@kardalum/plugin-sdk 0.19.0 → 0.20.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 +211 -0
- package/README.md +19 -0
- package/dist/admin-section-registry.d.ts +16 -1
- package/dist/admin-section-registry.js +23 -0
- package/dist/built-in-editor-ids.d.ts +1 -1
- package/dist/built-in-editor-ids.js +2 -20
- package/dist/built-in-settings-schemas.d.ts +10 -0
- package/dist/built-in-settings-schemas.js +86 -0
- package/dist/built-in-value-schemas.js +35 -0
- package/dist/built-ins.js +38 -7
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.js +55 -3
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +22 -0
- package/dist/content-library.d.ts +85 -0
- package/dist/content-library.js +15 -0
- package/dist/content-picker/page-picker-sheet.d.ts +13 -0
- package/dist/content-picker/page-picker-sheet.js +105 -0
- package/dist/content-picker/page-tree.d.ts +25 -0
- package/dist/content-picker/page-tree.js +132 -0
- package/dist/data-type-plugin.d.ts +7 -1
- package/dist/datatype-validation.d.ts +4 -9
- package/dist/datatype-validation.js +139 -1
- package/dist/entitlement-entry.d.ts +1 -1
- package/dist/entitlement-entry.js +1 -1
- package/dist/entitlement-gate.d.ts +14 -0
- package/dist/entitlement-gate.js +64 -7
- package/dist/entitlement-plan.d.ts +6 -0
- package/dist/entitlement-plan.js +10 -0
- package/dist/entitlement-types.d.ts +36 -12
- package/dist/entitlement.d.ts +31 -4
- package/dist/entitlement.js +58 -17
- package/dist/hook-entry.d.ts +5 -0
- package/dist/hook-entry.js +30 -0
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +36 -4
- package/dist/index.js +50 -3
- package/dist/mail.d.ts +30 -0
- package/dist/mail.js +1 -0
- package/dist/manifest-entry.d.ts +29 -4
- package/dist/manifest-entry.js +39 -2
- package/dist/manifest-schema.d.ts +443 -29
- package/dist/manifest-schema.js +285 -23
- package/dist/manifest.d.ts +450 -51
- package/dist/manifest.js +1 -1
- package/dist/media/media-picker.js +31 -18
- package/dist/media/upload-error.d.ts +5 -1
- package/dist/media/upload-error.js +14 -2
- package/dist/media-library.d.ts +32 -0
- package/dist/media-library.js +15 -0
- package/dist/nested-field-host.d.ts +76 -0
- package/dist/nested-field-host.js +90 -0
- package/dist/notify.d.ts +12 -4
- package/dist/notify.js +1 -1
- package/dist/outbound.d.ts +47 -0
- package/dist/outbound.js +1 -0
- package/dist/plugin-context.d.ts +5 -0
- package/dist/plugin-screen-context.d.ts +112 -0
- package/dist/plugin-screen-context.js +26 -0
- package/dist/providers.d.ts +268 -0
- package/dist/providers.js +74 -0
- package/dist/read-all-pages.d.ts +5 -0
- package/dist/read-all-pages.js +3 -2
- package/dist/richtext/block-panel.js +11 -6
- package/dist/richtext/insert-menu.js +9 -6
- package/dist/richtext/style-listbox.js +6 -4
- package/dist/sdk-strings.d.ts +285 -0
- package/dist/sdk-strings.js +347 -0
- package/dist/sealing.d.ts +14 -0
- package/dist/sealing.js +1 -0
- package/dist/simple-storage-value-provider.js +24 -24
- package/dist/structured-storage-types.d.ts +309 -9
- package/dist/text-entry.d.ts +1 -0
- package/dist/text-entry.js +6 -0
- package/dist/tokens/tailwind-theme.css +5 -0
- package/dist/tokens/tokens.css +15 -3
- package/dist/tokens/tokens.json +8 -3
- package/dist/views/asset-view.js +4 -1
- package/dist/views/content-list-preview.js +3 -1
- package/dist/views/content-list-settings-view.js +11 -7
- package/dist/views/content-list-view.d.ts +5 -3
- package/dist/views/content-list-view.js +38 -34
- package/dist/views/content-picker-view.d.ts +3 -0
- package/dist/views/content-picker-view.js +143 -0
- package/dist/views/crop-view.d.ts +4 -6
- package/dist/views/crop-view.js +22 -13
- package/dist/views/date-range-view.js +4 -1
- package/dist/views/file-upload-view.d.ts +5 -7
- package/dist/views/file-upload-view.js +16 -7
- package/dist/views/group-view.d.ts +8 -0
- package/dist/views/group-view.js +123 -0
- package/dist/views/html-view.js +7 -6
- package/dist/views/image-view.js +37 -19
- package/dist/views/link-view.d.ts +3 -0
- package/dist/views/link-view.js +150 -0
- package/dist/views/options-list-view.d.ts +3 -0
- package/dist/views/options-list-view.js +104 -0
- package/dist/views/repeatable-list-view.d.ts +3 -0
- package/dist/views/repeatable-list-view.js +113 -0
- package/dist/views/rich-text-view.js +28 -13
- package/dist/views/suggest-key.d.ts +17 -0
- package/dist/views/suggest-key.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +215 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +179 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +7 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +4 -2
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +126 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +115 -3
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +58 -11
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +57 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +137 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +10 -5
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +7 -4
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +180 -15
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +41 -5
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +24 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +90 -5
- package/node_modules/@kardalum/api-schemas/dist/form-protection.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.js +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +117 -41
- package/node_modules/@kardalum/api-schemas/dist/index.js +89 -26
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +63 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +54 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +224 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +404 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +312 -8
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +43 -3
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.d.ts +131 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.js +272 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.d.ts +84 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.js +49 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.d.ts +211 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.js +424 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +78 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +13 -1
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.js +370 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +53 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +284 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +5 -5
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +1 -2
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +1 -2
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.js +177 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +258 -7
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +96 -5
- package/node_modules/@kardalum/api-schemas/dist/page-address.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/page-address.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +28 -3
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +55 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.d.ts +76 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.js +316 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +42 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +26 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +26 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.d.ts +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +124 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.js +51 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.js +21 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +38 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +237 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +205 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +29 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +32 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +120 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +335 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +242 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +16 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +34 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +22 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +31 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.js +150 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +310 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +430 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.d.ts +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.js +114 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +342 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +400 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +180 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +612 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +47 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +100 -12
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.d.ts +189 -0
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.js +164 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +7 -3
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +497 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +91 -1
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +90 -8
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +59 -1
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +110 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +34 -2
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +384 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +616 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.js +26 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +160 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +58 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +34 -3
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +4 -3
- package/node_modules/@kardalum/api-schemas/package.json +1 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +6 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +5 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +15 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +12 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +8 -3
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +21 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +8 -2
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +17 -10
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +355 -22
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +2 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.js +353 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.js +26 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +34 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.js +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +47 -5
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.d.ts +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +95 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.js +68 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +298 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +25 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +91 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +140 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +36 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +21 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +10 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +2 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +75 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +123 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +1 -2
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +6 -1
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +5 -4
- package/package.json +12 -2
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
// M33 K36 (Reading time 2.8 R3): the plain text of the editor's document and of HTML, with no
|
|
2
|
+
// dependency, no DOM and no node built-ins, so a plugin runs the same reader in its server code
|
|
3
|
+
// and in its browser bundle (`@kardalum/plugin-sdk/text`), and `@kardalum/client` re-exports
|
|
4
|
+
// `richTextToText` from here. `htmlToText` is one left-to-right pass over the input with no
|
|
5
|
+
// regular expression: every loop below moves the read position forward, so the cost is linear in
|
|
6
|
+
// the input it reads, which is itself capped.
|
|
7
|
+
//
|
|
8
|
+
// Both readers stop early on three limits and report the cut through `onCut`: `maxLength`
|
|
9
|
+
// characters of output, `RICH_TEXT_READ_NODES_MAX` nodes or tags visited (or 4 times `maxLength`
|
|
10
|
+
// with a floor of `RICH_TEXT_READ_NODES_FLOOR`, whichever is fewer, so a document of very many
|
|
11
|
+
// empty blocks, which add no character, is not walked in full), and for HTML
|
|
12
|
+
// `HTML_TO_TEXT_INPUT_MAX` characters of input. `richTextToText` called with no options reads as
|
|
13
|
+
// it did in 0.19 (`@kardalum/client`): no node cap, and the same output character for character.
|
|
14
|
+
import { RICH_TEXT_MAX_DEPTH } from "./rich-text-shape.js";
|
|
15
|
+
/** How many nodes (rich text) or tags (HTML) a plain text reader visits before it stops. Not the
|
|
16
|
+
* stored shape's `RICH_TEXT_MAX_NODES` (20,000): this one bounds a read of any input. */
|
|
17
|
+
export const RICH_TEXT_READ_NODES_MAX = 100_000;
|
|
18
|
+
/** The fewest nodes or tags a reader given `maxLength` may visit, however small `maxLength` is,
|
|
19
|
+
* so a short excerpt behind a few images or empty blocks still finds its text. */
|
|
20
|
+
export const RICH_TEXT_READ_NODES_FLOOR = 1024;
|
|
21
|
+
/** How many characters of HTML `htmlToText` reads (2 MiB); the rest is not read. */
|
|
22
|
+
export const HTML_TO_TEXT_INPUT_MAX = 2 * 1024 * 1024;
|
|
23
|
+
/** Whether a value can be read as a node: an object that is not an array. */
|
|
24
|
+
export function isRichTextNode(value) {
|
|
25
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
/** A node's children, or null when its `content` is not a list. */
|
|
28
|
+
export function richTextChildrenOf(node) {
|
|
29
|
+
return Array.isArray(node.content) ? node.content : null;
|
|
30
|
+
}
|
|
31
|
+
/** The node types that end a line of plain text. */
|
|
32
|
+
export const RICH_TEXT_TEXT_BLOCKS = new Set([
|
|
33
|
+
"paragraph",
|
|
34
|
+
"heading",
|
|
35
|
+
"listItem",
|
|
36
|
+
"blockquote",
|
|
37
|
+
"codeBlock",
|
|
38
|
+
"horizontalRule",
|
|
39
|
+
"tableRow",
|
|
40
|
+
"tableHeader",
|
|
41
|
+
"tableCell",
|
|
42
|
+
]);
|
|
43
|
+
/** The collected text, with the limits it stops at. */
|
|
44
|
+
class TextSink {
|
|
45
|
+
maxLength;
|
|
46
|
+
parts = [];
|
|
47
|
+
length = 0;
|
|
48
|
+
visited = 0;
|
|
49
|
+
visitLimit;
|
|
50
|
+
/** Set once a limit is reached; the reader then stops. */
|
|
51
|
+
stopped = false;
|
|
52
|
+
cut = false;
|
|
53
|
+
/** `capped` false only for `richTextToText` called with no options, which reads as 0.19 did. */
|
|
54
|
+
constructor(maxLength, capped = true) {
|
|
55
|
+
this.maxLength = maxLength;
|
|
56
|
+
this.visitLimit = !capped
|
|
57
|
+
? Number.POSITIVE_INFINITY
|
|
58
|
+
: maxLength === Number.POSITIVE_INFINITY
|
|
59
|
+
? RICH_TEXT_READ_NODES_MAX
|
|
60
|
+
: Math.min(RICH_TEXT_READ_NODES_MAX, Math.max(RICH_TEXT_READ_NODES_FLOOR, maxLength * 4));
|
|
61
|
+
}
|
|
62
|
+
/** Counts one node or tag; false (and the reader stops) once the cap is passed. */
|
|
63
|
+
visit() {
|
|
64
|
+
if (this.stopped)
|
|
65
|
+
return false;
|
|
66
|
+
if (this.visited >= this.visitLimit) {
|
|
67
|
+
this.stop();
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
this.visited += 1;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
text(value) {
|
|
74
|
+
if (this.stopped || value.length === 0)
|
|
75
|
+
return;
|
|
76
|
+
const room = this.maxLength - this.length;
|
|
77
|
+
if (value.length <= room) {
|
|
78
|
+
this.parts.push(value);
|
|
79
|
+
this.length += value.length;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let end = room;
|
|
83
|
+
// Never end on the first half of a surrogate pair.
|
|
84
|
+
if (end > 0 && isHighSurrogate(value.charCodeAt(end - 1)))
|
|
85
|
+
end -= 1;
|
|
86
|
+
if (end > 0) {
|
|
87
|
+
this.parts.push(value.slice(0, end));
|
|
88
|
+
this.length += end;
|
|
89
|
+
}
|
|
90
|
+
this.stop();
|
|
91
|
+
}
|
|
92
|
+
/** HTML text: each run of ASCII whitespace reads as one space, and none at the start of a
|
|
93
|
+
* line, as a browser shows it (in `pre` too). */
|
|
94
|
+
collapsedText(value) {
|
|
95
|
+
if (this.stopped || value.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
const last = this.parts[this.parts.length - 1];
|
|
98
|
+
let afterSpace = last === undefined || isSpace(last.charCodeAt(last.length - 1));
|
|
99
|
+
let out = "";
|
|
100
|
+
let run = 0;
|
|
101
|
+
for (let index = 0; index < value.length; index++) {
|
|
102
|
+
if (!isSpace(value.charCodeAt(index))) {
|
|
103
|
+
afterSpace = false;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
out += value.slice(run, index);
|
|
107
|
+
if (!afterSpace) {
|
|
108
|
+
out += " ";
|
|
109
|
+
afterSpace = true;
|
|
110
|
+
}
|
|
111
|
+
run = index + 1;
|
|
112
|
+
}
|
|
113
|
+
out += value.slice(run);
|
|
114
|
+
this.text(out);
|
|
115
|
+
}
|
|
116
|
+
/** A hard break in the editor's document: a line break wherever it is, as in 0.19 (two in a
|
|
117
|
+
* row are a blank line). Past `maxLength` it is not written. */
|
|
118
|
+
hardBreak() {
|
|
119
|
+
if (this.stopped || this.length >= this.maxLength)
|
|
120
|
+
return;
|
|
121
|
+
this.parts.push("\n");
|
|
122
|
+
this.length += 1;
|
|
123
|
+
}
|
|
124
|
+
/** The end of a block in the editor's document: a line break unless nothing came yet or the
|
|
125
|
+
* last thing written was one, as in 0.19. Past `maxLength` it is not written. */
|
|
126
|
+
blockBreak() {
|
|
127
|
+
if (this.stopped)
|
|
128
|
+
return;
|
|
129
|
+
const last = this.parts[this.parts.length - 1];
|
|
130
|
+
if (last === undefined || last === "\n" || this.length >= this.maxLength)
|
|
131
|
+
return;
|
|
132
|
+
this.parts.push("\n");
|
|
133
|
+
this.length += 1;
|
|
134
|
+
}
|
|
135
|
+
/** A line break, written only after some text and never twice in a row. A break past
|
|
136
|
+
* `maxLength` is not written, and is a cut only if text follows it. */
|
|
137
|
+
lineBreak() {
|
|
138
|
+
if (this.stopped)
|
|
139
|
+
return;
|
|
140
|
+
const last = this.parts[this.parts.length - 1];
|
|
141
|
+
if (last === undefined || last.endsWith("\n"))
|
|
142
|
+
return;
|
|
143
|
+
if (this.length >= this.maxLength)
|
|
144
|
+
return;
|
|
145
|
+
this.parts.push("\n");
|
|
146
|
+
this.length += 1;
|
|
147
|
+
}
|
|
148
|
+
/** A break between two runs of HTML text: a space written just before it joins the break. */
|
|
149
|
+
softBreak() {
|
|
150
|
+
if (this.stopped)
|
|
151
|
+
return;
|
|
152
|
+
const last = this.parts[this.parts.length - 1];
|
|
153
|
+
if (last !== undefined && last.endsWith(" ")) {
|
|
154
|
+
if (last.length === 1)
|
|
155
|
+
this.parts.pop();
|
|
156
|
+
else
|
|
157
|
+
this.parts[this.parts.length - 1] = last.slice(0, -1);
|
|
158
|
+
this.length -= 1;
|
|
159
|
+
}
|
|
160
|
+
this.lineBreak();
|
|
161
|
+
}
|
|
162
|
+
/** A part of the document was left out without stopping the read (the depth cap). */
|
|
163
|
+
skipped() {
|
|
164
|
+
this.cut = true;
|
|
165
|
+
}
|
|
166
|
+
stop() {
|
|
167
|
+
this.stopped = true;
|
|
168
|
+
this.cut = true;
|
|
169
|
+
}
|
|
170
|
+
/** The text, without trailing line breaks (and, `trimSpace`, without a trailing space). */
|
|
171
|
+
result(onCut, trimSpace = false) {
|
|
172
|
+
if (this.cut)
|
|
173
|
+
onCut?.();
|
|
174
|
+
let end = this.parts.length;
|
|
175
|
+
while (end > 0 && this.parts[end - 1] === "\n")
|
|
176
|
+
end--;
|
|
177
|
+
const text = this.parts.slice(0, end).join("");
|
|
178
|
+
return trimSpace && text.endsWith(" ") ? text.slice(0, -1) : text;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function isHighSurrogate(code) {
|
|
182
|
+
return code >= 0xd800 && code <= 0xdbff;
|
|
183
|
+
}
|
|
184
|
+
function isSpace(code) {
|
|
185
|
+
return code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0c || code === 0x0d;
|
|
186
|
+
}
|
|
187
|
+
function maxLengthOf(options) {
|
|
188
|
+
const maxLength = options?.maxLength;
|
|
189
|
+
if (maxLength === undefined)
|
|
190
|
+
return Number.POSITIVE_INFINITY;
|
|
191
|
+
if (typeof maxLength !== "number" || !Number.isInteger(maxLength) || maxLength < 0) {
|
|
192
|
+
throw new TypeError("maxLength must be a whole number of zero or more");
|
|
193
|
+
}
|
|
194
|
+
return maxLength;
|
|
195
|
+
}
|
|
196
|
+
function textNode(value, depth, sink) {
|
|
197
|
+
if (!isRichTextNode(value))
|
|
198
|
+
return;
|
|
199
|
+
if (depth > RICH_TEXT_MAX_DEPTH) {
|
|
200
|
+
sink.skipped();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (!sink.visit())
|
|
204
|
+
return;
|
|
205
|
+
if (value.type === "text") {
|
|
206
|
+
if (typeof value.text === "string")
|
|
207
|
+
sink.text(value.text);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (value.type === "hardBreak") {
|
|
211
|
+
sink.hardBreak();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const content = richTextChildrenOf(value);
|
|
215
|
+
if (content !== null) {
|
|
216
|
+
for (const child of content) {
|
|
217
|
+
if (sink.stopped)
|
|
218
|
+
return;
|
|
219
|
+
textNode(child, depth + 1, sink);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (typeof value.type === "string" && RICH_TEXT_TEXT_BLOCKS.has(value.type))
|
|
223
|
+
sink.blockBreak();
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A rich text field's value as plain text, for a search index, a summary or
|
|
227
|
+
* a native text view: the text runs in order, one line per block (a table
|
|
228
|
+
* cell is a block), a line break for a hard break. No markup, no escaping
|
|
229
|
+
* (the result is text, not HTML). A bare string comes back as it is (cut to
|
|
230
|
+
* `maxLength`). Stops at `maxLength` characters, and after
|
|
231
|
+
* `RICH_TEXT_READ_NODES_MAX` nodes or 4 times `maxLength` nodes (at least
|
|
232
|
+
* `RICH_TEXT_READ_NODES_FLOOR`), whichever is fewer; leaves out what lies
|
|
233
|
+
* past `RICH_TEXT_MAX_DEPTH` levels; `onCut` hears each. Called with no
|
|
234
|
+
* options (or neither option), it reads as 0.19's `@kardalum/client` did:
|
|
235
|
+
* the same text, with no node cap.
|
|
236
|
+
*/
|
|
237
|
+
export function richTextToText(doc, options) {
|
|
238
|
+
const capped = options !== undefined && (options.maxLength !== undefined || options.onCut !== undefined);
|
|
239
|
+
const sink = new TextSink(maxLengthOf(options), capped);
|
|
240
|
+
if (typeof doc === "string") {
|
|
241
|
+
sink.text(doc);
|
|
242
|
+
}
|
|
243
|
+
else if (isRichTextNode(doc)) {
|
|
244
|
+
textNode(doc, 0, sink);
|
|
245
|
+
}
|
|
246
|
+
return sink.result(options?.onCut);
|
|
247
|
+
}
|
|
248
|
+
// --- HTML ---
|
|
249
|
+
/** The named references `htmlToText` decodes; any other stays as written. */
|
|
250
|
+
const NAMED_REFERENCES = new Map([
|
|
251
|
+
["amp", "&"],
|
|
252
|
+
["lt", "<"],
|
|
253
|
+
["gt", ">"],
|
|
254
|
+
["quot", '"'],
|
|
255
|
+
["apos", "'"],
|
|
256
|
+
["nbsp", " "],
|
|
257
|
+
]);
|
|
258
|
+
/** The longest name in the table above. */
|
|
259
|
+
const NAMED_REFERENCE_LENGTH_MAX = 4;
|
|
260
|
+
const DECIMAL_DIGITS_MAX = 7;
|
|
261
|
+
const HEX_DIGITS_MAX = 6;
|
|
262
|
+
/** Elements whose contents give no text. */
|
|
263
|
+
const SKIPPED_ELEMENTS = new Set(["script", "style", "template"]);
|
|
264
|
+
/** Inline (phrasing) elements: their tags are no break, so `Kar<b>da</b>lum` reads as one word.
|
|
265
|
+
* A closed set; every other tag, `br` and `img` among them, reads as a break. */
|
|
266
|
+
const INLINE_ELEMENTS = new Set([
|
|
267
|
+
"a", "abbr", "b", "bdi", "bdo", "cite", "code", "data", "del", "dfn", "em", "font", "i", "ins",
|
|
268
|
+
"kbd", "mark", "q", "s", "samp", "small", "span", "strike", "strong", "sub", "sup", "time", "tt",
|
|
269
|
+
"u", "var", "wbr",
|
|
270
|
+
]);
|
|
271
|
+
function isAsciiLetter(code) {
|
|
272
|
+
return (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a);
|
|
273
|
+
}
|
|
274
|
+
function isDecimalDigit(code) {
|
|
275
|
+
return code >= 0x30 && code <= 0x39;
|
|
276
|
+
}
|
|
277
|
+
function isHexDigit(code) {
|
|
278
|
+
return isDecimalDigit(code) || (code >= 0x41 && code <= 0x46) || (code >= 0x61 && code <= 0x66);
|
|
279
|
+
}
|
|
280
|
+
function isAsciiAlphanumeric(code) {
|
|
281
|
+
return isAsciiLetter(code) || isDecimalDigit(code);
|
|
282
|
+
}
|
|
283
|
+
/** Whether `<` at `index` starts a tag: only before an ASCII letter, `/`, `!` or `?`. */
|
|
284
|
+
function startsTag(html, index, end) {
|
|
285
|
+
if (index + 1 >= end)
|
|
286
|
+
return false;
|
|
287
|
+
const next = html.charCodeAt(index + 1);
|
|
288
|
+
return isAsciiLetter(next) || next === 0x2f || next === 0x21 || next === 0x3f;
|
|
289
|
+
}
|
|
290
|
+
/** The index just past the `>` that ends the tag opening at `start`, skipping a quoted
|
|
291
|
+
* attribute value (a quote right after `=`, spaces allowed between); `end` when the tag is
|
|
292
|
+
* never closed. */
|
|
293
|
+
function tagEnd(html, start, end) {
|
|
294
|
+
let quote = 0;
|
|
295
|
+
let afterEquals = false;
|
|
296
|
+
for (let index = start + 1; index < end; index++) {
|
|
297
|
+
const code = html.charCodeAt(index);
|
|
298
|
+
if (quote !== 0) {
|
|
299
|
+
if (code === quote)
|
|
300
|
+
quote = 0;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (code === 0x3e)
|
|
304
|
+
return index + 1;
|
|
305
|
+
if (afterEquals && (code === 0x22 || code === 0x27)) {
|
|
306
|
+
quote = code;
|
|
307
|
+
afterEquals = false;
|
|
308
|
+
}
|
|
309
|
+
else if (code === 0x3d) {
|
|
310
|
+
afterEquals = true;
|
|
311
|
+
}
|
|
312
|
+
else if (!isSpace(code)) {
|
|
313
|
+
afterEquals = false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return end;
|
|
317
|
+
}
|
|
318
|
+
/** The lower-cased tag name read from `start` (just past `<` or `</`). */
|
|
319
|
+
function tagNameAt(html, start, end) {
|
|
320
|
+
let index = start;
|
|
321
|
+
while (index < end && (isAsciiAlphanumeric(html.charCodeAt(index)) || html.charCodeAt(index) === 0x2d))
|
|
322
|
+
index++;
|
|
323
|
+
return html.slice(start, index).toLowerCase();
|
|
324
|
+
}
|
|
325
|
+
/** Whether a tag named `name` (lower case) starts at `start` (just past `<` or `</`):
|
|
326
|
+
* the name, then a space, `/`, `>` or the end. */
|
|
327
|
+
function namedTagAt(html, start, end, name) {
|
|
328
|
+
if (start + name.length > end)
|
|
329
|
+
return false;
|
|
330
|
+
for (let offset = 0; offset < name.length; offset++) {
|
|
331
|
+
const code = html.charCodeAt(start + offset);
|
|
332
|
+
const lower = code >= 0x41 && code <= 0x5a ? code + 0x20 : code;
|
|
333
|
+
if (lower !== name.charCodeAt(offset))
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
const after = start + name.length;
|
|
337
|
+
if (after === end)
|
|
338
|
+
return true;
|
|
339
|
+
const code = html.charCodeAt(after);
|
|
340
|
+
return isSpace(code) || code === 0x2f || code === 0x3e;
|
|
341
|
+
}
|
|
342
|
+
/** The index just past the end tag of the skipped element `name` whose start tag ended at
|
|
343
|
+
* `from`, counting nested `template` tags; `end` when it is never closed. Each tag it steps
|
|
344
|
+
* over is visited. */
|
|
345
|
+
function skippedElementEnd(html, from, end, name, sink) {
|
|
346
|
+
let depth = 1;
|
|
347
|
+
let index = from;
|
|
348
|
+
while (index < end) {
|
|
349
|
+
const open = html.indexOf("<", index);
|
|
350
|
+
if (open === -1 || open >= end)
|
|
351
|
+
return end;
|
|
352
|
+
if (open + 1 < end && html.charCodeAt(open + 1) === 0x2f && namedTagAt(html, open + 2, end, name)) {
|
|
353
|
+
if (!sink.visit())
|
|
354
|
+
return end;
|
|
355
|
+
index = tagEnd(html, open, end);
|
|
356
|
+
depth -= 1;
|
|
357
|
+
if (depth === 0)
|
|
358
|
+
return index;
|
|
359
|
+
}
|
|
360
|
+
else if (name === "template" && namedTagAt(html, open + 1, end, name)) {
|
|
361
|
+
if (!sink.visit())
|
|
362
|
+
return end;
|
|
363
|
+
index = tagEnd(html, open, end);
|
|
364
|
+
depth += 1;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
index = open + 1;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return end;
|
|
371
|
+
}
|
|
372
|
+
/** Reads a character reference at `amp` (an `&`): its text and the index after it, or null
|
|
373
|
+
* when it is not one this reader decodes (the `&` is then text). */
|
|
374
|
+
function referenceAt(html, amp, end) {
|
|
375
|
+
let index = amp + 1;
|
|
376
|
+
if (index < end && html.charCodeAt(index) === 0x23) {
|
|
377
|
+
index += 1;
|
|
378
|
+
let hex = false;
|
|
379
|
+
if (index < end && (html.charCodeAt(index) === 0x78 || html.charCodeAt(index) === 0x58)) {
|
|
380
|
+
hex = true;
|
|
381
|
+
index += 1;
|
|
382
|
+
}
|
|
383
|
+
const digitsStart = index;
|
|
384
|
+
const limit = hex ? HEX_DIGITS_MAX : DECIMAL_DIGITS_MAX;
|
|
385
|
+
// Reads one digit past the limit at most, so a long run costs nothing extra.
|
|
386
|
+
while (index < end && index - digitsStart <= limit && (hex ? isHexDigit(html.charCodeAt(index)) : isDecimalDigit(html.charCodeAt(index))))
|
|
387
|
+
index++;
|
|
388
|
+
const digits = index - digitsStart;
|
|
389
|
+
if (digits === 0 || digits > limit || index >= end || html.charCodeAt(index) !== 0x3b)
|
|
390
|
+
return null;
|
|
391
|
+
const code = Number.parseInt(html.slice(digitsStart, index), hex ? 16 : 10);
|
|
392
|
+
const valid = code !== 0 && code <= 0x10ffff && !(code >= 0xd800 && code <= 0xdfff);
|
|
393
|
+
return { text: valid ? String.fromCodePoint(code) : "�", next: index + 1 };
|
|
394
|
+
}
|
|
395
|
+
const nameStart = index;
|
|
396
|
+
while (index < end && index - nameStart <= NAMED_REFERENCE_LENGTH_MAX && isAsciiAlphanumeric(html.charCodeAt(index)))
|
|
397
|
+
index++;
|
|
398
|
+
if (index >= end || html.charCodeAt(index) !== 0x3b)
|
|
399
|
+
return null;
|
|
400
|
+
const decoded = NAMED_REFERENCES.get(html.slice(nameStart, index));
|
|
401
|
+
return decoded === undefined ? null : { text: decoded, next: index + 1 };
|
|
402
|
+
}
|
|
403
|
+
/** Writes the text between `from` and `to`, decoding character references. */
|
|
404
|
+
function writeText(html, from, to, sink) {
|
|
405
|
+
let run = from;
|
|
406
|
+
let index = from;
|
|
407
|
+
// A scan bounded by `to` (never `indexOf`, which would look past it on every call).
|
|
408
|
+
while (index < to && !sink.stopped) {
|
|
409
|
+
if (html.charCodeAt(index) !== 0x26) {
|
|
410
|
+
index++;
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
const reference = referenceAt(html, index, to);
|
|
414
|
+
if (reference === null) {
|
|
415
|
+
index++;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
sink.collapsedText(html.slice(run, index));
|
|
419
|
+
sink.text(reference.text);
|
|
420
|
+
run = reference.next;
|
|
421
|
+
index = reference.next;
|
|
422
|
+
}
|
|
423
|
+
if (sink.stopped)
|
|
424
|
+
return;
|
|
425
|
+
sink.collapsedText(html.slice(run, to));
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* The text a reader sees in a piece of HTML, for a word count, a search index
|
|
429
|
+
* or an excerpt. One left-to-right pass, no regular expression, no DOM. A tag
|
|
430
|
+
* of an inline element (`a`, `b`, `em`, `span`, `strong` and the rest of a
|
|
431
|
+
* closed set) is no break, so `Kar<b>da</b>lum` is one word; every other tag
|
|
432
|
+
* (`br` and `img` too) reads as a line break, never at the start and never two
|
|
433
|
+
* in a row. Each run of ASCII whitespace reads as one space (none at the start
|
|
434
|
+
* of a line, before a break or at the end), as a browser shows it; a decoded
|
|
435
|
+
* ` ` stays. Comments and the contents of `script`, `style` and
|
|
436
|
+
* `template` give nothing; `<` starts a tag
|
|
437
|
+
* only before an ASCII letter, `/`, `!` or `?`, otherwise it is text.
|
|
438
|
+
* `&`, `<`, `>`, `"`, `'`, ` ` and numeric references
|
|
439
|
+
* (`'`, `'`) are decoded: a numeric reference to U+0000, a surrogate
|
|
440
|
+
* or past U+10FFFF becomes U+FFFD, and one longer than 7 decimal or 6 hex
|
|
441
|
+
* digits, or without its `;`, stays as written, as does any other named
|
|
442
|
+
* reference. Reads at most `HTML_TO_TEXT_INPUT_MAX` characters of input and
|
|
443
|
+
* stops at `maxLength` characters of output, or after `RICH_TEXT_READ_NODES_MAX`
|
|
444
|
+
* tags or 4 times `maxLength` tags (at least `RICH_TEXT_READ_NODES_FLOOR`),
|
|
445
|
+
* whichever is fewer; `onCut` hears each.
|
|
446
|
+
* Never throws for any string (a value that is not one gives "").
|
|
447
|
+
*/
|
|
448
|
+
export function htmlToText(html, options) {
|
|
449
|
+
const sink = new TextSink(maxLengthOf(options));
|
|
450
|
+
if (typeof html !== "string")
|
|
451
|
+
return "";
|
|
452
|
+
const end = Math.min(html.length, HTML_TO_TEXT_INPUT_MAX);
|
|
453
|
+
let index = 0;
|
|
454
|
+
let textStart = 0;
|
|
455
|
+
while (index < end && !sink.stopped) {
|
|
456
|
+
const open = html.indexOf("<", index);
|
|
457
|
+
if (open === -1 || open >= end)
|
|
458
|
+
break;
|
|
459
|
+
if (!startsTag(html, open, end)) {
|
|
460
|
+
index = open + 1;
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
writeText(html, textStart, open, sink);
|
|
464
|
+
if (sink.stopped || !sink.visit())
|
|
465
|
+
break;
|
|
466
|
+
const next = html.charCodeAt(open + 1);
|
|
467
|
+
if (next === 0x21 && html.startsWith("--", open + 2)) {
|
|
468
|
+
// A comment: skipped to its `-->`, with no break.
|
|
469
|
+
const close = html.indexOf("-->", open + 4);
|
|
470
|
+
index = close === -1 || close + 3 > end ? end : close + 3;
|
|
471
|
+
}
|
|
472
|
+
else if (next === 0x21 || next === 0x3f) {
|
|
473
|
+
// A declaration or a processing instruction: skipped to its `>`.
|
|
474
|
+
const close = html.indexOf(">", open + 2);
|
|
475
|
+
index = close === -1 || close >= end ? end : close + 1;
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
index = tagEnd(html, open, end);
|
|
479
|
+
const closing = next === 0x2f;
|
|
480
|
+
const name = tagNameAt(html, closing ? open + 2 : open + 1, end);
|
|
481
|
+
if (!INLINE_ELEMENTS.has(name))
|
|
482
|
+
sink.softBreak();
|
|
483
|
+
if (!closing) {
|
|
484
|
+
if (SKIPPED_ELEMENTS.has(name)) {
|
|
485
|
+
index = skippedElementEnd(html, index, end, name, sink);
|
|
486
|
+
sink.softBreak();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
textStart = index;
|
|
491
|
+
}
|
|
492
|
+
if (!sink.stopped)
|
|
493
|
+
writeText(html, textStart, end, sink);
|
|
494
|
+
if (!sink.stopped && html.length > end)
|
|
495
|
+
sink.stop();
|
|
496
|
+
return sink.result(options?.onCut, true);
|
|
497
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const END_EFFECTS: readonly ["read_only", "off"];
|
|
3
|
+
export type EndEffect = (typeof END_EFFECTS)[number];
|
|
4
|
+
export declare const AFTER_DOWNLOAD_RULES: readonly ["author_decides", "not_refundable"];
|
|
5
|
+
export type AfterDownloadRule = (typeof AFTER_DOWNLOAD_RULES)[number];
|
|
6
|
+
export declare const SaleConditionsSchema: z.ZodObject<{
|
|
7
|
+
subscriptionStop: z.ZodEnum<{
|
|
8
|
+
off: "off";
|
|
9
|
+
read_only: "read_only";
|
|
10
|
+
}>;
|
|
11
|
+
subscriptionRefund: z.ZodEnum<{
|
|
12
|
+
off: "off";
|
|
13
|
+
read_only: "read_only";
|
|
14
|
+
}>;
|
|
15
|
+
oneTimeRefund: z.ZodEnum<{
|
|
16
|
+
off: "off";
|
|
17
|
+
read_only: "read_only";
|
|
18
|
+
}>;
|
|
19
|
+
afterDownload: z.ZodEnum<{
|
|
20
|
+
author_decides: "author_decides";
|
|
21
|
+
not_refundable: "not_refundable";
|
|
22
|
+
}>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export type SaleConditions = z.infer<typeof SaleConditionsSchema>;
|
|
25
|
+
export declare const DEFAULT_SALE_CONDITIONS: SaleConditions;
|
|
26
|
+
/** A stored value read back: nothing gives the defaults; a refused value gives them with `fellBack` (the caller logs one line). */
|
|
27
|
+
export declare function readSaleConditions(raw: unknown): {
|
|
28
|
+
conditions: SaleConditions;
|
|
29
|
+
fellBack: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** The metadata encoding, at most 60 characters. */
|
|
32
|
+
export declare function encodeSaleConditions(c: SaleConditions): string;
|
|
33
|
+
/** Split on the bar, never a pattern: five parts, "v1" first, then the schema. */
|
|
34
|
+
export declare function decodeSaleConditions(s: string): SaleConditions | null;
|
|
35
|
+
export type PlanShapeKind = "one_time" | "subscription";
|
|
36
|
+
export declare function planShapeKind(shape: string): PlanShapeKind | null;
|
|
37
|
+
/** The setting for an ending: a stop uses `subscriptionStop`; a refund uses `oneTimeRefund` for a one time plan, else `subscriptionRefund`. */
|
|
38
|
+
export declare function endEffectFor(c: SaleConditions, ending: "stop" | "refund", kind: PlanShapeKind): EndEffect;
|
|
39
|
+
export declare const SubmissionFieldsSchema: z.ZodObject<{
|
|
40
|
+
listingId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
subscriptionStop: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
off: "off";
|
|
43
|
+
read_only: "read_only";
|
|
44
|
+
}>>;
|
|
45
|
+
subscriptionRefund: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
off: "off";
|
|
47
|
+
read_only: "read_only";
|
|
48
|
+
}>>;
|
|
49
|
+
oneTimeRefund: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
off: "off";
|
|
51
|
+
read_only: "read_only";
|
|
52
|
+
}>>;
|
|
53
|
+
afterDownload: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
author_decides: "author_decides";
|
|
55
|
+
not_refundable: "not_refundable";
|
|
56
|
+
}>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export type SubmissionFields = z.infer<typeof SubmissionFieldsSchema>;
|
|
59
|
+
/** Byte limits for `receiveForm`. */
|
|
60
|
+
export declare const SUBMISSION_FIELD_LIMITS: {
|
|
61
|
+
readonly listingId: 64;
|
|
62
|
+
readonly subscriptionStop: 16;
|
|
63
|
+
readonly subscriptionRefund: 16;
|
|
64
|
+
readonly oneTimeRefund: 16;
|
|
65
|
+
readonly afterDownload: 16;
|
|
66
|
+
};
|
|
67
|
+
export declare function submissionFieldsOf(fields: Record<string, string>): {
|
|
68
|
+
listingId: string | null;
|
|
69
|
+
conditions: SaleConditions | null;
|
|
70
|
+
} | {
|
|
71
|
+
error: string;
|
|
72
|
+
};
|
|
73
|
+
/** The CMS release that reads the sale conditions; copy says "{release}". */
|
|
74
|
+
export declare const SALE_CONDITIONS_CMS_RELEASE = "0.20.0";
|
|
75
|
+
export declare const LicenseVerdictEndWireSchema: z.ZodObject<{
|
|
76
|
+
effect: z.ZodEnum<{
|
|
77
|
+
off: "off";
|
|
78
|
+
read_only: "read_only";
|
|
79
|
+
}>;
|
|
80
|
+
refunded: z.ZodBoolean;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export type LicenseVerdictEndWire = z.infer<typeof LicenseVerdictEndWireSchema>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// M32 I6f (S1): the author's sale conditions, set once at upload on the listing:
|
|
3
|
+
// what happens on the buyer's site when a subscription stops or a sale is
|
|
4
|
+
// refunded, and whether a plugin is refundable after a download.
|
|
5
|
+
export const END_EFFECTS = ["read_only", "off"];
|
|
6
|
+
export const AFTER_DOWNLOAD_RULES = ["author_decides", "not_refundable"];
|
|
7
|
+
export const SaleConditionsSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
subscriptionStop: z.enum(END_EFFECTS),
|
|
10
|
+
subscriptionRefund: z.enum(END_EFFECTS),
|
|
11
|
+
oneTimeRefund: z.enum(END_EFFECTS),
|
|
12
|
+
afterDownload: z.enum(AFTER_DOWNLOAD_RULES),
|
|
13
|
+
})
|
|
14
|
+
.strict();
|
|
15
|
+
export const DEFAULT_SALE_CONDITIONS = {
|
|
16
|
+
subscriptionStop: "read_only",
|
|
17
|
+
subscriptionRefund: "off",
|
|
18
|
+
oneTimeRefund: "off",
|
|
19
|
+
afterDownload: "author_decides",
|
|
20
|
+
};
|
|
21
|
+
/** A stored value read back: nothing gives the defaults; a refused value gives them with `fellBack` (the caller logs one line). */
|
|
22
|
+
export function readSaleConditions(raw) {
|
|
23
|
+
if (raw === null || raw === undefined)
|
|
24
|
+
return { conditions: { ...DEFAULT_SALE_CONDITIONS }, fellBack: false };
|
|
25
|
+
const parsed = SaleConditionsSchema.safeParse(raw);
|
|
26
|
+
if (parsed.success)
|
|
27
|
+
return { conditions: parsed.data, fellBack: false };
|
|
28
|
+
return { conditions: { ...DEFAULT_SALE_CONDITIONS }, fellBack: true };
|
|
29
|
+
}
|
|
30
|
+
const ENCODING_VERSION = "v1";
|
|
31
|
+
/** The metadata encoding, at most 60 characters. */
|
|
32
|
+
export function encodeSaleConditions(c) {
|
|
33
|
+
return [ENCODING_VERSION, c.subscriptionStop, c.subscriptionRefund, c.oneTimeRefund, c.afterDownload].join("|");
|
|
34
|
+
}
|
|
35
|
+
/** Split on the bar, never a pattern: five parts, "v1" first, then the schema. */
|
|
36
|
+
export function decodeSaleConditions(s) {
|
|
37
|
+
if (typeof s !== "string" || s.length > 60)
|
|
38
|
+
return null;
|
|
39
|
+
const parts = s.split("|");
|
|
40
|
+
if (parts.length !== 5 || parts[0] !== ENCODING_VERSION)
|
|
41
|
+
return null;
|
|
42
|
+
const parsed = SaleConditionsSchema.safeParse({
|
|
43
|
+
subscriptionStop: parts[1],
|
|
44
|
+
subscriptionRefund: parts[2],
|
|
45
|
+
oneTimeRefund: parts[3],
|
|
46
|
+
afterDownload: parts[4],
|
|
47
|
+
});
|
|
48
|
+
return parsed.success ? parsed.data : null;
|
|
49
|
+
}
|
|
50
|
+
export function planShapeKind(shape) {
|
|
51
|
+
if (shape === "one_time")
|
|
52
|
+
return "one_time";
|
|
53
|
+
if (shape === "monthly" || shape === "yearly")
|
|
54
|
+
return "subscription";
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/** The setting for an ending: a stop uses `subscriptionStop`; a refund uses `oneTimeRefund` for a one time plan, else `subscriptionRefund`. */
|
|
58
|
+
export function endEffectFor(c, ending, kind) {
|
|
59
|
+
if (ending === "stop")
|
|
60
|
+
return c.subscriptionStop;
|
|
61
|
+
return kind === "one_time" ? c.oneTimeRefund : c.subscriptionRefund;
|
|
62
|
+
}
|
|
63
|
+
export const SubmissionFieldsSchema = z
|
|
64
|
+
.object({
|
|
65
|
+
listingId: z.string().uuid().optional(),
|
|
66
|
+
subscriptionStop: z.enum(END_EFFECTS).optional(),
|
|
67
|
+
subscriptionRefund: z.enum(END_EFFECTS).optional(),
|
|
68
|
+
oneTimeRefund: z.enum(END_EFFECTS).optional(),
|
|
69
|
+
afterDownload: z.enum(AFTER_DOWNLOAD_RULES).optional(),
|
|
70
|
+
})
|
|
71
|
+
.refine((f) => {
|
|
72
|
+
const n = [f.subscriptionStop, f.subscriptionRefund, f.oneTimeRefund, f.afterDownload].filter((v) => v !== undefined).length;
|
|
73
|
+
return n === 0 || n === 4;
|
|
74
|
+
}, { message: "Choose all four sale conditions, or upload from the generic page." });
|
|
75
|
+
/** Byte limits for `receiveForm`. */
|
|
76
|
+
export const SUBMISSION_FIELD_LIMITS = { listingId: 64, subscriptionStop: 16, subscriptionRefund: 16, oneTimeRefund: 16, afterDownload: 16 };
|
|
77
|
+
export function submissionFieldsOf(fields) {
|
|
78
|
+
const pick = (k) => (typeof fields[k] === "string" && fields[k] !== "" ? fields[k] : undefined);
|
|
79
|
+
const parsed = SubmissionFieldsSchema.safeParse({
|
|
80
|
+
listingId: pick("listingId"),
|
|
81
|
+
subscriptionStop: pick("subscriptionStop"),
|
|
82
|
+
subscriptionRefund: pick("subscriptionRefund"),
|
|
83
|
+
oneTimeRefund: pick("oneTimeRefund"),
|
|
84
|
+
afterDownload: pick("afterDownload"),
|
|
85
|
+
});
|
|
86
|
+
if (!parsed.success)
|
|
87
|
+
return { error: parsed.error.issues[0]?.message ?? "The sale conditions are not valid." };
|
|
88
|
+
const f = parsed.data;
|
|
89
|
+
if (f.subscriptionStop === undefined || f.subscriptionRefund === undefined || f.oneTimeRefund === undefined || f.afterDownload === undefined) {
|
|
90
|
+
return { listingId: f.listingId ?? null, conditions: null };
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
listingId: f.listingId ?? null,
|
|
94
|
+
conditions: { subscriptionStop: f.subscriptionStop, subscriptionRefund: f.subscriptionRefund, oneTimeRefund: f.oneTimeRefund, afterDownload: f.afterDownload },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** The CMS release that reads the sale conditions; copy says "{release}". */
|
|
98
|
+
export const SALE_CONDITIONS_CMS_RELEASE = "0.20.0";
|
|
99
|
+
export const LicenseVerdictEndWireSchema = z.object({ effect: z.enum(END_EFFECTS), refunded: z.boolean() });
|