@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
package/build/index.d.cts
CHANGED
|
@@ -91,7 +91,7 @@ export { FontFamily_alias_1 as FontFamily } from './_tsup-dts-rollup.cjs';
|
|
|
91
91
|
export { FontFamilyInput_alias_1 as FontFamilyInput } from './_tsup-dts-rollup.cjs';
|
|
92
92
|
export { FontLoader_alias_1 as FontLoader } from './_tsup-dts-rollup.cjs';
|
|
93
93
|
export { canBlockEdit } from './_tsup-dts-rollup.cjs';
|
|
94
|
-
export {
|
|
94
|
+
export { canBlockInteract } from './_tsup-dts-rollup.cjs';
|
|
95
95
|
export { detectEmbedProvider } from './_tsup-dts-rollup.cjs';
|
|
96
96
|
export { getBlockDef } from './_tsup-dts-rollup.cjs';
|
|
97
97
|
export { getBlockResizeMode } from './_tsup-dts-rollup.cjs';
|
package/build/index.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export { FontFamily_alias_1 as FontFamily } from './_tsup-dts-rollup.js';
|
|
|
91
91
|
export { FontFamilyInput_alias_1 as FontFamilyInput } from './_tsup-dts-rollup.js';
|
|
92
92
|
export { FontLoader_alias_1 as FontLoader } from './_tsup-dts-rollup.js';
|
|
93
93
|
export { canBlockEdit } from './_tsup-dts-rollup.js';
|
|
94
|
-
export {
|
|
94
|
+
export { canBlockInteract } from './_tsup-dts-rollup.js';
|
|
95
95
|
export { detectEmbedProvider } from './_tsup-dts-rollup.js';
|
|
96
96
|
export { getBlockDef } from './_tsup-dts-rollup.js';
|
|
97
97
|
export { getBlockResizeMode } from './_tsup-dts-rollup.js';
|
package/build/index.js
CHANGED
|
@@ -166,7 +166,7 @@ var ControlsOptions = z.object({
|
|
|
166
166
|
* Tool activated by right mouse button.
|
|
167
167
|
* @default 'menu'
|
|
168
168
|
*/
|
|
169
|
-
rightMouseTool: z.string().max(32).default("
|
|
169
|
+
rightMouseTool: z.string().max(32).default("hand"),
|
|
170
170
|
/**
|
|
171
171
|
* Tool activated by mouse wheel.
|
|
172
172
|
* @default 'scroll'
|
|
@@ -327,7 +327,7 @@ var BlockDef = z.object({
|
|
|
327
327
|
resizeMode: z.enum([ResizeMode.Scale, ResizeMode.Text, ResizeMode.Free, ResizeMode.GroupOnly]).default(ResizeMode.Scale),
|
|
328
328
|
canRotate: z.boolean().default(true),
|
|
329
329
|
canScale: z.boolean().default(true),
|
|
330
|
-
|
|
330
|
+
interactable: z.boolean().default(true),
|
|
331
331
|
connectors: BlockDefConnectors.default(BlockDefConnectors.parse({}))
|
|
332
332
|
});
|
|
333
333
|
|
|
@@ -1522,7 +1522,7 @@ var ControlsSchema = {
|
|
|
1522
1522
|
/** Tool activated by middle mouse button */
|
|
1523
1523
|
middleMouseTool: field19.string().max(32).default("hand"),
|
|
1524
1524
|
/** Tool activated by right mouse button */
|
|
1525
|
-
rightMouseTool: field19.string().max(32).default("
|
|
1525
|
+
rightMouseTool: field19.string().max(32).default("hand"),
|
|
1526
1526
|
/** Tool activated by mouse wheel */
|
|
1527
1527
|
wheelTool: field19.string().max(32).default("scroll"),
|
|
1528
1528
|
/** Tool activated by mouse wheel with modifier key held */
|
|
@@ -2547,9 +2547,12 @@ function attachPointerListeners(domElement) {
|
|
|
2547
2547
|
});
|
|
2548
2548
|
},
|
|
2549
2549
|
onContextMenu: (e) => {
|
|
2550
|
+
if (e.target instanceof HTMLElement && e.target.closest('[contenteditable="true"]')) return;
|
|
2550
2551
|
e.preventDefault();
|
|
2551
|
-
const
|
|
2552
|
-
|
|
2552
|
+
const hasRightButtonEvent = state.eventsBuffer.some(
|
|
2553
|
+
(evt) => evt.button === 2 && (evt.type === "pointerdown" || evt.type === "pointerup")
|
|
2554
|
+
);
|
|
2555
|
+
if (hasRightButtonEvent) return;
|
|
2553
2556
|
state.eventsBuffer.push({
|
|
2554
2557
|
type: "pointerdown",
|
|
2555
2558
|
pointerId: 0,
|
|
@@ -2758,8 +2761,8 @@ function getBlockDef(ctx, tag) {
|
|
|
2758
2761
|
function canBlockEdit(ctx, tag) {
|
|
2759
2762
|
return getBlockDef(ctx, tag).editOptions.canEdit;
|
|
2760
2763
|
}
|
|
2761
|
-
function
|
|
2762
|
-
return getBlockDef(ctx, tag).
|
|
2764
|
+
function canBlockInteract(ctx, tag) {
|
|
2765
|
+
return getBlockDef(ctx, tag).interactable;
|
|
2763
2766
|
}
|
|
2764
2767
|
function getBlockResizeMode(ctx, entityId) {
|
|
2765
2768
|
const block = Block.read(ctx, entityId);
|
|
@@ -3155,6 +3158,10 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3155
3158
|
changed.add(entityId);
|
|
3156
3159
|
}
|
|
3157
3160
|
for (const entityId of added) {
|
|
3161
|
+
if (hasComponent5(ctx, entityId, Block)) {
|
|
3162
|
+
const block = Block.read(ctx, entityId);
|
|
3163
|
+
if (!canBlockInteract(ctx, block.tag)) continue;
|
|
3164
|
+
}
|
|
3158
3165
|
if (!hasComponent5(ctx, entityId, Aabb)) {
|
|
3159
3166
|
addComponent4(ctx, entityId, Aabb, { value: [0, 0, 0, 0] });
|
|
3160
3167
|
}
|
|
@@ -3162,6 +3169,7 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
|
|
|
3162
3169
|
computeAabb(ctx, entityId, aabb.value);
|
|
3163
3170
|
}
|
|
3164
3171
|
for (const entityId of changed) {
|
|
3172
|
+
if (!hasComponent5(ctx, entityId, Aabb)) continue;
|
|
3165
3173
|
const aabb = Aabb.write(ctx, entityId);
|
|
3166
3174
|
computeAabb(ctx, entityId, aabb.value);
|
|
3167
3175
|
}
|
|
@@ -3273,6 +3281,7 @@ import { defineQuery as defineQuery9 } from "@woven-ecs/core";
|
|
|
3273
3281
|
var scaleWithZoomQuery = defineQuery9((q) => q.with(Block).tracking(ScaleWithZoom));
|
|
3274
3282
|
var _scaledSize = [0, 0];
|
|
3275
3283
|
var _anchorOffset = [0, 0];
|
|
3284
|
+
var _anchorAdj = [0, 0];
|
|
3276
3285
|
var scaleWithZoomSystem = defineEditorSystem({ phase: "render", priority: 100 }, (ctx) => {
|
|
3277
3286
|
const camera = Camera.read(ctx);
|
|
3278
3287
|
const state = ScaleWithZoomState.read(ctx);
|
|
@@ -3297,7 +3306,15 @@ function scaleBlock(ctx, entityId, zoom) {
|
|
|
3297
3306
|
_scaledSize[1] = swz.startSize[1] * scaleY;
|
|
3298
3307
|
Vec22.copy(_anchorOffset, swz.startSize);
|
|
3299
3308
|
Vec22.sub(_anchorOffset, _scaledSize);
|
|
3300
|
-
|
|
3309
|
+
if (block.rotateZ !== 0) {
|
|
3310
|
+
_anchorAdj[0] = _anchorOffset[0] * (swz.anchor[0] - 0.5);
|
|
3311
|
+
_anchorAdj[1] = _anchorOffset[1] * (swz.anchor[1] - 0.5);
|
|
3312
|
+
Vec22.rotate(_anchorAdj, block.rotateZ);
|
|
3313
|
+
_anchorOffset[0] = _anchorOffset[0] * 0.5 + _anchorAdj[0];
|
|
3314
|
+
_anchorOffset[1] = _anchorOffset[1] * 0.5 + _anchorAdj[1];
|
|
3315
|
+
} else {
|
|
3316
|
+
Vec22.multiply(_anchorOffset, swz.anchor);
|
|
3317
|
+
}
|
|
3301
3318
|
Vec22.copy(block.position, swz.startPosition);
|
|
3302
3319
|
Vec22.add(block.position, _anchorOffset);
|
|
3303
3320
|
Vec22.copy(block.size, _scaledSize);
|
|
@@ -4274,7 +4291,7 @@ export {
|
|
|
4274
4291
|
VerticalAlignment,
|
|
4275
4292
|
addComponent6 as addComponent,
|
|
4276
4293
|
canBlockEdit,
|
|
4277
|
-
|
|
4294
|
+
canBlockInteract,
|
|
4278
4295
|
clearPointerTrackingState,
|
|
4279
4296
|
createEntity5 as createEntity,
|
|
4280
4297
|
defineCanvasComponent14 as defineCanvasComponent,
|