smart-home-engine 0.26.2 → 0.27.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/dist/web/assets/index-6dbanXAb.css +1 -0
- package/dist/web/assets/{index-D8-_nETT.js → index-DnqoSlvw.js} +80 -80
- package/dist/web/assets/{tsMode-CXjN2zbx.js → tsMode-CuEvjcPu.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/src/index.js +3 -7
- package/src/web/git-api.js +132 -0
- package/dist/web/assets/index-CND95LL-.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-
|
|
1
|
+
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-DnqoSlvw.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
package/dist/web/index.html
CHANGED
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
}
|
|
156
156
|
})();
|
|
157
157
|
</script>
|
|
158
|
-
<script type="module" crossorigin src="/assets/index-
|
|
158
|
+
<script type="module" crossorigin src="/assets/index-DnqoSlvw.js"></script>
|
|
159
159
|
<link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
|
|
160
160
|
<link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
|
|
161
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
161
|
+
<link rel="stylesheet" crossorigin href="/assets/index-6dbanXAb.css">
|
|
162
162
|
</head>
|
|
163
163
|
<body>
|
|
164
164
|
<div id="app"></div>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -522,7 +522,7 @@ function createScript(source, name) {
|
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
function runScript(script, name,
|
|
525
|
+
function runScript(script, name, _origin) {
|
|
526
526
|
const scriptDir = path.dirname(path.resolve(name));
|
|
527
527
|
const logLabel = makeLabel(name);
|
|
528
528
|
|
|
@@ -1035,10 +1035,7 @@ function runScript(script, name, origin) {
|
|
|
1035
1035
|
subscriptions.filter((s) => s._script === name).length +
|
|
1036
1036
|
varSubscriptions.filter((s) => s._script === name).length +
|
|
1037
1037
|
mqttEventCallbacks.filter((c) => c._script === name).length;
|
|
1038
|
-
const registeredTimers =
|
|
1039
|
-
_myJobs.length +
|
|
1040
|
-
sunEvents.filter((e) => e._script === name).length +
|
|
1041
|
-
_myTimers.size;
|
|
1038
|
+
const registeredTimers = _myJobs.length + sunEvents.filter((e) => e._script === name).length + _myTimers.size;
|
|
1042
1039
|
if (registeredCallbacks > 0 || registeredTimers > 0) {
|
|
1043
1040
|
const parts = [];
|
|
1044
1041
|
if (registeredCallbacks > 0) parts.push(`${registeredCallbacks} callback${registeredCallbacks !== 1 ? 's' : ''}`);
|
|
@@ -1077,7 +1074,7 @@ function loadScript(file, origin) {
|
|
|
1077
1074
|
|
|
1078
1075
|
function unloadScript(file) {
|
|
1079
1076
|
file = file.replace(/\\/g, '/');
|
|
1080
|
-
const
|
|
1077
|
+
const _origin = scriptOrigins.get(file) || 'user';
|
|
1081
1078
|
const unloadLabel = makeLabel(file);
|
|
1082
1079
|
log.info(unloadLabel, 'unloading');
|
|
1083
1080
|
scriptOrigins.delete(file);
|
|
@@ -1195,7 +1192,6 @@ function loadSandbox(callback) {
|
|
|
1195
1192
|
}
|
|
1196
1193
|
});
|
|
1197
1194
|
|
|
1198
|
-
|
|
1199
1195
|
callback();
|
|
1200
1196
|
}
|
|
1201
1197
|
});
|
package/src/web/git-api.js
CHANGED
|
@@ -198,4 +198,136 @@ router.post('/push', async (req, res) => {
|
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
// GET /she/git/log?path=<relPath>&limit=<n>
|
|
202
|
+
// Returns commits touching the given file (relative to scriptDir), up to limit.
|
|
203
|
+
router.get('/log', async (req, res) => {
|
|
204
|
+
const scriptDir = getRoot(req);
|
|
205
|
+
if (!scriptDir) return res.status(500).json({ error: 'scriptDir not configured' });
|
|
206
|
+
|
|
207
|
+
const relPath = String(req.query.path ?? '').trim();
|
|
208
|
+
if (!relPath) return res.status(400).json({ error: 'Missing path parameter' });
|
|
209
|
+
|
|
210
|
+
const limit = Math.min(parseInt(String(req.query.limit ?? '30'), 10) || 30, 200);
|
|
211
|
+
|
|
212
|
+
const gitRoot = await getGitRoot(scriptDir);
|
|
213
|
+
if (!gitRoot) return res.status(404).json({ error: 'Not a git repository' });
|
|
214
|
+
|
|
215
|
+
const abs = safePath(scriptDir, relPath);
|
|
216
|
+
if (!abs) return res.status(400).json({ error: 'Invalid path' });
|
|
217
|
+
|
|
218
|
+
const relToRoot = path.relative(gitRoot, abs).replace(/\\/g, '/');
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
const { stdout } = await git(
|
|
222
|
+
['log', '--follow', '--format=%H%x1f%s%x1f%an%x1f%ai', `-n`, String(limit), '--', relToRoot],
|
|
223
|
+
gitRoot,
|
|
224
|
+
);
|
|
225
|
+
const commits = stdout
|
|
226
|
+
.split('\n')
|
|
227
|
+
.filter(Boolean)
|
|
228
|
+
.map((line) => {
|
|
229
|
+
const [hash, subject, author, date] = line.split('\x1f');
|
|
230
|
+
return { hash, subject, author, date };
|
|
231
|
+
});
|
|
232
|
+
res.json(commits);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
res.status(500).json({ error: e.message });
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// GET /she/git/show?hash=<hash>&path=<relPath>
|
|
239
|
+
// Returns { content: string, binary: false } or { content: null, binary: true }.
|
|
240
|
+
router.get('/show', async (req, res) => {
|
|
241
|
+
const scriptDir = getRoot(req);
|
|
242
|
+
if (!scriptDir) return res.status(500).json({ error: 'scriptDir not configured' });
|
|
243
|
+
|
|
244
|
+
const hash = String(req.query.hash ?? '').trim();
|
|
245
|
+
if (!/^[0-9a-f]{4,64}$/i.test(hash)) return res.status(400).json({ error: 'Invalid hash' });
|
|
246
|
+
|
|
247
|
+
const relPath = String(req.query.path ?? '').trim();
|
|
248
|
+
if (!relPath) return res.status(400).json({ error: 'Missing path parameter' });
|
|
249
|
+
|
|
250
|
+
const gitRoot = await getGitRoot(scriptDir);
|
|
251
|
+
if (!gitRoot) return res.status(404).json({ error: 'Not a git repository' });
|
|
252
|
+
|
|
253
|
+
const abs = safePath(scriptDir, relPath);
|
|
254
|
+
if (!abs) return res.status(400).json({ error: 'Invalid path' });
|
|
255
|
+
|
|
256
|
+
const relToRoot = path.relative(gitRoot, abs).replace(/\\/g, '/');
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
const { stdout } = await git(['show', `${hash}:${relToRoot}`], gitRoot);
|
|
260
|
+
const binary = stdout.includes('\0');
|
|
261
|
+
res.json({ content: binary ? null : stdout, binary });
|
|
262
|
+
} catch (e) {
|
|
263
|
+
res.status(500).json({ error: e.message });
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// GET /she/git/log?path=<relPath>&limit=<n>
|
|
268
|
+
// Returns commits touching the given file (relative to scriptDir), up to limit.
|
|
269
|
+
router.get('/log', async (req, res) => {
|
|
270
|
+
const scriptDir = getRoot(req);
|
|
271
|
+
if (!scriptDir) return res.status(500).json({ error: 'scriptDir not configured' });
|
|
272
|
+
|
|
273
|
+
const relPath = String(req.query.path ?? '').trim();
|
|
274
|
+
if (!relPath) return res.status(400).json({ error: 'Missing path parameter' });
|
|
275
|
+
|
|
276
|
+
const limit = Math.min(parseInt(String(req.query.limit ?? '30'), 10) || 30, 200);
|
|
277
|
+
|
|
278
|
+
const gitRoot = await getGitRoot(scriptDir);
|
|
279
|
+
if (!gitRoot) return res.status(404).json({ error: 'Not a git repository' });
|
|
280
|
+
|
|
281
|
+
const abs = safePath(scriptDir, relPath);
|
|
282
|
+
if (!abs) return res.status(400).json({ error: 'Invalid path' });
|
|
283
|
+
|
|
284
|
+
const relToRoot = path.relative(gitRoot, abs).replace(/\\/g, '/');
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
const { stdout } = await git(
|
|
288
|
+
['log', '--follow', '--format=%H%x1f%s%x1f%an%x1f%ai', `-n`, String(limit), '--', relToRoot],
|
|
289
|
+
gitRoot,
|
|
290
|
+
);
|
|
291
|
+
const commits = stdout
|
|
292
|
+
.split('\n')
|
|
293
|
+
.filter(Boolean)
|
|
294
|
+
.map((line) => {
|
|
295
|
+
const [hash, subject, author, date] = line.split('\x1f');
|
|
296
|
+
return { hash, subject, author, date };
|
|
297
|
+
});
|
|
298
|
+
res.json(commits);
|
|
299
|
+
} catch (e) {
|
|
300
|
+
res.status(500).json({ error: e.message });
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// GET /she/git/show?hash=<hash>&path=<relPath>
|
|
305
|
+
// Returns { content: string, binary: false } or { content: null, binary: true }.
|
|
306
|
+
router.get('/show', async (req, res) => {
|
|
307
|
+
const scriptDir = getRoot(req);
|
|
308
|
+
if (!scriptDir) return res.status(500).json({ error: 'scriptDir not configured' });
|
|
309
|
+
|
|
310
|
+
const hash = String(req.query.hash ?? '').trim();
|
|
311
|
+
if (!/^[0-9a-f]{4,64}$/i.test(hash)) return res.status(400).json({ error: 'Invalid hash' });
|
|
312
|
+
|
|
313
|
+
const relPath = String(req.query.path ?? '').trim();
|
|
314
|
+
if (!relPath) return res.status(400).json({ error: 'Missing path parameter' });
|
|
315
|
+
|
|
316
|
+
const gitRoot = await getGitRoot(scriptDir);
|
|
317
|
+
if (!gitRoot) return res.status(404).json({ error: 'Not a git repository' });
|
|
318
|
+
|
|
319
|
+
const abs = safePath(scriptDir, relPath);
|
|
320
|
+
if (!abs) return res.status(400).json({ error: 'Invalid path' });
|
|
321
|
+
|
|
322
|
+
const relToRoot = path.relative(gitRoot, abs).replace(/\\/g, '/');
|
|
323
|
+
|
|
324
|
+
try {
|
|
325
|
+
const { stdout } = await git(['show', `${hash}:${relToRoot}`], gitRoot);
|
|
326
|
+
const binary = stdout.includes('\0');
|
|
327
|
+
res.json({ content: binary ? null : stdout, binary });
|
|
328
|
+
} catch (e) {
|
|
329
|
+
res.status(500).json({ error: e.message });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
201
333
|
module.exports = { router, git, getGitRoot };
|