@v-tilt/browser 1.10.10 → 1.12.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.
Files changed (91) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.js +1 -1
  4. package/dist/array.full.js.map +1 -1
  5. package/dist/array.js +1 -1
  6. package/dist/array.js.map +1 -1
  7. package/dist/array.no-external.js +1 -1
  8. package/dist/array.no-external.js.map +1 -1
  9. package/dist/autocapture-types.d.ts +17 -0
  10. package/dist/autocapture-utils.d.ts +24 -1
  11. package/dist/autocapture.d.ts +94 -5
  12. package/dist/chat.js +1 -1
  13. package/dist/chat.js.map +1 -1
  14. package/dist/config.d.ts +8 -1
  15. package/dist/constants.d.ts +19 -13
  16. package/dist/core/capture.d.ts +15 -5
  17. package/dist/core/config-utils.d.ts +15 -0
  18. package/dist/core/consent.d.ts +62 -0
  19. package/dist/core/event-buffer.d.ts +60 -0
  20. package/dist/core/fb-cookies.d.ts +32 -0
  21. package/dist/core/feature-manager.d.ts +61 -69
  22. package/dist/core/fifo-queue.d.ts +23 -0
  23. package/dist/core/identity.d.ts +23 -33
  24. package/dist/core/index.d.ts +7 -1
  25. package/dist/core/page-lifecycle.d.ts +41 -0
  26. package/dist/core/remote-config.d.ts +14 -17
  27. package/dist/extensions/chat/bubble-drag.d.ts +30 -0
  28. package/dist/extensions/chat/chat-api.d.ts +15 -0
  29. package/dist/extensions/chat/chat-styles.d.ts +27 -0
  30. package/dist/extensions/chat/chat-wrapper.d.ts +20 -145
  31. package/dist/extensions/chat/chat.d.ts +129 -12
  32. package/dist/extensions/chat/message-content-styles.d.ts +1 -0
  33. package/dist/extensions/chat/message-html.d.ts +6 -0
  34. package/dist/extensions/chat/message-markdown.d.ts +8 -0
  35. package/dist/extensions/chat/normalize-send-content.d.ts +24 -0
  36. package/dist/extensions/chat/types.d.ts +19 -57
  37. package/dist/extensions/chat/widget-registry.d.ts +53 -0
  38. package/dist/extensions/chat/widgets/collect-email.d.ts +6 -0
  39. package/dist/extensions/chat/widgets/escalate-to-human.d.ts +6 -0
  40. package/dist/extensions/ga4-proxy.d.ts +59 -0
  41. package/dist/extensions/google-tag-gateway/consent-bridge.d.ts +27 -0
  42. package/dist/extensions/google-tag-gateway/enhanced-conversions.d.ts +35 -0
  43. package/dist/extensions/google-tag-gateway/event-bridge.d.ts +74 -0
  44. package/dist/extensions/google-tag-gateway/google-tag-gateway.d.ts +95 -0
  45. package/dist/extensions/google-tag-gateway/gtag-loader.d.ts +85 -0
  46. package/dist/extensions/google-tag-gateway/index.d.ts +7 -0
  47. package/dist/extensions/google-tag-gateway/normalize.d.ts +28 -0
  48. package/dist/extensions/google-tag-gateway/public-api.d.ts +23 -0
  49. package/dist/extensions/history-autocapture.d.ts +2 -2
  50. package/dist/extensions/replay/index.d.ts +1 -1
  51. package/dist/extensions/replay/session-recording-utils.d.ts +13 -43
  52. package/dist/extensions/replay/session-recording-wrapper.d.ts +10 -66
  53. package/dist/extensions/replay/session-recording.d.ts +53 -1
  54. package/dist/extensions/replay/types.d.ts +6 -1
  55. package/dist/extensions/web-vitals/web-vitals-manager.d.ts +14 -43
  56. package/dist/external-scripts-loader.js +1 -1
  57. package/dist/external-scripts-loader.js.map +1 -1
  58. package/dist/feature.d.ts +54 -172
  59. package/dist/main.js +1 -1
  60. package/dist/main.js.map +1 -1
  61. package/dist/module.d.ts +728 -753
  62. package/dist/module.js +1 -1
  63. package/dist/module.js.map +1 -1
  64. package/dist/module.no-external.d.ts +728 -753
  65. package/dist/module.no-external.js +1 -1
  66. package/dist/module.no-external.js.map +1 -1
  67. package/dist/rate-limiter.d.ts +0 -1
  68. package/dist/recorder.js +1 -1
  69. package/dist/recorder.js.map +1 -1
  70. package/dist/request.d.ts +34 -20
  71. package/dist/scroll-depth-tracker.d.ts +42 -0
  72. package/dist/server.d.ts +114 -0
  73. package/dist/server.js +1 -1
  74. package/dist/server.js.map +1 -1
  75. package/dist/session.d.ts +12 -0
  76. package/dist/types.d.ts +204 -9
  77. package/dist/user-manager.d.ts +26 -52
  78. package/dist/utils/base64.d.ts +30 -0
  79. package/dist/utils/bot-detection.d.ts +28 -0
  80. package/dist/utils/endpoint-url.d.ts +36 -0
  81. package/dist/utils/event-emitter.d.ts +1 -0
  82. package/dist/utils/globals.d.ts +71 -2
  83. package/dist/utils/index.d.ts +20 -5
  84. package/dist/utils/logger.d.ts +66 -0
  85. package/dist/utils/request-utils.d.ts +5 -0
  86. package/dist/utils/safewrap.d.ts +6 -1
  87. package/dist/utils/transport-health.d.ts +55 -0
  88. package/dist/utils/type-guards.d.ts +1 -1
  89. package/dist/vtilt.d.ts +85 -25
  90. package/dist/web-vitals.js.map +1 -1
  91. package/package.json +9 -4
