@pooder/kit 5.3.1 → 5.4.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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +243 -36
- package/dist/index.d.ts +243 -36
- package/dist/index.js +2278 -1041
- package/dist/index.mjs +2278 -1041
- package/package.json +1 -1
- package/src/coordinate.ts +106 -106
- package/src/extensions/background.ts +323 -230
- package/src/extensions/bridgeSelection.ts +17 -17
- package/src/extensions/constraints.ts +322 -322
- package/src/extensions/dieline.ts +1149 -1076
- package/src/extensions/dielineShape.ts +109 -0
- package/src/extensions/edgeScale.ts +19 -19
- package/src/extensions/feature.ts +1137 -1021
- package/src/extensions/featureComplete.ts +46 -46
- package/src/extensions/film.ts +266 -194
- package/src/extensions/geometry.ts +885 -752
- package/src/extensions/image.ts +2054 -1926
- package/src/extensions/index.ts +11 -11
- package/src/extensions/maskOps.ts +283 -283
- package/src/extensions/mirror.ts +128 -128
- package/src/extensions/ruler.ts +654 -451
- package/src/extensions/sceneLayout.ts +140 -140
- package/src/extensions/sceneLayoutModel.ts +364 -352
- package/src/extensions/sceneVisibility.ts +64 -71
- package/src/extensions/size.ts +389 -389
- package/src/extensions/tracer.ts +1019 -1019
- package/src/extensions/white-ink.ts +1567 -1514
- package/src/extensions/wrappedOffsets.ts +33 -33
- package/src/index.ts +2 -2
- package/src/services/CanvasService.ts +832 -300
- package/src/services/ViewportSystem.ts +95 -95
- package/src/services/index.ts +3 -3
- package/src/services/renderSpec.ts +53 -18
- package/src/units.ts +27 -27
- package/tests/run.ts +118 -118
- package/tsconfig.test.json +15 -15
- package/.test-dist/src/CanvasService.js +0 -249
- package/.test-dist/src/ViewportSystem.js +0 -75
- package/.test-dist/src/background.js +0 -203
- package/.test-dist/src/bridgeSelection.js +0 -20
- package/.test-dist/src/constraints.js +0 -237
- package/.test-dist/src/coordinate.js +0 -74
- package/.test-dist/src/dieline.js +0 -818
- package/.test-dist/src/edgeScale.js +0 -12
- package/.test-dist/src/extensions/background.js +0 -203
- package/.test-dist/src/extensions/bridgeSelection.js +0 -20
- package/.test-dist/src/extensions/constraints.js +0 -237
- package/.test-dist/src/extensions/dieline.js +0 -828
- package/.test-dist/src/extensions/edgeScale.js +0 -12
- package/.test-dist/src/extensions/feature.js +0 -825
- package/.test-dist/src/extensions/featureComplete.js +0 -32
- package/.test-dist/src/extensions/film.js +0 -167
- package/.test-dist/src/extensions/geometry.js +0 -545
- package/.test-dist/src/extensions/image.js +0 -1529
- package/.test-dist/src/extensions/index.js +0 -30
- package/.test-dist/src/extensions/maskOps.js +0 -279
- package/.test-dist/src/extensions/mirror.js +0 -104
- package/.test-dist/src/extensions/ruler.js +0 -345
- package/.test-dist/src/extensions/sceneLayout.js +0 -96
- package/.test-dist/src/extensions/sceneLayoutModel.js +0 -196
- package/.test-dist/src/extensions/sceneVisibility.js +0 -62
- package/.test-dist/src/extensions/size.js +0 -331
- package/.test-dist/src/extensions/tracer.js +0 -538
- package/.test-dist/src/extensions/white-ink.js +0 -1190
- package/.test-dist/src/extensions/wrappedOffsets.js +0 -33
- package/.test-dist/src/feature.js +0 -826
- package/.test-dist/src/featureComplete.js +0 -32
- package/.test-dist/src/film.js +0 -167
- package/.test-dist/src/geometry.js +0 -506
- package/.test-dist/src/image.js +0 -1250
- package/.test-dist/src/index.js +0 -18
- package/.test-dist/src/maskOps.js +0 -270
- package/.test-dist/src/mirror.js +0 -104
- package/.test-dist/src/renderSpec.js +0 -2
- package/.test-dist/src/ruler.js +0 -343
- package/.test-dist/src/sceneLayout.js +0 -99
- package/.test-dist/src/sceneLayoutModel.js +0 -196
- package/.test-dist/src/sceneView.js +0 -40
- package/.test-dist/src/sceneVisibility.js +0 -42
- package/.test-dist/src/services/CanvasService.js +0 -249
- package/.test-dist/src/services/ViewportSystem.js +0 -76
- package/.test-dist/src/services/index.js +0 -24
- package/.test-dist/src/services/renderSpec.js +0 -2
- package/.test-dist/src/size.js +0 -332
- package/.test-dist/src/tracer.js +0 -544
- package/.test-dist/src/units.js +0 -30
- package/.test-dist/src/white-ink.js +0 -829
- package/.test-dist/src/wrappedOffsets.js +0 -33
- package/.test-dist/tests/run.js +0 -94
|
@@ -1,71 +1,64 @@
|
|
|
1
|
-
import { Service, ServiceContext, WORKBENCH_SERVICE } from "@pooder/core";
|
|
2
|
-
import { CanvasService } from "../services";
|
|
3
|
-
|
|
4
|
-
const CANVAS_SERVICE_ID = "CanvasService";
|
|
5
|
-
const HIDDEN_DIELINE_TOOLS = new Set(["pooder.kit.image", "pooder.kit.white-ink"]);
|
|
6
|
-
const HIDDEN_RULER_TOOLS = new Set(["pooder.kit.white-ink"]);
|
|
7
|
-
|
|
8
|
-
export class SceneVisibilityService implements Service {
|
|
9
|
-
private context?: ServiceContext;
|
|
10
|
-
private activeToolId: string | null = null;
|
|
11
|
-
private canvasService?: CanvasService;
|
|
12
|
-
|
|
13
|
-
init(context: ServiceContext) {
|
|
14
|
-
if (this.context) {
|
|
15
|
-
this.dispose(this.context);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const canvasService =
|
|
19
|
-
context.get<CanvasService>(CANVAS_SERVICE_ID);
|
|
20
|
-
if (!canvasService) {
|
|
21
|
-
throw new Error("[SceneVisibilityService] CanvasService is required.");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
this.context = context;
|
|
25
|
-
this.canvasService = canvasService;
|
|
26
|
-
this.activeToolId = context.get(WORKBENCH_SERVICE)?.activeToolId ?? null;
|
|
27
|
-
context.eventBus.on("tool:activated", this.onToolActivated);
|
|
28
|
-
context.eventBus.on("object:added", this.onObjectAdded);
|
|
29
|
-
this.apply();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
dispose(context: ServiceContext) {
|
|
33
|
-
const activeContext = this.context ?? context;
|
|
34
|
-
activeContext.eventBus.off("tool:activated", this.onToolActivated);
|
|
35
|
-
activeContext.eventBus.off("object:added", this.onObjectAdded);
|
|
36
|
-
this.context = undefined;
|
|
37
|
-
this.activeToolId = null;
|
|
38
|
-
this.canvasService = undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private onToolActivated = (e: { id: string | null }) => {
|
|
42
|
-
this.activeToolId = e.id;
|
|
43
|
-
this.apply();
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
private onObjectAdded = () => {
|
|
47
|
-
this.apply();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
private apply() {
|
|
51
|
-
if (!this.canvasService) return;
|
|
52
|
-
|
|
53
|
-
const dielineLayer = this.canvasService.getLayer("dieline-overlay");
|
|
54
|
-
if (dielineLayer) {
|
|
55
|
-
const visible = !HIDDEN_DIELINE_TOOLS.has(this.activeToolId || "");
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
rulerLayer.set({ visible });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
this.canvasService.requestRenderAll();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
1
|
+
import { Service, ServiceContext, WORKBENCH_SERVICE } from "@pooder/core";
|
|
2
|
+
import { CanvasService } from "../services";
|
|
3
|
+
|
|
4
|
+
const CANVAS_SERVICE_ID = "CanvasService";
|
|
5
|
+
const HIDDEN_DIELINE_TOOLS = new Set(["pooder.kit.image", "pooder.kit.white-ink"]);
|
|
6
|
+
const HIDDEN_RULER_TOOLS = new Set(["pooder.kit.white-ink"]);
|
|
7
|
+
|
|
8
|
+
export class SceneVisibilityService implements Service {
|
|
9
|
+
private context?: ServiceContext;
|
|
10
|
+
private activeToolId: string | null = null;
|
|
11
|
+
private canvasService?: CanvasService;
|
|
12
|
+
|
|
13
|
+
init(context: ServiceContext) {
|
|
14
|
+
if (this.context) {
|
|
15
|
+
this.dispose(this.context);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const canvasService =
|
|
19
|
+
context.get<CanvasService>(CANVAS_SERVICE_ID);
|
|
20
|
+
if (!canvasService) {
|
|
21
|
+
throw new Error("[SceneVisibilityService] CanvasService is required.");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.context = context;
|
|
25
|
+
this.canvasService = canvasService;
|
|
26
|
+
this.activeToolId = context.get(WORKBENCH_SERVICE)?.activeToolId ?? null;
|
|
27
|
+
context.eventBus.on("tool:activated", this.onToolActivated);
|
|
28
|
+
context.eventBus.on("object:added", this.onObjectAdded);
|
|
29
|
+
this.apply();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dispose(context: ServiceContext) {
|
|
33
|
+
const activeContext = this.context ?? context;
|
|
34
|
+
activeContext.eventBus.off("tool:activated", this.onToolActivated);
|
|
35
|
+
activeContext.eventBus.off("object:added", this.onObjectAdded);
|
|
36
|
+
this.context = undefined;
|
|
37
|
+
this.activeToolId = null;
|
|
38
|
+
this.canvasService = undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private onToolActivated = (e: { id: string | null }) => {
|
|
42
|
+
this.activeToolId = e.id;
|
|
43
|
+
this.apply();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
private onObjectAdded = () => {
|
|
47
|
+
this.apply();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
private apply() {
|
|
51
|
+
if (!this.canvasService) return;
|
|
52
|
+
|
|
53
|
+
const dielineLayer = this.canvasService.getLayer("dieline-overlay");
|
|
54
|
+
if (dielineLayer) {
|
|
55
|
+
const visible = !HIDDEN_DIELINE_TOOLS.has(this.activeToolId || "");
|
|
56
|
+
this.canvasService.setLayerVisibility("dieline-overlay", visible);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const rulerVisible = !HIDDEN_RULER_TOOLS.has(this.activeToolId || "");
|
|
60
|
+
this.canvasService.setLayerVisibility("ruler-overlay", rulerVisible);
|
|
61
|
+
|
|
62
|
+
this.canvasService.requestRenderAll();
|
|
63
|
+
}
|
|
64
|
+
}
|