@merkaly/nuxt 0.13.1 → 0.13.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/module.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useAuth } from "../composables/useAuth.js";
|
|
2
2
|
import { inApp, runBootstrapStage, useBootstrapState } from "./state.js";
|
|
3
3
|
export const runBootstrap = async (nuxtApp) => {
|
|
4
|
-
const { error, fail, isAuthenticated, token } = inApp(nuxtApp, useAuth);
|
|
4
|
+
const { error, fail, isAuthenticated, token } = await inApp(nuxtApp, useAuth);
|
|
5
5
|
if (error.value || nuxtApp.payload.error) return;
|
|
6
|
-
const failStage = (stage) => {
|
|
7
|
-
const reason = inApp(nuxtApp, () => useBootstrapState(stage)).error.value;
|
|
6
|
+
const failStage = async (stage) => {
|
|
7
|
+
const reason = (await inApp(nuxtApp, () => useBootstrapState(stage))).error.value;
|
|
8
8
|
return fail({ message: reason?.message || `${stage} failed`, stage, status: reason?.status });
|
|
9
9
|
};
|
|
10
10
|
if (!await runBootstrapStage(nuxtApp, "organization")) return failStage("organization");
|
|
@@ -29,7 +29,7 @@ interface StageData {
|
|
|
29
29
|
organization: MerkalyOrganization;
|
|
30
30
|
user: MerkalyUser;
|
|
31
31
|
}
|
|
32
|
-
export declare const inApp: <T>(nuxtApp: NuxtApp, fn: () => T) => T
|
|
32
|
+
export declare const inApp: <T>(nuxtApp: NuxtApp, fn: () => T) => Promise<T>;
|
|
33
33
|
export declare const registerBootstrapLoaders: (nuxtApp: NuxtApp, loaders: BootstrapLoaders) => void;
|
|
34
34
|
export declare const useBootstrapState: <S extends BootstrapStage>(stage: S) => {
|
|
35
35
|
data: Ref<StageData[S] | undefined, StageData[S] | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, useState } from "#imports";
|
|
2
2
|
import { until } from "@vueuse/core";
|
|
3
|
-
export const inApp = (nuxtApp, fn) => nuxtApp.runWithContext(fn);
|
|
3
|
+
export const inApp = async (nuxtApp, fn) => await nuxtApp.runWithContext(fn);
|
|
4
4
|
const registry = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
export const registerBootstrapLoaders = (nuxtApp, loaders) => {
|
|
6
6
|
registry.set(nuxtApp, { ...registry.get(nuxtApp), ...loaders });
|
|
@@ -27,11 +27,11 @@ const resolveLoader = async (nuxtApp, loader) => {
|
|
|
27
27
|
if (result.data.value == null) throw new Error("Empty response");
|
|
28
28
|
return result.data.value;
|
|
29
29
|
};
|
|
30
|
-
export const runBootstrapStage = (nuxtApp, stage, { force = false } = {}) => {
|
|
30
|
+
export const runBootstrapStage = async (nuxtApp, stage, { force = false } = {}) => {
|
|
31
31
|
const loader = registry.get(nuxtApp)?.[stage];
|
|
32
|
-
const { data, error, status } = inApp(nuxtApp, () => useBootstrapState(stage));
|
|
33
|
-
if (!loader) return
|
|
34
|
-
if (status.value === "success" && !force) return
|
|
32
|
+
const { data, error, status } = await inApp(nuxtApp, () => useBootstrapState(stage));
|
|
33
|
+
if (!loader) return true;
|
|
34
|
+
if (status.value === "success" && !force) return true;
|
|
35
35
|
status.value = "pending";
|
|
36
36
|
error.value = void 0;
|
|
37
37
|
return resolveLoader(nuxtApp, loader).then((value) => {
|