@storyblok/nuxt 8.2.4 → 9.0.1
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 +2 -2
- package/dist/module.mjs +9 -7
- package/dist/runtime/composables/useAsyncStoryblok.d.ts +5 -5
- package/dist/runtime/composables/useAsyncStoryblok.js +33 -11
- package/dist/runtime/plugin.d.ts +1 -1
- package/dist/types.d.mts +4 -2
- package/package.json +18 -18
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -19
- package/dist/types.d.ts +0 -7
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin, addImports } from '@nuxt/kit';
|
|
2
2
|
|
|
3
|
-
const module = defineNuxtModule({
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
5
5
|
name: "@storyblok/nuxt",
|
|
6
6
|
configKey: "storyblok"
|
|
@@ -68,11 +68,13 @@ const module = defineNuxtModule({
|
|
|
68
68
|
for (const name of names) {
|
|
69
69
|
addImports({ name, as: name, from: "@storyblok/vue" });
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
if (!nuxt.options.imports.scan) {
|
|
72
|
+
addImports({
|
|
73
|
+
name: "useAsyncStoryblok",
|
|
74
|
+
as: "useAsyncStoryblok",
|
|
75
|
+
from: resolver.resolve("runtime/composables/useAsyncStoryblok")
|
|
76
|
+
});
|
|
77
|
+
}
|
|
76
78
|
nuxt.options.typescript.hoist.push("@storyblok/vue");
|
|
77
79
|
if (options.devtools) {
|
|
78
80
|
nuxt.hook("devtools:customTabs", (iframeTabs) => {
|
|
@@ -90,4 +92,4 @@ const module = defineNuxtModule({
|
|
|
90
92
|
}
|
|
91
93
|
});
|
|
92
94
|
|
|
93
|
-
export { module as default };
|
|
95
|
+
export { module$1 as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ISbResult, type ISbStoriesParams, type StoryblokBridgeConfigV2 } from '@storyblok/vue';
|
|
2
2
|
import { type ComputedRef, type Ref } from 'vue';
|
|
3
3
|
import type { AsyncDataOptions, NuxtError } from '#app';
|
|
4
|
-
import type { DedupeOption } from 'nuxt/app/defaults';
|
|
5
4
|
/**
|
|
6
5
|
* Options for the useAsyncStoryblok composable.
|
|
7
6
|
* Extends Nuxt's AsyncDataOptions with Storyblok-specific configuration.
|
|
@@ -13,14 +12,15 @@ export interface UseAsyncStoryblokOptions extends AsyncDataOptions<ISbResult> {
|
|
|
13
12
|
bridge: StoryblokBridgeConfigV2;
|
|
14
13
|
}
|
|
15
14
|
interface AsyncDataExecuteOptions {
|
|
16
|
-
dedupe?:
|
|
17
|
-
cause?: 'initial' | 'refresh:hook' | 'refresh:manual' | 'watch';
|
|
15
|
+
dedupe?: 'cancel' | 'defer';
|
|
18
16
|
}
|
|
19
17
|
export interface UseAsyncStoryblokResult {
|
|
20
18
|
story: ComputedRef<ISbResult['data']['story']>;
|
|
21
|
-
|
|
19
|
+
/** In Nuxt 3: null when not loaded. In Nuxt 4: undefined when not loaded. */
|
|
20
|
+
data: Ref<ISbResult | null | undefined>;
|
|
22
21
|
pending: Ref<boolean>;
|
|
23
|
-
error:
|
|
22
|
+
/** In Nuxt 3: null when no error. In Nuxt 4: undefined when no error. */
|
|
23
|
+
error: Ref<NuxtError<unknown> | null | undefined>;
|
|
24
24
|
refresh: (opts?: AsyncDataExecuteOptions) => Promise<void>;
|
|
25
25
|
execute: (opts?: AsyncDataExecuteOptions) => Promise<void>;
|
|
26
26
|
clear: () => void;
|
|
@@ -11,19 +11,42 @@ const stableStringify = (obj) => {
|
|
|
11
11
|
};
|
|
12
12
|
export async function useAsyncStoryblok(url, options) {
|
|
13
13
|
const storyblokApiInstance = useStoryblokApi();
|
|
14
|
-
const { api, bridge, ...rest } = options;
|
|
14
|
+
const { api, bridge = {}, ...rest } = options;
|
|
15
15
|
const uniqueKey = `${stableStringify(api)}${url}`;
|
|
16
|
+
const bridgeOptions = {
|
|
17
|
+
...bridge,
|
|
18
|
+
resolveRelations: bridge.resolveRelations ?? api.resolve_relations,
|
|
19
|
+
resolveLinks: bridge.resolveLinks ?? api.resolve_links
|
|
20
|
+
};
|
|
16
21
|
const result = await useAsyncData(uniqueKey, () => storyblokApiInstance.get(`cdn/stories/${url}`, api), rest);
|
|
17
22
|
if (import.meta.client) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const registerBridge = (storyId) => {
|
|
24
|
+
useStoryblokBridge(storyId, (evStory) => {
|
|
25
|
+
if (result.data.value) {
|
|
26
|
+
result.data.value = {
|
|
27
|
+
...result.data.value,
|
|
28
|
+
data: {
|
|
29
|
+
...result.data.value.data,
|
|
30
|
+
story: evStory
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}, bridgeOptions);
|
|
35
|
+
};
|
|
36
|
+
const id = result.data.value?.data?.story?.id;
|
|
37
|
+
if (id) {
|
|
38
|
+
registerBridge(id);
|
|
39
|
+
} else {
|
|
40
|
+
const stopWatch = watch(
|
|
41
|
+
() => result.data.value?.data?.story?.id,
|
|
42
|
+
(storyId) => {
|
|
43
|
+
if (storyId) {
|
|
44
|
+
stopWatch();
|
|
45
|
+
registerBridge(storyId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
27
50
|
}
|
|
28
51
|
return {
|
|
29
52
|
data: result.data,
|
|
@@ -35,4 +58,3 @@ export async function useAsyncStoryblok(url, options) {
|
|
|
35
58
|
story: computed(() => result.data.value?.data.story)
|
|
36
59
|
};
|
|
37
60
|
}
|
|
38
|
-
;
|
package/dist/runtime/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { NuxtModule } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
import type { default as Module } from './module.
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module.
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type AllModuleOptions, type PublicModuleOptions } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.1",
|
|
5
5
|
"description": "Storyblok Nuxt module",
|
|
6
6
|
"homepage": "https://github.com/storyblok/monoblok/tree/main/packages/nuxt#readme",
|
|
7
7
|
"repository": {
|
|
@@ -14,35 +14,35 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./dist/types.d.
|
|
18
|
-
"import": "./dist/module.mjs"
|
|
19
|
-
"require": "./dist/module.cjs"
|
|
17
|
+
"types": "./dist/types.d.mts",
|
|
18
|
+
"import": "./dist/module.mjs"
|
|
20
19
|
}
|
|
21
20
|
},
|
|
22
|
-
"main": "./dist/module.
|
|
23
|
-
"types": "./dist/types.d.ts",
|
|
21
|
+
"main": "./dist/module.mjs",
|
|
24
22
|
"files": [
|
|
25
23
|
"dist"
|
|
26
24
|
],
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"nuxt": "^3.15.0 || ^4.0.0"
|
|
27
|
+
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@storyblok/vue": "9.4.
|
|
29
|
+
"@storyblok/vue": "9.4.5"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@cypress/vite-dev-server": "^6.0.3",
|
|
32
|
-
"@nuxt/eslint": "^1.
|
|
33
|
-
"@nuxt/eslint-config": "^1.
|
|
34
|
-
"@nuxt/kit": "^
|
|
35
|
-
"@nuxt/module-builder": "^0.
|
|
36
|
-
"@nuxt/schema": "^
|
|
37
|
-
"@nuxt/test-utils": "^3.
|
|
38
|
-
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
33
|
+
"@nuxt/eslint": "^1.2.0",
|
|
34
|
+
"@nuxt/eslint-config": "^1.2.0",
|
|
35
|
+
"@nuxt/kit": "^4.2.2",
|
|
36
|
+
"@nuxt/module-builder": "^1.0.0",
|
|
37
|
+
"@nuxt/schema": "^4.2.2",
|
|
38
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
39
39
|
"@types/node": "^22.15.18",
|
|
40
40
|
"cypress": "^14.3.3",
|
|
41
41
|
"eslint": "^9.26.0",
|
|
42
42
|
"eslint-config-prettier": "^10.0.1",
|
|
43
43
|
"eslint-plugin-cypress": "^4.3.0",
|
|
44
44
|
"eslint-plugin-vue": "^9.32.0",
|
|
45
|
-
"nuxt": "^
|
|
45
|
+
"nuxt": "^4.2.2",
|
|
46
46
|
"prettier": "^3.4.2",
|
|
47
47
|
"start-server-and-test": "^2.0.11",
|
|
48
48
|
"@storyblok/eslint-config": "0.4.1"
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "nuxt-module-build prepare && nuxt-module-build build",
|
|
69
69
|
"test:types": "tsc --noEmit --skipLibCheck",
|
|
70
|
-
"dev": "nuxi dev playground",
|
|
70
|
+
"dev": "nuxi dev playground --port 3000",
|
|
71
71
|
"dev:build": "nuxi build playground",
|
|
72
72
|
"dev:preview": "nuxi preview playground --port 3100",
|
|
73
|
-
"dev:e2e": "nuxi dev playground
|
|
73
|
+
"dev:e2e": "nuxi dev playground --port 3100",
|
|
74
74
|
"prepare:playground": "nuxi prepare playground",
|
|
75
75
|
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
|
|
76
76
|
"cy:open": "cypress open",
|
|
77
77
|
"cy:run": "cypress run",
|
|
78
78
|
"test:e2e": "start-server-and-test dev:e2e http://localhost:3100 cy:run",
|
|
79
79
|
"test:e2e-watch": "start-server-and-test dev:e2e http://localhost:3100 cy:open",
|
|
80
|
-
"pretest:e2e-static": "nuxi generate playground
|
|
80
|
+
"pretest:e2e-static": "nuxi generate playground",
|
|
81
81
|
"test:e2e-static": "start-server-and-test dev:preview http://localhost:3100 cy:run",
|
|
82
82
|
"lint": "eslint .",
|
|
83
83
|
"lint:fix": "eslint . --fix",
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
|
|
3
|
-
interface PublicModuleOptions {
|
|
4
|
-
enableSudoMode: boolean;
|
|
5
|
-
usePlugin: boolean;
|
|
6
|
-
bridge: boolean;
|
|
7
|
-
devtools: boolean;
|
|
8
|
-
apiOptions: any;
|
|
9
|
-
componentsDir: string;
|
|
10
|
-
enableServerClient: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface AllModuleOptions extends PublicModuleOptions {
|
|
13
|
-
accessToken: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare const _default: _nuxt_schema.NuxtModule<AllModuleOptions, AllModuleOptions, false>;
|
|
17
|
-
|
|
18
|
-
export { _default as default };
|
|
19
|
-
export type { AllModuleOptions, PublicModuleOptions };
|
package/dist/types.d.ts
DELETED