@kennofizet/apphub-frontend 0.1.3 → 0.1.4

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.3",
3
+ "version": "0.1.4",
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",
@@ -6,19 +6,34 @@ export function resolveRootApp(instance = getCurrentInstance()) {
6
6
  return instance.appContext?.app ?? instance.app ?? null
7
7
  }
8
8
 
9
+ export function resolveHostApp(app) {
10
+ if (app != null) return app
11
+ const instance = getCurrentInstance()
12
+ if (!instance) return null
13
+ return instance.appContext?.app ?? instance.app ?? null
14
+ }
15
+
16
+ export function getAppHubStoreForApp(app) {
17
+ const resolved = resolveHostApp(app)
18
+ return resolved != null ? getAppHubStore(resolved) : null
19
+ }
20
+
9
21
  export function getHostApiForApp(app) {
10
- return getAppHubStore(app)?.facade ?? null
22
+ return getAppHubStoreForApp(app)?.facade ?? null
11
23
  }
12
24
 
13
25
  export function isBackendReadyForApp(app) {
14
- const store = getAppHubStore(app)
26
+ const store = getAppHubStoreForApp(app)
15
27
  return !!(store?.credentials?.backendUrl && store?.credentials?.token)
16
28
  }
17
29
 
18
30
  export function isHostApiReadyForApp(app) {
19
- const store = getAppHubStore(app)
31
+ const store = getAppHubStoreForApp(app)
20
32
  if (!store?.credentials?.backendUrl || !store?.credentials?.token) return false
21
- return store.facade?.hasImpl?.() === true
33
+ if (typeof store.facade?.hasImpl === 'function') {
34
+ return store.facade.hasImpl()
35
+ }
36
+ return !!store.facade
22
37
  }
23
38
 
24
39
  /**
package/src/index.js CHANGED
@@ -375,11 +375,14 @@ export function installAppHubModule(vueApp, options = {}) {
375
375
  let store = getAppHubStore(vueApp)
376
376
 
377
377
  if (store) {
378
+ vueApp.provide('apphubHostApp', vueApp)
378
379
  applyModuleOptions(store, options)
379
380
  ensureModuleInfrastructure(vueApp, store)
380
- if (store.options.originBootstrapLoading || store.options.originBlocked) {
381
+ // While bootstrap is in flight, leave API state to startBootstrapSession — do not
382
+ // disable again (hub-host-starter may re-apply config when parent re-sends postMessage).
383
+ if (store.options.originBlocked) {
381
384
  disableModuleServices(store)
382
- } else {
385
+ } else if (!store.options.originBootstrapLoading) {
383
386
  enableModuleApi(store)
384
387
  }
385
388
  return store.facade
@@ -402,6 +405,7 @@ export function installAppHubModule(vueApp, options = {}) {
402
405
  }
403
406
  registerAppHubStore(vueApp, store)
404
407
 
408
+ vueApp.provide('apphubHostApp', vueApp)
405
409
  vueApp.provide('apphubOptions', moduleOptions)
406
410
  vueApp.component('AppHubDesktop', AppHubDesktop)
407
411
  vueApp.component('AppHubRunner', AppHubRunner)
@@ -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'))
@@ -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'))
@@ -102,7 +102,10 @@ export function createAppStoreState(options = {}) {
102
102
  const append = options.append === true
103
103
  const backendReady = options.backendReady !== false
104
104
 
105
- if (!backendReady || !hostApi?.hasImpl?.()) {
105
+ const facadeReady = hostApi && (
106
+ typeof hostApi.hasImpl === 'function' ? hostApi.hasImpl() : true
107
+ )
108
+ if (!backendReady || !facadeReady) {
106
109
  if (!append) {
107
110
  bucket.items = []
108
111
  bucket.error = 'no_api'