@pooder/kit 5.3.0 → 5.3.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/CanvasService.js +249 -249
- package/.test-dist/src/ViewportSystem.js +75 -75
- package/.test-dist/src/background.js +203 -203
- package/.test-dist/src/bridgeSelection.js +20 -20
- package/.test-dist/src/constraints.js +237 -237
- package/.test-dist/src/dieline.js +818 -818
- package/.test-dist/src/edgeScale.js +12 -12
- package/.test-dist/src/feature.js +826 -826
- package/.test-dist/src/featureComplete.js +32 -32
- package/.test-dist/src/film.js +167 -167
- package/.test-dist/src/geometry.js +506 -506
- package/.test-dist/src/image.js +1250 -1250
- package/.test-dist/src/maskOps.js +270 -270
- package/.test-dist/src/mirror.js +104 -104
- package/.test-dist/src/renderSpec.js +2 -2
- package/.test-dist/src/ruler.js +343 -343
- package/.test-dist/src/sceneLayout.js +99 -99
- package/.test-dist/src/sceneLayoutModel.js +196 -196
- package/.test-dist/src/sceneView.js +40 -40
- package/.test-dist/src/sceneVisibility.js +42 -42
- package/.test-dist/src/size.js +332 -332
- package/.test-dist/src/tracer.js +544 -544
- package/.test-dist/src/white-ink.js +829 -829
- package/.test-dist/src/wrappedOffsets.js +33 -33
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +108 -20
- package/dist/index.mjs +108 -20
- package/package.json +1 -1
- package/src/coordinate.ts +106 -106
- package/src/extensions/background.ts +230 -230
- package/src/extensions/bridgeSelection.ts +17 -17
- package/src/extensions/constraints.ts +322 -322
- package/src/extensions/dieline.ts +46 -0
- package/src/extensions/edgeScale.ts +19 -19
- package/src/extensions/feature.ts +1021 -1021
- package/src/extensions/featureComplete.ts +46 -46
- package/src/extensions/film.ts +194 -194
- package/src/extensions/geometry.ts +752 -719
- package/src/extensions/image.ts +1926 -1924
- 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 +451 -451
- package/src/extensions/sceneLayout.ts +140 -140
- package/src/extensions/sceneLayoutModel.ts +352 -342
- package/src/extensions/sceneVisibility.ts +71 -71
- package/src/extensions/size.ts +389 -389
- package/src/extensions/tracer.ts +58 -19
- package/src/extensions/white-ink.ts +1400 -1400
- package/src/extensions/wrappedOffsets.ts +33 -33
- package/src/index.ts +2 -2
- package/src/services/CanvasService.ts +300 -300
- package/src/services/ViewportSystem.ts +95 -95
- package/src/services/index.ts +3 -3
- package/src/services/renderSpec.ts +18 -18
- package/src/units.ts +27 -27
- package/tests/run.ts +118 -118
- package/tsconfig.test.json +15 -15
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFeaturesStrict = validateFeaturesStrict;
|
|
4
|
-
exports.completeFeaturesStrict = completeFeaturesStrict;
|
|
5
|
-
const constraints_1 = require("./constraints");
|
|
6
|
-
function validateFeaturesStrict(features, context) {
|
|
7
|
-
const eps = 1e-6;
|
|
8
|
-
const issues = [];
|
|
9
|
-
for (const f of features) {
|
|
10
|
-
if (!f.constraints || f.constraints.length === 0)
|
|
11
|
-
continue;
|
|
12
|
-
// Pass ALL constraints (including validateOnly) for strict validation check
|
|
13
|
-
const constrained = constraints_1.ConstraintRegistry.apply(f.x, f.y, f, context, f.constraints);
|
|
14
|
-
if (Math.abs(constrained.x - f.x) > eps ||
|
|
15
|
-
Math.abs(constrained.y - f.y) > eps) {
|
|
16
|
-
issues.push({
|
|
17
|
-
featureId: f.id,
|
|
18
|
-
groupId: f.groupId,
|
|
19
|
-
reason: "Position violates constraint strategy",
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return { ok: issues.length === 0, issues: issues.length ? issues : undefined };
|
|
24
|
-
}
|
|
25
|
-
function completeFeaturesStrict(features, context, update) {
|
|
26
|
-
const validation = validateFeaturesStrict(features, context);
|
|
27
|
-
if (!validation.ok)
|
|
28
|
-
return validation;
|
|
29
|
-
const next = JSON.parse(JSON.stringify(features || []));
|
|
30
|
-
update(next);
|
|
31
|
-
return { ok: true };
|
|
32
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFeaturesStrict = validateFeaturesStrict;
|
|
4
|
+
exports.completeFeaturesStrict = completeFeaturesStrict;
|
|
5
|
+
const constraints_1 = require("./constraints");
|
|
6
|
+
function validateFeaturesStrict(features, context) {
|
|
7
|
+
const eps = 1e-6;
|
|
8
|
+
const issues = [];
|
|
9
|
+
for (const f of features) {
|
|
10
|
+
if (!f.constraints || f.constraints.length === 0)
|
|
11
|
+
continue;
|
|
12
|
+
// Pass ALL constraints (including validateOnly) for strict validation check
|
|
13
|
+
const constrained = constraints_1.ConstraintRegistry.apply(f.x, f.y, f, context, f.constraints);
|
|
14
|
+
if (Math.abs(constrained.x - f.x) > eps ||
|
|
15
|
+
Math.abs(constrained.y - f.y) > eps) {
|
|
16
|
+
issues.push({
|
|
17
|
+
featureId: f.id,
|
|
18
|
+
groupId: f.groupId,
|
|
19
|
+
reason: "Position violates constraint strategy",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { ok: issues.length === 0, issues: issues.length ? issues : undefined };
|
|
24
|
+
}
|
|
25
|
+
function completeFeaturesStrict(features, context, update) {
|
|
26
|
+
const validation = validateFeaturesStrict(features, context);
|
|
27
|
+
if (!validation.ok)
|
|
28
|
+
return validation;
|
|
29
|
+
const next = JSON.parse(JSON.stringify(features || []));
|
|
30
|
+
update(next);
|
|
31
|
+
return { ok: true };
|
|
32
|
+
}
|
package/.test-dist/src/film.js
CHANGED
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilmTool = void 0;
|
|
4
|
-
const core_1 = require("@pooder/core");
|
|
5
|
-
const fabric_1 = require("fabric");
|
|
6
|
-
class FilmTool {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.id = "pooder.kit.film";
|
|
9
|
-
this.metadata = {
|
|
10
|
-
name: "FilmTool",
|
|
11
|
-
};
|
|
12
|
-
this.url = "";
|
|
13
|
-
this.opacity = 0.5;
|
|
14
|
-
if (options) {
|
|
15
|
-
Object.assign(this, options);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
activate(context) {
|
|
19
|
-
this.canvasService = context.services.get("CanvasService");
|
|
20
|
-
if (!this.canvasService) {
|
|
21
|
-
console.warn("CanvasService not found for FilmTool");
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const configService = context.services.get("ConfigurationService");
|
|
25
|
-
if (configService) {
|
|
26
|
-
// Load initial config
|
|
27
|
-
this.url = configService.get("film.url", this.url);
|
|
28
|
-
this.opacity = configService.get("film.opacity", this.opacity);
|
|
29
|
-
// Listen for changes
|
|
30
|
-
configService.onAnyChange((e) => {
|
|
31
|
-
if (e.key.startsWith("film.")) {
|
|
32
|
-
const prop = e.key.split(".")[1];
|
|
33
|
-
console.log(`[FilmTool] Config change detected: ${e.key} -> ${e.value}`);
|
|
34
|
-
if (prop && prop in this) {
|
|
35
|
-
this[prop] = e.value;
|
|
36
|
-
this.updateFilm();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
this.initLayer();
|
|
42
|
-
this.updateFilm();
|
|
43
|
-
}
|
|
44
|
-
deactivate(context) {
|
|
45
|
-
if (this.canvasService) {
|
|
46
|
-
const layer = this.canvasService.getLayer("overlay");
|
|
47
|
-
if (layer) {
|
|
48
|
-
const img = this.canvasService.getObject("film-image", "overlay");
|
|
49
|
-
if (img) {
|
|
50
|
-
layer.remove(img);
|
|
51
|
-
this.canvasService.requestRenderAll();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
this.canvasService = undefined;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
contribute() {
|
|
58
|
-
return {
|
|
59
|
-
[core_1.ContributionPointIds.CONFIGURATIONS]: [
|
|
60
|
-
{
|
|
61
|
-
id: "film.url",
|
|
62
|
-
type: "string",
|
|
63
|
-
label: "Film Image URL",
|
|
64
|
-
default: "",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: "film.opacity",
|
|
68
|
-
type: "number",
|
|
69
|
-
label: "Opacity",
|
|
70
|
-
min: 0,
|
|
71
|
-
max: 1,
|
|
72
|
-
step: 0.1,
|
|
73
|
-
default: 0.5,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
[core_1.ContributionPointIds.COMMANDS]: [
|
|
77
|
-
{
|
|
78
|
-
command: "setFilmImage",
|
|
79
|
-
title: "Set Film Image",
|
|
80
|
-
handler: (url, opacity) => {
|
|
81
|
-
if (this.url === url && this.opacity === opacity)
|
|
82
|
-
return true;
|
|
83
|
-
this.url = url;
|
|
84
|
-
this.opacity = opacity;
|
|
85
|
-
this.updateFilm();
|
|
86
|
-
return true;
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
initLayer() {
|
|
93
|
-
if (!this.canvasService)
|
|
94
|
-
return;
|
|
95
|
-
let overlayLayer = this.canvasService.getLayer("overlay");
|
|
96
|
-
if (!overlayLayer) {
|
|
97
|
-
const width = this.canvasService.canvas.width || 800;
|
|
98
|
-
const height = this.canvasService.canvas.height || 600;
|
|
99
|
-
const layer = this.canvasService.createLayer("overlay", {
|
|
100
|
-
width,
|
|
101
|
-
height,
|
|
102
|
-
left: 0,
|
|
103
|
-
top: 0,
|
|
104
|
-
originX: "left",
|
|
105
|
-
originY: "top",
|
|
106
|
-
selectable: false,
|
|
107
|
-
evented: false,
|
|
108
|
-
subTargetCheck: false,
|
|
109
|
-
interactive: false,
|
|
110
|
-
});
|
|
111
|
-
this.canvasService.canvas.bringObjectToFront(layer);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async updateFilm() {
|
|
115
|
-
if (!this.canvasService)
|
|
116
|
-
return;
|
|
117
|
-
const layer = this.canvasService.getLayer("overlay");
|
|
118
|
-
if (!layer) {
|
|
119
|
-
console.warn("[FilmTool] Overlay layer not found");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const { url, opacity } = this;
|
|
123
|
-
if (!url) {
|
|
124
|
-
const img = this.canvasService.getObject("film-image", "overlay");
|
|
125
|
-
if (img) {
|
|
126
|
-
layer.remove(img);
|
|
127
|
-
this.canvasService.requestRenderAll();
|
|
128
|
-
}
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const width = this.canvasService.canvas.width || 800;
|
|
132
|
-
const height = this.canvasService.canvas.height || 600;
|
|
133
|
-
let img = this.canvasService.getObject("film-image", "overlay");
|
|
134
|
-
try {
|
|
135
|
-
if (img) {
|
|
136
|
-
if (img.getSrc() !== url) {
|
|
137
|
-
await img.setSrc(url);
|
|
138
|
-
}
|
|
139
|
-
img.set({ opacity });
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
img = await fabric_1.FabricImage.fromURL(url, { crossOrigin: "anonymous" });
|
|
143
|
-
img.scaleToWidth(width);
|
|
144
|
-
if (img.getScaledHeight() < height)
|
|
145
|
-
img.scaleToHeight(height);
|
|
146
|
-
img.set({
|
|
147
|
-
originX: "left",
|
|
148
|
-
originY: "top",
|
|
149
|
-
left: 0,
|
|
150
|
-
top: 0,
|
|
151
|
-
opacity,
|
|
152
|
-
selectable: false,
|
|
153
|
-
evented: false,
|
|
154
|
-
data: { id: "film-image" },
|
|
155
|
-
});
|
|
156
|
-
layer.add(img);
|
|
157
|
-
}
|
|
158
|
-
this.canvasService.requestRenderAll();
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
console.error("[FilmTool] Failed to load film image", url, error);
|
|
162
|
-
}
|
|
163
|
-
layer.dirty = true;
|
|
164
|
-
this.canvasService.requestRenderAll();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.FilmTool = FilmTool;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilmTool = void 0;
|
|
4
|
+
const core_1 = require("@pooder/core");
|
|
5
|
+
const fabric_1 = require("fabric");
|
|
6
|
+
class FilmTool {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.id = "pooder.kit.film";
|
|
9
|
+
this.metadata = {
|
|
10
|
+
name: "FilmTool",
|
|
11
|
+
};
|
|
12
|
+
this.url = "";
|
|
13
|
+
this.opacity = 0.5;
|
|
14
|
+
if (options) {
|
|
15
|
+
Object.assign(this, options);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
activate(context) {
|
|
19
|
+
this.canvasService = context.services.get("CanvasService");
|
|
20
|
+
if (!this.canvasService) {
|
|
21
|
+
console.warn("CanvasService not found for FilmTool");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const configService = context.services.get("ConfigurationService");
|
|
25
|
+
if (configService) {
|
|
26
|
+
// Load initial config
|
|
27
|
+
this.url = configService.get("film.url", this.url);
|
|
28
|
+
this.opacity = configService.get("film.opacity", this.opacity);
|
|
29
|
+
// Listen for changes
|
|
30
|
+
configService.onAnyChange((e) => {
|
|
31
|
+
if (e.key.startsWith("film.")) {
|
|
32
|
+
const prop = e.key.split(".")[1];
|
|
33
|
+
console.log(`[FilmTool] Config change detected: ${e.key} -> ${e.value}`);
|
|
34
|
+
if (prop && prop in this) {
|
|
35
|
+
this[prop] = e.value;
|
|
36
|
+
this.updateFilm();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
this.initLayer();
|
|
42
|
+
this.updateFilm();
|
|
43
|
+
}
|
|
44
|
+
deactivate(context) {
|
|
45
|
+
if (this.canvasService) {
|
|
46
|
+
const layer = this.canvasService.getLayer("overlay");
|
|
47
|
+
if (layer) {
|
|
48
|
+
const img = this.canvasService.getObject("film-image", "overlay");
|
|
49
|
+
if (img) {
|
|
50
|
+
layer.remove(img);
|
|
51
|
+
this.canvasService.requestRenderAll();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this.canvasService = undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
contribute() {
|
|
58
|
+
return {
|
|
59
|
+
[core_1.ContributionPointIds.CONFIGURATIONS]: [
|
|
60
|
+
{
|
|
61
|
+
id: "film.url",
|
|
62
|
+
type: "string",
|
|
63
|
+
label: "Film Image URL",
|
|
64
|
+
default: "",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "film.opacity",
|
|
68
|
+
type: "number",
|
|
69
|
+
label: "Opacity",
|
|
70
|
+
min: 0,
|
|
71
|
+
max: 1,
|
|
72
|
+
step: 0.1,
|
|
73
|
+
default: 0.5,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
[core_1.ContributionPointIds.COMMANDS]: [
|
|
77
|
+
{
|
|
78
|
+
command: "setFilmImage",
|
|
79
|
+
title: "Set Film Image",
|
|
80
|
+
handler: (url, opacity) => {
|
|
81
|
+
if (this.url === url && this.opacity === opacity)
|
|
82
|
+
return true;
|
|
83
|
+
this.url = url;
|
|
84
|
+
this.opacity = opacity;
|
|
85
|
+
this.updateFilm();
|
|
86
|
+
return true;
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
initLayer() {
|
|
93
|
+
if (!this.canvasService)
|
|
94
|
+
return;
|
|
95
|
+
let overlayLayer = this.canvasService.getLayer("overlay");
|
|
96
|
+
if (!overlayLayer) {
|
|
97
|
+
const width = this.canvasService.canvas.width || 800;
|
|
98
|
+
const height = this.canvasService.canvas.height || 600;
|
|
99
|
+
const layer = this.canvasService.createLayer("overlay", {
|
|
100
|
+
width,
|
|
101
|
+
height,
|
|
102
|
+
left: 0,
|
|
103
|
+
top: 0,
|
|
104
|
+
originX: "left",
|
|
105
|
+
originY: "top",
|
|
106
|
+
selectable: false,
|
|
107
|
+
evented: false,
|
|
108
|
+
subTargetCheck: false,
|
|
109
|
+
interactive: false,
|
|
110
|
+
});
|
|
111
|
+
this.canvasService.canvas.bringObjectToFront(layer);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async updateFilm() {
|
|
115
|
+
if (!this.canvasService)
|
|
116
|
+
return;
|
|
117
|
+
const layer = this.canvasService.getLayer("overlay");
|
|
118
|
+
if (!layer) {
|
|
119
|
+
console.warn("[FilmTool] Overlay layer not found");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const { url, opacity } = this;
|
|
123
|
+
if (!url) {
|
|
124
|
+
const img = this.canvasService.getObject("film-image", "overlay");
|
|
125
|
+
if (img) {
|
|
126
|
+
layer.remove(img);
|
|
127
|
+
this.canvasService.requestRenderAll();
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const width = this.canvasService.canvas.width || 800;
|
|
132
|
+
const height = this.canvasService.canvas.height || 600;
|
|
133
|
+
let img = this.canvasService.getObject("film-image", "overlay");
|
|
134
|
+
try {
|
|
135
|
+
if (img) {
|
|
136
|
+
if (img.getSrc() !== url) {
|
|
137
|
+
await img.setSrc(url);
|
|
138
|
+
}
|
|
139
|
+
img.set({ opacity });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
img = await fabric_1.FabricImage.fromURL(url, { crossOrigin: "anonymous" });
|
|
143
|
+
img.scaleToWidth(width);
|
|
144
|
+
if (img.getScaledHeight() < height)
|
|
145
|
+
img.scaleToHeight(height);
|
|
146
|
+
img.set({
|
|
147
|
+
originX: "left",
|
|
148
|
+
originY: "top",
|
|
149
|
+
left: 0,
|
|
150
|
+
top: 0,
|
|
151
|
+
opacity,
|
|
152
|
+
selectable: false,
|
|
153
|
+
evented: false,
|
|
154
|
+
data: { id: "film-image" },
|
|
155
|
+
});
|
|
156
|
+
layer.add(img);
|
|
157
|
+
}
|
|
158
|
+
this.canvasService.requestRenderAll();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error("[FilmTool] Failed to load film image", url, error);
|
|
162
|
+
}
|
|
163
|
+
layer.dirty = true;
|
|
164
|
+
this.canvasService.requestRenderAll();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.FilmTool = FilmTool;
|