symbiote-ui 0.3.0-alpha.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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/canvas/AutoLayout.js +731 -0
- package/canvas/Breadcrumb/Breadcrumb.css.js +75 -0
- package/canvas/Breadcrumb/Breadcrumb.js +96 -0
- package/canvas/Breadcrumb/Breadcrumb.tpl.js +7 -0
- package/canvas/CanvasConnectionRenderer.js +971 -0
- package/canvas/CanvasGraph/CanvasGraph.css.js +29 -0
- package/canvas/CanvasGraph/CanvasGraph.js +1697 -0
- package/canvas/CanvasGraph/CanvasGraphDrawState.js +280 -0
- package/canvas/CanvasGraph/CanvasGraphGeometry.js +194 -0
- package/canvas/CanvasViewport.js +550 -0
- package/canvas/ConnectionRenderer.js +1283 -0
- package/canvas/FlowSimulator.js +326 -0
- package/canvas/ForceLayout.js +226 -0
- package/canvas/ForceWorker.js +1303 -0
- package/canvas/FrameManager.js +223 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.css.js +136 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.js +129 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.tpl.js +12 -0
- package/canvas/GraphTabs/GraphTabs.css.js +101 -0
- package/canvas/GraphTabs/GraphTabs.js +189 -0
- package/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
- package/canvas/LODManager.js +88 -0
- package/canvas/Minimap/Minimap.css.js +73 -0
- package/canvas/Minimap/Minimap.js +210 -0
- package/canvas/Minimap/Minimap.tpl.js +7 -0
- package/canvas/NodeCanvas/NodeCanvas.css.js +398 -0
- package/canvas/NodeCanvas/NodeCanvas.js +1499 -0
- package/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
- package/canvas/NodeSearch/NodeSearch.css.js +97 -0
- package/canvas/NodeSearch/NodeSearch.js +140 -0
- package/canvas/NodeSearch/NodeSearch.tpl.js +25 -0
- package/canvas/NodeViewManager.js +748 -0
- package/canvas/PcbRouteDiagnostics.js +463 -0
- package/canvas/PcbRouter.js +1127 -0
- package/canvas/PinExpansion.js +134 -0
- package/canvas/PseudoConnection.js +84 -0
- package/canvas/SelectionSync.js +163 -0
- package/canvas/SubgraphManager.js +203 -0
- package/canvas/SubgraphRouter.js +452 -0
- package/canvas/ViewportActions.js +473 -0
- package/canvas/graph-explorer.js +339 -0
- package/canvas/graph-layout.js +148 -0
- package/canvas/graph-model.js +68 -0
- package/canvas/html-in-canvas.js +202 -0
- package/canvas/project-graph-builder.js +440 -0
- package/canvas/project-graph-model.js +183 -0
- package/chat/ChatComposer/ChatComposer.css.js +652 -0
- package/chat/ChatComposer/ChatComposer.js +304 -0
- package/chat/ChatList/ChatList.css.js +102 -0
- package/chat/ChatList/ChatList.js +99 -0
- package/chat/ChatList/ChatList.tpl.js +20 -0
- package/chat/ChatListItem/ChatListItem.css.js +117 -0
- package/chat/ChatListItem/ChatListItem.js +32 -0
- package/chat/ChatListItem/ChatListItem.tpl.js +17 -0
- package/chat/ChatMessageItem/ChatMessageItem.css.js +628 -0
- package/chat/ChatMessageItem/ChatMessageItem.js +156 -0
- package/chat/ChatSidebar/ChatSidebar.css.js +150 -0
- package/chat/ChatSidebar/ChatSidebar.js +230 -0
- package/chat/ChatSidebar/ChatSidebar.tpl.js +18 -0
- package/chat/ChatSidebar/constants.js +11 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.css.js +445 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.js +304 -0
- package/chat/ChatTranscript/ChatTranscript.css.js +90 -0
- package/chat/ChatTranscript/ChatTranscript.js +244 -0
- package/chat/chat-context.js +123 -0
- package/chat/message-model.js +156 -0
- package/cli.js +20 -0
- package/control/Button/Button.css.js +93 -0
- package/control/Button/Button.js +78 -0
- package/control/Button/Button.tpl.js +3 -0
- package/control/Field/Field.css.js +91 -0
- package/control/Field/Field.js +17 -0
- package/control/Field/Field.tpl.js +3 -0
- package/core/Connection.js +47 -0
- package/core/Editor.js +449 -0
- package/core/Frame.js +33 -0
- package/core/GraphMermaid.js +348 -0
- package/core/GraphText.js +228 -0
- package/core/Node.js +145 -0
- package/core/Portal.js +106 -0
- package/core/Socket.js +187 -0
- package/core/SubgraphNode.js +121 -0
- package/core/base-path.js +55 -0
- package/core/dom-utils.js +14 -0
- package/core/index.js +18 -0
- package/core/local-cache.js +26 -0
- package/core/state-sync.js +227 -0
- package/custom-elements.json +6380 -0
- package/discover.js +240 -0
- package/display/Badge/Badge.css.js +44 -0
- package/display/Badge/Badge.js +17 -0
- package/display/Badge/Badge.tpl.js +3 -0
- package/display/Banner/Banner.css.js +61 -0
- package/display/Banner/Banner.js +17 -0
- package/display/Banner/Banner.tpl.js +3 -0
- package/display/CodeBlock/CodeBlock.css.js +194 -0
- package/display/CodeBlock/CodeBlock.js +220 -0
- package/display/CodeBlock/CodeBlock.tpl.js +11 -0
- package/display/DataTable/DataTable.css.js +101 -0
- package/display/DataTable/DataTable.js +136 -0
- package/display/DataTable/DataTable.tpl.js +13 -0
- package/display/EmptyState/EmptyState.css.js +33 -0
- package/display/EmptyState/EmptyState.js +17 -0
- package/display/EmptyState/EmptyState.tpl.js +3 -0
- package/display/EventFeed/EventFeed.css.js +145 -0
- package/display/EventFeed/EventFeed.js +64 -0
- package/display/EventFeed/EventFeed.tpl.js +14 -0
- package/display/EventFeed/EventFeedItem.js +116 -0
- package/display/EventFeed/EventFeedItem.tpl.js +22 -0
- package/display/LoadingOverlay/LoadingOverlay.css.js +91 -0
- package/display/LoadingOverlay/LoadingOverlay.js +48 -0
- package/display/LoadingOverlay/LoadingOverlay.tpl.js +12 -0
- package/display/Metric/Metric.css.js +60 -0
- package/display/Metric/Metric.js +17 -0
- package/display/Metric/Metric.tpl.js +6 -0
- package/display/OutputGraphPreview/OutputGraphPreview.css.js +122 -0
- package/display/OutputGraphPreview/OutputGraphPreview.js +89 -0
- package/display/OutputGraphPreview/OutputGraphPreview.tpl.js +13 -0
- package/display/OutputListPreview/OutputListPreview.css.js +109 -0
- package/display/OutputListPreview/OutputListPreview.js +77 -0
- package/display/OutputListPreview/OutputListPreview.tpl.js +13 -0
- package/display/SourceEditor/SourceEditor.css.js +39 -0
- package/display/SourceEditor/SourceEditor.js +129 -0
- package/display/SourceEditor/SourceEditor.tpl.js +10 -0
- package/display/SourceViewer/SourceViewer.css.js +80 -0
- package/display/SourceViewer/SourceViewer.js +418 -0
- package/display/SourceViewer/SourceViewer.tpl.js +17 -0
- package/display/StatusRibbon/StatusRibbon.css.js +73 -0
- package/display/StatusRibbon/StatusRibbon.js +87 -0
- package/display/StatusRibbon/StatusRibbon.tpl.js +7 -0
- package/display/event-feed-adapter.js +72 -0
- package/display/format-utils.js +29 -0
- package/display/highlight.js +659 -0
- package/display/icons.js +37 -0
- package/display/markdown-formatter.js +60 -0
- package/display/network-approval-page.js +487 -0
- package/display/output-preview.js +261 -0
- package/effects/CellBg/CellBg.css.js +33 -0
- package/effects/CellBg/CellBg.js +410 -0
- package/effects/CellBg/CellBg.tpl.js +5 -0
- package/graph/canvas-adapter.js +223 -0
- package/graph/graph-algorithms.js +31 -0
- package/graph/index.js +46 -0
- package/graph/model.js +176 -0
- package/graph/project-graph-build.js +66 -0
- package/graph/project-graph-metadata.js +253 -0
- package/graph/project-package.js +128 -0
- package/graph/project-runtime.js +116 -0
- package/graph/project-transaction.js +284 -0
- package/graph/skeleton-utils.js +84 -0
- package/graph/theme-contract.js +36 -0
- package/graph/transaction-parser.js +56 -0
- package/icons/MaterialSymbols.js +69 -0
- package/icons/material-symbols-outlined-400.ttf +0 -0
- package/icons/material-symbols.css +24 -0
- package/index.js +95 -0
- package/inspector/InspectorPanel/InspectorPanel.css.js +375 -0
- package/inspector/InspectorPanel/InspectorPanel.js +368 -0
- package/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
- package/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
- package/inspector/TemplatePreview/TemplatePreview.js +145 -0
- package/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
- package/interactions/ConnectFlow.js +304 -0
- package/interactions/Drag.js +104 -0
- package/interactions/Selector.js +133 -0
- package/interactions/SnapGrid.js +66 -0
- package/interactions/Zoom.js +139 -0
- package/layout/ActionZone/ActionZone.css.js +88 -0
- package/layout/ActionZone/ActionZone.js +261 -0
- package/layout/ActionZone/ActionZone.tpl.js +11 -0
- package/layout/CrossLayoutPortalBridge/CrossLayoutPortalBridge.js +255 -0
- package/layout/Layout/Layout.css.js +91 -0
- package/layout/Layout/Layout.js +637 -0
- package/layout/Layout/Layout.tpl.js +27 -0
- package/layout/LayoutNode/LayoutNode.css.js +302 -0
- package/layout/LayoutNode/LayoutNode.js +509 -0
- package/layout/LayoutNode/LayoutNode.tpl.js +39 -0
- package/layout/LayoutPreview/LayoutPreview.css.js +46 -0
- package/layout/LayoutPreview/LayoutPreview.js +102 -0
- package/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
- package/layout/LayoutRouter/LayoutRouter.js +274 -0
- package/layout/LayoutRouter/SectionRegistry.js +135 -0
- package/layout/LayoutRouter/routerSync.js +250 -0
- package/layout/LayoutSidebar/LayoutSidebar.css.js +411 -0
- package/layout/LayoutSidebar/LayoutSidebar.js +368 -0
- package/layout/LayoutSidebar/LayoutSidebar.tpl.js +26 -0
- package/layout/LayoutSidebar/SidebarSection.css.js +20 -0
- package/layout/LayoutSidebar/SidebarSection.js +184 -0
- package/layout/LayoutSidebar/SidebarSection.tpl.js +22 -0
- package/layout/LayoutTree.js +373 -0
- package/layout/PanelMenu/PanelMenu.css.js +43 -0
- package/layout/PanelMenu/PanelMenu.js +95 -0
- package/layout/PanelMenu/PanelMenu.tpl.js +17 -0
- package/layout/ProjectTabs/ProjectTabs.css.js +188 -0
- package/layout/ProjectTabs/ProjectTabs.js +77 -0
- package/layout/ProjectTabs/ProjectTabs.tpl.js +15 -0
- package/layout/index.js +40 -0
- package/list/ListDetailShell/ListDetailShell.css.js +128 -0
- package/list/ListDetailShell/ListDetailShell.js +72 -0
- package/list/ListDetailShell/ListDetailShell.tpl.js +36 -0
- package/list/ListItem/ListItem.css.js +111 -0
- package/list/ListItem/ListItem.js +66 -0
- package/list/ListItem/ListItem.tpl.js +18 -0
- package/locale/index.js +503 -0
- package/manifest/component-registry.js +2446 -0
- package/manifest/graph-schema.js +285 -0
- package/manifest/index.js +6 -0
- package/manifest/project-schema-catalog.js +246 -0
- package/manifest/rule-catalog.js +201 -0
- package/manifest/theme-catalog.js +2149 -0
- package/manifest/ui-schema-catalog.js +334 -0
- package/menu/ContextMenu/ContextMenu.css.js +61 -0
- package/menu/ContextMenu/ContextMenu.js +82 -0
- package/menu/ContextMenu/ContextMenu.tpl.js +19 -0
- package/navigation/QuickOpen/QuickOpen.css.js +92 -0
- package/navigation/QuickOpen/QuickOpen.js +185 -0
- package/navigation/QuickOpen/QuickOpen.tpl.js +15 -0
- package/navigation/quick-open-utils.js +101 -0
- package/node/CtrlItem/CtrlItem.css.js +41 -0
- package/node/CtrlItem/CtrlItem.js +24 -0
- package/node/CtrlItem/CtrlItem.tpl.js +17 -0
- package/node/GraphFrame/GraphFrame.css.js +66 -0
- package/node/GraphFrame/GraphFrame.js +32 -0
- package/node/GraphFrame/GraphFrame.tpl.js +13 -0
- package/node/GraphNode/GraphNode.css.js +815 -0
- package/node/GraphNode/GraphNode.js +173 -0
- package/node/GraphNode/GraphNode.tpl.js +33 -0
- package/node/NodeCallout/NodeCallout.css.js +91 -0
- package/node/NodeCallout/NodeCallout.js +281 -0
- package/node/NodeCallout/NodeCallout.tpl.js +8 -0
- package/node/NodeSocket/NodeSocket.css.js +68 -0
- package/node/NodeSocket/NodeSocket.js +26 -0
- package/node/NodeSocket/NodeSocket.tpl.js +7 -0
- package/node/PortItem/PortItem.css.js +93 -0
- package/node/PortItem/PortItem.js +87 -0
- package/node/PortItem/PortItem.tpl.js +10 -0
- package/package.json +165 -0
- package/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
- package/palette/PaletteBrowser/PaletteBrowser.js +152 -0
- package/palette/PaletteBrowser/PaletteBrowser.tpl.js +23 -0
- package/plugins/History.js +408 -0
- package/plugins/Readonly.js +60 -0
- package/rules/symbiote-3x.json +170 -0
- package/schemas/component-descriptor-v1.json +91 -0
- package/schemas/component-descriptor-v2.json +145 -0
- package/schemas/graph-model-v1.json +179 -0
- package/schemas/graph-v1.json +91 -0
- package/schemas/project-package-v1.json +102 -0
- package/schemas/project-transaction-v1.json +114 -0
- package/schemas/runtime-ui-v1.json +80 -0
- package/schemas/theme-rule-block-v1.json +73 -0
- package/shapes/CircleShape.js +79 -0
- package/shapes/CommentShape.js +35 -0
- package/shapes/DiamondShape.js +130 -0
- package/shapes/NodeShape.js +79 -0
- package/shapes/PillShape.js +91 -0
- package/shapes/RectShape.js +84 -0
- package/shapes/SVGShape.js +525 -0
- package/shapes/index.js +63 -0
- package/surface/Card/Card.css.js +57 -0
- package/surface/Card/Card.js +17 -0
- package/surface/Card/Card.tpl.js +3 -0
- package/themes/Palette.js +30 -0
- package/themes/Skin.js +113 -0
- package/themes/Theme.js +82 -0
- package/themes/carbon.js +135 -0
- package/themes/dark.js +140 -0
- package/themes/default-dark.js +714 -0
- package/themes/default-provider.css +635 -0
- package/themes/default-provider.js +718 -0
- package/themes/ebook.js +136 -0
- package/themes/grey.js +137 -0
- package/themes/light.js +139 -0
- package/themes/neon.js +138 -0
- package/themes/pcb.js +273 -0
- package/themes/synthwave.js +138 -0
- package/tokens/base.json +29 -0
- package/tokens/themes/carbon.json +11 -0
- package/tokens/themes/dark.json +12 -0
- package/tokens/themes/default-dark.json +1543 -0
- package/tokens/themes/default-provider.json +1543 -0
- package/tokens/themes/ebook.json +11 -0
- package/tokens/themes/grey.json +11 -0
- package/tokens/themes/light.json +12 -0
- package/tokens/themes/neon.json +11 -0
- package/tokens/themes/pcb.json +11 -0
- package/tokens/themes/synthwave.json +11 -0
- package/toolbar/QuickToolbar/QuickToolbar.css.js +152 -0
- package/toolbar/QuickToolbar/QuickToolbar.js +529 -0
- package/toolbar/QuickToolbar/QuickToolbar.tpl.js +34 -0
- package/tree/TreePanel/TreePanel.css.js +112 -0
- package/tree/TreePanel/TreePanel.js +147 -0
- package/tree/TreePanel/TreePanel.tpl.js +18 -0
- package/tree/TreeView/TreeView.css.js +122 -0
- package/tree/TreeView/TreeView.js +365 -0
- package/tree/TreeView/TreeView.tpl.js +10 -0
- package/ui/dialogs.js +221 -0
- package/ui/host-adapters.js +114 -0
- package/ui/index.js +660 -0
- package/ui/locale.js +50 -0
- package/ui/overlay-stack.js +89 -0
- package/ui/shared-styles.js +26 -0
- package/webmcp.js +37 -0
- package/xr/deep-graph.js +646 -0
- package/xr/emulation.js +198 -0
- package/xr/gesture.js +228 -0
- package/xr/html-canvas-renderer.js +472 -0
- package/xr/index.js +15 -0
- package/xr/layout-projection.js +1046 -0
- package/xr/panel-frame.js +128 -0
- package/xr/panel-host.js +267 -0
- package/xr/pointer.js +258 -0
- package/xr/scene-controller.js +242 -0
- package/xr/spatial-scene.js +212 -0
- package/xr/theme-bridge.js +105 -0
- package/xr/three-webxr-adapter.js +3439 -0
- package/xr/webgl-layer-renderer.js +419 -0
- package/xr/webxr.js +679 -0
- package/xr/workbench.js +516 -0
package/display/icons.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const ICONS = {
|
|
2
|
+
OK: '[icon:ok]',
|
|
3
|
+
ERROR: '[icon:error]',
|
|
4
|
+
WAIT: '[icon:wait]',
|
|
5
|
+
WARN: '[icon:warn]',
|
|
6
|
+
RUN: '[icon:run]',
|
|
7
|
+
INFO: '[icon:info]',
|
|
8
|
+
STOP: '[icon:stop]',
|
|
9
|
+
PAUSE: '[icon:pause]',
|
|
10
|
+
SKIP: '[icon:skip]',
|
|
11
|
+
BOUNCE: '[icon:bounce]'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ICON_MAP = {
|
|
15
|
+
'[icon:ok]': { name: 'check_circle', kind: 'ok' },
|
|
16
|
+
'[icon:error]': { name: 'cancel', kind: 'error' },
|
|
17
|
+
'[icon:wait]': { name: 'hourglass_empty', kind: 'wait' },
|
|
18
|
+
'[icon:warn]': { name: 'warning', kind: 'warn' },
|
|
19
|
+
'[icon:run]': { name: 'sync', kind: 'run' },
|
|
20
|
+
'[icon:info]': { name: 'info', kind: 'info' },
|
|
21
|
+
'[icon:stop]': { name: 'block', kind: 'stop' },
|
|
22
|
+
'[icon:pause]': { name: 'pause_circle', kind: 'pause' },
|
|
23
|
+
'[icon:skip]': { name: 'skip_next', kind: 'skip' },
|
|
24
|
+
'[icon:bounce]': { name: 'reply', kind: 'bounce' }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function renderIconHtml(marker) {
|
|
28
|
+
let config = ICON_MAP[marker]
|
|
29
|
+
if (!config) return ''
|
|
30
|
+
let spin = marker === ICONS.RUN ? 'spin-icon' : ''
|
|
31
|
+
return `<span class="material-symbols-outlined portal-inline-icon portal-inline-icon-${config.kind} ${spin}">${config.name}</span>`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function replaceIconsWithHtml(text) {
|
|
35
|
+
if (!text) return ''
|
|
36
|
+
return text.replace(/\[icon:[a-z]+\]/g, match => renderIconHtml(match) || match)
|
|
37
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { renderMarkdown } from './highlight.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {*} str
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function escapeHtml(str) {
|
|
8
|
+
if (!str) return '';
|
|
9
|
+
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {number} sec
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function formatElapsed(sec) {
|
|
17
|
+
if (sec < 60) return `${sec}s`;
|
|
18
|
+
let m = Math.floor(sec / 60);
|
|
19
|
+
let s = sec % 60;
|
|
20
|
+
return s > 0 ? `${m}m ${s}s` : `${m}m`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} html
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
export function formatMarkdownMentions(html) {
|
|
28
|
+
return String(html || '').replace(
|
|
29
|
+
/(?:<code class="md-inline-code">|<\/code>|"|'|')*@\[([^\]]+)\](?:<code class="md-inline-code">|<\/code>|"|'|')*/g,
|
|
30
|
+
'<span class="markdown-mention">@[$1]</span>'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} text
|
|
36
|
+
* @param {Object} [options]
|
|
37
|
+
* @param {string} [options.basePath]
|
|
38
|
+
* @param {function} [options.render]
|
|
39
|
+
* @param {function} [options.resolveImageSrc]
|
|
40
|
+
* @param {function} [options.transformHtml]
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
export function formatMarkdown(text, options = {}) {
|
|
44
|
+
if (!text) return '';
|
|
45
|
+
let {
|
|
46
|
+
basePath = '',
|
|
47
|
+
render = renderMarkdown,
|
|
48
|
+
resolveImageSrc,
|
|
49
|
+
transformHtml,
|
|
50
|
+
} = options || {};
|
|
51
|
+
|
|
52
|
+
let html = render(text, { basePath, resolveImageSrc });
|
|
53
|
+
html = formatMarkdownMentions(html);
|
|
54
|
+
|
|
55
|
+
if (typeof transformHtml === 'function') {
|
|
56
|
+
html = transformHtml(html);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return html;
|
|
60
|
+
}
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { createTranslator, getLocalization } from '../locale/index.js';
|
|
2
|
+
|
|
3
|
+
const TEXT_KEYS = {
|
|
4
|
+
title: 'networkApproval.title',
|
|
5
|
+
heading: 'networkApproval.heading',
|
|
6
|
+
message: 'networkApproval.message',
|
|
7
|
+
requestLabel: 'networkApproval.requestLabel',
|
|
8
|
+
addressLabel: 'networkApproval.addressLabel',
|
|
9
|
+
waitingStatus: 'networkApproval.waitingStatus',
|
|
10
|
+
approvedStatus: 'networkApproval.approvedStatus',
|
|
11
|
+
rejectedStatus: 'networkApproval.rejectedStatus',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function escapeHtml(value) {
|
|
15
|
+
return String(value ?? '').replace(/[&<>"']/g, (char) => ({
|
|
16
|
+
'&': '&',
|
|
17
|
+
'<': '<',
|
|
18
|
+
'>': '>',
|
|
19
|
+
'"': '"',
|
|
20
|
+
"'": ''',
|
|
21
|
+
})[char]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function serializeText(text = {}, options = {}) {
|
|
25
|
+
let locale = options.locale ?? getLocalization().locale;
|
|
26
|
+
let t = createTranslator({ locale, messages: options.messages });
|
|
27
|
+
let defaults = Object.fromEntries(
|
|
28
|
+
Object.entries(TEXT_KEYS).map(([name, key]) => [name, t(key)])
|
|
29
|
+
);
|
|
30
|
+
return { ...defaults, ...text };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function scriptJson(value) {
|
|
34
|
+
return JSON.stringify(value)
|
|
35
|
+
.replace(/</g, '\\u003C')
|
|
36
|
+
.replace(/>/g, '\\u003E')
|
|
37
|
+
.replace(/&/g, '\\u0026')
|
|
38
|
+
.replace(/\u2028/g, '\\u2028')
|
|
39
|
+
.replace(/\u2029/g, '\\u2029');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function createNetworkApprovalPageStyles() {
|
|
43
|
+
return `
|
|
44
|
+
:root {
|
|
45
|
+
--sn-theme-hue: 218;
|
|
46
|
+
--sn-theme-chroma: 89%;
|
|
47
|
+
--sn-theme-bg-lightness: 10%;
|
|
48
|
+
--sn-theme-surface-lightness: 13%;
|
|
49
|
+
--sn-theme-text-lightness: 94%;
|
|
50
|
+
--sn-theme-radius-scale: 1;
|
|
51
|
+
--sn-theme-motion-scale: 1;
|
|
52
|
+
--sn-theme-elevation-scale: 1;
|
|
53
|
+
--sn-hue-base: 0;
|
|
54
|
+
--sn-hue-accent: var(--sn-theme-hue);
|
|
55
|
+
--sn-sat-vivid: var(--sn-theme-chroma);
|
|
56
|
+
--sn-sat-muted: 0%;
|
|
57
|
+
--sn-lit-bg: var(--sn-theme-bg-lightness);
|
|
58
|
+
--sn-lit-surface: var(--sn-theme-surface-lightness);
|
|
59
|
+
--sn-lit-text: var(--sn-theme-text-lightness);
|
|
60
|
+
--sn-lit-text-dim: 60%;
|
|
61
|
+
--sn-lit-accent: 63%;
|
|
62
|
+
--sn-bg: hsl(0 0% var(--sn-lit-bg));
|
|
63
|
+
--sn-panel-bg: hsl(0 0% var(--sn-lit-surface));
|
|
64
|
+
--sn-node-border: hsl(var(--sn-hue-base) var(--sn-sat-muted) var(--sn-lit-text) / 0.1);
|
|
65
|
+
--sn-node-selected: hsl(var(--sn-hue-accent) var(--sn-sat-vivid) var(--sn-lit-accent));
|
|
66
|
+
--sn-node-radius: calc(6px * var(--sn-theme-radius-scale));
|
|
67
|
+
--sn-node-shadow: 0 2px calc(8px * var(--sn-theme-elevation-scale)) hsl(var(--sn-hue-base) var(--sn-sat-muted) 0% / 0.4);
|
|
68
|
+
--sn-text: hsl(var(--sn-hue-base) var(--sn-sat-muted) var(--sn-lit-text));
|
|
69
|
+
--sn-text-dim: hsl(var(--sn-hue-base) var(--sn-sat-muted) var(--sn-lit-text-dim));
|
|
70
|
+
--sn-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
71
|
+
--sn-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
|
|
72
|
+
--sn-cell-bg: var(--sn-bg);
|
|
73
|
+
--sn-cell-dot: hsl(var(--sn-hue-base) var(--sn-sat-muted) 31%);
|
|
74
|
+
--sn-cell-base-alpha: 0.06;
|
|
75
|
+
--sn-cell-alpha-span: 0.18;
|
|
76
|
+
--sn-cell-glare: hsl(var(--sn-hue-base) var(--sn-sat-muted) var(--sn-lit-text) / 0.02);
|
|
77
|
+
--sn-cell-vignette-mid: hsl(var(--sn-hue-base) var(--sn-sat-muted) var(--sn-lit-bg) / 0.7);
|
|
78
|
+
--sn-cell-vignette-edge: var(--sn-bg);
|
|
79
|
+
--sn-cell-noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
* {
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
body {
|
|
87
|
+
margin: 0;
|
|
88
|
+
min-height: 100vh;
|
|
89
|
+
display: grid;
|
|
90
|
+
place-items: center;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
background: var(--sn-cell-bg);
|
|
93
|
+
color: var(--sn-text);
|
|
94
|
+
font: 14px var(--sn-font);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sn-network-approval-cell-bg,
|
|
98
|
+
.sn-network-approval-cell-bg canvas,
|
|
99
|
+
.sn-network-approval-cell-bg::after,
|
|
100
|
+
body::after {
|
|
101
|
+
content: "";
|
|
102
|
+
position: fixed;
|
|
103
|
+
inset: 0;
|
|
104
|
+
pointer-events: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sn-network-approval-cell-bg {
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
z-index: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.sn-network-approval-cell-bg canvas {
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
display: block;
|
|
116
|
+
background: var(--sn-cell-bg);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.sn-network-approval-cell-bg::after {
|
|
120
|
+
background:
|
|
121
|
+
radial-gradient(ellipse 80% 50% at 50% -10%, var(--sn-cell-glare) 0%, transparent 100%),
|
|
122
|
+
radial-gradient(ellipse at 50% 50%, transparent 20%, var(--sn-cell-vignette-mid) 70%, var(--sn-cell-vignette-edge) 100%),
|
|
123
|
+
var(--sn-cell-noise);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
body::after {
|
|
127
|
+
background:
|
|
128
|
+
linear-gradient(to bottom, var(--sn-bg) 0%, transparent 18%),
|
|
129
|
+
linear-gradient(to top, var(--sn-bg) 0%, transparent 18%),
|
|
130
|
+
linear-gradient(to right, var(--sn-bg) 0%, transparent 18%),
|
|
131
|
+
linear-gradient(to left, var(--sn-bg) 0%, transparent 18%);
|
|
132
|
+
z-index: 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
main {
|
|
136
|
+
position: relative;
|
|
137
|
+
width: min(520px, calc(100vw - 32px));
|
|
138
|
+
padding: 22px;
|
|
139
|
+
border: 1px solid var(--sn-node-border);
|
|
140
|
+
border-radius: var(--sn-node-radius);
|
|
141
|
+
background: color-mix(in srgb, var(--sn-panel-bg) 92%, transparent);
|
|
142
|
+
box-shadow: var(--sn-node-shadow), 0 18px 60px hsl(var(--sn-hue-base) var(--sn-sat-muted) 0% / 0.32);
|
|
143
|
+
backdrop-filter: blur(18px);
|
|
144
|
+
z-index: 2;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
h1 {
|
|
148
|
+
margin: 0 0 10px;
|
|
149
|
+
font-size: 18px;
|
|
150
|
+
line-height: 1.2;
|
|
151
|
+
letter-spacing: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
p {
|
|
155
|
+
margin: 10px 0 0;
|
|
156
|
+
color: var(--sn-text-dim);
|
|
157
|
+
line-height: 1.45;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
code {
|
|
161
|
+
color: var(--sn-node-selected);
|
|
162
|
+
font-family: var(--sn-font-mono);
|
|
163
|
+
font-size: 12px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#status {
|
|
167
|
+
color: var(--sn-text);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@media (prefers-reduced-motion: reduce) {
|
|
171
|
+
.sn-network-approval-cell-bg canvas {
|
|
172
|
+
opacity: 0.55;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function createNetworkApprovalCellBgScript() {
|
|
179
|
+
return `
|
|
180
|
+
(() => {
|
|
181
|
+
const canvas = document.getElementById('sn-network-approval-canvas');
|
|
182
|
+
const ctx = canvas?.getContext?.('2d');
|
|
183
|
+
if (!canvas || !ctx) return;
|
|
184
|
+
|
|
185
|
+
const RULE_B = [3];
|
|
186
|
+
const RULE_S = [2, 3];
|
|
187
|
+
const CELL_SIZE = 14;
|
|
188
|
+
const STEP_MS = 75;
|
|
189
|
+
const MIN_RADIUS = 2;
|
|
190
|
+
const MAX_RADIUS = 5;
|
|
191
|
+
const FADE_RATE = 0.04;
|
|
192
|
+
const PALETTE_SIZE = 32;
|
|
193
|
+
const prefersReducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
194
|
+
const state = {
|
|
195
|
+
cols: 0,
|
|
196
|
+
rows: 0,
|
|
197
|
+
grid: new Uint8Array(0),
|
|
198
|
+
radii: new Float32Array(0),
|
|
199
|
+
palette: [],
|
|
200
|
+
running: false,
|
|
201
|
+
currentSpeed: 0,
|
|
202
|
+
accumulator: 0,
|
|
203
|
+
lastTime: performance.now(),
|
|
204
|
+
isAnimating: false,
|
|
205
|
+
stagnantCount: 0,
|
|
206
|
+
pulseTimer: null,
|
|
207
|
+
bgFill: 'transparent',
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
function readToken(token) {
|
|
211
|
+
return getComputedStyle(document.documentElement).getPropertyValue(token).trim();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function normalizeColor(value) {
|
|
215
|
+
const probe = document.createElement('span');
|
|
216
|
+
probe.style.color = value;
|
|
217
|
+
document.documentElement.append(probe);
|
|
218
|
+
const normalized = getComputedStyle(probe).color.trim();
|
|
219
|
+
probe.remove();
|
|
220
|
+
return normalized || null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function parseRgb(value) {
|
|
224
|
+
const normalized = normalizeColor(value);
|
|
225
|
+
if (!normalized) return null;
|
|
226
|
+
const rgbMatch = normalized.match(/rgba?\\(([^)]+)\\)/);
|
|
227
|
+
if (rgbMatch) {
|
|
228
|
+
const channels = rgbMatch[1]
|
|
229
|
+
.replaceAll(',', ' ')
|
|
230
|
+
.split(/[ /\\t]+/)
|
|
231
|
+
.filter(Boolean)
|
|
232
|
+
.slice(0, 3)
|
|
233
|
+
.map((part) => part.endsWith('%') ? Number.parseFloat(part) * 2.55 : Number.parseFloat(part));
|
|
234
|
+
return channels.every(Number.isFinite) ? channels : null;
|
|
235
|
+
}
|
|
236
|
+
const srgbMatch = normalized.match(/color\\(\\s*srgb\\s+([^)]+)\\)/);
|
|
237
|
+
if (!srgbMatch) return null;
|
|
238
|
+
const channels = srgbMatch[1]
|
|
239
|
+
.split(/[ /\\t]+/)
|
|
240
|
+
.filter(Boolean)
|
|
241
|
+
.slice(0, 3)
|
|
242
|
+
.map((part) => part.endsWith('%') ? Number.parseFloat(part) * 2.55 : Number.parseFloat(part) * 255);
|
|
243
|
+
return channels.every(Number.isFinite) ? channels : null;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function buildPalette() {
|
|
247
|
+
const bg = readToken('--sn-cell-bg') || readToken('--sn-bg');
|
|
248
|
+
const dot = readToken('--sn-cell-dot') || readToken('--sn-text-dim');
|
|
249
|
+
const bgRgb = parseRgb(bg) || [0, 0, 0];
|
|
250
|
+
const dotRgb = parseRgb(dot) || bgRgb;
|
|
251
|
+
const baseAlpha = Number.parseFloat(readToken('--sn-cell-base-alpha')) || 0;
|
|
252
|
+
const alphaSpan = Number.parseFloat(readToken('--sn-cell-alpha-span')) || 0;
|
|
253
|
+
state.bgFill = normalizeColor(bg) || 'transparent';
|
|
254
|
+
state.palette = [];
|
|
255
|
+
for (let i = 0; i < PALETTE_SIZE; i++) {
|
|
256
|
+
const t = i / (PALETTE_SIZE - 1);
|
|
257
|
+
const alpha = baseAlpha + t * alphaSpan;
|
|
258
|
+
const r = Math.round(bgRgb[0] * (1 - alpha) + dotRgb[0] * alpha);
|
|
259
|
+
const g = Math.round(bgRgb[1] * (1 - alpha) + dotRgb[1] * alpha);
|
|
260
|
+
const b = Math.round(bgRgb[2] * (1 - alpha) + dotRgb[2] * alpha);
|
|
261
|
+
state.palette.push('#' + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0'));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function seedRandom() {
|
|
266
|
+
if (!state.grid.length) return;
|
|
267
|
+
for (let i = 0; i < state.grid.length; i++) {
|
|
268
|
+
state.grid[i] = Math.random() < 0.15 ? 1 : 0;
|
|
269
|
+
if (state.grid[i]) state.radii[i] = MIN_RADIUS;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function draw() {
|
|
274
|
+
if (!canvas._w) return;
|
|
275
|
+
const w = canvas._w;
|
|
276
|
+
const h = canvas._h;
|
|
277
|
+
ctx.clearRect(0, 0, w, h);
|
|
278
|
+
ctx.fillStyle = state.bgFill;
|
|
279
|
+
ctx.fillRect(0, 0, w, h);
|
|
280
|
+
const maxIdx = PALETTE_SIZE - 1;
|
|
281
|
+
for (let y = 0; y < state.rows; y++) {
|
|
282
|
+
for (let x = 0; x < state.cols; x++) {
|
|
283
|
+
const idx = y * state.cols + x;
|
|
284
|
+
const alive = state.grid[idx];
|
|
285
|
+
const targetR = alive ? MAX_RADIUS : MIN_RADIUS;
|
|
286
|
+
const currentR = state.radii[idx];
|
|
287
|
+
state.radii[idx] = alive
|
|
288
|
+
? currentR + (targetR - currentR) * 0.2
|
|
289
|
+
: currentR + (targetR - currentR) * FADE_RATE;
|
|
290
|
+
const radius = state.radii[idx];
|
|
291
|
+
const t = Math.max(0, Math.min(1, (radius - MIN_RADIUS) / (MAX_RADIUS - MIN_RADIUS)));
|
|
292
|
+
const paletteIndex = (t * maxIdx + 0.5) | 0;
|
|
293
|
+
ctx.beginPath();
|
|
294
|
+
ctx.arc(x * CELL_SIZE, y * CELL_SIZE, radius, 0, Math.PI * 2);
|
|
295
|
+
ctx.fillStyle = state.palette[paletteIndex];
|
|
296
|
+
ctx.fill();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function resize() {
|
|
302
|
+
const dpr = devicePixelRatio || 1;
|
|
303
|
+
const w = canvas.parentElement.clientWidth;
|
|
304
|
+
const h = canvas.parentElement.clientHeight;
|
|
305
|
+
if (!w || !h) return;
|
|
306
|
+
canvas.width = w * dpr;
|
|
307
|
+
canvas.height = h * dpr;
|
|
308
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
309
|
+
canvas._w = w;
|
|
310
|
+
canvas._h = h;
|
|
311
|
+
buildPalette();
|
|
312
|
+
const oldGrid = state.grid;
|
|
313
|
+
const oldRadii = state.radii;
|
|
314
|
+
const oldCols = state.cols;
|
|
315
|
+
const oldRows = state.rows;
|
|
316
|
+
state.cols = Math.ceil(w / CELL_SIZE) + 1;
|
|
317
|
+
state.rows = Math.ceil(h / CELL_SIZE) + 1;
|
|
318
|
+
state.grid = new Uint8Array(state.cols * state.rows);
|
|
319
|
+
state.radii = new Float32Array(state.cols * state.rows);
|
|
320
|
+
state.radii.fill(MIN_RADIUS);
|
|
321
|
+
if (oldGrid.length) {
|
|
322
|
+
const mc = Math.min(state.cols, oldCols);
|
|
323
|
+
const mr = Math.min(state.rows, oldRows);
|
|
324
|
+
for (let y = 0; y < mr; y++) {
|
|
325
|
+
for (let x = 0; x < mc; x++) {
|
|
326
|
+
state.grid[y * state.cols + x] = oldGrid[y * oldCols + x];
|
|
327
|
+
state.radii[y * state.cols + x] = oldRadii[y * oldCols + x];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
seedRandom();
|
|
332
|
+
}
|
|
333
|
+
draw();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function injectNoise() {
|
|
337
|
+
const regionW = Math.max(4, (state.cols * 0.3) | 0);
|
|
338
|
+
const regionH = Math.max(4, (state.rows * 0.3) | 0);
|
|
339
|
+
const startX = (Math.random() * Math.max(1, state.cols - regionW)) | 0;
|
|
340
|
+
const startY = (Math.random() * Math.max(1, state.rows - regionH)) | 0;
|
|
341
|
+
for (let y = startY; y < startY + regionH; y++) {
|
|
342
|
+
for (let x = startX; x < startX + regionW; x++) {
|
|
343
|
+
if (Math.random() < 0.15) {
|
|
344
|
+
const idx = y * state.cols + x;
|
|
345
|
+
state.grid[idx] = 1;
|
|
346
|
+
state.radii[idx] = MIN_RADIUS;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function step() {
|
|
353
|
+
const len = state.cols * state.rows;
|
|
354
|
+
const next = new Uint8Array(len);
|
|
355
|
+
let changed = 0;
|
|
356
|
+
for (let y = 0; y < state.rows; y++) {
|
|
357
|
+
for (let x = 0; x < state.cols; x++) {
|
|
358
|
+
let neighbors = 0;
|
|
359
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
360
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
361
|
+
if (dx === 0 && dy === 0) continue;
|
|
362
|
+
const nx = (x + dx + state.cols) % state.cols;
|
|
363
|
+
const ny = (y + dy + state.rows) % state.rows;
|
|
364
|
+
neighbors += state.grid[ny * state.cols + nx];
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const idx = y * state.cols + x;
|
|
368
|
+
const alive = state.grid[idx];
|
|
369
|
+
next[idx] = alive ? (RULE_S.includes(neighbors) ? 1 : 0) : (RULE_B.includes(neighbors) ? 1 : 0);
|
|
370
|
+
if (next[idx] !== alive) changed++;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
state.grid = next;
|
|
374
|
+
if (changed < len * 0.02) {
|
|
375
|
+
state.stagnantCount++;
|
|
376
|
+
if (state.stagnantCount >= 5) {
|
|
377
|
+
injectNoise();
|
|
378
|
+
state.stagnantCount = 0;
|
|
379
|
+
}
|
|
380
|
+
} else {
|
|
381
|
+
state.stagnantCount = 0;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function stop() {
|
|
386
|
+
state.running = false;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function loop() {
|
|
390
|
+
if (!state.isAnimating) return;
|
|
391
|
+
const time = performance.now();
|
|
392
|
+
const dt = Math.min(time - state.lastTime, 100);
|
|
393
|
+
state.lastTime = time;
|
|
394
|
+
const targetSpeed = state.running ? 1 : 0;
|
|
395
|
+
state.currentSpeed += (targetSpeed - state.currentSpeed) * 0.03;
|
|
396
|
+
if (!state.running && state.currentSpeed < 0.005) {
|
|
397
|
+
state.currentSpeed = 0;
|
|
398
|
+
state.isAnimating = false;
|
|
399
|
+
}
|
|
400
|
+
state.accumulator += dt * state.currentSpeed;
|
|
401
|
+
let maxSteps = 5;
|
|
402
|
+
while (state.accumulator >= STEP_MS && maxSteps > 0) {
|
|
403
|
+
step();
|
|
404
|
+
state.accumulator -= STEP_MS;
|
|
405
|
+
maxSteps--;
|
|
406
|
+
}
|
|
407
|
+
draw();
|
|
408
|
+
if (state.isAnimating) requestAnimationFrame(loop);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function pulse(duration = 10000) {
|
|
412
|
+
if (prefersReducedMotion) return;
|
|
413
|
+
if (state.pulseTimer) clearTimeout(state.pulseTimer);
|
|
414
|
+
state.running = true;
|
|
415
|
+
if (!state.isAnimating) {
|
|
416
|
+
state.lastTime = performance.now();
|
|
417
|
+
state.isAnimating = true;
|
|
418
|
+
requestAnimationFrame(loop);
|
|
419
|
+
}
|
|
420
|
+
state.pulseTimer = setTimeout(() => {
|
|
421
|
+
state.pulseTimer = null;
|
|
422
|
+
stop();
|
|
423
|
+
}, duration);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
addEventListener('resize', () => {
|
|
427
|
+
resize();
|
|
428
|
+
pulse(10000);
|
|
429
|
+
});
|
|
430
|
+
resize();
|
|
431
|
+
pulse(10000);
|
|
432
|
+
})();
|
|
433
|
+
`;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export function renderNetworkApprovalPage(options = {}) {
|
|
437
|
+
let text = serializeText(options.text, options);
|
|
438
|
+
let requestId = String(options.requestId ?? '');
|
|
439
|
+
let address = String(options.address ?? '');
|
|
440
|
+
let waitEndpoint = String(options.waitEndpoint || '/api/network-auth/wait');
|
|
441
|
+
|
|
442
|
+
return `<!doctype html>
|
|
443
|
+
<html>
|
|
444
|
+
<head>
|
|
445
|
+
<meta charset="utf-8">
|
|
446
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
447
|
+
<title>${escapeHtml(text.title)}</title>
|
|
448
|
+
<style>${createNetworkApprovalPageStyles()}</style>
|
|
449
|
+
</head>
|
|
450
|
+
<body>
|
|
451
|
+
<div class="sn-network-approval-cell-bg" aria-hidden="true">
|
|
452
|
+
<canvas id="sn-network-approval-canvas"></canvas>
|
|
453
|
+
</div>
|
|
454
|
+
<main>
|
|
455
|
+
<h1>${escapeHtml(text.heading)}</h1>
|
|
456
|
+
<p>${escapeHtml(text.message)}</p>
|
|
457
|
+
<p>${escapeHtml(text.requestLabel)}: <code>${escapeHtml(requestId)}</code><br>${escapeHtml(text.addressLabel)}: <code>${escapeHtml(address)}</code></p>
|
|
458
|
+
<p id="status">${escapeHtml(text.waitingStatus)}</p>
|
|
459
|
+
</main>
|
|
460
|
+
<script>${createNetworkApprovalCellBgScript()}</script>
|
|
461
|
+
<script>
|
|
462
|
+
const requestId = ${scriptJson(requestId)};
|
|
463
|
+
const waitEndpoint = ${scriptJson(waitEndpoint)};
|
|
464
|
+
const approvedStatus = ${scriptJson(text.approvedStatus)};
|
|
465
|
+
const rejectedStatus = ${scriptJson(text.rejectedStatus)};
|
|
466
|
+
async function poll() {
|
|
467
|
+
try {
|
|
468
|
+
const separator = waitEndpoint.includes('?') ? '&' : '?';
|
|
469
|
+
const res = await fetch(waitEndpoint + separator + 'id=' + encodeURIComponent(requestId), { cache: 'no-store' });
|
|
470
|
+
const data = await res.json();
|
|
471
|
+
if (data.ok) {
|
|
472
|
+
document.getElementById('status').textContent = approvedStatus;
|
|
473
|
+
location.reload();
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
if (data.rejected) {
|
|
477
|
+
document.getElementById('status').textContent = rejectedStatus;
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
} catch {}
|
|
481
|
+
setTimeout(poll, 1500);
|
|
482
|
+
}
|
|
483
|
+
poll();
|
|
484
|
+
</script>
|
|
485
|
+
</body>
|
|
486
|
+
</html>`;
|
|
487
|
+
}
|