@woven-canvas/core 1.0.1 → 1.0.3
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 -8
- package/build/_tsup-dts-rollup.d.ts +8 -8
- package/build/index.cjs +28 -10
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +27 -9
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -132,7 +132,7 @@ declare const BlockDef: z.ZodObject<{
|
|
|
132
132
|
}>>;
|
|
133
133
|
canRotate: z.ZodDefault<z.ZodBoolean>;
|
|
134
134
|
canScale: z.ZodDefault<z.ZodBoolean>;
|
|
135
|
-
|
|
135
|
+
interactable: z.ZodDefault<z.ZodBoolean>;
|
|
136
136
|
connectors: z.ZodDefault<z.ZodObject<{
|
|
137
137
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
138
138
|
terminals: z.ZodDefault<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
@@ -208,6 +208,11 @@ export { canBlockEdit }
|
|
|
208
208
|
export { canBlockEdit as canBlockEdit_alias_1 }
|
|
209
209
|
export { canBlockEdit as canBlockEdit_alias_2 }
|
|
210
210
|
|
|
211
|
+
declare function canBlockInteract(ctx: Context, tag: string): boolean;
|
|
212
|
+
export { canBlockInteract }
|
|
213
|
+
export { canBlockInteract as canBlockInteract_alias_1 }
|
|
214
|
+
export { canBlockInteract as canBlockInteract_alias_2 }
|
|
215
|
+
|
|
211
216
|
declare function canBlockRotate(ctx: Context, tag: string): boolean;
|
|
212
217
|
export { canBlockRotate }
|
|
213
218
|
export { canBlockRotate as canBlockRotate_alias_1 }
|
|
@@ -216,11 +221,6 @@ declare function canBlockScale(ctx: Context, tag: string): boolean;
|
|
|
216
221
|
export { canBlockScale }
|
|
217
222
|
export { canBlockScale as canBlockScale_alias_1 }
|
|
218
223
|
|
|
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
|
-
|
|
224
224
|
declare const canSeeBlocksSystem: EditorSystem;
|
|
225
225
|
export { canSeeBlocksSystem }
|
|
226
226
|
export { canSeeBlocksSystem as canSeeBlocksSystem_alias_1 }
|
|
@@ -516,7 +516,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
516
516
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
517
517
|
canRotate?: boolean | undefined;
|
|
518
518
|
canScale?: boolean | undefined;
|
|
519
|
-
|
|
519
|
+
interactable?: boolean | undefined;
|
|
520
520
|
connectors?: {
|
|
521
521
|
enabled?: boolean | undefined;
|
|
522
522
|
terminals?: [number, number][] | undefined;
|
|
@@ -532,7 +532,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
532
532
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
533
533
|
canRotate?: boolean | undefined;
|
|
534
534
|
canScale?: boolean | undefined;
|
|
535
|
-
|
|
535
|
+
interactable?: boolean | undefined;
|
|
536
536
|
connectors?: {
|
|
537
537
|
enabled?: boolean | undefined;
|
|
538
538
|
terminals?: [number, number][] | undefined;
|
|
@@ -132,7 +132,7 @@ declare const BlockDef: z.ZodObject<{
|
|
|
132
132
|
}>>;
|
|
133
133
|
canRotate: z.ZodDefault<z.ZodBoolean>;
|
|
134
134
|
canScale: z.ZodDefault<z.ZodBoolean>;
|
|
135
|
-
|
|
135
|
+
interactable: z.ZodDefault<z.ZodBoolean>;
|
|
136
136
|
connectors: z.ZodDefault<z.ZodObject<{
|
|
137
137
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
138
138
|
terminals: z.ZodDefault<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
@@ -208,6 +208,11 @@ export { canBlockEdit }
|
|
|
208
208
|
export { canBlockEdit as canBlockEdit_alias_1 }
|
|
209
209
|
export { canBlockEdit as canBlockEdit_alias_2 }
|
|
210
210
|
|
|
211
|
+
declare function canBlockInteract(ctx: Context, tag: string): boolean;
|
|
212
|
+
export { canBlockInteract }
|
|
213
|
+
export { canBlockInteract as canBlockInteract_alias_1 }
|
|
214
|
+
export { canBlockInteract as canBlockInteract_alias_2 }
|
|
215
|
+
|
|
211
216
|
declare function canBlockRotate(ctx: Context, tag: string): boolean;
|
|
212
217
|
export { canBlockRotate }
|
|
213
218
|
export { canBlockRotate as canBlockRotate_alias_1 }
|
|
@@ -216,11 +221,6 @@ declare function canBlockScale(ctx: Context, tag: string): boolean;
|
|
|
216
221
|
export { canBlockScale }
|
|
217
222
|
export { canBlockScale as canBlockScale_alias_1 }
|
|
218
223
|
|
|
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
|
-
|
|
224
224
|
declare const canSeeBlocksSystem: EditorSystem;
|
|
225
225
|
export { canSeeBlocksSystem }
|
|
226
226
|
export { canSeeBlocksSystem as canSeeBlocksSystem_alias_1 }
|
|
@@ -516,7 +516,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
516
516
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
517
517
|
canRotate?: boolean | undefined;
|
|
518
518
|
canScale?: boolean | undefined;
|
|
519
|
-
|
|
519
|
+
interactable?: boolean | undefined;
|
|
520
520
|
connectors?: {
|
|
521
521
|
enabled?: boolean | undefined;
|
|
522
522
|
terminals?: [number, number][] | undefined;
|
|
@@ -532,7 +532,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
|
|
|
532
532
|
resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
|
|
533
533
|
canRotate?: boolean | undefined;
|
|
534
534
|
canScale?: boolean | undefined;
|
|
535
|
-
|
|
535
|
+
interactable?: boolean | undefined;
|
|
536
536
|
connectors?: {
|
|
537
537
|
enabled?: boolean | undefined;
|
|
538
538
|
terminals?: [number, number][] | undefined;
|
package/build/index.cjs
CHANGED
|
@@ -86,7 +86,7 @@ __export(index_exports, {
|
|
|
86
86
|
VerticalAlignment: () => VerticalAlignment,
|
|
87
87
|
addComponent: () => import_core50.addComponent,
|
|
88
88
|
canBlockEdit: () => canBlockEdit,
|
|
89
|
-
|
|
89
|
+
canBlockInteract: () => canBlockInteract,
|
|
90
90
|
clearPointerTrackingState: () => clearPointerTrackingState,
|
|
91
91
|
createEntity: () => import_core50.createEntity,
|
|
92
92
|
defineCanvasComponent: () => import_canvas_store35.defineCanvasComponent,
|
|
@@ -259,7 +259,7 @@ var ControlsOptions = import_zod.z.object({
|
|
|
259
259
|
* Tool activated by right mouse button.
|
|
260
260
|
* @default 'menu'
|
|
261
261
|
*/
|
|
262
|
-
rightMouseTool: import_zod.z.string().max(32).default("
|
|
262
|
+
rightMouseTool: import_zod.z.string().max(32).default("hand"),
|
|
263
263
|
/**
|
|
264
264
|
* Tool activated by mouse wheel.
|
|
265
265
|
* @default 'scroll'
|
|
@@ -420,7 +420,7 @@ var BlockDef = import_zod.z.object({
|
|
|
420
420
|
resizeMode: import_zod.z.enum([ResizeMode.Scale, ResizeMode.Text, ResizeMode.Free, ResizeMode.GroupOnly]).default(ResizeMode.Scale),
|
|
421
421
|
canRotate: import_zod.z.boolean().default(true),
|
|
422
422
|
canScale: import_zod.z.boolean().default(true),
|
|
423
|
-
|
|
423
|
+
interactable: import_zod.z.boolean().default(true),
|
|
424
424
|
connectors: BlockDefConnectors.default(BlockDefConnectors.parse({}))
|
|
425
425
|
});
|
|
426
426
|
|
|
@@ -1615,7 +1615,7 @@ var ControlsSchema = {
|
|
|
1615
1615
|
/** Tool activated by middle mouse button */
|
|
1616
1616
|
middleMouseTool: import_core19.field.string().max(32).default("hand"),
|
|
1617
1617
|
/** Tool activated by right mouse button */
|
|
1618
|
-
rightMouseTool: import_core19.field.string().max(32).default("
|
|
1618
|
+
rightMouseTool: import_core19.field.string().max(32).default("hand"),
|
|
1619
1619
|
/** Tool activated by mouse wheel */
|
|
1620
1620
|
wheelTool: import_core19.field.string().max(32).default("scroll"),
|
|
1621
1621
|
/** Tool activated by mouse wheel with modifier key held */
|
|
@@ -2632,9 +2632,13 @@ function attachPointerListeners(domElement) {
|
|
|
2632
2632
|
});
|
|
2633
2633
|
},
|
|
2634
2634
|
onContextMenu: (e) => {
|
|
2635
|
+
if (e.target instanceof HTMLElement && e.target.closest('[contenteditable="true"]')) return;
|
|
2635
2636
|
e.preventDefault();
|
|
2636
|
-
const
|
|
2637
|
-
|
|
2637
|
+
const hasRightButtonEvent = state.eventsBuffer.some(
|
|
2638
|
+
(evt) => evt.button === 2 && (evt.type === "pointerdown" || evt.type === "pointerup")
|
|
2639
|
+
);
|
|
2640
|
+
if (hasRightButtonEvent) return;
|
|
2641
|
+
if (state.pointerEntityMap.size > 0) return;
|
|
2638
2642
|
state.eventsBuffer.push({
|
|
2639
2643
|
type: "pointerdown",
|
|
2640
2644
|
pointerId: 0,
|
|
@@ -2843,8 +2847,8 @@ function getBlockDef(ctx, tag) {
|
|
|
2843
2847
|
function canBlockEdit(ctx, tag) {
|
|
2844
2848
|
return getBlockDef(ctx, tag).editOptions.canEdit;
|
|
2845
2849
|
}
|
|
2846
|
-
function
|
|
2847
|
-
return getBlockDef(ctx, tag).
|
|
2850
|
+
function canBlockInteract(ctx, tag) {
|
|
2851
|
+
return getBlockDef(ctx, tag).interactable;
|
|
2848
2852
|
}
|
|
2849
2853
|
function getBlockResizeMode(ctx, entityId) {
|
|
2850
2854
|
const block = Block.read(ctx, entityId);
|
|
@@ -3240,6 +3244,10 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3240
3244
|
changed.add(entityId);
|
|
3241
3245
|
}
|
|
3242
3246
|
for (const entityId of added) {
|
|
3247
|
+
if ((0, import_core43.hasComponent)(ctx, entityId, Block)) {
|
|
3248
|
+
const block = Block.read(ctx, entityId);
|
|
3249
|
+
if (!canBlockInteract(ctx, block.tag)) continue;
|
|
3250
|
+
}
|
|
3243
3251
|
if (!(0, import_core43.hasComponent)(ctx, entityId, Aabb)) {
|
|
3244
3252
|
(0, import_core43.addComponent)(ctx, entityId, Aabb, { value: [0, 0, 0, 0] });
|
|
3245
3253
|
}
|
|
@@ -3247,6 +3255,7 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3247
3255
|
computeAabb(ctx, entityId, aabb.value);
|
|
3248
3256
|
}
|
|
3249
3257
|
for (const entityId of changed) {
|
|
3258
|
+
if (!(0, import_core43.hasComponent)(ctx, entityId, Aabb)) continue;
|
|
3250
3259
|
const aabb = Aabb.write(ctx, entityId);
|
|
3251
3260
|
computeAabb(ctx, entityId, aabb.value);
|
|
3252
3261
|
}
|
|
@@ -3358,6 +3367,7 @@ var import_core46 = require("@woven-ecs/core");
|
|
|
3358
3367
|
var scaleWithZoomQuery = (0, import_core46.defineQuery)((q) => q.with(Block).tracking(ScaleWithZoom));
|
|
3359
3368
|
var _scaledSize = [0, 0];
|
|
3360
3369
|
var _anchorOffset = [0, 0];
|
|
3370
|
+
var _anchorAdj = [0, 0];
|
|
3361
3371
|
var scaleWithZoomSystem = defineEditorSystem({ phase: "render", priority: 100 }, (ctx) => {
|
|
3362
3372
|
const camera = Camera.read(ctx);
|
|
3363
3373
|
const state = ScaleWithZoomState.read(ctx);
|
|
@@ -3382,7 +3392,15 @@ function scaleBlock(ctx, entityId, zoom) {
|
|
|
3382
3392
|
_scaledSize[1] = swz.startSize[1] * scaleY;
|
|
3383
3393
|
import_math8.Vec2.copy(_anchorOffset, swz.startSize);
|
|
3384
3394
|
import_math8.Vec2.sub(_anchorOffset, _scaledSize);
|
|
3385
|
-
|
|
3395
|
+
if (block.rotateZ !== 0) {
|
|
3396
|
+
_anchorAdj[0] = _anchorOffset[0] * (swz.anchor[0] - 0.5);
|
|
3397
|
+
_anchorAdj[1] = _anchorOffset[1] * (swz.anchor[1] - 0.5);
|
|
3398
|
+
import_math8.Vec2.rotate(_anchorAdj, block.rotateZ);
|
|
3399
|
+
_anchorOffset[0] = _anchorOffset[0] * 0.5 + _anchorAdj[0];
|
|
3400
|
+
_anchorOffset[1] = _anchorOffset[1] * 0.5 + _anchorAdj[1];
|
|
3401
|
+
} else {
|
|
3402
|
+
import_math8.Vec2.multiply(_anchorOffset, swz.anchor);
|
|
3403
|
+
}
|
|
3386
3404
|
import_math8.Vec2.copy(block.position, swz.startPosition);
|
|
3387
3405
|
import_math8.Vec2.add(block.position, _anchorOffset);
|
|
3388
3406
|
import_math8.Vec2.copy(block.size, _scaledSize);
|
|
@@ -4356,7 +4374,7 @@ function clearPointerTrackingState(ctx) {
|
|
|
4356
4374
|
VerticalAlignment,
|
|
4357
4375
|
addComponent,
|
|
4358
4376
|
canBlockEdit,
|
|
4359
|
-
|
|
4377
|
+
canBlockInteract,
|
|
4360
4378
|
clearPointerTrackingState,
|
|
4361
4379
|
createEntity,
|
|
4362
4380
|
defineCanvasComponent,
|