@ccslabs/xtend 0.1.0-rc.1
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 +65 -0
- package/LICENSE +201 -0
- package/README.md +184 -0
- package/a11y/motion-contrast-policy.d.ts +32 -0
- package/a11y/motion-contrast-policy.js +261 -0
- package/a11y/runtime-a11y-contract.d.ts +44 -0
- package/a11y/runtime-a11y-contract.js +385 -0
- package/a11y/screenreader-signals.d.ts +32 -0
- package/a11y/screenreader-signals.js +372 -0
- package/api.d.ts +168 -0
- package/api.js +864 -0
- package/catalog/catalog-public-types.d.ts +66 -0
- package/catalog/component-catalog-coverage.d.ts +20 -0
- package/catalog/component-catalog-coverage.js +377 -0
- package/catalog/component-long-tail-migration.d.ts +18 -0
- package/catalog/component-long-tail-migration.js +305 -0
- package/catalog/component-regression-priority.d.ts +20 -0
- package/catalog/component-regression-priority.js +305 -0
- package/catalog/enterprise-component-flex-release-handoff.d.ts +32 -0
- package/catalog/enterprise-component-flex-release-handoff.js +437 -0
- package/catalog/enterprise-component-style-audit.d.ts +22 -0
- package/catalog/enterprise-component-style-audit.js +353 -0
- package/catalog/enterprise-form-control-theme-a11y.d.ts +19 -0
- package/catalog/enterprise-form-control-theme-a11y.js +220 -0
- package/catalog/enterprise-icon-control-audit.d.ts +21 -0
- package/catalog/enterprise-icon-control-audit.js +258 -0
- package/catalog/enterprise-layout-display-media-tokenization.d.ts +20 -0
- package/catalog/enterprise-layout-display-media-tokenization.js +237 -0
- package/catalog/enterprise-navigation-routing-state-hardening.d.ts +20 -0
- package/catalog/enterprise-navigation-routing-state-hardening.js +255 -0
- package/catalog/enterprise-overlay-mode-token-parity.d.ts +15 -0
- package/catalog/enterprise-overlay-mode-token-parity.js +178 -0
- package/catalog/enterprise-third-party-authoring-guide.d.ts +23 -0
- package/catalog/enterprise-third-party-authoring-guide.js +310 -0
- package/catalog/enterprise-visual-dom-snapshot-matrix.d.ts +31 -0
- package/catalog/enterprise-visual-dom-snapshot-matrix.js +357 -0
- package/catalog/epic10-existing-component-metadata.d.ts +25 -0
- package/catalog/epic10-existing-component-metadata.js +534 -0
- package/catalog/epic10-p0-component-wave.d.ts +28 -0
- package/catalog/epic10-p0-component-wave.js +688 -0
- package/catalog/epic10-platform-gates.d.ts +31 -0
- package/catalog/epic10-platform-gates.js +425 -0
- package/catalog/epic10-release-handoff.d.ts +30 -0
- package/catalog/epic10-release-handoff.js +195 -0
- package/catalog/epic11-enterprise-ux-handoff.d.ts +29 -0
- package/catalog/epic11-enterprise-ux-handoff.js +403 -0
- package/catalog/epic12-docs-adoption.d.ts +29 -0
- package/catalog/epic12-docs-adoption.js +183 -0
- package/catalog/epic12-rc0-gate-matrix.d.ts +36 -0
- package/catalog/epic12-rc0-gate-matrix.js +439 -0
- package/catalog/epic12-rc0-handoff.d.ts +30 -0
- package/catalog/epic12-rc0-handoff.js +385 -0
- package/catalog/epic13-conditional-network-evidence-ci.d.ts +35 -0
- package/catalog/epic13-conditional-network-evidence-ci.js +278 -0
- package/catalog/epic13-conditional-network-evidence.d.ts +34 -0
- package/catalog/epic13-conditional-network-evidence.js +280 -0
- package/catalog/epic13-docs-rmt-production-hardening.d.ts +39 -0
- package/catalog/epic13-docs-rmt-production-hardening.js +286 -0
- package/catalog/epic13-hydration-performance-closure.d.ts +33 -0
- package/catalog/epic13-hydration-performance-closure.js +234 -0
- package/catalog/epic13-known-residual-triage.d.ts +32 -0
- package/catalog/epic13-known-residual-triage.js +339 -0
- package/catalog/epic13-package-export-lock.d.ts +41 -0
- package/catalog/epic13-package-export-lock.js +604 -0
- package/catalog/epic13-prod-browser-csp-smoke.d.ts +35 -0
- package/catalog/epic13-prod-browser-csp-smoke.js +218 -0
- package/catalog/epic13-rc1-gate-matrix-ci-handoff.d.ts +36 -0
- package/catalog/epic13-rc1-gate-matrix-ci-handoff.js +418 -0
- package/catalog/epic13-rc1-migration-notes.d.ts +36 -0
- package/catalog/epic13-rc1-migration-notes.js +271 -0
- package/catalog/epic13-rc1-readiness.d.ts +33 -0
- package/catalog/epic13-rc1-readiness.js +487 -0
- package/catalog/epic13-release-owner-acceptance.d.ts +33 -0
- package/catalog/epic13-release-owner-acceptance.js +354 -0
- package/catalog/epic13-release-report-pack-dry-run-evidence.d.ts +36 -0
- package/catalog/epic13-release-report-pack-dry-run-evidence.js +253 -0
- package/catalog/epic13-rmt-production-readiness.d.ts +35 -0
- package/catalog/epic13-rmt-production-readiness.js +314 -0
- package/catalog/epic13-trusted-dom-boundary.d.ts +36 -0
- package/catalog/epic13-trusted-dom-boundary.js +230 -0
- package/catalog/epic13-visual-owner-artifact.d.ts +35 -0
- package/catalog/epic13-visual-owner-artifact.js +233 -0
- package/catalog/epic14-lsp-handoff.d.ts +28 -0
- package/catalog/epic14-lsp-handoff.js +312 -0
- package/catalog/epic14-rmt-tooling.d.ts +33 -0
- package/catalog/epic14-rmt-tooling.js +282 -0
- package/catalog/surface-manager-adapter-runtime.d.ts +37 -0
- package/catalog/surface-manager-adapter-runtime.js +203 -0
- package/catalog/surface-manager-browser-lab.d.ts +39 -0
- package/catalog/surface-manager-browser-lab.js +225 -0
- package/catalog/surface-manager-controller.d.ts +43 -0
- package/catalog/surface-manager-controller.js +290 -0
- package/catalog/surface-manager-layout-engines.d.ts +32 -0
- package/catalog/surface-manager-layout-engines.js +161 -0
- package/catalog/surface-manager-lazy-loading.d.ts +35 -0
- package/catalog/surface-manager-lazy-loading.js +173 -0
- package/catalog/surface-manager-materialization.d.ts +37 -0
- package/catalog/surface-manager-materialization.js +202 -0
- package/catalog/surface-manager-native-rmt-surfaces.d.ts +48 -0
- package/catalog/surface-manager-native-rmt-surfaces.js +325 -0
- package/catalog/surface-manager-overlay-bridge.d.ts +42 -0
- package/catalog/surface-manager-overlay-bridge.js +247 -0
- package/catalog/surface-manager-persistence.d.ts +37 -0
- package/catalog/surface-manager-persistence.js +178 -0
- package/catalog/surface-manager-quality-gates.d.ts +48 -0
- package/catalog/surface-manager-quality-gates.js +324 -0
- package/catalog/surface-manager-release-handoff.d.ts +47 -0
- package/catalog/surface-manager-release-handoff.js +274 -0
- package/catalog/surface-manager-remote-policy.d.ts +34 -0
- package/catalog/surface-manager-remote-policy.js +199 -0
- package/catalog/surface-manager-rmt-authoring.d.ts +44 -0
- package/catalog/surface-manager-rmt-authoring.js +368 -0
- package/catalog/surface-manager-route-lifecycle.d.ts +32 -0
- package/catalog/surface-manager-route-lifecycle.js +162 -0
- package/catalog/surface-manager-runtime-release-handoff.d.ts +36 -0
- package/catalog/surface-manager-runtime-release-handoff.js +245 -0
- package/catalog/surface-manager-side-panel-runtime.d.ts +46 -0
- package/catalog/surface-manager-side-panel-runtime.js +307 -0
- package/catalog/surface-manager-stack-policy.d.ts +32 -0
- package/catalog/surface-manager-stack-policy.js +169 -0
- package/catalog/surface-manager-window-runtime.d.ts +45 -0
- package/catalog/surface-manager-window-runtime.js +285 -0
- package/catalog/surface-manager-workbench-fixture.d.ts +50 -0
- package/catalog/surface-manager-workbench-fixture.js +315 -0
- package/catalog/type-exports-api.js +236 -0
- package/catalog/type-exports-builder.js +405 -0
- package/catalog/type-exports-catalog.js +394 -0
- package/catalog/type-exports-loader.js +266 -0
- package/catalog/type-exports-policy.js +461 -0
- package/catalog/type-exports-rmt.js +407 -0
- package/catalog/type-exports-vendor.js +365 -0
- package/catalog/type-exports.js +574 -0
- package/components/icon-packs/core.js +154 -0
- package/components/icon-packs/lucide.js +136 -0
- package/components/manifest.json +44 -0
- package/components/prism.d.ts +73 -0
- package/components/prism.js +300 -0
- package/components/turndown.d.ts +34 -0
- package/components/turndown.js +107 -0
- package/components/x-rmt-lifecycle-demo-build.d.ts +78 -0
- package/components/x-rmt-lifecycle-demo-build.js +1175 -0
- package/components/x-rmt-lifecycle-demo.d.ts +83 -0
- package/components/x-rmt-lifecycle-demo.js +1175 -0
- package/components/xalert.d.ts +42 -0
- package/components/xalert.js +538 -0
- package/components/xbutton.d.ts +127 -0
- package/components/xbutton.js +612 -0
- package/components/xcalendar.d.ts +39 -0
- package/components/xcalendar.js +338 -0
- package/components/xcards.d.ts +34 -0
- package/components/xcards.js +253 -0
- package/components/xcheckbox.d.ts +48 -0
- package/components/xcheckbox.js +448 -0
- package/components/xcode.d.ts +35 -0
- package/components/xcode.js +370 -0
- package/components/xdialog.d.ts +48 -0
- package/components/xdialog.js +763 -0
- package/components/xdrawer.d.ts +61 -0
- package/components/xdrawer.js +654 -0
- package/components/xfooter.d.ts +41 -0
- package/components/xfooter.js +351 -0
- package/components/xform.d.ts +43 -0
- package/components/xform.js +456 -0
- package/components/xheader.d.ts +68 -0
- package/components/xheader.js +1253 -0
- package/components/xhero.d.ts +42 -0
- package/components/xhero.js +475 -0
- package/components/xicon.d.ts +146 -0
- package/components/xicon.js +688 -0
- package/components/xinput.d.ts +37 -0
- package/components/xinput.js +444 -0
- package/components/xlightbox.d.ts +48 -0
- package/components/xlightbox.js +571 -0
- package/components/xlink.d.ts +63 -0
- package/components/xlink.js +565 -0
- package/components/xmasonry.d.ts +35 -0
- package/components/xmasonry.js +666 -0
- package/components/xmenu.d.ts +118 -0
- package/components/xmenu.js +1005 -0
- package/components/xmodal.d.ts +64 -0
- package/components/xmodal.js +831 -0
- package/components/xplayer.d.ts +57 -0
- package/components/xplayer.js +1748 -0
- package/components/xpopover.d.ts +54 -0
- package/components/xpopover.js +466 -0
- package/components/xprogress.d.ts +40 -0
- package/components/xprogress.js +345 -0
- package/components/xradio.d.ts +50 -0
- package/components/xradio.js +474 -0
- package/components/xrouter.d.ts +244 -0
- package/components/xrouter.js +1841 -0
- package/components/xsection.d.ts +34 -0
- package/components/xsection.js +253 -0
- package/components/xselect.d.ts +46 -0
- package/components/xselect.js +463 -0
- package/components/xsidepanel.d.ts +56 -0
- package/components/xsidepanel.js +728 -0
- package/components/xspinner.d.ts +38 -0
- package/components/xspinner.js +388 -0
- package/components/xstate.d.ts +137 -0
- package/components/xstate.js +493 -0
- package/components/xstatus.d.ts +41 -0
- package/components/xstatus.js +381 -0
- package/components/xsummary.d.ts +43 -0
- package/components/xsummary.js +293 -0
- package/components/xsurfacemanager-controller.d.ts +130 -0
- package/components/xsurfacemanager-controller.js +699 -0
- package/components/xsurfacemanager.d.ts +452 -0
- package/components/xsurfacemanager.js +3775 -0
- package/components/xsurfaceoverlay-bridge.d.ts +43 -0
- package/components/xsurfaceoverlay-bridge.js +238 -0
- package/components/xsurfacewindow.d.ts +50 -0
- package/components/xsurfacewindow.js +576 -0
- package/components/xtabs.d.ts +73 -0
- package/components/xtabs.js +611 -0
- package/components/xtend-public-types.d.ts +208 -0
- package/components/xtextarea.d.ts +46 -0
- package/components/xtextarea.js +451 -0
- package/components/xtheme.d.ts +253 -0
- package/components/xtheme.js +1438 -0
- package/components/xtoast.d.ts +39 -0
- package/components/xtoast.js +389 -0
- package/components/xtooltip.d.ts +53 -0
- package/components/xtooltip.js +432 -0
- package/components/xtype.d.ts +42 -0
- package/components/xtype.js +244 -0
- package/components/xutils.d.ts +164 -0
- package/components/xutils.js +496 -0
- package/components/xwriter.d.ts +67 -0
- package/components/xwriter.js +854 -0
- package/design-tokens/themes/enterprise-light.json +40 -0
- package/design-tokens/themes/xtend-signature.json +126 -0
- package/design-tokens/xtend-design-tokens.d.ts +95 -0
- package/design-tokens/xtend-design-tokens.js +395 -0
- package/design-tokens/xtheme-token-alias-layer.d.ts +84 -0
- package/design-tokens/xtheme-token-alias-layer.js +423 -0
- package/docs/.htaccess +51 -0
- package/docs/README.md +340 -0
- package/docs/XTend-ADR.md +221 -0
- package/docs/a11y-keyboard-smokes.md +62 -0
- package/docs/about.md +18 -0
- package/docs/api.md +157 -0
- package/docs/best-practices.md +76 -0
- package/docs/component-catalog-coverage.md +58 -0
- package/docs/component-lab.md +103 -0
- package/docs/component-long-tail-migration.md +41 -0
- package/docs/component-platform.md +159 -0
- package/docs/component-ux-app-authoring.md +130 -0
- package/docs/component-ux-authoring.md +96 -0
- package/docs/component-ux-gates.md +45 -0
- package/docs/components/x-rmt-lifecycle-demo-build.md +60 -0
- package/docs/components/xalert.md +81 -0
- package/docs/components/xbutton.md +103 -0
- package/docs/components/xcalendar.md +82 -0
- package/docs/components/xcards.md +128 -0
- package/docs/components/xcheckbox.md +102 -0
- package/docs/components/xcode.md +126 -0
- package/docs/components/xdialog.md +92 -0
- package/docs/components/xdrawer.md +84 -0
- package/docs/components/xfooter.md +126 -0
- package/docs/components/xform.md +128 -0
- package/docs/components/xheader.md +308 -0
- package/docs/components/xhero.md +142 -0
- package/docs/components/xicon.md +125 -0
- package/docs/components/xinput.md +129 -0
- package/docs/components/xlightbox.md +98 -0
- package/docs/components/xlink.md +109 -0
- package/docs/components/xmasonry.md +124 -0
- package/docs/components/xmenu.md +158 -0
- package/docs/components/xmodal.md +82 -0
- package/docs/components/xplayer.md +104 -0
- package/docs/components/xpopover.md +67 -0
- package/docs/components/xprogress.md +56 -0
- package/docs/components/xradio.md +103 -0
- package/docs/components/xrouter.md +260 -0
- package/docs/components/xsection.md +125 -0
- package/docs/components/xselect.md +105 -0
- package/docs/components/xsidepanel.md +30 -0
- package/docs/components/xspinner.md +102 -0
- package/docs/components/xstate.md +148 -0
- package/docs/components/xstatus.md +55 -0
- package/docs/components/xsummary.md +78 -0
- package/docs/components/xsurfacemanager.md +27 -0
- package/docs/components/xsurfacewindow.md +21 -0
- package/docs/components/xtabs.md +160 -0
- package/docs/components/xtextarea.md +98 -0
- package/docs/components/xtheme.md +167 -0
- package/docs/components/xtoast.md +62 -0
- package/docs/components/xtooltip.md +66 -0
- package/docs/components/xtype.md +82 -0
- package/docs/components/xutils.md +144 -0
- package/docs/components/xwriter.md +94 -0
- package/docs/components.md +117 -0
- package/docs/conditional-network-evidence-ci.md +38 -0
- package/docs/conditional-network-evidence.md +50 -0
- package/docs/core-migration-guide.md +110 -0
- package/docs/design-tokens.md +116 -0
- package/docs/docs-rmt-production-hardening.md +31 -0
- package/docs/enterprise-adoption.md +411 -0
- package/docs/enterprise-component-flex-release-handoff.md +129 -0
- package/docs/epic10-platform-gates.md +62 -0
- package/docs/epic10-release-handoff.md +81 -0
- package/docs/epic11-enterprise-ux-handoff.md +70 -0
- package/docs/epic12-rc0-handoff.md +61 -0
- package/docs/existing-component-metadata.md +67 -0
- package/docs/hydration-performance-closure.md +34 -0
- package/docs/hydration-policies.md +71 -0
- package/docs/index.php +1625 -0
- package/docs/known-residual-triage.md +22 -0
- package/docs/manifest-import-policy.md +79 -0
- package/docs/manifest.md +106 -0
- package/docs/menu.json +1190 -0
- package/docs/motion-contrast.md +67 -0
- package/docs/package-export-lock.md +44 -0
- package/docs/performance-measurements.md +106 -0
- package/docs/performance-regression.md +89 -0
- package/docs/performance.md +94 -0
- package/docs/previews/README.md +17 -0
- package/docs/prod-browser-csp-smokes.md +40 -0
- package/docs/public-component-types.md +79 -0
- package/docs/quick-start-guide.md +152 -0
- package/docs/rc0-adoption-guide.md +102 -0
- package/docs/rc0-gate-matrix.md +58 -0
- package/docs/rc1-gate-matrix-ci-handoff.md +56 -0
- package/docs/rc1-migration-notes.md +69 -0
- package/docs/rc1-readiness.md +46 -0
- package/docs/release-owner-acceptance.md +56 -0
- package/docs/release-report-pack-dry-run-evidence.md +39 -0
- package/docs/rmt-dsl-authoring-polish.md +122 -0
- package/docs/rmt-first-demo-app.md +77 -0
- package/docs/rmt-first-xtend-apps.md +105 -0
- package/docs/rmt-kernel-panic-recovery-incident-handoff.md +61 -0
- package/docs/rmt-kernel-security-hardening-migration.md +50 -0
- package/docs/rmt-kernel-trusted-output-authoring.md +69 -0
- package/docs/rmt-language-server.md +177 -0
- package/docs/rmt-lifecycle-demo.md +25 -0
- package/docs/rmt-linter.md +140 -0
- package/docs/rmt-production-readiness.md +63 -0
- package/docs/rmt-tooling-release-gates.md +77 -0
- package/docs/rmt-vnext-authoring.md +60 -0
- package/docs/rmt-vnext-cross-surface-events.md +68 -0
- package/docs/rmt-vnext-enterprise-mfe-handoff.md +70 -0
- package/docs/rmt-vnext-migration-notes.md +62 -0
- package/docs/rmt-vnext-release-handoff.md +69 -0
- package/docs/rmt-vnext-remote-surfaces.md +90 -0
- package/docs/rmt-vnext-surface-registry-enterprise.md +76 -0
- package/docs/screenreader-signals.md +56 -0
- package/docs/supply-chain-gates.md +100 -0
- package/docs/surface-manager-authoring-guide.md +94 -0
- package/docs/surface-manager-browser-lab.md +45 -0
- package/docs/surface-manager-component-lab.md +43 -0
- package/docs/surface-manager-controller.md +66 -0
- package/docs/surface-manager-layout-engines.md +32 -0
- package/docs/surface-manager-lazy-hydration.md +63 -0
- package/docs/surface-manager-migration-guide.md +94 -0
- package/docs/surface-manager-native-rmt-surfaces.md +38 -0
- package/docs/surface-manager-overlay-bridge.md +53 -0
- package/docs/surface-manager-persistence.md +30 -0
- package/docs/surface-manager-quality-gates.md +51 -0
- package/docs/surface-manager-release-handoff.md +68 -0
- package/docs/surface-manager-remote-policy.md +54 -0
- package/docs/surface-manager-rmt-authoring.md +86 -0
- package/docs/surface-manager-route-lifecycle.md +59 -0
- package/docs/surface-manager-runtime-release-handoff.md +69 -0
- package/docs/surface-manager-side-panel-runtime.md +36 -0
- package/docs/surface-manager-stack-policy.md +39 -0
- package/docs/surface-manager-window-runtime.md +47 -0
- package/docs/surface-manager-workbench-fixture.md +43 -0
- package/docs/third-party-design-authoring.md +406 -0
- package/docs/trusted-dom-boundary-browser-proof.md +32 -0
- package/docs/trusted-dom-sanitizing.md +110 -0
- package/docs/type-exports.md +61 -0
- package/docs/typescript-components.md +63 -0
- package/docs/utils/fabric-runtime.js +650 -0
- package/docs/utils/pageloader.js +2823 -0
- package/docs/utils/parsedown.php +298 -0
- package/docs/visual-browser-regression.md +83 -0
- package/docs/visual-owner-artifacts.md +46 -0
- package/docs/visual-snapshot-automation.md +87 -0
- package/docs/xtend-api-types.md +55 -0
- package/docs/xtend-builder-types.md +55 -0
- package/docs/xtend-catalog-types.md +44 -0
- package/docs/xtend-fabric-rmt-lane-mapping.md +143 -0
- package/docs/xtend-fabric.md +474 -0
- package/docs/xtend-loader-types.md +58 -0
- package/docs/xtend-loader.md +265 -0
- package/docs/xtend-policy-types.md +38 -0
- package/docs/xtend-rmt-types.md +39 -0
- package/docs/xtend-vendor-types.md +36 -0
- package/docs/xtendrmt-app-dsl.md +269 -0
- package/docs/xtendrmt-migration-guide.md +235 -0
- package/docs/xtendrmt-native-authoring.md +337 -0
- package/docs/xtendrmt-overview.md +89 -0
- package/docs/xtendrmt-parsedown-docs.rmt +956 -0
- package/docs/xtendrmt-parsedown-scheduling.md +301 -0
- package/docs/xtendrmt-runtime-bridge.md +155 -0
- package/fabric/hydration-policy.d.ts +27 -0
- package/fabric/hydration-policy.js +306 -0
- package/fabric/package.json +58 -0
- package/fabric/rmt-lane-mapping.d.ts +47 -0
- package/fabric/rmt-lane-mapping.js +504 -0
- package/fabric/xtend-fabric.d.ts +81 -0
- package/fabric/xtend-fabric.js +2669 -0
- package/fabric/xtend-policy-public-types.d.ts +135 -0
- package/package.json +8225 -0
- package/security/README.md +54 -0
- package/security/manifest-import-policy.d.ts +43 -0
- package/security/manifest-import-policy.js +260 -0
- package/security/supply-chain-gate-policy.d.ts +45 -0
- package/security/supply-chain-gate-policy.js +249 -0
- package/security/trusted-dom-policy.d.ts +36 -0
- package/security/trusted-dom-policy.js +316 -0
- package/tools/package.json +77 -0
- package/tools/rmt-editor/vscode/README.md +33 -0
- package/tools/rmt-editor/vscode/extension.d.ts +9 -0
- package/tools/rmt-editor/vscode/extension.js +55 -0
- package/tools/rmt-editor/vscode/language-configuration.json +28 -0
- package/tools/rmt-editor/vscode/package.json +83 -0
- package/tools/rmt-editor/vscode/snippets/rmt.code-snippets +243 -0
- package/tools/rmt-editor/vscode/syntaxes/rmt.tmLanguage.json +13 -0
- package/tools/rmt-editor/vscode/xtend-rmt-language-0.0.0-enterprise-readiness.vsix +0 -0
- package/tools/rmt-language/code-actions.d.ts +15 -0
- package/tools/rmt-language/code-actions.js +566 -0
- package/tools/rmt-language/completions.d.ts +22 -0
- package/tools/rmt-language/completions.js +475 -0
- package/tools/rmt-language/definitions.d.ts +13 -0
- package/tools/rmt-language/definitions.js +212 -0
- package/tools/rmt-language/diagnostics.d.ts +23 -0
- package/tools/rmt-language/diagnostics.js +486 -0
- package/tools/rmt-language/format-adapter.d.ts +16 -0
- package/tools/rmt-language/format-adapter.js +270 -0
- package/tools/rmt-language/hover.d.ts +12 -0
- package/tools/rmt-language/hover.js +326 -0
- package/tools/rmt-language/kernel-escalation.d.ts +122 -0
- package/tools/rmt-language/kernel-escalation.js +427 -0
- package/tools/rmt-language/kernel-panic-monitor.d.ts +176 -0
- package/tools/rmt-language/kernel-panic-monitor.js +674 -0
- package/tools/rmt-language/kernel-policy-parity.d.ts +142 -0
- package/tools/rmt-language/kernel-policy-parity.js +629 -0
- package/tools/rmt-language/kernel-recovery.d.ts +173 -0
- package/tools/rmt-language/kernel-recovery.js +666 -0
- package/tools/rmt-language/kernel-scheduler-failure.d.ts +136 -0
- package/tools/rmt-language/kernel-scheduler-failure.js +486 -0
- package/tools/rmt-language/kernel-security-regression.d.ts +154 -0
- package/tools/rmt-language/kernel-security-regression.js +465 -0
- package/tools/rmt-language/kernel-trust-authority.d.ts +120 -0
- package/tools/rmt-language/kernel-trust-authority.js +549 -0
- package/tools/rmt-language/parser.d.ts +14 -0
- package/tools/rmt-language/parser.js +111 -0
- package/tools/rmt-language/rmt-tooling-public-types.d.ts +179 -0
- package/tools/rmt-language/rules/boundary-policy.js +81 -0
- package/tools/rmt-language/rules/document-policy.js +65 -0
- package/tools/rmt-language/rules/index.js +29 -0
- package/tools/rmt-language/rules/route-policy.js +81 -0
- package/tools/rmt-language/rules/scheduler-policy.js +66 -0
- package/tools/rmt-language/rules/template-policy.js +130 -0
- package/tools/rmt-language/semantic-graph.d.ts +18 -0
- package/tools/rmt-language/semantic-graph.js +827 -0
- package/tools/rmt-language/snippets/README.md +17 -0
- package/tools/rmt-language/snippets/index.d.ts +17 -0
- package/tools/rmt-language/snippets/index.js +417 -0
- package/tools/rmt-language/snippets/rmt.code-snippets +243 -0
- package/tools/rmt-language/source-model.d.ts +14 -0
- package/tools/rmt-language/source-model.js +731 -0
- package/tools/rmt-language/symbols.d.ts +13 -0
- package/tools/rmt-language/symbols.js +183 -0
- package/tools/rmt-language/vnext-compatibility.d.ts +28 -0
- package/tools/rmt-language/vnext-compatibility.js +675 -0
- package/tools/rmt-language/vnext-compiler.d.ts +17 -0
- package/tools/rmt-language/vnext-compiler.js +716 -0
- package/tools/rmt-language/vnext-composition.d.ts +30 -0
- package/tools/rmt-language/vnext-composition.js +595 -0
- package/tools/rmt-language/vnext-conditions.d.ts +25 -0
- package/tools/rmt-language/vnext-conditions.js +474 -0
- package/tools/rmt-language/vnext-cross-surface-events.d.ts +30 -0
- package/tools/rmt-language/vnext-cross-surface-events.js +607 -0
- package/tools/rmt-language/vnext-degradation.d.ts +23 -0
- package/tools/rmt-language/vnext-degradation.js +428 -0
- package/tools/rmt-language/vnext-enterprise-fixtures.d.ts +28 -0
- package/tools/rmt-language/vnext-enterprise-fixtures.js +487 -0
- package/tools/rmt-language/vnext-enterprise-registry.d.ts +21 -0
- package/tools/rmt-language/vnext-enterprise-registry.js +495 -0
- package/tools/rmt-language/vnext-enterprise-release.d.ts +44 -0
- package/tools/rmt-language/vnext-enterprise-release.js +472 -0
- package/tools/rmt-language/vnext-event-governance.d.ts +29 -0
- package/tools/rmt-language/vnext-event-governance.js +488 -0
- package/tools/rmt-language/vnext-events.d.ts +44 -0
- package/tools/rmt-language/vnext-events.js +680 -0
- package/tools/rmt-language/vnext-import-resolver.d.ts +28 -0
- package/tools/rmt-language/vnext-import-resolver.js +642 -0
- package/tools/rmt-language/vnext-lifecycle.d.ts +22 -0
- package/tools/rmt-language/vnext-lifecycle.js +404 -0
- package/tools/rmt-language/vnext-parser.d.ts +21 -0
- package/tools/rmt-language/vnext-parser.js +1391 -0
- package/tools/rmt-language/vnext-regression.d.ts +25 -0
- package/tools/rmt-language/vnext-regression.js +394 -0
- package/tools/rmt-language/vnext-release.d.ts +29 -0
- package/tools/rmt-language/vnext-release.js +293 -0
- package/tools/rmt-language/vnext-remote-compatibility.d.ts +33 -0
- package/tools/rmt-language/vnext-remote-compatibility.js +892 -0
- package/tools/rmt-language/vnext-remote-compiler.d.ts +14 -0
- package/tools/rmt-language/vnext-remote-compiler.js +520 -0
- package/tools/rmt-language/vnext-remote-manifest.d.ts +33 -0
- package/tools/rmt-language/vnext-remote-manifest.js +538 -0
- package/tools/rmt-language/vnext-remote-security.d.ts +27 -0
- package/tools/rmt-language/vnext-remote-security.js +380 -0
- package/tools/rmt-language/vnext-remote-tooling.d.ts +25 -0
- package/tools/rmt-language/vnext-remote-tooling.js +805 -0
- package/tools/rmt-language/vnext-scheduler.d.ts +24 -0
- package/tools/rmt-language/vnext-scheduler.js +469 -0
- package/tools/rmt-language/vnext-security.d.ts +28 -0
- package/tools/rmt-language/vnext-security.js +597 -0
- package/tools/rmt-language/vnext-streaming.d.ts +28 -0
- package/tools/rmt-language/vnext-streaming.js +593 -0
- package/tools/rmt-language/vnext-surfaces.d.ts +24 -0
- package/tools/rmt-language/vnext-surfaces.js +406 -0
- package/tools/rmt-language/vnext-tooling.d.ts +25 -0
- package/tools/rmt-language/vnext-tooling.js +728 -0
- package/tools/rmt-language-server/protocol.d.ts +22 -0
- package/tools/rmt-language-server/protocol.js +352 -0
- package/tools/rmt-language-server/server.d.ts +15 -0
- package/tools/rmt-language-server/server.js +622 -0
- package/tools/rmt-linter/cli.d.ts +14 -0
- package/tools/rmt-linter/cli.js +450 -0
- package/tools/rmt-linter/reporter.d.ts +16 -0
- package/tools/rmt-linter/reporter.js +472 -0
- package/xtend-builder/README.md +83 -0
- package/xtend-builder/a11y/README.md +42 -0
- package/xtend-builder/a11y/component-a11y-profile.d.ts +14 -0
- package/xtend-builder/a11y/component-a11y-profile.js +314 -0
- package/xtend-builder/blueprints/README.md +105 -0
- package/xtend-builder/blueprints/component-blueprint.contract.d.ts +16 -0
- package/xtend-builder/blueprints/component-blueprint.contract.js +343 -0
- package/xtend-builder/builder-public-types.d.ts +234 -0
- package/xtend-builder/extensions/README.md +26 -0
- package/xtend-builder/extensions/component-extension-points.d.ts +11 -0
- package/xtend-builder/extensions/component-extension-points.js +277 -0
- package/xtend-builder/generators/README.md +149 -0
- package/xtend-builder/generators/component-files.d.ts +5 -0
- package/xtend-builder/generators/component-files.js +769 -0
- package/xtend-builder/generators/component-plan.d.ts +4 -0
- package/xtend-builder/generators/component-plan.js +104 -0
- package/xtend-builder/generators/registry.d.ts +6 -0
- package/xtend-builder/generators/registry.js +118 -0
- package/xtend-builder/generators/rmt-build.js +738 -0
- package/xtend-builder/generators/rmt-lifecycle-demo.js +922 -0
- package/xtend-builder/lib/cli.d.ts +9 -0
- package/xtend-builder/lib/cli.js +543 -0
- package/xtend-builder/lib/layout.d.ts +6 -0
- package/xtend-builder/lib/layout.js +153 -0
- package/xtend-builder/lib/package-resolver.js +25 -0
- package/xtend-builder/package.json +90 -0
- package/xtend-builder/performance/README.md +31 -0
- package/xtend-builder/performance/component-performance-profile.d.ts +11 -0
- package/xtend-builder/performance/component-performance-profile.js +347 -0
- package/xtend-builder/performance/component-ux-performance-contract.d.ts +27 -0
- package/xtend-builder/performance/component-ux-performance-contract.js +424 -0
- package/xtend-builder/preview/README.md +61 -0
- package/xtend-builder/preview/component-lab-ux-inspector.d.ts +20 -0
- package/xtend-builder/preview/component-lab-ux-inspector.js +448 -0
- package/xtend-builder/preview/component-lab.d.ts +14 -0
- package/xtend-builder/preview/component-lab.js +278 -0
- package/xtend-builder/preview/component-preview.d.ts +5 -0
- package/xtend-builder/preview/component-preview.js +160 -0
- package/xtend-builder/scaffold.config.d.ts +4 -0
- package/xtend-builder/scaffold.config.js +2056 -0
- package/xtend-builder/scaffold.d.ts +3 -0
- package/xtend-builder/scaffold.js +11 -0
- package/xtend-builder/templates/README.md +33 -0
- package/xtend-builder/templates/component/a11y.template.ts +11 -0
- package/xtend-builder/templates/component/component-suite.template.d.ts +2 -0
- package/xtend-builder/templates/component/component-suite.template.js +108 -0
- package/xtend-builder/templates/component/contract.template.ts +10 -0
- package/xtend-builder/templates/component/demo-plan.template.md +73 -0
- package/xtend-builder/templates/component/docs.template.md +301 -0
- package/xtend-builder/templates/component/fixture-data.template.ts +28 -0
- package/xtend-builder/templates/component/fixture.template.html +37 -0
- package/xtend-builder/templates/component/manifest-plan.template.json +22 -0
- package/xtend-builder/templates/component/performance.template.ts +13 -0
- package/xtend-builder/templates/component/rmt.template.ts +12 -0
- package/xtend-builder/templates/component/source.template.d.ts +2 -0
- package/xtend-builder/templates/component/source.template.js +137 -0
- package/xtend-builder/templates/component/source.template.ts +110 -0
- package/xtend-builder/templates/component/types.template.d.ts +423 -0
- package/xtend-builder/templates/loader.d.ts +4 -0
- package/xtend-builder/templates/loader.js +51 -0
- package/xtend-builder/templates/registry.d.ts +6 -0
- package/xtend-builder/templates/registry.js +119 -0
- package/xtend-builder/typing/README.md +130 -0
- package/xtend-builder/typing/component-contract-v2.d.ts +15 -0
- package/xtend-builder/typing/component-contract-v2.js +248 -0
- package/xtend-builder/typing/component-network-contract.d.ts +22 -0
- package/xtend-builder/typing/component-network-contract.js +478 -0
- package/xtend-builder/typing/component-shell-contract.d.ts +21 -0
- package/xtend-builder/typing/component-shell-contract.js +312 -0
- package/xtend-builder/typing/component-styling-contract.d.ts +22 -0
- package/xtend-builder/typing/component-styling-contract.js +301 -0
- package/xtend-builder/typing/component-types.d.ts +10 -0
- package/xtend-builder/typing/component-types.js +551 -0
- package/xtend-builder/typing/enterprise-component-flex-hardening-contract.d.ts +20 -0
- package/xtend-builder/typing/enterprise-component-flex-hardening-contract.js +332 -0
- package/xtend-builder/typing/feedback-status-ux-contract.d.ts +25 -0
- package/xtend-builder/typing/feedback-status-ux-contract.js +347 -0
- package/xtend-builder/typing/form-controls-ux-contract.d.ts +25 -0
- package/xtend-builder/typing/form-controls-ux-contract.js +357 -0
- package/xtend-builder/typing/layout-display-media-ux-contract.d.ts +25 -0
- package/xtend-builder/typing/layout-display-media-ux-contract.js +420 -0
- package/xtend-builder/typing/navigation-routing-ux-contract.d.ts +17 -0
- package/xtend-builder/typing/navigation-routing-ux-contract.js +297 -0
- package/xtend-builder/typing/overlay-interaction-ux-contract.d.ts +25 -0
- package/xtend-builder/typing/overlay-interaction-ux-contract.js +383 -0
- package/xtend-builder/typing/rmt-dsl-authoring-polish.d.ts +27 -0
- package/xtend-builder/typing/rmt-dsl-authoring-polish.js +419 -0
- package/xtend-builder/typing/rmt-shell-authoring-contract.d.ts +26 -0
- package/xtend-builder/typing/rmt-shell-authoring-contract.js +315 -0
- package/xtend-builder/utils/README.md +8 -0
- package/xtend-builder/utils/naming.d.ts +7 -0
- package/xtend-builder/utils/naming.js +36 -0
- package/xtend-builder/utils/validation.d.ts +5 -0
- package/xtend-builder/utils/validation.js +95 -0
- package/xtend-builder/wiring/README.md +46 -0
- package/xtend-builder/wiring/features.d.ts +5 -0
- package/xtend-builder/wiring/features.js +165 -0
- package/xtend-builder/wiring/hydration.d.ts +4 -0
- package/xtend-builder/wiring/hydration.js +44 -0
- package/xtend-builder/wiring/manifest.d.ts +5 -0
- package/xtend-builder/wiring/manifest.js +48 -0
- package/xtend-builder/workflows/README.md +47 -0
- package/xtend-builder/workflows/developer-workflow.d.ts +6 -0
- package/xtend-builder/workflows/developer-workflow.js +125 -0
- package/xtend-builder/writing/manifest-patcher.d.ts +49 -0
- package/xtend-builder/writing/manifest-patcher.js +391 -0
- package/xtend-builder/writing/write-plan.d.ts +148 -0
- package/xtend-builder/writing/write-plan.js +646 -0
- package/xtend-dev.d.ts +23 -0
- package/xtend-dev.js +4 -0
- package/xtend-loader.d.ts +201 -0
- package/xtend-loader.js +1704 -0
- package/xtend.css +402 -0
- package/xtendrmt/package.json +64 -0
- package/xtendrmt/rmt-core.d.ts +4452 -0
- package/xtendrmt/rmt-core.esm.js +25793 -0
- package/xtendrmt/rmt-first-demo-app.js +265 -0
- package/xtendrmt/rmt-first-demo-app.rmt +737 -0
- package/xtendrmt/rmt-lifecycle-demo.app.js +493 -0
- package/xtendrmt/rmt-lifecycle-demo.core.json +810 -0
- package/xtendrmt/rmt-lifecycle-demo.rmt +35 -0
- package/xtendrmt/rmt-lifecycle-demo.rmt-build.app.js +153 -0
- package/xtendrmt/rmt-lifecycle-demo.rmt-build.core.json +810 -0
- package/xtendrmt/rmt-lifecycle-demo.rmt-build.scaffold.json +202 -0
- package/xtendrmt/rmt-lifecycle-demo.scaffold.json +187 -0
- package/xtendrmt/rmt-manifest.json +548 -0
- package/xtendrmt/rmt-runtime.browser.js +26183 -0
- package/xtendrmt/rmt-runtime.esm.js +26214 -0
- package/xtendrmt/rmt-vnext-enterprise-mfe-demo.core.json +849 -0
- package/xtendrmt/rmt-vnext-enterprise-mfe-demo.rmt +50 -0
- package/xtendrmt/rmt-vnext-reference-demo.core.json +1069 -0
- package/xtendrmt/rmt-vnext-reference-demo.rmt +50 -0
- package/xtendrmt/rmt.schema.json +3145 -0
- package/xtendrmt/surface-workbench.js +316 -0
- package/xtendrmt/surface-workbench.rmt +762 -0
- package/xtendrmt/xtendrmt-bestcase-demo.core.json +1187 -0
- package/xtendrmt/xtendrmt-bestcase-demo.js +1728 -0
- package/xtendrmt/xtendrmt-bestcase-demo.rmt +57 -0
|
@@ -0,0 +1,1391 @@
|
|
|
1
|
+
const {
|
|
2
|
+
RMT_SOURCE_MODEL_WORKPACKAGE,
|
|
3
|
+
createRmtSourceModel
|
|
4
|
+
} = require('./source-model');
|
|
5
|
+
|
|
6
|
+
const RMT_VNEXT_AST_SCHEMA = 'xtend.rmt.vnext.ast.v1';
|
|
7
|
+
const RMT_VNEXT_PARSER_SCHEMA = 'xtend.rmt.vnext-parser.v1';
|
|
8
|
+
const RMT_VNEXT_PARSER_REPORT_SCHEMA = 'xtend.rmt.vnext-parser-report.v1';
|
|
9
|
+
const RMT_VNEXT_PARSER_WORKPACKAGE = 'WP-E15-04';
|
|
10
|
+
const RMT_VNEXT_PARSER_MODULE_PATH = 'tools/rmt-language/vnext-parser.js';
|
|
11
|
+
const RMT_VNEXT_PARSER_SUITE_PATH = 'tests/rmt-language/rmt_vnext_parser_suite.js';
|
|
12
|
+
const RMT_VNEXT_PARSER_PACKAGE_SCRIPT = 'npm run test:rmt-vnext-parser';
|
|
13
|
+
const RMT_VNEXT_SYNTAX_ERROR_CODE = 'rmt.vnext.syntax.error';
|
|
14
|
+
const RMT_VNEXT_CONTEXT_ERROR_CODE = 'rmt.vnext.syntax.context';
|
|
15
|
+
const RMT_FILE_FALLBACK_CODE = 'rmt.document.extension.fallback-used';
|
|
16
|
+
|
|
17
|
+
const RESERVED_WORDS = new Set([
|
|
18
|
+
'template',
|
|
19
|
+
'remote',
|
|
20
|
+
'surface',
|
|
21
|
+
'lane',
|
|
22
|
+
'weight',
|
|
23
|
+
'mount',
|
|
24
|
+
'hydrate',
|
|
25
|
+
'suspend',
|
|
26
|
+
'resume',
|
|
27
|
+
'invalidate',
|
|
28
|
+
'dispose',
|
|
29
|
+
'prewarm',
|
|
30
|
+
'recycle',
|
|
31
|
+
'detach',
|
|
32
|
+
'reattach',
|
|
33
|
+
'stream',
|
|
34
|
+
'from',
|
|
35
|
+
'endpoint',
|
|
36
|
+
'sse',
|
|
37
|
+
'worker',
|
|
38
|
+
'when',
|
|
39
|
+
'slot',
|
|
40
|
+
'import',
|
|
41
|
+
'on',
|
|
42
|
+
'action',
|
|
43
|
+
'trust',
|
|
44
|
+
'boundary',
|
|
45
|
+
'sanitize',
|
|
46
|
+
'true',
|
|
47
|
+
'false',
|
|
48
|
+
'null'
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
const IMPERATIVE_WORDS = new Set([
|
|
52
|
+
'if',
|
|
53
|
+
'else',
|
|
54
|
+
'for',
|
|
55
|
+
'while',
|
|
56
|
+
'switch',
|
|
57
|
+
'case',
|
|
58
|
+
'try',
|
|
59
|
+
'catch',
|
|
60
|
+
'finally',
|
|
61
|
+
'function',
|
|
62
|
+
'return',
|
|
63
|
+
'await',
|
|
64
|
+
'async',
|
|
65
|
+
'class',
|
|
66
|
+
'new',
|
|
67
|
+
'eval'
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
const LIFECYCLE_OPERATIONS = new Set([
|
|
71
|
+
'mount',
|
|
72
|
+
'hydrate',
|
|
73
|
+
'suspend',
|
|
74
|
+
'resume',
|
|
75
|
+
'invalidate',
|
|
76
|
+
'dispose',
|
|
77
|
+
'prewarm',
|
|
78
|
+
'recycle',
|
|
79
|
+
'detach',
|
|
80
|
+
'reattach'
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
const SOURCE_KINDS = new Set(['endpoint', 'sse', 'worker']);
|
|
84
|
+
const COMPARISON_OPERATORS = new Set(['==', '!=', '>', '>=', '<', '<=']);
|
|
85
|
+
|
|
86
|
+
function normalizeSourceInput(input = {}, options = {}) {
|
|
87
|
+
if (typeof input === 'string') {
|
|
88
|
+
return {
|
|
89
|
+
text: input,
|
|
90
|
+
uri: options.uri,
|
|
91
|
+
filePath: options.filePath,
|
|
92
|
+
version: options.version
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
text: String(input.text || ''),
|
|
98
|
+
uri: input.uri || options.uri,
|
|
99
|
+
filePath: input.filePath || options.filePath,
|
|
100
|
+
version: input.version === undefined ? options.version : input.version,
|
|
101
|
+
languageId: input.languageId || options.languageId || 'rmt'
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function createRange(sourceModel, startOffset, endOffset) {
|
|
106
|
+
return sourceModel.rangeForOffsets(startOffset, endOffset);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function createToken(type, value, startOffset, endOffset, extra = {}) {
|
|
110
|
+
return {
|
|
111
|
+
type,
|
|
112
|
+
value,
|
|
113
|
+
startOffset,
|
|
114
|
+
endOffset,
|
|
115
|
+
...extra
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function createLexerDiagnostic(sourceModel, input = {}) {
|
|
120
|
+
return sourceModel.createDiagnostic({
|
|
121
|
+
schema: input.schema,
|
|
122
|
+
code: input.code || RMT_VNEXT_SYNTAX_ERROR_CODE,
|
|
123
|
+
severity: input.severity || 'error',
|
|
124
|
+
message: input.message || 'Invalid RMT vNext syntax',
|
|
125
|
+
startOffset: input.startOffset,
|
|
126
|
+
endOffset: input.endOffset,
|
|
127
|
+
range: input.range,
|
|
128
|
+
workpackage: RMT_VNEXT_PARSER_WORKPACKAGE
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function createFilePolicyDiagnostics(sourceModel) {
|
|
133
|
+
if (!sourceModel || !sourceModel.filePolicy || !sourceModel.filePolicy.fallback) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return [
|
|
138
|
+
sourceModel.createDiagnostic({
|
|
139
|
+
code: RMT_FILE_FALLBACK_CODE,
|
|
140
|
+
severity: 'warning',
|
|
141
|
+
message: `${sourceModel.filePolicy.extension} is only an RMT fallback file type. New vNext documents should use .rmt.`,
|
|
142
|
+
range: sourceModel.lineRange(0),
|
|
143
|
+
workpackage: RMT_VNEXT_PARSER_WORKPACKAGE
|
|
144
|
+
})
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function isIdentifierStart(character) {
|
|
149
|
+
return /[A-Za-z_]/.test(character);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function isIdentifierPart(character) {
|
|
153
|
+
return /[A-Za-z0-9_-]/.test(character);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function tokenizeVNextSource(sourceModel) {
|
|
157
|
+
const text = sourceModel.text;
|
|
158
|
+
const tokens = [];
|
|
159
|
+
const diagnostics = [];
|
|
160
|
+
let index = 0;
|
|
161
|
+
|
|
162
|
+
function pushDiagnostic(input) {
|
|
163
|
+
diagnostics.push(createLexerDiagnostic(sourceModel, input));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
while (index < text.length) {
|
|
167
|
+
const start = index;
|
|
168
|
+
const character = text[index];
|
|
169
|
+
|
|
170
|
+
if (character === ' ' || character === '\t' || character === '\f' || character === '\v') {
|
|
171
|
+
index += 1;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (character === '\r' || character === '\n') {
|
|
176
|
+
if (character === '\r' && text[index + 1] === '\n') {
|
|
177
|
+
index += 2;
|
|
178
|
+
} else {
|
|
179
|
+
index += 1;
|
|
180
|
+
}
|
|
181
|
+
tokens.push(createToken('newline', '\n', start, index));
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (character === '/' && text[index + 1] === '/') {
|
|
186
|
+
index += 2;
|
|
187
|
+
while (index < text.length && text[index] !== '\n' && text[index] !== '\r') {
|
|
188
|
+
index += 1;
|
|
189
|
+
}
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (character === '/' && text[index + 1] === '*') {
|
|
194
|
+
index += 2;
|
|
195
|
+
while (index < text.length && !(text[index] === '*' && text[index + 1] === '/')) {
|
|
196
|
+
index += 1;
|
|
197
|
+
}
|
|
198
|
+
if (index >= text.length) {
|
|
199
|
+
pushDiagnostic({
|
|
200
|
+
message: 'Unterminated block comment.',
|
|
201
|
+
startOffset: start,
|
|
202
|
+
endOffset: text.length
|
|
203
|
+
});
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
index += 2;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (character === '"') {
|
|
211
|
+
index += 1;
|
|
212
|
+
while (index < text.length) {
|
|
213
|
+
if (text[index] === '\\') {
|
|
214
|
+
index += 2;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (text[index] === '"') {
|
|
218
|
+
index += 1;
|
|
219
|
+
const raw = text.slice(start, index);
|
|
220
|
+
try {
|
|
221
|
+
tokens.push(createToken('string', JSON.parse(raw), start, index, { raw }));
|
|
222
|
+
} catch (error) {
|
|
223
|
+
pushDiagnostic({
|
|
224
|
+
message: error && error.message ? error.message : 'Invalid string literal.',
|
|
225
|
+
startOffset: start,
|
|
226
|
+
endOffset: index
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
index += 1;
|
|
232
|
+
}
|
|
233
|
+
if (index >= text.length && text[index - 1] !== '"') {
|
|
234
|
+
pushDiagnostic({
|
|
235
|
+
message: 'Unterminated string literal.',
|
|
236
|
+
startOffset: start,
|
|
237
|
+
endOffset: text.length
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (character === '`') {
|
|
244
|
+
index += 1;
|
|
245
|
+
while (index < text.length && text[index] !== '`') {
|
|
246
|
+
index += 1;
|
|
247
|
+
}
|
|
248
|
+
if (text[index] !== '`') {
|
|
249
|
+
pushDiagnostic({
|
|
250
|
+
message: 'Unterminated escaped identifier.',
|
|
251
|
+
startOffset: start,
|
|
252
|
+
endOffset: text.length
|
|
253
|
+
});
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
index += 1;
|
|
257
|
+
tokens.push(createToken('identifier', text.slice(start + 1, index - 1), start, index, { escaped: true }));
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (/[0-9]/.test(character)) {
|
|
262
|
+
index += 1;
|
|
263
|
+
while (index < text.length && /[0-9]/.test(text[index])) {
|
|
264
|
+
index += 1;
|
|
265
|
+
}
|
|
266
|
+
tokens.push(createToken('integer', Number(text.slice(start, index)), start, index, { raw: text.slice(start, index) }));
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (isIdentifierStart(character)) {
|
|
271
|
+
index += 1;
|
|
272
|
+
while (index < text.length && isIdentifierPart(text[index])) {
|
|
273
|
+
index += 1;
|
|
274
|
+
}
|
|
275
|
+
tokens.push(createToken('identifier', text.slice(start, index), start, index));
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const twoCharacter = text.slice(index, index + 2);
|
|
280
|
+
if (['->', '==', '!=', '>=', '<=', '&&', '||'].includes(twoCharacter)) {
|
|
281
|
+
index += 2;
|
|
282
|
+
tokens.push(createToken('symbol', twoCharacter, start, index));
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if ('{}().;!<>'.includes(character)) {
|
|
287
|
+
index += 1;
|
|
288
|
+
tokens.push(createToken('symbol', character, start, index));
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
pushDiagnostic({
|
|
293
|
+
message: `Unexpected character "${character}".`,
|
|
294
|
+
startOffset: start,
|
|
295
|
+
endOffset: start + 1
|
|
296
|
+
});
|
|
297
|
+
index += 1;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
tokens.push(createToken('eof', '<eof>', text.length, text.length));
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
tokens,
|
|
304
|
+
diagnostics
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
class VNextParser {
|
|
309
|
+
constructor(sourceModel, tokens, diagnostics = []) {
|
|
310
|
+
this.sourceModel = sourceModel;
|
|
311
|
+
this.tokens = tokens;
|
|
312
|
+
this.diagnostics = diagnostics.slice();
|
|
313
|
+
this.index = 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
current() {
|
|
317
|
+
return this.tokens[this.index] || this.tokens[this.tokens.length - 1];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
previous() {
|
|
321
|
+
return this.tokens[Math.max(0, this.index - 1)] || this.current();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
isAtEnd() {
|
|
325
|
+
return this.current().type === 'eof';
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
consume() {
|
|
329
|
+
const token = this.current();
|
|
330
|
+
if (!this.isAtEnd()) {
|
|
331
|
+
this.index += 1;
|
|
332
|
+
}
|
|
333
|
+
return token;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
matches(value) {
|
|
337
|
+
const token = this.current();
|
|
338
|
+
return token && token.value === value;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
match(value) {
|
|
342
|
+
if (!this.matches(value)) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
return this.consume();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
matchSeparator() {
|
|
349
|
+
const token = this.current();
|
|
350
|
+
if (token.type === 'newline' || token.value === ';') {
|
|
351
|
+
return this.consume();
|
|
352
|
+
}
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
skipSeparators() {
|
|
357
|
+
while (this.matchSeparator()) {
|
|
358
|
+
// keep consuming
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
isIdentifierToken(token) {
|
|
363
|
+
return token
|
|
364
|
+
&& token.type === 'identifier'
|
|
365
|
+
&& (token.escaped || !RESERVED_WORDS.has(token.value));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
addDiagnostic(token, message, code = RMT_VNEXT_SYNTAX_ERROR_CODE) {
|
|
369
|
+
const currentToken = token || this.current();
|
|
370
|
+
this.diagnostics.push(createLexerDiagnostic(this.sourceModel, {
|
|
371
|
+
code,
|
|
372
|
+
message,
|
|
373
|
+
startOffset: currentToken.startOffset,
|
|
374
|
+
endOffset: Math.max(currentToken.endOffset, currentToken.startOffset + 1)
|
|
375
|
+
}));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
createNode(type, startToken, endToken, fields = {}) {
|
|
379
|
+
const start = startToken ? startToken.startOffset : 0;
|
|
380
|
+
const end = endToken ? endToken.endOffset : start;
|
|
381
|
+
return {
|
|
382
|
+
type,
|
|
383
|
+
range: createRange(this.sourceModel, start, end),
|
|
384
|
+
...fields
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
parseDocument() {
|
|
389
|
+
const body = [];
|
|
390
|
+
this.skipSeparators();
|
|
391
|
+
|
|
392
|
+
while (!this.isAtEnd()) {
|
|
393
|
+
if (this.matches('import')) {
|
|
394
|
+
body.push(this.parseImportDeclaration());
|
|
395
|
+
} else if (this.matches('template')) {
|
|
396
|
+
body.push(this.parseTemplateDeclaration());
|
|
397
|
+
} else if (this.matches('remote')) {
|
|
398
|
+
body.push(this.parseRemoteSurfaceDeclaration());
|
|
399
|
+
} else if (this.matches('surface')) {
|
|
400
|
+
body.push(this.parseSurfaceDeclaration(null));
|
|
401
|
+
} else if (LIFECYCLE_OPERATIONS.has(this.current().value) || this.matches('stream')) {
|
|
402
|
+
this.addDiagnostic(this.current(), 'Lifecycle and stream statements must be inside a lane or slot.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
403
|
+
this.skipStatementOrBlock();
|
|
404
|
+
} else {
|
|
405
|
+
this.reportUnexpectedTopLevel();
|
|
406
|
+
}
|
|
407
|
+
this.skipSeparators();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const documentNode = {
|
|
411
|
+
schema: RMT_VNEXT_AST_SCHEMA,
|
|
412
|
+
type: 'RmtVNextDocument',
|
|
413
|
+
body,
|
|
414
|
+
range: createRange(this.sourceModel, 0, this.sourceModel.length)
|
|
415
|
+
};
|
|
416
|
+
assignAstPointers(documentNode, '');
|
|
417
|
+
documentNode.imports = body.filter((node) => node.type === 'RmtImportDeclaration');
|
|
418
|
+
documentNode.templates = body.filter((node) => node.type === 'RmtTemplateDeclaration');
|
|
419
|
+
documentNode.surfaces = body.filter((node) => node.type === 'RmtSurfaceDeclaration');
|
|
420
|
+
documentNode.remoteSurfaces = body.filter((node) => node.type === 'RmtRemoteSurfaceDeclaration');
|
|
421
|
+
return documentNode;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
reportUnexpectedTopLevel() {
|
|
425
|
+
const token = this.current();
|
|
426
|
+
if (IMPERATIVE_WORDS.has(token.value)) {
|
|
427
|
+
this.addDiagnostic(token, `Imperative keyword "${token.value}" is not part of RMT vNext.`, RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
428
|
+
} else {
|
|
429
|
+
this.addDiagnostic(token, `Unexpected top-level token "${token.value}".`);
|
|
430
|
+
}
|
|
431
|
+
this.skipStatementOrBlock();
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
parseImportDeclaration() {
|
|
435
|
+
const start = this.expectValue('import', 'Expected import declaration.');
|
|
436
|
+
const pathToken = this.current();
|
|
437
|
+
let importPath = null;
|
|
438
|
+
|
|
439
|
+
if (pathToken.type === 'string') {
|
|
440
|
+
importPath = pathToken.value;
|
|
441
|
+
this.consume();
|
|
442
|
+
} else {
|
|
443
|
+
this.addDiagnostic(pathToken, 'Import paths must be static strings.');
|
|
444
|
+
this.consume();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
this.consumeStatementEnd('Expected statement end after import.');
|
|
448
|
+
const end = this.previous();
|
|
449
|
+
|
|
450
|
+
return this.createNode('RmtImportDeclaration', start, end, {
|
|
451
|
+
path: importPath,
|
|
452
|
+
mode: importPath && importPath.includes('*') ? 'static_glob' : 'static_file'
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
parseTemplateDeclaration() {
|
|
457
|
+
const start = this.expectValue('template', 'Expected template declaration.');
|
|
458
|
+
const name = this.parseQualifiedIdentifier('Expected template identifier.');
|
|
459
|
+
const body = this.parseBlock(() => {
|
|
460
|
+
if (this.matches('import')) {
|
|
461
|
+
return this.parseImportDeclaration();
|
|
462
|
+
}
|
|
463
|
+
if (this.matches('surface')) {
|
|
464
|
+
return this.parseSurfaceDeclaration(name && name.value);
|
|
465
|
+
}
|
|
466
|
+
this.addDiagnostic(this.current(), 'Templates may contain imports and surfaces only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
467
|
+
this.skipStatementOrBlock();
|
|
468
|
+
return null;
|
|
469
|
+
});
|
|
470
|
+
const end = body.endToken || this.previous();
|
|
471
|
+
|
|
472
|
+
return this.createNode('RmtTemplateDeclaration', start, end, {
|
|
473
|
+
name: name && name.value,
|
|
474
|
+
nameNode: name,
|
|
475
|
+
body: body.items
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
parseSurfaceDeclaration(templateName) {
|
|
480
|
+
const start = this.expectValue('surface', 'Expected surface declaration.');
|
|
481
|
+
const name = this.parseQualifiedIdentifier('Expected surface identifier.');
|
|
482
|
+
const body = this.parseBlock(() => {
|
|
483
|
+
if (this.matches('lane')) {
|
|
484
|
+
return this.parseLaneDeclaration(templateName, name && name.value);
|
|
485
|
+
}
|
|
486
|
+
this.addDiagnostic(this.current(), 'Surfaces may contain lanes only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
487
|
+
this.skipStatementOrBlock();
|
|
488
|
+
return null;
|
|
489
|
+
});
|
|
490
|
+
const end = body.endToken || this.previous();
|
|
491
|
+
|
|
492
|
+
return this.createNode('RmtSurfaceDeclaration', start, end, {
|
|
493
|
+
name: name && name.value,
|
|
494
|
+
nameNode: name,
|
|
495
|
+
body: body.items
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
parseRemoteSurfaceDeclaration() {
|
|
500
|
+
const start = this.expectValue('remote', 'Expected remote surface declaration.');
|
|
501
|
+
this.expectValue('surface', 'Expected surface keyword after remote.');
|
|
502
|
+
const name = this.parseQualifiedIdentifierAllowReserved('Expected remote surface identifier.');
|
|
503
|
+
this.expectValue('from', 'Expected from in remote surface declaration.');
|
|
504
|
+
this.expectValue('remote', 'Expected remote keyword after from.');
|
|
505
|
+
const remoteToken = this.current();
|
|
506
|
+
let remoteId = null;
|
|
507
|
+
if (remoteToken.type === 'string') {
|
|
508
|
+
remoteId = remoteToken.value;
|
|
509
|
+
this.consume();
|
|
510
|
+
} else {
|
|
511
|
+
this.addDiagnostic(remoteToken, 'Remote id must be a static string.');
|
|
512
|
+
this.consume();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const body = this.parseBlock(() => this.parseRemoteSurfaceItem(name && name.value));
|
|
516
|
+
const end = body.endToken || this.previous();
|
|
517
|
+
|
|
518
|
+
return this.createNode('RmtRemoteSurfaceDeclaration', start, end, {
|
|
519
|
+
name: name && name.value,
|
|
520
|
+
nameNode: name,
|
|
521
|
+
remoteId,
|
|
522
|
+
body: body.items
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
parseRemoteSurfaceItem(surfaceName) {
|
|
527
|
+
if (this.matches('owner')) return this.parseRemoteOwnerClause();
|
|
528
|
+
if (this.matches('version')) return this.parseRemoteStringClause('version', 'RmtRemoteVersionClause', 'Expected remote version string.');
|
|
529
|
+
if (this.matches('origin')) return this.parseRemoteStringClause('origin', 'RmtRemoteOriginClause', 'Expected remote origin string.');
|
|
530
|
+
if (this.matches('integrity')) return this.parseRemoteIntegrityClause();
|
|
531
|
+
if (this.matches('trust')) return this.parseRemoteTrustBoundaryClause();
|
|
532
|
+
if (this.matches('fallback')) return this.parseRemoteFallbackClause();
|
|
533
|
+
if (this.matches('exposes')) return this.parseRemoteExposeClause(surfaceName);
|
|
534
|
+
if (this.matches('emits') || this.matches('consumes')) return this.parseRemoteEventClause(surfaceName);
|
|
535
|
+
|
|
536
|
+
this.addDiagnostic(this.current(), 'Remote surfaces may contain owner, version, origin, integrity, trust boundary, fallback, exposes, emits and consumes clauses only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
537
|
+
this.skipStatementOrBlock();
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
parseRemoteOwnerClause() {
|
|
542
|
+
const start = this.expectValue('owner', 'Expected owner clause.');
|
|
543
|
+
let ownerKind = 'team';
|
|
544
|
+
if (this.matches('team')) {
|
|
545
|
+
ownerKind = this.consume().value;
|
|
546
|
+
}
|
|
547
|
+
const ownerToken = this.current();
|
|
548
|
+
let ownerId = null;
|
|
549
|
+
if (ownerToken.type === 'string') {
|
|
550
|
+
ownerId = ownerToken.value;
|
|
551
|
+
this.consume();
|
|
552
|
+
} else {
|
|
553
|
+
this.addDiagnostic(ownerToken, 'Remote owner must be a static string.');
|
|
554
|
+
this.consume();
|
|
555
|
+
}
|
|
556
|
+
this.consumeStatementEnd('Expected statement end after owner clause.');
|
|
557
|
+
const end = this.previous();
|
|
558
|
+
|
|
559
|
+
return this.createNode('RmtRemoteOwnerClause', start, end, {
|
|
560
|
+
kind: ownerKind,
|
|
561
|
+
id: ownerId
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
parseRemoteStringClause(keyword, nodeType, message) {
|
|
566
|
+
const start = this.expectValue(keyword, `Expected ${keyword} clause.`);
|
|
567
|
+
const valueToken = this.current();
|
|
568
|
+
let value = null;
|
|
569
|
+
if (valueToken.type === 'string') {
|
|
570
|
+
value = valueToken.value;
|
|
571
|
+
this.consume();
|
|
572
|
+
} else {
|
|
573
|
+
this.addDiagnostic(valueToken, message);
|
|
574
|
+
this.consume();
|
|
575
|
+
}
|
|
576
|
+
this.consumeStatementEnd(`Expected statement end after ${keyword} clause.`);
|
|
577
|
+
const end = this.previous();
|
|
578
|
+
|
|
579
|
+
return this.createNode(nodeType, start, end, {
|
|
580
|
+
value
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
parseRemoteIntegrityClause() {
|
|
585
|
+
const start = this.expectValue('integrity', 'Expected integrity clause.');
|
|
586
|
+
const algorithm = this.parseQualifiedIdentifierAllowReserved('Expected integrity algorithm.');
|
|
587
|
+
const digestToken = this.current();
|
|
588
|
+
let digest = null;
|
|
589
|
+
if (digestToken.type === 'string') {
|
|
590
|
+
digest = digestToken.value;
|
|
591
|
+
this.consume();
|
|
592
|
+
} else {
|
|
593
|
+
this.addDiagnostic(digestToken, 'Integrity digest must be a static string.');
|
|
594
|
+
this.consume();
|
|
595
|
+
}
|
|
596
|
+
this.consumeStatementEnd('Expected statement end after integrity clause.');
|
|
597
|
+
const end = this.previous();
|
|
598
|
+
|
|
599
|
+
return this.createNode('RmtRemoteIntegrityClause', start, end, {
|
|
600
|
+
algorithm: algorithm && algorithm.value,
|
|
601
|
+
algorithmNode: algorithm,
|
|
602
|
+
digest
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
parseRemoteTrustBoundaryClause() {
|
|
607
|
+
const start = this.expectValue('trust', 'Expected trust boundary clause.');
|
|
608
|
+
this.expectValue('boundary', 'Expected boundary keyword in remote trust clause.');
|
|
609
|
+
const boundaryToken = this.current();
|
|
610
|
+
let boundary = null;
|
|
611
|
+
if (boundaryToken.type === 'string') {
|
|
612
|
+
boundary = boundaryToken.value;
|
|
613
|
+
this.consume();
|
|
614
|
+
} else {
|
|
615
|
+
this.addDiagnostic(boundaryToken, 'Remote trust boundary must be a static string.');
|
|
616
|
+
this.consume();
|
|
617
|
+
}
|
|
618
|
+
this.consumeStatementEnd('Expected statement end after remote trust boundary clause.');
|
|
619
|
+
const end = this.previous();
|
|
620
|
+
|
|
621
|
+
return this.createNode('RmtRemoteTrustBoundaryClause', start, end, {
|
|
622
|
+
boundary
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
parseRemoteFallbackClause() {
|
|
627
|
+
const start = this.expectValue('fallback', 'Expected fallback clause.');
|
|
628
|
+
this.expectValue('surface', 'Expected surface keyword in fallback clause.');
|
|
629
|
+
const ref = this.parseQualifiedIdentifierAllowReserved('Expected fallback surface identifier.');
|
|
630
|
+
this.consumeStatementEnd('Expected statement end after fallback clause.');
|
|
631
|
+
const end = this.previous();
|
|
632
|
+
|
|
633
|
+
return this.createNode('RmtRemoteFallbackClause', start, end, {
|
|
634
|
+
kind: 'surface',
|
|
635
|
+
ref: ref && ref.value,
|
|
636
|
+
refNode: ref
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
parseRemoteExposeClause(surfaceName) {
|
|
641
|
+
const start = this.expectValue('exposes', 'Expected exposes clause.');
|
|
642
|
+
this.expectValue('lane', 'Expected lane keyword in exposes clause.');
|
|
643
|
+
const lane = this.parseQualifiedIdentifierAllowReserved('Expected exposed lane identifier.');
|
|
644
|
+
this.expectValue('->', 'Expected -> in exposes clause.');
|
|
645
|
+
const target = this.parseRemoteShellTarget('Expected shell target in exposes clause.');
|
|
646
|
+
this.consumeStatementEnd('Expected statement end after exposes clause.');
|
|
647
|
+
const end = this.previous();
|
|
648
|
+
|
|
649
|
+
return this.createNode('RmtRemoteExposeClause', start, end, {
|
|
650
|
+
surface: surfaceName,
|
|
651
|
+
lane: lane && lane.value,
|
|
652
|
+
laneNode: lane,
|
|
653
|
+
target
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
parseRemoteEventClause(surfaceName) {
|
|
658
|
+
const start = this.consume();
|
|
659
|
+
const kind = start.value;
|
|
660
|
+
const event = this.parseQualifiedIdentifierAllowReserved('Expected remote event identifier.');
|
|
661
|
+
const body = this.parseBlock(() => this.parseRemoteEventItem(kind));
|
|
662
|
+
const end = body.endToken || this.previous();
|
|
663
|
+
|
|
664
|
+
return this.createNode('RmtRemoteEventClause', start, end, {
|
|
665
|
+
surface: surfaceName,
|
|
666
|
+
kind,
|
|
667
|
+
event: event && event.value,
|
|
668
|
+
eventNode: event,
|
|
669
|
+
body: body.items
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
parseRemoteEventItem(kind) {
|
|
674
|
+
if (this.matches('owner')) return this.parseRemoteOwnerClause();
|
|
675
|
+
if (this.matches('direction')) return this.parseRemoteEventDirectionClause(kind);
|
|
676
|
+
if (this.matches('lane')) return this.parseRemoteEventLaneClause();
|
|
677
|
+
if (this.matches('from')) return this.parseRemoteEventFromClause();
|
|
678
|
+
if (this.matches('payload')) return this.parseRemoteStringClause('payload', 'RmtRemoteEventPayloadClause', 'Expected event payload schema string.');
|
|
679
|
+
|
|
680
|
+
this.addDiagnostic(this.current(), 'Remote event clauses may contain owner, direction, lane, from and payload only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
681
|
+
this.skipStatementOrBlock();
|
|
682
|
+
return null;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
parseRemoteEventDirectionClause(kind) {
|
|
686
|
+
const start = this.expectValue('direction', 'Expected direction clause.');
|
|
687
|
+
const token = this.current();
|
|
688
|
+
let direction = null;
|
|
689
|
+
if (token.value === 'outbound' || token.value === 'inbound') {
|
|
690
|
+
direction = token.value;
|
|
691
|
+
this.consume();
|
|
692
|
+
} else {
|
|
693
|
+
this.addDiagnostic(token, 'Event direction must be outbound or inbound.');
|
|
694
|
+
this.consume();
|
|
695
|
+
}
|
|
696
|
+
this.consumeStatementEnd('Expected statement end after direction clause.');
|
|
697
|
+
const end = this.previous();
|
|
698
|
+
|
|
699
|
+
return this.createNode('RmtRemoteEventDirectionClause', start, end, {
|
|
700
|
+
direction: direction || (kind === 'emits' ? 'outbound' : 'inbound')
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
parseRemoteEventLaneClause() {
|
|
705
|
+
const start = this.expectValue('lane', 'Expected lane clause.');
|
|
706
|
+
const lane = this.parseQualifiedIdentifierAllowReserved('Expected event lane identifier.');
|
|
707
|
+
this.consumeStatementEnd('Expected statement end after lane clause.');
|
|
708
|
+
const end = this.previous();
|
|
709
|
+
|
|
710
|
+
return this.createNode('RmtRemoteEventLaneClause', start, end, {
|
|
711
|
+
lane: lane && lane.value,
|
|
712
|
+
laneNode: lane
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
parseRemoteEventFromClause() {
|
|
717
|
+
const start = this.expectValue('from', 'Expected from clause.');
|
|
718
|
+
const source = this.parseRemoteShellTarget('Expected event source scope.');
|
|
719
|
+
this.consumeStatementEnd('Expected statement end after from clause.');
|
|
720
|
+
const end = this.previous();
|
|
721
|
+
|
|
722
|
+
return this.createNode('RmtRemoteEventFromClause', start, end, {
|
|
723
|
+
source
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
parseRemoteShellTarget(message) {
|
|
728
|
+
const target = this.parseQualifiedIdentifierAllowReserved(message || 'Expected shell target.');
|
|
729
|
+
let ref = target && target.value;
|
|
730
|
+
if (target && target.value && this.current().type === 'string') {
|
|
731
|
+
ref = `${target.value}:${this.current().value}`;
|
|
732
|
+
this.consume();
|
|
733
|
+
} else if (target && target.value === 'shell.session') {
|
|
734
|
+
ref = 'shell.session:current';
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
return {
|
|
738
|
+
type: target && target.value,
|
|
739
|
+
ref,
|
|
740
|
+
targetNode: target
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
parseLaneDeclaration(templateName, surfaceName) {
|
|
745
|
+
const start = this.expectValue('lane', 'Expected lane declaration.');
|
|
746
|
+
const name = this.parseQualifiedIdentifier('Expected lane identifier.');
|
|
747
|
+
let weight = null;
|
|
748
|
+
|
|
749
|
+
while (this.matches('weight')) {
|
|
750
|
+
this.consume();
|
|
751
|
+
const weightToken = this.current();
|
|
752
|
+
if (weightToken.type !== 'integer') {
|
|
753
|
+
this.addDiagnostic(weightToken, 'Lane weight must be a nonnegative integer.');
|
|
754
|
+
this.consume();
|
|
755
|
+
} else {
|
|
756
|
+
weight = weightToken.value;
|
|
757
|
+
this.consume();
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const body = this.parseBlock(() => this.parseLaneItem(templateName, surfaceName, name && name.value));
|
|
762
|
+
const end = body.endToken || this.previous();
|
|
763
|
+
|
|
764
|
+
return this.createNode('RmtLaneDeclaration', start, end, {
|
|
765
|
+
name: name && name.value,
|
|
766
|
+
nameNode: name,
|
|
767
|
+
weight,
|
|
768
|
+
body: body.items
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
parseLaneItem(templateName, surfaceName, laneName) {
|
|
773
|
+
if (LIFECYCLE_OPERATIONS.has(this.current().value)) {
|
|
774
|
+
return this.parseLifecycleStatement({
|
|
775
|
+
templateName,
|
|
776
|
+
surfaceName,
|
|
777
|
+
laneName
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
if (this.matches('stream')) {
|
|
781
|
+
return this.parseStreamStatement({
|
|
782
|
+
templateName,
|
|
783
|
+
surfaceName,
|
|
784
|
+
laneName
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
this.addDiagnostic(this.current(), 'Lanes may contain lifecycle or stream statements only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
788
|
+
this.skipStatementOrBlock();
|
|
789
|
+
return null;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
parseLifecycleStatement(scope = {}) {
|
|
793
|
+
const start = this.consume();
|
|
794
|
+
const target = this.parseTarget();
|
|
795
|
+
const source = this.matches('from') ? this.parseSourceClause() : null;
|
|
796
|
+
const condition = this.matches('when') ? this.parseConditionClause() : null;
|
|
797
|
+
const policy = this.matches('{') ? this.parsePolicyBlock(scope) : null;
|
|
798
|
+
|
|
799
|
+
if (!policy) {
|
|
800
|
+
this.consumeStatementEnd('Expected statement end after lifecycle statement.');
|
|
801
|
+
} else {
|
|
802
|
+
this.consumeOptionalStatementEnd();
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const end = policy ? getNodeEndToken(policy) : this.previous();
|
|
806
|
+
return this.createNode('RmtLifecycleStatement', start, end, {
|
|
807
|
+
op: start.value,
|
|
808
|
+
target,
|
|
809
|
+
source,
|
|
810
|
+
condition,
|
|
811
|
+
policy,
|
|
812
|
+
scope
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
parseStreamStatement(scope = {}) {
|
|
817
|
+
const start = this.expectValue('stream', 'Expected stream statement.');
|
|
818
|
+
const target = this.parseTarget();
|
|
819
|
+
let source = null;
|
|
820
|
+
|
|
821
|
+
if (this.matches('from')) {
|
|
822
|
+
source = this.parseSourceClause();
|
|
823
|
+
} else {
|
|
824
|
+
this.addDiagnostic(this.current(), 'Stream statements require a data source.');
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
const condition = this.matches('when') ? this.parseConditionClause() : null;
|
|
828
|
+
const policy = this.matches('{') ? this.parsePolicyBlock(scope) : null;
|
|
829
|
+
|
|
830
|
+
if (!policy) {
|
|
831
|
+
this.consumeStatementEnd('Expected statement end after stream statement.');
|
|
832
|
+
} else {
|
|
833
|
+
this.consumeOptionalStatementEnd();
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
const end = policy ? getNodeEndToken(policy) : this.previous();
|
|
837
|
+
return this.createNode('RmtStreamStatement', start, end, {
|
|
838
|
+
op: 'stream',
|
|
839
|
+
target,
|
|
840
|
+
source,
|
|
841
|
+
condition,
|
|
842
|
+
policy,
|
|
843
|
+
scope
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
parseSourceClause() {
|
|
848
|
+
const start = this.expectValue('from', 'Expected data source clause.');
|
|
849
|
+
const kindToken = this.current();
|
|
850
|
+
let kind = null;
|
|
851
|
+
|
|
852
|
+
if (SOURCE_KINDS.has(kindToken.value)) {
|
|
853
|
+
kind = kindToken.value;
|
|
854
|
+
this.consume();
|
|
855
|
+
} else {
|
|
856
|
+
this.addDiagnostic(kindToken, 'Data source kind must be endpoint, sse or worker.');
|
|
857
|
+
this.consume();
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
const target = this.parseQualifiedIdentifier('Expected data source identifier.');
|
|
861
|
+
const end = target && target.endToken ? target.endToken : this.previous();
|
|
862
|
+
|
|
863
|
+
return this.createNode('RmtSourceClause', start, end, {
|
|
864
|
+
kind,
|
|
865
|
+
target: target && target.value,
|
|
866
|
+
targetNode: target
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
parseConditionClause() {
|
|
871
|
+
const start = this.expectValue('when', 'Expected condition clause.');
|
|
872
|
+
const expression = this.parseExpression();
|
|
873
|
+
const end = expression ? getNodeEndToken(expression) : this.previous();
|
|
874
|
+
|
|
875
|
+
return this.createNode('RmtConditionClause', start, end, {
|
|
876
|
+
expression
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
parseExpression() {
|
|
881
|
+
return this.parseOrExpression();
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
parseOrExpression() {
|
|
885
|
+
let left = this.parseAndExpression();
|
|
886
|
+
while (this.matches('||')) {
|
|
887
|
+
const operator = this.consume();
|
|
888
|
+
const right = this.parseAndExpression();
|
|
889
|
+
left = this.createNode('RmtConditionExpression', getNodeStartToken(left), getNodeEndToken(right || left), {
|
|
890
|
+
kind: 'logical',
|
|
891
|
+
op: operator.value,
|
|
892
|
+
left,
|
|
893
|
+
right
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
return left;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
parseAndExpression() {
|
|
900
|
+
let left = this.parseUnaryExpression();
|
|
901
|
+
while (this.matches('&&')) {
|
|
902
|
+
const operator = this.consume();
|
|
903
|
+
const right = this.parseUnaryExpression();
|
|
904
|
+
left = this.createNode('RmtConditionExpression', getNodeStartToken(left), getNodeEndToken(right || left), {
|
|
905
|
+
kind: 'logical',
|
|
906
|
+
op: operator.value,
|
|
907
|
+
left,
|
|
908
|
+
right
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
return left;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
parseUnaryExpression() {
|
|
915
|
+
if (this.matches('!')) {
|
|
916
|
+
const operator = this.consume();
|
|
917
|
+
const argument = this.parseUnaryExpression();
|
|
918
|
+
return this.createNode('RmtConditionExpression', operator, getNodeEndToken(argument || operator), {
|
|
919
|
+
kind: 'unary',
|
|
920
|
+
op: '!',
|
|
921
|
+
argument
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
return this.parseCompareExpression();
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
parseCompareExpression() {
|
|
928
|
+
let left = this.parsePrimaryExpression();
|
|
929
|
+
if (COMPARISON_OPERATORS.has(this.current().value)) {
|
|
930
|
+
const operator = this.consume();
|
|
931
|
+
const right = this.parsePrimaryExpression();
|
|
932
|
+
left = this.createNode('RmtConditionExpression', getNodeStartToken(left), getNodeEndToken(right || left), {
|
|
933
|
+
kind: 'binary',
|
|
934
|
+
op: operator.value,
|
|
935
|
+
left,
|
|
936
|
+
right
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
return left;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
parsePrimaryExpression() {
|
|
943
|
+
const token = this.current();
|
|
944
|
+
|
|
945
|
+
if (token.value === '(') {
|
|
946
|
+
const start = this.consume();
|
|
947
|
+
const expression = this.parseExpression();
|
|
948
|
+
const end = this.expectValue(')', 'Expected closing parenthesis in condition.');
|
|
949
|
+
return this.createNode('RmtConditionExpression', start, end || getNodeEndToken(expression), {
|
|
950
|
+
kind: 'group',
|
|
951
|
+
expression
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
if (token.type === 'string' || token.type === 'integer' || token.value === 'true' || token.value === 'false' || token.value === 'null') {
|
|
956
|
+
this.consume();
|
|
957
|
+
let value = token.value;
|
|
958
|
+
if (token.value === 'true') value = true;
|
|
959
|
+
if (token.value === 'false') value = false;
|
|
960
|
+
if (token.value === 'null') value = null;
|
|
961
|
+
return this.createNode('RmtConditionExpression', token, token, {
|
|
962
|
+
kind: 'literal',
|
|
963
|
+
value
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
if (this.isIdentifierToken(token)) {
|
|
968
|
+
const path = this.parseQualifiedIdentifier('Expected condition path.');
|
|
969
|
+
|
|
970
|
+
if (this.matches('(')) {
|
|
971
|
+
this.addDiagnostic(this.current(), 'Function calls are not allowed in RMT vNext conditions.');
|
|
972
|
+
this.skipParenthesized();
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return this.createNode('RmtConditionExpression', path.startToken, path.endToken, {
|
|
976
|
+
kind: 'path',
|
|
977
|
+
path: path.parts,
|
|
978
|
+
value: path.value
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
this.addDiagnostic(token, 'Expected condition expression.');
|
|
983
|
+
this.consume();
|
|
984
|
+
return this.createNode('RmtConditionExpression', token, token, {
|
|
985
|
+
kind: 'missing'
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
parsePolicyBlock(scope = {}) {
|
|
990
|
+
const start = this.expectValue('{', 'Expected policy block.');
|
|
991
|
+
const body = [];
|
|
992
|
+
this.skipSeparators();
|
|
993
|
+
|
|
994
|
+
while (!this.isAtEnd() && !this.matches('}')) {
|
|
995
|
+
let item = null;
|
|
996
|
+
if (this.matches('slot')) {
|
|
997
|
+
item = this.parseSlotDeclaration(scope);
|
|
998
|
+
} else if (this.matches('on')) {
|
|
999
|
+
item = this.parseEventBinding();
|
|
1000
|
+
} else if (this.matches('trust')) {
|
|
1001
|
+
item = this.parseTrustPolicy();
|
|
1002
|
+
} else if (this.matches('sanitize')) {
|
|
1003
|
+
item = this.parseSanitizePolicy();
|
|
1004
|
+
} else {
|
|
1005
|
+
this.addDiagnostic(this.current(), 'Policy blocks may contain slots, event bindings and security policies only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
1006
|
+
this.skipStatementOrBlock();
|
|
1007
|
+
}
|
|
1008
|
+
if (item) body.push(item);
|
|
1009
|
+
this.skipSeparators();
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
const end = this.expectValue('}', 'Expected closing brace for policy block.') || this.previous();
|
|
1013
|
+
return this.createNode('RmtPolicyBlock', start, end, {
|
|
1014
|
+
body,
|
|
1015
|
+
scope
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
parseSlotDeclaration(scope = {}) {
|
|
1020
|
+
const start = this.expectValue('slot', 'Expected slot declaration.');
|
|
1021
|
+
const name = this.parseQualifiedIdentifier('Expected slot identifier.');
|
|
1022
|
+
const body = this.parseBlock(() => {
|
|
1023
|
+
if (LIFECYCLE_OPERATIONS.has(this.current().value)) {
|
|
1024
|
+
return this.parseLifecycleStatement(scope);
|
|
1025
|
+
}
|
|
1026
|
+
if (this.matches('stream')) {
|
|
1027
|
+
return this.parseStreamStatement(scope);
|
|
1028
|
+
}
|
|
1029
|
+
this.addDiagnostic(this.current(), 'Slots may contain lifecycle or stream statements only.', RMT_VNEXT_CONTEXT_ERROR_CODE);
|
|
1030
|
+
this.skipStatementOrBlock();
|
|
1031
|
+
return null;
|
|
1032
|
+
});
|
|
1033
|
+
const end = body.endToken || this.previous();
|
|
1034
|
+
|
|
1035
|
+
return this.createNode('RmtSlotDeclaration', start, end, {
|
|
1036
|
+
name: name && name.value,
|
|
1037
|
+
nameNode: name,
|
|
1038
|
+
body: body.items
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
parseEventBinding() {
|
|
1043
|
+
const start = this.expectValue('on', 'Expected event binding.');
|
|
1044
|
+
const event = this.parseQualifiedIdentifier('Expected event identifier.');
|
|
1045
|
+
this.expectValue('->', 'Expected -> in event binding.');
|
|
1046
|
+
this.expectValue('action', 'Expected action keyword in event binding.');
|
|
1047
|
+
const action = this.parseQualifiedIdentifier('Expected action identifier.');
|
|
1048
|
+
const condition = this.matches('when') ? this.parseConditionClause() : null;
|
|
1049
|
+
this.consumeStatementEnd('Expected statement end after event binding.');
|
|
1050
|
+
const end = this.previous();
|
|
1051
|
+
|
|
1052
|
+
return this.createNode('RmtEventBinding', start, end, {
|
|
1053
|
+
event: event && event.value,
|
|
1054
|
+
eventNode: event,
|
|
1055
|
+
action: action && action.value,
|
|
1056
|
+
actionNode: action,
|
|
1057
|
+
condition
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
parseTrustPolicy() {
|
|
1062
|
+
const start = this.expectValue('trust', 'Expected trust policy.');
|
|
1063
|
+
this.expectValue('boundary', 'Expected boundary keyword in trust policy.');
|
|
1064
|
+
const boundary = this.current();
|
|
1065
|
+
let value = null;
|
|
1066
|
+
if (boundary.type === 'string') {
|
|
1067
|
+
value = boundary.value;
|
|
1068
|
+
this.consume();
|
|
1069
|
+
} else {
|
|
1070
|
+
this.addDiagnostic(boundary, 'Trust boundary must be a string.');
|
|
1071
|
+
this.consume();
|
|
1072
|
+
}
|
|
1073
|
+
this.consumeStatementEnd('Expected statement end after trust policy.');
|
|
1074
|
+
const end = this.previous();
|
|
1075
|
+
|
|
1076
|
+
return this.createNode('RmtTrustBoundaryPolicy', start, end, {
|
|
1077
|
+
boundary: value
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
parseSanitizePolicy() {
|
|
1082
|
+
const start = this.expectValue('sanitize', 'Expected sanitize policy.');
|
|
1083
|
+
const format = this.parseQualifiedIdentifier('Expected sanitize format.');
|
|
1084
|
+
this.consumeStatementEnd('Expected statement end after sanitize policy.');
|
|
1085
|
+
const end = this.previous();
|
|
1086
|
+
|
|
1087
|
+
return this.createNode('RmtSanitizePolicy', start, end, {
|
|
1088
|
+
format: format && format.value,
|
|
1089
|
+
formatNode: format
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
parseTarget() {
|
|
1094
|
+
return this.parseQualifiedIdentifier('Expected target identifier.');
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
parseQualifiedIdentifier(message) {
|
|
1098
|
+
const first = this.current();
|
|
1099
|
+
if (!this.isIdentifierToken(first)) {
|
|
1100
|
+
this.addDiagnostic(first, message || 'Expected identifier.');
|
|
1101
|
+
this.consume();
|
|
1102
|
+
return {
|
|
1103
|
+
type: 'RmtIdentifier',
|
|
1104
|
+
value: null,
|
|
1105
|
+
parts: [],
|
|
1106
|
+
startToken: first,
|
|
1107
|
+
endToken: first,
|
|
1108
|
+
range: createRange(this.sourceModel, first.startOffset, first.endOffset)
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
const parts = [first.value];
|
|
1113
|
+
const start = this.consume();
|
|
1114
|
+
let end = start;
|
|
1115
|
+
|
|
1116
|
+
while (this.matches('.')) {
|
|
1117
|
+
const dot = this.consume();
|
|
1118
|
+
const next = this.current();
|
|
1119
|
+
if (!this.isIdentifierToken(next)) {
|
|
1120
|
+
this.addDiagnostic(next, 'Expected identifier after dot.');
|
|
1121
|
+
end = dot;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
parts.push(next.value);
|
|
1125
|
+
end = this.consume();
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
return {
|
|
1129
|
+
type: 'RmtIdentifier',
|
|
1130
|
+
value: parts.join('.'),
|
|
1131
|
+
parts,
|
|
1132
|
+
escaped: Boolean(start.escaped),
|
|
1133
|
+
startToken: start,
|
|
1134
|
+
endToken: end,
|
|
1135
|
+
range: createRange(this.sourceModel, start.startOffset, end.endOffset)
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
parseQualifiedIdentifierAllowReserved(message) {
|
|
1140
|
+
const first = this.current();
|
|
1141
|
+
if (!first || first.type !== 'identifier') {
|
|
1142
|
+
this.addDiagnostic(first, message || 'Expected identifier.');
|
|
1143
|
+
this.consume();
|
|
1144
|
+
return {
|
|
1145
|
+
type: 'RmtIdentifier',
|
|
1146
|
+
value: null,
|
|
1147
|
+
parts: [],
|
|
1148
|
+
startToken: first,
|
|
1149
|
+
endToken: first,
|
|
1150
|
+
range: createRange(this.sourceModel, first.startOffset, first.endOffset)
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
const parts = [first.value];
|
|
1155
|
+
const start = this.consume();
|
|
1156
|
+
let end = start;
|
|
1157
|
+
|
|
1158
|
+
while (this.matches('.')) {
|
|
1159
|
+
const dot = this.consume();
|
|
1160
|
+
const next = this.current();
|
|
1161
|
+
if (!next || next.type !== 'identifier') {
|
|
1162
|
+
this.addDiagnostic(next, 'Expected identifier after dot.');
|
|
1163
|
+
end = dot;
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
parts.push(next.value);
|
|
1167
|
+
end = this.consume();
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
return {
|
|
1171
|
+
type: 'RmtIdentifier',
|
|
1172
|
+
value: parts.join('.'),
|
|
1173
|
+
parts,
|
|
1174
|
+
escaped: Boolean(start.escaped),
|
|
1175
|
+
startToken: start,
|
|
1176
|
+
endToken: end,
|
|
1177
|
+
range: createRange(this.sourceModel, start.startOffset, end.endOffset)
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
parseBlock(parseItem) {
|
|
1182
|
+
const start = this.expectValue('{', 'Expected opening brace.');
|
|
1183
|
+
const items = [];
|
|
1184
|
+
this.skipSeparators();
|
|
1185
|
+
|
|
1186
|
+
while (!this.isAtEnd() && !this.matches('}')) {
|
|
1187
|
+
const item = parseItem();
|
|
1188
|
+
if (item) {
|
|
1189
|
+
items.push(item);
|
|
1190
|
+
}
|
|
1191
|
+
this.skipSeparators();
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
const end = this.expectValue('}', 'Expected closing brace.') || this.previous();
|
|
1195
|
+
return {
|
|
1196
|
+
startToken: start,
|
|
1197
|
+
endToken: end,
|
|
1198
|
+
items
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
expectValue(value, message) {
|
|
1203
|
+
if (this.matches(value)) {
|
|
1204
|
+
return this.consume();
|
|
1205
|
+
}
|
|
1206
|
+
this.addDiagnostic(this.current(), message || `Expected ${value}.`);
|
|
1207
|
+
return null;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
consumeStatementEnd(message) {
|
|
1211
|
+
if (this.matchSeparator()) {
|
|
1212
|
+
this.skipSeparators();
|
|
1213
|
+
return true;
|
|
1214
|
+
}
|
|
1215
|
+
if (this.matches('}') || this.isAtEnd()) {
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
this.addDiagnostic(this.current(), message || 'Expected statement end.');
|
|
1219
|
+
this.skipUntilStatementBoundary();
|
|
1220
|
+
this.skipSeparators();
|
|
1221
|
+
return false;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
consumeOptionalStatementEnd() {
|
|
1225
|
+
if (this.matchSeparator()) {
|
|
1226
|
+
this.skipSeparators();
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
skipParenthesized() {
|
|
1231
|
+
if (!this.matches('(')) return;
|
|
1232
|
+
let depth = 0;
|
|
1233
|
+
while (!this.isAtEnd()) {
|
|
1234
|
+
const token = this.consume();
|
|
1235
|
+
if (token.value === '(') depth += 1;
|
|
1236
|
+
if (token.value === ')') {
|
|
1237
|
+
depth -= 1;
|
|
1238
|
+
if (depth <= 0) return;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
skipStatementOrBlock() {
|
|
1244
|
+
while (!this.isAtEnd()) {
|
|
1245
|
+
if (this.matches('{')) {
|
|
1246
|
+
this.skipBlockTokens();
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
if (this.current().type === 'newline' || this.current().value === ';') {
|
|
1250
|
+
this.skipSeparators();
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
if (this.matches('}')) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
this.consume();
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
skipUntilStatementBoundary() {
|
|
1261
|
+
while (!this.isAtEnd() && this.current().type !== 'newline' && this.current().value !== ';' && this.current().value !== '}') {
|
|
1262
|
+
if (this.matches('{')) {
|
|
1263
|
+
this.skipBlockTokens();
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
this.consume();
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
skipBlockTokens() {
|
|
1271
|
+
let depth = 0;
|
|
1272
|
+
while (!this.isAtEnd()) {
|
|
1273
|
+
const token = this.consume();
|
|
1274
|
+
if (token.value === '{') depth += 1;
|
|
1275
|
+
if (token.value === '}') {
|
|
1276
|
+
depth -= 1;
|
|
1277
|
+
if (depth <= 0) return;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
function getNodeStartToken(nodeOrToken) {
|
|
1284
|
+
if (!nodeOrToken) return null;
|
|
1285
|
+
if (typeof nodeOrToken.startOffset === 'number') return nodeOrToken;
|
|
1286
|
+
if (nodeOrToken.range && typeof nodeOrToken.range.startOffset === 'number') {
|
|
1287
|
+
return {
|
|
1288
|
+
startOffset: nodeOrToken.range.startOffset,
|
|
1289
|
+
endOffset: nodeOrToken.range.startOffset,
|
|
1290
|
+
value: nodeOrToken.type || 'node'
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
return null;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
function getNodeEndToken(nodeOrToken) {
|
|
1297
|
+
if (!nodeOrToken) return null;
|
|
1298
|
+
if (typeof nodeOrToken.endOffset === 'number') return nodeOrToken;
|
|
1299
|
+
if (nodeOrToken.range && typeof nodeOrToken.range.endOffset === 'number') {
|
|
1300
|
+
return {
|
|
1301
|
+
startOffset: nodeOrToken.range.endOffset,
|
|
1302
|
+
endOffset: nodeOrToken.range.endOffset,
|
|
1303
|
+
value: nodeOrToken.type || 'node'
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
function assignAstPointers(node, pointer = '') {
|
|
1310
|
+
if (!node || typeof node !== 'object') return;
|
|
1311
|
+
if (node.type && !node.astPointer) {
|
|
1312
|
+
node.astPointer = pointer || '/';
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
['body'].forEach((key) => {
|
|
1316
|
+
const value = node[key];
|
|
1317
|
+
if (!Array.isArray(value)) return;
|
|
1318
|
+
value.forEach((child, index) => {
|
|
1319
|
+
assignAstPointers(child, `${pointer}/${key}/${index}`);
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
['source', 'condition', 'policy', 'expression', 'left', 'right', 'argument'].forEach((key) => {
|
|
1324
|
+
const value = node[key];
|
|
1325
|
+
if (value && typeof value === 'object' && value.type) {
|
|
1326
|
+
assignAstPointers(value, `${pointer}/${key}`);
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
function parseRmtVNextSource(input = {}, options = {}) {
|
|
1332
|
+
const normalizedInput = normalizeSourceInput(input, options);
|
|
1333
|
+
const sourceModel = createRmtSourceModel(normalizedInput);
|
|
1334
|
+
const filePolicyDiagnostics = createFilePolicyDiagnostics(sourceModel);
|
|
1335
|
+
const lexed = tokenizeVNextSource(sourceModel);
|
|
1336
|
+
const parser = new VNextParser(sourceModel, lexed.tokens, filePolicyDiagnostics.concat(lexed.diagnostics));
|
|
1337
|
+
const ast = parser.parseDocument();
|
|
1338
|
+
const errorDiagnostics = parser.diagnostics.filter((diagnostic) => diagnostic.severity === 'error');
|
|
1339
|
+
const ok = errorDiagnostics.length === 0;
|
|
1340
|
+
|
|
1341
|
+
return {
|
|
1342
|
+
schema: RMT_VNEXT_PARSER_SCHEMA,
|
|
1343
|
+
workpackage: RMT_VNEXT_PARSER_WORKPACKAGE,
|
|
1344
|
+
ok,
|
|
1345
|
+
phase: ok ? 'parse' : 'syntax',
|
|
1346
|
+
status: ok ? 'parsed' : 'syntax_error',
|
|
1347
|
+
sourceModel,
|
|
1348
|
+
ast,
|
|
1349
|
+
tokens: lexed.tokens.filter((token) => token.type !== 'eof'),
|
|
1350
|
+
diagnostics: parser.diagnostics,
|
|
1351
|
+
syntaxDiagnostics: parser.diagnostics.filter((diagnostic) => diagnostic.severity === 'error'),
|
|
1352
|
+
filePolicyDiagnostics
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
function createRmtVNextParser(defaultOptions = {}) {
|
|
1357
|
+
function parseSource(input = {}, options = {}) {
|
|
1358
|
+
return parseRmtVNextSource(input, {
|
|
1359
|
+
...defaultOptions,
|
|
1360
|
+
...options
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
return Object.freeze({
|
|
1365
|
+
schema: RMT_VNEXT_PARSER_SCHEMA,
|
|
1366
|
+
astSchema: RMT_VNEXT_AST_SCHEMA,
|
|
1367
|
+
workpackage: RMT_VNEXT_PARSER_WORKPACKAGE,
|
|
1368
|
+
parseSource
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
module.exports = {
|
|
1373
|
+
IMPERATIVE_WORDS,
|
|
1374
|
+
LIFECYCLE_OPERATIONS,
|
|
1375
|
+
RMT_FILE_FALLBACK_CODE,
|
|
1376
|
+
RMT_SOURCE_MODEL_WORKPACKAGE,
|
|
1377
|
+
RMT_VNEXT_AST_SCHEMA,
|
|
1378
|
+
RMT_VNEXT_CONTEXT_ERROR_CODE,
|
|
1379
|
+
RMT_VNEXT_PARSER_MODULE_PATH,
|
|
1380
|
+
RMT_VNEXT_PARSER_PACKAGE_SCRIPT,
|
|
1381
|
+
RMT_VNEXT_PARSER_REPORT_SCHEMA,
|
|
1382
|
+
RMT_VNEXT_PARSER_SCHEMA,
|
|
1383
|
+
RMT_VNEXT_PARSER_SUITE_PATH,
|
|
1384
|
+
RMT_VNEXT_PARSER_WORKPACKAGE,
|
|
1385
|
+
RMT_VNEXT_SYNTAX_ERROR_CODE,
|
|
1386
|
+
RESERVED_WORDS,
|
|
1387
|
+
SOURCE_KINDS,
|
|
1388
|
+
createRmtVNextParser,
|
|
1389
|
+
parseRmtVNextSource,
|
|
1390
|
+
tokenizeVNextSource
|
|
1391
|
+
};
|