@operato/scene-timer 10.0.0-beta.22 → 10.0.0-beta.30
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/duetimer.d.ts +37 -37
- package/dist/duetimer.js.map +1 -1
- package/dist/timer.d.ts +37 -37
- package/dist/timer.js.map +1 -1
- package/package.json +2 -2
package/dist/duetimer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
|
|
2
2
|
declare const DueTimer_base: (new (...args: any[]) => {
|
|
3
3
|
contains(x: number, y: number): boolean;
|
|
4
4
|
get path(): {
|
|
@@ -49,7 +49,7 @@ declare const DueTimer_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
|
|
52
|
+
isContainer(): this is import("@hatiolab/things-scene").Container;
|
|
53
53
|
isLine(): boolean;
|
|
54
54
|
isRoot(): boolean;
|
|
55
55
|
isRootModel(): boolean;
|
|
@@ -65,9 +65,9 @@ declare const DueTimer_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:
|
|
68
|
+
setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
|
|
69
69
|
get model(): any;
|
|
70
|
-
get state():
|
|
70
|
+
get state(): import("@hatiolab/things-scene").State;
|
|
71
71
|
get hierarchy(): any;
|
|
72
72
|
get volatile(): never[];
|
|
73
73
|
_applyProps(target: any, props: any, options: any): any;
|
|
@@ -103,7 +103,7 @@ declare const DueTimer_base: (new (...args: any[]) => {
|
|
|
103
103
|
draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
104
104
|
prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
105
105
|
postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
106
|
-
prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
|
|
106
|
+
prepare(resolve: (component: import("@hatiolab/things-scene").Component) => void, reject: (reason: any) => void): void;
|
|
107
107
|
prepareIf(condition: boolean): void;
|
|
108
108
|
drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
109
109
|
drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
|
|
@@ -154,16 +154,16 @@ declare const DueTimer_base: (new (...args: any[]) => {
|
|
|
154
154
|
get started(): boolean;
|
|
155
155
|
set started(v: boolean): any;
|
|
156
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;
|
|
157
|
+
findFirst(finder: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): import("@hatiolab/things-scene").Component | undefined;
|
|
158
|
+
findAll(s: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): any[] | undefined;
|
|
159
|
+
capture(x: number, y: number, except?: (c: import("@hatiolab/things-scene").Component) => boolean): any;
|
|
160
160
|
findAnchor(name: string): any;
|
|
161
|
-
isDescendible(container: Component): boolean;
|
|
161
|
+
isDescendible(container: import("@hatiolab/things-scene").Component): boolean;
|
|
162
162
|
getContext(component?: unknown): any;
|
|
163
|
-
get root(): Component;
|
|
164
|
-
get rootModel(): Component;
|
|
165
|
-
get parent(): Component;
|
|
166
|
-
set parent(v: Component): any;
|
|
163
|
+
get root(): import("@hatiolab/things-scene").Component;
|
|
164
|
+
get rootModel(): import("@hatiolab/things-scene").Component;
|
|
165
|
+
get parent(): import("@hatiolab/things-scene").Component;
|
|
166
|
+
set parent(v: import("@hatiolab/things-scene").Component): any;
|
|
167
167
|
get scalable(): boolean;
|
|
168
168
|
get stuck(): boolean;
|
|
169
169
|
get capturable(): boolean;
|
|
@@ -188,20 +188,20 @@ declare const DueTimer_base: (new (...args: any[]) => {
|
|
|
188
188
|
ondropfile(transfered: FileList, files: string[]): void;
|
|
189
189
|
transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
|
|
190
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;
|
|
191
|
+
transcoordS2T(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
192
|
+
transcoordT2P(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
193
|
+
transcoordT2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
194
|
+
transcoordS2TR(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
195
|
+
transcoordS2O(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
196
|
+
transcoordC2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
197
|
+
transcoordS2C(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
198
198
|
toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
|
|
199
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;
|
|
200
|
+
toScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
201
|
+
fromScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
202
|
+
toLocal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
203
|
+
toGlobal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
204
|
+
toOther(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
205
205
|
on(name: string | object, callback: Function, context?: any): any;
|
|
206
206
|
off(name?: string | object, callback?: Function, context?: any): any;
|
|
207
207
|
once(name: string | object, callback: Function, context?: any): any;
|
|
@@ -211,24 +211,24 @@ declare const DueTimer_base: (new (...args: any[]) => {
|
|
|
211
211
|
onchange(after: Record<string, any>, before: Record<string, any>): void;
|
|
212
212
|
calculateBounds?(): void;
|
|
213
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[];
|
|
214
|
+
removeComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
|
|
215
|
+
addComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
|
|
216
|
+
insertComponentAt(component: import("@hatiolab/things-scene").Component, index: number, ghost?: boolean): void;
|
|
217
|
+
getOverlay(component: import("@hatiolab/things-scene").Component): HTMLElement | undefined;
|
|
218
|
+
findById(id: string): import("@hatiolab/things-scene").Component | undefined;
|
|
219
|
+
findByRefid(ref: string | number): import("@hatiolab/things-scene").Component | undefined;
|
|
220
|
+
findAllById(id: string): import("@hatiolab/things-scene").Component[];
|
|
221
221
|
resize(): void;
|
|
222
222
|
fit(type?: string): void;
|
|
223
|
-
get components(): Component[] | undefined;
|
|
223
|
+
get components(): import("@hatiolab/things-scene").Component[] | undefined;
|
|
224
224
|
get layout(): any;
|
|
225
225
|
get auxOverlay(): HTMLElement | undefined;
|
|
226
226
|
get isReady(): boolean;
|
|
227
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;
|
|
228
|
+
get selected(): import("@hatiolab/things-scene").Component[];
|
|
229
|
+
set selected(_v: import("@hatiolab/things-scene").Component[]): any;
|
|
230
|
+
get focused(): import("@hatiolab/things-scene").Component | null;
|
|
231
|
+
set focused(_v: import("@hatiolab/things-scene").Component | null): any;
|
|
232
232
|
get hasSameParentForAllSelected(): boolean;
|
|
233
233
|
set hasSameParentForAllSelected(_v: boolean): any;
|
|
234
234
|
get fitMode(): string | undefined;
|
package/dist/duetimer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../src/duetimer.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"duetimer.js","sourceRoot":"","sources":["../src/duetimer.ts"],"names":[],"mappings":";AAAA,OAAO,EAA+B,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAErG;;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,GAAd,MAAM,QAAS,SAAQ,QAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,GAAW,CAAC,CAAA;IAE1B,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CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AArHoB,QAAQ;IAD5B,cAAc,CAAC,UAAU,CAAC;GACN,QAAQ,CAqH5B;eArHoB,QAAQ","sourcesContent":["import { 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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
|
|
2
2
|
declare const Timer_base: (new (...args: any[]) => {
|
|
3
3
|
contains(x: number, y: number): boolean;
|
|
4
4
|
get path(): {
|
|
@@ -49,7 +49,7 @@ declare const Timer_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
|
|
52
|
+
isContainer(): this is import("@hatiolab/things-scene").Container;
|
|
53
53
|
isLine(): boolean;
|
|
54
54
|
isRoot(): boolean;
|
|
55
55
|
isRootModel(): boolean;
|
|
@@ -65,9 +65,9 @@ declare const Timer_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:
|
|
68
|
+
setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
|
|
69
69
|
get model(): any;
|
|
70
|
-
get state():
|
|
70
|
+
get state(): import("@hatiolab/things-scene").State;
|
|
71
71
|
get hierarchy(): any;
|
|
72
72
|
get volatile(): never[];
|
|
73
73
|
_applyProps(target: any, props: any, options: any): any;
|
|
@@ -103,7 +103,7 @@ declare const Timer_base: (new (...args: any[]) => {
|
|
|
103
103
|
draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
104
104
|
prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
105
105
|
postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
106
|
-
prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
|
|
106
|
+
prepare(resolve: (component: import("@hatiolab/things-scene").Component) => void, reject: (reason: any) => void): void;
|
|
107
107
|
prepareIf(condition: boolean): void;
|
|
108
108
|
drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
|
|
109
109
|
drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
|
|
@@ -154,16 +154,16 @@ declare const Timer_base: (new (...args: any[]) => {
|
|
|
154
154
|
get started(): boolean;
|
|
155
155
|
set started(v: boolean): any;
|
|
156
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;
|
|
157
|
+
findFirst(finder: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): import("@hatiolab/things-scene").Component | undefined;
|
|
158
|
+
findAll(s: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): any[] | undefined;
|
|
159
|
+
capture(x: number, y: number, except?: (c: import("@hatiolab/things-scene").Component) => boolean): any;
|
|
160
160
|
findAnchor(name: string): any;
|
|
161
|
-
isDescendible(container: Component): boolean;
|
|
161
|
+
isDescendible(container: import("@hatiolab/things-scene").Component): boolean;
|
|
162
162
|
getContext(component?: unknown): any;
|
|
163
|
-
get root(): Component;
|
|
164
|
-
get rootModel(): Component;
|
|
165
|
-
get parent(): Component;
|
|
166
|
-
set parent(v: Component): any;
|
|
163
|
+
get root(): import("@hatiolab/things-scene").Component;
|
|
164
|
+
get rootModel(): import("@hatiolab/things-scene").Component;
|
|
165
|
+
get parent(): import("@hatiolab/things-scene").Component;
|
|
166
|
+
set parent(v: import("@hatiolab/things-scene").Component): any;
|
|
167
167
|
get scalable(): boolean;
|
|
168
168
|
get stuck(): boolean;
|
|
169
169
|
get capturable(): boolean;
|
|
@@ -188,20 +188,20 @@ declare const Timer_base: (new (...args: any[]) => {
|
|
|
188
188
|
ondropfile(transfered: FileList, files: string[]): void;
|
|
189
189
|
transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
|
|
190
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;
|
|
191
|
+
transcoordS2T(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
192
|
+
transcoordT2P(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
193
|
+
transcoordT2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
194
|
+
transcoordS2TR(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
195
|
+
transcoordS2O(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
196
|
+
transcoordC2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
197
|
+
transcoordS2C(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
198
198
|
toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
|
|
199
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;
|
|
200
|
+
toScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
201
|
+
fromScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
202
|
+
toLocal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
203
|
+
toGlobal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
204
|
+
toOther(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
|
|
205
205
|
on(name: string | object, callback: Function, context?: any): any;
|
|
206
206
|
off(name?: string | object, callback?: Function, context?: any): any;
|
|
207
207
|
once(name: string | object, callback: Function, context?: any): any;
|
|
@@ -211,24 +211,24 @@ declare const Timer_base: (new (...args: any[]) => {
|
|
|
211
211
|
onchange(after: Record<string, any>, before: Record<string, any>): void;
|
|
212
212
|
calculateBounds?(): void;
|
|
213
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[];
|
|
214
|
+
removeComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
|
|
215
|
+
addComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
|
|
216
|
+
insertComponentAt(component: import("@hatiolab/things-scene").Component, index: number, ghost?: boolean): void;
|
|
217
|
+
getOverlay(component: import("@hatiolab/things-scene").Component): HTMLElement | undefined;
|
|
218
|
+
findById(id: string): import("@hatiolab/things-scene").Component | undefined;
|
|
219
|
+
findByRefid(ref: string | number): import("@hatiolab/things-scene").Component | undefined;
|
|
220
|
+
findAllById(id: string): import("@hatiolab/things-scene").Component[];
|
|
221
221
|
resize(): void;
|
|
222
222
|
fit(type?: string): void;
|
|
223
|
-
get components(): Component[] | undefined;
|
|
223
|
+
get components(): import("@hatiolab/things-scene").Component[] | undefined;
|
|
224
224
|
get layout(): any;
|
|
225
225
|
get auxOverlay(): HTMLElement | undefined;
|
|
226
226
|
get isReady(): boolean;
|
|
227
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;
|
|
228
|
+
get selected(): import("@hatiolab/things-scene").Component[];
|
|
229
|
+
set selected(_v: import("@hatiolab/things-scene").Component[]): any;
|
|
230
|
+
get focused(): import("@hatiolab/things-scene").Component | null;
|
|
231
|
+
set focused(_v: import("@hatiolab/things-scene").Component | null): any;
|
|
232
232
|
get hasSameParentForAllSelected(): boolean;
|
|
233
233
|
set hasSameParentForAllSelected(_v: boolean): any;
|
|
234
234
|
get fitMode(): string | undefined;
|
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,
|
|
1
|
+
{"version":3,"file":"timer.js","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAA+B,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAErG,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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AAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,UAAU,CAAC,OAAiC;QAC1C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACxB,IAAI,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,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 { 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": "10.0.0-beta.
|
|
5
|
+
"version": "10.0.0-beta.30",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"prettier --write"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "06b35b1726ec4f27ee76657ce341c6c6f3ba1b3a"
|
|
62
62
|
}
|