@@ -4,63 +4,33 @@
4
4
  * Utility functions for session recording.
5
5
  * Based on PostHog's sessionrecording-utils.ts
6
6
  */
7
- import { EventType, IncrementalSource, eventWithTime } from "@rrweb/types";
7
+ import { IncrementalSource, eventWithTime } from "@rrweb/types";
8
8
  import type { SnapshotBuffer } from "./types";
9
9
  export declare const INCREMENTAL_SNAPSHOT_EVENT_TYPE = 3;
10
10
  export declare const ONE_KB = 1024;
11
11
  export declare const ONE_MB: number;
12
12
  export declare const SEVEN_MB: number;
13
- export declare const PARTIAL_COMPRESSION_THRESHOLD = 1024;
14
13
  export declare const RECORDING_MAX_EVENT_SIZE: number;
15
14
  export declare const RECORDING_BUFFER_TIMEOUT = 2000;
16
15
  export declare const RECORDING_IDLE_THRESHOLD_MS: number;
17
- /** Active interaction sources */
18
- export declare const ACTIVE_SOURCES: IncrementalSource[];
19
16
  /**
20
- * Gzip compress data to a base64 string
17
+ * Selectors passed to rrweb `blockSelector` by default so common non-visible
18
+ * template / screen-reader / Webflow CMS nodes are not serialized (they replay
19
+ * as same-sized placeholders). Reduces payload size and keeps hidden form copy
20
+ * out of recordings. Stylesheet-only `display:none` is not detectable here.
21
21
  */
22
- export declare function gzipToString(data: unknown): string;
22
+ export declare const DEFAULT_INVISIBLE_TEMPLATE_BLOCK_SELECTOR: string;
23
23
  /**
24
- * Estimate the size of an object in bytes
24
+ * Merge comma-separated CSS selector lists with de-duplication.
25
+ * When `skipDefaults` is true, omit {@link DEFAULT_INVISIBLE_TEMPLATE_BLOCK_SELECTOR}.
25
26
  */
