@tokenoftrust/storefront-runner 7.3.2 → 7.5.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.
Files changed (415) hide show
  1. package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
  2. package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
  3. package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
  4. package/apps/storefront/astro.config.mjs +8 -2
  5. package/apps/storefront/package.json +1 -2
  6. package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
  7. package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
  8. package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
  9. package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
  10. package/apps/storefront/src/layouts/Layout.astro +17 -0
  11. package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
  12. package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +32 -8
  13. package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +16 -2
  14. package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
  15. package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
  16. package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
  17. package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
  18. package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
  19. package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
  20. package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
  21. package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
  22. package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
  23. package/apps/storefront/src/lib/activity/store.ts +9 -3
  24. package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
  25. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
  26. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
  27. package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
  28. package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
  29. package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
  30. package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +447 -0
  31. package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
  32. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
  33. package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
  34. package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
  35. package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
  36. package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
  37. package/apps/storefront/src/middleware/controlPlane.ts +15 -1
  38. package/apps/storefront/src/middleware/index.ts +7 -3
  39. package/apps/storefront/src/middleware/renderChain.ts +46 -33
  40. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
  41. package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
  42. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
  43. package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
  44. package/apps/storefront/src/pages/products/[handle].astro +2 -15
  45. package/apps/storefront/tsconfig.astro.json +11 -0
  46. package/package.json +1 -1
  47. package/packages/public-runtime/src/activity/README.md +12 -0
  48. package/packages/public-runtime/src/activity/catalog.ts +7 -0
  49. package/packages/public-runtime/src/activity/event.ts +19 -0
  50. package/packages/public-runtime/src/activity/redaction.ts +31 -2
  51. package/packages/public-runtime/src/catalog-files.ts +3 -2
  52. package/packages/public-runtime/src/checkout-orders.ts +18 -19
  53. package/packages/public-runtime/src/checkout.ts +70 -0
  54. package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
  55. package/packages/public-runtime/src/compliance/index.ts +1 -1
  56. package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
  57. package/packages/public-runtime/src/compliance/profile.ts +268 -20
  58. package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
  59. package/packages/public-runtime/src/customization-runtime.ts +1 -1
  60. package/packages/public-runtime/src/product.ts +9 -1
  61. package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
  62. package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
  63. package/pnpm-lock.runner.yaml +0 -15
  64. package/scripts/tenant/materialize-tenant-content.mjs +3 -0
  65. package/scripts/tenant/validate.mjs +128 -0
  66. package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
  67. package/apps/storefront/drizzle.config.apps.ts +0 -13
  68. package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
  69. package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
  70. package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
  71. package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
  72. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
  73. package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
  74. package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
  75. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
  76. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
  77. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
  78. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
  79. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
  80. package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
  81. package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
  82. package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
  83. package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
  84. package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
  85. package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
  86. package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
  87. package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
  88. package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
  89. package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
  90. package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
  91. package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
  92. package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
  93. package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
  94. package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
  95. package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
  96. package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
  97. package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
  98. package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
  99. package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
  100. package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
  101. package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
  102. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
  103. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
  104. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
  105. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
  106. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
  107. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
  108. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
  109. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
  110. package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
  111. package/apps/storefront/perf/README.md +0 -64
  112. package/apps/storefront/perf/assert-budgets.ts +0 -159
  113. package/apps/storefront/platform-reconcile-tenants.json +0 -3
  114. package/apps/storefront/playwright.config.ts +0 -23
  115. package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
  116. package/apps/storefront/public/js/dashboard-apps.js +0 -183
  117. package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
  118. package/apps/storefront/public/js/dashboard-delegate.js +0 -167
  119. package/apps/storefront/public/js/dashboard-team.js +0 -356
  120. package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
  121. package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
  122. package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
  123. package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
  124. package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
  125. package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
  126. package/apps/storefront/src/config/storeName.ts +0 -34
  127. package/apps/storefront/src/lib/access/admin/README.md +0 -122
  128. package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
  129. package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
  130. package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
  131. package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
  132. package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
  133. package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
  134. package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
  135. package/apps/storefront/src/lib/access/dashboard/agentStoreEntry.ts +0 -253
  136. package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
  137. package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -153
  138. package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -474
  139. package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
  140. package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
  141. package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
  142. package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
  143. package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
  144. package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
  145. package/apps/storefront/src/lib/activity/alerts.ts +0 -426
  146. package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
  147. package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
  148. package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
  149. package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
  150. package/apps/storefront/src/lib/activity/query.ts +0 -403
  151. package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
  152. package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
  153. package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
  154. package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
  155. package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
  156. package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
  157. package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
  158. package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
  159. package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
  160. package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
  161. package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
  162. package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
  163. package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
  164. package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
  165. package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
  166. package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
  167. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
  168. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
  169. package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
  170. package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
  171. package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
  172. package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
  173. package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
  174. package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
  175. package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
  176. package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
  177. package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
  178. package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
  179. package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
  180. package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
  181. package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
  182. package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
  183. package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
  184. package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
  185. package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
  186. package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
  187. package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
  188. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
  189. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
  190. package/apps/storefront/src/lib/content/index.ts +0 -27
  191. package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
  192. package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
  193. package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
  194. package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
  195. package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
  196. package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
  197. package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
  198. package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
  199. package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
  200. package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
  201. package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
  202. package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
  203. package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
  204. package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
  205. package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
  206. package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
  207. package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
  208. package/apps/storefront/src/lib/developer-experience/dev/agentGrantAttestation.ts +0 -74
  209. package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
  210. package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
  211. package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
  212. package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
  213. package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
  214. package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
  215. package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
  216. package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
  217. package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
  218. package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
  219. package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
  220. package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
  221. package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
  222. package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
  223. package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
  224. package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
  225. package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
  226. package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
  227. package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
  228. package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
  229. package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
  230. package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
  231. package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
  232. package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
  233. package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
  234. package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
  235. package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
  236. package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
  237. package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
  238. package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
  239. package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
  240. package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
  241. package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
  242. package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
  243. package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
  244. package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
  245. package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
  246. package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
  247. package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
  248. package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
  249. package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
  250. package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
  251. package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
  252. package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
  253. package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
  254. package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
  255. package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
  256. package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
  257. package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
  258. package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
  259. package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
  260. package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
  261. package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
  262. package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
  263. package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
  264. package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
  265. package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
  266. package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
  267. package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
  268. package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
  269. package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
  270. package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
  271. package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
  272. package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
  273. package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
  274. package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
  275. package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
  276. package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
  277. package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
  278. package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
  279. package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
  280. package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
  281. package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
  282. package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
  283. package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
  284. package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
  285. package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
  286. package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
  287. package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
  288. package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
  289. package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
  290. package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
  291. package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
  292. package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
  293. package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
  294. package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
  295. package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
  296. package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
  297. package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
  298. package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
  299. package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
  300. package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
  301. package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
  302. package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
  303. package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
  304. package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
  305. package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
  306. package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
  307. package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
  308. package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
  309. package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
  310. package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
  311. package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
  312. package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
  313. package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
  314. package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
  315. package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
  316. package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
  317. package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
  318. package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
  319. package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
  320. package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
  321. package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
  322. package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
  323. package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
  324. package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
  325. package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
  326. package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
  327. package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
  328. package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
  329. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
  330. package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
  331. package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
  332. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
  333. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
  334. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
  335. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
  336. package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
  337. package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
  338. package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
  339. package/apps/storefront/src/pages/api/contact.ts +0 -144
  340. package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
  341. package/apps/storefront/src/styles/admin.css +0 -1161
  342. package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
  343. package/apps/storefront/test/pipeline/harness.ts +0 -209
  344. package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
  345. package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
  346. package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
  347. package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
  348. package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
  349. package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
  350. package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
  351. package/apps/storefront/vitest.config.cts +0 -44
  352. package/apps/storefront/vitest.faults.config.cts +0 -13
  353. package/apps/storefront/vitest.workers.config.cts +0 -7
  354. package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
  355. package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
  356. package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
  357. package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
  358. package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
  359. package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
  360. package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
  361. package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
  362. package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
  363. package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
  364. package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
  365. package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
  366. package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
  367. package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
  368. package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
  369. package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
  370. package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
  371. package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
  372. package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
  373. package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
  374. package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
  375. package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
  376. package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
  377. package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
  378. package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
  379. package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
  380. package/packages/feedback/package.json +0 -35
  381. package/packages/feedback/scripts/build-player.mjs +0 -28
  382. package/packages/feedback/src/index.ts +0 -1
  383. package/packages/feedback/src/primitives/composer.ts +0 -639
  384. package/packages/feedback/src/primitives/dialog.ts +0 -263
  385. package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
  386. package/packages/feedback/src/primitives/index.ts +0 -10
  387. package/packages/feedback/src/primitives/launcher.ts +0 -200
  388. package/packages/feedback/src/primitives/picker.ts +0 -663
  389. package/packages/feedback/src/primitives/redaction.ts +0 -204
  390. package/packages/feedback/src/primitives/selection.ts +0 -49
  391. package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
  392. package/packages/feedback/src/primitives/styles.ts +0 -77
  393. package/packages/feedback/src/primitives/surface.ts +0 -124
  394. package/packages/feedback/src/primitives/target.ts +0 -293
  395. package/packages/feedback/src/tour/canonical.ts +0 -27
  396. package/packages/feedback/src/tour/index.ts +0 -3
  397. package/packages/feedback/src/tour/player/browser.ts +0 -5
  398. package/packages/feedback/src/tour/player/host.ts +0 -12
  399. package/packages/feedback/src/tour/player/index.ts +0 -205
  400. package/packages/feedback/src/tour/player/manifest.ts +0 -76
  401. package/packages/feedback/src/tour/player/player.css +0 -130
  402. package/packages/feedback/src/tour/player/resolver.ts +0 -12
  403. package/packages/feedback/src/tour/player/surface.ts +0 -295
  404. package/packages/feedback/src/tour/player/types.ts +0 -8
  405. package/packages/feedback/src/tour/resolve/core.ts +0 -267
  406. package/packages/feedback/src/tour/resolve/dom.ts +0 -115
  407. package/packages/feedback/src/tour/resolve/index.ts +0 -29
  408. package/packages/feedback/src/tour/sanitize.ts +0 -76
  409. package/packages/feedback/src/tour/schema.ts +0 -362
  410. package/packages/feedback/src/v1/guards.ts +0 -335
  411. package/packages/feedback/src/v1/index.ts +0 -3
  412. package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
  413. package/packages/feedback/src/v1/types.ts +0 -177
  414. package/packages/feedback/tsconfig.json +0 -9
  415. package/packages/feedback/vitest.config.cts +0 -21
