mokup 2.2.3 → 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 CHANGED
@@ -1,11 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const bundle = require('./shared/mokup.BXPIIxtS.cjs');
4
- require('./shared/mokup.Dy9VDphS.cjs');
5
- require('@mokup/shared/pathe');
6
- require('@mokup/shared/path-utils');
7
- require('@mokup/shared/timing');
3
+ const core = require('@mokup/core');
8
4
 
9
5
 
10
6
 
11
- exports.buildBundleModule = bundle.buildBundleModule;
7
+ exports.buildBundleModule = core.buildBundleModule;
package/dist/bundle.d.cts CHANGED
@@ -1,27 +1 @@
1
- import { R as RouteTable } from './shared/mokup.DeotZ0g8.cjs';
2
- export { a as ResolvedRoute } from './shared/mokup.DeotZ0g8.cjs';
3
- import '@mokup/runtime';
4
- import '@mokup/shared';
5
- import '@mokup/shared/hono';
6
-
7
- /**
8
- * Build the source for a virtual mokup bundle module.
9
- *
10
- * @param params - Bundle build parameters.
11
- * @param params.routes - Resolved routes to serialize.
12
- * @param params.root - Workspace root path.
13
- * @param params.resolveModulePath - Optional module resolver.
14
- * @returns JavaScript source string.
15
- *
16
- * @example
17
- * import { buildBundleModule } from 'mokup/bundle'
18
- *
19
- * const source = buildBundleModule({ routes: [], root: '/project' })
20
- */
21
- declare function buildBundleModule(params: {
22
- routes: RouteTable;
23
- root: string;
24
- resolveModulePath?: (file: string, root: string) => string;
25
- }): string;
26
-
27
- export { RouteTable, buildBundleModule };
1
+ export { ResolvedRoute, RouteTable, buildBundleModule } from '@mokup/core';
package/dist/bundle.d.mts CHANGED
@@ -1,27 +1 @@
1
- import { R as RouteTable } from './shared/mokup.DeotZ0g8.mjs';
2
- export { a as ResolvedRoute } from './shared/mokup.DeotZ0g8.mjs';
3
- import '@mokup/runtime';
4
- import '@mokup/shared';
5
- import '@mokup/shared/hono';
6
-
7
- /**
8
- * Build the source for a virtual mokup bundle module.
9
- *
10
- * @param params - Bundle build parameters.
11
- * @param params.routes - Resolved routes to serialize.
12
- * @param params.root - Workspace root path.
13
- * @param params.resolveModulePath - Optional module resolver.
14
- * @returns JavaScript source string.
15
- *
16
- * @example
17
- * import { buildBundleModule } from 'mokup/bundle'
18
- *
19
- * const source = buildBundleModule({ routes: [], root: '/project' })
20
- */
21
- declare function buildBundleModule(params: {
22
- routes: RouteTable;
23
- root: string;
24
- resolveModulePath?: (file: string, root: string) => string;
25
- }): string;
26
-
27
- export { RouteTable, buildBundleModule };
1
+ export { ResolvedRoute, RouteTable, buildBundleModule } from '@mokup/core';
package/dist/bundle.d.ts CHANGED
@@ -1,27 +1 @@
1
- import { R as RouteTable } from './shared/mokup.DeotZ0g8.js';
2
- export { a as ResolvedRoute } from './shared/mokup.DeotZ0g8.js';
3
- import '@mokup/runtime';
4
- import '@mokup/shared';
5
- import '@mokup/shared/hono';
6
-
7
- /**
8
- * Build the source for a virtual mokup bundle module.
9
- *
10
- * @param params - Bundle build parameters.
11
- * @param params.routes - Resolved routes to serialize.
12
- * @param params.root - Workspace root path.
13
- * @param params.resolveModulePath - Optional module resolver.
14
- * @returns JavaScript source string.
15
- *
16
- * @example
17
- * import { buildBundleModule } from 'mokup/bundle'
18
- *
19
- * const source = buildBundleModule({ routes: [], root: '/project' })
20
- */
21
- declare function buildBundleModule(params: {
22
- routes: RouteTable;
23
- root: string;
24
- resolveModulePath?: (file: string, root: string) => string;
25
- }): string;
26
-
27
- export { RouteTable, buildBundleModule };
1
+ export { ResolvedRoute, RouteTable, buildBundleModule } from '@mokup/core';
package/dist/bundle.mjs CHANGED
@@ -1,5 +1 @@
1
- export { b as buildBundleModule } from './shared/mokup.CsBTglhs.mjs';
2
- import './shared/mokup.Iqw32OxC.mjs';
3
- import '@mokup/shared/pathe';
4
- import '@mokup/shared/path-utils';
5
- import '@mokup/shared/timing';
1
+ export { buildBundleModule } from '@mokup/core';
@@ -1,5 +1,6 @@
1
1
 