26
- export declare function estimateSize(obj: unknown): number;
27
- export interface CompressedFullSnapshotEvent {
28
- type: typeof EventType.FullSnapshot;
29
- data: string;
30
- }
31
- export interface CompressedIncrementalSnapshotEvent {
32
- type: typeof EventType.IncrementalSnapshot;
33
- data: {
34
- source: IncrementalSource;
35
- texts: string;
36
- attributes: string;
37
- removes: string;
38
- adds: string;
39
- };
40
- }
41
- export interface CompressedIncrementalStyleSnapshotEvent {
42
- type: typeof EventType.IncrementalSnapshot;
43
- data: {
44
- source: typeof IncrementalSource.StyleSheetRule;
45
- id?: number;
46
- styleId?: number;
47
- replace?: string;
48
- replaceSync?: string;
49
- adds?: string;
50
- removes?: string;
51
- };
52
- }
53
- export type CompressedEvent = CompressedFullSnapshotEvent | CompressedIncrementalSnapshotEvent | CompressedIncrementalStyleSnapshotEvent;
54
- export type CompressedEventWithTime = CompressedEvent & {
55
- timestamp: number;
56
- delay?: number;
57
- cv: "2024-10";
58
- };
27
+ export declare function mergeBlockSelectors(skipDefaults: boolean | undefined, ...sources: (string | undefined | null)[]): string | undefined;
28
+ /** Active interaction sources */
29
+ export declare const ACTIVE_SOURCES: IncrementalSource[];
59
30
  /**
60
- * Compress an rrweb event for transmission
61
- * Only compresses full snapshots and mutation events above threshold
31
+ * Estimate the size of an object in bytes
62
32
  */
63
- export declare function compressEvent(event: eventWithTime): eventWithTime | CompressedEventWithTime;
33
+ export declare function estimateSize(obj: unknown): number;
64
34
  /**
65
35
  * Truncate large console log payloads to prevent excessive data
66
36
  */
@@ -1,92 +1,36 @@
1
1
  /**
2
2
  * Session Recording Wrapper
3
3
  *
4
- * Lightweight wrapper that handles the decision of WHEN to load recording.
5
- * The actual recording logic is in LazyLoadedSessionRecording which is
6
- * loaded on demand.
4
+ * Extends ToggleableLazyFeature to handle lazy-loading the rrweb recorder
5
+ * script and delegating to the heavy LazyLoadedSessionRecording instance.
7
6
  *
8
- * Implements the ToggleableFeature interface for consistent lifecycle management.
9
- * Based on PostHog's sessionrecording-wrapper.ts
7
+ * @see docs/patterns/tracker-feature-lifecycle.md
10
8
  */
11
9
  import type { VTilt } from "../../vtilt";
12
- import type { VTiltConfig, RemoteConfig } from "../../types";
13
- import type { ToggleableFeature } from "../../feature";
10
+ import type { VTiltConfig } from "../../types";
14
11
  import type { SessionRecordingConfig, SessionStartReason } from "./types";
12
+ import { ToggleableLazyFeature } from "../../feature";
15
13
  import { LazyLoadedSessionRecordingInterface } from "../../utils/globals";
16
- /** Status when lazy loading is in progress */
17
14
  export declare const LAZY_LOADING: "lazy_loading";
18
- /** Session recording status */
19
15
  export type SessionRecordingStatus = "disabled" | "buffering" | "active" | "paused" | "sampled" | "trigger_pending" | typeof LAZY_LOADING;
20
16
  export type { LazyLoadedSessionRecordingInterface };
