@formless63/viewer-lbx 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +26 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/colors.d.ts +18 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +20 -0
- package/dist/colors.js.map +1 -0
- package/dist/definitions.d.ts +3 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +10 -0
- package/dist/definitions.js.map +1 -0
- package/dist/font-metrics.d.ts +81 -0
- package/dist/font-metrics.d.ts.map +1 -0
- package/dist/font-metrics.js +65 -0
- package/dist/font-metrics.js.map +1 -0
- package/dist/fonts.d.ts +15 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +31 -0
- package/dist/fonts.js.map +1 -0
- package/dist/geometry.d.ts +17 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +36 -0
- package/dist/geometry.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/lbx-viewer.d.ts +17 -0
- package/dist/lbx-viewer.d.ts.map +1 -0
- package/dist/lbx-viewer.js +153 -0
- package/dist/lbx-viewer.js.map +1 -0
- package/dist/parse.d.ts +42 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +90 -0
- package/dist/parse.js.map +1 -0
- package/dist/raster.d.ts +45 -0
- package/dist/raster.d.ts.map +1 -0
- package/dist/raster.js +87 -0
- package/dist/raster.js.map +1 -0
- package/dist/tape-stocks.d.ts +34 -0
- package/dist/tape-stocks.d.ts.map +1 -0
- package/dist/tape-stocks.js +99 -0
- package/dist/tape-stocks.js.map +1 -0
- package/dist/text-layout.d.ts +67 -0
- package/dist/text-layout.d.ts.map +1 -0
- package/dist/text-layout.js +88 -0
- package/dist/text-layout.js.map +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brother TZe tape stocks, for previewing a label on another cassette.
|
|
3
|
+
*
|
|
4
|
+
* Pairs, not two pickers: tape and ink are fixed together at manufacture, so a list
|
|
5
|
+
* of real cassettes can only preview what can be printed. Part numbers are
|
|
6
|
+
* Brother's published ones. Colours approximate the stock on a screen; clear tape
|
|
7
|
+
* renders as if stuck to something white.
|
|
8
|
+
*
|
|
9
|
+
* A preview only: nothing is written to the file or remembered.
|
|
10
|
+
*/
|
|
11
|
+
/** The file's own declared stock: the default. */
|
|
12
|
+
export const LBX_FILE_STOCK_ID = 'file';
|
|
13
|
+
/** White on black and black on white first, then grouped by tape colour. */
|
|
14
|
+
export const LBX_TAPE_STOCKS = [
|
|
15
|
+
{
|
|
16
|
+
id: 'white-on-black',
|
|
17
|
+
ink: '#ffffff',
|
|
18
|
+
tape: '#000000',
|
|
19
|
+
label: 'White on black',
|
|
20
|
+
tze: 'TZe-335',
|
|
21
|
+
},
|
|
22
|
+
{ id: 'gold-on-black', ink: '#c9a227', tape: '#000000', label: 'Gold on black', tze: 'TZe-334' },
|
|
23
|
+
{
|
|
24
|
+
id: 'black-on-white',
|
|
25
|
+
ink: '#000000',
|
|
26
|
+
tape: '#ffffff',
|
|
27
|
+
label: 'Black on white',
|
|
28
|
+
tze: 'TZe-231',
|
|
29
|
+
},
|
|
30
|
+
{ id: 'blue-on-white', ink: '#0057b8', tape: '#ffffff', label: 'Blue on white', tze: 'TZe-233' },
|
|
31
|
+
{ id: 'red-on-white', ink: '#c8102e', tape: '#ffffff', label: 'Red on white', tze: 'TZe-232' },
|
|
32
|
+
{
|
|
33
|
+
id: 'black-on-clear',
|
|
34
|
+
ink: '#000000',
|
|
35
|
+
tape: '#f4f4f4',
|
|
36
|
+
label: 'Black on clear',
|
|
37
|
+
tze: 'TZe-131',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'white-on-clear',
|
|
41
|
+
ink: '#ffffff',
|
|
42
|
+
tape: '#f4f4f4',
|
|
43
|
+
label: 'White on clear',
|
|
44
|
+
tze: 'TZe-135',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'black-on-yellow',
|
|
48
|
+
ink: '#000000',
|
|
49
|
+
tape: '#f2c800',
|
|
50
|
+
label: 'Black on yellow',
|
|
51
|
+
tze: 'TZe-631',
|
|
52
|
+
},
|
|
53
|
+
{ id: 'black-on-red', ink: '#000000', tape: '#c8102e', label: 'Black on red', tze: 'TZe-431' },
|
|
54
|
+
{ id: 'white-on-red', ink: '#ffffff', tape: '#c8102e', label: 'White on red', tze: 'TZe-435' },
|
|
55
|
+
{ id: 'black-on-blue', ink: '#000000', tape: '#0057b8', label: 'Black on blue', tze: 'TZe-531' },
|
|
56
|
+
{ id: 'white-on-blue', ink: '#ffffff', tape: '#0057b8', label: 'White on blue', tze: 'TZe-535' },
|
|
57
|
+
{
|
|
58
|
+
id: 'black-on-green',
|
|
59
|
+
ink: '#000000',
|
|
60
|
+
tape: '#00843d',
|
|
61
|
+
label: 'Black on green',
|
|
62
|
+
tze: 'TZe-731',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'white-on-green',
|
|
66
|
+
ink: '#ffffff',
|
|
67
|
+
tape: '#00843d',
|
|
68
|
+
label: 'White on green',
|
|
69
|
+
tze: 'TZe-735',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: 'black-on-silver',
|
|
73
|
+
ink: '#000000',
|
|
74
|
+
tape: '#c0c0c0',
|
|
75
|
+
label: 'Black on silver',
|
|
76
|
+
tze: 'TZe-921',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'black-on-fluorescent-yellow',
|
|
80
|
+
ink: '#000000',
|
|
81
|
+
tape: '#e4f000',
|
|
82
|
+
label: 'Black on fluorescent yellow',
|
|
83
|
+
tze: 'TZe-C31',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'black-on-fluorescent-orange',
|
|
87
|
+
ink: '#000000',
|
|
88
|
+
tape: '#ff7a00',
|
|
89
|
+
label: 'Black on fluorescent orange',
|
|
90
|
+
tze: 'TZe-B31',
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
/** The stock for an id, or null (the file's own colours) for anything else. */
|
|
94
|
+
export function resolveLbxTapeStock(id) {
|
|
95
|
+
if (typeof id !== 'string' || id === LBX_FILE_STOCK_ID)
|
|
96
|
+
return null;
|
|
97
|
+
return LBX_TAPE_STOCKS.find((stock) => stock.id === id) ?? null;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=tape-stocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tape-stocks.js","sourceRoot":"","sources":["../src/tape-stocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoBH,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,eAAe,GAA4B;IACtD;QACE,EAAE,EAAE,gBAAgB;QACpB,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,gBAAgB;QACvB,GAAG,EAAE,SAAS;KACf;IACD,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE;IAChG;QACE,EAAE,EAAE,gBAAgB;QACpB,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,gBAAgB;QACvB,GAAG,EAAE,SAAS;KACf;IACD,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE;IAChG,EAAE,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,S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AE,gBAAgB;QACvB,GAAG,EAAE,SAAS;KACf;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,iBAAiB;QACxB,GAAG,EAAE,SAAS;KACf;IACD;QACE,EAAE,EAAE,6BAA6B;QACjC,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,6BAA6B;QACpC,GAAG,EAAE,SAAS;KACf;IACD;QACE,EAAE,EAAE,6BAA6B;QACjC,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,6BAA6B;QACpC,GAAG,EAAE,SAAS;KACf;CACF,CAAC;AAEF,+EAA+E;AAC/E,MAAM,UAAU,mBAAmB,CAAC,EAAW;IAC7C,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IACpE,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type LbxResolvedFontMetrics } from './font-metrics.ts';
|
|
2
|
+
import type { LbxTextObject } from './parse.ts';
|
|
3
|
+
export declare function textLines(obj: LbxTextObject): string[];
|
|
4
|
+
/** Everything `renderTextObject` needs to place one text run, all in pt. */
|
|
5
|
+
export interface LbxTextLayout {
|
|
6
|
+
/**
|
|
7
|
+
* The "as if horizontal" box the alignment math runs in. For a
|
|
8
|
+
* perpendicular run this is the stored footprint with width/height swapped
|
|
9
|
+
* back, kept centred on the same point.
|
|
10
|
+
*/
|
|
11
|
+
layoutX: number;
|
|
12
|
+
layoutY: number;
|
|
13
|
+
layoutWidth: number;
|
|
14
|
+
layoutHeight: number;
|
|
15
|
+
/** Centre of the stored footprint — also the rotation centre. */
|
|
16
|
+
cx: number;
|
|
17
|
+
cy: number;
|
|
18
|
+
/** Rotation normalised into [0, 360); `perpendicular` means 90 or 270. */
|
|
19
|
+
angle: number;
|
|
20
|
+
perpendicular: boolean;
|
|
21
|
+
/** Font size actually used (the file's, or 12pt when it declares none). */
|
|
22
|
+
size: number;
|
|
23
|
+
/** Baseline → line-box top, in pt. */
|
|
24
|
+
ascent: number;
|
|
25
|
+
/** Baseline → line-box bottom, in pt. */
|
|
26
|
+
descent: number;
|
|
27
|
+
/** Baseline-to-baseline advance, including the file's own `lineSpace`. */
|
|
28
|
+
lineAdvance: number;
|
|
29
|
+
blockTop: number;
|
|
30
|
+
blockHeight: number;
|
|
31
|
+
/** One baseline per line of `data`, top to bottom. */
|
|
32
|
+
baselines: number[];
|
|
33
|
+
/**
|
|
34
|
+
* Where the printed ink of the whole block actually lands — the glyph
|
|
35
|
+
* extent, not the line box. Not used to place anything; it is what a
|
|
36
|
+
* verification test compares against a measured reference render.
|
|
37
|
+
*/
|
|
38
|
+
inkTop: number;
|
|
39
|
+
inkBottom: number;
|
|
40
|
+
/** Resolved horizontal anchor. */
|
|
41
|
+
textX: number;
|
|
42
|
+
anchor: 'start' | 'middle' | 'end';
|
|
43
|
+
/** True when the file asks for `horizontalAlignment="JUSTIFY"`. */
|
|
44
|
+
justified: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Advance the line must be stretched to, in pt — `layoutWidth` for a
|
|
47
|
+
* justified run, `null` otherwise (render at the face's natural advance).
|
|
48
|
+
* See `resolveLbxTextBaselines`'s JUSTIFY note.
|
|
49
|
+
*/
|
|
50
|
+
textLength: number | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Lay out one text object. Pure, so baselines can be checked against measurements
|
|
54
|
+
* without rasterising; SVG's `dominant-baseline` is inconsistent across browsers.
|
|
55
|
+
*
|
|
56
|
+
* The line box is the face's own ascent, descent and line gap. Lines stack, the
|
|
57
|
+
* block is aligned in the object's box, and each baseline sits `ascent` below the
|
|
58
|
+
* block top. A block taller than its box overflows symmetrically when centred, so
|
|
59
|
+
* the offsets are not clamped.
|
|
60
|
+
*
|
|
61
|
+
* JUSTIFY stretches each line across the frame, glyphs included (`textLength` with
|
|
62
|
+
* `spacingAndGlyphs`). Against a measured P-touch render, the far end of two runs
|
|
63
|
+
* landed within 0.22pt; the face's natural advance fell about 2pt short and the
|
|
64
|
+
* file's `logFont width` about 1pt.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveLbxTextBaselines(obj: LbxTextObject, metrics?: LbxResolvedFontMetrics): LbxTextLayout;
|
|
67
|
+
//# sourceMappingURL=text-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-layout.d.ts","sourceRoot":"","sources":["../src/text-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,EAAE,CAEtD;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,sBAA6D,GACrE,aAAa,CA6Ef"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { resolveLbxFontMetrics } from './font-metrics.js';
|
|
2
|
+
export function textLines(obj) {
|
|
3
|
+
return obj.data.split(/\r?\n/);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Lay out one text object. Pure, so baselines can be checked against measurements
|
|
7
|
+
* without rasterising; SVG's `dominant-baseline` is inconsistent across browsers.
|
|
8
|
+
*
|
|
9
|
+
* The line box is the face's own ascent, descent and line gap. Lines stack, the
|
|
10
|
+
* block is aligned in the object's box, and each baseline sits `ascent` below the
|
|
11
|
+
* block top. A block taller than its box overflows symmetrically when centred, so
|
|
12
|
+
* the offsets are not clamped.
|
|
13
|
+
*
|
|
14
|
+
* JUSTIFY stretches each line across the frame, glyphs included (`textLength` with
|
|
15
|
+
* `spacingAndGlyphs`). Against a measured P-touch render, the far end of two runs
|
|
16
|
+
* landed within 0.22pt; the face's natural advance fell about 2pt short and the
|
|
17
|
+
* file's `logFont width` about 1pt.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveLbxTextBaselines(obj, metrics = resolveLbxFontMetrics(obj.font.name)) {
|
|
20
|
+
const { x, y, width, height, angle = 0 } = obj.position;
|
|
21
|
+
const size = obj.font.size > 0 ? obj.font.size : 12;
|
|
22
|
+
const lines = textLines(obj);
|
|
23
|
+
const ascent = metrics.ascent * size;
|
|
24
|
+
const descent = metrics.descent * size;
|
|
25
|
+
// `lineSpace` is Brother's own extra leading, in pt, on top of the face's.
|
|
26
|
+
const lineAdvance = (metrics.ascent + metrics.descent + metrics.lineGap) * size + (obj.lineSpace ?? 0);
|
|
27
|
+
const blockHeight = lines.length * lineAdvance;
|
|
28
|
+
// The stored objectStyle x/y/width/height are the FINAL on-canvas
|
|
29
|
+
// footprint — for a perpendicular rotation (90/270, vertical text) that
|
|
30
|
+
// footprint is already narrow×tall, not the "as if horizontal" box the
|
|
31
|
+
// alignment math below expects. Lay the lines out in a virtual box with
|
|
32
|
+
// width/height swapped back (centered on the same point); the caller
|
|
33
|
+
// rotates the whole group into the real footprint.
|
|
34
|
+
const cx = x + width / 2;
|
|
35
|
+
const cy = y + height / 2;
|
|
36
|
+
const normalizedAngle = ((angle % 360) + 360) % 360;
|
|
37
|
+
const perpendicular = normalizedAngle === 90 || normalizedAngle === 270;
|
|
38
|
+
const layoutWidth = perpendicular ? height : width;
|
|
39
|
+
const layoutHeight = perpendicular ? width : height;
|
|
40
|
+
const layoutX = cx - layoutWidth / 2;
|
|
41
|
+
const layoutY = cy - layoutHeight / 2;
|
|
42
|
+
const vAlign = obj.verticalAlignment ?? 'TOP';
|
|
43
|
+
const blockTop = vAlign === 'CENTER'
|
|
44
|
+
? layoutY + (layoutHeight - blockHeight) / 2
|
|
45
|
+
: vAlign === 'BOTTOM'
|
|
46
|
+
? layoutY + layoutHeight - blockHeight
|
|
47
|
+
: layoutY;
|
|
48
|
+
const baselines = lines.map((_, i) => blockTop + ascent + i * lineAdvance);
|
|
49
|
+
const hAlign = obj.horizontalAlignment ?? 'LEFT';
|
|
50
|
+
const anchor = hAlign === 'CENTER' ? 'middle' : hAlign === 'RIGHT' ? 'end' : 'start';
|
|
51
|
+
const textX = hAlign === 'CENTER'
|
|
52
|
+
? layoutX + layoutWidth / 2
|
|
53
|
+
: hAlign === 'RIGHT'
|
|
54
|
+
? layoutX + layoutWidth
|
|
55
|
+
: layoutX;
|
|
56
|
+
// JUSTIFY keeps the `start` anchor above and additionally stretches the
|
|
57
|
+
// line across the frame. Guarded on a positive width so a degenerate/
|
|
58
|
+
// zero-width object can never emit an invalid `textLength`.
|
|
59
|
+
const justified = hAlign === 'JUSTIFY';
|
|
60
|
+
const textLength = justified && layoutWidth > 0 ? layoutWidth : null;
|
|
61
|
+
return {
|
|
62
|
+
layoutX,
|
|
63
|
+
layoutY,
|
|
64
|
+
layoutWidth,
|
|
65
|
+
layoutHeight,
|
|
66
|
+
cx,
|
|
67
|
+
cy,
|
|
68
|
+
angle: normalizedAngle,
|
|
69
|
+
perpendicular,
|
|
70
|
+
size,
|
|
71
|
+
ascent,
|
|
72
|
+
descent,
|
|
73
|
+
lineAdvance,
|
|
74
|
+
blockTop,
|
|
75
|
+
blockHeight,
|
|
76
|
+
baselines,
|
|
77
|
+
// Glyph extent, measured off the first and last baseline. `inkBottom` is
|
|
78
|
+
// an em offset ABOVE the baseline for a face like Narrow Display whose
|
|
79
|
+
// capitals float, hence the subtraction on both ends.
|
|
80
|
+
inkTop: (baselines[0] ?? 0) - metrics.inkTop * size,
|
|
81
|
+
inkBottom: (baselines.at(-1) ?? 0) - metrics.inkBottom * size,
|
|
82
|
+
textX,
|
|
83
|
+
anchor,
|
|
84
|
+
justified,
|
|
85
|
+
textLength,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=text-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-layout.js","sourceRoot":"","sources":["../src/text-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA+B,MAAM,mBAAmB,CAAC;AAGvF,MAAM,UAAU,SAAS,CAAC,GAAkB;IAC1C,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAmDD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S,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAErE,OAAO;QACL,OAAO;QACP,OAAO;QACP,WAAW;QACX,YAAY;QACZ,EAAE;QACF,EAAE;QACF,KAAK,EAAE,eAAe;QACtB,aAAa;QACb,IAAI;QACJ,MAAM;QACN,OAAO;QACP,WAAW;QACX,QAAQ;QACR,WAAW;QACX,SAAS;QACT,yEAAyE;QACzE,uEAAuE;QACvE,sDAAsD;QACtD,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI;QACnD,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI;QAC7D,KAAK;QACL,MAAM;QACN,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formless63/viewer-lbx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Brother P-touch .lbx label viewer.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"brother",
|
|
8
|
+
"p-touch",
|
|
9
|
+
"lbx",
|
|
10
|
+
"label"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/formless63/netlibs.git",
|
|
16
|
+
"directory": "packages/viewer-lbx"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/formless63/netlibs/tree/main/packages/viewer-lbx#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/formless63/netlibs/issues"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"**/*.css"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./definitions": {
|
|
40
|
+
"types": "./dist/definitions.d.ts",
|
|
41
|
+
"import": "./dist/definitions.js"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@formless63/viewer-core": "0.1.0",
|
|
47
|
+
"bil-lbx": "0.3.1",
|
|
48
|
+
"fast-xml-parser": "^5.9.3",
|
|
49
|
+
"jszip": "^3.10.1"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": "^19.0.0"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
}
|
|
57
|
+
}
|