@woven-canvas/core 1.0.15 → 1.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/build/_tsup-dts-rollup.d.cts +8 -0
- package/build/_tsup-dts-rollup.d.ts +8 -0
- package/build/index.cjs +37 -1
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +36 -1
- package/build/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -171,6 +171,7 @@ declare const BlockDef: z.ZodObject<{
|
|
|
171
171
|
canScale: z.ZodDefault<z.ZodBoolean>;
|
|
172
172
|
snappable: z.ZodDefault<z.ZodBoolean>;
|
|
173
173
|
interactable: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
showOperations: z.ZodDefault<z.ZodBoolean>;
|
|
174
175
|
excludeFromRankBounds: z.ZodDefault<z.ZodBoolean>;
|
|
175
176
|
connectors: z.ZodDefault<z.ZodObject<{
|
|
176
177
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -738,6 +739,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
738
739
|
canScale?: boolean | undefined;
|
|
739
740
|
snappable?: boolean | undefined;
|
|
740
741
|
interactable?: boolean | undefined;
|
|
742
|
+
showOperations?: boolean | undefined;
|
|
741
743
|
excludeFromRankBounds?: boolean | undefined;
|
|
742
744
|
connectors?: {
|
|
743
745
|
enabled?: boolean | undefined;
|
|
@@ -756,6 +758,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
756
758
|
canScale?: boolean | undefined;
|
|
757
759
|
snappable?: boolean | undefined;
|
|
758
760
|
interactable?: boolean | undefined;
|
|
761
|
+
showOperations?: boolean | undefined;
|
|
759
762
|
excludeFromRankBounds?: boolean | undefined;
|
|
760
763
|
connectors?: {
|
|
761
764
|
enabled?: boolean | undefined;
|
|
@@ -934,6 +937,11 @@ export { EventType }
|
|
|
934
937
|
|
|
935
938
|
export { field }
|
|
936
939
|
|
|
940
|
+
declare function filterRoots(ctx: Context, entityIds: EntityId[]): EntityId[];
|
|
941
|
+
export { filterRoots }
|
|
942
|
+
export { filterRoots as filterRoots_alias_1 }
|
|
943
|
+
export { filterRoots as filterRoots_alias_2 }
|
|
944
|
+
|
|
937
945
|
declare function findFrameAtPoint(ctx: Context, point: [number, number], exclude?: EntityId | null): EntityId | null;
|
|
938
946
|
export { findFrameAtPoint }
|
|
939
947
|
export { findFrameAtPoint as findFrameAtPoint_alias_1 }
|
|
@@ -171,6 +171,7 @@ declare const BlockDef: z.ZodObject<{
|
|
|
171
171
|
canScale: z.ZodDefault<z.ZodBoolean>;
|
|
172
172
|
snappable: z.ZodDefault<z.ZodBoolean>;
|
|
173
173
|
interactable: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
showOperations: z.ZodDefault<z.ZodBoolean>;
|
|
174
175
|
excludeFromRankBounds: z.ZodDefault<z.ZodBoolean>;
|
|
175
176
|
connectors: z.ZodDefault<z.ZodObject<{
|
|
176
177
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -738,6 +739,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
738
739
|
canScale?: boolean | undefined;
|
|
739
740
|
snappable?: boolean | undefined;
|
|
740
741
|
interactable?: boolean | undefined;
|
|
742
|
+
showOperations?: boolean | undefined;
|
|
741
743
|
excludeFromRankBounds?: boolean | undefined;
|
|
742
744
|
connectors?: {
|
|
743
745
|
enabled?: boolean | undefined;
|
|
@@ -756,6 +758,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
756
758
|
canScale?: boolean | undefined;
|
|
757
759
|
snappable?: boolean | undefined;
|
|
758
760
|
interactable?: boolean | undefined;
|
|
761
|
+
showOperations?: boolean | undefined;
|
|
759
762
|
excludeFromRankBounds?: boolean | undefined;
|
|
760
763
|
connectors?: {
|
|
761
764
|
enabled?: boolean | undefined;
|
|
@@ -934,6 +937,11 @@ export { EventType }
|
|
|
934
937
|
|
|
935
938
|
export { field }
|
|
936
939
|
|
|
940
|
+
declare function filterRoots(ctx: Context, entityIds: EntityId[]): EntityId[];
|
|
941
|
+
export { filterRoots }
|
|
942
|
+
export { filterRoots as filterRoots_alias_1 }
|
|
943
|
+
export { filterRoots as filterRoots_alias_2 }
|
|
944
|
+
|
|
937
945
|
declare function findFrameAtPoint(ctx: Context, point: [number, number], exclude?: EntityId | null): EntityId | null;
|
|
938
946
|
export { findFrameAtPoint }
|
|
939
947
|
export { findFrameAtPoint as findFrameAtPoint_alias_1 }
|
package/build/index.cjs
CHANGED
|
@@ -156,6 +156,7 @@ __export(index_exports, {
|
|
|
156
156
|
deselectBlock: () => deselectBlock,
|
|
157
157
|
detectEmbedProvider: () => detectEmbedProvider,
|
|
158
158
|
field: () => import_core74.field,
|
|
159
|
+
filterRoots: () => filterRoots,
|
|
159
160
|
findFrameAtPoint: () => findFrameAtPoint,
|
|
160
161
|
generateUuidBySeed: () => generateUuidBySeed,
|
|
161
162
|
getBackrefs: () => import_core74.getBackrefs,
|
|
@@ -641,6 +642,7 @@ var BlockDef = import_zod.z.object({
|
|
|
641
642
|
canScale: import_zod.z.boolean().default(true),
|
|
642
643
|
snappable: import_zod.z.boolean().default(true),
|
|
643
644
|
interactable: import_zod.z.boolean().default(true),
|
|
645
|
+
showOperations: import_zod.z.boolean().default(true),
|
|
644
646
|
excludeFromRankBounds: import_zod.z.boolean().default(false),
|
|
645
647
|
connectors: BlockDefConnectors.default(BlockDefConnectors.parse({}))
|
|
646
648
|
});
|
|
@@ -3323,6 +3325,21 @@ function getDescendants(ctx, parentId) {
|
|
|
3323
3325
|
}
|
|
3324
3326
|
return result;
|
|
3325
3327
|
}
|
|
3328
|
+
function filterRoots(ctx, entityIds) {
|
|
3329
|
+
const idSet = new Set(entityIds);
|
|
3330
|
+
return entityIds.filter((entityId) => {
|
|
3331
|
+
if (!(0, import_core41.hasComponent)(ctx, entityId, Block)) return false;
|
|
3332
|
+
let current = Block.read(ctx, entityId).parentId;
|
|
3333
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3334
|
+
while (current !== null && (0, import_core41.hasComponent)(ctx, current, Block)) {
|
|
3335
|
+
if (idSet.has(current)) return false;
|
|
3336
|
+
if (visited.has(current)) break;
|
|
3337
|
+
visited.add(current);
|
|
3338
|
+
current = Block.read(ctx, current).parentId;
|
|
3339
|
+
}
|
|
3340
|
+
return true;
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3326
3343
|
function cascadeDelete(ctx, entityId) {
|
|
3327
3344
|
const children = (0, import_core41.getBackrefs)(ctx, entityId, Block, "parentId");
|
|
3328
3345
|
for (const childId of children) {
|
|
@@ -5925,6 +5942,7 @@ var blockSystem = defineEditorSystem({ phase: "update" }, (ctx) => {
|
|
|
5925
5942
|
}
|
|
5926
5943
|
}
|
|
5927
5944
|
});
|
|
5945
|
+
on(ctx, DuplicateSelected, duplicateSelected);
|
|
5928
5946
|
on(ctx, BringForwardSelected, bringForwardSelected);
|
|
5929
5947
|
on(ctx, SendBackwardSelected, sendBackwardSelected);
|
|
5930
5948
|
on(ctx, SetCursor, (ctx2, payload) => {
|
|
@@ -5950,6 +5968,23 @@ function deselectAllBlocks(ctx) {
|
|
|
5950
5968
|
deselectBlock(ctx, entityId);
|
|
5951
5969
|
}
|
|
5952
5970
|
}
|
|
5971
|
+
var DUPLICATE_OFFSET = 20;
|
|
5972
|
+
function duplicateSelected(ctx) {
|
|
5973
|
+
const selectedBlocks = [...selectedBlocksQuery4.current(ctx)];
|
|
5974
|
+
if (selectedBlocks.length === 0) return;
|
|
5975
|
+
cloneEntities(ctx, selectedBlocks, [0, 0], crypto.randomUUID());
|
|
5976
|
+
const grid = Grid.read(ctx);
|
|
5977
|
+
const offset = grid.enabled && grid.colWidth > 0 && grid.rowHeight > 0 ? [grid.colWidth, grid.rowHeight] : [DUPLICATE_OFFSET, DUPLICATE_OFFSET];
|
|
5978
|
+
for (const entityId of filterRoots(ctx, selectedBlocks)) {
|
|
5979
|
+
const worldPos = Block.getWorldPosition(ctx, entityId);
|
|
5980
|
+
import_math12.Vec2.add(worldPos, offset);
|
|
5981
|
+
Block.setWorldPosition(ctx, entityId, worldPos);
|
|
5982
|
+
}
|
|
5983
|
+
const { transformBoxId } = TransformBoxStateSingleton.read(ctx);
|
|
5984
|
+
if (transformBoxId !== null) {
|
|
5985
|
+
UpdateTransformBox.spawn(ctx, { transformBoxId });
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5953
5988
|
function bringForwardSelected(ctx) {
|
|
5954
5989
|
const selectedBlocks = [...selectedBlocksQuery4.current(ctx)];
|
|
5955
5990
|
if (selectedBlocks.length === 0) return;
|
|
@@ -5987,7 +6022,6 @@ function sendBackwardSelected(ctx) {
|
|
|
5987
6022
|
}
|
|
5988
6023
|
}
|
|
5989
6024
|
function cloneEntities(ctx, entityIds, offset, seed) {
|
|
5990
|
-
const rootSet = new Set(entityIds);
|
|
5991
6025
|
const allEntityIdsSet = new Set(entityIds);
|
|
5992
6026
|
for (const entityId of entityIds) {
|
|
5993
6027
|
for (const descendant of getDescendants(ctx, entityId)) {
|
|
@@ -5995,6 +6029,7 @@ function cloneEntities(ctx, entityIds, offset, seed) {
|
|
|
5995
6029
|
}
|
|
5996
6030
|
}
|
|
5997
6031
|
entityIds = [...allEntityIdsSet];
|
|
6032
|
+
const rootSet = new Set(filterRoots(ctx, entityIds));
|
|
5998
6033
|
const { componentsById } = (0, import_core67.getResources)(ctx);
|
|
5999
6034
|
const documentComponents = new Map([...componentsById].filter(([, def]) => def.sync === "document"));
|
|
6000
6035
|
const syncedComponentId = import_canvas_store46.Synced._getComponentId(ctx);
|
|
@@ -7406,6 +7441,7 @@ var Editor = class {
|
|
|
7406
7441
|
deselectBlock,
|
|
7407
7442
|
detectEmbedProvider,
|
|
7408
7443
|
field,
|
|
7444
|
+
filterRoots,
|
|
7409
7445
|
findFrameAtPoint,
|
|
7410
7446
|
generateUuidBySeed,
|
|
7411
7447
|
getBackrefs,
|