mokup 2.0.2 → 2.1.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/cli-bin.cjs +3 -1
- package/dist/cli-bin.mjs +3 -1
- package/dist/index.cjs +39 -0
- package/dist/index.d.cts +62 -44
- package/dist/index.d.mts +62 -44
- package/dist/index.d.ts +64 -44
- package/dist/index.mjs +37 -0
- package/dist/server/worker.d.ts +2 -0
- package/dist/shared/{mokup.jeVwRMia.mjs → mokup.Bp9u3JKA.mjs} +1630 -1220
- package/dist/shared/mokup.CWQ8woZc.d.cts +302 -0
- package/dist/shared/mokup.CWQ8woZc.d.mts +302 -0
- package/dist/shared/mokup.CWQ8woZc.d.ts +302 -0
- package/dist/shared/{mokup.B-yfMz5B.cjs → mokup.i875Kuim.cjs} +1630 -1220
- package/dist/sw.cjs +5 -2
- package/dist/sw.d.cts +63 -0
- package/dist/sw.d.mts +63 -0
- package/dist/sw.d.ts +63 -0
- package/dist/sw.mjs +5 -2
- package/dist/types/virtual.d.ts +9 -0
- package/dist/vite.cjs +645 -347
- package/dist/vite.d.cts +20 -2
- package/dist/vite.d.mts +20 -2
- package/dist/vite.d.ts +22 -2
- package/dist/vite.mjs +637 -340
- package/dist/webpack.cjs +276 -204
- package/dist/webpack.d.cts +36 -4
- package/dist/webpack.d.mts +37 -3
- package/dist/webpack.d.ts +36 -4
- package/dist/webpack.mjs +272 -197
- package/package.json +7 -6
package/dist/cli-bin.cjs
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const process = require('node:process');
|
|
5
|
+
const logger$1 = require('@mokup/shared/logger');
|
|
5
6
|
const cli = require('@mokup/cli');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
9
|
|
|
9
10
|
const process__default = /*#__PURE__*/_interopDefaultCompat(process);
|
|
10
11
|
|
|
12
|
+
const logger = logger$1.createLogger();
|
|
11
13
|
cli.runCli().catch((error) => {
|
|
12
|
-
|
|
14
|
+
logger.error(error instanceof Error ? error.message : String(error));
|
|
13
15
|
process__default.exit(1);
|
|
14
16
|
});
|
package/dist/cli-bin.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import process from 'node:process';
|
|
3
|
+
import { createLogger } from '@mokup/shared/logger';
|
|
3
4
|
import { runCli } from '@mokup/cli';
|
|
4
5
|
|
|
6
|
+
const logger = createLogger();
|
|
5
7
|
runCli().catch((error) => {
|
|
6
|
-
|
|
8
|
+
logger.error(error instanceof Error ? error.message : String(error));
|
|
7
9
|
process.exit(1);
|
|
8
10
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const middlewareSymbol = Symbol.for("mokup.config.middlewares");
|
|
4
|
+
function createRegistry(list) {
|
|
5
|
+
return {
|
|
6
|
+
use: (...handlers) => {
|
|
7
|
+
list.push(...handlers);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function attachMetadata(config, meta) {
|
|
12
|
+
Object.defineProperty(config, middlewareSymbol, {
|
|
13
|
+
value: meta,
|
|
14
|
+
enumerable: false
|
|
15
|
+
});
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
function defineConfig(input) {
|
|
19
|
+
if (typeof input === "function") {
|
|
20
|
+
const pre = [];
|
|
21
|
+
const normal = [];
|
|
22
|
+
const post = [];
|
|
23
|
+
const context = {
|
|
24
|
+
pre: createRegistry(pre),
|
|
25
|
+
normal: createRegistry(normal),
|
|
26
|
+
post: createRegistry(post)
|
|
27
|
+
};
|
|
28
|
+
const result = input(context);
|
|
29
|
+
const config2 = result && typeof result === "object" ? result : {};
|
|
30
|
+
return attachMetadata(config2, { pre, normal, post });
|
|
31
|
+
}
|
|
32
|
+
const config = input && typeof input === "object" ? input : {};
|
|
33
|
+
return attachMetadata(config, { pre: [], normal: [], post: [] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function defineHandler(input) {
|
|
37
|
+
return input;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.defineConfig = defineConfig;
|
|
41
|
+
exports.defineHandler = defineHandler;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,48 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
1
|
+
import { c as RouteDirectoryConfig, b as MiddlewareRegistry, R as RequestHandler, e as RouteRule } from './shared/mokup.CWQ8woZc.cjs';
|
|
2
|
+
export { H as HttpMethod, a as MiddlewarePosition, M as MokupPluginOptions, d as RouteResponse, f as RuntimeMode, S as ServiceWorkerOptions, V as VitePluginOptions, g as VitePluginOptionsInput } from './shared/mokup.CWQ8woZc.cjs';
|
|
4
3
|
export { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
4
|
+
export { PlaygroundOptionsInput } from '@mokup/shared';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
type DefineConfigFactory = (context: {
|
|
7
|
+
pre: MiddlewareRegistry;
|
|
8
|
+
normal: MiddlewareRegistry;
|
|
9
|
+
post: MiddlewareRegistry;
|
|
10
|
+
}) => RouteDirectoryConfig | void;
|
|
11
|
+
/**
|
|
12
|
+
* Define a directory config with Hono-style middleware registration.
|
|
13
|
+
*
|
|
14
|
+
* @param input - Config object or factory callback.
|
|
15
|
+
* @returns Route directory config with middleware metadata.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { defineConfig } from 'mokup'
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig(({ pre, normal, post }) => {
|
|
21
|
+
* pre.use(async (c, next) => {
|
|
22
|
+
* c.header('x-before', '1')
|
|
23
|
+
* await next()
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* normal.use(async (_c, next) => {
|
|
27
|
+
* await next()
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* post.use(async (c, next) => {
|
|
31
|
+
* await next()
|
|
32
|
+
* c.header('x-after', '1')
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* return { delay: 120 }
|
|
36
|
+
* })
|
|
37
|
+
*/
|
|
38
|
+
declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Define a mock route handler with type hints.
|
|
42
|
+
*
|
|
43
|
+
* @param input - Handler function or rule object.
|
|
44
|
+
* @returns The same handler or rule.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import { defineHandler } from 'mokup'
|
|
48
|
+
*
|
|
49
|
+
* export default defineHandler((c) => {
|
|
50
|
+
* return { ok: true }
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* import { defineHandler } from 'mokup'
|
|
55
|
+
*
|
|
56
|
+
* export default defineHandler({
|
|
57
|
+
* enabled: false,
|
|
58
|
+
* handler: async (c) => {
|
|
59
|
+
* return { ok: false, method: c.req.method }
|
|
60
|
+
* },
|
|
61
|
+
* })
|
|
62
|
+
*/
|
|
63
|
+
declare function defineHandler(input: RequestHandler): RequestHandler;
|
|
64
|
+
declare function defineHandler(input: RouteRule): RouteRule;
|
|
47
65
|
|
|
48
|
-
export
|
|
66
|
+
export { MiddlewareRegistry, RequestHandler, RouteDirectoryConfig, RouteRule, defineConfig, defineHandler };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,48 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
1
|
+
import { c as RouteDirectoryConfig, b as MiddlewareRegistry, R as RequestHandler, e as RouteRule } from './shared/mokup.CWQ8woZc.mjs';
|
|
2
|
+
export { H as HttpMethod, a as MiddlewarePosition, M as MokupPluginOptions, d as RouteResponse, f as RuntimeMode, S as ServiceWorkerOptions, V as VitePluginOptions, g as VitePluginOptionsInput } from './shared/mokup.CWQ8woZc.mjs';
|
|
4
3
|
export { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
4
|
+
export { PlaygroundOptionsInput } from '@mokup/shared';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
type DefineConfigFactory = (context: {
|
|
7
|
+
pre: MiddlewareRegistry;
|
|
8
|
+
normal: MiddlewareRegistry;
|
|
9
|
+
post: MiddlewareRegistry;
|
|
10
|
+
}) => RouteDirectoryConfig | void;
|
|
11
|
+
/**
|
|
12
|
+
* Define a directory config with Hono-style middleware registration.
|
|
13
|
+
*
|
|
14
|
+
* @param input - Config object or factory callback.
|
|
15
|
+
* @returns Route directory config with middleware metadata.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { defineConfig } from 'mokup'
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig(({ pre, normal, post }) => {
|
|
21
|
+
* pre.use(async (c, next) => {
|
|
22
|
+
* c.header('x-before', '1')
|
|
23
|
+
* await next()
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* normal.use(async (_c, next) => {
|
|
27
|
+
* await next()
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* post.use(async (c, next) => {
|
|
31
|
+
* await next()
|
|
32
|
+
* c.header('x-after', '1')
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* return { delay: 120 }
|
|
36
|
+
* })
|
|
37
|
+
*/
|
|
38
|
+
declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Define a mock route handler with type hints.
|
|
42
|
+
*
|
|
43
|
+
* @param input - Handler function or rule object.
|
|
44
|
+
* @returns The same handler or rule.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import { defineHandler } from 'mokup'
|
|
48
|
+
*
|
|
49
|
+
* export default defineHandler((c) => {
|
|
50
|
+
* return { ok: true }
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* import { defineHandler } from 'mokup'
|
|
55
|
+
*
|
|
56
|
+
* export default defineHandler({
|
|
57
|
+
* enabled: false,
|
|
58
|
+
* handler: async (c) => {
|
|
59
|
+
* return { ok: false, method: c.req.method }
|
|
60
|
+
* },
|
|
61
|
+
* })
|
|
62
|
+
*/
|
|
63
|
+
declare function defineHandler(input: RequestHandler): RequestHandler;
|
|
64
|
+
declare function defineHandler(input: RouteRule): RouteRule;
|
|
47
65
|
|
|
48
|
-
export
|
|
66
|
+
export { MiddlewareRegistry, RequestHandler, RouteDirectoryConfig, RouteRule, defineConfig, defineHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
/// <reference path="./types/virtual.d.ts" />
|
|
2
|
+
|
|
3
|
+
import { c as RouteDirectoryConfig, b as MiddlewareRegistry, R as RequestHandler, e as RouteRule } from './shared/mokup.CWQ8woZc.js';
|
|
4
|
+
export { H as HttpMethod, a as MiddlewarePosition, M as MokupPluginOptions, d as RouteResponse, f as RuntimeMode, S as ServiceWorkerOptions, V as VitePluginOptions, g as VitePluginOptionsInput } from './shared/mokup.CWQ8woZc.js';
|
|
4
5
|
export { Context, MiddlewareHandler } from '@mokup/shared/hono';
|
|
6
|
+
export { PlaygroundOptionsInput } from '@mokup/shared';
|
|
5
7
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
type DefineConfigFactory = (context: {
|
|
9
|
+
pre: MiddlewareRegistry;
|
|
10
|
+
normal: MiddlewareRegistry;
|
|
11
|
+
post: MiddlewareRegistry;
|
|
12
|
+
}) => RouteDirectoryConfig | void;
|
|
13
|
+
/**
|
|
14
|
+
* Define a directory config with Hono-style middleware registration.
|
|
15
|
+
*
|
|
16
|
+
* @param input - Config object or factory callback.
|
|
17
|
+
* @returns Route directory config with middleware metadata.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { defineConfig } from 'mokup'
|
|
21
|
+
*
|
|
22
|
+
* export default defineConfig(({ pre, normal, post }) => {
|
|
23
|
+
* pre.use(async (c, next) => {
|
|
24
|
+
* c.header('x-before', '1')
|
|
25
|
+
* await next()
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* normal.use(async (_c, next) => {
|
|
29
|
+
* await next()
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* post.use(async (c, next) => {
|
|
33
|
+
* await next()
|
|
34
|
+
* c.header('x-after', '1')
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* return { delay: 120 }
|
|
38
|
+
* })
|
|
39
|
+
*/
|
|
40
|
+
declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
|
|
27
41
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Define a mock route handler with type hints.
|
|
44
|
+
*
|
|
45
|
+
* @param input - Handler function or rule object.
|
|
46
|
+
* @returns The same handler or rule.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { defineHandler } from 'mokup'
|
|
50
|
+
*
|
|
51
|
+
* export default defineHandler((c) => {
|
|
52
|
+
* return { ok: true }
|
|
53
|
+
* })
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* import { defineHandler } from 'mokup'
|
|
57
|
+
*
|
|
58
|
+
* export default defineHandler({
|
|
59
|
+
* enabled: false,
|
|
60
|
+
* handler: async (c) => {
|
|
61
|
+
* return { ok: false, method: c.req.method }
|
|
62
|
+
* },
|
|
63
|
+
* })
|
|
64
|
+
*/
|
|
65
|
+
declare function defineHandler(input: RequestHandler): RequestHandler;
|
|
66
|
+
declare function defineHandler(input: RouteRule): RouteRule;
|
|
47
67
|
|
|
48
|
-
export
|
|
68
|
+
export { MiddlewareRegistry, RequestHandler, RouteDirectoryConfig, RouteRule, defineConfig, defineHandler };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
+
const middlewareSymbol = Symbol.for("mokup.config.middlewares");
|
|
2
|
+
function createRegistry(list) {
|
|
3
|
+
return {
|
|
4
|
+
use: (...handlers) => {
|
|
5
|
+
list.push(...handlers);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function attachMetadata(config, meta) {
|
|
10
|
+
Object.defineProperty(config, middlewareSymbol, {
|
|
11
|
+
value: meta,
|
|
12
|
+
enumerable: false
|
|
13
|
+
});
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
function defineConfig(input) {
|
|
17
|
+
if (typeof input === "function") {
|
|
18
|
+
const pre = [];
|
|
19
|
+
const normal = [];
|
|
20
|
+
const post = [];
|
|
21
|
+
const context = {
|
|
22
|
+
pre: createRegistry(pre),
|
|
23
|
+
normal: createRegistry(normal),
|
|
24
|
+
post: createRegistry(post)
|
|
25
|
+
};
|
|
26
|
+
const result = input(context);
|
|
27
|
+
const config2 = result && typeof result === "object" ? result : {};
|
|
28
|
+
return attachMetadata(config2, { pre, normal, post });
|
|
29
|
+
}
|
|
30
|
+
const config = input && typeof input === "object" ? input : {};
|
|
31
|
+
return attachMetadata(config, { pre: [], normal: [], post: [] });
|
|
32
|
+
}
|
|
1
33
|
|
|
34
|
+
function defineHandler(input) {
|
|
35
|
+
return input;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { defineConfig, defineHandler };
|
package/dist/server/worker.d.ts
CHANGED