@zerospin/studio 0.0.0-stage → 1.0.0-alpha.11
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/README.md +63 -2
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +41 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +17 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +32 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/table.d.ts +9 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +23 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/entry.rsc.d.ts +4 -0
- package/dist/entry.rsc.d.ts.map +1 -0
- package/dist/entry.rsc.js +77 -0
- package/dist/entry.rsc.js.map +1 -0
- package/dist/entry.ssr.d.ts +2 -0
- package/dist/entry.ssr.d.ts.map +1 -0
- package/dist/entry.ssr.js +19 -0
- package/dist/entry.ssr.js.map +1 -0
- package/dist/fixtures/agents.d.ts +65605 -0
- package/dist/fixtures/agents.d.ts.map +1 -0
- package/dist/fixtures/agents.js +195 -0
- package/dist/fixtures/agents.js.map +1 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +6 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +14 -0
- package/dist/main.js.map +1 -0
- package/dist/server/makeStudioViteConfig.d.ts +11 -0
- package/dist/server/makeStudioViteConfig.d.ts.map +1 -0
- package/dist/server/makeStudioViteConfig.js +75 -0
- package/dist/server/makeStudioViteConfig.js.map +1 -0
- package/dist/server/openStudioServer.d.ts +14 -0
- package/dist/server/openStudioServer.d.ts.map +1 -0
- package/dist/server/openStudioServer.js +42 -0
- package/dist/server/openStudioServer.js.map +1 -0
- package/dist/startStudio.d.ts +15 -0
- package/dist/startStudio.d.ts.map +1 -0
- package/dist/startStudio.js +16 -0
- package/dist/startStudio.js.map +1 -0
- package/package.json +71 -3
- package/src/components/ui/button.tsx +75 -0
- package/src/components/ui/combobox.tsx +135 -0
- package/src/components/ui/table.tsx +81 -0
- package/src/entry.rsc.tsx +106 -0
- package/src/entry.ssr.tsx +19 -0
- package/src/fixtures/agents.ts +219 -0
- package/src/lib/cn.ts +6 -0
- package/src/main.tsx +17 -0
- package/src/rsc-env.d.ts +6 -0
- package/src/server/makeStudioViteConfig.ts +90 -0
- package/src/server/openStudioServer.ts +54 -0
- package/src/startStudio.ts +26 -0
- package/src/styles.css +79 -0
- package/vite.config.ts +7 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { makeZerospinError } from '@zerospin/error';
|
|
2
|
+
import { makeFn } from '@zerospin/logger';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import { openStudioServer } from './server/openStudioServer.js';
|
|
5
|
+
/** Start Studio within its caller-owned cancellation lifetime and return explicit disposal. */
|
|
6
|
+
export const startStudio = makeFn('startStudio')(function* (props) {
|
|
7
|
+
return yield* Effect.tryPromise({
|
|
8
|
+
try: () => openStudioServer(props),
|
|
9
|
+
catch: failure => makeZerospinError({
|
|
10
|
+
code: 'studio-start-failed',
|
|
11
|
+
message: 'Could not start Zerospin Studio.',
|
|
12
|
+
cause: String(failure),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=startStudio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startStudio.js","sourceRoot":"","sources":["../src/startStudio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,KAO3D;IACC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QAC9B,GAAG,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,EAAE,CACf,iBAAiB,CAAC;YAChB,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,kCAAkC;YAC3C,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC;SACvB,CAAC;KACL,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { ISystemSpec } from '@zerospin/core/system/types';\nimport { makeZerospinError } from '@zerospin/error';\nimport { makeFn } from '@zerospin/logger';\nimport * as Effect from 'effect/Effect';\n\nimport { openStudioServer } from './server/openStudioServer.js';\n\n/** Start Studio within its caller-owned cancellation lifetime and return explicit disposal. */\nexport const startStudio = makeFn('startStudio')(function* (props: {\n projectRoot: string;\n port: number;\n open: boolean;\n publicUrl?: string;\n systemSpec: ISystemSpec;\n signal: AbortSignal;\n}) {\n return yield* Effect.tryPromise({\n try: () => openStudioServer(props),\n catch: failure =>\n makeZerospinError({\n code: 'studio-start-failed',\n message: 'Could not start Zerospin Studio.',\n cause: String(failure),\n }),\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerospin/studio",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"src",
|
|
12
|
+
"vite.config.ts"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
"./startStudio": {
|
|
16
|
+
"types": "./dist/startStudio.d.ts",
|
|
17
|
+
"import": "./dist/startStudio.js",
|
|
18
|
+
"default": "./dist/startStudio.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@base-ui/react": "^1.6.0",
|
|
23
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
24
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
25
|
+
"@vitejs/plugin-rsc": "0.5.38",
|
|
26
|
+
"class-variance-authority": "^0.7.1",
|
|
27
|
+
"clsx": "^2.1.1",
|
|
28
|
+
"es-toolkit": "^1.52.0",
|
|
29
|
+
"lucide-react": "^1.24.0",
|
|
30
|
+
"react": "19.2.7",
|
|
31
|
+
"react-dom": "19.2.7",
|
|
32
|
+
"react-server-dom-webpack": "19.2.7",
|
|
33
|
+
"tailwind-merge": "^3.6.0",
|
|
34
|
+
"tailwindcss": "^4.3.0",
|
|
35
|
+
"vite": "^8.0.11",
|
|
36
|
+
"@zerospin/error": "1.0.0-alpha.11",
|
|
37
|
+
"@zerospin/browser": "1.0.0-alpha.11",
|
|
38
|
+
"@zerospin/logger": "1.0.0-alpha.11",
|
|
39
|
+
"@zerospin/core": "1.0.0-alpha.11",
|
|
40
|
+
"@zerospin/system-diagrams": "1.0.0-alpha.11",
|
|
41
|
+
"@zerospin/shapes": "1.0.0-alpha.11"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@effect/language-service": "^0.87.2",
|
|
45
|
+
"@shadcn/lint": "0.2.5",
|
|
46
|
+
"@storybook/react-vite": "10.6.1",
|
|
47
|
+
"@types/node": "^25.6.2",
|
|
48
|
+
"@types/react": "^19.2.14",
|
|
49
|
+
"@types/react-dom": "19.2.3",
|
|
50
|
+
"effect": "4.0.2",
|
|
51
|
+
"msw": "3.0.2",
|
|
52
|
+
"msw-storybook-addon": "3.0.3",
|
|
53
|
+
"oxlint": "1.87.0",
|
|
54
|
+
"rimraf": "^6.1.3",
|
|
55
|
+
"storybook": "10.6.1"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"effect": "^4.0.2"
|
|
59
|
+
},
|
|
60
|
+
"msw": {
|
|
61
|
+
"workerDirectory": [
|
|
62
|
+
".storybook/public"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
67
|
+
"lib": "pnpm run clean && tsc -b tsconfig.json",
|
|
68
|
+
"ts": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.etc.json --noEmit",
|
|
69
|
+
"format": "oxfmt package.json project.json tsconfig.json tsconfig.etc.json vite.config.ts src .storybook stories",
|
|
70
|
+
"format:check": "oxfmt --check package.json project.json tsconfig.json tsconfig.etc.json vite.config.ts src .storybook stories",
|
|
71
|
+
"lint": "oxlint src vite.config.ts .storybook stories --ignore-pattern '**/mockServiceWorker.js' --format stylish && oxlint -c shadcn.oxlintrc.json src stories --format stylish",
|
|
72
|
+
"storybook": "storybook dev --port ${PORT:-12021} --no-open --exact-port"
|
|
73
|
+
}
|
|
6
74
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button as ButtonPrimitive } from '@base-ui/react/button';
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
+
import { clsx } from 'clsx';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
|
|
8
|
+
const buttonVariants = cva(
|
|
9
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
10
|
+
{
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
size: 'default',
|
|
13
|
+
variant: 'default',
|
|
14
|
+
},
|
|
15
|
+
variants: {
|
|
16
|
+
size: {
|
|
17
|
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
18
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
19
|
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
|
20
|
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
21
|
+
icon: 'size-9',
|
|
22
|
+
'icon-xs': "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
23
|
+
'icon-sm': 'size-8',
|
|
24
|
+
'icon-lg': 'size-10',
|
|
25
|
+
},
|
|
26
|
+
variant: {
|
|
27
|
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
28
|
+
destructive:
|
|
29
|
+
'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
30
|
+
outline:
|
|
31
|
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
|
|
32
|
+
secondary:
|
|
33
|
+
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
34
|
+
ghost:
|
|
35
|
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
36
|
+
link: 'text-primary underline-offset-[0.25em] hover:underline',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
function Button(
|
|
43
|
+
props: React.ComponentProps<typeof ButtonPrimitive> &
|
|
44
|
+
VariantProps<typeof buttonVariants>,
|
|
45
|
+
) {
|
|
46
|
+
const {
|
|
47
|
+
className,
|
|
48
|
+
variant = 'default',
|
|
49
|
+
size = 'default',
|
|
50
|
+
...buttonProps
|
|
51
|
+
} = props;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ButtonPrimitive
|
|
55
|
+
className={state =>
|
|
56
|
+
twMerge(
|
|
57
|
+
clsx(
|
|
58
|
+
buttonVariants({
|
|
59
|
+
className:
|
|
60
|
+
typeof className === 'function' ? className(state) : className,
|
|
61
|
+
size,
|
|
62
|
+
variant,
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
data-size={size}
|
|
68
|
+
data-slot="button"
|
|
69
|
+
data-variant={variant}
|
|
70
|
+
{...buttonProps}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { Button };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Combobox as ComboboxPrimitive } from '@base-ui/react';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { CheckIcon, ChevronDownIcon } from 'lucide-react';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
|
|
8
|
+
const Combobox = ComboboxPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
function ComboboxInput({
|
|
11
|
+
triggerLabel,
|
|
12
|
+
...props
|
|
13
|
+
}: ComboboxPrimitive.Input.Props & { triggerLabel: string }) {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
data-slot="combobox-input-wrapper"
|
|
17
|
+
className="flex h-9 w-full items-center rounded-md border border-input bg-transparent shadow-xs focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50"
|
|
18
|
+
>
|
|
19
|
+
<ComboboxPrimitive.Input
|
|
20
|
+
data-slot="combobox-input"
|
|
21
|
+
className="h-full min-w-0 flex-1 bg-transparent px-3 py-1 text-sm outline-none placeholder:text-muted-foreground"
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
<ComboboxPrimitive.Trigger
|
|
25
|
+
aria-label={triggerLabel}
|
|
26
|
+
className="flex h-full w-9 items-center justify-center text-muted-foreground"
|
|
27
|
+
>
|
|
28
|
+
<ChevronDownIcon className="size-4" />
|
|
29
|
+
</ComboboxPrimitive.Trigger>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function ComboboxContent({
|
|
35
|
+
className,
|
|
36
|
+
portalContainer,
|
|
37
|
+
...props
|
|
38
|
+
}: ComboboxPrimitive.Popup.Props & {
|
|
39
|
+
portalContainer?: ComboboxPrimitive.Portal.Props['container'];
|
|
40
|
+
}) {
|
|
41
|
+
return (
|
|
42
|
+
<ComboboxPrimitive.Portal container={portalContainer}>
|
|
43
|
+
<ComboboxPrimitive.Positioner
|
|
44
|
+
side="bottom"
|
|
45
|
+
sideOffset={6}
|
|
46
|
+
align="start"
|
|
47
|
+
className="isolate z-50"
|
|
48
|
+
>
|
|
49
|
+
<ComboboxPrimitive.Popup
|
|
50
|
+
data-slot="combobox-content"
|
|
51
|
+
className={twMerge(
|
|
52
|
+
clsx(
|
|
53
|
+
'group/combobox-content max-h-96 w-(--anchor-width) min-w-80 overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10',
|
|
54
|
+
className,
|
|
55
|
+
),
|
|
56
|
+
)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
</ComboboxPrimitive.Positioner>
|
|
60
|
+
</ComboboxPrimitive.Portal>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function ComboboxList(props: ComboboxPrimitive.List.Props) {
|
|
65
|
+
return (
|
|
66
|
+
<ComboboxPrimitive.List
|
|
67
|
+
data-slot="combobox-list"
|
|
68
|
+
className="max-h-80 overflow-y-auto p-1"
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function ComboboxItem({
|
|
75
|
+
className,
|
|
76
|
+
children,
|
|
77
|
+
...props
|
|
78
|
+
}: ComboboxPrimitive.Item.Props) {
|
|
79
|
+
return (
|
|
80
|
+
<ComboboxPrimitive.Item
|
|
81
|
+
data-slot="combobox-item"
|
|
82
|
+
className={twMerge(
|
|
83
|
+
clsx(
|
|
84
|
+
'relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none data-highlighted:bg-accent data-highlighted:text-accent-foreground',
|
|
85
|
+
className,
|
|
86
|
+
),
|
|
87
|
+
)}
|
|
88
|
+
{...props}
|
|
89
|
+
>
|
|
90
|
+
{children}
|
|
91
|
+
<ComboboxPrimitive.ItemIndicator className="absolute right-2 flex size-4 items-center justify-center">
|
|
92
|
+
<CheckIcon className="size-4" />
|
|
93
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
94
|
+
</ComboboxPrimitive.Item>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function ComboboxGroup(props: ComboboxPrimitive.Group.Props) {
|
|
99
|
+
return <ComboboxPrimitive.Group data-slot="combobox-group" {...props} />;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function ComboboxLabel(props: ComboboxPrimitive.GroupLabel.Props) {
|
|
103
|
+
return (
|
|
104
|
+
<ComboboxPrimitive.GroupLabel
|
|
105
|
+
data-slot="combobox-label"
|
|
106
|
+
className="px-2 py-1.5 text-xs text-muted-foreground"
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function ComboboxCollection(props: ComboboxPrimitive.Collection.Props) {
|
|
113
|
+
return <ComboboxPrimitive.Collection {...props} />;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function ComboboxEmpty(props: ComboboxPrimitive.Empty.Props) {
|
|
117
|
+
return (
|
|
118
|
+
<ComboboxPrimitive.Empty
|
|
119
|
+
className="hidden w-full justify-center py-3 text-sm text-muted-foreground group-data-empty/combobox-content:flex"
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
Combobox,
|
|
127
|
+
ComboboxCollection,
|
|
128
|
+
ComboboxContent,
|
|
129
|
+
ComboboxEmpty,
|
|
130
|
+
ComboboxGroup,
|
|
131
|
+
ComboboxInput,
|
|
132
|
+
ComboboxItem,
|
|
133
|
+
ComboboxLabel,
|
|
134
|
+
ComboboxList,
|
|
135
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
|
|
6
|
+
function Table({ className, ...props }: React.ComponentProps<'table'>) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
data-slot="table-container"
|
|
10
|
+
className="relative w-full overflow-x-auto"
|
|
11
|
+
>
|
|
12
|
+
<table
|
|
13
|
+
data-slot="table"
|
|
14
|
+
className={twMerge(clsx('w-full caption-bottom text-sm', className))}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
|
|
22
|
+
return (
|
|
23
|
+
<thead
|
|
24
|
+
data-slot="table-header"
|
|
25
|
+
className={twMerge(clsx('[&_tr]:border-b', className))}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
|
|
32
|
+
return (
|
|
33
|
+
<tbody
|
|
34
|
+
data-slot="table-body"
|
|
35
|
+
className={twMerge(clsx('[&_tr:last-child]:border-0', className))}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
|
|
42
|
+
return (
|
|
43
|
+
<tr
|
|
44
|
+
data-slot="table-row"
|
|
45
|
+
className={twMerge(
|
|
46
|
+
clsx(
|
|
47
|
+
'border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted',
|
|
48
|
+
className,
|
|
49
|
+
),
|
|
50
|
+
)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
|
|
57
|
+
return (
|
|
58
|
+
<th
|
|
59
|
+
data-slot="table-head"
|
|
60
|
+
className={twMerge(
|
|
61
|
+
clsx(
|
|
62
|
+
'h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground',
|
|
63
|
+
className,
|
|
64
|
+
),
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
|
|
72
|
+
return (
|
|
73
|
+
<td
|
|
74
|
+
data-slot="table-cell"
|
|
75
|
+
className={twMerge(clsx('p-2 align-middle whitespace-nowrap', className))}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { Table, TableBody, TableCell, TableHead, TableHeader, TableRow };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { renderToReadableStream } from '@vitejs/plugin-rsc/rsc/server';
|
|
2
|
+
import { SystemSpecSchema } from '@zerospin/core/system/SystemSpecSchema';
|
|
3
|
+
import { SystemDiagrams } from '@zerospin/system-diagrams';
|
|
4
|
+
import '@zerospin/system-diagrams/styles.css';
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import serializedSystemSpec from 'virtual:zerospin-studio-system-spec';
|
|
7
|
+
|
|
8
|
+
import './styles.css';
|
|
9
|
+
|
|
10
|
+
const systemSpec = Schema.decodeUnknownSync(
|
|
11
|
+
Schema.fromJsonString(SystemSpecSchema),
|
|
12
|
+
)(serializedSystemSpec);
|
|
13
|
+
|
|
14
|
+
function StudioDocument(props: { sectionId: string | undefined }) {
|
|
15
|
+
const { sectionId } = props;
|
|
16
|
+
return (
|
|
17
|
+
<html lang="en">
|
|
18
|
+
<head>
|
|
19
|
+
<meta charSet="UTF-8" />
|
|
20
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
21
|
+
<title>{`${systemSpec.systemName} · Zerospin Declaration Board`}</title>
|
|
22
|
+
{import.meta.viteRsc.loadCss()}
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<SystemDiagrams
|
|
26
|
+
systemSpec={systemSpec}
|
|
27
|
+
navigation={{ sectionId, basePath: '' }}
|
|
28
|
+
/>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default async function handleStudioRequest(request: Request) {
|
|
35
|
+
const url = new URL(request.url);
|
|
36
|
+
if (request.method !== 'GET') {
|
|
37
|
+
return new Response('Method not allowed', {
|
|
38
|
+
status: 405,
|
|
39
|
+
headers: { Allow: 'GET' },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isRsc = url.pathname === '/index.rsc';
|
|
44
|
+
const pathname = isRsc
|
|
45
|
+
? (url.searchParams.get('pathname') ?? '/')
|
|
46
|
+
: url.pathname;
|
|
47
|
+
let sectionId: string | undefined;
|
|
48
|
+
if (pathname === '/') {
|
|
49
|
+
const aggregate = Object.keys(systemSpec.aggregates).sort((left, right) =>
|
|
50
|
+
left.localeCompare(right),
|
|
51
|
+
)[0];
|
|
52
|
+
const service = Object.keys(systemSpec.services).sort((left, right) =>
|
|
53
|
+
left.localeCompare(right),
|
|
54
|
+
)[0];
|
|
55
|
+
const firstPage =
|
|
56
|
+
aggregate !== undefined
|
|
57
|
+
? `/aggregates/${encodeURIComponent(aggregate)}`
|
|
58
|
+
: service !== undefined
|
|
59
|
+
? `/services/${encodeURIComponent(service)}`
|
|
60
|
+
: undefined;
|
|
61
|
+
if (firstPage !== undefined) {
|
|
62
|
+
return new Response(null, {
|
|
63
|
+
status: 302,
|
|
64
|
+
headers: {
|
|
65
|
+
Location: isRsc
|
|
66
|
+
? `/index.rsc?pathname=${encodeURIComponent(firstPage)}`
|
|
67
|
+
: firstPage,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
const route = /^\/(aggregates|services)\/([^/]+)$/.exec(pathname);
|
|
73
|
+
if (!route) return new Response('Not found', { status: 404 });
|
|
74
|
+
const group = route[1];
|
|
75
|
+
const encodedName = route[2];
|
|
76
|
+
if (encodedName === undefined)
|
|
77
|
+
return new Response('Not found', { status: 404 });
|
|
78
|
+
let name: string;
|
|
79
|
+
try {
|
|
80
|
+
name = decodeURIComponent(encodedName);
|
|
81
|
+
} catch {
|
|
82
|
+
return new Response('Invalid page name', { status: 400 });
|
|
83
|
+
}
|
|
84
|
+
const owners =
|
|
85
|
+
group === 'aggregates' ? systemSpec.aggregates : systemSpec.services;
|
|
86
|
+
if (!Object.hasOwn(owners, name))
|
|
87
|
+
return new Response('Not found', { status: 404 });
|
|
88
|
+
sectionId = `system-board-${group === 'aggregates' ? 'aggregate' : 'service'}-${encodeURIComponent(name)}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (isRsc) {
|
|
92
|
+
const rscStream = renderToReadableStream(
|
|
93
|
+
<StudioDocument sectionId={sectionId} />,
|
|
94
|
+
);
|
|
95
|
+
return new Response(rscStream, {
|
|
96
|
+
headers: { 'Content-Type': 'text/x-component;charset=utf-8' },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const { makeStudioHtml } = await import.meta.viteRsc.loadModule<
|
|
101
|
+
typeof import('./entry.ssr.js')
|
|
102
|
+
>('ssr', 'index');
|
|
103
|
+
return new Response(makeStudioHtml(), {
|
|
104
|
+
headers: { 'Content-Type': 'text/html;charset=utf-8' },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getClientEntryUrl } from '@vitejs/plugin-rsc/ssr';
|
|
2
|
+
|
|
3
|
+
export function makeStudioHtml() {
|
|
4
|
+
const clientEntryUrl = getClientEntryUrl()
|
|
5
|
+
.replaceAll('&', '&')
|
|
6
|
+
.replaceAll('"', '"');
|
|
7
|
+
return `<!doctype html>
|
|
8
|
+
<html lang="en">
|
|
9
|
+
<head>
|
|
10
|
+
<meta charset="UTF-8" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
12
|
+
<title>Zerospin Studio</title>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<p role="status">Loading Studio…</p>
|
|
16
|
+
<script type="module" src="${clientEntryUrl}"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>`;
|
|
19
|
+
}
|