moi-computer 0.12.1-next.2 → 0.12.1-next.4
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/bunfig.toml +1 -5
- package/client/api/app-config.ts +1 -2
- package/client/api/app-ui-keys.ts +3 -1
- package/client/api/http.ts +4 -1
- package/client/api/workspace-keys.ts +3 -3
- package/client/app/app-provider.tsx +22 -2
- package/client/app/app-router.tsx +6 -0
- package/client/app/routes/home-route.tsx +14 -0
- package/client/app/routes/onboarding-route.tsx +11 -0
- package/client/app/routes/settings-route.tsx +10 -0
- package/client/app/routes/workspace-route.tsx +21 -19
- package/client/app/shell/sidebar-layout.tsx +34 -53
- package/client/components/shared/screen-shell.tsx +23 -0
- package/client/components/shared/ultrafast-icon.tsx +61 -0
- package/client/components/shared/workspace-icon.tsx +2 -2
- package/client/features/account/account-menu.tsx +96 -0
- package/client/features/account/account-provider.tsx +142 -0
- package/client/features/account/account-test-utils.tsx +294 -0
- package/client/features/account/api.ts +142 -0
- package/client/features/account/identity.ts +23 -0
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/app-settings/profile-settings.tsx +95 -0
- package/client/features/app-settings/settings-page.tsx +48 -0
- package/client/features/app-settings/settings-section.tsx +26 -0
- package/client/features/app-settings/users-settings.tsx +195 -0
- package/client/features/chat/applet-chat-intents.ts +4 -20
- package/client/features/chat/chat-send.ts +17 -13
- package/client/features/chat/composer/model-order.ts +8 -4
- package/client/features/chat/composer/model-picker.tsx +88 -34
- package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
- package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -15
- package/client/features/chat/messages/chat-empty-state.tsx +1 -4
- package/client/features/chat/messages/fork-history.ts +5 -5
- package/client/features/chat/messages/turn-view.tsx +3 -12
- package/client/features/chat/messages/user-message-bubble.tsx +63 -0
- package/client/features/chat/sessions/api.ts +121 -80
- package/client/features/chat/sessions/browser-tab-state.ts +14 -12
- package/client/features/chat/sessions/chat-selector.tsx +5 -6
- package/client/features/chat/sessions/use-selected-session.ts +172 -257
- package/client/features/chat/use-chat.ts +14 -19
- package/client/features/collab/applet-api.ts +15 -14
- package/client/features/collab/components/cursors.tsx +61 -24
- package/client/features/collab/components/presence-avatars.tsx +25 -12
- package/client/features/collab/components/presence-frame.tsx +20 -24
- package/client/features/collab/components/presence-group.tsx +15 -7
- package/client/features/collab/components/user-avatar-group.tsx +21 -8
- package/client/features/collab/components/user-avatar.tsx +38 -7
- package/client/features/collab/components/user.tsx +31 -12
- package/client/features/collab/users.ts +0 -5
- package/client/features/collab/workspace-users-menu.tsx +4 -4
- package/client/features/demo/demo-dialog.tsx +11 -3
- package/client/features/dev/collab/collab-playground.tsx +7 -7
- package/client/features/dev/collab/local-user-settings.tsx +7 -53
- package/client/features/dev/dev-index-page.tsx +5 -0
- package/client/features/dev/dev-routes.tsx +2 -0
- package/client/features/dev/harness-debug-page.tsx +3 -3
- package/client/features/dev/onboarding-preview-page.tsx +76 -0
- package/client/features/dev/workspace-setup-mocks.ts +16 -14
- package/client/features/dev/workspace-setup-preview.tsx +11 -17
- package/client/features/harness/api.ts +45 -15
- package/client/features/harness/device-login-steps.tsx +9 -3
- package/client/features/harness/harness-login-panel.tsx +228 -0
- package/client/features/harness/harness-presentation.ts +15 -0
- package/client/features/harness/harness-selector.tsx +119 -0
- package/client/features/harness/use-harness-login.ts +77 -0
- package/client/features/home/home-page.tsx +7 -7
- package/client/features/onboarding/agent-setup-step.tsx +57 -0
- package/client/features/onboarding/api.ts +42 -0
- package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
- package/client/features/onboarding/onboarding-page.tsx +32 -0
- package/client/features/onboarding/onboarding-screen.tsx +20 -0
- package/client/features/onboarding/onboarding-status.tsx +24 -0
- package/client/features/onboarding/workspace-setup-step.tsx +239 -0
- package/client/features/overview/default/registry.tsx +2 -2
- package/client/features/overview/default/views-widget.tsx +6 -5
- package/client/features/overview/overview.tsx +9 -11
- package/client/features/overview/widget-canvas.tsx +1 -1
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/update/update-control.tsx +1 -1
- package/client/features/views/api.ts +69 -16
- package/client/features/views/pending-view-screen.tsx +30 -9
- package/client/features/views/use-view-actions.ts +19 -20
- package/client/features/views/view-presentation.ts +2 -2
- package/client/features/views/view-submission.ts +28 -41
- package/client/features/workspace/add/api.ts +3 -23
- package/client/features/workspace/add/create-workspace-dialog.tsx +11 -7
- package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
- package/client/features/workspace/add/workspace-agent-options.ts +11 -12
- package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
- package/client/features/workspace/api.ts +32 -36
- package/client/features/workspace/harness-transition.ts +88 -0
- package/client/features/{settings → workspace/settings}/api.ts +1 -34
- package/client/features/{settings → workspace/settings}/connectors-settings.tsx +3 -3
- package/client/features/{settings → workspace/settings}/environment-settings.tsx +3 -3
- package/client/features/{settings → workspace/settings}/general-settings.tsx +77 -3
- package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
- package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
- package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
- package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
- package/client/features/workspace/setup/workspace-setup.tsx +34 -14
- package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +25 -9
- package/client/features/workspace/workspace-content.tsx +11 -8
- package/client/features/workspace/workspace-frame.tsx +2 -1
- package/client/features/workspace/workspace-layout-context.tsx +5 -2
- package/client/features/workspace/workspace-menu.tsx +12 -8
- package/client/features/workspace/workspace-pending-screen.tsx +10 -10
- package/client/features/workspace/workspace-presentation.tsx +5 -13
- package/client/features/workspace/workspace-state.ts +169 -0
- package/client/features/workspace/workspace-tabs.tsx +22 -2
- package/client/index.css +2 -0
- package/client/index.tsx +3 -3
- package/client/lib/flags.ts +1 -1
- package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
- package/client/lib/user-display-name.ts +6 -0
- package/client/main.tsx +4 -1
- package/client/runtime/workspace-events.ts +21 -4
- package/client/runtime/workspace-theme.ts +9 -0
- package/client/tailwind-config.ts +43 -0
- package/dist/chunk-0mjzg20x.js +2 -0
- package/dist/chunk-2y59vrxg.js +5 -0
- package/dist/chunk-58dyt9bk.js +2 -0
- package/dist/chunk-5aj040e5.css +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-71fn6rmj.js +546 -0
- package/dist/chunk-7yg1m8hx.js +2 -0
- package/dist/chunk-825hys3h.js +1 -0
- package/dist/chunk-9bb8m9rx.js +2 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-g0tcwqxc.js +1 -0
- package/dist/chunk-n0nab26d.js +1 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-v88n1bay.js +74 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +1 -1
- package/lib/{app-icons.ts → identity-icons.ts} +6 -7
- package/lib/onboarding.ts +41 -0
- package/lib/speed-mode.ts +5 -0
- package/lib/types.ts +72 -63
- package/lib/view-build-directives.ts +1 -2
- package/lib/workspace-icon.ts +2 -2
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-name.ts +15 -12
- package/package.json +9 -8
- package/server/README.md +27 -25
- package/server/api/harnesses.ts +31 -8
- package/server/api/index.ts +164 -131
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +23 -24
- package/server/app-settings.ts +6 -2
- package/server/applets/config.ts +5 -5
- package/server/applets/views.ts +19 -17
- package/server/cli/commands/init.ts +3 -3
- package/server/cli/commands/skill.ts +16 -17
- package/server/cli/commands/start.ts +8 -34
- package/server/cli/server.ts +18 -6
- package/server/collab/config.ts +1 -2
- package/server/collab/manager.ts +4 -1
- package/server/collab/skill/index.ts +1 -1
- package/server/control.ts +3 -3
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +24 -8
- package/server/harness/acp/session.ts +8 -4
- package/server/harness/auth.ts +14 -17
- package/server/harness/claude-code/NOTES.md +4 -3
- package/server/harness/claude-code/index.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -20
- package/server/harness/claude-code/run-action.ts +123 -0
- package/server/harness/claude-code/session-title.ts +5 -7
- package/server/harness/claude-code/session.ts +24 -16
- package/server/harness/codex/NOTES.md +14 -9
- package/server/harness/codex/adapter.ts +14 -17
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/run-action.ts +93 -0
- package/server/harness/codex/session-title.ts +6 -8
- package/server/harness/codex/session.ts +11 -11
- package/server/harness/command.ts +45 -0
- package/server/harness/executable.ts +5 -0
- package/server/harness/fork.ts +6 -4
- package/server/harness/install.ts +49 -0
- package/server/harness/openclaw/session.ts +1 -2
- package/server/harness/run-action.ts +85 -0
- package/server/harness/session-title.ts +0 -46
- package/server/harness/types.ts +26 -2
- package/server/onboarding/brief.ts +29 -0
- package/server/onboarding/ideas.ts +48 -0
- package/server/onboarding/jobs.ts +291 -0
- package/server/onboarding/prompt.md +49 -0
- package/server/sessions/archive.ts +5 -14
- package/server/sessions/config.ts +17 -16
- package/server/sessions/lifecycle.ts +15 -13
- package/server/sessions/pending-views.ts +79 -108
- package/server/sessions/selected.ts +75 -161
- package/server/sessions/store.ts +40 -113
- package/server/sessions/view-sessions.ts +128 -111
- package/server/skills/locations.ts +82 -0
- package/server/skills/lock.ts +29 -0
- package/server/skills/template.ts +36 -25
- package/server/skills/update.ts +52 -5
- package/server/skills/version.ts +17 -22
- package/server/skills/workspace.ts +121 -0
- package/server/web.ts +23 -8
- package/server/workspace-state/file.ts +177 -0
- package/server/workspace-state/index.ts +162 -0
- package/server/workspace-state/legacy-migration.ts +79 -0
- package/server/workspace-state/lock.ts +42 -0
- package/server/workspace-state/types.ts +16 -0
- package/server/workspaces/change-harness.ts +88 -0
- package/server/workspaces/harness-transition.ts +29 -0
- package/server/workspaces/init.ts +29 -16
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +58 -10
- package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
- package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
- package/skill/references/DESIGN.md +148 -0
- package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
- package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
- package/ui-components/badge.tsx +1 -1
- package/client/accept-hmr-dependencies.ts +0 -22
- package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
- package/dist/chunk-00rh9df4.js +0 -2
- package/dist/chunk-4nh7y1hq.css +0 -1
- package/dist/chunk-am4agx6v.js +0 -2
- package/dist/chunk-d7cbm65e.js +0 -2
- package/dist/chunk-hbpdv7vd.js +0 -1
- package/dist/chunk-hmka9rt5.js +0 -2
- package/dist/chunk-hvh9f5h0.js +0 -14
- package/dist/chunk-mjjregkn.js +0 -10
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-rt30jbcm.js +0 -1
- package/dist/chunk-vt6zybej.js +0 -2
- package/dist/chunk-wbkwf6cc.js +0 -68
- package/dist/chunk-xjyfyz64.js +0 -1
- package/dist/chunk-y8nbwp21.js +0 -546
- package/dist/chunk-ysfdcew7.js +0 -1
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
- /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
- /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient, type QueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { requestJson } from '@/client/api/http'
|
|
4
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
+
import { toast } from '@/client/components/ui/toast'
|
|
6
|
+
import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
|
|
7
|
+
import type { WorkspaceState } from '@/lib/types'
|
|
8
|
+
|
|
9
|
+
// Per-user chat state for one workspace: pin, the chat each tab shows, chat
|
|
10
|
+
// settings and fork history, and views being built. One cache, kept current by
|
|
11
|
+
// write replies and `state:changed` events instead of refetches.
|
|
12
|
+
|
|
13
|
+
export function workspaceStateKey(workspaceId: string) {
|
|
14
|
+
return workspaceKeys.state(workspaceId)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Writes that answer with the state share this key. While one is in flight,
|
|
18
|
+
// replies and events wait, so they never land over a newer optimistic change.
|
|
19
|
+
function writeKey(workspaceId: string) {
|
|
20
|
+
return [...workspaceStateKey(workspaceId), 'write'] as const
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function writesInFlight(queryClient: QueryClient, workspaceId: string): number {
|
|
24
|
+
return queryClient.isMutating({ mutationKey: writeKey(workspaceId) })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Keep the newer copy. A reply or event can arrive after a newer one.
|
|
28
|
+
function newer(current: WorkspaceState | undefined, next: WorkspaceState): WorkspaceState {
|
|
29
|
+
return current && current.revision > next.revision ? current : next
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function workspaceStateOptions(queryClient: QueryClient, workspaceId: string) {
|
|
33
|
+
const queryKey = workspaceStateKey(workspaceId)
|
|
34
|
+
return {
|
|
35
|
+
queryKey,
|
|
36
|
+
queryFn: async ({ signal }: { signal: AbortSignal }) => {
|
|
37
|
+
const next = await requestJson<WorkspaceState>(`/api/workspaces/${workspaceId}/state`, {
|
|
38
|
+
signal
|
|
39
|
+
})
|
|
40
|
+
const current = queryClient.getQueryData<WorkspaceState>(queryKey)
|
|
41
|
+
// A write in flight already shows its change; its reply brings the
|
|
42
|
+
// server's copy.
|
|
43
|
+
if (current && writesInFlight(queryClient, workspaceId) > 0) return current
|
|
44
|
+
return newer(current, next)
|
|
45
|
+
},
|
|
46
|
+
// Events keep the cache current, so new observers never refetch. A focus
|
|
47
|
+
// refetch heals anything missed while the socket was down.
|
|
48
|
+
staleTime: 0,
|
|
49
|
+
gcTime: 5 * 60_000,
|
|
50
|
+
refetchOnMount: false,
|
|
51
|
+
refetchOnWindowFocus: true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function useWorkspaceState<T = WorkspaceState>(
|
|
56
|
+
workspaceId: string,
|
|
57
|
+
select?: (state: WorkspaceState) => T
|
|
58
|
+
) {
|
|
59
|
+
const queryClient = useQueryClient()
|
|
60
|
+
return useQuery({ ...workspaceStateOptions(queryClient, workspaceId), select })
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getCachedWorkspaceState(
|
|
64
|
+
queryClient: QueryClient,
|
|
65
|
+
workspaceId: string
|
|
66
|
+
): WorkspaceState | undefined {
|
|
67
|
+
return queryClient.getQueryData<WorkspaceState>(workspaceStateKey(workspaceId))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Apply a local change before the server confirms it.
|
|
71
|
+
export function changeWorkspaceStateCache(
|
|
72
|
+
queryClient: QueryClient,
|
|
73
|
+
workspaceId: string,
|
|
74
|
+
change: (draft: WorkspaceState) => void
|
|
75
|
+
): void {
|
|
76
|
+
queryClient.setQueryData<WorkspaceState>(workspaceStateKey(workspaceId), current => {
|
|
77
|
+
if (!current) return current
|
|
78
|
+
const draft = structuredClone(current)
|
|
79
|
+
change(draft)
|
|
80
|
+
return draft
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function receiveWorkspaceState(
|
|
85
|
+
queryClient: QueryClient,
|
|
86
|
+
workspaceId: string,
|
|
87
|
+
next: WorkspaceState
|
|
88
|
+
): void {
|
|
89
|
+
queryClient.setQueryData<WorkspaceState>(workspaceStateKey(workspaceId), current =>
|
|
90
|
+
newer(current, next)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type WorkspaceStateWriteOptions<Input> = {
|
|
95
|
+
request: (input: Input) => Promise<WorkspaceState>
|
|
96
|
+
optimistic?: (draft: WorkspaceState, input: Input) => void
|
|
97
|
+
onSuccess?: (state: WorkspaceState, input: Input) => void
|
|
98
|
+
errorTitle: string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// A write that answers with the new state. Writes to one workspace run in
|
|
102
|
+
// order; the last reply becomes the cache, and a failure refetches it.
|
|
103
|
+
export function useWorkspaceStateWrite<Input>(
|
|
104
|
+
workspaceId: string,
|
|
105
|
+
{ request, optimistic, onSuccess, errorTitle }: WorkspaceStateWriteOptions<Input>
|
|
106
|
+
) {
|
|
107
|
+
const queryClient = useQueryClient()
|
|
108
|
+
const queryKey = workspaceStateKey(workspaceId)
|
|
109
|
+
return useMutation<WorkspaceState, Error, Input>({
|
|
110
|
+
mutationKey: writeKey(workspaceId),
|
|
111
|
+
scope: { id: `workspace-state:${workspaceId}` },
|
|
112
|
+
mutationFn: request,
|
|
113
|
+
onMutate: async input => {
|
|
114
|
+
if (!optimistic) return
|
|
115
|
+
await queryClient.cancelQueries({ queryKey, exact: true })
|
|
116
|
+
changeWorkspaceStateCache(queryClient, workspaceId, draft => optimistic(draft, input))
|
|
117
|
+
},
|
|
118
|
+
onSuccess: (state, input) => {
|
|
119
|
+
// This write still counts as in flight; a later one owns the cache.
|
|
120
|
+
if (writesInFlight(queryClient, workspaceId) === 1)
|
|
121
|
+
receiveWorkspaceState(queryClient, workspaceId, state)
|
|
122
|
+
onSuccess?.(state, input)
|
|
123
|
+
},
|
|
124
|
+
onError: error => {
|
|
125
|
+
toast.add({ title: errorTitle, description: error.message, type: 'error' })
|
|
126
|
+
void queryClient.invalidateQueries({ queryKey, exact: true })
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Mounted once for the app: every browser tab hears every workspace's
|
|
132
|
+
// changes, so cached states stay current even while their workspace is closed.
|
|
133
|
+
export function useWorkspaceStateSync(): void {
|
|
134
|
+
const queryClient = useQueryClient()
|
|
135
|
+
useWorkspaceEvent(event => {
|
|
136
|
+
if (event.type !== 'state:changed') return
|
|
137
|
+
if (!getCachedWorkspaceState(queryClient, event.workspaceId)) return
|
|
138
|
+
if (writesInFlight(queryClient, event.workspaceId) > 0) return
|
|
139
|
+
receiveWorkspaceState(queryClient, event.workspaceId, event.state)
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// A harness replaced a temporary chat id with its real one. Mirrors the
|
|
144
|
+
// server's rename so the chat keeps its tab, settings, pin and build at once.
|
|
145
|
+
export function renameSessionInState(draft: WorkspaceState, from: string, to: string): void {
|
|
146
|
+
if (from === to) return
|
|
147
|
+
const source = draft.sessions[from]
|
|
148
|
+
if (source) {
|
|
149
|
+
const target = draft.sessions[to]
|
|
150
|
+
const config =
|
|
151
|
+
source.config || target?.config ? { ...source.config, ...target?.config } : undefined
|
|
152
|
+
draft.sessions[to] = { ...source, ...target, ...(config ? { config } : {}) }
|
|
153
|
+
delete draft.sessions[from]
|
|
154
|
+
}
|
|
155
|
+
for (const session of Object.values(draft.sessions))
|
|
156
|
+
if (session.fork?.fromSessionId === from) session.fork.fromSessionId = to
|
|
157
|
+
for (const [tabId, sessionId] of Object.entries(draft.selected))
|
|
158
|
+
if (sessionId === from) draft.selected[tabId as keyof WorkspaceState['selected']] = to
|
|
159
|
+
if (draft.pinnedSessionId === from) draft.pinnedSessionId = to
|
|
160
|
+
for (const view of Object.values(draft.pendingViews))
|
|
161
|
+
if (view.buildSessionId === from) view.buildSessionId = to
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// An archived chat leaves every tab and the pin.
|
|
165
|
+
export function clearSessionInState(draft: WorkspaceState, sessionId: string): void {
|
|
166
|
+
for (const [tabId, selected] of Object.entries(draft.selected))
|
|
167
|
+
if (selected === sessionId) delete draft.selected[tabId as keyof WorkspaceState['selected']]
|
|
168
|
+
if (draft.pinnedSessionId === sessionId) delete draft.pinnedSessionId
|
|
169
|
+
}
|
|
@@ -22,6 +22,7 @@ export type WorkspaceTabItem = {
|
|
|
22
22
|
closable?: boolean
|
|
23
23
|
reorderable?: boolean
|
|
24
24
|
loading?: boolean
|
|
25
|
+
needsAttention?: boolean
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export type CreateWorkspaceTabItem = {
|
|
@@ -117,7 +118,7 @@ function WorkspaceTab(props: WorkspaceTabProps) {
|
|
|
117
118
|
<button
|
|
118
119
|
type="button"
|
|
119
120
|
aria-hidden={preview || undefined}
|
|
120
|
-
aria-label={tab.label}
|
|
121
|
+
aria-label={tab.needsAttention && !tab.loading ? `${tab.label}: needs attention` : tab.label}
|
|
121
122
|
disabled={preview}
|
|
122
123
|
tabIndex={preview ? -1 : undefined}
|
|
123
124
|
onClick={props.preview ? undefined : () => props.onSelect(tab.key)}
|
|
@@ -137,7 +138,26 @@ function WorkspaceTab(props: WorkspaceTabProps) {
|
|
|
137
138
|
{tab.loading ? (
|
|
138
139
|
<Spinner data-icon="inline-start" className="shrink-0" />
|
|
139
140
|
) : (
|
|
140
|
-
<
|
|
141
|
+
<span
|
|
142
|
+
className="relative size-4 shrink-0"
|
|
143
|
+
title={tab.needsAttention ? 'Needs attention' : undefined}
|
|
144
|
+
>
|
|
145
|
+
<tab.Icon
|
|
146
|
+
data-icon="inline-start"
|
|
147
|
+
stroke={1.75}
|
|
148
|
+
className={cn(
|
|
149
|
+
'size-4',
|
|
150
|
+
tab.needsAttention &&
|
|
151
|
+
'[mask-image:radial-gradient(circle_at_calc(100%_-_0.1875rem)_0.1875rem,transparent_0.3125rem,black_0.3125rem)]'
|
|
152
|
+
)}
|
|
153
|
+
/>
|
|
154
|
+
{tab.needsAttention && (
|
|
155
|
+
<span
|
|
156
|
+
aria-hidden="true"
|
|
157
|
+
className="absolute top-0 right-0 size-1.5 rounded-full bg-primary"
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</span>
|
|
141
161
|
)}
|
|
142
162
|
<span
|
|
143
163
|
className={cn(
|
package/client/index.css
CHANGED
package/client/index.tsx
CHANGED
|
@@ -20,9 +20,9 @@ import { startHmrWatchdog } from './runtime/hmr-watchdog'
|
|
|
20
20
|
// bundle/vendor boundary. The one missing piece was that the externalized
|
|
21
21
|
// virtual modules (`esm:react/jsx-dev-runtime` etc.) were never hot-accepted,
|
|
22
22
|
// which made EVERY edit propagate to the entry and force a full reload —
|
|
23
|
-
// fixed by the `import.meta.hot.accept()` in externalize-react.ts.
|
|
24
|
-
// edits
|
|
25
|
-
// fall back to
|
|
23
|
+
// fixed by the `import.meta.hot.accept()` in externalize-react.ts. Accepted
|
|
24
|
+
// component edits apply in place; updates reaching non-component or mixed
|
|
25
|
+
// exports still fall back to Bun's full reload.
|
|
26
26
|
if (import.meta.hot) {
|
|
27
27
|
startHmrWatchdog()
|
|
28
28
|
}
|
package/client/lib/flags.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// Live token-by-token streaming of assistant responses. When true, the client
|
|
7
7
|
// asks the server to stream partial messages (only honored by providers whose
|
|
8
|
-
// `/
|
|
8
|
+
// `/harness` payload reports `supportsStreaming` — Claude Code and OpenClaw;
|
|
9
9
|
// ignored elsewhere). When false, responses arrive as whole blocks, exactly as
|
|
10
10
|
// before streaming existed.
|
|
11
11
|
export const STREAM_RESPONSES = true
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
IconDatabase,
|
|
23
23
|
IconDeviceGamepad2,
|
|
24
24
|
IconDiamond,
|
|
25
|
-
IconDots,
|
|
26
25
|
IconFeather,
|
|
27
26
|
IconFile,
|
|
28
27
|
IconFlame,
|
|
@@ -50,7 +49,6 @@ import {
|
|
|
50
49
|
IconPlug,
|
|
51
50
|
IconRobot,
|
|
52
51
|
IconRocket,
|
|
53
|
-
IconSettings,
|
|
54
52
|
IconShield,
|
|
55
53
|
IconShoppingCart,
|
|
56
54
|
IconSnowflake,
|
|
@@ -66,16 +64,16 @@ import {
|
|
|
66
64
|
IconWorld
|
|
67
65
|
} from '@tabler/icons-react'
|
|
68
66
|
|
|
69
|
-
import {
|
|
67
|
+
import { IDENTITY_ICON_IDS, isIdentityIconId, type IdentityIconId } from '@/lib/identity-icons'
|
|
70
68
|
|
|
71
|
-
export type
|
|
72
|
-
id:
|
|
69
|
+
export type IdentityIconChoice = {
|
|
70
|
+
id: IdentityIconId
|
|
73
71
|
Icon: TablerIcon
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
// UI component for every shared
|
|
74
|
+
// UI component for every shared identity icon id. Record<> keeps this map in sync
|
|
77
75
|
// with the server-safe list used by builder and bundle validation.
|
|
78
|
-
const
|
|
76
|
+
const identityIconById: Record<IdentityIconId, TablerIcon> = {
|
|
79
77
|
rocket: IconRocket,
|
|
80
78
|
sparkles: IconSparkles,
|
|
81
79
|
bolt: IconBolt,
|
|
@@ -100,8 +98,6 @@ const appIconById: Record<AppIconId, TablerIcon> = {
|
|
|
100
98
|
hexagon: IconHexagon,
|
|
101
99
|
plug: IconPlug,
|
|
102
100
|
tool: IconTool,
|
|
103
|
-
settings: IconSettings,
|
|
104
|
-
dots: IconDots,
|
|
105
101
|
bug: IconBug,
|
|
106
102
|
activity: IconActivity,
|
|
107
103
|
chart: IconChartBar,
|
|
@@ -142,13 +138,13 @@ const appIconById: Record<AppIconId, TablerIcon> = {
|
|
|
142
138
|
chef: IconChefHat
|
|
143
139
|
}
|
|
144
140
|
|
|
145
|
-
export const
|
|
141
|
+
export const IDENTITY_ICON_CHOICES: IdentityIconChoice[] = IDENTITY_ICON_IDS.map(id => ({
|
|
146
142
|
id,
|
|
147
|
-
Icon:
|
|
143
|
+
Icon: identityIconById[id]
|
|
148
144
|
}))
|
|
149
145
|
|
|
150
|
-
export {
|
|
146
|
+
export { IDENTITY_ICON_IDS }
|
|
151
147
|
|
|
152
|
-
export function
|
|
153
|
-
return id &&
|
|
148
|
+
export function resolveIdentityIcon(id: string | undefined): TablerIcon | null {
|
|
149
|
+
return id && isIdentityIconId(id) ? identityIconById[id] : null
|
|
154
150
|
}
|
package/client/main.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { Toaster } from '@/client/components/ui/toast'
|
|
|
6
6
|
import { TooltipProvider } from '@/client/components/ui/tooltip'
|
|
7
7
|
import { installAppletErrorHook } from '@/client/features/applets/applet-log'
|
|
8
8
|
import { initConnection } from '@/client/features/chat/connection/chat-connection'
|
|
9
|
+
import { AccountProvider } from '@/client/features/account/account-provider'
|
|
9
10
|
import { AppProvider } from './app/app-provider'
|
|
10
11
|
import { AppRouter } from './app/app-router'
|
|
11
12
|
|
|
@@ -27,7 +28,9 @@ export function mount(el: HTMLElement) {
|
|
|
27
28
|
<AppProvider>
|
|
28
29
|
<TooltipProvider>
|
|
29
30
|
<Router>
|
|
30
|
-
<
|
|
31
|
+
<AccountProvider>
|
|
32
|
+
<AppRouter />
|
|
33
|
+
</AccountProvider>
|
|
31
34
|
</Router>
|
|
32
35
|
<Toaster />
|
|
33
36
|
</TooltipProvider>
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import type { NavigationRequest } from '@/lib/navigation'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AppSettings,
|
|
4
|
+
CompiledView,
|
|
5
|
+
HarnessAvailability,
|
|
6
|
+
HarnessStatus,
|
|
7
|
+
WidgetInfo,
|
|
8
|
+
WorkspaceType,
|
|
9
|
+
WorkspaceState
|
|
10
|
+
} from '@/lib/types'
|
|
3
11
|
|
|
4
12
|
export type WorkspaceEvent =
|
|
13
|
+
| { type: 'connection:opened' }
|
|
14
|
+
| {
|
|
15
|
+
type: 'harness-status:changed'
|
|
16
|
+
harness: WorkspaceType
|
|
17
|
+
status: HarnessStatus
|
|
18
|
+
}
|
|
19
|
+
| { type: 'workspace-harness:switched'; workspaceId: string; harness: WorkspaceType }
|
|
5
20
|
| { type: 'widget:updated'; name: string }
|
|
6
21
|
| { type: 'widget-layout:updated'; widgets: WidgetInfo[] }
|
|
7
22
|
// `moi refresh` — cache-bust and re-fetch applets without a rebuild. `only`
|
|
8
23
|
// narrows to one kind; absent means both widgets and views.
|
|
9
24
|
| { type: 'applets:refresh'; only?: 'widgets' | 'views' }
|
|
10
25
|
| { type: 'view:updated'; name: string }
|
|
11
|
-
| { type: 'view-layout:updated'; views:
|
|
26
|
+
| { type: 'view-layout:updated'; workspaceId: string; views: CompiledView[] }
|
|
12
27
|
| { type: 'view:deleted'; workspaceId: string; name: string }
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
// A workspace's chat state changed (pin, selection, chat settings, views
|
|
29
|
+
// being built). Carries the whole state, so caches update without a refetch.
|
|
30
|
+
| { type: 'state:changed'; workspaceId: string; state: WorkspaceState }
|
|
15
31
|
// `origin` on an event is the browser tab whose write caused it (absent for
|
|
16
32
|
// CLI and agent changes), so that tab can skip its own echo. See
|
|
17
33
|
// client/lib/browser-tab-id.ts.
|
|
@@ -122,6 +138,7 @@ export class WorkspaceEventsClient {
|
|
|
122
138
|
socket.onopen = () => {
|
|
123
139
|
this.reconnectAttempt = 0
|
|
124
140
|
this.sendNavigationPresence()
|
|
141
|
+
for (const handler of this.listeners) handler({ type: 'connection:opened' })
|
|
125
142
|
}
|
|
126
143
|
|
|
127
144
|
socket.onmessage = event => {
|
|
@@ -26,9 +26,14 @@ const WORKSPACE_COLOR_PROPERTIES = THEME_COLOR_TOKENS.map(
|
|
|
26
26
|
token => [token, themeColorProperty(token)] as const
|
|
27
27
|
)
|
|
28
28
|
const WORKSPACE_RADIUS_PROPERTY = '--radius' as const
|
|
29
|
+
const WORKSPACE_COLOR_ALIASES = {
|
|
30
|
+
'--secondary': 'var(--accent)',
|
|
31
|
+
'--secondary-foreground': 'var(--accent-foreground)'
|
|
32
|
+
} as const
|
|
29
33
|
const WORKSPACE_THEME_PROPERTIES = [
|
|
30
34
|
...WORKSPACE_FONT_PROPERTIES.map(([, property]) => property),
|
|
31
35
|
...WORKSPACE_COLOR_PROPERTIES.map(([, property]) => property),
|
|
36
|
+
...(Object.keys(WORKSPACE_COLOR_ALIASES) as (keyof typeof WORKSPACE_COLOR_ALIASES)[]),
|
|
32
37
|
WORKSPACE_RADIUS_PROPERTY
|
|
33
38
|
]
|
|
34
39
|
|
|
@@ -64,6 +69,10 @@ export function getWorkspaceThemeColorStyle(
|
|
|
64
69
|
for (const [token, property] of WORKSPACE_COLOR_PROPERTIES) {
|
|
65
70
|
style[property] = colors?.[token]
|
|
66
71
|
}
|
|
72
|
+
// CSS aliases resolve where declared; inherited root aliases keep the root colors.
|
|
73
|
+
for (const [property, value] of Object.entries(WORKSPACE_COLOR_ALIASES)) {
|
|
74
|
+
style[property as keyof typeof WORKSPACE_COLOR_ALIASES] = colors ? value : undefined
|
|
75
|
+
}
|
|
67
76
|
return style
|
|
68
77
|
}
|
|
69
78
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Config } from 'tailwindcss'
|
|
2
|
+
|
|
3
|
+
// Compact headings shared by every prose-sm surface in the app.
|
|
4
|
+
export default {
|
|
5
|
+
theme: {
|
|
6
|
+
extend: {
|
|
7
|
+
typography: {
|
|
8
|
+
sm: {
|
|
9
|
+
css: {
|
|
10
|
+
h1: {
|
|
11
|
+
fontSize: '1.375rem',
|
|
12
|
+
fontWeight: '500',
|
|
13
|
+
lineHeight: '1.375',
|
|
14
|
+
marginTop: '1.25rem',
|
|
15
|
+
marginBottom: '0.625rem'
|
|
16
|
+
},
|
|
17
|
+
h2: {
|
|
18
|
+
fontSize: '1.125rem',
|
|
19
|
+
fontWeight: '500',
|
|
20
|
+
lineHeight: '1.375',
|
|
21
|
+
marginTop: '1.25rem',
|
|
22
|
+
marginBottom: '0.625rem'
|
|
23
|
+
},
|
|
24
|
+
h3: {
|
|
25
|
+
fontSize: '1rem',
|
|
26
|
+
fontWeight: '500',
|
|
27
|
+
lineHeight: '1.375',
|
|
28
|
+
marginTop: '1.25rem',
|
|
29
|
+
marginBottom: '0.625rem'
|
|
30
|
+
},
|
|
31
|
+
h4: {
|
|
32
|
+
fontSize: '0.875rem',
|
|
33
|
+
fontWeight: '500',
|
|
34
|
+
lineHeight: '1.375',
|
|
35
|
+
marginTop: '1.25rem',
|
|
36
|
+
marginBottom: '0.625rem'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} satisfies Config
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var N=Object.create;var{getPrototypeOf:H,defineProperty:k,getOwnPropertyNames:J}=Object;var E=Object.prototype.hasOwnProperty;function V(a){return this[a]}var M,Z,e=(a,r,t)=>{var i=a!=null&&typeof a==="object";if(i){var o=r?M??=new WeakMap:Z??=new WeakMap,s=o.get(a);if(s)return s}t=a!=null?N(H(a)):{};let d=r||!a||!a.__esModule||!E.call(a,"default")?k(t,"default",{value:a,enumerable:!0}):t;if(a&&typeof a==="object"||typeof a==="function"){for(let l of J(a))if(!E.call(d,l))k(d,l,{get:V.bind(a,l),enumerable:!0})}if(i)o.set(a,d);return d};var x=(a,r)=>()=>(r||a((r={exports:{}}).exports,r),r.exports);var F=(a)=>a;function Q(a,r){this[a]=F.bind(null,r)}var se=(a,r)=>{for(var t in r)k(a,t,{get:r[t],enumerable:!0,configurable:!0,set:Q.bind(r,t)})};var Le=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var A,y,u,U=(a,r)=>{for(var[t,i,o]of A||[])for(var s=[a],d=globalThis,l=d.document,j,w,m,p,g;w=s.pop();)if(!y[w]&&(m=i[w])){y[w]=1;for(p=1;p<m.length;p++)s.push(o[m[p]]);if(!r&&w!==a&&(j=l&&l.head)){if(u===void 0)u=(p=l.querySelector("meta[property=csp-nonce]"))&&(p.nonce||p.getAttribute("nonce"))||"";if(g=l.createElement("link"),g.rel="modulepreload",g.crossOrigin="",u)g.nonce=u;g.href=new d.URL(m[0],t),j.appendChild(g)}}},G=(a,r,t,i)=>{for(var o={},s=0;s<r.length;s++)o[r[s]]=t[s];(A||=[]).push([a,o,r]),y||={},U(r[i],1)};G(import.meta.url,["0mjzg20x","v88n1bay","825hys3h","g0tcwqxc","nf2wkvf9","71fn6rmj","7yg1m8hx","9bb8m9rx","58dyt9bk","n0nab26d","2y59vrxg"],[["/chunk-0mjzg20x.js"],["/chunk-v88n1bay.js",6,0,7,8],["/chunk-825hys3h.js",7],["/chunk-g0tcwqxc.js",0,8],["/chunk-nf2wkvf9.js"],["/chunk-71fn6rmj.js",10,6,0,7],["/chunk-7yg1m8hx.js",0,7],["/chunk-9bb8m9rx.js",0,8],["/chunk-58dyt9bk.js"],["/chunk-n0nab26d.js",10],["/chunk-2y59vrxg.js"]],0);
|
|
2
|
+
if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);var h=["pink","orange","amber","lime","emerald","cyan","blue","violet"];function b(a){return typeof a==="string"&&h.includes(a)}function S(a){let r=2166136261;for(let t=0;t<a.length;t++)r^=a.charCodeAt(t),r=Math.imul(r,16777619);return h[(r>>>0)%h.length]??h[0]}var Fe=1;var K=8192,W=320;function X(a){return typeof a==="object"&&a!==null&&!Array.isArray(a)}function f(a,r=256){return typeof a==="string"&&a.length>0&&!a.includes("\x00")&&new TextEncoder().encode(a).length<=r}function ye(a){return X(a)&&f(a.id,240)&&a.id.trim().length>0&&(a.name===void 0||f(a.name)&&a.name.trim().length>0)&&b(a.color)&&(a.avatar===void 0||f(a.avatar,K))&&(a.email===void 0||f(a.email,W))}var aa=["Curious Kiwi","Cheerful Cherry","Sleepy Peach","Excited Banana","Cosmic Mango","Velvet Lemon","Electric Plum","Wandering Pear","Dramatic Papaya","Suspicious Pineapple","Confused Coconut","Sneaky Tangerine","Gentle Fig","Quiet Apricot","Mellow Melon","Dreamy Guava"];function P(a,r){let t=a.filter((i)=>i!==r);return t[Math.floor(Math.random()*t.length)]??a[0]}function ra(a){return{name:P(aa,a?.name),color:P(h,a?.color)}}function ta(a,r){let t=r.name.trim();return{id:a,...t?{name:t}:{},color:r.color}}function L(){return ta(`local-${crypto.randomUUID().slice(0,8)}`,ra())}var _="moi:local-profile",ea=Object.freeze([]),c,n,T,I=!1,v=new Set,z=new Set;function C(a,r){return JSON.stringify(a)===JSON.stringify(r)}function re(a){if(!a||typeof a.id!=="string"||!a.id.trim())throw Error("A user profile needs an id.");if(a.name!==void 0&&typeof a.name!=="string")throw Error("A user profile name must be a string when provided.");if(a.color!==void 0&&!b(a.color))throw Error("A user profile color must be one of the user palette names.");let r=a.id.trim(),t=a.name?.trim(),i={id:r,...t?{name:t}:{},color:a.color??S(r),...a.avatar!==void 0?{avatar:a.avatar}:{},...a.email!==void 0?{email:a.email}:{}};if(!ye(i))throw Error("Invalid user profile.");return Object.freeze(i)}function oa(a){if(!Array.isArray(a))throw Error("Users must be an array.");let r=new Set,t=a.map((i)=>{let o=re(i);if(r.has(o.id))throw Error("Users must have unique ids.");return r.add(o.id),o});return Object.freeze(t)}function le(a){if(!a||typeof a!=="object")throw Error("Users must be published as an object.");let r=oa(a.users),t;if(a.me!==void 0&&a.me!==null){if(typeof a.me!=="string")throw Error("The current user id must be a string.");let o=a.me.trim();if(t=r.find((s)=>s.id===o),!t)throw Error("The current user must be listed in users.")}let i=n!=="external"||!C(c,t);if(n="external",i)c=t;if(T=t?r:ea,i)v.forEach((o)=>o());z.forEach((o)=>o())}function Y(){return T}function pe(a){return z.add(a),()=>{z.delete(a)}}function O(){return c}function oe(a){return v.add(a),()=>{v.delete(a)}}function be(){return n}function Be({provider:a,profile:r}){if(n==="external")return;if(a===void 0){if(n===void 0||n==="local")return;n=void 0,c=void 0}else{let t=r===void 0?void 0:re(r);if(n===a&&C(c,t))return;n=a,c=t}v.forEach((t)=>t())}function ia(){try{localStorage.setItem(_,JSON.stringify(c))}catch{}}function ve(a){if(n!==void 0&&n!=="local")return;let r=re(a);n="local",c=r,ia(),v.forEach((t)=>t())}function D(a,r){if(!a||!r||r.provider!==void 0||n!==void 0)return;try{let t=localStorage.getItem(_);if(t){ve(JSON.parse(t));return}}catch{}ve(L())}function q(){if(typeof window>"u"||I)return;I=!0;let a=window;a.moi??={};let r={publishUsers:le};a.moi.collab=r}function R(a){if(a.key!==_||!a.newValue||n!=="local")return;try{let r=re(JSON.parse(a.newValue));if(C(r,c))return;c=r,v.forEach((t)=>t())}catch{}}function B(){return window.addEventListener("storage",R),()=>window.removeEventListener("storage",R)}q();B();async function na(a){let[{mount:r},t,i]=await Promise.all([(U("v88n1bay"),import("/chunk-v88n1bay.js")),(U("825hys3h"),import("/chunk-825hys3h.js")).then((o)=>o.loadAppConfig()),(U("g0tcwqxc"),import("/chunk-g0tcwqxc.js")).then((o)=>o.loadProxyUser())]);D(t?.environment==="local"&&!t.demo,i),r(a)}globalThis.__init=na;export{e,x,se,Le,U,Fe,X,ye,re,le,Y,pe,O,oe,be,Be,ve};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SVG/attribute allowlists and URI sanitization approach derived from DOMPurify.
|
|
3
|
+
* DOMPurify — MIT License, Copyright (c) 2015 Mario Heiderich
|
|
4
|
+
* https://github.com/cure53/DOMPurify/blob/main/LICENSE
|
|
5
|
+
*/var v=new Set(["svg","a","altglyph","altglyphdef","altglyphitem","animate","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","filter","font","foreignobject","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","set","stop","style","switch","symbol","text","textpath","title","tref","tspan","use","view","vkern"]),y=new Set(["a","b","blockquote","body","br","code","del","div","em","h1","h2","h3","h4","h5","h6","i","li","mark","ol","p","pre","span","strong","s","sub","sup","table","tbody","td","th","thead","tr","u","ul"]),A=new Set(["script","iframe","object","embed","form","input","textarea","select","button","link","meta","base","img","video","audio","source","picture","svg"]),x=new Set(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clip-path","clip-rule","clippathunits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","diffuseconstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","from","fx","fy","g1","g2","glyph-name","glyphref","gradienttransform","gradientunits","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","kernelmatrix","kernelunitlength","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","mask","mask-type","maskcontentunits","maskunits","max","media","method","min","mode","name","numoctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","radius","refx","refy","repeatcount","repeatdur","requiredfeatures","restart","result","role","rotate","rx","ry","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","text-anchor","text-decoration","text-rendering","textlength","to","transform","transform-origin","type","u1","u2","unicode","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewbox","visibility","width","word-spacing","wrap","writing-mode","x","x1","x2","xchannelselector","xlink:href","xml:id","xml:space","xlink:title","xmlns","xmlns:xlink","y","y1","y2","z","zoomandpan"]),k=new Set(["class","dir","href","id","lang","role","style","tabindex","title"]),d=/^data-/,p=/^aria-/,o=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,g=/^(?:https?:|mailto:)/i,S=/^data:/i,T=/^data:image\/(?:png|jpeg|jpg|gif|webp|avif|bmp|tiff|x-icon|vnd\.microsoft\.icon)[;,]/i,_=/^data:image\/svg\+xml[;,]/i,u=/^#/;function w(t){return t.replace(/\\([0-9a-fA-F]{1,6})\s?|\\([^\n])/g,(i,r,n)=>{if(r){let e=parseInt(r,16);if(e>1114111||e===0)return"�";return String.fromCodePoint(e)}return n})}var E=/^data:(?:image\/(?:png|jpeg|jpg|gif|webp|avif)|font\/(?:woff2?|opentype|truetype|sfnt)|application\/(?:x-font-woff|font-woff2?|x-font-ttf|x-font-opentype|font-sfnt))[;,]/i;function f(t){let i=w(t);return i=i.replace(/@import\s+(?:url\s*\([^)]*\)|"[^"]*"|'[^']*')[^;]*;?|@import\b[^;]*;?/gi,""),i=i.replace(/expression\s*\([^)]*\)/gi,""),i=i.replace(/-moz-binding\s*:[^;]*/gi,""),i=i.replace(/behavior\s*:[^;]*/gi,""),i=i.replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gis,(r,n,e)=>{let a=e.replace(o,"");if(E.test(a)||u.test(a))return r;return""}),i}function L(t){return f(t)}var N=new Set(["animate","set","animatecolor","animatetransform"]),R=/^(?:href|xlink:href|on)/i;function z(t){let i=t.getAttribute("attributeName");if(!i)return!1;return R.test(i.replace(o,""))}var h=/^on/i,D=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]),m=10;function I(t){let i=t.search(/;base64,/i);if(i>=0){let n=t.slice(i+8),e=Uint8Array.from(atob(n),(a)=>a.charCodeAt(0));return new TextDecoder().decode(e)}let r=t.indexOf(",");if(r<0)return null;return decodeURIComponent(t.slice(r+1))}function C(t){let i=new TextEncoder().encode(t),r=Array.from(i,(n)=>String.fromCharCode(n)).join("");return"data:image/svg+xml;base64,"+btoa(r)}function G(t,i){if(i>=m)return console.warn(`Embedded SVG data URI recursion depth limit (${m}) reached`),null;let r;try{let e=I(t);if(e===null)return null;r=e}catch{return null}let n=b(r,i+1);if(!n)return null;return C(n)}function O(t,i,r,n){let e=r.replace(o,""),a=t.tagName.toLowerCase();if(a==="image"||a==="feimage"){if(T.test(e))return r;if(_.test(e))return G(e,n);return null}if(a==="use"){if(u.test(e))return r;return null}if(a==="a"){if(g.test(e))return r;return null}if(S.test(e)||u.test(e))return r;return null}function l(t,i){for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!x.has(e)){t.removeAttribute(n.name);continue}if(e==="href"||e==="xlink:href"){let s=O(t,e,n.value,i);if(s===null)t.removeAttribute(n.name);else if(s!==n.value)n.value=s;continue}if(e==="style"){n.value=f(n.value);continue}if(D.has(e)&&/url\s*\(/i.test(n.value))n.value=f(n.value)}}function M(t){let i=t.tagName.toLowerCase();for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!k.has(e)){t.removeAttribute(n.name);continue}if(e==="href"){if(i!=="a"){t.removeAttribute(n.name);continue}let s=n.value.replace(o,"");if(!g.test(s))t.removeAttribute(n.name);continue}if(e==="style")n.value=f(n.value)}}function c(t,i,r){for(let n=t.children.length-1;n>=0;n--){let e=t.children[n],a=e.tagName.toLowerCase();if(i==="svg")if(a==="foreignobject")l(e,r),c(e,"html",r);else if(a==="style"){if(l(e,r),e.textContent)e.textContent=L(e.textContent)}else if(N.has(a)&&z(e))e.remove();else if(v.has(a))l(e,r),c(e,"svg",r);else e.remove();else if(A.has(a))e.remove();else if(y.has(a))M(e),c(e,"html",r);else e.remove()}}function b(t,i){let r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return"";let e=r.documentElement;if(e.tagName.toLowerCase()!=="svg")return"";if(l(e,i),c(e,"svg",i),e.children.length===0)return"";return new XMLSerializer().serializeToString(e)}function We(t){return b(t,0)}export{We};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function s(t,e){let o=await t.text();return Error(o||e)}async function p(t,e,o="Request failed"){let n=await fetch(t,e);if(!n.ok)throw await s(n,o);return n.json()}async function N(t,e,o="Request failed"){let n=await fetch(t,e);if(!n.ok)throw await s(n,o)}function v(t,e){return{method:t,headers:{"Content-Type":"application/json"},body:e===void 0?void 0:JSON.stringify(e)}}
|
|
2
|
+
export{p,N,v};
|