@holo-js/events 0.3.15 → 0.3.17
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/index.d.ts +2 -2
- package/dist/index.mjs +27 -26
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QueueJobDefinition, QueueJsonValue } from '@holo-js/queue';
|
|
1
|
+
import { QueueJobDefinition, QueueJsonValue, QueueRegisteredJob } from '@holo-js/queue';
|
|
2
2
|
|
|
3
3
|
type EventDelayValue = number | Date;
|
|
4
4
|
type EventDefinitionDispatcher = <TPayload>(event: EventDefinition<TPayload, string | undefined>, payload: TPayload) => EventPendingDispatch<TPayload>;
|
|
@@ -197,7 +197,7 @@ declare module '@holo-js/queue' {
|
|
|
197
197
|
type QueueModule = {
|
|
198
198
|
defineJob(definition: QueueJobDefinition<EventsInvokeListenerPayload, void>): QueueJobDefinition<EventsInvokeListenerPayload, void>;
|
|
199
199
|
dispatch(jobName: string, payload: EventsInvokeListenerPayload): QueuePendingDispatchChain;
|
|
200
|
-
getRegisteredQueueJob(name: string):
|
|
200
|
+
getRegisteredQueueJob(name: string): QueueRegisteredJob | undefined;
|
|
201
201
|
registerQueueJob(definition: QueueJobDefinition<EventsInvokeListenerPayload, void>, options: {
|
|
202
202
|
name: string;
|
|
203
203
|
}): void;
|
package/dist/index.mjs
CHANGED
|
@@ -410,23 +410,28 @@ function deferEventDispatchToDatabaseCommit(callback, _context) {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
// src/queue.ts
|
|
413
|
+
import { createRequire } from "module";
|
|
413
414
|
var EVENTS_INVOKE_LISTENER_JOB = "holo.events.invoke-listener";
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
415
|
+
var require2 = createRequire(import.meta.url);
|
|
416
|
+
var queueSpecifier = "@holo-js/queue";
|
|
417
|
+
function rethrowQueueLoadError(error) {
|
|
418
|
+
if (error && typeof error === "object" && "code" in error && (error.code === "ERR_MODULE_NOT_FOUND" || error.code === "MODULE_NOT_FOUND")) {
|
|
419
|
+
throw new Error("[@holo-js/events] Queued listeners require @holo-js/queue to be installed.");
|
|
420
|
+
}
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
423
|
+
function loadQueueModuleSync() {
|
|
424
|
+
try {
|
|
425
|
+
return require2(queueSpecifier);
|
|
426
|
+
} catch (error) {
|
|
427
|
+
return rethrowQueueLoadError(error);
|
|
428
|
+
}
|
|
420
429
|
}
|
|
421
430
|
async function loadQueueModule() {
|
|
422
431
|
try {
|
|
423
|
-
|
|
424
|
-
return await import(specifier);
|
|
432
|
+
return await import(queueSpecifier);
|
|
425
433
|
} catch (error) {
|
|
426
|
-
|
|
427
|
-
throw new Error("[@holo-js/events] Queued listeners require @holo-js/queue to be installed.");
|
|
428
|
-
}
|
|
429
|
-
throw error;
|
|
434
|
+
return rethrowQueueLoadError(error);
|
|
430
435
|
}
|
|
431
436
|
}
|
|
432
437
|
function createQueuedListenerEventEnvelope(payload) {
|
|
@@ -455,27 +460,23 @@ async function runQueuedListenerInvocation(payload) {
|
|
|
455
460
|
assertQueuedListenerMatchesEvent(listener, payload.eventName);
|
|
456
461
|
await listener.definition.handle(createQueuedListenerEventEnvelope(payload));
|
|
457
462
|
}
|
|
458
|
-
function
|
|
459
|
-
|
|
460
|
-
if (registry.has(EVENTS_INVOKE_LISTENER_JOB)) {
|
|
463
|
+
function registerEventsQueueJob(queue) {
|
|
464
|
+
if (queue.getRegisteredQueueJob(EVENTS_INVOKE_LISTENER_JOB)) {
|
|
461
465
|
return;
|
|
462
466
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
})
|
|
470
|
-
}));
|
|
467
|
+
queue.registerQueueJob({
|
|
468
|
+
handle: runQueuedListenerInvocation
|
|
469
|
+
}, { name: EVENTS_INVOKE_LISTENER_JOB });
|
|
470
|
+
}
|
|
471
|
+
function ensureEventsQueueJobRegistered() {
|
|
472
|
+
registerEventsQueueJob(loadQueueModuleSync());
|
|
471
473
|
}
|
|
472
474
|
async function ensureEventsQueueJobRegisteredAsync() {
|
|
473
|
-
await loadQueueModule();
|
|
474
|
-
ensureEventsQueueJobRegistered();
|
|
475
|
+
registerEventsQueueJob(await loadQueueModule());
|
|
475
476
|
}
|
|
476
477
|
async function dispatchQueuedListenerViaQueue(dispatch) {
|
|
477
478
|
const queueModule = await loadQueueModule();
|
|
478
|
-
|
|
479
|
+
registerEventsQueueJob(queueModule);
|
|
479
480
|
let pending = queueModule.dispatch(EVENTS_INVOKE_LISTENER_JOB, {
|
|
480
481
|
listenerId: dispatch.listenerId,
|
|
481
482
|
eventName: dispatch.event.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/events",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Holo-JS Framework - event contracts and runtime surface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"test": "vitest --run"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@holo-js/db": "^0.3.
|
|
26
|
+
"@holo-js/db": "^0.3.17"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@holo-js/queue": "^0.3.
|
|
29
|
+
"@holo-js/queue": "^0.3.17"
|
|
30
30
|
},
|
|
31
31
|
"peerDependenciesMeta": {
|
|
32
32
|
"@holo-js/queue": {
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@holo-js/queue": "^0.3.
|
|
37
|
+
"@holo-js/queue": "^0.3.17",
|
|
38
38
|
"@types/node": "^22.10.2",
|
|
39
39
|
"tsup": "^8.3.5",
|
|
40
40
|
"typescript": "^5.7.2",
|
|
41
41
|
"vitest": "^4.1.5"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": "
|
|
44
|
+
"node": "^22.12.0 || ^24.0.0 || ^26.0.0"
|
|
45
45
|
}
|
|
46
46
|
}
|