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