neutralino-python 0.1.0__py3-none-any.whl
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.
- neutralino/__init__.py +88 -0
- neutralino/_catalog.py +297 -0
- neutralino/_data/LICENSE.neutralino-js-client +21 -0
- neutralino/_data/LICENSE.neutralinojs +1066 -0
- neutralino/_data/docs/cli.md +315 -0
- neutralino/_data/docs/custom-components.md +107 -0
- neutralino/_data/docs/custom-frontends.md +80 -0
- neutralino/_data/docs/desktop-helpers.md +296 -0
- neutralino/_data/docs/guide.md +131 -0
- neutralino/_data/docs/llms-full.txt +3921 -0
- neutralino/_data/docs/llms.txt +43 -0
- neutralino/_data/docs/manifests/components.json +20128 -0
- neutralino/_data/docs/manifests/examples.json +52 -0
- neutralino/_data/docs/manifests/native.json +3024 -0
- neutralino/_data/docs/manifests/schema.json +43 -0
- neutralino/_data/docs/manual-checklist.md +189 -0
- neutralino/_data/docs/packaging.md +252 -0
- neutralino/_data/docs/performance.md +15 -0
- neutralino/_data/docs/platforms.md +15 -0
- neutralino/_data/docs/reference/components.md +1685 -0
- neutralino/_data/docs/reference/native.md +148 -0
- neutralino/_data/docs/security.md +60 -0
- neutralino/_data/docs/ui.md +249 -0
- neutralino/_data/docs/updates.md +366 -0
- neutralino/_data/examples/README.md +6 -0
- neutralino/_data/examples/crud/README.md +36 -0
- neutralino/_data/examples/crud/app.py +243 -0
- neutralino/_data/examples/dashboard/README.md +36 -0
- neutralino/_data/examples/dashboard/app.py +367 -0
- neutralino/_data/examples/editor/README.md +35 -0
- neutralino/_data/examples/editor/app.py +190 -0
- neutralino/_data/examples/file-manager/README.md +40 -0
- neutralino/_data/examples/file-manager/app.py +120 -0
- neutralino/_data/examples/file-manager/frontend/index.html +20 -0
- neutralino/_data/examples/file-manager/frontend/main.js +55 -0
- neutralino/_data/examples/file-manager/frontend/neutralino.js +1 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/file-manager/frontend/style.css +4 -0
- neutralino/_data/examples/hybrid/README.md +48 -0
- neutralino/_data/examples/hybrid/app.py +80 -0
- neutralino/_data/examples/hybrid/components/counter.mjs +37 -0
- neutralino/_data/examples/hybrid/components/widget.mjs +23 -0
- neutralino/_data/examples/hybrid/styles.css +21 -0
- neutralino/_data/examples/hybrid/widget/package.json +20 -0
- neutralino/_data/examples/hybrid/widget/src/Widget.jsx +25 -0
- neutralino/_data/examples/hybrid/widget/vite.config.mjs +19 -0
- neutralino/_data/examples/monitor/README.md +36 -0
- neutralino/_data/examples/monitor/app.py +375 -0
- neutralino/_data/examples/react/README.md +90 -0
- neutralino/_data/examples/react/app.py +68 -0
- neutralino/_data/examples/react/frontend/.gitignore +5 -0
- neutralino/_data/examples/react/frontend/index.html +17 -0
- neutralino/_data/examples/react/frontend/package-lock.json +1232 -0
- neutralino/_data/examples/react/frontend/package.json +25 -0
- neutralino/_data/examples/react/frontend/scripts/prepare-bridge.mjs +49 -0
- neutralino/_data/examples/react/frontend/src/App.tsx +157 -0
- neutralino/_data/examples/react/frontend/src/backend.ts +21 -0
- neutralino/_data/examples/react/frontend/src/calls.test.ts +206 -0
- neutralino/_data/examples/react/frontend/src/calls.ts +306 -0
- neutralino/_data/examples/react/frontend/src/globals.d.ts +14 -0
- neutralino/_data/examples/react/frontend/src/hooks.ts +45 -0
- neutralino/_data/examples/react/frontend/src/main.tsx +13 -0
- neutralino/_data/examples/react/frontend/src/styles.css +11 -0
- neutralino/_data/examples/react/frontend/tsconfig.json +18 -0
- neutralino/_data/examples/react/frontend/vite.config.ts +9 -0
- neutralino/_data/examples/settings/README.md +38 -0
- neutralino/_data/examples/settings/app.py +440 -0
- neutralino/_data/examples/updater/.gitignore +2 -0
- neutralino/_data/examples/updater/README.md +82 -0
- neutralino/_data/examples/updater/app.py +160 -0
- neutralino/_data/examples/updater/app.toml +21 -0
- neutralino/_data/examples/updater/demo.py +107 -0
- neutralino/_data/examples/updater/requirements.txt +2 -0
- neutralino/_data/examples/updater/sources/github-private.toml +21 -0
- neutralino/_data/examples/updater/sources/github-public.toml +21 -0
- neutralino/_data/examples/vanilla/README.md +35 -0
- neutralino/_data/examples/vanilla/app.py +46 -0
- neutralino/_data/examples/vanilla/frontend/index.html +17 -0
- neutralino/_data/examples/vanilla/frontend/main.js +29 -0
- neutralino/_data/examples/vanilla/frontend/neutralino.js +1 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/vanilla/frontend/style.css +4 -0
- neutralino/_data/explorer/app.py +1328 -0
- neutralino/_data/explorer/catalogue.json +48179 -0
- neutralino/_data/explorer/explorer_previews.py +247 -0
- neutralino/_data/explorer/sources/native/always_on_top.py +55 -0
- neutralino/_data/explorer/sources/native/binary.py +125 -0
- neutralino/_data/explorer/sources/native/borderless.py +99 -0
- neutralino/_data/explorer/sources/native/broadcast.py +90 -0
- neutralino/_data/explorer/sources/native/config.py +78 -0
- neutralino/_data/explorer/sources/native/controls.py +140 -0
- neutralino/_data/explorer/sources/native/directory.py +163 -0
- neutralino/_data/explorer/sources/native/displays.py +75 -0
- neutralino/_data/explorer/sources/native/env.py +98 -0
- neutralino/_data/explorer/sources/native/events.py +124 -0
- neutralino/_data/explorer/sources/native/exec_command.py +79 -0
- neutralino/_data/explorer/sources/native/folder.py +70 -0
- neutralino/_data/explorer/sources/native/icon_badge.py +101 -0
- neutralino/_data/explorer/sources/native/image.py +119 -0
- neutralino/_data/explorer/sources/native/lifecycle.py +99 -0
- neutralino/_data/explorer/sources/native/locale.py +70 -0
- neutralino/_data/explorer/sources/native/main_menu.py +103 -0
- neutralino/_data/explorer/sources/native/message_box.py +101 -0
- neutralino/_data/explorer/sources/native/mouse.py +70 -0
- neutralino/_data/explorer/sources/native/multi_window.py +134 -0
- neutralino/_data/explorer/sources/native/notification.py +74 -0
- neutralino/_data/explorer/sources/native/open_external.py +81 -0
- neutralino/_data/explorer/sources/native/open_file.py +102 -0
- neutralino/_data/explorer/sources/native/paths.py +77 -0
- neutralino/_data/explorer/sources/native/print_snapshot.py +84 -0
- neutralino/_data/explorer/sources/native/read_write.py +192 -0
- neutralino/_data/explorer/sources/native/resources.py +110 -0
- neutralino/_data/explorer/sources/native/save_file.py +101 -0
- neutralino/_data/explorer/sources/native/server_mount.py +106 -0
- neutralino/_data/explorer/sources/native/sound.py +84 -0
- neutralino/_data/explorer/sources/native/spawn_process.py +128 -0
- neutralino/_data/explorer/sources/native/states.py +122 -0
- neutralino/_data/explorer/sources/native/stats_permissions.py +147 -0
- neutralino/_data/explorer/sources/native/storage.py +108 -0
- neutralino/_data/explorer/sources/native/system_info.py +115 -0
- neutralino/_data/explorer/sources/native/text.py +133 -0
- neutralino/_data/explorer/sources/native/trash.py +98 -0
- neutralino/_data/explorer/sources/native/tray.py +109 -0
- neutralino/_data/explorer/sources/native/watcher.py +167 -0
- neutralino/_data/explorer/sources/patterns/content_blocks.py +119 -0
- neutralino/_data/explorer/sources/patterns/dynamic_dashboard.py +121 -0
- neutralino/_data/explorer/sources/patterns/dynamic_form.py +120 -0
- neutralino/_data/explorer/sources/patterns/dynamic_table.py +109 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.mjs +24 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.py +124 -0
- neutralino/_data/explorer/sources/patterns/errors_timeouts.py +108 -0
- neutralino/_data/explorer/sources/patterns/feature_flags.py +99 -0
- neutralino/_data/explorer/sources/patterns/file_drop.py +126 -0
- neutralino/_data/explorer/sources/patterns/http_from_python.py +152 -0
- neutralino/_data/explorer/sources/patterns/keyboard_shortcuts.py +153 -0
- neutralino/_data/explorer/sources/patterns/live_config_reload.py +160 -0
- neutralino/_data/explorer/sources/patterns/logging.py +184 -0
- neutralino/_data/explorer/sources/patterns/long_tasks.py +121 -0
- neutralino/_data/explorer/sources/patterns/multi_window_sync.py +68 -0
- neutralino/_data/explorer/sources/patterns/navigation_from_backend.py +109 -0
- neutralino/_data/explorer/sources/patterns/onboarding.py +123 -0
- neutralino/_data/explorer/sources/patterns/optimistic_updates.py +89 -0
- neutralino/_data/explorer/sources/patterns/persistence.py +114 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.mjs +10 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.py +64 -0
- neutralino/_data/explorer/sources/patterns/python_push.py +84 -0
- neutralino/_data/explorer/sources/patterns/recurring_events.py +114 -0
- neutralino/_data/explorer/sources/patterns/roles_permissions.py +104 -0
- neutralino/_data/explorer/sources/patterns/scheduled_jobs.py +194 -0
- neutralino/_data/explorer/sources/patterns/settings_page.py +165 -0
- neutralino/_data/explorer/sources/patterns/sqlite.py +181 -0
- neutralino/_data/explorer/sources/patterns/streaming.py +102 -0
- neutralino/_data/explorer/sources/patterns/texts_i18n.py +81 -0
- neutralino/_data/explorer/sources/patterns/theme_from_backend.py +86 -0
- neutralino/_data/explorer/sources/patterns/updater.py +232 -0
- neutralino/_data/explorer/sources/workspace/calendar/app.py +547 -0
- neutralino/_data/explorer/sources/workspace/customers/app.py +467 -0
- neutralino/_data/explorer/sources/workspace/dashboard/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/dashboard/app.py +367 -0
- neutralino/_data/explorer/sources/workspace/documents/app.py +511 -0
- neutralino/_data/explorer/sources/workspace/inbox/app.py +439 -0
- neutralino/_data/explorer/sources/workspace/orders/app.py +491 -0
- neutralino/_data/explorer/sources/workspace/reports/app.py +386 -0
- neutralino/_data/explorer/sources/workspace/settings/README.md +38 -0
- neutralino/_data/explorer/sources/workspace/settings/app.py +440 -0
- neutralino/_data/explorer/sources/workspace/system/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/system/app.py +375 -0
- neutralino/_data/explorer/sources/workspace/tasks/app.py +462 -0
- neutralino/_data/renderer/LICENSES/@babel__runtime@7.29.17/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/@codemirror__autocomplete@6.20.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__commands@6.11.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-css@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-html@6.4.12/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-javascript@6.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-json@6.0.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-markdown@6.5.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-python@6.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-sql@6.10.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-yaml@6.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__language@6.13.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__search@6.7.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__state@6.7.6/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__view@6.44.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__accessibility@3.1.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__core@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__sortable@10.0.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__utilities@3.2.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@emoji-mart__data@1.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__core@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__dom@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react-dom@2.1.9/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react@0.27.20/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__utils@0.2.12/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@lezer__common@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__css@1.3.9/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__highlight@1.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__html@1.3.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__javascript@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__json@1.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__lr@1.4.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__markdown@1.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__python@1.1.21/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__yaml@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__carousel@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__charts@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__code-highlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__core@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dates@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dropzone@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__emoji@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__hooks@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__lightbox@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__notifications@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__nprogress@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__schedule@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__spotlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__store@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__tiptap@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@marijn__find-cluster-break@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@reduxjs__toolkit@2.16.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tabler__icons-react@3.55.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__react-virtual@3.14.32/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__virtual-core@3.19.17/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__core@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-blockquote@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-bold@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code-block@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-document@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-hard-break@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-heading@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-horizontal-rule@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-italic@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-link@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-list@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-paragraph@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-strike@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-text@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-underline@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extensions@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__react@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__starter-kit@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/attr-accept@4.0.1/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/clsx@2.1.1/license +9 -0
- neutralino/_data/renderer/LICENSES/crelt@1.0.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/d3-array@3.2.5/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-color@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-format@3.1.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-interpolate@3.0.2/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-path@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-scale@4.0.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-shape@3.2.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time-format@4.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/dayjs@1.11.23/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/decimal.js-light@2.5.1/LICENCE.md +23 -0
- neutralino/_data/renderer/LICENSES/diff@9.0.0/LICENSE +29 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE +202 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE-MPL +373 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-react@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-reactive-utils@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/NOTICE +39 -0
- neutralino/_data/renderer/LICENSES/eventemitter3@5.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/fast-equals@5.4.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/file-selector@5.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/get-nonce@1.0.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/immer@11.2.14/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/linkifyjs@4.4.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/marked@18.4.0/LICENSE +44 -0
- neutralino/_data/renderer/LICENSES/neutralino.js@6.11.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/orderedmap@2.1.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/packages.json +1838 -0
- neutralino/_data/renderer/LICENSES/prosemirror-commands@1.7.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-dropcursor@1.8.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-gapcursor@1.4.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-history@1.5.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-keymap@1.2.3/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-model@1.25.13/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-schema-list@1.6.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-state@1.4.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-transform@1.12.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-view@1.44.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/react-dom@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-dropzone@20.1.4/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/react-is@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-number-format@5.4.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-redux@9.3.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll-bar@2.3.8/MIT-react-remove-scroll-bar.txt +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll@2.7.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-style-singleton@2.2.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-transition-group@4.4.5/LICENSE +30 -0
- neutralino/_data/renderer/LICENSES/react@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/recharts@3.11.3/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/redux-thunk@3.1.0/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/redux@5.0.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/reselect@5.2.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/rolldown@1.3.4/LICENSE +25 -0
- neutralino/_data/renderer/LICENSES/rope-sequence@1.3.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/rrule@2.8.1/LICENCE +65 -0
- neutralino/_data/renderer/LICENSES/scheduler@0.28.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/style-mod@4.1.5/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/tiny-invariant@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/tslib@2.9.1/LICENSE.txt +12 -0
- neutralino/_data/renderer/LICENSES/use-callback-ref@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sidecar@1.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sync-external-store@1.7.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/victory-vendor@38.1.1/LICENSE.txt +150 -0
- neutralino/_data/renderer/LICENSES/vite@8.4.1/LICENSE.md +2320 -0
- neutralino/_data/renderer/LICENSES/w3c-keyname@2.2.8/LICENSE +19 -0
- neutralino/_data/renderer/assets/IconGripVertical-BlJrWVuo.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DniHwTLK.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-Du0h7lB-.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CCe_blv1.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-CinrNxVJ.js +2 -0
- neutralino/_data/renderer/assets/css-CMUk25uq.js +1 -0
- neutralino/_data/renderer/assets/dist-70Le0T2N.js +1 -0
- neutralino/_data/renderer/assets/dist-BCHbQlae.js +11 -0
- neutralino/_data/renderer/assets/dist-BXts23GT.js +1 -0
- neutralino/_data/renderer/assets/dist-D2RX2UgP.js +23 -0
- neutralino/_data/renderer/assets/dist-DikJK2lp.js +1 -0
- neutralino/_data/renderer/assets/dist-acbbRM1z.js +1 -0
- neutralino/_data/renderer/assets/dnd-DaaaVala.js +5 -0
- neutralino/_data/renderer/assets/dropzone-CeqF5SZx.js +1 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-CbyYjwMN.js +1 -0
- neutralino/_data/renderer/assets/emoji-BfRPfoVw.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-C5ZYjSBQ.js +82 -0
- neutralino/_data/renderer/assets/highlight-CB6hGb5A.js +3 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/html-Dad3kwIa.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-X3Kr0nh-.js +1 -0
- neutralino/_data/renderer/assets/index-CU0HB-J7.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-BQb8vpw3.js +1 -0
- neutralino/_data/renderer/assets/json-BCFmxlML.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BHtgbsUV.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-DSuAylvy.js +5 -0
- neutralino/_data/renderer/assets/markdown-DjaNWMgH.js +77 -0
- neutralino/_data/renderer/assets/python-pdbIAveZ.js +9 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/richtext-Z6fG9G2_.js +137 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-knlyJw_A.js +1 -0
- neutralino/_data/renderer/assets/sql-DLoQFEde.js +2 -0
- neutralino/_data/renderer/assets/with-selector-BOM9_OlN.js +1 -0
- neutralino/_data/renderer/assets/yaml-BJNzokSe.js +1 -0
- neutralino/_data/renderer/index.html +22 -0
- neutralino/_data/renderer/manifest.json +202 -0
- neutralino/_data/renderer/neutralino.js +1 -0
- neutralino/_data/renderer/shared/mantine-core.mjs +5 -0
- neutralino/_data/renderer/shared/mantine-hooks.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom-client.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom.mjs +6 -0
- neutralino/_data/renderer/shared/react-jsx-runtime.mjs +5 -0
- neutralino/_data/renderer/shared/react.mjs +6 -0
- neutralino/_data/skills/README.md +6 -0
- neutralino/_data/skills/neutralino-app-patterns/SKILL.md +101 -0
- neutralino/_data/skills/neutralino-app-patterns/references/dashboards-and-background-work.md +55 -0
- neutralino/_data/skills/neutralino-app-patterns/references/storage-and-settings.md +57 -0
- neutralino/_data/skills/neutralino-app-patterns/references/tables-and-crud.md +81 -0
- neutralino/_data/skills/neutralino-frontend/SKILL.md +121 -0
- neutralino/_data/skills/neutralino-frontend/references/bridge.md +63 -0
- neutralino/_data/skills/neutralino-frontend/references/custom-components.md +84 -0
- neutralino/_data/skills/neutralino-frontend/references/frameworks.md +61 -0
- neutralino/_data/skills/neutralino-maintenance/SKILL.md +85 -0
- neutralino/_data/skills/neutralino-maintenance/references/platforms-and-gates.md +35 -0
- neutralino/_data/skills/neutralino-maintenance/references/records.md +38 -0
- neutralino/_data/skills/neutralino-maintenance/references/review-process.md +36 -0
- neutralino/_data/skills/neutralino-native/SKILL.md +107 -0
- neutralino/_data/skills/neutralino-native/references/api-conventions.md +72 -0
- neutralino/_data/skills/neutralino-native/references/desktop-helpers.md +53 -0
- neutralino/_data/skills/neutralino-native/references/permissions-windows.md +53 -0
- neutralino/_data/skills/neutralino-packaging/SKILL.md +99 -0
- neutralino/_data/skills/neutralino-packaging/references/build-layout.md +51 -0
- neutralino/_data/skills/neutralino-packaging/references/managed-install.md +59 -0
- neutralino/_data/skills/neutralino-packaging/references/templates-and-config.md +63 -0
- neutralino/_data/skills/neutralino-python/SKILL.md +109 -0
- neutralino/_data/skills/neutralino-python/references/architecture.md +53 -0
- neutralino/_data/skills/neutralino-python/references/cli.md +60 -0
- neutralino/_data/skills/neutralino-python/references/platforms-security.md +44 -0
- neutralino/_data/skills/neutralino-rpc/SKILL.md +114 -0
- neutralino/_data/skills/neutralino-rpc/references/errors-and-limits.md +44 -0
- neutralino/_data/skills/neutralino-rpc/references/expose-and-context.md +74 -0
- neutralino/_data/skills/neutralino-rpc/references/streams-and-cancellation.md +53 -0
- neutralino/_data/skills/neutralino-ui/SKILL.md +115 -0
- neutralino/_data/skills/neutralino-ui/references/components-and-tree.md +74 -0
- neutralino/_data/skills/neutralino-ui/references/state-forms-events.md +85 -0
- neutralino/_data/skills/neutralino-ui/references/themes-profiles-assets.md +105 -0
- neutralino/_data/skills/neutralino-updates/SKILL.md +94 -0
- neutralino/_data/skills/neutralino-updates/references/config-and-api.md +80 -0
- neutralino/_data/skills/neutralino-updates/references/releases-and-install.md +77 -0
- neutralino/_data/skills/neutralino-updates/references/security-rollback.md +48 -0
- neutralino/_data/ui/contracts.json +32927 -0
- neutralino/_data/ui/emoji.json +1 -0
- neutralino/_data/upstream-lock.json +97 -0
- neutralino/_managed.py +1099 -0
- neutralino/_paths.py +220 -0
- neutralino/_platform.py +150 -0
- neutralino/_scaffold.py +344 -0
- neutralino/api/_base.py +99 -0
- neutralino/api/_custom.py +1350 -0
- neutralino/api/_dec.py +21 -0
- neutralino/api/_enc.py +80 -0
- neutralino/api/app.py +119 -0
- neutralino/api/clipboard.py +101 -0
- neutralino/api/computer.py +261 -0
- neutralino/api/custom.py +36 -0
- neutralino/api/debug.py +41 -0
- neutralino/api/extensions.py +57 -0
- neutralino/api/filesystem.py +633 -0
- neutralino/api/net.py +22 -0
- neutralino/api/os.py +508 -0
- neutralino/api/resources.py +124 -0
- neutralino/api/server.py +66 -0
- neutralino/api/storage.py +98 -0
- neutralino/api/types.py +342 -0
- neutralino/api/updater.py +22 -0
- neutralino/api/window.py +397 -0
- neutralino/application.py +1260 -0
- neutralino/bundle.py +187 -0
- neutralino/cli.py +629 -0
- neutralino/client.py +496 -0
- neutralino/config.py +671 -0
- neutralino/devtools.py +1973 -0
- neutralino/errors.py +142 -0
- neutralino/events.py +579 -0
- neutralino/execution.py +293 -0
- neutralino/extension.py +134 -0
- neutralino/frontend/python-bridge.d.ts +207 -0
- neutralino/frontend/python-bridge.mjs +854 -0
- neutralino/protocol.py +456 -0
- neutralino/py.typed +0 -0
- neutralino/rpc.py +1625 -0
- neutralino/runtime.py +591 -0
- neutralino/supervisor.py +866 -0
- neutralino/sync_client.py +376 -0
- neutralino/templates/default/app.py +32 -0
- neutralino/templates/default/frontend/app.js +28 -0
- neutralino/templates/default/frontend/index.html +26 -0
- neutralino/templates/default/frontend/neutralino.js +1 -0
- neutralino/templates/default/frontend/styles.css +8 -0
- neutralino/templates/default/gitignore.txt +3 -0
- neutralino/templates/default/neutralino.config.json +25 -0
- neutralino/templates/hybrid/README.md +17 -0
- neutralino/templates/hybrid/app.py +49 -0
- neutralino/templates/hybrid/components/counter.mjs +37 -0
- neutralino/templates/hybrid/styles.css +21 -0
- neutralino/templates/python-ui/README.md +15 -0
- neutralino/templates/python-ui/app.py +44 -0
- neutralino/templates/python-ui/gitignore.txt +3 -0
- neutralino/templates/python-ui/requirements.txt +4 -0
- neutralino/templates/react/README.md +28 -0
- neutralino/templates/react/app.py +52 -0
- neutralino/templates/react/components/widget.mjs +23 -0
- neutralino/templates/react/widget/package.json +20 -0
- neutralino/templates/react/widget/src/Widget.jsx +25 -0
- neutralino/templates/react/widget/vite.config.mjs +19 -0
- neutralino/transport.py +661 -0
- neutralino/types.py +93 -0
- neutralino/ui/__init__.py +139 -0
- neutralino/ui/_app.py +1529 -0
- neutralino/ui/_assets.py +407 -0
- neutralino/ui/_bases.py +1210 -0
- neutralino/ui/_behaviours.py +1066 -0
- neutralino/ui/_charts.py +732 -0
- neutralino/ui/_component.py +882 -0
- neutralino/ui/_dates.py +168 -0
- neutralino/ui/_desktop.py +879 -0
- neutralino/ui/_events.py +192 -0
- neutralino/ui/_filters.py +427 -0
- neutralino/ui/_forms.py +282 -0
- neutralino/ui/_protocol.py +201 -0
- neutralino/ui/_schedule.py +543 -0
- neutralino/ui/_security.py +106 -0
- neutralino/ui/_session.py +969 -0
- neutralino/ui/_state.py +199 -0
- neutralino/ui/_tables.py +256 -0
- neutralino/ui/_theme.py +154 -0
- neutralino/ui/blocks/__init__.py +19 -0
- neutralino/ui/blocks/_data.py +2239 -0
- neutralino/ui/blocks/_interactive.py +622 -0
- neutralino/ui/blocks/_layout.py +2967 -0
- neutralino/ui/components/__init__.py +81 -0
- neutralino/ui/components/_dates.py +879 -0
- neutralino/ui/components/_editors.py +217 -0
- neutralino/ui/components/_extensions.py +790 -0
- neutralino/ui/components/_extras.py +303 -0
- neutralino/ui/components/_generated.py +30565 -0
- neutralino/ui/components/_types.py +17 -0
- neutralino/ui/schema.py +824 -0
- neutralino/ui/validators.py +362 -0
- neutralino/updates/__init__.py +96 -0
- neutralino/updates/_http.py +320 -0
- neutralino/updates/_layout.py +762 -0
- neutralino/updates/archive.py +216 -0
- neutralino/updates/config.py +256 -0
- neutralino/updates/errors.py +97 -0
- neutralino/updates/install.sh.in +201 -0
- neutralino/updates/launcher.py +18 -0
- neutralino/updates/manager.py +808 -0
- neutralino/updates/manifest.py +196 -0
- neutralino/updates/release.py +314 -0
- neutralino/updates/semver.py +84 -0
- neutralino/updates/sources.py +392 -0
- neutralino/windows.py +316 -0
- neutralino_python-0.1.0.dist-info/METADATA +121 -0
- neutralino_python-0.1.0.dist-info/RECORD +521 -0
- neutralino_python-0.1.0.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
// neutralino-python frontend companion: SDK RPC protocol v1.
|
|
2
|
+
// Dependency-free ES module. Works with the official Neutralino JS client
|
|
3
|
+
// (window.Neutralino or an injected client object). It never opens its own
|
|
4
|
+
// WebSocket: page -> backend uses Neutralino.extensions.dispatch, backend ->
|
|
5
|
+
// page arrives as the event "neutralino.sdk.rpc.v1" (sent with app.broadcast).
|
|
6
|
+
// Peer ids route messages; they are not credentials (see the SDK security doc).
|
|
7
|
+
|
|
8
|
+
export const RPC_EVENT = 'neutralino.sdk.rpc.v1';
|
|
9
|
+
export const PROTOCOL_VERSION = 1;
|
|
10
|
+
|
|
11
|
+
const KINDS = new Set(['hello', 'welcome', 'request', 'notify', 'result', 'error', 'chunk',
|
|
12
|
+
'progress', 'credit', 'cancel', 'bye', 'discover']);
|
|
13
|
+
const ENVELOPE = new Set(['v', 'kind', 'session', 'generation', 'from', 'to', 'id']);
|
|
14
|
+
const PAYLOAD = {
|
|
15
|
+
hello: ['capabilities'], welcome: ['capabilities'],
|
|
16
|
+
request: ['method', 'params', 'stream', 'credit'], notify: ['method', 'params'],
|
|
17
|
+
result: ['value'], error: ['error'], chunk: ['seq', 'value'], progress: ['seq', 'value'],
|
|
18
|
+
credit: ['count'], cancel: ['reason'], bye: ['reason'], discover: [],
|
|
19
|
+
};
|
|
20
|
+
const NAME_RE = /^[A-Za-z_][A-Za-z0-9_.\-]{0,127}$/;
|
|
21
|
+
const ID_RE = /^[A-Za-z0-9_.:\-]{1,128}$/;
|
|
22
|
+
const CODE_RE = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
23
|
+
const CAPABILITIES = ['rpc', 'stream', 'progress', 'cancel', 'discover', 'reverse'];
|
|
24
|
+
|
|
25
|
+
const DEFAULT_LIMITS = Object.freeze({
|
|
26
|
+
initialCredit: 16, maxCredit: 64, maxChunkBytes: 256 * 1024,
|
|
27
|
+
maxMessageBytes: 4 * 1024 * 1024, maxActive: 32, maxPending: 64,
|
|
28
|
+
handshakeRetryMs: 500, streamIdleMs: 30000, maxDepth: 64, progressPerSecond: 10,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Bounds for limits and timeouts (same rules as the Python RpcLimits): positive
|
|
32
|
+
// finite durations below the setTimeout maximum (a larger delay fires at once),
|
|
33
|
+
// positive bounded integer capacities, initialCredit <= maxCredit <= 64 and
|
|
34
|
+
// maxChunkBytes < maxMessageBytes. [kind, maximum]
|
|
35
|
+
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
36
|
+
const LIMIT_RULES = Object.freeze({
|
|
37
|
+
initialCredit: ['int', 64], maxCredit: ['int', 64],
|
|
38
|
+
maxChunkBytes: ['int', 64 * 1024 * 1024], maxMessageBytes: ['int', 64 * 1024 * 1024],
|
|
39
|
+
maxActive: ['int', 4096], maxPending: ['int', 4096], maxDepth: ['int', 1000],
|
|
40
|
+
handshakeRetryMs: ['number', MAX_TIMER_MS], streamIdleMs: ['number', MAX_TIMER_MS],
|
|
41
|
+
progressPerSecond: ['number', 1000],
|
|
42
|
+
});
|
|
43
|
+
const OPTION_KEYS = new Set(['neutralino', 'timeoutMs', 'limits']);
|
|
44
|
+
|
|
45
|
+
/** TypeError unless a number; RangeError unless finite, in (0, max] and (for 'int') integral. */
|
|
46
|
+
function checkNumber(name, v, kind, max) {
|
|
47
|
+
if (typeof v !== 'number') throw new TypeError(`${name} must be a number, got ${v === null ? 'null' : typeof v}`);
|
|
48
|
+
if (!Number.isFinite(v)) throw new RangeError(`${name} must be finite, got ${v}`);
|
|
49
|
+
if (kind === 'int' && !Number.isInteger(v)) throw new RangeError(`${name} must be an integer, got ${v}`);
|
|
50
|
+
if (v <= 0 || v > max) throw new RangeError(`${name} must be > 0 and <= ${max}, got ${v}`);
|
|
51
|
+
return v;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function resolveLimits(limits) {
|
|
55
|
+
if (limits === undefined) return DEFAULT_LIMITS;
|
|
56
|
+
if (!isPlainObject(limits)) throw new TypeError('limits must be a plain object');
|
|
57
|
+
const out = { ...DEFAULT_LIMITS };
|
|
58
|
+
for (const [k, v] of Object.entries(limits)) {
|
|
59
|
+
if (!Object.hasOwn(LIMIT_RULES, k)) throw new TypeError(`unknown limit ${k}`);
|
|
60
|
+
if (v !== undefined) out[k] = checkNumber(`limits.${k}`, v, ...LIMIT_RULES[k]);
|
|
61
|
+
}
|
|
62
|
+
if (out.initialCredit > out.maxCredit) throw new RangeError('limits.initialCredit must be <= limits.maxCredit');
|
|
63
|
+
if (out.maxChunkBytes >= out.maxMessageBytes) throw new RangeError('limits.maxChunkBytes must be < limits.maxMessageBytes');
|
|
64
|
+
return Object.freeze(out);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const encoder = new TextEncoder();
|
|
68
|
+
// In a /u regex a well-formed pair is one code point: this matches lone surrogates only.
|
|
69
|
+
const LONE_SURROGATE = /\p{Cs}/u;
|
|
70
|
+
|
|
71
|
+
/** Error carrying an RPC v1 code (METHOD_NOT_FOUND, TIMEOUT, CANCELLED, ...). */
|
|
72
|
+
export class RpcError extends Error {
|
|
73
|
+
constructor(code, message = code, details = undefined) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = 'RpcError';
|
|
76
|
+
this.code = code;
|
|
77
|
+
if (details !== undefined) this.details = details;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isPlainObject(v) {
|
|
82
|
+
if (v === null || typeof v !== 'object' || Array.isArray(v)) return false;
|
|
83
|
+
const proto = Object.getPrototypeOf(v);
|
|
84
|
+
return proto === Object.prototype || proto === null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Throws RpcError(PROTOCOL_ERROR) unless v is plain, finite, safe-integer JSON
|
|
89
|
+
* whose strings (values and keys) are well-formed UTF-16: the runtime cannot
|
|
90
|
+
* parse a lone surrogate and would drop the frame without any answer.
|
|
91
|
+
*/
|
|
92
|
+
export function checkJson(v, maxDepth = DEFAULT_LIMITS.maxDepth) {
|
|
93
|
+
const stack = [[v, 0]];
|
|
94
|
+
while (stack.length) {
|
|
95
|
+
const [x, depth] = stack.pop();
|
|
96
|
+
if (depth > maxDepth) throw new RpcError('PROTOCOL_ERROR', 'JSON nesting too deep');
|
|
97
|
+
if (typeof x === 'string') {
|
|
98
|
+
if (LONE_SURROGATE.test(x)) throw new RpcError('PROTOCOL_ERROR', 'string contains a lone UTF-16 surrogate');
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (x === null || typeof x === 'boolean') continue;
|
|
102
|
+
if (typeof x === 'number') {
|
|
103
|
+
if (!Number.isFinite(x) || (Number.isInteger(x) && !Number.isSafeInteger(x))) {
|
|
104
|
+
throw new RpcError('PROTOCOL_ERROR', 'number not representable');
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(x)) { for (const y of x) stack.push([y, depth + 1]); continue; }
|
|
109
|
+
if (isPlainObject(x)) {
|
|
110
|
+
for (const [k, y] of Object.entries(x)) {
|
|
111
|
+
if (LONE_SURROGATE.test(k)) throw new RpcError('PROTOCOL_ERROR', 'key contains a lone UTF-16 surrogate');
|
|
112
|
+
stack.push([y, depth + 1]);
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
throw new RpcError('PROTOCOL_ERROR', `value of type ${typeof x} is not JSON`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const isInt = (x) => typeof x === 'number' && Number.isSafeInteger(x);
|
|
121
|
+
|
|
122
|
+
/** Strict validation of one RPC v1 message. Returns the message or throws. */
|
|
123
|
+
export function validateMessage(m, limits = DEFAULT_LIMITS) {
|
|
124
|
+
const bad = (why) => { throw new RpcError('PROTOCOL_ERROR', why); };
|
|
125
|
+
if (!isPlainObject(m)) bad('not an object');
|
|
126
|
+
if (m.v !== 1) bad('unsupported version');
|
|
127
|
+
if (!KINDS.has(m.kind)) bad('unknown kind');
|
|
128
|
+
const allowed = new Set([...ENVELOPE, ...PAYLOAD[m.kind]]);
|
|
129
|
+
for (const k of Object.keys(m)) if (!allowed.has(k)) bad(`unexpected field ${k}`);
|
|
130
|
+
for (const k of ['from', 'to', 'id']) if (typeof m[k] !== 'string' || !ID_RE.test(m[k])) bad(`invalid ${k}`);
|
|
131
|
+
if (m.kind === 'hello') {
|
|
132
|
+
if (m.session !== null && m.session !== undefined) bad('hello must not carry a session');
|
|
133
|
+
if (m.generation !== null && m.generation !== undefined) bad('hello must not carry a generation');
|
|
134
|
+
} else {
|
|
135
|
+
for (const k of ['session', 'generation']) if (typeof m[k] !== 'string' || !ID_RE.test(m[k])) bad(`invalid ${k}`);
|
|
136
|
+
}
|
|
137
|
+
if (m.kind === 'hello' || m.kind === 'welcome') {
|
|
138
|
+
if (!Array.isArray(m.capabilities) || m.capabilities.length > 32 ||
|
|
139
|
+
!m.capabilities.every((c) => typeof c === 'string' && c.length <= 64)) bad('invalid capabilities');
|
|
140
|
+
}
|
|
141
|
+
if (m.kind === 'request' || m.kind === 'notify') {
|
|
142
|
+
if (typeof m.method !== 'string' || !NAME_RE.test(m.method)) bad('invalid method');
|
|
143
|
+
if (m.params !== null && m.params !== undefined && !isPlainObject(m.params)) bad('params must be an object');
|
|
144
|
+
}
|
|
145
|
+
if (m.kind === 'request') {
|
|
146
|
+
if (typeof m.stream !== 'boolean') bad('stream must be boolean');
|
|
147
|
+
if (m.stream) { if (!isInt(m.credit) || m.credit < 1 || m.credit > limits.maxCredit) bad('invalid credit'); }
|
|
148
|
+
else if ('credit' in m) bad('credit only for streams');
|
|
149
|
+
}
|
|
150
|
+
if ((m.kind === 'chunk' || m.kind === 'progress') && (!isInt(m.seq) || m.seq < 0 || !('value' in m))) bad(`invalid ${m.kind}`);
|
|
151
|
+
if (m.kind === 'result' && !('value' in m)) bad('result needs value');
|
|
152
|
+
if (m.kind === 'error') {
|
|
153
|
+
const e = m.error;
|
|
154
|
+
if (!isPlainObject(e)) bad('invalid error');
|
|
155
|
+
for (const k of Object.keys(e)) if (!['code', 'message', 'details'].includes(k)) bad('unexpected error field');
|
|
156
|
+
if (typeof e.code !== 'string' || !CODE_RE.test(e.code)) bad('invalid error code');
|
|
157
|
+
if (typeof e.message !== 'string' || e.message.length > 4096) bad('invalid error message');
|
|
158
|
+
}
|
|
159
|
+
if (m.kind === 'credit' && (!isInt(m.count) || m.count < 1 || m.count > limits.maxCredit)) bad('invalid credit count');
|
|
160
|
+
if ((m.kind === 'cancel' || m.kind === 'bye') && m.reason !== undefined && m.reason !== null &&
|
|
161
|
+
(typeof m.reason !== 'string' || m.reason.length > 256)) bad('invalid reason');
|
|
162
|
+
checkJson(m, limits.maxDepth);
|
|
163
|
+
if (encoder.encode(JSON.stringify(m)).length > limits.maxMessageBytes) bad('message too large');
|
|
164
|
+
return m;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function randomId(prefix) {
|
|
168
|
+
const bytes = new Uint8Array(12);
|
|
169
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
170
|
+
return prefix + Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Resolves when promise settles or after ms, whichever comes first (never rejects). */
|
|
174
|
+
function settledWithin(promise, ms) {
|
|
175
|
+
let timer;
|
|
176
|
+
const late = new Promise((resolve) => { timer = setTimeout(resolve, ms); });
|
|
177
|
+
return Promise.race([Promise.resolve(promise).catch(() => {}), late]).finally(() => clearTimeout(timer));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function deferred() {
|
|
181
|
+
const d = { settled: false };
|
|
182
|
+
d.promise = new Promise((a, b) => {
|
|
183
|
+
d.resolve = (v) => { d.settled = true; a(v); };
|
|
184
|
+
d.reject = (e) => { d.settled = true; b(e); };
|
|
185
|
+
});
|
|
186
|
+
d.promise.catch(() => {});
|
|
187
|
+
return d;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Cut to at most n UTF-16 units without leaving a lone high surrogate. */
|
|
191
|
+
function truncateU16(text, n) {
|
|
192
|
+
if (text.length <= n) return text;
|
|
193
|
+
const code = text.charCodeAt(n - 1);
|
|
194
|
+
return text.slice(0, code >= 0xd800 && code <= 0xdbff ? n - 1 : n);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function errorPayload(err) {
|
|
198
|
+
if (err instanceof RpcError && CODE_RE.test(err.code)) {
|
|
199
|
+
const out = { code: err.code, message: truncateU16(String(err.message), 4096) };
|
|
200
|
+
if (err.details !== undefined) {
|
|
201
|
+
try { checkJson(err.details, 16); out.details = err.details; } catch { /* drop */ }
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
if (err && err.name === 'AbortError') return { code: 'CANCELLED', message: 'cancelled' };
|
|
206
|
+
return { code: 'INTERNAL_ERROR', message: 'internal error' };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Talks to a Python backend extension over the official Neutralino client.
|
|
211
|
+
*
|
|
212
|
+
* const backend = new PythonBackend('org.example.backend');
|
|
213
|
+
* await backend.ready();
|
|
214
|
+
* const users = await backend.invoke('get_users', { department: 'IT' });
|
|
215
|
+
*/
|
|
216
|
+
export class PythonBackend {
|
|
217
|
+
constructor(extensionId, options = {}) {
|
|
218
|
+
if (!isPlainObject(options)) throw new TypeError('options must be a plain object');
|
|
219
|
+
for (const k of Object.keys(options)) if (!OPTION_KEYS.has(k)) throw new TypeError(`unknown option ${k}`);
|
|
220
|
+
const { neutralino = globalThis.Neutralino, timeoutMs = 30000, limits } = options;
|
|
221
|
+
if (typeof extensionId !== 'string' || !ID_RE.test(extensionId)) throw new RpcError('INVALID_PARAMS', 'invalid extension id');
|
|
222
|
+
if (!neutralino || !neutralino.events || !neutralino.extensions) throw new RpcError('INVALID_PARAMS', 'Neutralino client not available');
|
|
223
|
+
this.backendId = extensionId;
|
|
224
|
+
this.peerId = randomId('p-');
|
|
225
|
+
this.timeoutMs = checkNumber('timeoutMs', timeoutMs, 'number', MAX_TIMER_MS);
|
|
226
|
+
this.limits = resolveLimits(limits);
|
|
227
|
+
this._n = neutralino;
|
|
228
|
+
// One accepted handshake: { session, generation, recent }. Everything done for
|
|
229
|
+
// a served or outgoing call captures it and is dropped once it is replaced.
|
|
230
|
+
this._conn = null;
|
|
231
|
+
this._helloId = null;
|
|
232
|
+
this._subscribed = false;
|
|
233
|
+
this._pending = new Map();
|
|
234
|
+
this._handlers = new Map();
|
|
235
|
+
this._active = new Map();
|
|
236
|
+
// Page handlers still running (current calls and ones released by cancel,
|
|
237
|
+
// reset or dispose that ignore their signal): admission counts them all.
|
|
238
|
+
this._running = new Set();
|
|
239
|
+
this._disposed = false;
|
|
240
|
+
this._readyWaiter = deferred();
|
|
241
|
+
this._disposedWaiter = deferred();
|
|
242
|
+
this._listeners = [];
|
|
243
|
+
this._userListeners = [];
|
|
244
|
+
this._onMessage = (e) => { this._receive(e && e.detail); };
|
|
245
|
+
this._onExtConnect = (e) => { if (e && e.detail === this.backendId && !this._session) this._handshake(); };
|
|
246
|
+
this._onExtDisconnect = (e) => { if (e && e.detail === this.backendId) this._reset('DISCONNECTED'); };
|
|
247
|
+
this._onOffline = () => this.dispose();
|
|
248
|
+
this._onPageHide = () => this.dispose();
|
|
249
|
+
this._started = this._start();
|
|
250
|
+
this._started.catch(() => {});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async _start() {
|
|
254
|
+
// dispose() may run while this is suspended (e.g. React StrictMode mounts and
|
|
255
|
+
// unmounts at once): check after every await and undo what was added.
|
|
256
|
+
const subscribe = (async () => {
|
|
257
|
+
for (const [name, fn] of [[RPC_EVENT, this._onMessage], ['extClientConnect', this._onExtConnect],
|
|
258
|
+
['extClientDisconnect', this._onExtDisconnect], ['serverOffline', this._onOffline]]) {
|
|
259
|
+
if (this._disposed) return;
|
|
260
|
+
await this._listen(name, fn);
|
|
261
|
+
}
|
|
262
|
+
})();
|
|
263
|
+
// An events.on() that never settles must not leave ready() pending forever:
|
|
264
|
+
// it rejects at the handshake deadline; a late registration still connects.
|
|
265
|
+
let outcome = null;
|
|
266
|
+
await settledWithin(subscribe.then(() => { outcome = 'ok'; }, () => { outcome = 'failed'; }), this.timeoutMs);
|
|
267
|
+
if (outcome !== 'ok' && !this._disposed && !this._readyWaiter.settled) {
|
|
268
|
+
this._readyWaiter.reject(outcome === 'failed'
|
|
269
|
+
? new RpcError('INTERNAL_ERROR', 'could not subscribe to Neutralino events')
|
|
270
|
+
: new RpcError('TIMEOUT', 'Neutralino events.on() did not complete'));
|
|
271
|
+
}
|
|
272
|
+
await subscribe;
|
|
273
|
+
if (this._disposed) return;
|
|
274
|
+
this._subscribed = true;
|
|
275
|
+
globalThis.addEventListener?.('pagehide', this._onPageHide);
|
|
276
|
+
this._handshake();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async _listen(name, fn) {
|
|
280
|
+
await this._n.events.on(name, fn);
|
|
281
|
+
if (this._disposed) Promise.resolve(this._n.events.off(name, fn)).catch(() => {});
|
|
282
|
+
else this._listeners.push([name, fn]);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async _handshake() {
|
|
286
|
+
if (this._disposed || this._handshaking || !this._subscribed) return;
|
|
287
|
+
this._handshaking = true;
|
|
288
|
+
// A previous handshake may have timed out (rejected waiter): start fresh so a
|
|
289
|
+
// backend that comes up later still makes ready() and calls work.
|
|
290
|
+
if (this._readyWaiter.settled && !this._session) this._readyWaiter = deferred();
|
|
291
|
+
const helloId = randomId('h-');
|
|
292
|
+
this._helloId = helloId;
|
|
293
|
+
const deadline = Date.now() + this.timeoutMs;
|
|
294
|
+
try {
|
|
295
|
+
while (!this._disposed && !this._session && this._helloId === helloId) {
|
|
296
|
+
// Neither getStats() nor dispatch() is awaited past the retry interval:
|
|
297
|
+
// either can stay pending (a queued dispatch, an unanswered native call).
|
|
298
|
+
let connected = false;
|
|
299
|
+
const stats = Promise.resolve().then(() => this._n.extensions.getStats());
|
|
300
|
+
await settledWithin(stats.then((st) => {
|
|
301
|
+
connected = Array.isArray(st?.connected) && st.connected.includes(this.backendId);
|
|
302
|
+
}), this.limits.handshakeRetryMs);
|
|
303
|
+
if (connected && !this._disposed && !this._session && this._helloId === helloId) {
|
|
304
|
+
const hello = { v: 1, kind: 'hello', session: null, from: this.peerId, to: this.backendId,
|
|
305
|
+
id: helloId, capabilities: CAPABILITIES };
|
|
306
|
+
let sent;
|
|
307
|
+
try { sent = this._n.extensions.dispatch(this.backendId, RPC_EVENT, hello); } catch { /* retry */ }
|
|
308
|
+
await settledWithin(sent, this.limits.handshakeRetryMs);
|
|
309
|
+
}
|
|
310
|
+
if (Date.now() > deadline) {
|
|
311
|
+
this._readyWaiter.reject(new RpcError('TIMEOUT', 'backend did not answer the handshake'));
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
await new Promise((r) => setTimeout(r, this.limits.handshakeRetryMs));
|
|
315
|
+
}
|
|
316
|
+
} finally {
|
|
317
|
+
this._handshaking = false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Resolves once the backend accepted this page (welcome received). */
|
|
322
|
+
ready() {
|
|
323
|
+
return this._readyWaiter.promise;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
get session() { return this._session; }
|
|
327
|
+
|
|
328
|
+
get _session() { return this._conn ? this._conn.session : null; }
|
|
329
|
+
|
|
330
|
+
get _generation() { return this._conn ? this._conn.generation : null; }
|
|
331
|
+
|
|
332
|
+
_reset(code) {
|
|
333
|
+
for (const p of this._pending.values()) this._fail(p, new RpcError(code, 'backend disconnected'));
|
|
334
|
+
this._pending.clear();
|
|
335
|
+
const active = this._active;
|
|
336
|
+
this._active = new Map();
|
|
337
|
+
this._conn = null;
|
|
338
|
+
for (const c of active.values()) c.abort();
|
|
339
|
+
if (!this._disposed) {
|
|
340
|
+
if (this._readyWaiter.settled) this._readyWaiter = deferred();
|
|
341
|
+
this._handshake();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Validate and dispatch one message. The returned promise follows the
|
|
347
|
+
* official dispatch(), which may never settle: callers race it against their
|
|
348
|
+
* own settlement (deadline, signal, dispose, terminal) or do not await it.
|
|
349
|
+
*/
|
|
350
|
+
async _send(kind, id, fields = {}, conn = this._conn) {
|
|
351
|
+
if (this._disposed) throw new RpcError('DISCONNECTED', 'disposed');
|
|
352
|
+
if (!conn) throw new RpcError('DISCONNECTED', 'not connected to the backend');
|
|
353
|
+
// Work of an earlier handshake never reaches the current one (its ids may be reused).
|
|
354
|
+
if (conn !== this._conn) throw new RpcError('DISCONNECTED', 'session replaced');
|
|
355
|
+
const m = { v: 1, kind, session: conn.session, generation: conn.generation,
|
|
356
|
+
from: this.peerId, to: this.backendId, id, ...fields };
|
|
357
|
+
validateMessage(m, this.limits);
|
|
358
|
+
await this._n.extensions.dispatch(this.backendId, RPC_EVENT, m);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
_receive(m) {
|
|
362
|
+
if (this._disposed) return;
|
|
363
|
+
try { validateMessage(m, this.limits); } catch { return; }
|
|
364
|
+
if (m.to !== this.peerId || m.from !== this.backendId) return;
|
|
365
|
+
if (m.kind === 'welcome') {
|
|
366
|
+
if (m.id === this._helloId && !this._session) {
|
|
367
|
+
// The replay cache of served ids is per generation.
|
|
368
|
+
this._conn = { session: m.session, generation: m.generation, recent: new Map() };
|
|
369
|
+
if (this._readyWaiter.settled) this._readyWaiter = deferred();
|
|
370
|
+
this._readyWaiter.resolve();
|
|
371
|
+
}
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (m.kind === 'bye') {
|
|
375
|
+
// A stale "unknown session" bye (about an old generation) must not tear down
|
|
376
|
+
// a fresh session.
|
|
377
|
+
const current = m.session === this._session && m.generation === this._generation;
|
|
378
|
+
const stale = m.reason === 'unknown session' && (!this._session || m.generation === this._generation);
|
|
379
|
+
if (current || stale) this._reset('DISCONNECTED');
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (!this._session || m.session !== this._session || m.generation !== this._generation) return;
|
|
383
|
+
const p = this._pending.get(m.id);
|
|
384
|
+
switch (m.kind) {
|
|
385
|
+
case 'result': case 'error': return this._terminal(p, m);
|
|
386
|
+
case 'chunk': return this._chunk(p, m);
|
|
387
|
+
case 'progress':
|
|
388
|
+
// Advisory and coalesced (like the Python consumer): a gap is tolerated,
|
|
389
|
+
// stale or duplicate sequence numbers are dropped.
|
|
390
|
+
if (p && !p.terminal && m.seq >= p.progressSeq) {
|
|
391
|
+
p.progressSeq = m.seq + 1;
|
|
392
|
+
try { p.onProgress?.(m.value); } catch { /* user callback */ }
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
case 'credit': {
|
|
396
|
+
const a = this._active.get(m.id);
|
|
397
|
+
if (a && a.stream) { a.credit = Math.min(this.limits.maxCredit, a.credit + m.count); a.wake?.(); }
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
case 'cancel': this._active.get(m.id)?.abort(); return;
|
|
401
|
+
case 'request': case 'notify': case 'discover': this._serve(m); return;
|
|
402
|
+
default: return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
_terminal(p, m) {
|
|
407
|
+
if (!p || p.terminal) return;
|
|
408
|
+
p.terminal = true;
|
|
409
|
+
if (m.kind === 'result') { p.result = m.value; p.done.resolve(m.value); }
|
|
410
|
+
else {
|
|
411
|
+
// A stream iterator reads p.error; a plain call only awaits p.done.
|
|
412
|
+
p.error = new RpcError(m.error.code, m.error.message, m.error.details);
|
|
413
|
+
p.done.reject(p.error);
|
|
414
|
+
}
|
|
415
|
+
p.wake?.();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
_chunk(p, m) {
|
|
419
|
+
if (!p || p.terminal) return;
|
|
420
|
+
if (!p.stream || m.seq !== p.seq) {
|
|
421
|
+
this._fail(p, new RpcError('PROTOCOL_ERROR', 'chunk sequence violated'));
|
|
422
|
+
this._send('cancel', p.id, { reason: 'protocol error' }, p.conn).catch(() => {});
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (p.queue.length >= this.limits.maxCredit) {
|
|
426
|
+
this._fail(p, new RpcError('STREAM_OVERFLOW', 'backend ignored credit'));
|
|
427
|
+
this._send('cancel', p.id, { reason: 'overflow' }, p.conn).catch(() => {});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
p.seq += 1;
|
|
431
|
+
p.queue.push(m.value);
|
|
432
|
+
p.wake?.();
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
_fail(p, err) {
|
|
436
|
+
if (!p || p.terminal) return;
|
|
437
|
+
p.terminal = true;
|
|
438
|
+
p.error = err;
|
|
439
|
+
p.done.reject(err);
|
|
440
|
+
p.wake?.();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Wait for the handshake within this call's own budget: its timeoutMs and
|
|
445
|
+
* AbortSignal apply from the start, not only after the backend answered. A
|
|
446
|
+
* handshake that timed out earlier is retried.
|
|
447
|
+
*/
|
|
448
|
+
async _awaitReady(options, ms) {
|
|
449
|
+
if (this._disposed) throw new RpcError('DISCONNECTED', 'disposed');
|
|
450
|
+
if (options.signal?.aborted) throw new RpcError('CANCELLED', 'aborted');
|
|
451
|
+
if (this._session) return;
|
|
452
|
+
if (this._readyWaiter.settled && !this._handshaking) this._handshake();
|
|
453
|
+
await new Promise((resolve, reject) => {
|
|
454
|
+
const done = (fn, v) => {
|
|
455
|
+
clearTimeout(timer);
|
|
456
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
457
|
+
fn(v);
|
|
458
|
+
};
|
|
459
|
+
const onAbort = () => done(reject, new RpcError('CANCELLED', 'aborted'));
|
|
460
|
+
const timer = setTimeout(() => done(reject, new RpcError('TIMEOUT', 'backend not ready in time')), ms);
|
|
461
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
462
|
+
this.ready().then(() => done(resolve), (e) => done(reject, e));
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async _newPending(stream, options = {}, readyMs = this.timeoutMs) {
|
|
467
|
+
await this._awaitReady(options, readyMs);
|
|
468
|
+
if (this._pending.size >= this.limits.maxPending) throw new RpcError('BUSY', 'too many pending calls');
|
|
469
|
+
if (options.signal?.aborted) throw new RpcError('CANCELLED', 'aborted');
|
|
470
|
+
const p = { id: randomId('c-'), stream, done: deferred(), queue: [], seq: 0, progressSeq: 0,
|
|
471
|
+
terminal: false, error: null, result: undefined, onProgress: options.onProgress, wake: null };
|
|
472
|
+
p.conn = this._conn;
|
|
473
|
+
p.abort = () => { this._fail(p, new RpcError('CANCELLED', 'aborted')); this._cancel(p.id, p.conn); };
|
|
474
|
+
options.signal?.addEventListener('abort', p.abort, { once: true });
|
|
475
|
+
p.signal = options.signal;
|
|
476
|
+
this._pending.set(p.id, p);
|
|
477
|
+
return p;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
_cleanup(p) {
|
|
481
|
+
p.signal?.removeEventListener('abort', p.abort);
|
|
482
|
+
this._pending.delete(p.id);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
_deadline(p, ms) {
|
|
486
|
+
return setTimeout(() => {
|
|
487
|
+
if (!p.terminal) { this._fail(p, new RpcError('TIMEOUT', 'call timed out')); this._cancel(p.id, p.conn); }
|
|
488
|
+
}, ms);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/** Per-call timeoutMs (validated like the constructor's) or the default. */
|
|
492
|
+
_callMs(options) {
|
|
493
|
+
return options.timeoutMs === undefined ? this.timeoutMs
|
|
494
|
+
: checkNumber('timeoutMs', options.timeoutMs, 'number', MAX_TIMER_MS);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** Call a Python function registered with app.expose / ext.expose. */
|
|
498
|
+
async invoke(name, params = null, options = {}) {
|
|
499
|
+
if (typeof name !== 'string' || !NAME_RE.test(name)) throw new RpcError('INVALID_PARAMS', 'invalid method name');
|
|
500
|
+
if (params !== null && params !== undefined && !isPlainObject(params)) throw new RpcError('INVALID_PARAMS', 'params must be an object');
|
|
501
|
+
const ms = this._callMs(options);
|
|
502
|
+
const started = Date.now();
|
|
503
|
+
const p = await this._newPending(false, options, ms);
|
|
504
|
+
const timer = this._deadline(p, Math.max(0, ms - (Date.now() - started)));
|
|
505
|
+
try {
|
|
506
|
+
await this._sendFor(p, 'request', { method: name, params: params ?? null, stream: false });
|
|
507
|
+
return await p.done.promise;
|
|
508
|
+
} finally { clearTimeout(timer); this._cleanup(p); }
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Send for pending call p without waiting on dispatch() past p's own
|
|
513
|
+
* settlement (result, error, deadline, abort, disconnect, dispose). A
|
|
514
|
+
* validation or dispatch failure still rejects.
|
|
515
|
+
*/
|
|
516
|
+
async _sendFor(p, kind, fields) {
|
|
517
|
+
const sent = this._send(kind, p.id, fields, p.conn);
|
|
518
|
+
sent.catch(() => {});
|
|
519
|
+
await Promise.race([sent, p.done.promise]);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Consume a Python stream. Returns an AsyncIterable; after iteration ends,
|
|
524
|
+
* `await iterable.result` gives the terminal metadata (or null).
|
|
525
|
+
*/
|
|
526
|
+
stream(name, params = null, options = {}) {
|
|
527
|
+
if (typeof name !== 'string' || !NAME_RE.test(name)) throw new RpcError('INVALID_PARAMS', 'invalid method name');
|
|
528
|
+
const self = this;
|
|
529
|
+
const timeoutMs = options.timeoutMs === undefined ? undefined : this._callMs(options);
|
|
530
|
+
const window = options.credit === undefined ? this.limits.initialCredit
|
|
531
|
+
: checkNumber('credit', options.credit, 'int', this.limits.maxCredit);
|
|
532
|
+
const resultWaiter = deferred();
|
|
533
|
+
const iterable = {
|
|
534
|
+
id: null,
|
|
535
|
+
result: resultWaiter.promise,
|
|
536
|
+
async *[Symbol.asyncIterator]() {
|
|
537
|
+
const idle = timeoutMs ?? self.limits.streamIdleMs;
|
|
538
|
+
let p = null;
|
|
539
|
+
try {
|
|
540
|
+
p = await self._newPending(true, options, timeoutMs ?? self.timeoutMs);
|
|
541
|
+
iterable.id = p.id;
|
|
542
|
+
// Credits are granted in batches of half the window: fewer messages,
|
|
543
|
+
// same bound on items in flight.
|
|
544
|
+
const batch = Math.max(1, Math.floor(window / 2));
|
|
545
|
+
let consumed = 0;
|
|
546
|
+
// Not awaited: the idle timer below bounds the wait for the first item
|
|
547
|
+
// even if dispatch() never settles; a failed send fails the stream.
|
|
548
|
+
const failOnError = (e) => { if (!p.terminal) { self._fail(p, e); self._cancel(p.id, p.conn); } };
|
|
549
|
+
self._send('request', p.id, { method: name, params: params ?? null, stream: true,
|
|
550
|
+
credit: window }, p.conn).catch(failOnError);
|
|
551
|
+
while (true) {
|
|
552
|
+
if (p.queue.length) {
|
|
553
|
+
const value = p.queue.shift();
|
|
554
|
+
yield value;
|
|
555
|
+
consumed += 1;
|
|
556
|
+
if (!p.terminal && consumed >= batch) {
|
|
557
|
+
const count = consumed;
|
|
558
|
+
consumed = 0;
|
|
559
|
+
self._send('credit', p.id, { count }, p.conn).catch(failOnError);
|
|
560
|
+
}
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (p.error) throw p.error;
|
|
564
|
+
if (p.terminal) { resultWaiter.resolve(p.result ?? null); return; }
|
|
565
|
+
await new Promise((resolve, reject) => {
|
|
566
|
+
const t = setTimeout(() => reject(new RpcError('TIMEOUT', 'stream idle timeout')), idle);
|
|
567
|
+
p.wake = () => { clearTimeout(t); p.wake = null; resolve(); };
|
|
568
|
+
}).catch((e) => { self._fail(p, e); self._cancel(p.id, p.conn); });
|
|
569
|
+
}
|
|
570
|
+
} catch (e) {
|
|
571
|
+
resultWaiter.reject(e);
|
|
572
|
+
throw e;
|
|
573
|
+
} finally {
|
|
574
|
+
if (p) {
|
|
575
|
+
if (!p.terminal) { p.terminal = true; self._cancel(p.id, p.conn); }
|
|
576
|
+
self._cleanup(p);
|
|
577
|
+
}
|
|
578
|
+
// Left early (break/return): the terminal metadata will never come.
|
|
579
|
+
if (!resultWaiter.settled) resultWaiter.reject(new RpcError('CANCELLED', 'stream not consumed to the end'));
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
};
|
|
583
|
+
return iterable;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Fire-and-forget notification of a registered Python function. Resolves
|
|
588
|
+
* once handed to the runtime; rejects TIMEOUT if that takes longer than
|
|
589
|
+
* timeoutMs (handshake included) and DISCONNECTED on dispose().
|
|
590
|
+
*/
|
|
591
|
+
async emit(name, params = null) {
|
|
592
|
+
if (typeof name !== 'string' || !NAME_RE.test(name)) throw new RpcError('INVALID_PARAMS', 'invalid method name');
|
|
593
|
+
const started = Date.now();
|
|
594
|
+
await this._awaitReady({}, this.timeoutMs);
|
|
595
|
+
const sent = this._send('notify', randomId('n-'), { method: name, params: params ?? null });
|
|
596
|
+
sent.catch(() => {});
|
|
597
|
+
let timer;
|
|
598
|
+
const late = new Promise((_, reject) => {
|
|
599
|
+
timer = setTimeout(() => reject(new RpcError('TIMEOUT', 'notification not delivered in time')),
|
|
600
|
+
Math.max(0, this.timeoutMs - (Date.now() - started)));
|
|
601
|
+
});
|
|
602
|
+
try { await Promise.race([sent, late, this._disposedWaiter.promise]); } finally { clearTimeout(timer); }
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** Metadata of the Python functions the backend exposes. */
|
|
606
|
+
async discover(options = {}) {
|
|
607
|
+
const ms = this._callMs(options);
|
|
608
|
+
const started = Date.now();
|
|
609
|
+
const p = await this._newPending(false, options, ms);
|
|
610
|
+
const timer = this._deadline(p, Math.max(0, ms - (Date.now() - started)));
|
|
611
|
+
try {
|
|
612
|
+
await this._sendFor(p, 'discover', {});
|
|
613
|
+
return await p.done.promise;
|
|
614
|
+
} finally { clearTimeout(timer); this._cleanup(p); }
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** Best-effort cancel of an outgoing call or stream by id. */
|
|
618
|
+
cancel(requestId) {
|
|
619
|
+
this._cancel(requestId, this._conn);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
_cancel(requestId, conn) {
|
|
623
|
+
if (conn && conn === this._conn && !this._disposed) {
|
|
624
|
+
this._send('cancel', requestId, { reason: 'cancelled' }, conn).catch(() => {});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Expose a page function to Python (reverse RPC). handler(params, ctx) gets
|
|
630
|
+
* ctx = { signal, progress(value), peer }. With { stream: true } the handler
|
|
631
|
+
* returns an async iterable. Returns an unregister function.
|
|
632
|
+
*/
|
|
633
|
+
register(name, handler, { stream = false } = {}) {
|
|
634
|
+
if (typeof name !== 'string' || !NAME_RE.test(name)) throw new RpcError('INVALID_PARAMS', 'invalid method name');
|
|
635
|
+
if (typeof handler !== 'function') throw new RpcError('INVALID_PARAMS', 'handler must be a function');
|
|
636
|
+
if (this._handlers.has(name)) throw new RpcError('INVALID_PARAMS', `${name} is already registered`);
|
|
637
|
+
const entry = { handler, stream: Boolean(stream) };
|
|
638
|
+
this._handlers.set(name, entry);
|
|
639
|
+
return () => { if (this._handlers.get(name) === entry) this._handlers.delete(name); };
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
async _serve(m) {
|
|
643
|
+
// Identity of this call: the handshake and the active-call table it was
|
|
644
|
+
// admitted under. A reset or dispose replaces both; whatever this call does
|
|
645
|
+
// afterwards (send, retire its id, record it as served) is then dropped.
|
|
646
|
+
const conn = this._conn;
|
|
647
|
+
const active = this._active;
|
|
648
|
+
const reply = m.kind !== 'notify';
|
|
649
|
+
if (active.has(m.id) || conn.recent.has(m.id)) return;
|
|
650
|
+
if (this._running.size >= this.limits.maxActive) {
|
|
651
|
+
if (reply) this._send('error', m.id, { error: { code: 'BUSY', message: 'too many active calls' } }, conn).catch(() => {});
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const control = new AbortController();
|
|
655
|
+
const state = { stream: m.kind === 'request' && m.stream, credit: m.credit ?? 0, wake: null,
|
|
656
|
+
terminal: false, flushProgress: () => {}, abort: () => control.abort(), outstanding: 0, finished: false };
|
|
657
|
+
active.set(m.id, state);
|
|
658
|
+
this._running.add(state);
|
|
659
|
+
const settle = () => {
|
|
660
|
+
if (state.finished && state.outstanding === 0) this._running.delete(state);
|
|
661
|
+
};
|
|
662
|
+
// Settles with the handler's promise or rejects CANCELLED on abort, whichever
|
|
663
|
+
// comes first: a handler that ignores its signal releases the call at once,
|
|
664
|
+
// and its late settlement is discarded. Until that promise settles the
|
|
665
|
+
// handler still counts toward limits.maxActive (JS cannot stop it).
|
|
666
|
+
const cancelled = new Promise((_, reject) => {
|
|
667
|
+
const onAbort = () => reject(new RpcError('CANCELLED', 'cancelled'));
|
|
668
|
+
if (control.signal.aborted) onAbort();
|
|
669
|
+
else control.signal.addEventListener('abort', onAbort, { once: true });
|
|
670
|
+
});
|
|
671
|
+
cancelled.catch(() => {});
|
|
672
|
+
const untilAborted = (value) => {
|
|
673
|
+
const work = Promise.resolve(value);
|
|
674
|
+
state.outstanding += 1;
|
|
675
|
+
work.then(() => {}, () => {}).then(() => { state.outstanding -= 1; settle(); });
|
|
676
|
+
return Promise.race([work, cancelled]);
|
|
677
|
+
};
|
|
678
|
+
let iterator = null;
|
|
679
|
+
try {
|
|
680
|
+
if (m.kind === 'discover') {
|
|
681
|
+
const value = [...this._handlers].map(([name, e]) => ({ name, stream: e.stream, params: [],
|
|
682
|
+
required: [], schema: null, description: null }));
|
|
683
|
+
await this._sendUntil(control.signal, 'result', m.id, { value }, conn);
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const entry = this._handlers.get(m.method);
|
|
687
|
+
if (!entry) throw new RpcError('METHOD_NOT_FOUND', `no method ${m.method}`);
|
|
688
|
+
if (m.kind === 'request' && entry.stream !== m.stream) throw new RpcError('UNSUPPORTED', 'stream mode mismatch');
|
|
689
|
+
// Progress: validated before it takes a sequence number, rate-limited to
|
|
690
|
+
// limits.progressPerSecond with only the latest value kept (coalesced),
|
|
691
|
+
// and the pending latest value is flushed before the terminal message.
|
|
692
|
+
let progressSeq = 0;
|
|
693
|
+
let lastSent = 0;
|
|
694
|
+
let pendingValue;
|
|
695
|
+
let hasPending = false;
|
|
696
|
+
let timer = null;
|
|
697
|
+
const interval = 1000 / this.limits.progressPerSecond;
|
|
698
|
+
const flushProgress = () => {
|
|
699
|
+
timer = null;
|
|
700
|
+
if (!hasPending || control.signal.aborted || state.terminal) return;
|
|
701
|
+
hasPending = false;
|
|
702
|
+
lastSent = Date.now();
|
|
703
|
+
this._send('progress', m.id, { seq: progressSeq++, value: pendingValue }, conn).catch(() => {});
|
|
704
|
+
};
|
|
705
|
+
state.flushProgress = () => { if (timer) clearTimeout(timer); flushProgress(); };
|
|
706
|
+
const ctx = {
|
|
707
|
+
signal: control.signal,
|
|
708
|
+
peer: this.backendId,
|
|
709
|
+
progress: (value) => {
|
|
710
|
+
if (control.signal.aborted || !reply || state.terminal) return;
|
|
711
|
+
const v = value ?? null;
|
|
712
|
+
try {
|
|
713
|
+
checkJson(v, 8);
|
|
714
|
+
if (encoder.encode(JSON.stringify(v)).length > this.limits.maxChunkBytes) return;
|
|
715
|
+
} catch { return; }
|
|
716
|
+
pendingValue = v;
|
|
717
|
+
hasPending = true;
|
|
718
|
+
const wait = interval - (Date.now() - lastSent);
|
|
719
|
+
if (wait <= 0) flushProgress();
|
|
720
|
+
else if (!timer) timer = setTimeout(flushProgress, wait);
|
|
721
|
+
},
|
|
722
|
+
};
|
|
723
|
+
const out = await untilAborted(entry.handler(m.params ?? {}, ctx));
|
|
724
|
+
if (!reply) return;
|
|
725
|
+
if (state.stream) {
|
|
726
|
+
// Iterated by hand: every next() is raced against abort (for await would
|
|
727
|
+
// wait for a next() or return() that ignores the signal).
|
|
728
|
+
const isAsync = typeof out?.[Symbol.asyncIterator] === 'function';
|
|
729
|
+
if (!isAsync && typeof out?.[Symbol.iterator] !== 'function') throw new TypeError('stream handler did not return an iterable');
|
|
730
|
+
iterator = isAsync ? out[Symbol.asyncIterator]() : out[Symbol.iterator]();
|
|
731
|
+
let seq = 0;
|
|
732
|
+
while (true) {
|
|
733
|
+
const step = await untilAborted(iterator.next());
|
|
734
|
+
if (step.done) { iterator = null; break; }
|
|
735
|
+
const item = isAsync ? step.value : await untilAborted(step.value);
|
|
736
|
+
if (control.signal.aborted) throw new RpcError('CANCELLED', 'cancelled');
|
|
737
|
+
checkJson(item, this.limits.maxDepth);
|
|
738
|
+
if (encoder.encode(JSON.stringify(item)).length > this.limits.maxChunkBytes) throw new RpcError('STREAM_OVERFLOW', 'chunk too large');
|
|
739
|
+
while (state.credit <= 0) {
|
|
740
|
+
await new Promise((resolve, reject) => {
|
|
741
|
+
const onAbort = () => { clearTimeout(t); reject(new RpcError('CANCELLED', 'cancelled')); };
|
|
742
|
+
const t = setTimeout(() => {
|
|
743
|
+
control.signal.removeEventListener('abort', onAbort);
|
|
744
|
+
reject(new RpcError('TIMEOUT', 'no credit'));
|
|
745
|
+
}, this.limits.streamIdleMs);
|
|
746
|
+
state.wake = () => {
|
|
747
|
+
clearTimeout(t);
|
|
748
|
+
control.signal.removeEventListener('abort', onAbort);
|
|
749
|
+
state.wake = null;
|
|
750
|
+
resolve();
|
|
751
|
+
};
|
|
752
|
+
control.signal.addEventListener('abort', onAbort, { once: true });
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
state.credit -= 1;
|
|
756
|
+
await this._sendUntil(control.signal, 'chunk', m.id, { seq: seq++, value: item }, conn);
|
|
757
|
+
}
|
|
758
|
+
state.flushProgress();
|
|
759
|
+
state.terminal = true;
|
|
760
|
+
await this._sendUntil(control.signal, 'result', m.id, { value: null }, conn);
|
|
761
|
+
} else {
|
|
762
|
+
if (control.signal.aborted) throw new RpcError('CANCELLED', 'cancelled');
|
|
763
|
+
const value = out === undefined ? null : out;
|
|
764
|
+
checkJson(value, this.limits.maxDepth);
|
|
765
|
+
state.flushProgress();
|
|
766
|
+
state.terminal = true;
|
|
767
|
+
await this._sendUntil(control.signal, 'result', m.id, { value }, conn);
|
|
768
|
+
}
|
|
769
|
+
} catch (err) {
|
|
770
|
+
state.flushProgress?.();
|
|
771
|
+
state.terminal = true;
|
|
772
|
+
if (reply) this._send('error', m.id, { error: errorPayload(err) }, conn).catch(() => {});
|
|
773
|
+
} finally {
|
|
774
|
+
// Left early: ask the producer to finish, without waiting for it.
|
|
775
|
+
if (iterator) { try { Promise.resolve(iterator.return?.()).catch(() => {}); } catch { /* producer */ } }
|
|
776
|
+
if (active.get(m.id) === state) active.delete(m.id);
|
|
777
|
+
conn.recent.set(m.id, Date.now());
|
|
778
|
+
while (conn.recent.size > 1024) conn.recent.delete(conn.recent.keys().next().value);
|
|
779
|
+
state.finished = true;
|
|
780
|
+
settle();
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* _send for a served call: stop waiting on dispatch() once the call is
|
|
786
|
+
* aborted (the caller's own abort checks then apply; a terminal that was
|
|
787
|
+
* already handed over is not followed by a second one). Validation and
|
|
788
|
+
* dispatch failures still reject.
|
|
789
|
+
*/
|
|
790
|
+
async _sendUntil(signal, kind, id, fields, conn) {
|
|
791
|
+
const sent = this._send(kind, id, fields, conn);
|
|
792
|
+
sent.catch(() => {});
|
|
793
|
+
let onAbort;
|
|
794
|
+
const aborted = new Promise((resolve) => {
|
|
795
|
+
onAbort = resolve;
|
|
796
|
+
if (signal.aborted) resolve();
|
|
797
|
+
else signal.addEventListener('abort', onAbort, { once: true });
|
|
798
|
+
});
|
|
799
|
+
try { await Promise.race([sent, aborted]); } finally { signal.removeEventListener('abort', onAbort); }
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Subscribe to any Neutralino event; returns an unsubscribe function.
|
|
804
|
+
* dispose() removes every subscription made here.
|
|
805
|
+
*/
|
|
806
|
+
on(name, handler) {
|
|
807
|
+
if (this._disposed) throw new RpcError('DISCONNECTED', 'disposed');
|
|
808
|
+
let registered;
|
|
809
|
+
try { registered = Promise.resolve(this._n.events.on(name, handler)); } catch (e) { registered = Promise.reject(e); }
|
|
810
|
+
this._userListeners.push([name, handler, registered.catch(() => {})]);
|
|
811
|
+
return () => this.off(name, handler);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
off(name, handler) {
|
|
815
|
+
const i = this._userListeners.findIndex(([n, h]) => n === name && h === handler);
|
|
816
|
+
const registered = i >= 0 ? this._userListeners.splice(i, 1)[0][2] : undefined;
|
|
817
|
+
this._unlisten(name, handler, registered);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* events.off() now, and again once a still-pending events.on() settled: an
|
|
822
|
+
* adapter may register asynchronously, after an immediate off() found nothing.
|
|
823
|
+
*/
|
|
824
|
+
_unlisten(name, fn, registered) {
|
|
825
|
+
const off = () => { try { Promise.resolve(this._n.events.off(name, fn)).catch(() => {}); } catch { /* adapter */ } };
|
|
826
|
+
off();
|
|
827
|
+
registered?.then(off);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** Stop listening, fail pending calls, abort served calls. Idempotent. */
|
|
831
|
+
dispose() {
|
|
832
|
+
if (this._disposed) return;
|
|
833
|
+
if (this._session) {
|
|
834
|
+
const bye = { v: 1, kind: 'bye', session: this._session, generation: this._generation,
|
|
835
|
+
from: this.peerId, to: this.backendId, id: randomId('b-'), reason: 'page closed' };
|
|
836
|
+
Promise.resolve(this._n.extensions.dispatch(this.backendId, RPC_EVENT, bye)).catch(() => {});
|
|
837
|
+
}
|
|
838
|
+
this._disposed = true;
|
|
839
|
+
globalThis.removeEventListener?.('pagehide', this._onPageHide);
|
|
840
|
+
for (const [name, fn, registered] of [...this._listeners, ...this._userListeners]) {
|
|
841
|
+
this._unlisten(name, fn, registered);
|
|
842
|
+
}
|
|
843
|
+
this._listeners = [];
|
|
844
|
+
this._userListeners = [];
|
|
845
|
+
for (const p of this._pending.values()) this._fail(p, new RpcError('DISCONNECTED', 'disposed'));
|
|
846
|
+
this._pending.clear();
|
|
847
|
+
const active = this._active;
|
|
848
|
+
this._active = new Map();
|
|
849
|
+
for (const a of active.values()) a.abort();
|
|
850
|
+
this._handlers.clear();
|
|
851
|
+
this._readyWaiter.reject(new RpcError('DISCONNECTED', 'disposed'));
|
|
852
|
+
this._disposedWaiter.reject(new RpcError('DISCONNECTED', 'disposed'));
|
|
853
|
+
}
|
|
854
|
+
}
|