@operato/scene-timer 9.1.1 → 10.0.0-beta.1

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.
@@ -1,9 +1,245 @@
1
- import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
- declare const DueTimer_base: typeof Shape;
1
+ import { Component, ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
+ declare const DueTimer_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.js").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 DueTimer extends DueTimer_base {
4
240
  private _round;
5
241
  get nature(): ComponentNature;
6
- ready(): void;
242
+ ready(): Promise<void>;
7
243
  onchange(after: Properties): void;
8
244
  counting(): void;
9
245
  render(context: CanvasRenderingContext2D): void;
package/dist/duetimer.js CHANGED
@@ -46,14 +46,12 @@ const NATURE = {
46
46
  help: 'scene/component/duetimer'
47
47
  };
48
48
  let DueTimer = class DueTimer extends RectPath(Shape) {
49
- constructor() {
50
- super(...arguments);
51
- this._round = 0;
52
- }
49
+ _round = 0;
53
50
  get nature() {
54
51
  return NATURE;
55
52
  }
56
- ready() {
53
+ async ready() {
54
+ await super.ready();
57
55
  if (!this.app.isViewMode) {
58
56
  return;
59
57
  }
@@ -67,7 +65,6 @@ let DueTimer = class DueTimer extends RectPath(Shape) {
67
65
  }
68
66
  }
69
67
  counting() {
70
- // @ts-ignore
71
68
  if (this.disposed) {
72
69
  return;
73
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../src/duetimer.ts"],"names":[],"mappings":";AAAA,OAAO,EAA0C,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEhH;;GAEG;AACH,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK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AI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO;QACjB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,GAAG,CAAC,GAAG;QACT,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AApHoB,QAAQ;IAD5B,cAAc,CAAC,UAAU,CAAC;GACN,QAAQ,CAoH5B;eApHoB,QAAQ","sourcesContent":["import { Component, ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\n/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport format from './libs/format.js'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'due',\n name: 'due',\n placeholder: 'timestamp'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'select',\n label: 'data-reflection',\n name: 'dataReflection',\n property: {\n options: ['', 'countdown', 'round']\n }\n },\n {\n type: 'color',\n label: 'progress-color',\n name: 'progressColor',\n property: 'progressColor'\n }\n ],\n 'value-property': 'due',\n help: 'scene/component/duetimer'\n}\n\n@sceneComponent('duetimer')\nexport default class DueTimer extends RectPath(Shape) {\n private _round: number = 0\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n var { due = 0 } = this.state\n\n this.timeout = Math.max(Math.round((due - Date.now()) / 1000), 0)\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this.timeout = Math.max(Math.round((this.due - Date.now()) / 1000), 0)\n this.counting()\n }\n }\n\n counting() {\n // @ts-ignore\n if (this.disposed) {\n return\n }\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n const { dataReflection = 'countdown' } = this.state\n\n if (countdown > 0) {\n const text = format(countdown, this.getState('format-run'))\n\n this.text = text\n\n if (dataReflection != 'round') {\n this.setState('data', text)\n }\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n const text = format(countdown, this.getState('format-stop'))\n\n this.text = text\n\n this.setState('data', dataReflection != 'round' ? text : ++this._round)\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, progressColor = 'transparent' } = this.state\n\n // progress의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n context.fillStyle = progressColor\n context.fill()\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get due() {\n return Number(this.getState('due') || 0)\n }\n\n set due(due) {\n this.setState('due', due)\n }\n\n get countdown() {\n const due = this.due\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n\n get round() {\n return this._round\n }\n}\n"]}
1
+ {"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../src/duetimer.ts"],"names":[],"mappings":";AAAA,OAAO,EAA0C,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEhH;;GAEG;AACH,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,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,KAAK;YACZ,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,WAAW;SACzB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,gBAAgB;YACtB,QAAQ,EAAE;gBACR,OAAO,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC;aACpC;SACF;QACD;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,gBAAgB;YACvB,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,eAAe;SAC1B;KACF;IACD,gBAAgB,EAAE,KAAK;IACvB,IAAI,EAAE,0BAA0B;CACjC,CAAA;AAGc,IAAM,QAAQ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C,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AArHoB,QAAQ;IAD5B,cAAc,CAAC,UAAU,CAAC;GACN,QAAQ,CAqH5B;eArHoB,QAAQ","sourcesContent":["import { Component, ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\n/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport format from './libs/format.js'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'due',\n name: 'due',\n placeholder: 'timestamp'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'select',\n label: 'data-reflection',\n name: 'dataReflection',\n property: {\n options: ['', 'countdown', 'round']\n }\n },\n {\n type: 'color',\n label: 'progress-color',\n name: 'progressColor',\n property: 'progressColor'\n }\n ],\n 'value-property': 'due',\n help: 'scene/component/duetimer'\n}\n\n@sceneComponent('duetimer')\nexport default class DueTimer extends RectPath(Shape) {\n private _round: number = 0\n\n get nature() {\n return NATURE\n }\n\n async ready() {\n await super.ready()\n\n if (!this.app.isViewMode) {\n return\n }\n\n var { due = 0 } = this.state\n\n this.timeout = Math.max(Math.round((due - Date.now()) / 1000), 0)\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this.timeout = Math.max(Math.round((this.due - Date.now()) / 1000), 0)\n this.counting()\n }\n }\n\n counting() {\n if (this.disposed) {\n return\n }\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n const { dataReflection = 'countdown' } = this.state\n\n if (countdown > 0) {\n const text = format(countdown, this.getState('format-run'))\n\n this.text = text\n\n if (dataReflection != 'round') {\n this.setState('data', text)\n }\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n const text = format(countdown, this.getState('format-stop'))\n\n this.text = text\n\n this.setState('data', dataReflection != 'round' ? text : ++this._round)\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, progressColor = 'transparent' } = this.state\n\n // progress의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n context.fillStyle = progressColor\n context.fill()\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get due() {\n return Number(this.getState('due') || 0)\n }\n\n set due(due) {\n this.setState('due', due)\n }\n\n get countdown() {\n const due = this.due\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n\n get round() {\n return this._round\n }\n}\n"]}
package/dist/timer.d.ts CHANGED
@@ -1,10 +1,246 @@
1
- import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
- declare const Timer_base: typeof Shape;
1
+ import { Component, ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
+ declare const Timer_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.js").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 Timer extends Timer_base {
4
240
  private _due?;
5
241
  private _round;
6
242
  get nature(): ComponentNature;
7
- ready(): void;
243
+ ready(): Promise<void>;
8
244
  onchange(after: Properties): void;
9
245
  counting(): void;
10
246
  render(context: CanvasRenderingContext2D): void;
package/dist/timer.js CHANGED
@@ -69,14 +69,13 @@ const NATURE = {
69
69
  help: 'scene/component/timer'
70
70
  };
71
71
  let Timer = class Timer extends RectPath(Shape) {
72
- constructor() {
73
- super(...arguments);
74
- this._round = 0;
75
- }
72
+ _due;
73
+ _round = 0;
76
74
  get nature() {
77
75
  return NATURE;
78
76
  }
79
- ready() {
77
+ async ready() {
78
+ await super.ready();
80
79
  if (!this.app.isViewMode) {
81
80
  return;
82
81
  }
@@ -90,7 +89,6 @@ let Timer = class Timer extends RectPath(Shape) {
90
89
  }
91
90
  }
92
91
  counting() {
93
- // @ts-ignore
94
92
  if (this.disposed) {
95
93
  return;
96
94
  }
package/dist/timer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"timer.js","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAA0C,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEhH,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,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,MAAM;YACb,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,MAAM;SACpB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,OAAO;SACrB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,YAAY;YAClB,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;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO;QACjB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,SAAS;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,CAAA;QACV,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AArHoB,KAAK;IADzB,cAAc,CAAC,OAAO,CAAC;GACH,KAAK,CAqHzB;eArHoB,KAAK","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\nimport format from './libs/format.js'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'days',\n name: 'days',\n placeholder: 'days'\n },\n {\n type: 'number',\n label: 'hours',\n name: 'hours',\n placeholder: 'hours'\n },\n {\n type: 'number',\n label: 'minutes',\n name: 'minutes',\n placeholder: 'minutes'\n },\n {\n type: 'number',\n label: 'seconds',\n name: 'seconds',\n placeholder: 'seconds'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'color',\n label: 'progress-color',\n name: 'progressColor',\n property: 'progressColor'\n },\n {\n type: 'select',\n label: 'data-reflection',\n name: 'dataReflection',\n property: {\n options: ['countdown', 'round']\n }\n },\n {\n type: 'boolean',\n label: 'repeat',\n name: 'repeat'\n }\n ],\n 'value-property': 'timeout',\n help: 'scene/component/timer'\n}\n\n@sceneComponent('timer')\nexport default class Timer extends RectPath(Shape) {\n private _due?: number\n private _round: number = 0\n\n get nature() {\n return NATURE\n }\n\n ready() {\n if (!this.app.isViewMode) {\n return\n }\n\n var { days = 0, hours = 0, minutes = 0, seconds = 0 } = this.state\n\n this.timeout = days * 86400 + hours * 3600 + minutes * 60 + seconds\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n\n counting() {\n // @ts-ignore\n if (this.disposed) {\n return\n }\n\n const { dataReflection = 'countdown' } = this.state\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n\n if (countdown > 0) {\n const text = format(countdown, this.getState('format-run'))\n this.text = text\n\n if (dataReflection != 'round') {\n this.setState('data', text)\n }\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n const text = format(countdown, this.getState('format-stop'))\n this.text = text\n\n this.setState('data', dataReflection != 'round' ? text : ++this._round)\n\n if (this.state.repeat) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, progressColor = 'transparent' } = this.state\n\n // progress의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n context.fillStyle = progressColor\n context.fill()\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get countdown() {\n const timeout = this.timeout\n if (!timeout || timeout < 0) {\n return 0\n }\n\n const due = this._due || 0\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n\n get round() {\n return this._round\n }\n}\n"]}
1
+ {"version":3,"file":"timer.js","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAA0C,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEhH,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,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,MAAM;YACb,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,MAAM;SACpB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,OAAO;SACrB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,SAAS;SACvB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,UAAU;SACxB;QACD;YACE,I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AAA;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,OAAO;QACjB,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,SAAS;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,CAAA;QACV,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AAtHoB,KAAK;IADzB,cAAc,CAAC,OAAO,CAAC;GACH,KAAK,CAsHzB;eAtHoB,KAAK","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\n\nimport format from './libs/format.js'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'number',\n label: 'days',\n name: 'days',\n placeholder: 'days'\n },\n {\n type: 'number',\n label: 'hours',\n name: 'hours',\n placeholder: 'hours'\n },\n {\n type: 'number',\n label: 'minutes',\n name: 'minutes',\n placeholder: 'minutes'\n },\n {\n type: 'number',\n label: 'seconds',\n name: 'seconds',\n placeholder: 'seconds'\n },\n {\n type: 'string',\n label: 'format-run',\n name: 'format-run',\n placeholder: 'hh:mm:ss'\n },\n {\n type: 'string',\n label: 'format-stop',\n name: 'format-stop',\n placeholder: '--:--:--'\n },\n {\n type: 'color',\n label: 'progress-color',\n name: 'progressColor',\n property: 'progressColor'\n },\n {\n type: 'select',\n label: 'data-reflection',\n name: 'dataReflection',\n property: {\n options: ['countdown', 'round']\n }\n },\n {\n type: 'boolean',\n label: 'repeat',\n name: 'repeat'\n }\n ],\n 'value-property': 'timeout',\n help: 'scene/component/timer'\n}\n\n@sceneComponent('timer')\nexport default class Timer extends RectPath(Shape) {\n private _due?: number\n private _round: number = 0\n\n get nature() {\n return NATURE\n }\n\n async ready() {\n await super.ready()\n\n if (!this.app.isViewMode) {\n return\n }\n\n var { days = 0, hours = 0, minutes = 0, seconds = 0 } = this.state\n\n this.timeout = days * 86400 + hours * 3600 + minutes * 60 + seconds\n }\n\n onchange(after: Properties) {\n if ('timeout' in after) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n\n counting() {\n if (this.disposed) {\n return\n }\n\n const { dataReflection = 'countdown' } = this.state\n\n requestAnimationFrame(() => {\n const countdown = this.countdown\n\n if (countdown > 0) {\n const text = format(countdown, this.getState('format-run'))\n this.text = text\n\n if (dataReflection != 'round') {\n this.setState('data', text)\n }\n\n setTimeout(() => {\n this.counting()\n }, 1000)\n } else {\n const text = format(countdown, this.getState('format-stop'))\n this.text = text\n\n this.setState('data', dataReflection != 'round' ? text : ++this._round)\n\n if (this.state.repeat) {\n this._due = Date.now() + this.timeout * 1000\n this.counting()\n }\n }\n })\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, height, width, progressColor = 'transparent' } = this.state\n\n // progress의 색상\n context.beginPath()\n context.rect(left, top, width, height)\n this.drawFill(context)\n\n // value의 색상\n context.beginPath()\n\n var progress = (this.countdown / this.timeout) * 100\n\n if (!isNaN(progress)) {\n progress = width - (width * progress) / 100\n progress = Math.max(Math.min(progress, width), 0)\n\n context.rect(left, top, progress, height)\n context.fillStyle = progressColor\n context.fill()\n\n context.beginPath()\n }\n\n // stroke\n context.rect(left, top, width, height)\n }\n\n postrender(context: CanvasRenderingContext2D) {\n this.drawStroke(context)\n this.drawText(context)\n }\n\n get timeout() {\n return Number(this.getState('timeout') || 0)\n }\n\n set timeout(timeout) {\n this.setState('timeout', Number(timeout) || 0)\n }\n\n get countdown() {\n const timeout = this.timeout\n if (!timeout || timeout < 0) {\n return 0\n }\n\n const due = this._due || 0\n const now = Date.now()\n\n return Math.max(Math.round((due - now) / 1000), 0)\n }\n\n get round() {\n return this._round\n }\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/scene-timer",
3
3
  "description": "Timer component for things-scene",
4
4
  "author": "heartyoh",
5
- "version": "9.1.1",
5
+ "version": "10.0.0-beta.1",
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": "bb127dd516b9e962fb2d0a24bc2d8c5e108f06fb"
62
62
  }