@ccslabs/xtend 0.1.0-rc.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +4 -0
- package/catalog/component-catalog-coverage.js +2 -0
- package/catalog/epic13-package-export-lock.js +11 -1
- package/catalog/epic13-rmt-production-readiness.js +0 -1
- package/catalog/epic18-rmt-action-effect-runtime.d.ts +36 -0
- package/catalog/epic18-rmt-action-effect-runtime.js +249 -0
- package/catalog/epic18-rmt-app-platform-authoring.d.ts +39 -0
- package/catalog/epic18-rmt-app-platform-authoring.js +319 -0
- package/catalog/epic18-rmt-app-platform-fixture.d.ts +33 -0
- package/catalog/epic18-rmt-app-platform-fixture.js +221 -0
- package/catalog/epic18-rmt-app-platform-release-handoff.d.ts +30 -0
- package/catalog/epic18-rmt-app-platform-release-handoff.js +231 -0
- package/catalog/epic18-rmt-app-platform-tooling.d.ts +38 -0
- package/catalog/epic18-rmt-app-platform-tooling.js +242 -0
- package/catalog/epic18-rmt-component-template-primitives.d.ts +33 -0
- package/catalog/epic18-rmt-component-template-primitives.js +240 -0
- package/catalog/epic18-rmt-dom-descriptor-renderer.d.ts +35 -0
- package/catalog/epic18-rmt-dom-descriptor-renderer.js +232 -0
- package/catalog/epic18-rmt-event-routing-runtime.d.ts +35 -0
- package/catalog/epic18-rmt-event-routing-runtime.js +234 -0
- package/catalog/epic18-rmt-state-selector-runtime.d.ts +34 -0
- package/catalog/epic18-rmt-state-selector-runtime.js +216 -0
- package/catalog/epic18-rmt-surface-resource-graph-runtime.d.ts +36 -0
- package/catalog/epic18-rmt-surface-resource-graph-runtime.js +256 -0
- package/catalog/surface-manager-controller.js +5 -1
- package/catalog/surface-manager-materialization.js +7 -1
- package/catalog/surface-manager-overlay-bridge.js +41 -6
- package/catalog/surface-manager-workbench-fixture.js +1 -1
- package/catalog/surface-type-capability-matrix.d.ts +61 -0
- package/catalog/surface-type-capability-matrix.js +183 -0
- package/catalog/type-exports-rmt.js +37 -1
- package/catalog/type-exports.js +3 -3
- package/components/icon-packs/lucide.js +4 -0
- package/components/manifest.json +2 -0
- package/components/prism-rmt.d.ts +34 -0
- package/components/prism-rmt.js +130 -0
- package/components/xcards.js +15 -0
- package/components/xcode.d.ts +36 -1
- package/components/xcode.js +215 -20
- package/components/xfooter.js +17 -0
- package/components/xheader.js +14 -0
- package/components/xhero.js +16 -1
- package/components/xlink.js +97 -14
- package/components/xmasonry.js +15 -0
- package/components/xplayer.d.ts +44 -2
- package/components/xplayer.js +242 -15
- package/components/xrouter.js +27 -2
- package/components/xsection.js +15 -0
- package/components/xsidepanel.js +10 -2
- package/components/xsurfacemanager-controller.d.ts +2 -1
- package/components/xsurfacemanager-controller.js +27 -3
- package/components/xsurfacemanager.d.ts +2 -0
- package/components/xsurfacemanager.js +20 -8
- package/components/xsurfaceoverlay-bridge.d.ts +20 -5
- package/components/xsurfaceoverlay-bridge.js +114 -18
- package/components/xsurfaceportal.d.ts +29 -0
- package/components/xsurfaceportal.js +122 -0
- package/components/xsurfaceregion.d.ts +50 -0
- package/components/xsurfaceregion.js +285 -0
- package/components/xsurfacewindow.js +2 -1
- package/components/xtooltip.js +89 -23
- package/docs/README.md +222 -298
- package/docs/changelog.md +107 -0
- package/docs/component-catalog-coverage.md +9 -9
- package/docs/component-platform.md +19 -1
- package/docs/component-ux-app-authoring.md +56 -63
- package/docs/components/xcode.md +83 -53
- package/docs/components/xsurfaceportal.md +32 -0
- package/docs/components/xsurfaceregion.md +37 -0
- package/docs/components.md +105 -69
- package/docs/de/README.md +264 -0
- package/docs/de/XTend-ADR.md +221 -0
- package/docs/de/a11y-keyboard-smokes.md +62 -0
- package/docs/de/about.md +18 -0
- package/docs/de/api.md +157 -0
- package/docs/de/best-practices.md +76 -0
- package/docs/de/changelog.md +107 -0
- package/docs/de/component-catalog-coverage.md +58 -0
- package/docs/de/component-lab.md +103 -0
- package/docs/de/component-long-tail-migration.md +41 -0
- package/docs/de/component-platform.md +177 -0
- package/docs/de/component-ux-app-authoring.md +123 -0
- package/docs/de/component-ux-authoring.md +96 -0
- package/docs/de/component-ux-gates.md +45 -0
- package/docs/de/components/x-rmt-lifecycle-demo-build.md +60 -0
- package/docs/de/components/xalert.md +81 -0
- package/docs/de/components/xbutton.md +103 -0
- package/docs/de/components/xcalendar.md +82 -0
- package/docs/de/components/xcards.md +128 -0
- package/docs/de/components/xcheckbox.md +102 -0
- package/docs/de/components/xcode.md +156 -0
- package/docs/de/components/xdialog.md +92 -0
- package/docs/de/components/xdrawer.md +84 -0
- package/docs/de/components/xfooter.md +126 -0
- package/docs/de/components/xform.md +128 -0
- package/docs/de/components/xheader.md +308 -0
- package/docs/de/components/xhero.md +142 -0
- package/docs/de/components/xicon.md +125 -0
- package/docs/de/components/xinput.md +129 -0
- package/docs/de/components/xlightbox.md +98 -0
- package/docs/de/components/xlink.md +109 -0
- package/docs/de/components/xmasonry.md +124 -0
- package/docs/de/components/xmenu.md +158 -0
- package/docs/de/components/xmodal.md +82 -0
- package/docs/de/components/xplayer.md +104 -0
- package/docs/de/components/xpopover.md +67 -0
- package/docs/de/components/xprogress.md +56 -0
- package/docs/de/components/xradio.md +103 -0
- package/docs/de/components/xrouter.md +260 -0
- package/docs/de/components/xsection.md +125 -0
- package/docs/de/components/xselect.md +105 -0
- package/docs/de/components/xsidepanel.md +30 -0
- package/docs/de/components/xspinner.md +102 -0
- package/docs/de/components/xstate.md +148 -0
- package/docs/de/components/xstatus.md +55 -0
- package/docs/de/components/xsummary.md +78 -0
- package/docs/de/components/xsurfacemanager.md +27 -0
- package/docs/de/components/xsurfacewindow.md +21 -0
- package/docs/de/components/xtabs.md +160 -0
- package/docs/de/components/xtextarea.md +98 -0
- package/docs/de/components/xtheme.md +167 -0
- package/docs/de/components/xtoast.md +62 -0
- package/docs/de/components/xtooltip.md +66 -0
- package/docs/de/components/xtype.md +82 -0
- package/docs/de/components/xutils.md +144 -0
- package/docs/de/components/xwriter.md +94 -0
- package/docs/de/components.md +153 -0
- package/docs/de/conditional-network-evidence-ci.md +38 -0
- package/docs/de/conditional-network-evidence.md +50 -0
- package/docs/de/core-migration-guide.md +110 -0
- package/docs/de/design-tokens.md +116 -0
- package/docs/de/docs-rmt-production-hardening.md +31 -0
- package/docs/de/enterprise-adoption.md +413 -0
- package/docs/de/enterprise-component-flex-release-handoff.md +129 -0
- package/docs/de/epic10-platform-gates.md +62 -0
- package/docs/de/epic10-release-handoff.md +81 -0
- package/docs/de/epic11-enterprise-ux-handoff.md +70 -0
- package/docs/de/epic12-rc0-handoff.md +61 -0
- package/docs/de/epic18-media-manager-vendor-upstream.md +318 -0
- package/docs/de/epic18-rmt-app-platform-release-handoff.md +67 -0
- package/docs/de/epic18-vendor-bugfixes.md +34 -0
- package/docs/de/existing-component-metadata.md +67 -0
- package/docs/de/hydration-performance-closure.md +34 -0
- package/docs/de/hydration-policies.md +71 -0
- package/docs/de/known-residual-triage.md +22 -0
- package/docs/de/manifest-import-policy.md +79 -0
- package/docs/de/manifest.md +112 -0
- package/docs/de/motion-contrast.md +67 -0
- package/docs/de/package-export-lock.md +44 -0
- package/docs/de/performance-measurements.md +106 -0
- package/docs/de/performance-regression.md +89 -0
- package/docs/de/performance.md +94 -0
- package/docs/de/previews/README.md +17 -0
- package/docs/de/prod-browser-csp-smokes.md +40 -0
- package/docs/de/public-component-types.md +79 -0
- package/docs/de/quick-start-guide.md +220 -0
- package/docs/de/rc0-adoption-guide.md +102 -0
- package/docs/de/rc0-gate-matrix.md +58 -0
- package/docs/de/rc1-gate-matrix-ci-handoff.md +56 -0
- package/docs/de/rc1-migration-notes.md +69 -0
- package/docs/de/rc1-readiness.md +46 -0
- package/docs/de/release-owner-acceptance.md +56 -0
- package/docs/de/release-report-pack-dry-run-evidence.md +39 -0
- package/docs/de/rmt-action-effect-runtime.md +81 -0
- package/docs/de/rmt-app-platform-authoring.md +54 -0
- package/docs/de/rmt-app-platform-fixture.md +46 -0
- package/docs/de/rmt-app-platform-migration-guide.md +88 -0
- package/docs/de/rmt-app-platform-tooling.md +79 -0
- package/docs/de/rmt-component-template-primitives.md +57 -0
- package/docs/de/rmt-dom-descriptor-renderer.md +64 -0
- package/docs/de/rmt-dsl-authoring-polish.md +145 -0
- package/docs/de/rmt-event-routing-runtime.md +81 -0
- package/docs/de/rmt-first-demo-app.md +77 -0
- package/docs/de/rmt-first-xtend-apps.md +129 -0
- package/docs/de/rmt-kernel-panic-recovery-incident-handoff.md +61 -0
- package/docs/de/rmt-kernel-security-hardening-migration.md +50 -0
- package/docs/de/rmt-kernel-trusted-output-authoring.md +69 -0
- package/docs/de/rmt-language-server.md +234 -0
- package/docs/de/rmt-lifecycle-demo.md +24 -0
- package/docs/de/rmt-linter.md +140 -0
- package/docs/de/rmt-node-ssr-adapter.md +100 -0
- package/docs/de/rmt-php-ssr-adapter.md +120 -0
- package/docs/de/rmt-production-readiness.md +63 -0
- package/docs/de/rmt-state-selector-runtime.md +47 -0
- package/docs/de/rmt-surface-resource-graph-runtime.md +92 -0
- package/docs/de/rmt-tooling-release-gates.md +77 -0
- package/docs/de/rmt-vnext-authoring.md +170 -0
- package/docs/de/rmt-vnext-component-primitives.md +188 -0
- package/docs/de/rmt-vnext-cross-surface-events.md +68 -0
- package/docs/de/rmt-vnext-enterprise-mfe-handoff.md +70 -0
- package/docs/de/rmt-vnext-fabric-bridge-evidence.md +81 -0
- package/docs/de/rmt-vnext-migration-notes.md +62 -0
- package/docs/de/rmt-vnext-primitive-authoring-tooling.md +247 -0
- package/docs/de/rmt-vnext-primitive-grammar-design.md +289 -0
- package/docs/de/rmt-vnext-primitive-lowering.md +108 -0
- package/docs/de/rmt-vnext-primitive-migration.md +119 -0
- package/docs/de/rmt-vnext-primitive-parser-ast.md +76 -0
- package/docs/de/rmt-vnext-primitive-semantic-graph.md +118 -0
- package/docs/de/rmt-vnext-primitives-compiler-backlog.md +739 -0
- package/docs/de/rmt-vnext-release-handoff.md +83 -0
- package/docs/de/rmt-vnext-remote-surfaces.md +90 -0
- package/docs/de/rmt-vnext-source-to-sea-gate.md +612 -0
- package/docs/de/rmt-vnext-surface-registry-enterprise.md +76 -0
- package/docs/de/screenreader-signals.md +56 -0
- package/docs/de/supply-chain-gates.md +100 -0
- package/docs/de/surface-manager-authoring-guide.md +94 -0
- package/docs/de/surface-manager-browser-lab.md +45 -0
- package/docs/de/surface-manager-component-lab.md +43 -0
- package/docs/de/surface-manager-controller.md +66 -0
- package/docs/de/surface-manager-layout-engines.md +32 -0
- package/docs/de/surface-manager-lazy-hydration.md +63 -0
- package/docs/de/surface-manager-migration-guide.md +122 -0
- package/docs/de/surface-manager-native-rmt-surfaces.md +38 -0
- package/docs/de/surface-manager-overlay-bridge.md +53 -0
- package/docs/de/surface-manager-persistence.md +30 -0
- package/docs/de/surface-manager-quality-gates.md +51 -0
- package/docs/de/surface-manager-release-handoff.md +68 -0
- package/docs/de/surface-manager-remote-policy.md +54 -0
- package/docs/de/surface-manager-rmt-authoring.md +102 -0
- package/docs/de/surface-manager-route-lifecycle.md +59 -0
- package/docs/de/surface-manager-runtime-release-handoff.md +69 -0
- package/docs/de/surface-manager-side-panel-runtime.md +36 -0
- package/docs/de/surface-manager-stack-policy.md +39 -0
- package/docs/de/surface-manager-window-runtime.md +47 -0
- package/docs/de/surface-manager-workbench-fixture.md +43 -0
- package/docs/de/third-party-design-authoring.md +406 -0
- package/docs/de/trusted-dom-boundary-browser-proof.md +32 -0
- package/docs/de/trusted-dom-sanitizing.md +110 -0
- package/docs/de/type-exports.md +61 -0
- package/docs/de/typescript-components.md +63 -0
- package/docs/de/visual-browser-regression.md +83 -0
- package/docs/de/visual-owner-artifacts.md +46 -0
- package/docs/de/visual-snapshot-automation.md +87 -0
- package/docs/de/xtend-api-types.md +55 -0
- package/docs/de/xtend-builder-types.md +55 -0
- package/docs/de/xtend-catalog-types.md +44 -0
- package/docs/de/xtend-fabric-rmt-lane-mapping.md +143 -0
- package/docs/de/xtend-fabric.md +474 -0
- package/docs/de/xtend-loader-types.md +58 -0
- package/docs/de/xtend-loader.md +265 -0
- package/docs/de/xtend-policy-types.md +38 -0
- package/docs/de/xtend-rmt-types.md +40 -0
- package/docs/de/xtend-vendor-types.md +36 -0
- package/docs/de/xtendrmt-app-dsl.md +334 -0
- package/docs/de/xtendrmt-migration-guide.md +266 -0
- package/docs/de/xtendrmt-native-authoring.md +333 -0
- package/docs/de/xtendrmt-overview.md +109 -0
- package/docs/de/xtendrmt-parsedown-scheduling.md +301 -0
- package/docs/de/xtendrmt-runtime-bridge.md +155 -0
- package/docs/en/README.md +163 -0
- package/docs/en/XTend-ADR.md +221 -0
- package/docs/en/a11y-keyboard-smokes.md +68 -0
- package/docs/en/about.md +25 -0
- package/docs/en/api.md +171 -0
- package/docs/en/best-practices.md +125 -0
- package/docs/en/changelog.md +104 -0
- package/docs/en/component-catalog-coverage.md +104 -0
- package/docs/en/component-lab.md +103 -0
- package/docs/en/component-long-tail-migration.md +41 -0
- package/docs/en/component-platform.md +243 -0
- package/docs/en/component-ux-app-authoring.md +118 -0
- package/docs/en/component-ux-authoring.md +96 -0
- package/docs/en/component-ux-gates.md +45 -0
- package/docs/en/components/x-rmt-lifecycle-demo-build.md +75 -0
- package/docs/en/components/xalert.md +94 -0
- package/docs/en/components/xbutton.md +118 -0
- package/docs/en/components/xcalendar.md +95 -0
- package/docs/en/components/xcards.md +139 -0
- package/docs/en/components/xcheckbox.md +118 -0
- package/docs/en/components/xcode.md +153 -0
- package/docs/en/components/xdialog.md +108 -0
- package/docs/en/components/xdrawer.md +110 -0
- package/docs/en/components/xfooter.md +138 -0
- package/docs/en/components/xform.md +147 -0
- package/docs/en/components/xheader.md +308 -0
- package/docs/en/components/xhero.md +157 -0
- package/docs/en/components/xicon.md +149 -0
- package/docs/en/components/xinput.md +147 -0
- package/docs/en/components/xlightbox.md +113 -0
- package/docs/en/components/xlink.md +130 -0
- package/docs/en/components/xmasonry.md +136 -0
- package/docs/en/components/xmenu.md +185 -0
- package/docs/en/components/xmodal.md +102 -0
- package/docs/en/components/xplayer.md +114 -0
- package/docs/en/components/xpopover.md +87 -0
- package/docs/en/components/xprogress.md +73 -0
- package/docs/en/components/xradio.md +119 -0
- package/docs/en/components/xrouter.md +260 -0
- package/docs/en/components/xsection.md +136 -0
- package/docs/en/components/xselect.md +122 -0
- package/docs/en/components/xsidepanel.md +48 -0
- package/docs/en/components/xspinner.md +118 -0
- package/docs/en/components/xstate.md +163 -0
- package/docs/en/components/xstatus.md +71 -0
- package/docs/en/components/xsummary.md +90 -0
- package/docs/en/components/xsurfacemanager.md +42 -0
- package/docs/en/components/xsurfacewindow.md +31 -0
- package/docs/en/components/xtabs.md +187 -0
- package/docs/en/components/xtextarea.md +115 -0
- package/docs/en/components/xtheme.md +203 -0
- package/docs/en/components/xtoast.md +78 -0
- package/docs/en/components/xtooltip.md +85 -0
- package/docs/en/components/xtype.md +91 -0
- package/docs/en/components/xutils.md +161 -0
- package/docs/en/components/xwriter.md +106 -0
- package/docs/en/components.md +151 -0
- package/docs/en/conditional-network-evidence-ci.md +38 -0
- package/docs/en/conditional-network-evidence.md +50 -0
- package/docs/en/core-migration-guide.md +110 -0
- package/docs/en/design-tokens.md +137 -0
- package/docs/en/docs-rmt-production-hardening.md +31 -0
- package/docs/en/enterprise-adoption.md +413 -0
- package/docs/en/enterprise-component-flex-release-handoff.md +129 -0
- package/docs/en/epic10-platform-gates.md +62 -0
- package/docs/en/epic10-release-handoff.md +81 -0
- package/docs/en/epic11-enterprise-ux-handoff.md +70 -0
- package/docs/en/epic12-rc0-handoff.md +61 -0
- package/docs/en/epic18-media-manager-vendor-upstream.md +232 -0
- package/docs/en/epic18-rmt-app-platform-release-handoff.md +60 -0
- package/docs/en/epic18-vendor-bugfixes.md +29 -0
- package/docs/en/existing-component-metadata.md +67 -0
- package/docs/en/hydration-performance-closure.md +34 -0
- package/docs/en/hydration-policies.md +75 -0
- package/docs/en/known-residual-triage.md +22 -0
- package/docs/en/manifest-import-policy.md +81 -0
- package/docs/en/manifest.md +135 -0
- package/docs/en/motion-contrast.md +67 -0
- package/docs/en/package-export-lock.md +44 -0
- package/docs/en/performance-measurements.md +106 -0
- package/docs/en/performance-regression.md +89 -0
- package/docs/en/performance.md +132 -0
- package/docs/en/previews/README.md +17 -0
- package/docs/en/prod-browser-csp-smokes.md +40 -0
- package/docs/en/public-component-types.md +79 -0
- package/docs/en/quick-start-guide.md +189 -0
- package/docs/en/rc0-adoption-guide.md +102 -0
- package/docs/en/rc0-gate-matrix.md +58 -0
- package/docs/en/rc1-gate-matrix-ci-handoff.md +56 -0
- package/docs/en/rc1-migration-notes.md +69 -0
- package/docs/en/rc1-readiness.md +46 -0
- package/docs/en/release-owner-acceptance.md +56 -0
- package/docs/en/release-report-pack-dry-run-evidence.md +39 -0
- package/docs/en/rmt-action-effect-runtime.md +101 -0
- package/docs/en/rmt-app-platform-authoring.md +47 -0
- package/docs/en/rmt-app-platform-fixture.md +35 -0
- package/docs/en/rmt-app-platform-migration-guide.md +75 -0
- package/docs/en/rmt-app-platform-tooling.md +58 -0
- package/docs/en/rmt-component-template-primitives.md +49 -0
- package/docs/en/rmt-dom-descriptor-renderer.md +54 -0
- package/docs/en/rmt-dsl-authoring-polish.md +143 -0
- package/docs/en/rmt-event-routing-runtime.md +98 -0
- package/docs/en/rmt-first-demo-app.md +87 -0
- package/docs/en/rmt-first-xtend-apps.md +127 -0
- package/docs/en/rmt-kernel-panic-recovery-incident-handoff.md +60 -0
- package/docs/en/rmt-kernel-security-hardening-migration.md +49 -0
- package/docs/en/rmt-kernel-trusted-output-authoring.md +68 -0
- package/docs/en/rmt-language-server.md +243 -0
- package/docs/en/rmt-lifecycle-demo.md +23 -0
- package/docs/en/rmt-linter.md +146 -0
- package/docs/en/rmt-node-ssr-adapter.md +99 -0
- package/docs/en/rmt-php-ssr-adapter.md +118 -0
- package/docs/en/rmt-production-readiness.md +63 -0
- package/docs/en/rmt-state-selector-runtime.md +34 -0
- package/docs/en/rmt-surface-resource-graph-runtime.md +68 -0
- package/docs/en/rmt-tooling-release-gates.md +77 -0
- package/docs/en/rmt-vnext-authoring.md +102 -0
- package/docs/en/rmt-vnext-component-primitives.md +185 -0
- package/docs/en/rmt-vnext-cross-surface-events.md +59 -0
- package/docs/en/rmt-vnext-enterprise-mfe-handoff.md +62 -0
- package/docs/en/rmt-vnext-fabric-bridge-evidence.md +64 -0
- package/docs/en/rmt-vnext-migration-notes.md +62 -0
- package/docs/en/rmt-vnext-primitive-authoring-tooling.md +174 -0
- package/docs/en/rmt-vnext-primitive-grammar-design.md +268 -0
- package/docs/en/rmt-vnext-primitive-lowering.md +91 -0
- package/docs/en/rmt-vnext-primitive-migration.md +93 -0
- package/docs/en/rmt-vnext-primitive-parser-ast.md +59 -0
- package/docs/en/rmt-vnext-primitive-semantic-graph.md +103 -0
- package/docs/en/rmt-vnext-primitives-compiler-backlog.md +327 -0
- package/docs/en/rmt-vnext-release-handoff.md +83 -0
- package/docs/en/rmt-vnext-remote-surfaces.md +81 -0
- package/docs/en/rmt-vnext-source-to-sea-gate.md +482 -0
- package/docs/en/rmt-vnext-surface-registry-enterprise.md +68 -0
- package/docs/en/screenreader-signals.md +56 -0
- package/docs/en/supply-chain-gates.md +106 -0
- package/docs/en/surface-manager-authoring-guide.md +94 -0
- package/docs/en/surface-manager-browser-lab.md +45 -0
- package/docs/en/surface-manager-component-lab.md +43 -0
- package/docs/en/surface-manager-controller.md +66 -0
- package/docs/en/surface-manager-layout-engines.md +32 -0
- package/docs/en/surface-manager-lazy-hydration.md +63 -0
- package/docs/en/surface-manager-migration-guide.md +113 -0
- package/docs/en/surface-manager-native-rmt-surfaces.md +38 -0
- package/docs/en/surface-manager-overlay-bridge.md +53 -0
- package/docs/en/surface-manager-persistence.md +30 -0
- package/docs/en/surface-manager-quality-gates.md +51 -0
- package/docs/en/surface-manager-release-handoff.md +68 -0
- package/docs/en/surface-manager-remote-policy.md +54 -0
- package/docs/en/surface-manager-rmt-authoring.md +89 -0
- package/docs/en/surface-manager-route-lifecycle.md +59 -0
- package/docs/en/surface-manager-runtime-release-handoff.md +69 -0
- package/docs/en/surface-manager-side-panel-runtime.md +36 -0
- package/docs/en/surface-manager-stack-policy.md +39 -0
- package/docs/en/surface-manager-window-runtime.md +47 -0
- package/docs/en/surface-manager-workbench-fixture.md +43 -0
- package/docs/en/third-party-design-authoring.md +406 -0
- package/docs/en/trusted-dom-boundary-browser-proof.md +32 -0
- package/docs/en/trusted-dom-sanitizing.md +124 -0
- package/docs/en/type-exports.md +61 -0
- package/docs/en/typescript-components.md +63 -0
- package/docs/en/visual-browser-regression.md +83 -0
- package/docs/en/visual-owner-artifacts.md +46 -0
- package/docs/en/visual-snapshot-automation.md +87 -0
- package/docs/en/xtend-api-types.md +55 -0
- package/docs/en/xtend-builder-types.md +55 -0
- package/docs/en/xtend-catalog-types.md +44 -0
- package/docs/en/xtend-fabric-rmt-lane-mapping.md +143 -0
- package/docs/en/xtend-fabric.md +474 -0
- package/docs/en/xtend-loader-types.md +58 -0
- package/docs/en/xtend-loader.md +265 -0
- package/docs/en/xtend-policy-types.md +38 -0
- package/docs/en/xtend-rmt-types.md +40 -0
- package/docs/en/xtend-vendor-types.md +36 -0
- package/docs/en/xtendrmt-app-dsl.md +331 -0
- package/docs/en/xtendrmt-migration-guide.md +256 -0
- package/docs/en/xtendrmt-native-authoring.md +336 -0
- package/docs/en/xtendrmt-overview.md +63 -0
- package/docs/en/xtendrmt-parsedown-scheduling.md +301 -0
- package/docs/en/xtendrmt-runtime-bridge.md +155 -0
- package/docs/enterprise-adoption.md +4 -2
- package/docs/epic18-media-manager-vendor-upstream.md +318 -0
- package/docs/epic18-rmt-app-platform-release-handoff.md +67 -0
- package/docs/epic18-vendor-bugfixes.md +34 -0
- package/docs/index.php +1056 -109
- package/docs/manifest.md +8 -2
- package/docs/menu.json +986 -133
- package/docs/package-export-lock.md +2 -2
- package/docs/public-component-types.md +2 -2
- package/docs/quick-start-guide.md +126 -58
- package/docs/rmt-action-effect-runtime.md +101 -0
- package/docs/rmt-app-platform-authoring.md +54 -0
- package/docs/rmt-app-platform-fixture.md +46 -0
- package/docs/rmt-app-platform-migration-guide.md +88 -0
- package/docs/rmt-app-platform-tooling.md +79 -0
- package/docs/rmt-component-template-primitives.md +57 -0
- package/docs/rmt-dom-descriptor-renderer.md +64 -0
- package/docs/rmt-dsl-authoring-polish.md +67 -44
- package/docs/rmt-event-routing-runtime.md +98 -0
- package/docs/rmt-first-demo-app.md +2 -2
- package/docs/rmt-first-xtend-apps.md +70 -46
- package/docs/rmt-language-server.md +61 -4
- package/docs/rmt-lifecycle-demo.md +1 -2
- package/docs/rmt-node-ssr-adapter.md +144 -0
- package/docs/rmt-php-ssr-adapter.md +158 -0
- package/docs/rmt-state-selector-runtime.md +47 -0
- package/docs/rmt-surface-resource-graph-runtime.md +92 -0
- package/docs/rmt-vnext-authoring.md +128 -18
- package/docs/rmt-vnext-component-primitives.md +188 -0
- package/docs/rmt-vnext-fabric-bridge-evidence.md +81 -0
- package/docs/rmt-vnext-primitive-authoring-tooling.md +247 -0
- package/docs/rmt-vnext-primitive-grammar-design.md +289 -0
- package/docs/rmt-vnext-primitive-lowering.md +108 -0
- package/docs/rmt-vnext-primitive-migration.md +119 -0
- package/docs/rmt-vnext-primitive-parser-ast.md +76 -0
- package/docs/rmt-vnext-primitive-semantic-graph.md +118 -0
- package/docs/rmt-vnext-primitives-compiler-backlog.md +742 -0
- package/docs/rmt-vnext-release-handoff.md +14 -0
- package/docs/rmt-vnext-source-to-sea-gate.md +629 -0
- package/docs/surface-manager-migration-guide.md +34 -6
- package/docs/surface-manager-overlay-bridge.md +9 -4
- package/docs/surface-manager-rmt-authoring.md +50 -34
- package/docs/surface-manager-workbench-fixture.md +1 -2
- package/docs/third-party-design-authoring.md +1 -1
- package/docs/type-exports.md +3 -3
- package/docs/utils/pageloader.js +811 -62
- package/docs/visual-browser-regression.md +1 -1
- package/docs/xtend-rmt-types.md +3 -2
- package/docs/xtendrmt-app-dsl.md +187 -122
- package/docs/xtendrmt-docs-shell-vnext.rmt +165 -0
- package/docs/xtendrmt-migration-guide.md +48 -17
- package/docs/xtendrmt-native-authoring.md +213 -217
- package/docs/xtendrmt-overview.md +81 -61
- package/docs/xtendrmt-parsedown-scheduling.md +23 -8
- package/fabric/package.json +1 -1
- package/package.json +684 -21
- package/tools/package.json +5 -1
- package/tools/rmt-editor/vscode/README.md +72 -5
- package/tools/rmt-editor/vscode/XTend-Logo.png +0 -0
- package/tools/rmt-editor/vscode/extension.d.ts +33 -0
- package/tools/rmt-editor/vscode/extension.js +1816 -7
- package/tools/rmt-editor/vscode/language-configuration.json +2 -1
- package/tools/rmt-editor/vscode/package.json +193 -2
- package/tools/rmt-editor/vscode/snippets/rmt.code-snippets +41 -0
- package/tools/rmt-editor/vscode/syntaxes/rmt.tmLanguage.json +103 -1
- package/tools/rmt-editor/vscode/templates/launch.json +70 -0
- package/tools/rmt-editor/vscode/templates/tasks.json +172 -0
- package/tools/rmt-editor/vscode/xtend-rmt-language-0.0.0-enterprise-readiness.vsix +0 -0
- package/tools/rmt-language/app-platform-tooling.d.ts +128 -0
- package/tools/rmt-language/app-platform-tooling.js +677 -0
- package/tools/rmt-language/completions.d.ts +5 -0
- package/tools/rmt-language/completions.js +185 -3
- package/tools/rmt-language/diagnostics.js +54 -0
- package/tools/rmt-language/hover.js +36 -0
- package/tools/rmt-language/rmt-tooling-public-types.d.ts +7 -0
- package/tools/rmt-language/rules/app-platform-policy.js +39 -0
- package/tools/rmt-language/rules/index.js +5 -1
- package/tools/rmt-language/semantic-graph.d.ts +6 -0
- package/tools/rmt-language/semantic-graph.js +928 -0
- package/tools/rmt-language/snippets/index.js +44 -0
- package/tools/rmt-language/snippets/rmt.code-snippets +41 -0
- package/tools/rmt-language/vnext-compatibility.d.ts +10 -0
- package/tools/rmt-language/vnext-compatibility.js +642 -0
- package/tools/rmt-language/vnext-compiler.d.ts +5 -0
- package/tools/rmt-language/vnext-compiler.js +863 -17
- package/tools/rmt-language/vnext-parser.js +725 -9
- package/tools/rmt-language/vnext-release.d.ts +1 -0
- package/tools/rmt-language/vnext-release.js +20 -0
- package/tools/rmt-language/vnext-source-to-sea.d.ts +33 -0
- package/tools/rmt-language/vnext-source-to-sea.js +2227 -0
- package/tools/rmt-language/vnext-surfaces.js +111 -52
- package/tools/rmt-language/vnext-tooling.d.ts +19 -1
- package/tools/rmt-language/vnext-tooling.js +1247 -5
- package/tools/rmt-language-server/protocol.js +3 -0
- package/tools/rmt-language-server/server.d.ts +2 -0
- package/tools/rmt-language-server/server.js +176 -22
- package/tools/rmt-linter/cli.d.ts +2 -0
- package/tools/rmt-linter/cli.js +62 -0
- package/xtend-builder/generators/registry.js +11 -0
- package/xtend-builder/generators/rmt-app-platform.js +239 -0
- package/xtend-builder/generators/rmt-lifecycle-demo.js +3 -11
- package/xtend-builder/lib/cli.js +38 -0
- package/xtend-builder/package.json +3 -3
- package/xtend-builder/scaffold.config.js +29 -2
- package/xtend.css +49 -2
- package/xtendrmt/package.json +49 -1
- package/xtendrmt/rmt-action-effect-runtime.d.ts +126 -0
- package/xtendrmt/rmt-action-effect-runtime.js +494 -0
- package/xtendrmt/rmt-component-capability-registry.d.ts +180 -0
- package/xtendrmt/rmt-component-capability-registry.js +636 -0
- package/xtendrmt/rmt-core.d.ts +6 -0
- package/xtendrmt/rmt-core.esm.js +32 -6
- package/xtendrmt/rmt-dom-descriptor-renderer.d.ts +107 -0
- package/xtendrmt/rmt-dom-descriptor-renderer.js +1066 -0
- package/xtendrmt/rmt-event-routing-runtime.d.ts +144 -0
- package/xtendrmt/rmt-event-routing-runtime.js +666 -0
- package/xtendrmt/rmt-lifecycle-demo.app.js +2 -2
- package/xtendrmt/rmt-lifecycle-demo.core.json +4 -0
- package/xtendrmt/rmt-lifecycle-demo.rmt-build.app.js +1 -1
- package/xtendrmt/rmt-lifecycle-demo.rmt-build.scaffold.json +2 -2
- package/xtendrmt/rmt-lifecycle-demo.scaffold.json +4 -4
- package/xtendrmt/rmt-native-shell-runtime.d.ts +77 -0
- package/xtendrmt/rmt-native-shell-runtime.js +309 -0
- package/xtendrmt/rmt-node-ssr-adapter.d.ts +197 -0
- package/xtendrmt/rmt-node-ssr-adapter.js +1006 -0
- package/xtendrmt/rmt-php-ssr-adapter.php +976 -0
- package/xtendrmt/rmt-runtime.browser.js +32 -6
- package/xtendrmt/rmt-runtime.esm.js +32 -6
- package/xtendrmt/rmt-state-selector-runtime.d.ts +166 -0
- package/xtendrmt/rmt-state-selector-runtime.js +866 -0
- package/xtendrmt/rmt-surface-resource-graph-runtime.d.ts +224 -0
- package/xtendrmt/rmt-surface-resource-graph-runtime.js +932 -0
- package/xtendrmt/rmt-vnext-enterprise-mfe-demo.core.json +3 -0
- package/xtendrmt/rmt-vnext-reference-demo.core.json +3 -0
- package/xtendrmt/xtendrmt-bestcase-demo.core.json +3420 -372
- package/xtendrmt/xtendrmt-bestcase-demo.js +424 -8
- package/xtendrmt/xtendrmt-bestcase-demo.rmt +214 -6
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
declare(strict_types=1);
|
|
3
|
+
|
|
4
|
+
if (!defined('RMT_PHP_SSR_ADAPTER_SCHEMA')) {
|
|
5
|
+
define('RMT_PHP_SSR_ADAPTER_SCHEMA', 'xtend.rmt.php-ssr-adapter.v1');
|
|
6
|
+
define('RMT_PHP_SSR_RENDER_RESULT_SCHEMA', 'xtend.rmt.node-ssr-render-result.v1');
|
|
7
|
+
define('RMT_PHP_SSR_JSONL_FRAME_SCHEMA', 'xtend.rmt.node-ssr-jsonl-frame.v1');
|
|
8
|
+
define('RMT_PHP_SSR_HYDRATION_SCHEMA', 'xtend.rmt.node-ssr-hydration-payload.v1');
|
|
9
|
+
define('RMT_PHP_SSR_DIAGNOSTIC_SCHEMA', 'xtend.rmt.php-ssr-diagnostic.v1');
|
|
10
|
+
define('RMT_PHP_SSR_CHUNK_KIND', 'renderman_template_chunk');
|
|
11
|
+
define('RMT_PHP_SSR_RESPONSE_KIND', 'renderman_template_prerender_response');
|
|
12
|
+
define('RMT_PHP_SSR_EXECUTION_MODE', 'server_prerender_hydrate');
|
|
13
|
+
define('RMT_PHP_SSR_STREAMING_CONTRACT_SCHEMA', 'xtend.rmt.vnext-streaming-contract.v1');
|
|
14
|
+
define('RMT_PHP_SSR_KERNEL_BOUNDARY', 'no-rmt-kernel-import-of-xtend-types');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!class_exists('RmtPhpSsrAdapter', false)) {
|
|
18
|
+
final class RmtPhpSsrAdapter
|
|
19
|
+
{
|
|
20
|
+
private array $options;
|
|
21
|
+
|
|
22
|
+
private array $voidTags = [
|
|
23
|
+
'area' => true,
|
|
24
|
+
'base' => true,
|
|
25
|
+
'br' => true,
|
|
26
|
+
'col' => true,
|
|
27
|
+
'embed' => true,
|
|
28
|
+
'hr' => true,
|
|
29
|
+
'img' => true,
|
|
30
|
+
'input' => true,
|
|
31
|
+
'link' => true,
|
|
32
|
+
'meta' => true,
|
|
33
|
+
'param' => true,
|
|
34
|
+
'source' => true,
|
|
35
|
+
'track' => true,
|
|
36
|
+
'wbr' => true,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
private array $blockedTags = [
|
|
40
|
+
'script' => true,
|
|
41
|
+
'iframe' => true,
|
|
42
|
+
'frame' => true,
|
|
43
|
+
'frameset' => true,
|
|
44
|
+
'object' => true,
|
|
45
|
+
'embed' => true,
|
|
46
|
+
'base' => true,
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
private array $urlAttributes = [
|
|
50
|
+
'href' => true,
|
|
51
|
+
'src' => true,
|
|
52
|
+
'action' => true,
|
|
53
|
+
'formaction' => true,
|
|
54
|
+
'poster' => true,
|
|
55
|
+
'xlink:href' => true,
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
private array $trustBoundaryTokens = [
|
|
59
|
+
'xtend.security.trusted-dom-boundary.v1' => true,
|
|
60
|
+
'xtend.security.sanitizing-boundary.v1' => true,
|
|
61
|
+
'xtend.security.streaming-boundary.v1' => true,
|
|
62
|
+
'trusted' => true,
|
|
63
|
+
'sanitized' => true,
|
|
64
|
+
'host-sanitized' => true,
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
public function __construct(array $options = [])
|
|
68
|
+
{
|
|
69
|
+
$this->options = $options;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public function render($input, array $options = []): array
|
|
73
|
+
{
|
|
74
|
+
$mergedOptions = array_replace($this->options, $options);
|
|
75
|
+
$diagnostics = [];
|
|
76
|
+
$normalized = $this->normalizeRenderInput($input, $mergedOptions, $diagnostics);
|
|
77
|
+
$requestId = $this->safeIdentifier($mergedOptions['requestId'] ?? $mergedOptions['operationId'] ?? ('rmt-php-ssr-' . time()));
|
|
78
|
+
$rootId = $this->safeIdentifier($mergedOptions['rootId'] ?? 'rmt-php-ssr-root');
|
|
79
|
+
$componentCapabilities = [];
|
|
80
|
+
$html = $this->serializeDescriptor($normalized['descriptor'], [
|
|
81
|
+
'options' => $mergedOptions,
|
|
82
|
+
'componentCapabilities' => &$componentCapabilities,
|
|
83
|
+
'source' => [
|
|
84
|
+
'inputKind' => $normalized['kind'],
|
|
85
|
+
'sourceRef' => $normalized['sourceRef'] ?? null,
|
|
86
|
+
],
|
|
87
|
+
], $diagnostics);
|
|
88
|
+
$streamingContract = $this->createStreamingContract($normalized['coreDocument'] ?? null);
|
|
89
|
+
$hydration = [
|
|
90
|
+
'schema' => RMT_PHP_SSR_HYDRATION_SCHEMA,
|
|
91
|
+
'requestId' => $requestId,
|
|
92
|
+
'executionMode' => RMT_PHP_SSR_EXECUTION_MODE,
|
|
93
|
+
'sourceKind' => $normalized['kind'],
|
|
94
|
+
'sourceRef' => $normalized['sourceRef'] ?? null,
|
|
95
|
+
'componentCapabilities' => array_values($componentCapabilities),
|
|
96
|
+
'coreDocumentSchema' => $normalized['coreDocument']['schema'] ?? null,
|
|
97
|
+
'streamingContractSchema' => $streamingContract['schema'] ?? null,
|
|
98
|
+
];
|
|
99
|
+
$chunk = $this->createChunk([
|
|
100
|
+
'requestId' => $requestId,
|
|
101
|
+
'rootId' => $rootId,
|
|
102
|
+
'options' => $mergedOptions,
|
|
103
|
+
'coreDocument' => $normalized['coreDocument'] ?? null,
|
|
104
|
+
'renderedAt' => $mergedOptions['renderedAt'] ?? gmdate('c'),
|
|
105
|
+
'model' => $mergedOptions['model'] ?? [],
|
|
106
|
+
], $html, $normalized['descriptor'], $hydration);
|
|
107
|
+
$ok = !$this->hasBlockingDiagnostics($diagnostics);
|
|
108
|
+
|
|
109
|
+
return [
|
|
110
|
+
'schema' => RMT_PHP_SSR_RENDER_RESULT_SCHEMA,
|
|
111
|
+
'adapterSchema' => RMT_PHP_SSR_ADAPTER_SCHEMA,
|
|
112
|
+
'ok' => $ok,
|
|
113
|
+
'status' => $ok ? 'rendered' : 'blocked',
|
|
114
|
+
'requestId' => $requestId,
|
|
115
|
+
'html' => $html,
|
|
116
|
+
'head' => [
|
|
117
|
+
'preloads' => $this->collectPreloads($html),
|
|
118
|
+
'hints' => [[
|
|
119
|
+
'rel' => 'xtend-rmt-hydration',
|
|
120
|
+
'schema' => RMT_PHP_SSR_HYDRATION_SCHEMA,
|
|
121
|
+
]],
|
|
122
|
+
],
|
|
123
|
+
'chunks' => [$chunk],
|
|
124
|
+
'response' => [
|
|
125
|
+
'kind' => RMT_PHP_SSR_RESPONSE_KIND,
|
|
126
|
+
'version' => '1.0',
|
|
127
|
+
'executionMode' => RMT_PHP_SSR_EXECUTION_MODE,
|
|
128
|
+
'rootId' => $rootId,
|
|
129
|
+
'chunks' => [$chunk],
|
|
130
|
+
'hydration' => $hydration,
|
|
131
|
+
'diagnostics' => $diagnostics,
|
|
132
|
+
],
|
|
133
|
+
'hydration' => $hydration,
|
|
134
|
+
'streamingContract' => $streamingContract,
|
|
135
|
+
'componentCapabilities' => array_values($componentCapabilities),
|
|
136
|
+
'fabricTelemetryHints' => [
|
|
137
|
+
'schema' => 'xtend.rmt.php-ssr-fabric-telemetry-hints.v1',
|
|
138
|
+
'lanes' => $this->listLanes($normalized['coreDocument'] ?? null),
|
|
139
|
+
'kernelBoundary' => RMT_PHP_SSR_KERNEL_BOUNDARY,
|
|
140
|
+
'transport' => 'php-ssr',
|
|
141
|
+
],
|
|
142
|
+
'diagnostics' => $diagnostics,
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public function streamJsonl($input, array $options = []): Generator
|
|
147
|
+
{
|
|
148
|
+
$renderResult = $this->render($input, array_replace($options, ['streamMode' => true]));
|
|
149
|
+
$sequence = 0;
|
|
150
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'start', [
|
|
151
|
+
'payload' => [
|
|
152
|
+
'adapterSchema' => RMT_PHP_SSR_ADAPTER_SCHEMA,
|
|
153
|
+
'streamingContractSchema' => $renderResult['streamingContract']['schema'] ?? RMT_PHP_SSR_STREAMING_CONTRACT_SCHEMA,
|
|
154
|
+
],
|
|
155
|
+
]);
|
|
156
|
+
foreach ($renderResult['diagnostics'] as $diagnostic) {
|
|
157
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'diagnostic', [
|
|
158
|
+
'payload' => ['code' => $diagnostic['code'] ?? 'rmt.php_ssr.diagnostic'],
|
|
159
|
+
'diagnostics' => [$diagnostic],
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
if (!$renderResult['ok']) {
|
|
163
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'error', [
|
|
164
|
+
'payload' => [
|
|
165
|
+
'status' => $renderResult['status'],
|
|
166
|
+
'code' => $this->firstDiagnosticCode($renderResult['diagnostics']),
|
|
167
|
+
],
|
|
168
|
+
'diagnostics' => $renderResult['diagnostics'],
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
foreach ($renderResult['componentCapabilities'] as $capability) {
|
|
172
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'component', [
|
|
173
|
+
'capability' => $capability['tag'] ?? null,
|
|
174
|
+
'payload' => $capability,
|
|
175
|
+
]);
|
|
176
|
+
}
|
|
177
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'html', [
|
|
178
|
+
'variant' => 'ssr',
|
|
179
|
+
'capability' => 'stream.ssr.incremental',
|
|
180
|
+
'lane' => 'server-prerender',
|
|
181
|
+
'chunkKey' => $renderResult['chunks'][0]['template']['qualifiedId'] ?? null,
|
|
182
|
+
'payload' => ['html' => $renderResult['html']],
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
foreach (($renderResult['streamingContract']['streams'] ?? []) as $operation) {
|
|
186
|
+
$record = $operation['dataSource'] ?? null;
|
|
187
|
+
if (!$record) continue;
|
|
188
|
+
$diagnostics = [];
|
|
189
|
+
$payload = $this->normalizeStreamPayload($this->resolveDataSource($record, $operation, $options, $diagnostics));
|
|
190
|
+
foreach ($diagnostics as $diagnostic) {
|
|
191
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'diagnostic', [
|
|
192
|
+
'operationId' => $operation['operationId'] ?? $operation['id'] ?? null,
|
|
193
|
+
'variant' => $operation['variant'] ?? null,
|
|
194
|
+
'capability' => $operation['capability'] ?? null,
|
|
195
|
+
'payload' => ['code' => $diagnostic['code'] ?? 'rmt.php_ssr.diagnostic'],
|
|
196
|
+
'diagnostics' => [$diagnostic],
|
|
197
|
+
]);
|
|
198
|
+
if (in_array($diagnostic['severity'] ?? '', ['error', 'fatal'], true)) {
|
|
199
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'error', [
|
|
200
|
+
'operationId' => $operation['operationId'] ?? $operation['id'] ?? null,
|
|
201
|
+
'variant' => $operation['variant'] ?? null,
|
|
202
|
+
'capability' => $operation['capability'] ?? null,
|
|
203
|
+
'payload' => [
|
|
204
|
+
'code' => $diagnostic['code'] ?? 'rmt.php_ssr.diagnostic',
|
|
205
|
+
'status' => 'blocked',
|
|
206
|
+
],
|
|
207
|
+
'diagnostics' => [$diagnostic],
|
|
208
|
+
]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (array_key_exists('html', $payload)) {
|
|
212
|
+
$htmlDiagnostics = [];
|
|
213
|
+
$html = $this->sanitizeHtmlFragment((string) $payload['html'], [
|
|
214
|
+
'descriptor' => [
|
|
215
|
+
'trustBoundary' => $payload['trustBoundary'] ?? ($record['trustBoundary'] ?? ($operation['security']['boundaryIds'] ?? ($options['defaultTrustBoundary'] ?? null))),
|
|
216
|
+
],
|
|
217
|
+
'operationId' => $operation['operationId'] ?? null,
|
|
218
|
+
], array_replace($this->options, $options), $htmlDiagnostics);
|
|
219
|
+
foreach ($htmlDiagnostics as $diagnostic) {
|
|
220
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'diagnostic', [
|
|
221
|
+
'operationId' => $operation['operationId'] ?? $operation['id'] ?? null,
|
|
222
|
+
'variant' => $operation['variant'] ?? null,
|
|
223
|
+
'capability' => $operation['capability'] ?? null,
|
|
224
|
+
'payload' => ['code' => $diagnostic['code'] ?? 'rmt.php_ssr.diagnostic'],
|
|
225
|
+
'diagnostics' => [$diagnostic],
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'html', [
|
|
229
|
+
'operationId' => $operation['operationId'] ?? $operation['id'] ?? null,
|
|
230
|
+
'variant' => $operation['variant'] ?? null,
|
|
231
|
+
'capability' => $operation['capability'] ?? null,
|
|
232
|
+
'lane' => $operation['lane'] ?? null,
|
|
233
|
+
'chunkKey' => $operation['chunkKey'] ?? ($operation['operationId'] ?? null),
|
|
234
|
+
'payload' => [
|
|
235
|
+
'html' => $html,
|
|
236
|
+
'dataSourceId' => $record['id'] ?? null,
|
|
237
|
+
],
|
|
238
|
+
]);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'hydration', [
|
|
243
|
+
'variant' => 'hydration',
|
|
244
|
+
'capability' => 'stream.hydration.chunked',
|
|
245
|
+
'lane' => 'client-hydrate',
|
|
246
|
+
'chunkKey' => $renderResult['chunks'][0]['template']['qualifiedId'] ?? null,
|
|
247
|
+
'payload' => $renderResult['hydration'],
|
|
248
|
+
]);
|
|
249
|
+
yield $this->jsonlFrame($sequence, $renderResult['requestId'], 'complete', [
|
|
250
|
+
'payload' => [
|
|
251
|
+
'ok' => $renderResult['ok'],
|
|
252
|
+
'status' => $renderResult['status'],
|
|
253
|
+
'diagnostics' => count($renderResult['diagnostics']),
|
|
254
|
+
],
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public function toLaravelResponse($input, array $options = [])
|
|
259
|
+
{
|
|
260
|
+
$result = $this->isRenderResult($input) ? $input : $this->render($input, $options);
|
|
261
|
+
$headers = array_replace([
|
|
262
|
+
'Content-Type' => 'text/html; charset=UTF-8',
|
|
263
|
+
'X-XTend-RMT-SSR-Adapter' => RMT_PHP_SSR_ADAPTER_SCHEMA,
|
|
264
|
+
], $options['headers'] ?? []);
|
|
265
|
+
if (class_exists('\\Illuminate\\Http\\Response')) {
|
|
266
|
+
return new \Illuminate\Http\Response($result['html'], $options['status'] ?? 200, $headers);
|
|
267
|
+
}
|
|
268
|
+
if (class_exists('\\Symfony\\Component\\HttpFoundation\\Response')) {
|
|
269
|
+
return new \Symfony\Component\HttpFoundation\Response($result['html'], $options['status'] ?? 200, $headers);
|
|
270
|
+
}
|
|
271
|
+
return [
|
|
272
|
+
'status' => $options['status'] ?? 200,
|
|
273
|
+
'headers' => $headers,
|
|
274
|
+
'body' => $result['html'],
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
public function toLaravelStreamedResponse($input, array $options = [])
|
|
279
|
+
{
|
|
280
|
+
$headers = array_replace([
|
|
281
|
+
'Content-Type' => 'application/x-ndjson; charset=UTF-8',
|
|
282
|
+
'X-XTend-RMT-SSR-Adapter' => RMT_PHP_SSR_ADAPTER_SCHEMA,
|
|
283
|
+
], $options['headers'] ?? []);
|
|
284
|
+
$streamFactory = function () use ($input, $options): void {
|
|
285
|
+
foreach ($this->streamJsonl($input, $options) as $line) {
|
|
286
|
+
echo $line;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
if (class_exists('\\Symfony\\Component\\HttpFoundation\\StreamedResponse')) {
|
|
290
|
+
return new \Symfony\Component\HttpFoundation\StreamedResponse($streamFactory, $options['status'] ?? 200, $headers);
|
|
291
|
+
}
|
|
292
|
+
return [
|
|
293
|
+
'status' => $options['status'] ?? 200,
|
|
294
|
+
'headers' => $headers,
|
|
295
|
+
'stream' => $this->streamJsonl($input, $options),
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private function normalizeRenderInput($input, array $options, array &$diagnostics): array
|
|
300
|
+
{
|
|
301
|
+
$value = is_array($input) ? $input : ['descriptor' => $input];
|
|
302
|
+
$hasSource = isset($value['source']) || isset($value['text']);
|
|
303
|
+
$hasPreparedTemplate = isset($value['template']) || isset($value['preparedTemplate']) || (($value['kind'] ?? null) === 'renderman_prepared_template');
|
|
304
|
+
$hasExplicitDescriptor = isset($value['descriptor']) || isset($value['domDescriptor']) || $hasPreparedTemplate;
|
|
305
|
+
if ($hasSource && $hasExplicitDescriptor) {
|
|
306
|
+
$source = (string) ($value['source'] ?? $value['text']);
|
|
307
|
+
$compileResult = $this->compileSourceViaHost($source, $value, $options, $diagnostics);
|
|
308
|
+
$template = null;
|
|
309
|
+
if ($hasPreparedTemplate) {
|
|
310
|
+
$template = $value['template'] ?? ($value['preparedTemplate'] ?? $value);
|
|
311
|
+
$descriptor = $template['descriptor'] ?? ($template['domDescriptor'] ?? ($template['markup']['descriptor'] ?? (isset($template['html']) ? ['type' => 'html', 'html' => $template['html'], 'trustBoundary' => $template['trustBoundary'] ?? null] : null)));
|
|
312
|
+
} else {
|
|
313
|
+
$descriptor = $value['descriptor'] ?? $value['domDescriptor'];
|
|
314
|
+
}
|
|
315
|
+
return [
|
|
316
|
+
'kind' => 'source+descriptor',
|
|
317
|
+
'source' => $source,
|
|
318
|
+
'compileResult' => $compileResult,
|
|
319
|
+
'coreDocument' => is_array($compileResult) ? ($compileResult['coreDocument'] ?? null) : null,
|
|
320
|
+
'template' => $template,
|
|
321
|
+
'descriptor' => $this->normalizeDescriptor($descriptor),
|
|
322
|
+
'sourceRef' => $value['filePath'] ?? ($value['sourceRef'] ?? (is_array($compileResult) ? ($compileResult['coreDocument']['sourceRef'] ?? null) : null)),
|
|
323
|
+
];
|
|
324
|
+
}
|
|
325
|
+
if (isset($value['descriptor']) || isset($value['domDescriptor'])) {
|
|
326
|
+
return [
|
|
327
|
+
'kind' => 'dom-descriptor',
|
|
328
|
+
'descriptor' => $this->normalizeDescriptor($value['descriptor'] ?? $value['domDescriptor']),
|
|
329
|
+
'sourceRef' => $value['filePath'] ?? ($value['sourceRef'] ?? null),
|
|
330
|
+
];
|
|
331
|
+
}
|
|
332
|
+
$core = $value['coreDocument'] ?? ($value['core'] ?? ($this->isCoreDocument($value) ? $value : null));
|
|
333
|
+
if ($this->isCoreDocument($core)) {
|
|
334
|
+
return [
|
|
335
|
+
'kind' => 'core-document',
|
|
336
|
+
'coreDocument' => $core,
|
|
337
|
+
'descriptor' => isset($value['descriptor']) ? $this->normalizeDescriptor($value['descriptor']) : $this->deriveDescriptorFromCore($core),
|
|
338
|
+
'sourceRef' => $value['filePath'] ?? ($core['sourceRef'] ?? null),
|
|
339
|
+
];
|
|
340
|
+
}
|
|
341
|
+
if (isset($value['template']) || isset($value['preparedTemplate']) || (($value['kind'] ?? null) === 'renderman_prepared_template')) {
|
|
342
|
+
$template = $value['template'] ?? ($value['preparedTemplate'] ?? $value);
|
|
343
|
+
return [
|
|
344
|
+
'kind' => 'prepared-template',
|
|
345
|
+
'template' => $template,
|
|
346
|
+
'descriptor' => $this->normalizeDescriptor($template['descriptor'] ?? ($template['domDescriptor'] ?? ($template['markup']['descriptor'] ?? (isset($template['html']) ? ['type' => 'html', 'html' => $template['html'], 'trustBoundary' => $template['trustBoundary'] ?? null] : null)))),
|
|
347
|
+
'sourceRef' => $value['filePath'] ?? ($template['sourceRef'] ?? null),
|
|
348
|
+
];
|
|
349
|
+
}
|
|
350
|
+
if (is_string($input) || isset($value['source']) || isset($value['text'])) {
|
|
351
|
+
$source = is_string($input) ? $input : (string) ($value['source'] ?? $value['text']);
|
|
352
|
+
$compileResult = $this->compileSourceViaHost($source, $value, $options, $diagnostics);
|
|
353
|
+
if (!is_array($compileResult) || !isset($compileResult['coreDocument'])) {
|
|
354
|
+
return [
|
|
355
|
+
'kind' => 'source',
|
|
356
|
+
'source' => $source,
|
|
357
|
+
'sourceRef' => $value['filePath'] ?? null,
|
|
358
|
+
'descriptor' => ['type' => 'empty'],
|
|
359
|
+
];
|
|
360
|
+
}
|
|
361
|
+
return [
|
|
362
|
+
'kind' => 'source',
|
|
363
|
+
'source' => $source,
|
|
364
|
+
'compileResult' => $compileResult,
|
|
365
|
+
'coreDocument' => $compileResult['coreDocument'],
|
|
366
|
+
'descriptor' => $this->deriveDescriptorFromCore($compileResult['coreDocument']),
|
|
367
|
+
'sourceRef' => $value['filePath'] ?? ($compileResult['coreDocument']['sourceRef'] ?? null),
|
|
368
|
+
];
|
|
369
|
+
}
|
|
370
|
+
return [
|
|
371
|
+
'kind' => 'dom-descriptor',
|
|
372
|
+
'descriptor' => $this->normalizeDescriptor($input),
|
|
373
|
+
'sourceRef' => null,
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
private function compileSourceViaHost(string $source, array $value, array $options, array &$diagnostics): ?array
|
|
378
|
+
{
|
|
379
|
+
$compiler = $options['compileRmtVNextSource'] ?? null;
|
|
380
|
+
if (!is_callable($compiler)) {
|
|
381
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.compiler_required', 'Rendering RMT source in PHP requires an injected compileRmtVNextSource host bridge.', 'error', [
|
|
382
|
+
'filePath' => $value['filePath'] ?? null,
|
|
383
|
+
]);
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
$compileResult = $compiler($source, ['filePath' => $value['filePath'] ?? ($value['sourceRef'] ?? 'inline.rmt')]);
|
|
387
|
+
if (!is_array($compileResult) || ($compileResult['ok'] ?? false) === false || !isset($compileResult['coreDocument'])) {
|
|
388
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.compile_failed', 'Injected RMT compiler bridge did not return a Core Document.', 'error');
|
|
389
|
+
return is_array($compileResult) ? $compileResult : null;
|
|
390
|
+
}
|
|
391
|
+
return $compileResult;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
private function normalizeDescriptor($input): array
|
|
395
|
+
{
|
|
396
|
+
if (is_array($input)) {
|
|
397
|
+
if ($this->isList($input)) return ['type' => 'fragment', 'children' => $input];
|
|
398
|
+
if (isset($input['descriptor'])) return $this->normalizeDescriptor($input['descriptor']);
|
|
399
|
+
if (isset($input['domDescriptor'])) return $this->normalizeDescriptor($input['domDescriptor']);
|
|
400
|
+
return $input;
|
|
401
|
+
}
|
|
402
|
+
if ($input === null || $input === false) return ['type' => 'empty'];
|
|
403
|
+
return ['type' => 'text', 'text' => $input];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private function serializeDescriptor($input, array $context, array &$diagnostics): string
|
|
407
|
+
{
|
|
408
|
+
$descriptor = $this->normalizeDescriptor($input);
|
|
409
|
+
$type = (string) ($descriptor['type'] ?? ($descriptor['kind'] ?? (isset($descriptor['component']) || isset($descriptor['componentTag']) ? 'component' : (isset($descriptor['tag']) ? 'element' : (isset($descriptor['html']) ? 'html' : (array_key_exists('text', $descriptor) ? 'text' : 'fragment'))))));
|
|
410
|
+
if ($type === 'empty') return '';
|
|
411
|
+
if ($type === 'text') return $this->escapeHtml((string) ($descriptor['text'] ?? ''));
|
|
412
|
+
if ($type === 'html' || $type === 'trusted_html' || isset($descriptor['html'])) {
|
|
413
|
+
return $this->sanitizeHtmlFragment((string) ($descriptor['html'] ?? ($descriptor['content'] ?? '')), array_replace($context, ['descriptor' => $descriptor]), $context['options'] ?? [], $diagnostics);
|
|
414
|
+
}
|
|
415
|
+
if ($type === 'component') return $this->serializeComponent($descriptor, $context, $diagnostics);
|
|
416
|
+
if ($type === 'element') return $this->serializeElement($descriptor, $context, $diagnostics);
|
|
417
|
+
if ($type === 'slot') return $this->serializeDescriptor($this->descriptorWithSlot($descriptor['children'] ?? ($descriptor['text'] ?? ''), (string) ($descriptor['slot'] ?? ($descriptor['name'] ?? 'default'))), $context, $diagnostics);
|
|
418
|
+
if ($type === 'fragment') {
|
|
419
|
+
$html = '';
|
|
420
|
+
foreach ($this->asArray($descriptor['children'] ?? ($descriptor['nodes'] ?? [])) as $child) {
|
|
421
|
+
$html .= $this->serializeDescriptor($child, $context, $diagnostics);
|
|
422
|
+
}
|
|
423
|
+
return $html;
|
|
424
|
+
}
|
|
425
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.descriptor_type_unsupported', 'Unsupported PHP SSR descriptor type "' . $type . '".', 'error');
|
|
426
|
+
return '';
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private function serializeComponent(array $descriptor, array &$context, array &$diagnostics): string
|
|
430
|
+
{
|
|
431
|
+
$tag = (string) ($descriptor['tag'] ?? ($descriptor['componentTag'] ?? ($descriptor['host'] ?? ($descriptor['component'] ?? ($descriptor['ref'] ?? 'div')))));
|
|
432
|
+
$capability = $this->resolveCapability($tag);
|
|
433
|
+
if (!$capability && str_starts_with($tag, 'x-')) {
|
|
434
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.component_capability_missing', 'No XTend component capability metadata was available for "' . $tag . '".', 'warning', [
|
|
435
|
+
'tag' => $tag,
|
|
436
|
+
]);
|
|
437
|
+
}
|
|
438
|
+
if ($capability && isset($context['componentCapabilities']) && is_array($context['componentCapabilities'])) {
|
|
439
|
+
$context['componentCapabilities'][$capability['tag']] = $capability;
|
|
440
|
+
}
|
|
441
|
+
$normalizedTag = $this->normalizeTag($capability['tag'] ?? $tag, $diagnostics);
|
|
442
|
+
$attributes = $this->mergeAttributes(
|
|
443
|
+
$descriptor['attributes'] ?? [],
|
|
444
|
+
$descriptor['attrs'] ?? [],
|
|
445
|
+
$this->propertiesAsAttributes($descriptor['properties'] ?? ($descriptor['props'] ?? [])),
|
|
446
|
+
[
|
|
447
|
+
'data-rmt-node-ssr' => 'true',
|
|
448
|
+
'data-rmt-component-capability' => $capability['tag'] ?? $normalizedTag,
|
|
449
|
+
'data-rmt-component-family' => $capability['family'] ?? null,
|
|
450
|
+
'data-rmt-lazy-import' => $capability['modulePath'] ?? null,
|
|
451
|
+
],
|
|
452
|
+
$this->eventAttributes($descriptor['events'] ?? ($descriptor['eventBindings'] ?? []))
|
|
453
|
+
);
|
|
454
|
+
$parts = $this->asArray($descriptor['parts'] ?? ($descriptor['part'] ?? []));
|
|
455
|
+
if ($parts) $attributes['part'] = implode(' ', array_values(array_unique(array_map('strval', $parts))));
|
|
456
|
+
$children = [];
|
|
457
|
+
foreach (($descriptor['slots'] ?? []) as $slotName => $slotValue) {
|
|
458
|
+
foreach ($this->asArray($slotValue) as $slotChild) {
|
|
459
|
+
$children[] = $this->descriptorWithSlot($slotChild, (string) $slotName);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
foreach ($this->asArray($descriptor['children'] ?? ($descriptor['nodes'] ?? [])) as $child) {
|
|
463
|
+
$children[] = $child;
|
|
464
|
+
}
|
|
465
|
+
$open = '<' . $normalizedTag . $this->serializeAttributes($attributes, $diagnostics) . '>';
|
|
466
|
+
$html = '';
|
|
467
|
+
foreach ($children as $child) {
|
|
468
|
+
$html .= $this->serializeDescriptor($child, $context, $diagnostics);
|
|
469
|
+
}
|
|
470
|
+
return $open . $html . '</' . $normalizedTag . '>';
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
private function serializeElement(array $descriptor, array $context, array &$diagnostics): string
|
|
474
|
+
{
|
|
475
|
+
$tag = $this->normalizeTag((string) ($descriptor['tag'] ?? ($descriptor['element'] ?? 'div')), $diagnostics);
|
|
476
|
+
$attributes = $this->mergeAttributes($descriptor['attributes'] ?? [], $descriptor['attrs'] ?? []);
|
|
477
|
+
$open = '<' . $tag . $this->serializeAttributes($attributes, $diagnostics) . '>';
|
|
478
|
+
if (isset($this->voidTags[$tag])) return $open;
|
|
479
|
+
$html = '';
|
|
480
|
+
foreach ($this->asArray($descriptor['children'] ?? ($descriptor['nodes'] ?? [])) as $child) {
|
|
481
|
+
$html .= $this->serializeDescriptor($child, $context, $diagnostics);
|
|
482
|
+
}
|
|
483
|
+
return $open . $html . '</' . $tag . '>';
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
private function descriptorWithSlot($descriptor, string $slotName): array
|
|
487
|
+
{
|
|
488
|
+
if (is_array($descriptor) && !$this->isList($descriptor)) {
|
|
489
|
+
if (isset($descriptor['text']) && !isset($descriptor['type']) && !isset($descriptor['tag']) && !isset($descriptor['component'])) {
|
|
490
|
+
return [
|
|
491
|
+
'type' => 'element',
|
|
492
|
+
'tag' => 'span',
|
|
493
|
+
'attributes' => array_replace($descriptor['attributes'] ?? [], ['slot' => $slotName]),
|
|
494
|
+
'children' => [['type' => 'text', 'text' => $descriptor['text']]],
|
|
495
|
+
];
|
|
496
|
+
}
|
|
497
|
+
$descriptor['attributes'] = array_replace($descriptor['attributes'] ?? [], ['slot' => $descriptor['slot'] ?? (($descriptor['attributes']['slot'] ?? null) ?: $slotName)]);
|
|
498
|
+
return $descriptor;
|
|
499
|
+
}
|
|
500
|
+
return [
|
|
501
|
+
'type' => 'element',
|
|
502
|
+
'tag' => 'span',
|
|
503
|
+
'attributes' => ['slot' => $slotName],
|
|
504
|
+
'children' => [$descriptor],
|
|
505
|
+
];
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
private function sanitizeHtmlFragment(string $html, array $context, array $options, array &$diagnostics): string
|
|
509
|
+
{
|
|
510
|
+
if (!$this->hasTrustBoundary($context['descriptor'] ?? [], $options)) {
|
|
511
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.trust_boundary_missing', 'HTML fragments require an explicit XTend trust boundary or host sanitizer.', 'error', [
|
|
512
|
+
'operationId' => $context['operationId'] ?? null,
|
|
513
|
+
]);
|
|
514
|
+
}
|
|
515
|
+
if (isset($options['sanitizeHtmlOutput']) && is_callable($options['sanitizeHtmlOutput'])) {
|
|
516
|
+
return (string) $options['sanitizeHtmlOutput']($html, ['context' => $context, 'diagnostics' => $diagnostics]);
|
|
517
|
+
}
|
|
518
|
+
$before = $html;
|
|
519
|
+
$html = preg_replace('/<(script|iframe|frame|frameset|object|embed|base)\\b[^>]*>.*?<\\/\\1>/is', '', $html) ?? '';
|
|
520
|
+
$html = preg_replace('/<\\/?(script|iframe|frame|frameset|object|embed|base)\\b[^>]*>/i', '', $html) ?? '';
|
|
521
|
+
$html = preg_replace('/\\s+on[a-z0-9_-]+\\s*=\\s*("[^"]*"|\\\'[^\\\']*\\\'|[^\\s>]+)/i', '', $html) ?? '';
|
|
522
|
+
$html = preg_replace('/\\s+srcdoc\\s*=\\s*("[^"]*"|\\\'[^\\\']*\\\'|[^\\s>]+)/i', '', $html) ?? '';
|
|
523
|
+
$html = preg_replace_callback('/\\s+(href|src|action|formaction|poster|xlink:href)\\s*=\\s*("[^"]*"|\\\'[^\\\']*\\\'|[^\\s>]+)/i', function (array $matches): string {
|
|
524
|
+
$value = trim($matches[2], "'\"");
|
|
525
|
+
return $this->isSafeUrl($value) ? $matches[0] : '';
|
|
526
|
+
}, $html) ?? '';
|
|
527
|
+
if ($before !== $html) {
|
|
528
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.html_sanitized', 'Unsafe server markup was sanitized by the PHP SSR adapter fallback sanitizer.', 'warning');
|
|
529
|
+
}
|
|
530
|
+
return $html;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
private function resolveCapability(string $tag): ?array
|
|
534
|
+
{
|
|
535
|
+
$tag = strtolower(trim($tag));
|
|
536
|
+
$manifest = $this->options['manifest'] ?? [];
|
|
537
|
+
$modulePath = $manifest[$tag] ?? null;
|
|
538
|
+
if (!$modulePath && isset($this->options['componentCapabilities'][$tag]['modulePath'])) {
|
|
539
|
+
$modulePath = $this->options['componentCapabilities'][$tag]['modulePath'];
|
|
540
|
+
}
|
|
541
|
+
if (!$modulePath && !str_starts_with($tag, 'x-')) return null;
|
|
542
|
+
return [
|
|
543
|
+
'tag' => $tag,
|
|
544
|
+
'family' => $this->inferFamily($tag),
|
|
545
|
+
'visualKind' => 'public-ui',
|
|
546
|
+
'modulePath' => $modulePath,
|
|
547
|
+
'slots' => $this->options['componentCapabilities'][$tag]['slots'] ?? [],
|
|
548
|
+
'parts' => $this->options['componentCapabilities'][$tag]['parts'] ?? [],
|
|
549
|
+
'events' => $this->options['componentCapabilities'][$tag]['events'] ?? [],
|
|
550
|
+
'importPolicy' => 'explicit-importer-only',
|
|
551
|
+
'kernelBoundary' => RMT_PHP_SSR_KERNEL_BOUNDARY,
|
|
552
|
+
];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
private function inferFamily(string $tag): string
|
|
556
|
+
{
|
|
557
|
+
if (in_array($tag, ['x-input', 'x-select', 'x-checkbox', 'x-radio', 'x-calendar', 'x-textarea', 'x-form'], true)) return 'form';
|
|
558
|
+
if (in_array($tag, ['x-router', 'x-link', 'x-menu', 'x-drawer'], true)) return 'navigation';
|
|
559
|
+
if (in_array($tag, ['x-modal', 'x-dialog', 'x-popover', 'x-tooltip', 'x-lightbox', 'x-toast', 'x-side-panel', 'x-surface-window', 'x-surface-manager'], true)) return 'overlay-surface';
|
|
560
|
+
if (in_array($tag, ['x-player', 'x-status', 'x-progress', 'x-code', 'x-icon', 'x-cards', 'x-masonry', 'x-summary', 'x-type', 'x-writer'], true)) return 'media-feedback-layout';
|
|
561
|
+
if (in_array($tag, ['x-theme', 'x-section', 'x-hero', 'x-header', 'x-footer'], true)) return 'theme-layout';
|
|
562
|
+
return 'general-ui';
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
private function createStreamingContract(?array $coreDocument): ?array
|
|
566
|
+
{
|
|
567
|
+
if (!$coreDocument || empty($coreDocument['dataSources'])) return null;
|
|
568
|
+
$dataSources = [];
|
|
569
|
+
foreach ($coreDocument['dataSources'] as $dataSource) {
|
|
570
|
+
$dataSources[$dataSource['id'] ?? ($dataSource['target'] ?? '')] = $dataSource;
|
|
571
|
+
}
|
|
572
|
+
$streams = [];
|
|
573
|
+
foreach (($coreDocument['operations'] ?? []) as $operation) {
|
|
574
|
+
$sourceRef = $operation['source']['ref'] ?? null;
|
|
575
|
+
if (!$sourceRef || !isset($dataSources[$sourceRef])) continue;
|
|
576
|
+
$record = $dataSources[$sourceRef];
|
|
577
|
+
$variant = $this->operationVariant($operation, $record);
|
|
578
|
+
$streams[] = [
|
|
579
|
+
'schema' => 'xtend.rmt.vnext-stream-operation.v1',
|
|
580
|
+
'operationId' => $operation['id'] ?? null,
|
|
581
|
+
'operationKind' => $operation['kind'] ?? null,
|
|
582
|
+
'variant' => $variant,
|
|
583
|
+
'capability' => $variant === 'hydration' ? 'stream.hydration.chunked' : 'stream.' . $variant . '.incremental',
|
|
584
|
+
'lane' => $operation['scope']['lane'] ?? null,
|
|
585
|
+
'chunkKey' => 'rmt.vnext.' . $variant . '.' . ($operation['id'] ?? uniqid('operation:', false)),
|
|
586
|
+
'dataSource' => [
|
|
587
|
+
'id' => $record['id'] ?? $sourceRef,
|
|
588
|
+
'kind' => $record['kind'] ?? null,
|
|
589
|
+
'target' => $record['target'] ?? ($operation['source']['id'] ?? null),
|
|
590
|
+
],
|
|
591
|
+
'security' => [
|
|
592
|
+
'boundaryIds' => ['xtend.security.streaming-boundary.v1'],
|
|
593
|
+
],
|
|
594
|
+
];
|
|
595
|
+
}
|
|
596
|
+
return [
|
|
597
|
+
'schema' => RMT_PHP_SSR_STREAMING_CONTRACT_SCHEMA,
|
|
598
|
+
'coreSchema' => $coreDocument['schema'] ?? null,
|
|
599
|
+
'ok' => true,
|
|
600
|
+
'streams' => $streams,
|
|
601
|
+
'streamRecordCount' => count($streams),
|
|
602
|
+
];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
private function operationVariant(array $operation, array $record): string
|
|
606
|
+
{
|
|
607
|
+
if (($operation['op'] ?? null) === 'hydrate') return 'hydration';
|
|
608
|
+
$kind = $record['kind'] ?? ($operation['source']['kind'] ?? 'endpoint');
|
|
609
|
+
if ($kind === 'sse') return 'sse';
|
|
610
|
+
if ($kind === 'worker') return 'worker';
|
|
611
|
+
return 'ssr';
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
private function resolveDataSource(array $record, array $operation, array $options, array &$diagnostics)
|
|
615
|
+
{
|
|
616
|
+
$mergedOptions = array_replace($this->options, $options);
|
|
617
|
+
$target = $record['target'] ?? ($record['id'] ?? null);
|
|
618
|
+
if (isset($mergedOptions['resolveDataSource']) && is_callable($mergedOptions['resolveDataSource'])) {
|
|
619
|
+
return $mergedOptions['resolveDataSource']($record, ['operation' => $operation]);
|
|
620
|
+
}
|
|
621
|
+
if ($target && isset($mergedOptions['endpointHandlers'][$target]) && is_callable($mergedOptions['endpointHandlers'][$target])) {
|
|
622
|
+
return $mergedOptions['endpointHandlers'][$target]($record, ['operation' => $operation]);
|
|
623
|
+
}
|
|
624
|
+
$static = array_replace($mergedOptions['staticDataSources'] ?? [], $mergedOptions['fixtures'] ?? []);
|
|
625
|
+
if ($target && array_key_exists($target, $static)) return $static[$target];
|
|
626
|
+
if (isset($record['id']) && array_key_exists($record['id'], $static)) return $static[$record['id']];
|
|
627
|
+
if (isset($mergedOptions['fetchAdapter']) && is_callable($mergedOptions['fetchAdapter'])) {
|
|
628
|
+
return $mergedOptions['fetchAdapter']($record, ['operation' => $operation]);
|
|
629
|
+
}
|
|
630
|
+
if (isset($mergedOptions['laravelContainerResolver']) && is_callable($mergedOptions['laravelContainerResolver'])) {
|
|
631
|
+
return $mergedOptions['laravelContainerResolver']($record, ['operation' => $operation]);
|
|
632
|
+
}
|
|
633
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.datasource_missing', 'No host resolver was provided for data source "' . ($target ?: '<unknown>') . '".', 'error', [
|
|
634
|
+
'operationId' => $operation['operationId'] ?? ($operation['id'] ?? null),
|
|
635
|
+
'dataSourceId' => $record['id'] ?? null,
|
|
636
|
+
'target' => $target,
|
|
637
|
+
]);
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
private function normalizeStreamPayload($value): array
|
|
642
|
+
{
|
|
643
|
+
if ($value === null) return [];
|
|
644
|
+
if (is_string($value)) return ['html' => $value];
|
|
645
|
+
if (is_array($value)) return $value;
|
|
646
|
+
return ['value' => $value];
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
private function createChunk(array $state, string $html, array $descriptor, array $hydration): array
|
|
650
|
+
{
|
|
651
|
+
$documentId = $state['coreDocument']['manifest']['id'] ?? $state['requestId'];
|
|
652
|
+
$templateId = $this->safeIdentifier($state['options']['templateId'] ?? $documentId, 'rmt-php-ssr-template');
|
|
653
|
+
$namespace = (string) ($state['options']['namespace'] ?? 'rmt');
|
|
654
|
+
$qualifiedId = $this->safeIdentifier($namespace) . ':' . $templateId;
|
|
655
|
+
return [
|
|
656
|
+
'kind' => RMT_PHP_SSR_CHUNK_KIND,
|
|
657
|
+
'version' => '1.0',
|
|
658
|
+
'executionMode' => RMT_PHP_SSR_EXECUTION_MODE,
|
|
659
|
+
'transport' => 'server',
|
|
660
|
+
'rootId' => $state['rootId'],
|
|
661
|
+
'template' => [
|
|
662
|
+
'id' => $templateId,
|
|
663
|
+
'qualifiedId' => $qualifiedId,
|
|
664
|
+
'namespace' => $namespace,
|
|
665
|
+
'documentId' => $documentId,
|
|
666
|
+
'mode' => 'dom_descriptor',
|
|
667
|
+
'props' => [],
|
|
668
|
+
],
|
|
669
|
+
'target' => [
|
|
670
|
+
'elementId' => $state['rootId'],
|
|
671
|
+
'selector' => '#' . $state['rootId'],
|
|
672
|
+
'ownershipMode' => 'hydrate_existing',
|
|
673
|
+
'namespace' => $namespace,
|
|
674
|
+
],
|
|
675
|
+
'markup' => [
|
|
676
|
+
'html' => $html,
|
|
677
|
+
'textContent' => trim(preg_replace('/<[^>]*>/', ' ', $html) ?? ''),
|
|
678
|
+
'descriptor' => $descriptor,
|
|
679
|
+
],
|
|
680
|
+
'hydration' => [
|
|
681
|
+
'bindings' => [],
|
|
682
|
+
'slots' => [],
|
|
683
|
+
'props' => [],
|
|
684
|
+
'templateHydration' => [
|
|
685
|
+
'mode' => RMT_PHP_SSR_EXECUTION_MODE,
|
|
686
|
+
'schema' => RMT_PHP_SSR_HYDRATION_SCHEMA,
|
|
687
|
+
],
|
|
688
|
+
'errorBoundary' => ['mode' => 'preserve-server-markup'],
|
|
689
|
+
'reactivityHints' => ['source' => 'rmt-php-ssr-adapter'],
|
|
690
|
+
'ownershipMode' => 'hydrate_existing',
|
|
691
|
+
'resourceId' => 'template.chunk:' . $qualifiedId,
|
|
692
|
+
'metadata' => $hydration,
|
|
693
|
+
],
|
|
694
|
+
'modelSnapshot' => $state['model'],
|
|
695
|
+
'plan' => [
|
|
696
|
+
'executionMode' => RMT_PHP_SSR_EXECUTION_MODE,
|
|
697
|
+
'rootId' => $state['rootId'],
|
|
698
|
+
'templateQualifiedId' => $qualifiedId,
|
|
699
|
+
'namespace' => $namespace,
|
|
700
|
+
'phases' => ['server_prerender', 'html_delivery', 'client_hydrate'],
|
|
701
|
+
],
|
|
702
|
+
'renderedAt' => $state['renderedAt'],
|
|
703
|
+
];
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
private function deriveDescriptorFromCore(array $coreDocument): array
|
|
707
|
+
{
|
|
708
|
+
$selectors = [];
|
|
709
|
+
foreach (($coreDocument['selectors'] ?? []) as $selector) {
|
|
710
|
+
if (isset($selector['id'])) $selectors[$selector['id']] = $selector;
|
|
711
|
+
if (isset($selector['name'])) $selectors[$selector['name']] = $selector;
|
|
712
|
+
}
|
|
713
|
+
$children = [];
|
|
714
|
+
foreach (($coreDocument['surfaces'] ?? []) as $surface) {
|
|
715
|
+
$selectorId = $surface['source']['selectorId'] ?? ($surface['source']['id'] ?? ($surface['source']['name'] ?? null));
|
|
716
|
+
$state = $this->findStateValue($coreDocument, $selectorId ? ($selectors[$selectorId] ?? null) : null);
|
|
717
|
+
$text = is_array($state) ? ($state['text'] ?? ($state['label'] ?? ($state['value'] ?? null))) : null;
|
|
718
|
+
$children[] = [
|
|
719
|
+
'type' => 'component',
|
|
720
|
+
'tag' => $surface['component'] ?? ($surface['tag'] ?? 'section'),
|
|
721
|
+
'id' => $this->safeIdentifier($surface['id'] ?? ($surface['name'] ?? 'surface')),
|
|
722
|
+
'key' => $this->safeIdentifier($surface['key'] ?? ($surface['id'] ?? ($surface['name'] ?? 'surface'))),
|
|
723
|
+
'attributes' => [
|
|
724
|
+
'id' => $this->safeIdentifier($surface['id'] ?? ($surface['name'] ?? 'surface')),
|
|
725
|
+
'data-rmt-surface-id' => $surface['id'] ?? ($surface['name'] ?? null),
|
|
726
|
+
'data-rmt-surface-name' => $surface['name'] ?? ($surface['id'] ?? null),
|
|
727
|
+
'data-rmt-surface-kind' => $surface['kind'] ?? ($surface['type'] ?? 'surface'),
|
|
728
|
+
'data-rmt-primitive-id' => $surface['name'] ?? ($surface['id'] ?? null),
|
|
729
|
+
'data-rmt-lane' => 'server-prerender',
|
|
730
|
+
'data-rmt-source-ref' => $surface['sourceRef'] ?? ($surface['source']['sourceRef'] ?? null),
|
|
731
|
+
],
|
|
732
|
+
'children' => $text ? [['type' => 'text', 'text' => $text]] : [],
|
|
733
|
+
];
|
|
734
|
+
}
|
|
735
|
+
return [
|
|
736
|
+
'type' => 'element',
|
|
737
|
+
'tag' => 'section',
|
|
738
|
+
'attributes' => [
|
|
739
|
+
'data-rmt-node-ssr-root' => 'true',
|
|
740
|
+
'data-rmt-document-id' => $coreDocument['manifest']['id'] ?? 'rmt-document',
|
|
741
|
+
],
|
|
742
|
+
'children' => $children,
|
|
743
|
+
];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
private function findStateValue(array $coreDocument, ?array $selector)
|
|
747
|
+
{
|
|
748
|
+
if (!$selector) return null;
|
|
749
|
+
$candidates = array_filter([
|
|
750
|
+
$selector['target'] ?? null,
|
|
751
|
+
$selector['source'] ?? null,
|
|
752
|
+
$selector['sourceRef'] ?? null,
|
|
753
|
+
isset($selector['id']) ? 'state:' . $selector['id'] : null,
|
|
754
|
+
isset($selector['name']) ? 'state:' . $selector['name'] : null,
|
|
755
|
+
]);
|
|
756
|
+
foreach (($coreDocument['states'] ?? []) as $state) {
|
|
757
|
+
foreach ($candidates as $candidate) {
|
|
758
|
+
if (($state['id'] ?? null) === $candidate || ($state['name'] ?? null) === $candidate || ($state['target'] ?? null) === $candidate) {
|
|
759
|
+
return $state['initial'] ?? ($state['value'] ?? ($state['defaultValue'] ?? null));
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
private function serializeAttributes(array $attributes, array &$diagnostics): string
|
|
767
|
+
{
|
|
768
|
+
$result = '';
|
|
769
|
+
foreach ($attributes as $name => $value) {
|
|
770
|
+
$result .= $this->serializeAttribute((string) $name, $value, $diagnostics);
|
|
771
|
+
}
|
|
772
|
+
return $result;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
private function serializeAttribute(string $name, $value, array &$diagnostics): string
|
|
776
|
+
{
|
|
777
|
+
$name = strtolower(trim($name));
|
|
778
|
+
if ($name === '' || !preg_match('/^[a-z_:][a-z0-9_.:-]*$/', $name)) {
|
|
779
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.attribute_blocked', 'Blocked invalid attribute.', 'error', ['attribute' => $name]);
|
|
780
|
+
return '';
|
|
781
|
+
}
|
|
782
|
+
if (str_starts_with($name, 'on') || $name === 'srcdoc') {
|
|
783
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.attribute_blocked', 'Blocked unsafe attribute "' . $name . '".', 'error', ['attribute' => $name]);
|
|
784
|
+
return '';
|
|
785
|
+
}
|
|
786
|
+
if ($value === null || $value === false) return '';
|
|
787
|
+
if (isset($this->urlAttributes[$name]) && !$this->isSafeUrl((string) $value)) {
|
|
788
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.url_blocked', 'Blocked unsafe URL in "' . $name . '".', 'error', ['attribute' => $name]);
|
|
789
|
+
return '';
|
|
790
|
+
}
|
|
791
|
+
if ($value === true) $value = 'true';
|
|
792
|
+
if (is_array($value) || is_object($value)) $value = json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
793
|
+
return ' ' . $name . '="' . $this->escapeAttribute((string) $value) . '"';
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
private function normalizeTag(string $tag, array &$diagnostics): string
|
|
797
|
+
{
|
|
798
|
+
$tag = strtolower(trim($tag));
|
|
799
|
+
if ($tag !== '' && preg_match('/^[a-z][a-z0-9._:-]*$/', $tag) && !isset($this->blockedTags[$tag])) return $tag;
|
|
800
|
+
$diagnostics[] = $this->diagnostic('rmt.php_ssr.tag_blocked', 'Blocked unsafe tag "' . ($tag ?: '<empty>') . '".', 'error');
|
|
801
|
+
return 'div';
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
private function propertiesAsAttributes($properties): array
|
|
805
|
+
{
|
|
806
|
+
$attributes = [];
|
|
807
|
+
if (!is_array($properties)) return $attributes;
|
|
808
|
+
foreach ($properties as $name => $value) {
|
|
809
|
+
if (is_array($value) || is_object($value)) {
|
|
810
|
+
$attributes['data-rmt-prop-' . $this->safeIdentifier((string) $name, 'prop')] = json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
811
|
+
} else {
|
|
812
|
+
$attributes[(string) $name] = $value;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return $attributes;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
private function eventAttributes($events): array
|
|
819
|
+
{
|
|
820
|
+
$attributes = [];
|
|
821
|
+
if (!is_array($events)) return $attributes;
|
|
822
|
+
foreach ($events as $name => $action) {
|
|
823
|
+
$attributes['data-rmt-event-' . $this->safeIdentifier((string) $name, 'event')] = is_scalar($action) ? (string) $action : json_encode($action, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
824
|
+
}
|
|
825
|
+
return $attributes;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
private function mergeAttributes(...$records): array
|
|
829
|
+
{
|
|
830
|
+
$merged = [];
|
|
831
|
+
foreach ($records as $record) {
|
|
832
|
+
if (!is_array($record)) continue;
|
|
833
|
+
foreach ($record as $key => $value) {
|
|
834
|
+
$merged[$key] = $value;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return $merged;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
private function hasTrustBoundary(array $record, array $options): bool
|
|
841
|
+
{
|
|
842
|
+
$values = $this->asArray($record['trustBoundary'] ?? ($record['trust'] ?? ($record['securityBoundary'] ?? null)));
|
|
843
|
+
$values = array_merge($values, $this->asArray($options['trustBoundary'] ?? ($options['defaultTrustBoundary'] ?? null)));
|
|
844
|
+
foreach ($values as $value) {
|
|
845
|
+
if (is_array($value)) {
|
|
846
|
+
foreach ($value as $nested) {
|
|
847
|
+
if (isset($this->trustBoundaryTokens[(string) $nested])) return true;
|
|
848
|
+
}
|
|
849
|
+
} elseif (isset($this->trustBoundaryTokens[(string) $value])) {
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
private function isSafeUrl(string $value): bool
|
|
857
|
+
{
|
|
858
|
+
$compact = strtolower(preg_replace('/[\\x00-\\x1F\\x7F\\s]+/', '', trim($value)) ?? '');
|
|
859
|
+
if ($compact === '' || str_starts_with($compact, '#') || str_starts_with($compact, '/') || str_starts_with($compact, './') || str_starts_with($compact, '../')) return true;
|
|
860
|
+
if (str_starts_with($compact, 'http://') || str_starts_with($compact, 'https://') || str_starts_with($compact, 'mailto:') || str_starts_with($compact, 'tel:') || str_starts_with($compact, 'blob:')) return true;
|
|
861
|
+
if (str_starts_with($compact, 'data:image/')) return true;
|
|
862
|
+
return !preg_match('/^[a-z][a-z0-9+.-]*:/', $compact);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
private function collectPreloads(string $html): array
|
|
866
|
+
{
|
|
867
|
+
$preloads = [];
|
|
868
|
+
if (preg_match_all('/data-rmt-lazy-import="([^"]+)"/', $html, $matches)) {
|
|
869
|
+
foreach ($matches[1] as $href) {
|
|
870
|
+
$preloads[$href] = ['href' => $href, 'as' => 'script', 'rel' => 'modulepreload'];
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return array_values($preloads);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
private function listLanes(?array $coreDocument): array
|
|
877
|
+
{
|
|
878
|
+
if (!$coreDocument) return [];
|
|
879
|
+
return array_values(array_filter(array_map(function ($lane) {
|
|
880
|
+
return $lane['id'] ?? ($lane['name'] ?? null);
|
|
881
|
+
}, $coreDocument['lanes'] ?? [])));
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
private function jsonlFrame(int &$sequence, string $requestId, string $type, array $fields = []): string
|
|
885
|
+
{
|
|
886
|
+
$frame = [
|
|
887
|
+
'schema' => RMT_PHP_SSR_JSONL_FRAME_SCHEMA,
|
|
888
|
+
'type' => $type,
|
|
889
|
+
'requestId' => $requestId,
|
|
890
|
+
'sequence' => $sequence++,
|
|
891
|
+
'operationId' => $fields['operationId'] ?? null,
|
|
892
|
+
'variant' => $fields['variant'] ?? null,
|
|
893
|
+
'capability' => $fields['capability'] ?? null,
|
|
894
|
+
'lane' => $fields['lane'] ?? null,
|
|
895
|
+
'chunkKey' => $fields['chunkKey'] ?? null,
|
|
896
|
+
'payload' => $fields['payload'] ?? [],
|
|
897
|
+
'diagnostics' => $fields['diagnostics'] ?? [],
|
|
898
|
+
];
|
|
899
|
+
return json_encode($frame, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n";
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
private function diagnostic(string $code, string $message, string $severity = 'error', array $details = []): array
|
|
903
|
+
{
|
|
904
|
+
return array_replace([
|
|
905
|
+
'schema' => RMT_PHP_SSR_DIAGNOSTIC_SCHEMA,
|
|
906
|
+
'code' => $code,
|
|
907
|
+
'severity' => $severity,
|
|
908
|
+
'message' => $message,
|
|
909
|
+
], array_filter($details, function ($value) {
|
|
910
|
+
return $value !== null;
|
|
911
|
+
}));
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
private function hasBlockingDiagnostics(array $diagnostics): bool
|
|
915
|
+
{
|
|
916
|
+
foreach ($diagnostics as $diagnostic) {
|
|
917
|
+
if (in_array($diagnostic['severity'] ?? '', ['error', 'fatal'], true)) return true;
|
|
918
|
+
}
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
private function firstDiagnosticCode(array $diagnostics): ?string
|
|
923
|
+
{
|
|
924
|
+
foreach ($diagnostics as $diagnostic) {
|
|
925
|
+
if (isset($diagnostic['code'])) return (string) $diagnostic['code'];
|
|
926
|
+
}
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
private function isCoreDocument($value): bool
|
|
931
|
+
{
|
|
932
|
+
return is_array($value) && (($value['schema'] ?? null) === 'xtend.rmt.core-format.vnext.v1' || (isset($value['surfaces']) && isset($value['operations'])));
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
private function isRenderResult($value): bool
|
|
936
|
+
{
|
|
937
|
+
return is_array($value) && (($value['schema'] ?? null) === RMT_PHP_SSR_RENDER_RESULT_SCHEMA) && array_key_exists('html', $value);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
private function asArray($value): array
|
|
941
|
+
{
|
|
942
|
+
if (is_array($value)) return $this->isList($value) ? $value : [$value];
|
|
943
|
+
if ($value === null || $value === false) return [];
|
|
944
|
+
return [$value];
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
private function isList(array $value): bool
|
|
948
|
+
{
|
|
949
|
+
return $value === [] || array_keys($value) === range(0, count($value) - 1);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
private function safeIdentifier($value, string $fallback = 'rmt-php-ssr'): string
|
|
953
|
+
{
|
|
954
|
+
$normalized = preg_replace('/[^a-zA-Z0-9_.:-]+/', '-', trim((string) $value)) ?? '';
|
|
955
|
+
$normalized = trim($normalized, '-');
|
|
956
|
+
return $normalized !== '' ? $normalized : $fallback;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
private function escapeHtml(string $value): string
|
|
960
|
+
{
|
|
961
|
+
return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
private function escapeAttribute(string $value): string
|
|
965
|
+
{
|
|
966
|
+
return str_replace('`', '`', $this->escapeHtml($value));
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
if (!function_exists('createRmtPhpSsrAdapter')) {
|
|
972
|
+
function createRmtPhpSsrAdapter(array $options = []): RmtPhpSsrAdapter
|
|
973
|
+
{
|
|
974
|
+
return new RmtPhpSsrAdapter($options);
|
|
975
|
+
}
|
|
976
|
+
}
|