@navios/core 2.0.0-alpha.0 → 2.0.0-alpha.1

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +33 -3
  2. package/README.md +8 -6
  3. package/lib/{async-context-6pdlnNLA.d.mts → async-context-BAdt7bno.d.mts} +11 -9
  4. package/lib/async-context-BAdt7bno.d.mts.map +1 -0
  5. package/lib/{async-context-Dqk7pE-D.d.cts → async-context-RsWmy2Hi.d.cts} +11 -9
  6. package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
  7. package/lib/{attribute-factory-B3VuYnp7.d.cts → attribute-factory-BW1kgBqf.d.mts} +2 -2
  8. package/lib/{attribute-factory-B3VuYnp7.d.cts.map → attribute-factory-BW1kgBqf.d.mts.map} +1 -1
  9. package/lib/{attribute-factory-mKOXoVnV.d.mts → attribute-factory-DqN4x5XM.d.cts} +2 -2
  10. package/lib/{attribute-factory-mKOXoVnV.d.mts.map → attribute-factory-DqN4x5XM.d.cts.map} +1 -1
  11. package/lib/attribute-value-BNiJjxl1.mjs +225 -0
  12. package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
  13. package/lib/attribute-value-Cux5HhOL.cjs +314 -0
  14. package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
  15. package/lib/{basic-execution-context-DSk5MNtc.cjs → basic-execution-context-5uq2DvEA.cjs} +66 -29
  16. package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
  17. package/lib/{basic-execution-context-CeGuhMOz.mjs → basic-execution-context-u1VktGoM.mjs} +61 -30
  18. package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
  19. package/lib/{execution-context-BPD3FeFb.d.mts → execution-context-BVSmLkYp.d.cts} +2 -2
  20. package/lib/{execution-context-BPD3FeFb.d.mts.map → execution-context-BVSmLkYp.d.cts.map} +1 -1
  21. package/lib/{execution-context-BTJdHhbf.d.cts → execution-context-C5F9rojO.d.mts} +2 -2
  22. package/lib/{execution-context-BTJdHhbf.d.cts.map → execution-context-C5F9rojO.d.mts.map} +1 -1
  23. package/lib/{module-graph-DCP9MHG0.cjs → execution-context-token--cKS4cJv.cjs} +135 -12
  24. package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
  25. package/lib/{module-graph-xvVEykFM.mjs → execution-context-token-Cb3M3Ao0.mjs} +93 -12
  26. package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
  27. package/lib/index.cjs +84 -101
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +14 -10
  30. package/lib/index.d.cts.map +1 -1
  31. package/lib/index.d.mts +14 -10
  32. package/lib/index.d.mts.map +1 -1
  33. package/lib/index.mjs +76 -92
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +2 -2
  36. package/lib/legacy-compat/index.d.cts +3 -3
  37. package/lib/legacy-compat/index.d.mts +2 -2
  38. package/lib/legacy-compat/index.mjs +2 -2
  39. package/lib/{module-DZewk_2r.cjs → module-Bz83ZnJ5.cjs} +43 -34
  40. package/lib/module-Bz83ZnJ5.cjs.map +1 -0
  41. package/lib/{module-options-Dmse0gii.d.mts → module-options-CSqQUSTm.d.mts} +2 -2
  42. package/lib/{module-options-Dmse0gii.d.mts.map → module-options-CSqQUSTm.d.mts.map} +1 -1
  43. package/lib/{module-options-IuDO-p8u.d.cts → module-options-DSRBri4J.d.cts} +2 -2
  44. package/lib/{module-options-IuDO-p8u.d.cts.map → module-options-DSRBri4J.d.cts.map} +1 -1
  45. package/lib/{module-Bha7GER_.mjs → module-zPXwR2qp.mjs} +38 -35
  46. package/lib/module-zPXwR2qp.mjs.map +1 -0
  47. package/lib/settled-within-B6gpu2XW.cjs +32 -0
  48. package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
  49. package/lib/settled-within-Bc2pj8WB.mjs +21 -0
  50. package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
  51. package/lib/testing/index.cjs +12 -34
  52. package/lib/testing/index.cjs.map +1 -1
  53. package/lib/testing/index.d.cts +2 -2
  54. package/lib/testing/index.d.cts.map +1 -1
  55. package/lib/testing/index.d.mts +1 -1
  56. package/lib/testing/index.d.mts.map +1 -1
  57. package/lib/testing/index.mjs +12 -34
  58. package/lib/testing/index.mjs.map +1 -1
  59. package/lib/transport.cjs +19 -8
  60. package/lib/transport.d.cts +102 -38
  61. package/lib/transport.d.cts.map +1 -1
  62. package/lib/transport.d.mts +102 -38
  63. package/lib/transport.d.mts.map +1 -1
  64. package/lib/transport.mjs +6 -7
  65. package/package.json +2 -2
  66. package/lib/async-context-6pdlnNLA.d.mts.map +0 -1
  67. package/lib/async-context-Dqk7pE-D.d.cts.map +0 -1
  68. package/lib/attribute-value-CjX9ZkLq.cjs +0 -172
  69. package/lib/attribute-value-CjX9ZkLq.cjs.map +0 -1
  70. package/lib/attribute-value-DMEA255r.mjs +0 -119
  71. package/lib/attribute-value-DMEA255r.mjs.map +0 -1
  72. package/lib/basic-execution-context-CeGuhMOz.mjs.map +0 -1
  73. package/lib/basic-execution-context-DSk5MNtc.cjs.map +0 -1
  74. package/lib/execution-context-token-BXUKB2hf.cjs +0 -112
  75. package/lib/execution-context-token-BXUKB2hf.cjs.map +0 -1
  76. package/lib/execution-context-token-CrXmTvk2.mjs +0 -77
  77. package/lib/execution-context-token-CrXmTvk2.mjs.map +0 -1
  78. package/lib/module-Bha7GER_.mjs.map +0 -1
  79. package/lib/module-DZewk_2r.cjs.map +0 -1
  80. package/lib/module-graph-DCP9MHG0.cjs.map +0 -1
  81. package/lib/module-graph-xvVEykFM.mjs.map +0 -1
  82. package/lib/module-metadata-C8S92seK.cjs +0 -95
  83. package/lib/module-metadata-C8S92seK.cjs.map +0 -1
  84. package/lib/module-metadata-k3RTt20x.mjs +0 -66
  85. package/lib/module-metadata-k3RTt20x.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context-token-Cb3M3Ao0.mjs","names":[],"sources":["../src/execution/async-context.mts","../src/execution/context-host.mts","../src/modules/module-graph.mts","../src/execution/execution-context-token.mts"],"sourcesContent":["import type { ExecutionContext } from './execution-context.mjs'\n\ninterface Storage {\n run<R>(store: ExecutionContext, fn: () => R): R\n getStore(): ExecutionContext | undefined\n}\n\nlet storage: Storage | null = null\n\n/**\n * Turns on the async context: one `AsyncLocalStorage` holding the current\n * `ExecutionContext`. The `asyncContext: true` option of an application does it.\n */\nexport async function enableAsyncContext(): Promise<void> {\n if (storage === null) {\n const { AsyncLocalStorage } = await import('node:async_hooks')\n storage = new AsyncLocalStorage<ExecutionContext>()\n }\n}\n\n/**\n * Runs `fn` with `ctx` as the current context. A transport does this when its\n * host says that the application has an async context.\n */\nexport function runInContext<R>(ctx: ExecutionContext, fn: () => R): R {\n return storage === null ? fn() : storage.run(ctx, fn)\n}\n\n/**\n * The context of the handler being run, for code that cannot receive it as an\n * argument. Returns `undefined` outside a handler, and always when the\n * application was not created with `asyncContext: true`.\n */\nexport function currentContext(): ExecutionContext | undefined {\n return storage?.getStore()\n}\n","import { BoundInjectionToken, FactoryInjectionToken, InjectableScope } from '@navios/di'\n\nimport type { AnyInjectableType, ClassType, Container, InjectionToken } from '@navios/di'\n\nimport type { LoggerService } from '../logger/logger-output.mjs'\n\n/**\n * Dependencies shared by every execution context of an application.\n */\nexport interface ContextHost {\n readonly container: Container\n /**\n * Called when a context resolves a token that `needsScope` is true for; may\n * throw.\n */\n onScopedUse: ((token: AnyInjectableType) => void) | null\n /** Receives what an `onFinish` callback throws; without it that is dropped. */\n readonly logger?: Pick<LoggerService, 'error'>\n}\n\nfunction tokenName(token: unknown): string {\n return typeof token === 'function' ? token.name : String(token)\n}\n\ntype PlainToken = ClassType | InjectionToken<unknown, unknown>\n\n/** The token itself, without the args that are bound to it. */\nfunction plainToken(token: AnyInjectableType): PlainToken {\n return (\n token instanceof BoundInjectionToken || token instanceof FactoryInjectionToken\n ? token.token\n : token\n ) as PlainToken\n}\n\n/**\n * Whether a context resolves `token` from a DI scope of its execution. A\n * singleton is the same in all of them.\n */\nexport function needsScope(container: Container, token: AnyInjectableType): boolean {\n return container.getProvider(token)?.scope !== InjectableScope.Singleton\n}\n\n/**\n * Builds the host for an application's contexts, applying its policy for\n * request-scoped services.\n */\nexport function createContextHost(\n container: Container,\n mode: 'allow' | 'warn' | 'forbid',\n logger: LoggerService,\n): ContextHost {\n if (mode === 'allow') {\n return { container, onScopedUse: null, logger }\n }\n const seen = new Set<PlainToken>()\n return {\n container,\n logger,\n onScopedUse: (used) => {\n const token = plainToken(used)\n if (mode === 'forbid') {\n throw new Error(\n `[Navios] ${tokenName(token)} was requested with ctx.use()/ctx.resolve(), but this ` +\n `application forbids request-scoped services (requestScopedServices: 'forbid'). ` +\n `Keep per-execution data in a context key instead.`,\n )\n }\n if (!seen.has(token)) {\n seen.add(token)\n logger.warn(\n `${tokenName(token)} is resolved for every execution with ctx.use()/ctx.resolve(). ` +\n `If it only carries data derived from the context, a context key is cheaper and ` +\n `needs no DI scope. Set requestScopedServices: 'allow' to silence this.`,\n )\n }\n },\n }\n}\n","import { isDeepStrictEqual } from 'node:util'\n\nimport type { ClassType, Provider } from '@navios/di'\n\nimport { addMissing } from '../metadata/class-metadata.mjs'\n\nimport { getModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleMetadata } from './module-metadata.mjs'\n\n/**\n * A module as it applies to one application: its guards, interceptors and\n * attributes together with those it inherits, and the modules that import it.\n */\nexport interface ModuleNode {\n module: ClassType\n providers: Provider[]\n /** The module's transport-specific options, by option name. */\n entries: ReadonlyMap<string, unknown>\n guards: ClassType[]\n interceptors: ClassType[]\n attributes: Map<symbol, unknown>\n /**\n * The attributes that the importers of the module do not agree about, and what\n * each of two import paths gives it. They are not among `attributes`;\n * `handlerChain` refuses a handler that would inherit one.\n */\n disputed: ReadonlyMap<symbol, string>\n /** The modules that import this one, in the order they were reached. */\n importers: ModuleNode[]\n /** Whether the module was given to the application directly. */\n isRoot: boolean\n}\n\n/**\n * The classes a module lists under one of the options of a transport, once\n * each. Throws for an entry that is not a class: what an import cycle between\n * the files of two classes leaves behind.\n */\nexport function moduleClasses(\n node: Pick<ModuleNode, 'module' | 'entries'>,\n entry: string,\n): ClassType[] {\n const listed = node.entries.get(entry) as Iterable<unknown> | null | undefined\n if (!listed) {\n return []\n }\n const classes = Array.from(new Set(listed))\n const index = classes.findIndex((listedClass) => typeof listedClass !== 'function')\n if (index !== -1) {\n throw new Error(\n `[Navios] Module ${node.module.name} lists ${String(classes[index])} in ${entry}. When it ` +\n `should be a class, the files of the two usually import each other.`,\n )\n }\n return classes as ClassType[]\n}\n\n/** Two import paths that give a module different values of one attribute. */\ninterface Disagreement {\n one: ClassType[]\n other: ClassType[]\n /** Whether the other path gives a value at all. */\n otherHasValue: boolean\n}\n\n/** What a module has while the graph is being computed. */\ninterface Draft {\n node: ModuleNode\n metadata: ModuleMetadata\n /** The attributes the importers do not agree about. */\n disagreements: Map<symbol, Disagreement>\n /** Whether the walk is at what it imports. */\n open: boolean\n ranked: boolean\n}\n\nfunction names(path: readonly ClassType[]): string {\n return path.map((module) => module.name).join(' -> ')\n}\n\n/** One way to a module from a root, the module included. */\nfunction pathTo(node: ModuleNode): ClassType[] {\n const path = [node.module]\n for (let at = node; !at.isRoot && at.importers.length > 0;) {\n at = at.importers[0]\n path.unshift(at.module)\n }\n return path\n}\n\n/**\n * Gives a module the attributes it inherits. Guards add up over several import\n * paths, which is safe; attributes cannot. One that opens a handler and one that\n * restricts it would each be wrong if it applied because of one path alone, so\n * the paths have to agree where a handler inherits it.\n */\nfunction inheritAttributes(draft: Draft, importers: readonly Draft[]): void {\n const { node, metadata, disagreements } = draft\n const keys = new Set(\n importers.flatMap((importer) => [\n ...importer.node.attributes.keys(),\n ...importer.disagreements.keys(),\n ]),\n )\n for (const key of keys) {\n if (metadata.attributes.has(key)) {\n continue\n }\n const inherited = importers.find((importer) => importer.disagreements.has(key))\n if (inherited) {\n const { one, other, otherHasValue } = inherited.disagreements.get(key)!\n disagreements.set(key, {\n one: [...one, node.module],\n other: [...other, node.module],\n otherHasValue,\n })\n continue\n }\n const source = importers.find((importer) => importer.node.attributes.has(key))!\n const value = source.node.attributes.get(key)\n const disagrees = (importer: Draft) =>\n !importer.node.attributes.has(key) ||\n !isDeepStrictEqual(importer.node.attributes.get(key), value)\n const other = importers.find(disagrees)\n if (other === undefined && !node.isRoot) {\n node.attributes.set(key, value)\n } else {\n disagreements.set(key, {\n one: [...pathTo(source.node), node.module],\n other: other === undefined ? [node.module] : [...pathTo(other.node), node.module],\n otherHasValue: other !== undefined && other.node.attributes.has(key),\n })\n }\n }\n node.disputed = new Map(Array.from(disagreements, ([key, value]) => [key, described(value)]))\n}\n\nfunction described({ one, other, otherHasValue }: Disagreement): string {\n return `one over ${names(one)}, ${otherHasValue ? 'another' : 'none'} over ${names(other)}`\n}\n\n/**\n * Walks the import graph from the given roots and computes, for this\n * application only, what applies to each module.\n *\n * - Guards and interceptors are the union over every path that reaches a\n * module, outermost first: what the importers contribute, importers in\n * import order, then the module's own. Nothing is written back to the\n * classes, so two applications importing one module under different parents\n * do not affect each other.\n * - An attribute comes from the module itself or else from what imports it.\n * One that the importers do not agree about is in `disputed` instead.\n *\n * Neither depends on the order in which a module happens to be reached.\n * Modules are returned in dependency order: a module comes after everything\n * it imports. That cannot be done for modules that import each other, which is\n * an error as well.\n */\nexport function buildModuleGraph(roots: ClassType[]): ModuleNode[] {\n const drafts = new Map<ClassType, Draft>()\n const order: ModuleNode[] = []\n\n // First walk: every module once, in dependency order, with its importers.\n const path: ClassType[] = []\n const visit = (module: ClassType, importer: ModuleNode | null): void => {\n const known = drafts.get(module)\n if (known) {\n if (known.open) {\n throw new Error(\n `[Navios] Modules import each other in a cycle: ` +\n names([...path.slice(path.indexOf(module)), module]),\n )\n }\n if (importer && !known.node.importers.includes(importer)) {\n known.node.importers.push(importer)\n }\n return\n }\n const metadata = getModuleMetadata(module)\n const node: ModuleNode = {\n module,\n providers: metadata.providers,\n entries: metadata.entries,\n guards: [],\n interceptors: [],\n attributes: new Map(),\n disputed: new Map(),\n importers: importer ? [importer] : [],\n isRoot: false,\n }\n const draft: Draft = {\n node,\n metadata,\n disagreements: new Map(),\n open: true,\n ranked: false,\n }\n drafts.set(module, draft)\n path.push(module)\n for (const imported of metadata.imports) {\n visit(imported, node)\n }\n path.pop()\n draft.open = false\n order.push(node)\n }\n for (const root of roots) {\n visit(root, null)\n drafts.get(root)!.node.isRoot = true\n }\n\n // Second walk: importers before what they import, siblings in import\n // order. That is the reverse of a post-order that takes the imports last\n // to first.\n const outermostFirst: Draft[] = []\n const rank = (draft: Draft): void => {\n if (draft.ranked) {\n return\n }\n draft.ranked = true\n const imports = draft.metadata.imports\n for (let i = imports.length - 1; i >= 0; i--) {\n rank(drafts.get(imports[i])!)\n }\n outermostFirst.push(draft)\n }\n for (let i = roots.length - 1; i >= 0; i--) {\n rank(drafts.get(roots[i])!)\n }\n outermostFirst.reverse()\n\n // Each module is complete when its turn comes, because everything that\n // imports it came before; it then hands what it has to its imports.\n for (const draft of outermostFirst) {\n const { node, metadata } = draft\n addMissing(node.guards, metadata.guards)\n addMissing(node.interceptors, metadata.interceptors)\n inheritAttributes(\n draft,\n node.importers.map((importer) => drafts.get(importer.module)!),\n )\n for (const [key, value] of metadata.attributes) {\n node.attributes.set(key, value)\n }\n for (const imported of metadata.imports) {\n const child = drafts.get(imported)!\n addMissing(child.node.guards, node.guards)\n addMissing(child.node.interceptors, node.interceptors)\n }\n }\n return order\n}\n","import { InjectableScope, InjectionToken } from '@navios/di'\n\nimport type { ExecutionContext } from './execution-context.mjs'\n\n/**\n * The context of the current execution, on any transport. Injectable in\n * request-scoped services.\n */\nexport const ExecutionContextToken = InjectionToken.create<ExecutionContext>('ExecutionContext', {\n scope: InjectableScope.Request,\n})\n"],"mappings":";;;;AAOA,IAAI,UAA0B;;;;;AAM9B,eAAsB,qBAAoC;CACxD,IAAI,YAAY,MAAM;EACpB,MAAM,EAAE,sBAAsB,MAAM,OAAO;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A,MAAa,wBAAwB,eAAe,OAAyB,oBAAoB,EAC/F,OAAO,gBAAgB,QACzB,CAAC"}
package/lib/index.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./attribute-value-CjX9ZkLq.cjs");
2
+ const require_attribute_value = require("./attribute-value-Cux5HhOL.cjs");
3
3
  let _navios_di = require("@navios/di");
4
4
  let _navios_di_internal = require("@navios/di/internal");
5
- const require_execution_context_token = require("./execution-context-token-BXUKB2hf.cjs");
6
- let util = require("util");
7
- const require_module_graph = require("./module-graph-DCP9MHG0.cjs");
8
- const require_module_metadata = require("./module-metadata-C8S92seK.cjs");
5
+ const require_execution_context_token = require("./execution-context-token--cKS4cJv.cjs");
9
6
  let node_util = require("node:util");
7
+ const require_settled_within = require("./settled-within-B6gpu2XW.cjs");
10
8
  let node_async_hooks = require("node:async_hooks");
11
- let node_os = require("node:os");
9
+ const require_module = require("./module-Bz83ZnJ5.cjs");
12
10
  let node_process = require("node:process");
13
- const require_module = require("./module-DZewk_2r.cjs");
14
11
  // src/logger/cli-colors.mts
15
12
  const isColorAllowed = () => !process.env.NO_COLOR;
16
13
  const colorIfAllowed = (colorFn) => (text) => isColorAllowed() ? colorFn(text) : text;
@@ -35,9 +32,6 @@ const LOG_LEVELS = [
35
32
  "error",
36
33
  "fatal"
37
34
  ];
38
- /**
39
- * @publicApi
40
- */
41
35
  function isLogLevel(maybeLogLevel) {
42
36
  return LOG_LEVELS.includes(maybeLogLevel);
43
37
  }
@@ -225,7 +219,7 @@ var ConsoleLogger = class {
225
219
  error(message, ...optionalParams) {
226
220
  if (!this.isLevelEnabled("error")) return;
227
221
  const { messages, context, stack } = this.getContextAndStackAndMessagesToPrint([message, ...optionalParams]);
228
- this.printMessages(messages, context, "error", void 0, "stderr", stack);
222
+ this.printMessages(messages, context, "error", "stderr", stack);
229
223
  this.printStackTrace(stack);
230
224
  }
231
225
  warn(message, ...optionalParams) {
@@ -282,15 +276,15 @@ var ConsoleLogger = class {
282
276
  getTimestamp() {
283
277
  return dateTimeFormatter.format(Date.now());
284
278
  }
285
- printMessages(messages, context = "", logLevel = "log", requestId, writeStreamType, errorStack) {
286
- const resolvedRequestId = requestId ?? this.getCurrentRequestId();
279
+ printMessages(messages, context = "", logLevel = "log", writeStreamType, errorStack) {
280
+ const requestId = this.getCurrentRequestId();
287
281
  if (this.options.json) {
288
282
  for (const line of this.toJsonLines(messages)) this.guarded(() => this.printAsJson(line.message, {
289
283
  context,
290
284
  logLevel,
291
285
  writeStreamType,
292
286
  errorStack,
293
- requestId: resolvedRequestId,
287
+ requestId,
294
288
  error: line.error
295
289
  }));
296
290
  return;
@@ -300,7 +294,7 @@ var ConsoleLogger = class {
300
294
  const contextMessage = this.formatContext(context);
301
295
  const timestampDiff = this.updateAndGetTimestampDiff();
302
296
  const formattedLogLevel = logLevel.toUpperCase().padStart(7, " ");
303
- const formattedMessage = this.formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff, resolvedRequestId);
297
+ const formattedMessage = this.formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff, requestId);
304
298
  process[writeStreamType ?? "stdout"].write(formattedMessage);
305
299
  });
306
300
  }
@@ -338,9 +332,9 @@ var ConsoleLogger = class {
338
332
  };
339
333
  if (options.context) logObject.context = options.context;
340
334
  if (options.errorStack) logObject.stack = options.errorStack;
341
- if (this.options.requestId && options.requestId) logObject.requestId = options.requestId;
335
+ if (options.requestId) logObject.requestId = options.requestId;
342
336
  if (options.error) logObject.error = toJsonError(options.error, (value) => this.encodable(value));
343
- const formattedMessage = !this.options.colors && this.inspectOptions.compact === true ? this.stringify(logObject) : (0, util.inspect)(logObject, this.inspectOptions);
337
+ const formattedMessage = !this.options.colors && this.inspectOptions.compact === true ? this.stringify(logObject) : (0, node_util.inspect)(logObject, this.inspectOptions);
344
338
  process[options.writeStreamType ?? "stdout"].write(`${formattedMessage}\n`);
345
339
  }
346
340
  stringify(logObject) {
@@ -351,8 +345,8 @@ var ConsoleLogger = class {
351
345
  const { message, error } = logObject;
352
346
  return JSON.stringify({
353
347
  ...logObject,
354
- message: typeof message === "string" ? message : (0, util.inspect)(message, this.inspectOptions),
355
- error: error && (0, util.inspect)(error, this.inspectOptions)
348
+ message: typeof message === "string" ? message : (0, node_util.inspect)(message, this.inspectOptions),
349
+ error: error && (0, node_util.inspect)(error, this.inspectOptions)
356
350
  });
357
351
  }
358
352
  }
@@ -363,7 +357,7 @@ var ConsoleLogger = class {
363
357
  JSON.stringify(value, (key, inner) => this.stringifyReplacer(key, inner));
364
358
  return value;
365
359
  } catch {
366
- return (0, util.inspect)(value, {
360
+ return (0, node_util.inspect)(value, {
367
361
  ...this.inspectOptions,
368
362
  depth: 1
369
363
  });
@@ -400,7 +394,7 @@ var ConsoleLogger = class {
400
394
  return `${parts.length > 0 ? parts.join(" ") + " " : ""}${output}${timestampDiff}\n`;
401
395
  }
402
396
  getRequestId(requestId) {
403
- if (this.options.requestId && requestId) return `(${this.colorize(requestId, "log")}) `;
397
+ if (requestId) return `(${this.colorize(requestId, "log")}) `;
404
398
  return "";
405
399
  }
406
400
  stringifyMessage(message, logLevel) {
@@ -409,7 +403,7 @@ var ConsoleLogger = class {
409
403
  return this.stringifyMessage(message(), logLevel);
410
404
  }
411
405
  if (typeof message === "string") return this.colorize(message, logLevel);
412
- const outputText = (0, util.inspect)(message, this.inspectOptions);
406
+ const outputText = (0, node_util.inspect)(message, this.inspectOptions);
413
407
  if (isPlainObject(message)) return `Object(${Object.keys(message).length}) ${outputText}`;
414
408
  if (Array.isArray(message)) return `Array(${message.length}) ${outputText}`;
415
409
  return outputText;
@@ -450,7 +444,7 @@ var ConsoleLogger = class {
450
444
  stringifyReplacer(key, value) {
451
445
  if (typeof value === "bigint") return value.toString();
452
446
  if (typeof value === "symbol") return value.toString();
453
- if (value instanceof Map || value instanceof Set || value instanceof Error) return `${(0, util.inspect)(value, this.inspectOptions)}`;
447
+ if (value instanceof Map || value instanceof Set || value instanceof Error) return `${(0, node_util.inspect)(value, this.inspectOptions)}`;
454
448
  return value;
455
449
  }
456
450
  getContextAndMessagesToPrint(args) {
@@ -545,7 +539,7 @@ var PendingOutput = class {
545
539
  /** `settleNow` settles for the output that can be had at once. */
546
540
  constructor(settleNow) {
547
541
  this.settleNow = settleNow;
548
- if (unsettled.size === 0) process.on("exit", settleAll);
542
+ if (unsettled.size === 0 && hasExitEvent) process.on("exit", settleAll);
549
543
  unsettled.add(this);
550
544
  }
551
545
  log(...args) {
@@ -572,7 +566,7 @@ var PendingOutput = class {
572
566
  /** Writes what is held, and everything from here on, to `output`. */
573
567
  settle(output) {
574
568
  this.output = output;
575
- if (unsettled.delete(this) && unsettled.size === 0) process.off("exit", settleAll);
569
+ if (unsettled.delete(this) && unsettled.size === 0 && hasExitEvent) process.off("exit", settleAll);
576
570
  for (const [level, args] of this.held.splice(0)) try {
577
571
  this.write(level, args);
578
572
  } catch {
@@ -588,6 +582,12 @@ var PendingOutput = class {
588
582
  this.output[level]?.(message, ...rest);
589
583
  }
590
584
  };
585
+ /**
586
+ * Whether the runtime tells when the process ends. A Worker with a
587
+ * compatibility date before 2025-09-15 has a `process` without `on()`, and no
588
+ * exit to wait for.
589
+ */
590
+ const hasExitEvent = typeof process.on === "function";
591
591
  /** Those whose messages would be lost if the process ended now. */
592
592
  const unsettled = /* @__PURE__ */ new Set();
593
593
  function settleAll() {
@@ -647,28 +647,28 @@ var LoggerInstance = class {
647
647
  this.context = config?.context;
648
648
  }
649
649
  error(message, ...optionalParams) {
650
- optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(this.context) : optionalParams;
651
- this.localInstance?.error(message, ...optionalParams);
650
+ if (this.context && optionalParams.length === 0) optionalParams.push(void 0);
651
+ this.forward("error", message, optionalParams);
652
652
  }
653
653
  log(message, ...optionalParams) {
654
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
655
- this.localInstance?.log(message, ...optionalParams);
654
+ this.forward("log", message, optionalParams);
656
655
  }
657
656
  warn(message, ...optionalParams) {
658
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
659
- this.localInstance?.warn(message, ...optionalParams);
657
+ this.forward("warn", message, optionalParams);
660
658
  }
661
659
  debug(message, ...optionalParams) {
662
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
663
- this.localInstance?.debug?.(message, ...optionalParams);
660
+ this.forward("debug", message, optionalParams);
664
661
  }
665
662
  verbose(message, ...optionalParams) {
666
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
667
- this.localInstance?.verbose?.(message, ...optionalParams);
663
+ this.forward("verbose", message, optionalParams);
668
664
  }
669
665
  fatal(message, ...optionalParams) {
670
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
671
- this.localInstance?.fatal?.(message, ...optionalParams);
666
+ this.forward("fatal", message, optionalParams);
667
+ }
668
+ /** Writes to the output, the context last. `params` is the caller's own array. */
669
+ forward(level, message, params) {
670
+ if (this.context) params.push(this.context);
671
+ this.localInstance[level]?.(message, ...params);
672
672
  }
673
673
  };
674
674
  (0, _navios_di.registerInjectable)(LoggerInstance, {
@@ -739,7 +739,9 @@ function runStep(owner, phase, fn) {
739
739
  return await fn();
740
740
  } finally {
741
741
  step.running = false;
742
- if (--running === 0) storage.disable();
742
+ if (--running === 0) try {
743
+ storage.disable();
744
+ } catch {}
743
745
  }
744
746
  });
745
747
  }
@@ -753,22 +755,6 @@ function outsideSteps(fn) {
753
755
  return storage.exit(fn);
754
756
  }
755
757
  // src/application/module-providers.mts
756
- /** What a provider consists of. Its type does not show it. */
757
- function parts(provider) {
758
- const { record } = provider;
759
- return [
760
- record.kind,
761
- record.scope,
762
- record.target,
763
- record.fn,
764
- record.value
765
- ];
766
- }
767
- /** Whether two providers of one token come to the same. */
768
- function isSame(left, right) {
769
- const other = parts(right);
770
- return parts(left).every((part, index) => Object.is(part, other[index]));
771
- }
772
758
  function importsIndirectly(importer, imported) {
773
759
  const seen = /* @__PURE__ */ new Set();
774
760
  const pending = [imported];
@@ -783,12 +769,12 @@ function importsIndirectly(importer, imported) {
783
769
  }
784
770
  function choose(candidates) {
785
771
  const [first] = candidates;
786
- if (candidates.filter(({ provider }) => !isSame(provider, first.provider)).length === 0) return {
772
+ if (candidates.filter(({ provider }) => !(0, _navios_di_internal.isSameProvider)(provider, first.provider)).length === 0) return {
787
773
  module: first.node.module,
788
774
  provider: first.provider
789
775
  };
790
776
  const [top, ...rest] = candidates.filter(({ node }) => !candidates.some((other) => other.node !== node && importsIndirectly(other.node, node)));
791
- const rival = rest.find(({ provider }) => !isSame(provider, top.provider));
777
+ const rival = rest.find(({ provider }) => !(0, _navios_di_internal.isSameProvider)(provider, top.provider));
792
778
  return {
793
779
  module: top.node.module,
794
780
  provider: top.provider,
@@ -825,28 +811,6 @@ function moduleProviders(graph, isOfApplication) {
825
811
  }
826
812
  return chosen;
827
813
  }
828
- // src/application/settled-within.mts
829
- /** The longest delay a timer takes. */
830
- const MAX_DELAY_MS = 2 ** 31 - 1;
831
- /**
832
- * Whether `work` settles within `ms`. Rejects when it rejects in time; a later
833
- * rejection is dropped.
834
- */
835
- async function settledWithin(work, ms) {
836
- if (ms > MAX_DELAY_MS) {
837
- await work;
838
- return true;
839
- }
840
- let timer;
841
- const timeout = new Promise((resolve) => {
842
- timer = setTimeout(resolve, ms, false);
843
- });
844
- try {
845
- return await Promise.race([work.then(() => true), timeout]);
846
- } finally {
847
- clearTimeout(timer);
848
- }
849
- }
850
814
  // src/application/shutdown-signals.mts
851
815
  const registries = /* @__PURE__ */ new Map();
852
816
  /** Closes `application` when the process receives one of the signals. */
@@ -896,9 +860,36 @@ async function receive(signal, registry) {
896
860
  }));
897
861
  if (applications.every(([, registration]) => registration.exit) && process.listenerCount(signal) === 0) endProcess(signal);
898
862
  }
863
+ /**
864
+ * The numbers that are the same on every platform, for a runtime that has no
865
+ * `node:os` to ask.
866
+ */
867
+ const SIGNAL_NUMBERS = {
868
+ SIGHUP: 1,
869
+ SIGINT: 2,
870
+ SIGQUIT: 3,
871
+ SIGABRT: 6,
872
+ SIGKILL: 9,
873
+ SIGALRM: 14,
874
+ SIGTERM: 15
875
+ };
876
+ /**
877
+ * The number of a signal. `node:os` is asked for when a signal has arrived
878
+ * and not imported: workerd has no such module before the compatibility date
879
+ * 2025-09-15, and a Worker that never gets a signal must still load.
880
+ */
881
+ function signalNumber(signal) {
882
+ let numbers;
883
+ try {
884
+ numbers = process.getBuiltinModule?.("node:os")?.constants.signals;
885
+ } catch {}
886
+ return numbers?.[signal] ?? SIGNAL_NUMBERS[signal];
887
+ }
899
888
  function endProcess(signal) {
900
- if (process.pid === 1) process.exit(128 + node_os.constants.signals[signal]);
901
- else process.kill(process.pid, signal);
889
+ if (process.pid === 1) {
890
+ const number = signalNumber(signal);
891
+ process.exit(number === void 0 ? 1 : 128 + number);
892
+ } else process.kill(process.pid, signal);
902
893
  }
903
894
  // src/application/application.mts
904
895
  const noopLogger = {
@@ -966,7 +957,6 @@ var Application = class {
966
957
  initialised = false;
967
958
  initialisation = null;
968
959
  startup = null;
969
- closed = false;
970
960
  closing = null;
971
961
  tearingDown = null;
972
962
  signal;
@@ -977,7 +967,7 @@ var Application = class {
977
967
  if (options.container && backing.has(options.container)) throw new Error("[Navios] This container already backs an open application. Close that one first, or give each application a container of its own.");
978
968
  this.container = options.container ?? new _navios_di.Container();
979
969
  const given = /* @__PURE__ */ new Map();
980
- require_module_metadata.assertProviders("The application", options.providers ?? []);
970
+ require_attribute_value.assertProviders("The application", options.providers ?? []);
981
971
  for (const provider of options.providers ?? []) given.set(provider.token, ["providers", provider]);
982
972
  const { logger } = options;
983
973
  if (logger !== void 0 && !Array.isArray(logger)) {
@@ -992,7 +982,6 @@ var Application = class {
992
982
  this.slots.push({
993
983
  instance,
994
984
  transport: null,
995
- started: false,
996
985
  stopped: false
997
986
  });
998
987
  }
@@ -1064,6 +1053,10 @@ var Application = class {
1064
1053
  this.initialisation ??= this.initialise();
1065
1054
  return this.initialisation.then(() => this);
1066
1055
  }
1056
+ /** Whether `close()` was called, or a failed start-up took the application down. */
1057
+ get closed() {
1058
+ return this.closing !== null || this.tearingDown !== null;
1059
+ }
1067
1060
  assertOpen() {
1068
1061
  if (this.closed) throw closedError();
1069
1062
  }
@@ -1108,7 +1101,7 @@ var Application = class {
1108
1101
  }
1109
1102
  async build() {
1110
1103
  const { applicationOptions: options, container } = this;
1111
- let graph = require_module_graph.buildModuleGraph([this.appModule]);
1104
+ let graph = require_execution_context_token.buildModuleGraph([this.appModule]);
1112
1105
  const own = new Set(graph.map((node) => node.module));
1113
1106
  this.applyModuleProviders(graph, own, "before plugins");
1114
1107
  this.logger = await this.step("init", () => container.get(Logger, { context: "Navios" }));
@@ -1128,7 +1121,7 @@ var Application = class {
1128
1121
  if (this.tearingDown !== null) await this.stopTransport(slot, 0);
1129
1122
  }
1130
1123
  await this.setupPlugins();
1131
- if (this.extraModules.length > 0) graph = require_module_graph.buildModuleGraph([this.appModule, ...this.extraModules]);
1124
+ if (this.extraModules.length > 0) graph = require_execution_context_token.buildModuleGraph([this.appModule, ...this.extraModules]);
1132
1125
  this.applyModuleProviders(graph, own, "after plugins");
1133
1126
  await this.step("init", () => this.settleLogger());
1134
1127
  for (const node of graph) await this.step("init", async () => {
@@ -1280,10 +1273,7 @@ var Application = class {
1280
1273
  }
1281
1274
  async startTransports() {
1282
1275
  try {
1283
- for (const slot of this.slots) if (!slot.started) {
1284
- slot.started = true;
1285
- await this.startTransport(slot);
1286
- }
1276
+ for (const slot of this.slots) await this.startTransport(slot);
1287
1277
  this.assertNotTornDown();
1288
1278
  } catch (error) {
1289
1279
  await this.tearDownFailed();
@@ -1336,7 +1326,6 @@ var Application = class {
1336
1326
  if (this.closing === null) {
1337
1327
  this.signal ??= signal;
1338
1328
  this.closing = this.shutdown();
1339
- stopListening(this, this.closing);
1340
1329
  }
1341
1330
  if (phase !== null) {
1342
1331
  this.closing.catch((error) => this.report("Error closing the application", error));
@@ -1347,17 +1336,15 @@ var Application = class {
1347
1336
  /** Transports are given it, and may add to it, for a timer of theirs. */
1348
1337
  get shutdownTimeout() {
1349
1338
  const { shutdownTimeout = 1e4 } = this.applicationOptions;
1350
- return Math.min(shutdownTimeout, MAX_DELAY_MS - 6e4);
1339
+ return Math.min(shutdownTimeout, require_settled_within.MAX_DELAY_MS - 6e4);
1351
1340
  }
1352
1341
  async shutdown() {
1353
- this.closed = true;
1354
1342
  for (const [call, pending] of [["init()", this.initialisation], ["start()", this.startup]]) if (pending !== null) await this.shutdownStep(call, this.shutdownTimeout, () => pending.catch(ignore));
1355
1343
  await this.teardown(this.shutdownTimeout);
1356
1344
  }
1357
1345
  /** Takes down whatever was built so far, once. */
1358
1346
  teardown(transportTimeout) {
1359
1347
  if (this.tearingDown === null) {
1360
- this.closed = true;
1361
1348
  this.tearingDown = this.takeDown(transportTimeout);
1362
1349
  stopListening(this, this.tearingDown);
1363
1350
  }
@@ -1373,7 +1360,8 @@ var Application = class {
1373
1360
  await this.shutdownStep(label, shutdownTimeout, () => instance.onApplicationShutdown(this.signal));
1374
1361
  }
1375
1362
  for (const { plugin, run } of this.shutdownHooks.reverse()) await this.shutdownStep(`onShutdown of plugin ${plugin}`, shutdownTimeout, () => run(this.signal));
1376
- if (!await settledWithin(runStep(this, "shutdown", () => container.dispose()), shutdownTimeout)) this.reportTimeout("disposal of the container", shutdownTimeout);
1363
+ const disposal = runStep(this, "shutdown", () => container.dispose());
1364
+ if (!await require_settled_within.settledWithin(disposal, shutdownTimeout)) this.reportTimeout("disposal of the container", shutdownTimeout);
1377
1365
  } finally {
1378
1366
  backing.delete(container);
1379
1367
  }
@@ -1393,7 +1381,7 @@ var Application = class {
1393
1381
  /** Runs one part of the shutdown. Whatever becomes of it, the rest follows. */
1394
1382
  async shutdownStep(label, timeoutMs, fn) {
1395
1383
  try {
1396
- if (!await settledWithin(runStep(this, "shutdown", fn), timeoutMs)) this.reportTimeout(label, timeoutMs);
1384
+ if (!await require_settled_within.settledWithin(runStep(this, "shutdown", fn), timeoutMs)) this.reportTimeout(label, timeoutMs);
1397
1385
  } catch (error) {
1398
1386
  this.report(`Error in shutdown step "${label}"`, error);
1399
1387
  }
@@ -1608,11 +1596,7 @@ function describeIssue({ path = [], message }, loaded) {
1608
1596
  function checked(name, schema, loaded) {
1609
1597
  let config = loaded;
1610
1598
  if (schema) {
1611
- const result = schema["~standard"].validate(loaded);
1612
- if (result instanceof Promise) {
1613
- result.catch(() => {});
1614
- throw new Error(`[Navios] The schema of the configuration ${name} must validate synchronously.`);
1615
- }
1599
+ const result = require_module.validateNow(schema, loaded, `[Navios] The schema of the configuration ${name} must validate synchronously.`);
1616
1600
  if (result.issues) throw new Error(`[Navios] Invalid configuration ${name}: ` + result.issues.map((issue) => describeIssue(issue, loaded)).join("; "));
1617
1601
  config = result.value;
1618
1602
  }
@@ -1780,7 +1764,6 @@ Object.defineProperty(exports, "inject", {
1780
1764
  return _navios_di.inject;
1781
1765
  }
1782
1766
  });
1783
- exports.isLogLevel = isLogLevel;
1784
1767
  Object.defineProperty(exports, "optional", {
1785
1768
  enumerable: true,
1786
1769
  get: function() {