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