@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
@@ -1,1088 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import root from 'react-shadow';
|
5
|
-
import { FILE_REF_PROP, VAL_EXTENSION, Internal } from '@valbuild/core';
|
6
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
1
|
+
import { createElement } from 'react';
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
3
|
+
import { Internal } from '@valbuild/core';
|
7
4
|
import parse from 'style-to-object';
|
8
5
|
|
9
|
-
function
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
if (typeof res !== "object") return res;
|
15
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
6
|
+
function ValProviderWrapper(_ref) {
|
7
|
+
_ref.host;
|
8
|
+
_ref.children;
|
9
|
+
{
|
10
|
+
return null;
|
16
11
|
}
|
17
|
-
return (hint === "string" ? String : Number)(input);
|
18
|
-
}
|
19
|
-
|
20
|
-
function _toPropertyKey(arg) {
|
21
|
-
var key = _toPrimitive(arg, "string");
|
22
|
-
return typeof key === "symbol" ? key : String(key);
|
23
|
-
}
|
24
|
-
|
25
|
-
function _defineProperty(obj, key, value) {
|
26
|
-
key = _toPropertyKey(key);
|
27
|
-
if (key in obj) {
|
28
|
-
Object.defineProperty(obj, key, {
|
29
|
-
value: value,
|
30
|
-
enumerable: true,
|
31
|
-
configurable: true,
|
32
|
-
writable: true
|
33
|
-
});
|
34
|
-
} else {
|
35
|
-
obj[key] = value;
|
36
|
-
}
|
37
|
-
return obj;
|
38
|
-
}
|
39
|
-
|
40
|
-
function ownKeys(object, enumerableOnly) {
|
41
|
-
var keys = Object.keys(object);
|
42
|
-
if (Object.getOwnPropertySymbols) {
|
43
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
44
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
45
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
46
|
-
})), keys.push.apply(keys, symbols);
|
47
|
-
}
|
48
|
-
return keys;
|
49
|
-
}
|
50
|
-
function _objectSpread2(target) {
|
51
|
-
for (var i = 1; i < arguments.length; i++) {
|
52
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
53
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
54
|
-
_defineProperty(target, key, source[key]);
|
55
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
56
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
57
|
-
});
|
58
|
-
}
|
59
|
-
return target;
|
60
|
-
}
|
61
|
-
|
62
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
63
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
64
|
-
if (!it) {
|
65
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
66
|
-
if (it) o = it;
|
67
|
-
var i = 0;
|
68
|
-
var F = function () {};
|
69
|
-
return {
|
70
|
-
s: F,
|
71
|
-
n: function () {
|
72
|
-
if (i >= o.length) return {
|
73
|
-
done: true
|
74
|
-
};
|
75
|
-
return {
|
76
|
-
done: false,
|
77
|
-
value: o[i++]
|
78
|
-
};
|
79
|
-
},
|
80
|
-
e: function (e) {
|
81
|
-
throw e;
|
82
|
-
},
|
83
|
-
f: F
|
84
|
-
};
|
85
|
-
}
|
86
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
87
|
-
}
|
88
|
-
var normalCompletion = true,
|
89
|
-
didErr = false,
|
90
|
-
err;
|
91
|
-
return {
|
92
|
-
s: function () {
|
93
|
-
it = it.call(o);
|
94
|
-
},
|
95
|
-
n: function () {
|
96
|
-
var step = it.next();
|
97
|
-
normalCompletion = step.done;
|
98
|
-
return step;
|
99
|
-
},
|
100
|
-
e: function (e) {
|
101
|
-
didErr = true;
|
102
|
-
err = e;
|
103
|
-
},
|
104
|
-
f: function () {
|
105
|
-
try {
|
106
|
-
if (!normalCompletion && it.return != null) it.return();
|
107
|
-
} finally {
|
108
|
-
if (didErr) throw err;
|
109
|
-
}
|
110
|
-
}
|
111
|
-
};
|
112
|
-
}
|
113
|
-
|
114
|
-
function _regeneratorRuntime() {
|
115
|
-
_regeneratorRuntime = function () {
|
116
|
-
return exports;
|
117
|
-
};
|
118
|
-
var exports = {},
|
119
|
-
Op = Object.prototype,
|
120
|
-
hasOwn = Op.hasOwnProperty,
|
121
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
122
|
-
obj[key] = desc.value;
|
123
|
-
},
|
124
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
125
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
126
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
127
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
128
|
-
function define(obj, key, value) {
|
129
|
-
return Object.defineProperty(obj, key, {
|
130
|
-
value: value,
|
131
|
-
enumerable: !0,
|
132
|
-
configurable: !0,
|
133
|
-
writable: !0
|
134
|
-
}), obj[key];
|
135
|
-
}
|
136
|
-
try {
|
137
|
-
define({}, "");
|
138
|
-
} catch (err) {
|
139
|
-
define = function (obj, key, value) {
|
140
|
-
return obj[key] = value;
|
141
|
-
};
|
142
|
-
}
|
143
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
144
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
145
|
-
generator = Object.create(protoGenerator.prototype),
|
146
|
-
context = new Context(tryLocsList || []);
|
147
|
-
return defineProperty(generator, "_invoke", {
|
148
|
-
value: makeInvokeMethod(innerFn, self, context)
|
149
|
-
}), generator;
|
150
|
-
}
|
151
|
-
function tryCatch(fn, obj, arg) {
|
152
|
-
try {
|
153
|
-
return {
|
154
|
-
type: "normal",
|
155
|
-
arg: fn.call(obj, arg)
|
156
|
-
};
|
157
|
-
} catch (err) {
|
158
|
-
return {
|
159
|
-
type: "throw",
|
160
|
-
arg: err
|
161
|
-
};
|
162
|
-
}
|
163
|
-
}
|
164
|
-
exports.wrap = wrap;
|
165
|
-
var ContinueSentinel = {};
|
166
|
-
function Generator() {}
|
167
|
-
function GeneratorFunction() {}
|
168
|
-
function GeneratorFunctionPrototype() {}
|
169
|
-
var IteratorPrototype = {};
|
170
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
171
|
-
return this;
|
172
|
-
});
|
173
|
-
var getProto = Object.getPrototypeOf,
|
174
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
175
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
176
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
177
|
-
function defineIteratorMethods(prototype) {
|
178
|
-
["next", "throw", "return"].forEach(function (method) {
|
179
|
-
define(prototype, method, function (arg) {
|
180
|
-
return this._invoke(method, arg);
|
181
|
-
});
|
182
|
-
});
|
183
|
-
}
|
184
|
-
function AsyncIterator(generator, PromiseImpl) {
|
185
|
-
function invoke(method, arg, resolve, reject) {
|
186
|
-
var record = tryCatch(generator[method], generator, arg);
|
187
|
-
if ("throw" !== record.type) {
|
188
|
-
var result = record.arg,
|
189
|
-
value = result.value;
|
190
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
191
|
-
invoke("next", value, resolve, reject);
|
192
|
-
}, function (err) {
|
193
|
-
invoke("throw", err, resolve, reject);
|
194
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
195
|
-
result.value = unwrapped, resolve(result);
|
196
|
-
}, function (error) {
|
197
|
-
return invoke("throw", error, resolve, reject);
|
198
|
-
});
|
199
|
-
}
|
200
|
-
reject(record.arg);
|
201
|
-
}
|
202
|
-
var previousPromise;
|
203
|
-
defineProperty(this, "_invoke", {
|
204
|
-
value: function (method, arg) {
|
205
|
-
function callInvokeWithMethodAndArg() {
|
206
|
-
return new PromiseImpl(function (resolve, reject) {
|
207
|
-
invoke(method, arg, resolve, reject);
|
208
|
-
});
|
209
|
-
}
|
210
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
211
|
-
}
|
212
|
-
});
|
213
|
-
}
|
214
|
-
function makeInvokeMethod(innerFn, self, context) {
|
215
|
-
var state = "suspendedStart";
|
216
|
-
return function (method, arg) {
|
217
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
218
|
-
if ("completed" === state) {
|
219
|
-
if ("throw" === method) throw arg;
|
220
|
-
return doneResult();
|
221
|
-
}
|
222
|
-
for (context.method = method, context.arg = arg;;) {
|
223
|
-
var delegate = context.delegate;
|
224
|
-
if (delegate) {
|
225
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
226
|
-
if (delegateResult) {
|
227
|
-
if (delegateResult === ContinueSentinel) continue;
|
228
|
-
return delegateResult;
|
229
|
-
}
|
230
|
-
}
|
231
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
232
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
233
|
-
context.dispatchException(context.arg);
|
234
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
235
|
-
state = "executing";
|
236
|
-
var record = tryCatch(innerFn, self, context);
|
237
|
-
if ("normal" === record.type) {
|
238
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
239
|
-
return {
|
240
|
-
value: record.arg,
|
241
|
-
done: context.done
|
242
|
-
};
|
243
|
-
}
|
244
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
245
|
-
}
|
246
|
-
};
|
247
|
-
}
|
248
|
-
function maybeInvokeDelegate(delegate, context) {
|
249
|
-
var methodName = context.method,
|
250
|
-
method = delegate.iterator[methodName];
|
251
|
-
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;
|
252
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
253
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
254
|
-
var info = record.arg;
|
255
|
-
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);
|
256
|
-
}
|
257
|
-
function pushTryEntry(locs) {
|
258
|
-
var entry = {
|
259
|
-
tryLoc: locs[0]
|
260
|
-
};
|
261
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
262
|
-
}
|
263
|
-
function resetTryEntry(entry) {
|
264
|
-
var record = entry.completion || {};
|
265
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
266
|
-
}
|
267
|
-
function Context(tryLocsList) {
|
268
|
-
this.tryEntries = [{
|
269
|
-
tryLoc: "root"
|
270
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
271
|
-
}
|
272
|
-
function values(iterable) {
|
273
|
-
if (iterable) {
|
274
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
275
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
276
|
-
if ("function" == typeof iterable.next) return iterable;
|
277
|
-
if (!isNaN(iterable.length)) {
|
278
|
-
var i = -1,
|
279
|
-
next = function next() {
|
280
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
281
|
-
return next.value = undefined, next.done = !0, next;
|
282
|
-
};
|
283
|
-
return next.next = next;
|
284
|
-
}
|
285
|
-
}
|
286
|
-
return {
|
287
|
-
next: doneResult
|
288
|
-
};
|
289
|
-
}
|
290
|
-
function doneResult() {
|
291
|
-
return {
|
292
|
-
value: undefined,
|
293
|
-
done: !0
|
294
|
-
};
|
295
|
-
}
|
296
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
297
|
-
value: GeneratorFunctionPrototype,
|
298
|
-
configurable: !0
|
299
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
300
|
-
value: GeneratorFunction,
|
301
|
-
configurable: !0
|
302
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
303
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
304
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
305
|
-
}, exports.mark = function (genFun) {
|
306
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
307
|
-
}, exports.awrap = function (arg) {
|
308
|
-
return {
|
309
|
-
__await: arg
|
310
|
-
};
|
311
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
312
|
-
return this;
|
313
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
314
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
315
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
316
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
317
|
-
return result.done ? result.value : iter.next();
|
318
|
-
});
|
319
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
320
|
-
return this;
|
321
|
-
}), define(Gp, "toString", function () {
|
322
|
-
return "[object Generator]";
|
323
|
-
}), exports.keys = function (val) {
|
324
|
-
var object = Object(val),
|
325
|
-
keys = [];
|
326
|
-
for (var key in object) keys.push(key);
|
327
|
-
return keys.reverse(), function next() {
|
328
|
-
for (; keys.length;) {
|
329
|
-
var key = keys.pop();
|
330
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
331
|
-
}
|
332
|
-
return next.done = !0, next;
|
333
|
-
};
|
334
|
-
}, exports.values = values, Context.prototype = {
|
335
|
-
constructor: Context,
|
336
|
-
reset: function (skipTempReset) {
|
337
|
-
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);
|
338
|
-
},
|
339
|
-
stop: function () {
|
340
|
-
this.done = !0;
|
341
|
-
var rootRecord = this.tryEntries[0].completion;
|
342
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
343
|
-
return this.rval;
|
344
|
-
},
|
345
|
-
dispatchException: function (exception) {
|
346
|
-
if (this.done) throw exception;
|
347
|
-
var context = this;
|
348
|
-
function handle(loc, caught) {
|
349
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
350
|
-
}
|
351
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
352
|
-
var entry = this.tryEntries[i],
|
353
|
-
record = entry.completion;
|
354
|
-
if ("root" === entry.tryLoc) return handle("end");
|
355
|
-
if (entry.tryLoc <= this.prev) {
|
356
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
357
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
358
|
-
if (hasCatch && hasFinally) {
|
359
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
360
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
361
|
-
} else if (hasCatch) {
|
362
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
363
|
-
} else {
|
364
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
365
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
366
|
-
}
|
367
|
-
}
|
368
|
-
}
|
369
|
-
},
|
370
|
-
abrupt: function (type, arg) {
|
371
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
372
|
-
var entry = this.tryEntries[i];
|
373
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
374
|
-
var finallyEntry = entry;
|
375
|
-
break;
|
376
|
-
}
|
377
|
-
}
|
378
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
379
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
380
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
381
|
-
},
|
382
|
-
complete: function (record, afterLoc) {
|
383
|
-
if ("throw" === record.type) throw record.arg;
|
384
|
-
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;
|
385
|
-
},
|
386
|
-
finish: function (finallyLoc) {
|
387
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
388
|
-
var entry = this.tryEntries[i];
|
389
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
390
|
-
}
|
391
|
-
},
|
392
|
-
catch: function (tryLoc) {
|
393
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
394
|
-
var entry = this.tryEntries[i];
|
395
|
-
if (entry.tryLoc === tryLoc) {
|
396
|
-
var record = entry.completion;
|
397
|
-
if ("throw" === record.type) {
|
398
|
-
var thrown = record.arg;
|
399
|
-
resetTryEntry(entry);
|
400
|
-
}
|
401
|
-
return thrown;
|
402
|
-
}
|
403
|
-
}
|
404
|
-
throw new Error("illegal catch attempt");
|
405
|
-
},
|
406
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
407
|
-
return this.delegate = {
|
408
|
-
iterator: values(iterable),
|
409
|
-
resultName: resultName,
|
410
|
-
nextLoc: nextLoc
|
411
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
412
|
-
}
|
413
|
-
}, exports;
|
414
|
-
}
|
415
|
-
|
416
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
417
|
-
try {
|
418
|
-
var info = gen[key](arg);
|
419
|
-
var value = info.value;
|
420
|
-
} catch (error) {
|
421
|
-
reject(error);
|
422
|
-
return;
|
423
|
-
}
|
424
|
-
if (info.done) {
|
425
|
-
resolve(value);
|
426
|
-
} else {
|
427
|
-
Promise.resolve(value).then(_next, _throw);
|
428
|
-
}
|
429
|
-
}
|
430
|
-
function _asyncToGenerator(fn) {
|
431
|
-
return function () {
|
432
|
-
var self = this,
|
433
|
-
args = arguments;
|
434
|
-
return new Promise(function (resolve, reject) {
|
435
|
-
var gen = fn.apply(self, args);
|
436
|
-
function _next(value) {
|
437
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
438
|
-
}
|
439
|
-
function _throw(err) {
|
440
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
441
|
-
}
|
442
|
-
_next(undefined);
|
443
|
-
});
|
444
|
-
};
|
445
|
-
}
|
446
|
-
|
447
|
-
function _classCallCheck(instance, Constructor) {
|
448
|
-
if (!(instance instanceof Constructor)) {
|
449
|
-
throw new TypeError("Cannot call a class as a function");
|
450
|
-
}
|
451
|
-
}
|
452
|
-
|
453
|
-
function _defineProperties(target, props) {
|
454
|
-
for (var i = 0; i < props.length; i++) {
|
455
|
-
var descriptor = props[i];
|
456
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
457
|
-
descriptor.configurable = true;
|
458
|
-
if ("value" in descriptor) descriptor.writable = true;
|
459
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
460
|
-
}
|
461
|
-
}
|
462
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
463
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
464
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
465
|
-
Object.defineProperty(Constructor, "prototype", {
|
466
|
-
writable: false
|
467
|
-
});
|
468
|
-
return Constructor;
|
469
|
-
}
|
470
|
-
|
471
|
-
var ValApi = /*#__PURE__*/function () {
|
472
|
-
function ValApi(host) {
|
473
|
-
_classCallCheck(this, ValApi);
|
474
|
-
this.host = host;
|
475
|
-
}
|
476
|
-
_createClass(ValApi, [{
|
477
|
-
key: "getModule",
|
478
|
-
value: function () {
|
479
|
-
var _getModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(sourcePath) {
|
480
|
-
var res, serializedVal;
|
481
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
482
|
-
while (1) switch (_context.prev = _context.next) {
|
483
|
-
case 0:
|
484
|
-
_context.next = 2;
|
485
|
-
return fetch("".concat(this.host, "/ids").concat(sourcePath));
|
486
|
-
case 2:
|
487
|
-
res = _context.sent;
|
488
|
-
if (!res.ok) {
|
489
|
-
_context.next = 10;
|
490
|
-
break;
|
491
|
-
}
|
492
|
-
_context.next = 6;
|
493
|
-
return res.json();
|
494
|
-
case 6:
|
495
|
-
serializedVal = _context.sent;
|
496
|
-
return _context.abrupt("return", serializedVal);
|
497
|
-
case 10:
|
498
|
-
_context.t0 = Error;
|
499
|
-
_context.t1 = "Failed to get content of module \"".concat(sourcePath, "\". Status: ").concat(res.status, ". Error: ");
|
500
|
-
_context.next = 14;
|
501
|
-
return res.text();
|
502
|
-
case 14:
|
503
|
-
_context.t2 = _context.sent;
|
504
|
-
_context.t3 = _context.t1.concat.call(_context.t1, _context.t2);
|
505
|
-
throw (0, _context.t0)(_context.t3);
|
506
|
-
case 17:
|
507
|
-
case "end":
|
508
|
-
return _context.stop();
|
509
|
-
}
|
510
|
-
}, _callee, this);
|
511
|
-
}));
|
512
|
-
function getModule(_x) {
|
513
|
-
return _getModule.apply(this, arguments);
|
514
|
-
}
|
515
|
-
return getModule;
|
516
|
-
}()
|
517
|
-
}, {
|
518
|
-
key: "patchModuleContent",
|
519
|
-
value: function () {
|
520
|
-
var _patchModuleContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(moduleId, patch) {
|
521
|
-
var res;
|
522
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
523
|
-
while (1) switch (_context2.prev = _context2.next) {
|
524
|
-
case 0:
|
525
|
-
_context2.next = 2;
|
526
|
-
return fetch("".concat(this.host, "/ids").concat(moduleId), {
|
527
|
-
method: "PATCH",
|
528
|
-
headers: {
|
529
|
-
"Content-Type": "application/json-patch+json"
|
530
|
-
},
|
531
|
-
body: JSON.stringify(patch)
|
532
|
-
});
|
533
|
-
case 2:
|
534
|
-
res = _context2.sent;
|
535
|
-
if (!res.ok) {
|
536
|
-
_context2.next = 7;
|
537
|
-
break;
|
538
|
-
}
|
539
|
-
return _context2.abrupt("return", res.json());
|
540
|
-
case 7:
|
541
|
-
_context2.t0 = Error;
|
542
|
-
_context2.t1 = "Failed to patch content of module \"".concat(moduleId, "\". Error: ");
|
543
|
-
_context2.next = 11;
|
544
|
-
return res.text();
|
545
|
-
case 11:
|
546
|
-
_context2.t2 = _context2.sent;
|
547
|
-
_context2.t3 = _context2.t1.concat.call(_context2.t1, _context2.t2);
|
548
|
-
throw (0, _context2.t0)(_context2.t3);
|
549
|
-
case 14:
|
550
|
-
case "end":
|
551
|
-
return _context2.stop();
|
552
|
-
}
|
553
|
-
}, _callee2, this);
|
554
|
-
}));
|
555
|
-
function patchModuleContent(_x2, _x3) {
|
556
|
-
return _patchModuleContent.apply(this, arguments);
|
557
|
-
}
|
558
|
-
return patchModuleContent;
|
559
|
-
}()
|
560
|
-
}, {
|
561
|
-
key: "commit",
|
562
|
-
value: function () {
|
563
|
-
var _commit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
564
|
-
var res;
|
565
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
566
|
-
while (1) switch (_context3.prev = _context3.next) {
|
567
|
-
case 0:
|
568
|
-
_context3.next = 2;
|
569
|
-
return fetch("".concat(this.host, "/commit"), {
|
570
|
-
method: "POST"
|
571
|
-
});
|
572
|
-
case 2:
|
573
|
-
res = _context3.sent;
|
574
|
-
if (!res.ok) {
|
575
|
-
_context3.next = 7;
|
576
|
-
break;
|
577
|
-
}
|
578
|
-
return _context3.abrupt("return");
|
579
|
-
case 7:
|
580
|
-
_context3.t0 = Error;
|
581
|
-
_context3.t1 = "Failed to commit. Error: ";
|
582
|
-
_context3.next = 11;
|
583
|
-
return res.text();
|
584
|
-
case 11:
|
585
|
-
_context3.t2 = _context3.sent;
|
586
|
-
_context3.t3 = _context3.t1.concat.call(_context3.t1, _context3.t2);
|
587
|
-
throw (0, _context3.t0)(_context3.t3);
|
588
|
-
case 14:
|
589
|
-
case "end":
|
590
|
-
return _context3.stop();
|
591
|
-
}
|
592
|
-
}, _callee3, this);
|
593
|
-
}));
|
594
|
-
function commit() {
|
595
|
-
return _commit.apply(this, arguments);
|
596
|
-
}
|
597
|
-
return commit;
|
598
|
-
}()
|
599
|
-
}, {
|
600
|
-
key: "getSession",
|
601
|
-
value: function getSession() {
|
602
|
-
return fetch("".concat(this.host, "/session"));
|
603
|
-
}
|
604
|
-
}, {
|
605
|
-
key: "loginUrl",
|
606
|
-
value: function loginUrl() {
|
607
|
-
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(location.href));
|
608
|
-
}
|
609
|
-
}, {
|
610
|
-
key: "logout",
|
611
|
-
value: function logout() {
|
612
|
-
return fetch("".concat(this.host, "/logout"));
|
613
|
-
}
|
614
|
-
}]);
|
615
|
-
return ValApi;
|
616
|
-
}();
|
617
|
-
|
618
|
-
var ValStore = /*#__PURE__*/function () {
|
619
|
-
function ValStore(api) {
|
620
|
-
var _this = this;
|
621
|
-
_classCallCheck(this, ValStore);
|
622
|
-
_defineProperty(this, "subscribe", function (moduleId) {
|
623
|
-
return function (listener) {
|
624
|
-
var listeners = _this.listeners[moduleId] = moduleId in _this.listeners ? _this.listeners[moduleId] : [];
|
625
|
-
listeners.push(listener);
|
626
|
-
return function () {
|
627
|
-
listeners.splice(listeners.indexOf(listener), 1);
|
628
|
-
if (listeners.length === 0) {
|
629
|
-
delete _this.listeners[moduleId];
|
630
|
-
}
|
631
|
-
};
|
632
|
-
};
|
633
|
-
});
|
634
|
-
_defineProperty(this, "getSnapshot", function (moduleId) {
|
635
|
-
return function () {
|
636
|
-
return _this.vals.get(moduleId);
|
637
|
-
};
|
638
|
-
});
|
639
|
-
_defineProperty(this, "getServerSnapshot", function (moduleId) {
|
640
|
-
return function () {
|
641
|
-
return _this.vals.get(moduleId);
|
642
|
-
};
|
643
|
-
});
|
644
|
-
this.api = api;
|
645
|
-
this.vals = new Map();
|
646
|
-
this.listeners = {};
|
647
|
-
}
|
648
|
-
_createClass(ValStore, [{
|
649
|
-
key: "updateAll",
|
650
|
-
value: function () {
|
651
|
-
var _updateAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
652
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
653
|
-
while (1) switch (_context2.prev = _context2.next) {
|
654
|
-
case 0:
|
655
|
-
_context2.next = 2;
|
656
|
-
return Promise.all(
|
657
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
658
|
-
Object.keys(this.listeners).map( /*#__PURE__*/function () {
|
659
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(moduleId) {
|
660
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
661
|
-
while (1) switch (_context.prev = _context.next) {
|
662
|
-
case 0:
|
663
|
-
case "end":
|
664
|
-
return _context.stop();
|
665
|
-
}
|
666
|
-
}, _callee);
|
667
|
-
}));
|
668
|
-
return function (_x) {
|
669
|
-
return _ref.apply(this, arguments);
|
670
|
-
};
|
671
|
-
}()));
|
672
|
-
case 2:
|
673
|
-
case "end":
|
674
|
-
return _context2.stop();
|
675
|
-
}
|
676
|
-
}, _callee2, this);
|
677
|
-
}));
|
678
|
-
function updateAll() {
|
679
|
-
return _updateAll.apply(this, arguments);
|
680
|
-
}
|
681
|
-
return updateAll;
|
682
|
-
}()
|
683
|
-
}, {
|
684
|
-
key: "set",
|
685
|
-
value: function set(moduleId, val) {
|
686
|
-
this.vals.set(moduleId, val);
|
687
|
-
this.emitChange(moduleId);
|
688
|
-
}
|
689
|
-
}, {
|
690
|
-
key: "get",
|
691
|
-
value: function get(moduleId) {
|
692
|
-
return this.vals.get(moduleId);
|
693
|
-
}
|
694
|
-
}, {
|
695
|
-
key: "emitChange",
|
696
|
-
value: function emitChange(moduleId) {
|
697
|
-
var listeners = this.listeners[moduleId];
|
698
|
-
if (typeof listeners === "undefined") return;
|
699
|
-
var _iterator = _createForOfIteratorHelper(listeners),
|
700
|
-
_step;
|
701
|
-
try {
|
702
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
703
|
-
var listener = _step.value;
|
704
|
-
listener();
|
705
|
-
}
|
706
|
-
} catch (err) {
|
707
|
-
_iterator.e(err);
|
708
|
-
} finally {
|
709
|
-
_iterator.f();
|
710
|
-
}
|
711
|
-
}
|
712
|
-
}]);
|
713
|
-
return ValStore;
|
714
|
-
}();
|
715
|
-
|
716
|
-
var ValContext = /*#__PURE__*/React.createContext({
|
717
|
-
get valStore() {
|
718
|
-
throw Error("Val context not found. Ensure components are wrapped by ValProvider!");
|
719
|
-
},
|
720
|
-
get valApi() {
|
721
|
-
throw Error("Val context not found. Ensure components are wrapped by ValProvider!");
|
722
|
-
}
|
723
|
-
});
|
724
|
-
function ValProvider(_ref) {
|
725
|
-
var _ref3;
|
726
|
-
var _ref$host = _ref.host,
|
727
|
-
host = _ref$host === void 0 ? "/api/val" : _ref$host,
|
728
|
-
children = _ref.children;
|
729
|
-
var _useState = useState([]),
|
730
|
-
_useState2 = _slicedToArray(_useState, 2),
|
731
|
-
selectedSources = _useState2[0],
|
732
|
-
setSelectedSources = _useState2[1];
|
733
|
-
var _useState3 = useState(false),
|
734
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
735
|
-
editMode = _useState4[0],
|
736
|
-
setEditMode = _useState4[1];
|
737
|
-
var _useState5 = useState(null),
|
738
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
739
|
-
editFormPosition = _useState6[0],
|
740
|
-
setEditFormPosition = _useState6[1];
|
741
|
-
var _useState7 = useState({
|
742
|
-
status: "not-asked"
|
743
|
-
}),
|
744
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
745
|
-
authentication = _useState8[0],
|
746
|
-
setAuthentication = _useState8[1];
|
747
|
-
var valApi = useMemo(function () {
|
748
|
-
return new ValApi(host);
|
749
|
-
}, [host]);
|
750
|
-
var valStore = useMemo(function () {
|
751
|
-
return new ValStore(valApi);
|
752
|
-
}, [valApi]);
|
753
|
-
useEffect(function () {
|
754
|
-
if (editMode) {
|
755
|
-
valStore.updateAll();
|
756
|
-
}
|
757
|
-
}, [editMode]);
|
758
|
-
useEffect(function () {
|
759
|
-
var openValFormListener = undefined;
|
760
|
-
var styleElement = undefined;
|
761
|
-
var editButtonClickOptions = {
|
762
|
-
capture: true,
|
763
|
-
passive: true
|
764
|
-
};
|
765
|
-
if (editMode) {
|
766
|
-
// highlight val element by appending a new style
|
767
|
-
styleElement = document.createElement("style");
|
768
|
-
styleElement.id = "val-edit-highlight";
|
769
|
-
styleElement.innerHTML = "\n .val-edit-mode >* [data-val-path] {\n outline: black solid 2px;\n outline-offset: 4px;\n cursor: pointer;\n }\n ";
|
770
|
-
document.body.appendChild(styleElement);
|
771
|
-
|
772
|
-
// capture event clicks on data-val-path elements
|
773
|
-
openValFormListener = function openValFormListener(e) {
|
774
|
-
if (e.target instanceof Element) {
|
775
|
-
var _parent;
|
776
|
-
var parent = e.target;
|
777
|
-
while (parent && parent !== document.body) {
|
778
|
-
if (parent.getAttribute("data-val-path")) {
|
779
|
-
break;
|
780
|
-
}
|
781
|
-
if (parent.parentElement) {
|
782
|
-
parent = parent.parentElement;
|
783
|
-
} else {
|
784
|
-
break;
|
785
|
-
}
|
786
|
-
}
|
787
|
-
var valSources = (_parent = parent) === null || _parent === void 0 ? void 0 : _parent.getAttribute("data-val-path");
|
788
|
-
if (valSources) {
|
789
|
-
e.stopPropagation();
|
790
|
-
setSelectedSources(valSources.split(",") /* TODO: just split on commas will not work if path contains , */);
|
791
|
-
|
792
|
-
setEditFormPosition({
|
793
|
-
left: e.pageX,
|
794
|
-
top: e.pageY
|
795
|
-
});
|
796
|
-
// } else if (!isValElement(e.target)) {
|
797
|
-
// console.log("click outside", e.target);
|
798
|
-
// setEditFormPosition(null);
|
799
|
-
// setSelectedSources([]);
|
800
|
-
}
|
801
|
-
}
|
802
|
-
};
|
803
|
-
|
804
|
-
document.addEventListener("click", openValFormListener, editButtonClickOptions);
|
805
|
-
}
|
806
|
-
return function () {
|
807
|
-
var _styleElement;
|
808
|
-
if (openValFormListener) {
|
809
|
-
document.removeEventListener("click", openValFormListener, editButtonClickOptions);
|
810
|
-
}
|
811
|
-
(_styleElement = styleElement) === null || _styleElement === void 0 ? void 0 : _styleElement.remove();
|
812
|
-
};
|
813
|
-
}, [editMode]);
|
814
|
-
|
815
|
-
// useEffect(() => {
|
816
|
-
// const requestAuth = !(
|
817
|
-
// authentication.status === "authenticated" ||
|
818
|
-
// authentication.status === "local"
|
819
|
-
// );
|
820
|
-
// if (requestAuth) {
|
821
|
-
// setSelectedSources([]);
|
822
|
-
// console.log("request auth");
|
823
|
-
// setEditFormPosition(null);
|
824
|
-
// }
|
825
|
-
// if (!editMode) {
|
826
|
-
// // reset state when disabled
|
827
|
-
// setSelectedSources([]);
|
828
|
-
// console.log("reset state");
|
829
|
-
// setEditFormPosition(null);
|
830
|
-
// }
|
831
|
-
// }, [editMode, selectedSources.length, authentication.status]);
|
832
|
-
|
833
|
-
useEffect(function () {
|
834
|
-
if (editMode) {
|
835
|
-
document.body.classList.add("val-edit-mode");
|
836
|
-
} else {
|
837
|
-
document.body.classList.remove("val-edit-mode");
|
838
|
-
}
|
839
|
-
if (editMode) {
|
840
|
-
if (authentication.status !== "authenticated") {
|
841
|
-
valApi.getSession().then( /*#__PURE__*/function () {
|
842
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
|
843
|
-
var data, message;
|
844
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
845
|
-
while (1) switch (_context.prev = _context.next) {
|
846
|
-
case 0:
|
847
|
-
if (!(res.status === 401)) {
|
848
|
-
_context.next = 4;
|
849
|
-
break;
|
850
|
-
}
|
851
|
-
setAuthentication({
|
852
|
-
status: "unauthenticated"
|
853
|
-
});
|
854
|
-
_context.next = 21;
|
855
|
-
break;
|
856
|
-
case 4:
|
857
|
-
if (!res.ok) {
|
858
|
-
_context.next = 11;
|
859
|
-
break;
|
860
|
-
}
|
861
|
-
_context.next = 7;
|
862
|
-
return res.json();
|
863
|
-
case 7:
|
864
|
-
data = _context.sent;
|
865
|
-
if (data.mode === "local") {
|
866
|
-
setAuthentication({
|
867
|
-
status: "local"
|
868
|
-
});
|
869
|
-
} else if (data.mode === "proxy") {
|
870
|
-
setAuthentication({
|
871
|
-
status: "authenticated"
|
872
|
-
});
|
873
|
-
} else {
|
874
|
-
setAuthentication({
|
875
|
-
status: "error",
|
876
|
-
message: "Unknown authentication mode"
|
877
|
-
});
|
878
|
-
}
|
879
|
-
_context.next = 21;
|
880
|
-
break;
|
881
|
-
case 11:
|
882
|
-
message = "Unknown error";
|
883
|
-
_context.prev = 12;
|
884
|
-
_context.next = 15;
|
885
|
-
return res.text();
|
886
|
-
case 15:
|
887
|
-
message = _context.sent;
|
888
|
-
_context.next = 20;
|
889
|
-
break;
|
890
|
-
case 18:
|
891
|
-
_context.prev = 18;
|
892
|
-
_context.t0 = _context["catch"](12);
|
893
|
-
case 20:
|
894
|
-
setAuthentication({
|
895
|
-
status: "error",
|
896
|
-
message: message
|
897
|
-
});
|
898
|
-
case 21:
|
899
|
-
case "end":
|
900
|
-
return _context.stop();
|
901
|
-
}
|
902
|
-
}, _callee, null, [[12, 18]]);
|
903
|
-
}));
|
904
|
-
return function (_x) {
|
905
|
-
return _ref2.apply(this, arguments);
|
906
|
-
};
|
907
|
-
}())["catch"](function (err) {
|
908
|
-
console.error("Failed to fetch session", err);
|
909
|
-
setAuthentication({
|
910
|
-
status: "error",
|
911
|
-
message: "Unknown authentication mode"
|
912
|
-
});
|
913
|
-
});
|
914
|
-
}
|
915
|
-
} else {
|
916
|
-
if (authentication.status === "error") {
|
917
|
-
setAuthentication({
|
918
|
-
status: "not-asked"
|
919
|
-
});
|
920
|
-
}
|
921
|
-
}
|
922
|
-
}, [editMode, authentication.status]);
|
923
|
-
var _useState9 = useState(false),
|
924
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
925
|
-
showEditButton = _useState10[0],
|
926
|
-
setShowEditButton = _useState10[1];
|
927
|
-
useEffect(function () {
|
928
|
-
setShowEditButton(true);
|
929
|
-
}, []);
|
930
|
-
var _useState11 = useState({}),
|
931
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
932
|
-
inputs = _useState12[0],
|
933
|
-
setInputs = _useState12[1];
|
934
|
-
useEffect(function () {
|
935
|
-
setInputs({});
|
936
|
-
var _iterator = _createForOfIteratorHelper(selectedSources),
|
937
|
-
_step;
|
938
|
-
try {
|
939
|
-
var _loop = function _loop() {
|
940
|
-
var path = _step.value;
|
941
|
-
valApi.getModule(path).then(function (serializedModule) {
|
942
|
-
var input;
|
943
|
-
if (serializedModule.schema.type === "string" && typeof serializedModule.source === "string") {
|
944
|
-
input = {
|
945
|
-
status: "completed",
|
946
|
-
type: "text",
|
947
|
-
data: serializedModule.source
|
948
|
-
};
|
949
|
-
} else if (serializedModule.schema.type === "richtext" && _typeof(serializedModule.source) === "object") {
|
950
|
-
input = {
|
951
|
-
status: "completed",
|
952
|
-
type: "richtext",
|
953
|
-
data: serializedModule.source // TODO: validate
|
954
|
-
};
|
955
|
-
} else if (serializedModule.schema.type === "image" && serializedModule.source && _typeof(serializedModule.source) === "object" && FILE_REF_PROP in serializedModule.source && typeof serializedModule.source[FILE_REF_PROP] === "string" && VAL_EXTENSION in serializedModule.source && typeof serializedModule.source[VAL_EXTENSION] === "string") {
|
956
|
-
input = {
|
957
|
-
status: "completed",
|
958
|
-
type: "image",
|
959
|
-
data: Internal.convertImageSource(serializedModule.source)
|
960
|
-
};
|
961
|
-
}
|
962
|
-
console.log("input path", path);
|
963
|
-
console.log("serialized path", serializedModule.path);
|
964
|
-
if (!input) {
|
965
|
-
throw new Error("Unsupported module type: ".concat(serializedModule.schema.type));
|
966
|
-
}
|
967
|
-
setInputs(function (inputs) {
|
968
|
-
return _objectSpread2(_objectSpread2({}, inputs), {}, _defineProperty({}, serializedModule.path, input));
|
969
|
-
});
|
970
|
-
});
|
971
|
-
};
|
972
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
973
|
-
_loop();
|
974
|
-
}
|
975
|
-
} catch (err) {
|
976
|
-
_iterator.e(err);
|
977
|
-
} finally {
|
978
|
-
_iterator.f();
|
979
|
-
}
|
980
|
-
}, [selectedSources.join(",")]);
|
981
|
-
return /*#__PURE__*/jsxs(ValContext.Provider, {
|
982
|
-
value: {
|
983
|
-
valApi: valApi,
|
984
|
-
valStore: valStore
|
985
|
-
},
|
986
|
-
children: [children, showEditButton && /*#__PURE__*/jsxs(root.div, {
|
987
|
-
children: [/*#__PURE__*/jsx("link", {
|
988
|
-
rel: "preconnect",
|
989
|
-
href: "https://fonts.googleapis.com"
|
990
|
-
}), /*#__PURE__*/jsx("link", {
|
991
|
-
rel: "preconnect",
|
992
|
-
href: "https://fonts.gstatic.com",
|
993
|
-
crossOrigin: "anonymous"
|
994
|
-
}), /*#__PURE__*/jsx("link", {
|
995
|
-
href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,400;1,700&display=swap",
|
996
|
-
rel: "stylesheet"
|
997
|
-
}), /*#__PURE__*/jsx(Style, {}), /*#__PURE__*/jsx("div", {
|
998
|
-
"data-mode": "dark",
|
999
|
-
children: /*#__PURE__*/jsx(ValOverlay, {
|
1000
|
-
editMode: editMode,
|
1001
|
-
setEditMode: setEditMode,
|
1002
|
-
closeValWindow: function closeValWindow() {
|
1003
|
-
setEditFormPosition(null);
|
1004
|
-
setSelectedSources([]);
|
1005
|
-
setInputs({});
|
1006
|
-
},
|
1007
|
-
valWindow: (_ref3 = editFormPosition && {
|
1008
|
-
position: editFormPosition,
|
1009
|
-
inputs: inputs,
|
1010
|
-
onSubmit: function onSubmit(inputs) {
|
1011
|
-
Promise.all(Object.entries(inputs).map(function (_ref4) {
|
1012
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
1013
|
-
path = _ref5[0],
|
1014
|
-
input = _ref5[1];
|
1015
|
-
if (input.status === "completed") {
|
1016
|
-
var _Internal$splitModule = Internal.splitModuleIdAndModulePath(path),
|
1017
|
-
_Internal$splitModule2 = _slicedToArray(_Internal$splitModule, 2),
|
1018
|
-
moduleId = _Internal$splitModule2[0],
|
1019
|
-
modulePath = _Internal$splitModule2[1];
|
1020
|
-
if (input.type === "text") {
|
1021
|
-
var patch = [{
|
1022
|
-
value: input.data,
|
1023
|
-
op: "replace",
|
1024
|
-
path: "/".concat(modulePath.split(".").map(function (p) {
|
1025
|
-
return JSON.parse(p);
|
1026
|
-
}).join("/"))
|
1027
|
-
}];
|
1028
|
-
return valApi.patchModuleContent(moduleId, patch);
|
1029
|
-
} else if (input.type === "image") {
|
1030
|
-
var pathParts = modulePath.split(".").map(function (p) {
|
1031
|
-
return JSON.parse(p);
|
1032
|
-
});
|
1033
|
-
if (!(input !== null && input !== void 0 && input.data) || !("src" in input.data)) {
|
1034
|
-
// TODO: We probably need to have an Output type that is different from the Input: we have a union of both cases in Input right now, and we believe we do not want that
|
1035
|
-
console.warn("No .src on input provided - this might mean no changes was made");
|
1036
|
-
return;
|
1037
|
-
}
|
1038
|
-
var _patch = [{
|
1039
|
-
value: input.data.src,
|
1040
|
-
op: "replace",
|
1041
|
-
path: "/".concat(pathParts.slice(0, -1).join("/"), "/$").concat(pathParts[pathParts.length - 1])
|
1042
|
-
}];
|
1043
|
-
if (input.data.metadata) {
|
1044
|
-
if (input.data.addMetadata) {
|
1045
|
-
_patch.push({
|
1046
|
-
value: input.data.metadata,
|
1047
|
-
op: "add",
|
1048
|
-
path: "/".concat(pathParts.join("/"), "/metadata")
|
1049
|
-
});
|
1050
|
-
} else {
|
1051
|
-
_patch.push({
|
1052
|
-
value: input.data.metadata,
|
1053
|
-
op: "replace",
|
1054
|
-
path: "/".concat(pathParts.join("/"), "/metadata")
|
1055
|
-
});
|
1056
|
-
}
|
1057
|
-
}
|
1058
|
-
console.log("patch", _patch);
|
1059
|
-
return valApi.patchModuleContent(moduleId, _patch);
|
1060
|
-
} else if (input.type === "richtext") {
|
1061
|
-
var _patch2 = [{
|
1062
|
-
value: input.data,
|
1063
|
-
op: "replace",
|
1064
|
-
path: "/".concat(modulePath.split(".").map(function (p) {
|
1065
|
-
return JSON.parse(p);
|
1066
|
-
}).join("/"))
|
1067
|
-
}];
|
1068
|
-
return valApi.patchModuleContent(moduleId, _patch2);
|
1069
|
-
}
|
1070
|
-
throw new Error("Unsupported input type: ".concat(input.type));
|
1071
|
-
} else {
|
1072
|
-
console.error("Submitted incomplete input, ignoring...");
|
1073
|
-
return Promise.resolve();
|
1074
|
-
}
|
1075
|
-
})).then(function () {
|
1076
|
-
setEditFormPosition(null);
|
1077
|
-
setSelectedSources([]);
|
1078
|
-
setInputs({});
|
1079
|
-
});
|
1080
|
-
}
|
1081
|
-
}) !== null && _ref3 !== void 0 ? _ref3 : undefined
|
1082
|
-
})
|
1083
|
-
})]
|
1084
|
-
})]
|
1085
|
-
});
|
1086
12
|
}
|
1087
13
|
|
1088
14
|
function useVal(selector, locale) {
|
@@ -1224,4 +150,4 @@ function ListItemComponent(_ref6) {
|
|
1224
150
|
});
|
1225
151
|
}
|
1226
152
|
|
1227
|
-
export { ValProvider, ValRichText, useVal };
|
153
|
+
export { ValProviderWrapper as ValProvider, ValRichText, useVal };
|