@expofp/loader 1.0.93 → 1.0.94

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,185 +1,185 @@
1
- const A = ["1.0.93", "2025-12-23T19:19:25.466Z"];
2
- function P(n) {
3
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
1
+ const k = ["1.0.94", "2025-12-24T13:15:18.395Z"];
2
+ function N(s) {
3
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
4
4
  }
5
- var b = { exports: {} }, j, x;
6
- function T() {
7
- if (x) return j;
5
+ var b = { exports: {} }, I, x;
6
+ function P() {
7
+ if (x) return I;
8
8
  x = 1;
9
- var n = 1e3, r = n * 60, c = r * 60, e = c * 24, a = e * 7, l = e * 365.25;
10
- j = function(s, t) {
9
+ var s = 1e3, r = s * 60, c = r * 60, e = c * 24, a = e * 7, l = e * 365.25;
10
+ I = function(o, t) {
11
11
  t = t || {};
12
- var o = typeof s;
13
- if (o === "string" && s.length > 0)
14
- return m(s);
15
- if (o === "number" && isFinite(s))
16
- return t.long ? i(s) : p(s);
12
+ var n = typeof o;
13
+ if (n === "string" && o.length > 0)
14
+ return m(o);
15
+ if (n === "number" && isFinite(o))
16
+ return t.long ? i(o) : p(o);
17
17
  throw new Error(
18
- "val is not a non-empty string or a valid number. val=" + JSON.stringify(s)
18
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(o)
19
19
  );
20
20
  };
21
- function m(s) {
22
- if (s = String(s), !(s.length > 100)) {
21
+ function m(o) {
22
+ if (o = String(o), !(o.length > 100)) {
23
23
  var t = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
24
- s
24
+ o
25
25
  );
26
26
  if (t) {
27
- var o = parseFloat(t[1]), u = (t[2] || "ms").toLowerCase();
27
+ var n = parseFloat(t[1]), u = (t[2] || "ms").toLowerCase();
28
28
  switch (u) {
29
29
  case "years":
30
30
  case "year":
31
31
  case "yrs":
32
32
  case "yr":
33
33
  case "y":
34
- return o * l;
34
+ return n * l;
35
35
  case "weeks":
36
36
  case "week":
37
37
  case "w":
38
- return o * a;
38
+ return n * a;
39
39
  case "days":
40
40
  case "day":
41
41
  case "d":
42
- return o * e;
42
+ return n * e;
43
43
  case "hours":
44
44
  case "hour":
45
45
  case "hrs":
46
46
  case "hr":
47
47
  case "h":
48
- return o * c;
48
+ return n * c;
49
49
  case "minutes":
50
50
  case "minute":
51
51
  case "mins":
52
52
  case "min":
53
53
  case "m":
54
- return o * r;
54
+ return n * r;
55
55
  case "seconds":
56
56
  case "second":
57
57
  case "secs":
58
58
  case "sec":
59
59
  case "s":
60
- return o * n;
60
+ return n * s;
61
61
  case "milliseconds":
62
62
  case "millisecond":
63
63
  case "msecs":
64
64
  case "msec":
65
65
  case "ms":
66
- return o;
66
+ return n;
67
67
  default:
68
68
  return;
69
69
  }
70
70
  }
71
71
  }
72
72
  }
73
- function p(s) {
74
- var t = Math.abs(s);
75
- return t >= e ? Math.round(s / e) + "d" : t >= c ? Math.round(s / c) + "h" : t >= r ? Math.round(s / r) + "m" : t >= n ? Math.round(s / n) + "s" : s + "ms";
73
+ function p(o) {
74
+ var t = Math.abs(o);
75
+ return t >= e ? Math.round(o / e) + "d" : t >= c ? Math.round(o / c) + "h" : t >= r ? Math.round(o / r) + "m" : t >= s ? Math.round(o / s) + "s" : o + "ms";
76
76
  }
77
- function i(s) {
78
- var t = Math.abs(s);
79
- return t >= e ? d(s, t, e, "day") : t >= c ? d(s, t, c, "hour") : t >= r ? d(s, t, r, "minute") : t >= n ? d(s, t, n, "second") : s + " ms";
77
+ function i(o) {
78
+ var t = Math.abs(o);
79
+ return t >= e ? d(o, t, e, "day") : t >= c ? d(o, t, c, "hour") : t >= r ? d(o, t, r, "minute") : t >= s ? d(o, t, s, "second") : o + " ms";
80
80
  }
81
- function d(s, t, o, u) {
82
- var f = t >= o * 1.5;
83
- return Math.round(s / o) + " " + u + (f ? "s" : "");
81
+ function d(o, t, n, u) {
82
+ var f = t >= n * 1.5;
83
+ return Math.round(o / n) + " " + u + (f ? "s" : "");
84
84
  }
85
- return j;
85
+ return I;
86
86
  }
87
- var E, $;
88
- function z() {
89
- if ($) return E;
87
+ var A, $;
88
+ function T() {
89
+ if ($) return A;
90
90
  $ = 1;
91
- function n(r) {
92
- e.debug = e, e.default = e, e.coerce = d, e.disable = p, e.enable = l, e.enabled = i, e.humanize = T(), e.destroy = s, Object.keys(r).forEach((t) => {
91
+ function s(r) {
92
+ e.debug = e, e.default = e, e.coerce = d, e.disable = p, e.enable = l, e.enabled = i, e.humanize = P(), e.destroy = o, Object.keys(r).forEach((t) => {
93
93
  e[t] = r[t];
94
94
  }), e.names = [], e.skips = [], e.formatters = {};
95
95
  function c(t) {
96
- let o = 0;
96
+ let n = 0;
97
97
  for (let u = 0; u < t.length; u++)
98
- o = (o << 5) - o + t.charCodeAt(u), o |= 0;
99
- return e.colors[Math.abs(o) % e.colors.length];
98
+ n = (n << 5) - n + t.charCodeAt(u), n |= 0;
99
+ return e.colors[Math.abs(n) % e.colors.length];
100
100
  }
101
101
  e.selectColor = c;
102
102
  function e(t) {
103
- let o, u = null, f, w;
103
+ let n, u = null, f, y;
104
104
  function C(...h) {
105
105
  if (!C.enabled)
106
106
  return;
107
- const y = C, g = Number(/* @__PURE__ */ new Date()), L = g - (o || g);
108
- y.diff = L, y.prev = o, y.curr = g, o = g, h[0] = e.coerce(h[0]), typeof h[0] != "string" && h.unshift("%O");
107
+ const w = C, g = Number(/* @__PURE__ */ new Date()), U = g - (n || g);
108
+ w.diff = U, w.prev = n, w.curr = g, n = g, h[0] = e.coerce(h[0]), typeof h[0] != "string" && h.unshift("%O");
109
109
  let F = 0;
110
- h[0] = h[0].replace(/%([a-zA-Z%])/g, (I, q) => {
111
- if (I === "%%")
110
+ h[0] = h[0].replace(/%([a-zA-Z%])/g, (j, J) => {
111
+ if (j === "%%")
112
112
  return "%";
113
113
  F++;
114
- const _ = e.formatters[q];
114
+ const _ = e.formatters[J];
115
115
  if (typeof _ == "function") {
116
- const N = h[F];
117
- I = _.call(y, N), h.splice(F, 1), F--;
116
+ const q = h[F];
117
+ j = _.call(w, q), h.splice(F, 1), F--;
118
118
  }
119
- return I;
120
- }), e.formatArgs.call(y, h), (y.log || e.log).apply(y, h);
119
+ return j;
120
+ }), e.formatArgs.call(w, h), (w.log || e.log).apply(w, h);
121
121
  }
122
122
  return C.namespace = t, C.useColors = e.useColors(), C.color = e.selectColor(t), C.extend = a, C.destroy = e.destroy, Object.defineProperty(C, "enabled", {
123
123
  enumerable: !0,
124
124
  configurable: !1,
125
- get: () => u !== null ? u : (f !== e.namespaces && (f = e.namespaces, w = e.enabled(t)), w),
125
+ get: () => u !== null ? u : (f !== e.namespaces && (f = e.namespaces, y = e.enabled(t)), y),
126
126
  set: (h) => {
127
127
  u = h;
128
128
  }
129
129
  }), typeof e.init == "function" && e.init(C), C;
130
130
  }
131
- function a(t, o) {
132
- const u = e(this.namespace + (typeof o > "u" ? ":" : o) + t);
131
+ function a(t, n) {
132
+ const u = e(this.namespace + (typeof n > "u" ? ":" : n) + t);
133
133
  return u.log = this.log, u;
134
134
  }
135
135
  function l(t) {
136
136
  e.save(t), e.namespaces = t, e.names = [], e.skips = [];
137
- const o = (typeof t == "string" ? t : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
138
- for (const u of o)
137
+ const n = (typeof t == "string" ? t : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
138
+ for (const u of n)
139
139
  u[0] === "-" ? e.skips.push(u.slice(1)) : e.names.push(u);
140
140
  }
141
- function m(t, o) {
142
- let u = 0, f = 0, w = -1, C = 0;
141
+ function m(t, n) {
142
+ let u = 0, f = 0, y = -1, C = 0;
143
143
  for (; u < t.length; )
144
- if (f < o.length && (o[f] === t[u] || o[f] === "*"))
145
- o[f] === "*" ? (w = f, C = u, f++) : (u++, f++);
146
- else if (w !== -1)
147
- f = w + 1, C++, u = C;
144
+ if (f < n.length && (n[f] === t[u] || n[f] === "*"))
145
+ n[f] === "*" ? (y = f, C = u, f++) : (u++, f++);
146
+ else if (y !== -1)
147
+ f = y + 1, C++, u = C;
148
148
  else
149
149
  return !1;
150
- for (; f < o.length && o[f] === "*"; )
150
+ for (; f < n.length && n[f] === "*"; )
151
151
  f++;
152
- return f === o.length;
152
+ return f === n.length;
153
153
  }
154
154
  function p() {
155
155
  const t = [
156
156
  ...e.names,
157
- ...e.skips.map((o) => "-" + o)
157
+ ...e.skips.map((n) => "-" + n)
158
158
  ].join(",");
159
159
  return e.enable(""), t;
160
160
  }
161
161
  function i(t) {
162
- for (const o of e.skips)
163
- if (m(t, o))
162
+ for (const n of e.skips)
163
+ if (m(t, n))
164
164
  return !1;
165
- for (const o of e.names)
166
- if (m(t, o))
165
+ for (const n of e.names)
166
+ if (m(t, n))
167
167
  return !0;
168
168
  return !1;
169
169
  }
170
170
  function d(t) {
171
171
  return t instanceof Error ? t.stack || t.message : t;
172
172
  }
173
- function s() {
173
+ function o() {
174
174
  console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
175
175
  }
176
176
  return e.enable(e.load()), e;
177
177
  }
178
- return E = n, E;
178
+ return A = s, A;
179
179
  }
180
180
  var O;
181
- function B() {
182
- return O || (O = 1, (function(n, r) {
181
+ function z() {
182
+ return O || (O = 1, (function(s, r) {
183
183
  r.formatArgs = e, r.save = a, r.load = l, r.useColors = c, r.storage = m(), r.destroy = /* @__PURE__ */ (() => {
184
184
  let i = !1;
185
185
  return () => {
@@ -276,13 +276,13 @@ function B() {
276
276
  typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
277
277
  }
278
278
  function e(i) {
279
- if (i[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + i[0] + (this.useColors ? "%c " : " ") + "+" + n.exports.humanize(this.diff), !this.useColors)
279
+ if (i[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + i[0] + (this.useColors ? "%c " : " ") + "+" + s.exports.humanize(this.diff), !this.useColors)
280
280
  return;
281
281
  const d = "color: " + this.color;
282
282
  i.splice(1, 0, d, "color: inherit");
283
- let s = 0, t = 0;
284
- i[0].replace(/%[a-zA-Z%]/g, (o) => {
285
- o !== "%%" && (s++, o === "%c" && (t = s));
283
+ let o = 0, t = 0;
284
+ i[0].replace(/%[a-zA-Z%]/g, (n) => {
285
+ n !== "%%" && (o++, n === "%c" && (t = o));
286
286
  }), i.splice(t, 0, d);
287
287
  }
288
288
  r.log = console.debug || console.log || (() => {
@@ -307,8 +307,8 @@ function B() {
307
307
  } catch {
308
308
  }
309
309
  }
310
- n.exports = z()(r);
311
- const { formatters: p } = n.exports;
310
+ s.exports = T()(r);
311
+ const { formatters: p } = s.exports;
312
312
  p.j = function(i) {
313
313
  try {
314
314
  return JSON.stringify(i);
@@ -318,39 +318,39 @@ function B() {
318
318
  };
319
319
  })(b, b.exports)), b.exports;
320
320
  }
321
- var D = B();
322
- const S = /* @__PURE__ */ P(D);
321
+ var B = z();
322
+ const R = /* @__PURE__ */ N(B);
323
323
  let v;
324
- const R = async function(...r) {
324
+ const S = async function(...r) {
325
325
  return v || (typeof window < "u" && typeof document < "u" ? v = window.fetch.bind(window) : v = (await import("./fetch-retry.umd-g1itNdNw.js").then((a) => a.f)).default(globalThis.fetch)), v.apply(null, r);
326
326
  };
327
- async function H(n) {
327
+ async function D(s) {
328
328
  if (typeof window < "u" && typeof document < "u")
329
329
  return await import(
330
330
  /* @vite-ignore */
331
- n
331
+ s
332
332
  );
333
333
  {
334
334
  const { nodeImportHttpRuntime: r } = await import("./ImportHttpRuntime.node-B85BNHJG.js");
335
- return r(n, { fetchImpl: R });
335
+ return r(s, { fetchImpl: S });
336
336
  }
337
337
  }
338
- const J = S("efp:loader:resolve");
339
- async function M(n, r = {}) {
338
+ const L = R("efp:loader:resolve");
339
+ async function M(s, r = {}) {
340
340
  var l, m, p;
341
341
  const c = (l = r.maxHops) != null ? l : 32, e = /* @__PURE__ */ new Set();
342
- let a = n;
342
+ let a = s;
343
343
  for (let i = 0; i < c; i++) {
344
344
  if (a && typeof a == "object" && "$ref" in a) {
345
- const s = a.$ref;
346
- if (typeof s != "string")
347
- throw new Error(`$ref must be a string, got: ${typeof s}`);
348
- if (U(s)) {
349
- if (e.has(s))
350
- throw new Error(`Circular $ref detected at: ${s}`);
351
- e.add(s), J("Loading JSON ref:", s), (m = r.fetchCallback) == null || m.call(r, s);
352
- const t = await W(s, r.signal);
353
- (p = r.onHop) == null || p.call(r, { hop: i, ref: s, via: t.__via }), a = t.value;
345
+ const o = a.$ref;
346
+ if (typeof o != "string")
347
+ throw new Error(`$ref must be a string, got: ${typeof o}`);
348
+ if (H(o)) {
349
+ if (e.has(o))
350
+ throw new Error(`Circular $ref detected at: ${o}`);
351
+ e.add(o), L("Loading JSON ref:", o), (m = r.fetchCallback) == null || m.call(r, o);
352
+ const t = await W(o, r.signal);
353
+ (p = r.onHop) == null || p.call(r, { hop: i, ref: o, via: t.__via }), a = t.value;
354
354
  continue;
355
355
  }
356
356
  return a;
@@ -359,13 +359,13 @@ async function M(n, r = {}) {
359
359
  }
360
360
  throw new Error(`Too many ref hops (>${c}). Possible loop or unexpectedly deep chain.`);
361
361
  }
362
- function U(n) {
363
- return n.startsWith("http://") || n.startsWith("https://");
362
+ function H(s) {
363
+ return s.startsWith("http://") || s.startsWith("https://");
364
364
  }
365
- async function W(n, r) {
366
- const c = await G(n);
365
+ async function W(s, r) {
366
+ const c = await G(s);
367
367
  if (c.ok) return { value: c.value, __via: "import" };
368
- const e = await R(n, {
368
+ const e = await S(s, {
369
369
  method: "GET",
370
370
  signal: r,
371
371
  headers: {
@@ -374,7 +374,7 @@ async function W(n, r) {
374
374
  }
375
375
  });
376
376
  if (!e.ok)
377
- throw new Error(`Failed to fetch JSON ref: ${n} (${e.status} ${e.statusText})`);
377
+ throw new Error(`Failed to fetch JSON ref: ${s} (${e.status} ${e.statusText})`);
378
378
  const a = e.headers.get("content-type") || "";
379
379
  if (a.includes("application/json") || a.includes("+json"))
380
380
  return { value: await e.json(), __via: "fetch" };
@@ -385,19 +385,19 @@ async function W(n, r) {
385
385
  return { value: l, __via: "fetch" };
386
386
  }
387
387
  }
388
- async function G(n) {
388
+ async function G(s) {
389
389
  var r, c;
390
390
  try {
391
391
  const e = await import(
392
392
  /* @vite-ignore */
393
- n
393
+ s
394
394
  );
395
- return J("Imported JSON via import():", n), { ok: !0, value: (r = e == null ? void 0 : e.default) != null ? r : e };
395
+ return L("Imported JSON via import():", s), { ok: !0, value: (r = e == null ? void 0 : e.default) != null ? r : e };
396
396
  } catch (e) {
397
397
  try {
398
398
  const a = await import(
399
399
  /* @vite-ignore */
400
- n
400
+ s
401
401
  );
402
402
  return { ok: !0, value: (c = a == null ? void 0 : a.default) != null ? c : a };
403
403
  } catch (a) {
@@ -405,36 +405,40 @@ async function G(n) {
405
405
  }
406
406
  }
407
407
  }
408
- const k = S("efp:loader");
409
- typeof A < "u" ? k("Initialized", { version: A[0], builtAt: A[1] }) : k("Initialized");
410
- async function Z(n, r) {
411
- k("Loading manifest:", n), typeof n == "string" && (n = { $ref: n }), n = await M(n, { fetchCallback: r == null ? void 0 : r.fetchCallback });
412
- const c = await M(n.runtime, {
413
- fetchCallback: r == null ? void 0 : r.fetchCallback
414
- });
415
- if (k("Resolved runtime URL:", c), typeof c != "string")
416
- throw new Error("Resolved runtime is not a string ");
417
- const e = await H(c);
418
- return e.meta = { runtime: c }, e;
408
+ const E = R("efp:loader");
409
+ typeof k < "u" ? E("Initialized", { version: k[0], builtAt: k[1] }) : E("Initialized");
410
+ async function Z(s, r) {
411
+ let c = await M(s, { fetchCallback: r == null ? void 0 : r.fetchCallback }), e;
412
+ if (typeof c == "string" ? e = c : typeof c == "object" && "runtimeUrl" in c && (e = await M(c.runtimeUrl, { fetchCallback: r == null ? void 0 : r.fetchCallback })), e === void 0)
413
+ throw new Error(
414
+ "Could not determine runtime URL. It must be resolvable to a string or to a manifest with a runtimeUrl property."
415
+ );
416
+ if (E("Loading runtime:", e), typeof e != "string")
417
+ throw new Error("Runtime URL must be a string");
418
+ const a = await D(e);
419
+ return a.meta = { runtimeUrl: e }, a;
419
420
  }
420
421
  const K = new Proxy(
421
422
  {},
422
423
  {
423
- get: (n, r) => async (...c) => {
424
- const e = c[0], a = await Z(e), l = a[r];
424
+ get: (s, r) => async (...c) => {
425
+ const e = c[0];
426
+ if (e == null || typeof e != "object")
427
+ throw new Error(`First argument must be a manifest object, got: ${typeof e}`);
428
+ const a = await Z(e), l = a[r];
425
429
  if (typeof l != "function")
426
430
  throw new Error(`API has no function named '${r}'`);
427
431
  return l.apply(a, c);
428
432
  }
429
433
  }
430
434
  );
431
- async function V(n, ...r) {
432
- return K.load(n, ...r);
435
+ async function V(s, ...r) {
436
+ return K.load(s, ...r);
433
437
  }
434
438
  export {
435
- S as d,
439
+ R as d,
436
440
  K as default,
437
- P as g,
441
+ N as g,
438
442
  V as load,
439
443
  Z as loadApi
440
444
  };
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":["../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js","../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js","../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js","../../src/fetch.ts","../../src/importHttpRuntime.ts","../../src/resolve.ts","../../src/index.ts"],"sourcesContent":["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '')\n\t\t\t.trim()\n\t\t\t.replace(/\\s+/g, ',')\n\t\t\t.split(',')\n\t\t\t.filter(Boolean);\n\n\t\tfor (const ns of split) {\n\t\t\tif (ns[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(ns.slice(1));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(ns);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given string matches a namespace template, honoring\n\t * asterisks as wildcards.\n\t *\n\t * @param {String} search\n\t * @param {String} template\n\t * @return {Boolean}\n\t */\n\tfunction matchesTemplate(search, template) {\n\t\tlet searchIndex = 0;\n\t\tlet templateIndex = 0;\n\t\tlet starIndex = -1;\n\t\tlet matchIndex = 0;\n\n\t\twhile (searchIndex < search.length) {\n\t\t\tif (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {\n\t\t\t\t// Match character or proceed with wildcard\n\t\t\t\tif (template[templateIndex] === '*') {\n\t\t\t\t\tstarIndex = templateIndex;\n\t\t\t\t\tmatchIndex = searchIndex;\n\t\t\t\t\ttemplateIndex++; // Skip the '*'\n\t\t\t\t} else {\n\t\t\t\t\tsearchIndex++;\n\t\t\t\t\ttemplateIndex++;\n\t\t\t\t}\n\t\t\t} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition\n\t\t\t\t// Backtrack to the last '*' and try to match more characters\n\t\t\t\ttemplateIndex = starIndex + 1;\n\t\t\t\tmatchIndex++;\n\t\t\t\tsearchIndex = matchIndex;\n\t\t\t} else {\n\t\t\t\treturn false; // No match\n\t\t\t}\n\t\t}\n\n\t\t// Handle trailing '*' in template\n\t\twhile (templateIndex < template.length && template[templateIndex] === '*') {\n\t\t\ttemplateIndex++;\n\t\t}\n\n\t\treturn templateIndex === template.length;\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names,\n\t\t\t...createDebug.skips.map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tfor (const skip of createDebug.skips) {\n\t\t\tif (matchesTemplate(name, skip)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (const ns of createDebug.names) {\n\t\t\tif (matchesTemplate(name, ns)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","let fn: typeof fetch;\nexport const fetch = async function fetch(\n ...args: Parameters<typeof window.fetch>\n): ReturnType<typeof window.fetch> {\n if (!fn) {\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n fn = window.fetch.bind(window);\n } else {\n const fr = await import('fetch-retry');\n const fetchWithRetry = fr.default(globalThis.fetch);\n fn = fetchWithRetry;\n }\n }\n return fn.apply(null, args);\n};\n","import { fetch } from './fetch';\n\nexport async function importHttpRuntime<TModule = any>(runtime: string): Promise<TModule> {\n // if browser, use dynamic import\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n const module = await import(/* @vite-ignore */ runtime);\n return module as TModule;\n } else {\n const { nodeImportHttpRuntime } = await import('./ImportHttpRuntime.node');\n return nodeImportHttpRuntime<TModule>(runtime, { fetchImpl: fetch });\n }\n}\n","// resolveHttpRefToString.ts\n// Follows $ref chains until finding a value without $ref.\n//\n// Rules:\n// - If value is an object with {$ref: string} -> follow it (fetch if http/https URL)\n// - Otherwise -> return the value as-is\n//\n// Browser: tries `import(url, { with: { type: 'json' } })` first, falls back to fetch.\n// Node: uses fetch (Node 18+ has global fetch).\n\nimport debug from 'debug';\nimport { fetch } from './fetch';\n\nconst log = debug('efp:loader:resolve');\n\nexport type ResolveOptions = {\n maxHops?: number;\n signal?: AbortSignal;\n // Hook if you want to observe each hop (debug/log/preload metrics)\n onHop?: (info: { hop: number; ref: string; via: 'import' | 'fetch' }) => void;\n fetchCallback?: (ref: string) => void;\n};\n\nexport async function resolve<T>(input: unknown, options: ResolveOptions = {}): Promise<T> {\n const maxHops = options.maxHops ?? 32;\n const seen = new Set<string>();\n\n let cur: unknown = input;\n\n for (let hop = 0; hop < maxHops; hop++) {\n // If it's an object with $ref, follow it\n if (cur && typeof cur === 'object' && '$ref' in cur) {\n const obj = cur as any;\n const ref = obj.$ref;\n\n if (typeof ref !== 'string') {\n throw new Error(`$ref must be a string, got: ${typeof ref}`);\n }\n\n // If it's an http/https URL, fetch it\n if (isHttpUrl(ref)) {\n if (seen.has(ref)) {\n throw new Error(`Circular $ref detected at: ${ref}`);\n }\n seen.add(ref);\n log('Loading JSON ref:', ref);\n options.fetchCallback?.(ref);\n const json = await loadJson(ref, options.signal);\n options.onHop?.({ hop, ref, via: json.__via });\n cur = json.value;\n continue;\n }\n\n // Non-http $ref (e.g., relative, custom schema) - return the object as-is\n // (caller is responsible for handling these)\n return cur as T;\n }\n\n // No $ref found - return current value\n return cur as T;\n }\n\n throw new Error(`Too many ref hops (>${maxHops}). Possible loop or unexpectedly deep chain.`);\n}\n\nfunction isHttpUrl(s: string): boolean {\n return s.startsWith('http://') || s.startsWith('https://');\n}\n\nasync function loadJson(\n url: string,\n signal?: AbortSignal\n): Promise<{ value: unknown; __via: 'import' | 'fetch' }> {\n // Try import() JSON first (browser-friendly; depends on runtime/bundler support + CORS)\n const imported = await tryImportJson(url);\n if (imported.ok) return { value: imported.value, __via: 'import' };\n\n // Fallback to fetch\n const res = await fetch(url, {\n method: 'GET',\n signal,\n headers: {\n // Helps some CDNs/content negotiation setups\n Accept: 'application/json, text/plain;q=0.9, */*;q=0.1',\n },\n });\n\n if (!res.ok) {\n throw new Error(`Failed to fetch JSON ref: ${url} (${res.status} ${res.statusText})`);\n }\n\n // Prefer JSON; if server mislabels, fallback to text->JSON parse.\n const ct = res.headers.get('content-type') || '';\n if (ct.includes('application/json') || ct.includes('+json')) {\n return { value: await res.json(), __via: 'fetch' };\n }\n\n const text = await res.text();\n try {\n return { value: JSON.parse(text), __via: 'fetch' };\n } catch {\n // If the endpoint literally returns a plain string (not JSON), accept it.\n return { value: text, __via: 'fetch' };\n }\n}\n\nasync function tryImportJson(\n url: string\n): Promise<{ ok: true; value: unknown } | { ok: false; error: unknown }> {\n // `with: { type: 'json' }` is the modern import assertion form.\n // Some environments still only accept `assert: { type: 'json' }`.\n try {\n //// @ts-expect-error - TS lib definitions differ across versions\n const mod = await import(/* @vite-ignore */ url, { with: { type: 'json' } });\n log('Imported JSON via import():', url);\n return { ok: true, value: mod?.default ?? mod };\n } catch (e1) {\n try {\n //// @ts-expect-error - fallback for older assertion syntax\n const mod = await import(/* @vite-ignore */ url, { assert: { type: 'json' } });\n return { ok: true, value: mod?.default ?? mod };\n } catch (e2) {\n return { ok: false, error: e2 ?? e1 };\n }\n }\n}\n","import debug from 'debug';\nimport { importHttpRuntime } from './importHttpRuntime';\nimport { resolve } from './resolve';\nimport { LoaderApi, Manifest, Ref } from './types';\n\nconst log = debug('efp:loader');\n\ndeclare global {\n const __efpLoaderBuildInfo: [version: string, builtAt: string] | undefined;\n}\n\nif (typeof __efpLoaderBuildInfo !== 'undefined') {\n log('Initialized', { version: __efpLoaderBuildInfo[0], builtAt: __efpLoaderBuildInfo[1] });\n} else {\n log('Initialized');\n}\n\nexport async function loadApi(\n manifest: Manifest | Ref | string,\n options?: {\n fetchCallback?: (ref: string) => void;\n }\n): Promise<LoaderApi> {\n log('Loading manifest:', manifest);\n if (typeof manifest === 'string') {\n manifest = { $ref: manifest };\n }\n manifest = await resolve<Manifest>(manifest, { fetchCallback: options?.fetchCallback });\n const runtime = await resolve<string>(manifest.runtime, {\n fetchCallback: options?.fetchCallback,\n });\n\n log('Resolved runtime URL:', runtime);\n if (typeof runtime !== 'string') {\n throw new Error('Resolved runtime is not a string ');\n }\n\n const api = await importHttpRuntime(runtime);\n api.meta = { runtime };\n return api; //{ ...api, runtime } as LoaderApi;\n}\n\n// allow calling api functions directly from here\nconst api: LoaderApi = new Proxy(\n {},\n {\n get: (_, prop: string) => {\n return async (...args: any[]) => {\n const manifest = args[0];\n const runtimeApi = await loadApi(manifest);\n const fn = runtimeApi[prop];\n if (typeof fn !== 'function') {\n throw new Error(`API has no function named '${prop}'`);\n }\n return fn.apply(runtimeApi, args as any);\n };\n },\n }\n);\n\nexport async function load(manifest: Manifest | Ref | string, ...args: unknown[]) {\n return api.load!(manifest, ...args);\n}\n\nexport default api;\n"],"names":["hasRequiredMs","s","m","h","d","w","ms","val","options","type","parse","fmtLong","fmtShort","str","match","n","y","msAbs","plural","name","isPlural","hasRequiredCommon","setup","env","createDebug","coerce","disable","enable","enabled","requireMs","key","selectColor","namespace","i","hash","prevTime","enableOverride","namespacesCache","debug","args","curr","self","index","format","formatter","enabledCache","v","delimiter","newDebug","namespaces","split","ns","matchesTemplate","search","template","searchIndex","templateIndex","starIndex","matchIndex","skip","destroy","module","exports","formatArgs","save","load","localstorage","warned","useColors","c","lastC","r","formatters","error","fn","fetch","importHttpRuntime","runtime","nodeImportHttpRuntime","log$1","resolve","maxHops","_a","seen","cur","input","hop","ref","log","_b","json","loadJson","_c","isHttpUrl","signal","imported","url","res","ct","text","tryImportJson","mod","e1","e2","__efpLoaderBuildInfo","loadApi","manifest","api","api2","_","prop","runtimeApi"],"mappings":";;;;;;;AAIA,EAAAA,IAAY;AACZ,MAAIC,IAAI,KACJC,IAAID,IAAI,IACRE,IAAID,IAAI,IACRE,IAAID,IAAI,IACRE,IAAID,IAAI;AAiBZ,EAAAE,IAAE,SAAUC,GAAOC,GAAM;AACvB,IAAAA,IAAQA,KAAa,CAAA;AACrB,QAAIC,IAAI,OAAKF;AACf,QAAIE,MAAO,YAAUF,EAAA,SAAA;AAClB,aAAMG,EAAQH,CAAA;AACb,QAAOE,MAAQ,YAAe,SAAOF,CAAA;AACzC,aAAAC,EAAA,OAAAG,EAAAJ,CAAA,IAAAK,EAAAL,CAAA;AAEA,UAAI,IAAA;AAAA,MACJ,0DACG,KAAA,UAAAA,CAAA;AAAA,IACF;AAAA;AAWD,WAAQG,EAAOG,GAAI;QACjBA,IAAI,OAAIA,CAAM,GACZ,EAAAA,EAAA,SAAA;UAGAC,IAAA,mIAAA;AAAA,QACDD;AAAA,MACD;UACEC,GAGF;AAAA,YAAIC,IAAI,WAAWD,EAAK,CAAA,CAAA,QACZA,EAAA,CAAA,KAAA,MAAA,YAAA;AACd,gBAASL,GAAO;AAAA,UACZ,KAAK;AAAA,UACL,KAAK;AAAA,UACL,KAAK;AAAA,UACL,KAAK;AAAA,eACH;mBACGM,IAAOC;AAAA,UACZ,KAAK;AAAA,UACL,KAAK;AAAA,eACH;mBACGD,IAAMV;AAAA,UACX,KAAK;AAAA,UACL,KAAK;AAAA,eACH;mBACGU,IAAOX;AAAA,UACZ,KAAK;AAAA,UACL,KAAK;AAAA,UACL,KAAK;AAAA,UACL,KAAK;AAAA,eACH;mBACGW,IAAAZ;AAAA,UACL,KAAK;AAAA,UACL,KAAK;AAAA,UACL,KAAK;AAAA,UACL,KAAK;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AAA;AAGA8B,QAAIC,IAAO,QAAU/B,CAAA;AACrB,SAAA+B,SAAOD,EAAAA,SAAAA,EAAAA,GACTC;AAGA;AAA2B,MACxBD,IAAA,IAAA;AAAA,EACD,CAAA;AAAA,EAAA;AAAA,IAEI,KAAA,CAAAE,GAAOC,gBACCvE,MAAiB;AACvB,YAAMmE,IAAAnE,MACAwE,IAAK,QAAeL,CAAA,GACtBhC,IAAOqC;AACT,UAAA,OAAMrC,KAAU;AAClB,cAAA,IAAA,MAAA,8BAAAoC,CAAA,GAAA;AAEF,aAAApC,EAAA,MAAAqC,GAAAxE,CAAA;AAAA,IACF;AAAA,EAEJ;AAEA;AACE,eAAW0B,EAAMyC,MAAanE,GAAI;AACpC,SAAAoE,EAAA,KAAAD,GAAA,GAAAnE,CAAA;;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"bundle.js","sources":["../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js","../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js","../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js","../../src/fetch.ts","../../src/importHttpRuntime.ts","../../src/resolve.ts","../../src/index.ts"],"sourcesContent":["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '')\n\t\t\t.trim()\n\t\t\t.replace(/\\s+/g, ',')\n\t\t\t.split(',')\n\t\t\t.filter(Boolean);\n\n\t\tfor (const ns of split) {\n\t\t\tif (ns[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(ns.slice(1));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(ns);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given string matches a namespace template, honoring\n\t * asterisks as wildcards.\n\t *\n\t * @param {String} search\n\t * @param {String} template\n\t * @return {Boolean}\n\t */\n\tfunction matchesTemplate(search, template) {\n\t\tlet searchIndex = 0;\n\t\tlet templateIndex = 0;\n\t\tlet starIndex = -1;\n\t\tlet matchIndex = 0;\n\n\t\twhile (searchIndex < search.length) {\n\t\t\tif (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {\n\t\t\t\t// Match character or proceed with wildcard\n\t\t\t\tif (template[templateIndex] === '*') {\n\t\t\t\t\tstarIndex = templateIndex;\n\t\t\t\t\tmatchIndex = searchIndex;\n\t\t\t\t\ttemplateIndex++; // Skip the '*'\n\t\t\t\t} else {\n\t\t\t\t\tsearchIndex++;\n\t\t\t\t\ttemplateIndex++;\n\t\t\t\t}\n\t\t\t} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition\n\t\t\t\t// Backtrack to the last '*' and try to match more characters\n\t\t\t\ttemplateIndex = starIndex + 1;\n\t\t\t\tmatchIndex++;\n\t\t\t\tsearchIndex = matchIndex;\n\t\t\t} else {\n\t\t\t\treturn false; // No match\n\t\t\t}\n\t\t}\n\n\t\t// Handle trailing '*' in template\n\t\twhile (templateIndex < template.length && template[templateIndex] === '*') {\n\t\t\ttemplateIndex++;\n\t\t}\n\n\t\treturn templateIndex === template.length;\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names,\n\t\t\t...createDebug.skips.map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tfor (const skip of createDebug.skips) {\n\t\t\tif (matchesTemplate(name, skip)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (const ns of createDebug.names) {\n\t\t\tif (matchesTemplate(name, ns)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","let fn: typeof fetch;\nexport const fetch = async function fetch(\n ...args: Parameters<typeof window.fetch>\n): ReturnType<typeof window.fetch> {\n if (!fn) {\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n fn = window.fetch.bind(window);\n } else {\n const fr = await import('fetch-retry');\n const fetchWithRetry = fr.default(globalThis.fetch);\n fn = fetchWithRetry;\n }\n }\n return fn.apply(null, args);\n};\n","import { fetch } from './fetch';\n\nexport async function importHttpRuntime<TModule = any>(runtime: string): Promise<TModule> {\n // if browser, use dynamic import\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n const module = await import(/* @vite-ignore */ runtime);\n return module as TModule;\n } else {\n const { nodeImportHttpRuntime } = await import('./ImportHttpRuntime.node');\n return nodeImportHttpRuntime<TModule>(runtime, { fetchImpl: fetch });\n }\n}\n","// resolveHttpRefToString.ts\n// Follows $ref chains until finding a value without $ref.\n//\n// Rules:\n// - If value is an object with {$ref: string} -> follow it (fetch if http/https URL)\n// - Otherwise -> return the value as-is\n//\n// Browser: tries `import(url, { with: { type: 'json' } })` first, falls back to fetch.\n// Node: uses fetch (Node 18+ has global fetch).\n\nimport debug from 'debug';\nimport { fetch } from './fetch';\n\nconst log = debug('efp:loader:resolve');\n\nexport type ResolveOptions = {\n maxHops?: number;\n signal?: AbortSignal;\n // Hook if you want to observe each hop (debug/log/preload metrics)\n onHop?: (info: { hop: number; ref: string; via: 'import' | 'fetch' }) => void;\n fetchCallback?: (ref: string) => void;\n};\n\nexport async function resolve<T>(input: unknown, options: ResolveOptions = {}): Promise<T> {\n const maxHops = options.maxHops ?? 32;\n const seen = new Set<string>();\n\n let cur: unknown = input;\n\n for (let hop = 0; hop < maxHops; hop++) {\n // If it's an object with $ref, follow it\n if (cur && typeof cur === 'object' && '$ref' in cur) {\n const obj = cur as any;\n const ref = obj.$ref;\n\n if (typeof ref !== 'string') {\n throw new Error(`$ref must be a string, got: ${typeof ref}`);\n }\n\n // If it's an http/https URL, fetch it\n if (isHttpUrl(ref)) {\n if (seen.has(ref)) {\n throw new Error(`Circular $ref detected at: ${ref}`);\n }\n seen.add(ref);\n log('Loading JSON ref:', ref);\n options.fetchCallback?.(ref);\n const json = await loadJson(ref, options.signal);\n options.onHop?.({ hop, ref, via: json.__via });\n cur = json.value;\n continue;\n }\n\n // Non-http $ref (e.g., relative, custom schema) - return the object as-is\n // (caller is responsible for handling these)\n return cur as T;\n }\n\n // No $ref found - return current value\n return cur as T;\n }\n\n throw new Error(`Too many ref hops (>${maxHops}). Possible loop or unexpectedly deep chain.`);\n}\n\nfunction isHttpUrl(s: string): boolean {\n return s.startsWith('http://') || s.startsWith('https://');\n}\n\nasync function loadJson(\n url: string,\n signal?: AbortSignal\n): Promise<{ value: unknown; __via: 'import' | 'fetch' }> {\n // Try import() JSON first (browser-friendly; depends on runtime/bundler support + CORS)\n const imported = await tryImportJson(url);\n if (imported.ok) return { value: imported.value, __via: 'import' };\n\n // Fallback to fetch\n const res = await fetch(url, {\n method: 'GET',\n signal,\n headers: {\n // Helps some CDNs/content negotiation setups\n Accept: 'application/json, text/plain;q=0.9, */*;q=0.1',\n },\n });\n\n if (!res.ok) {\n throw new Error(`Failed to fetch JSON ref: ${url} (${res.status} ${res.statusText})`);\n }\n\n // Prefer JSON; if server mislabels, fallback to text->JSON parse.\n const ct = res.headers.get('content-type') || '';\n if (ct.includes('application/json') || ct.includes('+json')) {\n return { value: await res.json(), __via: 'fetch' };\n }\n\n const text = await res.text();\n try {\n return { value: JSON.parse(text), __via: 'fetch' };\n } catch {\n // If the endpoint literally returns a plain string (not JSON), accept it.\n return { value: text, __via: 'fetch' };\n }\n}\n\nasync function tryImportJson(\n url: string\n): Promise<{ ok: true; value: unknown } | { ok: false; error: unknown }> {\n // `with: { type: 'json' }` is the modern import assertion form.\n // Some environments still only accept `assert: { type: 'json' }`.\n try {\n //// @ts-expect-error - TS lib definitions differ across versions\n const mod = await import(/* @vite-ignore */ url, { with: { type: 'json' } });\n log('Imported JSON via import():', url);\n return { ok: true, value: mod?.default ?? mod };\n } catch (e1) {\n try {\n //// @ts-expect-error - fallback for older assertion syntax\n const mod = await import(/* @vite-ignore */ url, { assert: { type: 'json' } });\n return { ok: true, value: mod?.default ?? mod };\n } catch (e2) {\n return { ok: false, error: e2 ?? e1 };\n }\n }\n}\n","import debug from 'debug';\nimport { importHttpRuntime } from './importHttpRuntime';\nimport { resolve } from './resolve';\nimport type { LoaderApi, Manifest, Ref } from './types';\n\nconst log = debug('efp:loader');\n\ndeclare global {\n const __efpLoaderBuildInfo: [version: string, builtAt: string] | undefined;\n}\n\nif (typeof __efpLoaderBuildInfo !== 'undefined') {\n log('Initialized', { version: __efpLoaderBuildInfo[0], builtAt: __efpLoaderBuildInfo[1] });\n} else {\n log('Initialized');\n}\n\nexport async function loadApi(\n /**\n * \"url\" or { $ref: \"url\" }, or { runtimeUrl: \"url\" | { $ref: \"url\" } }\n */\n runtimeUrlOrManifest: string | Ref | Manifest,\n options?: {\n fetchCallback?: (ref: string) => void;\n }\n): Promise<LoaderApi> {\n let resolvedRoot = await resolve<string>(runtimeUrlOrManifest, { fetchCallback: options?.fetchCallback, });\n let runtimeUrl: string | undefined = undefined;\n if (typeof resolvedRoot === 'string') {\n runtimeUrl = resolvedRoot;\n } else if (typeof resolvedRoot === 'object' && 'runtimeUrl' in resolvedRoot) {\n const manifest = resolvedRoot as Manifest;\n runtimeUrl = await resolve<string>(manifest.runtimeUrl, { fetchCallback: options?.fetchCallback });\n }\n\n if (runtimeUrl === undefined) {\n throw new Error(\n 'Could not determine runtime URL. It must be resolvable to a string or to a manifest with a runtimeUrl property.'\n );\n }\n\n log('Loading runtime:', runtimeUrl);\n // if (typeof manifest === 'string') {\n // manifest = { $ref: manifest };\n // }\n // manifest = await resolve<Manifest>(manifest, { fetchCallback: options?.fetchCallback });\n // const runtime = await resolve<string>(manifest.runtime, {\n // fetchCallback: options?.fetchCallback,\n // });\n\n // log('Resolved runtime URL:', runtime);\n if (typeof runtimeUrl !== 'string') {\n throw new Error('Runtime URL must be a string');\n }\n\n const api = await importHttpRuntime(runtimeUrl);\n api.meta = { runtimeUrl };\n return api; //{ ...api, runtime } as LoaderApi;\n}\n\n// allow calling api functions directly from here\nconst api: LoaderApi = new Proxy(\n {},\n {\n get: (_, prop: string) => {\n return async (...args: any[]) => {\n const param0 = args[0];\n if (param0 == null || typeof param0 !== 'object') {\n throw new Error(`First argument must be a manifest object, got: ${typeof param0}`);\n }\n // const manifest = await resolve<Manifest>(param0);\n // const runtimeUrl = await resolve<string>(manifest.runtimeUrl);\n // if (typeof runtimeUrl !== 'string') {\n // throw new Error('Resolved runtime URL must be a string');\n // }\n\n const runtimeApi = await loadApi(param0);\n const fn = runtimeApi[prop];\n if (typeof fn !== 'function') {\n throw new Error(`API has no function named '${prop}'`);\n }\n return fn.apply(runtimeApi, args as any);\n };\n },\n }\n);\n\nexport async function load(manifest: Manifest | Ref, ...args: unknown[]) {\n return api.load!(manifest, ...args);\n}\n\n// export { resolve } from './resolve';\n\nexport default api;\n"],"names":["hasRequiredMs","m","h","d","w","ms","val","options","type","parse","fmtLong","fmtShort","str","match","y","msAbs","plural","name","isPlural","hasRequiredCommon","setup","env","createDebug","coerce","disable","enable","enabled","requireMs","key","selectColor","namespace","i","hash","prevTime","enableOverride","namespacesCache","debug","args","curr","self","index","format","formatter","enabledCache","v","delimiter","newDebug","namespaces","split","ns","matchesTemplate","search","template","searchIndex","templateIndex","starIndex","matchIndex","skip","destroy","module","exports","formatArgs","save","load","localstorage","warned","useColors","c","lastC","r","formatters","error","fn","fetch","n","importHttpRuntime","runtime","nodeImportHttpRuntime","log$1","resolve","maxHops","_a","seen","cur","input","hop","ref","log","_b","json","loadJson","_c","isHttpUrl","signal","imported","url","res","ct","text","tryImportJson","mod","e1","e2","__efpLoaderBuildInfo","loadApi","runtimeUrlOrManifest","resolvedRoot","runtimeUrl","api","api2","_","prop","param0","runtimeApi","manifest"],"mappings":";;;;;;;AAIA,EAAAA,IAAY;AACZ,MAAI,IAAI,KACJC,IAAI,IAAI,IACRC,IAAID,IAAI,IACRE,IAAID,IAAI,IACRE,IAAID,IAAI;AAiBZ,EAAAE,IAAE,SAAUC,GAAOC,GAAM;AACvB,IAAAA,IAAQA,KAAa,CAAA;AACrB,QAAIC,IAAI,OAAKF;AACf,QAAIE,MAAO,YAAUF,EAAA,SAAA;AAClB,aAAMG,EAAQH,CAAA;AACb,QAAOE,MAAQ,YAAe,SAAOF,CAAA;AACzC,aAAAC,EAAA,OAAAG,EAAAJ,CAAA,IAAAK,EAAAL,CAAA;AAEA,UAAI,IAAA;AAAA,MACJ,0DACG,KAAA,UAAAA,CAAA;AAAA,IACF;AAAA;AAWD,WAAQG,EAAOG,GAAI;QACjBA,IAAI,OAAIA,CAAM,GACZ,EAAAA,EAAA,SAAA;UAGAC,IAAA,mIAAA;AAAA,QACDD;AAAA,MACD;UACEC,G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MAChChB,EAAA,eAAO,EAAA,SAAAgB,EAAA,CAAA,GAAA,SAAAA,EAAA,CAAA,EAAA,CAAA,IAEPhB,EAAA,aAAA;AAWE,eAAIiB,EAAeC,GAAsBlG,GAAA;AACzC,MAAImG,IAAiC,MAAA3B,EAAA0B,GAAA,EAAA,eAAAlG,KAAA,gBAAAA,EAAA,cAAA,CAAA,GACjCoG;AAQF,MAPA,OAAAD,KAAa,WACfC,IAAWD,IACH,OAAAA,KAAW,YAAA,gBAAAA,MAEnBC,IAAA,MAAA5B,EADe2B,EACf,YAAA,EAAA,eAAAnG,KAAA,gBAAAA,EAAA,cAAA,CAAA,IAGEoG,MAAU;AAAA,UACR,IAAA;AAAA,MACF;AAAA,IACF;AAaE,MADFpB,EAAI,qBAAsB,GACxB,OAAMoB;AACR,UAAA,IAAA,MAAA,8BAAA;AAGAC,QAAIC,IAAO,QAAaF,CAAA;AACxB,SAAAE,SAAOD,EAAAA,YAAAA,EAAAA,GACTC;AAGA;AAA2B,MACxBD,IAAA,IAAA;AAAA,EACD,CAAA;AAAA,EAAA;AAAA,IAEI,KAAA,CAAAE,GAAOC,gBACU1E,MAAM;AACrB,gBAAcA;AACZ,UAAA2E,KAAU,QAAM,OAAAA,KAAA;AAClB,cAAA,IAAA,MAAA,kDAAA,OAAAA,CAAA,EAAA;AAQA,YAAMC,IAAK,QAAeD,CAAA,GACtBxC,IAAOyC;AACT,UAAA,OAAMzC,KAAU;AAClB,cAAA,IAAA,MAAA,8BAAAuC,CAAA,GAAA;AAEF,aAAAvC,EAAA,MAAAyC,GAAA5E,CAAA;AAAA,IACF;AAAA,EAEJ;AAEA;AACE,eAAW0B,EAAMmD,MAAa7E,GAAI;AACpC,SAAAuE,EAAA,KAAAM,GAAA,GAAA7E,CAAA;;","x_google_ignoreList":[0,1,2]}
@@ -1,10 +1,14 @@
1
- import { LoaderApi, Manifest, Ref } from './types';
1
+ import type { LoaderApi, Manifest, Ref } from './types';
2
2
  declare global {
3
3
  const __efpLoaderBuildInfo: [version: string, builtAt: string] | undefined;
4
4
  }
5
- export declare function loadApi(manifest: Manifest | Ref | string, options?: {
5
+ export declare function loadApi(
6
+ /**
7
+ * "url" or { $ref: "url" }, or { runtimeUrl: "url" | { $ref: "url" } }
8
+ */
9
+ runtimeUrlOrManifest: string | Ref | Manifest, options?: {
6
10
  fetchCallback?: (ref: string) => void;
7
11
  }): Promise<LoaderApi>;
8
12
  declare const api: LoaderApi;
9
- export declare function load(manifest: Manifest | Ref | string, ...args: unknown[]): Promise<unknown>;
13
+ export declare function load(manifest: Manifest | Ref, ...args: unknown[]): Promise<unknown>;
10
14
  export default api;
package/dist/esm/index.js CHANGED
@@ -8,29 +8,53 @@ if (typeof __efpLoaderBuildInfo !== 'undefined') {
8
8
  else {
9
9
  log('Initialized');
10
10
  }
11
- export async function loadApi(manifest, options) {
12
- log('Loading manifest:', manifest);
13
- if (typeof manifest === 'string') {
14
- manifest = { $ref: manifest };
11
+ export async function loadApi(
12
+ /**
13
+ * "url" or { $ref: "url" }, or { runtimeUrl: "url" | { $ref: "url" } }
14
+ */
15
+ runtimeUrlOrManifest, options) {
16
+ let resolvedRoot = await resolve(runtimeUrlOrManifest, { fetchCallback: options?.fetchCallback, });
17
+ let runtimeUrl = undefined;
18
+ if (typeof resolvedRoot === 'string') {
19
+ runtimeUrl = resolvedRoot;
15
20
  }
16
- manifest = await resolve(manifest, { fetchCallback: options?.fetchCallback });
17
- const runtime = await resolve(manifest.runtime, {
18
- fetchCallback: options?.fetchCallback,
19
- });
20
- log('Resolved runtime URL:', runtime);
21
- if (typeof runtime !== 'string') {
22
- throw new Error('Resolved runtime is not a string ');
21
+ else if (typeof resolvedRoot === 'object' && 'runtimeUrl' in resolvedRoot) {
22
+ const manifest = resolvedRoot;
23
+ runtimeUrl = await resolve(manifest.runtimeUrl, { fetchCallback: options?.fetchCallback });
23
24
  }
24
- const api = await importHttpRuntime(runtime);
25
- api.meta = { runtime };
25
+ if (runtimeUrl === undefined) {
26
+ throw new Error('Could not determine runtime URL. It must be resolvable to a string or to a manifest with a runtimeUrl property.');
27
+ }
28
+ log('Loading runtime:', runtimeUrl);
29
+ // if (typeof manifest === 'string') {
30
+ // manifest = { $ref: manifest };
31
+ // }
32
+ // manifest = await resolve<Manifest>(manifest, { fetchCallback: options?.fetchCallback });
33
+ // const runtime = await resolve<string>(manifest.runtime, {
34
+ // fetchCallback: options?.fetchCallback,
35
+ // });
36
+ // log('Resolved runtime URL:', runtime);
37
+ if (typeof runtimeUrl !== 'string') {
38
+ throw new Error('Runtime URL must be a string');
39
+ }
40
+ const api = await importHttpRuntime(runtimeUrl);
41
+ api.meta = { runtimeUrl };
26
42
  return api; //{ ...api, runtime } as LoaderApi;
27
43
  }
28
44
  // allow calling api functions directly from here
29
45
  const api = new Proxy({}, {
30
46
  get: (_, prop) => {
31
47
  return async (...args) => {
32
- const manifest = args[0];
33
- const runtimeApi = await loadApi(manifest);
48
+ const param0 = args[0];
49
+ if (param0 == null || typeof param0 !== 'object') {
50
+ throw new Error(`First argument must be a manifest object, got: ${typeof param0}`);
51
+ }
52
+ // const manifest = await resolve<Manifest>(param0);
53
+ // const runtimeUrl = await resolve<string>(manifest.runtimeUrl);
54
+ // if (typeof runtimeUrl !== 'string') {
55
+ // throw new Error('Resolved runtime URL must be a string');
56
+ // }
57
+ const runtimeApi = await loadApi(param0);
34
58
  const fn = runtimeApi[prop];
35
59
  if (typeof fn !== 'function') {
36
60
  throw new Error(`API has no function named '${prop}'`);
@@ -42,4 +66,5 @@ const api = new Proxy({}, {
42
66
  export async function load(manifest, ...args) {
43
67
  return api.load(manifest, ...args);
44
68
  }
69
+ // export { resolve } from './resolve';
45
70
  export default api;
@@ -2,7 +2,7 @@ export type Ref = {
2
2
  $ref: string;
3
3
  };
4
4
  export type Manifest = {
5
- runtime: Ref | string;
5
+ runtimeUrl: Ref | string;
6
6
  };
7
7
  export type LoaderFn = (manifest: Manifest | Ref | string, ...args: unknown[]) => Promise<unknown>;
8
8
  export type LoaderApi = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expofp/loader",
3
- "version": "1.0.93",
3
+ "version": "1.0.94",
4
4
  "description": "ExpoFP JavaScript loader library",
5
5
  "license": "MIT",
6
6
  "homepage": "https://expofp.com",