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,366 @@
|
|
|
1
|
+
# Application updates (`neutralino.updates`)
|
|
2
|
+
|
|
3
|
+
Optional, per application. An app that does not configure `[updates]` runs no
|
|
4
|
+
update code. This is **not** the native runtime updater
|
|
5
|
+
(`Application.updater`, Neutralino's `updater.*` API), which stays unchanged
|
|
6
|
+
and separate: `neutralino.updates` installs complete application versions
|
|
7
|
+
side by side and switches between them when the app is launched.
|
|
8
|
+
|
|
9
|
+
Linux x86_64 is the tested platform. Windows and macOS code paths exist
|
|
10
|
+
(`msvcrt` locks, `venv\Scripts\python.exe`, zip archives, platform keys) but
|
|
11
|
+
are **untested**; see [Limitations](#limitations).
|
|
12
|
+
|
|
13
|
+
## Configuration (`app.toml`)
|
|
14
|
+
|
|
15
|
+
Structure, unknown keys and value types are checked by one shared loader
|
|
16
|
+
(also used by `neutralino init` and the managed packager; from Python,
|
|
17
|
+
`neutralino.updates.load_config(path)`); `neutralino.updates` adds the update rules
|
|
18
|
+
(choices, ranges, provider/repository/url consistency, URL policy, relative
|
|
19
|
+
paths). Every failure is a `ConfigError`.
|
|
20
|
+
|
|
21
|
+
```toml
|
|
22
|
+
[app]
|
|
23
|
+
id = "org.example.inventory" # same rule as ui.Application(app_id=)
|
|
24
|
+
name = "Inventory"
|
|
25
|
+
version = "1.2.0" # SemVer 2.0.0
|
|
26
|
+
entry = "app.py" # relative to the project root
|
|
27
|
+
|
|
28
|
+
[updates] # optional; absent or enabled = false: no update code runs
|
|
29
|
+
enabled = true
|
|
30
|
+
provider = "github" # "github", or "url" (self-hosted manifest / loopback tests)
|
|
31
|
+
repository = "owner/name" # github only
|
|
32
|
+
# github_url = "https://ghe.example.com" # github only: GitHub Enterprise host (default https://github.com)
|
|
33
|
+
# url = "https://example.org/inventory/manifest.json" # provider = "url" only
|
|
34
|
+
auth = "auto" # auto | public | private
|
|
35
|
+
channel = "stable" # stable | prerelease
|
|
36
|
+
check_on_startup = true
|
|
37
|
+
check_interval_hours = 24 # 0: no periodic checks (only the startup check, if enabled)
|
|
38
|
+
silent_on_failure = true # background failures logged at debug level only
|
|
39
|
+
activation = "next-start" # next-start | prompt
|
|
40
|
+
keep_versions = 2 # current + previous kept when pruning
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`neutralino.updates.load_config(path)` returns a frozen `AppConfig`
|
|
44
|
+
(`.app`, `.updates`, `.package`).
|
|
45
|
+
|
|
46
|
+
## Using it in an app
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from pathlib import Path
|
|
50
|
+
from neutralino import Application
|
|
51
|
+
from neutralino.updates import UpdateManager, load_config, start_background_checks
|
|
52
|
+
|
|
53
|
+
config = load_config(Path(__file__).with_name("app.toml"))
|
|
54
|
+
updates = UpdateManager(config)
|
|
55
|
+
app = Application(resources="frontend")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@app.expose()
|
|
59
|
+
def page_ready() -> None: # called by the page once it is usable
|
|
60
|
+
updates.confirm_healthy() # ends this version's trial (see below)
|
|
61
|
+
start_background_checks(app, updates)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
app.run()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| API | Behaviour |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `UpdateManager(config, paths=None)` | `paths`: `InstallPaths`, an `AppPaths`, or default `InstallPaths.for_app(config.app.id)` |
|
|
70
|
+
| `check() -> UpdateResult` | manual check; raises a typed `UpdateError` on failure (message + `hint`) |
|
|
71
|
+
| `check_quietly()` | same, failures returned as `UpdateStatus.ERROR` |
|
|
72
|
+
| `download_and_stage(result=None)` | download, verify, extract, stage; `UpdateStatus.STAGED` |
|
|
73
|
+
| `pending_restart` / `staged_version` | a staged version starts at the next launch |
|
|
74
|
+
| `activate_staged()` | `activation = "prompt"`: after the user agreed |
|
|
75
|
+
| `confirm_healthy()` | end the running version's trial (also `neutralino.updates.confirm_healthy()`) |
|
|
76
|
+
| `relaunch(argv=None)` | on the user's explicit request, after `app.run()` returned: exec the install's `launcher.py`, which starts the pending version as a trial; False if nothing is pending; `UpdateError` if not started by the launcher |
|
|
77
|
+
| `start_background_checks(app, manager)` | daemon thread; never blocks the event loop, never raises, stops with `stop()` or when `app` (core or `ui.Application`) reaches `STOPPED` |
|
|
78
|
+
|
|
79
|
+
In a `ui` app, confirm after the page has rendered: `await
|
|
80
|
+
app.wait_for_window()` (or the blocking `app.wait_for_window()`) returns
|
|
81
|
+
once the page has committed and rendered its first tree, past the loading
|
|
82
|
+
spinner, so a
|
|
83
|
+
release whose page never renders is not confirmed and rolls back. The
|
|
84
|
+
packaged example `neutralino examples export updater DEST` does this.
|
|
85
|
+
|
|
86
|
+
`UpdateResult(status, current_version, latest_version=None, manifest=None,
|
|
87
|
+
asset=None, error=None, detail="")` is what `check()`/`check_quietly()`
|
|
88
|
+
return; `.available` is `status == "available"` and `.message` is a
|
|
89
|
+
one-line text for the user. Building one yourself (as the example does to
|
|
90
|
+
report an error) is supported.
|
|
91
|
+
|
|
92
|
+
`UpdateStatus`: `disabled`, `no-update`, `available`, `staged`,
|
|
93
|
+
`quarantined`, `error`. Errors: `NoReleaseError`, `NotFoundError`,
|
|
94
|
+
`GhMissingError`, `UnauthorizedError`, `RateLimitedError`, `NetworkError`,
|
|
95
|
+
`UnsafeUrlError`, `InvalidManifestError`, `WrongApplicationError`,
|
|
96
|
+
`WrongPlatformError`, `IntegrityError`, `UnsafeArchiveError`, `LockedError`,
|
|
97
|
+
`ConfigError` (all `UpdateError`).
|
|
98
|
+
|
|
99
|
+
### Sources and test isolation (Python API)
|
|
100
|
+
|
|
101
|
+
`UpdateManager(config, paths=None, *, source=None, platform=None,
|
|
102
|
+
running_version=None, http=None, env=None, archive_limits=None)`: by
|
|
103
|
+
default the source comes from `[updates]` and the paths from the app id.
|
|
104
|
+
Tests and custom setups pass them explicitly:
|
|
105
|
+
|
|
106
|
+
* `InstallPaths(root, cache_dir=None)`: the install folder (`versions/`,
|
|
107
|
+
`current.json`, ...) and the update cache; `InstallPaths.for_app(app_id)`
|
|
108
|
+
is the default.
|
|
109
|
+
* `UrlSource(url, *, application_id)`: a self-hosted `manifest.json`
|
|
110
|
+
(plain `http` only on loopback).
|
|
111
|
+
* `GitHubSource(repository, *, application_id, auth="auto",
|
|
112
|
+
api="https://api.github.com", env=None, gh_timeout=10.0,
|
|
113
|
+
gh_candidates=(...))`: the GitHub REST API. It calls `GET
|
|
114
|
+
/repos/{repo}/releases/latest` (with `auth = "auto"` an anonymous
|
|
115
|
+
`GET /repos/{repo}` after a 404), then fetches `manifest.json` and the
|
|
116
|
+
archive through each asset's API `url` with `Accept:
|
|
117
|
+
application/octet-stream`, following the redirect to the storage host
|
|
118
|
+
without the token. `api=` points it at GitHub Enterprise or a local fake;
|
|
119
|
+
`app.toml` has no key for this, so the CLI and `install.sh` always use
|
|
120
|
+
`api.github.com`.
|
|
121
|
+
* `find_github_token(*, env=None, hostname="github.com", timeout=10.0,
|
|
122
|
+
gh_candidates=(...))`: the credential lookup described under
|
|
123
|
+
[Security policy](#security-policy).
|
|
124
|
+
* `running_version=` overrides the version read from the install pointer.
|
|
125
|
+
|
|
126
|
+
To test the private flow without your real credentials, pass an `env`
|
|
127
|
+
whose `PATH` holds only a fake `gh` (or no `gh`) and `gh_candidates=()`:
|
|
128
|
+
an explicit `env` is the whole environment, and `gh` is looked up on its
|
|
129
|
+
`PATH`, then in `gh_candidates`.
|
|
130
|
+
|
|
131
|
+
Version rules: strict SemVer 2.0.0 (no `v` prefix, no leading zeros);
|
|
132
|
+
precedence per semver.org (build metadata ignored); only strictly newer
|
|
133
|
+
versions are offered (no downgrade); prereleases only with
|
|
134
|
+
`channel = "prerelease"`; a version that failed its trial is never offered
|
|
135
|
+
again.
|
|
136
|
+
|
|
137
|
+
## Releases
|
|
138
|
+
|
|
139
|
+
`neutralino.updates.release.build_release(project_dir, out_dir, platform=None, version=None, *, base_url=None, runtime_path=None, vendor=(), mode="portable", requirements=None, wheelhouse=None, python_version=None, platforms=None)`
|
|
140
|
+
(also `neutralino release --out DIR`, see [cli.md](cli.md), or
|
|
141
|
+
`python -m neutralino.updates.release PROJECT --out DIR`) builds locally,
|
|
142
|
+
never publishes:
|
|
143
|
+
|
|
144
|
+
| File | Content |
|
|
145
|
+
| --- | --- |
|
|
146
|
+
| `<app id>-<version>-<platform>.tar.gz` (`.zip` on Windows) | the portable `neutralino build` (frontend, backend, `vendor/` with neutralino + websockets + `--vendor` distributions, pinned runtime, `boot.py`), `release.json`, `app/app.toml` with the release version |
|
|
147
|
+
| `manifest.json` | schema below |
|
|
148
|
+
| `install.sh` | first-time installer for Linux, generated from the app's own `app.toml` (the template has no hardcoded identity) |
|
|
149
|
+
| `SHA256SUMS` | of the three files above |
|
|
150
|
+
|
|
151
|
+
`mode="managed"` (`neutralino release --mode managed`) builds the archive
|
|
152
|
+
with `neutralino build --mode managed` instead: it also holds the wheelhouse,
|
|
153
|
+
`requirements.lock.txt` and the offline `install.sh`/`install.py`
|
|
154
|
+
([packaging.md](packaging.md)), and `release.json` says `"mode": "managed"`.
|
|
155
|
+
Its version is `[app] version` of `app.toml` (a different `version` is
|
|
156
|
+
refused). Use it for apps installed with the managed installer and for any
|
|
157
|
+
app with compiled dependencies:
|
|
158
|
+
|
|
159
|
+
* the updater, after verifying and extracting such an archive, creates
|
|
160
|
+
`venv/` in the new version with a CPython of the build's target version
|
|
161
|
+
(the running interpreter, its base, or `pythonX.Y` on `PATH`, each probed
|
|
162
|
+
for `venv`/`ensurepip`) and runs `pip install --no-index --find-links
|
|
163
|
+
wheelhouse --require-hashes --only-binary=:all: -r requirements.lock.txt`
|
|
164
|
+
with `PIP_*`/`PYTHON*` cleared: no network, every wheel hash-checked. Only
|
|
165
|
+
then is the version moved to `versions/` and marked pending; any failure
|
|
166
|
+
(no interpreter, hash mismatch) is an `UpdateError` with a hint and stages
|
|
167
|
+
nothing. The wheelhouse is removed afterwards;
|
|
168
|
+
* a release without a wheelhouse is refused (`InvalidManifestError`) for an
|
|
169
|
+
install whose running version has a `venv/`;
|
|
170
|
+
* the first-time `install.sh` hands a managed archive, after its checksum
|
|
171
|
+
checks, to the bundled offline installer.
|
|
172
|
+
|
|
173
|
+
Archives are reproducible (sorted members, uid/gid 0, mtime 0, gzip mtime 0;
|
|
174
|
+
set `SOURCE_DATE_EPOCH` to fix the build manifest's `built_at`). Only the
|
|
175
|
+
build machine's platform can be built (the archive ships that machine's
|
|
176
|
+
pinned runtime).
|
|
177
|
+
|
|
178
|
+
Publishing is the owner's step, e.g. `gh release create v1.2.0 out/*` (tag
|
|
179
|
+
`v<version>` or `<version>`; it must equal the manifest's version).
|
|
180
|
+
|
|
181
|
+
### Manifest (`schema_version` 1)
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"schema_version": 1,
|
|
186
|
+
"applicationId": "org.example.inventory",
|
|
187
|
+
"version": "1.2.0",
|
|
188
|
+
"assets": {
|
|
189
|
+
"linux-x86_64": {"name": "org.example.inventory-1.2.0-linux-x86_64.tar.gz",
|
|
190
|
+
"url": "org.example.inventory-1.2.0-linux-x86_64.tar.gz",
|
|
191
|
+
"sha256": "<64 lowercase hex>", "size": 123456}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Platforms: `linux-x86_64`, `windows-x86_64`, `macos-arm64`, `macos-x86_64`.
|
|
197
|
+
`url` may be relative to the manifest. The legacy `update.json` format
|
|
198
|
+
(no `schema_version`, `linux_x64`) is still read.
|
|
199
|
+
|
|
200
|
+
### First install
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
# public repository or any static host
|
|
204
|
+
curl -fsSLO https://github.com/OWNER/REPO/releases/latest/download/install.sh && sh install.sh
|
|
205
|
+
# private repository (GitHub CLI logged in with an account that can read it)
|
|
206
|
+
gh release download -R OWNER/REPO -p install.sh -O - | sh
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The installer tries the public download first and falls back to `gh release
|
|
210
|
+
download` when that fails and `gh` is logged in; it verifies the manifest's
|
|
211
|
+
application id and the archive against both `manifest.json` and
|
|
212
|
+
`SHA256SUMS`, unpacks with `tarfile`'s `data` filter (links and devices
|
|
213
|
+
refused) into its own `staging/<version>.install.*` folder, and hands the
|
|
214
|
+
rest to the release's launcher (`_layout.py --install`): under `.launch.lock`
|
|
215
|
+
and `install.lock`, both taken without waiting, it moves the build into
|
|
216
|
+
`versions/` (a complete version already there is kept; an incomplete one is
|
|
217
|
+
replaced by renames), records the version and writes `launcher.py`,
|
|
218
|
+
`~/.local/bin/<app id>` and a `.desktop` entry. `NEUTRALINO_RELEASE_BASE=URL`
|
|
219
|
+
installs from another location; `sh install.sh --uninstall` runs the
|
|
220
|
+
installed `launcher.py --uninstall`, which removes only the managed names (see
|
|
221
|
+
Install layout) and keeps data, settings and logs. Both refuse (exit 1, nothing
|
|
222
|
+
changed) while the app runs or while another install or update holds
|
|
223
|
+
`install.lock`, and neither overwrites nor removes a command or menu entry
|
|
224
|
+
that lacks the installers' marker (`# neutralino-python managed launcher`,
|
|
225
|
+
`X-Neutralino-Python-App=<app id>`); links are never followed or removed.
|
|
226
|
+
|
|
227
|
+
## Install layout
|
|
228
|
+
|
|
229
|
+
The per-app data directory (`AppPaths(app_id).location("data")`, XDG on
|
|
230
|
+
Linux) is the install root. It is the same layout the managed installer
|
|
231
|
+
(`neutralino build --mode managed`, P07.03) writes: `versions/<v>/`,
|
|
232
|
+
`current.json` (`{"current", "previous", "pending"}`, extra keys added by the
|
|
233
|
+
updater) and `install.lock`. The updater only ever touches the names below;
|
|
234
|
+
everything else in the directory is the application's own data.
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
~/.local/share/<app id>/
|
|
238
|
+
current.json pointer: current, previous, pending (+ staged, trial, quarantined, schema)
|
|
239
|
+
current.json.bak the pointer before its last change
|
|
240
|
+
versions/<semver>/ complete builds (boot.py, app/, vendor/, runtime/, venv/?)
|
|
241
|
+
staging/ downloads (<sha256>.tar.gz.part, resumable) and extraction
|
|
242
|
+
quarantine/<semver>/ the most recent version whose trial failed
|
|
243
|
+
launcher.py the launcher (copy of neutralino/updates/_layout.py)
|
|
244
|
+
launcher.log launcher decisions (no secrets)
|
|
245
|
+
install.lock held briefly to change the pointer or versions/ (shared with the managed installer)
|
|
246
|
+
.launch.lock held by the running app: one copy at a time
|
|
247
|
+
<anything else> the application's data: never touched by updates
|
|
248
|
+
~/.cache/<app id>/updates/http-cache.json ETags and rate-limit backoff
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A pointer without `schema` (as older managed installers wrote it) is read as
|
|
252
|
+
schema 1. Both installers (the release `install.sh` and the managed
|
|
253
|
+
`install.sh`/`install.py`) write `launcher.py` and a `~/.local/bin/<app id>`
|
|
254
|
+
command that runs it, so pending/trial/rollback apply to every install. Both
|
|
255
|
+
uninstallers (`install.sh --uninstall`, `uninstall.py`) remove exactly the
|
|
256
|
+
managed names (the names listed above plus the managed installer's
|
|
257
|
+
`install.json`, `uninstall.py` and `install.lock`) and keep everything
|
|
258
|
+
else.
|
|
259
|
+
|
|
260
|
+
The launcher (`python3 -I launcher.py --app-dir ROOT -- ARGS` or
|
|
261
|
+
`python -m neutralino.updates.launcher`) takes the launch lock (a second
|
|
262
|
+
launch exits 0 with "already running"), resolves the pointer under the
|
|
263
|
+
update lock, then execs `versions/<v>/venv/bin/python` (when a managed venv
|
|
264
|
+
exists, P07.03) or its own interpreter with `-I versions/<v>/boot.py`,
|
|
265
|
+
exporting `NEUTRALINO_UPDATE_ROOT` and `NEUTRALINO_UPDATE_VERSION`. The
|
|
266
|
+
exec'd app inherits the launch lock.
|
|
267
|
+
|
|
268
|
+
Pointer writes are temp file + fsync + rename + directory fsync; a torn or
|
|
269
|
+
corrupt pointer is replaced by the backup, else rebuilt from the newest
|
|
270
|
+
usable version in `versions/`. A version is usable when its `boot.py` exists
|
|
271
|
+
and, if it has a `venv/`, the venv's interpreter exists (a failed dependency
|
|
272
|
+
install makes it unusable).
|
|
273
|
+
|
|
274
|
+
## Staging, trial and rollback
|
|
275
|
+
|
|
276
|
+
1. A check finds a newer version. `download_and_stage` downloads into
|
|
277
|
+
`staging/` (a separate download lock prevents two downloads; an
|
|
278
|
+
interrupted download resumes with an HTTP Range request, or restarts if
|
|
279
|
+
the server does not support ranges), verifies size and SHA-256, extracts
|
|
280
|
+
safely, checks `release.json` (application id, version, platform) and
|
|
281
|
+
`boot.py`, moves it to `versions/<v>/` and sets `pending` (or `staged` for
|
|
282
|
+
`activation = "prompt"`). Running files are never replaced; nothing
|
|
283
|
+
restarts the app.
|
|
284
|
+
2. The next launch activates `pending`: `previous = current`, `current =
|
|
285
|
+
trial = <v>`.
|
|
286
|
+
3. The new version calls `confirm_healthy()` once its backend and page are
|
|
287
|
+
really ready (in a `ui` app: after `wait_for_window()`): the trial ends, old versions are pruned (current, previous
|
|
288
|
+
if `keep_versions >= 2`, pending/staged, and newer extras up to
|
|
289
|
+
`keep_versions`), and `launcher.py` is refreshed from the running version.
|
|
290
|
+
4. If the app crashes, exits or is closed before confirming, the next launch
|
|
291
|
+
finds `trial == current`: it switches back to `previous`, moves the failed
|
|
292
|
+
version to `quarantine/` and never activates or stages it again. With no
|
|
293
|
+
usable previous version it keeps the current one.
|
|
294
|
+
|
|
295
|
+
Rollback restores application **files** only. Application data is never
|
|
296
|
+
rolled back: data migrations must stay compatible with the previous version
|
|
297
|
+
or back up their data themselves.
|
|
298
|
+
|
|
299
|
+
## Security policy
|
|
300
|
+
|
|
301
|
+
* **Integrity, not authenticity (accepted risk).** Each release asset is
|
|
302
|
+
checked against the SHA-256 and size in a manifest fetched over HTTPS from
|
|
303
|
+
the configured repository or URL. There is no signature verification (no
|
|
304
|
+
crypto dependency, no custom crypto): whoever can publish releases in the
|
|
305
|
+
repository (or serve the manifest URL) can ship code. Owners who need more
|
|
306
|
+
must sign out of band. Recorded in the maintenance risk register.
|
|
307
|
+
* HTTPS only; plain `http` is accepted for loopback hosts only (tests,
|
|
308
|
+
same-machine manifests), checked on every redirect hop; https -> http
|
|
309
|
+
redirects are refused; at most 5 redirects; 15 s timeouts; bounded
|
|
310
|
+
responses (API 4 MiB, manifest 256 KiB, asset size from the manifest, at
|
|
311
|
+
most 1 GiB).
|
|
312
|
+
* Archives: relative names only, no `..`, absolute paths, backslashes or
|
|
313
|
+
control characters, regular files and directories only (links, devices,
|
|
314
|
+
FIFOs refused), no duplicates (also case-insensitive), at most 50 000
|
|
315
|
+
members, 2 GiB expanded, ratio 200:1; files written by the updater with
|
|
316
|
+
modes 0644/0755, byte counts enforced while streaming.
|
|
317
|
+
* GitHub authentication (`auth`):
|
|
318
|
+
* `public`: anonymous API only.
|
|
319
|
+
* `auto` (default): anonymous first; if refused (404/401/403 without a rate
|
|
320
|
+
limit), the user's own credentials.
|
|
321
|
+
* `private`: credentials directly.
|
|
322
|
+
|
|
323
|
+
Credentials come from `GH_TOKEN` / `GITHUB_TOKEN`, else `gh auth token
|
|
324
|
+
--hostname github.com` (10 s timeout, `GH_PROMPT_DISABLED=1`, the token
|
|
325
|
+
read from stdout). The token is sent only to the configured API origin
|
|
326
|
+
(`https://api.github.com`; with `github_url` set, `<github_url>/api/v3`, the
|
|
327
|
+
GitHub Enterprise Server layout; the Python API's `GitHubSource(api=...)` can
|
|
328
|
+
name any other) as `Authorization: Bearer`. For another API address `gh` is
|
|
329
|
+
asked for that address's host, never for `github.com`, so a test or
|
|
330
|
+
enterprise API never receives the user's github.com token; a `GH_TOKEN` you
|
|
331
|
+
set yourself is sent to whichever API you configured. An explicit `env=`
|
|
332
|
+
mapping is the whole environment: without `PATH` in it no `gh` is found
|
|
333
|
+
except through `gh_candidates`. The token is never sent to the storage
|
|
334
|
+
host GitHub redirects asset downloads to, never in a URL, never in the
|
|
335
|
+
arguments of a process, never logged, and never written to disk (the cache
|
|
336
|
+
holds public metadata and ETags; for a private repository that includes the
|
|
337
|
+
release JSON, in the user's 0700 cache directory). No other token sources
|
|
338
|
+
are searched.
|
|
339
|
+
* Rate limits: a 403/429 with `X-RateLimit-Remaining: 0` (or `Retry-After`)
|
|
340
|
+
pauses checks until the reset time, persisted in the cache file; ETags make
|
|
341
|
+
repeated checks conditional.
|
|
342
|
+
* Background checks are silent on failure (`debug` log, `warning` if
|
|
343
|
+
`silent_on_failure = false`); messages contain error types and hosts, not
|
|
344
|
+
credentials.
|
|
345
|
+
|
|
346
|
+
## Limitations
|
|
347
|
+
|
|
348
|
+
* Linux x86_64 is the only platform tested end to end (real runtime, real
|
|
349
|
+
installer, real launcher). Windows (zip, `msvcrt` locking, no `exec`: the
|
|
350
|
+
launcher waits for the app) and macOS are implemented but untested; the
|
|
351
|
+
installer script is Linux only.
|
|
352
|
+
* No signed manifests (see the accepted risk above).
|
|
353
|
+
* Cross-platform release builds are not supported: build on each platform.
|
|
354
|
+
* A trial that the user closes before the page confirmed counts as failed
|
|
355
|
+
(rolled back at the next launch).
|
|
356
|
+
* Restart policy: nothing restarts the app on its own. A staged version
|
|
357
|
+
starts at the next launch; an app may offer "restart now" and call
|
|
358
|
+
`UpdateManager.relaunch()` after `app.run()` returned (POSIX `exec`; the
|
|
359
|
+
restarted launcher takes over the inherited launch lock).
|
|
360
|
+
* Manual checks (`neutralino updates check`, `UpdateManager.check()`) raise
|
|
361
|
+
or print typed, actionable errors; background checks never raise and log
|
|
362
|
+
at debug level (`silent_on_failure = true`).
|
|
363
|
+
* A remote private-repository smoke against github.com is not part of the
|
|
364
|
+
automated tests (it needs owner-authorized credentials and a fixture
|
|
365
|
+
repository); the private flow is tested against a local fake API and a fake
|
|
366
|
+
`gh`.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Installed examples
|
|
2
|
+
|
|
3
|
+
Each subdirectory of this folder is one example application that
|
|
4
|
+
`neutralino examples list` shows and `neutralino examples export <name> <dir>`
|
|
5
|
+
copies (never overwriting a changed file without `--force`). This README is
|
|
6
|
+
not an example; the reference examples are added by the documentation phase.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SQLite CRUD: an editable, filterable, virtualized table over 100 000 synthetic rows
|
|
2
|
+
|
|
3
|
+
A `neutralino.ui` app. Only Python opens the SQLite file. `ui.DataTable(provider=...,
|
|
4
|
+
virtual=True)` renders the rows in view and asks Python for one bounded window at a time
|
|
5
|
+
(offset/limit, a whitelisted sort column, the search box and the per-column filters on Name
|
|
6
|
+
and Category as bound SQL parameters); the page never holds the 100 000 rows. Create with a
|
|
7
|
+
validated form, update with inline cell edits (Name, Qty; checked again in Python), delete
|
|
8
|
+
with a row action that asks first. Pure Python, no Node.js.
|
|
9
|
+
|
|
10
|
+
## Run
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
neutralino runtime install # once: the pinned Neutralino runtime
|
|
14
|
+
python app.py items.db # a database file that persists between runs
|
|
15
|
+
python app.py # or: a fresh temporary database
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Build
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
neutralino build # portable app in dist/<folder name>/, start it with run.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Expected output
|
|
25
|
+
|
|
26
|
+
A window titled `Inventory` with the add form (Name, Category, Qty, `Add item`),
|
|
27
|
+
`100,000 items` and the table starting with `item 000000` (`hardware`, `0`). Adding a row
|
|
28
|
+
prints `added #100001`; an empty name prints `not added: the name is empty`; editing a Qty
|
|
29
|
+
to `-1` prints `not saved: the quantity must be between 0 and 1,000,000`; deleting asks
|
|
30
|
+
`Delete <name>?`.
|
|
31
|
+
|
|
32
|
+
## Test
|
|
33
|
+
|
|
34
|
+
From the installed wheel: `tests/integration/test_examples_installed.py` (window, total and
|
|
35
|
+
the first virtual rows). The same store and table contract over 100 000 rows (paged
|
|
36
|
+
variant): `tests/ui/test_patterns_p06_native.py::test_sqlite_crud_and_bounded_pages_over_100k_rows`.
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"""SQLite CRUD: an editable, filterable, virtualized table over 100 000 synthetic rows.
|
|
2
|
+
|
|
3
|
+
Run: python app.py [DATABASE] (without DATABASE: a fresh temporary file)
|
|
4
|
+
|
|
5
|
+
Ported from ``examples/patterns/sqlite.py`` and extended. The database is a ``sqlite3``
|
|
6
|
+
file that only Python opens: the page never sees a path, SQL or the connection.
|
|
7
|
+
``ui.DataTable(provider=..., virtual=True)`` renders only the rows in view and asks
|
|
8
|
+
``Store.page`` for one bounded window at a time (offset/limit, a whitelisted sort column,
|
|
9
|
+
the search text and the per-column filters as bound parameters). Create: a validated
|
|
10
|
+
``ui.Form``. Update: inline cell edits (name, quantity), checked again in Python. Delete: a
|
|
11
|
+
row action that asks for confirmation first.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import sqlite3
|
|
18
|
+
import sys
|
|
19
|
+
import tempfile
|
|
20
|
+
import threading
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
from neutralino import ui
|
|
25
|
+
|
|
26
|
+
CATEGORIES = ["hardware", "software", "service", "spare part"]
|
|
27
|
+
SORTABLE = {"id", "name", "category", "qty"}
|
|
28
|
+
MAX_PAGE = 200
|
|
29
|
+
SEED_ROWS = 100_000
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Invalid(ValueError):
|
|
33
|
+
"""A value the store refuses (the message is shown to the user)."""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def check_name(name: object) -> str:
|
|
37
|
+
text = str(name or "").strip()
|
|
38
|
+
if not text:
|
|
39
|
+
raise Invalid("the name is empty")
|
|
40
|
+
if len(text) > 80:
|
|
41
|
+
raise Invalid("the name is longer than 80 characters")
|
|
42
|
+
return text
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def check_qty(qty: object) -> int:
|
|
46
|
+
if isinstance(qty, bool) or not isinstance(qty, (int, float)) or qty != int(qty):
|
|
47
|
+
raise Invalid("the quantity must be a whole number")
|
|
48
|
+
if not 0 <= qty <= 1_000_000:
|
|
49
|
+
raise Invalid("the quantity must be between 0 and 1,000,000")
|
|
50
|
+
return int(qty)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Store:
|
|
54
|
+
"""One sqlite file, one connection, one lock."""
|
|
55
|
+
|
|
56
|
+
def __init__(self, path: Path, seed: int = SEED_ROWS) -> None:
|
|
57
|
+
self.path = path
|
|
58
|
+
self.fetched = 0 # rows returned by ``page`` since the start
|
|
59
|
+
self._lock = threading.Lock()
|
|
60
|
+
self._db = sqlite3.connect(path, check_same_thread=False)
|
|
61
|
+
self._db.row_factory = sqlite3.Row
|
|
62
|
+
with self._lock, self._db:
|
|
63
|
+
self._db.execute(
|
|
64
|
+
"CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT NOT NULL,"
|
|
65
|
+
" category TEXT NOT NULL, qty INTEGER NOT NULL)"
|
|
66
|
+
)
|
|
67
|
+
if self._db.execute("SELECT COUNT(*) FROM items").fetchone()[0] == 0 and seed:
|
|
68
|
+
self._db.executemany(
|
|
69
|
+
"INSERT INTO items (name, category, qty) VALUES (?, ?, ?)",
|
|
70
|
+
(
|
|
71
|
+
(f"item {i:06d}", CATEGORIES[i % len(CATEGORIES)], i % 97)
|
|
72
|
+
for i in range(seed)
|
|
73
|
+
),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def _where(self, q: ui.TableQuery) -> tuple[str, list[Any]]:
|
|
77
|
+
parts: list[str] = []
|
|
78
|
+
args: list[Any] = []
|
|
79
|
+
if q.search:
|
|
80
|
+
parts.append("name LIKE ? ESCAPE '\\'")
|
|
81
|
+
args.append(_like(q.search))
|
|
82
|
+
name = q.filters.get("name")
|
|
83
|
+
if isinstance(name, str) and name:
|
|
84
|
+
parts.append("name LIKE ? ESCAPE '\\'")
|
|
85
|
+
args.append(_like(name))
|
|
86
|
+
category = q.filters.get("category")
|
|
87
|
+
if isinstance(category, str) and category in CATEGORIES:
|
|
88
|
+
parts.append("category = ?")
|
|
89
|
+
args.append(category)
|
|
90
|
+
return (" WHERE " + " AND ".join(parts) if parts else ""), args
|
|
91
|
+
|
|
92
|
+
def count(self, q: ui.TableQuery | None = None) -> int:
|
|
93
|
+
where, args = self._where(q or ui.TableQuery())
|
|
94
|
+
with self._lock:
|
|
95
|
+
return int(self._db.execute(f"SELECT COUNT(*) FROM items{where}", args).fetchone()[0])
|
|
96
|
+
|
|
97
|
+
def page(self, q: ui.TableQuery) -> ui.TablePage:
|
|
98
|
+
"""One window of rows. ``limit`` is capped, ``sort`` is checked against ``SORTABLE``."""
|
|
99
|
+
order = (
|
|
100
|
+
f" ORDER BY {q.sort} {'DESC' if q.direction == 'desc' else 'ASC'}, id"
|
|
101
|
+
if q.sort in SORTABLE
|
|
102
|
+
else " ORDER BY id"
|
|
103
|
+
)
|
|
104
|
+
where, args = self._where(q)
|
|
105
|
+
limit = max(1, min(int(q.limit), MAX_PAGE))
|
|
106
|
+
with self._lock:
|
|
107
|
+
rows = self._db.execute(
|
|
108
|
+
f"SELECT id, name, category, qty FROM items{where}{order} LIMIT ? OFFSET ?",
|
|
109
|
+
[*args, limit, max(0, int(q.offset))],
|
|
110
|
+
).fetchall()
|
|
111
|
+
total = int(self._db.execute(f"SELECT COUNT(*) FROM items{where}", args).fetchone()[0])
|
|
112
|
+
self.fetched += len(rows)
|
|
113
|
+
return ui.TablePage(rows=[dict(r) for r in rows], total=total)
|
|
114
|
+
|
|
115
|
+
def add(self, name: object, category: object, qty: object) -> int:
|
|
116
|
+
if category not in CATEGORIES:
|
|
117
|
+
raise Invalid("choose a category")
|
|
118
|
+
values = (check_name(name), category, check_qty(qty))
|
|
119
|
+
with self._lock, self._db:
|
|
120
|
+
cur = self._db.execute(
|
|
121
|
+
"INSERT INTO items (name, category, qty) VALUES (?, ?, ?)", values
|
|
122
|
+
)
|
|
123
|
+
return int(cur.lastrowid or 0)
|
|
124
|
+
|
|
125
|
+
def update(self, item_id: int, column: str, value: object) -> None:
|
|
126
|
+
checked: Any
|
|
127
|
+
if column == "name":
|
|
128
|
+
checked = check_name(value)
|
|
129
|
+
elif column == "qty":
|
|
130
|
+
checked = check_qty(value)
|
|
131
|
+
else:
|
|
132
|
+
raise Invalid(f"{column} cannot be edited")
|
|
133
|
+
with self._lock, self._db:
|
|
134
|
+
cur = self._db.execute(
|
|
135
|
+
f"UPDATE items SET {column} = ? WHERE id = ?", (checked, item_id)
|
|
136
|
+
)
|
|
137
|
+
if cur.rowcount != 1:
|
|
138
|
+
raise Invalid(f"item {item_id} does not exist")
|
|
139
|
+
|
|
140
|
+
def delete(self, item_id: int) -> bool:
|
|
141
|
+
with self._lock, self._db:
|
|
142
|
+
return self._db.execute("DELETE FROM items WHERE id = ?", (item_id,)).rowcount == 1
|
|
143
|
+
|
|
144
|
+
def get(self, item_id: int) -> dict[str, Any] | None:
|
|
145
|
+
with self._lock:
|
|
146
|
+
row = self._db.execute(
|
|
147
|
+
"SELECT id, name, category, qty FROM items WHERE id = ?", (item_id,)
|
|
148
|
+
).fetchone()
|
|
149
|
+
return dict(row) if row else None
|
|
150
|
+
|
|
151
|
+
def close(self) -> None:
|
|
152
|
+
with self._lock:
|
|
153
|
+
self._db.close()
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _like(text: str) -> str:
|
|
157
|
+
return "%" + text.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_") + "%"
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def build(
|
|
161
|
+
app: ui.Application | ui.AsyncApplication, path: Path | None = None, seed: int = SEED_ROWS
|
|
162
|
+
) -> dict[str, Any]:
|
|
163
|
+
store = Store(path or Path(tempfile.mkdtemp(prefix="neutralino-crud-")) / "items.db", seed)
|
|
164
|
+
columns = [
|
|
165
|
+
ui.Column("id", "ID", kind="number", sortable=True, width=90),
|
|
166
|
+
ui.Column("name", "Name", sortable=True, editable=True, filter="text"),
|
|
167
|
+
ui.Column("category", "Category", sortable=True, filter="select", options=CATEGORIES),
|
|
168
|
+
ui.Column("qty", "Qty", kind="number", sortable=True, editable=True, width=110),
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
def show_total() -> None:
|
|
172
|
+
total.update(text=f"{store.count():,} items")
|
|
173
|
+
|
|
174
|
+
def added(ev: ui.SubmitEvent) -> None:
|
|
175
|
+
v = ev.values
|
|
176
|
+
try:
|
|
177
|
+
new_id = store.add(v.get("name"), v.get("category"), v.get("qty"))
|
|
178
|
+
except Invalid as err:
|
|
179
|
+
status.update(text=f"not added: {err}")
|
|
180
|
+
return
|
|
181
|
+
table.refresh()
|
|
182
|
+
show_total()
|
|
183
|
+
status.update(text=f"added #{new_id}")
|
|
184
|
+
|
|
185
|
+
def edited(ev: ui.TableEvent) -> None:
|
|
186
|
+
item_id, column = int(ev.keys[0]), str(ev.column)
|
|
187
|
+
try:
|
|
188
|
+
store.update(item_id, column, ev.value)
|
|
189
|
+
except Invalid as err:
|
|
190
|
+
status.update(text=f"not saved: {err}")
|
|
191
|
+
else:
|
|
192
|
+
status.update(text=f"saved #{item_id} {column}")
|
|
193
|
+
table.refresh()
|
|
194
|
+
|
|
195
|
+
def acted(ev: ui.RowActionEvent) -> None:
|
|
196
|
+
if ev.action == "delete" and store.delete(int(ev.key)):
|
|
197
|
+
show_total()
|
|
198
|
+
status.update(text=f"deleted #{ev.key}")
|
|
199
|
+
table.refresh()
|
|
200
|
+
|
|
201
|
+
with app.page("/"), ui.Stack(gap="sm", p="md"):
|
|
202
|
+
ui.Title("Inventory", order=3)
|
|
203
|
+
with ui.Form(on_submit=added) as form, ui.Group(align="flex-end"):
|
|
204
|
+
name = ui.TextInput(name="name", label="Name", required=True)
|
|
205
|
+
category = ui.Select(name="category", label="Category", data=CATEGORIES,
|
|
206
|
+
value=CATEGORIES[0]) # fmt: skip
|
|
207
|
+
qty = ui.NumberInput(name="qty", label="Qty", value=1, min=0)
|
|
208
|
+
add = ui.Button("Add item", type="submit")
|
|
209
|
+
total = ui.Text("", size="sm", dimmed=True)
|
|
210
|
+
status = ui.Text("", size="xs", dimmed=True)
|
|
211
|
+
table = ui.DataTable(
|
|
212
|
+
columns=[c.to_json() for c in columns],
|
|
213
|
+
provider=store.page,
|
|
214
|
+
page_size=100,
|
|
215
|
+
virtual=True,
|
|
216
|
+
height=420,
|
|
217
|
+
row_height=36,
|
|
218
|
+
searchable=True,
|
|
219
|
+
row_actions=[
|
|
220
|
+
ui.RowAction("delete", "Delete", color="red", confirm="Delete {name}?").to_json()
|
|
221
|
+
],
|
|
222
|
+
on_cell_edit=edited,
|
|
223
|
+
on_row_action=acted,
|
|
224
|
+
)
|
|
225
|
+
show_total()
|
|
226
|
+
return {
|
|
227
|
+
"store": store, "table": table, "form": form, "name": name, "category": category,
|
|
228
|
+
"qty": qty, "add": add, "total": total, "status": status,
|
|
229
|
+
} # fmt: skip
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def main(argv: list[str] | None = None) -> None:
|
|
233
|
+
args = sys.argv[1:] if argv is None else argv
|
|
234
|
+
app = ui.AsyncApplication(
|
|
235
|
+
title="Inventory", width=860, height=760, app_id="neutralino_example_crud",
|
|
236
|
+
profile="restricted",
|
|
237
|
+
) # fmt: skip
|
|
238
|
+
build(app, Path(args[0]).resolve() if args else None)
|
|
239
|
+
asyncio.run(app.run())
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
if __name__ == "__main__":
|
|
243
|
+
main()
|