nitro 3.0.1-alpha.2 → 3.0.260311-beta
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/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +6977 -2556
- package/dist/_build/rolldown.mjs +32 -31
- package/dist/_build/rollup.mjs +28 -35
- package/dist/_build/vite.build.mjs +10 -8
- package/dist/_chunks/nitro.mjs +80 -112
- package/dist/_chunks/nitro2.mjs +8 -7
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +42 -24
- package/dist/_common.mjs +14 -24
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -320
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +52 -36
- package/dist/_libs/citty.mjs +10 -12
- package/dist/_libs/commondir+is-reference.mjs +60 -49
- package/dist/_libs/compatx.mjs +1 -2
- package/dist/_libs/esbuild.d.mts +1 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -2
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +2 -2
- package/dist/_libs/estree-walker.mjs +1 -4
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +146 -169
- package/dist/_libs/httpxy.d.mts +12 -9
- package/dist/_libs/httpxy.mjs +299 -43
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -2
- package/dist/_libs/mlly.d.mts +1 -1
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/plugin-alias.mjs +2 -4
- package/dist/_libs/plugin-inject.mjs +2 -6
- package/dist/_libs/plugin-json.mjs +2 -4
- package/dist/_libs/pluginutils.mjs +5 -11
- package/dist/_libs/readdirp+chokidar.mjs +187 -192
- package/dist/_libs/remapping.mjs +1 -3
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -21
- package/dist/_libs/rou3.d.mts +3 -2
- package/dist/_libs/rou3.mjs +225 -51
- package/dist/_libs/std-env.d.mts +10 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -40
- package/dist/_libs/ultrahtml.mjs +3 -14
- package/dist/_libs/unimport+unplugin.mjs +250 -351
- package/dist/_libs/unplugin+unimport.d.mts +7 -10
- package/dist/_presets.mjs +389 -432
- package/dist/builder.d.mts +5 -4
- package/dist/builder.mjs +12 -6
- package/dist/cli/_chunks/build.mjs +22 -23
- package/dist/cli/_chunks/common.mjs +1 -2
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +9 -9
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +4 -6
- package/dist/cli/_chunks/prepare.mjs +2 -4
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +7 -9
- package/dist/cli/_chunks/task.mjs +1 -3
- package/dist/cli/index.mjs +5 -4
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +34 -31
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +9 -56
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +0 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/bun/runtime/bun.mjs +4 -3
- package/dist/presets/deno/runtime/deno-server.mjs +4 -3
- package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -1
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +3 -2
- package/dist/presets/node/runtime/node-server.mjs +3 -2
- package/dist/presets/stormkit/runtime/stormkit.mjs +0 -1
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +2 -4
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +38 -40
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +9 -4
- package/dist/runtime/internal/route-rules.mjs +9 -1
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +6 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +2 -2
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.mjs +1 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +2 -0
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +68 -117
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +236 -233
- package/package.json +83 -68
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
//#region src/utils.ts
|
|
2
|
-
function flatHooks(configHooks, hooks = {}, parentName) {
|
|
3
|
-
for (const key in configHooks) {
|
|
4
|
-
const subHook = configHooks[key];
|
|
5
|
-
const name = parentName ? `${parentName}:${key}` : key;
|
|
6
|
-
if (typeof subHook === "object" && subHook !== null) flatHooks(subHook, hooks, name);
|
|
7
|
-
else if (typeof subHook === "function") hooks[name] = subHook;
|
|
8
|
-
}
|
|
9
|
-
return hooks;
|
|
10
|
-
}
|
|
11
|
-
function mergeHooks(...hooks) {
|
|
12
|
-
const finalHooks = {};
|
|
13
|
-
for (const hook of hooks) {
|
|
14
|
-
const flatenHook = flatHooks(hook);
|
|
15
|
-
for (const key in flatenHook) if (finalHooks[key]) finalHooks[key].push(flatenHook[key]);
|
|
16
|
-
else finalHooks[key] = [flatenHook[key]];
|
|
17
|
-
}
|
|
18
|
-
for (const key in finalHooks) if (finalHooks[key].length > 1) {
|
|
19
|
-
const array = finalHooks[key];
|
|
20
|
-
finalHooks[key] = (...arguments_) => serial(array, (function_) => function_(...arguments_));
|
|
21
|
-
} else finalHooks[key] = finalHooks[key][0];
|
|
22
|
-
return finalHooks;
|
|
23
|
-
}
|
|
24
|
-
function serial(tasks, function_) {
|
|
25
|
-
return tasks.reduce((promise, task) => promise.then(() => function_(task)), Promise.resolve());
|
|
26
|
-
}
|
|
27
|
-
const createTask = /* @__PURE__ */ (() => {
|
|
28
|
-
if (console.createTask) return console.createTask;
|
|
29
|
-
const defaultTask = { run: (fn) => fn() };
|
|
30
|
-
return () => defaultTask;
|
|
31
|
-
})();
|
|
32
|
-
function callHooks(hooks, args, startIndex, task) {
|
|
33
|
-
for (let i = startIndex; i < hooks.length; i += 1) try {
|
|
34
|
-
const result = task ? task.run(() => hooks[i](...args)) : hooks[i](...args);
|
|
35
|
-
if (result instanceof Promise) return result.then(() => callHooks(hooks, args, i + 1, task));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
return Promise.reject(error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function serialTaskCaller(hooks, args, name) {
|
|
41
|
-
if (hooks.length > 0) return callHooks(hooks, args, 0, createTask(name));
|
|
42
|
-
}
|
|
43
|
-
function parallelTaskCaller(hooks, args, name) {
|
|
44
|
-
if (hooks.length > 0) {
|
|
45
|
-
const task = createTask(name);
|
|
46
|
-
return Promise.all(hooks.map((hook) => task.run(() => hook(...args))));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/** @deprecated */
|
|
50
|
-
function serialCaller(hooks, arguments_) {
|
|
51
|
-
return hooks.reduce((promise, hookFunction) => promise.then(() => hookFunction(...arguments_ || [])), Promise.resolve());
|
|
52
|
-
}
|
|
53
|
-
/** @deprecated */
|
|
54
|
-
function parallelCaller(hooks, args) {
|
|
55
|
-
return Promise.all(hooks.map((hook) => hook(...args || [])));
|
|
56
|
-
}
|
|
57
|
-
function callEachWith(callbacks, arg0) {
|
|
58
|
-
for (const callback of [...callbacks]) callback(arg0);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/hookable.ts
|
|
63
|
-
var Hookable = class {
|
|
64
|
-
_hooks;
|
|
65
|
-
_before;
|
|
66
|
-
_after;
|
|
67
|
-
_deprecatedHooks;
|
|
68
|
-
_deprecatedMessages;
|
|
69
|
-
constructor() {
|
|
70
|
-
this._hooks = {};
|
|
71
|
-
this._before = void 0;
|
|
72
|
-
this._after = void 0;
|
|
73
|
-
this._deprecatedMessages = void 0;
|
|
74
|
-
this._deprecatedHooks = {};
|
|
75
|
-
this.hook = this.hook.bind(this);
|
|
76
|
-
this.callHook = this.callHook.bind(this);
|
|
77
|
-
this.callHookWith = this.callHookWith.bind(this);
|
|
78
|
-
}
|
|
79
|
-
hook(name, function_, options = {}) {
|
|
80
|
-
if (!name || typeof function_ !== "function") return () => {};
|
|
81
|
-
const originalName = name;
|
|
82
|
-
let dep;
|
|
83
|
-
while (this._deprecatedHooks[name]) {
|
|
84
|
-
dep = this._deprecatedHooks[name];
|
|
85
|
-
name = dep.to;
|
|
86
|
-
}
|
|
87
|
-
if (dep && !options.allowDeprecated) {
|
|
88
|
-
let message = dep.message;
|
|
89
|
-
if (!message) message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
|
|
90
|
-
if (!this._deprecatedMessages) this._deprecatedMessages = /* @__PURE__ */ new Set();
|
|
91
|
-
if (!this._deprecatedMessages.has(message)) {
|
|
92
|
-
console.warn(message);
|
|
93
|
-
this._deprecatedMessages.add(message);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (!function_.name) try {
|
|
97
|
-
Object.defineProperty(function_, "name", {
|
|
98
|
-
get: () => "_" + name.replace(/\W+/g, "_") + "_hook_cb",
|
|
99
|
-
configurable: true
|
|
100
|
-
});
|
|
101
|
-
} catch {}
|
|
102
|
-
this._hooks[name] = this._hooks[name] || [];
|
|
103
|
-
this._hooks[name].push(function_);
|
|
104
|
-
return () => {
|
|
105
|
-
if (function_) {
|
|
106
|
-
this.removeHook(name, function_);
|
|
107
|
-
function_ = void 0;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
hookOnce(name, function_) {
|
|
112
|
-
let _unreg;
|
|
113
|
-
let _function = (...arguments_) => {
|
|
114
|
-
if (typeof _unreg === "function") _unreg();
|
|
115
|
-
_unreg = void 0;
|
|
116
|
-
_function = void 0;
|
|
117
|
-
return function_(...arguments_);
|
|
118
|
-
};
|
|
119
|
-
_unreg = this.hook(name, _function);
|
|
120
|
-
return _unreg;
|
|
121
|
-
}
|
|
122
|
-
removeHook(name, function_) {
|
|
123
|
-
const hooks = this._hooks[name];
|
|
124
|
-
if (hooks) {
|
|
125
|
-
const index = hooks.indexOf(function_);
|
|
126
|
-
if (index !== -1) hooks.splice(index, 1);
|
|
127
|
-
if (hooks.length === 0) this._hooks[name] = void 0;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
deprecateHook(name, deprecated) {
|
|
131
|
-
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
|
|
132
|
-
const _hooks = this._hooks[name] || [];
|
|
133
|
-
this._hooks[name] = void 0;
|
|
134
|
-
for (const hook of _hooks) this.hook(name, hook);
|
|
135
|
-
}
|
|
136
|
-
deprecateHooks(deprecatedHooks) {
|
|
137
|
-
for (const name in deprecatedHooks) this.deprecateHook(name, deprecatedHooks[name]);
|
|
138
|
-
}
|
|
139
|
-
addHooks(configHooks) {
|
|
140
|
-
const hooks = flatHooks(configHooks);
|
|
141
|
-
const removeFns = Object.keys(hooks).map((key) => this.hook(key, hooks[key]));
|
|
142
|
-
return () => {
|
|
143
|
-
for (const unreg of removeFns) unreg();
|
|
144
|
-
removeFns.length = 0;
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
removeHooks(configHooks) {
|
|
148
|
-
const hooks = flatHooks(configHooks);
|
|
149
|
-
for (const key in hooks) this.removeHook(key, hooks[key]);
|
|
150
|
-
}
|
|
151
|
-
removeAllHooks() {
|
|
152
|
-
this._hooks = {};
|
|
153
|
-
}
|
|
154
|
-
callHook(name, ...args) {
|
|
155
|
-
return this.callHookWith(serialTaskCaller, name, args);
|
|
156
|
-
}
|
|
157
|
-
callHookParallel(name, ...args) {
|
|
158
|
-
return this.callHookWith(parallelTaskCaller, name, args);
|
|
159
|
-
}
|
|
160
|
-
callHookWith(caller, name, args) {
|
|
161
|
-
const event = this._before || this._after ? {
|
|
162
|
-
name,
|
|
163
|
-
args,
|
|
164
|
-
context: {}
|
|
165
|
-
} : void 0;
|
|
166
|
-
if (this._before) callEachWith(this._before, event);
|
|
167
|
-
const result = caller(this._hooks[name] ? [...this._hooks[name]] : [], args, name);
|
|
168
|
-
if (result instanceof Promise) return result.finally(() => {
|
|
169
|
-
if (this._after && event) callEachWith(this._after, event);
|
|
170
|
-
});
|
|
171
|
-
if (this._after && event) callEachWith(this._after, event);
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
beforeEach(function_) {
|
|
175
|
-
this._before = this._before || [];
|
|
176
|
-
this._before.push(function_);
|
|
177
|
-
return () => {
|
|
178
|
-
if (this._before !== void 0) {
|
|
179
|
-
const index = this._before.indexOf(function_);
|
|
180
|
-
if (index !== -1) this._before.splice(index, 1);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
afterEach(function_) {
|
|
185
|
-
this._after = this._after || [];
|
|
186
|
-
this._after.push(function_);
|
|
187
|
-
return () => {
|
|
188
|
-
if (this._after !== void 0) {
|
|
189
|
-
const index = this._after.indexOf(function_);
|
|
190
|
-
if (index !== -1) this._after.splice(index, 1);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
function createHooks() {
|
|
196
|
-
return new Hookable();
|
|
197
|
-
}
|
|
198
|
-
var HookableCore = class {
|
|
199
|
-
_hooks;
|
|
200
|
-
constructor() {
|
|
201
|
-
this._hooks = {};
|
|
202
|
-
}
|
|
203
|
-
hook(name, fn) {
|
|
204
|
-
if (!name || typeof fn !== "function") return () => {};
|
|
205
|
-
this._hooks[name] = this._hooks[name] || [];
|
|
206
|
-
this._hooks[name].push(fn);
|
|
207
|
-
return () => {
|
|
208
|
-
if (fn) {
|
|
209
|
-
this.removeHook(name, fn);
|
|
210
|
-
fn = void 0;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
removeHook(name, function_) {
|
|
215
|
-
const hooks = this._hooks[name];
|
|
216
|
-
if (hooks) {
|
|
217
|
-
const index = hooks.indexOf(function_);
|
|
218
|
-
if (index !== -1) hooks.splice(index, 1);
|
|
219
|
-
if (hooks.length === 0) this._hooks[name] = void 0;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
callHook(name, ...args) {
|
|
223
|
-
const hooks = this._hooks[name];
|
|
224
|
-
if (!hooks || hooks.length === 0) return;
|
|
225
|
-
return callHooks(hooks, args, 0);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/debugger.ts
|
|
231
|
-
const isBrowser = typeof window !== "undefined";
|
|
232
|
-
/** Start debugging hook names and timing in console */
|
|
233
|
-
function createDebugger(hooks, _options = {}) {
|
|
234
|
-
const options = {
|
|
235
|
-
inspect: isBrowser,
|
|
236
|
-
group: isBrowser,
|
|
237
|
-
filter: () => true,
|
|
238
|
-
..._options
|
|
239
|
-
};
|
|
240
|
-
const _filter = options.filter;
|
|
241
|
-
const filter = typeof _filter === "string" ? (name) => name.startsWith(_filter) : _filter;
|
|
242
|
-
const _tag = options.tag ? `[${options.tag}] ` : "";
|
|
243
|
-
const logPrefix = (event) => _tag + event.name + "".padEnd(event._id, "\0");
|
|
244
|
-
const _idCtr = {};
|
|
245
|
-
const unsubscribeBefore = hooks.beforeEach((event) => {
|
|
246
|
-
if (filter !== void 0 && !filter(event.name)) return;
|
|
247
|
-
_idCtr[event.name] = _idCtr[event.name] || 0;
|
|
248
|
-
event._id = _idCtr[event.name]++;
|
|
249
|
-
console.time(logPrefix(event));
|
|
250
|
-
});
|
|
251
|
-
const unsubscribeAfter = hooks.afterEach((event) => {
|
|
252
|
-
if (filter !== void 0 && !filter(event.name)) return;
|
|
253
|
-
if (options.group) console.groupCollapsed(event.name);
|
|
254
|
-
if (options.inspect) console.timeLog(logPrefix(event), event.args);
|
|
255
|
-
else console.timeEnd(logPrefix(event));
|
|
256
|
-
if (options.group) console.groupEnd();
|
|
257
|
-
_idCtr[event.name]--;
|
|
258
|
-
});
|
|
259
|
-
return { close: () => {
|
|
260
|
-
unsubscribeBefore();
|
|
261
|
-
unsubscribeAfter();
|
|
262
|
-
} };
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
//#endregion
|
|
266
|
-
export { Hookable, HookableCore, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hookable",
|
|
3
|
-
"version": "6.0.1",
|
|
4
|
-
"description": "Awaitable hook system",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"hook",
|
|
7
|
-
"hookable",
|
|
8
|
-
"plugin",
|
|
9
|
-
"tapable",
|
|
10
|
-
"tappable"
|
|
11
|
-
],
|
|
12
|
-
"repository": "unjs/hookable",
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"sideEffects": false,
|
|
15
|
-
"type": "module",
|
|
16
|
-
"exports": {
|
|
17
|
-
".": "./dist/index.mjs"
|
|
18
|
-
},
|
|
19
|
-
"main": "./dist/index.mjs",
|
|
20
|
-
"types": "./dist/index.d.mts",
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"bench": "node --expose-gc --allow-natives-syntax test/bench.ts",
|
|
26
|
-
"build": "obuild src/index.ts",
|
|
27
|
-
"dev": "vitest",
|
|
28
|
-
"lint": "eslint --cache . && prettier -c src test",
|
|
29
|
-
"lint:fix": "eslint --cache . --fix && prettier -c src test -w",
|
|
30
|
-
"prepublish": "pnpm build",
|
|
31
|
-
"release": "pnpm test && pnpm build && changelogen --release --publish --push",
|
|
32
|
-
"test": "pnpm lint && vitest run --coverage",
|
|
33
|
-
"test:types": "tsc --noEmit"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/node": "^25.0.3",
|
|
37
|
-
"@vitest/coverage-v8": "^4.0.16",
|
|
38
|
-
"changelogen": "^0.6.2",
|
|
39
|
-
"esbuild": "^0.27.2",
|
|
40
|
-
"eslint": "^9.39.2",
|
|
41
|
-
"eslint-config-unjs": "^0.5.0",
|
|
42
|
-
"expect-type": "^1.3.0",
|
|
43
|
-
"hookable-prev": "npm:hookable@^5.5.3",
|
|
44
|
-
"mitata": "^1.0.34",
|
|
45
|
-
"obuild": "^0.4.9",
|
|
46
|
-
"prettier": "^3.7.4",
|
|
47
|
-
"typescript": "^5.9.3",
|
|
48
|
-
"vite": "^7.3.0",
|
|
49
|
-
"vitest": "^4.0.16"
|
|
50
|
-
},
|
|
51
|
-
"packageManager": "pnpm@10.26.0"
|
|
52
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// src/helpers.ts
|
|
2
|
-
import useColors from "@poppinss/colors";
|
|
3
|
-
var ANSI_REGEX = new RegExp(
|
|
4
|
-
[
|
|
5
|
-
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,
|
|
6
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
7
|
-
].join("|"),
|
|
8
|
-
"g"
|
|
9
|
-
);
|
|
10
|
-
function htmlEscape(value) {
|
|
11
|
-
return value.replace(/&/g, "&").replace(/\\"/g, "\"").replace(/</g, "<").replace(/>/g, ">");
|
|
12
|
-
}
|
|
13
|
-
function wordWrap(value, options) {
|
|
14
|
-
const width = options.width;
|
|
15
|
-
const indent = options.indent;
|
|
16
|
-
const newLine = `${options.newLine}${indent}`;
|
|
17
|
-
if (!width) {
|
|
18
|
-
return options.escape ? options.escape(value) : htmlEscape(value);
|
|
19
|
-
}
|
|
20
|
-
let regexString = ".{1," + width + "}";
|
|
21
|
-
regexString += "([\\s\u200B]+|$)|[^\\s\u200B]+?([\\s\u200B]+|$)";
|
|
22
|
-
const re = new RegExp(regexString, "g");
|
|
23
|
-
const lines = value.match(re) || [];
|
|
24
|
-
const result = lines.map(function(line) {
|
|
25
|
-
if (line.slice(-1) === "\n") {
|
|
26
|
-
line = line.slice(0, line.length - 1);
|
|
27
|
-
}
|
|
28
|
-
return options.escape ? options.escape(line) : htmlEscape(line);
|
|
29
|
-
}).join(newLine);
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
function stripAnsi(value) {
|
|
33
|
-
return value.replace(ANSI_REGEX, "");
|
|
34
|
-
}
|
|
35
|
-
var colors = useColors.ansi();
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
htmlEscape,
|
|
39
|
-
wordWrap,
|
|
40
|
-
stripAnsi,
|
|
41
|
-
colors
|
|
42
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
colors,
|
|
3
|
-
stripAnsi
|
|
4
|
-
} from "./chunk-4L7RY2JA.js";
|
|
5
|
-
import {
|
|
6
|
-
BaseComponent,
|
|
7
|
-
publicDirURL
|
|
8
|
-
} from "./chunk-PE3GG3TN.js";
|
|
9
|
-
|
|
10
|
-
// src/templates/error_stack_source/main.ts
|
|
11
|
-
import { extname } from "path";
|
|
12
|
-
import { highlightText } from "@speed-highlight/core";
|
|
13
|
-
import { highlightText as cliHighlightText } from "@speed-highlight/core/terminal";
|
|
14
|
-
var GUTTER = "\u2503";
|
|
15
|
-
var POINTER = "\u276F";
|
|
16
|
-
var LANGS_MAP = {
|
|
17
|
-
".tsx": "ts",
|
|
18
|
-
".jsx": "js",
|
|
19
|
-
".js": "js",
|
|
20
|
-
".ts": "ts",
|
|
21
|
-
".css": "css",
|
|
22
|
-
".json": "json",
|
|
23
|
-
".html": "html",
|
|
24
|
-
".astro": "ts",
|
|
25
|
-
".vue": "ts"
|
|
26
|
-
};
|
|
27
|
-
var ErrorStackSource = class extends BaseComponent {
|
|
28
|
-
cssFile = new URL("./error_stack_source/style.css", publicDirURL);
|
|
29
|
-
/**
|
|
30
|
-
* The toHTML method is used to output the HTML for the
|
|
31
|
-
* web view
|
|
32
|
-
*/
|
|
33
|
-
async toHTML(props) {
|
|
34
|
-
const frame = props.frame;
|
|
35
|
-
if (frame.type === "native" || !frame.source || !frame.fileName) {
|
|
36
|
-
return "";
|
|
37
|
-
}
|
|
38
|
-
const language = LANGS_MAP[extname(frame.fileName)] ?? "plain";
|
|
39
|
-
const highlightMarginTop = `${frame.source.findIndex((chunk) => {
|
|
40
|
-
return chunk.lineNumber === frame.lineNumber;
|
|
41
|
-
}) * 24}px`;
|
|
42
|
-
const highlight = `<div class="line-highlight" style="margin-top: ${highlightMarginTop}"></div>`;
|
|
43
|
-
let code = await highlightText(
|
|
44
|
-
frame.source.map((chunk) => chunk.chunk).join("\n"),
|
|
45
|
-
language,
|
|
46
|
-
true
|
|
47
|
-
);
|
|
48
|
-
code = code.replace(
|
|
49
|
-
'<div class="shj-numbers">',
|
|
50
|
-
`<div class="shj-numbers" style="counter-set: line ${frame.source[0].lineNumber - 1}">`
|
|
51
|
-
);
|
|
52
|
-
return `<pre><code class="shj-lang-js">${highlight}${code}</code></pre>`;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The toANSI method is used to output the text for the console
|
|
56
|
-
*/
|
|
57
|
-
async toANSI(props) {
|
|
58
|
-
const frame = props.frame;
|
|
59
|
-
if (frame.type === "native" || !frame.source || !frame.fileName) {
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
const language = LANGS_MAP[extname(frame.fileName)] ?? "plain";
|
|
63
|
-
const largestLineNumber = Math.max(...frame.source.map(({ lineNumber }) => lineNumber));
|
|
64
|
-
const lineNumberCols = String(largestLineNumber).length;
|
|
65
|
-
const code = frame.source.map(({ chunk }) => chunk).join("\n");
|
|
66
|
-
const highlighted = await cliHighlightText(code, language);
|
|
67
|
-
return `
|
|
68
|
-
|
|
69
|
-
${highlighted.split("\n").map((line, index) => {
|
|
70
|
-
const lineNumber = frame.source[index].lineNumber;
|
|
71
|
-
const alignedLineNumber = String(lineNumber).padStart(lineNumberCols, " ");
|
|
72
|
-
if (lineNumber === props.frame.lineNumber) {
|
|
73
|
-
return ` ${colors.bgRed(`${POINTER} ${alignedLineNumber} ${GUTTER} ${stripAnsi(line)}`)}`;
|
|
74
|
-
}
|
|
75
|
-
return ` ${colors.dim(alignedLineNumber)} ${colors.dim(GUTTER)} ${line}`;
|
|
76
|
-
}).join("\n")}
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export {
|
|
82
|
-
ErrorStackSource
|
|
83
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseComponent,
|
|
3
|
-
publicDirURL
|
|
4
|
-
} from "./chunk-PE3GG3TN.js";
|
|
5
|
-
|
|
6
|
-
// src/templates/header/main.ts
|
|
7
|
-
var DARK_MODE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="15" height="15" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M0 0h24v24H0z" stroke="none"/><path d="M12 3h.393a7.5 7.5 0 0 0 7.92 12.446A9 9 0 1 1 12 2.992z"/></svg>`;
|
|
8
|
-
var LIGHT_MODE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="15" height="15" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M0 0h24v24H0z" stroke="none"/><circle cx="12" cy="12" r="4"/><path d="M3 12h1m8-9v1m8 8h1m-9 8v1M5.6 5.6l.7.7m12.1-.7-.7.7m0 11.4.7.7m-12.1-.7-.7.7"/></svg>`;
|
|
9
|
-
var Header = class extends BaseComponent {
|
|
10
|
-
cssFile = new URL("./header/style.css", publicDirURL);
|
|
11
|
-
scriptFile = new URL("./header/script.js", publicDirURL);
|
|
12
|
-
/**
|
|
13
|
-
* The toHTML method is used to output the HTML for the
|
|
14
|
-
* web view
|
|
15
|
-
*/
|
|
16
|
-
async toHTML() {
|
|
17
|
-
return `<header id="header">
|
|
18
|
-
<div id="header-actions">
|
|
19
|
-
<div id="toggle-theme-container">
|
|
20
|
-
<input type="checkbox" id="toggle-theme-checkbox" />
|
|
21
|
-
<label id="toggle-theme-label" for="toggle-theme-checkbox">
|
|
22
|
-
<span id="light-theme-indicator" title="Light mode">${LIGHT_MODE_SVG}</span>
|
|
23
|
-
<span id="dark-theme-indicator" title="Dark mode">${DARK_MODE_SVG}</span>
|
|
24
|
-
</label>
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
</header>`;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The toANSI method is used to output the text for the console
|
|
31
|
-
*/
|
|
32
|
-
async toANSI() {
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
Header
|
|
39
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseComponent,
|
|
3
|
-
publicDirURL
|
|
4
|
-
} from "./chunk-PE3GG3TN.js";
|
|
5
|
-
|
|
6
|
-
// src/templates/layout/main.ts
|
|
7
|
-
var Layout = class extends BaseComponent {
|
|
8
|
-
cssFile = new URL("./layout/style.css", publicDirURL);
|
|
9
|
-
scriptFile = new URL("./layout/script.js", publicDirURL);
|
|
10
|
-
/**
|
|
11
|
-
* The toHTML method is used to output the HTML for the
|
|
12
|
-
* web view
|
|
13
|
-
*/
|
|
14
|
-
async toHTML(props) {
|
|
15
|
-
return `<!DOCTYPE html>
|
|
16
|
-
<html lang="en">
|
|
17
|
-
<head>
|
|
18
|
-
<meta charset="UTF-8" />
|
|
19
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
20
|
-
<title>${props.title}</title>
|
|
21
|
-
<!-- STYLES -->
|
|
22
|
-
<!-- GLOBAL SCRIPT -->
|
|
23
|
-
</head>
|
|
24
|
-
<body>
|
|
25
|
-
<div id="layout">
|
|
26
|
-
${await props.children()}
|
|
27
|
-
</div>
|
|
28
|
-
<!-- SCRIPTS -->
|
|
29
|
-
</body>
|
|
30
|
-
</html>`;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The toANSI method is used to output the text for the console
|
|
34
|
-
*/
|
|
35
|
-
async toANSI(props) {
|
|
36
|
-
return `
|
|
37
|
-
${await props.children()}
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
Layout
|
|
44
|
-
};
|