@inradius/solid-wc-hass-mixin 1.0.0 → 1.0.2
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 +2 -2
- package/dist/index.cjs +25 -1
- package/dist/index.js +21 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# @inradius/solid-wc-hass-mixin
|
|
2
|
-
 
|
|
2
|
+
  
|
|
3
3
|
|
|
4
4
|
A lightweight mixin for [component-register](https://www.npmjs.com/package/component-register) that streamlines the creation of Home Assistant Custom Cards using Solid.js.
|
|
5
5
|
|
|
@@ -59,4 +59,4 @@ The `withHomeAssistant` function accepts an options object:
|
|
|
59
59
|
3. Global Registry: Adds your card to `window.customCards` so it appears in the "Add Card" dialog in the Lovelace UI.
|
|
60
60
|
|
|
61
61
|
## License
|
|
62
|
-
MIT
|
|
62
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
const UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
3
|
+
const sanitize = (obj) => Object.fromEntries(
|
|
4
|
+
Object.entries(obj).filter(([key]) => !UNSAFE_KEYS.has(key))
|
|
5
|
+
);
|
|
6
|
+
const withHomeAssistant = (options) => {
|
|
7
|
+
const { cardSize = 3, customCard, defaultConfig = {} } = options;
|
|
8
|
+
return (ElementType) => {
|
|
9
|
+
const proto = ElementType.prototype;
|
|
10
|
+
const win = window;
|
|
11
|
+
win.customCards = win.customCards || [];
|
|
12
|
+
proto.setConfig = function(config) {
|
|
13
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
14
|
+
throw new Error("Invalid configuration");
|
|
15
|
+
}
|
|
16
|
+
this.config = { ...sanitize(defaultConfig), ...sanitize(config) };
|
|
17
|
+
};
|
|
18
|
+
proto.getCardSize = function() {
|
|
19
|
+
return cardSize;
|
|
20
|
+
};
|
|
21
|
+
win.customCards.push(sanitize(customCard));
|
|
22
|
+
return ElementType;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
module.exports = withHomeAssistant;
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
2
|
+
const sanitize = (obj) => Object.fromEntries(
|
|
3
|
+
Object.entries(obj).filter(([key]) => !UNSAFE_KEYS.has(key))
|
|
4
|
+
);
|
|
5
|
+
const withHomeAssistant = (options) => {
|
|
6
|
+
const { cardSize = 3, customCard, defaultConfig = {} } = options;
|
|
7
|
+
return (ElementType) => {
|
|
8
|
+
const proto = ElementType.prototype;
|
|
9
|
+
const win = window;
|
|
10
|
+
win.customCards = win.customCards || [];
|
|
11
|
+
proto.setConfig = function(config) {
|
|
12
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
9
13
|
throw new Error("Invalid configuration");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
}
|
|
15
|
+
this.config = { ...sanitize(defaultConfig), ...sanitize(config) };
|
|
16
|
+
};
|
|
17
|
+
proto.getCardSize = function() {
|
|
18
|
+
return cardSize;
|
|
19
|
+
};
|
|
20
|
+
win.customCards.push(sanitize(customCard));
|
|
21
|
+
return ElementType;
|
|
14
22
|
};
|
|
15
23
|
};
|
|
16
24
|
export {
|
|
17
|
-
|
|
25
|
+
withHomeAssistant as default
|
|
18
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inradius/solid-wc-hass-mixin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Travis Stroud <travis.unfasten577@travisstroud.me>",
|
|
6
6
|
"description": "A Solid.js Home Assistant web component mixin.",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"vite": "^5.4.0",
|
|
42
42
|
"vite-plugin-dts": "^4.0.0",
|
|
43
43
|
"vitest": "^2.1.0",
|
|
44
|
-
"@inradius/solid-wc-utils-config": "0.
|
|
44
|
+
"@inradius/solid-wc-utils-config": "0.1.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"component-register": "^0.8.0"
|