mokup 2.3.0 → 2.3.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/bundle.cjs +2 -6
- package/dist/bundle.d.cts +1 -27
- package/dist/bundle.d.mts +1 -27
- package/dist/bundle.d.ts +1 -27
- package/dist/bundle.mjs +1 -5
- package/dist/cli-bin.d.cts +1 -0
- package/dist/cli-bin.d.mts +1 -0
- package/dist/cli-bin.d.ts +1 -0
- package/dist/index.cjs +8 -159
- package/dist/index.d.cts +7 -48
- package/dist/index.d.mts +7 -48
- package/dist/index.d.ts +7 -48
- package/dist/index.mjs +8 -159
- package/dist/shared/mokup.BZpTBIrj.mjs +10 -0
- package/dist/shared/mokup.CO9HhGox.cjs +13 -0
- package/dist/vite.cjs +53 -153
- package/dist/vite.d.cts +2 -7
- package/dist/vite.d.mts +3 -6
- package/dist/vite.d.ts +2 -7
- package/dist/vite.mjs +22 -122
- package/dist/webpack.cjs +29 -38
- package/dist/webpack.d.cts +3 -6
- package/dist/webpack.d.mts +3 -6
- package/dist/webpack.d.ts +3 -6
- package/dist/webpack.mjs +5 -14
- package/package.json +7 -13
- package/dist/shared/mokup.BXPIIxtS.cjs +0 -47
- package/dist/shared/mokup.C-hwskJ_.mjs +0 -1790
- package/dist/shared/mokup.CsBTglhs.mjs +0 -45
- package/dist/shared/mokup.DXCs9518.cjs +0 -1810
- package/dist/shared/mokup.Dkqu10Hk.d.cts +0 -379
- package/dist/shared/mokup.Dkqu10Hk.d.mts +0 -379
- package/dist/shared/mokup.Dkqu10Hk.d.ts +0 -379
- package/dist/shared/mokup.Dy9VDphS.cjs +0 -181
- package/dist/shared/mokup.Iqw32OxC.mjs +0 -174
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { join } from '@mokup/shared/pathe';
|
|
3
|
+
|
|
4
|
+
const require$1 = createRequire(import.meta.url);
|
|
5
|
+
function resolvePlaygroundDist() {
|
|
6
|
+
const pkgPath = require$1.resolve("@mokup/playground/package.json");
|
|
7
|
+
return join(pkgPath, "..", "dist");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { resolvePlaygroundDist as r };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const node_module = require('node:module');
|
|
4
|
+
const pathe = require('@mokup/shared/pathe');
|
|
5
|
+
|
|
6
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.CO9HhGox.cjs', document.baseURI).href)));
|
|
8
|
+
function resolvePlaygroundDist() {
|
|
9
|
+
const pkgPath = require$1.resolve("@mokup/playground/package.json");
|
|
10
|
+
return pathe.join(pkgPath, "..", "dist");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.resolvePlaygroundDist = resolvePlaygroundDist;
|
package/dist/vite.cjs
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const process = require('node:process');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const pathe = require('@mokup/shared/pathe');
|
|
7
|
-
const scanner = require('./shared/mokup.DXCs9518.cjs');
|
|
8
|
-
const playgroundGrouping = require('@mokup/shared/playground-grouping');
|
|
9
|
-
const logger = require('@mokup/shared/logger');
|
|
4
|
+
const core = require('@mokup/core');
|
|
5
|
+
const assets = require('./shared/mokup.CO9HhGox.cjs');
|
|
10
6
|
const pc = require('picocolors');
|
|
11
7
|
const node_path = require('node:path');
|
|
12
8
|
const chokidar = require('@mokup/shared/chokidar');
|
|
13
|
-
require('
|
|
14
|
-
const pathUtils = require('@mokup/shared/path-utils');
|
|
15
|
-
const timing = require('@mokup/shared/timing');
|
|
9
|
+
const node_fs = require('node:fs');
|
|
16
10
|
const node_url = require('node:url');
|
|
17
11
|
require('node:module');
|
|
18
|
-
require('
|
|
19
|
-
require('@mokup/shared/hono');
|
|
20
|
-
require('@mokup/shared/esbuild');
|
|
21
|
-
require('@mokup/shared/jsonc-parser');
|
|
22
|
-
require('@mokup/runtime');
|
|
12
|
+
require('@mokup/shared/pathe');
|
|
23
13
|
|
|
24
14
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
25
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -27,79 +17,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
27
17
|
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
28
18
|
const chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
|
|
29
19
|
|
|
30
|
-
function resolvePlaygroundOutDir(outDir, playgroundPath) {
|
|
31
|
-
const normalized = scanner.normalizePlaygroundPath(playgroundPath);
|
|
32
|
-
const trimmed = normalized.replace(/^\/+/, "");
|
|
33
|
-
return trimmed ? pathe.join(outDir, pathe.normalize(trimmed)) : outDir;
|
|
34
|
-
}
|
|
35
|
-
function stripSwLifecycle(html) {
|
|
36
|
-
return html.replace(
|
|
37
|
-
/<script[^>]*mokup-sw-lifecycle\.js[^>]*><\/script>\s*/gi,
|
|
38
|
-
""
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
async function writeRoutesPayload(params, targetDir) {
|
|
42
|
-
const baseRoot = playgroundGrouping.resolveGroupRoot(params.dirs, params.root);
|
|
43
|
-
const groups = playgroundGrouping.resolveGroups(params.dirs, baseRoot);
|
|
44
|
-
const basePath = scanner.resolvePlaygroundRequestPath(params.base, params.playgroundPath);
|
|
45
|
-
const payload = {
|
|
46
|
-
basePath,
|
|
47
|
-
root: baseRoot,
|
|
48
|
-
count: params.routes.length,
|
|
49
|
-
groups: groups.map((group) => ({ key: group.key, label: group.label })),
|
|
50
|
-
routes: params.routes.map((route) => scanner.toPlaygroundRoute(route, baseRoot, groups)),
|
|
51
|
-
disabled: params.disabledRoutes.map(
|
|
52
|
-
(route) => scanner.toPlaygroundDisabledRoute(route, baseRoot, groups)
|
|
53
|
-
),
|
|
54
|
-
ignored: params.ignoredRoutes.map(
|
|
55
|
-
(route) => scanner.toPlaygroundIgnoredRoute(route, baseRoot, groups)
|
|
56
|
-
),
|
|
57
|
-
configs: params.configFiles.map((entry) => scanner.toPlaygroundConfigFile(entry, baseRoot, groups)),
|
|
58
|
-
disabledConfigs: params.disabledConfigFiles.map(
|
|
59
|
-
(entry) => scanner.toPlaygroundConfigFile(entry, baseRoot, groups)
|
|
60
|
-
)
|
|
61
|
-
};
|
|
62
|
-
await node_fs.promises.writeFile(
|
|
63
|
-
pathe.join(targetDir, "routes"),
|
|
64
|
-
JSON.stringify(payload, null, 2),
|
|
65
|
-
"utf8"
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
async function updateIndexHtml(targetDir, swScript) {
|
|
69
|
-
const indexPath = pathe.join(targetDir, "index.html");
|
|
70
|
-
const html = await node_fs.promises.readFile(indexPath, "utf8");
|
|
71
|
-
const cleaned = stripSwLifecycle(html);
|
|
72
|
-
const output = swScript ? scanner.injectPlaygroundSw(cleaned, swScript) : cleaned;
|
|
73
|
-
await node_fs.promises.writeFile(indexPath, output, "utf8");
|
|
74
|
-
}
|
|
75
|
-
async function removeLegacySwAsset(targetDir) {
|
|
76
|
-
const legacyFiles = [
|
|
77
|
-
pathe.join(targetDir, "assets", "mokup-sw-lifecycle.js"),
|
|
78
|
-
pathe.join(targetDir, "assets", "mokup-sw-lifecycle.js.map")
|
|
79
|
-
];
|
|
80
|
-
await Promise.all(legacyFiles.map((file) => node_fs.promises.rm(file, { force: true })));
|
|
81
|
-
}
|
|
82
|
-
async function writePlaygroundBuild(params) {
|
|
83
|
-
const distDir = scanner.resolvePlaygroundDist();
|
|
84
|
-
const targetDir = resolvePlaygroundOutDir(params.outDir, params.playgroundPath);
|
|
85
|
-
if (targetDir === params.outDir) {
|
|
86
|
-
params.logger.error("Playground build path resolves to the Vite outDir. Aborting output.");
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
await node_fs.promises.stat(distDir);
|
|
91
|
-
} catch (error) {
|
|
92
|
-
params.logger.error("Failed to locate playground assets:", error);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
await node_fs.promises.rm(targetDir, { recursive: true, force: true });
|
|
96
|
-
await node_fs.promises.mkdir(params.outDir, { recursive: true });
|
|
97
|
-
await node_fs.promises.cp(distDir, targetDir, { recursive: true });
|
|
98
|
-
await removeLegacySwAsset(targetDir);
|
|
99
|
-
await updateIndexHtml(targetDir, params.swScript);
|
|
100
|
-
await writeRoutesPayload(params, targetDir);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
20
|
const legacyEntryKeys = [
|
|
104
21
|
"dir",
|
|
105
22
|
"prefix",
|
|
@@ -231,7 +148,15 @@ function isViteDevServer(server) {
|
|
|
231
148
|
}
|
|
232
149
|
|
|
233
150
|
function createRouteRefresher(params) {
|
|
234
|
-
const {
|
|
151
|
+
const {
|
|
152
|
+
state,
|
|
153
|
+
optionList,
|
|
154
|
+
root,
|
|
155
|
+
logger,
|
|
156
|
+
enableViteMiddleware,
|
|
157
|
+
virtualModuleIds,
|
|
158
|
+
reloadOnChange = false
|
|
159
|
+
} = params;
|
|
235
160
|
return async (server, options) => {
|
|
236
161
|
const collected = [];
|
|
237
162
|
const collectedServer = [];
|
|
@@ -240,7 +165,7 @@ function createRouteRefresher(params) {
|
|
|
240
165
|
const collectedIgnored = [];
|
|
241
166
|
const collectedConfigs = [];
|
|
242
167
|
for (const entry of optionList) {
|
|
243
|
-
const dirs =
|
|
168
|
+
const dirs = core.resolveDirs(entry.dir, root());
|
|
244
169
|
const scanParams = {
|
|
245
170
|
dirs,
|
|
246
171
|
prefix: entry.prefix ?? "",
|
|
@@ -261,7 +186,7 @@ function createRouteRefresher(params) {
|
|
|
261
186
|
if (server) {
|
|
262
187
|
scanParams.server = server;
|
|
263
188
|
}
|
|
264
|
-
const scanned = await
|
|
189
|
+
const scanned = await core.scanRoutes(scanParams);
|
|
265
190
|
collected.push(...scanned);
|
|
266
191
|
if (entry.mode === "sw") {
|
|
267
192
|
collectedSw.push(...scanned);
|
|
@@ -272,16 +197,16 @@ function createRouteRefresher(params) {
|
|
|
272
197
|
collectedServer.push(...scanned);
|
|
273
198
|
}
|
|
274
199
|
}
|
|
275
|
-
state.routes =
|
|
276
|
-
state.serverRoutes =
|
|
277
|
-
state.swRoutes =
|
|
200
|
+
state.routes = core.sortRoutes(collected);
|
|
201
|
+
state.serverRoutes = core.sortRoutes(collectedServer);
|
|
202
|
+
state.swRoutes = core.sortRoutes(collectedSw);
|
|
278
203
|
state.disabledRoutes = collectedDisabled;
|
|
279
204
|
state.ignoredRoutes = collectedIgnored;
|
|
280
205
|
const configMap = new Map(collectedConfigs.map((entry) => [entry.file, entry]));
|
|
281
206
|
const resolvedConfigs = Array.from(configMap.values());
|
|
282
207
|
state.configFiles = resolvedConfigs.filter((entry) => entry.enabled);
|
|
283
208
|
state.disabledConfigFiles = resolvedConfigs.filter((entry) => !entry.enabled);
|
|
284
|
-
state.app = enableViteMiddleware && state.serverRoutes.length > 0 ?
|
|
209
|
+
state.app = enableViteMiddleware && state.serverRoutes.length > 0 ? core.createHonoApp(state.serverRoutes) : null;
|
|
285
210
|
const signature = buildRouteSignature(
|
|
286
211
|
state.routes,
|
|
287
212
|
state.disabledRoutes,
|
|
@@ -305,6 +230,9 @@ function createRouteRefresher(params) {
|
|
|
305
230
|
}
|
|
306
231
|
}
|
|
307
232
|
}
|
|
233
|
+
if (reloadOnChange) {
|
|
234
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
235
|
+
}
|
|
308
236
|
}
|
|
309
237
|
}
|
|
310
238
|
state.lastSignature = signature;
|
|
@@ -316,7 +244,7 @@ function createDirResolver(optionList, root) {
|
|
|
316
244
|
const dirs = [];
|
|
317
245
|
const seen = /* @__PURE__ */ new Set();
|
|
318
246
|
for (const entry of optionList) {
|
|
319
|
-
for (const dir of
|
|
247
|
+
for (const dir of core.resolveDirs(entry.dir, root())) {
|
|
320
248
|
if (seen.has(dir)) {
|
|
321
249
|
continue;
|
|
322
250
|
}
|
|
@@ -365,37 +293,6 @@ function addMiddlewareFirst(server, middleware) {
|
|
|
365
293
|
server.middlewares.use(middleware);
|
|
366
294
|
}
|
|
367
295
|
|
|
368
|
-
const portPattern = /:(?<port>\d{2,5})/g;
|
|
369
|
-
const escapeCode = 27;
|
|
370
|
-
function stripAnsi(value) {
|
|
371
|
-
let output = "";
|
|
372
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
373
|
-
const code = value.charCodeAt(index);
|
|
374
|
-
if (code === escapeCode && value[index + 1] === "[") {
|
|
375
|
-
index += 1;
|
|
376
|
-
while (index < value.length && value[index] !== "m") {
|
|
377
|
-
index += 1;
|
|
378
|
-
}
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
output += value[index];
|
|
382
|
-
}
|
|
383
|
-
return output;
|
|
384
|
-
}
|
|
385
|
-
function formatOutputLine(line, options) {
|
|
386
|
-
const { arrowToken, formattedArrow, labels, formatLabel, formatPort } = options;
|
|
387
|
-
let output = formattedArrow ? line.replaceAll(arrowToken, formattedArrow) : line;
|
|
388
|
-
if (labels && formatLabel) {
|
|
389
|
-
for (const label of labels) {
|
|
390
|
-
output = output.replaceAll(label, formatLabel(label));
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
if (formatPort) {
|
|
394
|
-
output = output.replace(portPattern, (_match, port) => `:${formatPort(port)}`);
|
|
395
|
-
}
|
|
396
|
-
return output;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
296
|
const arrowToken = "\u279C";
|
|
400
297
|
const playgroundLabel = "Mokup Playground";
|
|
401
298
|
const coloredArrow = pc__default.green(arrowToken);
|
|
@@ -432,7 +329,7 @@ function patchPlaygroundPrintUrls(server, playgroundPath) {
|
|
|
432
329
|
const coloredUrl = pc__default.magenta(outputUrl);
|
|
433
330
|
const playgroundLine = ` ${arrowToken} ${playgroundLabel}: ${coloredUrl}`;
|
|
434
331
|
const arrowPrefix = ` ${arrowToken} `;
|
|
435
|
-
const findIndex = (needle) => lines.findIndex((args) => stripAnsi(args[0]).includes(needle));
|
|
332
|
+
const findIndex = (needle) => lines.findIndex((args) => core.stripAnsi(args[0]).includes(needle));
|
|
436
333
|
const networkIndex = findIndex(`${arrowPrefix}Network:`);
|
|
437
334
|
const localIndex = findIndex(`${arrowPrefix}Local:`);
|
|
438
335
|
const insertIndex = networkIndex >= 0 ? networkIndex + 1 : localIndex >= 0 ? localIndex + 1 : lines.length;
|
|
@@ -441,7 +338,7 @@ function patchPlaygroundPrintUrls(server, playgroundPath) {
|
|
|
441
338
|
for (const args of outputLines) {
|
|
442
339
|
if (typeof args[0] === "string") {
|
|
443
340
|
const nextArgs = args.slice();
|
|
444
|
-
nextArgs[0] = formatOutputLine(nextArgs[0], formatOptions);
|
|
341
|
+
nextArgs[0] = core.formatOutputLine(nextArgs[0], formatOptions);
|
|
445
342
|
originalInfo(...nextArgs);
|
|
446
343
|
} else {
|
|
447
344
|
originalInfo(...args);
|
|
@@ -473,12 +370,12 @@ function normalizeRawWatcherPath(rawPath) {
|
|
|
473
370
|
return "";
|
|
474
371
|
}
|
|
475
372
|
function setupViteWatchers(params) {
|
|
476
|
-
const scheduleRefresh =
|
|
373
|
+
const scheduleRefresh = core.createDebouncer(80, () => {
|
|
477
374
|
void params.refresh({ force: true });
|
|
478
375
|
});
|
|
479
376
|
const handleWatchedFile = (file) => {
|
|
480
377
|
const resolvedFile = normalizeWatcherFile(file, params.server.config.root ?? params.root);
|
|
481
|
-
if (
|
|
378
|
+
if (core.isInDirs(resolvedFile, params.dirs)) {
|
|
482
379
|
scheduleRefresh();
|
|
483
380
|
}
|
|
484
381
|
};
|
|
@@ -496,19 +393,19 @@ function setupViteWatchers(params) {
|
|
|
496
393
|
}
|
|
497
394
|
const baseDir = typeof details === "object" && details && "watchedPath" in details ? details.watchedPath ?? (params.server.config.root ?? params.root) : params.server.config.root ?? params.root;
|
|
498
395
|
const resolvedFile = normalizeWatcherFile(candidate, baseDir);
|
|
499
|
-
if (
|
|
396
|
+
if (core.isInDirs(resolvedFile, params.dirs)) {
|
|
500
397
|
scheduleRefresh();
|
|
501
398
|
}
|
|
502
399
|
});
|
|
503
400
|
}
|
|
504
401
|
function setupPreviewWatchers(params) {
|
|
505
402
|
const watcher = chokidar__default.watch(params.dirs, { ignoreInitial: true });
|
|
506
|
-
const scheduleRefresh =
|
|
403
|
+
const scheduleRefresh = core.createDebouncer(80, () => {
|
|
507
404
|
void params.refresh({ force: true });
|
|
508
405
|
});
|
|
509
406
|
const handleWatchedFile = (file) => {
|
|
510
407
|
const resolvedFile = normalizeWatcherFile(file, params.server.config.root ?? params.root);
|
|
511
|
-
if (
|
|
408
|
+
if (core.isInDirs(resolvedFile, params.dirs)) {
|
|
512
409
|
scheduleRefresh();
|
|
513
410
|
}
|
|
514
411
|
};
|
|
@@ -525,7 +422,7 @@ function setupPreviewWatchers(params) {
|
|
|
525
422
|
}
|
|
526
423
|
const baseDir = typeof details === "object" && details && "watchedPath" in details ? details.watchedPath ?? (params.server.config.root ?? params.root) : params.server.config.root ?? params.root;
|
|
527
424
|
const resolvedFile = normalizeWatcherFile(candidate, baseDir);
|
|
528
|
-
if (
|
|
425
|
+
if (core.isInDirs(resolvedFile, params.dirs)) {
|
|
529
426
|
scheduleRefresh();
|
|
530
427
|
}
|
|
531
428
|
});
|
|
@@ -566,7 +463,7 @@ async function configureDevServer(params) {
|
|
|
566
463
|
return next();
|
|
567
464
|
}
|
|
568
465
|
try {
|
|
569
|
-
const code =
|
|
466
|
+
const code = core.buildSwScript({
|
|
570
467
|
routes: state.swRoutes,
|
|
571
468
|
root,
|
|
572
469
|
runtimeImportPath: resolveSwRuntimeImportPath(base),
|
|
@@ -586,7 +483,7 @@ async function configureDevServer(params) {
|
|
|
586
483
|
});
|
|
587
484
|
}
|
|
588
485
|
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
589
|
-
server.middlewares.use(
|
|
486
|
+
server.middlewares.use(core.createMiddleware(() => state.app, logger));
|
|
590
487
|
}
|
|
591
488
|
if (!watchEnabled) {
|
|
592
489
|
return;
|
|
@@ -625,7 +522,7 @@ async function configurePreviewServer(params) {
|
|
|
625
522
|
return next();
|
|
626
523
|
}
|
|
627
524
|
try {
|
|
628
|
-
const code =
|
|
525
|
+
const code = core.buildSwScript({
|
|
629
526
|
routes: state.swRoutes,
|
|
630
527
|
root,
|
|
631
528
|
basePaths: swConfig?.basePaths ?? []
|
|
@@ -643,7 +540,7 @@ async function configurePreviewServer(params) {
|
|
|
643
540
|
});
|
|
644
541
|
}
|
|
645
542
|
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
646
|
-
server.middlewares.use(
|
|
543
|
+
server.middlewares.use(core.createMiddleware(() => state.app, logger));
|
|
647
544
|
}
|
|
648
545
|
if (!watchEnabled) {
|
|
649
546
|
return null;
|
|
@@ -856,11 +753,11 @@ function createMokupPlugin(options = {}) {
|
|
|
856
753
|
const optionList = normalizeOptions(normalizedOptions);
|
|
857
754
|
const logEnabled = optionList.every((entry) => entry.log !== false);
|
|
858
755
|
const watchEnabled = optionList.every((entry) => entry.watch !== false);
|
|
859
|
-
const playgroundConfig =
|
|
860
|
-
const logger
|
|
756
|
+
const playgroundConfig = core.resolvePlaygroundOptions(normalizedOptions.playground);
|
|
757
|
+
const logger = core.createLogger(logEnabled);
|
|
861
758
|
const hasSwEntries = optionList.some((entry) => entry.mode === "sw");
|
|
862
|
-
const swConfig =
|
|
863
|
-
const unregisterConfig =
|
|
759
|
+
const swConfig = core.resolveSwConfig(optionList, logger);
|
|
760
|
+
const unregisterConfig = core.resolveSwUnregisterConfig(optionList, logger);
|
|
864
761
|
const resolveAllDirs = createDirResolver(optionList, () => root);
|
|
865
762
|
const hasSwRoutes = () => !!swConfig && state.swRoutes.length > 0;
|
|
866
763
|
const { resolveSwRequestPath, resolveSwRegisterScope } = createSwPathResolver(() => base);
|
|
@@ -876,14 +773,14 @@ function createMokupPlugin(options = {}) {
|
|
|
876
773
|
const resolvedBundleVirtualId = `\0${bundleVirtualId}`;
|
|
877
774
|
let swLifecycleFileName = null;
|
|
878
775
|
let swLifecycleScript = null;
|
|
879
|
-
const playgroundMiddleware =
|
|
776
|
+
const playgroundMiddleware = core.createPlaygroundMiddleware({
|
|
880
777
|
getRoutes: () => state.routes,
|
|
881
778
|
getDisabledRoutes: () => state.disabledRoutes,
|
|
882
779
|
getIgnoredRoutes: () => state.ignoredRoutes,
|
|
883
780
|
getConfigFiles: () => state.configFiles,
|
|
884
781
|
getDisabledConfigFiles: () => state.disabledConfigFiles,
|
|
885
782
|
config: playgroundConfig,
|
|
886
|
-
logger
|
|
783
|
+
logger,
|
|
887
784
|
getServer: () => currentServer,
|
|
888
785
|
getDirs: () => resolveAllDirs(),
|
|
889
786
|
getSwScript: () => buildSwLifecycleScript({
|
|
@@ -894,15 +791,17 @@ function createMokupPlugin(options = {}) {
|
|
|
894
791
|
hasSwRoutes: hasSwRoutes(),
|
|
895
792
|
resolveRequestPath: resolveSwRequestPath,
|
|
896
793
|
resolveRegisterScope: resolveSwRegisterScope
|
|
897
|
-
})
|
|
794
|
+
}),
|
|
795
|
+
resolvePlaygroundDist: assets.resolvePlaygroundDist
|
|
898
796
|
});
|
|
899
797
|
const refreshRoutes = createRouteRefresher({
|
|
900
798
|
state,
|
|
901
799
|
optionList,
|
|
902
800
|
root: () => root,
|
|
903
|
-
logger
|
|
801
|
+
logger,
|
|
904
802
|
enableViteMiddleware,
|
|
905
|
-
virtualModuleIds: [resolvedBundleVirtualId]
|
|
803
|
+
virtualModuleIds: [resolvedBundleVirtualId],
|
|
804
|
+
reloadOnChange: runtime === "worker"
|
|
906
805
|
});
|
|
907
806
|
return {
|
|
908
807
|
name: "mokup:vite",
|
|
@@ -941,7 +840,7 @@ function createMokupPlugin(options = {}) {
|
|
|
941
840
|
for (const config of state.disabledConfigFiles) {
|
|
942
841
|
this.addWatchFile(config.file);
|
|
943
842
|
}
|
|
944
|
-
return
|
|
843
|
+
return core.buildBundleModule({ routes: state.serverRoutes, root });
|
|
945
844
|
}
|
|
946
845
|
if (id !== resolvedSwVirtualId) {
|
|
947
846
|
if (id !== resolvedSwLifecycleVirtualId) {
|
|
@@ -967,7 +866,7 @@ function createMokupPlugin(options = {}) {
|
|
|
967
866
|
if (state.swRoutes.length === 0) {
|
|
968
867
|
await refreshRoutes();
|
|
969
868
|
}
|
|
970
|
-
return
|
|
869
|
+
return core.buildSwScript({
|
|
971
870
|
routes: state.swRoutes,
|
|
972
871
|
root,
|
|
973
872
|
basePaths: swConfig?.basePaths ?? []
|
|
@@ -1067,7 +966,7 @@ function createMokupPlugin(options = {}) {
|
|
|
1067
966
|
state,
|
|
1068
967
|
root,
|
|
1069
968
|
base,
|
|
1070
|
-
logger
|
|
969
|
+
logger,
|
|
1071
970
|
playgroundConfig,
|
|
1072
971
|
playgroundMiddleware,
|
|
1073
972
|
swConfig,
|
|
@@ -1085,7 +984,7 @@ function createMokupPlugin(options = {}) {
|
|
|
1085
984
|
state,
|
|
1086
985
|
root,
|
|
1087
986
|
base,
|
|
1088
|
-
logger
|
|
987
|
+
logger,
|
|
1089
988
|
playgroundMiddleware,
|
|
1090
989
|
swConfig,
|
|
1091
990
|
hasSwRoutes,
|
|
@@ -1113,7 +1012,7 @@ function createMokupPlugin(options = {}) {
|
|
|
1113
1012
|
resolveRequestPath: resolveSwRequestPath,
|
|
1114
1013
|
resolveRegisterScope: resolveSwRegisterScope
|
|
1115
1014
|
});
|
|
1116
|
-
await writePlaygroundBuild({
|
|
1015
|
+
await core.writePlaygroundBuild({
|
|
1117
1016
|
outDir,
|
|
1118
1017
|
base,
|
|
1119
1018
|
playgroundPath: playgroundConfig.path,
|
|
@@ -1125,7 +1024,8 @@ function createMokupPlugin(options = {}) {
|
|
|
1125
1024
|
disabledConfigFiles: state.disabledConfigFiles,
|
|
1126
1025
|
dirs: resolveAllDirs(),
|
|
1127
1026
|
swScript,
|
|
1128
|
-
logger
|
|
1027
|
+
logger,
|
|
1028
|
+
resolvePlaygroundDist: assets.resolvePlaygroundDist
|
|
1129
1029
|
});
|
|
1130
1030
|
}
|
|
1131
1031
|
};
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { MokupPluginOptions } from '@mokup/core';
|
|
2
|
+
export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput, ViteRuntime } from '@mokup/core';
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
|
-
export { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
5
|
-
export { PlaygroundOptionsInput } from '@mokup/shared';
|
|
6
|
-
import '@mokup/runtime';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Create the mokup Vite plugin.
|
|
@@ -25,6 +22,4 @@ import '@mokup/runtime';
|
|
|
25
22
|
*/
|
|
26
23
|
declare function createMokupPlugin(options?: MokupPluginOptions): Plugin;
|
|
27
24
|
|
|
28
|
-
// @ts-ignore
|
|
29
25
|
export = createMokupPlugin;
|
|
30
|
-
export { MokupPluginOptions };
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { MokupPluginOptions } from '@mokup/core';
|
|
2
|
+
export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput, ViteRuntime } from '@mokup/core';
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
|
-
export { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
5
|
-
export { PlaygroundOptionsInput } from '@mokup/shared';
|
|
6
|
-
import '@mokup/runtime';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Create the mokup Vite plugin.
|
|
@@ -25,4 +22,4 @@ import '@mokup/runtime';
|
|
|
25
22
|
*/
|
|
26
23
|
declare function createMokupPlugin(options?: MokupPluginOptions): Plugin;
|
|
27
24
|
|
|
28
|
-
export {
|
|
25
|
+
export { createMokupPlugin as default };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/// <reference path="./types/virtual.d.ts" />
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { MokupPluginOptions } from '@mokup/core';
|
|
4
|
+
export { Context, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput, ViteRuntime } from '@mokup/core';
|
|
5
5
|
import { Plugin } from 'vite';
|
|
6
|
-
export { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
7
|
-
export { PlaygroundOptionsInput } from '@mokup/shared';
|
|
8
|
-
import '@mokup/runtime';
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* Create the mokup Vite plugin.
|
|
@@ -27,6 +24,4 @@ import '@mokup/runtime';
|
|
|
27
24
|
*/
|
|
28
25
|
declare function createMokupPlugin(options?: MokupPluginOptions): Plugin;
|
|
29
26
|
|
|
30
|
-
// @ts-ignore
|
|
31
27
|
export = createMokupPlugin;
|
|
32
|
-
export { MokupPluginOptions };
|