ha-nunjucks 1.7.7-beta.2 → 1.7.7
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/dist/index.js +2 -2
- package/dist/utils/hashing.js +15 -8
- package/dist/utils/type_checking.d.ts +1 -1
- package/package.json +5 -4
- package/dist/models/hass.d.ts +0 -39
- package/dist/models/hass.js +0 -1
- package/dist/models/registries.d.ts +0 -63
- package/dist/models/registries.js +0 -1
- package/dist/utils/shuffling.d.ts +0 -1
- package/dist/utils/shuffling.js +0 -8
package/dist/index.js
CHANGED
|
@@ -92,7 +92,7 @@ if (version(packageInfo.version).compare(window.haNunjucks.version || '0.0.0') >
|
|
|
92
92
|
catch (e) {
|
|
93
93
|
// @ts-ignore
|
|
94
94
|
delete window.haNunjucks;
|
|
95
|
-
|
|
95
|
+
console.error(e);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
@@ -104,7 +104,7 @@ if (version(packageInfo.version).compare(window.haNunjucks.version || '0.0.0') >
|
|
|
104
104
|
* @returns {string | boolean} The rendered template string if a string was provided, otherwise the unaltered input
|
|
105
105
|
*/
|
|
106
106
|
export function renderTemplate(hass, str, context, validate = true) {
|
|
107
|
-
if (validate && !hasTemplate(str)) {
|
|
107
|
+
if ((validate && !hasTemplate(str)) || !window.haNunjucks) {
|
|
108
108
|
return str;
|
|
109
109
|
}
|
|
110
110
|
window.haNunjucks.hass = hass;
|
package/dist/utils/hashing.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { md5 as md5_0, sha1 as sha1_0 } from '@noble/hashes/legacy.js';
|
|
2
|
+
import { sha256 as sha256_0, sha512 as sha512_0 } from '@noble/hashes/sha2.js';
|
|
3
|
+
function hash(value, algorithm) {
|
|
4
|
+
const msgUint8 = new TextEncoder().encode(value);
|
|
5
|
+
const hashBuffer = algorithm(msgUint8);
|
|
6
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
7
|
+
const hashHex = hashArray
|
|
8
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
9
|
+
.join('');
|
|
10
|
+
return hashHex;
|
|
11
|
+
}
|
|
5
12
|
export function md5(value) {
|
|
6
|
-
return
|
|
13
|
+
return hash(value, md5_0);
|
|
7
14
|
}
|
|
8
15
|
export function sha1(value) {
|
|
9
|
-
return
|
|
16
|
+
return hash(value, sha1_0);
|
|
10
17
|
}
|
|
11
18
|
export function sha256(value) {
|
|
12
|
-
return
|
|
19
|
+
return hash(value, sha256_0);
|
|
13
20
|
}
|
|
14
21
|
export function sha512(value) {
|
|
15
|
-
return
|
|
22
|
+
return hash(value, sha512_0);
|
|
16
23
|
}
|
|
@@ -2,5 +2,5 @@ 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 ArrayBuffer |
|
|
5
|
+
export declare function string_like(value: object): value is ArrayBuffer | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Buffer<ArrayBuffer> | Buffer<any>;
|
|
6
6
|
export declare function pytypeof(value: any): "str" | "int" | "float" | "bool" | "function" | "list" | "dict" | "NoneType";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ha-nunjucks",
|
|
3
|
-
"version": "1.7.7
|
|
3
|
+
"version": "1.7.7",
|
|
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": [
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "ts-mocha tests/**/*.test.ts --require tests/fixtures.mjs",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"clean": "rm -rf ./dist",
|
|
13
|
+
"build": "npm run clean && tsc --project tsconfig.build.json",
|
|
14
|
+
"prelint": "tsc --noemit --project tsconfig.build.json",
|
|
14
15
|
"lint": "eslint --config ./eslint.config.js",
|
|
15
16
|
"setup": "git config --add core.hooksPath githooks && chmod +x githooks/pre-commit && npm i"
|
|
16
17
|
},
|
|
@@ -28,9 +29,9 @@
|
|
|
28
29
|
},
|
|
29
30
|
"homepage": "https://github.com/Nerwyn/ha-nunjucks#readme",
|
|
30
31
|
"dependencies": {
|
|
32
|
+
"@noble/hashes": "^2.2.0",
|
|
31
33
|
"buffer": "^6.0.3",
|
|
32
34
|
"home-assistant-js-websocket": "latest",
|
|
33
|
-
"jscrypto": "^1.0.3",
|
|
34
35
|
"mersenne-twister": "^1.1.0",
|
|
35
36
|
"nunjucks": "^3.2.4",
|
|
36
37
|
"python-struct": "^1.1.3",
|
package/dist/models/hass.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/models/hass.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
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 {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function shuffle(values: any[], seed: number): any[];
|
package/dist/utils/shuffling.js
DELETED