@edv4h/usketch-plugin-shape-island 1.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/LICENSE +21 -0
- package/dist/auto-group.d.ts +20 -0
- package/dist/auto-group.d.ts.map +1 -0
- package/dist/auto-group.js +276 -0
- package/dist/auto-group.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/island-metaball-layer.d.ts +5 -0
- package/dist/island-metaball-layer.d.ts.map +1 -0
- package/dist/island-metaball-layer.js +112 -0
- package/dist/island-metaball-layer.js.map +1 -0
- package/dist/island-render.d.ts +11 -0
- package/dist/island-render.d.ts.map +1 -0
- package/dist/island-render.js +83 -0
- package/dist/island-render.js.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +191 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EdV4H
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BoardStore } from "@edv4h/usketch-shared";
|
|
2
|
+
/**
|
|
3
|
+
* 全島の接触状態を分析し、接触している島同士を group シェイプでまとめる。
|
|
4
|
+
* 離れた島はグループから外す。
|
|
5
|
+
*/
|
|
6
|
+
export declare function reconcileIslandGroups(store: BoardStore, commands: {
|
|
7
|
+
execute: (cmd: {
|
|
8
|
+
execute: () => void;
|
|
9
|
+
undo: () => void;
|
|
10
|
+
}) => void;
|
|
11
|
+
}): void;
|
|
12
|
+
/** Detach a single island from its island-group */
|
|
13
|
+
export declare function detachIsland(store: BoardStore, commands: {
|
|
14
|
+
execute: (cmd: {
|
|
15
|
+
execute: () => void;
|
|
16
|
+
undo: () => void;
|
|
17
|
+
}) => void;
|
|
18
|
+
}, islandId: string): void;
|
|
19
|
+
export declare function cleanupIslandGroupTimers(): void;
|
|
20
|
+
//# sourceMappingURL=auto-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-group.d.ts","sourceRoot":"","sources":["../src/auto-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA0B,MAAM,uBAAuB,CAAC;AA6EhF;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE;IAAE,OAAO,EAAE,CAAC,GAAG,EAAE;QAAE,OAAO,EAAE,MAAM,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAA;CAAE,GAC7E,IAAI,CA2LN;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAC3B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE;IAAE,OAAO,EAAE,CAAC,GAAG,EAAE;QAAE,OAAO,EAAE,MAAM,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAA;CAAE,EAC/E,QAAQ,EAAE,MAAM,GACd,IAAI,CAsCN;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAK/C"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { generateId } from "@edv4h/usketch-shared";
|
|
2
|
+
import { computeGroupBounds, createGroupCommand, createUngroupCommand, getChildShapes, intersectsAABB, } from "@edv4h/usketch-store";
|
|
3
|
+
const TOUCH_PADDING = 4;
|
|
4
|
+
const MERGE_ANIMATION_MS = 700;
|
|
5
|
+
function expandBounds(b, pad) {
|
|
6
|
+
return {
|
|
7
|
+
x: b.x - pad,
|
|
8
|
+
y: b.y - pad,
|
|
9
|
+
width: b.width + pad * 2,
|
|
10
|
+
height: b.height + pad * 2,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
// Union-Find for connected component analysis
|
|
14
|
+
class UnionFind {
|
|
15
|
+
parent = new Map();
|
|
16
|
+
find(x) {
|
|
17
|
+
if (!this.parent.has(x)) {
|
|
18
|
+
this.parent.set(x, x);
|
|
19
|
+
}
|
|
20
|
+
let root = x;
|
|
21
|
+
while (this.parent.get(root) !== root) {
|
|
22
|
+
root = this.parent.get(root);
|
|
23
|
+
}
|
|
24
|
+
let curr = x;
|
|
25
|
+
while (curr !== root) {
|
|
26
|
+
const next = this.parent.get(curr);
|
|
27
|
+
this.parent.set(curr, root);
|
|
28
|
+
curr = next;
|
|
29
|
+
}
|
|
30
|
+
return root;
|
|
31
|
+
}
|
|
32
|
+
union(a, b) {
|
|
33
|
+
const ra = this.find(a);
|
|
34
|
+
const rb = this.find(b);
|
|
35
|
+
if (ra !== rb) {
|
|
36
|
+
if (ra < rb) {
|
|
37
|
+
this.parent.set(rb, ra);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.parent.set(ra, rb);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Track merge animation timers
|
|
46
|
+
const mergeTimers = new Map();
|
|
47
|
+
function triggerMergeAnimation(store, islandId) {
|
|
48
|
+
store.updateShape(islandId, { _islandJustMerged: true });
|
|
49
|
+
const existing = mergeTimers.get(islandId);
|
|
50
|
+
if (existing)
|
|
51
|
+
clearTimeout(existing);
|
|
52
|
+
mergeTimers.set(islandId, setTimeout(() => {
|
|
53
|
+
mergeTimers.delete(islandId);
|
|
54
|
+
const shape = store.getShapes().get(islandId);
|
|
55
|
+
if (shape?._islandJustMerged) {
|
|
56
|
+
store.updateShape(islandId, { _islandJustMerged: undefined });
|
|
57
|
+
}
|
|
58
|
+
}, MERGE_ANIMATION_MS));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 全島の接触状態を分析し、接触している島同士を group シェイプでまとめる。
|
|
62
|
+
* 離れた島はグループから外す。
|
|
63
|
+
*/
|
|
64
|
+
export function reconcileIslandGroups(store, commands) {
|
|
65
|
+
// 1. Collect all top-level island shapes (not already in an island-group)
|
|
66
|
+
// and islands that are in island-groups
|
|
67
|
+
const allIslands = [];
|
|
68
|
+
const islandGroupIds = new Set();
|
|
69
|
+
for (const [id, shape] of store.getShapes()) {
|
|
70
|
+
if (shape.type !== "island")
|
|
71
|
+
continue;
|
|
72
|
+
const parentId = shape.parentId;
|
|
73
|
+
// Track which groups are island-groups
|
|
74
|
+
if (parentId) {
|
|
75
|
+
const parent = store.getShapes().get(parentId);
|
|
76
|
+
if (parent?.type === "group" && parent._isIslandGroup) {
|
|
77
|
+
islandGroupIds.add(parentId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
allIslands.push({
|
|
81
|
+
id,
|
|
82
|
+
bounds: { x: shape.x, y: shape.y, width: shape.width, height: shape.height },
|
|
83
|
+
parentId,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (allIslands.length < 2) {
|
|
87
|
+
// If only 0-1 islands, dissolve any existing island-groups
|
|
88
|
+
for (const groupId of islandGroupIds) {
|
|
89
|
+
commands.execute(createUngroupCommand(store, groupId));
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// 2. Build adjacency via Union-Find
|
|
94
|
+
const uf = new UnionFind();
|
|
95
|
+
for (let i = 0; i < allIslands.length; i++) {
|
|
96
|
+
uf.find(allIslands[i].id);
|
|
97
|
+
for (let j = i + 1; j < allIslands.length; j++) {
|
|
98
|
+
const a = expandBounds(allIslands[i].bounds, TOUCH_PADDING);
|
|
99
|
+
const b = expandBounds(allIslands[j].bounds, TOUCH_PADDING);
|
|
100
|
+
if (intersectsAABB(a, b)) {
|
|
101
|
+
uf.union(allIslands[i].id, allIslands[j].id);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 3. Build desired clusters
|
|
106
|
+
const desiredClusters = new Map();
|
|
107
|
+
for (const island of allIslands) {
|
|
108
|
+
const root = uf.find(island.id);
|
|
109
|
+
if (!desiredClusters.has(root)) {
|
|
110
|
+
desiredClusters.set(root, []);
|
|
111
|
+
}
|
|
112
|
+
desiredClusters.get(root)?.push(island.id);
|
|
113
|
+
}
|
|
114
|
+
// 4. Build current clusters (based on existing island-groups)
|
|
115
|
+
const currentClusters = new Map(); // groupId → island IDs
|
|
116
|
+
for (const island of allIslands) {
|
|
117
|
+
if (island.parentId && islandGroupIds.has(island.parentId)) {
|
|
118
|
+
if (!currentClusters.has(island.parentId)) {
|
|
119
|
+
currentClusters.set(island.parentId, new Set());
|
|
120
|
+
}
|
|
121
|
+
currentClusters.get(island.parentId)?.add(island.id);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// 5. Find which island belongs to which current group
|
|
125
|
+
const islandToCurrentGroup = new Map();
|
|
126
|
+
for (const [groupId, members] of currentClusters) {
|
|
127
|
+
for (const memberId of members) {
|
|
128
|
+
islandToCurrentGroup.set(memberId, groupId);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// 6. Reconcile: compare desired vs current
|
|
132
|
+
const processedGroups = new Set();
|
|
133
|
+
for (const [, members] of desiredClusters) {
|
|
134
|
+
if (members.length < 2) {
|
|
135
|
+
// Single island — should not be in an island-group
|
|
136
|
+
const island = members[0];
|
|
137
|
+
const currentGroupId = islandToCurrentGroup.get(island);
|
|
138
|
+
if (currentGroupId && !processedGroups.has(currentGroupId)) {
|
|
139
|
+
processedGroups.add(currentGroupId);
|
|
140
|
+
commands.execute(createUngroupCommand(store, currentGroupId));
|
|
141
|
+
}
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
// Multi-island cluster — check if already correctly grouped
|
|
145
|
+
const memberSet = new Set(members);
|
|
146
|
+
let existingGroupId;
|
|
147
|
+
let needsRegroup = false;
|
|
148
|
+
// Check if all members share the same island-group
|
|
149
|
+
for (const id of members) {
|
|
150
|
+
const gid = islandToCurrentGroup.get(id);
|
|
151
|
+
if (!gid) {
|
|
152
|
+
needsRegroup = true;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
if (!existingGroupId) {
|
|
156
|
+
existingGroupId = gid;
|
|
157
|
+
}
|
|
158
|
+
else if (gid !== existingGroupId) {
|
|
159
|
+
needsRegroup = true;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Check if the existing group has extra members
|
|
164
|
+
if (existingGroupId && !needsRegroup) {
|
|
165
|
+
const currentMembers = currentClusters.get(existingGroupId);
|
|
166
|
+
if (currentMembers && currentMembers.size !== memberSet.size) {
|
|
167
|
+
needsRegroup = true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (!needsRegroup && existingGroupId) {
|
|
171
|
+
processedGroups.add(existingGroupId);
|
|
172
|
+
continue; // Already correctly grouped
|
|
173
|
+
}
|
|
174
|
+
// Dissolve any existing groups that overlap with this cluster
|
|
175
|
+
const groupsToDissolve = new Set();
|
|
176
|
+
for (const id of members) {
|
|
177
|
+
const gid = islandToCurrentGroup.get(id);
|
|
178
|
+
if (gid && !processedGroups.has(gid)) {
|
|
179
|
+
groupsToDissolve.add(gid);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const gid of groupsToDissolve) {
|
|
183
|
+
processedGroups.add(gid);
|
|
184
|
+
commands.execute(createUngroupCommand(store, gid));
|
|
185
|
+
}
|
|
186
|
+
// Create new group
|
|
187
|
+
const children = [];
|
|
188
|
+
for (const id of members) {
|
|
189
|
+
const shape = store.getShape(id);
|
|
190
|
+
if (shape)
|
|
191
|
+
children.push(shape);
|
|
192
|
+
}
|
|
193
|
+
if (children.length < 2)
|
|
194
|
+
continue;
|
|
195
|
+
const bounds = computeGroupBounds(children);
|
|
196
|
+
const groupId = generateId();
|
|
197
|
+
const groupShape = {
|
|
198
|
+
id: groupId,
|
|
199
|
+
type: "group",
|
|
200
|
+
x: bounds.x,
|
|
201
|
+
y: bounds.y,
|
|
202
|
+
width: bounds.width,
|
|
203
|
+
height: bounds.height,
|
|
204
|
+
style: { fill: "transparent", stroke: "transparent", strokeWidth: 0, opacity: 1 },
|
|
205
|
+
_isIslandGroup: true, // Mark as island-specific group
|
|
206
|
+
};
|
|
207
|
+
commands.execute(createGroupCommand(store, groupShape, members));
|
|
208
|
+
// Trigger merge animation on newly grouped islands
|
|
209
|
+
for (const id of members) {
|
|
210
|
+
triggerMergeAnimation(store, id);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Dissolve any remaining island-groups not processed
|
|
214
|
+
for (const groupId of islandGroupIds) {
|
|
215
|
+
if (!processedGroups.has(groupId)) {
|
|
216
|
+
// Check if this group still has the right members
|
|
217
|
+
const currentMembers = currentClusters.get(groupId);
|
|
218
|
+
if (!currentMembers)
|
|
219
|
+
continue;
|
|
220
|
+
let allInSameCluster = true;
|
|
221
|
+
let clusterRoot;
|
|
222
|
+
for (const memberId of currentMembers) {
|
|
223
|
+
const root = uf.find(memberId);
|
|
224
|
+
if (!clusterRoot) {
|
|
225
|
+
clusterRoot = root;
|
|
226
|
+
}
|
|
227
|
+
else if (root !== clusterRoot) {
|
|
228
|
+
allInSameCluster = false;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (!allInSameCluster) {
|
|
233
|
+
commands.execute(createUngroupCommand(store, groupId));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** Detach a single island from its island-group */
|
|
239
|
+
export function detachIsland(store, commands, islandId) {
|
|
240
|
+
const shape = store.getShape(islandId);
|
|
241
|
+
if (!shape || shape.type !== "island")
|
|
242
|
+
return;
|
|
243
|
+
const parentId = shape.parentId;
|
|
244
|
+
if (!parentId)
|
|
245
|
+
return;
|
|
246
|
+
const parent = store.getShapes().get(parentId);
|
|
247
|
+
if (!parent || parent.type !== "group" || !parent._isIslandGroup)
|
|
248
|
+
return;
|
|
249
|
+
// Get remaining children
|
|
250
|
+
const siblings = getChildShapes(store, parentId).filter((s) => s.id !== islandId);
|
|
251
|
+
// Ungroup the entire group
|
|
252
|
+
commands.execute(createUngroupCommand(store, parentId));
|
|
253
|
+
// If 2+ siblings remain, re-group them
|
|
254
|
+
if (siblings.length >= 2) {
|
|
255
|
+
const bounds = computeGroupBounds(siblings);
|
|
256
|
+
const newGroupId = generateId();
|
|
257
|
+
const newGroupShape = {
|
|
258
|
+
id: newGroupId,
|
|
259
|
+
type: "group",
|
|
260
|
+
x: bounds.x,
|
|
261
|
+
y: bounds.y,
|
|
262
|
+
width: bounds.width,
|
|
263
|
+
height: bounds.height,
|
|
264
|
+
style: { fill: "transparent", stroke: "transparent", strokeWidth: 0, opacity: 1 },
|
|
265
|
+
_isIslandGroup: true,
|
|
266
|
+
};
|
|
267
|
+
commands.execute(createGroupCommand(store, newGroupShape, siblings.map((s) => s.id)));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export function cleanupIslandGroupTimers() {
|
|
271
|
+
for (const timer of mergeTimers.values()) {
|
|
272
|
+
clearTimeout(timer);
|
|
273
|
+
}
|
|
274
|
+
mergeTimers.clear();
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=auto-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-group.js","sourceRoot":"","sources":["../src/auto-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,GACd,MAAM,sBAAsB,CAAC;AAE9B,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,SAAS,YAAY,CAAC,CAAc,EAAE,GAAW;IAChD,OAAO;QACN,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;QACZ,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;QACZ,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC;QACxB,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC;KAC1B,CAAC;AACH,CAAC;AAED,8CAA8C;AAC9C,MAAM,SAAS;IACN,MAAM,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEhD,IAAI,CAAC,CAAS;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,OAAO,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EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;YACjF,cAAc,EAAE,IAAI;SACpB,CAAC;QACF,QAAQ,CAAC,OAAO,CACf,kBAAkB,CACjB,KAAK,EACL,aAAa,EACb,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACzB,CACD,CAAC;IACH,CAAC;AACF,CAAC;AAED,MAAM,UAAU,wBAAwB;IACvC,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QAC1C,YAAY,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,WAAW,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"island-metaball-layer.d.ts","sourceRoot":"","sources":["../src/island-metaball-layer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAsCxD,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,kDAsJnE"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
function collectBlobs(store) {
|
|
4
|
+
const blobs = [];
|
|
5
|
+
for (const [, shape] of store.getShapes()) {
|
|
6
|
+
if (shape.type !== "island")
|
|
7
|
+
continue;
|
|
8
|
+
let groupId;
|
|
9
|
+
const parentId = shape.parentId;
|
|
10
|
+
if (parentId) {
|
|
11
|
+
const parent = store.getShapes().get(parentId);
|
|
12
|
+
if (parent?.type === "group" && parent._isIslandGroup) {
|
|
13
|
+
groupId = parentId;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
blobs.push({
|
|
17
|
+
id: shape.id,
|
|
18
|
+
x: shape.x,
|
|
19
|
+
y: shape.y,
|
|
20
|
+
width: shape.width,
|
|
21
|
+
height: shape.height,
|
|
22
|
+
color: shape.islandColor ?? "#a8d5ba",
|
|
23
|
+
groupId,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return blobs;
|
|
27
|
+
}
|
|
28
|
+
export function IslandMetaballLayer({ store }) {
|
|
29
|
+
const [blobs, setBlobs] = useState([]);
|
|
30
|
+
const [viewport, setViewport] = useState(store.getViewport());
|
|
31
|
+
const rafRef = useRef(0);
|
|
32
|
+
const update = useCallback(() => {
|
|
33
|
+
cancelAnimationFrame(rafRef.current);
|
|
34
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
35
|
+
setBlobs(collectBlobs(store));
|
|
36
|
+
setViewport(store.getViewport());
|
|
37
|
+
});
|
|
38
|
+
}, [store]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
update();
|
|
41
|
+
const unsub = store.subscribe(update);
|
|
42
|
+
return () => {
|
|
43
|
+
unsub();
|
|
44
|
+
cancelAnimationFrame(rafRef.current);
|
|
45
|
+
};
|
|
46
|
+
}, [store, update]);
|
|
47
|
+
if (blobs.length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
// Group blobs by island-group
|
|
50
|
+
const groups = new Map();
|
|
51
|
+
const singles = [];
|
|
52
|
+
for (const blob of blobs) {
|
|
53
|
+
if (blob.groupId) {
|
|
54
|
+
if (!groups.has(blob.groupId)) {
|
|
55
|
+
groups.set(blob.groupId, []);
|
|
56
|
+
}
|
|
57
|
+
groups.get(blob.groupId)?.push(blob);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
singles.push(blob);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const R = 24;
|
|
64
|
+
return (_jsxs("div", { style: {
|
|
65
|
+
position: "absolute",
|
|
66
|
+
top: 0,
|
|
67
|
+
left: 0,
|
|
68
|
+
width: "100%",
|
|
69
|
+
height: "100%",
|
|
70
|
+
pointerEvents: "none",
|
|
71
|
+
overflow: "hidden",
|
|
72
|
+
}, children: [[...groups.entries()].map(([groupId, groupBlobs]) => {
|
|
73
|
+
let minX = Infinity;
|
|
74
|
+
let minY = Infinity;
|
|
75
|
+
let maxX = -Infinity;
|
|
76
|
+
let maxY = -Infinity;
|
|
77
|
+
for (const b of groupBlobs) {
|
|
78
|
+
minX = Math.min(minX, b.x);
|
|
79
|
+
minY = Math.min(minY, b.y);
|
|
80
|
+
maxX = Math.max(maxX, b.x + b.width);
|
|
81
|
+
maxY = Math.max(maxY, b.y + b.height);
|
|
82
|
+
}
|
|
83
|
+
const pad = 40;
|
|
84
|
+
const gx = minX - pad;
|
|
85
|
+
const gy = minY - pad;
|
|
86
|
+
const gw = maxX - minX + pad * 2;
|
|
87
|
+
const gh = maxY - minY + pad * 2;
|
|
88
|
+
const color = groupBlobs[0].color;
|
|
89
|
+
const filterId = `island-merge-${groupId}`;
|
|
90
|
+
return (_jsx("div", { style: {
|
|
91
|
+
position: "absolute",
|
|
92
|
+
left: gx * viewport.zoom + viewport.x,
|
|
93
|
+
top: gy * viewport.zoom + viewport.y,
|
|
94
|
+
width: gw * viewport.zoom,
|
|
95
|
+
height: gh * viewport.zoom,
|
|
96
|
+
pointerEvents: "none",
|
|
97
|
+
}, children: _jsxs("svg", { width: gw * viewport.zoom, height: gh * viewport.zoom, viewBox: `0 0 ${gw} ${gh}`, style: { display: "block", overflow: "visible" }, children: [_jsx("defs", { children: _jsxs("filter", { id: filterId, x: "-20%", y: "-20%", width: "140%", height: "140%", children: [_jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "5", result: "blur" }), _jsx("feColorMatrix", { in: "blur", type: "matrix", values: "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7", result: "metaball" }), _jsx("feComposite", { in: "SourceGraphic", in2: "metaball", operator: "atop" })] }) }), _jsx("g", { filter: `url(#${filterId})`, style: {
|
|
98
|
+
filter: `drop-shadow(0 4px 8px rgba(0,0,0,0.12)) drop-shadow(0 0 12px ${color}66)`,
|
|
99
|
+
}, children: groupBlobs.map((blob) => (_jsx("rect", { x: blob.x - gx, y: blob.y - gy, width: blob.width, height: blob.height, rx: R, ry: R, fill: color, fillOpacity: 0.8, stroke: color, strokeWidth: 2 }, blob.id))) })] }) }, groupId));
|
|
100
|
+
}), singles.map((blob) => (_jsx("div", { style: {
|
|
101
|
+
position: "absolute",
|
|
102
|
+
left: blob.x * viewport.zoom + viewport.x,
|
|
103
|
+
top: blob.y * viewport.zoom + viewport.y,
|
|
104
|
+
width: blob.width * viewport.zoom,
|
|
105
|
+
height: blob.height * viewport.zoom,
|
|
106
|
+
borderRadius: R * viewport.zoom,
|
|
107
|
+
background: `linear-gradient(145deg, ${blob.color}cc, ${blob.color}88)`,
|
|
108
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.1)",
|
|
109
|
+
pointerEvents: "none",
|
|
110
|
+
} }, blob.id)))] }));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=island-metaball-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"island-metaball-layer.js","sourceRoot":"","sources":["../src/island-metaball-layer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAYjE,SAAS,YAAY,CAAC,KAAiB;IACtC,MAAM,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E,IAAI,CAAC,CAAC,GAAG,EAAE,EACd,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EACd,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,EACL,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,GAAG,EAChB,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,CAAC,IAVT,IAAI,CAAC,EAAE,CAWX,CACF,CAAC,GACC,IACC,IAlDD,OAAO,CAmDP,CACN,CAAC;YACH,CAAC,CAAC,EAGD,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACtB,cAEC,KAAK,EAAE;oBACN,QAAQ,EAAE,UAAU;oBACpB,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC;oBACzC,GAAG,EAAE,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC;oBACxC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI;oBACjC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI;oBACnC,YAAY,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI;oBAC/B,UAAU,EAAE,2BAA2B,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,KAAK;oBACvE,SAAS,EAAE,4BAA4B;oBACvC,aAAa,EAAE,MAAM;iBACrB,IAXI,IAAI,CAAC,EAAE,CAYX,CACF,CAAC,IACG,CACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BoundingBox, Point, ShapeData } from "@edv4h/usketch-shared";
|
|
2
|
+
export declare function renderIsland(data: ShapeData): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function getBoundsIsland(data: ShapeData): BoundingBox;
|
|
4
|
+
export declare function hitTestIsland(data: ShapeData, point: Point): boolean;
|
|
5
|
+
export declare function resizeIsland(data: ShapeData, handle: string, delta: Point): ShapeData;
|
|
6
|
+
export declare function createDefaultIsland(params: {
|
|
7
|
+
id: string;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}): ShapeData;
|
|
11
|
+
//# sourceMappingURL=island-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"island-render.d.ts","sourceRoot":"","sources":["../src/island-render.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AA0B3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,2CAsB3C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAE5D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAOpE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,CAqBrF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAY3F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const MIN_W = 100;
|
|
3
|
+
const MIN_H = 100;
|
|
4
|
+
// ── CSS injection for animations ──
|
|
5
|
+
let styleInjected = false;
|
|
6
|
+
function injectStyle() {
|
|
7
|
+
if (styleInjected)
|
|
8
|
+
return;
|
|
9
|
+
styleInjected = true;
|
|
10
|
+
const style = document.createElement("style");
|
|
11
|
+
style.textContent = `
|
|
12
|
+
@keyframes usketch-island-merge-pulse {
|
|
13
|
+
0% { box-shadow: 0 0 0 0 rgba(100, 200, 150, 0.6), 0 4px 16px rgba(0,0,0,0.1); }
|
|
14
|
+
50% { box-shadow: 0 0 24px 12px rgba(100, 200, 150, 0.3), 0 4px 16px rgba(0,0,0,0.1); }
|
|
15
|
+
100% { box-shadow: 0 0 16px 4px rgba(100, 200, 150, 0.15), 0 4px 16px rgba(0,0,0,0.1); }
|
|
16
|
+
}
|
|
17
|
+
@keyframes usketch-island-merge-ring {
|
|
18
|
+
0% { transform: scale(0.8); opacity: 0.8; }
|
|
19
|
+
100% { transform: scale(2); opacity: 0; }
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
document.head.appendChild(style);
|
|
23
|
+
}
|
|
24
|
+
export function renderIsland(data) {
|
|
25
|
+
injectStyle();
|
|
26
|
+
const justMerged = data._islandJustMerged;
|
|
27
|
+
// Island body is transparent — background is rendered by the metaball layer.
|
|
28
|
+
// This div serves as the container for child shapes and hit-test target.
|
|
29
|
+
return (_jsx("div", { style: {
|
|
30
|
+
width: "100%",
|
|
31
|
+
height: "100%",
|
|
32
|
+
borderRadius: 24,
|
|
33
|
+
background: "transparent",
|
|
34
|
+
boxSizing: "border-box",
|
|
35
|
+
position: "relative",
|
|
36
|
+
pointerEvents: "none",
|
|
37
|
+
overflow: "visible",
|
|
38
|
+
animation: justMerged ? "usketch-island-merge-pulse 600ms ease-out" : undefined,
|
|
39
|
+
} }));
|
|
40
|
+
}
|
|
41
|
+
export function getBoundsIsland(data) {
|
|
42
|
+
return { x: data.x, y: data.y, width: data.width, height: data.height };
|
|
43
|
+
}
|
|
44
|
+
export function hitTestIsland(data, point) {
|
|
45
|
+
return (point.x >= data.x &&
|
|
46
|
+
point.x <= data.x + data.width &&
|
|
47
|
+
point.y >= data.y &&
|
|
48
|
+
point.y <= data.y + data.height);
|
|
49
|
+
}
|
|
50
|
+
export function resizeIsland(data, handle, delta) {
|
|
51
|
+
const result = { ...data };
|
|
52
|
+
if (handle.includes("e")) {
|
|
53
|
+
result.width = Math.max(MIN_W, data.width + delta.x);
|
|
54
|
+
}
|
|
55
|
+
if (handle.includes("w")) {
|
|
56
|
+
const newWidth = Math.max(MIN_W, data.width - delta.x);
|
|
57
|
+
result.x = data.x + data.width - newWidth;
|
|
58
|
+
result.width = newWidth;
|
|
59
|
+
}
|
|
60
|
+
if (handle.includes("s")) {
|
|
61
|
+
result.height = Math.max(MIN_H, data.height + delta.y);
|
|
62
|
+
}
|
|
63
|
+
if (handle.includes("n")) {
|
|
64
|
+
const newHeight = Math.max(MIN_H, data.height - delta.y);
|
|
65
|
+
result.y = data.y + data.height - newHeight;
|
|
66
|
+
result.height = newHeight;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
export function createDefaultIsland(params) {
|
|
71
|
+
return {
|
|
72
|
+
id: params.id,
|
|
73
|
+
type: "island",
|
|
74
|
+
x: params.x,
|
|
75
|
+
y: params.y,
|
|
76
|
+
width: 400,
|
|
77
|
+
height: 300,
|
|
78
|
+
style: { fill: "#a8d5ba", stroke: "#8bc4a0", strokeWidth: 2, opacity: 1 },
|
|
79
|
+
islandTitle: "Island",
|
|
80
|
+
islandColor: "#a8d5ba",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=island-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"island-render.js","sourceRoot":"","sources":["../src/island-render.tsx"],"names":[],"mappings":";AAEA,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,KAAK,GAAG,GAAG,CAAC;AAElB,qCAAqC;AAErC,IAAI,aAAa,GAAG,KAAK,CAAC;AAC1B,SAAS,WAAW;IACnB,IAAI,aAAa;QAAE,OAAO;IAC1B,aAAa,GAAG,IAAI,CAAC;IACrB,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,W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EAAE,MAAM,CAAC,CAAC;QACX,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;QACzE,WAAW,EAAE,QAAQ;QACrB,WAAW,EAAE,SAAS;KACtB,CAAC;AACH,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKX,aAAa,EACb,MAAM,uBAAuB,CAAC;AAwB/B,eAAO,MAAM,YAAY,EAAE,aA+L1B,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { generateId } from "@edv4h/usketch-shared";
|
|
3
|
+
import { containsAABB, createAddShapeCommand, createReparentCommand } from "@edv4h/usketch-store";
|
|
4
|
+
import { cleanupIslandGroupTimers, detachIsland, reconcileIslandGroups } from "./auto-group.js";
|
|
5
|
+
import { IslandMetaballLayer } from "./island-metaball-layer.js";
|
|
6
|
+
import { createDefaultIsland, getBoundsIsland, hitTestIsland, renderIsland, resizeIsland, } from "./island-render.js";
|
|
7
|
+
function IslandIcon() {
|
|
8
|
+
return (_jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [_jsx("ellipse", { cx: "10", cy: "14", rx: "8", ry: "4", fill: "#a8d5ba", stroke: "#8bc4a0", strokeWidth: "1.5" }), _jsx("circle", { cx: "8", cy: "10", r: "2", fill: "#6b9" }), _jsx("circle", { cx: "12", cy: "8", r: "3", fill: "#5a8" }), _jsx("line", { x1: "12", y1: "5", x2: "12", y2: "8", stroke: "#764", strokeWidth: "1.5" })] }));
|
|
9
|
+
}
|
|
10
|
+
export const islandPlugin = {
|
|
11
|
+
id: "usketch-plugin-shape-island",
|
|
12
|
+
name: "Island",
|
|
13
|
+
setup(ctx) {
|
|
14
|
+
// ── Shape registration ──
|
|
15
|
+
ctx.shapes.register("island", {
|
|
16
|
+
render: renderIsland,
|
|
17
|
+
getBounds: getBoundsIsland,
|
|
18
|
+
hitTest: hitTestIsland,
|
|
19
|
+
resize: resizeIsland,
|
|
20
|
+
createDefault: createDefaultIsland,
|
|
21
|
+
renderTarget: "html",
|
|
22
|
+
minSize: { width: 100, height: 100 },
|
|
23
|
+
});
|
|
24
|
+
// ── Metaball background layer (renders below shapes) ──
|
|
25
|
+
ctx.layers.register({
|
|
26
|
+
id: "island-metaball",
|
|
27
|
+
order: -1,
|
|
28
|
+
fixed: true,
|
|
29
|
+
render: () => _jsx(IslandMetaballLayer, { store: ctx.store }),
|
|
30
|
+
});
|
|
31
|
+
// ── Drawing tool ──
|
|
32
|
+
let drawState = null;
|
|
33
|
+
function onPointerDown(toolCtx, event) {
|
|
34
|
+
const id = generateId();
|
|
35
|
+
drawState = { startX: event.worldPoint.x, startY: event.worldPoint.y, shapeId: id };
|
|
36
|
+
const shape = createDefaultIsland({ id, x: event.worldPoint.x, y: event.worldPoint.y });
|
|
37
|
+
shape.width = 0;
|
|
38
|
+
shape.height = 0;
|
|
39
|
+
toolCtx.store.addShape(shape);
|
|
40
|
+
}
|
|
41
|
+
function onPointerMove(toolCtx, event) {
|
|
42
|
+
if (!drawState)
|
|
43
|
+
return;
|
|
44
|
+
const x = Math.min(drawState.startX, event.worldPoint.x);
|
|
45
|
+
const y = Math.min(drawState.startY, event.worldPoint.y);
|
|
46
|
+
const width = Math.abs(event.worldPoint.x - drawState.startX);
|
|
47
|
+
const height = Math.abs(event.worldPoint.y - drawState.startY);
|
|
48
|
+
toolCtx.store.updateShape(drawState.shapeId, { x, y, width, height });
|
|
49
|
+
}
|
|
50
|
+
function onPointerUp(toolCtx) {
|
|
51
|
+
if (!drawState)
|
|
52
|
+
return;
|
|
53
|
+
const shape = toolCtx.store.getShape(drawState.shapeId);
|
|
54
|
+
if (shape && shape.width > 10 && shape.height > 10) {
|
|
55
|
+
toolCtx.store.deleteShape(drawState.shapeId);
|
|
56
|
+
toolCtx.commands.execute(createAddShapeCommand(toolCtx.store, shape));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
toolCtx.store.deleteShape(drawState.shapeId);
|
|
60
|
+
}
|
|
61
|
+
drawState = null;
|
|
62
|
+
toolCtx.store.setActiveToolId("select");
|
|
63
|
+
}
|
|
64
|
+
ctx.tools.register("island-draw", {
|
|
65
|
+
icon: IslandIcon,
|
|
66
|
+
cursor: "crosshair",
|
|
67
|
+
shortcut: "i",
|
|
68
|
+
order: 6,
|
|
69
|
+
onPointerDown,
|
|
70
|
+
onPointerMove,
|
|
71
|
+
onPointerUp,
|
|
72
|
+
onDeactivate() {
|
|
73
|
+
if (drawState) {
|
|
74
|
+
ctx.store.deleteShape(drawState.shapeId);
|
|
75
|
+
drawState = null;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
// ── Auto-parenting (same pattern as frame plugin) ──
|
|
80
|
+
const CONTAINER_TYPES = new Set(["frame", "island"]);
|
|
81
|
+
function autoReparent(shapeId) {
|
|
82
|
+
const shape = ctx.store.getShape(shapeId);
|
|
83
|
+
if (!shape || CONTAINER_TYPES.has(shape.type) || shape.type === "connector")
|
|
84
|
+
return;
|
|
85
|
+
const shapeBounds = { x: shape.x, y: shape.y, width: shape.width, height: shape.height };
|
|
86
|
+
let bestContainer = null;
|
|
87
|
+
for (const [id, candidate] of ctx.store.getShapes()) {
|
|
88
|
+
if (id === shapeId || !CONTAINER_TYPES.has(candidate.type))
|
|
89
|
+
continue;
|
|
90
|
+
const containerBounds = {
|
|
91
|
+
x: candidate.x,
|
|
92
|
+
y: candidate.y,
|
|
93
|
+
width: candidate.width,
|
|
94
|
+
height: candidate.height,
|
|
95
|
+
};
|
|
96
|
+
if (containsAABB(containerBounds, shapeBounds)) {
|
|
97
|
+
if (!bestContainer ||
|
|
98
|
+
candidate.width * candidate.height < bestContainer.width * bestContainer.height) {
|
|
99
|
+
bestContainer = candidate;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const currentParentId = shape.parentId;
|
|
104
|
+
const newParentId = bestContainer?.id;
|
|
105
|
+
if (currentParentId !== newParentId) {
|
|
106
|
+
ctx.commands.execute(createReparentCommand(ctx.store, [shapeId], newParentId ?? undefined));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// ── Auto-grouping: islands that touch form a group ──
|
|
110
|
+
const unsubMoveEnd = ctx.events.on("shapes:move-end", (data) => {
|
|
111
|
+
if (!data?.shapeIds)
|
|
112
|
+
return;
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
for (const shapeId of data.shapeIds) {
|
|
115
|
+
const shape = ctx.store.getShape(shapeId);
|
|
116
|
+
if (shape?.type === "island") {
|
|
117
|
+
// Island moved — adopt shapes now inside it
|
|
118
|
+
adoptContainedShapes(shapeId);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Non-island moved — reparent into nearest container
|
|
122
|
+
autoReparent(shapeId);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const prevSelection = [...ctx.store.getSelection()];
|
|
126
|
+
reconcileIslandGroups(ctx.store, ctx.commands);
|
|
127
|
+
if (prevSelection.length > 0) {
|
|
128
|
+
ctx.store.setSelection(prevSelection.filter((id) => ctx.store.getShape(id)));
|
|
129
|
+
}
|
|
130
|
+
}, 0);
|
|
131
|
+
});
|
|
132
|
+
// Adopt all non-container shapes fully inside an island
|
|
133
|
+
function adoptContainedShapes(islandId) {
|
|
134
|
+
const island = ctx.store.getShape(islandId);
|
|
135
|
+
if (!island || island.type !== "island")
|
|
136
|
+
return;
|
|
137
|
+
const islandBounds = {
|
|
138
|
+
x: island.x,
|
|
139
|
+
y: island.y,
|
|
140
|
+
width: island.width,
|
|
141
|
+
height: island.height,
|
|
142
|
+
};
|
|
143
|
+
for (const [childId, child] of ctx.store.getShapes()) {
|
|
144
|
+
if (childId === islandId || CONTAINER_TYPES.has(child.type) || child.type === "connector")
|
|
145
|
+
continue;
|
|
146
|
+
if (child.parentId === islandId)
|
|
147
|
+
continue;
|
|
148
|
+
const childBounds = { x: child.x, y: child.y, width: child.width, height: child.height };
|
|
149
|
+
if (containsAABB(islandBounds, childBounds)) {
|
|
150
|
+
ctx.commands.execute(createReparentCommand(ctx.store, [childId], islandId));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const unsubAdded = ctx.store.onMutation((event) => {
|
|
155
|
+
if (event.type !== "shape:added")
|
|
156
|
+
return;
|
|
157
|
+
const payload = event.payload;
|
|
158
|
+
if (!payload?.id)
|
|
159
|
+
return;
|
|
160
|
+
const shape = ctx.store.getShape(payload.id);
|
|
161
|
+
if (!shape)
|
|
162
|
+
return;
|
|
163
|
+
if (shape.type === "island") {
|
|
164
|
+
// Island was just created — adopt shapes already inside it
|
|
165
|
+
adoptContainedShapes(payload.id);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (CONTAINER_TYPES.has(shape.type) || shape.type === "connector")
|
|
169
|
+
return;
|
|
170
|
+
autoReparent(payload.id);
|
|
171
|
+
});
|
|
172
|
+
// ── Detach: Shift+D to detach selected island from its group ──
|
|
173
|
+
const unsubDetach = ctx.shortcuts.register("Shift+D", () => {
|
|
174
|
+
const selection = ctx.store.getSelection();
|
|
175
|
+
for (const id of selection) {
|
|
176
|
+
const shape = ctx.store.getShape(id);
|
|
177
|
+
if (shape?.type === "island") {
|
|
178
|
+
detachIsland(ctx.store, ctx.commands, id);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
this.teardown = () => {
|
|
183
|
+
unsubMoveEnd();
|
|
184
|
+
unsubAdded();
|
|
185
|
+
unsubDetach();
|
|
186
|
+
cleanupIslandGroupTimers();
|
|
187
|
+
ctx.layers.unregister("island-metaball");
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,GACZ,MAAM,oBAAoB,CAAC;AAE5B,SAAS,UAAU;IAClB,OAAO,CACN,eAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,aAC1D,kBAAS,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAC,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,WAAW,EAAC,KAAK,GAAG,EAC3F,iBAAQ,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAC,IAAI,EAAC,MAAM,GAAG,EAC3C,iBAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,IAAI,EAAC,MAAM,GAAG,EAC3C,eAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,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,CAAC,CAAC;QAEH,iEAAiE;QAEjE,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;YAC1D,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YAC3C,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACrC,IAAI,KAAK,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC9B,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAC3C,CAAC;YACF,CAAC;QACF,CAAC,CAAC,CAAC;QAEF,IAAsB,CAAC,QAAQ,GAAG,GAAG,EAAE;YACvC,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,CAAC;YACd,wBAAwB,EAAE,CAAC;YAC3B,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;QAC1C,CAAC,CAAC;IACH,CAAC;CACD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@edv4h/usketch-plugin-shape-island",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@edv4h/usketch-shared": "1.0.0",
|
|
16
|
+
"@edv4h/usketch-store": "1.0.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": ">=19"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/react": "19.2.14",
|
|
23
|
+
"typescript": "5.9.3",
|
|
24
|
+
"vitest": "3.2.4"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/EdV4H/usketch.git",
|
|
37
|
+
"directory": "plugins/usketch-plugin-shape-island"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/EdV4H/usketch#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/EdV4H/usketch/issues"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.json",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"test": "vitest run --passWithNoTests",
|
|
47
|
+
"clean": "rm -rf dist"
|
|
48
|
+
}
|
|
49
|
+
}
|