@jaredwray/fumanchu 4.0.1 → 4.0.2
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/README.md +23 -29
- package/dist/index.cjs +11 -2250
- package/dist/index.js +11 -2210
- package/package.json +13 -11
package/dist/index.js
CHANGED
|
@@ -1,2210 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return array.slice(0, -n);
|
|
12
|
-
};
|
|
13
|
-
var arrayify = (value) => {
|
|
14
|
-
if (value == null) return [];
|
|
15
|
-
return Array.isArray(value) ? value : [value];
|
|
16
|
-
};
|
|
17
|
-
var first = (array, n) => {
|
|
18
|
-
if (!Array.isArray(array)) return void 0;
|
|
19
|
-
if (typeof n !== "number") {
|
|
20
|
-
return array[0];
|
|
21
|
-
}
|
|
22
|
-
return array.slice(0, n);
|
|
23
|
-
};
|
|
24
|
-
var last = (value, n) => {
|
|
25
|
-
if (!Array.isArray(value) && typeof value !== "string") {
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
28
|
-
if (typeof n !== "number") {
|
|
29
|
-
const array = value;
|
|
30
|
-
return array[array.length - 1];
|
|
31
|
-
}
|
|
32
|
-
const start = Math.abs(n);
|
|
33
|
-
if (typeof value === "string") {
|
|
34
|
-
return value.slice(-start);
|
|
35
|
-
}
|
|
36
|
-
return value.slice(-start);
|
|
37
|
-
};
|
|
38
|
-
var length = (value) => {
|
|
39
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
40
|
-
return Object.keys(value).length;
|
|
41
|
-
}
|
|
42
|
-
if (typeof value === "string" || Array.isArray(value)) {
|
|
43
|
-
return value.length;
|
|
44
|
-
}
|
|
45
|
-
return 0;
|
|
46
|
-
};
|
|
47
|
-
var join = (array, separator = ", ") => {
|
|
48
|
-
if (typeof array === "string") return array;
|
|
49
|
-
if (!Array.isArray(array)) return "";
|
|
50
|
-
return array.join(separator);
|
|
51
|
-
};
|
|
52
|
-
var helpers = [
|
|
53
|
-
{
|
|
54
|
-
name: "after",
|
|
55
|
-
category: "array",
|
|
56
|
-
compatibility: ["browser", "nodejs"],
|
|
57
|
-
fn: after
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "before",
|
|
61
|
-
category: "array",
|
|
62
|
-
compatibility: ["browser", "nodejs"],
|
|
63
|
-
fn: before
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "arrayify",
|
|
67
|
-
category: "array",
|
|
68
|
-
compatibility: ["browser", "nodejs"],
|
|
69
|
-
fn: arrayify
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "first",
|
|
73
|
-
category: "array",
|
|
74
|
-
compatibility: ["browser", "nodejs"],
|
|
75
|
-
fn: first
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "last",
|
|
79
|
-
category: "array",
|
|
80
|
-
compatibility: ["browser", "nodejs"],
|
|
81
|
-
fn: last
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: "length",
|
|
85
|
-
category: "array",
|
|
86
|
-
compatibility: ["browser", "nodejs"],
|
|
87
|
-
fn: length
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: "join",
|
|
91
|
-
category: "array",
|
|
92
|
-
compatibility: ["browser", "nodejs"],
|
|
93
|
-
fn: join
|
|
94
|
-
}
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
// src/helpers/code.ts
|
|
98
|
-
import fs from "fs";
|
|
99
|
-
import path from "path";
|
|
100
|
-
import tag from "html-tag";
|
|
101
|
-
import codeBlock from "to-gfm-code-block";
|
|
102
|
-
var embed = (filepath, language) => {
|
|
103
|
-
let ext = typeof language === "string" ? language : path.extname(filepath).slice(1);
|
|
104
|
-
let code = fs.readFileSync(filepath, "utf8");
|
|
105
|
-
if (ext === "markdown" || ext === "md") {
|
|
106
|
-
ext = "markdown";
|
|
107
|
-
code = code.split("`").join("`");
|
|
108
|
-
}
|
|
109
|
-
return `${codeBlock(code, ext).trim()}
|
|
110
|
-
`;
|
|
111
|
-
};
|
|
112
|
-
var gist = (id) => {
|
|
113
|
-
return tag("script", { src: `https://gist.github.com/${id}.js` });
|
|
114
|
-
};
|
|
115
|
-
var jsfiddle = (options) => {
|
|
116
|
-
if (!options || !options.id) {
|
|
117
|
-
throw new Error("jsfiddle helper expects an `id`");
|
|
118
|
-
}
|
|
119
|
-
const {
|
|
120
|
-
id,
|
|
121
|
-
width = "100%",
|
|
122
|
-
height = "300",
|
|
123
|
-
skin = "/presentation/",
|
|
124
|
-
tabs = "result,js,html,css",
|
|
125
|
-
allowfullscreen = "allowfullscreen",
|
|
126
|
-
frameborder = "0"
|
|
127
|
-
} = options;
|
|
128
|
-
const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
|
|
129
|
-
return tag("iframe", { width, height, src, allowfullscreen, frameborder });
|
|
130
|
-
};
|
|
131
|
-
var helpers2 = [
|
|
132
|
-
{
|
|
133
|
-
name: "embed",
|
|
134
|
-
category: "code",
|
|
135
|
-
compatibility: ["nodejs"],
|
|
136
|
-
fn: embed
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "gist",
|
|
140
|
-
category: "code",
|
|
141
|
-
compatibility: ["browser", "nodejs"],
|
|
142
|
-
fn: gist
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "jsfiddle",
|
|
146
|
-
category: "code",
|
|
147
|
-
compatibility: ["browser", "nodejs"],
|
|
148
|
-
fn: jsfiddle
|
|
149
|
-
}
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
// src/helpers/collection.ts
|
|
153
|
-
var isEmpty = (collection) => {
|
|
154
|
-
if (collection == null) return true;
|
|
155
|
-
if (Array.isArray(collection)) return collection.length === 0;
|
|
156
|
-
if (typeof collection === "object")
|
|
157
|
-
return Object.keys(collection).length === 0;
|
|
158
|
-
return false;
|
|
159
|
-
};
|
|
160
|
-
var iterate = (collection, fn, inverse) => {
|
|
161
|
-
if (Array.isArray(collection)) {
|
|
162
|
-
let result = "";
|
|
163
|
-
for (let i = 0; i < collection.length; i++) {
|
|
164
|
-
result += fn(collection[i], i);
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
if (collection && typeof collection === "object") {
|
|
169
|
-
let result = "";
|
|
170
|
-
for (const key of Object.keys(collection)) {
|
|
171
|
-
result += fn(collection[key], key);
|
|
172
|
-
}
|
|
173
|
-
return result;
|
|
174
|
-
}
|
|
175
|
-
return inverse ? inverse() : "";
|
|
176
|
-
};
|
|
177
|
-
var helpers3 = [
|
|
178
|
-
{
|
|
179
|
-
name: "isEmpty",
|
|
180
|
-
category: "collection",
|
|
181
|
-
compatibility: ["browser", "nodejs"],
|
|
182
|
-
fn: isEmpty
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: "iterate",
|
|
186
|
-
category: "collection",
|
|
187
|
-
compatibility: ["browser", "nodejs"],
|
|
188
|
-
fn: iterate
|
|
189
|
-
}
|
|
190
|
-
];
|
|
191
|
-
|
|
192
|
-
// src/helpers/comparison.ts
|
|
193
|
-
var and = (...values) => values.every(Boolean);
|
|
194
|
-
var compare = (a, operator, b) => {
|
|
195
|
-
switch (operator) {
|
|
196
|
-
case "==":
|
|
197
|
-
return a == b;
|
|
198
|
-
// eslint-disable-line eqeqeq
|
|
199
|
-
case "===":
|
|
200
|
-
return a === b;
|
|
201
|
-
case "!=":
|
|
202
|
-
return a != b;
|
|
203
|
-
// eslint-disable-line eqeqeq
|
|
204
|
-
case "!==":
|
|
205
|
-
return a !== b;
|
|
206
|
-
case "<":
|
|
207
|
-
return a < b;
|
|
208
|
-
case ">":
|
|
209
|
-
return a > b;
|
|
210
|
-
case "<=":
|
|
211
|
-
return a <= b;
|
|
212
|
-
case ">=":
|
|
213
|
-
return a >= b;
|
|
214
|
-
case "typeof":
|
|
215
|
-
return typeof a === b;
|
|
216
|
-
default:
|
|
217
|
-
throw new Error(`helper {{compare}}: invalid operator: '${operator}'`);
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
var contains = (collection, value, startIndex = 0) => {
|
|
221
|
-
if (collection == null) return false;
|
|
222
|
-
if (typeof collection === "string" || Array.isArray(collection)) {
|
|
223
|
-
return collection.indexOf(value, startIndex) > -1;
|
|
224
|
-
}
|
|
225
|
-
if (typeof collection === "object") {
|
|
226
|
-
return value in collection;
|
|
227
|
-
}
|
|
228
|
-
return false;
|
|
229
|
-
};
|
|
230
|
-
var defaultHelper = (...values) => {
|
|
231
|
-
for (const val of values) {
|
|
232
|
-
if (val != null) return val;
|
|
233
|
-
}
|
|
234
|
-
return "";
|
|
235
|
-
};
|
|
236
|
-
var eq = (a, b) => a === b;
|
|
237
|
-
var gt = (a, b) => a > b;
|
|
238
|
-
var gte = (a, b) => a >= b;
|
|
239
|
-
var has = (value, pattern) => {
|
|
240
|
-
if (value == null || pattern == null) return false;
|
|
241
|
-
if (Array.isArray(value) || typeof value === "string") {
|
|
242
|
-
return value.indexOf(pattern) > -1;
|
|
243
|
-
}
|
|
244
|
-
if (typeof value === "object") {
|
|
245
|
-
return pattern in value;
|
|
246
|
-
}
|
|
247
|
-
return false;
|
|
248
|
-
};
|
|
249
|
-
var falsey = (val, keywords) => {
|
|
250
|
-
if (!val) return true;
|
|
251
|
-
const words = Array.isArray(keywords) ? keywords : keywords != null ? [keywords] : [
|
|
252
|
-
"0",
|
|
253
|
-
"false",
|
|
254
|
-
"nada",
|
|
255
|
-
"nil",
|
|
256
|
-
"nay",
|
|
257
|
-
"nah",
|
|
258
|
-
"negative",
|
|
259
|
-
"no",
|
|
260
|
-
"none",
|
|
261
|
-
"nope",
|
|
262
|
-
"nul",
|
|
263
|
-
"null",
|
|
264
|
-
"nix",
|
|
265
|
-
"nyet",
|
|
266
|
-
"uh-uh",
|
|
267
|
-
"veto",
|
|
268
|
-
"zero"
|
|
269
|
-
];
|
|
270
|
-
const lower = typeof val === "string" ? val.toLowerCase() : null;
|
|
271
|
-
for (const word of words) {
|
|
272
|
-
if (word === val) return true;
|
|
273
|
-
if (lower != null && word === lower) return true;
|
|
274
|
-
}
|
|
275
|
-
return false;
|
|
276
|
-
};
|
|
277
|
-
var isFalsey = (val) => falsey(val);
|
|
278
|
-
var isTruthy = (val) => !falsey(val);
|
|
279
|
-
var ifEven = (num) => typeof num === "number" && num % 2 === 0;
|
|
280
|
-
var ifNth = (a, b) => typeof a === "number" && typeof b === "number" && b % a === 0;
|
|
281
|
-
var ifOdd = (val) => typeof val === "number" && Math.abs(val % 2) === 1;
|
|
282
|
-
var is = (a, b) => a == b;
|
|
283
|
-
var isnt = (a, b) => a != b;
|
|
284
|
-
var lt = (a, b) => a < b;
|
|
285
|
-
var lte = (a, b) => a <= b;
|
|
286
|
-
var neither = (a, b) => !a && !b;
|
|
287
|
-
var not = (val) => !val;
|
|
288
|
-
var or = (...values) => values.some(Boolean);
|
|
289
|
-
var unlessEq = (a, b) => a !== b;
|
|
290
|
-
var unlessGt = (a, b) => a <= b;
|
|
291
|
-
var unlessLt = (a, b) => a >= b;
|
|
292
|
-
var unlessGteq = (a, b) => a < b;
|
|
293
|
-
var unlessLteq = (a, b) => a > b;
|
|
294
|
-
var helpers4 = [
|
|
295
|
-
{
|
|
296
|
-
name: "and",
|
|
297
|
-
category: "comparison",
|
|
298
|
-
compatibility: ["browser", "nodejs"],
|
|
299
|
-
fn: and
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: "compare",
|
|
303
|
-
category: "comparison",
|
|
304
|
-
compatibility: ["browser", "nodejs"],
|
|
305
|
-
fn: compare
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
name: "contains",
|
|
309
|
-
category: "comparison",
|
|
310
|
-
compatibility: ["browser", "nodejs"],
|
|
311
|
-
fn: contains
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
name: "default",
|
|
315
|
-
category: "comparison",
|
|
316
|
-
compatibility: ["browser", "nodejs"],
|
|
317
|
-
fn: defaultHelper
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
name: "eq",
|
|
321
|
-
category: "comparison",
|
|
322
|
-
compatibility: ["browser", "nodejs"],
|
|
323
|
-
fn: eq
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
name: "gt",
|
|
327
|
-
category: "comparison",
|
|
328
|
-
compatibility: ["browser", "nodejs"],
|
|
329
|
-
fn: gt
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
name: "gte",
|
|
333
|
-
category: "comparison",
|
|
334
|
-
compatibility: ["browser", "nodejs"],
|
|
335
|
-
fn: gte
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
name: "has",
|
|
339
|
-
category: "comparison",
|
|
340
|
-
compatibility: ["browser", "nodejs"],
|
|
341
|
-
fn: has
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
name: "isFalsey",
|
|
345
|
-
category: "comparison",
|
|
346
|
-
compatibility: ["browser", "nodejs"],
|
|
347
|
-
fn: isFalsey
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
name: "isTruthy",
|
|
351
|
-
category: "comparison",
|
|
352
|
-
compatibility: ["browser", "nodejs"],
|
|
353
|
-
fn: isTruthy
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
name: "ifEven",
|
|
357
|
-
category: "comparison",
|
|
358
|
-
compatibility: ["browser", "nodejs"],
|
|
359
|
-
fn: ifEven
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
name: "ifNth",
|
|
363
|
-
category: "comparison",
|
|
364
|
-
compatibility: ["browser", "nodejs"],
|
|
365
|
-
fn: ifNth
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
name: "ifOdd",
|
|
369
|
-
category: "comparison",
|
|
370
|
-
compatibility: ["browser", "nodejs"],
|
|
371
|
-
fn: ifOdd
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
name: "is",
|
|
375
|
-
category: "comparison",
|
|
376
|
-
compatibility: ["browser", "nodejs"],
|
|
377
|
-
fn: is
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: "isnt",
|
|
381
|
-
category: "comparison",
|
|
382
|
-
compatibility: ["browser", "nodejs"],
|
|
383
|
-
fn: isnt
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
name: "lt",
|
|
387
|
-
category: "comparison",
|
|
388
|
-
compatibility: ["browser", "nodejs"],
|
|
389
|
-
fn: lt
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
name: "lte",
|
|
393
|
-
category: "comparison",
|
|
394
|
-
compatibility: ["browser", "nodejs"],
|
|
395
|
-
fn: lte
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
name: "neither",
|
|
399
|
-
category: "comparison",
|
|
400
|
-
compatibility: ["browser", "nodejs"],
|
|
401
|
-
fn: neither
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
name: "not",
|
|
405
|
-
category: "comparison",
|
|
406
|
-
compatibility: ["browser", "nodejs"],
|
|
407
|
-
fn: not
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
name: "or",
|
|
411
|
-
category: "comparison",
|
|
412
|
-
compatibility: ["browser", "nodejs"],
|
|
413
|
-
fn: or
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
name: "unlessEq",
|
|
417
|
-
category: "comparison",
|
|
418
|
-
compatibility: ["browser", "nodejs"],
|
|
419
|
-
fn: unlessEq
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: "unlessGt",
|
|
423
|
-
category: "comparison",
|
|
424
|
-
compatibility: ["browser", "nodejs"],
|
|
425
|
-
fn: unlessGt
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
name: "unlessLt",
|
|
429
|
-
category: "comparison",
|
|
430
|
-
compatibility: ["browser", "nodejs"],
|
|
431
|
-
fn: unlessLt
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
name: "unlessGteq",
|
|
435
|
-
category: "comparison",
|
|
436
|
-
compatibility: ["browser", "nodejs"],
|
|
437
|
-
fn: unlessGteq
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
name: "unlessLteq",
|
|
441
|
-
category: "comparison",
|
|
442
|
-
compatibility: ["browser", "nodejs"],
|
|
443
|
-
fn: unlessLteq
|
|
444
|
-
}
|
|
445
|
-
];
|
|
446
|
-
|
|
447
|
-
// src/helpers/date.ts
|
|
448
|
-
import { parseDate } from "chrono-node";
|
|
449
|
-
import dayjs from "dayjs";
|
|
450
|
-
var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
451
|
-
var date = (humanReadableDate, formatString) => {
|
|
452
|
-
const parsedDate = parseDate(humanReadableDate);
|
|
453
|
-
if (!parsedDate) {
|
|
454
|
-
throw new Error(`Unable to parse date: ${humanReadableDate}`);
|
|
455
|
-
}
|
|
456
|
-
return dayjs(parsedDate).format(formatString);
|
|
457
|
-
};
|
|
458
|
-
var helpers5 = [
|
|
459
|
-
{
|
|
460
|
-
name: "year",
|
|
461
|
-
category: "date",
|
|
462
|
-
compatibility: ["browser", "nodejs"],
|
|
463
|
-
fn: year
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
name: "date",
|
|
467
|
-
category: "date",
|
|
468
|
-
compatibility: ["browser", "nodejs"],
|
|
469
|
-
fn: date
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
/* Adding this in for legacy support */
|
|
473
|
-
name: "moment",
|
|
474
|
-
category: "date",
|
|
475
|
-
compatibility: ["browser", "nodejs"],
|
|
476
|
-
fn: date
|
|
477
|
-
}
|
|
478
|
-
];
|
|
479
|
-
|
|
480
|
-
// src/helpers/fs.ts
|
|
481
|
-
import fs2 from "fs";
|
|
482
|
-
import path2 from "path";
|
|
483
|
-
import isGlob from "is-glob";
|
|
484
|
-
import micromatch from "micromatch";
|
|
485
|
-
var fileSize = (value, precision) => {
|
|
486
|
-
if (value == null) return "0 B";
|
|
487
|
-
const number = typeof value === "number" ? value : value.length ?? 0;
|
|
488
|
-
if (!number) return "0 B";
|
|
489
|
-
const precisionNumber = typeof precision === "number" ? precision : 2;
|
|
490
|
-
const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
491
|
-
const factor = 10 ** precisionNumber;
|
|
492
|
-
let i = abbr.length - 1;
|
|
493
|
-
do {
|
|
494
|
-
const size = 10 ** (i * 3);
|
|
495
|
-
if (size <= number + 1) {
|
|
496
|
-
const num = Math.round(number * factor / size) / factor;
|
|
497
|
-
return `${num} ${abbr[i]}`;
|
|
498
|
-
}
|
|
499
|
-
} while (--i >= 0);
|
|
500
|
-
return `${number} B`;
|
|
501
|
-
};
|
|
502
|
-
var read = (filepath) => {
|
|
503
|
-
return fs2.readFileSync(filepath, "utf8");
|
|
504
|
-
};
|
|
505
|
-
var isOptions = (value) => {
|
|
506
|
-
return Boolean(
|
|
507
|
-
value && typeof value === "object" && "hash" in value
|
|
508
|
-
);
|
|
509
|
-
};
|
|
510
|
-
var readdir = (dir, filter) => {
|
|
511
|
-
const files = fs2.readdirSync(dir).map((fp) => path2.join(dir, fp));
|
|
512
|
-
const filterArg = isOptions(filter) ? void 0 : filter;
|
|
513
|
-
if (typeof filterArg === "function") {
|
|
514
|
-
return filterArg(files);
|
|
515
|
-
}
|
|
516
|
-
if (filterArg instanceof RegExp) {
|
|
517
|
-
return files.filter((fp) => filterArg.test(fp));
|
|
518
|
-
}
|
|
519
|
-
if (typeof filterArg === "string") {
|
|
520
|
-
if (isGlob(filterArg)) {
|
|
521
|
-
return micromatch(files, filterArg);
|
|
522
|
-
}
|
|
523
|
-
if (filterArg === "isFile" || filterArg === "isDirectory") {
|
|
524
|
-
return files.filter((fp) => {
|
|
525
|
-
const stat = fs2.statSync(fp);
|
|
526
|
-
return filterArg === "isFile" ? stat.isFile() : stat.isDirectory();
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
return files;
|
|
531
|
-
};
|
|
532
|
-
var helpers6 = [
|
|
533
|
-
{
|
|
534
|
-
name: "fileSize",
|
|
535
|
-
category: "fs",
|
|
536
|
-
compatibility: ["nodejs"],
|
|
537
|
-
fn: fileSize
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
name: "read",
|
|
541
|
-
category: "fs",
|
|
542
|
-
compatibility: ["nodejs"],
|
|
543
|
-
fn: read
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
name: "readdir",
|
|
547
|
-
category: "fs",
|
|
548
|
-
compatibility: ["nodejs"],
|
|
549
|
-
fn: readdir
|
|
550
|
-
}
|
|
551
|
-
];
|
|
552
|
-
|
|
553
|
-
// src/helpers/html.ts
|
|
554
|
-
import path3 from "path";
|
|
555
|
-
import tag2 from "html-tag";
|
|
556
|
-
import striptags from "striptags";
|
|
557
|
-
var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
|
|
558
|
-
var attr = (options) => {
|
|
559
|
-
const val = parseAttributes(options?.hash ?? {});
|
|
560
|
-
return val.trim() ? ` ${val}` : "";
|
|
561
|
-
};
|
|
562
|
-
var css = function(list, options) {
|
|
563
|
-
if (arguments.length < 2) {
|
|
564
|
-
options = list;
|
|
565
|
-
list = [];
|
|
566
|
-
}
|
|
567
|
-
let styles = arrayify(list ?? []);
|
|
568
|
-
let assets = "";
|
|
569
|
-
if (this && this.options) {
|
|
570
|
-
assets = this.options.assets || "";
|
|
571
|
-
}
|
|
572
|
-
if (options?.hash?.href) {
|
|
573
|
-
styles = arrayify(options.hash.href);
|
|
574
|
-
}
|
|
575
|
-
return styles.map((item) => {
|
|
576
|
-
const ext = path3.extname(item);
|
|
577
|
-
let fp = item;
|
|
578
|
-
if (!/(^\/\/)|(:\/\/)/.test(item)) {
|
|
579
|
-
fp = path3.posix.join(assets, item);
|
|
580
|
-
}
|
|
581
|
-
if (ext === ".less") {
|
|
582
|
-
return `<link type="text/css" rel="stylesheet/less" href="${fp}">`;
|
|
583
|
-
}
|
|
584
|
-
return `<link type="text/css" rel="stylesheet" href="${fp}">`;
|
|
585
|
-
}).join("\n");
|
|
586
|
-
};
|
|
587
|
-
var js = (context) => {
|
|
588
|
-
if (context && typeof context === "object" && !Array.isArray(context)) {
|
|
589
|
-
const attrStr = parseAttributes(context.hash ?? {});
|
|
590
|
-
return `<script${attrStr ? ` ${attrStr}` : ""}></script>`;
|
|
591
|
-
}
|
|
592
|
-
if (typeof context === "string") {
|
|
593
|
-
return `<script src="${context}"></script>`;
|
|
594
|
-
}
|
|
595
|
-
const items = arrayify(context);
|
|
596
|
-
return items.map(
|
|
597
|
-
(fp) => path3.extname(fp) === ".coffee" ? tag2("script", { type: "text/coffeescript", src: fp }) : tag2("script", { src: fp })
|
|
598
|
-
).join("\n");
|
|
599
|
-
};
|
|
600
|
-
var sanitize = (str) => {
|
|
601
|
-
if (typeof str !== "string") return "";
|
|
602
|
-
return striptags(str).trim();
|
|
603
|
-
};
|
|
604
|
-
var ul = (context, options) => {
|
|
605
|
-
const attrs = parseAttributes(options.hash ?? {});
|
|
606
|
-
const items = context.map(
|
|
607
|
-
(item) => typeof item === "string" ? item : options.fn(item)
|
|
608
|
-
);
|
|
609
|
-
const open = attrs ? `<ul ${attrs}>` : "<ul>";
|
|
610
|
-
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
|
|
611
|
-
};
|
|
612
|
-
var ol = (context, options) => {
|
|
613
|
-
const attrs = parseAttributes(options.hash ?? {});
|
|
614
|
-
const items = context.map(
|
|
615
|
-
(item) => typeof item === "string" ? item : options.fn(item)
|
|
616
|
-
);
|
|
617
|
-
const open = attrs ? `<ol ${attrs}>` : "<ol>";
|
|
618
|
-
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
|
|
619
|
-
};
|
|
620
|
-
var thumbnailImage = (context) => {
|
|
621
|
-
let figure = "";
|
|
622
|
-
let image = "";
|
|
623
|
-
const link = context.full || false;
|
|
624
|
-
const imageAttributes = {
|
|
625
|
-
alt: context.alt,
|
|
626
|
-
src: context.thumbnail,
|
|
627
|
-
width: context.size.width,
|
|
628
|
-
height: context.size.height
|
|
629
|
-
};
|
|
630
|
-
const figureAttributes = { id: `image-${context.id}` };
|
|
631
|
-
const linkAttributes = { href: link, rel: "thumbnail" };
|
|
632
|
-
if (context.classes) {
|
|
633
|
-
if (context.classes.image) {
|
|
634
|
-
imageAttributes.class = context.classes.image.join(" ");
|
|
635
|
-
}
|
|
636
|
-
if (context.classes.figure) {
|
|
637
|
-
figureAttributes.class = context.classes.figure.join(" ");
|
|
638
|
-
}
|
|
639
|
-
if (context.classes.link) {
|
|
640
|
-
linkAttributes.class = context.classes.link.join(" ");
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
figure += `<figure ${parseAttributes(figureAttributes)}>
|
|
644
|
-
`;
|
|
645
|
-
image += `<img ${parseAttributes(imageAttributes)}>
|
|
646
|
-
`;
|
|
647
|
-
if (link) {
|
|
648
|
-
figure += `<a ${parseAttributes(linkAttributes)}>
|
|
649
|
-
${image}</a>
|
|
650
|
-
`;
|
|
651
|
-
} else {
|
|
652
|
-
figure += image;
|
|
653
|
-
}
|
|
654
|
-
if (context.caption) {
|
|
655
|
-
figure += `<figcaption>${context.caption}</figcaption>
|
|
656
|
-
`;
|
|
657
|
-
}
|
|
658
|
-
figure += "</figure>";
|
|
659
|
-
return figure;
|
|
660
|
-
};
|
|
661
|
-
var helpers7 = [
|
|
662
|
-
{
|
|
663
|
-
name: "attr",
|
|
664
|
-
category: "html",
|
|
665
|
-
compatibility: ["browser", "nodejs"],
|
|
666
|
-
fn: attr
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
name: "css",
|
|
670
|
-
category: "html",
|
|
671
|
-
compatibility: ["nodejs"],
|
|
672
|
-
fn: css
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
name: "js",
|
|
676
|
-
category: "html",
|
|
677
|
-
compatibility: ["nodejs"],
|
|
678
|
-
fn: js
|
|
679
|
-
},
|
|
680
|
-
{
|
|
681
|
-
name: "sanitize",
|
|
682
|
-
category: "html",
|
|
683
|
-
compatibility: ["browser", "nodejs"],
|
|
684
|
-
fn: sanitize
|
|
685
|
-
},
|
|
686
|
-
{
|
|
687
|
-
name: "ul",
|
|
688
|
-
category: "html",
|
|
689
|
-
compatibility: ["browser", "nodejs"],
|
|
690
|
-
fn: ul
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
name: "ol",
|
|
694
|
-
category: "html",
|
|
695
|
-
compatibility: ["browser", "nodejs"],
|
|
696
|
-
fn: ol
|
|
697
|
-
},
|
|
698
|
-
{
|
|
699
|
-
name: "thumbnailImage",
|
|
700
|
-
category: "html",
|
|
701
|
-
compatibility: ["browser", "nodejs"],
|
|
702
|
-
fn: thumbnailImage
|
|
703
|
-
}
|
|
704
|
-
];
|
|
705
|
-
|
|
706
|
-
// src/helpers/i18n.ts
|
|
707
|
-
import get from "get-value";
|
|
708
|
-
var i18n = function(prop, locals, options) {
|
|
709
|
-
if (locals && typeof locals === "object" && "hash" in locals && options === void 0) {
|
|
710
|
-
options = locals;
|
|
711
|
-
locals = {};
|
|
712
|
-
}
|
|
713
|
-
if (typeof prop !== "string") {
|
|
714
|
-
throw new Error('{{i18n}} helper expected "key" to be a string');
|
|
715
|
-
}
|
|
716
|
-
const context = {
|
|
717
|
-
...this,
|
|
718
|
-
...locals,
|
|
719
|
-
...options?.hash ?? {}
|
|
720
|
-
};
|
|
721
|
-
const lang = context.language || context.lang;
|
|
722
|
-
if (typeof lang !== "string") {
|
|
723
|
-
throw new TypeError('{{i18n}} helper expected "language" to be a string');
|
|
724
|
-
}
|
|
725
|
-
const cache = context[lang];
|
|
726
|
-
if (typeof cache === "undefined") {
|
|
727
|
-
throw new Error(`{{i18n}} helper cannot find language "${lang}"`);
|
|
728
|
-
}
|
|
729
|
-
const result = get(cache, prop);
|
|
730
|
-
if (typeof result === "undefined") {
|
|
731
|
-
throw new Error(
|
|
732
|
-
'{{i18n}} helper cannot find property "' + String(prop) + '" for language "' + lang + '"'
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
return String(result);
|
|
736
|
-
};
|
|
737
|
-
var helpers8 = [
|
|
738
|
-
{
|
|
739
|
-
name: "i18n",
|
|
740
|
-
category: "i18n",
|
|
741
|
-
compatibility: ["browser", "nodejs"],
|
|
742
|
-
fn: i18n
|
|
743
|
-
}
|
|
744
|
-
];
|
|
745
|
-
|
|
746
|
-
// src/helpers/inflection.ts
|
|
747
|
-
var inflect = (count, singular, plural, includeCount) => {
|
|
748
|
-
const word = count > 1 || count === 0 ? plural : singular;
|
|
749
|
-
return includeCount ? `${count} ${word}` : word;
|
|
750
|
-
};
|
|
751
|
-
var ordinalize = (value) => {
|
|
752
|
-
const num = Math.abs(Math.round(Number(value)));
|
|
753
|
-
const str = String(value);
|
|
754
|
-
const res = num % 100;
|
|
755
|
-
if ([11, 12, 13].includes(res)) {
|
|
756
|
-
return `${str}th`;
|
|
757
|
-
}
|
|
758
|
-
switch (num % 10) {
|
|
759
|
-
case 1:
|
|
760
|
-
return `${str}st`;
|
|
761
|
-
case 2:
|
|
762
|
-
return `${str}nd`;
|
|
763
|
-
case 3:
|
|
764
|
-
return `${str}rd`;
|
|
765
|
-
default:
|
|
766
|
-
return `${str}th`;
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
var helpers9 = [
|
|
770
|
-
{
|
|
771
|
-
name: "inflect",
|
|
772
|
-
category: "inflection",
|
|
773
|
-
compatibility: ["browser", "nodejs"],
|
|
774
|
-
fn: inflect
|
|
775
|
-
},
|
|
776
|
-
{
|
|
777
|
-
name: "ordinalize",
|
|
778
|
-
category: "inflection",
|
|
779
|
-
compatibility: ["browser", "nodejs"],
|
|
780
|
-
fn: ordinalize
|
|
781
|
-
}
|
|
782
|
-
];
|
|
783
|
-
|
|
784
|
-
// src/helpers/logging.ts
|
|
785
|
-
import loggingHelpers from "logging-helpers";
|
|
786
|
-
var {
|
|
787
|
-
log,
|
|
788
|
-
ok,
|
|
789
|
-
success,
|
|
790
|
-
info,
|
|
791
|
-
warning,
|
|
792
|
-
warn,
|
|
793
|
-
error,
|
|
794
|
-
danger,
|
|
795
|
-
bold,
|
|
796
|
-
_debug,
|
|
797
|
-
_inspect
|
|
798
|
-
} = loggingHelpers;
|
|
799
|
-
var helpers10 = [
|
|
800
|
-
{
|
|
801
|
-
name: "log",
|
|
802
|
-
category: "logging",
|
|
803
|
-
compatibility: ["nodejs"],
|
|
804
|
-
fn: log
|
|
805
|
-
},
|
|
806
|
-
{
|
|
807
|
-
name: "ok",
|
|
808
|
-
category: "logging",
|
|
809
|
-
compatibility: ["nodejs"],
|
|
810
|
-
fn: ok
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
name: "success",
|
|
814
|
-
category: "logging",
|
|
815
|
-
compatibility: ["nodejs"],
|
|
816
|
-
fn: success
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
name: "info",
|
|
820
|
-
category: "logging",
|
|
821
|
-
compatibility: ["nodejs"],
|
|
822
|
-
fn: info
|
|
823
|
-
},
|
|
824
|
-
{
|
|
825
|
-
name: "warning",
|
|
826
|
-
category: "logging",
|
|
827
|
-
compatibility: ["nodejs"],
|
|
828
|
-
fn: warning
|
|
829
|
-
},
|
|
830
|
-
{
|
|
831
|
-
name: "warn",
|
|
832
|
-
category: "logging",
|
|
833
|
-
compatibility: ["nodejs"],
|
|
834
|
-
fn: warn
|
|
835
|
-
},
|
|
836
|
-
{
|
|
837
|
-
name: "error",
|
|
838
|
-
category: "logging",
|
|
839
|
-
compatibility: ["nodejs"],
|
|
840
|
-
fn: error
|
|
841
|
-
},
|
|
842
|
-
{
|
|
843
|
-
name: "danger",
|
|
844
|
-
category: "logging",
|
|
845
|
-
compatibility: ["nodejs"],
|
|
846
|
-
fn: danger
|
|
847
|
-
},
|
|
848
|
-
{
|
|
849
|
-
name: "bold",
|
|
850
|
-
category: "logging",
|
|
851
|
-
compatibility: ["nodejs"],
|
|
852
|
-
fn: bold
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
name: "_debug",
|
|
856
|
-
category: "logging",
|
|
857
|
-
compatibility: ["nodejs"],
|
|
858
|
-
fn: _debug
|
|
859
|
-
},
|
|
860
|
-
{
|
|
861
|
-
name: "_inspect",
|
|
862
|
-
category: "logging",
|
|
863
|
-
compatibility: ["nodejs"],
|
|
864
|
-
fn: _inspect
|
|
865
|
-
}
|
|
866
|
-
];
|
|
867
|
-
|
|
868
|
-
// src/helpers/match.ts
|
|
869
|
-
import micromatch2 from "micromatch";
|
|
870
|
-
var match = (files, patterns, options) => {
|
|
871
|
-
const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
|
|
872
|
-
return micromatch2(files, pats, options);
|
|
873
|
-
};
|
|
874
|
-
var isMatch = (filepath, pattern, options) => {
|
|
875
|
-
return micromatch2.isMatch(filepath, pattern, options);
|
|
876
|
-
};
|
|
877
|
-
var mm = (...args) => {
|
|
878
|
-
console.log("the {{mm}} helper is depcrecated and will be removed");
|
|
879
|
-
console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
|
|
880
|
-
console.log("helper instead.");
|
|
881
|
-
return match(...args);
|
|
882
|
-
};
|
|
883
|
-
var helpers11 = [
|
|
884
|
-
{
|
|
885
|
-
name: "match",
|
|
886
|
-
category: "match",
|
|
887
|
-
compatibility: ["browser", "nodejs"],
|
|
888
|
-
fn: match
|
|
889
|
-
},
|
|
890
|
-
{
|
|
891
|
-
name: "isMatch",
|
|
892
|
-
category: "match",
|
|
893
|
-
compatibility: ["browser", "nodejs"],
|
|
894
|
-
fn: isMatch
|
|
895
|
-
},
|
|
896
|
-
{
|
|
897
|
-
name: "mm",
|
|
898
|
-
category: "match",
|
|
899
|
-
compatibility: ["browser", "nodejs"],
|
|
900
|
-
fn: mm
|
|
901
|
-
}
|
|
902
|
-
];
|
|
903
|
-
|
|
904
|
-
// src/helpers/math.ts
|
|
905
|
-
var isNumeric = (value) => typeof value === "number" && !Number.isNaN(value) || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
|
|
906
|
-
var toNumber = (value, message = "expected a number") => {
|
|
907
|
-
if (isNumeric(value)) {
|
|
908
|
-
return Number(value);
|
|
909
|
-
}
|
|
910
|
-
throw new TypeError(message);
|
|
911
|
-
};
|
|
912
|
-
var abs = (value) => {
|
|
913
|
-
const num = toNumber(value);
|
|
914
|
-
return Math.abs(num);
|
|
915
|
-
};
|
|
916
|
-
var add = (a, b) => {
|
|
917
|
-
if (isNumeric(a) && isNumeric(b)) {
|
|
918
|
-
return Number(a) + Number(b);
|
|
919
|
-
}
|
|
920
|
-
return "";
|
|
921
|
-
};
|
|
922
|
-
var avg = (...values) => {
|
|
923
|
-
const flat = values.flat().map((n) => Number(n));
|
|
924
|
-
return sum(flat) / flat.length;
|
|
925
|
-
};
|
|
926
|
-
var ceil = (value) => {
|
|
927
|
-
const num = toNumber(value);
|
|
928
|
-
return Math.ceil(num);
|
|
929
|
-
};
|
|
930
|
-
var divide = (a, b) => {
|
|
931
|
-
const numA = toNumber(a, "expected the first argument to be a number");
|
|
932
|
-
const numB = toNumber(b, "expected the second argument to be a number");
|
|
933
|
-
return numA / numB;
|
|
934
|
-
};
|
|
935
|
-
var floor = (value) => {
|
|
936
|
-
const num = toNumber(value);
|
|
937
|
-
return Math.floor(num);
|
|
938
|
-
};
|
|
939
|
-
var minus = (a, b) => {
|
|
940
|
-
const numA = toNumber(a, "expected the first argument to be a number");
|
|
941
|
-
const numB = toNumber(b, "expected the second argument to be a number");
|
|
942
|
-
return numA - numB;
|
|
943
|
-
};
|
|
944
|
-
var modulo = (a, b) => {
|
|
945
|
-
const numA = toNumber(a, "expected the first argument to be a number");
|
|
946
|
-
const numB = toNumber(b, "expected the second argument to be a number");
|
|
947
|
-
return numA % numB;
|
|
948
|
-
};
|
|
949
|
-
var multiply = (a, b) => {
|
|
950
|
-
const numA = toNumber(a, "expected the first argument to be a number");
|
|
951
|
-
const numB = toNumber(b, "expected the second argument to be a number");
|
|
952
|
-
return numA * numB;
|
|
953
|
-
};
|
|
954
|
-
var plus = (a, b) => {
|
|
955
|
-
const numA = toNumber(a, "expected the first argument to be a number");
|
|
956
|
-
const numB = toNumber(b, "expected the second argument to be a number");
|
|
957
|
-
return numA + numB;
|
|
958
|
-
};
|
|
959
|
-
var random = (min, max) => {
|
|
960
|
-
const minNum = toNumber(min, "expected minimum to be a number");
|
|
961
|
-
const maxNum = toNumber(max, "expected maximum to be a number");
|
|
962
|
-
return minNum + Math.floor(Math.random() * (maxNum - minNum + 1));
|
|
963
|
-
};
|
|
964
|
-
var remainder = (a, b) => a % b;
|
|
965
|
-
var round = (value) => {
|
|
966
|
-
const num = toNumber(value);
|
|
967
|
-
return Math.round(num);
|
|
968
|
-
};
|
|
969
|
-
var subtract = (a, b) => {
|
|
970
|
-
const numA = toNumber(a, "expected the first argument to be a number");
|
|
971
|
-
const numB = toNumber(b, "expected the second argument to be a number");
|
|
972
|
-
return numA - numB;
|
|
973
|
-
};
|
|
974
|
-
var sum = (...values) => {
|
|
975
|
-
const flat = values.flat();
|
|
976
|
-
let total = 0;
|
|
977
|
-
for (const value of flat) {
|
|
978
|
-
if (isNumeric(value)) {
|
|
979
|
-
total += Number(value);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return total;
|
|
983
|
-
};
|
|
984
|
-
var times = (a, b) => multiply(a, b);
|
|
985
|
-
var helpers12 = [
|
|
986
|
-
{
|
|
987
|
-
name: "abs",
|
|
988
|
-
category: "math",
|
|
989
|
-
compatibility: ["browser", "nodejs"],
|
|
990
|
-
fn: abs
|
|
991
|
-
},
|
|
992
|
-
{
|
|
993
|
-
name: "add",
|
|
994
|
-
category: "math",
|
|
995
|
-
compatibility: ["browser", "nodejs"],
|
|
996
|
-
fn: add
|
|
997
|
-
},
|
|
998
|
-
{
|
|
999
|
-
name: "avg",
|
|
1000
|
-
category: "math",
|
|
1001
|
-
compatibility: ["browser", "nodejs"],
|
|
1002
|
-
fn: avg
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
name: "ceil",
|
|
1006
|
-
category: "math",
|
|
1007
|
-
compatibility: ["browser", "nodejs"],
|
|
1008
|
-
fn: ceil
|
|
1009
|
-
},
|
|
1010
|
-
{
|
|
1011
|
-
name: "divide",
|
|
1012
|
-
category: "math",
|
|
1013
|
-
compatibility: ["browser", "nodejs"],
|
|
1014
|
-
fn: divide
|
|
1015
|
-
},
|
|
1016
|
-
{
|
|
1017
|
-
name: "floor",
|
|
1018
|
-
category: "math",
|
|
1019
|
-
compatibility: ["browser", "nodejs"],
|
|
1020
|
-
fn: floor
|
|
1021
|
-
},
|
|
1022
|
-
{
|
|
1023
|
-
name: "minus",
|
|
1024
|
-
category: "math",
|
|
1025
|
-
compatibility: ["browser", "nodejs"],
|
|
1026
|
-
fn: minus
|
|
1027
|
-
},
|
|
1028
|
-
{
|
|
1029
|
-
name: "modulo",
|
|
1030
|
-
category: "math",
|
|
1031
|
-
compatibility: ["browser", "nodejs"],
|
|
1032
|
-
fn: modulo
|
|
1033
|
-
},
|
|
1034
|
-
{
|
|
1035
|
-
name: "multiply",
|
|
1036
|
-
category: "math",
|
|
1037
|
-
compatibility: ["browser", "nodejs"],
|
|
1038
|
-
fn: multiply
|
|
1039
|
-
},
|
|
1040
|
-
{
|
|
1041
|
-
name: "plus",
|
|
1042
|
-
category: "math",
|
|
1043
|
-
compatibility: ["browser", "nodejs"],
|
|
1044
|
-
fn: plus
|
|
1045
|
-
},
|
|
1046
|
-
{
|
|
1047
|
-
name: "random",
|
|
1048
|
-
category: "math",
|
|
1049
|
-
compatibility: ["browser", "nodejs"],
|
|
1050
|
-
fn: random
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
name: "remainder",
|
|
1054
|
-
category: "math",
|
|
1055
|
-
compatibility: ["browser", "nodejs"],
|
|
1056
|
-
fn: remainder
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
name: "round",
|
|
1060
|
-
category: "math",
|
|
1061
|
-
compatibility: ["browser", "nodejs"],
|
|
1062
|
-
fn: round
|
|
1063
|
-
},
|
|
1064
|
-
{
|
|
1065
|
-
name: "subtract",
|
|
1066
|
-
category: "math",
|
|
1067
|
-
compatibility: ["browser", "nodejs"],
|
|
1068
|
-
fn: subtract
|
|
1069
|
-
},
|
|
1070
|
-
{
|
|
1071
|
-
name: "sum",
|
|
1072
|
-
category: "math",
|
|
1073
|
-
compatibility: ["browser", "nodejs"],
|
|
1074
|
-
fn: sum
|
|
1075
|
-
},
|
|
1076
|
-
{
|
|
1077
|
-
name: "times",
|
|
1078
|
-
category: "math",
|
|
1079
|
-
compatibility: ["browser", "nodejs"],
|
|
1080
|
-
fn: times
|
|
1081
|
-
}
|
|
1082
|
-
];
|
|
1083
|
-
|
|
1084
|
-
// src/helpers/md.ts
|
|
1085
|
-
import fs3 from "fs";
|
|
1086
|
-
import path4 from "path";
|
|
1087
|
-
import process2 from "process";
|
|
1088
|
-
import ent from "ent";
|
|
1089
|
-
import Handlebars from "handlebars";
|
|
1090
|
-
import { Remarkable } from "remarkable";
|
|
1091
|
-
var renderMarkdown = (input, options = {}) => {
|
|
1092
|
-
const options_ = { cwd: process2.cwd(), ...options };
|
|
1093
|
-
const md = new Remarkable({
|
|
1094
|
-
breaks: true,
|
|
1095
|
-
html: true,
|
|
1096
|
-
langPrefix: "lang-",
|
|
1097
|
-
typographer: false,
|
|
1098
|
-
xhtmlOut: false
|
|
1099
|
-
});
|
|
1100
|
-
const filepath = path4.resolve(options_.cwd, input);
|
|
1101
|
-
let string_ = input;
|
|
1102
|
-
if (fs3.existsSync(filepath)) {
|
|
1103
|
-
string_ = fs3.readFileSync(filepath, "utf8");
|
|
1104
|
-
}
|
|
1105
|
-
return new Handlebars.SafeString(ent.decode(md.render(string_)));
|
|
1106
|
-
};
|
|
1107
|
-
var helpers13 = [
|
|
1108
|
-
{
|
|
1109
|
-
name: "md",
|
|
1110
|
-
category: "markdown",
|
|
1111
|
-
compatibility: ["nodejs"],
|
|
1112
|
-
fn: renderMarkdown
|
|
1113
|
-
}
|
|
1114
|
-
];
|
|
1115
|
-
|
|
1116
|
-
// src/helpers/misc.ts
|
|
1117
|
-
import get2 from "get-value";
|
|
1118
|
-
import createFrame from "handlebars-helper-create-frame";
|
|
1119
|
-
import util from "handlebars-utils";
|
|
1120
|
-
import kindOf from "kind-of";
|
|
1121
|
-
var frame = createFrame;
|
|
1122
|
-
function option(prop, locals, options) {
|
|
1123
|
-
return get2(util.options(this, locals, options), prop);
|
|
1124
|
-
}
|
|
1125
|
-
function noop(options) {
|
|
1126
|
-
return options.fn(this);
|
|
1127
|
-
}
|
|
1128
|
-
var typeOf = kindOf;
|
|
1129
|
-
function withHash(options) {
|
|
1130
|
-
if (options.hash && Object.keys(options.hash).length) {
|
|
1131
|
-
return options.fn(options.hash);
|
|
1132
|
-
}
|
|
1133
|
-
return options.inverse(this);
|
|
1134
|
-
}
|
|
1135
|
-
var helpers14 = [
|
|
1136
|
-
{
|
|
1137
|
-
name: "frame",
|
|
1138
|
-
category: "misc",
|
|
1139
|
-
compatibility: ["browser", "nodejs"],
|
|
1140
|
-
fn: frame
|
|
1141
|
-
},
|
|
1142
|
-
{
|
|
1143
|
-
name: "option",
|
|
1144
|
-
category: "misc",
|
|
1145
|
-
compatibility: ["browser", "nodejs"],
|
|
1146
|
-
fn: option
|
|
1147
|
-
},
|
|
1148
|
-
{
|
|
1149
|
-
name: "noop",
|
|
1150
|
-
category: "misc",
|
|
1151
|
-
compatibility: ["browser", "nodejs"],
|
|
1152
|
-
fn: noop
|
|
1153
|
-
},
|
|
1154
|
-
{
|
|
1155
|
-
name: "typeOf",
|
|
1156
|
-
category: "misc",
|
|
1157
|
-
compatibility: ["browser", "nodejs"],
|
|
1158
|
-
fn: typeOf
|
|
1159
|
-
},
|
|
1160
|
-
{
|
|
1161
|
-
name: "withHash",
|
|
1162
|
-
category: "misc",
|
|
1163
|
-
compatibility: ["browser", "nodejs"],
|
|
1164
|
-
fn: withHash
|
|
1165
|
-
}
|
|
1166
|
-
];
|
|
1167
|
-
|
|
1168
|
-
// src/helpers/number.ts
|
|
1169
|
-
var isNumeric2 = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
1170
|
-
var bytes = (value, precision) => {
|
|
1171
|
-
if (value == null) return "0 B";
|
|
1172
|
-
let num;
|
|
1173
|
-
if (typeof value === "string") {
|
|
1174
|
-
num = value.length;
|
|
1175
|
-
if (!num) return "0 B";
|
|
1176
|
-
} else if (isNumeric2(value)) {
|
|
1177
|
-
num = Number(value);
|
|
1178
|
-
} else if (typeof value.length === "number") {
|
|
1179
|
-
num = value.length;
|
|
1180
|
-
if (!num) return "0 B";
|
|
1181
|
-
} else {
|
|
1182
|
-
return "0 B";
|
|
1183
|
-
}
|
|
1184
|
-
const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
|
|
1185
|
-
const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
1186
|
-
const factor = 10 ** prec;
|
|
1187
|
-
for (let i = abbr.length - 1; i >= 0; i--) {
|
|
1188
|
-
const size = 10 ** (i * 3);
|
|
1189
|
-
if (size <= num + 1) {
|
|
1190
|
-
const val = Math.round(num * factor / size) / factor;
|
|
1191
|
-
return `${val} ${abbr[i]}`;
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
return `${num}`;
|
|
1195
|
-
};
|
|
1196
|
-
var addCommas = (num) => num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
|
1197
|
-
var phoneNumber = (num) => {
|
|
1198
|
-
const str = num.toString();
|
|
1199
|
-
return `(${str.substr(0, 3)}) ${str.substr(3, 3)}-${str.substr(6, 4)}`;
|
|
1200
|
-
};
|
|
1201
|
-
var toAbbr = (value, precision) => {
|
|
1202
|
-
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1203
|
-
const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
|
|
1204
|
-
const factor = 10 ** prec;
|
|
1205
|
-
const abbr = ["k", "m", "b", "t", "q"];
|
|
1206
|
-
for (let i = abbr.length - 1; i >= 0; i--) {
|
|
1207
|
-
const size = 10 ** ((i + 1) * 3);
|
|
1208
|
-
if (size <= num + 1) {
|
|
1209
|
-
const val = Math.round(num * factor / size) / factor;
|
|
1210
|
-
return `${val}${abbr[i]}`;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
return `${num}`;
|
|
1214
|
-
};
|
|
1215
|
-
var toExponential = (value, digits) => {
|
|
1216
|
-
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1217
|
-
const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
|
|
1218
|
-
return Number(num).toExponential(d);
|
|
1219
|
-
};
|
|
1220
|
-
var toFixed = (value, digits) => {
|
|
1221
|
-
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1222
|
-
const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
|
|
1223
|
-
return Number(num).toFixed(d);
|
|
1224
|
-
};
|
|
1225
|
-
var toFloat = (value) => parseFloat(String(value));
|
|
1226
|
-
var toInt = (value) => parseInt(String(value), 10);
|
|
1227
|
-
var toPrecision = (value, precision) => {
|
|
1228
|
-
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1229
|
-
const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 1;
|
|
1230
|
-
return Number(num).toPrecision(prec);
|
|
1231
|
-
};
|
|
1232
|
-
var helpers15 = [
|
|
1233
|
-
{
|
|
1234
|
-
name: "bytes",
|
|
1235
|
-
category: "number",
|
|
1236
|
-
compatibility: ["browser", "nodejs"],
|
|
1237
|
-
fn: bytes
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
name: "addCommas",
|
|
1241
|
-
category: "number",
|
|
1242
|
-
compatibility: ["browser", "nodejs"],
|
|
1243
|
-
fn: addCommas
|
|
1244
|
-
},
|
|
1245
|
-
{
|
|
1246
|
-
name: "phoneNumber",
|
|
1247
|
-
category: "number",
|
|
1248
|
-
compatibility: ["browser", "nodejs"],
|
|
1249
|
-
fn: phoneNumber
|
|
1250
|
-
},
|
|
1251
|
-
{
|
|
1252
|
-
name: "toAbbr",
|
|
1253
|
-
category: "number",
|
|
1254
|
-
compatibility: ["browser", "nodejs"],
|
|
1255
|
-
fn: toAbbr
|
|
1256
|
-
},
|
|
1257
|
-
{
|
|
1258
|
-
name: "toExponential",
|
|
1259
|
-
category: "number",
|
|
1260
|
-
compatibility: ["browser", "nodejs"],
|
|
1261
|
-
fn: toExponential
|
|
1262
|
-
},
|
|
1263
|
-
{
|
|
1264
|
-
name: "toFixed",
|
|
1265
|
-
category: "number",
|
|
1266
|
-
compatibility: ["browser", "nodejs"],
|
|
1267
|
-
fn: toFixed
|
|
1268
|
-
},
|
|
1269
|
-
{
|
|
1270
|
-
name: "toFloat",
|
|
1271
|
-
category: "number",
|
|
1272
|
-
compatibility: ["browser", "nodejs"],
|
|
1273
|
-
fn: toFloat
|
|
1274
|
-
},
|
|
1275
|
-
{
|
|
1276
|
-
name: "toInt",
|
|
1277
|
-
category: "number",
|
|
1278
|
-
compatibility: ["browser", "nodejs"],
|
|
1279
|
-
fn: toInt
|
|
1280
|
-
},
|
|
1281
|
-
{
|
|
1282
|
-
name: "toPrecision",
|
|
1283
|
-
category: "number",
|
|
1284
|
-
compatibility: ["browser", "nodejs"],
|
|
1285
|
-
fn: toPrecision
|
|
1286
|
-
}
|
|
1287
|
-
];
|
|
1288
|
-
|
|
1289
|
-
// src/helpers/object.ts
|
|
1290
|
-
import getObject from "get-object";
|
|
1291
|
-
import get3 from "get-value";
|
|
1292
|
-
var isOptions2 = (value) => {
|
|
1293
|
-
return Boolean(value && typeof value === "object" && "hash" in value);
|
|
1294
|
-
};
|
|
1295
|
-
var createFrame2 = (options, hash) => ({
|
|
1296
|
-
...options?.data || {},
|
|
1297
|
-
...hash
|
|
1298
|
-
});
|
|
1299
|
-
var extend = (...objects) => {
|
|
1300
|
-
const args = [...objects];
|
|
1301
|
-
if (args.length && isOptions2(args[args.length - 1])) {
|
|
1302
|
-
const opts = args.pop();
|
|
1303
|
-
args.push(opts.hash);
|
|
1304
|
-
}
|
|
1305
|
-
const result = {};
|
|
1306
|
-
for (const obj of args) {
|
|
1307
|
-
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
1308
|
-
Object.assign(result, obj);
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
return result;
|
|
1312
|
-
};
|
|
1313
|
-
var forIn = (obj, options) => {
|
|
1314
|
-
if (!isOptions2(options)) {
|
|
1315
|
-
return options?.inverse?.(obj) ?? "";
|
|
1316
|
-
}
|
|
1317
|
-
const data = createFrame2(options, options.hash || {});
|
|
1318
|
-
let result = "";
|
|
1319
|
-
for (const key in obj) {
|
|
1320
|
-
data.key = key;
|
|
1321
|
-
result += options.fn(obj[key], { data });
|
|
1322
|
-
}
|
|
1323
|
-
return result;
|
|
1324
|
-
};
|
|
1325
|
-
var forOwn = (obj, options) => {
|
|
1326
|
-
if (!isOptions2(options)) {
|
|
1327
|
-
return options?.inverse?.(obj) ?? "";
|
|
1328
|
-
}
|
|
1329
|
-
const data = createFrame2(options, options.hash || {});
|
|
1330
|
-
let result = "";
|
|
1331
|
-
for (const key in obj) {
|
|
1332
|
-
if (Object.hasOwn(obj, key)) {
|
|
1333
|
-
data.key = key;
|
|
1334
|
-
result += options.fn(obj[key], { data });
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
return result;
|
|
1338
|
-
};
|
|
1339
|
-
var toPath = (...prop) => {
|
|
1340
|
-
const parts = [];
|
|
1341
|
-
for (const p of prop) {
|
|
1342
|
-
if (typeof p === "string" || typeof p === "number") {
|
|
1343
|
-
parts.push(p);
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return parts.join(".");
|
|
1347
|
-
};
|
|
1348
|
-
var getHelper = (prop, context, options) => {
|
|
1349
|
-
const val = get3(context, prop);
|
|
1350
|
-
if (options && typeof options.fn === "function") {
|
|
1351
|
-
return val ? options.fn(val) : options.inverse?.(context);
|
|
1352
|
-
}
|
|
1353
|
-
return val;
|
|
1354
|
-
};
|
|
1355
|
-
var getObjectHelper = (prop, context) => {
|
|
1356
|
-
return getObject(context, prop);
|
|
1357
|
-
};
|
|
1358
|
-
var hasOwn = (context, key) => {
|
|
1359
|
-
return Object.hasOwn(context, key);
|
|
1360
|
-
};
|
|
1361
|
-
var isObject = (value) => {
|
|
1362
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1363
|
-
};
|
|
1364
|
-
var JSONparse = (str) => {
|
|
1365
|
-
return JSON.parse(str);
|
|
1366
|
-
};
|
|
1367
|
-
var JSONstringify = (obj, indent) => {
|
|
1368
|
-
const ind = typeof indent === "number" ? indent : 0;
|
|
1369
|
-
return JSON.stringify(obj, null, ind);
|
|
1370
|
-
};
|
|
1371
|
-
var merge = (context, ...objects) => {
|
|
1372
|
-
const args = [context, ...objects];
|
|
1373
|
-
if (args.length && isOptions2(args[args.length - 1])) {
|
|
1374
|
-
const opts = args.pop();
|
|
1375
|
-
args.push(opts.hash);
|
|
1376
|
-
}
|
|
1377
|
-
return Object.assign(...args);
|
|
1378
|
-
};
|
|
1379
|
-
var parseJSON = JSONparse;
|
|
1380
|
-
var stringify = JSONstringify;
|
|
1381
|
-
var pick = (props, context, options) => {
|
|
1382
|
-
const keys = arrayify(props);
|
|
1383
|
-
let result = {};
|
|
1384
|
-
for (const key of keys) {
|
|
1385
|
-
result = Object.assign({}, result, getObject(context, key));
|
|
1386
|
-
}
|
|
1387
|
-
if (options && typeof options.fn === "function") {
|
|
1388
|
-
if (Object.keys(result).length) {
|
|
1389
|
-
return options.fn(result);
|
|
1390
|
-
}
|
|
1391
|
-
return options.inverse?.(context);
|
|
1392
|
-
}
|
|
1393
|
-
return result;
|
|
1394
|
-
};
|
|
1395
|
-
var helpers16 = [
|
|
1396
|
-
{
|
|
1397
|
-
name: "extend",
|
|
1398
|
-
category: "object",
|
|
1399
|
-
compatibility: ["browser", "nodejs"],
|
|
1400
|
-
fn: extend
|
|
1401
|
-
},
|
|
1402
|
-
{
|
|
1403
|
-
name: "forIn",
|
|
1404
|
-
category: "object",
|
|
1405
|
-
compatibility: ["browser", "nodejs"],
|
|
1406
|
-
fn: forIn
|
|
1407
|
-
},
|
|
1408
|
-
{
|
|
1409
|
-
name: "forOwn",
|
|
1410
|
-
category: "object",
|
|
1411
|
-
compatibility: ["browser", "nodejs"],
|
|
1412
|
-
fn: forOwn
|
|
1413
|
-
},
|
|
1414
|
-
{
|
|
1415
|
-
name: "toPath",
|
|
1416
|
-
category: "object",
|
|
1417
|
-
compatibility: ["browser", "nodejs"],
|
|
1418
|
-
fn: toPath
|
|
1419
|
-
},
|
|
1420
|
-
{
|
|
1421
|
-
name: "get",
|
|
1422
|
-
category: "object",
|
|
1423
|
-
compatibility: ["browser", "nodejs"],
|
|
1424
|
-
fn: getHelper
|
|
1425
|
-
},
|
|
1426
|
-
{
|
|
1427
|
-
name: "getObject",
|
|
1428
|
-
category: "object",
|
|
1429
|
-
compatibility: ["browser", "nodejs"],
|
|
1430
|
-
fn: getObjectHelper
|
|
1431
|
-
},
|
|
1432
|
-
{
|
|
1433
|
-
name: "hasOwn",
|
|
1434
|
-
category: "object",
|
|
1435
|
-
compatibility: ["browser", "nodejs"],
|
|
1436
|
-
fn: hasOwn
|
|
1437
|
-
},
|
|
1438
|
-
{
|
|
1439
|
-
name: "isObject",
|
|
1440
|
-
category: "object",
|
|
1441
|
-
compatibility: ["browser", "nodejs"],
|
|
1442
|
-
fn: isObject
|
|
1443
|
-
},
|
|
1444
|
-
{
|
|
1445
|
-
name: "JSONparse",
|
|
1446
|
-
category: "object",
|
|
1447
|
-
compatibility: ["browser", "nodejs"],
|
|
1448
|
-
fn: JSONparse
|
|
1449
|
-
},
|
|
1450
|
-
{
|
|
1451
|
-
name: "JSONstringify",
|
|
1452
|
-
category: "object",
|
|
1453
|
-
compatibility: ["browser", "nodejs"],
|
|
1454
|
-
fn: JSONstringify
|
|
1455
|
-
},
|
|
1456
|
-
{
|
|
1457
|
-
name: "merge",
|
|
1458
|
-
category: "object",
|
|
1459
|
-
compatibility: ["browser", "nodejs"],
|
|
1460
|
-
fn: merge
|
|
1461
|
-
},
|
|
1462
|
-
{
|
|
1463
|
-
name: "parseJSON",
|
|
1464
|
-
category: "object",
|
|
1465
|
-
compatibility: ["browser", "nodejs"],
|
|
1466
|
-
fn: parseJSON
|
|
1467
|
-
},
|
|
1468
|
-
{
|
|
1469
|
-
name: "pick",
|
|
1470
|
-
category: "object",
|
|
1471
|
-
compatibility: ["browser", "nodejs"],
|
|
1472
|
-
fn: pick
|
|
1473
|
-
},
|
|
1474
|
-
{
|
|
1475
|
-
name: "stringify",
|
|
1476
|
-
category: "object",
|
|
1477
|
-
compatibility: ["browser", "nodejs"],
|
|
1478
|
-
fn: stringify
|
|
1479
|
-
}
|
|
1480
|
-
];
|
|
1481
|
-
|
|
1482
|
-
// src/helpers/path.ts
|
|
1483
|
-
import path5 from "path";
|
|
1484
|
-
var expectedType = (variableName, expectedType2, variableValue) => {
|
|
1485
|
-
const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
|
|
1486
|
-
return `Expected ${variableName} to be of type ${expectedType2}, but got ${actualType}`;
|
|
1487
|
-
};
|
|
1488
|
-
var assertString = (name, value) => {
|
|
1489
|
-
if (typeof value !== "string") {
|
|
1490
|
-
throw new TypeError(expectedType(name, "string", value));
|
|
1491
|
-
}
|
|
1492
|
-
return value;
|
|
1493
|
-
};
|
|
1494
|
-
var absolute = function(filepath, options) {
|
|
1495
|
-
const fp = assertString("filepath", filepath);
|
|
1496
|
-
const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1497
|
-
return path5.resolve(cwd, fp);
|
|
1498
|
-
};
|
|
1499
|
-
var dirname = (filepath) => {
|
|
1500
|
-
const fp = assertString("filepath", filepath);
|
|
1501
|
-
return path5.dirname(fp);
|
|
1502
|
-
};
|
|
1503
|
-
var relative = (a, b) => {
|
|
1504
|
-
const from = assertString("first path", a);
|
|
1505
|
-
const to = assertString("second path", b);
|
|
1506
|
-
return path5.relative(path5.dirname(from), to);
|
|
1507
|
-
};
|
|
1508
|
-
var basename = (filepath) => {
|
|
1509
|
-
const fp = assertString("filepath", filepath);
|
|
1510
|
-
return path5.basename(fp);
|
|
1511
|
-
};
|
|
1512
|
-
var stem = (filepath) => {
|
|
1513
|
-
const fp = assertString("filepath", filepath);
|
|
1514
|
-
return path5.basename(fp, path5.extname(fp));
|
|
1515
|
-
};
|
|
1516
|
-
var extname = (filepath) => {
|
|
1517
|
-
const fp = assertString("filepath", filepath);
|
|
1518
|
-
return path5.extname(fp);
|
|
1519
|
-
};
|
|
1520
|
-
var resolveFn = function(filepath, ...paths) {
|
|
1521
|
-
let options;
|
|
1522
|
-
const last2 = paths[paths.length - 1];
|
|
1523
|
-
if (typeof last2 === "object" && last2 && "data" in last2) {
|
|
1524
|
-
options = paths.pop();
|
|
1525
|
-
}
|
|
1526
|
-
const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1527
|
-
const all2 = [
|
|
1528
|
-
cwd,
|
|
1529
|
-
assertString("filepath", filepath),
|
|
1530
|
-
...paths.map((p, i) => assertString(`path${i}`, p))
|
|
1531
|
-
];
|
|
1532
|
-
return path5.resolve(...all2);
|
|
1533
|
-
};
|
|
1534
|
-
var segments = (filepath, a, b) => {
|
|
1535
|
-
const fp = assertString("filepath", filepath);
|
|
1536
|
-
const start = Number(a);
|
|
1537
|
-
const end = Number(b);
|
|
1538
|
-
const segmentsArr = fp.split(/[\\/]+/);
|
|
1539
|
-
return segmentsArr.slice(start, end).join("/");
|
|
1540
|
-
};
|
|
1541
|
-
var helpers17 = [
|
|
1542
|
-
{
|
|
1543
|
-
name: "absolute",
|
|
1544
|
-
category: "path",
|
|
1545
|
-
compatibility: ["nodejs"],
|
|
1546
|
-
fn: absolute
|
|
1547
|
-
},
|
|
1548
|
-
{
|
|
1549
|
-
name: "dirname",
|
|
1550
|
-
category: "path",
|
|
1551
|
-
compatibility: ["nodejs"],
|
|
1552
|
-
fn: dirname
|
|
1553
|
-
},
|
|
1554
|
-
{
|
|
1555
|
-
name: "relative",
|
|
1556
|
-
category: "path",
|
|
1557
|
-
compatibility: ["nodejs"],
|
|
1558
|
-
fn: relative
|
|
1559
|
-
},
|
|
1560
|
-
{
|
|
1561
|
-
name: "basename",
|
|
1562
|
-
category: "path",
|
|
1563
|
-
compatibility: ["nodejs"],
|
|
1564
|
-
fn: basename
|
|
1565
|
-
},
|
|
1566
|
-
{
|
|
1567
|
-
name: "stem",
|
|
1568
|
-
category: "path",
|
|
1569
|
-
compatibility: ["nodejs"],
|
|
1570
|
-
fn: stem
|
|
1571
|
-
},
|
|
1572
|
-
{
|
|
1573
|
-
name: "extname",
|
|
1574
|
-
category: "path",
|
|
1575
|
-
compatibility: ["nodejs"],
|
|
1576
|
-
fn: extname
|
|
1577
|
-
},
|
|
1578
|
-
{
|
|
1579
|
-
name: "resolve",
|
|
1580
|
-
category: "path",
|
|
1581
|
-
compatibility: ["nodejs"],
|
|
1582
|
-
fn: resolveFn
|
|
1583
|
-
},
|
|
1584
|
-
{
|
|
1585
|
-
name: "segments",
|
|
1586
|
-
category: "path",
|
|
1587
|
-
compatibility: ["nodejs"],
|
|
1588
|
-
fn: segments
|
|
1589
|
-
}
|
|
1590
|
-
];
|
|
1591
|
-
|
|
1592
|
-
// src/helpers/regex.ts
|
|
1593
|
-
import util2 from "handlebars-utils";
|
|
1594
|
-
var toRegex = (str, locals, options) => {
|
|
1595
|
-
const opts = util2.options({}, locals, options);
|
|
1596
|
-
return new RegExp(str, opts.flags);
|
|
1597
|
-
};
|
|
1598
|
-
var test = (str, regex) => {
|
|
1599
|
-
if (typeof str !== "string") {
|
|
1600
|
-
return false;
|
|
1601
|
-
}
|
|
1602
|
-
if (!(regex instanceof RegExp)) {
|
|
1603
|
-
throw new TypeError("expected a regular expression");
|
|
1604
|
-
}
|
|
1605
|
-
return regex.test(str);
|
|
1606
|
-
};
|
|
1607
|
-
var helpers18 = [
|
|
1608
|
-
{
|
|
1609
|
-
name: "toRegex",
|
|
1610
|
-
category: "regex",
|
|
1611
|
-
compatibility: ["browser", "nodejs"],
|
|
1612
|
-
fn: toRegex
|
|
1613
|
-
},
|
|
1614
|
-
{
|
|
1615
|
-
name: "test",
|
|
1616
|
-
category: "regex",
|
|
1617
|
-
compatibility: ["browser", "nodejs"],
|
|
1618
|
-
fn: test
|
|
1619
|
-
}
|
|
1620
|
-
];
|
|
1621
|
-
|
|
1622
|
-
// src/helpers/string.ts
|
|
1623
|
-
var chop = (str) => str.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g, "");
|
|
1624
|
-
var changecase = (str, fn) => {
|
|
1625
|
-
if (str.length === 1) return str.toLowerCase();
|
|
1626
|
-
const res = chop(str).toLowerCase();
|
|
1627
|
-
return res.replace(/[-_.\W\s]+(\w|$)/g, (_, ch) => fn(ch));
|
|
1628
|
-
};
|
|
1629
|
-
var append = (str, suffix) => {
|
|
1630
|
-
if (typeof str === "string" && typeof suffix === "string") {
|
|
1631
|
-
return str + suffix;
|
|
1632
|
-
}
|
|
1633
|
-
return str;
|
|
1634
|
-
};
|
|
1635
|
-
var camelcase = (str) => typeof str === "string" ? changecase(str, (ch) => ch.toUpperCase()) : "";
|
|
1636
|
-
var capitalize = (str) => {
|
|
1637
|
-
if (typeof str !== "string" || str.length === 0) return "";
|
|
1638
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1639
|
-
};
|
|
1640
|
-
var capitalizeAll = (str) => {
|
|
1641
|
-
if (typeof str !== "string") return "";
|
|
1642
|
-
return str.replace(/\w\S*/g, (word) => capitalize(word));
|
|
1643
|
-
};
|
|
1644
|
-
var center = (str, spaces) => {
|
|
1645
|
-
if (typeof str !== "string") return "";
|
|
1646
|
-
let space = "";
|
|
1647
|
-
for (let i = 0; i < spaces; i++) {
|
|
1648
|
-
space += " ";
|
|
1649
|
-
}
|
|
1650
|
-
return space + str + space;
|
|
1651
|
-
};
|
|
1652
|
-
var chopStr = (str) => typeof str === "string" ? chop(str) : "";
|
|
1653
|
-
var dashcase = (str) => typeof str === "string" ? changecase(str, (ch) => `-${ch}`) : "";
|
|
1654
|
-
var dotcase = (str) => typeof str === "string" ? changecase(str, (ch) => `.${ch}`) : "";
|
|
1655
|
-
var truncate = (str, limit, suffix) => {
|
|
1656
|
-
if (typeof str === "string") {
|
|
1657
|
-
if (typeof suffix !== "string") {
|
|
1658
|
-
suffix = "";
|
|
1659
|
-
}
|
|
1660
|
-
if (str.length > limit) {
|
|
1661
|
-
return str.slice(0, limit - suffix.length) + suffix;
|
|
1662
|
-
}
|
|
1663
|
-
return str;
|
|
1664
|
-
}
|
|
1665
|
-
return "";
|
|
1666
|
-
};
|
|
1667
|
-
var ellipsis = (str, limit) => {
|
|
1668
|
-
if (typeof str === "string") {
|
|
1669
|
-
if (str.length <= limit) {
|
|
1670
|
-
return str;
|
|
1671
|
-
}
|
|
1672
|
-
return `${truncate(str, limit)}\u2026`;
|
|
1673
|
-
}
|
|
1674
|
-
return "";
|
|
1675
|
-
};
|
|
1676
|
-
var hyphenate = (str) => typeof str === "string" ? str.split(" ").join("-") : "";
|
|
1677
|
-
var isString = (value) => typeof value === "string";
|
|
1678
|
-
var lowercase = (str) => {
|
|
1679
|
-
if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
|
|
1680
|
-
return String(str.fn()).toLowerCase();
|
|
1681
|
-
}
|
|
1682
|
-
if (typeof str !== "string") return "";
|
|
1683
|
-
return str.toLowerCase();
|
|
1684
|
-
};
|
|
1685
|
-
var downcase = (...args) => lowercase(...args);
|
|
1686
|
-
var occurrences = (str, substring) => {
|
|
1687
|
-
if (typeof str !== "string") return "";
|
|
1688
|
-
const len = substring.length;
|
|
1689
|
-
let pos = str.indexOf(substring, 0);
|
|
1690
|
-
let n = 0;
|
|
1691
|
-
while (pos > -1) {
|
|
1692
|
-
n++;
|
|
1693
|
-
pos = str.indexOf(substring, pos + len);
|
|
1694
|
-
}
|
|
1695
|
-
return n;
|
|
1696
|
-
};
|
|
1697
|
-
var pascalcase = (str) => {
|
|
1698
|
-
if (typeof str !== "string") return "";
|
|
1699
|
-
const res = changecase(str, (ch) => ch.toUpperCase());
|
|
1700
|
-
return res.charAt(0).toUpperCase() + res.slice(1);
|
|
1701
|
-
};
|
|
1702
|
-
var pathcase = (str) => typeof str === "string" ? changecase(str, (ch) => `/${ch}`) : "";
|
|
1703
|
-
var plusify = (str, ch) => {
|
|
1704
|
-
if (typeof str !== "string") return "";
|
|
1705
|
-
if (typeof ch !== "string") ch = " ";
|
|
1706
|
-
return str.split(ch).join("+");
|
|
1707
|
-
};
|
|
1708
|
-
var prepend = (str, prefix) => {
|
|
1709
|
-
return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
|
|
1710
|
-
};
|
|
1711
|
-
var remove = (str, ch) => {
|
|
1712
|
-
if (typeof str !== "string") return "";
|
|
1713
|
-
if (typeof ch !== "string") return str;
|
|
1714
|
-
return str.split(ch).join("");
|
|
1715
|
-
};
|
|
1716
|
-
var removeFirst = (str, ch) => {
|
|
1717
|
-
if (typeof str !== "string") return "";
|
|
1718
|
-
if (typeof ch !== "string") return str;
|
|
1719
|
-
return str.replace(ch, "");
|
|
1720
|
-
};
|
|
1721
|
-
var replace = (str, a, b) => {
|
|
1722
|
-
if (typeof str !== "string") return "";
|
|
1723
|
-
if (typeof a !== "string") return str;
|
|
1724
|
-
if (typeof b !== "string") b = "";
|
|
1725
|
-
return str.split(a).join(b);
|
|
1726
|
-
};
|
|
1727
|
-
var replaceFirst = (str, a, b) => {
|
|
1728
|
-
if (typeof str !== "string") return "";
|
|
1729
|
-
if (typeof a !== "string") return str;
|
|
1730
|
-
if (typeof b !== "string") b = "";
|
|
1731
|
-
return str.replace(a, b);
|
|
1732
|
-
};
|
|
1733
|
-
var reverse = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
|
|
1734
|
-
var sentence = (str) => {
|
|
1735
|
-
if (typeof str !== "string") return "";
|
|
1736
|
-
return str.replace(
|
|
1737
|
-
/((?:\S[^.?!]*)[.?!]*)/g,
|
|
1738
|
-
(txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
|
|
1739
|
-
);
|
|
1740
|
-
};
|
|
1741
|
-
var snakecase = (str) => typeof str === "string" ? changecase(str, (ch) => `_${ch}`) : "";
|
|
1742
|
-
var trim = (str) => typeof str === "string" ? str.trim() : "";
|
|
1743
|
-
var trimLeft = (str) => typeof str === "string" ? str.replace(/^\s+/, "") : "";
|
|
1744
|
-
var trimRight = (str) => typeof str === "string" ? str.replace(/\s+$/, "") : "";
|
|
1745
|
-
var truncateWords = (str, count, suffix) => {
|
|
1746
|
-
if (typeof str === "string" && typeof count === "number" && Number.isFinite(count)) {
|
|
1747
|
-
if (typeof suffix !== "string") {
|
|
1748
|
-
suffix = "...";
|
|
1749
|
-
}
|
|
1750
|
-
const num = Math.trunc(count);
|
|
1751
|
-
let arr = str.split(" ");
|
|
1752
|
-
if (num < arr.length) {
|
|
1753
|
-
arr = arr.slice(0, num);
|
|
1754
|
-
}
|
|
1755
|
-
const val = arr.join(" ").trim();
|
|
1756
|
-
return val + suffix;
|
|
1757
|
-
}
|
|
1758
|
-
return "";
|
|
1759
|
-
};
|
|
1760
|
-
var truncateWordsAlias = truncateWords;
|
|
1761
|
-
var uppercase = (str) => {
|
|
1762
|
-
if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
|
|
1763
|
-
return String(str.fn()).toUpperCase();
|
|
1764
|
-
}
|
|
1765
|
-
if (typeof str !== "string") return "";
|
|
1766
|
-
return str.toUpperCase();
|
|
1767
|
-
};
|
|
1768
|
-
var upcase = (...args) => uppercase(...args);
|
|
1769
|
-
var helpers19 = [
|
|
1770
|
-
{
|
|
1771
|
-
name: "append",
|
|
1772
|
-
category: "string",
|
|
1773
|
-
compatibility: ["browser", "nodejs"],
|
|
1774
|
-
fn: append
|
|
1775
|
-
},
|
|
1776
|
-
{
|
|
1777
|
-
name: "camelcase",
|
|
1778
|
-
category: "string",
|
|
1779
|
-
compatibility: ["browser", "nodejs"],
|
|
1780
|
-
fn: camelcase
|
|
1781
|
-
},
|
|
1782
|
-
{
|
|
1783
|
-
name: "capitalize",
|
|
1784
|
-
category: "string",
|
|
1785
|
-
compatibility: ["browser", "nodejs"],
|
|
1786
|
-
fn: capitalize
|
|
1787
|
-
},
|
|
1788
|
-
{
|
|
1789
|
-
name: "capitalizeAll",
|
|
1790
|
-
category: "string",
|
|
1791
|
-
compatibility: ["browser", "nodejs"],
|
|
1792
|
-
fn: capitalizeAll
|
|
1793
|
-
},
|
|
1794
|
-
{
|
|
1795
|
-
name: "center",
|
|
1796
|
-
category: "string",
|
|
1797
|
-
compatibility: ["browser", "nodejs"],
|
|
1798
|
-
fn: center
|
|
1799
|
-
},
|
|
1800
|
-
{
|
|
1801
|
-
name: "chop",
|
|
1802
|
-
category: "string",
|
|
1803
|
-
compatibility: ["browser", "nodejs"],
|
|
1804
|
-
fn: chopStr
|
|
1805
|
-
},
|
|
1806
|
-
{
|
|
1807
|
-
name: "dashcase",
|
|
1808
|
-
category: "string",
|
|
1809
|
-
compatibility: ["browser", "nodejs"],
|
|
1810
|
-
fn: dashcase
|
|
1811
|
-
},
|
|
1812
|
-
{
|
|
1813
|
-
name: "dotcase",
|
|
1814
|
-
category: "string",
|
|
1815
|
-
compatibility: ["browser", "nodejs"],
|
|
1816
|
-
fn: dotcase
|
|
1817
|
-
},
|
|
1818
|
-
{
|
|
1819
|
-
name: "ellipsis",
|
|
1820
|
-
category: "string",
|
|
1821
|
-
compatibility: ["browser", "nodejs"],
|
|
1822
|
-
fn: ellipsis
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
name: "hyphenate",
|
|
1826
|
-
category: "string",
|
|
1827
|
-
compatibility: ["browser", "nodejs"],
|
|
1828
|
-
fn: hyphenate
|
|
1829
|
-
},
|
|
1830
|
-
{
|
|
1831
|
-
name: "isString",
|
|
1832
|
-
category: "string",
|
|
1833
|
-
compatibility: ["browser", "nodejs"],
|
|
1834
|
-
fn: isString
|
|
1835
|
-
},
|
|
1836
|
-
{
|
|
1837
|
-
name: "lowercase",
|
|
1838
|
-
category: "string",
|
|
1839
|
-
compatibility: ["browser", "nodejs"],
|
|
1840
|
-
fn: lowercase
|
|
1841
|
-
},
|
|
1842
|
-
{
|
|
1843
|
-
name: "downcase",
|
|
1844
|
-
category: "string",
|
|
1845
|
-
compatibility: ["browser", "nodejs"],
|
|
1846
|
-
fn: downcase
|
|
1847
|
-
},
|
|
1848
|
-
{
|
|
1849
|
-
name: "occurrences",
|
|
1850
|
-
category: "string",
|
|
1851
|
-
compatibility: ["browser", "nodejs"],
|
|
1852
|
-
fn: occurrences
|
|
1853
|
-
},
|
|
1854
|
-
{
|
|
1855
|
-
name: "pascalcase",
|
|
1856
|
-
category: "string",
|
|
1857
|
-
compatibility: ["browser", "nodejs"],
|
|
1858
|
-
fn: pascalcase
|
|
1859
|
-
},
|
|
1860
|
-
{
|
|
1861
|
-
name: "pathcase",
|
|
1862
|
-
category: "string",
|
|
1863
|
-
compatibility: ["browser", "nodejs"],
|
|
1864
|
-
fn: pathcase
|
|
1865
|
-
},
|
|
1866
|
-
{
|
|
1867
|
-
name: "plusify",
|
|
1868
|
-
category: "string",
|
|
1869
|
-
compatibility: ["browser", "nodejs"],
|
|
1870
|
-
fn: plusify
|
|
1871
|
-
},
|
|
1872
|
-
{
|
|
1873
|
-
name: "prepend",
|
|
1874
|
-
category: "string",
|
|
1875
|
-
compatibility: ["browser", "nodejs"],
|
|
1876
|
-
fn: prepend
|
|
1877
|
-
},
|
|
1878
|
-
{
|
|
1879
|
-
name: "remove",
|
|
1880
|
-
category: "string",
|
|
1881
|
-
compatibility: ["browser", "nodejs"],
|
|
1882
|
-
fn: remove
|
|
1883
|
-
},
|
|
1884
|
-
{
|
|
1885
|
-
name: "removeFirst",
|
|
1886
|
-
category: "string",
|
|
1887
|
-
compatibility: ["browser", "nodejs"],
|
|
1888
|
-
fn: removeFirst
|
|
1889
|
-
},
|
|
1890
|
-
{
|
|
1891
|
-
name: "replace",
|
|
1892
|
-
category: "string",
|
|
1893
|
-
compatibility: ["browser", "nodejs"],
|
|
1894
|
-
fn: replace
|
|
1895
|
-
},
|
|
1896
|
-
{
|
|
1897
|
-
name: "replaceFirst",
|
|
1898
|
-
category: "string",
|
|
1899
|
-
compatibility: ["browser", "nodejs"],
|
|
1900
|
-
fn: replaceFirst
|
|
1901
|
-
},
|
|
1902
|
-
{
|
|
1903
|
-
name: "reverse",
|
|
1904
|
-
category: "string",
|
|
1905
|
-
compatibility: ["browser", "nodejs"],
|
|
1906
|
-
fn: reverse
|
|
1907
|
-
},
|
|
1908
|
-
{
|
|
1909
|
-
name: "sentence",
|
|
1910
|
-
category: "string",
|
|
1911
|
-
compatibility: ["browser", "nodejs"],
|
|
1912
|
-
fn: sentence
|
|
1913
|
-
},
|
|
1914
|
-
{
|
|
1915
|
-
name: "snakecase",
|
|
1916
|
-
category: "string",
|
|
1917
|
-
compatibility: ["browser", "nodejs"],
|
|
1918
|
-
fn: snakecase
|
|
1919
|
-
},
|
|
1920
|
-
{
|
|
1921
|
-
name: "trim",
|
|
1922
|
-
category: "string",
|
|
1923
|
-
compatibility: ["browser", "nodejs"],
|
|
1924
|
-
fn: trim
|
|
1925
|
-
},
|
|
1926
|
-
{
|
|
1927
|
-
name: "trimLeft",
|
|
1928
|
-
category: "string",
|
|
1929
|
-
compatibility: ["browser", "nodejs"],
|
|
1930
|
-
fn: trimLeft
|
|
1931
|
-
},
|
|
1932
|
-
{
|
|
1933
|
-
name: "trimRight",
|
|
1934
|
-
category: "string",
|
|
1935
|
-
compatibility: ["browser", "nodejs"],
|
|
1936
|
-
fn: trimRight
|
|
1937
|
-
},
|
|
1938
|
-
{
|
|
1939
|
-
name: "truncate",
|
|
1940
|
-
category: "string",
|
|
1941
|
-
compatibility: ["browser", "nodejs"],
|
|
1942
|
-
fn: truncate
|
|
1943
|
-
},
|
|
1944
|
-
{
|
|
1945
|
-
name: "truncateWords",
|
|
1946
|
-
category: "string",
|
|
1947
|
-
compatibility: ["browser", "nodejs"],
|
|
1948
|
-
fn: truncateWordsAlias
|
|
1949
|
-
},
|
|
1950
|
-
{
|
|
1951
|
-
name: "uppercase",
|
|
1952
|
-
category: "string",
|
|
1953
|
-
compatibility: ["browser", "nodejs"],
|
|
1954
|
-
fn: uppercase
|
|
1955
|
-
},
|
|
1956
|
-
{
|
|
1957
|
-
name: "upcase",
|
|
1958
|
-
category: "string",
|
|
1959
|
-
compatibility: ["browser", "nodejs"],
|
|
1960
|
-
fn: upcase
|
|
1961
|
-
}
|
|
1962
|
-
];
|
|
1963
|
-
|
|
1964
|
-
// src/helpers/url.ts
|
|
1965
|
-
import { escape as qsEscape } from "querystring";
|
|
1966
|
-
import { format, parse, resolve } from "url";
|
|
1967
|
-
var all = ["browser", "nodejs"];
|
|
1968
|
-
var encodeUri = (str) => {
|
|
1969
|
-
if (typeof str === "string") {
|
|
1970
|
-
return encodeURIComponent(str);
|
|
1971
|
-
}
|
|
1972
|
-
};
|
|
1973
|
-
var escapeFn = (str) => {
|
|
1974
|
-
if (typeof str === "string") {
|
|
1975
|
-
return qsEscape(str);
|
|
1976
|
-
}
|
|
1977
|
-
};
|
|
1978
|
-
var decodeUri = (str) => {
|
|
1979
|
-
if (typeof str === "string") {
|
|
1980
|
-
return decodeURIComponent(str);
|
|
1981
|
-
}
|
|
1982
|
-
};
|
|
1983
|
-
function urlEncode(...args) {
|
|
1984
|
-
return encodeUri.apply(this, args);
|
|
1985
|
-
}
|
|
1986
|
-
function urlDecode(...args) {
|
|
1987
|
-
return decodeUri.apply(this, args);
|
|
1988
|
-
}
|
|
1989
|
-
var urlResolve = (base, href) => resolve(String(base), String(href));
|
|
1990
|
-
var urlParse = (str) => parse(String(str));
|
|
1991
|
-
var stripQuerystring = (str) => {
|
|
1992
|
-
if (typeof str === "string") {
|
|
1993
|
-
return str.split("?")[0];
|
|
1994
|
-
}
|
|
1995
|
-
};
|
|
1996
|
-
var stripProtocol = (str) => {
|
|
1997
|
-
if (typeof str === "string") {
|
|
1998
|
-
const parsed = parse(str);
|
|
1999
|
-
parsed.protocol = "";
|
|
2000
|
-
return format(parsed);
|
|
2001
|
-
}
|
|
2002
|
-
};
|
|
2003
|
-
var helpers20 = [
|
|
2004
|
-
{
|
|
2005
|
-
name: "encodeURI",
|
|
2006
|
-
category: "url",
|
|
2007
|
-
compatibility: all,
|
|
2008
|
-
fn: encodeUri
|
|
2009
|
-
},
|
|
2010
|
-
{
|
|
2011
|
-
name: "escape",
|
|
2012
|
-
category: "url",
|
|
2013
|
-
compatibility: ["nodejs"],
|
|
2014
|
-
fn: escapeFn
|
|
2015
|
-
},
|
|
2016
|
-
{
|
|
2017
|
-
name: "decodeURI",
|
|
2018
|
-
category: "url",
|
|
2019
|
-
compatibility: all,
|
|
2020
|
-
fn: decodeUri
|
|
2021
|
-
},
|
|
2022
|
-
{
|
|
2023
|
-
name: "url_encode",
|
|
2024
|
-
category: "url",
|
|
2025
|
-
compatibility: all,
|
|
2026
|
-
fn: urlEncode
|
|
2027
|
-
},
|
|
2028
|
-
{
|
|
2029
|
-
name: "url_decode",
|
|
2030
|
-
category: "url",
|
|
2031
|
-
compatibility: all,
|
|
2032
|
-
fn: urlDecode
|
|
2033
|
-
},
|
|
2034
|
-
{
|
|
2035
|
-
name: "urlResolve",
|
|
2036
|
-
category: "url",
|
|
2037
|
-
compatibility: ["nodejs"],
|
|
2038
|
-
fn: urlResolve
|
|
2039
|
-
},
|
|
2040
|
-
{
|
|
2041
|
-
name: "urlParse",
|
|
2042
|
-
category: "url",
|
|
2043
|
-
compatibility: ["nodejs"],
|
|
2044
|
-
fn: urlParse
|
|
2045
|
-
},
|
|
2046
|
-
{
|
|
2047
|
-
name: "stripQuerystring",
|
|
2048
|
-
category: "url",
|
|
2049
|
-
compatibility: all,
|
|
2050
|
-
fn: stripQuerystring
|
|
2051
|
-
},
|
|
2052
|
-
{
|
|
2053
|
-
name: "stripProtocol",
|
|
2054
|
-
category: "url",
|
|
2055
|
-
compatibility: ["nodejs"],
|
|
2056
|
-
fn: stripProtocol
|
|
2057
|
-
}
|
|
2058
|
-
];
|
|
2059
|
-
|
|
2060
|
-
// src/helper-registry.ts
|
|
2061
|
-
var HelperRegistry = class {
|
|
2062
|
-
_helpers = [];
|
|
2063
|
-
constructor() {
|
|
2064
|
-
this.init();
|
|
2065
|
-
}
|
|
2066
|
-
/**
|
|
2067
|
-
* Get all registered helpers.
|
|
2068
|
-
* @returns {Helper[]} The array of registered helpers.
|
|
2069
|
-
*/
|
|
2070
|
-
get helpers() {
|
|
2071
|
-
return this._helpers;
|
|
2072
|
-
}
|
|
2073
|
-
/**
|
|
2074
|
-
* Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
|
|
2075
|
-
*/
|
|
2076
|
-
init() {
|
|
2077
|
-
this.registerHelpers(helpers);
|
|
2078
|
-
this.registerHelpers(helpers3);
|
|
2079
|
-
this.registerHelpers(helpers5);
|
|
2080
|
-
this.registerHelpers(helpers6);
|
|
2081
|
-
this.registerHelpers(helpers2);
|
|
2082
|
-
this.registerHelpers(helpers13);
|
|
2083
|
-
this.registerHelpers(helpers7);
|
|
2084
|
-
this.registerHelpers(helpers4);
|
|
2085
|
-
this.registerHelpers(helpers8);
|
|
2086
|
-
this.registerHelpers(helpers9);
|
|
2087
|
-
this.registerHelpers(helpers10);
|
|
2088
|
-
this.registerHelpers(helpers11);
|
|
2089
|
-
this.registerHelpers(helpers12);
|
|
2090
|
-
this.registerHelpers(helpers14);
|
|
2091
|
-
this.registerHelpers(helpers15);
|
|
2092
|
-
this.registerHelpers(helpers17);
|
|
2093
|
-
this.registerHelpers(helpers18);
|
|
2094
|
-
this.registerHelpers(helpers19);
|
|
2095
|
-
this.registerHelpers(helpers20);
|
|
2096
|
-
this.registerHelpers(helpers16);
|
|
2097
|
-
}
|
|
2098
|
-
/**
|
|
2099
|
-
* Register a helper.
|
|
2100
|
-
* @param {Helper} helper The helper to register.
|
|
2101
|
-
* @returns True if the helper was registered, false otherwise.
|
|
2102
|
-
*/
|
|
2103
|
-
register(helper) {
|
|
2104
|
-
const result = false;
|
|
2105
|
-
if (!this.has(helper.name)) {
|
|
2106
|
-
this._helpers.push(helper);
|
|
2107
|
-
}
|
|
2108
|
-
return result;
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Register multiple helpers.
|
|
2112
|
-
* @param {Helper[]} helpers The array of helpers to register.
|
|
2113
|
-
*/
|
|
2114
|
-
registerHelpers(helpers22) {
|
|
2115
|
-
for (const helper of helpers22) {
|
|
2116
|
-
this.register(helper);
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Check if a helper is registered.
|
|
2121
|
-
* @param name The name of the helper.
|
|
2122
|
-
* @returns True if the helper is registered, false otherwise.
|
|
2123
|
-
*/
|
|
2124
|
-
has(name) {
|
|
2125
|
-
return this._helpers.some((helper) => helper.name === name);
|
|
2126
|
-
}
|
|
2127
|
-
/**
|
|
2128
|
-
* Filter helpers by the given criteria.
|
|
2129
|
-
* @param filter The filter criteria.
|
|
2130
|
-
* @returns The filtered helpers.
|
|
2131
|
-
*/
|
|
2132
|
-
filter(filter) {
|
|
2133
|
-
let result = this._helpers;
|
|
2134
|
-
if (filter.names) {
|
|
2135
|
-
result = result.filter((helper) => filter.names?.includes(helper.name));
|
|
2136
|
-
}
|
|
2137
|
-
if (filter.categories) {
|
|
2138
|
-
result = result.filter(
|
|
2139
|
-
(helper) => filter.categories?.includes(helper.category)
|
|
2140
|
-
);
|
|
2141
|
-
}
|
|
2142
|
-
if (filter.compatibility) {
|
|
2143
|
-
result = result.filter(
|
|
2144
|
-
(helper) => helper.compatibility?.some((c) => filter.compatibility?.includes(c))
|
|
2145
|
-
);
|
|
2146
|
-
}
|
|
2147
|
-
return result;
|
|
2148
|
-
}
|
|
2149
|
-
/**
|
|
2150
|
-
* Load Handlebars helpers.
|
|
2151
|
-
* @param {Handlebars} handlebars The Handlebars instance.
|
|
2152
|
-
* @returns {void}
|
|
2153
|
-
*/
|
|
2154
|
-
load(handlebars2, filters) {
|
|
2155
|
-
let helpers22 = this._helpers;
|
|
2156
|
-
if (filters) {
|
|
2157
|
-
helpers22 = this.filter(filters);
|
|
2158
|
-
}
|
|
2159
|
-
for (const helper of helpers22) {
|
|
2160
|
-
handlebars2.registerHelper(helper.name, helper.fn);
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
/**
|
|
2164
|
-
* Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
|
|
2165
|
-
* @param handlebars The Handlebars instance.
|
|
2166
|
-
* @returns {void}
|
|
2167
|
-
*/
|
|
2168
|
-
swap(handlebars2) {
|
|
2169
|
-
for (const helper of this._helpers) {
|
|
2170
|
-
handlebars2.unregisterHelper(helper.name);
|
|
2171
|
-
handlebars2.registerHelper(helper.name, helper.fn);
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
};
|
|
2175
|
-
|
|
2176
|
-
// src/index.ts
|
|
2177
|
-
var Handlebars2 = HandlebarsLib;
|
|
2178
|
-
var handlebars = HandlebarsLib.create();
|
|
2179
|
-
function helpers21(options) {
|
|
2180
|
-
const registry = new HelperRegistry();
|
|
2181
|
-
registry.load(options.handlebars ?? options.hbs);
|
|
2182
|
-
}
|
|
2183
|
-
async function createHandlebars() {
|
|
2184
|
-
const registry = new HelperRegistry();
|
|
2185
|
-
const handlebars2 = HandlebarsLib.create();
|
|
2186
|
-
registry.load(handlebars2);
|
|
2187
|
-
if (process.env.NODE_ENV === "development") {
|
|
2188
|
-
console.warn(
|
|
2189
|
-
"createHandlebars will be deprecated in future versions, use `fumanchu` instead."
|
|
2190
|
-
);
|
|
2191
|
-
}
|
|
2192
|
-
return handlebars2;
|
|
2193
|
-
}
|
|
2194
|
-
function fumanchu(options) {
|
|
2195
|
-
const registry = new HelperRegistry();
|
|
2196
|
-
let handlebars2 = HandlebarsLib.create();
|
|
2197
|
-
if (options?.handlebars) {
|
|
2198
|
-
handlebars2 = options.handlebars;
|
|
2199
|
-
}
|
|
2200
|
-
registry.load(handlebars2);
|
|
2201
|
-
return handlebars2;
|
|
2202
|
-
}
|
|
2203
|
-
export {
|
|
2204
|
-
Handlebars2 as Handlebars,
|
|
2205
|
-
HelperRegistry,
|
|
2206
|
-
createHandlebars,
|
|
2207
|
-
fumanchu,
|
|
2208
|
-
handlebars,
|
|
2209
|
-
helpers21 as helpers
|
|
2210
|
-
};
|
|
1
|
+
import j from"handlebars";var ln=(n,e)=>Array.isArray(n)?n.slice(e):[],yn=(n,e)=>Array.isArray(n)?n.slice(0,-e):[],l=n=>n==null?[]:Array.isArray(n)?n:[n],gn=(n,e)=>{if(Array.isArray(n))return typeof e!="number"?n[0]:n.slice(0,e)},fn=(n,e)=>{if(!Array.isArray(n)&&typeof n!="string")return;if(typeof e!="number"){let t=n;return t[t.length-1]}let r=Math.abs(e);return n.slice(-r)},un=n=>n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).length:typeof n=="string"||Array.isArray(n)?n.length:0,bn=(n,e=", ")=>typeof n=="string"?n:Array.isArray(n)?n.join(e):"",x=[{name:"after",category:"array",compatibility:["browser","nodejs"],fn:ln},{name:"before",category:"array",compatibility:["browser","nodejs"],fn:yn},{name:"arrayify",category:"array",compatibility:["browser","nodejs"],fn:l},{name:"first",category:"array",compatibility:["browser","nodejs"],fn:gn},{name:"last",category:"array",compatibility:["browser","nodejs"],fn},{name:"length",category:"array",compatibility:["browser","nodejs"],fn:un},{name:"join",category:"array",compatibility:["browser","nodejs"],fn:bn}];import dn from"fs";import hn from"path";import N from"html-tag";import wn from"to-gfm-code-block";var jn=(n,e)=>{let r=typeof e=="string"?e:hn.extname(n).slice(1),t=dn.readFileSync(n,"utf8");return(r==="markdown"||r==="md")&&(r="markdown",t=t.split("`").join("`")),`${wn(t,r).trim()}
|
|
2
|
+
`},kn=n=>N("script",{src:`https://gist.github.com/${n}.js`}),Hn=n=>{if(!n||!n.id)throw new Error("jsfiddle helper expects an `id`");let{id:e,width:r="100%",height:t="300",skin:o="/presentation/",tabs:s="result,js,html,css",allowfullscreen:i="allowfullscreen",frameborder:c="0"}=n,d=`http://jsfiddle.net/${e}/embedded/${s}${o}`;return N("iframe",{width:r,height:t,src:d,allowfullscreen:i,frameborder:c})},$=[{name:"embed",category:"code",compatibility:["nodejs"],fn:jn},{name:"gist",category:"code",compatibility:["browser","nodejs"],fn:kn},{name:"jsfiddle",category:"code",compatibility:["browser","nodejs"],fn:Hn}];var xn=n=>n==null?!0:Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:!1,Nn=(n,e,r)=>{if(Array.isArray(n)){let t="";for(let o=0;o<n.length;o++)t+=e(n[o],o);return t}if(n&&typeof n=="object"){let t="";for(let o of Object.keys(n))t+=e(n[o],o);return t}return r?r():""},O=[{name:"isEmpty",category:"collection",compatibility:["browser","nodejs"],fn:xn},{name:"iterate",category:"collection",compatibility:["browser","nodejs"],fn:Nn}];var $n=(...n)=>n.every(Boolean),On=(n,e,r)=>{switch(e){case"==":return n==r;case"===":return n===r;case"!=":return n!=r;case"!==":return n!==r;case"<":return n<r;case">":return n>r;case"<=":return n<=r;case">=":return n>=r;case"typeof":return typeof n===r;default:throw new Error(`helper {{compare}}: invalid operator: '${e}'`)}},An=(n,e,r=0)=>n==null?!1:typeof n=="string"||Array.isArray(n)?n.indexOf(e,r)>-1:typeof n=="object"?e in n:!1,Rn=(...n)=>{for(let e of n)if(e!=null)return e;return""},Sn=(n,e)=>n===e,Bn=(n,e)=>n>e,Tn=(n,e)=>n>=e,En=(n,e)=>n==null||e==null?!1:Array.isArray(n)||typeof n=="string"?n.indexOf(e)>-1:typeof n=="object"?e in n:!1,A=(n,e)=>{if(!n)return!0;let r=Array.isArray(e)?e:e!=null?[e]:["0","false","nada","nil","nay","nah","negative","no","none","nope","nul","null","nix","nyet","uh-uh","veto","zero"],t=typeof n=="string"?n.toLowerCase():null;for(let o of r)if(o===n||t!=null&&o===t)return!0;return!1},Fn=n=>A(n),_n=n=>!A(n),Cn=n=>typeof n=="number"&&n%2===0,Mn=(n,e)=>typeof n=="number"&&typeof e=="number"&&e%n===0,zn=n=>typeof n=="number"&&Math.abs(n%2)===1,Ln=(n,e)=>n==e,Un=(n,e)=>n!=e,Pn=(n,e)=>n<e,In=(n,e)=>n<=e,Jn=(n,e)=>!n&&!e,qn=n=>!n,Wn=(...n)=>n.some(Boolean),Dn=(n,e)=>n!==e,Gn=(n,e)=>n<=e,vn=(n,e)=>n>=e,Yn=(n,e)=>n<e,Qn=(n,e)=>n>e,R=[{name:"and",category:"comparison",compatibility:["browser","nodejs"],fn:$n},{name:"compare",category:"comparison",compatibility:["browser","nodejs"],fn:On},{name:"contains",category:"comparison",compatibility:["browser","nodejs"],fn:An},{name:"default",category:"comparison",compatibility:["browser","nodejs"],fn:Rn},{name:"eq",category:"comparison",compatibility:["browser","nodejs"],fn:Sn},{name:"gt",category:"comparison",compatibility:["browser","nodejs"],fn:Bn},{name:"gte",category:"comparison",compatibility:["browser","nodejs"],fn:Tn},{name:"has",category:"comparison",compatibility:["browser","nodejs"],fn:En},{name:"isFalsey",category:"comparison",compatibility:["browser","nodejs"],fn:Fn},{name:"isTruthy",category:"comparison",compatibility:["browser","nodejs"],fn:_n},{name:"ifEven",category:"comparison",compatibility:["browser","nodejs"],fn:Cn},{name:"ifNth",category:"comparison",compatibility:["browser","nodejs"],fn:Mn},{name:"ifOdd",category:"comparison",compatibility:["browser","nodejs"],fn:zn},{name:"is",category:"comparison",compatibility:["browser","nodejs"],fn:Ln},{name:"isnt",category:"comparison",compatibility:["browser","nodejs"],fn:Un},{name:"lt",category:"comparison",compatibility:["browser","nodejs"],fn:Pn},{name:"lte",category:"comparison",compatibility:["browser","nodejs"],fn:In},{name:"neither",category:"comparison",compatibility:["browser","nodejs"],fn:Jn},{name:"not",category:"comparison",compatibility:["browser","nodejs"],fn:qn},{name:"or",category:"comparison",compatibility:["browser","nodejs"],fn:Wn},{name:"unlessEq",category:"comparison",compatibility:["browser","nodejs"],fn:Dn},{name:"unlessGt",category:"comparison",compatibility:["browser","nodejs"],fn:Gn},{name:"unlessLt",category:"comparison",compatibility:["browser","nodejs"],fn:vn},{name:"unlessGteq",category:"comparison",compatibility:["browser","nodejs"],fn:Yn},{name:"unlessLteq",category:"comparison",compatibility:["browser","nodejs"],fn:Qn}];import{parseDate as Zn}from"chrono-node";import Vn from"dayjs";var Kn=()=>new Date().getFullYear().toString(),S=(n,e)=>{let r=Zn(n);if(!r)throw new Error(`Unable to parse date: ${n}`);return Vn(r).format(e)},B=[{name:"year",category:"date",compatibility:["browser","nodejs"],fn:Kn},{name:"date",category:"date",compatibility:["browser","nodejs"],fn:S},{name:"moment",category:"date",compatibility:["browser","nodejs"],fn:S}];import k from"fs";import Xn from"path";import ne from"is-glob";import ee from"micromatch";var re=(n,e)=>{if(n==null)return"0 B";let r=typeof n=="number"?n:n.length??0;if(!r)return"0 B";let t=typeof e=="number"?e:2,o=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],s=10**t,i=o.length-1;do{let c=10**(i*3);if(c<=r+1)return`${Math.round(r*s/c)/s} ${o[i]}`}while(--i>=0);return`${r} B`},te=n=>k.readFileSync(n,"utf8"),oe=n=>!!(n&&typeof n=="object"&&"hash"in n),se=(n,e)=>{let r=k.readdirSync(n).map(o=>Xn.join(n,o)),t=oe(e)?void 0:e;if(typeof t=="function")return t(r);if(t instanceof RegExp)return r.filter(o=>t.test(o));if(typeof t=="string"){if(ne(t))return ee(r,t);if(t==="isFile"||t==="isDirectory")return r.filter(o=>{let s=k.statSync(o);return t==="isFile"?s.isFile():s.isDirectory()})}return r},T=[{name:"fileSize",category:"fs",compatibility:["nodejs"],fn:re},{name:"read",category:"fs",compatibility:["nodejs"],fn:te},{name:"readdir",category:"fs",compatibility:["nodejs"],fn:se}];import H from"path";import E from"html-tag";import ie from"striptags";var y=(n={})=>Object.keys(n).map(e=>`${e}="${String(n[e]).replace(/^['"]|["']$/g,"")}"`).join(" "),ae=n=>{let e=y(n?.hash??{});return e.trim()?` ${e}`:""},ce=function(n,e){arguments.length<2&&(e=n,n=[]);let r=l(n??[]),t="";return this&&this.options&&(t=this.options.assets||""),e?.hash?.href&&(r=l(e.hash.href)),r.map(o=>{let s=H.extname(o),i=o;return/(^\/\/)|(:\/\/)/.test(o)||(i=H.posix.join(t,o)),s===".less"?`<link type="text/css" rel="stylesheet/less" href="${i}">`:`<link type="text/css" rel="stylesheet" href="${i}">`}).join(`
|
|
3
|
+
`)},pe=n=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=y(n.hash??{});return`<script${r?` ${r}`:""}></script>`}return typeof n=="string"?`<script src="${n}"></script>`:l(n).map(r=>H.extname(r)===".coffee"?E("script",{type:"text/coffeescript",src:r}):E("script",{src:r})).join(`
|
|
4
|
+
`)},me=n=>typeof n!="string"?"":ie(n).trim(),le=(n,e)=>{let r=y(e.hash??{}),t=n.map(s=>typeof s=="string"?s:e.fn(s));return`${r?`<ul ${r}>`:"<ul>"}${t.map(s=>`<li>${s}</li>`).join(`
|
|
5
|
+
`)}</ul>`},ye=(n,e)=>{let r=y(e.hash??{}),t=n.map(s=>typeof s=="string"?s:e.fn(s));return`${r?`<ol ${r}>`:"<ol>"}${t.map(s=>`<li>${s}</li>`).join(`
|
|
6
|
+
`)}</ol>`},ge=n=>{let e="",r="",t=n.full||!1,o={alt:n.alt,src:n.thumbnail,width:n.size.width,height:n.size.height},s={id:`image-${n.id}`},i={href:t,rel:"thumbnail"};return n.classes&&(n.classes.image&&(o.class=n.classes.image.join(" ")),n.classes.figure&&(s.class=n.classes.figure.join(" ")),n.classes.link&&(i.class=n.classes.link.join(" "))),e+=`<figure ${y(s)}>
|
|
7
|
+
`,r+=`<img ${y(o)}>
|
|
8
|
+
`,t?e+=`<a ${y(i)}>
|
|
9
|
+
${r}</a>
|
|
10
|
+
`:e+=r,n.caption&&(e+=`<figcaption>${n.caption}</figcaption>
|
|
11
|
+
`),e+="</figure>",e},F=[{name:"attr",category:"html",compatibility:["browser","nodejs"],fn:ae},{name:"css",category:"html",compatibility:["nodejs"],fn:ce},{name:"js",category:"html",compatibility:["nodejs"],fn:pe},{name:"sanitize",category:"html",compatibility:["browser","nodejs"],fn:me},{name:"ul",category:"html",compatibility:["browser","nodejs"],fn:le},{name:"ol",category:"html",compatibility:["browser","nodejs"],fn:ye},{name:"thumbnailImage",category:"html",compatibility:["browser","nodejs"],fn:ge}];import fe from"get-value";var ue=function(n,e,r){if(e&&typeof e=="object"&&"hash"in e&&r===void 0&&(r=e,e={}),typeof n!="string")throw new Error('{{i18n}} helper expected "key" to be a string');let t={...this,...e,...r?.hash??{}},o=t.language||t.lang;if(typeof o!="string")throw new TypeError('{{i18n}} helper expected "language" to be a string');let s=t[o];if(typeof s>"u")throw new Error(`{{i18n}} helper cannot find language "${o}"`);let i=fe(s,n);if(typeof i>"u")throw new Error('{{i18n}} helper cannot find property "'+String(n)+'" for language "'+o+'"');return String(i)},_=[{name:"i18n",category:"i18n",compatibility:["browser","nodejs"],fn:ue}];var be=(n,e,r,t)=>{let o=n>1||n===0?r:e;return t?`${n} ${o}`:o},de=n=>{let e=Math.abs(Math.round(Number(n))),r=String(n),t=e%100;if([11,12,13].includes(t))return`${r}th`;switch(e%10){case 1:return`${r}st`;case 2:return`${r}nd`;case 3:return`${r}rd`;default:return`${r}th`}},C=[{name:"inflect",category:"inflection",compatibility:["browser","nodejs"],fn:be},{name:"ordinalize",category:"inflection",compatibility:["browser","nodejs"],fn:de}];import he from"logging-helpers";var{log:we,ok:je,success:ke,info:He,warning:xe,warn:Ne,error:$e,danger:Oe,bold:Ae,_debug:Re,_inspect:Se}=he,M=[{name:"log",category:"logging",compatibility:["nodejs"],fn:we},{name:"ok",category:"logging",compatibility:["nodejs"],fn:je},{name:"success",category:"logging",compatibility:["nodejs"],fn:ke},{name:"info",category:"logging",compatibility:["nodejs"],fn:He},{name:"warning",category:"logging",compatibility:["nodejs"],fn:xe},{name:"warn",category:"logging",compatibility:["nodejs"],fn:Ne},{name:"error",category:"logging",compatibility:["nodejs"],fn:$e},{name:"danger",category:"logging",compatibility:["nodejs"],fn:Oe},{name:"bold",category:"logging",compatibility:["nodejs"],fn:Ae},{name:"_debug",category:"logging",compatibility:["nodejs"],fn:Re},{name:"_inspect",category:"logging",compatibility:["nodejs"],fn:Se}];import z from"micromatch";var L=(n,e,r)=>{let t=typeof e=="string"?e.split(/, */):e;return z(n,t,r)},Be=(n,e,r)=>z.isMatch(n,e,r),Te=(...n)=>(console.log("the {{mm}} helper is depcrecated and will be removed"),console.log("in handlebars-helpers v1.0.0, please use the {{match}}"),console.log("helper instead."),L(...n)),U=[{name:"match",category:"match",compatibility:["browser","nodejs"],fn:L},{name:"isMatch",category:"match",compatibility:["browser","nodejs"],fn:Be},{name:"mm",category:"match",compatibility:["browser","nodejs"],fn:Te}];var h=n=>typeof n=="number"&&!Number.isNaN(n)||typeof n=="string"&&n.trim()!==""&&!Number.isNaN(Number(n)),a=(n,e="expected a number")=>{if(h(n))return Number(n);throw new TypeError(e)},Ee=n=>{let e=a(n);return Math.abs(e)},Fe=(n,e)=>h(n)&&h(e)?Number(n)+Number(e):"",_e=(...n)=>{let e=n.flat().map(r=>Number(r));return I(e)/e.length},Ce=n=>{let e=a(n);return Math.ceil(e)},Me=(n,e)=>{let r=a(n,"expected the first argument to be a number"),t=a(e,"expected the second argument to be a number");return r/t},ze=n=>{let e=a(n);return Math.floor(e)},Le=(n,e)=>{let r=a(n,"expected the first argument to be a number"),t=a(e,"expected the second argument to be a number");return r-t},Ue=(n,e)=>{let r=a(n,"expected the first argument to be a number"),t=a(e,"expected the second argument to be a number");return r%t},P=(n,e)=>{let r=a(n,"expected the first argument to be a number"),t=a(e,"expected the second argument to be a number");return r*t},Pe=(n,e)=>{let r=a(n,"expected the first argument to be a number"),t=a(e,"expected the second argument to be a number");return r+t},Ie=(n,e)=>{let r=a(n,"expected minimum to be a number"),t=a(e,"expected maximum to be a number");return r+Math.floor(Math.random()*(t-r+1))},Je=(n,e)=>n%e,qe=n=>{let e=a(n);return Math.round(e)},We=(n,e)=>{let r=a(n,"expected the first argument to be a number"),t=a(e,"expected the second argument to be a number");return r-t},I=(...n)=>{let e=n.flat(),r=0;for(let t of e)h(t)&&(r+=Number(t));return r},De=(n,e)=>P(n,e),J=[{name:"abs",category:"math",compatibility:["browser","nodejs"],fn:Ee},{name:"add",category:"math",compatibility:["browser","nodejs"],fn:Fe},{name:"avg",category:"math",compatibility:["browser","nodejs"],fn:_e},{name:"ceil",category:"math",compatibility:["browser","nodejs"],fn:Ce},{name:"divide",category:"math",compatibility:["browser","nodejs"],fn:Me},{name:"floor",category:"math",compatibility:["browser","nodejs"],fn:ze},{name:"minus",category:"math",compatibility:["browser","nodejs"],fn:Le},{name:"modulo",category:"math",compatibility:["browser","nodejs"],fn:Ue},{name:"multiply",category:"math",compatibility:["browser","nodejs"],fn:P},{name:"plus",category:"math",compatibility:["browser","nodejs"],fn:Pe},{name:"random",category:"math",compatibility:["browser","nodejs"],fn:Ie},{name:"remainder",category:"math",compatibility:["browser","nodejs"],fn:Je},{name:"round",category:"math",compatibility:["browser","nodejs"],fn:qe},{name:"subtract",category:"math",compatibility:["browser","nodejs"],fn:We},{name:"sum",category:"math",compatibility:["browser","nodejs"],fn:I},{name:"times",category:"math",compatibility:["browser","nodejs"],fn:De}];import q from"fs";import Ge from"path";import ve from"process";import Ye from"ent";import Qe from"handlebars";import{Remarkable as Ze}from"remarkable";var Ve=(n,e={})=>{let r={cwd:ve.cwd(),...e},t=new Ze({breaks:!0,html:!0,langPrefix:"lang-",typographer:!1,xhtmlOut:!1}),o=Ge.resolve(r.cwd,n),s=n;return q.existsSync(o)&&(s=q.readFileSync(o,"utf8")),new Qe.SafeString(Ye.decode(t.render(s)))},W=[{name:"md",category:"markdown",compatibility:["nodejs"],fn:Ve}];import Ke from"get-value";import Xe from"handlebars-helper-create-frame";import nr from"handlebars-utils";import er from"kind-of";var rr=Xe;function tr(n,e,r){return Ke(nr.options(this,e,r),n)}function or(n){return n.fn(this)}var sr=er;function ir(n){return n.hash&&Object.keys(n.hash).length?n.fn(n.hash):n.inverse(this)}var D=[{name:"frame",category:"misc",compatibility:["browser","nodejs"],fn:rr},{name:"option",category:"misc",compatibility:["browser","nodejs"],fn:tr},{name:"noop",category:"misc",compatibility:["browser","nodejs"],fn:or},{name:"typeOf",category:"misc",compatibility:["browser","nodejs"],fn:sr},{name:"withHash",category:"misc",compatibility:["browser","nodejs"],fn:ir}];var u=n=>typeof n=="number"&&!Number.isNaN(n),ar=(n,e)=>{if(n==null)return"0 B";let r;if(typeof n=="string"){if(r=n.length,!r)return"0 B"}else if(u(n))r=Number(n);else if(typeof n.length=="number"){if(r=n.length,!r)return"0 B"}else return"0 B";let t=typeof e=="number"&&!Number.isNaN(e)?e:2,o=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],s=10**t;for(let i=o.length-1;i>=0;i--){let c=10**(i*3);if(c<=r+1)return`${Math.round(r*s/c)/s} ${o[i]}`}return`${r}`},cr=n=>n.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"),pr=n=>{let e=n.toString();return`(${e.substr(0,3)}) ${e.substr(3,3)}-${e.substr(6,4)}`},mr=(n,e)=>{let r=u(n)?Number(n):0,o=10**(typeof e=="number"&&!Number.isNaN(e)?e:2),s=["k","m","b","t","q"];for(let i=s.length-1;i>=0;i--){let c=10**((i+1)*3);if(c<=r+1)return`${Math.round(r*o/c)/o}${s[i]}`}return`${r}`},lr=(n,e)=>{let r=u(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:0;return Number(r).toExponential(t)},yr=(n,e)=>{let r=u(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:0;return Number(r).toFixed(t)},gr=n=>parseFloat(String(n)),fr=n=>parseInt(String(n),10),ur=(n,e)=>{let r=u(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:1;return Number(r).toPrecision(t)},G=[{name:"bytes",category:"number",compatibility:["browser","nodejs"],fn:ar},{name:"addCommas",category:"number",compatibility:["browser","nodejs"],fn:cr},{name:"phoneNumber",category:"number",compatibility:["browser","nodejs"],fn:pr},{name:"toAbbr",category:"number",compatibility:["browser","nodejs"],fn:mr},{name:"toExponential",category:"number",compatibility:["browser","nodejs"],fn:lr},{name:"toFixed",category:"number",compatibility:["browser","nodejs"],fn:yr},{name:"toFloat",category:"number",compatibility:["browser","nodejs"],fn:gr},{name:"toInt",category:"number",compatibility:["browser","nodejs"],fn:fr},{name:"toPrecision",category:"number",compatibility:["browser","nodejs"],fn:ur}];import v from"get-object";import br from"get-value";var w=n=>!!(n&&typeof n=="object"&&"hash"in n),Y=(n,e)=>({...n?.data||{},...e}),dr=(...n)=>{let e=[...n];if(e.length&&w(e[e.length-1])){let t=e.pop();e.push(t.hash)}let r={};for(let t of e)t&&typeof t=="object"&&!Array.isArray(t)&&Object.assign(r,t);return r},hr=(n,e)=>{if(!w(e))return e?.inverse?.(n)??"";let r=Y(e,e.hash||{}),t="";for(let o in n)r.key=o,t+=e.fn(n[o],{data:r});return t},wr=(n,e)=>{if(!w(e))return e?.inverse?.(n)??"";let r=Y(e,e.hash||{}),t="";for(let o in n)Object.hasOwn(n,o)&&(r.key=o,t+=e.fn(n[o],{data:r}));return t},jr=(...n)=>{let e=[];for(let r of n)(typeof r=="string"||typeof r=="number")&&e.push(r);return e.join(".")},kr=(n,e,r)=>{let t=br(e,n);return r&&typeof r.fn=="function"?t?r.fn(t):r.inverse?.(e):t},Hr=(n,e)=>v(e,n),xr=(n,e)=>Object.hasOwn(n,e),Nr=n=>!!n&&typeof n=="object"&&!Array.isArray(n),Q=n=>JSON.parse(n),Z=(n,e)=>JSON.stringify(n,null,typeof e=="number"?e:0),$r=(n,...e)=>{let r=[n,...e];if(r.length&&w(r[r.length-1])){let t=r.pop();r.push(t.hash)}return Object.assign(...r)},Or=Q,Ar=Z,Rr=(n,e,r)=>{let t=l(n),o={};for(let s of t)o=Object.assign({},o,v(e,s));return r&&typeof r.fn=="function"?Object.keys(o).length?r.fn(o):r.inverse?.(e):o},V=[{name:"extend",category:"object",compatibility:["browser","nodejs"],fn:dr},{name:"forIn",category:"object",compatibility:["browser","nodejs"],fn:hr},{name:"forOwn",category:"object",compatibility:["browser","nodejs"],fn:wr},{name:"toPath",category:"object",compatibility:["browser","nodejs"],fn:jr},{name:"get",category:"object",compatibility:["browser","nodejs"],fn:kr},{name:"getObject",category:"object",compatibility:["browser","nodejs"],fn:Hr},{name:"hasOwn",category:"object",compatibility:["browser","nodejs"],fn:xr},{name:"isObject",category:"object",compatibility:["browser","nodejs"],fn:Nr},{name:"JSONparse",category:"object",compatibility:["browser","nodejs"],fn:Q},{name:"JSONstringify",category:"object",compatibility:["browser","nodejs"],fn:Z},{name:"merge",category:"object",compatibility:["browser","nodejs"],fn:$r},{name:"parseJSON",category:"object",compatibility:["browser","nodejs"],fn:Or},{name:"pick",category:"object",compatibility:["browser","nodejs"],fn:Rr},{name:"stringify",category:"object",compatibility:["browser","nodejs"],fn:Ar}];import m from"path";var Sr=(n,e,r)=>{let t=Object.prototype.toString.call(r).slice(8,-1).toLowerCase();return`Expected ${n} to be of type ${e}, but got ${t}`},p=(n,e)=>{if(typeof e!="string")throw new TypeError(Sr(n,"string",e));return e},Br=function(n,e){let r=p("filepath",n),t=e?.data?.root?.cwd??this?.cwd??process.cwd();return m.resolve(t,r)},Tr=n=>{let e=p("filepath",n);return m.dirname(e)},Er=(n,e)=>{let r=p("first path",n),t=p("second path",e);return m.relative(m.dirname(r),t)},Fr=n=>{let e=p("filepath",n);return m.basename(e)},_r=n=>{let e=p("filepath",n);return m.basename(e,m.extname(e))},Cr=n=>{let e=p("filepath",n);return m.extname(e)},Mr=function(n,...e){let r,t=e[e.length-1];typeof t=="object"&&t&&"data"in t&&(r=e.pop());let s=[r?.data?.root?.cwd??this?.cwd??process.cwd(),p("filepath",n),...e.map((i,c)=>p(`path${c}`,i))];return m.resolve(...s)},zr=(n,e,r)=>{let t=p("filepath",n),o=Number(e),s=Number(r);return t.split(/[\\/]+/).slice(o,s).join("/")},K=[{name:"absolute",category:"path",compatibility:["nodejs"],fn:Br},{name:"dirname",category:"path",compatibility:["nodejs"],fn:Tr},{name:"relative",category:"path",compatibility:["nodejs"],fn:Er},{name:"basename",category:"path",compatibility:["nodejs"],fn:Fr},{name:"stem",category:"path",compatibility:["nodejs"],fn:_r},{name:"extname",category:"path",compatibility:["nodejs"],fn:Cr},{name:"resolve",category:"path",compatibility:["nodejs"],fn:Mr},{name:"segments",category:"path",compatibility:["nodejs"],fn:zr}];import Lr from"handlebars-utils";var Ur=(n,e,r)=>{let t=Lr.options({},e,r);return new RegExp(n,t.flags)},Pr=(n,e)=>{if(typeof n!="string")return!1;if(!(e instanceof RegExp))throw new TypeError("expected a regular expression");return e.test(n)},X=[{name:"toRegex",category:"regex",compatibility:["browser","nodejs"],fn:Ur},{name:"test",category:"regex",compatibility:["browser","nodejs"],fn:Pr}];var nn=n=>n.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g,""),g=(n,e)=>n.length===1?n.toLowerCase():nn(n).toLowerCase().replace(/[-_.\W\s]+(\w|$)/g,(t,o)=>e(o)),Ir=(n,e)=>typeof n=="string"&&typeof e=="string"?n+e:n,Jr=n=>typeof n=="string"?g(n,e=>e.toUpperCase()):"",en=n=>typeof n!="string"||n.length===0?"":n.charAt(0).toUpperCase()+n.slice(1),qr=n=>typeof n!="string"?"":n.replace(/\w\S*/g,e=>en(e)),Wr=(n,e)=>{if(typeof n!="string")return"";let r="";for(let t=0;t<e;t++)r+=" ";return r+n+r},Dr=n=>typeof n=="string"?nn(n):"",Gr=n=>typeof n=="string"?g(n,e=>`-${e}`):"",vr=n=>typeof n=="string"?g(n,e=>`.${e}`):"",rn=(n,e,r)=>typeof n=="string"?(typeof r!="string"&&(r=""),n.length>e?n.slice(0,e-r.length)+r:n):"",Yr=(n,e)=>typeof n=="string"?n.length<=e?n:`${rn(n,e)}\u2026`:"",Qr=n=>typeof n=="string"?n.split(" ").join("-"):"",Zr=n=>typeof n=="string",tn=n=>typeof n=="object"&&n!==null&&"fn"in n&&typeof n.fn=="function"?String(n.fn()).toLowerCase():typeof n!="string"?"":n.toLowerCase(),Vr=(...n)=>tn(...n),Kr=(n,e)=>{if(typeof n!="string")return"";let r=e.length,t=n.indexOf(e,0),o=0;for(;t>-1;)o++,t=n.indexOf(e,t+r);return o},Xr=n=>{if(typeof n!="string")return"";let e=g(n,r=>r.toUpperCase());return e.charAt(0).toUpperCase()+e.slice(1)},nt=n=>typeof n=="string"?g(n,e=>`/${e}`):"",et=(n,e)=>typeof n!="string"?"":(typeof e!="string"&&(e=" "),n.split(e).join("+")),rt=(n,e)=>typeof n=="string"&&typeof e=="string"?e+n:n,tt=(n,e)=>typeof n!="string"?"":typeof e!="string"?n:n.split(e).join(""),ot=(n,e)=>typeof n!="string"?"":typeof e!="string"?n:n.replace(e,""),st=(n,e,r)=>typeof n!="string"?"":typeof e!="string"?n:(typeof r!="string"&&(r=""),n.split(e).join(r)),it=(n,e,r)=>typeof n!="string"?"":typeof e!="string"?n:(typeof r!="string"&&(r=""),n.replace(e,r)),at=n=>typeof n=="string"?n.split("").reverse().join(""):"",ct=n=>typeof n!="string"?"":n.replace(/((?:\S[^.?!]*)[.?!]*)/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()),pt=n=>typeof n=="string"?g(n,e=>`_${e}`):"",mt=n=>typeof n=="string"?n.trim():"",lt=n=>typeof n=="string"?n.replace(/^\s+/,""):"",yt=n=>typeof n=="string"?n.replace(/\s+$/,""):"",gt=(n,e,r)=>{if(typeof n=="string"&&typeof e=="number"&&Number.isFinite(e)){typeof r!="string"&&(r="...");let t=Math.trunc(e),o=n.split(" ");return t<o.length&&(o=o.slice(0,t)),o.join(" ").trim()+r}return""},ft=gt,on=n=>typeof n=="object"&&n!==null&&"fn"in n&&typeof n.fn=="function"?String(n.fn()).toUpperCase():typeof n!="string"?"":n.toUpperCase(),ut=(...n)=>on(...n),sn=[{name:"append",category:"string",compatibility:["browser","nodejs"],fn:Ir},{name:"camelcase",category:"string",compatibility:["browser","nodejs"],fn:Jr},{name:"capitalize",category:"string",compatibility:["browser","nodejs"],fn:en},{name:"capitalizeAll",category:"string",compatibility:["browser","nodejs"],fn:qr},{name:"center",category:"string",compatibility:["browser","nodejs"],fn:Wr},{name:"chop",category:"string",compatibility:["browser","nodejs"],fn:Dr},{name:"dashcase",category:"string",compatibility:["browser","nodejs"],fn:Gr},{name:"dotcase",category:"string",compatibility:["browser","nodejs"],fn:vr},{name:"ellipsis",category:"string",compatibility:["browser","nodejs"],fn:Yr},{name:"hyphenate",category:"string",compatibility:["browser","nodejs"],fn:Qr},{name:"isString",category:"string",compatibility:["browser","nodejs"],fn:Zr},{name:"lowercase",category:"string",compatibility:["browser","nodejs"],fn:tn},{name:"downcase",category:"string",compatibility:["browser","nodejs"],fn:Vr},{name:"occurrences",category:"string",compatibility:["browser","nodejs"],fn:Kr},{name:"pascalcase",category:"string",compatibility:["browser","nodejs"],fn:Xr},{name:"pathcase",category:"string",compatibility:["browser","nodejs"],fn:nt},{name:"plusify",category:"string",compatibility:["browser","nodejs"],fn:et},{name:"prepend",category:"string",compatibility:["browser","nodejs"],fn:rt},{name:"remove",category:"string",compatibility:["browser","nodejs"],fn:tt},{name:"removeFirst",category:"string",compatibility:["browser","nodejs"],fn:ot},{name:"replace",category:"string",compatibility:["browser","nodejs"],fn:st},{name:"replaceFirst",category:"string",compatibility:["browser","nodejs"],fn:it},{name:"reverse",category:"string",compatibility:["browser","nodejs"],fn:at},{name:"sentence",category:"string",compatibility:["browser","nodejs"],fn:ct},{name:"snakecase",category:"string",compatibility:["browser","nodejs"],fn:pt},{name:"trim",category:"string",compatibility:["browser","nodejs"],fn:mt},{name:"trimLeft",category:"string",compatibility:["browser","nodejs"],fn:lt},{name:"trimRight",category:"string",compatibility:["browser","nodejs"],fn:yt},{name:"truncate",category:"string",compatibility:["browser","nodejs"],fn:rn},{name:"truncateWords",category:"string",compatibility:["browser","nodejs"],fn:ft},{name:"uppercase",category:"string",compatibility:["browser","nodejs"],fn:on},{name:"upcase",category:"string",compatibility:["browser","nodejs"],fn:ut}];import{escape as bt}from"querystring";import{format as dt,parse as an,resolve as ht}from"url";var b=["browser","nodejs"],cn=n=>{if(typeof n=="string")return encodeURIComponent(n)},wt=n=>{if(typeof n=="string")return bt(n)},pn=n=>{if(typeof n=="string")return decodeURIComponent(n)};function jt(...n){return cn.apply(this,n)}function kt(...n){return pn.apply(this,n)}var Ht=(n,e)=>ht(String(n),String(e)),xt=n=>an(String(n)),Nt=n=>{if(typeof n=="string")return n.split("?")[0]},$t=n=>{if(typeof n=="string"){let e=an(n);return e.protocol="",dt(e)}},mn=[{name:"encodeURI",category:"url",compatibility:b,fn:cn},{name:"escape",category:"url",compatibility:["nodejs"],fn:wt},{name:"decodeURI",category:"url",compatibility:b,fn:pn},{name:"url_encode",category:"url",compatibility:b,fn:jt},{name:"url_decode",category:"url",compatibility:b,fn:kt},{name:"urlResolve",category:"url",compatibility:["nodejs"],fn:Ht},{name:"urlParse",category:"url",compatibility:["nodejs"],fn:xt},{name:"stripQuerystring",category:"url",compatibility:b,fn:Nt},{name:"stripProtocol",category:"url",compatibility:["nodejs"],fn:$t}];var f=class{_helpers=[];constructor(){this.init()}get helpers(){return this._helpers}init(){this.registerHelpers(x),this.registerHelpers(O),this.registerHelpers(B),this.registerHelpers(T),this.registerHelpers($),this.registerHelpers(W),this.registerHelpers(F),this.registerHelpers(R),this.registerHelpers(_),this.registerHelpers(C),this.registerHelpers(M),this.registerHelpers(U),this.registerHelpers(J),this.registerHelpers(D),this.registerHelpers(G),this.registerHelpers(K),this.registerHelpers(X),this.registerHelpers(sn),this.registerHelpers(mn),this.registerHelpers(V)}register(e){return this.has(e.name)||this._helpers.push(e),!1}registerHelpers(e){for(let r of e)this.register(r)}has(e){return this._helpers.some(r=>r.name===e)}filter(e){let r=this._helpers;return e.names&&(r=r.filter(t=>e.names?.includes(t.name))),e.categories&&(r=r.filter(t=>e.categories?.includes(t.category))),e.compatibility&&(r=r.filter(t=>t.compatibility?.some(o=>e.compatibility?.includes(o)))),r}load(e,r){let t=this._helpers;r&&(t=this.filter(r));for(let o of t)e.registerHelper(o.name,o.fn)}swap(e){for(let r of this._helpers)e.unregisterHelper(r.name),e.registerHelper(r.name,r.fn)}};var Vo=j,Ko=j.create();function Xo(n){new f().load(n.handlebars??n.hbs)}async function ns(){let n=new f,e=j.create();return n.load(e),process.env.NODE_ENV==="development"&&console.warn("createHandlebars will be deprecated in future versions, use `fumanchu` instead."),e}function es(n){let e=new f,r=j.create();return n?.handlebars&&(r=n.handlebars),e.load(r),r}export{Vo as Handlebars,f as HelperRegistry,ns as createHandlebars,es as fumanchu,Ko as handlebars,Xo as helpers};
|