@unityevolv/ofiskit-ui-builder 0.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.
- package/LICENSE +661 -0
- package/README.md +30 -0
- package/dist/BuilderSteps.d.ts +35 -0
- package/dist/BuilderSteps.d.ts.map +1 -0
- package/dist/BuilderSteps.js +104 -0
- package/dist/BuilderSteps.js.map +1 -0
- package/dist/OfficeBuilder.d.ts +30 -0
- package/dist/OfficeBuilder.d.ts.map +1 -0
- package/dist/OfficeBuilder.js +55 -0
- package/dist/OfficeBuilder.js.map +1 -0
- package/dist/background/BackgroundStep.d.ts +35 -0
- package/dist/background/BackgroundStep.d.ts.map +1 -0
- package/dist/background/BackgroundStep.js +104 -0
- package/dist/background/BackgroundStep.js.map +1 -0
- package/dist/background/darkVersion.d.ts +25 -0
- package/dist/background/darkVersion.d.ts.map +1 -0
- package/dist/background/darkVersion.js +124 -0
- package/dist/background/darkVersion.js.map +1 -0
- package/dist/canvas/BuilderCanvas.d.ts +32 -0
- package/dist/canvas/BuilderCanvas.d.ts.map +1 -0
- package/dist/canvas/BuilderCanvas.js +40 -0
- package/dist/canvas/BuilderCanvas.js.map +1 -0
- package/dist/canvas/RoomShape.d.ts +27 -0
- package/dist/canvas/RoomShape.d.ts.map +1 -0
- package/dist/canvas/RoomShape.js +45 -0
- package/dist/canvas/RoomShape.js.map +1 -0
- package/dist/canvas/geometry.d.ts +115 -0
- package/dist/canvas/geometry.d.ts.map +1 -0
- package/dist/canvas/geometry.js +222 -0
- package/dist/canvas/geometry.js.map +1 -0
- package/dist/canvas/types.d.ts +47 -0
- package/dist/canvas/types.d.ts.map +1 -0
- package/dist/canvas/types.js +2 -0
- package/dist/canvas/types.js.map +1 -0
- package/dist/canvas/useCanvasDrag.d.ts +35 -0
- package/dist/canvas/useCanvasDrag.d.ts.map +1 -0
- package/dist/canvas/useCanvasDrag.js +138 -0
- package/dist/canvas/useCanvasDrag.js.map +1 -0
- package/dist/canvas/useCanvasKeys.d.ts +11 -0
- package/dist/canvas/useCanvasKeys.d.ts.map +1 -0
- package/dist/canvas/useCanvasKeys.js +43 -0
- package/dist/canvas/useCanvasKeys.js.map +1 -0
- package/dist/history.d.ts +31 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +49 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/panel/AreaInspector.d.ts +10 -0
- package/dist/panel/AreaInspector.d.ts.map +1 -0
- package/dist/panel/AreaInspector.js +30 -0
- package/dist/panel/AreaInspector.js.map +1 -0
- package/dist/panel/RoomInspector.d.ts +16 -0
- package/dist/panel/RoomInspector.d.ts.map +1 -0
- package/dist/panel/RoomInspector.js +26 -0
- package/dist/panel/RoomInspector.js.map +1 -0
- package/dist/panel/SaveBar.d.ts +7 -0
- package/dist/panel/SaveBar.d.ts.map +1 -0
- package/dist/panel/SaveBar.js +16 -0
- package/dist/panel/SaveBar.js.map +1 -0
- package/dist/panel/TemplateDetails.d.ts +16 -0
- package/dist/panel/TemplateDetails.d.ts.map +1 -0
- package/dist/panel/TemplateDetails.js +16 -0
- package/dist/panel/TemplateDetails.js.map +1 -0
- package/dist/panel/ToolBar.d.ts +34 -0
- package/dist/panel/ToolBar.d.ts.map +1 -0
- package/dist/panel/ToolBar.js +8 -0
- package/dist/panel/ToolBar.js.map +1 -0
- package/dist/prompt/PromptStep.d.ts +23 -0
- package/dist/prompt/PromptStep.d.ts.map +1 -0
- package/dist/prompt/PromptStep.js +24 -0
- package/dist/prompt/PromptStep.js.map +1 -0
- package/dist/prompt/prompt.d.ts +59 -0
- package/dist/prompt/prompt.d.ts.map +1 -0
- package/dist/prompt/prompt.js +40 -0
- package/dist/prompt/prompt.js.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolBar.js","sourceRoot":"","sources":["../../src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AAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAC7D,KAAK,EAAC,oBAAoB,GAC1B,EACD,KAAK,CAAC,UAAU,IAAI,CACnB,KAAC,MAAM,IACL,OAAO,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,EAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAC7D,KAAK,EAAC,wBAAwB,GAC9B,CACH,IACG,EAEL,KAAK,CAAC,WAAW,IAAI,CACpB,eAAK,SAAS,EAAC,YAAY,aACzB,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,8BAEpE,EACT,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,6BAEnE,IACL,CACP,IACO,CACX,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CanvasShape } from '@unityevolv/ofiskit-template';
|
|
2
|
+
import { type PromptDocument } from './prompt.js';
|
|
3
|
+
/**
|
|
4
|
+
* Step one, before a single room is drawn: the prompt for the picture.
|
|
5
|
+
*
|
|
6
|
+
* An author who opens a drawing tool with no background has nothing to draw on,
|
|
7
|
+
* and "find a top-down floor plan" is not a task most people can do. So this
|
|
8
|
+
* step hands them a prompt that already works, with the shape and resolution
|
|
9
|
+
* filled in and the parts worth changing exposed as fields.
|
|
10
|
+
*
|
|
11
|
+
* The canvas shape is chosen here because it cannot change afterwards: every
|
|
12
|
+
* room is placed relative to it. The step says so rather than letting somebody
|
|
13
|
+
* find out after an hour of drawing.
|
|
14
|
+
*/
|
|
15
|
+
export interface PromptStepProps {
|
|
16
|
+
document: PromptDocument;
|
|
17
|
+
shape: CanvasShape;
|
|
18
|
+
onShapeChange(shape: CanvasShape): void;
|
|
19
|
+
/** What choosing a different shape would undo, said before it happens. */
|
|
20
|
+
shapeChangeWarning?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function PromptStep(props: PromptStepProps): import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=PromptStep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptStep.d.ts","sourceRoot":"","sources":["../../src/prompt/PromptStep.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG9E,OAAO,EAIL,KAAK,cAAc,EAEpB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,cAAc,CAAA;IACxB,KAAK,EAAE,WAAW,CAAA;IAClB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACvC,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,+BAkIhD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, Button, Icon, Input, Textarea } from '@unityevolv/unitykit';
|
|
3
|
+
import { CANVAS_SHAPES } from '@unityevolv/ofiskit-template';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { applyPreset, defaultSlots, renderPrompt, } from './prompt.js';
|
|
6
|
+
export function PromptStep(props) {
|
|
7
|
+
const { document: prompt, shape } = props;
|
|
8
|
+
const [values, setValues] = useState(() => defaultSlots(prompt));
|
|
9
|
+
const [copied, setCopied] = useState(false);
|
|
10
|
+
const text = useMemo(() => renderPrompt(prompt, shape, values), [prompt, shape, values]);
|
|
11
|
+
return (_jsxs("div", { className: "mx-auto grid max-w-5xl gap-6 p-4 lg:grid-cols-[1fr_20rem]", children: [_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-lg font-semibold", children: "Choose the shape of your office" }), _jsx("p", { className: "mt-1 text-sm text-base-content/75", children: "This cannot change once rooms are placed, because every room is positioned against it." }), _jsx("div", { className: "mt-3 flex flex-wrap gap-2", children: CANVAS_SHAPES.map((candidate) => (_jsxs("button", { type: "button", onClick: () => props.onShapeChange(candidate), "aria-pressed": shape === candidate, className: [
|
|
12
|
+
'rounded-lg border px-3 py-2 text-sm',
|
|
13
|
+
'focus-visible:outline-2 focus-visible:outline-primary',
|
|
14
|
+
shape === candidate
|
|
15
|
+
? 'border-primary bg-primary/10 font-medium'
|
|
16
|
+
: 'border-base-300 hover:bg-base-200',
|
|
17
|
+
].join(' '), children: [prompt.canvases[candidate].label, _jsx("span", { className: "block text-xs text-base-content", children: prompt.canvases[candidate].resolution })] }, candidate))) }), props.shapeChangeWarning && (_jsx(Alert, { variant: "warn", className: "mt-3", children: props.shapeChangeWarning }))] }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h2", { className: "text-lg font-semibold", children: "The prompt" }), _jsxs(Button, { size: "sm", variant: "ghost", onClick: () => {
|
|
18
|
+
void navigator.clipboard.writeText(text).then(() => {
|
|
19
|
+
setCopied(true);
|
|
20
|
+
setTimeout(() => setCopied(false), 2000);
|
|
21
|
+
});
|
|
22
|
+
}, children: [_jsx(Icon, { name: copied ? 'check' : 'copy', size: "sm" }), copied ? 'Copied' : 'Copy'] })] }), _jsx(Textarea, { readOnly: true, value: text, rows: 16, className: "mt-2 font-mono text-xs", "aria-label": "The prompt" })] })] }), _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold", children: "Start from a theme" }), _jsx("p", { className: "mt-1 text-xs text-base-content/70", children: "Each one fills in every field below. A good place to start if you have no idea what you want." }), _jsx("div", { className: "mt-2 flex flex-wrap gap-1", children: Object.entries(prompt.presets).map(([id, preset]) => (_jsx("button", { type: "button", onClick: () => setValues(applyPreset(preset)), className: "rounded-full bg-base-200 px-2 py-1 text-xs hover:bg-base-300 focus-visible:outline-2 focus-visible:outline-primary", children: preset.label }, id))) })] }), _jsx("div", { className: "space-y-2", children: Object.entries(prompt.slots).map(([key, slot]) => (_jsx(Input, { label: slot.label, help: slot.help, value: values[key] ?? '', onChange: (event) => setValues({ ...values, [key]: event.target.value }) }, key))) }), _jsxs("div", { className: "rounded-lg bg-base-200 p-3", children: [_jsx("h3", { className: "text-sm font-semibold", children: "Worth knowing" }), _jsx("ul", { className: "mt-1 list-disc space-y-1 pl-4 text-xs text-base-content/75", children: prompt.guidance.map((line) => (_jsx("li", { children: line }, line))) })] })] })] }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=PromptStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptStep.js","sourceRoot":"","sources":["../../src/prompt/PromptStep.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAoB,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,YAAY,GAGb,MAAM,aAAa,CAAA;AAuBpB,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;IACzC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAa,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5E,MAAM,CAAC,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CAAC,EAAE,EAAE,CAAC,CACjD,KAAC,KAAK,IAEJ,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAJnE,GAAG,CAKR,CACH,CAAC,GACE,EAEN,eAAK,SAAS,EAAC,4BAA4B,aACzC,aAAI,SAAS,EAAC,uBAAuB,8BAAmB,EACxD,aAAI,SAAS,EAAC,4DAA4D,YACvE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC7B,uBAAgB,IAAI,IAAX,IAAI,CAAa,CAC3B,CAAC,GACC,IACD,IACF,IACF,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CanvasShape } from '@unityevolv/ofiskit-template';
|
|
2
|
+
/**
|
|
3
|
+
* The background-image prompt, as data.
|
|
4
|
+
*
|
|
5
|
+
* The prompt itself lives in the repository as a versioned document that the
|
|
6
|
+
* builder fetches and renders, rather than being compiled into this package.
|
|
7
|
+
* That is deliberate: improving the prompt should reach every author and every
|
|
8
|
+
* host immediately, without releasing the builder, and the prompt is the thing
|
|
9
|
+
* most likely to be improved after a few people have used it.
|
|
10
|
+
*/
|
|
11
|
+
export interface PromptSlot {
|
|
12
|
+
label: string;
|
|
13
|
+
help: string;
|
|
14
|
+
default: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PromptPreset {
|
|
17
|
+
label: string;
|
|
18
|
+
theme: string;
|
|
19
|
+
style: string;
|
|
20
|
+
palette: string;
|
|
21
|
+
lighting: string;
|
|
22
|
+
areaNames: string;
|
|
23
|
+
entryEdge: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PromptDocument {
|
|
26
|
+
version: number;
|
|
27
|
+
canvases: Record<CanvasShape, {
|
|
28
|
+
label: string;
|
|
29
|
+
ratio: string;
|
|
30
|
+
resolution: string;
|
|
31
|
+
}>;
|
|
32
|
+
slots: Record<string, PromptSlot>;
|
|
33
|
+
/** The rules an author may not edit, because they are what make it usable. */
|
|
34
|
+
fixed: string[];
|
|
35
|
+
template: string;
|
|
36
|
+
guidance: string[];
|
|
37
|
+
presets: Record<string, PromptPreset>;
|
|
38
|
+
}
|
|
39
|
+
export type SlotValues = Record<string, string>;
|
|
40
|
+
/** Every slot at its default, which is what the form opens with. */
|
|
41
|
+
export declare function defaultSlots(document: PromptDocument): SlotValues;
|
|
42
|
+
/**
|
|
43
|
+
* Fill the prompt in.
|
|
44
|
+
*
|
|
45
|
+
* The shape and resolution come from the canvas the author picked, so they can
|
|
46
|
+
* never disagree with the template being built — which is the mistake that
|
|
47
|
+
* produces an image that has to be regenerated after the rooms are drawn.
|
|
48
|
+
*/
|
|
49
|
+
export declare function renderPrompt(document: PromptDocument, shape: CanvasShape, values: SlotValues): string;
|
|
50
|
+
/** Fill every slot from a preset, so an author with no idea still gets a good image. */
|
|
51
|
+
export declare function applyPreset(preset: PromptPreset): SlotValues;
|
|
52
|
+
/**
|
|
53
|
+
* Load the prompt document.
|
|
54
|
+
*
|
|
55
|
+
* A path rather than a URL: the app serves it from its own origin, and no
|
|
56
|
+
* hostname is ever written down in the product.
|
|
57
|
+
*/
|
|
58
|
+
export declare function loadPromptDocument(path: string): Promise<PromptDocument>;
|
|
59
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/prompt/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAE/D;;;;;;;;GAQG;AAEH,MAAM,WAAW,UAAU;IACzB,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}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Every slot at its default, which is what the form opens with. */
|
|
2
|
+
export function defaultSlots(document) {
|
|
3
|
+
return Object.fromEntries(Object.entries(document.slots).map(([key, slot]) => [key, slot.default]));
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Fill the prompt in.
|
|
7
|
+
*
|
|
8
|
+
* The shape and resolution come from the canvas the author picked, so they can
|
|
9
|
+
* never disagree with the template being built — which is the mistake that
|
|
10
|
+
* produces an image that has to be regenerated after the rooms are drawn.
|
|
11
|
+
*/
|
|
12
|
+
export function renderPrompt(document, shape, values) {
|
|
13
|
+
const canvas = document.canvases[shape];
|
|
14
|
+
const substitutions = {
|
|
15
|
+
...values,
|
|
16
|
+
shape: canvas.label.toLocaleLowerCase(),
|
|
17
|
+
ratio: canvas.ratio,
|
|
18
|
+
resolution: canvas.resolution,
|
|
19
|
+
fixed: document.fixed.map((rule) => `- ${rule}`).join('\n'),
|
|
20
|
+
};
|
|
21
|
+
return document.template.replace(/\{\{(\w+)\}\}/g, (whole, key) => Object.hasOwn(substitutions, key) ? (substitutions[key] ?? whole) : whole);
|
|
22
|
+
}
|
|
23
|
+
/** Fill every slot from a preset, so an author with no idea still gets a good image. */
|
|
24
|
+
export function applyPreset(preset) {
|
|
25
|
+
const { label: _label, ...slots } = preset;
|
|
26
|
+
return slots;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load the prompt document.
|
|
30
|
+
*
|
|
31
|
+
* A path rather than a URL: the app serves it from its own origin, and no
|
|
32
|
+
* hostname is ever written down in the product.
|
|
33
|
+
*/
|
|
34
|
+
export async function loadPromptDocument(path) {
|
|
35
|
+
const response = await fetch(path);
|
|
36
|
+
if (!response.ok)
|
|
37
|
+
throw new Error(`The background prompt could not be loaded (${response.status}).`);
|
|
38
|
+
return (await response.json());
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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C1C,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAA;IACpG,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmB,CAAA;AAClD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unityevolv/ofiskit-ui-builder",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The office builder: draw rooms and user areas on a background image and emit a template. Takes a layout, emits a layout; the host decides what to do with it.",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
|
|
10
|
+
"files": ["dist"],
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"publishConfig": { "access": "public" },
|
|
13
|
+
"repository": { "type": "git", "url": "git+https://github.com/UnityEvolv/ofis-kit.git", "directory": "packages/ui-builder" },
|
|
14
|
+
"scripts": { "build": "tsc -p tsconfig.json", "typecheck": "tsc -p tsconfig.json --noEmit" },
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@unityevolv/ofiskit-template": "0.1.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@unityevolv/unitykit": ">=0.1.0",
|
|
20
|
+
"react": ">=18.0.0",
|
|
21
|
+
"react-dom": ">=18.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|