@kardalum/plugin-sdk 0.0.0-stage → 0.16.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.
- package/CHANGELOG.md +118 -0
- package/LICENSE +202 -0
- package/README.md +80 -2
- package/dist/admin-section-registry.d.ts +34 -0
- package/dist/admin-section-registry.js +49 -0
- package/dist/built-in-serializers.d.ts +3 -0
- package/dist/built-in-serializers.js +18 -0
- package/dist/built-in-settings-schemas.d.ts +14 -0
- package/dist/built-in-settings-schemas.js +225 -0
- package/dist/built-in-value-schemas.d.ts +4 -0
- package/dist/built-in-value-schemas.js +47 -0
- package/dist/built-ins.d.ts +1 -0
- package/dist/built-ins.js +257 -0
- package/dist/capabilities.d.ts +29 -0
- package/dist/capabilities.js +67 -0
- package/dist/data-type-plugin.d.ts +28 -0
- package/dist/data-type-plugin.js +1 -0
- package/dist/datatype-validation.d.ts +26 -0
- package/dist/datatype-validation.js +110 -0
- package/dist/datatypes-entry.d.ts +4 -0
- package/dist/datatypes-entry.js +18 -0
- package/dist/define-plugin.d.ts +25 -0
- package/dist/define-plugin.js +51 -0
- package/dist/entitlement-entry.d.ts +5 -0
- package/dist/entitlement-entry.js +24 -0
- package/dist/entitlement-gate.d.ts +36 -0
- package/dist/entitlement-gate.js +201 -0
- package/dist/entitlement-types.d.ts +39 -0
- package/dist/entitlement-types.js +1 -0
- package/dist/entitlement.d.ts +57 -0
- package/dist/entitlement.js +170 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +11 -0
- package/dist/icon-name.d.ts +1 -0
- package/dist/icon-name.js +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +94 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +26 -0
- package/dist/local-host.d.ts +3 -0
- package/dist/local-host.js +38 -0
- package/dist/manifest-entry.d.ts +8 -0
- package/dist/manifest-entry.js +13 -0
- package/dist/manifest-schema.d.ts +476 -0
- package/dist/manifest-schema.js +823 -0
- package/dist/manifest.d.ts +611 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +447 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +82 -0
- package/dist/plugin-context.js +77 -0
- package/dist/plugin-screen-context.d.ts +71 -0
- package/dist/plugin-screen-context.js +41 -0
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/register-built-ins.d.ts +1 -0
- package/dist/register-built-ins.js +41 -0
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +17 -0
- package/dist/rendition-eligibility.d.ts +24 -0
- package/dist/rendition-eligibility.js +40 -0
- package/dist/richtext/block-panel.d.ts +27 -0
- package/dist/richtext/block-panel.js +232 -0
- package/dist/richtext/extensions.d.ts +19 -0
- package/dist/richtext/extensions.js +56 -0
- package/dist/richtext/insert-menu.d.ts +24 -0
- package/dist/richtext/insert-menu.js +142 -0
- package/dist/richtext/kardalum-block.d.ts +33 -0
- package/dist/richtext/kardalum-block.js +282 -0
- package/dist/richtext/style-listbox.d.ts +10 -0
- package/dist/richtext/style-listbox.js +69 -0
- package/dist/richtext/text-style-class.d.ts +18 -0
- package/dist/richtext/text-style-class.js +36 -0
- package/dist/simple-storage-value-provider.d.ts +9 -0
- package/dist/simple-storage-value-provider.js +96 -0
- package/dist/structured-storage-types.d.ts +61 -0
- package/dist/structured-storage-types.js +11 -0
- package/dist/tailwind.d.ts +1 -0
- package/dist/tailwind.js +5 -0
- package/dist/tokens/system-dark.css +75 -0
- package/dist/tokens/tokens.css +239 -0
- package/dist/tokens/tokens.json +212 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +11 -0
- package/dist/ui-entry.d.ts +5 -0
- package/dist/ui-entry.js +42 -0
- package/dist/views/content-list-preview.d.ts +1 -0
- package/dist/views/content-list-preview.js +14 -0
- package/dist/views/content-list-settings-view.d.ts +1 -0
- package/dist/views/content-list-settings-view.js +97 -0
- package/dist/views/content-list-view.d.ts +19 -0
- package/dist/views/content-list-view.js +248 -0
- package/dist/views/crop-view.d.ts +55 -0
- package/dist/views/crop-view.js +161 -0
- package/dist/views/date-range-view.d.ts +6 -0
- package/dist/views/date-range-view.js +55 -0
- package/dist/views/file-upload-view.d.ts +43 -0
- package/dist/views/file-upload-view.js +104 -0
- package/dist/views/html-code-editor.d.ts +10 -0
- package/dist/views/html-code-editor.js +101 -0
- package/dist/views/html-view.d.ts +3 -0
- package/dist/views/html-view.js +53 -0
- package/dist/views/image-view.d.ts +3 -0
- package/dist/views/image-view.js +372 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +429 -0
- package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
- package/node_modules/@kardalum/api-schemas/README.md +56 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/package.json +35 -0
- package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
- package/node_modules/@kardalum/design-tokens/README.md +29 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
- package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
- package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
- package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
- package/node_modules/@kardalum/design-tokens/package.json +42 -0
- package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
- package/node_modules/@kardalum/plugin-package/README.md +71 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
- package/node_modules/@kardalum/plugin-package/package.json +54 -0
- package/node_modules/@kardalum/ui/LICENSE +202 -0
- package/node_modules/@kardalum/ui/README.md +35 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
- package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
- package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
- package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
- package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/index.js +18 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
- package/node_modules/@kardalum/ui/package.json +63 -0
- package/package.json +146 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* S234g. What destroying a media item would break, split by whether it
|
|
4
|
+
* breaks now, only after a rollback, or only if a trashed page comes back.
|
|
5
|
+
*
|
|
6
|
+
* Counted by distinct PAGE, never by row: a picture used across seven
|
|
7
|
+
* versions of one page is one page.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MediaReferenceCountsSchema: z.ZodObject<{
|
|
10
|
+
live: z.ZodNumber;
|
|
11
|
+
history: z.ZodNumber;
|
|
12
|
+
trashed: z.ZodNumber;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type MediaReferenceCounts = z.infer<typeof MediaReferenceCountsSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* One page, field and culture that references the item, with the highest
|
|
17
|
+
* version mentioning it there.
|
|
18
|
+
*
|
|
19
|
+
* `path` rather than a name: the path is on the content node and needs no
|
|
20
|
+
* second read, and since S227 it is derived from the name, so it is
|
|
21
|
+
* recognisable. `culture` is "" for a field shared by every language.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MediaReferenceUseSchema: z.ZodObject<{
|
|
24
|
+
contentId: z.ZodString;
|
|
25
|
+
path: z.ZodString;
|
|
26
|
+
culture: z.ZodString;
|
|
27
|
+
fieldId: z.ZodString;
|
|
28
|
+
version: z.ZodNumber;
|
|
29
|
+
state: z.ZodEnum<{
|
|
30
|
+
live: "live";
|
|
31
|
+
history: "history";
|
|
32
|
+
trashed: "trashed";
|
|
33
|
+
}>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type MediaReferenceUse = z.infer<typeof MediaReferenceUseSchema>;
|
|
36
|
+
export declare const MediaReferenceListQuerySchema: z.ZodObject<{
|
|
37
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
38
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type MediaReferenceListQuery = z.infer<typeof MediaReferenceListQuerySchema>;
|
|
41
|
+
export declare const MediaReferenceListResponseSchema: z.ZodObject<{
|
|
42
|
+
counts: z.ZodObject<{
|
|
43
|
+
live: z.ZodNumber;
|
|
44
|
+
history: z.ZodNumber;
|
|
45
|
+
trashed: z.ZodNumber;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
items: z.ZodArray<z.ZodObject<{
|
|
48
|
+
contentId: z.ZodString;
|
|
49
|
+
path: z.ZodString;
|
|
50
|
+
culture: z.ZodString;
|
|
51
|
+
fieldId: z.ZodString;
|
|
52
|
+
version: z.ZodNumber;
|
|
53
|
+
state: z.ZodEnum<{
|
|
54
|
+
live: "live";
|
|
55
|
+
history: "history";
|
|
56
|
+
trashed: "trashed";
|
|
57
|
+
}>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type MediaReferenceListResponse = z.infer<typeof MediaReferenceListResponseSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* The aggregate behind the Empty trash dialog: how many files are in the
|
|
64
|
+
* bin, and how many pages every one of them together would affect.
|
|
65
|
+
*
|
|
66
|
+
* One call rather than one per file, which is why the adapter's count
|
|
67
|
+
* takes an array.
|
|
68
|
+
*/
|
|
69
|
+
export declare const MediaTrashReferenceSummarySchema: z.ZodObject<{
|
|
70
|
+
files: z.ZodNumber;
|
|
71
|
+
counts: z.ZodObject<{
|
|
72
|
+
live: z.ZodNumber;
|
|
73
|
+
history: z.ZodNumber;
|
|
74
|
+
trashed: z.ZodNumber;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type MediaTrashReferenceSummary = z.infer<typeof MediaTrashReferenceSummarySchema>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* S234g. What destroying a media item would break, split by whether it
|
|
4
|
+
* breaks now, only after a rollback, or only if a trashed page comes back.
|
|
5
|
+
*
|
|
6
|
+
* Counted by distinct PAGE, never by row: a picture used across seven
|
|
7
|
+
* versions of one page is one page.
|
|
8
|
+
*/
|
|
9
|
+
export const MediaReferenceCountsSchema = z.object({
|
|
10
|
+
live: z.number().int().nonnegative(),
|
|
11
|
+
history: z.number().int().nonnegative(),
|
|
12
|
+
trashed: z.number().int().nonnegative(),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* One page, field and culture that references the item, with the highest
|
|
16
|
+
* version mentioning it there.
|
|
17
|
+
*
|
|
18
|
+
* `path` rather than a name: the path is on the content node and needs no
|
|
19
|
+
* second read, and since S227 it is derived from the name, so it is
|
|
20
|
+
* recognisable. `culture` is "" for a field shared by every language.
|
|
21
|
+
*/
|
|
22
|
+
export const MediaReferenceUseSchema = z.object({
|
|
23
|
+
contentId: z.string().uuid(),
|
|
24
|
+
path: z.string().min(1),
|
|
25
|
+
culture: z.string(),
|
|
26
|
+
fieldId: z.string().min(1),
|
|
27
|
+
version: z.number().int().positive(),
|
|
28
|
+
state: z.enum(["live", "history", "trashed"]),
|
|
29
|
+
});
|
|
30
|
+
export const MediaReferenceListQuerySchema = z.object({
|
|
31
|
+
// NOT a uuid. The list is ordered by (contentId, fieldId, culture) and
|
|
32
|
+
// a page can contribute several rows, so a cursor naming only the
|
|
33
|
+
// content id would skip the rest of that page's rows. It is an opaque
|
|
34
|
+
// string the adapter encodes and decodes, and no caller should parse it.
|
|
35
|
+
cursor: z.string().min(1).optional(),
|
|
36
|
+
limit: z.coerce.number().int().min(1).max(100).default(25),
|
|
37
|
+
});
|
|
38
|
+
export const MediaReferenceListResponseSchema = z.object({
|
|
39
|
+
counts: MediaReferenceCountsSchema,
|
|
40
|
+
items: z.array(MediaReferenceUseSchema),
|
|
41
|
+
nextCursor: z.string().min(1).nullable(),
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* The aggregate behind the Empty trash dialog: how many files are in the
|
|
45
|
+
* bin, and how many pages every one of them together would affect.
|
|
46
|
+
*
|
|
47
|
+
* One call rather than one per file, which is why the adapter's count
|
|
48
|
+
* takes an array.
|
|
49
|
+
*/
|
|
50
|
+
export const MediaTrashReferenceSummarySchema = z.object({
|
|
51
|
+
files: z.number().int().nonnegative(),
|
|
52
|
+
counts: MediaReferenceCountsSchema,
|
|
53
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S234g. How many distinct pages reference a media item, split by what
|
|
3
|
+
* destroying the item would actually break.
|
|
4
|
+
*
|
|
5
|
+
* "Page" is the unit, not "row": a version is immutable, so one page can
|
|
6
|
+
* carry many versions that each mention the same picture, and that is
|
|
7
|
+
* still one page. `live` is a page whose currently served version (for
|
|
8
|
+
* some culture) mentions the item, or whose latest version does; the
|
|
9
|
+
* second half is there because a culture pointer names the PUBLISHED
|
|
10
|
+
* version, so a picture added in an unpublished draft is on the newest
|
|
11
|
+
* version there is. `history` is a page that mentions it only in a version
|
|
12
|
+
* that is neither served nor latest, so only a rollback would surface it
|
|
13
|
+
* again; `trashed` is a page in the trash, which wins over the other two
|
|
14
|
+
* regardless of what its cultures point at.
|
|
15
|
+
*/
|
|
16
|
+
export interface ReferenceCounts {
|
|
17
|
+
/**
|
|
18
|
+
* Distinct pages whose served version or latest version references this
|
|
19
|
+
* item, drafts included.
|
|
20
|
+
*/
|
|
21
|
+
live: number;
|
|
22
|
+
/**
|
|
23
|
+
* Distinct pages referencing it only in a version that is neither served
|
|
24
|
+
* nor the latest.
|
|
25
|
+
*/
|
|
26
|
+
history: number;
|
|
27
|
+
/** Distinct pages referencing it that are themselves in the trash. */
|
|
28
|
+
trashed: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* S234g. One page's use of a media item, in one field and culture slot.
|
|
32
|
+
*
|
|
33
|
+
* A page can hold more than one of these for the same media item, one per
|
|
34
|
+
* field (and per culture, for a translated field), which is why this is a
|
|
35
|
+
* row rather than a rollup: `ReferenceCounts` answers "how many pages,"
|
|
36
|
+
* this answers "which pages, and where in each."
|
|
37
|
+
*/
|
|
38
|
+
export interface MediaReferenceUse {
|
|
39
|
+
contentId: string;
|
|
40
|
+
path: string;
|
|
41
|
+
culture: string;
|
|
42
|
+
fieldId: string;
|
|
43
|
+
/** The highest version that references this item in this slot. */
|
|
44
|
+
version: number;
|
|
45
|
+
state: "live" | "history" | "trashed";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The cursor for a media reference listing.
|
|
49
|
+
*
|
|
50
|
+
* Opaque on purpose, and NOT a content id. The list is ordered by
|
|
51
|
+
* (contentId, fieldId, culture) and one page can contribute several rows,
|
|
52
|
+
* so a cursor naming only the page would skip that page's remaining rows
|
|
53
|
+
* entirely: with three referencing fields and a page size of two, the
|
|
54
|
+
* third became unreachable. It is encoded here and decoded by the
|
|
55
|
+
* adapter, and nothing else should parse it.
|
|
56
|
+
*
|
|
57
|
+
* base64url rather than a delimiter, because a field id is not always a
|
|
58
|
+
* declared field: the extraction also records raw keys from a version's
|
|
59
|
+
* data, which are constrained by nothing and could contain any separator
|
|
60
|
+
* character chosen.
|
|
61
|
+
*/
|
|
62
|
+
export declare function mediaReferenceCursor(use: Pick<MediaReferenceUse, "contentId" | "fieldId" | "culture"> | undefined): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Decodes a cursor produced by `mediaReferenceCursor`.
|
|
65
|
+
*
|
|
66
|
+
* Returns null rather than throwing for anything malformed: this cursor
|
|
67
|
+
* round-trips through a query string, so a person can type nonsense into
|
|
68
|
+
* it, and that has to fall back to a first page (or a 400 from the route
|
|
69
|
+
* that calls this), never a 500 from an uncaught parse error here.
|
|
70
|
+
*/
|
|
71
|
+
export declare function decodeMediaReferenceCursor(cursor: string): {
|
|
72
|
+
contentId: string;
|
|
73
|
+
fieldId: string;
|
|
74
|
+
culture: string;
|
|
75
|
+
} | null;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// No btoa/atob/TextEncoder here on purpose: this package has no "dom" lib
|
|
2
|
+
// and no @types/node dependency, because it is imported from both the
|
|
3
|
+
// server and the browser admin UI. The alphabet, the UTF-8 packing and the
|
|
4
|
+
// bit-buffer base64 below are all plain ES2022 so both runtimes get the
|
|
5
|
+
// same bytes.
|
|
6
|
+
const BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
7
|
+
/**
|
|
8
|
+
* UTF-8 bytes of `str`, using encodeURIComponent to do the actual UTF-8
|
|
9
|
+
* packing (the JS engine's own, not a hand-rolled surrogate-pair walk) and
|
|
10
|
+
* unpacking its %XX escapes into byte values.
|
|
11
|
+
*/
|
|
12
|
+
function utf8Bytes(str) {
|
|
13
|
+
const escaped = encodeURIComponent(str);
|
|
14
|
+
const bytes = [];
|
|
15
|
+
for (let i = 0; i < escaped.length; i += 1) {
|
|
16
|
+
const char = escaped[i];
|
|
17
|
+
if (char === "%") {
|
|
18
|
+
bytes.push(parseInt(escaped.slice(i + 1, i + 3), 16));
|
|
19
|
+
i += 2;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
bytes.push(char.charCodeAt(0));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return bytes;
|
|
26
|
+
}
|
|
27
|
+
function utf8String(bytes) {
|
|
28
|
+
let escaped = "";
|
|
29
|
+
for (const byte of bytes)
|
|
30
|
+
escaped += `%${byte.toString(16).padStart(2, "0")}`;
|
|
31
|
+
return decodeURIComponent(escaped);
|
|
32
|
+
}
|
|
33
|
+
function base64UrlEncode(bytes) {
|
|
34
|
+
let result = "";
|
|
35
|
+
let bitBuffer = 0;
|
|
36
|
+
let bitCount = 0;
|
|
37
|
+
for (const byte of bytes) {
|
|
38
|
+
bitBuffer = (bitBuffer << 8) | byte;
|
|
39
|
+
bitCount += 8;
|
|
40
|
+
while (bitCount >= 6) {
|
|
41
|
+
bitCount -= 6;
|
|
42
|
+
result += BASE64URL_ALPHABET[(bitBuffer >> bitCount) & 0x3f];
|
|
43
|
+
}
|
|
44
|
+
bitBuffer &= (1 << bitCount) - 1;
|
|
45
|
+
}
|
|
46
|
+
if (bitCount > 0)
|
|
47
|
+
result += BASE64URL_ALPHABET[(bitBuffer << (6 - bitCount)) & 0x3f];
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
/** Returns null on any character outside the base64url alphabet. */
|
|
51
|
+
function base64UrlDecode(value) {
|
|
52
|
+
const bytes = [];
|
|
53
|
+
let bitBuffer = 0;
|
|
54
|
+
let bitCount = 0;
|
|
55
|
+
for (const char of value) {
|
|
56
|
+
const index = BASE64URL_ALPHABET.indexOf(char);
|
|
57
|
+
if (index === -1)
|
|
58
|
+
return null;
|
|
59
|
+
bitBuffer = (bitBuffer << 6) | index;
|
|
60
|
+
bitCount += 6;
|
|
61
|
+
if (bitCount >= 8) {
|
|
62
|
+
bitCount -= 8;
|
|
63
|
+
bytes.push((bitBuffer >> bitCount) & 0xff);
|
|
64
|
+
}
|
|
65
|
+
bitBuffer &= (1 << bitCount) - 1;
|
|
66
|
+
}
|
|
67
|
+
return bytes;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The cursor for a media reference listing.
|
|
71
|
+
*
|
|
72
|
+
* Opaque on purpose, and NOT a content id. The list is ordered by
|
|
73
|
+
* (contentId, fieldId, culture) and one page can contribute several rows,
|
|
74
|
+
* so a cursor naming only the page would skip that page's remaining rows
|
|
75
|
+
* entirely: with three referencing fields and a page size of two, the
|
|
76
|
+
* third became unreachable. It is encoded here and decoded by the
|
|
77
|
+
* adapter, and nothing else should parse it.
|
|
78
|
+
*
|
|
79
|
+
* base64url rather than a delimiter, because a field id is not always a
|
|
80
|
+
* declared field: the extraction also records raw keys from a version's
|
|
81
|
+
* data, which are constrained by nothing and could contain any separator
|
|
82
|
+
* character chosen.
|
|
83
|
+
*/
|
|
84
|
+
export function mediaReferenceCursor(use) {
|
|
85
|
+
if (!use)
|
|
86
|
+
return null;
|
|
87
|
+
const json = JSON.stringify([use.contentId, use.fieldId, use.culture]);
|
|
88
|
+
return base64UrlEncode(utf8Bytes(json));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Decodes a cursor produced by `mediaReferenceCursor`.
|
|
92
|
+
*
|
|
93
|
+
* Returns null rather than throwing for anything malformed: this cursor
|
|
94
|
+
* round-trips through a query string, so a person can type nonsense into
|
|
95
|
+
* it, and that has to fall back to a first page (or a 400 from the route
|
|
96
|
+
* that calls this), never a 500 from an uncaught parse error here.
|
|
97
|
+
*/
|
|
98
|
+
export function decodeMediaReferenceCursor(cursor) {
|
|
99
|
+
try {
|
|
100
|
+
const bytes = base64UrlDecode(cursor);
|
|
101
|
+
if (!bytes)
|
|
102
|
+
return null;
|
|
103
|
+
const json = utf8String(bytes);
|
|
104
|
+
const parsed = JSON.parse(json);
|
|
105
|
+
if (!Array.isArray(parsed) ||
|
|
106
|
+
parsed.length !== 3 ||
|
|
107
|
+
typeof parsed[0] !== "string" ||
|
|
108
|
+
typeof parsed[1] !== "string" ||
|
|
109
|
+
typeof parsed[2] !== "string") {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return { contentId: parsed[0], fieldId: parsed[1], culture: parsed[2] };
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S234f. Which media items a content version mentions.
|
|
3
|
+
*
|
|
4
|
+
* ONE function rather than three scattered rules, because the rules have
|
|
5
|
+
* to agree: a picture inserted through the picker AND pasted as a URL in
|
|
6
|
+
* the same field is one reference, not two, and only a single place that
|
|
7
|
+
* knows all three rules can say so.
|
|
8
|
+
*
|
|
9
|
+
* Content is immutable, so what this returns for a version is true of
|
|
10
|
+
* that version forever. That is what lets the answer be stored once at
|
|
11
|
+
* write time instead of searched for on every question.
|
|
12
|
+
*/
|
|
13
|
+
export interface MediaReference {
|
|
14
|
+
mediaId: string;
|
|
15
|
+
/** The key in the version's data. Not always a declared field: a pasted
|
|
16
|
+
* URL in `_name` is still a reference, and names itself. */
|
|
17
|
+
fieldId: string;
|
|
18
|
+
/** "" means invariant, shared by every language. Never null: all three
|
|
19
|
+
* Tier 1 dialects treat NULLs as distinct in a unique index, so a
|
|
20
|
+
* nullable culture would let duplicate rows through on every one of
|
|
21
|
+
* them. */
|
|
22
|
+
culture: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function mediaReferencesIn(fields: ReadonlyArray<{
|
|
25
|
+
id: string;
|
|
26
|
+
editorId: string;
|
|
27
|
+
}>, data: Record<string, unknown>, cultureData: Record<string, Record<string, unknown>> | null | undefined): MediaReference[];
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/** The editor whose stored value IS a media id, on its own, with nothing
|
|
2
|
+
* around it. The only one today. A third-party data type holding a media
|
|
3
|
+
* id is not found, which is a known gap with its fix named in the spec:
|
|
4
|
+
* a data type should be able to declare that its value holds media. */
|
|
5
|
+
const IMAGE_EDITOR_ID = "com.kardalum.image";
|
|
6
|
+
/** A media id is a uuid. Matched case-insensitively because a pasted URL
|
|
7
|
+
* may carry either case, and lowercased on the way out so one picture has
|
|
8
|
+
* one spelling in the table. */
|
|
9
|
+
const UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
10
|
+
const BARE_UUID = new RegExp(`^${UUID}$`, "i");
|
|
11
|
+
/** `/media/<id>/` anywhere in a string. The trailing slash is required so
|
|
12
|
+
* this matches a real media path rather than the word "media" followed by
|
|
13
|
+
* something uuid-shaped. Global, because one string can carry several. */
|
|
14
|
+
const MEDIA_URL = new RegExp(`/media/(${UUID})/`, "gi");
|
|
15
|
+
/** How deep the walk goes before it gives up. A TipTap document nests a
|
|
16
|
+
* few levels; anything approaching this is malformed or hostile, and
|
|
17
|
+
* stopping is better than recursing forever. The `seen` set below already
|
|
18
|
+
* stops a cycle, so this is the second of two belts. */
|
|
19
|
+
const MAX_DEPTH = 64;
|
|
20
|
+
export function mediaReferencesIn(fields, data, cultureData) {
|
|
21
|
+
// Built key-by-index rather than via `fields.map`: `fields` is itself a
|
|
22
|
+
// caller-supplied array, and `.map` would read `.length`, each index and
|
|
23
|
+
// then `.id`/`.editorId` off whatever came back, any of which can be a
|
|
24
|
+
// throwing accessor on a hostile or malformed document type definition.
|
|
25
|
+
// One field that refuses to be read costs only that field's entry, not
|
|
26
|
+
// the whole lookup.
|
|
27
|
+
const editorById = new Map();
|
|
28
|
+
{
|
|
29
|
+
let fieldCount;
|
|
30
|
+
try {
|
|
31
|
+
fieldCount = fields.length;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
fieldCount = 0;
|
|
35
|
+
}
|
|
36
|
+
for (let i = 0; i < fieldCount; i++) {
|
|
37
|
+
let field;
|
|
38
|
+
try {
|
|
39
|
+
field = fields[i];
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!field || typeof field !== "object")
|
|
45
|
+
continue;
|
|
46
|
+
try {
|
|
47
|
+
const { id, editorId } = field;
|
|
48
|
+
if (typeof id === "string" && typeof editorId === "string")
|
|
49
|
+
editorById.set(id, editorId);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// A field descriptor whose id or editorId refuses to be read
|
|
53
|
+
// tells us nothing. Carry on to the next one.
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Keyed on the three columns that make a row unique, so the caller
|
|
58
|
+
// never has to deduplicate and the unique index never has to refuse.
|
|
59
|
+
const found = new Map();
|
|
60
|
+
const scanSlice = (slice, culture) => {
|
|
61
|
+
// Enumerate keys with `Object.keys`, not `Object.entries`: `entries`
|
|
62
|
+
// invokes every getter in one pass to build its `[key, value]` pairs,
|
|
63
|
+
// so a single hostile top-level field would throw before the loop
|
|
64
|
+
// ever starts and take every sibling field down with it. Keys alone
|
|
65
|
+
// do not invoke getters; each value is then read on its own below.
|
|
66
|
+
let fieldIds;
|
|
67
|
+
try {
|
|
68
|
+
fieldIds = Object.keys(slice);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
for (const fieldId of fieldIds) {
|
|
74
|
+
let value;
|
|
75
|
+
try {
|
|
76
|
+
value = slice[fieldId];
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const add = (mediaId) => {
|
|
82
|
+
const id = mediaId.toLowerCase();
|
|
83
|
+
// Joined on NUL, which cannot appear in a culture, a field id or a
|
|
84
|
+
// uuid. A space could: fieldId is whatever key the data carries,
|
|
85
|
+
// including ones the document type never declared and never
|
|
86
|
+
// validated, so two different triples could otherwise collide and
|
|
87
|
+
// one reference would quietly overwrite the other.
|
|
88
|
+
found.set(`${culture}\u0000${fieldId}\u0000${id}`, { mediaId: id, fieldId, culture });
|
|
89
|
+
};
|
|
90
|
+
// Rule 1: an image field's value is a media id, bare.
|
|
91
|
+
if (editorById.get(fieldId) === IMAGE_EDITOR_ID && typeof value === "string" && BARE_UUID.test(value)) {
|
|
92
|
+
add(value);
|
|
93
|
+
}
|
|
94
|
+
// Rules 2 and 3 apply to every field, whatever its editor, because
|
|
95
|
+
// a URL can be pasted anywhere and a rich text tree can live under
|
|
96
|
+
// a data type this function has never heard of.
|
|
97
|
+
walk(value, 0, new Set(), add);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
scanSlice(data ?? {}, "");
|
|
101
|
+
// Same reasoning as `scanSlice`'s own loop: `Object.keys`, not
|
|
102
|
+
// `Object.entries`, so a throwing getter on one culture key costs only
|
|
103
|
+
// that culture, not every culture after it.
|
|
104
|
+
const cultures = cultureData ?? {};
|
|
105
|
+
let cultureKeys;
|
|
106
|
+
try {
|
|
107
|
+
cultureKeys = Object.keys(cultures);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
cultureKeys = [];
|
|
111
|
+
}
|
|
112
|
+
for (const culture of cultureKeys) {
|
|
113
|
+
let slice;
|
|
114
|
+
try {
|
|
115
|
+
slice = cultures[culture];
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (slice && typeof slice === "object")
|
|
121
|
+
scanSlice(slice, culture);
|
|
122
|
+
}
|
|
123
|
+
return [...found.values()];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Rules 2 and 3, over any value at all.
|
|
127
|
+
*
|
|
128
|
+
* Deliberately total: it inspects whatever it is handed and never throws.
|
|
129
|
+
* A malformed rich text document, a number where an object was expected,
|
|
130
|
+
* a structure that points at itself: all of them return what was found so
|
|
131
|
+
* far. A person's content save must never fail because an index could not
|
|
132
|
+
* be built, and this function is the only thing standing between a
|
|
133
|
+
* surprising value and that failure.
|
|
134
|
+
*/
|
|
135
|
+
function walk(value, depth, seen, add) {
|
|
136
|
+
if (depth > MAX_DEPTH || value === null || value === undefined)
|
|
137
|
+
return;
|
|
138
|
+
if (typeof value === "string") {
|
|
139
|
+
// Rule 3: a media URL pasted anywhere in a string.
|
|
140
|
+
for (const match of value.matchAll(MEDIA_URL)) {
|
|
141
|
+
if (match[1])
|
|
142
|
+
add(match[1]);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (typeof value !== "object")
|
|
147
|
+
return;
|
|
148
|
+
// A structure that points at itself would otherwise recurse forever.
|
|
149
|
+
if (seen.has(value))
|
|
150
|
+
return;
|
|
151
|
+
seen.add(value);
|
|
152
|
+
// Array.isArray is the one cheap type check here that can throw: it
|
|
153
|
+
// unwraps a Proxy and refuses a revoked one before inspecting
|
|
154
|
+
// anything. typeof, the null checks and the seen set are all safe
|
|
155
|
+
// against the same value, which is why only this one is wrapped. A
|
|
156
|
+
// value that will not say whether it is an array is a value nothing
|
|
157
|
+
// can be read out of, so treating it as neither is right.
|
|
158
|
+
let isArray;
|
|
159
|
+
try {
|
|
160
|
+
isArray = Array.isArray(value);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (isArray) {
|
|
166
|
+
// Read by index rather than `for...of`: iteration protocol reads
|
|
167
|
+
// `.length` and then each index through an ordinary get, and a
|
|
168
|
+
// throwing accessor defined on one index (or a hostile `.length`)
|
|
169
|
+
// would otherwise abort the loop and lose every element after it, not
|
|
170
|
+
// just the one index that refuses to be read.
|
|
171
|
+
const arr = value;
|
|
172
|
+
let length;
|
|
173
|
+
try {
|
|
174
|
+
length = arr.length;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (let i = 0; i < length; i++) {
|
|
180
|
+
let item;
|
|
181
|
+
try {
|
|
182
|
+
item = arr[i];
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
walk(item, depth + 1, seen, add);
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const record = value;
|
|
192
|
+
// Rule 2: a rich text image node names its media item in `mediaId`.
|
|
193
|
+
// Read wherever it appears rather than only under `attrs`, because the
|
|
194
|
+
// block editor carries image params in its own shape and both are the
|
|
195
|
+
// same fact.
|
|
196
|
+
//
|
|
197
|
+
// Wrapped because this function's whole contract is that it cannot
|
|
198
|
+
// throw: it runs inside a person's content save. Reading a property is
|
|
199
|
+
// not ordinarily dangerous, but the value here is whatever a caller
|
|
200
|
+
// handed over, and a getter that throws would take the save down with
|
|
201
|
+
// it. What is lost by catching is one reference nobody could have read
|
|
202
|
+
// anyway.
|
|
203
|
+
try {
|
|
204
|
+
const mediaId = record.mediaId;
|
|
205
|
+
if (typeof mediaId === "string" && BARE_UUID.test(mediaId))
|
|
206
|
+
add(mediaId);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// A property that refuses to be read tells us nothing. Carry on.
|
|
210
|
+
}
|
|
211
|
+
// Rule 4 (whole-branch review, finding 2): a `kardalumBlock` node stores
|
|
212
|
+
// an image param's value as a bare media id in `attrs.params`, with no
|
|
213
|
+
// `mediaId` key anywhere near it (kardalum-block.ts's
|
|
214
|
+
// `params: Record<string, unknown>`; render-context.ts reads the same
|
|
215
|
+
// value back as "a raw media UUID"). Rule 2 above only ever looks at
|
|
216
|
+
// `record.mediaId`, so a block's own picture went unfound by every rule:
|
|
217
|
+
// the field rule sees a rich text object rather than a string, the
|
|
218
|
+
// rich text rule reads only `mediaId`, and the url rule needs a
|
|
219
|
+
// `/media/<id>/` path, which a bare param value never has. A picture
|
|
220
|
+
// used only as a block image would report that nothing uses it, on the
|
|
221
|
+
// dialog about to destroy it.
|
|
222
|
+
//
|
|
223
|
+
// Deliberately over-matches: the partial's declared param types are not
|
|
224
|
+
// available where extraction runs, so a param holding some other uuid
|
|
225
|
+
// (not a media id at all) writes a row that names no media item. That
|
|
226
|
+
// is harmless for the same reason `media_id` carries no foreign key: a
|
|
227
|
+
// reference to something that does not exist is resolved away at read
|
|
228
|
+
// time. A missed reference is not recoverable at read time, which is
|
|
229
|
+
// why the trade runs this way.
|
|
230
|
+
let blockParams;
|
|
231
|
+
try {
|
|
232
|
+
blockParams = record.type === "kardalumBlock" ? record.attrs?.params : undefined;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
blockParams = undefined;
|
|
236
|
+
}
|
|
237
|
+
if (blockParams && typeof blockParams === "object") {
|
|
238
|
+
const paramRecord = blockParams;
|
|
239
|
+
let paramKeys;
|
|
240
|
+
try {
|
|
241
|
+
paramKeys = Object.keys(paramRecord);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
paramKeys = [];
|
|
245
|
+
}
|
|
246
|
+
for (const paramKey of paramKeys) {
|
|
247
|
+
let paramValue;
|
|
248
|
+
try {
|
|
249
|
+
paramValue = paramRecord[paramKey];
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (typeof paramValue === "string" && BARE_UUID.test(paramValue))
|
|
255
|
+
add(paramValue);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Read key-by-key, not via `Object.values`: that reads every enumerable
|
|
259
|
+
// property in one pass, so a single hostile getter anywhere in the
|
|
260
|
+
// object would abort the whole read and lose every sibling along with
|
|
261
|
+
// it, not just the one property that refuses to be read.
|
|
262
|
+
let keys;
|
|
263
|
+
try {
|
|
264
|
+
keys = Object.keys(record);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
for (const key of keys) {
|
|
270
|
+
let item;
|
|
271
|
+
try {
|
|
272
|
+
item = record[key];
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
walk(item, depth + 1, seen, add);
|
|
278
|
+
}
|
|
279
|
+
}
|