@storyblok/react 2.0.19 → 2.1.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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-65ac33dd.js"),o=require("./storyblok-js-a8758ae9.js");require("react"),exports.StoryblokComponent=e.StoryblokComponent,exports.getComponent=e.getComponent,exports.getStoryblokApi=e.useStoryblokApi,exports.storyblokInit=e.storyblokInit,exports.useStoryblokApi=e.useStoryblokApi,exports.RichTextResolver=o.y,exports.RichTextSchema=o.ie,exports.apiPlugin=o.le,exports.loadStoryblokBridge=o.pe,exports.registerStoryblokBridge=o.he,exports.renderRichText=o.de,exports.storyblokEditable=o.ce,exports.useStoryblokBridge=o.he;
@@ -0,0 +1,18 @@
1
+ import { S, g, u, s, u as u2 } from "./index-f1318b50.mjs";
2
+ import { y, i, l, p, h, d, c, h as h2 } from "./storyblok-js-612aedc3.mjs";
3
+ import "react";
4
+ export {
5
+ y as RichTextResolver,
6
+ i as RichTextSchema,
7
+ S as StoryblokComponent,
8
+ l as apiPlugin,
9
+ g as getComponent,
10
+ u as getStoryblokApi,
11
+ p as loadStoryblokBridge,
12
+ h as registerStoryblokBridge,
13
+ d as renderRichText,
14
+ c as storyblokEditable,
15
+ s as storyblokInit,
16
+ u2 as useStoryblokApi,
17
+ h2 as useStoryblokBridge
18
+ };
@@ -0,0 +1 @@
1
+ "use strict";"use client";const e=require("react"),o=require("./storyblok-js-a8758ae9.js");module.exports=({options:t})=>((async e=>{await o.pe(),new window.StoryblokBridge(e).on(["published","change"],(()=>{window.location.reload()}))})(t),e.createElement(e.Fragment,null));
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import React from "react";
3
+ import { p as pe } from "./storyblok-js-612aedc3.mjs";
4
+ const setBridge = async (options) => {
5
+ await pe();
6
+ const sbBridge = new window.StoryblokBridge(options);
7
+ sbBridge.on(["published", "change"], () => {
8
+ window.location.reload();
9
+ });
10
+ };
11
+ const StoryblokBridgeLoader = ({ options }) => {
12
+ setBridge(options);
13
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
14
+ };
15
+ export {
16
+ StoryblokBridgeLoader as default
17
+ };
@@ -0,0 +1 @@
1
+ "use strict";"use client";const e=require("react"),t=require("./client-6eb29fd9.js"),r=require("./index-65ac33dd.js");require("./storyblok-js-a8758ae9.js");module.exports=({story:o})=>(o=t.useStoryblokState(o),e.createElement(r.StoryblokComponent,{blok:o.content}));
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import React from "react";
3
+ import { u as useStoryblokState } from "./client-16ee9ae1.mjs";
4
+ import { S as StoryblokComponent } from "./index-f1318b50.mjs";
5
+ import "./storyblok-js-612aedc3.mjs";
6
+ const StoryblokStory = ({ story }) => {
7
+ story = useStoryblokState(story);
8
+ return /* @__PURE__ */ React.createElement(StoryblokComponent, { blok: story.content });
9
+ };
10
+ export {
11
+ StoryblokStory as default
12
+ };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { StoryblokBridgeConfigV2 } from "./types";
3
+ interface StoryblokBridgeLoaderProps {
4
+ options: StoryblokBridgeConfigV2;
5
+ [key: string]: unknown;
6
+ }
7
+ declare const StoryblokBridgeLoader: ({ options }: StoryblokBridgeLoaderProps) => React.JSX.Element;
8
+ export default StoryblokBridgeLoader;
@@ -0,0 +1,2 @@
1
+ import type { TUseStoryblokState } from "../types";
2
+ export declare const useStoryblokState: TUseStoryblokState;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { SbReactSDKOptions, StoryblokClient } from "../types";
3
+ export declare const useStoryblokApi: () => StoryblokClient;
4
+ export declare const getComponent: (componentKey: string) => false | import("react").ElementType<any>;
5
+ export declare const storyblokInit: (pluginOptions?: SbReactSDKOptions) => void;
6
+ export { default as StoryblokComponent } from "./storyblok-component";
7
+ export { useStoryblokApi as getStoryblokApi };
8
+ export { storyblokEditable, apiPlugin, loadStoryblokBridge, useStoryblokBridge, registerStoryblokBridge, renderRichText, RichTextResolver, RichTextSchema, } from "@storyblok/js";
9
+ export * from "../types";
@@ -1,13 +1,6 @@
1
- /// <reference types="react" />
2
- import { SbReactSDKOptions, ISbStoriesParams, StoryblokBridgeConfigV2, StoryblokClient, ISbStoryData } from "./types";
3
- export { default as StoryblokComponent } from "./components/storyblok-component";
4
- export { storyblokEditable, apiPlugin, useStoryblokBridge, registerStoryblokBridge, renderRichText, RichTextResolver, RichTextSchema, } from "@storyblok/js";
1
+ import { ISbStoriesParams, StoryblokBridgeConfigV2, ISbStoryData } from "./types";
5
2
  export declare const useStoryblok: (slug: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => ISbStoryData<import("@storyblok/js").StoryblokComponentType<string> & {
6
3
  [index: string]: any;
7
4
  }>;
8
- export declare const useStoryblokState: <T = void>(initialStory?: ISbStoryData<T>, bridgeOptions?: StoryblokBridgeConfigV2) => ISbStoryData<T>;
9
- export declare const useStoryblokApi: () => StoryblokClient;
10
- export { useStoryblokApi as getStoryblokApi };
11
- export declare const getComponent: (componentKey: string) => false | import("react").ElementType<any>;
12
- export declare const storyblokInit: (pluginOptions?: SbReactSDKOptions) => void;
13
- export * from "./types";
5
+ export * from "./common";
6
+ export * from "./common/client";
@@ -0,0 +1 @@
1
+ export * from "../common";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { ISbStoryData } from "./types";
3
+ interface StoryblokStoryProps {
4
+ story: ISbStoryData;
5
+ [key: string]: unknown;
6
+ }
7
+ declare const StoryblokStory: ({ story }: StoryblokStoryProps) => React.JSX.Element;
8
+ export default StoryblokStory;
@@ -1,9 +1,11 @@
1
- import { SbSDKOptions } from "@storyblok/js";
2
1
  import React from "react";
2
+ import { SbSDKOptions } from "@storyblok/js";
3
+ import type { ISbStoryData, StoryblokBridgeConfigV2 } from "@storyblok/js";
3
4
  export interface SbReactComponentsMap {
4
5
  [key: string]: React.ElementType;
5
6
  }
6
7
  export interface SbReactSDKOptions extends SbSDKOptions {
7
8
  components?: SbReactComponentsMap;
8
9
  }
10
+ export type TUseStoryblokState = <T = void>(initialStory: ISbStoryData<T> | null, bridgeOptions?: StoryblokBridgeConfigV2) => ISbStoryData<T> | null;
9
11
  export type { ISbConfig, ISbCache, ISbResult, ISbResponse, ISbError, ISbNode, ISbSchema, ThrottleFn, AsyncFn, ArrayFn, ISbContentMangmntAPI, ISbManagmentApiResult, ISbStories, ISbStory, ISbDimensions, ISbStoryData, ISbAlternateObject, ISbStoriesParams, ISbStoryParams, ISbRichtext, SbBlokData, SbBlokKeyDataTypes, SbRichTextOptions, SbSDKOptions, StoryblokBridgeConfigV2, StoryblokBridgeV2, StoryblokClient, StoryblokComponentType, useStoryblokBridge, } from "@storyblok/js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/react",
3
- "version": "2.0.19",
3
+ "version": "2.1.0",
4
4
  "description": "SDK to integrate Storyblok into your project using React.",
5
5
  "main": "./dist/storyblok-react.js",
6
6
  "module": "./dist/storyblok-react.mjs",
@@ -12,15 +12,31 @@
12
12
  ".": {
13
13
  "import": "./dist/storyblok-react.mjs",
14
14
  "require": "./dist/storyblok-react.js"
15
+ },
16
+ "./rsc": {
17
+ "import": "./dist/storyblok-react2.mjs",
18
+ "require": "./dist/storyblok-react2.js"
19
+ },
20
+ "./bridge-loader": {
21
+ "import": "./dist/storyblok-react3.mjs",
22
+ "require": "./dist/storyblok-react3.js"
23
+ },
24
+ "./story": {
25
+ "import": "./dist/storyblok-react4.mjs",
26
+ "require": "./dist/storyblok-react4.js"
15
27
  }
16
28
  },
