@valbuild/react 0.29.0 → 0.31.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 (44) hide show
  1. package/dist/{ValProviderInternal-fed8d4f2.browser.esm.js → ValProviderInternal-61d82ec0.esm.js} +11 -7
  2. package/dist/ValProviderInternal-62bd0c14.browser.esm.js +615 -0
  3. package/dist/ValProviderInternal-757e00dc.cjs.js +7 -0
  4. package/dist/{ValProviderInternal-11c45b39.cjs.prod.js → ValProviderInternal-757e00dc.cjs.prod.js} +12 -6
  5. package/dist/{ValProviderInternal-f1bbfabb.cjs.dev.js → ValProviderInternal-d20f3c34.cjs.dev.js} +12 -6
  6. package/dist/{ValProviderInternal-955b2ced.esm.js → ValProviderInternal-f64d019a.worker.esm.js} +11 -7
  7. package/dist/ValUI-596c6129.cjs.js +7 -0
  8. package/dist/{ValUI-c636bbdd.cjs.prod.js → ValUI-596c6129.cjs.prod.js} +4 -7
  9. package/dist/{ValUI-a5ff7b4f.cjs.dev.js → ValUI-82ba086a.cjs.dev.js} +4 -7
  10. package/dist/{ValUI-8e4092a8.esm.js → ValUI-c969250a.esm.js} +4 -7
  11. package/dist/{ValUI-3aefbfd7.browser.esm.js → ValUI-d049362e.browser.esm.js} +4 -7
  12. package/dist/{ValUI-14d84602.worker.esm.js → ValUI-eb3ed9e3.worker.esm.js} +4 -5
  13. package/dist/declarations/src/ValProviderInternal.d.ts +2 -2
  14. package/dist/{defineProperty-034d0378.browser.esm.js → defineProperty-12b5bd29.esm.js} +1 -1
  15. package/dist/{defineProperty-b209a901.esm.js → defineProperty-a4bf59bc.worker.esm.js} +1 -1
  16. package/dist/defineProperty-f319cb47.browser.esm.js +32 -0
  17. package/dist/{slicedToArray-5418adeb.esm.js → slicedToArray-331bebbb.esm.js} +16 -16
  18. package/dist/{slicedToArray-964e1994.browser.esm.js → slicedToArray-85f6bb43.browser.esm.js} +16 -16
  19. package/dist/{slicedToArray-5b9980b8.worker.esm.js → slicedToArray-d4c4a4ed.worker.esm.js} +16 -16
  20. package/dist/valbuild-react.browser.esm.js +2 -7
  21. package/dist/valbuild-react.cjs.dev.js +28 -9
  22. package/dist/valbuild-react.cjs.prod.js +28 -9
  23. package/dist/valbuild-react.esm.js +2 -7
  24. package/dist/valbuild-react.worker.esm.js +1 -3
  25. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +1 -1
  26. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +1 -1
  27. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +1 -1
  28. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +1 -1
  29. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +1 -1
  30. package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +1 -1
  31. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +1 -1
  32. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +1 -1
  33. package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +1 -1
  34. package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +1 -1
  35. package/package.json +3 -3
  36. package/stega/dist/valbuild-react-stega.browser.esm.js +2 -2
  37. package/stega/dist/valbuild-react-stega.cjs.dev.js +1 -1
  38. package/stega/dist/valbuild-react-stega.cjs.prod.js +1 -1
  39. package/stega/dist/valbuild-react-stega.esm.js +2 -2
  40. package/stega/dist/valbuild-react-stega.worker.esm.js +2 -32
  41. package/dist/ValProviderInternal-4491e75a.worker.esm.js +0 -17
  42. package/dist/ValUI-c636bbdd.cjs.js +0 -7
  43. package/dist/{slicedToArray-1fc98f25.cjs.prod.js → slicedToArray-a2a426c7.cjs.prod.js} +15 -15
  44. package/dist/{slicedToArray-fb0bef7d.cjs.dev.js → slicedToArray-a9d0d9cd.cjs.dev.js} +15 -15
