@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.cjs
CHANGED
|
@@ -88,16 +88,16 @@ var join = (array, separator = ", ") => {
|
|
|
88
88
|
if (!Array.isArray(array)) return "";
|
|
89
89
|
return array.join(separator);
|
|
90
90
|
};
|
|
91
|
-
var forEach = function(collection,
|
|
92
|
-
if (!Array.isArray(collection) || !
|
|
93
|
-
return
|
|
91
|
+
var forEach = function(collection, options2) {
|
|
92
|
+
if (!Array.isArray(collection) || !options2 || typeof options2.fn !== "function") {
|
|
93
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
94
94
|
}
|
|
95
95
|
if (collection.length === 0) {
|
|
96
|
-
return
|
|
96
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
97
97
|
}
|
|
98
98
|
const total = collection.length;
|
|
99
|
-
const hash =
|
|
100
|
-
const baseData =
|
|
99
|
+
const hash = options2.hash ?? {};
|
|
100
|
+
const baseData = options2.data ? { ...options2.data } : void 0;
|
|
101
101
|
let result = "";
|
|
102
102
|
for (let index = 0; index < total; index++) {
|
|
103
103
|
const value = collection[index];
|
|
@@ -118,10 +118,334 @@ var forEach = function(collection, options) {
|
|
|
118
118
|
} else {
|
|
119
119
|
context = { value, ...hash, ...meta };
|
|
120
120
|
}
|
|
121
|
-
result +=
|
|
121
|
+
result += options2.fn(context, { data });
|
|
122
122
|
}
|
|
123
123
|
return result;
|
|
124
124
|
};
|
|
125
|
+
var inArray = function(array, value, options2) {
|
|
126
|
+
if (!Array.isArray(array) || !options2) {
|
|
127
|
+
return "";
|
|
128
|
+
}
|
|
129
|
+
const found = array.includes(value);
|
|
130
|
+
if (found && options2.fn) {
|
|
131
|
+
return options2.fn(this);
|
|
132
|
+
}
|
|
133
|
+
if (!found && options2.inverse) {
|
|
134
|
+
return options2.inverse(this);
|
|
135
|
+
}
|
|
136
|
+
return "";
|
|
137
|
+
};
|
|
138
|
+
var isArray = (value) => {
|
|
139
|
+
return Array.isArray(value);
|
|
140
|
+
};
|
|
141
|
+
var itemAt = (array, idx) => {
|
|
142
|
+
if (!Array.isArray(array)) return void 0;
|
|
143
|
+
return array[idx];
|
|
144
|
+
};
|
|
145
|
+
var equalsLength = function(value, targetLength, options2) {
|
|
146
|
+
const actualLength = length(value);
|
|
147
|
+
const isEqual = actualLength === targetLength;
|
|
148
|
+
if (options2 && (options2.fn || options2.inverse)) {
|
|
149
|
+
if (isEqual && options2.fn) {
|
|
150
|
+
return options2.fn(this);
|
|
151
|
+
}
|
|
152
|
+
if (!isEqual && options2.inverse) {
|
|
153
|
+
return options2.inverse(this);
|
|
154
|
+
}
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
return isEqual;
|
|
158
|
+
};
|
|
159
|
+
var some = function(array, iter, options2) {
|
|
160
|
+
if (!Array.isArray(array) || typeof iter !== "function" || !options2) {
|
|
161
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
162
|
+
}
|
|
163
|
+
const hasSome = array.some(iter);
|
|
164
|
+
if (hasSome && options2.fn) {
|
|
165
|
+
return options2.fn(this);
|
|
166
|
+
}
|
|
167
|
+
if (!hasSome && options2.inverse) {
|
|
168
|
+
return options2.inverse(this);
|
|
169
|
+
}
|
|
170
|
+
return "";
|
|
171
|
+
};
|
|
172
|
+
var eachIndex = function(array, options2) {
|
|
173
|
+
if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
|
|
174
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
175
|
+
}
|
|
176
|
+
if (array.length === 0) {
|
|
177
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
178
|
+
}
|
|
179
|
+
let result = "";
|
|
180
|
+
for (let index = 0; index < array.length; index++) {
|
|
181
|
+
const context = {
|
|
182
|
+
item: array[index],
|
|
183
|
+
index
|
|
184
|
+
};
|
|
185
|
+
result += options2.fn(context);
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
};
|
|
189
|
+
var withAfter = function(array, idx, options2) {
|
|
190
|
+
if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
|
|
191
|
+
return "";
|
|
192
|
+
}
|
|
193
|
+
const sliced = array.slice(idx + 1);
|
|
194
|
+
if (sliced.length === 0) {
|
|
195
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
196
|
+
}
|
|
197
|
+
let result = "";
|
|
198
|
+
for (const item of sliced) {
|
|
199
|
+
result += options2.fn(item);
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
};
|
|
203
|
+
var withBefore = function(array, idx, options2) {
|
|
204
|
+
if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
|
|
205
|
+
return "";
|
|
206
|
+
}
|
|
207
|
+
const sliced = array.slice(0, idx);
|
|
208
|
+
if (sliced.length === 0) {
|
|
209
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
210
|
+
}
|
|
211
|
+
let result = "";
|
|
212
|
+
for (const item of sliced) {
|
|
213
|
+
result += options2.fn(item);
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
};
|
|
217
|
+
var withFirst = function(array, n, options2) {
|
|
218
|
+
let count = 1;
|
|
219
|
+
let opts = options2;
|
|
220
|
+
if (typeof n === "object" && n !== null && !Array.isArray(n)) {
|
|
221
|
+
opts = n;
|
|
222
|
+
} else if (typeof n === "number") {
|
|
223
|
+
count = n;
|
|
224
|
+
}
|
|
225
|
+
if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
|
|
226
|
+
return "";
|
|
227
|
+
}
|
|
228
|
+
if (array.length === 0) {
|
|
229
|
+
return opts.inverse ? opts.inverse(this) ?? "" : "";
|
|
230
|
+
}
|
|
231
|
+
const items = array.slice(0, count);
|
|
232
|
+
let result = "";
|
|
233
|
+
for (const item of items) {
|
|
234
|
+
result += opts.fn(item);
|
|
235
|
+
}
|
|
236
|
+
return result;
|
|
237
|
+
};
|
|
238
|
+
var withLast = function(array, n, options2) {
|
|
239
|
+
let count = 1;
|
|
240
|
+
let opts = options2;
|
|
241
|
+
if (typeof n === "object" && n !== null && !Array.isArray(n)) {
|
|
242
|
+
opts = n;
|
|
243
|
+
} else if (typeof n === "number") {
|
|
244
|
+
count = n;
|
|
245
|
+
}
|
|
246
|
+
if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
if (array.length === 0) {
|
|
250
|
+
return opts.inverse ? opts.inverse(this) ?? "" : "";
|
|
251
|
+
}
|
|
252
|
+
const items = array.slice(-count);
|
|
253
|
+
let result = "";
|
|
254
|
+
for (const item of items) {
|
|
255
|
+
result += opts.fn(item);
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
};
|
|
259
|
+
var withGroup = function(array, size, options2) {
|
|
260
|
+
if (!Array.isArray(array) || typeof size !== "number" || size <= 0 || !options2 || typeof options2.fn !== "function") {
|
|
261
|
+
return "";
|
|
262
|
+
}
|
|
263
|
+
if (array.length === 0) {
|
|
264
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
265
|
+
}
|
|
266
|
+
let result = "";
|
|
267
|
+
const groups = [];
|
|
268
|
+
for (let i = 0; i < array.length; i += size) {
|
|
269
|
+
groups.push(array.slice(i, i + size));
|
|
270
|
+
}
|
|
271
|
+
for (const group of groups) {
|
|
272
|
+
result += options2.fn(group);
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
275
|
+
};
|
|
276
|
+
var withSort = function(array, prop, options2) {
|
|
277
|
+
let sortProp;
|
|
278
|
+
let opts = options2;
|
|
279
|
+
if (typeof prop === "object" && prop !== null && !Array.isArray(prop)) {
|
|
280
|
+
opts = prop;
|
|
281
|
+
} else if (typeof prop === "string") {
|
|
282
|
+
sortProp = prop;
|
|
283
|
+
}
|
|
284
|
+
if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
|
|
285
|
+
return "";
|
|
286
|
+
}
|
|
287
|
+
if (array.length === 0) {
|
|
288
|
+
return opts.inverse ? opts.inverse(this) ?? "" : "";
|
|
289
|
+
}
|
|
290
|
+
const sorted = [...array];
|
|
291
|
+
if (sortProp) {
|
|
292
|
+
sorted.sort((a, b) => {
|
|
293
|
+
const aVal = a?.[sortProp];
|
|
294
|
+
const bVal = b?.[sortProp];
|
|
295
|
+
if (aVal === bVal) return 0;
|
|
296
|
+
if (aVal == null) return 1;
|
|
297
|
+
if (bVal == null) return -1;
|
|
298
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
299
|
+
return aVal.localeCompare(bVal);
|
|
300
|
+
}
|
|
301
|
+
return aVal < bVal ? -1 : 1;
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
sorted.sort((a, b) => {
|
|
305
|
+
if (a === b) return 0;
|
|
306
|
+
if (a == null) return 1;
|
|
307
|
+
if (b == null) return -1;
|
|
308
|
+
if (typeof a === "string" && typeof b === "string") {
|
|
309
|
+
return a.localeCompare(b);
|
|
310
|
+
}
|
|
311
|
+
return a < b ? -1 : 1;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
const shouldReverse = opts.hash?.reverse === true || opts.hash?.reverse === "true";
|
|
315
|
+
if (shouldReverse) {
|
|
316
|
+
sorted.reverse();
|
|
317
|
+
}
|
|
318
|
+
let result = "";
|
|
319
|
+
for (const item of sorted) {
|
|
320
|
+
result += opts.fn(item);
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
};
|
|
324
|
+
var filter = function(array, value, options2) {
|
|
325
|
+
if (!Array.isArray(array) || !options2) {
|
|
326
|
+
return options2?.inverse ? options2.inverse(this) ?? "" : "";
|
|
327
|
+
}
|
|
328
|
+
const filtered = array.filter((item) => item === value);
|
|
329
|
+
if (filtered.length > 0 && options2.fn) {
|
|
330
|
+
return options2.fn(this);
|
|
331
|
+
}
|
|
332
|
+
if (filtered.length === 0 && options2.inverse) {
|
|
333
|
+
return options2.inverse(this);
|
|
334
|
+
}
|
|
335
|
+
return "";
|
|
336
|
+
};
|
|
337
|
+
var map = (array, fn) => {
|
|
338
|
+
if (!Array.isArray(array) || typeof fn !== "function") {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
return array.map(fn);
|
|
342
|
+
};
|
|
343
|
+
var pluck = (collection, prop) => {
|
|
344
|
+
if (!Array.isArray(collection) || typeof prop !== "string") {
|
|
345
|
+
return [];
|
|
346
|
+
}
|
|
347
|
+
return collection.map((item) => {
|
|
348
|
+
if (item == null || typeof item !== "object") {
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
const parts = prop.split(".");
|
|
352
|
+
let value = item;
|
|
353
|
+
for (const part of parts) {
|
|
354
|
+
if (value == null || typeof value !== "object") {
|
|
355
|
+
return void 0;
|
|
356
|
+
}
|
|
357
|
+
value = value[part];
|
|
358
|
+
}
|
|
359
|
+
return value;
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
var reverse = (value) => {
|
|
363
|
+
if (typeof value === "string") {
|
|
364
|
+
return value.split("").reverse().join("");
|
|
365
|
+
}
|
|
366
|
+
if (Array.isArray(value)) {
|
|
367
|
+
return [...value].reverse();
|
|
368
|
+
}
|
|
369
|
+
return void 0;
|
|
370
|
+
};
|
|
371
|
+
var sort = (array, key) => {
|
|
372
|
+
if (!Array.isArray(array)) {
|
|
373
|
+
return [];
|
|
374
|
+
}
|
|
375
|
+
const sorted = [...array];
|
|
376
|
+
if (typeof key === "function") {
|
|
377
|
+
sorted.sort(key);
|
|
378
|
+
} else if (typeof key === "string") {
|
|
379
|
+
sorted.sort((a, b) => {
|
|
380
|
+
const aVal = a?.[key];
|
|
381
|
+
const bVal = b?.[key];
|
|
382
|
+
if (aVal === bVal) return 0;
|
|
383
|
+
if (aVal == null) return 1;
|
|
384
|
+
if (bVal == null) return -1;
|
|
385
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
386
|
+
return aVal.localeCompare(bVal);
|
|
387
|
+
}
|
|
388
|
+
return aVal < bVal ? -1 : 1;
|
|
389
|
+
});
|
|
390
|
+
} else {
|
|
391
|
+
sorted.sort((a, b) => {
|
|
392
|
+
if (a === b) return 0;
|
|
393
|
+
if (a == null) return 1;
|
|
394
|
+
if (b == null) return -1;
|
|
395
|
+
if (typeof a === "string" && typeof b === "string") {
|
|
396
|
+
return a.localeCompare(b);
|
|
397
|
+
}
|
|
398
|
+
return a < b ? -1 : 1;
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
return sorted;
|
|
402
|
+
};
|
|
403
|
+
var sortBy = (array, ...props) => {
|
|
404
|
+
if (!Array.isArray(array) || props.length === 0) {
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
const sorted = [...array];
|
|
408
|
+
sorted.sort((a, b) => {
|
|
409
|
+
for (const prop of props) {
|
|
410
|
+
const aVal = a?.[prop];
|
|
411
|
+
const bVal = b?.[prop];
|
|
412
|
+
if (aVal === bVal) continue;
|
|
413
|
+
if (aVal == null) return 1;
|
|
414
|
+
if (bVal == null) return -1;
|
|
415
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
416
|
+
const result = aVal.localeCompare(bVal);
|
|
417
|
+
if (result !== 0) return result;
|
|
418
|
+
} else {
|
|
419
|
+
return aVal < bVal ? -1 : 1;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return 0;
|
|
423
|
+
});
|
|
424
|
+
return sorted;
|
|
425
|
+
};
|
|
426
|
+
var unique = function(array, options2) {
|
|
427
|
+
if (!Array.isArray(array)) {
|
|
428
|
+
if (!options2) {
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
return options2.inverse ? options2.inverse(this) ?? "" : "";
|
|
432
|
+
}
|
|
433
|
+
const uniqueArray = [...new Set(array)];
|
|
434
|
+
if (!options2) {
|
|
435
|
+
return uniqueArray;
|
|
436
|
+
}
|
|
437
|
+
if (uniqueArray.length === 0 && options2.inverse) {
|
|
438
|
+
return options2.inverse(this);
|
|
439
|
+
}
|
|
440
|
+
if (uniqueArray.length > 0 && options2.fn) {
|
|
441
|
+
let result = "";
|
|
442
|
+
for (const item of uniqueArray) {
|
|
443
|
+
result += options2.fn(item);
|
|
444
|
+
}
|
|
445
|
+
return result;
|
|
446
|
+
}
|
|
447
|
+
return "";
|
|
448
|
+
};
|
|
125
449
|
var helpers = [
|
|
126
450
|
{
|
|
127
451
|
name: "after",
|
|
@@ -170,6 +494,120 @@ var helpers = [
|
|
|
170
494
|
category: "array",
|
|
171
495
|
compatibility: ["browser", "nodejs"],
|
|
172
496
|
fn: forEach
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
name: "inArray",
|
|
500
|
+
category: "array",
|
|
501
|
+
compatibility: ["browser", "nodejs"],
|
|
502
|
+
fn: inArray
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "isArray",
|
|
506
|
+
category: "array",
|
|
507
|
+
compatibility: ["browser", "nodejs"],
|
|
508
|
+
fn: isArray
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
name: "itemAt",
|
|
512
|
+
category: "array",
|
|
513
|
+
compatibility: ["browser", "nodejs"],
|
|
514
|
+
fn: itemAt
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
name: "equalsLength",
|
|
518
|
+
category: "array",
|
|
519
|
+
compatibility: ["browser", "nodejs"],
|
|
520
|
+
fn: equalsLength
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
name: "some",
|
|
524
|
+
category: "array",
|
|
525
|
+
compatibility: ["browser", "nodejs"],
|
|
526
|
+
fn: some
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
name: "eachIndex",
|
|
530
|
+
category: "array",
|
|
531
|
+
compatibility: ["browser", "nodejs"],
|
|
532
|
+
fn: eachIndex
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "withAfter",
|
|
536
|
+
category: "array",
|
|
537
|
+
compatibility: ["browser", "nodejs"],
|
|
538
|
+
fn: withAfter
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
name: "withBefore",
|
|
542
|
+
category: "array",
|
|
543
|
+
compatibility: ["browser", "nodejs"],
|
|
544
|
+
fn: withBefore
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
name: "withFirst",
|
|
548
|
+
category: "array",
|
|
549
|
+
compatibility: ["browser", "nodejs"],
|
|
550
|
+
fn: withFirst
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
name: "withLast",
|
|
554
|
+
category: "array",
|
|
555
|
+
compatibility: ["browser", "nodejs"],
|
|
556
|
+
fn: withLast
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
name: "withGroup",
|
|
560
|
+
category: "array",
|
|
561
|
+
compatibility: ["browser", "nodejs"],
|
|
562
|
+
fn: withGroup
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
name: "withSort",
|
|
566
|
+
category: "array",
|
|
567
|
+
compatibility: ["browser", "nodejs"],
|
|
568
|
+
fn: withSort
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
name: "filter",
|
|
572
|
+
category: "array",
|
|
573
|
+
compatibility: ["browser", "nodejs"],
|
|
574
|
+
fn: filter
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: "map",
|
|
578
|
+
category: "array",
|
|
579
|
+
compatibility: ["browser", "nodejs"],
|
|
580
|
+
fn: map
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: "pluck",
|
|
584
|
+
category: "array",
|
|
585
|
+
compatibility: ["browser", "nodejs"],
|
|
586
|
+
fn: pluck
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
name: "reverse",
|
|
590
|
+
category: "array",
|
|
591
|
+
compatibility: ["browser", "nodejs"],
|
|
592
|
+
fn: reverse
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: "sort",
|
|
596
|
+
category: "array",
|
|
597
|
+
compatibility: ["browser", "nodejs"],
|
|
598
|
+
fn: sort
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
name: "sortBy",
|
|
602
|
+
category: "array",
|
|
603
|
+
compatibility: ["browser", "nodejs"],
|
|
604
|
+
fn: sortBy
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: "unique",
|
|
608
|
+
category: "array",
|
|
609
|
+
compatibility: ["browser", "nodejs"],
|
|
610
|
+
fn: unique
|
|
173
611
|
}
|
|
174
612
|
];
|
|
175
613
|
|
|
@@ -191,8 +629,8 @@ var embed = (filepath, language) => {
|
|
|
191
629
|
var gist = (id) => {
|
|
192
630
|
return (0, import_html_tag.default)("script", { src: `https://gist.github.com/${id}.js` });
|
|
193
631
|
};
|
|
194
|
-
var jsfiddle = (
|
|
195
|
-
if (!
|
|
632
|
+
var jsfiddle = (options2) => {
|
|
633
|
+
if (!options2 || !options2.id) {
|
|
196
634
|
throw new Error("jsfiddle helper expects an `id`");
|
|
197
635
|
}
|
|
198
636
|
const {
|
|
@@ -203,7 +641,7 @@ var jsfiddle = (options) => {
|
|
|
203
641
|
tabs = "result,js,html,css",
|
|
204
642
|
allowfullscreen = "allowfullscreen",
|
|
205
643
|
frameborder = "0"
|
|
206
|
-
} =
|
|
644
|
+
} = options2;
|
|
207
645
|
const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
|
|
208
646
|
return (0, import_html_tag.default)("iframe", { width, height, src, allowfullscreen, frameborder });
|
|
209
647
|
};
|
|
@@ -524,17 +962,164 @@ var helpers4 = [
|
|
|
524
962
|
// src/helpers/date.ts
|
|
525
963
|
var import_chrono_node = require("chrono-node");
|
|
526
964
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
965
|
+
var import_isBetween = __toESM(require("dayjs/plugin/isBetween.js"), 1);
|
|
966
|
+
var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime.js"), 1);
|
|
967
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone.js"), 1);
|
|
968
|
+
var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
|
|
969
|
+
import_dayjs.default.extend(import_relativeTime.default);
|
|
970
|
+
import_dayjs.default.extend(import_isBetween.default);
|
|
971
|
+
import_dayjs.default.extend(import_utc.default);
|
|
972
|
+
import_dayjs.default.extend(import_timezone.default);
|
|
973
|
+
var parseDateInput = (input) => {
|
|
974
|
+
if (!input) {
|
|
975
|
+
return (0, import_dayjs.default)();
|
|
976
|
+
}
|
|
977
|
+
if (typeof input === "string") {
|
|
978
|
+
const parsed = (0, import_chrono_node.parseDate)(input);
|
|
979
|
+
if (parsed) {
|
|
980
|
+
return (0, import_dayjs.default)(parsed);
|
|
981
|
+
}
|
|
982
|
+
return (0, import_dayjs.default)(input);
|
|
983
|
+
}
|
|
984
|
+
return (0, import_dayjs.default)(input);
|
|
985
|
+
};
|
|
527
986
|
var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
528
987
|
var convertFormatString = (format2) => {
|
|
529
|
-
return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH")
|
|
988
|
+
return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH");
|
|
530
989
|
};
|
|
531
990
|
var date = (humanReadableDate, formatString) => {
|
|
532
|
-
const
|
|
533
|
-
|
|
991
|
+
const defaultFormat = "YYYY-MM-DD";
|
|
992
|
+
const format2 = formatString || defaultFormat;
|
|
993
|
+
const parsedDate = parseDateInput(humanReadableDate);
|
|
994
|
+
if (!parsedDate.isValid()) {
|
|
534
995
|
throw new Error(`Unable to parse date: ${humanReadableDate}`);
|
|
535
996
|
}
|
|
536
|
-
const convertedFormat = convertFormatString(
|
|
537
|
-
return
|
|
997
|
+
const convertedFormat = convertFormatString(format2);
|
|
998
|
+
return parsedDate.format(convertedFormat);
|
|
999
|
+
};
|
|
1000
|
+
var timestamp = () => {
|
|
1001
|
+
return Date.now().toString();
|
|
1002
|
+
};
|
|
1003
|
+
var now = (formatString) => {
|
|
1004
|
+
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
|
|
1005
|
+
const format2 = formatString || defaultFormat;
|
|
1006
|
+
const convertedFormat = convertFormatString(format2);
|
|
1007
|
+
return (0, import_dayjs.default)().format(convertedFormat);
|
|
1008
|
+
};
|
|
1009
|
+
var fromNow = (dateInput) => {
|
|
1010
|
+
const parsed = parseDateInput(dateInput);
|
|
1011
|
+
if (!parsed.isValid()) {
|
|
1012
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1013
|
+
}
|
|
1014
|
+
return parsed.fromNow();
|
|
1015
|
+
};
|
|
1016
|
+
var toNow = (dateInput) => {
|
|
1017
|
+
const parsed = parseDateInput(dateInput);
|
|
1018
|
+
if (!parsed.isValid()) {
|
|
1019
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1020
|
+
}
|
|
1021
|
+
return parsed.toNow();
|
|
1022
|
+
};
|
|
1023
|
+
var ago = (dateInput) => {
|
|
1024
|
+
return fromNow(dateInput);
|
|
1025
|
+
};
|
|
1026
|
+
var dateAdd = (dateInput, amount, unit) => {
|
|
1027
|
+
const parsed = parseDateInput(dateInput);
|
|
1028
|
+
if (!parsed.isValid()) {
|
|
1029
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1030
|
+
}
|
|
1031
|
+
return parsed.add(amount, unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1032
|
+
};
|
|
1033
|
+
var dateSubtract = (dateInput, amount, unit) => {
|
|
1034
|
+
const parsed = parseDateInput(dateInput);
|
|
1035
|
+
if (!parsed.isValid()) {
|
|
1036
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1037
|
+
}
|
|
1038
|
+
return parsed.subtract(amount, unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1039
|
+
};
|
|
1040
|
+
var startOf = (dateInput, unit) => {
|
|
1041
|
+
const parsed = parseDateInput(dateInput);
|
|
1042
|
+
if (!parsed.isValid()) {
|
|
1043
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1044
|
+
}
|
|
1045
|
+
return parsed.startOf(unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1046
|
+
};
|
|
1047
|
+
var endOf = (dateInput, unit) => {
|
|
1048
|
+
const parsed = parseDateInput(dateInput);
|
|
1049
|
+
if (!parsed.isValid()) {
|
|
1050
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1051
|
+
}
|
|
1052
|
+
return parsed.endOf(unit).format("YYYY-MM-DD HH:mm:ss");
|
|
1053
|
+
};
|
|
1054
|
+
var isBefore = (date1, date2) => {
|
|
1055
|
+
const parsed1 = parseDateInput(date1);
|
|
1056
|
+
const parsed2 = parseDateInput(date2);
|
|
1057
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1058
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1059
|
+
}
|
|
1060
|
+
return parsed1.isBefore(parsed2);
|
|
1061
|
+
};
|
|
1062
|
+
var isAfter = (date1, date2) => {
|
|
1063
|
+
const parsed1 = parseDateInput(date1);
|
|
1064
|
+
const parsed2 = parseDateInput(date2);
|
|
1065
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1066
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1067
|
+
}
|
|
1068
|
+
return parsed1.isAfter(parsed2);
|
|
1069
|
+
};
|
|
1070
|
+
var isSame = (date1, date2, unit) => {
|
|
1071
|
+
const parsed1 = parseDateInput(date1);
|
|
1072
|
+
const parsed2 = parseDateInput(date2);
|
|
1073
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1074
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1075
|
+
}
|
|
1076
|
+
return parsed1.isSame(parsed2, unit);
|
|
1077
|
+
};
|
|
1078
|
+
var isBetweenDates = (dateInput, startDate, endDate) => {
|
|
1079
|
+
const parsed = parseDateInput(dateInput);
|
|
1080
|
+
const parsedStart = parseDateInput(startDate);
|
|
1081
|
+
const parsedEnd = parseDateInput(endDate);
|
|
1082
|
+
if (!parsed.isValid() || !parsedStart.isValid() || !parsedEnd.isValid()) {
|
|
1083
|
+
throw new Error(
|
|
1084
|
+
`Unable to parse dates: ${dateInput}, ${startDate}, ${endDate}`
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1087
|
+
return parsed.isBetween(parsedStart, parsedEnd, null, "[]");
|
|
1088
|
+
};
|
|
1089
|
+
var diff = (date1, date2, unit) => {
|
|
1090
|
+
const parsed1 = parseDateInput(date1);
|
|
1091
|
+
const parsed2 = parseDateInput(date2);
|
|
1092
|
+
if (!parsed1.isValid() || !parsed2.isValid()) {
|
|
1093
|
+
throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
|
|
1094
|
+
}
|
|
1095
|
+
return parsed1.diff(parsed2, unit);
|
|
1096
|
+
};
|
|
1097
|
+
var toISOString = (dateInput) => {
|
|
1098
|
+
const parsed = parseDateInput(dateInput);
|
|
1099
|
+
if (!parsed.isValid()) {
|
|
1100
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1101
|
+
}
|
|
1102
|
+
return parsed.toISOString();
|
|
1103
|
+
};
|
|
1104
|
+
var dateTimezone = (dateInput, timezoneStr, formatString) => {
|
|
1105
|
+
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
|
|
1106
|
+
const format2 = formatString || defaultFormat;
|
|
1107
|
+
const convertedFormat = convertFormatString(format2);
|
|
1108
|
+
const parsed = parseDateInput(dateInput);
|
|
1109
|
+
if (!parsed.isValid()) {
|
|
1110
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1111
|
+
}
|
|
1112
|
+
return parsed.tz(timezoneStr).format(convertedFormat);
|
|
1113
|
+
};
|
|
1114
|
+
var dateLocale = (dateInput, locale, formatString) => {
|
|
1115
|
+
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
|
|
1116
|
+
const format2 = formatString || defaultFormat;
|
|
1117
|
+
const convertedFormat = convertFormatString(format2);
|
|
1118
|
+
const parsed = parseDateInput(dateInput);
|
|
1119
|
+
if (!parsed.isValid()) {
|
|
1120
|
+
throw new Error(`Unable to parse date: ${dateInput}`);
|
|
1121
|
+
}
|
|
1122
|
+
return parsed.locale(locale).format(convertedFormat);
|
|
538
1123
|
};
|
|
539
1124
|
var helpers5 = [
|
|
540
1125
|
{
|
|
@@ -555,6 +1140,108 @@ var helpers5 = [
|
|
|
555
1140
|
category: "date",
|
|
556
1141
|
compatibility: ["browser", "nodejs"],
|
|
557
1142
|
fn: date
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
name: "timestamp",
|
|
1146
|
+
category: "date",
|
|
1147
|
+
compatibility: ["browser", "nodejs"],
|
|
1148
|
+
fn: timestamp
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
name: "now",
|
|
1152
|
+
category: "date",
|
|
1153
|
+
compatibility: ["browser", "nodejs"],
|
|
1154
|
+
fn: now
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
name: "fromNow",
|
|
1158
|
+
category: "date",
|
|
1159
|
+
compatibility: ["browser", "nodejs"],
|
|
1160
|
+
fn: fromNow
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
name: "toNow",
|
|
1164
|
+
category: "date",
|
|
1165
|
+
compatibility: ["browser", "nodejs"],
|
|
1166
|
+
fn: toNow
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
name: "ago",
|
|
1170
|
+
category: "date",
|
|
1171
|
+
compatibility: ["browser", "nodejs"],
|
|
1172
|
+
fn: ago
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
name: "dateAdd",
|
|
1176
|
+
category: "date",
|
|
1177
|
+
compatibility: ["browser", "nodejs"],
|
|
1178
|
+
fn: dateAdd
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
name: "dateSubtract",
|
|
1182
|
+
category: "date",
|
|
1183
|
+
compatibility: ["browser", "nodejs"],
|
|
1184
|
+
fn: dateSubtract
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
name: "startOf",
|
|
1188
|
+
category: "date",
|
|
1189
|
+
compatibility: ["browser", "nodejs"],
|
|
1190
|
+
fn: startOf
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
name: "endOf",
|
|
1194
|
+
category: "date",
|
|
1195
|
+
compatibility: ["browser", "nodejs"],
|
|
1196
|
+
fn: endOf
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
name: "isBefore",
|
|
1200
|
+
category: "date",
|
|
1201
|
+
compatibility: ["browser", "nodejs"],
|
|
1202
|
+
fn: isBefore
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
name: "isAfter",
|
|
1206
|
+
category: "date",
|
|
1207
|
+
compatibility: ["browser", "nodejs"],
|
|
1208
|
+
fn: isAfter
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
name: "isSame",
|
|
1212
|
+
category: "date",
|
|
1213
|
+
compatibility: ["browser", "nodejs"],
|
|
1214
|
+
fn: isSame
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "isBetween",
|
|
1218
|
+
category: "date",
|
|
1219
|
+
compatibility: ["browser", "nodejs"],
|
|
1220
|
+
fn: isBetweenDates
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
name: "diff",
|
|
1224
|
+
category: "date",
|
|
1225
|
+
compatibility: ["browser", "nodejs"],
|
|
1226
|
+
fn: diff
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "toISOString",
|
|
1230
|
+
category: "date",
|
|
1231
|
+
compatibility: ["browser", "nodejs"],
|
|
1232
|
+
fn: toISOString
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
name: "dateTimezone",
|
|
1236
|
+
category: "date",
|
|
1237
|
+
compatibility: ["browser", "nodejs"],
|
|
1238
|
+
fn: dateTimezone
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "dateLocale",
|
|
1242
|
+
category: "date",
|
|
1243
|
+
compatibility: ["browser", "nodejs"],
|
|
1244
|
+
fn: dateLocale
|
|
558
1245
|
}
|
|
559
1246
|
];
|
|
560
1247
|
|
|
@@ -588,9 +1275,9 @@ var isOptions = (value) => {
|
|
|
588
1275
|
value && typeof value === "object" && "hash" in value
|
|
589
1276
|
);
|
|
590
1277
|
};
|
|
591
|
-
var readdir = (dir,
|
|
1278
|
+
var readdir = (dir, filter2) => {
|
|
592
1279
|
const files = import_node_fs2.default.readdirSync(dir).map((fp) => import_node_path2.default.join(dir, fp));
|
|
593
|
-
const filterArg = isOptions(
|
|
1280
|
+
const filterArg = isOptions(filter2) ? void 0 : filter2;
|
|
594
1281
|
if (typeof filterArg === "function") {
|
|
595
1282
|
return filterArg(files);
|
|
596
1283
|
}
|
|
@@ -636,13 +1323,13 @@ var import_node_path3 = __toESM(require("path"), 1);
|
|
|
636
1323
|
var import_html_tag2 = __toESM(require("html-tag"), 1);
|
|
637
1324
|
var import_striptags = __toESM(require("striptags"), 1);
|
|
638
1325
|
var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
|
|
639
|
-
var attr = (
|
|
640
|
-
const val = parseAttributes(
|
|
1326
|
+
var attr = (options2) => {
|
|
1327
|
+
const val = parseAttributes(options2?.hash ?? {});
|
|
641
1328
|
return val.trim() ? ` ${val}` : "";
|
|
642
1329
|
};
|
|
643
|
-
var css = function(list,
|
|
1330
|
+
var css = function(list, options2) {
|
|
644
1331
|
if (arguments.length < 2) {
|
|
645
|
-
|
|
1332
|
+
options2 = list;
|
|
646
1333
|
list = [];
|
|
647
1334
|
}
|
|
648
1335
|
let styles = arrayify(list ?? []);
|
|
@@ -650,8 +1337,8 @@ var css = function(list, options) {
|
|
|
650
1337
|
if (this && this.options) {
|
|
651
1338
|
assets = this.options.assets || "";
|
|
652
1339
|
}
|
|
653
|
-
if (
|
|
654
|
-
styles = arrayify(
|
|
1340
|
+
if (options2?.hash?.href) {
|
|
1341
|
+
styles = arrayify(options2.hash.href);
|
|
655
1342
|
}
|
|
656
1343
|
return styles.map((item) => {
|
|
657
1344
|
const ext = import_node_path3.default.extname(item);
|
|
@@ -682,18 +1369,18 @@ var sanitize = (str) => {
|
|
|
682
1369
|
if (typeof str !== "string") return "";
|
|
683
1370
|
return (0, import_striptags.default)(str).trim();
|
|
684
1371
|
};
|
|
685
|
-
var ul = (context,
|
|
686
|
-
const attrs = parseAttributes(
|
|
1372
|
+
var ul = (context, options2) => {
|
|
1373
|
+
const attrs = parseAttributes(options2.hash ?? {});
|
|
687
1374
|
const items = context.map(
|
|
688
|
-
(item) => typeof item === "string" ? item :
|
|
1375
|
+
(item) => typeof item === "string" ? item : options2.fn(item)
|
|
689
1376
|
);
|
|
690
1377
|
const open = attrs ? `<ul ${attrs}>` : "<ul>";
|
|
691
1378
|
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
|
|
692
1379
|
};
|
|
693
|
-
var ol = (context,
|
|
694
|
-
const attrs = parseAttributes(
|
|
1380
|
+
var ol = (context, options2) => {
|
|
1381
|
+
const attrs = parseAttributes(options2.hash ?? {});
|
|
695
1382
|
const items = context.map(
|
|
696
|
-
(item) => typeof item === "string" ? item :
|
|
1383
|
+
(item) => typeof item === "string" ? item : options2.fn(item)
|
|
697
1384
|
);
|
|
698
1385
|
const open = attrs ? `<ol ${attrs}>` : "<ol>";
|
|
699
1386
|
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
|
|
@@ -810,11 +1497,32 @@ var getObject = (object, path6) => {
|
|
|
810
1497
|
}
|
|
811
1498
|
return { [finalKey]: current[finalKey] };
|
|
812
1499
|
};
|
|
1500
|
+
var options = (thisArg, locals, opts) => {
|
|
1501
|
+
const result = {};
|
|
1502
|
+
if (thisArg && typeof thisArg === "object" && thisArg.options) {
|
|
1503
|
+
Object.assign(result, thisArg.options);
|
|
1504
|
+
}
|
|
1505
|
+
if (locals && typeof locals === "object") {
|
|
1506
|
+
if ("hash" in locals) {
|
|
1507
|
+
Object.assign(result, locals.hash);
|
|
1508
|
+
} else {
|
|
1509
|
+
Object.assign(result, locals);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
if (opts && typeof opts === "object") {
|
|
1513
|
+
if ("hash" in opts) {
|
|
1514
|
+
Object.assign(result, opts.hash);
|
|
1515
|
+
} else {
|
|
1516
|
+
Object.assign(result, opts);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
return result;
|
|
1520
|
+
};
|
|
813
1521
|
|
|
814
1522
|
// src/helpers/i18n.ts
|
|
815
|
-
var i18n = function(prop, locals,
|
|
816
|
-
if (locals && typeof locals === "object" && "hash" in locals &&
|
|
817
|
-
|
|
1523
|
+
var i18n = function(prop, locals, options2) {
|
|
1524
|
+
if (locals && typeof locals === "object" && "hash" in locals && options2 === void 0) {
|
|
1525
|
+
options2 = locals;
|
|
818
1526
|
locals = {};
|
|
819
1527
|
}
|
|
820
1528
|
if (typeof prop !== "string") {
|
|
@@ -823,7 +1531,7 @@ var i18n = function(prop, locals, options) {
|
|
|
823
1531
|
const context = {
|
|
824
1532
|
...this,
|
|
825
1533
|
...locals,
|
|
826
|
-
...
|
|
1534
|
+
...options2?.hash ?? {}
|
|
827
1535
|
};
|
|
828
1536
|
const lang = context.language || context.lang;
|
|
829
1537
|
if (typeof lang !== "string") {
|
|
@@ -959,9 +1667,9 @@ function _debug(...args) {
|
|
|
959
1667
|
console.error(colors.cyan(separator));
|
|
960
1668
|
return "";
|
|
961
1669
|
}
|
|
962
|
-
function _inspect(context,
|
|
1670
|
+
function _inspect(context, options2) {
|
|
963
1671
|
const val = JSON.stringify(context, null, 2);
|
|
964
|
-
const type =
|
|
1672
|
+
const type = options2?.hash?.type || "html";
|
|
965
1673
|
return switchOutput(type, val);
|
|
966
1674
|
}
|
|
967
1675
|
function switchOutput(type, json) {
|
|
@@ -1054,12 +1762,12 @@ var helpers10 = [
|
|
|
1054
1762
|
|
|
1055
1763
|
// src/helpers/match.ts
|
|
1056
1764
|
var import_micromatch2 = __toESM(require("micromatch"), 1);
|
|
1057
|
-
var match = (files, patterns,
|
|
1765
|
+
var match = (files, patterns, options2) => {
|
|
1058
1766
|
const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
|
|
1059
|
-
return (0, import_micromatch2.default)(files, pats,
|
|
1767
|
+
return (0, import_micromatch2.default)(files, pats, options2);
|
|
1060
1768
|
};
|
|
1061
|
-
var isMatch = (filepath, pattern,
|
|
1062
|
-
return import_micromatch2.default.isMatch(filepath, pattern,
|
|
1769
|
+
var isMatch = (filepath, pattern, options2) => {
|
|
1770
|
+
return import_micromatch2.default.isMatch(filepath, pattern, options2);
|
|
1063
1771
|
};
|
|
1064
1772
|
var mm = (...args) => {
|
|
1065
1773
|
console.log("the {{mm}} helper is depcrecated and will be removed");
|
|
@@ -1275,14 +1983,14 @@ var import_node_process = __toESM(require("process"), 1);
|
|
|
1275
1983
|
var import_ent = __toESM(require("ent"), 1);
|
|
1276
1984
|
var import_handlebars = __toESM(require("handlebars"), 1);
|
|
1277
1985
|
var import_remarkable = require("remarkable");
|
|
1278
|
-
var renderMarkdown = function(input,
|
|
1986
|
+
var renderMarkdown = function(input, options2) {
|
|
1279
1987
|
if (typeof input === "object" && input && "fn" in input && typeof input.fn === "function") {
|
|
1280
|
-
|
|
1988
|
+
options2 = input;
|
|
1281
1989
|
input = input.fn(this);
|
|
1282
1990
|
} else if (typeof input !== "string") {
|
|
1283
1991
|
input = "";
|
|
1284
1992
|
}
|
|
1285
|
-
const options_ = { cwd: import_node_process.default.cwd(), ...
|
|
1993
|
+
const options_ = { cwd: import_node_process.default.cwd(), ...options2 };
|
|
1286
1994
|
const md = new import_remarkable.Remarkable({
|
|
1287
1995
|
breaks: true,
|
|
1288
1996
|
html: true,
|
|
@@ -1316,34 +2024,33 @@ var helpers13 = [
|
|
|
1316
2024
|
|
|
1317
2025
|
// src/helpers/misc.ts
|
|
1318
2026
|
var import_handlebars2 = __toESM(require("handlebars"), 1);
|
|
1319
|
-
var import_handlebars_utils = __toESM(require("handlebars-utils"), 1);
|
|
1320
2027
|
var import_kind_of = __toESM(require("kind-of"), 1);
|
|
1321
|
-
function frame(context,
|
|
2028
|
+
function frame(context, options2) {
|
|
1322
2029
|
if (typeof context === "object" && context !== null && "hash" in context) {
|
|
1323
|
-
|
|
1324
|
-
context =
|
|
2030
|
+
options2 = context;
|
|
2031
|
+
context = options2.data;
|
|
1325
2032
|
}
|
|
1326
2033
|
const data = import_handlebars2.default.createFrame(context || {});
|
|
1327
|
-
if (typeof
|
|
1328
|
-
|
|
2034
|
+
if (typeof options2 !== "object" || options2 === null) {
|
|
2035
|
+
options2 = {};
|
|
1329
2036
|
}
|
|
1330
|
-
if (
|
|
1331
|
-
Object.assign(data,
|
|
2037
|
+
if (options2.hash && typeof options2.hash === "object") {
|
|
2038
|
+
Object.assign(data, options2.hash);
|
|
1332
2039
|
}
|
|
1333
|
-
return
|
|
2040
|
+
return options2.fn(this, { data });
|
|
1334
2041
|
}
|
|
1335
|
-
function option(prop, locals,
|
|
1336
|
-
return get(
|
|
2042
|
+
function option(prop, locals, opts) {
|
|
2043
|
+
return get(options(this, locals, opts), prop);
|
|
1337
2044
|
}
|
|
1338
|
-
function noop(
|
|
1339
|
-
return
|
|
2045
|
+
function noop(options2) {
|
|
2046
|
+
return options2.fn(this);
|
|
1340
2047
|
}
|
|
1341
2048
|
var typeOf = import_kind_of.default;
|
|
1342
|
-
function withHash(
|
|
1343
|
-
if (
|
|
1344
|
-
return
|
|
2049
|
+
function withHash(options2) {
|
|
2050
|
+
if (options2.hash && Object.keys(options2.hash).length) {
|
|
2051
|
+
return options2.fn(options2.hash);
|
|
1345
2052
|
}
|
|
1346
|
-
return
|
|
2053
|
+
return options2.inverse(this);
|
|
1347
2054
|
}
|
|
1348
2055
|
var helpers14 = [
|
|
1349
2056
|
{
|
|
@@ -1503,8 +2210,8 @@ var helpers15 = [
|
|
|
1503
2210
|
var isOptions2 = (value) => {
|
|
1504
2211
|
return Boolean(value && typeof value === "object" && "hash" in value);
|
|
1505
2212
|
};
|
|
1506
|
-
var createFrame = (
|
|
1507
|
-
...
|
|
2213
|
+
var createFrame = (options2, hash) => ({
|
|
2214
|
+
...options2?.data || {},
|
|
1508
2215
|
...hash
|
|
1509
2216
|
});
|
|
1510
2217
|
var extend = (...objects) => {
|
|
@@ -1521,28 +2228,28 @@ var extend = (...objects) => {
|
|
|
1521
2228
|
}
|
|
1522
2229
|
return result;
|
|
1523
2230
|
};
|
|
1524
|
-
var forIn = (obj,
|
|
1525
|
-
if (!isOptions2(
|
|
1526
|
-
return
|
|
2231
|
+
var forIn = (obj, options2) => {
|
|
2232
|
+
if (!isOptions2(options2)) {
|
|
2233
|
+
return options2?.inverse?.(obj) ?? "";
|
|
1527
2234
|
}
|
|
1528
|
-
const data = createFrame(
|
|
2235
|
+
const data = createFrame(options2, options2.hash || {});
|
|
1529
2236
|
let result = "";
|
|
1530
2237
|
for (const key in obj) {
|
|
1531
2238
|
data.key = key;
|
|
1532
|
-
result +=
|
|
2239
|
+
result += options2.fn(obj[key], { data });
|
|
1533
2240
|
}
|
|
1534
2241
|
return result;
|
|
1535
2242
|
};
|
|
1536
|
-
var forOwn = (obj,
|
|
1537
|
-
if (!isOptions2(
|
|
1538
|
-
return
|
|
2243
|
+
var forOwn = (obj, options2) => {
|
|
2244
|
+
if (!isOptions2(options2)) {
|
|
2245
|
+
return options2?.inverse?.(obj) ?? "";
|
|
1539
2246
|
}
|
|
1540
|
-
const data = createFrame(
|
|
2247
|
+
const data = createFrame(options2, options2.hash || {});
|
|
1541
2248
|
let result = "";
|
|
1542
2249
|
for (const key in obj) {
|
|
1543
2250
|
if (Object.hasOwn(obj, key)) {
|
|
1544
2251
|
data.key = key;
|
|
1545
|
-
result +=
|
|
2252
|
+
result += options2.fn(obj[key], { data });
|
|
1546
2253
|
}
|
|
1547
2254
|
}
|
|
1548
2255
|
return result;
|
|
@@ -1556,10 +2263,10 @@ var toPath = (...prop) => {
|
|
|
1556
2263
|
}
|
|
1557
2264
|
return parts.join(".");
|
|
1558
2265
|
};
|
|
1559
|
-
var getHelper = (prop, context,
|
|
2266
|
+
var getHelper = (prop, context, options2) => {
|
|
1560
2267
|
const val = get(context, prop);
|
|
1561
|
-
if (
|
|
1562
|
-
return val ?
|
|
2268
|
+
if (options2 && typeof options2.fn === "function") {
|
|
2269
|
+
return val ? options2.fn(val) : options2.inverse?.(context);
|
|
1563
2270
|
}
|
|
1564
2271
|
return val;
|
|
1565
2272
|
};
|
|
@@ -1589,17 +2296,17 @@ var merge = (context, ...objects) => {
|
|
|
1589
2296
|
};
|
|
1590
2297
|
var parseJSON = JSONparse;
|
|
1591
2298
|
var stringify = JSONstringify;
|
|
1592
|
-
var pick = (props, context,
|
|
2299
|
+
var pick = (props, context, options2) => {
|
|
1593
2300
|
const keys = arrayify(props);
|
|
1594
2301
|
let result = {};
|
|
1595
2302
|
for (const key of keys) {
|
|
1596
2303
|
result = Object.assign({}, result, getObject(context, key));
|
|
1597
2304
|
}
|
|
1598
|
-
if (
|
|
2305
|
+
if (options2 && typeof options2.fn === "function") {
|
|
1599
2306
|
if (Object.keys(result).length) {
|
|
1600
|
-
return
|
|
2307
|
+
return options2.fn(result);
|
|
1601
2308
|
}
|
|
1602
|
-
return
|
|
2309
|
+
return options2.inverse?.(context);
|
|
1603
2310
|
}
|
|
1604
2311
|
return result;
|
|
1605
2312
|
};
|
|
@@ -1702,9 +2409,9 @@ var assertString = (name, value) => {
|
|
|
1702
2409
|
}
|
|
1703
2410
|
return value;
|
|
1704
2411
|
};
|
|
1705
|
-
var absolute = function(filepath,
|
|
2412
|
+
var absolute = function(filepath, options2) {
|
|
1706
2413
|
const fp = assertString("filepath", filepath);
|
|
1707
|
-
const cwd =
|
|
2414
|
+
const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1708
2415
|
return import_node_path5.default.resolve(cwd, fp);
|
|
1709
2416
|
};
|
|
1710
2417
|
var dirname = (filepath) => {
|
|
@@ -1729,12 +2436,12 @@ var extname = (filepath) => {
|
|
|
1729
2436
|
return import_node_path5.default.extname(fp);
|
|
1730
2437
|
};
|
|
1731
2438
|
var resolveFn = function(filepath, ...paths) {
|
|
1732
|
-
let
|
|
2439
|
+
let options2;
|
|
1733
2440
|
const last2 = paths[paths.length - 1];
|
|
1734
2441
|
if (typeof last2 === "object" && last2 && "data" in last2) {
|
|
1735
|
-
|
|
2442
|
+
options2 = paths.pop();
|
|
1736
2443
|
}
|
|
1737
|
-
const cwd =
|
|
2444
|
+
const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1738
2445
|
const all2 = [
|
|
1739
2446
|
cwd,
|
|
1740
2447
|
assertString("filepath", filepath),
|
|
@@ -1801,10 +2508,9 @@ var helpers17 = [
|
|
|
1801
2508
|
];
|
|
1802
2509
|
|
|
1803
2510
|
// src/helpers/regex.ts
|
|
1804
|
-
var
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
return new RegExp(str, opts.flags);
|
|
2511
|
+
var toRegex = (str, locals, opts) => {
|
|
2512
|
+
const mergedOpts = options({}, locals, opts);
|
|
2513
|
+
return new RegExp(str, mergedOpts.flags);
|
|
1808
2514
|
};
|
|
1809
2515
|
var test = (str, regex) => {
|
|
1810
2516
|
if (typeof str !== "string") {
|
|
@@ -1941,7 +2647,7 @@ var replaceFirst = (str, a, b) => {
|
|
|
1941
2647
|
if (typeof b !== "string") b = "";
|
|
1942
2648
|
return str.replace(a, b);
|
|
1943
2649
|
};
|
|
1944
|
-
var
|
|
2650
|
+
var reverse2 = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
|
|
1945
2651
|
var sentence = (str) => {
|
|
1946
2652
|
if (typeof str !== "string") return "";
|
|
1947
2653
|
return str.replace(
|
|
@@ -1977,6 +2683,29 @@ var uppercase = (str) => {
|
|
|
1977
2683
|
return str.toUpperCase();
|
|
1978
2684
|
};
|
|
1979
2685
|
var upcase = (str) => uppercase(str);
|
|
2686
|
+
var split = (str, character) => {
|
|
2687
|
+
if (typeof str !== "string") return "";
|
|
2688
|
+
if (typeof character !== "string") character = "";
|
|
2689
|
+
return str.split(character);
|
|
2690
|
+
};
|
|
2691
|
+
var startsWith = (prefix, testString, _options) => {
|
|
2692
|
+
if (typeof prefix !== "string" || typeof testString !== "string") {
|
|
2693
|
+
return false;
|
|
2694
|
+
}
|
|
2695
|
+
return testString.startsWith(prefix);
|
|
2696
|
+
};
|
|
2697
|
+
var titleize = (str) => {
|
|
2698
|
+
if (typeof str !== "string") return "";
|
|
2699
|
+
return str.replace(/\w\S*/g, (word) => {
|
|
2700
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
2701
|
+
});
|
|
2702
|
+
};
|
|
2703
|
+
var raw = (options2) => {
|
|
2704
|
+
if (options2 && typeof options2.fn === "function") {
|
|
2705
|
+
return options2.fn();
|
|
2706
|
+
}
|
|
2707
|
+
return "";
|
|
2708
|
+
};
|
|
1980
2709
|
var helpers19 = [
|
|
1981
2710
|
{
|
|
1982
2711
|
name: "append",
|
|
@@ -2114,7 +2843,7 @@ var helpers19 = [
|
|
|
2114
2843
|
name: "reverse",
|
|
2115
2844
|
category: "string",
|
|
2116
2845
|
compatibility: ["browser", "nodejs"],
|
|
2117
|
-
fn:
|
|
2846
|
+
fn: reverse2
|
|
2118
2847
|
},
|
|
2119
2848
|
{
|
|
2120
2849
|
name: "sentence",
|
|
@@ -2169,6 +2898,30 @@ var helpers19 = [
|
|
|
2169
2898
|
category: "string",
|
|
2170
2899
|
compatibility: ["browser", "nodejs"],
|
|
2171
2900
|
fn: upcase
|
|
2901
|
+
},
|
|
2902
|
+
{
|
|
2903
|
+
name: "split",
|
|
2904
|
+
category: "string",
|
|
2905
|
+
compatibility: ["browser", "nodejs"],
|
|
2906
|
+
fn: split
|
|
2907
|
+
},
|
|
2908
|
+
{
|
|
2909
|
+
name: "startsWith",
|
|
2910
|
+
category: "string",
|
|
2911
|
+
compatibility: ["browser", "nodejs"],
|
|
2912
|
+
fn: startsWith
|
|
2913
|
+
},
|
|
2914
|
+
{
|
|
2915
|
+
name: "titleize",
|
|
2916
|
+
category: "string",
|
|
2917
|
+
compatibility: ["browser", "nodejs"],
|
|
2918
|
+
fn: titleize
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
name: "raw",
|
|
2922
|
+
category: "string",
|
|
2923
|
+
compatibility: ["browser", "nodejs"],
|
|
2924
|
+
fn: raw
|
|
2172
2925
|
}
|
|
2173
2926
|
];
|
|
2174
2927
|
|
|
@@ -2340,19 +3093,19 @@ var HelperRegistry = class {
|
|
|
2340
3093
|
* @param filter The filter criteria.
|
|
2341
3094
|
* @returns The filtered helpers.
|
|
2342
3095
|
*/
|
|
2343
|
-
filter(
|
|
3096
|
+
filter(filter2) {
|
|
2344
3097
|
let result = this._helpers;
|
|
2345
|
-
if (
|
|
2346
|
-
result = result.filter((helper) =>
|
|
3098
|
+
if (filter2.names) {
|
|
3099
|
+
result = result.filter((helper) => filter2.names?.includes(helper.name));
|
|
2347
3100
|
}
|
|
2348
|
-
if (
|
|
3101
|
+
if (filter2.categories) {
|
|
2349
3102
|
result = result.filter(
|
|
2350
|
-
(helper) =>
|
|
3103
|
+
(helper) => filter2.categories?.includes(helper.category)
|
|
2351
3104
|
);
|
|
2352
3105
|
}
|
|
2353
|
-
if (
|
|
3106
|
+
if (filter2.compatibility) {
|
|
2354
3107
|
result = result.filter(
|
|
2355
|
-
(helper) => helper.compatibility?.some((c) =>
|
|
3108
|
+
(helper) => helper.compatibility?.some((c) => filter2.compatibility?.includes(c))
|
|
2356
3109
|
);
|
|
2357
3110
|
}
|
|
2358
3111
|
return result;
|
|
@@ -2387,9 +3140,9 @@ var HelperRegistry = class {
|
|
|
2387
3140
|
// src/index.ts
|
|
2388
3141
|
var Handlebars3 = import_handlebars3.default;
|
|
2389
3142
|
var handlebars = import_handlebars3.default.create();
|
|
2390
|
-
function helpers21(
|
|
3143
|
+
function helpers21(options2) {
|
|
2391
3144
|
const registry = new HelperRegistry();
|
|
2392
|
-
registry.load(
|
|
3145
|
+
registry.load(options2.handlebars ?? options2.hbs);
|
|
2393
3146
|
}
|
|
2394
3147
|
async function createHandlebars() {
|
|
2395
3148
|
const registry = new HelperRegistry();
|
|
@@ -2405,11 +3158,11 @@ async function createHandlebars() {
|
|
|
2405
3158
|
}
|
|
2406
3159
|
return handlebars2;
|
|
2407
3160
|
}
|
|
2408
|
-
function fumanchu(
|
|
3161
|
+
function fumanchu(options2) {
|
|
2409
3162
|
const registry = new HelperRegistry();
|
|
2410
3163
|
let handlebars2 = import_handlebars3.default.create();
|
|
2411
|
-
if (
|
|
2412
|
-
handlebars2 =
|
|
3164
|
+
if (options2?.handlebars) {
|
|
3165
|
+
handlebars2 = options2.handlebars;
|
|
2413
3166
|
} else if (Object.keys(import_handlebars3.default.partials).length > 0) {
|
|
2414
3167
|
handlebars2.registerPartial(import_handlebars3.default.partials);
|
|
2415
3168
|
}
|
|
@@ -2425,4 +3178,5 @@ function fumanchu(options) {
|
|
|
2425
3178
|
handlebars,
|
|
2426
3179
|
helpers
|
|
2427
3180
|
});
|
|
3181
|
+
/* v8 ignore next -- @preserve */
|
|
2428
3182
|
/* c8 ignore next -- @preserve */
|