@b10cks/nuxt 0.10.3 → 0.10.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/dist/module.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Endpoint, type IBBaseQueryParams, type IBBlock, type IBContent, type IBContentQueryParams, type IBDataEntry, type IBDataSource, type IBResponse, type IBSpace } from '@b10cks/client';
|
|
2
2
|
export interface UseB10cksApiOptions<T> {
|
|
3
3
|
immediate?: boolean;
|
|
4
4
|
params?: Omit<IBBaseQueryParams, 'token'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useNuxtApp, useState } from "#app";
|
|
1
|
+
import { callOnce, useNuxtApp, useState } from "#app";
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
3
|
export const useB10cksApi = () => {
|
|
4
4
|
const { $b10cksClient } = useNuxtApp();
|
|
@@ -171,6 +171,11 @@ export const useB10cksApi = () => {
|
|
|
171
171
|
config: computed(() => configCache.value)
|
|
172
172
|
};
|
|
173
173
|
};
|
|
174
|
+
callOnce(async () => {
|
|
175
|
+
const { data: space, execute } = useSpace({ immediate: false });
|
|
176
|
+
await execute();
|
|
177
|
+
$b10cksClient.setRv(space.value?.rv || 426713400);
|
|
178
|
+
});
|
|
174
179
|
return {
|
|
175
180
|
useContent,
|
|
176
181
|
useContents,
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,32 +1,56 @@
|
|
|
1
1
|
import { useState } from "#app";
|
|
2
2
|
import { ApiClient } from "@b10cks/client";
|
|
3
|
-
import { B10cksVue, previewBridge } from "@b10cks/vue";
|
|
3
|
+
import { B10cksComponentResolverKey, B10cksVue, previewBridge } from "@b10cks/vue";
|
|
4
4
|
import { defineNuxtPlugin, useRequestURL, useRuntimeConfig } from "nuxt/app";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
import { resolveComponent } from "vue";
|
|
6
|
+
let rv = 0;
|
|
7
|
+
export default defineNuxtPlugin({
|
|
8
|
+
name: "b10cks",
|
|
9
|
+
setup(nuxtApp) {
|
|
10
|
+
const config = useRuntimeConfig();
|
|
11
|
+
const url = useRequestURL();
|
|
12
|
+
nuxtApp.vueApp.provide(B10cksComponentResolverKey, (componentName) => {
|
|
13
|
+
const pascalCaseBlockType = componentName.replace(/^([a-z])/, (match) => match.toUpperCase()).replace(/([a-z])([A-Z])/g, "$1$2");
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
try {
|
|
16
|
+
const component = resolveComponent(pascalCaseBlockType, false);
|
|
17
|
+
if (typeof component === "string") {
|
|
18
|
+
reject(new Error(`Component "${pascalCaseBlockType}" not found`));
|
|
19
|
+
} else {
|
|
20
|
+
resolve(component);
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
nuxtApp.vueApp.use(B10cksVue);
|
|
28
|
+
if (previewBridge.isInPreviewMode()) {
|
|
29
|
+
if (import.meta.client) {
|
|
30
|
+
previewBridge.init();
|
|
23
31
|
}
|
|
24
|
-
},
|
|
25
|
-
url
|
|
26
|
-
);
|
|
27
|
-
return {
|
|
28
|
-
provide: {
|
|
29
|
-
b10cksClient
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
const rvState = useState("b10cks_rv", () => url.searchParams.get("rv") || rv);
|
|
34
|
+
const b10cksClient = new ApiClient(
|
|
35
|
+
{
|
|
36
|
+
baseUrl: config.public.b10cks.apiUrl || "https://api.b10cks.com/api",
|
|
37
|
+
token: config.public.b10cks.accessToken,
|
|
38
|
+
fetchClient: $fetch,
|
|
39
|
+
rv: rvState.value,
|
|
40
|
+
getRv: () => {
|
|
41
|
+
return rvState.value;
|
|
42
|
+
},
|
|
43
|
+
setRv: (value) => {
|
|
44
|
+
rv = value;
|
|
45
|
+
rvState.value = value;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
url
|
|
49
|
+
);
|
|
50
|
+
return {
|
|
51
|
+
provide: {
|
|
52
|
+
b10cksClient
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
32
56
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b10cks/nuxt",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "b10cks Nuxt module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Michael Wallner @ Coder's Cantina",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@b10cks/client": "^0.10.
|
|
28
|
-
"@b10cks/vue": "^0.10.
|
|
27
|
+
"@b10cks/client": "^0.10.2",
|
|
28
|
+
"@b10cks/vue": "^0.10.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@nuxt/kit": "^4.2.1",
|