From 1c1e82ea1f32c24c4ca66bdf74ad327c29c4bd4e Mon Sep 17 00:00:00 2001 From: megantipps Date: Tue, 23 May 2023 15:58:20 +0200 Subject: [PATCH 1/7] initial sandpack commit --- integrations/figma/.env | 2 + integrations/sandpack/.eslintrc.json | 3 + integrations/sandpack/gitbook-manifest.yaml | 17 + integrations/sandpack/package.json | 16 + integrations/sandpack/src/index.tsx | 45 + integrations/sandpack/tsconfig.json | 3 + package-lock.json | 938 +++++++++++++++++++- 7 files changed, 1020 insertions(+), 4 deletions(-) create mode 100644 integrations/figma/.env create mode 100644 integrations/sandpack/.eslintrc.json create mode 100644 integrations/sandpack/gitbook-manifest.yaml create mode 100644 integrations/sandpack/package.json create mode 100644 integrations/sandpack/src/index.tsx create mode 100644 integrations/sandpack/tsconfig.json diff --git a/integrations/figma/.env b/integrations/figma/.env new file mode 100644 index 000000000..bbcaa6938 --- /dev/null +++ b/integrations/figma/.env @@ -0,0 +1,2 @@ +FIGMA_CLIENT_ID=5eCnrBa2kzuYg1yxfsclEc +FIGMA_CLIENT_SECRET=C4veOJNl3QH15XuZqVSJzg22oh2yvj diff --git a/integrations/sandpack/.eslintrc.json b/integrations/sandpack/.eslintrc.json new file mode 100644 index 000000000..99e7792b9 --- /dev/null +++ b/integrations/sandpack/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["@gitbook/eslint-config/integration"] +} \ No newline at end of file diff --git a/integrations/sandpack/gitbook-manifest.yaml b/integrations/sandpack/gitbook-manifest.yaml new file mode 100644 index 000000000..0ef8493f3 --- /dev/null +++ b/integrations/sandpack/gitbook-manifest.yaml @@ -0,0 +1,17 @@ +name: sandpack +title: Sandpack +organization: the-delta-integrations +visibility: private +description: '' +script: src/index.tsx +scopes: + - space:content:read + - space:content:write + - space:metadata:read + - space:metadata:write + - space:views:read +blocks: + - id: sandpack + title: Sandpack + description: TODO Sandpack description +secrets: {} diff --git a/integrations/sandpack/package.json b/integrations/sandpack/package.json new file mode 100644 index 000000000..5ec7d5821 --- /dev/null +++ b/integrations/sandpack/package.json @@ -0,0 +1,16 @@ +{ + "name": "sandpack", + "private": true, + "scripts": { + "lint": "eslint ./**/*.ts*", + "typecheck": "tsc --noEmit", + "publish-integrations-staging": "gitbook publish ." + }, + "devDependencies": { + "@gitbook/cli": "^0.8.0", + "@gitbook/runtime": "latest" + }, + "dependencies": { + "@gitbook/api": "^0.3.0" + } +} diff --git a/integrations/sandpack/src/index.tsx b/integrations/sandpack/src/index.tsx new file mode 100644 index 000000000..392d6180b --- /dev/null +++ b/integrations/sandpack/src/index.tsx @@ -0,0 +1,45 @@ +import { + createIntegration, + createComponent, + FetchEventCallback, + RuntimeContext, +} from '@gitbook/runtime'; + +type IntegrationContext = {} & RuntimeContext; + +const handleFetchEvent: FetchEventCallback = async (request, context) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { api } = context; + const user = api.user.getAuthenticatedUser(); + + return new Response(JSON.stringify(user)); +}; + +const exampleBlock = createComponent({ + componentId: 'sandpack', + initialState: (props) => { + return { + message: 'Click Me', + }; + }, + action: async (element, action, context) => { + switch (action.action) { + case 'click': + console.log('Button Clicked'); + return {}; + } + }, + render: async (element, action, context) => { + return ( + +