@useinsider/guido 3.21.2-beta.b6f3ef8 → 3.21.2-beta.ccc7173

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.
@@ -1,164 +0,0 @@
1
- import { SYNC_MODULE_CLASS as w } from "./useSyncModuleExtractor.js";
2
- import { readRuntimePrefetchState as M } from "../utils/runtimePrefetch.js";
3
- import f from "../package.json.js";
4
- const s = "guido:open:", k = "total", A = [
5
- "setup",
6
- "host_ready",
7
- "migration_start",
8
- "migration_end",
9
- "default_template_start",
10
- "default_template_end",
11
- "timer_clone_start",
12
- "timer_clone_end",
13
- "plugin_start",
14
- "script_ready",
15
- "fonts_sync_ready",
16
- "blocks_config_ready",
17
- "init_editor",
18
- "token_start",
19
- "token_end",
20
- "ready"
21
- ], p = [
22
- ["host_wait", "setup", "host_ready"],
23
- ["migration", "migration_start", "migration_end"],
24
- ["default_template", "default_template_start", "default_template_end"],
25
- ["timer_clone", "timer_clone_start", "timer_clone_end"],
26
- ["script", "plugin_start", "script_ready"],
27
- ["fonts_sync", "script_ready", "fonts_sync_ready"],
28
- ["blocks_config", "fonts_sync_ready", "blocks_config_ready"],
29
- ["editor_config", "blocks_config_ready", "init_editor"],
30
- ["stripo_load", "init_editor", "ready"],
31
- ["token", "token_start", "token_end"]
32
- ], b = (e) => new RegExp(`(?:^|[\\s"'])(?:${e})(?=[\\s"'])`, "g"), N = /<img\b/gi, $ = b(w), C = /\srecommendation-id=/g, O = b("items-block-v2|esd-(?:cart|browsed|purchased)-items-block"), I = "esd-timer-id", g = {
33
- html_bytes: null,
34
- css_bytes: null,
35
- image_count: null,
36
- synced_module_count: null,
37
- recommendation_block_count: null,
38
- items_block_count: null,
39
- has_timers: null,
40
- force_recreate: null
41
- };
42
- let d = null;
43
- const i = (e) => {
44
- try {
45
- e();
46
- } catch (t) {
47
- console.debug("guido:open: metrics step failed", t);
48
- }
49
- }, E = () => window.DD_RUM, y = (e, t) => e === void 0 || t === void 0 ? null : Math.round(t - e), _ = (e, t) => {
50
- var r;
51
- return ((r = e.match(t)) == null ? void 0 : r.length) ?? 0;
52
- }, h = (e) => new TextEncoder().encode(e).length, L = (e) => {
53
- if (!e)
54
- return g;
55
- try {
56
- const { html: t, css: r, forceRecreate: o } = e;
57
- return {
58
- html_bytes: h(t),
59
- css_bytes: h(r),
60
- image_count: _(t, N),
61
- synced_module_count: _(t, $),
62
- recommendation_block_count: _(t, C),
63
- items_block_count: _(t, O),
64
- has_timers: t.includes(I),
65
- force_recreate: o
66
- };
67
- } catch (t) {
68
- return console.debug("guido:open: template weight failed", t), g;
69
- }
70
- }, T = () => {
71
- i(() => {
72
- A.forEach((e) => performance.clearMarks(`${s}${e}`)), [...p.map(([e]) => e), k].forEach((e) => performance.clearMeasures(`${s}${e}`));
73
- });
74
- }, v = (e) => {
75
- const t = {
76
- marks: {},
77
- context: null,
78
- template: null,
79
- scriptPreloaded: null,
80
- runtimePrefetch: null,
81
- wasBackgrounded: document.visibilityState === "hidden",
82
- finished: e,
83
- onVisibilityChange: () => {
84
- document.visibilityState === "hidden" && (t.wasBackgrounded = !0);
85
- }
86
- };
87
- return t;
88
- }, l = (e, t) => {
89
- if (e.finished || e.marks[t] !== void 0)
90
- return;
91
- const r = performance.now();
92
- e.marks[t] = r, e === d && i(() => performance.mark(`${s}${t}`, { startTime: r }));
93
- }, u = (e) => {
94
- e.finished = !0, document.removeEventListener("visibilitychange", e.onVisibilityChange);
95
- }, B = (e, t) => {
96
- const { marks: r } = e, o = p.map(([n, a, c]) => [n, r[a], r[c]]);
97
- o.push([k, r.setup, t]), o.forEach(([n, a, c]) => {
98
- a !== void 0 && c !== void 0 && i(() => performance.measure(`${s}${n}`, { start: a, end: c }));
99
- });
100
- }, D = (e, t, r) => {
101
- const { marks: o, context: n } = e, a = Object.fromEntries(
102
- p.map(([c, R, S]) => [`${c}_ms`, y(o[R], o[S])])
103
- );
104
- return {
105
- outcome: t,
106
- open_ms: y(o.setup, r),
107
- ...a,
108
- script_preloaded: e.scriptPreloaded,
109
- runtime_prefetch: e.runtimePrefetch,
110
- ...L(e.template),
111
- partner_name: (n == null ? void 0 : n.partnerName) ?? null,
112
- product_type: (n == null ? void 0 : n.productType) ?? null,
113
- template_id: (n == null ? void 0 : n.templateId) ?? null,
114
- variation_id: (n == null ? void 0 : n.variationId) ?? null,
115
- guido_version: f.version,
116
- stripo_version: f.guido.stripo.version,
117
- was_backgrounded: e.wasBackgrounded
118
- };
119
- }, m = (e, t) => {
120
- i(() => {
121
- const r = e.marks.ready ?? performance.now(), o = D(e, t, r);
122
- e.template = null, e === d && B(e, r), console.debug("guido:open", o), i(() => {
123
- var n, a;
124
- return (a = (n = E()) == null ? void 0 : n.addAction) == null ? void 0 : a.call(n, "guido_editor_open", o);
125
- });
126
- });
127
- }, P = (e) => ({
128
- mark: (t) => l(e, t),
129
- timed: async (t, r) => {
130
- l(e, `${t}_start`);
131
- const o = await r();
132
- return l(e, `${t}_end`), o;
133
- },
134
- setContext: (t) => {
135
- e.context = t;
136
- },
137
- setTemplate: (t) => {
138
- e.template = t;
139
- },
140
- setScriptPreloaded: (t) => {
141
- e.scriptPreloaded = t;
142
- },
143
- markReady: () => {
144
- e.finished || (l(e, "ready"), u(e), i(() => {
145
- var t, r;
146
- return (r = (t = E()) == null ? void 0 : t.addTiming) == null ? void 0 : r.call(t, "guido_editor_ready");
147
- }), setTimeout(() => m(e, "ready"), 0));
148
- },
149
- markFailed: () => {
150
- e.finished || (u(e), m(e, "error"));
151
- },
152
- dispose: () => {
153
- e.finished || (u(e), m(e, "abandoned")), e === d && (T(), d = null);
154
- }
155
- }), F = () => {
156
- const e = v(!1);
157
- return T(), d = e, i(() => {
158
- e.runtimePrefetch = M();
159
- }), document.addEventListener("visibilitychange", e.onVisibilityChange), l(e, "setup"), P(e);
160
- }, G = () => P(d ?? v(!0));
161
- export {
162
- F as startEditorOpenMetrics,
163
- G as useEditorOpenMetrics
164
- };
@@ -1,4 +0,0 @@
1
- import { prefetchGuidoRuntime as r } from "../utils/runtimePrefetch.js";
2
- export {
3
- r as prefetchGuidoRuntime
4
- };
@@ -1,27 +0,0 @@
1
- export type TimedOpenPhase = 'migration' | 'default_template' | 'timer_clone';
2
- export type OpenPhase = 'setup' | 'host_ready' | `${TimedOpenPhase}_start` | `${TimedOpenPhase}_end` | 'plugin_start' | 'script_ready' | 'fonts_sync_ready' | 'blocks_config_ready' | 'init_editor' | 'token_start' | 'token_end' | 'ready';
3
- export type OpenOutcome = 'ready' | 'error' | 'abandoned';
4
- export interface OpenContext {
5
- partnerName: string;
6
- productType: number;
7
- templateId: string;
8
- variationId: string;
9
- }
10
- export interface OpenTemplate {
11
- html: string;
12
- css: string;
13
- forceRecreate: boolean;
14
- }
15
- export interface EditorOpenMetrics {
16
- mark: (phase: OpenPhase) => void;
17
- timed: <T>(phase: TimedOpenPhase, task: () => Promise<T>) => Promise<T>;
18
- setContext: (context: OpenContext) => void;
19
- setTemplate: (template: OpenTemplate) => void;
20
- setScriptPreloaded: (preloaded: boolean) => void;
21
- markReady: () => void;
22
- markFailed: () => void;
23
- dispose: () => void;
24
- }
25
- export declare const startEditorOpenMetrics: () => EditorOpenMetrics;
26
- /** Binds to the session open at call time, so a remounted editor never writes into its replacement's session. */
27
- export declare const useEditorOpenMetrics: () => EditorOpenMetrics;
@@ -1 +0,0 @@
1
- export { prefetchGuidoRuntime } from '../utils/runtimePrefetch';
@@ -1,4 +0,0 @@
1
- export type RuntimePrefetchState = 'none' | 'pending' | 'done';
2
- export declare const RUNTIME_PREFETCH_ATTRIBUTE = "data-guido-prefetch";
3
- export declare const prefetchGuidoRuntime: () => void;
4
- export declare const readRuntimePrefetchState: () => RuntimePrefetchState;
@@ -1,2 +0,0 @@
1
- /** Null when package.json does not pin `guido.stripo.version`. */
2
- export declare const getStripoRuntimeBaseUrl: () => string | null;
@@ -1,9 +0,0 @@
1
- const s = "2.81.1", n = ["UIEditor.js", "zone.js", "styles-BWH3PMR4.css", "polyfills-FF3RLU5F.js", "main-5LCHF56A.js", "chunk-2HYLRI4G.js", "chunk-4SN7BSQN.js", "chunk-5IY7ZG3R.js", "chunk-62K3AMOD.js", "chunk-GK543IRH.js", "chunk-L2EPGQ76.js", "chunk-LXS5IGCQ.js", "chunk-PNWIGF4L.js", "chunk-S2TYCIH3.js", "chunk-S5UZ4LUK.js", "chunk-V2AGQPVL.js", "chunk-XZ6MUAN5.js", "chunk-ZPL4VL4O.js", "assets/css/uiEditor.css", "assets/i18n/en.json", "assets/icons/ui-editor-icons.sprite.svg", "assets/icons/ui-editor-icons.map.json", "assets/imageeditor/scripts.min.js", "assets/imageeditor/assets/icons/merged.svg"], i = {
2
- version: s,
3
- files: n
4
- };
5
- export {
6
- i as default,
7
- n as files,
8
- s as version
9
- };
@@ -1,26 +0,0 @@
1
- import s from "../static/stripo-runtime-manifest.json.js";
2
- import { getStripoRuntimeBaseUrl as c } from "./stripoRuntime.js";
3
- const r = "data-guido-prefetch", d = "pending", o = "settled", i = `link[${r}]`, u = ["slow-2g", "2g"], l = /\.(?:js|json)$/, a = () => document.getElementById("UiEditorScript") !== null || window.UIEditor !== void 0, E = () => {
4
- const { connection: e } = navigator;
5
- return (e == null ? void 0 : e.saveData) === !0 || u.includes((e == null ? void 0 : e.effectiveType) ?? "");
6
- }, m = (e) => {
7
- const t = document.createElement("link"), n = () => t.setAttribute(r, o);
8
- t.rel = "prefetch", t.href = e, l.test(e) && t.setAttribute("crossorigin", "anonymous"), t.setAttribute(r, d), t.addEventListener("load", n, { once: !0 }), t.addEventListener("error", n, { once: !0 }), document.head.appendChild(t);
9
- }, T = () => {
10
- try {
11
- const e = c(), t = document.querySelector(i) !== null;
12
- if (!e || t || a() || E())
13
- return;
14
- s.files.forEach((n) => m(`${e}${n}`));
15
- } catch (e) {
16
- console.debug("guido: runtime prefetch skipped", e);
17
- }
18
- }, g = () => {
19
- const e = Array.from(document.querySelectorAll(i));
20
- return e.length ? e.every((t) => t.getAttribute(r) === o) ? "done" : "pending" : "none";
21
- };
22
- export {
23
- r as RUNTIME_PREFETCH_ATTRIBUTE,
24
- T as prefetchGuidoRuntime,
25
- g as readRuntimePrefetchState
26
- };
@@ -1,9 +0,0 @@
1
- import r from "../package.json.js";
2
- const e = "https://email-static.useinsider.com/guido/", n = () => {
3
- var s;
4
- const t = r.guido, o = (s = t == null ? void 0 : t.stripo) == null ? void 0 : s.version;
5
- return o ? `${e}${o}/` : null;
6
- };
7
- export {
8
- n as getStripoRuntimeBaseUrl
9
- };