@zerocost/sdk 0.16.0 → 0.18.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.
@@ -13,6 +13,7 @@ export interface ConsentUIResult {
13
13
  usageData: boolean;
14
14
  aiInteractions: boolean;
15
15
  }
16
+ export declare function injectStyles(theme: 'light' | 'dark' | 'auto'): void;
16
17
  export declare function showConsentUI(options: ConsentUIOptions): Promise<ConsentUIResult>;
17
18
  /** Remove any existing consent popup from the DOM */
18
19
  export declare function removeConsentUI(): void;
package/dist/index.cjs CHANGED
@@ -1357,14 +1357,14 @@ function injectStyles(theme) {
1357
1357
  `;
1358
1358
  let themeRule;
1359
1359
  if (theme === "dark") {
1360
- themeRule = `.zc-consent-root { ${darkVars} }`;
1360
+ themeRule = `.zc-consent-root, .zc-settings-btn { ${darkVars} }`;
1361
1361
  } else if (theme === "light") {
1362
- themeRule = `.zc-consent-root { ${lightVars} }`;
1362
+ themeRule = `.zc-consent-root, .zc-settings-btn { ${lightVars} }`;
1363
1363
  } else {
1364
1364
  themeRule = `
1365
- .zc-consent-root { ${lightVars} }
1365
+ .zc-consent-root, .zc-settings-btn { ${lightVars} }
1366
1366
  @media (prefers-color-scheme: dark) {
1367
- .zc-consent-root { ${darkVars} }
1367
+ .zc-consent-root, .zc-settings-btn { ${darkVars} }
1368
1368
  }
1369
1369
  `;
1370
1370
  }
@@ -1750,7 +1750,7 @@ function showConsentUI(options) {
1750
1750
  const footer = document.createElement("div");
1751
1751
  footer.className = "zc-consent-footer";
1752
1752
  const ppLink = document.createElement("a");
1753
- ppLink.href = privacyPolicyUrl || `${zerocostBaseUrl}/docs/privacy`;
1753
+ ppLink.href = privacyPolicyUrl || `${zerocostBaseUrl}/privacy`;
1754
1754
  ppLink.target = "_blank";
1755
1755
  ppLink.rel = "noopener noreferrer";
1756
1756
  ppLink.textContent = "Privacy Policy";
@@ -1760,7 +1760,7 @@ function showConsentUI(options) {
1760
1760
  sep1.textContent = "\xB7";
1761
1761
  footer.appendChild(sep1);
1762
1762
  const termsLink = document.createElement("a");
1763
- termsLink.href = `${zerocostBaseUrl}/docs/terms`;
1763
+ termsLink.href = `${zerocostBaseUrl}/terms`;
1764
1764
  termsLink.target = "_blank";
1765
1765
  termsLink.rel = "noopener noreferrer";
1766
1766
  termsLink.textContent = "Terms";
@@ -1815,6 +1815,7 @@ var ConsentManager = class {
1815
1815
  this.theme = opts.theme ?? "dark";
1816
1816
  this.hydrateFromStorage();
1817
1817
  if (this.consentConfig.showSettingsButton) {
1818
+ injectStyles(this.theme);
1818
1819
  this.injectSettingsButton();
1819
1820
  }
1820
1821
  }
@@ -1965,17 +1966,25 @@ var ConsentManager = class {
1965
1966
  }
1966
1967
  injectSettingsButton() {
1967
1968
  if (typeof document === "undefined") return;
1968
- const existing = document.getElementById("zerocost-privacy-settings-btn");
1969
- if (existing) return;
1970
- const btn = document.createElement("button");
1971
- btn.id = "zerocost-privacy-settings-btn";
1972
- btn.setAttribute("aria-label", "Privacy Settings");
1973
- btn.title = "Privacy Settings";
1974
- const pos = this.consentConfig.buttonPosition || "bottom-left";
1975
- btn.className = `zc-settings-btn zc-settings-${pos}`;
1976
- btn.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>`;
1977
- btn.addEventListener("click", () => this.open());
1978
- document.body.appendChild(btn);
1969
+ const mount = () => {
1970
+ if (!document.body) return;
1971
+ const existing = document.getElementById("zerocost-privacy-settings-btn");
1972
+ if (existing) return;
1973
+ const btn = document.createElement("button");
1974
+ btn.id = "zerocost-privacy-settings-btn";
1975
+ btn.setAttribute("aria-label", "Privacy Settings");
1976
+ btn.title = "Privacy Settings";
1977
+ const pos = this.consentConfig.buttonPosition || "bottom-left";
1978
+ btn.className = `zc-settings-btn zc-settings-${pos}`;
1979
+ btn.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>`;
1980
+ btn.addEventListener("click", () => this.open());
1981
+ document.body.appendChild(btn);
1982
+ };
1983
+ if (document.body) {
1984
+ mount();
1985
+ } else {
1986
+ window.addEventListener("DOMContentLoaded", mount);
1987
+ }
1979
1988
  }
1980
1989
  removeSettingsButton() {
1981
1990
  document.getElementById("zerocost-privacy-settings-btn")?.remove();
package/dist/index.js CHANGED
@@ -1327,14 +1327,14 @@ function injectStyles(theme) {
1327
1327
  `;
1328
1328
  let themeRule;
1329
1329
  if (theme === "dark") {
1330
- themeRule = `.zc-consent-root { ${darkVars} }`;
1330
+ themeRule = `.zc-consent-root, .zc-settings-btn { ${darkVars} }`;
1331
1331
  } else if (theme === "light") {
1332
- themeRule = `.zc-consent-root { ${lightVars} }`;
1332
+ themeRule = `.zc-consent-root, .zc-settings-btn { ${lightVars} }`;
1333
1333
  } else {
1334
1334
  themeRule = `
1335
- .zc-consent-root { ${lightVars} }
1335
+ .zc-consent-root, .zc-settings-btn { ${lightVars} }
1336
1336
  @media (prefers-color-scheme: dark) {
1337
- .zc-consent-root { ${darkVars} }
1337
+ .zc-consent-root, .zc-settings-btn { ${darkVars} }
1338
1338
  }
1339
1339
  `;
1340
1340
  }
@@ -1720,7 +1720,7 @@ function showConsentUI(options) {
1720
1720
  const footer = document.createElement("div");
1721
1721
  footer.className = "zc-consent-footer";
1722
1722
  const ppLink = document.createElement("a");
1723
- ppLink.href = privacyPolicyUrl || `${zerocostBaseUrl}/docs/privacy`;
1723
+ ppLink.href = privacyPolicyUrl || `${zerocostBaseUrl}/privacy`;
1724
1724
  ppLink.target = "_blank";
1725
1725
  ppLink.rel = "noopener noreferrer";
1726
1726
  ppLink.textContent = "Privacy Policy";
@@ -1730,7 +1730,7 @@ function showConsentUI(options) {
1730
1730
  sep1.textContent = "\xB7";
1731
1731
  footer.appendChild(sep1);
1732
1732
  const termsLink = document.createElement("a");
1733
- termsLink.href = `${zerocostBaseUrl}/docs/terms`;
1733
+ termsLink.href = `${zerocostBaseUrl}/terms`;
1734
1734
  termsLink.target = "_blank";
1735
1735
  termsLink.rel = "noopener noreferrer";
1736
1736
  termsLink.textContent = "Terms";
@@ -1785,6 +1785,7 @@ var ConsentManager = class {
1785
1785
  this.theme = opts.theme ?? "dark";
1786
1786
  this.hydrateFromStorage();
1787
1787
  if (this.consentConfig.showSettingsButton) {
1788
+ injectStyles(this.theme);
1788
1789
  this.injectSettingsButton();
1789
1790
  }
1790
1791
  }
@@ -1935,17 +1936,25 @@ var ConsentManager = class {
1935
1936
  }
1936
1937
  injectSettingsButton() {
1937
1938
  if (typeof document === "undefined") return;
1938
- const existing = document.getElementById("zerocost-privacy-settings-btn");
1939
- if (existing) return;
1940
- const btn = document.createElement("button");
1941
- btn.id = "zerocost-privacy-settings-btn";
1942
- btn.setAttribute("aria-label", "Privacy Settings");
1943
- btn.title = "Privacy Settings";
1944
- const pos = this.consentConfig.buttonPosition || "bottom-left";
1945
- btn.className = `zc-settings-btn zc-settings-${pos}`;
1946
- btn.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>`;
1947
- btn.addEventListener("click", () => this.open());
1948
- document.body.appendChild(btn);
1939
+ const mount = () => {
1940
+ if (!document.body) return;
1941
+ const existing = document.getElementById("zerocost-privacy-settings-btn");
1942
+ if (existing) return;
1943
+ const btn = document.createElement("button");
1944
+ btn.id = "zerocost-privacy-settings-btn";
1945
+ btn.setAttribute("aria-label", "Privacy Settings");
1946
+ btn.title = "Privacy Settings";
1947
+ const pos = this.consentConfig.buttonPosition || "bottom-left";
1948
+ btn.className = `zc-settings-btn zc-settings-${pos}`;
1949
+ btn.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>`;
1950
+ btn.addEventListener("click", () => this.open());
1951
+ document.body.appendChild(btn);
1952
+ };
1953
+ if (document.body) {
1954
+ mount();
1955
+ } else {
1956
+ window.addEventListener("DOMContentLoaded", mount);
1957
+ }
1949
1958
  }
1950
1959
  removeSettingsButton() {
1951
1960
  document.getElementById("zerocost-privacy-settings-btn")?.remove();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerocost/sdk",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",