@pooder/kit 6.0.1 → 6.1.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.
- package/.test-dist/src/extensions/background/BackgroundTool.js +524 -0
- package/.test-dist/src/extensions/background/index.js +17 -0
- package/.test-dist/src/extensions/dieline/DielineTool.js +748 -0
- package/.test-dist/src/extensions/dieline/commands.js +127 -0
- package/.test-dist/src/extensions/dieline/config.js +107 -0
- package/.test-dist/src/extensions/dieline/index.js +21 -0
- package/.test-dist/src/extensions/dieline/model.js +2 -0
- package/.test-dist/src/extensions/dieline/renderer.js +2 -0
- package/.test-dist/src/extensions/feature/FeatureTool.js +914 -0
- package/.test-dist/src/extensions/feature/index.js +17 -0
- package/.test-dist/src/extensions/film/FilmTool.js +207 -0
- package/.test-dist/src/extensions/film/index.js +17 -0
- package/.test-dist/src/extensions/image/ImageTool.js +1499 -0
- package/.test-dist/src/extensions/image/commands.js +162 -0
- package/.test-dist/src/extensions/image/config.js +129 -0
- package/.test-dist/src/extensions/image/index.js +21 -0
- package/.test-dist/src/extensions/image/model.js +2 -0
- package/.test-dist/src/extensions/image/renderer.js +5 -0
- package/.test-dist/src/extensions/mirror/MirrorTool.js +104 -0
- package/.test-dist/src/extensions/mirror/index.js +17 -0
- package/.test-dist/src/extensions/ruler/RulerTool.js +442 -0
- package/.test-dist/src/extensions/ruler/index.js +17 -0
- package/.test-dist/src/extensions/sceneLayout.js +2 -93
- package/.test-dist/src/extensions/sceneLayoutModel.js +15 -200
- package/.test-dist/src/extensions/size/SizeTool.js +332 -0
- package/.test-dist/src/extensions/size/index.js +17 -0
- package/.test-dist/src/extensions/white-ink/WhiteInkTool.js +1003 -0
- package/.test-dist/src/extensions/white-ink/commands.js +148 -0
- package/.test-dist/src/extensions/white-ink/config.js +31 -0
- package/.test-dist/src/extensions/white-ink/index.js +21 -0
- package/.test-dist/src/extensions/white-ink/model.js +2 -0
- package/.test-dist/src/extensions/white-ink/renderer.js +5 -0
- package/.test-dist/src/services/SceneLayoutService.js +96 -0
- package/.test-dist/src/services/index.js +1 -0
- package/.test-dist/src/shared/constants/layers.js +25 -0
- package/.test-dist/src/shared/imaging/sourceSizeCache.js +82 -0
- package/.test-dist/src/shared/index.js +22 -0
- package/.test-dist/src/shared/runtime/sessionState.js +74 -0
- package/.test-dist/src/shared/runtime/subscriptions.js +30 -0
- package/.test-dist/src/shared/scene/frame.js +34 -0
- package/.test-dist/src/shared/scene/sceneLayoutModel.js +202 -0
- package/.test-dist/tests/run.js +116 -0
- package/CHANGELOG.md +14 -0
- package/dist/index.d.mts +390 -367
- package/dist/index.d.ts +390 -367
- package/dist/index.js +5138 -4927
- package/dist/index.mjs +1149 -1977
- package/dist/tracer-PO7CRBYY.mjs +1016 -0
- package/package.json +2 -2
- package/src/extensions/{background.ts → background/BackgroundTool.ts} +33 -50
- package/src/extensions/background/index.ts +1 -0
- package/src/extensions/{dieline.ts → dieline/DielineTool.ts} +14 -218
- package/src/extensions/dieline/commands.ts +109 -0
- package/src/extensions/dieline/config.ts +106 -0
- package/src/extensions/dieline/index.ts +5 -0
- package/src/extensions/dieline/model.ts +1 -0
- package/src/extensions/dieline/renderer.ts +1 -0
- package/src/extensions/{feature.ts → feature/FeatureTool.ts} +27 -21
- package/src/extensions/feature/index.ts +1 -0
- package/src/extensions/{film.ts → film/FilmTool.ts} +36 -48
- package/src/extensions/film/index.ts +1 -0
- package/src/extensions/{image.ts → image/ImageTool.ts} +123 -402
- package/src/extensions/image/commands.ts +176 -0
- package/src/extensions/image/config.ts +128 -0
- package/src/extensions/image/index.ts +5 -0
- package/src/extensions/image/model.ts +1 -0
- package/src/extensions/image/renderer.ts +1 -0
- package/src/extensions/{mirror.ts → mirror/MirrorTool.ts} +1 -1
- package/src/extensions/mirror/index.ts +1 -0
- package/src/extensions/{ruler.ts → ruler/RulerTool.ts} +4 -5
- package/src/extensions/ruler/index.ts +1 -0
- package/src/extensions/sceneLayout.ts +1 -140
- package/src/extensions/sceneLayoutModel.ts +1 -364
- package/src/extensions/{size.ts → size/SizeTool.ts} +7 -6
- package/src/extensions/size/index.ts +1 -0
- package/src/extensions/{white-ink.ts → white-ink/WhiteInkTool.ts} +130 -317
- package/src/extensions/white-ink/commands.ts +157 -0
- package/src/extensions/white-ink/config.ts +30 -0
- package/src/extensions/white-ink/index.ts +5 -0
- package/src/extensions/white-ink/model.ts +1 -0
- package/src/extensions/white-ink/renderer.ts +1 -0
- package/src/services/SceneLayoutService.ts +139 -0
- package/src/services/index.ts +1 -0
- package/src/shared/constants/layers.ts +23 -0
- package/src/shared/imaging/sourceSizeCache.ts +103 -0
- package/src/shared/index.ts +6 -0
- package/src/shared/runtime/sessionState.ts +105 -0
- package/src/shared/runtime/subscriptions.ts +45 -0
- package/src/shared/scene/frame.ts +46 -0
- package/src/shared/scene/sceneLayoutModel.ts +367 -0
- package/tests/run.ts +146 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWhiteInkCommands = createWhiteInkCommands;
|
|
4
|
+
const WHITE_INK_PREVIEW_IMAGE_VISIBLE_KEY = "whiteInk.previewImageVisible";
|
|
5
|
+
const WHITE_INK_DEFAULT_OPACITY = 0.85;
|
|
6
|
+
function createWhiteInkCommands(tool) {
|
|
7
|
+
return [
|
|
8
|
+
{
|
|
9
|
+
command: "addWhiteInk",
|
|
10
|
+
id: "addWhiteInk",
|
|
11
|
+
title: "Add White Ink",
|
|
12
|
+
handler: async (url, options) => {
|
|
13
|
+
return await tool.addWhiteInkEntry(url, options);
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
command: "upsertWhiteInk",
|
|
18
|
+
id: "upsertWhiteInk",
|
|
19
|
+
title: "Upsert White Ink",
|
|
20
|
+
handler: async (url, options = {}) => {
|
|
21
|
+
return await tool.upsertWhiteInkEntry(url, options);
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
command: "getWhiteInks",
|
|
26
|
+
id: "getWhiteInks",
|
|
27
|
+
title: "Get White Inks",
|
|
28
|
+
handler: () => tool.cloneItems(tool.items),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
command: "getWhiteInkSettings",
|
|
32
|
+
id: "getWhiteInkSettings",
|
|
33
|
+
title: "Get White Ink Settings",
|
|
34
|
+
handler: () => {
|
|
35
|
+
const first = tool.getEffectiveWhiteInkItem(tool.items);
|
|
36
|
+
const primarySource = tool.getPrimaryImageSource();
|
|
37
|
+
const sourceUrl = tool.resolveSourceUrl(first) || primarySource;
|
|
38
|
+
return {
|
|
39
|
+
id: first?.id || null,
|
|
40
|
+
url: sourceUrl,
|
|
41
|
+
sourceUrl,
|
|
42
|
+
opacity: WHITE_INK_DEFAULT_OPACITY,
|
|
43
|
+
printWithWhiteInk: tool.printWithWhiteInk,
|
|
44
|
+
previewImageVisible: tool.previewImageVisible,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
command: "setWhiteInkPrintEnabled",
|
|
50
|
+
id: "setWhiteInkPrintEnabled",
|
|
51
|
+
title: "Set White Ink Preview Enabled",
|
|
52
|
+
handler: (enabled) => {
|
|
53
|
+
tool.printWithWhiteInk = !!enabled;
|
|
54
|
+
const configService = tool.context?.services.get("ConfigurationService");
|
|
55
|
+
configService?.update("whiteInk.printWithWhiteInk", tool.printWithWhiteInk);
|
|
56
|
+
tool.updateWhiteInks();
|
|
57
|
+
return { ok: true };
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
command: "setWhiteInkPreviewImageVisible",
|
|
62
|
+
id: "setWhiteInkPreviewImageVisible",
|
|
63
|
+
title: "Set White Ink Cover Visible",
|
|
64
|
+
handler: (visible) => {
|
|
65
|
+
tool.previewImageVisible = !!visible;
|
|
66
|
+
const configService = tool.context?.services.get("ConfigurationService");
|
|
67
|
+
configService?.update(WHITE_INK_PREVIEW_IMAGE_VISIBLE_KEY, tool.previewImageVisible);
|
|
68
|
+
tool.updateWhiteInks();
|
|
69
|
+
return { ok: true };
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
command: "getWorkingWhiteInks",
|
|
74
|
+
id: "getWorkingWhiteInks",
|
|
75
|
+
title: "Get Working White Inks",
|
|
76
|
+
handler: () => tool.cloneItems(tool.workingItems),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
command: "setWorkingWhiteInk",
|
|
80
|
+
id: "setWorkingWhiteInk",
|
|
81
|
+
title: "Set Working White Ink",
|
|
82
|
+
handler: (id, updates) => {
|
|
83
|
+
tool.updateWhiteInkInWorking(id, updates);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
command: "updateWhiteInk",
|
|
88
|
+
id: "updateWhiteInk",
|
|
89
|
+
title: "Update White Ink",
|
|
90
|
+
handler: async (id, updates, options = {}) => {
|
|
91
|
+
await tool.updateWhiteInkItem(id, updates, options);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
command: "removeWhiteInk",
|
|
96
|
+
id: "removeWhiteInk",
|
|
97
|
+
title: "Remove White Ink",
|
|
98
|
+
handler: (id) => {
|
|
99
|
+
tool.removeWhiteInk(id);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
command: "clearWhiteInks",
|
|
104
|
+
id: "clearWhiteInks",
|
|
105
|
+
title: "Clear White Inks",
|
|
106
|
+
handler: () => {
|
|
107
|
+
tool.clearWhiteInks();
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
command: "resetWorkingWhiteInks",
|
|
112
|
+
id: "resetWorkingWhiteInks",
|
|
113
|
+
title: "Reset Working White Inks",
|
|
114
|
+
handler: () => {
|
|
115
|
+
tool.workingItems = tool.cloneItems(tool.items);
|
|
116
|
+
tool.hasWorkingChanges = false;
|
|
117
|
+
tool.updateWhiteInks();
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
command: "completeWhiteInks",
|
|
122
|
+
id: "completeWhiteInks",
|
|
123
|
+
title: "Complete White Inks",
|
|
124
|
+
handler: async () => {
|
|
125
|
+
return await tool.completeWhiteInks();
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
command: "setWhiteInkImage",
|
|
130
|
+
id: "setWhiteInkImage",
|
|
131
|
+
title: "Set White Ink Image",
|
|
132
|
+
handler: async (url) => {
|
|
133
|
+
if (!url) {
|
|
134
|
+
tool.clearWhiteInks();
|
|
135
|
+
return { ok: true };
|
|
136
|
+
}
|
|
137
|
+
const targetId = tool.resolveReplaceTargetId(null);
|
|
138
|
+
const upsertResult = await tool.upsertWhiteInkEntry(url, {
|
|
139
|
+
id: targetId || undefined,
|
|
140
|
+
mode: targetId ? "replace" : "add",
|
|
141
|
+
createIfMissing: true,
|
|
142
|
+
addOptions: {},
|
|
143
|
+
});
|
|
144
|
+
return { ok: true, id: upsertResult.id };
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWhiteInkConfigurations = createWhiteInkConfigurations;
|
|
4
|
+
function createWhiteInkConfigurations() {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
id: "whiteInk.items",
|
|
8
|
+
type: "array",
|
|
9
|
+
label: "White Ink Images",
|
|
10
|
+
default: [],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "whiteInk.printWithWhiteInk",
|
|
14
|
+
type: "boolean",
|
|
15
|
+
label: "Preview White Ink",
|
|
16
|
+
default: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "whiteInk.previewImageVisible",
|
|
20
|
+
type: "boolean",
|
|
21
|
+
label: "Show Cover During White Ink Preview",
|
|
22
|
+
default: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "whiteInk.debug",
|
|
26
|
+
type: "boolean",
|
|
27
|
+
label: "White Ink Debug Log",
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./WhiteInkTool"), exports);
|
|
18
|
+
__exportStar(require("./commands"), exports);
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
__exportStar(require("./model"), exports);
|
|
21
|
+
__exportStar(require("./renderer"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeWhiteInkCoverScale = void 0;
|
|
4
|
+
var sourceSizeCache_1 = require("../../shared/imaging/sourceSizeCache");
|
|
5
|
+
Object.defineProperty(exports, "computeWhiteInkCoverScale", { enumerable: true, get: function () { return sourceSizeCache_1.getCoverScale; } });
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SceneLayoutService = void 0;
|
|
4
|
+
const core_1 = require("@pooder/core");
|
|
5
|
+
const sceneLayoutModel_1 = require("../shared/scene/sceneLayoutModel");
|
|
6
|
+
const subscriptions_1 = require("../shared/runtime/subscriptions");
|
|
7
|
+
const CONFIG_WATCH_PREFIXES = ["size.", "dieline."];
|
|
8
|
+
const CANVAS_SERVICE_ID = "CanvasService";
|
|
9
|
+
const GET_SCENE_LAYOUT_COMMAND = "getSceneLayout";
|
|
10
|
+
const GET_SCENE_GEOMETRY_COMMAND = "getSceneGeometry";
|
|
11
|
+
class SceneLayoutService {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.lastLayout = null;
|
|
14
|
+
this.lastGeometry = null;
|
|
15
|
+
this.subscriptions = new subscriptions_1.SubscriptionBag();
|
|
16
|
+
this.commandDisposables = [];
|
|
17
|
+
this.onCanvasResized = () => {
|
|
18
|
+
this.refresh();
|
|
19
|
+
};
|
|
20
|
+
this.onConfigChanged = (e) => {
|
|
21
|
+
if (CONFIG_WATCH_PREFIXES.some((prefix) => e.key.startsWith(prefix))) {
|
|
22
|
+
this.refresh();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
init(context) {
|
|
27
|
+
if (this.context) {
|
|
28
|
+
this.dispose(this.context);
|
|
29
|
+
}
|
|
30
|
+
const canvasService = context.get(CANVAS_SERVICE_ID);
|
|
31
|
+
const configService = context.get(core_1.CONFIGURATION_SERVICE);
|
|
32
|
+
const commandService = context.get(core_1.COMMAND_SERVICE);
|
|
33
|
+
if (!canvasService || !configService || !commandService) {
|
|
34
|
+
throw new Error("[SceneLayoutService] CanvasService, ConfigurationService and CommandService are required.");
|
|
35
|
+
}
|
|
36
|
+
this.context = context;
|
|
37
|
+
this.canvasService = canvasService;
|
|
38
|
+
this.configService = configService;
|
|
39
|
+
this.commandDisposables.push(commandService.registerCommand(GET_SCENE_LAYOUT_COMMAND, () => this.getLayout()), commandService.registerCommand(GET_SCENE_GEOMETRY_COMMAND, () => this.getGeometry()));
|
|
40
|
+
this.subscriptions.disposeAll();
|
|
41
|
+
this.subscriptions.onConfigChange(configService, this.onConfigChanged);
|
|
42
|
+
this.subscriptions.on(context.eventBus, "canvas:resized", this.onCanvasResized);
|
|
43
|
+
this.refresh();
|
|
44
|
+
}
|
|
45
|
+
dispose(context) {
|
|
46
|
+
this.subscriptions.disposeAll();
|
|
47
|
+
this.commandDisposables.forEach((item) => item.dispose());
|
|
48
|
+
this.commandDisposables = [];
|
|
49
|
+
this.context = undefined;
|
|
50
|
+
this.canvasService = undefined;
|
|
51
|
+
this.configService = undefined;
|
|
52
|
+
this.lastLayout = null;
|
|
53
|
+
this.lastGeometry = null;
|
|
54
|
+
}
|
|
55
|
+
refresh() {
|
|
56
|
+
const layout = this.getLayout(true);
|
|
57
|
+
if (!layout) {
|
|
58
|
+
this.lastGeometry = null;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.context?.eventBus.emit("scene:layout:change", layout);
|
|
62
|
+
const geometry = this.getGeometry(true);
|
|
63
|
+
if (geometry) {
|
|
64
|
+
this.context?.eventBus.emit("scene:geometry:change", geometry);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
getLayout(forceRefresh = false) {
|
|
68
|
+
if (!this.canvasService || !this.configService)
|
|
69
|
+
return null;
|
|
70
|
+
if (!forceRefresh && this.lastLayout)
|
|
71
|
+
return this.lastLayout;
|
|
72
|
+
const state = (0, sceneLayoutModel_1.readSizeState)(this.configService);
|
|
73
|
+
const layout = (0, sceneLayoutModel_1.computeSceneLayout)(this.canvasService, state);
|
|
74
|
+
if (!layout) {
|
|
75
|
+
this.lastLayout = null;
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
this.lastLayout = layout;
|
|
79
|
+
return layout;
|
|
80
|
+
}
|
|
81
|
+
getGeometry(forceRefresh = false) {
|
|
82
|
+
if (!this.configService)
|
|
83
|
+
return null;
|
|
84
|
+
const layout = this.getLayout(forceRefresh);
|
|
85
|
+
if (!layout) {
|
|
86
|
+
this.lastGeometry = null;
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (!forceRefresh && this.lastGeometry)
|
|
90
|
+
return this.lastGeometry;
|
|
91
|
+
const geometry = (0, sceneLayoutModel_1.buildSceneGeometry)(this.configService, layout);
|
|
92
|
+
this.lastGeometry = geometry;
|
|
93
|
+
return geometry;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.SceneLayoutService = SceneLayoutService;
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.CanvasService = void 0;
|
|
21
21
|
var CanvasService_1 = require("./CanvasService");
|
|
22
22
|
Object.defineProperty(exports, "CanvasService", { enumerable: true, get: function () { return __importDefault(CanvasService_1).default; } });
|
|
23
|
+
__exportStar(require("./SceneLayoutService"), exports);
|
|
23
24
|
__exportStar(require("./renderSpec"), exports);
|
|
24
25
|
__exportStar(require("./visibility"), exports);
|
|
25
26
|
__exportStar(require("./ViewportSystem"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LAYER_IDS = exports.FILM_LAYER_ID = exports.RULER_LAYER_ID = exports.FEATURE_OVERLAY_LAYER_ID = exports.DIELINE_LAYER_ID = exports.WHITE_INK_OVERLAY_LAYER_ID = exports.WHITE_INK_COVER_LAYER_ID = exports.WHITE_INK_OBJECT_LAYER_ID = exports.IMAGE_OVERLAY_LAYER_ID = exports.IMAGE_OBJECT_LAYER_ID = exports.BACKGROUND_LAYER_ID = void 0;
|
|
4
|
+
exports.BACKGROUND_LAYER_ID = "background";
|
|
5
|
+
exports.IMAGE_OBJECT_LAYER_ID = "image.user";
|
|
6
|
+
exports.IMAGE_OVERLAY_LAYER_ID = "image-overlay";
|
|
7
|
+
exports.WHITE_INK_OBJECT_LAYER_ID = "white-ink.user";
|
|
8
|
+
exports.WHITE_INK_COVER_LAYER_ID = "white-ink.cover";
|
|
9
|
+
exports.WHITE_INK_OVERLAY_LAYER_ID = "white-ink.overlay";
|
|
10
|
+
exports.DIELINE_LAYER_ID = "dieline-overlay";
|
|
11
|
+
exports.FEATURE_OVERLAY_LAYER_ID = "feature-overlay";
|
|
12
|
+
exports.RULER_LAYER_ID = "ruler-overlay";
|
|
13
|
+
exports.FILM_LAYER_ID = "overlay";
|
|
14
|
+
exports.LAYER_IDS = {
|
|
15
|
+
background: exports.BACKGROUND_LAYER_ID,
|
|
16
|
+
imageObject: exports.IMAGE_OBJECT_LAYER_ID,
|
|
17
|
+
imageOverlay: exports.IMAGE_OVERLAY_LAYER_ID,
|
|
18
|
+
whiteInkObject: exports.WHITE_INK_OBJECT_LAYER_ID,
|
|
19
|
+
whiteInkCover: exports.WHITE_INK_COVER_LAYER_ID,
|
|
20
|
+
whiteInkOverlay: exports.WHITE_INK_OVERLAY_LAYER_ID,
|
|
21
|
+
dieline: exports.DIELINE_LAYER_ID,
|
|
22
|
+
featureOverlay: exports.FEATURE_OVERLAY_LAYER_ID,
|
|
23
|
+
rulerOverlay: exports.RULER_LAYER_ID,
|
|
24
|
+
filmOverlay: exports.FILM_LAYER_ID,
|
|
25
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeSourceSize = normalizeSourceSize;
|
|
4
|
+
exports.getCoverScale = getCoverScale;
|
|
5
|
+
exports.createSourceSizeCache = createSourceSizeCache;
|
|
6
|
+
function normalizeSourceSize(size) {
|
|
7
|
+
const width = Number(size.width || 0);
|
|
8
|
+
const height = Number(size.height || 0);
|
|
9
|
+
if (!Number.isFinite(width) || !Number.isFinite(height))
|
|
10
|
+
return null;
|
|
11
|
+
if (width <= 0 || height <= 0)
|
|
12
|
+
return null;
|
|
13
|
+
return { width, height };
|
|
14
|
+
}
|
|
15
|
+
function getCoverScale(frame, source) {
|
|
16
|
+
const frameWidth = Math.max(1, Number(frame.width || 0));
|
|
17
|
+
const frameHeight = Math.max(1, Number(frame.height || 0));
|
|
18
|
+
const sourceWidth = Math.max(1, Number(source.width || 0));
|
|
19
|
+
const sourceHeight = Math.max(1, Number(source.height || 0));
|
|
20
|
+
return Math.max(frameWidth / sourceWidth, frameHeight / sourceHeight);
|
|
21
|
+
}
|
|
22
|
+
function createSourceSizeCache(loadSize) {
|
|
23
|
+
const sizesBySrc = new Map();
|
|
24
|
+
const pendingBySrc = new Map();
|
|
25
|
+
const rememberSourceSize = (src, size) => {
|
|
26
|
+
const normalized = normalizeSourceSize(size);
|
|
27
|
+
if (!src || !normalized)
|
|
28
|
+
return null;
|
|
29
|
+
sizesBySrc.set(src, normalized);
|
|
30
|
+
return normalized;
|
|
31
|
+
};
|
|
32
|
+
const getSourceSize = (src) => {
|
|
33
|
+
if (!src)
|
|
34
|
+
return null;
|
|
35
|
+
const cached = sizesBySrc.get(src);
|
|
36
|
+
if (!cached)
|
|
37
|
+
return null;
|
|
38
|
+
return { width: cached.width, height: cached.height };
|
|
39
|
+
};
|
|
40
|
+
const ensureImageSize = async (src) => {
|
|
41
|
+
if (!src)
|
|
42
|
+
return null;
|
|
43
|
+
const cached = sizesBySrc.get(src);
|
|
44
|
+
if (cached)
|
|
45
|
+
return { width: cached.width, height: cached.height };
|
|
46
|
+
const pending = pendingBySrc.get(src);
|
|
47
|
+
if (pending) {
|
|
48
|
+
return pending;
|
|
49
|
+
}
|
|
50
|
+
const task = loadSize(src);
|
|
51
|
+
pendingBySrc.set(src, task);
|
|
52
|
+
try {
|
|
53
|
+
const size = await task;
|
|
54
|
+
if (size) {
|
|
55
|
+
rememberSourceSize(src, size);
|
|
56
|
+
}
|
|
57
|
+
return size;
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
if (pendingBySrc.get(src) === task) {
|
|
61
|
+
pendingBySrc.delete(src);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const deleteSourceSize = (src) => {
|
|
66
|
+
if (!src)
|
|
67
|
+
return;
|
|
68
|
+
sizesBySrc.delete(src);
|
|
69
|
+
pendingBySrc.delete(src);
|
|
70
|
+
};
|
|
71
|
+
const clear = () => {
|
|
72
|
+
sizesBySrc.clear();
|
|
73
|
+
pendingBySrc.clear();
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
ensureImageSize,
|
|
77
|
+
rememberSourceSize,
|
|
78
|
+
getSourceSize,
|
|
79
|
+
deleteSourceSize,
|
|
80
|
+
clear,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants/layers"), exports);
|
|
18
|
+
__exportStar(require("./imaging/sourceSizeCache"), exports);
|
|
19
|
+
__exportStar(require("./runtime/sessionState"), exports);
|
|
20
|
+
__exportStar(require("./runtime/subscriptions"), exports);
|
|
21
|
+
__exportStar(require("./scene/frame"), exports);
|
|
22
|
+
__exportStar(require("./scene/sceneLayoutModel"), exports);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkingSessionState = void 0;
|
|
4
|
+
exports.cloneWithJson = cloneWithJson;
|
|
5
|
+
exports.applyCommittedSnapshot = applyCommittedSnapshot;
|
|
6
|
+
exports.runDeferredConfigUpdate = runDeferredConfigUpdate;
|
|
7
|
+
function cloneWithJson(value) {
|
|
8
|
+
return JSON.parse(JSON.stringify(value));
|
|
9
|
+
}
|
|
10
|
+
function applyCommittedSnapshot(session, nextCommitted, options) {
|
|
11
|
+
const clone = options.clone;
|
|
12
|
+
session.committed = clone(nextCommitted);
|
|
13
|
+
const shouldPreserveDirtyWorking = options.toolActive &&
|
|
14
|
+
options.preserveDirtyWorking !== false &&
|
|
15
|
+
session.hasWorkingChanges;
|
|
16
|
+
if (!shouldPreserveDirtyWorking) {
|
|
17
|
+
session.working = clone(session.committed);
|
|
18
|
+
session.hasWorkingChanges = false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function runDeferredConfigUpdate(state, action, cooldownMs = 0) {
|
|
22
|
+
state.isUpdatingConfig = true;
|
|
23
|
+
action();
|
|
24
|
+
if (cooldownMs <= 0) {
|
|
25
|
+
state.isUpdatingConfig = false;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
state.isUpdatingConfig = false;
|
|
30
|
+
}, cooldownMs);
|
|
31
|
+
}
|
|
32
|
+
class WorkingSessionState {
|
|
33
|
+
constructor(initial, clone) {
|
|
34
|
+
this.hasWorkingChanges = false;
|
|
35
|
+
this.isUpdatingConfig = false;
|
|
36
|
+
this.clone = clone;
|
|
37
|
+
this.committed = this.clone(initial);
|
|
38
|
+
this.working = this.clone(initial);
|
|
39
|
+
}
|
|
40
|
+
setCommitted(next, options = {}) {
|
|
41
|
+
this.committed = this.clone(next);
|
|
42
|
+
const shouldPreserveDirtyWorking = options.toolActive === true &&
|
|
43
|
+
options.preserveDirtyWorking !== false &&
|
|
44
|
+
this.hasWorkingChanges;
|
|
45
|
+
if (!shouldPreserveDirtyWorking) {
|
|
46
|
+
this.working = this.clone(this.committed);
|
|
47
|
+
this.hasWorkingChanges = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setWorking(next, options = {}) {
|
|
51
|
+
this.working = this.clone(next);
|
|
52
|
+
if (options.markDirty !== false) {
|
|
53
|
+
this.hasWorkingChanges = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
resetWorkingFromCommitted() {
|
|
57
|
+
this.working = this.clone(this.committed);
|
|
58
|
+
this.hasWorkingChanges = false;
|
|
59
|
+
}
|
|
60
|
+
commitWorkingToCommitted() {
|
|
61
|
+
this.committed = this.clone(this.working);
|
|
62
|
+
this.hasWorkingChanges = false;
|
|
63
|
+
}
|
|
64
|
+
runConfigUpdate(action) {
|
|
65
|
+
this.isUpdatingConfig = true;
|
|
66
|
+
try {
|
|
67
|
+
action();
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
this.isUpdatingConfig = false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.WorkingSessionState = WorkingSessionState;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionBag = void 0;
|
|
4
|
+
class SubscriptionBag {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.disposables = [];
|
|
7
|
+
}
|
|
8
|
+
add(disposable) {
|
|
9
|
+
if (disposable) {
|
|
10
|
+
this.disposables.push(disposable);
|
|
11
|
+
}
|
|
12
|
+
return disposable;
|
|
13
|
+
}
|
|
14
|
+
on(eventBus, event, handler) {
|
|
15
|
+
eventBus.on(event, handler);
|
|
16
|
+
this.disposables.push({
|
|
17
|
+
dispose: () => eventBus.off(event, handler),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
onConfigChange(configService, handler) {
|
|
21
|
+
this.add(configService.onAnyChange(handler));
|
|
22
|
+
}
|
|
23
|
+
disposeAll() {
|
|
24
|
+
while (this.disposables.length > 0) {
|
|
25
|
+
const disposable = this.disposables.pop();
|
|
26
|
+
disposable?.dispose();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.SubscriptionBag = SubscriptionBag;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emptyFrameRect = emptyFrameRect;
|
|
4
|
+
exports.resolveCutFrameRect = resolveCutFrameRect;
|
|
5
|
+
exports.toLayoutSceneRect = toLayoutSceneRect;
|
|
6
|
+
const sceneLayoutModel_1 = require("./sceneLayoutModel");
|
|
7
|
+
function emptyFrameRect() {
|
|
8
|
+
return { left: 0, top: 0, width: 0, height: 0 };
|
|
9
|
+
}
|
|
10
|
+
function resolveCutFrameRect(canvasService, configService) {
|
|
11
|
+
if (!canvasService || !configService) {
|
|
12
|
+
return emptyFrameRect();
|
|
13
|
+
}
|
|
14
|
+
const sizeState = (0, sceneLayoutModel_1.readSizeState)(configService);
|
|
15
|
+
const layout = (0, sceneLayoutModel_1.computeSceneLayout)(canvasService, sizeState);
|
|
16
|
+
if (!layout) {
|
|
17
|
+
return emptyFrameRect();
|
|
18
|
+
}
|
|
19
|
+
return canvasService.toSceneRect({
|
|
20
|
+
left: layout.cutRect.left,
|
|
21
|
+
top: layout.cutRect.top,
|
|
22
|
+
width: layout.cutRect.width,
|
|
23
|
+
height: layout.cutRect.height,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function toLayoutSceneRect(rect) {
|
|
27
|
+
return {
|
|
28
|
+
left: rect.left,
|
|
29
|
+
top: rect.top,
|
|
30
|
+
width: rect.width,
|
|
31
|
+
height: rect.height,
|
|
32
|
+
space: "scene",
|
|
33
|
+
};
|
|
34
|
+
}
|