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