2
2
  import '@mokup/cli';
3
+ import '@mokup/core';
3
4
  import '@mokup/runtime';
4
5
  import '@mokup/server';
5
6
  import '@mokup/server/fetch';
@@ -1,5 +1,6 @@
1
1
 
2
2
  import '@mokup/cli';
3
+ import '@mokup/core';
3
4
  import '@mokup/runtime';
4
5
  import '@mokup/server';
5
6
  import '@mokup/server/fetch';
package/dist/cli-bin.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  import '@mokup/cli';
3
+ import '@mokup/core';
3
4
  import '@mokup/runtime';
4
5
  import '@mokup/server';
5
6
  import '@mokup/server/fetch';
package/dist/index.cjs CHANGED
@@ -1,37 +1,13 @@
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
- }
3
+ const defineConfig$1 = require('@mokup/shared/define-config');
4
+
5
+ const shared = defineConfig$1.createDefineConfig({
6
+ logPrefix: "[mokup]"
7
+ });
8
+ const defineConfig = shared.defineConfig;
9
+ const onBeforeAll = shared.onBeforeAll;
10
+ const onAfterAll = shared.onAfterAll;
35
11
 
36
12
  function defineHandler(input) {
37
13
  return input;
@@ -39,3 +15,5 @@ function defineHandler(input) {
39
15
 
40
16
  exports.defineConfig = defineConfig;
41
17
  exports.defineHandler = defineHandler;
18
+ exports.onAfterAll = onAfterAll;
19
+ exports.onBeforeAll = onBeforeAll;
package/dist/index.d.cts CHANGED
@@ -1,42 +1,10 @@
1
- import { e as RouteDirectoryConfig, c as MiddlewareRegistry, d as RequestHandler, g as RouteRule } from './shared/mokup.DeotZ0g8.cjs';
2
- export { H as HttpMethod, b as MiddlewarePosition, M as MokupPluginOptions, f as RouteResponse, h as RuntimeMode, S as ServiceWorkerOptions, V as VitePluginOptions, i as VitePluginOptionsInput } from './shared/mokup.DeotZ0g8.cjs';
3
- export { Context, MiddlewareHandler } from '@mokup/shared/hono';
4
- export { PlaygroundOptionsInput } from '@mokup/shared';
5
- import '@mokup/runtime';
1
+ import * as _mokup_shared_define_config from '@mokup/shared/define-config';
2
+ import { RouteDirectoryConfig, MiddlewareHandler, RequestHandler, RouteRule } from '@mokup/core';
3
+ export { Context, HookErrorPolicy, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from '@mokup/core';
6
4
 
7
- type DefineConfigFactory = (context: {
8
- pre: MiddlewareRegistry;
9
- normal: MiddlewareRegistry;
10
- post: MiddlewareRegistry;
11
- }) => RouteDirectoryConfig | void;
12
- /**
13
- * Define a directory config with Hono-style middleware registration.
14
- *
15
- * @param input - Config object or factory callback.
16
- * @returns Route directory config with middleware metadata.
17
- *
18
- * @example
19
- * import { defineConfig } from 'mokup'
20
- *
21
- * export default defineConfig(({ pre, normal, post }) => {
22
- * pre.use(async (c, next) => {
23
- * c.header('x-before', '1')
24
- * await next()
25
- * })
26
- *
27
- * normal.use(async (_c, next) => {
28
- * await next()
29
- * })
30
- *
31
- * post.use(async (c, next) => {
32
- * await next()
33
- * c.header('x-after', '1')
34
- * })
35
- *
36
- * return { delay: 120 }
37
- * })
38
- */
39
- declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
5
+ declare const defineConfig: (input: RouteDirectoryConfig | _mokup_shared_define_config.DefineConfigFactory<RouteDirectoryConfig, MiddlewareHandler>) => RouteDirectoryConfig | Promise<RouteDirectoryConfig>;
6
+ declare const onBeforeAll: (handler: _mokup_shared_define_config.HookHandler) => void;
7
+ declare const onAfterAll: (handler: _mokup_shared_define_config.HookHandler) => void;
40
8
 
41
9
  /**
42
10
  * Define a mock route handler with type hints.
@@ -64,4 +32,4 @@ declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory)
64
32
  declare function defineHandler(input: RequestHandler): RequestHandler;
65
33
  declare function defineHandler(input: RouteRule): RouteRule;
66
34
 
67
- export { MiddlewareRegistry, RequestHandler, RouteDirectoryConfig, RouteRule, defineConfig, defineHandler };
35
+ export { defineConfig, defineHandler, onAfterAll, onBeforeAll };
package/dist/index.d.mts CHANGED
@@ -1,42 +1,10 @@
1
- import { e as RouteDirectoryConfig, c as MiddlewareRegistry, d as RequestHandler, g as RouteRule } from './shared/mokup.DeotZ0g8.mjs';
2
- export { H as HttpMethod, b as MiddlewarePosition, M as MokupPluginOptions, f as RouteResponse, h as RuntimeMode, S as ServiceWorkerOptions, V as VitePluginOptions, i as VitePluginOptionsInput } from './shared/mokup.DeotZ0g8.mjs';
3
- export { Context, MiddlewareHandler } from '@mokup/shared/hono';
4
- export { PlaygroundOptionsInput } from '@mokup/shared';
5
- import '@mokup/runtime';
1
+ import * as _mokup_shared_define_config from '@mokup/shared/define-config';
2
+ import { RouteDirectoryConfig, MiddlewareHandler, RequestHandler, RouteRule } from '@mokup/core';
3
+ export { Context, HookErrorPolicy, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from '@mokup/core';
6
4
 
7
- type DefineConfigFactory = (context: {
8
- pre: MiddlewareRegistry;
9
- normal: MiddlewareRegistry;
10
- post: MiddlewareRegistry;
11
- }) => RouteDirectoryConfig | void;
12
- /**
13
- * Define a directory config with Hono-style middleware registration.
14
- *
15
- * @param input - Config object or factory callback.
16
- * @returns Route directory config with middleware metadata.
17
- *
18
- * @example
19
- * import { defineConfig } from 'mokup'
20
- *
21
- * export default defineConfig(({ pre, normal, post }) => {
22
- * pre.use(async (c, next) => {
23
- * c.header('x-before', '1')
24
- * await next()
25
- * })
26
- *
27
- * normal.use(async (_c, next) => {
28
- * await next()
29
- * })
30
- *
31
- * post.use(async (c, next) => {
32
- * await next()
33
- * c.header('x-after', '1')
34
- * })
35
- *
36
- * return { delay: 120 }
37
- * })
38
- */
39
- declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
5
+ declare const defineConfig: (input: RouteDirectoryConfig | _mokup_shared_define_config.DefineConfigFactory<RouteDirectoryConfig, MiddlewareHandler>) => RouteDirectoryConfig | Promise<RouteDirectoryConfig>;
6
+ declare const onBeforeAll: (handler: _mokup_shared_define_config.HookHandler) => void;
7
+ declare const onAfterAll: (handler: _mokup_shared_define_config.HookHandler) => void;
40
8
 
41
9
  /**
42
10
  * Define a mock route handler with type hints.
@@ -64,4 +32,4 @@ declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory)
64
32
  declare function defineHandler(input: RequestHandler): RequestHandler;
65
33
  declare function defineHandler(input: RouteRule): RouteRule;
66
34
 
67
- export { MiddlewareRegistry, RequestHandler, RouteDirectoryConfig, RouteRule, defineConfig, defineHandler };
35
+ export { defineConfig, defineHandler, onAfterAll, onBeforeAll };
package/dist/index.d.ts CHANGED
@@ -1,44 +1,12 @@
1
1
  /// <reference path="./types/virtual.d.ts" />
2
2
 
3
- import { e as RouteDirectoryConfig, c as MiddlewareRegistry, d as RequestHandler, g as RouteRule } from './shared/mokup.DeotZ0g8.js';
4
- export { H as HttpMethod, b as MiddlewarePosition, M as MokupPluginOptions, f as RouteResponse, h as RuntimeMode, S as ServiceWorkerOptions, V as VitePluginOptions, i as VitePluginOptionsInput } from './shared/mokup.DeotZ0g8.js';
5
- export { Context, MiddlewareHandler } from '@mokup/shared/hono';
6
- export { PlaygroundOptionsInput } from '@mokup/shared';
7
- import '@mokup/runtime';
3
+ import * as _mokup_shared_define_config from '@mokup/shared/define-config';
4
+ import { RouteDirectoryConfig, MiddlewareHandler, RequestHandler, RouteRule } from '@mokup/core';
5
+ export { Context, HookErrorPolicy, HttpMethod, MiddlewareHandler, MiddlewarePosition, MiddlewareRegistry, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from '@mokup/core';
8
6
 
9
- type DefineConfigFactory = (context: {
10
- pre: MiddlewareRegistry;
11
- normal: MiddlewareRegistry;
12
- post: MiddlewareRegistry;
13
- }) => RouteDirectoryConfig | void;
14
- /**
15
- * Define a directory config with Hono-style middleware registration.
16
- *
17
- * @param input - Config object or factory callback.
18
- * @returns Route directory config with middleware metadata.
19
- *
20
- * @example
21
- * import { defineConfig } from 'mokup'
22
- *
23
- * export default defineConfig(({ pre, normal, post }) => {
24
- * pre.use(async (c, next) => {
25
- * c.header('x-before', '1')
26
- * await next()
27
- * })
28
- *
29
- * normal.use(async (_c, next) => {
30
- * await next()
31
- * })
32
- *
33
- * post.use(async (c, next) => {
34
- * await next()
35
- * c.header('x-after', '1')
36
- * })
37
- *
38
- * return { delay: 120 }
39
- * })
40
- */
41
- declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
7
+ declare const defineConfig: (input: RouteDirectoryConfig | _mokup_shared_define_config.DefineConfigFactory<RouteDirectoryConfig, MiddlewareHandler>) => RouteDirectoryConfig | Promise<RouteDirectoryConfig>;
8
+ declare const onBeforeAll: (handler: _mokup_shared_define_config.HookHandler) => void;
9
+ declare const onAfterAll: (handler: _mokup_shared_define_config.HookHandler) => void;
42
10
 
43
11
  /**
44
12
  * Define a mock route handler with type hints.
@@ -66,4 +34,4 @@ declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory)
66
34
  declare function defineHandler(input: RequestHandler): RequestHandler;
67
35
  declare function defineHandler(input: RouteRule): RouteRule;
68
36
 
69
- export { MiddlewareRegistry, RequestHandler, RouteDirectoryConfig, RouteRule, defineConfig, defineHandler };
37
+ export { defineConfig, defineHandler, onAfterAll, onBeforeAll };
package/dist/index.mjs CHANGED
@@ -1,38 +1,14 @@
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
+ import { createDefineConfig } from '@mokup/shared/define-config';
2
+
3
+ const shared = createDefineConfig({
4
+ logPrefix: "[mokup]"
5
+ });
6
+ const defineConfig = shared.defineConfig;
7
+ const onBeforeAll = shared.onBeforeAll;
8
+ const onAfterAll = shared.onAfterAll;
33
9
 
34
10
  function defineHandler(input) {
35
11
  return input;
36
12
  }
37
13
 
38
- export { defineConfig, defineHandler };
14
+ export { defineConfig, defineHandler, onAfterAll, onBeforeAll };
@@ -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;