@vite-hub/schedule 0.0.3 → 0.0.4
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 +201 -0
- package/README.md +147 -76
- package/dist/{client-BMFCy0dX.js → client-DpCD4YFE.js} +1 -1
- package/dist/discovery-DkFAN7Wd.d.ts +15 -0
- package/dist/{discovery-BZlat3Kc.js → discovery-DvU3B6iD.js} +17 -40
- package/dist/{execute-ClFYvmp9.js → execute-B-pii4wf.js} +1 -1
- package/dist/index.d.ts +1 -12
- package/dist/index.js +3 -3
- package/dist/nuxt.js +2 -1
- package/dist/runtime/driver.js +7 -4
- package/dist/runtime/static.js +18 -6
- package/dist/runtime.js +1 -1
- package/dist/vite-BHs17nWX.js +4166 -0
- package/dist/vite.d.ts +15 -1
- package/dist/vite.js +3 -2
- package/dist/{wait-until-CR-JjIOb.js → wait-until-BzIwzXw4.js} +1 -1
- package/package.json +6 -6
- package/dist/vite-BX6_KiRw.js +0 -1218
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineSchedule, defineScheduleTarget } from "./definition.js";
|
|
2
|
-
import { t as discoverScheduleDefinitions } from "./discovery-
|
|
3
|
-
import { a as executeStaticSchedule, i as executeSchedule, n as executeRuntimeSchedule, t as createScheduleRun } from "./execute-
|
|
2
|
+
import { t as discoverScheduleDefinitions } from "./discovery-DvU3B6iD.js";
|
|
3
|
+
import { a as executeStaticSchedule, i as executeSchedule, n as executeRuntimeSchedule, t as createScheduleRun } from "./execute-B-pii4wf.js";
|
|
4
4
|
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, d as createMemoryRuntimeScheduleStore, f as createMemoryScheduleRunStore, i as loadScheduleDefinition, l as createKVRuntimeScheduleStore, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore, u as createKVScheduleRunStore } from "./state-By7WU_ks.js";
|
|
5
|
-
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-
|
|
5
|
+
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-DpCD4YFE.js";
|
|
6
6
|
import { t as createScheduleKVStorage } from "./kv-storage-DWinmLLy.js";
|
|
7
7
|
export { createKVRuntimeScheduleStore, createKVScheduleRunStore, createMemoryRuntimeScheduleStore, createMemoryScheduleRunStore, createScheduleKVStorage, createScheduleRun, defineSchedule, defineScheduleTarget, discoverScheduleDefinitions, executeRuntimeSchedule, executeSchedule, executeStaticSchedule, getRuntimeScheduleStore, getScheduleRunStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRunStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|
package/dist/nuxt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as hubSchedule, t as createScheduleNitroConfig } from "./vite-
|
|
1
|
+
import { n as hubSchedule, t as createScheduleNitroConfig } from "./vite-BHs17nWX.js";
|
|
2
2
|
//#region src/nuxt.ts
|
|
3
3
|
function isScheduleVitePlugin(value) {
|
|
4
4
|
return Boolean(value && typeof value === "object" && value.name === "@vite-hub/schedule/vite");
|
|
@@ -14,6 +14,7 @@ function viteHubScheduleNuxtModule(options = {}, nuxt) {
|
|
|
14
14
|
const nitro = await createScheduleNitroConfig({
|
|
15
15
|
...options,
|
|
16
16
|
command: nuxt.options.dev ? "serve" : "build",
|
|
17
|
+
nitroOwnsPaths: true,
|
|
17
18
|
nitro: nitroConfig,
|
|
18
19
|
projectRoot: options.projectRoot || rootDir,
|
|
19
20
|
root: nuxt.options.srcDir || rootDir
|
package/dist/runtime/driver.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { a as executeStaticSchedule, r as executeRuntimeScheduleWake } from "../execute-
|
|
1
|
+
import { a as executeStaticSchedule, r as executeRuntimeScheduleWake } from "../execute-B-pii4wf.js";
|
|
2
2
|
import { c as setScheduleRuntimeRegistry, m as createScheduleError, n as getScheduleRunStore, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, s as setScheduleRunStore, t as getRuntimeScheduleStore } from "../state-By7WU_ks.js";
|
|
3
3
|
import { t as isRuntimeScheduleDue } from "../due-Bbh4yIxq.js";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
//#region src/runtime/driver.ts
|
|
6
6
|
const staticScheduleIdPrefix = "\0vitehub:static:";
|
|
7
|
+
function isObject(value) {
|
|
8
|
+
return Object(value) === value;
|
|
9
|
+
}
|
|
7
10
|
function isScheduleRegistryDefinition(value) {
|
|
8
|
-
return
|
|
11
|
+
return isObject(value) && "handler" in value;
|
|
9
12
|
}
|
|
10
13
|
function unwrapDefinition(loaded) {
|
|
11
14
|
if ("default" in loaded && isScheduleRegistryDefinition(loaded.default)) return loaded.default;
|
|
@@ -238,7 +241,7 @@ async function installScheduleRuntime(options) {
|
|
|
238
241
|
});
|
|
239
242
|
}
|
|
240
243
|
async function flushWaitUntil() {
|
|
241
|
-
while (pendingWork.size > 0) await Promise.allSettled(
|
|
244
|
+
while (pendingWork.size > 0) await Promise.allSettled(pendingWork);
|
|
242
245
|
}
|
|
243
246
|
const serialize = createSerializer();
|
|
244
247
|
const activeWakes = /* @__PURE__ */ new Set();
|
|
@@ -323,7 +326,7 @@ async function installScheduleRuntime(options) {
|
|
|
323
326
|
if (closePromise) return closePromise;
|
|
324
327
|
closing = true;
|
|
325
328
|
return closePromise = (async () => {
|
|
326
|
-
while (activeWakes.size > 0) await Promise.allSettled(
|
|
329
|
+
while (activeWakes.size > 0) await Promise.allSettled(activeWakes);
|
|
327
330
|
await serialize(async () => {});
|
|
328
331
|
await flushWaitUntil();
|
|
329
332
|
await installedDriver.close?.();
|
package/dist/runtime/static.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createLocalWaitUntil } from "../wait-until-
|
|
1
|
+
import { t as createLocalWaitUntil } from "../wait-until-BzIwzXw4.js";
|
|
2
2
|
//#region src/runtime/static.ts
|
|
3
3
|
function createStaticScheduleRun(options) {
|
|
4
4
|
const scheduledAt = options.scheduledAt ?? /* @__PURE__ */ new Date();
|
|
@@ -57,7 +57,7 @@ function readCloudflareScheduledEvent(event) {
|
|
|
57
57
|
const cron = event.controller?.cron ?? event.cron;
|
|
58
58
|
if (!cron) throw new TypeError("[vitehub:schedule] Cloudflare scheduled event is missing a cron string.");
|
|
59
59
|
const scheduledTime = event.controller?.scheduledTime ?? event.scheduledTime;
|
|
60
|
-
const scheduledAt = scheduledTime instanceof Date ? scheduledTime :
|
|
60
|
+
const scheduledAt = scheduledTime instanceof Date ? scheduledTime : scheduledTime === void 0 ? /* @__PURE__ */ new Date() : new Date(scheduledTime);
|
|
61
61
|
if (Number.isNaN(scheduledAt.getTime())) throw new TypeError("[vitehub:schedule] Cloudflare scheduled event has an invalid scheduledTime.");
|
|
62
62
|
return {
|
|
63
63
|
cron,
|
|
@@ -87,14 +87,23 @@ async function runWithCloudflareServerEnv(event, callback, hostWaitUntil) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
async function flushPendingWork(pending) {
|
|
90
|
-
while (pending.size > 0) await Promise.allSettled(
|
|
90
|
+
while (pending.size > 0) await Promise.allSettled(pending);
|
|
91
91
|
}
|
|
92
92
|
function restoreGlobalEnv(globals, hadGlobalEnv, previousGlobalEnv) {
|
|
93
93
|
if (hadGlobalEnv) globals.__env__ = previousGlobalEnv;
|
|
94
94
|
else delete globals.__env__;
|
|
95
95
|
}
|
|
96
96
|
function isRecord(value) {
|
|
97
|
-
return
|
|
97
|
+
return Object(value) === value && !Array.isArray(value);
|
|
98
|
+
}
|
|
99
|
+
function isCallable(value) {
|
|
100
|
+
if (value === null || value === void 0 || Object(value) !== value) return false;
|
|
101
|
+
try {
|
|
102
|
+
Function.prototype.toString.call(value);
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
function readCloudflareWaitUntil(event) {
|
|
100
109
|
const context = isRecord(event.context) ? event.context : void 0;
|
|
@@ -115,7 +124,10 @@ function readCloudflareWaitUntil(event) {
|
|
|
115
124
|
runtimeCloudflare,
|
|
116
125
|
isRecord(runtimeCloudflare?.context) ? runtimeCloudflare.context : void 0
|
|
117
126
|
];
|
|
118
|
-
for (const owner of owners)
|
|
127
|
+
for (const owner of owners) {
|
|
128
|
+
const waitUntil = owner?.waitUntil;
|
|
129
|
+
if (isCallable(waitUntil)) return (promise) => Reflect.apply(waitUntil, owner, [promise]);
|
|
130
|
+
}
|
|
119
131
|
}
|
|
120
132
|
function readCloudflareEventEnv(event) {
|
|
121
133
|
if (isRecord(event.env)) return event.env;
|
|
@@ -131,7 +143,7 @@ function readCloudflareEventEnv(event) {
|
|
|
131
143
|
return isRecord(runtimeCloudflare?.env) ? runtimeCloudflare.env : void 0;
|
|
132
144
|
}
|
|
133
145
|
function unwrapScheduleDefinition(loaded) {
|
|
134
|
-
const definition =
|
|
146
|
+
const definition = "default" in loaded ? loaded.default : loaded;
|
|
135
147
|
return definition && "cron" in definition ? definition : void 0;
|
|
136
148
|
}
|
|
137
149
|
//#endregion
|
package/dist/runtime.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as resetScheduleRuntime, c as setScheduleRuntimeRegistry, d as createMemoryRuntimeScheduleStore, i as loadScheduleDefinition, o as setRuntimeScheduleStore, r as getScheduleRuntimeRegistry, t as getRuntimeScheduleStore } from "./state-By7WU_ks.js";
|
|
2
|
-
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-
|
|
2
|
+
import { n as validateRuntimeScheduleCron, t as schedules } from "./client-DpCD4YFE.js";
|
|
3
3
|
export { createMemoryRuntimeScheduleStore, getRuntimeScheduleStore, getScheduleRuntimeRegistry, loadScheduleDefinition, resetScheduleRuntime, schedules, setRuntimeScheduleStore, setScheduleRuntimeRegistry, validateRuntimeScheduleCron };
|