@operato/scene-clone 9.0.0-beta.0 → 9.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clone.js +8 -4
- package/dist/clone.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/things-scene.config.js +1 -1
package/dist/clone.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Model, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene';
|
|
2
3
|
const NATURE = {
|
|
3
4
|
mutable: false,
|
|
4
5
|
resizable: true,
|
|
@@ -54,7 +55,7 @@ function clone(cloner, target, targetRetention) {
|
|
|
54
55
|
targetComponent.parent.insertComponentAt(component, index + 1);
|
|
55
56
|
return component;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
let Clone = class Clone extends RectPath(Shape) {
|
|
58
59
|
constructor() {
|
|
59
60
|
super(...arguments);
|
|
60
61
|
this._started = false;
|
|
@@ -119,6 +120,9 @@ export default class Clone extends RectPath(Shape) {
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
123
|
+
};
|
|
124
|
+
Clone = __decorate([
|
|
125
|
+
sceneComponent('clone')
|
|
126
|
+
], Clone);
|
|
127
|
+
export default Clone;
|
|
124
128
|
//# sourceMappingURL=clone.js.map
|
package/dist/clone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../src/clone.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../src/clone.ts"],"names":[],"mappings":";AAAA,OAAO,EAAyC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBA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A;gBAC3B,OAAO,IAAI,CAAC,QAAQ,CAAA;YACtB,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA5EoB,KAAK;IADzB,cAAc,CAAC,OAAO,CAAC;GACH,KAAK,CA4EzB;eA5EoB,KAAK","sourcesContent":["import { Component, ComponentNature, Container, Model, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'duration',\n name: 'duration',\n property: 'duration',\n placeholder: 'milli-seconds'\n },\n {\n type: 'id-input',\n label: 'target',\n name: 'target'\n },\n {\n type: 'checkbox',\n label: 'repeat',\n name: 'repeat',\n property: 'repeat'\n },\n {\n type: 'checkbox',\n label: 'autostart',\n name: 'autostart',\n property: 'autostart'\n },\n {\n type: 'number',\n label: 'targetRetention',\n name: 'targetRetention',\n property: 'targetRetention',\n placeholder: 'milli-seconds'\n }\n ],\n 'value-property': 'started',\n help: 'scene/component/clone'\n}\n\nfunction clone(cloner: Component, target: string, targetRetention: number) {\n var targetComponent = cloner.root.findById(target)\n if (!targetComponent) return\n\n var clone = Object.assign(targetComponent.hierarchy, {\n templatePrefix: '',\n id: ''\n })\n\n if (targetRetention) clone.retention = targetRetention\n\n var component = Model.compile(clone, cloner.app)\n var index = targetComponent.parent.indexOf(targetComponent)\n targetComponent.parent.insertComponentAt(component, index + 1)\n\n return component\n}\n\n@sceneComponent('clone')\nexport default class Clone extends RectPath(Shape) {\n private _started: boolean = false\n private _timeout?: number\n\n added(parent: Container) {\n this.started = false\n setTimeout(() => {\n if (this.getState('autostart')) this.started = true\n }, 500)\n }\n\n dispose() {\n this.started = false\n super.dispose()\n }\n\n render(ctx: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n ctx.beginPath()\n\n ctx.fillStyle = 'black'\n ctx.strokeStyle = 'black'\n\n ctx.rect(left, top, width * 0.8, height * 0.8)\n ctx.fill()\n ctx.stroke()\n\n ctx.beginPath()\n\n ctx.rect(left + width * 0.2, top + height * 0.2, width * 0.8, height * 0.8)\n }\n\n get nature() {\n return NATURE\n }\n\n get started() {\n return this._started\n }\n\n set started(started) {\n if (!!this.started == !!started) return\n\n this._started = !!started\n\n if (!this.app?.isViewMode) return\n\n if (this._started) {\n var { repeat, duration, target, targetRetention } = this.state\n\n if (!target) return\n\n if (duration < 500) duration = 500\n\n let self = this\n\n function _() {\n if (!self._started || !clone(self, target, targetRetention) || !duration || !repeat) {\n self._started = false\n return\n }\n\n self._timeout = setTimeout(() => {\n requestAnimationFrame(_)\n }, duration)\n }\n\n requestAnimationFrame(_)\n } else {\n if (this._timeout) {\n clearTimeout(this._timeout)\n delete this._timeout\n }\n }\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Clone } from './clone';
|
|
1
|
+
export { default as Clone } from './clone.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Clone } from './clone';
|
|
1
|
+
export { default as Clone } from './clone.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { default as Clone } from './clone.js'\n"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"name": "@operato/scene-clone",
|
|
3
3
|
"description": "Thing Scene component instance auto cloner.",
|
|
4
4
|
"author": "heartyoh",
|
|
5
|
-
"version": "9.0.0-beta.
|
|
5
|
+
"version": "9.0.0-beta.15",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"module": "dist/index.js",
|
|
8
9
|
"license": "MIT",
|
|
@@ -31,14 +32,14 @@
|
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@hatiolab/prettier-config": "^1.0.0",
|
|
34
|
-
"@things-factory/builder": "^
|
|
35
|
-
"@things-factory/operato-board": "^
|
|
35
|
+
"@things-factory/builder": "^9.0.0-beta",
|
|
36
|
+
"@things-factory/operato-board": "^9.0.0-beta",
|
|
36
37
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
37
38
|
"@typescript-eslint/parser": "^4.33.0",
|
|
38
39
|
"@web/dev-server": "^0.1.28",
|
|
39
40
|
"concurrently": "^8.0.1",
|
|
40
|
-
"eslint": "^
|
|
41
|
-
"eslint-config-prettier": "^
|
|
41
|
+
"eslint": "^9.18.0",
|
|
42
|
+
"eslint-config-prettier": "^10.0.1",
|
|
42
43
|
"husky": "^8.0.3",
|
|
43
44
|
"lint-staged": "^13.2.2",
|
|
44
45
|
"prettier": "^2.4.1",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"prettier --write"
|
|
58
59
|
]
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "3a94a8a9ee8cb8de82ad331cb08b9e48d6625d31"
|
|
61
62
|
}
|
package/things-scene.config.js
CHANGED