@omniviewdev/vite-plugin 0.7.4 → 0.8.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/dist/index.cjs +36 -32
- package/dist/index.d.cts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.js +37 -33
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -146,6 +146,8 @@ function workspaceViteCacheDirectory(raw) {
|
|
|
146
146
|
var import_node_child_process = require("child_process");
|
|
147
147
|
var import_node_fs2 = require("fs");
|
|
148
148
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
149
|
+
var import_node_util = require("util");
|
|
150
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
149
151
|
var navigationTypes = { update: true, "full-reload": true, prune: true };
|
|
150
152
|
var maximumStateBytes = 64 * 1024;
|
|
151
153
|
var maximumStateSize = BigInt(maximumStateBytes);
|
|
@@ -279,6 +281,28 @@ function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDB
|
|
|
279
281
|
if (!httpServer || Boolean(hmr?.server && hmr.server !== httpServer) || Boolean(hmr?.port && hmr.port !== server.config.server.port)) {
|
|
280
282
|
throw new Error("Managed Vite feedback requires HMR on its owned HTTP listener");
|
|
281
283
|
}
|
|
284
|
+
let observing;
|
|
285
|
+
const observe = async () => {
|
|
286
|
+
if (!context.authority) {
|
|
287
|
+
return Promise.resolve(null);
|
|
288
|
+
}
|
|
289
|
+
observing ??= execFileAsync(context.authority.executable, [
|
|
290
|
+
"workspace",
|
|
291
|
+
"inspect",
|
|
292
|
+
"--workspace",
|
|
293
|
+
context.workspaceRoot,
|
|
294
|
+
"--json"
|
|
295
|
+
], { encoding: "utf8", shell: false, windowsHide: true, timeout: 5e3, maxBuffer: 2 * 1024 * 1024 }).then(({ stdout }) => {
|
|
296
|
+
const value = JSON.parse(stdout);
|
|
297
|
+
if (value?.generation !== context.generation || value?.manifest?.workspaceID !== context.workspaceID) {
|
|
298
|
+
throw new Error("Observed development status identity changed");
|
|
299
|
+
}
|
|
300
|
+
return value;
|
|
301
|
+
}).catch(() => null).finally(() => {
|
|
302
|
+
observing = void 0;
|
|
303
|
+
});
|
|
304
|
+
return observing;
|
|
305
|
+
};
|
|
282
306
|
const authority = feedbackAuthorityReader(context, raw);
|
|
283
307
|
let closed = false;
|
|
284
308
|
let watchFailed = false;
|
|
@@ -337,7 +361,7 @@ function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDB
|
|
|
337
361
|
original.call(this, payload, data);
|
|
338
362
|
};
|
|
339
363
|
}
|
|
340
|
-
server.middlewares.use((request, response, next) => {
|
|
364
|
+
server.middlewares.use(async (request, response, next) => {
|
|
341
365
|
if (request.url === "/__omniview_development_status") {
|
|
342
366
|
let fd;
|
|
343
367
|
try {
|
|
@@ -352,11 +376,20 @@ function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDB
|
|
|
352
376
|
if (status.generation !== context.generation || status.manifest?.workspaceID !== context.workspaceID) {
|
|
353
377
|
throw new Error("Development status identity changed");
|
|
354
378
|
}
|
|
379
|
+
const observed = await observe();
|
|
380
|
+
const current = observed ?? status;
|
|
355
381
|
response.setHeader("Cache-Control", "no-store");
|
|
356
382
|
response.setHeader("Content-Type", "application/json");
|
|
357
383
|
response.end(JSON.stringify({
|
|
358
|
-
|
|
359
|
-
|
|
384
|
+
workspaceID: context.workspaceID,
|
|
385
|
+
generation: context.generation,
|
|
386
|
+
health: Object.fromEntries(["build", "hmr", "servedSource", "sourceReload", "dependencies", "readiness"].flatMap((key) => typeof observed?.health?.[key] === "string" && observed.health[key] ? [[key, observed.health[key]]] : [])),
|
|
387
|
+
builds: Object.fromEntries(Object.entries(current.builds ?? {}).map(([name, build]) => [name, {
|
|
388
|
+
phase: build && typeof build === "object" && "phase" in build && typeof build.phase === "string" ? build.phase : "unknown"
|
|
389
|
+
}])),
|
|
390
|
+
selectedPluginCount: Array.isArray(current.manifest?.plugins) ? current.manifest.plugins.length : null,
|
|
391
|
+
phase: current.launchPhase,
|
|
392
|
+
failedStage: current.failedStage,
|
|
360
393
|
recoveryCommand: `omniview-dev workspace refresh ${context.workspaceID}`
|
|
361
394
|
}));
|
|
362
395
|
} catch {
|
|
@@ -437,35 +470,6 @@ function managedViteFeedback() {
|
|
|
437
470
|
name: "omniview-managed-vite-feedback",
|
|
438
471
|
apply: "serve",
|
|
439
472
|
enforce: "pre",
|
|
440
|
-
transformIndexHtml() {
|
|
441
|
-
if (!process.env.OMNIVIEW_VITE_FEEDBACK) {
|
|
442
|
-
return [];
|
|
443
|
-
}
|
|
444
|
-
return [{
|
|
445
|
-
tag: "script",
|
|
446
|
-
attrs: { type: "module" },
|
|
447
|
-
injectTo: "body",
|
|
448
|
-
children: `
|
|
449
|
-
const banner = document.createElement('div');
|
|
450
|
-
banner.id = 'omniview-development-banner';
|
|
451
|
-
banner.setAttribute('role', 'status');
|
|
452
|
-
banner.style.cssText = 'position:fixed;bottom:32px;left:12px;max-width:calc(100vw - 24px);box-sizing:border-box;pointer-events:none;z-index:2147483647;padding:6px 12px;background:#172554;color:#fff;font:12px monospace;white-space:pre-wrap';
|
|
453
|
-
document.body.append(banner);
|
|
454
|
-
async function refreshDevelopmentStatus() {
|
|
455
|
-
try {
|
|
456
|
-
const response = await fetch('/__omniview_development_status', { cache: 'no-store' });
|
|
457
|
-
if (!response.ok) throw new Error('status unavailable');
|
|
458
|
-
const status = await response.json();
|
|
459
|
-
banner.textContent = 'DEVELOPMENT \u2014 ' + status.phase + (status.failedStage ? ' \u2014 failed stage: ' + status.failedStage + ' \u2014 recover: ' + status.recoveryCommand : '');
|
|
460
|
-
} catch {
|
|
461
|
-
banner.textContent = 'DEVELOPMENT \u2014 supervisor status unavailable; inspect workspace status before trusting served source';
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
refreshDevelopmentStatus();
|
|
465
|
-
setInterval(refreshDevelopmentStatus, 1500);
|
|
466
|
-
`
|
|
467
|
-
}];
|
|
468
|
-
},
|
|
469
473
|
configureServer(server) {
|
|
470
474
|
attachManagedViteFeedback(server);
|
|
471
475
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -71,14 +71,6 @@ declare function managedViteFeedback(): {
|
|
|
71
71
|
name: string;
|
|
72
72
|
apply: "serve";
|
|
73
73
|
enforce: "pre";
|
|
74
|
-
transformIndexHtml(): {
|
|
75
|
-
tag: string;
|
|
76
|
-
attrs: {
|
|
77
|
-
type: string;
|
|
78
|
-
};
|
|
79
|
-
injectTo: "body";
|
|
80
|
-
children: string;
|
|
81
|
-
}[];
|
|
82
74
|
configureServer(server: ManagedFeedbackServer): void;
|
|
83
75
|
};
|
|
84
76
|
|
package/dist/index.d.ts
CHANGED
|
@@ -71,14 +71,6 @@ declare function managedViteFeedback(): {
|
|
|
71
71
|
name: string;
|
|
72
72
|
apply: "serve";
|
|
73
73
|
enforce: "pre";
|
|
74
|
-
transformIndexHtml(): {
|
|
75
|
-
tag: string;
|
|
76
|
-
attrs: {
|
|
77
|
-
type: string;
|
|
78
|
-
};
|
|
79
|
-
injectTo: "body";
|
|
80
|
-
children: string;
|
|
81
|
-
}[];
|
|
82
74
|
configureServer(server: ManagedFeedbackServer): void;
|
|
83
75
|
};
|
|
84
76
|
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function workspaceViteCacheDirectory(raw) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// src/feedback.ts
|
|
108
|
-
import { execFileSync } from "node:child_process";
|
|
108
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
109
109
|
import {
|
|
110
110
|
closeSync,
|
|
111
111
|
constants,
|
|
@@ -118,6 +118,8 @@ import {
|
|
|
118
118
|
watch
|
|
119
119
|
} from "node:fs";
|
|
120
120
|
import path2 from "node:path";
|
|
121
|
+
import { promisify } from "node:util";
|
|
122
|
+
var execFileAsync = promisify(execFile);
|
|
121
123
|
var navigationTypes = { update: true, "full-reload": true, prune: true };
|
|
122
124
|
var maximumStateBytes = 64 * 1024;
|
|
123
125
|
var maximumStateSize = BigInt(maximumStateBytes);
|
|
@@ -251,6 +253,28 @@ function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDB
|
|
|
251
253
|
if (!httpServer || Boolean(hmr?.server && hmr.server !== httpServer) || Boolean(hmr?.port && hmr.port !== server.config.server.port)) {
|
|
252
254
|
throw new Error("Managed Vite feedback requires HMR on its owned HTTP listener");
|
|
253
255
|
}
|
|
256
|
+
let observing;
|
|
257
|
+
const observe = async () => {
|
|
258
|
+
if (!context.authority) {
|
|
259
|
+
return Promise.resolve(null);
|
|
260
|
+
}
|
|
261
|
+
observing ??= execFileAsync(context.authority.executable, [
|
|
262
|
+
"workspace",
|
|
263
|
+
"inspect",
|
|
264
|
+
"--workspace",
|
|
265
|
+
context.workspaceRoot,
|
|
266
|
+
"--json"
|
|
267
|
+
], { encoding: "utf8", shell: false, windowsHide: true, timeout: 5e3, maxBuffer: 2 * 1024 * 1024 }).then(({ stdout }) => {
|
|
268
|
+
const value = JSON.parse(stdout);
|
|
269
|
+
if (value?.generation !== context.generation || value?.manifest?.workspaceID !== context.workspaceID) {
|
|
270
|
+
throw new Error("Observed development status identity changed");
|
|
271
|
+
}
|
|
272
|
+
return value;
|
|
273
|
+
}).catch(() => null).finally(() => {
|
|
274
|
+
observing = void 0;
|
|
275
|
+
});
|
|
276
|
+
return observing;
|
|
277
|
+
};
|
|
254
278
|
const authority = feedbackAuthorityReader(context, raw);
|
|
255
279
|
let closed = false;
|
|
256
280
|
let watchFailed = false;
|
|
@@ -309,7 +333,7 @@ function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDB
|
|
|
309
333
|
original.call(this, payload, data);
|
|
310
334
|
};
|
|
311
335
|
}
|
|
312
|
-
server.middlewares.use((request, response, next) => {
|
|
336
|
+
server.middlewares.use(async (request, response, next) => {
|
|
313
337
|
if (request.url === "/__omniview_development_status") {
|
|
314
338
|
let fd;
|
|
315
339
|
try {
|
|
@@ -324,11 +348,20 @@ function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDB
|
|
|
324
348
|
if (status.generation !== context.generation || status.manifest?.workspaceID !== context.workspaceID) {
|
|
325
349
|
throw new Error("Development status identity changed");
|
|
326
350
|
}
|
|
351
|
+
const observed = await observe();
|
|
352
|
+
const current = observed ?? status;
|
|
327
353
|
response.setHeader("Cache-Control", "no-store");
|
|
328
354
|
response.setHeader("Content-Type", "application/json");
|
|
329
355
|
response.end(JSON.stringify({
|
|
330
|
-
|
|
331
|
-
|
|
356
|
+
workspaceID: context.workspaceID,
|
|
357
|
+
generation: context.generation,
|
|
358
|
+
health: Object.fromEntries(["build", "hmr", "servedSource", "sourceReload", "dependencies", "readiness"].flatMap((key) => typeof observed?.health?.[key] === "string" && observed.health[key] ? [[key, observed.health[key]]] : [])),
|
|
359
|
+
builds: Object.fromEntries(Object.entries(current.builds ?? {}).map(([name, build]) => [name, {
|
|
360
|
+
phase: build && typeof build === "object" && "phase" in build && typeof build.phase === "string" ? build.phase : "unknown"
|
|
361
|
+
}])),
|
|
362
|
+
selectedPluginCount: Array.isArray(current.manifest?.plugins) ? current.manifest.plugins.length : null,
|
|
363
|
+
phase: current.launchPhase,
|
|
364
|
+
failedStage: current.failedStage,
|
|
332
365
|
recoveryCommand: `omniview-dev workspace refresh ${context.workspaceID}`
|
|
333
366
|
}));
|
|
334
367
|
} catch {
|
|
@@ -409,35 +442,6 @@ function managedViteFeedback() {
|
|
|
409
442
|
name: "omniview-managed-vite-feedback",
|
|
410
443
|
apply: "serve",
|
|
411
444
|
enforce: "pre",
|
|
412
|
-
transformIndexHtml() {
|
|
413
|
-
if (!process.env.OMNIVIEW_VITE_FEEDBACK) {
|
|
414
|
-
return [];
|
|
415
|
-
}
|
|
416
|
-
return [{
|
|
417
|
-
tag: "script",
|
|
418
|
-
attrs: { type: "module" },
|
|
419
|
-
injectTo: "body",
|
|
420
|
-
children: `
|
|
421
|
-
const banner = document.createElement('div');
|
|
422
|
-
banner.id = 'omniview-development-banner';
|
|
423
|
-
banner.setAttribute('role', 'status');
|
|
424
|
-
banner.style.cssText = 'position:fixed;bottom:32px;left:12px;max-width:calc(100vw - 24px);box-sizing:border-box;pointer-events:none;z-index:2147483647;padding:6px 12px;background:#172554;color:#fff;font:12px monospace;white-space:pre-wrap';
|
|
425
|
-
document.body.append(banner);
|
|
426
|
-
async function refreshDevelopmentStatus() {
|
|
427
|
-
try {
|
|
428
|
-
const response = await fetch('/__omniview_development_status', { cache: 'no-store' });
|
|
429
|
-
if (!response.ok) throw new Error('status unavailable');
|
|
430
|
-
const status = await response.json();
|
|
431
|
-
banner.textContent = 'DEVELOPMENT \u2014 ' + status.phase + (status.failedStage ? ' \u2014 failed stage: ' + status.failedStage + ' \u2014 recover: ' + status.recoveryCommand : '');
|
|
432
|
-
} catch {
|
|
433
|
-
banner.textContent = 'DEVELOPMENT \u2014 supervisor status unavailable; inspect workspace status before trusting served source';
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
refreshDevelopmentStatus();
|
|
437
|
-
setInterval(refreshDevelopmentStatus, 1500);
|
|
438
|
-
`
|
|
439
|
-
}];
|
|
440
|
-
},
|
|
441
445
|
configureServer(server) {
|
|
442
446
|
attachManagedViteFeedback(server);
|
|
443
447
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omniviewdev/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Vite plugin for Omniview plugin development. Redirects shared dependency imports to the host app's singleton instances via window.__OMNIVIEW_SHARED__.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": "Omniview",
|