@hy-bricks/canvas 0.1.1 → 0.3.0

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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentInstanceHandle } from '@hy-bricks/core';
1
2
  import { ComponentOptionsMixin } from 'vue';
2
3
  import { ComponentProvideOptions } from 'vue';
3
4
  import { ComputedRef } from 'vue';
@@ -484,6 +485,7 @@ export declare type CanvasBindingMode = 'off' | 'data-preview' | 'runtime';
484
485
  export declare type CanvasCommandId = 'undo' | 'redo' | 'deleteSelection' | 'duplicateSelection' | 'clearSelection' | 'cancelInteraction' | 'zoomIn' | 'zoomOut' | 'zoom100' | 'resetViewport' | 'fitToContent' | 'fitToSelection' | 'fitToSelectionOrContent' | 'nudgeSelection' | 'nudgeSelectionLarge' | 'lockSelection' | 'unlockSelection' | 'bringForward' | 'sendBackward' | 'bringToFront' | 'sendToBack' | 'toggleGrid' | 'toggleRuler' | (string & {});
485
486
 
486
487
  export declare interface CanvasContext {
488
+ readonly canvasId: string;
487
489
  document: DocumentStore;
488
490
  selection: SelectionStore;
489
491
  viewport: ViewportStore;
@@ -523,6 +525,7 @@ export declare interface CanvasContext {
523
525
  }
524
526
 
525
527
  export declare interface CanvasContextOptions {
528
+ canvasId?: string;
526
529
  initialDocument?: PageDocument;
527
530
  scheduler?: RenderSchedulerOptions;
528
531
  viewport?: ViewportStoreOptions;
@@ -777,11 +780,18 @@ export declare interface CanvasHandle {
777
780
  getBindingMode(): CanvasBindingMode;
778
781
  testBinding(bindingId: string, mockPayload?: unknown): BindingTestTrace[];
779
782
  on<E extends 'binding:fire' | 'binding:error' | 'binding:trace'>(event: E, cb: BindingEventCb<E>): () => void;
783
+ on<E extends 'instance:ready' | 'instance:unmounted'>(event: E, cb: (instanceId: string) => void): () => void;
784
+ getInstanceRuntime(instanceId: string): ComponentInstanceHandle | null;
785
+ getInstanceReady(instanceId: string): Promise<void>;
780
786
  startTracing(opts?: TraceCollectorOptions): void;
781
787
  stopTracing(): BindingTraceEvent[];
782
788
  getTraceBuffer(): readonly BindingTraceEvent[];
783
789
  invalidateDataSource(sourceId?: string): void;
784
790
  getDataSourceSnapshot(): DataSourceSnapshot;
791
+ getCachedBySourceId(sourceId: string, params?: Record<string, unknown>): {
792
+ value: unknown;
793
+ status: DataSourceStatus;
794
+ } | undefined;
785
795
  attachBindingDelegate(delegate: WirePageBindingsHandle | null, dataStore?: DataSourceStore | null): void;
786
796
  }
787
797
 
@@ -1142,6 +1152,10 @@ declare interface DataSourceStore {
1142
1152
  }): void;
1143
1153
  invalidate(sourceId?: string): void;
1144
1154
  getSnapshot(): DataSourceSnapshot;
1155
+ getCachedBySourceId(sourceId: string, params?: Record<string, unknown>): {
1156
+ value: unknown;
1157
+ status: DataSourceStatus;
1158
+ } | undefined;
1145
1159
  disposeAll(): void;
1146
1160
  readonly isDisposed: boolean;
1147
1161
  attachTraceBridge(cb: (ev: StoreTraceEvent) => void): () => void;
@@ -1160,6 +1174,22 @@ declare type DeclValueType = 'string' | 'number' | 'boolean' | 'object' | 'array
1160
1174
 
1161
1175
  export declare const DEFAULT_FIT_PADDING = 40;
1162
1176
 
1177
+ export declare function deriveComponentContract(source: DeriveComponentContractSource, opts?: DeriveComponentContractOptions): ComponentContract;
1178
+
1179
+ export declare interface DeriveComponentContractOptions {
1180
+ fallback?: ComponentContract;
1181
+ }
1182
+
1183
+ export declare interface DeriveComponentContractSource {
1184
+ html: string;
1185
+ js: string;
1186
+ css?: string;
1187
+ }
1188
+
1189
+ export declare function deriveComponentKind(source: DeriveComponentContractSource, opts?: {
1190
+ fallback?: ComponentKind;
1191
+ }): ComponentKind;
1192
+
1163
1193
  export declare const DIVIDER_HIT_THICKNESS = 8;
1164
1194
 
1165
1195
  export declare interface DocumentSource {
@@ -1253,6 +1283,8 @@ export declare interface EmitDecl {
1253
1283
  highFrequency?: boolean;
1254
1284
  }
1255
1285
 
1286
+ export declare function emptyComponentContract(): ComponentContract;
1287
+
1256
1288
  export declare function emptyPageDocument(): PageDocument;
1257
1289
 
1258
1290
  export declare function filterExistingIds(ids: readonly string[], instances: readonly PageInstance[]): string[];
@@ -1327,6 +1359,10 @@ export declare interface GridContainerLayout {
1327
1359
  }>;
1328
1360
  }
1329
1361
 
1362
+ export declare class HandleDisposedError extends Error {
1363
+ constructor(message?: string);
1364
+ }
1365
+
1330
1366
  export declare function hitTestInstance(canvasPt: Point, instances: readonly PageInstance[], domBoxLookup?: (instanceId: string) => Rect | null): string | null;
1331
1367
 
1332
1368
  export declare const HyperCardCanvasDesigner: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1336,11 +1372,27 @@ binding: ShallowRef<WirePageBindingsHandle | null, WirePageBindingsHandle | null
1336
1372
  data: {
1337
1373
  invalidateDataSource(sourceId?: string): void;
1338
1374
  getDataSourceSnapshot(): DataSourceSnapshot;
1375
+ getCachedBySourceId(sourceId: string, params?: Record<string, unknown>): {
1376
+ value: unknown;
1377
+ status: DataSourceStatus;
1378
+ } | undefined;
1339
1379
  } | null;
1340
1380
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
1341
1381
  rootEl: HTMLDivElement;
1342
1382
  }, any>;
