@kennofizet/apphub-frontend 0.1.5 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kennofizet/apphub-frontend",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "App Hub Vue 3 UI — Windows-style desktop shell and modular apps (App Store default).",
5
5
  "main": "./src/index.js",
6
6
  "module": "./src/index.js",
package/src/index.js CHANGED
@@ -243,6 +243,9 @@ function createApiFacade() {
243
243
  setImpl(next) {
244
244
  impl = next
245
245
  },
246
+ hasImpl() {
247
+ return impl != null
248
+ },
246
249
  bootstrap: (...args) => impl?.bootstrap?.(...args),
247
250
  apps: (...args) => impl?.apps?.(...args),
248
251
  launch: (...args) => impl?.launch?.(...args),
@@ -263,7 +266,19 @@ function createApiFacade() {
263
266
  }
264
267
  }
265
268
 
269
+ function credentialsUnchanged(prev, next) {
270
+ return prev.backendUrl === next.backendUrl
271
+ && prev.token === next.token
272
+ && prev.coreUrl === next.coreUrl
273
+ && prev.hostAccessSecret === next.hostAccessSecret
274
+ }
275
+
266
276
  function applyModuleOptions(store, options = {}) {
277
+ const prevCredentials = { ...store.credentials }
278
+ const nextCredentials = buildCredentials(options)
279
+ Object.assign(store.credentials, nextCredentials)
280
+ const credsUnchanged = credentialsUnchanged(prevCredentials, nextCredentials)
281
+
267
282
  const nextPublic = buildPublicOptions({ ...options, token: options.token ?? store.credentials.token })
268
283
  Object.assign(store.options, {
269
284
  language: nextPublic.language,
@@ -286,11 +301,14 @@ function applyModuleOptions(store, options = {}) {
286
301
  })
287
302
  applyOriginSafety(store.options, options)
288
303
  if (store.credentials.backendUrl && store.credentials.token) {
289
- void startBootstrapSession(store)
304
+ if (credsUnchanged) {
305
+ reconcileOriginSafety(store)
306
+ } else {
307
+ void startBootstrapSession(store)
308
+ }
290
309
  } else {
291
310
  reconcileOriginSafety(store)
292
311
  }
293
- Object.assign(store.credentials, buildCredentials(options))
294
312
  }
295
313
 
296
314
  function syncApi(store) {
@@ -349,13 +367,10 @@ export function installAppHubModule(vueApp, options = {}) {
349
367
  let store = getAppHubStore(vueApp)
350
368
 
351
369
  if (store) {
370
+ vueApp.provide('apphubHostApp', vueApp)
352
371
  applyModuleOptions(store, options)
353
372
  ensureModuleInfrastructure(vueApp, store)
354
- if (store.options.originBootstrapLoading || store.options.originBlocked) {
355
- disableModuleServices(store)
356
- } else {
357
- enableModuleApi(store)
358
- }
373
+ reconcileOriginSafety(store)
359
374
  return store.facade
360
375
  }
361
376
 
@@ -377,6 +392,7 @@ export function installAppHubModule(vueApp, options = {}) {
377
392
  registerAppHubStore(vueApp, store)
378
393
 
379
394
  vueApp.provide('apphubOptions', moduleOptions)
395
+ vueApp.provide('apphubHostApp', vueApp)
380
396
  vueApp.component('AppHubDesktop', AppHubDesktop)
381
397
  vueApp.component('AppHubRunner', AppHubRunner)
382
398
 
@@ -122,7 +122,7 @@ const props = defineProps({
122
122
  const settingsOpen = ref(false)
123
123
  const appStore = useAppStore()
124
124
  const catalog = appStore.catalogs.store
125
- const rootApp = resolveRootApp(getCurrentInstance())
125
+ const rootApp = inject('apphubHostApp', null) ?? resolveRootApp(getCurrentInstance())
126
126
  const zone = useAppHubZoneContext()
127
127
  const moduleOptions = inject('apphubOptions', {})
128
128
  const lang = computed(() => resolveLang(moduleOptions?.language, 'vi'))
@@ -201,6 +201,15 @@ watch(
201
201
  },
202
202
  )
203
203
 
204
+ watch(
205
+ () => moduleOptions?.originBootstrapLoading,
206
+ (loading, wasLoading) => {
207
+ if (wasLoading && !loading && !moduleOptions?.originBlocked) {
208
+ if (!catalog.loaded || catalog.error === 'no_api') reloadCatalog()
209
+ }
210
+ },
211
+ )
212
+
204
213
  watch(
205
214
  () => [zone?.state?.selectedZoneId, zone?.state?.viewAllZones],
206
215
  () => {
@@ -83,7 +83,7 @@ const props = defineProps({
83
83
 
84
84
  const appStore = useAppStore()
85
85
  const catalog = appStore.catalogs.draft
86
- const rootApp = resolveRootApp(getCurrentInstance())
86
+ const rootApp = inject('apphubHostApp', null) ?? resolveRootApp(getCurrentInstance())
87
87
  const zone = useAppHubZoneContext()
88
88
  const moduleOptions = inject('apphubOptions', {})
89
89
  const lang = computed(() => resolveLang(moduleOptions?.language, 'vi'))
@@ -175,6 +175,15 @@ watch(
175
175
  },
176
176
  )
177
177
 
178
+ watch(
179
+ () => moduleOptions?.originBootstrapLoading,
180
+ (loading, wasLoading) => {
181
+ if (wasLoading && !loading && !moduleOptions?.originBlocked) {
182
+ if (!catalog.loaded || catalog.error === 'no_api') reloadCatalog()
183
+ }
184
+ },
185
+ )
186
+
178
187
  watch(
179
188
  () => [zone?.state?.selectedZoneId, zone?.state?.viewAllZones],
180
189
  () => {