tiun 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.forgejo/workflows/codeberg-tests.yml +226 -0
- data/.gitignore +7 -3
- data/.prettierrc.json +5 -0
- data/.rubocop.yml +221 -0
- data/AGENTS.md +132 -0
- data/Appraisals +18 -0
- data/CONTRIBUTING.md +80 -0
- data/CONTRIBUTING.ru.md +326 -0
- data/Gemfile +20 -1
- data/README.md +52 -23
- data/README.ru.md +72 -0
- data/Rakefile +10 -4
- data/TODO +2 -6
- data/bin/console +4 -3
- data/config/cucumber.yml +1 -0
- data/cucumber.mjs +6 -0
- data/docs/backend.md +73 -0
- data/docs/backend.ru.md +73 -0
- data/docs/components/approved.md +39 -0
- data/docs/components/approved.ru.md +39 -0
- data/docs/components/attachment-field.md +7 -0
- data/docs/components/attachment-field.ru.md +8 -0
- data/docs/components/attachment.md +48 -0
- data/docs/components/attachment.ru.md +48 -0
- data/docs/components/avatar.md +39 -0
- data/docs/components/avatar.ru.md +37 -0
- data/docs/components/chip.md +119 -0
- data/docs/components/chip.ru.md +99 -0
- data/docs/components/configuration.md +137 -0
- data/docs/components/configuration.ru.md +138 -0
- data/docs/components/daylight.md +41 -0
- data/docs/components/daylight.ru.md +41 -0
- data/docs/components/defaults.md +148 -0
- data/docs/components/defaults.ru.md +149 -0
- data/docs/components/documents.md +64 -0
- data/docs/components/documents.ru.md +64 -0
- data/docs/components/external-form-fields.ru.md +137 -0
- data/docs/components/external-renderers.md +50 -0
- data/docs/components/external-renderers.ru.md +51 -0
- data/docs/components/feedback.md +76 -0
- data/docs/components/feedback.ru.md +76 -0
- data/docs/components/footer.md +49 -0
- data/docs/components/footer.ru.md +49 -0
- data/docs/components/forms.md +177 -0
- data/docs/components/forms.ru.md +177 -0
- data/docs/components/images.md +111 -0
- data/docs/components/images.ru.md +111 -0
- data/docs/components/index.md +140 -0
- data/docs/components/index.ru.md +140 -0
- data/docs/components/intro.md +150 -0
- data/docs/components/intro.ru.md +150 -0
- data/docs/components/login.md +600 -0
- data/docs/components/login.ru.md +602 -0
- data/docs/components/methods.md +59 -0
- data/docs/components/methods.ru.md +59 -0
- data/docs/components/player.md +72 -0
- data/docs/components/player.ru.md +69 -0
- data/docs/components/profile.md +82 -0
- data/docs/components/profile.ru.md +82 -0
- data/docs/components/record-manager.md +69 -0
- data/docs/components/record-manager.ru.md +69 -0
- data/docs/components/row-column.ru.md +51 -0
- data/docs/components/rtfer.md +76 -0
- data/docs/components/rtfer.ru.md +76 -0
- data/docs/components/schema-calendar.md +86 -0
- data/docs/components/schema-calendar.ru.md +84 -0
- data/docs/components/schema-records.md +166 -0
- data/docs/components/schema-records.ru.md +166 -0
- data/docs/components/signup.md +194 -0
- data/docs/components/signup.ru.md +194 -0
- data/docs/components/slug-flow.md +97 -0
- data/docs/components/slug-flow.ru.md +59 -0
- data/docs/components/stockee.md +21 -0
- data/docs/components/stockee.ru.md +21 -0
- data/docs/components/text-views.md +64 -0
- data/docs/components/text-views.ru.md +57 -0
- data/docs/components/theme.md +212 -0
- data/docs/components/theme.ru.md +212 -0
- data/docs/components/tooltip.md +37 -0
- data/docs/components/tooltip.ru.md +30 -0
- data/docs/components/validation.md +153 -0
- data/docs/components/validation.ru.md +154 -0
- data/docs/components.md +31 -0
- data/docs/components.ru.md +31 -0
- data/docs/controller-names.md +23 -0
- data/docs/controller-names.ru.md +23 -0
- data/docs/examples/dneslov-frontend.md +38 -0
- data/docs/examples/dneslov-frontend.ru.md +39 -0
- data/docs/examples/dneslov-frontend.yaml +266 -0
- data/docs/frontend.md +316 -0
- data/docs/frontend.ru.md +332 -0
- data/docs/migrations/component-configuration.md +48 -0
- data/docs/migrations/component-configuration.ru.md +40 -0
- data/docs/migrations/component-shell-proposal.md +108 -0
- data/docs/migrations/component-shell-proposal.ru.md +150 -0
- data/docs/migrations/theme-layout.md +83 -0
- data/docs/migrations/theme-layout.ru.md +97 -0
- data/docs/reference.md +45 -0
- data/docs/reference.ru.md +1763 -0
- data/docs/resources.md +348 -0
- data/docs/resources.ru.md +349 -0
- data/docs/tasks/DNE-542.md +11 -0
- data/docs/tasks/DNE-566.md +8 -0
- data/docs/tasks/chip-segments.md +54 -0
- data/docs/tasks/configured-profile.md +73 -0
- data/docs/tasks/frontend/auth-form.md +7 -0
- data/docs/tasks/frontend/avatar.md +5 -0
- data/docs/tasks/frontend/component-removal.md +11 -0
- data/docs/tasks/frontend/dynamic-field.md +6 -0
- data/docs/tasks/frontend/field-caption.md +38 -0
- data/docs/tasks/frontend/form-core.md +65 -0
- data/docs/tasks/frontend/form-field-context.md +16 -0
- data/docs/tasks/frontend/form-session-renewal.md +58 -0
- data/docs/tasks/frontend/frontend-components.md +7 -0
- data/docs/tasks/frontend/frontend-docs.md +6 -0
- data/docs/tasks/frontend/frontend-layout.md +13 -0
- data/docs/tasks/frontend/frontend-methods.md +15 -0
- data/docs/tasks/frontend/frontend-other.md +13 -0
- data/docs/tasks/frontend/frontend-services.md +7 -0
- data/docs/tasks/frontend/fusion.md +22 -0
- data/docs/tasks/frontend/heading-core.md +5 -0
- data/docs/tasks/frontend/i18n-scope.md +37 -0
- data/docs/tasks/frontend/index-runtime.md +48 -0
- data/docs/tasks/frontend/inline-form.md +7 -0
- data/docs/tasks/frontend/intro-core.md +11 -0
- data/docs/tasks/frontend/login.md +8 -0
- data/docs/tasks/frontend/menu-branch.md +5 -0
- data/docs/tasks/frontend/paginator.md +7 -0
- data/docs/tasks/frontend/records-core.md +35 -0
- data/docs/tasks/frontend/resource-source-core.md +12 -0
- data/docs/tasks/frontend/signup.md +8 -0
- data/docs/tasks/frontend/span-body.md +16 -0
- data/docs/tasks/frontend/text-commonee.md +48 -0
- data/docs/tasks/frontend/theme-field.md +31 -0
- data/docs/tasks/frontend/theme-menu.md +8 -0
- data/docs/tasks/frontend/theme-settings.md +10 -0
- data/docs/tasks/frontend/view-content-core.md +12 -0
- data/docs/tasks/frontend/view-source-core.md +12 -0
- data/docs/tasks/ruby-extension-compatibility.ru.md +74 -0
- data/docs/tasks/todo-code-climate.md +8 -0
- data/docs/tasks/todo-compatibility.md +50 -0
- data/docs/tasks/todo-reek.md +5 -0
- data/docs/tasks/todo-yard-inch.md +7 -0
- data/eslint.config.mjs +15 -0
- data/exe/tiun +1 -0
- data/gemfiles/rails_7_0.gemfile +16 -0
- data/gemfiles/rails_7_2.gemfile +17 -0
- data/lib/config/locale/browser.en.yml +43 -0
- data/lib/config/locale/browser.ru.yml +35 -0
- data/lib/config/locale/confirmation.en.yml +16 -0
- data/lib/config/locale/confirmation.ru.yml +16 -0
- data/lib/config/locale/errors.en.yml +57 -0
- data/lib/config/locale/errors.ru.yml +47 -0
- data/lib/config/locale/form_delay.en.yml +11 -0
- data/lib/config/locale/form_delay.ru.yml +11 -0
- data/lib/config/locale/recovery.en.yml +14 -0
- data/lib/config/locale/ru.yml +272 -6
- data/lib/config/routes.rb +5 -11
- data/lib/tasks/tiun/translations.rake +12 -0
- data/lib/tiun/actor/validate.rb +3 -2
- data/lib/tiun/actor.rb +13 -10
- data/lib/tiun/api_not_found.rb +16 -0
- data/lib/tiun/attributes.rb +8 -7
- data/lib/tiun/auth/attribute_models.rb +32 -0
- data/lib/tiun/auth/controller/discord.rb +26 -0
- data/lib/tiun/auth/controller/facebook.rb +62 -0
- data/lib/tiun/auth/controller/github.rb +37 -0
- data/lib/tiun/auth/controller/kakao.rb +33 -0
- data/lib/tiun/auth/controller/oauth.rb +167 -0
- data/lib/tiun/auth/controller/ok.rb +8 -0
- data/lib/tiun/auth/controller/telegram.rb +188 -0
- data/lib/tiun/auth/controller/vk.rb +85 -0
- data/lib/tiun/auth/controller/wechat.rb +58 -0
- data/lib/tiun/auth/controller/weibo.rb +28 -0
- data/lib/tiun/auth/controller.rb +467 -150
- data/lib/tiun/auth/json_session.rb +19 -0
- data/lib/tiun/auth/token_identity.rb +37 -0
- data/lib/tiun/auth/user_identity.rb +27 -0
- data/lib/tiun/auth/views/oauth_address.html.erb +23 -0
- data/lib/tiun/auth.rb +184 -45
- data/lib/tiun/carrier_wave_store.rb +59 -0
- data/lib/tiun/cli.rb +52 -32
- data/lib/tiun/concern/resources.rb +85 -0
- data/lib/tiun/config_source.rb +52 -0
- data/lib/tiun/content_range.rb +123 -0
- data/lib/tiun/context/merge.rb +117 -0
- data/lib/tiun/context.rb +39 -0
- data/lib/tiun/controller/auth/identity.rb +201 -0
- data/lib/tiun/controller/auth/registration.rb +23 -0
- data/lib/tiun/controller/auth.rb +198 -0
- data/lib/tiun/controller/auto.rb.erb +10 -0
- data/lib/tiun/controller/base/actions.rb +156 -0
- data/lib/tiun/controller/base/assignment.rb +101 -0
- data/lib/tiun/controller/base/parameters.rb +198 -0
- data/lib/tiun/controller/base/params.rb +166 -0
- data/lib/tiun/controller/base/records.rb +107 -0
- data/lib/tiun/controller/base/representation.rb +97 -0
- data/lib/tiun/controller/base/scopes.rb +132 -0
- data/lib/tiun/controller/base.rb +52 -0
- data/lib/tiun/controller/component_assets.rb +96 -0
- data/lib/tiun/controller/meta.rb +248 -0
- data/lib/tiun/controller/translations.rb +22 -0
- data/lib/tiun/controller.rb +13 -0
- data/lib/tiun/core/boot.rb +210 -0
- data/lib/tiun/core/contexts.rb +53 -0
- data/lib/tiun/core/controller_contexts.rb +42 -0
- data/lib/tiun/core/defaults.rb +215 -0
- data/lib/tiun/core/evaluation.rb +105 -0
- data/lib/tiun/core/field_attributes.rb +78 -0
- data/lib/tiun/core/files.rb +153 -0
- data/lib/tiun/core/generation.rb +234 -0
- data/lib/tiun/core/methods.rb +104 -0
- data/lib/tiun/core/names.rb +140 -0
- data/lib/tiun/core/registry.rb +97 -0
- data/lib/tiun/core/reloading.rb +77 -0
- data/lib/tiun/core/resources.rb +308 -0
- data/lib/tiun/core/routing/forward.rb +206 -0
- data/lib/tiun/core/routing.rb +323 -0
- data/lib/tiun/core/types.rb +88 -0
- data/lib/tiun/core.rb +26 -0
- data/lib/tiun/core_helper.rb +85 -13
- data/lib/tiun/engine.rb +64 -20
- data/lib/tiun/error_handling.rb +121 -0
- data/lib/tiun/hooks.rb +131 -0
- data/lib/tiun/mailer/confirmation.rb +37 -0
- data/lib/tiun/mailer/recovery.rb +16 -0
- data/lib/tiun/migration.rb +72 -50
- data/lib/tiun/mixins.rb +128 -19
- data/lib/tiun/model/account/identity.rb +93 -0
- data/lib/tiun/model/account.rb +180 -7
- data/lib/tiun/model/auth/bcrypt.rb +47 -0
- data/lib/tiun/model/auth.rb +162 -36
- data/lib/tiun/model/auto.rb.erb +12 -0
- data/lib/tiun/model/me.rb +133 -0
- data/lib/tiun/model/settings.rb +186 -0
- data/lib/tiun/model/token/recovery.rb +48 -0
- data/lib/tiun/model/token.rb +37 -3
- data/lib/tiun/model.rb +82 -69
- data/lib/tiun/notification/service.rb +18 -0
- data/lib/tiun/notification.rb +6 -0
- data/lib/tiun/policy/default.rb +7 -0
- data/lib/tiun/policy.rb +84 -8
- data/lib/tiun/proceed/allowed_errors.rb +217 -0
- data/lib/tiun/proceed/auth.rb +50 -0
- data/lib/tiun/proceed/description.rb +89 -0
- data/lib/tiun/proceed/enums.rb +225 -0
- data/lib/tiun/proceed/hooks.rb +51 -0
- data/lib/tiun/proceed/pass_over_paths.rb +40 -0
- data/lib/tiun/proceed/policy.rb +172 -0
- data/lib/tiun/proceed/registration.rb +69 -0
- data/lib/tiun/proceed/schemas/component_nodes.rb +436 -0
- data/lib/tiun/proceed/schemas/constants.rb +116 -0
- data/lib/tiun/proceed/schemas/content.rb +68 -0
- data/lib/tiun/proceed/schemas/definitions.rb +181 -0
- data/lib/tiun/proceed/schemas/dictionary.rb +144 -0
- data/lib/tiun/proceed/schemas/fields.rb +182 -0
- data/lib/tiun/proceed/schemas/models.rb +50 -0
- data/lib/tiun/proceed/schemas/spans.rb +86 -0
- data/lib/tiun/proceed/schemas/values.rb +94 -0
- data/lib/tiun/proceed/schemas/view_paths.rb +86 -0
- data/lib/tiun/proceed/schemas/view_readiness.rb +51 -0
- data/lib/tiun/proceed/schemas/views.rb +192 -0
- data/lib/tiun/proceed/schemas.rb +137 -0
- data/lib/tiun/proceed/services.rb +79 -0
- data/lib/tiun/proceed/token_lifetimes.rb +49 -0
- data/lib/tiun/proceed/translations.rb +45 -0
- data/lib/tiun/proceed/versions.rb +315 -0
- data/lib/tiun/proceed.rb +23 -0
- data/lib/tiun/router.rb +40 -0
- data/lib/tiun/routes/mounts.rb +277 -0
- data/lib/tiun/routes.rb +150 -0
- data/lib/tiun/service/auto.rb.erb +5 -0
- data/lib/tiun/service/email_confirmation.rb +36 -0
- data/lib/tiun/service/job.rb +16 -0
- data/lib/tiun/service.rb +82 -0
- data/lib/tiun/services/translation.rb +297 -0
- data/lib/tiun/themes.rb +98 -0
- data/lib/tiun/translations/database.rb +72 -0
- data/lib/tiun/translations.rb +279 -0
- data/lib/tiun/version.rb +3 -3
- data/lib/tiun.rb +79 -486
- data/package-lock.json +4836 -0
- data/package.json +103 -0
- data/scripts/build-application.mjs +39 -0
- data/scripts/build-css.mjs +21 -0
- data/scripts/ci-badges.mjs +54 -0
- data/scripts/ci-badges.test.mjs +46 -0
- data/scripts/ci-coverage.mjs +26 -0
- data/scripts/ci-quality.mjs +80 -0
- data/scripts/ci-quality.sh +21 -0
- data/scripts/ci-quality.test.mjs +59 -0
- data/scripts/clean.mjs +3 -0
- data/scripts/publish-ci-badges.sh +45 -0
- data/src/auth/configuration.ts +50 -0
- data/src/browser/contracts.js +7 -0
- data/src/browser/mount.d.ts +26 -0
- data/src/browser/mount.jsx +1 -0
- data/src/browser/styles.js +17 -0
- data/src/browser/tiun.scss +23 -0
- data/src/browser/tiun.ts +1 -0
- data/src/calendar/configuration.ts +98 -0
- data/src/components/Avatar.tsx +45 -0
- data/src/components/Calendar.tsx +441 -0
- data/src/components/CatchWrapper.tsx +55 -0
- data/src/components/Chip.tsx +267 -0
- data/src/components/Column.tsx +13 -0
- data/src/components/Component.tsx +1039 -0
- data/src/components/Enum.tsx +142 -0
- data/src/components/Figure.tsx +11 -0
- data/src/components/FlexText.tsx +101 -0
- data/src/components/Footer.tsx +13 -0
- data/src/components/Grid.tsx +36 -0
- data/src/components/Heading.tsx +64 -0
- data/src/components/Image.tsx +168 -0
- data/src/components/Index.tsx +391 -0
- data/src/components/Intro.tsx +536 -0
- data/src/components/Loader.tsx +116 -0
- data/src/components/Lorem.tsx +379 -0
- data/src/components/Markdown.d.ts +17 -0
- data/src/components/Markdown.jsx +118 -0
- data/src/components/Menu.tsx +50 -0
- data/src/components/Modal.tsx +143 -0
- data/src/components/Paginator.tsx +265 -0
- data/src/components/Player.tsx +269 -0
- data/src/components/Records.tsx +1063 -0
- data/src/components/Row.tsx +193 -0
- data/src/components/Span.tsx +122 -0
- data/src/components/Step.tsx +19 -0
- data/src/components/Stockee.tsx +50 -0
- data/src/components/Toast.tsx +125 -0
- data/src/components/Tooltip.tsx +214 -0
- data/src/components/View.tsx +278 -0
- data/src/components/_palette.scss +26 -0
- data/src/components/calendar-browser.scss +133 -0
- data/src/components/calendar.scss +217 -0
- data/src/components/chip-browser.scss +270 -0
- data/src/components/chips.scss +95 -0
- data/src/components/column.scss +4 -0
- data/src/components/dashboard-browser.scss +81 -0
- data/src/components/dashboard.scss +117 -0
- data/src/components/description-browser.scss +112 -0
- data/src/components/document.scss +43 -0
- data/src/components/enum-browser.scss +33 -0
- data/src/components/enums.scss +56 -0
- data/src/components/footer.scss +51 -0
- data/src/components/form/ActionButton.tsx +66 -0
- data/src/components/form/Attachment.tsx +200 -0
- data/src/components/form/Block.tsx +55 -0
- data/src/components/form/BooleanBox.tsx +58 -0
- data/src/components/form/Collection.tsx +89 -0
- data/src/components/form/DynamicInput.tsx +806 -0
- data/src/components/form/ErrorSpan.tsx +17 -0
- data/src/components/form/ExternalField.tsx +554 -0
- data/src/components/form/FieldCaption.tsx +35 -0
- data/src/components/form/Form.tsx +407 -0
- data/src/components/form/HiddenField.tsx +10 -0
- data/src/components/form/JsonEditor.tsx +443 -0
- data/src/components/form/Login.tsx +381 -0
- data/src/components/form/NumberField.tsx +75 -0
- data/src/components/form/Pressee.tsx +101 -0
- data/src/components/form/RtferField.tsx +94 -0
- data/src/components/form/SelectField.tsx +73 -0
- data/src/components/form/SlugFlow.tsx +296 -0
- data/src/components/form/TextArea.tsx +5 -0
- data/src/components/form/TextField.tsx +6 -0
- data/src/components/form/Wye.tsx +67 -0
- data/src/components/form/auth.scss +366 -0
- data/src/components/form/changes.ts +239 -0
- data/src/components/form/context.ts +31 -0
- data/src/components/form/createForm.tsx +109 -0
- data/src/components/form/dynamic-field.scss +20 -0
- data/src/components/form/dynamicMatching.ts +44 -0
- data/src/components/form/form-browser.scss +106 -0
- data/src/components/form/forms.scss +1570 -0
- data/src/components/form/formsLib.ts +76 -0
- data/src/components/form/identity.ts +10 -0
- data/src/components/form/input.scss +37 -0
- data/src/components/form/layout.ts +72 -0
- data/src/components/form/login-browser.scss +30 -0
- data/src/components/form/render.tsx +94 -0
- data/src/components/form/resourceFields.ts +87 -0
- data/src/components/form/types.ts +214 -0
- data/src/components/form/values.ts +266 -0
- data/src/components/image.scss +67 -0
- data/src/components/intro-browser.scss +106 -0
- data/src/components/intro.scss +158 -0
- data/src/components/loader.scss +86 -0
- data/src/components/menu.scss +24 -0
- data/src/components/player.scss +48 -0
- data/src/components/records-browser.scss +62 -0
- data/src/components/records.scss +181 -0
- data/src/components/row.scss +31 -0
- data/src/components/stockee.scss +26 -0
- data/src/components/theme-palettes/compat.scss +15 -0
- data/src/components/theme-palettes/dark.scss +237 -0
- data/src/components/theme-palettes/light.scss +21 -0
- data/src/components/theme.scss +34 -0
- data/src/components/tiun_core.scss +9 -0
- data/src/components/toast.scss +63 -0
- data/src/components/tooltip.scss +22 -0
- data/src/components/view-browser.scss +321 -0
- data/src/components/view-controls.scss +385 -0
- data/src/concern/application.ts +56 -0
- data/src/concern/calendarViewProps.ts +28 -0
- data/src/concern/chipViewProps.ts +60 -0
- data/src/concern/documentHead.ts +66 -0
- data/src/concern/i18n.ts +70 -0
- data/src/concern/resourceRequest.ts +25 -0
- data/src/concern/schemaText.ts +6 -0
- data/src/concern/slugFlowProps.ts +76 -0
- data/src/concern/spanOptions.ts +37 -0
- data/src/concern/spansViewProps.tsx +103 -0
- data/src/concern/useFormAccess.ts +324 -0
- data/src/concern/useRecordsResource.ts +60 -0
- data/src/config/application.ts +57 -0
- data/src/config/componentDefaults.ts +106 -0
- data/src/config/components.ts +436 -0
- data/src/config/names.ts +72 -0
- data/src/config/records.ts +34 -0
- data/src/decorators/buttonBehaviours.tsx +46 -0
- data/src/decorators/configuration.ts +104 -0
- data/src/decorators/validation.ts +52 -0
- data/src/decorators/withAppearance.tsx +45 -0
- data/src/decorators/withCaption.tsx +21 -0
- data/src/decorators/withChildren.tsx +31 -0
- data/src/decorators/withClose.scss +37 -0
- data/src/decorators/withClose.tsx +44 -0
- data/src/decorators/withColumn.tsx +111 -0
- data/src/decorators/withDiscordAuth.tsx +4 -0
- data/src/decorators/withExternalAuth.tsx +50 -0
- data/src/decorators/withFacebookAuth.tsx +4 -0
- data/src/decorators/withField.tsx +91 -0
- data/src/decorators/withForm.tsx +365 -0
- data/src/decorators/withGithubAuth.tsx +4 -0
- data/src/decorators/withKakaoAuth.tsx +4 -0
- data/src/decorators/withMenuBranch.scss +45 -0
- data/src/decorators/withMenuBranch.tsx +109 -0
- data/src/decorators/withOkAuth.tsx +4 -0
- data/src/decorators/withPlayerList.tsx +77 -0
- data/src/decorators/withQuickLinkMark.ts +57 -0
- data/src/decorators/withRecordForm.tsx +561 -0
- data/src/decorators/withRequestActivity.scss +7 -0
- data/src/decorators/withRequestActivity.tsx +21 -0
- data/src/decorators/withRouter.tsx +395 -0
- data/src/decorators/withRouterLink.tsx +54 -0
- data/src/decorators/withTelegramAuth.tsx +4 -0
- data/src/decorators/withTextControl.tsx +194 -0
- data/src/decorators/withUnique.scss +39 -0
- data/src/decorators/withUnique.tsx +172 -0
- data/src/decorators/withUnsavedChanges.scss +39 -0
- data/src/decorators/withUnsavedChanges.tsx +312 -0
- data/src/decorators/withValidation.ts +38 -0
- data/src/decorators/withVkAuth.tsx +4 -0
- data/src/decorators/withWechatAuth.tsx +4 -0
- data/src/decorators/withWeiboAuth.tsx +4 -0
- data/src/intro/config.ts +72 -0
- data/src/intro/position.ts +70 -0
- data/src/layout/units.ts +21 -0
- data/src/records/types.ts +67 -0
- data/src/routing/nativePaths.ts +16 -0
- data/src/routing/routes.ts +337 -0
- data/src/schema/Schema.ts +2034 -0
- data/src/schema/dates.ts +17 -0
- data/src/schema.ts +274 -0
- data/src/services/Meta.ts +64 -0
- data/src/services/Resource.ts +480 -0
- data/src/services/Stock.ts +156 -0
- data/src/services/browser/requestActivity.d.ts +7 -0
- data/src/services/browser/requestActivity.js +119 -0
- data/src/services/browser/slugColor.js +13 -0
- data/src/services/calendar/clock.ts +169 -0
- data/src/services/calendar/dates.ts +127 -0
- data/src/services/calendar/daylight.ts +301 -0
- data/src/services/calendar/useCalendarDaylight.ts +76 -0
- data/src/services/calendar/utcTimeSource.ts +41 -0
- data/src/services/enumLookup.ts +96 -0
- data/src/services/form/blankCondition.ts +61 -0
- data/src/services/form/hoardValidation.ts +84 -0
- data/src/services/i18n/I18n.ts +227 -0
- data/src/services/i18n/messages.ts +185 -0
- data/src/services/load.ts +60 -0
- data/src/services/methods/aboutData.d.ts +9 -0
- data/src/services/methods/aboutData.js +32 -0
- data/src/services/methods/calendarChoices.d.ts +1 -0
- data/src/services/methods/calendarChoices.js +9 -0
- data/src/services/methods/eventDates.ts +96 -0
- data/src/services/methods/forms.ts +22 -0
- data/src/services/methods/mount.jsx +34 -0
- data/src/services/methods/paschal.ts +45 -0
- data/src/services/methods/prepared.ts +193 -0
- data/src/services/methods/query.ts +30 -0
- data/src/services/methods/registry.ts +22 -0
- data/src/services/methods/resolveReadResource.ts +57 -0
- data/src/services/methods.ts +156 -0
- data/src/services/records/range.ts +39 -0
- data/src/services/records/resource.ts +90 -0
- data/src/services/records/useRecordPages.ts +266 -0
- data/src/services/session/renewal.ts +394 -0
- data/src/services/textLink.ts +11 -0
- data/src/services/timer.ts +25 -0
- data/src/services/useAppearance.ts +496 -0
- data/src/services/useSwitch.ts +146 -0
- data/src/theme/cache.ts +88 -0
- data/src/theme/configuration.ts +261 -0
- data/src/theme/context.ts +48 -0
- data/src/theme/resource.ts +106 -0
- data/tiun.gemspec +53 -45
- data/tools/rubocop/compact_block_braces.rb +39 -0
- data/tools/rubocop/i18n_decorators.rb +15 -0
- data/tools/rubocop/spacing.rb +96 -0
- data/tsconfig.build.json +26 -0
- data/tsconfig.json +27 -0
- metadata +628 -72
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/lib/tiun/autocontroller.rb.erb +0 -20
- data/lib/tiun/autolistserializer.rb.erb +0 -9
- data/lib/tiun/automodel.rb.erb +0 -10
- data/lib/tiun/autoserializer.rb.erb +0 -9
- data/lib/tiun/base.rb +0 -405
- data/lib/tiun/core_controller.rb +0 -6
- data/lib/tiun/list_serializer.rb +0 -20
- data/lib/tiun/meta_controller.rb +0 -13
- data/lib/tiun/serializer.rb +0 -31
- /data/lib/tiun/{automigration.rb.erb → migration/auto.rb.erb} +0 -0
- /data/lib/tiun/{autopolicy.rb.erb → policy/auto.rb.erb} +0 -0
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import type { FormData, FormValue, UpdateMethod } from "../components/form/types.js";
|
|
2
|
+
import { settings } from "../config/application.js";
|
|
3
|
+
import { isRecord } from "../components/form/values.js";
|
|
4
|
+
import {
|
|
5
|
+
compareConfigurationVersions,
|
|
6
|
+
configurationLine,
|
|
7
|
+
configurationReferenceMap,
|
|
8
|
+
configurationVersion,
|
|
9
|
+
type ComponentDefinition,
|
|
10
|
+
} from "../config/components.js";
|
|
11
|
+
import type { Schema } from "../schema/Schema.js";
|
|
12
|
+
import type { ServerMeta } from "./Meta.js";
|
|
13
|
+
import { recordsLoaderResource } from "../config/records.js";
|
|
14
|
+
export interface ResourceField {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly kind?: string;
|
|
17
|
+
readonly readonly?: boolean;
|
|
18
|
+
readonly writeonly?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ResourceOperation {
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly method: string;
|
|
23
|
+
readonly kind?: string;
|
|
24
|
+
readonly root?: string;
|
|
25
|
+
readonly args: readonly ResourceField[];
|
|
26
|
+
}
|
|
27
|
+
export interface ResourceType {
|
|
28
|
+
readonly fields: readonly ResourceField[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const object = (value: unknown): value is Record<string, unknown> =>
|
|
32
|
+
Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
33
|
+
|
|
34
|
+
function fields(value: unknown): ResourceField[] {
|
|
35
|
+
return Array.isArray(value)
|
|
36
|
+
? value
|
|
37
|
+
.filter(object)
|
|
38
|
+
.filter((item) => typeof item.name === "string")
|
|
39
|
+
.map((item) => ({
|
|
40
|
+
name: String(item.name),
|
|
41
|
+
...(typeof item.kind === "string" ? { kind: item.kind } : {}),
|
|
42
|
+
...(typeof item.readonly === "boolean" ? { readonly: item.readonly } : {}),
|
|
43
|
+
...(typeof item.writeonly === "boolean" ? { writeonly: item.writeonly } : {}),
|
|
44
|
+
}))
|
|
45
|
+
: [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Finds a declaration by full version, line or latest version under a bare name.
|
|
50
|
+
* @param definitions Published definitions in configuration order.
|
|
51
|
+
* @param reference Base name with an optional colon and numeric version.
|
|
52
|
+
* @returns The matching declaration, or undefined.
|
|
53
|
+
*/
|
|
54
|
+
export function findConfigurationDefinition(
|
|
55
|
+
definitions: unknown,
|
|
56
|
+
reference: string,
|
|
57
|
+
): Record<string, unknown> | undefined {
|
|
58
|
+
if (!Array.isArray(definitions)) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const separator = reference.indexOf(":"),
|
|
62
|
+
name = separator < 0 ? reference : reference.slice(0, separator),
|
|
63
|
+
qualifier = separator < 0 ? undefined : reference.slice(separator + 1),
|
|
64
|
+
entries = definitions.filter(
|
|
65
|
+
(entry): entry is Record<string, unknown> & { name: string } =>
|
|
66
|
+
object(entry) && typeof entry.name === "string" && entry.name.split(":", 1)[0] === name,
|
|
67
|
+
);
|
|
68
|
+
if (qualifier === undefined) {
|
|
69
|
+
return entries.reduce<(typeof entries)[number] | undefined>((selected, entry) => {
|
|
70
|
+
const version = configurationVersion(entry.name, entry.version);
|
|
71
|
+
return !selected ||
|
|
72
|
+
compareConfigurationVersions(version, configurationVersion(selected.name, selected.version)) > 0
|
|
73
|
+
? entry
|
|
74
|
+
: selected;
|
|
75
|
+
}, undefined);
|
|
76
|
+
}
|
|
77
|
+
return entries.find((entry) => {
|
|
78
|
+
const version = configurationVersion(entry.name, entry.version);
|
|
79
|
+
return qualifier.includes(".")
|
|
80
|
+
? version === qualifier
|
|
81
|
+
: /^\d+$/.test(qualifier) && configurationLine(entry.name, version) === configurationLine("", qualifier);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Selects a resource from the prepared metadata by name or version reference.
|
|
87
|
+
* @param meta Server metadata with resource declarations.
|
|
88
|
+
* @param name Name, line or full version reference.
|
|
89
|
+
* @returns The selected resource, or undefined.
|
|
90
|
+
*/
|
|
91
|
+
export function findResource(meta: ServerMeta, name: string): Record<string, unknown> | undefined {
|
|
92
|
+
return findConfigurationDefinition(meta.resources, name);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function findResourceMethod(resource: unknown, method: string): Record<string, unknown> | undefined {
|
|
96
|
+
if (!object(resource) || !Array.isArray(resource.methods)) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return resource.methods
|
|
100
|
+
.filter(object)
|
|
101
|
+
.reduce<Record<string, unknown> | undefined>(
|
|
102
|
+
(selected, entry) =>
|
|
103
|
+
entry.name === method && (!selected || Number(entry.version ?? 0) > Number(selected.version ?? 0))
|
|
104
|
+
? entry
|
|
105
|
+
: selected,
|
|
106
|
+
undefined,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Checks whether a declared policy requires one of the available permissions.
|
|
112
|
+
* @param policy A comma-separated list of granted permission names, or an omitted requirement.
|
|
113
|
+
* @param permissions Names supplied by the current session or guest role.
|
|
114
|
+
* @returns True for an omitted rule or a matching permission.
|
|
115
|
+
*/
|
|
116
|
+
// eslint-disable-next-line one-var -- This is a separate public policy operation.
|
|
117
|
+
export const isPolicyAllowed = (policy: unknown, permissions?: readonly string[]): boolean => {
|
|
118
|
+
if (typeof policy === "undefined" || policy === null) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return (
|
|
122
|
+
typeof policy === "string" &&
|
|
123
|
+
policy.split(",").some((permission) => permissions?.includes(permission.trim()) === true)
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Applies the method's authentication and permission requirements for the active session.
|
|
129
|
+
* @param method Declared requirements for a resource method.
|
|
130
|
+
* @param access Current session and fallback settings.
|
|
131
|
+
* @returns Whether the browser can display the corresponding action.
|
|
132
|
+
*/
|
|
133
|
+
// eslint-disable-next-line one-var -- Keep the permission predicate separate from its caller.
|
|
134
|
+
const isResourceMethodAllowed = (
|
|
135
|
+
method: Readonly<Record<string, unknown>>,
|
|
136
|
+
access: {
|
|
137
|
+
readonly allowByDefault: boolean;
|
|
138
|
+
readonly permissions?: readonly string[] | undefined;
|
|
139
|
+
readonly signedIn: boolean;
|
|
140
|
+
},
|
|
141
|
+
): boolean => {
|
|
142
|
+
const { allowByDefault, permissions, signedIn } = access;
|
|
143
|
+
if (signedIn || method.auth === "no") {
|
|
144
|
+
if (typeof permissions !== "undefined") {
|
|
145
|
+
return isPolicyAllowed(method.policy, permissions);
|
|
146
|
+
}
|
|
147
|
+
return allowByDefault || (!signedIn && isPolicyAllowed(method.policy));
|
|
148
|
+
}
|
|
149
|
+
return method.auth !== "required" && isPolicyAllowed(method.policy);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Projects effective resource access for the active session without mutating or reloading the shared configuration.
|
|
154
|
+
* @param meta Common server configuration containing the resource declarations.
|
|
155
|
+
* @param permissions Current user permissions or the default guest role's permissions.
|
|
156
|
+
* @param signedIn Whether the current session has a user.
|
|
157
|
+
* @returns Client metadata used by forms, views and actions.
|
|
158
|
+
*/
|
|
159
|
+
// eslint-disable-next-line one-var -- This public operation projects a complete metadata snapshot.
|
|
160
|
+
export const withResourceAccess = (
|
|
161
|
+
meta: ServerMeta,
|
|
162
|
+
permissions: readonly string[] | undefined,
|
|
163
|
+
signedIn: boolean,
|
|
164
|
+
): ServerMeta => {
|
|
165
|
+
if (!Array.isArray(meta.resources)) {
|
|
166
|
+
return meta;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const allowByDefault = settings(meta).policy !== "deny";
|
|
170
|
+
return {
|
|
171
|
+
...meta,
|
|
172
|
+
resources: meta.resources
|
|
173
|
+
.filter(object)
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Resource records carry arbitrary schema values.
|
|
175
|
+
.map((resource) => {
|
|
176
|
+
let methods: readonly Readonly<Record<string, unknown>>[] = [];
|
|
177
|
+
if (Array.isArray(resource.methods)) {
|
|
178
|
+
methods = resource.methods.filter(object);
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
...resource,
|
|
182
|
+
methods: methods.map((method: Readonly<Record<string, unknown>>) => ({
|
|
183
|
+
...method,
|
|
184
|
+
allowed: isResourceMethodAllowed(method, { allowByDefault, permissions, signedIn }),
|
|
185
|
+
})),
|
|
186
|
+
};
|
|
187
|
+
}),
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Reads effective client access, or evaluates a common declaration for a standalone guest view.
|
|
193
|
+
* @param meta Prepared metadata or the common configuration without an active session.
|
|
194
|
+
* @param name Resource name.
|
|
195
|
+
* @param method HTTP method name.
|
|
196
|
+
* @returns Whether the method is available to the browser.
|
|
197
|
+
*/
|
|
198
|
+
export function resourceAllowed(meta: ServerMeta, name: unknown, method: string): boolean {
|
|
199
|
+
if (typeof name !== "string") {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
const operation = findResourceMethod(findResource(meta, name), method);
|
|
203
|
+
if (!operation) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if (typeof operation.allowed === "boolean") {
|
|
207
|
+
return operation.allowed;
|
|
208
|
+
}
|
|
209
|
+
return isResourceMethodAllowed(operation, { allowByDefault: settings(meta).policy !== "deny", signedIn: false });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Выбирает PATCH или PUT по разрешениям формы и ресурса.
|
|
214
|
+
* @param meta Серверные метаданные методов и прав.
|
|
215
|
+
* @param name Имя ресурса формы.
|
|
216
|
+
* @param allow Список разрешённых методов компонента формы.
|
|
217
|
+
* @returns PATCH, если он доступен, затем PUT либо `undefined`.
|
|
218
|
+
*/
|
|
219
|
+
export function resourceUpdateMethod(meta: ServerMeta, name: unknown, allow: unknown): UpdateMethod | undefined {
|
|
220
|
+
if (!Array.isArray(allow)) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
return (["patch", "put"] as const).find((method) => allow.includes(method) && resourceAllowed(meta, name, method));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Finds the configured GET that governs page visibility.
|
|
228
|
+
* @param schema Application resources, component defaults and named definitions.
|
|
229
|
+
* @param page The page whose children declare the data-bearing component.
|
|
230
|
+
* @returns The first list or anchored form resource in page order, if any.
|
|
231
|
+
*/
|
|
232
|
+
export function pageReadResource<T>(schema: Schema<T>, page: ComponentDefinition | undefined): string | undefined {
|
|
233
|
+
/**
|
|
234
|
+
* Traverses mounted children in rendering order.
|
|
235
|
+
* @param nodes Configured children.
|
|
236
|
+
* @param anchored Whether the current branch is in a nailed modal.
|
|
237
|
+
* @param ancestors Definitions already visited on the current path.
|
|
238
|
+
* @returns The first resource used for a GET.
|
|
239
|
+
*/
|
|
240
|
+
function find(
|
|
241
|
+
nodes: readonly ComponentDefinition[],
|
|
242
|
+
anchored = false,
|
|
243
|
+
ancestors: readonly ComponentDefinition[] = [],
|
|
244
|
+
): string | undefined {
|
|
245
|
+
if (ancestors.length > 32) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
for (const node of nodes) {
|
|
249
|
+
if (ancestors.includes(node)) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const branch = [...ancestors, node],
|
|
253
|
+
referencedComponent = typeof node.of === "string" ? schema.componentDefinitions[node.of] : undefined;
|
|
254
|
+
if (referencedComponent) {
|
|
255
|
+
if (ancestors.includes(referencedComponent)) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const resource = find(
|
|
259
|
+
[
|
|
260
|
+
{
|
|
261
|
+
...referencedComponent,
|
|
262
|
+
...node,
|
|
263
|
+
...(referencedComponent.of === undefined ? {} : { of: referencedComponent.of }),
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
anchored,
|
|
267
|
+
[...branch, referencedComponent],
|
|
268
|
+
);
|
|
269
|
+
if (resource) {
|
|
270
|
+
return resource;
|
|
271
|
+
}
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const { node: resolved, childOf } = schema.configuredComponent(node);
|
|
275
|
+
if (resolved.of === "modal" && resolved.landing !== "nailed") {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const access = object(resolved.resources) ? resolved.resources.access : undefined;
|
|
279
|
+
if (
|
|
280
|
+
anchored &&
|
|
281
|
+
resolved.of === "form" &&
|
|
282
|
+
resolved.mountTo === undefined &&
|
|
283
|
+
typeof access === "string" &&
|
|
284
|
+
Array.isArray(resolved.storeWith) &&
|
|
285
|
+
resolved.storeWith.includes("resource") &&
|
|
286
|
+
findResourceMethod(findResource(schema.metadata, access), "get")
|
|
287
|
+
) {
|
|
288
|
+
return access;
|
|
289
|
+
}
|
|
290
|
+
if (resolved.of === "records") {
|
|
291
|
+
const resource = recordsLoaderResource(resolved, childOf("loader"));
|
|
292
|
+
if (resource) {
|
|
293
|
+
return resource;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const resource = find(resolved.children ?? [], anchored || resolved.of === "modal", branch);
|
|
297
|
+
if (resource) {
|
|
298
|
+
return resource;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return page ? find([page]) : undefined;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Resolves an unparameterized current-owner resource; this is never a browser route. */
|
|
309
|
+
export function resourceOperation(meta: ServerMeta, name: string, method: string): ResourceOperation {
|
|
310
|
+
const matchedResource = findResource(meta, name),
|
|
311
|
+
operation = findResourceMethod(matchedResource, method);
|
|
312
|
+
if (
|
|
313
|
+
!object(matchedResource) ||
|
|
314
|
+
typeof matchedResource.path !== "string" ||
|
|
315
|
+
!matchedResource.path.startsWith("/") ||
|
|
316
|
+
matchedResource.path.startsWith("//") ||
|
|
317
|
+
/:[a-z_]+|[?#\s]/i.test(matchedResource.path) ||
|
|
318
|
+
!object(operation)
|
|
319
|
+
) {
|
|
320
|
+
throw new TypeError("Resource operation unavailable");
|
|
321
|
+
}
|
|
322
|
+
const root = matchedResource.root ?? operation.root;
|
|
323
|
+
return {
|
|
324
|
+
args: fields(operation.args),
|
|
325
|
+
method,
|
|
326
|
+
path: matchedResource.path,
|
|
327
|
+
...(typeof operation.kind === "string" ? { kind: operation.kind } : {}),
|
|
328
|
+
...(typeof root === "string" ? { root } : {}),
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Indexes type fields for write serialization, including versioned and default references.
|
|
334
|
+
* @param meta Server metadata with type declarations.
|
|
335
|
+
* @returns A lookup of field lists by type reference.
|
|
336
|
+
*/
|
|
337
|
+
export function resourceTypes(meta: ServerMeta): Readonly<Record<string, ResourceType>> {
|
|
338
|
+
const types = (Array.isArray(meta.types) ? meta.types : [])
|
|
339
|
+
.filter(object)
|
|
340
|
+
.filter((item) => typeof item.name === "string");
|
|
341
|
+
return configurationReferenceMap(
|
|
342
|
+
types.map((item) => [String(item.name), { fields: fields(item.fields) }]),
|
|
343
|
+
Object.fromEntries(types.map((item) => [item.name, item])),
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Checks that a server record contains the readable fields of the resource type.
|
|
349
|
+
* - Checks declared nested records and arrays before accepting a new snapshot.
|
|
350
|
+
* @param record The candidate snapshot.
|
|
351
|
+
* @param type The expected resource type.
|
|
352
|
+
* @param types The available resource types, indexed by name.
|
|
353
|
+
* @returns Whether all the declared fields can be read from the snapshot.
|
|
354
|
+
*/
|
|
355
|
+
export function isCompleteResourceRecord(
|
|
356
|
+
record: FormData,
|
|
357
|
+
type: ResourceType,
|
|
358
|
+
types: Readonly<Record<string, ResourceType>>,
|
|
359
|
+
): boolean {
|
|
360
|
+
return type.fields.every(({ kind, name, writeonly }) => {
|
|
361
|
+
if (writeonly === true) {
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
if (!Object.hasOwn(record, name)) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
const value = record[name],
|
|
368
|
+
nested = types[kind?.split(/\s+/u).find((part) => Object.hasOwn(types, part)) ?? ""];
|
|
369
|
+
if (nested === undefined || value === null) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return (Array.isArray(value) ? value : [value]).every(
|
|
373
|
+
(item) => isRecord(item) && isCompleteResourceRecord(item, nested, types),
|
|
374
|
+
);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Filters values by the declared write contract.
|
|
380
|
+
* - Keeps writable nested fields and their row identities.
|
|
381
|
+
* - An integer array can use the identifiers from a map of displayed choices.
|
|
382
|
+
* @param data Record values or serialized form values.
|
|
383
|
+
* @param operation Write operation with its accepted arguments.
|
|
384
|
+
* @param types Configured nested resource types by name.
|
|
385
|
+
* @returns Values ready for the write operation.
|
|
386
|
+
*/
|
|
387
|
+
export function declaredAttributes(
|
|
388
|
+
data: FormData,
|
|
389
|
+
operation: { readonly args?: readonly ResourceField[] },
|
|
390
|
+
types: Readonly<Record<string, ResourceType>>,
|
|
391
|
+
): FormData {
|
|
392
|
+
const args = operation.args ?? [];
|
|
393
|
+
return Object.fromEntries(
|
|
394
|
+
args.flatMap((field) => {
|
|
395
|
+
const { name } = field,
|
|
396
|
+
fieldName = name.replace(/_attributes$/, ""),
|
|
397
|
+
inputKey = Object.hasOwn(data, name)
|
|
398
|
+
? name
|
|
399
|
+
: Object.hasOwn(data, fieldName)
|
|
400
|
+
? fieldName
|
|
401
|
+
: `${name}_attributes`,
|
|
402
|
+
value = data[inputKey],
|
|
403
|
+
writeKey = inputKey.endsWith("_attributes") ? inputKey : name;
|
|
404
|
+
if (value === undefined) {
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
if (value && typeof value === "object" && args.some((other) => other.name === `${name}_attributes`)) {
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
if (field.kind === "integer array" && isRecord(value)) {
|
|
411
|
+
const identities = Object.keys(value);
|
|
412
|
+
if (identities.every((id) => /^-?\d+$/u.test(id))) {
|
|
413
|
+
return [[writeKey, identities]];
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const type = types[field.kind?.split(" ")[0] ?? ""];
|
|
417
|
+
if (!type) {
|
|
418
|
+
return [[writeKey, value]];
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const nested = (entry: FormValue): FormValue => {
|
|
422
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
423
|
+
return entry;
|
|
424
|
+
}
|
|
425
|
+
const result = declaredAttributes(
|
|
426
|
+
entry,
|
|
427
|
+
{ args: type.fields.filter((child) => !child.readonly || child.name === "id") },
|
|
428
|
+
types,
|
|
429
|
+
);
|
|
430
|
+
if (entry.id != null) {
|
|
431
|
+
result.id = entry.id;
|
|
432
|
+
}
|
|
433
|
+
if (entry._destroy !== undefined) {
|
|
434
|
+
result._destroy = entry._destroy;
|
|
435
|
+
}
|
|
436
|
+
return result;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
return [[writeKey, Array.isArray(value) ? value.map(nested) : nested(value)]];
|
|
440
|
+
}),
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Removes the IDs of deleted owned rows before recreating a record.
|
|
446
|
+
* - Keeps the record's own identity and reference IDs such as user_id.
|
|
447
|
+
* - Processes Rails nested attributes and leaves ordinary JSON fields intact.
|
|
448
|
+
* - Recreates each owned row once when a joined response repeats its identity.
|
|
449
|
+
* @param attributes Prepared attributes declared by the creation resource.
|
|
450
|
+
* @returns Attributes for POST with associations to create afresh.
|
|
451
|
+
*/
|
|
452
|
+
export function restoreAttributes(attributes: FormData): FormData {
|
|
453
|
+
return Object.fromEntries(
|
|
454
|
+
Object.entries(attributes).map(([name, value]) => {
|
|
455
|
+
if (!name.endsWith("_attributes")) {
|
|
456
|
+
return [name, value];
|
|
457
|
+
}
|
|
458
|
+
/** Recreates one owned row. @param entry Original row. @returns Its values without the deleted ID. */
|
|
459
|
+
const restoreRow = (entry: FormValue): FormValue => {
|
|
460
|
+
if (!isRecord(entry)) {
|
|
461
|
+
return entry;
|
|
462
|
+
}
|
|
463
|
+
const values = { ...entry };
|
|
464
|
+
delete values.id;
|
|
465
|
+
return restoreAttributes(values);
|
|
466
|
+
};
|
|
467
|
+
if (!Array.isArray(value)) return [name, restoreRow(value)];
|
|
468
|
+
const identities = new Set<FormValue>();
|
|
469
|
+
const rows = value.flatMap((entry) => {
|
|
470
|
+
const id = isRecord(entry) ? entry.id : undefined;
|
|
471
|
+
if (id != null) {
|
|
472
|
+
if (identities.has(id)) return [];
|
|
473
|
+
identities.add(id);
|
|
474
|
+
}
|
|
475
|
+
return [restoreRow(entry)];
|
|
476
|
+
});
|
|
477
|
+
return [name, rows];
|
|
478
|
+
}),
|
|
479
|
+
);
|
|
480
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { StockeeAsset } from "../components/Stockee.js";
|
|
2
|
+
|
|
3
|
+
const artboard = { viewBox: "0 0 24 24" },
|
|
4
|
+
avatar = { ...artboard, height: "24", width: "24" },
|
|
5
|
+
bin = "M6 7h12l-1 14H7L6 7Zm3-4h6l1 2h4v2H4V5h4l1-2Z",
|
|
6
|
+
chip = { height: "16", viewBox: "0 0 16 16", width: "16" },
|
|
7
|
+
deletePath = { d: `${bin}m1 6v10h1V9h-1Zm3 0v10h1V9h-1Z` },
|
|
8
|
+
filled = { fill: "currentColor" },
|
|
9
|
+
icon = { ...artboard, fill: "currentColor", height: "1em", width: "1em" },
|
|
10
|
+
outline = { fill: "none", stroke: "currentColor", strokeWidth: "2" },
|
|
11
|
+
user = "M12 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8ZM4 21v-3c0-5 16-5 16 0v3Z";
|
|
12
|
+
|
|
13
|
+
/** Built-in visual assets, keyed by the name used by their callers. */
|
|
14
|
+
export const Stock = Object.freeze({
|
|
15
|
+
calendarNext: { path: { ...outline, d: "M9 6l6 6-6 6" }, svg: artboard },
|
|
16
|
+
calendarPrevious: { path: { ...outline, d: "M15 18l-6-6 6-6" }, svg: artboard },
|
|
17
|
+
chipAdd: { path: { ...outline, d: "M3 8h10M8 3v10" }, svg: chip },
|
|
18
|
+
chipRemove: { path: { ...outline, d: "M4 4l8 8M12 4l-8 8" }, svg: chip },
|
|
19
|
+
close: { glyph: "×" },
|
|
20
|
+
collapse: { glyph: "▾" },
|
|
21
|
+
collectionAdd: {
|
|
22
|
+
path: { d: "M2 6H0v16h16v-2H2V6Zm20-4H6v16h16V2Zm-2 14H8V4h12v12Zm-7-11v4H9v2h4v4h2v-4h4V9h-4V5h-2Z" },
|
|
23
|
+
svg: artboard,
|
|
24
|
+
},
|
|
25
|
+
collectionRemove: { path: deletePath, svg: artboard },
|
|
26
|
+
collectionRemoveCompact: { path: { d: bin }, svg: artboard },
|
|
27
|
+
collectionRestore: {
|
|
28
|
+
path: { ...filled, d: "M12 5a7 7 0 1 1-6.32 10H3.5A9 9 0 1 0 6 5.3V2L1 7l5 5V7.83A6.97 6.97 0 0 1 12 5Z" },
|
|
29
|
+
svg: artboard,
|
|
30
|
+
},
|
|
31
|
+
copy: { path: { d: "M16 1H4v14h2V3h10V1Zm4 4H8v18h12V5Zm-2 16h-8V7h8v14Z" }, svg: artboard },
|
|
32
|
+
delete: { path: deletePath, svg: icon },
|
|
33
|
+
discord: {
|
|
34
|
+
path: {
|
|
35
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
36
|
+
d: "M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z",
|
|
37
|
+
},
|
|
38
|
+
svg: icon,
|
|
39
|
+
},
|
|
40
|
+
edit: {
|
|
41
|
+
path: {
|
|
42
|
+
d: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25ZM20.71 7.04a1 1 0 0 0 0-1.42l-2.34-2.34a1 1 0 0 0-1.42 0l-1.83 1.83 3.75 3.75 1.84-1.82Z",
|
|
43
|
+
},
|
|
44
|
+
svg: icon,
|
|
45
|
+
},
|
|
46
|
+
epic_head: {
|
|
47
|
+
path: {
|
|
48
|
+
fill: "none",
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
strokeLinecap: "round",
|
|
51
|
+
strokeLinejoin: "round",
|
|
52
|
+
strokeWidth: "1.5",
|
|
53
|
+
d: "M20 21H9l-2-3v-3H5l2-4V9a7 7 0 0 1 14 0v4l-1 4v4ZM7 9h14m-7-7 2 7M9 12h1m-3 5h3m-7-1H1m3 3-2 1",
|
|
54
|
+
},
|
|
55
|
+
svg: { ...artboard, height: "1.5em", width: "1.5em" },
|
|
56
|
+
},
|
|
57
|
+
event: {
|
|
58
|
+
path: {
|
|
59
|
+
...outline,
|
|
60
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
61
|
+
d: "M8 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm8 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM3 20v-2a5 5 0 0 1 10 0v2m2 0v-2a7 7 0 0 0-.7-3.1A5 5 0 0 1 21 18v2",
|
|
62
|
+
},
|
|
63
|
+
svg: icon,
|
|
64
|
+
},
|
|
65
|
+
expand: { glyph: "▸" },
|
|
66
|
+
facebook: {
|
|
67
|
+
path: {
|
|
68
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
69
|
+
d: "M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z",
|
|
70
|
+
},
|
|
71
|
+
svg: icon,
|
|
72
|
+
},
|
|
73
|
+
github: {
|
|
74
|
+
path: {
|
|
75
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
76
|
+
d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",
|
|
77
|
+
},
|
|
78
|
+
svg: icon,
|
|
79
|
+
},
|
|
80
|
+
image: { className: "material-icons", glyph: "image" },
|
|
81
|
+
intro: {
|
|
82
|
+
path: { d: "M5 3h13v18H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm0 14h13M7 7h7M7 11h7" },
|
|
83
|
+
svg: { ...artboard, height: "1.5em", width: "1.5em", ...outline },
|
|
84
|
+
},
|
|
85
|
+
// Speech bubble from the Kakao Developers sign-in asset.
|
|
86
|
+
kakao: {
|
|
87
|
+
path: {
|
|
88
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
89
|
+
d: "M34.001 16.5225C30.4222 16.5225 27.5225 19.0037 27.5225 22.0641C27.5225 24.0312 28.7219 25.7596 30.5292 26.7423L29.9181 29.2113C29.8954 29.285 29.9132 29.364 29.9619 29.4184C29.9975 29.457 30.0461 29.478 30.0931 29.478C30.1337 29.478 30.1742 29.464 30.2082 29.4341L32.834 27.5144C33.2117 27.5723 33.6007 27.6039 33.9994 27.6039C37.5767 27.6039 40.478 25.1226 40.478 22.0623C40.478 19.002 37.5783 16.5225 34.001 16.5225Z",
|
|
90
|
+
},
|
|
91
|
+
svg: { ...icon, viewBox: "26 15 16 16" },
|
|
92
|
+
},
|
|
93
|
+
moon: { glyph: "☾" },
|
|
94
|
+
more: { path: { ...filled, d: "M11 3h2v11l4-4 1.4 1.4L12 18l-6.4-6.6L7 10l4 4V3ZM4 20h16v2H4Z" }, svg: artboard },
|
|
95
|
+
near_me: { path: { d: "M21 3L3 10.53v.98l6.49 2.51L12 20.5h1L21 3Z" }, svg: icon },
|
|
96
|
+
next: { glyph: "▶" },
|
|
97
|
+
ok: {
|
|
98
|
+
path: {
|
|
99
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
100
|
+
d: "M12 0a6.2 6.2 0 0 0-6.194 6.195 6.2 6.2 0 0 0 6.195 6.192 6.2 6.2 0 0 0 6.193-6.192A6.2 6.2 0 0 0 12.001 0zm0 3.63a2.567 2.567 0 0 1 2.565 2.565 2.568 2.568 0 0 1-2.564 2.564 2.568 2.568 0 0 1-2.565-2.564 2.567 2.567 0 0 1 2.565-2.564zM6.807 12.6a1.814 1.814 0 0 0-.91 3.35 11.611 11.611 0 0 0 3.597 1.49l-3.462 3.463a1.815 1.815 0 0 0 2.567 2.566L12 20.066l3.405 3.403a1.813 1.813 0 0 0 2.564 0c.71-.709.71-1.858 0-2.566l-3.462-3.462a11.593 11.593 0 0 0 3.596-1.49 1.814 1.814 0 1 0-1.932-3.073 7.867 7.867 0 0 1-8.34 0c-.318-.2-.674-.29-1.024-.278z",
|
|
101
|
+
},
|
|
102
|
+
svg: icon,
|
|
103
|
+
},
|
|
104
|
+
paste: { glyph: "⎘" },
|
|
105
|
+
pause: { path: { ...filled, d: "M6 4h4v16H6zM14 4h4v16h-4z" }, svg: artboard },
|
|
106
|
+
play: { path: { ...filled, d: "M7 4v16l13-8z" }, svg: artboard },
|
|
107
|
+
plus: { glyph: "+" },
|
|
108
|
+
previous: { glyph: "◀" },
|
|
109
|
+
search: {
|
|
110
|
+
path: {
|
|
111
|
+
...filled,
|
|
112
|
+
d: "M10 3a7 7 0 1 0 4.9 12l5 5 1.4-1.4-5-5A7 7 0 0 0 10 3Zm0 2a5 5 0 1 1 0 10 5 5 0 0 1 0-10Z",
|
|
113
|
+
},
|
|
114
|
+
svg: artboard,
|
|
115
|
+
},
|
|
116
|
+
signedUser: { path: { ...outline, ...filled, d: user }, svg: avatar },
|
|
117
|
+
sun: { glyph: "☀" },
|
|
118
|
+
telegram: { path: { d: "M22 3 2 10.7l5.6 2.1L18 6.7l-8.3 7.7-.3 5.4 3-2.8 4.9 3.6L22 3Z" }, svg: icon },
|
|
119
|
+
thumb_up: {
|
|
120
|
+
path: {
|
|
121
|
+
d: "M1 21h4V9H1v12ZM23 10c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2Z",
|
|
122
|
+
},
|
|
123
|
+
svg: icon,
|
|
124
|
+
},
|
|
125
|
+
user: { path: { ...outline, d: user }, svg: avatar },
|
|
126
|
+
vk: {
|
|
127
|
+
path: {
|
|
128
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
129
|
+
d: "m9.489.004.729-.003h3.564l.73.003.914.01.433.007.418.011.403.014.388.016.374.021.36.025.345.03.333.033c1.74.196 2.933.616 3.833 1.516.9.9 1.32 2.092 1.516 3.833l.034.333.029.346.025.36.02.373.025.588.012.41.013.644.009.915.004.98-.001 3.313-.003.73-.01.914-.007.433-.011.418-.014.403-.016.388-.021.374-.025.36-.03.345-.033.333c-.196 1.74-.616 2.933-1.516 3.833-.9.9-2.092 1.32-3.833 1.516l-.333.034-.346.029-.36.025-.373.02-.588.025-.41.012-.644.013-.915.009-.98.004-3.313-.001-.73-.003-.914-.01-.433-.007-.418-.011-.403-.014-.388-.016-.374-.021-.36-.025-.345-.03-.333-.033c-1.74-.196-2.933-.616-3.833-1.516-.9-.9-1.32-2.092-1.516-3.833l-.034-.333-.029-.346-.025-.36-.02-.373-.025-.588-.012-.41-.013-.644-.009-.915-.004-.98.001-3.313.003-.73.01-.914.007-.433.011-.418.014-.403.016-.388.021-.374.025-.36.03-.345.033-.333c.196-1.74.616-2.933 1.516-3.833.9-.9 2.092-1.32 3.833-1.516l.333-.034.346-.029.36-.025.373-.02.588-.025.41-.012.644-.013.915-.009ZM6.79 7.3H4.05c.13 6.24 3.25 9.99 8.72 9.99h.31v-3.57c2.01.2 3.53 1.67 4.14 3.57h2.84c-.78-2.84-2.83-4.41-4.11-5.01 1.28-.74 3.08-2.54 3.51-4.98h-2.58c-.56 1.98-2.22 3.78-3.8 3.95V7.3H10.5v6.92c-1.6-.4-3.62-2.34-3.71-6.92Z",
|
|
130
|
+
},
|
|
131
|
+
svg: icon,
|
|
132
|
+
},
|
|
133
|
+
wechat: {
|
|
134
|
+
path: {
|
|
135
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
136
|
+
d: "M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z",
|
|
137
|
+
},
|
|
138
|
+
svg: icon,
|
|
139
|
+
},
|
|
140
|
+
weibo: {
|
|
141
|
+
path: {
|
|
142
|
+
// eslint-disable-next-line id-length -- SVG uses d for path data.
|
|
143
|
+
d: "M10.098 20.323c-3.977.391-7.414-1.406-7.672-4.02-.259-2.609 2.759-5.047 6.74-5.441 3.979-.394 7.413 1.404 7.671 4.018.259 2.6-2.759 5.049-6.737 5.439l-.002.004zM9.05 17.219c-.384.616-1.208.884-1.829.602-.612-.279-.793-.991-.406-1.593.379-.595 1.176-.861 1.793-.601.622.263.82.972.442 1.592zm1.27-1.627c-.141.237-.449.353-.689.253-.236-.09-.313-.361-.177-.586.138-.227.436-.346.672-.24.239.09.315.36.18.601l.014-.028zm.176-2.719c-1.893-.493-4.033.45-4.857 2.118-.836 1.704-.026 3.591 1.886 4.21 1.983.64 4.318-.341 5.132-2.179.8-1.793-.201-3.642-2.161-4.149zm7.563-1.224c-.346-.105-.57-.18-.405-.615.375-.977.42-1.804 0-2.404-.781-1.112-2.915-1.053-5.364-.03 0 0-.766.331-.571-.271.376-1.217.315-2.224-.27-2.809-1.338-1.337-4.869.045-7.888 3.08C1.309 10.87 0 13.273 0 15.348c0 3.981 5.099 6.395 10.086 6.395 6.536 0 10.888-3.801 10.888-6.82 0-1.822-1.547-2.854-2.915-3.284v.01zm1.908-5.092c-.766-.856-1.908-1.187-2.96-.962-.436.09-.706.511-.616.932.09.42.511.691.932.602.511-.105 1.067.044 1.442.465.376.421.466.977.316 1.473-.136.406.089.856.51.992.405.119.857-.105.992-.512.33-1.021.12-2.178-.646-3.035l.03.045zm2.418-2.195c-1.576-1.757-3.905-2.419-6.054-1.968-.496.104-.812.587-.706 1.081.104.496.586.813 1.082.707 1.532-.331 3.185.15 4.296 1.383 1.112 1.246 1.429 2.943.947 4.416-.165.48.106 1.007.586 1.157.479.165.991-.104 1.157-.586.675-2.088.241-4.478-1.338-6.235l.03.045z",
|
|
144
|
+
},
|
|
145
|
+
svg: icon,
|
|
146
|
+
},
|
|
147
|
+
}) satisfies Readonly<Record<string, StockeeAsset>>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Returns the registered Tiun asset, if any.
|
|
151
|
+
* @param name Asset name.
|
|
152
|
+
* @returns Built-in asset or undefined for an unknown name.
|
|
153
|
+
*/
|
|
154
|
+
export function stockee(name: string): StockeeAsset | undefined {
|
|
155
|
+
return Object.hasOwn(Stock, name) ? Stock[name as keyof typeof Stock] : undefined;
|
|
156
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enables tracking of HTTP mutations.
|
|
3
|
+
* @param target Browser window where transport is tracked.
|
|
4
|
+
* @returns Removes the subscriber and ends tracking when the last one leaves.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- The installer attaches and removes transport hooks on the window.
|
|
7
|
+
export declare function installRequestActivity(target: Window & typeof globalThis): () => void;
|