@woven-canvas/core 1.0.1 → 1.0.2
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 +27 -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 +26 -9
- package/build/index.js.map +1 -1
- package/package.json +1 -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,12 @@ 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;
|
|
2638
2641
|
state.eventsBuffer.push({
|
|
2639
2642
|
type: "pointerdown",
|
|
2640
2643
|
pointerId: 0,
|
|
@@ -2843,8 +2846,8 @@ function getBlockDef(ctx, tag) {
|
|
|
2843
2846
|
function canBlockEdit(ctx, tag) {
|
|
2844
2847
|
return getBlockDef(ctx, tag).editOptions.canEdit;
|
|
2845
2848
|
}
|
|
2846
|
-
function
|
|
2847
|
-
return getBlockDef(ctx, tag).
|
|
2849
|
+
function canBlockInteract(ctx, tag) {
|
|
2850
|
+
return getBlockDef(ctx, tag).interactable;
|
|
2848
2851
|
}
|
|
2849
2852
|
function getBlockResizeMode(ctx, entityId) {
|
|
2850
2853
|
const block = Block.read(ctx, entityId);
|
|
@@ -3240,6 +3243,10 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3240
3243
|
changed.add(entityId);
|
|
3241
3244
|
}
|
|
3242
3245
|
for (const entityId of added) {
|
|
3246
|
+
if ((0, import_core43.hasComponent)(ctx, entityId, Block)) {
|
|
3247
|
+
const block = Block.read(ctx, entityId);
|
|
3248
|
+
if (!canBlockInteract(ctx, block.tag)) continue;
|
|
3249
|
+
}
|
|
3243
3250
|
if (!(0, import_core43.hasComponent)(ctx, entityId, Aabb)) {
|
|
3244
3251
|
(0, import_core43.addComponent)(ctx, entityId, Aabb, { value: [0, 0, 0, 0] });
|
|
3245
3252
|
}
|
|
@@ -3247,6 +3254,7 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3247
3254
|
computeAabb(ctx, entityId, aabb.value);
|
|
3248
3255
|
}
|
|
3249
3256
|
for (const entityId of changed) {
|
|
3257
|
+
if (!(0, import_core43.hasComponent)(ctx, entityId, Aabb)) continue;
|
|
3250
3258
|
const aabb = Aabb.write(ctx, entityId);
|
|
3251
3259
|
computeAabb(ctx, entityId, aabb.value);
|
|
3252
3260
|
}
|
|
@@ -3358,6 +3366,7 @@ var import_core46 = require("@woven-ecs/core");
|
|
|
3358
3366
|
var scaleWithZoomQuery = (0, import_core46.defineQuery)((q) => q.with(Block).tracking(ScaleWithZoom));
|
|
3359
3367
|
var _scaledSize = [0, 0];
|
|
3360
3368
|
var _anchorOffset = [0, 0];
|
|
3369
|
+
var _anchorAdj = [0, 0];
|
|
3361
3370
|
var scaleWithZoomSystem = defineEditorSystem({ phase: "render", priority: 100 }, (ctx) => {
|
|
3362
3371
|
const camera = Camera.read(ctx);
|
|
3363
3372
|
const state = ScaleWithZoomState.read(ctx);
|
|
@@ -3382,7 +3391,15 @@ function scaleBlock(ctx, entityId, zoom) {
|
|
|
3382
3391
|
_scaledSize[1] = swz.startSize[1] * scaleY;
|
|
3383
3392
|
import_math8.Vec2.copy(_anchorOffset, swz.startSize);
|
|
3384
3393
|
import_math8.Vec2.sub(_anchorOffset, _scaledSize);
|
|
3385
|
-
|
|
3394
|
+
if (block.rotateZ !== 0) {
|
|
3395
|
+
_anchorAdj[0] = _anchorOffset[0] * (swz.anchor[0] - 0.5);
|
|
3396
|
+
_anchorAdj[1] = _anchorOffset[1] * (swz.anchor[1] - 0.5);
|
|
3397
|
+
import_math8.Vec2.rotate(_anchorAdj, block.rotateZ);
|
|
3398
|
+
_anchorOffset[0] = _anchorOffset[0] * 0.5 + _anchorAdj[0];
|
|
3399
|
+
_anchorOffset[1] = _anchorOffset[1] * 0.5 + _anchorAdj[1];
|
|
3400
|
+
} else {
|
|
3401
|
+
import_math8.Vec2.multiply(_anchorOffset, swz.anchor);
|
|
3402
|
+
}
|
|
3386
3403
|
import_math8.Vec2.copy(block.position, swz.startPosition);
|
|
3387
3404
|
import_math8.Vec2.add(block.position, _anchorOffset);
|
|
3388
3405
|
import_math8.Vec2.copy(block.size, _scaledSize);
|
|
@@ -4356,7 +4373,7 @@ function clearPointerTrackingState(ctx) {
|
|
|
4356
4373
|
VerticalAlignment,
|
|
4357
4374
|
addComponent,
|
|
4358
4375
|
canBlockEdit,
|
|
4359
|
-
|
|
4376
|
+
canBlockInteract,
|
|
4360
4377
|
clearPointerTrackingState,
|
|
4361
4378
|
createEntity,
|
|
4362
4379
|
defineCanvasComponent,
|