@woven-canvas/core 1.0.6 → 1.0.9

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/README.md CHANGED
@@ -27,7 +27,7 @@ loop();
27
27
 
28
28
  ## Documentation
29
29
 
30
- For full API documentation, see the [documentation site](https://wovencanvas.dev).
30
+ For full API documentation, see [woven-canvas.dev](https://woven-canvas.dev).
31
31
 
32
32
  ## License
33
33
 
@@ -169,6 +169,7 @@ declare const BlockDef: z.ZodObject<{
169
169
  }>>;
170
170
  canRotate: z.ZodDefault<z.ZodBoolean>;
171
171
  canScale: z.ZodDefault<z.ZodBoolean>;
172
+ snappable: z.ZodDefault<z.ZodBoolean>;
172
173
  interactable: z.ZodDefault<z.ZodBoolean>;
173
174
  excludeFromRankBounds: z.ZodDefault<z.ZodBoolean>;
174
175
  connectors: z.ZodDefault<z.ZodObject<{
@@ -215,6 +216,7 @@ declare const BlockSchema: {
215
216
  rank: StringFieldBuilder;
216
217
  resizeMode: EnumFieldBuilder<"default" | "scale" | "text" | "free" | "groupOnly">;
217
218
  parentId: RefFieldBuilder;
219
+ layerId: RefFieldBuilder;
218
220
  };
219
221
 
220
222
  declare const blockSystem: EditorSystem;
@@ -271,6 +273,8 @@ declare function canBlockScale(ctx: Context, tag: string): boolean;
271
273
  export { canBlockScale }
272
274
  export { canBlockScale as canBlockScale_alias_1 }
273
275
 
276
+ export declare function canBlockSnap(ctx: Context, tag: string): boolean;
277
+
274
278
  declare const canSeeBlocksSystem: EditorSystem;
275
279
  export { canSeeBlocksSystem }
276
280
  export { canSeeBlocksSystem as canSeeBlocksSystem_alias_1 }
@@ -447,6 +451,26 @@ declare const CorePluginOptionsSchema: z.ZodObject<{
447
451
  export { CorePluginOptionsSchema }
448
452
  export { CorePluginOptionsSchema as CorePluginOptionsSchema_alias_1 }
449
453
 
454
+ declare function createBlock(ctx: Context, block: CreateBlockInput): EntityId;
455
+ export { createBlock }
456
+ export { createBlock as createBlock_alias_1 }
457
+ export { createBlock as createBlock_alias_2 }
458
+
459
+ declare interface CreateBlockInput {
460
+ tag: string;
461
+ position: Vec2;
462
+ size?: Vec2;
463
+ rotateZ?: number;
464
+ flip?: [boolean, boolean];
465
+ resizeMode?: ResizeMode;
466
+ parentId?: EntityId | null;
467
+ layerId?: EntityId | null;
468
+ rank?: string;
469
+ }
470
+ export { CreateBlockInput }
471
+ export { CreateBlockInput as CreateBlockInput_alias_1 }
472
+ export { CreateBlockInput as CreateBlockInput_alias_2 }
473
+
450
474
  declare function createCorePlugin(options?: CorePluginOptionsInput): EditorPlugin<CorePluginOptions>;
451
475
  export { createCorePlugin }
452
476
  export { createCorePlugin as createCorePlugin_alias_1 }
@@ -632,6 +656,8 @@ declare class Editor {
632
656
  constructor(domElement: HTMLElement | null, optionsInput?: EditorOptionsInput);
633
657
  private get ctx();
634
658
  initialize(): Promise<void>;
659
+ loadFont(name: string): Promise<void>;
660
+ isFontLoaded(name: string): boolean;
635
661
  tick(): Promise<void>;
636
662
  nextTick(callback: (ctx: Context) => void): () => void;
637
663
  command<T>(def: CommandDef<T>, ...args: T extends void ? [] : [T]): void;
@@ -708,6 +734,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
708
734
  resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
709
735
  canRotate?: boolean | undefined;
710
736
  canScale?: boolean | undefined;
737
+ snappable?: boolean | undefined;
711
738
  interactable?: boolean | undefined;
712
739
  excludeFromRankBounds?: boolean | undefined;
713
740
  connectors?: {
@@ -725,6 +752,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
725
752
  resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
726
753
  canRotate?: boolean | undefined;
727
754
  canScale?: boolean | undefined;
755
+ snappable?: boolean | undefined;
728
756
  interactable?: boolean | undefined;
729
757
  excludeFromRankBounds?: boolean | undefined;
730
758
  connectors?: {
@@ -927,8 +955,10 @@ export { FontFamilyInput }
927
955
  export { FontFamilyInput as FontFamilyInput_alias_1 }
928
956
 
929
957
  declare class FontLoader {
930
- private loadedFonts;
958
+ private loaded;
959
+ private inFlight;
931
960
  loadFonts(families: FontFamily[]): Promise<void>;
961
+ loadFont(family: FontFamily): Promise<void>;
932
962
  private buildGoogleFontsUrl;
933
963
  private loadSingleFont;
934
964
  private getFontLoadPromises;
@@ -1132,6 +1162,7 @@ declare class HitGeometryDef extends CanvasComponentDef<typeof HitGeometrySchema
1132
1162
  getArcAt(ctx: Context, entityId: EntityId, index: number): Arc;
1133
1163
  setArcAt(ctx: Context, entityId: EntityId, index: number, arc: Arc): void;
1134
1164
  containsPointWorld(ctx: Context, entityId: EntityId, point: Vec2): boolean;
1165
+ private fillWorldPolygon;
1135
1166
  intersectsAabbWorld(ctx: Context, entityId: EntityId, aabb: Aabb_2): boolean;
1136
1167
  getExtremaWorld(ctx: Context, entityId: EntityId): Vec2[];
1137
1168
  addCapsule(ctx: Context, entityId: EntityId, capsule: Capsule): void;
@@ -1140,6 +1171,7 @@ declare class HitGeometryDef extends CanvasComponentDef<typeof HitGeometrySchema
1140
1171
  addArc(ctx: Context, entityId: EntityId, arc: Arc): void;
1141
1172
  addArcUv(ctx: Context, entityId: EntityId, uvA: Vec2, uvB: Vec2, uvC: Vec2, worldThickness: number): void;
1142
1173
  addArcWorld(ctx: Context, entityId: EntityId, worldA: Vec2, worldB: Vec2, worldC: Vec2, worldThickness: number): void;
1174
+ setPolygonUv(ctx: Context, entityId: EntityId, uvPoints: Vec2[]): void;
1143
1175
  clear(ctx: Context, entityId: EntityId): void;
1144
1176
  }
1145
1177
 
@@ -1148,6 +1180,8 @@ declare const HitGeometrySchema: {
1148
1180
  capsuleCount: NumberFieldBuilder<"uint16">;
1149
1181
  hitArcs: BufferFieldBuilder<"float32">;
1150
1182
  arcCount: NumberFieldBuilder<"uint16">;
1183
+ hitPolygon: BufferFieldBuilder<"float32">;
1184
+ polygonPointCount: NumberFieldBuilder<"uint16">;
1151
1185
  };
1152
1186
 
1153
1187
  declare const hoverCursorSystem: EditorSystem;
@@ -1228,6 +1262,11 @@ export { isHeldByRemote }
1228
1262
  export { isHeldByRemote as isHeldByRemote_alias_1 }
1229
1263
  export { isHeldByRemote as isHeldByRemote_alias_2 }
1230
1264
 
1265
+ declare function isLayerInteractive(ctx: Context, layerId: EntityId | null): boolean;
1266
+ export { isLayerInteractive }
1267
+ export { isLayerInteractive as isLayerInteractive_alias_1 }
1268
+ export { isLayerInteractive as isLayerInteractive_alias_2 }
1269
+
1231
1270
  declare function isReadonly(ctx: Context): boolean;
1232
1271
  export { isReadonly }
1233
1272
  export { isReadonly as isReadonly_alias_1 }
@@ -1397,6 +1436,17 @@ declare const keyboardSystem: EditorSystem;
1397
1436
  export { keyboardSystem }
1398
1437
  export { keyboardSystem as keyboardSystem_alias_1 }
1399
1438
 
1439
+ declare const Layer: CanvasComponentDef< {
1440
+ parentId: RefFieldBuilder;
1441
+ rank: StringFieldBuilder;
1442
+ label: StringFieldBuilder;
1443
+ locked: BooleanFieldBuilder;
1444
+ hidden: BooleanFieldBuilder;
1445
+ }, "layer">;
1446
+ export { Layer }
1447
+ export { Layer as Layer_alias_1 }
1448
+ export { Layer as Layer_alias_2 }
1449
+
1400
1450
  declare interface MachineResult<TState, TContext> {
1401
1451
  value: TState;
1402
1452
  context: TContext;
@@ -1416,6 +1466,11 @@ export { MAX_HIT_CAPSULES }
1416
1466
  export { MAX_HIT_CAPSULES as MAX_HIT_CAPSULES_alias_1 }
1417
1467
  export { MAX_HIT_CAPSULES as MAX_HIT_CAPSULES_alias_2 }
1418
1468
 
1469
+ declare const MAX_HIT_POLYGON_POINTS = 128;
1470
+ export { MAX_HIT_POLYGON_POINTS }
1471
+ export { MAX_HIT_POLYGON_POINTS as MAX_HIT_POLYGON_POINTS_alias_1 }
1472
+ export { MAX_HIT_POLYGON_POINTS as MAX_HIT_POLYGON_POINTS_alias_2 }
1473
+
1419
1474
  declare const Mouse: MouseDef;
1420
1475
  export { Mouse }
1421
1476
  export { Mouse as Mouse_alias_1 }
@@ -1479,6 +1534,13 @@ declare function parsePlugin(input: EditorPluginInput): EditorPlugin;
1479
1534
  export { parsePlugin }
1480
1535
  export { parsePlugin as parsePlugin_alias_1 }
1481
1536
 
1537
+ declare const PlaceBlockEvent: CommandDef< {
1538
+ entityId: EntityId;
1539
+ }>;
1540
+ export { PlaceBlockEvent }
1541
+ export { PlaceBlockEvent as PlaceBlockEvent_alias_1 }
1542
+ export { PlaceBlockEvent as PlaceBlockEvent_alias_2 }
1543
+
1482
1544
  declare const Pointer: PointerDef;
1483
1545
  export { Pointer }
1484
1546
  export { Pointer as Pointer_alias_1 }
@@ -1675,6 +1737,11 @@ export { resolveEmbedUrl }
1675
1737
  export { resolveEmbedUrl as resolveEmbedUrl_alias_1 }
1676
1738
  export { resolveEmbedUrl as resolveEmbedUrl_alias_2 }
1677
1739
 
1740
+ declare function resolveLayerRank(ctx: Context, entityId: EntityId): string;
1741
+ export { resolveLayerRank }
1742
+ export { resolveLayerRank as resolveLayerRank_alias_1 }
1743
+ export { resolveLayerRank as resolveLayerRank_alias_2 }
1744
+
1678
1745
  declare function resolveRefFields(ctx: Context, entityId: EntityId, componentDef: {
1679
1746
  schema: ComponentSchema_2;
1680
1747
  write: (ctx: Context, entityId: EntityId) => Record<string, unknown>;
@@ -1877,6 +1944,7 @@ declare interface SortableBlock {
1877
1944
  rank: string;
1878
1945
  stratum: Stratum;
1879
1946
  parentId: unknown;
1947
+ layerRank?: string;
1880
1948
  }
1881
1949
  export { SortableBlock }
1882
1950
  export { SortableBlock as SortableBlock_alias_1 }
@@ -169,6 +169,7 @@ declare const BlockDef: z.ZodObject<{
169
169
  }>>;
170
170
  canRotate: z.ZodDefault<z.ZodBoolean>;
171
171
  canScale: z.ZodDefault<z.ZodBoolean>;
172
+ snappable: z.ZodDefault<z.ZodBoolean>;
172
173
  interactable: z.ZodDefault<z.ZodBoolean>;
173
174
  excludeFromRankBounds: z.ZodDefault<z.ZodBoolean>;
174
175
  connectors: z.ZodDefault<z.ZodObject<{
@@ -215,6 +216,7 @@ declare const BlockSchema: {
215
216
  rank: StringFieldBuilder;
216
217
  resizeMode: EnumFieldBuilder<"default" | "scale" | "text" | "free" | "groupOnly">;
217
218
  parentId: RefFieldBuilder;
219
+ layerId: RefFieldBuilder;
218
220
  };
219
221
 
220
222
  declare const blockSystem: EditorSystem;
@@ -271,6 +273,8 @@ declare function canBlockScale(ctx: Context, tag: string): boolean;
271
273
  export { canBlockScale }
272
274
  export { canBlockScale as canBlockScale_alias_1 }
273
275
 
276
+ export declare function canBlockSnap(ctx: Context, tag: string): boolean;
277
+
274
278
  declare const canSeeBlocksSystem: EditorSystem;
275
279
  export { canSeeBlocksSystem }
276
280
  export { canSeeBlocksSystem as canSeeBlocksSystem_alias_1 }
@@ -447,6 +451,26 @@ declare const CorePluginOptionsSchema: z.ZodObject<{
447
451
  export { CorePluginOptionsSchema }
448
452
  export { CorePluginOptionsSchema as CorePluginOptionsSchema_alias_1 }
449
453
 
454
+ declare function createBlock(ctx: Context, block: CreateBlockInput): EntityId;
455
+ export { createBlock }
456
+ export { createBlock as createBlock_alias_1 }
457
+ export { createBlock as createBlock_alias_2 }
458
+
459
+ declare interface CreateBlockInput {
460
+ tag: string;
461
+ position: Vec2;
462
+ size?: Vec2;
463
+ rotateZ?: number;
464
+ flip?: [boolean, boolean];
465
+ resizeMode?: ResizeMode;
466
+ parentId?: EntityId | null;
467
+ layerId?: EntityId | null;
468
+ rank?: string;
469
+ }
470
+ export { CreateBlockInput }
471
+ export { CreateBlockInput as CreateBlockInput_alias_1 }
472
+ export { CreateBlockInput as CreateBlockInput_alias_2 }
473
+
450
474
  declare function createCorePlugin(options?: CorePluginOptionsInput): EditorPlugin<CorePluginOptions>;
451
475
  export { createCorePlugin }
452
476
  export { createCorePlugin as createCorePlugin_alias_1 }
@@ -632,6 +656,8 @@ declare class Editor {
632
656
  constructor(domElement: HTMLElement | null, optionsInput?: EditorOptionsInput);
633
657
  private get ctx();
634
658
  initialize(): Promise<void>;
659
+ loadFont(name: string): Promise<void>;
660
+ isFontLoaded(name: string): boolean;
635
661
  tick(): Promise<void>;
636
662
  nextTick(callback: (ctx: Context) => void): () => void;
637
663
  command<T>(def: CommandDef<T>, ...args: T extends void ? [] : [T]): void;
@@ -708,6 +734,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
708
734
  resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
709
735
  canRotate?: boolean | undefined;
710
736
  canScale?: boolean | undefined;
737
+ snappable?: boolean | undefined;
711
738
  interactable?: boolean | undefined;
712
739
  excludeFromRankBounds?: boolean | undefined;
713
740
  connectors?: {
@@ -725,6 +752,7 @@ export declare const EditorOptionsSchema: z.ZodObject<{
725
752
  resizeMode?: "scale" | "text" | "free" | "groupOnly" | undefined;
726
753
  canRotate?: boolean | undefined;
727
754
  canScale?: boolean | undefined;
755
+ snappable?: boolean | undefined;
728
756
  interactable?: boolean | undefined;
729
757
  excludeFromRankBounds?: boolean | undefined;
730
758
  connectors?: {
@@ -927,8 +955,10 @@ export { FontFamilyInput }
927
955
  export { FontFamilyInput as FontFamilyInput_alias_1 }
928
956
 
929
957
  declare class FontLoader {
930
- private loadedFonts;
958
+ private loaded;
959
+ private inFlight;
931
960
  loadFonts(families: FontFamily[]): Promise<void>;
961
+ loadFont(family: FontFamily): Promise<void>;
932
962
  private buildGoogleFontsUrl;
933
963
  private loadSingleFont;
934
964
  private getFontLoadPromises;
@@ -1132,6 +1162,7 @@ declare class HitGeometryDef extends CanvasComponentDef<typeof HitGeometrySchema
1132
1162
  getArcAt(ctx: Context, entityId: EntityId, index: number): Arc;
1133
1163
  setArcAt(ctx: Context, entityId: EntityId, index: number, arc: Arc): void;
1134
1164
  containsPointWorld(ctx: Context, entityId: EntityId, point: Vec2): boolean;
1165
+ private fillWorldPolygon;
1135
1166
  intersectsAabbWorld(ctx: Context, entityId: EntityId, aabb: Aabb_2): boolean;
1136
1167
  getExtremaWorld(ctx: Context, entityId: EntityId): Vec2[];
1137
1168
  addCapsule(ctx: Context, entityId: EntityId, capsule: Capsule): void;
@@ -1140,6 +1171,7 @@ declare class HitGeometryDef extends CanvasComponentDef<typeof HitGeometrySchema
1140
1171
  addArc(ctx: Context, entityId: EntityId, arc: Arc): void;
1141
1172
  addArcUv(ctx: Context, entityId: EntityId, uvA: Vec2, uvB: Vec2, uvC: Vec2, worldThickness: number): void;
1142
1173
  addArcWorld(ctx: Context, entityId: EntityId, worldA: Vec2, worldB: Vec2, worldC: Vec2, worldThickness: number): void;
1174
+ setPolygonUv(ctx: Context, entityId: EntityId, uvPoints: Vec2[]): void;
1143
1175
  clear(ctx: Context, entityId: EntityId): void;
1144
1176
  }
1145
1177
 
@@ -1148,6 +1180,8 @@ declare const HitGeometrySchema: {
1148
1180
  capsuleCount: NumberFieldBuilder<"uint16">;
1149
1181
  hitArcs: BufferFieldBuilder<"float32">;
1150
1182
  arcCount: NumberFieldBuilder<"uint16">;
1183
+ hitPolygon: BufferFieldBuilder<"float32">;
1184
+ polygonPointCount: NumberFieldBuilder<"uint16">;
1151
1185
  };
1152
1186
 
1153
1187
  declare const hoverCursorSystem: EditorSystem;
@@ -1228,6 +1262,11 @@ export { isHeldByRemote }
1228
1262
  export { isHeldByRemote as isHeldByRemote_alias_1 }
1229
1263
  export { isHeldByRemote as isHeldByRemote_alias_2 }
1230
1264
 
1265
+ declare function isLayerInteractive(ctx: Context, layerId: EntityId | null): boolean;
1266
+ export { isLayerInteractive }
1267
+ export { isLayerInteractive as isLayerInteractive_alias_1 }
1268
+ export { isLayerInteractive as isLayerInteractive_alias_2 }
1269
+
1231
1270
  declare function isReadonly(ctx: Context): boolean;
1232
1271
  export { isReadonly }
1233
1272
  export { isReadonly as isReadonly_alias_1 }
@@ -1397,6 +1436,17 @@ declare const keyboardSystem: EditorSystem;
1397
1436
  export { keyboardSystem }
1398
1437
  export { keyboardSystem as keyboardSystem_alias_1 }
1399
1438
 
1439
+ declare const Layer: CanvasComponentDef< {
1440
+ parentId: RefFieldBuilder;
1441
+ rank: StringFieldBuilder;
1442
+ label: StringFieldBuilder;
1443
+ locked: BooleanFieldBuilder;
1444
+ hidden: BooleanFieldBuilder;
1445
+ }, "layer">;
1446
+ export { Layer }
1447
+ export { Layer as Layer_alias_1 }
1448
+ export { Layer as Layer_alias_2 }
1449
+
1400
1450
  declare interface MachineResult<TState, TContext> {
1401
1451
  value: TState;
1402
1452
  context: TContext;
@@ -1416,6 +1466,11 @@ export { MAX_HIT_CAPSULES }
1416
1466
  export { MAX_HIT_CAPSULES as MAX_HIT_CAPSULES_alias_1 }
1417
1467
  export { MAX_HIT_CAPSULES as MAX_HIT_CAPSULES_alias_2 }
1418
1468
 
1469
+ declare const MAX_HIT_POLYGON_POINTS = 128;
1470
+ export { MAX_HIT_POLYGON_POINTS }
1471
+ export { MAX_HIT_POLYGON_POINTS as MAX_HIT_POLYGON_POINTS_alias_1 }
1472
+ export { MAX_HIT_POLYGON_POINTS as MAX_HIT_POLYGON_POINTS_alias_2 }
1473
+
1419
1474
  declare const Mouse: MouseDef;
1420
1475
  export { Mouse }
1421
1476
  export { Mouse as Mouse_alias_1 }
@@ -1479,6 +1534,13 @@ declare function parsePlugin(input: EditorPluginInput): EditorPlugin;
1479
1534
  export { parsePlugin }
1480
1535
  export { parsePlugin as parsePlugin_alias_1 }
1481
1536
 
1537
+ declare const PlaceBlockEvent: CommandDef< {
1538
+ entityId: EntityId;
1539
+ }>;
1540
+ export { PlaceBlockEvent }
1541
+ export { PlaceBlockEvent as PlaceBlockEvent_alias_1 }
1542
+ export { PlaceBlockEvent as PlaceBlockEvent_alias_2 }
1543
+
1482
1544
  declare const Pointer: PointerDef;
1483
1545
  export { Pointer }
1484
1546
  export { Pointer as Pointer_alias_1 }
@@ -1675,6 +1737,11 @@ export { resolveEmbedUrl }
1675
1737
  export { resolveEmbedUrl as resolveEmbedUrl_alias_1 }
1676
1738
  export { resolveEmbedUrl as resolveEmbedUrl_alias_2 }
1677
1739
 
1740
+ declare function resolveLayerRank(ctx: Context, entityId: EntityId): string;
1741
+ export { resolveLayerRank }
1742
+ export { resolveLayerRank as resolveLayerRank_alias_1 }
1743
+ export { resolveLayerRank as resolveLayerRank_alias_2 }
1744
+
1678
1745
  declare function resolveRefFields(ctx: Context, entityId: EntityId, componentDef: {
1679
1746
  schema: ComponentSchema_2;
1680
1747
  write: (ctx: Context, entityId: EntityId) => Record<string, unknown>;
@@ -1877,6 +1944,7 @@ declare interface SortableBlock {
1877
1944
  rank: string;
1878
1945
  stratum: Stratum;
1879
1946
  parentId: unknown;
1947
+ layerRank?: string;
1880
1948
  }
1881
1949
  export { SortableBlock }
1882
1950
  export { SortableBlock as SortableBlock_alias_1 }