@nexo-labs/payload-taxonomies 0.8.2-test-10 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,1045 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ COLLECTION_SLUG_TAXONOMY: () => COLLECTION_SLUG_TAXONOMY,
24
+ buildTaxonomizedCollection: () => buildTaxonomizedCollection,
25
+ taxonomiesCollection: () => taxonomiesCollection,
26
+ taxonomyRelationship: () => taxonomyRelationship
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/taxonomy.ts
31
+ var COLLECTION_SLUG_TAXONOMY = "taxonomy";
32
+ var taxonomiesCollection = (config) => ({
33
+ ...config,
34
+ slug: COLLECTION_SLUG_TAXONOMY,
35
+ labels: {
36
+ singular: "Taxonomia",
37
+ plural: "Taxonomias"
38
+ },
39
+ admin: {
40
+ useAsTitle: "singular_name",
41
+ group: "Contenido"
42
+ },
43
+ fields: [
44
+ {
45
+ name: "singular_name",
46
+ label: "Nombre singular",
47
+ type: "text",
48
+ localized: true,
49
+ required: true
50
+ },
51
+ {
52
+ name: "plural_name",
53
+ label: "Nombre plural",
54
+ type: "text",
55
+ localized: true,
56
+ required: false
57
+ },
58
+ {
59
+ name: "payload",
60
+ label: "Payload Adicional",
61
+ type: "json",
62
+ required: false
63
+ },
64
+ ...config.fields ?? []
65
+ ]
66
+ });
67
+
68
+ // ../../node_modules/.pnpm/jsep@1.4.0/node_modules/jsep/dist/jsep.js
69
+ var Hooks = class {
70
+ /**
71
+ * @callback HookCallback
72
+ * @this {*|Jsep} this
73
+ * @param {Jsep} env
74
+ * @returns: void
75
+ */
76
+ /**
77
+ * Adds the given callback to the list of callbacks for the given hook.
78
+ *
79
+ * The callback will be invoked when the hook it is registered for is run.
80
+ *
81
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
82
+ *
83
+ * @param {string|object} name The name of the hook, or an object of callbacks keyed by name
84
+ * @param {HookCallback|boolean} callback The callback function which is given environment variables.
85
+ * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
86
+ * @public
87
+ */
88
+ add(name, callback, first) {
89
+ if (typeof arguments[0] != "string") {
90
+ for (let name2 in arguments[0]) {
91
+ this.add(name2, arguments[0][name2], arguments[1]);
92
+ }
93
+ } else {
94
+ (Array.isArray(name) ? name : [name]).forEach(function(name2) {
95
+ this[name2] = this[name2] || [];
96
+ if (callback) {
97
+ this[name2][first ? "unshift" : "push"](callback);
98
+ }
99
+ }, this);
100
+ }
101
+ }
102
+ /**
103
+ * Runs a hook invoking all registered callbacks with the given environment variables.
104
+ *
105
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
106
+ *
107
+ * @param {string} name The name of the hook.
108
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
109
+ * @public
110
+ */
111
+ run(name, env) {
112
+ this[name] = this[name] || [];
113
+ this[name].forEach(function(callback) {
114
+ callback.call(env && env.context ? env.context : env, env);
115
+ });
116
+ }
117
+ };
118
+ var Plugins = class {
119
+ constructor(jsep2) {
120
+ this.jsep = jsep2;
121
+ this.registered = {};
122
+ }
123
+ /**
124
+ * @callback PluginSetup
125
+ * @this {Jsep} jsep
126
+ * @returns: void
127
+ */
128
+ /**
129
+ * Adds the given plugin(s) to the registry
130
+ *
131
+ * @param {object} plugins
132
+ * @param {string} plugins.name The name of the plugin
133
+ * @param {PluginSetup} plugins.init The init function
134
+ * @public
135
+ */
136
+ register(...plugins) {
137
+ plugins.forEach((plugin) => {
138
+ if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
139
+ throw new Error("Invalid JSEP plugin format");
140
+ }
141
+ if (this.registered[plugin.name]) {
142
+ return;
143
+ }
144
+ plugin.init(this.jsep);
145
+ this.registered[plugin.name] = plugin;
146
+ });
147
+ }
148
+ };
149
+ var Jsep = class _Jsep {
150
+ /**
151
+ * @returns {string}
152
+ */
153
+ static get version() {
154
+ return "1.4.0";
155
+ }
156
+ /**
157
+ * @returns {string}
158
+ */
159
+ static toString() {
160
+ return "JavaScript Expression Parser (JSEP) v" + _Jsep.version;
161
+ }
162
+ // ==================== CONFIG ================================
163
+ /**
164
+ * @method addUnaryOp
165
+ * @param {string} op_name The name of the unary op to add
166
+ * @returns {Jsep}
167
+ */
168
+ static addUnaryOp(op_name) {
169
+ _Jsep.max_unop_len = Math.max(op_name.length, _Jsep.max_unop_len);
170
+ _Jsep.unary_ops[op_name] = 1;
171
+ return _Jsep;
172
+ }
173
+ /**
174
+ * @method jsep.addBinaryOp
175
+ * @param {string} op_name The name of the binary op to add
176
+ * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
177
+ * @param {boolean} [isRightAssociative=false] whether operator is right-associative
178
+ * @returns {Jsep}
179
+ */
180
+ static addBinaryOp(op_name, precedence, isRightAssociative) {
181
+ _Jsep.max_binop_len = Math.max(op_name.length, _Jsep.max_binop_len);
182
+ _Jsep.binary_ops[op_name] = precedence;
183
+ if (isRightAssociative) {
184
+ _Jsep.right_associative.add(op_name);
185
+ } else {
186
+ _Jsep.right_associative.delete(op_name);
187
+ }
188
+ return _Jsep;
189
+ }
190
+ /**
191
+ * @method addIdentifierChar
192
+ * @param {string} char The additional character to treat as a valid part of an identifier
193
+ * @returns {Jsep}
194
+ */
195
+ static addIdentifierChar(char) {
196
+ _Jsep.additional_identifier_chars.add(char);
197
+ return _Jsep;
198
+ }
199
+ /**
200
+ * @method addLiteral
201
+ * @param {string} literal_name The name of the literal to add
202
+ * @param {*} literal_value The value of the literal
203
+ * @returns {Jsep}
204
+ */
205
+ static addLiteral(literal_name, literal_value) {
206
+ _Jsep.literals[literal_name] = literal_value;
207
+ return _Jsep;
208
+ }
209
+ /**
210
+ * @method removeUnaryOp
211
+ * @param {string} op_name The name of the unary op to remove
212
+ * @returns {Jsep}
213
+ */
214
+ static removeUnaryOp(op_name) {
215
+ delete _Jsep.unary_ops[op_name];
216
+ if (op_name.length === _Jsep.max_unop_len) {
217
+ _Jsep.max_unop_len = _Jsep.getMaxKeyLen(_Jsep.unary_ops);
218
+ }
219
+ return _Jsep;
220
+ }
221
+ /**
222
+ * @method removeAllUnaryOps
223
+ * @returns {Jsep}
224
+ */
225
+ static removeAllUnaryOps() {
226
+ _Jsep.unary_ops = {};
227
+ _Jsep.max_unop_len = 0;
228
+ return _Jsep;
229
+ }
230
+ /**
231
+ * @method removeIdentifierChar
232
+ * @param {string} char The additional character to stop treating as a valid part of an identifier
233
+ * @returns {Jsep}
234
+ */
235
+ static removeIdentifierChar(char) {
236
+ _Jsep.additional_identifier_chars.delete(char);
237
+ return _Jsep;
238
+ }
239
+ /**
240
+ * @method removeBinaryOp
241
+ * @param {string} op_name The name of the binary op to remove
242
+ * @returns {Jsep}
243
+ */
244
+ static removeBinaryOp(op_name) {
245
+ delete _Jsep.binary_ops[op_name];
246
+ if (op_name.length === _Jsep.max_binop_len) {
247
+ _Jsep.max_binop_len = _Jsep.getMaxKeyLen(_Jsep.binary_ops);
248
+ }
249
+ _Jsep.right_associative.delete(op_name);
250
+ return _Jsep;
251
+ }
252
+ /**
253
+ * @method removeAllBinaryOps
254
+ * @returns {Jsep}
255
+ */
256
+ static removeAllBinaryOps() {
257
+ _Jsep.binary_ops = {};
258
+ _Jsep.max_binop_len = 0;
259
+ return _Jsep;
260
+ }
261
+ /**
262
+ * @method removeLiteral
263
+ * @param {string} literal_name The name of the literal to remove
264
+ * @returns {Jsep}
265
+ */
266
+ static removeLiteral(literal_name) {
267
+ delete _Jsep.literals[literal_name];
268
+ return _Jsep;
269
+ }
270
+ /**
271
+ * @method removeAllLiterals
272
+ * @returns {Jsep}
273
+ */
274
+ static removeAllLiterals() {
275
+ _Jsep.literals = {};
276
+ return _Jsep;
277
+ }
278
+ // ==================== END CONFIG ============================
279
+ /**
280
+ * @returns {string}
281
+ */
282
+ get char() {
283
+ return this.expr.charAt(this.index);
284
+ }
285
+ /**
286
+ * @returns {number}
287
+ */
288
+ get code() {
289
+ return this.expr.charCodeAt(this.index);
290
+ }
291
+ /**
292
+ * @param {string} expr a string with the passed in express
293
+ * @returns Jsep
294
+ */
295
+ constructor(expr) {
296
+ this.expr = expr;
297
+ this.index = 0;
298
+ }
299
+ /**
300
+ * static top-level parser
301
+ * @returns {jsep.Expression}
302
+ */
303
+ static parse(expr) {
304
+ return new _Jsep(expr).parse();
305
+ }
306
+ /**
307
+ * Get the longest key length of any object
308
+ * @param {object} obj
309
+ * @returns {number}
310
+ */
311
+ static getMaxKeyLen(obj) {
312
+ return Math.max(0, ...Object.keys(obj).map((k) => k.length));
313
+ }
314
+ /**
315
+ * `ch` is a character code in the next three functions
316
+ * @param {number} ch
317
+ * @returns {boolean}
318
+ */
319
+ static isDecimalDigit(ch) {
320
+ return ch >= 48 && ch <= 57;
321
+ }
322
+ /**
323
+ * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
324
+ * @param {string} op_val
325
+ * @returns {number}
326
+ */
327
+ static binaryPrecedence(op_val) {
328
+ return _Jsep.binary_ops[op_val] || 0;
329
+ }
330
+ /**
331
+ * Looks for start of identifier
332
+ * @param {number} ch
333
+ * @returns {boolean}
334
+ */
335
+ static isIdentifierStart(ch) {
336
+ return ch >= 65 && ch <= 90 || // A...Z
337
+ ch >= 97 && ch <= 122 || // a...z
338
+ ch >= 128 && !_Jsep.binary_ops[String.fromCharCode(ch)] || // any non-ASCII that is not an operator
339
+ _Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
340
+ }
341
+ /**
342
+ * @param {number} ch
343
+ * @returns {boolean}
344
+ */
345
+ static isIdentifierPart(ch) {
346
+ return _Jsep.isIdentifierStart(ch) || _Jsep.isDecimalDigit(ch);
347
+ }
348
+ /**
349
+ * throw error at index of the expression
350
+ * @param {string} message
351
+ * @throws
352
+ */
353
+ throwError(message) {
354
+ const error = new Error(message + " at character " + this.index);
355
+ error.index = this.index;
356
+ error.description = message;
357
+ throw error;
358
+ }
359
+ /**
360
+ * Run a given hook
361
+ * @param {string} name
362
+ * @param {jsep.Expression|false} [node]
363
+ * @returns {?jsep.Expression}
364
+ */
365
+ runHook(name, node) {
366
+ if (_Jsep.hooks[name]) {
367
+ const env = { context: this, node };
368
+ _Jsep.hooks.run(name, env);
369
+ return env.node;
370
+ }
371
+ return node;
372
+ }
373
+ /**
374
+ * Runs a given hook until one returns a node
375
+ * @param {string} name
376
+ * @returns {?jsep.Expression}
377
+ */
378
+ searchHook(name) {
379
+ if (_Jsep.hooks[name]) {
380
+ const env = { context: this };
381
+ _Jsep.hooks[name].find(function(callback) {
382
+ callback.call(env.context, env);
383
+ return env.node;
384
+ });
385
+ return env.node;
386
+ }
387
+ }
388
+ /**
389
+ * Push `index` up to the next non-space character
390
+ */
391
+ gobbleSpaces() {
392
+ let ch = this.code;
393
+ while (ch === _Jsep.SPACE_CODE || ch === _Jsep.TAB_CODE || ch === _Jsep.LF_CODE || ch === _Jsep.CR_CODE) {
394
+ ch = this.expr.charCodeAt(++this.index);
395
+ }
396
+ this.runHook("gobble-spaces");
397
+ }
398
+ /**
399
+ * Top-level method to parse all expressions and returns compound or single node
400
+ * @returns {jsep.Expression}
401
+ */
402
+ parse() {
403
+ this.runHook("before-all");
404
+ const nodes = this.gobbleExpressions();
405
+ const node = nodes.length === 1 ? nodes[0] : {
406
+ type: _Jsep.COMPOUND,
407
+ body: nodes
408
+ };
409
+ return this.runHook("after-all", node);
410
+ }
411
+ /**
412
+ * top-level parser (but can be reused within as well)
413
+ * @param {number} [untilICode]
414
+ * @returns {jsep.Expression[]}
415
+ */
416
+ gobbleExpressions(untilICode) {
417
+ let nodes = [], ch_i, node;
418
+ while (this.index < this.expr.length) {
419
+ ch_i = this.code;
420
+ if (ch_i === _Jsep.SEMCOL_CODE || ch_i === _Jsep.COMMA_CODE) {
421
+ this.index++;
422
+ } else {
423
+ if (node = this.gobbleExpression()) {
424
+ nodes.push(node);
425
+ } else if (this.index < this.expr.length) {
426
+ if (ch_i === untilICode) {
427
+ break;
428
+ }
429
+ this.throwError('Unexpected "' + this.char + '"');
430
+ }
431
+ }
432
+ }
433
+ return nodes;
434
+ }
435
+ /**
436
+ * The main parsing function.
437
+ * @returns {?jsep.Expression}
438
+ */
439
+ gobbleExpression() {
440
+ const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
441
+ this.gobbleSpaces();
442
+ return this.runHook("after-expression", node);
443
+ }
444
+ /**
445
+ * Search for the operation portion of the string (e.g. `+`, `===`)
446
+ * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
447
+ * and move down from 3 to 2 to 1 character until a matching binary operation is found
448
+ * then, return that binary operation
449
+ * @returns {string|boolean}
450
+ */
451
+ gobbleBinaryOp() {
452
+ this.gobbleSpaces();
453
+ let to_check = this.expr.substr(this.index, _Jsep.max_binop_len);
454
+ let tc_len = to_check.length;
455
+ while (tc_len > 0) {
456
+ if (_Jsep.binary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
457
+ this.index += tc_len;
458
+ return to_check;
459
+ }
460
+ to_check = to_check.substr(0, --tc_len);
461
+ }
462
+ return false;
463
+ }
464
+ /**
465
+ * This function is responsible for gobbling an individual expression,
466
+ * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
467
+ * @returns {?jsep.BinaryExpression}
468
+ */
469
+ gobbleBinaryExpression() {
470
+ let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
471
+ left = this.gobbleToken();
472
+ if (!left) {
473
+ return left;
474
+ }
475
+ biop = this.gobbleBinaryOp();
476
+ if (!biop) {
477
+ return left;
478
+ }
479
+ biop_info = { value: biop, prec: _Jsep.binaryPrecedence(biop), right_a: _Jsep.right_associative.has(biop) };
480
+ right = this.gobbleToken();
481
+ if (!right) {
482
+ this.throwError("Expected expression after " + biop);
483
+ }
484
+ stack = [left, biop_info, right];
485
+ while (biop = this.gobbleBinaryOp()) {
486
+ prec = _Jsep.binaryPrecedence(biop);
487
+ if (prec === 0) {
488
+ this.index -= biop.length;
489
+ break;
490
+ }
491
+ biop_info = { value: biop, prec, right_a: _Jsep.right_associative.has(biop) };
492
+ cur_biop = biop;
493
+ const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
494
+ while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
495
+ right = stack.pop();
496
+ biop = stack.pop().value;
497
+ left = stack.pop();
498
+ node = {
499
+ type: _Jsep.BINARY_EXP,
500
+ operator: biop,
501
+ left,
502
+ right
503
+ };
504
+ stack.push(node);
505
+ }
506
+ node = this.gobbleToken();
507
+ if (!node) {
508
+ this.throwError("Expected expression after " + cur_biop);
509
+ }
510
+ stack.push(biop_info, node);
511
+ }
512
+ i = stack.length - 1;
513
+ node = stack[i];
514
+ while (i > 1) {
515
+ node = {
516
+ type: _Jsep.BINARY_EXP,
517
+ operator: stack[i - 1].value,
518
+ left: stack[i - 2],
519
+ right: node
520
+ };
521
+ i -= 2;
522
+ }
523
+ return node;
524
+ }
525
+ /**
526
+ * An individual part of a binary expression:
527
+ * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
528
+ * @returns {boolean|jsep.Expression}
529
+ */
530
+ gobbleToken() {
531
+ let ch, to_check, tc_len, node;
532
+ this.gobbleSpaces();
533
+ node = this.searchHook("gobble-token");
534
+ if (node) {
535
+ return this.runHook("after-token", node);
536
+ }
537
+ ch = this.code;
538
+ if (_Jsep.isDecimalDigit(ch) || ch === _Jsep.PERIOD_CODE) {
539
+ return this.gobbleNumericLiteral();
540
+ }
541
+ if (ch === _Jsep.SQUOTE_CODE || ch === _Jsep.DQUOTE_CODE) {
542
+ node = this.gobbleStringLiteral();
543
+ } else if (ch === _Jsep.OBRACK_CODE) {
544
+ node = this.gobbleArray();
545
+ } else {
546
+ to_check = this.expr.substr(this.index, _Jsep.max_unop_len);
547
+ tc_len = to_check.length;
548
+ while (tc_len > 0) {
549
+ if (_Jsep.unary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
550
+ this.index += tc_len;
551
+ const argument = this.gobbleToken();
552
+ if (!argument) {
553
+ this.throwError("missing unaryOp argument");
554
+ }
555
+ return this.runHook("after-token", {
556
+ type: _Jsep.UNARY_EXP,
557
+ operator: to_check,
558
+ argument,
559
+ prefix: true
560
+ });
561
+ }
562
+ to_check = to_check.substr(0, --tc_len);
563
+ }
564
+ if (_Jsep.isIdentifierStart(ch)) {
565
+ node = this.gobbleIdentifier();
566
+ if (_Jsep.literals.hasOwnProperty(node.name)) {
567
+ node = {
568
+ type: _Jsep.LITERAL,
569
+ value: _Jsep.literals[node.name],
570
+ raw: node.name
571
+ };
572
+ } else if (node.name === _Jsep.this_str) {
573
+ node = { type: _Jsep.THIS_EXP };
574
+ }
575
+ } else if (ch === _Jsep.OPAREN_CODE) {
576
+ node = this.gobbleGroup();
577
+ }
578
+ }
579
+ if (!node) {
580
+ return this.runHook("after-token", false);
581
+ }
582
+ node = this.gobbleTokenProperty(node);
583
+ return this.runHook("after-token", node);
584
+ }
585
+ /**
586
+ * Gobble properties of of identifiers/strings/arrays/groups.
587
+ * e.g. `foo`, `bar.baz`, `foo['bar'].baz`
588
+ * It also gobbles function calls:
589
+ * e.g. `Math.acos(obj.angle)`
590
+ * @param {jsep.Expression} node
591
+ * @returns {jsep.Expression}
592
+ */
593
+ gobbleTokenProperty(node) {
594
+ this.gobbleSpaces();
595
+ let ch = this.code;
596
+ while (ch === _Jsep.PERIOD_CODE || ch === _Jsep.OBRACK_CODE || ch === _Jsep.OPAREN_CODE || ch === _Jsep.QUMARK_CODE) {
597
+ let optional;
598
+ if (ch === _Jsep.QUMARK_CODE) {
599
+ if (this.expr.charCodeAt(this.index + 1) !== _Jsep.PERIOD_CODE) {
600
+ break;
601
+ }
602
+ optional = true;
603
+ this.index += 2;
604
+ this.gobbleSpaces();
605
+ ch = this.code;
606
+ }
607
+ this.index++;
608
+ if (ch === _Jsep.OBRACK_CODE) {
609
+ node = {
610
+ type: _Jsep.MEMBER_EXP,
611
+ computed: true,
612
+ object: node,
613
+ property: this.gobbleExpression()
614
+ };
615
+ if (!node.property) {
616
+ this.throwError('Unexpected "' + this.char + '"');
617
+ }
618
+ this.gobbleSpaces();
619
+ ch = this.code;
620
+ if (ch !== _Jsep.CBRACK_CODE) {
621
+ this.throwError("Unclosed [");
622
+ }
623
+ this.index++;
624
+ } else if (ch === _Jsep.OPAREN_CODE) {
625
+ node = {
626
+ type: _Jsep.CALL_EXP,
627
+ "arguments": this.gobbleArguments(_Jsep.CPAREN_CODE),
628
+ callee: node
629
+ };
630
+ } else if (ch === _Jsep.PERIOD_CODE || optional) {
631
+ if (optional) {
632
+ this.index--;
633
+ }
634
+ this.gobbleSpaces();
635
+ node = {
636
+ type: _Jsep.MEMBER_EXP,
637
+ computed: false,
638
+ object: node,
639
+ property: this.gobbleIdentifier()
640
+ };
641
+ }
642
+ if (optional) {
643
+ node.optional = true;
644
+ }
645
+ this.gobbleSpaces();
646
+ ch = this.code;
647
+ }
648
+ return node;
649
+ }
650
+ /**
651
+ * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
652
+ * keep track of everything in the numeric literal and then calling `parseFloat` on that string
653
+ * @returns {jsep.Literal}
654
+ */
655
+ gobbleNumericLiteral() {
656
+ let number = "", ch, chCode;
657
+ while (_Jsep.isDecimalDigit(this.code)) {
658
+ number += this.expr.charAt(this.index++);
659
+ }
660
+ if (this.code === _Jsep.PERIOD_CODE) {
661
+ number += this.expr.charAt(this.index++);
662
+ while (_Jsep.isDecimalDigit(this.code)) {
663
+ number += this.expr.charAt(this.index++);
664
+ }
665
+ }
666
+ ch = this.char;
667
+ if (ch === "e" || ch === "E") {
668
+ number += this.expr.charAt(this.index++);
669
+ ch = this.char;
670
+ if (ch === "+" || ch === "-") {
671
+ number += this.expr.charAt(this.index++);
672
+ }
673
+ while (_Jsep.isDecimalDigit(this.code)) {
674
+ number += this.expr.charAt(this.index++);
675
+ }
676
+ if (!_Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
677
+ this.throwError("Expected exponent (" + number + this.char + ")");
678
+ }
679
+ }
680
+ chCode = this.code;
681
+ if (_Jsep.isIdentifierStart(chCode)) {
682
+ this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
683
+ } else if (chCode === _Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === _Jsep.PERIOD_CODE) {
684
+ this.throwError("Unexpected period");
685
+ }
686
+ return {
687
+ type: _Jsep.LITERAL,
688
+ value: parseFloat(number),
689
+ raw: number
690
+ };
691
+ }
692
+ /**
693
+ * Parses a string literal, staring with single or double quotes with basic support for escape codes
694
+ * e.g. `"hello world"`, `'this is\nJSEP'`
695
+ * @returns {jsep.Literal}
696
+ */
697
+ gobbleStringLiteral() {
698
+ let str = "";
699
+ const startIndex = this.index;
700
+ const quote = this.expr.charAt(this.index++);
701
+ let closed = false;
702
+ while (this.index < this.expr.length) {
703
+ let ch = this.expr.charAt(this.index++);
704
+ if (ch === quote) {
705
+ closed = true;
706
+ break;
707
+ } else if (ch === "\\") {
708
+ ch = this.expr.charAt(this.index++);
709
+ switch (ch) {
710
+ case "n":
711
+ str += "\n";
712
+ break;
713
+ case "r":
714
+ str += "\r";
715
+ break;
716
+ case "t":
717
+ str += " ";
718
+ break;
719
+ case "b":
720
+ str += "\b";
721
+ break;
722
+ case "f":
723
+ str += "\f";
724
+ break;
725
+ case "v":
726
+ str += "\v";
727
+ break;
728
+ default:
729
+ str += ch;
730
+ }
731
+ } else {
732
+ str += ch;
733
+ }
734
+ }
735
+ if (!closed) {
736
+ this.throwError('Unclosed quote after "' + str + '"');
737
+ }
738
+ return {
739
+ type: _Jsep.LITERAL,
740
+ value: str,
741
+ raw: this.expr.substring(startIndex, this.index)
742
+ };
743
+ }
744
+ /**
745
+ * Gobbles only identifiers
746
+ * e.g.: `foo`, `_value`, `$x1`
747
+ * Also, this function checks if that identifier is a literal:
748
+ * (e.g. `true`, `false`, `null`) or `this`
749
+ * @returns {jsep.Identifier}
750
+ */
751
+ gobbleIdentifier() {
752
+ let ch = this.code, start = this.index;
753
+ if (_Jsep.isIdentifierStart(ch)) {
754
+ this.index++;
755
+ } else {
756
+ this.throwError("Unexpected " + this.char);
757
+ }
758
+ while (this.index < this.expr.length) {
759
+ ch = this.code;
760
+ if (_Jsep.isIdentifierPart(ch)) {
761
+ this.index++;
762
+ } else {
763
+ break;
764
+ }
765
+ }
766
+ return {
767
+ type: _Jsep.IDENTIFIER,
768
+ name: this.expr.slice(start, this.index)
769
+ };
770
+ }
771
+ /**
772
+ * Gobbles a list of arguments within the context of a function call
773
+ * or array literal. This function also assumes that the opening character
774
+ * `(` or `[` has already been gobbled, and gobbles expressions and commas
775
+ * until the terminator character `)` or `]` is encountered.
776
+ * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
777
+ * @param {number} termination
778
+ * @returns {jsep.Expression[]}
779
+ */
780
+ gobbleArguments(termination) {
781
+ const args = [];
782
+ let closed = false;
783
+ let separator_count = 0;
784
+ while (this.index < this.expr.length) {
785
+ this.gobbleSpaces();
786
+ let ch_i = this.code;
787
+ if (ch_i === termination) {
788
+ closed = true;
789
+ this.index++;
790
+ if (termination === _Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
791
+ this.throwError("Unexpected token " + String.fromCharCode(termination));
792
+ }
793
+ break;
794
+ } else if (ch_i === _Jsep.COMMA_CODE) {
795
+ this.index++;
796
+ separator_count++;
797
+ if (separator_count !== args.length) {
798
+ if (termination === _Jsep.CPAREN_CODE) {
799
+ this.throwError("Unexpected token ,");
800
+ } else if (termination === _Jsep.CBRACK_CODE) {
801
+ for (let arg = args.length; arg < separator_count; arg++) {
802
+ args.push(null);
803
+ }
804
+ }
805
+ }
806
+ } else if (args.length !== separator_count && separator_count !== 0) {
807
+ this.throwError("Expected comma");
808
+ } else {
809
+ const node = this.gobbleExpression();
810
+ if (!node || node.type === _Jsep.COMPOUND) {
811
+ this.throwError("Expected comma");
812
+ }
813
+ args.push(node);
814
+ }
815
+ }
816
+ if (!closed) {
817
+ this.throwError("Expected " + String.fromCharCode(termination));
818
+ }
819
+ return args;
820
+ }
821
+ /**
822
+ * Responsible for parsing a group of things within parentheses `()`
823
+ * that have no identifier in front (so not a function call)
824
+ * This function assumes that it needs to gobble the opening parenthesis
825
+ * and then tries to gobble everything within that parenthesis, assuming
826
+ * that the next thing it should see is the close parenthesis. If not,
827
+ * then the expression probably doesn't have a `)`
828
+ * @returns {boolean|jsep.Expression}
829
+ */
830
+ gobbleGroup() {
831
+ this.index++;
832
+ let nodes = this.gobbleExpressions(_Jsep.CPAREN_CODE);
833
+ if (this.code === _Jsep.CPAREN_CODE) {
834
+ this.index++;
835
+ if (nodes.length === 1) {
836
+ return nodes[0];
837
+ } else if (!nodes.length) {
838
+ return false;
839
+ } else {
840
+ return {
841
+ type: _Jsep.SEQUENCE_EXP,
842
+ expressions: nodes
843
+ };
844
+ }
845
+ } else {
846
+ this.throwError("Unclosed (");
847
+ }
848
+ }
849
+ /**
850
+ * Responsible for parsing Array literals `[1, 2, 3]`
851
+ * This function assumes that it needs to gobble the opening bracket
852
+ * and then tries to gobble the expressions as arguments.
853
+ * @returns {jsep.ArrayExpression}
854
+ */
855
+ gobbleArray() {
856
+ this.index++;
857
+ return {
858
+ type: _Jsep.ARRAY_EXP,
859
+ elements: this.gobbleArguments(_Jsep.CBRACK_CODE)
860
+ };
861
+ }
862
+ };
863
+ var hooks = new Hooks();
864
+ Object.assign(Jsep, {
865
+ hooks,
866
+ plugins: new Plugins(Jsep),
867
+ // Node Types
868
+ // ----------
869
+ // This is the full set of types that any JSEP node can be.
870
+ // Store them here to save space when minified
871
+ COMPOUND: "Compound",
872
+ SEQUENCE_EXP: "SequenceExpression",
873
+ IDENTIFIER: "Identifier",
874
+ MEMBER_EXP: "MemberExpression",
875
+ LITERAL: "Literal",
876
+ THIS_EXP: "ThisExpression",
877
+ CALL_EXP: "CallExpression",
878
+ UNARY_EXP: "UnaryExpression",
879
+ BINARY_EXP: "BinaryExpression",
880
+ ARRAY_EXP: "ArrayExpression",
881
+ TAB_CODE: 9,
882
+ LF_CODE: 10,
883
+ CR_CODE: 13,
884
+ SPACE_CODE: 32,
885
+ PERIOD_CODE: 46,
886
+ // '.'
887
+ COMMA_CODE: 44,
888
+ // ','
889
+ SQUOTE_CODE: 39,
890
+ // single quote
891
+ DQUOTE_CODE: 34,
892
+ // double quotes
893
+ OPAREN_CODE: 40,
894
+ // (
895
+ CPAREN_CODE: 41,
896
+ // )
897
+ OBRACK_CODE: 91,
898
+ // [
899
+ CBRACK_CODE: 93,
900
+ // ]
901
+ QUMARK_CODE: 63,
902
+ // ?
903
+ SEMCOL_CODE: 59,
904
+ // ;
905
+ COLON_CODE: 58,
906
+ // :
907
+ // Operations
908
+ // ----------
909
+ // Use a quickly-accessible map to store all of the unary operators
910
+ // Values are set to `1` (it really doesn't matter)
911
+ unary_ops: {
912
+ "-": 1,
913
+ "!": 1,
914
+ "~": 1,
915
+ "+": 1
916
+ },
917
+ // Also use a map for the binary operations but set their values to their
918
+ // binary precedence for quick reference (higher number = higher precedence)
919
+ // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
920
+ binary_ops: {
921
+ "||": 1,
922
+ "??": 1,
923
+ "&&": 2,
924
+ "|": 3,
925
+ "^": 4,
926
+ "&": 5,
927
+ "==": 6,
928
+ "!=": 6,
929
+ "===": 6,
930
+ "!==": 6,
931
+ "<": 7,
932
+ ">": 7,
933
+ "<=": 7,
934
+ ">=": 7,
935
+ "<<": 8,
936
+ ">>": 8,
937
+ ">>>": 8,
938
+ "+": 9,
939
+ "-": 9,
940
+ "*": 10,
941
+ "/": 10,
942
+ "%": 10,
943
+ "**": 11
944
+ },
945
+ // sets specific binary_ops as right-associative
946
+ right_associative: /* @__PURE__ */ new Set(["**"]),
947
+ // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
948
+ additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
949
+ // Literals
950
+ // ----------
951
+ // Store the values to return for the various literals we may encounter
952
+ literals: {
953
+ "true": true,
954
+ "false": false,
955
+ "null": null
956
+ },
957
+ // Except for `this`, which is special. This could be changed to something like `'self'` as well
958
+ this_str: "this"
959
+ });
960
+ Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
961
+ Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
962
+ var jsep = (expr) => new Jsep(expr).parse();
963
+ var stdClassProps = Object.getOwnPropertyNames(class Test {
964
+ });
965
+ Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === void 0).forEach((m) => {
966
+ jsep[m] = Jsep[m];
967
+ });
968
+ jsep.Jsep = Jsep;
969
+ var CONDITIONAL_EXP = "ConditionalExpression";
970
+ var ternary = {
971
+ name: "ternary",
972
+ init(jsep2) {
973
+ jsep2.hooks.add("after-expression", function gobbleTernary(env) {
974
+ if (env.node && this.code === jsep2.QUMARK_CODE) {
975
+ this.index++;
976
+ const test = env.node;
977
+ const consequent = this.gobbleExpression();
978
+ if (!consequent) {
979
+ this.throwError("Expected expression");
980
+ }
981
+ this.gobbleSpaces();
982
+ if (this.code === jsep2.COLON_CODE) {
983
+ this.index++;
984
+ const alternate = this.gobbleExpression();
985
+ if (!alternate) {
986
+ this.throwError("Expected expression");
987
+ }
988
+ env.node = {
989
+ type: CONDITIONAL_EXP,
990
+ test,
991
+ consequent,
992
+ alternate
993
+ };
994
+ if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
995
+ let newTest = test;
996
+ while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
997
+ newTest = newTest.right;
998
+ }
999
+ env.node.test = newTest.right;
1000
+ newTest.right = env.node;
1001
+ env.node = test;
1002
+ }
1003
+ } else {
1004
+ this.throwError("Expected :");
1005
+ }
1006
+ }
1007
+ });
1008
+ }
1009
+ };
1010
+ jsep.plugins.register(ternary);
1011
+
1012
+ // ../hegel/dist/index.js
1013
+ Array.prototype.mapNotNull = function(callback) {
1014
+ return this.map(callback).filter((item) => item != null);
1015
+ };
1016
+ Array.prototype.cast = function() {
1017
+ return this;
1018
+ };
1019
+
1020
+ // src/taxonomiesRelationshipFields.ts
1021
+ var taxonomyRelationship = {
1022
+ name: "categories",
1023
+ label: "Categor\xEDas",
1024
+ type: "relationship",
1025
+ relationTo: COLLECTION_SLUG_TAXONOMY,
1026
+ defaultValue: [],
1027
+ hasMany: true,
1028
+ required: false
1029
+ };
1030
+
1031
+ // src/buildTaxonomizedCollection.ts
1032
+ var buildTaxonomizedCollection = (config) => {
1033
+ const protoConfigCollection = {
1034
+ ...config,
1035
+ fields: [taxonomyRelationship, ...config.fields]
1036
+ };
1037
+ return protoConfigCollection;
1038
+ };
1039
+ // Annotate the CommonJS export names for ESM import in node:
1040
+ 0 && (module.exports = {
1041
+ COLLECTION_SLUG_TAXONOMY,
1042
+ buildTaxonomizedCollection,
1043
+ taxonomiesCollection,
1044
+ taxonomyRelationship
1045
+ });