@npaw/forge-web 10.0.4 → 10.2.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/index.js CHANGED
@@ -248,6 +248,20 @@ var ResourceTimingCorrelator = class {
248
248
  }
249
249
  };
250
250
 
251
+ // src/global.ts
252
+ function getGlobalObject() {
253
+ if (typeof globalThis !== "undefined") {
254
+ return globalThis;
255
+ }
256
+ if (typeof self !== "undefined") {
257
+ return self;
258
+ }
259
+ if (typeof window !== "undefined") {
260
+ return window;
261
+ }
262
+ throw new Error("no global object available");
263
+ }
264
+
251
265
  // src/sections-capture.ts
252
266
  var DEFAULT_VISIBILITY_THRESHOLD_PCT = 50;
253
267
  var DEFAULT_IMPRESSION_MIN_VISIBLE_MS = 1e3;
@@ -1141,7 +1155,7 @@ function resolveIntersectionObserverFactory(environment) {
1141
1155
  if (environment.intersectionObserverFactory) {
1142
1156
  return environment.intersectionObserverFactory;
1143
1157
  }
1144
- const ctor = globalThis.IntersectionObserver;
1158
+ const ctor = getGlobalObject().IntersectionObserver;
1145
1159
  if (typeof ctor !== "function") {
1146
1160
  return void 0;
1147
1161
  }
@@ -1151,7 +1165,7 @@ function resolveMutationObserverFactory(environment) {
1151
1165
  if (environment.mutationObserverFactory) {
1152
1166
  return environment.mutationObserverFactory;
1153
1167
  }
1154
- const ctor = globalThis.MutationObserver;
1168
+ const ctor = getGlobalObject().MutationObserver;
1155
1169
  if (typeof ctor !== "function") {
1156
1170
  return void 0;
1157
1171
  }
@@ -3282,7 +3296,7 @@ function persistentDeviceUuid() {
3282
3296
  }
3283
3297
  const generated = randomUuid();
3284
3298
  try {
3285
- (_a = globalThis.localStorage) == null ? void 0 : _a.setItem(DEVICE_UUID_STORAGE_KEY, generated);
3299
+ (_a = getGlobalObject().localStorage) == null ? void 0 : _a.setItem(DEVICE_UUID_STORAGE_KEY, generated);
3286
3300
  } catch (e) {
3287
3301
  }
3288
3302
  return generated;
@@ -3290,14 +3304,14 @@ function persistentDeviceUuid() {
3290
3304
  function readStoredUuid() {
3291
3305
  var _a;
3292
3306
  try {
3293
- const value = (_a = globalThis.localStorage) == null ? void 0 : _a.getItem(DEVICE_UUID_STORAGE_KEY);
3307
+ const value = (_a = getGlobalObject().localStorage) == null ? void 0 : _a.getItem(DEVICE_UUID_STORAGE_KEY);
3294
3308
  return value && value.trim().length > 0 ? value : void 0;
3295
3309
  } catch (e) {
3296
3310
  return void 0;
3297
3311
  }
3298
3312
  }
3299
3313
  function randomUuid() {
3300
- const cryptoRef = globalThis.crypto;
3314
+ const cryptoRef = getGlobalObject().crypto;
3301
3315
  if (typeof (cryptoRef == null ? void 0 : cryptoRef.randomUUID) === "function") {
3302
3316
  return cryptoRef.randomUUID();
3303
3317
  }
@@ -3431,11 +3445,11 @@ function readDownlinkKbps(environment) {
3431
3445
  }
3432
3446
  function readBrowserDeviceInsightsEnvironment() {
3433
3447
  const environment = {};
3434
- const performanceRef = globalThis.performance;
3448
+ const performanceRef = getGlobalObject().performance;
3435
3449
  if (performanceRef && typeof performanceRef.memory === "object" && performanceRef.memory !== null) {
3436
3450
  environment.memory = () => performanceRef.memory;
3437
3451
  }
3438
- const navigatorRef = globalThis.navigator;
3452
+ const navigatorRef = getGlobalObject().navigator;
3439
3453
  if (navigatorRef && typeof navigatorRef.getBattery === "function") {
3440
3454
  environment.getBattery = () => navigatorRef.getBattery();
3441
3455
  }
@@ -3526,8 +3540,17 @@ function diagnosticFromError(error, code) {
3526
3540
  function isPromiseLike(value) {
3527
3541
  return Boolean(value && typeof value.then === "function");
3528
3542
  }
3543
+ function fromEntries(entries) {
3544
+ const result = {};
3545
+ for (const entry of entries) {
3546
+ result[entry[0]] = entry[1];
3547
+ }
3548
+ return result;
3549
+ }
3529
3550
 
3530
3551
  // src/effects.ts
3552
+ var MAX_COMMAND_SUBSCRIPTIONS = 64;
3553
+ var COMMAND_NAME_PATTERN = /^[A-Za-z0-9_.-]{1,64}$/;
3531
3554
  var BrowserEffectExecutor = class {
3532
3555
  constructor(options) {
3533
3556
  this.timers = /* @__PURE__ */ new Map();
@@ -3536,6 +3559,7 @@ var BrowserEffectExecutor = class {
3536
3559
  this.diagnosticListeners = /* @__PURE__ */ new Set();
3537
3560
  this.logListeners = /* @__PURE__ */ new Set();
3538
3561
  this.capturePlanListeners = /* @__PURE__ */ new Set();
3562
+ this.commandListeners = /* @__PURE__ */ new Map();
3539
3563
  this.clock = options.clock;
3540
3564
  this.transport = options.transport;
3541
3565
  this.storage = options.storage;
@@ -3550,6 +3574,18 @@ var BrowserEffectExecutor = class {
3550
3574
  if (options.onLog) {
3551
3575
  this.logListeners.add(options.onLog);
3552
3576
  }
3577
+ if (options.commandListeners) {
3578
+ for (const name of Object.keys(options.commandListeners)) {
3579
+ const listeners = options.commandListeners[name];
3580
+ if (!listeners) {
3581
+ continue;
3582
+ }
3583
+ const entries = Array.isArray(listeners) ? listeners : [listeners];
3584
+ for (const listener of entries) {
3585
+ this.registerCommandListener(name, listener);
3586
+ }
3587
+ }
3588
+ }
3553
3589
  }
3554
3590
  addEventListener(listener) {
3555
3591
  this.eventListeners.add(listener);
@@ -3570,6 +3606,51 @@ var BrowserEffectExecutor = class {
3570
3606
  }
3571
3607
  return () => this.capturePlanListeners.delete(listener);
3572
3608
  }
3609
+ /**
3610
+ * Registers a remote command listener and re-sends the full subscription
3611
+ * set to the kernel. Every call is its own registration, even for a
3612
+ * function already registered under the name. Returns the unsubscribe
3613
+ * closure, which removes only that registration and re-sends the set
3614
+ * without the name once its last registration is gone.
3615
+ */
3616
+ addCommandListener(name, listener) {
3617
+ const registration = this.registerCommandListener(name, listener);
3618
+ if (!registration) {
3619
+ return () => void 0;
3620
+ }
3621
+ this.syncCommandSubscriptions();
3622
+ let active = true;
3623
+ return () => {
3624
+ if (!active) {
3625
+ return;
3626
+ }
3627
+ active = false;
3628
+ const registrations = this.commandListeners.get(registration.name);
3629
+ if (!registrations) {
3630
+ return;
3631
+ }
3632
+ const index = registrations.indexOf(registration);
3633
+ if (index >= 0) {
3634
+ registrations.splice(index, 1);
3635
+ }
3636
+ if (registrations.length === 0) {
3637
+ this.commandListeners.delete(registration.name);
3638
+ }
3639
+ this.syncCommandSubscriptions();
3640
+ };
3641
+ }
3642
+ /** The command names currently subscribed, sorted. */
3643
+ commandSubscriptions() {
3644
+ return Array.from(this.commandListeners.keys()).sort();
3645
+ }
3646
+ /** Sends the current subscription set (used by the bridge after `start`). */
3647
+ syncCommandSubscriptions() {
3648
+ this.submitCompletion({ type: "setCommandSubscriptions", names: this.commandSubscriptions() });
3649
+ }
3650
+ /** Drops every command listener without re-syncing (the runtime is gone). */
3651
+ clearCommandListeners() {
3652
+ this.commandListeners.clear();
3653
+ }
3573
3654
  execute(effects) {
3574
3655
  for (const effect of effects) {
3575
3656
  switch (effect.type) {
@@ -3606,6 +3687,9 @@ var BrowserEffectExecutor = class {
3606
3687
  case "deviceSampleRequest":
3607
3688
  this.track(this.executeDeviceSampleRequest(effect.families));
3608
3689
  break;
3690
+ case "commandRequest":
3691
+ this.dispatchCommandRequest({ id: effect.id, name: effect.name, args: effect.args });
3692
+ break;
3609
3693
  default:
3610
3694
  break;
3611
3695
  }
@@ -3709,6 +3793,75 @@ var BrowserEffectExecutor = class {
3709
3793
  }
3710
3794
  this.submitCompletion({ type: "recordDeviceSample", sample: compactDeviceSample(sample) });
3711
3795
  }
3796
+ /**
3797
+ * Validates and stores a listener. Blank or malformed names and the 65th
3798
+ * distinct name are refused with a diagnostic (the kernel would drop them
3799
+ * anyway) so a typo surfaces instead of silently never firing.
3800
+ */
3801
+ registerCommandListener(rawName, listener) {
3802
+ const name = typeof rawName === "string" ? rawName.trim() : "";
3803
+ if (!COMMAND_NAME_PATTERN.test(name)) {
3804
+ this.emitDiagnostic({
3805
+ code: "command_name_invalid",
3806
+ message: "command names are 1-64 characters of [A-Za-z0-9_.-]",
3807
+ recoverable: true,
3808
+ attributes: { name: String(rawName).slice(0, 64) }
3809
+ });
3810
+ return void 0;
3811
+ }
3812
+ let registrations = this.commandListeners.get(name);
3813
+ if (!registrations) {
3814
+ if (this.commandListeners.size >= MAX_COMMAND_SUBSCRIPTIONS) {
3815
+ this.emitDiagnostic({
3816
+ code: "command_subscriptions_limit",
3817
+ message: `at most ${MAX_COMMAND_SUBSCRIPTIONS} distinct command names can be subscribed`,
3818
+ recoverable: true,
3819
+ attributes: { name }
3820
+ });
3821
+ return void 0;
3822
+ }
3823
+ registrations = [];
3824
+ this.commandListeners.set(name, registrations);
3825
+ }
3826
+ const registration = { name, listener };
3827
+ registrations.push(registration);
3828
+ return registration;
3829
+ }
3830
+ /**
3831
+ * Hands a delivered command to every registration of its name, in
3832
+ * registration order and over a snapshot: a listener added or removed
3833
+ * while dispatching does not change who receives the in-flight command.
3834
+ * Each registration gets its own once-guarded `answer`; the kernel keeps
3835
+ * the first answer per command id. No registration (a race with an
3836
+ * unsubscribe) means no answer from here - the kernel auto-answers only
3837
+ * names nobody subscribed to.
3838
+ */
3839
+ dispatchCommandRequest(command) {
3840
+ const registrations = this.commandListeners.get(command.name);
3841
+ if (!registrations || registrations.length === 0) {
3842
+ return;
3843
+ }
3844
+ for (const { listener } of registrations.slice()) {
3845
+ let answered = false;
3846
+ const answer = (handled, details) => {
3847
+ if (answered) {
3848
+ return;
3849
+ }
3850
+ answered = true;
3851
+ this.submitCompletion({
3852
+ type: "commandAnswer",
3853
+ commandId: command.id,
3854
+ handled: Boolean(handled),
3855
+ details: normalizeDetails(details)
3856
+ });
3857
+ };
3858
+ try {
3859
+ listener({ id: command.id, name: command.name, args: command.args.slice() }, answer);
3860
+ } catch (error) {
3861
+ this.emitDiagnostic(diagnosticFromError(error, "command_listener_failed"));
3862
+ }
3863
+ }
3864
+ }
3712
3865
  scheduleTimer(timer) {
3713
3866
  this.cancelTimer(timer.id);
3714
3867
  const startedAtMs = this.clock.nowMs();
@@ -3786,6 +3939,20 @@ function actualTimestamp(base, actualDelayMs) {
3786
3939
  elapsedRealtimeMs: Math.round(base.elapsedRealtimeMs + actualDelayMs)
3787
3940
  };
3788
3941
  }
3942
+ function normalizeDetails(details) {
3943
+ const normalized = {};
3944
+ if (!details || typeof details !== "object") {
3945
+ return normalized;
3946
+ }
3947
+ for (const key of Object.keys(details)) {
3948
+ const value = details[key];
3949
+ if (value === void 0 || value === null) {
3950
+ continue;
3951
+ }
3952
+ normalized[key] = String(value);
3953
+ }
3954
+ return normalized;
3955
+ }
3789
3956
 
3790
3957
  // src/errors.ts
3791
3958
  var ForgeCreateError = class extends Error {
@@ -3825,13 +3992,14 @@ function createBrowserStorage() {
3825
3992
  }
3826
3993
  function safeLocalStorage() {
3827
3994
  try {
3828
- if (typeof globalThis.localStorage === "undefined") {
3995
+ const host = getGlobalObject();
3996
+ if (typeof host.localStorage === "undefined") {
3829
3997
  return null;
3830
3998
  }
3831
3999
  const probe = "__npaw_forge_storage_probe__";
3832
- globalThis.localStorage.setItem(probe, "1");
3833
- globalThis.localStorage.removeItem(probe);
3834
- return globalThis.localStorage;
4000
+ host.localStorage.setItem(probe, "1");
4001
+ host.localStorage.removeItem(probe);
4002
+ return host.localStorage;
3835
4003
  } catch (e) {
3836
4004
  return null;
3837
4005
  }
@@ -3840,10 +4008,11 @@ function safeLocalStorage() {
3840
4008
  // src/transport.ts
3841
4009
  var BrowserForgeTransport = class {
3842
4010
  async send(request) {
3843
- if (typeof globalThis.fetch === "function") {
4011
+ const host = getGlobalObject();
4012
+ if (typeof host.fetch === "function") {
3844
4013
  return sendWithFetch(request);
3845
4014
  }
3846
- if (typeof globalThis.XMLHttpRequest === "function") {
4015
+ if (typeof host.XMLHttpRequest === "function") {
3847
4016
  return sendWithXhr(request);
3848
4017
  }
3849
4018
  throw new Error("fetch and XMLHttpRequest are unavailable");
@@ -3858,7 +4027,7 @@ async function sendWithFetch(request) {
3858
4027
  if (body !== void 0) {
3859
4028
  init.body = body;
3860
4029
  }
3861
- const response = await withoutNetworkCapture(() => globalThis.fetch(requestUrl(request), init));
4030
+ const response = await withoutNetworkCapture(() => getGlobalObject().fetch(requestUrl(request), init));
3862
4031
  const headers = {};
3863
4032
  response.headers.forEach((value, key) => {
3864
4033
  headers[key] = value;
@@ -3911,8 +4080,9 @@ function requestUrl(request) {
3911
4080
  return base.toString();
3912
4081
  }
3913
4082
  function browserBaseUrl() {
3914
- if (typeof globalThis.location !== "undefined" && globalThis.location.href) {
3915
- return globalThis.location.href;
4083
+ const host = getGlobalObject();
4084
+ if (typeof host.location !== "undefined" && host.location.href) {
4085
+ return host.location.href;
3916
4086
  }
3917
4087
  return "https://localhost/";
3918
4088
  }
@@ -4000,6 +4170,9 @@ function assertRuntimeSupport() {
4000
4170
  if (typeof ArrayBuffer === "undefined" || typeof Uint8Array === "undefined") {
4001
4171
  throw new Error("typed arrays are unavailable");
4002
4172
  }
4173
+ if (typeof TextEncoder === "undefined" || typeof TextDecoder === "undefined") {
4174
+ throw new Error("TextEncoder/TextDecoder are unavailable");
4175
+ }
4003
4176
  }
4004
4177
 
4005
4178
  // src/runtime.ts
@@ -4023,7 +4196,8 @@ var ForgeRuntimeBridge = class _ForgeRuntimeBridge {
4023
4196
  onEvent: options.onEvent,
4024
4197
  onDiagnostic: options.onDiagnostic,
4025
4198
  onLog: options.onLog,
4026
- deviceSampleCollector: options.deviceSampleCollector
4199
+ deviceSampleCollector: options.deviceSampleCollector,
4200
+ commandListeners: options.commandListeners
4027
4201
  });
4028
4202
  }
4029
4203
  static async create(options) {
@@ -4038,7 +4212,20 @@ var ForgeRuntimeBridge = class _ForgeRuntimeBridge {
4038
4212
  attributes: {}
4039
4213
  });
4040
4214
  }
4041
- const module = await normalizeWasmLoader(options.wasm).load();
4215
+ let module;
4216
+ try {
4217
+ module = await normalizeWasmLoader(options.wasm).load();
4218
+ } catch (error) {
4219
+ if (error instanceof ForgeCreateError) {
4220
+ throw error;
4221
+ }
4222
+ throw new ForgeCreateError({
4223
+ code: "wasm_instantiate_failed",
4224
+ message: describeWasmLoadError(error),
4225
+ recoverable: false,
4226
+ attributes: {}
4227
+ });
4228
+ }
4042
4229
  const response = module.forgeRuntimeCreate(runtimeConfig(options));
4043
4230
  if (!response.ok || !response.value) {
4044
4231
  throw new ForgeCreateError(boundaryDiagnostic(response.error));
@@ -4052,9 +4239,14 @@ var ForgeRuntimeBridge = class _ForgeRuntimeBridge {
4052
4239
  onEvent: options.onEvent,
4053
4240
  onDiagnostic: options.onDiagnostic,
4054
4241
  onLog: options.onLog,
4055
- deviceSampleCollector: deviceSampleCollector(options)
4242
+ deviceSampleCollector: deviceSampleCollector(options),
4243
+ commandListeners: options.commandListeners
4056
4244
  });
4057
4245
  await bridge.process({ type: "start" });
4246
+ const subscriptions = bridge.commandSubscriptions();
4247
+ if (subscriptions.length > 0) {
4248
+ await bridge.process({ type: "setCommandSubscriptions", names: subscriptions });
4249
+ }
4058
4250
  return { bridge, module };
4059
4251
  }
4060
4252
  nowMs() {
@@ -4069,6 +4261,21 @@ var ForgeRuntimeBridge = class _ForgeRuntimeBridge {
4069
4261
  onLog(listener) {
4070
4262
  return this.executor.addLogListener(listener);
4071
4263
  }
4264
+ /**
4265
+ * Subscribes to a remote command name. Adding or removing a listener
4266
+ * re-sends the full subscription set to the kernel. Once the runtime is
4267
+ * destroyed nothing is registered and the returned unsubscribe is inert.
4268
+ */
4269
+ onCommand(name, listener) {
4270
+ if (this.destroyed) {
4271
+ return () => void 0;
4272
+ }
4273
+ return this.executor.addCommandListener(name, listener);
4274
+ }
4275
+ /** The command names currently subscribed, sorted. */
4276
+ commandSubscriptions() {
4277
+ return this.executor.commandSubscriptions();
4278
+ }
4072
4279
  /**
4073
4280
  * Subscribes to kernel-computed capture plans. The latest plan already
4074
4281
  * observed by the effect executor is replayed to the new listener so
@@ -4106,6 +4313,7 @@ var ForgeRuntimeBridge = class _ForgeRuntimeBridge {
4106
4313
  const batch = response.ok && response.value ? response.value : errorBatchFromBoundary(response.error);
4107
4314
  this.executor.execute(batch.effects);
4108
4315
  this.executor.cancelAll();
4316
+ this.executor.clearCommandListeners();
4109
4317
  await this.drainIdle();
4110
4318
  (_b = (_a = this.module).forgeRuntimeRelease) == null ? void 0 : _b.call(_a, this.handle);
4111
4319
  return batch;
@@ -4165,6 +4373,8 @@ var ForgeRuntimeBridge = class _ForgeRuntimeBridge {
4165
4373
  } : command;
4166
4374
  case "recordDeviceSample":
4167
4375
  return command.sample.sampledAtMs === void 0 ? { ...command, sample: { ...command.sample, sampledAtMs: this.nowMs() } } : command;
4376
+ case "commandAnswer":
4377
+ return command.timemarkMs === void 0 ? { ...command, timemarkMs: this.nowMs() } : command;
4168
4378
  default:
4169
4379
  return command;
4170
4380
  }
@@ -4322,6 +4532,13 @@ function errorBatchFromBoundary(error) {
4322
4532
  const diagnostic = boundaryDiagnostic(error);
4323
4533
  return errorBatch(diagnostic.code, diagnostic.message);
4324
4534
  }
4535
+ function describeWasmLoadError(error) {
4536
+ if (error instanceof Error) {
4537
+ const name = error.name && error.name !== "Error" ? `${error.name}: ` : "";
4538
+ return `WASM kernel failed to load: ${name}${error.message}`;
4539
+ }
4540
+ return `WASM kernel failed to load: ${String(error)}`;
4541
+ }
4325
4542
  function boundaryDiagnostic(error) {
4326
4543
  if (!error) {
4327
4544
  return {
@@ -4412,7 +4629,7 @@ var ForgeConnectionTypeObserver = class {
4412
4629
  }
4413
4630
  };
4414
4631
  function readNavigatorConnection() {
4415
- const navigatorRef = globalThis.navigator;
4632
+ const navigatorRef = getGlobalObject().navigator;
4416
4633
  return navigatorRef == null ? void 0 : navigatorRef.connection;
4417
4634
  }
4418
4635
 
@@ -4477,7 +4694,7 @@ function fixFromPosition(position) {
4477
4694
  };
4478
4695
  }
4479
4696
  function readGeolocationEnvironment() {
4480
- const navigatorRef = globalThis.navigator;
4697
+ const navigatorRef = getGlobalObject().navigator;
4481
4698
  const geolocation = navigatorRef == null ? void 0 : navigatorRef.geolocation;
4482
4699
  const permissions = navigatorRef == null ? void 0 : navigatorRef.permissions;
4483
4700
  if (!geolocation || !(permissions == null ? void 0 : permissions.query)) {
@@ -5146,6 +5363,19 @@ var _NPAWForge = class _NPAWForge {
5146
5363
  onLog(listener) {
5147
5364
  return this.runtime.onLog(listener);
5148
5365
  }
5366
+ /**
5367
+ * Listens for a remote command by name. The backend delivers commands in the
5368
+ * responses of Forge's own analytics requests, so they arrive only while
5369
+ * events flow; a command nobody subscribed to is answered `handled=false`
5370
+ * by the kernel and never re-delivered - register listeners early (or
5371
+ * through `commandListeners` at create time). Every listener of the name
5372
+ * runs; call `answer(handled, details?)` at most once per listener, the
5373
+ * first answer per command id is reported as a `command-answer` event.
5374
+ * Returns the unsubscribe function.
5375
+ */
5376
+ onCommand(name, listener) {
5377
+ return this.runtime.onCommand(name, listener);
5378
+ }
5149
5379
  async startSession(params) {
5150
5380
  var _a, _b;
5151
5381
  const result = await this.session("sessionstart", params);
@@ -11544,7 +11774,7 @@ var MediaTailorAdsAdapter = class extends BaseWebAdAdapter {
11544
11774
  if (this.fetchAttempts >= maxFetchRetries) {
11545
11775
  return;
11546
11776
  }
11547
- const fetchFn = (_d = (_c = this.options) == null ? void 0 : _c.fetch) != null ? _d : globalThis.fetch;
11777
+ const fetchFn = (_d = (_c = this.options) == null ? void 0 : _c.fetch) != null ? _d : getGlobalObject().fetch;
11548
11778
  if (typeof fetchFn !== "function") {
11549
11779
  return;
11550
11780
  }
@@ -13076,7 +13306,7 @@ function freewheelEvents() {
13076
13306
  ERROR_VAST_XML_PARSING: "ERROR_VAST_XML_PARSING",
13077
13307
  ERROR_PARSE: "ERROR_PARSE"
13078
13308
  };
13079
- return Object.fromEntries(
13309
+ return fromEntries(
13080
13310
  Object.entries(fallback).map(([key, value]) => {
13081
13311
  var _a;
13082
13312
  return [key, (_a = stringValue(read(sdk, key))) != null ? _a : value];
@@ -13214,7 +13444,7 @@ function bitmovinEvents(player) {
13214
13444
  StallStarted: "StallStarted",
13215
13445
  StallEnded: "StallEnded"
13216
13446
  };
13217
- return Object.fromEntries(
13447
+ return fromEntries(
13218
13448
  Object.entries(fallback).map(([key, value]) => {
13219
13449
  var _a;
13220
13450
  return [key, (_a = stringValue(read(events, key))) != null ? _a : value];
@@ -13575,7 +13805,7 @@ function storedFastDataPingTimeSeconds(value) {
13575
13805
  }
13576
13806
  }
13577
13807
  function cleanObject(value) {
13578
- return Object.fromEntries(
13808
+ return fromEntries(
13579
13809
  Object.entries(value).filter((entry) => entry[1] !== void 0)
13580
13810
  );
13581
13811
  }
@@ -13660,7 +13890,7 @@ function stripQuery(value) {
13660
13890
  return value == null ? void 0 : value.split("?")[0];
13661
13891
  }
13662
13892
  function globalRecord(name) {
13663
- return memberRecord(globalThis[name]);
13893
+ return memberRecord(getGlobalObject()[name]);
13664
13894
  }
13665
13895
  function realmOf(candidate) {
13666
13896
  var _a;