21
- /**
22
- * Session Recording Wrapper
23
- *
24
- * This is the lightweight class that lives in the main bundle.
25
- * Implements ToggleableFeature for consistent lifecycle management.
26
- *
27
- * It handles:
28
- * - Deciding if recording should be enabled
29
- * - Lazy loading the actual recording code
30
- * - Delegating to LazyLoadedSessionRecording
31
- */
32
- export declare class SessionRecordingWrapper implements ToggleableFeature {
33
- private readonly _instance;
17
+ export declare class SessionRecordingWrapper extends ToggleableLazyFeature<SessionRecordingConfig, LazyLoadedSessionRecordingInterface> {
34
18
  readonly name = "SessionRecording";
35
- private _lazyLoadedRecording;
36
- private _config;
37
- private _isStarted;
38
- constructor(_instance: VTilt, config?: SessionRecordingConfig);
39
- /**
40
- * Extract session recording config from VTiltConfig.
41
- * Self-contained - vtilt.ts doesn't need to know config details.
42
- */
19
+ readonly scriptName = "recorder";
20
+ constructor(instance: VTilt, config?: SessionRecordingConfig);
43
21
  static extractConfig(config: VTiltConfig): SessionRecordingConfig;
44
22
  get isEnabled(): boolean;
45
23
  get isStarted(): boolean;
46
- /**
47
- * Start if enabled (Feature interface).
48
- * Use startIfEnabledOrStop for recording as it needs to actively stop.
49
- */
50
24
  startIfEnabled(): void;
51
- /**
52
- * Start if enabled, or stop if disabled (ToggleableFeature interface).
53
- * This is the primary method for session recording.
54
- */
55
25
  startIfEnabledOrStop(trigger?: SessionStartReason): void;
56
- /**
57
- * Stop recording (Feature interface).
58
- */
59
26
  stop(): void;
60
- /**
61
- * Handle config updates (Feature interface).
62
- */
63
27
  onConfigUpdate(config: VTiltConfig): void;
64
- /**
65
- * Handle remote config updates (Feature interface).
66
- */
67
- onRemoteConfig(remoteConfig: RemoteConfig): void;
28
+ protected _createLoaded(): LazyLoadedSessionRecordingInterface;
29
+ protected _onLoaded(loaded: LazyLoadedSessionRecordingInterface, trigger?: SessionStartReason): void;
68
30
  get started(): boolean;
69
31
  get status(): SessionRecordingStatus;
70
32
  get sessionId(): string;
71
- /**
72
- * Alias for stop() for backwards compatibility.
73
- */
74
33
  stopRecording(): void;
75
- /**
76
- * Log a message to the recording.
77
- */
78
34
  log(message: string, level?: "log" | "warn" | "error"): void;
79
- /**
80
- * Update configuration.
81
- */
82
35
  updateConfig(config: Partial<SessionRecordingConfig>): void;
83
- private get _scriptName();
84
- /**
85
- * Lazy load the recording script and start.
86
- */
87
- private _lazyLoadAndStart;
88
- /**
89
- * Called after the recording script is loaded.
90
- */
91
- private _onScriptLoaded;
92
36
  }
@@ -59,6 +59,7 @@ export declare class LazyLoadedSessionRecording implements LazyLoadedSessionReco
59
59
  */
60
60
  updateConfig(config: Partial<SessionRecordingConfig>): void;
61
61
  private _onBeforeUnload;
62
+ private _onPageHide;
62
63
  private _onOffline;
63
64
  private _onOnline;
64
65
  private _onVisibilityChange;
@@ -72,12 +73,63 @@ export declare class LazyLoadedSessionRecording implements LazyLoadedSessionReco
72
73
  private _updateWindowAndSessionIds;
73
74
  private _clearBuffer;
74
75
  private _flushBuffer;
76
+ /**
77
+ * Unconditionally flush the buffer, ignoring status checks.
78
+ * Used during stop() and session transitions to prevent data loss.
79
+ */
80
+ private _forceFlushBuffer;
81
+ private _sendBufferContents;
75
82
  private _captureSnapshotBuffered;
76
83
  private _captureSnapshot;
84
+ /**
85
+ * Send a snapshot batch to the ingestion endpoint.
86
+ *
87
+ * Transport selection:
88
+ *
89
+ * - FullSnapshots, or batches over `BEACON_SIZE_LIMIT`, always use
90
+ * fetch (with retry). They're too important / too big for sendBeacon.
91
+ * - Smaller batches use `sendBeacon` first.
92
+ *
93
+ * Encoding selection (this is the part that fixes the server-side
94
+ * `Z_BUF_ERROR`):
95
+ *
96
+ * - **fetch path** sends the gzip bytes as a binary `Blob` and uses
97
+ * `?compression=gzip-js`. Reliable because the request lifetime is
98
+ * bounded by the JS context.
99
+ * - **sendBeacon path** sends the gzip bytes as a base64 *string* and
100
+ * uses `?compression=base64`. `sendBeacon(url, Blob([binary]))`
101
+ * races with tab discard / `pagehide`: the browser queues the
102
+ * beacon synchronously and serializes the body after JS is torn
103
+ * down, by which time the Uint8Array's backing `ArrayBuffer` may
104
+ * have been detached. A string-backed Blob owns its own UTF-8 copy
105
+ * and survives unload. The server already understands both flags.
106
+ *
107
+ * The query-param flag is *only* added once we know the encoded body
108
+ * actually carries that compression — never up front from configuration —
109
+ * so the URL can never claim compression while the body is empty/JSON.
110
+ */
77
111
  private _sendSnapshot;
112
+ /**
113
+ * fetch path — binary gzip body, `compression=gzip-js`. Auth travels
114
+ * in the `x-api-key` header (see `_sendSnapshot` for the rationale).
115
+ */
116
+ private _sendViaFetch;
117
+ /**
118
+ * sendBeacon path — base64 text body, `compression=base64`. The token
119
+ * must be on the URL (caller pre-built `baseUrl` with
120
+ * `includeTokenQuery: true`) because beacons cannot carry headers.
121
+ * Falls back to fetch+keepalive — same URL, no header — if the beacon
122
+ * is refused, so the two transports look identical on the wire.
123
+ */
124
+ private _sendViaBeacon;
78
125
  /**
79
126
  * Fetch with exponential backoff retry (PostHog-style)
80
- * Retries on network errors and 5xx server errors
127
+ * Retries on network errors and 5xx server errors.
128
+ *
129
+ * When `token` is non-empty the request is authenticated via the
130
+ * `x-api-key` header (clean URL, harder to block). When empty the
131
+ * caller has already authenticated via `?token=` in the URL (used by
132
+ * the beacon-fallback path where the URL must match the beacon's).
81
133
  */
82
134
  private _fetchWithRetry;
83
135
  /**
@@ -139,6 +139,11 @@ export interface SessionRecordingConfig {
139
139
  blockClass?: string;
140
140
  /** Block selector for elements to hide */
141
141
  blockSelector?: string;
142
+ /**
143
+ * When `true`, do not merge built-in selectors for off-screen / template DOM
144
+ * (`.sr-only`, Webflow `w-condition-invisible`, etc.). Default `false`.
145
+ */
146
+ skipDefaultInvisibleBlocking?: boolean;
142
147
  /** Ignore class for input masking */
143
148
  ignoreClass?: string;
144
149
  /** Mask text class */
@@ -153,7 +158,7 @@ export interface SessionRecordingConfig {
153
158
  recordHeaders?: boolean;
154
159
  /** Record body in network requests */
155
160
  recordBody?: boolean;
156
- /** Compress events before sending */
161
+ /** Gzip-compress the request body before sending (transport-level) */
157
162
  compressEvents?: boolean;
158
163
  /** Internal: Mutation throttler refill rate */
159
164
  __mutationThrottlerRefillRate?: number;
@@ -1,16 +1,9 @@
1
1
  /**
2
2
  * Web Vitals Manager
3
3
  *
4
+ * Extends LazyFeature to handle lazy-loading the web-vitals script.
4
5
  * Captures Core Web Vitals (LCP, CLS, FCP, INP, TTFB) and sends them
5
- * as batched $web_vitals events. Implements the Feature interface for
6
- * consistent lifecycle management.
7
- *
8
- * Follows PostHog's approach with:
9
- * 1. Extension pattern - checks for callbacks registered on __VTiltExtensions__
10
- * 2. Lazy loading - loads web-vitals.js on demand if not bundled
11
- * 3. Configurable metrics - choose which metrics to capture
12
- * 4. Smart buffering - collects metrics per page, flushes on navigation or timeout
13
- * 5. Session context - includes session_id and window_id for correlation
6
+ * as batched $web_vitals events.
14
7
  *
15
8
  * Event structure:
16
9
  * - event: "$web_vitals"
@@ -19,57 +12,35 @@
19
12
  * - $web_vitals_LCP_event: { name, value, delta, rating, ... }
20
13
  * - $pathname: string
21
14
  * - $current_url: string
15
+ *
16
+ * @see docs/patterns/tracker-feature-lifecycle.md
22
17
  */
23
18
  import { VTiltConfig, CapturePerformanceConfig, SupportedWebVitalsMetric } from "../../types";
24
- import type { Feature } from "../../feature";
25
- import { VTilt } from "../../vtilt";
26
- export declare class WebVitalsManager implements Feature {
19
+ import { LazyFeature } from "../../feature";
20
+ import type { VTilt } from "../../vtilt";
21
+ import { WebVitalsCallbacks } from "../../utils/globals";
22
+ export declare class WebVitalsManager extends LazyFeature<CapturePerformanceConfig, WebVitalsCallbacks> {
27
23
  readonly name = "WebVitals";
28
- private _instance;
24
+ readonly scriptName = "web-vitals";
29
25
  private _buffer;
30
26
  private _flushTimer;
31
- private _isStarted;
32
- private _config;
33
- /**
34
- * Extract web vitals config from VTiltConfig (self-contained)
35
- */
36
27
  static extractConfig(config: VTiltConfig): CapturePerformanceConfig;
37
- constructor(instance: VTilt);
38
- /**
39
- * Check if web vitals capture is enabled
40
- */
28
+ constructor(instance: VTilt, config?: CapturePerformanceConfig);
41
29
  get isEnabled(): boolean;
42
30
  /**
43
- * Check if capturing has started
44
- */
45
- get isStarted(): boolean;
46
- /**
47
- * Start capturing if enabled
31
+ * Web Vitals checks if callbacks are already registered (from full bundle)
32
+ * before trying to lazy-load the script.
48
33
  */
49
34
  startIfEnabled(): void;
50
- /**
51
- * Stop capturing (flushes any pending metrics)
52
- */
53
35
  stop(): void;
54
- /**
55
- * Handle config update
56
- */
57
36
  onConfigUpdate(config: VTiltConfig): void;
58
- /**
59
- * Get the list of metrics to capture
60
- */
37
+ protected _createLoaded(): WebVitalsCallbacks;
38
+ protected _onLoaded(loaded: WebVitalsCallbacks): void;
61
39
  get allowedMetrics(): SupportedWebVitalsMetric[];
62
- /**
63
- * Get flush timeout in ms
64
- */
65
40
  get flushTimeoutMs(): number;
66
- /**
67
- * Get maximum allowed metric value
68
- */
69
41
  get maxAllowedValue(): number;
70
42
  private _createEmptyBuffer;
71
43
  private _getWebVitalsCallbacks;
72
- private _loadWebVitals;
73
44
  private _startCapturing;
74
45
  private _getCurrentUrl;
75
46
  private _getCurrentPathname;
@@ -1,2 +1,2 @@
1
- !function(n){"use strict";var i="undefined"!=typeof window?window:void 0,o="undefined"!=typeof globalThis?globalThis:i,l=null==o?void 0:o.navigator,r=null==o?void 0:o.document;null==o||o.location,null==o||o.fetch,i&&r&&r.createElement,null==o||o.XMLHttpRequest,null==o||o.AbortController,null==l||l.userAgent;var d=null!=i?i:{},t="[ExternalScriptsLoader]",e=(n,i,o)=>{if(n.getConfig().disable_external_dependency_loading)return console.warn(t+" "+i+" was requested but loading of external scripts is disabled."),o("Loading of external scripts is disabled");var l=null==r?void 0:r.querySelectorAll("script");if(l)for(var d,e=function(){if(l[a].src===i){var n=l[a];return n.__vtilt_loading_callback_fired?{v:o()}:(n.addEventListener("load",i=>{n.__vtilt_loading_callback_fired=!0,o(void 0,i)}),n.onerror=n=>o(n),{v:void 0})}},a=0;a<l.length;a++)if(d=e())return d.v;var s=()=>{var n;if(!r)return o("document not found");var l=r.createElement("script");l.type="text/javascript",l.crossOrigin="anonymous",l.src=i,l.onload=n=>{l.__vtilt_loading_callback_fired=!0,o(void 0,n)},l.onerror=n=>o(n);var d=r.querySelectorAll("body > script");d.length>0?null===(n=d[0].parentNode)||void 0===n||n.insertBefore(l,d[0]):r.body.appendChild(l)};(null==r?void 0:r.body)?s():null==r||r.addEventListener("DOMContentLoaded",s)},a=(n,i)=>{var o=n.getConfig();return o.script_host?o.script_host.replace(/\/+$/gm,"")+"/"+i+".js":o.api_host?o.api_host.replace(/\/+$/gm,"")+"/dist/"+i+".js":(console.error(t+" Cannot load "+i+".js: api_host is required"),"")};d.__VTiltExtensions__=d.__VTiltExtensions__||{},d.__VTiltExtensions__.loadExternalDependency=(n,i,o)=>{var l=a(n,i);e(n,l,o)},n.getExtensionUrl=a,n.loadScript=e}({});
1
+ !function(r){"use strict";var n="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:n,o=null==e?void 0:e.navigator,i=null==e?void 0:e.document;null==e||e.location,null==e||e.fetch,n&&i&&i.createElement,null==e||e.XMLHttpRequest,null==e||e.AbortController,null==o||o.userAgent;var t=null!=n?n:{},l={none:0,error:1,warn:2,info:3,debug:4},a="[vTilt]",u=new Set(["none","error","warn","info","debug"]);function d(){return"undefined"!=typeof console}function s(r){var n=r.length>0&&"string"==typeof r[0]?r[0]:"",e=n?r.slice(1):r;return[n?a+":"+n:a,...e]}var v="warn",f=!1;var c=null;function w(){return c||(c={setLevel(r,n){void 0===n&&(n=!1),v=r,n&&(f=!0)},setLevelFromRemote(r){f||r&&u.has(r)&&(v=r)},getLevel:()=>v,isLockedByInit:()=>f,debug(){if(!(l[v]<l.debug)&&d()){for(var r=arguments.length,n=new Array(r),e=0;e<r;e++)n[e]=arguments[e];console.log(...s(n))}},info(){if(!(l[v]<l.info)&&d()){for(var r=arguments.length,n=new Array(r),e=0;e<r;e++)n[e]=arguments[e];console.log(...s(n))}},warn(){if(!(l[v]<l.warn)&&d()){for(var r=arguments.length,n=new Array(r),e=0;e<r;e++)n[e]=arguments[e];console.warn(...s(n))}},error(){if(!(l[v]<l.error)&&d()){for(var r=arguments.length,n=new Array(r),e=0;e<r;e++)n[e]=arguments[e];console.error(...s(n))}}}),c}var p="external-scripts",g=(r,n,e)=>{if(r.getConfig().disable_external_dependency_loading)return w().warn(p,n+" was requested but loading of external scripts is disabled."),e("Loading of external scripts is disabled");var o=null==i?void 0:i.querySelectorAll("script");if(o)for(var t,l=function(){if(o[a].src===n){var r=o[a];return r.__vtilt_loading_callback_fired?{v:e()}:(r.addEventListener("load",n=>{r.__vtilt_loading_callback_fired=!0,e(void 0,n)}),r.onerror=r=>e(r),{v:void 0})}},a=0;a<o.length;a++)if(t=l())return t.v;var u=()=>{var r;if(!i)return e("document not found");var o=i.createElement("script");o.type="text/javascript",o.crossOrigin="anonymous",o.src=n,o.onload=r=>{o.__vtilt_loading_callback_fired=!0,e(void 0,r)},o.onerror=r=>e(r);var t=i.querySelectorAll("body > script");t.length>0?null===(r=t[0].parentNode)||void 0===r||r.insertBefore(o,t[0]):i.body.appendChild(o)};(null==i?void 0:i.body)?u():null==i||i.addEventListener("DOMContentLoaded",u)},y=(r,n)=>{var e=r.getConfig();return e.script_host?e.script_host.replace(/\/+$/gm,"")+"/"+n+".js":e.api_host?e.api_host.replace(/\/+$/gm,"")+"/dist/"+n+".js":(w().error(p,"cannot load "+n+".js: api_host is required"),"")};t.__VTiltExtensions__=t.__VTiltExtensions__||{},t.__VTiltExtensions__.loadExternalDependency=(r,n,e)=>{var o=y(r,n);g(r,o,e)},r.getExtensionUrl=y,r.loadScript=g}({});
2
2
  //# sourceMappingURL=external-scripts-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-scripts-loader.js","sources":["../src/utils/globals.ts","../src/entrypoints/external-scripts-loader.ts"],"sourcesContent":[null,null],"names":["win","window","undefined","global","globalThis","navigator","document","location","fetch","createElement","XMLHttpRequest","AbortController","userAgent","assignableWindow","LOGGER_PREFIX","loadScript","vtilt","url","callback","getConfig","disable_external_dependency_loading","console","warn","existingScripts","querySelectorAll","_ret","_loop","i","src","alreadyExistingScriptTag","__vtilt_loading_callback_fired","v","addEventListener","event","onerror","error","length","addScript","scriptTag","type","crossOrigin","onload","scripts","_a","parentNode","insertBefore","body","appendChild","getExtensionUrl","kind","config","script_host","replace","api_host","__VTiltExtensions__","loadExternalDependency"],"mappings":"0BAaA,IAAMA,EACc,oBAAXC,OAAyBA,YAASC,EAiSrCC,EACkB,oBAAfC,WAA6BA,WAAaJ,EAMtCK,EAAYF,aAAM,EAANA,EAAQE,UACpBC,EAAWH,aAAM,EAANA,EAAQG,SACRH,SAAAA,EAAQI,SACXJ,SAAAA,EAAQK,MAOzBR,GAASM,GAAmBA,EAASG,cAIXN,SAAAA,EAAQO,eACPP,SAAAA,EAAQQ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C,EAASlC,EAAMG,YAGrB,OAAI+B,EAAOC,YACSD,EAAOC,YAAYC,QAAQ,SAAU,QAChCH,EAAI,MAIzBC,EAAOG,SACSH,EAAOG,SAASD,QAAQ,SAAU,aACxBH,EAAI,OAIlC5B,QAAQc,MACHrB,EAAa,gBAAgBmC,+BAE3B,KAITpC,EAAiByC,oBACfzC,EAAiByC,qBAAuB,CAAA,EAK1CzC,EAAiByC,oBAAoBC,uBAAyB,CAC5DvC,EACAiC,EACA/B,KAEA,IAAMD,EAAM+B,EAAgBhC,EAAOiC,GACnClC,EAAWC,EAAOC,EAAKC"}
1
+ {"version":3,"file":"external-scripts-loader.js","sources":["../src/utils/globals.ts","../src/utils/logger.ts","../src/entrypoints/external-scripts-loader.ts"],"sourcesContent":[null,null,null],"names":["win","window","undefined","global","globalThis","navigator","document","location","fetch","createElement","XMLHttpRequest","AbortController","userAgent","assignableWindow","LEVEL_PRIORITY","none","error","warn","info","debug","PREFIX","VALID_LEVELS","Set","hasConsole","console","formatArgs","args","scope","length","rest","slice","currentLevel","lockedByInit","singleton","getLogger","setLevel","level","lockFromInit","setLevelFromRemote","has","getLevel","isLockedByInit","_len","arguments","Array","_key","log","_len2","_key2","_len3","_key3","_len4","_key4","LOG_SCOPE","loadScript","vtilt","url","callback","getConfig","disable_external_dependency_loading","existingScripts","querySelectorAll","_ret","_loop","i","src","alreadyExistingScriptTag","__vtilt_loading_callback_fired","v","addEventListener","event","onerror","addScript","scriptTag","type","crossOrigin","onload","scripts","_a","parentNode","insertBefore","body","appendChild","getExtensionUrl","kind","config","script_host","replace","api_host","__VTiltExtensions__","loadExternalDependency"],"mappings":"0BAaA,IAAMA,EACc,oBAAXC,OAAyBA,YAASC,EA6WrCC,EACkB,oBAAfC,WAA6BA,WAAaJ,EAMtCK,EAAYF,aAAM,EAANA,EAAQE,UACpBC,EAAWH,aAAM,EAANA,EAAQG,SACRH,SAAAA,EAAQI,SACXJ,SAAAA,EAAQK,MAOzBR,GAASM,GAAmBA,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