@@ -1,9 +1,10 @@
1
+ 'use client';
1
2
  import React, { useContext, useMemo } from 'react';
2
- import { _ as _unsupportedIterableToArray, a as _slicedToArray } from './slicedToArray-964e1994.browser.esm.js';
3
- import { _ as _toPropertyKey, a as _defineProperty } from './defineProperty-034d0378.browser.esm.js';
3
+ import { a as _unsupportedIterableToArray, _ as _slicedToArray } from './slicedToArray-331bebbb.esm.js';
4
+ import { a as _toPropertyKey, _ as _defineProperty } from './defineProperty-12b5bd29.esm.js';
4
5
  import { result } from '@valbuild/core/fp';
5
6
  import { ValApi } from '@valbuild/core';
6
- import ValUI from './ValUI-3aefbfd7.browser.esm.js';
7
+ import ValUI from './ValUI-c969250a.esm.js';
7
8
  import { jsxs, jsx } from 'react/jsx-runtime';
8
9
 
9
10
  function _createForOfIteratorHelper(o, allowArrayLike) {
@@ -580,12 +581,15 @@ function createSubscriberId(moduleIds) {
580
581
  return moduleIds.slice().sort().join("&");
581
582
  }
582
583
 
583
- function useValStore() {
584
+ var useValStore = function useValStore() {
584
585
  return useContext(ValContext).valStore;
585
- }
586
- function useValApi() {
586
+ };
587
+
588
+ // NOTE: ValProviderInternal might not be defined if the user is not using ValProvider
589
+ // Addendum: This happens when this module will not be imported if the window === undefined. Not quite sure why this happens though. Some investigations might be in order.
590
+ var useValApi = function useValApi() {
587
591
  return useContext(ValContext).valApi;
588
- }
592
+ };
589
593
  var ValContext = /*#__PURE__*/React.createContext({
590
594
  valStore: undefined,
591
595
  valApi: undefined
@@ -0,0 +1,615 @@
1
+ 'use client';
2
+ import React, { useContext, useMemo } from 'react';
3
+ import { a as _unsupportedIterableToArray, _ as _slicedToArray } from './slicedToArray-85f6bb43.browser.esm.js';
4
+ import { a as _toPropertyKey, _ as _defineProperty } from './defineProperty-f319cb47.browser.esm.js';
5
+ import { result } from '@valbuild/core/fp';
6
+ import { ValApi } from '@valbuild/core';
7
+ import ValUI from './ValUI-d049362e.browser.esm.js';
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
+
10
+ function _createForOfIteratorHelper(o, allowArrayLike) {
11
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
12
+ if (!it) {
13
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
14
+ if (it) o = it;
15
+ var i = 0;
16
+ var F = function () {};
17
+ return {
18
+ s: F,
19
+ n: function () {
20
+ if (i >= o.length) return {
21
+ done: true
22
+ };
23
+ return {
24
+ done: false,
25
+ value: o[i++]
26
+ };
27
+ },
28
+ e: function (e) {
29
+ throw e;
30
+ },
31
+ f: F
32
+ };
33
+ }
34
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ var normalCompletion = true,
37
+ didErr = false,
38
+ err;
39
+ return {
40
+ s: function () {
41
+ it = it.call(o);
42
+ },
43
+ n: function () {
44
+ var step = it.next();
45
+ normalCompletion = step.done;
46
+ return step;
47
+ },
48
+ e: function (e) {
49
+ didErr = true;
50
+ err = e;
51
+ },
52
+ f: function () {
53
+ try {
54
+ if (!normalCompletion && it.return != null) it.return();
55
+ } finally {
56
+ if (didErr) throw err;
57
+ }
58
+ }
59
+ };
60
+ }
61
+
62
+ function _regeneratorRuntime() {
63
+ _regeneratorRuntime = function () {
64
+ return e;
65
+ };
66
+ var t,
67
+ e = {},
68
+ r = Object.prototype,
69
+ n = r.hasOwnProperty,
70
+ o = Object.defineProperty || function (t, e, r) {
71
+ t[e] = r.value;
72
+ },
73
+ i = "function" == typeof Symbol ? Symbol : {},
74
+ a = i.iterator || "@@iterator",
75
+ c = i.asyncIterator || "@@asyncIterator",
76
+ u = i.toStringTag || "@@toStringTag";
77
+ function define(t, e, r) {
78
+ return Object.defineProperty(t, e, {
79
+ value: r,
80
+ enumerable: !0,
81
+ configurable: !0,
82
+ writable: !0
83
+ }), t[e];
84
+ }
85
+ try {
86
+ define({}, "");
87
+ } catch (t) {
88
+ define = function (t, e, r) {
89
+ return t[e] = r;
90
+ };
91
+ }
92
+ function wrap(t, e, r, n) {
93
+ var i = e && e.prototype instanceof Generator ? e : Generator,
94
+ a = Object.create(i.prototype),
95
+ c = new Context(n || []);
96
+ return o(a, "_invoke", {
97
+ value: makeInvokeMethod(t, r, c)
98
+ }), a;
99
+ }
100
+ function tryCatch(t, e, r) {
101
+ try {
102
+ return {
103
+ type: "normal",
104
+ arg: t.call(e, r)
105
+ };
106
+ } catch (t) {
107
+ return {
108
+ type: "throw",
109
+ arg: t
110
+ };
111
+ }
112
+ }
113
+ e.wrap = wrap;
114
+ var h = "suspendedStart",
115
+ l = "suspendedYield",
116
+ f = "executing",
117
+ s = "completed",
118
+ y = {};
119
+ function Generator() {}
120
+ function GeneratorFunction() {}
121
+ function GeneratorFunctionPrototype() {}
122
+ var p = {};
123
+ define(p, a, function () {
124
+ return this;
125
+ });
126
+ var d = Object.getPrototypeOf,
127
+ v = d && d(d(values([])));
128
+ v && v !== r && n.call(v, a) && (p = v);
129
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
130
+ function defineIteratorMethods(t) {
131
+ ["next", "throw", "return"].forEach(function (e) {
132
+ define(t, e, function (t) {
133
+ return this._invoke(e, t);
134
+ });
135
+ });
136
+ }
137
+ function AsyncIterator(t, e) {
138
+ function invoke(r, o, i, a) {
139
+ var c = tryCatch(t[r], t, o);
140
+ if ("throw" !== c.type) {
141
+ var u = c.arg,
142
+ h = u.value;
143
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
144
+ invoke("next", t, i, a);
145
+ }, function (t) {
146
+ invoke("throw", t, i, a);
147
+ }) : e.resolve(h).then(function (t) {
148
+ u.value = t, i(u);
149
+ }, function (t) {
150
+ return invoke("throw", t, i, a);
151
+ });
152
+ }
153
+ a(c.arg);
154
+ }
155
+ var r;
156
+ o(this, "_invoke", {
157
+ value: function (t, n) {
158
+ function callInvokeWithMethodAndArg() {
159
+ return new e(function (e, r) {
160
+ invoke(t, n, e, r);
161
+ });
162
+ }
163
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
164
+ }
165
+ });
166
+ }
167
+ function makeInvokeMethod(e, r, n) {
168
+ var o = h;
169
+ return function (i, a) {
170
+ if (o === f) throw new Error("Generator is already running");
171
+ if (o === s) {
172
+ if ("throw" === i) throw a;
173
+ return {
174
+ value: t,
175
+ done: !0
176
+ };
177
+ }
178
+ for (n.method = i, n.arg = a;;) {
179
+ var c = n.delegate;
180
+ if (c) {
181
+ var u = maybeInvokeDelegate(c, n);
182
+ if (u) {
183
+ if (u === y) continue;
184
+ return u;
185
+ }
186
+ }
187
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
188
+ if (o === h) throw o = s, n.arg;
189
+ n.dispatchException(n.arg);
190
+ } else "return" === n.method && n.abrupt("return", n.arg);
191
+ o = f;
192
+ var p = tryCatch(e, r, n);
193
+ if ("normal" === p.type) {
194
+ if (o = n.done ? s : l, p.arg === y) continue;
195
+ return {
196
+ value: p.arg,
197
+ done: n.done
198
+ };
199
+ }
200
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
201
+ }
202
+ };
203
+ }
204
+ function maybeInvokeDelegate(e, r) {
205
+ var n = r.method,
206
+ o = e.iterator[n];
207
+ 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;
208
+ var i = tryCatch(o, e.iterator, r.arg);
209
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
210
+ var a = i.arg;
211
+ 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);
212
+ }
213
+ function pushTryEntry(t) {
214
+ var e = {
215
+ tryLoc: t[0]
216
+ };
217
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
218
+ }
219
+ function resetTryEntry(t) {
220
+ var e = t.completion || {};
221
+ e.type = "normal", delete e.arg, t.completion = e;
222
+ }
223
+ function Context(t) {
224
+ this.tryEntries = [{
225
+ tryLoc: "root"
226
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
227
+ }
228
+ function values(e) {
229
+ if (e || "" === e) {
230
+ var r = e[a];
231
+ if (r) return r.call(e);
232
+ if ("function" == typeof e.next) return e;
233
+ if (!isNaN(e.length)) {
234
+ var o = -1,
235
+ i = function next() {
236
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
237
+ return next.value = t, next.done = !0, next;
238
+ };
239
+ return i.next = i;
240
+ }
241
+ }
242
+ throw new TypeError(typeof e + " is not iterable");
243
+ }
244
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
245
+ value: GeneratorFunctionPrototype,
246
+ configurable: !0
247
+ }), o(GeneratorFunctionPrototype, "constructor", {
248
+ value: GeneratorFunction,
249
+ configurable: !0
250
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
251
+ var e = "function" == typeof t && t.constructor;
252
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
253
+ }, e.mark = function (t) {
254
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
255
+ }, e.awrap = function (t) {
256
+ return {
257
+ __await: t
258
+ };
259
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
260
+ return this;
261
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
262
+ void 0 === i && (i = Promise);
263
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
264
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
265
+ return t.done ? t.value : a.next();
266
+ });
267
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
268
+ return this;
269
+ }), define(g, "toString", function () {
270
+ return "[object Generator]";
271
+ }), e.keys = function (t) {
272
+ var e = Object(t),
273
+ r = [];
274
+ for (var n in e) r.push(n);
275
+ return r.reverse(), function next() {
276
+ for (; r.length;) {
277
+ var t = r.pop();
278
+ if (t in e) return next.value = t, next.done = !1, next;
279
+ }
280
+ return next.done = !0, next;
281
+ };
282
+ }, e.values = values, Context.prototype = {
283
+ constructor: Context,
284
+ reset: function (e) {
285
+ 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);
286
+ },
287
+ stop: function () {
288
+ this.done = !0;
289
+ var t = this.tryEntries[0].completion;
290
+ if ("throw" === t.type) throw t.arg;
291
+ return this.rval;
292
+ },
293
+ dispatchException: function (e) {
294
+ if (this.done) throw e;
295
+ var r = this;
296
+ function handle(n, o) {
297
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
298
+ }
299
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
300
+ var i = this.tryEntries[o],
301
+ a = i.completion;
302
+ if ("root" === i.tryLoc) return handle("end");
303
+ if (i.tryLoc <= this.prev) {
304
+ var c = n.call(i, "catchLoc"),
305
+ u = n.call(i, "finallyLoc");
306
+ if (c && u) {
307
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
308
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
309
+ } else if (c) {
310
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
311
+ } else {
312
+ if (!u) throw new Error("try statement without catch or finally");
313
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
314
+ }
315
+ }
316
+ }
317
+ },
318
+ abrupt: function (t, e) {
319
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
320
+ var o = this.tryEntries[r];
321
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
322
+ var i = o;
323
+ break;
324
+ }
325
+ }
326
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
327
+ var a = i ? i.completion : {};
328
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
329
+ },
330
+ complete: function (t, e) {
331
+ if ("throw" === t.type) throw t.arg;
332
+ 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;
333
+ },
334
+ finish: function (t) {
335
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
336
+ var r = this.tryEntries[e];
337
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
338
+ }
339
+ },
340
+ catch: function (t) {
341
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
342
+ var r = this.tryEntries[e];
343
+ if (r.tryLoc === t) {
344
+ var n = r.completion;
345
+ if ("throw" === n.type) {
346
+ var o = n.arg;
347
+ resetTryEntry(r);
348
+ }
349
+ return o;
350
+ }
351
+ }
352
+ throw new Error("illegal catch attempt");
353
+ },
354
+ delegateYield: function (e, r, n) {
355
+ return this.delegate = {
356
+ iterator: values(e),
357
+ resultName: r,
358
+ nextLoc: n
359
+ }, "next" === this.method && (this.arg = t), y;
360
+ }
361
+ }, e;
362
+ }
363
+
364
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
365
+ try {
366
+ var info = gen[key](arg);
367
+ var value = info.value;
368
+ } catch (error) {
369
+ reject(error);
370
+ return;
371
+ }
372
+ if (info.done) {
373
+ resolve(value);
374
+ } else {
375
+ Promise.resolve(value).then(_next, _throw);
376
+ }
377
+ }
378
+ function _asyncToGenerator(fn) {
379
+ return function () {
380
+ var self = this,
381
+ args = arguments;
382
+ return new Promise(function (resolve, reject) {
383
+ var gen = fn.apply(self, args);
384
+ function _next(value) {
385
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
386
+ }
387
+ function _throw(err) {
388
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
389
+ }
390
+ _next(undefined);
391
+ });
392
+ };
393
+ }
394
+
395
+ function _classCallCheck(instance, Constructor) {
396
+ if (!(instance instanceof Constructor)) {
397
+ throw new TypeError("Cannot call a class as a function");
398
+ }
399
+ }
400
+
401
+ function _defineProperties(target, props) {
402
+ for (var i = 0; i < props.length; i++) {
403
+ var descriptor = props[i];
404
+ descriptor.enumerable = descriptor.enumerable || false;
405
+ descriptor.configurable = true;
406
+ if ("value" in descriptor) descriptor.writable = true;
407
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
408
+ }
409
+ }
410
+ function _createClass(Constructor, protoProps, staticProps) {
411
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
412
+ if (staticProps) _defineProperties(Constructor, staticProps);
413
+ Object.defineProperty(Constructor, "prototype", {
414
+ writable: false
415
+ });
416
+ return Constructor;
417
+ }
418
+
419
+ var ValStore = /*#__PURE__*/function () {
420
+ // uncertain whether this is the optimal way of returning
421
+
422
+ function ValStore(api) {
423
+ var _this = this;
424
+ _classCallCheck(this, ValStore);
425
+ _defineProperty(this, "subscribe", function (moduleIds) {
426
+ return function (listener) {
427
+ var subscriberId = createSubscriberId(moduleIds);
428
+ if (!_this.listeners[subscriberId]) {
429
+ _this.listeners[subscriberId] = [];
430
+ _this.subscribers.set(subscriberId, {});
431
+ }
432
+ _this.listeners[subscriberId].push(listener);
433
+ return function () {
434
+ _this.listeners[subscriberId].splice(_this.listeners[subscriberId].indexOf(listener), 1);
435
+ };
436
+ };
437
+ });
438
+ _defineProperty(this, "getSnapshot", function (moduleIds) {
439
+ return function () {
440
+ return _this.get(moduleIds);
441
+ };
442
+ });
443
+ _defineProperty(this, "getServerSnapshot", function (moduleIds) {
444
+ return function () {
445
+ return _this.get(moduleIds);
446
+ };
447
+ });
448
+ _defineProperty(this, "get", function (moduleIds) {
449
+ var subscriberId = createSubscriberId(moduleIds);
450
+ return _this.subscribers.get(subscriberId);
451
+ });
452
+ this.api = api;
453
+ this.subscribers = new Map();
454
+ this.listeners = {};
455
+ }
456
+
457
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
458
+ _createClass(ValStore, [{
459
+ key: "update",
460
+ value: function () {
461
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(moduleIds) {
462
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
463
+ while (1) switch (_context.prev = _context.next) {
464
+ case 0:
465
+ return _context.abrupt("return", this.updateAll());
466
+ case 1:
467
+ case "end":
468
+ return _context.stop();
469
+ }
470
+ }, _callee, this);
471
+ }));
472
+ function update(_x) {
473
+ return _update.apply(this, arguments);
474
+ }
475
+ return update;
476
+ }()
477
+ }, {
478
+ key: "updateAll",
479
+ value: function () {
480
+ var _updateAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
481
+ var data, updatedSubscriberIds, subscriberIds, _loop, _i, _arr, _i2, _Array$from, _Array$from$_i, updatedSubscriberId, moduleIds, subscriberModules;
482
+ return _regeneratorRuntime().wrap(function _callee2$(_context3) {
483
+ while (1) switch (_context3.prev = _context3.next) {
484
+ case 0:
485
+ _context3.next = 2;
486
+ return this.api.getModules({
487
+ patch: true,
488
+ includeSource: true
489
+ });
490
+ case 2:
491
+ data = _context3.sent;
492
+ if (!result.isOk(data)) {
493
+ _context3.next = 16;
494
+ break;
495
+ }
496
+ updatedSubscriberIds = new Map();
497
+ subscriberIds = Array.from(this.subscribers.keys()); // Figure out which modules have been updated and map to updated subscribed id
498
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
499
+ var moduleId, source, updatedSubscriberId;
500
+ return _regeneratorRuntime().wrap(function _loop$(_context2) {
501
+ while (1) switch (_context2.prev = _context2.next) {
502
+ case 0:
503
+ moduleId = _arr[_i];
504
+ source = data.value.modules[moduleId].source;
505
+ if (typeof source !== "undefined") {
506
+ updatedSubscriberId = subscriberIds.find(function (subscriberId) {
507
+ return subscriberId.includes(moduleId);
508
+ } // NOTE: dependent on
509
+ );
510
+
511
+ if (updatedSubscriberId) {
512
+ updatedSubscriberIds.set(updatedSubscriberId, (updatedSubscriberIds.get(updatedSubscriberId) || []).concat(moduleId));
513
+ }
514
+ }
515
+ case 3:
516
+ case "end":
517
+ return _context2.stop();
518
+ }
519
+ }, _loop);
520
+ });
521
+ _i = 0, _arr = Object.keys(data.value.modules);
522
+ case 8:
523
+ if (!(_i < _arr.length)) {
524
+ _context3.next = 13;
525
+ break;
526
+ }
527
+ return _context3.delegateYield(_loop(), "t0", 10);
528
+ case 10:
529
+ _i++;
530
+ _context3.next = 8;
531
+ break;
532
+ case 13:
533
+ // For all updated subscribers: set new module data and emit change
534
+ for (_i2 = 0, _Array$from = Array.from(updatedSubscriberIds.entries()); _i2 < _Array$from.length; _i2++) {
535
+ _Array$from$_i = _slicedToArray(_Array$from[_i2], 2), updatedSubscriberId = _Array$from$_i[0], moduleIds = _Array$from$_i[1];
536
+ subscriberModules = Object.fromEntries(moduleIds.flatMap(function (moduleId) {
537
+ var source = data.value.modules[moduleId].source;
538
+ if (!source) {
539
+ return [];
540
+ }
541
+ return [[moduleId, source]];
542
+ }));
543
+ this.subscribers.set(updatedSubscriberId, subscriberModules);
544
+ this.emitChange(updatedSubscriberId);
545
+ }
546
+ _context3.next = 17;
547
+ break;
548
+ case 16:
549
+ console.error("Val: failed to update modules", data.error.message);
550
+ case 17:
551
+ case "end":
552
+ return _context3.stop();
553
+ }
554
+ }, _callee2, this);
555
+ }));
556
+ function updateAll() {
557
+ return _updateAll.apply(this, arguments);
558
+ }
559
+ return updateAll;
560
+ }()
561
+ }, {
562
+ key: "emitChange",
563
+ value: function emitChange(subscriberId) {
564
+ var _iterator = _createForOfIteratorHelper(this.listeners[subscriberId]),
565
+ _step;
566
+ try {
567
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
568
+ var listener = _step.value;
569
+ listener();
570
+ }
571
+ } catch (err) {
572
+ _iterator.e(err);
573
+ } finally {
574
+ _iterator.f();
575
+ }
576
+ }
577
+ }]);
578
+ return ValStore;
579
+ }();
580
+ function createSubscriberId(moduleIds) {
581
+ return moduleIds.slice().sort().join("&");
582
+ }
583
+
584
+ var useValStore = function useValStore() {
585
+ return useContext(ValContext).valStore;
586
+ };
587
+
588
+ // NOTE: ValProviderInternal might not be defined if the user is not using ValProvider
589
+ // Addendum: This happens when this module will not be imported if the window === undefined. Not quite sure why this happens though. Some investigations might be in order.
590
+ var useValApi = function useValApi() {
591
+ return useContext(ValContext).valApi;
592
+ };
593
+ var ValContext = /*#__PURE__*/React.createContext({
594
+ valStore: undefined,
595
+ valApi: undefined
596
+ });
597
+ function ValProviderInternal(_ref) {
598
+ var children = _ref.children;
599
+ var host = "/api/val";
600
+ var valApi = useMemo(function () {
601
+ return new ValApi(host);
602
+ }, [host]);
603
+ var valStore = useMemo(function () {
604
+ return new ValStore(valApi);
605
+ }, [valApi]);
606
+ return /*#__PURE__*/jsxs(ValContext.Provider, {
607
+ value: {
608
+ valApi: valApi,
609
+ valStore: valStore
610
+ },
611
+ children: [children, /*#__PURE__*/jsx(ValUI, {})]
612
+ });
613
+ }
614
+
615
+ export { ValContext, ValProviderInternal as default, useValApi, useValStore };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValProviderInternal-757e00dc.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValProviderInternal-757e00dc.cjs.dev.js");
7
+ }
@@ -1,11 +1,14 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
3
6
  var React = require('react');
