@pooder/kit 5.0.3 → 5.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/CHANGELOG.md +17 -0
- package/dist/index.d.mts +239 -269
- package/dist/index.d.ts +239 -269
- package/dist/index.js +6485 -5833
- package/dist/index.mjs +6587 -5923
- package/package.json +2 -2
- package/src/{background.ts → extensions/background.ts} +1 -1
- package/src/{dieline.ts → extensions/dieline.ts} +39 -17
- package/src/{feature.ts → extensions/feature.ts} +80 -67
- package/src/{film.ts → extensions/film.ts} +1 -1
- package/src/{geometry.ts → extensions/geometry.ts} +151 -105
- package/src/{image.ts → extensions/image.ts} +190 -192
- package/src/extensions/index.ts +11 -0
- package/src/{maskOps.ts → extensions/maskOps.ts} +28 -10
- package/src/{mirror.ts → extensions/mirror.ts} +1 -1
- package/src/{ruler.ts → extensions/ruler.ts} +5 -3
- package/src/extensions/sceneLayout.ts +140 -0
- package/src/{sceneLayoutModel.ts → extensions/sceneLayoutModel.ts} +17 -10
- package/src/extensions/sceneVisibility.ts +71 -0
- package/src/{size.ts → extensions/size.ts} +23 -13
- package/src/{tracer.ts → extensions/tracer.ts} +374 -45
- package/src/{white-ink.ts → extensions/white-ink.ts} +620 -236
- package/src/index.ts +2 -14
- package/src/{ViewportSystem.ts → services/ViewportSystem.ts} +5 -2
- package/src/services/index.ts +3 -0
- package/src/sceneLayout.ts +0 -121
- package/src/sceneVisibility.ts +0 -49
- /package/src/{bridgeSelection.ts → extensions/bridgeSelection.ts} +0 -0
- /package/src/{constraints.ts → extensions/constraints.ts} +0 -0
- /package/src/{edgeScale.ts → extensions/edgeScale.ts} +0 -0
- /package/src/{featureComplete.ts → extensions/featureComplete.ts} +0 -0
- /package/src/{wrappedOffsets.ts → extensions/wrappedOffsets.ts} +0 -0
- /package/src/{CanvasService.ts → services/CanvasService.ts} +0 -0
- /package/src/{renderSpec.ts → services/renderSpec.ts} +0 -0
package/src/index.ts
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./film";
|
|
4
|
-
export * from "./feature";
|
|
5
|
-
export * from "./image";
|
|
6
|
-
export * from "./white-ink";
|
|
7
|
-
export * from "./ruler";
|
|
8
|
-
export * from "./mirror";
|
|
9
|
-
export * from "./size";
|
|
10
|
-
export * from "./sceneLayout";
|
|
11
|
-
export * from "./sceneLayoutModel";
|
|
12
|
-
export * from "./sceneVisibility";
|
|
13
|
-
export * from "./units";
|
|
14
|
-
export { default as CanvasService } from "./CanvasService";
|
|
1
|
+
export * from "./extensions";
|
|
2
|
+
export * from "./services";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Coordinate, Layout, Point, Size } from "
|
|
1
|
+
import { Coordinate, Layout, Point, Size } from "../coordinate";
|
|
2
2
|
|
|
3
3
|
export class ViewportSystem {
|
|
4
4
|
private _containerSize: Size = { width: 0, height: 0 };
|
|
@@ -46,7 +46,10 @@ export class ViewportSystem {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
updatePhysical(width: number, height: number) {
|
|
49
|
-
if (
|
|
49
|
+
if (
|
|
50
|
+
this._physicalSize.width === width &&
|
|
51
|
+
this._physicalSize.height === height
|
|
52
|
+
)
|
|
50
53
|
return;
|
|
51
54
|
this._physicalSize = { width, height };
|
|
52
55
|
this.updateLayout();
|
package/src/sceneLayout.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CommandContribution,
|
|
3
|
-
ConfigurationService,
|
|
4
|
-
ContributionPointIds,
|
|
5
|
-
Extension,
|
|
6
|
-
ExtensionContext,
|
|
7
|
-
} from "@pooder/core";
|
|
8
|
-
import CanvasService from "./CanvasService";
|
|
9
|
-
import {
|
|
10
|
-
buildSceneGeometry,
|
|
11
|
-
computeSceneLayout,
|
|
12
|
-
readSizeState,
|
|
13
|
-
type SceneGeometrySnapshot,
|
|
14
|
-
type SceneLayoutSnapshot,
|
|
15
|
-
} from "./sceneLayoutModel";
|
|
16
|
-
|
|
17
|
-
const GEOMETRY_KEYS = new Set([
|
|
18
|
-
"dieline.shape",
|
|
19
|
-
"dieline.radius",
|
|
20
|
-
"dieline.pathData",
|
|
21
|
-
"size.unit",
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
export class SceneLayoutService implements Extension {
|
|
25
|
-
id = "pooder.kit.sceneLayout";
|
|
26
|
-
metadata = {
|
|
27
|
-
name: "SceneLayoutService",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
private context?: ExtensionContext;
|
|
31
|
-
private canvasService?: CanvasService;
|
|
32
|
-
private configService?: ConfigurationService;
|
|
33
|
-
private lastLayout: SceneLayoutSnapshot | null = null;
|
|
34
|
-
private lastGeometry: SceneGeometrySnapshot | null = null;
|
|
35
|
-
private onConfigChange?: { dispose(): void };
|
|
36
|
-
|
|
37
|
-
activate(context: ExtensionContext) {
|
|
38
|
-
this.context = context;
|
|
39
|
-
this.canvasService = context.services.get<CanvasService>("CanvasService");
|
|
40
|
-
this.configService = context.services.get<ConfigurationService>(
|
|
41
|
-
"ConfigurationService",
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (!this.canvasService || !this.configService) return;
|
|
45
|
-
|
|
46
|
-
this.onConfigChange = this.configService.onAnyChange((e) => {
|
|
47
|
-
if (e.key.startsWith("size.") || e.key.startsWith("dieline.")) {
|
|
48
|
-
this.refresh(GEOMETRY_KEYS.has(e.key));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
context.eventBus.on("canvas:resized", this.onCanvasResized);
|
|
52
|
-
this.refresh(true);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
deactivate(context: ExtensionContext) {
|
|
56
|
-
context.eventBus.off("canvas:resized", this.onCanvasResized);
|
|
57
|
-
this.onConfigChange?.dispose();
|
|
58
|
-
this.onConfigChange = undefined;
|
|
59
|
-
this.context = undefined;
|
|
60
|
-
this.canvasService = undefined;
|
|
61
|
-
this.configService = undefined;
|
|
62
|
-
this.lastLayout = null;
|
|
63
|
-
this.lastGeometry = null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
contribute() {
|
|
67
|
-
return {
|
|
68
|
-
[ContributionPointIds.COMMANDS]: [
|
|
69
|
-
{
|
|
70
|
-
command: "getSceneLayout",
|
|
71
|
-
title: "Get Scene Layout",
|
|
72
|
-
handler: () => this.getLayout(),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
command: "getSceneGeometry",
|
|
76
|
-
title: "Get Scene Geometry",
|
|
77
|
-
handler: () => this.getGeometry(),
|
|
78
|
-
},
|
|
79
|
-
] as CommandContribution[],
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private onCanvasResized = () => {
|
|
84
|
-
this.refresh(true);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
private refresh(forceGeometry = false) {
|
|
88
|
-
const layout = this.getLayout(true);
|
|
89
|
-
if (!layout) return;
|
|
90
|
-
this.context?.eventBus.emit("scene:layout:change", layout);
|
|
91
|
-
|
|
92
|
-
if (forceGeometry || !this.lastGeometry) {
|
|
93
|
-
const geometry = this.getGeometry(true);
|
|
94
|
-
if (geometry) {
|
|
95
|
-
this.context?.eventBus.emit("scene:geometry:change", geometry);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private getLayout(forceRefresh = false): SceneLayoutSnapshot | null {
|
|
101
|
-
if (!this.canvasService || !this.configService) return null;
|
|
102
|
-
if (!forceRefresh && this.lastLayout) return this.lastLayout;
|
|
103
|
-
|
|
104
|
-
const state = readSizeState(this.configService);
|
|
105
|
-
const layout = computeSceneLayout(this.canvasService, state);
|
|
106
|
-
this.lastLayout = layout;
|
|
107
|
-
return layout;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private getGeometry(forceRefresh = false): SceneGeometrySnapshot | null {
|
|
111
|
-
if (!this.configService) return null;
|
|
112
|
-
const layout = this.getLayout(forceRefresh);
|
|
113
|
-
if (!layout) return null;
|
|
114
|
-
if (!forceRefresh && this.lastGeometry) return this.lastGeometry;
|
|
115
|
-
|
|
116
|
-
const geometry = buildSceneGeometry(this.configService, layout);
|
|
117
|
-
this.lastGeometry = geometry;
|
|
118
|
-
return geometry;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
package/src/sceneVisibility.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Extension, ExtensionContext } from "@pooder/core";
|
|
2
|
-
import CanvasService from "./CanvasService";
|
|
3
|
-
|
|
4
|
-
export class SceneVisibilityService implements Extension {
|
|
5
|
-
id = "pooder.kit.sceneVisibility";
|
|
6
|
-
|
|
7
|
-
metadata = {
|
|
8
|
-
name: "SceneVisibilityService",
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
private canvasService?: CanvasService;
|
|
12
|
-
private activeToolId: string | null = null;
|
|
13
|
-
|
|
14
|
-
activate(context: ExtensionContext) {
|
|
15
|
-
this.canvasService = context.services.get<CanvasService>("CanvasService");
|
|
16
|
-
context.eventBus.on("tool:activated", this.onToolActivated);
|
|
17
|
-
context.eventBus.on("object:added", this.onObjectAdded);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
deactivate(context: ExtensionContext) {
|
|
21
|
-
context.eventBus.off("tool:activated", this.onToolActivated);
|
|
22
|
-
context.eventBus.off("object:added", this.onObjectAdded);
|
|
23
|
-
this.activeToolId = null;
|
|
24
|
-
this.canvasService = undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private onToolActivated = (e: { id: string | null }) => {
|
|
28
|
-
this.activeToolId = e.id;
|
|
29
|
-
this.apply();
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
private onObjectAdded = () => {
|
|
33
|
-
this.apply();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
private apply() {
|
|
37
|
-
if (!this.canvasService) return;
|
|
38
|
-
|
|
39
|
-
const dielineLayer = this.canvasService.getLayer("dieline-overlay");
|
|
40
|
-
if (dielineLayer) {
|
|
41
|
-
const visible =
|
|
42
|
-
this.activeToolId !== "pooder.kit.image" &&
|
|
43
|
-
this.activeToolId !== "pooder.kit.white-ink";
|
|
44
|
-
(dielineLayer as any).set({ visible });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.canvasService.requestRenderAll();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|