@valbuild/react 0.57.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/ValProvider-09e313e2.worker.esm.js +87 -0
  2. package/dist/ValProvider-461fa48b.cjs.js +7 -0
  3. package/dist/ValProvider-461fa48b.cjs.prod.js +115 -0
  4. package/dist/ValProvider-a3b1e699.esm.js +92 -0
  5. package/dist/ValProvider-b34afe68.browser.esm.js +92 -0
  6. package/dist/ValProvider-d17e4d13.cjs.dev.js +121 -0
  7. package/dist/{ValUI-891df000.cjs.dev.js → ValUI-1922d8db.cjs.dev.js} +3 -2
  8. package/dist/ValUI-23e2422b.cjs.js +7 -0
  9. package/dist/{ValUI-323cc3ff.cjs.prod.js → ValUI-23e2422b.cjs.prod.js} +3 -2
  10. package/dist/{ValUI-b82ca977.browser.esm.js → ValUI-7d39a3f6.browser.esm.js} +3 -2
  11. package/dist/{ValUI-29f95099.worker.esm.js → ValUI-84a9cc93.worker.esm.js} +3 -2
  12. package/dist/{ValUI-04c66635.esm.js → ValUI-8775ef5c.esm.js} +3 -2
  13. package/dist/declarations/src/internal/ValProvider.d.ts +1 -1
  14. package/dist/declarations/src/internal/ValRichText.d.ts +67 -14
  15. package/dist/{slicedToArray-a2a426c7.cjs.prod.js → slicedToArray-11a666de.cjs.dev.js} +3 -17
  16. package/dist/{slicedToArray-d4c4a4ed.worker.esm.js → slicedToArray-1dc7d2d6.esm.js} +3 -16
  17. package/dist/{slicedToArray-331bebbb.esm.js → slicedToArray-7b69258f.browser.esm.js} +3 -16
  18. package/dist/{slicedToArray-a9d0d9cd.cjs.dev.js → slicedToArray-c405fbf0.cjs.prod.js} +3 -17
  19. package/dist/{slicedToArray-85f6bb43.browser.esm.js → slicedToArray-e7da2c5e.worker.esm.js} +3 -16
  20. package/dist/toConsumableArray-0a75a603.worker.esm.js +19 -0
  21. package/dist/toConsumableArray-0ccd58b7.esm.js +19 -0
  22. package/dist/toConsumableArray-5a71fbb3.browser.esm.js +19 -0
  23. package/dist/toConsumableArray-b2d28ffa.cjs.dev.js +21 -0
  24. package/dist/toConsumableArray-b5e3b83f.cjs.prod.js +21 -0
  25. package/dist/unsupportedIterableToArray-42309462.cjs.prod.js +19 -0
  26. package/dist/unsupportedIterableToArray-50359a05.worker.esm.js +16 -0
  27. package/dist/unsupportedIterableToArray-7c30dadf.esm.js +16 -0
  28. package/dist/unsupportedIterableToArray-ac28611a.cjs.dev.js +19 -0
  29. package/dist/unsupportedIterableToArray-cce3cb41.browser.esm.js +16 -0
  30. package/internal/dist/valbuild-react-internal.browser.esm.js +95 -131
  31. package/internal/dist/valbuild-react-internal.cjs.dev.js +95 -131
  32. package/internal/dist/valbuild-react-internal.cjs.prod.js +95 -131
  33. package/internal/dist/valbuild-react-internal.esm.js +95 -131
  34. package/internal/dist/valbuild-react-internal.worker.esm.js +95 -131
  35. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -1
  36. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +2 -1
  37. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +2 -1
  38. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -1
  39. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -1
  40. package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +2 -1
  41. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +2 -1
  42. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +2 -1
  43. package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +2 -1
  44. package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +2 -1
  45. package/package.json +4 -4
  46. package/stega/dist/valbuild-react-stega.browser.esm.js +54 -7
  47. package/stega/dist/valbuild-react-stega.cjs.dev.js +55 -8
  48. package/stega/dist/valbuild-react-stega.cjs.prod.js +55 -8
  49. package/stega/dist/valbuild-react-stega.esm.js +54 -7
  50. package/stega/dist/valbuild-react-stega.worker.esm.js +54 -7
  51. package/dist/ValProvider-1009cb51.cjs.dev.js +0 -717
  52. package/dist/ValProvider-6a12fd8e.browser.esm.js +0 -688
  53. package/dist/ValProvider-8ec03a73.esm.js +0 -688
  54. package/dist/ValProvider-c7d7067b.cjs.js +0 -7
  55. package/dist/ValProvider-c7d7067b.cjs.prod.js +0 -711
  56. package/dist/ValProvider-ecf57703.worker.esm.js +0 -683
  57. package/dist/ValUI-323cc3ff.cjs.js +0 -7
  58. package/dist/declarations/src/internal/ValStore.d.ts +0 -16
  59. package/dist/defineProperty-6ed7deb7.browser.esm.js +0 -32
  60. package/dist/defineProperty-82fbeafc.worker.esm.js +0 -32
  61. package/dist/defineProperty-9bf3d0c0.esm.js +0 -32
  62. package/dist/defineProperty-c84f9aba.cjs.dev.js +0 -35
  63. package/dist/defineProperty-f8fe5660.cjs.prod.js +0 -35
