@kennofizet/apphub-frontend 0.1.3 → 0.1.5
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 +1 -1
- package/src/composables/useAppHubHostApi.js +0 -6
- package/src/index.js +6 -32
- package/src/modules/app-store/components/AppHubAppStoreApp.vue +5 -25
- package/src/modules/app-store/components/AppHubDraftStoreApp.vue +5 -25
- package/src/modules/app-store/composables/useAppStore.js +1 -1
package/package.json
CHANGED
|
@@ -15,12 +15,6 @@ export function isBackendReadyForApp(app) {
|
|
|
15
15
|
return !!(store?.credentials?.backendUrl && store?.credentials?.token)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function isHostApiReadyForApp(app) {
|
|
19
|
-
const store = getAppHubStore(app)
|
|
20
|
-
if (!store?.credentials?.backendUrl || !store?.credentials?.token) return false
|
|
21
|
-
return store.facade?.hasImpl?.() === true
|
|
22
|
-
}
|
|
23
|
-
|
|
24
18
|
/**
|
|
25
19
|
* Host-only API — use in Hub shell components. Not provided via inject
|
|
26
20
|
* so publisher app code cannot access grantBridgeScope or internal docs.
|
package/src/index.js
CHANGED
|
@@ -136,9 +136,6 @@ function applyBootstrapOrigins(store, bootstrapResponse, { fromCache = false } =
|
|
|
136
136
|
reconcileOriginSafety(store)
|
|
137
137
|
store.options.originBootstrapLoading = false
|
|
138
138
|
applyOriginSafety(store.options)
|
|
139
|
-
if (!store.options.originBlocked) {
|
|
140
|
-
enableModuleApi(store)
|
|
141
|
-
}
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
function applyCachedBootstrapIfAny(store) {
|
|
@@ -159,12 +156,9 @@ async function fetchBootstrapSession(store) {
|
|
|
159
156
|
const res = await store.facade.bootstrap()
|
|
160
157
|
if (res) applyBootstrapOrigins(store, res)
|
|
161
158
|
})().catch(() => {
|
|
162
|
-
const wasLoading = store.options.originBootstrapLoading === true
|
|
163
159
|
store.options.originBootstrapLoading = false
|
|
164
160
|
if (!store.options.serverOriginsResolved) {
|
|
165
161
|
reconcileOriginSafety(store)
|
|
166
|
-
} else if (!store.options.originBlocked && (wasLoading || !store.facade?.hasImpl?.())) {
|
|
167
|
-
enableModuleApi(store)
|
|
168
162
|
}
|
|
169
163
|
}).finally(() => {
|
|
170
164
|
bootstrapInflight.delete(store)
|
|
@@ -208,6 +202,8 @@ function reconcileOriginSafety(store) {
|
|
|
208
202
|
|
|
209
203
|
if (store.options.originBlocked && !wasBlocked) {
|
|
210
204
|
disableModuleServices(store)
|
|
205
|
+
} else if (!store.options.originBlocked && (wasBlocked || wasLoading)) {
|
|
206
|
+
enableModuleApi(store)
|
|
211
207
|
}
|
|
212
208
|
}
|
|
213
209
|
|
|
@@ -247,9 +243,6 @@ function createApiFacade() {
|
|
|
247
243
|
setImpl(next) {
|
|
248
244
|
impl = next
|
|
249
245
|
},
|
|
250
|
-
hasImpl() {
|
|
251
|
-
return impl != null
|
|
252
|
-
},
|
|
253
246
|
bootstrap: (...args) => impl?.bootstrap?.(...args),
|
|
254
247
|
apps: (...args) => impl?.apps?.(...args),
|
|
255
248
|
launch: (...args) => impl?.launch?.(...args),
|
|
@@ -291,14 +284,13 @@ function applyModuleOptions(store, options = {}) {
|
|
|
291
284
|
hostedSandboxSameOrigin: nextPublic.hostedSandboxSameOrigin,
|
|
292
285
|
enforceDevFriendlyOrigins: nextPublic.enforceDevFriendlyOrigins,
|
|
293
286
|
})
|
|
294
|
-
Object.assign(store.credentials, buildCredentials(options))
|
|
295
|
-
store._zonesSyncKey = null
|
|
296
287
|
applyOriginSafety(store.options, options)
|
|
297
288
|
if (store.credentials.backendUrl && store.credentials.token) {
|
|
298
289
|
void startBootstrapSession(store)
|
|
299
290
|
} else {
|
|
300
291
|
reconcileOriginSafety(store)
|
|
301
292
|
}
|
|
293
|
+
Object.assign(store.credentials, buildCredentials(options))
|
|
302
294
|
}
|
|
303
295
|
|
|
304
296
|
function syncApi(store) {
|
|
@@ -331,29 +323,11 @@ function ensureZoneContext(app, store) {
|
|
|
331
323
|
app.provide(APPHUB_ZONE_CONTEXT_KEY, store.zoneContext)
|
|
332
324
|
}
|
|
333
325
|
|
|
334
|
-
function
|
|
335
|
-
const { coreUrl, token } = store.credentials
|
|
336
|
-
return `${coreUrl}::${token}`
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function syncZoneContext(store, { force = false } = {}) {
|
|
326
|
+
function syncZoneContext(store) {
|
|
340
327
|
syncCoreApi(store)
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
const key = zoneSyncKey(store)
|
|
344
|
-
if (!force && store._zonesSyncKey === key && store.zoneContext.state.zones.length > 0) {
|
|
345
|
-
return store._zonesRefreshInflight ?? undefined
|
|
346
|
-
}
|
|
347
|
-
if (store._zonesRefreshInflight) {
|
|
348
|
-
return store._zonesRefreshInflight
|
|
328
|
+
if (store.zoneContext) {
|
|
329
|
+
store.zoneContext.refresh({ skipBootstrap: true })
|
|
349
330
|
}
|
|
350
|
-
|
|
351
|
-
store._zonesSyncKey = key
|
|
352
|
-
store._zonesRefreshInflight = store.zoneContext.refresh({ skipBootstrap: true })
|
|
353
|
-
.finally(() => {
|
|
354
|
-
store._zonesRefreshInflight = null
|
|
355
|
-
})
|
|
356
|
-
return store._zonesRefreshInflight
|
|
357
331
|
}
|
|
358
332
|
|
|
359
333
|
function ensureModuleState(app, store) {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
import { computed, getCurrentInstance, inject, onMounted, ref, watch } from 'vue'
|
|
101
101
|
import {
|
|
102
102
|
getHostApiForApp,
|
|
103
|
-
|
|
103
|
+
isBackendReadyForApp,
|
|
104
104
|
resolveRootApp,
|
|
105
105
|
} from '../../../composables/useAppHubHostApi.js'
|
|
106
106
|
import { useAppHubZoneContext } from '../../../composables/useAppHubZoneContext.js'
|
|
@@ -152,19 +152,11 @@ const labels = computed(() => ({
|
|
|
152
152
|
|
|
153
153
|
function hostApiOptions() {
|
|
154
154
|
return {
|
|
155
|
-
backendReady:
|
|
155
|
+
backendReady: isBackendReadyForApp(rootApp),
|
|
156
156
|
mode: CATALOG_MODE_STORE,
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
function canLoadCatalog() {
|
|
161
|
-
return (
|
|
162
|
-
!moduleOptions?.originBootstrapLoading
|
|
163
|
-
&& !moduleOptions?.originBlocked
|
|
164
|
-
&& isHostApiReadyForApp(rootApp)
|
|
165
|
-
)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
160
|
async function reloadCatalog() {
|
|
169
161
|
if (!rootApp) return
|
|
170
162
|
await appStore.loadCatalog(getHostApiForApp(rootApp), hostApiOptions())
|
|
@@ -205,26 +197,14 @@ onMounted(() => {
|
|
|
205
197
|
watch(
|
|
206
198
|
() => moduleOptions?.hasToken,
|
|
207
199
|
(hasToken) => {
|
|
208
|
-
if (hasToken &&
|
|
209
|
-
},
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
watch(
|
|
213
|
-
() => moduleOptions?.originBootstrapLoading,
|
|
214
|
-
(loading, prevLoading) => {
|
|
215
|
-
if (prevLoading && !loading && canLoadCatalog()) {
|
|
216
|
-
reloadCatalog()
|
|
217
|
-
}
|
|
200
|
+
if (hasToken && !catalog.loaded) reloadCatalog()
|
|
218
201
|
},
|
|
219
202
|
)
|
|
220
203
|
|
|
221
204
|
watch(
|
|
222
205
|
() => [zone?.state?.selectedZoneId, zone?.state?.viewAllZones],
|
|
223
|
-
(
|
|
224
|
-
if (
|
|
225
|
-
if (current[0] === previous[0] && current[1] === previous[1]) return
|
|
226
|
-
if (!canLoadCatalog() || !catalog.loaded) return
|
|
227
|
-
reloadCatalog()
|
|
206
|
+
() => {
|
|
207
|
+
if (moduleOptions?.hasToken) reloadCatalog()
|
|
228
208
|
},
|
|
229
209
|
)
|
|
230
210
|
</script>
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
import { computed, getCurrentInstance, inject, onMounted, reactive, ref, watch } from 'vue'
|
|
66
66
|
import {
|
|
67
67
|
getHostApiForApp,
|
|
68
|
-
|
|
68
|
+
isBackendReadyForApp,
|
|
69
69
|
resolveRootApp,
|
|
70
70
|
} from '../../../composables/useAppHubHostApi.js'
|
|
71
71
|
import { useAppHubZoneContext } from '../../../composables/useAppHubZoneContext.js'
|
|
@@ -119,19 +119,11 @@ const labels = computed(() => ({
|
|
|
119
119
|
|
|
120
120
|
function hostApiOptions() {
|
|
121
121
|
return {
|
|
122
|
-
backendReady:
|
|
122
|
+
backendReady: isBackendReadyForApp(rootApp),
|
|
123
123
|
mode: CATALOG_MODE_DRAFT,
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
function canLoadCatalog() {
|
|
128
|
-
return (
|
|
129
|
-
!moduleOptions?.originBootstrapLoading
|
|
130
|
-
&& !moduleOptions?.originBlocked
|
|
131
|
-
&& isHostApiReadyForApp(rootApp)
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
127
|
async function reloadCatalog() {
|
|
136
128
|
if (!rootApp) return
|
|
137
129
|
await appStore.loadCatalog(getHostApiForApp(rootApp), hostApiOptions())
|
|
@@ -179,26 +171,14 @@ onMounted(() => {
|
|
|
179
171
|
watch(
|
|
180
172
|
() => moduleOptions?.hasToken,
|
|
181
173
|
(hasToken) => {
|
|
182
|
-
if (hasToken &&
|
|
183
|
-
},
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
watch(
|
|
187
|
-
() => moduleOptions?.originBootstrapLoading,
|
|
188
|
-
(loading, prevLoading) => {
|
|
189
|
-
if (prevLoading && !loading && canLoadCatalog()) {
|
|
190
|
-
reloadCatalog()
|
|
191
|
-
}
|
|
174
|
+
if (hasToken && !catalog.loaded) reloadCatalog()
|
|
192
175
|
},
|
|
193
176
|
)
|
|
194
177
|
|
|
195
178
|
watch(
|
|
196
179
|
() => [zone?.state?.selectedZoneId, zone?.state?.viewAllZones],
|
|
197
|
-
(
|
|
198
|
-
if (
|
|
199
|
-
if (current[0] === previous[0] && current[1] === previous[1]) return
|
|
200
|
-
if (!canLoadCatalog() || !catalog.loaded) return
|
|
201
|
-
reloadCatalog()
|
|
180
|
+
() => {
|
|
181
|
+
if (moduleOptions?.hasToken) reloadCatalog()
|
|
202
182
|
},
|
|
203
183
|
)
|
|
204
184
|
</script>
|
|
@@ -102,7 +102,7 @@ export function createAppStoreState(options = {}) {
|
|
|
102
102
|
const append = options.append === true
|
|
103
103
|
const backendReady = options.backendReady !== false
|
|
104
104
|
|
|
105
|
-
if (!backendReady || !hostApi?.
|
|
105
|
+
if (!backendReady || !hostApi?.apps) {
|
|
106
106
|
if (!append) {
|
|
107
107
|
bucket.items = []
|
|
108
108
|
bucket.error = 'no_api'
|