@storyblok/astro 8.0.0 → 8.2.0

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.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Options for validating Storyblok Visual Editor requests.
3
+ */
4
+ interface StoryblokValidationOptions {
5
+ /**
6
+ * Optional space ID to validate against the request.
7
+ * If provided, the request must match this space ID to be considered valid.
8
+ */
9
+ spaceId?: string;
10
+ }
11
+ /**
12
+ * Validates whether a given URL is a legitimate request from the Storyblok Visual Editor.
13
+ *
14
+ * This function performs a multi-layered validation to ensure the request originates from
15
+ * the Storyblok Visual Editor by checking for required query parameters and optionally
16
+ * validating the space ID.
17
+ * @param url - The URL object to validate.
18
+ * @param options - Optional validation configuration.
19
+ * @param options.spaceId - If provided, validates that the request's space ID matches this value.
20
+ *
21
+ * @returns `true` if the URL contains all required Storyblok Visual Editor parameters
22
+ * and passes optional space ID validation; `false` otherwise.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const url = new URL('https://example.com/?_storyblok=123&_storyblok_c=456&_storyblok_tk[space_id]=789');
27
+ *
28
+ * // Basic validation
29
+ * if (isEditorRequest(url)) {
30
+ * console.log('Valid Storyblok editor request');
31
+ * }
32
+ *
33
+ * // Validation with space ID check
34
+ * if (isEditorRequest(url, { spaceId: '789' })) {
35
+ * console.log('Valid request for specific space');
36
+ * }
37
+ * ```
38
+ * @todo Move this to `@storyblok/live-preview` to keep live preview logic centralized.
39
+ */
40
+ export declare function isEditorRequest(url: URL, options?: StoryblokValidationOptions): boolean;
41
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
3
  "type": "module",
4
- "version": "8.0.0",
4
+ "version": "8.2.0",
5
5
  "private": false,
6
6
  "description": "Official Astro integration for the Storyblok Headless CMS",
7
7
  "author": "Storyblok",
@@ -39,7 +39,8 @@
39
39
  },
40
40
  "./client": "./dist/lib/client.ts",
41
41
  "./FallbackComponent.astro": "./dist/components/FallbackComponent.astro",
42
- "./StoryblokComponent.astro": "./dist/components/StoryblokComponent.astro"
42
+ "./StoryblokComponent.astro": "./dist/components/StoryblokComponent.astro",
43
+ "./StoryblokServerData.astro": "./dist/components/StoryblokServerData.astro"
43
44
  },
44
45
  "main": "./dist/storyblok-astro.es.js",
45
46
  "module": "./dist/storyblok-astro.js",
@@ -53,13 +54,14 @@
53
54
  },
54
55
  "dependencies": {
55
56
  "camelcase": "^8.0.0",
56
- "@storyblok/js": "5.0.0"
57
+ "morphdom": "^2.7.8",
58
+ "@storyblok/js": "5.1.0"
57
59
  },
58
60
  "devDependencies": {
59
61
  "@cypress/vite-dev-server": "^6.0.3",
60
62
  "@rollup/plugin-dynamic-import-vars": "^2.1.5",
61
63
  "@types/lodash.mergewith": "^4.6.9",
62
- "@types/node": "^22.15.18",
64
+ "@types/node": "^24.11.0",
63
65
  "astro": "^5.13.2",
64
66
  "cypress": "^14.3.3",
65
67
  "eslint": "^9.26.0",
@@ -74,7 +76,7 @@
74
76
  "vite-plugin-dts": "^4.5.3",
75
77
  "vite-plugin-static-copy": "^2.2.0",
76
78
  "vitest": "^3.1.3",
77
- "@storyblok/eslint-config": "0.4.2"
79
+ "@storyblok/eslint-config": "0.5.0"
78
80
  },
79
81
  "eslintConfig": {
80
82
  "env": {
@@ -139,9 +141,8 @@
139
141
  "lint:fix": "eslint . --fix",
140
142
  "lint:playground": "pnpm -r --parallel --filter='./playground/*' run lint",
141
143
  "lint:playground:fix": "pnpm -r --parallel --filter='./playground/*' run lint:fix",
142
- "test": "pnpm run test:unit:ci && pnpm run test:e2e",
143
- "test:unit": "vitest",
144
- "test:unit:ci": "vitest run",
144
+ "test": "pnpm run test:unit && pnpm run test:e2e",
145
+ "test:unit": "vitest run",
145
146
  "test:e2e": "start-server-and-test playground:test http://localhost:4321/ cy:run",
146
147
  "test:e2e-watch": "start-server-and-test playground:test http://localhost:4321/ cy:open",
147
148
  "cy:run": "cypress run",