@templatical/core 0.0.1 → 0.0.2
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/cloud/index.cjs +106 -24
- package/dist/cloud/index.cjs.map +1 -1
- package/dist/cloud/index.d.cts +17 -2
- package/dist/cloud/index.d.ts +17 -2
- package/dist/cloud/index.js +105 -24
- package/dist/cloud/index.js.map +1 -1
- package/dist/editor-K644r-hl.d.cts +39 -0
- package/dist/editor-K644r-hl.d.ts +39 -0
- package/dist/index.cjs +40 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -76
- package/dist/index.d.ts +13 -76
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/package.json +17 -7
package/dist/cloud/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(cloud_exports, {
|
|
|
43
43
|
useAiConfig: () => useAiConfig,
|
|
44
44
|
useAiRewrite: () => useAiRewrite,
|
|
45
45
|
useCollaboration: () => useCollaboration,
|
|
46
|
+
useCollaborationBroadcast: () => useCollaborationBroadcast,
|
|
46
47
|
useCommentListener: () => useCommentListener,
|
|
47
48
|
useComments: () => useComments,
|
|
48
49
|
useDesignReference: () => useDesignReference,
|
|
@@ -60,16 +61,22 @@ module.exports = __toCommonJS(cloud_exports);
|
|
|
60
61
|
|
|
61
62
|
// src/cloud/auth.ts
|
|
62
63
|
var import_types = require("@templatical/types");
|
|
63
|
-
var
|
|
64
|
+
var AuthManager = class _AuthManager {
|
|
65
|
+
static DEFAULT_BASE_URL = "https://templatical.com";
|
|
66
|
+
accessToken = null;
|
|
67
|
+
expiresAt = null;
|
|
68
|
+
_projectId = null;
|
|
69
|
+
_tenantId = null;
|
|
70
|
+
_tenantSlug = null;
|
|
71
|
+
_testEmailConfig = null;
|
|
72
|
+
_userConfig = null;
|
|
73
|
+
url;
|
|
74
|
+
baseUrl;
|
|
75
|
+
requestOptions;
|
|
76
|
+
onError;
|
|
77
|
+
refreshPromise = null;
|
|
78
|
+
static REFRESH_THRESHOLD_MS = 60 * 1e3;
|
|
64
79
|
constructor(config) {
|
|
65
|
-
this.accessToken = null;
|
|
66
|
-
this.expiresAt = null;
|
|
67
|
-
this._projectId = null;
|
|
68
|
-
this._tenantId = null;
|
|
69
|
-
this._tenantSlug = null;
|
|
70
|
-
this._testEmailConfig = null;
|
|
71
|
-
this._userConfig = null;
|
|
72
|
-
this.refreshPromise = null;
|
|
73
80
|
this.url = config.url;
|
|
74
81
|
this.baseUrl = (config.baseUrl ?? _AuthManager.DEFAULT_BASE_URL).replace(
|
|
75
82
|
/\/$/,
|
|
@@ -192,7 +199,7 @@ var _AuthManager = class _AuthManager {
|
|
|
192
199
|
}
|
|
193
200
|
return this.accessToken;
|
|
194
201
|
} catch (error) {
|
|
195
|
-
const wrappedError = error instanceof Error ? error : new Error("Token refresh failed");
|
|
202
|
+
const wrappedError = error instanceof Error ? error : new Error("Token refresh failed", { cause: error });
|
|
196
203
|
this.onError?.(wrappedError);
|
|
197
204
|
throw wrappedError;
|
|
198
205
|
}
|
|
@@ -217,9 +224,6 @@ var _AuthManager = class _AuthManager {
|
|
|
217
224
|
return response;
|
|
218
225
|
}
|
|
219
226
|
};
|
|
220
|
-
_AuthManager.DEFAULT_BASE_URL = "https://templatical.com";
|
|
221
|
-
_AuthManager.REFRESH_THRESHOLD_MS = 60 * 1e3;
|
|
222
|
-
var AuthManager = _AuthManager;
|
|
223
227
|
function createSdkAuthManager(config, onError) {
|
|
224
228
|
if (config.mode === "direct") {
|
|
225
229
|
const baseUrl = (config.baseUrl ?? "https://templatical.com").replace(
|
|
@@ -563,8 +567,11 @@ function resolveWebSocketConfig(serverConfig) {
|
|
|
563
567
|
};
|
|
564
568
|
}
|
|
565
569
|
var WebSocketClient = class {
|
|
570
|
+
pusher = null;
|
|
571
|
+
authManager;
|
|
572
|
+
config;
|
|
573
|
+
onError;
|
|
566
574
|
constructor(options) {
|
|
567
|
-
this.pusher = null;
|
|
568
575
|
this.authManager = options.authManager;
|
|
569
576
|
this.config = options.config;
|
|
570
577
|
this.onError = options.onError;
|
|
@@ -699,7 +706,8 @@ function useEditor(options) {
|
|
|
699
706
|
previewMode: false,
|
|
700
707
|
isDirty: false,
|
|
701
708
|
isSaving: false,
|
|
702
|
-
isLoading: false
|
|
709
|
+
isLoading: false,
|
|
710
|
+
uiTheme: "auto"
|
|
703
711
|
});
|
|
704
712
|
const content = (0, import_vue.computed)({
|
|
705
713
|
get: () => state.content,
|
|
@@ -780,6 +788,9 @@ function useEditor(options) {
|
|
|
780
788
|
function setDarkMode(darkMode) {
|
|
781
789
|
state.darkMode = darkMode;
|
|
782
790
|
}
|
|
791
|
+
function setUiTheme(theme) {
|
|
792
|
+
state.uiTheme = theme;
|
|
793
|
+
}
|
|
783
794
|
function setPreviewMode(previewMode) {
|
|
784
795
|
state.previewMode = previewMode;
|
|
785
796
|
if (previewMode) {
|
|
@@ -935,6 +946,7 @@ function useEditor(options) {
|
|
|
935
946
|
selectBlock,
|
|
936
947
|
setViewport,
|
|
937
948
|
setDarkMode,
|
|
949
|
+
setUiTheme,
|
|
938
950
|
setPreviewMode,
|
|
939
951
|
updateBlock,
|
|
940
952
|
updateSettings,
|
|
@@ -1197,7 +1209,7 @@ function useAiChat(options) {
|
|
|
1197
1209
|
}
|
|
1198
1210
|
return result;
|
|
1199
1211
|
} catch (err) {
|
|
1200
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to generate template");
|
|
1212
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to generate template", { cause: err });
|
|
1201
1213
|
error.value = wrappedError.message;
|
|
1202
1214
|
failedPrompt.value = prompt;
|
|
1203
1215
|
onError?.(wrappedError);
|
|
@@ -1693,7 +1705,9 @@ function useDesignReference(options) {
|
|
|
1693
1705
|
}
|
|
1694
1706
|
return result;
|
|
1695
1707
|
} catch (err) {
|
|
1696
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to generate template from design"
|
|
1708
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to generate template from design", {
|
|
1709
|
+
cause: err
|
|
1710
|
+
});
|
|
1697
1711
|
error.value = wrappedError.message;
|
|
1698
1712
|
onError?.(wrappedError);
|
|
1699
1713
|
return null;
|
|
@@ -1797,7 +1811,7 @@ function useComments(options) {
|
|
|
1797
1811
|
try {
|
|
1798
1812
|
comments.value = await api.getComments(templateId);
|
|
1799
1813
|
} catch (err) {
|
|
1800
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to load comments");
|
|
1814
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to load comments", { cause: err });
|
|
1801
1815
|
onError?.(wrappedError);
|
|
1802
1816
|
} finally {
|
|
1803
1817
|
isLoading.value = false;
|
|
@@ -1831,7 +1845,7 @@ function useComments(options) {
|
|
|
1831
1845
|
emitEvent("created", comment);
|
|
1832
1846
|
return comment;
|
|
1833
1847
|
} catch (err) {
|
|
1834
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to create comment");
|
|
1848
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to create comment", { cause: err });
|
|
1835
1849
|
onError?.(wrappedError);
|
|
1836
1850
|
return null;
|
|
1837
1851
|
} finally {
|
|
@@ -1858,7 +1872,7 @@ function useComments(options) {
|
|
|
1858
1872
|
emitEvent("updated", updated);
|
|
1859
1873
|
return updated;
|
|
1860
1874
|
} catch (err) {
|
|
1861
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to update comment");
|
|
1875
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to update comment", { cause: err });
|
|
1862
1876
|
onError?.(wrappedError);
|
|
1863
1877
|
return null;
|
|
1864
1878
|
} finally {
|
|
@@ -1899,7 +1913,7 @@ function useComments(options) {
|
|
|
1899
1913
|
emitEvent("deleted", commentSnapshot);
|
|
1900
1914
|
return true;
|
|
1901
1915
|
} catch (err) {
|
|
1902
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to delete comment");
|
|
1916
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to delete comment", { cause: err });
|
|
1903
1917
|
onError?.(wrappedError);
|
|
1904
1918
|
return false;
|
|
1905
1919
|
} finally {
|
|
@@ -1924,7 +1938,7 @@ function useComments(options) {
|
|
|
1924
1938
|
emitEvent(eventType, updated);
|
|
1925
1939
|
return updated;
|
|
1926
1940
|
} catch (err) {
|
|
1927
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to toggle comment resolution");
|
|
1941
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to toggle comment resolution", { cause: err });
|
|
1928
1942
|
onError?.(wrappedError);
|
|
1929
1943
|
return null;
|
|
1930
1944
|
} finally {
|
|
@@ -2257,6 +2271,73 @@ function useCollaboration(options) {
|
|
|
2257
2271
|
};
|
|
2258
2272
|
}
|
|
2259
2273
|
|
|
2274
|
+
// src/cloud/collaboration-broadcast.ts
|
|
2275
|
+
function useCollaborationBroadcast(editor, collaboration) {
|
|
2276
|
+
const originalAddBlock = editor.addBlock;
|
|
2277
|
+
const originalUpdateBlock = editor.updateBlock;
|
|
2278
|
+
const originalRemoveBlock = editor.removeBlock;
|
|
2279
|
+
const originalMoveBlock = editor.moveBlock;
|
|
2280
|
+
const originalUpdateSettings = editor.updateSettings;
|
|
2281
|
+
const originalSetContent = editor.setContent;
|
|
2282
|
+
editor.addBlock = (block, targetSectionId, columnIndex) => {
|
|
2283
|
+
originalAddBlock(block, targetSectionId, columnIndex);
|
|
2284
|
+
collaboration._broadcastOperation({
|
|
2285
|
+
operation: "add_block",
|
|
2286
|
+
data: {
|
|
2287
|
+
block,
|
|
2288
|
+
section_id: targetSectionId,
|
|
2289
|
+
column_index: columnIndex
|
|
2290
|
+
},
|
|
2291
|
+
timestamp: Date.now()
|
|
2292
|
+
});
|
|
2293
|
+
};
|
|
2294
|
+
editor.updateBlock = (blockId, updates) => {
|
|
2295
|
+
originalUpdateBlock(blockId, updates);
|
|
2296
|
+
collaboration._broadcastOperation({
|
|
2297
|
+
operation: "update_block",
|
|
2298
|
+
data: { block_id: blockId, updates },
|
|
2299
|
+
timestamp: Date.now()
|
|
2300
|
+
});
|
|
2301
|
+
};
|
|
2302
|
+
editor.removeBlock = (blockId) => {
|
|
2303
|
+
originalRemoveBlock(blockId);
|
|
2304
|
+
collaboration._broadcastOperation({
|
|
2305
|
+
operation: "delete_block",
|
|
2306
|
+
data: { block_id: blockId },
|
|
2307
|
+
timestamp: Date.now()
|
|
2308
|
+
});
|
|
2309
|
+
};
|
|
2310
|
+
editor.moveBlock = (blockId, newIndex, targetSectionId, columnIndex) => {
|
|
2311
|
+
originalMoveBlock(blockId, newIndex, targetSectionId, columnIndex);
|
|
2312
|
+
collaboration._broadcastOperation({
|
|
2313
|
+
operation: "move_block",
|
|
2314
|
+
data: {
|
|
2315
|
+
block_id: blockId,
|
|
2316
|
+
index: newIndex,
|
|
2317
|
+
section_id: targetSectionId,
|
|
2318
|
+
column_index: columnIndex
|
|
2319
|
+
},
|
|
2320
|
+
timestamp: Date.now()
|
|
2321
|
+
});
|
|
2322
|
+
};
|
|
2323
|
+
editor.updateSettings = (updates) => {
|
|
2324
|
+
originalUpdateSettings(updates);
|
|
2325
|
+
collaboration._broadcastOperation({
|
|
2326
|
+
operation: "update_settings",
|
|
2327
|
+
data: { updates },
|
|
2328
|
+
timestamp: Date.now()
|
|
2329
|
+
});
|
|
2330
|
+
};
|
|
2331
|
+
editor.setContent = (content, markDirty) => {
|
|
2332
|
+
originalSetContent(content, markDirty);
|
|
2333
|
+
collaboration._broadcastOperation({
|
|
2334
|
+
operation: "set_content",
|
|
2335
|
+
data: { content },
|
|
2336
|
+
timestamp: Date.now()
|
|
2337
|
+
});
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2260
2341
|
// src/cloud/web-socket.ts
|
|
2261
2342
|
var import_vue10 = require("vue");
|
|
2262
2343
|
function useWebSocket(options) {
|
|
@@ -2466,7 +2547,7 @@ function useTestEmail(options) {
|
|
|
2466
2547
|
signature: testEmailConfig.value.signature
|
|
2467
2548
|
});
|
|
2468
2549
|
} catch (err) {
|
|
2469
|
-
const wrappedError = err instanceof Error ? err : new Error("Failed to send test email");
|
|
2550
|
+
const wrappedError = err instanceof Error ? err : new Error("Failed to send test email", { cause: err });
|
|
2470
2551
|
error.value = wrappedError.message;
|
|
2471
2552
|
onError?.(wrappedError);
|
|
2472
2553
|
throw wrappedError;
|
|
@@ -2534,7 +2615,7 @@ function usePlanConfig(options) {
|
|
|
2534
2615
|
config.value = await apiClient.fetchConfig();
|
|
2535
2616
|
} catch (error) {
|
|
2536
2617
|
onError?.(
|
|
2537
|
-
error instanceof Error ? error : new Error("Failed to fetch config")
|
|
2618
|
+
error instanceof Error ? error : new Error("Failed to fetch config", { cause: error })
|
|
2538
2619
|
);
|
|
2539
2620
|
} finally {
|
|
2540
2621
|
isLoading.value = false;
|
|
@@ -2676,6 +2757,7 @@ function useMcpListener(options) {
|
|
|
2676
2757
|
useAiConfig,
|
|
2677
2758
|
useAiRewrite,
|
|
2678
2759
|
useCollaboration,
|
|
2760
|
+
useCollaborationBroadcast,
|
|
2679
2761
|
useCommentListener,
|
|
2680
2762
|
useComments,
|
|
2681
2763
|
useDesignReference,
|