1343
1383
 
1384
+ export declare interface HyperCardPageRendererExpose {
1385
+ data: {
1386
+ invalidateDataSource(sourceId?: string): void;
1387
+ getDataSourceSnapshot(): DataSourceSnapshot;
1388
+ getCachedBySourceId(sourceId: string, params?: Record<string, unknown>): {
1389
+ value: unknown;
1390
+ status: DataSourceStatus;
1391
+ } | undefined;
1392
+ } | null;
1393
+ binding: WirePageBindingsHandle | null;
1394
+ }
1395
+
1344
1396
  export declare interface InstanceDataInputMissingIssue extends BindingIssueBase {
1345
1397
  code: 'required-data-input-missing';
1346
1398
  instanceId: string;
@@ -1379,6 +1431,8 @@ export declare function isInstancePositionLocked(inst: LockedSubset): boolean;
1379
1431
 
1380
1432
  export declare function isInstanceSizeLocked(inst: LockedSubset): boolean;
1381
1433
 
1434
+ export declare function isResizeHandleAllowed(parentMode: ContainerLayoutConfig['mode'] | undefined, handle: ResizeHandle, widthMode: LayoutBoxAxisMode | undefined, heightMode: LayoutBoxAxisMode | undefined): boolean;
1435
+
1382
1436
  export declare function isV1Layout(layout: PageLayout | CanvasLayoutConfig | undefined): layout is CanvasLayoutConfig;
1383
1437
 
1384
1438
  export declare interface LayoutBox {
@@ -1469,6 +1523,8 @@ export declare interface MethodDecl {
1469
1523
  argsHint?: string;
1470
1524
  }
1471
1525
 
1526
+ export declare function migrateGridCellsToLayoutItem(doc: PageDocument): PageDocument;
1527
+
1472
1528
  export declare function migrateInstanceToLayoutBox(inst: PageInstance): PageInstance;
1473
1529
 
1474
1530
  export declare function migrateLayoutV0ToV1(raw: PageLayout | CanvasLayoutConfig | undefined): CanvasLayoutConfig;
@@ -1509,6 +1565,8 @@ export declare type NormalizedPageBinding = (PageBindingBase & {
1509
1565
  type: 'data';
1510
1566
  });
1511
1567
 
1568
+ export declare function normalizeGridCells0Based(cells: NonNullable<GridContainerLayout['cells']>): NonNullable<GridContainerLayout['cells']>;
1569
+
1512
1570
  export declare function normalizeInstanceSlotFields(inst: PageInstance): PageInstance;
1513
1571
 
1514
1572
  export declare function normalizeKeyString(s: string): string;
@@ -1713,7 +1771,7 @@ declare interface Rect_2 {
1713
1771
 
1714
1772
  export declare function registerDesignerHandle(canvasId: string, handle: CanvasHandle): void;
1715
1773
 
1716
- export declare function renderLayoutBoxStyle(layoutBox: LayoutBox, zIndex: number, rotation: number | undefined, parentLayoutMode: ContainerLayoutConfig['mode'] | undefined): Record<string, string | number>;
1774
+ export declare function renderLayoutBoxStyle(layoutBox: LayoutBox, zIndex: number, rotation: number | undefined, parentLayoutMode: ContainerLayoutConfig['mode'] | undefined, parentSplitDirection?: 'horizontal' | 'vertical'): Record<string, string | number>;
1717
1775
 
1718
1776
  export declare interface RenderScheduler {
1719
1777
  register(instanceId: string, el: Element): void;
@@ -1849,6 +1907,7 @@ export declare interface SplitDividerDragState {
1849
1907
  parentId: string | null;
1850
1908
  dividerIndex: number | null;
1851
1909
  startRatios: number[] | null;
1910
+ childIds: string[] | null;
1852
1911
  parentAxisPx: number;
1853
1912
  startPt: Point | null;
1854
1913
  direction: 'horizontal' | 'vertical' | null;
@@ -1862,6 +1921,7 @@ export declare interface SplitDividerInteraction {
1862
1921
  parentId: string;
1863
1922
  dividerIndex: number;
1864
1923
  startRatios: number[];
1924
+ childIds: string[];
1865
1925
  parentAxisPx: number;
1866
1926
  direction: 'horizontal' | 'vertical';
1867
1927
  gap: number;