@perspective-ai/sdk 1.0.0 → 1.1.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.
- package/dist/browser.cjs +8 -43
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +8 -43
- package/dist/browser.js.map +1 -1
- package/dist/cdn/perspective.global.js +7 -7
- package/dist/cdn/perspective.global.js.map +1 -1
- package/dist/constants.cjs +3 -38
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -16
- package/dist/constants.d.ts +2 -16
- package/dist/constants.js +4 -38
- package/dist/constants.js.map +1 -1
- package/dist/index.cjs +8 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +5 -49
- package/src/iframe.test.ts +115 -0
- package/src/iframe.ts +8 -9
package/dist/browser.cjs
CHANGED
|
@@ -38,7 +38,7 @@ __export(browser_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(browser_exports);
|
|
39
39
|
|
|
40
40
|
// src/constants.ts
|
|
41
|
-
var SDK_VERSION = "1.
|
|
41
|
+
var SDK_VERSION = "1.1.0";
|
|
42
42
|
var FEATURES = {
|
|
43
43
|
RESIZE: 1 << 0,
|
|
44
44
|
// 0b0001
|
|
@@ -51,21 +51,6 @@ var FEATURES = {
|
|
|
51
51
|
};
|
|
52
52
|
var CURRENT_FEATURES = FEATURES.RESIZE | FEATURES.THEME_SYNC | FEATURES.ANON_ID | FEATURES.SCROLLBAR_STYLES;
|
|
53
53
|
var PARAM_KEYS = {
|
|
54
|
-
// User identification
|
|
55
|
-
email: "email",
|
|
56
|
-
name: "name",
|
|
57
|
-
// Navigation
|
|
58
|
-
returnUrl: "returnUrl",
|
|
59
|
-
// Interview behavior
|
|
60
|
-
voice: "voice",
|
|
61
|
-
scroll: "scroll",
|
|
62
|
-
hideProgress: "hideProgress",
|
|
63
|
-
hideGreeting: "hideGreeting",
|
|
64
|
-
hideBranding: "hideBranding",
|
|
65
|
-
// Interview mode & auth
|
|
66
|
-
mode: "mode",
|
|
67
|
-
invite: "invite",
|
|
68
|
-
// System (internal)
|
|
69
54
|
embed: "embed",
|
|
70
55
|
embedType: "embed_type",
|
|
71
56
|
theme: "theme"
|
|
@@ -82,26 +67,9 @@ var BRAND_KEYS = {
|
|
|
82
67
|
darkBg: "brand.dark.bg",
|
|
83
68
|
darkText: "brand.dark.text"
|
|
84
69
|
};
|
|
85
|
-
var UTM_PARAMS = [
|
|
86
|
-
"utm_source",
|
|
87
|
-
"utm_medium",
|
|
88
|
-
"utm_campaign",
|
|
89
|
-
"utm_term",
|
|
90
|
-
"utm_content"
|
|
91
|
-
];
|
|
92
70
|
var RESERVED_PARAMS = /* @__PURE__ */ new Set([
|
|
93
|
-
PARAM_KEYS
|
|
94
|
-
|
|
95
|
-
PARAM_KEYS.theme,
|
|
96
|
-
BRAND_KEYS.primary,
|
|
97
|
-
BRAND_KEYS.secondary,
|
|
98
|
-
BRAND_KEYS.bg,
|
|
99
|
-
BRAND_KEYS.text,
|
|
100
|
-
BRAND_KEYS.darkPrimary,
|
|
101
|
-
BRAND_KEYS.darkSecondary,
|
|
102
|
-
BRAND_KEYS.darkBg,
|
|
103
|
-
BRAND_KEYS.darkText,
|
|
104
|
-
...UTM_PARAMS
|
|
71
|
+
...Object.values(PARAM_KEYS),
|
|
72
|
+
...Object.values(BRAND_KEYS)
|
|
105
73
|
]);
|
|
106
74
|
var DATA_ATTRS = {
|
|
107
75
|
widget: "data-perspective-widget",
|
|
@@ -141,8 +109,6 @@ var ERROR_CODES = {
|
|
|
141
109
|
UNKNOWN: "UNKNOWN"
|
|
142
110
|
};
|
|
143
111
|
var PARAM_VALUES = {
|
|
144
|
-
disabled: "0",
|
|
145
|
-
enabled: "1",
|
|
146
112
|
true: "true",
|
|
147
113
|
false: "false"
|
|
148
114
|
};
|
|
@@ -279,13 +245,12 @@ function getOrCreateAnonId() {
|
|
|
279
245
|
return crypto.randomUUID();
|
|
280
246
|
}
|
|
281
247
|
}
|
|
282
|
-
function
|
|
248
|
+
function getParentSearchParams() {
|
|
283
249
|
if (!hasDom()) return {};
|
|
284
250
|
const params = {};
|
|
285
251
|
const searchParams = new URLSearchParams(window.location.search);
|
|
286
|
-
for (const key of
|
|
287
|
-
|
|
288
|
-
if (value) {
|
|
252
|
+
for (const [key, value] of searchParams.entries()) {
|
|
253
|
+
if (!RESERVED_PARAMS.has(key)) {
|
|
289
254
|
params[key] = value;
|
|
290
255
|
}
|
|
291
256
|
}
|
|
@@ -308,8 +273,8 @@ function buildIframeUrl(researchId, type, host, customParams, brand, themeOverri
|
|
|
308
273
|
} else {
|
|
309
274
|
url.searchParams.set(PARAM_KEYS.theme, themeOverride || THEME_VALUES.light);
|
|
310
275
|
}
|
|
311
|
-
const
|
|
312
|
-
for (const [key, value] of Object.entries(
|
|
276
|
+
const parentParams = getParentSearchParams();
|
|
277
|
+
for (const [key, value] of Object.entries(parentParams)) {
|
|
313
278
|
url.searchParams.set(key, value);
|
|
314
279
|
}
|
|
315
280
|
const setColor = (key, color) => {
|