mokup 2.1.0 → 2.1.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.
@@ -283,7 +283,7 @@ function resolvePlaygroundOptions(playground) {
283
283
  return { enabled: true, path: "/__mokup" };
284
284
  }
285
285
 
286
- 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.i875Kuim.cjs', document.baseURI).href)));
286
+ 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.To7knvSq.cjs', document.baseURI).href)));
287
287
  const mimeTypes = {
288
288
  ".html": "text/html; charset=utf-8",
289
289
  ".css": "text/css; charset=utf-8",
@@ -774,6 +774,7 @@ function resolveSwUnregisterConfig(options, logger) {
774
774
  function buildSwScript(params) {
775
775
  const { routes, root } = params;
776
776
  const runtimeImportPath = params.runtimeImportPath ?? "mokup/runtime";
777
+ const loggerImportPath = params.loggerImportPath ?? "@mokup/shared/logger";
777
778
  const basePaths = params.basePaths ?? [];
778
779
  const resolveModulePath = params.resolveModulePath ?? toViteImportPath;
779
780
  const { manifest, modules } = buildManifestData({
@@ -782,7 +783,7 @@ function buildSwScript(params) {
782
783
  resolveModulePath
783
784
  });
784
785
  const imports = [
785
- "import { createLogger } from '@mokup/shared/logger'",
786
+ `import { createLogger } from ${JSON.stringify(loggerImportPath)}`,
786
787
  `import { createRuntimeApp, handle } from ${JSON.stringify(runtimeImportPath)}`
787
788
  ];
788
789
  const moduleEntries = [];
@@ -1315,7 +1316,7 @@ function isConfigFile(file) {
1315
1316
  return configExtensions.includes(ext);
1316
1317
  }
1317
1318
 
1318
- const sourceRoot = pathe.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.i875Kuim.cjs', document.baseURI).href))));
1319
+ const sourceRoot = pathe.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.To7knvSq.cjs', document.baseURI).href))));
1319
1320
  const mokupSourceEntry = pathe.resolve(sourceRoot, "../index.ts");
1320
1321
  const mokupViteSourceEntry = pathe.resolve(sourceRoot, "../vite.ts");
1321
1322
  const hasMokupSourceEntry = node_fs.existsSync(mokupSourceEntry);
@@ -1340,7 +1341,7 @@ const workspaceResolvePlugin = createWorkspaceResolvePlugin();
1340
1341
  async function loadModule(file) {
1341
1342
  const ext = pathe.extname(file).toLowerCase();
1342
1343
  if (ext === ".cjs") {
1343
- 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.i875Kuim.cjs', document.baseURI).href)));
1344
+ 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.To7knvSq.cjs', document.baseURI).href)));
1344
1345
  delete require$1.cache[file];
1345
1346
  return require$1(file);
1346
1347
  }
@@ -771,6 +771,7 @@ function resolveSwUnregisterConfig(options, logger) {
771
771
  function buildSwScript(params) {
772
772
  const { routes, root } = params;
773
773
  const runtimeImportPath = params.runtimeImportPath ?? "mokup/runtime";
774
+ const loggerImportPath = params.loggerImportPath ?? "@mokup/shared/logger";
774
775
  const basePaths = params.basePaths ?? [];
775
776
  const resolveModulePath = params.resolveModulePath ?? toViteImportPath;
776
777
  const { manifest, modules } = buildManifestData({
@@ -779,7 +780,7 @@ function buildSwScript(params) {
779
780
  resolveModulePath
780
781
  });
781
782
  const imports = [
782
- "import { createLogger } from '@mokup/shared/logger'",
783
+ `import { createLogger } from ${JSON.stringify(loggerImportPath)}`,
783
784
  `import { createRuntimeApp, handle } from ${JSON.stringify(runtimeImportPath)}`
784
785
  ];
785
786
  const moduleEntries = [];
package/dist/vite.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const process = require('node:process');
4
- const scanner = require('./shared/mokup.i875Kuim.cjs');
4
+ const scanner = require('./shared/mokup.To7knvSq.cjs');
5
5
  const logger = require('@mokup/shared/logger');
6
6
  const pc = require('picocolors');
7
7
  const node_path = require('node:path');
@@ -148,6 +148,10 @@ function resolveSwRuntimeImportPath(base) {
148
148
  const normalizedBase = normalizeBase(base);
149
149
  return `${normalizedBase}@id/mokup/runtime`;
150
150
  }
151
+ function resolveSwLoggerImportPath(base) {
152
+ const normalizedBase = normalizeBase(base);
153
+ return `${normalizedBase}@id/@mokup/shared/logger`;
154
+ }
151
155
 
152
156
  function buildRouteSignature(routes, disabledRoutes, ignoredRoutes, configFiles, disabledConfigFiles) {
153
157
  return routes.map(
@@ -316,6 +320,47 @@ function addMiddlewareFirst(server, middleware) {
316
320
  server.middlewares.use(middleware);
317
321
  }
318
322
 
323
+ const portPattern = /:(?<port>\d{2,5})/g;
324
+ const escapeCode = 27;
325
+ function stripAnsi(value) {
326
+ let output = "";
327
+ for (let index = 0; index < value.length; index += 1) {
328
+ const code = value.charCodeAt(index);
329
+ if (code === escapeCode && value[index + 1] === "[") {
330
+ index += 1;
331
+ while (index < value.length && value[index] !== "m") {
332
+ index += 1;
333
+ }
334
+ continue;
335
+ }
336
+ output += value[index];
337
+ }
338
+ return output;
339
+ }
340
+ function formatOutputLine(line, options) {
341
+ const { arrowToken, formattedArrow, labels, formatLabel, formatPort } = options;
342
+ let output = formattedArrow ? line.replaceAll(arrowToken, formattedArrow) : line;
343
+ if (labels && formatLabel) {
344
+ for (const label of labels) {
345
+ output = output.replaceAll(label, formatLabel(label));
346
+ }
347
+ }
348
+ if (formatPort) {
349
+ output = output.replace(portPattern, (_match, port) => `:${formatPort(port)}`);
350
+ }
351
+ return output;
352
+ }
353
+
354
+ const arrowToken = "\u279C";
355
+ const playgroundLabel = "Mokup Playground";
356
+ const coloredArrow = pc__default.green(arrowToken);
357
+ const formatOptions = {
358
+ arrowToken,
359
+ formattedArrow: coloredArrow,
360
+ labels: [playgroundLabel],
361
+ formatLabel: pc__default.bold,
362
+ formatPort: pc__default.bold
363
+ };
319
364
  function patchPlaygroundPrintUrls(server, playgroundPath) {
320
365
  const originalPrintUrls = server.printUrls.bind(server);
321
366
  const patchPrintUrls = () => {
@@ -340,18 +385,22 @@ function patchPlaygroundPrintUrls(server, playgroundPath) {
340
385
  const localUrl = server.resolvedUrls?.local?.[0];
341
386
  const outputUrl = formatPlaygroundUrl(localUrl, playgroundPath);
342
387
  const coloredUrl = pc__default.magenta(outputUrl);
343
- const playgroundLine = ` \u279C Mokup Playground: ${coloredUrl}`;
344
- const ansiEscape = "\x1B";
345
- const ansiPattern = new RegExp(`${ansiEscape}\\[[0-9;]*m`, "g");
346
- const stripAnsi = (value) => value.replace(ansiPattern, "");
388
+ const playgroundLine = ` ${arrowToken} ${playgroundLabel}: ${coloredUrl}`;
389
+ const arrowPrefix = ` ${arrowToken} `;
347
390
  const findIndex = (needle) => lines.findIndex((args) => stripAnsi(args[0]).includes(needle));
348
- const networkIndex = findIndex(" \u279C Network:");
349
- const localIndex = findIndex(" \u279C Local:");
391
+ const networkIndex = findIndex(`${arrowPrefix}Network:`);
392
+ const localIndex = findIndex(`${arrowPrefix}Local:`);
350
393
  const insertIndex = networkIndex >= 0 ? networkIndex + 1 : localIndex >= 0 ? localIndex + 1 : lines.length;
351
394
  const outputLines = lines.slice();
352
395
  outputLines.splice(insertIndex, 0, [playgroundLine]);
353
396
  for (const args of outputLines) {
354
- originalInfo(...args);
397
+ if (typeof args[0] === "string") {
398
+ const nextArgs = args.slice();
399
+ nextArgs[0] = formatOutputLine(nextArgs[0], formatOptions);
400
+ originalInfo(...nextArgs);
401
+ } else {
402
+ originalInfo(...args);
403
+ }
355
404
  }
356
405
  };
357
406
  Object.defineProperty(server, "printUrls", {
@@ -476,6 +525,7 @@ async function configureDevServer(params) {
476
525
  routes: state.swRoutes,
477
526
  root,
478
527
  runtimeImportPath: resolveSwRuntimeImportPath(base),
528
+ loggerImportPath: resolveSwLoggerImportPath(base),
479
529
  basePaths: swConfig?.basePaths ?? []
480
530
  });
481
531
  res.statusCode = 200;
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cwd } from 'node:process';
2
- import { k as buildManifestData, r as resolveDirs, s as scanRoutes, a as sortRoutes, c as createHonoApp, i as isInDirs, d as createDebouncer, b as buildSwScript, j as createMiddleware, e as resolvePlaygroundOptions, f as resolveSwConfig, g as resolveSwUnregisterConfig, h as createPlaygroundMiddleware } from './shared/mokup.Bp9u3JKA.mjs';
2
+ import { k as buildManifestData, r as resolveDirs, s as scanRoutes, a as sortRoutes, c as createHonoApp, i as isInDirs, d as createDebouncer, b as buildSwScript, j as createMiddleware, e as resolvePlaygroundOptions, f as resolveSwConfig, g as resolveSwUnregisterConfig, h as createPlaygroundMiddleware } from './shared/mokup.ghra3mzH.mjs';
3
3
  import { createLogger } from '@mokup/shared/logger';
4
4
  import pc from 'picocolors';
5
5
  import { isAbsolute, resolve } from 'node:path';
@@ -140,6 +140,10 @@ function resolveSwRuntimeImportPath(base) {
140
140
  const normalizedBase = normalizeBase(base);
141
141
  return `${normalizedBase}@id/mokup/runtime`;
142
142
  }
143
+ function resolveSwLoggerImportPath(base) {
144
+ const normalizedBase = normalizeBase(base);
145
+ return `${normalizedBase}@id/@mokup/shared/logger`;
146
+ }
143
147
 
144
148
  function buildRouteSignature(routes, disabledRoutes, ignoredRoutes, configFiles, disabledConfigFiles) {
145
149
  return routes.map(
@@ -308,6 +312,47 @@ function addMiddlewareFirst(server, middleware) {
308
312
  server.middlewares.use(middleware);
309
313
  }
310
314
 
315
+ const portPattern = /:(?<port>\d{2,5})/g;
316
+ const escapeCode = 27;
317
+ function stripAnsi(value) {
318
+ let output = "";
319
+ for (let index = 0; index < value.length; index += 1) {
320
+ const code = value.charCodeAt(index);
321
+ if (code === escapeCode && value[index + 1] === "[") {
322
+ index += 1;
323
+ while (index < value.length && value[index] !== "m") {
324
+ index += 1;
325
+ }
326
+ continue;
327
+ }
328
+ output += value[index];
329
+ }
330
+ return output;
331
+ }
332
+ function formatOutputLine(line, options) {
333
+ const { arrowToken, formattedArrow, labels, formatLabel, formatPort } = options;
334
+ let output = formattedArrow ? line.replaceAll(arrowToken, formattedArrow) : line;
335
+ if (labels && formatLabel) {
336
+ for (const label of labels) {
337
+ output = output.replaceAll(label, formatLabel(label));
338
+ }
339
+ }
340
+ if (formatPort) {
341
+ output = output.replace(portPattern, (_match, port) => `:${formatPort(port)}`);
342
+ }
343
+ return output;
344
+ }
345
+
346
+ const arrowToken = "\u279C";
347
+ const playgroundLabel = "Mokup Playground";
348
+ const coloredArrow = pc.green(arrowToken);
349
+ const formatOptions = {
350
+ arrowToken,
351
+ formattedArrow: coloredArrow,
352
+ labels: [playgroundLabel],
353
+ formatLabel: pc.bold,
354
+ formatPort: pc.bold
355
+ };
311
356
  function patchPlaygroundPrintUrls(server, playgroundPath) {
312
357
  const originalPrintUrls = server.printUrls.bind(server);
313
358
  const patchPrintUrls = () => {
@@ -332,18 +377,22 @@ function patchPlaygroundPrintUrls(server, playgroundPath) {
332
377
  const localUrl = server.resolvedUrls?.local?.[0];
333
378
  const outputUrl = formatPlaygroundUrl(localUrl, playgroundPath);
334
379
  const coloredUrl = pc.magenta(outputUrl);
335
- const playgroundLine = ` \u279C Mokup Playground: ${coloredUrl}`;
336
- const ansiEscape = "\x1B";
337
- const ansiPattern = new RegExp(`${ansiEscape}\\[[0-9;]*m`, "g");
338
- const stripAnsi = (value) => value.replace(ansiPattern, "");
380
+ const playgroundLine = ` ${arrowToken} ${playgroundLabel}: ${coloredUrl}`;
381
+ const arrowPrefix = ` ${arrowToken} `;
339
382
  const findIndex = (needle) => lines.findIndex((args) => stripAnsi(args[0]).includes(needle));
340
- const networkIndex = findIndex(" \u279C Network:");
341
- const localIndex = findIndex(" \u279C Local:");
383
+ const networkIndex = findIndex(`${arrowPrefix}Network:`);
384
+ const localIndex = findIndex(`${arrowPrefix}Local:`);
342
385
  const insertIndex = networkIndex >= 0 ? networkIndex + 1 : localIndex >= 0 ? localIndex + 1 : lines.length;
343
386
  const outputLines = lines.slice();
344
387
  outputLines.splice(insertIndex, 0, [playgroundLine]);
345
388
  for (const args of outputLines) {
346
- originalInfo(...args);
389
+ if (typeof args[0] === "string") {
390
+ const nextArgs = args.slice();
391
+ nextArgs[0] = formatOutputLine(nextArgs[0], formatOptions);
392
+ originalInfo(...nextArgs);
393
+ } else {
394
+ originalInfo(...args);
395
+ }
347
396
  }
348
397
  };
349
398
  Object.defineProperty(server, "printUrls", {
@@ -468,6 +517,7 @@ async function configureDevServer(params) {
468
517
  routes: state.swRoutes,
469
518
  root,
470
519
  runtimeImportPath: resolveSwRuntimeImportPath(base),
520
+ loggerImportPath: resolveSwLoggerImportPath(base),
471
521
  basePaths: swConfig?.basePaths ?? []
472
522
  });
473
523
  res.statusCode = 200;
package/dist/webpack.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const process = require('node:process');
4
- const scanner = require('./shared/mokup.i875Kuim.cjs');
4
+ const scanner = require('./shared/mokup.To7knvSq.cjs');
5
5
  const logger = require('@mokup/shared/logger');
6
6
  const esbuild = require('@mokup/shared/esbuild');
7
7
  const node_module = require('node:module');
package/dist/webpack.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cwd } from 'node:process';
2
- import { b as buildSwScript, t as toPosix, r as resolveDirs, s as scanRoutes, a as sortRoutes, c as createHonoApp, i as isInDirs, d as createDebouncer, e as resolvePlaygroundOptions, f as resolveSwConfig, g as resolveSwUnregisterConfig, h as createPlaygroundMiddleware, j as createMiddleware } from './shared/mokup.Bp9u3JKA.mjs';
2
+ import { b as buildSwScript, t as toPosix, r as resolveDirs, s as scanRoutes, a as sortRoutes, c as createHonoApp, i as isInDirs, d as createDebouncer, e as resolvePlaygroundOptions, f as resolveSwConfig, g as resolveSwUnregisterConfig, h as createPlaygroundMiddleware, j as createMiddleware } from './shared/mokup.ghra3mzH.mjs';
3
3
  import { createLogger } from '@mokup/shared/logger';
4
4
  import { build } from '@mokup/shared/esbuild';
5
5
  import { createRequire } from 'node:module';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mokup",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "description": "Mock utilities and Vite plugin for mokup.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://mokup.icebreaker.top",
@@ -92,10 +92,10 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "picocolors": "^1.1.1",
95
- "@mokup/cli": "1.0.6",
96
- "@mokup/playground": "0.0.11",
95
+ "@mokup/cli": "1.0.7",
96
+ "@mokup/playground": "0.0.12",
97
97
  "@mokup/runtime": "1.0.3",
98
- "@mokup/server": "1.1.3",
98
+ "@mokup/server": "1.1.4",
99
99
  "@mokup/shared": "1.0.2"
100
100
  },
101
101
  "devDependencies": {