@jaredwray/fumanchu 4.6.0 → 4.6.1
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 +7 -0
- package/dist/index.cjs +2854 -3150
- package/dist/index.d.cts +65 -64
- package/dist/index.d.mts +106 -0
- package/dist/index.mjs +2868 -0
- package/package.json +34 -20
- package/dist/index.d.ts +0 -105
- package/dist/index.js +0 -3170
package/dist/index.d.cts
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
import { CacheableMemory, CacheableMemoryOptions } from
|
|
2
|
-
|
|
3
|
-
import HandlebarsLib from 'handlebars';
|
|
1
|
+
import { CacheableMemory, CacheableMemoryOptions } from "@cacheable/memory";
|
|
2
|
+
import HandlebarsLib from "handlebars";
|
|
4
3
|
|
|
4
|
+
//#region src/helper-registry.d.ts
|
|
5
5
|
type Helper = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
name: string;
|
|
7
|
+
category: string;
|
|
8
|
+
compatibility?: string[];
|
|
9
|
+
fn: ((...arguments_: any[]) => string) | ((...arguments_: any[]) => number) | ((...arguments_: any[]) => boolean) | ((...arguments_: any[]) => unknown) | ((...arguments_: any[]) => number | string) | ((...arguments_: any[]) => HandlebarsLib.SafeString);
|
|
10
10
|
};
|
|
11
11
|
type HelperFilter = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
names?: string[];
|
|
13
|
+
categories?: string[];
|
|
14
|
+
compatibility?: string[];
|
|
15
15
|
};
|
|
16
16
|
declare class HelperRegistry {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
17
|
+
private readonly _helpers;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Get all registered helpers.
|
|
21
|
+
* @returns {Helper[]} The array of registered helpers.
|
|
22
|
+
*/
|
|
23
|
+
get helpers(): Helper[];
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
|
|
26
|
+
*/
|
|
27
|
+
init(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Register a helper.
|
|
30
|
+
* @param {Helper} helper The helper to register.
|
|
31
|
+
* @returns True if the helper was registered, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
register(helper: Helper): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Register multiple helpers.
|
|
36
|
+
* @param {Helper[]} helpers The array of helpers to register.
|
|
37
|
+
*/
|
|
38
|
+
registerHelpers(helpers: Helper[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a helper is registered.
|
|
41
|
+
* @param name The name of the helper.
|
|
42
|
+
* @returns True if the helper is registered, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
has(name: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Filter helpers by the given criteria.
|
|
47
|
+
* @param filter The filter criteria.
|
|
48
|
+
* @returns The filtered helpers.
|
|
49
|
+
*/
|
|
50
|
+
filter(filter: HelperFilter): Helper[];
|
|
51
|
+
/**
|
|
52
|
+
* Load Handlebars helpers.
|
|
53
|
+
* @param {Handlebars} handlebars The Handlebars instance.
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*/
|
|
56
|
+
load(handlebars: any, filters?: HelperFilter): void;
|
|
57
|
+
/**
|
|
58
|
+
* Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
|
|
59
|
+
* @param handlebars The Handlebars instance.
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
swap(handlebars: any): void;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/index.d.ts
|
|
65
66
|
/**
|
|
66
67
|
* Handlebars library not initiated with helpers
|
|
67
68
|
* @type {Handlebars}
|
|
@@ -76,8 +77,8 @@ declare const handlebars: typeof HandlebarsLib;
|
|
|
76
77
|
* Fumanchu Handlebars helpers
|
|
77
78
|
*/
|
|
78
79
|
type HelpersOptions = {
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
handlebars?: typeof HandlebarsLib;
|
|
81
|
+
hbs?: typeof HandlebarsLib;
|
|
81
82
|
};
|
|
82
83
|
/**
|
|
83
84
|
* Register Handlebars helpers
|
|
@@ -91,9 +92,9 @@ declare function helpers(options: HelpersOptions): void;
|
|
|
91
92
|
*/
|
|
92
93
|
declare function createHandlebars(): Promise<typeof HandlebarsLib>;
|
|
93
94
|
type FumanchuOptions = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
handlebars?: typeof HandlebarsLib;
|
|
96
|
+
filter?: HelperFilter;
|
|
97
|
+
caching?: boolean | CacheableMemory | CacheableMemoryOptions;
|
|
97
98
|
};
|
|
98
99
|
/**
|
|
99
100
|
* Will return a Handlebars instance with Fumanchu helpers (experimental)
|
|
@@ -101,5 +102,5 @@ type FumanchuOptions = {
|
|
|
101
102
|
* @returns {Handlebars} Handlebars instance with helpers
|
|
102
103
|
*/
|
|
103
104
|
declare function fumanchu(options?: FumanchuOptions): typeof HandlebarsLib;
|
|
104
|
-
|
|
105
|
-
export { type FumanchuOptions, Handlebars, type HelperFilter, HelperRegistry,
|
|
105
|
+
//#endregion
|
|
106
|
+
export { CacheableMemory, type CacheableMemoryOptions, FumanchuOptions, Handlebars, type HelperFilter, HelperRegistry, HelpersOptions, createHandlebars, fumanchu, handlebars, helpers };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { CacheableMemory, CacheableMemoryOptions } from "@cacheable/memory";
|
|
2
|
+
import HandlebarsLib from "handlebars";
|
|
3
|
+
|
|
4
|
+
//#region src/helper-registry.d.ts
|
|
5
|
+
type Helper = {
|
|
6
|
+
name: string;
|
|
7
|
+
category: string;
|
|
8
|
+
compatibility?: string[];
|
|
9
|
+
fn: ((...arguments_: any[]) => string) | ((...arguments_: any[]) => number) | ((...arguments_: any[]) => boolean) | ((...arguments_: any[]) => unknown) | ((...arguments_: any[]) => number | string) | ((...arguments_: any[]) => HandlebarsLib.SafeString);
|
|
10
|
+
};
|
|
11
|
+
type HelperFilter = {
|
|
12
|
+
names?: string[];
|
|
13
|
+
categories?: string[];
|
|
14
|
+
compatibility?: string[];
|
|
15
|
+
};
|
|
16
|
+
declare class HelperRegistry {
|
|
17
|
+
private readonly _helpers;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Get all registered helpers.
|
|
21
|
+
* @returns {Helper[]} The array of registered helpers.
|
|
22
|
+
*/
|
|
23
|
+
get helpers(): Helper[];
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
|
|
26
|
+
*/
|
|
27
|
+
init(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Register a helper.
|
|
30
|
+
* @param {Helper} helper The helper to register.
|
|
31
|
+
* @returns True if the helper was registered, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
register(helper: Helper): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Register multiple helpers.
|
|
36
|
+
* @param {Helper[]} helpers The array of helpers to register.
|
|
37
|
+
*/
|
|
38
|
+
registerHelpers(helpers: Helper[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a helper is registered.
|
|
41
|
+
* @param name The name of the helper.
|
|
42
|
+
* @returns True if the helper is registered, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
has(name: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Filter helpers by the given criteria.
|
|
47
|
+
* @param filter The filter criteria.
|
|
48
|
+
* @returns The filtered helpers.
|
|
49
|
+
*/
|
|
50
|
+
filter(filter: HelperFilter): Helper[];
|
|
51
|
+
/**
|
|
52
|
+
* Load Handlebars helpers.
|
|
53
|
+
* @param {Handlebars} handlebars The Handlebars instance.
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*/
|
|
56
|
+
load(handlebars: any, filters?: HelperFilter): void;
|
|
57
|
+
/**
|
|
58
|
+
* Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
|
|
59
|
+
* @param handlebars The Handlebars instance.
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
swap(handlebars: any): void;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/index.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* Handlebars library not initiated with helpers
|
|
68
|
+
* @type {Handlebars}
|
|
69
|
+
*/
|
|
70
|
+
declare const Handlebars: typeof HandlebarsLib;
|
|
71
|
+
/**
|
|
72
|
+
* Fumanchu Handlebars instance not initiated with helpers
|
|
73
|
+
* @type {Handlebars}
|
|
74
|
+
*/
|
|
75
|
+
declare const handlebars: typeof HandlebarsLib;
|
|
76
|
+
/**
|
|
77
|
+
* Fumanchu Handlebars helpers
|
|
78
|
+
*/
|
|
79
|
+
type HelpersOptions = {
|
|
80
|
+
handlebars?: typeof HandlebarsLib;
|
|
81
|
+
hbs?: typeof HandlebarsLib;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Register Handlebars helpers
|
|
85
|
+
* @param {HelpersOptions} options - Options for Fumanchu helpers
|
|
86
|
+
*/
|
|
87
|
+
declare function helpers(options: HelpersOptions): void;
|
|
88
|
+
/**
|
|
89
|
+
* Create a new Handlebars instance with Fumanchu helpers
|
|
90
|
+
* @returns {Promise<Handlebars>}
|
|
91
|
+
* @deprecated Will be deprecated in future versions, use `fumanchu()` instead.
|
|
92
|
+
*/
|
|
93
|
+
declare function createHandlebars(): Promise<typeof HandlebarsLib>;
|
|
94
|
+
type FumanchuOptions = {
|
|
95
|
+
handlebars?: typeof HandlebarsLib;
|
|
96
|
+
filter?: HelperFilter;
|
|
97
|
+
caching?: boolean | CacheableMemory | CacheableMemoryOptions;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Will return a Handlebars instance with Fumanchu helpers (experimental)
|
|
101
|
+
* @param {FumanchuOptions} [options] - Options for Fumanchu
|
|
102
|
+
* @returns {Handlebars} Handlebars instance with helpers
|
|
103
|
+
*/
|
|
104
|
+
declare function fumanchu(options?: FumanchuOptions): typeof HandlebarsLib;
|
|
105
|
+
//#endregion
|
|
106
|
+
export { CacheableMemory, type CacheableMemoryOptions, FumanchuOptions, Handlebars, type HelperFilter, HelperRegistry, HelpersOptions, createHandlebars, fumanchu, handlebars, helpers };
|