@returningai/widget-sdk 1.8.11 → 1.8.12

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.
@@ -13365,6 +13365,90 @@ class WidgetCallbackRegistry {
13365
13365
  return { ...this.registeredCallbacks };
13366
13366
  }
13367
13367
  }
13368
+ const loadedGoogleFontFamilies = /* @__PURE__ */ new Set();
13369
+ const LOCAL_OR_SYSTEM_FONT_FAMILIES = /* @__PURE__ */ new Set([
13370
+ "aeonik",
13371
+ "courier",
13372
+ "courier new",
13373
+ "monaco",
13374
+ "monospace",
13375
+ "sans-serif",
13376
+ "serif",
13377
+ "system-ui"
13378
+ ]);
13379
+ const SERIF_FONT_FAMILIES = /* @__PURE__ */ new Set(["lora", "playfair display", "prata"]);
13380
+ const GOOGLE_FONT_VARIANTS = ":ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,700";
13381
+ function normalizeFontFamily(family) {
13382
+ return family.trim() === "Noto" ? "Noto Sans" : family.trim();
13383
+ }
13384
+ function getFontStack(family) {
13385
+ const normalizedFamily = normalizeFontFamily(family);
13386
+ if (normalizedFamily.includes(",")) return normalizedFamily;
13387
+ const normalizedKey = normalizedFamily.toLowerCase();
13388
+ switch (normalizedKey) {
13389
+ case "monospace":
13390
+ return "monospace";
13391
+ case "courier":
13392
+ case "courier new":
13393
+ return '"Courier New", Courier, monospace';
13394
+ case "monaco":
13395
+ return "Monaco, Menlo, Consolas, monospace";
13396
+ case "system-ui":
13397
+ return "system-ui, -apple-system, sans-serif";
13398
+ case "sans-serif":
13399
+ case "serif":
13400
+ return normalizedKey;
13401
+ default:
13402
+ return `'${normalizedFamily.replace(/[\\']/g, "\\\\$&")}', ${SERIF_FONT_FAMILIES.has(normalizedKey) ? "Georgia, 'Times New Roman', serif" : "system-ui, -apple-system, sans-serif"}`;
13403
+ }
13404
+ }
13405
+ function ensureGoogleFontPreconnect() {
13406
+ if (!document.getElementById("rai-fonts-preconnect")) {
13407
+ const link = document.createElement("link");
13408
+ link.id = "rai-fonts-preconnect";
13409
+ link.rel = "preconnect";
13410
+ link.href = "https://fonts.googleapis.com";
13411
+ document.head.appendChild(link);
13412
+ }
13413
+ if (!document.getElementById("rai-fonts-static-preconnect")) {
13414
+ const link = document.createElement("link");
13415
+ link.id = "rai-fonts-static-preconnect";
13416
+ link.rel = "preconnect";
13417
+ link.href = "https://fonts.gstatic.com";
13418
+ link.crossOrigin = "anonymous";
13419
+ document.head.appendChild(link);
13420
+ }
13421
+ }
13422
+ function ensureGoogleFontLoaded(family) {
13423
+ const normalizedFamily = normalizeFontFamily(family);
13424
+ const fontKey = normalizedFamily.toLowerCase();
13425
+ if (!normalizedFamily || normalizedFamily.includes(",") || LOCAL_OR_SYSTEM_FONT_FAMILIES.has(fontKey)) {
13426
+ return;
13427
+ }
13428
+ if (loadedGoogleFontFamilies.has(fontKey)) return;
13429
+ ensureGoogleFontPreconnect();
13430
+ const linkId = `rai-font-${normalizedFamily.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
13431
+ const fontUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
13432
+ normalizedFamily
13433
+ )}${GOOGLE_FONT_VARIANTS}&display=swap`;
13434
+ let link = document.getElementById(linkId);
13435
+ if (link && link.href !== fontUrl) {
13436
+ link.remove();
13437
+ link = null;
13438
+ }
13439
+ if (!link) {
13440
+ link = document.createElement("link");
13441
+ link.id = linkId;
13442
+ link.rel = "stylesheet";
13443
+ link.href = fontUrl;
13444
+ document.head.appendChild(link);
13445
+ }
13446
+ loadedGoogleFontFamilies.add(fontKey);
13447
+ link.onerror = () => {
13448
+ loadedGoogleFontFamilies.delete(fontKey);
13449
+ link == null ? void 0 : link.remove();
13450
+ };
13451
+ }
13368
13452
  const STORE_CALLBACK_FIELD_OPTIONS_SCOPE = "store.callback_field_options";
