@templatical/core 0.48.0 → 0.50.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/README.md CHANGED
@@ -45,6 +45,8 @@ watch(editor.content, (next) => {
45
45
 
46
46
  - `useEditor` — reactive state (content, selection, viewport, darkMode, isDirty) + mutation methods (`addBlock`, `removeBlock`, `moveBlock`, `updateBlock`, `updateSettings`, `selectBlock`, …)
47
47
  - `useHistory` — undo/redo stack
48
+ - `useCollaboration` — the real-time collaboration controller over a `CollaborationProvider`: ordered operation batches, block locks, presence, and undo/redo as inverse operations
49
+ - `diffContent` / `invertOperations` — the operations between two contents, and the guarded operations that undo a batch
48
50
  - `useHistoryInterceptor` — wraps mutation methods so they push onto the history stack automatically
49
51
  - `useBlockActions` — higher-level helpers built on top of `useEditor` (`createAndAddBlock(type)`, `duplicateBlock`, `deleteBlock`, `updateBlockProperty`)
50
52
  - `useAutoSave` — debounced save with onSave callback
@@ -55,7 +57,7 @@ watch(editor.content, (next) => {
55
57
 
56
58
  ## Cloud subpath
57
59
 
58
- The `@templatical/core/cloud` subpath provides Templatical Cloud integrations (Auth, API client, WebSocket, AI chat/rewrite, collaboration, comments, scoring, and `createCloudSavedBlocksProvider`). Used by `@templatical/editor`'s `initCloud()`.
60
+ The `@templatical/core/cloud` subpath provides Templatical Cloud integrations (Auth, API client, WebSocket, comments, and `createCloudSavedBlocksProvider`). Used by `@templatical/editor`'s `initCloud()`.
59
61
 
60
62
  ## Documentation
61
63
 
@@ -1,6 +1,5 @@
1
- import { r as UseEditorReturn } from "../editor-Bl4WsPU3.js";
2
- import { AiChatMessage, AiConfig, AuthConfig, AuthRequestOptions, Block, Collaborator, CommentResponse, CommentsProvider, CustomFont, ExportResult, FontsConfig, HealthCheckResult, MediaProvider, MergeTag, PlanConfig, PlanFeatures, RenderProvider, SavedBlock, SavedBlocksProvider, ScoringCategory, ScoringFinding, ScoringResult, SdkAuthConfig, Template, TemplateContent, TemplateOperationPayload, TemplatePatch, TemplateVersionResponse, TemplatesProvider, TestEmailConfig, TestEmailProvider, UserConfig, VersionHistoryProvider, WebSocketServerConfig } from "@templatical/types";
3
- import { ComputedRef, Ref, ref } from "vue";
1
+ import { AuthConfig, AuthRequestOptions, Block, CommentResponse, CommentsProvider, CustomFont, ExportResult, FontsConfig, HealthCheckResult, MediaProvider, PlanConfig, PlanFeatures, RenderProvider, SavedBlock, SavedBlocksProvider, SdkAuthConfig, Template, TemplateContent, TemplatePatch, TemplateVersionResponse, TemplatesProvider, TestEmailConfig, TestEmailProvider, UserConfig, VersionHistoryProvider, WebSocketServerConfig } from "@templatical/types";
2
+ import { ComputedRef, Ref } from "vue";
4
3
  import { Channel, PresenceChannel } from "pusher-js";
5
4
  //#region src/cloud/auth.d.ts
6
5
  /**
@@ -234,13 +233,6 @@ export declare const API_ROUTES: {
234
233
  readonly "comments.update": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/comments/{comment}";
235
234
  readonly "comments.destroy": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/comments/{comment}";
236
235
  readonly "comments.resolve": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/comments/{comment}/resolve";
237
- readonly "ai.generate": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/generate";
238
- readonly "ai.conversationMessages": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/conversation-messages";
239
- readonly "ai.suggestions": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/suggestions";
240
- readonly "ai.rewriteText": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/rewrite-text";
241
- readonly "ai.score": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/score";
242
- readonly "ai.fixFinding": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/fix-finding";
243
- readonly "ai.generateFromDesign": "/api/v1/projects/{project}/tenants/{tenant}/templates/{template}/ai/generate-from-design";
244
236
  readonly "media.upload": "/api/v1/projects/{project}/tenants/{tenant}/media/upload";
245
237
  readonly "media.browse": "/api/v1/projects/{project}/tenants/{tenant}/media/browse";
246
238
  readonly "media.delete": "/api/v1/projects/{project}/tenants/{tenant}/media/delete";
@@ -292,99 +284,6 @@ export declare class WebSocketClient {
292
284
  get isConnected(): boolean;
293
285
  }
294
286
  //#endregion
295
- //#region src/cloud/mcp-operation-handler.d.ts
296
- export declare function handleOperation(editor: UseEditorReturn, payload: TemplateOperationPayload): void;
297
- //#endregion
298
- //#region src/cloud/ai-chat.d.ts
299
- interface UseAiChatOptions {
300
- authManager: AuthManager;
301
- getTemplateId: () => string | null;
302
- onApply?: (content: TemplateContent) => void;
303
- onError?: (error: Error) => void;
304
- }
305
- interface UseAiChatReturn {
306
- messages: ReturnType<typeof ref<AiChatMessage[]>>;
307
- isGenerating: ReturnType<typeof ref<boolean>>;
308
- isLoadingHistory: ReturnType<typeof ref<boolean>>;
309
- isLastChangeReverted: ReturnType<typeof ref<boolean>>;
310
- lastApplyMessageId: ReturnType<typeof ref<string | null>>;
311
- error: ReturnType<typeof ref<string | null>>;
312
- failedPrompt: ReturnType<typeof ref<string | null>>;
313
- suggestions: ReturnType<typeof ref<string[]>>;
314
- isLoadingSuggestions: ReturnType<typeof ref<boolean>>;
315
- sendPrompt: (prompt: string, currentContent: TemplateContent, mergeTags: MergeTag[]) => Promise<TemplateContent | null>;
316
- toggleLastRevert: () => void;
317
- loadConversation: () => Promise<void>;
318
- loadSuggestions: (currentContent: TemplateContent, mergeTags: MergeTag[]) => Promise<void>;
319
- clearChat: () => void;
320
- }
321
- export declare function useAiChat(options: UseAiChatOptions): UseAiChatReturn;
322
- //#endregion
323
- //#region src/cloud/ai-rewrite.d.ts
324
- interface UseAiRewriteOptions {
325
- authManager: AuthManager;
326
- getTemplateId: () => string | null;
327
- }
328
- interface UseAiRewriteReturn {
329
- isRewriting: ReturnType<typeof ref<boolean>>;
330
- streamingText: ReturnType<typeof ref<string>>;
331
- previousContent: ReturnType<typeof ref<string | null>>;
332
- rewrittenContent: ReturnType<typeof ref<string | null>>;
333
- isReverted: ReturnType<typeof ref<boolean>>;
334
- error: ReturnType<typeof ref<string | null>>;
335
- rewrite: (content: string, instruction: string, mergeTags: MergeTag[]) => Promise<string | null>;
336
- undo: () => string | null;
337
- redo: () => string | null;
338
- reset: () => void;
339
- }
340
- export declare function useAiRewrite(options: UseAiRewriteOptions): UseAiRewriteReturn;
341
- //#endregion
342
- //#region src/cloud/ai-config.d.ts
343
- interface UseAiConfigReturn {
344
- isFeatureEnabled: (feature: keyof AiConfig) => boolean;
345
- hasAnyMenuFeature: ComputedRef<boolean>;
346
- }
347
- export declare function useAiConfig(config?: AiConfig | false): UseAiConfigReturn;
348
- //#endregion
349
- //#region src/cloud/template-scoring.d.ts
350
- interface UseTemplateScoringOptions {
351
- authManager: AuthManager;
352
- getTemplateId: () => string | null;
353
- }
354
- interface UseTemplateScoringReturn {
355
- isScoring: ReturnType<typeof ref<boolean>>;
356
- scoringResult: ReturnType<typeof ref<ScoringResult | null>>;
357
- error: ReturnType<typeof ref<string | null>>;
358
- fixingFindingId: ReturnType<typeof ref<string | null>>;
359
- fixStreamingText: ReturnType<typeof ref<string>>;
360
- fixError: ReturnType<typeof ref<string | null>>;
361
- score: (content: TemplateContent, mergeTags: MergeTag[]) => Promise<ScoringResult | null>;
362
- fixFinding: (blockContent: string, finding: ScoringFinding, mergeTags: MergeTag[]) => Promise<string | null>;
363
- removeFinding: (category: ScoringCategory, findingId: string) => void;
364
- reset: () => void;
365
- }
366
- export declare function useTemplateScoring(options: UseTemplateScoringOptions): UseTemplateScoringReturn;
367
- //#endregion
368
- //#region src/cloud/design-reference.d.ts
369
- interface UseDesignReferenceOptions {
370
- authManager: AuthManager;
371
- getTemplateId: () => string | null;
372
- onApply?: (content: TemplateContent) => void;
373
- onError?: (error: Error) => void;
374
- }
375
- interface UseDesignReferenceReturn {
376
- isGenerating: ReturnType<typeof ref<boolean>>;
377
- error: ReturnType<typeof ref<string | null>>;
378
- generate: (input: DesignReferenceInput) => Promise<TemplateContent | null>;
379
- reset: () => void;
380
- }
381
- interface DesignReferenceInput {
382
- prompt?: string;
383
- imageUpload?: File;
384
- pdfUpload?: File;
385
- }
386
- export declare function useDesignReference(options: UseDesignReferenceOptions): UseDesignReferenceReturn;
387
- //#endregion
388
287
  //#region src/cloud/comments-provider.d.ts
389
288
  /**
390
289
  * The two methods this adapter needs from a Pusher channel, named structurally.
@@ -439,45 +338,6 @@ interface CreateCloudCommentsProviderOptions {
439
338
  */
440
339
  export declare function createCloudCommentsProvider(options: CreateCloudCommentsProviderOptions): CommentsProvider;
441
340
  //#endregion
442
- //#region src/cloud/collaboration.d.ts
443
- interface UseCollaborationOptions {
444
- authManager: AuthManager;
445
- editor: UseEditorReturn;
446
- channel: Ref<PresenceChannel | null>;
447
- onError?: (error: Error) => void;
448
- onCollaboratorJoined?: (collaborator: Collaborator) => void;
449
- onCollaboratorLeft?: (collaborator: Collaborator) => void;
450
- onBlockLocked?: (event: {
451
- blockId: string;
452
- collaborator: Collaborator;
453
- }) => void;
454
- onBlockUnlocked?: (event: {
455
- blockId: string;
456
- collaborator: Collaborator;
457
- }) => void;
458
- }
459
- interface UseCollaborationReturn {
460
- collaborators: Ref<Collaborator[]>;
461
- lockedBlocks: Ref<Map<string, Collaborator>>;
462
- }
463
- export declare function useCollaboration(options: UseCollaborationOptions): UseCollaborationReturn & {
464
- _broadcastOperation: (payload: TemplateOperationPayload) => void;
465
- _isProcessingRemoteOperation: () => boolean;
466
- };
467
- //#endregion
468
- //#region src/cloud/collaboration-broadcast.d.ts
469
- interface BroadcastTarget {
470
- _broadcastOperation: (payload: TemplateOperationPayload) => void;
471
- }
472
- /**
473
- * Wraps editor mutation methods to broadcast operations to collaboration
474
- * peers after each mutation executes. Mutates the editor object in place.
475
- *
476
- * Must be applied **before** the history interceptor so the call chain is:
477
- * history.record() → broadcast + original mutation.
478
- */
479
- export declare function useCollaborationBroadcast(editor: Pick<UseEditorReturn, "addBlock" | "updateBlock" | "removeBlock" | "moveBlock" | "updateSettings" | "setContent">, collaboration: BroadcastTarget): void;
480
- //#endregion
481
341
  //#region src/cloud/web-socket.d.ts
482
342
  interface UseWebSocketOptions {
483
343
  authManager: AuthManager;
@@ -733,13 +593,5 @@ interface HealthCheckOptions {
733
593
  }
734
594
  export declare function performHealthCheck(options?: HealthCheckOptions): Promise<HealthCheckResult>;
735
595
  //#endregion
736
- //#region src/cloud/mcp-listener.d.ts
737
- interface UseMcpListenerOptions {
738
- editor: UseEditorReturn;
739
- channel: Ref<PresenceChannel | null>;
740
- onOperation?: (payload: TemplateOperationPayload) => void;
741
- }
742
- export declare function useMcpListener(options: UseMcpListenerOptions): void;
743
- //#endregion
744
- export type { AuthConfig, AuthRequestOptions, CloudMediaBrowseParams, CloudMediaBrowseResponse, CloudMediaFolder, CloudMediaItem, CloudMediaUsageInfo, CloudMediaUsageResponse, CreateCloudCommentsProviderOptions, CreateCloudRenderProviderOptions, CreateCloudTestEmailProviderOptions, DesignReferenceInput, ExportFontsPayload, PresenceMember, RealtimeChannel, SdkAuthConfig, TestEmailConfig, UseAiChatOptions, UseAiChatReturn, UseAiConfigReturn, UseAiRewriteOptions, UseAiRewriteReturn, UseCollaborationOptions, UseCollaborationReturn, UseDesignReferenceOptions, UseDesignReferenceReturn, UseExportOptions, UseExportReturn, UseMcpListenerOptions, UsePlanConfigOptions, UsePlanConfigReturn, UseTemplateScoringOptions, UseTemplateScoringReturn, UseTestEmailOptions, UseTestEmailReturn, UseWebSocketOptions, UseWebSocketReturn, UserConfig, WebSocketClientOptions, WebSocketConfig };
596
+ export type { AuthConfig, AuthRequestOptions, CloudMediaBrowseParams, CloudMediaBrowseResponse, CloudMediaFolder, CloudMediaItem, CloudMediaUsageInfo, CloudMediaUsageResponse, CreateCloudCommentsProviderOptions, CreateCloudRenderProviderOptions, CreateCloudTestEmailProviderOptions, ExportFontsPayload, PresenceMember, RealtimeChannel, SdkAuthConfig, TestEmailConfig, UseExportOptions, UseExportReturn, UsePlanConfigOptions, UsePlanConfigReturn, UseTestEmailOptions, UseTestEmailReturn, UseWebSocketOptions, UseWebSocketReturn, UserConfig, WebSocketClientOptions, WebSocketConfig };
745
597
  //# sourceMappingURL=index.d.ts.map