@@ -1,500 +0,0 @@
1
- /**
2
- * Hosted /dev activity log (hosted-dev-activity-bridge). Polls
3
- * GET /api/dev/activity — a translated, file-level feed of what the local dev
4
- * loop reported — and renders it newest-first. Also drives the "your edit
5
- * landed" celebration: the first poll primes a baseline (sessionStorage, same
6
- * survive-a-reload rationale as the local stepper's editBase), and any LATER
7
- * event past that baseline triggers the banner + a lightweight confetti
8
- * burst. POLL (not SSE): Workers are stateless per request, so a redeploy
9
- * mid-session needs no reconnect logic here. Imported from a processed
10
- * `<script>` in cockpit.astro (ADR 0013), rendered only when hostedActivity
11
- * (never alongside the isLocalDevLoop-gated local scripts). basePath is read
12
- * from `document.body.dataset`.
13
- */
14
- export function initHostedActivity(): void {
15
- const root = document.getElementById("hostedActivity");
16
- if (!root) return;
17
-
18
- // The request's tenant prefix ("" host-routed, "/<tenant>" path-routed). Every
19
- // /api/dev/* call below carries it so the activity feed + the CLI sign-in-code mint
20
- // run in THIS store's scope (locals.tenant on the API request) — the same store this
21
- // /<tenant>/cockpit rendered for, never the session's first membership.
22
- const basePath = document.body.dataset.cockpitBasePath || "";
23
-
24
- // ?reset — a TRUE reset for re-testing the onboarding loop: clear THIS browser's
25
- // stepper progress AND the server-side KV (live-runtime record + activity buffer),
26
- // then reload clean. Clearing the server too means a stopped local loop stops reading
27
- // as "up" immediately instead of lingering until the runtime TTL/live-window expires.
28
- try {
29
- if (/[?&]reset\b/.test(location.search)) {
30
- ["tot.hosted.steps", "tot.hosted.current", "tot.hosted.editBase"].forEach((k) => {
31
- try { window.sessionStorage.removeItem(k); } catch (e) {}
32
- });
33
- let reloaded = false;
34
- const doneReset = () => { if (reloaded) return; reloaded = true; location.replace(location.pathname); };
35
- setTimeout(doneReset, 2000); // fallback so a hung request still lands us fresh
36
- try { fetch(basePath + "/api/dev/activity", { method: "DELETE", cache: "no-store" }).then(doneReset, doneReset); }
37
- catch (e) { doneReset(); }
38
- return; // the post-clear reload re-runs this script against a fresh, empty state
39
- }
40
- } catch (e) {}
41
-
42
- const tableEl: any = document.getElementById("haTable");
43
- const bodyEl: any = document.getElementById("haBody");
44
- const emptyEl: any = document.getElementById("haEmpty");
45
-
46
- // Bridge strip — the rail's power source, fed by the SAME poll's `runtime` object
47
- // (no second poller). `runtime` is { cliVersion, runnerVersion, url, aliveAt, live }
48
- // reported by the developer's local `tot` CLI; absent until its data layer lands,
49
- // so every read here is defensive (missing runtime -> the strip stays hidden).
50
- const bridge: any = document.getElementById("bridge");
51
- const bUrl: any = document.getElementById("bUrl");
52
- const bGo: any = document.getElementById("bGo");
53
- const bKicker = document.getElementById("bKicker");
54
- const bHint: any = document.getElementById("bHint");
55
- const bDiag: any = document.getElementById("bDiag");
56
- const bTxt: any = document.getElementById("bTxt");
57
- const bObstacle: any = document.getElementById("bObstacle");
58
- const bObTitle = document.getElementById("bObTitle");
59
- const bObMsg = document.getElementById("bObMsg");
60
- const bObCmd: any = document.getElementById("bObCmd");
61
- const bObNote = document.getElementById("bObNote");
62
- const doneRunMeta = document.getElementById("doneRunMeta");
63
- let sawLive = false;
64
- function updateBridge(rt: any, obstacle: any) {
65
- if (!bridge) return;
66
- const live = !!(rt && rt.live);
67
- if (live) sawLive = true;
68
- // Obstacle lane (v2 §6): a failed `tot start` is the ONE reason the strip
69
- // shows BEFORE the loop was ever live this page-view — the developer needs the
70
- // fix, not a silent "watching…". The server returns `obstacle` only when there
71
- // is no live heartbeat, so a live loop supersedes it. Fill from server copy.
72
- if (obstacle && !live) {
73
- bridge.hidden = false;
74
- bridge.setAttribute("data-live", "obstacle");
75
- if (bTxt) bTxt.hidden = true;
76
- if (bDiag) bDiag.hidden = true;
77
- if (bGo) bGo.hidden = true;
78
- if (bHint) bHint.hidden = true;
79
- if (bObstacle) bObstacle.hidden = false;
80
- if (bObTitle) bObTitle.textContent = obstacle.title || "Setup hit a snag";
81
- if (bObMsg) bObMsg.textContent = obstacle.message || "";
82
- if (bObCmd) {
83
- if (obstacle.fixCommand) { bObCmd.textContent = obstacle.fixCommand; bObCmd.hidden = false; }
84
- else bObCmd.hidden = true;
85
- }
86
- if (bObNote) bObNote.textContent = obstacle.fixNote || "";
87
- return;
88
- }
89
- // Back to the normal live/quiet strip: restore the pieces the obstacle state hid.
90
- if (bObstacle) bObstacle.hidden = true;
91
- if (bTxt) bTxt.hidden = false;
92
- if (!rt || !rt.url) { bridge.hidden = true; return; }
93
- // On FIRST arrival, a stale runtime record (offline, never seen live this
94
- // page-view — e.g. left over from a prior run, still within the heartbeat TTL)
95
- // must NOT show — let Step 1 "Get your store running" do the work. Only surface
96
- // the strip once it's live, or after it's gone quiet HAVING been live this page-view.
97
- if (!live && !sawLive) { bridge.hidden = true; return; }
98
- bridge.hidden = false;
99
- bridge.setAttribute("data-live", live ? "1" : "0");
100
- if (bUrl) { bUrl.textContent = rt.url; bUrl.href = rt.url; }
101
- // No point offering "Open your store" to a server that stopped answering.
102
- if (bGo) { bGo.href = rt.url; bGo.hidden = !live; }
103
- if (bKicker) bKicker.textContent = live ? "Live on your machine" : "Went quiet";
104
- if (bHint) bHint.hidden = live; // recovery hint only while offline
105
- if (doneRunMeta) doneRunMeta.textContent = rt.url; // the collapsed Step-1 row's meta
106
- if (bDiag) {
107
- if (rt.cliVersion) {
108
- bDiag.textContent = "tot CLI v" + rt.cliVersion + (rt.runnerVersion ? " · runner v" + rt.runnerVersion : "");
109
- bDiag.hidden = false;
110
- } else {
111
- bDiag.hidden = true;
112
- }
113
- }
114
- updateEditHint(rt); // suggest the exact "open this file" command on Step 2
115
- }
116
-
117
- // Item 6 — once the CLI reports the developer's $EDITOR, show the EXACT command to
118
- // open the first file to edit (e.g. `code content/home.html`). Without one, guess
119
- // from the browser's OS (a reasonable proxy for the local dev machine in the common
120
- // case of viewing the cockpit on the same laptop) and default to VS Code (`code`) —
121
- // the most common case — with an alternate + AI-agent note underneath.
122
- const editOpenCmd = document.getElementById("editOpenCmd");
123
- const editOpenHint = document.getElementById("editOpenHint");
124
- function platformOpenDirCmd(dirArg: string) {
125
- const plat = String(((navigator as any).userAgentData && (navigator as any).userAgentData.platform) || navigator.platform || navigator.userAgent || "");
126
- if (/win/i.test(plat)) return "explorer " + dirArg;
127
- if (/mac/i.test(plat)) return "open " + dirArg;
128
- return "xdg-open " + dirArg;
129
- }
130
- function updateEditHint(rt: any) {
131
- if (!editOpenCmd) return;
132
- const editor = rt && typeof rt.editor === "string" ? rt.editor : "";
133
- const cwd = rt && typeof rt.cwd === "string" ? rt.cwd : "";
134
- // Prefer the FULL path (works from any directory) when the CLI reports the
135
- // project dir; else a project-relative path with a "run it from there" note.
136
- const file = cwd ? (cwd.replace(/\/+$/, "") + "/content/home.html") : "content/home.html";
137
- editOpenCmd.textContent = (editor || "code") + " " + file;
138
- if (editOpenHint) {
139
- if (editor) {
140
- editOpenHint.textContent = cwd
141
- ? "Run that anywhere to open the file — then change a line and save."
142
- : "Run that from your project directory — then change a line and save.";
143
- } else {
144
- const altCmd = platformOpenDirCmd(cwd || ".");
145
- editOpenHint.textContent = "Using VS Code? Run that. Prefer Cursor, another editor, or an AI coding " +
146
- "agent like Claude? Same idea — open the folder (`" + altCmd + "`) or file above and edit there. " +
147
- "Set $EDITOR and we'll show your exact command instead.";
148
- }
149
- }
150
- }
151
-
152
- const SS = window.sessionStorage;
153
- function load(k: string, d: any) { try { const v = SS.getItem(k); return v === null ? d : JSON.parse(v); } catch (e) { return d; } }
154
- function put(k: string, v: any) { try { SS.setItem(k, JSON.stringify(v)); } catch (e) {} }
155
-
156
- let baseline = load("tot.hosted.editBase", null); // null = not yet primed by a first poll
157
- let expanded = false; // activity list: last 3 by default, expand to all
158
- // Have we seen the store go live during THIS PAGE VIEW? In-memory ONLY (not
159
- // persisted): a fresh land or a reload starts false, so a stale/offline record can
160
- // never greet the developer with "went quiet" — Step 1 owns that moment. The
161
- // recovery ("went quiet") state shows only after we actually watched it live → drop.
162
-
163
- // Guided accordion. Each step opens with its content; when its activity is detected
164
- // it animates CLOSED to a reopenable done-bar, and a single "Next Up" panel at the
165
- // bottom expands to tease the following step with ONE CTA that opens it.
166
- // steps = completion flags {run, edit}
167
- // current = the OPEN step key, or null between steps (Next Up showing)
168
- // Both persisted so a reload restores the exact place in the flow.
169
- const steps = load("tot.hosted.steps", { run: false, edit: false });
170
- // Live-driven flow. current is the EXPLICITLY-opened step ("run" when Step 1 was
171
- // reopened, "edit"/"next" for those) or null — the default view, where Step 1's
172
- // open/minimized state is driven by whether localhost is LIVE. NOT persisted: a
173
- // refresh lands in this default view (progress in steps still persists).
174
- let current: string | null = null;
175
- let liveNow = false; // is localhost live right now? set each poll from runtime.live
176
- const bodies: any = {
177
- run: document.getElementById("stage-run"),
178
- edit: document.getElementById("hosted-stage-edit"),
179
- next: document.getElementById("hosted-stage-next"),
180
- };
181
- // Rail station elements — the reskin's DOM (applyView targets these).
182
- const stEls: any = {
183
- run: document.getElementById("st-run"),
184
- edit: document.getElementById("st-edit"),
185
- next: document.getElementById("st-next"),
186
- };
187
- const segRun: any = document.getElementById("seg-run");
188
- const segEdit: any = document.getElementById("seg-edit");
189
- const doneRunEl: any = document.getElementById("done-run");
190
- const doneEditEl: any = document.getElementById("done-edit");
191
- const doneEditMeta = document.getElementById("doneEditMeta");
192
- const lockEditEl: any = document.getElementById("lock-edit");
193
- const lockNextEl: any = document.getElementById("lock-next");
194
- const teaseEditEl: any = document.getElementById("tease-edit");
195
- const teaseNextEl: any = document.getElementById("tease-next");
196
- const quietNoteEl: any = document.getElementById("quietNote");
197
-
198
- // Persisted state mutations funnel through here so the sessionStorage write can
199
- // never be forgotten at a call site (progress in steps + the edit baseline are
200
- // the only things that survive a reload).
201
- function completeStep(key: string) {
202
- if (steps[key]) return false; // already done — no-op
203
- steps[key] = true; put("tot.hosted.steps", steps);
204
- return true; // "just completed" — caller may celebrate
205
- }
206
- function setBaseline(v: number) { baseline = v; put("tot.hosted.editBase", baseline); }
207
-
208
- // ============================================================================
209
- // STATE → VIEW → DOM. The flow's behaviour is split into three layers so the
210
- // rules live in ONE readable place and every render goes through one path:
211
- // 1. derive — computeView(): pure, reads state (steps/current/liveNow),
212
- // returns a view model. EVERY visibility/emphasis rule is here.
213
- // 2. apply — applyView(): the ONLY code that mutates the rail DOM (station
214
- // statuses, segment lit/flow, step bodies, done rows, locked
215
- // labels, teasers, quiet note, activity).
216
- // 3. renderSteps(): apply(compute()). Call after ANY state change — never poke
217
- // an element directly from a handler or the poll.
218
- // The signal-rail reskin kept layer 1's RULES verbatim (only added derived
219
- // fields) and rewrote applyView() + the markup/CSS it targets.
220
- // ============================================================================
221
-
222
- // --- derive ---------------------------------------------------------------
223
- function unlocked(step: string) {
224
- return step === "run" || (step === "edit" && steps.run) || (step === "next" && steps.edit);
225
- }
226
- // Step 1 is OPEN while you still need to get the store running (localhost not live) or
227
- // when you explicitly reopened it; it MINIMIZES to a done row once localhost is live —
228
- // in opposition to revealing the Step-2 teaser.
229
- function step1Open() {
230
- return current === "run" || (current === null && !(steps.run && liveNow));
231
- }
232
- // The complete view model — no DOM access, so the rules can be read top to bottom:
233
- // open which step BODY is expanded {run, edit, next}
234
- // seg which rail segment is LIT {run, edit}
235
- // flow do lit segments flow downward (live) boolean
236
- // stRun/Edit/Next each station's status "open" | "done" | "next" | "locked"
237
- // teaseEdit/Next is that step's forward teaser shown (live-gated)
238
- // doneRun/Edit is that step's collapsed done row shown
239
- // lockEdit/Next is that step's locked label shown
240
- // quietNote the Step-1 "went quiet" note (re-inflated after a drop)
241
- // showActivity is "Your activity" visible (NEVER while Step 1 is open)
242
- function computeView() {
243
- const s1 = step1Open();
244
- // Forward teasers show ONLY while localhost is live — a forward CTA only makes
245
- // sense while the loop is alive. When the loop goes quiet Step 1 re-inflates to own
246
- // that moment, so the teaser retracts. Either is also hidden while the step it
247
- // teases is already open.
248
- const teaseEdit = steps.run && !steps.edit && liveNow && current !== "edit";
249
- const teaseNext = steps.edit && liveNow && current !== "next";
250
- return {
251
- open: { run: s1, edit: current === "edit", next: current === "next" },
252
- seg: { run: steps.run, edit: steps.edit },
253
- flow: liveNow,
254
- stRun: s1 ? "open" : "done",
255
- stEdit: steps.edit ? "done" : (current === "edit") ? "open" : teaseEdit ? "next" : "locked",
256
- stNext: (current === "next") ? "open" : teaseNext ? "next" : "locked",
257
- teaseEdit: teaseEdit,
258
- teaseNext: teaseNext,
259
- doneRun: !s1 && steps.run,
260
- doneEdit: steps.edit && current !== "edit",
261
- lockEdit: !steps.run,
262
- lockNext: !steps.edit,
263
- quietNote: s1 && steps.run && !liveNow && sawLive,
264
- showActivity: !s1 && steps.run,
265
- };
266
- }
267
-
268
- // --- apply (targets the rail DOM; the rules live in computeView above) -----
269
- function applyView(v: ReturnType<typeof computeView>) {
270
- if (stEls.run) stEls.run.setAttribute("data-st", v.stRun);
271
- if (stEls.edit) stEls.edit.setAttribute("data-st", v.stEdit);
272
- if (stEls.next) stEls.next.setAttribute("data-st", v.stNext);
273
- if (segRun) { segRun.setAttribute("data-lit", v.seg.run ? "1" : "0"); segRun.setAttribute("data-flow", v.flow ? "1" : "0"); }
274
- if (segEdit) { segEdit.setAttribute("data-lit", v.seg.edit ? "1" : "0"); segEdit.setAttribute("data-flow", v.flow ? "1" : "0"); }
275
- if (bodies.run) bodies.run.hidden = !v.open.run;
276
- if (bodies.edit) bodies.edit.hidden = !v.open.edit;
277
- if (bodies.next) bodies.next.hidden = !v.open.next;
278
- if (doneRunEl) doneRunEl.hidden = !v.doneRun;
279
- if (doneEditEl) doneEditEl.hidden = !v.doneEdit;
280
- if (lockEditEl) lockEditEl.hidden = !v.lockEdit;
281
- if (lockNextEl) lockNextEl.hidden = !v.lockNext;
282
- if (teaseEditEl) teaseEditEl.hidden = !v.teaseEdit;
283
- if (teaseNextEl) teaseNextEl.hidden = !v.teaseNext;
284
- if (quietNoteEl) quietNoteEl.hidden = !v.quietNote;
285
- if (root) (root as any).hidden = !v.showActivity;
286
- }
287
- // Single render entry point — derive, then apply. (Named renderSteps so the
288
- // existing call sites keep working; distinct from the activity render(events).)
289
- function renderSteps() { applyView(computeView()); }
290
-
291
- function expandStage(el: any) {
292
- if (!el) return;
293
- el.hidden = false;
294
- el.classList.add("expanding");
295
- setTimeout(() => { if (el && el.classList) el.classList.remove("expanding"); }, 420);
296
- }
297
-
298
- // Open a step (from a teaser CTA or a collapsed done row) — animates it in.
299
- function goTo(step: string) {
300
- if (!unlocked(step)) return;
301
- current = step;
302
- renderSteps();
303
- expandStage(bodies[step]);
304
- window.scrollTo({ top: 0, behavior: "smooth" });
305
- }
306
-
307
- // Rail click wiring: done rows reopen their step; teaser CTAs open the teased step.
308
- if (doneRunEl) doneRunEl.addEventListener("click", () => { goTo("run"); });
309
- if (doneEditEl) doneEditEl.addEventListener("click", () => { goTo("edit"); });
310
- const ctaEdit = document.getElementById("cta-edit");
311
- if (ctaEdit) ctaEdit.addEventListener("click", () => { goTo("edit"); });
312
- const ctaNext = document.getElementById("cta-next");
313
- if (ctaNext) ctaNext.addEventListener("click", () => { goTo("next"); });
314
-
315
- // Absolute clock time with seconds (e.g. "2:57:14 PM") — a fixed point, not a
316
- // churning duration. Full date+time stays on the hover title (render()).
317
- function rel(ts: number | string): string {
318
- try {
319
- return new Date(Number(ts)).toLocaleTimeString([], { hour: "numeric", minute: "2-digit", second: "2-digit" });
320
- } catch (x) {
321
- return "";
322
- }
323
- }
324
-
325
- // Toast — reuses the shared #toast element (also driven by the copy script).
326
- const toastEl = document.getElementById("toast");
327
- const toastMsgEl = document.getElementById("toastMsg");
328
- let toastT: ReturnType<typeof setTimeout>;
329
- function toast(msg: string) {
330
- if (!toastEl || !toastMsgEl) return;
331
- toastMsgEl.textContent = msg;
332
- toastEl.classList.add("show");
333
- clearTimeout(toastT);
334
- toastT = setTimeout(() => { toastEl.classList.remove("show"); }, 2600);
335
- }
336
-
337
- // Celebration — replaces the full-screen confetti. Stamps the Step-2 node (spark
338
- // burst + stamp, via the .celebrating class) and shows a toast. Reduced-motion
339
- // disables the burst/stamp in CSS; the toast still shows.
340
- function celebrate(file?: string) {
341
- const st = stEls.edit;
342
- if (st) {
343
- st.classList.remove("celebrating");
344
- void st.offsetWidth; // restart the burst animation
345
- st.classList.add("celebrating");
346
- setTimeout(() => { if (st && st.classList) st.classList.remove("celebrating"); }, 1100);
347
- }
348
- if (doneEditMeta && file) doneEditMeta.textContent = file;
349
- toast("Saved " + (file || "your file") + " — your store reloaded. That's the loop.");
350
- }
351
-
352
- const toggleEl: any = document.getElementById("haToggle");
353
- const VISIBLE = 3; // show the latest 3 by default; expand for the rest
354
- if (toggleEl) {
355
- toggleEl.addEventListener("click", () => { expanded = !expanded; render(lastEvents); });
356
- }
357
- let lastEvents: any[] = [];
358
-
359
- function render(events: any[]) {
360
- lastEvents = events;
361
- // Item 3 — drop the "up"/"running locally" pings; the live widget at the top
362
- // already conveys that. Only real FILE activity belongs in the table, and each
363
- // field is its own <td> so time / action / file never run together.
364
- const real = (events || []).filter((e) => e && e.event !== "up");
365
- Array.prototype.forEach.call(bodyEl.querySelectorAll(".ha-row"), (n: any) => { n.remove(); });
366
- if (!real.length) {
367
- emptyEl.hidden = false;
368
- if (tableEl) tableEl.hidden = true;
369
- if (toggleEl) toggleEl.hidden = true;
370
- return;
371
- }
372
- emptyEl.hidden = true;
373
- if (tableEl) tableEl.hidden = false;
374
- const newestFirst = real.slice().reverse();
375
- const shown = expanded ? newestFirst : newestFirst.slice(0, VISIBLE);
376
- shown.forEach((e, i) => {
377
- const tr = document.createElement("tr");
378
- tr.className = i === 0 ? "ha-row is-new" : "ha-row"; // accent the newest row
379
- const when = document.createElement("td");
380
- when.className = "ha-when";
381
- when.textContent = rel(e.at);
382
- try { when.title = new Date(e.at).toLocaleString(); } catch (x) {} // exact time on hover
383
- const desc = document.createElement("td");
384
- desc.className = "ha-desc";
385
- desc.textContent = e.description;
386
- const file = document.createElement("td");
387
- file.className = "ha-file";
388
- file.textContent = e.file || ""; // the concrete file name, e.g. content/home.html
389
- tr.appendChild(when); tr.appendChild(desc); tr.appendChild(file);
390
- bodyEl.appendChild(tr);
391
- });
392
- if (toggleEl) {
393
- if (real.length > VISIBLE) {
394
- toggleEl.hidden = false;
395
- toggleEl.textContent = expanded ? "Show fewer" : "Show all " + real.length;
396
- } else {
397
- toggleEl.hidden = true;
398
- }
399
- }
400
- }
401
-
402
- // Adaptive poll cadence + visibility pause (2026-07-15 KV-quota incident: a
403
- // single backgrounded tab, polling flat-out every 3s with no pause, burned
404
- // through the ENTIRE account-wide daily KV read quota by itself and took
405
- // down real customer traffic with 500s). Two rules:
406
- // 1. HIDDEN tab → don't poll at all. A backgrounded/minimized tab can't be
407
- // "watching" the loop; resume (with an immediate catch-up poll) the
408
- // instant it becomes visible again.
409
- // 2. VISIBLE but the loop is already fully celebrated (steps.run AND
410
- // steps.edit) → the high-stakes "is it working yet" moment has passed,
411
- // so back off to a slow cadence. Still visible AND still mid-loop →
412
- // keep the fast cadence (this is the one case where sub-second-feeling
413
- // responsiveness genuinely matters — a real developer staring at the
414
- // screen waiting to see their save land).
415
- const FAST_MS = 3000; // actively watching for the loop to prove itself
416
- const SLOW_MS = 20000; // loop already celebrated — just an occasional glance
417
- let pollTimer: ReturnType<typeof setTimeout> | null = null;
418
-
419
- function nextDelay() {
420
- return (steps.run && steps.edit) ? SLOW_MS : FAST_MS;
421
- }
422
-
423
- function scheduleNext() {
424
- if (pollTimer) { clearTimeout(pollTimer); pollTimer = null; }
425
- if (document.hidden) return; // stay fully paused; visibilitychange resumes us
426
- pollTimer = setTimeout(poll, nextDelay());
427
- }
428
-
429
- function poll() {
430
- fetch(basePath + "/api/dev/activity", { cache: "no-store" })
431
- .then((r) => (r.ok ? r.json() : Promise.reject()))
432
- .then((d) => {
433
- const events = (d && d.events) || [];
434
- const rt = d && d.runtime;
435
- const isLive = !!(rt && rt.live);
436
- liveNow = isLive; // drives Step 1 minimize + the Step-2 teaser visibility below
437
- updateBridge(rt, d && d.obstacle); // same poll drives the bridge strip (+ obstacle lane)
438
- render(events);
439
- // b1 fix — Step-2 completion must key off the SAME events the feed shows:
440
- // REAL file edits (event !== "up"), NOT the single newest buffer entry. The
441
- // local loop interleaves recurring "up" liveness pings into this one ring
442
- // buffer, so the newest event is frequently an "up" ping even right after a
443
- // save. The old gate read events[last]: when an "up" ping landed AFTER the
444
- // edit it (1) made lastIsEdit false so completeStep("edit") never fired, and
445
- // (2) still advanced the baseline watermark past the edit's timestamp —
446
- // permanently stranding Step 2 even though the save rendered in "Your
447
- // activity". Filter to real edits (mirroring render()'s filter) and advance
448
- // the watermark only from real edits, so a liveness ping can neither satisfy
449
- // nor poison the gate.
450
- const realEdits = events.filter((e: any) => e && e.event !== "up");
451
- const lastEdit = realEdits.length ? realEdits[realEdits.length - 1] : null;
452
- const latestEdit = lastEdit ? lastEdit.at : 0;
453
- // Step 1 "Get running" completes once localhost reports LIVE (or any activity
454
- // arrives). Once complete, renderSteps() minimizes Step 1 and reveals the Step-2 nudge.
455
- if (isLive || events.length) completeStep("run");
456
- if (baseline === null) {
457
- setBaseline(latestEdit); // first poll primes the watermark from real edits — no edit inferred yet
458
- } else if (latestEdit > baseline) {
459
- setBaseline(latestEdit);
460
- // A real FILE edit landed after the watermark → Step 2 completes (once).
461
- // completeStep flips + persists once, returning true on that first poll only.
462
- if (completeStep("edit")) {
463
- celebrate(lastEdit && lastEdit.file);
464
- if (current === "edit") current = null; // minimize Step 2 → reveal Step-3 teaser
465
- }
466
- }
467
- // ALWAYS re-render so a localhost drop hides the Step-2 nudge + reopens Step 1.
468
- renderSteps();
469
- })
470
- .catch(() => {})
471
- .then(scheduleNext); // reschedule (or not, if now hidden) regardless of outcome
472
- }
473
-
474
- document.addEventListener("visibilitychange", () => {
475
- if (document.hidden) {
476
- if (pollTimer) { clearTimeout(pollTimer); pollTimer = null; }
477
- } else {
478
- poll(); // catch up immediately; poll() reschedules itself at the end
479
- }
480
- });
481
-
482
- // Item 7/10 — Step 3 "Submit for preview" opens the "coming soon" dialog (the
483
- // compliance-reviewed preview pipeline isn't wired into this panel yet).
484
- const submitBtn = document.getElementById("submitPreview");
485
- const comingSoon: any = document.getElementById("comingSoon");
486
- if (submitBtn && comingSoon) {
487
- submitBtn.addEventListener("click", () => {
488
- if (typeof comingSoon.showModal === "function") comingSoon.showModal();
489
- else comingSoon.setAttribute("open", "");
490
- });
491
- const csClose = document.getElementById("comingSoonClose");
492
- if (csClose) csClose.addEventListener("click", () => {
493
- if (typeof comingSoon.close === "function") comingSoon.close();
494
- comingSoon.removeAttribute("open");
495
- });
496
- }
497
-
498
- renderSteps();
499
- if (!document.hidden) poll(); // if the tab starts hidden, visibilitychange kicks it off later
500
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Info popover: toggle on the ⓘ button, dismiss on outside click. Imported
3
- * from a processed `<script>` in cockpit.astro.
4
- */
5
- export function initInfoPopover(): void {
6
- const info1 = document.getElementById("info1");
7
- if (!info1) return;
8
- const openBtn = info1.querySelector(".info-btn");
9
- if (!openBtn) return;
10
- openBtn.addEventListener("click", (e) => { e.stopPropagation(); info1.classList.toggle("open"); });
11
- document.addEventListener("click", (e) => { if (!info1.contains(e.target as Node)) info1.classList.remove("open"); });
12
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Copy the "connect the MCP" command (d3-unhold-dev-step0-connect-mcp). Static
3
- * text (no minting), so unlike the setup-command copy button (copyCommand.ts)
4
- * this button is visible from load. Imported from a processed `<script>` in
5
- * cockpit.astro.
6
- */
7
- export function initMcpCopy(): void {
8
- const copyIcon = document.getElementById("mcpCopyIcon");
9
- const cmdText = document.getElementById("mcpCmdText");
10
- const toast = document.getElementById("toast");
11
- const toastMsg = document.getElementById("toastMsg");
12
- if (!copyIcon || !cmdText) return;
13
- let tT: ReturnType<typeof setTimeout>;
14
- function ping(m: string) {
15
- if (!toast || !toastMsg) return;
16
- toastMsg.textContent = m; toast.classList.add("show");
17
- clearTimeout(tT); tT = setTimeout(() => { toast.classList.remove("show"); }, 1900);
18
- }
19
- copyIcon.addEventListener("click", () => {
20
- const text = cmdText.textContent || "";
21
- const done = navigator.clipboard
22
- ? navigator.clipboard.writeText(text).then(() => true).catch(() => false)
23
- : Promise.resolve(false);
24
- done.then((ok) => {
25
- if (ok) {
26
- copyIcon.setAttribute("data-copied", "1");
27
- setTimeout(() => { copyIcon.removeAttribute("data-copied"); }, 1600);
28
- ping("Copied");
29
- } else {
30
- ping("Select the command above to copy");
31
- }
32
- });
33
- });
34
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * Live loop Monitor — polls the local dev server's /__tot/dev-loop-status
3
- * and renders the loopbar: server health, watched file, and the save→reload
4
- * timeline. Imported from a processed `<script>` in cockpit.astro (ADR 0013),
5
- * rendered only when isLocalDevLoop (the storefront's own `astro dev`, never
6
- * the hosted panel). Broadcasts window.__totLoop + the "tot:loop-state"
7
- * CustomEvent so the stepper and ask widgets share this one poll instead of
8
- * each opening their own. All dynamic values go through textContent, never
9
- * innerHTML.
10
- */
11
- declare global {
12
- interface Window {
13
- __totLoop?: Record<string, unknown>;
14
- }
15
- }
16
-
17
- export function initMonitor(): void {
18
- const bar: any = document.getElementById("loopbar");
19
- if (!bar) return;
20
- const elStatus: any = document.getElementById("lbStatus");
21
- const elWatch: any = document.getElementById("lbWatch");
22
- const elLast: any = document.getElementById("lbLast");
23
- const elServer: any = document.getElementById("lbServer");
24
- const elUrl: any = document.getElementById("lbUrl");
25
- const elFile: any = document.getElementById("lbFile");
26
- const elSave: any = document.getElementById("lbSave");
27
- const elReload: any = document.getElementById("lbReload");
28
- const head = document.getElementById("lbHead");
29
-
30
- if (head) head.addEventListener("click", () => { bar.classList.toggle("open"); });
31
-
32
- function rel(ts: number | string): string {
33
- const d = Math.max(0, Math.round((Date.now() - Number(ts)) / 1000));
34
- return d < 2 ? "just now" : d < 60 ? d + "s ago" : Math.floor(d / 60) + "m ago";
35
- }
36
- function setTs(el: any, ts: number | undefined, emptyText: string) {
37
- if (ts) {
38
- el.setAttribute("data-ts", String(ts));
39
- el.classList.remove("dim");
40
- el.textContent = rel(ts);
41
- } else {
42
- el.removeAttribute("data-ts");
43
- el.classList.add("dim");
44
- el.textContent = emptyText;
45
- }
46
- }
47
- setInterval(() => {
48
- [elSave, elReload].forEach((el) => {
49
- const ts = el.getAttribute("data-ts");
50
- if (ts) el.textContent = rel(ts);
51
- });
52
- }, 1000);
53
-
54
- function render(s: any) {
55
- bar.classList.add("live");
56
- const port = s.port || null;
57
- const url = port ? ("localhost:" + port + (s.tenant ? "/" + s.tenant + "/" : "/")) : "—";
58
- elServer.textContent = s.server ? ("running" + (port ? " · port " + port : "")) : "not running";
59
- elServer.classList.toggle("dim", !s.server);
60
- elUrl.textContent = url;
61
- elUrl.classList.toggle("dim", !port);
62
- elFile.textContent = s.watchedFile || "content/*.html";
63
- elFile.classList.toggle("dim", !s.watchedFile);
64
- elWatch.textContent = s.watchedFile || "your content";
65
- setTs(elSave, s.lastSaveAt, "no saves yet");
66
- setTs(elReload, s.lastReloadAt, "waiting for a save");
67
-
68
- const saved = s.lastSaveAt || 0;
69
- const reloaded = s.lastReloadAt || 0;
70
- let state, status, last;
71
- if (!saved) {
72
- state = "running"; status = "Running"; last = "reloads on save";
73
- } else if (reloaded >= saved) {
74
- state = "running"; status = "Running"; last = "reloaded";
75
- } else if (Date.now() - saved < 3000) {
76
- state = "reloading"; status = "Reloading…"; last = "change detected";
77
- } else {
78
- state = "stale"; status = "Stale"; last = "save not reflected — restart?";
79
- }
80
- bar.setAttribute("data-state", state);
81
- elStatus.textContent = status;
82
- elLast.textContent = last;
83
- // Broadcast the snapshot so other consumers (stepper, Ask) share this
84
- // one poll instead of each opening their own. window.__totLoop holds the
85
- // latest for listeners that attach late.
86
- window.__totLoop = s;
87
- window.dispatchEvent(new CustomEvent("tot:loop-state", { detail: s }));
88
- }
89
- function offline() {
90
- bar.classList.add("live");
91
- bar.setAttribute("data-state", "stale");
92
- elStatus.textContent = "Offline";
93
- elLast.textContent = "dev server not reachable";
94
- elServer.textContent = "not reachable";
95
- const off = { server: false, offline: true };
96
- window.__totLoop = off;
97
- window.dispatchEvent(new CustomEvent("tot:loop-state", { detail: off }));
98
- }
99
- function poll() {
100
- fetch("/__tot/dev-loop-status", { cache: "no-store" })
101
- .then((r) => (r.ok ? r.json() : Promise.reject()))
102
- .then(render)
103
- .catch(offline);
104
- }
105
- poll();
106
- setInterval(poll, 1000);
107
- }