@tokenoftrust/storefront-runner 2.2.88 → 2.2.89

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.
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Force-injectable compliance markup for the raw-HTML serve path.
3
+ *
4
+ * `rawHtmlResponse` (rawMarketingHtml.ts) bypasses Astro's Layout, so these are
5
+ * the platform-owned anchors that CAN be guaranteed on a raw document
6
+ * independent of its content: the FDA nicotine warning, the shipping/
7
+ * jurisdiction notice, and the excise-tax disclosure. Each mirrors the exact
8
+ * markup its Layout.astro sibling renders (NicotineWarning.astro "bar" variant,
9
+ * ShippingRestrictionNotice.astro "footer" variant via ComplianceNotice.astro,
10
+ * and Layout's own excise-tax <p>) so a raw and a block-composed page present
11
+ * these anchors identically. See `rawHtmlPolicy` for which anchors this does
12
+ * and doesn't cover (notably: NOT `age-gate`).
13
+ */
14
+
15
+ function escapeHtml(value: string): string {
16
+ return value
17
+ .replace(/&/g, "&amp;")
18
+ .replace(/</g, "&lt;")
19
+ .replace(/>/g, "&gt;")
20
+ .replace(/"/g, "&quot;")
21
+ .replace(/'/g, "&#39;");
22
+ }
23
+
24
+ const NICOTINE_WARNING_TEXT =
25
+ "WARNING: This product contains nicotine. Nicotine is an addictive chemical.";
26
+
27
+ /** Mirrors NicotineWarning.astro's "bar" variant. */
28
+ export function nicotineWarningBarHtml(): string {
29
+ return (
30
+ '<div class="border-b-2 border-[var(--color-text)] bg-[var(--color-text)] text-[var(--color-bg)]" role="note" aria-label="Health warning" data-compliance="nicotine-warning">' +
31
+ '<p class="container-prose py-2 text-center text-[0.72rem] font-semibold uppercase tracking-[0.06em] sm:text-xs">' +
32
+ NICOTINE_WARNING_TEXT +
33
+ "</p></div>"
34
+ );
35
+ }
36
+
37
+ /** Mirrors ShippingRestrictionNotice.astro's "footer" variant (via ComplianceNotice.astro). Empty when `text` is absent — same as the Astro component. */
38
+ export function shippingRestrictionNoticeHtml(text: string | undefined): string {
39
+ if (!text) return "";
40
+ return (
41
+ '<div class="border-t border-[var(--color-border)] bg-[var(--color-bg)]" data-compliance="shipping-restriction">' +
42
+ '<p class="container-prose py-3 text-center text-sm text-[var(--color-muted)]" role="note" aria-label="Shipping restriction notice">' +
43
+ escapeHtml(text) +
44
+ "</p></div>"
45
+ );
46
+ }
47
+
48
+ /** Mirrors Layout.astro's excise-tax disclosure <p>. */
49
+ export function exciseTaxNoticeHtml(): string {
50
+ return (
51
+ '<p class="border-t border-[var(--color-border)] bg-[var(--color-bg)] py-2.5 text-center text-xs text-[var(--color-muted)]" data-capability="excise-tax">' +
52
+ "Applicable excise tax is calculated at checkout.</p>"
53
+ );
54
+ }
55
+
56
+ export interface RawComplianceChromeInput {
57
+ nicotineWarning?: boolean;
58
+ shippingRestriction?: string;
59
+ exciseTaxEnabled?: boolean;
60
+ }
61
+
62
+ /** The markup to inject at `rawHtmlResponse`'s body-start boundary. */
63
+ export function renderRawComplianceTop(input: RawComplianceChromeInput): string {
64
+ return input.nicotineWarning ? nicotineWarningBarHtml() : "";
65
+ }
66
+
67
+ /** The markup to inject at `rawHtmlResponse`'s body-deferred boundary. */
68
+ export function renderRawComplianceBottom(input: RawComplianceChromeInput): string {
69
+ let out = shippingRestrictionNoticeHtml(input.shippingRestriction);
70
+ if (input.exciseTaxEnabled) out += exciseTaxNoticeHtml();
71
+ return out;
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "2.2.88",
3
+ "version": "2.2.89",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",