neutralino-python 0.1.0rc1__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-C2NUKJAE.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DHnOKa8c.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-CLVygP7p.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CXJaU0yv.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-DX0MbxKq.js +2 -0
- neutralino/_data/renderer/assets/css-BotC7byr.js +1 -0
- neutralino/_data/renderer/assets/dist-3kB5bJpS.js +23 -0
- neutralino/_data/renderer/assets/dist-6zrr4MrK.js +1 -0
- neutralino/_data/renderer/assets/dist-Beotrn8G.js +1 -0
- neutralino/_data/renderer/assets/dist-CCJHv8n0.js +11 -0
- neutralino/_data/renderer/assets/dist-CdYA9or5.js +1 -0
- neutralino/_data/renderer/assets/dist-D2p_6o_g.js +1 -0
- neutralino/_data/renderer/assets/dnd-DkNumIKC.js +5 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/dropzone-agrigkXv.js +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-_ztrE73N.js +1 -0
- neutralino/_data/renderer/assets/emoji-Cj3VQHg8.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-DbOmMyz5.js +82 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/highlight-LH6Cyuz6.js +3 -0
- neutralino/_data/renderer/assets/html-CpATC083.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-C-4QDF6w.js +1 -0
- neutralino/_data/renderer/assets/index-CqHW60Dy.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-D2QSKlDI.js +1 -0
- neutralino/_data/renderer/assets/json-D8zfYii3.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BijRfmPy.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-Cpthnhzg.js +77 -0
- neutralino/_data/renderer/assets/markdown-CsS2tf5C.js +5 -0
- neutralino/_data/renderer/assets/python-B477ud9A.js +9 -0
- neutralino/_data/renderer/assets/richtext-BwtgvH7-.js +137 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Db1pwUWd.js +1 -0
- neutralino/_data/renderer/assets/sql-DbpHRl6F.js +2 -0
- neutralino/_data/renderer/assets/with-selector-CUfuSYau.js +1 -0
- neutralino/_data/renderer/assets/yaml-BPsr1O3S.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 +1261 -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.0rc1.dist-info/METADATA +117 -0
- neutralino_python-0.1.0rc1.dist-info/RECORD +521 -0
- neutralino_python-0.1.0rc1.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0rc1.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: neutralino-app-patterns
|
|
3
|
+
description: Proven application patterns for neutralino-python apps - paged data tables, CRUD with forms, dashboards with live updates, background and long tasks, scheduled jobs, persistence and settings, multi-window state. Use it when building a real app screen and you want the tested shape and a runnable example to start from.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# neutralino-app-patterns
|
|
7
|
+
|
|
8
|
+
Every pattern below exists as a tested example. Prefer exporting and adapting one to writing from
|
|
9
|
+
scratch.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
neutralino examples list
|
|
13
|
+
neutralino examples export <name> ./my-app # copies the folder; never overwrites without --force
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Names such as `settings`, `crud`, `file-manager`, `monitor`, `editor`, `dashboard`, `hybrid`, `react`,
|
|
17
|
+
`vanilla`, `updater` are the packaged examples of this version family; `examples list` is the
|
|
18
|
+
authority for the installed version. Paths written `examples/patterns/*.py`, `examples/native/*.py`,
|
|
19
|
+
`examples/workspace/<name>/app.py` and `examples/monitor` below are in the framework's source repository
|
|
20
|
+
only (the wheel does not ship them); with only the wheel, use the packaged example named next to them or the
|
|
21
|
+
snippet shown here.
|
|
22
|
+
|
|
23
|
+
## Choose the pattern
|
|
24
|
+
|
|
25
|
+
| Screen | Pattern | Example (repository path) |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| Thousands of rows, search, sort, edit, delete | `ui.DataTable(provider=...)` with a Python paging function | `examples/patterns/sqlite.py`, `dynamic_table.py` |
|
|
28
|
+
| Add/edit record | `ui.Form` + validators; table `refresh()` after a write | `examples/workspace/customers/app.py`, `orders`, `tasks` |
|
|
29
|
+
| Settings | validated form or `ui.blocks.SettingsPanel`; atomic JSON | the packaged `settings` example, `patterns/settings_page.py`, `persistence.py` |
|
|
30
|
+
| Dashboard | `ui.blocks.StatsGrid`, charts, period filter; Python computes every number | the packaged `dashboard` example, `patterns/dynamic_dashboard.py` |
|
|
31
|
+
| Long task with cancel | worker thread + `ctx.progress`, or an async task + `ui.Progress` | `patterns/long_tasks.py`, `streaming.py` |
|
|
32
|
+
| Python pushes updates | `ui.State.bind` plus `app.events.broadcast` from an asyncio task | `patterns/python_push.py` |
|
|
33
|
+
| Recurring jobs | one asyncio scheduler, per-job outcome | `patterns/scheduled_jobs.py` |
|
|
34
|
+
| Several windows | Python owns the state, pushes to every window | `patterns/multi_window_sync.py` |
|
|
35
|
+
| Optimistic UI | change first, ask Python, roll back on failure | `patterns/optimistic_updates.py` |
|
|
36
|
+
| Files and folders | native dialogs or file-drop with checked paths | the packaged `file-manager` example, `patterns/file_drop.py` |
|
|
37
|
+
|
|
38
|
+
## Minimal paged table with a provider
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from neutralino import ui
|
|
42
|
+
|
|
43
|
+
ROWS = [{"id": i, "name": f"Item {i}", "qty": i % 7} for i in range(1, 5001)]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def page(q: ui.TableQuery) -> ui.TablePage:
|
|
47
|
+
rows = [r for r in ROWS if not q.search or q.search.lower() in r["name"].lower()]
|
|
48
|
+
if q.sort in ("id", "name", "qty"): # whitelist: never put q.sort into SQL or getattr
|
|
49
|
+
rows.sort(key=lambda r: r[q.sort], reverse=q.direction == "desc")
|
|
50
|
+
limit = max(1, min(q.limit, 200))
|
|
51
|
+
return ui.TablePage(rows=rows[q.offset : q.offset + limit], total=len(rows))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
app = ui.Application(title="Items", profile="restricted")
|
|
55
|
+
with app.page("/"):
|
|
56
|
+
columns = [
|
|
57
|
+
ui.Column("id", "ID", kind="number", sortable=True),
|
|
58
|
+
ui.Column("name", "Name", sortable=True),
|
|
59
|
+
ui.Column("qty", "Qty", kind="number", sortable=True),
|
|
60
|
+
]
|
|
61
|
+
table = ui.DataTable(
|
|
62
|
+
columns=[c.to_json() for c in columns], provider=page, page_size=25, searchable=True
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
app.run()
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Adapted from `examples/patterns/sqlite.py` (`Store.page`): only the visible page travels to the window;
|
|
70
|
+
the provider runs in Python and caps `limit`. After a write call `table.refresh()`.
|
|
71
|
+
|
|
72
|
+
## Rules that every pattern follows
|
|
73
|
+
|
|
74
|
+
- **Python owns the data.** The page reflects it. Validate again in Python (submit snapshot, table edit,
|
|
75
|
+
row action); client checks are advisory. Browser `localStorage` is a cache at best.
|
|
76
|
+
- **Persist atomically.** `app.settings` (JSON, atomic write) or `State.persist(app.settings, key,
|
|
77
|
+
decode=...)`; a corrupt file is renamed aside and defaults are used. For a database use the standard
|
|
78
|
+
library (`sqlite3`) behind a lock, one connection per owner; keep the file under `app.paths.data_dir`.
|
|
79
|
+
- **Never block the loop.** Sync handlers already run on worker threads; in async code use
|
|
80
|
+
`asyncio.to_thread` for blocking work. Start background tasks from an async handler so they get the
|
|
81
|
+
running loop; keep a handle, cancel and `gather` it in a `dispose()`.
|
|
82
|
+
- **Bound everything.** Cap page sizes, list lengths, upload sizes; whitelist sort columns and edit fields.
|
|
83
|
+
- **Confirm destructive actions** with `RowAction(confirm="Delete {name}?")` or `ui.current_window().confirm(...)`.
|
|
84
|
+
- **Errors.** Show a short sanitised message in the UI; log the detail. Map error codes in one place
|
|
85
|
+
(`patterns/errors_timeouts.py`). Native errors are `NativeError` with `.code`.
|
|
86
|
+
- **Permissions.** List only the routes the screen uses (`ROUTES` in each `examples/native/*.py`).
|
|
87
|
+
|
|
88
|
+
## Pitfalls
|
|
89
|
+
|
|
90
|
+
- Reading `input.value` in a button handler for a debounced input returns the committed value, not the
|
|
91
|
+
draft; use a `ui.Form` submit (CRUD) or `await input.fetch_value()`.
|
|
92
|
+
- Updating a table by mutating `rows` in place does nothing; assign a new list or call `refresh()`.
|
|
93
|
+
- Row keys must be unique and stable (`row_key`), or selection and row actions hit the wrong row.
|
|
94
|
+
- Scheduling with `sleep(interval)` drifts; compute the next due time from the previous due time.
|
|
95
|
+
- Several windows: component trees are per window; keep shared data in Python (a `ui.State`) and push it to each window.
|
|
96
|
+
|
|
97
|
+
## References
|
|
98
|
+
|
|
99
|
+
- [references/tables-and-crud.md](references/tables-and-crud.md): provider contract, columns, row actions, edit flow, forms.
|
|
100
|
+
- [references/dashboards-and-background-work.md](references/dashboards-and-background-work.md): stats, charts, live updates, tasks, schedulers, multi-window.
|
|
101
|
+
- [references/storage-and-settings.md](references/storage-and-settings.md): settings file, `State.persist`, native storage, app directories, SQLite.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Dashboards and background work
|
|
2
|
+
|
|
3
|
+
## Dashboards
|
|
4
|
+
|
|
5
|
+
- Python computes every number; the page only formats it. the packaged `dashboard` example aggregates
|
|
6
|
+
the chosen period, compares it with the previous period of equal length and returns series, splits and
|
|
7
|
+
top rows.
|
|
8
|
+
- Building blocks: `ui.blocks.StatsGrid([ui.blocks.StatItem(key, label, value, delta=...)], cols=3)`,
|
|
9
|
+
`ui.LineChart`/`BarChart`/`DonutChart` (`data`, `data_key`, `series`), `ui.DataTable`, `ui.blocks.DashboardGrid`,
|
|
10
|
+
`ui.blocks.InfoCard`. Update by assigning new data (`chart.update(data=new_rows)`), batch several updates with
|
|
11
|
+
`with app.batch():` so the page gets one patch.
|
|
12
|
+
- Schema-driven dashboards (widgets as validated data): `examples/patterns/dynamic_dashboard.py`.
|
|
13
|
+
- A period filter is a `ui.SegmentedControl` or `ui.blocks.FilterPanel`; recompute in its handler.
|
|
14
|
+
|
|
15
|
+
## Background work in a UI app
|
|
16
|
+
|
|
17
|
+
| Work | Where it runs |
|
|
18
|
+
|---|---|
|
|
19
|
+
| Blocking CPU or I/O | sync handler (worker thread) or `asyncio.to_thread` |
|
|
20
|
+
| Long task with progress/cancel | worker thread polling a cancel flag, reporting to a `ui.Progress`; `ui.current_window().notify(...)` at the end (`patterns/long_tasks.py`) |
|
|
21
|
+
| Periodic push | asyncio task started from an async handler; `State.set(...)` patches bound components; keep the task and cancel it in `dispose()` (`patterns/python_push.py`) |
|
|
22
|
+
| Native events to pages | `await app.events.broadcast("reading", {...})`; add `events.broadcast` to the allow list |
|
|
23
|
+
| Recurring jobs | one scheduler task, next due time from the previous due time, skip and count missed runs, jobs never overlap themselves (`patterns/scheduled_jobs.py`) |
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import asyncio
|
|
27
|
+
|
|
28
|
+
from neutralino import ui
|
|
29
|
+
|
|
30
|
+
reading: ui.State[int] = ui.State(0)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async def pump(app: ui.AsyncApplication) -> None:
|
|
34
|
+
for n in range(1, 21):
|
|
35
|
+
reading.set(n) # patches every bound component
|
|
36
|
+
await app.events.broadcast("reading", {"n": n}) # needs native route events.broadcast
|
|
37
|
+
await asyncio.sleep(0.05)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Source: `examples/patterns/python_push.py` (also shows `dispose()` and `Window.notify`).
|
|
41
|
+
`ui.AsyncApplication(..., profile="custom", native_allow_list=["events.broadcast"])` is what that example uses.
|
|
42
|
+
|
|
43
|
+
## Several windows
|
|
44
|
+
|
|
45
|
+
`app.window("/route", title=..., width=..., height=...)` opens another window (`Window`); component trees are
|
|
46
|
+
per window. Keep the shared data in Python (a `ui.State` or your own store) and push it to every window
|
|
47
|
+
(`examples/patterns/multi_window_sync.py`, `examples/multi_window`). `ui.current_window()` inside a handler is
|
|
48
|
+
the window that caused it.
|
|
49
|
+
|
|
50
|
+
## Pitfalls
|
|
51
|
+
|
|
52
|
+
- Starting an asyncio task from a sync handler: it has no running loop; make the handler async.
|
|
53
|
+
- Forgetting to cancel the task when the window closes leaves a loop spinning; follow the `dispose()` pattern.
|
|
54
|
+
- Cooperative cancel only: check the flag between steps; a blocking call cannot be interrupted.
|
|
55
|
+
- Progress is advisory and coalesced to 10 per second; do not use it as a log.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Storage and settings
|
|
2
|
+
|
|
3
|
+
## Choose where data lives
|
|
4
|
+
|
|
5
|
+
| Data | Place |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Small preferences | `app.settings` (`ui.Settings`, atomic JSON in `app.paths.config_dir`) |
|
|
8
|
+
| A value kept in sync with a component | `ui.State(...).persist(app.settings, "key", decode=fn)` |
|
|
9
|
+
| Application data (database, documents) | `app.paths.data_dir`, with the standard library (`sqlite3`, `json`) |
|
|
10
|
+
| Caches, logs | `app.paths.cache_dir`, `app.paths.log_dir` |
|
|
11
|
+
| Runtime key-value storage | native `storage.*` (`examples/native/storage.py`; keys 1-50 chars `A-Za-z0-9_-`) |
|
|
12
|
+
| Browser `localStorage` | cache at best; never authoritative |
|
|
13
|
+
|
|
14
|
+
All per-OS paths come from `ui.AppPaths(app_id)`: pass `app_id=` to `ui.Application` so two apps never share
|
|
15
|
+
directories. In a managed install the app's data directory sits beside `versions/` and is never touched by
|
|
16
|
+
installs, updates or rollbacks; data migrations must stay compatible with the previous version or back up
|
|
17
|
+
their data (nothing rolls data back).
|
|
18
|
+
|
|
19
|
+
## Settings file behaviour
|
|
20
|
+
|
|
21
|
+
Every mutation is one atomic write (temp file, fsync, `os.replace`); a failed write leaves file and memory
|
|
22
|
+
unchanged. JSON values only (finite numbers, string keys); keys are non-empty strings up to 256 characters;
|
|
23
|
+
the file is capped at 1 MiB (`ValidationError` beyond). A file that cannot be read is renamed
|
|
24
|
+
`settings.json.corrupt-<time>` and settings start empty. `settings.subscribe(fn)` calls
|
|
25
|
+
`fn(SettingsChange(changed, removed))` on the writing thread after the write.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from neutralino import ui
|
|
29
|
+
|
|
30
|
+
prefs: ui.State[dict] = ui.State({"theme": "light", "volume": 5})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def decode(raw: object) -> dict:
|
|
34
|
+
if not isinstance(raw, dict) or raw.get("theme") not in ("light", "dark"):
|
|
35
|
+
raise ValueError("invalid prefs") # a raising decode ignores the stored value
|
|
36
|
+
return {"theme": raw["theme"], "volume": max(0, min(10, int(raw.get("volume", 5))))}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# after creating the application: prefs.persist(app.settings, "prefs", decode=decode)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Source: `examples/patterns/persistence.py` (also mirrors the value to native storage and restores from it when
|
|
43
|
+
the file is missing, which needs `storage.setData` and `storage.getData` allowed).
|
|
44
|
+
|
|
45
|
+
## SQLite
|
|
46
|
+
|
|
47
|
+
Keep one connection behind a lock (or one per thread), create the schema on start, use parameters for
|
|
48
|
+
values and whitelists for identifiers (`examples/patterns/sqlite.py`). Store the file under
|
|
49
|
+
`app.paths.data_dir`. Close the connection when the app stops. Do not store secrets in settings; they are
|
|
50
|
+
plain JSON (0600 on POSIX).
|
|
51
|
+
|
|
52
|
+
## Settings pages
|
|
53
|
+
|
|
54
|
+
Generate a page from a schema and validate in Python (`examples/patterns/settings_page.py`), or use
|
|
55
|
+
`ui.blocks.SettingsPanel([ui.blocks.SettingSpec(key, label)], value=...)` with `on_change`; the
|
|
56
|
+
the packaged `settings` example example validates every field, shows errors on the right field and
|
|
57
|
+
saves atomically.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Tables and CRUD
|
|
2
|
+
|
|
3
|
+
## The provider contract
|
|
4
|
+
|
|
5
|
+
`ui.DataTable(provider=fn)`: `fn(query: ui.TableQuery)` returns `ui.TablePage(rows, total)`, a list of
|
|
6
|
+
row mappings, or an awaitable of either. `TableQuery` has `offset`, `limit`, `sort`, `direction`
|
|
7
|
+
(`"asc"`/`"desc"`), `search` and `filters`. Only the visible window travels to the page
|
|
8
|
+
(`UiLimits.max_query_rows`, 1000, bounds it). The table checks events against its declared columns and actions:
|
|
9
|
+
sort and filter only on sortable/filterable columns, `row_action` only for declared actions, `cell_edit`
|
|
10
|
+
only on editable columns (value typed by the column kind). Row keys are strings or safe integers; set
|
|
11
|
+
`row_key="id"`.
|
|
12
|
+
|
|
13
|
+
Rules for your provider: cap `limit`, whitelist `sort` against column names (never interpolate it into
|
|
14
|
+
SQL otherwise), escape `LIKE` patterns, return `total` for paging, hold a lock around a shared
|
|
15
|
+
`sqlite3` connection (`examples/patterns/sqlite.py` does all four).
|
|
16
|
+
|
|
17
|
+
## Columns and actions
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from neutralino import ui
|
|
21
|
+
|
|
22
|
+
columns = [
|
|
23
|
+
ui.Column("id", "ID", kind="number", sortable=True),
|
|
24
|
+
ui.Column("name", "Name", sortable=True, editable=True),
|
|
25
|
+
ui.Column("qty", "Qty", kind="number", sortable=True, editable=True),
|
|
26
|
+
]
|
|
27
|
+
actions = [ui.RowAction("delete", "Delete", color="red", confirm="Delete {name}?")]
|
|
28
|
+
table = ui.DataTable(
|
|
29
|
+
columns=[c.to_json() for c in columns],
|
|
30
|
+
row_actions=[a.to_json() for a in actions],
|
|
31
|
+
rows=[{"id": 1, "name": "Bolt", "qty": 3}], # small data; or provider=fn for big data
|
|
32
|
+
row_key="id",
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`confirm` text is filled in the page with the row's values as plain text. `RowAction("open",
|
|
37
|
+
when="is_dir")` shows the button only on rows whose `is_dir` field is truthy; with local `rows`
|
|
38
|
+
Python also rejects the action on other rows (with a `provider`, check in the handler). A table that
|
|
39
|
+
declares row actions without an `on_row_action` handler logs a warning once: clicks would do nothing. `ui.blocks.TableBlock` and
|
|
40
|
+
`ui.blocks.UsersTable` are ready-made variants (selection, roles, add/save/remove events;
|
|
41
|
+
`examples/workspace/customers/app.py` uses `TableBlock(variant="selection", provider=..., row_key="id")`).
|
|
42
|
+
|
|
43
|
+
## CRUD flow
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
def edited(ev: ui.TableEvent) -> None: # on_cell_edit
|
|
47
|
+
item_id, column, value = ev.keys[0], str(ev.column), ev.value
|
|
48
|
+
ok = store.update(int(item_id), column, value) # validate again: the page is advisory
|
|
49
|
+
table.refresh() # re-query the provider
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def acted(ev: ui.RowActionEvent) -> None: # on_row_action
|
|
53
|
+
if ev.action == "delete" and store.delete(int(ev.key)):
|
|
54
|
+
table.refresh()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def added(ev: ui.SubmitEvent) -> None: # Form on_submit: ev.values is validated and nested
|
|
58
|
+
store.add(str(ev.values["name"]).strip(), int(ev.values["qty"]))
|
|
59
|
+
table.refresh()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Wire them with `on_cell_edit=edited`, `on_row_action=acted` and `with ui.Form(on_submit=added):` around named
|
|
63
|
+
`ui.TextInput(name="name", required=True)` and `ui.NumberInput(name="qty", min=0)`. After the write, reflect the
|
|
64
|
+
outcome in a status `ui.Text`. Source: `examples/patterns/sqlite.py`.
|
|
65
|
+
|
|
66
|
+
Server-driven variant (columns and actions as plain data, registered provider and actions, nothing
|
|
67
|
+
evaluated): `examples/patterns/dynamic_table.py`; forms from a schema: `dynamic_form.py`
|
|
68
|
+
(`ui.Form.from_schema`).
|
|
69
|
+
|
|
70
|
+
## Edit dialog pattern
|
|
71
|
+
|
|
72
|
+
Open a `ui.Drawer`/`ui.Modal` on `on_row_click`, fill a form's fields by assigning `.value`, submit with `ui.Form`
|
|
73
|
+
and `on_submit`. `form.reset()` returns fields to their initial values, `form.dirty` tells whether anything changed,
|
|
74
|
+
`form.set_errors({"email": "already used"})` shows a server-side failure on one field
|
|
75
|
+
(`examples/workspace/customers`, `tasks`, `calendar`).
|
|
76
|
+
|
|
77
|
+
## Pitfalls
|
|
78
|
+
|
|
79
|
+
- A row action or edit for a row that was deleted meanwhile: re-read, handle `None`, tell the user.
|
|
80
|
+
- Optimistic UI needs a rollback path (`examples/patterns/optimistic_updates.py`).
|
|
81
|
+
- Do not rely on `ev.value` types for numbers from untrusted pages: convert and bound them in Python.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: neutralino-frontend
|
|
3
|
+
description: Connect HTML/CSS/JS, React, Vue or Svelte frontends to Python through the canonical python-bridge.mjs, or add custom JavaScript/React components to a Python UI with ui.CustomComponent. Use it when the interface is web code, a control is missing from neutralino.ui, or a page must call Python.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# neutralino-frontend
|
|
7
|
+
|
|
8
|
+
Two independent ways to use web code. Pick one per window.
|
|
9
|
+
|
|
10
|
+
| Situation | Use |
|
|
11
|
+
|---|---|
|
|
12
|
+
| The UI exists (or must be written) as HTML/JS/React/Vue/Svelte | `neutralino.Application(resources="frontend/dist")` and `python-bridge.mjs` |
|
|
13
|
+
| The UI is Python and one control is missing | `ui.CustomComponent` + `app.add_js_module(...)` (plain JS or compiled React) |
|
|
14
|
+
|
|
15
|
+
No framework is required or excluded: the bridge needs only the official `neutralino.js` loaded by a script tag.
|
|
16
|
+
|
|
17
|
+
## Own frontend, Python backend
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from neutralino import Application
|
|
21
|
+
|
|
22
|
+
app = Application(resources="./frontend/dist", title="Hello", width=1000, height=700)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@app.expose()
|
|
26
|
+
def get_users(department: str):
|
|
27
|
+
return [{"department": department, "name": "Alice"}]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@app.expose(stream=True)
|
|
31
|
+
async def count(n: int):
|
|
32
|
+
for i in range(n):
|
|
33
|
+
yield i
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
app.run()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Runnable copies: `neutralino examples export vanilla DEST` and `neutralino examples export react DEST`
|
|
41
|
+
(Vite + React + TypeScript).
|
|
42
|
+
Scaffold with `neutralino init myapp --template vanilla` (original frontend scaffold plus `app.toml`).
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
neutralino frontend export src/bridge --with-client # python-bridge.mjs + .d.mts (+ pinned neutralino.js)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Page side (same in every framework):
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { PythonBackend, RpcError } from './bridge/python-bridge.mjs';
|
|
52
|
+
Neutralino.init(); // exactly once
|
|
53
|
+
const backend = new PythonBackend(NL_PYTHON_EXTENSION_ID);
|
|
54
|
+
const users = await backend.invoke('get_users', { department: 'IT' });
|
|
55
|
+
for await (const n of backend.stream('count', { n: 10 })) { /* ... break cancels the generator */ }
|
|
56
|
+
backend.register('page.add', ({ a, b }) => a + b); // Python: await app.frontend.invoke("page.add", {...})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
|
|
61
|
+
- Load `neutralino.js` once with a script tag (`<script src="neutralino.js"></script>`), call
|
|
62
|
+
`Neutralino.init()` once, create one `PythonBackend` per page. ESM/bundler apps keep `neutralino.js`
|
|
63
|
+
as a static asset and import only the bridge; for an imported client pass it explicitly:
|
|
64
|
+
`new PythonBackend(id, { neutralino: client })`.
|
|
65
|
+
- The page can call only functions Python exposed. List the native routes the page itself uses in
|
|
66
|
+
`native_allow_list` (profile rules: neutralino-native).
|
|
67
|
+
- Bundler settings: relative asset URLs (`base: './'` in Vite), no CDN imports, a CSP such as
|
|
68
|
+
`script-src 'self'` with `connect-src ws://127.0.0.1:*`.
|
|
69
|
+
- Every call's `timeoutMs` and `signal` apply from the moment of the call, including during the
|
|
70
|
+
handshake. `dispose()` is automatic on `pagehide`/`serverOffline` and safe right after construction
|
|
71
|
+
(React StrictMode).
|
|
72
|
+
- Errors arrive as `RpcError` with `code` (`INVALID_PARAMS`, `TIMEOUT`, `CANCELLED`, `BUSY`, ...).
|
|
73
|
+
Strings with a lone UTF-16 surrogate are rejected with `PROTOCOL_ERROR` before sending.
|
|
74
|
+
|
|
75
|
+
## Custom component inside a Python UI
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from neutralino import ui
|
|
79
|
+
|
|
80
|
+
stars = ui.CustomComponent(
|
|
81
|
+
"star-rating",
|
|
82
|
+
props={"max": 5},
|
|
83
|
+
on_event=lambda ev: print(ev.payload), # {"name": "rate", "data": {"stars": 3}}
|
|
84
|
+
on_error=lambda ev: print(ev.payload), # {"phase": ..., "message": ...}
|
|
85
|
+
)
|
|
86
|
+
stars.update(props={"max": 10}) # -> adapter.update(props)
|
|
87
|
+
stars.send("reset") # fire and forget -> adapter.command("reset", null)
|
|
88
|
+
# in async code: value = await stars.request("reset") (bounded by UiLimits.patch_timeout)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
// components.mjs, loaded with app.add_js_module("components.mjs")
|
|
93
|
+
window.NeutralinoUI.registerComponent('star-rating', () => ({
|
|
94
|
+
mount(el, props, emit) { el.onclick = () => emit('rate', { stars: 3 }); },
|
|
95
|
+
update(props) {}, command(name, data) { return 0; }, dispose() {},
|
|
96
|
+
}));
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Scaffolds: `neutralino init --template hybrid` (plain JS component, no Node) and `--template react`
|
|
100
|
+
(compiled `components/widget.mjs` committed; Node only to change the widget). Examples:
|
|
101
|
+
`examples/patterns/python_calls_page.py` + `.mjs` (Python asks the page, with a deadline).
|
|
102
|
+
|
|
103
|
+
## Pitfalls
|
|
104
|
+
|
|
105
|
+
- Component names: lowercase letters, digits, `-`; event names lowercase identifiers.
|
|
106
|
+
- `emit()` data must be JSON and at most 256 KiB UTF-8, else it throws in the page and nothing is sent.
|
|
107
|
+
- A throwing adapter or a component name not registered within 10 s is contained: an error notice
|
|
108
|
+
replaces that component; Python gets the `error` event (`on_error`), else `app.on_error`.
|
|
109
|
+
- Custom modules are trusted code with the page's privileges and the allowed native routes: load only
|
|
110
|
+
your own files. They must live in the app directory or `asset_roots`.
|
|
111
|
+
- React components must use the React/Mantine versions the renderer ships (the template pins them) and
|
|
112
|
+
Vite `external` for the shared modules, or hooks and the theme will not be shared.
|
|
113
|
+
|
|
114
|
+
## References
|
|
115
|
+
|
|
116
|
+
Paths written `examples/...` in this skill are in the framework's source repository only; the wheel ships the
|
|
117
|
+
apps that `neutralino examples list` shows (`neutralino examples export NAME DIR`).
|
|
118
|
+
|
|
119
|
+
- [references/bridge.md](references/bridge.md): the page API, loading modes, types, error codes, calling the page from Python.
|
|
120
|
+
- [references/frameworks.md](references/frameworks.md): Vue 3, Svelte, React/Vite settings and the repository examples.
|
|
121
|
+
- [references/custom-components.md](references/custom-components.md): JS and React adapters, lifecycle, limits, local file rules.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# The page API (`python-bridge.mjs`)
|
|
2
|
+
|
|
3
|
+
Canonical module in the package: `neutralino/frontend/python-bridge.mjs` with types in
|
|
4
|
+
`python-bridge.d.ts` and `python-bridge.d.mts`. Export it into your project:
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
neutralino frontend export src/bridge # the module and its types
|
|
8
|
+
neutralino frontend export src/bridge --with-client # also the pinned official neutralino.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Loading
|
|
12
|
+
|
|
13
|
+
`python-bridge.mjs` is an ES module and does not bundle the official client. Load the official
|
|
14
|
+
`neutralino.js` once, call `Neutralino.init()` exactly once, then create one `PythonBackend` per page.
|
|
15
|
+
|
|
16
|
+
- **Script tag (plain HTML).** `<script src="neutralino.js"></script>` defines `window.Neutralino`;
|
|
17
|
+
`import { PythonBackend } from './python-bridge.mjs'` in `<script type="module">`;
|
|
18
|
+
`new PythonBackend(NL_PYTHON_EXTENSION_ID)` uses `globalThis.Neutralino`.
|
|
19
|
+
- **ESM / bundler.** Copy the files with `neutralino frontend export`; the `.d.mts` next to the `.mjs`
|
|
20
|
+
lets TypeScript resolve types. Keep `neutralino.js` as a static asset, import only the bridge:
|
|
21
|
+
`--with-client` writes it next to the bridge, so move it to the static folder (`public/` in Vite).
|
|
22
|
+
Vite's "can't be bundled
|
|
23
|
+
without type=module" warning for that script is expected.
|
|
24
|
+
- **Injection.** `new PythonBackend(id, { neutralino: myClient })`; the object needs
|
|
25
|
+
`events.on/off` and `extensions.dispatch/getStats`.
|
|
26
|
+
|
|
27
|
+
## Calls
|
|
28
|
+
|
|
29
|
+
| Method | Meaning |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `invoke(name, params?, {timeoutMs, signal, onProgress})` | one request, one result |
|
|
32
|
+
| `stream(name, params?, {credit, timeoutMs, signal, onProgress})` | async iterable; `await it.result` after the loop gives the terminal value |
|
|
33
|
+
| `emit(name, params?)` | notification, no reply (rejects `TIMEOUT` or `DISCONNECTED`) |
|
|
34
|
+
| `discover()` | exposed methods: names, parameters, schema, stream mode, `description` only if given |
|
|
35
|
+
| `register(name, handler, {stream})` | the page exposes a function; Python calls it with `await app.frontend.invoke(...)`; returns an unregister function |
|
|
36
|
+
| `on(event, fn)` / `off` | native events through the backend's client |
|
|
37
|
+
| `ready()` / `dispose()` | handshake / cleanup (automatic on `pagehide` and `serverOffline`) |
|
|
38
|
+
|
|
39
|
+
- Progress: `ctx.progress(...)` on the Python side reaches `onProgress`; it is rate-limited to 10 per
|
|
40
|
+
second with the latest value kept; a gap is tolerated.
|
|
41
|
+
- Streams use credit: the producer pauses without credit (default window 16, max 64). Leaving the
|
|
42
|
+
`for await` loop cancels the Python generator; `result` then rejects `CANCELLED`.
|
|
43
|
+
- Default `timeoutMs` 30000, validated (> 0, <= 2147483647); a handshake that timed out is retried by the
|
|
44
|
+
next call.
|
|
45
|
+
- Messages: RPC 4 MiB, stream items 256 KiB; return values must be JSON with integers within
|
|
46
|
+
+-(2**53-1); strings with a lone UTF-16 surrogate are `PROTOCOL_ERROR`.
|
|
47
|
+
- `RpcError.code`: `METHOD_NOT_FOUND`, `INVALID_PARAMS`, `BUSY`, `TIMEOUT`, `CANCELLED`,
|
|
48
|
+
`PROTOCOL_ERROR`, `INTERNAL_ERROR`, `DISCONNECTED`, `UNSUPPORTED`, `STREAM_OVERFLOW`. At most 32 calls
|
|
49
|
+
per page are active; more get `BUSY`.
|
|
50
|
+
|
|
51
|
+
## Python calls the page
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
async def ask_page(app) -> None: # `app`: a running neutralino.AsyncApplication
|
|
55
|
+
result = await app.frontend.invoke("page.add", {"a": 1, "b": 2}) # the page registered it
|
|
56
|
+
async with app.frontend.stream("page.lines", {"n": 5}) as s: # cancel is sent on early exit
|
|
57
|
+
async for item in s:
|
|
58
|
+
print(result, item)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
In a Python UI the equivalent is `ui.CustomComponent.request(...)` (see `custom-components.md`).
|
|
62
|
+
The framework's source repository tests this flow end to end (framework-free page, real runtime); a
|
|
63
|
+
runnable copy for you: `neutralino examples export vanilla DEST`.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Custom components and local files (`neutralino.ui`)
|
|
2
|
+
|
|
3
|
+
Trusted, application-owned CSS, HTML and JavaScript next to the built-in components. Everything is
|
|
4
|
+
local: files are copied into a per-user staging directory at start, served with relative URLs, never
|
|
5
|
+
fetched from a CDN, and the installed package is never written to.
|
|
6
|
+
|
|
7
|
+
## Local files
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from neutralino import ui
|
|
11
|
+
|
|
12
|
+
app = ui.Application(title="Demo") # the app directory is this file's directory
|
|
13
|
+
app.add_css_file("web/app.css") # loaded in every window
|
|
14
|
+
app.add_js_module("web/components.mjs") # ES module, runs before the page renders custom components
|
|
15
|
+
url = app.add_asset("web/logo.png") # -> "custom/files/logo.png" for img src
|
|
16
|
+
app.add_asset_dir("web/img", prefix="img")
|
|
17
|
+
with app.page("/"):
|
|
18
|
+
ui.HtmlFile("web/about.html") # trusted markup (no scripts or inline handlers under the CSP)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
All violations raise `ValidationError`: relative paths start at the directory of the file that created
|
|
22
|
+
the application (not the working directory) and may not contain `..`; the real path must lie in the
|
|
23
|
+
application directory or in `asset_roots=[...]`; files inside the installed `neutralino` package are
|
|
24
|
+
refused; `.css` for stylesheets, `.js`/`.mjs` for modules, regular files only, at most 64 MiB. Use
|
|
25
|
+
`ui.Html(text)` (sanitised) for markup you did not write.
|
|
26
|
+
|
|
27
|
+
## Plain JavaScript adapter
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
window.NeutralinoUI.registerComponent('star-rating', () => {
|
|
31
|
+
let root;
|
|
32
|
+
return {
|
|
33
|
+
mount(el, props, emit) { root = el; el.onclick = () => emit('rate', { stars: 3 }); },
|
|
34
|
+
update(props) { /* new props from Python */ },
|
|
35
|
+
command(name, data) { if (name === 'reset') return 0; }, // send()/request() from Python
|
|
36
|
+
dispose() { /* remove listeners, timers */ },
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Python side: `ui.CustomComponent("star-rating", props={...}, on_event=..., on_error=...)`,
|
|
42
|
+
`.update(props=...)`, `.send(name, data)`, `await .request(name, data)`. Names are lowercase letters,
|
|
43
|
+
digits and `-`; event names lowercase identifiers. `emit(name, data)` takes JSON only, at most 256 KiB
|
|
44
|
+
UTF-8 (`NeutralinoUI.limits.maxEventBytes`); larger or non-JSON data throws in the caller and nothing
|
|
45
|
+
is sent; Python validates the same bounds again.
|
|
46
|
+
|
|
47
|
+
## Compiled React component
|
|
48
|
+
|
|
49
|
+
Build with Vite as an ES library whose shared modules are external; the page's import map resolves
|
|
50
|
+
them to the renderer's instances, so hooks, context and the Mantine theme are shared:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
const shared = ['react', 'react/jsx-runtime', 'react-dom', 'react-dom/client', '@mantine/core', '@mantine/hooks'];
|
|
54
|
+
export default defineConfig({ plugins: [react()], build: {
|
|
55
|
+
lib: { entry: 'src/Widget.jsx', formats: ['es'], fileName: () => 'widget.mjs' },
|
|
56
|
+
rollupOptions: { external: shared } } });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
function Widget({ props, emit, onCommand }) {
|
|
61
|
+
const [n, setN] = useState(0);
|
|
62
|
+
useEffect(() => { onCommand((name) => name === 'get' ? n : null); return () => onCommand(null); }, [n]);
|
|
63
|
+
return <Button onClick={() => emit('inc', { n: n + 1 })}>{n}</Button>;
|
|
64
|
+
}
|
|
65
|
+
window.NeutralinoUI.registerReactComponent('my-widget', Widget);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Use the React and Mantine versions the renderer ships (the `react` template's `widget/package.json`
|
|
69
|
+
pins them). `neutralino init --template react` creates a working setup; the committed
|
|
70
|
+
`components/widget.mjs` needs no Node at run time.
|
|
71
|
+
|
|
72
|
+
## Lifecycle and errors
|
|
73
|
+
|
|
74
|
+
- `mount` runs once per instance; `update` on every Python props change; `dispose` when the
|
|
75
|
+
component is removed, its page route changes, or the window reloads or closes.
|
|
76
|
+
- A throwing `mount`/`update`/`command`/`dispose`, a React render error, a factory that returns no
|
|
77
|
+
adapter, or a name never registered within 10 s is contained: an error notice replaces that component;
|
|
78
|
+
Python receives it as the component's `error` event (`on_error`); without one, `app.on_error(fn)` gets
|
|
79
|
+
a `ui.CustomComponentError` (`component`, `phase`, `message`); else it is logged. A failing
|
|
80
|
+
`request()` also raises `RpcError` in the caller.
|
|
81
|
+
- Python calls to the page are bounded by `UiLimits.patch_timeout`, fail with `DISCONNECTED` when no
|
|
82
|
+
page is mounted, and stop waiting when the awaiting task is cancelled
|
|
83
|
+
(`examples/patterns/python_calls_page.py`).
|
|
84
|
+
- Custom modules are trusted code with the page's privileges and the native routes your app allows.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Framework recipes
|
|
2
|
+
|
|
3
|
+
The bridge calls are identical in every framework. Create one backend per app and keep results in
|
|
4
|
+
the framework's state.
|
|
5
|
+
|
|
6
|
+
## Build settings for any bundler
|
|
7
|
+
|
|
8
|
+
- relative asset URLs (`base: './'` in Vite) and no CDN imports;
|
|
9
|
+
- copy `neutralino.js` into the output and load it with `<script src="neutralino.js"></script>`
|
|
10
|
+
before your bundle;
|
|
11
|
+
- a CSP like the examples': `script-src 'self'`, `connect-src` to `ws://127.0.0.1:*`;
|
|
12
|
+
- if the page calls native APIs itself, list them in `native_allow_list`.
|
|
13
|
+
|
|
14
|
+
Point Python at the build output: `neutralino.Application(resources="frontend/dist")` and, for
|
|
15
|
+
`neutralino build`, `--frontend frontend/dist` (or `--frontend-cmd` to run your bundler first;
|
|
16
|
+
`neutralino build --help`).
|
|
17
|
+
|
|
18
|
+
## React (Vite, TypeScript)
|
|
19
|
+
|
|
20
|
+
The packaged `react` example (its `npm run prepare-bridge` script copies the bridge; you can do
|
|
21
|
+
the same with `neutralino frontend export`). Its `frontend/index.html` loads `neutralino.js` with a
|
|
22
|
+
classic script tag. Create the backend once at module level and call it from effects.
|
|
23
|
+
`dispose()` on unmount is safe: React StrictMode mounts and unmounts at once.
|
|
24
|
+
|
|
25
|
+
## Vue 3
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
// backend.js
|
|
29
|
+
export const backend = new PythonBackend(NL_PYTHON_EXTENSION_ID);
|
|
30
|
+
// Users.vue <script setup>
|
|
31
|
+
import { ref, onMounted } from 'vue';
|
|
32
|
+
import { backend } from './backend.js';
|
|
33
|
+
const users = ref([]);
|
|
34
|
+
onMounted(async () => { users.value = await backend.invoke('get_users', { department: 'IT' }); });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Call `Neutralino.init()` once in `main.js` before `createApp(App).mount('#app')`.
|
|
38
|
+
|
|
39
|
+
## Svelte
|
|
40
|
+
|
|
41
|
+
```svelte
|
|
42
|
+
<script>
|
|
43
|
+
import { onMount } from 'svelte';
|
|
44
|
+
import { backend } from './backend.js';
|
|
45
|
+
let users = [];
|
|
46
|
+
onMount(async () => { users = await backend.invoke('get_users', { department: 'IT' }); });
|
|
47
|
+
</script>
|
|
48
|
+
{#each users as u}<p>{u.name}</p>{/each}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For a stream, append inside the `for await` loop; `break` cancels the Python generator.
|
|
52
|
+
|
|
53
|
+
## Packaging a frontend app
|
|
54
|
+
|
|
55
|
+
`neutralino build` ships the built frontend folder inside `app/`; the bundle needs no Node at run time.
|
|
56
|
+
`--bundle` (a `resources.neu` archive) needs Node at build time (see neutralino-packaging).
|
|
57
|
+
|
|
58
|
+
## Checks that exist
|
|
59
|
+
|
|
60
|
+
The framework's source repository (not the wheel) type-checks a framework-style TypeScript consumer of
|
|
61
|
+
the declarations and runs a framework-free page against the real runtime. Vue and Svelte snippets above are documented patterns, not separately built examples.
|