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
package/dist/builder.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as NitroDevApp } from "./_dev.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { RunnerMessageListener, RunnerRPCHooks } from "env-runner";
|
|
3
|
+
import { IncomingMessage } from "node:http";
|
|
4
4
|
import { Server, ServerOptions } from "srvx";
|
|
5
|
-
import { LoadConfigOptions, Nitro, NitroBuildInfo, NitroConfig, NitroOptions,
|
|
5
|
+
import { LoadConfigOptions, Nitro, NitroBuildInfo, NitroConfig, NitroOptions, TaskEvent, TaskRunnerOptions } from "nitro/types";
|
|
6
|
+
import { Socket } from "node:net";
|
|
6
7
|
|
|
7
8
|
//#region src/nitro.d.ts
|
|
8
9
|
declare function createNitro(config?: NitroConfig, opts?: LoadConfigOptions): Promise<Nitro>;
|
|
@@ -36,7 +37,7 @@ declare function createDevServer(nitro: Nitro): NitroDevServer;
|
|
|
36
37
|
declare class NitroDevServer extends NitroDevApp implements RunnerRPCHooks {
|
|
37
38
|
#private;
|
|
38
39
|
constructor(nitro: Nitro);
|
|
39
|
-
upgrade(req: IncomingMessage, socket:
|
|
40
|
+
upgrade(req: IncomingMessage, socket: Socket, head: any): Promise<void>;
|
|
40
41
|
listen(opts?: Partial<Omit<ServerOptions, "fetch">>): Server;
|
|
41
42
|
close(): Promise<void>;
|
|
42
43
|
reload(): void;
|
package/dist/builder.mjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { D as
|
|
3
|
-
import "./_libs/
|
|
1
|
+
import "./_libs/c12+rc9.mjs";
|
|
2
|
+
import { D as copyPublicAssets, E as prepare, _ as writeTypes, j as build, m as getBuildInfo } from "./_build/common.mjs";
|
|
3
|
+
import "./_libs/compatx.mjs";
|
|
4
|
+
import "./_libs/klona.mjs";
|
|
4
5
|
import { a as loadOptions, i as createNitro, n as runTask, r as prerender, t as listTasks } from "./_chunks/nitro.mjs";
|
|
6
|
+
import "./_libs/escape-string-regexp.mjs";
|
|
5
7
|
import "./_libs/tsconfck.mjs";
|
|
6
8
|
import "./_chunks/nitro2.mjs";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import "./_libs/rou3.mjs";
|
|
10
|
+
import "./_libs/readdirp+chokidar.mjs";
|
|
11
|
+
import "./_libs/perfect-debounce.mjs";
|
|
12
|
+
import "./_libs/httpxy.mjs";
|
|
13
|
+
import { n as createDevServer } from "./_dev.mjs";
|
|
14
|
+
import "./_libs/ultrahtml.mjs";
|
|
15
|
+
export { build, copyPublicAssets, createDevServer, createNitro, getBuildInfo, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as resolve } from "../../_build/common.mjs";
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
3
|
import { t as commonArgs } from "./common.mjs";
|
|
4
4
|
import { build, copyPublicAssets, createNitro, prepare, prerender } from "nitro/builder";
|
|
5
|
-
|
|
6
5
|
//#region src/cli/commands/build.ts
|
|
6
|
+
const buildArgs = {
|
|
7
|
+
...commonArgs,
|
|
8
|
+
minify: {
|
|
9
|
+
type: "boolean",
|
|
10
|
+
description: "Minify the output (overrides preset defaults you can also use `--no-minify` to disable)."
|
|
11
|
+
},
|
|
12
|
+
preset: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "The build preset to use (you can also use `NITRO_PRESET` environment variable)."
|
|
15
|
+
},
|
|
16
|
+
builder: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "The builder to use (you can also use `NITRO_BUILDER` environment variable)."
|
|
19
|
+
},
|
|
20
|
+
compatibilityDate: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "The date to use for preset compatibility (you can also use `NITRO_COMPATIBILITY_DATE` environment variable)."
|
|
23
|
+
}
|
|
24
|
+
};
|
|
7
25
|
var build_default = defineCommand({
|
|
8
26
|
meta: {
|
|
9
27
|
name: "build",
|
|
10
28
|
description: "Build nitro project for production"
|
|
11
29
|
},
|
|
12
|
-
args:
|
|
13
|
-
...commonArgs,
|
|
14
|
-
minify: {
|
|
15
|
-
type: "boolean",
|
|
16
|
-
description: "Minify the output (overrides preset defaults you can also use `--no-minify` to disable)."
|
|
17
|
-
},
|
|
18
|
-
preset: {
|
|
19
|
-
type: "string",
|
|
20
|
-
description: "The build preset to use (you can also use `NITRO_PRESET` environment variable)."
|
|
21
|
-
},
|
|
22
|
-
builder: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "The builder to use (you can also use `NITRO_BUILDER` environment variable)."
|
|
25
|
-
},
|
|
26
|
-
compatibilityDate: {
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "The date to use for preset compatibility (you can also use `NITRO_COMPATIBILITY_DATE` environment variable)."
|
|
29
|
-
}
|
|
30
|
-
},
|
|
30
|
+
args: buildArgs,
|
|
31
31
|
async run({ args }) {
|
|
32
32
|
const nitro = await createNitro({
|
|
33
33
|
rootDir: resolve(args.dir || args._dir || "."),
|
|
@@ -43,6 +43,5 @@ var build_default = defineCommand({
|
|
|
43
43
|
await nitro.close();
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
|
|
47
46
|
//#endregion
|
|
48
|
-
export { build_default as default };
|
|
47
|
+
export { buildArgs, build_default as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { dt as resolve, m as getBuildInfo, ut as relative } from "../../_build/common.mjs";
|
|
2
|
+
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
|
+
import "./common.mjs";
|
|
4
|
+
import build_default, { buildArgs } from "./build.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
|
+
//#region src/cli/commands/deploy.ts
|
|
8
|
+
var deploy_default = defineCommand({
|
|
9
|
+
meta: {
|
|
10
|
+
name: "deploy",
|
|
11
|
+
description: "Build and deploy nitro project for production"
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
...buildArgs,
|
|
15
|
+
prebuilt: {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
description: "Skip the build step and deploy the existing build"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async run(ctx) {
|
|
21
|
+
globalThis.__nitroDeploying__ = true;
|
|
22
|
+
if (!ctx.args.prebuilt) await build_default.run(ctx);
|
|
23
|
+
if (globalThis.__nitroDeployed__) return;
|
|
24
|
+
const { buildInfo, outputDir } = await getBuildInfo(resolve(ctx.args.dir || ctx.args._dir || "."));
|
|
25
|
+
if (!buildInfo) {
|
|
26
|
+
consola.error("No build info found, cannot deploy.");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
if (!buildInfo.commands?.deploy) {
|
|
30
|
+
consola.error(`The \`${buildInfo.preset}\` preset does not have a default deploy command.\n\nTry using a different preset with the \`--preset\` option, or configure a deploy command in the Nitro config, or deploy manually.`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const extraArgs = ctx.rawArgs.indexOf("--") !== -1 ? ctx.rawArgs.slice(ctx.rawArgs.indexOf("--") + 1).join(" ") : "";
|
|
34
|
+
const deployCommand = buildInfo.commands.deploy.replace(/([\s:])\.\/(\S*)/g, `$1${relative(process.cwd(), outputDir)}/$2`) + (extraArgs ? ` ${extraArgs}` : "");
|
|
35
|
+
consola.info(`$ ${deployCommand}`);
|
|
36
|
+
execSync(deployCommand, { stdio: "inherit" });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
40
|
+
export { deploy_default as default };
|
package/dist/cli/_chunks/dev.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../_libs/
|
|
3
|
-
import
|
|
1
|
+
import { dt as resolve } from "../../_build/common.mjs";
|
|
2
|
+
import "../../_libs/readdirp+chokidar.mjs";
|
|
3
|
+
import "../../_libs/perfect-debounce.mjs";
|
|
4
|
+
import "../../_libs/httpxy.mjs";
|
|
5
|
+
import { t as NitroDevServer } from "../../_dev.mjs";
|
|
4
6
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
5
7
|
import { t as commonArgs } from "./common.mjs";
|
|
6
|
-
import { consola } from "consola";
|
|
8
|
+
import { consola as consola$1 } from "consola";
|
|
7
9
|
import { build, createNitro, prepare } from "nitro/builder";
|
|
8
|
-
|
|
9
10
|
//#region src/cli/commands/dev.ts
|
|
10
11
|
const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
|
|
11
12
|
var dev_default = defineCommand({
|
|
@@ -29,7 +30,7 @@ var dev_default = defineCommand({
|
|
|
29
30
|
let nitro;
|
|
30
31
|
const reload = async () => {
|
|
31
32
|
if (nitro) {
|
|
32
|
-
consola.info("Restarting dev server...");
|
|
33
|
+
consola$1.info("Restarting dev server...");
|
|
33
34
|
if ("unwatch" in nitro.options._c12) await nitro.options._c12.unwatch();
|
|
34
35
|
await nitro.close();
|
|
35
36
|
}
|
|
@@ -42,7 +43,7 @@ var dev_default = defineCommand({
|
|
|
42
43
|
c12: { async onUpdate({ getDiff, newConfig }) {
|
|
43
44
|
const diff = getDiff();
|
|
44
45
|
if (diff.length === 0) return;
|
|
45
|
-
consola.info("Nitro config updated:\n" + diff.map((entry) => ` ${entry.toString()}`).join("\n"));
|
|
46
|
+
consola$1.info("Nitro config updated:\n" + diff.map((entry) => ` ${entry.toString()}`).join("\n"));
|
|
46
47
|
await (diff.every((e) => hmrKeyRe.test(e.key)) ? nitro.updateConfig(newConfig.config || {}) : reload());
|
|
47
48
|
} }
|
|
48
49
|
});
|
|
@@ -57,6 +58,5 @@ var dev_default = defineCommand({
|
|
|
57
58
|
await reload();
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
|
-
|
|
61
61
|
//#endregion
|
|
62
|
-
export { dev_default as default };
|
|
62
|
+
export { dev_default as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
//#region src/cli/commands/docs.ts
|
|
4
|
+
var docs_default = defineCommand({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "docs",
|
|
7
|
+
description: "Explore Nitro documentation"
|
|
8
|
+
},
|
|
9
|
+
args: { page: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "Page path to open"
|
|
12
|
+
} },
|
|
13
|
+
run({ rawArgs }) {
|
|
14
|
+
const runnerCmd = ([
|
|
15
|
+
["bun", "x"],
|
|
16
|
+
["pnpm", "dlx"],
|
|
17
|
+
["npm", "x"]
|
|
18
|
+
].find(([pkg]) => {
|
|
19
|
+
try {
|
|
20
|
+
execSync(`${pkg} -v`, { stdio: "ignore" });
|
|
21
|
+
return true;
|
|
22
|
+
} catch {}
|
|
23
|
+
}) || ["npm", "x"]).join(" ");
|
|
24
|
+
const docsDir = new URL("../../../skills/nitro/docs", import.meta.url).pathname;
|
|
25
|
+
const args = rawArgs?.join(" ") || "";
|
|
26
|
+
execSync(`${runnerCmd} mdzilla ${docsDir}${args ? ` ${args}` : ""}`, { stdio: "inherit" });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { docs_default as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as resolve } from "../../_build/common.mjs";
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
|
-
import { consola } from "consola";
|
|
3
|
+
import { consola as consola$1 } from "consola";
|
|
4
4
|
import { listTasks, loadOptions } from "nitro/builder";
|
|
5
|
-
|
|
6
5
|
//#region src/cli/commands/task/list.ts
|
|
7
6
|
var list_default = defineCommand({
|
|
8
7
|
meta: {
|
|
@@ -19,9 +18,8 @@ var list_default = defineCommand({
|
|
|
19
18
|
cwd,
|
|
20
19
|
buildDir: (await loadOptions({ rootDir: cwd }).catch(() => void 0))?.buildDir || ".nitro"
|
|
21
20
|
});
|
|
22
|
-
for (const [name, task] of Object.entries(tasks)) consola.log(` - \`${name}\`${task.meta?.description ? ` - ${task.meta.description}` : ""}`);
|
|
21
|
+
for (const [name, task] of Object.entries(tasks)) consola$1.log(` - \`${name}\`${task.meta?.description ? ` - ${task.meta.description}` : ""}`);
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
|
-
export { list_default as default };
|
|
25
|
+
export { list_default as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as resolve } from "../../_build/common.mjs";
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
3
|
import { t as commonArgs } from "./common.mjs";
|
|
4
4
|
import { createNitro, writeTypes } from "nitro/builder";
|
|
5
|
-
|
|
6
5
|
//#region src/cli/commands/prepare.ts
|
|
7
6
|
var prepare_default = defineCommand({
|
|
8
7
|
meta: {
|
|
@@ -14,6 +13,5 @@ var prepare_default = defineCommand({
|
|
|
14
13
|
await writeTypes(await createNitro({ rootDir: resolve(args.dir || args._dir || ".") }));
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
|
-
export { prepare_default as default };
|
|
17
|
+
export { prepare_default as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { dt as resolve } from "../../_build/common.mjs";
|
|
2
|
+
import "../../_libs/httpxy.mjs";
|
|
3
|
+
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
4
|
+
import { t as startPreview } from "../../_chunks/nitro3.mjs";
|
|
5
|
+
import { t as commonArgs } from "./common.mjs";
|
|
6
|
+
import { serve } from "srvx";
|
|
7
|
+
import { log } from "srvx/log";
|
|
8
|
+
//#region src/cli/commands/preview.ts
|
|
9
|
+
var preview_default = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "preview",
|
|
12
|
+
description: "Start a local server to preview the built server"
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
...commonArgs,
|
|
16
|
+
port: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "specify port"
|
|
19
|
+
},
|
|
20
|
+
host: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "specify hostname"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
async run({ args }) {
|
|
26
|
+
const rootDir = resolve(args.dir || args._dir || ".");
|
|
27
|
+
const server = serve({
|
|
28
|
+
fetch(req) {
|
|
29
|
+
return preview.fetch(req);
|
|
30
|
+
},
|
|
31
|
+
middleware: [log()],
|
|
32
|
+
gracefulShutdown: false,
|
|
33
|
+
port: args.port,
|
|
34
|
+
hostname: args.host
|
|
35
|
+
});
|
|
36
|
+
const preview = await startPreview({
|
|
37
|
+
rootDir,
|
|
38
|
+
loader: { srvxServer: server }
|
|
39
|
+
});
|
|
40
|
+
if (preview.upgrade) server.node?.server?.on("upgrade", (req, socket, head) => {
|
|
41
|
+
preview.upgrade(req, socket, head);
|
|
42
|
+
});
|
|
43
|
+
process.on("SIGINT", async () => {
|
|
44
|
+
await server.close();
|
|
45
|
+
await preview.close();
|
|
46
|
+
process.exit(0);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
export { preview_default as default };
|
package/dist/cli/_chunks/run.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as resolve } from "../../_build/common.mjs";
|
|
2
2
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
3
|
-
import { consola } from "consola";
|
|
3
|
+
import { consola as consola$1 } from "consola";
|
|
4
4
|
import destr from "destr";
|
|
5
5
|
import { loadOptions, runTask } from "nitro/builder";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/task/run.ts
|
|
8
7
|
var run_default = defineCommand({
|
|
9
8
|
meta: {
|
|
@@ -28,10 +27,10 @@ var run_default = defineCommand({
|
|
|
28
27
|
async run({ args }) {
|
|
29
28
|
const cwd = resolve(args.dir || args.cwd || ".");
|
|
30
29
|
const options = await loadOptions({ rootDir: cwd }).catch(() => void 0);
|
|
31
|
-
consola.info(`Running task \`${args.name}\`...`);
|
|
30
|
+
consola$1.info(`Running task \`${args.name}\`...`);
|
|
32
31
|
let payload = destr(args.payload || "{}");
|
|
33
32
|
if (typeof payload !== "object") {
|
|
34
|
-
consola.error(`Invalid payload: \`${args.payload}\` (it should be a valid JSON object)`);
|
|
33
|
+
consola$1.error(`Invalid payload: \`${args.payload}\` (it should be a valid JSON object)`);
|
|
35
34
|
payload = void 0;
|
|
36
35
|
}
|
|
37
36
|
try {
|
|
@@ -43,13 +42,12 @@ var run_default = defineCommand({
|
|
|
43
42
|
cwd,
|
|
44
43
|
buildDir: options?.buildDir || ".nitro"
|
|
45
44
|
});
|
|
46
|
-
consola.success("Result:", result);
|
|
45
|
+
consola$1.success("Result:", result);
|
|
47
46
|
} catch (error) {
|
|
48
|
-
consola.error(`Failed to run task \`${args.name}\`: ${error}`);
|
|
47
|
+
consola$1.error(`Failed to run task \`${args.name}\`: ${error}`);
|
|
49
48
|
process.exit(1);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
|
-
|
|
54
52
|
//#endregion
|
|
55
|
-
export { run_default as default };
|
|
53
|
+
export { run_default as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { t as defineCommand } from "../../_libs/citty.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/cli/commands/task/index.ts
|
|
4
3
|
var task_default = defineCommand({
|
|
5
4
|
meta: {
|
|
@@ -11,6 +10,5 @@ var task_default = defineCommand({
|
|
|
11
10
|
run: () => import("./run.mjs").then((r) => r.default)
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
//#endregion
|
|
16
|
-
export { task_default as default };
|
|
14
|
+
export { task_default as default };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as runMain, t as defineCommand } from "../_libs/citty.mjs";
|
|
3
3
|
import { version } from "nitro/meta";
|
|
4
|
-
|
|
5
4
|
//#region src/cli/index.ts
|
|
6
5
|
runMain(defineCommand({
|
|
7
6
|
meta: {
|
|
@@ -12,10 +11,12 @@ runMain(defineCommand({
|
|
|
12
11
|
subCommands: {
|
|
13
12
|
dev: () => import("./_chunks/dev.mjs").then((r) => r.default),
|
|
14
13
|
build: () => import("./_chunks/build.mjs").then((r) => r.default),
|
|
14
|
+
deploy: () => import("./_chunks/deploy.mjs").then((r) => r.default),
|
|
15
15
|
prepare: () => import("./_chunks/prepare.mjs").then((r) => r.default),
|
|
16
|
-
task: () => import("./_chunks/task.mjs").then((r) => r.default)
|
|
16
|
+
task: () => import("./_chunks/task.mjs").then((r) => r.default),
|
|
17
|
+
preview: () => import("./_chunks/preview.mjs").then((r) => r.default),
|
|
18
|
+
docs: () => import("./_chunks/docs.mjs").then((r) => r.default)
|
|
17
19
|
}
|
|
18
20
|
}));
|
|
19
|
-
|
|
20
21
|
//#endregion
|
|
21
|
-
export {
|
|
22
|
+
export {};
|
|
@@ -630,6 +630,14 @@ function createStyleSheet() {
|
|
|
630
630
|
padding: 10px 15px;
|
|
631
631
|
margin: 0;
|
|
632
632
|
}
|
|
633
|
+
.dumper-dump pre code, .dumper-dump pre code span {
|
|
634
|
+
display: inline;
|
|
635
|
+
margin: 0;
|
|
636
|
+
padding: 0;
|
|
637
|
+
}
|
|
638
|
+
.dumper-toggle {
|
|
639
|
+
padding: 0 !important;
|
|
640
|
+
}
|
|
633
641
|
.dumper-dump pre samp {
|
|
634
642
|
position: relative;
|
|
635
643
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function h(n,t,e,r,s,i,a,l){return h.fromTZ(h.tp(n,t,e,r,s,i,a),l)}h.fromTZISO=(n,t,e)=>h.fromTZ(k(n,t),e);h.fromTZ=function(n,t){let e=new Date(Date.UTC(n.y,n.m-1,n.d,n.h,n.i,n.s)),r=D(n.tz,e),s=new Date(e.getTime()-r),i=D(n.tz,s);if(i-r===0)return s;{let a=new Date(e.getTime()-i),l=D(n.tz,a);if(l-i===0)return a;if(!t&&l-i>0)return a;if(t)throw new Error("Invalid date passed to fromTZ()");return s}};h.toTZ=function(n,t){let e=n.toLocaleString("en-US",{timeZone:t}).replace(/[\u202f]/," "),r=new Date(e);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}};h.tp=(n,t,e,r,s,i,a)=>({y:n,m:t,d:e,h:r,i:s,s:i,tz:a});function D(n,t=new Date){let e=t.toLocaleString("en-US",{timeZone:n,timeZoneName:"shortOffset"}).split(" ").slice(-1)[0],r=t.toLocaleString("en-US").replace(/[\u202f]/," ");return Date.parse(`${r} GMT`)-Date.parse(`${r} ${e}`)}function k(n,t){let e=new Date(Date.parse(n));if(isNaN(e))throw new Error("minitz: Invalid ISO8601 passed to parser.");let r=n.substring(9);return n.includes("Z")||r.includes("-")||r.includes("+")?h.tp(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),"Etc/UTC"):h.tp(e.getFullYear(),e.getMonth()+1,e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),t)}h.minitz=h;var b=32,p=31|b,v=[1,2,4,8,16],d=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(t,e){this.pattern=t,this.timezone=e,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let t=this.pattern.replace(/\s+/g," ").split(" ");if(t.length<5||t.length>6)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five or six space separated parts are required.");if(t.length===5&&t.unshift("0"),t[3].indexOf("L")>=0&&(t[3]=t[3].replace("L",""),this.lastDayOfMonth=!0),t[3]=="*"&&(this.starDOM=!0),t[4].length>=3&&(t[4]=this.replaceAlphaMonths(t[4])),t[5].length>=3&&(t[5]=this.replaceAlphaDays(t[5])),t[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0){let e=new f(new Date,this.timezone).getDate(!0);t[0]=t[0].replace("?",e.getSeconds().toString()),t[1]=t[1].replace("?",e.getMinutes().toString()),t[2]=t[2].replace("?",e.getHours().toString()),this.starDOM||(t[3]=t[3].replace("?",e.getDate().toString())),t[4]=t[4].replace("?",(e.getMonth()+1).toString()),this.starDOW||(t[5]=t[5].replace("?",e.getDay().toString()))}this.throwAtIllegalCharacters(t),this.partToArray("second",t[0],0,1),this.partToArray("minute",t[1],0,1),this.partToArray("hour",t[2],0,1),this.partToArray("day",t[3],-1,1),this.partToArray("month",t[4],-1,1),this.partToArray("dayOfWeek",t[5],0,p),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(t,e,r,s){let i=this[t],a=t==="day"&&this.lastDayOfMonth;if(e===""&&!a)throw new TypeError("CronPattern: configuration entry "+t+" ("+e+") is empty, check for trailing spaces.");if(e==="*")return i.fill(s);let l=e.split(",");if(l.length>1)for(let o=0;o<l.length;o++)this.partToArray(t,l[o],r,s);else e.indexOf("-")!==-1&&e.indexOf("/")!==-1?this.handleRangeWithStepping(e,t,r,s):e.indexOf("-")!==-1?this.handleRange(e,t,r,s):e.indexOf("/")!==-1?this.handleStepping(e,t,r,s):e!==""&&this.handleNumber(e,t,r,s)}throwAtIllegalCharacters(t){for(let e=0;e<t.length;e++)if((e===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(t[e]))throw new TypeError("CronPattern: configuration entry "+e+" ("+t[e]+") contains illegal characters.")}handleNumber(t,e,r,s){let i=this.extractNth(t,e),a=parseInt(i[0],10)+r;if(isNaN(a))throw new TypeError("CronPattern: "+e+" is not a number: '"+t+"'");this.setPart(e,a,i[1]||s)}setPart(t,e,r){if(!Object.prototype.hasOwnProperty.call(this,t))throw new TypeError("CronPattern: Invalid part specified: "+t);if(t==="dayOfWeek"){if(e===7&&(e=0),e<0||e>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+e);this.setNthWeekdayOfMonth(e,r);return}if(t==="second"||t==="minute"){if(e<0||e>=60)throw new RangeError("CronPattern: Invalid value for "+t+": "+e)}else if(t==="hour"){if(e<0||e>=24)throw new RangeError("CronPattern: Invalid value for "+t+": "+e)}else if(t==="day"){if(e<0||e>=31)throw new RangeError("CronPattern: Invalid value for "+t+": "+e)}else if(t==="month"&&(e<0||e>=12))throw new RangeError("CronPattern: Invalid value for "+t+": "+e);this[t][e]=r}handleRangeWithStepping(t,e,r,s){let i=this.extractNth(t,e),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+t+"'");let[,l,o,u]=a,c=parseInt(l,10)+r,w=parseInt(o,10)+r,C=parseInt(u,10);if(isNaN(c))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(w))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(C))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(C===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(C>this[e].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[e].length+")");if(c>w)throw new TypeError("CronPattern: From value is larger than to value: '"+t+"'");for(let T=c;T<=w;T+=C)this.setPart(e,T,i[1]||s)}extractNth(t,e){let r=t,s;if(r.includes("#")){if(e!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");s=r.split("#")[1],r=r.split("#")[0]}return[r,s]}handleRange(t,e,r,s){let i=this.extractNth(t,e),a=i[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+t+"'");let l=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;if(isNaN(l))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(l>o)throw new TypeError("CronPattern: From value is larger than to value: '"+t+"'");for(let u=l;u<=o;u++)this.setPart(e,u,i[1]||s)}handleStepping(t,e,r,s){let i=this.extractNth(t,e),a=i[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+t+"'");a[0]===""&&(a[0]="*");let l=0;a[0]!=="*"&&(l=parseInt(a[0],10)+r);let o=parseInt(a[1],10);if(isNaN(o))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(o===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(o>this[e].length)throw new TypeError("CronPattern: Syntax error, max steps for part is ("+this[e].length+")");for(let u=l;u<this[e].length;u+=o)this.setPart(e,u,i[1]||s)}replaceAlphaDays(t){return t.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths(t){return t.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(t){let e=t.trim().toLowerCase();return e==="@yearly"||e==="@annually"?"0 0 1 1 *":e==="@monthly"?"0 0 1 * *":e==="@weekly"?"0 0 * * 0":e==="@daily"?"0 0 * * *":e==="@hourly"?"0 * * * *":t}setNthWeekdayOfMonth(t,e){if(typeof e!="number"&&e==="L")this.dayOfWeek[t]=this.dayOfWeek[t]|b;else if(e===p)this.dayOfWeek[t]=p;else if(e<6&&e>0)this.dayOfWeek[t]=this.dayOfWeek[t]|v[e-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${e}, Type: ${typeof e}`)}};var O=[31,28,31,30,31,30,31,31,30,31,30,31],m=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],f=class n{tz;ms;second;minute;hour;day;month;year;constructor(t,e){if(this.tz=e,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t=="string")this.fromString(t);else if(t instanceof n)this.fromCronDate(t);else throw new TypeError("CronDate: Invalid type ("+typeof t+") passed to CronDate constructor")}isNthWeekdayOfMonth(t,e,r,s){let a=new Date(Date.UTC(t,e,r)).getUTCDay(),l=0;for(let o=1;o<=r;o++)new Date(Date.UTC(t,e,o)).getUTCDay()===a&&l++;if(s&p&&v[l-1]&s)return!0;if(s&b){let o=new Date(Date.UTC(t,e+1,0)).getUTCDate();for(let u=r+1;u<=o;u++)if(new Date(Date.UTC(t,e,u)).getUTCDay()===a)return!1;return!0}return!1}fromDate(t){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes()+this.tz,this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply();else{let e=h.toTZ(t,this.tz);this.ms=t.getMilliseconds(),this.second=e.s,this.minute=e.i,this.hour=e.h,this.day=e.d,this.month=e.m-1,this.year=e.y}else this.ms=t.getMilliseconds(),this.second=t.getSeconds(),this.minute=t.getMinutes(),this.hour=t.getHours(),this.day=t.getDate(),this.month=t.getMonth(),this.year=t.getFullYear()}fromCronDate(t){this.tz=t.tz,this.year=t.year,this.month=t.month,this.day=t.day,this.hour=t.hour,this.minute=t.minute,this.second=t.second,this.ms=t.ms}apply(){if(this.month>11||this.day>O[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let t=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),!0}else return!1}fromString(t){if(typeof this.tz=="number"){let e=h.fromTZISO(t);this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply()}else return this.fromDate(h.fromTZISO(t,this.tz))}findNext(t,e,r,s){let i=this[e],a;r.lastDayOfMonth&&(this.month!==1?a=O[this.month]:a=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let l=!r.starDOW&&e=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let o=this[e]+s;o<r[e].length;o++){let u=r[e][o];if(e==="day"&&r.lastDayOfMonth&&o-s==a&&(u=1),e==="day"&&!r.starDOW){let c=r.dayOfWeek[(l+(o-s-1))%7];if(c&&c&p)c=this.isNthWeekdayOfMonth(this.year,this.month,o-s,c)?1:0;else if(c)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${c}`);t.legacyMode&&!r.starDOM?u=u||c:u=u&&c}if(u)return this[e]=o-s,i!==this[e]?2:1}return 3}recurse(t,e,r){let s=this.findNext(e,m[r][0],t,m[r][2]);if(s>1){let i=r+1;for(;i<m.length;)this[m[i][0]]=-m[i][2],i++;if(s===3)return this[m[r][1]]++,this[m[r][0]]=-m[r][2],this.apply(),this.recurse(t,e,0);if(this.apply())return this.recurse(t,e,r-1)}return r+=1,r>=m.length?this:this.year>=3e3?null:this.recurse(t,e,r)}increment(t,e,r){return this.second+=e.interval!==void 0&&e.interval>1&&r?e.interval:1,this.ms=0,this.apply(),this.recurse(t,e,0)}getDate(t){return t||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):h.fromTZ(h.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function N(n){if(n===void 0&&(n={}),delete n.name,n.legacyMode=n.legacyMode===void 0?!0:n.legacyMode,n.paused=n.paused===void 0?!1:n.paused,n.maxRuns=n.maxRuns===void 0?1/0:n.maxRuns,n.catch=n.catch===void 0?!1:n.catch,n.interval=n.interval===void 0?0:parseInt(n.interval.toString(),10),n.utcOffset=n.utcOffset===void 0?void 0:parseInt(n.utcOffset.toString(),10),n.unref=n.unref===void 0?!1:n.unref,n.startAt&&(n.startAt=new f(n.startAt,n.timezone)),n.stopAt&&(n.stopAt=new f(n.stopAt,n.timezone)),n.interval!==null){if(isNaN(n.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(n.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(n.utcOffset!==void 0){if(isNaN(n.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(n.utcOffset<-870||n.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(n.utcOffset!==void 0&&n.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(n.unref!==!0&&n.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");return n}function g(n){return Object.prototype.toString.call(n)==="[object Function]"||typeof n=="function"||n instanceof Function}function S(n){return g(n)}function P(n){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(n):n&&typeof n.unref<"u"&&n.unref()}var _=30*1e3,y=[],R=class{name;options;_states;fn;constructor(t,e,r){let s,i;if(g(e))i=e;else if(typeof e=="object")s=e;else if(e!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(g(r))i=r;else if(typeof r=="object")s=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=s?.name,this.options=N(s),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:s?s.maxRuns:void 0,paused:s?s.paused:!1,pattern:new d("* * * * *")},t&&(t instanceof Date||typeof t=="string"&&t.indexOf(":")>0)?this._states.once=new f(t,this.options.timezone||this.options.utcOffset):this._states.pattern=new d(t,this.options.timezone),this.name){if(y.find(l=>l.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");y.push(this)}return i!==void 0&&S(i)&&(this.fn=i,this.schedule()),this}nextRun(t){let e=this._next(t);return e?e.getDate(!1):null}nextRuns(t,e){this._states.maxRuns!==void 0&&t>this._states.maxRuns&&(t=this._states.maxRuns);let r=[],s=e||this._states.currentRun||void 0;for(;t--&&(s=this.nextRun(s));)r.push(s);return r}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let t=this.nextRun(this._states.currentRun),e=!this._states.paused,r=this.fn!==void 0,s=!this._states.kill;return e&&r&&s&&t!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(t){let e=this._next(t);return e?t instanceof f||t instanceof Date?e.getTime()-t.getTime():e.getTime()-new f(t).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let t=y.indexOf(this);t>=0&&y.splice(t,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(t){if(t&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");t&&(this.fn=t);let e=this.msToNext(),r=this.nextRun(this._states.currentRun);return e==null||isNaN(e)||r===null?this:(e>_&&(e=_),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),e),this._states.currentTimeout&&this.options.unref&&P(this._states.currentTimeout),this)}async _trigger(t){if(this._states.blocking=!0,this._states.currentRun=new f(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){g(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new f(t,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(t){let e=new Date,r=!this._states.paused&&e.getTime()>=t.getTime(),s=this._states.blocking&&this.options.protect;r&&!s?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&s&&g(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(t){let e=!!(t||this._states.currentRun),r=!1;!t&&this.options.startAt&&this.options.interval&&([t,e]=this._calculatePreviousRun(t,e),r=!t),t=new f(t,this.options.timezone||this.options.utcOffset),this.options.startAt&&t&&t.getTime()<this.options.startAt.getTime()&&(t=this.options.startAt);let s=this._states.once||new f(t,this.options.timezone||this.options.utcOffset);return!r&&s!==this._states.once&&(s=s.increment(this._states.pattern,this.options,e)),this._states.once&&this._states.once.getTime()<=t.getTime()||s===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&s.getTime()>=this.options.stopAt.getTime()?null:s}_calculatePreviousRun(t,e){let r=new f(void 0,this.options.timezone||this.options.utcOffset),s=t;if(this.options.startAt.getTime()<=r.getTime()){s=this.options.startAt;let i=s.getTime()+this.options.interval*1e3;for(;i<=r.getTime();)s=new f(s,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),i=s.getTime()+this.options.interval*1e3;e=!0}return s===null&&(s=void 0),[s,e]}};export{R as Cron,f as CronDate,d as CronPattern,y as scheduledJobs};
|
|
1
|
+
function T(s){return Date.UTC(s.y,s.m-1,s.d,s.h,s.i,s.s)}function D(s,e){return s.y===e.y&&s.m===e.m&&s.d===e.d&&s.h===e.h&&s.i===e.i&&s.s===e.s}function A(s,e){let t=new Date(Date.parse(s));if(isNaN(t))throw new Error("Invalid ISO8601 passed to timezone parser.");let r=s.substring(9);return r.includes("Z")||r.includes("+")||r.includes("-")?b(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),"Etc/UTC"):b(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),e)}function v(s,e,t){return k(A(s,e),t)}function k(s,e){let t=new Date(T(s)),r=g(t,s.tz),n=T(s),i=T(r),a=n-i,o=new Date(t.getTime()+a),h=g(o,s.tz);if(D(h,s)){let u=new Date(o.getTime()-36e5),d=g(u,s.tz);return D(d,s)?u:o}let l=new Date(o.getTime()+T(s)-T(h)),y=g(l,s.tz);if(D(y,s))return l;if(e)throw new Error("Invalid date passed to fromTZ()");return o.getTime()>l.getTime()?o:l}function g(s,e){let t,r;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}),r=t.formatToParts(s)}catch(i){let a=i instanceof Error?i.message:String(i);throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`)}let n={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let i of r)(i.type==="year"||i.type==="month"||i.type==="day"||i.type==="hour"||i.type==="minute"||i.type==="second")&&(n[i.type]=parseInt(i.value,10));if(isNaN(n.year)||isNaN(n.month)||isNaN(n.day)||isNaN(n.hour)||isNaN(n.minute)||isNaN(n.second))throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(n)}`);return n.hour===24&&(n.hour=0),{y:n.year,m:n.month,d:n.day,h:n.hour,i:n.minute,s:n.second,tz:e}}function b(s,e,t,r,n,i,a){return{y:s,m:e,d:t,h:r,i:n,s:i,tz:a}}var O=[1,2,4,8,16],C=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,r){this.pattern=e,this.timezone=t,this.mode=r?.mode??"auto",this.alternativeWeekdays=r?.alternativeWeekdays??!1,this.sloppyRanges=r?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw new TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[""],t=e.length;if(e.length<5||e.length>7)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if(this.mode!=="auto"){let n;switch(this.mode){case"5-part":n=5;break;case"6-part":n=6;break;case"7-part":n=7;break;case"5-or-6-parts":n=[5,6];break;case"6-or-7-parts":n=[6,7];break;default:n=0}if(!(Array.isArray(n)?n.includes(t):t===n)){let a=Array.isArray(n)?n.join(" or "):n.toString();throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${a} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift("0"),e.length===6&&e.push("*"),e[3].toUpperCase()==="LW"?(this.lastWeekday=!0,e[3]=""):e[3].toUpperCase().indexOf("L")>=0&&(e[3]=e[3].replace(/L/gi,""),this.lastDayOfMonth=!0),e[3]=="*"&&(this.starDOM=!0),e[6]=="*"&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith("+")&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===""))throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch(e[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(e[0]=e[0].replace(/\?/g,"*"),e[1]=e[1].replace(/\?/g,"*"),e[2]=e[2].replace(/\?/g,"*"),e[3]=e[3].replace(/\?/g,"*"),e[4]=e[4].replace(/\?/g,"*"),e[5]=e[5].replace(/\?/g,"*"),e[6]&&(e[6]=e[6].replace(/\?/g,"*"))),this.mode){case"5-part":e[0]="0",e[6]="*";break;case"6-part":e[6]="*";break;case"5-or-6-parts":e[6]="*";break;case"6-or-7-parts":break;case"7-part":case"auto":break}this.throwAtIllegalCharacters(e),this.partToArray("second",e[0],0,1),this.partToArray("minute",e[1],0,1),this.partToArray("hour",e[2],0,1),this.partToArray("day",e[3],-1,1),this.partToArray("month",e[4],-1,1);let r=this.alternativeWeekdays?-1:0;this.partToArray("dayOfWeek",e[5],r,63),this.partToArray("year",e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,r,n){let i=this[e],a=e==="day"&&this.lastDayOfMonth,o=e==="day"&&this.lastWeekday;if(t===""&&!a&&!o)throw new TypeError("CronPattern: configuration entry "+e+" ("+t+") is empty, check for trailing spaces.");if(t==="*")return i.fill(n);let h=t.split(",");if(h.length>1)for(let l=0;l<h.length;l++)this.partToArray(e,h[l],r,n);else t.indexOf("-")!==-1&&t.indexOf("/")!==-1?this.handleRangeWithStepping(t,e,r,n):t.indexOf("-")!==-1?this.handleRange(t,e,r,n):t.indexOf("/")!==-1?this.handleStepping(t,e,r,n):t!==""&&this.handleNumber(t,e,r,n)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[t]))throw new TypeError("CronPattern: configuration entry "+t+" ("+e[t]+") contains illegal characters.")}handleNumber(e,t,r,n){let i=this.extractNth(e,t),a=e.toUpperCase().includes("W");if(t!=="day"&&a)throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(t="nearestWeekdays");let o=parseInt(i[0],10)+r;if(isNaN(o))throw new TypeError("CronPattern: "+t+" is not a number: '"+e+"'");this.setPart(t,o,i[1]||n)}setPart(e,t,r){if(!Object.prototype.hasOwnProperty.call(this,e))throw new TypeError("CronPattern: Invalid part specified: "+e);if(e==="dayOfWeek"){if(t===7&&(t=0),t<0||t>6)throw new RangeError("CronPattern: Invalid value for dayOfWeek: "+t);this.setNthWeekdayOfMonth(t,r);return}if(e==="second"||e==="minute"){if(t<0||t>=60)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="hour"){if(t<0||t>=24)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="day"||e==="nearestWeekdays"){if(t<0||t>=31)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="month"){if(t<0||t>=12)throw new RangeError("CronPattern: Invalid value for "+e+": "+t)}else if(e==="year"&&(t<1||t>=1e4))throw new RangeError("CronPattern: Invalid value for "+e+": "+t+" (supported range: 1-9999)");this[e][t]=r}validateNotNaN(e,t){if(isNaN(e))throw new TypeError(t)}validateRange(e,t,r,n,i){if(e>t)throw new TypeError("CronPattern: From value is larger than to value: '"+i+"'");if(r!==void 0){if(r===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(r>this[n].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[n].length+")")}}handleRangeWithStepping(e,t,r,n){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+e+"'");let[,o,h,l]=a,y=parseInt(o,10)+r,u=parseInt(h,10)+r,d=parseInt(l,10);this.validateNotNaN(y,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(u,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateNotNaN(d,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(y,u,d,t,e);for(let c=y;c<=u;c+=d)this.setPart(t,c,i[1]||n)}extractNth(e,t){let r=e,n;if(r.includes("#")){if(t!=="dayOfWeek")throw new Error("CronPattern: nth (#) only allowed in day-of-week field");n=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if(t!=="dayOfWeek")throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");n="L",r=r.slice(0,-1)}return[r,n]}handleRange(e,t,r,n){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");let i=this.extractNth(e,t),a=i[0].split("-");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");let o=parseInt(a[0],10)+r,h=parseInt(a[1],10)+r;this.validateNotNaN(o,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(h,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateRange(o,h,void 0,t,e);for(let l=o;l<=h;l++)this.setPart(t,l,i[1]||n)}handleStepping(e,t,r,n){if(e.toUpperCase().includes("W"))throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let i=this.extractNth(e,t),a=i[0].split("/");if(a.length!==2)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if(this.sloppyRanges)a[0]===""&&(a[0]="*");else{if(a[0]==="")throw new TypeError("CronPattern: Syntax error, stepping with missing prefix ('"+e+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");if(a[0]!=="*")throw new TypeError("CronPattern: Syntax error, stepping with numeric prefix ('"+e+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.")}let o=0;a[0]!=="*"&&(o=parseInt(a[0],10)+r);let h=parseInt(a[1],10);this.validateNotNaN(h,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(0,this[t].length-1,h,t,e);for(let l=o;l<this[t].length;l+=h)this.setPart(t,l,i[1]||n)}replaceAlphaDays(e){return e.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,"1").replace(/mon/gi,"2").replace(/tue/gi,"3").replace(/wed/gi,"4").replace(/thu/gi,"5").replace(/fri/gi,"6").replace(/sat/gi,"7")}replaceAlphaMonths(e){return e.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(e){let t=e.trim().toLowerCase();if(t==="@yearly"||t==="@annually")return"0 0 1 1 *";if(t==="@monthly")return"0 0 1 * *";if(t==="@weekly")return"0 0 * * 0";if(t==="@daily"||t==="@midnight")return"0 0 * * *";if(t==="@hourly")return"0 * * * *";if(t==="@reboot")throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return e}setNthWeekdayOfMonth(e,t){if(typeof t!="number"&&t.toUpperCase()==="L")this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|O[t-1];else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}};var P=[31,28,31,30,31,30,31,31,30,31,30,31],f=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],m=class s{tz;ms;second;minute;hour;day;month;year;constructor(e,t){if(this.tz=t,e&&e instanceof Date)if(!isNaN(e))this.fromDate(e);else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");else if(e==null)this.fromDate(new Date);else if(e&&typeof e=="string")this.fromString(e);else if(e instanceof s)this.fromCronDate(e);else throw new TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getLastDayOfMonth(e,t){return t!==1?P[t]:new Date(Date.UTC(e,t+1,0)).getUTCDate()}getLastWeekday(e,t){let r=this.getLastDayOfMonth(e,t),i=new Date(Date.UTC(e,t,r)).getUTCDay();return i===0?r-2:i===6?r-1:r}getNearestWeekday(e,t,r){let n=this.getLastDayOfMonth(e,t);if(r>n)return-1;let a=new Date(Date.UTC(e,t,r)).getUTCDay();return a===0?r===n?r-2:r+1:a===6?r===1?r+2:r-1:r}isNthWeekdayOfMonth(e,t,r,n){let a=new Date(Date.UTC(e,t,r)).getUTCDay(),o=0;for(let h=1;h<=r;h++)new Date(Date.UTC(e,t,h)).getUTCDay()===a&&o++;if(n&63&&O[o-1]&n)return!0;if(n&32){let h=this.getLastDayOfMonth(e,t);for(let l=r+1;l<=h;l++)if(new Date(Date.UTC(e,t,l)).getUTCDay()===a)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=g(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(t){let r=t instanceof Error?t.message:String(t);throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.month<0||this.day>P[this.month]||this.day<1||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz=="number"){let t=v(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(v(e,this.tz))}findNext(e,t,r,n){return this._findMatch(e,t,r,n,1)}_findMatch(e,t,r,n,i){let a=this[t],o;r.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let h=!r.starDOW&&t=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,l=this[t]+n,y=i===1?u=>u<r[t].length:u=>u>=0;for(let u=l;y(u);u+=i){let d=r[t][u];if(t==="day"&&!d){for(let c=0;c<r.nearestWeekdays.length;c++)if(r.nearestWeekdays[c]){let M=this.getNearestWeekday(this.year,this.month,c-n);if(M===-1)continue;if(M===u-n){d=1;break}}}if(t==="day"&&r.lastWeekday){let c=this.getLastWeekday(this.year,this.month);u-n===c&&(d=1)}if(t==="day"&&r.lastDayOfMonth&&u-n==o&&(d=1),t==="day"&&!r.starDOW){let c=r.dayOfWeek[(h+(u-n-1))%7];if(c&&c&63)c=this.isNthWeekdayOfMonth(this.year,this.month,u-n,c)?1:0;else if(c)throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${c}`);r.useAndLogic?d=d&&c:!e.domAndDow&&!r.starDOM?d=d||c:d=d&&c}if(d)return this[t]=u-n,a!==this[t]?2:1}return 3}recurse(e,t,r){if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let i=-1;for(let a=this.year+1;a<e.year.length&&a<1e4;a++)if(e.year[a]===1){i=a;break}if(i===-1)return null;this.year=i,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let n=this.findNext(t,f[r][0],e,f[r][2]);if(n>1){let i=r+1;for(;i<f.length;)this[f[i][0]]=-f[i][2],i++;if(n===3){if(this[f[r][1]]++,this[f[r][0]]=-f[r][2],this.apply(),r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,r-1)}return r+=1,r>=f.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,r)}increment(e,t,r){return this.second+=t.interval!==void 0&&t.interval>1&&r?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,r,n=0){if(n>1e4)return null;if(r===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let a=-1;for(let o=this.year-1;o>=0;o--)if(e.year[o]===1){a=o;break}if(a===-1)return null;this.year=a,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,f[r][0],e,f[r][2]);if(i>1){let a=r+1;for(;a<f.length;){let o=f[a][0],h=f[a][2],l=this.getMaxPatternValue(o,e,h);this[o]=l,a++}if(i===3){if(this[f[r][1]]--,r===0){let y=this.getLastDayOfMonth(this.year,this.month);this.day>y&&(this.day=y)}if(r===1)if(this.day<=0)this.day=1;else{let y=this.year,u=this.month;for(;u<0;)u+=12,y--;for(;u>11;)u-=12,y++;let d=u!==1?P[u]:new Date(Date.UTC(y,u+1,0)).getUTCDate();this.day>d&&(this.day=d)}this.apply();let o=f[r][0],h=f[r][2],l=this.getMaxPatternValue(o,e,h);if(o==="day"){let y=this.getLastDayOfMonth(this.year,this.month);this[o]=Math.min(l,y)}else this[o]=l;if(this.apply(),r===0){let y=f[1][2],u=this.getMaxPatternValue("day",e,y),d=this.getLastDayOfMonth(this.year,this.month),c=Math.min(u,d);c!==this.day&&(this.day=c,this.hour=this.getMaxPatternValue("hour",e,f[2][2]),this.minute=this.getMaxPatternValue("minute",e,f[3][2]),this.second=this.getMaxPatternValue("second",e,f[4][2]))}if(r===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,n+1)}else if(this.apply())return this.recurseBackward(e,t,r-1,n+1)}return r+=1,r>=f.length?this:this.year<0?null:this.recurseBackward(e,t,r,n+1)}getMaxPatternValue(e,t,r){if(e==="day"&&t.lastDayOfMonth)return this.getLastDayOfMonth(this.year,this.month);if(e==="day"&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let n=t[e].length-1;n>=0;n--)if(t[e][n])return n-r;return t[e].length-1-r}findPrevious(e,t,r,n){return this._findMatch(e,t,r,n,-1)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):k(b(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let r=0;r<f.length;r++){let n=f[r][0],i=f[r][2],a=this[n];if(a+i<0||a+i>=e[n].length)return!1;let o=e[n][a+i];if(n==="day"){if(!o){for(let h=0;h<e.nearestWeekdays.length;h++)if(e.nearestWeekdays[h]){let l=this.getNearestWeekday(this.year,this.month,h-i);if(l!==-1&&l===a){o=1;break}}}if(e.lastWeekday){let h=this.getLastWeekday(this.year,this.month);a===h&&(o=1)}if(e.lastDayOfMonth){let h=this.getLastDayOfMonth(this.year,this.month);a===h&&(o=1)}if(!e.starDOW){let h=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),l=e.dayOfWeek[(h+(a-1))%7];l&&l&63&&(l=this.isNthWeekdayOfMonth(this.year,this.month,a,l)?1:0),e.useAndLogic?o=o&&l:!t.domAndDow&&!e.starDOM?o=o||l:o=o&&l}}if(!o)return!1}return!0}};function R(s){if(s===void 0&&(s={}),delete s.name,s.legacyMode!==void 0&&s.domAndDow===void 0?s.domAndDow=!s.legacyMode:s.domAndDow===void 0&&(s.domAndDow=!1),s.legacyMode=!s.domAndDow,s.paused=s.paused===void 0?!1:s.paused,s.maxRuns=s.maxRuns===void 0?1/0:s.maxRuns,s.catch=s.catch===void 0?!1:s.catch,s.interval=s.interval===void 0?0:parseInt(s.interval.toString(),10),s.utcOffset=s.utcOffset===void 0?void 0:parseInt(s.utcOffset.toString(),10),s.dayOffset=s.dayOffset===void 0?0:parseInt(s.dayOffset.toString(),10),s.unref=s.unref===void 0?!1:s.unref,s.mode=s.mode===void 0?"auto":s.mode,s.alternativeWeekdays=s.alternativeWeekdays===void 0?!1:s.alternativeWeekdays,s.sloppyRanges=s.sloppyRanges===void 0?!1:s.sloppyRanges,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(s.mode))throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(s.startAt&&(s.startAt=new m(s.startAt,s.timezone)),s.stopAt&&(s.stopAt=new m(s.stopAt,s.timezone)),s.interval!==null){if(isNaN(s.interval))throw new Error("CronOptions: Supplied value for interval is not a number");if(s.interval<0)throw new Error("CronOptions: Supplied value for interval can not be negative")}if(s.utcOffset!==void 0){if(isNaN(s.utcOffset))throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(s.utcOffset<-870||s.utcOffset>870)throw new Error("CronOptions: utcOffset out of bounds.");if(s.utcOffset!==void 0&&s.timezone)throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(s.unref!==!0&&s.unref!==!1)throw new Error("CronOptions: Unref should be either true, false or undefined(false).");if(s.dayOffset!==void 0&&s.dayOffset!==0&&isNaN(s.dayOffset))throw new Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return s}function p(s){return Object.prototype.toString.call(s)==="[object Function]"||typeof s=="function"||s instanceof Function}function _(s){return p(s)}function x(s){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer(s):s&&typeof s.unref<"u"&&s.unref()}var W=30*1e3,w=[],E=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,r){let n,i;if(p(t))i=t;else if(typeof t=="object")n=t;else if(t!==void 0)throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(p(r))i=r;else if(typeof r=="object")n=r;else if(r!==void 0)throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=n?.name,this.options=R(n),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:n?n.maxRuns:void 0,paused:n?n.paused:!1,pattern:new C("* * * * *",void 0,{mode:"auto"})},e&&(e instanceof Date||typeof e=="string"&&e.indexOf(":")>0)?this._states.once=new m(e,this.getTz()):this._states.pattern=new C(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(w.find(o=>o.name===this.name))throw new Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");w.push(this)}return i!==void 0&&_(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let r=t||this._states.currentRun||void 0;return this._enumerateRuns(e,r,"next")}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,"previous")}_enumerateRuns(e,t,r){let n=[],i=t?new m(t,this.getTz()):null,a=r==="next"?this._next:this._previous;for(;e--;){let o=a.call(this,i);if(!o)break;let h=o.getDate(!1);n.push(this.applyDayOffset(h)),i=o}return n}match(e){if(this._states.once){let r=new m(e,this.getTz());r.ms=0;let n=new m(this._states.once,this.getTz());return n.ms=0,r.getTime()===n.getTime()}let t=new m(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,r=this.fn!==void 0,n=!this._states.kill;return t&&r&&n&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof m||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new m(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=w.indexOf(this);e>=0&&w.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");e&&(this.fn=e);let t=this.msToNext(),r=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||r===null?this:(t>W&&(t=W),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(r),t),this._states.currentTimeout&&this.options.unref&&x(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new m(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(t){if(p(this.options.catch))try{this.options.catch(t,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new m(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,r=!this._states.paused&&t.getTime()>=e.getTime(),n=this._states.blocking&&this.options.protect;r&&!n?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):r&&n&&p(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),r=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),r=!e),e=new m(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let n=this._states.once||new m(e,this.getTz());return!r&&n!==this._states.once&&(n=n.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||n===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&n.getTime()>=this.options.stopAt.getTime()?null:n}_previous(e){let t=new m(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let r=new m(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(r=r.decrement(this._states.pattern,this.options),r===null||this.options.startAt&&r.getTime()<this.options.startAt.getTime()?null:r)}_calculatePreviousRun(e,t){let r=new m(void 0,this.getTz()),n=e;if(this.options.startAt.getTime()<=r.getTime()){n=this.options.startAt;let i=n.getTime()+this.options.interval*1e3;for(;i<=r.getTime();)n=new m(n,this.getTz()).increment(this._states.pattern,this.options,!0),i=n.getTime()+this.options.interval*1e3;t=!0}return n===null&&(n=void 0),[n,t]}};export{E as Cron,m as CronDate,C as CronPattern,w as scheduledJobs};
|
|
@@ -16,6 +16,16 @@
|
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/hexagon/croner/issues"
|
|
18
18
|
},
|
|
19
|
+
"funding": [
|
|
20
|
+
{
|
|
21
|
+
"type": "other",
|
|
22
|
+
"url": "https://paypal.me/hexagonpp"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "github",
|
|
26
|
+
"url": "https://github.com/sponsors/hexagon"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
19
29
|
"files": [
|
|
20
30
|
"dist/*.js",
|
|
21
31
|
"dist/*.cjs",
|
|
@@ -59,5 +69,5 @@
|
|
|
59
69
|
}
|
|
60
70
|
},
|
|
61
71
|
"license": "MIT",
|
|
62
|
-
"version": "
|
|
72
|
+
"version": "10.0.1"
|
|
63
73
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import useColors from "@poppinss/colors";
|
|
2
|
+
const ANSI_REGEX = new RegExp([`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|"), "g");
|
|
3
|
+
function htmlEscape(value) {
|
|
4
|
+
return value.replace(/&/g, "&").replace(/\\"/g, "\"").replace(/</g, "<").replace(/>/g, ">");
|
|
5
|
+
}
|
|
6
|
+
function wordWrap(value, options) {
|
|
7
|
+
const width = options.width;
|
|
8
|
+
const indent = options.indent;
|
|
9
|
+
const newLine = `${options.newLine}${indent}`;
|
|
10
|
+
if (!width) return options.escape ? options.escape(value) : htmlEscape(value);
|
|
11
|
+
let regexString = ".{1," + width + "}";
|
|
12
|
+
regexString += "([\\s]+|$)|[^\\s]+?([\\s]+|$)";
|
|
13
|
+
const re = new RegExp(regexString, "g");
|
|
14
|
+
return (value.match(re) || []).map(function(line) {
|
|
15
|
+
if (line.slice(-1) === "\n") line = line.slice(0, line.length - 1);
|
|
16
|
+
return options.escape ? options.escape(line) : htmlEscape(line);
|
|
17
|
+
}).join(newLine);
|
|
18
|
+
}
|
|
19
|
+
function stripAnsi(value) {
|
|
20
|
+
return value.replace(ANSI_REGEX, "");
|
|
21
|
+
}
|
|
22
|
+
const colors = useColors.ansi();
|
|
23
|
+
export { wordWrap as i, htmlEscape as n, stripAnsi as r, colors as t };
|