@plasmicpkgs/plasmic-sanity-io 1.0.87 → 1.0.89
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/plasmic-sanity-io.cjs.development.js +348 -254
- package/dist/plasmic-sanity-io.cjs.development.js.map +1 -1
- package/dist/plasmic-sanity-io.cjs.production.min.js +1 -1
- package/dist/plasmic-sanity-io.cjs.production.min.js.map +1 -1
- package/dist/plasmic-sanity-io.esm.js +348 -254
- package/dist/plasmic-sanity-io.esm.js.map +1 -1
- package/dist/sanity.d.ts +10 -3
- package/dist/utils.d.ts +4 -0
- package/package.json +4 -5
|
@@ -16,29 +16,24 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
16
16
|
reject(error);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
if (info.done) {
|
|
21
20
|
resolve(value);
|
|
22
21
|
} else {
|
|
23
22
|
Promise.resolve(value).then(_next, _throw);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
function _asyncToGenerator(fn) {
|
|
28
26
|
return function () {
|
|
29
27
|
var self = this,
|
|
30
|
-
|
|
28
|
+
args = arguments;
|
|
31
29
|
return new Promise(function (resolve, reject) {
|
|
32
30
|
var gen = fn.apply(self, args);
|
|
33
|
-
|
|
34
31
|
function _next(value) {
|
|
35
32
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
function _throw(err) {
|
|
39
35
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
_next(undefined);
|
|
43
38
|
});
|
|
44
39
|
};
|
|
@@ -55,17 +50,16 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
55
50
|
* This source code is licensed under the MIT license found in the
|
|
56
51
|
* LICENSE file in the root directory of this source tree.
|
|
57
52
|
*/
|
|
53
|
+
|
|
58
54
|
var runtime = function (exports) {
|
|
59
55
|
|
|
60
56
|
var Op = Object.prototype;
|
|
61
57
|
var hasOwn = Op.hasOwnProperty;
|
|
62
58
|
var undefined$1; // More compressible than void 0.
|
|
63
|
-
|
|
64
59
|
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
65
60
|
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
66
61
|
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
67
62
|
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
68
|
-
|
|
69
63
|
function define(obj, key, value) {
|
|
70
64
|
Object.defineProperty(obj, key, {
|
|
71
65
|
value: value,
|
|
@@ -75,7 +69,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
75
69
|
});
|
|
76
70
|
return obj[key];
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
try {
|
|
80
73
|
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
81
74
|
define({}, "");
|
|
@@ -84,19 +77,20 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
84
77
|
return obj[key] = value;
|
|
85
78
|
};
|
|
86
79
|
}
|
|
87
|
-
|
|
88
80
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
89
81
|
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
90
82
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
91
83
|
var generator = Object.create(protoGenerator.prototype);
|
|
92
|
-
var context = new Context(tryLocsList || []);
|
|
93
|
-
// .throw, and .return methods.
|
|
84
|
+
var context = new Context(tryLocsList || []);
|
|
94
85
|
|
|
86
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
87
|
+
// .throw, and .return methods.
|
|
95
88
|
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
96
89
|
return generator;
|
|
97
90
|
}
|
|
91
|
+
exports.wrap = wrap;
|
|
98
92
|
|
|
99
|
-
|
|
93
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
100
94
|
// record like context.tryEntries[i].completion. This interface could
|
|
101
95
|
// have been (and was previously) designed to take a closure to be
|
|
102
96
|
// invoked without arguments, but in all the cases we care about we
|
|
@@ -106,7 +100,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
106
100
|
// in every case, so we don't have to touch the arguments object. The
|
|
107
101
|
// only additional allocation required is the completion record, which
|
|
108
102
|
// has a stable shape and so hopefully should be cheap to allocate.
|
|
109
|
-
|
|
110
103
|
function tryCatch(fn, obj, arg) {
|
|
111
104
|
try {
|
|
112
105
|
return {
|
|
@@ -120,46 +113,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
120
113
|
};
|
|
121
114
|
}
|
|
122
115
|
}
|
|
123
|
-
|
|
124
116
|
var GenStateSuspendedStart = "suspendedStart";
|
|
125
117
|
var GenStateSuspendedYield = "suspendedYield";
|
|
126
118
|
var GenStateExecuting = "executing";
|
|
127
|
-
var GenStateCompleted = "completed";
|
|
119
|
+
var GenStateCompleted = "completed";
|
|
120
|
+
|
|
121
|
+
// Returning this object from the innerFn has the same effect as
|
|
128
122
|
// breaking out of the dispatch switch statement.
|
|
123
|
+
var ContinueSentinel = {};
|
|
129
124
|
|
|
130
|
-
|
|
125
|
+
// Dummy constructor functions that we use as the .constructor and
|
|
131
126
|
// .constructor.prototype properties for functions that return Generator
|
|
132
127
|
// objects. For full spec compliance, you may wish to configure your
|
|
133
128
|
// minifier not to mangle the names of these two functions.
|
|
134
|
-
|
|
135
129
|
function Generator() {}
|
|
136
|
-
|
|
137
130
|
function GeneratorFunction() {}
|
|
131
|
+
function GeneratorFunctionPrototype() {}
|
|
138
132
|
|
|
139
|
-
|
|
133
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
140
134
|
// don't natively support it.
|
|
141
|
-
|
|
142
|
-
|
|
143
135
|
var IteratorPrototype = {};
|
|
144
136
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
145
137
|
return this;
|
|
146
138
|
});
|
|
147
139
|
var getProto = Object.getPrototypeOf;
|
|
148
140
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
149
|
-
|
|
150
141
|
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
151
142
|
// This environment has a native %IteratorPrototype%; use it instead
|
|
152
143
|
// of the polyfill.
|
|
153
144
|
IteratorPrototype = NativeIteratorPrototype;
|
|
154
145
|
}
|
|
155
|
-
|
|
156
146
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
157
147
|
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
158
148
|
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
159
149
|
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
160
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
161
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
150
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
162
151
|
|
|
152
|
+
// Helper for defining the .next, .throw, and .return methods of the
|
|
153
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
163
154
|
function defineIteratorMethods(prototype) {
|
|
164
155
|
["next", "throw", "return"].forEach(function (method) {
|
|
165
156
|
define(prototype, method, function (arg) {
|
|
@@ -167,14 +158,13 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
167
158
|
});
|
|
168
159
|
});
|
|
169
160
|
}
|
|
170
|
-
|
|
171
161
|
exports.isGeneratorFunction = function (genFun) {
|
|
172
162
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
173
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
163
|
+
return ctor ? ctor === GeneratorFunction ||
|
|
164
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
174
165
|
// do is to check its .name property.
|
|
175
166
|
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
176
167
|
};
|
|
177
|
-
|
|
178
168
|
exports.mark = function (genFun) {
|
|
179
169
|
if (Object.setPrototypeOf) {
|
|
180
170
|
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
@@ -182,31 +172,27 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
182
172
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
183
173
|
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
184
174
|
}
|
|
185
|
-
|
|
186
175
|
genFun.prototype = Object.create(Gp);
|
|
187
176
|
return genFun;
|
|
188
|
-
};
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Within the body of any async function, `await x` is transformed to
|
|
189
180
|
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
190
181
|
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
191
182
|
// meant to be awaited.
|
|
192
|
-
|
|
193
|
-
|
|
194
183
|
exports.awrap = function (arg) {
|
|
195
184
|
return {
|
|
196
185
|
__await: arg
|
|
197
186
|
};
|
|
198
187
|
};
|
|
199
|
-
|
|
200
188
|
function AsyncIterator(generator, PromiseImpl) {
|
|
201
189
|
function invoke(method, arg, resolve, reject) {
|
|
202
190
|
var record = tryCatch(generator[method], generator, arg);
|
|
203
|
-
|
|
204
191
|
if (record.type === "throw") {
|
|
205
192
|
reject(record.arg);
|
|
206
193
|
} else {
|
|
207
194
|
var result = record.arg;
|
|
208
195
|
var value = result.value;
|
|
209
|
-
|
|
210
196
|
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
211
197
|
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
212
198
|
invoke("next", value, resolve, reject);
|
|
@@ -214,7 +200,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
214
200
|
invoke("throw", err, resolve, reject);
|
|
215
201
|
});
|
|
216
202
|
}
|
|
217
|
-
|
|
218
203
|
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
219
204
|
// When a yielded Promise is resolved, its final value becomes
|
|
220
205
|
// the .value of the Promise<{value,done}> result for the
|
|
@@ -228,17 +213,15 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
228
213
|
});
|
|
229
214
|
}
|
|
230
215
|
}
|
|
231
|
-
|
|
232
216
|
var previousPromise;
|
|
233
|
-
|
|
234
217
|
function enqueue(method, arg) {
|
|
235
218
|
function callInvokeWithMethodAndArg() {
|
|
236
219
|
return new PromiseImpl(function (resolve, reject) {
|
|
237
220
|
invoke(method, arg, resolve, reject);
|
|
238
221
|
});
|
|
239
222
|
}
|
|
240
|
-
|
|
241
|
-
|
|
223
|
+
return previousPromise =
|
|
224
|
+
// If enqueue has been called before, then we want to wait until
|
|
242
225
|
// all previous Promises have been resolved before calling invoke,
|
|
243
226
|
// so that results are always delivered in the correct order. If
|
|
244
227
|
// enqueue has not been called before, then it is important to
|
|
@@ -250,24 +233,25 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
250
233
|
// execute code before the first await. Since we implement simple
|
|
251
234
|
// async functions in terms of async generators, it is especially
|
|
252
235
|
// important to get this right, even though it requires care.
|
|
253
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
236
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
237
|
+
// Avoid propagating failures to Promises returned by later
|
|
254
238
|
// invocations of the iterator.
|
|
255
239
|
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
256
|
-
}
|
|
257
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
258
|
-
|
|
240
|
+
}
|
|
259
241
|
|
|
242
|
+
// Define the unified helper method that is used to implement .next,
|
|
243
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
260
244
|
this._invoke = enqueue;
|
|
261
245
|
}
|
|
262
|
-
|
|
263
246
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
264
247
|
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
265
248
|
return this;
|
|
266
249
|
});
|
|
267
|
-
exports.AsyncIterator = AsyncIterator;
|
|
250
|
+
exports.AsyncIterator = AsyncIterator;
|
|
251
|
+
|
|
252
|
+
// Note that simple async functions are implemented on top of
|
|
268
253
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
269
254
|
// the final result produced by the iterator.
|
|
270
|
-
|
|
271
255
|
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
272
256
|
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
273
257
|
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
@@ -276,39 +260,32 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
276
260
|
return result.done ? result.value : iter.next();
|
|
277
261
|
});
|
|
278
262
|
};
|
|
279
|
-
|
|
280
263
|
function makeInvokeMethod(innerFn, self, context) {
|
|
281
264
|
var state = GenStateSuspendedStart;
|
|
282
265
|
return function invoke(method, arg) {
|
|
283
266
|
if (state === GenStateExecuting) {
|
|
284
267
|
throw new Error("Generator is already running");
|
|
285
268
|
}
|
|
286
|
-
|
|
287
269
|
if (state === GenStateCompleted) {
|
|
288
270
|
if (method === "throw") {
|
|
289
271
|
throw arg;
|
|
290
|
-
}
|
|
291
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
292
|
-
|
|
272
|
+
}
|
|
293
273
|
|
|
274
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
275
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
294
276
|
return doneResult();
|
|
295
277
|
}
|
|
296
|
-
|
|
297
278
|
context.method = method;
|
|
298
279
|
context.arg = arg;
|
|
299
|
-
|
|
300
280
|
while (true) {
|
|
301
281
|
var delegate = context.delegate;
|
|
302
|
-
|
|
303
282
|
if (delegate) {
|
|
304
283
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
305
|
-
|
|
306
284
|
if (delegateResult) {
|
|
307
285
|
if (delegateResult === ContinueSentinel) continue;
|
|
308
286
|
return delegateResult;
|
|
309
287
|
}
|
|
310
288
|
}
|
|
311
|
-
|
|
312
289
|
if (context.method === "next") {
|
|
313
290
|
// Setting context._sent for legacy support of Babel's
|
|
314
291
|
// function.sent implementation.
|
|
@@ -318,51 +295,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
318
295
|
state = GenStateCompleted;
|
|
319
296
|
throw context.arg;
|
|
320
297
|
}
|
|
321
|
-
|
|
322
298
|
context.dispatchException(context.arg);
|
|
323
299
|
} else if (context.method === "return") {
|
|
324
300
|
context.abrupt("return", context.arg);
|
|
325
301
|
}
|
|
326
|
-
|
|
327
302
|
state = GenStateExecuting;
|
|
328
303
|
var record = tryCatch(innerFn, self, context);
|
|
329
|
-
|
|
330
304
|
if (record.type === "normal") {
|
|
331
305
|
// If an exception is thrown from innerFn, we leave state ===
|
|
332
306
|
// GenStateExecuting and loop back for another invocation.
|
|
333
307
|
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
334
|
-
|
|
335
308
|
if (record.arg === ContinueSentinel) {
|
|
336
309
|
continue;
|
|
337
310
|
}
|
|
338
|
-
|
|
339
311
|
return {
|
|
340
312
|
value: record.arg,
|
|
341
313
|
done: context.done
|
|
342
314
|
};
|
|
343
315
|
} else if (record.type === "throw") {
|
|
344
|
-
state = GenStateCompleted;
|
|
316
|
+
state = GenStateCompleted;
|
|
317
|
+
// Dispatch the exception by looping back around to the
|
|
345
318
|
// context.dispatchException(context.arg) call above.
|
|
346
|
-
|
|
347
319
|
context.method = "throw";
|
|
348
320
|
context.arg = record.arg;
|
|
349
321
|
}
|
|
350
322
|
}
|
|
351
323
|
};
|
|
352
|
-
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
353
327
|
// result, either by returning a { value, done } result from the
|
|
354
328
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
355
329
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
356
|
-
|
|
357
|
-
|
|
358
330
|
function maybeInvokeDelegate(delegate, context) {
|
|
359
331
|
var method = delegate.iterator[context.method];
|
|
360
|
-
|
|
361
332
|
if (method === undefined$1) {
|
|
362
333
|
// A .throw or .return when the delegate iterator has no .throw
|
|
363
334
|
// method always terminates the yield* loop.
|
|
364
335
|
context.delegate = null;
|
|
365
|
-
|
|
366
336
|
if (context.method === "throw") {
|
|
367
337
|
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
368
338
|
if (delegate.iterator["return"]) {
|
|
@@ -371,51 +341,45 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
371
341
|
context.method = "return";
|
|
372
342
|
context.arg = undefined$1;
|
|
373
343
|
maybeInvokeDelegate(delegate, context);
|
|
374
|
-
|
|
375
344
|
if (context.method === "throw") {
|
|
376
345
|
// If maybeInvokeDelegate(context) changed context.method from
|
|
377
346
|
// "return" to "throw", let that override the TypeError below.
|
|
378
347
|
return ContinueSentinel;
|
|
379
348
|
}
|
|
380
349
|
}
|
|
381
|
-
|
|
382
350
|
context.method = "throw";
|
|
383
351
|
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
384
352
|
}
|
|
385
|
-
|
|
386
353
|
return ContinueSentinel;
|
|
387
354
|
}
|
|
388
|
-
|
|
389
355
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
390
|
-
|
|
391
356
|
if (record.type === "throw") {
|
|
392
357
|
context.method = "throw";
|
|
393
358
|
context.arg = record.arg;
|
|
394
359
|
context.delegate = null;
|
|
395
360
|
return ContinueSentinel;
|
|
396
361
|
}
|
|
397
|
-
|
|
398
362
|
var info = record.arg;
|
|
399
|
-
|
|
400
363
|
if (!info) {
|
|
401
364
|
context.method = "throw";
|
|
402
365
|
context.arg = new TypeError("iterator result is not an object");
|
|
403
366
|
context.delegate = null;
|
|
404
367
|
return ContinueSentinel;
|
|
405
368
|
}
|
|
406
|
-
|
|
407
369
|
if (info.done) {
|
|
408
370
|
// Assign the result of the finished delegate to the temporary
|
|
409
371
|
// variable specified by delegate.resultName (see delegateYield).
|
|
410
|
-
context[delegate.resultName] = info.value;
|
|
372
|
+
context[delegate.resultName] = info.value;
|
|
411
373
|
|
|
412
|
-
|
|
374
|
+
// Resume execution at the desired location (see delegateYield).
|
|
375
|
+
context.next = delegate.nextLoc;
|
|
376
|
+
|
|
377
|
+
// If context.method was "throw" but the delegate handled the
|
|
413
378
|
// exception, let the outer generator proceed normally. If
|
|
414
379
|
// context.method was "next", forget context.arg since it has been
|
|
415
380
|
// "consumed" by the delegate iterator. If context.method was
|
|
416
381
|
// "return", allow the original .return call to continue in the
|
|
417
382
|
// outer generator.
|
|
418
|
-
|
|
419
383
|
if (context.method !== "return") {
|
|
420
384
|
context.method = "next";
|
|
421
385
|
context.arg = undefined$1;
|
|
@@ -423,54 +387,49 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
423
387
|
} else {
|
|
424
388
|
// Re-yield the result returned by the delegate method.
|
|
425
389
|
return info;
|
|
426
|
-
}
|
|
427
|
-
// the outer generator.
|
|
428
|
-
|
|
390
|
+
}
|
|
429
391
|
|
|
392
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
393
|
+
// the outer generator.
|
|
430
394
|
context.delegate = null;
|
|
431
395
|
return ContinueSentinel;
|
|
432
|
-
}
|
|
433
|
-
// unified ._invoke helper method.
|
|
434
|
-
|
|
396
|
+
}
|
|
435
397
|
|
|
398
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
399
|
+
// unified ._invoke helper method.
|
|
436
400
|
defineIteratorMethods(Gp);
|
|
437
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
401
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
402
|
+
|
|
403
|
+
// A Generator should always return itself as the iterator object when the
|
|
438
404
|
// @@iterator function is called on it. Some browsers' implementations of the
|
|
439
405
|
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
440
406
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
441
407
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
442
|
-
|
|
443
408
|
define(Gp, iteratorSymbol, function () {
|
|
444
409
|
return this;
|
|
445
410
|
});
|
|
446
411
|
define(Gp, "toString", function () {
|
|
447
412
|
return "[object Generator]";
|
|
448
413
|
});
|
|
449
|
-
|
|
450
414
|
function pushTryEntry(locs) {
|
|
451
415
|
var entry = {
|
|
452
416
|
tryLoc: locs[0]
|
|
453
417
|
};
|
|
454
|
-
|
|
455
418
|
if (1 in locs) {
|
|
456
419
|
entry.catchLoc = locs[1];
|
|
457
420
|
}
|
|
458
|
-
|
|
459
421
|
if (2 in locs) {
|
|
460
422
|
entry.finallyLoc = locs[2];
|
|
461
423
|
entry.afterLoc = locs[3];
|
|
462
424
|
}
|
|
463
|
-
|
|
464
425
|
this.tryEntries.push(entry);
|
|
465
426
|
}
|
|
466
|
-
|
|
467
427
|
function resetTryEntry(entry) {
|
|
468
428
|
var record = entry.completion || {};
|
|
469
429
|
record.type = "normal";
|
|
470
430
|
delete record.arg;
|
|
471
431
|
entry.completion = record;
|
|
472
432
|
}
|
|
473
|
-
|
|
474
433
|
function Context(tryLocsList) {
|
|
475
434
|
// The root entry object (effectively a try statement without a catch
|
|
476
435
|
// or a finally block) gives us a place to store values thrown from
|
|
@@ -481,97 +440,84 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
481
440
|
tryLocsList.forEach(pushTryEntry, this);
|
|
482
441
|
this.reset(true);
|
|
483
442
|
}
|
|
484
|
-
|
|
485
443
|
exports.keys = function (object) {
|
|
486
444
|
var keys = [];
|
|
487
|
-
|
|
488
445
|
for (var key in object) {
|
|
489
446
|
keys.push(key);
|
|
490
447
|
}
|
|
448
|
+
keys.reverse();
|
|
491
449
|
|
|
492
|
-
|
|
450
|
+
// Rather than returning an object with a next method, we keep
|
|
493
451
|
// things simple and return the next function itself.
|
|
494
|
-
|
|
495
452
|
return function next() {
|
|
496
453
|
while (keys.length) {
|
|
497
454
|
var key = keys.pop();
|
|
498
|
-
|
|
499
455
|
if (key in object) {
|
|
500
456
|
next.value = key;
|
|
501
457
|
next.done = false;
|
|
502
458
|
return next;
|
|
503
459
|
}
|
|
504
|
-
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// To avoid creating an additional object, we just hang the .value
|
|
505
463
|
// and .done properties off the next function object itself. This
|
|
506
464
|
// also ensures that the minifier will not anonymize the function.
|
|
507
|
-
|
|
508
|
-
|
|
509
465
|
next.done = true;
|
|
510
466
|
return next;
|
|
511
467
|
};
|
|
512
468
|
};
|
|
513
|
-
|
|
514
469
|
function values(iterable) {
|
|
515
470
|
if (iterable) {
|
|
516
471
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
517
|
-
|
|
518
472
|
if (iteratorMethod) {
|
|
519
473
|
return iteratorMethod.call(iterable);
|
|
520
474
|
}
|
|
521
|
-
|
|
522
475
|
if (typeof iterable.next === "function") {
|
|
523
476
|
return iterable;
|
|
524
477
|
}
|
|
525
|
-
|
|
526
478
|
if (!isNaN(iterable.length)) {
|
|
527
479
|
var i = -1,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
480
|
+
next = function next() {
|
|
481
|
+
while (++i < iterable.length) {
|
|
482
|
+
if (hasOwn.call(iterable, i)) {
|
|
483
|
+
next.value = iterable[i];
|
|
484
|
+
next.done = false;
|
|
485
|
+
return next;
|
|
486
|
+
}
|
|
534
487
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return next;
|
|
540
|
-
};
|
|
541
|
-
|
|
488
|
+
next.value = undefined$1;
|
|
489
|
+
next.done = true;
|
|
490
|
+
return next;
|
|
491
|
+
};
|
|
542
492
|
return next.next = next;
|
|
543
493
|
}
|
|
544
|
-
}
|
|
545
|
-
|
|
494
|
+
}
|
|
546
495
|
|
|
496
|
+
// Return an iterator with no values.
|
|
547
497
|
return {
|
|
548
498
|
next: doneResult
|
|
549
499
|
};
|
|
550
500
|
}
|
|
551
|
-
|
|
552
501
|
exports.values = values;
|
|
553
|
-
|
|
554
502
|
function doneResult() {
|
|
555
503
|
return {
|
|
556
504
|
value: undefined$1,
|
|
557
505
|
done: true
|
|
558
506
|
};
|
|
559
507
|
}
|
|
560
|
-
|
|
561
508
|
Context.prototype = {
|
|
562
509
|
constructor: Context,
|
|
563
510
|
reset: function reset(skipTempReset) {
|
|
564
511
|
this.prev = 0;
|
|
565
|
-
this.next = 0;
|
|
512
|
+
this.next = 0;
|
|
513
|
+
// Resetting context._sent for legacy support of Babel's
|
|
566
514
|
// function.sent implementation.
|
|
567
|
-
|
|
568
515
|
this.sent = this._sent = undefined$1;
|
|
569
516
|
this.done = false;
|
|
570
517
|
this.delegate = null;
|
|
571
518
|
this.method = "next";
|
|
572
519
|
this.arg = undefined$1;
|
|
573
520
|
this.tryEntries.forEach(resetTryEntry);
|
|
574
|
-
|
|
575
521
|
if (!skipTempReset) {
|
|
576
522
|
for (var name in this) {
|
|
577
523
|
// Not sure about the optimal order of these conditions:
|
|
@@ -585,50 +531,40 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
585
531
|
this.done = true;
|
|
586
532
|
var rootEntry = this.tryEntries[0];
|
|
587
533
|
var rootRecord = rootEntry.completion;
|
|
588
|
-
|
|
589
534
|
if (rootRecord.type === "throw") {
|
|
590
535
|
throw rootRecord.arg;
|
|
591
536
|
}
|
|
592
|
-
|
|
593
537
|
return this.rval;
|
|
594
538
|
},
|
|
595
539
|
dispatchException: function dispatchException(exception) {
|
|
596
540
|
if (this.done) {
|
|
597
541
|
throw exception;
|
|
598
542
|
}
|
|
599
|
-
|
|
600
543
|
var context = this;
|
|
601
|
-
|
|
602
544
|
function handle(loc, caught) {
|
|
603
545
|
record.type = "throw";
|
|
604
546
|
record.arg = exception;
|
|
605
547
|
context.next = loc;
|
|
606
|
-
|
|
607
548
|
if (caught) {
|
|
608
549
|
// If the dispatched exception was caught by a catch block,
|
|
609
550
|
// then let that catch block handle the exception normally.
|
|
610
551
|
context.method = "next";
|
|
611
552
|
context.arg = undefined$1;
|
|
612
553
|
}
|
|
613
|
-
|
|
614
554
|
return !!caught;
|
|
615
555
|
}
|
|
616
|
-
|
|
617
556
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
618
557
|
var entry = this.tryEntries[i];
|
|
619
558
|
var record = entry.completion;
|
|
620
|
-
|
|
621
559
|
if (entry.tryLoc === "root") {
|
|
622
560
|
// Exception thrown outside of any try block that could handle
|
|
623
561
|
// it, so set the completion value of the entire function to
|
|
624
562
|
// throw the exception.
|
|
625
563
|
return handle("end");
|
|
626
564
|
}
|
|
627
|
-
|
|
628
565
|
if (entry.tryLoc <= this.prev) {
|
|
629
566
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
630
567
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
631
|
-
|
|
632
568
|
if (hasCatch && hasFinally) {
|
|
633
569
|
if (this.prev < entry.catchLoc) {
|
|
634
570
|
return handle(entry.catchLoc, true);
|
|
@@ -652,36 +588,30 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
652
588
|
abrupt: function abrupt(type, arg) {
|
|
653
589
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
654
590
|
var entry = this.tryEntries[i];
|
|
655
|
-
|
|
656
591
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
657
592
|
var finallyEntry = entry;
|
|
658
593
|
break;
|
|
659
594
|
}
|
|
660
595
|
}
|
|
661
|
-
|
|
662
596
|
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
663
597
|
// Ignore the finally entry if control is not jumping to a
|
|
664
598
|
// location outside the try/catch block.
|
|
665
599
|
finallyEntry = null;
|
|
666
600
|
}
|
|
667
|
-
|
|
668
601
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
669
602
|
record.type = type;
|
|
670
603
|
record.arg = arg;
|
|
671
|
-
|
|
672
604
|
if (finallyEntry) {
|
|
673
605
|
this.method = "next";
|
|
674
606
|
this.next = finallyEntry.finallyLoc;
|
|
675
607
|
return ContinueSentinel;
|
|
676
608
|
}
|
|
677
|
-
|
|
678
609
|
return this.complete(record);
|
|
679
610
|
},
|
|
680
611
|
complete: function complete(record, afterLoc) {
|
|
681
612
|
if (record.type === "throw") {
|
|
682
613
|
throw record.arg;
|
|
683
614
|
}
|
|
684
|
-
|
|
685
615
|
if (record.type === "break" || record.type === "continue") {
|
|
686
616
|
this.next = record.arg;
|
|
687
617
|
} else if (record.type === "return") {
|
|
@@ -691,13 +621,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
691
621
|
} else if (record.type === "normal" && afterLoc) {
|
|
692
622
|
this.next = afterLoc;
|
|
693
623
|
}
|
|
694
|
-
|
|
695
624
|
return ContinueSentinel;
|
|
696
625
|
},
|
|
697
626
|
finish: function finish(finallyLoc) {
|
|
698
627
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
699
628
|
var entry = this.tryEntries[i];
|
|
700
|
-
|
|
701
629
|
if (entry.finallyLoc === finallyLoc) {
|
|
702
630
|
this.complete(entry.completion, entry.afterLoc);
|
|
703
631
|
resetTryEntry(entry);
|
|
@@ -708,21 +636,18 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
708
636
|
"catch": function _catch(tryLoc) {
|
|
709
637
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
710
638
|
var entry = this.tryEntries[i];
|
|
711
|
-
|
|
712
639
|
if (entry.tryLoc === tryLoc) {
|
|
713
640
|
var record = entry.completion;
|
|
714
|
-
|
|
715
641
|
if (record.type === "throw") {
|
|
716
642
|
var thrown = record.arg;
|
|
717
643
|
resetTryEntry(entry);
|
|
718
644
|
}
|
|
719
|
-
|
|
720
645
|
return thrown;
|
|
721
646
|
}
|
|
722
|
-
}
|
|
723
|
-
// argument that corresponds to a known catch block.
|
|
724
|
-
|
|
647
|
+
}
|
|
725
648
|
|
|
649
|
+
// The context.catch method must only be called with a location
|
|
650
|
+
// argument that corresponds to a known catch block.
|
|
726
651
|
throw new Error("illegal catch attempt");
|
|
727
652
|
},
|
|
728
653
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
@@ -731,27 +656,26 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
731
656
|
resultName: resultName,
|
|
732
657
|
nextLoc: nextLoc
|
|
733
658
|
};
|
|
734
|
-
|
|
735
659
|
if (this.method === "next") {
|
|
736
660
|
// Deliberately forget the last sent value so that we don't
|
|
737
661
|
// accidentally pass it on to the delegate.
|
|
738
662
|
this.arg = undefined$1;
|
|
739
663
|
}
|
|
740
|
-
|
|
741
664
|
return ContinueSentinel;
|
|
742
665
|
}
|
|
743
|
-
};
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
744
669
|
// or not, return the runtime object so that we can declare the variable
|
|
745
670
|
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
746
671
|
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
747
|
-
|
|
748
672
|
return exports;
|
|
749
|
-
}(
|
|
673
|
+
}(
|
|
674
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
750
675
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
751
676
|
// object. Either way, the resulting object will be used to initialize
|
|
752
677
|
// the regeneratorRuntime variable at the top of this file.
|
|
753
678
|
module.exports );
|
|
754
|
-
|
|
755
679
|
try {
|
|
756
680
|
regeneratorRuntime = runtime;
|
|
757
681
|
} catch (accidentalStrictMode) {
|
|
@@ -773,6 +697,26 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
773
697
|
}
|
|
774
698
|
});
|
|
775
699
|
|
|
700
|
+
var filterParameters = [{
|
|
701
|
+
value: '==',
|
|
702
|
+
label: 'Is'
|
|
703
|
+
}, {
|
|
704
|
+
value: '!=',
|
|
705
|
+
label: 'Is not'
|
|
706
|
+
}, {
|
|
707
|
+
value: '>',
|
|
708
|
+
label: 'Greater than'
|
|
709
|
+
}, {
|
|
710
|
+
value: '<',
|
|
711
|
+
label: 'Less than'
|
|
712
|
+
}, {
|
|
713
|
+
value: '<=',
|
|
714
|
+
label: 'Less than or equal'
|
|
715
|
+
}, {
|
|
716
|
+
value: '>=',
|
|
717
|
+
label: 'Greater than or equal '
|
|
718
|
+
}];
|
|
719
|
+
|
|
776
720
|
function ensure(x) {
|
|
777
721
|
if (x === null || x === undefined) {
|
|
778
722
|
debugger;
|
|
@@ -782,11 +726,9 @@ function ensure(x) {
|
|
|
782
726
|
}
|
|
783
727
|
}
|
|
784
728
|
var modulePath = "@plasmicpkgs/plasmic-sanity-io";
|
|
785
|
-
|
|
786
729
|
var makeDataProviderName = function makeDataProviderName(docType) {
|
|
787
730
|
return "currentSanity" + pascalCase(docType) + "Item";
|
|
788
731
|
};
|
|
789
|
-
|
|
790
732
|
function makeSanityClient(creds) {
|
|
791
733
|
var sanity = sanityClient({
|
|
792
734
|
projectId: creds.projectId,
|
|
@@ -797,7 +739,6 @@ function makeSanityClient(creds) {
|
|
|
797
739
|
});
|
|
798
740
|
return sanity;
|
|
799
741
|
}
|
|
800
|
-
|
|
801
742
|
var CredentialsContext = /*#__PURE__*/React.createContext(undefined);
|
|
802
743
|
var sanityCredentialsProviderMeta = {
|
|
803
744
|
name: "SanityCredentialsProvider",
|
|
@@ -841,11 +782,11 @@ var sanityCredentialsProviderMeta = {
|
|
|
841
782
|
};
|
|
842
783
|
function SanityCredentialsProvider(_ref) {
|
|
843
784
|
var projectId = _ref.projectId,
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
785
|
+
dataset = _ref.dataset,
|
|
786
|
+
apiVersion = _ref.apiVersion,
|
|
787
|
+
token = _ref.token,
|
|
788
|
+
useCdn = _ref.useCdn,
|
|
789
|
+
children = _ref.children;
|
|
849
790
|
return React.createElement(CredentialsContext.Provider, {
|
|
850
791
|
value: {
|
|
851
792
|
projectId: projectId,
|
|
@@ -895,12 +836,54 @@ var sanityFetcherMeta = {
|
|
|
895
836
|
type: "choice",
|
|
896
837
|
options: function options(props, ctx) {
|
|
897
838
|
var _ctx$docTypes;
|
|
898
|
-
|
|
899
839
|
return (_ctx$docTypes = ctx == null ? void 0 : ctx.docTypes) != null ? _ctx$docTypes : [];
|
|
900
840
|
},
|
|
901
841
|
displayName: "Document type",
|
|
902
842
|
description: "Document type to be queried (*[_type == DOC_TYPE] shortcut)."
|
|
903
843
|
},
|
|
844
|
+
filterField: {
|
|
845
|
+
type: "choice",
|
|
846
|
+
displayName: "Filter field",
|
|
847
|
+
description: "Field (from Collection) to filter by",
|
|
848
|
+
options: function options(props, ctx) {
|
|
849
|
+
var _ctx$sanityFields;
|
|
850
|
+
return (_ctx$sanityFields = ctx == null ? void 0 : ctx.sanityFields) != null ? _ctx$sanityFields : [];
|
|
851
|
+
},
|
|
852
|
+
hidden: function hidden(props, ctx) {
|
|
853
|
+
return !props.docType && !props.groq;
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
filterParameter: {
|
|
857
|
+
type: "choice",
|
|
858
|
+
displayName: "Filter Parameter",
|
|
859
|
+
description: "Filter Parameter filter by.Read more (https://www.sanity.io/docs/groq-operators#3b7211e976f6)",
|
|
860
|
+
options: function options(props, ctx) {
|
|
861
|
+
var _ctx$queryOptions;
|
|
862
|
+
return (_ctx$queryOptions = ctx == null ? void 0 : ctx.queryOptions) != null ? _ctx$queryOptions : [];
|
|
863
|
+
},
|
|
864
|
+
hidden: function hidden(props, ctx) {
|
|
865
|
+
return !props.filterField;
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
filterValue: {
|
|
869
|
+
type: "string",
|
|
870
|
+
displayName: "Filter value",
|
|
871
|
+
description: "Value to filter by, should be of filter field type",
|
|
872
|
+
hidden: function hidden(props, ctx) {
|
|
873
|
+
return !props.filterParameter;
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
limit: {
|
|
877
|
+
type: "string",
|
|
878
|
+
displayName: "Limit",
|
|
879
|
+
description: "Limit"
|
|
880
|
+
},
|
|
881
|
+
noAutoRepeat: {
|
|
882
|
+
type: "boolean",
|
|
883
|
+
displayName: "No auto-repeat",
|
|
884
|
+
description: "Do not automatically repeat children for every category.",
|
|
885
|
+
defaultValue: false
|
|
886
|
+
},
|
|
904
887
|
noLayout: {
|
|
905
888
|
type: "boolean",
|
|
906
889
|
displayName: "No layout",
|
|
@@ -911,18 +894,21 @@ var sanityFetcherMeta = {
|
|
|
911
894
|
};
|
|
912
895
|
function SanityFetcher(_ref2) {
|
|
913
896
|
var _allDataTypes$data;
|
|
914
|
-
|
|
915
897
|
var groq = _ref2.groq,
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
898
|
+
docType = _ref2.docType,
|
|
899
|
+
filterField = _ref2.filterField,
|
|
900
|
+
filterValue = _ref2.filterValue,
|
|
901
|
+
filterParameter = _ref2.filterParameter,
|
|
902
|
+
limit = _ref2.limit,
|
|
903
|
+
noAutoRepeat = _ref2.noAutoRepeat,
|
|
904
|
+
children = _ref2.children,
|
|
905
|
+
className = _ref2.className,
|
|
906
|
+
noLayout = _ref2.noLayout,
|
|
907
|
+
setControlContextData = _ref2.setControlContextData;
|
|
921
908
|
var projectIdRegex = new RegExp(/^[-a-z0-9]+$/i);
|
|
922
909
|
var datasetRegex = new RegExp(/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/);
|
|
923
910
|
var dateRegex = new RegExp(/^\d{4}-\d{2}-\d{2}$/);
|
|
924
911
|
var creds = ensure(useContext(CredentialsContext));
|
|
925
|
-
|
|
926
912
|
if (!creds.projectId || !projectIdRegex.test(creds.projectId)) {
|
|
927
913
|
return React.createElement("div", null, "Please specify a valid projectId, it can only contain only a-z, 0-9 and dashes.");
|
|
928
914
|
} else if (!creds.dataset || !datasetRegex.test(creds.dataset)) {
|
|
@@ -930,13 +916,11 @@ function SanityFetcher(_ref2) {
|
|
|
930
916
|
} else if (creds.apiVersion) {
|
|
931
917
|
if (creds.apiVersion !== "v1" && creds.apiVersion !== "1" && creds.apiVersion !== "X") {
|
|
932
918
|
var date = new Date(creds.apiVersion);
|
|
933
|
-
|
|
934
919
|
if (!(dateRegex.test(creds.apiVersion) && date instanceof Date && date.getTime() > 0)) {
|
|
935
920
|
return React.createElement("div", null, "Please specify a valid API version, expected `v1`, `1` or date in format `YYYY-MM-DD`.");
|
|
936
921
|
}
|
|
937
922
|
}
|
|
938
923
|
}
|
|
939
|
-
|
|
940
924
|
var filterUniqueDocTypes = function filterUniqueDocTypes(records) {
|
|
941
925
|
return records.map(function (record) {
|
|
942
926
|
return record._type;
|
|
@@ -944,11 +928,9 @@ function SanityFetcher(_ref2) {
|
|
|
944
928
|
if (!acc.includes(type)) {
|
|
945
929
|
acc.push(type);
|
|
946
930
|
}
|
|
947
|
-
|
|
948
931
|
return acc;
|
|
949
932
|
}, []);
|
|
950
933
|
};
|
|
951
|
-
|
|
952
934
|
var allDataTypes = usePlasmicQueryData(JSON.stringify(creds) + "/SANITY_DOCTYPES", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
953
935
|
var sanity, resp;
|
|
954
936
|
return runtime_1.wrap(function _callee$(_context) {
|
|
@@ -958,11 +940,9 @@ function SanityFetcher(_ref2) {
|
|
|
958
940
|
sanity = makeSanityClient(creds);
|
|
959
941
|
_context.next = 3;
|
|
960
942
|
return sanity.fetch("*{_type}").then(filterUniqueDocTypes);
|
|
961
|
-
|
|
962
943
|
case 3:
|
|
963
944
|
resp = _context.sent;
|
|
964
945
|
return _context.abrupt("return", resp);
|
|
965
|
-
|
|
966
946
|
case 5:
|
|
967
947
|
case "end":
|
|
968
948
|
return _context.stop();
|
|
@@ -971,82 +951,206 @@ function SanityFetcher(_ref2) {
|
|
|
971
951
|
}, _callee);
|
|
972
952
|
})));
|
|
973
953
|
var docTypes = (_allDataTypes$data = allDataTypes.data) != null ? _allDataTypes$data : false;
|
|
974
|
-
|
|
975
954
|
if (!groq && docType) {
|
|
976
|
-
groq = "*[_type=='" + docType + "'
|
|
955
|
+
groq = "*[_type=='" + docType + "'";
|
|
977
956
|
}
|
|
978
|
-
|
|
979
957
|
var cacheKey = JSON.stringify({
|
|
958
|
+
docType: docType,
|
|
959
|
+
filterField: filterField,
|
|
960
|
+
filterValue: filterValue,
|
|
961
|
+
filterParameter: filterParameter,
|
|
962
|
+
limit: limit,
|
|
980
963
|
groq: groq,
|
|
981
964
|
creds: creds
|
|
982
965
|
});
|
|
983
966
|
var sanity = makeSanityClient(creds);
|
|
984
|
-
var
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
967
|
+
var _usePlasmicQueryData = usePlasmicQueryData(docType && groq ? cacheKey : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
968
|
+
var query, resp;
|
|
969
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
970
|
+
while (1) {
|
|
971
|
+
switch (_context2.prev = _context2.next) {
|
|
972
|
+
case 0:
|
|
973
|
+
if (groq) {
|
|
974
|
+
_context2.next = 2;
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
return _context2.abrupt("return", null);
|
|
978
|
+
case 2:
|
|
979
|
+
if (limit) {
|
|
980
|
+
query = groq + "][" + limit + "]";
|
|
981
|
+
} else {
|
|
982
|
+
query = groq + "]";
|
|
983
|
+
}
|
|
984
|
+
_context2.next = 5;
|
|
985
|
+
return sanity.fetch(query);
|
|
986
|
+
case 5:
|
|
987
|
+
resp = _context2.sent;
|
|
988
|
+
return _context2.abrupt("return", resp);
|
|
989
|
+
case 7:
|
|
990
|
+
case "end":
|
|
991
|
+
return _context2.stop();
|
|
992
|
+
}
|
|
1008
993
|
}
|
|
1009
|
-
}
|
|
1010
|
-
},
|
|
1011
|
-
|
|
1012
|
-
|
|
994
|
+
}, _callee2);
|
|
995
|
+
}))),
|
|
996
|
+
response = _usePlasmicQueryData.data;
|
|
997
|
+
var _usePlasmicQueryData2 = usePlasmicQueryData(groq && filterField && filterValue && filterParameter && response ? cacheKey + "/filtered" : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
998
|
+
var query, matched, resp;
|
|
999
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1000
|
+
while (1) {
|
|
1001
|
+
switch (_context3.prev = _context3.next) {
|
|
1002
|
+
case 0:
|
|
1003
|
+
if (!(!docType && !filterField && !filterValue && !filterParameter && !response)) {
|
|
1004
|
+
_context3.next = 2;
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
1007
|
+
return _context3.abrupt("return", null);
|
|
1008
|
+
case 2:
|
|
1009
|
+
if (response) {
|
|
1010
|
+
_context3.next = 4;
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
return _context3.abrupt("return", null);
|
|
1014
|
+
case 4:
|
|
1015
|
+
matched = Object.values(response).flatMap(function (model) {
|
|
1016
|
+
return Array.isArray(model) ? model : [model];
|
|
1017
|
+
}).map(function (item) {
|
|
1018
|
+
var fields = Object.entries(item).find(function (el) {
|
|
1019
|
+
return el[0] === filterField;
|
|
1020
|
+
});
|
|
1021
|
+
return fields;
|
|
1022
|
+
});
|
|
1023
|
+
Object.values(matched).map(function (model) {
|
|
1024
|
+
return Array.isArray(model) ? model : [model];
|
|
1025
|
+
}).map(function (item) {
|
|
1026
|
+
if (typeof item[1] === "number" && typeof item[1] !== "object") {
|
|
1027
|
+
query = groq + " && " + filterField + " " + filterParameter + " " + filterValue + "]";
|
|
1028
|
+
} else if (typeof item[1] !== "number" && typeof item[1] !== "object" && typeof item[1] === "string") {
|
|
1029
|
+
query = groq + " && " + filterField + " " + filterParameter + " \"" + filterValue + "\"]";
|
|
1030
|
+
} else {
|
|
1031
|
+
query = groq + " && " + filterField + " " + filterParameter + " " + filterValue + "]";
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
_context3.next = 8;
|
|
1035
|
+
return sanity.fetch(query);
|
|
1036
|
+
case 8:
|
|
1037
|
+
resp = _context3.sent;
|
|
1038
|
+
return _context3.abrupt("return", resp);
|
|
1039
|
+
case 10:
|
|
1040
|
+
case "end":
|
|
1041
|
+
return _context3.stop();
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}, _callee3);
|
|
1045
|
+
}))),
|
|
1046
|
+
filteredData = _usePlasmicQueryData2.data;
|
|
1013
1047
|
if (!docTypes) {
|
|
1014
1048
|
return React.createElement("div", null, "Please configure the Sanity provider with a valid projectId, dataset, and token (if necessary). Don't forget to add 'https://host.plasmicdev.com' as an authorized host on the CORS origins section of your project.");
|
|
1015
1049
|
}
|
|
1016
|
-
|
|
1017
1050
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1018
1051
|
docTypes: docTypes
|
|
1019
1052
|
});
|
|
1020
|
-
|
|
1021
|
-
if (!(data != null && data.data)) {
|
|
1053
|
+
if (!response) {
|
|
1022
1054
|
return React.createElement("div", null, "Please specify a valid GROQ query or select a Document type.");
|
|
1023
1055
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
Object.keys(item).forEach(function (field) {
|
|
1029
|
-
if (item[field]._type === "image") {
|
|
1030
|
-
item[field].imgUrl = imageBuilder.image(item[field]).ignoreImageParams().toString();
|
|
1031
|
-
}
|
|
1056
|
+
var sanityFields = response.map(function (item) {
|
|
1057
|
+
var fields = Object.keys(item).filter(function (field) {
|
|
1058
|
+
var value = get(item, field);
|
|
1059
|
+
return typeof value !== "object" && value._type !== "image" && typeof value === "number" || typeof value === "string" && !value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/);
|
|
1032
1060
|
});
|
|
1033
|
-
return
|
|
1034
|
-
key: item._id,
|
|
1035
|
-
name: "sanityItem",
|
|
1036
|
-
data: item,
|
|
1037
|
-
hidden: true
|
|
1038
|
-
}, React.createElement(DataProvider, {
|
|
1039
|
-
name: makeDataProviderName(docType),
|
|
1040
|
-
data: item
|
|
1041
|
-
}, repeatedElement(index, children))) : React.createElement(DataProvider, {
|
|
1042
|
-
key: item._id,
|
|
1043
|
-
name: "sanityItem",
|
|
1044
|
-
data: item
|
|
1045
|
-
}, repeatedElement(index, children));
|
|
1061
|
+
return fields;
|
|
1046
1062
|
});
|
|
1047
|
-
|
|
1063
|
+
var operators;
|
|
1064
|
+
var matchedFields = Object.values(response).flatMap(function (model) {
|
|
1065
|
+
return Array.isArray(model) ? model : [model];
|
|
1066
|
+
}).map(function (item) {
|
|
1067
|
+
var fields = Object.entries(item).find(function (el) {
|
|
1068
|
+
return el[0] === filterField;
|
|
1069
|
+
});
|
|
1070
|
+
return fields;
|
|
1071
|
+
});
|
|
1072
|
+
Object.values(matchedFields).map(function (model) {
|
|
1073
|
+
return Array.isArray(model) ? model : [model];
|
|
1074
|
+
}).map(function (item) {
|
|
1075
|
+
if (typeof item[1] === "number" && typeof item[1] !== "object") {
|
|
1076
|
+
operators = filterParameters;
|
|
1077
|
+
} else if (typeof item[1] !== "number" && typeof item[1] !== "object" && typeof item[1] === "string") {
|
|
1078
|
+
operators = [{
|
|
1079
|
+
value: "==",
|
|
1080
|
+
label: "Equality"
|
|
1081
|
+
}, {
|
|
1082
|
+
value: "!=",
|
|
1083
|
+
label: "Inequality"
|
|
1084
|
+
}];
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1088
|
+
queryOptions: operators,
|
|
1089
|
+
docTypes: docTypes,
|
|
1090
|
+
sanityFields: sanityFields[0]
|
|
1091
|
+
});
|
|
1092
|
+
if (filterField && !filterParameter && !filterValue) {
|
|
1093
|
+
return React.createElement("div", null, "Please specify a Filter Parameter and a Filter Value");
|
|
1094
|
+
}
|
|
1095
|
+
if (filterField && filterParameter && !filterValue) {
|
|
1096
|
+
return React.createElement("div", null, "Please specify a Filter Value");
|
|
1097
|
+
}
|
|
1098
|
+
if (!filterField && !filterParameter && filterValue) {
|
|
1099
|
+
return React.createElement("div", null, "Please specify a Filter Field and a Filter Parameter");
|
|
1100
|
+
}
|
|
1101
|
+
if (!filterField && filterParameter && !filterValue) {
|
|
1102
|
+
return React.createElement("div", null, "Please specify a Filter Field and a Filter Value");
|
|
1103
|
+
}
|
|
1104
|
+
var repElements;
|
|
1105
|
+
var imageBuilder = imageUrlBuilder(sanity);
|
|
1106
|
+
if (filteredData) {
|
|
1107
|
+
if (filteredData.length === 0) {
|
|
1108
|
+
return React.createElement("div", null, "No published types found");
|
|
1109
|
+
}
|
|
1110
|
+
repElements = filteredData.map(function (item, index) {
|
|
1111
|
+
Object.keys(item).forEach(function (field) {
|
|
1112
|
+
if (item[field]._type === "image") {
|
|
1113
|
+
item[field].imgUrl = imageBuilder.image(item[field]).ignoreImageParams().toString();
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
return React.createElement(DataProvider, {
|
|
1117
|
+
key: item._id,
|
|
1118
|
+
name: "sanityItem",
|
|
1119
|
+
data: item,
|
|
1120
|
+
hidden: true
|
|
1121
|
+
}, React.createElement(DataProvider, {
|
|
1122
|
+
name: makeDataProviderName(docType),
|
|
1123
|
+
data: item
|
|
1124
|
+
}, repeatedElement(index, children)));
|
|
1125
|
+
});
|
|
1126
|
+
} else {
|
|
1127
|
+
repElements = noAutoRepeat ? children : response.map(function (item, index) {
|
|
1128
|
+
Object.keys(item).forEach(function (field) {
|
|
1129
|
+
if (item[field]._type === "image") {
|
|
1130
|
+
item[field].imgUrl = imageBuilder.image(item[field]).ignoreImageParams().toString();
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
return docType ? React.createElement(DataProvider, {
|
|
1134
|
+
key: item._id,
|
|
1135
|
+
name: "sanityItem",
|
|
1136
|
+
data: item,
|
|
1137
|
+
hidden: true
|
|
1138
|
+
}, React.createElement(DataProvider, {
|
|
1139
|
+
name: makeDataProviderName(docType),
|
|
1140
|
+
data: item
|
|
1141
|
+
}, repeatedElement(index, children))) : React.createElement(DataProvider, {
|
|
1142
|
+
key: item._id,
|
|
1143
|
+
name: "sanityItem",
|
|
1144
|
+
data: item
|
|
1145
|
+
}, repeatedElement(index, children));
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
return React.createElement(DataProvider, {
|
|
1149
|
+
name: "sanityItems",
|
|
1150
|
+
data: response
|
|
1151
|
+
}, noLayout ? React.createElement(React.Fragment, null, " ", repElements, " ") : React.createElement("div", {
|
|
1048
1152
|
className: className
|
|
1049
|
-
}, " ", repElements, " ");
|
|
1153
|
+
}, " ", repElements, " "));
|
|
1050
1154
|
}
|
|
1051
1155
|
var sanityFieldMeta = {
|
|
1052
1156
|
name: "SanityField",
|
|
@@ -1064,7 +1168,6 @@ var sanityFieldMeta = {
|
|
|
1064
1168
|
type: "choice",
|
|
1065
1169
|
options: function options(props, ctx) {
|
|
1066
1170
|
var _ctx$fields;
|
|
1067
|
-
|
|
1068
1171
|
return (_ctx$fields = ctx == null ? void 0 : ctx.fields) != null ? _ctx$fields : [];
|
|
1069
1172
|
},
|
|
1070
1173
|
displayName: "Field",
|
|
@@ -1072,18 +1175,16 @@ var sanityFieldMeta = {
|
|
|
1072
1175
|
}
|
|
1073
1176
|
}
|
|
1074
1177
|
};
|
|
1075
|
-
function SanityField(
|
|
1076
|
-
var className =
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1178
|
+
function SanityField(_ref6) {
|
|
1179
|
+
var className = _ref6.className,
|
|
1180
|
+
path = _ref6.path,
|
|
1181
|
+
field = _ref6.field,
|
|
1182
|
+
setControlContextData = _ref6.setControlContextData;
|
|
1080
1183
|
var item = useSelector("sanityItem");
|
|
1081
|
-
|
|
1082
1184
|
if (!item) {
|
|
1083
1185
|
return React.createElement("div", null, "SanityField must be used within a SanityFetcher");
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1186
|
+
}
|
|
1187
|
+
// Getting only fields that aren't objects
|
|
1087
1188
|
var displayableFields = Object.keys(item).filter(function (field) {
|
|
1088
1189
|
var value = get(item, field);
|
|
1089
1190
|
return typeof value !== "object" || value._type === "image";
|
|
@@ -1092,21 +1193,17 @@ function SanityField(_ref5) {
|
|
|
1092
1193
|
fields: displayableFields,
|
|
1093
1194
|
isImage: false
|
|
1094
1195
|
});
|
|
1095
|
-
|
|
1096
1196
|
if (!path && !field) {
|
|
1097
1197
|
return React.createElement("div", null, "Please specify a valid path or select a field.");
|
|
1098
1198
|
}
|
|
1099
|
-
|
|
1100
1199
|
if (!path) {
|
|
1101
1200
|
path = field;
|
|
1102
1201
|
}
|
|
1103
|
-
|
|
1104
1202
|
var data = get(item, path);
|
|
1105
1203
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1106
1204
|
fields: displayableFields,
|
|
1107
1205
|
isImage: (data == null ? void 0 : data._type) == "image"
|
|
1108
1206
|
});
|
|
1109
|
-
|
|
1110
1207
|
if (!data) {
|
|
1111
1208
|
return React.createElement("div", null, "Please specify a valid path.");
|
|
1112
1209
|
} else if ((data == null ? void 0 : data._type) === "image") {
|
|
@@ -1129,15 +1226,12 @@ function registerAll(loader) {
|
|
|
1129
1226
|
registerComponent(Component, defaultMeta);
|
|
1130
1227
|
}
|
|
1131
1228
|
};
|
|
1132
|
-
|
|
1133
1229
|
if (loader) {
|
|
1134
1230
|
loader.registerGlobalContext(SanityCredentialsProvider, sanityCredentialsProviderMeta);
|
|
1135
1231
|
} else {
|
|
1136
1232
|
registerGlobalContext(SanityCredentialsProvider, sanityCredentialsProviderMeta);
|
|
1137
1233
|
}
|
|
1138
|
-
|
|
1139
1234
|
_registerComponent(SanityFetcher, sanityFetcherMeta);
|
|
1140
|
-
|
|
1141
1235
|
_registerComponent(SanityField, sanityFieldMeta);
|
|
1142
1236
|
}
|
|
1143
1237
|
|