@joryio/web-sdk 1.4.0-beta.1 → 1.4.0-beta.4
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 +45 -1
- package/README.md +1 -1
- package/dist/cards-ui/card-feed-view.d.ts +4 -0
- package/dist/cards-ui/card-feed-view.d.ts.map +1 -0
- package/dist/cards-ui/index.d.ts +4 -0
- package/dist/cards-ui/index.d.ts.map +1 -0
- package/dist/core/cards-ui-contract.d.ts +30 -0
- package/dist/core/cards-ui-contract.d.ts.map +1 -0
- package/dist/core/cards.d.ts +130 -0
- package/dist/core/cards.d.ts.map +1 -0
- package/dist/core/config.d.ts +21 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/editor-gate.d.ts +47 -0
- package/dist/core/editor-gate.d.ts.map +1 -0
- package/dist/core/flags.d.ts +73 -0
- package/dist/core/flags.d.ts.map +1 -0
- package/dist/core/inapp.d.ts +13 -1
- package/dist/core/inapp.d.ts.map +1 -1
- package/dist/core/links.d.ts +27 -0
- package/dist/core/links.d.ts.map +1 -0
- package/dist/core/network.d.ts.map +1 -1
- package/dist/core/page-context.d.ts +101 -0
- package/dist/core/page-context.d.ts.map +1 -0
- package/dist/core/page-edits.d.ts +129 -0
- package/dist/core/page-edits.d.ts.map +1 -0
- package/dist/core/placements.d.ts +218 -0
- package/dist/core/placements.d.ts.map +1 -0
- package/dist/core/sdk-host-files.d.ts +5 -0
- package/dist/core/sdk-host-files.d.ts.map +1 -0
- package/dist/core/sdk.d.ts +36 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/editor/index.d.ts +4 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/visual-editor.d.ts +39 -0
- package/dist/editor/visual-editor.d.ts.map +1 -0
- package/dist/index.d.mts +201 -3
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/joryio-cards-ui.min.js +7 -0
- package/dist/joryio-cards-ui.min.js.map +1 -0
- package/dist/joryio-editor.min.js +7 -0
- package/dist/joryio-editor.min.js.map +1 -0
- package/dist/joryio-sw.js +1 -1
- package/dist/joryio.cjs.js +7200 -3513
- package/dist/joryio.min.js +2 -2
- package/dist/joryio.min.js.map +1 -1
- package/dist/joryio.mjs +7192 -3514
- package/dist/joryio.umd.js +7200 -3513
- package/package.json +4 -1
- package/src/cards-ui/card-feed-view.ts +249 -0
- package/src/cards-ui/index.ts +26 -0
- package/src/core/cards-ui-contract.ts +58 -0
- package/src/core/cards.ts +843 -0
- package/src/core/config.ts +86 -2
- package/src/core/editor-gate.ts +158 -0
- package/src/core/flags.ts +372 -0
- package/src/core/inapp.ts +283 -152
- package/src/core/links.ts +104 -0
- package/src/core/network.ts +5 -2
- package/src/core/page-context.ts +460 -0
- package/src/core/page-edits.ts +1036 -0
- package/src/core/placements.ts +1431 -0
- package/src/core/sdk-host-files.ts +93 -0
- package/src/core/sdk.ts +378 -1
- package/src/editor/index.ts +27 -0
- package/src/editor/visual-editor.ts +301 -0
- package/src/index.ts +33 -0
- package/src/snippet/loader.js +25 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The point-and-click picker (BACKLOG D444 Phase 4,
|
|
3
|
+
* docs/PLACEMENTS_WEBSITE_LAYER.md 3) - the body of `joryio-editor.min.js`.
|
|
4
|
+
*
|
|
5
|
+
* The handshake lives in the core bundle (src/core/editor-gate.ts): this
|
|
6
|
+
* file is loaded, and this class constructed, only once the server vouched
|
|
7
|
+
* for the editor token, with the dashboard origin the token names. From then
|
|
8
|
+
* on it accepts messages only from that origin and that opener window, and
|
|
9
|
+
* posts only to them. It lets the person point at an element, computes a
|
|
10
|
+
* robust selector, offers the operations that fit, and posts
|
|
11
|
+
* `joryio:editor-pick` back.
|
|
12
|
+
*
|
|
13
|
+
* It reads the page the person already sees and writes nothing to it but its
|
|
14
|
+
* own highlight and panel (built from text nodes, never HTML). No free-form
|
|
15
|
+
* DOM editing: a pick is a selector + one of the five page-edit operations.
|
|
16
|
+
*/
|
|
17
|
+
import type { Logger } from '../utils/logger';
|
|
18
|
+
import { isSafeSelector, isSafeEditUrl, type PageEditOperation } from '../core/page-edits';
|
|
19
|
+
import { EDITOR_MESSAGES } from '../core/editor-gate';
|
|
20
|
+
|
|
21
|
+
export { EDITOR_MESSAGES };
|
|
22
|
+
|
|
23
|
+
/** Attributes that name an element on purpose, most stable first. */
|
|
24
|
+
const NAMING_ATTRIBUTES = ['data-joryio-id', 'data-testid', 'data-test', 'data-qa', 'data-cy', 'data-id', 'name'];
|
|
25
|
+
const PLACEMENT_KEY_PATTERN = /^[a-z0-9][a-z0-9_]{0,63}$/;
|
|
26
|
+
|
|
27
|
+
/** CSS.escape, for browsers (and test DOMs) without it. */
|
|
28
|
+
export function cssEscape(value: string): string {
|
|
29
|
+
const css = (globalThis as any).CSS;
|
|
30
|
+
if (css && typeof css.escape === 'function') return css.escape(value);
|
|
31
|
+
let out = '';
|
|
32
|
+
for (let i = 0; i < value.length; i++) {
|
|
33
|
+
const ch = value[i];
|
|
34
|
+
const code = value.charCodeAt(i);
|
|
35
|
+
if (code === 0) out += '\uFFFD';
|
|
36
|
+
else if (/[0-9]/.test(ch) && (i === 0 || (i === 1 && value[0] === '-'))) out += `\\${code.toString(16)} `;
|
|
37
|
+
else if (/[A-Za-z0-9_-]/.test(ch) || code >= 0x80) out += ch;
|
|
38
|
+
else out += `\\${ch}`;
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const unique = (doc: Document, selector: string, el: Element): boolean => {
|
|
44
|
+
try {
|
|
45
|
+
const hits = doc.querySelectorAll(selector);
|
|
46
|
+
return hits.length === 1 && hits[0] === el;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** An id that looks generated (long digit runs, framework hashes) changes between builds; skip it. */
|
|
53
|
+
const stableId = (id: string) => !!id && id.length <= 64 && !/\d{4,}/.test(id) && !/^(ember|react|radix|headlessui|mui)[-_:]/i.test(id) && !/:/.test(id);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A selector that finds this element and only it, preferring what the site
|
|
57
|
+
* named on purpose: an id, then a naming data attribute, then a path of
|
|
58
|
+
* tag + nth-of-type from the nearest named ancestor (or the body).
|
|
59
|
+
*/
|
|
60
|
+
export function robustSelector(el: Element): string | null {
|
|
61
|
+
const doc = el.ownerDocument;
|
|
62
|
+
if (!doc) return null;
|
|
63
|
+
const named = (node: Element): string | null => {
|
|
64
|
+
if (stableId(node.id)) {
|
|
65
|
+
const s = `#${cssEscape(node.id)}`;
|
|
66
|
+
if (unique(doc, s, node)) return s;
|
|
67
|
+
}
|
|
68
|
+
for (const attr of NAMING_ATTRIBUTES) {
|
|
69
|
+
const v = node.getAttribute(attr);
|
|
70
|
+
if (!v || v.length > 100) continue;
|
|
71
|
+
const s = `${node.tagName.toLowerCase()}[${attr}="${v.replace(/["\\]/g, '\\$&')}"]`;
|
|
72
|
+
if (unique(doc, s, node)) return s;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
76
|
+
const own = named(el);
|
|
77
|
+
if (own) return isSafeSelector(own) ? own : null;
|
|
78
|
+
const parts: string[] = [];
|
|
79
|
+
let node: Element | null = el;
|
|
80
|
+
while (node && node !== doc.body && node !== doc.documentElement) {
|
|
81
|
+
const anchor = parts.length ? named(node) : null;
|
|
82
|
+
if (anchor) {
|
|
83
|
+
parts.unshift(anchor);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
const tag = node.tagName.toLowerCase();
|
|
87
|
+
const parent: Element | null = node.parentElement;
|
|
88
|
+
const same = parent ? Array.from(parent.children).filter((c) => c.tagName === node!.tagName) : [];
|
|
89
|
+
parts.unshift(same.length > 1 ? `${tag}:nth-of-type(${same.indexOf(node) + 1})` : tag);
|
|
90
|
+
node = parent;
|
|
91
|
+
if (node === doc.body) parts.unshift('body');
|
|
92
|
+
}
|
|
93
|
+
const selector = parts.join(' > ');
|
|
94
|
+
return selector && isSafeSelector(selector) && unique(doc, selector, el) ? selector : null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The operations that fit an element: an image can change its picture, a link its address. */
|
|
98
|
+
export function operationsFor(el: Element): PageEditOperation[] {
|
|
99
|
+
const ops: PageEditOperation[] = [];
|
|
100
|
+
if (el.tagName !== 'IMG' && (el.textContent || '').trim()) ops.push('replace_text');
|
|
101
|
+
if (el.tagName === 'IMG') ops.push('replace_image');
|
|
102
|
+
if (el.tagName === 'A') ops.push('replace_link');
|
|
103
|
+
ops.push('hide', 'insert_placement');
|
|
104
|
+
return ops;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface EditorPick {
|
|
108
|
+
type: typeof EDITOR_MESSAGES.PICK;
|
|
109
|
+
selector: string;
|
|
110
|
+
operation: PageEditOperation;
|
|
111
|
+
value?: string;
|
|
112
|
+
placementKey?: string;
|
|
113
|
+
position?: 'before' | 'after' | 'prepend' | 'append';
|
|
114
|
+
tag: string;
|
|
115
|
+
text: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class VisualEditor {
|
|
119
|
+
private listeners: Array<() => void> = [];
|
|
120
|
+
private highlight: HTMLElement | null = null;
|
|
121
|
+
private panel: HTMLElement | null = null;
|
|
122
|
+
private selected: Element | null = null;
|
|
123
|
+
private active = false;
|
|
124
|
+
|
|
125
|
+
constructor(
|
|
126
|
+
private dashboardOrigin: string,
|
|
127
|
+
private opener: Window,
|
|
128
|
+
private logger: Logger,
|
|
129
|
+
private onStop: () => void = () => undefined,
|
|
130
|
+
) {}
|
|
131
|
+
|
|
132
|
+
/** The token was vouched for by the server: show the picker. */
|
|
133
|
+
start(): void {
|
|
134
|
+
if (this.active) return;
|
|
135
|
+
this.active = true;
|
|
136
|
+
const onMessage = (e: MessageEvent) => {
|
|
137
|
+
const data = e.data as { type?: string } | null;
|
|
138
|
+
if (!data || typeof data.type !== 'string') return;
|
|
139
|
+
if (e.origin !== this.dashboardOrigin || e.source !== this.opener) return;
|
|
140
|
+
if (data.type === EDITOR_MESSAGES.CLOSE) this.stop();
|
|
141
|
+
};
|
|
142
|
+
window.addEventListener('message', onMessage);
|
|
143
|
+
this.listeners.push(() => window.removeEventListener('message', onMessage));
|
|
144
|
+
this.activate();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
isActive(): boolean {
|
|
148
|
+
return this.active;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
stop(): void {
|
|
152
|
+
if (!this.active) return;
|
|
153
|
+
this.send({ type: EDITOR_MESSAGES.CLOSED });
|
|
154
|
+
this.active = false;
|
|
155
|
+
for (const off of this.listeners.splice(0)) off();
|
|
156
|
+
this.highlight?.remove();
|
|
157
|
+
this.panel?.remove();
|
|
158
|
+
this.highlight = this.panel = null;
|
|
159
|
+
this.selected = null;
|
|
160
|
+
try {
|
|
161
|
+
this.onStop();
|
|
162
|
+
} catch (error) {
|
|
163
|
+
this.logger.debug('Joryio editor stop callback failed', error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private send(message: Record<string, unknown>): void {
|
|
168
|
+
if (!this.active) return;
|
|
169
|
+
try {
|
|
170
|
+
this.opener.postMessage(message, this.dashboardOrigin);
|
|
171
|
+
} catch {
|
|
172
|
+
/* the dashboard tab closed */
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private activate(): void {
|
|
177
|
+
const doc = document;
|
|
178
|
+
const highlight = doc.createElement('div');
|
|
179
|
+
highlight.setAttribute('data-joryio-editor', 'highlight');
|
|
180
|
+
highlight.style.cssText = 'position:fixed;pointer-events:none;z-index:2147483646;border:2px solid #14b8a6;background:rgba(20,184,166,.12);border-radius:3px;display:none';
|
|
181
|
+
const panel = doc.createElement('div');
|
|
182
|
+
panel.setAttribute('data-joryio-editor', 'panel');
|
|
183
|
+
panel.style.cssText = 'position:fixed;left:16px;right:16px;bottom:16px;z-index:2147483647;max-width:560px;margin:0 auto;background:#0f172a;color:#fff;font:14px/1.4 system-ui,sans-serif;padding:12px 14px;border-radius:10px;box-shadow:0 8px 30px rgba(0,0,0,.3)';
|
|
184
|
+
panel.textContent = 'Joryio editor - click an element on the page. Esc to finish.';
|
|
185
|
+
doc.body.appendChild(highlight);
|
|
186
|
+
doc.body.appendChild(panel);
|
|
187
|
+
this.highlight = highlight;
|
|
188
|
+
this.panel = panel;
|
|
189
|
+
const inEditor = (t: EventTarget | null) => t instanceof Element && !!t.closest('[data-joryio-editor]');
|
|
190
|
+
const onMove = (e: MouseEvent) => {
|
|
191
|
+
if (this.selected || inEditor(e.target)) return;
|
|
192
|
+
this.outline(e.target instanceof Element ? e.target : null);
|
|
193
|
+
};
|
|
194
|
+
const onClick = (e: MouseEvent) => {
|
|
195
|
+
if (inEditor(e.target)) return;
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
if (e.target instanceof Element) this.select(e.target);
|
|
199
|
+
};
|
|
200
|
+
const onKey = (e: KeyboardEvent) => {
|
|
201
|
+
if (e.key === 'Escape') this.selected ? this.unselect() : this.stop();
|
|
202
|
+
};
|
|
203
|
+
doc.addEventListener('mousemove', onMove, true);
|
|
204
|
+
doc.addEventListener('click', onClick, true);
|
|
205
|
+
doc.addEventListener('keydown', onKey, true);
|
|
206
|
+
this.listeners.push(
|
|
207
|
+
() => doc.removeEventListener('mousemove', onMove, true),
|
|
208
|
+
() => doc.removeEventListener('click', onClick, true),
|
|
209
|
+
() => doc.removeEventListener('keydown', onKey, true),
|
|
210
|
+
);
|
|
211
|
+
this.send({ type: EDITOR_MESSAGES.ACTIVE, url: `${location.origin}${location.pathname}` });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private outline(el: Element | null): void {
|
|
215
|
+
if (!this.highlight) return;
|
|
216
|
+
if (!el || el === document.body || el === document.documentElement) {
|
|
217
|
+
this.highlight.style.display = 'none';
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const r = el.getBoundingClientRect();
|
|
221
|
+
Object.assign(this.highlight.style, { display: 'block', top: `${r.top}px`, left: `${r.left}px`, width: `${r.width}px`, height: `${r.height}px` });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private unselect(): void {
|
|
225
|
+
this.selected = null;
|
|
226
|
+
if (this.panel) this.panel.textContent = 'Joryio editor - click an element on the page. Esc to finish.';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** The element is chosen: its selector and the operations that fit it, as buttons. */
|
|
230
|
+
select(el: Element): void {
|
|
231
|
+
const selector = robustSelector(el);
|
|
232
|
+
if (!this.panel) return;
|
|
233
|
+
if (!selector) {
|
|
234
|
+
this.panel.textContent = 'This element has no stable selector. Choose its parent or another element.';
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this.selected = el;
|
|
238
|
+
this.outline(el);
|
|
239
|
+
const panel = this.panel;
|
|
240
|
+
panel.textContent = '';
|
|
241
|
+
const line = (text: string, mono = false) => {
|
|
242
|
+
const p = document.createElement('div');
|
|
243
|
+
p.textContent = text;
|
|
244
|
+
if (mono) p.style.cssText = 'font-family:ui-monospace,monospace;font-size:12px;opacity:.8;word-break:break-all;margin:4px 0 8px';
|
|
245
|
+
panel.appendChild(p);
|
|
246
|
+
};
|
|
247
|
+
line(`<${el.tagName.toLowerCase()}> ${(el.textContent || '').trim().slice(0, 60)}`);
|
|
248
|
+
line(selector, true);
|
|
249
|
+
const input = document.createElement('input');
|
|
250
|
+
input.setAttribute('data-joryio-editor', 'value');
|
|
251
|
+
input.style.cssText = 'width:100%;box-sizing:border-box;padding:6px 8px;border-radius:6px;border:0;margin-bottom:8px;color:#0f172a';
|
|
252
|
+
input.placeholder = 'New text, https:// address or placement key';
|
|
253
|
+
panel.appendChild(input);
|
|
254
|
+
const row = document.createElement('div');
|
|
255
|
+
row.style.cssText = 'display:flex;flex-wrap:wrap;gap:6px';
|
|
256
|
+
const labels: Record<PageEditOperation, string> = {
|
|
257
|
+
replace_text: 'Replace text',
|
|
258
|
+
replace_image: 'Replace image',
|
|
259
|
+
replace_link: 'Replace link',
|
|
260
|
+
hide: 'Hide',
|
|
261
|
+
insert_placement: 'Insert placement after',
|
|
262
|
+
};
|
|
263
|
+
for (const op of operationsFor(el)) {
|
|
264
|
+
const b = document.createElement('button');
|
|
265
|
+
b.type = 'button';
|
|
266
|
+
b.textContent = labels[op];
|
|
267
|
+
b.setAttribute('data-joryio-op', op);
|
|
268
|
+
b.style.cssText = 'padding:6px 10px;border-radius:6px;border:0;background:#14b8a6;color:#fff;cursor:pointer';
|
|
269
|
+
b.addEventListener('click', (e) => {
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
e.stopPropagation();
|
|
272
|
+
this.pick(el, selector, op, input.value.trim());
|
|
273
|
+
});
|
|
274
|
+
row.appendChild(b);
|
|
275
|
+
}
|
|
276
|
+
panel.appendChild(row);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Validate like the server does, then hand the pick to the dashboard. */
|
|
280
|
+
pick(el: Element, selector: string, operation: PageEditOperation, value: string): boolean {
|
|
281
|
+
const base: EditorPick = { type: EDITOR_MESSAGES.PICK, selector, operation, tag: el.tagName.toLowerCase(), text: (el.textContent || '').trim().slice(0, 200) };
|
|
282
|
+
let msg: EditorPick | null = null;
|
|
283
|
+
if (operation === 'hide') msg = base;
|
|
284
|
+
else if (operation === 'replace_text') msg = value || base.text ? { ...base, value: (value || base.text).slice(0, 2000) } : null;
|
|
285
|
+
else if (operation === 'replace_image' || operation === 'replace_link') msg = isSafeEditUrl(value) ? { ...base, value } : null;
|
|
286
|
+
else if (operation === 'insert_placement') msg = PLACEMENT_KEY_PATTERN.test(value) ? { ...base, placementKey: value, position: 'after' } : null;
|
|
287
|
+
if (!msg) {
|
|
288
|
+
if (this.panel) {
|
|
289
|
+
const warn = document.createElement('div');
|
|
290
|
+
warn.style.cssText = 'margin-top:6px;color:#fca5a5';
|
|
291
|
+
warn.textContent =
|
|
292
|
+
operation === 'insert_placement' ? 'Enter a placement key (lowercase letters, digits, _).' : 'Enter an address starting with https:// (or http://).';
|
|
293
|
+
this.panel.appendChild(warn);
|
|
294
|
+
}
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
this.send(msg as unknown as Record<string, unknown>);
|
|
298
|
+
this.unselect();
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -71,6 +71,39 @@ export { SDK_VERSION } from './core/config';
|
|
|
71
71
|
// (the same constant on every Joryio SDK).
|
|
72
72
|
export { IN_APP_DISPLAY_DWELL_MS } from './core/inapp';
|
|
73
73
|
|
|
74
|
+
// Placements: spots inside the page filled per visitor (the same names and
|
|
75
|
+
// values on every Joryio SDK).
|
|
76
|
+
export { PLACEMENT_VIEWABLE_FRACTION, PLACEMENT_MIN_REFRESH_SECONDS } from './core/placements';
|
|
77
|
+
export { PLACEMENT_PRODUCT_ELEMENT_PREFIX, PLACEMENT_PRODUCT_CARD_WIDTH, placementProductElementId } from './core/placements';
|
|
78
|
+
export type {
|
|
79
|
+
Placement,
|
|
80
|
+
PlacementItem,
|
|
81
|
+
PlacementHandle,
|
|
82
|
+
PlacementContent,
|
|
83
|
+
PlacementEmptyBehavior,
|
|
84
|
+
PlacementItemKind,
|
|
85
|
+
InsertPlacementOptions,
|
|
86
|
+
PlacementsUpdatedCallback,
|
|
87
|
+
} from './core/placements';
|
|
88
|
+
|
|
89
|
+
// Links: the site-wide link handler (the same names and source values on every Joryio SDK).
|
|
90
|
+
export type { JoryioLink, JoryioLinkSource, JoryioLinkHandler } from './core/links';
|
|
91
|
+
|
|
92
|
+
// Content cards: the person's feed (the same names and values on every Joryio SDK).
|
|
93
|
+
export { CARD_MIN_REFRESH_SECONDS, CARD_FEED_TTL_SECONDS } from './core/cards';
|
|
94
|
+
export type {
|
|
95
|
+
Card,
|
|
96
|
+
CardFeed,
|
|
97
|
+
CardStateScope,
|
|
98
|
+
CardFeedHandle,
|
|
99
|
+
GetCardsOptions,
|
|
100
|
+
MountCardFeedOptions,
|
|
101
|
+
CardsUpdatedCallback,
|
|
102
|
+
} from './core/cards';
|
|
103
|
+
// Feature flags + remote config (the same names and values on every Joryio SDK).
|
|
104
|
+
export { FLAGS_MIN_REFRESH_SECONDS, FLAG_SYNC_PUSH_VALUE } from './core/flags';
|
|
105
|
+
export type { FlagResult, FlagValueType, FlagReason, FlagsUpdatedCallback } from './core/flags';
|
|
106
|
+
|
|
74
107
|
// Default export for convenience
|
|
75
108
|
export default JoryioSDK;
|
|
76
109
|
|
package/src/snippet/loader.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
* <script>
|
|
10
|
-
* !function(){var e=window.joryio=window.joryio||[];if(!e.initialize)if(e.invoked)window.console&&console.error&&console.error("Joryio snippet included twice.");else{e.invoked=!0,e.methods=["init","track","identify","identifyFromLink","addAlias","setAttributes","setAttribute","incrementAttribute","unsetAttribute","addToArray","removeFromArray","reset","resetTo","flush","optOut","optIn","updateConsent","getTrackingConsent","isUserOptedOut","setSdkAuthenticationToken","setSdkAuthenticationErrorCallback","setStorefrontIdentityToken","setStorefrontIdentityTokenProvider","getAnonymousId","getUserId","ready","getIdentity","getSessionInfo","getUTMData","updateUTM","syncInAppCampaigns","getInAppCampaigns","displayInAppCampaign","dismissInAppMessage","trackInAppConversion","ecommerce","wipeData","destroy"],e.keep=["init","optOut","optIn","updateConsent","wipeData"],e.factory=function(t){return function(){var n=Array.prototype.slice.call(arguments);if(n.unshift(t),e.length>=1e3)for(var i=0;i<e.length;i++)if(e.keep.indexOf(e[i][0])<0){e.splice(i,1);break}return e.push(n),/^(get|is)[A-Z]/.test(t)?void 0:e}};for(var t=0;t<e.methods.length;t++){var n=e.methods[t];e[n]=e.factory(n)}e.load=function(e){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://sdk.joryio.com/web/1/joryio.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},e.load()}}();
|
|
10
|
+
* !function(){var e=window.joryio=window.joryio||[];if(!e.initialize)if(e.invoked)window.console&&console.error&&console.error("Joryio snippet included twice.");else{e.invoked=!0,e.methods=["init","track","identify","identifyFromLink","addAlias","setAttributes","setAttribute","incrementAttribute","unsetAttribute","addToArray","removeFromArray","reset","resetTo","flush","optOut","optIn","updateConsent","getTrackingConsent","isUserOptedOut","setSdkAuthenticationToken","setSdkAuthenticationErrorCallback","setStorefrontIdentityToken","setStorefrontIdentityTokenProvider","getAnonymousId","getUserId","ready","getIdentity","getSessionInfo","getUTMData","updateUTM","syncInAppCampaigns","getInAppCampaigns","displayInAppCampaign","dismissInAppMessage","trackInAppConversion","insertPlacement","getPlacements","refreshPlacements","onPlacementsUpdated","setPageVariables","getCards","getUnreadCardCount","markCardViewed","markCardRead","markCardClicked","dismissCard","refreshCards","onCardsUpdated","mountCardFeed","setLinkHandler","clearLinkHandler","getFlag","getBoolFlag","getStringFlag","getNumberFlag","getJsonFlag","getAllFlags","refreshFlags","onFlagsUpdated","ecommerce","wipeData","destroy"],e.keep=["init","optOut","optIn","updateConsent","wipeData"],e.factory=function(t){return function(){var n=Array.prototype.slice.call(arguments);if(n.unshift(t),e.length>=1e3)for(var i=0;i<e.length;i++)if(e.keep.indexOf(e[i][0])<0){e.splice(i,1);break}return e.push(n),/^(get|is)[A-Z]/.test(t)?void 0:e}};for(var t=0;t<e.methods.length;t++){var n=e.methods[t];e[n]=e.factory(n)}e.load=function(e){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://sdk.joryio.com/web/1/joryio.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},e.load()}}();
|
|
11
11
|
* joryio.init({ sdkKey: 'YOUR_SDK_KEY' });
|
|
12
12
|
* </script>
|
|
13
13
|
*
|
|
@@ -81,6 +81,30 @@
|
|
|
81
81
|
'displayInAppCampaign',
|
|
82
82
|
'dismissInAppMessage',
|
|
83
83
|
'trackInAppConversion',
|
|
84
|
+
'insertPlacement',
|
|
85
|
+
'getPlacements',
|
|
86
|
+
'refreshPlacements',
|
|
87
|
+
'onPlacementsUpdated',
|
|
88
|
+
'setPageVariables',
|
|
89
|
+
'getCards',
|
|
90
|
+
'getUnreadCardCount',
|
|
91
|
+
'markCardViewed',
|
|
92
|
+
'markCardRead',
|
|
93
|
+
'markCardClicked',
|
|
94
|
+
'dismissCard',
|
|
95
|
+
'refreshCards',
|
|
96
|
+
'onCardsUpdated',
|
|
97
|
+
'mountCardFeed',
|
|
98
|
+
'setLinkHandler',
|
|
99
|
+
'clearLinkHandler',
|
|
100
|
+
'getFlag',
|
|
101
|
+
'getBoolFlag',
|
|
102
|
+
'getStringFlag',
|
|
103
|
+
'getNumberFlag',
|
|
104
|
+
'getJsonFlag',
|
|
105
|
+
'getAllFlags',
|
|
106
|
+
'refreshFlags',
|
|
107
|
+
'onFlagsUpdated',
|
|
84
108
|
'ecommerce',
|
|
85
109
|
'wipeData',
|
|
86
110
|
'destroy'
|