@templatical/core 0.51.1 → 0.52.1

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,7 +1,6 @@
1
1
  import { Block, BlockDefaults, BlockLock, BlockLockHolder, BlockType, CollaborationActor, CollaborationConflictCode, CollaborationConnectionState, CollaborationMember, CollaborationProvider, CollaborationRemoteChange, Comment, CommentAuthor, CommentInput, CommentPatch, CommentsListParams, CommentsProvider, CustomBlock, CustomBlockDefinition, MediaProvider, Operation, OperationError, SavedBlock, SavedBlockPatch, SavedBlocksListParams, SavedBlocksProvider, Template, TemplateContent, TemplateDefaults, TemplateSaveTrigger, TemplateSettings, TemplateVersion, TemplatesProvider, UiTheme, VersionHistoryListParams, VersionHistoryProvider, ViewportSize, invertOperations } from "@templatical/types";
2
2
  import { ComputedRef, DeepReadonly, Ref } from "@vue/reactivity";
3
3
  import { ComputedRef as ComputedRef$1, Ref as Ref$1 } from "vue";
4
- //#region src/editor.d.ts
5
4
  interface EditorState {
6
5
  /**
7
6
  * The template currently being edited, as the store last returned it — `null`
@@ -107,8 +106,6 @@ interface UseEditorReturn {
107
106
  hasTemplate: () => boolean;
108
107
  }
109
108
  export declare function useEditor(options: UseEditorOptions): UseEditorReturn;
110
- //#endregion
111
- //#region src/history.d.ts
112
109
  interface UseHistoryOptions {
113
110
  content: Ref<TemplateContent>;
114
111
  setContent: (content: TemplateContent, markDirty?: boolean) => void;
@@ -126,8 +123,6 @@ interface UseHistoryReturn {
126
123
  destroy: () => void;
127
124
  }
128
125
  export declare function useHistory(options: UseHistoryOptions): UseHistoryReturn;
129
- //#endregion
130
- //#region src/block-actions.d.ts
131
126
  interface UseBlockActionsOptions {
132
127
  addBlock: (block: Block, targetSectionId?: string, columnIndex?: number, index?: number) => void;
133
128
  removeBlock: (blockId: string) => void;
@@ -157,8 +152,6 @@ interface UseBlockActionsReturn {
157
152
  updateBlockProperty: <K extends keyof Block>(blockId: string, key: K, value: Block[K]) => void;
158
153
  }
159
154
  export declare function useBlockActions(options: UseBlockActionsOptions): UseBlockActionsReturn;
160
- //#endregion
161
- //#region src/auto-save.d.ts
162
155
  interface UseAutoSaveOptions {
163
156
  content: Ref<TemplateContent>;
164
157
  isDirty: () => boolean;
@@ -189,8 +182,6 @@ interface UseAutoSaveReturn {
189
182
  */
190
183
  export declare const DEFAULT_AUTO_SAVE_DEBOUNCE_MS = 2000;
191
184
  export declare function useAutoSave(options: UseAutoSaveOptions): UseAutoSaveReturn;
192
- //#endregion
193
- //#region src/condition-preview.d.ts
194
185
  interface UseConditionPreviewReturn {
195
186
  isHidden: (blockId: string) => boolean;
196
187
  toggleBlock: (blockId: string) => void;
@@ -209,8 +200,6 @@ interface ConditionPreviewEditor {
209
200
  selectBlock: (blockId: string | null) => void;
210
201
  }
211
202
  export declare function useConditionPreview(editor: ConditionPreviewEditor): UseConditionPreviewReturn;
212
- //#endregion
213
- //#region src/data-source-fetch.d.ts
214
203
  export declare function useDataSourceFetch(options: {
215
204
  definition: ComputedRef<CustomBlockDefinition | undefined>;
216
205
  block: ComputedRef<CustomBlock>;
@@ -222,8 +211,6 @@ export declare function useDataSourceFetch(options: {
222
211
  hasDataSource: ComputedRef<boolean>;
223
212
  needsFetch: ComputedRef<boolean>;
224
213
  };
225
- //#endregion
226
- //#region src/history-interceptor.d.ts
227
214
  /**
228
215
  * The mutable slice of an editor this wraps — structural, so the OSS and Cloud
229
216
  * `useEditor` returns both satisfy it without either having to grow toward the
@@ -245,8 +232,6 @@ interface HistoryInterceptorEditor {
245
232
  * changes by diffing the content and keeps its own undo history.
246
233
  */
247
234
  export declare function useHistoryInterceptor(editor: HistoryInterceptorEditor, history: UseHistoryReturn): void;
248
- //#endregion
249
- //#region src/diff-content.d.ts
250
235
  /**
251
236
  * The operations that turn `before` into `after`. Blocks are matched by id, so
252
237
  * a drag comes out as a `moveBlock` and a layout change as a `columns` change
@@ -269,8 +254,6 @@ export declare function useHistoryInterceptor(editor: HistoryInterceptorEditor,
269
254
  * doesn't conflict with it, and locks keep two people off one block.
270
255
  */
271
256
  export declare function diffContent(before: TemplateContent, after: TemplateContent): Operation[];
272
- //#endregion
273
- //#region src/collaboration.d.ts
274
257
  /** The template fields the controller reads, as the editor's readonly state holds them. */
275
258
  type CollaborationTemplate = DeepReadonly<Pick<Template, "id" | "revision" | "content">>;
276
259
  /** The slice of the editor the controller reads and writes. */
@@ -419,8 +402,6 @@ interface UseCollaborationReturn {
419
402
  * stacks.
420
403
  */
421
404
  export declare function useCollaboration(options: UseCollaborationOptions): UseCollaborationReturn;
422
- //#endregion
423
- //#region src/saved-blocks.d.ts
424
405
  interface UseSavedBlocksOptions {
425
406
  /**
426
407
  * Storage backend. Supplied by the consumer via `init({ savedBlocks })`, or
@@ -486,8 +467,6 @@ interface UseSavedBlocksReturn {
486
467
  * re-thrown, leaving the local list untouched on failure.
487
468
  */
488
469
  export declare function useSavedBlocks(options: UseSavedBlocksOptions): UseSavedBlocksReturn;
489
- //#endregion
490
- //#region src/saved-blocks-local.d.ts
491
470
  interface LocalStorageSavedBlocksOptions {
492
471
  /**
493
472
  * `localStorage` key holding the serialized array.
@@ -509,8 +488,6 @@ interface LocalStorageSavedBlocksOptions {
509
488
  * that needs to outlive a browser profile.
510
489
  */
511
490
  export declare function createLocalStorageSavedBlocksProvider(options?: LocalStorageSavedBlocksOptions): SavedBlocksProvider;
512
- //#endregion
513
- //#region src/media-local.d.ts
514
491
  interface LocalStorageMediaProviderOptions {
515
492
  /**
516
493
  * `localStorage` key holding the serialized array.
@@ -534,8 +511,6 @@ interface LocalStorageMediaProviderOptions {
534
511
  * this adapter is a flat list of assets.
535
512
  */
536
513
  export declare function createLocalStorageMediaProvider(options?: LocalStorageMediaProviderOptions): MediaProvider;
537
- //#endregion
538
- //#region src/version-history.d.ts
539
514
  interface UseVersionHistoryOptions {
540
515
  /**
541
516
  * Storage backend. Supplied by the consumer via `init({ versionHistory })`,
@@ -603,8 +578,6 @@ interface UseVersionHistoryReturn {
603
578
  * decides that, because they are the side that pays for the storage.
604
579
  */
605
580
  export declare function useVersionHistory(options: UseVersionHistoryOptions): UseVersionHistoryReturn;
606
- //#endregion
607
- //#region src/comments.d.ts
608
581
  interface UseCommentsOptions {
609
582
  /**
610
583
  * Storage backend. Supplied by the consumer via `init({ comments })`, or by
@@ -697,6 +670,5 @@ interface UseCommentListenerOptions {
697
670
  * one's comments.
698
671
  */
699
672
  export declare function useCommentListener(options: UseCommentListenerOptions): void;
700
- //#endregion
701
673
  export { type CollaborationApplyOptions, type CollaborationApplyResult, type CollaborationEditor, type CollaborationNotice, type CollaborationRemoteResync, type CollaborationTemplate, type EditorState, type LocalStorageMediaProviderOptions, type LocalStorageSavedBlocksOptions, type UseAutoSaveOptions, type UseAutoSaveReturn, type UseBlockActionsOptions, type UseBlockActionsReturn, type UseCollaborationOptions, type UseCollaborationReturn, type UseCommentListenerOptions, type UseCommentsOptions, type UseCommentsReturn, type UseConditionPreviewReturn, type UseEditorOptions, type UseEditorReturn, type UseHistoryOptions, type UseHistoryReturn, type UseSavedBlocksOptions, type UseSavedBlocksReturn, type UseVersionHistoryOptions, type UseVersionHistoryReturn, invertOperations };
702
674
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { OperationError, SdkError, applyOperations, applyOperationsInPlace, assertNoSlotInContent, assertNoWrapperInContent, cloneBlock, createBlock, createDefaultTemplateContent, deepEqual, generateId, getColumnCount, invertOperations, invertOperations as invertOperations$1, safeClone } from "@templatical/types";
2
2
  import { computed, getCurrentScope, onScopeDispose, reactive, readonly, ref, shallowRef, watch } from "@vue/reactivity";
3
3
  import { computed as computed$1, onScopeDispose as onScopeDispose$1, ref as ref$1, watch as watch$1 } from "vue";
4
- //#region src/error-reporting.ts
4
+ // src/error-reporting.ts
5
5
  /**
6
6
  * Turn a thrown value into an `Error`.
7
7
  *
@@ -30,8 +30,7 @@ function notifyHandler(onError, run) {
30
30
  onError?.(wrapReportedError(error));
31
31
  }
32
32
  }
33
- //#endregion
34
- //#region src/editor.ts
33
+ // src/editor.ts
35
34
  function useEditor(options) {
36
35
  const seedContent = options.content ?? createDefaultTemplateContent(options.defaultFontFamily, options.templateDefaults);
37
36
  assertNoSlotInContent(seedContent);
@@ -359,8 +358,7 @@ function useEditor(options) {
359
358
  hasTemplate
360
359
  };
361
360
  }
362
- //#endregion
363
- //#region src/history.ts
361
+ // src/history.ts
364
362
  const MAX_STACK_SIZE = 50;
365
363
  const DEBOUNCE_MS = 300;
366
364
  const NAVIGATE_IDLE_MS = 1500;
@@ -457,8 +455,7 @@ function useHistory(options) {
457
455
  destroy
458
456
  };
459
457
  }
460
- //#endregion
461
- //#region src/block-actions.ts
458
+ // src/block-actions.ts
462
459
  function useBlockActions(options) {
463
460
  const { addBlock, removeBlock, updateBlock, selectBlock, findBlockLocation } = options;
464
461
  function createAndAddBlock(type, targetSectionId, columnIndex) {
@@ -492,8 +489,7 @@ function useBlockActions(options) {
492
489
  updateBlockProperty
493
490
  };
494
491
  }
495
- //#endregion
496
- //#region src/auto-save.ts
492
+ // src/auto-save.ts
497
493
  /**
498
494
  * Trailing debounce, in ms, measured from the *last* content mutation.
499
495
  *
@@ -556,8 +552,7 @@ function useAutoSave(options) {
556
552
  destroy
557
553
  };
558
554
  }
559
- //#endregion
560
- //#region src/condition-preview.ts
555
+ // src/condition-preview.ts
561
556
  function useConditionPreview(editor) {
562
557
  const hiddenBlockIds = reactive(/* @__PURE__ */ new Set());
563
558
  const hasHiddenBlocks = computed(() => hiddenBlockIds.size > 0);
@@ -581,8 +576,7 @@ function useConditionPreview(editor) {
581
576
  hasHiddenBlocks
582
577
  };
583
578
  }
584
- //#endregion
585
- //#region src/data-source-fetch.ts
579
+ // src/data-source-fetch.ts
586
580
  function useDataSourceFetch(options) {
587
581
  const isFetching = ref(false);
588
582
  const fetchError = ref(false);
@@ -617,8 +611,7 @@ function useDataSourceFetch(options) {
617
611
  needsFetch
618
612
  };
619
613
  }
620
- //#endregion
621
- //#region src/history-interceptor.ts
614
+ // src/history-interceptor.ts
622
615
  /**
623
616
  * Wraps editor mutation methods to record history snapshots before each
624
617
  * operation. Mutates the editor object in place.
@@ -658,8 +651,7 @@ function useHistoryInterceptor(editor, history) {
658
651
  originalUpdateSettings(updates);
659
652
  };
660
653
  }
661
- //#endregion
662
- //#region src/diff-content.ts
654
+ // src/diff-content.ts
663
655
  const ROOT_KEY = "root";
664
656
  const BLOCK_SKIP = /* @__PURE__ */ new Set([
665
657
  "id",
@@ -1791,8 +1783,7 @@ function useCollaboration(options) {
1791
1783
  destroy
1792
1784
  };
1793
1785
  }
1794
- //#endregion
1795
- //#region src/saved-blocks.ts
1786
+ // src/saved-blocks.ts
1796
1787
  /**
1797
1788
  * Reactive state over a {@link SavedBlocksProvider}.
1798
1789
  *
@@ -1915,8 +1906,7 @@ function useSavedBlocks(options) {
1915
1906
  remove
1916
1907
  };
1917
1908
  }
1918
- //#endregion
1919
- //#region src/saved-blocks-local.ts
1909
+ // src/saved-blocks-local.ts
1920
1910
  const DEFAULT_KEY$1 = "templatical:saved-blocks";
1921
1911
  /**
1922
1912
  * Browser-local {@link SavedBlocksProvider} backed by `localStorage`.
@@ -1994,8 +1984,7 @@ function createLocalStorageSavedBlocksProvider(options = {}) {
1994
1984
  }
1995
1985
  };
1996
1986
  }
1997
- //#endregion
1998
- //#region src/media-local.ts
1987
+ // src/media-local.ts
1999
1988
  const DEFAULT_KEY = "templatical:media";
2000
1989
  const PAGE_SIZE = 50;
2001
1990
  /**
@@ -2113,8 +2102,7 @@ function createLocalStorageMediaProvider(options = {}) {
2113
2102
  storage: false
2114
2103
  };
2115
2104
  }
2116
- //#endregion
2117
- //#region src/version-history.ts
2105
+ // src/version-history.ts
2118
2106
  /**
2119
2107
  * Reactive state over a {@link VersionHistoryProvider}.
2120
2108
  *
@@ -2237,8 +2225,7 @@ function useVersionHistory(options) {
2237
2225
  restore
2238
2226
  };
2239
2227
  }
2240
- //#endregion
2241
- //#region src/comments.ts
2228
+ // src/comments.ts
2242
2229
  /**
2243
2230
  * Reactive state over a {@link CommentsProvider}.
2244
2231
  *
@@ -2538,7 +2525,6 @@ function useCommentListener(options) {
2538
2525
  }, { immediate: true });
2539
2526
  onScopeDispose$1(stop);
2540
2527
  }
2541
- //#endregion
2542
2528
  export { DEFAULT_AUTO_SAVE_DEBOUNCE_MS, createLocalStorageMediaProvider, createLocalStorageSavedBlocksProvider, diffContent, invertOperations, useAutoSave, useBlockActions, useCollaboration, useCommentListener, useComments, useConditionPreview, useDataSourceFetch, useEditor, useHistory, useHistoryInterceptor, useSavedBlocks, useVersionHistory };
2543
2529
 
2544
2530
  //# sourceMappingURL=index.js.map