@powerlines/engine 0.49.23 → 0.49.26
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-BLp7JcAB.d.mts.map +1 -1
- package/dist/{engine-DOd1eqhI.cjs → engine-CwATBJKZ.cjs} +3 -1
- package/dist/engine-DFKgU8-G.d.cts.map +1 -1
- package/dist/{engine-CSxGz1az.mjs → engine-DL7ZeYlx.mjs} +4 -2
- package/dist/engine-DL7ZeYlx.mjs.map +1 -0
- package/dist/engine.cjs +1 -1
- package/dist/engine.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -9
- package/dist/engine-CSxGz1az.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-BLp7JcAB.d.mts","names":[],"sources":["../src/_internal/execution-api-worker.ts","../src/engine.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"engine-BLp7JcAB.d.mts","names":[],"sources":["../src/_internal/execution-api-worker.ts","../src/engine.ts"],"mappings":";;;;;;;cAwCM,SAAA;AAAA,UA8DW,yBAAA;;AAhEgC;;;;EAgF/C,OAAA;EAhBe;;;EAqBf,cAAA;EALA;;;EAUA,IAAA,GAAO,IAAA;EAKP;;;EAAA,IAAA;EAKsB;AAGxB;;EAHE,OAAA,EAAS,aAAa;AAAA;AAAA,cAGX,kBAAA,YAA8B,2BAAA;EAAA;YAsE7B,gBAAA;EAAA,UACA,OAAA,EAAS,yBAAA;EAAA,cAxDP,cAAA,CAAA,GAAc,OAAA,QAAA,SAAA;EAAA,UASlB,qBAAA,CAAA;EAuWC;;;;;;;EAAA,OAxVS,IAAA,CAClB,OAAA,UACA,OAAA,EAAS,yBAAA,GAAyB,OAAA,CAAA,kBAAA;EAzCgC;;;;;;EAAA,UAqE3D,WAAA,CACG,gBAAA,UACA,OAAA,EAAS,yBAAA;EAsTR,OAAA,CACX,OAAA,UACA,OAAA,E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AAA,UAAiB,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBA8B/C,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,CACpB,OAAA,EAAS,aAAA,EACT,OAAA,YAAkC,OAAA,CAAA,gBAAA"}
|
|
@@ -12,6 +12,7 @@ let h3 = require("h3");
|
|
|
12
12
|
let sirv = require("sirv");
|
|
13
13
|
sirv = require_chunk.__toESM(sirv, 1);
|
|
14
14
|
let _powerlines_core_lib_config = require("@powerlines/core/lib/config");
|
|
15
|
+
let _stryke_env_environment_checks = require("@stryke/env/environment-checks");
|
|
15
16
|
let _stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
16
17
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
17
18
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
@@ -177,7 +178,7 @@ var ExecutionApiWorker = class ExecutionApiWorker {
|
|
|
177
178
|
delete nodeOptions.inspect;
|
|
178
179
|
delete nodeOptions["inspect-brk"];
|
|
179
180
|
delete nodeOptions.inspect_brk;
|
|
180
|
-
if (
|
|
181
|
+
if (_stryke_env_environment_checks.isDebug) {
|
|
181
182
|
const nodeDebugType = getNodeDebugType(originalOptions);
|
|
182
183
|
if (nodeDebugType) {
|
|
183
184
|
const debuggerAddress = getParsedDebugAddress(originalOptions[nodeDebugType]);
|
|
@@ -186,6 +187,7 @@ var ExecutionApiWorker = class ExecutionApiWorker {
|
|
|
186
187
|
port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1
|
|
187
188
|
};
|
|
188
189
|
nodeOptions[nodeDebugType] = formatDebugAddress(address);
|
|
190
|
+
this.#logger.info(`Node.js debugger listening on ${nodeOptions[nodeDebugType]}`);
|
|
189
191
|
}
|
|
190
192
|
nodeOptions["enable-source-maps"] = true;
|
|
191
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-DFKgU8-G.d.cts","names":[],"sources":["../src/_internal/execution-api-worker.ts","../src/engine.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"engine-DFKgU8-G.d.cts","names":[],"sources":["../src/_internal/execution-api-worker.ts","../src/engine.ts"],"mappings":";;;;;;;cAwCM,SAAA;AAAA,UA8DW,yBAAA;;AAhEgC;;;;EAgF/C,OAAA;EAhBe;;;EAqBf,cAAA;EALA;;;EAUA,IAAA,GAAO,IAAA;EAKP;;;EAAA,IAAA;EAKsB;AAGxB;;EAHE,OAAA,EAAS,aAAa;AAAA;AAAA,cAGX,kBAAA,YAA8B,2BAAA;EAAA;YAsE7B,gBAAA;EAAA,UACA,OAAA,EAAS,yBAAA;EAAA,cAxDP,cAAA,CAAA,GAAc,OAAA,QAAA,SAAA;EAAA,UASlB,qBAAA,CAAA;EAuWC;;;;;;;EAAA,OAxVS,IAAA,CAClB,OAAA,UACA,OAAA,EAAS,yBAAA,GAAyB,OAAA,CAAA,kBAAA;EAzCgC;;;;;;EAAA,UAqE3D,WAAA,CACG,gBAAA,UACA,OAAA,EAAS,yBAAA;EAsTR,OAAA,CACX,OAAA,UACA,OAAA,EAAS,sBAAA,EACT,YAAA,EAAc,YAAA,GAAY,OAAA;EAjXA;;;EAoZf,QAAA,CAAA,GAAY,OAAA;EAAA,UAUf,SAAA,CAAA;EAAA,UAoBA,UAAA,CAAA;EAAA,UAUM,YAAA,CACd,OAAA,UACA,OAAA,EAAS,sBAAA,EACT,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;;;;;AArjBmB;;;cCQpC,gBAAA,YAA4B,MAAA,EAAQ,eAAA;EAAA;EDwDhC;;;EAAA,IC1CJ,OAAA,CAAA,GAAW,aAAA;ED0DtB;;;EAAA,ICnDW,GAAA,CAAA,GAAO,kBAAA;EDkElB;;;;AAKsB;AAGxB;;cC/DqB,OAAA,EAAS,aAAA,EAAe,GAAA,EAAK,kBAAA;EDsI3B;;;;;;;;;ECxHR,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EDod3B;;;;;;;;EClcZ,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EDqGtC;;;;;;;;ECnFC,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAmB,OAAA;EDsD3C;;;;;;;;;ECnCE,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EDyXvC;;;;;;ECzWE,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EDuZtC;;;;;;;;;ECpYG,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EDqapB;;;;AC7iB9B;;;;;EA2Je,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EA3HF;;;;;;EA2InC,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAtEf;;;;;;;;;EAyFpB,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EAAlB;;;;;;;;EAkBrB,QAAA,CAAA,GAAQ,OAAA;EAhNyC;;;EAAA,CA6NhD,MAAA,CAAO,YAAA,KAAa,OAAA;;;;;;;;;;;YAclB,OAAA,CAAQ,OAAA,UAAiB,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBA8B/C,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,CACpB,OAAA,EAAS,aAAA,EACT,OAAA,YAAkC,OAAA,CAAA,gBAAA"}
|
|
@@ -10,6 +10,7 @@ import { getPort } from "get-port-please";
|
|
|
10
10
|
import { createApp, fromNodeMiddleware } from "h3";
|
|
11
11
|
import sirv from "sirv";
|
|
12
12
|
import { getDefaultMode } from "@powerlines/core/lib/config";
|
|
13
|
+
import { isDebug } from "@stryke/env/environment-checks";
|
|
13
14
|
import { resolve } from "@stryke/fs/resolve";
|
|
14
15
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
15
16
|
import { isString } from "@stryke/type-checks/is-string";
|
|
@@ -174,7 +175,7 @@ var ExecutionApiWorker = class ExecutionApiWorker {
|
|
|
174
175
|
delete nodeOptions.inspect;
|
|
175
176
|
delete nodeOptions["inspect-brk"];
|
|
176
177
|
delete nodeOptions.inspect_brk;
|
|
177
|
-
if (
|
|
178
|
+
if (isDebug) {
|
|
178
179
|
const nodeDebugType = getNodeDebugType(originalOptions);
|
|
179
180
|
if (nodeDebugType) {
|
|
180
181
|
const debuggerAddress = getParsedDebugAddress(originalOptions[nodeDebugType]);
|
|
@@ -183,6 +184,7 @@ var ExecutionApiWorker = class ExecutionApiWorker {
|
|
|
183
184
|
port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1
|
|
184
185
|
};
|
|
185
186
|
nodeOptions[nodeDebugType] = formatDebugAddress(address);
|
|
187
|
+
this.#logger.info(`Node.js debugger listening on ${nodeOptions[nodeDebugType]}`);
|
|
186
188
|
}
|
|
187
189
|
nodeOptions["enable-source-maps"] = true;
|
|
188
190
|
}
|
|
@@ -560,4 +562,4 @@ async function createEngine(options, apiPath = "@powerlines/engine/api") {
|
|
|
560
562
|
|
|
561
563
|
//#endregion
|
|
562
564
|
export { createContext as n, createEngine as r, PowerlinesEngine as t };
|
|
563
|
-
//# sourceMappingURL=engine-
|
|
565
|
+
//# sourceMappingURL=engine-DL7ZeYlx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-DL7ZeYlx.mjs","names":["#restartPromise","#resolveRestartPromise","#logger","#worker","#createWorker","#activeTasks","#hangingTimer","#context","#api"],"sources":["../src/_internal/execution-api-worker.ts","../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 { InlineConfig, Logger, Mode } from \"@powerlines/core\";\nimport { getDefaultMode } from \"@powerlines/core/lib/config\";\nimport { isDebug } from \"@stryke/env/environment-checks\";\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 { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { formatDuration } from \"date-fns/formatDuration\";\nimport { pipeline } from \"node:stream\";\nimport { parseArgs } from \"node:util\";\nimport {\n MessageChannel,\n StructuredSerializeOptions\n} from \"node:worker_threads\";\nimport Tinypool from \"tinypool\";\nimport { MessagePortDuplex } from \"../helpers/stream\";\nimport { ExecutionApiWorkerInterface } from \"../types\";\nimport { EngineExecutionOptions } from \"../types/config\";\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\nexport interface ExecutionApiWorkerOptions {\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\nexport class ExecutionApiWorker implements ExecutionApiWorkerInterface {\n #worker: Tinypool | undefined;\n\n #logger: Logger;\n\n #activeTasks = 0;\n\n #restartPromise: Promise<typeof RESTARTED> | null = null;\n\n #resolveRestartPromise: ((arg: typeof RESTARTED) => void) | null = null;\n\n #hangingTimer: NodeJS.Timeout | false = false;\n\n #createWorker: () => void;\n\n protected get restartPromise() {\n if (!this.#restartPromise) {\n this.#restartPromise = new Promise(resolve => {\n this.#resolveRestartPromise = resolve;\n });\n }\n return this.#restartPromise;\n }\n\n protected resolveRestartPromise() {\n if (this.#resolveRestartPromise) {\n this.#resolveRestartPromise(RESTARTED);\n this.#restartPromise = null;\n this.#resolveRestartPromise = null;\n }\n }\n\n /**\n * Creates a new instance of the Execution API Worker 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 apiPath - The path to the Execution API 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 ExecutionApiWorker class.\n */\n public static async from(\n apiPath: string,\n options: ExecutionApiWorkerOptions\n ) {\n const mode = await getDefaultMode(options.context.cwd);\n\n const resolvedPath = await resolve(apiPath, {\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 API path: \\`${apiPath}\\`.`\n );\n }\n\n return new ExecutionApiWorker(resolvedPath, {\n mode,\n ...options\n });\n }\n\n /**\n * Create a new API worker instance.\n *\n * @param executionApiPath - The path to the worker file.\n * @param options - The options for the worker, including exposed commands, timeout, and hooks for activity and restart.\n */\n protected constructor(\n protected executionApiPath: string,\n protected options: ExecutionApiWorkerOptions\n ) {\n const {\n isolatedMemory = false,\n mode = \"production\",\n context\n } = this.options;\n\n this.options.timeout ??= 900_000;\n\n this.#logger = context.extendLogger({ category: \"communication\" });\n this.#worker = undefined;\n\n // ensure we end workers if they weren't before exit\n process.on(\"exit\", () => {\n void this.finalize();\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 (isDebug) {\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 this.#logger.info(\n `Node.js debugger listening on ${nodeOptions[nodeDebugType]}`\n );\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 // // Issue: https://github.com/nodejs/node/issues/59706\n // if (!nodeOptionsParts.includes(\"--no-experimental-strip-types\")) {\n // nodeOptionsParts.push(\"--no-experimental-strip-types\");\n // }\n\n this.#createWorker = () => {\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: mode,\n NODE_OPTIONS: nodeOptionsParts.join(\" \"),\n POWERLINES_EXECUTION_WORKER: \"true\"\n };\n\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 if (\n env.FORCE_COLOR === undefined &&\n !env.NO_COLOR &&\n !env.CI &&\n env.TERM !== \"dumb\" &&\n (process.stdout.isTTY || process.stderr?.isTTY)\n ) {\n env.FORCE_COLOR = \"1\";\n }\n\n this.#logger.debug(\n `Creating worker from file ${\n executionApiPath\n } with execution arguments: ${JSON.stringify(execArgv, null, 2)}`\n );\n\n this.#worker = new Tinypool({\n terminateTimeout: 5000,\n filename: executionApiPath,\n execArgv,\n env\n });\n\n this.#restartPromise = new Promise(resolve => {\n this.#resolveRestartPromise = resolve;\n });\n\n this.#worker.on(\"exit\", (code, signal) => {\n this.#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 this.#logger.error(error);\n\n void this.finalize().then(() => {\n throw error;\n });\n }\n });\n\n this.#worker.on(\"error\", error => {\n this.#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 this.#worker.on(\"message\", data => {\n this.onActivity();\n\n if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) {\n if (data[0] === 0) {\n this.#logger.trace(\n `Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`\n );\n } else {\n this.#logger.debug(\n `Received error message from worker: ${JSON.stringify(\n data.slice(1),\n null,\n 2\n )}`\n );\n }\n }\n\n this.#logger.trace(\n `Received message from worker: ${JSON.stringify(data, null, 2)}`\n );\n });\n };\n\n this.#createWorker();\n }\n\n public async execute(\n command: string,\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) {\n if (this.options.timeout) {\n this.#activeTasks++;\n try {\n let attempts = 0;\n for (;;) {\n this.onActivity();\n\n const result = await Promise.race([\n this.innerExecute(command, options, inlineConfig),\n this.#restartPromise\n ]);\n if (result !== RESTARTED) {\n return;\n }\n\n this.#logger.warn(\n `Execution Host Worker was restarted while calling method \"${\n command\n }\" (attempt ${attempts++}). Retrying the call...`\n );\n }\n } finally {\n this.#activeTasks--;\n this.onActivity();\n }\n } else {\n await this.innerExecute(command, options, inlineConfig);\n }\n }\n\n /**\n * Closes the worker process, terminating it if it's still running. This method should be called when the worker is no longer needed, to free up system resources and ensure a clean shutdown. If the worker has already been terminated, this method will have no effect.\n */\n public async finalize(): Promise<void> {\n const worker = this.#worker;\n if (!worker) {\n return;\n }\n\n await worker.destroy();\n this.#worker = undefined;\n }\n\n protected onHanging() {\n if (!this.#worker) {\n return;\n }\n\n this.#createWorker();\n\n this.#logger.warn(\n `Sending SIGTERM signal to worker due to timeout${\n this.options.timeout\n ? ` of ${formatDuration({ seconds: this.options.timeout / 1000 })}`\n : \"\"\n }. Subsequent errors may be a result of the worker exiting.`\n );\n\n void this.finalize().then(() => {\n this.#resolveRestartPromise?.(RESTARTED);\n });\n }\n\n protected onActivity() {\n if (this.#hangingTimer) {\n clearTimeout(this.#hangingTimer);\n }\n\n this.#hangingTimer =\n this.#activeTasks > 0 &&\n setTimeout(() => this.onHanging(), this.options.timeout);\n }\n\n protected async innerExecute(\n command: string,\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) {\n if (!this.#worker) {\n throw new Error(\"Execution Host Worker is not initialized\");\n }\n\n const { port1, port2 } = new MessageChannel();\n const promise = this.#worker.run(\n { command, options, inlineConfig, port: port2 },\n {\n transferList: [port2] as StructuredSerializeOptions\n }\n );\n\n let aborted = false;\n const onActivityAbort = () => {\n if (!aborted) {\n aborted = true;\n }\n };\n const duplex = new MessagePortDuplex(port1, { onActivityAbort });\n\n pipeline(duplex, process.stdout, (err: NodeJS.ErrnoException | null) => {\n if (err) {\n this.#logger.debug(\n `Received exception message from worker: ${JSON.stringify(\n err,\n null,\n 2\n )}`\n );\n\n throw err;\n }\n });\n\n await promise;\n }\n}\n","/* -------------------------------------------------------------------\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 { 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 { ExecutionApiWorker } from \"./_internal/execution-api-worker\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { Engine } 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 implements Engine, AsyncDisposable {\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 #api: ExecutionApiWorker;\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 api(): ExecutionApiWorker {\n return this.#api;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param api - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(context: EngineContext, api: ExecutionApiWorker) {\n this.#context = context;\n this.#api = api;\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.api.finalize();\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 command - 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(command: string, inlineConfig: InlineConfig) {\n await Promise.all(\n (await this.context.loadExecutions(command, inlineConfig)).map(\n async execution => {\n try {\n await this.api.execute(command, execution.options, inlineConfig);\n } catch (error) {\n this.context.error(\n `Execution of method \"${command}\" 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(\n options: EngineOptions,\n apiPath = \"@powerlines/engine/api\"\n) {\n EventEmitter.setMaxListeners(Infinity);\n\n const context = await createContext(options);\n const host = await ExecutionApiWorker.from(apiPath, {\n root: options.root,\n context\n });\n\n return new PowerlinesEngine(context, host);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,YAAY,OAAO,6BAA6B;;;;AAatD,MAAM,sBAAsB,EAAE,MAAM,WAAiC;CACnE,OAAO,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG;AACvC;;;;;;;;AAWA,MAAM,yBACJ,YACiB;CACjB,IAAI,CAAC,WAAW,CAAC,SAAS,OAAO,GAC/B,OAAO;EAAE,MAAM;EAAW,MAAM;CAAK;CAIvC,IAAI,QAAQ,SAAS,GAAG,GAAG;EACzB,MAAM,CAAC,MAAM,QAAQ,QAAQ,MAAM,GAAG;EACtC,IAAI,CAAC,QAAQ,CAAC,MACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS;EAGrD,OAAO;GAAE;GAAM,MAAM,OAAO,SAAS,MAAM,EAAE;EAAE;C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pC,QAAQ,UAAU,QAAQ,QAAQ,YAAY,GAAG;EACjD,QAAQ,MAAM,QAAQ;GACpB,IAAI,IAAI,MAAM,mBAAmB,KAAK,KAAK;IAAE,KAAK;IAAM,QAAQ;GAAK,CAAC,CAAC,CAAC;EAC1E;CACF,CAAC;CAED,OAAO,wBAAwB,KAAK,SAAS,MAAM;EACjD,SAAS;EACT,WAAW;CACb,CAAC;AACH;AAEA,eAAsB,aACpB,SACA,UAAU,0BACV;CACA,aAAa,gBAAgB,QAAQ;CAErC,MAAM,UAAU,MAAM,cAAc,OAAO;CAM3C,OAAO,IAAI,iBAAiB,SAAS,MALlB,mBAAmB,KAAK,SAAS;EAClD,MAAM,QAAQ;EACd;CACF,CAAC,CAEwC;AAC3C"}
|
package/dist/engine.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_engine = require('./engine-
|
|
2
|
+
const require_engine = require('./engine-CwATBJKZ.cjs');
|
|
3
3
|
|
|
4
4
|
exports.PowerlinesEngine = require_engine.PowerlinesEngine;
|
|
5
5
|
exports.createContext = require_engine.createContext;
|
package/dist/engine.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_engine = require('./engine-
|
|
2
|
+
const require_engine = require('./engine-CwATBJKZ.cjs');
|
|
3
3
|
const require_context_engine_context = require('./context/engine-context.cjs');
|
|
4
4
|
require('./context/index.cjs');
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createContext, r as createEngine, t as PowerlinesEngine } from "./engine-
|
|
1
|
+
import { n as createContext, r as createEngine, t as PowerlinesEngine } from "./engine-DL7ZeYlx.mjs";
|
|
2
2
|
import { PowerlinesEngineContext } from "./context/engine-context.mjs";
|
|
3
3
|
import "./context/index.mjs";
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/engine",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.26",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An internal package containing the core engine modules for Powerlines.",
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"import": "./dist/api/types.mjs",
|
|
78
78
|
"require": "./dist/api/types.cjs"
|
|
79
79
|
},
|
|
80
|
-
"./chunk-C_NdSu1c": "./dist/chunk-C_NdSu1c.cjs",
|
|
81
80
|
"./context": {
|
|
82
81
|
"import": "./dist/context/index.mjs",
|
|
83
82
|
"require": "./dist/context/index.cjs"
|
|
@@ -90,8 +89,6 @@
|
|
|
90
89
|
"import": "./dist/engine.mjs",
|
|
91
90
|
"require": "./dist/engine.cjs"
|
|
92
91
|
},
|
|
93
|
-
"./engine-CSxGz1az": "./dist/engine-CSxGz1az.mjs",
|
|
94
|
-
"./engine-DOd1eqhI": "./dist/engine-DOd1eqhI.cjs",
|
|
95
92
|
"./helpers": {
|
|
96
93
|
"import": "./dist/helpers/index.mjs",
|
|
97
94
|
"require": "./dist/helpers/index.cjs"
|
|
@@ -119,9 +116,9 @@
|
|
|
119
116
|
"types": "./dist/index.d.cts",
|
|
120
117
|
"files": ["dist"],
|
|
121
118
|
"dependencies": {
|
|
122
|
-
"@powerlines/core": "^0.48.
|
|
123
|
-
"@storm-software/config": "^1.137.
|
|
124
|
-
"@storm-software/config-tools": "^1.190.
|
|
119
|
+
"@powerlines/core": "^0.48.24",
|
|
120
|
+
"@storm-software/config": "^1.137.66",
|
|
121
|
+
"@storm-software/config-tools": "^1.190.34",
|
|
125
122
|
"@stryke/async": "^0.1.7",
|
|
126
123
|
"@stryke/convert": "^0.7.10",
|
|
127
124
|
"@stryke/env": "^0.20.96",
|
|
@@ -150,10 +147,10 @@
|
|
|
150
147
|
"unplugin": "^3.0.0"
|
|
151
148
|
},
|
|
152
149
|
"devDependencies": {
|
|
153
|
-
"@storm-software/testing-tools": "^1.119.
|
|
150
|
+
"@storm-software/testing-tools": "^1.119.187",
|
|
154
151
|
"@stryke/types": "^0.12.7",
|
|
155
152
|
"@types/node": "^25.9.1",
|
|
156
153
|
"typescript": "^6.0.3"
|
|
157
154
|
},
|
|
158
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "ba29330277e0d8be78bdad08d260ddae06a95e81"
|
|
159
156
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine-CSxGz1az.mjs","names":["#restartPromise","#resolveRestartPromise","#logger","#worker","#createWorker","#activeTasks","#hangingTimer","#context","#api"],"sources":["../src/_internal/execution-api-worker.ts","../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 { InlineConfig, Logger, 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 { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { formatDuration } from \"date-fns/formatDuration\";\nimport { pipeline } from \"node:stream\";\nimport { parseArgs } from \"node:util\";\nimport {\n MessageChannel,\n StructuredSerializeOptions\n} from \"node:worker_threads\";\nimport Tinypool from \"tinypool\";\nimport { MessagePortDuplex } from \"../helpers/stream\";\nimport { ExecutionApiWorkerInterface } from \"../types\";\nimport { EngineExecutionOptions } from \"../types/config\";\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\nexport interface ExecutionApiWorkerOptions {\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\nexport class ExecutionApiWorker implements ExecutionApiWorkerInterface {\n #worker: Tinypool | undefined;\n\n #logger: Logger;\n\n #activeTasks = 0;\n\n #restartPromise: Promise<typeof RESTARTED> | null = null;\n\n #resolveRestartPromise: ((arg: typeof RESTARTED) => void) | null = null;\n\n #hangingTimer: NodeJS.Timeout | false = false;\n\n #createWorker: () => void;\n\n protected get restartPromise() {\n if (!this.#restartPromise) {\n this.#restartPromise = new Promise(resolve => {\n this.#resolveRestartPromise = resolve;\n });\n }\n return this.#restartPromise;\n }\n\n protected resolveRestartPromise() {\n if (this.#resolveRestartPromise) {\n this.#resolveRestartPromise(RESTARTED);\n this.#restartPromise = null;\n this.#resolveRestartPromise = null;\n }\n }\n\n /**\n * Creates a new instance of the Execution API Worker 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 apiPath - The path to the Execution API 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 ExecutionApiWorker class.\n */\n public static async from(\n apiPath: string,\n options: ExecutionApiWorkerOptions\n ) {\n const mode = await getDefaultMode(options.context.cwd);\n\n const resolvedPath = await resolve(apiPath, {\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 API path: \\`${apiPath}\\`.`\n );\n }\n\n return new ExecutionApiWorker(resolvedPath, {\n mode,\n ...options\n });\n }\n\n /**\n * Create a new API worker instance.\n *\n * @param executionApiPath - The path to the worker file.\n * @param options - The options for the worker, including exposed commands, timeout, and hooks for activity and restart.\n */\n protected constructor(\n protected executionApiPath: string,\n protected options: ExecutionApiWorkerOptions\n ) {\n const {\n isolatedMemory = false,\n mode = \"production\",\n context\n } = this.options;\n\n this.options.timeout ??= 900_000;\n\n this.#logger = context.extendLogger({ category: \"communication\" });\n this.#worker = undefined;\n\n // ensure we end workers if they weren't before exit\n process.on(\"exit\", () => {\n void this.finalize();\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 // // Issue: https://github.com/nodejs/node/issues/59706\n // if (!nodeOptionsParts.includes(\"--no-experimental-strip-types\")) {\n // nodeOptionsParts.push(\"--no-experimental-strip-types\");\n // }\n\n this.#createWorker = () => {\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: mode,\n NODE_OPTIONS: nodeOptionsParts.join(\" \"),\n POWERLINES_EXECUTION_WORKER: \"true\"\n };\n\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 if (\n env.FORCE_COLOR === undefined &&\n !env.NO_COLOR &&\n !env.CI &&\n env.TERM !== \"dumb\" &&\n (process.stdout.isTTY || process.stderr?.isTTY)\n ) {\n env.FORCE_COLOR = \"1\";\n }\n\n this.#logger.debug(\n `Creating worker from file ${\n executionApiPath\n } with execution arguments: ${JSON.stringify(execArgv, null, 2)}`\n );\n\n this.#worker = new Tinypool({\n terminateTimeout: 5000,\n filename: executionApiPath,\n execArgv,\n env\n });\n\n this.#restartPromise = new Promise(resolve => {\n this.#resolveRestartPromise = resolve;\n });\n\n this.#worker.on(\"exit\", (code, signal) => {\n this.#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 this.#logger.error(error);\n\n void this.finalize().then(() => {\n throw error;\n });\n }\n });\n\n this.#worker.on(\"error\", error => {\n this.#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 this.#worker.on(\"message\", data => {\n this.onActivity();\n\n if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) {\n if (data[0] === 0) {\n this.#logger.trace(\n `Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`\n );\n } else {\n this.#logger.debug(\n `Received error message from worker: ${JSON.stringify(\n data.slice(1),\n null,\n 2\n )}`\n );\n }\n }\n\n this.#logger.trace(\n `Received message from worker: ${JSON.stringify(data, null, 2)}`\n );\n });\n };\n\n this.#createWorker();\n }\n\n public async execute(\n command: string,\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) {\n if (this.options.timeout) {\n this.#activeTasks++;\n try {\n let attempts = 0;\n for (;;) {\n this.onActivity();\n\n const result = await Promise.race([\n this.innerExecute(command, options, inlineConfig),\n this.#restartPromise\n ]);\n if (result !== RESTARTED) {\n return;\n }\n\n this.#logger.warn(\n `Execution Host Worker was restarted while calling method \"${\n command\n }\" (attempt ${attempts++}). Retrying the call...`\n );\n }\n } finally {\n this.#activeTasks--;\n this.onActivity();\n }\n } else {\n await this.innerExecute(command, options, inlineConfig);\n }\n }\n\n /**\n * Closes the worker process, terminating it if it's still running. This method should be called when the worker is no longer needed, to free up system resources and ensure a clean shutdown. If the worker has already been terminated, this method will have no effect.\n */\n public async finalize(): Promise<void> {\n const worker = this.#worker;\n if (!worker) {\n return;\n }\n\n await worker.destroy();\n this.#worker = undefined;\n }\n\n protected onHanging() {\n if (!this.#worker) {\n return;\n }\n\n this.#createWorker();\n\n this.#logger.warn(\n `Sending SIGTERM signal to worker due to timeout${\n this.options.timeout\n ? ` of ${formatDuration({ seconds: this.options.timeout / 1000 })}`\n : \"\"\n }. Subsequent errors may be a result of the worker exiting.`\n );\n\n void this.finalize().then(() => {\n this.#resolveRestartPromise?.(RESTARTED);\n });\n }\n\n protected onActivity() {\n if (this.#hangingTimer) {\n clearTimeout(this.#hangingTimer);\n }\n\n this.#hangingTimer =\n this.#activeTasks > 0 &&\n setTimeout(() => this.onHanging(), this.options.timeout);\n }\n\n protected async innerExecute(\n command: string,\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) {\n if (!this.#worker) {\n throw new Error(\"Execution Host Worker is not initialized\");\n }\n\n const { port1, port2 } = new MessageChannel();\n const promise = this.#worker.run(\n { command, options, inlineConfig, port: port2 },\n {\n transferList: [port2] as StructuredSerializeOptions\n }\n );\n\n let aborted = false;\n const onActivityAbort = () => {\n if (!aborted) {\n aborted = true;\n }\n };\n const duplex = new MessagePortDuplex(port1, { onActivityAbort });\n\n pipeline(duplex, process.stdout, (err: NodeJS.ErrnoException | null) => {\n if (err) {\n this.#logger.debug(\n `Received exception message from worker: ${JSON.stringify(\n err,\n null,\n 2\n )}`\n );\n\n throw err;\n }\n });\n\n await promise;\n }\n}\n","/* -------------------------------------------------------------------\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 { 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 { ExecutionApiWorker } from \"./_internal/execution-api-worker\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { Engine } 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 implements Engine, AsyncDisposable {\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 #api: ExecutionApiWorker;\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 api(): ExecutionApiWorker {\n return this.#api;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param api - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(context: EngineContext, api: ExecutionApiWorker) {\n this.#context = context;\n this.#api = api;\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.api.finalize();\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 command - 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(command: string, inlineConfig: InlineConfig) {\n await Promise.all(\n (await this.context.loadExecutions(command, inlineConfig)).map(\n async execution => {\n try {\n await this.api.execute(command, execution.options, inlineConfig);\n } catch (error) {\n this.context.error(\n `Execution of method \"${command}\" 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(\n options: EngineOptions,\n apiPath = \"@powerlines/engine/api\"\n) {\n EventEmitter.setMaxListeners(Infinity);\n\n const context = await createContext(options);\n const host = await ExecutionApiWorker.from(apiPath, {\n root: options.root,\n context\n });\n\n return new PowerlinesEngine(context, host);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,YAAY,OAAO,6BAA6B;;;;AAatD,MAAM,sBAAsB,EAAE,MAAM,WAAiC;CACnE,OAAO,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG;AACvC;;;;;;;;AAWA,MAAM,yBACJ,YACiB;CACjB,IAAI,CAAC,WAAW,CAAC,SAAS,OAAO,GAC/B,OAAO;EAAE,MAAM;EAAW,MAAM;CAAK;CAIvC,IAAI,QAAQ,SAAS,GAAG,GAAG;EACzB,MAAM,CAAC,MAAM,QAAQ,QAAQ,MAAM,GAAG;EACtC,IAAI,CAAC,QAAQ,CAAC,MACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS;EAGrD,OAAO;GAAE;GAAM,MAAM,OAAO,SAAS,MAAM,EAAE;EAAE;CACjD;CAEA,OAAO;EAAE,MAAM;EAAW,MAAM,OAAO,SAAS,SAAS,EAAE;CAAE;AAC/D;;;;AAOA,SAAS,iBAAiB,aAA2C;CACnE,IAAI,YAAY,SACd,OAAO;CAET,IAAI,YAAY,kBAAkB,YAAY,aAC5C,OAAO;AAIX;AAyCA,IAAa,qBAAb,MAAa,mBAA0D;CAsEzD;CACA;CAtEZ;CAEA;CAEA,eAAe;CAEf,kBAAoD;CAEpD,yBAAmE;CAEnE,gBAAwC;CAExC;CAEA,IAAc,iBAAiB;EAC7B,IAAI,CAAC,KAAKA,iBACR,KAAKA,kBAAkB,IAAI,SAAQ,YAAW;GAC5C,KAAKC,yBAAyB;EAChC,CAAC;EAEH,OAAO,KAAKD;CACd;CAEA,AAAU,wBAAwB;EAChC,IAAI,KAAKC,wBAAwB;GAC/B,KAAKA,uBAAuB,SAAS;GACrC,KAAKD,kBAAkB;GACvB,KAAKC,yBAAyB;EAChC;CACF;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