@replohq/sdk 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../consent/window-api.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { consentStore, isConsentAllowed } from \"./consent-store\";\n\n/**\n * Global, framework-agnostic consent API exposed on `window.Replo.customerPrivacy`,\n * mirroring Shopify's Customer Privacy API surface so on-page (third-party)\n * scripts can query consent and react to changes without importing canopy.\n *\n * It deliberately lives under our own `window.Replo` namespace rather than\n * `window.Shopify` to avoid colliding with Shopify's real API on Shopify-backed\n * sites.\n */\n\ntype ToggleableCategory = Exclude<ConsentCategory, \"necessary\">;\n\n/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */\ntype ConsentSignal = \"yes\" | \"no\" | \"\";\n\nexport interface ReploCustomerPrivacyApi {\n /** Per-category declaration, or \"\" when the visitor has not decided. */\n currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal>;\n analyticsProcessingAllowed(): boolean;\n marketingAllowed(): boolean;\n preferencesProcessingAllowed(): boolean;\n saleOfDataAllowed(): boolean;\n /** Whether the consent banner should still be shown (mode on + undecided). */\n shouldShowBanner(): boolean;\n /** Update a subset of categories; runs the optional callback once persisted. */\n setTrackingConsent(\n consent: Partial<Record<ToggleableCategory, boolean>>,\n callback?: () => void,\n ): void;\n}\n\ndeclare global {\n interface Window {\n Replo?: { customerPrivacy?: ReploCustomerPrivacyApi };\n }\n}\n\n/** DOM event dispatched on `document` whenever consent changes. */\nexport const CONSENT_CHANGE_EVENT = \"visitorConsentCollected\";\n\nfunction isAllowed(category: ConsentCategory): boolean {\n return isConsentAllowed({\n state: consentStore.getSnapshot(),\n requiredConsent: [category],\n });\n}\n\nfunction currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal> {\n const state = consentStore.getSnapshot();\n const signal = (category: ToggleableCategory): ConsentSignal => {\n if (state.decidedAt === null) {\n return \"\";\n }\n return state.categories[category] ? \"yes\" : \"no\";\n };\n return {\n analytics: signal(\"analytics\"),\n marketing: signal(\"marketing\"),\n preferences: signal(\"preferences\"),\n sale_of_data: signal(\"sale_of_data\"),\n };\n}\n\nconst api: ReploCustomerPrivacyApi = {\n currentVisitorConsent,\n analyticsProcessingAllowed: () => isAllowed(\"analytics\"),\n marketingAllowed: () => isAllowed(\"marketing\"),\n preferencesProcessingAllowed: () => isAllowed(\"preferences\"),\n saleOfDataAllowed: () => isAllowed(\"sale_of_data\"),\n shouldShowBanner: () => {\n const state = consentStore.getSnapshot();\n return state.mode !== \"off\" && state.decidedAt === null;\n },\n setTrackingConsent: (consent, callback) => {\n consentStore.updateCategories({ next: consent });\n callback?.();\n },\n};\n\nfunction consentChangeDetail() {\n return {\n analyticsAllowed: isAllowed(\"analytics\"),\n marketingAllowed: isAllowed(\"marketing\"),\n preferencesAllowed: isAllowed(\"preferences\"),\n saleOfDataAllowed: isAllowed(\"sale_of_data\"),\n };\n}\n\nlet teardown: (() => void) | null = null;\n\n/**\n * Installs `window.Replo.customerPrivacy` and dispatches `visitorConsentCollected`\n * on `document` whenever consent changes. Idempotent; returns a teardown that\n * removes the change subscription. Safe to call on the server (no-op).\n */\nexport function installConsentWindowApi(): () => void {\n if (typeof window === \"undefined\") {\n return () => {\n // no-op on the server\n };\n }\n if (teardown) {\n return teardown;\n }\n window.Replo = { ...window.Replo, customerPrivacy: api };\n const unsubscribe = consentStore.subscribe(() => {\n document.dispatchEvent(\n new CustomEvent(CONSENT_CHANGE_EVENT, { detail: consentChangeDetail() }),\n );\n });\n teardown = () => {\n unsubscribe();\n teardown = null;\n };\n return teardown;\n}\n"],
5
- "mappings": ";AAIA,SAAS,cAAc,wBAAwB;AAwCxC,MAAM,uBAAuB;AAEpC,SAAS,UAAU,UAAoC;AACrD,SAAO,iBAAiB;AAAA,IACtB,OAAO,a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,aAAa,UAAU,MAAM;AAC/C,aAAS;AAAA,MACP,IAAI,YAAY,sBAAsB,EAAE,QAAQ,oBAAoB,EAAE,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACD,aAAW,MAAM;AACf,gBAAY;AACZ,eAAW;AAAA,EACb;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { consentStore, isConsentAllowed } from \"./consent-store\";\n\n/**\n * Global, framework-agnostic consent API exposed on `window.Replo.customerPrivacy`,\n * mirroring Shopify's Customer Privacy API surface so on-page (third-party)\n * scripts can query consent and react to changes without importing canopy.\n *\n * It deliberately lives under our own `window.Replo` namespace rather than\n * `window.Shopify` to avoid colliding with Shopify's real API on Shopify-backed\n * sites.\n */\n\ntype ToggleableCategory = Exclude<ConsentCategory, \"necessary\">;\n\n/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */\ntype ConsentSignal = \"yes\" | \"no\" | \"\";\n\nexport interface ReploCustomerPrivacyApi {\n /** Per-category declaration, or \"\" when the visitor has not decided. */\n currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal>;\n analyticsProcessingAllowed(): boolean;\n marketingAllowed(): boolean;\n preferencesProcessingAllowed(): boolean;\n saleOfDataAllowed(): boolean;\n /**\n * Whether Replo's consent banner should still be shown (mode on + undecided).\n * Always false when an external CMP owns consent and shows its own banner.\n */\n shouldShowBanner(): boolean;\n /** Update a subset of categories; runs the optional callback once persisted. */\n setTrackingConsent(\n consent: Partial<Record<ToggleableCategory, boolean>>,\n callback?: () => void,\n ): void;\n}\n\ndeclare global {\n interface Window {\n Replo?: { customerPrivacy?: ReploCustomerPrivacyApi };\n }\n}\n\n/** DOM event dispatched on `document` whenever consent changes. */\nexport const CONSENT_CHANGE_EVENT = \"visitorConsentCollected\";\n\nfunction isAllowed(category: ConsentCategory): boolean {\n return isConsentAllowed({\n state: consentStore.getSnapshot(),\n requiredConsent: [category],\n });\n}\n\nfunction currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal> {\n const state = consentStore.getSnapshot();\n const signal = (category: ToggleableCategory): ConsentSignal => {\n if (state.decidedAt === null) {\n return \"\";\n }\n return state.categories[category] ? \"yes\" : \"no\";\n };\n return {\n analytics: signal(\"analytics\"),\n marketing: signal(\"marketing\"),\n preferences: signal(\"preferences\"),\n sale_of_data: signal(\"sale_of_data\"),\n };\n}\n\nconst api: ReploCustomerPrivacyApi = {\n currentVisitorConsent,\n analyticsProcessingAllowed: () => isAllowed(\"analytics\"),\n marketingAllowed: () => isAllowed(\"marketing\"),\n preferencesProcessingAllowed: () => isAllowed(\"preferences\"),\n saleOfDataAllowed: () => isAllowed(\"sale_of_data\"),\n shouldShowBanner: () => {\n const state = consentStore.getSnapshot();\n // A delegated platform renders its own banner; showing Replo's too would\n // ask the visitor twice.\n if (state.cmp === \"cookiebot\" || state.cmp === \"external\") {\n return false;\n }\n return state.mode !== \"off\" && state.decidedAt === null;\n },\n setTrackingConsent: (consent, callback) => {\n consentStore.updateCategories({ next: consent });\n callback?.();\n },\n};\n\nfunction consentChangeDetail() {\n return {\n analyticsAllowed: isAllowed(\"analytics\"),\n marketingAllowed: isAllowed(\"marketing\"),\n preferencesAllowed: isAllowed(\"preferences\"),\n saleOfDataAllowed: isAllowed(\"sale_of_data\"),\n };\n}\n\nlet teardown: (() => void) | null = null;\n\n/**\n * Installs `window.Replo.customerPrivacy` and dispatches `visitorConsentCollected`\n * on `document` whenever consent changes. Idempotent; returns a teardown that\n * removes the change subscription. Safe to call on the server (no-op).\n */\nexport function installConsentWindowApi(): () => void {\n if (typeof window === \"undefined\") {\n return () => {\n // no-op on the server\n };\n }\n if (teardown) {\n return teardown;\n }\n window.Replo = { ...window.Replo, customerPrivacy: api };\n const unsubscribe = consentStore.subscribe(() => {\n document.dispatchEvent(\n new CustomEvent(CONSENT_CHANGE_EVENT, { detail: consentChangeDetail() }),\n );\n });\n teardown = () => {\n unsubscribe();\n teardown = null;\n };\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IAAI,WAAgC;AAO7B,SAAS,0BAAsC;AACpD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,MAAM;AAAA,IAEb;AAAA,EACF;AACA,MAAI,UAAU;AACZ,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,EAAE,GAAG,OAAO,OAAO,iBAAiB,IAAI;AACvD,QAAM,cAAc,aAAa,UAAU,MAAM;AAC/C,aAAS;AAAA,MACP,IAAI,YAAY,sBAAsB,EAAE,QAAQ,oBAAoB,EAAE,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACD,aAAW,MAAM;AACf,gBAAY;AACZ,eAAW;AAAA,EACb;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  export const BUILD_METADATA = {
2
2
  "packageName": "@replohq/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "branch": "HEAD",
5
- "commit": "539d866ed8d4f2a8f13f1b3bd23cc3131d96c35f",
6
- "builtAt": "2026-08-20T02:24:19.564Z"
5
+ "commit": "5076021b33cfdcd5bddd4ee545268e6d34896ee2",
6
+ "builtAt": "2026-08-20T20:41:16.929Z"
7
7
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@replohq/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "reploBuild": {
5
5
  "packageName": "@replohq/sdk",
6
- "version": "0.7.0",
6
+ "version": "0.8.0",
7
7
  "branch": "HEAD",
8
- "commit": "539d866ed8d4f2a8f13f1b3bd23cc3131d96c35f",
9
- "builtAt": "2026-08-20T02:24:19.564Z"
8
+ "commit": "5076021b33cfdcd5bddd4ee545268e6d34896ee2",
9
+ "builtAt": "2026-08-20T20:41:16.929Z"
10
10
  },
11
11
  "description": "Replo SDK — cart, analytics, and data loaders for agent-built Next.js sites.",
12
12
  "license": "SEE LICENSE IN LICENSE",