ha-nunjucks 1.3.0 → 1.4.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 CHANGED
@@ -7,13 +7,13 @@
7
7
 
8
8
  [![Github][github]][github]
9
9
 
10
- A wrapper for [nunjucks](https://www.npmjs.com/package/nunjucks) for use with Home Assistant frontend custom components to render [templates](https://www.home-assistant.io/docs/configuration/templating/) instanteneously at HTML render time. This repository offers an easy way for developers to add templating support to Home Assistant custom cards.
10
+ A wrapper for [nunjucks](https://www.npmjs.com/package/nunjucks) for use with Home Assistant frontend custom components to render [templates](https://www.home-assistant.io/docs/configuration/templating/) instanteneously at HTML render time. This repository offers a fast and easy way for developers to add templating support to Home Assistant custom cards.
11
11
 
12
12
  ## What is nunjucks?
13
13
 
14
14
  [Nunjucks](https://mozilla.github.io/nunjucks/) is a templating engine for JavaScript that is heavily inspired by jinja2. Home Assistant uses jinja2 to process templates in card configurations on the backend, so the syntax of jinja2 and Nunjucks is virtually the same. This makes it an excellent alternative to Home Assistant core jinja2 templating for custom cards.
15
15
 
16
- While some Home Assistant native cards support templating for certain fields, implementing proper Home Assistant jinja2 template support in custom cards can be difficult. Additionally Home Assistant jinja2 templates are processed by the Python backend, and can take several seconds to render. Nunjucks templates are processed by the frontend using the frontend [`hass`](https://developers.home-assistant.io/docs/frontend/data/) object before your custom card's HTML is rendered, making nunjucks templating synchronous, instanteous. and much faster than traditional jinja2 templates.
16
+ While some Home Assistant native cards support templating for certain fields, implementing proper Home Assistant jinja2 template support in custom cards can be difficult. Additionally Home Assistant jinja2 templates are processed by the Python backend, and use subscriptions which must be managed and do not play as well with dynamic custom variables. Nunjucks templates are processed by the frontend using the frontend [`hass`](https://developers.home-assistant.io/docs/frontend/data/) object before your custom card's HTML is rendered, making nunjucks templating synchronous, near instanteous, and easier to use than traditional jinja2 templates.
17
17
 
18
18
  ## Usage
19
19
 
@@ -33,7 +33,7 @@ const renderedString = renderTemplate(this.hass, templateString);
33
33
 
34
34
  That's it! The result of `renderTemplate` is the rendered template for you to use. In unit and integration testing render time is under 1 ms and shouldn't cause any latency in your projects.
35
35
 
36
- Rather than rendering templates on the backend, nunjucks renders templates on the frontend. This repository uses the Home Assistant object present in all custom cards to read entity state data.
36
+ Rather than rendering templates on the backend, nunjucks renders templates on the frontend. This repository uses the Home Assistant object present in all custom cards to read entity state data. A single shared Nunjucks environment is used for the frontend across all custom element instances that use Nunjucks, which helps with initial load times.
37
37
 
38
38
  You can also provide context to the `renderTemplate` function to pass to nunjucks if you want to make additional variables or project specific functions available to your users for use in templates.
39
39
 
@@ -223,10 +223,10 @@ In addition to these functions, you have access to [a datetime library](https://
223
223
 
224
224
  ### [To/From JSON](https://www.home-assistant.io/docs/configuration/templating/#tofrom-json)
225
225
 
226
- | Name | Type | Arguments | Description |
227
- | --------- | ------ | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
228
- | to_json | filter | obj, ensure_ascii, pretty_print, sort_keys | Turn an object into a JSON string. `ensure_ascii` converts unicode characters into escape sequences. `pretty_print` formats the output with new lines and an indent of two spaces. `sort_keys` sorts the keys of the JSON object. **Consider using the nunjucks `safe` filter with this** |
229
- | from_json | filter | value | Parse a string as JSON. |
226
+ | Name | Type | Arguments | Description |
227
+ | --------- | ------ | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
228
+ | to_json | filter | obj, ensure_ascii, pretty_print, sort_keys | Turn an object into a JSON string. `ensure_ascii` converts unicode characters into escape sequences. `pretty_print` formats the output with new lines and an indent of two spaces. `sort_keys` sorts the keys of the JSON object. **Consider using the nunjucks `safe` filter with this, or the nunjucks `dump` filter instead.** |
229
+ | from_json | filter | value | Parse a string as JSON. |
230
230
 
231
231
  ### [Distance](https://www.home-assistant.io/docs/configuration/templating/#distance)
232
232
 
@@ -306,7 +306,7 @@ In addition to these functions, you have access to [a datetime library](https://
306
306
  | ------------------- | ------ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
307
307
  | match | test | value, find | Matches the find string at the beginning of the value string using regex. |
308
308
  | search | test | value, find | Matches the find string anywhere in the value string using regex. |
309
- | test | test | value, find | Matches the find regular expression in the value string usign regex. Regular expressions should be preceded by r, like `r/foobar/g`. |
309
+ | test | test | value, find | Matches the find regular expression in the value string using regex. Regular expressions should be preceded by r, like `r/foobar/g`. |
310
310
  | regex_replace | filter | value, find (default ''), replace (default '') | Replaces the find expression with the replace expression string using RegEx. |
311
311
  | regex_findall | filter | value, find (default '') | Finds all RegEx matches of the find expression in value and returns an array of matches. |
312
312
  | regex_findall_index | filter | value, find (default ''), index (default 0) | Performs a RegEx find all but returns the match at a provided index. |
@@ -315,10 +315,10 @@ In addition to these functions, you have access to [a datetime library](https://
315
315
 
316
316
  Functions that are not from the Home Assistant templating documentation.
317
317
 
318
- | Name | Arguments | Description |
319
- | ----------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
320
- | match_media | mediaquery | Returns the boolean result of the provided [CSS media query](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries). |
321
- | str | value, filter | Return the string representation of the input. |
318
+ | Name | Type | Arguments | Description |
319
+ | ----------- | ---------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
320
+ | match_media | function | value | Returns the boolean result of the provided [CSS media query](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries). |
321
+ | str | function, filter | value | Return the string representation of the input. |
322
322
 
323
323
  [last-commit-shield]: https://img.shields.io/github/last-commit/Nerwyn/ha-nunjucks?style=for-the-badge
324
324
  [commits]: https://github.com/Nerwyn/ha-nunjucks/commits/main
package/dist/filters.js CHANGED
@@ -1,4 +1,3 @@
1
- import { HASS } from '.';
2
1
  import { area_devices, area_entities, area_id, area_name } from './utils/areas';
3
2
  import { contains } from './utils/contains';
4
3
  import { device_attr, device_entities, device_id } from './utils/devices';
@@ -22,7 +21,7 @@ export function addFilters(env) {
22
21
  }
23
22
  for (const func in HASS_FILTERS) {
24
23
  env.addFilter(func, function (...args) {
25
- return HASS_FILTERS[func](HASS, ...args);
24
+ return HASS_FILTERS[func](window.haNunjucks.hass, ...args);
26
25
  });
27
26
  }
28
27
  return env;
package/dist/globals.js CHANGED
@@ -1,4 +1,3 @@
1
- import { HASS } from '.';
2
1
  import { area_devices, area_entities, area_id, area_name, areas, } from './utils/areas';
3
2
  import { device_attr, device_entities, device_id, is_device_attr, } from './utils/devices';
4
3
  import { closest, distance } from './utils/distance';
@@ -24,7 +23,7 @@ export function addGlobals(env) {
24
23
  }
25
24
  for (const func in HASS_GLOBALS) {
26
25
  env.addGlobal(func, function (...args) {
27
- return HASS_GLOBALS[func](HASS, ...args);
26
+ return HASS_GLOBALS[func](window.haNunjucks.hass, ...args);
28
27
  });
29
28
  }
30
29
  for (const c in CONST_GLOBALS) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { HomeAssistant } from './models/hass';
2
- export declare let HASS: HomeAssistant;
1
+ import { HomeAssistant } from './models/interfaces/hass';
3
2
  /**
4
3
  * Render a Home Assistant template string using nunjucks
5
4
  * @param {HomeAssistant} hass The Home Assistant object
package/dist/index.js CHANGED
@@ -4,9 +4,20 @@ import { addGlobals } from './globals';
4
4
  import { addTests } from './tests';
5
5
  import { fetchLabelRegistry } from './utils/labels';
6
6
  import { buildStatesObject } from './utils/states';
7
- export let HASS;
8
- nunjucks.installJinjaCompat();
9
- const env = addTests(addFilters(addGlobals(new nunjucks.Environment())));
7
+ if (!window.haNunjucks) {
8
+ window.haNunjucks = {};
9
+ nunjucks.installJinjaCompat();
10
+ window.haNunjucks.env = addTests(addFilters(addGlobals(new nunjucks.Environment())));
11
+ window.haNunjucks.states = {};
12
+ window.hassConnection?.then((hassConnection) => {
13
+ const entities = hassConnection?.conn?._entityRegistryDisplay?.state
14
+ ?.entities;
15
+ for (const entity of entities) {
16
+ const [domain, _id] = entity.ei.split('.');
17
+ window.haNunjucks.states[domain] ??= {};
18
+ }
19
+ });
20
+ }
10
21
  /**
11
22
  * Render a Home Assistant template string using nunjucks
12
23
  * @param {HomeAssistant} hass The Home Assistant object
@@ -15,28 +26,26 @@ const env = addTests(addFilters(addGlobals(new nunjucks.Environment())));
15
26
  * @returns {string | boolean} The rendered template string if a string was provided, otherwise the unaltered input
16
27
  */
17
28
  export function renderTemplate(hass, str, context) {
18
- if (!HASS) {
29
+ if (!window.haNunjucks?.labelRegistry) {
19
30
  fetchLabelRegistry(hass);
20
31
  }
21
- HASS = hass;
32
+ window.haNunjucks.hass = hass;
22
33
  if (typeof str == 'string' &&
23
34
  ((str.includes('{{') && str.includes('}}')) ||
24
35
  (str.includes('{%') && str.includes('%}')))) {
25
- str = env
36
+ str = window.haNunjucks.env
26
37
  .renderString(structuredClone(str), {
27
38
  hass,
28
- _states: buildStatesObject(hass),
39
+ _states: buildStatesObject(),
29
40
  ...context,
30
41
  })
31
42
  .trim();
32
43
  if ([undefined, null, 'undefined', 'null', 'None'].includes(str)) {
33
44
  return '';
34
45
  }
35
- if (str.toLowerCase() == 'true') {
36
- return true;
37
- }
38
- if (str.toLowerCase() == 'false') {
39
- return false;
46
+ const lowerStr = str.toLowerCase();
47
+ if (['true', 'false'].includes(lowerStr)) {
48
+ return lowerStr == 'true';
40
49
  }
41
50
  return str;
42
51
  }
@@ -0,0 +1,39 @@
1
+ import { Auth, Connection, HassConfig, HassEntities, HassEntity, HassServices, MessageBase } from 'home-assistant-js-websocket';
2
+ import { AreaRegistryEntry, DeviceRegistryEntry, EntityRegistryDisplayEntry, FloorRegistryEntry } from './registries';
3
+ export interface HomeAssistant {
4
+ auth: Auth;
5
+ connection: Connection;
6
+ connected: boolean;
7
+ states: HassEntities;
8
+ entities: {
9
+ [id: string]: EntityRegistryDisplayEntry;
10
+ };
11
+ devices: {
12
+ [id: string]: DeviceRegistryEntry;
13
+ };
14
+ areas: {
15
+ [id: string]: AreaRegistryEntry;
16
+ };
17
+ floors: {
18
+ [id: string]: FloorRegistryEntry;
19
+ };
20
+ services: HassServices;
21
+ config: HassConfig;
22
+ panelUrl: string;
23
+ language: string;
24
+ selectedLanguage: string | null;
25
+ suspendWhenHidden: boolean;
26
+ enableShortcuts: boolean;
27
+ vibrate: boolean;
28
+ debugConnection: boolean;
29
+ dockedSidebar: 'docked' | 'always_hidden' | 'auto';
30
+ defaultPanel: string;
31
+ moreInfoEntityId: string | null;
32
+ callApi<T>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, parameters?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
33
+ fetchWithAuth(path: string, init?: Record<string, any>): Promise<Response>;
34
+ sendWS(msg: MessageBase): void;
35
+ callWS<T>(msg: MessageBase): Promise<T>;
36
+ formatEntityState(stateObj: HassEntity, state?: string): string;
37
+ formatEntityAttributeValue(stateObj: HassEntity, attribute: string, value?: any): string;
38
+ formatEntityAttributeName(stateObj: HassEntity, attribute: string): string;
39
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,63 @@
1
+ interface RegistryEntry {
2
+ created_at: number;
3
+ modified_at: number;
4
+ }
5
+ export interface AreaRegistryEntry extends RegistryEntry {
6
+ area_id: string;
7
+ floor_id: string | null;
8
+ name: string;
9
+ picture: string | null;
10
+ icon: string | null;
11
+ labels: string[];
12
+ aliases: string[];
13
+ }
14
+ export interface DeviceRegistryEntry extends RegistryEntry {
15
+ id: string;
16
+ config_entries: string[];
17
+ connections: Array<[string, string]>;
18
+ identifiers: Array<[string, string]>;
19
+ manufacturer: string | null;
20
+ model: string | null;
21
+ model_id: string | null;
22
+ name: string | null;
23
+ labels: string[];
24
+ sw_version: string | null;
25
+ hw_version: string | null;
26
+ serial_number: string | null;
27
+ via_device_id: string | null;
28
+ area_id: string | null;
29
+ name_by_user: string | null;
30
+ entry_type: 'service' | null;
31
+ disabled_by: 'user' | 'integration' | 'config_entry' | null;
32
+ configuration_url: string | null;
33
+ primary_config_entry: string | null;
34
+ }
35
+ type EntityCategory = 'config' | 'diagnostic';
36
+ export interface EntityRegistryDisplayEntry {
37
+ entity_id: string;
38
+ name?: string;
39
+ icon?: string;
40
+ device_id?: string;
41
+ area_id?: string;
42
+ labels: string[];
43
+ hidden?: boolean;
44
+ entity_category?: EntityCategory;
45
+ translation_key?: string;
46
+ platform?: string;
47
+ display_precision?: number;
48
+ }
49
+ export interface FloorRegistryEntry extends RegistryEntry {
50
+ aliases: string[];
51
+ floor_id: string;
52
+ name: string;
53
+ level?: number;
54
+ icon?: string;
55
+ }
56
+ export interface LabelRegistryEntry extends RegistryEntry {
57
+ label_id: string;
58
+ name: string;
59
+ icon?: string;
60
+ color?: string;
61
+ description?: string;
62
+ }
63
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function areas(hass: HomeAssistant): string[];
3
3
  export declare function area_id(hass: HomeAssistant, lookup_value: string): string | null | undefined;
4
4
  export declare function area_name(hass: HomeAssistant, lookup_value: string): string | undefined;
@@ -1,5 +1,5 @@
1
- import { HomeAssistant } from '../models/hass';
2
- import { DeviceRegistryEntry } from '../models/registries';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
+ import { DeviceRegistryEntry } from '../models/interfaces/registries';
3
3
  export declare function device_entities(hass: HomeAssistant, device_id: string): string[];
4
4
  export declare function device_attr(hass: HomeAssistant, device_or_entity_id: string, attr_name: keyof DeviceRegistryEntry): any;
5
5
  export declare function is_device_attr(hass: HomeAssistant, device_or_entity_id: string, attr_name: keyof DeviceRegistryEntry, attr_value: string): boolean;
@@ -1,4 +1,4 @@
1
1
  import { HassEntities, HassEntity } from 'home-assistant-js-websocket';
2
- import { HomeAssistant } from '../models/hass';
2
+ import { HomeAssistant } from '../models/interfaces/hass';
3
3
  export declare function distance(hass: HomeAssistant, ...args: (string | HassEntity | number)[]): number | null | undefined;
4
4
  export declare function closest(hass: HomeAssistant, ...args: (string | string[] | HassEntity | HassEntities)[]): HassEntity | null;
@@ -1,2 +1,2 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function is_hidden_entity(hass: HomeAssistant, entity_id: string): boolean;
@@ -1,4 +1,4 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function floors(hass: HomeAssistant): string[];
3
3
  export declare function floor_id(hass: HomeAssistant, lookup_value: string): string | null | undefined;
4
4
  export declare function floor_name(hass: HomeAssistant, lookup_value: string): string | undefined;
@@ -1,3 +1,3 @@
1
1
  import { HassEntities, HassEntity } from 'home-assistant-js-websocket';
2
- import { HomeAssistant } from '../models/hass';
2
+ import { HomeAssistant } from '../models/interfaces/hass';
3
3
  export declare function expand(hass: HomeAssistant, ...args: (string | HassEntity | HassEntities)[]): HassEntity[];
@@ -1,2 +1,2 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function iif(hass: HomeAssistant, condition: string, if_true?: string | Record<string, string>, if_false?: string, if_none?: string): string | boolean;
@@ -1,2 +1,2 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function integration_entities(hass: HomeAssistant, integration: string): string[];
@@ -1,4 +1,4 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function fetchLabelRegistry(hass: HomeAssistant): Promise<void>;
3
3
  export declare function labels(hass: HomeAssistant, lookup_value?: string): string[];
4
4
  export declare function label_id(lookup_value: string): string | undefined;
@@ -1,19 +1,19 @@
1
- const labelRegistry = {};
2
1
  export async function fetchLabelRegistry(hass) {
3
2
  if (hass.connection) {
3
+ window.haNunjucks.labelRegistry = {};
4
4
  const labels = await hass.connection.sendMessagePromise({
5
5
  type: 'config/label_registry/list',
6
6
  });
7
7
  labels.sort((ent1, ent2) => ent1.name.localeCompare(ent2.name));
8
8
  for (const label of labels) {
9
- labelRegistry[label.label_id] = label;
9
+ window.haNunjucks.labelRegistry[label.label_id] = label;
10
10
  }
11
11
  }
12
12
  }
13
13
  export function labels(hass, lookup_value) {
14
14
  try {
15
15
  if (!lookup_value) {
16
- return Object.keys(labelRegistry);
16
+ return Object.keys(window.haNunjucks.labelRegistry);
17
17
  }
18
18
  return (hass.entities[lookup_value]?.labels ??
19
19
  hass.devices[lookup_value]?.labels ??
@@ -25,22 +25,22 @@ export function labels(hass, lookup_value) {
25
25
  }
26
26
  }
27
27
  export function label_id(lookup_value) {
28
- for (const id in labelRegistry) {
29
- if (labelRegistry[id].name == lookup_value) {
28
+ for (const id in window.haNunjucks.labelRegistry) {
29
+ if (window.haNunjucks.labelRegistry[id].name == lookup_value) {
30
30
  return id;
31
31
  }
32
32
  }
33
33
  return undefined;
34
34
  }
35
35
  export function label_name(lookup_value) {
36
- return labelRegistry[lookup_value]?.name;
36
+ return window.haNunjucks.labelRegistry[lookup_value]?.name;
37
37
  }
38
38
  export function label_areas(hass, label_name_or_id) {
39
39
  try {
40
40
  const areaIds = [];
41
41
  let labelId = undefined;
42
42
  if (label_name_or_id) {
43
- if (labelRegistry[label_name_or_id]) {
43
+ if (window.haNunjucks.labelRegistry[label_name_or_id]) {
44
44
  labelId = label_name_or_id;
45
45
  }
46
46
  else {
@@ -67,7 +67,7 @@ export function label_devices(hass, label_name_or_id) {
67
67
  const deviceIds = [];
68
68
  if (label_name_or_id) {
69
69
  let labelId = undefined;
70
- if (labelRegistry[label_name_or_id]) {
70
+ if (window.haNunjucks.labelRegistry[label_name_or_id]) {
71
71
  labelId = label_name_or_id;
72
72
  }
73
73
  else {
@@ -94,7 +94,7 @@ export function label_entities(hass, label_name_or_id) {
94
94
  const entityIds = [];
95
95
  if (label_name_or_id) {
96
96
  let labelId = undefined;
97
- if (labelRegistry[label_name_or_id]) {
97
+ if (window.haNunjucks.labelRegistry[label_name_or_id]) {
98
98
  labelId = label_name_or_id;
99
99
  }
100
100
  else {
@@ -1,4 +1,4 @@
1
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
2
2
  export declare function state_translated(hass: HomeAssistant, entity_id: string, state?: string): string;
3
3
  export declare function attr_name_translated(hass: HomeAssistant, entity_id: string, attr_name: string): string;
4
4
  export declare function attr_value_translated(hass: HomeAssistant, entity_id: string, attr_name: string, attr_value?: string): any;
@@ -1,8 +1,7 @@
1
- import { HassEntity } from 'home-assistant-js-websocket';
2
- import { HomeAssistant } from '../models/hass';
1
+ import { HomeAssistant } from '../models/interfaces/hass';
3
2
  export declare function states(hass: HomeAssistant, entity_id: string, rounded?: boolean | Record<string, boolean>, with_unit?: boolean): string | undefined;
4
3
  export declare function is_state(hass: HomeAssistant, entity_id: string, value: string | string[]): boolean;
5
4
  export declare function state_attr(hass: HomeAssistant, entity_id: string, attribute: string): any;
6
5
  export declare function is_state_attr(hass: HomeAssistant, entity_id: string, attribute: string, value: string): boolean;
7
6
  export declare function has_value(hass: HomeAssistant, entity_id: string): boolean;
8
- export declare function buildStatesObject(hass: HomeAssistant): Record<string, Record<string, HassEntity>>;
7
+ export declare function buildStatesObject(): Record<string, Record<string, import("home-assistant-js-websocket").HassEntity>>;
@@ -64,12 +64,12 @@ export function has_value(hass, entity_id) {
64
64
  return false;
65
65
  }
66
66
  }
67
- export function buildStatesObject(hass) {
68
- const states = {};
69
- for (const entityId in hass.states) {
70
- const [domain, entity] = entityId.split('.');
71
- states[domain] = states[domain] ?? {};
72
- states[domain][entity] = hass.states[entityId];
67
+ export function buildStatesObject() {
68
+ for (const entityId in window.haNunjucks.hass.states) {
69
+ const [domain, id] = entityId.split('.');
70
+ window.haNunjucks.states[domain] ??= {};
71
+ window.haNunjucks.states[domain][id] =
72
+ window.haNunjucks.hass.states[entityId];
73
73
  }
74
- return states;
74
+ return window.haNunjucks.states;
75
75
  }
@@ -2,4 +2,4 @@ import { datetime } from 'ts-py-datetime';
2
2
  export declare function list(value: object[]): boolean;
3
3
  export declare function set(value: object[]): value is object[] & Set<any>;
4
4
  export declare function is_datetime(value: object): value is datetime;
5
- export declare function string_like(value: object): value is Buffer | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer;
5
+ export declare function string_like(value: object): value is ArrayBuffer | Buffer<ArrayBuffer> | Buffer<any> | Uint8Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ha-nunjucks",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Wrapper for nunjucks for use with Home Assistant frontend custom components to render templates",
5
5
  "main": "./dist/index.js",
6
6
  "files": [
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "type": "module",
10
10
  "scripts": {
11
- "test": "ts-mocha 'tests/**/*.test.ts'",
11
+ "test": "ts-mocha tests/**/*.test.ts",
12
12
  "build": "tsc",
13
13
  "prelint": "tsc --noemit",
14
14
  "lint": "eslint --config ./.eslintrc.config.cjs"
@@ -39,12 +39,14 @@
39
39
  "eslint": "latest",
40
40
  "eslint-config-prettier": "latest",
41
41
  "eslint-plugin-prettier": "latest",
42
+ "jsdom-global": "latest",
42
43
  "lint-staged": "latest",
44
+ "mocha": "latest",
43
45
  "prettier": "latest",
44
46
  "prettier-plugin-organize-imports": "latest",
45
47
  "ts-loader": "latest",
46
48
  "ts-mocha": "latest",
47
- "ts-node": "latest",
49
+ "ts-node": "^10.9.2",
48
50
  "tsx": "latest",
49
51
  "typescript": "latest"
50
52
  }