@valbuild/react 0.12.0 → 0.13.3
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.
- package/dist/ValProvider-52f2fa13.esm.js +731 -0
- package/dist/ValProvider-7364ec46.cjs.dev.js +746 -0
- package/dist/ValProvider-a45a47b9.worker.esm.js +726 -0
- package/dist/ValProvider-c7a8476b.browser.esm.js +731 -0
- package/dist/ValProvider-e1d5ffbe.cjs.js +7 -0
- package/dist/ValProvider-e1d5ffbe.cjs.prod.js +746 -0
- package/dist/ValUI-0fbdafd4.cjs.prod.js +398 -0
- package/dist/ValUI-371e9bf4.cjs.dev.js +398 -0
- package/dist/ValUI-51404232.browser.esm.js +396 -0
- package/dist/ValUI-9a3eb570.esm.js +396 -0
- package/dist/declarations/src/AuthStatus.d.ts +6 -0
- package/dist/declarations/src/ShadowRoot.d.ts +4 -0
- package/dist/declarations/src/ValProvider.d.ts +1 -1
- package/dist/declarations/src/ValProviderWrapper.d.ts +3 -0
- package/dist/declarations/src/ValUI.d.ts +8 -0
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/{slicedToArray-0ead6329.cjs.dev.js → slicedToArray-0eb0bcdb.cjs.prod.js} +3 -17
- package/dist/{slicedToArray-bf9b195a.worker.esm.js → slicedToArray-1a246338.browser.esm.js} +3 -16
- package/dist/{slicedToArray-236143cd.browser.esm.js → slicedToArray-9e7d1407.worker.esm.js} +3 -16
- package/dist/{slicedToArray-57b117df.cjs.prod.js → slicedToArray-b7cf26e0.cjs.dev.js} +3 -17
- package/dist/{slicedToArray-390fde8c.esm.js → slicedToArray-d846e1d2.esm.js} +3 -16
- package/dist/unsupportedIterableToArray-51bb61c2.esm.js +16 -0
- package/dist/unsupportedIterableToArray-738344ef.worker.esm.js +16 -0
- package/dist/unsupportedIterableToArray-9e97e24a.cjs.dev.js +18 -0
- package/dist/unsupportedIterableToArray-afbea1dd.cjs.prod.js +18 -0
- package/dist/unsupportedIterableToArray-d3087ed5.browser.esm.js +16 -0
- package/dist/valbuild-react.browser.esm.js +9 -1083
- package/dist/valbuild-react.cjs.dev.js +24 -1074
- package/dist/valbuild-react.cjs.prod.js +24 -1074
- package/dist/valbuild-react.esm.js +13 -1079
- package/dist/valbuild-react.worker.esm.js +13 -1079
- package/jest.config.js +5 -0
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +2 -1
- package/package.json +9 -6
- package/src/AuthStatus.tsx +13 -0
- package/src/ShadowRoot.tsx +32 -0
- package/src/ValApi.ts +65 -0
- package/src/ValProvider.tsx +51 -0
- package/src/ValProviderWrapper.tsx +15 -0
- package/src/ValRichText.tsx +141 -0
- package/src/ValStore.ts +62 -0
- package/src/ValUI.tsx +353 -0
- package/src/assets.ts +124 -0
- package/src/hooks/useVal.test.tsx +57 -0
- package/src/hooks/useVal.ts +35 -0
- package/src/index.ts +6 -0
- package/src/jsx-dev-runtime.js +47 -0
- package/src/jsx-namespace.d.ts +46 -0
- package/src/jsx-runtime.d.ts +1 -0
- package/src/jsx-runtime.dev.d.ts +1 -0
- package/src/jsx-runtime.js +52 -0
@@ -0,0 +1,731 @@
|
|
1
|
+
'use client';
|
2
|
+
import React, { useMemo, useContext, lazy } from 'react';
|
3
|
+
import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-51bb61c2.esm.js';
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
5
|
+
|
6
|
+
function _regeneratorRuntime() {
|
7
|
+
_regeneratorRuntime = function () {
|
8
|
+
return exports;
|
9
|
+
};
|
10
|
+
var exports = {},
|
11
|
+
Op = Object.prototype,
|
12
|
+
hasOwn = Op.hasOwnProperty,
|
13
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
14
|
+
obj[key] = desc.value;
|
15
|
+
},
|
16
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
17
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
18
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
19
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
20
|
+
function define(obj, key, value) {
|
21
|
+
return Object.defineProperty(obj, key, {
|
22
|
+
value: value,
|
23
|
+
enumerable: !0,
|
24
|
+
configurable: !0,
|
25
|
+
writable: !0
|
26
|
+
}), obj[key];
|
27
|
+
}
|
28
|
+
try {
|
29
|
+
define({}, "");
|
30
|
+
} catch (err) {
|
31
|
+
define = function (obj, key, value) {
|
32
|
+
return obj[key] = value;
|
33
|
+
};
|
34
|
+
}
|
35
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
36
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
37
|
+
generator = Object.create(protoGenerator.prototype),
|
38
|
+
context = new Context(tryLocsList || []);
|
39
|
+
return defineProperty(generator, "_invoke", {
|
40
|
+
value: makeInvokeMethod(innerFn, self, context)
|
41
|
+
}), generator;
|
42
|
+
}
|
43
|
+
function tryCatch(fn, obj, arg) {
|
44
|
+
try {
|
45
|
+
return {
|
46
|
+
type: "normal",
|
47
|
+
arg: fn.call(obj, arg)
|
48
|
+
};
|
49
|
+
} catch (err) {
|
50
|
+
return {
|
51
|
+
type: "throw",
|
52
|
+
arg: err
|
53
|
+
};
|
54
|
+
}
|
55
|
+
}
|
56
|
+
exports.wrap = wrap;
|
57
|
+
var ContinueSentinel = {};
|
58
|
+
function Generator() {}
|
59
|
+
function GeneratorFunction() {}
|
60
|
+
function GeneratorFunctionPrototype() {}
|
61
|
+
var IteratorPrototype = {};
|
62
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
63
|
+
return this;
|
64
|
+
});
|
65
|
+
var getProto = Object.getPrototypeOf,
|
66
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
67
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
68
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
69
|
+
function defineIteratorMethods(prototype) {
|
70
|
+
["next", "throw", "return"].forEach(function (method) {
|
71
|
+
define(prototype, method, function (arg) {
|
72
|
+
return this._invoke(method, arg);
|
73
|
+
});
|
74
|
+
});
|
75
|
+
}
|
76
|
+
function AsyncIterator(generator, PromiseImpl) {
|
77
|
+
function invoke(method, arg, resolve, reject) {
|
78
|
+
var record = tryCatch(generator[method], generator, arg);
|
79
|
+
if ("throw" !== record.type) {
|
80
|
+
var result = record.arg,
|
81
|
+
value = result.value;
|
82
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
83
|
+
invoke("next", value, resolve, reject);
|
84
|
+
}, function (err) {
|
85
|
+
invoke("throw", err, resolve, reject);
|
86
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
87
|
+
result.value = unwrapped, resolve(result);
|
88
|
+
}, function (error) {
|
89
|
+
return invoke("throw", error, resolve, reject);
|
90
|
+
});
|
91
|
+
}
|
92
|
+
reject(record.arg);
|
93
|
+
}
|
94
|
+
var previousPromise;
|
95
|
+
defineProperty(this, "_invoke", {
|
96
|
+
value: function (method, arg) {
|
97
|
+
function callInvokeWithMethodAndArg() {
|
98
|
+
return new PromiseImpl(function (resolve, reject) {
|
99
|
+
invoke(method, arg, resolve, reject);
|
100
|
+
});
|
101
|
+
}
|
102
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
103
|
+
}
|
104
|
+
});
|
105
|
+
}
|
106
|
+
function makeInvokeMethod(innerFn, self, context) {
|
107
|
+
var state = "suspendedStart";
|
108
|
+
return function (method, arg) {
|
109
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
110
|
+
if ("completed" === state) {
|
111
|
+
if ("throw" === method) throw arg;
|
112
|
+
return doneResult();
|
113
|
+
}
|
114
|
+
for (context.method = method, context.arg = arg;;) {
|
115
|
+
var delegate = context.delegate;
|
116
|
+
if (delegate) {
|
117
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
118
|
+
if (delegateResult) {
|
119
|
+
if (delegateResult === ContinueSentinel) continue;
|
120
|
+
return delegateResult;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
124
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
125
|
+
context.dispatchException(context.arg);
|
126
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
127
|
+
state = "executing";
|
128
|
+
var record = tryCatch(innerFn, self, context);
|
129
|
+
if ("normal" === record.type) {
|
130
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
131
|
+
return {
|
132
|
+
value: record.arg,
|
133
|
+
done: context.done
|
134
|
+
};
|
135
|
+
}
|
136
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
137
|
+
}
|
138
|
+
};
|
139
|
+
}
|
140
|
+
function maybeInvokeDelegate(delegate, context) {
|
141
|
+
var methodName = context.method,
|
142
|
+
method = delegate.iterator[methodName];
|
143
|
+
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;
|
144
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
145
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
146
|
+
var info = record.arg;
|
147
|
+
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);
|
148
|
+
}
|
149
|
+
function pushTryEntry(locs) {
|
150
|
+
var entry = {
|
151
|
+
tryLoc: locs[0]
|
152
|
+
};
|
153
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
154
|
+
}
|
155
|
+
function resetTryEntry(entry) {
|
156
|
+
var record = entry.completion || {};
|
157
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
158
|
+
}
|
159
|
+
function Context(tryLocsList) {
|
160
|
+
this.tryEntries = [{
|
161
|
+
tryLoc: "root"
|
162
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
163
|
+
}
|
164
|
+
function values(iterable) {
|
165
|
+
if (iterable) {
|
166
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
167
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
168
|
+
if ("function" == typeof iterable.next) return iterable;
|
169
|
+
if (!isNaN(iterable.length)) {
|
170
|
+
var i = -1,
|
171
|
+
next = function next() {
|
172
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
173
|
+
return next.value = undefined, next.done = !0, next;
|
174
|
+
};
|
175
|
+
return next.next = next;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
return {
|
179
|
+
next: doneResult
|
180
|
+
};
|
181
|
+
}
|
182
|
+
function doneResult() {
|
183
|
+
return {
|
184
|
+
value: undefined,
|
185
|
+
done: !0
|
186
|
+
};
|
187
|
+
}
|
188
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
189
|
+
value: GeneratorFunctionPrototype,
|
190
|
+
configurable: !0
|
191
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
192
|
+
value: GeneratorFunction,
|
193
|
+
configurable: !0
|
194
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
195
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
196
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
197
|
+
}, exports.mark = function (genFun) {
|
198
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
199
|
+
}, exports.awrap = function (arg) {
|
200
|
+
return {
|
201
|
+
__await: arg
|
202
|
+
};
|
203
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
204
|
+
return this;
|
205
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
206
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
207
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
208
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
209
|
+
return result.done ? result.value : iter.next();
|
210
|
+
});
|
211
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
212
|
+
return this;
|
213
|
+
}), define(Gp, "toString", function () {
|
214
|
+
return "[object Generator]";
|
215
|
+
}), exports.keys = function (val) {
|
216
|
+
var object = Object(val),
|
217
|
+
keys = [];
|
218
|
+
for (var key in object) keys.push(key);
|
219
|
+
return keys.reverse(), function next() {
|
220
|
+
for (; keys.length;) {
|
221
|
+
var key = keys.pop();
|
222
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
223
|
+
}
|
224
|
+
return next.done = !0, next;
|
225
|
+
};
|
226
|
+
}, exports.values = values, Context.prototype = {
|
227
|
+
constructor: Context,
|
228
|
+
reset: function (skipTempReset) {
|
229
|
+
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);
|
230
|
+
},
|
231
|
+
stop: function () {
|
232
|
+
this.done = !0;
|
233
|
+
var rootRecord = this.tryEntries[0].completion;
|
234
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
235
|
+
return this.rval;
|
236
|
+
},
|
237
|
+
dispatchException: function (exception) {
|
238
|
+
if (this.done) throw exception;
|
239
|
+
var context = this;
|
240
|
+
function handle(loc, caught) {
|
241
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
242
|
+
}
|
243
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
244
|
+
var entry = this.tryEntries[i],
|
245
|
+
record = entry.completion;
|
246
|
+
if ("root" === entry.tryLoc) return handle("end");
|
247
|
+
if (entry.tryLoc <= this.prev) {
|
248
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
249
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
250
|
+
if (hasCatch && hasFinally) {
|
251
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
252
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
253
|
+
} else if (hasCatch) {
|
254
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
255
|
+
} else {
|
256
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
257
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
258
|
+
}
|
259
|
+
}
|
260
|
+
}
|
261
|
+
},
|
262
|
+
abrupt: function (type, arg) {
|
263
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
264
|
+
var entry = this.tryEntries[i];
|
265
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
266
|
+
var finallyEntry = entry;
|
267
|
+
break;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
271
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
272
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
273
|
+
},
|
274
|
+
complete: function (record, afterLoc) {
|
275
|
+
if ("throw" === record.type) throw record.arg;
|
276
|
+
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;
|
277
|
+
},
|
278
|
+
finish: function (finallyLoc) {
|
279
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
280
|
+
var entry = this.tryEntries[i];
|
281
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
282
|
+
}
|
283
|
+
},
|
284
|
+
catch: function (tryLoc) {
|
285
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
286
|
+
var entry = this.tryEntries[i];
|
287
|
+
if (entry.tryLoc === tryLoc) {
|
288
|
+
var record = entry.completion;
|
289
|
+
if ("throw" === record.type) {
|
290
|
+
var thrown = record.arg;
|
291
|
+
resetTryEntry(entry);
|
292
|
+
}
|
293
|
+
return thrown;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
throw new Error("illegal catch attempt");
|
297
|
+
},
|
298
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
299
|
+
return this.delegate = {
|
300
|
+
iterator: values(iterable),
|
301
|
+
resultName: resultName,
|
302
|
+
nextLoc: nextLoc
|
303
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
304
|
+
}
|
305
|
+
}, exports;
|
306
|
+
}
|
307
|
+
|
308
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
309
|
+
try {
|
310
|
+
var info = gen[key](arg);
|
311
|
+
var value = info.value;
|
312
|
+
} catch (error) {
|
313
|
+
reject(error);
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
if (info.done) {
|
317
|
+
resolve(value);
|
318
|
+
} else {
|
319
|
+
Promise.resolve(value).then(_next, _throw);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
function _asyncToGenerator(fn) {
|
323
|
+
return function () {
|
324
|
+
var self = this,
|
325
|
+
args = arguments;
|
326
|
+
return new Promise(function (resolve, reject) {
|
327
|
+
var gen = fn.apply(self, args);
|
328
|
+
function _next(value) {
|
329
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
330
|
+
}
|
331
|
+
function _throw(err) {
|
332
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
333
|
+
}
|
334
|
+
_next(undefined);
|
335
|
+
});
|
336
|
+
};
|
337
|
+
}
|
338
|
+
|
339
|
+
function _classCallCheck(instance, Constructor) {
|
340
|
+
if (!(instance instanceof Constructor)) {
|
341
|
+
throw new TypeError("Cannot call a class as a function");
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
function _toPrimitive(input, hint) {
|
346
|
+
if (typeof input !== "object" || input === null) return input;
|
347
|
+
var prim = input[Symbol.toPrimitive];
|
348
|
+
if (prim !== undefined) {
|
349
|
+
var res = prim.call(input, hint || "default");
|
350
|
+
if (typeof res !== "object") return res;
|
351
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
352
|
+
}
|
353
|
+
return (hint === "string" ? String : Number)(input);
|
354
|
+
}
|
355
|
+
|
356
|
+
function _toPropertyKey(arg) {
|
357
|
+
var key = _toPrimitive(arg, "string");
|
358
|
+
return typeof key === "symbol" ? key : String(key);
|
359
|
+
}
|
360
|
+
|
361
|
+
function _defineProperties(target, props) {
|
362
|
+
for (var i = 0; i < props.length; i++) {
|
363
|
+
var descriptor = props[i];
|
364
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
365
|
+
descriptor.configurable = true;
|
366
|
+
if ("value" in descriptor) descriptor.writable = true;
|
367
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
368
|
+
}
|
369
|
+
}
|
370
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
371
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
372
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
373
|
+
Object.defineProperty(Constructor, "prototype", {
|
374
|
+
writable: false
|
375
|
+
});
|
376
|
+
return Constructor;
|
377
|
+
}
|
378
|
+
|
379
|
+
var ValApi = /*#__PURE__*/function () {
|
380
|
+
function ValApi(host) {
|
381
|
+
_classCallCheck(this, ValApi);
|
382
|
+
this.host = host;
|
383
|
+
}
|
384
|
+
_createClass(ValApi, [{
|
385
|
+
key: "getModule",
|
386
|
+
value: function () {
|
387
|
+
var _getModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourcePath) {
|
388
|
+
var res, serializedVal;
|
389
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
390
|
+
while (1) switch (_context.prev = _context.next) {
|
391
|
+
case 0:
|
392
|
+
_context.next = 2;
|
393
|
+
return fetch("".concat(this.host, "/ids").concat(sourcePath));
|
394
|
+
case 2:
|
395
|
+
res = _context.sent;
|
396
|
+
if (!res.ok) {
|
397
|
+
_context.next = 10;
|
398
|
+
break;
|
399
|
+
}
|
400
|
+
_context.next = 6;
|
401
|
+
return res.json();
|
402
|
+
case 6:
|
403
|
+
serializedVal = _context.sent;
|
404
|
+
return _context.abrupt("return", serializedVal);
|
405
|
+
case 10:
|
406
|
+
_context.t0 = Error;
|
407
|
+
_context.t1 = "Failed to get content of module \"".concat(sourcePath, "\". Status: ").concat(res.status, ". Error: ");
|
408
|
+
_context.next = 14;
|
409
|
+
return res.text();
|
410
|
+
case 14:
|
411
|
+
_context.t2 = _context.sent;
|
412
|
+
_context.t3 = _context.t1.concat.call(_context.t1, _context.t2);
|
413
|
+
throw (0, _context.t0)(_context.t3);
|
414
|
+
case 17:
|
415
|
+
case "end":
|
416
|
+
return _context.stop();
|
417
|
+
}
|
418
|
+
}, _callee, this);
|
419
|
+
}));
|
420
|
+
function getModule(_x) {
|
421
|
+
return _getModule.apply(this, arguments);
|
422
|
+
}
|
423
|
+
return getModule;
|
424
|
+
}()
|
425
|
+
}, {
|
426
|
+
key: "patchModuleContent",
|
427
|
+
value: function () {
|
428
|
+
var _patchModuleContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(moduleId, patch) {
|
429
|
+
var res;
|
430
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
431
|
+
while (1) switch (_context2.prev = _context2.next) {
|
432
|
+
case 0:
|
433
|
+
_context2.next = 2;
|
434
|
+
return fetch("".concat(this.host, "/ids").concat(moduleId), {
|
435
|
+
method: "PATCH",
|
436
|
+
headers: {
|
437
|
+
"Content-Type": "application/json-patch+json"
|
438
|
+
},
|
439
|
+
body: JSON.stringify(patch)
|
440
|
+
});
|
441
|
+
case 2:
|
442
|
+
res = _context2.sent;
|
443
|
+
if (!res.ok) {
|
444
|
+
_context2.next = 7;
|
445
|
+
break;
|
446
|
+
}
|
447
|
+
return _context2.abrupt("return", res.json());
|
448
|
+
case 7:
|
449
|
+
_context2.t0 = Error;
|
450
|
+
_context2.t1 = "Failed to patch content of module \"".concat(moduleId, "\". Error: ");
|
451
|
+
_context2.next = 11;
|
452
|
+
return res.text();
|
453
|
+
case 11:
|
454
|
+
_context2.t2 = _context2.sent;
|
455
|
+
_context2.t3 = _context2.t1.concat.call(_context2.t1, _context2.t2);
|
456
|
+
throw (0, _context2.t0)(_context2.t3);
|
457
|
+
case 14:
|
458
|
+
case "end":
|
459
|
+
return _context2.stop();
|
460
|
+
}
|
461
|
+
}, _callee2, this);
|
462
|
+
}));
|
463
|
+
function patchModuleContent(_x2, _x3) {
|
464
|
+
return _patchModuleContent.apply(this, arguments);
|
465
|
+
}
|
466
|
+
return patchModuleContent;
|
467
|
+
}()
|
468
|
+
}, {
|
469
|
+
key: "commit",
|
470
|
+
value: function () {
|
471
|
+
var _commit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
472
|
+
var res;
|
473
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
474
|
+
while (1) switch (_context3.prev = _context3.next) {
|
475
|
+
case 0:
|
476
|
+
_context3.next = 2;
|
477
|
+
return fetch("".concat(this.host, "/commit"), {
|
478
|
+
method: "POST"
|
479
|
+
});
|
480
|
+
case 2:
|
481
|
+
res = _context3.sent;
|
482
|
+
if (!res.ok) {
|
483
|
+
_context3.next = 7;
|
484
|
+
break;
|
485
|
+
}
|
486
|
+
return _context3.abrupt("return");
|
487
|
+
case 7:
|
488
|
+
_context3.t0 = Error;
|
489
|
+
_context3.t1 = "Failed to commit. Error: ";
|
490
|
+
_context3.next = 11;
|
491
|
+
return res.text();
|
492
|
+
case 11:
|
493
|
+
_context3.t2 = _context3.sent;
|
494
|
+
_context3.t3 = _context3.t1.concat.call(_context3.t1, _context3.t2);
|
495
|
+
throw (0, _context3.t0)(_context3.t3);
|
496
|
+
case 14:
|
497
|
+
case "end":
|
498
|
+
return _context3.stop();
|
499
|
+
}
|
500
|
+
}, _callee3, this);
|
501
|
+
}));
|
502
|
+
function commit() {
|
503
|
+
return _commit.apply(this, arguments);
|
504
|
+
}
|
505
|
+
return commit;
|
506
|
+
}()
|
507
|
+
}, {
|
508
|
+
key: "getSession",
|
509
|
+
value: function getSession() {
|
510
|
+
return fetch("".concat(this.host, "/session"));
|
511
|
+
}
|
512
|
+
}, {
|
513
|
+
key: "loginUrl",
|
514
|
+
value: function loginUrl() {
|
515
|
+
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(location.href));
|
516
|
+
}
|
517
|
+
}, {
|
518
|
+
key: "logout",
|
519
|
+
value: function logout() {
|
520
|
+
return fetch("".concat(this.host, "/logout"));
|
521
|
+
}
|
522
|
+
}]);
|
523
|
+
return ValApi;
|
524
|
+
}();
|
525
|
+
|
526
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
527
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
528
|
+
if (!it) {
|
529
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
530
|
+
if (it) o = it;
|
531
|
+
var i = 0;
|
532
|
+
var F = function () {};
|
533
|
+
return {
|
534
|
+
s: F,
|
535
|
+
n: function () {
|
536
|
+
if (i >= o.length) return {
|
537
|
+
done: true
|
538
|
+
};
|
539
|
+
return {
|
540
|
+
done: false,
|
541
|
+
value: o[i++]
|
542
|
+
};
|
543
|
+
},
|
544
|
+
e: function (e) {
|
545
|
+
throw e;
|
546
|
+
},
|
547
|
+
f: F
|
548
|
+
};
|
549
|
+
}
|
550
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
551
|
+
}
|
552
|
+
var normalCompletion = true,
|
553
|
+
didErr = false,
|
554
|
+
err;
|
555
|
+
return {
|
556
|
+
s: function () {
|
557
|
+
it = it.call(o);
|
558
|
+
},
|
559
|
+
n: function () {
|
560
|
+
var step = it.next();
|
561
|
+
normalCompletion = step.done;
|
562
|
+
return step;
|
563
|
+
},
|
564
|
+
e: function (e) {
|
565
|
+
didErr = true;
|
566
|
+
err = e;
|
567
|
+
},
|
568
|
+
f: function () {
|
569
|
+
try {
|
570
|
+
if (!normalCompletion && it.return != null) it.return();
|
571
|
+
} finally {
|
572
|
+
if (didErr) throw err;
|
573
|
+
}
|
574
|
+
}
|
575
|
+
};
|
576
|
+
}
|
577
|
+
|
578
|
+
function _defineProperty(obj, key, value) {
|
579
|
+
key = _toPropertyKey(key);
|
580
|
+
if (key in obj) {
|
581
|
+
Object.defineProperty(obj, key, {
|
582
|
+
value: value,
|
583
|
+
enumerable: true,
|
584
|
+
configurable: true,
|
585
|
+
writable: true
|
586
|
+
});
|
587
|
+
} else {
|
588
|
+
obj[key] = value;
|
589
|
+
}
|
590
|
+
return obj;
|
591
|
+
}
|
592
|
+
|
593
|
+
var ValStore = /*#__PURE__*/function () {
|
594
|
+
function ValStore(api) {
|
595
|
+
var _this = this;
|
596
|
+
_classCallCheck(this, ValStore);
|
597
|
+
_defineProperty(this, "subscribe", function (moduleId) {
|
598
|
+
return function (listener) {
|
599
|
+
var listeners = _this.listeners[moduleId] = moduleId in _this.listeners ? _this.listeners[moduleId] : [];
|
600
|
+
listeners.push(listener);
|
601
|
+
return function () {
|
602
|
+
listeners.splice(listeners.indexOf(listener), 1);
|
603
|
+
if (listeners.length === 0) {
|
604
|
+
delete _this.listeners[moduleId];
|
605
|
+
}
|
606
|
+
};
|
607
|
+
};
|
608
|
+
});
|
609
|
+
_defineProperty(this, "getSnapshot", function (moduleId) {
|
610
|
+
return function () {
|
611
|
+
return _this.vals.get(moduleId);
|
612
|
+
};
|
613
|
+
});
|
614
|
+
_defineProperty(this, "getServerSnapshot", function (moduleId) {
|
615
|
+
return function () {
|
616
|
+
return _this.vals.get(moduleId);
|
617
|
+
};
|
618
|
+
});
|
619
|
+
this.api = api;
|
620
|
+
this.vals = new Map();
|
621
|
+
this.listeners = {};
|
622
|
+
}
|
623
|
+
_createClass(ValStore, [{
|
624
|
+
key: "updateAll",
|
625
|
+
value: function () {
|
626
|
+
var _updateAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
627
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
628
|
+
while (1) switch (_context2.prev = _context2.next) {
|
629
|
+
case 0:
|
630
|
+
_context2.next = 2;
|
631
|
+
return Promise.all(
|
632
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
633
|
+
Object.keys(this.listeners).map( /*#__PURE__*/function () {
|
634
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(moduleId) {
|
635
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
636
|
+
while (1) switch (_context.prev = _context.next) {
|
637
|
+
case 0:
|
638
|
+
case "end":
|
639
|
+
return _context.stop();
|
640
|
+
}
|
641
|
+
}, _callee);
|
642
|
+
}));
|
643
|
+
return function (_x) {
|
644
|
+
return _ref.apply(this, arguments);
|
645
|
+
};
|
646
|
+
}()));
|
647
|
+
case 2:
|
648
|
+
case "end":
|
649
|
+
return _context2.stop();
|
650
|
+
}
|
651
|
+
}, _callee2, this);
|
652
|
+
}));
|
653
|
+
function updateAll() {
|
654
|
+
return _updateAll.apply(this, arguments);
|
655
|
+
}
|
656
|
+
return updateAll;
|
657
|
+
}()
|
658
|
+
}, {
|
659
|
+
key: "set",
|
660
|
+
value: function set(moduleId, val) {
|
661
|
+
this.vals.set(moduleId, val);
|
662
|
+
this.emitChange(moduleId);
|
663
|
+
}
|
664
|
+
}, {
|
665
|
+
key: "get",
|
666
|
+
value: function get(moduleId) {
|
667
|
+
return this.vals.get(moduleId);
|
668
|
+
}
|
669
|
+
}, {
|
670
|
+
key: "emitChange",
|
671
|
+
value: function emitChange(moduleId) {
|
672
|
+
var listeners = this.listeners[moduleId];
|
673
|
+
if (typeof listeners === "undefined") return;
|
674
|
+
var _iterator = _createForOfIteratorHelper(listeners),
|
675
|
+
_step;
|
676
|
+
try {
|
677
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
678
|
+
var listener = _step.value;
|
679
|
+
listener();
|
680
|
+
}
|
681
|
+
} catch (err) {
|
682
|
+
_iterator.e(err);
|
683
|
+
} finally {
|
684
|
+
_iterator.f();
|
685
|
+
}
|
686
|
+
}
|
687
|
+
}]);
|
688
|
+
return ValStore;
|
689
|
+
}();
|
690
|
+
|
691
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
692
|
+
function useValStore() {
|
693
|
+
return useContext(ValContext).valStore;
|
694
|
+
}
|
695
|
+
function useValApi() {
|
696
|
+
return useContext(ValContext).valApi;
|
697
|
+
}
|
698
|
+
var ValContext = /*#__PURE__*/React.createContext({
|
699
|
+
get valStore() {
|
700
|
+
throw Error("Val context not found. Ensure components are wrapped by ValProvider!");
|
701
|
+
},
|
702
|
+
get valApi() {
|
703
|
+
throw Error("Val context not found. Ensure components are wrapped by ValProvider!");
|
704
|
+
}
|
705
|
+
});
|
706
|
+
var ValUI = typeof window !== "undefined" ? /*#__PURE__*/lazy(function () {
|
707
|
+
return import('./ValUI-9a3eb570.esm.js');
|
708
|
+
}) : null;
|
709
|
+
function ValProvider(_ref) {
|
710
|
+
var _ref$host = _ref.host,
|
711
|
+
host = _ref$host === void 0 ? "/api/val" : _ref$host,
|
712
|
+
children = _ref.children;
|
713
|
+
var valApi = useMemo(function () {
|
714
|
+
return new ValApi(host);
|
715
|
+
}, [host]);
|
716
|
+
var valStore = useMemo(function () {
|
717
|
+
return new ValStore(valApi);
|
718
|
+
}, [valApi]);
|
719
|
+
return /*#__PURE__*/jsxs(ValContext.Provider, {
|
720
|
+
value: {
|
721
|
+
valApi: valApi,
|
722
|
+
valStore: valStore
|
723
|
+
},
|
724
|
+
children: [children, ValUI && /*#__PURE__*/jsx(ValUI, {
|
725
|
+
valApi: valApi,
|
726
|
+
valStore: valStore
|
727
|
+
})]
|
728
|
+
});
|
729
|
+
}
|
730
|
+
|
731
|
+
export { ValContext, _defineProperty as _, _createForOfIteratorHelper as a, _asyncToGenerator as b, _regeneratorRuntime as c, ValProvider as default, useValApi, useValStore };
|