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

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.d.ts CHANGED
@@ -1,5 +1,241 @@
1
- import { ComponentNature, Container, Shape } from '@hatiolab/things-scene';
2
- declare const Clone_base: typeof Shape;
1
+ import { Component, ComponentNature, Container, Shape } from '@hatiolab/things-scene';
2
+ declare const Clone_base: (new (...args: any[]) => {
3
+ contains(x: number, y: number): boolean;
4
+ get path(): {
5
+ x: any;
6
+ y: any;
7
+ }[];
8
+ set path(path: {
9
+ x: any;
10
+ y: any;
11
+ }[]): any;
12
+ get anchors(): {
13
+ name: string;
14
+ position: {
15
+ x: any;
16
+ y: any;
17
+ };
18
+ }[];
19
+ get bounds(): any;
20
+ set bounds(bounds: any): any;
21
+ render(ctx: CanvasRenderingContext2D): void;
22
+ _app: any;
23
+ _model: any;
24
+ _state: any;
25
+ _delta: any;
26
+ _animation: any;
27
+ _animate: any;
28
+ _parent: any;
29
+ _disposed: any;
30
+ _textHidden: any;
31
+ _text_substitutor: any;
32
+ _value_substitutor: any;
33
+ _mappings: any;
34
+ _realObject: import("@hatiolab/things-scene").IRealObject | undefined;
35
+ _cachedState: any;
36
+ updatedAt: any;
37
+ fontSize: any;
38
+ __cache__: any;
39
+ created(): void;
40
+ added(parent: any): void;
41
+ removed(parent: any): void;
42
+ ready(): Promise<void>;
43
+ touch(): void;
44
+ clearCache(...attrs: any[]): void;
45
+ removeSelf(completely: any): void;
46
+ resetAnimation(): void;
47
+ dispose(): void;
48
+ get nature(): import("@hatiolab/things-scene").ComponentNature;
49
+ get disposed(): boolean;
50
+ isLayer(): boolean;
51
+ isGroup(): boolean;
52
+ isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component").Container;
53
+ isLine(): boolean;
54
+ isRoot(): boolean;
55
+ isRootModel(): boolean;
56
+ is3dish(): boolean;
57
+ get is3dMode(): boolean;
58
+ isIn3DSpace(): boolean;
59
+ isTemplate(): boolean;
60
+ isHTMLElement(): boolean;
61
+ isConnectable(): boolean;
62
+ isIdentifiable(): boolean;
63
+ isPositionable(): boolean;
64
+ replaceRefids(replaceMap: any): void;
65
+ get(property: any): any;
66
+ set(props: any, propval?: any): any;
67
+ getState(property: any): any;
68
+ setState(props: any, propval?: any): any;
69
+ get model(): any;
70
+ get state(): any;
71
+ get hierarchy(): any;
72
+ get volatile(): never[];
73
+ _applyProps(target: any, props: any, options: any): any;
74
+ move(offset: {
75
+ x: number;
76
+ y: number;
77
+ }, ...args: boolean[]): void;
78
+ symmetryX(x?: number): void;
79
+ symmetryY(y: number): void;
80
+ adjustResize(bounds: import("@hatiolab/things-scene").BOUNDS, origin_bounds: import("@hatiolab/things-scene").BOUNDS, diagonal: boolean): {
81
+ left: any;
82
+ top: any;
83
+ width: any;
84
+ height: any;
85
+ };
86
+ adjustRotation(rotation: number, step: boolean): number;
87
+ outline(progress: number): any;
88
+ get center(): import("@hatiolab/things-scene").POINT;
89
+ set center(p: import("@hatiolab/things-scene").POINT): any;
90
+ get location(): import("@hatiolab/things-scene").POINT;
91
+ set location(l: import("@hatiolab/things-scene").POINT): any;
92
+ get rotate(): import("@hatiolab/things-scene").POINT;
93
+ set rotate(r: import("@hatiolab/things-scene").POINT): any;
94
+ get dimension(): import("@hatiolab/things-scene").DIMENSION;
95
+ set dimension(d: import("@hatiolab/things-scene").DIMENSION): any;
96
+ get drawPath(): import("@hatiolab/things-scene").POINT[];
97
+ get rotatePoint(): import("@hatiolab/things-scene").POINT;
98
+ get mutable(): boolean;
99
+ get resizable(): boolean;
100
+ get rotatable(): boolean;
101
+ buildRealObject(): import("@hatiolab/things-scene").IRealObject | undefined;
102
+ get realObject(): import("@hatiolab/things-scene").IRealObject | undefined;
103
+ draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
104
+ prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
105
+ postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
106
+ prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
107
+ prepareIf(condition: boolean): void;
108
+ drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
109
+ drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
110
+ drawFill(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
111
+ get strokeStyle(): any;
112
+ set strokeStyle(v: any): any;
113
+ get fillStyle(): any;
114
+ set fillStyle(v: any): any;
115
+ get fontColor(): string;
116
+ set fontColor(v: string): any;
117
+ get rotation(): number;
118
+ set rotation(v: number): any;
119
+ get decorators(): string[];
120
+ get decotag(): string;
121
+ get hidden(): boolean;
122
+ set hidden(v: boolean): any;
123
+ get tag(): string;
124
+ set tag(v: string): any;
125
+ get appendum(): any;
126
+ set appendum(v: any): any;
127
+ defaultTextSubstitutor(): string;
128
+ textLines(context?: import("@hatiolab/things-scene").SceneRenderContext): any[][];
129
+ get font(): string;
130
+ get lineHeight(): number;
131
+ get textSubstitutor(): () => string;
132
+ get text(): string;
133
+ set text(v: string): any;
134
+ get textBounds(): import("@hatiolab/things-scene").BOUNDS;
135
+ get textRotation(): number;
136
+ get textHidden(): boolean;
137
+ set textHidden(v: boolean): any;
138
+ get hasTextProperty(): boolean;
139
+ animate(opts: import("@hatiolab/things-scene").AnimationConfig): any;
140
+ effect(context: import("@hatiolab/things-scene").SceneRenderContext, model: any): void;
141
+ serialize(...others: any[]): string;
142
+ trim(): void;
143
+ closeScene(data: any): void;
144
+ delta(attr?: string | object, value?: any): any;
145
+ invalidate(): void;
146
+ get value(): any;
147
+ set value(v: any): any;
148
+ get data(): any;
149
+ set data(v: any): any;
150
+ set tap(v: any): any;
151
+ get mappings(): any[];
152
+ get retention(): number;
153
+ get animation(): import("@hatiolab/things-scene").AnimationController | undefined;
154
+ get started(): boolean;
155
+ set started(v: boolean): any;
156
+ 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;
160
+ findAnchor(name: string): any;
161
+ isDescendible(container: Component): boolean;
162
+ getContext(component?: unknown): any;
163
+ get root(): Component;
164
+ get rootModel(): Component;
165
+ get parent(): Component;
166
+ set parent(v: Component): any;
167
+ get scalable(): boolean;
168
+ get stuck(): boolean;
169
+ get capturable(): boolean;
170
+ get position(): string;
171
+ get origin(): string;
172
+ get offset(): import("@hatiolab/things-scene").POINT;
173
+ get app(): import("@hatiolab/things-scene").ApplicationContext;
174
+ drawEffect(context: import("@hatiolab/things-scene").SceneRenderContext): void;
175
+ prepareFill(resolve: Function, reject: Function): void;
176
+ prepareFillIf(condition: boolean): void;
177
+ onchangeFill(after: Record<string, any>, before: Record<string, any>): void;
178
+ drawImage(context: import("@hatiolab/things-scene").SceneRenderContext, image: HTMLImageElement, left: number, top: number, width: number, height: number): void;
179
+ mutateBounds(logic: ((bounds: import("@hatiolab/things-scene").BOUNDS) => import("@hatiolab/things-scene").BOUNDS | void) | null, context?: any): void;
180
+ mutatePath(beforeLogic: ((path: import("@hatiolab/things-scene").POINT[]) => import("@hatiolab/things-scene").POINT[] | void) | null, afterLogic: ((path: import("@hatiolab/things-scene").POINT[]) => import("@hatiolab/things-scene").POINT[] | void) | null, context?: any): void;
181
+ access(accessor: string): any;
182
+ substitute(template: string, data: any): string | undefined;
183
+ onchangeMappings(after: Record<string, any>, before: Record<string, any>): void;
184
+ onchangeData(after: Record<string, any>, before: Record<string, any>): void;
185
+ buildMappings(): void;
186
+ executeMappings(force?: boolean): void;
187
+ disposeMappings(): void;
188
+ ondropfile(transfered: FileList, files: string[]): void;
189
+ transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
190
+ 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;
198
+ toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
199
+ 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;
205
+ on(name: string | object, callback: Function, context?: any): any;
206
+ off(name?: string | object, callback?: Function, context?: any): any;
207
+ once(name: string | object, callback: Function, context?: any): any;
208
+ trigger(name: string, ...args: any[]): any;
209
+ delegate_on(delegator: any): any;
210
+ delegate_off(delegator: any): any;
211
+ onchange(after: Record<string, any>, before: Record<string, any>): void;
212
+ calculateBounds?(): void;
213
+ 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[];
221
+ resize(): void;
222
+ fit(type?: string): void;
223
+ get components(): Component[] | undefined;
224
+ get layout(): any;
225
+ get auxOverlay(): HTMLElement | undefined;
226
+ get isReady(): boolean;
227
+ 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;
232
+ get hasSameParentForAllSelected(): boolean;
233
+ set hasSameParentForAllSelected(_v: boolean): any;
234
+ get fitMode(): string | undefined;
235
+ set fitMode(_v: string | undefined): any;
236
+ get element(): HTMLElement | null;
237
+ set element(_v: HTMLElement | null): any;
238
+ }) & typeof Shape;
3
239
  export default class Clone extends Clone_base {
4
240
  private _started;
5
241
  private _timeout?;
package/dist/clone.js CHANGED
@@ -56,10 +56,8 @@ function clone(cloner, target, targetRetention) {
56
56
  return component;
57
57
  }
58
58
  let Clone = class Clone extends RectPath(Shape) {
59
- constructor() {
60
- super(...arguments);
61
- this._started = false;
62
- }
59
+ _started = false;
60
+ _timeout;
63
61
  added(parent) {
64
62
  this.started = false;
65
63
  setTimeout(() => {
@@ -89,11 +87,10 @@ let Clone = class Clone extends RectPath(Shape) {
89
87
  return this._started;
90
88
  }
91
89
  set started(started) {
92
- var _a;
93
90
  if (!!this.started == !!started)
94
91
  return;
95
92
  this._started = !!started;
96
- if (!((_a = this.app) === null || _a === void 0 ? void 0 : _a.isViewMode))
93
+ if (!this.app?.isViewMode)
97
94
  return;
98
95
  if (this._started) {
99
96
  var { repeat, duration, target, targetRetention } = this.state;
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,IA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B,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"]}
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;IA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,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 { 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"]}
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": "9.1.1",
5
+ "version": "10.0.0-beta.2",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "things-scene": true,
11
11
  "publishConfig": {
12
12
  "access": "public",
13
- "@oprato:registry": "https://registry.npmjs.org"
13
+ "@operato:registry": "https://registry.npmjs.org"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -22,27 +22,27 @@
22
22
  "serve:dev": "npm run serve",
23
23
  "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
24
24
  "build": "tsc",
25
- "prepublish": "tsc",
26
- "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
27
- "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
25
+ "prepublishOnly": "tsc",
26
+ "lint": "eslint src/ && prettier \"src/**/*.ts\" --check",
27
+ "format": "eslint src/ --fix && prettier \"src/**/*.ts\" --write",
28
28
  "migration": "things-factory-migration"
29
29
  },
30
30
  "dependencies": {
31
- "@hatiolab/things-scene": "^9.0.0"
31
+ "@hatiolab/things-scene": "^10.0.0-beta.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@hatiolab/prettier-config": "^1.0.0",
35
- "@things-factory/builder": "^9.0.0",
36
- "@things-factory/operato-board": "^9.0.0",
37
- "@typescript-eslint/eslint-plugin": "^4.33.0",
38
- "@typescript-eslint/parser": "^4.33.0",
35
+ "@things-factory/builder": "^10.0.0-beta.1",
36
+ "@things-factory/operato-board": "^10.0.0-beta.1",
37
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
38
+ "@typescript-eslint/parser": "^8.0.0",
39
39
  "@web/dev-server": "^0.1.28",
40
40
  "concurrently": "^8.0.1",
41
41
  "eslint": "^9.18.0",
42
42
  "eslint-config-prettier": "^10.0.1",
43
43
  "husky": "^8.0.3",
44
- "lint-staged": "^13.2.2",
45
- "prettier": "^2.4.1",
44
+ "lint-staged": "^15.2.2",
45
+ "prettier": "^3.2.5",
46
46
  "tslib": "^2.3.1",
47
47
  "typescript": "^5.0.4"
48
48
  },
@@ -58,5 +58,5 @@
58
58
  "prettier --write"
59
59
  ]
60
60
  },
61
- "gitHead": "14946e6f709e9b427a43ac6c5751b4fdb58961dd"
61
+ "gitHead": "350ece104754d007967cf8e3f54d0d157465e94a"
62
62
  }