@tokenoftrust/storefront-runner 7.3.1 → 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.
- package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
- package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
- package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
- package/apps/storefront/astro.config.mjs +8 -2
- package/apps/storefront/package.json +1 -2
- package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
- package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
- package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
- package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
- package/apps/storefront/src/layouts/Layout.astro +17 -0
- package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
- package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +147 -0
- package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +67 -1
- package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
- package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
- package/apps/storefront/src/lib/access/auth/session.ts +79 -0
- package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
- package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
- package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
- package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
- package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
- package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
- package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
- package/apps/storefront/src/lib/activity/store.ts +9 -3
- package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
- package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
- package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
- package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
- package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
- package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
- package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +447 -0
- package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
- package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
- package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
- package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
- package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
- package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
- package/apps/storefront/src/middleware/controlPlane.ts +15 -1
- package/apps/storefront/src/middleware/index.ts +40 -1
- package/apps/storefront/src/middleware/renderChain.ts +46 -33
- package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
- package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
- package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
- package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
- package/apps/storefront/src/pages/products/[handle].astro +2 -15
- package/apps/storefront/tsconfig.astro.json +11 -0
- package/package.json +1 -1
- package/packages/public-runtime/src/activity/README.md +12 -0
- package/packages/public-runtime/src/activity/catalog.ts +7 -0
- package/packages/public-runtime/src/activity/event.ts +19 -0
- package/packages/public-runtime/src/activity/redaction.ts +31 -2
- package/packages/public-runtime/src/catalog-files.ts +3 -2
- package/packages/public-runtime/src/checkout-orders.ts +18 -19
- package/packages/public-runtime/src/checkout.ts +70 -0
- package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
- package/packages/public-runtime/src/compliance/index.ts +1 -1
- package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
- package/packages/public-runtime/src/compliance/profile.ts +268 -20
- package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
- package/packages/public-runtime/src/customization-runtime.ts +1 -1
- package/packages/public-runtime/src/product.ts +9 -1
- package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
- package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
- package/pnpm-lock.runner.yaml +0 -15
- package/scripts/tenant/materialize-tenant-content.mjs +3 -0
- package/scripts/tenant/validate.mjs +128 -0
- package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
- package/apps/storefront/drizzle.config.apps.ts +0 -13
- package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
- package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
- package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
- package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
- package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
- package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
- package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
- package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
- package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
- package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
- package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
- package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
- package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
- package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
- package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
- package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
- package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
- package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
- package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
- package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
- package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
- package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
- package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
- package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
- package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
- package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
- package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
- package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
- package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
- package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
- package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
- package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
- package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
- package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
- package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
- package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
- package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
- package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
- package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
- package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
- package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
- package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
- package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
- package/apps/storefront/perf/README.md +0 -64
- package/apps/storefront/perf/assert-budgets.ts +0 -159
- package/apps/storefront/platform-reconcile-tenants.json +0 -3
- package/apps/storefront/playwright.config.ts +0 -23
- package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
- package/apps/storefront/public/js/dashboard-apps.js +0 -183
- package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
- package/apps/storefront/public/js/dashboard-delegate.js +0 -167
- package/apps/storefront/public/js/dashboard-team.js +0 -356
- package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
- package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
- package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
- package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
- package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
- package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
- package/apps/storefront/src/config/storeName.ts +0 -34
- package/apps/storefront/src/lib/access/admin/README.md +0 -122
- package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
- package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
- package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
- package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
- package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
- package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
- package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
- package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
- package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -150
- package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -452
- package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
- package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
- package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
- package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
- package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
- package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
- package/apps/storefront/src/lib/activity/alerts.ts +0 -426
- package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
- package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
- package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
- package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
- package/apps/storefront/src/lib/activity/query.ts +0 -403
- package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
- package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
- package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
- package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
- package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
- package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
- package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
- package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
- package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
- package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
- package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
- package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
- package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
- package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
- package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
- package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
- package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
- package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
- package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
- package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
- package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
- package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
- package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
- package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
- package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
- package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
- package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
- package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
- package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
- package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
- package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
- package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
- package/apps/storefront/src/lib/content/index.ts +0 -27
- package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
- package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
- package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
- package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
- package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
- package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
- package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
- package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
- package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
- package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
- package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
- package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
- package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
- package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
- package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
- package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
- package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
- package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
- package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
- package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
- package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
- package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
- package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
- package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
- package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
- package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
- package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
- package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
- package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
- package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
- package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
- package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
- package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
- package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
- package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
- package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
- package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
- package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
- package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
- package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
- package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
- package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
- package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
- package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
- package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
- package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
- package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
- package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
- package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
- package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
- package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
- package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
- package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
- package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
- package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
- package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
- package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
- package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
- package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
- package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
- package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
- package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
- package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
- package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
- package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
- package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
- package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
- package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
- package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
- package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
- package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
- package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
- package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
- package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
- package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
- package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
- package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
- package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
- package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
- package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
- package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
- package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
- package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
- package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
- package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
- package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
- package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
- package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
- package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
- package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
- package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
- package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
- package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
- package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
- package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
- package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
- package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
- package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
- package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
- package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
- package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
- package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
- package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
- package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
- package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
- package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
- package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
- package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
- package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
- package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
- package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
- package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
- package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
- package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
- package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
- package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
- package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
- package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
- package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
- package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
- package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
- package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
- package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
- package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
- package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
- package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
- package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
- package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
- package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
- package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
- package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
- package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
- package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
- package/apps/storefront/src/pages/api/contact.ts +0 -144
- package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
- package/apps/storefront/src/styles/admin.css +0 -1161
- package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
- package/apps/storefront/test/pipeline/harness.ts +0 -209
- package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
- package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
- package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
- package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
- package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
- package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
- package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
- package/apps/storefront/vitest.config.cts +0 -44
- package/apps/storefront/vitest.faults.config.cts +0 -13
- package/apps/storefront/vitest.workers.config.cts +0 -7
- package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
- package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
- package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
- package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
- package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
- package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
- package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
- package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
- package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
- package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
- package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
- package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
- package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
- package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
- package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
- package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
- package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
- package/packages/feedback/package.json +0 -35
- package/packages/feedback/scripts/build-player.mjs +0 -28
- package/packages/feedback/src/index.ts +0 -1
- package/packages/feedback/src/primitives/composer.ts +0 -639
- package/packages/feedback/src/primitives/dialog.ts +0 -263
- package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
- package/packages/feedback/src/primitives/index.ts +0 -10
- package/packages/feedback/src/primitives/launcher.ts +0 -200
- package/packages/feedback/src/primitives/picker.ts +0 -663
- package/packages/feedback/src/primitives/redaction.ts +0 -204
- package/packages/feedback/src/primitives/selection.ts +0 -49
- package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
- package/packages/feedback/src/primitives/styles.ts +0 -77
- package/packages/feedback/src/primitives/surface.ts +0 -124
- package/packages/feedback/src/primitives/target.ts +0 -293
- package/packages/feedback/src/tour/canonical.ts +0 -27
- package/packages/feedback/src/tour/index.ts +0 -3
- package/packages/feedback/src/tour/player/browser.ts +0 -5
- package/packages/feedback/src/tour/player/host.ts +0 -12
- package/packages/feedback/src/tour/player/index.ts +0 -205
- package/packages/feedback/src/tour/player/manifest.ts +0 -76
- package/packages/feedback/src/tour/player/player.css +0 -130
- package/packages/feedback/src/tour/player/resolver.ts +0 -12
- package/packages/feedback/src/tour/player/surface.ts +0 -295
- package/packages/feedback/src/tour/player/types.ts +0 -8
- package/packages/feedback/src/tour/resolve/core.ts +0 -267
- package/packages/feedback/src/tour/resolve/dom.ts +0 -115
- package/packages/feedback/src/tour/resolve/index.ts +0 -29
- package/packages/feedback/src/tour/sanitize.ts +0 -76
- package/packages/feedback/src/tour/schema.ts +0 -362
- package/packages/feedback/src/v1/guards.ts +0 -335
- package/packages/feedback/src/v1/index.ts +0 -3
- package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
- package/packages/feedback/src/v1/types.ts +0 -177
- package/packages/feedback/tsconfig.json +0 -9
- package/packages/feedback/vitest.config.cts +0 -21
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
// The floating "✦ ask" affordance for `tot dev`'s inline-AI edit loop (WS5 G1).
|
|
2
|
-
// Injected into every page ONLY in `astro dev` by inlineAiEditPlugin in
|
|
3
|
-
// astro.config.mjs (never bundled into the production build — this file isn't
|
|
4
|
-
// imported by any Astro page/component, only served verbatim by that dev-only
|
|
5
|
-
// Vite middleware). Talks to /__tot/ai-edit and /__tot/ai-undo, which
|
|
6
|
-
// scripts/dev/ai-edit.mjs implements against the tenant this `tot dev` run is
|
|
7
|
-
// serving (TOT_DEV_TENANT).
|
|
8
|
-
//
|
|
9
|
-
// Plain vanilla JS, no build step, no framework — this never ships to users.
|
|
10
|
-
|
|
11
|
-
(function () {
|
|
12
|
-
const ROOT_ID = "__tot-ai-widget";
|
|
13
|
-
if (document.getElementById(ROOT_ID)) return; // one instance per page
|
|
14
|
-
|
|
15
|
-
const root = document.createElement("div");
|
|
16
|
-
root.id = ROOT_ID;
|
|
17
|
-
root.innerHTML = `
|
|
18
|
-
<style>
|
|
19
|
-
#${ROOT_ID} { position: fixed; right: 1rem; bottom: 1rem; z-index: 2147483647;
|
|
20
|
-
font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
21
|
-
#${ROOT_ID} .toggle { width: 3rem; height: 3rem; border-radius: 999px; border: none;
|
|
22
|
-
background: #16181d; color: #e8e6e0; font-size: 1.25rem; cursor: pointer;
|
|
23
|
-
box-shadow: 0 8px 24px -8px rgba(0,0,0,.45); }
|
|
24
|
-
#${ROOT_ID} .toggle:hover { background: #23262d; }
|
|
25
|
-
#${ROOT_ID} .panel { display: none; position: absolute; right: 0; bottom: 3.75rem;
|
|
26
|
-
width: 22rem; max-width: 90vw; background: #fff; color: #16191d; border-radius: 12px;
|
|
27
|
-
box-shadow: 0 16px 40px -12px rgba(0,0,0,.35); border: 1px solid #e4e0d6; padding: .9rem; }
|
|
28
|
-
#${ROOT_ID}.open .panel { display: block; }
|
|
29
|
-
#${ROOT_ID} textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 3.5rem;
|
|
30
|
-
border: 1px solid #d8d4c8; border-radius: 8px; padding: .5rem .6rem; font: inherit; }
|
|
31
|
-
#${ROOT_ID} .row { display: flex; gap: .4rem; margin-top: .5rem; }
|
|
32
|
-
#${ROOT_ID} button.primary { flex: 1; background: #0f7b6c; color: #fff; border: none;
|
|
33
|
-
border-radius: 8px; padding: .5rem .7rem; font: 600 .85rem/1 inherit; cursor: pointer; }
|
|
34
|
-
#${ROOT_ID} button.primary:disabled { opacity: .5; cursor: default; }
|
|
35
|
-
#${ROOT_ID} button.secondary { background: #ece9e0; color: #2a2d31; border: none;
|
|
36
|
-
border-radius: 8px; padding: .5rem .7rem; font: 600 .8rem/1 inherit; cursor: pointer; }
|
|
37
|
-
#${ROOT_ID} .status { margin-top: .6rem; font-size: .82rem; white-space: pre-wrap; }
|
|
38
|
-
#${ROOT_ID} .status.error { color: #a83a3a; }
|
|
39
|
-
#${ROOT_ID} .status.ok { color: #0f7b6c; }
|
|
40
|
-
#${ROOT_ID} details { margin-top: .5rem; }
|
|
41
|
-
#${ROOT_ID} pre { max-height: 12rem; overflow: auto; background: #16181d; color: #dbe3ea;
|
|
42
|
-
border-radius: 8px; padding: .5rem .6rem; font-size: .75rem; }
|
|
43
|
-
/* Locate mode (C7): highlight box, hint, and result toast — top-level ids so
|
|
44
|
-
they overlay the whole page, outside the widget's own stacking. */
|
|
45
|
-
#${ROOT_ID}-locate-hi { position: fixed; z-index: 2147483646; pointer-events: none;
|
|
46
|
-
border: 2px solid #0f7b6c; background: rgba(15,123,108,.12); border-radius: 3px; display: none; }
|
|
47
|
-
#${ROOT_ID}-locate-hint { position: fixed; left: 50%; top: 1rem; transform: translateX(-50%);
|
|
48
|
-
z-index: 2147483647; background: #16181d; color: #e8e6e0; font: 600 .8rem/1 -apple-system, sans-serif;
|
|
49
|
-
padding: .55rem .9rem; border-radius: 999px; box-shadow: 0 8px 24px -8px rgba(0,0,0,.45); display: none; }
|
|
50
|
-
#${ROOT_ID}-locate-toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%) translateY(160%);
|
|
51
|
-
z-index: 2147483647; background: #16181d; color: #e8e6e0; display: flex; align-items: center;
|
|
52
|
-
font: 500 .8rem/1.3 ui-monospace, Menlo, monospace; padding: .6rem 1rem; border-radius: 8px;
|
|
53
|
-
box-shadow: 0 8px 24px -8px rgba(0,0,0,.45); transition: transform .25s; max-width: 90vw; }
|
|
54
|
-
#${ROOT_ID}-locate-toast.show { transform: translateX(-50%) translateY(0); }
|
|
55
|
-
</style>
|
|
56
|
-
<button class="toggle" type="button" aria-label="Ask AI to edit this site" title="Ask AI to edit this site">✦</button>
|
|
57
|
-
<div class="panel">
|
|
58
|
-
<textarea placeholder="e.g. make it darker but still friendly" aria-label="Describe the change"></textarea>
|
|
59
|
-
<div class="row">
|
|
60
|
-
<button class="primary" type="button" data-action="ask">Ask</button>
|
|
61
|
-
<button class="secondary" type="button" data-action="undo">Undo last</button>
|
|
62
|
-
<button class="secondary" type="button" data-action="locate" title="Click an element on the page to jump to its source">◎ Locate</button>
|
|
63
|
-
</div>
|
|
64
|
-
<div class="status" role="status" aria-live="polite"></div>
|
|
65
|
-
</div>
|
|
66
|
-
`;
|
|
67
|
-
document.body.appendChild(root);
|
|
68
|
-
|
|
69
|
-
const toggle = root.querySelector(".toggle");
|
|
70
|
-
const textarea = root.querySelector("textarea");
|
|
71
|
-
const askBtn = root.querySelector('[data-action="ask"]');
|
|
72
|
-
const undoBtn = root.querySelector('[data-action="undo"]');
|
|
73
|
-
const status = root.querySelector(".status");
|
|
74
|
-
|
|
75
|
-
toggle.addEventListener("click", () => root.classList.toggle("open"));
|
|
76
|
-
|
|
77
|
-
function setStatus(text, kind) {
|
|
78
|
-
status.textContent = text;
|
|
79
|
-
status.className = "status" + (kind ? " " + kind : "");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function renderResult(result) {
|
|
83
|
-
if (!result.ok) {
|
|
84
|
-
setStatus(result.message || `Refused (${result.status}).`, "error");
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (result.status === "noop") {
|
|
88
|
-
setStatus(result.summary || "No change was needed.", "ok");
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
setStatus(`✔ ${result.summary} — reloading…`, "ok");
|
|
92
|
-
// The file write already fires the existing content/theme HMR watch (see
|
|
93
|
-
// astro.config.mjs's tenantHotReload); nothing else to do here.
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function postJson(path, body) {
|
|
97
|
-
const res = await fetch(path, {
|
|
98
|
-
method: "POST",
|
|
99
|
-
headers: { "content-type": "application/json" },
|
|
100
|
-
body: JSON.stringify(body || {}),
|
|
101
|
-
});
|
|
102
|
-
return res.json();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
askBtn.addEventListener("click", async () => {
|
|
106
|
-
const prompt = textarea.value.trim();
|
|
107
|
-
if (!prompt) return;
|
|
108
|
-
askBtn.disabled = true;
|
|
109
|
-
setStatus("Asking…");
|
|
110
|
-
try {
|
|
111
|
-
const result = await postJson("/__tot/ai-edit", { prompt });
|
|
112
|
-
renderResult(result);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
setStatus(`Request failed: ${e.message}`, "error");
|
|
115
|
-
} finally {
|
|
116
|
-
askBtn.disabled = false;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
undoBtn.addEventListener("click", async () => {
|
|
121
|
-
undoBtn.disabled = true;
|
|
122
|
-
setStatus("Undoing…");
|
|
123
|
-
try {
|
|
124
|
-
const result = await postJson("/__tot/ai-undo", {});
|
|
125
|
-
if (!result.ok) {
|
|
126
|
-
setStatus(result.message || "Nothing to undo.", "error");
|
|
127
|
-
} else {
|
|
128
|
-
setStatus(`↺ Reverted "${result.undid}" — reloading…`, "ok");
|
|
129
|
-
}
|
|
130
|
-
} catch (e) {
|
|
131
|
-
setStatus(`Request failed: ${e.message}`, "error");
|
|
132
|
-
} finally {
|
|
133
|
-
undoBtn.disabled = false;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
textarea.addEventListener("keydown", (e) => {
|
|
138
|
-
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) askBtn.click();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// ── Locate mode (C7): click an element → its source file:line:col ──────────
|
|
142
|
-
// Enter locate mode, hover to highlight, click an element: we capture a DOM path
|
|
143
|
-
// and POST it to /__tot/locate, which (server-side, scripts/dev/dev-locate.mjs)
|
|
144
|
-
// parses the raw-HTML tenant source with parse5 and walks the SAME path to a
|
|
145
|
-
// line:col. captureDomPath MUST stay in lockstep with scripts/dev/locate.mjs's
|
|
146
|
-
// walk (see its header + locate.test.mjs's round-trip): a DOM path is an array of
|
|
147
|
-
// { tag, index } from <body>'s child down to the target, index = 0-based position
|
|
148
|
-
// among same-tag element siblings (nth-of-type). Raw-HTML tenants only; the server
|
|
149
|
-
// refuses templated pages with { status: "not_raw_html" }.
|
|
150
|
-
function captureDomPath(el) {
|
|
151
|
-
const path = [];
|
|
152
|
-
let node = el;
|
|
153
|
-
while (node && node.tagName && node.tagName.toLowerCase() !== "body") {
|
|
154
|
-
const parent = node.parentElement;
|
|
155
|
-
if (!parent) break;
|
|
156
|
-
const tag = node.tagName.toLowerCase();
|
|
157
|
-
let index = 0;
|
|
158
|
-
for (let sib = node.previousElementSibling; sib; sib = sib.previousElementSibling) {
|
|
159
|
-
if (sib.tagName.toLowerCase() === tag) index += 1;
|
|
160
|
-
}
|
|
161
|
-
path.unshift({ tag, index });
|
|
162
|
-
if (parent.tagName && parent.tagName.toLowerCase() === "body") break;
|
|
163
|
-
node = parent;
|
|
164
|
-
}
|
|
165
|
-
return path;
|
|
166
|
-
}
|
|
167
|
-
// Exposed for the in-browser verification harness (dev-only, harmless in prod
|
|
168
|
-
// since this whole file is never bundled into the production build).
|
|
169
|
-
window.__totCaptureDomPath = captureDomPath;
|
|
170
|
-
|
|
171
|
-
const locateBtn = root.querySelector('[data-action="locate"]');
|
|
172
|
-
let hi, hint, ltoast, locating = false, lastHover = null;
|
|
173
|
-
|
|
174
|
-
function ensureLocateEls() {
|
|
175
|
-
if (hi) return;
|
|
176
|
-
hi = document.createElement("div");
|
|
177
|
-
hi.id = ROOT_ID + "-locate-hi";
|
|
178
|
-
hint = document.createElement("div");
|
|
179
|
-
hint.id = ROOT_ID + "-locate-hint";
|
|
180
|
-
hint.textContent = "Click an element to jump to its source · Esc to cancel";
|
|
181
|
-
ltoast = document.createElement("div");
|
|
182
|
-
ltoast.id = ROOT_ID + "-locate-toast";
|
|
183
|
-
document.body.append(hi, hint, ltoast);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function inWidget(el) {
|
|
187
|
-
return !!el && (el === root || root.contains(el) || el === hi || el === hint || el === ltoast);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function onMove(e) {
|
|
191
|
-
const el = document.elementFromPoint(e.clientX, e.clientY);
|
|
192
|
-
if (!el || inWidget(el)) {
|
|
193
|
-
hi.style.display = "none";
|
|
194
|
-
lastHover = null;
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
lastHover = el;
|
|
198
|
-
const r = el.getBoundingClientRect();
|
|
199
|
-
hi.style.display = "block";
|
|
200
|
-
hi.style.left = r.left + "px";
|
|
201
|
-
hi.style.top = r.top + "px";
|
|
202
|
-
hi.style.width = r.width + "px";
|
|
203
|
-
hi.style.height = r.height + "px";
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function showLToast(text, located) {
|
|
207
|
-
ensureLocateEls();
|
|
208
|
-
ltoast.textContent = text;
|
|
209
|
-
if (located) {
|
|
210
|
-
// Best-effort $EDITOR jump (server degrades gracefully when unset).
|
|
211
|
-
const open = document.createElement("button");
|
|
212
|
-
open.textContent = "Open in editor";
|
|
213
|
-
open.style.cssText =
|
|
214
|
-
"margin-left:.7rem;background:#0f7b6c;color:#fff;border:none;border-radius:6px;" +
|
|
215
|
-
"padding:.3rem .6rem;font:600 .72rem/1 -apple-system,sans-serif;cursor:pointer";
|
|
216
|
-
open.addEventListener("click", () => {
|
|
217
|
-
postJson("/__tot/open-in-editor", located).catch(() => {});
|
|
218
|
-
});
|
|
219
|
-
ltoast.appendChild(open);
|
|
220
|
-
}
|
|
221
|
-
ltoast.classList.add("show");
|
|
222
|
-
clearTimeout(showLToast._t);
|
|
223
|
-
showLToast._t = setTimeout(() => ltoast.classList.remove("show"), 6000);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
async function onClick(e) {
|
|
227
|
-
if (inWidget(e.target)) return; // clicks on the widget itself pass through
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
e.stopPropagation();
|
|
230
|
-
const el = lastHover || document.elementFromPoint(e.clientX, e.clientY);
|
|
231
|
-
exitLocate();
|
|
232
|
-
if (!el) return;
|
|
233
|
-
const domPath = captureDomPath(el);
|
|
234
|
-
// C8 (capstone) branches HERE: when framed (window !== window.parent) it
|
|
235
|
-
// postMessages { type:"tot:locate", path, line, col } to the parent editor
|
|
236
|
-
// instead of this standalone toast. C7 ships the standalone path only.
|
|
237
|
-
let res, body;
|
|
238
|
-
try {
|
|
239
|
-
res = await fetch("/__tot/locate", {
|
|
240
|
-
method: "POST",
|
|
241
|
-
headers: { "content-type": "application/json" },
|
|
242
|
-
body: JSON.stringify({ domPath, path: location.pathname }),
|
|
243
|
-
});
|
|
244
|
-
body = await res.json();
|
|
245
|
-
} catch (err) {
|
|
246
|
-
showLToast("Locate unavailable — is tot dev running?");
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
// C8 capstone: when this page is FRAMED (the live-preview iframe inside /dev),
|
|
250
|
-
// deliver the result to the parent cockpit instead of a standalone toast — the
|
|
251
|
-
// parent opens the file + places the cursor. Only content-region hits (a real
|
|
252
|
-
// {line,col}) are forwarded; chrome/refused clicks stay silent inside the frame
|
|
253
|
-
// (no toast over the preview, no misleading jump), honoring the content-region
|
|
254
|
-
// decision. targetOrigin is our own origin (same-origin preview) — never "*".
|
|
255
|
-
const framed = window !== window.parent;
|
|
256
|
-
if (!res.ok || (body && body.status)) {
|
|
257
|
-
if (framed) return; // refused inside the frame — quietly no-op
|
|
258
|
-
showLToast(
|
|
259
|
-
body && body.status === "not_raw_html"
|
|
260
|
-
? "Locate works on raw-HTML tenants only — this page is templated."
|
|
261
|
-
: "Couldn’t find that element in the source.",
|
|
262
|
-
);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (framed) {
|
|
266
|
-
try {
|
|
267
|
-
window.parent.postMessage(
|
|
268
|
-
{ type: "tot:locate", path: body.path, line: body.line, col: body.col },
|
|
269
|
-
window.location.origin,
|
|
270
|
-
);
|
|
271
|
-
} catch (err) { /* parent gone / cross-origin — nothing to do */ }
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
showLToast(`${body.path}:${body.line}:${body.col}`, body);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function onEsc(e) {
|
|
278
|
-
if (e.key === "Escape") {
|
|
279
|
-
e.preventDefault();
|
|
280
|
-
exitLocate();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function enterLocate() {
|
|
285
|
-
ensureLocateEls();
|
|
286
|
-
locating = true;
|
|
287
|
-
root.classList.remove("open");
|
|
288
|
-
hint.style.display = "block";
|
|
289
|
-
document.addEventListener("mousemove", onMove, true);
|
|
290
|
-
document.addEventListener("click", onClick, true);
|
|
291
|
-
document.addEventListener("keydown", onEsc, true);
|
|
292
|
-
document.body.style.cursor = "crosshair";
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function exitLocate() {
|
|
296
|
-
locating = false;
|
|
297
|
-
if (hi) hi.style.display = "none";
|
|
298
|
-
if (hint) hint.style.display = "none";
|
|
299
|
-
document.removeEventListener("mousemove", onMove, true);
|
|
300
|
-
document.removeEventListener("click", onClick, true);
|
|
301
|
-
document.removeEventListener("keydown", onEsc, true);
|
|
302
|
-
document.body.style.cursor = "";
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (locateBtn) {
|
|
306
|
-
locateBtn.addEventListener("click", () => (locating ? exitLocate() : enterLocate()));
|
|
307
|
-
}
|
|
308
|
-
})();
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment-aware endpoint base for the /dev cockpit (file tree/viewer/diff +
|
|
3
|
-
* click-to-source). Local `astro dev` serves these off dev-server-only plugins at
|
|
4
|
-
* `/__tot/*` (dev-plugins/dev-file-browser.mjs, dev-write.mjs, dev-diff.mjs, ...) —
|
|
5
|
-
* paths that don't exist in the deployed Cloudflare Worker. The hosted Worker instead
|
|
6
|
-
* serves the SAME shape off `/api/dev/*` Astro API routes
|
|
7
|
-
* (cp-tree, cp-file, cp-write, cp-diff, cp-locate). One dev.astro UI, one resolver.
|
|
8
|
-
*
|
|
9
|
-
* `basePath` is the request's tenant prefix ("" host-routed, "/<tenant>" path-routed).
|
|
10
|
-
* The HOSTED routes are tenant-scoped through the middleware's host/path resolution, so
|
|
11
|
-
* a `/<tenant>/cockpit` render must call `/<tenant>/api/dev/*` for `locals.tenant` to be
|
|
12
|
-
* that store on the API request (not the generic home host). The local `/__tot/*` dev
|
|
13
|
-
* plugins are single-tenant and take no prefix.
|
|
14
|
-
*/
|
|
15
|
-
export function resolveDevApiBase(isDev: boolean, basePath = ""): string {
|
|
16
|
-
return isDev ? "/__tot" : `${basePath}/api/dev`;
|
|
17
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mint a browserless "get going" command for an ALREADY-AUTHENTICATED developer — the
|
|
3
|
-
* second half of the invite story. The developer accepted the magic link (OTP-free web
|
|
4
|
-
* sign-in) and landed on /cockpit; this hands them a single-copy, THREE-LINE paste — line 1
|
|
5
|
-
* installs the CLI, line 2 signs the terminal in, line 3 runs `start` (checkout → run →
|
|
6
|
-
* open the browser on the working site) — so they go from web sign-in to a running store
|
|
7
|
-
* with NO second browser round-trip and NO OTP.
|
|
8
|
-
*
|
|
9
|
-
* The paste carries a NON-SECRET rendezvous handle minted by the MCP's
|
|
10
|
-
* POST /oauth/device/rendezvous (RFC 8628 rendezvous), authenticated by the storefront's
|
|
11
|
-
* SIGNED CLIENT ASSERTION (private_key_jwt) — NOT a shared secret. `tot login --code <handle>`
|
|
12
|
-
* then ATTACHES the terminal's own PKCE key and the developer approves it by fingerprint
|
|
13
|
-
* back here in the cockpit (see the /api/dev/cli-signin-{status,approve} routes). The handle
|
|
14
|
-
* is not a credential: intercepting it grants nothing without the terminal's private key,
|
|
15
|
-
* and the developer must still approve the matching fingerprint.
|
|
16
|
-
*
|
|
17
|
-
* Line 2 appends `--mcp <origin>` ONLY when the MCP is not the CLI's built-in prod default —
|
|
18
|
-
* on prod the shortest form is emitted.
|
|
19
|
-
*
|
|
20
|
-
* `activityBridge` (optional) piggybacks the local→hosted activity-bridge credential
|
|
21
|
-
* (see lib/developer-experience/dev/activityIngestToken.ts) onto the SAME pasted line as two extra `tot login`
|
|
22
|
-
* flags — no second browser round-trip. Omitted entirely when the caller has no SESSION KV
|
|
23
|
-
* to mint against — the local loop then simply runs with no hosted signal.
|
|
24
|
-
*/
|
|
25
|
-
import { readEnv } from "@/lib/publication/shared/env";
|
|
26
|
-
import { redactEmailForHint } from "@/lib/access/privacy/emailHint";
|
|
27
|
-
import { createRendezvous, type RendezvousDeps } from "@/lib/developer-experience/dev/rendezvousBroker";
|
|
28
|
-
|
|
29
|
-
// The CLI's built-in default MCP (packages/cli login.mjs DEFAULT_MCP_URL). When the derived
|
|
30
|
-
// MCP origin equals this, --mcp is redundant noise, so we omit it.
|
|
31
|
-
const PROD_MCP_ORIGIN = "https://mcp.tokenoftrust.com";
|
|
32
|
-
|
|
33
|
-
export type CliSignInCodeResult =
|
|
34
|
-
| { ok: true; command: string; rendezvousCode: string; expiresAt: string | null }
|
|
35
|
-
| { ok: false; status: 502 | 503; reason: string };
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Mint the ready-to-paste CLI sign-in command for `email`. The caller MUST pass the
|
|
39
|
-
* VERIFIED session email (never a client-supplied value) — a signed-in developer can only
|
|
40
|
-
* start a rendezvous for themselves. `tenant` (the developer's own vendor, session-derived)
|
|
41
|
-
* is threaded so the CLI session lands already bound to that store (no client_list
|
|
42
|
-
* round-trip). Fail-closed: an unconfigured seam or a 401/403 (assertion rejected / client
|
|
43
|
-
* not entitled to broker) is a 503; any other fault is a 502. Never throws.
|
|
44
|
-
*
|
|
45
|
-
* Returns the pasteable `command` AND the `rendezvousCode` — the cockpit polls the latter
|
|
46
|
-
* for a terminal attaching, then shows the fingerprint approval prompt.
|
|
47
|
-
*/
|
|
48
|
-
export async function mintCliSignInCommand(
|
|
49
|
-
email: string,
|
|
50
|
-
tenant: string | null = null,
|
|
51
|
-
deps: RendezvousDeps = {},
|
|
52
|
-
activityBridge: { token: string; url: string } | null = null,
|
|
53
|
-
traceId: string | null = null,
|
|
54
|
-
): Promise<CliSignInCodeResult> {
|
|
55
|
-
// MCP_BASE_URL is the MCP tier this storefront's client assertion is registered
|
|
56
|
-
// with (where the rendezvous is created), so the pasted `--mcp` host MUST match it
|
|
57
|
-
// — the terminal redeems the rendezvous against that same MCP. (The retired shim
|
|
58
|
-
// used MCP_APP_BINDING_URL, which may point at a different tier.)
|
|
59
|
-
const baseUrl = await readEnv("MCP_BASE_URL");
|
|
60
|
-
if (!baseUrl) {
|
|
61
|
-
return { ok: false, status: 503, reason: "not-configured" };
|
|
62
|
-
}
|
|
63
|
-
let mcpOrigin: string;
|
|
64
|
-
try {
|
|
65
|
-
mcpOrigin = new URL(baseUrl).origin;
|
|
66
|
-
} catch {
|
|
67
|
-
return { ok: false, status: 503, reason: "bad-mcp-url" };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const created = await createRendezvous(email, tenant, deps);
|
|
71
|
-
if (!created.ok) {
|
|
72
|
-
// 503 = seam not configured / assertion rejected / not entitled on this env;
|
|
73
|
-
// 502 = MCP fault. Surface neither internal detail nor any token.
|
|
74
|
-
return { ok: false, status: created.status, reason: created.reason };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const mcpFlag = mcpOrigin === PROD_MCP_ORIGIN ? "" : ` --mcp ${mcpOrigin}`;
|
|
78
|
-
// Display-only recovery hint for a stale one-use handle. If sign-in fails before
|
|
79
|
-
// anything is cached locally, `tot login` can still send the developer back to
|
|
80
|
-
// cockpit with the right address prefilled.
|
|
81
|
-
const emailHint = redactEmailForHint(email);
|
|
82
|
-
const emailHintFlag = emailHint ? ` --email-hint ${emailHint}` : "";
|
|
83
|
-
// Piggyback the activity-bridge credential onto the SAME login line — additive
|
|
84
|
-
// flags, ignored by older CLI builds that don't yet recognize them.
|
|
85
|
-
const activityFlags = activityBridge
|
|
86
|
-
? ` --activity-token ${activityBridge.token} --activity-url ${activityBridge.url}`
|
|
87
|
-
: "";
|
|
88
|
-
// The invite→terminal→problem trace id, minted once with this rendezvous and baked
|
|
89
|
-
// into the activity-ingest-token claims. Emitted here too so `tot login` records it
|
|
90
|
-
// locally — additive, ignored by older CLI builds.
|
|
91
|
-
const traceFlag = traceId ? ` --trace-id ${traceId}` : "";
|
|
92
|
-
// The EXACT version this build was cut alongside — baked in at build time (astro.config
|
|
93
|
-
// Vite define) so the paste installs precisely the CLI this cockpit expects. `typeof`
|
|
94
|
-
// guard: the define isn't applied under vitest, where it falls back to the unpinned spec.
|
|
95
|
-
const cliInstallSpec =
|
|
96
|
-
typeof __CLI_INSTALL_SPEC__ !== "undefined" ? __CLI_INSTALL_SPEC__ : "@tokenoftrust/cli";
|
|
97
|
-
// `hash -r` after the install clears the shell's cached command path so the
|
|
98
|
-
// just-installed `tot` is the one that runs — without it, a shell that already
|
|
99
|
-
// resolved an OLDER `tot` (e.g. a stray Homebrew/other-prefix install earlier in
|
|
100
|
-
// this session) keeps running the stale binary, and `npm i -g` silently updates a
|
|
101
|
-
// file the shell never consults. Portable across bash/zsh/sh; fish can't run the
|
|
102
|
-
// `&&` chain anyway. This is what makes the pinned version actually take effect.
|
|
103
|
-
// A first-line no-op stamping which cockpit build generated this command (short git
|
|
104
|
-
// SHA — the same one /health reports) + the CLI it pins, so a paste can be matched to
|
|
105
|
-
// a deploy at a glance (pairs with `tot login`'s runtime version banner). Uses the
|
|
106
|
-
// `: '…'` null-command form, NOT a `#` comment — interactive zsh doesn't treat `#` as
|
|
107
|
-
// a comment (no INTERACTIVE_COMMENTS) and errors on it; `: '…'` is a portable no-op.
|
|
108
|
-
const cockpitBuild = (typeof __GIT_SHA__ !== "undefined" ? __GIT_SHA__ : "unknown").slice(0, 7);
|
|
109
|
-
const command = [
|
|
110
|
-
`: 'tot setup (cockpit ${cockpitBuild}, ${cliInstallSpec})'`,
|
|
111
|
-
`npm i -g ${cliInstallSpec} &&`,
|
|
112
|
-
`hash -r &&`,
|
|
113
|
-
`tot login --code ${created.rendezvousCode}${emailHintFlag}${mcpFlag}${traceFlag}${activityFlags} &&`,
|
|
114
|
-
// `start` must talk to the SAME MCP the session was minted on — it otherwise defaults
|
|
115
|
-
// to the prod MCP and won't see a qa session (→ "not signed in" → sample fallback).
|
|
116
|
-
`tot start${mcpFlag}`,
|
|
117
|
-
].join("\n");
|
|
118
|
-
return {
|
|
119
|
-
ok: true,
|
|
120
|
-
command,
|
|
121
|
-
rendezvousCode: created.rendezvousCode,
|
|
122
|
-
expiresAt: created.expiresIn != null ? new Date(Date.now() + created.expiresIn * 1000).toISOString() : null,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* "Stuck? Ask" recovery affordance. A quiet FAB that opens a scoped Q&A
|
|
3
|
-
* for "why isn't the loop working" — NOT general AI editing. Static answers
|
|
4
|
-
* ship as markup; the two stateful answers (is it running? / save-vs-reload)
|
|
5
|
-
* update from the shared tot:loop-state signal + window.__totLoop (monitor.ts
|
|
6
|
-
* — no second poll). "Reconnect preview" reloads the page, re-establishing
|
|
7
|
-
* the HMR connection and re-reading loop state (recovers a stale client); a
|
|
8
|
-
* fully-down server is handled by the answer text (run tot start). Imported
|
|
9
|
-
* from a processed `<script>` in cockpit.astro (ADR 0013), rendered only when
|
|
10
|
-
* isLocalDevLoop.
|
|
11
|
-
*/
|
|
12
|
-
export function initAsk(): void {
|
|
13
|
-
const fab = document.getElementById("askFab");
|
|
14
|
-
const panel = document.getElementById("askPanel");
|
|
15
|
-
if (!fab || !panel) return;
|
|
16
|
-
const ansRunning = document.getElementById("ans-running");
|
|
17
|
-
const ansChange = document.getElementById("ans-change");
|
|
18
|
-
const restart = document.getElementById("restartBtn");
|
|
19
|
-
|
|
20
|
-
fab.addEventListener("click", (e) => { e.stopPropagation(); panel.classList.toggle("open"); });
|
|
21
|
-
document.addEventListener("click", (e) => {
|
|
22
|
-
if (!panel.contains(e.target as Node) && e.target !== fab && !fab.contains(e.target as Node)) panel.classList.remove("open");
|
|
23
|
-
});
|
|
24
|
-
if (restart) restart.addEventListener("click", () => { location.reload(); });
|
|
25
|
-
|
|
26
|
-
function rel(ts: number | string): string {
|
|
27
|
-
const d = Math.max(0, Math.round((Date.now() - Number(ts)) / 1000));
|
|
28
|
-
return d < 2 ? "just now" : d < 60 ? d + "s ago" : Math.floor(d / 60) + "m ago";
|
|
29
|
-
}
|
|
30
|
-
function update(s: any) {
|
|
31
|
-
if (!s) return;
|
|
32
|
-
if (ansRunning) {
|
|
33
|
-
ansRunning.textContent = (s.offline || !s.server)
|
|
34
|
-
? "Your dev server isn't reachable right now — run tot start in your terminal, then reload this page."
|
|
35
|
-
: "Yes — your server is running" + (s.port ? " on port " + s.port : "") + ". This page is connected to it.";
|
|
36
|
-
}
|
|
37
|
-
if (ansChange) {
|
|
38
|
-
if (!s.lastSaveAt) {
|
|
39
|
-
ansChange.textContent = "No saves seen yet. Edit a watched file (like content/home.html) and save — it'll show up here.";
|
|
40
|
-
} else if ((s.lastReloadAt || 0) >= s.lastSaveAt) {
|
|
41
|
-
ansChange.textContent = "Working: your last save (" + rel(s.lastSaveAt) + ") triggered a reload (" + rel(s.lastReloadAt) + "). If the page didn't visibly change, make sure you edited the file the page renders from.";
|
|
42
|
-
} else {
|
|
43
|
-
ansChange.textContent = "Your save (" + rel(s.lastSaveAt) + ") hasn't been reflected by a reload yet — the preview may be stale. Try Reconnect preview below.";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
window.addEventListener("tot:loop-state", (e: any) => { update(e.detail); });
|
|
48
|
-
if (window.__totLoop) update(window.__totLoop);
|
|
49
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* C8 · Click-to-source capstone — the cockpit side. Runs the live-preview
|
|
3
|
-
* iframe (mini + full-screen dialog) and LISTENS for the framed picker's
|
|
4
|
-
* tot:locate postMessage. The picker (ai-widget-client.js, auto-injected into
|
|
5
|
-
* the same-origin preview) resolves a click to {path,line,col} via
|
|
6
|
-
* /__tot/locate, then — because it is framed — postMessages the result here
|
|
7
|
-
* instead of showing its own toast. We verify event.origin === our origin,
|
|
8
|
-
* then hand off to files.ts's window.__totOpenFileAt to open the source +
|
|
9
|
-
* drop the caret. Only content-region hits ever arrive (chrome/refused
|
|
10
|
-
* clicks stay silent in the frame), per decision
|
|
11
|
-
* click-to-source-anchors-at-content-region. Imported from a processed
|
|
12
|
-
* `<script>` in cockpit.astro (ADR 0013), rendered only when isLocalDevLoop.
|
|
13
|
-
* isDev and the hosted app domain are read from `document.body.dataset`.
|
|
14
|
-
*/
|
|
15
|
-
export function initClickToSource(): void {
|
|
16
|
-
const isDev = document.body.dataset.cockpitIsDev === "true";
|
|
17
|
-
const hostedAppDomain = document.body.dataset.cockpitAppDomain || "";
|
|
18
|
-
const dlg: any = document.getElementById("previewDialog");
|
|
19
|
-
const expandBtn = document.getElementById("previewExpand");
|
|
20
|
-
const closeBtn = document.getElementById("previewClose");
|
|
21
|
-
const dlgFrame: any = document.getElementById("previewDialogFrame");
|
|
22
|
-
const miniFrame: any = document.getElementById("previewFrame");
|
|
23
|
-
const urlEl = document.getElementById("previewUrl");
|
|
24
|
-
|
|
25
|
-
if (miniFrame) {
|
|
26
|
-
if (isDev) {
|
|
27
|
-
// Point the preview at the DEV tenant (TOT_DEV_TENANT), read from the server
|
|
28
|
-
// via /__tot/dev-loop-status — NOT the SSR appDomain (workerd can't see
|
|
29
|
-
// TOT_DEV_*). Same-origin, so the auto-injected picker can postMessage back.
|
|
30
|
-
fetch("/__tot/dev-loop-status")
|
|
31
|
-
.then((r) => r.json())
|
|
32
|
-
.then((s) => {
|
|
33
|
-
const tenant = s && s.tenant;
|
|
34
|
-
if (!tenant) return;
|
|
35
|
-
const src = "/" + tenant + "/";
|
|
36
|
-
miniFrame.src = src;
|
|
37
|
-
if (urlEl) urlEl.textContent = "localhost preview · " + tenant;
|
|
38
|
-
})
|
|
39
|
-
.catch(() => { /* dev server unreachable — preview stays blank */ });
|
|
40
|
-
} else if (hostedAppDomain) {
|
|
41
|
-
// Hosted: the SSR-resolved tenant IS the signed-in developer's own store
|
|
42
|
-
// (cp-env's capability gate already scoped it) — same-origin, so a cp-write
|
|
43
|
-
// save + this reload shows the developer's own draft overlay via the
|
|
44
|
-
// middleware's tot_dev_draft cookie check.
|
|
45
|
-
miniFrame.src = "/" + hostedAppDomain + "/";
|
|
46
|
-
if (urlEl) urlEl.textContent = "your store · " + hostedAppDomain;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (expandBtn && dlg) {
|
|
51
|
-
expandBtn.addEventListener("click", () => {
|
|
52
|
-
if (dlgFrame && !dlgFrame.getAttribute("src") && miniFrame) dlgFrame.src = miniFrame.getAttribute("src") || miniFrame.src;
|
|
53
|
-
if (typeof dlg.showModal === "function") dlg.showModal(); else dlg.setAttribute("open", "");
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
if (closeBtn && dlg) closeBtn.addEventListener("click", () => { dlg.close ? dlg.close() : dlg.removeAttribute("open"); });
|
|
57
|
-
if (dlg) dlg.addEventListener("click", (e: MouseEvent) => { if (e.target === dlg) { dlg.close ? dlg.close() : dlg.removeAttribute("open"); } });
|
|
58
|
-
|
|
59
|
-
// The one privileged inbound message: a source location from OUR OWN origin's
|
|
60
|
-
// framed preview. Reject any other origin, shape, or type outright.
|
|
61
|
-
window.addEventListener("message", (e) => {
|
|
62
|
-
if (e.origin !== window.location.origin) return;
|
|
63
|
-
const d: any = e.data;
|
|
64
|
-
if (!d || d.type !== "tot:locate" || typeof d.path !== "string") return;
|
|
65
|
-
if (typeof (window as any).__totOpenFileAt === "function") {
|
|
66
|
-
const opened = (window as any).__totOpenFileAt(d.path, d.line, d.col);
|
|
67
|
-
// If the preview was expanded full-screen, close it so the editor + caret are visible.
|
|
68
|
-
if (opened && dlg && dlg.open) { dlg.close ? dlg.close() : dlg.removeAttribute("open"); }
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|