@sanity/workbench 0.0.1-alpha.0 → 0.1.0-alpha.2
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/LICENSE +21 -0
- package/dist/_internal.d.ts +34 -0
- package/dist/_internal.js +38 -0
- package/dist/_internal.js.map +1 -0
- package/package.json +17 -23
- package/src/_exports/_internal.ts +1 -0
- package/src/_internal/index.ts +2 -0
- package/src/_internal/render.test.ts +18 -0
- package/src/_internal/render.ts +95 -0
- package/dist/index.cjs +0 -16
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/src/index.tsx +0 -35
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sanity.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workbench configuration.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare type Config = undefined;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Module Federation instance, loads a remote workbench
|
|
10
|
+
* application, and renders it into the provided root element.
|
|
11
|
+
*
|
|
12
|
+
* @param rootElement - The DOM element to render into
|
|
13
|
+
* @param config - Workbench configuration (reserved for future use)
|
|
14
|
+
* @param options - Rendering options forwarded to the remote
|
|
15
|
+
* @returns A cleanup function that unmounts the remote application
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderWorkbench(
|
|
20
|
+
rootElement: HTMLElement,
|
|
21
|
+
config?: Config,
|
|
22
|
+
options?: RenderWorkbenchOptions,
|
|
23
|
+
): Promise<() => void>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Options for rendering the workbench.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare interface RenderWorkbenchOptions {
|
|
31
|
+
reactStrictMode?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createInstance } from "@sanity/federation/runtime";
|
|
2
|
+
const REMOTE_NAME = "workbench-remote", REMOTE_MODULE = "App";
|
|
3
|
+
async function renderWorkbench(rootElement, config, options) {
|
|
4
|
+
if (!rootElement)
|
|
5
|
+
throw new Error("Missing root element to mount application into");
|
|
6
|
+
const remoteUrl = import.meta.env.SANITY_INTERNAL_WORKBENCH_REMOTE_URL;
|
|
7
|
+
if (!remoteUrl)
|
|
8
|
+
throw new Error("SANITY_INTERNAL_WORKBENCH_REMOTE_URL is not set");
|
|
9
|
+
const mf = createInstance({
|
|
10
|
+
name: "sanity-workbench"
|
|
11
|
+
});
|
|
12
|
+
mf.registerRemotes([
|
|
13
|
+
{
|
|
14
|
+
name: REMOTE_NAME,
|
|
15
|
+
entry: remoteUrl
|
|
16
|
+
}
|
|
17
|
+
]);
|
|
18
|
+
let remoteModule;
|
|
19
|
+
try {
|
|
20
|
+
remoteModule = await mf.loadRemote(
|
|
21
|
+
`${REMOTE_NAME}/${REMOTE_MODULE}`
|
|
22
|
+
);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Failed to load remote workbench module from "${remoteUrl}"`,
|
|
26
|
+
{ cause: error }
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (!remoteModule || typeof remoteModule.render != "function")
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Remote module from "${remoteUrl}" did not expose a render function`
|
|
32
|
+
);
|
|
33
|
+
return remoteModule.render(rootElement, config, options);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
renderWorkbench
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=_internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_internal.js","sources":["../src/_internal/render.ts"],"sourcesContent":["import { createInstance } from \"@sanity/federation/runtime\";\n\n/**\n * Workbench configuration.\n *\n * @public\n */\nexport type Config = undefined;\n\n/**\n * Options for rendering the workbench.\n *\n * @public\n */\nexport interface RenderWorkbenchOptions {\n reactStrictMode?: boolean;\n}\n\ndeclare global {\n interface ImportMetaEnv {\n readonly SANITY_INTERNAL_WORKBENCH_REMOTE_URL: string;\n }\n interface ImportMeta {\n readonly env: ImportMetaEnv;\n }\n}\n\nconst REMOTE_NAME = \"workbench-remote\";\nconst REMOTE_MODULE = \"App\";\n\ninterface RemoteModule {\n render(\n rootElement: HTMLElement,\n config?: Config,\n options?: RenderWorkbenchOptions,\n ): () => void;\n}\n\n/**\n * Creates a Module Federation instance, loads a remote workbench\n * application, and renders it into the provided root element.\n *\n * @param rootElement - The DOM element to render into\n * @param config - Workbench configuration (reserved for future use)\n * @param options - Rendering options forwarded to the remote\n * @returns A cleanup function that unmounts the remote application\n *\n * @public\n */\nexport async function renderWorkbench(\n rootElement: HTMLElement,\n config?: Config,\n options?: RenderWorkbenchOptions,\n): Promise<() => void> {\n if (!rootElement) {\n throw new Error(\"Missing root element to mount application into\");\n }\n\n const remoteUrl = import.meta.env.SANITY_INTERNAL_WORKBENCH_REMOTE_URL;\n\n if (!remoteUrl) {\n throw new Error(\"SANITY_INTERNAL_WORKBENCH_REMOTE_URL is not set\");\n }\n\n const mf = createInstance({\n name: \"sanity-workbench\",\n });\n\n mf.registerRemotes([\n {\n name: REMOTE_NAME,\n entry: remoteUrl,\n },\n ]);\n\n let remoteModule: RemoteModule | null;\n try {\n remoteModule = await mf.loadRemote<RemoteModule>(\n `${REMOTE_NAME}/${REMOTE_MODULE}`,\n );\n } catch (error) {\n throw new Error(\n `Failed to load remote workbench module from \"${remoteUrl}\"`,\n { cause: error },\n );\n }\n\n if (!remoteModule || typeof remoteModule.render !== \"function\") {\n throw new Error(\n `Remote module from \"${remoteUrl}\" did not expose a render function`,\n );\n }\n\n return remoteModule.render(rootElement, config, options);\n}\n"],"names":[],"mappings":";AA2BA,MAAM,cAAc,oBACd,gBAAgB;AAqBtB,eAAsB,gBACpB,aACA,QACA,SACqB;AACrB,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,gDAAgD;AAGlE,QAAM,YAAY,YAAY,IAAI;AAElC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,iDAAiD;AAGnE,QAAM,KAAK,eAAe;AAAA,IACxB,MAAM;AAAA,EAAA,CACP;AAED,KAAG,gBAAgB;AAAA,IACjB;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,IAAA;AAAA,EACT,CACD;AAED,MAAI;AACJ,MAAI;AACF,mBAAe,MAAM,GAAG;AAAA,MACtB,GAAG,WAAW,IAAI,aAAa;AAAA,IAAA;AAAA,EAEnC,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,gDAAgD,SAAS;AAAA,MACzD,EAAE,OAAO,MAAA;AAAA,IAAM;AAAA,EAEnB;AAEA,MAAI,CAAC,gBAAgB,OAAO,aAAa,UAAW;AAClD,UAAM,IAAI;AAAA,MACR,uBAAuB,SAAS;AAAA,IAAA;AAIpC,SAAO,aAAa,OAAO,aAAa,QAAQ,OAAO;AACzD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/workbench",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Workbench component for the Sanity Content Operating System",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/sanity-io/workbench/packages/@sanity/workbench#readme",
|
|
@@ -20,36 +20,30 @@
|
|
|
20
20
|
"type": "module",
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"exports": {
|
|
23
|
-
"
|
|
24
|
-
"source": "./src/
|
|
25
|
-
"
|
|
26
|
-
"default": "./dist/index.js"
|
|
23
|
+
"./_internal": {
|
|
24
|
+
"source": "./src/_exports/_internal.ts",
|
|
25
|
+
"default": "./dist/_internal.js"
|
|
27
26
|
},
|
|
28
27
|
"./package.json": "./package.json"
|
|
29
28
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"check:lint": "oxlint",
|
|
33
|
-
"check:lint:fix": "oxlint --fix",
|
|
34
|
-
"check:types": "tsc --noEmit",
|
|
35
|
-
"dev": "pkg watch"
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@sanity/federation": "0.1.0-alpha.2"
|
|
36
31
|
},
|
|
37
32
|
"devDependencies": {
|
|
38
|
-
"@repo/oxc-config": "workspace:*",
|
|
39
|
-
"@repo/tsconfig": "workspace:*",
|
|
40
33
|
"@sanity/pkg-utils": "^9.2.3",
|
|
41
|
-
"
|
|
42
|
-
"@
|
|
43
|
-
"
|
|
44
|
-
"react-dom": "catalog:",
|
|
45
|
-
"typescript": "catalog:"
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"react": "catalog:",
|
|
49
|
-
"react-dom": "catalog:"
|
|
34
|
+
"typescript": "^5.9.2",
|
|
35
|
+
"@repo/oxc-config": "0.0.0",
|
|
36
|
+
"@repo/tsconfig": "0.0.1"
|
|
50
37
|
},
|
|
51
38
|
"browserslist": "extends @sanity/browserslist-config",
|
|
52
39
|
"engines": {
|
|
53
40
|
"node": ">=20.19.1 <22 || >=22.12"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "pkg build --strict --clean --check",
|
|
44
|
+
"check:lint": "oxlint",
|
|
45
|
+
"check:lint:fix": "oxlint --fix",
|
|
46
|
+
"check:types": "tsc --noEmit",
|
|
47
|
+
"dev": "pkg watch"
|
|
54
48
|
}
|
|
55
|
-
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../_internal";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { renderWorkbench } from "./render";
|
|
4
|
+
|
|
5
|
+
describe("renderWorkbench", () => {
|
|
6
|
+
it("throws when rootElement is missing", async () => {
|
|
7
|
+
await expect(
|
|
8
|
+
renderWorkbench(null as unknown as HTMLElement),
|
|
9
|
+
).rejects.toThrow("Missing root element to mount application into");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("throws when SANITY_INTERNAL_WORKBENCH_REMOTE_URL is not set", async () => {
|
|
13
|
+
const el = document.createElement("div");
|
|
14
|
+
await expect(renderWorkbench(el)).rejects.toThrow(
|
|
15
|
+
"SANITY_INTERNAL_WORKBENCH_REMOTE_URL is not set",
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createInstance } from "@sanity/federation/runtime";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Workbench configuration.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type Config = undefined;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options for rendering the workbench.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface RenderWorkbenchOptions {
|
|
16
|
+
reactStrictMode?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare global {
|
|
20
|
+
interface ImportMetaEnv {
|
|
21
|
+
readonly SANITY_INTERNAL_WORKBENCH_REMOTE_URL: string;
|
|
22
|
+
}
|
|
23
|
+
interface ImportMeta {
|
|
24
|
+
readonly env: ImportMetaEnv;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const REMOTE_NAME = "workbench-remote";
|
|
29
|
+
const REMOTE_MODULE = "App";
|
|
30
|
+
|
|
31
|
+
interface RemoteModule {
|
|
32
|
+
render(
|
|
33
|
+
rootElement: HTMLElement,
|
|
34
|
+
config?: Config,
|
|
35
|
+
options?: RenderWorkbenchOptions,
|
|
36
|
+
): () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Module Federation instance, loads a remote workbench
|
|
41
|
+
* application, and renders it into the provided root element.
|
|
42
|
+
*
|
|
43
|
+
* @param rootElement - The DOM element to render into
|
|
44
|
+
* @param config - Workbench configuration (reserved for future use)
|
|
45
|
+
* @param options - Rendering options forwarded to the remote
|
|
46
|
+
* @returns A cleanup function that unmounts the remote application
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export async function renderWorkbench(
|
|
51
|
+
rootElement: HTMLElement,
|
|
52
|
+
config?: Config,
|
|
53
|
+
options?: RenderWorkbenchOptions,
|
|
54
|
+
): Promise<() => void> {
|
|
55
|
+
if (!rootElement) {
|
|
56
|
+
throw new Error("Missing root element to mount application into");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const remoteUrl = import.meta.env.SANITY_INTERNAL_WORKBENCH_REMOTE_URL;
|
|
60
|
+
|
|
61
|
+
if (!remoteUrl) {
|
|
62
|
+
throw new Error("SANITY_INTERNAL_WORKBENCH_REMOTE_URL is not set");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const mf = createInstance({
|
|
66
|
+
name: "sanity-workbench",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
mf.registerRemotes([
|
|
70
|
+
{
|
|
71
|
+
name: REMOTE_NAME,
|
|
72
|
+
entry: remoteUrl,
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
let remoteModule: RemoteModule | null;
|
|
77
|
+
try {
|
|
78
|
+
remoteModule = await mf.loadRemote<RemoteModule>(
|
|
79
|
+
`${REMOTE_NAME}/${REMOTE_MODULE}`,
|
|
80
|
+
);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Failed to load remote workbench module from "${remoteUrl}"`,
|
|
84
|
+
{ cause: error },
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!remoteModule || typeof remoteModule.render !== "function") {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`Remote module from "${remoteUrl}" did not expose a render function`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return remoteModule.render(rootElement, config, options);
|
|
95
|
+
}
|
package/dist/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var jsxRuntime = require("react/jsx-runtime"), react = require("react"), client = require("react-dom/client");
|
|
4
|
-
function Workbench(_props) {
|
|
5
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h1", { children: "Hello World" });
|
|
6
|
-
}
|
|
7
|
-
function renderWorkbench(rootElement, config, options) {
|
|
8
|
-
if (!rootElement)
|
|
9
|
-
throw new Error("Missing root element to mount application into");
|
|
10
|
-
const root = client.createRoot(rootElement), workbench = /* @__PURE__ */ jsxRuntime.jsx(Workbench, { config });
|
|
11
|
-
return root.render(
|
|
12
|
-
options?.reactStrictMode ? /* @__PURE__ */ jsxRuntime.jsx(react.StrictMode, { children: workbench }) : workbench
|
|
13
|
-
), () => root.unmount();
|
|
14
|
-
}
|
|
15
|
-
exports.renderWorkbench = renderWorkbench;
|
|
16
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.tsx"],"sourcesContent":["import { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\n\ninterface WorkbenchProps {\n config: undefined;\n}\n\nfunction Workbench(_props: WorkbenchProps) {\n return <h1>Hello World</h1>;\n}\n\ninterface RenderWorkbenchOptions {\n reactStrictMode: boolean;\n}\n\nexport function renderWorkbench(\n rootElement: HTMLElement,\n config: Config,\n options?: RenderWorkbenchOptions,\n): () => void {\n if (!rootElement) {\n throw new Error(\"Missing root element to mount application into\");\n }\n\n const root = createRoot(rootElement);\n const workbench = <Workbench config={config} />;\n\n root.render(\n options?.reactStrictMode ? <StrictMode>{workbench}</StrictMode> : workbench,\n );\n\n return () => root.unmount();\n}\n\nexport type Config = WorkbenchProps[\"config\"];\n"],"names":["jsx","createRoot","StrictMode"],"mappings":";;;AAOA,SAAS,UAAU,QAAwB;AACzC,SAAOA,2BAAAA,IAAC,QAAG,UAAA,cAAA,CAAW;AACxB;AAMO,SAAS,gBACd,aACA,QACA,SACY;AACZ,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,gDAAgD;AAGlE,QAAM,OAAOC,OAAAA,WAAW,WAAW,GAC7B,YAAYD,+BAAC,aAAU,QAAgB;AAE7C,SAAA,KAAK;AAAA,IACH,SAAS,kBAAkBA,+BAACE,MAAAA,YAAA,EAAY,qBAAU,IAAgB;AAAA,EAAA,GAG7D,MAAM,KAAK,QAAA;AACpB;;"}
|
package/dist/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { StrictMode } from "react";
|
|
3
|
-
import { createRoot } from "react-dom/client";
|
|
4
|
-
function Workbench(_props) {
|
|
5
|
-
return /* @__PURE__ */ jsx("h1", { children: "Hello World" });
|
|
6
|
-
}
|
|
7
|
-
function renderWorkbench(rootElement, config, options) {
|
|
8
|
-
if (!rootElement)
|
|
9
|
-
throw new Error("Missing root element to mount application into");
|
|
10
|
-
const root = createRoot(rootElement), workbench = /* @__PURE__ */ jsx(Workbench, { config });
|
|
11
|
-
return root.render(
|
|
12
|
-
options?.reactStrictMode ? /* @__PURE__ */ jsx(StrictMode, { children: workbench }) : workbench
|
|
13
|
-
), () => root.unmount();
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
renderWorkbench
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\n\ninterface WorkbenchProps {\n config: undefined;\n}\n\nfunction Workbench(_props: WorkbenchProps) {\n return <h1>Hello World</h1>;\n}\n\ninterface RenderWorkbenchOptions {\n reactStrictMode: boolean;\n}\n\nexport function renderWorkbench(\n rootElement: HTMLElement,\n config: Config,\n options?: RenderWorkbenchOptions,\n): () => void {\n if (!rootElement) {\n throw new Error(\"Missing root element to mount application into\");\n }\n\n const root = createRoot(rootElement);\n const workbench = <Workbench config={config} />;\n\n root.render(\n options?.reactStrictMode ? <StrictMode>{workbench}</StrictMode> : workbench,\n );\n\n return () => root.unmount();\n}\n\nexport type Config = WorkbenchProps[\"config\"];\n"],"names":[],"mappings":";;;AAOA,SAAS,UAAU,QAAwB;AACzC,SAAO,oBAAC,QAAG,UAAA,cAAA,CAAW;AACxB;AAMO,SAAS,gBACd,aACA,QACA,SACY;AACZ,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,gDAAgD;AAGlE,QAAM,OAAO,WAAW,WAAW,GAC7B,YAAY,oBAAC,aAAU,QAAgB;AAE7C,SAAA,KAAK;AAAA,IACH,SAAS,kBAAkB,oBAAC,YAAA,EAAY,qBAAU,IAAgB;AAAA,EAAA,GAG7D,MAAM,KAAK,QAAA;AACpB;"}
|
package/src/index.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { StrictMode } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
interface WorkbenchProps {
|
|
5
|
-
config: undefined;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function Workbench(_props: WorkbenchProps) {
|
|
9
|
-
return <h1>Hello World</h1>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface RenderWorkbenchOptions {
|
|
13
|
-
reactStrictMode: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function renderWorkbench(
|
|
17
|
-
rootElement: HTMLElement,
|
|
18
|
-
config: Config,
|
|
19
|
-
options?: RenderWorkbenchOptions,
|
|
20
|
-
): () => void {
|
|
21
|
-
if (!rootElement) {
|
|
22
|
-
throw new Error("Missing root element to mount application into");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const root = createRoot(rootElement);
|
|
26
|
-
const workbench = <Workbench config={config} />;
|
|
27
|
-
|
|
28
|
-
root.render(
|
|
29
|
-
options?.reactStrictMode ? <StrictMode>{workbench}</StrictMode> : workbench,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
return () => root.unmount();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type Config = WorkbenchProps["config"];
|