@pooder/kit 5.3.1 → 6.0.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/.test-dist/src/extensions/background.js +475 -131
- package/.test-dist/src/extensions/dieline.js +283 -180
- package/.test-dist/src/extensions/dielineShape.js +66 -0
- package/.test-dist/src/extensions/feature.js +388 -303
- package/.test-dist/src/extensions/film.js +133 -74
- package/.test-dist/src/extensions/geometry.js +120 -56
- package/.test-dist/src/extensions/image.js +296 -212
- package/.test-dist/src/extensions/index.js +1 -3
- package/.test-dist/src/extensions/maskOps.js +75 -20
- package/.test-dist/src/extensions/ruler.js +312 -215
- package/.test-dist/src/extensions/sceneLayoutModel.js +9 -3
- package/.test-dist/src/extensions/sceneVisibility.js +3 -10
- package/.test-dist/src/extensions/tracer.js +229 -58
- package/.test-dist/src/extensions/white-ink.js +139 -129
- package/.test-dist/src/services/CanvasService.js +888 -126
- package/.test-dist/src/services/index.js +1 -0
- package/.test-dist/src/services/visibility.js +54 -0
- package/.test-dist/tests/run.js +58 -4
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +377 -82
- package/dist/index.d.ts +377 -82
- package/dist/index.js +3920 -2178
- package/dist/index.mjs +3992 -2247
- package/package.json +1 -1
- package/src/extensions/background.ts +631 -145
- package/src/extensions/dieline.ts +280 -187
- package/src/extensions/dielineShape.ts +109 -0
- package/src/extensions/feature.ts +485 -366
- package/src/extensions/film.ts +152 -76
- package/src/extensions/geometry.ts +203 -104
- package/src/extensions/image.ts +319 -238
- package/src/extensions/index.ts +0 -1
- package/src/extensions/ruler.ts +481 -268
- package/src/extensions/sceneLayoutModel.ts +18 -6
- package/src/extensions/white-ink.ts +157 -171
- package/src/services/CanvasService.ts +1126 -140
- package/src/services/index.ts +1 -0
- package/src/services/renderSpec.ts +69 -4
- package/src/services/visibility.ts +78 -0
- package/tests/run.ts +139 -4
- 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/dieline.js +0 -818
- package/.test-dist/src/edgeScale.js +0 -12
- 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/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/size.js +0 -332
- package/.test-dist/src/tracer.js +0 -544
- package/.test-dist/src/white-ink.js +0 -829
- package/.test-dist/src/wrappedOffsets.js +0 -33
- package/src/extensions/sceneVisibility.ts +0 -71
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrappedDistance = wrappedDistance;
|
|
4
|
-
exports.sampleWrappedOffsets = sampleWrappedOffsets;
|
|
5
|
-
function wrappedDistance(total, start, end) {
|
|
6
|
-
if (!Number.isFinite(total) || total <= 0)
|
|
7
|
-
return 0;
|
|
8
|
-
if (!Number.isFinite(start) || !Number.isFinite(end))
|
|
9
|
-
return 0;
|
|
10
|
-
const s = ((start % total) + total) % total;
|
|
11
|
-
const e = ((end % total) + total) % total;
|
|
12
|
-
return e >= s ? e - s : total - s + e;
|
|
13
|
-
}
|
|
14
|
-
function sampleWrappedOffsets(total, start, end, count) {
|
|
15
|
-
if (!Number.isFinite(total) || total <= 0)
|
|
16
|
-
return [];
|
|
17
|
-
if (!Number.isFinite(start) || !Number.isFinite(end))
|
|
18
|
-
return [];
|
|
19
|
-
const n = Math.max(0, Math.floor(count));
|
|
20
|
-
if (n <= 0)
|
|
21
|
-
return [];
|
|
22
|
-
const dist = wrappedDistance(total, start, end);
|
|
23
|
-
if (n === 1)
|
|
24
|
-
return [((start % total) + total) % total];
|
|
25
|
-
const step = dist / (n - 1);
|
|
26
|
-
const offsets = [];
|
|
27
|
-
for (let i = 0; i < n; i++) {
|
|
28
|
-
const raw = start + step * i;
|
|
29
|
-
const wrapped = ((raw % total) + total) % total;
|
|
30
|
-
offsets.push(wrapped);
|
|
31
|
-
}
|
|
32
|
-
return offsets;
|
|
33
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
if (dielineLayer.visible !== visible) {
|
|
57
|
-
dielineLayer.set({ visible });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const rulerLayer = this.canvasService.getLayer("ruler-overlay");
|
|
62
|
-
if (rulerLayer) {
|
|
63
|
-
const visible = !HIDDEN_RULER_TOOLS.has(this.activeToolId || "");
|
|
64
|
-
if (rulerLayer.visible !== visible) {
|
|
65
|
-
rulerLayer.set({ visible });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
this.canvasService.requestRenderAll();
|
|
70
|
-
}
|
|
71
|
-
}
|