@esphome/compose 0.0.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.
- package/LICENSE +21 -0
- package/dist/index.d.mts +155371 -0
- package/dist/index.d.ts +155371 -0
- package/dist/index.js +635 -0
- package/dist/index.mjs +574 -0
- package/package.json +50 -0
- package/tsconfig.sdk.json +14 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
import yaml from "yaml";
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
5
|
+
var RefHandle = class {
|
|
6
|
+
_token;
|
|
7
|
+
constructor() {
|
|
8
|
+
this._token = `r_${Math.random().toString(36).slice(2, 11)}`;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return this._token;
|
|
12
|
+
}
|
|
13
|
+
toJSON() {
|
|
14
|
+
return this._token;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
function useRef() {
|
|
18
|
+
return new RefHandle();
|
|
19
|
+
}
|
|
20
|
+
function isRef(val) {
|
|
21
|
+
return val instanceof RefHandle;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/hooks/useState.ts
|
|
25
|
+
var _currentHookPath = null;
|
|
26
|
+
var _currentHookIndex = 0;
|
|
27
|
+
var _currentComponentName = null;
|
|
28
|
+
function setCurrentHookPath(path) {
|
|
29
|
+
_currentHookPath = path;
|
|
30
|
+
_currentHookIndex = 0;
|
|
31
|
+
}
|
|
32
|
+
function getCurrentHookPath() {
|
|
33
|
+
return _currentHookPath;
|
|
34
|
+
}
|
|
35
|
+
function setCurrentHookIndex(index) {
|
|
36
|
+
_currentHookIndex = index;
|
|
37
|
+
}
|
|
38
|
+
function getCurrentHookIndex() {
|
|
39
|
+
return _currentHookIndex;
|
|
40
|
+
}
|
|
41
|
+
function setCurrentComponentName(name) {
|
|
42
|
+
_currentComponentName = name;
|
|
43
|
+
}
|
|
44
|
+
function getCurrentComponentName() {
|
|
45
|
+
return _currentComponentName;
|
|
46
|
+
}
|
|
47
|
+
function assertHookCall() {
|
|
48
|
+
if (!_currentHookPath) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
"Hooks must be called within a function component during render. This error occurs when a hook (useScript, etc.) is called outside of a component render context."
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/hooks/useContext.ts
|
|
56
|
+
var contextMap = /* @__PURE__ */ new Map();
|
|
57
|
+
function createContext(defaultValue) {
|
|
58
|
+
return { id: /* @__PURE__ */ Symbol(), value: defaultValue };
|
|
59
|
+
}
|
|
60
|
+
function withContext(ctx, value, fn) {
|
|
61
|
+
let stack = contextMap.get(ctx.id);
|
|
62
|
+
if (!stack) {
|
|
63
|
+
stack = [];
|
|
64
|
+
contextMap.set(ctx.id, stack);
|
|
65
|
+
}
|
|
66
|
+
stack.push(value);
|
|
67
|
+
try {
|
|
68
|
+
return fn();
|
|
69
|
+
} finally {
|
|
70
|
+
stack.pop();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function useContext(ctx) {
|
|
74
|
+
const stack = contextMap.get(ctx.id);
|
|
75
|
+
if (stack && stack.length > 0) return stack[stack.length - 1];
|
|
76
|
+
return ctx.value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/hooks/useScope.ts
|
|
80
|
+
var scriptScopeContext = createContext({ value: {} });
|
|
81
|
+
function findInScope(id) {
|
|
82
|
+
let frame = useContext(scriptScopeContext);
|
|
83
|
+
let found = frame.value[id];
|
|
84
|
+
while (!found && frame.next) {
|
|
85
|
+
frame = frame.next;
|
|
86
|
+
found = frame.value[id];
|
|
87
|
+
}
|
|
88
|
+
return found;
|
|
89
|
+
}
|
|
90
|
+
function registerInScope(id, entry) {
|
|
91
|
+
const frame = useContext(scriptScopeContext);
|
|
92
|
+
frame.value[id] = entry;
|
|
93
|
+
}
|
|
94
|
+
function withScriptScope(fn) {
|
|
95
|
+
const prev = useContext(scriptScopeContext);
|
|
96
|
+
const scopeFrame = { next: prev, value: {} };
|
|
97
|
+
setCurrentHookPath("espcompose_script_render");
|
|
98
|
+
try {
|
|
99
|
+
const result = withContext(scriptScopeContext, scopeFrame, fn);
|
|
100
|
+
const scripts = Object.values(scopeFrame.value).map((e) => e.def);
|
|
101
|
+
return { result, scripts };
|
|
102
|
+
} finally {
|
|
103
|
+
setCurrentHookPath(null);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/hooks/useScript.ts
|
|
108
|
+
function useScript(metadata) {
|
|
109
|
+
assertHookCall();
|
|
110
|
+
if (findInScope(metadata.id)) {
|
|
111
|
+
return [{ "script.execute": metadata.id }];
|
|
112
|
+
}
|
|
113
|
+
registerInScope(metadata.id, { def: metadata });
|
|
114
|
+
return [{ "script.execute": metadata.id }];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/runtime.ts
|
|
118
|
+
function camelToSnake(key) {
|
|
119
|
+
return key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
120
|
+
}
|
|
121
|
+
function keysToSnakeCase(obj) {
|
|
122
|
+
const out = {};
|
|
123
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
124
|
+
out[camelToSnake(k)] = serializeValue(v);
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
function serializeValue(v) {
|
|
129
|
+
if (isRef(v)) return v.toString();
|
|
130
|
+
if (Array.isArray(v)) return v.map(serializeValue);
|
|
131
|
+
if (v !== null && typeof v === "object") {
|
|
132
|
+
return keysToSnakeCase(v);
|
|
133
|
+
}
|
|
134
|
+
return v;
|
|
135
|
+
}
|
|
136
|
+
function createElement(type, props, ...children) {
|
|
137
|
+
const flatChildren = children.flat().filter((c) => c != null);
|
|
138
|
+
return {
|
|
139
|
+
type,
|
|
140
|
+
props: {
|
|
141
|
+
...props ?? {},
|
|
142
|
+
...flatChildren.length > 0 ? { children: flatChildren } : {}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function Fragment(props) {
|
|
147
|
+
const { children } = props;
|
|
148
|
+
if (children == null) return null;
|
|
149
|
+
return Array.isArray(children) ? children : [children];
|
|
150
|
+
}
|
|
151
|
+
function toPlainObject(el) {
|
|
152
|
+
if (el == null) return void 0;
|
|
153
|
+
if (Array.isArray(el)) {
|
|
154
|
+
const mapped = el.map(toPlainObject).filter((v) => v != null);
|
|
155
|
+
return mapped.length === 1 ? mapped[0] : mapped;
|
|
156
|
+
}
|
|
157
|
+
if (typeof el.type === "function") {
|
|
158
|
+
const result = el.type(el.props);
|
|
159
|
+
if (result == null) return void 0;
|
|
160
|
+
return toPlainObject(Array.isArray(result) ? result : result);
|
|
161
|
+
}
|
|
162
|
+
const { children, ref, "x:custom": xCustom, ...ownProps } = el.props;
|
|
163
|
+
const propsWithId = ref != null ? { id: isRef(ref) ? ref.toString() : String(ref), ...ownProps } : ownProps;
|
|
164
|
+
const allProps = xCustom != null ? { ...propsWithId, ...xCustom } : propsWithId;
|
|
165
|
+
if (el.type === "esphome") {
|
|
166
|
+
const childSections = childrenToTopLevelSections(
|
|
167
|
+
children
|
|
168
|
+
);
|
|
169
|
+
return {
|
|
170
|
+
esphome: stripUndefined(keysToSnakeCase(allProps)),
|
|
171
|
+
...childSections
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const childData = buildChildData(
|
|
175
|
+
children
|
|
176
|
+
);
|
|
177
|
+
const data = stripUndefined(keysToSnakeCase({ ...allProps, ...childData }));
|
|
178
|
+
return { [el.type]: Object.keys(data).length > 0 ? data : null };
|
|
179
|
+
}
|
|
180
|
+
function childrenToTopLevelSections(children) {
|
|
181
|
+
if (!children) return {};
|
|
182
|
+
const normalized = flattenFragments(Array.isArray(children) ? children : [children]);
|
|
183
|
+
const sections = {};
|
|
184
|
+
for (const child of normalized) {
|
|
185
|
+
if (typeof child.type === "function") {
|
|
186
|
+
const result = child.type(child.props);
|
|
187
|
+
if (result == null) continue;
|
|
188
|
+
const rendered = Array.isArray(result) ? result : [result];
|
|
189
|
+
const inner = flattenFragments(rendered);
|
|
190
|
+
for (const c of inner) {
|
|
191
|
+
mergeSection(sections, c);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
mergeSection(sections, child);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const out = {};
|
|
198
|
+
for (const [key, values] of Object.entries(sections)) {
|
|
199
|
+
out[key] = values.length === 1 ? values[0] : values;
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
function mergeSection(sections, child) {
|
|
204
|
+
const { children: grandchildren, ref, "x:custom": xCustom, ...ownProps } = child.props;
|
|
205
|
+
const propsWithId = ref != null ? { id: isRef(ref) ? ref.toString() : String(ref), ...ownProps } : ownProps;
|
|
206
|
+
const allProps = xCustom != null ? { ...propsWithId, ...xCustom } : propsWithId;
|
|
207
|
+
const childData = buildChildData(
|
|
208
|
+
grandchildren
|
|
209
|
+
);
|
|
210
|
+
const data = stripUndefined(keysToSnakeCase({ ...allProps, ...childData }));
|
|
211
|
+
if (!sections[child.type]) sections[child.type] = [];
|
|
212
|
+
sections[child.type].push(Object.keys(data).length > 0 ? data : null);
|
|
213
|
+
}
|
|
214
|
+
function buildChildData(children) {
|
|
215
|
+
if (!children) return {};
|
|
216
|
+
const arr = Array.isArray(children) ? children : [children];
|
|
217
|
+
const out = {};
|
|
218
|
+
for (const child of arr) {
|
|
219
|
+
const plain = toPlainObject(child);
|
|
220
|
+
if (plain != null && typeof plain === "object" && !Array.isArray(plain)) {
|
|
221
|
+
Object.assign(out, plain);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return out;
|
|
225
|
+
}
|
|
226
|
+
function flattenFragments(elements) {
|
|
227
|
+
const out = [];
|
|
228
|
+
for (const el of elements) {
|
|
229
|
+
if (el.type === Fragment) {
|
|
230
|
+
const result = Fragment(el.props);
|
|
231
|
+
if (result != null) {
|
|
232
|
+
const nested = Array.isArray(result) ? result : [result];
|
|
233
|
+
out.push(...flattenFragments(nested));
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
out.push(el);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
function stripUndefined(obj) {
|
|
242
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
243
|
+
}
|
|
244
|
+
function render(element) {
|
|
245
|
+
return toPlainObject(Array.isArray(element) ? element : element);
|
|
246
|
+
}
|
|
247
|
+
function toYAML(config) {
|
|
248
|
+
return yaml.stringify(config, { aliasDuplicateObjects: false, nullStr: "" });
|
|
249
|
+
}
|
|
250
|
+
var ESPCompose = {
|
|
251
|
+
createElement,
|
|
252
|
+
Fragment,
|
|
253
|
+
render,
|
|
254
|
+
toYAML,
|
|
255
|
+
useScript,
|
|
256
|
+
withScriptScope
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// src/actions.ts
|
|
260
|
+
function delay(_ms) {
|
|
261
|
+
}
|
|
262
|
+
var logger = {
|
|
263
|
+
/**
|
|
264
|
+
* Emit a log message at the given level.
|
|
265
|
+
*
|
|
266
|
+
* Compiles to: `logger.log:\n message: <message>\n level: <level>`
|
|
267
|
+
*
|
|
268
|
+
* @espcomposeAction logger.log
|
|
269
|
+
*
|
|
270
|
+
* @param message - The message string to emit.
|
|
271
|
+
* @param level - Log level: "VERBOSE", "DEBUG", "INFO", "WARN", "ERROR".
|
|
272
|
+
* Defaults to "DEBUG" in ESPHome when omitted.
|
|
273
|
+
*/
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
275
|
+
log(_message, _level) {
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// src/generated/registry.ts
|
|
280
|
+
var ESPHomeRegistry = {
|
|
281
|
+
adalight: { yamlKey: "adalight" },
|
|
282
|
+
adc128s102: { yamlKey: "adc128s102" },
|
|
283
|
+
ads1115: { yamlKey: "ads1115" },
|
|
284
|
+
ads1118: { yamlKey: "ads1118" },
|
|
285
|
+
airthings_ble: { yamlKey: "airthings_ble" },
|
|
286
|
+
alarm_control_panel: { yamlKey: "alarm_control_panel" },
|
|
287
|
+
animation: { yamlKey: "animation" },
|
|
288
|
+
apds9960: { yamlKey: "apds9960" },
|
|
289
|
+
api: { yamlKey: "api" },
|
|
290
|
+
as3935_i2c: { yamlKey: "as3935_i2c" },
|
|
291
|
+
as3935_spi: { yamlKey: "as3935_spi" },
|
|
292
|
+
as5600: { yamlKey: "as5600" },
|
|
293
|
+
async_tcp: { yamlKey: "async_tcp" },
|
|
294
|
+
at581x: { yamlKey: "at581x" },
|
|
295
|
+
audio: { yamlKey: "audio" },
|
|
296
|
+
audio_adc: { yamlKey: "audio_adc" },
|
|
297
|
+
audio_dac: { yamlKey: "audio_dac" },
|
|
298
|
+
audio_file: { yamlKey: "audio_file" },
|
|
299
|
+
bedjet: { yamlKey: "bedjet" },
|
|
300
|
+
binary_sensor: { yamlKey: "binary_sensor" },
|
|
301
|
+
bk72xx: { yamlKey: "bk72xx" },
|
|
302
|
+
ble_client: { yamlKey: "ble_client" },
|
|
303
|
+
ble_nus: { yamlKey: "ble_nus" },
|
|
304
|
+
bluetooth_proxy: { yamlKey: "bluetooth_proxy" },
|
|
305
|
+
bme680_bsec: { yamlKey: "bme680_bsec" },
|
|
306
|
+
bme68x_bsec2_i2c: { yamlKey: "bme68x_bsec2_i2c" },
|
|
307
|
+
bp1658cj: { yamlKey: "bp1658cj" },
|
|
308
|
+
bp5758d: { yamlKey: "bp5758d" },
|
|
309
|
+
button: { yamlKey: "button" },
|
|
310
|
+
bytebuffer: { yamlKey: "bytebuffer" },
|
|
311
|
+
camera_encoder: { yamlKey: "camera_encoder" },
|
|
312
|
+
canbus: { yamlKey: "canbus" },
|
|
313
|
+
cap1188: { yamlKey: "cap1188" },
|
|
314
|
+
captive_portal: { yamlKey: "captive_portal" },
|
|
315
|
+
cc1101: { yamlKey: "cc1101" },
|
|
316
|
+
cd74hc4067: { yamlKey: "cd74hc4067" },
|
|
317
|
+
ch422g: { yamlKey: "ch422g" },
|
|
318
|
+
ch423: { yamlKey: "ch423" },
|
|
319
|
+
climate: { yamlKey: "climate" },
|
|
320
|
+
color: { yamlKey: "color" },
|
|
321
|
+
cover: { yamlKey: "cover" },
|
|
322
|
+
custom_component: { yamlKey: "custom_component" },
|
|
323
|
+
dac7678: { yamlKey: "dac7678" },
|
|
324
|
+
dallas: { yamlKey: "dallas" },
|
|
325
|
+
daly_bms: { yamlKey: "daly_bms" },
|
|
326
|
+
dashboard_import: { yamlKey: "dashboard_import" },
|
|
327
|
+
datetime: { yamlKey: "datetime" },
|
|
328
|
+
debug: { yamlKey: "debug" },
|
|
329
|
+
deep_sleep: { yamlKey: "deep_sleep" },
|
|
330
|
+
demo: { yamlKey: "demo" },
|
|
331
|
+
dfplayer: { yamlKey: "dfplayer" },
|
|
332
|
+
dfrobot_sen0395: { yamlKey: "dfrobot_sen0395" },
|
|
333
|
+
display: { yamlKey: "display" },
|
|
334
|
+
dlms_meter: { yamlKey: "dlms_meter" },
|
|
335
|
+
dsmr: { yamlKey: "dsmr" },
|
|
336
|
+
e131: { yamlKey: "e131" },
|
|
337
|
+
emc2101: { yamlKey: "emc2101" },
|
|
338
|
+
esp_ldo: { yamlKey: "esp_ldo" },
|
|
339
|
+
esp32: { yamlKey: "esp32" },
|
|
340
|
+
esp32_ble: { yamlKey: "esp32_ble" },
|
|
341
|
+
esp32_ble_beacon: { yamlKey: "esp32_ble_beacon" },
|
|
342
|
+
esp32_ble_server: { yamlKey: "esp32_ble_server" },
|
|
343
|
+
esp32_ble_tracker: { yamlKey: "esp32_ble_tracker" },
|
|
344
|
+
esp32_camera: { yamlKey: "esp32_camera" },
|
|
345
|
+
esp32_camera_web_server: { yamlKey: "esp32_camera_web_server" },
|
|
346
|
+
esp32_hosted: { yamlKey: "esp32_hosted" },
|
|
347
|
+
esp32_improv: { yamlKey: "esp32_improv" },
|
|
348
|
+
esp32_touch: { yamlKey: "esp32_touch" },
|
|
349
|
+
esp8266: { yamlKey: "esp8266" },
|
|
350
|
+
esphome: { yamlKey: "esphome" },
|
|
351
|
+
espnow: { yamlKey: "espnow" },
|
|
352
|
+
ethernet: { yamlKey: "ethernet" },
|
|
353
|
+
event: { yamlKey: "event" },
|
|
354
|
+
exposure_notifications: { yamlKey: "exposure_notifications" },
|
|
355
|
+
external_components: { yamlKey: "external_components" },
|
|
356
|
+
ezo_pmp: { yamlKey: "ezo_pmp" },
|
|
357
|
+
factory_reset: { yamlKey: "factory_reset" },
|
|
358
|
+
fan: { yamlKey: "fan" },
|
|
359
|
+
fingerprint_grow: { yamlKey: "fingerprint_grow" },
|
|
360
|
+
font: { yamlKey: "font" },
|
|
361
|
+
gdk101: { yamlKey: "gdk101" },
|
|
362
|
+
globals: { yamlKey: "globals" },
|
|
363
|
+
gp8403: { yamlKey: "gp8403" },
|
|
364
|
+
gps: { yamlKey: "gps" },
|
|
365
|
+
graph: { yamlKey: "graph" },
|
|
366
|
+
graphical_display_menu: { yamlKey: "graphical_display_menu" },
|
|
367
|
+
grove_tb6612fng: { yamlKey: "grove_tb6612fng" },
|
|
368
|
+
hlk_fm22x: { yamlKey: "hlk_fm22x" },
|
|
369
|
+
hmac_md5: { yamlKey: "hmac_md5" },
|
|
370
|
+
hmac_sha256: { yamlKey: "hmac_sha256" },
|
|
371
|
+
host: { yamlKey: "host" },
|
|
372
|
+
http_request: { yamlKey: "http_request" },
|
|
373
|
+
i2c: { yamlKey: "i2c" },
|
|
374
|
+
i2c_device: { yamlKey: "i2c_device" },
|
|
375
|
+
i2s_audio: { yamlKey: "i2s_audio" },
|
|
376
|
+
image: { yamlKey: "image" },
|
|
377
|
+
improv_serial: { yamlKey: "improv_serial" },
|
|
378
|
+
infrared: { yamlKey: "infrared" },
|
|
379
|
+
interval: { yamlKey: "interval" },
|
|
380
|
+
json: { yamlKey: "json" },
|
|
381
|
+
key_collector: { yamlKey: "key_collector" },
|
|
382
|
+
lcd_menu: { yamlKey: "lcd_menu" },
|
|
383
|
+
ld2410: { yamlKey: "ld2410" },
|
|
384
|
+
ld2412: { yamlKey: "ld2412" },
|
|
385
|
+
ld2420: { yamlKey: "ld2420" },
|
|
386
|
+
ld2450: { yamlKey: "ld2450" },
|
|
387
|
+
libretiny: { yamlKey: "libretiny" },
|
|
388
|
+
light: { yamlKey: "light" },
|
|
389
|
+
lightwaverf: { yamlKey: "lightwaverf" },
|
|
390
|
+
ln882x: { yamlKey: "ln882x" },
|
|
391
|
+
lock: { yamlKey: "lock" },
|
|
392
|
+
logger: { yamlKey: "logger" },
|
|
393
|
+
lvgl: { yamlKey: "lvgl" },
|
|
394
|
+
m5stack_8angle: { yamlKey: "m5stack_8angle" },
|
|
395
|
+
mapping: { yamlKey: "mapping" },
|
|
396
|
+
matrix_keypad: { yamlKey: "matrix_keypad" },
|
|
397
|
+
max6956: { yamlKey: "max6956" },
|
|
398
|
+
mcp23008: { yamlKey: "mcp23008" },
|
|
399
|
+
mcp23016: { yamlKey: "mcp23016" },
|
|
400
|
+
mcp23017: { yamlKey: "mcp23017" },
|
|
401
|
+
mcp23s08: { yamlKey: "mcp23s08" },
|
|
402
|
+
mcp23s17: { yamlKey: "mcp23s17" },
|
|
403
|
+
mcp3008: { yamlKey: "mcp3008" },
|
|
404
|
+
mcp3204: { yamlKey: "mcp3204" },
|
|
405
|
+
mcp4461: { yamlKey: "mcp4461" },
|
|
406
|
+
mcp4728: { yamlKey: "mcp4728" },
|
|
407
|
+
mdns: { yamlKey: "mdns" },
|
|
408
|
+
media_player: { yamlKey: "media_player" },
|
|
409
|
+
media_source: { yamlKey: "media_source" },
|
|
410
|
+
micro_wake_word: { yamlKey: "micro_wake_word" },
|
|
411
|
+
micronova: { yamlKey: "micronova" },
|
|
412
|
+
microphone: { yamlKey: "microphone" },
|
|
413
|
+
modbus: { yamlKey: "modbus" },
|
|
414
|
+
modbus_controller: { yamlKey: "modbus_controller" },
|
|
415
|
+
mopeka_ble: { yamlKey: "mopeka_ble" },
|
|
416
|
+
mpr121: { yamlKey: "mpr121" },
|
|
417
|
+
mqtt: { yamlKey: "mqtt" },
|
|
418
|
+
msa3xx: { yamlKey: "msa3xx" },
|
|
419
|
+
my9231: { yamlKey: "my9231" },
|
|
420
|
+
network: { yamlKey: "network" },
|
|
421
|
+
nrf52: { yamlKey: "nrf52" },
|
|
422
|
+
number: { yamlKey: "number" },
|
|
423
|
+
one_wire: { yamlKey: "one_wire" },
|
|
424
|
+
online_image: { yamlKey: "online_image" },
|
|
425
|
+
opentherm: { yamlKey: "opentherm" },
|
|
426
|
+
openthread: { yamlKey: "openthread" },
|
|
427
|
+
ota: { yamlKey: "ota" },
|
|
428
|
+
output: { yamlKey: "output" },
|
|
429
|
+
packages: { yamlKey: "packages" },
|
|
430
|
+
packet_transport: { yamlKey: "packet_transport" },
|
|
431
|
+
pca6416a: { yamlKey: "pca6416a" },
|
|
432
|
+
pca9554: { yamlKey: "pca9554" },
|
|
433
|
+
pca9685: { yamlKey: "pca9685" },
|
|
434
|
+
pcf8574: { yamlKey: "pcf8574" },
|
|
435
|
+
pi4ioe5v6408: { yamlKey: "pi4ioe5v6408" },
|
|
436
|
+
pipsolar: { yamlKey: "pipsolar" },
|
|
437
|
+
pn532: { yamlKey: "pn532" },
|
|
438
|
+
pn532_i2c: { yamlKey: "pn532_i2c" },
|
|
439
|
+
pn532_spi: { yamlKey: "pn532_spi" },
|
|
440
|
+
pn7150_i2c: { yamlKey: "pn7150_i2c" },
|
|
441
|
+
pn7160_i2c: { yamlKey: "pn7160_i2c" },
|
|
442
|
+
pn7160_spi: { yamlKey: "pn7160_spi" },
|
|
443
|
+
power_supply: { yamlKey: "power_supply" },
|
|
444
|
+
preferences: { yamlKey: "preferences" },
|
|
445
|
+
prometheus: { yamlKey: "prometheus" },
|
|
446
|
+
psram: { yamlKey: "psram" },
|
|
447
|
+
pylontech: { yamlKey: "pylontech" },
|
|
448
|
+
qr_code: { yamlKey: "qr_code" },
|
|
449
|
+
radon_eye_ble: { yamlKey: "radon_eye_ble" },
|
|
450
|
+
rc522_i2c: { yamlKey: "rc522_i2c" },
|
|
451
|
+
rc522_spi: { yamlKey: "rc522_spi" },
|
|
452
|
+
rd03d: { yamlKey: "rd03d" },
|
|
453
|
+
rdm6300: { yamlKey: "rdm6300" },
|
|
454
|
+
remote_receiver: { yamlKey: "remote_receiver" },
|
|
455
|
+
remote_transmitter: { yamlKey: "remote_transmitter" },
|
|
456
|
+
rf_bridge: { yamlKey: "rf_bridge" },
|
|
457
|
+
rp2040: { yamlKey: "rp2040" },
|
|
458
|
+
rp2040_ble: { yamlKey: "rp2040_ble" },
|
|
459
|
+
rtl87xx: { yamlKey: "rtl87xx" },
|
|
460
|
+
rtttl: { yamlKey: "rtttl" },
|
|
461
|
+
runtime_stats: { yamlKey: "runtime_stats" },
|
|
462
|
+
ruuvi_ble: { yamlKey: "ruuvi_ble" },
|
|
463
|
+
safe_mode: { yamlKey: "safe_mode" },
|
|
464
|
+
script: { yamlKey: "script" },
|
|
465
|
+
seeed_mr24hpc1: { yamlKey: "seeed_mr24hpc1" },
|
|
466
|
+
seeed_mr60bha2: { yamlKey: "seeed_mr60bha2" },
|
|
467
|
+
seeed_mr60fda2: { yamlKey: "seeed_mr60fda2" },
|
|
468
|
+
select: { yamlKey: "select" },
|
|
469
|
+
sensor: { yamlKey: "sensor" },
|
|
470
|
+
serial_proxy: { yamlKey: "serial_proxy" },
|
|
471
|
+
servo: { yamlKey: "servo" },
|
|
472
|
+
sha256: { yamlKey: "sha256" },
|
|
473
|
+
sim800l: { yamlKey: "sim800l" },
|
|
474
|
+
sm16716: { yamlKey: "sm16716" },
|
|
475
|
+
sm2135: { yamlKey: "sm2135" },
|
|
476
|
+
sm2235: { yamlKey: "sm2235" },
|
|
477
|
+
sm2335: { yamlKey: "sm2335" },
|
|
478
|
+
sml: { yamlKey: "sml" },
|
|
479
|
+
sn74hc165: { yamlKey: "sn74hc165" },
|
|
480
|
+
sn74hc595: { yamlKey: "sn74hc595" },
|
|
481
|
+
socket: { yamlKey: "socket" },
|
|
482
|
+
speaker: { yamlKey: "speaker" },
|
|
483
|
+
spi: { yamlKey: "spi" },
|
|
484
|
+
spi_device: { yamlKey: "spi_device" },
|
|
485
|
+
split_buffer: { yamlKey: "split_buffer" },
|
|
486
|
+
sprinkler: { yamlKey: "sprinkler" },
|
|
487
|
+
statsd: { yamlKey: "statsd" },
|
|
488
|
+
status_led: { yamlKey: "status_led" },
|
|
489
|
+
stepper: { yamlKey: "stepper" },
|
|
490
|
+
substitutions: { yamlKey: "substitutions" },
|
|
491
|
+
sun: { yamlKey: "sun" },
|
|
492
|
+
sun_gtil2: { yamlKey: "sun_gtil2" },
|
|
493
|
+
switch: { yamlKey: "switch" },
|
|
494
|
+
sx126x: { yamlKey: "sx126x" },
|
|
495
|
+
sx127x: { yamlKey: "sx127x" },
|
|
496
|
+
sx1509: { yamlKey: "sx1509" },
|
|
497
|
+
sy6970: { yamlKey: "sy6970" },
|
|
498
|
+
syslog: { yamlKey: "syslog" },
|
|
499
|
+
tca9548a: { yamlKey: "tca9548a" },
|
|
500
|
+
tca9555: { yamlKey: "tca9555" },
|
|
501
|
+
teleinfo: { yamlKey: "teleinfo" },
|
|
502
|
+
text: { yamlKey: "text" },
|
|
503
|
+
text_sensor: { yamlKey: "text_sensor" },
|
|
504
|
+
time: { yamlKey: "time" },
|
|
505
|
+
tinyusb: { yamlKey: "tinyusb" },
|
|
506
|
+
tlc59208f: { yamlKey: "tlc59208f" },
|
|
507
|
+
tlc5947: { yamlKey: "tlc5947" },
|
|
508
|
+
tlc5971: { yamlKey: "tlc5971" },
|
|
509
|
+
tm1651: { yamlKey: "tm1651" },
|
|
510
|
+
touchscreen: { yamlKey: "touchscreen" },
|
|
511
|
+
ttp229_bsf: { yamlKey: "ttp229_bsf" },
|
|
512
|
+
ttp229_lsf: { yamlKey: "ttp229_lsf" },
|
|
513
|
+
tuya: { yamlKey: "tuya" },
|
|
514
|
+
uart: { yamlKey: "uart" },
|
|
515
|
+
udp: { yamlKey: "udp" },
|
|
516
|
+
update: { yamlKey: "update" },
|
|
517
|
+
uponor_smatrix: { yamlKey: "uponor_smatrix" },
|
|
518
|
+
usb_cdc_acm: { yamlKey: "usb_cdc_acm" },
|
|
519
|
+
usb_host: { yamlKey: "usb_host" },
|
|
520
|
+
usb_uart: { yamlKey: "usb_uart" },
|
|
521
|
+
valve: { yamlKey: "valve" },
|
|
522
|
+
vbus: { yamlKey: "vbus" },
|
|
523
|
+
voice_assistant: { yamlKey: "voice_assistant" },
|
|
524
|
+
water_heater: { yamlKey: "water_heater" },
|
|
525
|
+
web_server: { yamlKey: "web_server" },
|
|
526
|
+
web_server_base: { yamlKey: "web_server_base" },
|
|
527
|
+
web_server_idf: { yamlKey: "web_server_idf" },
|
|
528
|
+
wiegand: { yamlKey: "wiegand" },
|
|
529
|
+
wifi: { yamlKey: "wifi" },
|
|
530
|
+
wireguard: { yamlKey: "wireguard" },
|
|
531
|
+
wk2132_i2c: { yamlKey: "wk2132_i2c" },
|
|
532
|
+
wk2132_spi: { yamlKey: "wk2132_spi" },
|
|
533
|
+
wk2168_i2c: { yamlKey: "wk2168_i2c" },
|
|
534
|
+
wk2168_spi: { yamlKey: "wk2168_spi" },
|
|
535
|
+
wk2204_i2c: { yamlKey: "wk2204_i2c" },
|
|
536
|
+
wk2204_spi: { yamlKey: "wk2204_spi" },
|
|
537
|
+
wk2212_i2c: { yamlKey: "wk2212_i2c" },
|
|
538
|
+
wk2212_spi: { yamlKey: "wk2212_spi" },
|
|
539
|
+
wled: { yamlKey: "wled" },
|
|
540
|
+
xiaomi_ble: { yamlKey: "xiaomi_ble" },
|
|
541
|
+
xiaomi_rtcgq02lm: { yamlKey: "xiaomi_rtcgq02lm" },
|
|
542
|
+
xl9535: { yamlKey: "xl9535" },
|
|
543
|
+
xpt2046: { yamlKey: "xpt2046" },
|
|
544
|
+
zephyr_ble_server: { yamlKey: "zephyr_ble_server" },
|
|
545
|
+
zigbee: { yamlKey: "zigbee" },
|
|
546
|
+
zwave_proxy: { yamlKey: "zwave_proxy" }
|
|
547
|
+
};
|
|
548
|
+
export {
|
|
549
|
+
ESPCompose,
|
|
550
|
+
ESPHomeRegistry,
|
|
551
|
+
Fragment,
|
|
552
|
+
RefHandle,
|
|
553
|
+
assertHookCall,
|
|
554
|
+
createContext,
|
|
555
|
+
createElement,
|
|
556
|
+
delay,
|
|
557
|
+
findInScope,
|
|
558
|
+
getCurrentComponentName,
|
|
559
|
+
getCurrentHookIndex,
|
|
560
|
+
getCurrentHookPath,
|
|
561
|
+
isRef,
|
|
562
|
+
logger,
|
|
563
|
+
registerInScope,
|
|
564
|
+
render,
|
|
565
|
+
setCurrentComponentName,
|
|
566
|
+
setCurrentHookIndex,
|
|
567
|
+
setCurrentHookPath,
|
|
568
|
+
toYAML,
|
|
569
|
+
useContext,
|
|
570
|
+
useRef,
|
|
571
|
+
useScript,
|
|
572
|
+
withContext,
|
|
573
|
+
withScriptScope
|
|
574
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@esphome/compose",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "ESPHome Compose SDK - TypeScript framework for generating ESPHome YAML",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./tsconfig.sdk.json": "./tsconfig.sdk.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"tsconfig.sdk.json"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"esphome",
|
|
22
|
+
"typescript",
|
|
23
|
+
"yaml",
|
|
24
|
+
"sdk"
|
|
25
|
+
],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"yaml": "^2.4.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
36
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"eslint": "^8.0.0",
|
|
39
|
+
"tsup": "^8.0.0",
|
|
40
|
+
"tsx": "^4.0.0",
|
|
41
|
+
"typescript": "^5.4.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --tsconfig tsconfig.json",
|
|
45
|
+
"clean": "rimraf dist",
|
|
46
|
+
"codegen": "tsx tools/codegen/generate.ts",
|
|
47
|
+
"lint": "eslint --ext .ts,.tsx src",
|
|
48
|
+
"test": "echo \"No tests yet\""
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"jsxFactory": "ESPCompose.createElement",
|
|
8
|
+
"jsxFragmentFactory": "ESPCompose.Fragment",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true
|
|
13
|
+
}
|
|
14
|
+
}
|