@jaredwray/fumanchu 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -26
- package/dist/index.browser.cjs +3 -0
- package/dist/index.browser.d.cts +109 -0
- package/dist/index.browser.d.mts +109 -0
- package/dist/index.browser.mjs +3 -0
- package/dist/index.node.cjs +3064 -0
- package/dist/index.node.d.cts +107 -0
- package/dist/index.node.d.mts +107 -0
- package/dist/index.node.mjs +3023 -0
- package/package.json +60 -34
- package/dist/index.cjs +0 -3209
- package/dist/index.d.cts +0 -105
- package/dist/index.d.ts +0 -105
- package/dist/index.js +0 -3170
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { CacheableMemory, CacheableMemoryOptions } from "@cacheable/memory";
|
|
2
|
+
import HandlebarsLib from "handlebars";
|
|
3
|
+
|
|
4
|
+
//#region src/helper-registry-base.d.ts
|
|
5
|
+
type Helper = {
|
|
6
|
+
name: string;
|
|
7
|
+
category: string;
|
|
8
|
+
compatibility?: string[];
|
|
9
|
+
fn: (...arguments_: any[]) => any;
|
|
10
|
+
};
|
|
11
|
+
type HelperFilter = {
|
|
12
|
+
names?: string[];
|
|
13
|
+
categories?: string[];
|
|
14
|
+
compatibility?: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Base class for helper registries. Holds all state-management logic and
|
|
18
|
+
* leaves `init()` empty so environment-specific subclasses decide which
|
|
19
|
+
* helper sets to register. This lets the browser registry avoid importing
|
|
20
|
+
* any Node-only helper files.
|
|
21
|
+
*/
|
|
22
|
+
declare class HelperRegistryBase {
|
|
23
|
+
protected readonly _helpers: Helper[];
|
|
24
|
+
constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Get all registered helpers.
|
|
27
|
+
*/
|
|
28
|
+
get helpers(): Helper[];
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the helper registry. Overridden by subclasses.
|
|
31
|
+
*/
|
|
32
|
+
init(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Register a helper. Returns true if the helper was added, false if a
|
|
35
|
+
* helper with the same name was already present.
|
|
36
|
+
*/
|
|
37
|
+
register(helper: Helper): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Register multiple helpers.
|
|
40
|
+
*/
|
|
41
|
+
registerHelpers(helpers: Helper[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a helper is registered.
|
|
44
|
+
*/
|
|
45
|
+
has(name: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Filter helpers by the given criteria.
|
|
48
|
+
*/
|
|
49
|
+
filter(filter: HelperFilter): Helper[];
|
|
50
|
+
/**
|
|
51
|
+
* Load Handlebars helpers.
|
|
52
|
+
*/
|
|
53
|
+
load(handlebars: any, filters?: HelperFilter): void;
|
|
54
|
+
/**
|
|
55
|
+
* Swap Handlebars helpers. This is used when you want to swap out legacy
|
|
56
|
+
* helpers for fumanchu helpers.
|
|
57
|
+
*/
|
|
58
|
+
swap(handlebars: any): void;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/helper-registry.d.ts
|
|
62
|
+
declare class HelperRegistry extends HelperRegistryBase {
|
|
63
|
+
init(): void;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/index.node.d.ts
|
|
67
|
+
/**
|
|
68
|
+
* Handlebars library not initiated with helpers
|
|
69
|
+
* @type {Handlebars}
|
|
70
|
+
*/
|
|
71
|
+
declare const Handlebars: typeof HandlebarsLib;
|
|
72
|
+
/**
|
|
73
|
+
* Fumanchu Handlebars instance not initiated with helpers
|
|
74
|
+
* @type {Handlebars}
|
|
75
|
+
*/
|
|
76
|
+
declare const handlebars: typeof HandlebarsLib;
|
|
77
|
+
/**
|
|
78
|
+
* Fumanchu Handlebars helpers
|
|
79
|
+
*/
|
|
80
|
+
type HelpersOptions = {
|
|
81
|
+
handlebars?: typeof HandlebarsLib;
|
|
82
|
+
hbs?: typeof HandlebarsLib;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Register Handlebars helpers
|
|
86
|
+
* @param {HelpersOptions} options - Options for Fumanchu helpers
|
|
87
|
+
*/
|
|
88
|
+
declare function helpers(options: HelpersOptions): void;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new Handlebars instance with Fumanchu helpers
|
|
91
|
+
* @returns {Promise<Handlebars>}
|
|
92
|
+
* @deprecated Will be deprecated in future versions, use `fumanchu()` instead.
|
|
93
|
+
*/
|
|
94
|
+
declare function createHandlebars(): Promise<typeof HandlebarsLib>;
|
|
95
|
+
type FumanchuOptions = {
|
|
96
|
+
handlebars?: typeof HandlebarsLib;
|
|
97
|
+
filter?: HelperFilter;
|
|
98
|
+
caching?: boolean | CacheableMemory | CacheableMemoryOptions;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Will return a Handlebars instance with Fumanchu helpers (experimental)
|
|
102
|
+
* @param {FumanchuOptions} [options] - Options for Fumanchu
|
|
103
|
+
* @returns {Handlebars} Handlebars instance with helpers
|
|
104
|
+
*/
|
|
105
|
+
declare function fumanchu(options?: FumanchuOptions): typeof HandlebarsLib;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { CacheableMemory, type CacheableMemoryOptions, FumanchuOptions, Handlebars, type HelperFilter, HelperRegistry, HelpersOptions, createHandlebars, fumanchu, handlebars, helpers };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { CacheableMemory, CacheableMemoryOptions } from "@cacheable/memory";
|
|
2
|
+
import HandlebarsLib from "handlebars";
|
|
3
|
+
|
|
4
|
+
//#region src/helper-registry-base.d.ts
|
|
5
|
+
type Helper = {
|
|
6
|
+
name: string;
|
|
7
|
+
category: string;
|
|
8
|
+
compatibility?: string[];
|
|
9
|
+
fn: (...arguments_: any[]) => any;
|
|
10
|
+
};
|
|
11
|
+
type HelperFilter = {
|
|
12
|
+
names?: string[];
|
|
13
|
+
categories?: string[];
|
|
14
|
+
compatibility?: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Base class for helper registries. Holds all state-management logic and
|
|
18
|
+
* leaves `init()` empty so environment-specific subclasses decide which
|
|
19
|
+
* helper sets to register. This lets the browser registry avoid importing
|
|
20
|
+
* any Node-only helper files.
|
|
21
|
+
*/
|
|
22
|
+
declare class HelperRegistryBase {
|
|
23
|
+
protected readonly _helpers: Helper[];
|
|
24
|
+
constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Get all registered helpers.
|
|
27
|
+
*/
|
|
28
|
+
get helpers(): Helper[];
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the helper registry. Overridden by subclasses.
|
|
31
|
+
*/
|
|
32
|
+
init(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Register a helper. Returns true if the helper was added, false if a
|
|
35
|
+
* helper with the same name was already present.
|
|
36
|
+
*/
|
|
37
|
+
register(helper: Helper): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Register multiple helpers.
|
|
40
|
+
*/
|
|
41
|
+
registerHelpers(helpers: Helper[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a helper is registered.
|
|
44
|
+
*/
|
|
45
|
+
has(name: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Filter helpers by the given criteria.
|
|
48
|
+
*/
|
|
49
|
+
filter(filter: HelperFilter): Helper[];
|
|
50
|
+
/**
|
|
51
|
+
* Load Handlebars helpers.
|
|
52
|
+
*/
|
|
53
|
+
load(handlebars: any, filters?: HelperFilter): void;
|
|
54
|
+
/**
|
|
55
|
+
* Swap Handlebars helpers. This is used when you want to swap out legacy
|
|
56
|
+
* helpers for fumanchu helpers.
|
|
57
|
+
*/
|
|
58
|
+
swap(handlebars: any): void;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/helper-registry.d.ts
|
|
62
|
+
declare class HelperRegistry extends HelperRegistryBase {
|
|
63
|
+
init(): void;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/index.node.d.ts
|
|
67
|
+
/**
|
|
68
|
+
* Handlebars library not initiated with helpers
|
|
69
|
+
* @type {Handlebars}
|
|
70
|
+
*/
|
|
71
|
+
declare const Handlebars: typeof HandlebarsLib;
|
|
72
|
+
/**
|
|
73
|
+
* Fumanchu Handlebars instance not initiated with helpers
|
|
74
|
+
* @type {Handlebars}
|
|
75
|
+
*/
|
|
76
|
+
declare const handlebars: typeof HandlebarsLib;
|
|
77
|
+
/**
|
|
78
|
+
* Fumanchu Handlebars helpers
|
|
79
|
+
*/
|
|
80
|
+
type HelpersOptions = {
|
|
81
|
+
handlebars?: typeof HandlebarsLib;
|
|
82
|
+
hbs?: typeof HandlebarsLib;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Register Handlebars helpers
|
|
86
|
+
* @param {HelpersOptions} options - Options for Fumanchu helpers
|
|
87
|
+
*/
|
|
88
|
+
declare function helpers(options: HelpersOptions): void;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new Handlebars instance with Fumanchu helpers
|
|
91
|
+
* @returns {Promise<Handlebars>}
|
|
92
|
+
* @deprecated Will be deprecated in future versions, use `fumanchu()` instead.
|
|
93
|
+
*/
|
|
94
|
+
declare function createHandlebars(): Promise<typeof HandlebarsLib>;
|
|
95
|
+
type FumanchuOptions = {
|
|
96
|
+
handlebars?: typeof HandlebarsLib;
|
|
97
|
+
filter?: HelperFilter;
|
|
98
|
+
caching?: boolean | CacheableMemory | CacheableMemoryOptions;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Will return a Handlebars instance with Fumanchu helpers (experimental)
|
|
102
|
+
* @param {FumanchuOptions} [options] - Options for Fumanchu
|
|
103
|
+
* @returns {Handlebars} Handlebars instance with helpers
|
|
104
|
+
*/
|
|
105
|
+
declare function fumanchu(options?: FumanchuOptions): typeof HandlebarsLib;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { CacheableMemory, type CacheableMemoryOptions, FumanchuOptions, Handlebars, type HelperFilter, HelperRegistry, HelpersOptions, createHandlebars, fumanchu, handlebars, helpers };
|