@jaredwray/fumanchu 4.4.0 → 4.5.0
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 +855 -101
- package/dist/index.js +855 -101
- package/package.json +9 -10
package/dist/index.js
CHANGED
|
@@ -49,16 +49,16 @@ var join = (array, separator = ", ") => {
|
|
|
49
49
|
if (!Array.isArray(array)) return "";
|
|
50
50
|
return array.join(separator);
|
|
51
51
|
};
|
|
52
|
-
var forEach = function(collection,
|
|
53
|
-
if (!Array.isArray(collection) || !
|
|
54
|
-
return
|
|
52
|
+
var forEach = function(collection, options2) {
|
|
53
|
+
if (!Array.isArray(collection) || !options2 || typeof options2.fn !== "function") {
|
|
54
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
55
55
|
}
|
|
56
56
|
if (collection.length === 0) {
|
|
57
|
-
return
|
|
57
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
58
58
|
}
|
|
59
59
|
const total = collection.length;
|
|
60
|
-
const hash =
|
|
61
|
-
const baseData =
|
|
60
|
+
const hash = options2.hash ?? {};
|
|
61
|
+
const baseData = options2.data ? { ...options2.data } : void 0;
|
|
62
62
|
let result = "";
|
|
63
63
|
for (let index = 0; index < total; index++) {
|
|
64
64
|
const value = collection[index];
|
|
@@ -79,10 +79,334 @@ var forEach = function(collection, options) {
|
|
|
79
79
|
} else {
|
|
80
80
|
context = { value, ...hash, ...meta };
|
|
81
81
|
}
|
|
82
|
-
result +=
|
|
82
|
+
result += options2.fn(context, { data });
|
|
83
83
|
}
|
|
84
84
|
return result;
|
|
85
85
|
};
|
|
86
|
+
var inArray = function(array, value, options2) {
|
|
87
|
+
if (!Array.isArray(array) || !options2) {
|
|
88
|
+
return "";
|
|
89
|
+
}
|
|
90
|
+
const found = array.includes(value);
|
|
91
|
+
if (found && options2.fn) {
|
|
92
|
+
return options2.fn(this);
|
|
93
|
+
}
|
|
94
|
+
if (!found && options2.inverse) {
|
|
95
|
+
return options2.inverse(this);
|
|
96
|
+
}
|
|
97
|
+
return "";
|
|
98
|
+
};
|
|
99
|
+
var isArray = (value) => {
|
|
100
|
+
return Array.isArray(value);
|
|
101
|
+
};
|
|
102
|
+
var itemAt = (array, idx) => {
|
|
103
|
+
if (!Array.isArray(array)) return void 0;
|
|
104
|
+
return array[idx];
|
|
105
|
+
};
|
|
106
|
+
var equalsLength = function(value, targetLength, options2) {
|
|
107
|
+
const actualLength = length(value);
|
|
108
|
+
const isEqual = actualLength === targetLength;
|
|
109
|
+
if (options2 && (options2.fn || options2.inverse)) {
|
|
110
|
+
if (isEqual && options2.fn) {
|
|
111
|
+
return options2.fn(this);
|
|
112
|
+
}
|
|
113
|
+
if (!isEqual && options2.inverse) {
|
|
114
|
+
return options2.inverse(this);
|
|
115
|
+
}
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
return isEqual;
|
|
119
|
+
};
|
|
120
|
+
var some = function(array, iter, options2) {
|
|
121
|
+
if (!Array.isArray(array) || typeof iter !== "function" || !options2) {
|
|
122
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
123
|
+
}
|
|
124
|
+
const hasSome = array.some(iter);
|
|
125
|
+
if (hasSome && options2.fn) {
|
|
126
|
+
return options2.fn(this);
|
|
127
|
+
}
|
|
128
|
+
if (!hasSome && options2.inverse) {
|
|
129
|
+
return options2.inverse(this);
|
|
130
|
+
}
|
|
131
|
+
return "";
|
|
132
|
+
};
|
|
133
|
+
var eachIndex = function(array, options2) {
|
|
134
|
+
if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
|
|
135
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
136
|
+
}
|
|
137
|
+
if (array.length === 0) {
|
|
138
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
139
|
+
}
|
|
140
|
+
let result = "";
|
|
141
|
+
for (let index = 0; index < array.length; index++) {
|
|
142
|
+
const context = {
|
|
143
|
+
item: array[index],
|
|
144
|
+
index
|
|
145
|
+
};
|
|
146
|
+
result += options2.fn(context);
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
};
|
|
150
|
+
var withAfter = function(array, idx, options2) {
|
|
151
|
+
if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
|
|
152
|
+
return "";
|
|
153
|
+
}
|
|
154
|
+
const sliced = array.slice(idx + 1);
|
|
155
|
+
if (sliced.length === 0) {
|
|
156
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
157
|
+
}
|
|
158
|
+
let result = "";
|
|
159
|
+
for (const item of sliced) {
|
|
160
|
+
result += options2.fn(item);
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
var withBefore = function(array, idx, options2) {
|
|
165
|
+
if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
|
|
166
|
+
return "";
|
|
167
|
+
}
|
|
168
|
+
const sliced = array.slice(0, idx);
|
|
169
|
+
if (sliced.length === 0) {
|
|
170
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
171
|
+
}
|
|
172
|
+
let result = "";
|
|
173
|
+
for (const item of sliced) {
|
|
174
|
+
result += options2.fn(item);
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
};
|
|
178
|
+
var withFirst = function(array, n, options2) {
|
|
179
|
+
let count = 1;
|
|
180
|
+
let opts = options2;
|
|
181
|
+
if (typeof n === "object" && n !== null && !Array.isArray(n)) {
|
|
182
|
+
opts = n;
|
|
183
|
+
} else if (typeof n === "number") {
|
|
184
|
+
count = n;
|
|
185
|
+
}
|
|
186
|
+
if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
|
|
187
|
+
return "";
|
|
188
|
+
}
|
|
189
|
+
if (array.length === 0) {
|
|
190
|
+
return opts.inverse ? opts.inverse(this) ?? "" : "";
|
|
191
|
+
}
|
|
192
|
+
const items = array.slice(0, count);
|
|
193
|
+
let result = "";
|
|
194
|
+
for (const item of items) {
|
|
195
|
+
result += opts.fn(item);
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
};
|
|
199
|
+
var withLast = function(array, n, options2) {
|
|
200
|
+
let count = 1;
|
|
201
|
+
let opts = options2;
|
|
202
|
+
if (typeof n === "object" && n !== null && !Array.isArray(n)) {
|
|
203
|
+
opts = n;
|
|
204
|
+
} else if (typeof n === "number") {
|
|
205
|
+
count = n;
|
|
206
|
+
}
|
|
207
|
+
if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
|
|
208
|
+
return "";
|
|
209
|
+
}
|
|
210
|
+
if (array.length === 0) {
|
|
211
|
+
return opts.inverse ? opts.inverse(this) ?? "" : "";
|
|
212
|
+
}
|
|
213
|
+
const items = array.slice(-count);
|
|
214
|
+
let result = "";
|
|
215
|
+
for (const item of items) {
|
|
216
|
+
result += opts.fn(item);
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
};
|
|
220
|
+
var withGroup = function(array, size, options2) {
|
|
221
|
+
if (!Array.isArray(array) || typeof size !== "number" || size <= 0 || !options2 || typeof options2.fn !== "function") {
|
|
222
|
+
return "";
|
|
223
|
+
}
|
|
224
|
+
if (array.length === 0) {
|
|
225
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
226
|
+
}
|
|
227
|
+
let result = "";
|
|
228
|
+
const groups = [];
|
|
229
|
+
for (let i = 0; i < array.length; i += size) {
|
|
230
|
+
groups.push(array.slice(i, i + size));
|
|
231
|
+
}
|
|
232
|
+
for (const group of groups) {
|
|
233
|
+
result += options2.fn(group);
|
|
234
|
+
}
|
|
235
|
+
return result;
|
|
236
|
+
};
|
|
237
|
+
var withSort = function(array, prop, options2) {
|
|
238
|
+
let sortProp;
|
|
239
|
+
let opts = options2;
|
|
240
|
+
if (typeof prop === "object" && prop !== null && !Array.isArray(prop)) {
|
|
241
|
+
opts = prop;
|
|
242
|
+
} else if (typeof prop === "string") {
|
|
243
|
+
sortProp = prop;
|
|
244
|
+
}
|
|
245
|
+
if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
|
|
246
|
+
return "";
|
|
247
|
+
}
|
|
248
|
+
if (array.length === 0) {
|
|
249
|
+
return opts.inverse ? opts.inverse(this) ?? "" : "";
|
|
250
|
+
}
|
|
251
|
+
const sorted = [...array];
|
|
252
|
+
if (sortProp) {
|
|
253
|
+
sorted.sort((a, b) => {
|
|
254
|
+
const aVal = a?.[sortProp];
|
|
255
|
+
const bVal = b?.[sortProp];
|
|
256
|
+
if (aVal === bVal) return 0;
|
|
257
|
+
if (aVal == null) return 1;
|
|
258
|
+
if (bVal == null) return -1;
|
|
259
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
260
|
+
return aVal.localeCompare(bVal);
|
|
261
|
+
}
|
|
262
|
+
return aVal < bVal ? -1 : 1;
|
|
263
|
+
});
|
|
264
|
+
} else {
|
|
265
|
+
sorted.sort((a, b) => {
|
|
266
|
+
if (a === b) return 0;
|
|
267
|
+
if (a == null) return 1;
|
|
268
|
+
if (b == null) return -1;
|
|
269
|
+
if (typeof a === "string" && typeof b === "string") {
|
|
270
|
+
return a.localeCompare(b);
|
|
271
|
+
}
|
|
272
|
+
return a < b ? -1 : 1;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const shouldReverse = opts.hash?.reverse === true || opts.hash?.reverse === "true";
|
|
276
|
+
if (shouldReverse) {
|
|
277
|
+
sorted.reverse();
|
|
278
|
+
}
|
|
279
|
+
let result = "";
|
|
280
|
+
for (const item of sorted) {
|
|
281
|
+
result += opts.fn(item);
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
};
|
|
285
|
+
var filter = function(array, value, options2) {
|
|
286
|
+
if (!Array.isArray(array) || !options2) {
|
|
287
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
288
|
+
}
|
|
289
|
+
const filtered = array.filter((item) => item === value);
|
|
290
|
+
if (filtered.length > 0 && options2.fn) {
|
|
291
|
+
return options2.fn(this);
|
|
292
|
+
}
|
|
293
|
+
if (filtered.length === 0 && options2.inverse) {
|
|
294
|
+
return options2.inverse(this);
|
|
295
|
+
}
|
|
296
|
+
return "";
|
|
297
|
+
};
|
|
298
|
+
var map = (array, fn) => {
|
|
299
|
+
if (!Array.isArray(array) || typeof fn !== "function") {
|
|
300
|
+
return [];
|
|
301
|
+
}
|
|
302
|
+
return array.map(fn);
|
|
303
|
+
};
|
|
304
|
+
var pluck = (collection, prop) => {
|
|
305
|
+
if (!Array.isArray(collection) || typeof prop !== "string") {
|
|
306
|
+
return [];
|
|
307
|
+
}
|
|
308
|
+
return collection.map((item) => {
|
|
309
|
+
if (item == null || typeof item !== "object") {
|
|
310
|
+
return void 0;
|
|
311
|
+
}
|
|
312
|
+
const parts = prop.split(".");
|
|
313
|
+
let value = item;
|
|
314
|
+
for (const part of parts) {
|
|
315
|
+
if (value == null || typeof value !== "object") {
|
|
316
|
+
return void 0;
|
|
317
|
+
}
|
|
318
|
+
value = value[part];
|
|
319
|
+
}
|
|
320
|
+
return value;
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
var reverse = (value) => {
|
|
324
|
+
if (typeof value === "string") {
|
|
325
|
+
return value.split("").reverse().join("");
|
|
326
|
+
}
|
|
327
|
+
if (Array.isArray(value)) {
|
|
328
|
+
return [...value].reverse();
|
|
329
|
+
}
|
|
330
|
+
return void 0;
|
|
331
|
+
};
|
|
332
|
+
var sort = (array, key) => {
|
|
333
|
+
if (!Array.isArray(array)) {
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
const sorted = [...array];
|
|
337
|
+
if (typeof key === "function") {
|
|
338
|
+
sorted.sort(key);
|
|
339
|
+
} else if (typeof key === "string") {
|
|
340
|
+
sorted.sort((a, b) => {
|
|
341
|
+
const aVal = a?.[key];
|
|
342
|
+
const bVal = b?.[key];
|
|
343
|
+
if (aVal === bVal) return 0;
|
|
344
|
+
if (aVal == null) return 1;
|
|
345
|
+
if (bVal == null) return -1;
|
|
346
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
347
|
+
return aVal.localeCompare(bVal);
|
|
348
|
+
}
|
|
349
|
+
return aVal < bVal ? -1 : 1;
|
|
350
|
+
});
|
|
351
|
+
} else {
|
|
352
|
+
sorted.sort((a, b) => {
|
|
353
|
+
if (a === b) return 0;
|
|
354
|
+
if (a == null) return 1;
|
|
355
|
+
if (b == null) return -1;
|
|
356
|
+
if (typeof a === "string" && typeof b === "string") {
|
|
357
|
+
return a.localeCompare(b);
|
|
358
|
+
}
|
|
359
|
+
return a < b ? -1 : 1;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
return sorted;
|
|
363
|
+
};
|
|
364
|
+
var sortBy = (array, ...props) => {
|
|
365
|
+
if (!Array.isArray(array) || props.length === 0) {
|
|
366
|
+
return [];
|
|
367
|
+
}
|
|
368
|
+
const sorted = [...array];
|
|
369
|
+
sorted.sort((a, b) => {
|
|
370
|
+
for (const prop of props) {
|
|
371
|
+
const aVal = a?.[prop];
|
|
372
|
+
const bVal = b?.[prop];
|
|
373
|
+
if (aVal === bVal) continue;
|
|
374
|
+
if (aVal == null) return 1;
|
|
375
|
+
if (bVal == null) return -1;
|
|
376
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
377
|
+
const result = aVal.localeCompare(bVal);
|
|
378
|
+
if (result !== 0) return result;
|
|
379
|
+
} else {
|
|
380
|
+
return aVal < bVal ? -1 : 1;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return 0;
|
|
384
|
+
});
|
|
385
|
+
return sorted;
|
|
386
|
+
};
|
|
387
|
+
var unique = function(array, options2) {
|
|
388
|
+
if (!Array.isArray(array)) {
|
|
389
|
+
if (!options2) {
|
|
390
|
+
return [];
|
|
391
|
+
}
|
|
392
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
393
|
+
}
|
|
394
|
+
const uniqueArray = [...new Set(array)];
|
|
395
|
+
if (!options2) {
|
|
396
|
+
return uniqueArray;
|
|
397
|
+
}
|
|
398
|
+
if (uniqueArray.length === 0 && options2.inverse) {
|
|
399
|
+
return options2.inverse(this);
|
|
400
|
+
}
|
|
401
|
+
if (uniqueArray.length > 0 && options2.fn) {
|
|
402
|
+
let result = "";
|
|
403
|
+
for (const item of uniqueArray) {
|
|
404
|
+
result += options2.fn(item);
|
|
405
|
+
}
|
|
406
|
+
return result;
|
|
407
|
+
}
|
|
408
|
+
return "";
|
|
409
|
+
};
|
|
86
410
|
var helpers = [
|
|
87
411
|
{
|
|
88
412
|
name: "after",
|
|
@@ -131,6 +455,120 @@ var helpers = [
|
|
|
131
455
|
category: "array",
|
|
132
456
|
compatibility: ["browser", "nodejs"],
|
|
133
457
|
fn: forEach
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
name: "inArray",
|
|
461
|
+
category: "array",
|
|
462
|
+
compatibility: ["browser", "nodejs"],
|
|
463
|
+
fn: inArray
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: "isArray",
|
|
467
|
+
category: "array",
|
|
468
|
+
compatibility: ["browser", "nodejs"],
|
|
469
|
+
fn: isArray
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: "itemAt",
|
|
473
|
+
category: "array",
|
|
474
|
+
compatibility: ["browser", "nodejs"],
|
|
475
|
+
fn: itemAt
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
name: "equalsLength",
|
|
479
|
+
category: "array",
|
|
480
|
+
compatibility: ["browser", "nodejs"],
|
|
481
|
+
fn: equalsLength
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: "some",
|
|
485
|
+
category: "array",
|
|
486
|
+
compatibility: ["browser", "nodejs"],
|
|
487
|
+
fn: some
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "eachIndex",
|
|
491
|
+
category: "array",
|
|
492
|
+
compatibility: ["browser", "nodejs"],
|
|
493
|
+
fn: eachIndex
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
name: "withAfter",
|
|
497
|
+
category: "array",
|
|
498
|
+
compatibility: ["browser", "nodejs"],
|
|
499
|
+
fn: withAfter
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
name: "withBefore",
|
|
503
|
+
category: "array",
|
|
504
|
+
compatibility: ["browser", "nodejs"],
|
|
505
|
+
fn: withBefore
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
name: "withFirst",
|
|
509
|
+
category: "array",
|
|
510
|
+
compatibility: ["browser", "nodejs"],
|
|
511
|
+
fn: withFirst
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "withLast",
|
|
515
|
+
category: "array",
|
|
516
|
+
compatibility: ["browser", "nodejs"],
|
|
517
|
+
fn: withLast
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: "withGroup",
|
|
521
|
+
category: "array",
|
|
522
|
+
compatibility: ["browser", "nodejs"],
|
|
523
|
+
fn: withGroup
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: "withSort",
|
|
527
|
+
category: "array",
|
|
528
|
+
compatibility: ["browser", "nodejs"],
|
|
529
|
+
fn: withSort
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: "filter",
|
|
533
|
+
category: "array",
|
|
534
|
+
compatibility: ["browser", "nodejs"],
|
|
535
|
+
fn: filter
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: "map",
|
|
539
|
+
category: "array",
|
|
540
|
+
compatibility: ["browser", "nodejs"],
|
|
541
|
+
fn: map
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: "pluck",
|
|
545
|
+
category: "array",
|
|
546
|
+
compatibility: ["browser", "nodejs"],
|
|
547
|
+
fn: pluck
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
name: "reverse",
|
|
551
|
+
category: "array",
|
|
552
|
+
compatibility: ["browser", "nodejs"],
|
|
553
|
+
fn: reverse
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: "sort",
|
|
557
|
+
category: "array",
|
|
558
|
+
compatibility: ["browser", "nodejs"],
|
|
559
|
+
fn: sort
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: "sortBy",
|
|
563
|
+
category: "array",
|
|
564
|
+
compatibility: ["browser", "nodejs"],
|
|
565
|
+
fn: sortBy
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "unique",
|
|
569
|
+
category: "array",
|
|
570
|
+
compatibility: ["browser", "nodejs"],
|
|
571
|
+
fn: unique
|
|
134
572
|
}
|
|
135
573
|
];
|
|
136
574
|
|
|
@@ -152,8 +590,8 @@ var embed = (filepath, language) => {
|
|
|
152
590
|
var gist = (id) => {
|
|
153
591
|
return tag("script", { src: `https://gist.github.com/${id}.js` });
|
|
154
592
|
};
|
|
155
|
-
var jsfiddle = (
|
|
156
|
-
if (!
|
|
593
|
+
var jsfiddle = (options2) => {
|
|
594
|
+
if (!options2 || !options2.id) {
|
|
157
595
|
throw new Error("jsfiddle helper expects an `id`");
|
|
158
596
|
}
|
|
159
597
|
const {
|
|
@@ -164,7 +602,7 @@ var jsfiddle = (options) => {
|
|
|
164
602
|
tabs = "result,js,html,css",
|
|
165
603
|
allowfullscreen = "allowfullscreen",
|
|
166
604
|
frameborder = "0"
|
|
167
|
-
} =
|
|
605
|
+
} = options2;
|
|
168
606
|
const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
|
|
169
607
|
return tag("iframe", { width, height, src, allowfullscreen, frameborder });
|
|
170
608
|
};
|
|
@@ -485,17 +923,164 @@ var helpers4 = [
|
|
|
485
923
|
// src/helpers/date.ts
|
|
486
924
|
import { parseDate } from "chrono-node";
|
|
487
925
|
import dayjs from "dayjs";
|
|
926
|
+
import isBetween from "dayjs/plugin/isBetween.js";
|
|
927
|
+
import relativeTime from "dayjs/plugin/relativeTime.js";
|
|
928
|
+
import timezone from "dayjs/plugin/timezone.js";
|
|
929
|
+
import utc from "dayjs/plugin/utc.js";
|
|
930
|
+
dayjs.extend(relativeTime);
|
|
931
|
+
dayjs.extend(isBetween);
|
|
932
|
+
dayjs.extend(utc);
|
|
933
|
+
dayjs.extend(timezone);
|
|
934
|
+
var parseDateInput = (input) => {
|
|
935
|
+
if (!input) {
|
|
936
|
+
return dayjs();
|
|
937
|
+
}
|
|
938
|
+
if (typeof input === "string") {
|
|
939
|
+
const parsed = parseDate(input);
|
|
940
|
+
if (parsed) {
|
|
941
|
+
return dayjs(parsed);
|
|
942
|
+
}
|
|
943
|
+
return dayjs(input);
|
|
944
|
+
}
|
|
945
|
+
return dayjs(input);
|
|
946
|
+
};
|
|
488
947
|
var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
489
948
|
var convertFormatString = (format2) => {
|
|
490
|
-
return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH")
|
|
949
|
+
return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH");
|
|
491
950
|
};
|
|
492
951
|
var date = (humanReadableDate, formatString) => {
|
|
493
|
-
const
|
|
494
|
-
|
|
952
|
+
const defaultFormat = "YYYY-MM-DD";
|
|
953
|
+
const format2 = formatString || defaultFormat;
|
|
954
|
+
const parsedDate = parseDateInput(humanReadableDate);
|
|
955
|
+
if (!parsedDate.isValid()) {
|
|
495
956
|
throw new Error(`Unable to parse date: ${humanReadableDate}`);
|
|
496
957
|
}
|
|
497
|
-
const convertedFormat = convertFormatString(
|
|
498
|
-
return
|
|
958
|
+
const convertedFormat = convertFormatString(format2);
|
|
959
|
+
return parsedDate.format(convertedFormat);
|
|
960
|
+
};
|
|
961
|
+
var timestamp = () => {
|
|
962
|
+
return Date.now().toString();
|
|
963
|
+
};
|
|
964
|
+
var now = (formatString) => {
|
|
965
|
+
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
|
|
966
|
+
const format2 = formatString || defaultFormat;
|
|
967
|
+
const convertedFormat = convertFormatString(format2);
|
|
968
|
+
return dayjs().format(convertedFormat);
|
|
969
|
+
};
|
|
970
|
+
var fromNow = (dateInput) => {
|
|
971
|
+
const parsed = parseDateInput(dateInput);
|
|
972
|
+
if (!parsed.isValid()) {
|
|
973
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
974
|
+
}
|
|
975
|
+
return parsed.fromNow();
|
|
976
|
+
};
|
|
977
|
+
var toNow = (dateInput) => {
|
|
978
|
+
const parsed = parseDateInput(dateInput);
|
|
979
|
+
if (!parsed.isValid()) {
|
|
980
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
981
|
+
}
|
|
982
|
+
return parsed.toNow();
|
|
983
|
+
};
|
|
984
|
+
var ago = (dateInput) => {
|
|
985
|
+
return fromNow(dateInput);
|
|
986
|
+
};
|
|
987
|
+
var dateAdd = (dateInput, amount, unit) => {
|
|
988
|
+
const parsed = parseDateInput(dateInput);
|
|
989
|
+
if (!parsed.isValid()) {
|
|
990
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
991
|
+
}
|
|
992
|
+
return parsed.add(amount, unit).format("YYYY-MM-DD HH:mm:ss");
|
|
993
|
+
};
|
|
994
|
+
var dateSubtract = (dateInput, amount, unit) => {
|
|
995
|
+
const parsed = parseDateInput(dateInput);
|
|
996
|
+
if (!parsed.isValid()) {
|
|
997
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
998
|
+
}
|
|
999
|
+
return parsed.subtract(amount, unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1000
|
+
};
|
|
1001
|
+
var startOf = (dateInput, unit) => {
|
|
1002
|
+
const parsed = parseDateInput(dateInput);
|
|
1003
|
+
if (!parsed.isValid()) {
|
|
1004
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1005
|
+
}
|
|
1006
|
+
return parsed.startOf(unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1007
|
+
};
|
|
1008
|
+
var endOf = (dateInput, unit) => {
|
|
1009
|
+
const parsed = parseDateInput(dateInput);
|
|
1010
|
+
if (!parsed.isValid()) {
|
|
1011
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1012
|
+
}
|
|
1013
|
+
return parsed.endOf(unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1014
|
+
};
|
|
1015
|
+
var isBefore = (date1, date2) => {
|
|
1016
|
+
const parsed1 = parseDateInput(date1);
|
|
1017
|
+
const parsed2 = parseDateInput(date2);
|
|
1018
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1019
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1020
|
+
}
|
|
1021
|
+
return parsed1.isBefore(parsed2);
|
|
1022
|
+
};
|
|
1023
|
+
var isAfter = (date1, date2) => {
|
|
1024
|
+
const parsed1 = parseDateInput(date1);
|
|
1025
|
+
const parsed2 = parseDateInput(date2);
|
|
1026
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1027
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1028
|
+
}
|
|
1029
|
+
return parsed1.isAfter(parsed2);
|
|
1030
|
+
};
|
|
1031
|
+
var isSame = (date1, date2, unit) => {
|
|
1032
|
+
const parsed1 = parseDateInput(date1);
|
|
1033
|
+
const parsed2 = parseDateInput(date2);
|
|
1034
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1035
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1036
|
+
}
|
|
1037
|
+
return parsed1.isSame(parsed2, unit);
|
|
1038
|
+
};
|
|
1039
|
+
var isBetweenDates = (dateInput, startDate, endDate) => {
|
|
1040
|
+
const parsed = parseDateInput(dateInput);
|
|
1041
|
+
const parsedStart = parseDateInput(startDate);
|
|
1042
|
+
const parsedEnd = parseDateInput(endDate);
|
|
1043
|
+
if (!parsed.isValid() || !parsedStart.isValid() || !parsedEnd.isValid()) {
|
|
1044
|
+
throw new Error(
|
|
1045
|
+
`Unable to parse dates: ${dateInput}, ${startDate}, ${endDate}`
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
return parsed.isBetween(parsedStart, parsedEnd, null, "[]");
|
|
1049
|
+
};
|
|
1050
|
+
var diff = (date1, date2, unit) => {
|
|
1051
|
+
const parsed1 = parseDateInput(date1);
|
|
1052
|
+
const parsed2 = parseDateInput(date2);
|
|
1053
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1054
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1055
|
+
}
|
|
1056
|
+
return parsed1.diff(parsed2, unit);
|
|
1057
|
+
};
|
|
1058
|
+
var toISOString = (dateInput) => {
|
|
1059
|
+
const parsed = parseDateInput(dateInput);
|
|
1060
|
+
if (!parsed.isValid()) {
|
|
1061
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1062
|
+
}
|
|
1063
|
+
return parsed.toISOString();
|
|
1064
|
+
};
|
|
1065
|
+
var dateTimezone = (dateInput, timezoneStr, formatString) => {
|
|
1066
|
+
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
|
|
1067
|
+
const format2 = formatString || defaultFormat;
|
|
1068
|
+
const convertedFormat = convertFormatString(format2);
|
|
1069
|
+
const parsed = parseDateInput(dateInput);
|
|
1070
|
+
if (!parsed.isValid()) {
|
|
1071
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1072
|
+
}
|
|
1073
|
+
return parsed.tz(timezoneStr).format(convertedFormat);
|
|
1074
|
+
};
|
|
1075
|
+
var dateLocale = (dateInput, locale, formatString) => {
|
|
1076
|
+
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
|
|
1077
|
+
const format2 = formatString || defaultFormat;
|
|
1078
|
+
const convertedFormat = convertFormatString(format2);
|
|
1079
|
+
const parsed = parseDateInput(dateInput);
|
|
1080
|
+
if (!parsed.isValid()) {
|
|
1081
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1082
|
+
}
|
|
1083
|
+
return parsed.locale(locale).format(convertedFormat);
|
|
499
1084
|
};
|
|
500
1085
|
var helpers5 = [
|
|
501
1086
|
{
|
|
@@ -516,6 +1101,108 @@ var helpers5 = [
|
|
|
516
1101
|
category: "date",
|
|
517
1102
|
compatibility: ["browser", "nodejs"],
|
|
518
1103
|
fn: date
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
name: "timestamp",
|
|
1107
|
+
category: "date",
|
|
1108
|
+
compatibility: ["browser", "nodejs"],
|
|
1109
|
+
fn: timestamp
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
name: "now",
|
|
1113
|
+
category: "date",
|
|
1114
|
+
compatibility: ["browser", "nodejs"],
|
|
1115
|
+
fn: now
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
name: "fromNow",
|
|
1119
|
+
category: "date",
|
|
1120
|
+
compatibility: ["browser", "nodejs"],
|
|
1121
|
+
fn: fromNow
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
name: "toNow",
|
|
1125
|
+
category: "date",
|
|
1126
|
+
compatibility: ["browser", "nodejs"],
|
|
1127
|
+
fn: toNow
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
name: "ago",
|
|
1131
|
+
category: "date",
|
|
1132
|
+
compatibility: ["browser", "nodejs"],
|
|
1133
|
+
fn: ago
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: "dateAdd",
|
|
1137
|
+
category: "date",
|
|
1138
|
+
compatibility: ["browser", "nodejs"],
|
|
1139
|
+
fn: dateAdd
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
name: "dateSubtract",
|
|
1143
|
+
category: "date",
|
|
1144
|
+
compatibility: ["browser", "nodejs"],
|
|
1145
|
+
fn: dateSubtract
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
name: "startOf",
|
|
1149
|
+
category: "date",
|
|
1150
|
+
compatibility: ["browser", "nodejs"],
|
|
1151
|
+
fn: startOf
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
name: "endOf",
|
|
1155
|
+
category: "date",
|
|
1156
|
+
compatibility: ["browser", "nodejs"],
|
|
1157
|
+
fn: endOf
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
name: "isBefore",
|
|
1161
|
+
category: "date",
|
|
1162
|
+
compatibility: ["browser", "nodejs"],
|
|
1163
|
+
fn: isBefore
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
name: "isAfter",
|
|
1167
|
+
category: "date",
|
|
1168
|
+
compatibility: ["browser", "nodejs"],
|
|
1169
|
+
fn: isAfter
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
name: "isSame",
|
|
1173
|
+
category: "date",
|
|
1174
|
+
compatibility: ["browser", "nodejs"],
|
|
1175
|
+
fn: isSame
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
name: "isBetween",
|
|
1179
|
+
category: "date",
|
|
1180
|
+
compatibility: ["browser", "nodejs"],
|
|
1181
|
+
fn: isBetweenDates
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
name: "diff",
|
|
1185
|
+
category: "date",
|
|
1186
|
+
compatibility: ["browser", "nodejs"],
|
|
1187
|
+
fn: diff
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
name: "toISOString",
|
|
1191
|
+
category: "date",
|
|
1192
|
+
compatibility: ["browser", "nodejs"],
|
|
1193
|
+
fn: toISOString
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
name: "dateTimezone",
|
|
1197
|
+
category: "date",
|
|
1198
|
+
compatibility: ["browser", "nodejs"],
|
|
1199
|
+
fn: dateTimezone
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
name: "dateLocale",
|
|
1203
|
+
category: "date",
|
|
1204
|
+
compatibility: ["browser", "nodejs"],
|
|
1205
|
+
fn: dateLocale
|
|
519
1206
|
}
|
|
520
1207
|
];
|
|
521
1208
|
|
|
@@ -549,9 +1236,9 @@ var isOptions = (value) => {
|
|
|
549
1236
|
value && typeof value === "object" && "hash" in value
|
|
550
1237
|
);
|
|
551
1238
|
};
|
|
552
|
-
var readdir = (dir,
|
|
1239
|
+
var readdir = (dir, filter2) => {
|
|
553
1240
|
const files = fs2.readdirSync(dir).map((fp) => path2.join(dir, fp));
|
|
554
|
-
const filterArg = isOptions(
|
|
1241
|
+
const filterArg = isOptions(filter2) ? void 0 : filter2;
|
|
555
1242
|
if (typeof filterArg === "function") {
|
|
556
1243
|
return filterArg(files);
|
|
557
1244
|
}
|
|
@@ -597,13 +1284,13 @@ import path3 from "path";
|
|
|
597
1284
|
import tag2 from "html-tag";
|
|
598
1285
|
import striptags from "striptags";
|
|
599
1286
|
var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
|
|
600
|
-
var attr = (
|
|
601
|
-
const val = parseAttributes(
|
|
1287
|
+
var attr = (options2) => {
|
|
1288
|
+
const val = parseAttributes(options2?.hash ?? {});
|
|
602
1289
|
return val.trim() ? ` ${val}` : "";
|
|
603
1290
|
};
|
|
604
|
-
var css = function(list,
|
|
1291
|
+
var css = function(list, options2) {
|
|
605
1292
|
if (arguments.length < 2) {
|
|
606
|
-
|
|
1293
|
+
options2 = list;
|
|
607
1294
|
list = [];
|
|
608
1295
|
}
|
|
609
1296
|
let styles = arrayify(list ?? []);
|
|
@@ -611,8 +1298,8 @@ var css = function(list, options) {
|
|
|
611
1298
|
if (this && this.options) {
|
|
612
1299
|
assets = this.options.assets || "";
|
|
613
1300
|
}
|
|
614
|
-
if (
|
|
615
|
-
styles = arrayify(
|
|
1301
|
+
if (options2?.hash?.href) {
|
|
1302
|
+
styles = arrayify(options2.hash.href);
|
|
616
1303
|
}
|
|
617
1304
|
return styles.map((item) => {
|
|
618
1305
|
const ext = path3.extname(item);
|
|
@@ -643,18 +1330,18 @@ var sanitize = (str) => {
|
|
|
643
1330
|
if (typeof str !== "string") return "";
|
|
644
1331
|
return striptags(str).trim();
|
|
645
1332
|
};
|
|
646
|
-
var ul = (context,
|
|
647
|
-
const attrs = parseAttributes(
|
|
1333
|
+
var ul = (context, options2) => {
|
|
1334
|
+
const attrs = parseAttributes(options2.hash ?? {});
|
|
648
1335
|
const items = context.map(
|
|
649
|
-
(item) => typeof item === "string" ? item :
|
|
1336
|
+
(item) => typeof item === "string" ? item : options2.fn(item)
|
|
650
1337
|
);
|
|
651
1338
|
const open = attrs ? `<ul ${attrs}>` : "<ul>";
|
|
652
1339
|
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
|
|
653
1340
|
};
|
|
654
|
-
var ol = (context,
|
|
655
|
-
const attrs = parseAttributes(
|
|
1341
|
+
var ol = (context, options2) => {
|
|
1342
|
+
const attrs = parseAttributes(options2.hash ?? {});
|
|
656
1343
|
const items = context.map(
|
|
657
|
-
(item) => typeof item === "string" ? item :
|
|
1344
|
+
(item) => typeof item === "string" ? item : options2.fn(item)
|
|
658
1345
|
);
|
|
659
1346
|
const open = attrs ? `<ol ${attrs}>` : "<ol>";
|
|
660
1347
|
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
|
|
@@ -771,11 +1458,32 @@ var getObject = (object, path6) => {
|
|
|
771
1458
|
}
|
|
772
1459
|
return { [finalKey]: current[finalKey] };
|
|
773
1460
|
};
|
|
1461
|
+
var options = (thisArg, locals, opts) => {
|
|
1462
|
+
const result = {};
|
|
1463
|
+
if (thisArg && typeof thisArg === "object" && thisArg.options) {
|
|
1464
|
+
Object.assign(result, thisArg.options);
|
|
1465
|
+
}
|
|
1466
|
+
if (locals && typeof locals === "object") {
|
|
1467
|
+
if ("hash" in locals) {
|
|
1468
|
+
Object.assign(result, locals.hash);
|
|
1469
|
+
} else {
|
|
1470
|
+
Object.assign(result, locals);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
if (opts && typeof opts === "object") {
|
|
1474
|
+
if ("hash" in opts) {
|
|
1475
|
+
Object.assign(result, opts.hash);
|
|
1476
|
+
} else {
|
|
1477
|
+
Object.assign(result, opts);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
return result;
|
|
1481
|
+
};
|
|
774
1482
|
|
|
775
1483
|
// src/helpers/i18n.ts
|
|
776
|
-
var i18n = function(prop, locals,
|
|
777
|
-
if (locals && typeof locals === "object" && "hash" in locals &&
|
|
778
|
-
|
|
1484
|
+
var i18n = function(prop, locals, options2) {
|
|
1485
|
+
if (locals && typeof locals === "object" && "hash" in locals && options2 === void 0) {
|
|
1486
|
+
options2 = locals;
|
|
779
1487
|
locals = {};
|
|
780
1488
|
}
|
|
781
1489
|
if (typeof prop !== "string") {
|
|
@@ -784,7 +1492,7 @@ var i18n = function(prop, locals, options) {
|
|
|
784
1492
|
const context = {
|
|
785
1493
|
...this,
|
|
786
1494
|
...locals,
|
|
787
|
-
...
|
|
1495
|
+
...options2?.hash ?? {}
|
|
788
1496
|
};
|
|
789
1497
|
const lang = context.language || context.lang;
|
|
790
1498
|
if (typeof lang !== "string") {
|
|
@@ -920,9 +1628,9 @@ function _debug(...args) {
|
|
|
920
1628
|
console.error(colors.cyan(separator));
|
|
921
1629
|
return "";
|
|
922
1630
|
}
|
|
923
|
-
function _inspect(context,
|
|
1631
|
+
function _inspect(context, options2) {
|
|
924
1632
|
const val = JSON.stringify(context, null, 2);
|
|
925
|
-
const type =
|
|
1633
|
+
const type = options2?.hash?.type || "html";
|
|
926
1634
|
return switchOutput(type, val);
|
|
927
1635
|
}
|
|
928
1636
|
function switchOutput(type, json) {
|
|
@@ -1015,12 +1723,12 @@ var helpers10 = [
|
|
|
1015
1723
|
|
|
1016
1724
|
// src/helpers/match.ts
|
|
1017
1725
|
import micromatch2 from "micromatch";
|
|
1018
|
-
var match = (files, patterns,
|
|
1726
|
+
var match = (files, patterns, options2) => {
|
|
1019
1727
|
const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
|
|
1020
|
-
return micromatch2(files, pats,
|
|
1728
|
+
return micromatch2(files, pats, options2);
|
|
1021
1729
|
};
|
|
1022
|
-
var isMatch = (filepath, pattern,
|
|
1023
|
-
return micromatch2.isMatch(filepath, pattern,
|
|
1730
|
+
var isMatch = (filepath, pattern, options2) => {
|
|
1731
|
+
return micromatch2.isMatch(filepath, pattern, options2);
|
|
1024
1732
|
};
|
|
1025
1733
|
var mm = (...args) => {
|
|
1026
1734
|
console.log("the {{mm}} helper is depcrecated and will be removed");
|
|
@@ -1236,14 +1944,14 @@ import process2 from "process";
|
|
|
1236
1944
|
import ent from "ent";
|
|
1237
1945
|
import Handlebars from "handlebars";
|
|
1238
1946
|
import { Remarkable } from "remarkable";
|
|
1239
|
-
var renderMarkdown = function(input,
|
|
1947
|
+
var renderMarkdown = function(input, options2) {
|
|
1240
1948
|
if (typeof input === "object" && input && "fn" in input && typeof input.fn === "function") {
|
|
1241
|
-
|
|
1949
|
+
options2 = input;
|
|
1242
1950
|
input = input.fn(this);
|
|
1243
1951
|
} else if (typeof input !== "string") {
|
|
1244
1952
|
input = "";
|
|
1245
1953
|
}
|
|
1246
|
-
const options_ = { cwd: process2.cwd(), ...
|
|
1954
|
+
const options_ = { cwd: process2.cwd(), ...options2 };
|
|
1247
1955
|
const md = new Remarkable({
|
|
1248
1956
|
breaks: true,
|
|
1249
1957
|
html: true,
|
|
@@ -1277,34 +1985,33 @@ var helpers13 = [
|
|
|
1277
1985
|
|
|
1278
1986
|
// src/helpers/misc.ts
|
|
1279
1987
|
import Handlebars2 from "handlebars";
|
|
1280
|
-
import util from "handlebars-utils";
|
|
1281
1988
|
import kindOf from "kind-of";
|
|
1282
|
-
function frame(context,
|
|
1989
|
+
function frame(context, options2) {
|
|
1283
1990
|
if (typeof context === "object" && context !== null && "hash" in context) {
|
|
1284
|
-
|
|
1285
|
-
context =
|
|
1991
|
+
options2 = context;
|
|
1992
|
+
context = options2.data;
|
|
1286
1993
|
}
|
|
1287
1994
|
const data = Handlebars2.createFrame(context || {});
|
|
1288
|
-
if (typeof
|
|
1289
|
-
|
|
1995
|
+
if (typeof options2 !== "object" || options2 === null) {
|
|
1996
|
+
options2 = {};
|
|
1290
1997
|
}
|
|
1291
|
-
if (
|
|
1292
|
-
Object.assign(data,
|
|
1998
|
+
if (options2.hash && typeof options2.hash === "object") {
|
|
1999
|
+
Object.assign(data, options2.hash);
|
|
1293
2000
|
}
|
|
1294
|
-
return
|
|
2001
|
+
return options2.fn(this, { data });
|
|
1295
2002
|
}
|
|
1296
|
-
function option(prop, locals,
|
|
1297
|
-
return get(
|
|
2003
|
+
function option(prop, locals, opts) {
|
|
2004
|
+
return get(options(this, locals, opts), prop);
|
|
1298
2005
|
}
|
|
1299
|
-
function noop(
|
|
1300
|
-
return
|
|
2006
|
+
function noop(options2) {
|
|
2007
|
+
return options2.fn(this);
|
|
1301
2008
|
}
|
|
1302
2009
|
var typeOf = kindOf;
|
|
1303
|
-
function withHash(
|
|
1304
|
-
if (
|
|
1305
|
-
return
|
|
2010
|
+
function withHash(options2) {
|
|
2011
|
+
if (options2.hash && Object.keys(options2.hash).length) {
|
|
2012
|
+
return options2.fn(options2.hash);
|
|
1306
2013
|
}
|
|
1307
|
-
return
|
|
2014
|
+
return options2.inverse(this);
|
|
1308
2015
|
}
|
|
1309
2016
|
var helpers14 = [
|
|
1310
2017
|
{
|
|
@@ -1464,8 +2171,8 @@ var helpers15 = [
|
|
|
1464
2171
|
var isOptions2 = (value) => {
|
|
1465
2172
|
return Boolean(value && typeof value === "object" && "hash" in value);
|
|
1466
2173
|
};
|
|
1467
|
-
var createFrame = (
|
|
1468
|
-
...
|
|
2174
|
+
var createFrame = (options2, hash) => ({
|
|
2175
|
+
...options2?.data || {},
|
|
1469
2176
|
...hash
|
|
1470
2177
|
});
|
|
1471
2178
|
var extend = (...objects) => {
|
|
@@ -1482,28 +2189,28 @@ var extend = (...objects) => {
|
|
|
1482
2189
|
}
|
|
1483
2190
|
return result;
|
|
1484
2191
|
};
|
|
1485
|
-
var forIn = (obj,
|
|
1486
|
-
if (!isOptions2(
|
|
1487
|
-
return
|
|
2192
|
+
var forIn = (obj, options2) => {
|
|
2193
|
+
if (!isOptions2(options2)) {
|
|
2194
|
+
return options2?.inverse?.(obj) ?? "";
|
|
1488
2195
|
}
|
|
1489
|
-
const data = createFrame(
|
|
2196
|
+
const data = createFrame(options2, options2.hash || {});
|
|
1490
2197
|
let result = "";
|
|
1491
2198
|
for (const key in obj) {
|
|
1492
2199
|
data.key = key;
|
|
1493
|
-
result +=
|
|
2200
|
+
result += options2.fn(obj[key], { data });
|
|
1494
2201
|
}
|
|
1495
2202
|
return result;
|
|
1496
2203
|
};
|
|
1497
|
-
var forOwn = (obj,
|
|
1498
|
-
if (!isOptions2(
|
|
1499
|
-
return
|
|
2204
|
+
var forOwn = (obj, options2) => {
|
|
2205
|
+
if (!isOptions2(options2)) {
|
|
2206
|
+
return options2?.inverse?.(obj) ?? "";
|
|
1500
2207
|
}
|
|
1501
|
-
const data = createFrame(
|
|
2208
|
+
const data = createFrame(options2, options2.hash || {});
|
|
1502
2209
|
let result = "";
|
|
1503
2210
|
for (const key in obj) {
|
|
1504
2211
|
if (Object.hasOwn(obj, key)) {
|
|
1505
2212
|
data.key = key;
|
|
1506
|
-
result +=
|
|
2213
|
+
result += options2.fn(obj[key], { data });
|
|
1507
2214
|
}
|
|
1508
2215
|
}
|
|
1509
2216
|
return result;
|
|
@@ -1517,10 +2224,10 @@ var toPath = (...prop) => {
|
|
|
1517
2224
|
}
|
|
1518
2225
|
return parts.join(".");
|
|
1519
2226
|
};
|
|
1520
|
-
var getHelper = (prop, context,
|
|
2227
|
+
var getHelper = (prop, context, options2) => {
|
|
1521
2228
|
const val = get(context, prop);
|
|
1522
|
-
if (
|
|
1523
|
-
return val ?
|
|
2229
|
+
if (options2 && typeof options2.fn === "function") {
|
|
2230
|
+
return val ? options2.fn(val) : options2.inverse?.(context);
|
|
1524
2231
|
}
|
|
1525
2232
|
return val;
|
|
1526
2233
|
};
|
|
@@ -1550,17 +2257,17 @@ var merge = (context, ...objects) => {
|
|
|
1550
2257
|
};
|
|
1551
2258
|
var parseJSON = JSONparse;
|
|
1552
2259
|
var stringify = JSONstringify;
|
|
1553
|
-
var pick = (props, context,
|
|
2260
|
+
var pick = (props, context, options2) => {
|
|
1554
2261
|
const keys = arrayify(props);
|
|
1555
2262
|
let result = {};
|
|
1556
2263
|
for (const key of keys) {
|
|
1557
2264
|
result = Object.assign({}, result, getObject(context, key));
|
|
1558
2265
|
}
|
|
1559
|
-
if (
|
|
2266
|
+
if (options2 && typeof options2.fn === "function") {
|
|
1560
2267
|
if (Object.keys(result).length) {
|
|
1561
|
-
return
|
|
2268
|
+
return options2.fn(result);
|
|
1562
2269
|
}
|
|
1563
|
-
return
|
|
2270
|
+
return options2.inverse?.(context);
|
|
1564
2271
|
}
|
|
1565
2272
|
return result;
|
|
1566
2273
|
};
|
|
@@ -1663,9 +2370,9 @@ var assertString = (name, value) => {
|
|
|
1663
2370
|
}
|
|
1664
2371
|
return value;
|
|
1665
2372
|
};
|
|
1666
|
-
var absolute = function(filepath,
|
|
2373
|
+
var absolute = function(filepath, options2) {
|
|
1667
2374
|
const fp = assertString("filepath", filepath);
|
|
1668
|
-
const cwd =
|
|
2375
|
+
const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1669
2376
|
return path5.resolve(cwd, fp);
|
|
1670
2377
|
};
|
|
1671
2378
|
var dirname = (filepath) => {
|
|
@@ -1690,12 +2397,12 @@ var extname = (filepath) => {
|
|
|
1690
2397
|
return path5.extname(fp);
|
|
1691
2398
|
};
|
|
1692
2399
|
var resolveFn = function(filepath, ...paths) {
|
|
1693
|
-
let
|
|
2400
|
+
let options2;
|
|
1694
2401
|
const last2 = paths[paths.length - 1];
|
|
1695
2402
|
if (typeof last2 === "object" && last2 && "data" in last2) {
|
|
1696
|
-
|
|
2403
|
+
options2 = paths.pop();
|
|
1697
2404
|
}
|
|
1698
|
-
const cwd =
|
|
2405
|
+
const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1699
2406
|
const all2 = [
|
|
1700
2407
|
cwd,
|
|
1701
2408
|
assertString("filepath", filepath),
|
|
@@ -1762,10 +2469,9 @@ var helpers17 = [
|
|
|
1762
2469
|
];
|
|
1763
2470
|
|
|
1764
2471
|
// src/helpers/regex.ts
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
return new RegExp(str, opts.flags);
|
|
2472
|
+
var toRegex = (str, locals, opts) => {
|
|
2473
|
+
const mergedOpts = options({}, locals, opts);
|
|
2474
|
+
return new RegExp(str, mergedOpts.flags);
|
|
1769
2475
|
};
|
|
1770
2476
|
var test = (str, regex) => {
|
|
1771
2477
|
if (typeof str !== "string") {
|
|
@@ -1902,7 +2608,7 @@ var replaceFirst = (str, a, b) => {
|
|
|
1902
2608
|
if (typeof b !== "string") b = "";
|
|
1903
2609
|
return str.replace(a, b);
|
|
1904
2610
|
};
|
|
1905
|
-
var
|
|
2611
|
+
var reverse2 = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
|
|
1906
2612
|
var sentence = (str) => {
|
|
1907
2613
|
if (typeof str !== "string") return "";
|
|
1908
2614
|
return str.replace(
|
|
@@ -1938,6 +2644,29 @@ var uppercase = (str) => {
|
|
|
1938
2644
|
return str.toUpperCase();
|
|
1939
2645
|
};
|
|
1940
2646
|
var upcase = (str) => uppercase(str);
|
|
2647
|
+
var split = (str, character) => {
|
|
2648
|
+
if (typeof str !== "string") return "";
|
|
2649
|
+
if (typeof character !== "string") character = "";
|
|
2650
|
+
return str.split(character);
|
|
2651
|
+
};
|
|
2652
|
+
var startsWith = (prefix, testString, _options) => {
|
|
2653
|
+
if (typeof prefix !== "string" || typeof testString !== "string") {
|
|
2654
|
+
return false;
|
|
2655
|
+
}
|
|
2656
|
+
return testString.startsWith(prefix);
|
|
2657
|
+
};
|
|
2658
|
+
var titleize = (str) => {
|
|
2659
|
+
if (typeof str !== "string") return "";
|
|
2660
|
+
return str.replace(/\w\S*/g, (word) => {
|
|
2661
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
2662
|
+
});
|
|
2663
|
+
};
|
|
2664
|
+
var raw = (options2) => {
|
|
2665
|
+
if (options2 && typeof options2.fn === "function") {
|
|
2666
|
+
return options2.fn();
|
|
2667
|
+
}
|
|
2668
|
+
return "";
|
|
2669
|
+
};
|
|
1941
2670
|
var helpers19 = [
|
|
1942
2671
|
{
|
|
1943
2672
|
name: "append",
|
|
@@ -2075,7 +2804,7 @@ var helpers19 = [
|
|
|
2075
2804
|
name: "reverse",
|
|
2076
2805
|
category: "string",
|
|
2077
2806
|
compatibility: ["browser", "nodejs"],
|
|
2078
|
-
fn:
|
|
2807
|
+
fn: reverse2
|
|
2079
2808
|
},
|
|
2080
2809
|
{
|
|
2081
2810
|
name: "sentence",
|
|
@@ -2130,6 +2859,30 @@ var helpers19 = [
|
|
|
2130
2859
|
category: "string",
|
|
2131
2860
|
compatibility: ["browser", "nodejs"],
|
|
2132
2861
|
fn: upcase
|
|
2862
|
+
},
|
|
2863
|
+
{
|
|
2864
|
+
name: "split",
|
|
2865
|
+
category: "string",
|
|
2866
|
+
compatibility: ["browser", "nodejs"],
|
|
2867
|
+
fn: split
|
|
2868
|
+
},
|
|
2869
|
+
{
|
|
2870
|
+
name: "startsWith",
|
|
2871
|
+
category: "string",
|
|
2872
|
+
compatibility: ["browser", "nodejs"],
|
|
2873
|
+
fn: startsWith
|
|
2874
|
+
},
|
|
2875
|
+
{
|
|
2876
|
+
name: "titleize",
|
|
2877
|
+
category: "string",
|
|
2878
|
+
compatibility: ["browser", "nodejs"],
|
|
2879
|
+
fn: titleize
|
|
2880
|
+
},
|
|
2881
|
+
{
|
|
2882
|
+
name: "raw",
|
|
2883
|
+
category: "string",
|
|
2884
|
+
compatibility: ["browser", "nodejs"],
|
|
2885
|
+
fn: raw
|
|
2133
2886
|
}
|
|
2134
2887
|
];
|
|
2135
2888
|
|
|
@@ -2301,19 +3054,19 @@ var HelperRegistry = class {
|
|
|
2301
3054
|
* @param filter The filter criteria.
|
|
2302
3055
|
* @returns The filtered helpers.
|
|
2303
3056
|
*/
|
|
2304
|
-
filter(
|
|
3057
|
+
filter(filter2) {
|
|
2305
3058
|
let result = this._helpers;
|
|
2306
|
-
if (
|
|
2307
|
-
result = result.filter((helper) =>
|
|
3059
|
+
if (filter2.names) {
|
|
3060
|
+
result = result.filter((helper) => filter2.names?.includes(helper.name));
|
|
2308
3061
|
}
|
|
2309
|
-
if (
|
|
3062
|
+
if (filter2.categories) {
|
|
2310
3063
|
result = result.filter(
|
|
2311
|
-
(helper) =>
|
|
3064
|
+
(helper) => filter2.categories?.includes(helper.category)
|
|
2312
3065
|
);
|
|
2313
3066
|
}
|
|
2314
|
-
if (
|
|
3067
|
+
if (filter2.compatibility) {
|
|
2315
3068
|
result = result.filter(
|
|
2316
|
-
(helper) => helper.compatibility?.some((c) =>
|
|
3069
|
+
(helper) => helper.compatibility?.some((c) => filter2.compatibility?.includes(c))
|
|
2317
3070
|
);
|
|
2318
3071
|
}
|
|
2319
3072
|
return result;
|
|
@@ -2348,9 +3101,9 @@ var HelperRegistry = class {
|
|
|
2348
3101
|
// src/index.ts
|
|
2349
3102
|
var Handlebars3 = HandlebarsLib;
|
|
2350
3103
|
var handlebars = HandlebarsLib.create();
|
|
2351
|
-
function helpers21(
|
|
3104
|
+
function helpers21(options2) {
|
|
2352
3105
|
const registry = new HelperRegistry();
|
|
2353
|
-
registry.load(
|
|
3106
|
+
registry.load(options2.handlebars ?? options2.hbs);
|
|
2354
3107
|
}
|
|
2355
3108
|
async function createHandlebars() {
|
|
2356
3109
|
const registry = new HelperRegistry();
|
|
@@ -2366,11 +3119,11 @@ async function createHandlebars() {
|
|
|
2366
3119
|
}
|
|
2367
3120
|
return handlebars2;
|
|
2368
3121
|
}
|
|
2369
|
-
function fumanchu(
|
|
3122
|
+
function fumanchu(options2) {
|
|
2370
3123
|
const registry = new HelperRegistry();
|
|
2371
3124
|
let handlebars2 = HandlebarsLib.create();
|
|
2372
|
-
if (
|
|
2373
|
-
handlebars2 =
|
|
3125
|
+
if (options2?.handlebars) {
|
|
3126
|
+
handlebars2 = options2.handlebars;
|
|
2374
3127
|
} else if (Object.keys(HandlebarsLib.partials).length > 0) {
|
|
2375
3128
|
handlebars2.registerPartial(HandlebarsLib.partials);
|
|
2376
3129
|
}
|
|
@@ -2385,4 +3138,5 @@ export {
|
|
|
2385
3138
|
handlebars,
|
|
2386
3139
|
helpers21 as helpers
|
|
2387
3140
|
};
|
|
3141
|
+
/* v8 ignore next -- @preserve */
|
|
2388
3142
|
/* c8 ignore next -- @preserve */
|