Skip to content

Commit

Permalink
Merge branch 'v1.x' of github.com:ct-js/ct-js into v1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Mar 2, 2021
2 parents 1d3d095 + 21caa7c commit 8c0b377
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 7 deletions.
14 changes: 14 additions & 0 deletions app/data/ct.libs/nanoid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Nano ID for ct.js

This catmod is a bit modified and minified `nanoid` [npm module](https://github.com/ai/nanoid). The original module is made by Andrey Sitnik and dozens of contributors, and is distributed under the MIT license.

Nano ID is an URL-friendly, secure ID generator that is shorter but more collision-resilient than GUID.

# Usage

```js
// Regular ID
var id = ct.nanoid.generate() //=> "V1StGXR8_Z5jdHi6B-myT"
// An ID of a specific size
var shortId = ct.nanoid.generate(10) //=> "IRFa-VaY2b"
```
26 changes: 26 additions & 0 deletions app/data/ct.libs/nanoid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Nano ID (https://github.com/ai/nanoid)
The MIT License (MIT)
Copyright 2017 Andrey Sitnik <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

(function(exports){'use strict';let urlAlphabet='ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';if(typeof crypto==='undefined'){throw new Error('Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.')}let random=bytes=>crypto.getRandomValues(new Uint8Array(bytes));let customRandom=(alphabet,size,getRandom)=>{let mask=(2<<(Math.log(alphabet.length-1)/Math.LN2))-1;let step= - ~((1.6*mask*size)/alphabet.length);return()=>{let id='';while(true){let bytes=getRandom(step);let j=step;while(j--){id+=alphabet[bytes[j]&mask]||'';if(id.length===size){return id}}}}};let customAlphabet=(alphabet,size)=>customRandom(alphabet,size,random);let nanoid=(size=21)=>{let id='';let bytes=crypto.getRandomValues(new Uint8Array(size));while(size--){let byte=bytes[size]&63;if(byte<36){id+=byte.toString(36)}else if(byte<62){id+=(byte-26).toString(36).toUpperCase()}else if(byte<63){id+='_'}else{id+='-'}}return id};exports.customAlphabet=customAlphabet;exports.customRandom=customRandom;exports.generate=nanoid;exports.random=random;exports.urlAlphabet=urlAlphabet;return exports}(ct.nanoid={}));
14 changes: 14 additions & 0 deletions app/data/ct.libs/nanoid/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"main": {
"name": "Nano ID",
"tagline": "A tiny, secure, URL-friendly, unique string ID generator for JavaScript, bundled for ct.js.",
"version": "3.1.20",
"packageName": "nanoid",
"authors": [{
"name": "Andrey Sitnik and contributors"
}],
"categories": [
"utilities"
]
}
}
4 changes: 3 additions & 1 deletion app/data/ct.release/backgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class Background extends PIXI.TilingSprite {
constructor(texName, frame = 0, depth = 0, exts = {}) {
var width = ct.camera.width,
height = ct.camera.height;
const texture = ct.res.getTexture(texName, frame || 0);
const texture = texName instanceof PIXI.Texture ?
texName :
ct.res.getTexture(texName, frame || 0);
if (exts.repeat === 'no-repeat' || exts.repeat === 'repeat-x') {
height = texture.height * (exts.scaleY || 1);
}
Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ const bakePackages = async () => {
const NwBuilder = require('nw-builder');
// Use the appropriate icon for each release channel
if (nightly) {
await fs.copy('./buildAssets/icon.png', './app/ct_ide.png');
} else {
await fs.copy('./buildAssets/nightly.png', './app/ct_ide.png');
} else {
await fs.copy('./buildAssets/icon.png', './app/ct_ide.png');
}
await fs.remove(path.join('./build', `ctjs - v${pack.version}`));
var nw = new NwBuilder({
Expand Down
9 changes: 6 additions & 3 deletions src/riotTags/debugger/debugger-screen-embedded.tag
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
Exposes this.reloadGame
debugger-screen-embedded(class="{opts.class} {flexrow: verticalLayout, flexcol: !verticalLayout}")
webview.tall#thePreview(
ref="gameView"
partition="persist:trusted"
ref="gameView" allownw nwfaketop
allownw nwfaketop
)
.aResizer(ref="gutter" onmousedown="{gutterMouseDown}" class="{vertical: verticalLayout, horizontal: !verticalLayout}")
.flexfix(
style="flex: 0 0 auto; {verticalLayout? 'width:'+width+'px' : 'height:'+height+'px'}"
)
webview.tall.flexfix-body(
partition="persist:trusted" src="empty.html"
ref="devtoolsView" allownw nwfaketop
ref="devtoolsView"
src="empty.html"
partition="persist:trusted"
style="overflow: hidden;"
)
//allownw nwfaketop
.flexfix-footer.aDebuggerToolbar.noshrink(
class="{vertical: verticalLayout} {tight: (verticalLayout && width < 1000) || (!verticalLayout && window.innerWidth < 1000)}"
)
Expand Down
2 changes: 2 additions & 0 deletions src/riotTags/shared/extensions-editor.tag
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ extensions-editor
class="{compact: parent.opts.compact, wide: parent.opts.wide}"
val="{parent.opts.entity[ext.key] || ext.default}"
onselected="{writeUid(ext.key)}"
showempty="yep"
)
.aPoint2DInput(if="{ext.type === 'point2D'}" class="{compact: parent.opts.compact, wide: parent.opts.wide}")
label
Expand All @@ -131,6 +132,7 @@ extensions-editor
class="{compact: parent.opts.compact, wide: parent.opts.wide}"
val="{parent.opts.entity[ext.key] || ext.default}"
onselected="{writeUid(ext.key)}"
showempty="yep"
)
color-input(
if="{ext.type === 'color'}"
Expand Down
3 changes: 2 additions & 1 deletion src/typedefs/ct.js/Background.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface IBackgroundTemplate {

declare class Background extends PIXI.TilingSprite {
constructor(bgName: string, frame: number, depth: number, exts: object);
constructor(pixiTexture: PIXI.Texture, frame: number, depth: number, exts: object);
depth: number;
shiftX: number;
shiftY: number;
Expand All @@ -14,4 +15,4 @@ declare class Background extends PIXI.TilingSprite {
scaleX: number;
scaleY: number;
repeat: string;
}
}

0 comments on commit 8c0b377

Please sign in to comment.