@woven-canvas/core 0.1.4 → 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/build/_tsup-dts-rollup.d.cts +12 -2
- package/build/_tsup-dts-rollup.d.ts +12 -2
- package/build/index.cjs +30 -6
- 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 +35 -12
- package/build/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -132,6 +132,7 @@ declare const BlockDef: z.ZodObject<{
|
|
|
132
132
|
}>>;
|
|
133
133
|
canRotate: z.ZodDefault<z.ZodBoolean>;
|
|
134
134
|
canScale: z.ZodDefault<z.ZodBoolean>;
|
|
135
|
+
selectable: z.ZodDefault<z.ZodBoolean>;
|
|
135
136
|
connectors: z.ZodDefault<z.ZodObject<{
|
|
136
137
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
137
138
|
terminals: z.ZodDefault<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
@@ -215,6 +216,11 @@ declare function canBlockScale(ctx: Context, tag: string): boolean;
|
|
|
215
216
|
export { canBlockScale }
|
|
216
217
|
export { canBlockScale as canBlockScale_alias_1 }
|
|
217
218
|
|
|
219
|
+
declare function canBlockSelect(ctx: Context, tag: string): boolean;
|
|
220
|
+
export { canBlockSelect }
|
|
221
|
+
export { canBlockSelect as canBlockSelect_alias_1 }
|
|
222
|
+
export { canBlockSelect as canBlockSelect_alias_2 }
|
|
223
|
+
|
|
218
224
|
declare const canSeeBlocksSystem: EditorSystem;
|
|
219
225
|
export { canSeeBlocksSystem }
|
|
220
226
|
export { canSeeBlocksSystem as canSeeBlocksSystem_alias_1 }
|
|
@@ -336,6 +342,8 @@ declare const ControlsSchema: {
|
|
|
336
342
|
heldSnapshot: StringFieldBuilder;
|
|
337
343
|
};
|
|
338
344
|
|
|
345
|
+
export declare const CORE_PLUGIN_NAME = "core";
|
|
346
|
+
|
|
339
347
|
declare const CorePlugin: EditorPlugin;
|
|
340
348
|
export { CorePlugin }
|
|
341
349
|
export { CorePlugin as CorePlugin_alias_1 }
|
|
@@ -501,6 +509,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
501
509
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
502
510
|
canRotate?: boolean | undefined;
|
|
503
511
|
canScale?: boolean | undefined;
|
|
512
|
+
selectable?: boolean | undefined;
|
|
504
513
|
connectors?: {
|
|
505
514
|
enabled?: boolean | undefined;
|
|
506
515
|
terminals?: [number, number][] | undefined;
|
|
@@ -516,6 +525,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
516
525
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
517
526
|
canRotate?: boolean | undefined;
|
|
518
527
|
canScale?: boolean | undefined;
|
|
528
|
+
selectable?: boolean | undefined;
|
|
519
529
|
connectors?: {
|
|
520
530
|
enabled?: boolean | undefined;
|
|
521
531
|
terminals?: [number, number][] | undefined;
|
|
@@ -1113,6 +1123,7 @@ declare class MouseDef extends CanvasSingletonDef<typeof MouseSchema> {
|
|
|
1113
1123
|
didLeave(ctx: Context): boolean;
|
|
1114
1124
|
getPosition(ctx: Context): Vec2;
|
|
1115
1125
|
getWheelDelta(ctx: Context): Vec2;
|
|
1126
|
+
isObscured(ctx: Context): boolean;
|
|
1116
1127
|
}
|
|
1117
1128
|
|
|
1118
1129
|
declare interface MouseInput {
|
|
@@ -1140,6 +1151,7 @@ declare const MouseSchema: {
|
|
|
1140
1151
|
wheelTrigger: BooleanFieldBuilder;
|
|
1141
1152
|
enterTrigger: BooleanFieldBuilder;
|
|
1142
1153
|
leaveTrigger: BooleanFieldBuilder;
|
|
1154
|
+
obscured: BooleanFieldBuilder;
|
|
1143
1155
|
};
|
|
1144
1156
|
|
|
1145
1157
|
declare const mouseSystem: EditorSystem;
|
|
@@ -1161,8 +1173,6 @@ declare function parsePlugin(input: EditorPluginInput): EditorPlugin;
|
|
|
1161
1173
|
export { parsePlugin }
|
|
1162
1174
|
export { parsePlugin as parsePlugin_alias_1 }
|
|
1163
1175
|
|
|
1164
|
-
export declare const PLUGIN_NAME = "core";
|
|
1165
|
-
|
|
1166
1176
|
declare const Pointer: PointerDef;
|
|
1167
1177
|
export { Pointer }
|
|
1168
1178
|
export { Pointer as Pointer_alias_1 }
|
|
@@ -132,6 +132,7 @@ declare const BlockDef: z.ZodObject<{
|
|
|
132
132
|
}>>;
|
|
133
133
|
canRotate: z.ZodDefault<z.ZodBoolean>;
|
|
134
134
|
canScale: z.ZodDefault<z.ZodBoolean>;
|
|
135
|
+
selectable: z.ZodDefault<z.ZodBoolean>;
|
|
135
136
|
connectors: z.ZodDefault<z.ZodObject<{
|
|
136
137
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
137
138
|
terminals: z.ZodDefault<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
@@ -215,6 +216,11 @@ declare function canBlockScale(ctx: Context, tag: string): boolean;
|
|
|
215
216
|
export { canBlockScale }
|
|
216
217
|
export { canBlockScale as canBlockScale_alias_1 }
|
|
217
218
|
|
|
219
|
+
declare function canBlockSelect(ctx: Context, tag: string): boolean;
|
|
220
|
+
export { canBlockSelect }
|
|
221
|
+
export { canBlockSelect as canBlockSelect_alias_1 }
|
|
222
|
+
export { canBlockSelect as canBlockSelect_alias_2 }
|
|
223
|
+
|
|
218
224
|
declare const canSeeBlocksSystem: EditorSystem;
|
|
219
225
|
export { canSeeBlocksSystem }
|
|
220
226
|
export { canSeeBlocksSystem as canSeeBlocksSystem_alias_1 }
|
|
@@ -336,6 +342,8 @@ declare const ControlsSchema: {
|
|
|
336
342
|
heldSnapshot: StringFieldBuilder;
|
|
337
343
|
};
|
|
338
344
|
|
|
345
|
+
export declare const CORE_PLUGIN_NAME = "core";
|
|
346
|
+
|
|
339
347
|
declare const CorePlugin: EditorPlugin;
|
|
340
348
|
export { CorePlugin }
|
|
341
349
|
export { CorePlugin as CorePlugin_alias_1 }
|
|
@@ -501,6 +509,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
501
509
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
502
510
|
canRotate?: boolean | undefined;
|
|
503
511
|
canScale?: boolean | undefined;
|
|
512
|
+
selectable?: boolean | undefined;
|
|
504
513
|
connectors?: {
|
|
505
514
|
enabled?: boolean | undefined;
|
|
506
515
|
terminals?: [number, number][] | undefined;
|
|
@@ -516,6 +525,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
516
525
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
517
526
|
canRotate?: boolean | undefined;
|
|
518
527
|
canScale?: boolean | undefined;
|
|
528
|
+
selectable?: boolean | undefined;
|
|
519
529
|
connectors?: {
|
|
520
530
|
enabled?: boolean | undefined;
|
|
521
531
|
terminals?: [number, number][] | undefined;
|
|
@@ -1113,6 +1123,7 @@ declare class MouseDef extends CanvasSingletonDef<typeof MouseSchema> {
|
|
|
1113
1123
|
didLeave(ctx: Context): boolean;
|
|
1114
1124
|
getPosition(ctx: Context): Vec2;
|
|
1115
1125
|
getWheelDelta(ctx: Context): Vec2;
|
|
1126
|
+
isObscured(ctx: Context): boolean;
|
|
1116
1127
|
}
|
|
1117
1128
|
|
|
1118
1129
|
declare interface MouseInput {
|
|
@@ -1140,6 +1151,7 @@ declare const MouseSchema: {
|
|
|
1140
1151
|
wheelTrigger: BooleanFieldBuilder;
|
|
1141
1152
|
enterTrigger: BooleanFieldBuilder;
|
|
1142
1153
|
leaveTrigger: BooleanFieldBuilder;
|
|
1154
|
+
obscured: BooleanFieldBuilder;
|
|
1143
1155
|
};
|
|
1144
1156
|
|
|
1145
1157
|
declare const mouseSystem: EditorSystem;
|
|
@@ -1161,8 +1173,6 @@ declare function parsePlugin(input: EditorPluginInput): EditorPlugin;
|
|
|
1161
1173
|
export { parsePlugin }
|
|
1162
1174
|
export { parsePlugin as parsePlugin_alias_1 }
|
|
1163
1175
|
|
|
1164
|
-
export declare const PLUGIN_NAME = "core";
|
|
1165
|
-
|
|
1166
1176
|
declare const Pointer: PointerDef;
|
|
1167
1177
|
export { Pointer }
|
|
1168
1178
|
export { Pointer as Pointer_alias_1 }
|
package/build/index.cjs
CHANGED
|
@@ -84,6 +84,7 @@ __export(index_exports, {
|
|
|
84
84
|
VerticalAlignment: () => VerticalAlignment,
|
|
85
85
|
addComponent: () => import_core49.addComponent,
|
|
86
86
|
canBlockEdit: () => canBlockEdit,
|
|
87
|
+
canBlockSelect: () => canBlockSelect,
|
|
87
88
|
clearPointerTrackingState: () => clearPointerTrackingState,
|
|
88
89
|
createEntity: () => import_core49.createEntity,
|
|
89
90
|
defineCanvasComponent: () => import_canvas_store34.defineCanvasComponent,
|
|
@@ -412,6 +413,7 @@ var BlockDef = import_zod.z.object({
|
|
|
412
413
|
resizeMode: import_zod.z.enum([ResizeMode.Scale, ResizeMode.Text, ResizeMode.Free, ResizeMode.GroupOnly]).default(ResizeMode.Scale),
|
|
413
414
|
canRotate: import_zod.z.boolean().default(true),
|
|
414
415
|
canScale: import_zod.z.boolean().default(true),
|
|
416
|
+
selectable: import_zod.z.boolean().default(true),
|
|
415
417
|
connectors: BlockDefConnectors.default(BlockDefConnectors.parse({}))
|
|
416
418
|
});
|
|
417
419
|
|
|
@@ -1419,7 +1421,7 @@ var VerticalAlign = (0, import_canvas_store17.defineCanvasComponent)(
|
|
|
1419
1421
|
);
|
|
1420
1422
|
|
|
1421
1423
|
// src/constants.ts
|
|
1422
|
-
var
|
|
1424
|
+
var CORE_PLUGIN_NAME = "core";
|
|
1423
1425
|
var STRATUM_ORDER = {
|
|
1424
1426
|
background: 0,
|
|
1425
1427
|
content: 1,
|
|
@@ -1585,7 +1587,7 @@ var ControlsSchema = {
|
|
|
1585
1587
|
/** Tool activated by mouse wheel with modifier key held */
|
|
1586
1588
|
modWheelTool: import_core18.field.string().max(32).default("zoom"),
|
|
1587
1589
|
/** JSON snapshot of block to place on next click (empty string = no placement active) */
|
|
1588
|
-
heldSnapshot: import_core18.field.string().max(
|
|
1590
|
+
heldSnapshot: import_core18.field.string().max(65536).default("")
|
|
1589
1591
|
};
|
|
1590
1592
|
var ControlsDef = class extends import_canvas_store20.CanvasSingletonDef {
|
|
1591
1593
|
constructor() {
|
|
@@ -2157,7 +2159,9 @@ var MouseSchema = {
|
|
|
2157
2159
|
/** True for 1 frame when mouse enters the editor element */
|
|
2158
2160
|
enterTrigger: import_core24.field.boolean().default(false),
|
|
2159
2161
|
/** True for 1 frame when mouse leaves the editor element */
|
|
2160
|
-
leaveTrigger: import_core24.field.boolean().default(false)
|
|
2162
|
+
leaveTrigger: import_core24.field.boolean().default(false),
|
|
2163
|
+
/** Whether the mouse is over a UI element (not the canvas) */
|
|
2164
|
+
obscured: import_core24.field.boolean().default(false)
|
|
2161
2165
|
};
|
|
2162
2166
|
var MouseDef = class extends import_canvas_store26.CanvasSingletonDef {
|
|
2163
2167
|
constructor() {
|
|
@@ -2189,6 +2193,10 @@ var MouseDef = class extends import_canvas_store26.CanvasSingletonDef {
|
|
|
2189
2193
|
const m = this.read(ctx);
|
|
2190
2194
|
return [m.wheelDeltaX, m.wheelDeltaY];
|
|
2191
2195
|
}
|
|
2196
|
+
/** Check if mouse is over a UI element (not the canvas) */
|
|
2197
|
+
isObscured(ctx) {
|
|
2198
|
+
return this.read(ctx).obscured;
|
|
2199
|
+
}
|
|
2192
2200
|
};
|
|
2193
2201
|
var Mouse = new MouseDef();
|
|
2194
2202
|
|
|
@@ -2473,7 +2481,8 @@ function attachMouseListeners(domElement) {
|
|
|
2473
2481
|
state.eventsBuffer.push({
|
|
2474
2482
|
type: "mousemove",
|
|
2475
2483
|
clientX: e.clientX,
|
|
2476
|
-
clientY: e.clientY
|
|
2484
|
+
clientY: e.clientY,
|
|
2485
|
+
target: e.target
|
|
2477
2486
|
});
|
|
2478
2487
|
},
|
|
2479
2488
|
onWheel: (e) => {
|
|
@@ -2530,6 +2539,7 @@ var mouseSystem = defineEditorSystem({ phase: "input" }, (ctx) => {
|
|
|
2530
2539
|
case "mousemove":
|
|
2531
2540
|
mouse.position = [event.clientX - screen.left, event.clientY - screen.top];
|
|
2532
2541
|
mouse.moveTrigger = true;
|
|
2542
|
+
mouse.obscured = event.target !== resources.domElement;
|
|
2533
2543
|
break;
|
|
2534
2544
|
case "wheel":
|
|
2535
2545
|
mouse.wheelDeltaX = event.deltaX;
|
|
@@ -2794,6 +2804,9 @@ function getBlockDef(ctx, tag) {
|
|
|
2794
2804
|
function canBlockEdit(ctx, tag) {
|
|
2795
2805
|
return getBlockDef(ctx, tag).editOptions.canEdit;
|
|
2796
2806
|
}
|
|
2807
|
+
function canBlockSelect(ctx, tag) {
|
|
2808
|
+
return getBlockDef(ctx, tag).selectable;
|
|
2809
|
+
}
|
|
2797
2810
|
function getBlockResizeMode(ctx, entityId) {
|
|
2798
2811
|
const block = Block.read(ctx, entityId);
|
|
2799
2812
|
if (block.resizeMode !== ResizeMode.Default) {
|
|
@@ -3041,6 +3054,7 @@ function arraysEqual(a, b) {
|
|
|
3041
3054
|
}
|
|
3042
3055
|
var added = /* @__PURE__ */ new Set();
|
|
3043
3056
|
var changed = /* @__PURE__ */ new Set();
|
|
3057
|
+
var prevObscuredByElement = /* @__PURE__ */ new WeakMap();
|
|
3044
3058
|
var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (ctx) => {
|
|
3045
3059
|
added.clear();
|
|
3046
3060
|
for (const entityId of blocksChanged.added(ctx)) {
|
|
@@ -3082,6 +3096,15 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3082
3096
|
clearHovered(ctx);
|
|
3083
3097
|
return;
|
|
3084
3098
|
}
|
|
3099
|
+
const resources = (0, import_core42.getResources)(ctx);
|
|
3100
|
+
const isObscured = Mouse.isObscured(ctx);
|
|
3101
|
+
const wasObscured = prevObscuredByElement.get(resources.domElement) ?? false;
|
|
3102
|
+
const obscuredChanged = isObscured !== wasObscured;
|
|
3103
|
+
prevObscuredByElement.set(resources.domElement, isObscured);
|
|
3104
|
+
if (isObscured) {
|
|
3105
|
+
clearHovered(ctx);
|
|
3106
|
+
return;
|
|
3107
|
+
}
|
|
3085
3108
|
const mousePos = Mouse.getPosition(ctx);
|
|
3086
3109
|
const worldPos = Camera.toWorld(ctx, mousePos);
|
|
3087
3110
|
const intersected = intersectPoint(ctx, worldPos);
|
|
@@ -3094,7 +3117,7 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3094
3117
|
if (pointers.length > 0) {
|
|
3095
3118
|
return;
|
|
3096
3119
|
}
|
|
3097
|
-
if (intersectsChanged || heldChanged) {
|
|
3120
|
+
if (intersectsChanged || heldChanged || obscuredChanged) {
|
|
3098
3121
|
updateHovered(ctx, intersected);
|
|
3099
3122
|
}
|
|
3100
3123
|
});
|
|
@@ -3196,7 +3219,7 @@ function scaleBlock(ctx, entityId, zoom) {
|
|
|
3196
3219
|
|
|
3197
3220
|
// src/CorePlugin.ts
|
|
3198
3221
|
var CorePlugin = {
|
|
3199
|
-
name:
|
|
3222
|
+
name: CORE_PLUGIN_NAME,
|
|
3200
3223
|
singletons: Object.values(singletons_exports).filter((v) => v instanceof import_canvas_store31.CanvasSingletonDef),
|
|
3201
3224
|
components: Object.values(components_exports).filter((v) => v instanceof import_canvas_store31.CanvasComponentDef),
|
|
3202
3225
|
blockDefs: [
|
|
@@ -4104,6 +4127,7 @@ function clearPointerTrackingState(ctx) {
|
|
|
4104
4127
|
VerticalAlignment,
|
|
4105
4128
|
addComponent,
|
|
4106
4129
|
canBlockEdit,
|
|
4130
|
+
canBlockSelect,
|
|
4107
4131
|
clearPointerTrackingState,
|
|
4108
4132
|
createEntity,
|
|
4109
4133
|
defineCanvasComponent,
|