@almadar/runtime 6.20.0 → 6.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OrbitalServerRuntime-TewGACFH.d.ts → OrbitalServerRuntime-CO0rEx3p.d.ts} +0 -5
- package/dist/OrbitalServerRuntime.d.ts +1 -1
- package/dist/OrbitalServerRuntime.js +19 -28
- package/dist/OrbitalServerRuntime.js.map +1 -1
- package/dist/{chunk-JZ4IDIUU.js → chunk-53VRCHPK.js} +81 -4
- package/dist/chunk-53VRCHPK.js.map +1 -0
- package/dist/chunk-U4PL237A.js +51 -0
- package/dist/chunk-U4PL237A.js.map +1 -0
- package/dist/createOsHandlers.js +2 -36
- package/dist/createOsHandlers.js.map +1 -1
- package/dist/index.d.ts +56 -3
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-JZ4IDIUU.js.map +0 -1
|
@@ -1088,11 +1088,6 @@ declare class OrbitalServerRuntime {
|
|
|
1088
1088
|
* Register a single tick
|
|
1089
1089
|
*/
|
|
1090
1090
|
private registerTick;
|
|
1091
|
-
/**
|
|
1092
|
-
* Parse interval string to milliseconds
|
|
1093
|
-
* Supports: '5s', '1m', '1h', '30000' (ms)
|
|
1094
|
-
*/
|
|
1095
|
-
private parseIntervalString;
|
|
1096
1091
|
/**
|
|
1097
1092
|
* Execute a tick for all applicable entities
|
|
1098
1093
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
export { C as ClientEffectTuple, D as ClientNavigateTuple, F as ClientNotifyTuple, G as ClientRenderUITuple, H as EffectResult, J as LoaderConfig, O as OrbitalEventRequest, e as OrbitalEventResponse, K as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, R as RegisteredOrbital, j as RuntimeOrbital, k as RuntimeOrbitalSchema, l as RuntimeTrait, M as RuntimeTraitTick, n as collectDeclaredConfigDefaults, N as createOrbitalServerRuntime } from './OrbitalServerRuntime-
|
|
2
|
+
export { C as ClientEffectTuple, D as ClientNavigateTuple, F as ClientNotifyTuple, G as ClientRenderUITuple, H as EffectResult, J as LoaderConfig, O as OrbitalEventRequest, e as OrbitalEventResponse, K as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, R as RegisteredOrbital, j as RuntimeOrbital, k as RuntimeOrbitalSchema, l as RuntimeTrait, M as RuntimeTraitTick, n as collectDeclaredConfigDefaults, N as createOrbitalServerRuntime } from './OrbitalServerRuntime-CO0rEx3p.js';
|
|
3
3
|
import './types-BA7GoDni.js';
|
|
4
4
|
import '@almadar/core';
|
|
5
5
|
export { I as InMemoryPersistence, P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, StateMachineManager, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-
|
|
2
|
-
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-
|
|
1
|
+
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-53VRCHPK.js';
|
|
2
|
+
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-53VRCHPK.js';
|
|
3
|
+
import { isValidCronExpression } from './chunk-U4PL237A.js';
|
|
3
4
|
import './chunk-PZ5AY32C.js';
|
|
4
5
|
import { createLogger } from '@almadar/logger';
|
|
5
6
|
import * as nodeModule from 'module';
|
|
@@ -603,11 +604,26 @@ var OrbitalServerRuntime = class {
|
|
|
603
604
|
* Register a single tick
|
|
604
605
|
*/
|
|
605
606
|
registerTick(orbitalName, traitName, tick, registered) {
|
|
607
|
+
if (typeof tick.interval === "string" && isValidCronExpression(tick.interval)) {
|
|
608
|
+
if (this.config.debug) {
|
|
609
|
+
registerLog.debug("register:tick-cron", {
|
|
610
|
+
orbital: orbitalName,
|
|
611
|
+
trait: traitName,
|
|
612
|
+
tick: tick.name,
|
|
613
|
+
expression: tick.interval
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
const handle2 = this.tickScheduler.addCron(tick.interval, () => {
|
|
617
|
+
void this.executeTick(orbitalName, traitName, tick, registered);
|
|
618
|
+
});
|
|
619
|
+
this.tickBindings.push({ orbitalName, traitName, tick, handle: handle2 });
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
606
622
|
let intervalMs;
|
|
607
623
|
if (typeof tick.interval === "number") {
|
|
608
624
|
intervalMs = tick.interval;
|
|
609
625
|
} else if (typeof tick.interval === "string") {
|
|
610
|
-
intervalMs =
|
|
626
|
+
intervalMs = parseDurationString(tick.interval);
|
|
611
627
|
} else {
|
|
612
628
|
intervalMs = 1e3;
|
|
613
629
|
}
|
|
@@ -629,31 +645,6 @@ var OrbitalServerRuntime = class {
|
|
|
629
645
|
handle
|
|
630
646
|
});
|
|
631
647
|
}
|
|
632
|
-
/**
|
|
633
|
-
* Parse interval string to milliseconds
|
|
634
|
-
* Supports: '5s', '1m', '1h', '30000' (ms)
|
|
635
|
-
*/
|
|
636
|
-
parseIntervalString(interval) {
|
|
637
|
-
const match = interval.match(/^(\d+)(ms|s|m|h)?$/);
|
|
638
|
-
if (!match) {
|
|
639
|
-
registerLog.warn("register:tick-invalid-interval", { interval, defaultMs: 1e3 });
|
|
640
|
-
return 1e3;
|
|
641
|
-
}
|
|
642
|
-
const value = parseInt(match[1], 10);
|
|
643
|
-
const unit = match[2] || "ms";
|
|
644
|
-
switch (unit) {
|
|
645
|
-
case "ms":
|
|
646
|
-
return value;
|
|
647
|
-
case "s":
|
|
648
|
-
return value * 1e3;
|
|
649
|
-
case "m":
|
|
650
|
-
return value * 60 * 1e3;
|
|
651
|
-
case "h":
|
|
652
|
-
return value * 60 * 60 * 1e3;
|
|
653
|
-
default:
|
|
654
|
-
return value;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
648
|
/**
|
|
658
649
|
* Execute a tick for all applicable entities
|
|
659
650
|
*/
|