@fairfox/polly 0.20.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +11 -0
  2. package/dist/src/background/index.js +22 -12
  3. package/dist/src/background/index.js.map +3 -3
  4. package/dist/src/background/message-router.js +22 -12
  5. package/dist/src/background/message-router.js.map +3 -3
  6. package/dist/src/client/index.js +187 -154
  7. package/dist/src/client/index.js.map +4 -4
  8. package/dist/src/elysia/index.js +19 -9
  9. package/dist/src/elysia/index.js.map +2 -2
  10. package/dist/src/elysia/plugin.d.ts +3 -3
  11. package/dist/src/index.js +22 -12
  12. package/dist/src/index.js.map +3 -3
  13. package/dist/src/shared/adapters/index.js +22 -12
  14. package/dist/src/shared/adapters/index.js.map +3 -3
  15. package/dist/src/shared/lib/context-helpers.js +22 -12
  16. package/dist/src/shared/lib/context-helpers.js.map +3 -3
  17. package/dist/src/shared/lib/errors.js +19 -9
  18. package/dist/src/shared/lib/errors.js.map +2 -2
  19. package/dist/src/shared/lib/message-bus.js +22 -12
  20. package/dist/src/shared/lib/message-bus.js.map +3 -3
  21. package/dist/src/shared/lib/resource.js +22 -12
  22. package/dist/src/shared/lib/resource.js.map +3 -3
  23. package/dist/src/shared/lib/state.js +22 -12
  24. package/dist/src/shared/lib/state.js.map +3 -3
  25. package/dist/src/shared/lib/test-helpers.js +19 -9
  26. package/dist/src/shared/lib/test-helpers.js.map +2 -2
  27. package/dist/src/shared/state/app-state.js +22 -12
  28. package/dist/src/shared/state/app-state.js.map +3 -3
  29. package/dist/src/shared/types/messages.js +19 -9
  30. package/dist/src/shared/types/messages.js.map +2 -2
  31. package/dist/tools/init/src/cli.js +6 -2
  32. package/dist/tools/init/src/cli.js.map +2 -2
  33. package/dist/tools/test/src/adapters/index.d.ts +2 -2
  34. package/dist/tools/test/src/adapters/index.js +19 -9
  35. package/dist/tools/test/src/adapters/index.js.map +3 -3
  36. package/dist/tools/test/src/index.js +19 -9
  37. package/dist/tools/test/src/index.js.map +3 -3
  38. package/dist/tools/test/src/test-utils.js +19 -9
  39. package/dist/tools/test/src/test-utils.js.map +2 -2
  40. package/dist/tools/verify/src/cli.js +10 -6
  41. package/dist/tools/verify/src/cli.js.map +4 -4
  42. package/dist/tools/verify/src/config.js +19 -9
  43. package/dist/tools/verify/src/config.js.map +2 -2
  44. package/dist/tools/visualize/src/cli.js +6 -2
  45. package/dist/tools/visualize/src/cli.js.map +2 -2
  46. package/package.json +8 -10
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
6
8
  var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
8
10
  if (entry)
9
11
  return entry;
10
12
  entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
16
21
  __moduleCache.set(from, entry);
17
22
  return entry;
18
23
  };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
19
29
  var __export = (target, all) => {
20
30
  for (var name in all)
21
31
  __defProp(target, name, {
22
32
  get: all[name],
23
33
  enumerable: true,
24
34
  configurable: true,
25
- set: (newValue) => all[name] = () => newValue
35
+ set: __exportSetter.bind(all, name)
26
36
  });
27
37
  };
