mokup 2.3.2 → 2.3.3
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/vite.cjs +9 -16
- package/dist/vite.mjs +10 -17
- package/dist/webpack.cjs +2 -6
- package/dist/webpack.mjs +2 -6
- package/package.json +2 -2
package/dist/vite.cjs
CHANGED
|
@@ -449,6 +449,9 @@ async function configureDevServer(params) {
|
|
|
449
449
|
watchEnabled
|
|
450
450
|
} = params;
|
|
451
451
|
await refreshRoutes(server);
|
|
452
|
+
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
453
|
+
addMiddlewareFirst(server, core.createMiddleware(() => state.app, logger));
|
|
454
|
+
}
|
|
452
455
|
addMiddlewareFirst(server, playgroundMiddleware);
|
|
453
456
|
if (playgroundConfig.enabled) {
|
|
454
457
|
const playgroundPath = resolveRegisterPath(base, playgroundConfig.path);
|
|
@@ -482,9 +485,6 @@ async function configureDevServer(params) {
|
|
|
482
485
|
}
|
|
483
486
|
});
|
|
484
487
|
}
|
|
485
|
-
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
486
|
-
server.middlewares.use(core.createMiddleware(() => state.app, logger));
|
|
487
|
-
}
|
|
488
488
|
if (!watchEnabled) {
|
|
489
489
|
return;
|
|
490
490
|
}
|
|
@@ -512,6 +512,9 @@ async function configurePreviewServer(params) {
|
|
|
512
512
|
watchEnabled
|
|
513
513
|
} = params;
|
|
514
514
|
await refreshRoutes(server);
|
|
515
|
+
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
516
|
+
addMiddlewareFirst(server, core.createMiddleware(() => state.app, logger));
|
|
517
|
+
}
|
|
515
518
|
addMiddlewareFirst(server, playgroundMiddleware);
|
|
516
519
|
const swPath = swConfig ? resolveRegisterPath(base, swConfig.path) : null;
|
|
517
520
|
if (swPath && hasSwRoutes()) {
|
|
@@ -539,9 +542,6 @@ async function configurePreviewServer(params) {
|
|
|
539
542
|
}
|
|
540
543
|
});
|
|
541
544
|
}
|
|
542
|
-
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
543
|
-
server.middlewares.use(core.createMiddleware(() => state.app, logger));
|
|
544
|
-
}
|
|
545
545
|
if (!watchEnabled) {
|
|
546
546
|
return null;
|
|
547
547
|
}
|
|
@@ -602,12 +602,11 @@ function buildSwLifecycleScript(params) {
|
|
|
602
602
|
importPath,
|
|
603
603
|
swConfig,
|
|
604
604
|
unregisterConfig,
|
|
605
|
-
hasSwEntries,
|
|
606
605
|
hasSwRoutes,
|
|
607
606
|
resolveRequestPath,
|
|
608
607
|
resolveRegisterScope
|
|
609
608
|
} = params;
|
|
610
|
-
const shouldUnregister = unregisterConfig.unregister === true
|
|
609
|
+
const shouldUnregister = unregisterConfig.unregister === true;
|
|
611
610
|
if (shouldUnregister) {
|
|
612
611
|
const path2 = resolveRequestPath(unregisterConfig.path);
|
|
613
612
|
const scope2 = resolveRegisterScope(unregisterConfig.scope);
|
|
@@ -642,12 +641,11 @@ function buildSwLifecycleInlineScript(params) {
|
|
|
642
641
|
const {
|
|
643
642
|
swConfig,
|
|
644
643
|
unregisterConfig,
|
|
645
|
-
hasSwEntries,
|
|
646
644
|
hasSwRoutes,
|
|
647
645
|
resolveRequestPath,
|
|
648
646
|
resolveRegisterScope
|
|
649
647
|
} = params;
|
|
650
|
-
const shouldUnregister = unregisterConfig.unregister === true
|
|
648
|
+
const shouldUnregister = unregisterConfig.unregister === true;
|
|
651
649
|
if (shouldUnregister) {
|
|
652
650
|
const path2 = resolveRequestPath(unregisterConfig.path);
|
|
653
651
|
const scope2 = resolveRegisterScope(unregisterConfig.scope);
|
|
@@ -755,7 +753,7 @@ function createMokupPlugin(options = {}) {
|
|
|
755
753
|
const watchEnabled = optionList.every((entry) => entry.watch !== false);
|
|
756
754
|
const playgroundConfig = core.resolvePlaygroundOptions(normalizedOptions.playground);
|
|
757
755
|
const logger = core.createLogger(logEnabled);
|
|
758
|
-
|
|
756
|
+
optionList.some((entry) => entry.mode === "sw");
|
|
759
757
|
const swConfig = core.resolveSwConfig(optionList, logger);
|
|
760
758
|
const unregisterConfig = core.resolveSwUnregisterConfig(optionList, logger);
|
|
761
759
|
const resolveAllDirs = createDirResolver(optionList, () => root);
|
|
@@ -787,7 +785,6 @@ function createMokupPlugin(options = {}) {
|
|
|
787
785
|
importPath: resolveSwImportPath(base),
|
|
788
786
|
swConfig,
|
|
789
787
|
unregisterConfig,
|
|
790
|
-
hasSwEntries,
|
|
791
788
|
hasSwRoutes: hasSwRoutes(),
|
|
792
789
|
resolveRequestPath: resolveSwRequestPath,
|
|
793
790
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -855,7 +852,6 @@ function createMokupPlugin(options = {}) {
|
|
|
855
852
|
importPath,
|
|
856
853
|
swConfig,
|
|
857
854
|
unregisterConfig,
|
|
858
|
-
hasSwEntries,
|
|
859
855
|
hasSwRoutes: hasSwRoutes(),
|
|
860
856
|
resolveRequestPath: resolveSwRequestPath,
|
|
861
857
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -881,7 +877,6 @@ function createMokupPlugin(options = {}) {
|
|
|
881
877
|
importPath: "mokup/sw",
|
|
882
878
|
swConfig,
|
|
883
879
|
unregisterConfig,
|
|
884
|
-
hasSwEntries,
|
|
885
880
|
hasSwRoutes: hasSwRoutes(),
|
|
886
881
|
resolveRequestPath: resolveSwRequestPath,
|
|
887
882
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -915,7 +910,6 @@ function createMokupPlugin(options = {}) {
|
|
|
915
910
|
importPath: command === "build" ? "mokup/sw" : resolveSwImportPath(base),
|
|
916
911
|
swConfig,
|
|
917
912
|
unregisterConfig,
|
|
918
|
-
hasSwEntries,
|
|
919
913
|
hasSwRoutes: hasSwRoutes(),
|
|
920
914
|
resolveRequestPath: resolveSwRequestPath,
|
|
921
915
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -1007,7 +1001,6 @@ function createMokupPlugin(options = {}) {
|
|
|
1007
1001
|
const swScript = buildSwLifecycleInlineScript({
|
|
1008
1002
|
swConfig,
|
|
1009
1003
|
unregisterConfig,
|
|
1010
|
-
hasSwEntries,
|
|
1011
1004
|
hasSwRoutes: hasSwRoutes(),
|
|
1012
1005
|
resolveRequestPath: resolveSwRequestPath,
|
|
1013
1006
|
resolveRegisterScope: resolveSwRegisterScope
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cwd } from 'node:process';
|
|
2
|
-
import { resolveDirs, scanRoutes, sortRoutes, createHonoApp, formatOutputLine, stripAnsi, createDebouncer, isInDirs,
|
|
2
|
+
import { resolveDirs, scanRoutes, sortRoutes, createHonoApp, formatOutputLine, stripAnsi, createDebouncer, isInDirs, createMiddleware, buildSwScript, resolvePlaygroundOptions, createLogger, resolveSwConfig, resolveSwUnregisterConfig, createPlaygroundMiddleware, buildBundleModule, writePlaygroundBuild } from '@mokup/core';
|
|
3
3
|
import { r as resolvePlaygroundDist } from './shared/mokup.BZpTBIrj.mjs';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
5
|
import { isAbsolute, resolve, dirname } from 'node:path';
|
|
@@ -441,6 +441,9 @@ async function configureDevServer(params) {
|
|
|
441
441
|
watchEnabled
|
|
442
442
|
} = params;
|
|
443
443
|
await refreshRoutes(server);
|
|
444
|
+
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
445
|
+
addMiddlewareFirst(server, createMiddleware(() => state.app, logger));
|
|
446
|
+
}
|
|
444
447
|
addMiddlewareFirst(server, playgroundMiddleware);
|
|
445
448
|
if (playgroundConfig.enabled) {
|
|
446
449
|
const playgroundPath = resolveRegisterPath(base, playgroundConfig.path);
|
|
@@ -474,9 +477,6 @@ async function configureDevServer(params) {
|
|
|
474
477
|
}
|
|
475
478
|
});
|
|
476
479
|
}
|
|
477
|
-
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
478
|
-
server.middlewares.use(createMiddleware(() => state.app, logger));
|
|
479
|
-
}
|
|
480
480
|
if (!watchEnabled) {
|
|
481
481
|
return;
|
|
482
482
|
}
|
|
@@ -504,6 +504,9 @@ async function configurePreviewServer(params) {
|
|
|
504
504
|
watchEnabled
|
|
505
505
|
} = params;
|
|
506
506
|
await refreshRoutes(server);
|
|
507
|
+
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
508
|
+
addMiddlewareFirst(server, createMiddleware(() => state.app, logger));
|
|
509
|
+
}
|
|
507
510
|
addMiddlewareFirst(server, playgroundMiddleware);
|
|
508
511
|
const swPath = swConfig ? resolveRegisterPath(base, swConfig.path) : null;
|
|
509
512
|
if (swPath && hasSwRoutes()) {
|
|
@@ -531,9 +534,6 @@ async function configurePreviewServer(params) {
|
|
|
531
534
|
}
|
|
532
535
|
});
|
|
533
536
|
}
|
|
534
|
-
if (enableViteMiddleware && state.serverRoutes.length > 0) {
|
|
535
|
-
server.middlewares.use(createMiddleware(() => state.app, logger));
|
|
536
|
-
}
|
|
537
537
|
if (!watchEnabled) {
|
|
538
538
|
return null;
|
|
539
539
|
}
|
|
@@ -594,12 +594,11 @@ function buildSwLifecycleScript(params) {
|
|
|
594
594
|
importPath,
|
|
595
595
|
swConfig,
|
|
596
596
|
unregisterConfig,
|
|
597
|
-
hasSwEntries,
|
|
598
597
|
hasSwRoutes,
|
|
599
598
|
resolveRequestPath,
|
|
600
599
|
resolveRegisterScope
|
|
601
600
|
} = params;
|
|
602
|
-
const shouldUnregister = unregisterConfig.unregister === true
|
|
601
|
+
const shouldUnregister = unregisterConfig.unregister === true;
|
|
603
602
|
if (shouldUnregister) {
|
|
604
603
|
const path2 = resolveRequestPath(unregisterConfig.path);
|
|
605
604
|
const scope2 = resolveRegisterScope(unregisterConfig.scope);
|
|
@@ -634,12 +633,11 @@ function buildSwLifecycleInlineScript(params) {
|
|
|
634
633
|
const {
|
|
635
634
|
swConfig,
|
|
636
635
|
unregisterConfig,
|
|
637
|
-
hasSwEntries,
|
|
638
636
|
hasSwRoutes,
|
|
639
637
|
resolveRequestPath,
|
|
640
638
|
resolveRegisterScope
|
|
641
639
|
} = params;
|
|
642
|
-
const shouldUnregister = unregisterConfig.unregister === true
|
|
640
|
+
const shouldUnregister = unregisterConfig.unregister === true;
|
|
643
641
|
if (shouldUnregister) {
|
|
644
642
|
const path2 = resolveRequestPath(unregisterConfig.path);
|
|
645
643
|
const scope2 = resolveRegisterScope(unregisterConfig.scope);
|
|
@@ -747,7 +745,7 @@ function createMokupPlugin(options = {}) {
|
|
|
747
745
|
const watchEnabled = optionList.every((entry) => entry.watch !== false);
|
|
748
746
|
const playgroundConfig = resolvePlaygroundOptions(normalizedOptions.playground);
|
|
749
747
|
const logger = createLogger(logEnabled);
|
|
750
|
-
|
|
748
|
+
optionList.some((entry) => entry.mode === "sw");
|
|
751
749
|
const swConfig = resolveSwConfig(optionList, logger);
|
|
752
750
|
const unregisterConfig = resolveSwUnregisterConfig(optionList, logger);
|
|
753
751
|
const resolveAllDirs = createDirResolver(optionList, () => root);
|
|
@@ -779,7 +777,6 @@ function createMokupPlugin(options = {}) {
|
|
|
779
777
|
importPath: resolveSwImportPath(base),
|
|
780
778
|
swConfig,
|
|
781
779
|
unregisterConfig,
|
|
782
|
-
hasSwEntries,
|
|
783
780
|
hasSwRoutes: hasSwRoutes(),
|
|
784
781
|
resolveRequestPath: resolveSwRequestPath,
|
|
785
782
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -847,7 +844,6 @@ function createMokupPlugin(options = {}) {
|
|
|
847
844
|
importPath,
|
|
848
845
|
swConfig,
|
|
849
846
|
unregisterConfig,
|
|
850
|
-
hasSwEntries,
|
|
851
847
|
hasSwRoutes: hasSwRoutes(),
|
|
852
848
|
resolveRequestPath: resolveSwRequestPath,
|
|
853
849
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -873,7 +869,6 @@ function createMokupPlugin(options = {}) {
|
|
|
873
869
|
importPath: "mokup/sw",
|
|
874
870
|
swConfig,
|
|
875
871
|
unregisterConfig,
|
|
876
|
-
hasSwEntries,
|
|
877
872
|
hasSwRoutes: hasSwRoutes(),
|
|
878
873
|
resolveRequestPath: resolveSwRequestPath,
|
|
879
874
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -907,7 +902,6 @@ function createMokupPlugin(options = {}) {
|
|
|
907
902
|
importPath: command === "build" ? "mokup/sw" : resolveSwImportPath(base),
|
|
908
903
|
swConfig,
|
|
909
904
|
unregisterConfig,
|
|
910
|
-
hasSwEntries,
|
|
911
905
|
hasSwRoutes: hasSwRoutes(),
|
|
912
906
|
resolveRequestPath: resolveSwRequestPath,
|
|
913
907
|
resolveRegisterScope: resolveSwRegisterScope
|
|
@@ -999,7 +993,6 @@ function createMokupPlugin(options = {}) {
|
|
|
999
993
|
const swScript = buildSwLifecycleInlineScript({
|
|
1000
994
|
swConfig,
|
|
1001
995
|
unregisterConfig,
|
|
1002
|
-
hasSwEntries,
|
|
1003
996
|
hasSwRoutes: hasSwRoutes(),
|
|
1004
997
|
resolveRequestPath: resolveSwRequestPath,
|
|
1005
998
|
resolveRegisterScope: resolveSwRegisterScope
|
package/dist/webpack.cjs
CHANGED
|
@@ -36,12 +36,11 @@ function buildSwLifecycleScript(params) {
|
|
|
36
36
|
importPath,
|
|
37
37
|
swConfig,
|
|
38
38
|
unregisterConfig,
|
|
39
|
-
hasSwEntries,
|
|
40
39
|
hasSwRoutes,
|
|
41
40
|
resolveRequestPath,
|
|
42
41
|
resolveRegisterScope
|
|
43
42
|
} = params;
|
|
44
|
-
const shouldUnregister = unregisterConfig.unregister === true
|
|
43
|
+
const shouldUnregister = unregisterConfig.unregister === true;
|
|
45
44
|
if (shouldUnregister) {
|
|
46
45
|
const path2 = resolveRequestPath(unregisterConfig.path);
|
|
47
46
|
const scope2 = resolveRegisterScope(unregisterConfig.scope);
|
|
@@ -80,7 +79,6 @@ function createBundleBuilder(params) {
|
|
|
80
79
|
root,
|
|
81
80
|
swConfig,
|
|
82
81
|
unregisterConfig,
|
|
83
|
-
hasSwEntries,
|
|
84
82
|
hasSwRoutes,
|
|
85
83
|
resolveRequestPath,
|
|
86
84
|
resolveRegisterScope,
|
|
@@ -94,7 +92,6 @@ function createBundleBuilder(params) {
|
|
|
94
92
|
importPath: "mokup/sw",
|
|
95
93
|
swConfig,
|
|
96
94
|
unregisterConfig,
|
|
97
|
-
hasSwEntries,
|
|
98
95
|
hasSwRoutes: hasSwRoutes(),
|
|
99
96
|
resolveRequestPath,
|
|
100
97
|
resolveRegisterScope
|
|
@@ -342,7 +339,7 @@ function createMokupWebpackPlugin(options = {}) {
|
|
|
342
339
|
const watchEnabled = optionList.every((entry) => entry.watch !== false);
|
|
343
340
|
const playgroundConfig = core.resolvePlaygroundOptions(normalizedOptions.playground);
|
|
344
341
|
const logger = core.createLogger(logEnabled);
|
|
345
|
-
|
|
342
|
+
optionList.some((entry) => entry.mode === "sw");
|
|
346
343
|
const swConfig = core.resolveSwConfig(optionList, logger);
|
|
347
344
|
const unregisterConfig = core.resolveSwUnregisterConfig(optionList, logger);
|
|
348
345
|
let root = process.cwd();
|
|
@@ -393,7 +390,6 @@ function createMokupWebpackPlugin(options = {}) {
|
|
|
393
390
|
root: () => root,
|
|
394
391
|
swConfig,
|
|
395
392
|
unregisterConfig,
|
|
396
|
-
hasSwEntries,
|
|
397
393
|
hasSwRoutes,
|
|
398
394
|
resolveRequestPath: (path) => resolveRegisterPath(base, path),
|
|
399
395
|
resolveRegisterScope: (scope) => resolveRegisterScope(base, scope),
|
package/dist/webpack.mjs
CHANGED
|
@@ -29,12 +29,11 @@ function buildSwLifecycleScript(params) {
|
|
|
29
29
|
importPath,
|
|
30
30
|
swConfig,
|
|
31
31
|
unregisterConfig,
|
|
32
|
-
hasSwEntries,
|
|
33
32
|
hasSwRoutes,
|
|
34
33
|
resolveRequestPath,
|
|
35
34
|
resolveRegisterScope
|
|
36
35
|
} = params;
|
|
37
|
-
const shouldUnregister = unregisterConfig.unregister === true
|
|
36
|
+
const shouldUnregister = unregisterConfig.unregister === true;
|
|
38
37
|
if (shouldUnregister) {
|
|
39
38
|
const path2 = resolveRequestPath(unregisterConfig.path);
|
|
40
39
|
const scope2 = resolveRegisterScope(unregisterConfig.scope);
|
|
@@ -73,7 +72,6 @@ function createBundleBuilder(params) {
|
|
|
73
72
|
root,
|
|
74
73
|
swConfig,
|
|
75
74
|
unregisterConfig,
|
|
76
|
-
hasSwEntries,
|
|
77
75
|
hasSwRoutes,
|
|
78
76
|
resolveRequestPath,
|
|
79
77
|
resolveRegisterScope,
|
|
@@ -87,7 +85,6 @@ function createBundleBuilder(params) {
|
|
|
87
85
|
importPath: "mokup/sw",
|
|
88
86
|
swConfig,
|
|
89
87
|
unregisterConfig,
|
|
90
|
-
hasSwEntries,
|
|
91
88
|
hasSwRoutes: hasSwRoutes(),
|
|
92
89
|
resolveRequestPath,
|
|
93
90
|
resolveRegisterScope
|
|
@@ -335,7 +332,7 @@ function createMokupWebpackPlugin(options = {}) {
|
|
|
335
332
|
const watchEnabled = optionList.every((entry) => entry.watch !== false);
|
|
336
333
|
const playgroundConfig = resolvePlaygroundOptions(normalizedOptions.playground);
|
|
337
334
|
const logger = createLogger(logEnabled);
|
|
338
|
-
|
|
335
|
+
optionList.some((entry) => entry.mode === "sw");
|
|
339
336
|
const swConfig = resolveSwConfig(optionList, logger);
|
|
340
337
|
const unregisterConfig = resolveSwUnregisterConfig(optionList, logger);
|
|
341
338
|
let root = cwd();
|
|
@@ -386,7 +383,6 @@ function createMokupWebpackPlugin(options = {}) {
|
|
|
386
383
|
root: () => root,
|
|
387
384
|
swConfig,
|
|
388
385
|
unregisterConfig,
|
|
389
|
-
hasSwEntries,
|
|
390
386
|
hasSwRoutes,
|
|
391
387
|
resolveRequestPath: (path) => resolveRegisterPath(base, path),
|
|
392
388
|
resolveRegisterScope: (scope) => resolveRegisterScope(base, scope),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mokup",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.3",
|
|
5
5
|
"description": "Mock utilities and Vite plugin for mokup.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://mokup.icebreaker.top",
|
|
@@ -165,8 +165,8 @@
|
|
|
165
165
|
"dependencies": {
|
|
166
166
|
"picocolors": "^1.1.1",
|
|
167
167
|
"@mokup/cli": "1.1.2",
|
|
168
|
-
"@mokup/core": "1.1.1",
|
|
169
168
|
"@mokup/playground": "0.1.1",
|
|
169
|
+
"@mokup/core": "1.1.1",
|
|
170
170
|
"@mokup/runtime": "1.0.8",
|
|
171
171
|
"@mokup/server": "1.2.2",
|
|
172
172
|
"@mokup/shared": "1.1.3"
|