dynim-vue 1.0.69 → 1.0.73
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/DynimProvider.d.ts +3 -17
- package/dist/DynimProvider.d.ts.map +1 -1
- package/dist/DynimProvider.js +151 -166
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/DynimProvider.d.ts
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DynimProvider -
|
|
2
|
+
* DynimProvider - Bundle renderer and shared context provider (Vue)
|
|
3
3
|
*
|
|
4
4
|
* Handles:
|
|
5
5
|
* - Loading tenant bundles
|
|
6
|
-
* -
|
|
6
|
+
* - Delegating builder operations to standalone script (window.dynim)
|
|
7
7
|
* - Shared context for bundles to access Vue, packages, etc.
|
|
8
8
|
*/
|
|
9
9
|
import { type InjectionKey, type PropType } from 'vue';
|
|
10
10
|
import * as Vue from 'vue';
|
|
11
|
-
import type { CodeMessage } from 'dynim-core';
|
|
12
11
|
export interface DynimConfig {
|
|
13
|
-
/** Function to fetch a session token for authentication */
|
|
14
|
-
getSession?: () => Promise<{
|
|
15
|
-
token: string;
|
|
16
|
-
refreshToken?: string;
|
|
17
|
-
}>;
|
|
18
12
|
/** Called when an error occurs */
|
|
19
13
|
onError?: (error: Event | Error) => void;
|
|
20
14
|
/** NPM packages to expose to bundles (e.g., { 'vue-router': VueRouter }) */
|
|
@@ -31,14 +25,6 @@ export interface DynimContextValue {
|
|
|
31
25
|
exitBuilder: () => void;
|
|
32
26
|
/** Whether builder/edit mode is active */
|
|
33
27
|
isEditing: boolean;
|
|
34
|
-
/** Send a code edit request to AI */
|
|
35
|
-
sendCode: (query: string) => Promise<void>;
|
|
36
|
-
/** Save current edits */
|
|
37
|
-
saveCode: () => Promise<void>;
|
|
38
|
-
/** Abandon/discard current edits */
|
|
39
|
-
abandonCode: () => Promise<void>;
|
|
40
|
-
/** Current code message state (thinking, edits, etc.) */
|
|
41
|
-
codeMessage: CodeMessage;
|
|
42
28
|
/** Whether a bundle is currently loaded */
|
|
43
29
|
isBundleLoaded: boolean;
|
|
44
30
|
/** Whether bundle is loading */
|
|
@@ -72,7 +58,7 @@ export declare const DynimProvider: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
|
72
58
|
[key: string]: any;
|
|
73
59
|
}> | Vue.VNode<Vue.RendererNode, Vue.RendererElement, {
|
|
74
60
|
[key: string]: any;
|
|
75
|
-
}>[] | undefined)[] |
|
|
61
|
+
}>[] | undefined)[] | undefined)[], {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {}, string, Vue.PublicProps, Readonly<Vue.ExtractPropTypes<{
|
|
76
62
|
config: {
|
|
77
63
|
type: PropType<DynimConfig>;
|
|
78
64
|
default: () => {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EASL,KAAK,YAAY,EACjB,KAAK,QAAQ,EAEd,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAgB3B,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC;IACzC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,qBAAqB;IACrB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,gCAAgC;IAChC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,iBAAiB,CAAmB,CAAC;AAElF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa;;cAIJ,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;cAArB,QAAQ,CAAC,WAAW,CAAC;;;;;kEA8VzC,CAAC;AAEH;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
|
package/dist/DynimProvider.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DynimProvider -
|
|
2
|
+
* DynimProvider - Bundle renderer and shared context provider (Vue)
|
|
3
3
|
*
|
|
4
4
|
* Handles:
|
|
5
5
|
* - Loading tenant bundles
|
|
6
|
-
* -
|
|
6
|
+
* - Delegating builder operations to standalone script (window.dynim)
|
|
7
7
|
* - Shared context for bundles to access Vue, packages, etc.
|
|
8
8
|
*/
|
|
9
|
-
import { defineComponent, ref,
|
|
9
|
+
import { defineComponent, ref, computed, provide, inject, onMounted, onUnmounted, h, } from 'vue';
|
|
10
10
|
import * as Vue from 'vue';
|
|
11
|
-
import {
|
|
11
|
+
import { createCodeClient, createBundleLoader, createCSSLoader, BundleNotFoundError, BundleAuthError, } from 'dynim-core';
|
|
12
12
|
import { createSharedContext, updateSharedContext, isSharedContextReady } from './inference/sharedContext';
|
|
13
13
|
import { generateThemeCSS } from './theme';
|
|
14
14
|
export const DynimInjectionKey = Symbol('dynim');
|
|
@@ -37,20 +37,14 @@ export const DynimProvider = defineComponent({
|
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
setup(props, { slots }) {
|
|
40
|
-
// Client refs
|
|
41
|
-
let builderClientRef = null;
|
|
42
|
-
let builderRef = null;
|
|
40
|
+
// Client refs
|
|
43
41
|
let codeClientRef = null;
|
|
44
42
|
let bundleLoaderRef = null;
|
|
45
|
-
|
|
46
|
-
let isExitingRef = false;
|
|
43
|
+
let cssLoaderRef = null;
|
|
47
44
|
let hasAttemptedInitialLoadRef = false;
|
|
48
|
-
let isBuilderActiveRef = false;
|
|
49
45
|
// Cached auth token
|
|
50
46
|
let cachedTokenRef = null;
|
|
51
47
|
let tokenPromiseRef = null;
|
|
52
|
-
// Bundle load signal
|
|
53
|
-
let pendingBundleProjectIdRef = null;
|
|
54
48
|
// Theme state ref
|
|
55
49
|
let hasAttemptedThemeLoadRef = false;
|
|
56
50
|
// Load bundle function ref
|
|
@@ -59,46 +53,48 @@ export const DynimProvider = defineComponent({
|
|
|
59
53
|
const isEditing = ref(false);
|
|
60
54
|
const isBundleLoaded = ref(false);
|
|
61
55
|
const isBundleLoading = ref(false);
|
|
62
|
-
const isInitialLoadComplete = ref(false);
|
|
63
56
|
const TenantApp = ref(null);
|
|
64
57
|
const bundleError = ref(null);
|
|
65
|
-
const bundleLoadSignal = ref(0);
|
|
66
58
|
const theme = ref(null);
|
|
67
|
-
const codeMessage = reactive({
|
|
68
|
-
thinking: '',
|
|
69
|
-
text: '',
|
|
70
|
-
status: 'idle',
|
|
71
|
-
bundleReady: false,
|
|
72
|
-
bundleError: undefined,
|
|
73
|
-
});
|
|
74
59
|
// Get config reference
|
|
75
60
|
const getConfig = () => props.config;
|
|
61
|
+
// Delegate session management to the standalone SDK (window.dynim)
|
|
62
|
+
const getSession = async () => {
|
|
63
|
+
const dynim = window.dynim;
|
|
64
|
+
if (dynim?.getSession) {
|
|
65
|
+
return dynim.getSession();
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
76
69
|
// Get auth token (cached after first call)
|
|
77
70
|
const getAuthToken = async () => {
|
|
78
|
-
const config = getConfig();
|
|
79
|
-
// Return cached token if available
|
|
80
71
|
if (cachedTokenRef)
|
|
81
72
|
return cachedTokenRef;
|
|
82
|
-
// Reuse in-flight promise if one exists
|
|
83
73
|
if (tokenPromiseRef)
|
|
84
74
|
return tokenPromiseRef;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
cachedTokenRef = session.token;
|
|
90
|
-
return session.token;
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
75
|
+
tokenPromiseRef = (async () => {
|
|
76
|
+
try {
|
|
77
|
+
const session = await getSession();
|
|
78
|
+
if (!session)
|
|
93
79
|
return null;
|
|
80
|
+
cachedTokenRef = session.token;
|
|
81
|
+
// Sync token to code-client
|
|
82
|
+
if (codeClientRef) {
|
|
83
|
+
codeClientRef.setSessionToken(session.token, session.refreshToken);
|
|
84
|
+
if (session.cssVersion !== undefined) {
|
|
85
|
+
codeClientRef.setCSSVersion(session.cssVersion ?? null);
|
|
86
|
+
}
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
return session.token;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
tokenPromiseRef = null;
|
|
95
|
+
}
|
|
96
|
+
})();
|
|
97
|
+
return tokenPromiseRef;
|
|
102
98
|
};
|
|
103
99
|
// Get bundle loader
|
|
104
100
|
const getBundleLoader = () => {
|
|
@@ -114,8 +110,24 @@ export const DynimProvider = defineComponent({
|
|
|
114
110
|
}
|
|
115
111
|
return bundleLoaderRef;
|
|
116
112
|
};
|
|
117
|
-
//
|
|
118
|
-
const
|
|
113
|
+
// Get CSS loader
|
|
114
|
+
const getCSSLoader = () => {
|
|
115
|
+
if (!cssLoaderRef) {
|
|
116
|
+
cssLoaderRef = createCSSLoader({
|
|
117
|
+
linkId: 'dynim-bundle-css',
|
|
118
|
+
onError: (error) => {
|
|
119
|
+
console.warn('[DynimProvider] CSS load failed:', error);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return cssLoaderRef;
|
|
124
|
+
};
|
|
125
|
+
// Build CSS URL
|
|
126
|
+
const buildCSSUrl = (temp = false) => {
|
|
127
|
+
return codeClientRef?.getCSSUrl(temp) ?? null;
|
|
128
|
+
};
|
|
129
|
+
// Load bundle (JS + CSS)
|
|
130
|
+
const loadBundle = async (bundleUrl, loadCSS = true) => {
|
|
119
131
|
const loader = getBundleLoader();
|
|
120
132
|
if (loader.isLoading())
|
|
121
133
|
return;
|
|
@@ -126,12 +138,22 @@ export const DynimProvider = defineComponent({
|
|
|
126
138
|
TenantApp.value = App;
|
|
127
139
|
isBundleLoaded.value = true;
|
|
128
140
|
cleanup();
|
|
141
|
+
if (loadCSS) {
|
|
142
|
+
const isTemp = bundleUrl.includes('temp=true');
|
|
143
|
+
const cssUrl = buildCSSUrl(isTemp);
|
|
144
|
+
if (cssUrl) {
|
|
145
|
+
getCSSLoader().load(cssUrl);
|
|
146
|
+
}
|
|
147
|
+
else if (!isTemp) {
|
|
148
|
+
getCSSLoader().unload();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
129
151
|
}
|
|
130
152
|
catch (error) {
|
|
131
|
-
// 404 = no bundle, 401 = not authenticated - show children
|
|
132
153
|
if (error instanceof BundleNotFoundError || error instanceof BundleAuthError) {
|
|
133
154
|
TenantApp.value = null;
|
|
134
155
|
isBundleLoaded.value = false;
|
|
156
|
+
getCSSLoader().unload();
|
|
135
157
|
return;
|
|
136
158
|
}
|
|
137
159
|
bundleError.value = error;
|
|
@@ -140,16 +162,10 @@ export const DynimProvider = defineComponent({
|
|
|
140
162
|
isBundleLoading.value = false;
|
|
141
163
|
}
|
|
142
164
|
};
|
|
143
|
-
// Load saved bundle
|
|
144
|
-
const loadSavedBundle = async () => {
|
|
145
|
-
await loadBundle('/api/code/bundle');
|
|
146
|
-
};
|
|
147
165
|
// Fetch theme
|
|
148
166
|
const fetchTheme = async () => {
|
|
149
167
|
if (hasAttemptedThemeLoadRef)
|
|
150
168
|
return;
|
|
151
|
-
if (!getConfig().getSession)
|
|
152
|
-
return;
|
|
153
169
|
hasAttemptedThemeLoadRef = true;
|
|
154
170
|
try {
|
|
155
171
|
const token = await getAuthToken();
|
|
@@ -167,53 +183,85 @@ export const DynimProvider = defineComponent({
|
|
|
167
183
|
}
|
|
168
184
|
}
|
|
169
185
|
catch (error) {
|
|
170
|
-
// Theme fetch failed - use defaults (non-critical)
|
|
171
186
|
console.warn('[DynimProvider] Failed to fetch theme:', error);
|
|
172
187
|
}
|
|
173
188
|
};
|
|
174
|
-
// Public methods
|
|
189
|
+
// Public methods — delegate to window.dynim (standalone script)
|
|
175
190
|
const enterBuilder = () => {
|
|
176
|
-
|
|
177
|
-
builderRef.enter();
|
|
178
|
-
// Fetch theme lazily when entering builder
|
|
179
|
-
fetchTheme();
|
|
180
|
-
}
|
|
191
|
+
window.dynim?.enterBuilder();
|
|
181
192
|
};
|
|
182
193
|
const exitBuilder = () => {
|
|
183
|
-
|
|
184
|
-
builderRef.exit();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
const sendCode = async (query) => {
|
|
188
|
-
await codeClientRef?.sendCode(query);
|
|
189
|
-
};
|
|
190
|
-
const saveCode = async () => {
|
|
191
|
-
await codeClientRef?.saveCode();
|
|
192
|
-
await loadSavedBundle();
|
|
193
|
-
};
|
|
194
|
-
const abandonCode = async () => {
|
|
195
|
-
await codeClientRef?.abandonCode();
|
|
196
|
-
await loadSavedBundle();
|
|
194
|
+
window.dynim?.exitBuilder();
|
|
197
195
|
};
|
|
198
196
|
// Context value (computed for reactivity)
|
|
199
197
|
const contextValue = computed(() => ({
|
|
200
198
|
enterBuilder,
|
|
201
199
|
exitBuilder,
|
|
202
200
|
isEditing: isEditing.value,
|
|
203
|
-
sendCode,
|
|
204
|
-
saveCode,
|
|
205
|
-
abandonCode,
|
|
206
|
-
codeMessage,
|
|
207
201
|
isBundleLoaded: isBundleLoaded.value,
|
|
208
202
|
isBundleLoading: isBundleLoading.value,
|
|
209
203
|
}));
|
|
210
204
|
// Theme CSS (computed)
|
|
211
205
|
const themeCSS = computed(() => generateThemeCSS(theme.value ?? undefined));
|
|
206
|
+
// DOM event handlers
|
|
207
|
+
const eventHandlers = [
|
|
208
|
+
['dynim:bundle-ready', () => {
|
|
209
|
+
const bundleUrl = `/api/code/bundle?temp=true&_t=${Date.now()}`;
|
|
210
|
+
loadBundleRef?.(bundleUrl, true);
|
|
211
|
+
}],
|
|
212
|
+
['dynim:bundle-saved', ((e) => {
|
|
213
|
+
const detail = e.detail;
|
|
214
|
+
if (detail?.cssVersion && codeClientRef) {
|
|
215
|
+
codeClientRef.setCSSVersion(detail.cssVersion);
|
|
216
|
+
}
|
|
217
|
+
loadBundleRef?.('/api/code/bundle', true);
|
|
218
|
+
})],
|
|
219
|
+
['dynim:bundle-abandoned', () => {
|
|
220
|
+
loadBundleRef?.('/api/code/bundle', true);
|
|
221
|
+
}],
|
|
222
|
+
['dynim:load-bundle', ((e) => {
|
|
223
|
+
const detail = e.detail;
|
|
224
|
+
if (detail?.bundleUrl) {
|
|
225
|
+
loadBundleRef?.(detail.bundleUrl);
|
|
226
|
+
}
|
|
227
|
+
})],
|
|
228
|
+
['dynim:enter', () => {
|
|
229
|
+
isEditing.value = true;
|
|
230
|
+
}],
|
|
231
|
+
['dynim:exit', () => {
|
|
232
|
+
isEditing.value = false;
|
|
233
|
+
}],
|
|
234
|
+
];
|
|
235
|
+
// Identified handler for syncing token to code client
|
|
236
|
+
const onIdentified = async () => {
|
|
237
|
+
const session = await getSession();
|
|
238
|
+
if (session && codeClientRef) {
|
|
239
|
+
codeClientRef.setSessionToken(session.token, session.refreshToken);
|
|
240
|
+
if (session.cssVersion !== undefined) {
|
|
241
|
+
codeClientRef.setCSSVersion(session.cssVersion ?? null);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
// Initial load handler
|
|
246
|
+
const onIdentifiedForLoad = () => {
|
|
247
|
+
doInitialLoad();
|
|
248
|
+
};
|
|
249
|
+
const doInitialLoad = async () => {
|
|
250
|
+
if (hasAttemptedInitialLoadRef)
|
|
251
|
+
return;
|
|
252
|
+
hasAttemptedInitialLoadRef = true;
|
|
253
|
+
try {
|
|
254
|
+
await loadBundleRef?.('/api/code/bundle');
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
console.log('[DynimProvider] Initial bundle load:', error.message);
|
|
258
|
+
}
|
|
259
|
+
setTimeout(() => fetchTheme(), 3000);
|
|
260
|
+
};
|
|
212
261
|
// Lifecycle: Setup on mount
|
|
213
262
|
onMounted(() => {
|
|
214
263
|
const config = getConfig();
|
|
215
264
|
const { packages = {}, hooks = {}, contexts = {} } = config;
|
|
216
|
-
// Keep loadBundleRef updated
|
|
217
265
|
loadBundleRef = loadBundle;
|
|
218
266
|
// Set up shared context for bundles
|
|
219
267
|
const sdkPackages = {
|
|
@@ -221,7 +269,6 @@ export const DynimProvider = defineComponent({
|
|
|
221
269
|
...packages,
|
|
222
270
|
};
|
|
223
271
|
if (!isSharedContextReady()) {
|
|
224
|
-
// Create fresh shared context
|
|
225
272
|
createSharedContext({
|
|
226
273
|
Vue,
|
|
227
274
|
packages: sdkPackages,
|
|
@@ -230,7 +277,6 @@ export const DynimProvider = defineComponent({
|
|
|
230
277
|
});
|
|
231
278
|
}
|
|
232
279
|
else {
|
|
233
|
-
// Update existing context with packages (handles HMR)
|
|
234
280
|
updateSharedContext({
|
|
235
281
|
packages: sdkPackages,
|
|
236
282
|
hooks,
|
|
@@ -239,113 +285,52 @@ export const DynimProvider = defineComponent({
|
|
|
239
285
|
}
|
|
240
286
|
// Initialize code client
|
|
241
287
|
codeClientRef = createCodeClient({
|
|
242
|
-
getSession:
|
|
243
|
-
|
|
244
|
-
|
|
288
|
+
getSession: async () => {
|
|
289
|
+
const session = await getSession();
|
|
290
|
+
if (!session)
|
|
291
|
+
throw new Error('Not authenticated');
|
|
292
|
+
return session;
|
|
245
293
|
},
|
|
246
294
|
onError: (error) => {
|
|
247
295
|
console.error('[DynimProvider] Code error:', error);
|
|
248
296
|
config.onError?.(error);
|
|
249
297
|
},
|
|
250
298
|
});
|
|
251
|
-
//
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
onExit: () => {
|
|
271
|
-
isEditing.value = false;
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
// Initialize builder client
|
|
275
|
-
builderClientRef = createBuilderClient({
|
|
276
|
-
getSession: config.getSession,
|
|
277
|
-
onError: (error) => {
|
|
278
|
-
console.error('[DynimProvider] Error:', error);
|
|
279
|
-
config.onError?.(error);
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
// Auto-load saved bundle on mount if auth is available
|
|
283
|
-
if (!hasAttemptedInitialLoadRef) {
|
|
284
|
-
hasAttemptedInitialLoadRef = true;
|
|
285
|
-
// No auth configured = skip bundle load
|
|
286
|
-
if (!config.getSession) {
|
|
287
|
-
isInitialLoadComplete.value = true;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
// Load bundle with the provided token
|
|
291
|
-
const doInitialLoad = async () => {
|
|
292
|
-
try {
|
|
293
|
-
await loadBundleRef?.('/api/code/bundle');
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
// Errors handled in loadBundle (404 = no bundle, etc.)
|
|
297
|
-
console.log('[DynimProvider] Initial bundle load:', error.message);
|
|
298
|
-
}
|
|
299
|
-
finally {
|
|
300
|
-
isInitialLoadComplete.value = true;
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
doInitialLoad();
|
|
304
|
-
// Prefetch theme after 3s delay (non-blocking, so it's ready when builder opens)
|
|
305
|
-
setTimeout(() => {
|
|
306
|
-
fetchTheme();
|
|
307
|
-
}, 3000);
|
|
308
|
-
}
|
|
299
|
+
// Listen to DOM events from standalone script
|
|
300
|
+
for (const [event, handler] of eventHandlers) {
|
|
301
|
+
window.addEventListener(event, handler);
|
|
302
|
+
}
|
|
303
|
+
window.addEventListener('dynim:identified', onIdentified);
|
|
304
|
+
// Auto-load saved bundle once standalone SDK has authenticated
|
|
305
|
+
const dynim = window.dynim;
|
|
306
|
+
if (dynim?.getSession) {
|
|
307
|
+
dynim.getSession().then((session) => {
|
|
308
|
+
if (session) {
|
|
309
|
+
doInitialLoad();
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
window.addEventListener('dynim:identified', onIdentifiedForLoad, { once: true });
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
window.addEventListener('dynim:identified', onIdentifiedForLoad, { once: true });
|
|
309
318
|
}
|
|
310
319
|
});
|
|
311
320
|
// Cleanup on unmount
|
|
312
321
|
onUnmounted(() => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
// Watch for bundleReady
|
|
316
|
-
watch(() => ({ bundleReady: codeMessage.bundleReady, projectId: codeMessage.projectId }), ({ bundleReady, projectId }) => {
|
|
317
|
-
if (bundleReady && projectId) {
|
|
318
|
-
if (isBuilderActiveRef && !isExitingRef) {
|
|
319
|
-
pendingBundleProjectIdRef = projectId;
|
|
320
|
-
bundleLoadSignal.value++;
|
|
321
|
-
}
|
|
322
|
+
for (const [event, handler] of eventHandlers) {
|
|
323
|
+
window.removeEventListener(event, handler);
|
|
322
324
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (signal === 0)
|
|
327
|
-
return;
|
|
328
|
-
const projectId = pendingBundleProjectIdRef;
|
|
329
|
-
if (!projectId || isExitingRef) {
|
|
330
|
-
pendingBundleProjectIdRef = null;
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const bundleUrl = `/api/code/bundle?temp=true&_t=${Date.now()}`;
|
|
334
|
-
loadBundleRef?.(bundleUrl);
|
|
335
|
-
pendingBundleProjectIdRef = null;
|
|
325
|
+
window.removeEventListener('dynim:identified', onIdentified);
|
|
326
|
+
window.removeEventListener('dynim:identified', onIdentifiedForLoad);
|
|
327
|
+
cssLoaderRef?.unload();
|
|
336
328
|
});
|
|
337
329
|
// Provide context
|
|
338
330
|
provide(DynimInjectionKey, contextValue.value);
|
|
339
|
-
// Watch for context value changes and update provided value
|
|
340
|
-
watch(contextValue, (newValue) => {
|
|
341
|
-
provide(DynimInjectionKey, newValue);
|
|
342
|
-
});
|
|
343
331
|
// Render function
|
|
344
332
|
return () => {
|
|
345
|
-
// Render content
|
|
346
333
|
const renderContent = () => {
|
|
347
|
-
if (!isInitialLoadComplete.value)
|
|
348
|
-
return null;
|
|
349
334
|
if (bundleError.value) {
|
|
350
335
|
return [
|
|
351
336
|
h('div', {
|
package/dist/index.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export { DynimProvider, useDynim, DynimInjectionKey } from './DynimProvider';
|
|
|
18
18
|
export type { DynimConfig, DynimContextValue } from './DynimProvider';
|
|
19
19
|
export { defaultTheme } from './theme';
|
|
20
20
|
export type { DynimTheme } from './theme';
|
|
21
|
-
export type { CodeMessage, CodeEdit
|
|
21
|
+
export type { CodeMessage, CodeEdit } from 'dynim-core';
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dynim-vue",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dev": "tsc --watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"dynim-core": "^1.0.
|
|
30
|
+
"dynim-core": "^1.0.98"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"vue": ">=3.3.0",
|