reactive-md 0.6.1 → 0.8.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-ch.md +66 -0
- package/CHANGELOG.md +66 -0
- package/CONTRIBUTING-ch.md +6 -62
- package/CONTRIBUTING.md +5 -63
- package/README-ch.md +232 -67
- package/README-en.md +209 -71
- package/README.md +209 -71
- package/SECURITY-ch.md +3 -1
- package/SECURITY.md +3 -1
- package/THIRD_PARTY_NOTICES.md +1909 -87
- package/cli/args.mjs +33 -1
- package/cli/build.mjs +62 -1
- package/cli/check.mjs +444 -0
- package/cli/help.mjs +181 -3
- package/cli/init.mjs +1577 -0
- package/cli/main.mjs +11 -1
- package/cli/package-loader.mjs +41 -0
- package/dist-library/LocalDocumentView-6trX7xJc.js +97920 -0
- package/dist-library/{authoring-BEVyth5X.js → authoring-BsfSwQRm.js} +237 -209
- package/dist-library/compiler--ea2CKQF.js +61 -0
- package/dist-library/compiler-core-kPiH-gOV.js +11805 -0
- package/dist-library/component-state-Cq2K5gkS.js +490 -0
- package/dist-library/component-state-D_cw_EHe.js +54 -0
- package/dist-library/config-validation-DXTynAw7.js +3005 -0
- package/dist-library/default-components-Z_YMio5P.js +2346 -0
- package/dist-library/identity-MYJXKSkB.js +1443 -0
- package/dist-library/math-display-BJz4gbFc.js +24000 -0
- package/dist-library/math-sample-BGEW49zY.js +1124 -0
- package/dist-library/options-CX5m5n-J.js +115 -0
- package/dist-library/parser-standard-DlCk7sLo.js +10122 -0
- package/dist-library/props-DGlBk0e5.js +183 -0
- package/dist-library/react-ByOHunUW.js +122 -0
- package/dist-library/reactive-md-authoring.js +712 -1077
- package/dist-library/reactive-md-build.js +7966 -0
- package/dist-library/reactive-md-compiler-standard.js +33 -0
- package/dist-library/reactive-md-compiler.js +22 -0
- package/dist-library/reactive-md-default-packs.js +71 -0
- package/dist-library/reactive-md-default-preset.js +10 -0
- package/dist-library/reactive-md-export.js +111 -0
- package/dist-library/reactive-md-print.css +18 -3
- package/dist-library/reactive-md-react-runtime.js +251 -0
- package/dist-library/reactive-md-react-server.js +55 -0
- package/dist-library/reactive-md-react-unstyled.js +9 -1
- package/dist-library/reactive-md-react.js +9 -1
- package/dist-library/reactive-md-runtime-browser.js +51 -0
- package/dist-library/reactive-md-runtime.js +3 -0
- package/dist-library/reactive-md-sdk.js +6 -0
- package/dist-library/reactive-md-standalone-host.js +442 -0
- package/dist-library/reactive-md-testing-browser.js +523 -0
- package/dist-library/reactive-md-testing-react.js +221 -0
- package/dist-library/reactive-md-testing.js +638 -0
- package/dist-library/reactive-md-vite.js +959 -0
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1080 -795
- package/dist-library/registry-B9Jc3FVe.js +1174 -0
- package/dist-library/resources-BGt8mpDA.js +204 -0
- package/dist-library/runtime-C-sbfpOX.js +1157 -0
- package/dist-library/runtime-Dkq7ldyg.js +172 -0
- package/dist-library/schema-ZFufO8V0.js +39 -0
- package/dist-library/shareable-DDVL4Fi9.js +844 -0
- package/dist-library/types/authoring/catalog.d.ts +168 -0
- package/dist-library/types/authoring/conformance.d.ts +24 -0
- package/dist-library/types/{editor → authoring}/editor-i18n.d.ts +3 -24
- package/dist-library/types/authoring/extensions.d.ts +13 -0
- package/dist-library/types/authoring/index.d.ts +14 -11
- package/dist-library/types/authoring/insert.d.ts +16 -0
- package/dist-library/types/{editor → authoring}/native-components.d.ts +19 -2
- package/dist-library/types/authoring/templates.d.ts +65 -0
- package/dist-library/types/build/diagnostics.d.ts +8 -0
- package/dist-library/types/build/digest.d.ts +5 -0
- package/dist-library/types/build/entry.d.ts +9 -0
- package/dist-library/types/build/host.d.ts +36 -0
- package/dist-library/types/build/index.d.ts +99 -0
- package/dist-library/types/build/notices.d.ts +29 -0
- package/dist-library/types/build/resources.d.ts +60 -0
- package/dist-library/types/build/vite.d.ts +15 -0
- package/dist-library/types/compiler/index.d.ts +22 -0
- package/dist-library/types/compiler/result.d.ts +30 -0
- package/dist-library/types/compiler/standard.d.ts +16 -0
- package/dist-library/types/compiler/types.d.ts +69 -0
- package/dist-library/types/components/chart-motion.d.ts +12 -0
- package/dist-library/types/components/controls.d.ts +21 -0
- package/dist-library/types/{local → components}/data-table.d.ts +10 -24
- package/dist-library/types/components/default-chart-types.d.ts +22 -0
- package/dist-library/types/components/default-chart.d.ts +2 -0
- package/dist-library/types/components/default-preset.d.ts +10 -0
- package/dist-library/types/components/diagram-inspector.d.ts +24 -0
- package/dist-library/types/components/gallery.d.ts +6 -0
- package/dist-library/types/components/layout.d.ts +23 -0
- package/dist-library/types/components/mafs-plot-grid.d.ts +57 -0
- package/dist-library/types/components/mafs-visuals.d.ts +40 -0
- package/dist-library/types/components/numeric-sliders.d.ts +3 -0
- package/dist-library/types/components/uiarc/calendar/calendar.d.ts +26 -0
- package/dist-library/types/components/uiarc/date-picker/date-picker.d.ts +29 -0
- package/dist-library/types/components/uiarc/lib/motion-tokens.d.ts +2 -0
- package/dist-library/types/components/uiarc/lib/use-today.d.ts +2 -0
- package/dist-library/types/components/uiarc/motion-tokens.d.ts +60 -0
- package/dist-library/types/components/uiarc/rmd-motion.d.ts +12 -0
- package/dist-library/types/components/uiarc/select/select.d.ts +21 -0
- package/dist-library/types/components/uiarc/slider/slider.d.ts +53 -0
- package/dist-library/types/components/use-hydrated.d.ts +6 -0
- package/dist-library/types/components/visuals.d.ts +13 -0
- package/dist-library/types/export/component-state.d.ts +39 -0
- package/dist-library/types/export/index.d.ts +47 -0
- package/dist-library/types/export/requirements.d.ts +23 -0
- package/dist-library/types/export/resources.d.ts +8 -0
- package/dist-library/types/export/restoration.d.ts +52 -0
- package/dist-library/types/index.d.ts +1 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +16 -0
- package/dist-library/types/local/compilation/compiler-services.d.ts +64 -0
- package/dist-library/types/local/compilation/compiler-structure.d.ts +46 -0
- package/dist-library/types/local/compilation/compiler-values.d.ts +9 -0
- package/dist-library/types/local/compilation/compiler.d.ts +34 -0
- package/dist-library/types/local/compilation/component-kernel.d.ts +487 -0
- package/dist-library/types/local/{dependencies.d.ts → compilation/dependencies.d.ts} +4 -3
- package/dist-library/types/local/{diagnostics.d.ts → configuration/diagnostic-messages.d.ts} +193 -65
- package/dist-library/types/local/configuration/diagnostics.d.ts +58 -0
- package/dist-library/types/local/{limits.d.ts → configuration/limits.d.ts} +15 -2
- package/dist-library/types/local/configuration/options-core.d.ts +120 -0
- package/dist-library/types/local/configuration/options.d.ts +17 -0
- package/dist-library/types/local/configuration/portable-options.d.ts +3 -0
- package/dist-library/types/local/configuration/schema-core.d.ts +32 -0
- package/dist-library/types/local/configuration/schema.d.ts +12 -0
- package/dist-library/types/local/contracts/types.d.ts +519 -0
- package/dist-library/types/local/{version.d.ts → contracts/version.d.ts} +1 -1
- package/dist-library/types/local/{computations.d.ts → evaluation/computations.d.ts} +6 -3
- package/dist-library/types/local/{expression.d.ts → evaluation/expression.d.ts} +2 -2
- package/dist-library/types/local/{math-display.d.ts → evaluation/math-display.d.ts} +2 -16
- package/dist-library/types/local/evaluation/math-sample.d.ts +23 -0
- package/dist-library/types/local/evaluation/math.d.ts +73 -0
- package/dist-library/types/local/{validation.d.ts → evaluation/validation.d.ts} +1 -1
- package/dist-library/types/local/html/html-details.d.ts +16 -0
- package/dist-library/types/local/html/html-entities.d.ts +7 -0
- package/dist-library/types/local/html/html-policy.d.ts +43 -0
- package/dist-library/types/local/html/html-recovery.d.ts +16 -0
- package/dist-library/types/local/html/html-table-names.d.ts +9 -0
- package/dist-library/types/local/{html-table.d.ts → html/html-table.d.ts} +2 -6
- package/dist-library/types/local/{html.d.ts → html/html.d.ts} +1 -1
- package/dist-library/types/local/index.d.ts +31 -24
- package/dist-library/types/local/markdown/fast-markdown.d.ts +137 -0
- package/dist-library/types/local/{footnotes.d.ts → markdown/footnotes.d.ts} +1 -1
- package/dist-library/types/local/{heading-anchors.d.ts → markdown/heading-anchors.d.ts} +12 -2
- package/dist-library/types/local/markdown/markdown-blocks.d.ts +55 -0
- package/dist-library/types/local/markdown/markdown-structure.d.ts +3 -0
- package/dist-library/types/local/markdown/plain-paragraphs.d.ts +10 -0
- package/dist-library/types/local/parsing/lexical.d.ts +21 -0
- package/dist-library/types/local/parsing/parse-budget.d.ts +67 -0
- package/dist-library/types/local/parsing/parser-capabilities.d.ts +42 -0
- package/dist-library/types/local/parsing/parser-core.d.ts +65 -0
- package/dist-library/types/local/parsing/parser-standard.d.ts +7 -0
- package/dist-library/types/local/parsing/parser.d.ts +16 -0
- package/dist-library/types/local/parsing/rmd-recovery.d.ts +48 -0
- package/dist-library/types/local/{LocalDocumentView.d.ts → rendering/LocalDocumentView.d.ts} +67 -24
- package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +36 -0
- package/dist-library/types/local/rendering/render-types.d.ts +57 -0
- package/dist-library/types/local/rendering/view-revision.d.ts +75 -0
- package/dist-library/types/local/{retention.d.ts → runtime/retention.d.ts} +1 -1
- package/dist-library/types/local/runtime/runtime.d.ts +34 -0
- package/dist-library/types/local/{state.d.ts → runtime/state.d.ts} +4 -4
- package/dist-library/types/local/session/compiler-cache.d.ts +44 -0
- package/dist-library/types/local/session/incremental.d.ts +48 -0
- package/dist-library/types/local/session/parse-session.d.ts +62 -0
- package/dist-library/types/local/session/row-reuse.d.ts +46 -0
- package/dist-library/types/local/{authoring.d.ts → source/authoring.d.ts} +11 -3
- package/dist-library/types/local/source/node-walk.d.ts +3 -0
- package/dist-library/types/local/source/source-context.d.ts +63 -0
- package/dist-library/types/local/{source-migration.d.ts → source/source-migration.d.ts} +2 -2
- package/dist-library/types/local/{i18n.d.ts → theme/i18n.d.ts} +2 -2
- package/dist-library/types/local/theme/theme-name.d.ts +3 -0
- package/dist-library/types/local/{theme.d.ts → theme/theme.d.ts} +3 -3
- package/dist-library/types/local/transport/compile-patch.d.ts +127 -0
- package/dist-library/types/local/{compiled-data.d.ts → transport/compiled-data.d.ts} +1 -1
- package/dist-library/types/local/transport/flat-compiled-data.d.ts +17 -0
- package/dist-library/types/local/transport/shared-data.d.ts +10 -0
- package/dist-library/types/local/transport/worker.d.ts +265 -0
- package/dist-library/types/local/widgets/visuals.d.ts +25 -0
- package/dist-library/types/presets/default-authoring.d.ts +50 -0
- package/dist-library/types/presets/default-components.d.ts +4 -0
- package/dist-library/types/presets/default-semantics.d.ts +8 -0
- package/dist-library/types/presets/default.d.ts +11 -0
- package/dist-library/types/presets/identity.d.ts +7 -0
- package/dist-library/types/presets/packs.d.ts +4 -0
- package/dist-library/types/react/component-api.d.ts +260 -0
- package/dist-library/types/react/component-primitives.d.ts +21 -0
- package/dist-library/types/react/component-utils.d.ts +125 -0
- package/dist-library/types/react/default-theme.d.ts +6 -0
- package/dist-library/types/react/field-validation.d.ts +11 -0
- package/dist-library/types/react/index.d.ts +17 -5
- package/dist-library/types/react/overflow-text-tooltip.d.ts +6 -0
- package/dist-library/types/react/package.d.ts +69 -0
- package/dist-library/types/react/runtime/common.d.ts +4 -0
- package/dist-library/types/react/runtime/index.d.ts +8 -0
- package/dist-library/types/react/runtime/useComponentState.d.ts +30 -0
- package/dist-library/types/react/runtime/useKeys.d.ts +16 -0
- package/dist-library/types/react/runtime/useSwipe.d.ts +27 -0
- package/dist-library/types/react/runtime/useTicker.d.ts +17 -0
- package/dist-library/types/react/sdk.d.ts +110 -0
- package/dist-library/types/react/server.d.ts +15 -0
- package/dist-library/types/react/tooltip-layer.d.ts +10 -0
- package/dist-library/types/react/use-draft-field.d.ts +17 -0
- package/dist-library/types/runtime-services/browser/index.d.ts +63 -0
- package/dist-library/types/runtime-services/component-state.d.ts +152 -0
- package/dist-library/types/runtime-services/identity.d.ts +41 -0
- package/dist-library/types/runtime-services/index.d.ts +10 -0
- package/dist-library/types/runtime-services/random.d.ts +42 -0
- package/dist-library/types/runtime-services/runtime.d.ts +51 -0
- package/dist-library/types/runtime-services/scheduler.d.ts +44 -0
- package/dist-library/types/sdk/assembly.d.ts +73 -0
- package/dist-library/types/sdk/compat-profile.d.ts +57 -0
- package/dist-library/types/sdk/compiler-config.d.ts +33 -0
- package/dist-library/types/sdk/config-validation.d.ts +33 -0
- package/dist-library/types/sdk/config.d.ts +35 -0
- package/dist-library/types/sdk/hash.d.ts +9 -0
- package/dist-library/types/sdk/index.d.ts +10 -0
- package/dist-library/types/sdk/manifest.d.ts +49 -0
- package/dist-library/types/sdk/pattern.d.ts +11 -0
- package/dist-library/types/sdk/preset-core.d.ts +11 -0
- package/dist-library/types/sdk/preset.d.ts +9 -0
- package/dist-library/types/sdk/props.d.ts +33 -0
- package/dist-library/types/sdk/registry-core.d.ts +16 -0
- package/dist-library/types/sdk/registry.d.ts +18 -0
- package/dist-library/types/sdk/theme.d.ts +73 -0
- package/dist-library/types/sdk/types.d.ts +221 -0
- package/dist-library/types/sdk/version.d.ts +49 -0
- package/dist-library/types/shareable.d.ts +29 -3
- package/dist-library/types/standalone/diagnostics.d.ts +16 -0
- package/dist-library/types/standalone/events.d.ts +4 -0
- package/dist-library/types/standalone/library.d.ts +6 -0
- package/dist-library/types/standalone/payload.d.ts +15 -0
- package/dist-library/types/standalone/prepare.d.ts +21 -0
- package/dist-library/types/standalone/session.d.ts +68 -0
- package/dist-library/types/standalone/version.d.ts +7 -0
- package/dist-library/types/testing/behavior.d.ts +19 -0
- package/dist-library/types/testing/browser.d.ts +126 -0
- package/dist-library/types/testing/cases.d.ts +16 -0
- package/dist-library/types/testing/index.d.ts +13 -0
- package/dist-library/types/testing/manifest.d.ts +10 -0
- package/dist-library/types/testing/react.d.ts +45 -0
- package/dist-library/types/testing/report.d.ts +20 -0
- package/dist-library/types/testing/types.d.ts +125 -0
- package/dist-library/types/testing/values.d.ts +22 -0
- package/dist-library/types/vite/client.d.ts +36 -0
- package/dist-library/types/vite/discovery.d.ts +51 -0
- package/dist-library/types/vite/index.d.ts +31 -0
- package/dist-library/types/vite/registration.d.ts +109 -0
- package/dist-library/types-BFCrMrg0.js +52 -0
- package/dist-library/validation-W-bmny-x.js +2253 -0
- package/dist-library/values-CIt8AjiU.js +134 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +591 -95
- package/docs/README-ch.md +90 -0
- package/docs/README.md +87 -81
- package/docs/compatibility/compatibility-ch.md +22 -14
- package/docs/compatibility/compatibility-en.md +22 -14
- package/docs/compatibility/source-versioning-ch.md +15 -12
- package/docs/compatibility/source-versioning-en.md +16 -13
- package/docs/development/component-development-ch.md +51 -195
- package/docs/development/component-development-en.md +51 -195
- package/docs/development/component-development-reference-ch.md +253 -0
- package/docs/development/component-development-reference-en.md +238 -0
- package/docs/development/component-protocol-ch.md +51 -50
- package/docs/development/component-protocol-en.md +52 -49
- package/docs/development/local-module-layout-ch.md +59 -0
- package/docs/development/local-module-layout-en.md +59 -0
- package/docs/development/performance-overview-ch.md +402 -0
- package/docs/development/performance-overview-en.md +402 -0
- package/docs/development/releasing-ch.md +8 -104
- package/docs/development/releasing-en.md +8 -104
- package/docs/guides/local-guide-ch.md +28 -9
- package/docs/guides/local-guide-en.md +31 -12
- package/docs/integration/author-tools-ch.md +4 -2
- package/docs/integration/author-tools-en.md +4 -2
- package/docs/integration/codemirror-ch.md +52 -0
- package/docs/integration/codemirror-en.md +29 -0
- package/docs/integration/compiler-ch.md +47 -0
- package/docs/integration/compiler-en.md +34 -0
- package/docs/integration/directory-discovery-ch.md +53 -0
- package/docs/integration/directory-discovery-en.md +31 -0
- package/docs/integration/editor-ch.md +48 -21
- package/docs/integration/editor-en.md +48 -21
- package/docs/integration/extension-sdk-ch.md +392 -0
- package/docs/integration/extension-sdk-en.md +377 -0
- package/docs/integration/local-integration-ch.md +63 -9
- package/docs/integration/local-integration-en.md +89 -13
- package/docs/integration/repository-split-ch.md +40 -0
- package/docs/integration/repository-split-en.md +23 -0
- package/docs/integration/shareable-export-ch.md +46 -2
- package/docs/integration/shareable-export-en.md +46 -2
- package/docs/reference/computations-formatting-ch.md +4 -2
- package/docs/reference/computations-formatting-en.md +4 -2
- package/docs/reference/constraints-collections-ch.md +21 -1
- package/docs/reference/constraints-collections-en.md +21 -1
- package/docs/reference/diagnostics-counting-ch.md +1 -1
- package/docs/reference/diagnostics-counting-en.md +1 -1
- package/docs/reference/html-compatibility-ch.md +4 -0
- package/docs/reference/html-compatibility-en.md +4 -0
- package/docs/reference/local-components-v2-ch.md +2 -0
- package/docs/reference/local-components-v2-en.md +2 -0
- package/docs/reference/local-interaction-syntax-ch.md +51 -15
- package/docs/reference/local-interaction-syntax-en.md +58 -14
- package/docs/reference/theme-protocol-ch.md +79 -7
- package/docs/reference/theme-protocol-en.md +79 -7
- package/docs/reference/tolerance-ch.md +64 -0
- package/docs/reference/tolerance-en.md +57 -0
- package/docs/releases/release-0.4.0-ch.md +2 -0
- package/docs/releases/release-0.4.0-en.md +2 -0
- package/docs/releases/release-0.4.1-ch.md +2 -0
- package/docs/releases/release-0.4.1-en.md +2 -0
- package/docs/releases/release-0.5.0-ch.md +2 -0
- package/docs/releases/release-0.5.0-en.md +2 -0
- package/docs/releases/release-0.5.1-ch.md +2 -0
- package/docs/releases/release-0.5.1-en.md +2 -0
- package/docs/releases/release-0.5.2-ch.md +2 -0
- package/docs/releases/release-0.5.2-en.md +2 -0
- package/docs/releases/release-0.5.3-ch.md +2 -0
- package/docs/releases/release-0.5.3-en.md +2 -0
- package/docs/releases/release-0.6.0-ch.md +2 -0
- package/docs/releases/release-0.6.0-en.md +2 -0
- package/docs/releases/release-0.6.1-ch.md +2 -0
- package/docs/releases/release-0.6.1-en.md +2 -0
- package/docs/releases/release-0.7.0-ch.md +86 -0
- package/docs/releases/release-0.7.0-en.md +86 -0
- package/docs/releases/release-0.8.0-ch.md +126 -0
- package/docs/releases/release-0.8.0-en.md +126 -0
- package/examples/component-package/LICENSE +21 -0
- package/examples/component-package/NOTICES.md +12 -0
- package/examples/component-package/README-ch.md +101 -0
- package/examples/component-package/README.md +133 -0
- package/examples/component-package/package.json +35 -0
- package/examples/component-package/sample/document.reactive.md +14 -0
- package/examples/component-package/scripts/build-export.mjs +44 -0
- package/examples/component-package/scripts/build.mjs +130 -0
- package/examples/component-package/scripts/verify.mjs +257 -0
- package/examples/component-package/src/assets/notice.svg +4 -0
- package/examples/component-package/src/component.css +40 -0
- package/examples/component-package/src/components.tsx +105 -0
- package/examples/component-package/src/harness.tsx +34 -0
- package/examples/component-package/src/manifests.ts +71 -0
- package/examples/component-package/src/node-entry.ts +18 -0
- package/examples/component-package/src/sample.ts +4 -0
- package/examples/component-package/src/theme.css +44 -0
- package/examples/component-package/src/theme.ts +22 -0
- package/examples/component-package/tsconfig.json +15 -0
- package/examples/conformance/README-ch.md +55 -0
- package/examples/conformance/README.md +2 -0
- package/examples/conformance/local-draft-3.json +296 -0
- package/examples/game-2048-package/LICENSE +21 -0
- package/examples/game-2048-package/NOTICES.md +11 -0
- package/examples/game-2048-package/README-ch.md +97 -0
- package/examples/game-2048-package/README.md +102 -0
- package/examples/game-2048-package/package.json +35 -0
- package/examples/game-2048-package/sample/document.reactive.md +17 -0
- package/examples/game-2048-package/scripts/build-export.mjs +44 -0
- package/examples/game-2048-package/scripts/build.mjs +130 -0
- package/examples/game-2048-package/scripts/verify.mjs +180 -0
- package/examples/game-2048-package/src/component.css +161 -0
- package/examples/game-2048-package/src/components.tsx +326 -0
- package/examples/game-2048-package/src/game-engine.ts +228 -0
- package/examples/game-2048-package/src/harness.tsx +34 -0
- package/examples/game-2048-package/src/manifest.ts +85 -0
- package/examples/game-2048-package/src/node-entry.ts +30 -0
- package/examples/game-2048-package/src/sample.ts +4 -0
- package/examples/game-2048-package/tsconfig.json +15 -0
- package/examples/integration/README-ch.md +63 -0
- package/examples/integration/README.md +17 -1
- package/examples/integration/extension-sdk/README-ch.md +24 -0
- package/examples/integration/extension-sdk/README.md +24 -0
- package/examples/integration/extension-sdk/advanced-standalone.ts +6 -0
- package/examples/integration/extension-sdk/advanced.tsx +101 -0
- package/examples/integration/extension-sdk/env.d.ts +2 -0
- package/examples/integration/extension-sdk/extensions.tsx +97 -0
- package/examples/integration/extension-sdk/index.html +3 -0
- package/examples/integration/extension-sdk/main.tsx +10 -0
- package/examples/integration/extension-sdk/package.json +6 -0
- package/examples/integration/extension-sdk/standalone.ts +7 -0
- package/examples/integration/extension-sdk/tsconfig.json +8 -0
- package/examples/integration/react-comprehensive/index.html +12 -0
- package/examples/integration/react-comprehensive/main.jsx +123 -0
- package/examples/integration/react-comprehensive/package.json +18 -0
- package/examples/local/README-ch.md +76 -0
- package/examples/local/README.md +4 -2
- package/examples/local/scenarios/blog-zh.reactive.md +71 -0
- package/examples/local/scenarios/blog.reactive.md +71 -0
- package/examples/local/scenarios/classroom-zh.reactive.md +97 -0
- package/examples/local/scenarios/classroom.reactive.md +97 -0
- package/examples/local/scenarios/proposal-zh.reactive.md +79 -0
- package/examples/local/scenarios/proposal.reactive.md +79 -0
- package/examples/local/scenarios/survey-zh.reactive.md +74 -0
- package/examples/local/scenarios/survey.reactive.md +74 -0
- package/examples/local/showcase/README-ch.md +22 -0
- package/examples/local/showcase/README.md +9 -3
- package/examples/local/showcase/features.reactive.md +637 -0
- package/examples/local/showcase/zh/features.reactive.md +637 -0
- package/examples/sci-fi-theme/README-ch.md +131 -0
- package/examples/sci-fi-theme/README.md +146 -0
- package/examples/sci-fi-theme/demo/demo.css +532 -0
- package/examples/sci-fi-theme/demo/document.reactive.md +185 -0
- package/examples/sci-fi-theme/demo/index.html +13 -0
- package/examples/sci-fi-theme/demo/main.tsx +180 -0
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -0
- package/examples/sci-fi-theme/docs/design-system.md +474 -0
- package/examples/sci-fi-theme/package.json +27 -0
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -0
- package/examples/sci-fi-theme/src/components.css +1460 -0
- package/examples/sci-fi-theme/src/index.ts +6 -0
- package/examples/sci-fi-theme/src/sci-fi.css +5 -0
- package/examples/sci-fi-theme/src/theme.ts +37 -0
- package/examples/sci-fi-theme/src/tokens.css +408 -0
- package/examples/sci-fi-theme/tsconfig.json +20 -0
- package/examples/sci-fi-theme/vite.config.ts +24 -0
- package/examples/tetris-package/LICENSE +21 -0
- package/examples/tetris-package/NOTICES.md +11 -0
- package/examples/tetris-package/README-ch.md +91 -0
- package/examples/tetris-package/README.md +95 -0
- package/examples/tetris-package/package.json +35 -0
- package/examples/tetris-package/sample/document.reactive.md +16 -0
- package/examples/tetris-package/scripts/build-export.mjs +44 -0
- package/examples/tetris-package/scripts/build.mjs +130 -0
- package/examples/tetris-package/scripts/verify.mjs +173 -0
- package/examples/tetris-package/src/component.css +145 -0
- package/examples/tetris-package/src/components.tsx +334 -0
- package/examples/tetris-package/src/harness.tsx +34 -0
- package/examples/tetris-package/src/manifests.ts +93 -0
- package/examples/tetris-package/src/node-entry.ts +16 -0
- package/examples/tetris-package/src/sample.ts +4 -0
- package/examples/tetris-package/src/tetris-engine.ts +325 -0
- package/examples/tetris-package/tsconfig.json +15 -0
- package/package.json +98 -44
- package/dist-library/compiler-Cm3ppMxG.js +0 -46044
- package/dist-library/react-Bh7_oxZp.js +0 -59655
- package/dist-library/reactive-md-editor.css +0 -2
- package/dist-library/reactive-md-editor.js +0 -3853
- package/dist-library/runtime-DlFYQ4s_.js +0 -498
- package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +0 -7
- package/dist-library/types/editor/editor-toolbar.d.ts +0 -24
- package/dist-library/types/editor/editor-view-bar.d.ts +0 -11
- package/dist-library/types/editor/extended-native-components.d.ts +0 -58
- package/dist-library/types/editor/index.d.ts +0 -9
- package/dist-library/types/editor/locale.d.ts +0 -13
- package/dist-library/types/editor/source-authoring.d.ts +0 -59
- package/dist-library/types/editor/types.d.ts +0 -48
- package/dist-library/types/editor/use-gutter-metrics.d.ts +0 -5
- package/dist-library/types/editor/use-source-history.d.ts +0 -16
- package/dist-library/types/local/compiler.d.ts +0 -4
- package/dist-library/types/local/math.d.ts +0 -48
- package/dist-library/types/local/options.d.ts +0 -36
- package/dist-library/types/local/parser.d.ts +0 -13
- package/dist-library/types/local/render-types.d.ts +0 -27
- package/dist-library/types/local/runtime.d.ts +0 -2
- package/dist-library/types/local/schema.d.ts +0 -77
- package/dist-library/types/local/types.d.ts +0 -263
- package/dist-library/types/local/visuals.d.ts +0 -12
- package/dist-library/types/local/worker.d.ts +0 -98
- package/docs/development/performance-ch.md +0 -76
- package/docs/development/performance-en.md +0 -76
- /package/dist-library/types/{editor → authoring}/command-types.d.ts +0 -0
- /package/dist-library/types/{editor → authoring}/editor-commands.d.ts +0 -0
- /package/dist-library/types/local/{locale.d.ts → contracts/locale.d.ts} +0 -0
- /package/dist-library/types/local/{collection-functions.d.ts → evaluation/collection-functions.d.ts} +0 -0
- /package/dist-library/types/local/{data-functions.d.ts → evaluation/data-functions.d.ts} +0 -0
- /package/dist-library/types/local/{dates.d.ts → evaluation/dates.d.ts} +0 -0
- /package/dist-library/types/local/{formatting.d.ts → evaluation/formatting.d.ts} +0 -0
- /package/dist-library/types/local/{html-names.d.ts → html/html-names.d.ts} +0 -0
- /package/dist-library/types/local/{text-length.d.ts → source/text-length.d.ts} +0 -0
- /package/dist-library/types/local/{colors.d.ts → theme/colors.d.ts} +0 -0
- /package/dist-library/types/local/{code-block.d.ts → widgets/code-block.d.ts} +0 -0
- /package/dist-library/types/local/{code-languages.d.ts → widgets/code-languages.d.ts} +0 -0
- /package/dist-library/types/local/{diagram-layout.d.ts → widgets/diagram-layout.d.ts} +0 -0
- /package/dist-library/types/local/{image-view.d.ts → widgets/image-view.d.ts} +0 -0
- /package/dist-library/types/local/{math-view.d.ts → widgets/math-view.d.ts} +0 -0
- /package/dist-library/types/local/{table-surface.d.ts → widgets/table-surface.d.ts} +0 -0
package/cli/init.mjs
ADDED
|
@@ -0,0 +1,1577 @@
|
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createInterface } from 'node:readline/promises';
|
|
4
|
+
import { EXIT, fsFailure, usageError } from './errors.mjs';
|
|
5
|
+
import { initHelp } from './help.mjs';
|
|
6
|
+
|
|
7
|
+
const COMPONENT_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
8
|
+
const COMPONENT_ID = /^[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)*$/;
|
|
9
|
+
const SEMANTIC_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
10
|
+
const SCAFFOLD_PACKAGE_VERSION = '0.1.0';
|
|
11
|
+
// The published engine package version used for generated npm dependencies and
|
|
12
|
+
// install instructions. Kept in sync with package.json by check-versions.
|
|
13
|
+
const SCAFFOLD_ENGINE_VERSION = '0.8.0';
|
|
14
|
+
// The SDK data contract version, independent of the engine release. Kept in
|
|
15
|
+
// sync with src/sdk/version.ts by scripts/check-versions.mjs.
|
|
16
|
+
const SCAFFOLD_SDK_VERSION = '0.7.0';
|
|
17
|
+
const SCAFFOLD_COMPONENT_PROTOCOL = 'reactive-md-component/v1';
|
|
18
|
+
const SCAFFOLD_PRESET_PROTOCOL = 'reactive-md-preset/v1';
|
|
19
|
+
const SCAFFOLD_REACT_PRESET_PROTOCOL = 'reactive-md-react-preset/v1';
|
|
20
|
+
const MAX_NAME_LENGTH = 128;
|
|
21
|
+
const MAX_ID_LENGTH = 160;
|
|
22
|
+
const MAX_PROPS = 64;
|
|
23
|
+
const MAX_ENUM_VALUES = 64;
|
|
24
|
+
const MAX_PATTERN_LENGTH = 512;
|
|
25
|
+
const FORMS = ['leaf', 'inline', 'container'];
|
|
26
|
+
const CAPABILITY_ORDER = ['interactive', 'static', 'ssr', 'offline'];
|
|
27
|
+
const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
28
|
+
const PROP_KINDS = new Set(['string', 'number', 'boolean', 'enum']);
|
|
29
|
+
const PROP_KEYS = new Set([
|
|
30
|
+
'kind', 'required', 'static', 'dynamic', 'default', 'nullable', 'enum', 'values',
|
|
31
|
+
'pattern', 'min', 'max', 'integer', 'positive', 'color', 'coerce', 'description',
|
|
32
|
+
]);
|
|
33
|
+
const PROP_FLAGS = ['required', 'static', 'dynamic', 'nullable', 'integer', 'positive', 'color'];
|
|
34
|
+
|
|
35
|
+
const INIT_SPEC = new Map([
|
|
36
|
+
['--name', { key: 'name' }],
|
|
37
|
+
['--id', { key: 'id' }],
|
|
38
|
+
['--form', { key: 'form' }],
|
|
39
|
+
['--props', { key: 'props' }],
|
|
40
|
+
['--capabilities', { key: 'capabilities' }],
|
|
41
|
+
['--version', { key: 'version' }],
|
|
42
|
+
['--locale', { key: 'locale' }],
|
|
43
|
+
['-y', { key: 'yes', boolean: true }],
|
|
44
|
+
['--yes', { key: 'yes', boolean: true }],
|
|
45
|
+
['-h', { key: 'help', boolean: true }],
|
|
46
|
+
['--help', { key: 'help', boolean: true }],
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parse init arguments. The option reader mirrors the build command: values may
|
|
51
|
+
* be separate tokens or `--option=value`, and `--` makes the rest literal.
|
|
52
|
+
*
|
|
53
|
+
* @param {string[]} argv
|
|
54
|
+
*/
|
|
55
|
+
function parseInitOptions(argv) {
|
|
56
|
+
const positionals = [];
|
|
57
|
+
const options = {};
|
|
58
|
+
let literal = false;
|
|
59
|
+
|
|
60
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
61
|
+
const token = argv[index];
|
|
62
|
+
if (literal) {
|
|
63
|
+
positionals.push(token);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (token === '--') {
|
|
67
|
+
literal = true;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (token === '-' || !token.startsWith('-')) {
|
|
71
|
+
positionals.push(token);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let name = token;
|
|
76
|
+
let inlineValue;
|
|
77
|
+
if (token.startsWith('--')) {
|
|
78
|
+
const equals = token.indexOf('=');
|
|
79
|
+
if (equals > 2) {
|
|
80
|
+
name = token.slice(0, equals);
|
|
81
|
+
inlineValue = token.slice(equals + 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const entry = INIT_SPEC.get(name);
|
|
85
|
+
if (!entry) {
|
|
86
|
+
throw usageError(`Unknown option "${name}". Run "reactive-md init --help" for usage.`);
|
|
87
|
+
}
|
|
88
|
+
if (entry.boolean) {
|
|
89
|
+
if (inlineValue !== undefined) throw usageError(`Option "${name}" does not take a value.`);
|
|
90
|
+
options[entry.key] = true;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
let value = inlineValue;
|
|
94
|
+
if (value === undefined) {
|
|
95
|
+
if (index + 1 >= argv.length) throw usageError(`Option "${name}" requires a value.`);
|
|
96
|
+
value = argv[index + 1];
|
|
97
|
+
index += 1;
|
|
98
|
+
}
|
|
99
|
+
options[entry.key] = value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return { positionals, options };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** @param {unknown} value @param {string} option */
|
|
106
|
+
function requireText(value, option) {
|
|
107
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
108
|
+
throw usageError(`Option "${option}" requires a non-empty value.`);
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** @param {unknown} value */
|
|
114
|
+
function isPlainObject(value) {
|
|
115
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The SDK accepts only linear-time-safe patterns. Keep the scaffold to the same
|
|
120
|
+
* subset so a generated manifest cannot fail when it is imported.
|
|
121
|
+
*
|
|
122
|
+
* @param {string} source
|
|
123
|
+
*/
|
|
124
|
+
function patternQuantifier(source, index) {
|
|
125
|
+
const char = source[index];
|
|
126
|
+
if (char === '*' || char === '+' || char === '?') {
|
|
127
|
+
return { length: source[index + 1] === '?' ? 2 : 1 };
|
|
128
|
+
}
|
|
129
|
+
if (char !== '{') return null;
|
|
130
|
+
const match = /^\{(\d+)(?:,(\d*))?\}/.exec(source.slice(index));
|
|
131
|
+
if (!match) return null;
|
|
132
|
+
return { length: match[0].length + (source[index + match[0].length] === '?' ? 1 : 0) };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @param {string} source
|
|
137
|
+
*/
|
|
138
|
+
function isSafePattern(source) {
|
|
139
|
+
const groups = [];
|
|
140
|
+
let escaped = false;
|
|
141
|
+
let inClass = false;
|
|
142
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
143
|
+
const char = source[index];
|
|
144
|
+
if (escaped) {
|
|
145
|
+
escaped = false;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (char === '\\') {
|
|
149
|
+
const next = source[index + 1];
|
|
150
|
+
if (next !== undefined && next >= '1' && next <= '9') return false;
|
|
151
|
+
if (next === 'k' && source[index + 2] === '<') return false;
|
|
152
|
+
escaped = true;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (inClass) {
|
|
156
|
+
if (char === ']') inClass = false;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (char === '[') {
|
|
160
|
+
inClass = true;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (char === '(') {
|
|
164
|
+
if (source[index + 1] === '?') {
|
|
165
|
+
if (source[index + 2] !== ':') return false;
|
|
166
|
+
groups.push({ quantified: false, alternation: false });
|
|
167
|
+
index += 2;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
groups.push({ quantified: false, alternation: false });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (char === '|') {
|
|
174
|
+
const group = groups[groups.length - 1];
|
|
175
|
+
if (group) group.alternation = true;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (char === ')') {
|
|
179
|
+
const group = groups.pop();
|
|
180
|
+
if (!group) return false;
|
|
181
|
+
const quantifier = patternQuantifier(source, index + 1);
|
|
182
|
+
if (quantifier && (group.quantified || group.alternation)) return false;
|
|
183
|
+
const parent = groups[groups.length - 1];
|
|
184
|
+
if (parent) {
|
|
185
|
+
parent.quantified = parent.quantified || group.quantified || quantifier !== null;
|
|
186
|
+
parent.alternation = parent.alternation || group.alternation;
|
|
187
|
+
}
|
|
188
|
+
if (quantifier) index += quantifier.length;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const quantifier = patternQuantifier(source, index);
|
|
192
|
+
if (quantifier) {
|
|
193
|
+
const group = groups[groups.length - 1];
|
|
194
|
+
if (group) group.quantified = true;
|
|
195
|
+
index += quantifier.length - 1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return groups.length === 0 && !escaped && !inClass;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Turn a directory name into a valid component tag. Returns null when the name
|
|
203
|
+
* contains no letters or digits at all.
|
|
204
|
+
*
|
|
205
|
+
* @param {string} base
|
|
206
|
+
*/
|
|
207
|
+
function deriveComponentName(base) {
|
|
208
|
+
const normalized = base
|
|
209
|
+
.toLowerCase()
|
|
210
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
211
|
+
.replace(/^-+|-+$/g, '');
|
|
212
|
+
if (normalized === '') return null;
|
|
213
|
+
const candidate = /^[a-z]/.test(normalized) ? normalized : `c-${normalized}`;
|
|
214
|
+
return COMPONENT_NAME.test(candidate) ? candidate : null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** @param {string} name */
|
|
218
|
+
function pascalCase(name) {
|
|
219
|
+
return name.split('-').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** @param {string} value */
|
|
223
|
+
function validateName(value) {
|
|
224
|
+
if (value.length > MAX_NAME_LENGTH || !COMPONENT_NAME.test(value)) {
|
|
225
|
+
throw usageError(`Invalid component name "${value}". Use lowercase kebab-case, for example "my-widget".`);
|
|
226
|
+
}
|
|
227
|
+
return value;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** @param {string} value */
|
|
231
|
+
function validatePresetName(value) {
|
|
232
|
+
if (value.length > MAX_NAME_LENGTH || !COMPONENT_NAME.test(value)) {
|
|
233
|
+
throw usageError(`Invalid preset name "${value}". Use lowercase kebab-case, for example "my-preset".`);
|
|
234
|
+
}
|
|
235
|
+
return value;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** @param {string} value */
|
|
239
|
+
function validateId(value) {
|
|
240
|
+
if (value.length > MAX_ID_LENGTH || !COMPONENT_ID.test(value)) {
|
|
241
|
+
throw usageError(`Invalid component id "${value}". Use a lowercase namespaced id such as "example/my-widget".`);
|
|
242
|
+
}
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** @param {unknown} value */
|
|
247
|
+
function validateForm(value) {
|
|
248
|
+
const normalized = String(value).trim().toLowerCase();
|
|
249
|
+
if (!FORMS.includes(normalized)) {
|
|
250
|
+
throw usageError(`Invalid value for "--form": "${value}". Expected leaf, inline or container.`);
|
|
251
|
+
}
|
|
252
|
+
return normalized;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** @param {unknown} value */
|
|
256
|
+
function validatePresetVersion(value) {
|
|
257
|
+
const text = requireText(value, '--version').trim();
|
|
258
|
+
if (!SEMANTIC_VERSION.test(text)) {
|
|
259
|
+
throw usageError(`Invalid preset version "${text}". Use a semantic version such as "0.1.0".`);
|
|
260
|
+
}
|
|
261
|
+
return text;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** @param {unknown} value */
|
|
265
|
+
function parseLocale(value) {
|
|
266
|
+
if (value === undefined) return 'en';
|
|
267
|
+
const normalized = String(value).trim().toLowerCase();
|
|
268
|
+
if (normalized !== 'en' && normalized !== 'zh') {
|
|
269
|
+
throw usageError(`Invalid value for "--locale": "${value}". Expected en or zh.`);
|
|
270
|
+
}
|
|
271
|
+
return normalized;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Validate a props declaration before any file is written so the generated
|
|
276
|
+
* manifest is accepted by defineLocalComponent.
|
|
277
|
+
*
|
|
278
|
+
* @param {string} propName
|
|
279
|
+
* @param {unknown} value
|
|
280
|
+
*/
|
|
281
|
+
function validatePropDeclaration(propName, value) {
|
|
282
|
+
const label = `props.${propName}`;
|
|
283
|
+
if (!isPlainObject(value)) {
|
|
284
|
+
throw usageError(`Invalid ${label}: must be an object.`);
|
|
285
|
+
}
|
|
286
|
+
for (const key of Object.keys(value)) {
|
|
287
|
+
if (!PROP_KEYS.has(key)) {
|
|
288
|
+
throw usageError(`Invalid ${label}: unknown field "${key}".`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const kind = value.kind;
|
|
292
|
+
if (typeof kind !== 'string' || !PROP_KINDS.has(kind)) {
|
|
293
|
+
throw usageError(`Invalid ${label}.kind: expected "string", "number", "boolean" or "enum".`);
|
|
294
|
+
}
|
|
295
|
+
for (const flag of PROP_FLAGS) {
|
|
296
|
+
if (value[flag] !== undefined && typeof value[flag] !== 'boolean') {
|
|
297
|
+
throw usageError(`Invalid ${label}.${flag}: expected a boolean.`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (value.static === true && value.dynamic === true) {
|
|
301
|
+
throw usageError(`Invalid ${label}: it cannot be both static and dynamic.`);
|
|
302
|
+
}
|
|
303
|
+
if (value.coerce !== undefined) {
|
|
304
|
+
if (value.coerce !== 'text') throw usageError(`Invalid ${label}.coerce: expected "text".`);
|
|
305
|
+
if (kind !== 'string') throw usageError(`Invalid ${label}.coerce: only string props accept coerce.`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const enumValues = value.enum !== undefined ? value.enum : value.values;
|
|
309
|
+
if (value.enum !== undefined && value.values !== undefined) {
|
|
310
|
+
throw usageError(`Invalid ${label}: use "enum" or "values", not both.`);
|
|
311
|
+
}
|
|
312
|
+
if (kind === 'enum') {
|
|
313
|
+
if (!Array.isArray(enumValues) || enumValues.length === 0) {
|
|
314
|
+
throw usageError(`Invalid ${label}.enum: expected a non-empty string array.`);
|
|
315
|
+
}
|
|
316
|
+
if (enumValues.length > MAX_ENUM_VALUES) {
|
|
317
|
+
throw usageError(`Invalid ${label}.enum: accepts at most ${MAX_ENUM_VALUES} values.`);
|
|
318
|
+
}
|
|
319
|
+
const seen = new Set();
|
|
320
|
+
for (const item of enumValues) {
|
|
321
|
+
if (typeof item !== 'string' || item.length === 0 || item.length > MAX_NAME_LENGTH) {
|
|
322
|
+
throw usageError(`Invalid ${label}.enum: values must be non-empty strings.`);
|
|
323
|
+
}
|
|
324
|
+
if (seen.has(item)) throw usageError(`Invalid ${label}.enum: "${item}" is repeated.`);
|
|
325
|
+
seen.add(item);
|
|
326
|
+
}
|
|
327
|
+
} else if (enumValues !== undefined) {
|
|
328
|
+
throw usageError(`Invalid ${label}.enum: only enum props declare allowed values.`);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (value.pattern !== undefined) {
|
|
332
|
+
if (kind !== 'string' || typeof value.pattern !== 'string') {
|
|
333
|
+
throw usageError(`Invalid ${label}.pattern: only string props accept a pattern.`);
|
|
334
|
+
}
|
|
335
|
+
if (value.pattern.length > MAX_PATTERN_LENGTH) {
|
|
336
|
+
throw usageError(`Invalid ${label}.pattern: exceeds the ${MAX_PATTERN_LENGTH}-character limit.`);
|
|
337
|
+
}
|
|
338
|
+
try {
|
|
339
|
+
new RegExp(value.pattern);
|
|
340
|
+
} catch {
|
|
341
|
+
throw usageError(`Invalid ${label}.pattern: not a valid regular expression.`);
|
|
342
|
+
}
|
|
343
|
+
if (!isSafePattern(value.pattern)) {
|
|
344
|
+
throw usageError(`Invalid ${label}.pattern: nested quantifiers, quantified alternation, backreferences and lookarounds are rejected.`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const hasBounds = value.min !== undefined || value.max !== undefined;
|
|
349
|
+
if (hasBounds) {
|
|
350
|
+
if (kind !== 'number') throw usageError(`Invalid ${label}: min and max apply to number props.`);
|
|
351
|
+
for (const key of ['min', 'max']) {
|
|
352
|
+
if (value[key] !== undefined && (typeof value[key] !== 'number' || !Number.isFinite(value[key]))) {
|
|
353
|
+
throw usageError(`Invalid ${label}.${key}: expected a finite number.`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (value.min !== undefined && value.max !== undefined && value.min > value.max) {
|
|
357
|
+
throw usageError(`Invalid ${label}: min cannot exceed max.`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (kind !== 'number' && (value.integer === true || value.positive === true)) {
|
|
361
|
+
throw usageError(`Invalid ${label}: integer and positive apply to number props.`);
|
|
362
|
+
}
|
|
363
|
+
if (kind !== 'string' && value.color === true) {
|
|
364
|
+
throw usageError(`Invalid ${label}.color: only string props accept a color flag.`);
|
|
365
|
+
}
|
|
366
|
+
if (value.description !== undefined) {
|
|
367
|
+
if (!isPlainObject(value.description)
|
|
368
|
+
|| Object.values(value.description).some((entry) => typeof entry !== 'string' || entry.length > 256)
|
|
369
|
+
|| Object.keys(value.description).some((key) => DANGEROUS_KEYS.has(key)
|
|
370
|
+
|| !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(key))) {
|
|
371
|
+
throw usageError(`Invalid ${label}.description: expected locale-keyed strings such as {"en": "..."}.`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (value.default !== undefined) {
|
|
376
|
+
const fallback = value.default;
|
|
377
|
+
if (fallback === null) {
|
|
378
|
+
if (value.nullable !== true) throw usageError(`Invalid ${label}.default: null requires nullable.`);
|
|
379
|
+
} else if (kind === 'string') {
|
|
380
|
+
if (typeof fallback !== 'string') throw usageError(`Invalid ${label}.default: expected a string.`);
|
|
381
|
+
} else if (kind === 'number') {
|
|
382
|
+
if (typeof fallback !== 'number' || !Number.isFinite(fallback)) {
|
|
383
|
+
throw usageError(`Invalid ${label}.default: expected a finite number.`);
|
|
384
|
+
}
|
|
385
|
+
if (value.integer === true && !Number.isInteger(fallback)) {
|
|
386
|
+
throw usageError(`Invalid ${label}.default: expected an integer.`);
|
|
387
|
+
}
|
|
388
|
+
if (value.positive === true && fallback <= 0) {
|
|
389
|
+
throw usageError(`Invalid ${label}.default: expected a number greater than zero.`);
|
|
390
|
+
}
|
|
391
|
+
if (value.min !== undefined && fallback < value.min) {
|
|
392
|
+
throw usageError(`Invalid ${label}.default: below the declared minimum.`);
|
|
393
|
+
}
|
|
394
|
+
if (value.max !== undefined && fallback > value.max) {
|
|
395
|
+
throw usageError(`Invalid ${label}.default: above the declared maximum.`);
|
|
396
|
+
}
|
|
397
|
+
} else if (kind === 'boolean') {
|
|
398
|
+
if (typeof fallback !== 'boolean') throw usageError(`Invalid ${label}.default: expected a boolean.`);
|
|
399
|
+
} else if (!Array.isArray(enumValues) || !enumValues.includes(fallback)) {
|
|
400
|
+
throw usageError(`Invalid ${label}.default: must be one of the enum values.`);
|
|
401
|
+
}
|
|
402
|
+
if (typeof fallback === 'string' && typeof value.pattern === 'string'
|
|
403
|
+
&& !new RegExp(value.pattern).test(fallback)) {
|
|
404
|
+
throw usageError(`Invalid ${label}.default: does not match the declared pattern.`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** @param {unknown} value */
|
|
410
|
+
function parseProps(value) {
|
|
411
|
+
const text = requireText(value, '--props');
|
|
412
|
+
let parsed;
|
|
413
|
+
try {
|
|
414
|
+
parsed = JSON.parse(text);
|
|
415
|
+
} catch (error) {
|
|
416
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
417
|
+
throw usageError(`Option "--props" is not valid JSON: ${detail}.`);
|
|
418
|
+
}
|
|
419
|
+
if (!isPlainObject(parsed)) {
|
|
420
|
+
throw usageError('Option "--props" must be a JSON object mapping prop names to declarations.');
|
|
421
|
+
}
|
|
422
|
+
const names = Object.keys(parsed);
|
|
423
|
+
if (names.length > MAX_PROPS) {
|
|
424
|
+
throw usageError(`Option "--props" declares more than ${MAX_PROPS} properties.`);
|
|
425
|
+
}
|
|
426
|
+
for (const name of names) {
|
|
427
|
+
if (DANGEROUS_KEYS.has(name)) throw usageError(`Invalid prop name "${name}".`);
|
|
428
|
+
if (name.length > MAX_NAME_LENGTH || !COMPONENT_NAME.test(name)) {
|
|
429
|
+
throw usageError(`Invalid prop name "${name}". Use lowercase kebab-case.`);
|
|
430
|
+
}
|
|
431
|
+
validatePropDeclaration(name, parsed[name]);
|
|
432
|
+
}
|
|
433
|
+
return parsed;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** @param {unknown} value */
|
|
437
|
+
function parseCapabilities(value) {
|
|
438
|
+
const text = requireText(value, '--capabilities');
|
|
439
|
+
const tokens = text.split(',').map((token) => token.trim());
|
|
440
|
+
if (tokens.some((token) => token === '')) {
|
|
441
|
+
throw usageError('Option "--capabilities" must not contain empty entries.');
|
|
442
|
+
}
|
|
443
|
+
const selected = new Set();
|
|
444
|
+
for (const token of tokens) {
|
|
445
|
+
const normalized = token.toLowerCase();
|
|
446
|
+
if (!CAPABILITY_ORDER.includes(normalized)) {
|
|
447
|
+
throw usageError(`Invalid capability "${token}". Expected a comma-separated subset of interactive, static, ssr, offline.`);
|
|
448
|
+
}
|
|
449
|
+
if (selected.has(normalized)) {
|
|
450
|
+
throw usageError(`Capability "${normalized}" is listed more than once.`);
|
|
451
|
+
}
|
|
452
|
+
selected.add(normalized);
|
|
453
|
+
}
|
|
454
|
+
if (!selected.has('interactive') && !selected.has('static')) {
|
|
455
|
+
throw usageError('At least one of "interactive" or "static" is required for the preview.');
|
|
456
|
+
}
|
|
457
|
+
return CAPABILITY_ORDER.filter((capability) => selected.has(capability));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** @param {unknown} context */
|
|
461
|
+
function canPrompt(context) {
|
|
462
|
+
const input = context.stdin ?? process.stdin;
|
|
463
|
+
return Boolean(input && input.isTTY && context.stdout && context.stdout.isTTY);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** @param {string} value */
|
|
467
|
+
function escapeAttribute(value) {
|
|
468
|
+
return String(value)
|
|
469
|
+
.replace(/&/g, '&')
|
|
470
|
+
.replace(/"/g, '"')
|
|
471
|
+
.replace(/</g, '<');
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** @param {{kind?: string, pattern?: string, color?: boolean}} prop */
|
|
475
|
+
function sampleString(prop) {
|
|
476
|
+
const fallback = prop.color === true ? '#000000' : 'example';
|
|
477
|
+
const candidates = prop.color === true
|
|
478
|
+
? ['#000000', 'black', 'red', 'example']
|
|
479
|
+
: ['example', 'Example', 'x', 'sample', 'value', 'abc', 'a1', 'test'];
|
|
480
|
+
if (typeof prop.pattern !== 'string') return fallback;
|
|
481
|
+
let expression;
|
|
482
|
+
try {
|
|
483
|
+
expression = new RegExp(prop.pattern);
|
|
484
|
+
} catch {
|
|
485
|
+
return fallback;
|
|
486
|
+
}
|
|
487
|
+
return candidates.find((candidate) => expression.test(candidate)) ?? fallback;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** @param {Record<string, any>} prop */
|
|
491
|
+
function sampleNumber(prop) {
|
|
492
|
+
let value = 1;
|
|
493
|
+
if (typeof prop.min === 'number') value = Math.ceil(prop.min);
|
|
494
|
+
if (prop.positive === true && value <= 0) value = 1;
|
|
495
|
+
if (typeof prop.max === 'number' && value > prop.max) value = prop.max;
|
|
496
|
+
if (prop.integer === true) value = Math.trunc(value);
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** @param {Record<string, any>} prop */
|
|
501
|
+
function sampleValue(prop) {
|
|
502
|
+
if (prop.kind === 'number') return String(sampleNumber(prop));
|
|
503
|
+
if (prop.kind === 'boolean') return 'true';
|
|
504
|
+
if (prop.kind === 'enum') {
|
|
505
|
+
const values = prop.enum ?? prop.values ?? [];
|
|
506
|
+
return values[0] ?? '';
|
|
507
|
+
}
|
|
508
|
+
return sampleString(prop);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Author attributes only for required props without a default. Optional props
|
|
513
|
+
* use their defaults in the preview document.
|
|
514
|
+
*
|
|
515
|
+
* @param {Record<string, any>} props
|
|
516
|
+
*/
|
|
517
|
+
function sampleAttributes(props) {
|
|
518
|
+
const attributes = [];
|
|
519
|
+
for (const [name, prop] of Object.entries(props)) {
|
|
520
|
+
if (prop.required !== true || prop.default !== undefined) continue;
|
|
521
|
+
attributes.push(`${name}="${escapeAttribute(sampleValue(prop))}"`);
|
|
522
|
+
}
|
|
523
|
+
return attributes;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @param {{name: string, form: string, props: Record<string, any>}} plan
|
|
528
|
+
*/
|
|
529
|
+
function sampleTag(plan) {
|
|
530
|
+
const attributes = sampleAttributes(plan.props);
|
|
531
|
+
const suffix = attributes.length > 0 ? ` ${attributes.join(' ')}` : '';
|
|
532
|
+
if (plan.form === 'leaf') return `<${plan.name}${suffix}>`;
|
|
533
|
+
if (plan.form === 'inline') return `<${plan.name}${suffix}>inline content</${plan.name}>`;
|
|
534
|
+
return `<${plan.name}${suffix}>\n\n**Markdown** children render here.\n\n</${plan.name}>`;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** @param {{name: string, form: string, props: Record<string, any>}} plan */
|
|
538
|
+
function previewSource(plan) {
|
|
539
|
+
const tag = sampleTag(plan);
|
|
540
|
+
if (plan.form === 'inline') return `Preview text before ${tag} and after.`;
|
|
541
|
+
return tag;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** @param {string} value @param {number} indent */
|
|
545
|
+
function jsonBlock(value, indent) {
|
|
546
|
+
return JSON.stringify(value, null, 2).replace(/\n/g, `\n${' '.repeat(indent)}`);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** @param {{name: string, id: string, form: string, props: Record<string, any>, capabilities: string[]}} plan */
|
|
550
|
+
function manifestSource(plan) {
|
|
551
|
+
const structure = plan.form === 'leaf'
|
|
552
|
+
? ''
|
|
553
|
+
: plan.form === 'inline'
|
|
554
|
+
? " structure: { rule: 'inline' },\n"
|
|
555
|
+
: " structure: { rule: 'any', label: 'optional' },\n";
|
|
556
|
+
const capabilities = CAPABILITY_ORDER
|
|
557
|
+
.map((capability) => `${capability}: ${plan.capabilities.includes(capability)}`)
|
|
558
|
+
.join(', ');
|
|
559
|
+
const tag = sampleTag(plan);
|
|
560
|
+
return `import { defineLocalComponent } from 'reactive-md/sdk';
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Pure-data manifest. It has no React or CSS imports, so Node consumers can
|
|
564
|
+
* read the definition without a bundler.
|
|
565
|
+
*/
|
|
566
|
+
const id = ${JSON.stringify(plan.id)};
|
|
567
|
+
export const manifest = defineLocalComponent({
|
|
568
|
+
id,
|
|
569
|
+
name: ${JSON.stringify(plan.name)},
|
|
570
|
+
version: '${SCAFFOLD_PACKAGE_VERSION}',
|
|
571
|
+
protocol: '${SCAFFOLD_COMPONENT_PROTOCOL}',
|
|
572
|
+
form: ${JSON.stringify(plan.form)},
|
|
573
|
+
props: ${jsonBlock(plan.props, 2)},
|
|
574
|
+
styles: [id + '.css'],
|
|
575
|
+
${structure} capabilities: { ${capabilities} },
|
|
576
|
+
authoring: {
|
|
577
|
+
title: { en: ${JSON.stringify(pascalCase(plan.name))} },
|
|
578
|
+
description: { en: ${JSON.stringify(`A <${plan.name}> component.`)} },
|
|
579
|
+
insertText: ${JSON.stringify(tag)},
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
export default manifest;
|
|
584
|
+
`;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/** @param {{name: string, form: string}} plan */
|
|
588
|
+
function componentSource(plan) {
|
|
589
|
+
const componentName = `${pascalCase(plan.name)}View`;
|
|
590
|
+
const element = plan.form === 'inline' ? 'span' : 'div';
|
|
591
|
+
const titleElement = plan.form === 'inline' ? 'span' : 'strong';
|
|
592
|
+
const bodyElement = plan.form === 'inline' ? 'span' : 'p';
|
|
593
|
+
const childClass = `<${element} className="${plan.name}-children">{ctx.children.render()}</${element}>`;
|
|
594
|
+
const children = plan.form === 'leaf'
|
|
595
|
+
? ''
|
|
596
|
+
: ` {ctx.content.form !== 'leaf' ? ${childClass} : null}\n`;
|
|
597
|
+
return `import {
|
|
598
|
+
defineReactComponentPackage,
|
|
599
|
+
type LocalComponentContext,
|
|
600
|
+
type LocalComponentValue,
|
|
601
|
+
} from 'reactive-md/react';
|
|
602
|
+
import { manifest } from './manifest.js';
|
|
603
|
+
import css from './${plan.name}.css?inline';
|
|
604
|
+
|
|
605
|
+
function text(value: LocalComponentValue | undefined): string {
|
|
606
|
+
if (value === undefined || value === null) return '';
|
|
607
|
+
return String(value);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export function ${componentName}(ctx: LocalComponentContext) {
|
|
611
|
+
return (
|
|
612
|
+
<${element} className="${plan.name}" data-${plan.name} role="group">
|
|
613
|
+
<${titleElement} className="${plan.name}-title">{text(ctx.props.label) || ${JSON.stringify(pascalCase(plan.name))}}</${titleElement}>
|
|
614
|
+
<${bodyElement} className="${plan.name}-body">
|
|
615
|
+
Edit <code>src/${plan.name}.tsx</code> and <code>src/${plan.name}.css</code> to build this component.
|
|
616
|
+
</${bodyElement}>
|
|
617
|
+
<button type="button" className="${plan.name}-action" data-${plan.name}-action disabled={ctx.mode !== 'interactive' || ctx.disabled} onClick={() => ctx.runtime.reset(ctx.content)}>
|
|
618
|
+
Reset example
|
|
619
|
+
</button>
|
|
620
|
+
${children} </${element}>
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
export const componentPackage = defineReactComponentPackage({
|
|
625
|
+
...manifest,
|
|
626
|
+
css,
|
|
627
|
+
render: ${componentName},
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
export const { definition, components, resources } = componentPackage;
|
|
631
|
+
|
|
632
|
+
export default componentPackage;
|
|
633
|
+
`;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/** @param {{name: string}} plan */
|
|
637
|
+
function cssSource(plan) {
|
|
638
|
+
return `.local-document .${plan.name} {
|
|
639
|
+
display: grid;
|
|
640
|
+
gap: var(--space-2, 8px);
|
|
641
|
+
padding: var(--space-3, 12px);
|
|
642
|
+
color: var(--ink);
|
|
643
|
+
background: var(--surface);
|
|
644
|
+
border: 1px solid var(--accent);
|
|
645
|
+
border-radius: var(--radius-card, 8px);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.local-document .${plan.name}-title {
|
|
649
|
+
font-size: 1rem;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.local-document .${plan.name}-body {
|
|
653
|
+
margin: 0;
|
|
654
|
+
color: var(--ink-muted, inherit);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.local-document .${plan.name}-children {
|
|
658
|
+
display: grid;
|
|
659
|
+
gap: var(--space-2, 8px);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.local-document .${plan.name}-action {
|
|
663
|
+
justify-self: start;
|
|
664
|
+
min-width: 6rem;
|
|
665
|
+
min-height: 2.25rem;
|
|
666
|
+
}
|
|
667
|
+
`;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function envSource() {
|
|
671
|
+
return `/// <reference types="vite/client" />
|
|
672
|
+
/// <reference types="reactive-md/vite/client" />
|
|
673
|
+
`;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** @param {{name: string}} plan */
|
|
677
|
+
function extensionsSource(plan) {
|
|
678
|
+
return `import { createReactHost } from 'reactive-md/react';
|
|
679
|
+
import { componentPackage } from './src/${plan.name}.js';
|
|
680
|
+
|
|
681
|
+
export const host = createReactHost({ packages: [componentPackage] });
|
|
682
|
+
|
|
683
|
+
export default host;
|
|
684
|
+
`;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** @param {{name: string, id: string, capabilities: string[]}} plan */
|
|
688
|
+
function packageJsonSource(plan) {
|
|
689
|
+
return `${JSON.stringify({
|
|
690
|
+
name: `reactive-md-${plan.name}-component`,
|
|
691
|
+
version: SCAFFOLD_PACKAGE_VERSION,
|
|
692
|
+
private: true,
|
|
693
|
+
type: 'module',
|
|
694
|
+
description: `A <${plan.name}> component package for Reactive MD.`,
|
|
695
|
+
license: 'MIT',
|
|
696
|
+
files: ['dist', `src/${plan.name}.css`, 'README.md'],
|
|
697
|
+
exports: {
|
|
698
|
+
'.': {
|
|
699
|
+
types: './dist/types/src/manifest.d.ts',
|
|
700
|
+
import: './dist/node/manifest.js',
|
|
701
|
+
},
|
|
702
|
+
'./react': {
|
|
703
|
+
types: `./dist/types/src/${plan.name}.d.ts`,
|
|
704
|
+
import: './dist/node/react.js',
|
|
705
|
+
},
|
|
706
|
+
'./host': {
|
|
707
|
+
types: './dist/types/extensions.d.ts',
|
|
708
|
+
import: './dist/node/host.js',
|
|
709
|
+
},
|
|
710
|
+
'./styles.css': `./src/${plan.name}.css`,
|
|
711
|
+
},
|
|
712
|
+
scripts: {
|
|
713
|
+
dev: 'vite',
|
|
714
|
+
build: 'node scripts/build.mjs',
|
|
715
|
+
'build:preview': 'vite build',
|
|
716
|
+
preview: 'vite preview',
|
|
717
|
+
typecheck: 'tsc --noEmit',
|
|
718
|
+
test: 'node scripts/build.mjs && node scripts/verify.mjs',
|
|
719
|
+
check: 'reactive-md check .',
|
|
720
|
+
export: 'node scripts/build-export.mjs',
|
|
721
|
+
},
|
|
722
|
+
peerDependencies: {
|
|
723
|
+
'reactive-md': `^${SCAFFOLD_ENGINE_VERSION}`,
|
|
724
|
+
react: '^19.0.0',
|
|
725
|
+
'react-dom': '^19.0.0',
|
|
726
|
+
},
|
|
727
|
+
devDependencies: {
|
|
728
|
+
'@types/node': '^22.0.0',
|
|
729
|
+
'@types/react': '^19.0.0',
|
|
730
|
+
'@types/react-dom': '^19.0.0',
|
|
731
|
+
typescript: '^7.0.0',
|
|
732
|
+
vite: '^8.0.0',
|
|
733
|
+
},
|
|
734
|
+
}, null, 2)}\n`;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function tsconfigSource() {
|
|
738
|
+
return `${JSON.stringify({
|
|
739
|
+
compilerOptions: {
|
|
740
|
+
target: 'ES2022',
|
|
741
|
+
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
742
|
+
module: 'ESNext',
|
|
743
|
+
moduleResolution: 'Bundler',
|
|
744
|
+
jsx: 'react-jsx',
|
|
745
|
+
strict: true,
|
|
746
|
+
skipLibCheck: true,
|
|
747
|
+
noEmit: true,
|
|
748
|
+
types: ['vite/client', 'node'],
|
|
749
|
+
},
|
|
750
|
+
include: ['src', 'main', 'extensions.ts', 'vite.config.ts'],
|
|
751
|
+
}, null, 2)}\n`;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function tsconfigBuildSource() {
|
|
755
|
+
return `${JSON.stringify({
|
|
756
|
+
extends: './tsconfig.json',
|
|
757
|
+
compilerOptions: {
|
|
758
|
+
noEmit: false,
|
|
759
|
+
declaration: true,
|
|
760
|
+
emitDeclarationOnly: true,
|
|
761
|
+
outDir: 'dist/types',
|
|
762
|
+
rootDir: '.',
|
|
763
|
+
},
|
|
764
|
+
include: ['src', 'extensions.ts'],
|
|
765
|
+
}, null, 2)}\n`;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function viteConfigSource() {
|
|
769
|
+
return `import { fileURLToPath } from 'node:url';
|
|
770
|
+
import { defineConfig } from 'vite';
|
|
771
|
+
import { reactiveMd } from 'reactive-md/vite';
|
|
772
|
+
|
|
773
|
+
const root = fileURLToPath(new URL('./main', import.meta.url));
|
|
774
|
+
|
|
775
|
+
export default defineConfig({
|
|
776
|
+
root,
|
|
777
|
+
plugins: [reactiveMd()],
|
|
778
|
+
});
|
|
779
|
+
`;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** @param {{name: string, capabilities: string[]}} plan */
|
|
783
|
+
function htmlSource(plan) {
|
|
784
|
+
const title = `${pascalCase(plan.name)} preview`;
|
|
785
|
+
return `<!doctype html>
|
|
786
|
+
<html lang="en">
|
|
787
|
+
<head>
|
|
788
|
+
<meta charset="utf-8" />
|
|
789
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
790
|
+
<title>${title}</title>
|
|
791
|
+
</head>
|
|
792
|
+
<body>
|
|
793
|
+
<main id="reactive-md-document"></main>
|
|
794
|
+
<script type="module" src="./main.tsx"></script>
|
|
795
|
+
</body>
|
|
796
|
+
</html>
|
|
797
|
+
`;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/** @param {{name: string, capabilities: string[]}} plan */
|
|
801
|
+
function previewMainSource(plan) {
|
|
802
|
+
const mode = plan.capabilities.includes('interactive') ? 'interactive' : 'static';
|
|
803
|
+
return `import { createRoot } from 'react-dom/client';
|
|
804
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
805
|
+
import 'reactive-md/styles.css';
|
|
806
|
+
import { host } from 'virtual:reactive-md/host';
|
|
807
|
+
import sample from './sample.reactive.md?raw';
|
|
808
|
+
|
|
809
|
+
const target = document.getElementById('reactive-md-document');
|
|
810
|
+
if (!target) throw new Error('Missing #reactive-md-document.');
|
|
811
|
+
|
|
812
|
+
const mode: 'interactive' | 'static' = '${mode}';
|
|
813
|
+
|
|
814
|
+
createRoot(target).render(
|
|
815
|
+
<LocalReactiveDocument source={sample} reactConfig={host.reactConfig} mode={mode} />,
|
|
816
|
+
);
|
|
817
|
+
`;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/** @param {{name: string, form: string, props: Record<string, any>}} plan */
|
|
821
|
+
function sampleDocumentSource(plan) {
|
|
822
|
+
return `# ${pascalCase(plan.name)} preview
|
|
823
|
+
|
|
824
|
+
This preview serves ${'`'}main/sample.reactive.md${'`'} through the Vite plugin.
|
|
825
|
+
The component below is discovered in ${'`'}main/plugin/${plan.name}/index.ts${'`'}.
|
|
826
|
+
|
|
827
|
+
${previewSource(plan)}
|
|
828
|
+
`;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/** @param {{name: string}} plan */
|
|
832
|
+
function buildScriptSource(plan) {
|
|
833
|
+
return `import { spawnSync } from 'node:child_process';
|
|
834
|
+
import { readFile, rm } from 'node:fs/promises';
|
|
835
|
+
import path from 'node:path';
|
|
836
|
+
import { fileURLToPath } from 'node:url';
|
|
837
|
+
import { build } from 'vite';
|
|
838
|
+
|
|
839
|
+
const root = path.resolve(fileURLToPath(new URL('..', import.meta.url)));
|
|
840
|
+
const dist = path.join(root, 'dist');
|
|
841
|
+
const external = [/^reactive-md(?:\\/|$)/, /^react(?:\\/|$)/, /^react-dom(?:\\/|$)/];
|
|
842
|
+
|
|
843
|
+
if (!path.isAbsolute(dist) || path.relative(root, dist) !== 'dist') throw new Error('Invalid build output directory.');
|
|
844
|
+
await rm(dist, { recursive: true, force: true });
|
|
845
|
+
await build({
|
|
846
|
+
root,
|
|
847
|
+
configFile: false,
|
|
848
|
+
logLevel: 'warn',
|
|
849
|
+
oxc: { jsx: { development: false } },
|
|
850
|
+
build: {
|
|
851
|
+
outDir: path.join(dist, 'node'),
|
|
852
|
+
emptyOutDir: true,
|
|
853
|
+
target: 'es2022',
|
|
854
|
+
sourcemap: false,
|
|
855
|
+
lib: {
|
|
856
|
+
entry: {
|
|
857
|
+
manifest: path.join(root, 'src', 'manifest.ts'),
|
|
858
|
+
react: path.join(root, 'src', '${plan.name}.tsx'),
|
|
859
|
+
host: path.join(root, 'extensions.ts'),
|
|
860
|
+
},
|
|
861
|
+
formats: ['es'],
|
|
862
|
+
fileName: (_format, entryName) => \`\${entryName}.js\`,
|
|
863
|
+
},
|
|
864
|
+
rollupOptions: { external },
|
|
865
|
+
},
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
const typescriptUrl = import.meta.resolve('typescript/package.json');
|
|
869
|
+
const typescript = JSON.parse(await readFile(fileURLToPath(typescriptUrl), 'utf8'));
|
|
870
|
+
const tsc = spawnSync(process.execPath, [
|
|
871
|
+
fileURLToPath(new URL(typescript.bin.tsc, typescriptUrl)),
|
|
872
|
+
'--project',
|
|
873
|
+
path.join(root, 'tsconfig.build.json'),
|
|
874
|
+
], { cwd: root, stdio: 'inherit', windowsHide: true });
|
|
875
|
+
if (tsc.status !== 0) {
|
|
876
|
+
throw new Error('TypeScript declaration generation failed.');
|
|
877
|
+
}
|
|
878
|
+
console.log('Built dist/node and dist/types.');
|
|
879
|
+
`;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/** @param {{name: string, form: string, props: Record<string, any>, capabilities: string[]}} plan */
|
|
883
|
+
function verifyScriptSource(plan) {
|
|
884
|
+
return `import { createLocalComplianceReport, runLocalManifestCompliance } from 'reactive-md/testing';
|
|
885
|
+
import { runLocalReactCompliance } from 'reactive-md/testing/react';
|
|
886
|
+
import { manifest } from '../dist/node/manifest.js';
|
|
887
|
+
import { host } from '../dist/node/host.js';
|
|
888
|
+
|
|
889
|
+
const component = ${JSON.stringify(plan.name)};
|
|
890
|
+
const source = ${JSON.stringify(previewSource(plan))};
|
|
891
|
+
|
|
892
|
+
const manifestSuite = runLocalManifestCompliance(manifest);
|
|
893
|
+
const reactSuite = runLocalReactCompliance({
|
|
894
|
+
config: host.config,
|
|
895
|
+
reactConfig: host.reactConfig,
|
|
896
|
+
resources: host.resources,
|
|
897
|
+
component,
|
|
898
|
+
spec: {
|
|
899
|
+
protocol: 'reactive-md-react-spec/v1',
|
|
900
|
+
source,
|
|
901
|
+
staticMarkupIncludes: [${JSON.stringify(`data-${plan.name}`)}],
|
|
902
|
+
ssrMarkupIncludes: [${JSON.stringify(`data-${plan.name}`)}],
|
|
903
|
+
},
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
const declared = host.config.components[0]?.capabilities ?? {};
|
|
907
|
+
const nodeCapabilities = ['static', 'ssr'].filter((name) => declared[name] === true);
|
|
908
|
+
const report = createLocalComplianceReport({
|
|
909
|
+
config: host.config,
|
|
910
|
+
component,
|
|
911
|
+
suites: [manifestSuite, reactSuite],
|
|
912
|
+
capabilities: nodeCapabilities,
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
console.log(\`\${component}: passed=\${report.summary.passed} failed=\${report.summary.failed} skipped=\${report.summary.skipped} unsupported=\${report.summary.unsupported}\`);
|
|
916
|
+
for (const diagnostic of report.diagnostics) {
|
|
917
|
+
console.error(\`[\${diagnostic.code}] \${diagnostic.message}\`);
|
|
918
|
+
}
|
|
919
|
+
if (!report.ok) process.exit(1);
|
|
920
|
+
if (nodeCapabilities.length === 0) {
|
|
921
|
+
console.log('No static or SSR capability is declared. Interactive and offline evidence needs a browser run.');
|
|
922
|
+
} else {
|
|
923
|
+
console.log(\`Node and SSR compliance passed for: \${nodeCapabilities.join(', ')}.\`);
|
|
924
|
+
}
|
|
925
|
+
`;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/** @param {{name: string, form: string, props: Record<string, any>, capabilities: string[], id: string}} plan */
|
|
929
|
+
function componentExportScriptSource(plan) {
|
|
930
|
+
return `import path from 'node:path';
|
|
931
|
+
import { fileURLToPath } from 'node:url';
|
|
932
|
+
import { build } from 'vite';
|
|
933
|
+
import { reactiveMd } from 'reactive-md/vite';
|
|
934
|
+
|
|
935
|
+
// The preview build is the package export: the Vite plugin writes
|
|
936
|
+
// main/dist/reactive-md-export.json together with the standalone runtime.
|
|
937
|
+
const root = path.resolve(fileURLToPath(new URL('../main', import.meta.url)));
|
|
938
|
+
|
|
939
|
+
await build({ root, configFile: false, plugins: [reactiveMd()] });
|
|
940
|
+
console.log('Exported ${plan.name} preview assets through the public Vite API.');
|
|
941
|
+
`;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/** @param {{name: string, form: string, props: Record<string, any>, capabilities: string[], id: string}} plan */
|
|
945
|
+
function readmeSource(plan) {
|
|
946
|
+
const tag = sampleTag(plan);
|
|
947
|
+
return `# ${pascalCase(plan.name)} Reactive MD component
|
|
948
|
+
|
|
949
|
+
A minimal component package scaffolded by \`reactive-md init component\`.
|
|
950
|
+
|
|
951
|
+
## Edit these files
|
|
952
|
+
|
|
953
|
+
- \`src/manifest.ts\` - pure data: id, tag name, form, props and capabilities.
|
|
954
|
+
- \`src/${plan.name}.tsx\` - the React view passed to \`defineReactComponentPackage\`.
|
|
955
|
+
- \`src/${plan.name}.css\` - component styles, scoped under \`.local-document\`.
|
|
956
|
+
|
|
957
|
+
The preview discovers the component through \`main/plugin/${plan.name}/index.ts\`.\n\nThe remaining files are build plumbing: \`extensions.ts\`, \`vite.config.ts\`,
|
|
958
|
+
\`main/\`, \`scripts/\`, \`tsconfig.json\` and \`package.json\`. Change them when the
|
|
959
|
+
package layout or preview entry needs to move.
|
|
960
|
+
|
|
961
|
+
## Buttons
|
|
962
|
+
|
|
963
|
+
Buttons inside the document use the theme controls by default. A plain native
|
|
964
|
+
button renders as the secondary variant:
|
|
965
|
+
|
|
966
|
+
\`\`\`html
|
|
967
|
+
<button type="button">Action</button>
|
|
968
|
+
\`\`\`
|
|
969
|
+
|
|
970
|
+
Add a semantic class to choose another variant. \`md-button-primary\`,
|
|
971
|
+
\`md-button-secondary\` and \`md-button-quiet\` work on their own; the older
|
|
972
|
+
\`md-button\` class stays compatible and can sit beside a variant:
|
|
973
|
+
|
|
974
|
+
\`\`\`html
|
|
975
|
+
<button type="button" class="md-button-primary">Primary</button>
|
|
976
|
+
\`\`\`
|
|
977
|
+
|
|
978
|
+
Component CSS overrides the properties it declares. Other properties keep the
|
|
979
|
+
theme, regardless of stylesheet order:
|
|
980
|
+
|
|
981
|
+
\`\`\`css
|
|
982
|
+
.local-document .${plan.name}-action {
|
|
983
|
+
min-width: 8rem;
|
|
984
|
+
}
|
|
985
|
+
\`\`\`
|
|
986
|
+
|
|
987
|
+
Set \`data-rmd-appearance="custom"\` to opt one element out of the shared button
|
|
988
|
+
skin. Its component then owns all interaction states. The element keeps theme
|
|
989
|
+
variables such as \`--accent\`, \`--surface\` and \`--ink\`:
|
|
990
|
+
|
|
991
|
+
\`\`\`html
|
|
992
|
+
<button type="button" data-rmd-appearance="custom">Custom</button>
|
|
993
|
+
\`\`\`
|
|
994
|
+
|
|
995
|
+
Native buttons outside \`.md-document\` are not styled.
|
|
996
|
+
|
|
997
|
+
## Native controls
|
|
998
|
+
|
|
999
|
+
Native fields inside \`.md-document\` use the theme without extra classes:
|
|
1000
|
+
|
|
1001
|
+
\`\`\`html
|
|
1002
|
+
<span class="md-field">
|
|
1003
|
+
<label class="md-label" for="email">Email</label>
|
|
1004
|
+
<input id="email" type="email" placeholder="you@example.com" />
|
|
1005
|
+
<span class="md-hint">Used for receipts.</span>
|
|
1006
|
+
</span>
|
|
1007
|
+
\`\`\`
|
|
1008
|
+
|
|
1009
|
+
\`textarea\`, single and multiple \`select\`, checkbox, radio, range, progress and
|
|
1010
|
+
meter use the same skin. A native checkbox shows switch appearance with
|
|
1011
|
+
\`class="md-switch"\` or \`role="switch"\`. Native date and time pickers, number
|
|
1012
|
+
spinners and select arrows stay available. Use native \`disabled\` and
|
|
1013
|
+
\`readonly\` on fields; read-only fields stay focusable and disabled fields keep
|
|
1014
|
+
the disabled appearance.
|
|
1015
|
+
|
|
1016
|
+
Cards, badges and other public UI share the theme too:
|
|
1017
|
+
|
|
1018
|
+
\`\`\`html
|
|
1019
|
+
<div class="md-card">
|
|
1020
|
+
<h3 class="md-card-title">Build status</h3>
|
|
1021
|
+
<div class="md-card-body">
|
|
1022
|
+
<p>The latest export succeeded.</p>
|
|
1023
|
+
<span class="md-badge md-badge-success">Passing</span>
|
|
1024
|
+
</div>
|
|
1025
|
+
</div>
|
|
1026
|
+
\`\`\`
|
|
1027
|
+
|
|
1028
|
+
Shared classes provide appearance. Behavior, ARIA, focus order and positioning
|
|
1029
|
+
stay with your component or page. \`data-rmd-appearance="custom"\` opts one
|
|
1030
|
+
element out of the shared skin and keeps the theme variables available. Set
|
|
1031
|
+
\`data-rmd-density="compact"\` or \`"comfortable"\` on the document root or a
|
|
1032
|
+
subtree to resize controls and table cells.
|
|
1033
|
+
|
|
1034
|
+
### Inline components
|
|
1035
|
+
|
|
1036
|
+
An inline component renders inside a paragraph. Keep its markup to phrasing
|
|
1037
|
+
content: spans, labels, inputs and inline elements. Do not emit \`div\`, \`p\` or
|
|
1038
|
+
block containers; the field classes work on spans.
|
|
1039
|
+
|
|
1040
|
+
## Install
|
|
1041
|
+
|
|
1042
|
+
Reactive MD ${SCAFFOLD_ENGINE_VERSION} includes the extension SDK. Install the published package
|
|
1043
|
+
together with the React peers, then install the remaining development
|
|
1044
|
+
dependencies:
|
|
1045
|
+
|
|
1046
|
+
\`\`\`sh
|
|
1047
|
+
npm install reactive-md@${SCAFFOLD_ENGINE_VERSION} react@^19 react-dom@^19
|
|
1048
|
+
npm install
|
|
1049
|
+
\`\`\`
|
|
1050
|
+
|
|
1051
|
+
## Develop
|
|
1052
|
+
|
|
1053
|
+
\`\`\`sh
|
|
1054
|
+
npm run dev # preview served from main/index.html
|
|
1055
|
+
npm test # build, then run manifest and React/SSR compliance
|
|
1056
|
+
npm run build # dist/node entries and dist/types declarations
|
|
1057
|
+
npm run check # verify exports, config round-trip, registry and resources
|
|
1058
|
+
npm run export # preview build exported through the public Vite API
|
|
1059
|
+
npm run typecheck
|
|
1060
|
+
\`\`\`
|
|
1061
|
+
|
|
1062
|
+
The preview imports \`host\` from \`virtual:reactive-md/host\` and passes
|
|
1063
|
+
\`host.reactConfig\` to \`LocalReactiveDocument\`. The Vite plugin bundles the
|
|
1064
|
+
component, its CSS and its dependencies.
|
|
1065
|
+
|
|
1066
|
+
## Use in a document
|
|
1067
|
+
|
|
1068
|
+
\`\`\`md
|
|
1069
|
+
${tag}
|
|
1070
|
+
\`\`\`
|
|
1071
|
+
|
|
1072
|
+
## Package exports
|
|
1073
|
+
|
|
1074
|
+
- \`.\` - the pure-data manifest.
|
|
1075
|
+
- \`./react\` - the \`defineReactComponentPackage\` result with \`definition\`,
|
|
1076
|
+
\`components\` and \`resources\`.
|
|
1077
|
+
- \`./host\` - the \`createReactHost\` result.
|
|
1078
|
+
- \`./styles.css\` - the source stylesheet.
|
|
1079
|
+
|
|
1080
|
+
Declared capabilities: ${plan.capabilities.join(', ')}.
|
|
1081
|
+
|
|
1082
|
+
\`npm test\` proves static and SSR rendering in Node. Interactive and offline
|
|
1083
|
+
evidence needs a browser run; connect \`reactive-md/testing/browser\` in CI for
|
|
1084
|
+
that.
|
|
1085
|
+
`;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/** @param {{name: string, id: string, version: string}} plan */
|
|
1089
|
+
function presetSource(plan) {
|
|
1090
|
+
return `import { defineLocalPreset } from 'reactive-md/sdk';
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Pure semantic preset. Component declarations are ordinary manifests created
|
|
1094
|
+
* with defineLocalComponent; keep this entry free of React and CSS imports.
|
|
1095
|
+
*/
|
|
1096
|
+
/** @type {import('reactive-md/sdk').LocalPresetPackage} */
|
|
1097
|
+
export const preset = defineLocalPreset({
|
|
1098
|
+
protocol: '${SCAFFOLD_PRESET_PROTOCOL}',
|
|
1099
|
+
id: ${JSON.stringify(plan.id)},
|
|
1100
|
+
version: ${JSON.stringify(plan.version)},
|
|
1101
|
+
components: [],
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
export default preset;
|
|
1105
|
+
`;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
function presetDeclarationSource() {
|
|
1109
|
+
return `import type { LocalPresetPackage } from 'reactive-md/sdk';
|
|
1110
|
+
|
|
1111
|
+
export declare const preset: LocalPresetPackage;
|
|
1112
|
+
export default preset;
|
|
1113
|
+
`;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/** @param {{name: string}} plan */
|
|
1117
|
+
function reactPresetSource(plan) {
|
|
1118
|
+
return `import { defineReactPreset } from 'reactive-md/react';
|
|
1119
|
+
import preset from './preset.js';
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* React implementations paired with the semantic preset by manifest identity.
|
|
1123
|
+
* Add one defineReactComponent result per preset component.
|
|
1124
|
+
*/
|
|
1125
|
+
export const reactPreset = defineReactPreset({
|
|
1126
|
+
protocol: '${SCAFFOLD_REACT_PRESET_PROTOCOL}',
|
|
1127
|
+
preset,
|
|
1128
|
+
components: [],
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
export default reactPreset;
|
|
1132
|
+
`;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
function reactPresetDeclarationSource() {
|
|
1136
|
+
return `import type { LocalReactPresetPackage } from 'reactive-md/react';
|
|
1137
|
+
|
|
1138
|
+
export declare const reactPreset: LocalReactPresetPackage;
|
|
1139
|
+
export default reactPreset;
|
|
1140
|
+
`;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/** @param {{name: string, version: string}} plan */
|
|
1144
|
+
function presetPackageJsonSource(plan) {
|
|
1145
|
+
return `${JSON.stringify({
|
|
1146
|
+
name: `reactive-md-${plan.name}-preset`,
|
|
1147
|
+
version: plan.version,
|
|
1148
|
+
private: true,
|
|
1149
|
+
type: 'module',
|
|
1150
|
+
description: `A Reactive MD preset package for ${plan.name}.`,
|
|
1151
|
+
license: 'MIT',
|
|
1152
|
+
files: ['src', 'dist', 'README.md'],
|
|
1153
|
+
exports: {
|
|
1154
|
+
'.': {
|
|
1155
|
+
types: './src/preset.d.ts',
|
|
1156
|
+
import: './src/preset.js',
|
|
1157
|
+
},
|
|
1158
|
+
'./react': {
|
|
1159
|
+
types: './src/react.d.ts',
|
|
1160
|
+
import: './src/react.js',
|
|
1161
|
+
},
|
|
1162
|
+
'./package.json': './package.json',
|
|
1163
|
+
},
|
|
1164
|
+
scripts: {
|
|
1165
|
+
typecheck: 'tsc --noEmit',
|
|
1166
|
+
check: 'reactive-md check .',
|
|
1167
|
+
export: 'node scripts/build-export.mjs',
|
|
1168
|
+
},
|
|
1169
|
+
peerDependencies: {
|
|
1170
|
+
'reactive-md': `^${SCAFFOLD_ENGINE_VERSION}`,
|
|
1171
|
+
react: '^19.0.0',
|
|
1172
|
+
'react-dom': '^19.0.0',
|
|
1173
|
+
},
|
|
1174
|
+
devDependencies: {
|
|
1175
|
+
typescript: '^7.0.0',
|
|
1176
|
+
},
|
|
1177
|
+
}, null, 2)}\n`;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
function presetTsconfigSource() {
|
|
1181
|
+
return `${JSON.stringify({
|
|
1182
|
+
compilerOptions: {
|
|
1183
|
+
target: 'ES2022',
|
|
1184
|
+
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
1185
|
+
module: 'ESNext',
|
|
1186
|
+
moduleResolution: 'Bundler',
|
|
1187
|
+
strict: true,
|
|
1188
|
+
skipLibCheck: true,
|
|
1189
|
+
noEmit: true,
|
|
1190
|
+
allowJs: true,
|
|
1191
|
+
checkJs: true,
|
|
1192
|
+
},
|
|
1193
|
+
include: ['src'],
|
|
1194
|
+
}, null, 2)}\n`;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function presetExportScriptSource() {
|
|
1198
|
+
return `import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
1199
|
+
import path from 'node:path';
|
|
1200
|
+
import { fileURLToPath } from 'node:url';
|
|
1201
|
+
import { readLocalConfig } from 'reactive-md/sdk';
|
|
1202
|
+
import { createReactHost } from 'reactive-md/react';
|
|
1203
|
+
import reactPreset from '../src/react.js';
|
|
1204
|
+
|
|
1205
|
+
// Compose the public host APIs and write the export identity the package
|
|
1206
|
+
// advertises. No repository aliases or sibling source trees are used.
|
|
1207
|
+
const root = path.resolve(fileURLToPath(new URL('..', import.meta.url)));
|
|
1208
|
+
const packageInfo = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
|
|
1209
|
+
const host = createReactHost({ presets: [reactPreset] });
|
|
1210
|
+
const config = readLocalConfig(host.config);
|
|
1211
|
+
const report = {
|
|
1212
|
+
package: packageInfo.name,
|
|
1213
|
+
version: packageInfo.version,
|
|
1214
|
+
configKey: config.key,
|
|
1215
|
+
presets: config.presets.map(({ id, version }) => ({ id, version })),
|
|
1216
|
+
components: config.registry.map(({ id, name, version }) => ({ id, name, version })),
|
|
1217
|
+
resources: host.resources.map(({ id }) => id),
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
await mkdir(path.join(root, 'dist'), { recursive: true });
|
|
1221
|
+
await writeFile(path.join(root, 'dist', 'export.json'), \`\${JSON.stringify(report, null, 2)}\\n\`);
|
|
1222
|
+
console.log(\`Wrote dist/export.json (\${report.components.length} components, \${report.resources.length} resources).\`);
|
|
1223
|
+
`;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/** @param {{name: string, id: string, version: string}} plan */
|
|
1227
|
+
function presetReadmeSource(plan) {
|
|
1228
|
+
return `# ${pascalCase(plan.name)} Reactive MD preset
|
|
1229
|
+
|
|
1230
|
+
A minimal preset package scaffolded by \`reactive-md init preset\`.
|
|
1231
|
+
|
|
1232
|
+
## Edit these files
|
|
1233
|
+
|
|
1234
|
+
- \`src/preset.js\` - the semantic preset built with \`defineLocalPreset\`.
|
|
1235
|
+
Add \`defineLocalComponent\` manifests to \`components\`.
|
|
1236
|
+
- \`src/react.js\` - the React pairing built with \`defineReactPreset\`.
|
|
1237
|
+
Add one implementation per semantic component.
|
|
1238
|
+
- \`src/*.d.ts\` - declarations for both public entries.
|
|
1239
|
+
|
|
1240
|
+
Keep the semantic entry free of React and CSS imports so Node consumers can
|
|
1241
|
+
read the preset without a bundler.
|
|
1242
|
+
|
|
1243
|
+
## Commands
|
|
1244
|
+
|
|
1245
|
+
\`\`\`sh
|
|
1246
|
+
npm run typecheck
|
|
1247
|
+
npm run check # exports, config round-trip, registry and resources
|
|
1248
|
+
npm run export # dist/export.json through the public host APIs
|
|
1249
|
+
\`\`\`
|
|
1250
|
+
|
|
1251
|
+
\`npm run check\` loads the semantic entry and the React pairing, rebuilds the
|
|
1252
|
+
configuration, round-trips it through structuredClone and JSON, and verifies
|
|
1253
|
+
that every declared implementation and style resource is present. Browser
|
|
1254
|
+
evidence for interactive or offline capabilities still needs a separate run.
|
|
1255
|
+
|
|
1256
|
+
## Install
|
|
1257
|
+
|
|
1258
|
+
\`\`\`sh
|
|
1259
|
+
npm install reactive-md@${SCAFFOLD_ENGINE_VERSION} react@^19 react-dom@^19
|
|
1260
|
+
npm install
|
|
1261
|
+
\`\`\`
|
|
1262
|
+
|
|
1263
|
+
## Use in a host
|
|
1264
|
+
|
|
1265
|
+
\`\`\`ts
|
|
1266
|
+
import { createReactHost } from 'reactive-md/react';
|
|
1267
|
+
import { reactPreset } from './src/react.js';
|
|
1268
|
+
|
|
1269
|
+
export const host = createReactHost({ presets: [reactPreset] });
|
|
1270
|
+
\`\`\`
|
|
1271
|
+
|
|
1272
|
+
Preset id: \`${plan.id}\`. Version: \`${plan.version}\`.
|
|
1273
|
+
`;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* @param {{directory: string, name: string, id: string, version: string}} plan
|
|
1278
|
+
*/
|
|
1279
|
+
function renderPresetFiles(plan) {
|
|
1280
|
+
return [
|
|
1281
|
+
['.gitignore', 'node_modules/\ndist/\n*.tgz\n'],
|
|
1282
|
+
['package.json', presetPackageJsonSource(plan)],
|
|
1283
|
+
['README.md', presetReadmeSource(plan)],
|
|
1284
|
+
['tsconfig.json', presetTsconfigSource()],
|
|
1285
|
+
['src/preset.js', presetSource(plan)],
|
|
1286
|
+
['src/preset.d.ts', presetDeclarationSource()],
|
|
1287
|
+
['src/react.js', reactPresetSource(plan)],
|
|
1288
|
+
['src/react.d.ts', reactPresetDeclarationSource()],
|
|
1289
|
+
['scripts/build-export.mjs', presetExportScriptSource()],
|
|
1290
|
+
];
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* @param {{
|
|
1295
|
+
* directory: string, name: string, id: string, form: string,
|
|
1296
|
+
* props: Record<string, any>, capabilities: string[]
|
|
1297
|
+
* }} plan
|
|
1298
|
+
*/
|
|
1299
|
+
function renderFiles(plan) {
|
|
1300
|
+
const componentFile = `src/${plan.name}.tsx`;
|
|
1301
|
+
return [
|
|
1302
|
+
['.gitignore', 'node_modules/\ndist/\n.reactive-md/\n*.tgz\n'],
|
|
1303
|
+
['package.json', packageJsonSource(plan)],
|
|
1304
|
+
['README.md', readmeSource(plan)],
|
|
1305
|
+
['tsconfig.json', tsconfigSource()],
|
|
1306
|
+
['tsconfig.build.json', tsconfigBuildSource()],
|
|
1307
|
+
['vite.config.ts', viteConfigSource()],
|
|
1308
|
+
['extensions.ts', extensionsSource(plan)],
|
|
1309
|
+
[`main/plugin/${plan.name}/index.ts`, `export { componentPackage as default } from '../../../src/${plan.name}.js';\n`],
|
|
1310
|
+
['main/index.html', htmlSource(plan)],
|
|
1311
|
+
['main/main.tsx', previewMainSource(plan)],
|
|
1312
|
+
['main/sample.reactive.md', sampleDocumentSource(plan)],
|
|
1313
|
+
['src/manifest.ts', manifestSource(plan)],
|
|
1314
|
+
[componentFile, componentSource(plan)],
|
|
1315
|
+
[`src/${plan.name}.css`, cssSource(plan)],
|
|
1316
|
+
['src/env.d.ts', envSource()],
|
|
1317
|
+
['scripts/build.mjs', buildScriptSource(plan)],
|
|
1318
|
+
['scripts/verify.mjs', verifyScriptSource(plan)],
|
|
1319
|
+
['scripts/build-export.mjs', componentExportScriptSource(plan)],
|
|
1320
|
+
];
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Reject an existing target path before prompting or writing.
|
|
1325
|
+
*
|
|
1326
|
+
* @param {string} targetPath
|
|
1327
|
+
*/
|
|
1328
|
+
async function assertTargetAvailable(targetPath) {
|
|
1329
|
+
try {
|
|
1330
|
+
await stat(targetPath);
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
const code = error && typeof error === 'object' && 'code' in error ? error.code : null;
|
|
1333
|
+
if (code === 'ENOENT') return;
|
|
1334
|
+
throw fsFailure('Cannot inspect target path', targetPath, error, EXIT.IO);
|
|
1335
|
+
}
|
|
1336
|
+
throw usageError(`Refusing to overwrite existing path: "${targetPath}".`);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* @param {string[]} directories
|
|
1341
|
+
* @param {Record<string, any>} options
|
|
1342
|
+
* @param {{packageRoot: string, stdin?: NodeJS.ReadableStream, stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream}} context
|
|
1343
|
+
*/
|
|
1344
|
+
async function runInitPreset(directories, options, context) {
|
|
1345
|
+
for (const [option, value] of [
|
|
1346
|
+
['--form', options.form],
|
|
1347
|
+
['--props', options.props],
|
|
1348
|
+
['--capabilities', options.capabilities],
|
|
1349
|
+
]) {
|
|
1350
|
+
if (value !== undefined) {
|
|
1351
|
+
throw usageError(`Option "${option}" is only supported by "reactive-md init component".`);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
if (directories.length === 0) {
|
|
1355
|
+
throw usageError('Missing preset directory. Usage: reactive-md init preset <directory>.');
|
|
1356
|
+
}
|
|
1357
|
+
if (directories.length > 1) {
|
|
1358
|
+
throw usageError(`Expected one preset directory, received ${directories.length}.`);
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
const directory = requireText(directories[0], 'directory');
|
|
1362
|
+
const targetPath = path.resolve(directory);
|
|
1363
|
+
await assertTargetAvailable(targetPath);
|
|
1364
|
+
|
|
1365
|
+
const interactive = options.yes !== true && canPrompt(context);
|
|
1366
|
+
let reader;
|
|
1367
|
+
const ask = async (label, fallback) => {
|
|
1368
|
+
if (!reader) return fallback;
|
|
1369
|
+
const hint = fallback === undefined || fallback === '' ? '' : ` [${fallback}]`;
|
|
1370
|
+
const answer = (await reader.question(`${label}${hint}: `)).trim();
|
|
1371
|
+
return answer === '' ? fallback : answer;
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
let name;
|
|
1375
|
+
let id;
|
|
1376
|
+
let version = options.version;
|
|
1377
|
+
try {
|
|
1378
|
+
if (interactive) {
|
|
1379
|
+
reader = createInterface({ input: context.stdin ?? process.stdin, output: context.stdout });
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
if (options.name !== undefined) {
|
|
1383
|
+
name = requireText(options.name, '--name').trim();
|
|
1384
|
+
} else if (interactive) {
|
|
1385
|
+
name = await ask('Preset name', deriveComponentName(path.basename(targetPath)) ?? '');
|
|
1386
|
+
} else {
|
|
1387
|
+
name = deriveComponentName(path.basename(targetPath));
|
|
1388
|
+
}
|
|
1389
|
+
if (name === undefined || name === null || name === '') {
|
|
1390
|
+
throw usageError('Cannot derive a preset name from the directory. Pass "--name <name>".');
|
|
1391
|
+
}
|
|
1392
|
+
validatePresetName(name);
|
|
1393
|
+
|
|
1394
|
+
if (options.id !== undefined) {
|
|
1395
|
+
id = requireText(options.id, '--id').trim();
|
|
1396
|
+
} else if (interactive) {
|
|
1397
|
+
id = await ask('Preset id', `local/${name}`);
|
|
1398
|
+
} else {
|
|
1399
|
+
id = `local/${name}`;
|
|
1400
|
+
}
|
|
1401
|
+
validateId(id);
|
|
1402
|
+
|
|
1403
|
+
if (version === undefined) version = interactive ? await ask('Preset version', SCAFFOLD_PACKAGE_VERSION) : SCAFFOLD_PACKAGE_VERSION;
|
|
1404
|
+
} finally {
|
|
1405
|
+
reader?.close();
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
const presetVersion = validatePresetVersion(version);
|
|
1409
|
+
const plan = { directory: targetPath, name, id, version: presetVersion };
|
|
1410
|
+
|
|
1411
|
+
// Validate through the owning SDK before creating any directory so the
|
|
1412
|
+
// generated entries are registrable and round-trip cleanly.
|
|
1413
|
+
const { defineLocalPreset, createLocalConfig } = await import(new URL('../dist-library/reactive-md-sdk.js', import.meta.url).href);
|
|
1414
|
+
try {
|
|
1415
|
+
const preset = defineLocalPreset({
|
|
1416
|
+
protocol: SCAFFOLD_PRESET_PROTOCOL,
|
|
1417
|
+
id,
|
|
1418
|
+
version: presetVersion,
|
|
1419
|
+
components: [],
|
|
1420
|
+
});
|
|
1421
|
+
createLocalConfig({ presets: [preset] });
|
|
1422
|
+
} catch (error) {
|
|
1423
|
+
throw usageError(`Invalid preset: ${error instanceof Error ? error.message : String(error)}`);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
const files = renderPresetFiles(plan);
|
|
1427
|
+
files.push(['LICENSE', await readFile(path.join(context.packageRoot, 'LICENSE'), 'utf8')]);
|
|
1428
|
+
|
|
1429
|
+
try {
|
|
1430
|
+
await mkdir(path.dirname(targetPath), { recursive: true });
|
|
1431
|
+
await mkdir(targetPath);
|
|
1432
|
+
} catch (error) {
|
|
1433
|
+
throw fsFailure('Cannot create scaffold directory', targetPath, error, EXIT.IO);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
for (const [relative, content] of files) {
|
|
1437
|
+
const file = path.join(targetPath, ...relative.split('/'));
|
|
1438
|
+
try {
|
|
1439
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
1440
|
+
await writeFile(file, content, { encoding: 'utf8', flag: 'wx' });
|
|
1441
|
+
} catch (error) {
|
|
1442
|
+
throw fsFailure('Cannot write scaffold file', file, error, EXIT.IO);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
context.stdout.write(`Created preset scaffold "${name}" in "${targetPath}".\n`);
|
|
1447
|
+
context.stdout.write('Next: install the Reactive MD tarball, then run "npm run check".\n');
|
|
1448
|
+
return EXIT.OK;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* @param {string[]} argv
|
|
1453
|
+
* @param {{packageRoot?: string, stdin?: NodeJS.ReadableStream, stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream}} context
|
|
1454
|
+
*/
|
|
1455
|
+
export async function runInit(argv, context) {
|
|
1456
|
+
const { positionals, options } = parseInitOptions(argv);
|
|
1457
|
+
const locale = parseLocale(options.locale);
|
|
1458
|
+
if (options.help) {
|
|
1459
|
+
context.stdout.write(initHelp(locale));
|
|
1460
|
+
return EXIT.OK;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
if (positionals.length === 0) {
|
|
1464
|
+
throw usageError('Missing init target. Usage: reactive-md init <component|preset> <directory>.');
|
|
1465
|
+
}
|
|
1466
|
+
const [target, ...directories] = positionals;
|
|
1467
|
+
if (target === 'preset') {
|
|
1468
|
+
return runInitPreset(directories, options, context);
|
|
1469
|
+
}
|
|
1470
|
+
if (target !== 'component') {
|
|
1471
|
+
throw usageError(`Unknown init target "${target}". Usage: reactive-md init <component|preset> <directory>.`);
|
|
1472
|
+
}
|
|
1473
|
+
if (options.version !== undefined) {
|
|
1474
|
+
throw usageError('Option "--version" is only supported by "reactive-md init preset".');
|
|
1475
|
+
}
|
|
1476
|
+
if (directories.length === 0) {
|
|
1477
|
+
throw usageError('Missing component directory. Usage: reactive-md init component <directory>.');
|
|
1478
|
+
}
|
|
1479
|
+
if (directories.length > 1) {
|
|
1480
|
+
throw usageError(`Expected one component directory, received ${directories.length}.`);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
const directory = requireText(directories[0], 'directory');
|
|
1484
|
+
const targetPath = path.resolve(directory);
|
|
1485
|
+
await assertTargetAvailable(targetPath);
|
|
1486
|
+
|
|
1487
|
+
const interactive = options.yes !== true && canPrompt(context);
|
|
1488
|
+
let reader;
|
|
1489
|
+
const ask = async (label, fallback) => {
|
|
1490
|
+
if (!reader) return fallback;
|
|
1491
|
+
const hint = fallback === undefined || fallback === '' ? '' : ` [${fallback}]`;
|
|
1492
|
+
const answer = (await reader.question(`${label}${hint}: `)).trim();
|
|
1493
|
+
return answer === '' ? fallback : answer;
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1496
|
+
let name;
|
|
1497
|
+
let id;
|
|
1498
|
+
let form;
|
|
1499
|
+
let propsInput = options.props;
|
|
1500
|
+
let capabilitiesInput = options.capabilities;
|
|
1501
|
+
try {
|
|
1502
|
+
if (interactive) {
|
|
1503
|
+
reader = createInterface({ input: context.stdin ?? process.stdin, output: context.stdout });
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
if (options.name !== undefined) {
|
|
1507
|
+
name = requireText(options.name, '--name').trim();
|
|
1508
|
+
} else if (interactive) {
|
|
1509
|
+
name = await ask('Component tag name', deriveComponentName(path.basename(targetPath)) ?? '');
|
|
1510
|
+
} else {
|
|
1511
|
+
name = deriveComponentName(path.basename(targetPath));
|
|
1512
|
+
}
|
|
1513
|
+
if (name === undefined || name === null || name === '') {
|
|
1514
|
+
throw usageError('Cannot derive a component name from the directory. Pass "--name <tag>".');
|
|
1515
|
+
}
|
|
1516
|
+
validateName(name);
|
|
1517
|
+
|
|
1518
|
+
if (options.id !== undefined) {
|
|
1519
|
+
id = requireText(options.id, '--id').trim();
|
|
1520
|
+
} else if (interactive) {
|
|
1521
|
+
id = await ask('Component id', `local/${name}`);
|
|
1522
|
+
} else {
|
|
1523
|
+
id = `local/${name}`;
|
|
1524
|
+
}
|
|
1525
|
+
validateId(id);
|
|
1526
|
+
|
|
1527
|
+
if (options.form !== undefined) {
|
|
1528
|
+
form = validateForm(options.form);
|
|
1529
|
+
} else if (interactive) {
|
|
1530
|
+
form = validateForm(await ask('Component form (leaf, inline, container)', 'leaf'));
|
|
1531
|
+
} else {
|
|
1532
|
+
form = 'leaf';
|
|
1533
|
+
}
|
|
1534
|
+
if (interactive && propsInput === undefined) propsInput = await ask('Props JSON', '{}');
|
|
1535
|
+
if (interactive && capabilitiesInput === undefined) capabilitiesInput = await ask('Capabilities (comma separated)', CAPABILITY_ORDER.join(','));
|
|
1536
|
+
} finally {
|
|
1537
|
+
reader?.close();
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
const props = parseProps(propsInput !== undefined ? propsInput : '{}');
|
|
1541
|
+
const capabilities = parseCapabilities(
|
|
1542
|
+
capabilitiesInput !== undefined ? capabilitiesInput : CAPABILITY_ORDER.join(','),
|
|
1543
|
+
);
|
|
1544
|
+
|
|
1545
|
+
const plan = { directory: targetPath, name, id, form, props, capabilities };
|
|
1546
|
+
// Reuse the owning SDK contract, including built-in/HTML name collisions,
|
|
1547
|
+
// before creating any directory. The generated project must be registrable.
|
|
1548
|
+
const { defineLocalComponent, createLocalConfig } = await import(new URL('../dist-library/reactive-md-sdk.js', import.meta.url).href);
|
|
1549
|
+
try {
|
|
1550
|
+
const definition = defineLocalComponent({ id, name, version: SCAFFOLD_PACKAGE_VERSION, protocol: SCAFFOLD_COMPONENT_PROTOCOL,
|
|
1551
|
+
form, props, capabilities: Object.fromEntries(CAPABILITY_ORDER.map(key => [key, capabilities.includes(key)])) });
|
|
1552
|
+
createLocalConfig({ components: [definition] });
|
|
1553
|
+
} catch (error) { throw usageError(`Invalid component: ${error instanceof Error ? error.message : String(error)}`); }
|
|
1554
|
+
const files = renderFiles(plan);
|
|
1555
|
+
files.push(['LICENSE', await readFile(path.join(context.packageRoot, 'LICENSE'), 'utf8')]);
|
|
1556
|
+
|
|
1557
|
+
try {
|
|
1558
|
+
await mkdir(path.dirname(targetPath), { recursive: true });
|
|
1559
|
+
await mkdir(targetPath);
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
throw fsFailure('Cannot create scaffold directory', targetPath, error, EXIT.IO);
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
for (const [relative, content] of files) {
|
|
1565
|
+
const file = path.join(targetPath, ...relative.split('/'));
|
|
1566
|
+
try {
|
|
1567
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
1568
|
+
await writeFile(file, content, { encoding: 'utf8', flag: 'wx' });
|
|
1569
|
+
} catch (error) {
|
|
1570
|
+
throw fsFailure('Cannot write scaffold file', file, error, EXIT.IO);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
context.stdout.write(`Created component scaffold "${name}" in "${targetPath}".\n`);
|
|
1575
|
+
context.stdout.write('Next: install the Reactive MD tarball, then run "npm run dev".\n');
|
|
1576
|
+
return EXIT.OK;
|
|
1577
|
+
}
|