13369
13453
  const STORE_CALLBACK_FIELD_OPTIONS_CALLBACK_NAME = "callbackFieldOptions";
13370
13454
  const STORE_CALLBACK_FIELD_OPTIONS_TIMEOUT_MS = 15e3;
@@ -14003,89 +14087,6 @@ function resolveWidgetServerUrl(domainKey) {
14003
14087
  function resolveV2ApiUrl(domainKey) {
14004
14088
  return DOMAIN_KEY_TO_V2_API_URL[domainKey] || DOMAIN_KEY_TO_V2_API_URL.PROD;
14005
14089
  }
14006
- const loadedGoogleFontFamilies = /* @__PURE__ */ new Set();
14007
- const LOCAL_OR_SYSTEM_FONT_FAMILIES = /* @__PURE__ */ new Set([
14008
- "aeonik",
14009
- "courier",
14010
- "courier new",
14011
- "monaco",
14012
- "monospace",
14013
- "sans-serif",
14014
- "serif",
14015
- "system-ui"
14016
- ]);
14017
- const SERIF_FONT_FAMILIES = /* @__PURE__ */ new Set(["lora", "playfair display", "prata"]);
14018
- const GOOGLE_FONT_VARIANTS = ":ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,700";
14019
- function normalizeFontFamily(family) {
14020
- return family.trim() === "Noto" ? "Noto Sans" : family.trim();
14021
- }
14022
- function getFontStack(family) {
14023
- const normalizedFamily = normalizeFontFamily(family);
14024
- const normalizedKey = normalizedFamily.toLowerCase();
14025
- switch (normalizedKey) {
14026
- case "monospace":
14027
- return "monospace";
14028
- case "courier":
14029
- case "courier new":
14030
- return '"Courier New", Courier, monospace';
14031
- case "monaco":
14032
- return "Monaco, Menlo, Consolas, monospace";
14033
- case "system-ui":
14034
- return "system-ui, -apple-system, sans-serif";
14035
- case "sans-serif":
14036
- case "serif":
14037
- return normalizedKey;
14038
- default:
14039
- return `'${normalizedFamily.replace(/[\\']/g, "\\\\$&")}', ${SERIF_FONT_FAMILIES.has(normalizedKey) ? "Georgia, 'Times New Roman', serif" : "system-ui, -apple-system, sans-serif"}`;
14040
- }
14041
- }
14042
- function ensureGoogleFontPreconnect() {
14043
- if (!document.getElementById("rai-fonts-preconnect")) {
14044
- const link = document.createElement("link");
14045
- link.id = "rai-fonts-preconnect";
14046
- link.rel = "preconnect";
14047
- link.href = "https://fonts.googleapis.com";
14048
- document.head.appendChild(link);
14049
- }
14050
- if (!document.getElementById("rai-fonts-static-preconnect")) {
14051
- const link = document.createElement("link");
14052
- link.id = "rai-fonts-static-preconnect";
14053
- link.rel = "preconnect";
14054
- link.href = "https://fonts.gstatic.com";
14055
- link.crossOrigin = "anonymous";
14056
- document.head.appendChild(link);
14057
- }
14058
- }
14059
- function ensureGoogleFontLoaded(family) {
14060
- const normalizedFamily = normalizeFontFamily(family);
14061
- const fontKey = normalizedFamily.toLowerCase();
14062
- if (!normalizedFamily || LOCAL_OR_SYSTEM_FONT_FAMILIES.has(fontKey)) {
14063
- return;
14064
- }
14065
- if (loadedGoogleFontFamilies.has(fontKey)) return;
14066
- ensureGoogleFontPreconnect();
14067
- const linkId = `rai-font-${normalizedFamily.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
14068
- const fontUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
14069
- normalizedFamily
14070
- )}${GOOGLE_FONT_VARIANTS}&display=swap`;
14071
- let link = document.getElementById(linkId);
14072
- if (link && link.href !== fontUrl) {
14073
- link.remove();
14074
- link = null;
14075
- }
14076
- if (!link) {
14077
- link = document.createElement("link");
14078
- link.id = linkId;
14079
- link.rel = "stylesheet";
14080
- link.href = fontUrl;
14081
- document.head.appendChild(link);
14082
- }
14083
- loadedGoogleFontFamilies.add(fontKey);
14084
- link.onerror = () => {
14085
- loadedGoogleFontFamilies.delete(fontKey);
14086
- link == null ? void 0 : link.remove();
14087
- };
14088
- }
14089
14090
  const DANGEROUS_ELEMENTS = ["script", "iframe", "object", "embed"];
14090
14091
  const URL_ATTRS = ["src", "href", "xlink:href"];
14091
14092
  function sanitizeLoaderHtml(html2) {
@@ -15570,7 +15571,7 @@ class CustomWidget extends BaseWidget {
15570
15571
  }
15571
15572
  }
15572
15573
  }
