@elytracms/core 0.0.6
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/LICENSE +21 -0
- package/dist/clipboard/build.d.ts +77 -0
- package/dist/clipboard/build.js +128 -0
- package/dist/clipboard/build.js.map +1 -0
- package/dist/clipboard/clipboard.d.ts +33 -0
- package/dist/clipboard/clipboard.js +45 -0
- package/dist/clipboard/clipboard.js.map +1 -0
- package/dist/clipboard/fragment.d.ts +112 -0
- package/dist/clipboard/fragment.js +79 -0
- package/dist/clipboard/fragment.js.map +1 -0
- package/dist/clipboard/html.d.ts +26 -0
- package/dist/clipboard/html.js +82 -0
- package/dist/clipboard/html.js.map +1 -0
- package/dist/clipboard/index.d.ts +15 -0
- package/dist/clipboard/index.js +16 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/clipboard/references.d.ts +50 -0
- package/dist/clipboard/references.js +0 -0
- package/dist/clipboard/references.js.map +1 -0
- package/dist/clipboard/serialize.d.ts +69 -0
- package/dist/clipboard/serialize.js +130 -0
- package/dist/clipboard/serialize.js.map +1 -0
- package/dist/cms-core/collections.d.ts +82 -0
- package/dist/cms-core/collections.js +187 -0
- package/dist/cms-core/collections.js.map +1 -0
- package/dist/cms-core/documents.d.ts +71 -0
- package/dist/cms-core/documents.js +67 -0
- package/dist/cms-core/documents.js.map +1 -0
- package/dist/cms-core/envelopes.d.ts +80 -0
- package/dist/cms-core/envelopes.js +124 -0
- package/dist/cms-core/envelopes.js.map +1 -0
- package/dist/cms-core/fields.d.ts +220 -0
- package/dist/cms-core/fields.js +250 -0
- package/dist/cms-core/fields.js.map +1 -0
- package/dist/cms-core/fixtures.d.ts +92 -0
- package/dist/cms-core/fixtures.js +357 -0
- package/dist/cms-core/fixtures.js.map +1 -0
- package/dist/cms-core/hierarchy.d.ts +113 -0
- package/dist/cms-core/hierarchy.js +223 -0
- package/dist/cms-core/hierarchy.js.map +1 -0
- package/dist/cms-core/index.d.ts +25 -0
- package/dist/cms-core/index.js +26 -0
- package/dist/cms-core/index.js.map +1 -0
- package/dist/cms-core/infer.d.ts +103 -0
- package/dist/cms-core/infer.js +57 -0
- package/dist/cms-core/infer.js.map +1 -0
- package/dist/cms-core/issues.d.ts +92 -0
- package/dist/cms-core/issues.js +74 -0
- package/dist/cms-core/issues.js.map +1 -0
- package/dist/cms-core/json-schema.d.ts +25 -0
- package/dist/cms-core/json-schema.js +110 -0
- package/dist/cms-core/json-schema.js.map +1 -0
- package/dist/cms-core/localization.d.ts +51 -0
- package/dist/cms-core/localization.js +89 -0
- package/dist/cms-core/localization.js.map +1 -0
- package/dist/cms-core/routes.d.ts +76 -0
- package/dist/cms-core/routes.js +220 -0
- package/dist/cms-core/routes.js.map +1 -0
- package/dist/cms-core/self-type.d.ts +41 -0
- package/dist/cms-core/self-type.js +191 -0
- package/dist/cms-core/self-type.js.map +1 -0
- package/dist/cms-core/url-for-document.d.ts +39 -0
- package/dist/cms-core/url-for-document.js +138 -0
- package/dist/cms-core/url-for-document.js.map +1 -0
- package/dist/cms-core/validate-document.d.ts +121 -0
- package/dist/cms-core/validate-document.js +871 -0
- package/dist/cms-core/validate-document.js.map +1 -0
- package/dist/cms-core/versions.d.ts +75 -0
- package/dist/cms-core/versions.js +97 -0
- package/dist/cms-core/versions.js.map +1 -0
- package/dist/collaboration/approval.d.ts +68 -0
- package/dist/collaboration/approval.js +104 -0
- package/dist/collaboration/approval.js.map +1 -0
- package/dist/collaboration/collaboration.d.ts +49 -0
- package/dist/collaboration/collaboration.js +56 -0
- package/dist/collaboration/collaboration.js.map +1 -0
- package/dist/collaboration/comments.d.ts +72 -0
- package/dist/collaboration/comments.js +118 -0
- package/dist/collaboration/comments.js.map +1 -0
- package/dist/collaboration/core.d.ts +25 -0
- package/dist/collaboration/core.js +26 -0
- package/dist/collaboration/core.js.map +1 -0
- package/dist/collaboration/index.d.ts +14 -0
- package/dist/collaboration/index.js +15 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/presence.d.ts +62 -0
- package/dist/collaboration/presence.js +85 -0
- package/dist/collaboration/presence.js.map +1 -0
- package/dist/collaboration/publishing.d.ts +60 -0
- package/dist/collaboration/publishing.js +93 -0
- package/dist/collaboration/publishing.js.map +1 -0
- package/dist/collaboration/versions.d.ts +52 -0
- package/dist/collaboration/versions.js +81 -0
- package/dist/collaboration/versions.js.map +1 -0
- package/dist/component-registry/index.d.ts +3 -0
- package/dist/component-registry/index.js +4 -0
- package/dist/component-registry/index.js.map +1 -0
- package/dist/component-registry/issues.d.ts +6 -0
- package/dist/component-registry/issues.js +2 -0
- package/dist/component-registry/issues.js.map +1 -0
- package/dist/component-registry/manifest.d.ts +164 -0
- package/dist/component-registry/manifest.js +129 -0
- package/dist/component-registry/manifest.js.map +1 -0
- package/dist/component-registry/registry.d.ts +33 -0
- package/dist/component-registry/registry.js +90 -0
- package/dist/component-registry/registry.js.map +1 -0
- package/dist/content/__fixtures__/filterable-collections.d.ts +14 -0
- package/dist/content/__fixtures__/filterable-collections.js +15 -0
- package/dist/content/__fixtures__/filterable-collections.js.map +1 -0
- package/dist/content/__fixtures__/sample-accessor-types.d.ts +56 -0
- package/dist/content/__fixtures__/sample-accessor-types.js +5 -0
- package/dist/content/__fixtures__/sample-accessor-types.js.map +1 -0
- package/dist/content/__fixtures__/sample-delivery-types.d.ts +122 -0
- package/dist/content/__fixtures__/sample-delivery-types.js +5 -0
- package/dist/content/__fixtures__/sample-delivery-types.js.map +1 -0
- package/dist/content/assets.d.ts +53 -0
- package/dist/content/assets.js +38 -0
- package/dist/content/assets.js.map +1 -0
- package/dist/content/binding-sources.d.ts +53 -0
- package/dist/content/binding-sources.js +73 -0
- package/dist/content/binding-sources.js.map +1 -0
- package/dist/content/client.d.ts +90 -0
- package/dist/content/client.js +383 -0
- package/dist/content/client.js.map +1 -0
- package/dist/content/codegen.d.ts +54 -0
- package/dist/content/codegen.js +305 -0
- package/dist/content/codegen.js.map +1 -0
- package/dist/content/context.d.ts +38 -0
- package/dist/content/context.js +21 -0
- package/dist/content/context.js.map +1 -0
- package/dist/content/cursor.d.ts +33 -0
- package/dist/content/cursor.js +104 -0
- package/dist/content/cursor.js.map +1 -0
- package/dist/content/index.d.ts +28 -0
- package/dist/content/index.js +29 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/locale.d.ts +30 -0
- package/dist/content/locale.js +26 -0
- package/dist/content/locale.js.map +1 -0
- package/dist/content/perspective.d.ts +29 -0
- package/dist/content/perspective.js +31 -0
- package/dist/content/perspective.js.map +1 -0
- package/dist/content/populate.d.ts +25 -0
- package/dist/content/populate.js +22 -0
- package/dist/content/populate.js.map +1 -0
- package/dist/content/query.d.ts +122 -0
- package/dist/content/query.js +257 -0
- package/dist/content/query.js.map +1 -0
- package/dist/content/raw.d.ts +13 -0
- package/dist/content/raw.js +14 -0
- package/dist/content/raw.js.map +1 -0
- package/dist/content/resolve.d.ts +97 -0
- package/dist/content/resolve.js +261 -0
- package/dist/content/resolve.js.map +1 -0
- package/dist/content/serialize.d.ts +30 -0
- package/dist/content/serialize.js +57 -0
- package/dist/content/serialize.js.map +1 -0
- package/dist/content/tags.d.ts +54 -0
- package/dist/content/tags.js +40 -0
- package/dist/content/tags.js.map +1 -0
- package/dist/data-binding/fixtures.d.ts +20 -0
- package/dist/data-binding/fixtures.js +47 -0
- package/dist/data-binding/fixtures.js.map +1 -0
- package/dist/data-binding/index.d.ts +14 -0
- package/dist/data-binding/index.js +15 -0
- package/dist/data-binding/index.js.map +1 -0
- package/dist/data-binding/issues.d.ts +45 -0
- package/dist/data-binding/issues.js +46 -0
- package/dist/data-binding/issues.js.map +1 -0
- package/dist/data-binding/resolve.d.ts +87 -0
- package/dist/data-binding/resolve.js +204 -0
- package/dist/data-binding/resolve.js.map +1 -0
- package/dist/data-binding/sample.d.ts +21 -0
- package/dist/data-binding/sample.js +23 -0
- package/dist/data-binding/sample.js.map +1 -0
- package/dist/data-binding/sources.d.ts +225 -0
- package/dist/data-binding/sources.js +154 -0
- package/dist/data-binding/sources.js.map +1 -0
- package/dist/data-binding/tokens.d.ts +62 -0
- package/dist/data-binding/tokens.js +150 -0
- package/dist/data-binding/tokens.js.map +1 -0
- package/dist/design-tokens/css.d.ts +34 -0
- package/dist/design-tokens/css.js +51 -0
- package/dist/design-tokens/css.js.map +1 -0
- package/dist/design-tokens/index.d.ts +10 -0
- package/dist/design-tokens/index.js +11 -0
- package/dist/design-tokens/index.js.map +1 -0
- package/dist/design-tokens/style-guide.d.ts +30 -0
- package/dist/design-tokens/style-guide.js +31 -0
- package/dist/design-tokens/style-guide.js.map +1 -0
- package/dist/design-tokens/tokens.d.ts +89 -0
- package/dist/design-tokens/tokens.js +112 -0
- package/dist/design-tokens/tokens.js.map +1 -0
- package/dist/export-sync/builder-source.d.ts +85 -0
- package/dist/export-sync/builder-source.js +124 -0
- package/dist/export-sync/builder-source.js.map +1 -0
- package/dist/export-sync/check.d.ts +61 -0
- package/dist/export-sync/check.js +126 -0
- package/dist/export-sync/check.js.map +1 -0
- package/dist/export-sync/cli.d.ts +89 -0
- package/dist/export-sync/cli.js +323 -0
- package/dist/export-sync/cli.js.map +1 -0
- package/dist/export-sync/core.d.ts +58 -0
- package/dist/export-sync/core.js +41 -0
- package/dist/export-sync/core.js.map +1 -0
- package/dist/export-sync/eject.d.ts +28 -0
- package/dist/export-sync/eject.js +21 -0
- package/dist/export-sync/eject.js.map +1 -0
- package/dist/export-sync/fixtures.d.ts +25 -0
- package/dist/export-sync/fixtures.js +87 -0
- package/dist/export-sync/fixtures.js.map +1 -0
- package/dist/export-sync/generate.d.ts +7 -0
- package/dist/export-sync/generate.js +505 -0
- package/dist/export-sync/generate.js.map +1 -0
- package/dist/export-sync/index.d.ts +37 -0
- package/dist/export-sync/index.js +39 -0
- package/dist/export-sync/index.js.map +1 -0
- package/dist/export-sync/init.d.ts +123 -0
- package/dist/export-sync/init.js +234 -0
- package/dist/export-sync/init.js.map +1 -0
- package/dist/export-sync/manifest-host.d.ts +48 -0
- package/dist/export-sync/manifest-host.js +73 -0
- package/dist/export-sync/manifest-host.js.map +1 -0
- package/dist/export-sync/node.d.ts +20 -0
- package/dist/export-sync/node.js +101 -0
- package/dist/export-sync/node.js.map +1 -0
- package/dist/export-sync/push.d.ts +76 -0
- package/dist/export-sync/push.js +197 -0
- package/dist/export-sync/push.js.map +1 -0
- package/dist/export-sync/registry-sync-client.d.ts +59 -0
- package/dist/export-sync/registry-sync-client.js +97 -0
- package/dist/export-sync/registry-sync-client.js.map +1 -0
- package/dist/export-sync/sync.d.ts +47 -0
- package/dist/export-sync/sync.js +47 -0
- package/dist/export-sync/sync.js.map +1 -0
- package/dist/export-sync/typegen.d.ts +40 -0
- package/dist/export-sync/typegen.js +45 -0
- package/dist/export-sync/typegen.js.map +1 -0
- package/dist/export-sync/validate.d.ts +19 -0
- package/dist/export-sync/validate.js +102 -0
- package/dist/export-sync/validate.js.map +1 -0
- package/dist/export-sync/watch.d.ts +66 -0
- package/dist/export-sync/watch.js +70 -0
- package/dist/export-sync/watch.js.map +1 -0
- package/dist/operations/assets.d.ts +198 -0
- package/dist/operations/assets.js +75 -0
- package/dist/operations/assets.js.map +1 -0
- package/dist/operations/authorization.d.ts +49 -0
- package/dist/operations/authorization.js +128 -0
- package/dist/operations/authorization.js.map +1 -0
- package/dist/operations/changesets.d.ts +160 -0
- package/dist/operations/changesets.js +442 -0
- package/dist/operations/changesets.js.map +1 -0
- package/dist/operations/client.d.ts +49 -0
- package/dist/operations/client.js +57 -0
- package/dist/operations/client.js.map +1 -0
- package/dist/operations/core.d.ts +238 -0
- package/dist/operations/core.js +269 -0
- package/dist/operations/core.js.map +1 -0
- package/dist/operations/documents.d.ts +432 -0
- package/dist/operations/documents.js +344 -0
- package/dist/operations/documents.js.map +1 -0
- package/dist/operations/graph.d.ts +138 -0
- package/dist/operations/graph.js +78 -0
- package/dist/operations/graph.js.map +1 -0
- package/dist/operations/index.d.ts +19 -0
- package/dist/operations/index.js +20 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/members.d.ts +87 -0
- package/dist/operations/members.js +56 -0
- package/dist/operations/members.js.map +1 -0
- package/dist/operations/publishing.d.ts +89 -0
- package/dist/operations/publishing.js +57 -0
- package/dist/operations/publishing.js.map +1 -0
- package/dist/operations/references.d.ts +222 -0
- package/dist/operations/references.js +177 -0
- package/dist/operations/references.js.map +1 -0
- package/dist/operations/schema.d.ts +413 -0
- package/dist/operations/schema.js +138 -0
- package/dist/operations/schema.js.map +1 -0
- package/dist/operations/tokens.d.ts +79 -0
- package/dist/operations/tokens.js +102 -0
- package/dist/operations/tokens.js.map +1 -0
- package/dist/persistence/adapter.d.ts +79 -0
- package/dist/persistence/adapter.js +55 -0
- package/dist/persistence/adapter.js.map +1 -0
- package/dist/persistence/assets.d.ts +120 -0
- package/dist/persistence/assets.js +141 -0
- package/dist/persistence/assets.js.map +1 -0
- package/dist/persistence/backend-validation.d.ts +43 -0
- package/dist/persistence/backend-validation.js +57 -0
- package/dist/persistence/backend-validation.js.map +1 -0
- package/dist/persistence/cli-tokens.d.ts +50 -0
- package/dist/persistence/cli-tokens.js +66 -0
- package/dist/persistence/cli-tokens.js.map +1 -0
- package/dist/persistence/cms.d.ts +148 -0
- package/dist/persistence/cms.js +232 -0
- package/dist/persistence/cms.js.map +1 -0
- package/dist/persistence/contract-scenarios.d.ts +73 -0
- package/dist/persistence/contract-scenarios.js +496 -0
- package/dist/persistence/contract-scenarios.js.map +1 -0
- package/dist/persistence/core.d.ts +96 -0
- package/dist/persistence/core.js +110 -0
- package/dist/persistence/core.js.map +1 -0
- package/dist/persistence/graph.d.ts +61 -0
- package/dist/persistence/graph.js +98 -0
- package/dist/persistence/graph.js.map +1 -0
- package/dist/persistence/index.d.ts +22 -0
- package/dist/persistence/index.js +23 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/members.d.ts +70 -0
- package/dist/persistence/members.js +0 -0
- package/dist/persistence/members.js.map +1 -0
- package/dist/persistence/publishing.d.ts +59 -0
- package/dist/persistence/publishing.js +95 -0
- package/dist/persistence/publishing.js.map +1 -0
- package/dist/persistence/reference-extraction.d.ts +44 -0
- package/dist/persistence/reference-extraction.js +204 -0
- package/dist/persistence/reference-extraction.js.map +1 -0
- package/dist/persistence/reference-indexing.d.ts +68 -0
- package/dist/persistence/reference-indexing.js +112 -0
- package/dist/persistence/reference-indexing.js.map +1 -0
- package/dist/persistence/references.d.ts +257 -0
- package/dist/persistence/references.js +0 -0
- package/dist/persistence/references.js.map +1 -0
- package/dist/persistence/seed.d.ts +55 -0
- package/dist/persistence/seed.js +102 -0
- package/dist/persistence/seed.js.map +1 -0
- package/dist/persistence/self-maintaining-adapter.d.ts +41 -0
- package/dist/persistence/self-maintaining-adapter.js +79 -0
- package/dist/persistence/self-maintaining-adapter.js.map +1 -0
- package/dist/plugins/asset-storage.d.ts +76 -0
- package/dist/plugins/asset-storage.js +104 -0
- package/dist/plugins/asset-storage.js.map +1 -0
- package/dist/plugins/component-package.d.ts +54 -0
- package/dist/plugins/component-package.js +92 -0
- package/dist/plugins/component-package.js.map +1 -0
- package/dist/plugins/data-sources.d.ts +78 -0
- package/dist/plugins/data-sources.js +99 -0
- package/dist/plugins/data-sources.js.map +1 -0
- package/dist/plugins/examples.d.ts +47 -0
- package/dist/plugins/examples.js +205 -0
- package/dist/plugins/examples.js.map +1 -0
- package/dist/plugins/export-targets.d.ts +47 -0
- package/dist/plugins/export-targets.js +78 -0
- package/dist/plugins/export-targets.js.map +1 -0
- package/dist/plugins/field-types.d.ts +86 -0
- package/dist/plugins/field-types.js +93 -0
- package/dist/plugins/field-types.js.map +1 -0
- package/dist/plugins/hooks.d.ts +60 -0
- package/dist/plugins/hooks.js +94 -0
- package/dist/plugins/hooks.js.map +1 -0
- package/dist/plugins/index.d.ts +27 -0
- package/dist/plugins/index.js +28 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/marketplace.d.ts +90 -0
- package/dist/plugins/marketplace.js +110 -0
- package/dist/plugins/marketplace.js.map +1 -0
- package/dist/plugins/plugin.d.ts +107 -0
- package/dist/plugins/plugin.js +122 -0
- package/dist/plugins/plugin.js.map +1 -0
- package/dist/plugins/templates.d.ts +66 -0
- package/dist/plugins/templates.js +74 -0
- package/dist/plugins/templates.js.map +1 -0
- package/dist/project-graph/binding.d.ts +68 -0
- package/dist/project-graph/binding.js +39 -0
- package/dist/project-graph/binding.js.map +1 -0
- package/dist/project-graph/container.d.ts +126 -0
- package/dist/project-graph/container.js +221 -0
- package/dist/project-graph/container.js.map +1 -0
- package/dist/project-graph/edit.d.ts +66 -0
- package/dist/project-graph/edit.js +201 -0
- package/dist/project-graph/edit.js.map +1 -0
- package/dist/project-graph/fixtures.d.ts +51 -0
- package/dist/project-graph/fixtures.js +224 -0
- package/dist/project-graph/fixtures.js.map +1 -0
- package/dist/project-graph/ids.d.ts +17 -0
- package/dist/project-graph/ids.js +19 -0
- package/dist/project-graph/ids.js.map +1 -0
- package/dist/project-graph/index.d.ts +12 -0
- package/dist/project-graph/index.js +13 -0
- package/dist/project-graph/index.js.map +1 -0
- package/dist/project-graph/issues.d.ts +61 -0
- package/dist/project-graph/issues.js +44 -0
- package/dist/project-graph/issues.js.map +1 -0
- package/dist/project-graph/json.d.ts +6 -0
- package/dist/project-graph/json.js +10 -0
- package/dist/project-graph/json.js.map +1 -0
- package/dist/project-graph/node.d.ts +48 -0
- package/dist/project-graph/node.js +42 -0
- package/dist/project-graph/node.js.map +1 -0
- package/dist/project-graph/normalize.d.ts +17 -0
- package/dist/project-graph/normalize.js +110 -0
- package/dist/project-graph/normalize.js.map +1 -0
- package/dist/project-graph/serialize.d.ts +36 -0
- package/dist/project-graph/serialize.js +51 -0
- package/dist/project-graph/serialize.js.map +1 -0
- package/dist/project-graph/structure.d.ts +40 -0
- package/dist/project-graph/structure.js +36 -0
- package/dist/project-graph/structure.js.map +1 -0
- package/dist/project-graph/validate.d.ts +84 -0
- package/dist/project-graph/validate.js +158 -0
- package/dist/project-graph/validate.js.map +1 -0
- package/dist/rich-text/adapter.d.ts +43 -0
- package/dist/rich-text/adapter.js +24 -0
- package/dist/rich-text/adapter.js.map +1 -0
- package/dist/rich-text/dom-editor.d.ts +101 -0
- package/dist/rich-text/dom-editor.js +482 -0
- package/dist/rich-text/dom-editor.js.map +1 -0
- package/dist/rich-text/embed.d.ts +70 -0
- package/dist/rich-text/embed.js +70 -0
- package/dist/rich-text/embed.js.map +1 -0
- package/dist/rich-text/fixtures.d.ts +25 -0
- package/dist/rich-text/fixtures.js +115 -0
- package/dist/rich-text/fixtures.js.map +1 -0
- package/dist/rich-text/html.d.ts +5 -0
- package/dist/rich-text/html.js +309 -0
- package/dist/rich-text/html.js.map +1 -0
- package/dist/rich-text/index.d.ts +19 -0
- package/dist/rich-text/index.js +20 -0
- package/dist/rich-text/index.js.map +1 -0
- package/dist/rich-text/markdown.d.ts +7 -0
- package/dist/rich-text/markdown.js +235 -0
- package/dist/rich-text/markdown.js.map +1 -0
- package/dist/rich-text/portable-text.d.ts +50 -0
- package/dist/rich-text/portable-text.js +223 -0
- package/dist/rich-text/portable-text.js.map +1 -0
- package/dist/rich-text/registry.d.ts +48 -0
- package/dist/rich-text/registry.js +16 -0
- package/dist/rich-text/registry.js.map +1 -0
- package/dist/rich-text/render.d.ts +69 -0
- package/dist/rich-text/render.js +205 -0
- package/dist/rich-text/render.js.map +1 -0
- package/dist/rich-text/schema.d.ts +86 -0
- package/dist/rich-text/schema.js +80 -0
- package/dist/rich-text/schema.js.map +1 -0
- package/dist/rich-text/test-support.d.ts +7 -0
- package/dist/rich-text/test-support.js +8 -0
- package/dist/rich-text/test-support.js.map +1 -0
- package/dist/runtime-renderer/client.d.ts +14 -0
- package/dist/runtime-renderer/client.js +15 -0
- package/dist/runtime-renderer/client.js.map +1 -0
- package/dist/runtime-renderer/condition.d.ts +8 -0
- package/dist/runtime-renderer/condition.js +48 -0
- package/dist/runtime-renderer/condition.js.map +1 -0
- package/dist/runtime-renderer/content-client.d.ts +62 -0
- package/dist/runtime-renderer/content-client.js +37 -0
- package/dist/runtime-renderer/content-client.js.map +1 -0
- package/dist/runtime-renderer/context.d.ts +185 -0
- package/dist/runtime-renderer/context.js +7 -0
- package/dist/runtime-renderer/context.js.map +1 -0
- package/dist/runtime-renderer/fallback.d.ts +39 -0
- package/dist/runtime-renderer/fallback.js +45 -0
- package/dist/runtime-renderer/fallback.js.map +1 -0
- package/dist/runtime-renderer/index.d.ts +13 -0
- package/dist/runtime-renderer/index.js +13 -0
- package/dist/runtime-renderer/index.js.map +1 -0
- package/dist/runtime-renderer/primitives.d.ts +85 -0
- package/dist/runtime-renderer/primitives.js +442 -0
- package/dist/runtime-renderer/primitives.js.map +1 -0
- package/dist/runtime-renderer/render.d.ts +138 -0
- package/dist/runtime-renderer/render.js +825 -0
- package/dist/runtime-renderer/render.js.map +1 -0
- package/dist/runtime-renderer/rich-text.d.ts +26 -0
- package/dist/runtime-renderer/rich-text.js +113 -0
- package/dist/runtime-renderer/rich-text.js.map +1 -0
- package/dist/starter-kits/index.d.ts +13 -0
- package/dist/starter-kits/index.js +14 -0
- package/dist/starter-kits/index.js.map +1 -0
- package/dist/starter-kits/instantiate.d.ts +29 -0
- package/dist/starter-kits/instantiate.js +24 -0
- package/dist/starter-kits/instantiate.js.map +1 -0
- package/dist/starter-kits/kit.d.ts +61 -0
- package/dist/starter-kits/kit.js +37 -0
- package/dist/starter-kits/kit.js.map +1 -0
- package/dist/starter-kits/kits.d.ts +7 -0
- package/dist/starter-kits/kits.js +201 -0
- package/dist/starter-kits/kits.js.map +1 -0
- package/dist/starter-kits/manifests.d.ts +7 -0
- package/dist/starter-kits/manifests.js +111 -0
- package/dist/starter-kits/manifests.js.map +1 -0
- package/dist/starter-kits/upgrade.d.ts +39 -0
- package/dist/starter-kits/upgrade.js +54 -0
- package/dist/starter-kits/upgrade.js.map +1 -0
- package/dist/starter-kits/validate.d.ts +16 -0
- package/dist/starter-kits/validate.js +77 -0
- package/dist/starter-kits/validate.js.map +1 -0
- package/dist/studio-core/context.d.ts +27 -0
- package/dist/studio-core/context.js +44 -0
- package/dist/studio-core/context.js.map +1 -0
- package/dist/studio-core/errors.d.ts +58 -0
- package/dist/studio-core/errors.js +74 -0
- package/dist/studio-core/errors.js.map +1 -0
- package/dist/studio-core/fixtures.d.ts +18 -0
- package/dist/studio-core/fixtures.js +83 -0
- package/dist/studio-core/fixtures.js.map +1 -0
- package/dist/studio-core/ids.d.ts +22 -0
- package/dist/studio-core/ids.js +33 -0
- package/dist/studio-core/ids.js.map +1 -0
- package/dist/studio-core/index.d.ts +11 -0
- package/dist/studio-core/index.js +12 -0
- package/dist/studio-core/index.js.map +1 -0
- package/dist/studio-core/issues.d.ts +50 -0
- package/dist/studio-core/issues.js +33 -0
- package/dist/studio-core/issues.js.map +1 -0
- package/dist/studio-core/metadata.d.ts +109 -0
- package/dist/studio-core/metadata.js +74 -0
- package/dist/studio-core/metadata.js.map +1 -0
- package/dist/studio-core/repository.d.ts +73 -0
- package/dist/studio-core/repository.js +202 -0
- package/dist/studio-core/repository.js.map +1 -0
- package/dist/studio-core/sections.d.ts +73 -0
- package/dist/studio-core/sections.js +68 -0
- package/dist/studio-core/sections.js.map +1 -0
- package/dist/studio-core/validate.d.ts +15 -0
- package/dist/studio-core/validate.js +119 -0
- package/dist/studio-core/validate.js.map +1 -0
- package/dist/studio-core/workspace-config.d.ts +587 -0
- package/dist/studio-core/workspace-config.js +434 -0
- package/dist/studio-core/workspace-config.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ComponentNode } from '@elytracms/core/project-graph';
|
|
3
|
+
import type { RichTextDoc, RichTextValue } from './schema';
|
|
4
|
+
import type { RichTextRegistry } from './registry';
|
|
5
|
+
/**
|
|
6
|
+
* Server-safe read-only renderer: rich-text storage JSON → React (brief §7.6).
|
|
7
|
+
*
|
|
8
|
+
* "Server-safe" means this module imports only `react` (no `react-dom`, no browser
|
|
9
|
+
* globals, no editor bundle), so an exported Next.js app can render content on the
|
|
10
|
+
* server. It returns React elements; callers turn them into markup with
|
|
11
|
+
* `react-dom/server` or hydrate them as-is.
|
|
12
|
+
*
|
|
13
|
+
* Unknown node types never crash: each one renders a visible fallback and is
|
|
14
|
+
* collected as a structured {@link RichTextRenderIssue} (validation is first-class).
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A structured problem found while rendering: an unknown node type, or a
|
|
18
|
+
* `componentEmbed` whose embedded composition value is missing/malformed (EC-189).
|
|
19
|
+
*/
|
|
20
|
+
export interface RichTextRenderIssue {
|
|
21
|
+
code: 'unknown-node' | 'invalid-embed';
|
|
22
|
+
message: string;
|
|
23
|
+
/** The offending storage `node.type`. */
|
|
24
|
+
nodeType: string;
|
|
25
|
+
/** Index path into the document tree (content indices), for tooling. */
|
|
26
|
+
path: number[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Renders an embedded composition value (a single `ComponentNode`, EC-189) to
|
|
30
|
+
* React. INJECTED by the host so the rich-text package stays free of
|
|
31
|
+
* `@elytracms/core/runtime-renderer` (which already depends on rich-text via the RichText
|
|
32
|
+
* primitive). The host binds this to `renderComposition(node, renderContext)`, so
|
|
33
|
+
* an embed renders byte-equivalent to the same component in a page/block field.
|
|
34
|
+
* Omit to fall back to the visible placeholder (e.g. server-safe validation passes
|
|
35
|
+
* with no registry/implementations available).
|
|
36
|
+
*/
|
|
37
|
+
export type RichTextEmbedRenderer = (node: ComponentNode) => ReactNode;
|
|
38
|
+
export interface RenderRichTextOptions {
|
|
39
|
+
/** Registry of custom block/inline renderers. Defaults to empty. */
|
|
40
|
+
registry?: RichTextRegistry;
|
|
41
|
+
/**
|
|
42
|
+
* Renders `componentEmbed` nodes (EC-189). Bound by the host to
|
|
43
|
+
* `renderComposition`. When absent, embeds show the visible fallback.
|
|
44
|
+
*/
|
|
45
|
+
renderEmbed?: RichTextEmbedRenderer;
|
|
46
|
+
/**
|
|
47
|
+
* Collector invoked once per unknown node encountered. Lets tooling surface
|
|
48
|
+
* issues without re-walking the tree.
|
|
49
|
+
*/
|
|
50
|
+
onIssue?: (issue: RichTextRenderIssue) => void;
|
|
51
|
+
/** className applied to the wrapping element of the document. */
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Built-in node types this renderer understands without any registry. */
|
|
55
|
+
export declare const BUILTIN_NODE_TYPES: readonly ["doc", "paragraph", "text", "heading", "bulletList", "orderedList", "listItem", "blockquote", "codeBlock", "hardBreak", "horizontalRule", "image", "embed", "componentEmbed"];
|
|
56
|
+
/** Built-in mark types this renderer understands. */
|
|
57
|
+
export declare const BUILTIN_MARK_TYPES: readonly ["bold", "italic", "code", "link", "strike", "underline"];
|
|
58
|
+
/**
|
|
59
|
+
* Render a parsed rich-text document tree to a React element. Pure: no DOM access.
|
|
60
|
+
* The wrapping element is a `div.rich-text` so consumers can scope styles.
|
|
61
|
+
*/
|
|
62
|
+
export declare function renderRichTextDoc(doc: RichTextDoc, options?: RenderRichTextOptions): ReactElement;
|
|
63
|
+
/** Render a versioned rich-text value (convenience over {@link renderRichTextDoc}). */
|
|
64
|
+
export declare function renderRichTextValue(value: RichTextValue, options?: RenderRichTextOptions): ReactElement;
|
|
65
|
+
/**
|
|
66
|
+
* Walk a document and collect every unknown-node issue *without* rendering. Useful
|
|
67
|
+
* for pre-flight validation (e.g. before export) where you only want the issues.
|
|
68
|
+
*/
|
|
69
|
+
export declare function findUnknownNodes(doc: RichTextDoc, registry?: RichTextRegistry): RichTextRenderIssue[];
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Fragment, createElement } from 'react';
|
|
2
|
+
import { COMPONENT_EMBED_NODE_TYPE, embeddedComponentNode } from './embed';
|
|
3
|
+
import { emptyRichTextRegistry } from './registry';
|
|
4
|
+
/** Built-in node types this renderer understands without any registry. */
|
|
5
|
+
export const BUILTIN_NODE_TYPES = [
|
|
6
|
+
'doc',
|
|
7
|
+
'paragraph',
|
|
8
|
+
'text',
|
|
9
|
+
'heading',
|
|
10
|
+
'bulletList',
|
|
11
|
+
'orderedList',
|
|
12
|
+
'listItem',
|
|
13
|
+
'blockquote',
|
|
14
|
+
'codeBlock',
|
|
15
|
+
'hardBreak',
|
|
16
|
+
'horizontalRule',
|
|
17
|
+
'image',
|
|
18
|
+
'embed',
|
|
19
|
+
// EC-189: an embedded registry component (a composition value). Built-in so a
|
|
20
|
+
// document carrying embeds is never flagged "unknown-node" — its render is
|
|
21
|
+
// delegated to the injected embed renderer (see `RichTextEmbedRenderer`).
|
|
22
|
+
COMPONENT_EMBED_NODE_TYPE,
|
|
23
|
+
];
|
|
24
|
+
/** Built-in mark types this renderer understands. */
|
|
25
|
+
export const BUILTIN_MARK_TYPES = ['bold', 'italic', 'code', 'link', 'strike', 'underline'];
|
|
26
|
+
function attrString(value) {
|
|
27
|
+
return typeof value === 'string' ? value : undefined;
|
|
28
|
+
}
|
|
29
|
+
function attrNumber(value) {
|
|
30
|
+
return typeof value === 'number' ? value : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Wrap inline content in the elements implied by its marks, innermost-first. */
|
|
33
|
+
function applyMarks(content, marks, key) {
|
|
34
|
+
if (!marks || marks.length === 0)
|
|
35
|
+
return content;
|
|
36
|
+
return marks.reduce((acc, mark, i) => {
|
|
37
|
+
const markKey = `${key}-m${i}`;
|
|
38
|
+
switch (mark.type) {
|
|
39
|
+
case 'bold':
|
|
40
|
+
return createElement('strong', { key: markKey }, acc);
|
|
41
|
+
case 'italic':
|
|
42
|
+
return createElement('em', { key: markKey }, acc);
|
|
43
|
+
case 'code':
|
|
44
|
+
return createElement('code', { key: markKey }, acc);
|
|
45
|
+
case 'strike':
|
|
46
|
+
return createElement('s', { key: markKey }, acc);
|
|
47
|
+
case 'underline':
|
|
48
|
+
return createElement('u', { key: markKey }, acc);
|
|
49
|
+
case 'link': {
|
|
50
|
+
const href = attrString(mark.attrs?.href) ?? '#';
|
|
51
|
+
const target = attrString(mark.attrs?.target);
|
|
52
|
+
const rel = target === '_blank' ? 'noopener noreferrer' : attrString(mark.attrs?.rel);
|
|
53
|
+
return createElement('a', { key: markKey, href, ...(target ? { target } : {}), ...(rel ? { rel } : {}) }, acc);
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
// Unknown mark: keep the text visible, wrapped in a tagged span so it is
|
|
57
|
+
// inspectable but never lost.
|
|
58
|
+
return createElement('span', { key: markKey, 'data-unknown-mark': mark.type }, acc);
|
|
59
|
+
}
|
|
60
|
+
}, content);
|
|
61
|
+
}
|
|
62
|
+
/** The visible fallback shown for an embed the renderer cannot resolve (EC-189). */
|
|
63
|
+
function invalidEmbedFallback(key) {
|
|
64
|
+
return createElement('div', { key, 'data-invalid-embed': '', className: 'rich-text-invalid-embed', role: 'note' }, 'Invalid embedded component.');
|
|
65
|
+
}
|
|
66
|
+
function renderChildren(nodes, ctx, path) {
|
|
67
|
+
if (!nodes)
|
|
68
|
+
return [];
|
|
69
|
+
return nodes.map((child, i) => renderNode(child, ctx, [...path, i]));
|
|
70
|
+
}
|
|
71
|
+
/** The visible fallback shown for any node type the renderer cannot resolve. */
|
|
72
|
+
function unknownFallback(node, key) {
|
|
73
|
+
return createElement('div', { key, 'data-unknown-node': node.type, className: 'rich-text-unknown', role: 'note' }, `Unknown content block: ${node.type}`);
|
|
74
|
+
}
|
|
75
|
+
function renderNode(node, ctx, path) {
|
|
76
|
+
const key = `n-${path.join('-')}`;
|
|
77
|
+
// Leaf text node.
|
|
78
|
+
if (node.type === 'text') {
|
|
79
|
+
return applyMarks(node.text ?? '', node.marks, key);
|
|
80
|
+
}
|
|
81
|
+
switch (node.type) {
|
|
82
|
+
case 'paragraph':
|
|
83
|
+
return createElement('p', { key }, ...renderChildren(node.content, ctx, path));
|
|
84
|
+
case 'heading': {
|
|
85
|
+
const level = attrNumber(node.attrs?.level);
|
|
86
|
+
const clamped = level && level >= 1 && level <= 6 ? level : 1;
|
|
87
|
+
return createElement(`h${clamped}`, { key }, ...renderChildren(node.content, ctx, path));
|
|
88
|
+
}
|
|
89
|
+
case 'bulletList':
|
|
90
|
+
return createElement('ul', { key }, ...renderChildren(node.content, ctx, path));
|
|
91
|
+
case 'orderedList':
|
|
92
|
+
return createElement('ol', { key }, ...renderChildren(node.content, ctx, path));
|
|
93
|
+
case 'listItem':
|
|
94
|
+
return createElement('li', { key }, ...renderChildren(node.content, ctx, path));
|
|
95
|
+
case 'blockquote':
|
|
96
|
+
return createElement('blockquote', { key }, ...renderChildren(node.content, ctx, path));
|
|
97
|
+
case 'codeBlock': {
|
|
98
|
+
const language = attrString(node.attrs?.language);
|
|
99
|
+
return createElement('pre', { key }, createElement('code', language ? { className: `language-${language}` } : {}, ...renderChildren(node.content, ctx, path)));
|
|
100
|
+
}
|
|
101
|
+
case 'hardBreak':
|
|
102
|
+
return createElement('br', { key });
|
|
103
|
+
case 'horizontalRule':
|
|
104
|
+
return createElement('hr', { key });
|
|
105
|
+
case 'image': {
|
|
106
|
+
const src = attrString(node.attrs?.src) ?? '';
|
|
107
|
+
const alt = attrString(node.attrs?.alt) ?? '';
|
|
108
|
+
const title = attrString(node.attrs?.title);
|
|
109
|
+
return createElement('img', { key, src, alt, ...(title ? { title } : {}) });
|
|
110
|
+
}
|
|
111
|
+
case 'embed': {
|
|
112
|
+
// Generic media/embed: an iframe by URL (e.g. video, map). Server-safe.
|
|
113
|
+
const src = attrString(node.attrs?.src) ?? '';
|
|
114
|
+
const title = attrString(node.attrs?.title) ?? 'Embedded content';
|
|
115
|
+
return createElement('iframe', {
|
|
116
|
+
key,
|
|
117
|
+
src,
|
|
118
|
+
title,
|
|
119
|
+
loading: 'lazy',
|
|
120
|
+
'data-embed-provider': attrString(node.attrs?.provider) ?? undefined,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
case COMPONENT_EMBED_NODE_TYPE: {
|
|
124
|
+
// EC-189: an embedded registry component. Resolve the embedded composition
|
|
125
|
+
// value and delegate to the injected embed renderer (bound to
|
|
126
|
+
// `renderComposition`), so the embed renders identically to the same
|
|
127
|
+
// component in a page/block field. A missing renderer or a malformed embed
|
|
128
|
+
// degrades to the visible fallback — never a crash, never silent.
|
|
129
|
+
const embedded = embeddedComponentNode(node);
|
|
130
|
+
if (!embedded) {
|
|
131
|
+
ctx.onIssue?.({
|
|
132
|
+
code: 'invalid-embed',
|
|
133
|
+
message: 'Component embed is missing a valid embedded component node.',
|
|
134
|
+
nodeType: node.type,
|
|
135
|
+
path,
|
|
136
|
+
});
|
|
137
|
+
return invalidEmbedFallback(key);
|
|
138
|
+
}
|
|
139
|
+
if (!ctx.renderEmbed)
|
|
140
|
+
return invalidEmbedFallback(key);
|
|
141
|
+
return createElement(Fragment, { key }, ctx.renderEmbed(embedded));
|
|
142
|
+
}
|
|
143
|
+
default: {
|
|
144
|
+
// Custom node from the registry (block or inline).
|
|
145
|
+
const def = ctx.registry.get(node.type);
|
|
146
|
+
if (def) {
|
|
147
|
+
const children = node.content && node.content.length > 0 ? renderChildren(node.content, ctx, path) : undefined;
|
|
148
|
+
const element = def.render({ node, children });
|
|
149
|
+
return element ? createElement(Fragment, { key }, element) : null;
|
|
150
|
+
}
|
|
151
|
+
// Unknown: visible fallback + structured issue. Never throws.
|
|
152
|
+
ctx.onIssue?.({
|
|
153
|
+
code: 'unknown-node',
|
|
154
|
+
message: `No renderer registered for rich-text node type "${node.type}".`,
|
|
155
|
+
nodeType: node.type,
|
|
156
|
+
path,
|
|
157
|
+
});
|
|
158
|
+
return unknownFallback(node, key);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Render a parsed rich-text document tree to a React element. Pure: no DOM access.
|
|
164
|
+
* The wrapping element is a `div.rich-text` so consumers can scope styles.
|
|
165
|
+
*/
|
|
166
|
+
export function renderRichTextDoc(doc, options = {}) {
|
|
167
|
+
const ctx = {
|
|
168
|
+
registry: options.registry ?? emptyRichTextRegistry,
|
|
169
|
+
renderEmbed: options.renderEmbed,
|
|
170
|
+
onIssue: options.onIssue,
|
|
171
|
+
};
|
|
172
|
+
const children = renderChildren(doc.content, ctx, []);
|
|
173
|
+
return createElement('div', { className: options.className ? `rich-text ${options.className}` : 'rich-text' }, ...children);
|
|
174
|
+
}
|
|
175
|
+
/** Render a versioned rich-text value (convenience over {@link renderRichTextDoc}). */
|
|
176
|
+
export function renderRichTextValue(value, options = {}) {
|
|
177
|
+
return renderRichTextDoc(value.doc, options);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Walk a document and collect every unknown-node issue *without* rendering. Useful
|
|
181
|
+
* for pre-flight validation (e.g. before export) where you only want the issues.
|
|
182
|
+
*/
|
|
183
|
+
export function findUnknownNodes(doc, registry = emptyRichTextRegistry) {
|
|
184
|
+
const issues = [];
|
|
185
|
+
const builtins = new Set(BUILTIN_NODE_TYPES);
|
|
186
|
+
const walk = (nodes, path) => {
|
|
187
|
+
if (!nodes)
|
|
188
|
+
return;
|
|
189
|
+
nodes.forEach((node, i) => {
|
|
190
|
+
const here = [...path, i];
|
|
191
|
+
if (!builtins.has(node.type) && !registry.has(node.type)) {
|
|
192
|
+
issues.push({
|
|
193
|
+
code: 'unknown-node',
|
|
194
|
+
message: `No renderer registered for rich-text node type "${node.type}".`,
|
|
195
|
+
nodeType: node.type,
|
|
196
|
+
path: here,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
walk(node.content, here);
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
walk(doc.content, []);
|
|
203
|
+
return issues;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/rich-text/render.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAI/C,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC1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AS,kBAAkB,CAAC,CAAA;IACpD,MAAM,IAAI,GAAG,CAAC,KAA0C,EAAE,IAAc,EAAQ,EAAE;QAChF,IAAI,CAAC,KAAK;YAAE,OAAM;QAClB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACxB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAA;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzD,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,mDAAmD,IAAI,CAAC,IAAI,IAAI;oBACzE,QAAQ,EAAE,IAAI,CAAC,IAAI;oBACnB,IAAI,EAAE,IAAI;iBACX,CAAC,CAAA;YACJ,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACrB,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { JsonValue } from '@elytracms/core/project-graph';
|
|
3
|
+
/**
|
|
4
|
+
* Rich-text storage format (brief §7.6).
|
|
5
|
+
*
|
|
6
|
+
* The on-disk shape is intentionally ProseMirror/TipTap-shaped: a JSON document is
|
|
7
|
+
* a tree of nodes `{ type, attrs?, content?, marks?, text? }`. Keeping the storage
|
|
8
|
+
* format identical to ProseMirror's lets a TipTap editor plug in later behind the
|
|
9
|
+
* {@link RichTextAdapter} seam without a migration — the editor reads/writes the
|
|
10
|
+
* exact same JSON this package validates and renders.
|
|
11
|
+
*
|
|
12
|
+
* Nothing in this module imports TipTap. The format is modelled directly so the
|
|
13
|
+
* spike has no required dependency on a paid or cloud editor service.
|
|
14
|
+
*/
|
|
15
|
+
/** The schema version this build of the package reads and writes. Stored per value. */
|
|
16
|
+
export declare const RICH_TEXT_SCHEMA_VERSION = 1;
|
|
17
|
+
/** Attribute bag carried by a node or mark. Plain JSON only — never runtime handles. */
|
|
18
|
+
export declare const richTextAttrsSchema: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
19
|
+
export type RichTextAttrs = Record<string, JsonValue>;
|
|
20
|
+
/**
|
|
21
|
+
* A mark applied to inline text (bold, italic, code, link, …). Marks are
|
|
22
|
+
* ProseMirror-shaped: a `type` plus an optional attribute bag (e.g. a link `href`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const richTextMarkSchema: z.ZodObject<{
|
|
25
|
+
type: z.ZodString;
|
|
26
|
+
attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type RichTextMark = z.infer<typeof richTextMarkSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* A single node in the document tree.
|
|
31
|
+
*
|
|
32
|
+
* - Leaf text nodes carry `text` (and optional `marks`).
|
|
33
|
+
* - Block/inline nodes carry `content` (ordered children) and/or `attrs`.
|
|
34
|
+
*
|
|
35
|
+
* The schema deliberately keeps `type` an open string: a document referencing an
|
|
36
|
+
* unknown node type still *parses* so the renderer can show a visible fallback and
|
|
37
|
+
* tooling can report a structured issue — mirroring how the project graph keeps
|
|
38
|
+
* component ids as open strings (see `@elytracms/core/project-graph`).
|
|
39
|
+
*/
|
|
40
|
+
export interface RichTextNode {
|
|
41
|
+
type: string;
|
|
42
|
+
attrs?: RichTextAttrs;
|
|
43
|
+
content?: RichTextNode[];
|
|
44
|
+
marks?: RichTextMark[];
|
|
45
|
+
text?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const richTextNodeSchema: z.ZodType<RichTextNode>;
|
|
48
|
+
/** The root document node. By ProseMirror convention its `type` is `doc`. */
|
|
49
|
+
export declare const richTextDocSchema: z.ZodObject<{
|
|
50
|
+
type: z.ZodLiteral<"doc">;
|
|
51
|
+
content: z.ZodDefault<z.ZodArray<z.ZodType<RichTextNode, unknown, z.core.$ZodTypeInternals<RichTextNode, unknown>>>>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export type RichTextDoc = z.infer<typeof richTextDocSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* A stored rich-text value. Every value carries the schema {@link version} it was
|
|
56
|
+
* written under so old content stays readable across format changes (brief §7.6).
|
|
57
|
+
*/
|
|
58
|
+
export declare const richTextValueSchema: z.ZodObject<{
|
|
59
|
+
version: z.ZodNumber;
|
|
60
|
+
doc: z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"doc">;
|
|
62
|
+
content: z.ZodDefault<z.ZodArray<z.ZodType<RichTextNode, unknown, z.core.$ZodTypeInternals<RichTextNode, unknown>>>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type RichTextValue = z.infer<typeof richTextValueSchema>;
|
|
66
|
+
/** Wrap a document tree in a versioned value, stamping the current schema version. */
|
|
67
|
+
export declare function createRichTextValue(doc: RichTextDoc): RichTextValue;
|
|
68
|
+
/** Convenience constructor for an empty (but valid) versioned value. */
|
|
69
|
+
export declare function emptyRichTextValue(): RichTextValue;
|
|
70
|
+
export type ParseRichTextResult = {
|
|
71
|
+
ok: true;
|
|
72
|
+
value: RichTextValue;
|
|
73
|
+
} | {
|
|
74
|
+
ok: false;
|
|
75
|
+
error: z.ZodError;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Parse a rich-text value from a JSON string or already-parsed object. Never throws
|
|
79
|
+
* on invalid input — returns a structured failure instead (validation is
|
|
80
|
+
* first-class; see AGENTS.md).
|
|
81
|
+
*/
|
|
82
|
+
export declare function parseRichTextValue(input: string | unknown): ParseRichTextResult;
|
|
83
|
+
/** Serialize a rich-text value to JSON, parsing first so output is always valid. */
|
|
84
|
+
export declare function serializeRichTextValue(value: RichTextValue): string;
|
|
85
|
+
/** True when a value's stored version matches the version this build understands. */
|
|
86
|
+
export declare function isCompatibleRichTextVersion(value: RichTextValue): boolean;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { jsonValueSchema } from '@elytracms/core/project-graph';
|
|
3
|
+
/**
|
|
4
|
+
* Rich-text storage format (brief §7.6).
|
|
5
|
+
*
|
|
6
|
+
* The on-disk shape is intentionally ProseMirror/TipTap-shaped: a JSON document is
|
|
7
|
+
* a tree of nodes `{ type, attrs?, content?, marks?, text? }`. Keeping the storage
|
|
8
|
+
* format identical to ProseMirror's lets a TipTap editor plug in later behind the
|
|
9
|
+
* {@link RichTextAdapter} seam without a migration — the editor reads/writes the
|
|
10
|
+
* exact same JSON this package validates and renders.
|
|
11
|
+
*
|
|
12
|
+
* Nothing in this module imports TipTap. The format is modelled directly so the
|
|
13
|
+
* spike has no required dependency on a paid or cloud editor service.
|
|
14
|
+
*/
|
|
15
|
+
/** The schema version this build of the package reads and writes. Stored per value. */
|
|
16
|
+
export const RICH_TEXT_SCHEMA_VERSION = 1;
|
|
17
|
+
/** Attribute bag carried by a node or mark. Plain JSON only — never runtime handles. */
|
|
18
|
+
export const richTextAttrsSchema = z.record(z.string(), jsonValueSchema);
|
|
19
|
+
/**
|
|
20
|
+
* A mark applied to inline text (bold, italic, code, link, …). Marks are
|
|
21
|
+
* ProseMirror-shaped: a `type` plus an optional attribute bag (e.g. a link `href`).
|
|
22
|
+
*/
|
|
23
|
+
export const richTextMarkSchema = z.object({
|
|
24
|
+
type: z.string().min(1),
|
|
25
|
+
attrs: richTextAttrsSchema.optional(),
|
|
26
|
+
});
|
|
27
|
+
export const richTextNodeSchema = z.lazy(() => z.object({
|
|
28
|
+
type: z.string().min(1),
|
|
29
|
+
attrs: richTextAttrsSchema.optional(),
|
|
30
|
+
content: z.array(richTextNodeSchema).optional(),
|
|
31
|
+
marks: z.array(richTextMarkSchema).optional(),
|
|
32
|
+
text: z.string().optional(),
|
|
33
|
+
}));
|
|
34
|
+
/** The root document node. By ProseMirror convention its `type` is `doc`. */
|
|
35
|
+
export const richTextDocSchema = z.object({
|
|
36
|
+
type: z.literal('doc'),
|
|
37
|
+
content: z.array(richTextNodeSchema).default([]),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* A stored rich-text value. Every value carries the schema {@link version} it was
|
|
41
|
+
* written under so old content stays readable across format changes (brief §7.6).
|
|
42
|
+
*/
|
|
43
|
+
export const richTextValueSchema = z.object({
|
|
44
|
+
/** Schema version this value was written under. */
|
|
45
|
+
version: z.number().int().nonnegative(),
|
|
46
|
+
doc: richTextDocSchema,
|
|
47
|
+
});
|
|
48
|
+
/** Wrap a document tree in a versioned value, stamping the current schema version. */
|
|
49
|
+
export function createRichTextValue(doc) {
|
|
50
|
+
return { version: RICH_TEXT_SCHEMA_VERSION, doc };
|
|
51
|
+
}
|
|
52
|
+
/** Convenience constructor for an empty (but valid) versioned value. */
|
|
53
|
+
export function emptyRichTextValue() {
|
|
54
|
+
return createRichTextValue({ type: 'doc', content: [] });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parse a rich-text value from a JSON string or already-parsed object. Never throws
|
|
58
|
+
* on invalid input — returns a structured failure instead (validation is
|
|
59
|
+
* first-class; see AGENTS.md).
|
|
60
|
+
*/
|
|
61
|
+
export function parseRichTextValue(input) {
|
|
62
|
+
let json;
|
|
63
|
+
try {
|
|
64
|
+
json = typeof input === 'string' ? JSON.parse(input) : input;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
json = undefined;
|
|
68
|
+
}
|
|
69
|
+
const result = richTextValueSchema.safeParse(json);
|
|
70
|
+
return result.success ? { ok: true, value: result.data } : { ok: false, error: result.error };
|
|
71
|
+
}
|
|
72
|
+
/** Serialize a rich-text value to JSON, parsing first so output is always valid. */
|
|
73
|
+
export function serializeRichTextValue(value) {
|
|
74
|
+
return JSON.stringify(richTextValueSchema.parse(value));
|
|
75
|
+
}
|
|
76
|
+
/** True when a value's stored version matches the version this build understands. */
|
|
77
|
+
export function isCompatibleRichTextVersion(value) {
|
|
78
|
+
return value.version === RICH_TEXT_SCHEMA_VERSION;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/rich-text/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAG/D;;;;;;;;;;;GAWG;AAEH,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAEzC,wFAAwF;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAA;AAGxE;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA;AAsBF,MAAM,CAAC,MAAM,kBAAkB,GAA4B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACrE,CAAC,CAAC,MAAM,CAAC;IACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IACrC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,k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GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAA;AAC/F,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,sBAAsB,CAAC,KAAoB;IACzD,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AACzD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,2BAA2B,CAAC,KAAoB;IAC9D,OAAO,KAAK,CAAC,OAAO,KAAK,wBAAwB,CAAA;AACnD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only helper: render a React element to static HTML markup.
|
|
3
|
+
*
|
|
4
|
+
* The read-only renderer in `render.tsx` is server-safe and imports only `react`;
|
|
5
|
+
* `react-dom` is a devDependency used solely by tests to assert on emitted markup.
|
|
6
|
+
*/
|
|
7
|
+
export { renderToStaticMarkup } from 'react-dom/server';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only helper: render a React element to static HTML markup.
|
|
3
|
+
*
|
|
4
|
+
* The read-only renderer in `render.tsx` is server-safe and imports only `react`;
|
|
5
|
+
* `react-dom` is a devDependency used solely by tests to assert on emitted markup.
|
|
6
|
+
*/
|
|
7
|
+
export { renderToStaticMarkup } from 'react-dom/server';
|
|
8
|
+
//# sourceMappingURL=test-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-support.js","sourceRoot":"","sources":["../../src/rich-text/test-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @elytracms/core/runtime-renderer/client — the two CLIENT-boundary modules, as a
|
|
3
|
+
* lean barrel (EC-201). Both depend on `react` alone, so importing the island
|
|
4
|
+
* surface from here (instead of the package index) keeps a downstream client
|
|
5
|
+
* bundle free of the server closure (rich-text, zod, the registry).
|
|
6
|
+
*
|
|
7
|
+
* Used by `@elytracms/next/client` to assemble the host's published client
|
|
8
|
+
* island entry; the `'use client'` directive here marks the boundary in source
|
|
9
|
+
* (the published `@elytracms/next` re-inserts it post-bundle — see that
|
|
10
|
+
* package's `tsup.config.ts`).
|
|
11
|
+
*/
|
|
12
|
+
export { ContentClientProvider, useContentClient, createFixtureContentClient, } from './content-client';
|
|
13
|
+
export type { ContentClient, ContentDocumentView, ContentAssetView, ContentQuery, } from './content-client';
|
|
14
|
+
export { RenderErrorBoundary, RenderErrorFallback } from './fallback';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* @elytracms/core/runtime-renderer/client — the two CLIENT-boundary modules, as a
|
|
4
|
+
* lean barrel (EC-201). Both depend on `react` alone, so importing the island
|
|
5
|
+
* surface from here (instead of the package index) keeps a downstream client
|
|
6
|
+
* bundle free of the server closure (rich-text, zod, the registry).
|
|
7
|
+
*
|
|
8
|
+
* Used by `@elytracms/next/client` to assemble the host's published client
|
|
9
|
+
* island entry; the `'use client'` directive here marks the boundary in source
|
|
10
|
+
* (the published `@elytracms/next` re-inserts it post-bundle — see that
|
|
11
|
+
* package's `tsup.config.ts`).
|
|
12
|
+
*/
|
|
13
|
+
export { ContentClientProvider, useContentClient, createFixtureContentClient, } from './content-client';
|
|
14
|
+
export { RenderErrorBoundary, RenderErrorFallback } from './fallback';
|
|
15
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/runtime-renderer/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;;;;;;;GAUG;AAEH,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAQzB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Condition } from '@elytracms/core/project-graph';
|
|
2
|
+
import type { ItemContext, ResolveBinding } from './context';
|
|
3
|
+
/**
|
|
4
|
+
* Evaluate a node's render condition. The left operand is resolved from the condition's
|
|
5
|
+
* binding source; the operator is applied against `condition.value`. A thrown resolver
|
|
6
|
+
* error is treated as a failed condition (node renders nothing) rather than a crash.
|
|
7
|
+
*/
|
|
8
|
+
export declare function evaluateCondition(condition: Condition, resolveBinding: ResolveBinding, item?: ItemContext): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluate a node's render condition. The left operand is resolved from the condition's
|
|
3
|
+
* binding source; the operator is applied against `condition.value`. A thrown resolver
|
|
4
|
+
* error is treated as a failed condition (node renders nothing) rather than a crash.
|
|
5
|
+
*/
|
|
6
|
+
export function evaluateCondition(condition, resolveBinding, item) {
|
|
7
|
+
let left;
|
|
8
|
+
try {
|
|
9
|
+
left = resolveBinding(condition.source, item);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
switch (condition.operator) {
|
|
15
|
+
case 'truthy':
|
|
16
|
+
return Boolean(left);
|
|
17
|
+
case 'exists':
|
|
18
|
+
return left !== undefined && left !== null;
|
|
19
|
+
case 'eq':
|
|
20
|
+
return left === condition.value;
|
|
21
|
+
case 'neq':
|
|
22
|
+
return left !== condition.value;
|
|
23
|
+
case 'gt':
|
|
24
|
+
return compare(left, condition.value, (a, b) => a > b);
|
|
25
|
+
case 'gte':
|
|
26
|
+
return compare(left, condition.value, (a, b) => a >= b);
|
|
27
|
+
case 'lt':
|
|
28
|
+
return compare(left, condition.value, (a, b) => a < b);
|
|
29
|
+
case 'lte':
|
|
30
|
+
return compare(left, condition.value, (a, b) => a <= b);
|
|
31
|
+
default: {
|
|
32
|
+
// Exhaustiveness guard: unknown operators never render.
|
|
33
|
+
const _never = condition.operator;
|
|
34
|
+
return Boolean(_never);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Numeric ordering comparison. Ordering operators are numeric-only: a non-number operand yields
|
|
40
|
+
* `false`. This matches `@elytracms/core/data-binding`'s `resolveCondition`, so the canvas and the
|
|
41
|
+
* Builder's inspector/page-tree previews evaluate identically (one canonical model).
|
|
42
|
+
*/
|
|
43
|
+
function compare(left, right, op) {
|
|
44
|
+
if (typeof left !== 'number' || typeof right !== 'number')
|
|
45
|
+
return false;
|
|
46
|
+
return op(left, right);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../src/runtime-renderer/condition.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAoB,EACpB,cAA8B,EAC9B,IAAkB;IAElB,IAAI,IAAa,CAAA;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,cAAc,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;IAED,QAAQ,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC3B,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;QACtB,KAAK,QAAQ;YACX,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,CAAA;QAC5C,KAAK,IAAI;YACP,OAAO,IAAI,KAAK,SAAS,CAAC,KAAK,CAAA;QACjC,KAAK,KAAK;YACR,OAAO,IAAI,KAAK,SAAS,CAAC,KAAK,CAAA;QACjC,KAAK,IAAI;YACP,OAAO,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACxD,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QACzD,KAAK,IAAI;YACP,OAAO,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACxD,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QACzD,OAAO,CAAC,CAAC,CAAC;YACR,wDAAwD;YACxD,MAAM,MAAM,GAAU,SAAS,CAAC,QAAQ,CAAA;YACxC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,IAAa,EAAE,KAAc,EAAE,EAAqC;IACnF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACvE,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only content access for self-fetching components (EC-191). With editor
|
|
4
|
+
* bindings gone (EC-190), dynamic data lives INSIDE dev components: a component
|
|
5
|
+
* reads what it needs from the injected client and renders it. The host provides a
|
|
6
|
+
* live client (Convex-backed), the studio a read client, tests a fixture-backed
|
|
7
|
+
* deterministic one — so the SAME component renders real data on the canvas, at
|
|
8
|
+
* delivery, and in tests (the AGENTS.md determinism rule).
|
|
9
|
+
*
|
|
10
|
+
* The client is **synchronous**: it reads already-loaded content (the host fetches
|
|
11
|
+
* for delivery, the studio pre-loads for preview, the test holds fixtures), which
|
|
12
|
+
* keeps render deterministic and Suspense-free. A component may ALSO fetch arbitrary
|
|
13
|
+
* external content through its own async hooks — the client is one source, not the
|
|
14
|
+
* only one.
|
|
15
|
+
*/
|
|
16
|
+
export interface ContentDocumentView {
|
|
17
|
+
collection: string;
|
|
18
|
+
id: string;
|
|
19
|
+
values: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/** A resolved asset (EC-191) — id plus delivery-shape url/alt when known. */
|
|
22
|
+
export interface ContentAssetView {
|
|
23
|
+
id: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
alt?: string;
|
|
26
|
+
}
|
|
27
|
+
/** A minimal list query (EC-191). Kept deliberately small for v1. */
|
|
28
|
+
export interface ContentQuery {
|
|
29
|
+
collection: string;
|
|
30
|
+
/** Cap the number of returned documents. */
|
|
31
|
+
limit?: number;
|
|
32
|
+
}
|
|
33
|
+
/** The read-content contract injected into the render context (EC-191). */
|
|
34
|
+
export interface ContentClient {
|
|
35
|
+
getDocument(collection: string, id: string): ContentDocumentView | undefined;
|
|
36
|
+
listDocuments(query: ContentQuery): ContentDocumentView[];
|
|
37
|
+
resolveAsset(id: string): ContentAssetView | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Provide a `ContentClient` to the rendered subtree. The renderer wraps its public
|
|
41
|
+
* composite entry points (page/composition) in this when `ctx.content` is set; a
|
|
42
|
+
* host rendering nodes directly can wrap manually.
|
|
43
|
+
*/
|
|
44
|
+
export declare function ContentClientProvider({ client, children, }: {
|
|
45
|
+
client: ContentClient;
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
}): ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* Read the injected `ContentClient` inside a component implementation (EC-191).
|
|
50
|
+
* Returns `null` when none is provided (e.g. a pure-static render) — a self-fetching
|
|
51
|
+
* component must degrade visibly, never crash, when content access is absent.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useContentClient(): ContentClient | null;
|
|
54
|
+
/**
|
|
55
|
+
* A deterministic, in-memory `ContentClient` over fixed documents + assets (EC-191).
|
|
56
|
+
* The studio preview and tests use it so a self-fetching component renders the same
|
|
57
|
+
* content every time. `limit` is the only query knob in v1.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createFixtureContentClient(fixtures: {
|
|
60
|
+
documents?: readonly ContentDocumentView[];
|
|
61
|
+
assets?: readonly ContentAssetView[];
|
|
62
|
+
}): ContentClient;
|