@omniviewdev/vite-plugin 0.4.2 → 0.5.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/index.cjs +399 -10
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +408 -10
- package/package.json +2 -2
- package/shims/_omniviewdev__base-ui.mjs +6 -0
- package/shims/_omniviewdev__runtime__api.mjs +1 -0
- package/shims/_omniviewdev__runtime__models.mjs +3 -1
- package/shims/react-icons__si.mjs +489 -159
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
2
|
+
import path3 from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
5
|
// src/sharedPackages.ts
|
|
@@ -55,16 +55,346 @@ function safeFilename(packageName) {
|
|
|
55
55
|
return result;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// src/workspace.ts
|
|
59
|
+
import { realpathSync, statSync } from "node:fs";
|
|
60
|
+
import path from "node:path";
|
|
61
|
+
function workspaceViteRoots(raw) {
|
|
62
|
+
if (raw === void 0) {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
const roots = JSON.parse(raw);
|
|
66
|
+
if (!Array.isArray(roots) || roots.length === 0) {
|
|
67
|
+
throw new Error("OMNIVIEW_VITE_ALLOWED_ROOTS must be a nonempty JSON array");
|
|
68
|
+
}
|
|
69
|
+
return [...new Set(roots.map((root) => {
|
|
70
|
+
if (typeof root !== "string" || !path.isAbsolute(root) || root.includes("*") || root.includes("\0") || path.parse(root).root === root) {
|
|
71
|
+
throw new Error("Vite workspace roots must be explicit absolute repository directories");
|
|
72
|
+
}
|
|
73
|
+
const canonical = realpathSync(root);
|
|
74
|
+
if (canonical !== path.resolve(root) || !statSync(canonical).isDirectory()) {
|
|
75
|
+
throw new Error("Vite workspace roots must be canonical repository directories");
|
|
76
|
+
}
|
|
77
|
+
return canonical;
|
|
78
|
+
}))];
|
|
79
|
+
}
|
|
80
|
+
function workspaceVitePort(raw) {
|
|
81
|
+
if (raw === void 0) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
if (!/^[0-9]+$/.test(raw)) {
|
|
85
|
+
throw new Error("Owned Vite port must be an integer");
|
|
86
|
+
}
|
|
87
|
+
const port = Number(raw);
|
|
88
|
+
if (port < 1 || port > 65535) {
|
|
89
|
+
throw new Error("Owned Vite port is outside 1..65535");
|
|
90
|
+
}
|
|
91
|
+
return port;
|
|
92
|
+
}
|
|
93
|
+
function workspaceViteCacheDirectory(raw) {
|
|
94
|
+
if (raw === void 0) {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
if (!path.isAbsolute(raw) || raw.includes("\0") || path.parse(raw).root === raw) {
|
|
98
|
+
throw new Error("Managed Vite cache must be an explicit absolute directory");
|
|
99
|
+
}
|
|
100
|
+
const canonical = realpathSync(raw);
|
|
101
|
+
if (canonical !== path.resolve(raw) || !statSync(canonical).isDirectory()) {
|
|
102
|
+
throw new Error("Managed Vite cache must be an existing canonical owned directory");
|
|
103
|
+
}
|
|
104
|
+
return canonical;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/feedback.ts
|
|
108
|
+
import { execFileSync } from "node:child_process";
|
|
109
|
+
import {
|
|
110
|
+
closeSync,
|
|
111
|
+
constants,
|
|
112
|
+
fstatSync,
|
|
113
|
+
lstatSync,
|
|
114
|
+
openSync,
|
|
115
|
+
readSync,
|
|
116
|
+
realpathSync as realpathSync2,
|
|
117
|
+
statSync as statSync2,
|
|
118
|
+
watch
|
|
119
|
+
} from "node:fs";
|
|
120
|
+
import path2 from "node:path";
|
|
121
|
+
var navigationTypes = { update: true, "full-reload": true, prune: true };
|
|
122
|
+
var maximumStateBytes = 64 * 1024;
|
|
123
|
+
var maximumStateSize = BigInt(maximumStateBytes);
|
|
124
|
+
function feedbackContext(raw) {
|
|
125
|
+
const value = JSON.parse(raw);
|
|
126
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
127
|
+
throw new Error("OMNIVIEW_VITE_FEEDBACK must be an explicit managed feedback context");
|
|
128
|
+
}
|
|
129
|
+
const context = value;
|
|
130
|
+
if (context.schemaVersion !== 1 || typeof context.workspaceID !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(context.workspaceID) || typeof context.generation !== "string" || !context.generation || context.generation.includes("\0") || typeof context.workspaceRoot !== "string" || !path2.isAbsolute(context.workspaceRoot) || context.workspaceRoot.includes("\0") || path2.parse(context.workspaceRoot).root === context.workspaceRoot || typeof context.file !== "string" || !path2.isAbsolute(context.file) || context.file.includes("\0") || path2.resolve(context.file) !== context.file) {
|
|
131
|
+
throw new Error("Managed Vite feedback requires versioned, explicit workspace and file ownership");
|
|
132
|
+
}
|
|
133
|
+
if (realpathSync2(context.workspaceRoot) !== context.workspaceRoot || !statSync2(context.workspaceRoot).isDirectory()) {
|
|
134
|
+
throw new Error("Managed Vite feedback workspace must be an existing canonical directory");
|
|
135
|
+
}
|
|
136
|
+
let authority;
|
|
137
|
+
if (context.authority !== void 0) {
|
|
138
|
+
if (!context.authority || typeof context.authority !== "object" || Array.isArray(context.authority)) {
|
|
139
|
+
throw new Error("Managed Vite feedback authority must be explicit supervisor ownership");
|
|
140
|
+
}
|
|
141
|
+
const value2 = context.authority;
|
|
142
|
+
if (typeof value2.executable !== "string" || !path2.isAbsolute(value2.executable) || value2.executable.includes("\0") || path2.resolve(value2.executable) !== value2.executable || realpathSync2(value2.executable) !== value2.executable || !lstatSync(value2.executable).isFile() || !value2.identity || typeof value2.identity !== "object" || Array.isArray(value2.identity)) {
|
|
143
|
+
throw new Error("Managed Vite feedback authority requires its exact canonical supervisor executable");
|
|
144
|
+
}
|
|
145
|
+
const identity = value2.identity;
|
|
146
|
+
if (typeof identity.volume !== "string" || !/^[0-9]+$/.test(identity.volume) || typeof identity.fileID !== "string" || !/^[0-9a-f]{32}$/.test(identity.fileID)) {
|
|
147
|
+
throw new Error("Managed Vite feedback authority requires the full stable file identity");
|
|
148
|
+
}
|
|
149
|
+
authority = {
|
|
150
|
+
executable: value2.executable,
|
|
151
|
+
identity: { volume: identity.volume, fileID: identity.fileID }
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
schemaVersion: 1,
|
|
156
|
+
workspaceID: context.workspaceID,
|
|
157
|
+
generation: context.generation,
|
|
158
|
+
workspaceRoot: context.workspaceRoot,
|
|
159
|
+
file: context.file,
|
|
160
|
+
authority
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function readViteFeedbackAuthority(raw) {
|
|
164
|
+
try {
|
|
165
|
+
const context = feedbackContext(raw);
|
|
166
|
+
if (!context.authority) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
const output = execFileSync(context.authority.executable, ["vite-feedback-read", "--context", raw], {
|
|
170
|
+
encoding: "utf8",
|
|
171
|
+
shell: false,
|
|
172
|
+
windowsHide: true,
|
|
173
|
+
timeout: 2e3,
|
|
174
|
+
maxBuffer: 1024,
|
|
175
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
176
|
+
});
|
|
177
|
+
const result = JSON.parse(output);
|
|
178
|
+
if (!result || typeof result !== "object" || Array.isArray(result) || Object.keys(result).length !== 1) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return result.held !== false;
|
|
182
|
+
} catch {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function privateFeedbackFile(stat) {
|
|
187
|
+
const owner = process.getuid?.();
|
|
188
|
+
return stat.isFile() && owner !== void 0 && stat.uid === BigInt(owner) && (stat.mode & 0o777n) === 0o600n;
|
|
189
|
+
}
|
|
190
|
+
function retainUnixFeedbackAuthority(context) {
|
|
191
|
+
const bytes = Buffer.alloc(maximumStateBytes + 1);
|
|
192
|
+
let identity;
|
|
193
|
+
function readHeld(captureIdentity = false) {
|
|
194
|
+
let descriptor;
|
|
195
|
+
try {
|
|
196
|
+
descriptor = openSync(context.file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
197
|
+
const stat = fstatSync(descriptor, { bigint: true });
|
|
198
|
+
if (!privateFeedbackFile(stat) || realpathSync2(context.file) !== context.file) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
if (captureIdentity) {
|
|
202
|
+
identity = stat;
|
|
203
|
+
}
|
|
204
|
+
if (!identity || stat.dev !== identity.dev || stat.ino !== identity.ino) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
const linked = lstatSync(context.file, { bigint: true });
|
|
208
|
+
if (!privateFeedbackFile(linked) || linked.dev !== identity.dev || linked.ino !== identity.ino || stat.size < 1n || stat.size > maximumStateSize) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
const length = readSync(descriptor, bytes, 0, bytes.length, 0);
|
|
212
|
+
if (BigInt(length) !== stat.size) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
const state = JSON.parse(bytes.toString("utf8", 0, length));
|
|
216
|
+
if (!state || typeof state !== "object" || Array.isArray(state)) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
const value = state;
|
|
220
|
+
const after = lstatSync(context.file, { bigint: true });
|
|
221
|
+
return !privateFeedbackFile(after) || after.dev !== identity.dev || after.ino !== identity.ino || value.schemaVersion !== context.schemaVersion || value.workspaceID !== context.workspaceID || value.generation !== context.generation || value.workspaceRoot !== context.workspaceRoot || typeof value.held !== "boolean" || value.held;
|
|
222
|
+
} catch {
|
|
223
|
+
return true;
|
|
224
|
+
} finally {
|
|
225
|
+
if (descriptor !== void 0) {
|
|
226
|
+
closeSync(descriptor);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return { initiallyHeld: readHeld(true), readHeld };
|
|
231
|
+
}
|
|
232
|
+
function feedbackAuthorityReader(context, raw) {
|
|
233
|
+
if (process.platform !== "win32") {
|
|
234
|
+
return retainUnixFeedbackAuthority(context);
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
initiallyHeld: readViteFeedbackAuthority(raw),
|
|
238
|
+
readHeld: () => readViteFeedbackAuthority(raw)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function attachManagedViteFeedback(server, raw = process.env.OMNIVIEW_VITE_FEEDBACK) {
|
|
242
|
+
if (raw === void 0) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const context = feedbackContext(raw);
|
|
246
|
+
if (process.platform === "win32" && !context.authority) {
|
|
247
|
+
throw new Error("Managed Vite feedback on Windows requires its supervisor file authority");
|
|
248
|
+
}
|
|
249
|
+
const httpServer = server.httpServer;
|
|
250
|
+
const hmr = typeof server.config.server.hmr === "object" ? server.config.server.hmr : void 0;
|
|
251
|
+
if (!httpServer || Boolean(hmr?.server && hmr.server !== httpServer) || Boolean(hmr?.port && hmr.port !== server.config.server.port)) {
|
|
252
|
+
throw new Error("Managed Vite feedback requires HMR on its owned HTTP listener");
|
|
253
|
+
}
|
|
254
|
+
const authority = feedbackAuthorityReader(context, raw);
|
|
255
|
+
let closed = false;
|
|
256
|
+
let watchFailed = false;
|
|
257
|
+
let watcher;
|
|
258
|
+
let held = authority.initiallyHeld;
|
|
259
|
+
const pendingPings = /* @__PURE__ */ new Set();
|
|
260
|
+
function readHeld() {
|
|
261
|
+
return closed || watchFailed || authority.readHeld();
|
|
262
|
+
}
|
|
263
|
+
const originalWebSocketSend = server.ws.send;
|
|
264
|
+
function reloadConnectedConsumers() {
|
|
265
|
+
if (server.ws.clients.size > 0) {
|
|
266
|
+
originalWebSocketSend.call(server.ws, { type: "full-reload", path: "*" });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function releasePendingHTTPPings() {
|
|
270
|
+
for (const response of pendingPings) {
|
|
271
|
+
held = readHeld();
|
|
272
|
+
if (held) {
|
|
273
|
+
return "held";
|
|
274
|
+
}
|
|
275
|
+
pendingPings.delete(response);
|
|
276
|
+
response.writeHead(204).end();
|
|
277
|
+
}
|
|
278
|
+
return "released";
|
|
279
|
+
}
|
|
280
|
+
function refreshReadinessAndReleaseConsumers() {
|
|
281
|
+
const previouslyHeld = held;
|
|
282
|
+
held = readHeld();
|
|
283
|
+
if (held) {
|
|
284
|
+
return "held";
|
|
285
|
+
}
|
|
286
|
+
if (!previouslyHeld) {
|
|
287
|
+
return "ready";
|
|
288
|
+
}
|
|
289
|
+
held = readHeld();
|
|
290
|
+
if (held) {
|
|
291
|
+
return "held";
|
|
292
|
+
}
|
|
293
|
+
reloadConnectedConsumers();
|
|
294
|
+
return releasePendingHTTPPings();
|
|
295
|
+
}
|
|
296
|
+
const environments = server.environments;
|
|
297
|
+
const channels = /* @__PURE__ */ new Set([server.ws]);
|
|
298
|
+
for (const environment of Object.values(environments ?? {})) {
|
|
299
|
+
channels.add(environment.hot);
|
|
300
|
+
}
|
|
301
|
+
for (const channel of channels) {
|
|
302
|
+
const original = channel.send;
|
|
303
|
+
channel.send = function(payload, data) {
|
|
304
|
+
if (payload && typeof payload === "object" && "type" in payload && typeof payload.type === "string" && navigationTypes[payload.type]) {
|
|
305
|
+
if (refreshReadinessAndReleaseConsumers() !== "ready" || server.ws.clients.size === 0) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
original.call(this, payload, data);
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
server.middlewares.use((request, response, next) => {
|
|
313
|
+
if (request.headers.accept !== "text/x-vite-ping") {
|
|
314
|
+
next();
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if (refreshReadinessAndReleaseConsumers() !== "held") {
|
|
318
|
+
response.writeHead(204).end();
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
pendingPings.add(response);
|
|
322
|
+
response.once("close", () => pendingPings.delete(response));
|
|
323
|
+
});
|
|
324
|
+
const upgradeHandlers = /* @__PURE__ */ new Map();
|
|
325
|
+
for (const listener of httpServer.rawListeners("upgrade")) {
|
|
326
|
+
const original = listener;
|
|
327
|
+
const gated = function(request, socket, head) {
|
|
328
|
+
if (request.headers["sec-websocket-protocol"] === "vite-ping") {
|
|
329
|
+
if (refreshReadinessAndReleaseConsumers() === "held") {
|
|
330
|
+
socket.destroy();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
original.call(this, request, socket, head);
|
|
335
|
+
};
|
|
336
|
+
upgradeHandlers.set(original, gated);
|
|
337
|
+
httpServer.off("upgrade", original);
|
|
338
|
+
httpServer.on("upgrade", gated);
|
|
339
|
+
}
|
|
340
|
+
const originalClose = server.close;
|
|
341
|
+
function cleanup() {
|
|
342
|
+
if (closed) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
closed = true;
|
|
346
|
+
watcher?.close();
|
|
347
|
+
for (const response of pendingPings) {
|
|
348
|
+
response.destroy();
|
|
349
|
+
}
|
|
350
|
+
pendingPings.clear();
|
|
351
|
+
for (const [original, gated] of upgradeHandlers) {
|
|
352
|
+
httpServer.off("upgrade", gated);
|
|
353
|
+
httpServer.on("upgrade", original);
|
|
354
|
+
}
|
|
355
|
+
httpServer.off("close", cleanup);
|
|
356
|
+
server.close = originalClose;
|
|
357
|
+
}
|
|
358
|
+
server.close = async function() {
|
|
359
|
+
cleanup();
|
|
360
|
+
await originalClose.call(this);
|
|
361
|
+
};
|
|
362
|
+
httpServer.once("close", cleanup);
|
|
363
|
+
try {
|
|
364
|
+
watcher = watch(context.file, { persistent: false }, () => {
|
|
365
|
+
refreshReadinessAndReleaseConsumers();
|
|
366
|
+
});
|
|
367
|
+
watcher.on("error", () => {
|
|
368
|
+
watchFailed = true;
|
|
369
|
+
held = true;
|
|
370
|
+
});
|
|
371
|
+
refreshReadinessAndReleaseConsumers();
|
|
372
|
+
} catch {
|
|
373
|
+
watchFailed = true;
|
|
374
|
+
held = true;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function managedViteFeedback() {
|
|
378
|
+
return {
|
|
379
|
+
name: "omniview-managed-vite-feedback",
|
|
380
|
+
apply: "serve",
|
|
381
|
+
enforce: "pre",
|
|
382
|
+
configureServer(server) {
|
|
383
|
+
attachManagedViteFeedback(server);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
58
388
|
// src/index.ts
|
|
59
|
-
var
|
|
389
|
+
var moduleDirectory = typeof __dirname === "string" ? __dirname : path3.dirname(fileURLToPath(import.meta.url));
|
|
60
390
|
function getShimsDir() {
|
|
61
|
-
const packageRoot =
|
|
62
|
-
return
|
|
391
|
+
const packageRoot = path3.resolve(moduleDirectory, "..");
|
|
392
|
+
return path3.join(packageRoot, "shims");
|
|
63
393
|
}
|
|
64
394
|
function buildShimMap(shimsDir) {
|
|
65
395
|
const map = /* @__PURE__ */ new Map();
|
|
66
396
|
for (const pkg of SHARED_PACKAGES) {
|
|
67
|
-
const shimFile =
|
|
397
|
+
const shimFile = path3.join(shimsDir, `${safeFilename(pkg)}.mjs`);
|
|
68
398
|
map.set(pkg, shimFile);
|
|
69
399
|
}
|
|
70
400
|
return map;
|
|
@@ -75,7 +405,7 @@ function omniviewExternals(options = {}) {
|
|
|
75
405
|
const shimMap = buildShimMap(shimsDir);
|
|
76
406
|
if (options.additionalShared) {
|
|
77
407
|
for (const pkg of options.additionalShared) {
|
|
78
|
-
const shimFile =
|
|
408
|
+
const shimFile = path3.join(shimsDir, `${safeFilename(pkg)}.mjs`);
|
|
79
409
|
shimMap.set(pkg, shimFile);
|
|
80
410
|
}
|
|
81
411
|
}
|
|
@@ -85,8 +415,55 @@ function omniviewExternals(options = {}) {
|
|
|
85
415
|
enforce: "pre",
|
|
86
416
|
// Run before other plugins (especially @vitejs/plugin-react)
|
|
87
417
|
config(config, { command }) {
|
|
418
|
+
const cache = workspaceViteCacheDirectory(process.env.OMNIVIEW_VITE_CACHE_DIRECTORY);
|
|
419
|
+
if (cache) {
|
|
420
|
+
if (config.cacheDir && path3.resolve(config.root ?? process.cwd(), config.cacheDir) !== cache) {
|
|
421
|
+
throw new Error("Plugin Vite cache conflicts with its owned workspace cache");
|
|
422
|
+
}
|
|
423
|
+
config.cacheDir = cache;
|
|
424
|
+
}
|
|
425
|
+
const output = process.env.OMNIVIEW_BUILD_OUTPUT_DIRECTORY;
|
|
426
|
+
if (command === "build" && output) {
|
|
427
|
+
const root = path3.resolve(config.root ?? process.cwd());
|
|
428
|
+
const configured = config.build?.outDir && path3.resolve(root, config.build.outDir);
|
|
429
|
+
if (configured && configured !== path3.join(root, "dist") && configured !== path3.resolve(output)) {
|
|
430
|
+
throw new Error("Plugin distribution path conflicts with controlled workspace output");
|
|
431
|
+
}
|
|
432
|
+
config.build = { ...config.build, outDir: output };
|
|
433
|
+
}
|
|
88
434
|
if (command === "serve") {
|
|
435
|
+
const roots = workspaceViteRoots(process.env.OMNIVIEW_VITE_ALLOWED_ROOTS);
|
|
436
|
+
const ownedPort = workspaceVitePort(process.env.OMNIVIEW_VITE_PORT);
|
|
437
|
+
if (roots) {
|
|
438
|
+
if (!ownedPort) {
|
|
439
|
+
throw new Error("Managed plugin Vite requires its owned OMNIVIEW_VITE_PORT");
|
|
440
|
+
}
|
|
441
|
+
config.server = config.server ?? {};
|
|
442
|
+
if (config.server.port !== void 0 && config.server.port !== ownedPort) {
|
|
443
|
+
throw new Error("Plugin Vite port conflicts with its owned workspace lease");
|
|
444
|
+
}
|
|
445
|
+
if (config.server.hmr === false || typeof config.server.hmr === "object" && (config.server.hmr.clientPort !== void 0 && config.server.hmr.clientPort !== ownedPort || config.server.hmr.port !== void 0 && config.server.hmr.port !== ownedPort || config.server.hmr.host !== void 0 && config.server.hmr.host !== "127.0.0.1" || config.server.hmr.protocol !== void 0 && config.server.hmr.protocol !== "ws")) {
|
|
446
|
+
throw new Error("Plugin Vite HMR conflicts with its owned loopback endpoint");
|
|
447
|
+
}
|
|
448
|
+
config.server.port = ownedPort;
|
|
449
|
+
config.server.strictPort = true;
|
|
450
|
+
config.server.fs = {
|
|
451
|
+
...config.server.fs,
|
|
452
|
+
strict: true,
|
|
453
|
+
allow: [.../* @__PURE__ */ new Set([...config.server.fs?.allow ?? [config.root ?? process.cwd()], ...roots, shimsDir])]
|
|
454
|
+
};
|
|
455
|
+
config.server.hmr = {
|
|
456
|
+
...typeof config.server.hmr === "object" ? config.server.hmr : {},
|
|
457
|
+
host: "127.0.0.1",
|
|
458
|
+
protocol: "ws",
|
|
459
|
+
clientPort: ownedPort
|
|
460
|
+
};
|
|
461
|
+
}
|
|
89
462
|
config.optimizeDeps = config.optimizeDeps ?? {};
|
|
463
|
+
config.optimizeDeps.exclude = [.../* @__PURE__ */ new Set([...config.optimizeDeps.exclude ?? [], ...allPackages])];
|
|
464
|
+
if (roots) {
|
|
465
|
+
config.optimizeDeps.force = true;
|
|
466
|
+
}
|
|
90
467
|
config.optimizeDeps.esbuildOptions = config.optimizeDeps.esbuildOptions ?? {};
|
|
91
468
|
config.optimizeDeps.esbuildOptions.plugins = [
|
|
92
469
|
...config.optimizeDeps.esbuildOptions.plugins ?? [],
|
|
@@ -116,21 +493,41 @@ function omniviewExternals(options = {}) {
|
|
|
116
493
|
} else if (typeof existing === "function") {
|
|
117
494
|
const originalFn = existing;
|
|
118
495
|
config.build.rollupOptions.external = (source, importer, isResolved) => {
|
|
119
|
-
if (sharedSet.has(source))
|
|
496
|
+
if (sharedSet.has(source)) {
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
120
499
|
return originalFn(source, importer, isResolved);
|
|
121
500
|
};
|
|
122
501
|
} else if (existing === void 0 || existing === null) {
|
|
123
502
|
config.build.rollupOptions.external = [...allPackages];
|
|
124
503
|
} else {
|
|
125
504
|
config.build.rollupOptions.external = (source) => {
|
|
126
|
-
if (sharedSet.has(source))
|
|
127
|
-
|
|
128
|
-
|
|
505
|
+
if (sharedSet.has(source)) {
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
if (typeof existing === "string") {
|
|
509
|
+
return source === existing;
|
|
510
|
+
}
|
|
511
|
+
if (existing instanceof RegExp) {
|
|
512
|
+
return existing.test(source);
|
|
513
|
+
}
|
|
129
514
|
return false;
|
|
130
515
|
};
|
|
131
516
|
}
|
|
132
517
|
}
|
|
133
518
|
},
|
|
519
|
+
configResolved(config) {
|
|
520
|
+
if (config.command !== "serve" || !config.optimizeDeps.include) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
config.optimizeDeps.include = config.optimizeDeps.include.filter((dependency) => {
|
|
524
|
+
const target = dependency.slice(dependency.lastIndexOf(">") + 1).trim();
|
|
525
|
+
return !sharedSet.has(target);
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
configureServer(server) {
|
|
529
|
+
attachManagedViteFeedback(server);
|
|
530
|
+
},
|
|
134
531
|
resolveId(source) {
|
|
135
532
|
if (sharedSet.has(source)) {
|
|
136
533
|
const shimPath = shimMap.get(source);
|
|
@@ -146,6 +543,7 @@ var index_default = omniviewExternals;
|
|
|
146
543
|
export {
|
|
147
544
|
SHARED_PACKAGES,
|
|
148
545
|
index_default as default,
|
|
546
|
+
managedViteFeedback,
|
|
149
547
|
omniviewExternals,
|
|
150
548
|
safeFilename
|
|
151
549
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omniviewdev/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"shims"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "pnpm run generate-shims && pnpm run check-shims && tsup src/index.ts --format esm,cjs --dts --clean",
|
|
22
|
+
"build": "pnpm run generate-shims && pnpm run check-shims && node ../../scripts/build-tsup.mjs src/index.ts --format esm,cjs --dts --clean",
|
|
23
23
|
"check-shims": "tsx scripts/check-shim-exports.ts",
|
|
24
24
|
"generate-shims": "tsx scripts/generate-shims.ts",
|
|
25
25
|
"test": "tsx --test scripts/*.test.ts",
|
|
@@ -18,6 +18,8 @@ export const AspectRatio = mod.AspectRatio;
|
|
|
18
18
|
export const Autocomplete = mod.Autocomplete;
|
|
19
19
|
export const Avatar = mod.Avatar;
|
|
20
20
|
export const AvatarGroup = mod.AvatarGroup;
|
|
21
|
+
export const BUILT_IN_THEMES = mod.BUILT_IN_THEMES;
|
|
22
|
+
export const BUILT_IN_THEME_IDS = mod.BUILT_IN_THEME_IDS;
|
|
21
23
|
export const BUILT_IN_THEME_MODES = mod.BUILT_IN_THEME_MODES;
|
|
22
24
|
export const Badge = mod.Badge;
|
|
23
25
|
export const Banner = mod.Banner;
|
|
@@ -120,6 +122,7 @@ export const TextArea = mod.TextArea;
|
|
|
120
122
|
export const TextField = mod.TextField;
|
|
121
123
|
export const ThemeProvider = mod.ThemeProvider;
|
|
122
124
|
export const ThemeSwitcher = mod.ThemeSwitcher;
|
|
125
|
+
export const ThemeValidationError = mod.ThemeValidationError;
|
|
123
126
|
export const TimeColumns = mod.TimeColumns;
|
|
124
127
|
export const TimePicker = mod.TimePicker;
|
|
125
128
|
export const Timeline = mod.Timeline;
|
|
@@ -134,10 +137,12 @@ export const Underline = mod.Underline;
|
|
|
134
137
|
export const buildSections = mod.buildSections;
|
|
135
138
|
export const computeTabSegments = mod.computeTabSegments;
|
|
136
139
|
export const createThemeRegistry = mod.createThemeRegistry;
|
|
140
|
+
export const createThemeRootApplier = mod.createThemeRootApplier;
|
|
137
141
|
export const fileTypeLabel = mod.fileTypeLabel;
|
|
138
142
|
export const formatBytes = mod.formatBytes;
|
|
139
143
|
export const formatDate = mod.formatDate;
|
|
140
144
|
export const getDaysInMonth = mod.getDaysInMonth;
|
|
145
|
+
export const isBuiltInThemeId = mod.isBuiltInThemeId;
|
|
141
146
|
export const isLeapYear = mod.isLeapYear;
|
|
142
147
|
export const statusToColor = mod.statusToColor;
|
|
143
148
|
export const themeRegistry = mod.themeRegistry;
|
|
@@ -171,5 +176,6 @@ export const useTreeConfig = mod.useTreeConfig;
|
|
|
171
176
|
export const useTreeItem = mod.useTreeItem;
|
|
172
177
|
export const useTreeStoreContext = mod.useTreeStoreContext;
|
|
173
178
|
export const validateSections = mod.validateSections;
|
|
179
|
+
export const validateThemeDefinition = mod.validateThemeDefinition;
|
|
174
180
|
|
|
175
181
|
export default mod.default !== undefined ? mod.default : mod;
|
|
@@ -14,6 +14,7 @@ export const DataClient = mod.DataClient;
|
|
|
14
14
|
export const DevServerManager = mod.DevServerManager;
|
|
15
15
|
export const DiagnosticsClient = mod.DiagnosticsClient;
|
|
16
16
|
export const ExecClient = mod.ExecClient;
|
|
17
|
+
export const GetInstanceInfo = mod.GetInstanceInfo;
|
|
17
18
|
export const GetOperatingSystem = mod.GetOperatingSystem;
|
|
18
19
|
export const GraphClient = mod.GraphClient;
|
|
19
20
|
export const LogsClient = mod.LogsClient;
|
|
@@ -37,7 +37,6 @@ export const DeleteInput = mod.DeleteInput;
|
|
|
37
37
|
export const DeleteResult = mod.DeleteResult;
|
|
38
38
|
export const DependencyNode = mod.DependencyNode;
|
|
39
39
|
export const DependencyTree = mod.DependencyTree;
|
|
40
|
-
export const DevInfoFile = mod.DevInfoFile;
|
|
41
40
|
export const DevProcessStatus = mod.DevProcessStatus;
|
|
42
41
|
export const DevServerErrorPayload = mod.DevServerErrorPayload;
|
|
43
42
|
export const DevServerLogEntry = mod.DevServerLogEntry;
|
|
@@ -67,6 +66,7 @@ export const GraphNode = mod.GraphNode;
|
|
|
67
66
|
export const Handler = mod.Handler;
|
|
68
67
|
export const HealthCondition = mod.HealthCondition;
|
|
69
68
|
export const HealthStatus = mod.HealthStatus;
|
|
69
|
+
export const LifecycleStage = mod.LifecycleStage;
|
|
70
70
|
export const ListInput = mod.ListInput;
|
|
71
71
|
export const ListResult = mod.ListResult;
|
|
72
72
|
export const LogSession = mod.LogSession;
|
|
@@ -120,6 +120,7 @@ export const Setting = mod.Setting;
|
|
|
120
120
|
export const SettingFileSelection = mod.SettingFileSelection;
|
|
121
121
|
export const SettingOption = mod.SettingOption;
|
|
122
122
|
export const SettingType = mod.SettingType;
|
|
123
|
+
export const StateIsolationProvenance = mod.StateIsolationProvenance;
|
|
123
124
|
export const Subgraph = mod.Subgraph;
|
|
124
125
|
export const SubgraphNode = mod.SubgraphNode;
|
|
125
126
|
export const TimeSeries = mod.TimeSeries;
|
|
@@ -143,6 +144,7 @@ export const time = mod.time;
|
|
|
143
144
|
export const types = mod.types;
|
|
144
145
|
export const ui = mod.ui;
|
|
145
146
|
export const utils = mod.utils;
|
|
147
|
+
export const DevInfoFile = mod.DevInfoFile;
|
|
146
148
|
export const main = mod.main;
|
|
147
149
|
export const plugin = mod.plugin;
|
|
148
150
|
|