@wildo-ai/saas-website 1.1.4 → 1.1.6
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/dist/esm/astro/blog-post-bridge.d.ts +23 -20
- package/dist/esm/astro/blog-post-bridge.d.ts.map +1 -1
- package/dist/esm/astro/blog-post-bridge.js +13 -6
- package/dist/esm/astro/blog-post-bridge.js.map +1 -1
- package/dist/esm/astro/blog-post-head.renderer.d.ts.map +1 -1
- package/dist/esm/astro/bridge-runtime.d.ts +55 -26
- package/dist/esm/astro/bridge-runtime.d.ts.map +1 -1
- package/dist/esm/astro/bridge-runtime.js +21 -7
- package/dist/esm/astro/bridge-runtime.js.map +1 -1
- package/dist/esm/astro/collect-expected-label-keys.d.ts.map +1 -1
- package/dist/esm/astro/headers-renderer.d.ts.map +1 -1
- package/dist/esm/astro/i18n-routing.helper.d.ts.map +1 -1
- package/dist/esm/astro/label-pack-loader.d.ts +4 -4
- package/dist/esm/astro/label-pack-loader.d.ts.map +1 -1
- package/dist/esm/astro/label-pack-loader.js +14 -4
- package/dist/esm/astro/label-pack-loader.js.map +1 -1
- package/dist/esm/astro/llms-txt-server.d.ts.map +1 -1
- package/dist/esm/astro/pick-labels-for-page.d.ts.map +1 -1
- package/dist/esm/astro/robots-renderer.d.ts +9 -8
- package/dist/esm/astro/robots-renderer.d.ts.map +1 -1
- package/dist/esm/astro/robots-renderer.js +15 -15
- package/dist/esm/astro/robots-renderer.js.map +1 -1
- package/dist/esm/astro/sitemap-coverage.d.ts.map +1 -1
- package/dist/esm/astro/structured-data.renderer.d.ts.map +1 -1
- package/dist/esm/astro/website-page-head.renderer.d.ts +1 -1
- package/dist/esm/astro/website-page-head.renderer.d.ts.map +1 -1
- package/dist/esm/astro/website-page-head.renderer.js +2 -1
- package/dist/esm/astro/website-page-head.renderer.js.map +1 -1
- package/dist/esm/astro/website-page-runtime.helper.d.ts.map +1 -1
- package/dist/esm/astro/website-site-context.d.ts +5 -2
- package/dist/esm/astro/website-site-context.d.ts.map +1 -1
- package/dist/esm/astro/website-site-context.js.map +1 -1
- package/dist/esm/astro-island.d.ts.map +1 -1
- package/dist/esm/astro.d.ts.map +1 -1
- package/dist/esm/companion-exports.d.ts +8 -15
- package/dist/esm/companion-exports.d.ts.map +1 -1
- package/dist/esm/companion-exports.js +8 -15
- package/dist/esm/companion-exports.js.map +1 -1
- package/dist/esm/components/low-level/WebsiteInternalButton.d.ts.map +1 -1
- package/dist/esm/components/low-level/WebsiteInternalLink.d.ts.map +1 -1
- package/dist/esm/config/define-website-config.d.ts +3 -2
- package/dist/esm/config/define-website-config.d.ts.map +1 -1
- package/dist/esm/config/define-website-config.js +10 -10
- package/dist/esm/config/define-website-config.js.map +1 -1
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/load-website-config.d.ts +6 -0
- package/dist/esm/config/load-website-config.d.ts.map +1 -1
- package/dist/esm/config/load-website-config.js +20 -10
- package/dist/esm/config/load-website-config.js.map +1 -1
- package/dist/esm/config/load-website-pricing-catalog.d.ts +13 -0
- package/dist/esm/config/load-website-pricing-catalog.d.ts.map +1 -0
- package/dist/esm/config/load-website-pricing-catalog.js +34 -0
- package/dist/esm/config/load-website-pricing-catalog.js.map +1 -0
- package/dist/esm/config/load-website-site-context.d.ts +53 -0
- package/dist/esm/config/load-website-site-context.d.ts.map +1 -0
- package/dist/esm/config/load-website-site-context.js +98 -0
- package/dist/esm/config/load-website-site-context.js.map +1 -0
- package/dist/esm/config/wildo-website-config.schemas.d.ts +10 -5
- package/dist/esm/config/wildo-website-config.schemas.d.ts.map +1 -1
- package/dist/esm/config/wildo-website-config.schemas.js +10 -5
- package/dist/esm/config/wildo-website-config.schemas.js.map +1 -1
- package/dist/esm/config-loader.d.ts +2 -0
- package/dist/esm/config-loader.d.ts.map +1 -1
- package/dist/esm/config-loader.js +2 -0
- package/dist/esm/config-loader.js.map +1 -1
- package/dist/esm/core/anonymous-session/InboundContactForm.d.ts +26 -6
- package/dist/esm/core/anonymous-session/InboundContactForm.d.ts.map +1 -1
- package/dist/esm/core/anonymous-session/InboundContactForm.js +51 -33
- package/dist/esm/core/anonymous-session/InboundContactForm.js.map +1 -1
- package/dist/esm/core/anonymous-session/inbound-contact-form.schema.d.ts +14 -3
- package/dist/esm/core/anonymous-session/inbound-contact-form.schema.d.ts.map +1 -1
- package/dist/esm/core/anonymous-session/inbound-contact-form.schema.js +28 -13
- package/dist/esm/core/anonymous-session/inbound-contact-form.schema.js.map +1 -1
- package/dist/esm/core/anonymous-session/website-anonymous-session-client.d.ts +24 -1
- package/dist/esm/core/anonymous-session/website-anonymous-session-client.d.ts.map +1 -1
- package/dist/esm/core/anonymous-session/website-anonymous-session-client.js +46 -3
- package/dist/esm/core/anonymous-session/website-anonymous-session-client.js.map +1 -1
- package/dist/esm/core/anonymous-session/website-submission-challenge.d.ts +36 -0
- package/dist/esm/core/anonymous-session/website-submission-challenge.d.ts.map +1 -0
- package/dist/esm/core/anonymous-session/website-submission-challenge.js +69 -0
- package/dist/esm/core/anonymous-session/website-submission-challenge.js.map +1 -0
- package/dist/esm/core/consent/WebsiteConsentBanner.d.ts +6 -0
- package/dist/esm/core/consent/WebsiteConsentBanner.d.ts.map +1 -0
- package/dist/esm/core/consent/WebsiteConsentBanner.js +129 -0
- package/dist/esm/core/consent/WebsiteConsentBanner.js.map +1 -0
- package/dist/esm/core/consent/WebsiteConsentContext.d.ts +85 -0
- package/dist/esm/core/consent/WebsiteConsentContext.d.ts.map +1 -0
- package/dist/esm/core/consent/WebsiteConsentContext.js +89 -0
- package/dist/esm/core/consent/WebsiteConsentContext.js.map +1 -0
- package/dist/esm/core/consent/WebsiteConsentGate.d.ts +27 -0
- package/dist/esm/core/consent/WebsiteConsentGate.d.ts.map +1 -0
- package/dist/esm/core/consent/WebsiteConsentGate.js +9 -0
- package/dist/esm/core/consent/WebsiteConsentGate.js.map +1 -0
- package/dist/esm/core/consent/useWebsiteConsent.d.ts +10 -0
- package/dist/esm/core/consent/useWebsiteConsent.d.ts.map +1 -0
- package/dist/esm/core/consent/useWebsiteConsent.js +17 -0
- package/dist/esm/core/consent/useWebsiteConsent.js.map +1 -0
- package/dist/esm/core/consent/website-consent-storage.d.ts +22 -0
- package/dist/esm/core/consent/website-consent-storage.d.ts.map +1 -0
- package/dist/esm/core/consent/website-consent-storage.js +102 -0
- package/dist/esm/core/consent/website-consent-storage.js.map +1 -0
- package/dist/esm/core/contexts/WebsitePageContext.d.ts.map +1 -1
- package/dist/esm/core/contexts/WebsitePageContext.js.map +1 -1
- package/dist/esm/core/contexts/WebsiteRuntimeContext.d.ts +33 -6
- package/dist/esm/core/contexts/WebsiteRuntimeContext.d.ts.map +1 -1
- package/dist/esm/core/contexts/WebsiteRuntimeContext.js.map +1 -1
- package/dist/esm/core/contexts/WebsiteSectionContext.d.ts.map +1 -1
- package/dist/esm/core/contexts/WebsiteSectionContext.js.map +1 -1
- package/dist/esm/core/contexts/useWebsitePage.d.ts.map +1 -1
- package/dist/esm/core/contexts/useWebsiteRuntime.d.ts +18 -0
- package/dist/esm/core/contexts/useWebsiteRuntime.d.ts.map +1 -1
- package/dist/esm/core/contexts/useWebsiteRuntime.js +28 -2
- package/dist/esm/core/contexts/useWebsiteRuntime.js.map +1 -1
- package/dist/esm/core/contexts/useWebsiteSection.d.ts.map +1 -1
- package/dist/esm/core/external-providers/WebsiteProviderComponent.d.ts +57 -0
- package/dist/esm/core/external-providers/WebsiteProviderComponent.d.ts.map +1 -0
- package/dist/esm/core/external-providers/WebsiteProviderComponent.js +56 -0
- package/dist/esm/core/external-providers/WebsiteProviderComponent.js.map +1 -0
- package/dist/esm/core/external-providers/frontend-provider-registry.website.d.ts +1 -2
- package/dist/esm/core/external-providers/frontend-provider-registry.website.d.ts.map +1 -1
- package/dist/esm/core/external-providers/frontend-provider-registry.website.js.map +1 -1
- package/dist/esm/core/external-providers/provider-component-registry.website.d.ts +63 -0
- package/dist/esm/core/external-providers/provider-component-registry.website.d.ts.map +1 -0
- package/dist/esm/core/external-providers/provider-component-registry.website.js +68 -0
- package/dist/esm/core/external-providers/provider-component-registry.website.js.map +1 -0
- package/dist/esm/core/external-providers/useWebsiteProviderComponent.d.ts +36 -0
- package/dist/esm/core/external-providers/useWebsiteProviderComponent.d.ts.map +1 -0
- package/dist/esm/core/external-providers/useWebsiteProviderComponent.js +59 -0
- package/dist/esm/core/external-providers/useWebsiteProviderComponent.js.map +1 -0
- package/dist/esm/core/external-providers/useWebsiteProviderScripts.d.ts +43 -10
- package/dist/esm/core/external-providers/useWebsiteProviderScripts.d.ts.map +1 -1
- package/dist/esm/core/external-providers/useWebsiteProviderScripts.js +92 -29
- package/dist/esm/core/external-providers/useWebsiteProviderScripts.js.map +1 -1
- package/dist/esm/core/external-providers/website-provider-sdk-activations.d.ts +11 -0
- package/dist/esm/core/external-providers/website-provider-sdk-activations.d.ts.map +1 -0
- package/dist/esm/core/external-providers/website-provider-sdk-activations.js +14 -0
- package/dist/esm/core/external-providers/website-provider-sdk-activations.js.map +1 -0
- package/dist/esm/core/factories/define-website-page-manifest.d.ts.map +1 -1
- package/dist/esm/core/factories/define-website-section.d.ts +3 -3
- package/dist/esm/core/factories/define-website-section.d.ts.map +1 -1
- package/dist/esm/core/factories/define-website-section.js +3 -3
- package/dist/esm/core/factories/define-website-section.js.map +1 -1
- package/dist/esm/core/hooks/useWebsiteDesignTokens.d.ts.map +1 -1
- package/dist/esm/core/hooks/useWebsiteLabel.d.ts.map +1 -1
- package/dist/esm/core/layouts/WebsitePageLayout.d.ts +21 -1
- package/dist/esm/core/layouts/WebsitePageLayout.d.ts.map +1 -1
- package/dist/esm/core/layouts/WebsitePageLayout.js +39 -8
- package/dist/esm/core/layouts/WebsitePageLayout.js.map +1 -1
- package/dist/esm/core/layouts/WebsiteSection.d.ts.map +1 -1
- package/dist/esm/core/routing/internal-routing.utils.d.ts.map +1 -1
- package/dist/esm/index.d.ts +36 -65
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +36 -65
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mdx/BlogPost.d.ts.map +1 -1
- package/dist/esm/mdx/blog-post-collection.config.d.ts.map +1 -1
- package/dist/esm/mdx/blog-post-frontmatter-source.d.ts.map +1 -1
- package/dist/esm/mdx/index.d.ts.map +1 -1
- package/dist/esm/mdx.d.ts.map +1 -1
- package/dist/esm/schemas/blog/blog-post-frontmatter.shared.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/design-tokens/website-design-tokens.shared.schemas.d.ts +35 -6
- package/dist/esm/schemas/design-tokens/website-design-tokens.shared.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/design-tokens/website-design-tokens.shared.schemas.js +39 -5
- package/dist/esm/schemas/design-tokens/website-design-tokens.shared.schemas.js.map +1 -1
- package/dist/esm/schemas/label-keys/website-consent-label-keys.schemas.d.ts +61 -0
- package/dist/esm/schemas/label-keys/website-consent-label-keys.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/label-keys/website-consent-label-keys.schemas.js +73 -0
- package/dist/esm/schemas/label-keys/website-consent-label-keys.schemas.js.map +1 -0
- package/dist/esm/schemas/label-keys/website-label-key.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/label-keys/website-provider-component-label-keys.schemas.d.ts +32 -0
- package/dist/esm/schemas/label-keys/website-provider-component-label-keys.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/label-keys/website-provider-component-label-keys.schemas.js +36 -0
- package/dist/esm/schemas/label-keys/website-provider-component-label-keys.schemas.js.map +1 -0
- package/dist/esm/schemas/manifests/website-page-manifest.shared.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/manifests/website-root-config.shared.schemas.d.ts +6 -5
- package/dist/esm/schemas/manifests/website-root-config.shared.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/manifests/website-root-config.shared.schemas.js +8 -7
- package/dist/esm/schemas/manifests/website-root-config.shared.schemas.js.map +1 -1
- package/dist/esm/schemas/refs/page-ref.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/refs/section-ref.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/sections/website-section-category.shared.d.ts.map +1 -1
- package/dist/esm/schemas/sections/website-section-category.shared.js.map +1 -1
- package/dist/esm/schemas/sections/website-section-definition.shared.schemas.d.ts +14 -7
- package/dist/esm/schemas/sections/website-section-definition.shared.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/sections/website-section-definition.shared.schemas.js +14 -7
- package/dist/esm/schemas/sections/website-section-definition.shared.schemas.js.map +1 -1
- package/dist/esm/schemas/structured-data/pricing-offer-structured-data.shared.d.ts +57 -0
- package/dist/esm/schemas/structured-data/pricing-offer-structured-data.shared.d.ts.map +1 -0
- package/dist/esm/schemas/structured-data/pricing-offer-structured-data.shared.js +76 -0
- package/dist/esm/schemas/structured-data/pricing-offer-structured-data.shared.js.map +1 -0
- package/dist/esm/schemas/structured-data/structured-data-reconciliation.shared.d.ts +23 -0
- package/dist/esm/schemas/structured-data/structured-data-reconciliation.shared.d.ts.map +1 -1
- package/dist/esm/schemas/structured-data/structured-data-reconciliation.shared.js +20 -2
- package/dist/esm/schemas/structured-data/structured-data-reconciliation.shared.js.map +1 -1
- package/dist/esm/schemas/structured-data/website-structured-data.shared.schemas.d.ts +7 -5
- package/dist/esm/schemas/structured-data/website-structured-data.shared.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/structured-data/website-structured-data.shared.schemas.js.map +1 -1
- package/dist/esm/schemas/validators/label-pack.validator.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -29
- package/src/__tests__/bundle-isolation.test.ts +19 -22
- package/src/astro/__tests__/blog-post-bridge.test.tsx +58 -1
- package/src/astro/__tests__/bridge-runtime.test.tsx +44 -1
- package/src/astro/__tests__/label-pack-loader.test.ts +29 -1
- package/src/astro/blog-post-bridge.tsx +36 -26
- package/src/astro/bridge-runtime.tsx +79 -33
- package/src/astro/label-pack-loader.ts +12 -4
- package/src/astro/robots-renderer.ts +15 -15
- package/src/astro/website-page-head.renderer.ts +2 -2
- package/src/astro/website-site-context.ts +5 -2
- package/src/companion-exports.ts +8 -15
- package/src/config/__tests__/website-build-origins.test.ts +52 -0
- package/src/config/define-website-config.ts +10 -10
- package/src/config/load-website-config.ts +27 -15
- package/src/config/load-website-pricing-catalog.ts +52 -0
- package/src/config/load-website-site-context.ts +145 -0
- package/src/config/wildo-website-config.schemas.ts +10 -5
- package/src/config-loader.ts +2 -0
- package/src/core/__tests__/WebsitePageLayout.test.tsx +1 -1
- package/src/core/__tests__/contexts.test.tsx +20 -1
- package/src/core/__tests__/website-consent.test.tsx +312 -0
- package/src/core/anonymous-session/InboundContactForm.tsx +100 -45
- package/src/core/anonymous-session/__tests__/InboundContactForm.labels.test.tsx +108 -0
- package/src/core/anonymous-session/__tests__/InboundContactForm.submission-challenge.test.tsx +139 -0
- package/src/core/anonymous-session/__tests__/inbound-contact-form.schema.test.ts +11 -4
- package/src/core/anonymous-session/inbound-contact-form.schema.ts +30 -13
- package/src/core/anonymous-session/website-anonymous-session-client.ts +52 -3
- package/src/core/anonymous-session/website-submission-challenge.ts +99 -0
- package/src/core/consent/WebsiteConsentBanner.tsx +223 -0
- package/src/core/consent/WebsiteConsentContext.tsx +164 -0
- package/src/core/consent/WebsiteConsentGate.tsx +34 -0
- package/src/core/consent/useWebsiteConsent.ts +18 -0
- package/src/core/consent/website-consent-storage.ts +116 -0
- package/src/core/contexts/WebsiteRuntimeContext.tsx +33 -6
- package/src/core/contexts/useWebsiteRuntime.ts +33 -2
- package/src/core/external-providers/WebsiteProviderComponent.tsx +153 -0
- package/src/core/external-providers/__tests__/frontend-provider-registry.website.test.ts +4 -0
- package/src/core/external-providers/__tests__/website-provider-component.test.tsx +238 -0
- package/src/core/external-providers/__tests__/website-provider-sdks.test.tsx +72 -0
- package/src/core/external-providers/frontend-provider-registry.website.ts +1 -2
- package/src/core/external-providers/provider-component-registry.website.ts +115 -0
- package/src/core/external-providers/useWebsiteProviderComponent.ts +76 -0
- package/src/core/external-providers/useWebsiteProviderScripts.ts +114 -40
- package/src/core/external-providers/website-provider-sdk-activations.ts +23 -0
- package/src/core/factories/define-website-section.ts +3 -3
- package/src/core/layouts/WebsitePageLayout.tsx +75 -7
- package/src/index.ts +38 -65
- package/src/schemas/__tests__/design-token-css-property.test.ts +72 -0
- package/src/schemas/__tests__/pricing-offer-structured-data.test.ts +122 -0
- package/src/schemas/__tests__/structured-data-reconciliation.test.ts +35 -0
- package/src/schemas/design-tokens/website-design-tokens.shared.schemas.ts +45 -5
- package/src/schemas/label-keys/__tests__/scaffolded-consent-label-pack.parity.test.ts +83 -0
- package/src/schemas/label-keys/website-consent-label-keys.schemas.ts +78 -0
- package/src/schemas/label-keys/website-provider-component-label-keys.schemas.ts +40 -0
- package/src/schemas/manifests/website-root-config.shared.schemas.ts +10 -9
- package/src/schemas/sections/website-section-definition.shared.schemas.ts +14 -7
- package/src/schemas/structured-data/pricing-offer-structured-data.shared.ts +144 -0
- package/src/schemas/structured-data/structured-data-reconciliation.shared.ts +46 -1
- package/src/schemas/structured-data/website-structured-data.shared.schemas.ts +7 -5
- package/dist/esm/core/external-providers/provider-scripts.website.d.ts +0 -68
- package/dist/esm/core/external-providers/provider-scripts.website.d.ts.map +0 -1
- package/dist/esm/core/external-providers/provider-scripts.website.js +0 -99
- package/dist/esm/core/external-providers/provider-scripts.website.js.map +0 -1
- package/src/core/external-providers/__tests__/provider-scripts.website.test.ts +0 -146
- package/src/core/external-providers/provider-scripts.website.ts +0 -126
|
@@ -12,24 +12,54 @@
|
|
|
12
12
|
* does not exist would throw, and starting a vendor SDK there would run a live
|
|
13
13
|
* analytics client inside a build.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
15
|
+
* Both come from `@wildo-ai/external-connectors-public/website`. The script
|
|
16
|
+
* injector lives there rather than here so the SaaS application, the technical
|
|
17
|
+
* doc and this site run ONE copy of it: a second copy of a DOM mutation
|
|
18
|
+
* eventually disagrees about idempotence, which is how a vendor tag gets loaded
|
|
19
|
+
* twice. It first shipped here alone, and that is how the application came to
|
|
20
|
+
* declare its Drive Picker's Google API script and never inject it.
|
|
21
|
+
*
|
|
22
|
+
* ## Client-side injection, and the alternative that was rejected
|
|
23
|
+
*
|
|
24
|
+
* This is an Astro static site, so the "obvious" home for a third-party tag is
|
|
25
|
+
* the built HTML `<head>`. That was rejected for now: the set of live providers
|
|
26
|
+
* is per SERVICE and per ENVIRONMENT, resolved from the materialized artifact,
|
|
27
|
+
* while the built HTML is one artifact shared across deploys of the same build.
|
|
28
|
+
* Baking the tags in would make the build environment-specific — the same class
|
|
29
|
+
* of coupling the DATA channel exists to avoid. Injecting from the client keeps
|
|
30
|
+
* one build correct everywhere, at the cost of the tag arriving after hydration.
|
|
31
|
+
* Revisit if a provider ever needs to run before first paint.
|
|
23
32
|
*/
|
|
24
|
-
import { useEffect } from 'react';
|
|
25
|
-
import { activateFrontendProviderSdks, } from '@wildo-ai/external-connectors-public/website';
|
|
26
|
-
import { collectDeclaredProviderScripts, injectProviderScripts, } from './provider-scripts.website.js';
|
|
33
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
34
|
+
import { activateFrontendProviderSdks, collectProviderScriptsWithoutComponents, consentPurposesRequiredByProvider, createFrontendProviderSdkActivationLane, injectProviderScripts, } from '@wildo-ai/external-connectors-public/website';
|
|
27
35
|
import { AppFrontendType } from '@wildo-ai/saas-models/public-runtime';
|
|
28
|
-
|
|
36
|
+
/**
|
|
37
|
+
* A stable key for a granted-purpose set, so an effect re-runs when the SET changes and not when a new
|
|
38
|
+
* array with the same members is handed in.
|
|
39
|
+
*/
|
|
40
|
+
function grantedKey(grantedConsentPurposes) {
|
|
41
|
+
return [...grantedConsentPurposes].sort().join(',');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Injects the `<script>` tags of the live providers that rest on NO consent purpose and render no component.
|
|
45
|
+
*
|
|
46
|
+
* No consent input, deliberately (#1704): an executed `<script>` cannot be stopped, so a provider that rests on a
|
|
47
|
+
* purpose must ship as a stoppable SDK (started on the grant and stopped on withdrawal by
|
|
48
|
+
* {@link useWebsiteProviderSdks}); a consent-based module declaring `scripts` is refused at projection and skipped by
|
|
49
|
+
* the collector. No grant could change what this injects.
|
|
50
|
+
*/
|
|
51
|
+
export function useWebsiteProviderScripts(registry,
|
|
52
|
+
/**
|
|
53
|
+
* The website's provider-component registry (#1703). A provider with a registered component loads its
|
|
54
|
+
* scripts WITH that component, when a page first shows it — so an address lookup's vendor loader is
|
|
55
|
+
* not downloaded on every page of the site, only on the one with the form. This hook injects the rest.
|
|
56
|
+
*/
|
|
57
|
+
componentRegistry) {
|
|
29
58
|
useEffect(() => {
|
|
30
59
|
if (typeof document === 'undefined')
|
|
31
60
|
return;
|
|
32
|
-
const
|
|
61
|
+
const withComponents = [...(componentRegistry?.providersWithComponents() ?? [])].map((providerRef) => ({ providerRef }));
|
|
62
|
+
const scripts = collectProviderScriptsWithoutComponents(registry?.modules.values() ?? [], withComponents);
|
|
33
63
|
if (scripts.length === 0)
|
|
34
64
|
return;
|
|
35
65
|
injectProviderScripts(scripts, document);
|
|
@@ -37,7 +67,7 @@ export function useWebsiteProviderScripts(registry) {
|
|
|
37
67
|
// work immediately; removing the element undoes neither, so a cleanup that
|
|
38
68
|
// removed it would only make the next mount inject a SECOND copy of an
|
|
39
69
|
// already-running script. Idempotence by `src` is the real guard.
|
|
40
|
-
}, [registry]);
|
|
70
|
+
}, [registry, componentRegistry]);
|
|
41
71
|
}
|
|
42
72
|
/**
|
|
43
73
|
* Loads and starts the npm SDK of every live provider that declares one.
|
|
@@ -46,33 +76,66 @@ export function useWebsiteProviderScripts(registry) {
|
|
|
46
76
|
* offers a teardown — an analytics client that cannot be stopped cannot honour
|
|
47
77
|
* a consent withdrawal, and accumulates one instance per view transition.
|
|
48
78
|
*/
|
|
49
|
-
export function useWebsiteProviderSdks(registry
|
|
79
|
+
export function useWebsiteProviderSdks(registry,
|
|
80
|
+
/**
|
|
81
|
+
* The purposes the visitor granted (#534). Providers are activated in TWO groups on purpose: those that
|
|
82
|
+
* rest on no purpose (error monitoring, captcha) are started once and never restarted by a consent
|
|
83
|
+
* change, while the consent-based ones start when their purpose is granted and are DEACTIVATED when it
|
|
84
|
+
* is withdrawn — which is the only way a withdrawal stops a running analytics client.
|
|
85
|
+
*/
|
|
86
|
+
grantedConsentPurposes) {
|
|
87
|
+
const consentFree = useProviderSdkGroup(registry, false, []);
|
|
88
|
+
const consentBased = useProviderSdkGroup(registry, true, grantedConsentPurposes);
|
|
89
|
+
// The providers RUNNING on this page, both groups, published by the page layout (#1735): a form reads the captcha
|
|
90
|
+
// vendor's handle from here. Emptied the moment a group stops, so nothing holds a handle past a withdrawal.
|
|
91
|
+
return useMemo(() => [...consentFree, ...consentBased], [consentFree, consentBased]);
|
|
92
|
+
}
|
|
93
|
+
function useProviderSdkGroup(registry, consentBased, grantedConsentPurposes) {
|
|
94
|
+
const [running, setRunning] = useState([]);
|
|
95
|
+
// Keyed by the grants this group's providers actually rest on, so changing an unrelated purpose does
|
|
96
|
+
// not stop and restart a running analytics client.
|
|
97
|
+
const relevant = registry === undefined
|
|
98
|
+
? []
|
|
99
|
+
: [...registry.modules.values()]
|
|
100
|
+
.filter((module) => (consentPurposesRequiredByProvider(module).length > 0) === consentBased)
|
|
101
|
+
.flatMap((module) => consentPurposesRequiredByProvider(module))
|
|
102
|
+
.filter((purpose) => grantedConsentPurposes.includes(purpose));
|
|
103
|
+
const key = grantedKey(relevant);
|
|
104
|
+
// One lane per group for the page's lifetime: a start waits for the previous stop.
|
|
105
|
+
const lane = useRef(createFrontendProviderSdkActivationLane());
|
|
50
106
|
useEffect(() => {
|
|
51
107
|
if (registry === undefined)
|
|
52
108
|
return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
109
|
+
const modules = [...registry.modules.values()].filter((module) => (consentPurposesRequiredByProvider(module).length > 0) === consentBased);
|
|
110
|
+
if (modules.length === 0)
|
|
111
|
+
return;
|
|
112
|
+
// Through the group's lane, so a start never overlaps the previous stop of the same page-global vendor (#1704): a
|
|
113
|
+
// visitor who grants, withdraws and grants again while the bundle downloads must not have the first run's stop
|
|
114
|
+
// switch off the second run's client. The stop also covers an unmount mid-download.
|
|
115
|
+
const stop = lane.current.start(() => activateFrontendProviderSdks({
|
|
56
116
|
surface: AppFrontendType.STATIC_WEBSITE,
|
|
57
|
-
modules
|
|
117
|
+
modules,
|
|
118
|
+
grantedConsentPurposes,
|
|
58
119
|
onDiagnostic: (diagnostic) => {
|
|
59
120
|
// The website runtime has no logger service, and a provider that cannot
|
|
60
121
|
// start is a developer-facing fact that must not be silent.
|
|
61
122
|
// eslint-disable-next-line no-console
|
|
62
123
|
console.warn(`[wildo-provider-sdk] ${diagnostic.kind}: ${diagnostic.message}`);
|
|
63
124
|
},
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
125
|
+
}), (result) => {
|
|
126
|
+
setRunning(modules.flatMap((module) => {
|
|
127
|
+
const activation = result.activations.get(module.metadata.ref);
|
|
128
|
+
return activation === undefined
|
|
129
|
+
? []
|
|
130
|
+
: [{ providerRef: module.metadata.ref, providerCapabilities: [...module.providerCapabilities], activation }];
|
|
131
|
+
}));
|
|
71
132
|
});
|
|
72
133
|
return () => {
|
|
73
|
-
|
|
74
|
-
|
|
134
|
+
setRunning([]);
|
|
135
|
+
stop();
|
|
75
136
|
};
|
|
76
|
-
|
|
137
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- keyed by the granted SET, see grantedKey.
|
|
138
|
+
}, [registry, consentBased, key]);
|
|
139
|
+
return running;
|
|
77
140
|
}
|
|
78
141
|
//# sourceMappingURL=useWebsiteProviderScripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use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E,CAAC,CAAC;YACjF,CAAC;SACF,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACjB,SAAS,GAAG,MAAM,CAAC;YACnB,0EAA0E;YAC1E,yEAAyE;YACzE,iDAAiD;YACjD,IAAI,SAAS;gBAAE,KAAK,MAAM,CAAC,aAAa,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,KAAK,SAAS,EAAE,aAAa,EAAE,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjB,CAAC","sourcesContent":["/**\n * The website's executable-surface hooks: load what the live providers declared.\n *\n * Two mechanisms, one per kind of vendor. `useWebsiteProviderScripts` adds the\n * `<script>` tags a provider declared — the case a dynamic `import()` cannot\n * serve, and the dominant one on a marketing site. `useWebsiteProviderSdks`\n * activates the npm SDK of any provider that ships one, which reaches this\n * bundle through the CODE channel.\n *\n * Both are effect-only, and that is not incidental: this is an Astro site, so\n * page modules execute in Node at build time. Injecting into a document that\n * does not exist would throw, and starting a vendor SDK there would run a live\n * analytics client inside a build.\n *\n * SDK activation comes from `@wildo-ai/external-connectors-public/website`, which\n * this package now depends on. The script injector beside it does NOT yet, and\n * that is a timing artifact rather than a decision: it belongs in the same\n * package so the technical doc can use one copy — a second copy of a DOM\n * mutation eventually disagrees about idempotence, which is how a vendor tag\n * gets loaded twice. Moving it needs that package's `dist` to carry it, and no\n * watcher is running in this tree; consolidating it is a one-step follow-up, not\n * a design question.\n */\n\nimport { useEffect } from 'react';\nimport {\n activateFrontendProviderSdks,\n type ActivatedFrontendProviderSdks,\n} from '@wildo-ai/external-connectors-public/website';\nimport {\n collectDeclaredProviderScripts,\n injectProviderScripts,\n} from './provider-scripts.website';\nimport { AppFrontendType } from '@wildo-ai/saas-models/public-runtime';\nimport type { FrontendWebsiteProviderRegistry } from './frontend-provider-registry.website';\n\nexport function useWebsiteProviderScripts(\n registry: FrontendWebsiteProviderRegistry | undefined,\n): void {\n useEffect(() => {\n if (typeof document === 'undefined') return;\n\n const scripts = collectDeclaredProviderScripts(registry);\n if (scripts.length === 0) return;\n\n injectProviderScripts(scripts, document);\n // Deliberately no teardown. A vendor tag installs a global and often starts\n // work immediately; removing the element undoes neither, so a cleanup that\n // removed it would only make the next mount inject a SECOND copy of an\n // already-running script. Idempotence by `src` is the real guard.\n }, [registry]);\n}\n\n/**\n * Loads and starts the npm SDK of every live provider that declares one.\n *\n * Unlike a script tag, an SDK activation IS undone on unmount where the vendor\n * offers a teardown — an analytics client that cannot be stopped cannot honour\n * a consent withdrawal, and accumulates one instance per view transition.\n */\nexport function useWebsiteProviderSdks(\n registry: FrontendWebsiteProviderRegistry | undefined,\n): void {\n useEffect(() => {\n if (registry === undefined) return;\n\n let unmounted = false;\n let activated: ActivatedFrontendProviderSdks | undefined;\n\n void activateFrontendProviderSdks({\n surface: AppFrontendType.STATIC_WEBSITE,\n modules: registry.modules.values(),\n onDiagnostic: (diagnostic) => {\n // The website runtime has no logger service, and a provider that cannot\n // start is a developer-facing fact that must not be silent.\n // eslint-disable-next-line no-console\n console.warn(`[wildo-provider-sdk] ${diagnostic.kind}: ${diagnostic.message}`);\n },\n }).then((result) => {\n activated = result;\n // Activation is asynchronous and unmount is not: if the surface went away\n // while a vendor bundle was still downloading, stop what we just started\n // rather than leaving a client nobody can reach.\n if (unmounted) void result.deactivateAll();\n });\n\n return () => {\n unmounted = true;\n void activated?.deactivateAll();\n };\n }, [registry]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useWebsiteProviderScripts.js","sourceRoot":"","sources":["../../../../../src/core/external-providers/useWebsiteProviderScripts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,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mechanisms, one per kind of vendor. `useWebsiteProviderScripts` adds the\n * `<script>` tags a provider declared — the case a dynamic `import()` cannot\n * serve, and the dominant one on a marketing site. `useWebsiteProviderSdks`\n * activates the npm SDK of any provider that ships one, which reaches this\n * bundle through the CODE channel.\n *\n * Both are effect-only, and that is not incidental: this is an Astro site, so\n * page modules execute in Node at build time. Injecting into a document that\n * does not exist would throw, and starting a vendor SDK there would run a live\n * analytics client inside a build.\n *\n * Both come from `@wildo-ai/external-connectors-public/website`. The script\n * injector lives there rather than here so the SaaS application, the technical\n * doc and this site run ONE copy of it: a second copy of a DOM mutation\n * eventually disagrees about idempotence, which is how a vendor tag gets loaded\n * twice. It first shipped here alone, and that is how the application came to\n * declare its Drive Picker's Google API script and never inject it.\n *\n * ## Client-side injection, and the alternative that was rejected\n *\n * This is an Astro static site, so the \"obvious\" home for a third-party tag is\n * the built HTML `<head>`. That was rejected for now: the set of live providers\n * is per SERVICE and per ENVIRONMENT, resolved from the materialized artifact,\n * while the built HTML is one artifact shared across deploys of the same build.\n * Baking the tags in would make the build environment-specific — the same class\n * of coupling the DATA channel exists to avoid. Injecting from the client keeps\n * one build correct everywhere, at the cost of the tag arriving after hydration.\n * Revisit if a provider ever needs to run before first paint.\n */\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport {\n activateFrontendProviderSdks,\n collectProviderScriptsWithoutComponents,\n consentPurposesRequiredByProvider,\n createFrontendProviderSdkActivationLane,\n injectProviderScripts,\n} from '@wildo-ai/external-connectors-public/website';\nimport { AppFrontendType, type ConsentPurpose } from '@wildo-ai/saas-models/public-runtime';\nimport type { FrontendWebsiteProviderRegistry } from './frontend-provider-registry.website';\nimport type { WebsiteProviderComponentRegistry } from './provider-component-registry.website';\nimport type { WebsiteProviderSdkActivation } from './website-provider-sdk-activations';\n\n/**\n * A stable key for a granted-purpose set, so an effect re-runs when the SET changes and not when a new\n * array with the same members is handed in.\n */\nfunction grantedKey(grantedConsentPurposes: readonly ConsentPurpose[]): string {\n return [...grantedConsentPurposes].sort().join(',');\n}\n\n/**\n * Injects the `<script>` tags of the live providers that rest on NO consent purpose and render no component.\n *\n * No consent input, deliberately (#1704): an executed `<script>` cannot be stopped, so a provider that rests on a\n * purpose must ship as a stoppable SDK (started on the grant and stopped on withdrawal by\n * {@link useWebsiteProviderSdks}); a consent-based module declaring `scripts` is refused at projection and skipped by\n * the collector. No grant could change what this injects.\n */\nexport function useWebsiteProviderScripts(\n registry: FrontendWebsiteProviderRegistry | undefined,\n /**\n * The website's provider-component registry (#1703). A provider with a registered component loads its\n * scripts WITH that component, when a page first shows it — so an address lookup's vendor loader is\n * not downloaded on every page of the site, only on the one with the form. This hook injects the rest.\n */\n componentRegistry?: WebsiteProviderComponentRegistry,\n): void {\n useEffect(() => {\n if (typeof document === 'undefined') return;\n\n const withComponents = [...(componentRegistry?.providersWithComponents() ?? [])].map((providerRef) => ({ providerRef }));\n const scripts = collectProviderScriptsWithoutComponents(registry?.modules.values() ?? [], withComponents);\n if (scripts.length === 0) return;\n\n injectProviderScripts(scripts, document);\n // Deliberately no teardown. A vendor tag installs a global and often starts\n // work immediately; removing the element undoes neither, so a cleanup that\n // removed it would only make the next mount inject a SECOND copy of an\n // already-running script. Idempotence by `src` is the real guard.\n }, [registry, componentRegistry]);\n}\n\n/**\n * Loads and starts the npm SDK of every live provider that declares one.\n *\n * Unlike a script tag, an SDK activation IS undone on unmount where the vendor\n * offers a teardown — an analytics client that cannot be stopped cannot honour\n * a consent withdrawal, and accumulates one instance per view transition.\n */\nexport function useWebsiteProviderSdks(\n registry: FrontendWebsiteProviderRegistry | undefined,\n /**\n * The purposes the visitor granted (#534). Providers are activated in TWO groups on purpose: those that\n * rest on no purpose (error monitoring, captcha) are started once and never restarted by a consent\n * change, while the consent-based ones start when their purpose is granted and are DEACTIVATED when it\n * is withdrawn — which is the only way a withdrawal stops a running analytics client.\n */\n grantedConsentPurposes: readonly ConsentPurpose[],\n): ReadonlyArray<WebsiteProviderSdkActivation> {\n const consentFree = useProviderSdkGroup(registry, false, []);\n const consentBased = useProviderSdkGroup(registry, true, grantedConsentPurposes);\n // The providers RUNNING on this page, both groups, published by the page layout (#1735): a form reads the captcha\n // vendor's handle from here. Emptied the moment a group stops, so nothing holds a handle past a withdrawal.\n return useMemo(() => [...consentFree, ...consentBased], [consentFree, consentBased]);\n}\n\nfunction useProviderSdkGroup(\n registry: FrontendWebsiteProviderRegistry | undefined,\n consentBased: boolean,\n grantedConsentPurposes: readonly ConsentPurpose[],\n): ReadonlyArray<WebsiteProviderSdkActivation> {\n const [running, setRunning] = useState<ReadonlyArray<WebsiteProviderSdkActivation>>([]);\n // Keyed by the grants this group's providers actually rest on, so changing an unrelated purpose does\n // not stop and restart a running analytics client.\n const relevant = registry === undefined\n ? []\n : [...registry.modules.values()]\n .filter((module) => (consentPurposesRequiredByProvider(module).length > 0) === consentBased)\n .flatMap((module) => consentPurposesRequiredByProvider(module))\n .filter((purpose) => grantedConsentPurposes.includes(purpose));\n const key = grantedKey(relevant);\n // One lane per group for the page's lifetime: a start waits for the previous stop.\n const lane = useRef(createFrontendProviderSdkActivationLane());\n useEffect(() => {\n if (registry === undefined) return;\n const modules = [...registry.modules.values()].filter(\n (module) => (consentPurposesRequiredByProvider(module).length > 0) === consentBased,\n );\n if (modules.length === 0) return;\n\n // Through the group's lane, so a start never overlaps the previous stop of the same page-global vendor (#1704): a\n // visitor who grants, withdraws and grants again while the bundle downloads must not have the first run's stop\n // switch off the second run's client. The stop also covers an unmount mid-download.\n const stop = lane.current.start(\n () => activateFrontendProviderSdks({\n surface: AppFrontendType.STATIC_WEBSITE,\n modules,\n grantedConsentPurposes,\n onDiagnostic: (diagnostic) => {\n // The website runtime has no logger service, and a provider that cannot\n // start is a developer-facing fact that must not be silent.\n // eslint-disable-next-line no-console\n console.warn(`[wildo-provider-sdk] ${diagnostic.kind}: ${diagnostic.message}`);\n },\n }),\n (result) => {\n setRunning(modules.flatMap((module) => {\n const activation = result.activations.get(module.metadata.ref);\n return activation === undefined\n ? []\n : [{ providerRef: module.metadata.ref, providerCapabilities: [...module.providerCapabilities], activation }];\n }));\n },\n );\n return () => {\n setRunning([]);\n stop();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed by the granted SET, see grantedKey.\n }, [registry, consentBased, key]);\n return running;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProviderFrontendSdkActivation } from '@wildo-ai/external-connectors-public/website';
|
|
2
|
+
/** One running provider: its ref, the capabilities it serves, and its activation (whose `handle` is the vendor's client). */
|
|
3
|
+
export interface WebsiteProviderSdkActivation {
|
|
4
|
+
readonly providerRef: string;
|
|
5
|
+
readonly providerCapabilities: ReadonlyArray<string>;
|
|
6
|
+
readonly activation: ProviderFrontendSdkActivation;
|
|
7
|
+
}
|
|
8
|
+
export declare const WebsiteProviderSdkActivationsContext: import("react").Context<readonly WebsiteProviderSdkActivation[]>;
|
|
9
|
+
/** The provider SDKs running on this page, in declaration order. Empty outside a page layout and before any start. */
|
|
10
|
+
export declare function useWebsiteProviderSdkActivations(): ReadonlyArray<WebsiteProviderSdkActivation>;
|
|
11
|
+
//# sourceMappingURL=website-provider-sdk-activations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"website-provider-sdk-activations.d.ts","sourceRoot":"","sources":["../../../../../src/core/external-providers/website-provider-sdk-activations.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAElG,6HAA6H;AAC7H,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrD,QAAQ,CAAC,UAAU,EAAE,6BAA6B,CAAC;CACpD;AAED,eAAO,MAAM,oCAAoC,kEAAiE,CAAC;AAEnH,sHAAsH;AACtH,wBAAgB,gCAAgC,IAAI,aAAa,CAAC,4BAA4B,CAAC,CAE9F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider SDKs RUNNING on this website page (#1735), published by the page layout.
|
|
3
|
+
*
|
|
4
|
+
* A section reaches a running vendor through here rather than through a global — the contact form asks the consented
|
|
5
|
+
* captcha vendor for a token this way. The list is emptied the moment a provider is stopped (a consent withdrawal, a
|
|
6
|
+
* navigation), so a consumer that reads it at the moment it needs a handle never holds one past a withdrawal.
|
|
7
|
+
*/
|
|
8
|
+
import { createContext, useContext } from 'react';
|
|
9
|
+
export const WebsiteProviderSdkActivationsContext = createContext([]);
|
|
10
|
+
/** The provider SDKs running on this page, in declaration order. Empty outside a page layout and before any start. */
|
|
11
|
+
export function useWebsiteProviderSdkActivations() {
|
|
12
|
+
return useContext(WebsiteProviderSdkActivationsContext);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=website-provider-sdk-activations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"website-provider-sdk-activations.js","sourceRoot":"","sources":["../../../../../src/core/external-providers/website-provider-sdk-activations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAUlD,MAAM,CAAC,MAAM,oCAAoC,GAAG,aAAa,CAA8C,EAAE,CAAC,CAAC;AAEnH,sHAAsH;AACtH,MAAM,UAAU,gCAAgC;IAC9C,OAAO,UAAU,CAAC,oCAAoC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * The provider SDKs RUNNING on this website page (#1735), published by the page layout.\n *\n * A section reaches a running vendor through here rather than through a global — the contact form asks the consented\n * captcha vendor for a token this way. The list is emptied the moment a provider is stopped (a consent withdrawal, a\n * navigation), so a consumer that reads it at the moment it needs a handle never holds one past a withdrawal.\n */\nimport { createContext, useContext } from 'react';\nimport type { ProviderFrontendSdkActivation } from '@wildo-ai/external-connectors-public/website';\n\n/** One running provider: its ref, the capabilities it serves, and its activation (whose `handle` is the vendor's client). */\nexport interface WebsiteProviderSdkActivation {\n readonly providerRef: string;\n readonly providerCapabilities: ReadonlyArray<string>;\n readonly activation: ProviderFrontendSdkActivation;\n}\n\nexport const WebsiteProviderSdkActivationsContext = createContext<ReadonlyArray<WebsiteProviderSdkActivation>>([]);\n\n/** The provider SDKs running on this page, in declaration order. Empty outside a page layout and before any start. */\nexport function useWebsiteProviderSdkActivations(): ReadonlyArray<WebsiteProviderSdkActivation> {\n return useContext(WebsiteProviderSdkActivationsContext);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-website-page-manifest.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"define-website-page-manifest.d.ts","sourceRoot":"","sources":["../../../../../src/core/factories/define-website-page-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,4BAA4B,EAC7B,MAAM,8DAA8D,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,8BAA8B,CAAC,MAAM;IACpD,GAAG,EAAE,cAAc,GAAG,MAAM,CAAC;IAC7B,SAAS,EAAE,oBAAoB,GAAG,MAAM,CAAC;IACzC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,SAAS,CAAC,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC;IACrD,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,CAAC,EAAE,4BAA4B,CAAC;IACzC,GAAG,CAAC,EAAE,oBAAoB,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CAAC,MAAM,CAC9C,SAAQ,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC;IAClD,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACtE,KAAK,EAAE,8BAA8B,CAAC,MAAM,CAAC,GAC5C,wBAAwB,CAAC,MAAM,CAAC,CAmBlC;AACD,yEAAyE"}
|
|
@@ -65,9 +65,9 @@ export interface TypedWebsiteSectionDefinition<TProps> extends Omit<WebsiteSecti
|
|
|
65
65
|
* **Why a factory instead of constructing the literal directly**:
|
|
66
66
|
* - Consumers don't have to remember to parse refs / keys
|
|
67
67
|
* themselves before assembling the literal.
|
|
68
|
-
* - The schema parse provides a single audited validation chokepoint
|
|
69
|
-
*
|
|
70
|
-
* without re-entering the React graph.
|
|
68
|
+
* - The schema parse provides a single audited validation chokepoint,
|
|
69
|
+
* and the parsed `expectedLabelKeys` are what `wildo website audit`
|
|
70
|
+
* checks every locale pack against, without re-entering the React graph.
|
|
71
71
|
* - The factory is the documented authoring API the
|
|
72
72
|
* `website_factory_authoring` skill targets — keeping the
|
|
73
73
|
* authoring surface narrow lets the framework evolve the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-website-section.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"define-website-section.d.ts","sourceRoot":"","sources":["../../../../../src/core/factories/define-website-section.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kEAAkE,CAAC;AACjH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AACrG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sEAAsE,CAAC;AAExH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,yBAAyB,CAAC,MAAM;IAC/C,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAAC;IACvC,QAAQ,EAAE,sBAAsB,CAAC;IACjC,iBAAiB,EAAE,SAAS,CAAC,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC;IACzD,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,2BAA2B,CAAC;CACvD;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,6BAA6B,CAAC,MAAM,CACnD,SAAQ,IAAI,CAAC,wBAAwB,EAAE,WAAW,GAAG,mBAAmB,CAAC;IACzE,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,2BAA2B,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EACzC,KAAK,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACvC,6BAA6B,CAAC,MAAM,CAAC,CAoBvC;AACD,mEAAmE"}
|
|
@@ -15,9 +15,9 @@ import { WebsiteSectionDefinitionSchema } from '../../schemas/sections/website-s
|
|
|
15
15
|
* **Why a factory instead of constructing the literal directly**:
|
|
16
16
|
* - Consumers don't have to remember to parse refs / keys
|
|
17
17
|
* themselves before assembling the literal.
|
|
18
|
-
* - The schema parse provides a single audited validation chokepoint
|
|
19
|
-
*
|
|
20
|
-
* without re-entering the React graph.
|
|
18
|
+
* - The schema parse provides a single audited validation chokepoint,
|
|
19
|
+
* and the parsed `expectedLabelKeys` are what `wildo website audit`
|
|
20
|
+
* checks every locale pack against, without re-entering the React graph.
|
|
21
21
|
* - The factory is the documented authoring API the
|
|
22
22
|
* `website_factory_authoring` skill targets — keeping the
|
|
23
23
|
* authoring surface narrow lets the framework evolve the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-website-section.js","sourceRoot":"","sources":["../../../../../src/core/factories/define-website-section.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kEAAkE,CAAC;AAuDlH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAwC;IAExC,MAAM,MAAM,GAAG,8BAA8B,CAAC,KAAK,CAAC;QAClD,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC,CAAC;IACH;;;;OAIG;IACH,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnF,CAAC;AACJ,CAAC;AACD,mEAAmE","sourcesContent":["import type { ComponentType } from 'react';\n\nimport { WebsiteSectionDefinitionSchema } from '../../schemas/sections/website-section-definition.shared.schemas';\nimport type { WebsiteSectionDefinition } from '../../schemas/sections/website-section-definition.shared.schemas';\nimport type { WebsiteSectionCategory } from '../../schemas/sections/website-section-category.shared';\nimport type { WebsiteSectionRef } from '../../schemas/refs/section-ref.schemas';\nimport type { WebsiteLabelKey } from '../../schemas/label-keys/website-label-key.schemas';\nimport type { WebsiteStructuredDataReturn } from '../../schemas/structured-data/website-structured-data.shared.schemas';\n\n/**\n * @wildo_source:part:start saas.website.factories.define-section facet:layer:core facet:family:website\n *\n * Input shape consumed by `defineWebsiteSection<TProps>`. Mirrors\n * `WebsiteSectionDefinition` but keeps `Component` typed against the\n * caller-supplied generic so the precise prop shape survives end-to-end\n * (the consumer's `<HeroSection />` JSX can keep its strongly-typed\n * props after going through the factory).\n *\n * **String inputs vs. branded inputs**: `sectionRef` and\n * `expectedLabelKeys` accept raw strings as well as already-branded\n * values. The factory parses them through the underlying schemas, so\n * either path is safe — accepting strings directly removes the\n * ergonomic drag of forcing every section author to remember to call\n * `WebsiteSectionRefSchema.parse(...)` in their definition.\n */\nexport interface DefineWebsiteSectionInput<TProps> {\n sectionRef: WebsiteSectionRef | string;\n category: WebsiteSectionCategory;\n expectedLabelKeys: readonly (WebsiteLabelKey | string)[];\n Component: ComponentType<TProps>;\n /**\n * See `WebsiteSectionDefinition.getStructuredData?` JSDoc for the\n * full authoring contract. The factory passes the function through\n * unchanged; the framework invokes it at static-build time and\n * forwards the return value to `renderPageStructuredData()`.\n */\n getStructuredData?: () => WebsiteStructuredDataReturn;\n}\n\n/**\n * Return shape of `defineWebsiteSection<TProps>`. Identical to\n * `WebsiteSectionDefinition` except `Component` retains the\n * caller-supplied generic prop shape rather than the schema's\n * lowest-common-denominator `ComponentType<unknown>`.\n *\n * **Why this matters**: a consumer's `pageComponent` JSX composes\n * sections like `<HERO_SECTION.Component {...heroProps} />`. Without\n * preserving `TProps`, the spread would be untyped and a renamed prop\n * would silently miss the type system. With `TProps` preserved, the\n * call site fails to compile the moment the prop contract drifts.\n */\nexport interface TypedWebsiteSectionDefinition<TProps>\n extends Omit<WebsiteSectionDefinition, 'Component' | 'getStructuredData'> {\n Component: ComponentType<TProps>;\n getStructuredData?: () => WebsiteStructuredDataReturn;\n}\n\n/**\n * `defineWebsiteSection<TProps>` — factory that materializes a\n * `WebsiteSectionDefinition` from authored input.\n *\n * **Two responsibilities**, one entry point:\n * 1. Runtime validation — parses the input through\n * `WebsiteSectionDefinitionSchema` so brand checks, regex\n * validations, and array refinements run at module load time\n * (not at render time, not at build-output time).\n * 2. Type preservation — returns an object whose `Component` field\n * keeps the caller-supplied `TProps`, so JSX usage of the\n * returned section retains compile-time prop checking.\n *\n * **Why a factory instead of constructing the literal directly**:\n * - Consumers don't have to remember to parse refs / keys\n * themselves before assembling the literal.\n * - The schema parse provides a single audited validation chokepoint
|
|
1
|
+
{"version":3,"file":"define-website-section.js","sourceRoot":"","sources":["../../../../../src/core/factories/define-website-section.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kEAAkE,CAAC;AAuDlH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAwC;IAExC,MAAM,MAAM,GAAG,8BAA8B,CAAC,KAAK,CAAC;QAClD,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC,CAAC;IACH;;;;OAIG;IACH,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnF,CAAC;AACJ,CAAC;AACD,mEAAmE","sourcesContent":["import type { ComponentType } from 'react';\n\nimport { WebsiteSectionDefinitionSchema } from '../../schemas/sections/website-section-definition.shared.schemas';\nimport type { WebsiteSectionDefinition } from '../../schemas/sections/website-section-definition.shared.schemas';\nimport type { WebsiteSectionCategory } from '../../schemas/sections/website-section-category.shared';\nimport type { WebsiteSectionRef } from '../../schemas/refs/section-ref.schemas';\nimport type { WebsiteLabelKey } from '../../schemas/label-keys/website-label-key.schemas';\nimport type { WebsiteStructuredDataReturn } from '../../schemas/structured-data/website-structured-data.shared.schemas';\n\n/**\n * @wildo_source:part:start saas.website.factories.define-section facet:layer:core facet:family:website\n *\n * Input shape consumed by `defineWebsiteSection<TProps>`. Mirrors\n * `WebsiteSectionDefinition` but keeps `Component` typed against the\n * caller-supplied generic so the precise prop shape survives end-to-end\n * (the consumer's `<HeroSection />` JSX can keep its strongly-typed\n * props after going through the factory).\n *\n * **String inputs vs. branded inputs**: `sectionRef` and\n * `expectedLabelKeys` accept raw strings as well as already-branded\n * values. The factory parses them through the underlying schemas, so\n * either path is safe — accepting strings directly removes the\n * ergonomic drag of forcing every section author to remember to call\n * `WebsiteSectionRefSchema.parse(...)` in their definition.\n */\nexport interface DefineWebsiteSectionInput<TProps> {\n sectionRef: WebsiteSectionRef | string;\n category: WebsiteSectionCategory;\n expectedLabelKeys: readonly (WebsiteLabelKey | string)[];\n Component: ComponentType<TProps>;\n /**\n * See `WebsiteSectionDefinition.getStructuredData?` JSDoc for the\n * full authoring contract. The factory passes the function through\n * unchanged; the framework invokes it at static-build time and\n * forwards the return value to `renderPageStructuredData()`.\n */\n getStructuredData?: () => WebsiteStructuredDataReturn;\n}\n\n/**\n * Return shape of `defineWebsiteSection<TProps>`. Identical to\n * `WebsiteSectionDefinition` except `Component` retains the\n * caller-supplied generic prop shape rather than the schema's\n * lowest-common-denominator `ComponentType<unknown>`.\n *\n * **Why this matters**: a consumer's `pageComponent` JSX composes\n * sections like `<HERO_SECTION.Component {...heroProps} />`. Without\n * preserving `TProps`, the spread would be untyped and a renamed prop\n * would silently miss the type system. With `TProps` preserved, the\n * call site fails to compile the moment the prop contract drifts.\n */\nexport interface TypedWebsiteSectionDefinition<TProps>\n extends Omit<WebsiteSectionDefinition, 'Component' | 'getStructuredData'> {\n Component: ComponentType<TProps>;\n getStructuredData?: () => WebsiteStructuredDataReturn;\n}\n\n/**\n * `defineWebsiteSection<TProps>` — factory that materializes a\n * `WebsiteSectionDefinition` from authored input.\n *\n * **Two responsibilities**, one entry point:\n * 1. Runtime validation — parses the input through\n * `WebsiteSectionDefinitionSchema` so brand checks, regex\n * validations, and array refinements run at module load time\n * (not at render time, not at build-output time).\n * 2. Type preservation — returns an object whose `Component` field\n * keeps the caller-supplied `TProps`, so JSX usage of the\n * returned section retains compile-time prop checking.\n *\n * **Why a factory instead of constructing the literal directly**:\n * - Consumers don't have to remember to parse refs / keys\n * themselves before assembling the literal.\n * - The schema parse provides a single audited validation chokepoint,\n * and the parsed `expectedLabelKeys` are what `wildo website audit`\n * checks every locale pack against, without re-entering the React graph.\n * - The factory is the documented authoring API the\n * `website_factory_authoring` skill targets — keeping the\n * authoring surface narrow lets the framework evolve the\n * internal schema (add fields, refinements) without churning\n * every section definition in every consumer app.\n *\n * @param input section authoring input (see `DefineWebsiteSectionInput`).\n * @returns a `TypedWebsiteSectionDefinition<TProps>` with `Component`\n * preserved at the precise prop type.\n *\n * @example\n * interface HeroProps {\n * headlineKey: WebsiteLabelKey;\n * subheadlineKey: WebsiteLabelKey;\n * }\n * function HeroSection({ headlineKey, subheadlineKey }: HeroProps) {\n * // …\n * }\n * export const HERO_SECTION = defineWebsiteSection<HeroProps>({\n * sectionRef: 'hero',\n * category: WebsiteSectionCategory.HERO,\n * expectedLabelKeys: [\n * 'website.landing.hero.headline',\n * 'website.landing.hero.subheadline',\n * ],\n * Component: HeroSection,\n * });\n */\nexport function defineWebsiteSection<TProps>(\n input: DefineWebsiteSectionInput<TProps>,\n): TypedWebsiteSectionDefinition<TProps> {\n const parsed = WebsiteSectionDefinitionSchema.parse({\n sectionRef: input.sectionRef,\n category: input.category,\n expectedLabelKeys: input.expectedLabelKeys,\n Component: input.Component,\n getStructuredData: input.getStructuredData,\n });\n /**\n * Re-attach `Component` and `getStructuredData` from the original\n * input so the precise generic types survive — `parsed.Component`\n * is `unknown` per the schema's `z.unknown()` contract.\n */\n return {\n sectionRef: parsed.sectionRef,\n category: parsed.category,\n expectedLabelKeys: parsed.expectedLabelKeys,\n Component: input.Component,\n ...(input.getStructuredData ? { getStructuredData: input.getStructuredData } : {}),\n };\n}\n/** @wildo_source:part:end saas.website.factories.define-section */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebsiteDesignTokens.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"useWebsiteDesignTokens.d.ts","sourceRoot":"","sources":["../../../../../src/core/hooks/useWebsiteDesignTokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AAE5G;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D;AACD,0DAA0D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebsiteLabel.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"useWebsiteLabel.d.ts","sourceRoot":"","sources":["../../../../../src/core/hooks/useWebsiteLabel.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,oDAAoD,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA8BxD;AACD,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAajE;AACD,gEAAgE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type WebsiteConsentRecorder } from '../consent/WebsiteConsentContext';
|
|
2
3
|
import { type WebsitePageRef } from '../../schemas/refs/page-ref.schemas';
|
|
3
4
|
/**
|
|
4
5
|
* @wildo_source:part:start saas.website.page-layout.component facet:layer:core facet:family:website
|
|
@@ -28,6 +29,14 @@ import { type WebsitePageRef } from '../../schemas/refs/page-ref.schemas';
|
|
|
28
29
|
* captcha so non-React tooling can detect the configured vendor
|
|
29
30
|
* without reverse-engineering app code.
|
|
30
31
|
*
|
|
32
|
+
* 4. **Provides the visitor's consent state and enforces it** (#534) —
|
|
33
|
+
* mounts `WebsiteConsentProvider`, starts a provider SDK or script only
|
|
34
|
+
* once the purpose it rests on is granted (and stops the SDK when it is
|
|
35
|
+
* withdrawn), and renders the consent panel when the site runs a
|
|
36
|
+
* consent-based provider and the visitor has not decided. Here rather
|
|
37
|
+
* than in each bridge because every page — including every blog post —
|
|
38
|
+
* renders through this layout, so no page can be mounted without it.
|
|
39
|
+
*
|
|
31
40
|
* **Why semantic `<header>` / `<main>` / `<footer>` elements**:
|
|
32
41
|
* marketing-site SEO scoring penalizes pages that ship a single
|
|
33
42
|
* unstructured `<div>` tree. Using semantic landmarks costs nothing
|
|
@@ -73,13 +82,24 @@ export interface WebsitePageLayoutProps {
|
|
|
73
82
|
* vertical-rhythm overrides on long-scroll landing pages.
|
|
74
83
|
*/
|
|
75
84
|
mainClassName?: string;
|
|
85
|
+
/**
|
|
86
|
+
* OPTIONAL anonymous-session client. When supplied, a visitor's consent decision is ALSO recorded
|
|
87
|
+
* server-side against their session, which is what lets it follow them into the account they go on
|
|
88
|
+
* to create (#1258). Pass the SAME instance the page's capture sections use, so one `uuidRef`
|
|
89
|
+
* carries the decision, the lead and the draft note together.
|
|
90
|
+
*
|
|
91
|
+
* Absent keeps today's behaviour exactly: the decision lives in this browser and nowhere else.
|
|
92
|
+
* The engine cannot construct the client here — it needs the application's own
|
|
93
|
+
* `frontendServiceName` — which is why it arrives as a prop rather than off the runtime context.
|
|
94
|
+
*/
|
|
95
|
+
consentRecorder?: WebsiteConsentRecorder;
|
|
76
96
|
/**
|
|
77
97
|
* The page's section composition. Typically a sequence of
|
|
78
98
|
* `<WebsiteSection>` wrappers around concrete section components.
|
|
79
99
|
*/
|
|
80
100
|
children: ReactNode;
|
|
81
101
|
}
|
|
82
|
-
export declare function WebsitePageLayout(
|
|
102
|
+
export declare function WebsitePageLayout(props: WebsitePageLayoutProps): ReactNode;
|
|
83
103
|
export declare namespace WebsitePageLayout {
|
|
84
104
|
var displayName: string;
|
|
85
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsitePageLayout.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"WebsitePageLayout.d.ts","sourceRoot":"","sources":["../../../../../src/core/layouts/WebsitePageLayout.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAcvD,OAAO,EAAgD,KAAK,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG7H,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,qCAAqC,CAAC;AA6F7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,SAAS,CAY1E;yBAZe,iBAAiB;;;AAiLjC,gEAAgE"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { BUILTIN_PROVIDER_CAPABILITY } from '@wildo-ai/saas-models/public-runtime';
|
|
4
|
+
import { consentPurposesInUseByProviders } from '@wildo-ai/external-connectors-public/website';
|
|
4
5
|
import { WebsitePageContextProvider } from '../contexts/WebsitePageContext.js';
|
|
5
6
|
import { useWebsiteProviderScripts, useWebsiteProviderSdks, } from '../external-providers/useWebsiteProviderScripts.js';
|
|
7
|
+
import { WebsiteProviderSdkActivationsContext } from '../external-providers/website-provider-sdk-activations.js';
|
|
6
8
|
import { useWebsiteRuntime } from '../contexts/useWebsiteRuntime.js';
|
|
9
|
+
import { websiteDesignTokenCssVar } from '../../schemas/design-tokens/website-design-tokens.shared.schemas.js';
|
|
7
10
|
import { useWebsiteLabelByKey } from '../hooks/useWebsiteLabel.js';
|
|
11
|
+
import { WebsiteConsentProvider, WebsiteConsentStatus } from '../consent/WebsiteConsentContext.js';
|
|
12
|
+
import { useWebsiteConsent } from '../consent/useWebsiteConsent.js';
|
|
13
|
+
import { WebsiteConsentBanner, WebsiteConsentSettingsButton } from '../consent/WebsiteConsentBanner.js';
|
|
8
14
|
import { WebsitePageRefSchema, } from '../../schemas/refs/page-ref.schemas.js';
|
|
9
15
|
/**
|
|
10
16
|
* Stable DOM id stamped on the `<main>` element so the framework's
|
|
@@ -86,16 +92,23 @@ const SKIP_LINK_FOCUS_CSS = `
|
|
|
86
92
|
overflow: visible !important;
|
|
87
93
|
clip: auto !important;
|
|
88
94
|
white-space: normal !important;
|
|
89
|
-
background:
|
|
90
|
-
color:
|
|
91
|
-
border: 2px solid
|
|
92
|
-
border-radius:
|
|
95
|
+
background: ${websiteDesignTokenCssVar('colors', 'background', '#fff')} !important;
|
|
96
|
+
color: ${websiteDesignTokenCssVar('colors', 'foreground', '#000')} !important;
|
|
97
|
+
border: 2px solid ${websiteDesignTokenCssVar('colors', 'primary', '#000')} !important;
|
|
98
|
+
border-radius: ${websiteDesignTokenCssVar('radii', 'md', '0.375rem')} !important;
|
|
93
99
|
z-index: 9999 !important;
|
|
94
100
|
text-decoration: none !important;
|
|
95
101
|
}
|
|
96
102
|
`.trim();
|
|
97
|
-
export function WebsitePageLayout(
|
|
103
|
+
export function WebsitePageLayout(props) {
|
|
98
104
|
const runtime = useWebsiteRuntime();
|
|
105
|
+
// Derived from the LIVE providers, so the panel asks about exactly what this site processes.
|
|
106
|
+
const purposesInUse = useMemo(() => consentPurposesInUseByProviders(runtime.frontendProviderRegistry?.modules.values()), [runtime.frontendProviderRegistry]);
|
|
107
|
+
return (_jsx(WebsiteConsentProvider, { purposesInUse: purposesInUse, recorder: props.consentRecorder, children: _jsx(WebsitePageLayoutContent, { ...props }) }));
|
|
108
|
+
}
|
|
109
|
+
function WebsitePageLayoutContent({ pageRef, header, footer, className, mainClassName, children, }) {
|
|
110
|
+
const runtime = useWebsiteRuntime();
|
|
111
|
+
const consent = useWebsiteConsent();
|
|
99
112
|
/**
|
|
100
113
|
* Defensive parse: callers should pass a `WebsitePageManifest.ref`
|
|
101
114
|
* (already branded), but accepting raw strings + parsing here means
|
|
@@ -135,8 +148,12 @@ export function WebsitePageLayout({ pageRef, header, footer, className, mainClas
|
|
|
135
148
|
// resolved provider refs and stamped them into the attributes below and
|
|
136
149
|
// stopped there — a provider could be declared, enabled and hydrated without
|
|
137
150
|
// anything of it ever running.
|
|
138
|
-
|
|
139
|
-
|
|
151
|
+
//
|
|
152
|
+
// Consent-based providers start only once their purpose is granted (#534). Before the stored decision is
|
|
153
|
+
// read, nothing is granted — the static HTML and the first render start nothing optional.
|
|
154
|
+
useWebsiteProviderScripts(runtime.frontendProviderRegistry, runtime.providerComponentRegistry);
|
|
155
|
+
// The running SDKs are published to the page (#1735): the contact form asks the consented captcha vendor for a token.
|
|
156
|
+
const runningProviderSdks = useWebsiteProviderSdks(runtime.frontendProviderRegistry, consent.grantedPurposes);
|
|
140
157
|
const providerRootAttributes = useMemo(() => {
|
|
141
158
|
const attrs = {};
|
|
142
159
|
const productAnalyticsProviderRef = runtime.frontendProviderRegistry
|
|
@@ -171,7 +188,21 @@ export function WebsitePageLayout({ pageRef, header, footer, className, mainClas
|
|
|
171
188
|
* ship an English skip link to a non-EN visitor.
|
|
172
189
|
*/
|
|
173
190
|
const skipLinkLabel = useWebsiteLabelByKey(runtime.skipToMainContentLabelKey);
|
|
174
|
-
return (_jsx(WebsitePageContextProvider, { value: pageContextValue, children: _jsxs("div", { "data-website-page-ref": safePageRef, className: className, ...providerRootAttributes, children: [_jsx("style", { children: SKIP_LINK_FOCUS_CSS }), _jsx("a", { href: `#${MAIN_CONTENT_DOM_ID}`, "data-website-skip-link": "", style: SKIP_LINK_HIDDEN_STYLE, children: skipLinkLabel }), resolvedHeader !== null ? _jsx("header", { children: resolvedHeader }) : null, _jsx("main", { id: MAIN_CONTENT_DOM_ID, className: mainClassName, tabIndex: -1, children: children }), resolvedFooter !== null ? _jsx("footer", { children: resolvedFooter }) : null] }) }));
|
|
191
|
+
return (_jsx(WebsitePageContextProvider, { value: pageContextValue, children: _jsx(WebsiteProviderSdkActivationsContext.Provider, { value: runningProviderSdks, children: _jsxs("div", { "data-website-page-ref": safePageRef, className: className, ...providerRootAttributes, children: [_jsx("style", { children: SKIP_LINK_FOCUS_CSS }), _jsx("a", { href: `#${MAIN_CONTENT_DOM_ID}`, "data-website-skip-link": "", style: SKIP_LINK_HIDDEN_STYLE, children: skipLinkLabel }), resolvedHeader !== null ? _jsx("header", { children: resolvedHeader }) : null, _jsx("main", { id: MAIN_CONTENT_DOM_ID, className: mainClassName, tabIndex: -1, children: children }), resolvedFooter !== null ? _jsx("footer", { children: resolvedFooter }) : null, renderConsentSurface(consent, runtime.consentBannerComponent)] }) }) }));
|
|
175
192
|
}
|
|
176
193
|
WebsitePageLayout.displayName = 'WebsitePageLayout';
|
|
194
|
+
/**
|
|
195
|
+
* The panel while a decision is owed (or re-opened), the reopen button once one is made, and nothing at
|
|
196
|
+
* all on a site whose live providers rest on no consent. Nothing renders before the stored decision is
|
|
197
|
+
* read, so a visitor who already decided never sees the panel flash.
|
|
198
|
+
*/
|
|
199
|
+
function renderConsentSurface(consent, BannerOverride) {
|
|
200
|
+
if (!consent.isResolved || consent.purposesInUse.length === 0)
|
|
201
|
+
return null;
|
|
202
|
+
if (consent.status === WebsiteConsentStatus.UNDECIDED || consent.isSettingsOpen) {
|
|
203
|
+
const Banner = BannerOverride ?? WebsiteConsentBanner;
|
|
204
|
+
return _jsx(Banner, {});
|
|
205
|
+
}
|
|
206
|
+
return (_jsx("div", { "data-website-consent-settings": "", children: _jsx(WebsiteConsentSettingsButton, {}) }));
|
|
207
|
+
}
|
|
177
208
|
//# sourceMappingURL=WebsitePageLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsitePageLayout.js","sourceRoot":"","sources":["../../../../src/core/layouts/WebsitePageLayout.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,oBAAoB,GAErB,MAAM,qCAAqC,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,mBAAmB,GAAG,cAAc,CAAC;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AAI,kBAAkB,EAAE,CAAC;YACvB,KAAK,CAAC,mCAAmC,CAAC,GAAG,kBAAkB,CAAC;QAClE,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAEvC;;;;;;;;;;OAUG;IACH,MAAM,aAAa,GAAG,oBAAoB,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAE9E,OAAO,CACL,KAAC,0BAA0B,IAAC,KAAK,EAAE,gBAAgB,YACjD,wCACyB,WAAgC,EACvD,SAAS,EAAE,SAAS,KAChB,sBAAsB,aAS1B,0BAAQ,mBAAmB,GAAS,EACpC,YACE,IAAI,EAAE,IAAI,mBAAmB,EAAE,4BACR,EAAE,EACzB,KAAK,EAAE,sBAAsB,YAE5B,aAAa,GACZ,EACH,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,2BAAS,cAAc,GAAU,CAAC,CAAC,CAAC,IAAI,EACnE,eAAM,EAAE,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,YAClE,QAAQ,GACJ,EACN,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,2BAAS,cAAc,GAAU,CAAC,CAAC,CAAC,IAAI,IAC/D,GACqB,CAC9B,CAAC;AACJ,CAAC;AACD,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC","sourcesContent":["import React, { useMemo, type ReactNode } from 'react';\nimport { BUILTIN_PROVIDER_CAPABILITY } from '@wildo-ai/saas-models/public-runtime';\n\nimport { WebsitePageContextProvider } from '../contexts/WebsitePageContext';\nimport {\n useWebsiteProviderScripts,\n useWebsiteProviderSdks,\n} from '../external-providers/useWebsiteProviderScripts';\nimport type { WebsitePageContextValue } from '../contexts/WebsitePageContext';\nimport { useWebsiteRuntime } from '../contexts/useWebsiteRuntime';\nimport { useWebsiteLabelByKey } from '../hooks/useWebsiteLabel';\nimport {\n WebsitePageRefSchema,\n type WebsitePageRef,\n} from '../../schemas/refs/page-ref.schemas';\n\n/**\n * Stable DOM id stamped on the `<main>` element so the framework's\n * skip-link `<a href=\"#main-content\">` can move keyboard focus past\n * the chrome on every page (Phase 6 audit fix M-α). Co-located here\n * (rather than exposed as a prop) because:\n * - The skip-link target is a framework concern — exposing it as a\n * consumer-tunable id would invite drift between the link's href\n * and the main element's id.\n * - Screen readers announce the heading inside `<main id=\"...\">` on\n * focus; a stable, framework-owned id keeps that affordance\n * deterministic across every page on every site.\n */\nconst MAIN_CONTENT_DOM_ID = 'main-content';\n\n/**\n * Inline style for the skip link's \"visually hidden by default,\n * visible on focus\" pattern. Inlined (NOT shipped as a CSS class)\n * because:\n * - The framework intentionally avoids shipping any CSS file the\n * consumer must opt in to — the only stylesheet emitted is the\n * `:root { --website-*: … }` design-token block, and the rest of\n * the styling surface lives in consumer code (see Phase 5\n * `renderWebsiteDesignTokensCss`). Inlining keeps the skip link\n * self-sufficient and side-effect-free.\n * - The \"skip-link\" pattern is a small, well-known a11y idiom; the\n * handful of style declarations here do not benefit from being\n * reorganized into a class with a custom-property hook.\n *\n * The \"focused\" variant uses BOTH `:focus` AND `:focus-visible`\n * pseudo-classes via a scoped `<style>` tag inside the layout output.\n * We cannot apply pseudo-class styles via a `style` attribute, but\n * emitting a tiny scoped block once at the layout root is safe (one\n * block per page render, ~120 bytes) and avoids importing a CSS-in-JS\n * runtime.\n *\n * **Why both selectors and not just `:focus-visible`** (Phase 6 fourth\n * audit fix M-Η): `:focus-visible` is the modern UA-heuristic-driven\n * selector that hides focus rings on mouse clicks, and it is the\n * RIGHT default for buttons / links. For a skip link though we WANT\n * the affordance to appear on EVERY focus event — the link is\n * invisible by default and a keyboard-only user (the only intended\n * audience) is the only one who can reach it. Older browsers that\n * predate `:focus-visible` (and Safari < 15.4 with the feature\n * disabled) would skip the rule entirely with a `:focus-visible`-only\n * declaration, leaving the keyboard user looking at an apparently\n * empty page when they pressed Tab. Pairing `:focus, :focus-visible`\n * is the documented WCAG 2.1 fallback pattern.\n */\nconst SKIP_LINK_HIDDEN_STYLE: React.CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\n/**\n * Single scoped style block for the skip link's `:focus-visible`\n * affordance. Targets the `data-website-skip-link` attribute (NOT a\n * class) so consumer Tailwind / utility classes cannot accidentally\n * shadow it. Stays trivially small to keep payload under the\n * \"framework rendering\" implicit budget.\n */\nconst SKIP_LINK_FOCUS_CSS = `\n[data-website-skip-link]:focus,\n[data-website-skip-link]:focus-visible {\n position: fixed !important;\n top: 0.5rem !important;\n left: 0.5rem !important;\n width: auto !important;\n height: auto !important;\n padding: 0.75rem 1rem !important;\n margin: 0 !important;\n overflow: visible !important;\n clip: auto !important;\n white-space: normal !important;\n background: var(--website-colors-background, #fff) !important;\n color: var(--website-colors-foreground, #000) !important;\n border: 2px solid var(--website-colors-primary, #000) !important;\n border-radius: var(--website-radii-md, 0.375rem) !important;\n z-index: 9999 !important;\n text-decoration: none !important;\n}\n`.trim();\n\n/**\n * @wildo_source:part:start saas.website.page-layout.component facet:layer:core facet:family:website\n *\n * `WebsitePageLayout` — the per-page structural primitive.\n *\n * **Three responsibilities** (each carrying its own semantic weight):\n *\n * 1. **Provides `WebsitePageContext`** — registers the active page\n * ref so child sections (`<WebsiteSection>`) and label hooks\n * (`useWebsiteLabel`) can derive label keys without re-typing\n * the page ref at every leaf.\n * 2. **Renders the site-wide chrome** — pulls\n * `headerComponent` and `footerComponent` from the runtime\n * navigation config and wraps the page's main content in the\n * site's standard header/main/footer scaffold. Per-page\n * overrides (`header={…}` / `footer={…}` props) take precedence\n * over the runtime defaults so individual pages can opt into a\n * custom chrome (eg. a campaign landing page running with\n * header-only minimal chrome).\n * 3. **Stamps DOM landmarks** — emits `data-website-page-ref` on\n * the layout root for analytics / SEO crawlers / overlay\n * tooling that needs to identify the active page from the DOM\n * without booting React. When the website facet hydrates\n * frontend-provider bootstraps, the same root also carries the\n * active public provider refs for analytics / browser-monitoring /\n * captcha so non-React tooling can detect the configured vendor\n * without reverse-engineering app code.\n *\n * **Why semantic `<header>` / `<main>` / `<footer>` elements**:\n * marketing-site SEO scoring penalizes pages that ship a single\n * unstructured `<div>` tree. Using semantic landmarks costs nothing\n * and improves crawler accessibility AND screen-reader\n * navigability — both are first-class concerns for a public\n * marketing surface.\n *\n * **Why this lives in `core/`** (not `components/`): the layout is\n * structural framework machinery (it owns the page-context\n * provisioning + the navigation slot resolution), not a styled\n * primitive. Designers override `header` / `footer` via runtime\n * config or per-page props, NOT by replacing this component.\n */\nexport interface WebsitePageLayoutProps {\n /**\n * The active page's ref. Accepts either an already-branded\n * `WebsitePageRef` or a raw string — the layout parses through\n * `WebsitePageRefSchema` so a malformed ref fails loud at render.\n *\n * Typically sourced from the page's `WebsitePageManifest.ref`\n * (eg. `<WebsitePageLayout pageRef={LANDING_PAGE_MANIFEST.ref}>`).\n */\n pageRef: WebsitePageRef | string;\n /**\n * Per-page header override. When supplied, takes precedence over\n * `WebsiteRuntimeContext.designTokens` navigation config's\n * `headerComponent`. Pass `null` explicitly to suppress the header\n * entirely (campaign landing pages without site-wide nav).\n */\n header?: ReactNode | null;\n /**\n * Per-page footer override. Same semantics as `header`.\n */\n footer?: ReactNode | null;\n /**\n * Optional className applied to the root `<div data-website-page-ref=\"…\">`\n * wrapper. Use for page-level layout tweaks (eg. `min-h-screen` on\n * landing pages).\n */\n className?: string;\n /**\n * Optional className applied to the inner `<main>` element. Use for\n * vertical-rhythm overrides on long-scroll landing pages.\n */\n mainClassName?: string;\n /**\n * The page's section composition. Typically a sequence of\n * `<WebsiteSection>` wrappers around concrete section components.\n */\n children: ReactNode;\n}\n\nexport function WebsitePageLayout({\n pageRef,\n header,\n footer,\n className,\n mainClassName,\n children,\n}: WebsitePageLayoutProps): ReactNode {\n const runtime = useWebsiteRuntime();\n\n /**\n * Defensive parse: callers should pass a `WebsitePageManifest.ref`\n * (already branded), but accepting raw strings + parsing here means\n * a hand-typed call site can't smuggle a malformed ref into the\n * label-key derivation chain.\n */\n const safePageRef = useMemo<WebsitePageRef>(\n () => WebsitePageRefSchema.parse(pageRef),\n [pageRef],\n );\n\n const pageContextValue = useMemo<WebsitePageContextValue>(\n () => ({ pageRef: safePageRef }),\n [safePageRef],\n );\n\n /**\n * Header resolution rules:\n * - `header === null` => explicit suppression\n * - `header !== undefined` => per-page override (any ReactNode)\n * - `header === undefined` => fall back to the runtime navigation\n * config's `headerComponent`\n *\n * The fallback is the common path: every page renders the same\n * site-wide chrome. The override path is the escape hatch (campaign\n * landing pages with custom header layouts).\n */\n const resolvedHeader = useMemo<ReactNode>(() => {\n if (header === null) return null;\n if (header !== undefined) return header;\n const HeaderComponent = runtime.navigation.headerComponent;\n return <HeaderComponent />;\n }, [header, runtime.navigation.headerComponent]);\n\n const resolvedFooter = useMemo<ReactNode>(() => {\n if (footer === null) return null;\n if (footer !== undefined) return footer;\n const FooterComponent = runtime.navigation.footerComponent;\n return <FooterComponent />;\n }, [footer, runtime.navigation.footerComponent]);\n\n // Load whatever the live providers declared. Until this landed, the surface\n // resolved provider refs and stamped them into the attributes below and\n // stopped there — a provider could be declared, enabled and hydrated without\n // anything of it ever running.\n useWebsiteProviderScripts(runtime.frontendProviderRegistry);\n useWebsiteProviderSdks(runtime.frontendProviderRegistry);\n\n const providerRootAttributes = useMemo<Record<string, string>>(() => {\n const attrs: Record<string, string> = {};\n const productAnalyticsProviderRef = runtime.frontendProviderRegistry\n ?.findProviderByProviderCapability(\n BUILTIN_PROVIDER_CAPABILITY.FRONTEND_PRODUCT_ANALYTICS,\n )\n ?.metadata.ref;\n const errorMonitoringProviderRef = runtime.frontendProviderRegistry\n ?.findProviderByProviderCapability(\n BUILTIN_PROVIDER_CAPABILITY.FRONTEND_ERROR_MONITORING,\n )\n ?.metadata.ref;\n const captchaProviderRef = runtime.frontendProviderRegistry\n ?.findProviderByProviderCapability(\n BUILTIN_PROVIDER_CAPABILITY.FRONTEND_CAPTCHA,\n )\n ?.metadata.ref;\n\n if (productAnalyticsProviderRef) {\n attrs['data-website-product-analytics-provider-ref'] = productAnalyticsProviderRef;\n }\n if (errorMonitoringProviderRef) {\n attrs['data-website-error-monitoring-provider-ref'] = errorMonitoringProviderRef;\n }\n if (captchaProviderRef) {\n attrs['data-website-captcha-provider-ref'] = captchaProviderRef;\n }\n\n return attrs;\n }, [runtime.frontendProviderRegistry]);\n\n /**\n * Resolved skip-link label. Reads through the runtime label pack\n * via the standard `useWebsiteLabelByKey` hook so a missing\n * translation surfaces the same diagnostic shape as any other\n * missing chrome label. The framework guarantees the key reaches\n * the bridge (see `pickLabelsForPage`) and the consumer's\n * label-pack validator (see `composeEffectiveChromeLabelKeys` in\n * `label-pack-loader.ts`) ensures it is present in every locale\n * pack — there is therefore no silent-fallback path that would\n * ship an English skip link to a non-EN visitor.\n */\n const skipLinkLabel = useWebsiteLabelByKey(runtime.skipToMainContentLabelKey);\n\n return (\n <WebsitePageContextProvider value={pageContextValue}>\n <div\n data-website-page-ref={safePageRef as unknown as string}\n className={className}\n {...providerRootAttributes}\n >\n {/*\n * Skip link rendered as the FIRST focusable element on the\n * page so a keyboard / AT user can bypass the chrome on every\n * navigation (WCAG 2.1 §2.4.1 \"Bypass Blocks\", Level A).\n * Visually hidden by default; revealed on focus via the\n * scoped `<style>` block below.\n */}\n <style>{SKIP_LINK_FOCUS_CSS}</style>\n <a\n href={`#${MAIN_CONTENT_DOM_ID}`}\n data-website-skip-link=\"\"\n style={SKIP_LINK_HIDDEN_STYLE}\n >\n {skipLinkLabel}\n </a>\n {resolvedHeader !== null ? <header>{resolvedHeader}</header> : null}\n <main id={MAIN_CONTENT_DOM_ID} className={mainClassName} tabIndex={-1}>\n {children}\n </main>\n {resolvedFooter !== null ? <footer>{resolvedFooter}</footer> : null}\n </div>\n </WebsitePageContextProvider>\n );\n}\nWebsitePageLayout.displayName = 'WebsitePageLayout';\n/** @wildo_source:part:end saas.website.page-layout.component */\n"]}
|
|
1
|
+
{"version":3,"file":"WebsitePageLayout.js","sourceRoot":"","sources":["../../../../../src/core/layouts/WebsitePageLayout.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,+BAA+B,EAAE,MAAM,8CAA8C,CAAC;AAE/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,oCAAoC,EAAE,MAAM,wDAAwD,CAAC;AAE9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kEAAkE,CAAC;AAC5G,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AAC7H,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AACrG,OAAO,EACL,oBAAoB,GAErB,MAAM,qCAAqC,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,sBAAsB,GAAwB;IAClD,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,QAAQ;IAClB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,EAAE,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,YAClE,QAAQ,GACJ,EACN,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,2BAAS,cAAc,GAAU,CAAC,CAAC,CAAC,IAAI,EAClE,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,IAC1D,GAC0C,GACrB,CAC9B,CAAC;AACJ,CAAC;AACD,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,SAAS,oBAAoB,CAC3B,OAA6C,EAC7C,cAA+C;IAE/C,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,IAAI,OAAO,CAAC,MAAM,KAAK,oBAAoB,CAAC,SAAS,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAChF,MAAM,MAAM,GAAG,cAAc,IAAI,oBAAoB,CAAC;QACtD,OAAO,KAAC,MAAM,KAAG,CAAC;IACpB,CAAC;IACD,OAAO,CACL,+CAAmC,EAAE,YACnC,KAAC,4BAA4B,KAAG,GAC5B,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React, { useMemo, type ReactNode } from 'react';\nimport { BUILTIN_PROVIDER_CAPABILITY } from '@wildo-ai/saas-models/public-runtime';\nimport { consentPurposesInUseByProviders } from '@wildo-ai/external-connectors-public/website';\n\nimport { WebsitePageContextProvider } from '../contexts/WebsitePageContext';\nimport {\n useWebsiteProviderScripts,\n useWebsiteProviderSdks,\n} from '../external-providers/useWebsiteProviderScripts';\nimport { WebsiteProviderSdkActivationsContext } from '../external-providers/website-provider-sdk-activations';\nimport type { WebsitePageContextValue } from '../contexts/WebsitePageContext';\nimport { useWebsiteRuntime } from '../contexts/useWebsiteRuntime';\nimport { websiteDesignTokenCssVar } from '../../schemas/design-tokens/website-design-tokens.shared.schemas';\nimport { useWebsiteLabelByKey } from '../hooks/useWebsiteLabel';\nimport { WebsiteConsentProvider, WebsiteConsentStatus, type WebsiteConsentRecorder } from '../consent/WebsiteConsentContext';\nimport { useWebsiteConsent } from '../consent/useWebsiteConsent';\nimport { WebsiteConsentBanner, WebsiteConsentSettingsButton } from '../consent/WebsiteConsentBanner';\nimport {\n WebsitePageRefSchema,\n type WebsitePageRef,\n} from '../../schemas/refs/page-ref.schemas';\n\n/**\n * Stable DOM id stamped on the `<main>` element so the framework's\n * skip-link `<a href=\"#main-content\">` can move keyboard focus past\n * the chrome on every page (Phase 6 audit fix M-α). Co-located here\n * (rather than exposed as a prop) because:\n * - The skip-link target is a framework concern — exposing it as a\n * consumer-tunable id would invite drift between the link's href\n * and the main element's id.\n * - Screen readers announce the heading inside `<main id=\"...\">` on\n * focus; a stable, framework-owned id keeps that affordance\n * deterministic across every page on every site.\n */\nconst MAIN_CONTENT_DOM_ID = 'main-content';\n\n/**\n * Inline style for the skip link's \"visually hidden by default,\n * visible on focus\" pattern. Inlined (NOT shipped as a CSS class)\n * because:\n * - The framework intentionally avoids shipping any CSS file the\n * consumer must opt in to — the only stylesheet emitted is the\n * `:root { --website-*: … }` design-token block, and the rest of\n * the styling surface lives in consumer code (see Phase 5\n * `renderWebsiteDesignTokensCss`). Inlining keeps the skip link\n * self-sufficient and side-effect-free.\n * - The \"skip-link\" pattern is a small, well-known a11y idiom; the\n * handful of style declarations here do not benefit from being\n * reorganized into a class with a custom-property hook.\n *\n * The \"focused\" variant uses BOTH `:focus` AND `:focus-visible`\n * pseudo-classes via a scoped `<style>` tag inside the layout output.\n * We cannot apply pseudo-class styles via a `style` attribute, but\n * emitting a tiny scoped block once at the layout root is safe (one\n * block per page render, ~120 bytes) and avoids importing a CSS-in-JS\n * runtime.\n *\n * **Why both selectors and not just `:focus-visible`** (Phase 6 fourth\n * audit fix M-Η): `:focus-visible` is the modern UA-heuristic-driven\n * selector that hides focus rings on mouse clicks, and it is the\n * RIGHT default for buttons / links. For a skip link though we WANT\n * the affordance to appear on EVERY focus event — the link is\n * invisible by default and a keyboard-only user (the only intended\n * audience) is the only one who can reach it. Older browsers that\n * predate `:focus-visible` (and Safari < 15.4 with the feature\n * disabled) would skip the rule entirely with a `:focus-visible`-only\n * declaration, leaving the keyboard user looking at an apparently\n * empty page when they pressed Tab. Pairing `:focus, :focus-visible`\n * is the documented WCAG 2.1 fallback pattern.\n */\nconst SKIP_LINK_HIDDEN_STYLE: React.CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\n/**\n * Single scoped style block for the skip link's `:focus-visible`\n * affordance. Targets the `data-website-skip-link` attribute (NOT a\n * class) so consumer Tailwind / utility classes cannot accidentally\n * shadow it. Stays trivially small to keep payload under the\n * \"framework rendering\" implicit budget.\n */\nconst SKIP_LINK_FOCUS_CSS = `\n[data-website-skip-link]:focus,\n[data-website-skip-link]:focus-visible {\n position: fixed !important;\n top: 0.5rem !important;\n left: 0.5rem !important;\n width: auto !important;\n height: auto !important;\n padding: 0.75rem 1rem !important;\n margin: 0 !important;\n overflow: visible !important;\n clip: auto !important;\n white-space: normal !important;\n background: ${websiteDesignTokenCssVar('colors', 'background', '#fff')} !important;\n color: ${websiteDesignTokenCssVar('colors', 'foreground', '#000')} !important;\n border: 2px solid ${websiteDesignTokenCssVar('colors', 'primary', '#000')} !important;\n border-radius: ${websiteDesignTokenCssVar('radii', 'md', '0.375rem')} !important;\n z-index: 9999 !important;\n text-decoration: none !important;\n}\n`.trim();\n\n/**\n * @wildo_source:part:start saas.website.page-layout.component facet:layer:core facet:family:website\n *\n * `WebsitePageLayout` — the per-page structural primitive.\n *\n * **Three responsibilities** (each carrying its own semantic weight):\n *\n * 1. **Provides `WebsitePageContext`** — registers the active page\n * ref so child sections (`<WebsiteSection>`) and label hooks\n * (`useWebsiteLabel`) can derive label keys without re-typing\n * the page ref at every leaf.\n * 2. **Renders the site-wide chrome** — pulls\n * `headerComponent` and `footerComponent` from the runtime\n * navigation config and wraps the page's main content in the\n * site's standard header/main/footer scaffold. Per-page\n * overrides (`header={…}` / `footer={…}` props) take precedence\n * over the runtime defaults so individual pages can opt into a\n * custom chrome (eg. a campaign landing page running with\n * header-only minimal chrome).\n * 3. **Stamps DOM landmarks** — emits `data-website-page-ref` on\n * the layout root for analytics / SEO crawlers / overlay\n * tooling that needs to identify the active page from the DOM\n * without booting React. When the website facet hydrates\n * frontend-provider bootstraps, the same root also carries the\n * active public provider refs for analytics / browser-monitoring /\n * captcha so non-React tooling can detect the configured vendor\n * without reverse-engineering app code.\n *\n * 4. **Provides the visitor's consent state and enforces it** (#534) —\n * mounts `WebsiteConsentProvider`, starts a provider SDK or script only\n * once the purpose it rests on is granted (and stops the SDK when it is\n * withdrawn), and renders the consent panel when the site runs a\n * consent-based provider and the visitor has not decided. Here rather\n * than in each bridge because every page — including every blog post —\n * renders through this layout, so no page can be mounted without it.\n *\n * **Why semantic `<header>` / `<main>` / `<footer>` elements**:\n * marketing-site SEO scoring penalizes pages that ship a single\n * unstructured `<div>` tree. Using semantic landmarks costs nothing\n * and improves crawler accessibility AND screen-reader\n * navigability — both are first-class concerns for a public\n * marketing surface.\n *\n * **Why this lives in `core/`** (not `components/`): the layout is\n * structural framework machinery (it owns the page-context\n * provisioning + the navigation slot resolution), not a styled\n * primitive. Designers override `header` / `footer` via runtime\n * config or per-page props, NOT by replacing this component.\n */\nexport interface WebsitePageLayoutProps {\n /**\n * The active page's ref. Accepts either an already-branded\n * `WebsitePageRef` or a raw string — the layout parses through\n * `WebsitePageRefSchema` so a malformed ref fails loud at render.\n *\n * Typically sourced from the page's `WebsitePageManifest.ref`\n * (eg. `<WebsitePageLayout pageRef={LANDING_PAGE_MANIFEST.ref}>`).\n */\n pageRef: WebsitePageRef | string;\n /**\n * Per-page header override. When supplied, takes precedence over\n * `WebsiteRuntimeContext.designTokens` navigation config's\n * `headerComponent`. Pass `null` explicitly to suppress the header\n * entirely (campaign landing pages without site-wide nav).\n */\n header?: ReactNode | null;\n /**\n * Per-page footer override. Same semantics as `header`.\n */\n footer?: ReactNode | null;\n /**\n * Optional className applied to the root `<div data-website-page-ref=\"…\">`\n * wrapper. Use for page-level layout tweaks (eg. `min-h-screen` on\n * landing pages).\n */\n className?: string;\n /**\n * Optional className applied to the inner `<main>` element. Use for\n * vertical-rhythm overrides on long-scroll landing pages.\n */\n mainClassName?: string;\n /**\n * OPTIONAL anonymous-session client. When supplied, a visitor's consent decision is ALSO recorded\n * server-side against their session, which is what lets it follow them into the account they go on\n * to create (#1258). Pass the SAME instance the page's capture sections use, so one `uuidRef`\n * carries the decision, the lead and the draft note together.\n *\n * Absent keeps today's behaviour exactly: the decision lives in this browser and nowhere else.\n * The engine cannot construct the client here — it needs the application's own\n * `frontendServiceName` — which is why it arrives as a prop rather than off the runtime context.\n */\n consentRecorder?: WebsiteConsentRecorder;\n /**\n * The page's section composition. Typically a sequence of\n * `<WebsiteSection>` wrappers around concrete section components.\n */\n children: ReactNode;\n}\n\nexport function WebsitePageLayout(props: WebsitePageLayoutProps): ReactNode {\n const runtime = useWebsiteRuntime();\n // Derived from the LIVE providers, so the panel asks about exactly what this site processes.\n const purposesInUse = useMemo(\n () => consentPurposesInUseByProviders(runtime.frontendProviderRegistry?.modules.values()),\n [runtime.frontendProviderRegistry],\n );\n return (\n <WebsiteConsentProvider purposesInUse={purposesInUse} recorder={props.consentRecorder}>\n <WebsitePageLayoutContent {...props} />\n </WebsiteConsentProvider>\n );\n}\n\nfunction WebsitePageLayoutContent({\n pageRef,\n header,\n footer,\n className,\n mainClassName,\n children,\n}: WebsitePageLayoutProps): ReactNode {\n const runtime = useWebsiteRuntime();\n const consent = useWebsiteConsent();\n\n /**\n * Defensive parse: callers should pass a `WebsitePageManifest.ref`\n * (already branded), but accepting raw strings + parsing here means\n * a hand-typed call site can't smuggle a malformed ref into the\n * label-key derivation chain.\n */\n const safePageRef = useMemo<WebsitePageRef>(\n () => WebsitePageRefSchema.parse(pageRef),\n [pageRef],\n );\n\n const pageContextValue = useMemo<WebsitePageContextValue>(\n () => ({ pageRef: safePageRef }),\n [safePageRef],\n );\n\n /**\n * Header resolution rules:\n * - `header === null` => explicit suppression\n * - `header !== undefined` => per-page override (any ReactNode)\n * - `header === undefined` => fall back to the runtime navigation\n * config's `headerComponent`\n *\n * The fallback is the common path: every page renders the same\n * site-wide chrome. The override path is the escape hatch (campaign\n * landing pages with custom header layouts).\n */\n const resolvedHeader = useMemo<ReactNode>(() => {\n if (header === null) return null;\n if (header !== undefined) return header;\n const HeaderComponent = runtime.navigation.headerComponent;\n return <HeaderComponent />;\n }, [header, runtime.navigation.headerComponent]);\n\n const resolvedFooter = useMemo<ReactNode>(() => {\n if (footer === null) return null;\n if (footer !== undefined) return footer;\n const FooterComponent = runtime.navigation.footerComponent;\n return <FooterComponent />;\n }, [footer, runtime.navigation.footerComponent]);\n\n // Load whatever the live providers declared. Until this landed, the surface\n // resolved provider refs and stamped them into the attributes below and\n // stopped there — a provider could be declared, enabled and hydrated without\n // anything of it ever running.\n //\n // Consent-based providers start only once their purpose is granted (#534). Before the stored decision is\n // read, nothing is granted — the static HTML and the first render start nothing optional.\n useWebsiteProviderScripts(runtime.frontendProviderRegistry, runtime.providerComponentRegistry);\n // The running SDKs are published to the page (#1735): the contact form asks the consented captcha vendor for a token.\n const runningProviderSdks = useWebsiteProviderSdks(runtime.frontendProviderRegistry, consent.grantedPurposes);\n\n const providerRootAttributes = useMemo<Record<string, string>>(() => {\n const attrs: Record<string, string> = {};\n const productAnalyticsProviderRef = runtime.frontendProviderRegistry\n ?.findProviderByProviderCapability(\n BUILTIN_PROVIDER_CAPABILITY.FRONTEND_PRODUCT_ANALYTICS,\n )\n ?.metadata.ref;\n const errorMonitoringProviderRef = runtime.frontendProviderRegistry\n ?.findProviderByProviderCapability(\n BUILTIN_PROVIDER_CAPABILITY.FRONTEND_ERROR_MONITORING,\n )\n ?.metadata.ref;\n const captchaProviderRef = runtime.frontendProviderRegistry\n ?.findProviderByProviderCapability(\n BUILTIN_PROVIDER_CAPABILITY.FRONTEND_CAPTCHA,\n )\n ?.metadata.ref;\n\n if (productAnalyticsProviderRef) {\n attrs['data-website-product-analytics-provider-ref'] = productAnalyticsProviderRef;\n }\n if (errorMonitoringProviderRef) {\n attrs['data-website-error-monitoring-provider-ref'] = errorMonitoringProviderRef;\n }\n if (captchaProviderRef) {\n attrs['data-website-captcha-provider-ref'] = captchaProviderRef;\n }\n\n return attrs;\n }, [runtime.frontendProviderRegistry]);\n\n /**\n * Resolved skip-link label. Reads through the runtime label pack\n * via the standard `useWebsiteLabelByKey` hook so a missing\n * translation surfaces the same diagnostic shape as any other\n * missing chrome label. The framework guarantees the key reaches\n * the bridge (see `pickLabelsForPage`) and the consumer's\n * label-pack validator (see `composeEffectiveChromeLabelKeys` in\n * `label-pack-loader.ts`) ensures it is present in every locale\n * pack — there is therefore no silent-fallback path that would\n * ship an English skip link to a non-EN visitor.\n */\n const skipLinkLabel = useWebsiteLabelByKey(runtime.skipToMainContentLabelKey);\n\n return (\n <WebsitePageContextProvider value={pageContextValue}>\n <WebsiteProviderSdkActivationsContext.Provider value={runningProviderSdks}>\n <div\n data-website-page-ref={safePageRef as unknown as string}\n className={className}\n {...providerRootAttributes}\n >\n {/*\n * Skip link rendered as the FIRST focusable element on the\n * page so a keyboard / AT user can bypass the chrome on every\n * navigation (WCAG 2.1 §2.4.1 \"Bypass Blocks\", Level A).\n * Visually hidden by default; revealed on focus via the\n * scoped `<style>` block below.\n */}\n <style>{SKIP_LINK_FOCUS_CSS}</style>\n <a\n href={`#${MAIN_CONTENT_DOM_ID}`}\n data-website-skip-link=\"\"\n style={SKIP_LINK_HIDDEN_STYLE}\n >\n {skipLinkLabel}\n </a>\n {resolvedHeader !== null ? <header>{resolvedHeader}</header> : null}\n <main id={MAIN_CONTENT_DOM_ID} className={mainClassName} tabIndex={-1}>\n {children}\n </main>\n {resolvedFooter !== null ? <footer>{resolvedFooter}</footer> : null}\n {renderConsentSurface(consent, runtime.consentBannerComponent)}\n </div>\n </WebsiteProviderSdkActivationsContext.Provider>\n </WebsitePageContextProvider>\n );\n}\nWebsitePageLayout.displayName = 'WebsitePageLayout';\n\n/**\n * The panel while a decision is owed (or re-opened), the reopen button once one is made, and nothing at\n * all on a site whose live providers rest on no consent. Nothing renders before the stored decision is\n * read, so a visitor who already decided never sees the panel flash.\n */\nfunction renderConsentSurface(\n consent: ReturnType<typeof useWebsiteConsent>,\n BannerOverride: React.ComponentType | undefined,\n): ReactNode {\n if (!consent.isResolved || consent.purposesInUse.length === 0) return null;\n if (consent.status === WebsiteConsentStatus.UNDECIDED || consent.isSettingsOpen) {\n const Banner = BannerOverride ?? WebsiteConsentBanner;\n return <Banner />;\n }\n return (\n <div data-website-consent-settings=\"\">\n <WebsiteConsentSettingsButton />\n </div>\n );\n}\n/** @wildo_source:part:end saas.website.page-layout.component */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsiteSection.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"WebsiteSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/layouts/WebsiteSection.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAAC;IACvC;;;;;;;OAOG;IACH,QAAQ,EAAE,sBAAsB,CAAC;IACjC;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,QAAQ,EACR,EAAE,EACF,SAAS,EACT,QAAQ,EACR,SAAS,EACT,cAAc,GACf,EAAE,mBAAmB,GAAG,SAAS,CAmCjC;yBA3Ce,cAAc;;;AA6C9B,4DAA4D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-routing.utils.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"internal-routing.utils.d.ts","sourceRoot":"","sources":["../../../../../src/core/routing/internal-routing.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,WAAW,8BAA8B;IAC7C,iFAAiF;IACjF,MAAM,EAAE,iBAAiB,CAAC;IAC1B,sFAAsF;IACtF,aAAa,EAAE,iBAAiB,CAAC;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,8BAA8B,GAAG,MAAM,CAWpF;AACD,iEAAiE"}
|