@powerlines/engine 0.15.18 → 0.15.19

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/engine.cjs CHANGED
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('./chunk-C0xms8kb.cjs');
3
3
  const require_context_engine_context = require('./context/engine-context.cjs');
4
4
  const require_helpers_execution_host_worker = require('./helpers/execution-host-worker.cjs');
5
- let _powerlines_core_constants = require("@powerlines/core/constants");
6
5
  let devframe_node = require("devframe/node");
7
6
  let get_port_please = require("get-port-please");
8
7
  let h3 = require("h3");
@@ -252,7 +251,7 @@ async function createContext(options) {
252
251
  websocket: port
253
252
  });
254
253
  }
255
- async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods = _powerlines_core_constants.EXECUTION_API_METHODS) {
254
+ async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods) {
256
255
  node_events.EventEmitter.setMaxListeners(100);
257
256
  const context = await createContext(options);
258
257
  return new PowerlinesEngine(context, await require_helpers_execution_host_worker.ExecutionHostWorker.from(executionHostPath, {
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.cts","names":[],"sources":["../src/engine.ts"],"mappings":";;;;;;;;;;AA+CA;;;cAAa,gBAAA,uBACW,aAAA,kBAA+B,qBAAA,aAE1C,MAAA,CAAO,aAAA,GAAgB,eAAA;EAAA;EAAhB;;;EAAA,IAeP,OAAA,CAAA,GAAW,aAAA;EAmBX;;;EAAA,IAZA,IAAA,CAAA,GAAQ,aAAA,CAAc,aAAA;EA4BmB;;;;;;;cAhBlD,OAAA,EAAS,aAAA,EACT,IAAA,EAAM,aAAA,CAAc,aAAA;EAsF0B;;;;;;;;;EAvEnC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+KlB;;;;;;;;EA7JrB,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAt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AM,aAAA,CAAc,aAAA;EAsF0B;;;;;;;;;EAvEnC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+KlB;;;;;;;;EA7JrB,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAtElD;;;;;;;;EAwFa,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAmB,OAAA;EAhE3C;;;;;;;;;EAmFE,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAvDhB;;;;;;EAuErB,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAnCnC;;;;;;;;;EAsDA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAnB9B;;;;;;;;;EAsCL,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAgBrC;;;;;;EAAA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAmBI;;;;;;;;;EAAvC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+ClD;;;;AAkCJ;;;;EA/De,QAAA,CAAA,GAAQ,OAAA;EA+DmC;;;EAAA,CAlD1C,MAAA,CAAO,YAAA,KAAa,OAAA;EAkDA;;;;;AAuBpC;;;;;EAvBoC,UApClB,OAAA,CACd,MAAA,EAAQ,aAAA,UACR,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBAkCR,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,iBAAA,WACA,gBAAA,GAAmB,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
package/dist/engine.d.mts CHANGED
@@ -2,8 +2,8 @@ import { n as EngineOptions } from "./config-BNe23XHx.mjs";
2
2
  import { t as EngineContext } from "./context-DzgsMSWr.mjs";
3
3
  import { t as PowerlinesEngineContext } from "./engine-context-DEotmVzB.mjs";
4
4
  import { n as ExecutionHost, t as Engine } from "./api-Cdw4v0W4.mjs";
5
- import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
6
5
  import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
6
+ import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
7
7
 
8
8
  //#region src/engine.d.ts
9
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.mts","names":[],"sources":["../src/engine.ts"],"mappings":";;;;;;;;;;AA+CA;;;cAAa,gBAAA,uBACW,aAAA,kBAA+B,qBAAA,aAE1C,MAAA,CAAO,aAAA,GAAgB,eAAA;EAAA;EAAhB;;;EAAA,IAeP,OAAA,CAAA,GAAW,aAAA;EAmBX;;;EAAA,IAZA,IAAA,CAAA,GAAQ,aAAA,CAAc,aAAA;EA4BmB;;;;;;;cAhBlD,OAAA,EAAS,aAAA,EACT,IAAA,EAAM,aAAA,CAAc,aAAA;EAsF0B;;;;;;;;;EAvEnC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+KlB;;;;;;;;EA7JrB,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAtElD;;;;;;;;EAwFa,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAmB,OAAA;EAhE3C;;;;;;;;;EAmFE,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAvDhB;;;;;;EAuErB,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAnCnC;;;;;;;;;EAsDA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAnB9B;;;;;;;;;EAsCL,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAgBrC;;;;;;EAAA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAmBI;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Ac,gBAAA,GAAgB,OAAA;EAnB9B;;;;;;;;;EAsCL,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAgBrC;;;;;;EAAA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAmBI;;;;;;;;;EAAvC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+ClD;;;;AAkCJ;;;;EA/De,QAAA,CAAA,GAAQ,OAAA;EA+DmC;;;EAAA,CAlD1C,MAAA,CAAO,YAAA,KAAa,OAAA;EAkDA;;;;;AAuBpC;;;;;EAvBoC,UApClB,OAAA,CACd,MAAA,EAAQ,aAAA,UACR,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBAkCR,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,iBAAA,WACA,gBAAA,GAAmB,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
package/dist/engine.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { PowerlinesEngineContext } from "./context/engine-context.mjs";
2
2
  import { ExecutionHostWorker } from "./helpers/execution-host-worker.mjs";
3
- import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
4
3
  import { createH3DevToolsHost } from "devframe/node";
5
4
  import { getPort } from "get-port-please";
6
5
  import { createApp, fromNodeMiddleware } from "h3";
@@ -249,7 +248,7 @@ async function createContext(options) {
249
248
  websocket: port
250
249
  });
251
250
  }
252
- async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods = EXECUTION_API_METHODS) {
251
+ async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods) {
253
252
  EventEmitter.setMaxListeners(100);
254
253
  const context = await createContext(options);
255
254
  return new PowerlinesEngine(context, await ExecutionHostWorker.from(executionHostPath, {
@@ -1 +1 @@
1
- {"version":3,"file":"engine.mjs","names":["#context","#host"],"sources":["../src/engine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n BuildInlineConfig,\n CleanInlineConfig,\n CreateInlineConfig,\n DeployInlineConfig,\n DocsInlineConfig,\n InlineConfig,\n LintInlineConfig,\n PrepareInlineConfig,\n TestInlineConfig,\n TypesInlineConfig\n} from \"@powerlines/core\";\nimport { EXECUTION_API_METHODS } from \"@powerlines/core/constants\";\nimport { createH3DevToolsHost } from \"devframe/node\";\nimport { getPort } from \"get-port-please\";\nimport { createApp, fromNodeMiddleware } from \"h3\";\nimport { EventEmitter } from \"node:events\";\nimport sirv from \"sirv\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { ExecutionHostWorker } from \"./helpers/execution-host-worker\";\nimport { Engine, ExecutionHost } from \"./types/api\";\nimport { EngineOptions } from \"./types/config\";\nimport { EngineContext } from \"./types/context\";\n\n/**\n * The Powerlines process' orchestration and coordination API.\n *\n * @public\n */\nexport class PowerlinesEngine<\n TExecutionAPI extends ReadonlyArray<string> = typeof EXECUTION_API_METHODS\n>\n implements Engine<TExecutionAPI>, AsyncDisposable\n{\n /**\n * The Powerlines context\n */\n #context: EngineContext;\n\n /**\n * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.\n */\n #host: ExecutionHost<TExecutionAPI>;\n\n /**\n * The Powerlines context\n */\n public get context(): EngineContext {\n return this.#context;\n }\n\n /**\n * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.\n */\n public get host(): ExecutionHost<TExecutionAPI> {\n return this.#host;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param host - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(\n context: EngineContext,\n host: ExecutionHost<TExecutionAPI>\n ) {\n this.#context = context;\n this.#host = host;\n }\n\n /**\n * Create a new Powerlines project\n *\n * @remarks\n * This method will create a new Powerlines project in the current directory.\n *\n * @param inlineConfig - The inline configuration for the create command\n * @returns A promise that resolves when the project has been created\n */\n public async create(inlineConfig: CreateInlineConfig) {\n const timer = this.context.timer(\"Create\");\n this.context.info(\"🆕 Creating a new project\");\n\n await this.execute(\"create\", inlineConfig);\n\n this.context.debug(\"✔ Create command completed successfully\");\n timer();\n }\n\n /**\n * Generate the Powerlines typescript declaration file\n *\n * @remarks\n * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.\n *\n * @param inlineConfig - The inline configuration for the types command\n */\n public async types(inlineConfig: TypesInlineConfig) {\n const timer = this.context.timer(\"Types\");\n this.context.info(\"🏗️ Generating typescript declarations for the project\");\n\n await this.execute(\"types\", inlineConfig);\n\n this.context.debug(\"✔ Types generation has completed successfully\");\n timer();\n }\n\n /**\n * Prepare the Powerlines API\n *\n * @remarks\n * This method will prepare the Powerlines API for use, initializing any necessary resources.\n *\n * @param inlineConfig - The inline configuration for the prepare command\n */\n public async prepare(inlineConfig: PrepareInlineConfig) {\n const timer = this.context.timer(\"Prepare\");\n this.context.info(\"🏗️ Preparing the project\");\n\n await this.execute(\"prepare\", inlineConfig);\n\n this.context.debug(\"✔ Preparation has completed successfully\");\n timer();\n }\n\n /**\n * Clean any previously prepared artifacts\n *\n * @remarks\n * This method will remove the previous Powerlines artifacts from the project.\n *\n * @param inlineConfig - The inline configuration for the clean command\n * @returns A promise that resolves when the clean command has completed\n */\n public async clean(inlineConfig: CleanInlineConfig) {\n const timer = this.context.timer(\"Clean\");\n this.context.info(\"🧹 Cleaning the previous artifacts\");\n\n await this.execute(\"clean\", inlineConfig);\n\n this.context.debug(\"✔ Cleaning completed successfully\");\n timer();\n }\n\n /**\n * Lint the project\n *\n * @param inlineConfig - The inline configuration for the lint command\n * @returns A promise that resolves when the lint command has completed\n */\n public async lint(inlineConfig: LintInlineConfig) {\n const timer = this.context.timer(\"Lint\");\n this.context.info(\"📝 Linting the project\");\n\n await this.execute(\"lint\", inlineConfig);\n\n this.context.debug(\"✔ Linting completed successfully\");\n timer();\n }\n\n /**\n * Test the project\n *\n * @remarks\n * This method will run the tests for the Powerlines project.\n *\n * @param inlineConfig - The inline configuration for the test command\n * @returns A promise that resolves when the test command has completed\n */\n public async test(inlineConfig: TestInlineConfig) {\n const timer = this.context.timer(\"Test\");\n this.context.info(\"🧪 Running tests for the project\");\n\n await this.execute(\"test\", inlineConfig);\n\n this.context.debug(\"✔ Testing completed successfully\");\n timer();\n }\n\n /**\n * Build the project\n *\n * @remarks\n * This method will build the Powerlines project, generating the necessary artifacts.\n *\n * @param inlineConfig - The inline configuration for the build command\n * @returns A promise that resolves when the build command has completed\n */\n public async build(inlineConfig: BuildInlineConfig) {\n const timer = this.context.timer(\"Build\");\n this.context.info(\"📦 Building the project\");\n\n await this.execute(\"build\", inlineConfig);\n\n this.context.debug(\"✔ Build completed successfully\");\n timer();\n }\n\n /**\n * Prepare the documentation for the project\n *\n * @param inlineConfig - The inline configuration for the docs command\n * @returns A promise that resolves when the documentation generation has completed\n */\n public async docs(inlineConfig: DocsInlineConfig) {\n const timer = this.context.timer(\"Docs\");\n this.context.info(\"📓 Generating documentation for the project\");\n\n await this.execute(\"docs\", inlineConfig);\n\n this.context.debug(\"✔ Documentation generation completed successfully\");\n timer();\n }\n\n /**\n * Deploy the project source code\n *\n * @remarks\n * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.\n *\n * @param inlineConfig - The inline configuration for the deploy command\n * @returns A promise that resolves when the deploy command has completed\n */\n public async deploy(inlineConfig: DeployInlineConfig) {\n const timer = this.context.timer(\"Deploy\");\n this.context.info(\"🚀 Deploying the project\");\n\n await this.execute(\"deploy\", inlineConfig);\n\n this.context.debug(\"✔ Deployment completed successfully\");\n timer();\n }\n\n /**\n * Finalization/cleanup processing for the Powerlines API\n *\n * @remarks\n * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.\n *\n * @returns A promise that resolves when the finalization process has completed\n */\n public async finalize() {\n const timer = this.context.timer(\"Finalize\");\n this.context.info(\"🏁 Finalization processes started\");\n\n await this.host.end();\n\n this.context.debug(\"✔ Finalization completed successfully\");\n timer();\n }\n\n /**\n * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.\n */\n public async [Symbol.asyncDispose]() {\n return this.finalize();\n }\n\n /**\n * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.\n *\n * @remarks\n * This method will load the executions for the specified command and inline configuration, then execute each one while managing their lifecycle, including handling their completion and any errors that may occur during execution.\n *\n * @param method - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.\n * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.\n * @returns A promise that resolves when all executions for the specified command have completed\n */\n protected async execute(\n method: TExecutionAPI[number],\n inlineConfig: InlineConfig\n ) {\n await Promise.all(\n (await this.context.loadExecutions(method, inlineConfig)).map(\n async execution => {\n try {\n await this.host[method]({\n options: execution.options,\n inlineConfig\n });\n } catch (error) {\n this.context.error(\n `Execution of method \"${method}\" failed for execution with invocation ID \"${\n execution.invocationId\n }\" and execution ID \"${execution.options.executionId}\": \\n\\n${\n error instanceof Error\n ? error.stack || error.message\n : String(error)\n }`\n );\n\n throw error;\n } finally {\n this.context.completeExecution(\n execution.invocationId,\n execution.options.executionId\n );\n }\n }\n )\n );\n }\n}\n\nexport async function createContext(options: EngineOptions) {\n const port =\n options.port ??\n (await getPort({\n host: options.host || \"localhost\",\n random: true\n }));\n\n const app = createApp();\n const host = createH3DevToolsHost({\n appName: options.framework?.name || \"powerlines\",\n origin: `http://${options.host || \"localhost\"}:${port}`,\n mount: (base, dir) => {\n app.use(base, fromNodeMiddleware(sirv(dir, { dev: true, single: true })));\n }\n });\n\n return PowerlinesEngineContext.from(options, host, {\n backend: \"websocket\",\n websocket: port\n });\n}\n\nexport async function createEngine<TExecutionAPI extends ReadonlyArray<string>>(\n options: EngineOptions,\n executionHostPath = \"@powerlines/engine/execution-host\",\n executionMethods: TExecutionAPI = EXECUTION_API_METHODS as unknown as TExecutionAPI\n) {\n EventEmitter.setMaxListeners(100);\n\n const context = await createContext(options);\n const host = await ExecutionHostWorker.from<TExecutionAPI>(\n executionHostPath,\n {\n root: options.root,\n context,\n executionMethods\n }\n );\n\n return new PowerlinesEngine<TExecutionAPI>(context, host);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+CA,IAAa,mBAAb,MAIA;;;;CAIE;;;;CAKA;;;;CAKA,IAAW,UAAyB;AAClC,SAAO,MAAKA;;;;;CAMd,IAAW,OAAqC;AAC9C,SAAO,MAAKC;;;;;;;;;CAUd,AAAO,YACL,SACA,MACA;AACA,QAAKD,UAAW;AAChB,QAAKC,OAAQ;;;;;;;;;;;CAYf,MAAa,OAAO,cAAkC;EACpD,MAAM,QAAQ,KAAK,QAAQ,MAAM,SAAS;AAC1C,OAAK,QAAQ,KAAK,4BAA4B;AAE9C,QAAM,KAAK,QAAQ,UAAU,aAAa;AAE1C,OAAK,QAAQ,MAAM,0CAA0C;AAC7D,SAAO;;;;;;;;;;CAWT,MAAa,MAAM,cAAiC;EAClD,MAAM,QAAQ,KAAK,QAAQ,MAAM,QAAQ;AACzC,OAAK,QAAQ,KAAK,0DAA0D;AAE5E,QAAM,KAAK,QAAQ,SAAS,aAAa;AAEzC,OAAK,QAAQ,MAAM,gDAAgD;AACnE,SAAO;;;;;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CAAC;AAEF,QAAO,wBAAwB,KAAK,SAAS,MAAM;EACjD,SAAS;EACT,WAAW;EACZ,CAAC;;AAGJ,eAAsB,aACpB,SACA,oBAAoB,qCACpB,mBAAkC,uBAClC;AACA,cAAa,gBAAgB,IAAI;CAEjC,MAAM,UAAU,MAAM,cAAc,QAAQ;AAU5C,QAAO,IAAI,iBAAgC,SAAS,MATjC,oBAAoB,KACrC,mBACA;EACE,MAAM,QAAQ;EACd;EACA;EACD,CACF,CAEwD"}
1
+ {"version":3,"file":"engine.mjs","names":["#context","#host"],"sources":["../src/engine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n BuildInlineConfig,\n CleanInlineConfig,\n CreateInlineConfig,\n DeployInlineConfig,\n DocsInlineConfig,\n InlineConfig,\n LintInlineConfig,\n PrepareInlineConfig,\n TestInlineConfig,\n TypesInlineConfig\n} from \"@powerlines/core\";\nimport { EXECUTION_API_METHODS } from \"@powerlines/core/constants\";\nimport { createH3DevToolsHost } from \"devframe/node\";\nimport { getPort } from \"get-port-please\";\nimport { createApp, fromNodeMiddleware } from \"h3\";\nimport { EventEmitter } from \"node:events\";\nimport sirv from \"sirv\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { ExecutionHostWorker } from \"./helpers/execution-host-worker\";\nimport { Engine, ExecutionHost } from \"./types/api\";\nimport { EngineOptions } from \"./types/config\";\nimport { EngineContext } from \"./types/context\";\n\n/**\n * The Powerlines process' orchestration and coordination API.\n *\n * @public\n */\nexport class PowerlinesEngine<\n TExecutionAPI extends ReadonlyArray<string> = typeof EXECUTION_API_METHODS\n>\n implements Engine<TExecutionAPI>, AsyncDisposable\n{\n /**\n * The Powerlines context\n */\n #context: EngineContext;\n\n /**\n * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.\n */\n #host: ExecutionHost<TExecutionAPI>;\n\n /**\n * The Powerlines context\n */\n public get context(): EngineContext {\n return this.#context;\n }\n\n /**\n * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.\n */\n public get host(): ExecutionHost<TExecutionAPI> {\n return this.#host;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param host - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(\n context: EngineContext,\n host: ExecutionHost<TExecutionAPI>\n ) {\n this.#context = context;\n this.#host = host;\n }\n\n /**\n * Create a new Powerlines project\n *\n * @remarks\n * This method will create a new Powerlines project in the current directory.\n *\n * @param inlineConfig - The inline configuration for the create command\n * @returns A promise that resolves when the project has been created\n */\n public async create(inlineConfig: CreateInlineConfig) {\n const timer = this.context.timer(\"Create\");\n this.context.info(\"🆕 Creating a new project\");\n\n await this.execute(\"create\", inlineConfig);\n\n this.context.debug(\"✔ Create command completed successfully\");\n timer();\n }\n\n /**\n * Generate the Powerlines typescript declaration file\n *\n * @remarks\n * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.\n *\n * @param inlineConfig - The inline configuration for the types command\n */\n public async types(inlineConfig: TypesInlineConfig) {\n const timer = this.context.timer(\"Types\");\n this.context.info(\"🏗️ Generating typescript declarations for the project\");\n\n await this.execute(\"types\", inlineConfig);\n\n this.context.debug(\"✔ Types generation has completed successfully\");\n timer();\n }\n\n /**\n * Prepare the Powerlines API\n *\n * @remarks\n * This method will prepare the Powerlines API for use, initializing any necessary resources.\n *\n * @param inlineConfig - The inline configuration for the prepare command\n */\n public async prepare(inlineConfig: PrepareInlineConfig) {\n const timer = this.context.timer(\"Prepare\");\n this.context.info(\"🏗️ Preparing the project\");\n\n await this.execute(\"prepare\", inlineConfig);\n\n this.context.debug(\"✔ Preparation has completed successfully\");\n timer();\n }\n\n /**\n * Clean any previously prepared artifacts\n *\n * @remarks\n * This method will remove the previous Powerlines artifacts from the project.\n *\n * @param inlineConfig - The inline configuration for the clean command\n * @returns A promise that resolves when the clean command has completed\n */\n public async clean(inlineConfig: CleanInlineConfig) {\n const timer = this.context.timer(\"Clean\");\n this.context.info(\"🧹 Cleaning the previous artifacts\");\n\n await this.execute(\"clean\", inlineConfig);\n\n this.context.debug(\"✔ Cleaning completed successfully\");\n timer();\n }\n\n /**\n * Lint the project\n *\n * @param inlineConfig - The inline configuration for the lint command\n * @returns A promise that resolves when the lint command has completed\n */\n public async lint(inlineConfig: LintInlineConfig) {\n const timer = this.context.timer(\"Lint\");\n this.context.info(\"📝 Linting the project\");\n\n await this.execute(\"lint\", inlineConfig);\n\n this.context.debug(\"✔ Linting completed successfully\");\n timer();\n }\n\n /**\n * Test the project\n *\n * @remarks\n * This method will run the tests for the Powerlines project.\n *\n * @param inlineConfig - The inline configuration for the test command\n * @returns A promise that resolves when the test command has completed\n */\n public async test(inlineConfig: TestInlineConfig) {\n const timer = this.context.timer(\"Test\");\n this.context.info(\"🧪 Running tests for the project\");\n\n await this.execute(\"test\", inlineConfig);\n\n this.context.debug(\"✔ Testing completed successfully\");\n timer();\n }\n\n /**\n * Build the project\n *\n * @remarks\n * This method will build the Powerlines project, generating the necessary artifacts.\n *\n * @param inlineConfig - The inline configuration for the build command\n * @returns A promise that resolves when the build command has completed\n */\n public async build(inlineConfig: BuildInlineConfig) {\n const timer = this.context.timer(\"Build\");\n this.context.info(\"📦 Building the project\");\n\n await this.execute(\"build\", inlineConfig);\n\n this.context.debug(\"✔ Build completed successfully\");\n timer();\n }\n\n /**\n * Prepare the documentation for the project\n *\n * @param inlineConfig - The inline configuration for the docs command\n * @returns A promise that resolves when the documentation generation has completed\n */\n public async docs(inlineConfig: DocsInlineConfig) {\n const timer = this.context.timer(\"Docs\");\n this.context.info(\"📓 Generating documentation for the project\");\n\n await this.execute(\"docs\", inlineConfig);\n\n this.context.debug(\"✔ Documentation generation completed successfully\");\n timer();\n }\n\n /**\n * Deploy the project source code\n *\n * @remarks\n * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.\n *\n * @param inlineConfig - The inline configuration for the deploy command\n * @returns A promise that resolves when the deploy command has completed\n */\n public async deploy(inlineConfig: DeployInlineConfig) {\n const timer = this.context.timer(\"Deploy\");\n this.context.info(\"🚀 Deploying the project\");\n\n await this.execute(\"deploy\", inlineConfig);\n\n this.context.debug(\"✔ Deployment completed successfully\");\n timer();\n }\n\n /**\n * Finalization/cleanup processing for the Powerlines API\n *\n * @remarks\n * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.\n *\n * @returns A promise that resolves when the finalization process has completed\n */\n public async finalize() {\n const timer = this.context.timer(\"Finalize\");\n this.context.info(\"🏁 Finalization processes started\");\n\n await this.host.end();\n\n this.context.debug(\"✔ Finalization completed successfully\");\n timer();\n }\n\n /**\n * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.\n */\n public async [Symbol.asyncDispose]() {\n return this.finalize();\n }\n\n /**\n * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.\n *\n * @remarks\n * This method will load the executions for the specified command and inline configuration, then execute each one while managing their lifecycle, including handling their completion and any errors that may occur during execution.\n *\n * @param method - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.\n * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.\n * @returns A promise that resolves when all executions for the specified command have completed\n */\n protected async execute(\n method: TExecutionAPI[number],\n inlineConfig: InlineConfig\n ) {\n await Promise.all(\n (await this.context.loadExecutions(method, inlineConfig)).map(\n async execution => {\n try {\n await this.host[method]({\n options: execution.options,\n inlineConfig\n });\n } catch (error) {\n this.context.error(\n `Execution of method \"${method}\" failed for execution with invocation ID \"${\n execution.invocationId\n }\" and execution ID \"${execution.options.executionId}\": \\n\\n${\n error instanceof Error\n ? error.stack || error.message\n : String(error)\n }`\n );\n\n throw error;\n } finally {\n this.context.completeExecution(\n execution.invocationId,\n execution.options.executionId\n );\n }\n }\n )\n );\n }\n}\n\nexport async function createContext(options: EngineOptions) {\n const port =\n options.port ??\n (await getPort({\n host: options.host || \"localhost\",\n random: true\n }));\n\n const app = createApp();\n const host = createH3DevToolsHost({\n appName: options.framework?.name || \"powerlines\",\n origin: `http://${options.host || \"localhost\"}:${port}`,\n mount: (base, dir) => {\n app.use(base, fromNodeMiddleware(sirv(dir, { dev: true, single: true })));\n }\n });\n\n return PowerlinesEngineContext.from(options, host, {\n backend: \"websocket\",\n websocket: port\n });\n}\n\nexport async function createEngine<TExecutionAPI extends ReadonlyArray<string>>(\n options: EngineOptions,\n executionHostPath = \"@powerlines/engine/execution-host\",\n executionMethods?: TExecutionAPI\n) {\n EventEmitter.setMaxListeners(100);\n\n const context = await createContext(options);\n const host = await ExecutionHostWorker.from<TExecutionAPI>(\n executionHostPath,\n {\n root: options.root,\n context,\n executionMethods\n }\n );\n\n return new PowerlinesEngine<TExecutionAPI>(context, host);\n}\n"],"mappings":";;;;;;;;;;;;;;AA+CA,IAAa,mBAAb,MAIA;;;;CAIE;;;;CAKA;;;;CAKA,IAAW,UAAyB;AAClC,SAAO,MAAKA;;;;;CAMd,IAAW,OAAqC;AAC9C,SAAO,MAAKC;;;;;;;;;CAUd,AAAO,YACL,SACA,MACA;AACA,QAAKD,UAAW;AAChB,QAAKC,OAAQ;;;;;;;;;;;CAYf,MAAa,OAAO,cAAkC;EACpD,MAAM,QAAQ,KAAK,QAAQ,MAAM,SAAS;AAC1C,OAAK,QAAQ,KAAK,4B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,QAAQ,QAAQ;EACtB,QAAQ;EACT,CAAC;CAEJ,MAAM,MAAM,WAAW;CACvB,MAAM,OAAO,qBAAqB;EAChC,SAAS,QAAQ,WAAW,QAAQ;EACpC,QAAQ,UAAU,QAAQ,QAAQ,YAAY,GAAG;EACjD,QAAQ,MAAM,QAAQ;AACpB,OAAI,IAAI,MAAM,mBAAmB,KAAK,KAAK;IAAE,KAAK;IAAM,QAAQ;IAAM,CAAC,CAAC,CAAC;;EAE5E,CAAC;AAEF,QAAO,wBAAwB,KAAK,SAAS,MAAM;EACjD,SAAS;EACT,WAAW;EACZ,CAAC;;AAGJ,eAAsB,aACpB,SACA,oBAAoB,qCACpB,kBACA;AACA,cAAa,gBAAgB,IAAI;CAEjC,MAAM,UAAU,MAAM,cAAc,QAAQ;AAU5C,QAAO,IAAI,iBAAgC,SAAS,MATjC,oBAAoB,KACrC,mBACA;EACE,MAAM,QAAQ;EACd;EACA;EACD,CACF,CAEwD"}
@@ -31,11 +31,12 @@ interface ExecutionHostWorkerOptions<TExecutionAPI extends ReadonlyArray<string>
31
31
  /**
32
32
  * An array of method names that the worker exposes. These methods will be available on the Worker instance and can be called to execute tasks in the worker process.
33
33
  */
34
- executionMethods: TExecutionAPI;
34
+ executionMethods?: TExecutionAPI;
35
35
  }
36
36
  declare class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {
37
37
  #private;
38
38
  protected executionHostPath: string;
39
+ protected exposedMethods: string[];
39
40
  protected options: ExecutionHostWorkerOptions<TExecutionAPI>;
40
41
  /**
41
42
  * Creates a new instance of the ExecutionHostWorker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.
@@ -49,9 +50,10 @@ declare class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {
49
50
  * Create a new worker instance.
50
51
  *
51
52
  * @param executionHostPath - The path to the worker file.
53
+ * @param exposedMethods - An array of method names that the worker exposes.
52
54
  * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.
53
55
  */
54
- constructor(executionHostPath: string, options: ExecutionHostWorkerOptions<TExecutionAPI>);
56
+ constructor(executionHostPath: string, exposedMethods: string[], options: ExecutionHostWorkerOptions<TExecutionAPI>);
55
57
  /**
56
58
  * Ends the worker process and cleans up any resources associated with it. This method should be called when the worker is no longer needed, to ensure that it is properly terminated and does not continue to consume system resources. If the worker is already terminated or was never initialized, this method will throw an error.
57
59
  *
@@ -65,4 +67,4 @@ declare class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {
65
67
  }
66
68
  //#endregion
67
69
  export { ExecutionHostWorkerOptions as n, NodeOptions as r, ExecutionHostWorker as t };
68
- //# sourceMappingURL=execution-host-worker-BjXO7l3Q.d.cts.map
70
+ //# sourceMappingURL=execution-host-worker-D7LinO52.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-host-worker-D7LinO52.d.cts","names":[],"sources":["../src/helpers/execution-host-worker.ts"],"mappings":";;;;;;KAwDY,WAAA,GAAc,MAAA;AAAA,UAqDT,0BAAA,uBACO,aAAA;EAtDZ;;;;;EAuEV,OAAA;EAlByC;;;EAuBzC,cAAA;EAeS;;;EAVT,IAAA,GAAO,IAAA;EA3BP;;;EAgCA,IAAA;EALA;;;EAUA,OAAA,EAAS,aAAA;EAAA;;;EAKT,gBAAA,GAAmB,aAAA;AAAA;AAAA,cAGR,mBAAA,uBAA0C,aAAA;EAAA;YA2DzC,iBAAA;EAAA,UACA,cAAA;EAAA,UACA,OAAA,EAAS,0BAAA,CAA2B,aAAA;EAA3B;;;;;;;EAAA,OAnDD,IAAA,uBAA2B,aAAA,SAAA,CAC7C,iBAAA,UACA,OAAA,EAAS,0BAAA,CAA2B,aAAA,IAAc,OAAA,CAAA,aAAA,CAAA,aAAA;EAiD/B;;;;;;;cAFT,iBAAA,UACA,cAAA,YACA,OAAA,EAAS,0BAAA,CAA2B,aAAA;EAFpC;;;;;EAiaC,GAAA,CAAA,GAAO,UAAA,CAAW,MAAA;EAldN;;;EAgelB,KAAA,CAAA;AAAA"}
@@ -31,11 +31,12 @@ interface ExecutionHostWorkerOptions<TExecutionAPI extends ReadonlyArray<string>
31
31
  /**
32
32
  * An array of method names that the worker exposes. These methods will be available on the Worker instance and can be called to execute tasks in the worker process.
33
33
  */
34
- executionMethods: TExecutionAPI;
34
+ executionMethods?: TExecutionAPI;
35
35
  }
36
36
  declare class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {
37
37
  #private;
38
38
  protected executionHostPath: string;
39
+ protected exposedMethods: string[];
39
40
  protected options: ExecutionHostWorkerOptions<TExecutionAPI>;
40
41
  /**
41
42
  * Creates a new instance of the ExecutionHostWorker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.
@@ -49,9 +50,10 @@ declare class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {
49
50
  * Create a new worker instance.
50
51
  *
51
52
  * @param executionHostPath - The path to the worker file.
53
+ * @param exposedMethods - An array of method names that the worker exposes.
52
54
  * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.
53
55
  */
54
- constructor(executionHostPath: string, options: ExecutionHostWorkerOptions<TExecutionAPI>);
56
+ constructor(executionHostPath: string, exposedMethods: string[], options: ExecutionHostWorkerOptions<TExecutionAPI>);
55
57
  /**
56
58
  * Ends the worker process and cleans up any resources associated with it. This method should be called when the worker is no longer needed, to ensure that it is properly terminated and does not continue to consume system resources. If the worker is already terminated or was never initialized, this method will throw an error.
57
59
  *
@@ -65,4 +67,4 @@ declare class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {
65
67
  }
66
68
  //#endregion
67
69
  export { ExecutionHostWorkerOptions as n, NodeOptions as r, ExecutionHostWorker as t };
68
- //# sourceMappingURL=execution-host-worker-B8TS4clU.d.mts.map
70
+ //# sourceMappingURL=execution-host-worker-zpQqaW_W.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-host-worker-zpQqaW_W.d.mts","names":[],"sources":["../src/helpers/execution-host-worker.ts"],"mappings":";;;;;;KAwDY,WAAA,GAAc,MAAA;AAAA,UAqDT,0BAAA,uBACO,aAAA;EAtDZ;;;;;EAuEV,OAAA;EAlByC;;;EAuBzC,cAAA;EAeS;;;EAVT,IAAA,GAAO,IAAA;EA3BP;;;EAgCA,IAAA;EALA;;;EAUA,OAAA,EAAS,aAAA;EAAA;;;EAKT,gBAAA,GAAmB,aAAA;AAAA;AAAA,cAGR,mBAAA,uBAA0C,aAAA;EAAA;YA2DzC,iBAAA;EAAA,UACA,cAAA;EAAA,UACA,OAAA,EAAS,0BAAA,CAA2B,aAAA;EAA3B;;;;;;;EAAA,OAnDD,IAAA,uBAA2B,aAAA,SAAA,CAC7C,iBAAA,UACA,OAAA,EAAS,0BAAA,CAA2B,aAAA,IAAc,OAAA,CAAA,aAAA,CAAA,aAAA;EAiD/B;;;;;;;cAFT,iBAAA,UACA,cAAA,YACA,OAAA,EAAS,0BAAA,CAA2B,aAAA;EAFpC;;;;;EAiaC,GAAA,CAAA,GAAO,UAAA,CAAW,MAAA;EAldN;;;EAgelB,KAAA,CAAA;AAAA"}
@@ -3,11 +3,11 @@ const require_chunk = require('../chunk-C0xms8kb.cjs');
3
3
  const require_helpers_rpc = require('./rpc.cjs');
4
4
  let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
5
5
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
6
+ let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
6
7
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
7
8
  let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
8
9
  let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
9
10
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
10
- let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
11
11
  let defu = require("defu");
12
12
 
13
13
  //#region src/helpers/create-execution-host.ts
@@ -1,11 +1,11 @@
1
1
  import { createRpcClient } from "./rpc.mjs";
2
2
  import { consoleLogger } from "@powerlines/core/plugin-utils";
3
3
  import { uuid } from "@stryke/unique-id/uuid";
4
+ import { isFunction } from "@stryke/type-checks/is-function";
4
5
  import { isSetObject } from "@stryke/type-checks/is-set-object";
5
6
  import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
6
7
  import { resolvePluginConfig } from "@powerlines/core/lib/context-helpers";
7
8
  import { titleCase } from "@stryke/string-format/title-case";
8
- import { isFunction } from "@stryke/type-checks/is-function";
9
9
  import { defu } from "defu";
10
10
 
11
11
  //#region src/helpers/create-execution-host.ts
@@ -1,8 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('../chunk-C0xms8kb.cjs');
3
3
  let _powerlines_core_lib_config = require("@powerlines/core/lib/config");
4
+ let _stryke_convert_to_array = require("@stryke/convert/to-array");
4
5
  let _stryke_fs_resolve = require("@stryke/fs/resolve");
5
6
  let _stryke_path_append = require("@stryke/path/append");
7
+ let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
6
8
  let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
7
9
  let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
8
10
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
@@ -10,6 +12,7 @@ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-stri
10
12
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
11
13
  let date_fns_formatDuration = require("date-fns/formatDuration");
12
14
  let jest_worker = require("jest-worker");
15
+ let jiti = require("jiti");
13
16
  let node_stream = require("node:stream");
14
17
  let node_util = require("node:util");
15
18
 
@@ -69,7 +72,14 @@ var ExecutionHostWorker = class ExecutionHostWorker {
69
72
  const mode = await (0, _powerlines_core_lib_config.getDefaultMode)(options.context.cwd);
70
73
  const resolvedPath = await (0, _stryke_fs_resolve.resolve)(executionHostPath, { paths: [options.context.cwd, options.root ? (0, _stryke_path_append.appendPath)(options.root, options.context.cwd) : void 0].filter(Boolean) });
71
74
  if (!resolvedPath) throw new Error(`Could not resolve the provided Execution Host path: \`${executionHostPath}\`.`);
72
- return new ExecutionHostWorker(resolvedPath, {
75
+ let exposedMethods = (0, _stryke_convert_to_array.toArray)(options.executionMethods ?? []);
76
+ if (exposedMethods.length === 0) {
77
+ const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href);
78
+ const mod = await jiti$1.import(jiti$1.esmResolve(resolvedPath));
79
+ if ((0, _stryke_type_checks_is_function.isFunction)(mod)) exposedMethods.push(...exposedMethods, "default");
80
+ else if ((0, _stryke_type_checks_is_set_object.isSetObject)(mod)) exposedMethods = Object.keys(mod).filter((name) => (0, _stryke_type_checks_is_function.isFunction)(mod[name]));
81
+ }
82
+ return new ExecutionHostWorker(resolvedPath, exposedMethods, {
73
83
  mode,
74
84
  ...options
75
85
  });
@@ -78,12 +88,14 @@ var ExecutionHostWorker = class ExecutionHostWorker {
78
88
  * Create a new worker instance.
79
89
  *
80
90
  * @param executionHostPath - The path to the worker file.
91
+ * @param exposedMethods - An array of method names that the worker exposes.
81
92
  * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.
82
93
  */
83
- constructor(executionHostPath, options) {
94
+ constructor(executionHostPath, exposedMethods, options) {
84
95
  this.executionHostPath = executionHostPath;
96
+ this.exposedMethods = exposedMethods;
85
97
  this.options = options;
86
- const { timeout = 9e5, isolatedMemory = false, mode = "production", context, executionMethods } = this.options;
98
+ const { timeout = 9e5, isolatedMemory = false, mode = "production", context } = this.options;
87
99
  const logger = context.extendLogger({ category: "communication" });
88
100
  let restartPromise;
89
101
  let resolveRestartPromise;
@@ -211,7 +223,7 @@ var ExecutionHostWorker = class ExecutionHostWorker {
211
223
  }
212
224
  this.#worker = new jest_worker.Worker(executionHostPath, {
213
225
  maxRetries: 0,
214
- exposedMethods: executionMethods,
226
+ exposedMethods: this.exposedMethods,
215
227
  computeWorkerKey: (_, ...args) => {
216
228
  let executionId = "default";
217
229
  let configIndex = 0;
@@ -269,7 +281,7 @@ var ExecutionHostWorker = class ExecutionHostWorker {
269
281
  this.#worker.getStderr().pipe(process.stderr);
270
282
  };
271
283
  createWorker();
272
- for (const method of executionMethods) {
284
+ for (const method of this.exposedMethods) {
273
285
  if (method.startsWith("_")) continue;
274
286
  this[method] = timeout ? async (...args) => {
275
287
  activeTasks++;
@@ -1,2 +1,2 @@
1
- import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-BjXO7l3Q.cjs";
1
+ import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-D7LinO52.cjs";
2
2
  export { ExecutionHostWorker, ExecutionHostWorkerOptions, NodeOptions };
@@ -1,2 +1,2 @@
1
- import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-B8TS4clU.mjs";
1
+ import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-zpQqaW_W.mjs";
2
2
  export { ExecutionHostWorker, ExecutionHostWorkerOptions, NodeOptions };
@@ -1,6 +1,8 @@
1
1
  import { getDefaultMode } from "@powerlines/core/lib/config";
2
+ import { toArray } from "@stryke/convert/to-array";
2
3
  import { resolve } from "@stryke/fs/resolve";
3
4
  import { appendPath } from "@stryke/path/append";
5
+ import { isFunction } from "@stryke/type-checks/is-function";
4
6
  import { isNumber } from "@stryke/type-checks/is-number";
5
7
  import { isSet } from "@stryke/type-checks/is-set";
6
8
  import { isSetObject } from "@stryke/type-checks/is-set-object";
@@ -8,6 +10,7 @@ import { isSetString } from "@stryke/type-checks/is-set-string";
8
10
  import { isString } from "@stryke/type-checks/is-string";
9
11
  import { formatDuration } from "date-fns/formatDuration";
10
12
  import { Worker } from "jest-worker";
13
+ import { createJiti } from "jiti";
11
14
  import { Transform } from "node:stream";
12
15
  import { parseArgs } from "node:util";
13
16
 
@@ -67,7 +70,14 @@ var ExecutionHostWorker = class ExecutionHostWorker {
67
70
  const mode = await getDefaultMode(options.context.cwd);
68
71
  const resolvedPath = await resolve(executionHostPath, { paths: [options.context.cwd, options.root ? appendPath(options.root, options.context.cwd) : void 0].filter(Boolean) });
69
72
  if (!resolvedPath) throw new Error(`Could not resolve the provided Execution Host path: \`${executionHostPath}\`.`);
70
- return new ExecutionHostWorker(resolvedPath, {
73
+ let exposedMethods = toArray(options.executionMethods ?? []);
74
+ if (exposedMethods.length === 0) {
75
+ const jiti = createJiti(import.meta.url);
76
+ const mod = await jiti.import(jiti.esmResolve(resolvedPath));
77
+ if (isFunction(mod)) exposedMethods.push(...exposedMethods, "default");
78
+ else if (isSetObject(mod)) exposedMethods = Object.keys(mod).filter((name) => isFunction(mod[name]));
79
+ }
80
+ return new ExecutionHostWorker(resolvedPath, exposedMethods, {
71
81
  mode,
72
82
  ...options
73
83
  });
@@ -76,12 +86,14 @@ var ExecutionHostWorker = class ExecutionHostWorker {
76
86
  * Create a new worker instance.
77
87
  *
78
88
  * @param executionHostPath - The path to the worker file.
89
+ * @param exposedMethods - An array of method names that the worker exposes.
79
90
  * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.
80
91
  */
81
- constructor(executionHostPath, options) {
92
+ constructor(executionHostPath, exposedMethods, options) {
82
93
  this.executionHostPath = executionHostPath;
94
+ this.exposedMethods = exposedMethods;
83
95
  this.options = options;
84
- const { timeout = 9e5, isolatedMemory = false, mode = "production", context, executionMethods } = this.options;
96
+ const { timeout = 9e5, isolatedMemory = false, mode = "production", context } = this.options;
85
97
  const logger = context.extendLogger({ category: "communication" });
86
98
  let restartPromise;
87
99
  let resolveRestartPromise;
@@ -209,7 +221,7 @@ var ExecutionHostWorker = class ExecutionHostWorker {
209
221
  }
210
222
  this.#worker = new Worker(executionHostPath, {
211
223
  maxRetries: 0,
212
- exposedMethods: executionMethods,
224
+ exposedMethods: this.exposedMethods,
213
225
  computeWorkerKey: (_, ...args) => {
214
226
  let executionId = "default";
215
227
  let configIndex = 0;
@@ -267,7 +279,7 @@ var ExecutionHostWorker = class ExecutionHostWorker {
267
279
  this.#worker.getStderr().pipe(process.stderr);
268
280
  };
269
281
  createWorker();
270
- for (const method of executionMethods) {
282
+ for (const method of this.exposedMethods) {
271
283
  if (method.startsWith("_")) continue;
272
284
  this[method] = timeout ? async (...args) => {
273
285
  activeTasks++;
@@ -1 +1 @@
1
- {"version":3,"file":"execution-host-worker.mjs","names":["#worker","JestWorker"],"sources":["../../src/helpers/execution-host-worker.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Mode } from \"@powerlines/core\";\nimport { getDefaultMode } from \"@powerlines/core/lib/config\";\nimport { resolve } from \"@stryke/fs/resolve\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { formatDuration } from \"date-fns/formatDuration\";\nimport { Worker as JestWorker } from \"jest-worker\";\nimport type { ChildProcess } from \"node:child_process\";\nimport { Transform } from \"node:stream\";\nimport { parseArgs } from \"node:util\";\nimport { ExecutionHost, ExecutionHostParams } from \"../types/api\";\nimport { EngineContext } from \"../types/context\";\n\nconst RESTARTED = Symbol(\"powerlines-worker:restarted\");\n\n/**\n * The debug address is in the form of `[host:]port`. The host is optional.\n */\ninterface DebugAddress {\n host?: string;\n port: number;\n}\n\n/**\n * Formats the debug address into a string.\n */\nconst formatDebugAddress = ({ host, port }: DebugAddress): string => {\n return host ? `${host}:${port}` : `${port}`;\n};\n\nexport type NodeOptions = Record<string, string | boolean | undefined>;\n\n/**\n * Get's the debug address from the `NODE_OPTIONS` environment variable. If the\n * address is not found, it returns the default host (`undefined`) and port\n * (`9229`).\n *\n * @returns An object with the host and port of the debug address.\n */\nconst getParsedDebugAddress = (\n address: string | boolean | undefined\n): DebugAddress => {\n if (!address || !isString(address)) {\n return { host: undefined, port: 9229 };\n }\n\n // The address is in the form of `[host:]port`. Let's parse the address.\n if (address.includes(\":\")) {\n const [host, port] = address.split(\":\");\n if (!host || !port) {\n throw new Error(`Invalid debug address: ${address}`);\n }\n\n return { host, port: Number.parseInt(port, 10) };\n }\n\n return { host: undefined, port: Number.parseInt(address, 10) };\n};\n\ntype NodeInspectType = \"inspect\" | \"inspect-brk\" | undefined;\n\n/**\n * Get the debug type from the `NODE_OPTIONS` environment variable.\n */\nfunction getNodeDebugType(nodeOptions: NodeOptions): NodeInspectType {\n if (nodeOptions.inspect) {\n return \"inspect\";\n }\n if (nodeOptions[\"inspect-brk\"] || nodeOptions.inspect_brk) {\n return \"inspect-brk\";\n }\n\n return undefined;\n}\n\nconst cleanupWorkers = (worker: JestWorker) => {\n for (const curWorker of ((worker as any)._workerPool?._workers || []) as {\n _child?: ChildProcess;\n }[]) {\n curWorker._child?.kill(\"SIGINT\");\n }\n};\n\nexport interface ExecutionHostWorkerOptions<\n TExecutionAPI extends ReadonlyArray<string>\n> {\n // /**\n // * `-1` if not inspectable\n // */\n // debuggerPortOffset?: number;\n\n // /**\n // * Whether to enable source maps support in the worker, which can improve the quality of stack traces at the cost of increased memory usage and slower performance. Defaults to `false`.\n // */\n // enableSourceMaps?: boolean;\n\n /**\n * The maximum time in milliseconds a worker can run before being terminated.\n *\n * @defaultValue 900000 (15 minutes)\n */\n timeout?: number;\n\n /**\n * True if `--max-old-space-size` should not be forwarded to the worker.\n */\n isolatedMemory?: boolean;\n\n /**\n * The mode to run the worker in, which can affect how the worker is initialized and how it behaves. This is determined based on the resolved configuration of the engine, and can be used to optimize the worker for different environments (e.g., development, production, etc.).\n */\n mode?: Mode;\n\n /**\n * An optional root to resolve the execution host path from, which can be used to specify a custom root directory for the worker to use when resolving paths and loading configuration files. If this option is not provided, the worker will use the current working directory as the root directory by default.\n */\n root?: string;\n\n /**\n * The context of the {@link @powerlines/engine#Engine | Engine instance}, which can be used to access the engine's state and services within the worker.\n */\n context: EngineContext;\n\n /**\n * An array of method names that the worker exposes. These methods will be available on the Worker instance and can be called to execute tasks in the worker process.\n */\n executionMethods: TExecutionAPI;\n}\n\nexport class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {\n #worker: JestWorker | undefined;\n\n /**\n * Creates a new instance of the ExecutionHostWorker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.\n *\n * @param executionHostPath - The path to the Execution Host file.\n * @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.\n * @returns A promise that resolves to an instance of the ExecutionHostWorker class.\n */\n public static async from<TExecutionAPI extends ReadonlyArray<string>>(\n executionHostPath: string,\n options: ExecutionHostWorkerOptions<TExecutionAPI>\n ) {\n const mode = await getDefaultMode(options.context.cwd);\n\n const resolvedPath = await resolve(executionHostPath, {\n paths: [\n options.context.cwd,\n options.root ? appendPath(options.root, options.context.cwd) : undefined\n ].filter(Boolean) as string[]\n });\n if (!resolvedPath) {\n throw new Error(\n `Could not resolve the provided Execution Host path: \\`${executionHostPath}\\`.`\n );\n }\n\n return new ExecutionHostWorker<TExecutionAPI>(resolvedPath, {\n mode,\n ...options\n }) as unknown as ExecutionHost<TExecutionAPI>;\n }\n\n /**\n * Create a new worker instance.\n *\n * @param executionHostPath - The path to the worker file.\n * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.\n */\n public constructor(\n protected executionHostPath: string,\n protected options: ExecutionHostWorkerOptions<TExecutionAPI>\n ) {\n const {\n timeout = 900_000,\n isolatedMemory = false,\n mode = \"production\",\n context,\n executionMethods\n } = this.options;\n\n const logger = context.extendLogger({ category: \"communication\" });\n\n let restartPromise: Promise<typeof RESTARTED>;\n let resolveRestartPromise: (arg: typeof RESTARTED) => void;\n let activeTasks = 0;\n\n this.#worker = undefined;\n\n // ensure we end workers if they weren't before exit\n process.on(\"exit\", () => {\n this.close();\n });\n\n let nodeOptions = {} as {\n [longOption: string]: string | boolean | undefined;\n };\n\n const args: string[] = [...process.execArgv];\n if (process.env.NODE_OPTIONS) {\n let isInString = false;\n let willStartNewArg = true;\n\n const stringifiedNodeOptions = process.env.NODE_OPTIONS.split(\" \").filter(\n part =>\n ((part.startsWith('\"') && part.endsWith('\"')) ||\n (part.startsWith(\"'\") && part.endsWith(\"'\"))) &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString).length > 0 &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString)\n .every(p => p.startsWith(\"--\"))\n );\n args.push(\n ...stringifiedNodeOptions.map(part => part.replace(/^['\"]|['\"]$/g, \"\"))\n );\n\n const inputNodeModules = stringifiedNodeOptions.reduce((acc, part) => {\n return acc.replace(part, \"\").trim();\n }, process.env.NODE_OPTIONS);\n for (let i = 0; i < inputNodeModules.length; i++) {\n let char = inputNodeModules[i];\n if (char) {\n // Skip any escaped characters in strings.\n if (char === \"\\\\\" && isInString) {\n // Ensure we don't have an escape character at the end.\n if (inputNodeModules.length === i + 1) {\n throw new Error(\"Invalid escape character at the end.\");\n }\n\n // Skip the next character.\n char = inputNodeModules[++i];\n if (!char) {\n continue;\n }\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === \" \" && !isInString) {\n willStartNewArg = true;\n continue;\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString;\n continue;\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char);\n willStartNewArg = false;\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char;\n }\n }\n }\n\n if (isInString) {\n throw new Error(\"Unterminated string\");\n }\n }\n\n if (args.length > 0) {\n const { values, tokens } = parseArgs({\n args,\n strict: false,\n tokens: true\n });\n nodeOptions = values;\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan = null;\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (!token) continue;\n\n if (token.kind === \"option-terminator\") {\n break;\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === \"option\") {\n orphan = !isSet(token.value) ? token : null;\n continue;\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== \"positional\") {\n orphan = null;\n continue;\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue;\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (orphan.name in nodeOptions && isString(nodeOptions[orphan.name])) {\n nodeOptions[orphan.name] += ` ${token.value}`;\n } else {\n nodeOptions[orphan.name] = token.value;\n }\n }\n }\n\n const originalOptions = { ...nodeOptions };\n\n delete nodeOptions.inspect;\n delete nodeOptions[\"inspect-brk\"];\n delete nodeOptions.inspect_brk;\n\n if (mode === \"development\") {\n const nodeDebugType = getNodeDebugType(originalOptions);\n if (nodeDebugType) {\n const debuggerAddress = getParsedDebugAddress(\n originalOptions[nodeDebugType]\n );\n const address: DebugAddress = {\n host: debuggerAddress.host,\n // current process runs on `address.port`\n port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1\n };\n nodeOptions[nodeDebugType] = formatDebugAddress(address);\n }\n\n nodeOptions[\"enable-source-maps\"] = true;\n }\n\n if (isolatedMemory) {\n delete nodeOptions[\"max-old-space-size\"];\n delete nodeOptions.max_old_space_size;\n }\n\n const execArgv: string[] = [];\n const nodeOptionsParts: string[] = [];\n for (const [key, value] of Object.entries(nodeOptions)) {\n let formatted: string | null = null;\n if (value === true) {\n formatted = `--${key}`;\n } else if (value) {\n formatted = `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(\" \") && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`;\n }\n\n if (formatted === null) {\n continue;\n }\n\n if (\n [\n \"experimental-network-inspection\",\n \"experimental-storage-inspection\",\n \"experimental-worker-inspection\",\n \"experimental-inspector-network-resource\"\n ].includes(key)\n ) {\n execArgv.push(formatted);\n } else {\n nodeOptionsParts.push(formatted);\n }\n }\n\n const onHanging = () => {\n const worker = this.#worker;\n if (!worker) {\n return;\n }\n\n const resolve = resolveRestartPromise;\n // eslint-disable-next-line ts/no-use-before-define\n createWorker();\n\n logger.warn(\n `Sending SIGTERM signal to worker due to timeout${\n timeout ? ` of ${formatDuration({ seconds: timeout / 1000 })}` : \"\"\n }. Subsequent errors may be a result of the worker exiting.`\n );\n\n void worker.end().then(() => {\n resolve(RESTARTED);\n });\n };\n\n let hangingTimer: NodeJS.Timeout | false = false;\n\n const onActivity = () => {\n if (hangingTimer) {\n clearTimeout(hangingTimer);\n }\n\n hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout);\n };\n\n const createWorker = () => {\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n NODE_ENV: mode,\n NODE_OPTIONS: nodeOptionsParts.join(\" \"),\n POWERLINES_EXECUTION_HOST_WORKER: \"true\"\n };\n\n if (env.FORCE_COLOR === undefined) {\n // Mirror the enablement heuristic from picocolors (see https://github.com/vercel/next.js/blob/6a40da0345939fe4f7b1ae519b296a86dd103432/packages/next/src/lib/picocolors.ts#L21-L24).\n // Picocolors snapshots `process.env`/`stdout.isTTY` at module load time, so when the worker\n // process bootstraps with piped stdio its own check would disable colors. Re-evaluating the\n // same conditions here lets us opt the worker into color output only when the parent would\n // have seen colors, while still respecting explicit opt-outs like NO_COLOR.\n const supportsColors =\n !env.NO_COLOR &&\n !env.CI &&\n env.TERM !== \"dumb\" &&\n (process.stdout.isTTY || process.stderr?.isTTY);\n\n if (supportsColors) {\n env.FORCE_COLOR = \"1\";\n }\n }\n\n this.#worker = new JestWorker(executionHostPath, {\n maxRetries: 0,\n exposedMethods: executionMethods,\n computeWorkerKey: (_, ...args: Array<unknown>) => {\n let executionId = \"default\";\n let configIndex = 0;\n if (args.length > 0 && isSetObject(args[0])) {\n const arg = args[0] as ExecutionHostParams;\n if (isSetObject(arg.options)) {\n configIndex = arg.options.configIndex ?? 0;\n executionId = arg.options.executionId || \"default\";\n }\n }\n\n return `${executionId}-${configIndex}`;\n },\n forkOptions: {\n execArgv,\n env\n }\n });\n restartPromise = new Promise(resolve => {\n resolveRestartPromise = resolve;\n });\n\n for (const worker of ((this.#worker as any)._workerPool?._workers ||\n []) as {\n _child?: ChildProcess;\n }[]) {\n worker._child?.on(\"exit\", (code, signal) => {\n logger.debug(\n `Worker process exited with code ${code} and signal ${signal}`\n );\n\n if ((code || (signal && signal !== \"SIGINT\")) && this.#worker) {\n const error = new Error(\n `Execution Host Worker exited unexpectedly with code ${\n code\n } and signal ${signal}`\n );\n logger.error(error);\n\n throw error;\n }\n });\n\n worker._child?.on(\"error\", error => {\n logger.error({\n meta: { category: \"communication\" },\n message: `Worker process emitted an error: ${error.message}`,\n error\n });\n });\n\n // if a child process emits a particular message, we track that as activity\n // so the parent process can keep track of progress\n worker._child?.on(\"message\", data => {\n onActivity();\n\n if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) {\n if (data[0] === 0) {\n logger.trace(\n `Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`\n );\n } else {\n logger.debug(\n `Received error message from worker: ${JSON.stringify(\n data.slice(1),\n null,\n 2\n )}`\n );\n }\n }\n\n logger.trace(\n `Received message from worker: ${JSON.stringify(data, null, 2)}`\n );\n });\n }\n\n let aborted = false;\n const onActivityAbort = () => {\n if (!aborted) {\n aborted = true;\n }\n };\n\n // Listen to the worker's stdout and stderr, if there's any thing logged, abort the activity first\n const abortActivityStreamOnLog = new Transform({\n transform(_chunk, _encoding, callback) {\n onActivityAbort();\n callback();\n }\n });\n // Stop the activity if there's any output from the worker\n this.#worker.getStdout().pipe(abortActivityStreamOnLog);\n this.#worker.getStderr().pipe(abortActivityStreamOnLog);\n\n // Pipe the worker's stdout and stderr to the parent process\n this.#worker.getStdout().pipe(process.stdout);\n this.#worker.getStderr().pipe(process.stderr);\n };\n createWorker();\n\n for (const method of executionMethods) {\n if (method.startsWith(\"_\")) {\n continue;\n }\n\n (this as any)[method] = timeout\n ? async (...args: any[]) => {\n activeTasks++;\n try {\n let attempts = 0;\n for (;;) {\n onActivity();\n\n const result = await Promise.race([\n // eslint-disable-next-line ts/no-unsafe-call\n (this.#worker as any)[method](\n args.length > 0 && args[0] ? args[0] : {}\n ),\n restartPromise\n ]);\n if (result !== RESTARTED) {\n return result;\n }\n\n logger.warn(\n `Execution Host Worker was restarted while calling method \"${\n method\n }\" (attempt ${attempts++}). Retrying the call...`\n );\n }\n } finally {\n activeTasks--;\n onActivity();\n }\n }\n : // eslint-disable-next-line ts/no-unsafe-call\n (this.#worker as any)[method].bind(this.#worker);\n }\n }\n\n /**\n * Ends the worker process and cleans up any resources associated with it. This method should be called when the worker is no longer needed, to ensure that it is properly terminated and does not continue to consume system resources. If the worker is already terminated or was never initialized, this method will throw an error.\n *\n * @returns A promise that resolves when the worker has been successfully terminated.\n */\n public async end(): ReturnType<JestWorker[\"end\"]> {\n const worker = this.#worker;\n if (!worker) {\n throw new Error(\"Execution Host Worker is not initialized\");\n }\n\n cleanupWorkers(worker);\n this.#worker = undefined;\n return worker.end();\n }\n\n /**\n * Quietly end the worker if it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AM,2BAA2B,IAAI,UAAU,EAC7C,UAAU,QAAQ,WAAW,UAAU;AACrC,qBAAiB;AACjB,cAAU;MAEb,CAAC;AAEF,SAAKA,OAAQ,WAAW,CAAC,KAAK,yBAAyB;AACvD,SAAKA,OAAQ,WAAW,CAAC,KAAK,yBAAyB;AAGvD,SAAKA,OAAQ,WAAW,CAAC,KAAK,QAAQ,OAAO;AAC7C,SAAKA,OAAQ,WAAW,CAAC,KAAK,QAAQ,OAAO;;AAE/C,gBAAc;AAEd,OAAK,MAAM,UAAU,kBAAkB;AACrC,OAAI,OAAO,WAAW,IAAI,CACxB;AAGF,GAAC,KAAa,UAAU,UACpB,OAAO,GAAG,SAAgB;AACxB;AACA,QAAI;KACF,IAAI,WAAW;AACf,cAAS;AACP,kBAAY;MAEZ,MAAM,SAAS,MAAM,QAAQ,KAAK,CAE/B,MAAKA,OAAgB,QACpB,KAAK,SAAS,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE,CAC1C,EACD,eACD,CAAC;AACF,UAAI,WAAW,UACb,QAAO;AAGT,aAAO,KACL,6DACE,OACD,aAAa,WAAW,yBAC1B;;cAEK;AACR;AACA,iBAAY;;OAIf,MAAKA,OAAgB,QAAQ,KAAK,MAAKA,OAAQ;;;;;;;;CASxD,MAAa,MAAqC;EAChD,MAAM,SAAS,MAAKA;AACpB,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,2CAA2C;AAG7D,iBAAe,OAAO;AACtB,QAAKA,SAAU;AACf,SAAO,OAAO,KAAK;;;;;CAMrB,AAAO,QAAc;AACnB,MAAI,MAAKA,QAAS;AAChB,kBAAe,MAAKA,OAAQ;AAC5B,GAAK,MAAKA,OAAQ,KAAK"}
1
+ {"version":3,"file":"execution-host-worker.mjs","names":["#worker","JestWorker"],"sources":["../../src/helpers/execution-host-worker.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Mode } from \"@powerlines/core\";\nimport { getDefaultMode } from \"@powerlines/core/lib/config\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { resolve } from \"@stryke/fs/resolve\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport { formatDuration } from \"date-fns/formatDuration\";\nimport { Worker as JestWorker } from \"jest-worker\";\nimport { createJiti } from \"jiti\";\nimport type { ChildProcess } from \"node:child_process\";\nimport { Transform } from \"node:stream\";\nimport { parseArgs } from \"node:util\";\nimport { ExecutionHost, ExecutionHostParams } from \"../types/api\";\nimport { EngineContext } from \"../types/context\";\n\nconst RESTARTED = Symbol(\"powerlines-worker:restarted\");\n\n/**\n * The debug address is in the form of `[host:]port`. The host is optional.\n */\ninterface DebugAddress {\n host?: string;\n port: number;\n}\n\n/**\n * Formats the debug address into a string.\n */\nconst formatDebugAddress = ({ host, port }: DebugAddress): string => {\n return host ? `${host}:${port}` : `${port}`;\n};\n\nexport type NodeOptions = Record<string, string | boolean | undefined>;\n\n/**\n * Get's the debug address from the `NODE_OPTIONS` environment variable. If the\n * address is not found, it returns the default host (`undefined`) and port\n * (`9229`).\n *\n * @returns An object with the host and port of the debug address.\n */\nconst getParsedDebugAddress = (\n address: string | boolean | undefined\n): DebugAddress => {\n if (!address || !isString(address)) {\n return { host: undefined, port: 9229 };\n }\n\n // The address is in the form of `[host:]port`. Let's parse the address.\n if (address.includes(\":\")) {\n const [host, port] = address.split(\":\");\n if (!host || !port) {\n throw new Error(`Invalid debug address: ${address}`);\n }\n\n return { host, port: Number.parseInt(port, 10) };\n }\n\n return { host: undefined, port: Number.parseInt(address, 10) };\n};\n\ntype NodeInspectType = \"inspect\" | \"inspect-brk\" | undefined;\n\n/**\n * Get the debug type from the `NODE_OPTIONS` environment variable.\n */\nfunction getNodeDebugType(nodeOptions: NodeOptions): NodeInspectType {\n if (nodeOptions.inspect) {\n return \"inspect\";\n }\n if (nodeOptions[\"inspect-brk\"] || nodeOptions.inspect_brk) {\n return \"inspect-brk\";\n }\n\n return undefined;\n}\n\nconst cleanupWorkers = (worker: JestWorker) => {\n for (const curWorker of ((worker as any)._workerPool?._workers || []) as {\n _child?: ChildProcess;\n }[]) {\n curWorker._child?.kill(\"SIGINT\");\n }\n};\n\nexport interface ExecutionHostWorkerOptions<\n TExecutionAPI extends ReadonlyArray<string>\n> {\n // /**\n // * `-1` if not inspectable\n // */\n // debuggerPortOffset?: number;\n\n // /**\n // * Whether to enable source maps support in the worker, which can improve the quality of stack traces at the cost of increased memory usage and slower performance. Defaults to `false`.\n // */\n // enableSourceMaps?: boolean;\n\n /**\n * The maximum time in milliseconds a worker can run before being terminated.\n *\n * @defaultValue 900000 (15 minutes)\n */\n timeout?: number;\n\n /**\n * True if `--max-old-space-size` should not be forwarded to the worker.\n */\n isolatedMemory?: boolean;\n\n /**\n * The mode to run the worker in, which can affect how the worker is initialized and how it behaves. This is determined based on the resolved configuration of the engine, and can be used to optimize the worker for different environments (e.g., development, production, etc.).\n */\n mode?: Mode;\n\n /**\n * An optional root to resolve the execution host path from, which can be used to specify a custom root directory for the worker to use when resolving paths and loading configuration files. If this option is not provided, the worker will use the current working directory as the root directory by default.\n */\n root?: string;\n\n /**\n * The context of the {@link @powerlines/engine#Engine | Engine instance}, which can be used to access the engine's state and services within the worker.\n */\n context: EngineContext;\n\n /**\n * An array of method names that the worker exposes. These methods will be available on the Worker instance and can be called to execute tasks in the worker process.\n */\n executionMethods?: TExecutionAPI;\n}\n\nexport class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {\n #worker: JestWorker | undefined;\n\n /**\n * Creates a new instance of the ExecutionHostWorker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.\n *\n * @param executionHostPath - The path to the Execution Host file.\n * @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.\n * @returns A promise that resolves to an instance of the ExecutionHostWorker class.\n */\n public static async from<TExecutionAPI extends ReadonlyArray<string>>(\n executionHostPath: string,\n options: ExecutionHostWorkerOptions<TExecutionAPI>\n ) {\n const mode = await getDefaultMode(options.context.cwd);\n\n const resolvedPath = await resolve(executionHostPath, {\n paths: [\n options.context.cwd,\n options.root ? appendPath(options.root, options.context.cwd) : undefined\n ].filter(Boolean) as string[]\n });\n if (!resolvedPath) {\n throw new Error(\n `Could not resolve the provided Execution Host path: \\`${executionHostPath}\\`.`\n );\n }\n\n let exposedMethods = toArray((options.executionMethods ?? []) as string[]);\n if (exposedMethods.length === 0) {\n const jiti = createJiti(import.meta.url);\n const mod: Record<string, AnyFunction> = await jiti.import(\n jiti.esmResolve(resolvedPath)\n );\n if (isFunction(mod)) {\n exposedMethods.push(...exposedMethods, \"default\");\n } else if (isSetObject(mod)) {\n exposedMethods = Object.keys(mod).filter(name => isFunction(mod[name]));\n }\n }\n\n return new ExecutionHostWorker<TExecutionAPI>(\n resolvedPath,\n exposedMethods,\n {\n mode,\n ...options\n }\n ) as unknown as ExecutionHost<TExecutionAPI>;\n }\n\n /**\n * Create a new worker instance.\n *\n * @param executionHostPath - The path to the worker file.\n * @param exposedMethods - An array of method names that the worker exposes.\n * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.\n */\n public constructor(\n protected executionHostPath: string,\n protected exposedMethods: string[],\n protected options: ExecutionHostWorkerOptions<TExecutionAPI>\n ) {\n const {\n timeout = 900_000,\n isolatedMemory = false,\n mode = \"production\",\n context\n } = this.options;\n\n const logger = context.extendLogger({ category: \"communication\" });\n\n let restartPromise: Promise<typeof RESTARTED>;\n let resolveRestartPromise: (arg: typeof RESTARTED) => void;\n let activeTasks = 0;\n\n this.#worker = undefined;\n\n // ensure we end workers if they weren't before exit\n process.on(\"exit\", () => {\n this.close();\n });\n\n let nodeOptions = {} as {\n [longOption: string]: string | boolean | undefined;\n };\n\n const args: string[] = [...process.execArgv];\n if (process.env.NODE_OPTIONS) {\n let isInString = false;\n let willStartNewArg = true;\n\n const stringifiedNodeOptions = process.env.NODE_OPTIONS.split(\" \").filter(\n part =>\n ((part.startsWith('\"') && part.endsWith('\"')) ||\n (part.startsWith(\"'\") && part.endsWith(\"'\"))) &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString).length > 0 &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString)\n .every(p => p.startsWith(\"--\"))\n );\n args.push(\n ...stringifiedNodeOptions.map(part => part.replace(/^['\"]|['\"]$/g, \"\"))\n );\n\n const inputNodeModules = stringifiedNodeOptions.reduce((acc, part) => {\n return acc.replace(part, \"\").trim();\n }, process.env.NODE_OPTIONS);\n for (let i = 0; i < inputNodeModules.length; i++) {\n let char = inputNodeModules[i];\n if (char) {\n // Skip any escaped characters in strings.\n if (char === \"\\\\\" && isInString) {\n // Ensure we don't have an escape character at the end.\n if (inputNodeModules.length === i + 1) {\n throw new Error(\"Invalid escape character at the end.\");\n }\n\n // Skip the next character.\n char = inputNodeModules[++i];\n if (!char) {\n continue;\n }\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === \" \" && !isInString) {\n willStartNewArg = true;\n continue;\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString;\n continue;\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char);\n willStartNewArg = false;\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char;\n }\n }\n }\n\n if (isInString) {\n throw new Error(\"Unterminated string\");\n }\n }\n\n if (args.length > 0) {\n const { values, tokens } = parseArgs({\n args,\n strict: false,\n tokens: true\n });\n nodeOptions = values;\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan = null;\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (!token) continue;\n\n if (token.kind === \"option-terminator\") {\n break;\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === \"option\") {\n orphan = !isSet(token.value) ? token : null;\n continue;\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== \"positional\") {\n orphan = null;\n continue;\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue;\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (orphan.name in nodeOptions && isString(nodeOptions[orphan.name])) {\n nodeOptions[orphan.name] += ` ${token.value}`;\n } else {\n nodeOptions[orphan.name] = token.value;\n }\n }\n }\n\n const originalOptions = { ...nodeOptions };\n\n delete nodeOptions.inspect;\n delete nodeOptions[\"inspect-brk\"];\n delete nodeOptions.inspect_brk;\n\n if (mode === \"development\") {\n const nodeDebugType = getNodeDebugType(originalOptions);\n if (nodeDebugType) {\n const debuggerAddress = getParsedDebugAddress(\n originalOptions[nodeDebugType]\n );\n const address: DebugAddress = {\n host: debuggerAddress.host,\n // current process runs on `address.port`\n port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1\n };\n nodeOptions[nodeDebugType] = formatDebugAddress(address);\n }\n\n nodeOptions[\"enable-source-maps\"] = true;\n }\n\n if (isolatedMemory) {\n delete nodeOptions[\"max-old-space-size\"];\n delete nodeOptions.max_old_space_size;\n }\n\n const execArgv: string[] = [];\n const nodeOptionsParts: string[] = [];\n for (const [key, value] of Object.entries(nodeOptions)) {\n let formatted: string | null = null;\n if (value === true) {\n formatted = `--${key}`;\n } else if (value) {\n formatted = `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(\" \") && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`;\n }\n\n if (formatted === null) {\n continue;\n }\n\n if (\n [\n \"experimental-network-inspection\",\n \"experimental-storage-inspection\",\n \"experimental-worker-inspection\",\n \"experimental-inspector-network-resource\"\n ].includes(key)\n ) {\n execArgv.push(formatted);\n } else {\n nodeOptionsParts.push(formatted);\n }\n }\n\n const onHanging = () => {\n const worker = this.#worker;\n if (!worker) {\n return;\n }\n\n const resolve = resolveRestartPromise;\n // eslint-disable-next-line ts/no-use-before-define\n createWorker();\n\n logger.warn(\n `Sending SIGTERM signal to worker due to timeout${\n timeout ? ` of ${formatDuration({ seconds: timeout / 1000 })}` : \"\"\n }. Subsequent errors may be a result of the worker exiting.`\n );\n\n void worker.end().then(() => {\n resolve(RESTARTED);\n });\n };\n\n let hangingTimer: NodeJS.Timeout | false = false;\n\n const onActivity = () => {\n if (hangingTimer) {\n clearTimeout(hangingTimer);\n }\n\n hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout);\n };\n\n const createWorker = () => {\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n NODE_ENV: mode,\n NODE_OPTIONS: nodeOptionsParts.join(\" \"),\n POWERLINES_EXECUTION_HOST_WORKER: \"true\"\n };\n\n if (env.FORCE_COLOR === undefined) {\n // Mirror the enablement heuristic from picocolors (see https://github.com/vercel/next.js/blob/6a40da0345939fe4f7b1ae519b296a86dd103432/packages/next/src/lib/picocolors.ts#L21-L24).\n // Picocolors snapshots `process.env`/`stdout.isTTY` at module load time, so when the worker\n // process bootstraps with piped stdio its own check would disable colors. Re-evaluating the\n // same conditions here lets us opt the worker into color output only when the parent would\n // have seen colors, while still respecting explicit opt-outs like NO_COLOR.\n const supportsColors =\n !env.NO_COLOR &&\n !env.CI &&\n env.TERM !== \"dumb\" &&\n (process.stdout.isTTY || process.stderr?.isTTY);\n\n if (supportsColors) {\n env.FORCE_COLOR = \"1\";\n }\n }\n\n this.#worker = new JestWorker(executionHostPath, {\n maxRetries: 0,\n exposedMethods: this.exposedMethods,\n computeWorkerKey: (_, ...args: Array<unknown>) => {\n let executionId = \"default\";\n let configIndex = 0;\n if (args.length > 0 && isSetObject(args[0])) {\n const arg = args[0] as ExecutionHostParams;\n if (isSetObject(arg.options)) {\n configIndex = arg.options.configIndex ?? 0;\n executionId = arg.options.executionId || \"default\";\n }\n }\n\n return `${executionId}-${configIndex}`;\n },\n forkOptions: {\n execArgv,\n env\n }\n });\n\n restartPromise = new Promise(resolve => {\n resolveRestartPromise = resolve;\n });\n\n for (const worker of ((this.#worker as any)._workerPool?._workers ||\n []) as {\n _child?: ChildProcess;\n }[]) {\n worker._child?.on(\"exit\", (code, signal) => {\n logger.debug(\n `Worker process exited with code ${code} and signal ${signal}`\n );\n\n if ((code || (signal && signal !== \"SIGINT\")) && this.#worker) {\n const error = new Error(\n `Execution Host Worker exited unexpectedly with code ${\n code\n } and signal ${signal}`\n );\n logger.error(error);\n\n throw error;\n }\n });\n\n worker._child?.on(\"error\", error => {\n logger.error({\n meta: { category: \"communication\" },\n message: `Worker process emitted an error: ${error.message}`,\n error\n });\n });\n\n // if a child process emits a particular message, we track that as activity\n // so the parent process can keep track of progress\n worker._child?.on(\"message\", data => {\n onActivity();\n\n if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) {\n if (data[0] === 0) {\n logger.trace(\n `Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`\n );\n } else {\n logger.debug(\n `Received error message from worker: ${JSON.stringify(\n data.slice(1),\n null,\n 2\n )}`\n );\n }\n }\n\n logger.trace(\n `Received message from worker: ${JSON.stringify(data, null, 2)}`\n );\n });\n }\n\n let aborted = false;\n const onActivityAbort = () => {\n if (!aborted) {\n aborted = true;\n }\n };\n\n // Listen to the worker's stdout and stderr, if there's any thing logged, abort the activity first\n const abortActivityStreamOnLog = new Transform({\n transform(_chunk, _encoding, callback) {\n onActivityAbort();\n callback();\n }\n });\n // Stop the activity if there's any output from the worker\n this.#worker.getStdout().pipe(abortActivityStreamOnLog);\n this.#worker.getStderr().pipe(abortActivityStreamOnLog);\n\n // Pipe the worker's stdout and stderr to the parent process\n this.#worker.getStdout().pipe(process.stdout);\n this.#worker.getStderr().pipe(process.stderr);\n };\n createWorker();\n\n for (const method of this.exposedMethods) {\n if (method.startsWith(\"_\")) {\n continue;\n }\n\n (this as any)[method] = timeout\n ? async (...args: any[]) => {\n activeTasks++;\n try {\n let attempts = 0;\n for (;;) {\n onActivity();\n\n const result = await Promise.race([\n // eslint-disable-next-line ts/no-unsafe-call\n (this.#worker as any)[method](\n args.length > 0 && args[0] ? args[0] : {}\n ),\n restartPromise\n ]);\n if (result !== RESTARTED) {\n return result;\n }\n\n logger.warn(\n `Execution Host Worker was restarted while calling method \"${\n method\n }\" (attempt ${attempts++}). Retrying the call...`\n );\n }\n } finally {\n activeTasks--;\n onActivity();\n }\n }\n : // eslint-disable-next-line ts/no-unsafe-call\n (this.#worker as any)[method].bind(this.#worker);\n }\n }\n\n /**\n * Ends the worker process and cleans up any resources associated with it. This method should be called when the worker is no longer needed, to ensure that it is properly terminated and does not continue to consume system resources. If the worker is already terminated or was never initialized, this method will throw an error.\n *\n * @returns A promise that resolves when the worker has been successfully terminated.\n */\n public async end(): ReturnType<JestWorker[\"end\"]> {\n const worker = this.#worker;\n if (!worker) {\n throw new Error(\"Execution Host Worker is not initialized\");\n }\n\n cleanupWorkers(worker);\n this.#worker = undefined;\n return worker.end();\n }\n\n /**\n * Quietly end the worker if it exists\n */\n public close(): void {\n if (this.#worker) {\n cleanupWorkers(this.#worker);\n void this.#worker.end();\n }\n }\n}\n"],"mappings":";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;CAMrB,AAAO,QAAc;AACnB,MAAI,MAAKA,QAAS;AAChB,kBAAe,MAAKA,OAAQ;AAC5B,GAAK,MAAKA,OAAQ,KAAK"}
@@ -1,5 +1,5 @@
1
1
  import { t as createExecutionHost } from "../create-execution-host-DbOCE5bd.cjs";
2
- import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-BjXO7l3Q.cjs";
2
+ import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-D7LinO52.cjs";
3
3
  import { t as finalize } from "../finalize-CW0cO75l.cjs";
4
4
  import { t as createRpcClient } from "../rpc-BsFxzyAK.cjs";
5
5
  export { ExecutionHostWorker, ExecutionHostWorkerOptions, NodeOptions, createExecutionHost, createRpcClient, finalize };
@@ -1,5 +1,5 @@
1
1
  import { t as createExecutionHost } from "../create-execution-host-CdpuL_YG.mjs";
2
- import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-B8TS4clU.mjs";
2
+ import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "../execution-host-worker-zpQqaW_W.mjs";
3
3
  import { t as finalize } from "../finalize-DeSY1r74.mjs";
4
4
  import { t as createRpcClient } from "../rpc-xwbFMMNu.mjs";
5
5
  export { ExecutionHostWorker, ExecutionHostWorkerOptions, NodeOptions, createExecutionHost, createRpcClient, finalize };
package/dist/index.d.cts CHANGED
@@ -4,7 +4,7 @@ import { t as PowerlinesEngineContext } from "./engine-context-Dw8odBCo.cjs";
4
4
  import { a as PowerlinesExecutionHost, i as ExecutionInterface, n as ExecutionHost, o as Worker, r as ExecutionHostParams, t as Engine } from "./api-6w4hZL6n.cjs";
5
5
  import { PowerlinesEngine, createContext, createEngine } from "./engine.cjs";
6
6
  import { t as createExecutionHost } from "./create-execution-host-DbOCE5bd.cjs";
7
- import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "./execution-host-worker-BjXO7l3Q.cjs";
7
+ import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "./execution-host-worker-D7LinO52.cjs";
8
8
  import { t as finalize } from "./finalize-CW0cO75l.cjs";
9
9
  import { t as createRpcClient } from "./rpc-BsFxzyAK.cjs";
10
10
  export { Engine, EngineContext, EngineExecutionItem, EngineExecutionOptions, EngineOptions, EngineResolvedConfig, EngineSystemContext, ExecutionCommandScopeState, ExecutionHookScopeState, ExecutionHost, ExecutionHostParams, ExecutionHostWorker, ExecutionHostWorkerOptions, ExecutionInterface, ExecutionPluginScopeState, ExecutionScopeState, ExecutionScopeType, ExecutionState, ExtractRpcFunction, ExtractRpcFunctions, InputRpcFunction, InputRpcFunctions, LogPayload, NodeOptions, PowerlinesEngine, PowerlinesEngineContext, PowerlinesExecutionHost, RpcClient, RpcClientCall, RpcClientCallEvent, RpcClientCallOptional, RpcClientEvents, RpcClientFunctions, RpcClientHost, RpcClientOptions, RpcClientRemoteFunctions, RpcContext, RpcFunction, RpcFunctions, RpcPayloadEnvelop, RpcPayloadMetadata, RpcServerFunctions, Worker, WrapRpcFunction, WrapRpcFunctions, WrappedRpcFunction, WrappedRpcFunctions, createContext, createEngine, createExecutionHost, createRpcClient, finalize };
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import { t as PowerlinesEngineContext } from "./engine-context-DEotmVzB.mjs";
4
4
  import { a as PowerlinesExecutionHost, i as ExecutionInterface, n as ExecutionHost, o as Worker, r as ExecutionHostParams, t as Engine } from "./api-Cdw4v0W4.mjs";
5
5
  import { PowerlinesEngine, createContext, createEngine } from "./engine.mjs";
6
6
  import { t as createExecutionHost } from "./create-execution-host-CdpuL_YG.mjs";
7
- import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "./execution-host-worker-B8TS4clU.mjs";
7
+ import { n as ExecutionHostWorkerOptions, r as NodeOptions, t as ExecutionHostWorker } from "./execution-host-worker-zpQqaW_W.mjs";
8
8
  import { t as finalize } from "./finalize-DeSY1r74.mjs";
9
9
  import { t as createRpcClient } from "./rpc-xwbFMMNu.mjs";
10
10
  export { Engine, EngineContext, EngineExecutionItem, EngineExecutionOptions, EngineOptions, EngineResolvedConfig, EngineSystemContext, ExecutionCommandScopeState, ExecutionHookScopeState, ExecutionHost, ExecutionHostParams, ExecutionHostWorker, ExecutionHostWorkerOptions, ExecutionInterface, ExecutionPluginScopeState, ExecutionScopeState, ExecutionScopeType, ExecutionState, ExtractRpcFunction, ExtractRpcFunctions, InputRpcFunction, InputRpcFunctions, LogPayload, NodeOptions, PowerlinesEngine, PowerlinesEngineContext, PowerlinesExecutionHost, RpcClient, RpcClientCall, RpcClientCallEvent, RpcClientCallOptional, RpcClientEvents, RpcClientFunctions, RpcClientHost, RpcClientOptions, RpcClientRemoteFunctions, RpcContext, RpcFunction, RpcFunctions, RpcPayloadEnvelop, RpcPayloadMetadata, RpcServerFunctions, Worker, WrapRpcFunction, WrapRpcFunctions, WrappedRpcFunction, WrappedRpcFunctions, createContext, createEngine, createExecutionHost, createRpcClient, finalize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/engine",
3
- "version": "0.15.18",
3
+ "version": "0.15.19",
4
4
  "private": false,
5
5
  "description": "An internal package containing the core engine modules for Powerlines.",
6
6
  "homepage": "https://stormsoftware.com",
@@ -155,5 +155,5 @@
155
155
  "@types/node": "^25.8.0",
156
156
  "typescript": "^6.0.3"
157
157
  },
158
- "gitHead": "3a81361fe40ac713daf61003a349ec9fd7d97f0e"
158
+ "gitHead": "defec65066e27532bba43fc6c8ef65ccb74d5877"
159
159
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution-host-worker-B8TS4clU.d.mts","names":[],"sources":["../src/helpers/execution-host-worker.ts"],"mappings":";;;;;;KAoDY,WAAA,GAAc,MAAA;AAAA,UAqDT,0BAAA,uBACO,aAAA;EAtDZ;;;;;EAuEV,OAAA;EAlByC;;;EAuB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