moi-computer 0.11.0 → 0.11.1-dev.be1ed10
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 +2 -2
- package/client/AGENTS.md +2 -2
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/toast.tsx +2 -2
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/applets/AppletMount.tsx +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +24 -15
- package/client/features/chat/ChatPopup.tsx +9 -5
- package/client/features/chat/applet-chat-intents.ts +170 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -128
- package/client/features/chat/composer/ModelPicker.tsx +47 -60
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
- package/client/features/chat/sessions/session-view.ts +53 -0
- package/client/features/chat/useChat.ts +42 -24
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/dev/HarnessDebugPage.tsx +11 -8
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +855 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +25 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +210 -162
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +2 -30
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +23 -30
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-mzrgr577.js +5 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/default-widgets.ts +32 -0
- package/lib/format.ts +67 -7
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +91 -34
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +42 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +139 -66
- package/server/applet-typecheck.ts +95 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +13 -242
- package/server/applets/build-worker.ts +178 -0
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +44 -189
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +169 -108
- package/server/control.ts +63 -42
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +45 -50
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +49 -56
- package/server/harness/claude-code/NOTES.md +54 -13
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +13 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +447 -343
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +19 -1
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +13 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +9 -5
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +22 -14
- package/server/navigation-relay.ts +110 -0
- package/server/preview.ts +3 -1
- package/server/registry.ts +71 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +48 -9
- package/server/tabs.ts +19 -33
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +20 -2
- package/server/views.ts +126 -6
- package/server/web.ts +46 -13
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +90 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +38 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +27 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -92
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -264
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-104m57qw.js +0 -2
- package/dist/chunk-59zf0m6n.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-c9pjqx9m.js +0 -14
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-p1yqa71k.js +0 -83
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-r5xrenjy.css +0 -1
- package/dist/chunk-tny85yt2.js +0 -2
- package/dist/chunk-v7wr1df4.js +0 -2
- package/server/bundler/applet-css.ts +0 -155
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
import { findFreePosition } from '@/client/features/widgets/grid'
|
|
4
|
-
import type { WidgetInfo, WorkspaceLayout } from '@/lib/types'
|
|
5
|
-
|
|
6
|
-
// Rebalances the widget grid as the (server-authoritative) widget set changes.
|
|
7
|
-
// The widgets list is the source of truth for what exists; the layout grid only
|
|
8
|
-
// carries positions. Placement is derived here and persisted via `setLayout`
|
|
9
|
-
// (the layout mutation):
|
|
10
|
-
// - a brand-new widget (never seen) with no grid slot → gets packed in
|
|
11
|
-
// - a visible widget whose config size changed → re-packed
|
|
12
|
-
// - a widget the user hid (known, absent from the grid) → left hidden
|
|
13
|
-
//
|
|
14
|
-
// On the first resolution per workspace nothing is placed: the saved grid is
|
|
15
|
-
// authoritative, so hidden widgets stay hidden and visible ones keep positions.
|
|
16
|
-
// This runs on every widgets change (including focus/switch-back refetches) but
|
|
17
|
-
// is a no-op when the set is unchanged, so it never loops or un-hides widgets.
|
|
18
|
-
export function useGridReconcile(
|
|
19
|
-
workspaceId: string,
|
|
20
|
-
widgets: WidgetInfo[] | undefined,
|
|
21
|
-
layout: WorkspaceLayout,
|
|
22
|
-
setLayout: (update: Partial<WorkspaceLayout>) => void
|
|
23
|
-
) {
|
|
24
|
-
// Last-seen widget sizes, scoped to the workspace it was recorded for.
|
|
25
|
-
const baseline = useRef<{
|
|
26
|
-
workspaceId: string
|
|
27
|
-
sizes: Map<string, { w: number; h: number }>
|
|
28
|
-
} | null>(null)
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (!widgets) return
|
|
32
|
-
const sizes = new Map(widgets.map(w => [w.id, { w: w.config.colSpan, h: w.config.rowSpan }]))
|
|
33
|
-
|
|
34
|
-
// First sight of this workspace's widgets — trust the saved grid, move nothing.
|
|
35
|
-
if (baseline.current?.workspaceId !== workspaceId) {
|
|
36
|
-
baseline.current = { workspaceId, sizes }
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const prev = baseline.current.sizes
|
|
41
|
-
const gridIds = new Set(layout.widgetGrid.map(g => g.i))
|
|
42
|
-
const needsPositioning = widgets.filter(w => {
|
|
43
|
-
const known = prev.has(w.id)
|
|
44
|
-
if (!known) return !gridIds.has(w.id) // new widget with no slot → place it
|
|
45
|
-
if (!gridIds.has(w.id)) return false // known + hidden by the user → leave it hidden
|
|
46
|
-
const p = prev.get(w.id)! // visible → re-pack only if its size changed
|
|
47
|
-
return p.w !== w.config.colSpan || p.h !== w.config.rowSpan
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
baseline.current = { workspaceId, sizes }
|
|
51
|
-
if (needsPositioning.length === 0) return
|
|
52
|
-
|
|
53
|
-
// Keep untouched widgets where they are; reconstruct w/h from config for
|
|
54
|
-
// overlap detection, then pack the ones that need a (new) position.
|
|
55
|
-
const newConfig = new Map(widgets.map(w => [w.id, w.config]))
|
|
56
|
-
const kept = layout.widgetGrid
|
|
57
|
-
.filter(g => !needsPositioning.some(w => w.id === g.i) && newConfig.has(g.i))
|
|
58
|
-
.map(g => {
|
|
59
|
-
const c = newConfig.get(g.i)!
|
|
60
|
-
return { i: g.i, x: g.x, y: g.y, w: c.colSpan, h: c.rowSpan }
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const grid = kept.map(({ i, x, y }) => ({ i, x, y }))
|
|
64
|
-
const placed = [...kept]
|
|
65
|
-
for (const w of needsPositioning) {
|
|
66
|
-
const pos = findFreePosition(placed, w.config.colSpan, w.config.rowSpan, 4)
|
|
67
|
-
grid.push({ i: w.id, x: pos.x, y: pos.y })
|
|
68
|
-
placed.push({ i: w.id, x: pos.x, y: pos.y, w: w.config.colSpan, h: w.config.rowSpan })
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
setLayout({ widgetGrid: grid })
|
|
72
|
-
}, [workspaceId, widgets, layout.widgetGrid, setLayout])
|
|
73
|
-
}
|
package/dist/chunk-104m57qw.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Xc as P,Yc as v}from"/chunk-v7wr1df4.js";var w=v((q,$)=>{$.exports=globalThis.__esm.react});var x=P(w(),1);function y(o){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}${o}`}var m=new Set,b=new Set,H=!1,g=null,h=!1,U=1000,f=30000,T=0;function j(){let o=Math.min(U*2**T,f);T++,setTimeout(u,o)}function u(){if(g||h)return;h=!0;let o=new WebSocket(y("/api/workspaces/ws"));o.onopen=()=>{if(g=o,h=!1,T=0,H)for(let i of b)i();H=!0},o.onmessage=(i)=>{try{let p=JSON.parse(i.data);for(let a of m)a(p)}catch{}},o.onclose=()=>{if(g=null,h=!1,m.size>0)j()},o.onerror=()=>{o.close()}}function F(o){return b.add(o),()=>{b.delete(o)}}function G(o){let i=x.useRef(o);i.current=o,x.useEffect(()=>{let p=(a)=>i.current(a);return m.add(p),u(),()=>{if(m.delete(p),m.size===0&&g)g.close(),g=null}},[])}
|
|
2
|
-
export{w as Tc,y as Uc,F as Vc,G as Wc};
|
package/dist/chunk-59zf0m6n.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_c as r}from"/chunk-v7wr1df4.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function o(a){let[{mount:t}]=await Promise.all([import("/chunk-p1yqa71k.js"),import("/chunk-kmbxhgwv.js").then((e)=>e.loadAppConfig())]);t(a)}globalThis.__init=o;
|
package/dist/chunk-bj3akjs2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"/chunk-pcnahct1.js";import"/chunk-v7wr1df4.js";export{a as sanitizeSvg};
|
package/dist/chunk-c9pjqx9m.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import"/chunk-v7wr1df4.js";function t(z,Q){return z[13]=1,z[14]=Q>>8,z[15]=Q&255,z[16]=Q>>8,z[17]=Q&255,z}var e=112,zz=72,Qz=89,Zz=115,p;function Nz(){let z=new Int32Array(256);for(let Q=0;Q<256;Q++){let Z=Q;for(let $=0;$<8;$++)Z=Z&1?3988292384^Z>>>1:Z>>>1;z[Q]=Z}return z}function Iz(z){let Q=-1;if(!p)p=Nz();for(let Z=0;Z<z.length;Z++)Q=p[(Q^z[Z])&255]^Q>>>8;return Q^-1}function Uz(z){let Q=z.length-1;for(let Z=Q;Z>=4;Z--)if(z[Z-4]===9&&z[Z-3]===e&&z[Z-2]===zz&&z[Z-1]===Qz&&z[Z]===Zz)return Z-3;return 0}function $z(z,Q,Z=!1){let $=new Uint8Array(13);Q*=39.3701,$[0]=e,$[1]=zz,$[2]=Qz,$[3]=Zz,$[4]=Q>>>24,$[5]=Q>>>16,$[6]=Q>>>8,$[7]=Q&255,$[8]=$[4],$[9]=$[5],$[10]=$[6],$[11]=$[7],$[12]=1;let Y=Iz($),K=new Uint8Array(4);if(K[0]=Y>>>24,K[1]=Y>>>16,K[2]=Y>>>8,K[3]=Y&255,Z){let X=Uz(z);return z.set($,X),z.set(K,X+13),z}else{let X=new Uint8Array(4);X[0]=0,X[1]=0,X[2]=0,X[3]=9;let J=new Uint8Array(54);return J.set(z,0),J.set(X,33),J.set($,37),J.set(K,50),J}}var Dz="AAlwSFlz",Fz="AAAJcEhZ",Rz="AAAACXBI";function wz(z){let Q=z.indexOf(Dz);if(Q===-1)Q=z.indexOf(Fz);if(Q===-1)Q=z.indexOf(Rz);return Q}var Jz="[modern-screenshot]",D=typeof window<"u",Ez=D&&"Worker"in window,Kz=D&&"atob"in window,Cz=D&&"btoa"in window,x=D?window.navigator?.userAgent:"",Yz=x.includes("Chrome"),S=x.includes("AppleWebKit")&&!Yz,u=x.includes("Firefox"),fz=(z)=>z&&("__CONTEXT__"in z),Tz=(z)=>z.constructor.name==="CSSFontFaceRule",bz=(z)=>z.constructor.name==="CSSImportRule",Sz=(z)=>z.constructor.name==="CSSLayerBlockRule",k=(z)=>z.nodeType===1,f=(z)=>typeof z.className==="object",Xz=(z)=>z.tagName==="image",hz=(z)=>z.tagName==="use",w=(z)=>k(z)&&typeof z.style<"u"&&!f(z),gz=(z)=>z.nodeType===8,vz=(z)=>z.nodeType===3,R=(z)=>z.tagName==="IMG",h=(z)=>z.tagName==="VIDEO",pz=(z)=>z.tagName==="CANVAS",yz=(z)=>z.tagName==="TEXTAREA",mz=(z)=>z.tagName==="INPUT",xz=(z)=>z.tagName==="STYLE",uz=(z)=>z.tagName==="SCRIPT",iz=(z)=>z.tagName==="SELECT",cz=(z)=>z.tagName==="SLOT",dz=(z)=>z.tagName==="IFRAME",az=(...z)=>console.warn(Jz,...z);function lz(z){let Q=z?.createElement?.("canvas");if(Q)Q.height=Q.width=1;return Boolean(Q)&&"toDataURL"in Q&&Boolean(Q.toDataURL("image/webp").includes("image/webp"))}var y=(z)=>z.startsWith("data:");function Gz(z,Q){if(z.match(/^[a-z]+:\/\//i))return z;if(D&&z.match(/^\/\//))return window.location.protocol+z;if(z.match(/^[a-z]+:/i))return z;if(!D)return z;let Z=g().implementation.createHTMLDocument(),$=Z.createElement("base"),Y=Z.createElement("a");if(Z.head.appendChild($),Z.body.appendChild(Y),Q)$.href=Q;return Y.href=z,Y.href}function g(z){return(z&&k(z)?z?.ownerDocument:z)??window.document}var v="http://www.w3.org/2000/svg";function jz(z,Q,Z){let $=g(Z).createElementNS(v,"svg");return $.setAttributeNS(null,"width",z.toString()),$.setAttributeNS(null,"height",Q.toString()),$.setAttributeNS(null,"viewBox",`0 0 ${z} ${Q}`),$}function Vz(z,Q){let Z=new XMLSerializer().serializeToString(z);if(Q)Z=Z.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"");return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Z)}`}async function sz(z,Q="image/png",Z=1){try{return await new Promise(($,Y)=>{z.toBlob((K)=>{if(K)$(K);else Y(Error("Blob is null"))},Q,Z)})}catch($){if(Kz)return rz(z.toDataURL(Q,Z));throw $}}function rz(z){let[Q,Z]=z.split(","),$=Q.match(/data:(.+);/)?.[1]??void 0,Y=window.atob(Z),K=Y.length,X=new Uint8Array(K);for(let J=0;J<K;J+=1)X[J]=Y.charCodeAt(J);return new Blob([X],{type:$})}function Hz(z,Q){return new Promise((Z,$)=>{let Y=new FileReader;if(Y.onload=()=>Z(Y.result),Y.onerror=()=>$(Y.error),Y.onabort=()=>$(Error(`Failed read blob to ${Q}`)),Q==="dataUrl")Y.readAsDataURL(z);else if(Q==="arrayBuffer")Y.readAsArrayBuffer(z)})}var nz=(z)=>Hz(z,"dataUrl"),oz=(z)=>Hz(z,"arrayBuffer");function F(z,Q){let Z=g(Q).createElement("img");return Z.decoding="sync",Z.loading="eager",Z.src=z,Z}function E(z,Q){return new Promise((Z)=>{let{timeout:$,ownerDocument:Y,onError:K,onWarn:X}=Q??{},J=typeof z==="string"?F(z,g(Y)):z,V=null,j=null;function G(){Z(J),V&&clearTimeout(V),j?.()}if($)V=setTimeout(G,$);if(h(J)){let M=J.currentSrc||J.src;if(!M){if(J.poster)return E(J.poster,Q).then(Z);return G()}if(J.readyState>=2)return G();let B=G,q=(W)=>{X?.("Failed video load",M,W),K?.(W),G()};j=()=>{J.removeEventListener("loadeddata",B),J.removeEventListener("error",q)},J.addEventListener("loadeddata",B,{once:!0}),J.addEventListener("error",q,{once:!0})}else{let M=Xz(J)?J.href.baseVal:J.currentSrc||J.src;if(!M)return G();let B=async()=>{if(R(J)&&"decode"in J)try{await J.decode()}catch(W){X?.("Failed to decode image, trying to render anyway",J.dataset.originalSrc||M,W)}G()},q=(W)=>{X?.("Failed image load",J.dataset.originalSrc||M,W),G()};if(R(J)&&J.complete)return B();j=()=>{J.removeEventListener("load",B),J.removeEventListener("error",q)},J.addEventListener("load",B,{once:!0}),J.addEventListener("error",q,{once:!0})}})}async function tz(z,Q){if(w(z))if(R(z)||h(z))await E(z,Q);else await Promise.all(["img","video"].flatMap((Z)=>{return Array.from(z.querySelectorAll(Z)).map(($)=>E($,Q))}))}var Bz=function(){let Q=0,Z=()=>`0000${(Math.random()*1679616<<0).toString(36)}`.slice(-4);return()=>{return Q+=1,`u${Z()}${Q}`}}();function Mz(z){return z?.split(",").map((Q)=>Q.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var a=0;function ez(z){let Q=`${Jz}[#${a}]`;return a++,{time:(Z)=>z&&console.time(`${Q} ${Z}`),timeEnd:(Z)=>z&&console.timeEnd(`${Q} ${Z}`),warn:(...Z)=>z&&az(...Z)}}function zQ(z){return{cache:z?"no-cache":"force-cache"}}async function N(z,Q){return fz(z)?z:QQ(z,{...Q,autoDestruct:!0})}async function QQ(z,Q){let{scale:Z=1,workerUrl:$,workerNumber:Y=1}=Q||{},K=Boolean(Q?.debug),X=Q?.features??!0,J=z.ownerDocument??(D?window.document:void 0),V=z.ownerDocument?.defaultView??(D?window:void 0),j=new Map,G={width:0,height:0,quality:1,type:"image/png",scale:Z,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:30000,progress:null,debug:K,fetch:{requestInit:zQ(Q?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...Q?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:Y,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...Q,__CONTEXT__:!0,log:ez(K),node:z,ownerDocument:J,ownerWindow:V,dpi:Z===1?null:96*Z,svgStyleElement:qz(J),svgDefsElement:J?.createElementNS(v,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:Ez&&$&&Y?Y:0})].map(()=>{try{let q=new Worker($);return q.onmessage=async(W)=>{let{url:H,result:L}=W.data;if(L)j.get(H)?.resolve?.(L);else j.get(H)?.reject?.(Error(`Error receiving message from worker: ${H}`))},q.onmessageerror=(W)=>{let{url:H}=W.data;j.get(H)?.reject?.(Error(`Error receiving message from worker: ${H}`))},q}catch(q){return G.log.warn("Failed to new Worker",q),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[lz(J)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:j,drawImageCount:0,tasks:[],features:X,isEnable:(q)=>{if(q==="restoreScrollPosition")return typeof X==="boolean"?!1:X[q]??!1;if(typeof X==="boolean")return X;return X[q]??!0},shadowRoots:[]};G.log.time("wait until load"),await tz(z,{timeout:G.timeout,onWarn:G.log.warn}),G.log.timeEnd("wait until load");let{width:M,height:B}=ZQ(z,G);return G.width=M,G.height=B,G}function qz(z){if(!z)return;let Q=z.createElement("style"),Z=Q.ownerDocument.createTextNode(`
|
|
2
|
-
.______background-clip--text {
|
|
3
|
-
background-clip: text;
|
|
4
|
-
-webkit-background-clip: text;
|
|
5
|
-
}
|
|
6
|
-
`);return Q.appendChild(Z),Q}function ZQ(z,Q){let{width:Z,height:$}=Q;if(k(z)&&(!Z||!$)){let Y=z.getBoundingClientRect();Z=Z||Y.width||Number(z.getAttribute("width"))||0,$=$||Y.height||Number(z.getAttribute("height"))||0}return{width:Z,height:$}}async function $Q(z,Q){let{log:Z,timeout:$,drawImageCount:Y,drawImageInterval:K}=Q;Z.time("image to canvas");let X=await E(z,{timeout:$,onWarn:Q.log.warn}),{canvas:J,context2d:V}=JQ(z.ownerDocument,Q),j=()=>{try{V?.drawImage(X,0,0,J.width,J.height)}catch(G){Q.log.warn("Failed to drawImage",G)}};if(j(),Q.isEnable("fixSvgXmlDecode"))for(let G=0;G<Y;G++)await new Promise((M)=>{setTimeout(()=>{V?.clearRect(0,0,J.width,J.height),j(),M()},G+K)});return Q.drawImageCount=0,Z.timeEnd("image to canvas"),J}function JQ(z,Q){let{width:Z,height:$,scale:Y,backgroundColor:K,maximumCanvasSize:X}=Q,J=z.createElement("canvas");if(J.width=Math.floor(Z*Y),J.height=Math.floor($*Y),J.style.width=`${Z}px`,J.style.height=`${$}px`,X){if(J.width>X||J.height>X)if(J.width>X&&J.height>X)if(J.width>J.height)J.height*=X/J.width,J.width=X;else J.width*=X/J.height,J.height=X;else if(J.width>X)J.height*=X/J.width,J.width=X;else J.width*=X/J.height,J.height=X}let V=J.getContext("2d");if(V&&K)V.fillStyle=K,V.fillRect(0,0,J.width,J.height);return{canvas:J,context2d:V}}function Wz(z,Q){if(z.ownerDocument)try{let K=z.toDataURL();if(K!=="data:,")return F(K,z.ownerDocument)}catch(K){Q.log.warn("Failed to clone canvas",K)}let Z=z.cloneNode(!1),$=z.getContext("2d"),Y=Z.getContext("2d");try{if($&&Y)Y.putImageData($.getImageData(0,0,z.width,z.height),0,0);return Z}catch(K){Q.log.warn("Failed to clone canvas",K)}return Z}function KQ(z,Q){try{if(z?.contentDocument?.documentElement)return i(z.contentDocument.documentElement,Q)}catch(Z){Q.log.warn("Failed to clone iframe",Z)}return z.cloneNode(!1)}function YQ(z){let Q=z.cloneNode(!1);if(z.currentSrc&&z.currentSrc!==z.src)Q.src=z.currentSrc,Q.srcset="";if(Q.loading==="lazy")Q.loading="eager";return Q}async function XQ(z,Q){if(z.ownerDocument&&!z.currentSrc&&z.poster)return F(z.poster,z.ownerDocument);let Z=z.cloneNode(!1);if(Z.crossOrigin="anonymous",z.currentSrc&&z.currentSrc!==z.src)Z.src=z.currentSrc;let $=Z.ownerDocument;if($){let Y=!0;if(await E(Z,{onError:()=>Y=!1,onWarn:Q.log.warn}),!Y){if(z.poster)return F(z.poster,z.ownerDocument);return Z}Z.currentTime=z.currentTime,await new Promise((X)=>{Z.addEventListener("seeked",X,{once:!0})});let K=$.createElement("canvas");K.width=z.offsetWidth,K.height=z.offsetHeight;try{let X=K.getContext("2d");if(X)X.drawImage(Z,0,0,K.width,K.height)}catch(X){if(Q.log.warn("Failed to clone video",X),z.poster)return F(z.poster,z.ownerDocument);return Z}return Wz(K,Q)}return Z}function GQ(z,Q){if(pz(z))return Wz(z,Q);if(dz(z))return KQ(z,Q);if(R(z))return YQ(z);if(h(z))return XQ(z,Q);return z.cloneNode(!1)}function jQ(z){let Q=z.sandbox;if(!Q){let{ownerDocument:Z}=z;try{if(Z)Q=Z.createElement("iframe"),Q.id=`__SANDBOX__${Bz()}`,Q.width="0",Q.height="0",Q.style.visibility="hidden",Q.style.position="fixed",Z.body.appendChild(Q),Q.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',z.sandbox=Q}catch($){z.log.warn("Failed to getSandBox",$)}}return Q}var VQ=["width","height","-webkit-text-fill-color"],HQ=["stroke","fill"];function Lz(z,Q,Z){let{defaultComputedStyles:$}=Z,Y=z.nodeName.toLowerCase(),K=f(z)&&Y!=="svg",X=K?HQ.map((H)=>[H,z.getAttribute(H)]).filter(([,H])=>H!==null):[],J=[K&&"svg",Y,X.map((H,L)=>`${H}=${L}`).join(","),Q].filter(Boolean).join(":");if($.has(J))return $.get(J);let j=jQ(Z)?.contentWindow;if(!j)return new Map;let G=j?.document,M,B;if(K)M=G.createElementNS(v,"svg"),B=M.ownerDocument.createElementNS(M.namespaceURI,Y),X.forEach(([H,L])=>{B.setAttributeNS(null,H,L)}),M.appendChild(B);else M=B=G.createElement(Y);B.textContent=" ",G.body.appendChild(M);let q=j.getComputedStyle(B,Q),W=new Map;for(let H=q.length,L=0;L<H;L++){let P=q.item(L);if(VQ.includes(P))continue;W.set(P,q.getPropertyValue(P))}return G.body.removeChild(M),$.set(J,W),W}function Pz(z,Q,Z){let $=new Map,Y=[],K=new Map;if(Z)for(let J of Z)X(J);else for(let J=z.length,V=0;V<J;V++){let j=z.item(V);X(j)}for(let J=Y.length,V=0;V<J;V++)K.get(Y[V])?.forEach((j,G)=>$.set(G,j));function X(J){let V=z.getPropertyValue(J),j=z.getPropertyPriority(J),G=J.lastIndexOf("-"),M=G>-1?J.substring(0,G):void 0;if(M){let B=K.get(M);if(!B)B=new Map,K.set(M,B);B.set(J,[V,j])}if(Q.get(J)===V&&!j)return;if(M)Y.push(M);else $.set(J,[V,j])}return $}function BQ(z,Q,Z,$){let{ownerWindow:Y,includeStyleProperties:K,currentParentNodeStyle:X}=$,J=Q.style,V=Y.getComputedStyle(z),j=Lz(z,null,$);X?.forEach((M,B)=>{j.delete(B)});let G=Pz(V,j,K);if(G.delete("transition-property"),G.delete("all"),G.delete("d"),G.delete("content"),Z)G.delete("position"),G.delete("margin-top"),G.delete("margin-right"),G.delete("margin-bottom"),G.delete("margin-left"),G.delete("margin-block-start"),G.delete("margin-block-end"),G.delete("margin-inline-start"),G.delete("margin-inline-end"),G.set("box-sizing",["border-box",""]);if(G.get("background-clip")?.[0]==="text")Q.classList.add("______background-clip--text");if(Yz){if(!G.has("font-kerning"))G.set("font-kerning",["normal",""]);if((G.get("overflow-x")?.[0]==="hidden"||G.get("overflow-y")?.[0]==="hidden")&&G.get("text-overflow")?.[0]==="ellipsis"&&z.scrollWidth===z.clientWidth)G.set("text-overflow",["clip",""])}for(let M=J.length,B=0;B<M;B++)J.removeProperty(J.item(B));return G.forEach(([M,B],q)=>{J.setProperty(q,M,B)}),G}function MQ(z,Q){if(yz(z)||mz(z)||iz(z))Q.setAttribute("value",z.value)}var qQ=["::before","::after"],WQ=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function LQ(z,Q,Z,$,Y){let{ownerWindow:K,svgStyleElement:X,svgStyles:J,currentNodeStyle:V}=$;if(!X||!K)return;function j(G){let M=K.getComputedStyle(z,G),B=M.getPropertyValue("content");if(!B||B==="none")return;Y?.(B),B=B.replace(/(')|(")|(counter\(.+\))/g,"");let q=[Bz()],W=Lz(z,G,$);V?.forEach((O,A)=>{W.delete(A)});let H=Pz(M,W,$.includeStyleProperties);if(H.delete("content"),H.delete("-webkit-locale"),H.get("background-clip")?.[0]==="text")Q.classList.add("______background-clip--text");let L=[`content: '${B}';`];if(H.forEach(([O,A],U)=>{L.push(`${U}: ${O}${A?" !important":""};`)}),L.length===1)return;try{Q.className=[Q.className,...q].join(" ")}catch(O){$.log.warn("Failed to copyPseudoClass",O);return}let P=L.join(`
|
|
7
|
-
`),_=J.get(P);if(!_)_=[],J.set(P,_);_.push(`.${q[0]}${G}`)}if(qQ.forEach(j),Z)WQ.forEach(j)}var l=new Set(["symbol"]);async function s(z,Q,Z,$,Y){if(k(Z)&&(xz(Z)||uz(Z)))return;if($.filter&&!$.filter(Z))return;if(l.has(Q.nodeName)||l.has(Z.nodeName))$.currentParentNodeStyle=void 0;else $.currentParentNodeStyle=$.currentNodeStyle;let K=await i(Z,$,!1,Y);if($.isEnable("restoreScrollPosition"))PQ(z,K);Q.appendChild(K)}async function r(z,Q,Z,$){let Y=z.firstChild;if(k(z)){if(z.shadowRoot)Y=z.shadowRoot?.firstChild,Z.shadowRoots.push(z.shadowRoot)}for(let K=Y;K;K=K.nextSibling){if(gz(K))continue;if(k(K)&&cz(K)&&typeof K.assignedNodes==="function"){let X=K.assignedNodes();for(let J=0;J<X.length;J++)await s(z,Q,X[J],Z,$)}else await s(z,Q,K,Z,$)}}function PQ(z,Q){if(!w(z)||!w(Q))return;let{scrollTop:Z,scrollLeft:$}=z;if(!Z&&!$)return;let{transform:Y}=Q.style,K=new DOMMatrix(Y),{a:X,b:J,c:V,d:j}=K;K.a=1,K.b=0,K.c=0,K.d=1,K.translateSelf(-$,-Z),K.a=X,K.b=J,K.c=V,K.d=j,Q.style.transform=K.toString()}function OQ(z,Q){let{backgroundColor:Z,width:$,height:Y,style:K}=Q,X=z.style;if(Z)X.setProperty("background-color",Z,"important");if($)X.setProperty("width",`${$}px`,"important");if(Y)X.setProperty("height",`${Y}px`,"important");if(K)for(let J in K)X[J]=K[J]}var _Q=/^[\w-:]+$/;async function i(z,Q,Z=!1,$){let{ownerDocument:Y,ownerWindow:K,fontFamilies:X,onCloneEachNode:J}=Q;if(Y&&vz(z)){if($&&/\S/.test(z.data))$(z.data);return Y.createTextNode(z.data)}if(Y&&K&&k(z)&&(w(z)||f(z))){let j=await GQ(z,Q);if(Q.isEnable("removeAbnormalAttributes")){let H=j.getAttributeNames();for(let L=H.length,P=0;P<L;P++){let _=H[P];if(!_Q.test(_))j.removeAttribute(_)}}let G=Q.currentNodeStyle=BQ(z,j,Z,Q);if(Z)OQ(j,Q);let M=!1;if(Q.isEnable("copyScrollbar")){let H=[G.get("overflow-x")?.[0],G.get("overflow-y")?.[0]];M=H.includes("scroll")||(H.includes("auto")||H.includes("overlay"))&&(z.scrollHeight>z.clientHeight||z.scrollWidth>z.clientWidth)}let B=G.get("text-transform")?.[0],q=Mz(G.get("font-family")?.[0]),W=q?(H)=>{if(B==="uppercase")H=H.toUpperCase();else if(B==="lowercase")H=H.toLowerCase();else if(B==="capitalize")H=H[0].toUpperCase()+H.substring(1);q.forEach((L)=>{let P=X.get(L);if(!P)X.set(L,P=new Set);H.split("").forEach((_)=>P.add(_))})}:void 0;if(LQ(z,j,M,Q,W),MQ(z,j),!h(z))await r(z,j,Q,W);return await J?.(j),j}let V=z.cloneNode(!1);return await r(z,V,Q),await J?.(V),V}function AQ(z){if(z.ownerDocument=void 0,z.ownerWindow=void 0,z.svgStyleElement=void 0,z.svgDefsElement=void 0,z.svgStyles.clear(),z.defaultComputedStyles.clear(),z.sandbox){try{z.sandbox.remove()}catch(Q){z.log.warn("Failed to destroyContext",Q)}z.sandbox=void 0}z.workers=[],z.fontFamilies.clear(),z.fontCssTexts.clear(),z.requests.clear(),z.tasks=[],z.shadowRoots=[]}function kQ(z){let{url:Q,timeout:Z,responseType:$,...Y}=z,K=new AbortController,X=Z?setTimeout(()=>K.abort(),Z):void 0;return fetch(Q,{signal:K.signal,...Y}).then((J)=>{if(!J.ok)throw Error("Failed fetch, not 2xx response",{cause:J});switch($){case"arrayBuffer":return J.arrayBuffer();case"dataUrl":return J.blob().then(nz);case"text":default:return J.text()}}).finally(()=>clearTimeout(X))}function C(z,Q){let{url:Z,requestType:$="text",responseType:Y="text",imageDom:K}=Q,X=Z,{timeout:J,acceptOfImage:V,requests:j,fetchFn:G,fetch:{requestInit:M,bypassingCache:B,placeholderImage:q},font:W,workers:H,fontFamilies:L}=z;if($==="image"&&(S||u))z.drawImageCount++;let P=j.get(Z);if(!P){if(B){if(B instanceof RegExp&&B.test(X))X+=(/\?/.test(X)?"&":"?")+new Date().getTime()}let _=$.startsWith("font")&&W&&W.minify,O=new Set;if(_)$.split(";")[1].split(",").forEach((b)=>{if(!L.has(b))return;L.get(b).forEach((d)=>O.add(d))});let A=_&&O.size,U={url:X,timeout:J,responseType:A?"arrayBuffer":Y,headers:$==="image"?{accept:V}:void 0,...M};P={type:$,resolve:void 0,reject:void 0,response:null},P.response=(async()=>{if(G&&$==="image"){let I=await G(Z);if(I)return I}if(!S&&Z.startsWith("http")&&H.length)return new Promise((I,b)=>{H[j.size&H.length-1].postMessage({rawUrl:Z,...U}),P.resolve=I,P.reject=b});return kQ(U)})().catch((I)=>{if(j.delete(Z),$==="image"&&q)return z.log.warn("Failed to fetch image base64, trying to use placeholder image",X),typeof q==="string"?q:q(K);throw I}),j.set(Z,P)}return P.response}async function Oz(z,Q,Z,$){if(!_z(z))return z;for(let[Y,K]of NQ(z,Q))try{let X=await C(Z,{url:K,requestType:$?"image":"text",responseType:"dataUrl"});z=z.replace(IQ(Y),`$1${X}$3`)}catch(X){Z.log.warn("Failed to fetch css data url",Y,X)}return z}function _z(z){return/url\((['"]?)([^'"]+?)\1\)/.test(z)}var Az=/url\((['"]?)([^'"]+?)\1\)/g;function NQ(z,Q){let Z=[];return z.replace(Az,($,Y,K)=>{return Z.push([K,Gz(K,Q)]),$}),Z.filter(([$])=>!y($))}function IQ(z){let Q=z.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${Q})(['"]?\\))`,"g")}var UQ=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function DQ(z,Q){return UQ.map((Z)=>{let $=z.getPropertyValue(Z);if(!$||$==="none")return null;if(S||u)Q.drawImageCount++;return Oz($,null,Q,!0).then((Y)=>{if(!Y||$===Y)return;z.setProperty(Z,Y,z.getPropertyPriority(Z))})}).filter(Boolean)}function FQ(z,Q){if(R(z)){let Z=z.currentSrc||z.src;if(!y(Z))return[C(Q,{url:Z,imageDom:z,requestType:"image",responseType:"dataUrl"}).then(($)=>{if(!$)return;z.srcset="",z.dataset.originalSrc=Z,z.src=$||""})];if(S||u)Q.drawImageCount++}else if(f(z)&&!y(z.href.baseVal)){let Z=z.href.baseVal;return[C(Q,{url:Z,imageDom:z,requestType:"image",responseType:"dataUrl"}).then(($)=>{if(!$)return;z.dataset.originalSrc=Z,z.href.baseVal=$||""})]}return[]}function RQ(z,Q){let{ownerDocument:Z,svgDefsElement:$}=Q,Y=z.getAttribute("href")??z.getAttribute("xlink:href");if(!Y)return[];let[K,X]=Y.split("#");if(X){let J=`#${X}`,V=Q.shadowRoots.reduce((j,G)=>{return j??G.querySelector(`svg ${J}`)},Z?.querySelector(`svg ${J}`));if(K)z.setAttribute("href",J);if($?.querySelector(J))return[];if(V)return $?.appendChild(V.cloneNode(!0)),[];else if(K)return[C(Q,{url:K,responseType:"text"}).then((j)=>{$?.insertAdjacentHTML("beforeend",j)})]}return[]}function kz(z,Q){let{tasks:Z}=Q;if(k(z)){if(R(z)||Xz(z))Z.push(...FQ(z,Q));if(hz(z))Z.push(...RQ(z,Q))}if(w(z))Z.push(...DQ(z.style,Q));z.childNodes.forEach(($)=>{kz($,Q)})}async function wQ(z,Q){let{ownerDocument:Z,svgStyleElement:$,fontFamilies:Y,fontCssTexts:K,tasks:X,font:J}=Q;if(!Z||!$||!Y.size)return;if(J&&J.cssText){let V=o(J.cssText,Q);$.appendChild(Z.createTextNode(`${V}
|
|
8
|
-
`))}else{let V=Array.from(Z.styleSheets).filter((q)=>{try{return"cssRules"in q&&Boolean(q.cssRules.length)}catch(W){return Q.log.warn(`Error while reading CSS rules from ${q.href}`,W),!1}}),j=Z.implementation.createHTMLDocument(""),G=j.createElement("style");j.head.appendChild(G);let M=G.sheet;if(await Promise.all(V.flatMap((q)=>{return Array.from(q.cssRules).map(async(W)=>{if(bz(W)){let H=W.href,L="";try{L=await C(Q,{url:H,requestType:"text",responseType:"text"})}catch(_){Q.log.warn(`Error fetch remote css import from ${H}`,_)}let P=L.replace(Az,(_,O,A)=>_.replace(A,Gz(A,H)));for(let _ of CQ(P))try{M.insertRule(_,M.cssRules.length)}catch(O){Q.log.warn("Error inserting rule from remote css import",{rule:_,error:O})}}})})),M.cssRules.length)V.push(M);let B=[];V.forEach((q)=>{m(q.cssRules,B)}),B.filter((q)=>Tz(q)&&_z(q.style.getPropertyValue("src"))&&Mz(q.style.getPropertyValue("font-family"))?.some((W)=>Y.has(W))).forEach((q)=>{let W=q,H=K.get(W.cssText);if(H)$.appendChild(Z.createTextNode(`${H}
|
|
9
|
-
`));else X.push(Oz(W.cssText,W.parentStyleSheet?W.parentStyleSheet.href:null,Q).then((L)=>{L=o(L,Q),K.set(W.cssText,L),$.appendChild(Z.createTextNode(`${L}
|
|
10
|
-
`))}))})}}var EQ=/(\/\*[\s\S]*?\*\/)/g,n=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function CQ(z){if(z==null)return[];let Q=[],Z=z.replace(EQ,"");while(!0){let K=n.exec(Z);if(!K)break;Q.push(K[0])}Z=Z.replace(n,"");let $=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,Y=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");while(!0){let K=$.exec(Z);if(!K)if(K=Y.exec(Z),!K)break;else $.lastIndex=Y.lastIndex;else Y.lastIndex=$.lastIndex;Q.push(K[0])}return Q}var fQ=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,TQ=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function o(z,Q){let{font:Z}=Q,$=Z?Z?.preferredFormat:void 0;return $?z.replace(TQ,(Y)=>{while(!0){let[K,,X]=fQ.exec(Y)||[];if(!X)return"";if(X===$)return`src: ${K};`}}):z}function m(z,Q=[]){for(let Z of Array.from(z))if(Sz(Z))Q.push(...m(Z.cssRules));else if("cssRules"in Z)m(Z.cssRules,Q);else Q.push(Z);return Q}var bQ=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function SQ(z){return bQ.test(z.innerHTML)}async function hQ(z,Q){let Z=await N(z,Q);if(k(Z.node)&&f(Z.node)&&!SQ(Z.node))return Z.node;let{ownerDocument:$,log:Y,tasks:K,svgStyleElement:X,svgDefsElement:J,svgStyles:V,font:j,progress:G,autoDestruct:M,onCloneNode:B,onEmbedNode:q,onCreateForeignObjectSvg:W}=Z;Y.time("clone node");let H=await i(Z.node,Z,!0);if(X&&$){let A="";V.forEach((U,I)=>{A+=`${U.join(`,
|
|
11
|
-
`)} {
|
|
12
|
-
${I}
|
|
13
|
-
}
|
|
14
|
-
`}),X.appendChild($.createTextNode(A))}if(Y.timeEnd("clone node"),await B?.(H),j!==!1&&k(H))Y.time("embed web font"),await wQ(H,Z),Y.timeEnd("embed web font");Y.time("embed node"),kz(H,Z);let L=K.length,P=0,_=async()=>{while(!0){let A=K.pop();if(!A)break;try{await A}catch(U){Z.log.warn("Failed to run task",U)}G?.(++P,L)}};G?.(P,L),await Promise.all([...Array.from({length:4})].map(_)),Y.timeEnd("embed node"),await q?.(H);let O=gQ(H,Z);return J&&O.insertBefore(J,O.children[0]),X&&O.insertBefore(X,O.children[0]),M&&AQ(Z),await W?.(O),O}function gQ(z,Q){let{width:Z,height:$}=Q,Y=jz(Z,$,z.ownerDocument),K=Y.ownerDocument.createElementNS(Y.namespaceURI,"foreignObject");return K.setAttributeNS(null,"x","0%"),K.setAttributeNS(null,"y","0%"),K.setAttributeNS(null,"width","100%"),K.setAttributeNS(null,"height","100%"),K.append(z),Y.appendChild(K),Y}async function c(z,Q){let Z=await N(z,Q),$=await hQ(Z),Y=Vz($,Z.isEnable("removeControlCharacter"));if(!Z.autoDestruct)Z.svgStyleElement=qz(Z.ownerDocument),Z.svgDefsElement=Z.ownerDocument?.createElementNS(v,"defs"),Z.svgStyles.clear();let K=F(Y,$.ownerDocument);return await $Q(K,Z)}async function pQ(z,Q){let Z=await N(z,Q),{log:$,type:Y,quality:K,dpi:X}=Z,J=await c(Z);$.time("canvas to blob");let V=await sz(J,Y,K);if(["image/png","image/jpeg"].includes(Y)&&X){let j=await oz(V.slice(0,33)),G=new Uint8Array(j);if(Y==="image/png")G=$z(G,X);else if(Y==="image/jpeg")G=t(G,X);return $.timeEnd("canvas to blob"),new Blob([G,V.slice(33)],{type:Y})}return $.timeEnd("canvas to blob"),V}async function T(z,Q){let Z=await N(z,Q),{log:$,quality:Y,type:K,dpi:X}=Z,J=await c(Z);$.time("canvas to data url");let V=J.toDataURL(K,Y);if(["image/png","image/jpeg"].includes(K)&&X&&Kz&&Cz){let[j,G]=V.split(","),M=0,B=!1;if(K==="image/png"){let O=wz(G);if(O>=0)M=Math.ceil((O+28)/3)*4,B=!0;else M=44}else if(K==="image/jpeg")M=24;let q=G.substring(0,M),W=G.substring(M),H=window.atob(q),L=new Uint8Array(H.length);for(let O=0;O<L.length;O++)L[O]=H.charCodeAt(O);let P=K==="image/png"?$z(L,X,B):t(L,X),_=window.btoa(String.fromCharCode(...P));V=[j,",",_,W].join("")}return $.timeEnd("canvas to data url"),V}async function vQ(z,Q){let Z=await N(z,Q),{width:$,height:Y,ownerDocument:K}=Z,X=await T(Z),J=jz($,Y,K),V=J.ownerDocument.createElementNS(J.namespaceURI,"image");return V.setAttributeNS(null,"href",X),V.setAttributeNS(null,"height","100%"),V.setAttributeNS(null,"width","100%"),J.appendChild(V),Vz(J,Z.isEnable("removeControlCharacter"))}async function yQ(z,Q){let Z=await N(z,Q),{ownerDocument:$,width:Y,height:K,scale:X,type:J}=Z,V=J==="image/svg+xml"?await vQ(Z):await T(Z),j=F(V,$);return j.width=Math.floor(Y*X),j.height=Math.floor(K*X),j.style.width=`${Y}px`,j.style.height=`${K}px`,j}async function mQ(z,Q){return T(await N(z,{...Q,type:"image/jpeg"}))}async function xQ(z,Q){let Z=await N(z,Q),$=await c(Z);return $.getContext("2d").getImageData(0,0,$.width,$.height).data}async function uQ(z,Q){return T(await N(z,{...Q,type:"image/png"}))}async function iQ(z,Q){return T(await N(z,{...Q,type:"image/webp"}))}export{tz as waitUntilLoad,E as loadMedia,iQ as domToWebp,vQ as domToSvg,uQ as domToPng,xQ as domToPixel,mQ as domToJpeg,yQ as domToImage,hQ as domToForeignObjectSvg,T as domToDataUrl,c as domToCanvas,pQ as domToBlob,AQ as destroyContext,QQ as createContext};
|