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,543 @@
|
|
|
1
|
+
"""Typed schedule events and recurrence (``ui.Scheduler`` and the schedule views).
|
|
2
|
+
|
|
3
|
+
An event is a :class:`ScheduleEvent` (or a mapping with the same keys);
|
|
4
|
+
start/end follow the time-zone policy of :mod:`neutralino.ui._dates`.
|
|
5
|
+
All-day events use ``datetime.date`` start/end (end inclusive).
|
|
6
|
+
|
|
7
|
+
Recurrence is a validated RRULE subset (:class:`Recurrence`): ``FREQ``
|
|
8
|
+
DAILY/WEEKLY/MONTHLY/YEARLY, ``INTERVAL``, ``COUNT`` or ``UNTIL``, ``BYDAY``
|
|
9
|
+
(weekday codes; with an ordinal such as ``2TU``/``-1FR`` for MONTHLY only),
|
|
10
|
+
``BYMONTHDAY``, ``BYMONTH`` and ``WKST``. A recurring event may be sent as
|
|
11
|
+
is (the page expands it in the visible range) or expanded in Python with
|
|
12
|
+
:func:`expand_events` into ordinary events; both give the same
|
|
13
|
+
occurrences, in wall time (a 09:00 weekly meeting stays at 09:00 across a
|
|
14
|
+
DST change).
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import datetime as _dt
|
|
20
|
+
import re
|
|
21
|
+
from collections.abc import Iterable, Iterator, Mapping, Sequence
|
|
22
|
+
from dataclasses import dataclass, field, replace
|
|
23
|
+
from typing import Any, Literal, cast
|
|
24
|
+
|
|
25
|
+
from ..errors import ValidationError
|
|
26
|
+
from ..types import JSONValue
|
|
27
|
+
from ._dates import from_wall, parse_date, parse_datetime, to_wall, wire_datetime
|
|
28
|
+
from ._protocol import check_value, to_wire
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"Recurrence",
|
|
32
|
+
"RecurrenceRule",
|
|
33
|
+
"ScheduleEvent",
|
|
34
|
+
"expand_events",
|
|
35
|
+
"parse_rrule",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
_ID_STR_MAX = 200
|
|
39
|
+
_WEEKDAYS = ("MO", "TU", "WE", "TH", "FR", "SA", "SU") # index = date.weekday()
|
|
40
|
+
_FREQS = ("DAILY", "WEEKLY", "MONTHLY", "YEARLY")
|
|
41
|
+
_RRULE_KEYS = {"FREQ", "INTERVAL", "COUNT", "UNTIL", "BYDAY", "BYMONTHDAY", "BYMONTH", "WKST"}
|
|
42
|
+
_BYDAY_RE = re.compile(r"^([+-]?[1-5])?(MO|TU|WE|TH|FR|SA|SU)$")
|
|
43
|
+
_MAX_SCAN_DAYS = 366 * 60
|
|
44
|
+
_MAX_OCCURRENCES = 10_000
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# ------------------------------------------------------------------- rrule
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class RecurrenceRule:
|
|
50
|
+
"""A parsed RRULE of the supported subset."""
|
|
51
|
+
|
|
52
|
+
freq: Literal["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]
|
|
53
|
+
interval: int = 1
|
|
54
|
+
count: int | None = None
|
|
55
|
+
until: _dt.datetime | None = None # wall time, inclusive
|
|
56
|
+
byday: tuple[tuple[int, int], ...] = () # (ordinal or 0, weekday 0=MO)
|
|
57
|
+
bymonthday: tuple[int, ...] = ()
|
|
58
|
+
bymonth: tuple[int, ...] = ()
|
|
59
|
+
wkst: int = 0
|
|
60
|
+
|
|
61
|
+
def __str__(self) -> str:
|
|
62
|
+
parts = [f"FREQ={self.freq}"]
|
|
63
|
+
if self.interval != 1:
|
|
64
|
+
parts.append(f"INTERVAL={self.interval}")
|
|
65
|
+
if self.count is not None:
|
|
66
|
+
parts.append(f"COUNT={self.count}")
|
|
67
|
+
if self.until is not None:
|
|
68
|
+
parts.append("UNTIL=" + self.until.strftime("%Y%m%dT%H%M%S"))
|
|
69
|
+
if self.byday:
|
|
70
|
+
parts.append("BYDAY=" + ",".join(f"{n or ''}{_WEEKDAYS[w]}" for n, w in self.byday))
|
|
71
|
+
if self.bymonthday:
|
|
72
|
+
parts.append("BYMONTHDAY=" + ",".join(map(str, self.bymonthday)))
|
|
73
|
+
if self.bymonth:
|
|
74
|
+
parts.append("BYMONTH=" + ",".join(map(str, self.bymonth)))
|
|
75
|
+
if self.wkst:
|
|
76
|
+
parts.append(f"WKST={_WEEKDAYS[self.wkst]}")
|
|
77
|
+
return ";".join(parts)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _int(v: str, key: str, lo: int, hi: int) -> int:
|
|
81
|
+
if not re.fullmatch(r"[+-]?\d{1,6}", v):
|
|
82
|
+
raise ValidationError(f"rrule {key}: expected an integer")
|
|
83
|
+
n = int(v)
|
|
84
|
+
if not lo <= n <= hi:
|
|
85
|
+
raise ValidationError(f"rrule {key}: {n} is outside {lo}..{hi}")
|
|
86
|
+
return n
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def parse_rrule(rule: str) -> RecurrenceRule:
|
|
90
|
+
"""Parse and validate an RRULE string of the supported subset."""
|
|
91
|
+
raw: Any = rule
|
|
92
|
+
if not isinstance(raw, str) or not 0 < len(raw) <= 500:
|
|
93
|
+
raise ValidationError("rrule: expected a non-empty string (max 500 characters)")
|
|
94
|
+
s = rule.strip()
|
|
95
|
+
if s.upper().startswith("RRULE:"):
|
|
96
|
+
s = s[6:]
|
|
97
|
+
if "\n" in s or "\r" in s:
|
|
98
|
+
raise ValidationError("rrule: a single RRULE line is expected")
|
|
99
|
+
fields: dict[str, str] = {}
|
|
100
|
+
for part in s.split(";"):
|
|
101
|
+
if not part:
|
|
102
|
+
continue
|
|
103
|
+
key, sep, val = part.partition("=")
|
|
104
|
+
key = key.strip().upper()
|
|
105
|
+
if not sep or not val:
|
|
106
|
+
raise ValidationError(f"rrule: malformed part {part[:40]!r}")
|
|
107
|
+
if key not in _RRULE_KEYS:
|
|
108
|
+
raise ValidationError(
|
|
109
|
+
f"rrule: {key} is not supported (supported: {sorted(_RRULE_KEYS)})"
|
|
110
|
+
)
|
|
111
|
+
if key in fields:
|
|
112
|
+
raise ValidationError(f"rrule: {key} given twice")
|
|
113
|
+
fields[key] = val.strip().upper()
|
|
114
|
+
freq = fields.get("FREQ")
|
|
115
|
+
if freq not in _FREQS:
|
|
116
|
+
raise ValidationError(f"rrule: FREQ must be one of {list(_FREQS)}")
|
|
117
|
+
interval = _int(fields["INTERVAL"], "INTERVAL", 1, 1000) if "INTERVAL" in fields else 1
|
|
118
|
+
count = _int(fields["COUNT"], "COUNT", 1, _MAX_OCCURRENCES) if "COUNT" in fields else None
|
|
119
|
+
until: _dt.datetime | None = None
|
|
120
|
+
if "UNTIL" in fields:
|
|
121
|
+
if count is not None:
|
|
122
|
+
raise ValidationError("rrule: COUNT and UNTIL cannot both be given")
|
|
123
|
+
u = fields["UNTIL"].rstrip("Z")
|
|
124
|
+
try:
|
|
125
|
+
if len(u) == 8:
|
|
126
|
+
until = _dt.datetime.strptime(u, "%Y%m%d").replace(hour=23, minute=59, second=59)
|
|
127
|
+
else:
|
|
128
|
+
until = _dt.datetime.strptime(u, "%Y%m%dT%H%M%S")
|
|
129
|
+
except ValueError:
|
|
130
|
+
raise ValidationError("rrule UNTIL: expected YYYYMMDD or YYYYMMDDTHHMMSS") from None
|
|
131
|
+
byday: list[tuple[int, int]] = []
|
|
132
|
+
if "BYDAY" in fields:
|
|
133
|
+
for item in fields["BYDAY"].split(","):
|
|
134
|
+
m = _BYDAY_RE.fullmatch(item)
|
|
135
|
+
if not m:
|
|
136
|
+
raise ValidationError(f"rrule BYDAY: invalid value {item[:10]!r}")
|
|
137
|
+
n = int(m.group(1)) if m.group(1) else 0
|
|
138
|
+
if n and freq != "MONTHLY":
|
|
139
|
+
raise ValidationError(
|
|
140
|
+
"rrule BYDAY: ordinals (e.g. 2TU) are supported for MONTHLY only"
|
|
141
|
+
)
|
|
142
|
+
byday.append((n, _WEEKDAYS.index(m.group(2))))
|
|
143
|
+
if freq == "YEARLY":
|
|
144
|
+
raise ValidationError("rrule: BYDAY is not supported with FREQ=YEARLY")
|
|
145
|
+
bymonthday = tuple(
|
|
146
|
+
_int(x, "BYMONTHDAY", -31, 31) for x in fields.get("BYMONTHDAY", "").split(",") if x
|
|
147
|
+
)
|
|
148
|
+
if 0 in bymonthday:
|
|
149
|
+
raise ValidationError("rrule BYMONTHDAY: 0 is not a day")
|
|
150
|
+
if bymonthday and byday and freq == "MONTHLY":
|
|
151
|
+
raise ValidationError("rrule: BYMONTHDAY and BYDAY cannot be combined")
|
|
152
|
+
bymonth = tuple(_int(x, "BYMONTH", 1, 12) for x in fields.get("BYMONTH", "").split(",") if x)
|
|
153
|
+
wkst = 0
|
|
154
|
+
if "WKST" in fields:
|
|
155
|
+
if fields["WKST"] not in _WEEKDAYS:
|
|
156
|
+
raise ValidationError("rrule WKST: expected a weekday code")
|
|
157
|
+
wkst = _WEEKDAYS.index(fields["WKST"])
|
|
158
|
+
return RecurrenceRule(
|
|
159
|
+
freq=freq,
|
|
160
|
+
interval=interval,
|
|
161
|
+
count=count,
|
|
162
|
+
until=until,
|
|
163
|
+
byday=tuple(byday),
|
|
164
|
+
bymonthday=bymonthday,
|
|
165
|
+
bymonth=bymonth,
|
|
166
|
+
wkst=wkst,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _days_in_month(d: _dt.date) -> int:
|
|
171
|
+
nxt = (d.replace(day=1) + _dt.timedelta(days=32)).replace(day=1)
|
|
172
|
+
return (nxt - _dt.timedelta(days=1)).day
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _nth_weekday(d: _dt.date) -> tuple[int, int]:
|
|
176
|
+
"""(n-th from the start, n-th from the end as negative) of d's weekday in its month."""
|
|
177
|
+
return (d.day - 1) // 7 + 1, -((_days_in_month(d) - d.day) // 7 + 1)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _matches(rule: RecurrenceRule, d0: _dt.date, d: _dt.date) -> bool:
|
|
181
|
+
if rule.bymonth and d.month not in rule.bymonth:
|
|
182
|
+
return False
|
|
183
|
+
if rule.freq == "DAILY":
|
|
184
|
+
if (d - d0).days % rule.interval:
|
|
185
|
+
return False
|
|
186
|
+
elif rule.freq == "WEEKLY":
|
|
187
|
+
if ((_week_start(d, rule.wkst) - _week_start(d0, rule.wkst)).days // 7) % rule.interval:
|
|
188
|
+
return False
|
|
189
|
+
days = {w for _, w in rule.byday} or {d0.weekday()}
|
|
190
|
+
return d.weekday() in days and (not rule.bymonthday or _monthday_ok(rule, d))
|
|
191
|
+
elif rule.freq == "MONTHLY":
|
|
192
|
+
if ((d.year - d0.year) * 12 + d.month - d0.month) % rule.interval:
|
|
193
|
+
return False
|
|
194
|
+
elif (d.year - d0.year) % rule.interval or (not rule.bymonth and d.month != d0.month): # YEARLY
|
|
195
|
+
return False
|
|
196
|
+
if rule.byday:
|
|
197
|
+
first, last = _nth_weekday(d)
|
|
198
|
+
return any(w == d.weekday() and n in (0, first, last) for n, w in rule.byday)
|
|
199
|
+
if rule.bymonthday:
|
|
200
|
+
return _monthday_ok(rule, d)
|
|
201
|
+
if rule.freq in ("MONTHLY", "YEARLY"):
|
|
202
|
+
return d.day == d0.day
|
|
203
|
+
return True
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _week_start(d: _dt.date, wkst: int) -> _dt.date:
|
|
207
|
+
return d - _dt.timedelta(days=(d.weekday() - wkst) % 7)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _monthday_ok(rule: RecurrenceRule, d: _dt.date) -> bool:
|
|
211
|
+
neg = d.day - _days_in_month(d) - 1
|
|
212
|
+
return d.day in rule.bymonthday or neg in rule.bymonthday
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _starts(
|
|
216
|
+
rule: RecurrenceRule, dtstart: _dt.datetime, until: _dt.datetime
|
|
217
|
+
) -> Iterator[_dt.datetime]:
|
|
218
|
+
"""Occurrence starts (wall time) from ``dtstart`` up to ``until`` (inclusive)."""
|
|
219
|
+
d0 = dtstart.date()
|
|
220
|
+
t = dtstart.time()
|
|
221
|
+
emitted = 0
|
|
222
|
+
for i in range(_MAX_SCAN_DAYS):
|
|
223
|
+
d = d0 + _dt.timedelta(days=i)
|
|
224
|
+
start = _dt.datetime.combine(d, t)
|
|
225
|
+
if start > until or (rule.until is not None and start > rule.until):
|
|
226
|
+
return
|
|
227
|
+
if _matches(rule, d0, d):
|
|
228
|
+
emitted += 1
|
|
229
|
+
yield start
|
|
230
|
+
if rule.count is not None and emitted >= rule.count:
|
|
231
|
+
return
|
|
232
|
+
raise ValidationError("rrule: the series is too long to expand (over 60 years of days)")
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
# ---------------------------------------------------------------- events
|
|
236
|
+
def _check_id(v: Any, what: str) -> str | int:
|
|
237
|
+
if isinstance(v, bool) or not isinstance(v, (str, int)):
|
|
238
|
+
raise ValidationError(f"{what}: expected a str or int")
|
|
239
|
+
if isinstance(v, str) and not 0 < len(v) <= _ID_STR_MAX:
|
|
240
|
+
raise ValidationError(f"{what}: 1..{_ID_STR_MAX} characters")
|
|
241
|
+
if isinstance(v, int) and not -(2**53 - 1) <= v <= 2**53 - 1:
|
|
242
|
+
raise ValidationError(f"{what}: outside the JavaScript safe integer range")
|
|
243
|
+
return v
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _as_moment(v: Any, what: str) -> _dt.datetime | _dt.date:
|
|
247
|
+
if isinstance(v, (_dt.datetime, _dt.date)):
|
|
248
|
+
return v
|
|
249
|
+
if isinstance(v, str) and len(v) <= 64:
|
|
250
|
+
return parse_date(v) if len(v) == 10 else _dt.datetime.fromisoformat(v)
|
|
251
|
+
raise ValidationError(f"{what}: expected a datetime, a date or an ISO string")
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@dataclass(frozen=True)
|
|
255
|
+
class Recurrence:
|
|
256
|
+
"""Recurrence of a series: ``rrule`` (validated subset), excluded
|
|
257
|
+
occurrence starts and an optional explicit series start."""
|
|
258
|
+
|
|
259
|
+
rrule: str
|
|
260
|
+
exdates: tuple[_dt.datetime, ...] = ()
|
|
261
|
+
dtstart: _dt.datetime | None = None
|
|
262
|
+
rule: RecurrenceRule = field(init=False, repr=False, compare=False)
|
|
263
|
+
|
|
264
|
+
def __post_init__(self) -> None:
|
|
265
|
+
object.__setattr__(self, "rule", parse_rrule(self.rrule))
|
|
266
|
+
object.__setattr__(self, "rrule", str(self.rule))
|
|
267
|
+
ex: list[_dt.datetime] = []
|
|
268
|
+
for i, v in enumerate(cast("Iterable[Any]", self.exdates)):
|
|
269
|
+
m = _as_moment(v, f"exdates[{i}]")
|
|
270
|
+
ex.append(m if isinstance(m, _dt.datetime) else _dt.datetime.combine(m, _dt.time()))
|
|
271
|
+
if len(ex) > 1000:
|
|
272
|
+
raise ValidationError("exdates: more than 1000")
|
|
273
|
+
object.__setattr__(self, "exdates", tuple(ex))
|
|
274
|
+
ds: Any = self.dtstart
|
|
275
|
+
if ds is not None and not isinstance(ds, _dt.datetime):
|
|
276
|
+
raise ValidationError("dtstart: expected a datetime")
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
@dataclass(frozen=True)
|
|
280
|
+
class ScheduleEvent:
|
|
281
|
+
"""One event of a schedule view.
|
|
282
|
+
|
|
283
|
+
``start``/``end`` are datetimes (naive = wall time, aware = converted to
|
|
284
|
+
the view's ``timezone``) or, for ``all_day`` events, dates with an
|
|
285
|
+
inclusive ``end``. ``color`` is a theme colour or CSS colour,
|
|
286
|
+
``resource_id`` places it in a resource view, ``recurrence`` makes it a
|
|
287
|
+
series; ``recurring_event_id``/``recurrence_id`` mark an override of one
|
|
288
|
+
occurrence of a series. ``data`` is application data kept in Python
|
|
289
|
+
(never sent to the page).
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
id: str | int
|
|
293
|
+
title: str
|
|
294
|
+
start: _dt.datetime | _dt.date
|
|
295
|
+
end: _dt.datetime | _dt.date
|
|
296
|
+
all_day: bool = False
|
|
297
|
+
color: str = "blue"
|
|
298
|
+
resource_id: str | int | None = None
|
|
299
|
+
variant: Literal["filled", "light"] | None = None
|
|
300
|
+
display: Literal["default", "background"] | None = None
|
|
301
|
+
recurrence: Recurrence | None = None
|
|
302
|
+
recurring_event_id: str | int | None = None
|
|
303
|
+
recurrence_id: _dt.datetime | None = None
|
|
304
|
+
data: Any = field(default=None, compare=False)
|
|
305
|
+
|
|
306
|
+
def __post_init__(self) -> None:
|
|
307
|
+
me: Any = self # runtime checks of the annotated fields
|
|
308
|
+
_check_id(me.id, "ScheduleEvent.id")
|
|
309
|
+
if not isinstance(me.title, str) or len(me.title) > 500:
|
|
310
|
+
raise ValidationError("ScheduleEvent.title: a str of at most 500 characters")
|
|
311
|
+
start = _as_moment(self.start, "ScheduleEvent.start")
|
|
312
|
+
end = _as_moment(self.end, "ScheduleEvent.end")
|
|
313
|
+
if not isinstance(me.all_day, bool):
|
|
314
|
+
raise ValidationError("ScheduleEvent.all_day: expected a bool")
|
|
315
|
+
if self.all_day:
|
|
316
|
+
start = start.date() if isinstance(start, _dt.datetime) else start
|
|
317
|
+
end = end.date() if isinstance(end, _dt.datetime) else end
|
|
318
|
+
else:
|
|
319
|
+
if not (isinstance(start, _dt.datetime) and isinstance(end, _dt.datetime)):
|
|
320
|
+
raise ValidationError(
|
|
321
|
+
"ScheduleEvent: timed events need datetime start/end "
|
|
322
|
+
"(use all_day=True for dates)"
|
|
323
|
+
)
|
|
324
|
+
if (start.utcoffset() is None) != (end.utcoffset() is None):
|
|
325
|
+
raise ValidationError(
|
|
326
|
+
"ScheduleEvent: start and end must both be naive or both aware"
|
|
327
|
+
)
|
|
328
|
+
if end < start: # pyright: ignore[reportOperatorIssue]
|
|
329
|
+
raise ValidationError("ScheduleEvent: end is before start")
|
|
330
|
+
object.__setattr__(self, "start", start)
|
|
331
|
+
object.__setattr__(self, "end", end)
|
|
332
|
+
if not isinstance(me.color, str) or not 0 < len(me.color) <= 64:
|
|
333
|
+
raise ValidationError("ScheduleEvent.color: a theme colour name or CSS colour")
|
|
334
|
+
if self.resource_id is not None:
|
|
335
|
+
_check_id(self.resource_id, "ScheduleEvent.resource_id")
|
|
336
|
+
if self.variant not in (None, "filled", "light"):
|
|
337
|
+
raise ValidationError("ScheduleEvent.variant: 'filled' or 'light'")
|
|
338
|
+
if self.display not in (None, "default", "background"):
|
|
339
|
+
raise ValidationError("ScheduleEvent.display: 'default' or 'background'")
|
|
340
|
+
if me.recurrence is not None and not isinstance(me.recurrence, Recurrence):
|
|
341
|
+
object.__setattr__(self, "recurrence", _recurrence(self.recurrence))
|
|
342
|
+
if (self.recurring_event_id is None) != (self.recurrence_id is None):
|
|
343
|
+
raise ValidationError("ScheduleEvent: recurring_event_id and recurrence_id go together")
|
|
344
|
+
if self.recurring_event_id is not None:
|
|
345
|
+
_check_id(self.recurring_event_id, "ScheduleEvent.recurring_event_id")
|
|
346
|
+
if self.recurrence is not None:
|
|
347
|
+
raise ValidationError("ScheduleEvent: an occurrence override cannot recur")
|
|
348
|
+
|
|
349
|
+
# ----------------------------------------------------------- helpers
|
|
350
|
+
@classmethod
|
|
351
|
+
def from_mapping(cls, m: Mapping[str, Any]) -> ScheduleEvent:
|
|
352
|
+
"""Build from a mapping with the field names (``resourceId`` etc. also accepted)."""
|
|
353
|
+
alias = {
|
|
354
|
+
"resourceId": "resource_id",
|
|
355
|
+
"allDay": "all_day",
|
|
356
|
+
"recurringEventId": "recurring_event_id",
|
|
357
|
+
"recurrenceId": "recurrence_id",
|
|
358
|
+
}
|
|
359
|
+
kw = {alias.get(k, k): v for k, v in m.items()}
|
|
360
|
+
unknown = set(kw) - set(cls.__dataclass_fields__)
|
|
361
|
+
if unknown:
|
|
362
|
+
raise ValidationError(f"ScheduleEvent: unknown keys {sorted(unknown)}")
|
|
363
|
+
rid = kw.get("recurrence_id")
|
|
364
|
+
if isinstance(rid, str):
|
|
365
|
+
kw["recurrence_id"] = parse_datetime(rid)
|
|
366
|
+
return cls(**kw)
|
|
367
|
+
|
|
368
|
+
def wall_span(self, tz: _dt.tzinfo | None = None) -> tuple[_dt.datetime, _dt.datetime]:
|
|
369
|
+
"""Start and end as naive wall times (all-day: midnight to next midnight)."""
|
|
370
|
+
if self.all_day:
|
|
371
|
+
s = cast("_dt.date", self.start)
|
|
372
|
+
e = cast("_dt.date", self.end)
|
|
373
|
+
return (
|
|
374
|
+
_dt.datetime.combine(s, _dt.time()),
|
|
375
|
+
_dt.datetime.combine(e + _dt.timedelta(days=1), _dt.time()),
|
|
376
|
+
)
|
|
377
|
+
return (
|
|
378
|
+
to_wall(cast("_dt.datetime", self.start), tz),
|
|
379
|
+
to_wall(cast("_dt.datetime", self.end), tz),
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
def overlaps(self, start: _dt.date, end: _dt.date, tz: _dt.tzinfo | None = None) -> bool:
|
|
383
|
+
"""Whether the event (or its series) touches the inclusive day range."""
|
|
384
|
+
s, e = self.wall_span(tz)
|
|
385
|
+
lo = _dt.datetime.combine(start, _dt.time())
|
|
386
|
+
hi = _dt.datetime.combine(end + _dt.timedelta(days=1), _dt.time())
|
|
387
|
+
if self.recurrence is not None:
|
|
388
|
+
first = to_wall(self.recurrence.dtstart, tz) if self.recurrence.dtstart else s
|
|
389
|
+
rule = self.recurrence.rule
|
|
390
|
+
if first >= hi or (rule.until is not None and rule.until + (e - s) < lo):
|
|
391
|
+
return False
|
|
392
|
+
return any(True for _ in _occurrences(self, lo, hi, tz))
|
|
393
|
+
return s < hi and e >= lo
|
|
394
|
+
|
|
395
|
+
def to_wire(self, tz: _dt.tzinfo | None = None) -> dict[str, JSONValue]:
|
|
396
|
+
s, e = self.wall_span(tz)
|
|
397
|
+
out: dict[str, JSONValue] = {
|
|
398
|
+
"id": self.id,
|
|
399
|
+
"title": self.title,
|
|
400
|
+
"start": wire_datetime(s),
|
|
401
|
+
"end": wire_datetime(e),
|
|
402
|
+
"color": self.color,
|
|
403
|
+
}
|
|
404
|
+
if self.resource_id is not None:
|
|
405
|
+
out["resourceId"] = self.resource_id
|
|
406
|
+
if self.variant is not None:
|
|
407
|
+
out["variant"] = self.variant
|
|
408
|
+
if self.display is not None:
|
|
409
|
+
out["display"] = self.display
|
|
410
|
+
if self.recurrence is not None:
|
|
411
|
+
rec: dict[str, JSONValue] = {
|
|
412
|
+
"rrule": self.recurrence.rrule,
|
|
413
|
+
"exdate": [wire_datetime(to_wall(x, tz)) for x in self.recurrence.exdates],
|
|
414
|
+
}
|
|
415
|
+
if self.recurrence.dtstart is not None:
|
|
416
|
+
rec["dtstart"] = wire_datetime(to_wall(self.recurrence.dtstart, tz))
|
|
417
|
+
out["recurrence"] = rec
|
|
418
|
+
if self.recurring_event_id is not None and self.recurrence_id is not None:
|
|
419
|
+
out["recurringEventId"] = self.recurring_event_id
|
|
420
|
+
out["recurrenceId"] = wire_datetime(to_wall(self.recurrence_id, tz))
|
|
421
|
+
check_value(out, path="event")
|
|
422
|
+
return cast("dict[str, JSONValue]", to_wire(out))
|
|
423
|
+
|
|
424
|
+
def moved(
|
|
425
|
+
self,
|
|
426
|
+
start: _dt.datetime | _dt.date,
|
|
427
|
+
end: _dt.datetime | _dt.date,
|
|
428
|
+
resource_id: str | int | None = None,
|
|
429
|
+
) -> ScheduleEvent:
|
|
430
|
+
"""A copy at a new placement (same kind of values as the original)."""
|
|
431
|
+
rid = self.resource_id if resource_id is None else resource_id
|
|
432
|
+
return replace(self, start=start, end=end, resource_id=rid)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def _recurrence(v: Any) -> Recurrence:
|
|
436
|
+
if isinstance(v, str):
|
|
437
|
+
return Recurrence(v)
|
|
438
|
+
if isinstance(v, Mapping):
|
|
439
|
+
m = cast("Mapping[str, Any]", v)
|
|
440
|
+
unknown = set(m) - {"rrule", "exdates", "exdate", "dtstart"}
|
|
441
|
+
if unknown:
|
|
442
|
+
raise ValidationError(f"recurrence: unknown keys {sorted(unknown)}")
|
|
443
|
+
ds = m.get("dtstart")
|
|
444
|
+
return Recurrence(
|
|
445
|
+
str(m.get("rrule", "")),
|
|
446
|
+
tuple(m.get("exdates", m.get("exdate", ()))),
|
|
447
|
+
parse_datetime(ds) if isinstance(ds, str) else ds,
|
|
448
|
+
)
|
|
449
|
+
raise ValidationError("recurrence: a Recurrence, an RRULE string or a mapping")
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def as_event(v: Any) -> ScheduleEvent:
|
|
453
|
+
if isinstance(v, ScheduleEvent):
|
|
454
|
+
return v
|
|
455
|
+
if isinstance(v, Mapping):
|
|
456
|
+
return ScheduleEvent.from_mapping(cast("Mapping[str, Any]", v))
|
|
457
|
+
raise ValidationError("events: expected ScheduleEvent objects or mappings")
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def _occurrences(
|
|
461
|
+
series: ScheduleEvent, lo: _dt.datetime, hi: _dt.datetime, tz: _dt.tzinfo | None
|
|
462
|
+
) -> Iterator[tuple[_dt.datetime, _dt.datetime]]:
|
|
463
|
+
"""Wall-time (start, end) of the series' occurrences touching [lo, hi)."""
|
|
464
|
+
rec = series.recurrence
|
|
465
|
+
assert rec is not None
|
|
466
|
+
s, e = series.wall_span(tz)
|
|
467
|
+
duration = e - s
|
|
468
|
+
dtstart = to_wall(rec.dtstart, tz) if rec.dtstart is not None else s
|
|
469
|
+
ex = {to_wall(x, tz) for x in rec.exdates}
|
|
470
|
+
for start in _starts(rec.rule, dtstart, hi):
|
|
471
|
+
if start in ex:
|
|
472
|
+
continue
|
|
473
|
+
end = start + duration
|
|
474
|
+
if end >= lo and start < hi:
|
|
475
|
+
yield start, end
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def expand_events(
|
|
479
|
+
events: Sequence[ScheduleEvent | Mapping[str, Any]],
|
|
480
|
+
start: _dt.date,
|
|
481
|
+
end: _dt.date,
|
|
482
|
+
tz: _dt.tzinfo | None = None,
|
|
483
|
+
) -> list[ScheduleEvent]:
|
|
484
|
+
"""Expand recurring series into ordinary events within the inclusive day range.
|
|
485
|
+
|
|
486
|
+
Occurrence ids are ``"<series id>::YYYY-MM-DD HH:MM:SS"`` (as in the page),
|
|
487
|
+
excluded dates are skipped and overrides (``recurring_event_id`` +
|
|
488
|
+
``recurrence_id``) replace their occurrence. Non-recurring events that
|
|
489
|
+
touch the range are returned unchanged. Occurrence times are wall times
|
|
490
|
+
(aware in ``tz`` when given).
|
|
491
|
+
"""
|
|
492
|
+
evs = [as_event(e) for e in events]
|
|
493
|
+
lo = _dt.datetime.combine(start, _dt.time())
|
|
494
|
+
hi = _dt.datetime.combine(end + _dt.timedelta(days=1), _dt.time())
|
|
495
|
+
overrides = {
|
|
496
|
+
(str(e.recurring_event_id), wire_datetime(to_wall(e.recurrence_id, tz))): e
|
|
497
|
+
for e in evs
|
|
498
|
+
if e.recurring_event_id is not None and e.recurrence_id is not None
|
|
499
|
+
}
|
|
500
|
+
used: set[int] = set()
|
|
501
|
+
out: list[ScheduleEvent] = []
|
|
502
|
+
for e in evs:
|
|
503
|
+
if e.recurring_event_id is not None:
|
|
504
|
+
continue
|
|
505
|
+
if e.recurrence is None:
|
|
506
|
+
if e.overlaps(start, end, tz):
|
|
507
|
+
out.append(e)
|
|
508
|
+
continue
|
|
509
|
+
for s, f in _occurrences(e, lo, hi, tz):
|
|
510
|
+
rid = wire_datetime(s)
|
|
511
|
+
ov = overrides.get((str(e.id), rid))
|
|
512
|
+
if ov is not None:
|
|
513
|
+
used.add(id(ov))
|
|
514
|
+
if ov.overlaps(start, end, tz):
|
|
515
|
+
out.append(ov)
|
|
516
|
+
continue
|
|
517
|
+
out.append(_occurrence(e, s, f, tz))
|
|
518
|
+
if len(out) > _MAX_OCCURRENCES:
|
|
519
|
+
raise ValidationError(f"more than {_MAX_OCCURRENCES} occurrences in the range")
|
|
520
|
+
out.extend(
|
|
521
|
+
ov for ov in overrides.values() if id(ov) not in used and ov.overlaps(start, end, tz)
|
|
522
|
+
)
|
|
523
|
+
return out
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
def _occurrence(
|
|
527
|
+
e: ScheduleEvent, s: _dt.datetime, f: _dt.datetime, tz: _dt.tzinfo | None
|
|
528
|
+
) -> ScheduleEvent:
|
|
529
|
+
rid = wire_datetime(s)
|
|
530
|
+
if e.all_day:
|
|
531
|
+
start: _dt.datetime | _dt.date = s.date()
|
|
532
|
+
end: _dt.datetime | _dt.date = (f - _dt.timedelta(days=1)).date()
|
|
533
|
+
else:
|
|
534
|
+
start, end = from_wall(s, tz), from_wall(f, tz)
|
|
535
|
+
return replace(
|
|
536
|
+
e,
|
|
537
|
+
id=f"{e.id}::{rid}",
|
|
538
|
+
start=start,
|
|
539
|
+
end=end,
|
|
540
|
+
recurrence=None,
|
|
541
|
+
recurring_event_id=e.id,
|
|
542
|
+
recurrence_id=s,
|
|
543
|
+
)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Native permission profiles for the Python UI facade (spec 17, ADR-006/017).
|
|
2
|
+
|
|
3
|
+
A profile picks the ``nativeAllowList`` of the application's runtime:
|
|
4
|
+
|
|
5
|
+
* ``"restricted"``: the routes the SDK needs at start-up and for RPC in both
|
|
6
|
+
directions (:data:`neutralino.config.SDK_NATIVE_ALLOW_LIST`) plus
|
|
7
|
+
``window.setTitle`` for :meth:`ui.Window.set_title`. Tested on the real
|
|
8
|
+
runtime; the default of the ``neutralino init`` UI templates.
|
|
9
|
+
* ``"trusted"``: ``"restricted"`` plus the routes of every typed desktop
|
|
10
|
+
helper (:func:`ui.desktop_routes`): dialogs, notifications, clipboard,
|
|
11
|
+
``os.open``, window geometry, full screen and icon. No ``os.execCommand``,
|
|
12
|
+
``os.spawnProcess``, ``filesystem.*``, ``storage.*`` or ``computer.*``.
|
|
13
|
+
* ``"custom"``: the explicit ``native_allow_list=`` (a list of routes, or
|
|
14
|
+
``"*"`` for upstream's everything-allowed behaviour).
|
|
15
|
+
|
|
16
|
+
Without a profile (``profile=None``) the facade keeps the core SDK's
|
|
17
|
+
behaviour unchanged: ``native_allow_list`` as given, else the config's own
|
|
18
|
+
lists, else the core least-privilege default.
|
|
19
|
+
|
|
20
|
+
Upstream has one permission policy per runtime: the page *and* the Python
|
|
21
|
+
extension connection get exactly the same list (ADR-006). A profile limits
|
|
22
|
+
what injected page script can reach through ``Neutralino.*``; it is not a
|
|
23
|
+
sandbox for Python, which keeps every privilege of its process.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from collections.abc import Mapping, Sequence
|
|
29
|
+
from typing import Any, Final, Literal, get_args
|
|
30
|
+
|
|
31
|
+
from .. import config as config_mod
|
|
32
|
+
from ..errors import ValidationError
|
|
33
|
+
from ._desktop import desktop_routes
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"NATIVE_PROFILES",
|
|
37
|
+
"RESTRICTED_ROUTES",
|
|
38
|
+
"TRUSTED_ROUTES",
|
|
39
|
+
"NativeProfile",
|
|
40
|
+
"profile_routes",
|
|
41
|
+
"resolve_native_profile",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
NativeProfile = Literal["restricted", "trusted", "custom"]
|
|
45
|
+
NATIVE_PROFILES: Final[tuple[str, ...]] = get_args(NativeProfile)
|
|
46
|
+
|
|
47
|
+
# The UI engine's own native use: the core SDK minimum (app.broadcast and
|
|
48
|
+
# extensions.getStats for the backend; extensions.dispatch for page -> Python;
|
|
49
|
+
# app.exit for the graceful stop) and window.setTitle (Window.set_title).
|
|
50
|
+
RESTRICTED_ROUTES: Final[tuple[str, ...]] = tuple(
|
|
51
|
+
sorted({*config_mod.SDK_NATIVE_ALLOW_LIST, "window.setTitle"})
|
|
52
|
+
)
|
|
53
|
+
TRUSTED_ROUTES: Final[tuple[str, ...]] = tuple(sorted({*RESTRICTED_ROUTES, *desktop_routes()}))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def profile_routes(profile: NativeProfile) -> list[str]:
|
|
57
|
+
"""The native routes of ``"restricted"`` or ``"trusted"`` (a new list).
|
|
58
|
+
|
|
59
|
+
Use it to build a ``"custom"`` list on top of a profile::
|
|
60
|
+
|
|
61
|
+
ui.Application(profile="custom",
|
|
62
|
+
native_allow_list=[*ui.profile_routes("restricted"), "os.open"])
|
|
63
|
+
"""
|
|
64
|
+
if profile == "restricted":
|
|
65
|
+
return list(RESTRICTED_ROUTES)
|
|
66
|
+
if profile == "trusted":
|
|
67
|
+
return list(TRUSTED_ROUTES)
|
|
68
|
+
raise ValidationError(
|
|
69
|
+
f"profile {profile!r} has no fixed routes; one of 'restricted', 'trusted'"
|
|
70
|
+
+ (" ('custom' uses native_allow_list=)" if profile == "custom" else "")
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _has_user_lists(cfg: Mapping[str, Any] | None) -> bool:
|
|
75
|
+
return cfg is not None and config_mod._has_user_lists(cfg) # pyright: ignore[reportPrivateUsage]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def resolve_native_profile(
|
|
79
|
+
profile: NativeProfile | None,
|
|
80
|
+
native_allow_list: Sequence[str] | str | None,
|
|
81
|
+
cfg: Mapping[str, Any] | None,
|
|
82
|
+
) -> Sequence[str] | str | None:
|
|
83
|
+
"""Validate ``profile`` with ``native_allow_list`` and the app config and
|
|
84
|
+
return the ``native_allow_list`` for the core application."""
|
|
85
|
+
if profile is None:
|
|
86
|
+
return native_allow_list
|
|
87
|
+
if profile not in NATIVE_PROFILES:
|
|
88
|
+
raise ValidationError(f"profile must be one of {list(NATIVE_PROFILES)} or None")
|
|
89
|
+
if profile == "custom":
|
|
90
|
+
if native_allow_list is None:
|
|
91
|
+
raise ValidationError(
|
|
92
|
+
"profile='custom' needs native_allow_list=[...] (or '*'); build on a profile "
|
|
93
|
+
"with ui.profile_routes('restricted')"
|
|
94
|
+
)
|
|
95
|
+
return native_allow_list
|
|
96
|
+
if native_allow_list is not None:
|
|
97
|
+
raise ValidationError(
|
|
98
|
+
f"profile={profile!r} fixes the native allow list; for extra routes use "
|
|
99
|
+
f"profile='custom', native_allow_list=[*ui.profile_routes({profile!r}), ...]"
|
|
100
|
+
)
|
|
101
|
+
if _has_user_lists(cfg):
|
|
102
|
+
raise ValidationError(
|
|
103
|
+
f"the config sets nativeAllowList/nativeBlockList and profile={profile!r} sets "
|
|
104
|
+
"another list; set the native permissions in one place"
|
|
105
|
+
)
|
|
106
|
+
return profile_routes(profile)
|