@operato/scene-clone 10.0.0-beta.2 → 10.0.0-beta.65

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/README.md CHANGED
@@ -1,11 +1,39 @@
1
- # things-scene-clone
1
+ # @operato/scene-clone
2
2
 
3
- ## build
3
+ > Thing Scene component instance auto cloner.
4
4
 
5
- `$ yarn build`
5
+ <!-- AUTOGEN_BEGIN: do not edit between markers (run scripts/regenerate-readmes.mjs to update) -->
6
6
 
7
- | type | filename | for | tested |
8
- | ---- | ------------------------ | -------------- | ------ |
9
- | UMD | things-scene-clone.js | modern browser | O |
10
- | UMD | things-scene-clone-ie.js | ie 11 | O |
11
- | ESM | things-scene-clone.mjs | modern browser | O |
7
+ ## Components
8
+
9
+ - `Clone`
10
+
11
+ ## Templates (things-scene catalog)
12
+
13
+ | type | group | description |
14
+ |---|---|---|
15
+ | `clone` | etc | component cloner |
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ yarn add @operato/scene-clone
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```ts
26
+ import { Clone } from '@operato/scene-clone'
27
+ ```
28
+
29
+ ## Build
30
+
31
+ ```bash
32
+ yarn build
33
+ ```
34
+
35
+ Output: ESM module at `dist/index.js` (single bundle, no UMD/IE legacy).
36
+
37
+ _Version: 10.0.0-beta.2_
38
+
39
+ <!-- AUTOGEN_END -->
package/dist/clone.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component, ComponentNature, Container, Shape } from '@hatiolab/things-scene';
1
+ import { ComponentNature, Container, Shape } from '@hatiolab/things-scene';
2
2
  declare const Clone_base: (new (...args: any[]) => {
3
3
  contains(x: number, y: number): boolean;
4
4
  get path(): {
@@ -49,7 +49,7 @@ declare const Clone_base: (new (...args: any[]) => {
49
49
  get disposed(): boolean;
50
50
  isLayer(): boolean;
51
51
  isGroup(): boolean;
52
- isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component").Container;
52
+ isContainer(): this is Container;
53
53
  isLine(): boolean;
54
54
  isRoot(): boolean;
55
55
  isRootModel(): boolean;
@@ -65,9 +65,10 @@ declare const Clone_base: (new (...args: any[]) => {
65
65
  get(property: any): any;
66
66
  set(props: any, propval?: any): any;
67
67
  getState(property: any): any;
68
- setState(props: any, propval?: any): any;
68
+ setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
69
69
  get model(): any;
70
- get state(): any;
70
+ get state(): import("@hatiolab/things-scene").State;
71
+ get refid(): any;
71
72
  get hierarchy(): any;
72
73
  get volatile(): never[];
73
74
  _applyProps(target: any, props: any, options: any): any;
@@ -103,7 +104,7 @@ declare const Clone_base: (new (...args: any[]) => {
103
104
  draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
104
105
  prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
105
106
  postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
106
- prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
107
+ prepare(resolve: (component: import("@hatiolab/things-scene").Component) => void, reject: (reason: any) => void): void;
107
108
  prepareIf(condition: boolean): void;
108
109
  drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
109
110
  drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
@@ -154,16 +155,16 @@ declare const Clone_base: (new (...args: any[]) => {
154
155
  get started(): boolean;
155
156
  set started(v: boolean): any;
156
157
  get controls(): import("@hatiolab/things-scene").Control[] | undefined;
157
- findFirst(finder: string | ((c: Component) => boolean), ...others: any[]): Component | undefined;
158
- findAll(s: string | ((c: Component) => boolean), ...others: any[]): any[] | undefined;
159
- capture(x: number, y: number, except?: (c: Component) => boolean): any;
158
+ findFirst(finder: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): import("@hatiolab/things-scene").Component | undefined;
159
+ findAll(s: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): any[] | undefined;
160
+ capture(x: number, y: number, except?: (c: import("@hatiolab/things-scene").Component) => boolean): any;
160
161
  findAnchor(name: string): any;
161
- isDescendible(container: Component): boolean;
162
+ isDescendible(container: import("@hatiolab/things-scene").Component | any): boolean;
162
163
  getContext(component?: unknown): any;
163
- get root(): Component;
164
- get rootModel(): Component;
165
- get parent(): Component;
166
- set parent(v: Component): any;
164
+ get root(): import("@hatiolab/things-scene").Component;
165
+ get rootModel(): import("@hatiolab/things-scene").Component;
166
+ get parent(): import("@hatiolab/things-scene").Component;
167
+ set parent(v: import("@hatiolab/things-scene").Component): any;
167
168
  get scalable(): boolean;
168
169
  get stuck(): boolean;
169
170
  get capturable(): boolean;
@@ -188,47 +189,51 @@ declare const Clone_base: (new (...args: any[]) => {
188
189
  ondropfile(transfered: FileList, files: string[]): void;
189
190
  transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
190
191
  transcoordP2S(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
191
- transcoordS2T(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
192
- transcoordT2P(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
193
- transcoordT2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
194
- transcoordS2TR(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
195
- transcoordS2O(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
196
- transcoordC2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
197
- transcoordS2C(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
192
+ transcoordS2T(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
193
+ transcoordT2P(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
194
+ transcoordT2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
195
+ transcoordS2TR(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
196
+ transcoordS2O(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
197
+ transcoordC2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
198
+ transcoordS2C(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
198
199
  toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
199
200
  fromParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
200
- toScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
201
- fromScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
202
- toLocal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
203
- toGlobal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
204
- toOther(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
201
+ toScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
202
+ fromScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
203
+ toLocal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
204
+ toGlobal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
205
+ toOther(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
206
+ on<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
205
207
  on(name: string | object, callback: Function, context?: any): any;
208
+ off<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback?: ((...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void) | undefined, context?: any): any;
206
209
  off(name?: string | object, callback?: Function, context?: any): any;
210
+ once<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
207
211
  once(name: string | object, callback: Function, context?: any): any;
212
+ trigger<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, ...args: import("@hatiolab/things-scene").ComponentEventMap[K]): any;
208
213
  trigger(name: string, ...args: any[]): any;
209
214
  delegate_on(delegator: any): any;
210
215
  delegate_off(delegator: any): any;
211
216
  onchange(after: Record<string, any>, before: Record<string, any>): void;
212
217
  calculateBounds?(): void;
213
218
  oncreate_element?(element: HTMLElement): void;
214
- removeComponent(component: Component, ghost?: boolean): void;
215
- addComponent(component: Component, ghost?: boolean): void;
216
- insertComponentAt(component: Component, index: number, ghost?: boolean): void;
217
- getOverlay(component: Component): HTMLElement | undefined;
218
- findById(id: string): Component | undefined;
219
- findByRefid(ref: string | number): Component | undefined;
220
- findAllById(id: string): Component[];
219
+ removeComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
220
+ addComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
221
+ insertComponentAt(component: import("@hatiolab/things-scene").Component, index: number, ghost?: boolean): void;
222
+ getOverlay(component: import("@hatiolab/things-scene").Component): HTMLElement | undefined;
223
+ findById(id: string): import("@hatiolab/things-scene").Component | undefined;
224
+ findByRefid(ref: string | number): import("@hatiolab/things-scene").Component | undefined;
225
+ findAllById(id: string): import("@hatiolab/things-scene").Component[];
221
226
  resize(): void;
222
227
  fit(type?: string): void;
223
- get components(): Component[] | undefined;
228
+ get components(): import("@hatiolab/things-scene").Component[] | undefined;
224
229
  get layout(): any;
225
230
  get auxOverlay(): HTMLElement | undefined;
226
231
  get isReady(): boolean;
227
232
  get unitScale(): number;
228
- get selected(): Component[];
229
- set selected(_v: Component[]): any;
230
- get focused(): Component | null;
231
- set focused(_v: Component | null): any;
233
+ get selected(): import("@hatiolab/things-scene").Component[];
234
+ set selected(_v: import("@hatiolab/things-scene").Component[]): any;
235
+ get focused(): import("@hatiolab/things-scene").Component | null;
236
+ set focused(_v: import("@hatiolab/things-scene").Component | null): any;
232
237
  get hasSameParentForAllSelected(): boolean;
233
238
  set hasSameParentForAllSelected(_v: boolean): any;
234
239
  get fitMode(): string | undefined;
package/dist/clone.js.map CHANGED
@@ -1 +1 @@
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,wBAAwB,CAAA;AAEtH,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,eAAe;SAC7B;QACD;YACE,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ;SACnB;QACD;YACE,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,WAAW;SACtB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,eAAe;SAC7B;KACF;IACD,gBAAgB,EAAE,SAAS;IAC3B,IAAI,EAAE,uBAAuB;CAC9B,CAAA;AAED,SAAS,KAAK,CAAC,MAAW,EAAE,MAAc,EAAE,eAAuB;IACjE,IAAI,eAAe,GAAG,MAAM,CAA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AC,QAAQ,GAAG,KAAK,CAAA;oBACrB,OAAM;gBACR,CAAC;gBAED,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC9B,qBAAqB,CAAC,CAAC,CAAC,CAAA;gBAC1B,CAAC,EAAE,QAAQ,CAAC,CAAA;YACd,CAAC;YAED,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAC1B,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;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: any, 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"]}
1
+ {"version":3,"file":"clone.js","sourceRoot":"","sources":["../src/clone.ts"],"names":[],"mappings":";AAAA,OAAO,EAA8B,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE3G,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,eAAe;SAC7B;QACD;YACE,IAA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AM;QAEvC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAA;QAEzB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU;YAAE,OAAM;QAEjC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;YAE9D,IAAI,CAAC,MAAM;gBAAE,OAAM;YAEnB,IAAI,QAAQ,GAAG,GAAG;gBAAE,QAAQ,GAAG,GAAG,CAAA;YAElC,IAAI,IAAI,GAAG,IAAI,CAAA;YAEf,SAAS,CAAC;gBACR,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;oBACpF,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;oBACrB,OAAM;gBACR,CAAC;gBAED,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC9B,qBAAqB,CAAC,CAAC,CAAC,CAAA;gBAC1B,CAAC,EAAE,QAAQ,CAAC,CAAA;YACd,CAAC;YAED,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAC1B,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;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 { 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: any, 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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/scene-clone",
3
3
  "description": "Thing Scene component instance auto cloner.",
4
4
  "author": "heartyoh",
5
- "version": "10.0.0-beta.2",
5
+ "version": "10.0.0-beta.65",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@hatiolab/prettier-config": "^1.0.0",
35
- "@things-factory/builder": "^10.0.0-beta.1",
36
- "@things-factory/operato-board": "^10.0.0-beta.1",
35
+ "@things-factory/builder": "^10.0.0-zeta.1",
36
+ "@things-factory/operato-board": "^10.0.0-zeta.1",
37
37
  "@typescript-eslint/eslint-plugin": "^8.0.0",
38
38
  "@typescript-eslint/parser": "^8.0.0",
39
39
  "@web/dev-server": "^0.1.28",
@@ -58,5 +58,5 @@
58
58
  "prettier --write"
59
59
  ]
60
60
  },
61
- "gitHead": "350ece104754d007967cf8e3f54d0d157465e94a"
61
+ "gitHead": "99733bf39e2d279630d68844f19d9687272a4992"
62
62
  }