@jaredwray/fumanchu 4.6.1 → 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.
@@ -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,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}