diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..923d261e
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,33 @@
+name: Release CI
+
+on:
+ push:
+ branches: [master, next]
+ pull_request:
+ branches: [master, next]
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Setup Node
+ uses: actions/setup-node@v2
+ with:
+ node-version: "lts/*"
+ cache: "npm"
+ - name: Install dependencies
+ run: npm ci
+ - name: Build lib
+ run: npm run build
+ - name: Jest run
+ run: npm run test:unit
+ - name: Cypress run
+ run: npm run test:e2e
+ # - name: Release
+ # working-directory: lib
+ # env:
+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ # NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ # run: npx semantic-release
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..f496869a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+.DS_Store
+node_modules
+dist
+dist-v2
+lib/cypress/videos
\ No newline at end of file
diff --git a/.husky/.gitignore b/.husky/.gitignore
new file mode 100644
index 00000000..31354ec1
--- /dev/null
+++ b/.husky/.gitignore
@@ -0,0 +1 @@
+_
diff --git a/.husky/commit-msg b/.husky/commit-msg
new file mode 100644
index 00000000..2b0b740c
--- /dev/null
+++ b/.husky/commit-msg
@@ -0,0 +1,6 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npx --no -- commitlint --edit "$1"
+# npx --no-install commitlint --edit
+
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100644
index 00000000..36af2198
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npx lint-staged
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 00000000..728a19f8
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,4 @@
+.*
+*.md
+*.json
+example
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..6bc15409
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Storyblok
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..101c9673
--- /dev/null
+++ b/README.md
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## đ Usage
+
+> If you are first-time user of the Storyblok, read the [Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) guide to get a project ready in less than 5 minutes.
+
+### Installation
+
+Install `@storyblok/js`:
+
+```bash
+npm install --save-dev @storyblok/js
+// yarn add -D @storyblok/js
+```
+
+#### From a CDN
+
+Install the file from the CDN:
+
+```html
+
+```
+
+### Initialization
+
+Register the plugin on your application and add the [access token](https://www.storyblok.com/docs/api/content-delivery#topics/authentication?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) of your Storyblok space. You can also add the `apiPlugin` in case that you want to use the Storyblok API Client:
+
+```js
+import { storyblokInit, apiPlugin } from "@storyblok/js";
+
+const { storyblokApi } = storyblokInit({
+ accessToken: "YOUR_ACCESS_TOKEN",
+ bridge: true / false,
+ use: [apiPlugin],
+});
+```
+
+That's it! All the features are enabled for you: the _Api Client_ for interacting with [Storyblok CDN API](https://www.storyblok.com/docs/api/content-delivery#topics/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js), and _Storyblok Bridge_ for [real-time visual editing experience](https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
+
+> You can enable/disable some of these features if you don't need them, so you save some KB. Please read the "Features and API" section
+
+### Getting Started
+
+`@storyblok/js` does three actions when you initialize it:
+
+- Provides a `storyblokApi` object in your app, which is an instance of [storyblok-js-client](https://github.com/storyblok/storyblok-js-client).
+- Loads [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) for real-time visual updates.
+- Provides a `storyblokEditable` function to link editable components to the Storyblok Visual Editor.
+
+#### 1. Fetching Content
+
+Inject `storyblokApi`:
+
+```js
+import { storyblokInit, apiPlugin } from "@storyblok/js";
+
+const { storyblokApi } = storyblokInit({
+ accessToken: "YOUR_ACCESS_TOKEN",
+ use: [apiPlugin],
+});
+
+const { data } = await storyblokApi.get("cdn/stories", { version: "draft" });
+
+```
+
+> Note: if you don't use `apiPlugin`, you can use your prefered method or function to fetch your data.
+
+#### 2. Listen to Storyblok Visual Editor events
+
+Use `useStoryBridge` to get the new story every time is triggered a `change` event from the Visual Editor. You need to pass the story id as first param, and a callback function as second param to update the new story:
+
+```js
+import { storyblokInit, apiPlugin, useStoryblokBridge } from "@storyblok/js";
+
+const { storyblokApi } = storyblokInit({
+ accessToken: "YOUR_ACCESS_TOKEN",
+ use: [apiPlugin],
+});
+
+const { data } = await storyblokApi.get("cdn/stories", { version: "draft" });
+
+const story = data ? data.story : null;
+
+useStoryblokBridge(story.id, (story) => (state.story = story));
+```
+
+You can pass [Bridge options](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) as a third parameter as well:
+
+```js
+useStoryblokBridge(story.id, (story) => (state.story = story), {
+ resolveRelations: ["Article.author"],
+});
+```
+
+#### 3. Link your components to Storyblok Visual Editor
+
+For every component you've defined in your Storyblok space, call the `storyblokEditable` function with the blok content:
+
+```js
+import { storyblokEditable } from "@storyblok/js";
+
+storyblokEditable(blok);
+```
+
+Where `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
+
+### Features and API
+
+You can **choose the features to use** when you initialize the plugin. In that way, you can improve Web Performance by optimizing your page load and save some bytes.
+
+#### Storyblok API
+
+You can use an `apiOptions` object. This is passed down to the (storyblok-js-client config object](https://github.com/storyblok/storyblok-js-client#class-storyblok):
+
+```js
+const { storyblokApi } = storyblokInit({
+ accessToken: "YOUR_ACCESS_TOKEN",
+ apiOptions: {
+ // storyblok-js-client config object
+ cache: { type: "memory" },
+ },
+ use: [apiPlugin],
+});
+```
+
+If you prefer to use your own fetch method, just remove the `apiPlugin` and `storyblok-js-client` won't be added to your application.
+
+```js
+storyblokInit({});
+```
+
+#### Storyblok Bridge
+
+You can conditionally load it by using the `bridge` option. Very useful if you want to disable it in production:
+
+```js
+const { storyblokApi } = storyblokInit({
+ bridge: process.env.NODE_ENV !== "production",
+});
+```
+
+If you don't use `useStoryblokBridge`, you have still access to the raw `window.StoryblokBridge`:
+
+```js
+const sbBridge = new window.StoryblokBridge(options);
+
+sbBridge.on(["input", "published", "change"], (event) => {
+ // ...
+});
+```
+
+## đ Related Links
+
+- **[Storyblok Technology Hub](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**: Storyblok integrates with every framework so that you are free to choose the best fit for your project. We prepared the technology hub so that you can find selected beginner tutorials, videos, boilerplates, and even cheatsheets all in one place.
+- **[Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**: Get a project ready in less than 5 minutes.
+- **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects and fieldtypes.
+
+## âšī¸ More Resources
+
+### Support
+
+- Bugs or Feature Requests? [Submit an issue](/../../issues/new).
+- Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
+
+### Contributing
+
+Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
+This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.
+
+### License
+
+This repository is published under the [MIT](./LICENSE) license.
diff --git a/lib/__tests__/.eslintrc b/lib/__tests__/.eslintrc
new file mode 100644
index 00000000..55f121d1
--- /dev/null
+++ b/lib/__tests__/.eslintrc
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "jest": true
+ }
+}
diff --git a/lib/__tests__/index.test.js b/lib/__tests__/index.test.js
new file mode 100644
index 00000000..7c18bfff
--- /dev/null
+++ b/lib/__tests__/index.test.js
@@ -0,0 +1,59 @@
+import { getLog } from "jest-console";
+import { storyblokInit, apiPlugin, storyblokEditable } from "@storyblok/js";
+
+describe("@storyblok/js", () => {
+ describe("Api", () => {
+ it("Is not loaded by default", () => {
+ const result = storyblokInit({
+ accessToken: "wANpEQEsMYGOwLxwXQ76Ggtt",
+ });
+
+ expect(result).toEqual({});
+ });
+
+ it("Is loaded correctly when using the apiPlugin", async () => {
+ const { storyblokApi } = storyblokInit({
+ accessToken: "wANpEQEsMYGOwLxwXQ76Ggtt",
+ use: [apiPlugin],
+ });
+
+ const result = await storyblokApi.getAll("cdn/stories");
+
+ expect(result.length).toBeGreaterThan(0);
+ });
+
+ it("Logs an error if no access token is provided", () => {
+ const { storyblokApi } = storyblokInit({
+ accessToken: null,
+ apiOptions: { accessToken: null },
+ use: [apiPlugin],
+ });
+
+ expect(getLog().logs).toEqual([
+ [
+ "error",
+ "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication",
+ ],
+ ]);
+ });
+ });
+
+ describe("Editable", () => {
+ it("Gets data-blok-c and data-blok-uid", async () => {
+ const { storyblokApi } = storyblokInit({
+ accessToken: "wANpEQEsMYGOwLxwXQ76Ggtt",
+ use: [apiPlugin],
+ });
+
+ const { data } = await storyblokApi.get("cdn/stories/demo");
+
+ let blok = data.story.content;
+ blok._editable = ``;
+
+ const editableResult = storyblokEditable(blok);
+
+ expect(editableResult["data-blok-c"]).toBeDefined();
+ expect(editableResult["data-blok-uid"]).toBeDefined();
+ });
+ });
+});
diff --git a/lib/cypress.json b/lib/cypress.json
new file mode 100644
index 00000000..28bcedc9
--- /dev/null
+++ b/lib/cypress.json
@@ -0,0 +1,5 @@
+{
+ "integration": {
+ "testFiles": "**/*.spec.js"
+ }
+}
diff --git a/lib/cypress/.eslintrc b/lib/cypress/.eslintrc
new file mode 100644
index 00000000..0f1b1514
--- /dev/null
+++ b/lib/cypress/.eslintrc
@@ -0,0 +1,3 @@
+{
+ "extends": ["plugin:cypress/recommended"]
+}
diff --git a/lib/cypress/fixtures/example.json b/lib/cypress/fixtures/example.json
new file mode 100644
index 00000000..02e42543
--- /dev/null
+++ b/lib/cypress/fixtures/example.json
@@ -0,0 +1,5 @@
+{
+ "name": "Using fixtures to represent data",
+ "email": "hello@cypress.io",
+ "body": "Fixtures are a great way to mock data for responses to routes"
+}
diff --git a/lib/cypress/integration/index.spec.js b/lib/cypress/integration/index.spec.js
new file mode 100644
index 00000000..5ebf51ae
--- /dev/null
+++ b/lib/cypress/integration/index.spec.js
@@ -0,0 +1,15 @@
+describe("@storyblok/js", () => {
+ describe("Bridge", () => {
+ it("Is loaded by default", () => {
+ cy.visit("http://localhost:3000/");
+ cy.get(".with-bridge").click();
+ cy.get("#storyblok-javascript-bridge").should("exist");
+ });
+
+ it("Is not loaded if options.bridge: false and errors in console", () => {
+ cy.visit("http://localhost:3000/");
+ cy.get(".without-bridge").click();
+ cy.get("#storyblok-javascript-bridge").should("not.exist");
+ });
+ });
+});
diff --git a/lib/cypress/support/commands.js b/lib/cypress/support/commands.js
new file mode 100644
index 00000000..119ab03f
--- /dev/null
+++ b/lib/cypress/support/commands.js
@@ -0,0 +1,25 @@
+// ***********************************************
+// This example commands.js shows you how to
+// create various custom commands and overwrite
+// existing commands.
+//
+// For more comprehensive examples of custom
+// commands please read more here:
+// https://on.cypress.io/custom-commands
+// ***********************************************
+//
+//
+// -- This is a parent command --
+// Cypress.Commands.add('login', (email, password) => { ... })
+//
+//
+// -- This is a child command --
+// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
+//
+//
+// -- This is a dual command --
+// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
+//
+//
+// -- This will overwrite an existing command --
+// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
diff --git a/lib/cypress/support/index.js b/lib/cypress/support/index.js
new file mode 100644
index 00000000..d68db96d
--- /dev/null
+++ b/lib/cypress/support/index.js
@@ -0,0 +1,20 @@
+// ***********************************************************
+// This example support/index.js is processed and
+// loaded automatically before your test files.
+//
+// This is a great place to put global configuration and
+// behavior that modifies Cypress.
+//
+// You can change the location of this file or turn off
+// automatically serving support files with the
+// 'supportFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/configuration
+// ***********************************************************
+
+// Import commands.js using ES2015 syntax:
+import './commands'
+
+// Alternatively you can use CommonJS syntax:
+// require('./commands')
diff --git a/lib/index.js b/lib/index.js
new file mode 100644
index 00000000..c4d5793d
--- /dev/null
+++ b/lib/index.js
@@ -0,0 +1,51 @@
+import { loadBridge } from "./modules/bridge";
+
+export const useStoryblokBridge = (id, cb, options = {}) => {
+ if (typeof window === "undefined") {
+ return;
+ }
+
+ if (typeof window.storyblokRegisterEvent === "undefined") {
+ console.error(
+ "Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js"
+ );
+
+ return;
+ }
+
+ window.storyblokRegisterEvent(() => {
+ const sbBridge = new window.StoryblokBridge(options);
+
+ sbBridge.on(["input", "published", "change"], (event) => {
+ if (event.action == "input" && event.story.id === id) {
+ cb(event.story);
+ } else {
+ window.location.reload();
+ }
+ });
+ });
+};
+
+export { default as apiPlugin } from "./modules/api";
+export { default as storyblokEditable } from "./modules/editable";
+
+export const storyblokInit = (pluginOptions = {}) => {
+ const { bridge, accessToken, use = [], apiOptions = {} } = pluginOptions;
+
+ apiOptions.accessToken = apiOptions.accessToken || accessToken;
+
+ // Initialize plugins
+ const options = { bridge, apiOptions };
+ let result = {};
+
+ use.forEach((pluginFactory) => {
+ result = { ...result, ...pluginFactory(options) };
+ });
+
+ // Load bridge
+ if (bridge !== false) {
+ loadBridge("https://app.storyblok.com/f/storyblok-v2-latest.js");
+ }
+
+ return result;
+};
diff --git a/lib/modules/api.js b/lib/modules/api.js
new file mode 100644
index 00000000..dddd3edf
--- /dev/null
+++ b/lib/modules/api.js
@@ -0,0 +1,14 @@
+import StoryblokClient from "storyblok-js-client";
+
+export default (options = {}) => {
+ const { apiOptions } = options;
+ if (!apiOptions.accessToken) {
+ console.error(
+ "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
+ );
+ return;
+ }
+
+ const storyblokApi = new StoryblokClient(apiOptions);
+ return { storyblokApi };
+};
diff --git a/lib/modules/bridge.js b/lib/modules/bridge.js
new file mode 100644
index 00000000..aff1e948
--- /dev/null
+++ b/lib/modules/bridge.js
@@ -0,0 +1,33 @@
+let loaded = false;
+const callbacks = [];
+
+export const loadBridge = (src) => {
+ // Way to make sure all event handlers are called after loading
+ window.storyblokRegisterEvent = (cb) => {
+ if (window.location === window.parent.location) {
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
+ return;
+ }
+
+ if (!loaded) callbacks.push(cb);
+ else cb();
+ };
+
+ return new Promise((resolve, reject) => {
+ if (document.getElementById("storyblok-javascript-bridge")) return;
+
+ const script = document.createElement("script");
+ script.async = true;
+ script.src = src;
+ script.id = "storyblok-javascript-bridge";
+
+ script.onerror = (error) => reject(error);
+ script.onload = (ev) => {
+ callbacks.forEach((cb) => cb());
+ loaded = true;
+ resolve(ev);
+ };
+
+ document.getElementsByTagName("head")[0].appendChild(script);
+ });
+};
diff --git a/lib/modules/editable.js b/lib/modules/editable.js
new file mode 100644
index 00000000..e721c4aa
--- /dev/null
+++ b/lib/modules/editable.js
@@ -0,0 +1,14 @@
+export default (blok) => {
+ if (typeof blok !== "object" || typeof blok._editable === "undefined") {
+ return {};
+ }
+
+ const options = JSON.parse(
+ blok._editable.replace(/^$/, "")
+ );
+
+ return {
+ "data-blok-c": JSON.stringify(options),
+ "data-blok-uid": options.id + "-" + options.uid,
+ };
+};
diff --git a/lib/package.json b/lib/package.json
new file mode 100644
index 00000000..b89a636b
--- /dev/null
+++ b/lib/package.json
@@ -0,0 +1,85 @@
+{
+ "name": "@storyblok/js",
+ "version": "0.0.1",
+ "description": "SDK to integrate Storyblok into your project using JavaScript.",
+ "main": "./dist/storyblok-js.js",
+ "module": "./dist/storyblok-js.mjs",
+ "files": [
+ "dist"
+ ],
+ "exports": {
+ ".": {
+ "import": "./dist/storyblok-js.mjs",
+ "require": "./dist/storyblok-js.js"
+ }
+ },
+ "scripts": {
+ "dev": "vite build --watch",
+ "build": "vite build",
+ "test": "npm run test:unit && npm run test:e2e",
+ "test:unit": "jest __tests__",
+ "test:e2e": "start-server-and-test cy:playground http-get://localhost:3000/ cy:run",
+ "test:e2e-watch": "start-server-and-test cy:playground http-get://localhost:3000/ cy:open",
+ "cy:playground": "npm run demo --prefix ../playground",
+ "cy:run": "cypress run --spec 'cypress/integration/*'",
+ "cy:open": "cypress open --spec 'cypress/integration/*'",
+ "prepublishOnly": "npm run build && cp ../README.md ./"
+ },
+ "dependencies": {
+ "storyblok-js-client": "^4.2.0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.15.0",
+ "@babel/preset-env": "^7.16.11",
+ "babel-jest": "^26.6.3",
+ "cypress": "^8.3.0",
+ "eslint-plugin-cypress": "^2.12.1",
+ "eslint-plugin-jest": "^25.2.4",
+ "jest": "^26.6.3",
+ "jest-console": "^0.1.0",
+ "start-server-and-test": "^1.14.0",
+ "vite": "^2.4.4"
+ },
+ "babel": {
+ "presets": [
+ [
+ "@babel/preset-env",
+ {
+ "targets": {
+ "node": "current"
+ }
+ }
+ ]
+ ]
+ },
+ "eslintConfig": {
+ "env": {
+ "node": true
+ }
+ },
+ "jest": {
+ "moduleFileExtensions": [
+ "js",
+ "json"
+ ],
+ "transform": {
+ "^.+\\.js$": "babel-jest"
+ }
+ },
+ "release": {
+ "branches": [
+ "master",
+ "next"
+ ]
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/storyblok/storyblok-js"
+ },
+ "author": "Storyblok",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/storyblok/storyblok-js/issues"
+ },
+ "homepage": "https://github.com/storyblok/storyblok-js"
+}
diff --git a/lib/vite.config.js b/lib/vite.config.js
new file mode 100644
index 00000000..321f6590
--- /dev/null
+++ b/lib/vite.config.js
@@ -0,0 +1,20 @@
+import { defineConfig } from "vite";
+import path from "path";
+
+const libName = "storyblok-js"
+
+export default defineConfig(() => {
+ return {
+ build: {
+ lib: {
+ entry: path.resolve(__dirname, "index.js"),
+ name: "storyblok",
+ fileName: format => format === "es" ? `${libName}.mjs` : `${libName}.js`
+ },
+ rollupOptions: {
+ output: {
+ },
+ },
+ },
+ };
+});
diff --git a/package.json b/package.json
new file mode 100644
index 00000000..0f0e9df5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "@storyblok/js-workspace",
+ "private": true,
+ "version": "0.0.1",
+ "workspaces": ["./lib", "./playground"],
+ "scripts": {
+ "dev": "npm run dev --workspace=lib & npm run demo",
+ "demo": "npm run demo --workspace=playground",
+ "build": "npm run build --workspace=lib",
+ "test:unit": "npm run test:unit --workspace=lib",
+ "test:e2e": "npm run test:e2e --workspace=lib",
+ "prepare": "husky install"
+ },
+ "devDependencies": {
+ "@commitlint/cli": "^14.1.0",
+ "@commitlint/config-conventional": "^14.1.0",
+ "eslint": "^8.2.0",
+ "eslint-config-prettier": "^8.3.0",
+ "husky": "^7.0.4",
+ "lint-staged": "^11.2.6",
+ "prettier": "^2.4.1"
+ },
+ "lint-staged": {
+ "*.{vue,svelte,js,jsx,css}": ["prettier --write", "eslint"],
+ "*.md": ["prettier --write"]
+ },
+ "commitlint": {
+ "extends": ["@commitlint/config-conventional"]
+ },
+ "eslintConfig": {
+ "extends": ["eslint:recommended", "prettier"],
+ "ignorePatterns": "dist/"
+ },
+ "prettier": {
+ "trailingComma": "es5",
+ "tabWidth": 2,
+ "semi": true,
+ "singleQuote": false
+ }
+}
diff --git a/playground/index.html b/playground/index.html
new file mode 100644
index 00000000..851a5602
--- /dev/null
+++ b/playground/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+ JS App
+
+
+ Hello
+
+ storyblokInit With Bridge
+
+
+ storyblokInit Without Bridge
+
+
+
+
+
diff --git a/playground/main.js b/playground/main.js
new file mode 100644
index 00000000..2cf74eda
--- /dev/null
+++ b/playground/main.js
@@ -0,0 +1,14 @@
+import { storyblokInit } from "@storyblok/js";
+
+window.initWithBridge = () => {
+ storyblokInit({
+ accessToken: "wANpEQEsMYGOwLxwXQ76Ggtt",
+ });
+};
+
+window.initWithoutBridge = () => {
+ storyblokInit({
+ accessToken: "wANpEQEsMYGOwLxwXQ76Ggtt",
+ bridge: false,
+ });
+};
diff --git a/playground/package.json b/playground/package.json
new file mode 100644
index 00000000..b9d89ace
--- /dev/null
+++ b/playground/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "@storyblok/js-playground",
+ "version": "0.0.1",
+ "scripts": {
+ "demo": "vite",
+ "build": "vite build"
+ },
+ "devDependencies": {
+ "@storyblok/js": "^0.0.1",
+ "vite": "^2.4.4"
+ }
+}
diff --git a/playground/vite.config.js b/playground/vite.config.js
new file mode 100644
index 00000000..5d0ec3b2
--- /dev/null
+++ b/playground/vite.config.js
@@ -0,0 +1,6 @@
+import { defineConfig } from "vite";
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [],
+});