15573
- console.log(`[rai-widget] v${"1.8.11"}`);
15574
+ console.log(`[rai-widget] v${"1.8.12"}`);
15574
15575
  class StoreWidgetCompat extends StoreWidget {
15575
15576
  }
15576
15577
  const WIDGET_REGISTRY = [
@@ -15634,7 +15635,7 @@ function exposePublicApi() {
15634
15635
  })();
15635
15636
  const widget = container == null ? void 0 : container.querySelector(ALL_WIDGET_SELECTOR);
15636
15637
  window.ReturningAIWidget = {
15637
- version: "1.8.11",
15638
+ version: "1.8.12",
15638
15639
  reload: () => (widget == null ? void 0 : widget.reload()) ?? Promise.resolve(),
15639
15640
  logout: () => (widget == null ? void 0 : widget.logoutPublic()) ?? Promise.resolve(),
15640
15641
  isAuthenticated: () => (widget == null ? void 0 : widget.isAuthenticated()) ?? false,
@@ -0,0 +1,3 @@
1
+ export declare function normalizeFontFamily(family: string): string;
2
+ export declare function getFontStack(family: string): string;
3
+ export declare function ensureGoogleFontLoaded(family: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@returningai/widget-sdk",
3
- "version": "1.8.11",
3
+ "version": "1.8.12",
4
4
  "description": "Shadow DOM isolated widget SDK for ReturningAI",
5
5
  "main": "dist/rai-widget.iife.js",
6
6
  "module": "dist/rai-widget.js",
@@ -42,7 +42,7 @@
42
42
  "build:all": "npm run build && npm run build:banner",
43
43
  "build:all:min": "npm run build:min && npm run build:banner:min",
44
44
  "types": "tsc --emitDeclarationOnly --outDir dist/types && cp src/jsx.d.ts src/react18.d.ts src/react19.d.ts dist/types/",
45
- "test": "npm run test:host-callback && npm run test:bundle-readiness && npm run test:bundle-runtime-cache && npm run test:bundle-token-sync && npm run test:auth-bootstrap && npm run test:auth-error-reporting && npm run test:auth-refresh-state && npm run test:auth-renewal-recovery && npm run test:auth-session-coordinator && npm run test:startup-performance && npm run test:widget-error-presentation && npm run test:jsx-types",
45
+ "test": "npm run test:host-callback && npm run test:bundle-readiness && npm run test:bundle-runtime-cache && npm run test:bundle-token-sync && npm run test:auth-bootstrap && npm run test:auth-error-reporting && npm run test:auth-refresh-state && npm run test:auth-renewal-recovery && npm run test:auth-session-coordinator && npm run test:startup-performance && npm run test:widget-error-presentation && npm run test:fonts && npm run test:jsx-types",
46
46
  "test:host-callback": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/postmessage-host-callback.test.js",
47
47
  "test:bundle-readiness": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/bundle-readiness.test.js",
48
48
  "test:bundle-runtime-cache": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/bundle-runtime-cache.test.js",
@@ -54,6 +54,7 @@
54
54
  "test:auth-session-coordinator": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/auth-session-coordinator.test.js",
55
55
  "test:startup-performance": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/startup-performance.test.js",
56
56
  "test:widget-error-presentation": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/widget-error-presentation.test.js",
57
+ "test:fonts": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/fonts.test.js",
57
58
  "test:jsx-types": "npm run types && node --test test/jsx/declaration-shape.test.mjs test/jsx/packed-consumer.test.mjs && tsc -p test/jsx/tsconfig.react.json && tsc -p test/jsx/tsconfig.vue.json",
58
59
  "coverage:repowise": "rm -rf coverage && npm run coverage:host-callback && npm run coverage:bundle-readiness && npm run test:jsx-types",
59
60
  "coverage:host-callback": "rm -rf test/.tmp && tsc -p test/tsconfig.json && c8 --reporter=lcov --reports-dir=coverage/host-callback --exclude-after-remap --exclude='**/*.test.ts' node test/.tmp/test/postmessage-host-callback.test.js && node scripts/name-lcov-test.mjs coverage/host-callback/lcov.info test/postmessage-host-callback.test.ts",