@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/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 { canBlockSelect } from './_tsup-dts-rollup.cjs';
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 { canBlockSelect } from './_tsup-dts-rollup.js';
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("menu"),
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
- selectable: z.boolean().default(true),
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("menu"),
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,13 @@ 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 hasPointerDown = state.eventsBuffer.some((evt) => evt.type === "pointerdown");
2552
- if (hasPointerDown) return;
2552
+ const hasRightButtonEvent = state.eventsBuffer.some(
2553
+ (evt) => evt.button === 2 && (evt.type === "pointerdown" || evt.type === "pointerup")
2554
+ );
2555
+ if (hasRightButtonEvent) return;
2556
+ if (state.pointerEntityMap.size > 0) return;
2553
2557
  state.eventsBuffer.push({
2554
2558
  type: "pointerdown",
2555
2559
  pointerId: 0,
@@ -2758,8 +2762,8 @@ function getBlockDef(ctx, tag) {
2758
2762
  function canBlockEdit(ctx, tag) {
2759
2763
  return getBlockDef(ctx, tag).editOptions.canEdit;
2760
2764
  }
2761
- function canBlockSelect(ctx, tag) {
2762
- return getBlockDef(ctx, tag).selectable;
2765
+ function canBlockInteract(ctx, tag) {
2766
+ return getBlockDef(ctx, tag).interactable;
2763
2767
  }
2764
2768
  function getBlockResizeMode(ctx, entityId) {
2765
2769
  const block = Block.read(ctx, entityId);
@@ -3155,6 +3159,10 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
3155
3159
  changed.add(entityId);
3156
3160
  }
3157
3161
  for (const entityId of added) {
3162
+ if (hasComponent5(ctx, entityId, Block)) {
3163
+ const block = Block.read(ctx, entityId);
3164
+ if (!canBlockInteract(ctx, block.tag)) continue;
3165
+ }
3158
3166
  if (!hasComponent5(ctx, entityId, Aabb)) {
3159
3167
  addComponent4(ctx, entityId, Aabb, { value: [0, 0, 0, 0] });
3160
3168
  }
@@ -3162,6 +3170,7 @@ var intersectSystem = defineEditorSystem({ phase: "capture", priority: 100 }, (c
3162
3170
  computeAabb(ctx, entityId, aabb.value);
3163
3171
  }
3164
3172
  for (const entityId of changed) {
3173
+ if (!hasComponent5(ctx, entityId, Aabb)) continue;
3165
3174
  const aabb = Aabb.write(ctx, entityId);
3166
3175
  computeAabb(ctx, entityId, aabb.value);
3167
3176
  }
@@ -3273,6 +3282,7 @@ import { defineQuery as defineQuery9 } from "@woven-ecs/core";
3273
3282
  var scaleWithZoomQuery = defineQuery9((q) => q.with(Block).tracking(ScaleWithZoom));
3274
3283
  var _scaledSize = [0, 0];
3275
3284
  var _anchorOffset = [0, 0];
3285
+ var _anchorAdj = [0, 0];
3276
3286
  var scaleWithZoomSystem = defineEditorSystem({ phase: "render", priority: 100 }, (ctx) => {
3277
3287
  const camera = Camera.read(ctx);
3278
3288
  const state = ScaleWithZoomState.read(ctx);
@@ -3297,7 +3307,15 @@ function scaleBlock(ctx, entityId, zoom) {
3297
3307
  _scaledSize[1] = swz.startSize[1] * scaleY;
3298
3308
  Vec22.copy(_anchorOffset, swz.startSize);
3299
3309
  Vec22.sub(_anchorOffset, _scaledSize);
3300
- Vec22.multiply(_anchorOffset, swz.anchor);
3310
+ if (block.rotateZ !== 0) {
3311
+ _anchorAdj[0] = _anchorOffset[0] * (swz.anchor[0] - 0.5);
3312
+ _anchorAdj[1] = _anchorOffset[1] * (swz.anchor[1] - 0.5);
3313
+ Vec22.rotate(_anchorAdj, block.rotateZ);
3314
+ _anchorOffset[0] = _anchorOffset[0] * 0.5 + _anchorAdj[0];
3315
+ _anchorOffset[1] = _anchorOffset[1] * 0.5 + _anchorAdj[1];
3316
+ } else {
3317
+ Vec22.multiply(_anchorOffset, swz.anchor);
3318
+ }
3301
3319
  Vec22.copy(block.position, swz.startPosition);
3302
3320
  Vec22.add(block.position, _anchorOffset);
3303
3321
  Vec22.copy(block.size, _scaledSize);
@@ -4274,7 +4292,7 @@ export {
4274
4292
  VerticalAlignment,
4275
4293
  addComponent6 as addComponent,
4276
4294
  canBlockEdit,
4277
- canBlockSelect,
4295
+ canBlockInteract,
4278
4296
  clearPointerTrackingState,
4279
4297
  createEntity5 as createEntity,
4280
4298
  defineCanvasComponent14 as defineCanvasComponent,