@peers-app/peers-ui 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +8 -5
- package/babel.config.js +4 -4
- package/biome.json +191 -0
- package/dist/command-palette/command-palette-ui.d.ts +1 -2
- package/dist/command-palette/command-palette-ui.js +175 -244
- package/dist/command-palette/command-palette.js +65 -64
- package/dist/components/chat-overlay.d.ts +2 -2
- package/dist/components/chat-overlay.js +160 -217
- package/dist/components/checkbox.d.ts +5 -4
- package/dist/components/checkbox.js +4 -7
- package/dist/components/group-switcher.d.ts +1 -2
- package/dist/components/group-switcher.js +119 -159
- package/dist/components/input-date.d.ts +3 -3
- package/dist/components/input-date.js +6 -6
- package/dist/components/input-number.d.ts +7 -6
- package/dist/components/input-number.js +25 -20
- package/dist/components/input.d.ts +5 -4
- package/dist/components/input.js +4 -7
- package/dist/components/inverse-lazy-list.d.ts +3 -3
- package/dist/components/inverse-lazy-list.js +13 -47
- package/dist/components/io-schema-values.d.ts +5 -6
- package/dist/components/io-schema-values.js +28 -65
- package/dist/components/io-schema.d.ts +4 -5
- package/dist/components/io-schema.js +42 -79
- package/dist/components/lazy-list.d.ts +3 -3
- package/dist/components/lazy-list.js +38 -58
- package/dist/components/list-screen.d.ts +3 -8
- package/dist/components/list-screen.js +28 -23
- package/dist/components/loading-indicator.d.ts +1 -2
- package/dist/components/loading-indicator.js +2 -6
- package/dist/components/markdown-editor/autolink-plugin.js +5 -8
- package/dist/components/markdown-editor/editor-inline.d.ts +2 -3
- package/dist/components/markdown-editor/editor-inline.js +2 -6
- package/dist/components/markdown-editor/editor.d.ts +6 -6
- package/dist/components/markdown-editor/editor.js +9 -19
- package/dist/components/markdown-editor/markdown-plugin.d.ts +1 -1
- package/dist/components/markdown-editor/markdown-plugin.js +20 -21
- package/dist/components/markdown-editor/mention-node.d.ts +2 -2
- package/dist/components/markdown-editor/mention-node.js +24 -24
- package/dist/components/markdown-editor/mentions-plugin.d.ts +2 -2
- package/dist/components/markdown-editor/mentions-plugin.js +61 -62
- package/dist/components/markdown-editor/theme.js +28 -28
- package/dist/components/markdown-editor/toolbar.d.ts +2 -3
- package/dist/components/markdown-editor/toolbar.js +32 -49
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +43 -43
- package/dist/components/message-logs/message-logs.d.ts +1 -2
- package/dist/components/message-logs/message-logs.js +91 -116
- package/dist/components/messages/avatar.d.ts +3 -4
- package/dist/components/messages/avatar.js +37 -46
- package/dist/components/messages/channel-message-list.d.ts +5 -6
- package/dist/components/messages/channel-message-list.js +34 -34
- package/dist/components/messages/channel-view.d.ts +1 -2
- package/dist/components/messages/channel-view.js +23 -57
- package/dist/components/messages/message-compose.d.ts +3 -4
- package/dist/components/messages/message-compose.js +27 -38
- package/dist/components/messages/message-display.d.ts +2 -3
- package/dist/components/messages/message-display.js +42 -95
- package/dist/components/messages/thread-message-list.d.ts +4 -5
- package/dist/components/messages/thread-message-list.js +29 -29
- package/dist/components/router.d.ts +1 -2
- package/dist/components/router.js +58 -66
- package/dist/components/save-button.d.ts +3 -3
- package/dist/components/save-button.js +23 -33
- package/dist/components/sortable-list.d.ts +11 -12
- package/dist/components/sortable-list.js +42 -22
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.js +16 -47
- package/dist/components/tooltip.d.ts +4 -4
- package/dist/components/tooltip.js +4 -9
- package/dist/components/trust-level-badge.d.ts +2 -3
- package/dist/components/trust-level-badge.js +16 -16
- package/dist/components/trust-level-dropdown.d.ts +3 -4
- package/dist/components/trust-level-dropdown.js +32 -55
- package/dist/components/typeahead.d.ts +3 -3
- package/dist/components/typeahead.js +48 -89
- package/dist/components/voice-indicator.d.ts +2 -2
- package/dist/components/voice-indicator.js +93 -106
- package/dist/components/voice-subscribe-events.d.ts +32 -0
- package/dist/components/voice-subscribe-events.js +2 -0
- package/dist/globals.d.ts +3 -5
- package/dist/globals.js +22 -33
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +22 -12
- package/dist/hooks.test.js +129 -145
- package/dist/index.d.ts +9 -8
- package/dist/index.js +13 -12
- package/dist/mention-configs.d.ts +2 -2
- package/dist/mention-configs.js +55 -42
- package/dist/screens/assistants/assistant-config.d.ts +2 -3
- package/dist/screens/assistants/assistant-config.js +9 -22
- package/dist/screens/assistants/assistant-details.d.ts +1 -2
- package/dist/screens/assistants/assistant-details.js +13 -28
- package/dist/screens/assistants/assistant-info.d.ts +2 -3
- package/dist/screens/assistants/assistant-info.js +3 -17
- package/dist/screens/assistants/assistant-list.d.ts +1 -2
- package/dist/screens/assistants/assistant-list.js +15 -56
- package/dist/screens/assistants/assistant-tools.d.ts +2 -3
- package/dist/screens/assistants/assistant-tools.js +10 -24
- package/dist/screens/console-logs/console-logs-list.d.ts +1 -2
- package/dist/screens/console-logs/console-logs-list.js +130 -134
- package/dist/screens/console-logs/log-display.d.ts +2 -3
- package/dist/screens/console-logs/log-display.js +40 -42
- package/dist/screens/console-logs/log-filters.d.ts +1 -2
- package/dist/screens/console-logs/log-filters.js +2 -24
- package/dist/screens/console-logs/mobile-log-card.d.ts +2 -3
- package/dist/screens/console-logs/mobile-log-card.js +64 -67
- package/dist/screens/console-logs/resizable-table-header.d.ts +1 -2
- package/dist/screens/console-logs/resizable-table-header.js +31 -67
- package/dist/screens/contacts/contact-details.d.ts +1 -2
- package/dist/screens/contacts/contact-details.js +16 -46
- package/dist/screens/contacts/contact-list.d.ts +1 -2
- package/dist/screens/contacts/contact-list.js +44 -103
- package/dist/screens/contacts/index.d.ts +4 -4
- package/dist/screens/contacts/index.js +1 -1
- package/dist/screens/contacts/user-connect.d.ts +1 -2
- package/dist/screens/contacts/user-connect.js +85 -186
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -2
- package/dist/screens/data-explorer/data-explorer.js +61 -181
- package/dist/screens/data-explorer/index.d.ts +2 -2
- package/dist/screens/data-explorer/query-executor.d.ts +1 -2
- package/dist/screens/data-explorer/query-executor.js +56 -166
- package/dist/screens/groups/group-details.d.ts +1 -2
- package/dist/screens/groups/group-details.js +27 -122
- package/dist/screens/groups/group-invite-listener.d.ts +2 -3
- package/dist/screens/groups/group-invite-listener.js +8 -104
- package/dist/screens/groups/group-list.d.ts +1 -2
- package/dist/screens/groups/group-list.js +56 -133
- package/dist/screens/groups/group-members.d.ts +2 -3
- package/dist/screens/groups/group-members.js +62 -132
- package/dist/screens/groups/index.d.ts +4 -4
- package/dist/screens/groups/index.js +1 -1
- package/dist/screens/join-group/index.d.ts +2 -2
- package/dist/screens/join-group/join-group.d.ts +1 -2
- package/dist/screens/join-group/join-group.js +9 -109
- package/dist/screens/network-viewer/connection-troubleshooter.d.ts +2 -3
- package/dist/screens/network-viewer/connection-troubleshooter.js +89 -193
- package/dist/screens/network-viewer/cpu-usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/cpu-usage-graph.js +60 -99
- package/dist/screens/network-viewer/device-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/device-details-modal.js +25 -177
- package/dist/screens/network-viewer/group-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/group-details-modal.js +31 -142
- package/dist/screens/network-viewer/index.d.ts +4 -4
- package/dist/screens/network-viewer/index.js +3 -3
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +22 -0
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/network-viewer.d.ts +1 -2
- package/dist/screens/network-viewer/network-viewer.js +91 -296
- package/dist/screens/network-viewer/usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/usage-graph.js +78 -110
- package/dist/screens/packages/package-details.d.ts +1 -2
- package/dist/screens/packages/package-details.js +35 -41
- package/dist/screens/packages/package-info.d.ts +2 -2
- package/dist/screens/packages/package-info.js +33 -86
- package/dist/screens/packages/package-list.d.ts +1 -2
- package/dist/screens/packages/package-list.js +42 -106
- package/dist/screens/packages/package-new-local.d.ts +1 -2
- package/dist/screens/packages/package-new-local.js +13 -19
- package/dist/screens/packages/package-versions.d.ts +2 -3
- package/dist/screens/packages/package-versions.js +29 -96
- package/dist/screens/peer-types/peer-type-details.d.ts +3 -4
- package/dist/screens/peer-types/peer-type-details.js +26 -78
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -2
- package/dist/screens/peer-types/peer-type-list.js +13 -24
- package/dist/screens/search/global-search.d.ts +1 -2
- package/dist/screens/search/global-search.js +104 -182
- package/dist/screens/settings/color-mode-dropdown.d.ts +3 -4
- package/dist/screens/settings/color-mode-dropdown.js +18 -37
- package/dist/screens/settings/settings-page.d.ts +1 -1
- package/dist/screens/settings/settings-page.js +86 -213
- package/dist/screens/settings/voice-settings-agent.d.ts +1 -1
- package/dist/screens/settings/voice-settings-agent.js +7 -44
- package/dist/screens/settings/voice-settings-api-keys.d.ts +2 -2
- package/dist/screens/settings/voice-settings-api-keys.js +2 -29
- package/dist/screens/settings/voice-settings-output.d.ts +2 -2
- package/dist/screens/settings/voice-settings-output.js +2 -40
- package/dist/screens/settings/voice-settings-providers.d.ts +2 -2
- package/dist/screens/settings/voice-settings-providers.js +2 -19
- package/dist/screens/settings/voice-settings-types.d.ts +4 -4
- package/dist/screens/settings/voice-settings-types.js +31 -31
- package/dist/screens/settings/voice-settings-wake-word.d.ts +2 -2
- package/dist/screens/settings/voice-settings-wake-word.js +2 -33
- package/dist/screens/settings/voice-settings.d.ts +1 -1
- package/dist/screens/settings/voice-settings.js +35 -112
- package/dist/screens/setup-user.d.ts +1 -2
- package/dist/screens/setup-user.js +38 -116
- package/dist/screens/tools/tool-code.d.ts +2 -3
- package/dist/screens/tools/tool-code.js +9 -13
- package/dist/screens/tools/tool-details.d.ts +1 -2
- package/dist/screens/tools/tool-details.js +26 -39
- package/dist/screens/tools/tool-info.d.ts +2 -3
- package/dist/screens/tools/tool-info.js +9 -48
- package/dist/screens/tools/tool-list.d.ts +1 -2
- package/dist/screens/tools/tool-list.js +33 -65
- package/dist/screens/tools/tool-schema.d.ts +2 -3
- package/dist/screens/tools/tool-schema.js +2 -13
- package/dist/screens/tools/tool-test-details.d.ts +1 -2
- package/dist/screens/tools/tool-test-details.js +12 -28
- package/dist/screens/tools/tool-test-list.d.ts +1 -2
- package/dist/screens/tools/tool-test-list.js +17 -56
- package/dist/screens/variables/variable-details.d.ts +1 -2
- package/dist/screens/variables/variable-details.js +19 -86
- package/dist/screens/variables/variable-list.d.ts +1 -2
- package/dist/screens/variables/variable-list.js +16 -27
- package/dist/screens/welcome-modal.d.ts +1 -2
- package/dist/screens/welcome-modal.js +44 -111
- package/dist/screens/workflows/workflow-details.d.ts +1 -2
- package/dist/screens/workflows/workflow-details.js +17 -31
- package/dist/screens/workflows/workflow-info.d.ts +2 -3
- package/dist/screens/workflows/workflow-info.js +2 -9
- package/dist/screens/workflows/workflow-instructions.d.ts +2 -3
- package/dist/screens/workflows/workflow-instructions.js +23 -55
- package/dist/screens/workflows/workflow-list.d.ts +1 -2
- package/dist/screens/workflows/workflow-list.js +23 -62
- package/dist/setupTests.d.ts +1 -1
- package/dist/setupTests.js +10 -11
- package/dist/system-apps/assistants.app.d.ts +1 -1
- package/dist/system-apps/assistants.app.js +3 -3
- package/dist/system-apps/console-logs.app.d.ts +1 -1
- package/dist/system-apps/console-logs.app.js +3 -3
- package/dist/system-apps/contacts.app.d.ts +1 -1
- package/dist/system-apps/contacts.app.js +4 -4
- package/dist/system-apps/data-explorer.app.d.ts +1 -1
- package/dist/system-apps/data-explorer.app.js +4 -4
- package/dist/system-apps/groups.app.d.ts +1 -1
- package/dist/system-apps/groups.app.js +4 -4
- package/dist/system-apps/index.d.ts +17 -17
- package/dist/system-apps/index.js +52 -52
- package/dist/system-apps/join-group.app.d.ts +1 -1
- package/dist/system-apps/join-group.app.js +4 -4
- package/dist/system-apps/mobile-settings.app.d.ts +1 -1
- package/dist/system-apps/mobile-settings.app.js +3 -3
- package/dist/system-apps/network-viewer.app.d.ts +1 -1
- package/dist/system-apps/network-viewer.app.js +4 -4
- package/dist/system-apps/packages.app.d.ts +1 -1
- package/dist/system-apps/packages.app.js +3 -3
- package/dist/system-apps/search.app.d.ts +1 -1
- package/dist/system-apps/search.app.js +4 -4
- package/dist/system-apps/settings.app.d.ts +1 -1
- package/dist/system-apps/settings.app.js +3 -3
- package/dist/system-apps/threads.app.d.ts +1 -1
- package/dist/system-apps/threads.app.js +3 -3
- package/dist/system-apps/tools.app.d.ts +1 -1
- package/dist/system-apps/tools.app.js +3 -3
- package/dist/system-apps/types.app.d.ts +1 -1
- package/dist/system-apps/types.app.js +3 -3
- package/dist/system-apps/variables.app.d.ts +1 -1
- package/dist/system-apps/variables.app.js +3 -3
- package/dist/system-apps/workflows.app.d.ts +1 -1
- package/dist/system-apps/workflows.app.js +3 -3
- package/dist/tabs-layout/tabs-layout.d.ts +2 -3
- package/dist/tabs-layout/tabs-layout.js +215 -246
- package/dist/tabs-layout/tabs-state.d.ts +2 -2
- package/dist/tabs-layout/tabs-state.js +73 -61
- package/dist/ui-defaults/index.d.ts +2 -2
- package/dist/ui-defaults/list-screen.d.ts +2 -3
- package/dist/ui-defaults/list-screen.js +33 -37
- package/dist/ui-defaults/markdown-field.js +24 -56
- package/dist/ui-router/routes-loader.d.ts +1 -1
- package/dist/ui-router/routes-loader.js +17 -13
- package/dist/ui-router/ui-loader.d.ts +6 -6
- package/dist/ui-router/ui-loader.js +172 -268
- package/dist/utils.js +49 -39
- package/jest.config.js +16 -16
- package/package.json +16 -14
- package/src/command-palette/command-palette-ui.tsx +261 -237
- package/src/command-palette/command-palette.ts +81 -78
- package/src/components/chat-overlay.tsx +366 -261
- package/src/components/checkbox.tsx +15 -12
- package/src/components/group-switcher.tsx +150 -105
- package/src/components/input-date.tsx +17 -16
- package/src/components/input-number.tsx +47 -31
- package/src/components/input.tsx +15 -12
- package/src/components/inverse-lazy-list.tsx +14 -13
- package/src/components/io-schema-values.tsx +51 -69
- package/src/components/io-schema.tsx +94 -69
- package/src/components/lazy-list.tsx +51 -34
- package/src/components/list-screen.tsx +51 -35
- package/src/components/loading-indicator.tsx +2 -4
- package/src/components/markdown-editor/autolink-plugin.tsx +4 -11
- package/src/components/markdown-editor/editor-inline.tsx +3 -4
- package/src/components/markdown-editor/editor.tsx +53 -51
- package/src/components/markdown-editor/markdown-plugin.tsx +48 -40
- package/src/components/markdown-editor/mention-node.ts +39 -38
- package/src/components/markdown-editor/mentions-plugin.tsx +99 -101
- package/src/components/markdown-editor/theme.ts +28 -29
- package/src/components/markdown-editor/toolbar.tsx +53 -47
- package/src/components/markdown-with-mentions.tsx +56 -46
- package/src/components/message-logs/message-logs.tsx +225 -165
- package/src/components/messages/avatar.tsx +70 -52
- package/src/components/messages/channel-message-list.tsx +80 -68
- package/src/components/messages/channel-view.tsx +34 -33
- package/src/components/messages/message-compose.tsx +84 -67
- package/src/components/messages/message-display.tsx +103 -89
- package/src/components/messages/thread-message-list.tsx +53 -44
- package/src/components/router.tsx +42 -43
- package/src/components/save-button.tsx +43 -39
- package/src/components/sortable-list.tsx +77 -49
- package/src/components/tabs.tsx +31 -31
- package/src/components/tooltip.tsx +21 -28
- package/src/components/trust-level-badge.tsx +15 -11
- package/src/components/trust-level-dropdown.tsx +49 -19
- package/src/components/typeahead.tsx +57 -59
- package/src/components/voice-indicator.tsx +158 -141
- package/src/components/voice-subscribe-events.ts +20 -0
- package/src/globals.tsx +42 -40
- package/src/hooks.test.tsx +141 -134
- package/src/hooks.ts +80 -48
- package/src/index.tsx +17 -10
- package/src/mention-configs.ts +122 -68
- package/src/screens/assistants/assistant-config.tsx +28 -18
- package/src/screens/assistants/assistant-details.tsx +35 -36
- package/src/screens/assistants/assistant-info.tsx +16 -11
- package/src/screens/assistants/assistant-list.tsx +37 -34
- package/src/screens/assistants/assistant-tools.tsx +41 -20
- package/src/screens/console-logs/console-logs-list.tsx +173 -140
- package/src/screens/console-logs/log-display.tsx +65 -38
- package/src/screens/console-logs/log-filters.tsx +4 -3
- package/src/screens/console-logs/mobile-log-card.tsx +78 -71
- package/src/screens/console-logs/resizable-table-header.tsx +29 -21
- package/src/screens/contacts/contact-details.tsx +29 -30
- package/src/screens/contacts/contact-list.tsx +71 -60
- package/src/screens/contacts/index.ts +5 -5
- package/src/screens/contacts/user-connect.tsx +177 -171
- package/src/screens/data-explorer/data-explorer.tsx +134 -98
- package/src/screens/data-explorer/index.ts +2 -3
- package/src/screens/data-explorer/query-executor.tsx +90 -80
- package/src/screens/groups/group-details.tsx +120 -101
- package/src/screens/groups/group-invite-listener.tsx +34 -37
- package/src/screens/groups/group-list.tsx +119 -103
- package/src/screens/groups/group-members.tsx +225 -164
- package/src/screens/groups/index.ts +5 -6
- package/src/screens/join-group/index.ts +2 -2
- package/src/screens/join-group/join-group.tsx +41 -39
- package/src/screens/network-viewer/connection-troubleshooter.tsx +145 -104
- package/src/screens/network-viewer/cpu-usage-graph.tsx +39 -43
- package/src/screens/network-viewer/device-details-modal.tsx +46 -59
- package/src/screens/network-viewer/group-details-modal.tsx +68 -49
- package/src/screens/network-viewer/index.ts +4 -5
- package/src/screens/network-viewer/network-viewer-ipc.ts +23 -0
- package/src/screens/network-viewer/network-viewer.tsx +261 -236
- package/src/screens/network-viewer/usage-graph.tsx +57 -49
- package/src/screens/packages/package-details.tsx +43 -35
- package/src/screens/packages/package-info.tsx +107 -66
- package/src/screens/packages/package-list.tsx +175 -98
- package/src/screens/packages/package-new-local.tsx +28 -26
- package/src/screens/packages/package-versions.tsx +102 -77
- package/src/screens/peer-types/peer-type-details.tsx +60 -50
- package/src/screens/peer-types/peer-type-list.tsx +20 -30
- package/src/screens/search/global-search.tsx +153 -137
- package/src/screens/settings/color-mode-dropdown.tsx +52 -35
- package/src/screens/settings/settings-page.tsx +215 -141
- package/src/screens/settings/voice-settings-agent.tsx +13 -12
- package/src/screens/settings/voice-settings-api-keys.tsx +14 -12
- package/src/screens/settings/voice-settings-output.tsx +12 -11
- package/src/screens/settings/voice-settings-providers.tsx +7 -3
- package/src/screens/settings/voice-settings-types.ts +52 -49
- package/src/screens/settings/voice-settings-wake-word.tsx +25 -9
- package/src/screens/settings/voice-settings.tsx +66 -43
- package/src/screens/setup-user.tsx +88 -41
- package/src/screens/tools/tool-code.tsx +12 -17
- package/src/screens/tools/tool-details.tsx +28 -28
- package/src/screens/tools/tool-info.tsx +14 -19
- package/src/screens/tools/tool-list.tsx +58 -40
- package/src/screens/tools/tool-schema.tsx +16 -9
- package/src/screens/tools/tool-test-details.tsx +11 -22
- package/src/screens/tools/tool-test-list.tsx +29 -30
- package/src/screens/variables/variable-details.tsx +63 -51
- package/src/screens/variables/variable-list.tsx +29 -30
- package/src/screens/welcome-modal.tsx +68 -48
- package/src/screens/workflows/workflow-details.tsx +40 -30
- package/src/screens/workflows/workflow-info.tsx +4 -11
- package/src/screens/workflows/workflow-instructions.tsx +35 -28
- package/src/screens/workflows/workflow-list.tsx +50 -40
- package/src/setupTests.ts +14 -13
- package/src/system-apps/assistants.app.ts +5 -5
- package/src/system-apps/console-logs.app.ts +4 -4
- package/src/system-apps/contacts.app.ts +6 -6
- package/src/system-apps/data-explorer.app.ts +5 -5
- package/src/system-apps/groups.app.ts +6 -6
- package/src/system-apps/index.ts +49 -49
- package/src/system-apps/join-group.app.ts +5 -5
- package/src/system-apps/mobile-settings.app.ts +4 -5
- package/src/system-apps/network-viewer.app.ts +5 -5
- package/src/system-apps/packages.app.ts +5 -5
- package/src/system-apps/search.app.ts +6 -6
- package/src/system-apps/settings.app.ts +5 -5
- package/src/system-apps/threads.app.ts +5 -5
- package/src/system-apps/tools.app.ts +5 -5
- package/src/system-apps/types.app.ts +5 -5
- package/src/system-apps/variables.app.ts +5 -5
- package/src/system-apps/workflows.app.ts +5 -5
- package/src/tabs-layout/tabs-layout.tsx +345 -254
- package/src/tabs-layout/tabs-state.ts +100 -81
- package/src/ui-defaults/index.ts +2 -3
- package/src/ui-defaults/list-screen.tsx +45 -40
- package/src/ui-defaults/markdown-field.tsx +22 -26
- package/src/ui-router/routes-loader.ts +40 -24
- package/src/ui-router/ui-loader.tsx +312 -214
- package/src/utils.ts +68 -81
- package/tsconfig.json +5 -10
- package/dist/components/input-datetime.d.ts +0 -7
- package/dist/components/input-datetime.js +0 -35
- package/dist/components/lazy-sortable-list.d.ts +0 -29
- package/dist/components/lazy-sortable-list.js +0 -12
- package/dist/components/left-bar.d.ts +0 -5
- package/dist/components/left-bar.js +0 -207
- package/dist/components/main-content-container.d.ts +0 -2
- package/dist/components/main-content-container.js +0 -92
- package/dist/components/messages/thread-view.d.ts +0 -6
- package/dist/components/messages/thread-view.js +0 -174
- package/dist/components/off-canvas.d.ts +0 -13
- package/dist/components/off-canvas.js +0 -89
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +0 -6
- package/dist/components/text-list-editor.tsx/text-list-editor.js +0 -13
- package/dist/components/top-bar.d.ts +0 -2
- package/dist/components/top-bar.js +0 -51
- package/dist/components/typeahead/mentions-plugin.d.ts +0 -7
- package/dist/components/typeahead/mentions-plugin.js +0 -203
- package/dist/components/typeahead/typeahead-editor.d.ts +0 -15
- package/dist/components/typeahead/typeahead-editor.js +0 -134
- package/dist/components/typeahead/typeahead.d.ts +0 -12
- package/dist/components/typeahead/typeahead.js +0 -94
- package/dist/screens/profile.d.ts +0 -2
- package/dist/screens/profile.js +0 -76
- package/src/components/input-datetime.tsx +0 -41
- package/src/components/lazy-sortable-list.tsx +0 -51
- package/src/components/left-bar.tsx +0 -322
- package/src/components/main-content-container.tsx +0 -79
- package/src/components/messages/thread-view.tsx +0 -214
- package/src/components/off-canvas.tsx +0 -83
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +0 -13
- package/src/components/top-bar.tsx +0 -119
- package/src/components/typeahead/mentions-plugin.tsx +0 -265
- package/src/components/typeahead/typeahead-editor.tsx +0 -140
- package/src/components/typeahead/typeahead.tsx +0 -77
- package/src/screens/profile.tsx +0 -75
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
debounceByArgs,
|
|
3
|
+
getUserContext,
|
|
4
|
+
type IPackage,
|
|
5
|
+
type IPeersPackageUIs,
|
|
6
|
+
type IPeersUI,
|
|
7
|
+
type IPeersUIRoute,
|
|
8
|
+
newid,
|
|
9
|
+
Packages,
|
|
10
|
+
PackageVersions,
|
|
11
|
+
rpcServerCalls,
|
|
12
|
+
toJSON,
|
|
13
|
+
type UIContext,
|
|
14
|
+
zodAnyObject,
|
|
15
|
+
} from "@peers-app/peers-sdk";
|
|
2
16
|
import { orderBy } from "lodash";
|
|
3
17
|
import React, { Component, useEffect } from "react";
|
|
4
18
|
import { LoadingIndicator } from "../components/loading-indicator";
|
|
@@ -33,7 +47,7 @@ class UIErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState>
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
36
|
-
console.error(
|
|
50
|
+
console.error("UIErrorBoundary caught an error:", error, errorInfo);
|
|
37
51
|
this.setState({
|
|
38
52
|
error,
|
|
39
53
|
errorInfo,
|
|
@@ -44,41 +58,59 @@ class UIErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState>
|
|
|
44
58
|
if (this.state.hasError) {
|
|
45
59
|
const { peersUIId, packageName, componentName } = this.props;
|
|
46
60
|
const { error, errorInfo } = this.state;
|
|
47
|
-
|
|
61
|
+
|
|
48
62
|
return (
|
|
49
|
-
<div
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
+
<div
|
|
64
|
+
style={{
|
|
65
|
+
padding: "20px",
|
|
66
|
+
border: "2px solid #ff6b6b",
|
|
67
|
+
borderRadius: "8px",
|
|
68
|
+
backgroundColor: "#fff5f5",
|
|
69
|
+
color: "#721c24",
|
|
70
|
+
fontFamily: "monospace",
|
|
71
|
+
margin: "10px 0",
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<h3 style={{ color: "#c53030", marginTop: 0 }}>UI Component Error</h3>
|
|
75
|
+
<div style={{ marginBottom: "15px" }}>
|
|
76
|
+
{peersUIId && (
|
|
77
|
+
<div>
|
|
78
|
+
<strong>Peers UI ID:</strong> {peersUIId}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
{packageName && (
|
|
82
|
+
<div>
|
|
83
|
+
<strong>Package:</strong> {packageName}
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
86
|
+
{componentName && (
|
|
87
|
+
<div>
|
|
88
|
+
<strong>Component:</strong> {componentName}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
63
91
|
</div>
|
|
64
|
-
|
|
65
|
-
<details style={{ marginBottom:
|
|
66
|
-
<summary style={{ cursor:
|
|
92
|
+
|
|
93
|
+
<details style={{ marginBottom: "15px" }}>
|
|
94
|
+
<summary style={{ cursor: "pointer", fontWeight: "bold", marginBottom: "10px" }}>
|
|
67
95
|
Error Details
|
|
68
96
|
</summary>
|
|
69
|
-
<div
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
97
|
+
<div
|
|
98
|
+
style={{
|
|
99
|
+
backgroundColor: "#fed7d7",
|
|
100
|
+
padding: "10px",
|
|
101
|
+
borderRadius: "4px",
|
|
102
|
+
whiteSpace: "pre-wrap",
|
|
103
|
+
overflow: "auto",
|
|
104
|
+
maxHeight: "200px",
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<strong>Error:</strong> {error?.message || "Unknown error"}
|
|
78
108
|
{error?.stack && (
|
|
79
109
|
<>
|
|
80
|
-
<br
|
|
81
|
-
<
|
|
110
|
+
<br />
|
|
111
|
+
<br />
|
|
112
|
+
<strong>Stack Trace:</strong>
|
|
113
|
+
<br />
|
|
82
114
|
{error.stack}
|
|
83
115
|
</>
|
|
84
116
|
)}
|
|
@@ -87,32 +119,35 @@ class UIErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState>
|
|
|
87
119
|
|
|
88
120
|
{errorInfo && (
|
|
89
121
|
<details>
|
|
90
|
-
<summary style={{ cursor:
|
|
122
|
+
<summary style={{ cursor: "pointer", fontWeight: "bold", marginBottom: "10px" }}>
|
|
91
123
|
Component Stack
|
|
92
124
|
</summary>
|
|
93
|
-
<div
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
125
|
+
<div
|
|
126
|
+
style={{
|
|
127
|
+
backgroundColor: "#fed7d7",
|
|
128
|
+
padding: "10px",
|
|
129
|
+
borderRadius: "4px",
|
|
130
|
+
whiteSpace: "pre-wrap",
|
|
131
|
+
overflow: "auto",
|
|
132
|
+
maxHeight: "200px",
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
101
135
|
{errorInfo.componentStack}
|
|
102
136
|
</div>
|
|
103
137
|
</details>
|
|
104
138
|
)}
|
|
105
139
|
|
|
106
|
-
<button
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
107
142
|
onClick={() => this.setState({ hasError: false, error: null, errorInfo: null })}
|
|
108
143
|
style={{
|
|
109
|
-
marginTop:
|
|
110
|
-
padding:
|
|
111
|
-
backgroundColor:
|
|
112
|
-
color:
|
|
113
|
-
border:
|
|
114
|
-
borderRadius:
|
|
115
|
-
cursor:
|
|
144
|
+
marginTop: "15px",
|
|
145
|
+
padding: "8px 16px",
|
|
146
|
+
backgroundColor: "#c53030",
|
|
147
|
+
color: "white",
|
|
148
|
+
border: "none",
|
|
149
|
+
borderRadius: "4px",
|
|
150
|
+
cursor: "pointer",
|
|
116
151
|
}}
|
|
117
152
|
>
|
|
118
153
|
Try Again
|
|
@@ -126,30 +161,48 @@ class UIErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState>
|
|
|
126
161
|
}
|
|
127
162
|
|
|
128
163
|
interface IProps extends UIContext {
|
|
129
|
-
props: Record<string,
|
|
164
|
+
props: Record<string, unknown>;
|
|
130
165
|
}
|
|
131
166
|
|
|
132
167
|
export const UIRouter = (props: IProps) => {
|
|
133
168
|
let matchingRoute: IPeersUIRoute | undefined;
|
|
134
169
|
const allRoutes = _window.getPeersUIRoutes() as IPeersUIRoute[];
|
|
135
|
-
const filteredRoutes = allRoutes.filter(r => {
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
170
|
+
const filteredRoutes = allRoutes.filter((r) => {
|
|
171
|
+
if (
|
|
172
|
+
props.uiEditMode &&
|
|
173
|
+
props.uiEditMode !== "*" &&
|
|
174
|
+
r.uiEditMode !== "*" &&
|
|
175
|
+
r.uiEditMode !== props.uiEditMode
|
|
176
|
+
)
|
|
177
|
+
return false;
|
|
178
|
+
if (
|
|
179
|
+
props.uiCategory &&
|
|
180
|
+
props.uiCategory !== "*" &&
|
|
181
|
+
r.uiCategory !== "*" &&
|
|
182
|
+
r.uiCategory !== props.uiCategory
|
|
183
|
+
)
|
|
184
|
+
return false;
|
|
185
|
+
if (
|
|
186
|
+
props.uiSubcategory &&
|
|
187
|
+
props.uiSubcategory !== "*" &&
|
|
188
|
+
r.uiSubcategory !== "*" &&
|
|
189
|
+
r.uiSubcategory !== props.uiSubcategory
|
|
190
|
+
)
|
|
191
|
+
return false;
|
|
139
192
|
return true;
|
|
140
193
|
});
|
|
141
194
|
|
|
142
195
|
const context: UIContext & { path: string } = {
|
|
143
196
|
...props,
|
|
144
197
|
path: props.path || mainContentPath(),
|
|
145
|
-
}
|
|
198
|
+
};
|
|
146
199
|
for (const route of filteredRoutes) {
|
|
147
200
|
// if (route.path && !context.path.startsWith(route.path)) continue;
|
|
148
201
|
|
|
149
202
|
// <todo> test this
|
|
150
203
|
if (route.path) {
|
|
151
204
|
// since `isMatch` can already be used to match the path, this might be overkill
|
|
152
|
-
// but if you just need a simple regex match this makes it nice instead of having to declare a whole function
|
|
205
|
+
// but if you just need a simple regex match this makes it nice instead of having to declare a whole function
|
|
153
206
|
const match = route.path.match(/^\/(.+)\/([gimsuy]{0,6})$/);
|
|
154
207
|
if (match) {
|
|
155
208
|
const [, pattern, flags] = match;
|
|
@@ -181,9 +234,9 @@ export const UIRouter = (props: IProps) => {
|
|
|
181
234
|
}
|
|
182
235
|
|
|
183
236
|
return UILoader({ peersUIId: matchingRoute.peersUIId, props: props.props });
|
|
184
|
-
}
|
|
237
|
+
};
|
|
185
238
|
|
|
186
|
-
const UILoader = (args: { peersUIId: string
|
|
239
|
+
const UILoader = (args: { peersUIId: string; props: Record<string, unknown> }) => {
|
|
187
240
|
const { props, peersUIId } = args;
|
|
188
241
|
const [lastReloadTime] = useObservable(packageReloaded);
|
|
189
242
|
args.props.__lastPackageReload = lastReloadTime;
|
|
@@ -192,7 +245,11 @@ const UILoader = (args: { peersUIId: string, props: Record<string, any> }) => {
|
|
|
192
245
|
if (peersUI?.content) {
|
|
193
246
|
const parseResult = peersUI.propsSchema.safeParse(props);
|
|
194
247
|
if (!parseResult.success) {
|
|
195
|
-
console.error(
|
|
248
|
+
console.error("props did not match schema", {
|
|
249
|
+
props,
|
|
250
|
+
schema: peersUI.propsSchema,
|
|
251
|
+
errors: parseResult.error,
|
|
252
|
+
});
|
|
196
253
|
return (
|
|
197
254
|
<div>
|
|
198
255
|
<pre>
|
|
@@ -200,121 +257,131 @@ const UILoader = (args: { peersUIId: string, props: Record<string, any> }) => {
|
|
|
200
257
|
peersUIId: {peersUI.peersUIId} <br />
|
|
201
258
|
Component name: {peersUI.content?.name} <br />
|
|
202
259
|
Props did not match schema <br />
|
|
203
|
-
Errors: {JSON.stringify(parseResult.error, null, 2)} <br
|
|
204
|
-
|
|
260
|
+
Errors: {JSON.stringify(parseResult.error, null, 2)} <br />
|
|
261
|
+
<br />
|
|
262
|
+
Props {JSON.stringify(toJSON(props), null, 2)}
|
|
263
|
+
<br />
|
|
205
264
|
</pre>
|
|
206
265
|
</div>
|
|
207
266
|
);
|
|
208
267
|
}
|
|
209
|
-
const Component = peersUI.content as React.ComponentType<
|
|
268
|
+
const Component = peersUI.content as React.ComponentType<Record<string, unknown>>;
|
|
210
269
|
return (
|
|
211
|
-
<UIErrorBoundary
|
|
212
|
-
peersUIId={peersUIId}
|
|
213
|
-
componentName={peersUI.content?.name}
|
|
214
|
-
>
|
|
270
|
+
<UIErrorBoundary peersUIId={peersUIId} componentName={peersUI.content?.name}>
|
|
215
271
|
<Component {...args.props} />
|
|
216
272
|
</UIErrorBoundary>
|
|
217
273
|
);
|
|
218
274
|
}
|
|
219
275
|
|
|
220
276
|
return <UIAsyncLoader {...args} />;
|
|
221
|
-
}
|
|
277
|
+
};
|
|
222
278
|
|
|
223
|
-
const uiLoadingPromises: Record<string, Promise<
|
|
279
|
+
const uiLoadingPromises: Record<string, Promise<void>> = {};
|
|
224
280
|
|
|
225
281
|
// Check if we're running in a React Native WebView (has injectUIBundle available)
|
|
226
|
-
const isReactNativeWebView =
|
|
282
|
+
const isReactNativeWebView =
|
|
283
|
+
typeof (window as Window & { ReactNativeWebView?: unknown }).ReactNativeWebView !== "undefined";
|
|
227
284
|
|
|
228
285
|
async function resolveUiBundleFileId(pkg: IPackage): Promise<string | undefined> {
|
|
229
286
|
if (!pkg.activePackageVersionId) return undefined;
|
|
230
287
|
try {
|
|
231
288
|
const pv = await PackageVersions().get(pkg.activePackageVersionId);
|
|
232
289
|
return pv?.uiBundleFileId;
|
|
233
|
-
} catch {
|
|
290
|
+
} catch {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
234
293
|
}
|
|
235
294
|
|
|
295
|
+
type PeersUiBundleWindow = Window & {
|
|
296
|
+
__peersUIs?: Record<string, IPeersUI>;
|
|
297
|
+
__peersUIBundleLoaded?: (loadedFileId: string) => void;
|
|
298
|
+
__peersUIBundleError?: (errorFileId: string, errorMsg: string) => void;
|
|
299
|
+
};
|
|
300
|
+
|
|
236
301
|
function loadUIBundle(pkg: IPackage, forceRefresh?: boolean) {
|
|
237
|
-
let importPromise: Promise<
|
|
302
|
+
let importPromise: Promise<void> = uiLoadingPromises[pkg.packageId];
|
|
238
303
|
if (!importPromise || forceRefresh) {
|
|
239
304
|
const sTime = Date.now();
|
|
240
305
|
console.log(`loading ui bundle for ${pkg.name}`);
|
|
241
|
-
importPromise =
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
306
|
+
importPromise = (async () => {
|
|
307
|
+
const uiBundleFileId = await resolveUiBundleFileId(pkg);
|
|
308
|
+
if (!uiBundleFileId) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (isReactNativeWebView && rpcServerCalls.injectUIBundle) {
|
|
313
|
+
const _w = window as PeersUiBundleWindow;
|
|
314
|
+
_w.__peersUIs = _w.__peersUIs || {};
|
|
248
315
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (loadedFileId === uiBundleFileId) {
|
|
256
|
-
Object.keys(_window.__peersUIs || {}).forEach(peersUIId => {
|
|
257
|
-
peersUIs[peersUIId] = _window.__peersUIs[peersUIId];
|
|
258
|
-
});
|
|
259
|
-
resolveLoad();
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
_window.__peersUIBundleError = (errorFileId: string, errorMsg: string) => {
|
|
264
|
-
if (errorFileId === uiBundleFileId) {
|
|
265
|
-
rejectLoad(new Error(errorMsg));
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
await rpcServerCalls.injectUIBundle(uiBundleFileId);
|
|
271
|
-
await loadPromise;
|
|
272
|
-
console.log(`finished loading ui bundle for ${pkg.name}: ${(Date.now() - sTime).toFixed(0)}ms`);
|
|
273
|
-
} else {
|
|
274
|
-
let bundleCode = await rpcServerCalls.getFileContents(uiBundleFileId);
|
|
275
|
-
if (bundleCode) {
|
|
276
|
-
const exportUIs = (peerUIs: IPeersPackageUIs) => {
|
|
277
|
-
peerUIs?.uis?.forEach(ui => {
|
|
278
|
-
peersUIs[ui.peersUIId] = ui;
|
|
316
|
+
const loadPromise = new Promise<void>((resolveLoad, rejectLoad) => {
|
|
317
|
+
_w.__peersUIBundleLoaded = (loadedFileId: string) => {
|
|
318
|
+
if (loadedFileId === uiBundleFileId) {
|
|
319
|
+
const store = _w.__peersUIs || {};
|
|
320
|
+
Object.keys(store).forEach((peersUIId) => {
|
|
321
|
+
peersUIs[peersUIId] = store[peersUIId];
|
|
279
322
|
});
|
|
323
|
+
resolveLoad();
|
|
280
324
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
_w.__peersUIBundleError = (errorFileId: string, errorMsg: string) => {
|
|
328
|
+
if (errorFileId === uiBundleFileId) {
|
|
329
|
+
rejectLoad(new Error(errorMsg));
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
await rpcServerCalls.injectUIBundle(uiBundleFileId);
|
|
335
|
+
await loadPromise;
|
|
336
|
+
console.log(
|
|
337
|
+
`finished loading ui bundle for ${pkg.name}: ${(Date.now() - sTime).toFixed(0)}ms`,
|
|
338
|
+
);
|
|
339
|
+
} else {
|
|
340
|
+
const bundleCode = await rpcServerCalls.getFileContents(uiBundleFileId);
|
|
341
|
+
if (bundleCode) {
|
|
342
|
+
const exportUIs = (peerUIs: IPeersPackageUIs) => {
|
|
343
|
+
peerUIs?.uis?.forEach((ui) => {
|
|
344
|
+
peersUIs[ui.peersUIId] = ui;
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
const bundleFunction = new Function("exportUIs", bundleCode);
|
|
348
|
+
await bundleFunction(exportUIs);
|
|
285
349
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
reject(err);
|
|
350
|
+
console.log(
|
|
351
|
+
`finished loading ui bundle for ${pkg.name}: ${(Date.now() - sTime).toFixed(0)}ms, ${bundleCode ? (bundleCode.length / 1000).toFixed(0) : "0"} KB`,
|
|
352
|
+
);
|
|
290
353
|
}
|
|
354
|
+
})().catch((err: unknown) => {
|
|
355
|
+
console.error(`Error while loading ui module for ${pkg.name}`, err);
|
|
356
|
+
throw err;
|
|
291
357
|
});
|
|
292
358
|
uiLoadingPromises[pkg.packageId] = importPromise;
|
|
293
359
|
}
|
|
294
360
|
return importPromise;
|
|
295
361
|
}
|
|
296
362
|
|
|
297
|
-
const UIAsyncLoader = (props: { peersUIId: string
|
|
363
|
+
const UIAsyncLoader = (props: { peersUIId: string; props: Record<string, unknown> }) => {
|
|
298
364
|
const { peersUIId } = props;
|
|
299
365
|
const [loaded, setLoaded] = React.useState(false);
|
|
300
366
|
const [loadError, setLoadError] = React.useState<Error | null>(null);
|
|
301
367
|
|
|
302
368
|
const allRoutes = _window.getPeersUIRoutes() as IPeersUIRoute[];
|
|
303
|
-
const uiPackageId = allRoutes.find(r => r.peersUIId === peersUIId)?.packageId;
|
|
369
|
+
const uiPackageId = allRoutes.find((r) => r.peersUIId === peersUIId)?.packageId;
|
|
304
370
|
|
|
305
371
|
useObservable(allPackages);
|
|
306
|
-
const pkg = allPackages().find(p => p.packageId === uiPackageId);
|
|
372
|
+
const pkg = allPackages().find((p) => p.packageId === uiPackageId);
|
|
307
373
|
|
|
308
374
|
useEffect(() => {
|
|
309
375
|
if (!pkg) return;
|
|
376
|
+
const pkgRef = pkg;
|
|
310
377
|
setLoadError(null);
|
|
311
|
-
loadUIBundle(
|
|
378
|
+
loadUIBundle(pkgRef)
|
|
312
379
|
.then(() => setLoaded(true))
|
|
313
380
|
.catch((error) => {
|
|
314
|
-
console.error(`Failed to load UI bundle for package ${
|
|
381
|
+
console.error(`Failed to load UI bundle for package ${pkgRef.name}:`, error);
|
|
315
382
|
setLoadError(error);
|
|
316
383
|
});
|
|
317
|
-
}, [pkg?.packageId]);
|
|
384
|
+
}, [pkg?.packageId, pkg?.name, pkg]);
|
|
318
385
|
|
|
319
386
|
if (!pkg) {
|
|
320
387
|
return <div>Could not find package that owns peersUIId {peersUIId}</div>;
|
|
@@ -322,46 +389,59 @@ const UIAsyncLoader = (props: { peersUIId: string, props: Record<string, any> })
|
|
|
322
389
|
|
|
323
390
|
if (loadError) {
|
|
324
391
|
return (
|
|
325
|
-
<div
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
<div
|
|
392
|
+
<div
|
|
393
|
+
style={{
|
|
394
|
+
padding: "20px",
|
|
395
|
+
border: "2px solid #ff6b6b",
|
|
396
|
+
borderRadius: "8px",
|
|
397
|
+
backgroundColor: "#fff5f5",
|
|
398
|
+
color: "#721c24",
|
|
399
|
+
fontFamily: "monospace",
|
|
400
|
+
margin: "10px 0",
|
|
401
|
+
}}
|
|
402
|
+
>
|
|
403
|
+
<h3 style={{ color: "#c53030", marginTop: 0 }}>Bundle Loading Error</h3>
|
|
404
|
+
<div style={{ marginBottom: "15px" }}>
|
|
405
|
+
<div>
|
|
406
|
+
<strong>Peers UI ID:</strong> {peersUIId}
|
|
407
|
+
</div>
|
|
408
|
+
<div>
|
|
409
|
+
<strong>Package:</strong> {pkg.name}
|
|
410
|
+
</div>
|
|
411
|
+
<div>
|
|
412
|
+
<strong>Package ID:</strong> {pkg.packageId}
|
|
413
|
+
</div>
|
|
339
414
|
</div>
|
|
340
|
-
|
|
341
|
-
<details style={{ marginBottom:
|
|
342
|
-
<summary style={{ cursor:
|
|
415
|
+
|
|
416
|
+
<details style={{ marginBottom: "15px" }}>
|
|
417
|
+
<summary style={{ cursor: "pointer", fontWeight: "bold", marginBottom: "10px" }}>
|
|
343
418
|
Error Details
|
|
344
419
|
</summary>
|
|
345
|
-
<div
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
420
|
+
<div
|
|
421
|
+
style={{
|
|
422
|
+
backgroundColor: "#fed7d7",
|
|
423
|
+
padding: "10px",
|
|
424
|
+
borderRadius: "4px",
|
|
425
|
+
whiteSpace: "pre-wrap",
|
|
426
|
+
overflow: "auto",
|
|
427
|
+
maxHeight: "200px",
|
|
428
|
+
}}
|
|
429
|
+
>
|
|
430
|
+
<strong>Error:</strong> {loadError.message || "Unknown error"}
|
|
354
431
|
{loadError.stack && (
|
|
355
432
|
<>
|
|
356
|
-
<br
|
|
357
|
-
<
|
|
433
|
+
<br />
|
|
434
|
+
<br />
|
|
435
|
+
<strong>Stack Trace:</strong>
|
|
436
|
+
<br />
|
|
358
437
|
{loadError.stack}
|
|
359
438
|
</>
|
|
360
439
|
)}
|
|
361
440
|
</div>
|
|
362
441
|
</details>
|
|
363
442
|
|
|
364
|
-
<button
|
|
443
|
+
<button
|
|
444
|
+
type="button"
|
|
365
445
|
onClick={() => {
|
|
366
446
|
setLoadError(null);
|
|
367
447
|
setLoaded(false);
|
|
@@ -372,13 +452,13 @@ const UIAsyncLoader = (props: { peersUIId: string, props: Record<string, any> })
|
|
|
372
452
|
}
|
|
373
453
|
}}
|
|
374
454
|
style={{
|
|
375
|
-
marginTop:
|
|
376
|
-
padding:
|
|
377
|
-
backgroundColor:
|
|
378
|
-
color:
|
|
379
|
-
border:
|
|
380
|
-
borderRadius:
|
|
381
|
-
cursor:
|
|
455
|
+
marginTop: "15px",
|
|
456
|
+
padding: "8px 16px",
|
|
457
|
+
backgroundColor: "#c53030",
|
|
458
|
+
color: "white",
|
|
459
|
+
border: "none",
|
|
460
|
+
borderRadius: "4px",
|
|
461
|
+
cursor: "pointer",
|
|
382
462
|
}}
|
|
383
463
|
>
|
|
384
464
|
Retry Loading
|
|
@@ -388,7 +468,7 @@ const UIAsyncLoader = (props: { peersUIId: string, props: Record<string, any> })
|
|
|
388
468
|
}
|
|
389
469
|
|
|
390
470
|
if (!loaded) {
|
|
391
|
-
return
|
|
471
|
+
return <LoadingIndicator />;
|
|
392
472
|
}
|
|
393
473
|
|
|
394
474
|
const peersUI = peersUIs[peersUIId];
|
|
@@ -396,9 +476,9 @@ const UIAsyncLoader = (props: { peersUIId: string, props: Record<string, any> })
|
|
|
396
476
|
const _props = { ...props, uiVar: undefined };
|
|
397
477
|
try {
|
|
398
478
|
peersUI.propsSchema.parse(_props);
|
|
399
|
-
const Component = peersUI.content as React.ComponentType<
|
|
479
|
+
const Component = peersUI.content as React.ComponentType<Record<string, unknown>>;
|
|
400
480
|
return (
|
|
401
|
-
<UIErrorBoundary
|
|
481
|
+
<UIErrorBoundary
|
|
402
482
|
peersUIId={peersUIId}
|
|
403
483
|
packageName={pkg.name}
|
|
404
484
|
componentName={peersUI.content?.name}
|
|
@@ -408,33 +488,46 @@ const UIAsyncLoader = (props: { peersUIId: string, props: Record<string, any> })
|
|
|
408
488
|
);
|
|
409
489
|
} catch (parseError) {
|
|
410
490
|
return (
|
|
411
|
-
<div
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
<div
|
|
491
|
+
<div
|
|
492
|
+
style={{
|
|
493
|
+
padding: "20px",
|
|
494
|
+
border: "2px solid #ff6b6b",
|
|
495
|
+
borderRadius: "8px",
|
|
496
|
+
backgroundColor: "#fff5f5",
|
|
497
|
+
color: "#721c24",
|
|
498
|
+
fontFamily: "monospace",
|
|
499
|
+
margin: "10px 0",
|
|
500
|
+
}}
|
|
501
|
+
>
|
|
502
|
+
<h3 style={{ color: "#c53030", marginTop: 0 }}>Props Validation Error</h3>
|
|
503
|
+
<div style={{ marginBottom: "15px" }}>
|
|
504
|
+
<div>
|
|
505
|
+
<strong>Peers UI ID:</strong> {peersUIId}
|
|
506
|
+
</div>
|
|
507
|
+
<div>
|
|
508
|
+
<strong>Package:</strong> {pkg.name}
|
|
509
|
+
</div>
|
|
510
|
+
<div>
|
|
511
|
+
<strong>Component:</strong> {peersUI.content?.name}
|
|
512
|
+
</div>
|
|
425
513
|
</div>
|
|
426
|
-
|
|
427
|
-
<div
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
514
|
+
|
|
515
|
+
<div
|
|
516
|
+
style={{
|
|
517
|
+
backgroundColor: "#fed7d7",
|
|
518
|
+
padding: "10px",
|
|
519
|
+
borderRadius: "4px",
|
|
520
|
+
whiteSpace: "pre-wrap",
|
|
521
|
+
overflow: "auto",
|
|
522
|
+
maxHeight: "200px",
|
|
523
|
+
marginBottom: "15px",
|
|
524
|
+
}}
|
|
525
|
+
>
|
|
526
|
+
<strong>Error:</strong> Props did not match schema
|
|
527
|
+
<br />
|
|
528
|
+
<strong>Validation Error:</strong> {JSON.stringify(parseError, null, 2)}
|
|
529
|
+
<br />
|
|
530
|
+
<br />
|
|
438
531
|
<strong>Props:</strong> {JSON.stringify(toJSON(_props), null, 2)}
|
|
439
532
|
</div>
|
|
440
533
|
</div>
|
|
@@ -443,60 +536,65 @@ const UIAsyncLoader = (props: { peersUIId: string, props: Record<string, any> })
|
|
|
443
536
|
} else {
|
|
444
537
|
return <div>Component not found</div>;
|
|
445
538
|
}
|
|
446
|
-
}
|
|
539
|
+
};
|
|
447
540
|
|
|
448
|
-
|
|
449
|
-
registerPeersUIRoute: (route: IPeersUIRoute) =>
|
|
450
|
-
getPeersUIRoutes: () => IPeersUIRoute[]
|
|
451
|
-
UIRouter: typeof UIRouter
|
|
452
|
-
UILoader: typeof UILoader
|
|
541
|
+
type PeersRuntimeWindow = Window & {
|
|
542
|
+
registerPeersUIRoute: (route: IPeersUIRoute) => void;
|
|
543
|
+
getPeersUIRoutes: () => IPeersUIRoute[];
|
|
544
|
+
UIRouter: typeof UIRouter;
|
|
545
|
+
UILoader: typeof UILoader;
|
|
453
546
|
};
|
|
454
547
|
|
|
455
|
-
|
|
456
|
-
|
|
548
|
+
let _window: PeersRuntimeWindow;
|
|
549
|
+
|
|
550
|
+
if (typeof window !== "undefined") {
|
|
551
|
+
_window = window as unknown as PeersRuntimeWindow;
|
|
457
552
|
if (!_window.registerPeersUIRoute) {
|
|
458
553
|
let uiRoutes: IPeersUIRoute[] = [];
|
|
459
|
-
Object.defineProperty(window,
|
|
554
|
+
Object.defineProperty(window, "registerPeersUIRoute", {
|
|
460
555
|
value: (route: IPeersUIRoute) => {
|
|
461
|
-
uiRoutes = uiRoutes.filter(r => !(r.peersUIId === route.peersUIId));
|
|
556
|
+
uiRoutes = uiRoutes.filter((r) => !(r.peersUIId === route.peersUIId));
|
|
462
557
|
uiRoutes.push(route);
|
|
463
|
-
uiRoutes = orderBy(uiRoutes, r => r.priority ?? 0,
|
|
558
|
+
uiRoutes = orderBy(uiRoutes, (r) => r.priority ?? 0, "desc");
|
|
464
559
|
},
|
|
465
560
|
writable: false,
|
|
466
|
-
configurable: false
|
|
561
|
+
configurable: false,
|
|
467
562
|
});
|
|
468
|
-
Object.defineProperty(window,
|
|
563
|
+
Object.defineProperty(window, "getPeersUIRoutes", {
|
|
469
564
|
value: () => {
|
|
470
565
|
return [...uiRoutes];
|
|
471
566
|
},
|
|
472
567
|
writable: false,
|
|
473
|
-
configurable: false
|
|
568
|
+
configurable: false,
|
|
474
569
|
});
|
|
475
|
-
Object.defineProperty(window,
|
|
570
|
+
Object.defineProperty(window, "UIRouter", {
|
|
476
571
|
value: UIRouter,
|
|
477
572
|
writable: false,
|
|
478
|
-
configurable: false
|
|
573
|
+
configurable: false,
|
|
479
574
|
});
|
|
480
|
-
Object.defineProperty(window,
|
|
575
|
+
Object.defineProperty(window, "UILoader", {
|
|
481
576
|
value: UILoader,
|
|
482
577
|
writable: false,
|
|
483
|
-
configurable: false
|
|
578
|
+
configurable: false,
|
|
484
579
|
});
|
|
485
580
|
}
|
|
486
581
|
}
|
|
487
582
|
|
|
488
|
-
export const peersSystemPackageId =
|
|
583
|
+
export const peersSystemPackageId = "000peers0system000package";
|
|
489
584
|
|
|
490
585
|
/**
|
|
491
586
|
* This is meant to make it easy to register components that are internal to peers
|
|
492
587
|
*/
|
|
493
588
|
export async function registerInternalPeersUI(props: {
|
|
494
|
-
component:
|
|
495
|
-
|
|
496
|
-
|
|
589
|
+
component: IPeersUI["content"];
|
|
590
|
+
/** Zod schemas may use a different zod instance than peers-sdk (duplicate resolution); keep loose. */
|
|
591
|
+
// biome-ignore lint/suspicious/noExplicitAny: see JSDoc
|
|
592
|
+
propsSchema?: any;
|
|
593
|
+
routes?: Omit<IPeersUIRoute, "peersUIId" | "packageId">[];
|
|
497
594
|
peersUIId?: string;
|
|
498
595
|
}) {
|
|
499
|
-
|
|
596
|
+
const routeWin = window as Window & { registerPeersUIRoute?: (route: IPeersUIRoute) => void };
|
|
597
|
+
while (!routeWin.registerPeersUIRoute) {
|
|
500
598
|
console.log("Waiting for registerPeersUIRoute to be defined on the window object");
|
|
501
599
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
502
600
|
}
|
|
@@ -510,7 +608,7 @@ export async function registerInternalPeersUI(props: {
|
|
|
510
608
|
peersUIs[peersUIId] = peersUI;
|
|
511
609
|
|
|
512
610
|
if (props.routes?.length) {
|
|
513
|
-
props.routes.forEach(route => {
|
|
611
|
+
props.routes.forEach((route) => {
|
|
514
612
|
_window.registerPeersUIRoute({
|
|
515
613
|
packageId: peersSystemPackageId,
|
|
516
614
|
peersUIId,
|
|
@@ -530,11 +628,11 @@ const reloadPackage = debounceByArgs(async (packageId: string) => {
|
|
|
530
628
|
}
|
|
531
629
|
}, 200);
|
|
532
630
|
|
|
533
|
-
getUserContext().then(
|
|
534
|
-
Packages().dataChanged.subscribe(async evt => {
|
|
631
|
+
getUserContext().then((_userContext) => {
|
|
632
|
+
Packages().dataChanged.subscribe(async (evt) => {
|
|
535
633
|
const pkg = evt.dataObject;
|
|
536
634
|
const loadingPromise = uiLoadingPromises[pkg.packageId];
|
|
537
635
|
if (!loadingPromise) return;
|
|
538
636
|
reloadPackage(pkg.packageId);
|
|
539
|
-
})
|
|
540
|
-
})
|
|
637
|
+
});
|
|
638
|
+
});
|