17
29
  "scripts": {
18
30
  "dev": "vite build --watch",
19
31
  "build": "vite build && tsc --project tsconfig.json",
20
- "test": "npm run test:unit && npm run test:e2e",
32
+ "test": "npm run test:unit && npm run test:e2e && npm run test:comp",
21
33
  "test:unit": "jest __tests__",
22
- "test:e2e": "cypress run-ct",
23
- "test:e2e-watch": "cypress open-ct",
34
+ "test:e2e": "start-server-and-test cy:playground http://localhost:3000/ cy:run",
35
+ "test:e2e-watch": "start-server-and-test cy:playground http-get://localhost:3000/ cy:open",
36
+ "cy:playground": "npm run demo --prefix ../playground-next13-live-editing",
37
+ "cy:run": "cypress run",
38
+ "cy:open": "cypress open",
39
+ "test:comp": "cypress run-ct",
24
40
  "prepublishOnly": "npm run build && cp ../README.md ./"
25
41
  },
26
42
  "dependencies": {
@@ -41,7 +57,9 @@
41
57
  "jest": "^29.5.0",
42
58
  "react": "^18.2.0",
43
59
  "react-dom": "^18.2.0",
44
- "vite": "^2.9.15"
60
+ "start-server-and-test": "^2.0.0",
61
+ "terser": "^5.16.6",
62
+ "vite": "^4.1.4"
45
63
  },
46
64
  "peerDependencies": {
47
65
  "react": "^17.0.0 || ^18.0.0",