@returningai/widget-sdk 1.8.10 → 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.
- package/CHANGELOG.md +22 -0
- package/README.md +14 -1
- package/dist/rai-banner.iife.js +1 -1
- package/dist/rai-banner.js +1 -1
- package/dist/rai-widget.iife.js +1 -1
- package/dist/rai-widget.js +86 -85
- package/dist/types/core/fonts.d.ts +3 -0
- package/dist/types/jsx.d.ts +7 -31
- package/dist/types/react18.d.ts +13 -0
- package/dist/types/react19.d.ts +15 -0
- package/package.json +20 -3
package/dist/rai-widget.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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,
|
package/dist/types/jsx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface RaiSharedWidgetAttributes {
|
|
1
|
+
export interface RaiSharedWidgetAttributes {
|
|
2
2
|
'data-email'?: string
|
|
3
3
|
'widget-type'?: 'store' | 'channel' | 'milestone' | 'social' | 'currency-view' | 'referral-conditions' | 'custom'
|
|
4
4
|
theme?: 'light' | 'dark'
|
|
@@ -20,30 +20,30 @@ interface RaiSharedWidgetAttributes {
|
|
|
20
20
|
style?: string
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
interface RaiCommunityWidgetAttributes extends RaiSharedWidgetAttributes {
|
|
23
|
+
export interface RaiCommunityWidgetAttributes extends RaiSharedWidgetAttributes {
|
|
24
24
|
'community-id': string
|
|
25
25
|
'channel-id'?: string
|
|
26
26
|
/** @deprecated Standard widgets should use community-id. */
|
|
27
27
|
'widget-id'?: string
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
interface RaiCustomWidgetAttributes extends RaiSharedWidgetAttributes {
|
|
30
|
+
export interface RaiCustomWidgetAttributes extends RaiSharedWidgetAttributes {
|
|
31
31
|
'widget-id': string
|
|
32
32
|
'community-id'?: never
|
|
33
33
|
'channel-id'?: never
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
type RaiWidgetElementAttributes<TAttributes> = TAttributes & {
|
|
36
|
+
export type RaiWidgetElementAttributes<TAttributes> = TAttributes & {
|
|
37
37
|
[attributeName: string]: unknown
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
type RaiCommunityWidgetElementAttributes =
|
|
40
|
+
export type RaiCommunityWidgetElementAttributes =
|
|
41
41
|
RaiWidgetElementAttributes<RaiCommunityWidgetAttributes>
|
|
42
42
|
|
|
43
|
-
type RaiCustomWidgetElementAttributes =
|
|
43
|
+
export type RaiCustomWidgetElementAttributes =
|
|
44
44
|
RaiWidgetElementAttributes<RaiCustomWidgetAttributes>
|
|
45
45
|
|
|
46
|
-
interface RaiWidgetIntrinsicElements {
|
|
46
|
+
export interface RaiWidgetIntrinsicElements {
|
|
47
47
|
'rai-store-widget': RaiCommunityWidgetElementAttributes
|
|
48
48
|
'rai-channel-widget': RaiCommunityWidgetElementAttributes
|
|
49
49
|
'rai-milestone-widget': RaiCommunityWidgetElementAttributes
|
|
@@ -54,30 +54,6 @@ interface RaiWidgetIntrinsicElements {
|
|
|
54
54
|
'rai-widget': RaiCommunityWidgetElementAttributes
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
type RaiGlobalIntrinsicElements = JSX.IntrinsicElements
|
|
58
|
-
|
|
59
|
-
declare global {
|
|
60
|
-
namespace React {
|
|
61
|
-
namespace JSX {
|
|
62
|
-
interface ElementChildrenAttribute {
|
|
63
|
-
children: {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface IntrinsicElements
|
|
67
|
-
extends RaiGlobalIntrinsicElements,
|
|
68
|
-
RaiWidgetIntrinsicElements {}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
namespace JSX {
|
|
73
|
-
interface ElementChildrenAttribute {
|
|
74
|
-
children: {}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface IntrinsicElements extends RaiWidgetIntrinsicElements {}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
57
|
declare module '@vue/runtime-core' {
|
|
82
58
|
interface GlobalComponents {
|
|
83
59
|
RaiStoreWidget: { $props: RaiCommunityWidgetElementAttributes }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { RaiWidgetIntrinsicElements } from './jsx'
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace React {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface ElementChildrenAttribute {
|
|
7
|
+
children: {}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface IntrinsicElements extends RaiWidgetIntrinsicElements {}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@returningai/widget-sdk",
|
|
3
|
-
"version": "1.8.
|
|
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",
|
|
@@ -11,6 +11,22 @@
|
|
|
11
11
|
"types": "./dist/types/index.d.ts",
|
|
12
12
|
"import": "./dist/rai-widget.js",
|
|
13
13
|
"default": "./dist/rai-widget.iife.js"
|
|
14
|
+
},
|
|
15
|
+
"./react18": {
|
|
16
|
+
"types": "./dist/types/react18.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./react19": {
|
|
19
|
+
"types": "./dist/types/react19.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
"react18": [
|
|
25
|
+
"dist/types/react18.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"react19": [
|
|
28
|
+
"dist/types/react19.d.ts"
|
|
29
|
+
]
|
|
14
30
|
}
|
|
15
31
|
},
|
|
16
32
|
"files": [
|
|
@@ -25,8 +41,8 @@
|
|
|
25
41
|
"build:banner:min": "vite build --config vite.banner.config.ts --mode production",
|
|
26
42
|
"build:all": "npm run build && npm run build:banner",
|
|
27
43
|
"build:all:min": "npm run build:min && npm run build:banner:min",
|
|
28
|
-
"types": "tsc --emitDeclarationOnly --outDir dist/types && cp src/jsx.d.ts
|
|
29
|
-
"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",
|
|
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:fonts && npm run test:jsx-types",
|
|
30
46
|
"test:host-callback": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/postmessage-host-callback.test.js",
|
|
31
47
|
"test:bundle-readiness": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/bundle-readiness.test.js",
|
|
32
48
|
"test:bundle-runtime-cache": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/bundle-runtime-cache.test.js",
|
|
@@ -38,6 +54,7 @@
|
|
|
38
54
|
"test:auth-session-coordinator": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/auth-session-coordinator.test.js",
|
|
39
55
|
"test:startup-performance": "rm -rf test/.tmp && tsc -p test/tsconfig.json && node test/.tmp/test/startup-performance.test.js",
|
|
40
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",
|
|
41
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",
|
|
42
59
|
"coverage:repowise": "rm -rf coverage && npm run coverage:host-callback && npm run coverage:bundle-readiness && npm run test:jsx-types",
|
|
43
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",
|