@@ -1,711 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var slicedToArray = require('./slicedToArray-a2a426c7.cjs.prod.js');
7
- var React = require('react');
8
- var defineProperty = require('./defineProperty-f8fe5660.cjs.prod.js');
9
- var fp = require('@valbuild/core/fp');
10
- var core = require('@valbuild/core');
11
- var ReactJSXRuntime = require('react/jsx-runtime');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
-
15
- function _interopNamespace(e) {
16
- if (e && e.__esModule) return e;
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
25
- });
26
- }
27
- });
28
- }
29
- n["default"] = e;
30
- return Object.freeze(n);
31
- }
32
-
33
- var React__default = /*#__PURE__*/_interopDefault(React);
34
-
35
- function _createForOfIteratorHelper(o, allowArrayLike) {
36
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
37
- if (!it) {
38
- if (Array.isArray(o) || (it = slicedToArray._unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
39
- if (it) o = it;
40
- var i = 0;
41
- var F = function () {};
42
- return {
43
- s: F,
44
- n: function () {
45
- if (i >= o.length) return {
46
- done: true
47
- };
48
- return {
49
- done: false,
50
- value: o[i++]
51
- };
52
- },
53
- e: function (e) {
54
- throw e;
55
- },
56
- f: F
57
- };
58
- }
59
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
60
- }
61
- var normalCompletion = true,
62
- didErr = false,
63
- err;
64
- return {
65
- s: function () {
66
- it = it.call(o);
67
- },
68
- n: function () {
69
- var step = it.next();
70
- normalCompletion = step.done;
71
- return step;
72
- },
73
- e: function (e) {
74
- didErr = true;
75
- err = e;
76
- },
77
- f: function () {
78
- try {
79
- if (!normalCompletion && it.return != null) it.return();
80
- } finally {
81
- if (didErr) throw err;
82
- }
83
- }
84
- };
85
- }
86
-
87
- function _regeneratorRuntime() {
88
- _regeneratorRuntime = function () {
89
- return e;
90
- };
91
- var t,
92
- e = {},
93
- r = Object.prototype,
94
- n = r.hasOwnProperty,
95
- o = Object.defineProperty || function (t, e, r) {
96
- t[e] = r.value;
97
- },
98
- i = "function" == typeof Symbol ? Symbol : {},
99
- a = i.iterator || "@@iterator",
100
- c = i.asyncIterator || "@@asyncIterator",
101
- u = i.toStringTag || "@@toStringTag";
102
- function define(t, e, r) {
103
- return Object.defineProperty(t, e, {
104
- value: r,
105
- enumerable: !0,
106
- configurable: !0,
107
- writable: !0
108
- }), t[e];
109
- }
110
- try {
111
- define({}, "");
112
- } catch (t) {
113
- define = function (t, e, r) {
114
- return t[e] = r;
115
- };
116
- }
117
- function wrap(t, e, r, n) {
118
- var i = e && e.prototype instanceof Generator ? e : Generator,
119
- a = Object.create(i.prototype),
120
- c = new Context(n || []);
121
- return o(a, "_invoke", {
122
- value: makeInvokeMethod(t, r, c)
123
- }), a;
124
- }
125
- function tryCatch(t, e, r) {
126
- try {
127
- return {
128
- type: "normal",
129
- arg: t.call(e, r)
130
- };
131
- } catch (t) {
132
- return {
133
- type: "throw",
134
- arg: t
135
- };
136
- }
137
- }
138
- e.wrap = wrap;
139
- var h = "suspendedStart",
140
- l = "suspendedYield",
141
- f = "executing",
142
- s = "completed",
143
- y = {};
144
- function Generator() {}
145
- function GeneratorFunction() {}
146
- function GeneratorFunctionPrototype() {}
147
- var p = {};
148
- define(p, a, function () {
149
- return this;
150
- });
151
- var d = Object.getPrototypeOf,
152
- v = d && d(d(values([])));
153
- v && v !== r && n.call(v, a) && (p = v);
154
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
155
- function defineIteratorMethods(t) {
156
- ["next", "throw", "return"].forEach(function (e) {
157
- define(t, e, function (t) {
158
- return this._invoke(e, t);
159
- });
160
- });
161
- }
162
- function AsyncIterator(t, e) {
163
- function invoke(r, o, i, a) {
164
- var c = tryCatch(t[r], t, o);
165
- if ("throw" !== c.type) {
166
- var u = c.arg,
167
- h = u.value;
168
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
169
- invoke("next", t, i, a);
170
- }, function (t) {
171
- invoke("throw", t, i, a);
172
- }) : e.resolve(h).then(function (t) {
173
- u.value = t, i(u);
174
- }, function (t) {
175
- return invoke("throw", t, i, a);
176
- });
177
- }
178
- a(c.arg);
179
- }
180
- var r;
181
- o(this, "_invoke", {
182
- value: function (t, n) {
183
- function callInvokeWithMethodAndArg() {
184
- return new e(function (e, r) {
185
- invoke(t, n, e, r);
186
- });
187
- }
188
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
189
- }
190
- });
191
- }
192
- function makeInvokeMethod(e, r, n) {
193
- var o = h;
194
- return function (i, a) {
195
- if (o === f) throw new Error("Generator is already running");
196
- if (o === s) {
197
- if ("throw" === i) throw a;
198
- return {
199
- value: t,
200
- done: !0
201
- };
202
- }
203
- for (n.method = i, n.arg = a;;) {
204
- var c = n.delegate;
205
- if (c) {
206
- var u = maybeInvokeDelegate(c, n);
207
- if (u) {
208
- if (u === y) continue;
209
- return u;
210
- }
211
- }
212
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
213
- if (o === h) throw o = s, n.arg;
214
- n.dispatchException(n.arg);
215
- } else "return" === n.method && n.abrupt("return", n.arg);
216
- o = f;
217
- var p = tryCatch(e, r, n);
218
- if ("normal" === p.type) {
219
- if (o = n.done ? s : l, p.arg === y) continue;
220
- return {
221
- value: p.arg,
222
- done: n.done
223
- };
224
- }
225
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
226
- }
227
- };
228
- }
229
- function maybeInvokeDelegate(e, r) {
230
- var n = r.method,
231
- o = e.iterator[n];
232
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
233
- var i = tryCatch(o, e.iterator, r.arg);
234
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
235
- var a = i.arg;
236
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
237
- }
238
- function pushTryEntry(t) {
239
- var e = {
240
- tryLoc: t[0]
241
- };
242
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
243
- }
244
- function resetTryEntry(t) {
245
- var e = t.completion || {};
246
- e.type = "normal", delete e.arg, t.completion = e;
247
- }
248
- function Context(t) {
249
- this.tryEntries = [{
250
- tryLoc: "root"
251
- }], t.forEach(pushTryEntry, this), this.reset(!0);
252
- }
253
- function values(e) {
254
- if (e || "" === e) {
255
- var r = e[a];
256
- if (r) return r.call(e);
257
- if ("function" == typeof e.next) return e;
258
- if (!isNaN(e.length)) {
259
- var o = -1,
260
- i = function next() {
261
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
262
- return next.value = t, next.done = !0, next;
263
- };
264
- return i.next = i;
265
- }
266
- }
267
- throw new TypeError(typeof e + " is not iterable");
268
- }
269
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
270
- value: GeneratorFunctionPrototype,
271
- configurable: !0
272
- }), o(GeneratorFunctionPrototype, "constructor", {
273
- value: GeneratorFunction,
274
- configurable: !0
275
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
276
- var e = "function" == typeof t && t.constructor;
277
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
278
- }, e.mark = function (t) {
279
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
280
- }, e.awrap = function (t) {
281
- return {
282
- __await: t
283
- };
284
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
285
- return this;
286
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
287
- void 0 === i && (i = Promise);
288
- var a = new AsyncIterator(wrap(t, r, n, o), i);
289
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
290
- return t.done ? t.value : a.next();
291
- });
292
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
293
- return this;
294
- }), define(g, "toString", function () {
295
- return "[object Generator]";
296
- }), e.keys = function (t) {
297
- var e = Object(t),
298
- r = [];
299
- for (var n in e) r.push(n);
300
- return r.reverse(), function next() {
301
- for (; r.length;) {
302
- var t = r.pop();
303
- if (t in e) return next.value = t, next.done = !1, next;
304
- }
305
- return next.done = !0, next;
306
- };
307
- }, e.values = values, Context.prototype = {
308
- constructor: Context,
309
- reset: function (e) {
310
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
311
- },
312
- stop: function () {
313
- this.done = !0;
314
- var t = this.tryEntries[0].completion;
315
- if ("throw" === t.type) throw t.arg;
316
- return this.rval;
317
- },
318
- dispatchException: function (e) {
319
- if (this.done) throw e;
320
- var r = this;
321
- function handle(n, o) {
322
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
323
- }
324
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
325
- var i = this.tryEntries[o],
326
- a = i.completion;
327
- if ("root" === i.tryLoc) return handle("end");
328
- if (i.tryLoc <= this.prev) {
329
- var c = n.call(i, "catchLoc"),
330
- u = n.call(i, "finallyLoc");
331
- if (c && u) {
332
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
333
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
334
- } else if (c) {
335
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
336
- } else {
337
- if (!u) throw new Error("try statement without catch or finally");
338
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
339
- }
340
- }
341
- }
342
- },
343
- abrupt: function (t, e) {
344
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
345
- var o = this.tryEntries[r];
346
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
347
- var i = o;
348
- break;
349
- }
350
- }
351
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
352
- var a = i ? i.completion : {};
353
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
354
- },
355
- complete: function (t, e) {
356
- if ("throw" === t.type) throw t.arg;
357
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
358
- },
359
- finish: function (t) {
360
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
361
- var r = this.tryEntries[e];
362
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
363
- }
364
- },
365
- catch: function (t) {
366
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
367
- var r = this.tryEntries[e];
368
- if (r.tryLoc === t) {
369
- var n = r.completion;
370
- if ("throw" === n.type) {
371
- var o = n.arg;
372
- resetTryEntry(r);
373
- }
374
- return o;
375
- }
376
- }
377
- throw new Error("illegal catch attempt");
378
- },
379
- delegateYield: function (e, r, n) {
380
- return this.delegate = {
381
- iterator: values(e),
382
- resultName: r,
383
- nextLoc: n
384
- }, "next" === this.method && (this.arg = t), y;
385
- }
386
- }, e;
387
- }
388
-
389
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
390
- try {
391
- var info = gen[key](arg);
392
- var value = info.value;
393
- } catch (error) {
394
- reject(error);
395
- return;
396
- }
397
- if (info.done) {
398
- resolve(value);
399
- } else {
400
- Promise.resolve(value).then(_next, _throw);
401
- }
402
- }
403
- function _asyncToGenerator(fn) {
404
- return function () {
405
- var self = this,
406
- args = arguments;
407
- return new Promise(function (resolve, reject) {
408
- var gen = fn.apply(self, args);
409
- function _next(value) {
410
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
411
- }
412
- function _throw(err) {
413
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
414
- }
415
- _next(undefined);
416
- });
417
- };
418
- }
419
-
420
- function _classCallCheck(instance, Constructor) {
421
- if (!(instance instanceof Constructor)) {
422
- throw new TypeError("Cannot call a class as a function");
423
- }
424
- }
425
-
426
- function _defineProperties(target, props) {
427
- for (var i = 0; i < props.length; i++) {
428
- var descriptor = props[i];
429
- descriptor.enumerable = descriptor.enumerable || false;
430
- descriptor.configurable = true;
431
- if ("value" in descriptor) descriptor.writable = true;
432
- Object.defineProperty(target, defineProperty.toPropertyKey(descriptor.key), descriptor);
433
- }
434
- }
435
- function _createClass(Constructor, protoProps, staticProps) {
436
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
437
- if (staticProps) _defineProperties(Constructor, staticProps);
438
- Object.defineProperty(Constructor, "prototype", {
439
- writable: false
440
- });
441
- return Constructor;
442
- }
443
-
444
- var ValStore = /*#__PURE__*/function () {
445
- // uncertain whether this is the optimal way of returning
446
-
447
- function ValStore(api) {
448
- var _this = this;
449
- _classCallCheck(this, ValStore);
450
- defineProperty._defineProperty(this, "subscribe", function (moduleIds) {
451
- return function (listener) {
452
- var subscriberId = createSubscriberId(moduleIds);
453
- if (!_this.listeners[subscriberId]) {
454
- _this.listeners[subscriberId] = [];
455
- _this.subscribers.set(subscriberId, {});
456
- }
457
- _this.listeners[subscriberId].push(listener);
458
- return function () {
459
- _this.listeners[subscriberId].splice(_this.listeners[subscriberId].indexOf(listener), 1);
460
- };
461
- };
462
- });
463
- defineProperty._defineProperty(this, "getSnapshot", function (moduleIds) {
464
- return function () {
465
- return _this.get(moduleIds);
466
- };
467
- });
468
- defineProperty._defineProperty(this, "getServerSnapshot", function (moduleIds) {
469
- return function () {
470
- return _this.get(moduleIds);
471
- };
472
- });
473
- defineProperty._defineProperty(this, "get", function (moduleIds) {
474
- var subscriberId = createSubscriberId(moduleIds);
475
- return _this.subscribers.get(subscriberId);
476
- });
477
- this.api = api;
478
- this.subscribers = new Map();
479
- this.listeners = {};
480
- }
481
- _createClass(ValStore, [{
482
- key: "update",
483
- value: function () {
484
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(moduleIds) {
485
- var _this2 = this;
486
- return _regeneratorRuntime().wrap(function _callee$(_context) {
487
- while (1) switch (_context.prev = _context.next) {
488
- case 0:
489
- _context.next = 2;
490
- return Promise.all(moduleIds.map(function (moduleId) {
491
- return _this2.updateTree(moduleId);
492
- }));
493
- case 2:
494
- case "end":
495
- return _context.stop();
496
- }
497
- }, _callee);
498
- }));
499
- function update(_x) {
500
- return _update.apply(this, arguments);
501
- }
502
- return update;
503
- }()
504
- }, {
505
- key: "updateAll",
506
- value: function () {
507
- var _updateAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
508
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
509
- while (1) switch (_context2.prev = _context2.next) {
510
- case 0:
511
- _context2.next = 2;
512
- return this.updateTree();
513
- case 2:
514
- case "end":
515
- return _context2.stop();
516
- }
517
- }, _callee2, this);
518
- }));
519
- function updateAll() {
520
- return _updateAll.apply(this, arguments);
521
- }
522
- return updateAll;
523
- }()
524
- }, {
525
- key: "updateTree",
526
- value: function () {
527
- var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(treePath) {
528
- var data, updatedSubscriberIds, subscriberIds, _loop, _i, _arr, _i2, _Array$from, _Array$from$_i, updatedSubscriberId, moduleIds, subscriberModules;
529
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
530
- while (1) switch (_context4.prev = _context4.next) {
531
- case 0:
532
- _context4.next = 2;
533
- return this.api.getTree({
534
- treePath: treePath,
535
- patch: true,
536
- includeSource: true
537
- });
538
- case 2:
539
- data = _context4.sent;
540
- if (!fp.result.isOk(data)) {
541
- _context4.next = 16;
542
- break;
543
- }
544
- updatedSubscriberIds = new Map();
545
- subscriberIds = Array.from(this.subscribers.keys()); // Figure out which modules have been updated and map to updated subscribed id
546
- _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
547
- var moduleId, source, updatedSubscriberId;
548
- return _regeneratorRuntime().wrap(function _loop$(_context3) {
549
- while (1) switch (_context3.prev = _context3.next) {
550
- case 0:
551
- moduleId = _arr[_i];
552
- source = data.value.modules[moduleId].source;
553
- if (typeof source !== "undefined") {
554
- updatedSubscriberId = subscriberIds.find(function (subscriberId) {
555
- return subscriberId.includes(moduleId);
556
- } // NOTE: dependent on
557
- );
558
- if (updatedSubscriberId) {
559
- updatedSubscriberIds.set(updatedSubscriberId, (updatedSubscriberIds.get(updatedSubscriberId) || []).concat(moduleId));
560
- }
561
- }
562
- case 3:
563
- case "end":
564
- return _context3.stop();
565
- }
566
- }, _loop);
567
- });
568
- _i = 0, _arr = Object.keys(data.value.modules);
569
- case 8:
570
- if (!(_i < _arr.length)) {
571
- _context4.next = 13;
572
- break;
573
- }
574
- return _context4.delegateYield(_loop(), "t0", 10);
575
- case 10:
576
- _i++;
577
- _context4.next = 8;
578
- break;
579
- case 13:
580
- // For all updated subscribers: set new module data and emit change
581
- for (_i2 = 0, _Array$from = Array.from(updatedSubscriberIds.entries()); _i2 < _Array$from.length; _i2++) {
582
- _Array$from$_i = slicedToArray._slicedToArray(_Array$from[_i2], 2), updatedSubscriberId = _Array$from$_i[0], moduleIds = _Array$from$_i[1];
583
- subscriberModules = Object.fromEntries(moduleIds.flatMap(function (moduleId) {
584
- var source = data.value.modules[moduleId].source;
585
- if (!source) {
586
- return [];
587
- }
588
- return [[moduleId, source]];
589
- }));
590
- this.subscribers.set(updatedSubscriberId, subscriberModules);
591
- this.emitChange(updatedSubscriberId);
592
- }
593
- _context4.next = 17;
594
- break;
595
- case 16:
596
- console.error("Val: failed to update modules", data.error);
597
- case 17:
598
- case "end":
599
- return _context4.stop();
600
- }
601
- }, _callee3, this);
602
- }));
603
- function updateTree(_x2) {
604
- return _updateTree.apply(this, arguments);
605
- }
606
- return updateTree;
607
- }()
608
- }, {
609
- key: "emitChange",
610
- value: function emitChange(subscriberId) {
611
- var _iterator = _createForOfIteratorHelper(this.listeners[subscriberId]),
612
- _step;
613
- try {
614
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
615
- var listener = _step.value;
616
- listener();
617
- }
618
- } catch (err) {
619
- _iterator.e(err);
620
- } finally {
621
- _iterator.f();
622
- }
623
- }
624
- }]);
625
- return ValStore;
626
- }();
627
- function createSubscriberId(moduleIds) {
628
- return moduleIds.slice().sort().join("&");
629
- }
630
-
631
- var useValStore = function useValStore() {
632
- if (!ValContext) {
633
- return undefined;
634
- }
635
- return React.useContext(ValContext).valStore;
636
- };
637
- var useValApi = function useValApi() {
638
- if (!ValContext) {
639
- return undefined;
640
- }
641
- return React.useContext(ValContext).valApi;
642
- };
643
- var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React__default["default"].createContext({
644
- valStore: undefined,
645
- valApi: undefined
646
- }) : undefined;
647
- var ValUI = /*#__PURE__*/React.lazy(function () {
648
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValUI-323cc3ff.cjs.prod.js')); });
649
- });
650
- function ValProvider(_ref) {
651
- var children = _ref.children,
652
- onSubmit = _ref.onSubmit;
653
- var host = "/api/val";
654
- var api = React.useMemo(function () {
655
- return new core.ValApi(host);
656
- }, [host]);
657
- var store = React.useMemo(function () {
658
- return new ValStore(api);
659
- }, [api]);
660
- var _useState = React.useState(false),
661
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
662
- isClient = _useState2[0],
663
- setIsClient = _useState2[1];
664
- var _useState3 = React.useState(),
665
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
666
- enabled = _useState4[0],
667
- setEnabled = _useState4[1];
668
- React.useEffect(function () {
669
- setIsClient(true);
670
- try {
671
- var _document$cookie, _document$cookie2;
672
- var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
673
- if (valEnabled) {
674
- setEnabled(true);
675
- }
676
- var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
677
- if (valDisabled) {
678
- setEnabled(false);
679
- }
680
- // If we are in development and Val is not enabled or disabled, enable Val
681
- if ( "production" === "development" && !valEnabled && !valDisabled) ;
682
- } catch (e) {
683
- console.warn("Could not read Val enabled state", e);
684
- }
685
- }, []);
686
- if (isClient && !enabled) {
687
- if (!api) {
688
- console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
689
- }
690
- }
691
- if (!isClient || !enabled || !store || !api || !ValContext) {
692
- return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
693
- children: children
694
- });
695
- }
696
- return /*#__PURE__*/ReactJSXRuntime.jsxs(ValContext.Provider, {
697
- value: {
698
- valApi: api,
699
- valStore: store
700
- },
701
- children: [children, /*#__PURE__*/ReactJSXRuntime.jsx(ValUI, {
702
- host: host,
703
- onSubmit: onSubmit
704
- })]
705
- });
706
- }
707
-
708
- exports.ValContext = ValContext;
709
- exports.ValProvider = ValProvider;
710
- exports.useValApi = useValApi;
711
- exports.useValStore = useValStore;