@plasmicpkgs/plasmic-cms 0.0.213 → 0.0.215
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/LICENSE.app.md +661 -0
- package/dist/api.d.ts +4 -2
- package/dist/components.d.ts +10 -3
- package/dist/context.d.ts +14 -5
- package/dist/plasmic-cms.cjs.development.js +757 -946
- package/dist/plasmic-cms.cjs.development.js.map +1 -1
- package/dist/plasmic-cms.cjs.production.min.js +1 -1
- package/dist/plasmic-cms.cjs.production.min.js.map +1 -1
- package/dist/plasmic-cms.esm.js +720 -910
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/dist/schema.d.ts +1 -0
- package/package.json +3 -3
- package/LICENSE.md +0 -21
|
@@ -9,9 +9,309 @@ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGl
|
|
|
9
9
|
var host = require('@plasmicapp/host');
|
|
10
10
|
var query = require('@plasmicapp/query');
|
|
11
11
|
var dayjs = _interopDefault(require('dayjs'));
|
|
12
|
-
var React = require('react');
|
|
13
|
-
var React__default = _interopDefault(React);
|
|
12
|
+
var React = _interopDefault(require('react'));
|
|
14
13
|
|
|
14
|
+
function _regeneratorRuntime() {
|
|
15
|
+
_regeneratorRuntime = function () {
|
|
16
|
+
return e;
|
|
17
|
+
};
|
|
18
|
+
var t,
|
|
19
|
+
e = {},
|
|
20
|
+
r = Object.prototype,
|
|
21
|
+
n = r.hasOwnProperty,
|
|
22
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
23
|
+
t[e] = r.value;
|
|
24
|
+
},
|
|
25
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
26
|
+
a = i.iterator || "@@iterator",
|
|
27
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
28
|
+
u = i.toStringTag || "@@toStringTag";
|
|
29
|
+
function define(t, e, r) {
|
|
30
|
+
return Object.defineProperty(t, e, {
|
|
31
|
+
value: r,
|
|
32
|
+
enumerable: !0,
|
|
33
|
+
configurable: !0,
|
|
34
|
+
writable: !0
|
|
35
|
+
}), t[e];
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
define({}, "");
|
|
39
|
+
} catch (t) {
|
|
40
|
+
define = function (t, e, r) {
|
|
41
|
+
return t[e] = r;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function wrap(t, e, r, n) {
|
|
45
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
46
|
+
a = Object.create(i.prototype),
|
|
47
|
+
c = new Context(n || []);
|
|
48
|
+
return o(a, "_invoke", {
|
|
49
|
+
value: makeInvokeMethod(t, r, c)
|
|
50
|
+
}), a;
|
|
51
|
+
}
|
|
52
|
+
function tryCatch(t, e, r) {
|
|
53
|
+
try {
|
|
54
|
+
return {
|
|
55
|
+
type: "normal",
|
|
56
|
+
arg: t.call(e, r)
|
|
57
|
+
};
|
|
58
|
+
} catch (t) {
|
|
59
|
+
return {
|
|
60
|
+
type: "throw",
|
|
61
|
+
arg: t
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
e.wrap = wrap;
|
|
66
|
+
var h = "suspendedStart",
|
|
67
|
+
l = "suspendedYield",
|
|
68
|
+
f = "executing",
|
|
69
|
+
s = "completed",
|
|
70
|
+
y = {};
|
|
71
|
+
function Generator() {}
|
|
72
|
+
function GeneratorFunction() {}
|
|
73
|
+
function GeneratorFunctionPrototype() {}
|
|
74
|
+
var p = {};
|
|
75
|
+
define(p, a, function () {
|
|
76
|
+
return this;
|
|
77
|
+
});
|
|
78
|
+
var d = Object.getPrototypeOf,
|
|
79
|
+
v = d && d(d(values([])));
|
|
80
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
81
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
82
|
+
function defineIteratorMethods(t) {
|
|
83
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
84
|
+
define(t, e, function (t) {
|
|
85
|
+
return this._invoke(e, t);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function AsyncIterator(t, e) {
|
|
90
|
+
function invoke(r, o, i, a) {
|
|
91
|
+
var c = tryCatch(t[r], t, o);
|
|
92
|
+
if ("throw" !== c.type) {
|
|
93
|
+
var u = c.arg,
|
|
94
|
+
h = u.value;
|
|
95
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
96
|
+
invoke("next", t, i, a);
|
|
97
|
+
}, function (t) {
|
|
98
|
+
invoke("throw", t, i, a);
|
|
99
|
+
}) : e.resolve(h).then(function (t) {
|
|
100
|
+
u.value = t, i(u);
|
|
101
|
+
}, function (t) {
|
|
102
|
+
return invoke("throw", t, i, a);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
a(c.arg);
|
|
106
|
+
}
|
|
107
|
+
var r;
|
|
108
|
+
o(this, "_invoke", {
|
|
109
|
+
value: function (t, n) {
|
|
110
|
+
function callInvokeWithMethodAndArg() {
|
|
111
|
+
return new e(function (e, r) {
|
|
112
|
+
invoke(t, n, e, r);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function makeInvokeMethod(e, r, n) {
|
|
120
|
+
var o = h;
|
|
121
|
+
return function (i, a) {
|
|
122
|
+
if (o === f) throw new Error("Generator is already running");
|
|
123
|
+
if (o === s) {
|
|
124
|
+
if ("throw" === i) throw a;
|
|
125
|
+
return {
|
|
126
|
+
value: t,
|
|
127
|
+
done: !0
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
for (n.method = i, n.arg = a;;) {
|
|
131
|
+
var c = n.delegate;
|
|
132
|
+
if (c) {
|
|
133
|
+
var u = maybeInvokeDelegate(c, n);
|
|
134
|
+
if (u) {
|
|
135
|
+
if (u === y) continue;
|
|
136
|
+
return u;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
140
|
+
if (o === h) throw o = s, n.arg;
|
|
141
|
+
n.dispatchException(n.arg);
|
|
142
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
143
|
+
o = f;
|
|
144
|
+
var p = tryCatch(e, r, n);
|
|
145
|
+
if ("normal" === p.type) {
|
|
146
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
147
|
+
return {
|
|
148
|
+
value: p.arg,
|
|
149
|
+
done: n.done
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function maybeInvokeDelegate(e, r) {
|
|
157
|
+
var n = r.method,
|
|
158
|
+
o = e.iterator[n];
|
|
159
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
160
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
161
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
162
|
+
var a = i.arg;
|
|
163
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
164
|
+
}
|
|
165
|
+
function pushTryEntry(t) {
|
|
166
|
+
var e = {
|
|
167
|
+
tryLoc: t[0]
|
|
168
|
+
};
|
|
169
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
170
|
+
}
|
|
171
|
+
function resetTryEntry(t) {
|
|
172
|
+
var e = t.completion || {};
|
|
173
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
174
|
+
}
|
|
175
|
+
function Context(t) {
|
|
176
|
+
this.tryEntries = [{
|
|
177
|
+
tryLoc: "root"
|
|
178
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
179
|
+
}
|
|
180
|
+
function values(e) {
|
|
181
|
+
if (e || "" === e) {
|
|
182
|
+
var r = e[a];
|
|
183
|
+
if (r) return r.call(e);
|
|
184
|
+
if ("function" == typeof e.next) return e;
|
|
185
|
+
if (!isNaN(e.length)) {
|
|
186
|
+
var o = -1,
|
|
187
|
+
i = function next() {
|
|
188
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
189
|
+
return next.value = t, next.done = !0, next;
|
|
190
|
+
};
|
|
191
|
+
return i.next = i;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
195
|
+
}
|
|
196
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
197
|
+
value: GeneratorFunctionPrototype,
|
|
198
|
+
configurable: !0
|
|
199
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
200
|
+
value: GeneratorFunction,
|
|
201
|
+
configurable: !0
|
|
202
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
203
|
+
var e = "function" == typeof t && t.constructor;
|
|
204
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
205
|
+
}, e.mark = function (t) {
|
|
206
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
207
|
+
}, e.awrap = function (t) {
|
|
208
|
+
return {
|
|
209
|
+
__await: t
|
|
210
|
+
};
|
|
211
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
212
|
+
return this;
|
|
213
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
214
|
+
void 0 === i && (i = Promise);
|
|
215
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
216
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
217
|
+
return t.done ? t.value : a.next();
|
|
218
|
+
});
|
|
219
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
220
|
+
return this;
|
|
221
|
+
}), define(g, "toString", function () {
|
|
222
|
+
return "[object Generator]";
|
|
223
|
+
}), e.keys = function (t) {
|
|
224
|
+
var e = Object(t),
|
|
225
|
+
r = [];
|
|
226
|
+
for (var n in e) r.push(n);
|
|
227
|
+
return r.reverse(), function next() {
|
|
228
|
+
for (; r.length;) {
|
|
229
|
+
var t = r.pop();
|
|
230
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
231
|
+
}
|
|
232
|
+
return next.done = !0, next;
|
|
233
|
+
};
|
|
234
|
+
}, e.values = values, Context.prototype = {
|
|
235
|
+
constructor: Context,
|
|
236
|
+
reset: function (e) {
|
|
237
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
238
|
+
},
|
|
239
|
+
stop: function () {
|
|
240
|
+
this.done = !0;
|
|
241
|
+
var t = this.tryEntries[0].completion;
|
|
242
|
+
if ("throw" === t.type) throw t.arg;
|
|
243
|
+
return this.rval;
|
|
244
|
+
},
|
|
245
|
+
dispatchException: function (e) {
|
|
246
|
+
if (this.done) throw e;
|
|
247
|
+
var r = this;
|
|
248
|
+
function handle(n, o) {
|
|
249
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
250
|
+
}
|
|
251
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
252
|
+
var i = this.tryEntries[o],
|
|
253
|
+
a = i.completion;
|
|
254
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
255
|
+
if (i.tryLoc <= this.prev) {
|
|
256
|
+
var c = n.call(i, "catchLoc"),
|
|
257
|
+
u = n.call(i, "finallyLoc");
|
|
258
|
+
if (c && u) {
|
|
259
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
260
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
261
|
+
} else if (c) {
|
|
262
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
263
|
+
} else {
|
|
264
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
265
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
abrupt: function (t, e) {
|
|
271
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
272
|
+
var o = this.tryEntries[r];
|
|
273
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
274
|
+
var i = o;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
279
|
+
var a = i ? i.completion : {};
|
|
280
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
281
|
+
},
|
|
282
|
+
complete: function (t, e) {
|
|
283
|
+
if ("throw" === t.type) throw t.arg;
|
|
284
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
285
|
+
},
|
|
286
|
+
finish: function (t) {
|
|
287
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
288
|
+
var r = this.tryEntries[e];
|
|
289
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
catch: function (t) {
|
|
293
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
294
|
+
var r = this.tryEntries[e];
|
|
295
|
+
if (r.tryLoc === t) {
|
|
296
|
+
var n = r.completion;
|
|
297
|
+
if ("throw" === n.type) {
|
|
298
|
+
var o = n.arg;
|
|
299
|
+
resetTryEntry(r);
|
|
300
|
+
}
|
|
301
|
+
return o;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
throw new Error("illegal catch attempt");
|
|
305
|
+
},
|
|
306
|
+
delegateYield: function (e, r, n) {
|
|
307
|
+
return this.delegate = {
|
|
308
|
+
iterator: values(e),
|
|
309
|
+
resultName: r,
|
|
310
|
+
nextLoc: n
|
|
311
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
312
|
+
}
|
|
313
|
+
}, e;
|
|
314
|
+
}
|
|
15
315
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16
316
|
try {
|
|
17
317
|
var info = gen[key](arg);
|
|
@@ -142,668 +442,11 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
142
442
|
return target;
|
|
143
443
|
}
|
|
144
444
|
|
|
145
|
-
function createCommonjsModule(fn, module) {
|
|
146
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
150
|
-
/**
|
|
151
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
152
|
-
*
|
|
153
|
-
* This source code is licensed under the MIT license found in the
|
|
154
|
-
* LICENSE file in the root directory of this source tree.
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
var runtime = function (exports) {
|
|
158
|
-
|
|
159
|
-
var Op = Object.prototype;
|
|
160
|
-
var hasOwn = Op.hasOwnProperty;
|
|
161
|
-
var undefined$1; // More compressible than void 0.
|
|
162
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
163
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
164
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
165
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
166
|
-
function define(obj, key, value) {
|
|
167
|
-
Object.defineProperty(obj, key, {
|
|
168
|
-
value: value,
|
|
169
|
-
enumerable: true,
|
|
170
|
-
configurable: true,
|
|
171
|
-
writable: true
|
|
172
|
-
});
|
|
173
|
-
return obj[key];
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
176
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
177
|
-
define({}, "");
|
|
178
|
-
} catch (err) {
|
|
179
|
-
define = function define(obj, key, value) {
|
|
180
|
-
return obj[key] = value;
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
184
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
185
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
186
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
187
|
-
var context = new Context(tryLocsList || []);
|
|
188
|
-
|
|
189
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
190
|
-
// .throw, and .return methods.
|
|
191
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
192
|
-
return generator;
|
|
193
|
-
}
|
|
194
|
-
exports.wrap = wrap;
|
|
195
|
-
|
|
196
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
197
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
198
|
-
// have been (and was previously) designed to take a closure to be
|
|
199
|
-
// invoked without arguments, but in all the cases we care about we
|
|
200
|
-
// already have an existing method we want to call, so there's no need
|
|
201
|
-
// to create a new function object. We can even get away with assuming
|
|
202
|
-
// the method takes exactly one argument, since that happens to be true
|
|
203
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
204
|
-
// only additional allocation required is the completion record, which
|
|
205
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
206
|
-
function tryCatch(fn, obj, arg) {
|
|
207
|
-
try {
|
|
208
|
-
return {
|
|
209
|
-
type: "normal",
|
|
210
|
-
arg: fn.call(obj, arg)
|
|
211
|
-
};
|
|
212
|
-
} catch (err) {
|
|
213
|
-
return {
|
|
214
|
-
type: "throw",
|
|
215
|
-
arg: err
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
220
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
221
|
-
var GenStateExecuting = "executing";
|
|
222
|
-
var GenStateCompleted = "completed";
|
|
223
|
-
|
|
224
|
-
// Returning this object from the innerFn has the same effect as
|
|
225
|
-
// breaking out of the dispatch switch statement.
|
|
226
|
-
var ContinueSentinel = {};
|
|
227
|
-
|
|
228
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
229
|
-
// .constructor.prototype properties for functions that return Generator
|
|
230
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
231
|
-
// minifier not to mangle the names of these two functions.
|
|
232
|
-
function Generator() {}
|
|
233
|
-
function GeneratorFunction() {}
|
|
234
|
-
function GeneratorFunctionPrototype() {}
|
|
235
|
-
|
|
236
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
237
|
-
// don't natively support it.
|
|
238
|
-
var IteratorPrototype = {};
|
|
239
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
240
|
-
return this;
|
|
241
|
-
});
|
|
242
|
-
var getProto = Object.getPrototypeOf;
|
|
243
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
244
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
245
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
246
|
-
// of the polyfill.
|
|
247
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
248
|
-
}
|
|
249
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
250
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
251
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
252
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
253
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
254
|
-
|
|
255
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
256
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
257
|
-
function defineIteratorMethods(prototype) {
|
|
258
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
259
|
-
define(prototype, method, function (arg) {
|
|
260
|
-
return this._invoke(method, arg);
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
265
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
266
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
267
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
268
|
-
// do is to check its .name property.
|
|
269
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
270
|
-
};
|
|
271
|
-
exports.mark = function (genFun) {
|
|
272
|
-
if (Object.setPrototypeOf) {
|
|
273
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
274
|
-
} else {
|
|
275
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
276
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
277
|
-
}
|
|
278
|
-
genFun.prototype = Object.create(Gp);
|
|
279
|
-
return genFun;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
// Within the body of any async function, `await x` is transformed to
|
|
283
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
284
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
285
|
-
// meant to be awaited.
|
|
286
|
-
exports.awrap = function (arg) {
|
|
287
|
-
return {
|
|
288
|
-
__await: arg
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
292
|
-
function invoke(method, arg, resolve, reject) {
|
|
293
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
294
|
-
if (record.type === "throw") {
|
|
295
|
-
reject(record.arg);
|
|
296
|
-
} else {
|
|
297
|
-
var result = record.arg;
|
|
298
|
-
var value = result.value;
|
|
299
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
300
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
301
|
-
invoke("next", value, resolve, reject);
|
|
302
|
-
}, function (err) {
|
|
303
|
-
invoke("throw", err, resolve, reject);
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
307
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
308
|
-
// the .value of the Promise<{value,done}> result for the
|
|
309
|
-
// current iteration.
|
|
310
|
-
result.value = unwrapped;
|
|
311
|
-
resolve(result);
|
|
312
|
-
}, function (error) {
|
|
313
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
314
|
-
// into the async generator function so it can be handled there.
|
|
315
|
-
return invoke("throw", error, resolve, reject);
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
var previousPromise;
|
|
320
|
-
function enqueue(method, arg) {
|
|
321
|
-
function callInvokeWithMethodAndArg() {
|
|
322
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
323
|
-
invoke(method, arg, resolve, reject);
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
return previousPromise =
|
|
327
|
-
// If enqueue has been called before, then we want to wait until
|
|
328
|
-
// all previous Promises have been resolved before calling invoke,
|
|
329
|
-
// so that results are always delivered in the correct order. If
|
|
330
|
-
// enqueue has not been called before, then it is important to
|
|
331
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
332
|
-
// so that the async generator function has the opportunity to do
|
|
333
|
-
// any necessary setup in a predictable way. This predictability
|
|
334
|
-
// is why the Promise constructor synchronously invokes its
|
|
335
|
-
// executor callback, and why async functions synchronously
|
|
336
|
-
// execute code before the first await. Since we implement simple
|
|
337
|
-
// async functions in terms of async generators, it is especially
|
|
338
|
-
// important to get this right, even though it requires care.
|
|
339
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
340
|
-
// Avoid propagating failures to Promises returned by later
|
|
341
|
-
// invocations of the iterator.
|
|
342
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Define the unified helper method that is used to implement .next,
|
|
346
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
347
|
-
this._invoke = enqueue;
|
|
348
|
-
}
|
|
349
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
350
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
351
|
-
return this;
|
|
352
|
-
});
|
|
353
|
-
exports.AsyncIterator = AsyncIterator;
|
|
354
|
-
|
|
355
|
-
// Note that simple async functions are implemented on top of
|
|
356
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
357
|
-
// the final result produced by the iterator.
|
|
358
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
359
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
360
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
361
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
362
|
-
: iter.next().then(function (result) {
|
|
363
|
-
return result.done ? result.value : iter.next();
|
|
364
|
-
});
|
|
365
|
-
};
|
|
366
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
367
|
-
var state = GenStateSuspendedStart;
|
|
368
|
-
return function invoke(method, arg) {
|
|
369
|
-
if (state === GenStateExecuting) {
|
|
370
|
-
throw new Error("Generator is already running");
|
|
371
|
-
}
|
|
372
|
-
if (state === GenStateCompleted) {
|
|
373
|
-
if (method === "throw") {
|
|
374
|
-
throw arg;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
378
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
379
|
-
return doneResult();
|
|
380
|
-
}
|
|
381
|
-
context.method = method;
|
|
382
|
-
context.arg = arg;
|
|
383
|
-
while (true) {
|
|
384
|
-
var delegate = context.delegate;
|
|
385
|
-
if (delegate) {
|
|
386
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
387
|
-
if (delegateResult) {
|
|
388
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
389
|
-
return delegateResult;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
if (context.method === "next") {
|
|
393
|
-
// Setting context._sent for legacy support of Babel's
|
|
394
|
-
// function.sent implementation.
|
|
395
|
-
context.sent = context._sent = context.arg;
|
|
396
|
-
} else if (context.method === "throw") {
|
|
397
|
-
if (state === GenStateSuspendedStart) {
|
|
398
|
-
state = GenStateCompleted;
|
|
399
|
-
throw context.arg;
|
|
400
|
-
}
|
|
401
|
-
context.dispatchException(context.arg);
|
|
402
|
-
} else if (context.method === "return") {
|
|
403
|
-
context.abrupt("return", context.arg);
|
|
404
|
-
}
|
|
405
|
-
state = GenStateExecuting;
|
|
406
|
-
var record = tryCatch(innerFn, self, context);
|
|
407
|
-
if (record.type === "normal") {
|
|
408
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
409
|
-
// GenStateExecuting and loop back for another invocation.
|
|
410
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
411
|
-
if (record.arg === ContinueSentinel) {
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
return {
|
|
415
|
-
value: record.arg,
|
|
416
|
-
done: context.done
|
|
417
|
-
};
|
|
418
|
-
} else if (record.type === "throw") {
|
|
419
|
-
state = GenStateCompleted;
|
|
420
|
-
// Dispatch the exception by looping back around to the
|
|
421
|
-
// context.dispatchException(context.arg) call above.
|
|
422
|
-
context.method = "throw";
|
|
423
|
-
context.arg = record.arg;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
430
|
-
// result, either by returning a { value, done } result from the
|
|
431
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
432
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
433
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
434
|
-
var method = delegate.iterator[context.method];
|
|
435
|
-
if (method === undefined$1) {
|
|
436
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
437
|
-
// method always terminates the yield* loop.
|
|
438
|
-
context.delegate = null;
|
|
439
|
-
if (context.method === "throw") {
|
|
440
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
441
|
-
if (delegate.iterator["return"]) {
|
|
442
|
-
// If the delegate iterator has a return method, give it a
|
|
443
|
-
// chance to clean up.
|
|
444
|
-
context.method = "return";
|
|
445
|
-
context.arg = undefined$1;
|
|
446
|
-
maybeInvokeDelegate(delegate, context);
|
|
447
|
-
if (context.method === "throw") {
|
|
448
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
449
|
-
// "return" to "throw", let that override the TypeError below.
|
|
450
|
-
return ContinueSentinel;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
context.method = "throw";
|
|
454
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
455
|
-
}
|
|
456
|
-
return ContinueSentinel;
|
|
457
|
-
}
|
|
458
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
459
|
-
if (record.type === "throw") {
|
|
460
|
-
context.method = "throw";
|
|
461
|
-
context.arg = record.arg;
|
|
462
|
-
context.delegate = null;
|
|
463
|
-
return ContinueSentinel;
|
|
464
|
-
}
|
|
465
|
-
var info = record.arg;
|
|
466
|
-
if (!info) {
|
|
467
|
-
context.method = "throw";
|
|
468
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
469
|
-
context.delegate = null;
|
|
470
|
-
return ContinueSentinel;
|
|
471
|
-
}
|
|
472
|
-
if (info.done) {
|
|
473
|
-
// Assign the result of the finished delegate to the temporary
|
|
474
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
475
|
-
context[delegate.resultName] = info.value;
|
|
476
|
-
|
|
477
|
-
// Resume execution at the desired location (see delegateYield).
|
|
478
|
-
context.next = delegate.nextLoc;
|
|
479
|
-
|
|
480
|
-
// If context.method was "throw" but the delegate handled the
|
|
481
|
-
// exception, let the outer generator proceed normally. If
|
|
482
|
-
// context.method was "next", forget context.arg since it has been
|
|
483
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
484
|
-
// "return", allow the original .return call to continue in the
|
|
485
|
-
// outer generator.
|
|
486
|
-
if (context.method !== "return") {
|
|
487
|
-
context.method = "next";
|
|
488
|
-
context.arg = undefined$1;
|
|
489
|
-
}
|
|
490
|
-
} else {
|
|
491
|
-
// Re-yield the result returned by the delegate method.
|
|
492
|
-
return info;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
496
|
-
// the outer generator.
|
|
497
|
-
context.delegate = null;
|
|
498
|
-
return ContinueSentinel;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
502
|
-
// unified ._invoke helper method.
|
|
503
|
-
defineIteratorMethods(Gp);
|
|
504
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
505
|
-
|
|
506
|
-
// A Generator should always return itself as the iterator object when the
|
|
507
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
508
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
509
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
510
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
511
|
-
define(Gp, iteratorSymbol, function () {
|
|
512
|
-
return this;
|
|
513
|
-
});
|
|
514
|
-
define(Gp, "toString", function () {
|
|
515
|
-
return "[object Generator]";
|
|
516
|
-
});
|
|
517
|
-
function pushTryEntry(locs) {
|
|
518
|
-
var entry = {
|
|
519
|
-
tryLoc: locs[0]
|
|
520
|
-
};
|
|
521
|
-
if (1 in locs) {
|
|
522
|
-
entry.catchLoc = locs[1];
|
|
523
|
-
}
|
|
524
|
-
if (2 in locs) {
|
|
525
|
-
entry.finallyLoc = locs[2];
|
|
526
|
-
entry.afterLoc = locs[3];
|
|
527
|
-
}
|
|
528
|
-
this.tryEntries.push(entry);
|
|
529
|
-
}
|
|
530
|
-
function resetTryEntry(entry) {
|
|
531
|
-
var record = entry.completion || {};
|
|
532
|
-
record.type = "normal";
|
|
533
|
-
delete record.arg;
|
|
534
|
-
entry.completion = record;
|
|
535
|
-
}
|
|
536
|
-
function Context(tryLocsList) {
|
|
537
|
-
// The root entry object (effectively a try statement without a catch
|
|
538
|
-
// or a finally block) gives us a place to store values thrown from
|
|
539
|
-
// locations where there is no enclosing try statement.
|
|
540
|
-
this.tryEntries = [{
|
|
541
|
-
tryLoc: "root"
|
|
542
|
-
}];
|
|
543
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
544
|
-
this.reset(true);
|
|
545
|
-
}
|
|
546
|
-
exports.keys = function (object) {
|
|
547
|
-
var keys = [];
|
|
548
|
-
for (var key in object) {
|
|
549
|
-
keys.push(key);
|
|
550
|
-
}
|
|
551
|
-
keys.reverse();
|
|
552
|
-
|
|
553
|
-
// Rather than returning an object with a next method, we keep
|
|
554
|
-
// things simple and return the next function itself.
|
|
555
|
-
return function next() {
|
|
556
|
-
while (keys.length) {
|
|
557
|
-
var key = keys.pop();
|
|
558
|
-
if (key in object) {
|
|
559
|
-
next.value = key;
|
|
560
|
-
next.done = false;
|
|
561
|
-
return next;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// To avoid creating an additional object, we just hang the .value
|
|
566
|
-
// and .done properties off the next function object itself. This
|
|
567
|
-
// also ensures that the minifier will not anonymize the function.
|
|
568
|
-
next.done = true;
|
|
569
|
-
return next;
|
|
570
|
-
};
|
|
571
|
-
};
|
|
572
|
-
function values(iterable) {
|
|
573
|
-
if (iterable) {
|
|
574
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
575
|
-
if (iteratorMethod) {
|
|
576
|
-
return iteratorMethod.call(iterable);
|
|
577
|
-
}
|
|
578
|
-
if (typeof iterable.next === "function") {
|
|
579
|
-
return iterable;
|
|
580
|
-
}
|
|
581
|
-
if (!isNaN(iterable.length)) {
|
|
582
|
-
var i = -1,
|
|
583
|
-
next = function next() {
|
|
584
|
-
while (++i < iterable.length) {
|
|
585
|
-
if (hasOwn.call(iterable, i)) {
|
|
586
|
-
next.value = iterable[i];
|
|
587
|
-
next.done = false;
|
|
588
|
-
return next;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
next.value = undefined$1;
|
|
592
|
-
next.done = true;
|
|
593
|
-
return next;
|
|
594
|
-
};
|
|
595
|
-
return next.next = next;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// Return an iterator with no values.
|
|
600
|
-
return {
|
|
601
|
-
next: doneResult
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
exports.values = values;
|
|
605
|
-
function doneResult() {
|
|
606
|
-
return {
|
|
607
|
-
value: undefined$1,
|
|
608
|
-
done: true
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
Context.prototype = {
|
|
612
|
-
constructor: Context,
|
|
613
|
-
reset: function reset(skipTempReset) {
|
|
614
|
-
this.prev = 0;
|
|
615
|
-
this.next = 0;
|
|
616
|
-
// Resetting context._sent for legacy support of Babel's
|
|
617
|
-
// function.sent implementation.
|
|
618
|
-
this.sent = this._sent = undefined$1;
|
|
619
|
-
this.done = false;
|
|
620
|
-
this.delegate = null;
|
|
621
|
-
this.method = "next";
|
|
622
|
-
this.arg = undefined$1;
|
|
623
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
624
|
-
if (!skipTempReset) {
|
|
625
|
-
for (var name in this) {
|
|
626
|
-
// Not sure about the optimal order of these conditions:
|
|
627
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
628
|
-
this[name] = undefined$1;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
},
|
|
633
|
-
stop: function stop() {
|
|
634
|
-
this.done = true;
|
|
635
|
-
var rootEntry = this.tryEntries[0];
|
|
636
|
-
var rootRecord = rootEntry.completion;
|
|
637
|
-
if (rootRecord.type === "throw") {
|
|
638
|
-
throw rootRecord.arg;
|
|
639
|
-
}
|
|
640
|
-
return this.rval;
|
|
641
|
-
},
|
|
642
|
-
dispatchException: function dispatchException(exception) {
|
|
643
|
-
if (this.done) {
|
|
644
|
-
throw exception;
|
|
645
|
-
}
|
|
646
|
-
var context = this;
|
|
647
|
-
function handle(loc, caught) {
|
|
648
|
-
record.type = "throw";
|
|
649
|
-
record.arg = exception;
|
|
650
|
-
context.next = loc;
|
|
651
|
-
if (caught) {
|
|
652
|
-
// If the dispatched exception was caught by a catch block,
|
|
653
|
-
// then let that catch block handle the exception normally.
|
|
654
|
-
context.method = "next";
|
|
655
|
-
context.arg = undefined$1;
|
|
656
|
-
}
|
|
657
|
-
return !!caught;
|
|
658
|
-
}
|
|
659
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
660
|
-
var entry = this.tryEntries[i];
|
|
661
|
-
var record = entry.completion;
|
|
662
|
-
if (entry.tryLoc === "root") {
|
|
663
|
-
// Exception thrown outside of any try block that could handle
|
|
664
|
-
// it, so set the completion value of the entire function to
|
|
665
|
-
// throw the exception.
|
|
666
|
-
return handle("end");
|
|
667
|
-
}
|
|
668
|
-
if (entry.tryLoc <= this.prev) {
|
|
669
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
670
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
671
|
-
if (hasCatch && hasFinally) {
|
|
672
|
-
if (this.prev < entry.catchLoc) {
|
|
673
|
-
return handle(entry.catchLoc, true);
|
|
674
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
675
|
-
return handle(entry.finallyLoc);
|
|
676
|
-
}
|
|
677
|
-
} else if (hasCatch) {
|
|
678
|
-
if (this.prev < entry.catchLoc) {
|
|
679
|
-
return handle(entry.catchLoc, true);
|
|
680
|
-
}
|
|
681
|
-
} else if (hasFinally) {
|
|
682
|
-
if (this.prev < entry.finallyLoc) {
|
|
683
|
-
return handle(entry.finallyLoc);
|
|
684
|
-
}
|
|
685
|
-
} else {
|
|
686
|
-
throw new Error("try statement without catch or finally");
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
},
|
|
691
|
-
abrupt: function abrupt(type, arg) {
|
|
692
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
693
|
-
var entry = this.tryEntries[i];
|
|
694
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
695
|
-
var finallyEntry = entry;
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
700
|
-
// Ignore the finally entry if control is not jumping to a
|
|
701
|
-
// location outside the try/catch block.
|
|
702
|
-
finallyEntry = null;
|
|
703
|
-
}
|
|
704
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
705
|
-
record.type = type;
|
|
706
|
-
record.arg = arg;
|
|
707
|
-
if (finallyEntry) {
|
|
708
|
-
this.method = "next";
|
|
709
|
-
this.next = finallyEntry.finallyLoc;
|
|
710
|
-
return ContinueSentinel;
|
|
711
|
-
}
|
|
712
|
-
return this.complete(record);
|
|
713
|
-
},
|
|
714
|
-
complete: function complete(record, afterLoc) {
|
|
715
|
-
if (record.type === "throw") {
|
|
716
|
-
throw record.arg;
|
|
717
|
-
}
|
|
718
|
-
if (record.type === "break" || record.type === "continue") {
|
|
719
|
-
this.next = record.arg;
|
|
720
|
-
} else if (record.type === "return") {
|
|
721
|
-
this.rval = this.arg = record.arg;
|
|
722
|
-
this.method = "return";
|
|
723
|
-
this.next = "end";
|
|
724
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
725
|
-
this.next = afterLoc;
|
|
726
|
-
}
|
|
727
|
-
return ContinueSentinel;
|
|
728
|
-
},
|
|
729
|
-
finish: function finish(finallyLoc) {
|
|
730
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
731
|
-
var entry = this.tryEntries[i];
|
|
732
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
733
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
734
|
-
resetTryEntry(entry);
|
|
735
|
-
return ContinueSentinel;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
},
|
|
739
|
-
"catch": function _catch(tryLoc) {
|
|
740
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
741
|
-
var entry = this.tryEntries[i];
|
|
742
|
-
if (entry.tryLoc === tryLoc) {
|
|
743
|
-
var record = entry.completion;
|
|
744
|
-
if (record.type === "throw") {
|
|
745
|
-
var thrown = record.arg;
|
|
746
|
-
resetTryEntry(entry);
|
|
747
|
-
}
|
|
748
|
-
return thrown;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
// The context.catch method must only be called with a location
|
|
753
|
-
// argument that corresponds to a known catch block.
|
|
754
|
-
throw new Error("illegal catch attempt");
|
|
755
|
-
},
|
|
756
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
757
|
-
this.delegate = {
|
|
758
|
-
iterator: values(iterable),
|
|
759
|
-
resultName: resultName,
|
|
760
|
-
nextLoc: nextLoc
|
|
761
|
-
};
|
|
762
|
-
if (this.method === "next") {
|
|
763
|
-
// Deliberately forget the last sent value so that we don't
|
|
764
|
-
// accidentally pass it on to the delegate.
|
|
765
|
-
this.arg = undefined$1;
|
|
766
|
-
}
|
|
767
|
-
return ContinueSentinel;
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
772
|
-
// or not, return the runtime object so that we can declare the variable
|
|
773
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
774
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
775
|
-
return exports;
|
|
776
|
-
}(
|
|
777
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
778
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
779
|
-
// object. Either way, the resulting object will be used to initialize
|
|
780
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
781
|
-
module.exports );
|
|
782
|
-
try {
|
|
783
|
-
regeneratorRuntime = runtime;
|
|
784
|
-
} catch (accidentalStrictMode) {
|
|
785
|
-
// This module should not be running in strict mode, so the above
|
|
786
|
-
// assignment should always work unless something is misconfigured. Just
|
|
787
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
788
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
789
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
790
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
791
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
792
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
793
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
794
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
795
|
-
if (typeof globalThis === "object") {
|
|
796
|
-
globalThis.regeneratorRuntime = runtime;
|
|
797
|
-
} else {
|
|
798
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
|
|
803
445
|
function queryParamsToApi(params) {
|
|
804
446
|
return {
|
|
805
447
|
where: params.where,
|
|
806
448
|
limit: params.limit,
|
|
449
|
+
offset: params.offset,
|
|
807
450
|
order: params.orderBy ? [{
|
|
808
451
|
field: params.orderBy,
|
|
809
452
|
dir: params.desc ? "desc" : "asc"
|
|
@@ -820,133 +463,147 @@ var HttpError = /*#__PURE__*/function (_Error) {
|
|
|
820
463
|
}
|
|
821
464
|
return HttpError;
|
|
822
465
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
823
|
-
var API = /*#__PURE__*/function () {
|
|
466
|
+
var API = /*#__PURE__*/function (_get, _fetchTables, _query, _count) {
|
|
824
467
|
function API(config) {
|
|
825
468
|
this.config = config;
|
|
826
469
|
}
|
|
827
470
|
var _proto = API.prototype;
|
|
828
|
-
_proto.get =
|
|
829
|
-
|
|
471
|
+
_proto.get = function get(_x, _x2) {
|
|
472
|
+
return (_get = _get || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(endpoint, params) {
|
|
830
473
|
var url, response, message, _json$error, json;
|
|
831
|
-
return
|
|
832
|
-
while (1) {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
474
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
475
|
+
while (1) switch (_context.prev = _context.next) {
|
|
476
|
+
case 0:
|
|
477
|
+
if (params === void 0) {
|
|
478
|
+
params = {};
|
|
479
|
+
}
|
|
480
|
+
url = new URL(this.config.host + "/api/v1/cms/databases/" + this.config.databaseId + endpoint);
|
|
481
|
+
url.search = new URLSearchParams(params).toString();
|
|
482
|
+
_context.next = 5;
|
|
483
|
+
return fetch(url.toString(), {
|
|
484
|
+
method: "GET",
|
|
485
|
+
headers: {
|
|
486
|
+
accept: "*/*",
|
|
487
|
+
"x-plasmic-api-cms-tokens": this.config.databaseId + ":" + this.config.databaseToken
|
|
488
|
+
},
|
|
489
|
+
mode: "cors"
|
|
490
|
+
});
|
|
491
|
+
case 5:
|
|
492
|
+
response = _context.sent;
|
|
493
|
+
if (!(response.status !== 200)) {
|
|
494
|
+
_context.next = 12;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
_context.next = 9;
|
|
498
|
+
return response.text();
|
|
499
|
+
case 9:
|
|
500
|
+
message = _context.sent;
|
|
501
|
+
try {
|
|
502
|
+
json = JSON.parse(message);
|
|
503
|
+
if ((_json$error = json.error) != null && _json$error.message) {
|
|
504
|
+
message = json.error.message;
|
|
854
505
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
_context.next = 14;
|
|
868
|
-
return response.json();
|
|
869
|
-
case 14:
|
|
870
|
-
return _context.abrupt("return", _context.sent);
|
|
871
|
-
case 15:
|
|
872
|
-
case "end":
|
|
873
|
-
return _context.stop();
|
|
874
|
-
}
|
|
506
|
+
} catch (_unused) {
|
|
507
|
+
// ignored
|
|
508
|
+
}
|
|
509
|
+
throw new HttpError(response.status, message);
|
|
510
|
+
case 12:
|
|
511
|
+
_context.next = 14;
|
|
512
|
+
return response.json();
|
|
513
|
+
case 14:
|
|
514
|
+
return _context.abrupt("return", _context.sent);
|
|
515
|
+
case 15:
|
|
516
|
+
case "end":
|
|
517
|
+
return _context.stop();
|
|
875
518
|
}
|
|
876
519
|
}, _callee, this);
|
|
877
|
-
}));
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
return get;
|
|
882
|
-
}();
|
|
883
|
-
_proto.fetchTables = /*#__PURE__*/function () {
|
|
884
|
-
var _fetchTables = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
520
|
+
}))).apply(this, arguments);
|
|
521
|
+
};
|
|
522
|
+
_proto.fetchTables = function fetchTables() {
|
|
523
|
+
return (_fetchTables = _fetchTables || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
885
524
|
var response;
|
|
886
|
-
return
|
|
887
|
-
while (1) {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
return _context2.stop();
|
|
904
|
-
}
|
|
525
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
526
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
527
|
+
case 0:
|
|
528
|
+
_context2.prev = 0;
|
|
529
|
+
_context2.next = 3;
|
|
530
|
+
return this.get("");
|
|
531
|
+
case 3:
|
|
532
|
+
response = _context2.sent;
|
|
533
|
+
return _context2.abrupt("return", response.tables);
|
|
534
|
+
case 7:
|
|
535
|
+
_context2.prev = 7;
|
|
536
|
+
_context2.t0 = _context2["catch"](0);
|
|
537
|
+
console.error(_context2.t0);
|
|
538
|
+
throw _context2.t0;
|
|
539
|
+
case 11:
|
|
540
|
+
case "end":
|
|
541
|
+
return _context2.stop();
|
|
905
542
|
}
|
|
906
543
|
}, _callee2, this, [[0, 7]]);
|
|
907
|
-
}));
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
return fetchTables;
|
|
912
|
-
}();
|
|
913
|
-
_proto.query = /*#__PURE__*/function () {
|
|
914
|
-
var _query = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(table, params) {
|
|
544
|
+
}))).apply(this, arguments);
|
|
545
|
+
};
|
|
546
|
+
_proto.query = function query(_x3, _x4) {
|
|
547
|
+
return (_query = _query || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(table, params) {
|
|
915
548
|
var response;
|
|
916
|
-
return
|
|
917
|
-
while (1) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
return _context3.stop();
|
|
941
|
-
}
|
|
549
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
550
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
551
|
+
case 0:
|
|
552
|
+
if (params === void 0) {
|
|
553
|
+
params = {};
|
|
554
|
+
}
|
|
555
|
+
_context3.prev = 1;
|
|
556
|
+
_context3.next = 4;
|
|
557
|
+
return this.get("/tables/" + table + "/query", {
|
|
558
|
+
q: JSON.stringify(queryParamsToApi(params)),
|
|
559
|
+
draft: Number(params.useDraft),
|
|
560
|
+
locale: this.config.locale
|
|
561
|
+
});
|
|
562
|
+
case 4:
|
|
563
|
+
response = _context3.sent;
|
|
564
|
+
return _context3.abrupt("return", response.rows);
|
|
565
|
+
case 8:
|
|
566
|
+
_context3.prev = 8;
|
|
567
|
+
_context3.t0 = _context3["catch"](1);
|
|
568
|
+
console.error(_context3.t0);
|
|
569
|
+
throw _context3.t0;
|
|
570
|
+
case 12:
|
|
571
|
+
case "end":
|
|
572
|
+
return _context3.stop();
|
|
942
573
|
}
|
|
943
574
|
}, _callee3, this, [[1, 8]]);
|
|
944
|
-
}));
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
575
|
+
}))).apply(this, arguments);
|
|
576
|
+
};
|
|
577
|
+
_proto.count = function count(_x5, _x6) {
|
|
578
|
+
return (_count = _count || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(table, params) {
|
|
579
|
+
var response;
|
|
580
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
581
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
582
|
+
case 0:
|
|
583
|
+
if (params === void 0) {
|
|
584
|
+
params = {};
|
|
585
|
+
}
|
|
586
|
+
_context4.prev = 1;
|
|
587
|
+
_context4.next = 4;
|
|
588
|
+
return this.get("/tables/" + table + "/count", {
|
|
589
|
+
q: JSON.stringify(queryParamsToApi(params)),
|
|
590
|
+
draft: Number(params.useDraft)
|
|
591
|
+
});
|
|
592
|
+
case 4:
|
|
593
|
+
response = _context4.sent;
|
|
594
|
+
return _context4.abrupt("return", response.count);
|
|
595
|
+
case 8:
|
|
596
|
+
_context4.prev = 8;
|
|
597
|
+
_context4.t0 = _context4["catch"](1);
|
|
598
|
+
console.error(_context4.t0);
|
|
599
|
+
throw _context4.t0;
|
|
600
|
+
case 12:
|
|
601
|
+
case "end":
|
|
602
|
+
return _context4.stop();
|
|
603
|
+
}
|
|
604
|
+
}, _callee4, this, [[1, 8]]);
|
|
605
|
+
}))).apply(this, arguments);
|
|
606
|
+
};
|
|
950
607
|
return API;
|
|
951
608
|
}();
|
|
952
609
|
function mkApi(config) {
|
|
@@ -964,9 +621,17 @@ var mkQueryContextKey = function mkQueryContextKey(table) {
|
|
|
964
621
|
return "" + contextPrefix + capitalizeFirst(table) + collectionResultSuffix;
|
|
965
622
|
};
|
|
966
623
|
var itemContextSuffix = "Item";
|
|
624
|
+
var countContextSuffix = "Count";
|
|
625
|
+
var modeContextSuffix = "Mode";
|
|
967
626
|
var mkRowContextKey = function mkRowContextKey(table) {
|
|
968
627
|
return "" + contextPrefix + capitalizeFirst(table) + itemContextSuffix;
|
|
969
628
|
};
|
|
629
|
+
var mkCountContextKey = function mkCountContextKey(table) {
|
|
630
|
+
return "" + contextPrefix + capitalizeFirst(table) + countContextSuffix;
|
|
631
|
+
};
|
|
632
|
+
var mkModeContextKey = function mkModeContextKey(table) {
|
|
633
|
+
return "" + contextPrefix + capitalizeFirst(table) + modeContextSuffix;
|
|
634
|
+
};
|
|
970
635
|
function capitalizeFirst(str) {
|
|
971
636
|
var _str$;
|
|
972
637
|
return ((_str$ = str[0]) == null ? void 0 : _str$.toUpperCase()) + str.slice(1);
|
|
@@ -977,7 +642,7 @@ function useDatabase() {
|
|
|
977
642
|
function DatabaseProvider(_ref) {
|
|
978
643
|
var config = _ref.config,
|
|
979
644
|
children = _ref.children;
|
|
980
|
-
return
|
|
645
|
+
return React.createElement(host.DataProvider, {
|
|
981
646
|
name: databaseContextKey,
|
|
982
647
|
data: config,
|
|
983
648
|
hidden: true
|
|
@@ -989,15 +654,15 @@ function useTables() {
|
|
|
989
654
|
function TablesProvider(_ref2) {
|
|
990
655
|
var children = _ref2.children,
|
|
991
656
|
tables = _ref2.tables;
|
|
992
|
-
return
|
|
657
|
+
return React.createElement(host.DataProvider, {
|
|
993
658
|
name: tablesContextKey,
|
|
994
659
|
data: tables,
|
|
995
660
|
hidden: true
|
|
996
661
|
}, children);
|
|
997
662
|
}
|
|
998
|
-
function
|
|
999
|
-
return [].concat(Object.keys(env).reverse()).filter(function (
|
|
1000
|
-
return
|
|
663
|
+
function getClosestMatchingKeysBy(env, pred) {
|
|
664
|
+
return [].concat(Object.keys(env).reverse()).filter(function (key) {
|
|
665
|
+
return pred(key);
|
|
1001
666
|
});
|
|
1002
667
|
}
|
|
1003
668
|
function QueryResultProvider(_ref3) {
|
|
@@ -1005,13 +670,17 @@ function QueryResultProvider(_ref3) {
|
|
|
1005
670
|
table = _ref3.table,
|
|
1006
671
|
rows = _ref3.rows,
|
|
1007
672
|
hidden = _ref3.hidden;
|
|
1008
|
-
return
|
|
673
|
+
return React.createElement(host.DataProvider, {
|
|
674
|
+
name: table ? mkModeContextKey(table) : undefined,
|
|
675
|
+
data: "rows",
|
|
676
|
+
hidden: true
|
|
677
|
+
}, React.createElement(host.DataProvider, {
|
|
1009
678
|
name: table ? mkQueryContextKey(table) : undefined,
|
|
1010
679
|
data: rows,
|
|
1011
680
|
hidden: hidden
|
|
1012
|
-
}, children);
|
|
681
|
+
}, children));
|
|
1013
682
|
}
|
|
1014
|
-
function useTablesWithDataLoaded() {
|
|
683
|
+
function useTablesWithDataLoaded(mode) {
|
|
1015
684
|
var env = host.useDataEnv();
|
|
1016
685
|
var tables = useTables();
|
|
1017
686
|
if (!env) {
|
|
@@ -1020,21 +689,39 @@ function useTablesWithDataLoaded() {
|
|
|
1020
689
|
if (!tables) {
|
|
1021
690
|
return undefined;
|
|
1022
691
|
}
|
|
1023
|
-
var matchingKeys =
|
|
692
|
+
var matchingKeys = getClosestMatchingKeysBy(env, function (key) {
|
|
693
|
+
if (mode === "rows") {
|
|
694
|
+
return key.endsWith(itemContextSuffix);
|
|
695
|
+
} else if (mode === "count") {
|
|
696
|
+
return key.endsWith(countContextSuffix);
|
|
697
|
+
} else {
|
|
698
|
+
return key.endsWith(itemContextSuffix) || key.endsWith(countContextSuffix);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
1024
701
|
return tables.filter(function (table) {
|
|
1025
702
|
return matchingKeys.some(function (key) {
|
|
1026
|
-
|
|
703
|
+
if (mode === "rows") {
|
|
704
|
+
return mkRowContextKey(table.identifier) === key;
|
|
705
|
+
} else if (mode === "count") {
|
|
706
|
+
return mkCountContextKey(table.identifier) === key;
|
|
707
|
+
} else {
|
|
708
|
+
return mkRowContextKey(table.identifier) === key || mkCountContextKey(table.identifier) === key;
|
|
709
|
+
}
|
|
1027
710
|
});
|
|
1028
711
|
});
|
|
1029
712
|
}
|
|
713
|
+
function deriveTableId(tables, table) {
|
|
714
|
+
if (!table && tables && tables.length > 0) {
|
|
715
|
+
table = tables[0].identifier;
|
|
716
|
+
}
|
|
717
|
+
return table;
|
|
718
|
+
}
|
|
1030
719
|
function useRow(tables, table) {
|
|
1031
720
|
var env = host.useDataEnv();
|
|
1032
721
|
if (!env) {
|
|
1033
722
|
return undefined;
|
|
1034
723
|
}
|
|
1035
|
-
|
|
1036
|
-
table = tables[0].identifier;
|
|
1037
|
-
}
|
|
724
|
+
table = deriveTableId(tables, table);
|
|
1038
725
|
if (table) {
|
|
1039
726
|
return {
|
|
1040
727
|
table: table,
|
|
@@ -1043,15 +730,42 @@ function useRow(tables, table) {
|
|
|
1043
730
|
}
|
|
1044
731
|
return undefined;
|
|
1045
732
|
}
|
|
733
|
+
function useCount(tables, table) {
|
|
734
|
+
var env = host.useDataEnv();
|
|
735
|
+
if (!env) {
|
|
736
|
+
return undefined;
|
|
737
|
+
}
|
|
738
|
+
table = deriveTableId(tables, table);
|
|
739
|
+
if (table) {
|
|
740
|
+
return {
|
|
741
|
+
table: table,
|
|
742
|
+
count: env[mkCountContextKey(table)]
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
return undefined;
|
|
746
|
+
}
|
|
1046
747
|
function RowProvider(_ref4) {
|
|
1047
748
|
var children = _ref4.children,
|
|
1048
749
|
table = _ref4.table,
|
|
1049
750
|
row = _ref4.row;
|
|
1050
|
-
return
|
|
751
|
+
return React.createElement(host.DataProvider, {
|
|
1051
752
|
name: mkRowContextKey(table),
|
|
1052
753
|
data: row
|
|
1053
754
|
}, children);
|
|
1054
755
|
}
|
|
756
|
+
function CountProvider(_ref5) {
|
|
757
|
+
var children = _ref5.children,
|
|
758
|
+
table = _ref5.table,
|
|
759
|
+
count = _ref5.count;
|
|
760
|
+
return React.createElement(host.DataProvider, {
|
|
761
|
+
name: table ? mkModeContextKey(table) : undefined,
|
|
762
|
+
data: "count",
|
|
763
|
+
hidden: true
|
|
764
|
+
}, React.createElement(host.DataProvider, {
|
|
765
|
+
name: table ? mkCountContextKey(table) : undefined,
|
|
766
|
+
data: count
|
|
767
|
+
}, children));
|
|
768
|
+
}
|
|
1055
769
|
|
|
1056
770
|
function mkTableOptions(tables) {
|
|
1057
771
|
if (!tables) {
|
|
@@ -1098,27 +812,28 @@ function mkFieldOptions(tables, tableIdentifier, types) {
|
|
|
1098
812
|
}
|
|
1099
813
|
|
|
1100
814
|
var _excluded = ["className", "table", "field", "dateFormat", "setControlContextData"],
|
|
1101
|
-
_excluded2 = ["
|
|
815
|
+
_excluded2 = ["className", "table", "setControlContextData"],
|
|
816
|
+
_excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
|
|
1102
817
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1103
818
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1104
819
|
function renderMaybeData(maybeData, renderFn, loaderProps, inEditor, loadingMessage, forceLoadingState) {
|
|
1105
820
|
if ("error" in maybeData) {
|
|
1106
821
|
var error = maybeData.error;
|
|
1107
822
|
if (!inEditor) {
|
|
1108
|
-
return
|
|
823
|
+
return React.createElement(React.Fragment, null, loadingMessage != null ? loadingMessage : React.createElement("div", null, "Loading..."));
|
|
1109
824
|
}
|
|
1110
825
|
if (error && error instanceof HttpError && error.status === 404) {
|
|
1111
826
|
if (loaderProps.hideIfNotFound) {
|
|
1112
827
|
return null;
|
|
1113
828
|
} else {
|
|
1114
|
-
return
|
|
829
|
+
return React.createElement("div", null, "Error: Data not found");
|
|
1115
830
|
}
|
|
1116
831
|
} else {
|
|
1117
|
-
return
|
|
832
|
+
return React.createElement("div", null, "Error: ", error == null ? void 0 : error.message);
|
|
1118
833
|
}
|
|
1119
834
|
}
|
|
1120
835
|
if (!("data" in maybeData) || forceLoadingState) {
|
|
1121
|
-
return
|
|
836
|
+
return React.createElement(React.Fragment, null, loadingMessage != null ? loadingMessage : React.createElement("div", null, "Loading..."));
|
|
1122
837
|
}
|
|
1123
838
|
return renderFn(maybeData.data);
|
|
1124
839
|
}
|
|
@@ -1168,9 +883,9 @@ function CmsCredentialsProvider(_ref) {
|
|
|
1168
883
|
locale: locale,
|
|
1169
884
|
host: host || defaultHost
|
|
1170
885
|
};
|
|
1171
|
-
return
|
|
886
|
+
return React.createElement(DatabaseProvider, {
|
|
1172
887
|
config: config
|
|
1173
|
-
},
|
|
888
|
+
}, React.createElement(TablesFetcher, null, children));
|
|
1174
889
|
}
|
|
1175
890
|
function TablesFetcher(_ref2) {
|
|
1176
891
|
var children = _ref2.children;
|
|
@@ -1179,32 +894,30 @@ function TablesFetcher(_ref2) {
|
|
|
1179
894
|
component: "TablesFetcher",
|
|
1180
895
|
databaseConfig: databaseConfig
|
|
1181
896
|
});
|
|
1182
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
1183
|
-
return
|
|
1184
|
-
while (1) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
return _context.stop();
|
|
1200
|
-
}
|
|
897
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
898
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
899
|
+
while (1) switch (_context.prev = _context.next) {
|
|
900
|
+
case 0:
|
|
901
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
902
|
+
_context.next = 2;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
return _context.abrupt("return", []);
|
|
906
|
+
case 2:
|
|
907
|
+
_context.next = 4;
|
|
908
|
+
return mkApi(databaseConfig).fetchTables();
|
|
909
|
+
case 4:
|
|
910
|
+
return _context.abrupt("return", _context.sent);
|
|
911
|
+
case 5:
|
|
912
|
+
case "end":
|
|
913
|
+
return _context.stop();
|
|
1201
914
|
}
|
|
1202
915
|
}, _callee);
|
|
1203
916
|
})));
|
|
1204
|
-
var inEditor = !!
|
|
1205
|
-
return
|
|
917
|
+
var inEditor = !!host.usePlasmicCanvasContext();
|
|
918
|
+
return React.createElement(TablesProvider, {
|
|
1206
919
|
tables: maybeData.data
|
|
1207
|
-
}, inEditor && maybeData.error ?
|
|
920
|
+
}, inEditor && maybeData.error ? React.createElement("div", null, "CMS Error: ", maybeData.error.message) : children);
|
|
1208
921
|
}
|
|
1209
922
|
function isDatabaseConfigured(config) {
|
|
1210
923
|
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
@@ -1254,6 +967,17 @@ var cmsQueryRepeaterMeta = {
|
|
|
1254
967
|
return true;
|
|
1255
968
|
}
|
|
1256
969
|
},
|
|
970
|
+
mode: {
|
|
971
|
+
type: "choice",
|
|
972
|
+
options: [{
|
|
973
|
+
label: "Rows",
|
|
974
|
+
value: "rows"
|
|
975
|
+
}, {
|
|
976
|
+
label: "Count",
|
|
977
|
+
value: "count"
|
|
978
|
+
}],
|
|
979
|
+
defaultValueHint: "rows"
|
|
980
|
+
},
|
|
1257
981
|
where: {
|
|
1258
982
|
type: "object",
|
|
1259
983
|
displayName: "Filter",
|
|
@@ -1283,19 +1007,36 @@ var cmsQueryRepeaterMeta = {
|
|
|
1283
1007
|
description: "Field to order by.",
|
|
1284
1008
|
options: function options(_, ctx) {
|
|
1285
1009
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table, ["number", "boolean", "date-time", "long-text", "text"]);
|
|
1010
|
+
},
|
|
1011
|
+
hidden: function hidden(ps) {
|
|
1012
|
+
return ps.mode === "count";
|
|
1286
1013
|
}
|
|
1287
1014
|
},
|
|
1288
1015
|
desc: {
|
|
1289
1016
|
type: "boolean",
|
|
1290
1017
|
displayName: "Sort descending?",
|
|
1291
1018
|
description: 'Sort descending by "Order by" field.',
|
|
1292
|
-
defaultValue: false
|
|
1019
|
+
defaultValue: false,
|
|
1020
|
+
hidden: function hidden(ps) {
|
|
1021
|
+
return ps.mode === "count";
|
|
1022
|
+
}
|
|
1293
1023
|
},
|
|
1294
1024
|
limit: {
|
|
1295
1025
|
type: "number",
|
|
1296
1026
|
displayName: "Limit",
|
|
1297
1027
|
description: "Maximum number of entries to fetch (0 for unlimited).",
|
|
1298
|
-
defaultValue: 0
|
|
1028
|
+
defaultValue: 0,
|
|
1029
|
+
hidden: function hidden(ps) {
|
|
1030
|
+
return ps.mode === "count";
|
|
1031
|
+
}
|
|
1032
|
+
},
|
|
1033
|
+
offset: {
|
|
1034
|
+
type: "number",
|
|
1035
|
+
displayName: "Offset",
|
|
1036
|
+
description: "Skips this number of rows in the result set; used in combination with limit to build pagination",
|
|
1037
|
+
hidden: function hidden(ps) {
|
|
1038
|
+
return ps.mode === "count";
|
|
1039
|
+
}
|
|
1299
1040
|
},
|
|
1300
1041
|
emptyMessage: {
|
|
1301
1042
|
type: "slot",
|
|
@@ -1333,7 +1074,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1333
1074
|
type: "boolean",
|
|
1334
1075
|
displayName: "No auto-repeat",
|
|
1335
1076
|
description: "Do not automatically repeat children for every entry.",
|
|
1336
|
-
defaultValue: false
|
|
1077
|
+
defaultValue: false,
|
|
1078
|
+
hidden: function hidden(ps) {
|
|
1079
|
+
return ps.mode === "count";
|
|
1080
|
+
}
|
|
1337
1081
|
}
|
|
1338
1082
|
}
|
|
1339
1083
|
};
|
|
@@ -1341,11 +1085,13 @@ function CmsQueryRepeater(_ref5) {
|
|
|
1341
1085
|
var table = _ref5.table,
|
|
1342
1086
|
children = _ref5.children,
|
|
1343
1087
|
setControlContextData = _ref5.setControlContextData,
|
|
1088
|
+
mode = _ref5.mode,
|
|
1344
1089
|
where = _ref5.where,
|
|
1345
1090
|
useDraft = _ref5.useDraft,
|
|
1346
1091
|
orderBy = _ref5.orderBy,
|
|
1347
1092
|
desc = _ref5.desc,
|
|
1348
1093
|
limit = _ref5.limit,
|
|
1094
|
+
offset = _ref5.offset,
|
|
1349
1095
|
emptyMessage = _ref5.emptyMessage,
|
|
1350
1096
|
forceEmptyState = _ref5.forceEmptyState,
|
|
1351
1097
|
loadingMessage = _ref5.loadingMessage,
|
|
@@ -1366,78 +1112,96 @@ function CmsQueryRepeater(_ref5) {
|
|
|
1366
1112
|
useDraft: useDraft,
|
|
1367
1113
|
orderBy: orderBy,
|
|
1368
1114
|
desc: desc,
|
|
1369
|
-
limit: limit
|
|
1115
|
+
limit: limit,
|
|
1116
|
+
offset: offset
|
|
1370
1117
|
};
|
|
1371
1118
|
if (!table && tables && tables.length > 0) {
|
|
1372
1119
|
table = tables[0].identifier;
|
|
1373
1120
|
}
|
|
1374
1121
|
var cacheKey = JSON.stringify({
|
|
1375
1122
|
component: "CmsQueryLoader",
|
|
1123
|
+
mode: mode,
|
|
1376
1124
|
table: table,
|
|
1377
1125
|
databaseConfig: databaseConfig,
|
|
1378
1126
|
params: params
|
|
1379
1127
|
});
|
|
1380
1128
|
if (tables) {
|
|
1381
1129
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1382
|
-
setControlContextData == null
|
|
1130
|
+
setControlContextData == null || setControlContextData({
|
|
1383
1131
|
tables: tables,
|
|
1384
1132
|
table: table
|
|
1385
1133
|
});
|
|
1386
1134
|
}
|
|
1387
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
1388
|
-
return
|
|
1389
|
-
while (1) {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1135
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1136
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1137
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1138
|
+
case 0:
|
|
1139
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1140
|
+
_context2.next = 2;
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
throw new Error("You must specify a CMS ID and API key");
|
|
1144
|
+
case 2:
|
|
1145
|
+
if (table) {
|
|
1146
|
+
_context2.next = 6;
|
|
1147
|
+
break;
|
|
1148
|
+
}
|
|
1149
|
+
throw new Error("You must select a model to query");
|
|
1150
|
+
case 6:
|
|
1151
|
+
if (!(tables && !tables.find(function (t) {
|
|
1152
|
+
return t.identifier === table;
|
|
1153
|
+
}))) {
|
|
1154
|
+
_context2.next = 10;
|
|
1155
|
+
break;
|
|
1156
|
+
}
|
|
1157
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1158
|
+
case 10:
|
|
1159
|
+
if (!(mode === "count")) {
|
|
1160
|
+
_context2.next = 14;
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
return _context2.abrupt("return", mkApi(databaseConfig).count(table, params));
|
|
1164
|
+
case 14:
|
|
1165
|
+
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1166
|
+
case 15:
|
|
1167
|
+
case "end":
|
|
1168
|
+
return _context2.stop();
|
|
1417
1169
|
}
|
|
1418
1170
|
}, _callee2);
|
|
1419
1171
|
})));
|
|
1420
|
-
var inEditor = !!
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
return
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1172
|
+
var inEditor = !!host.usePlasmicCanvasContext();
|
|
1173
|
+
if (mode === "count") {
|
|
1174
|
+
var node = renderMaybeData(maybeData, function () {
|
|
1175
|
+
return children;
|
|
1176
|
+
}, {
|
|
1177
|
+
hideIfNotFound: false
|
|
1178
|
+
}, inEditor, loadingMessage, forceLoadingState);
|
|
1179
|
+
return React.createElement(CountProvider, {
|
|
1180
|
+
table: table,
|
|
1181
|
+
count: typeof (maybeData == null ? void 0 : maybeData.data) === "number" ? maybeData.data : undefined
|
|
1182
|
+
}, node);
|
|
1183
|
+
} else {
|
|
1184
|
+
var _node = renderMaybeData(maybeData, function (rows) {
|
|
1185
|
+
if (rows.length === 0 || forceEmptyState) {
|
|
1186
|
+
return emptyMessage;
|
|
1187
|
+
}
|
|
1188
|
+
return noAutoRepeat ? children : rows.map(function (row, index) {
|
|
1189
|
+
return React.createElement(RowProvider, {
|
|
1190
|
+
key: index,
|
|
1191
|
+
table: table,
|
|
1192
|
+
row: row
|
|
1193
|
+
}, host.repeatedElement(index, children));
|
|
1194
|
+
});
|
|
1195
|
+
}, {
|
|
1196
|
+
hideIfNotFound: false
|
|
1197
|
+
}, inEditor, loadingMessage, forceLoadingState);
|
|
1198
|
+
return React.createElement(QueryResultProvider, {
|
|
1199
|
+
rows: Array.isArray(maybeData == null ? void 0 : maybeData.data) ? maybeData.data : undefined,
|
|
1200
|
+
table: table
|
|
1201
|
+
}, noLayout ? React.createElement(React.Fragment, null, " ", _node, " ") : React.createElement("div", {
|
|
1202
|
+
className: className
|
|
1203
|
+
}, " ", _node, " "));
|
|
1204
|
+
}
|
|
1441
1205
|
}
|
|
1442
1206
|
var cmsRowFieldMeta = {
|
|
1443
1207
|
name: componentPrefix + "-row-field",
|
|
@@ -1450,7 +1214,7 @@ var cmsRowFieldMeta = {
|
|
|
1450
1214
|
displayName: "Model",
|
|
1451
1215
|
hidden: function hidden(props, ctx) {
|
|
1452
1216
|
var _ctx$tables$length, _ctx$tables;
|
|
1453
|
-
return ((_ctx$tables$length = ctx == null
|
|
1217
|
+
return ((_ctx$tables$length = ctx == null || (_ctx$tables = ctx.tables) == null ? void 0 : _ctx$tables.length) != null ? _ctx$tables$length : 0) <= 1 && !props.table;
|
|
1454
1218
|
},
|
|
1455
1219
|
helpText: "Pick model from a CMS Data Fetcher",
|
|
1456
1220
|
description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
|
|
@@ -1472,7 +1236,7 @@ var cmsRowFieldMeta = {
|
|
|
1472
1236
|
},
|
|
1473
1237
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1474
1238
|
var _ctx$fieldMeta, _ctx$fieldMeta2;
|
|
1475
|
-
return (ctx == null
|
|
1239
|
+
return (ctx == null || (_ctx$fieldMeta = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta.name) || (ctx == null || (_ctx$fieldMeta2 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta2.identifier);
|
|
1476
1240
|
}
|
|
1477
1241
|
},
|
|
1478
1242
|
dateFormat: {
|
|
@@ -1553,9 +1317,9 @@ function CmsRowField(_ref9) {
|
|
|
1553
1317
|
dateFormat = _ref9.dateFormat,
|
|
1554
1318
|
setControlContextData = _ref9.setControlContextData,
|
|
1555
1319
|
rest = _objectWithoutPropertiesLoose(_ref9, _excluded);
|
|
1556
|
-
var tables = useTablesWithDataLoaded();
|
|
1320
|
+
var tables = useTablesWithDataLoaded("rows");
|
|
1557
1321
|
var res = useRow(tables, table);
|
|
1558
|
-
var unknown =
|
|
1322
|
+
var unknown = React.createElement("div", Object.assign({
|
|
1559
1323
|
className: className
|
|
1560
1324
|
}, rest), "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1561
1325
|
var fieldMeta = res ? deriveInferredTableField({
|
|
@@ -1566,7 +1330,7 @@ function CmsRowField(_ref9) {
|
|
|
1566
1330
|
}) : undefined;
|
|
1567
1331
|
if (tables) {
|
|
1568
1332
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1569
|
-
setControlContextData == null
|
|
1333
|
+
setControlContextData == null || setControlContextData(_extends({
|
|
1570
1334
|
tables: tables
|
|
1571
1335
|
}, res && res.row ? {
|
|
1572
1336
|
table: res.table,
|
|
@@ -1578,7 +1342,7 @@ function CmsRowField(_ref9) {
|
|
|
1578
1342
|
return unknown;
|
|
1579
1343
|
}
|
|
1580
1344
|
if (!res.row) {
|
|
1581
|
-
return
|
|
1345
|
+
return React.createElement("div", {
|
|
1582
1346
|
className: className
|
|
1583
1347
|
}, "Error: No CMS Entry found");
|
|
1584
1348
|
}
|
|
@@ -1596,6 +1360,50 @@ function CmsRowField(_ref9) {
|
|
|
1596
1360
|
className: className
|
|
1597
1361
|
}, rest)) : null;
|
|
1598
1362
|
}
|
|
1363
|
+
var cmsCountFieldMeta = {
|
|
1364
|
+
name: componentPrefix + "-count",
|
|
1365
|
+
displayName: "CMS Entries Count",
|
|
1366
|
+
importName: "CmsCount",
|
|
1367
|
+
importPath: modulePath,
|
|
1368
|
+
props: {
|
|
1369
|
+
table: {
|
|
1370
|
+
type: "choice",
|
|
1371
|
+
displayName: "Model",
|
|
1372
|
+
hidden: function hidden(props, ctx) {
|
|
1373
|
+
var _ctx$tables$length2, _ctx$tables2;
|
|
1374
|
+
return ((_ctx$tables$length2 = ctx == null || (_ctx$tables2 = ctx.tables) == null ? void 0 : _ctx$tables2.length) != null ? _ctx$tables$length2 : 0) <= 1 && !props.table;
|
|
1375
|
+
},
|
|
1376
|
+
helpText: "Pick model from a CMS Data Fetcher",
|
|
1377
|
+
description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
|
|
1378
|
+
options: function options(_, ctx) {
|
|
1379
|
+
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1380
|
+
},
|
|
1381
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1382
|
+
return ctx == null ? void 0 : ctx.table;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
function CmsCount(_ref10) {
|
|
1388
|
+
var className = _ref10.className,
|
|
1389
|
+
table = _ref10.table,
|
|
1390
|
+
rest = _objectWithoutPropertiesLoose(_ref10, _excluded2);
|
|
1391
|
+
var tables = useTablesWithDataLoaded("count");
|
|
1392
|
+
var res = useCount(tables, table);
|
|
1393
|
+
var unknown = React.createElement("div", Object.assign({
|
|
1394
|
+
className: className
|
|
1395
|
+
}, rest), "Count: ", table != null ? table : "Unknown Model");
|
|
1396
|
+
if (!res) {
|
|
1397
|
+
return unknown;
|
|
1398
|
+
}
|
|
1399
|
+
if (res.count == null) {
|
|
1400
|
+
return null;
|
|
1401
|
+
} else {
|
|
1402
|
+
return React.createElement("div", Object.assign({
|
|
1403
|
+
className: className
|
|
1404
|
+
}, rest), new Intl.NumberFormat().format(res.count));
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1599
1407
|
var DEFAULT_TYPE_FILTERS = ["text"];
|
|
1600
1408
|
function deriveInferredTableField(opts) {
|
|
1601
1409
|
var _tables$find;
|
|
@@ -1604,7 +1412,7 @@ function deriveInferredTableField(opts) {
|
|
|
1604
1412
|
field = opts.field,
|
|
1605
1413
|
typeFilters = opts.typeFilters;
|
|
1606
1414
|
if (!table) return undefined;
|
|
1607
|
-
var schema = tables == null
|
|
1415
|
+
var schema = tables == null || (_tables$find = tables.find(function (t) {
|
|
1608
1416
|
return t.identifier === table;
|
|
1609
1417
|
})) == null ? void 0 : _tables$find.schema;
|
|
1610
1418
|
var fieldMeta = field ? schema == null ? void 0 : schema.fields.find(function (f) {
|
|
@@ -1625,9 +1433,9 @@ function renderValue(value, type, props) {
|
|
|
1625
1433
|
case "long-text":
|
|
1626
1434
|
case "date-time":
|
|
1627
1435
|
case "ref":
|
|
1628
|
-
return
|
|
1436
|
+
return React.createElement("div", Object.assign({}, props), value);
|
|
1629
1437
|
case "rich-text":
|
|
1630
|
-
return
|
|
1438
|
+
return React.createElement("div", Object.assign({
|
|
1631
1439
|
dangerouslySetInnerHTML: {
|
|
1632
1440
|
__html: value
|
|
1633
1441
|
},
|
|
@@ -1637,7 +1445,7 @@ function renderValue(value, type, props) {
|
|
|
1637
1445
|
}, props));
|
|
1638
1446
|
case "image":
|
|
1639
1447
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
1640
|
-
return
|
|
1448
|
+
return React.createElement("img", Object.assign({
|
|
1641
1449
|
src: value.url,
|
|
1642
1450
|
width: value.imageMeta.width,
|
|
1643
1451
|
height: value.imageMeta.height
|
|
@@ -1646,7 +1454,7 @@ function renderValue(value, type, props) {
|
|
|
1646
1454
|
return null;
|
|
1647
1455
|
case "file":
|
|
1648
1456
|
if (value && typeof value === "object" && value.url && value.name) {
|
|
1649
|
-
return
|
|
1457
|
+
return React.createElement("a", Object.assign({
|
|
1650
1458
|
href: value.url,
|
|
1651
1459
|
target: "_blank"
|
|
1652
1460
|
}, props), value.name);
|
|
@@ -1674,8 +1482,8 @@ var cmsRowLinkMeta = {
|
|
|
1674
1482
|
type: "choice",
|
|
1675
1483
|
displayName: "Model",
|
|
1676
1484
|
hidden: function hidden(props, ctx) {
|
|
1677
|
-
var _ctx$tables$
|
|
1678
|
-
return ((_ctx$tables$
|
|
1485
|
+
var _ctx$tables$length3, _ctx$tables3;
|
|
1486
|
+
return ((_ctx$tables$length3 = ctx == null || (_ctx$tables3 = ctx.tables) == null ? void 0 : _ctx$tables3.length) != null ? _ctx$tables$length3 : 0) <= 1 && !props.table;
|
|
1679
1487
|
},
|
|
1680
1488
|
helpText: "Pick model from a CMS Data Fetcher",
|
|
1681
1489
|
description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
|
|
@@ -1690,14 +1498,14 @@ var cmsRowLinkMeta = {
|
|
|
1690
1498
|
type: "choice",
|
|
1691
1499
|
displayName: "Field",
|
|
1692
1500
|
description: "Field (from model schema) to use.",
|
|
1693
|
-
options: function options(
|
|
1501
|
+
options: function options(_ref11, ctx) {
|
|
1694
1502
|
var _ctx$table3;
|
|
1695
|
-
var table =
|
|
1503
|
+
var table = _ref11.table;
|
|
1696
1504
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table);
|
|
1697
1505
|
},
|
|
1698
1506
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1699
1507
|
var _ctx$fieldMeta3, _ctx$fieldMeta4;
|
|
1700
|
-
return (ctx == null
|
|
1508
|
+
return (ctx == null || (_ctx$fieldMeta3 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta3.name) || (ctx == null || (_ctx$fieldMeta4 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta4.identifier);
|
|
1701
1509
|
}
|
|
1702
1510
|
},
|
|
1703
1511
|
hrefProp: {
|
|
@@ -1712,7 +1520,7 @@ var cmsRowLinkMeta = {
|
|
|
1712
1520
|
description: "Prefix to prepend to prop value.",
|
|
1713
1521
|
hidden: function hidden(_, ctx) {
|
|
1714
1522
|
var _ctx$fieldMeta5;
|
|
1715
|
-
return (ctx == null
|
|
1523
|
+
return (ctx == null || (_ctx$fieldMeta5 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta5.type) === "file";
|
|
1716
1524
|
}
|
|
1717
1525
|
},
|
|
1718
1526
|
suffix: {
|
|
@@ -1721,24 +1529,24 @@ var cmsRowLinkMeta = {
|
|
|
1721
1529
|
description: "Suffix to append to prop value.",
|
|
1722
1530
|
hidden: function hidden(_, ctx) {
|
|
1723
1531
|
var _ctx$fieldMeta6;
|
|
1724
|
-
return (ctx == null
|
|
1532
|
+
return (ctx == null || (_ctx$fieldMeta6 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta6.type) === "file";
|
|
1725
1533
|
}
|
|
1726
1534
|
}
|
|
1727
1535
|
}
|
|
1728
1536
|
};
|
|
1729
|
-
function CmsRowLink(
|
|
1537
|
+
function CmsRowLink(_ref12) {
|
|
1730
1538
|
var _res$row$data2;
|
|
1731
|
-
var table =
|
|
1732
|
-
field =
|
|
1733
|
-
hrefProp =
|
|
1734
|
-
children =
|
|
1735
|
-
setControlContextData =
|
|
1736
|
-
prefix =
|
|
1737
|
-
suffix =
|
|
1738
|
-
var tables = useTablesWithDataLoaded();
|
|
1539
|
+
var table = _ref12.table,
|
|
1540
|
+
field = _ref12.field,
|
|
1541
|
+
hrefProp = _ref12.hrefProp,
|
|
1542
|
+
children = _ref12.children,
|
|
1543
|
+
setControlContextData = _ref12.setControlContextData,
|
|
1544
|
+
prefix = _ref12.prefix,
|
|
1545
|
+
suffix = _ref12.suffix;
|
|
1546
|
+
var tables = useTablesWithDataLoaded("rows");
|
|
1739
1547
|
var res = useRow(tables, table);
|
|
1740
1548
|
if (!res || !res.row) {
|
|
1741
|
-
return
|
|
1549
|
+
return React.createElement(React.Fragment, null, children);
|
|
1742
1550
|
}
|
|
1743
1551
|
var fieldMeta = deriveInferredTableField({
|
|
1744
1552
|
table: res.table,
|
|
@@ -1748,7 +1556,7 @@ function CmsRowLink(_ref11) {
|
|
|
1748
1556
|
});
|
|
1749
1557
|
if (tables) {
|
|
1750
1558
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1751
|
-
setControlContextData == null
|
|
1559
|
+
setControlContextData == null || setControlContextData({
|
|
1752
1560
|
tables: tables,
|
|
1753
1561
|
table: res.table,
|
|
1754
1562
|
row: res.row,
|
|
@@ -1756,20 +1564,20 @@ function CmsRowLink(_ref11) {
|
|
|
1756
1564
|
});
|
|
1757
1565
|
}
|
|
1758
1566
|
if (!fieldMeta) {
|
|
1759
|
-
return
|
|
1567
|
+
return React.createElement(React.Fragment, null, children);
|
|
1760
1568
|
}
|
|
1761
1569
|
if (!children) {
|
|
1762
1570
|
return null;
|
|
1763
1571
|
}
|
|
1764
1572
|
var value = ((_res$row$data2 = res.row.data) == null ? void 0 : _res$row$data2[fieldMeta.identifier]) || "";
|
|
1765
|
-
var childrenWithProps =
|
|
1766
|
-
if (
|
|
1573
|
+
var childrenWithProps = React.Children.map(children, function (child) {
|
|
1574
|
+
if (React.isValidElement(child)) {
|
|
1767
1575
|
var _React$cloneElement;
|
|
1768
|
-
return
|
|
1576
|
+
return React.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
|
|
1769
1577
|
}
|
|
1770
1578
|
return child;
|
|
1771
1579
|
});
|
|
1772
|
-
return
|
|
1580
|
+
return React.createElement(React.Fragment, null, childrenWithProps != null ? childrenWithProps : null);
|
|
1773
1581
|
}
|
|
1774
1582
|
var cmsRowImageMeta = {
|
|
1775
1583
|
name: componentPrefix + "-row-image",
|
|
@@ -1788,8 +1596,8 @@ var cmsRowImageMeta = {
|
|
|
1788
1596
|
type: "choice",
|
|
1789
1597
|
displayName: "Model",
|
|
1790
1598
|
hidden: function hidden(props, ctx) {
|
|
1791
|
-
var _ctx$tables$
|
|
1792
|
-
return ((_ctx$tables$
|
|
1599
|
+
var _ctx$tables$length4, _ctx$tables4;
|
|
1600
|
+
return ((_ctx$tables$length4 = ctx == null || (_ctx$tables4 = ctx.tables) == null ? void 0 : _ctx$tables4.length) != null ? _ctx$tables$length4 : 0) <= 1 && !props.table;
|
|
1793
1601
|
},
|
|
1794
1602
|
helpText: "Pick model from a CMS Data Fetcher",
|
|
1795
1603
|
description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
|
|
@@ -1804,14 +1612,14 @@ var cmsRowImageMeta = {
|
|
|
1804
1612
|
type: "choice",
|
|
1805
1613
|
displayName: "Field",
|
|
1806
1614
|
description: "Field (from model schema) to use.",
|
|
1807
|
-
options: function options(
|
|
1615
|
+
options: function options(_ref13, ctx) {
|
|
1808
1616
|
var _ctx$table4;
|
|
1809
|
-
var table =
|
|
1617
|
+
var table = _ref13.table;
|
|
1810
1618
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table, ["image"]);
|
|
1811
1619
|
},
|
|
1812
1620
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1813
1621
|
var _ctx$fieldMeta7, _ctx$fieldMeta8;
|
|
1814
|
-
return (ctx == null
|
|
1622
|
+
return (ctx == null || (_ctx$fieldMeta7 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta7.name) || (ctx == null || (_ctx$fieldMeta8 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta8.identifier);
|
|
1815
1623
|
}
|
|
1816
1624
|
},
|
|
1817
1625
|
srcProp: {
|
|
@@ -1822,17 +1630,17 @@ var cmsRowImageMeta = {
|
|
|
1822
1630
|
}
|
|
1823
1631
|
}
|
|
1824
1632
|
};
|
|
1825
|
-
function CmsRowImage(
|
|
1633
|
+
function CmsRowImage(_ref14) {
|
|
1826
1634
|
var _res$row$data3;
|
|
1827
|
-
var table =
|
|
1828
|
-
field =
|
|
1829
|
-
srcProp =
|
|
1830
|
-
children =
|
|
1831
|
-
setControlContextData =
|
|
1832
|
-
var tables = useTablesWithDataLoaded();
|
|
1635
|
+
var table = _ref14.table,
|
|
1636
|
+
field = _ref14.field,
|
|
1637
|
+
srcProp = _ref14.srcProp,
|
|
1638
|
+
children = _ref14.children,
|
|
1639
|
+
setControlContextData = _ref14.setControlContextData;
|
|
1640
|
+
var tables = useTablesWithDataLoaded("rows");
|
|
1833
1641
|
var res = useRow(tables, table);
|
|
1834
1642
|
if (!res || !res.row) {
|
|
1835
|
-
return
|
|
1643
|
+
return React.createElement(React.Fragment, null, children);
|
|
1836
1644
|
}
|
|
1837
1645
|
var fieldMeta = deriveInferredTableField({
|
|
1838
1646
|
table: res.table,
|
|
@@ -1842,7 +1650,7 @@ function CmsRowImage(_ref13) {
|
|
|
1842
1650
|
});
|
|
1843
1651
|
if (tables) {
|
|
1844
1652
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1845
|
-
setControlContextData == null
|
|
1653
|
+
setControlContextData == null || setControlContextData({
|
|
1846
1654
|
tables: tables,
|
|
1847
1655
|
table: res.table,
|
|
1848
1656
|
row: res.row,
|
|
@@ -1850,25 +1658,25 @@ function CmsRowImage(_ref13) {
|
|
|
1850
1658
|
});
|
|
1851
1659
|
}
|
|
1852
1660
|
if (!fieldMeta) {
|
|
1853
|
-
return
|
|
1661
|
+
return React.createElement(React.Fragment, null, children);
|
|
1854
1662
|
}
|
|
1855
1663
|
var value = ((_res$row$data3 = res.row.data) == null ? void 0 : _res$row$data3[fieldMeta.identifier]) || "";
|
|
1856
|
-
var childrenWithProps =
|
|
1857
|
-
if (
|
|
1664
|
+
var childrenWithProps = React.Children.map(children, function (child) {
|
|
1665
|
+
if (React.isValidElement(child) && value) {
|
|
1858
1666
|
var _React$cloneElement3;
|
|
1859
1667
|
if (typeof value === "object" && value.url && value.imageMeta) {
|
|
1860
1668
|
var _React$cloneElement2;
|
|
1861
|
-
return
|
|
1669
|
+
return React.cloneElement(child, (_React$cloneElement2 = {}, _React$cloneElement2[srcProp] = {
|
|
1862
1670
|
src: value.url,
|
|
1863
1671
|
fullHeight: value.imageMeta.height,
|
|
1864
1672
|
fullWidth: value.imageMeta.width
|
|
1865
1673
|
}, _React$cloneElement2));
|
|
1866
1674
|
}
|
|
1867
|
-
return
|
|
1675
|
+
return React.cloneElement(child, (_React$cloneElement3 = {}, _React$cloneElement3[srcProp] = value, _React$cloneElement3));
|
|
1868
1676
|
}
|
|
1869
1677
|
return child;
|
|
1870
1678
|
});
|
|
1871
|
-
return
|
|
1679
|
+
return React.createElement(React.Fragment, null, childrenWithProps);
|
|
1872
1680
|
}
|
|
1873
1681
|
var cmsRowFieldValueMeta = {
|
|
1874
1682
|
name: componentPrefix + "-row-value",
|
|
@@ -1883,8 +1691,8 @@ var cmsRowFieldValueMeta = {
|
|
|
1883
1691
|
type: "choice",
|
|
1884
1692
|
displayName: "Model",
|
|
1885
1693
|
hidden: function hidden(props, ctx) {
|
|
1886
|
-
var _ctx$tables$
|
|
1887
|
-
return ((_ctx$tables$
|
|
1694
|
+
var _ctx$tables$length5, _ctx$tables5;
|
|
1695
|
+
return ((_ctx$tables$length5 = ctx == null || (_ctx$tables5 = ctx.tables) == null ? void 0 : _ctx$tables5.length) != null ? _ctx$tables$length5 : 0) <= 1 && !props.table;
|
|
1888
1696
|
},
|
|
1889
1697
|
helpText: "Pick model from a CMS Data Fetcher",
|
|
1890
1698
|
description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
|
|
@@ -1899,14 +1707,14 @@ var cmsRowFieldValueMeta = {
|
|
|
1899
1707
|
type: "choice",
|
|
1900
1708
|
displayName: "Field",
|
|
1901
1709
|
description: "Field (from model schema) to use.",
|
|
1902
|
-
options: function options(
|
|
1710
|
+
options: function options(_ref15, ctx) {
|
|
1903
1711
|
var _ctx$table5;
|
|
1904
|
-
var table =
|
|
1712
|
+
var table = _ref15.table;
|
|
1905
1713
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table5 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table5 : table);
|
|
1906
1714
|
},
|
|
1907
1715
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1908
1716
|
var _ctx$fieldMeta9, _ctx$fieldMeta10;
|
|
1909
|
-
return (ctx == null
|
|
1717
|
+
return (ctx == null || (_ctx$fieldMeta9 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta9.name) || (ctx == null || (_ctx$fieldMeta10 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta10.identifier);
|
|
1910
1718
|
}
|
|
1911
1719
|
},
|
|
1912
1720
|
valueProp: {
|
|
@@ -1917,18 +1725,18 @@ var cmsRowFieldValueMeta = {
|
|
|
1917
1725
|
}
|
|
1918
1726
|
}
|
|
1919
1727
|
};
|
|
1920
|
-
function CmsRowFieldValue(
|
|
1728
|
+
function CmsRowFieldValue(_ref16) {
|
|
1921
1729
|
var _res$row$data4;
|
|
1922
|
-
var table =
|
|
1923
|
-
field =
|
|
1924
|
-
valueProp =
|
|
1925
|
-
children =
|
|
1926
|
-
setControlContextData =
|
|
1927
|
-
rest = _objectWithoutPropertiesLoose(
|
|
1928
|
-
var tables = useTablesWithDataLoaded();
|
|
1730
|
+
var table = _ref16.table,
|
|
1731
|
+
field = _ref16.field,
|
|
1732
|
+
valueProp = _ref16.valueProp,
|
|
1733
|
+
children = _ref16.children,
|
|
1734
|
+
setControlContextData = _ref16.setControlContextData,
|
|
1735
|
+
rest = _objectWithoutPropertiesLoose(_ref16, _excluded3);
|
|
1736
|
+
var tables = useTablesWithDataLoaded("rows");
|
|
1929
1737
|
var res = useRow(tables, table);
|
|
1930
1738
|
if (!res || !res.row) {
|
|
1931
|
-
return
|
|
1739
|
+
return React.createElement(React.Fragment, null, children);
|
|
1932
1740
|
}
|
|
1933
1741
|
var fieldMeta = deriveInferredTableField({
|
|
1934
1742
|
table: res.table,
|
|
@@ -1938,7 +1746,7 @@ function CmsRowFieldValue(_ref15) {
|
|
|
1938
1746
|
});
|
|
1939
1747
|
if (tables) {
|
|
1940
1748
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1941
|
-
setControlContextData == null
|
|
1749
|
+
setControlContextData == null || setControlContextData({
|
|
1942
1750
|
tables: tables,
|
|
1943
1751
|
table: res.table,
|
|
1944
1752
|
row: res.row,
|
|
@@ -1946,17 +1754,17 @@ function CmsRowFieldValue(_ref15) {
|
|
|
1946
1754
|
});
|
|
1947
1755
|
}
|
|
1948
1756
|
if (!fieldMeta) {
|
|
1949
|
-
return
|
|
1757
|
+
return React.createElement(React.Fragment, null, children);
|
|
1950
1758
|
}
|
|
1951
1759
|
var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
|
|
1952
|
-
var childrenWithProps =
|
|
1953
|
-
if (
|
|
1760
|
+
var childrenWithProps = React.Children.map(children, function (child) {
|
|
1761
|
+
if (React.isValidElement(child)) {
|
|
1954
1762
|
var _extends2;
|
|
1955
|
-
return
|
|
1763
|
+
return React.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
|
|
1956
1764
|
}
|
|
1957
1765
|
return child;
|
|
1958
1766
|
});
|
|
1959
|
-
return
|
|
1767
|
+
return React.createElement(React.Fragment, null, childrenWithProps);
|
|
1960
1768
|
}
|
|
1961
1769
|
|
|
1962
1770
|
function registerAll(loader) {
|
|
@@ -1982,9 +1790,11 @@ function registerAll(loader) {
|
|
|
1982
1790
|
_registerComponent(CmsRowLink, cmsRowLinkMeta);
|
|
1983
1791
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
1984
1792
|
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
1793
|
+
_registerComponent(CmsCount, cmsCountFieldMeta);
|
|
1985
1794
|
}
|
|
1986
1795
|
|
|
1987
1796
|
exports.API = API;
|
|
1797
|
+
exports.CmsCount = CmsCount;
|
|
1988
1798
|
exports.CmsCredentialsProvider = CmsCredentialsProvider;
|
|
1989
1799
|
exports.CmsQueryRepeater = CmsQueryRepeater;
|
|
1990
1800
|
exports.CmsRowField = CmsRowField;
|
|
@@ -1992,6 +1802,7 @@ exports.CmsRowFieldValue = CmsRowFieldValue;
|
|
|
1992
1802
|
exports.CmsRowImage = CmsRowImage;
|
|
1993
1803
|
exports.CmsRowLink = CmsRowLink;
|
|
1994
1804
|
exports.HttpError = HttpError;
|
|
1805
|
+
exports.cmsCountFieldMeta = cmsCountFieldMeta;
|
|
1995
1806
|
exports.cmsCredentialsProviderMeta = cmsCredentialsProviderMeta;
|
|
1996
1807
|
exports.cmsQueryRepeaterMeta = cmsQueryRepeaterMeta;
|
|
1997
1808
|
exports.cmsRowFieldMeta = cmsRowFieldMeta;
|