@flanksource/page-runtime 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +495 -0
- package/dist/build/README.md +96 -0
- package/{spikes/lib → dist/build}/cjs-export-names.mjs +4 -2
- package/dist/build/dependencies.mjs +279 -0
- package/dist/build/dependencies.mjs.map +1 -0
- package/dist/build/dependency-cache-Zg-FGasE.mjs +2130 -0
- package/dist/build/dependency-cache-Zg-FGasE.mjs.map +1 -0
- package/dist/build/index.mjs +42 -0
- package/dist/build/index.mjs.map +1 -0
- package/{builder-package.json → dist/build/package.json} +1 -1
- package/dist/build/types/activity-schema.d.ts +62 -0
- package/dist/build/types/build/barrels.d.ts +70 -0
- package/dist/build/types/build/base.d.ts +2 -0
- package/dist/build/types/build/browser-runtime-exports.d.ts +19 -0
- package/dist/build/types/build/check-fragment.d.ts +5 -0
- package/dist/build/types/build/commonjs-exports.d.ts +5 -0
- package/dist/build/types/build/convert-commonjs.d.ts +12 -0
- package/dist/build/types/build/dependencies.d.ts +6 -0
- package/dist/build/types/build/dependency-barrel-index.d.ts +5 -0
- package/dist/build/types/build/dependency-barrels.d.ts +7 -0
- package/dist/build/types/build/dependency-cache.d.ts +7 -0
- package/dist/build/types/build/dependency-optional.d.ts +4 -0
- package/dist/build/types/build/dependency-plugin.d.ts +8 -0
- package/dist/build/types/build/dependency-runtime.d.ts +20 -0
- package/dist/build/types/build/dependency-workers.d.ts +8 -0
- package/dist/build/types/build/errors.d.ts +9 -0
- package/dist/build/types/build/fragment.d.ts +13 -0
- package/dist/build/types/build/index.d.ts +7 -0
- package/dist/build/types/build/library-runtime.d.ts +21 -0
- package/dist/build/types/build/module-utils.d.ts +3 -0
- package/dist/build/types/build/recipe-dependencies.d.ts +2 -0
- package/dist/build/types/build/runtime-entries.d.ts +4 -0
- package/dist/build/types/build/runtime-layer.d.ts +17 -0
- package/dist/build/types/build/trace.d.ts +140 -0
- package/dist/build/types/design-schema.d.ts +98 -0
- package/dist/build/types/host/agent-source.d.ts +2 -0
- package/dist/build/types/host/agent-validation.d.ts +3 -0
- package/dist/build/types/host/design-validation.d.ts +2 -0
- package/dist/build/types/host/message-values.d.ts +8 -0
- package/dist/build/types/host/review/validation.d.ts +5 -0
- package/dist/build/types/host/validation.d.ts +6 -0
- package/dist/build/types/link/page-sources.d.ts +31 -0
- package/dist/build/types/link/types.d.ts +62 -0
- package/dist/build/types/link/validation.d.ts +9 -0
- package/dist/build/types/markers.d.ts +10 -0
- package/dist/build/types/review-schema.d.ts +60 -0
- package/dist/build/types/schema.d.ts +319 -0
- package/dist/build/types/sw/barrels.d.ts +9 -0
- package/dist/build/types/sw/compiler-plugins.d.ts +6 -0
- package/dist/build/types/sw/composition.d.ts +8 -0
- package/dist/build/types/sw/module-transform.d.ts +68 -0
- package/dist/build/types/sw/profile.d.ts +7 -0
- package/dist/build/types/sw/source-provider.d.ts +7 -0
- package/dist/build/types/sw/versions.d.ts +10 -0
- package/dist/node/catalog.mjs +1 -0
- package/dist/node/chunks/publication-RchcQvxD.mjs +229 -0
- package/dist/node/chunks/publication-RchcQvxD.mjs.map +1 -0
- package/dist/node/chunks/schema-CaRTfg2x.mjs +12 -0
- package/dist/node/chunks/schema-CaRTfg2x.mjs.map +1 -0
- package/dist/node/dev.mjs +410 -0
- package/dist/node/dev.mjs.map +1 -0
- package/dist/node/publication/cli.mjs +13 -0
- package/dist/node/publication/cli.mjs.map +1 -0
- package/dist/node/publication.mjs +1 -0
- package/dist/node/schema.mjs +1 -0
- package/dist/node/styles.mjs +49 -0
- package/dist/node/styles.mjs.map +1 -0
- package/dist/static/boot.js +40938 -0
- package/dist/static/boot.js.map +1 -0
- package/dist/static/bootstrap.html +1 -0
- package/dist/static/devtools-hook.js +118 -0
- package/dist/static/document-bundle.js +1 -0
- package/dist/static/document.js +2621 -0
- package/dist/static/editing.js +37 -0
- package/dist/static/export-compiler.js +81521 -0
- package/dist/static/export-compiler.js.map +1 -0
- package/dist/static/page-agent.js +17193 -0
- package/dist/static/page-agent.js.map +1 -0
- package/dist/static/sw.js +86112 -0
- package/dist/static/sw.js.map +1 -0
- package/package.json +46 -13
- package/scripts/build-node.ts +26 -0
- package/scripts/build-static.ts +15 -4
- package/scripts/build.ts +1 -0
- package/scripts/react-externals.ts +18 -0
- package/scripts/release-version.ts +2 -1
- package/src/activity-schema.ts +3 -2
- package/src/build/README.md +3 -1
- package/src/build/browser-runtime-exports.ts +52 -0
- package/src/build/dependencies.ts +3 -1
- package/src/build/dependency-barrel-index.ts +48 -0
- package/src/build/dependency-barrels.ts +26 -5
- package/src/build/dependency-cache.ts +1 -1
- package/src/build/dependency-optional.ts +15 -0
- package/src/build/dependency-plugin.ts +2 -2
- package/src/build/dependency-runtime.ts +48 -13
- package/src/build/dependency-workers.ts +41 -0
- package/src/build/library-runtime.ts +6 -3
- package/src/build/runtime-layer.ts +99 -0
- package/src/build/trace.ts +12 -10
- package/src/dev/README.md +30 -0
- package/src/dev/index.ts +4 -1
- package/src/dev/runtime-origin.ts +63 -0
- package/src/editing.ts +1 -1
- package/src/form/entry-source.ts +68 -0
- package/src/form/form-page.ts +63 -0
- package/src/form/index.ts +2 -0
- package/src/form/source-update.ts +17 -0
- package/src/frame/activity.ts +4 -2
- package/src/frame/agent/README.md +1 -1
- package/src/frame/agent/agent.browser.ts +1 -1
- package/src/frame/agent/frame-layout.ts +54 -0
- package/src/frame/agent/index.ts +11 -8
- package/src/frame/agent/overlay.ts +19 -6
- package/src/frame/agent/owner.ts +6 -3
- package/src/frame/agent/review.ts +3 -2
- package/src/frame/agent.ts +1 -0
- package/src/frame/boot-styles.ts +3 -3
- package/src/frame/boot.ts +98 -34
- package/src/frame/bridge.ts +4 -4
- package/src/frame/document-assets.ts +76 -0
- package/src/frame/document-entry.ts +68 -0
- package/src/frame/document-modules.ts +113 -0
- package/src/frame/document-mount.ts +32 -0
- package/src/frame/export-page.ts +6 -4
- package/src/frame/export.ts +5 -6
- package/src/frame/index.ts +2 -1
- package/src/frame/mount-page.ts +36 -0
- package/src/frame/render-job.ts +101 -0
- package/src/frame/runtime.browser.ts +20 -1
- package/src/frame/tailwind/load.ts +16 -7
- package/src/frame/tailwind/recipe.ts +4 -9
- package/src/frame/tailwind/runtime.ts +4 -4
- package/src/frame/tailwind/stylesheets.ts +12 -7
- package/src/frame/tailwind/testing/client.ts +8 -7
- package/src/frame/tailwind/testing/server.ts +1 -1
- package/src/frame/testing/boot-layout.ts +3 -0
- package/src/frame/testing/host.ts +18 -0
- package/src/frame/testing/server.ts +18 -3
- package/src/host/BuildLog.tsx +2 -1
- package/src/host/DEBUG_CONSOLE.md +13 -0
- package/src/host/PageForm.tsx +63 -0
- package/src/host/PageFrame.tsx +14 -6
- package/src/host/RuntimeActivity.tsx +3 -1
- package/src/host/RuntimeDebugPanel.tsx +18 -0
- package/src/host/activity-state.ts +1 -1
- package/src/host/bridge.ts +2 -1
- package/src/host/debug-runtime.tsx +17 -0
- package/src/host/design-validation.ts +1 -1
- package/src/host/index.ts +1 -0
- package/src/host/link/transport.ts +2 -1
- package/src/host/review/index.ts +6 -5
- package/src/host/runtime-diagnostics.ts +41 -0
- package/src/host/validation.ts +40 -3
- package/src/link/testing/server.ts +10 -7
- package/src/link/testing/worker.ts +1 -1
- package/src/schema.ts +32 -6
- package/src/styles.ts +40 -0
- package/src/sw/compile.ts +1 -1
- package/src/sw/compiler.ts +14 -7
- package/src/sw/converted.browser.ts +1 -1
- package/src/sw/errors.ts +15 -2
- package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/browser-server.ts +5 -5
- package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures.ts +2 -2
- package/src/sw/link-compiler.ts +12 -4
- package/src/sw/link-route.ts +1 -1
- package/src/sw/markers.ts +1 -1
- package/src/sw/module-transform.ts +14 -2
- package/src/sw/profile.ts +3 -1
- package/src/sw/resolver.ts +8 -4
- package/src/sw/router.ts +52 -12
- package/src/sw/runtime-exports.ts +39 -0
- package/src/sw/source-provider.ts +20 -0
- package/src/sw/versions.ts +11 -4
- package/src/sw/worker.ts +5 -1
- package/.vitest/gavel-reporter-3e3dfb64eda19344.mjs +0 -59
- package/.vitest/vitest-report-root-1793958008919344000.json +0 -1
- package/.vitest/vitest-report-root-1793958052786561000.json +0 -1
- package/.vitest/vitest-report-root-1793958143511414000.json +0 -1
- package/.vitest/vitest-report-root-1793958185908019000.json +0 -1
- package/.vitest/vitest-report-root-1793958252687550000.json +0 -1
- package/.vitest/vitest-report-root-1793958260385388000.json +0 -1
- package/.vitest/vitest-report-root-1793958312358683000.json +0 -1
- package/.vitest/vitest-report-root-1793958386118791000.json +0 -1
- package/.vitest/vitest-report-root-1793958388712140000.json +0 -1
- package/.vitest/vitest-report-root-1793958429135603000.json +0 -1
- package/.vitest/vitest-report-root-1793958433387809000.json +0 -1
- package/.vitest/vitest-report-root-1793958517322792000.json +0 -1
- package/.vitest/vitest-report-root-1793958542332252000.json +0 -1
- package/.vitest/vitest-report-root-1793958617698698000.json +0 -1
- package/.vitest/vitest-report-root-1793958676587753000.json +0 -1
- package/.vitest/vitest-report-root-1793958707827469000.json +0 -1
- package/.vitest/vitest-report-root-1793958729745028000.json +0 -1
- package/.vitest/vitest-report-root-1793958736696408000.json +0 -1
- package/.vitest/vitest-report-root-1793958740449993000.json +0 -1
- package/.vitest/vitest-report-root-1793958841510921000.json +0 -1
- package/.vitest/vitest-report-root-1793958847664582000.json +0 -1
- package/.vitest/vitest-report-root-1793958900327643000.json +0 -1
- package/.vitest/vitest-report-root-1793958950822823000.json +0 -1
- package/.vitest/vitest-report-root-1793959013655262000.json +0 -1
- package/.vitest/vitest-report-root-1793959017905881000.json +0 -1
- package/.vitest/vitest-report-root-1793959093169044000.json +0 -1
- package/.vitest/vitest-report-root-1793959093978087000.json +0 -1
- package/.vitest/vitest-report-root-1793959101111925000.json +0 -1
- package/.vitest/vitest-report-root-1793959145317906000.json +0 -1
- package/.vitest/vitest-report-root-1793959190760607000.json +0 -1
- package/.vitest/vitest-report-root-1793959249695805000.json +0 -1
- package/.vitest/vitest-report-root-1793959323191511000.json +0 -1
- package/.vitest/vitest-report-root-1793959453311564000.json +0 -1
- package/.vitest/vitest-report-root-1793959495806182000.json +0 -1
- package/.vitest/vitest-report-root-1793959499945435000.json +0 -1
- package/.vitest/vitest-report-root-1793959546773807000.json +0 -1
- package/.vitest/vitest-report-root-1793959583335593000.json +0 -1
- package/.vitest/vitest-report-root-1793959621479504000.json +0 -1
- package/.vitest/vitest-report-root-1793959651002360000.json +0 -1
- package/.vitest/vitest-report-root-1793959655646061000.json +0 -1
- package/.vitest/vitest-report-root-1793959741176826000.json +0 -1
- package/.vitest/vitest-report-root-1793959744743733000.json +0 -1
- package/.vitest/vitest-report-root-1793959833244182000.json +0 -1
- package/.vitest/vitest-report-root-1793959882131751000.json +0 -1
- package/.vitest/vitest-report-root-1793959887033254000.json +0 -1
- package/.vitest/vitest-report-root-1793960000631977000.json +0 -1
- package/.vitest/vitest-report-root-1793960011938504000.json +0 -1
- package/.vitest/vitest-report-root-1793961370018852000.json +0 -1
- package/.vitest/vitest-report-root-1793961745370827000.json +0 -1
- package/.vitest/vitest-report-root-1793961764143180000.json +0 -1
- package/.vitest/vitest-report-root-1793961835963066000.json +0 -1
- package/.vitest/vitest-report-root-1793961890729922000.json +0 -1
- package/.vitest/vitest-report-root-1793961968680074000.json +0 -1
- package/.vitest/vitest-report-root-1793962066862337000.json +0 -1
- package/.vitest/vitest-report-root-1793962087917497000.json +0 -1
- package/.vitest/vitest-report-root-1793962157254386000.json +0 -1
- package/.vitest/vitest-report-root-1793962171214865000.json +0 -1
- package/.vitest/vitest-report-root-1793962183290533000.json +0 -1
- package/.vitest/vitest-report-root-1793962184809932000.json +0 -1
- package/.vitest/vitest-report-root-1793962197715204000.json +0 -1
- package/.vitest/vitest-report-root-1793962244650717000.json +0 -1
- package/.vitest/vitest-report-root-1793962259802273000.json +0 -1
- package/.vitest/vitest-report-root-1793962278799745000.json +0 -1
- package/.vitest/vitest-report-root-1793962304412974000.json +0 -1
- package/.vitest/vitest-report-root-1793962328411454000.json +0 -1
- package/.vitest/vitest-report-root-1793962355747869000.json +0 -1
- package/.vitest/vitest-report-root-1793962381401572000.json +0 -1
- package/.vitest/vitest-report-root-1793962393326735000.json +0 -1
- package/.vitest/vitest-report-root-1793962393329206000.json +0 -1
- package/.vitest/vitest-report-root-1793962437796768000.json +0 -1
- package/.vitest/vitest-report-root-1793962444190384000.json +0 -1
- package/.vitest/vitest-report-root-1793962445347541000.json +0 -1
- package/.vitest/vitest-report-root-1793962473691143000.json +0 -1
- package/.vitest/vitest-report-root-1793962474291457000.json +0 -1
- package/.vitest/vitest-report-root-1793962499680468000.json +0 -1
- package/.vitest/vitest-report-root-1793962504410483000.json +0 -1
- package/.vitest/vitest-report-root-1793962516850524000.json +0 -1
- package/.vitest/vitest-report-root-1793962536736273000.json +0 -1
- package/.vitest/vitest-report-root-1793962551181783000.json +0 -1
- package/.vitest/vitest-report-root-1793962553575620000.json +0 -1
- package/.vitest/vitest-report-root-1793962555169730000.json +0 -1
- package/.vitest/vitest-report-root-1793962572639765000.json +0 -1
- package/.vitest/vitest-report-root-1793962597102952000.json +0 -1
- package/.vitest/vitest-report-root-1793962637156669000.json +0 -1
- package/.vitest/vitest-report-root-1793962653530027000.json +0 -1
- package/.vitest/vitest-report-root-1793962665824334000.json +0 -1
- package/.vitest/vitest-report-root-1793962682161714000.json +0 -1
- package/.vitest/vitest-report-root-1793962719526168000.json +0 -1
- package/.vitest/vitest-report-root-1793962723853934000.json +0 -1
- package/.vitest/vitest-report-root-1793962741927728000.json +0 -1
- package/.vitest/vitest-report-root-1793962794308371000.json +0 -1
- package/.vitest/vitest-report-root-1793962796334481000.json +0 -1
- package/.vitest/vitest-report-root-1793962798075169000.json +0 -1
- package/.vitest/vitest-report-root-1793962836466676000.json +0 -1
- package/.vitest/vitest-report-root-1793962846507317000.json +0 -1
- package/.vitest/vitest-report-root-1793962876266701000.json +0 -1
- package/.vitest/vitest-report-root-1793962922031308000.json +0 -1
- package/.vitest/vitest-report-root-1793962932957166000.json +0 -1
- package/.vitest/vitest-report-root-1793962946930725000.json +0 -1
- package/.vitest/vitest-report-root-1793963027896350000.json +0 -1
- package/.vitest/vitest-report-root-1793963036618707000.json +0 -1
- package/.vitest/vitest-report-root-1793963067365318000.json +0 -1
- package/.vitest/vitest-report-root-1793963077597641000.json +0 -1
- package/.vitest/vitest-report-root-1793963126365651000.json +0 -1
- package/.vitest/vitest-report-root-1793963208744553000.json +0 -1
- package/.vitest/vitest-report-root-1793963232806450000.json +0 -1
- package/.vitest/vitest-report-root-1793963325077422000.json +0 -1
- package/.vitest/vitest-report-root-1793963392172877000.json +0 -1
- package/.vitest/vitest-report-root-1793963398218324000.json +0 -1
- package/.vitest/vitest-report-root-1793963410749092000.json +0 -1
- package/.vitest/vitest-report-root-1793963437279580000.json +0 -1
- package/.vitest/vitest-report-root-1793963450096193000.json +0 -1
- package/.vitest/vitest-report-root-1793963478908641000.json +0 -1
- package/.vitest/vitest-report-root-1793963507838465000.json +0 -1
- package/.vitest/vitest-report-root-1793963528668174000.json +0 -1
- package/.vitest/vitest-report-root-1793963601860390000.json +0 -1
- package/.vitest/vitest-report-root-1793963611633446000.json +0 -1
- package/.vitest/vitest-report-root-1793963624713406000.json +0 -1
- package/.vitest/vitest-report-root-1793963680656685000.json +0 -1
- package/.vitest/vitest-report-root-1793963705231851000.json +0 -1
- package/.vitest/vitest-report-root-1793963708929500000.json +0 -1
- package/.vitest/vitest-report-root-1793963710267844000.json +0 -1
- package/.vitest/vitest-report-root-1793963713999248000.json +0 -1
- package/.vitest/vitest-report-root-1793963786513455000.json +0 -1
- package/.vitest/vitest-report-root-1793963792518765000.json +0 -1
- package/.vitest/vitest-report-root-1793963804089549000.json +0 -1
- package/.vitest/vitest-report-root-1793963840412921000.json +0 -1
- package/.vitest/vitest-report-root-1793963880361176000.json +0 -1
- package/.vitest/vitest-report-root-1793963935121106000.json +0 -1
- package/.vitest/vitest-report-root-1793963937290698000.json +0 -1
- package/.vitest/vitest-report-root-1793963977050773000.json +0 -1
- package/.vitest/vitest-report-root-1793963981229158000.json +0 -1
- package/.vitest/vitest-report-root-1793963989422080000.json +0 -1
- package/.vitest/vitest-report-root-1793964025924629000.json +0 -1
- package/.vitest/vitest-report-root-1793964027983705000.json +0 -1
- package/.vitest/vitest-report-root-1793964059969386000.json +0 -1
- package/.vitest/vitest-report-root-1793964071524069000.json +0 -1
- package/.vitest/vitest-report-root-1793964076285860000.json +0 -1
- package/.vitest/vitest-report-root-1793964077988100000.json +0 -1
- package/.vitest/vitest-report-root-1793964093289042000.json +0 -1
- package/.vitest/vitest-report-root-1793964102899356000.json +0 -1
- package/.vitest/vitest-report-root-1793964128089691000.json +0 -1
- package/.vitest/vitest-report-root-1793964129495156000.json +0 -1
- package/.vitest/vitest-report-root-1793964182849665000.json +0 -1
- package/.vitest/vitest-report-root-1793964223959893000.json +0 -1
- package/.vitest/vitest-report-root-1793964253351716000.json +0 -1
- package/.vitest/vitest-report-root-1793964290220122000.json +0 -1
- package/.vitest/vitest-report-root-1793964318037006000.json +0 -1
- package/.vitest/vitest-report-root-1793964334676691000.json +0 -1
- package/.vitest/vitest-report-root-1793964378520677000.json +0 -1
- package/.vitest/vitest-report-root-1793964383748994000.json +0 -1
- package/.vitest/vitest-report-root-1793964394042303000.json +0 -1
- package/.vitest/vitest-report-root-1793964466521881000.json +0 -1
- package/.vitest/vitest-report-root-1793964470478175000.json +0 -1
- package/.vitest/vitest-report-root-1793964484499019000.json +0 -1
- package/.vitest/vitest-report-root-1793964527645213000.json +0 -1
- package/.vitest/vitest-report-root-1793964608875865000.json +0 -1
- package/.vitest/vitest-report-root-1793964623608336000.json +0 -1
- package/.vitest/vitest-report-root-1793964629870846000.json +0 -1
- package/.vitest/vitest-report-root-1793964674515564000.json +0 -1
- package/.vitest/vitest-report-root-1793964706923651000.json +0 -1
- package/.vitest/vitest-report-root-1793964712832942000.json +0 -1
- package/.vitest/vitest-report-root-1793964714824633000.json +0 -1
- package/.vitest/vitest-report-root-1793964755433952000.json +0 -1
- package/.vitest/vitest-report-root-1793964783157670000.json +0 -1
- package/.vitest/vitest-report-root-1793964818963246000.json +0 -1
- package/.vitest/vitest-report-root-1793964843818548000.json +0 -1
- package/.vitest/vitest-report-root-1793964929824204000.json +0 -1
- package/.vitest/vitest-report-root-1793964973060713000.json +0 -1
- package/.vitest/vitest-report-root-1793964983122482000.json +0 -1
- package/.vitest/vitest-report-root-1793965107264567000.json +0 -1
- package/.vitest/vitest-report-root-1793965258759177000.json +0 -1
- package/.vitest/vitest-report-root-1793965277212091000.json +0 -1
- package/.vitest/vitest-report-root-1793965420648188000.json +0 -1
- package/.vitest/vitest-report-root-1793965611688414000.json +0 -1
- package/.vitest/vitest-report-root-1793965753407694000.json +0 -1
- package/.vitest/vitest-report-root-1793965766104309000.json +0 -1
- package/.vitest/vitest-report-root-1793965766823098000.json +0 -1
- package/.vitest/vitest-report-root-1793965806066109000.json +0 -1
- package/.vitest/vitest-report-root-1793965824697182000.json +0 -1
- package/.vitest/vitest-report-root-1793965904374564000.json +0 -1
- package/.vitest/vitest-report-root-1793965920838340000.json +0 -1
- package/.vitest/vitest-report-root-1793965932520617000.json +0 -1
- package/.vitest/vitest-report-root-1793965971574656000.json +0 -1
- package/.vitest/vitest-report-root-1793966049815024000.json +0 -1
- package/.vitest/vitest-report-root-1793966057888034000.json +0 -1
- package/.vitest/vitest-report-root-1793966066838868000.json +0 -1
- package/.vitest/vitest-report-root-1793966160347764000.json +0 -1
- package/.vitest/vitest-report-root-1793966196305985000.json +0 -1
- package/.vitest/vitest-report-root-1793966221538043000.json +0 -1
- package/.vitest/vitest-report-root-1793966251519918000.json +0 -1
- package/.vitest/vitest-report-root-1793966447000588000.json +0 -1
- package/.vitest/vitest-report-root-1793966463178249000.json +0 -1
- package/.vitest/vitest-report-root-1793966486995648000.json +0 -1
- package/.vitest/vitest-report-root-1793966726756953000.json +0 -1
- package/.vitest/vitest-report-root-1793966763656807000.json +0 -1
- package/.vitest/vitest-report-root-1793966979409799000.json +0 -1
- package/.vitest/vitest-report-root-1793967385250149000.json +0 -1
- package/.vitest/vitest-report-root-1793967617080163000.json +0 -1
- package/.vitest/vitest-report-root-1793967649428508000.json +0 -1
- package/.vitest/vitest-report-root-1793967773689520000.json +0 -1
- package/.vitest/vitest-report-root-1793968743743508000.json +0 -1
- package/.vitest/vitest-report-root-1793968846470407000.json +0 -1
- package/.vitest/vitest-report-root-1793968880878391000.json +0 -1
- package/.vitest/vitest-report-root-1793969027713529000.json +0 -1
- package/.vitest/vitest-report-root-1793969041841266000.json +0 -1
- package/.vitest/vitest-report-root-1793969142007468000.json +0 -1
- package/.vitest/vitest-report-root-1793969164867379000.json +0 -1
- package/.vitest/vitest-report-root-1793969193145858000.json +0 -1
- package/.vitest/vitest-report-root-1793969246818533000.json +0 -1
- package/.vitest/vitest-report-root-1793969270845486000.json +0 -1
- package/.vitest/vitest-report-root-1793969272514219000.json +0 -1
- package/.vitest/vitest-report-root-1793969302476105000.json +0 -1
- package/.vitest/vitest-report-root-1793969401697799000.json +0 -1
- package/.vitest/vitest-report-root-1793969433222630000.json +0 -1
- package/.vitest/vitest-report-root-1793969453350714000.json +0 -1
- package/.vitest/vitest-report-root-1793969567187400000.json +0 -1
- package/.vitest/vitest-report-root-1793969602230024000.json +0 -1
- package/.vitest/vitest-report-root-1793969633261063000.json +0 -1
- package/.vitest/vitest-report-root-1793969673876404000.json +0 -1
- package/.vitest/vitest-report-root-1793969702287010000.json +0 -1
- package/.vitest/vitest-report-root-1793969745828386000.json +0 -1
- package/.vitest/vitest-report-root-1793969893687205000.json +0 -1
- package/.vitest/vitest-report-root-1793969949642120000.json +0 -1
- package/.vitest/vitest-report-root-1793969981399076000.json +0 -1
- package/.vitest/vitest-report-root-1793970027152713000.json +0 -1
- package/.vitest/vitest-report-root-1793970030585158000.json +0 -1
- package/.vitest/vitest-report-root-1793970160195767000.json +0 -1
- package/.vitest/vitest-report-root-1793970215752422000.json +0 -1
- package/.vitest/vitest-report-root-1793970217114968000.json +0 -1
- package/.vitest/vitest-report-root-1793970329879319000.json +0 -1
- package/.vitest/vitest-report-root-1793970590586994000.json +0 -1
- package/.vitest/vitest-report-root-1793970625359990000.json +0 -1
- package/.vitest/vitest-report-root-1793970672590269000.json +0 -1
- package/.vitest/vitest-report-root-1793970796789022000.json +0 -1
- package/.vitest/vitest-report-root-1793970825710990000.json +0 -1
- package/.vitest/vitest-report-root-1793970884000509000.json +0 -1
- package/.vitest/vitest-report-root-1793970900444617000.json +0 -1
- package/.vitest/vitest-report-root-1793972186024681000.json +0 -1
- package/.vitest/vitest-report-root-1793972227757396000.json +0 -1
- package/.vitest/vitest-report-root-1793972736341600000.json +0 -1
- package/.vitest/vitest-report-root-1793972769249562000.json +0 -1
- package/.vitest/vitest-report-root-1793972859435283000.json +0 -1
- package/.vitest/vitest-report-root-1793972915169294000.json +0 -1
- package/.vitest/vitest-report-root-1793973081515450000.json +0 -1
- package/.vitest/vitest-report-root-1793973111336773000.json +0 -1
- package/.vitest/vitest-report-root-1793973253986969000.json +0 -1
- package/.vitest/vitest-report-root-1793973561283775000.json +0 -1
- package/.vitest/vitest-report-root-1793973593320977000.json +0 -1
- package/.vitest/vitest-report-root-1793973648302867000.json +0 -1
- package/.vitest/vitest-report-root-1793973819657242000.json +0 -1
- package/.vitest/vitest-report-root-1793973952727311000.json +0 -1
- package/.vitest/vitest-report-root-1793974334455876000.json +0 -1
- package/.vitest/vitest-report-root-1793974437074196000.json +0 -1
- package/.vitest/vitest-report-root-1793974437553146000.json +0 -1
- package/.vitest/vitest-report-root-1793974461818626000.json +0 -1
- package/.vitest/vitest-report-root-1793974515255198000.json +0 -1
- package/.vitest/vitest-report-root-1793974516267191000.json +0 -1
- package/.vitest/vitest-report-root-1793974621202824000.json +0 -1
- package/.vitest/vitest-report-root-1793974718450330000.json +0 -1
- package/.vitest/vitest-report-root-1793974834942373000.json +0 -1
- package/.vitest/vitest-report-root-1793974921367314000.json +0 -1
- package/.vitest/vitest-report-root-1793975019367156000.json +0 -1
- package/.vitest/vitest-report-root-1793975048166096000.json +0 -1
- package/.vitest/vitest-report-root-1793975133024339000.json +0 -1
- package/.vitest/vitest-report-root-1793975159711704000.json +0 -1
- package/.vitest/vitest-report-root-1793975517481736000.json +0 -1
- package/.vitest/vitest-report-root-1793975680008825000.json +0 -1
- package/.vitest/vitest-report-root-1793976067648494000.json +0 -1
- package/.vitest/vitest-report-root-1793976314122479000.json +0 -1
- package/.vitest/vitest-report-root-1793976513022402000.json +0 -1
- package/.vitest/vitest-report-root-1793976540410805000.json +0 -1
- package/.vitest/vitest-report-root-1793976555103273000.json +0 -1
- package/.vitest/vitest-report-root-1793976702974407000.json +0 -1
- package/.vitest/vitest-report-root-1793976721093108000.json +0 -1
- package/.vitest/vitest-report-root-1793976955473681000.json +0 -1
- package/.vitest/vitest-report-root-1793977049628483000.json +0 -1
- package/.vitest/vitest-report-root-1793977098467804000.json +0 -1
- package/.vitest/vitest-report-root-1793977132144900000.json +0 -1
- package/.vitest/vitest-report-root-1793977279648191000.json +0 -1
- package/.vitest/vitest-report-root-1793977365312127000.json +0 -1
- package/.vitest/vitest-report-root-1793978227796817000.json +0 -1
- package/.vitest/vitest-report-root-1793978255189735000.json +0 -1
- package/.vitest/vitest-report-root-1793978306509070000.json +0 -1
- package/.vitest/vitest-report-root-1793978418301216000.json +0 -1
- package/.vitest/vitest-report-root-1793978445072573000.json +0 -1
- package/.vitest/vitest-report-root-1793978546605517000.json +0 -1
- package/.vitest/vitest-report-root-1793978576060950000.json +0 -1
- package/.vitest/vitest-report-root-1793978590261408000.json +0 -1
- package/.vitest/vitest-report-root-1793978674733179000.json +0 -1
- package/.vitest/vitest-report-root-1793978718588785000.json +0 -1
- package/.vitest/vitest-report-root-1793978725363453000.json +0 -1
- package/.vitest/vitest-report-root-1793978729967285000.json +0 -1
- package/.vitest/vitest-report-root-1793978755641607000.json +0 -1
- package/.vitest/vitest-report-root-1793978782769802000.json +0 -1
- package/.vitest/vitest-report-root-1793978784870947000.json +0 -1
- package/.vitest/vitest-report-root-1793978806927335000.json +0 -1
- package/.vitest/vitest-report-root-1793978822508324000.json +0 -1
- package/.vitest/vitest-report-root-1793978836339794000.json +0 -1
- package/.vitest/vitest-report-root-1793978837947352000.json +0 -1
- package/.vitest/vitest-report-root-1793978891548295000.json +0 -1
- package/.vitest/vitest-report-root-1793978946172947000.json +0 -1
- package/.vitest/vitest-report-root-1793978947109807000.json +0 -1
- package/.vitest/vitest-report-root-1793979034208662000.json +0 -1
- package/.vitest/vitest-report-root-1793979070583608000.json +0 -1
- package/.vitest/vitest-report-root-1793979081187144000.json +0 -1
- package/.vitest/vitest-report-root-1793979085428673000.json +0 -1
- package/.vitest/vitest-report-root-1793979155097858000.json +0 -1
- package/.vitest/vitest-report-root-1793979233508873000.json +0 -1
- package/.vitest/vitest-report-root-1793979268653273000.json +0 -1
- package/.vitest/vitest-report-root-1793979341978843000.json +0 -1
- package/.vitest/vitest-report-root-1793979345344877000.json +0 -1
- package/.vitest/vitest-report-root-1793979389390374000.json +0 -1
- package/.vitest/vitest-report-root-1793979400063493000.json +0 -1
- package/.vitest/vitest-report-root-1793979432448725000.json +0 -1
- package/.vitest/vitest-report-root-1793979459139430000.json +0 -1
- package/.vitest/vitest-report-root-1793979480341961000.json +0 -1
- package/.vitest/vitest-report-root-1793979510130869000.json +0 -1
- package/.vitest/vitest-report-root-1793979524763924000.json +0 -1
- package/.vitest/vitest-report-root-1793979571563010000.json +0 -1
- package/.vitest/vitest-report-root-1793979627916920000.json +0 -1
- package/.vitest/vitest-report-root-1793979726395379000.json +0 -1
- package/.vitest/vitest-report-root-1793979752029533000.json +0 -1
- package/.vitest/vitest-report-root-1793979753365744000.json +0 -1
- package/.vitest/vitest-report-root-1793979759386206000.json +0 -1
- package/.vitest/vitest-report-root-1793979787819109000.json +0 -1
- package/.vitest/vitest-report-root-1793979827615051000.json +0 -1
- package/.vitest/vitest-report-root-1793979927737393000.json +0 -1
- package/.vitest/vitest-report-root-1793979929836169000.json +0 -1
- package/.vitest/vitest-report-root-1793979955780781000.json +0 -1
- package/.vitest/vitest-report-root-1793980200569636000.json +0 -1
- package/.vitest/vitest-report-root-1793980206045213000.json +0 -1
- package/.vitest/vitest-report-root-1793980285772027000.json +0 -1
- package/.vitest/vitest-report-root-1793980459229828000.json +0 -1
- package/.vitest/vitest-report-root-1793980460545874000.json +0 -1
- package/.vitest/vitest-report-root-1793980554484341000.json +0 -1
- package/.vitest/vitest-report-root-1793980674494388000.json +0 -1
- package/.vitest/vitest-report-root-1793980683752195000.json +0 -1
- package/.vitest/vitest-report-root-1793980947108651000.json +0 -1
- package/.vitest/vitest-report-root-1793981129616629000.json +0 -1
- package/.vitest/vitest-report-root-1793981196611441000.json +0 -1
- package/.vitest/vitest-report-root-1793981226583545000.json +0 -1
- package/.vitest/vitest-report-root-1793981294259721000.json +0 -1
- package/.vitest/vitest-report-root-1793981353393048000.json +0 -1
- package/.vitest/vitest-report-root-1793981424585368000.json +0 -1
- package/.vitest/vitest-report-root-1793981513266687000.json +0 -1
- package/.vitest/vitest-report-root-1793981526418218000.json +0 -1
- package/.vitest/vitest-report-root-1793981540069877000.json +0 -1
- package/.vitest/vitest-report-root-1793981761193625000.json +0 -1
- package/.vitest/vitest-report-root-1793981868520992000.json +0 -1
- package/.vitest/vitest-report-root-1793982048467772000.json +0 -1
- package/.vitest/vitest-report-root-1793982119518020000.json +0 -1
- package/.vitest/vitest-report-root-1793982243473651000.json +0 -1
- package/.vitest/vitest-report-root-1793982406880629000.json +0 -1
- package/.vitest/vitest-report-root-1793982433563632000.json +0 -1
- package/.vitest/vitest-report-root-1793982496753204000.json +0 -1
- package/.vitest/vitest-report-root-1793982500153311000.json +0 -1
- package/.vitest/vitest-report-root-1793982542086095000.json +0 -1
- package/.vitest/vitest-report-root-1793982659482988000.json +0 -1
- package/.vitest/vitest-report-root-1793983799132716000.json +0 -1
- package/.vitest/vitest-report-root-1793983822721833000.json +0 -1
- package/.vitest/vitest-report-root-1793984998618484000.json +0 -1
- package/.vitest/vitest-report-root-1793985050475750000.json +0 -1
- package/.vitest/vitest-report-root-1793985095516077000.json +0 -1
- package/.vitest/vitest-report-root-1793985130729074000.json +0 -1
- package/.vitest/vitest-report-root-1793985177150997000.json +0 -1
- package/.vitest/vitest-report-root-1793985267658626000.json +0 -1
- package/.vitest/vitest-report-root-1793985412705211000.json +0 -1
- package/.vitest/vitest-report-root-1793985433752853000.json +0 -1
- package/.vitest/vitest-report-root-1794087938302852000.json +0 -1
- package/.vitest/vitest-report-root-1794087978339022000.json +0 -1
- package/.vitest/vitest-report-root-1794088095283811000.json +0 -1
- package/.vitest/vitest-report-root-1794088129997065000.json +0 -1
- package/.vitest/vitest-report-root-1794088147336556000.json +0 -1
- package/.vitest/vitest-report-root-1794088173414593000.json +0 -1
- package/.vitest/vitest-report-root-1794088221289657000.json +0 -1
- package/.vitest/vitest-report-root-1794088250766611000.json +0 -1
- package/.vitest/vitest-report-root-1794088365553234000.json +0 -1
- package/.vitest/vitest-report-root-1794088395202655000.json +0 -1
- package/.vitest/vitest-report-root-1794090028732187000.json +0 -1
- package/.vitest/vitest-report-root-1794090054787283000.json +0 -1
- package/.vitest/vitest-report-root-1794090153955794000.json +0 -1
- package/.vitest/vitest-report-root-1794090161850160000.json +0 -1
- package/.vitest/vitest-report-root-1794091755693314000.json +0 -1
- package/.vitest/vitest-report-root-1794091765029349000.json +0 -1
- package/.vitest/vitest-report-root-1794091975649927000.json +0 -1
- package/.vitest/vitest-report-root-1794091994027950000.json +0 -1
- package/.vitest/vitest-report-root-1794092005178771000.json +0 -1
- package/.vitest/vitest-report-root-1794113295302382000.json +0 -1
- package/.vitest/vitest-report-root-1794114156337032000.json +0 -1
- package/.vitest/vitest-report-root-1794114198454137000.json +0 -1
- package/.vitest/vitest-report-root-1794114254064413000.json +0 -1
- package/.vitest/vitest-report-root-1794114280107510000.json +0 -1
- package/.vitest/vitest-report-root-1794114495199837000.json +0 -1
- package/.vitest/vitest-report-root-1794114646604233000.json +0 -1
- package/.vitest/vitest-report-root-1794114666311689000.json +0 -1
- package/.vitest/vitest-report-root-1794114974303438000.json +0 -1
- package/.vitest/vitest-report-root-1794115037361450000.json +0 -1
- package/.vitest/vitest-report-root-1794115097838937000.json +0 -1
- package/.vitest/vitest-report-root-1794115604669388000.json +0 -1
- package/.vitest/vitest-report-root-1794115633814500000.json +0 -1
- package/.vitest/vitest-report-root-1794115648756242000.json +0 -1
- package/.vitest/vitest-report-root-1794115873440741000.json +0 -1
- package/.vitest/vitest-report-root-1794115952930230000.json +0 -1
- package/.vitest/vitest-report-root-1794115963344701000.json +0 -1
- package/.vitest/vitest-report-root-1794116196067450000.json +0 -1
- package/.vitest/vitest-report-root-1794116254301280000.json +0 -1
- package/.vitest/vitest-report-root-1794116259342966000.json +0 -1
- package/.vitest/vitest-report-root-1794118178787879000.json +0 -1
- package/.vitest/vitest-report-root-1794137087891409000.json +0 -1
- package/.vitest/vitest-report-root-1794137100301214000.json +0 -1
- package/.vitest/vitest-report-root-1794137107377813000.json +0 -1
- package/.vitest/vitest-report-root-1794137171230704000.json +0 -1
- package/.vitest/vitest-report-root-1794137317761465000.json +0 -1
- package/.vitest/vitest-report-root-1794137320282368000.json +0 -1
- package/PACKAGE_PUBLICATIONS.md +0 -26
- package/scripts/local-workspaces.test.ts +0 -31
- package/scripts/release-version-cli.test.ts +0 -40
- package/scripts/release-version.test.ts +0 -29
- package/spikes/README.md +0 -70
- package/spikes/barrel-rewriting/README.md +0 -97
- package/spikes/barrel-rewriting/measure.ts +0 -134
- package/spikes/barrel-rewriting/readme.ts +0 -174
- package/spikes/barrel-rewriting/results.json +0 -3440
- package/spikes/barrel-rewriting/run.ts +0 -330
- package/spikes/barrel-rewriting/setup.ts +0 -90
- package/spikes/barrel-rewriting/sw.ts +0 -148
- package/spikes/barrel-rewriting/tenant.ts +0 -91
- package/spikes/barrel-rewriting/worker-config.ts +0 -33
- package/spikes/closure-fragments/README.md +0 -157
- package/spikes/closure-fragments/results.json +0 -959
- package/spikes/closure-fragments/run.ts +0 -298
- package/spikes/compiler/README.md +0 -177
- package/spikes/compiler/compile.test.ts +0 -78
- package/spikes/compiler/compile.ts +0 -82
- package/spikes/compiler/facet-redact.d.ts +0 -5
- package/spikes/compiler/markers.ts +0 -88
- package/spikes/compiler/pages.ts +0 -43
- package/spikes/compiler/readme.ts +0 -116
- package/spikes/compiler/reference.ts +0 -81
- package/spikes/compiler/render.ts +0 -113
- package/spikes/compiler/results.json +0 -3310
- package/spikes/compiler/run.ts +0 -250
- package/spikes/compiler/sucrase-parser.d.ts +0 -8
- package/spikes/compiler/sw.ts +0 -62
- package/spikes/diagram-readiness/README.md +0 -134
- package/spikes/diagram-readiness/analysis.test.ts +0 -52
- package/spikes/diagram-readiness/analysis.ts +0 -35
- package/spikes/diagram-readiness/browser.ts +0 -209
- package/spikes/diagram-readiness/readme.ts +0 -65
- package/spikes/diagram-readiness/results.json +0 -30289
- package/spikes/diagram-readiness/run.ts +0 -103
- package/spikes/diagram-readiness/server.ts +0 -53
- package/spikes/esm-sh/README.md +0 -27
- package/spikes/frame-commenting/README.md +0 -183
- package/spikes/frame-commenting/agent.ts +0 -110
- package/spikes/frame-commenting/hook.ts +0 -1
- package/spikes/frame-commenting/host.ts +0 -66
- package/spikes/frame-commenting/measure.ts +0 -180
- package/spikes/frame-commenting/model.test.ts +0 -27
- package/spikes/frame-commenting/model.ts +0 -40
- package/spikes/frame-commenting/readme.ts +0 -61
- package/spikes/frame-commenting/results.json +0 -5320
- package/spikes/frame-commenting/run.ts +0 -73
- package/spikes/frame-commenting/setup.ts +0 -125
- package/spikes/lib/barrels.test.ts +0 -107
- package/spikes/lib/barrels.ts +0 -309
- package/spikes/lib/content-types.ts +0 -28
- package/spikes/lib/convert-commonjs.ts +0 -168
- package/spikes/lib/fragment.ts +0 -108
- package/spikes/lib/library-set.ts +0 -194
- package/spikes/lib/module-transform.test.ts +0 -133
- package/spikes/lib/module-transform.ts +0 -351
- package/spikes/lib/origin.ts +0 -140
- package/spikes/lib/pages.ts +0 -290
- package/spikes/lib/report.ts +0 -23
- package/spikes/lib/runtime-server.ts +0 -282
- package/spikes/lib/static-server.ts +0 -82
- package/spikes/lib/trace.ts +0 -384
- package/spikes/local-folder-link/README.md +0 -85
- package/spikes/local-folder-link/checkout.ts +0 -132
- package/spikes/local-folder-link/documents.ts +0 -36
- package/spikes/local-folder-link/readme.ts +0 -42
- package/spikes/local-folder-link/results.json +0 -12815
- package/spikes/local-folder-link/rewrite.test.ts +0 -27
- package/spikes/local-folder-link/rewrite.ts +0 -38
- package/spikes/local-folder-link/run.ts +0 -123
- package/spikes/local-folder-link/server.ts +0 -100
- package/spikes/local-folder-link/sw.ts +0 -97
- package/spikes/origin-isolation/README.md +0 -426
- package/spikes/origin-isolation/browsers.ts +0 -43
- package/spikes/origin-isolation/helper.ts +0 -6
- package/spikes/origin-isolation/host.ts +0 -25
- package/spikes/origin-isolation/measure.ts +0 -118
- package/spikes/origin-isolation/model.test.ts +0 -45
- package/spikes/origin-isolation/model.ts +0 -49
- package/spikes/origin-isolation/proxy.ts +0 -35
- package/spikes/origin-isolation/readme.ts +0 -83
- package/spikes/origin-isolation/results.json +0 -3242
- package/spikes/origin-isolation/run.ts +0 -35
- package/spikes/origin-isolation/server.ts +0 -108
- package/spikes/origin-isolation/sw.ts +0 -28
- package/spikes/origin-isolation/tenant.ts +0 -165
- package/spikes/react-runtime-set/README.md +0 -48
- package/spikes/react-runtime-set/convert.ts +0 -118
- package/spikes/react-runtime-set/export-names.mjs +0 -8
- package/spikes/react-runtime-set/page/page.js +0 -46
- package/spikes/react-runtime-set/results.json +0 -84
- package/spikes/react-runtime-set/run.ts +0 -255
- package/spikes/run.ts +0 -15
- package/spikes/sw-tenant-frame/README.md +0 -95
- package/spikes/sw-tenant-frame/results.json +0 -1348
- package/spikes/sw-tenant-frame/run.ts +0 -373
- package/spikes/sw-tenant-frame/site/frame.html +0 -113
- package/spikes/sw-tenant-frame/site/host.html +0 -25
- package/spikes/sw-tenant-frame/site/sw.js +0 -10
- package/spikes/tailwind-parity/README.md +0 -78
- package/spikes/tailwind-parity/compare.test.ts +0 -70
- package/spikes/tailwind-parity/compare.ts +0 -91
- package/spikes/tailwind-parity/facet-font-scale.d.ts +0 -6
- package/spikes/tailwind-parity/facet-styles.ts +0 -77
- package/spikes/tailwind-parity/results.json +0 -885
- package/spikes/tailwind-parity/run.ts +0 -385
- package/spikes/tailwind-parity/runtime-tailwind.ts +0 -82
- package/src/activity.test.ts +0 -57
- package/src/build/barrels.test.ts +0 -107
- package/src/build/dependency-runtime.test.ts +0 -121
- package/src/build/library-runtime.test.ts +0 -343
- package/src/dev/cli.test.ts +0 -12
- package/src/dev/packages.test.ts +0 -175
- package/src/editing.test.tsx +0 -31
- package/src/frame/activity.test.ts +0 -27
- package/src/frame/agent/overlay.test.ts +0 -42
- package/src/frame/agent/owner.test.ts +0 -78
- package/src/frame/agent/vocabulary.test.ts +0 -36
- package/src/frame/boot-bundle.test.ts +0 -20
- package/src/frame/boot-styles.test.ts +0 -102
- package/src/frame/boot.test.ts +0 -108
- package/src/frame/export-compiler.test.ts +0 -23
- package/src/frame/export.test.ts +0 -17
- package/src/frame/tailwind/cache.test.ts +0 -53
- package/src/frame/tailwind/load.test.ts +0 -74
- package/src/frame/tailwind/runtime-cache.test.ts +0 -97
- package/src/frame/tailwind/store.test.ts +0 -104
- package/src/frame/tailwind/tailwind.test.ts +0 -119
- package/src/host/BuildLog.test.tsx +0 -40
- package/src/host/PageFrame.test.tsx +0 -39
- package/src/host/activity-state.test.ts +0 -37
- package/src/host/agent-source.test.ts +0 -9
- package/src/host/agent-validation.test.ts +0 -40
- package/src/host/bridge-request.test.ts +0 -87
- package/src/host/bridge.test.ts +0 -34
- package/src/host/build-log.test.ts +0 -47
- package/src/host/clear-cache.test.ts +0 -75
- package/src/host/design-validation.test.ts +0 -38
- package/src/host/link/transport.test.ts +0 -10
- package/src/host/origin.test.ts +0 -10
- package/src/host/review/remote.test.ts +0 -21
- package/src/host/review/source.test.ts +0 -19
- package/src/host/review/validation.test.ts +0 -34
- package/src/host/runtime-integration.test.ts +0 -29
- package/src/host/source-path.test.ts +0 -14
- package/src/host/vocabulary-validation.test.ts +0 -60
- package/src/link/build.test.ts +0 -25
- package/src/link/commonjs.test.ts +0 -34
- package/src/link/overrides.test.ts +0 -103
- package/src/link/page-sources.test.ts +0 -52
- package/src/publication/publication.test.ts +0 -89
- package/src/storage/db.test.ts +0 -52
- package/src/sw/activity-router.test.ts +0 -53
- package/src/sw/candidates.test.ts +0 -9
- package/src/sw/compile.test.ts +0 -152
- package/src/sw/compiler.test.ts +0 -51
- package/src/sw/composition.test.ts +0 -51
- package/src/sw/converted-resolver.test.ts +0 -129
- package/src/sw/converted-router.test.ts +0 -91
- package/src/sw/converted.test.ts +0 -31
- package/src/sw/errors.test.ts +0 -8
- package/src/sw/link-activity.test.ts +0 -126
- package/src/sw/link-cache.test.ts +0 -15
- package/src/sw/link-markdown.test.ts +0 -52
- package/src/sw/link-route.test.ts +0 -150
- package/src/sw/link-source.test.ts +0 -31
- package/src/sw/markers.test.ts +0 -33
- package/src/sw/module-transform.test.ts +0 -131
- package/src/sw/package-generation.test.ts +0 -33
- package/src/sw/page-clients.test.ts +0 -37
- package/src/sw/profile.test.ts +0 -21
- package/src/sw/resolver.test.ts +0 -183
- package/src/sw/router-cache.test.ts +0 -78
- package/src/sw/runtime-module.test.ts +0 -61
- package/src/sw/source-hash.test.ts +0 -7
- package/src/sw/storage.test.ts +0 -108
- package/tsconfig.json +0 -10
- package/vitest.browser.config.ts +0 -4
- package/vitest.config.ts +0 -9
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/browser-client.ts +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/copy-to-clipboard-entry.headers +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/copy-to-clipboard-entry.mjs.txt +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/copy-to-clipboard-module.headers +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/copy-to-clipboard-module.mjs.txt +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/react-copy-to-clipboard-entry.headers +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/react-copy-to-clipboard-entry.mjs.txt +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/react-copy-to-clipboard-module.headers +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/react-copy-to-clipboard-module.mjs.txt +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/toggle-selection-entry.headers +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/toggle-selection-entry.mjs.txt +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/toggle-selection-module.headers +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/fixtures/toggle-selection-module.mjs.txt +0 -0
- /package/{spikes/esm-sh → src/sw/esm-sh-fixtures}/redact.ts +0 -0
package/src/schema.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Contracts shared across @flanksource/page-runtime: what a library build publishes (src/build) and what the service
|
|
2
2
|
// worker, frame and host read (src/sw, src/frame, src/host). Each slice extends this file only through the owner named
|
|
3
|
-
// in the plan's Execution section
|
|
4
|
-
// spikes/lib/module-transform.ts) and are the starting contract.
|
|
3
|
+
// in the plan's Execution section.
|
|
5
4
|
|
|
6
5
|
export type PageStylesRecipe = {
|
|
7
6
|
name: string;
|
|
@@ -44,6 +43,16 @@ export type CompilerPlugins = { remark: CompilerPlugin[] };
|
|
|
44
43
|
|
|
45
44
|
export type ImportMap ={ imports: Record<string, string>; scopes: Record<string, Record<string, string>> };
|
|
46
45
|
|
|
46
|
+
export type DocumentSource = {
|
|
47
|
+
page: string;
|
|
48
|
+
layout: string;
|
|
49
|
+
files: Record<string, { text: string } | { base64: string }>;
|
|
50
|
+
dependencies: Record<string, string>;
|
|
51
|
+
managed: Record<string, string>;
|
|
52
|
+
profileUrl?: string;
|
|
53
|
+
dynamicStyles?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* A library's barrel export index, published as `runtime/barrels.json`: for each entry barrel, the defining module of
|
|
49
58
|
* every named export (`modules[pos]`, or `[pos, importName]` when the name is re-exported under another one).
|
|
@@ -56,13 +65,17 @@ export type BarrelIndex = {
|
|
|
56
65
|
export type DependencyPolicy = "any" | "ask" | "strict";
|
|
57
66
|
export type RuntimePolicy = { dependencies: DependencyPolicy; allow?: string[] };
|
|
58
67
|
|
|
68
|
+
export type RuntimeExports = Pick<Fragment, "imports" | "scopes" | "remaps" | "integrity"> & { versions: Record<string, string> };
|
|
69
|
+
|
|
59
70
|
export type RuntimeProfile = {
|
|
71
|
+
renderJobs?: true;
|
|
60
72
|
runtimeDomain: string;
|
|
61
73
|
embedders: string[];
|
|
62
74
|
packageOrigin: string;
|
|
63
75
|
registry: string;
|
|
64
76
|
managed: Record<string, string>;
|
|
65
77
|
dependencies?: Record<string, string>;
|
|
78
|
+
runtimeExports?: true;
|
|
66
79
|
/** `any` allows every declared package; `ask` and `strict` allow only the names (or `*` globs) in `allow`. */
|
|
67
80
|
policy: RuntimePolicy;
|
|
68
81
|
/** CommonJS-to-ESM converter for packages without ESM entries; also added to `connect-src`. */
|
|
@@ -100,24 +113,37 @@ export type RuntimePhase = "resolve" | "fetch" | "compile" | "link" | "render" |
|
|
|
100
113
|
export type RuntimeError = { phase: RuntimePhase; message: string; file: string; line?: number; column?: number };
|
|
101
114
|
export type Theme = { theme: "light" | "dark"; density: "compact" | "comfortable" | "spacious" };
|
|
102
115
|
export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
|
|
116
|
+
export type SourceProvider = { url: string; paths: string[] };
|
|
103
117
|
export type HostMessage =
|
|
104
118
|
| AgentHostMessage
|
|
105
|
-
| { type: "open"; page: string; manifest: FolderManifest; lock?: PageLock; files: Record<string, string>; policy?: RuntimePolicy }
|
|
106
|
-
| { type: "
|
|
119
|
+
| { type: "open"; page: string; layout?: string; manifest: FolderManifest; lock?: PageLock; files: Record<string, string>; sourceProvider?: SourceProvider; policy?: RuntimePolicy }
|
|
120
|
+
| { type: "prepare-render"; open: OpenMessage }
|
|
121
|
+
| { type: "render"; data: JsonValue }
|
|
122
|
+
| { type: "sources"; files: Record<string, string | null>; data?: JsonValue }
|
|
107
123
|
| { type: "reload" }
|
|
108
124
|
| ({ type: "theme" } & Theme)
|
|
109
125
|
| { type: "data"; data: JsonValue }
|
|
110
126
|
| { type: "export"; format: "html" | "print" };
|
|
127
|
+
/** The `open` host message without its `type`: what `PageFrame` takes as `open` and what `formPageOpen` builds. */
|
|
128
|
+
export type OpenMessage = Omit<Extract<HostMessage, { type: "open" }>, "type">;
|
|
111
129
|
export type FrameMessage =
|
|
112
130
|
| import("./activity-schema.ts").ActivityMessage
|
|
113
131
|
| AgentFrameMessage
|
|
114
132
|
| { type: "lock"; lock: PageLock }
|
|
115
133
|
| { type: "status"; state: "connecting" | "booting" | "mounted" | "fonts" | "images" | "stylesheets" | "diagrams" | "hook" | "quiescence" | "ready" }
|
|
116
134
|
| { type: "error"; error: RuntimeError }
|
|
117
|
-
| { type: "snapshot"; html: string }
|
|
135
|
+
| { type: "snapshot"; html: string }
|
|
136
|
+
| { type: "prepared-render"; lock: PageLock; navigate: boolean; runtimeVersion: string }
|
|
137
|
+
| { type: "rendered"; html: string; modulesMs: number; readinessMs: number; snapshotMs: number }
|
|
138
|
+
/** A page-defined event with a JSON payload, sent through `host.emit` (see `PageHost`). */
|
|
139
|
+
| { type: "emit"; event: string; payload: JsonValue }
|
|
140
|
+
/** The rendered height of the page root in CSS pixels, sent whenever it changes. */
|
|
141
|
+
| { type: "size"; height: number };
|
|
142
|
+
/** What the runtime gives a page component next to its data: the page-to-host half of the bridge. */
|
|
143
|
+
export type PageHost = { emit(event: string, payload: JsonValue): void };
|
|
118
144
|
export type BridgeEnvelope<M = HostMessage | FrameMessage> = { bridge: "page-runtime-v1"; session: string; id?: string; re?: string; message: M };
|
|
119
145
|
|
|
120
|
-
export type FrameConfig = { page: string; entry: string; lock: PageLock; profile: RuntimeProfile; runtimeVersion: string };
|
|
146
|
+
export type FrameConfig = { page: string; entry: string; layout?: string; lock: PageLock; profile: RuntimeProfile; runtimeVersion: string };
|
|
121
147
|
|
|
122
148
|
export type AgentRect = { left: number; top: number; width: number; height: number };
|
|
123
149
|
export type AgentLocator = import("@flanksource/clicky-ui/comments").CommentLocator;
|
package/src/styles.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Normal declarations: dependencies first, derived libraries next, utilities last. */
|
|
2
|
+
export function cascadeOrder(layers: string[] = ['components', 'facet']): string {
|
|
3
|
+
const ordered = [...new Set(layers)];
|
|
4
|
+
for (const layer of ordered) if (!/^[a-zA-Z_][\w-]*$/.test(layer) || ['theme', 'base', 'utilities'].includes(layer)) throw new Error(`Invalid library cascade layer: ${layer}`);
|
|
5
|
+
return `@layer theme, base, ${ordered.join(', ')}, utilities;`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const layerOrder = cascadeOrder();
|
|
9
|
+
|
|
10
|
+
export function inspectStyles(document: Document): Record<string, string> {
|
|
11
|
+
const view = document.defaultView;
|
|
12
|
+
if (!view) throw new Error('Style inspection requires a live document');
|
|
13
|
+
const root = view.getComputedStyle(document.documentElement);
|
|
14
|
+
const body = view.getComputedStyle(document.body);
|
|
15
|
+
const documentRoot = document.querySelector('[data-facet-theme]') ?? document.body;
|
|
16
|
+
const documentStyle = view.getComputedStyle(documentRoot);
|
|
17
|
+
const heading = document.querySelector('h2');
|
|
18
|
+
const page = documentRoot.querySelector('[data-page-size]');
|
|
19
|
+
return {
|
|
20
|
+
order: [...document.querySelectorAll('style')].map(style => style.textContent?.match(/@layer\s+[^{};]+;/)?.[0]).find(Boolean) ?? 'No explicit layer order',
|
|
21
|
+
theme: documentRoot.getAttribute('data-facet-theme') ?? 'facet',
|
|
22
|
+
'--text-xl': root.getPropertyValue('--text-xl').trim(),
|
|
23
|
+
'--text-sm': root.getPropertyValue('--text-sm').trim(),
|
|
24
|
+
...Object.fromEntries([...new Set([...Array.from(root), ...Array.from(documentStyle)])]
|
|
25
|
+
.filter(name => /^--(?:facet|text)-/.test(name))
|
|
26
|
+
.map(name => [name, (documentStyle.getPropertyValue(name) || root.getPropertyValue(name)).trim()])),
|
|
27
|
+
'body font size': body.fontSize,
|
|
28
|
+
'document font size': documentStyle.fontSize,
|
|
29
|
+
'document font family': documentStyle.fontFamily,
|
|
30
|
+
'document line height': documentStyle.lineHeight,
|
|
31
|
+
'document text color': documentStyle.color,
|
|
32
|
+
'document background': documentStyle.backgroundColor === 'rgba(0, 0, 0, 0)' ? body.backgroundColor : documentStyle.backgroundColor,
|
|
33
|
+
'heading font size': heading ? view.getComputedStyle(heading).fontSize : 'No h2',
|
|
34
|
+
...(page ? {
|
|
35
|
+
'page size': page.getAttribute('data-page-size') ?? '',
|
|
36
|
+
...Object.fromEntries(['top', 'right', 'bottom', 'left'].map(side => [`page margin ${side}`, page.getAttribute(`data-margin-${side}`) ?? ''])),
|
|
37
|
+
} : {}),
|
|
38
|
+
stylesheets: [...document.querySelectorAll('[data-page-runtime-base]')].map(style => style.getAttribute('data-page-runtime-base')).join('\n'),
|
|
39
|
+
};
|
|
40
|
+
}
|
package/src/sw/compile.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { CommonJsSource } from "../link/types.ts";
|
|
|
11
11
|
|
|
12
12
|
/** Where page modules import the development JSX runtime from: a shim that marks host elements. */
|
|
13
13
|
export const DEV_SHIM_URL = "/__runtime/jsx-dev-runtime.js";
|
|
14
|
-
export const COMPILER_REVISION = "editable-boundaries-
|
|
14
|
+
export const COMPILER_REVISION = "editable-boundaries-live-v2";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Adds `data-source` to host elements from jsxDEV's source argument. MDX's development output passes a full
|
package/src/sw/compiler.ts
CHANGED
|
@@ -5,7 +5,7 @@ import remarkFrontmatter from "remark-frontmatter";
|
|
|
5
5
|
import remarkGfm from "remark-gfm";
|
|
6
6
|
import { remarkAlert } from "remark-github-blockquote-alert";
|
|
7
7
|
import type { PageLock } from "../schema.ts";
|
|
8
|
-
import { compileSource, DEV_SHIM_URL, type MdxPlugins } from "./compile.ts";
|
|
8
|
+
import { compileMdx, compileSource, DEV_SHIM_URL, type MdxPlugins } from "./compile.ts";
|
|
9
9
|
import { CANONICAL_CANDIDATES, defineNodeEnv, specifierKind, stylesheetModule, transformModule } from "./module-transform.ts";
|
|
10
10
|
import { resolveSpecifier } from "./composition.ts";
|
|
11
11
|
import { RuntimeFailure } from "./errors.ts";
|
|
@@ -13,7 +13,7 @@ import { sourceCandidates } from "./candidates.ts";
|
|
|
13
13
|
import type { WorkerActivity } from "../activity-schema.ts";
|
|
14
14
|
import { RUNTIME_MODULES } from "./runtime-module.ts";
|
|
15
15
|
|
|
16
|
-
export type CompilerOptions = { path: string; code: string; lock: PageLock; sources: string[]; plugins: MdxPlugins; activity?: WorkerActivity };
|
|
16
|
+
export type CompilerOptions = { path: string; code: string; lock: PageLock; sources: string[]; plugins: MdxPlugins; remark?: unknown[]; activity?: WorkerActivity; transpile?: (compile: () => Promise<string>) => Promise<string> };
|
|
17
17
|
export const BASE_PLUGINS: MdxPlugins = { remarkFrontmatter, remarkGfm, remarkAlert, rehypeRaw };
|
|
18
18
|
export const moduleUrl = (url: string): string => {
|
|
19
19
|
const parsed = new URL(url, "https://runtime.invalid");
|
|
@@ -39,7 +39,7 @@ function canonical(specifier: string, options: { path: string; lock: PageLock; s
|
|
|
39
39
|
if (!parsed.pathname.startsWith(prefix)) throw new Error(`${options.path}: unsupported module URL ${target}`);
|
|
40
40
|
const relative = parsed.pathname.slice(prefix.length);
|
|
41
41
|
const listing = source ? options.sources : Object.keys(options.lock.integrity);
|
|
42
|
-
const candidates = source ? ["", ".tsx", ".ts", ".jsx", ".js", ".mdx", ".md", "/index.tsx", "/index.ts", "/index.js"] : CANONICAL_CANDIDATES;
|
|
42
|
+
const candidates = source ? ["", ".tsx", ".ts", ".jsx", ".js", ".mdx", ".md", "/index.tsx", "/index.ts", "/index.jsx", "/index.js"] : CANONICAL_CANDIDATES;
|
|
43
43
|
const found = candidates.map((suffix) => `${relative}${suffix}`).find((file) => listing.includes(converted ? `esm/${file}` : file) || (!source && !converted && options.lock.remaps[file] !== undefined));
|
|
44
44
|
if (!found) throw new RuntimeFailure({ phase: "link", file: options.path, line: options.line, message: `${options.path}:${options.line}: cannot resolve ${specifier} to a canonical file` });
|
|
45
45
|
target = `${prefix}${source || converted ? found : options.lock.remaps[found] ?? found}`;
|
|
@@ -61,7 +61,10 @@ export async function rewriteImports(options: { code: string; path: string; lock
|
|
|
61
61
|
if (item.specifier === undefined) throw new RuntimeFailure({ phase: "link", file: options.path, line: code.slice(0, item.start).split("\n").length, message: `${options.path}: dynamic imports must name a literal module` });
|
|
62
62
|
const target = canonical(item.specifier, { ...options, line: code.slice(0, item.start).split("\n").length });
|
|
63
63
|
const quoted = /^['"`]/.test(code.slice(item.start, item.end));
|
|
64
|
-
const
|
|
64
|
+
const revision = new URL(options.path, "https://runtime.invalid").searchParams.get("revision");
|
|
65
|
+
const revised = new URL(target, "https://runtime.invalid");
|
|
66
|
+
if (revision && (revised.pathname.startsWith("/src/") || (revised.pathname.endsWith(".css") && revised.searchParams.has("module")))) revised.searchParams.set("revision", revision);
|
|
67
|
+
const text = moduleUrl(revised.href);
|
|
65
68
|
code = `${code.slice(0, item.start)}${quoted ? JSON.stringify(text) : text}${code.slice(item.end)}`;
|
|
66
69
|
}
|
|
67
70
|
return defineNodeEnv(code).code;
|
|
@@ -75,12 +78,16 @@ export async function compilePage(options: CompilerOptions): Promise<{ code: str
|
|
|
75
78
|
if (url.searchParams.has("raw")) code = `export default ${JSON.stringify(options.code)};`;
|
|
76
79
|
else if (url.searchParams.has("url")) code = `export default ${JSON.stringify(moduleUrl(url.pathname))};`;
|
|
77
80
|
else if (extension === ".json") code = `export default ${JSON.stringify(JSON.parse(options.code))};`;
|
|
78
|
-
else if (extension === ".css") code = stylesheetModule(options.code, moduleUrl(
|
|
81
|
+
else if (extension === ".css") { const stylesheet = new URL(url); stylesheet.searchParams.delete("module"); code = stylesheetModule(options.code, moduleUrl(stylesheet.href)); }
|
|
79
82
|
else if ([".ts", ".tsx", ".jsx", ".mdx", ".md"].includes(extension)) {
|
|
80
83
|
const started = performance.now();
|
|
81
|
-
|
|
84
|
+
const input = { path: url.pathname.slice("/src/".length), extension, code: options.code };
|
|
85
|
+
const transpile = () => options.remark && /^\.mdx?$/.test(extension)
|
|
86
|
+
? compileMdx(input, compile, options.plugins, options.remark)
|
|
87
|
+
: compileSource(input, { compile, plugins: options.plugins });
|
|
88
|
+
try { code = await (options.transpile ? options.transpile(transpile) : transpile()); }
|
|
82
89
|
finally { if (options.activity) options.activity.compileMs += performance.now() - started; }
|
|
83
90
|
} else if ([".js", ".mjs"].includes(extension)) code = options.code;
|
|
84
91
|
else throw new Error(`${options.path}: unsupported source extension ${extension}`);
|
|
85
|
-
return { code: await rewriteImports({ code, path:
|
|
92
|
+
return { code: await rewriteImports({ code, path: options.path, lock: options.lock, sources: options.sources, ...(options.activity ? { activity: options.activity } : {}) }), candidates: sourceCandidates({ path: url.pathname, code: options.code }) };
|
|
86
93
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
3
|
import { afterAll, beforeAll, expect, it } from "vitest";
|
|
4
|
-
import { startConvertedBrowserServer } from "
|
|
4
|
+
import { startConvertedBrowserServer } from "./esm-sh-fixtures/browser-server.ts";
|
|
5
5
|
|
|
6
6
|
const exec = promisify(execFile);
|
|
7
7
|
const session = `esm-sh-${process.pid}`;
|
package/src/sw/errors.ts
CHANGED
|
@@ -10,8 +10,21 @@ export class RuntimeFailure extends Error {
|
|
|
10
10
|
export function runtimeError(options: { error: unknown; phase: RuntimePhase; file: string }): RuntimeError {
|
|
11
11
|
if (options.error instanceof RuntimeFailure) return options.error.detail;
|
|
12
12
|
const message = options.error instanceof Error ? options.error.message : String(options.error);
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (options.error instanceof Error) {
|
|
14
|
+
for (const token of (options.error.stack ?? "").split(/\s+/)) {
|
|
15
|
+
const start = token.search(/\/(?:src|npm)\//);
|
|
16
|
+
if (start === -1) continue;
|
|
17
|
+
const frame = token.slice(start + 5).replace(/\)$/, "");
|
|
18
|
+
const columnAt = frame.lastIndexOf(":");
|
|
19
|
+
const lineAt = frame.lastIndexOf(":", columnAt - 1);
|
|
20
|
+
if (lineAt < 0) continue;
|
|
21
|
+
const line = frame.slice(lineAt + 1, columnAt);
|
|
22
|
+
const column = frame.slice(columnAt + 1);
|
|
23
|
+
if (!/^\d+$/.test(line) || !/^\d+$/.test(column)) continue;
|
|
24
|
+
const file = frame.slice(0, lineAt).split("?")[0]!;
|
|
25
|
+
return { phase: options.phase, file: decodeURIComponent(file), message, line: Number(line), column: Number(column) };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
const location = /(?:\(|:)(\d+):(\d+)\)?/.exec(message);
|
|
16
29
|
return { phase: options.phase, file: options.file, message, ...(location ? { line: Number(location[1]), column: Number(location[2]) } : {}) };
|
|
17
30
|
}
|
|
@@ -2,12 +2,12 @@ import { createServer, type Server, type ServerResponse } from "node:http";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { build } from "rolldown";
|
|
5
|
-
import type { Fragment } from "../../
|
|
6
|
-
import { digest } from "
|
|
7
|
-
import { contentSecurityPolicy } from "
|
|
5
|
+
import type { Fragment } from "../../schema.ts";
|
|
6
|
+
import { digest } from "../integrity.ts";
|
|
7
|
+
import { contentSecurityPolicy } from "../router.ts";
|
|
8
8
|
import { FACET, MANIFESTS, PROFILE, UI, recordedModules, registryResponse } from "./fixtures.ts";
|
|
9
9
|
|
|
10
|
-
const root = fileURLToPath(new URL("
|
|
10
|
+
const root = fileURLToPath(new URL("../../../", import.meta.url));
|
|
11
11
|
const require = createRequire(import.meta.url);
|
|
12
12
|
const runtime = `${UI}@0.3.0/dist/runtime/react@18.3.1/`;
|
|
13
13
|
const PAGE = `import React from "react";
|
|
@@ -63,7 +63,7 @@ export async function startConvertedBrowserServer() {
|
|
|
63
63
|
const modules = await recordedModules();
|
|
64
64
|
const files = await reactFiles();
|
|
65
65
|
const worker = await bundle("src/sw/worker.ts");
|
|
66
|
-
const client = await bundle("
|
|
66
|
+
const client = await bundle("src/sw/esm-sh-fixtures/browser-client.ts");
|
|
67
67
|
files.set(`${UI}@0.3.0/index.js`, 'import React from "react"; export const sharedReact = React;');
|
|
68
68
|
files.set(`${FACET}@0.1.0/index.js`, "export {};");
|
|
69
69
|
const integrity = Object.fromEntries(await Promise.all([...files].map(async ([path, code]) => [path, await digest(new TextEncoder().encode(code))])));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import type { Fragment, RuntimeProfile } from "../../
|
|
3
|
-
import type { PackageManifest } from "
|
|
2
|
+
import type { Fragment, RuntimeProfile } from "../../schema.ts";
|
|
3
|
+
import type { PackageManifest } from "../resolver.ts";
|
|
4
4
|
|
|
5
5
|
export const CONVERTER = "https://converter.example";
|
|
6
6
|
export const UI = "@flanksource/clicky-ui";
|
package/src/sw/link-compiler.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { pageSourceModule, pageSourcePath, validatePageSourceLinks, type PageSou
|
|
|
11
11
|
import type { LinkActivity } from "./link-activity.ts";
|
|
12
12
|
import { RUNTIME_MODULES } from "./runtime-module.ts";
|
|
13
13
|
|
|
14
|
-
type Context = { path: string; lock: PageSourceLock; links: StoredLink[]; sources: string[] };
|
|
14
|
+
type Context = { path: string; lock: PageSourceLock; links: StoredLink[]; sources: string[]; revision?: string };
|
|
15
15
|
const SOURCE_SUFFIXES = ["", ".tsx", ".ts", ".jsx", ".js", ".mdx", ".md", "/index.tsx", "/index.ts", "/index.js"];
|
|
16
16
|
|
|
17
17
|
function resolveLinked(specifier: string, options: Context): string {
|
|
@@ -38,7 +38,9 @@ function resolveLinked(specifier: string, options: Context): string {
|
|
|
38
38
|
if (query.has("raw")) target += "?raw";
|
|
39
39
|
else if (query.has("url")) target += "?url";
|
|
40
40
|
else if (/\.(css|json)$/.test(found)) target += "?module";
|
|
41
|
-
|
|
41
|
+
const revised = new URL(target, "https://runtime.invalid");
|
|
42
|
+
if (options.revision && revised.pathname.startsWith("/src/")) revised.searchParams.set("revision", options.revision);
|
|
43
|
+
return moduleUrl(revised.href);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export async function rewriteLinkImports(options: Context & { code: string }): Promise<string> {
|
|
@@ -75,7 +77,8 @@ type LinkCompileOptions = Context & { code: string; query: URLSearchParams; plug
|
|
|
75
77
|
|
|
76
78
|
export async function compileLinkModule(options: LinkCompileOptions): Promise<string> {
|
|
77
79
|
const compiled = await compileLinkSource(options);
|
|
78
|
-
|
|
80
|
+
const revision = options.query.get("revision");
|
|
81
|
+
return compiled.imports ? await rewriteLinkModule({ ...options, ...(revision ? { revision } : {}), code: compiled.code }) : compiled.code;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
export async function rewriteLinkModule(options: Context & { code: string; metrics?: LinkActivity }): Promise<string> {
|
|
@@ -96,7 +99,12 @@ export async function compileLinkSource(options: LinkCompileOptions): Promise<{
|
|
|
96
99
|
if (options.query.has("raw")) return { code: `export default ${JSON.stringify(options.code)};`, imports: false };
|
|
97
100
|
if (options.query.has("url")) return { code: `export default ${JSON.stringify(moduleUrl(options.path))};`, imports: false };
|
|
98
101
|
if (extension === ".json") return { code: `export default ${JSON.stringify(JSON.parse(options.code))};`, imports: false };
|
|
99
|
-
if (extension === ".css")
|
|
102
|
+
if (extension === ".css") {
|
|
103
|
+
const stylesheet = new URL(options.path, "https://runtime.invalid");
|
|
104
|
+
const revision = options.query.get("revision");
|
|
105
|
+
if (revision) stylesheet.searchParams.set("revision", revision);
|
|
106
|
+
return { code: stylesheetModule(options.code, moduleUrl(stylesheet.href)), imports: false };
|
|
107
|
+
}
|
|
100
108
|
const owner = options.links.find((link) => options.path.startsWith(`/link/${link.id}/`));
|
|
101
109
|
const commonjs = owner?.build.commonjs?.[decodeURIComponent(options.path.slice(`/link/${owner.id}/`.length))];
|
|
102
110
|
let code = options.code;
|
package/src/sw/link-route.ts
CHANGED
|
@@ -154,7 +154,7 @@ export function createLinkRoutes(options: Options) {
|
|
|
154
154
|
const url = new URL(request.url);
|
|
155
155
|
if (url.pathname === "/frame/__runtime-link-relay" || url.pathname === "/frame/_link-relay") return new Response(linkRelayDocument({ embedders: options.profile.embedders, allowed: options.profile.links === "allow" }), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
156
156
|
if (url.pathname === "/link/_control") {
|
|
157
|
-
try { return await control(request); } catch (error) { return new Response(
|
|
157
|
+
try { return await control(request); } catch (error) { console.error("Link control request rejected", error); return new Response("Link control request rejected", { status: 403 }); }
|
|
158
158
|
}
|
|
159
159
|
const frame = url.pathname.startsWith("/frame/");
|
|
160
160
|
if (!/^\/(src|npm|link|frame)\//.test(url.pathname) && url.pathname !== DEV_SHIM_URL && !Object.hasOwn(RUNTIME_MODULES, url.pathname)) return undefined;
|
package/src/sw/markers.ts
CHANGED
|
@@ -71,7 +71,7 @@ export function insertSourceMarkers(code: string, path: string, typescript: bool
|
|
|
71
71
|
const tag = code.slice(name.start, tokens[end - 1]!.end);
|
|
72
72
|
if (editable.has(tag)) {
|
|
73
73
|
const at = openingEnd(tokens, index);
|
|
74
|
-
if (tokens.slice(end, tokens.findIndex((item) => item.start === at)).some((item) => code.slice(item.start, item.end) === "data-source"
|
|
74
|
+
if (tokens.slice(end, tokens.findIndex((item) => item.start === at)).some((item) => code.slice(item.start, item.end) === "data-source")) throw new Error(`${path}:${line}:${column}: source markers are compiler-owned`);
|
|
75
75
|
const previous = insertions.findIndex((item) => item.at === afterTypeArguments(tokens, end - 1));
|
|
76
76
|
if (previous >= 0) insertions.splice(previous, 1);
|
|
77
77
|
insertions.push({ at, text: ` data-source=${JSON.stringify(formatEditableSource({ file: path, line, column, ordinal: ordinal++, hash }))} ` });
|
|
@@ -28,8 +28,10 @@ export function stylesheetModule(css: string, url: string): string {
|
|
|
28
28
|
return [
|
|
29
29
|
`const link = document.createElement("link");`,
|
|
30
30
|
`link.rel = "stylesheet"; link.href = ${JSON.stringify(url)};`,
|
|
31
|
+
'link.dataset.pageRuntimeStylesheet = new URL(link.href).pathname;',
|
|
32
|
+
'const previous = [...document.querySelectorAll("link[data-page-runtime-stylesheet]")].filter(item => item.dataset.pageRuntimeStylesheet === link.dataset.pageRuntimeStylesheet);',
|
|
31
33
|
`link.dataset.pageRuntime = "loading";`,
|
|
32
|
-
`const ready = new Promise((resolve, reject) => { link.onload = () => { link.dataset.pageRuntime = "loaded"; resolve(link.sheet); }; link.onerror = () => { link.dataset.pageRuntime = "error"; reject(new Error("stylesheet failed: " + link.href)); }; });`,
|
|
34
|
+
`const ready = new Promise((resolve, reject) => { link.onload = () => { for (const item of previous) item.remove(); link.dataset.pageRuntime = "loaded"; resolve(link.sheet); }; link.onerror = () => { link.dataset.pageRuntime = "error"; reject(new Error("stylesheet failed: " + link.href)); }; });`,
|
|
33
35
|
"document.head.append(link);",
|
|
34
36
|
`export const source = ${JSON.stringify(css)};`,
|
|
35
37
|
"export default ready;",
|
|
@@ -49,7 +51,17 @@ const PLAIN_NAME = new RegExp(String.raw`^${IDENTIFIER}$`, "u");
|
|
|
49
51
|
|
|
50
52
|
function unquote(name: string): string {
|
|
51
53
|
if (name.startsWith('"')) return JSON.parse(name) as string;
|
|
52
|
-
if (name.startsWith("'"))
|
|
54
|
+
if (name.startsWith("'")) {
|
|
55
|
+
let json = '"';
|
|
56
|
+
for (let i = 1; i < name.length - 1; i += 1) {
|
|
57
|
+
const char = name[i]!;
|
|
58
|
+
if (char === "\\") {
|
|
59
|
+
const escaped = name[++i]!;
|
|
60
|
+
json += escaped === "'" ? "'" : `\\${escaped}`;
|
|
61
|
+
} else json += char === '"' ? '\\"' : char;
|
|
62
|
+
}
|
|
63
|
+
return JSON.parse(`${json}"`) as string;
|
|
64
|
+
}
|
|
53
65
|
return name;
|
|
54
66
|
}
|
|
55
67
|
|
package/src/sw/profile.ts
CHANGED
|
@@ -35,7 +35,8 @@ function url(value: unknown, path: string, originOnly = false): void {
|
|
|
35
35
|
|
|
36
36
|
export function validateProfile(value: unknown): RuntimeProfile {
|
|
37
37
|
const p = record(value, "profile");
|
|
38
|
-
keys(p, ["runtimeDomain", "embedders", "packageOrigin", "registry", "managed", "dependencies", "policy", "convert", "minReleaseAgeDays", "network", "csp", "links", "sources", "readinessTimeoutMs"], "profile");
|
|
38
|
+
keys(p, ["runtimeDomain", "embedders", "packageOrigin", "registry", "managed", "dependencies", "runtimeExports", "policy", "convert", "minReleaseAgeDays", "network", "csp", "links", "sources", "readinessTimeoutMs", "renderJobs"], "profile");
|
|
39
|
+
if (p.renderJobs !== undefined && p.renderJobs !== true) throw new Error("profile.renderJobs: expected true");
|
|
39
40
|
if (typeof p.runtimeDomain !== "string" || !/^[a-z0-9.-]+(?::\d+)?$/i.test(p.runtimeDomain)) throw new Error("profile.runtimeDomain: invalid domain");
|
|
40
41
|
url(p.packageOrigin, "packageOrigin");
|
|
41
42
|
url(p.registry, "registry");
|
|
@@ -44,6 +45,7 @@ export function validateProfile(value: unknown): RuntimeProfile {
|
|
|
44
45
|
const managed = record(p.managed, "managed");
|
|
45
46
|
for (const [name, range] of Object.entries(managed)) if (!name || typeof range !== "string" || !range.trim()) throw new Error(`managed.${name}: expected range`);
|
|
46
47
|
if (p.dependencies !== undefined) validateDependencies(p.dependencies, "profile.dependencies");
|
|
48
|
+
if (p.runtimeExports !== undefined && p.runtimeExports !== true) throw new Error("profile.runtimeExports: expected true");
|
|
47
49
|
validatePolicy(p.policy);
|
|
48
50
|
if (p.convert !== undefined) {
|
|
49
51
|
const convert = record(p.convert, "convert");
|
package/src/sw/resolver.ts
CHANGED
|
@@ -8,10 +8,11 @@ import { CONVERTED_ENTRY, crawlConvertedPackage } from "./converted.ts";
|
|
|
8
8
|
import type { LibraryLink } from "../link/types.ts";
|
|
9
9
|
import { assertLinksAllowed, validateLink } from "../link/validation.ts";
|
|
10
10
|
import { composeLinkOverrides } from "../link/overrides.ts";
|
|
11
|
+
import { applyRuntimeExports } from "./runtime-exports.ts";
|
|
11
12
|
|
|
12
13
|
export type PackageManifest = { name: string; version: string; type?: string; main?: string; module?: string; exports?: unknown; dependencies?: Record<string, string>; peerDependencies?: Record<string, string>; sideEffects?: boolean | string[] };
|
|
13
14
|
type Metadata = { versions: Record<string, PackageManifest>; time: Record<string, string> };
|
|
14
|
-
export type ResolveOptions = { page: string; profile: RuntimeProfile; manifest: FolderManifest; lock?: PageLock; fetch?: typeof fetch; now?: number; links?: readonly LibraryLink[]; developerOverrides?: boolean };
|
|
15
|
+
export type ResolveOptions = { page: string; profile: RuntimeProfile; manifest: FolderManifest; lock?: PageLock; fetch?: typeof fetch; now?: number; links?: readonly LibraryLink[]; developerOverrides?: boolean; runtimeExportsUrl?: string };
|
|
15
16
|
class CommonJsOnlyError extends Error {}
|
|
16
17
|
|
|
17
18
|
export async function fetchJson<T>(fetcher: typeof fetch, url: string): Promise<T> {
|
|
@@ -100,8 +101,10 @@ export async function resolvePage(options: ResolveOptions): Promise<PageLock> {
|
|
|
100
101
|
}
|
|
101
102
|
const fetcher = options.fetch ?? fetch; const now = options.now ?? Date.now();
|
|
102
103
|
const requests = { ...profile.managed, ...profile.dependencies, ...options.manifest.dependencies, ...options.manifest.pageRuntime?.pages?.[options.page] };
|
|
104
|
+
if (profile.runtimeExports) Object.assign(requests, profile.managed);
|
|
103
105
|
const versions: Record<string, string> = {}; const manifests: PackageManifest[] = []; const fragments: Fragment[] = []; const indices: BarrelIndex[] = [];
|
|
104
|
-
|
|
106
|
+
const required = ["@flanksource/clicky-ui", "@flanksource/facet"];
|
|
107
|
+
for (const name of [...required, ...Object.keys(profile.managed).filter(name => !required.includes(name)).sort()]) {
|
|
105
108
|
if (!requests[name]) throw new Error(`${options.page}: missing managed range for ${name}`);
|
|
106
109
|
const local = links.find(link => link.build.library === name);
|
|
107
110
|
if (local) {
|
|
@@ -128,7 +131,8 @@ export async function resolvePage(options: ResolveOptions): Promise<PageLock> {
|
|
|
128
131
|
const facet = manifests[1]!;
|
|
129
132
|
const facetRange = facet.dependencies?.["@flanksource/clicky-ui"] ?? facet.peerDependencies?.["@flanksource/clicky-ui"];
|
|
130
133
|
if (!facetRange || !satisfiesVersion(versions["@flanksource/clicky-ui"]!, facetRange)) throw new Error(`${facet.name}@${facet.version} declares @flanksource/clicky-ui ${facetRange ?? "missing"} (package.json), rejects ${versions["@flanksource/clicky-ui"]} (folder/page override)`);
|
|
131
|
-
const
|
|
134
|
+
const pinned = profile.runtimeExports ? applyRuntimeExports(await fetchJson(fetcher, options.runtimeExportsUrl ?? new URL("/runtime-exports.json", profile.packageOrigin).href), composed, versions) : {};
|
|
135
|
+
const additional = Object.entries(requests).filter(([name]) => !Object.hasOwn(pinned, name) && !Object.hasOwn(profile.managed, name) && !manifests.some((m) => m.name === name) && !links.some(link => link.build.library === name));
|
|
132
136
|
const listings: Record<string, string> = {};
|
|
133
137
|
for (const [name, range] of additional) {
|
|
134
138
|
if (BASE_PACKAGES.includes(name)) throw new Error(`${options.page}: ${name} is part of the shared runtime set and cannot be declared as a dependency`);
|
|
@@ -180,7 +184,7 @@ async function addEsmPackage(options: AdditionalOptions): Promise<Record<string,
|
|
|
180
184
|
const [prefix, suffix = ""] = path.replace(/^\.\//, "").split("*");
|
|
181
185
|
for (const file of paths) {
|
|
182
186
|
const relative = file.slice(root.length + 1);
|
|
183
|
-
if (relative.startsWith(prefix!) && relative.endsWith(suffix)) imports[specifier.
|
|
187
|
+
if (relative.startsWith(prefix!) && relative.endsWith(suffix)) imports[specifier.replaceAll("*", () => relative.slice(prefix!.length, relative.length - suffix.length))] = `/npm/${file}`;
|
|
184
188
|
}
|
|
185
189
|
} else imports[specifier] = `/npm/${root}/${path.replace(/^\.\//, "")}`;
|
|
186
190
|
}
|
package/src/sw/router.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FrameConfig, HostMessage, PageLock, RuntimeError, RuntimePolicy, RuntimeProfile } from "../schema.ts";
|
|
2
2
|
import { validateHostMessage, validateSourcePath, validateLock } from "../host/validation.ts";
|
|
3
3
|
import { compilePage, moduleUrl, requestModuleUrl, rewriteImports } from "./compiler.ts";
|
|
4
|
+
import { fetchSource } from "./source-provider.ts";
|
|
4
5
|
import type { MdxPlugins } from "./compile.ts";
|
|
5
6
|
import { COMPILER_REVISION, DEV_SHIM, DEV_SHIM_URL } from "./compile.ts";
|
|
6
7
|
import { CONTENT_TYPES, extensionOf } from "./content-types.ts";
|
|
@@ -18,7 +19,11 @@ import { candidatesForPage, lazyRuntimeDb, putCandidates, tailwindCacheName } fr
|
|
|
18
19
|
export { digest, verifyIntegrity } from "./integrity.ts";
|
|
19
20
|
|
|
20
21
|
export type RouterOptions = { origin: string; version: string; profile: RuntimeProfile; plugins: MdxPlugins; caches: CacheStorage; indexedDB?: IDBFactory; fetch?: typeof fetch; onActivity?: (event: { request: Request; record: WorkerActivity }) => void };
|
|
21
|
-
type StoredPage = { lock: PageLock; files: Record<string, string>; manifest: Extract<HostMessage, { type: "open" }>["manifest"]; policy?: RuntimePolicy };
|
|
22
|
+
type StoredPage = { lock: PageLock; files: Record<string, string>; sourceProvider?: import("../schema.ts").SourceProvider; layout?: string; manifest: Extract<HostMessage, { type: "open" }>["manifest"]; policy?: RuntimePolicy };
|
|
23
|
+
const sourcePaths = (saved: StoredPage) => {
|
|
24
|
+
const prefix = saved.lock.page.slice(0, saved.lock.page.indexOf("/") + 1);
|
|
25
|
+
return [...new Set([...Object.keys(saved.files), ...(saved.sourceProvider?.paths ?? []).map(path => prefix + path)])];
|
|
26
|
+
};
|
|
22
27
|
const JS = { "content-type": "text/javascript; charset=utf-8" };
|
|
23
28
|
const serial = (value: unknown) => JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
24
29
|
const frameMetadata = new WeakMap<FrameConfig, { map: string; config: string }>();
|
|
@@ -38,6 +43,10 @@ export function frameDocument(options: { config?: FrameConfig; preload?: Iterabl
|
|
|
38
43
|
|
|
39
44
|
export function contentSecurityPolicy(profile: RuntimeProfile, nonce: string): string {
|
|
40
45
|
const directives: Record<string, string[]> = { "script-src": ["'self'", `'nonce-${nonce}'`], "style-src": ["'self'", "'unsafe-inline'"], "img-src": ["'self'", "data:", "blob:"], "connect-src": ["'self'", profile.packageOrigin, profile.registry, ...profile.network.allow.map((v) => new URL(v).origin)], "frame-ancestors": profile.embedders };
|
|
46
|
+
if (profile.renderJobs) {
|
|
47
|
+
Object.assign(directives, { "default-src": ["'none'"], "base-uri": ["'self'"], "form-action": ["'none'"], "worker-src": ["'self'"] });
|
|
48
|
+
directives["connect-src"]!.push("blob:");
|
|
49
|
+
}
|
|
41
50
|
if (profile.convert) directives["connect-src"]!.push(profile.convert.origin);
|
|
42
51
|
if (profile.csp.wasm) directives["script-src"]!.push("'wasm-unsafe-eval'");
|
|
43
52
|
for (const [name, values] of Object.entries(profile.csp.add)) directives[name] = [...(directives[name] ?? []), ...values];
|
|
@@ -48,6 +57,7 @@ export function createRouter(options: RouterOptions) {
|
|
|
48
57
|
const profile = validateProfile(options.profile); const fetcher = options.fetch ?? fetch;
|
|
49
58
|
const store = options.caches.open(`page-runtime-${options.version}-pages`);
|
|
50
59
|
const output = options.caches.open(`page-runtime-${options.version}-compiled`);
|
|
60
|
+
const transpiled = profile.renderJobs ? options.caches.open(`page-runtime-${options.version}-transpiled`) : undefined;
|
|
51
61
|
const packages = options.caches.open(`page-runtime-${options.version}-packages`);
|
|
52
62
|
const pages = new Map<string, Promise<StoredPage>>();
|
|
53
63
|
const modules = new WeakMap<PageLock, Map<string, Promise<{ response: Response; activity: WorkerActivity }>>>();
|
|
@@ -64,6 +74,7 @@ export function createRouter(options: RouterOptions) {
|
|
|
64
74
|
const database = lazyRuntimeDb(options.indexedDB ? { factory: options.indexedDB } : {});
|
|
65
75
|
const linkRoute = createLinkRoutes({ ...options, load, database });
|
|
66
76
|
const key = (page: string) => `${options.origin}/__runtime/pages/${encodeURIComponent(page)}`;
|
|
77
|
+
const sourceOwnerKey = (namespace: string) => `${options.origin}/__runtime/render-owner/${namespace}`;
|
|
67
78
|
async function load(page: string): Promise<StoredPage> {
|
|
68
79
|
let pending = pages.get(page);
|
|
69
80
|
if (!pending) {
|
|
@@ -84,18 +95,23 @@ export function createRouter(options: RouterOptions) {
|
|
|
84
95
|
}
|
|
85
96
|
return pending;
|
|
86
97
|
}
|
|
87
|
-
async function message(value: unknown): Promise<
|
|
98
|
+
async function message(value: unknown): Promise<FrameConfig> {
|
|
88
99
|
const m = validateHostMessage(value);
|
|
89
100
|
if (m.type !== "open") throw new Error("worker requires open message");
|
|
90
101
|
validateSourcePath(m.page);
|
|
102
|
+
const namespace = profile.renderJobs ? m.page.split('/')[0]! : undefined;
|
|
103
|
+
if (namespace && !/^[a-f0-9]{64}$/.test(namespace)) throw new Error("render source requires a content namespace");
|
|
91
104
|
const previous = await (await store).match(key(m.page));
|
|
92
105
|
const saved = previous ? await previous.json() as StoredPage : undefined;
|
|
93
106
|
const policy = m.policy ?? profile.policy;
|
|
94
107
|
const existing = m.lock ?? (saved?.lock.lock === 2 && serial(saved.manifest) === serial(m.manifest) && saved.policy && serial(saved.policy) === serial(policy) ? saved.lock : undefined);
|
|
95
108
|
const lock = await resolvePage({ page: m.page, profile: { ...profile, policy }, manifest: m.manifest, ...(existing ? { lock: existing } : {}), fetch: fetcher });
|
|
96
|
-
|
|
109
|
+
if (m.sourceProvider && new URL(m.sourceProvider.url).origin !== options.origin) throw new Error("source provider must use the runtime origin");
|
|
110
|
+
const savedPage: StoredPage = { lock, files: m.files, ...(m.sourceProvider ? { sourceProvider: m.sourceProvider } : {}), ...(m.layout ? { layout: m.layout } : {}), manifest: m.manifest, policy };
|
|
97
111
|
await (await store).put(key(m.page), Response.json(savedPage));
|
|
112
|
+
if (namespace) await (await store).put(sourceOwnerKey(namespace), new Response(m.page));
|
|
98
113
|
pages.set(m.page, Promise.resolve(savedPage));
|
|
114
|
+
return { page: m.page, entry: moduleUrl(`/src/${m.page}`), ...(m.layout ? { layout: moduleUrl(`/src/${m.layout}`) } : {}), lock, profile, runtimeVersion: options.version };
|
|
99
115
|
}
|
|
100
116
|
async function update(page: string, value: unknown): Promise<void> {
|
|
101
117
|
const m = validateHostMessage(value);
|
|
@@ -120,28 +136,46 @@ export function createRouter(options: RouterOptions) {
|
|
|
120
136
|
const code = exportModules.get(saved.lock.page)?.get(path);
|
|
121
137
|
if (code === undefined) throw new RuntimeFailure({ phase: "fetch", file: path, message: `no export compile is registered for ${path}; export the page again` });
|
|
122
138
|
activity.source = "compiled"; activity.generated = "export module"; activity.decodedBytes = byteLength(code);
|
|
123
|
-
const linked = await rewriteImports({ code, path: url.pathname
|
|
139
|
+
const linked = await rewriteImports({ code, path: `${url.pathname}${url.search}`, lock: saved.lock, sources: sourcePaths(saved), activity });
|
|
124
140
|
activity.outputBytes = byteLength(linked);
|
|
125
141
|
return new Response(linked, { headers: JS });
|
|
126
142
|
}
|
|
127
143
|
async function compiled(url: URL, saved: StoredPage, activity: WorkerActivity): Promise<Response> {
|
|
128
144
|
const path = decodeURIComponent(url.pathname.slice("/src/".length)); validateSourcePath(path);
|
|
129
|
-
|
|
145
|
+
let code = saved.files[path];
|
|
146
|
+
if (code === undefined && saved.sourceProvider) {
|
|
147
|
+
const prefix = saved.lock.page.slice(0, saved.lock.page.indexOf("/") + 1);
|
|
148
|
+
const response = await fetchSource({ provider: saved.sourceProvider, path: path.startsWith(prefix) ? path.slice(prefix.length) : path, fetch: fetcher });
|
|
149
|
+
if (!url.searchParams.has("module") && !url.searchParams.has("raw") && !url.searchParams.has("url") && !/\.(tsx?|jsx?|mdx?|mjs|css|json)$/.test(path)) return response;
|
|
150
|
+
code = await response.text();
|
|
151
|
+
}
|
|
130
152
|
if (code === undefined) throw new RuntimeFailure({ phase: "fetch", file: path, message: `source ${path} does not exist` });
|
|
131
153
|
activity.decodedBytes = byteLength(code); activity.source = "compiled";
|
|
132
154
|
const asModule = url.searchParams.has("module") || /\.(tsx?|jsx?|mdx?|mjs)$/.test(path) || url.searchParams.has("raw") || url.searchParams.has("url");
|
|
133
155
|
if (!asModule) { activity.outputBytes = activity.decodedBytes; return new Response(code, { headers: { "content-type": CONTENT_TYPES[extensionOf(path)] ?? "application/octet-stream" } }); }
|
|
134
|
-
const
|
|
156
|
+
const paths = sourcePaths(saved);
|
|
157
|
+
const hash = await digest(new TextEncoder().encode(serial({ compiler: COMPILER_REVISION, code, lock: saved.lock, query: [...url.searchParams], paths })));
|
|
135
158
|
const cacheKey = `${options.origin}/__runtime/compiled/${encodeURIComponent(hash)}`;
|
|
136
|
-
const
|
|
159
|
+
const jobModule = !!transpiled && url.searchParams.has("revision");
|
|
160
|
+
const hit = jobModule ? undefined : await (await output).match(cacheKey);
|
|
137
161
|
if (hit) { activity.source = "cache"; activity.cache = "storage"; activity.outputBytes = hit.headers.has("content-length") ? Number(hit.headers.get("content-length")) : (await hit.clone().arrayBuffer()).byteLength; return hit; }
|
|
138
162
|
let result;
|
|
139
|
-
|
|
163
|
+
const transpile = jobModule ? async (compile: () => Promise<string>) => {
|
|
164
|
+
const sourceKey = await digest(new TextEncoder().encode(serial({ compiler: COMPILER_REVISION, path, code })));
|
|
165
|
+
const url = `${options.origin}/__runtime/transpiled/${encodeURIComponent(sourceKey)}`;
|
|
166
|
+
const cache = await transpiled!;
|
|
167
|
+
const cached = await cache.match(url);
|
|
168
|
+
if (cached) return cached.text();
|
|
169
|
+
const source = await compile();
|
|
170
|
+
await cache.put(url, new Response(source));
|
|
171
|
+
return source;
|
|
172
|
+
} : undefined;
|
|
173
|
+
try { result = await compilePage({ path: `${url.pathname}${url.search}`, code, lock: saved.lock, sources: paths, plugins: options.plugins, activity, ...(transpile ? { transpile } : {}) }); }
|
|
140
174
|
catch (error) { throw error instanceof RuntimeFailure ? error : new RuntimeFailure(runtimeError({ error, phase: "compile", file: path })); }
|
|
141
175
|
activity.outputBytes = byteLength(result.code);
|
|
142
176
|
if (/\.(css|json)$/.test(path) || url.searchParams.has("raw") || url.searchParams.has("url")) { activity.source = "generated"; activity.generated = extensionOf(path) + " module"; }
|
|
143
177
|
const response = new Response(result.code, { headers: { ...JS, "content-length": String(activity.outputBytes), "x-page-candidates": encodeURIComponent(JSON.stringify(result.candidates)) } });
|
|
144
|
-
await (await output).put(cacheKey, response.clone());
|
|
178
|
+
if (!jobModule) await (await output).put(cacheKey, response.clone());
|
|
145
179
|
await putCandidates(await database(), { page: saved.lock.page, module: url.pathname, sourceHash: hash, candidates: result.candidates });
|
|
146
180
|
return response;
|
|
147
181
|
}
|
|
@@ -186,7 +220,7 @@ export function createRouter(options: RouterOptions) {
|
|
|
186
220
|
if (url.searchParams.has("url")) return respond(`export default ${JSON.stringify(moduleUrl(url.pathname))};`, "URL module");
|
|
187
221
|
if ([".js", ".mjs"].includes(ext)) {
|
|
188
222
|
const code = conversion ? await rewriteConvertedImports({ code: text, ...conversion }) : text;
|
|
189
|
-
return respond(await rewriteImports({ code, path: url.pathname, lock: saved.lock, sources:
|
|
223
|
+
return respond(await rewriteImports({ code, path: url.pathname, lock: saved.lock, sources: sourcePaths(saved), activity }));
|
|
190
224
|
}
|
|
191
225
|
if (url.searchParams.has("module") || request.destination === "script") {
|
|
192
226
|
if (ext === ".json") return respond(`export default ${JSON.stringify(JSON.parse(text))};`, "JSON module");
|
|
@@ -199,8 +233,14 @@ export function createRouter(options: RouterOptions) {
|
|
|
199
233
|
}
|
|
200
234
|
async function serve(request: Request, activity: WorkerActivity, onError?: (error: ReturnType<typeof runtimeError>) => void): Promise<Response> {
|
|
201
235
|
const url = new URL(request.url);
|
|
202
|
-
|
|
236
|
+
let page = url.searchParams.get("page") ?? (url.pathname.startsWith("/frame/") ? decodeURIComponent(url.pathname.slice(7)) : null);
|
|
203
237
|
try {
|
|
238
|
+
if (profile.renderJobs && url.pathname.startsWith("/src/")) {
|
|
239
|
+
const namespace = url.pathname.split('/')[2]!;
|
|
240
|
+
const owner = /^[a-f0-9]{64}$/.test(namespace) ? await (await store).match(sourceOwnerKey(namespace)) : undefined;
|
|
241
|
+
if (!owner) throw new Error(`${url.pathname}: render source is not registered`);
|
|
242
|
+
page = await owner.text();
|
|
243
|
+
}
|
|
204
244
|
if (activity.kind === "npm" && !activity.package) throw new Error(`invalid npm request: ${url.pathname}`);
|
|
205
245
|
if (url.origin !== options.origin) {
|
|
206
246
|
if (!permitsNetwork(profile, url.href)) { activity.error = { phase: "fetch", message: `egress denied: ${url.href}` }; activity.outputBytes = byteLength(activity.error.message); return new Response(activity.error.message, { status: 403 }); }
|
|
@@ -223,7 +263,7 @@ export function createRouter(options: RouterOptions) {
|
|
|
223
263
|
const exists = await (await store).match(key(page!));
|
|
224
264
|
const saved = exists ? await load(page!) : undefined;
|
|
225
265
|
let config = saved ? frameConfigs.get(saved.lock) : undefined;
|
|
226
|
-
if (saved && !config) { config = { page: page!, entry: moduleUrl(`/src/${page}`), lock: saved.lock, profile: { ...profile, packageOrigin: saved.lock.packageOrigin }, runtimeVersion: options.version }; frameConfigs.set(saved.lock, config); }
|
|
266
|
+
if (saved && !config) { config = { page: page!, entry: moduleUrl(`/src/${page}`), ...(saved.layout ? { layout: moduleUrl(`/src/${saved.layout}`) } : {}), lock: saved.lock, profile: { ...profile, packageOrigin: saved.lock.packageOrigin }, runtimeVersion: options.version }; frameConfigs.set(saved.lock, config); }
|
|
227
267
|
const document = frameDocument({ ...(config ? { config } : {}), ...(saved ? { preload: moduleGraph.get(saved.lock) ?? [] } : {}) });
|
|
228
268
|
activity.generated = "frame + import map"; activity.outputBytes = byteLength(document.html); activity.decodedBytes = activity.outputBytes;
|
|
229
269
|
return new Response(document.html, { headers: { "content-type": "text/html; charset=utf-8", "content-security-policy": contentSecurityPolicy(config?.profile ?? profile, document.nonce) } });
|