4
- var slicedToArray = require('./slicedToArray-1fc98f25.cjs.prod.js');
7
+ var slicedToArray = require('./slicedToArray-a2a426c7.cjs.prod.js');
5
8
  var defineProperty = require('./defineProperty-36ed93cd.cjs.prod.js');
6
9
  var fp = require('@valbuild/core/fp');
7
10
  var core = require('@valbuild/core');
8
- var ValUI = require('./ValUI-c636bbdd.cjs.prod.js');
11
+ var ValUI = require('./ValUI-596c6129.cjs.prod.js');
9
12
  var ReactJSXRuntime = require('react/jsx-runtime');
10
13
 
11
14
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -587,12 +590,15 @@ function createSubscriberId(moduleIds) {
587
590
  return moduleIds.slice().sort().join("&");
588
591
  }
589
592
 
590
- function useValStore() {
593
+ var useValStore = function useValStore() {
591
594
  return React.useContext(ValContext).valStore;
592
- }
593
- function useValApi() {
595
+ };
596
+
597
+ // NOTE: ValProviderInternal might not be defined if the user is not using ValProvider
598
+ // Addendum: This happens when this module will not be imported if the window === undefined. Not quite sure why this happens though. Some investigations might be in order.
599
+ var useValApi = function useValApi() {
594
600
  return React.useContext(ValContext).valApi;
595
- }
601
+ };
596
602
  var ValContext = /*#__PURE__*/React__default["default"].createContext({
597
603
  valStore: undefined,
598
604
  valApi: undefined