@operato/scene-label 10.0.0-beta.22 → 10.0.0-beta.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/barcode.d.ts CHANGED
@@ -49,7 +49,7 @@ declare const Barcode_base: (new (...args: any[]) => {
49
49
  get disposed(): boolean;
50
50
  isLayer(): boolean;
51
51
  isGroup(): boolean;
52
- isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component").Container;
52
+ isContainer(): this is import("@hatiolab/things-scene").Container;
53
53
  isLine(): boolean;
54
54
  isRoot(): boolean;
55
55
  isRootModel(): boolean;
@@ -65,9 +65,10 @@ declare const Barcode_base: (new (...args: any[]) => {
65
65
  get(property: any): any;
66
66
  set(props: any, propval?: any): any;
67
67
  getState(property: any): any;
68
- setState(props: any, propval?: any): any;
68
+ setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
69
69
  get model(): any;
70
- get state(): any;
70
+ get state(): import("@hatiolab/things-scene").State;
71
+ get refid(): any;
71
72
  get hierarchy(): any;
72
73
  get volatile(): never[];
73
74
  _applyProps(target: any, props: any, options: any): any;
@@ -158,7 +159,7 @@ declare const Barcode_base: (new (...args: any[]) => {
158
159
  findAll(s: string | ((c: Component) => boolean), ...others: any[]): any[] | undefined;
159
160
  capture(x: number, y: number, except?: (c: Component) => boolean): any;
160
161
  findAnchor(name: string): any;
161
- isDescendible(container: Component): boolean;
162
+ isDescendible(container: Component | any): boolean;
162
163
  getContext(component?: unknown): any;
163
164
  get root(): Component;
164
165
  get rootModel(): Component;
@@ -202,9 +203,13 @@ declare const Barcode_base: (new (...args: any[]) => {
202
203
  toLocal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
203
204
  toGlobal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
204
205
  toOther(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
206
+ on<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
205
207
  on(name: string | object, callback: Function, context?: any): any;
208
+ off<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback?: ((...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void) | undefined, context?: any): any;
206
209
  off(name?: string | object, callback?: Function, context?: any): any;
210
+ once<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
207
211
  once(name: string | object, callback: Function, context?: any): any;
212
+ trigger<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, ...args: import("@hatiolab/things-scene").ComponentEventMap[K]): any;
208
213
  trigger(name: string, ...args: any[]): any;
209
214
  delegate_on(delegator: any): any;
210
215
  delegate_off(delegator: any): any;
@@ -1,4 +1,4 @@
1
- import { Component, ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
1
+ import { ComponentNature, Properties, Shape } from '@hatiolab/things-scene';
2
2
  declare const LabelPrinter_base: (new (...args: any[]) => {
3
3
  contains(x: number, y: number): boolean;
4
4
  get path(): {
@@ -49,7 +49,7 @@ declare const LabelPrinter_base: (new (...args: any[]) => {
49
49
  get disposed(): boolean;
50
50
  isLayer(): boolean;
51
51
  isGroup(): boolean;
52
- isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component").Container;
52
+ isContainer(): this is import("@hatiolab/things-scene").Container;
53
53
  isLine(): boolean;
54
54
  isRoot(): boolean;
55
55
  isRootModel(): boolean;
@@ -65,9 +65,10 @@ declare const LabelPrinter_base: (new (...args: any[]) => {
65
65
  get(property: any): any;
66
66
  set(props: any, propval?: any): any;
67
67
  getState(property: any): any;
68
- setState(props: any, propval?: any): any;
68
+ setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
69
69
  get model(): any;
70
- get state(): any;
70
+ get state(): import("@hatiolab/things-scene").State;
71
+ get refid(): any;
71
72
  get hierarchy(): any;
72
73
  get volatile(): never[];
73
74
  _applyProps(target: any, props: any, options: any): any;
@@ -103,7 +104,7 @@ declare const LabelPrinter_base: (new (...args: any[]) => {
103
104
  draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
104
105
  prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
105
106
  postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
106
- prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
107
+ prepare(resolve: (component: import("@hatiolab/things-scene").Component) => void, reject: (reason: any) => void): void;
107
108
  prepareIf(condition: boolean): void;
108
109
  drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
109
110
  drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
@@ -154,16 +155,16 @@ declare const LabelPrinter_base: (new (...args: any[]) => {
154
155
  get started(): boolean;
155
156
  set started(v: boolean): any;
156
157
  get controls(): import("@hatiolab/things-scene").Control[] | undefined;
157
- findFirst(finder: string | ((c: Component) => boolean), ...others: any[]): Component | undefined;
158
- findAll(s: string | ((c: Component) => boolean), ...others: any[]): any[] | undefined;
159
- capture(x: number, y: number, except?: (c: Component) => boolean): any;
158
+ findFirst(finder: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): import("@hatiolab/things-scene").Component | undefined;
159
+ findAll(s: string | ((c: import("@hatiolab/things-scene").Component) => boolean), ...others: any[]): any[] | undefined;
160
+ capture(x: number, y: number, except?: (c: import("@hatiolab/things-scene").Component) => boolean): any;
160
161
  findAnchor(name: string): any;
161
- isDescendible(container: Component): boolean;
162
+ isDescendible(container: import("@hatiolab/things-scene").Component | any): boolean;
162
163
  getContext(component?: unknown): any;
163
- get root(): Component;
164
- get rootModel(): Component;
165
- get parent(): Component;
166
- set parent(v: Component): any;
164
+ get root(): import("@hatiolab/things-scene").Component;
165
+ get rootModel(): import("@hatiolab/things-scene").Component;
166
+ get parent(): import("@hatiolab/things-scene").Component;
167
+ set parent(v: import("@hatiolab/things-scene").Component): any;
167
168
  get scalable(): boolean;
168
169
  get stuck(): boolean;
169
170
  get capturable(): boolean;
@@ -188,47 +189,51 @@ declare const LabelPrinter_base: (new (...args: any[]) => {
188
189
  ondropfile(transfered: FileList, files: string[]): void;
189
190
  transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
190
191
  transcoordP2S(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
191
- transcoordS2T(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
192
- transcoordT2P(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
193
- transcoordT2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
194
- transcoordS2TR(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
195
- transcoordS2O(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
196
- transcoordC2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
197
- transcoordS2C(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
192
+ transcoordS2T(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
193
+ transcoordT2P(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
194
+ transcoordT2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
195
+ transcoordS2TR(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
196
+ transcoordS2O(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
197
+ transcoordC2S(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
198
+ transcoordS2C(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
198
199
  toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
199
200
  fromParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
200
- toScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
201
- fromScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
202
- toLocal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
203
- toGlobal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
204
- toOther(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
201
+ toScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
202
+ fromScene(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
203
+ toLocal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
204
+ toGlobal(x: number, y: number, top?: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
205
+ toOther(x: number, y: number, target: import("@hatiolab/things-scene").Component): import("@hatiolab/things-scene").POINT;
206
+ on<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
205
207
  on(name: string | object, callback: Function, context?: any): any;
208
+ off<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback?: ((...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void) | undefined, context?: any): any;
206
209
  off(name?: string | object, callback?: Function, context?: any): any;
210
+ once<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
207
211
  once(name: string | object, callback: Function, context?: any): any;
212
+ trigger<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, ...args: import("@hatiolab/things-scene").ComponentEventMap[K]): any;
208
213
  trigger(name: string, ...args: any[]): any;
209
214
  delegate_on(delegator: any): any;
210
215
  delegate_off(delegator: any): any;
211
216
  onchange(after: Record<string, any>, before: Record<string, any>): void;
212
217
  calculateBounds?(): void;
213
218
  oncreate_element?(element: HTMLElement): void;
214
- removeComponent(component: Component, ghost?: boolean): void;
215
- addComponent(component: Component, ghost?: boolean): void;
216
- insertComponentAt(component: Component, index: number, ghost?: boolean): void;
217
- getOverlay(component: Component): HTMLElement | undefined;
218
- findById(id: string): Component | undefined;
219
- findByRefid(ref: string | number): Component | undefined;
220
- findAllById(id: string): Component[];
219
+ removeComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
220
+ addComponent(component: import("@hatiolab/things-scene").Component, ghost?: boolean): void;
221
+ insertComponentAt(component: import("@hatiolab/things-scene").Component, index: number, ghost?: boolean): void;
222
+ getOverlay(component: import("@hatiolab/things-scene").Component): HTMLElement | undefined;
223
+ findById(id: string): import("@hatiolab/things-scene").Component | undefined;
224
+ findByRefid(ref: string | number): import("@hatiolab/things-scene").Component | undefined;
225
+ findAllById(id: string): import("@hatiolab/things-scene").Component[];
221
226
  resize(): void;
222
227
  fit(type?: string): void;
223
- get components(): Component[] | undefined;
228
+ get components(): import("@hatiolab/things-scene").Component[] | undefined;
224
229
  get layout(): any;
225
230
  get auxOverlay(): HTMLElement | undefined;
226
231
  get isReady(): boolean;
227
232
  get unitScale(): number;
228
- get selected(): Component[];
229
- set selected(_v: Component[]): any;
230
- get focused(): Component | null;
231
- set focused(_v: Component | null): any;
233
+ get selected(): import("@hatiolab/things-scene").Component[];
234
+ set selected(_v: import("@hatiolab/things-scene").Component[]): any;
235
+ get focused(): import("@hatiolab/things-scene").Component | null;
236
+ set focused(_v: import("@hatiolab/things-scene").Component | null): any;
232
237
  get hasSameParentForAllSelected(): boolean;
233
238
  set hasSameParentForAllSelected(_v: boolean): any;
234
239
  get fitMode(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"label-printer.js","sourceRoot":"","sources":["../src/label-printer.ts"],"names":[],"mappings":"AAAA;;GAEG;;;AAEH,OAAO,EAA0C,QAAQ,E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C,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,iBAAiB,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE;YAClF,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;QAEF,IAAI,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEnC,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,OAAO;oBACV,aAAa,IAAI,YAAY;wBAC3B,CAAC,CAAC,IAAI,UAAU,CACZ,QAAQ;4BACN,CAAC,CAAC;gCACE;oCACE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;iCAC3B;6BACF;4BACH,CAAC,CAAC,SAAS,CACd;wBACH,CAAC,CAAC,IAAI,cAAc,EAAE,CAAA;YAC5B,CAAC;YAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAChC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,GAAa,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;CACF,CAAA;AAvFoB,YAAY;IADhC,cAAc,CAAC,eAAe,CAAC;GACX,YAAY,CAuFhC;eAvFoB,YAAY","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\nimport { BrowserPrinter, USBPrinter } from '@operato/barcode'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'direct-printer',\n name: 'directPrinter',\n property: {\n options: [\n {\n display: 'USB Connected Printer',\n value: 'direct-usb'\n },\n {\n display: 'Zebra Browser Print',\n value: 'zebra-browser-print'\n }\n ]\n }\n },\n {\n type: 'string',\n label: 'vendor id',\n name: 'vendorId',\n placeholder: '0x0A5F'\n },\n {\n type: 'board-selector',\n label: 'board id',\n name: 'boardId'\n },\n {\n type: 'number',\n label: 'copies',\n name: 'copies'\n }\n ],\n 'value-property': 'data',\n help: 'scene/component/label-printer'\n}\n\n@sceneComponent('label-printer')\nexport default class LabelPrinter extends RectPath(Shape) {\n private static _image: HTMLImageElement\n private printer?: USBPrinter | BrowserPrinter\n\n static get image() {\n if (!LabelPrinter._image) {\n LabelPrinter._image = new Image()\n LabelPrinter._image.src = new URL('../icons/label-printer.png', import.meta.url).href\n }\n\n return LabelPrinter._image\n }\n get nature() {\n return NATURE\n }\n\n dispose() {\n super.dispose()\n }\n\n render(context: CanvasRenderingContext2D) {\n /*\n * TODO printable 상태를 구분할 수 있는 표시를 추가할 것.\n */\n\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, LabelPrinter.image, left, top, width, height)\n }\n\n onchange(after: Properties, before: Properties) {\n if ('data' in after) {\n this.print(after.data)\n }\n\n if ('directPrinter' in after) {\n delete this.printer\n }\n }\n\n async print(data: any) {\n if (!this.app.isViewMode || data.constructor !== Object || Object.keys(data).length === 0) {\n /* in cases of\n * - edit mode\n * - data is not a object\n * - data object is empty\n * we doesn't print\n */\n return\n }\n\n var { directPrinter, boardId, vendorId, copies = 1 } = this.state\n\n var searchParams = new URLSearchParams()\n for (var key in data) {\n searchParams.append(key, data[key])\n }\n const response = await fetch(`label-command/${boardId}?${searchParams.toString()}`, {\n method: 'GET'\n })\n\n var command = await response.text()\n\n try {\n if (!this.printer) {\n this.printer =\n directPrinter == 'direct-usb'\n ? new USBPrinter(\n vendorId\n ? [\n {\n vendorId: Number(vendorId)\n }\n ]\n : undefined\n )\n : new BrowserPrinter()\n }\n\n for (var i = 0; i < copies; i++) {\n await this.printer.print(command)\n }\n } catch (err) {\n throw new Error(err as string)\n }\n }\n}\n"]}
1
+ {"version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AI,IAAI,EAAE,CAAC;YACrB,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACrC,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,iBAAiB,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE;YAClF,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;QAEF,IAAI,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEnC,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,OAAO;oBACV,aAAa,IAAI,YAAY;wBAC3B,CAAC,CAAC,IAAI,UAAU,CACZ,QAAQ;4BACN,CAAC,CAAC;gCACE;oCACE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;iCAC3B;6BACF;4BACH,CAAC,CAAC,SAAS,CACd;wBACH,CAAC,CAAC,IAAI,cAAc,EAAE,CAAA;YAC5B,CAAC;YAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAChC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,GAAa,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;CACF,CAAA;AAvFoB,YAAY;IADhC,cAAc,CAAC,eAAe,CAAC;GACX,YAAY,CAuFhC;eAvFoB,YAAY","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { ComponentNature, Properties, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\nimport { BrowserPrinter, USBPrinter } from '@operato/barcode'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'direct-printer',\n name: 'directPrinter',\n property: {\n options: [\n {\n display: 'USB Connected Printer',\n value: 'direct-usb'\n },\n {\n display: 'Zebra Browser Print',\n value: 'zebra-browser-print'\n }\n ]\n }\n },\n {\n type: 'string',\n label: 'vendor id',\n name: 'vendorId',\n placeholder: '0x0A5F'\n },\n {\n type: 'board-selector',\n label: 'board id',\n name: 'boardId'\n },\n {\n type: 'number',\n label: 'copies',\n name: 'copies'\n }\n ],\n 'value-property': 'data',\n help: 'scene/component/label-printer'\n}\n\n@sceneComponent('label-printer')\nexport default class LabelPrinter extends RectPath(Shape) {\n private static _image: HTMLImageElement\n private printer?: USBPrinter | BrowserPrinter\n\n static get image() {\n if (!LabelPrinter._image) {\n LabelPrinter._image = new Image()\n LabelPrinter._image.src = new URL('../icons/label-printer.png', import.meta.url).href\n }\n\n return LabelPrinter._image\n }\n get nature() {\n return NATURE\n }\n\n dispose() {\n super.dispose()\n }\n\n render(context: CanvasRenderingContext2D) {\n /*\n * TODO printable 상태를 구분할 수 있는 표시를 추가할 것.\n */\n\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, LabelPrinter.image, left, top, width, height)\n }\n\n onchange(after: Properties, before: Properties) {\n if ('data' in after) {\n this.print(after.data)\n }\n\n if ('directPrinter' in after) {\n delete this.printer\n }\n }\n\n async print(data: any) {\n if (!this.app.isViewMode || data.constructor !== Object || Object.keys(data).length === 0) {\n /* in cases of\n * - edit mode\n * - data is not a object\n * - data object is empty\n * we doesn't print\n */\n return\n }\n\n var { directPrinter, boardId, vendorId, copies = 1 } = this.state\n\n var searchParams = new URLSearchParams()\n for (var key in data) {\n searchParams.append(key, data[key])\n }\n const response = await fetch(`label-command/${boardId}?${searchParams.toString()}`, {\n method: 'GET'\n })\n\n var command = await response.text()\n\n try {\n if (!this.printer) {\n this.printer =\n directPrinter == 'direct-usb'\n ? new USBPrinter(\n vendorId\n ? [\n {\n vendorId: Number(vendorId)\n }\n ]\n : undefined\n )\n : new BrowserPrinter()\n }\n\n for (var i = 0; i < copies; i++) {\n await this.printer.print(command)\n }\n } catch (err) {\n throw new Error(err as string)\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@operato/scene-label",
3
3
  "description": "Barcode Label component for things-scene",
4
- "version": "10.0.0-beta.22",
4
+ "version": "10.0.0-beta.65",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "things-scene": true,
@@ -35,8 +35,8 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@hatiolab/prettier-config": "^1.0.0",
38
- "@things-factory/builder": "^10.0.0-beta.1",
39
- "@things-factory/operato-board": "^10.0.0-beta.1",
38
+ "@things-factory/builder": "^10.0.0-zeta.1",
39
+ "@things-factory/operato-board": "^10.0.0-zeta.1",
40
40
  "@types/codemirror": "^5.60.5",
41
41
  "@types/w3c-web-usb": "^1.0.5",
42
42
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -63,5 +63,5 @@
63
63
  "prettier --write"
64
64
  ]
65
65
  },
66
- "gitHead": "f48e52f4f5fdc30ec06af9da7cf253f6e29cfb0e"
66
+ "gitHead": "99733bf39e2d279630d68844f19d9687272a4992"
67
67
  }