@pooder/kit 5.4.0 → 6.0.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/coordinate.js +74 -0
- package/.test-dist/src/extensions/background.js +547 -0
- package/.test-dist/src/extensions/bridgeSelection.js +20 -0
- package/.test-dist/src/extensions/constraints.js +237 -0
- package/.test-dist/src/extensions/dieline.js +935 -0
- package/.test-dist/src/extensions/dielineShape.js +66 -0
- package/.test-dist/src/extensions/edgeScale.js +12 -0
- package/.test-dist/src/extensions/feature.js +910 -0
- package/.test-dist/src/extensions/featureComplete.js +32 -0
- package/.test-dist/src/extensions/film.js +226 -0
- package/.test-dist/src/extensions/geometry.js +609 -0
- package/.test-dist/src/extensions/image.js +1788 -0
- package/.test-dist/src/extensions/index.js +28 -0
- package/.test-dist/src/extensions/maskOps.js +334 -0
- package/.test-dist/src/extensions/mirror.js +104 -0
- package/.test-dist/src/extensions/ruler.js +442 -0
- package/.test-dist/src/extensions/sceneLayout.js +96 -0
- package/.test-dist/src/extensions/sceneLayoutModel.js +202 -0
- package/.test-dist/src/extensions/sceneVisibility.js +55 -0
- package/.test-dist/src/extensions/size.js +331 -0
- package/.test-dist/src/extensions/tracer.js +709 -0
- package/.test-dist/src/extensions/white-ink.js +1200 -0
- package/.test-dist/src/extensions/wrappedOffsets.js +33 -0
- package/.test-dist/src/index.js +18 -0
- package/.test-dist/src/services/CanvasService.js +1032 -0
- package/.test-dist/src/services/ViewportSystem.js +76 -0
- package/.test-dist/src/services/index.js +25 -0
- package/.test-dist/src/services/renderSpec.js +2 -0
- package/.test-dist/src/services/visibility.js +57 -0
- package/.test-dist/src/units.js +30 -0
- package/.test-dist/tests/run.js +150 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +164 -62
- package/dist/index.d.ts +164 -62
- package/dist/index.js +2433 -1719
- package/dist/index.mjs +2442 -1723
- package/package.json +1 -1
- package/src/coordinate.ts +106 -106
- package/src/extensions/background.ts +716 -323
- package/src/extensions/bridgeSelection.ts +17 -17
- package/src/extensions/constraints.ts +322 -322
- package/src/extensions/dieline.ts +1173 -1149
- package/src/extensions/dielineShape.ts +109 -109
- package/src/extensions/edgeScale.ts +19 -19
- package/src/extensions/feature.ts +1140 -1137
- package/src/extensions/featureComplete.ts +46 -46
- package/src/extensions/film.ts +270 -266
- package/src/extensions/geometry.ts +851 -885
- package/src/extensions/image.ts +2240 -2054
- package/src/extensions/index.ts +10 -11
- package/src/extensions/maskOps.ts +283 -283
- package/src/extensions/mirror.ts +128 -128
- package/src/extensions/ruler.ts +664 -654
- package/src/extensions/sceneLayout.ts +140 -140
- package/src/extensions/sceneLayoutModel.ts +364 -364
- package/src/extensions/size.ts +389 -389
- package/src/extensions/tracer.ts +1019 -1019
- package/src/extensions/white-ink.ts +1508 -1575
- package/src/extensions/wrappedOffsets.ts +33 -33
- package/src/index.ts +2 -2
- package/src/services/CanvasService.ts +1317 -832
- package/src/services/ViewportSystem.ts +95 -95
- package/src/services/index.ts +4 -3
- package/src/services/renderSpec.ts +85 -53
- package/src/services/visibility.ts +83 -0
- package/src/units.ts +27 -27
- package/tests/run.ts +258 -118
- package/tsconfig.test.json +15 -15
- package/src/extensions/sceneVisibility.ts +0 -64
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COMMAND_SERVICE,
|
|
3
|
-
CONFIGURATION_SERVICE,
|
|
4
|
-
CommandService,
|
|
5
|
-
ConfigurationService,
|
|
6
|
-
Service,
|
|
7
|
-
ServiceContext,
|
|
8
|
-
} from "@pooder/core";
|
|
9
|
-
import { CanvasService } from "../services";
|
|
10
|
-
import {
|
|
11
|
-
buildSceneGeometry,
|
|
12
|
-
computeSceneLayout,
|
|
13
|
-
readSizeState,
|
|
14
|
-
type SceneGeometrySnapshot,
|
|
15
|
-
type SceneLayoutSnapshot,
|
|
16
|
-
} from "./sceneLayoutModel";
|
|
17
|
-
|
|
18
|
-
interface ConfigChangeEvent {
|
|
19
|
-
key: string;
|
|
20
|
-
value: unknown;
|
|
21
|
-
oldValue: unknown;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const CONFIG_WATCH_PREFIXES = ["size.", "dieline."] as const;
|
|
25
|
-
const CANVAS_SERVICE_ID = "CanvasService";
|
|
26
|
-
const GET_SCENE_LAYOUT_COMMAND = "getSceneLayout";
|
|
27
|
-
const GET_SCENE_GEOMETRY_COMMAND = "getSceneGeometry";
|
|
28
|
-
|
|
29
|
-
export class SceneLayoutService implements Service {
|
|
30
|
-
private context?: ServiceContext;
|
|
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
|
-
private commandDisposables: Array<{ dispose(): void }> = [];
|
|
37
|
-
|
|
38
|
-
init(context: ServiceContext) {
|
|
39
|
-
if (this.context) {
|
|
40
|
-
this.dispose(this.context);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const canvasService =
|
|
44
|
-
context.get<CanvasService>(CANVAS_SERVICE_ID);
|
|
45
|
-
const configService =
|
|
46
|
-
context.get<ConfigurationService>(CONFIGURATION_SERVICE);
|
|
47
|
-
const commandService = context.get<CommandService>(COMMAND_SERVICE);
|
|
48
|
-
|
|
49
|
-
if (!canvasService || !configService || !commandService) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
"[SceneLayoutService] CanvasService, ConfigurationService and CommandService are required.",
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.context = context;
|
|
56
|
-
this.canvasService = canvasService;
|
|
57
|
-
this.configService = configService;
|
|
58
|
-
|
|
59
|
-
this.commandDisposables.push(
|
|
60
|
-
commandService.registerCommand(GET_SCENE_LAYOUT_COMMAND, () =>
|
|
61
|
-
this.getLayout(),
|
|
62
|
-
),
|
|
63
|
-
commandService.registerCommand(GET_SCENE_GEOMETRY_COMMAND, () =>
|
|
64
|
-
this.getGeometry(),
|
|
65
|
-
),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
this.onConfigChange = configService.onAnyChange(this.onConfigChanged);
|
|
69
|
-
context.eventBus.on("canvas:resized", this.onCanvasResized);
|
|
70
|
-
this.refresh();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
dispose(context: ServiceContext) {
|
|
74
|
-
const activeContext = this.context ?? context;
|
|
75
|
-
activeContext.eventBus.off("canvas:resized", this.onCanvasResized);
|
|
76
|
-
this.onConfigChange?.dispose();
|
|
77
|
-
this.onConfigChange = undefined;
|
|
78
|
-
this.commandDisposables.forEach((item) => item.dispose());
|
|
79
|
-
this.commandDisposables = [];
|
|
80
|
-
this.context = undefined;
|
|
81
|
-
this.canvasService = undefined;
|
|
82
|
-
this.configService = undefined;
|
|
83
|
-
this.lastLayout = null;
|
|
84
|
-
this.lastGeometry = null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private onCanvasResized = () => {
|
|
88
|
-
this.refresh();
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
private onConfigChanged = (e: ConfigChangeEvent) => {
|
|
92
|
-
if (CONFIG_WATCH_PREFIXES.some((prefix) => e.key.startsWith(prefix))) {
|
|
93
|
-
this.refresh();
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
private refresh() {
|
|
98
|
-
const layout = this.getLayout(true);
|
|
99
|
-
if (!layout) {
|
|
100
|
-
this.lastGeometry = null;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
this.context?.eventBus.emit("scene:layout:change", layout);
|
|
105
|
-
|
|
106
|
-
const geometry = this.getGeometry(true);
|
|
107
|
-
if (geometry) {
|
|
108
|
-
this.context?.eventBus.emit("scene:geometry:change", geometry);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
getLayout(forceRefresh = false): SceneLayoutSnapshot | null {
|
|
113
|
-
if (!this.canvasService || !this.configService) return null;
|
|
114
|
-
if (!forceRefresh && this.lastLayout) return this.lastLayout;
|
|
115
|
-
|
|
116
|
-
const state = readSizeState(this.configService);
|
|
117
|
-
const layout = computeSceneLayout(this.canvasService, state);
|
|
118
|
-
if (!layout) {
|
|
119
|
-
this.lastLayout = null;
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.lastLayout = layout;
|
|
124
|
-
return layout;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
getGeometry(forceRefresh = false): SceneGeometrySnapshot | null {
|
|
128
|
-
if (!this.configService) return null;
|
|
129
|
-
const layout = this.getLayout(forceRefresh);
|
|
130
|
-
if (!layout) {
|
|
131
|
-
this.lastGeometry = null;
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
if (!forceRefresh && this.lastGeometry) return this.lastGeometry;
|
|
135
|
-
|
|
136
|
-
const geometry = buildSceneGeometry(this.configService, layout);
|
|
137
|
-
this.lastGeometry = geometry;
|
|
138
|
-
return geometry;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
COMMAND_SERVICE,
|
|
3
|
+
CONFIGURATION_SERVICE,
|
|
4
|
+
CommandService,
|
|
5
|
+
ConfigurationService,
|
|
6
|
+
Service,
|
|
7
|
+
ServiceContext,
|
|
8
|
+
} from "@pooder/core";
|
|
9
|
+
import { CanvasService } from "../services";
|
|
10
|
+
import {
|
|
11
|
+
buildSceneGeometry,
|
|
12
|
+
computeSceneLayout,
|
|
13
|
+
readSizeState,
|
|
14
|
+
type SceneGeometrySnapshot,
|
|
15
|
+
type SceneLayoutSnapshot,
|
|
16
|
+
} from "./sceneLayoutModel";
|
|
17
|
+
|
|
18
|
+
interface ConfigChangeEvent {
|
|
19
|
+
key: string;
|
|
20
|
+
value: unknown;
|
|
21
|
+
oldValue: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const CONFIG_WATCH_PREFIXES = ["size.", "dieline."] as const;
|
|
25
|
+
const CANVAS_SERVICE_ID = "CanvasService";
|
|
26
|
+
const GET_SCENE_LAYOUT_COMMAND = "getSceneLayout";
|
|
27
|
+
const GET_SCENE_GEOMETRY_COMMAND = "getSceneGeometry";
|
|
28
|
+
|
|
29
|
+
export class SceneLayoutService implements Service {
|
|
30
|
+
private context?: ServiceContext;
|
|
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
|
+
private commandDisposables: Array<{ dispose(): void }> = [];
|
|
37
|
+
|
|
38
|
+
init(context: ServiceContext) {
|
|
39
|
+
if (this.context) {
|
|
40
|
+
this.dispose(this.context);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const canvasService =
|
|
44
|
+
context.get<CanvasService>(CANVAS_SERVICE_ID);
|
|
45
|
+
const configService =
|
|
46
|
+
context.get<ConfigurationService>(CONFIGURATION_SERVICE);
|
|
47
|
+
const commandService = context.get<CommandService>(COMMAND_SERVICE);
|
|
48
|
+
|
|
49
|
+
if (!canvasService || !configService || !commandService) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"[SceneLayoutService] CanvasService, ConfigurationService and CommandService are required.",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.context = context;
|
|
56
|
+
this.canvasService = canvasService;
|
|
57
|
+
this.configService = configService;
|
|
58
|
+
|
|
59
|
+
this.commandDisposables.push(
|
|
60
|
+
commandService.registerCommand(GET_SCENE_LAYOUT_COMMAND, () =>
|
|
61
|
+
this.getLayout(),
|
|
62
|
+
),
|
|
63
|
+
commandService.registerCommand(GET_SCENE_GEOMETRY_COMMAND, () =>
|
|
64
|
+
this.getGeometry(),
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
this.onConfigChange = configService.onAnyChange(this.onConfigChanged);
|
|
69
|
+
context.eventBus.on("canvas:resized", this.onCanvasResized);
|
|
70
|
+
this.refresh();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
dispose(context: ServiceContext) {
|
|
74
|
+
const activeContext = this.context ?? context;
|
|
75
|
+
activeContext.eventBus.off("canvas:resized", this.onCanvasResized);
|
|
76
|
+
this.onConfigChange?.dispose();
|
|
77
|
+
this.onConfigChange = undefined;
|
|
78
|
+
this.commandDisposables.forEach((item) => item.dispose());
|
|
79
|
+
this.commandDisposables = [];
|
|
80
|
+
this.context = undefined;
|
|
81
|
+
this.canvasService = undefined;
|
|
82
|
+
this.configService = undefined;
|
|
83
|
+
this.lastLayout = null;
|
|
84
|
+
this.lastGeometry = null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private onCanvasResized = () => {
|
|
88
|
+
this.refresh();
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
private onConfigChanged = (e: ConfigChangeEvent) => {
|
|
92
|
+
if (CONFIG_WATCH_PREFIXES.some((prefix) => e.key.startsWith(prefix))) {
|
|
93
|
+
this.refresh();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
private refresh() {
|
|
98
|
+
const layout = this.getLayout(true);
|
|
99
|
+
if (!layout) {
|
|
100
|
+
this.lastGeometry = null;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.context?.eventBus.emit("scene:layout:change", layout);
|
|
105
|
+
|
|
106
|
+
const geometry = this.getGeometry(true);
|
|
107
|
+
if (geometry) {
|
|
108
|
+
this.context?.eventBus.emit("scene:geometry:change", geometry);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getLayout(forceRefresh = false): SceneLayoutSnapshot | null {
|
|
113
|
+
if (!this.canvasService || !this.configService) return null;
|
|
114
|
+
if (!forceRefresh && this.lastLayout) return this.lastLayout;
|
|
115
|
+
|
|
116
|
+
const state = readSizeState(this.configService);
|
|
117
|
+
const layout = computeSceneLayout(this.canvasService, state);
|
|
118
|
+
if (!layout) {
|
|
119
|
+
this.lastLayout = null;
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.lastLayout = layout;
|
|
124
|
+
return layout;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getGeometry(forceRefresh = false): SceneGeometrySnapshot | null {
|
|
128
|
+
if (!this.configService) return null;
|
|
129
|
+
const layout = this.getLayout(forceRefresh);
|
|
130
|
+
if (!layout) {
|
|
131
|
+
this.lastGeometry = null;
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (!forceRefresh && this.lastGeometry) return this.lastGeometry;
|
|
135
|
+
|
|
136
|
+
const geometry = buildSceneGeometry(this.configService, layout);
|
|
137
|
+
this.lastGeometry = geometry;
|
|
138
|
+
return geometry;
|
|
139
|
+
}
|
|
140
|
+
}
|