28
38
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -42,57 +52,69 @@ var i = Symbol.for("preact-signals");
42
52
  function t() {
43
53
  if (!(s > 1)) {
44
54
  var i2, t2 = false;
55
+ (function() {
56
+ var i3 = d;
57
+ d = undefined;
58
+ while (i3 !== undefined) {
59
+ if (i3.S.v === i3.v)
60
+ i3.S.i = i3.i;
61
+ i3 = i3.o;
62
+ }
63
+ })();
45
64
  while (h !== undefined) {
46
- var r = h;
65
+ var n = h;
47
66
  h = undefined;
48
- f++;
49
- while (r !== undefined) {
50
- var o = r.o;
51
- r.o = undefined;
52
- r.f &= -3;
53
- if (!(8 & r.f) && c(r))
67
+ v++;
68
+ while (n !== undefined) {
69
+ var r = n.u;
70
+ n.u = undefined;
71
+ n.f &= -3;
72
+ if (!(8 & n.f) && w(n))
54
73
  try {
55
- r.c();
56
- } catch (r2) {
74
+ n.c();
75
+ } catch (n2) {
57
76
  if (!t2) {
58
- i2 = r2;
77
+ i2 = n2;
59
78
  t2 = true;
60
79
  }
61
80
  }
62
- r = o;
81
+ n = r;
63
82
  }
64
83
  }
65
- f = 0;
84
+ v = 0;
66
85
  s--;
67
86
  if (t2)
68
87
  throw i2;
69
88
  } else
70
89
  s--;
71
90
  }
72
- var o = undefined;
73
- function n(i2) {
74
- var t2 = o;
75
- o = undefined;
91
+ var r = undefined;
92
+ function o(i2) {
93
+ var t2 = r;
94
+ r = undefined;
76
95
  try {
77
96
  return i2();
78
97
  } finally {
79
- o = t2;
98
+ r = t2;
80
99
  }
81
100
  }
101
+ var f;
82
102
  var h = undefined;
83
103
  var s = 0;
84
- var f = 0;
85
104
  var v = 0;
86
- function e(i2) {
87
- if (o !== undefined) {
105
+ var e = 0;
106
+ var d = undefined;
107
+ var c = 0;
108
+ function a(i2) {
109
+ if (r !== undefined) {
88
110
  var t2 = i2.n;
89
- if (t2 === undefined || t2.t !== o) {
90
- t2 = { i: 0, S: i2, p: o.s, n: undefined, t: o, e: undefined, x: undefined, r: t2 };
91
- if (o.s !== undefined)
92
- o.s.n = t2;
93
- o.s = t2;
111
+ if (t2 === undefined || t2.t !== r) {
112
+ t2 = { i: 0, S: i2, p: r.s, n: undefined, t: r, e: undefined, x: undefined, r: t2 };
113
+ if (r.s !== undefined)
114
+ r.s.n = t2;
115
+ r.s = t2;
94
116
  i2.n = t2;
95
- if (32 & o.f)
117
+ if (32 & r.f)
96
118
  i2.S(t2);
97
119
  return t2;
98
120
  } else if (t2.i === -1) {
@@ -101,129 +123,138 @@ function e(i2) {
101
123
  t2.n.p = t2.p;
102
124
  if (t2.p !== undefined)
103
125
  t2.p.n = t2.n;
104
- t2.p = o.s;
126
+ t2.p = r.s;
105
127
  t2.n = undefined;
106
- o.s.n = t2;
107
- o.s = t2;
128
+ r.s.n = t2;
129
+ r.s = t2;
108
130
  }
109
131
  return t2;
110
132
  }
111
133
  }
112
134
  }
113
- function u(i2, t2) {
135
+ function l(i2, t2) {
114
136
  this.v = i2;
115
137
  this.i = 0;
116
138
  this.n = undefined;
117
139
  this.t = undefined;
140
+ this.l = 0;
118
141
  this.W = t2 == null ? undefined : t2.watched;
119
142
  this.Z = t2 == null ? undefined : t2.unwatched;
120
143
  this.name = t2 == null ? undefined : t2.name;
121
144
  }
122
- u.prototype.brand = i;
123
- u.prototype.h = function() {
145
+ l.prototype.brand = i;
146
+ l.prototype.h = function() {
124
147
  return true;
125
148
  };
126
- u.prototype.S = function(i2) {
127
- var t2 = this, r = this.t;
128
- if (r !== i2 && i2.e === undefined) {
129
- i2.x = r;
149
+ l.prototype.S = function(i2) {
150
+ var t2 = this, n = this.t;
151
+ if (n !== i2 && i2.e === undefined) {
152
+ i2.x = n;
130
153
  this.t = i2;
131
- if (r !== undefined)
132
- r.e = i2;
154
+ if (n !== undefined)
155
+ n.e = i2;
133
156
  else
134
- n(function() {
157
+ o(function() {
135
158
  var i3;
136
159
  (i3 = t2.W) == null || i3.call(t2);
137
160
  });
138
161
  }
139
162
  };
140
- u.prototype.U = function(i2) {
163
+ l.prototype.U = function(i2) {
141
164
  var t2 = this;
142
165
  if (this.t !== undefined) {
143
- var { e: r, x: o2 } = i2;
144
- if (r !== undefined) {
145
- r.x = o2;
166
+ var { e: n, x: r2 } = i2;
167
+ if (n !== undefined) {
168
+ n.x = r2;
146
169
  i2.e = undefined;
147
170
  }
148
- if (o2 !== undefined) {
149
- o2.e = r;
171
+ if (r2 !== undefined) {
172
+ r2.e = n;
150
173
  i2.x = undefined;
151
174
  }
152
175
  if (i2 === this.t) {
153
- this.t = o2;
154
- if (o2 === undefined)
155
- n(function() {
176
+ this.t = r2;
177
+ if (r2 === undefined)
178
+ o(function() {
156
179
  var i3;
157
180
  (i3 = t2.Z) == null || i3.call(t2);
158
181
  });
159
182
  }
160
183
  }
161
184
  };
162
- u.prototype.subscribe = function(i2) {
185
+ l.prototype.subscribe = function(i2) {
163
186
  var t2 = this;
164
- return E(function() {
165
- var r = t2.value, n2 = o;
166
- o = undefined;
187
+ return C(function() {
188
+ var n = t2.value, o2 = r;
189
+ r = undefined;
167
190
  try {
168
- i2(r);
191
+ i2(n);
169
192
  } finally {
170
- o = n2;
193
+ r = o2;
171
194
  }
172
195
  }, { name: "sub" });
173
196
  };
174
- u.prototype.valueOf = function() {
197
+ l.prototype.valueOf = function() {
175
198
  return this.value;
176
199
  };
177
- u.prototype.toString = function() {
200
+ l.prototype.toString = function() {
178
201
  return this.value + "";
179
202
  };
180
- u.prototype.toJSON = function() {
203
+ l.prototype.toJSON = function() {
181
204
  return this.value;
182
205
  };
183
- u.prototype.peek = function() {
184
- var i2 = o;
185
- o = undefined;
206
+ l.prototype.peek = function() {
207
+ var i2 = r;
208
+ r = undefined;
186
209
  try {
187
210
  return this.value;
188
211
  } finally {
189
- o = i2;
212
+ r = i2;
190
213
  }
191
214
  };
192
- Object.defineProperty(u.prototype, "value", { get: function() {
193
- var i2 = e(this);
215
+ Object.defineProperty(l.prototype, "value", { get: function() {
216
+ var i2 = a(this);
194
217
  if (i2 !== undefined)
195
218
  i2.i = this.i;
196
219
  return this.v;
197
220
  }, set: function(i2) {
198
221
  if (i2 !== this.v) {
199
- if (f > 100)
222
+ if (v > 100)
200
223
  throw new Error("Cycle detected");
224
+ (function(i3) {
225
+ if (s !== 0 && v === 0) {
226
+ if (i3.l !== e) {
227
+ i3.l = e;
228
+ d = { S: i3, v: i3.v, i: i3.i, o: d };
229
+ }
230
+ }
231
+ })(this);
201
232
  this.v = i2;
202
233
  this.i++;
203
- v++;
234
+ c++;
204
235
  s++;
205
236
  try {
206
- for (var r = this.t;r !== undefined; r = r.x)
207
- r.t.N();
237
+ for (var n = this.t;n !== undefined; n = n.x)
238
+ n.t.N();
208
239
  } finally {
209
240
  t();
210
241
  }
211
242
  }
212
243
  } });
213
- function d(i2, t2) {
214
- return new u(i2, t2);
244
+ function y(i2, t2) {
245
+ return new l(i2, t2);
215
246
  }
216
- function c(i2) {
247
+ function w(i2) {
217
248
  for (var t2 = i2.s;t2 !== undefined; t2 = t2.n)
218
249
  if (t2.S.i !== t2.i || !t2.S.h() || t2.S.i !== t2.i)
219
250
  return true;
220
251
  return false;
221
252
  }
222
- function a(i2) {
253
+ function _(i2) {
223
254
  for (var t2 = i2.s;t2 !== undefined; t2 = t2.n) {
224
- var r = t2.S.n;
225
- if (r !== undefined)
226
- t2.r = r;
255
+ var n = t2.S.n;
256
+ if (n !== undefined)
257
+ t2.r = n;
227
258
  t2.S.n = t2;
228
259
  t2.i = -1;
229
260
  if (t2.n === undefined) {
@@ -232,55 +263,55 @@ function a(i2) {
232
263
  }
233
264
  }
234
265
  }
235
- function l(i2) {
236
- var t2 = i2.s, r = undefined;
266
+ function b(i2) {
267
+ var t2 = i2.s, n = undefined;
237
268
  while (t2 !== undefined) {
238
- var o2 = t2.p;
269
+ var r2 = t2.p;
239
270
  if (t2.i === -1) {
240
271
  t2.S.U(t2);
241
- if (o2 !== undefined)
242
- o2.n = t2.n;
272
+ if (r2 !== undefined)
273
+ r2.n = t2.n;
243
274
  if (t2.n !== undefined)
244
- t2.n.p = o2;
275
+ t2.n.p = r2;
245
276
  } else
246
- r = t2;
277
+ n = t2;
247
278
  t2.S.n = t2.r;
248
279
  if (t2.r !== undefined)
249
280
  t2.r = undefined;
250
- t2 = o2;
281
+ t2 = r2;
251
282
  }
252
- i2.s = r;
283
+ i2.s = n;
253
284
  }
254
- function y(i2, t2) {
255
- u.call(this, undefined);
285
+ function p(i2, t2) {
286
+ l.call(this, undefined);
256
287
  this.x = i2;
257
288
  this.s = undefined;
258
- this.g = v - 1;
289
+ this.g = c - 1;
259
290
  this.f = 4;
260
291
  this.W = t2 == null ? undefined : t2.watched;
261
292
  this.Z = t2 == null ? undefined : t2.unwatched;
262
293
  this.name = t2 == null ? undefined : t2.name;
263
294
  }
264
- y.prototype = new u;
265
- y.prototype.h = function() {
295
+ p.prototype = new l;
296
+ p.prototype.h = function() {
266
297
  this.f &= -3;
267
298
  if (1 & this.f)
268
299
  return false;
269
300
  if ((36 & this.f) == 32)
270
301
  return true;
271
302
  this.f &= -5;
272
- if (this.g === v)
303
+ if (this.g === c)
273
304
  return true;
274
- this.g = v;
305
+ this.g = c;
275
306
  this.f |= 1;
276
- if (this.i > 0 && !c(this)) {
307
+ if (this.i > 0 && !w(this)) {
277
308
  this.f &= -2;
278
309
  return true;
279
310
  }
280
- var i2 = o;
311
+ var i2 = r;
281
312
  try {
282
- a(this);
283
- o = this;
313
+ _(this);
314
+ r = this;
284
315
  var t2 = this.x();
285
316
  if (16 & this.f || this.v !== t2 || this.i === 0) {
286
317
  this.v = t2;
@@ -292,22 +323,22 @@ y.prototype.h = function() {
292
323
  this.f |= 16;
293
324
  this.i++;
294
325
  }
295
- o = i2;
296
- l(this);
326
+ r = i2;
327
+ b(this);
297
328
  this.f &= -2;
298
329
  return true;
299
330
  };
300
- y.prototype.S = function(i2) {
331
+ p.prototype.S = function(i2) {
301
332
  if (this.t === undefined) {
302
333
  this.f |= 36;
303
334
  for (var t2 = this.s;t2 !== undefined; t2 = t2.n)
304
335
  t2.S.S(t2);
305
336
  }
306
- u.prototype.S.call(this, i2);
337
+ l.prototype.S.call(this, i2);
307
338
  };
308
- y.prototype.U = function(i2) {
339
+ p.prototype.U = function(i2) {
309
340
  if (this.t !== undefined) {
310
- u.prototype.U.call(this, i2);
341
+ l.prototype.U.call(this, i2);
311
342
  if (this.t === undefined) {
312
343
  this.f &= -33;
313
344
  for (var t2 = this.s;t2 !== undefined; t2 = t2.n)
@@ -315,17 +346,17 @@ y.prototype.U = function(i2) {
315
346
  }
316
347
  }
317
348
  };
318
- y.prototype.N = function() {
349
+ p.prototype.N = function() {
319
350
  if (!(2 & this.f)) {
320
351
  this.f |= 6;
321
352
  for (var i2 = this.t;i2 !== undefined; i2 = i2.x)
322
353
  i2.t.N();
323
354
  }
324
355
  };
325
- Object.defineProperty(y.prototype, "value", { get: function() {
356
+ Object.defineProperty(p.prototype, "value", { get: function() {
326
357
  if (1 & this.f)
327
358
  throw new Error("Cycle detected");
328
- var i2 = e(this);
359
+ var i2 = a(this);
329
360
  this.h();
330
361
  if (i2 !== undefined)
331
362
  i2.i = this.i;
@@ -333,52 +364,54 @@ Object.defineProperty(y.prototype, "value", { get: function() {
333
364
  throw this.v;
334
365
  return this.v;
335
366
  } });
336
- function _(i2) {
337
- var r = i2.u;
338
- i2.u = undefined;
339
- if (typeof r == "function") {
367
+ function S(i2) {
368
+ var n = i2.m;
369
+ i2.m = undefined;
370
+ if (typeof n == "function") {
340
371
  s++;
341
- var n2 = o;
342
- o = undefined;
372
+ var o2 = r;
373
+ r = undefined;
343
374
  try {
344
- r();
375
+ n();
345
376
  } catch (t2) {
346
377
  i2.f &= -2;
347
378
  i2.f |= 8;
348
- b(i2);
379
+ m(i2);
349
380
  throw t2;
350
381
  } finally {
351
- o = n2;
382
+ r = o2;
352
383
  t();
353
384
  }
354
385
  }
355
386
  }
356
- function b(i2) {
387
+ function m(i2) {
357
388
  for (var t2 = i2.s;t2 !== undefined; t2 = t2.n)
358
389
  t2.S.U(t2);
359
390
  i2.x = undefined;
360
391
  i2.s = undefined;
361
- _(i2);
392
+ S(i2);
362
393
  }
363
- function g(i2) {
364
- if (o !== this)
394
+ function x(i2) {
395
+ if (r !== this)
365
396
  throw new Error("Out-of-order effect");
366
- l(this);
367
- o = i2;
397
+ b(this);
398
+ r = i2;
368
399
  this.f &= -2;
369
400
  if (8 & this.f)
370
- b(this);
401
+ m(this);
371
402
  t();
372
403
  }
373
- function p(i2, t2) {
404
+ function E(i2, t2) {
374
405
  this.x = i2;
375
- this.u = undefined;
406
+ this.m = undefined;
376
407
  this.s = undefined;
377
- this.o = undefined;
408
+ this.u = undefined;
378
409
  this.f = 32;
379
410
  this.name = t2 == null ? undefined : t2.name;
411
+ if (f)
412
+ f.push(this);
380
413
  }
381
- p.prototype.c = function() {
414
+ E.prototype.c = function() {
382
415
  var i2 = this.S();
383
416
  try {
384
417
  if (8 & this.f)
@@ -387,49 +420,49 @@ p.prototype.c = function() {
387
420
  return;
388
421
  var t2 = this.x();
389
422
  if (typeof t2 == "function")
390
- this.u = t2;
423
+ this.m = t2;
391
424
  } finally {
392
425
  i2();
393
426
  }
394
427
  };
395
- p.prototype.S = function() {
428
+ E.prototype.S = function() {
396
429
  if (1 & this.f)
397
430
  throw new Error("Cycle detected");
398
431
  this.f |= 1;
399
432
  this.f &= -9;
433
+ S(this);
400
434
  _(this);
401
- a(this);
402
435
  s++;
403
- var i2 = o;
404
- o = this;
405
- return g.bind(this, i2);
436
+ var i2 = r;
437
+ r = this;
438
+ return x.bind(this, i2);
406
439
  };
407
- p.prototype.N = function() {
440
+ E.prototype.N = function() {
408
441
  if (!(2 & this.f)) {
409
442
  this.f |= 2;
410
- this.o = h;
443
+ this.u = h;
411
444
  h = this;
412
445
  }
413
446
  };
414
- p.prototype.d = function() {
447
+ E.prototype.d = function() {
415
448
  this.f |= 8;
416
449
  if (!(1 & this.f))
417
- b(this);
450
+ m(this);
418
451
  };
419
- p.prototype.dispose = function() {
452
+ E.prototype.dispose = function() {
420
453
  this.d();
421
454
  };
422
- function E(i2, t2) {
423
- var r = new p(i2, t2);
455
+ function C(i2, t2) {
456
+ var n = new E(i2, t2);
424
457
  try {
425
- r.c();
458
+ n.c();
426
459
  } catch (i3) {
427
- r.d();
460
+ n.d();
428
461
  throw i3;
429
462
  }
430
- var o2 = r.d.bind(r);
431
- o2[Symbol.dispose] = o2;
432
- return o2;
463
+ var r2 = n.d.bind(n);
464
+ r2[Symbol.dispose] = r2;
465
+ return r2;
433
466
  }
434
467
 
435
468
  // src/core/clock.ts
@@ -474,12 +507,12 @@ function createPollyClient(url, options = {}) {
474
507
  const baseClient = treaty(url);
475
508
  const clock = createLamportClock("client");
476
509
  const clientState = {
477
- isOnline: d(typeof navigator !== "undefined" ? navigator.onLine : true),
478
- isSyncing: d(false),
479
- queuedRequests: d([])
510
+ isOnline: y(typeof navigator === "undefined" ? true : navigator.onLine),
511
+ isSyncing: y(false),
512
+ queuedRequests: y([])
480
513
  };
481
514
  let ws = null;
482
- const shouldUseWebSocket = options.websocket !== undefined ? options.websocket : isDev2;
515
+ const shouldUseWebSocket = options.websocket === undefined ? isDev2 : options.websocket;
483
516
  if (shouldUseWebSocket && typeof WebSocket !== "undefined") {
484
517
  const wsPath = options.websocketPath || "/polly/ws";
485
518
  const wsUrl = url.replace(/^http/, "ws") + wsPath;
@@ -569,4 +602,4 @@ export {
569
602
  createPollyClient
570
603
  };
571
604
 
572
- //# debugId=BBBA85418EE0677E64756E2164756E21
605
+ //# debugId=6AC28BB9CB83861664756E2164756E21