@powerlines/plugin-napi-rs 0.1.3 → 0.1.4

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.
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _stryke_path_append = require("@stryke/path/append");
4
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
5
+ let powerlines_plugin_utils = require("powerlines/plugin-utils");
6
+
7
+ //#region src/helpers/format-path.ts
8
+ /**
9
+ * Format the given path by replacing tokens and making it relative to the project root.
10
+ *
11
+ * @remarks
12
+ * This function is used to format paths in the plugin's configuration, such as the path to the crate or the output directory. It replaces tokens in the path (e.g. `{crate}`) with their corresponding values from the plugin context, and then makes the path relative to the project root.
13
+ *
14
+ * @param context - The plugin context, which contains the configuration and other information about the plugin's execution environment.
15
+ * @param path - The path to format or undefined, which may contain tokens to be replaced. This can be a path to a file or directory, and can include tokens such as `{crate}` that will be replaced with their corresponding values from the plugin context.
16
+ * @returns The formatted path, which has had tokens replaced and is relative to the project root. If the input path is undefined, this function will return undefined.
17
+ */
18
+ function formatPath(context, path) {
19
+ const cwd = (0, _stryke_path_append.appendPath)(context.config.root, context.config.cwd);
20
+ return path ? (0, _stryke_path_file_path_fns.relativePath)(cwd, (0, _stryke_path_append.appendPath)((0, _stryke_path_append.appendPath)((0, powerlines_plugin_utils.replacePathTokens)(context, path), context.config.root), context.config.cwd)) : void 0;
21
+ }
22
+
23
+ //#endregion
24
+ exports.formatPath = formatPath;
@@ -0,0 +1,16 @@
1
+ import { NapiPluginContext } from "../types/plugin.cjs";
2
+ //#region src/helpers/format-path.d.ts
3
+ /**
4
+ * Format the given path by replacing tokens and making it relative to the project root.
5
+ *
6
+ * @remarks
7
+ * This function is used to format paths in the plugin's configuration, such as the path to the crate or the output directory. It replaces tokens in the path (e.g. `{crate}`) with their corresponding values from the plugin context, and then makes the path relative to the project root.
8
+ *
9
+ * @param context - The plugin context, which contains the configuration and other information about the plugin's execution environment.
10
+ * @param path - The path to format or undefined, which may contain tokens to be replaced. This can be a path to a file or directory, and can include tokens such as `{crate}` that will be replaced with their corresponding values from the plugin context.
11
+ * @returns The formatted path, which has had tokens replaced and is relative to the project root. If the input path is undefined, this function will return undefined.
12
+ */
13
+ declare function formatPath(context: NapiPluginContext, path?: string): string | undefined;
14
+ //#endregion
15
+ export { formatPath };
16
+ //# sourceMappingURL=format-path.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-path.d.cts","names":[],"sources":["../../src/helpers/format-path.ts"],"mappings":";;;;;AAiCA;;;;;;;iBAAgB,UAAA,CACd,OAAA,EAAS,iBAAA,EACT,IAAA"}
@@ -0,0 +1,16 @@
1
+ import { NapiPluginContext } from "../types/plugin.mjs";
2
+ //#region src/helpers/format-path.d.ts
3
+ /**
4
+ * Format the given path by replacing tokens and making it relative to the project root.
5
+ *
6
+ * @remarks
7
+ * This function is used to format paths in the plugin's configuration, such as the path to the crate or the output directory. It replaces tokens in the path (e.g. `{crate}`) with their corresponding values from the plugin context, and then makes the path relative to the project root.
8
+ *
9
+ * @param context - The plugin context, which contains the configuration and other information about the plugin's execution environment.
10
+ * @param path - The path to format or undefined, which may contain tokens to be replaced. This can be a path to a file or directory, and can include tokens such as `{crate}` that will be replaced with their corresponding values from the plugin context.
11
+ * @returns The formatted path, which has had tokens replaced and is relative to the project root. If the input path is undefined, this function will return undefined.
12
+ */
13
+ declare function formatPath(context: NapiPluginContext, path?: string): string | undefined;
14
+ //#endregion
15
+ export { formatPath };
16
+ //# sourceMappingURL=format-path.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-path.d.mts","names":[],"sources":["../../src/helpers/format-path.ts"],"mappings":";;;;;AAiCA;;;;;;;iBAAgB,UAAA,CACd,OAAA,EAAS,iBAAA,EACT,IAAA"}
@@ -0,0 +1,23 @@
1
+ import { appendPath } from "@stryke/path/append";
2
+ import { relativePath } from "@stryke/path/file-path-fns";
3
+ import { replacePathTokens } from "powerlines/plugin-utils";
4
+
5
+ //#region src/helpers/format-path.ts
6
+ /**
7
+ * Format the given path by replacing tokens and making it relative to the project root.
8
+ *
9
+ * @remarks
10
+ * This function is used to format paths in the plugin's configuration, such as the path to the crate or the output directory. It replaces tokens in the path (e.g. `{crate}`) with their corresponding values from the plugin context, and then makes the path relative to the project root.
11
+ *
12
+ * @param context - The plugin context, which contains the configuration and other information about the plugin's execution environment.
13
+ * @param path - The path to format or undefined, which may contain tokens to be replaced. This can be a path to a file or directory, and can include tokens such as `{crate}` that will be replaced with their corresponding values from the plugin context.
14
+ * @returns The formatted path, which has had tokens replaced and is relative to the project root. If the input path is undefined, this function will return undefined.
15
+ */
16
+ function formatPath(context, path) {
17
+ const cwd = appendPath(context.config.root, context.config.cwd);
18
+ return path ? relativePath(cwd, appendPath(appendPath(replacePathTokens(context, path), context.config.root), context.config.cwd)) : void 0;
19
+ }
20
+
21
+ //#endregion
22
+ export { formatPath };
23
+ //# sourceMappingURL=format-path.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-path.mjs","names":[],"sources":["../../src/helpers/format-path.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 { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { replacePathTokens } from \"powerlines/plugin-utils\";\nimport { NapiPluginContext } from \"../types\";\n\n/**\n * Format the given path by replacing tokens and making it relative to the project root.\n *\n * @remarks\n * This function is used to format paths in the plugin's configuration, such as the path to the crate or the output directory. It replaces tokens in the path (e.g. `{crate}`) with their corresponding values from the plugin context, and then makes the path relative to the project root.\n *\n * @param context - The plugin context, which contains the configuration and other information about the plugin's execution environment.\n * @param path - The path to format or undefined, which may contain tokens to be replaced. This can be a path to a file or directory, and can include tokens such as `{crate}` that will be replaced with their corresponding values from the plugin context.\n * @returns The formatted path, which has had tokens replaced and is relative to the project root. If the input path is undefined, this function will return undefined.\n */\nexport function formatPath(\n context: NapiPluginContext,\n path?: string\n): string | undefined {\n const cwd = appendPath(context.config.root, context.config.cwd);\n\n return path\n ? relativePath(\n cwd,\n appendPath(\n appendPath(replacePathTokens(context, path), context.config.root),\n context.config.cwd\n )\n )\n : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAgB,WAAU,SAAA,MAAA;CACxB,MAAA,MAAS,WAAA,QAAiB,OAAA,MAAA,QAAA,OAAA,IAAA;AAC1B,QAAO,OAAA,aAAA,KAAA,WAAA,WAAA,kBAAA,SAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,OAAA,IAAA,CAAA,GAAA"}
package/dist/index.cjs CHANGED
@@ -1,12 +1,15 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_types_targets = require('./types/targets.cjs');
4
+ const require_helpers_format_path = require('./helpers/format-path.cjs');
5
+ const require_to_array = require('./node_modules/.pnpm/@stryke_convert@0.7.0/node_modules/@stryke/convert/dist/to-array.cjs');
6
+ let _stryke_path_append = require("@stryke/path/append");
7
+ let powerlines_plugin_utils = require("powerlines/plugin-utils");
3
8
  let _napi_rs_cli = require("@napi-rs/cli");
4
9
  let _powerlines_plugin_alloy = require("@powerlines/plugin-alloy");
5
10
  _powerlines_plugin_alloy = require_runtime.__toESM(_powerlines_plugin_alloy);
6
- let _stryke_path_append = require("@stryke/path/append");
7
- let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
8
11
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
9
- let powerlines_plugin_utils = require("powerlines/plugin-utils");
12
+ let defu = require("defu");
10
13
 
11
14
  //#region src/index.tsx
12
15
  /**
@@ -24,33 +27,60 @@ const plugin = (options = {}) => {
24
27
  outputDir: this.config.root,
25
28
  platform: true,
26
29
  strip: false,
27
- packageJsonPath: (0, _stryke_path_append.appendPath)(this.config.root, "package.json"),
28
30
  ...options
29
31
  } };
30
32
  },
31
- configResolved() {
32
- if (!this.config.napi.target && this.additionalArgs.target) this.config.napi.target = (0, _napi_rs_cli.parseTriple)(this.additionalArgs.target);
33
+ async configResolved() {
34
+ if (!this.config.napi.target && this.additionalArgs.target && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.target) || Array.isArray(this.additionalArgs.target) && this.additionalArgs.target.length > 0)) this.config.napi.target = (0, _napi_rs_cli.parseTriple)(Array.isArray(this.additionalArgs.target) && this.additionalArgs.target.length > 0 ? this.additionalArgs.target[0] : String(this.additionalArgs.target));
33
35
  else this.config.napi.target = (0, _stryke_type_checks_is_string.isString)(this.config.napi.target) ? (0, _napi_rs_cli.parseTriple)(this.config.napi.target) : this.config.napi.target;
34
- if (!this.config.napi.profile && this.additionalArgs.profile) this.config.napi.profile = this.additionalArgs.profile;
36
+ if (!this.config.napi.targets) if (this.additionalArgs.targets && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.targets) || Array.isArray(this.additionalArgs.targets) && this.additionalArgs.targets.length > 0)) this.config.napi.targets = require_to_array.toArray(this.additionalArgs.targets).map((target) => (0, _napi_rs_cli.parseTriple)(target));
37
+ else this.config.napi.targets = require_types_targets.DEFAULT_TARGETS.map((target) => (0, _napi_rs_cli.parseTriple)(target));
38
+ if (!this.config.napi.profile && this.additionalArgs.profile && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.profile) || Array.isArray(this.additionalArgs.profile) && this.additionalArgs.profile.length > 0)) this.config.napi.profile = Array.isArray(this.additionalArgs.profile) && this.additionalArgs.profile.length > 0 ? this.additionalArgs.profile[0] : String(this.additionalArgs.profile);
35
39
  if (!this.config.napi.release && this.additionalArgs.release) this.config.napi.release = Boolean(this.additionalArgs.release);
36
- if (!this.config.napi.configPath && this.additionalArgs.configPath) this.config.napi.configPath = this.additionalArgs.configPath;
37
- if (!this.config.napi.manifestPath && this.additionalArgs.manifestPath) this.config.napi.manifestPath = this.additionalArgs.manifestPath;
38
- if (!this.config.napi.packageJsonPath && this.additionalArgs.packageJsonPath) this.config.napi.packageJsonPath = this.additionalArgs.packageJsonPath;
40
+ if (!this.config.napi.configPath && this.additionalArgs.configPath && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.configPath) || Array.isArray(this.additionalArgs.configPath) && this.additionalArgs.configPath.length > 0)) this.config.napi.configPath = Array.isArray(this.additionalArgs.configPath) && this.additionalArgs.configPath.length > 0 ? this.additionalArgs.configPath[0] : String(this.additionalArgs.configPath);
41
+ if (!this.config.napi.manifestPath && this.additionalArgs.manifestPath && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.manifestPath) || Array.isArray(this.additionalArgs.manifestPath) && this.additionalArgs.manifestPath.length > 0)) this.config.napi.manifestPath = Array.isArray(this.additionalArgs.manifestPath) && this.additionalArgs.manifestPath.length > 0 ? this.additionalArgs.manifestPath[0] : String(this.additionalArgs.manifestPath);
42
+ if (!this.config.napi.npmDir && this.additionalArgs.npmDir && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.npmDir) || Array.isArray(this.additionalArgs.npmDir) && this.additionalArgs.npmDir.length > 0)) this.config.napi.npmDir = Array.isArray(this.additionalArgs.npmDir) && this.additionalArgs.npmDir.length > 0 ? this.additionalArgs.npmDir[0] : String(this.additionalArgs.npmDir);
43
+ if (!this.config.napi.packageJsonPath) {
44
+ if (this.additionalArgs.packageJsonPath && ((0, _stryke_type_checks_is_string.isString)(this.additionalArgs.packageJsonPath) || Array.isArray(this.additionalArgs.packageJsonPath) && this.additionalArgs.packageJsonPath.length > 0)) this.config.napi.packageJsonPath = Array.isArray(this.additionalArgs.packageJsonPath) && this.additionalArgs.packageJsonPath.length > 0 ? this.additionalArgs.packageJsonPath[0] : String(this.additionalArgs.packageJsonPath);
45
+ if (!this.config.napi.packageJsonPath) this.config.napi.packageJsonPath = (0, _stryke_path_append.appendPath)(this.config.root, "package.json");
46
+ }
39
47
  if (this.config.napi.target?.platform === "wasm") this.dependencies["@napi-rs/wasm-runtime"] = "^1.1.4";
48
+ let packageJson = {};
49
+ let originalPackageJson = {};
50
+ if (this.fs.existsSync(this.config.napi.packageJsonPath)) packageJson = JSON.parse(await this.fs.read(this.config.napi.packageJsonPath) || "{}");
51
+ originalPackageJson = { ...packageJson };
52
+ packageJson.napi = {
53
+ binaryName: this.config.napi.binaryName,
54
+ packageName: this.config.napi.packageName,
55
+ targets: this.config.napi.targets?.map((target) => target.triple),
56
+ npmClient: this.config.napi.npmClient,
57
+ constEnum: this.config.napi.constEnum,
58
+ dtsHeader: this.config.napi.dtsHeader,
59
+ dtsHeaderFile: this.config.napi.dtsHeaderFile,
60
+ ...packageJson.napi,
61
+ wasm: this.config.napi.target?.platform === "wasm" ? (0, defu.defu)(packageJson.napi?.wasm ?? {}, this.config.napi.wasm ?? {}, { initialMemory: 16384 }) : void 0
62
+ };
63
+ if (JSON.stringify(packageJson) !== JSON.stringify(originalPackageJson)) await this.fs.write(this.config.napi.packageJsonPath, JSON.stringify(packageJson, null, 2));
40
64
  },
41
65
  async prepare() {
42
66
  this.debug(`Preparing the N-API Rust runtime artifacts for the Powerlines project.`);
67
+ this.napi = new _napi_rs_cli.NapiCli();
68
+ if (this.config.napi.npmDir) await this.napi.createNpmDirs({
69
+ cwd: (0, _stryke_path_append.appendPath)(this.config.root, this.config.cwd),
70
+ npmDir: require_helpers_format_path.formatPath(this, this.config.napi.npmDir),
71
+ configPath: require_helpers_format_path.formatPath(this, this.config.napi.configPath),
72
+ packageJsonPath: require_helpers_format_path.formatPath(this, this.config.napi.packageJsonPath)
73
+ });
43
74
  },
44
75
  async build() {
45
- this.debug(`Preparing the N-API Rust runtime artifacts for the Powerlines project.`);
46
- const cwd = (0, _stryke_path_append.appendPath)(this.config.root, this.config.cwd);
47
- const { task } = await new _napi_rs_cli.NapiCli().build({
48
- cwd,
76
+ this.debug(`Building the N-API Rust runtime artifacts for the Powerlines project.`);
77
+ const { task } = await this.napi.build({
78
+ cwd: (0, _stryke_path_append.appendPath)(this.config.root, this.config.cwd),
49
79
  package: this.config.napi.packageName,
50
- outputDir: (0, _stryke_path_file_path_fns.relativePath)(cwd, (0, _stryke_path_append.appendPath)((0, _stryke_path_append.appendPath)(this.config.napi.outputDir, this.config.root), this.config.cwd)),
51
- configPath: this.config.napi.configPath ? (0, _stryke_path_file_path_fns.relativePath)(cwd, (0, _stryke_path_append.appendPath)((0, _stryke_path_append.appendPath)((0, powerlines_plugin_utils.replacePathTokens)(this, this.config.napi.configPath), this.config.root), this.config.cwd)) : void 0,
52
- manifestPath: this.config.napi.manifestPath ? (0, _stryke_path_file_path_fns.relativePath)(cwd, (0, _stryke_path_append.appendPath)((0, _stryke_path_append.appendPath)((0, powerlines_plugin_utils.replacePathTokens)(this, this.config.napi.manifestPath), this.config.root), this.config.cwd)) : void 0,
53
- packageJsonPath: this.config.napi.packageJsonPath ? (0, _stryke_path_file_path_fns.relativePath)(cwd, (0, _stryke_path_append.appendPath)((0, _stryke_path_append.appendPath)((0, powerlines_plugin_utils.replacePathTokens)(this, this.config.napi.packageJsonPath), this.config.root), this.config.cwd)) : void 0,
80
+ outputDir: require_helpers_format_path.formatPath(this, this.config.napi.outputDir),
81
+ configPath: require_helpers_format_path.formatPath(this, this.config.napi.configPath),
82
+ manifestPath: require_helpers_format_path.formatPath(this, this.config.napi.manifestPath),
83
+ packageJsonPath: require_helpers_format_path.formatPath(this, this.config.napi.packageJsonPath),
54
84
  target: this.config.napi.target?.triple,
55
85
  profile: this.config.napi.profile,
56
86
  release: this.config.napi.release ?? this.config.mode === "production",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;YA8BY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;;;;cASE,MAAA,oBAA2B,iBAAA,GAAoB,iBAAA,EAC1D,OAAA,GAAS,iBAAA,KA8IJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;YAiCY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;;;;cASE,MAAA,oBAA2B,iBAAA,GAAoB,iBAAA,EAC1D,OAAA,GAAS,iBAAA,KA8OJ,MAAA,CAAO,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;YA8BY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;;;;cASE,MAAA,oBAA2B,iBAAA,GAAoB,iBAAA,EAC1D,OAAA,GAAS,iBAAA,KA8IJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;YAiCY,MAAA;IACR,IAAA,GAAO,iBAAA;EAAA;AAAA;;;;;;cASE,MAAA,oBAA2B,iBAAA,GAAoB,iBAAA,EAC1D,OAAA,GAAS,iBAAA,KA8OJ,MAAA,CAAO,QAAA"}
package/dist/index.mjs CHANGED
@@ -1,9 +1,12 @@
1
+ import { DEFAULT_TARGETS } from "./types/targets.mjs";
2
+ import { formatPath } from "./helpers/format-path.mjs";
3
+ import { toArray } from "./node_modules/.pnpm/@stryke_convert@0.7.0/node_modules/@stryke/convert/dist/to-array.mjs";
4
+ import { appendPath } from "@stryke/path/append";
5
+ import { isVerbose } from "powerlines/plugin-utils";
1
6
  import { NapiCli, parseTriple } from "@napi-rs/cli";
2
7
  import alloy from "@powerlines/plugin-alloy";
3
- import { appendPath } from "@stryke/path/append";
4
- import { relativePath } from "@stryke/path/file-path-fns";
5
8
  import { isString } from "@stryke/type-checks/is-string";
6
- import { isVerbose, replacePathTokens } from "powerlines/plugin-utils";
9
+ import { defu } from "defu";
7
10
 
8
11
  //#region src/index.tsx
9
12
  /**
@@ -21,33 +24,60 @@ const plugin = (options = {}) => {
21
24
  outputDir: this.config.root,
22
25
  platform: true,
23
26
  strip: false,
24
- packageJsonPath: appendPath(this.config.root, "package.json"),
25
27
  ...options
26
28
  } };
27
29
  },
28
- configResolved() {
29
- if (!this.config.napi.target && this.additionalArgs.target) this.config.napi.target = parseTriple(this.additionalArgs.target);
30
+ async configResolved() {
31
+ if (!this.config.napi.target && this.additionalArgs.target && (isString(this.additionalArgs.target) || Array.isArray(this.additionalArgs.target) && this.additionalArgs.target.length > 0)) this.config.napi.target = parseTriple(Array.isArray(this.additionalArgs.target) && this.additionalArgs.target.length > 0 ? this.additionalArgs.target[0] : String(this.additionalArgs.target));
30
32
  else this.config.napi.target = isString(this.config.napi.target) ? parseTriple(this.config.napi.target) : this.config.napi.target;
31
- if (!this.config.napi.profile && this.additionalArgs.profile) this.config.napi.profile = this.additionalArgs.profile;
33
+ if (!this.config.napi.targets) if (this.additionalArgs.targets && (isString(this.additionalArgs.targets) || Array.isArray(this.additionalArgs.targets) && this.additionalArgs.targets.length > 0)) this.config.napi.targets = toArray(this.additionalArgs.targets).map((target) => parseTriple(target));
34
+ else this.config.napi.targets = DEFAULT_TARGETS.map((target) => parseTriple(target));
35
+ if (!this.config.napi.profile && this.additionalArgs.profile && (isString(this.additionalArgs.profile) || Array.isArray(this.additionalArgs.profile) && this.additionalArgs.profile.length > 0)) this.config.napi.profile = Array.isArray(this.additionalArgs.profile) && this.additionalArgs.profile.length > 0 ? this.additionalArgs.profile[0] : String(this.additionalArgs.profile);
32
36
  if (!this.config.napi.release && this.additionalArgs.release) this.config.napi.release = Boolean(this.additionalArgs.release);
33
- if (!this.config.napi.configPath && this.additionalArgs.configPath) this.config.napi.configPath = this.additionalArgs.configPath;
34
- if (!this.config.napi.manifestPath && this.additionalArgs.manifestPath) this.config.napi.manifestPath = this.additionalArgs.manifestPath;
35
- if (!this.config.napi.packageJsonPath && this.additionalArgs.packageJsonPath) this.config.napi.packageJsonPath = this.additionalArgs.packageJsonPath;
37
+ if (!this.config.napi.configPath && this.additionalArgs.configPath && (isString(this.additionalArgs.configPath) || Array.isArray(this.additionalArgs.configPath) && this.additionalArgs.configPath.length > 0)) this.config.napi.configPath = Array.isArray(this.additionalArgs.configPath) && this.additionalArgs.configPath.length > 0 ? this.additionalArgs.configPath[0] : String(this.additionalArgs.configPath);
38
+ if (!this.config.napi.manifestPath && this.additionalArgs.manifestPath && (isString(this.additionalArgs.manifestPath) || Array.isArray(this.additionalArgs.manifestPath) && this.additionalArgs.manifestPath.length > 0)) this.config.napi.manifestPath = Array.isArray(this.additionalArgs.manifestPath) && this.additionalArgs.manifestPath.length > 0 ? this.additionalArgs.manifestPath[0] : String(this.additionalArgs.manifestPath);
39
+ if (!this.config.napi.npmDir && this.additionalArgs.npmDir && (isString(this.additionalArgs.npmDir) || Array.isArray(this.additionalArgs.npmDir) && this.additionalArgs.npmDir.length > 0)) this.config.napi.npmDir = Array.isArray(this.additionalArgs.npmDir) && this.additionalArgs.npmDir.length > 0 ? this.additionalArgs.npmDir[0] : String(this.additionalArgs.npmDir);
40
+ if (!this.config.napi.packageJsonPath) {
41
+ if (this.additionalArgs.packageJsonPath && (isString(this.additionalArgs.packageJsonPath) || Array.isArray(this.additionalArgs.packageJsonPath) && this.additionalArgs.packageJsonPath.length > 0)) this.config.napi.packageJsonPath = Array.isArray(this.additionalArgs.packageJsonPath) && this.additionalArgs.packageJsonPath.length > 0 ? this.additionalArgs.packageJsonPath[0] : String(this.additionalArgs.packageJsonPath);
42
+ if (!this.config.napi.packageJsonPath) this.config.napi.packageJsonPath = appendPath(this.config.root, "package.json");
43
+ }
36
44
  if (this.config.napi.target?.platform === "wasm") this.dependencies["@napi-rs/wasm-runtime"] = "^1.1.4";
45
+ let packageJson = {};
46
+ let originalPackageJson = {};
47
+ if (this.fs.existsSync(this.config.napi.packageJsonPath)) packageJson = JSON.parse(await this.fs.read(this.config.napi.packageJsonPath) || "{}");
48
+ originalPackageJson = { ...packageJson };
49
+ packageJson.napi = {
50
+ binaryName: this.config.napi.binaryName,
51
+ packageName: this.config.napi.packageName,
52
+ targets: this.config.napi.targets?.map((target) => target.triple),
53
+ npmClient: this.config.napi.npmClient,
54
+ constEnum: this.config.napi.constEnum,
55
+ dtsHeader: this.config.napi.dtsHeader,
56
+ dtsHeaderFile: this.config.napi.dtsHeaderFile,
57
+ ...packageJson.napi,
58
+ wasm: this.config.napi.target?.platform === "wasm" ? defu(packageJson.napi?.wasm ?? {}, this.config.napi.wasm ?? {}, { initialMemory: 16384 }) : void 0
59
+ };
60
+ if (JSON.stringify(packageJson) !== JSON.stringify(originalPackageJson)) await this.fs.write(this.config.napi.packageJsonPath, JSON.stringify(packageJson, null, 2));
37
61
  },
38
62
  async prepare() {
39
63
  this.debug(`Preparing the N-API Rust runtime artifacts for the Powerlines project.`);
64
+ this.napi = new NapiCli();
65
+ if (this.config.napi.npmDir) await this.napi.createNpmDirs({
66
+ cwd: appendPath(this.config.root, this.config.cwd),
67
+ npmDir: formatPath(this, this.config.napi.npmDir),
68
+ configPath: formatPath(this, this.config.napi.configPath),
69
+ packageJsonPath: formatPath(this, this.config.napi.packageJsonPath)
70
+ });
40
71
  },
41
72
  async build() {
42
- this.debug(`Preparing the N-API Rust runtime artifacts for the Powerlines project.`);
43
- const cwd = appendPath(this.config.root, this.config.cwd);
44
- const { task } = await new NapiCli().build({
45
- cwd,
73
+ this.debug(`Building the N-API Rust runtime artifacts for the Powerlines project.`);
74
+ const { task } = await this.napi.build({
75
+ cwd: appendPath(this.config.root, this.config.cwd),
46
76
  package: this.config.napi.packageName,
47
- outputDir: relativePath(cwd, appendPath(appendPath(this.config.napi.outputDir, this.config.root), this.config.cwd)),
48
- configPath: this.config.napi.configPath ? relativePath(cwd, appendPath(appendPath(replacePathTokens(this, this.config.napi.configPath), this.config.root), this.config.cwd)) : void 0,
49
- manifestPath: this.config.napi.manifestPath ? relativePath(cwd, appendPath(appendPath(replacePathTokens(this, this.config.napi.manifestPath), this.config.root), this.config.cwd)) : void 0,
50
- packageJsonPath: this.config.napi.packageJsonPath ? relativePath(cwd, appendPath(appendPath(replacePathTokens(this, this.config.napi.packageJsonPath), this.config.root), this.config.cwd)) : void 0,
77
+ outputDir: formatPath(this, this.config.napi.outputDir),
78
+ configPath: formatPath(this, this.config.napi.configPath),
79
+ manifestPath: formatPath(this, this.config.napi.manifestPath),
80
+ packageJsonPath: formatPath(this, this.config.napi.packageJsonPath),
51
81
  target: this.config.napi.target?.triple,
52
82
  profile: this.config.napi.profile,
53
83
  release: this.config.napi.release ?? this.config.mode === "production",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"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 { NapiCli, parseTriple } from \"@napi-rs/cli\";\nimport alloy from \"@powerlines/plugin-alloy\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { Plugin } from \"powerlines\";\nimport { isVerbose, replacePathTokens } from \"powerlines/plugin-utils\";\nimport type { NapiPluginContext, NapiPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n napi?: NapiPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin for integrating with N-API Rust modules, providing features such as automatic generation of bindings and runtime integration with N-API Rust modules.\n *\n * @see https://napi.rs/docs\n */\nexport const plugin = <TContext extends NapiPluginContext = NapiPluginContext>(\n options: NapiPluginOptions = {}\n) => {\n return [\n alloy(),\n {\n name: \"napi-rs\",\n config() {\n return {\n napi: {\n dts: \"binding.d.ts\",\n jsBinding: \"binding.js\",\n outputDir: this.config.root,\n platform: true,\n strip: false,\n packageJsonPath: appendPath(this.config.root, \"package.json\"),\n ...options\n }\n };\n },\n configResolved() {\n if (!this.config.napi.target && this.additionalArgs.target) {\n this.config.napi.target = parseTriple(this.additionalArgs.target);\n } else {\n this.config.napi.target = isString(this.config.napi.target)\n ? parseTriple(this.config.napi.target)\n : this.config.napi.target;\n }\n\n if (!this.config.napi.profile && this.additionalArgs.profile) {\n this.config.napi.profile = this.additionalArgs.profile;\n }\n\n if (!this.config.napi.release && this.additionalArgs.release) {\n this.config.napi.release = Boolean(this.additionalArgs.release);\n }\n\n if (!this.config.napi.configPath && this.additionalArgs.configPath) {\n this.config.napi.configPath = this.additionalArgs.configPath;\n }\n\n if (\n !this.config.napi.manifestPath &&\n this.additionalArgs.manifestPath\n ) {\n this.config.napi.manifestPath = this.additionalArgs.manifestPath;\n }\n\n if (\n !this.config.napi.packageJsonPath &&\n this.additionalArgs.packageJsonPath\n ) {\n this.config.napi.packageJsonPath =\n this.additionalArgs.packageJsonPath;\n }\n\n if (this.config.napi.target?.platform === \"wasm\") {\n this.dependencies[\"@napi-rs/wasm-runtime\"] = \"^1.1.4\";\n }\n },\n async prepare() {\n this.debug(\n `Preparing the N-API Rust runtime artifacts for the Powerlines project.`\n );\n },\n async build() {\n this.debug(\n `Preparing the N-API Rust runtime artifacts for the Powerlines project.`\n );\n\n const cwd = appendPath(this.config.root, this.config.cwd);\n const cli = new NapiCli();\n\n const { task } = await cli.build({\n cwd,\n package: this.config.napi.packageName,\n outputDir: relativePath(\n cwd,\n appendPath(\n appendPath(this.config.napi.outputDir, this.config.root),\n this.config.cwd\n )\n ),\n configPath: this.config.napi.configPath\n ? relativePath(\n cwd,\n appendPath(\n appendPath(\n replacePathTokens(this, this.config.napi.configPath),\n this.config.root\n ),\n this.config.cwd\n )\n )\n : undefined,\n manifestPath: this.config.napi.manifestPath\n ? relativePath(\n cwd,\n appendPath(\n appendPath(\n replacePathTokens(this, this.config.napi.manifestPath),\n this.config.root\n ),\n this.config.cwd\n )\n )\n : undefined,\n packageJsonPath: this.config.napi.packageJsonPath\n ? relativePath(\n cwd,\n appendPath(\n appendPath(\n replacePathTokens(this, this.config.napi.packageJsonPath),\n this.config.root\n ),\n this.config.cwd\n )\n )\n : undefined,\n target: this.config.napi.target?.triple,\n profile: this.config.napi.profile,\n release:\n this.config.napi.release ?? this.config.mode === \"production\",\n features: this.config.napi.features,\n noDefaultFeatures: this.config.napi.noDefaultFeatures,\n strip: this.config.napi.strip,\n platform: this.config.napi.platform,\n noDtsHeader: this.config.napi.noDtsHeader,\n jsBinding: this.config.napi.jsBinding,\n dts: this.config.napi.dts,\n dtsCache: this.config.napi.dtsCache ?? !this.config.skipCache,\n verbose: isVerbose(this)\n });\n\n const outputs = await task;\n for (const output of outputs) {\n const code = await this.fs.read(output.path);\n if (code) {\n await this.fs.write(output.path, code);\n }\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAY,UAAO,UAAA,EAAA,KAAA;AACjB,QAAO,CAAC,OAAC,EAAA;EACT,MAAA;EACF,SAAA;YAEE,MAAA;IACG,KAAU;IACd,WAAA;IACO,WAAa,KAAG,OAAA;IACtB,UAAA;IACK,OAAM;IACH,iBAAC,WAAqB,KAAA,OAAA,MAAA,eAAA;IAC3B,GAAA;IACI,EACL;;EAEA,iBAAiB;AACf,OAAA,CAAA,KAAS,OAAA,KAAA,UAAA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,KAAA,OAAA,KAAA,EAAA,KAAA,OAAA,IAAA,CAAA,GAAA;IAClE,iBAAA,KAAA,OAAA,KAAA,kBAAA,aAAA,KAAA,WAAA,WAAA,kBAAA,MAAA,KAAA,OAAA,KAAA,gBAAA,EAAA,KAAA,OAAA,KAAA,EAAA,KAAA,OAAA,IAAA,CAAA,GAAA;;IAEA,SAAG,KAAA,OAAA,KAAA;IACH,SAAQ,KAAM,OAAM,KAAA,WAAiB,KAAA,OAAA,SAAA;IACrC,UAAO,KAAA,OAAe,KAAA;IACtB,mBAAE,KAAA,OAAA,KAAA;IACF,OAAO,KAAA,OAAY,KAAA;IACnB,UAAS,KAAA,OAAA,KAAe;IACxB,aAAA,KAAA,OAAA,KAAA;;IAEA,KAAI,KAAK,OAAO,KAAK;IACrB,UAAO,KAAA,OAAe,KAAK,YAAQ,CAAA,KAAU,OAAO;IACpD,SAAA,UAAA,KAAA;IACD,CAAA;GACD,MAAM,UAAU,MAAA;AAChB,QAAE,MAAK,UAAK,SAAA;IACV,MAAG,OAAU,MAAM,KAAI,GAAI,KAAC,OAAQ,KAAA;AACpC,QAAC,KACF,OAAA,KAAA,GAAA,MAAA,OAAA,MAAA,KAAA;;;EAIJ,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"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 { NapiCli, parseTriple } from \"@napi-rs/cli\";\nimport alloy from \"@powerlines/plugin-alloy\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { defu } from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { isVerbose } from \"powerlines/plugin-utils\";\nimport { formatPath } from \"./helpers/format-path\";\nimport { DEFAULT_TARGETS, Target } from \"./types\";\nimport type { NapiPluginContext, NapiPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n napi?: NapiPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin for integrating with N-API Rust modules, providing features such as automatic generation of bindings and runtime integration with N-API Rust modules.\n *\n * @see https://napi.rs/docs\n */\nexport const plugin = <TContext extends NapiPluginContext = NapiPluginContext>(\n options: NapiPluginOptions = {}\n) => {\n return [\n alloy(),\n {\n name: \"napi-rs\",\n config() {\n return {\n napi: {\n dts: \"binding.d.ts\",\n jsBinding: \"binding.js\",\n outputDir: this.config.root,\n platform: true,\n strip: false,\n ...options\n }\n };\n },\n async configResolved() {\n if (\n !this.config.napi.target &&\n this.additionalArgs.target &&\n (isString(this.additionalArgs.target) ||\n (Array.isArray(this.additionalArgs.target) &&\n this.additionalArgs.target.length > 0))\n ) {\n this.config.napi.target = parseTriple(\n (Array.isArray(this.additionalArgs.target) &&\n this.additionalArgs.target.length > 0\n ? this.additionalArgs.target[0]\n : String(this.additionalArgs.target))!\n );\n } else {\n this.config.napi.target = isString(this.config.napi.target)\n ? parseTriple(this.config.napi.target)\n : this.config.napi.target;\n }\n\n if (!this.config.napi.targets) {\n if (\n this.additionalArgs.targets &&\n (isString(this.additionalArgs.targets) ||\n (Array.isArray(this.additionalArgs.targets) &&\n this.additionalArgs.targets.length > 0))\n ) {\n this.config.napi.targets = toArray(this.additionalArgs.targets).map(\n (target: string) => parseTriple(target)\n );\n } else {\n this.config.napi.targets = DEFAULT_TARGETS.map(target =>\n parseTriple(target)\n );\n }\n }\n\n if (\n !this.config.napi.profile &&\n this.additionalArgs.profile &&\n (isString(this.additionalArgs.profile) ||\n (Array.isArray(this.additionalArgs.profile) &&\n this.additionalArgs.profile.length > 0))\n ) {\n this.config.napi.profile = (\n Array.isArray(this.additionalArgs.profile) &&\n this.additionalArgs.profile.length > 0\n ? this.additionalArgs.profile[0]\n : String(this.additionalArgs.profile)\n )!;\n }\n\n if (!this.config.napi.release && this.additionalArgs.release) {\n this.config.napi.release = Boolean(this.additionalArgs.release);\n }\n\n if (\n !this.config.napi.configPath &&\n this.additionalArgs.configPath &&\n (isString(this.additionalArgs.configPath) ||\n (Array.isArray(this.additionalArgs.configPath) &&\n this.additionalArgs.configPath.length > 0))\n ) {\n this.config.napi.configPath = (\n Array.isArray(this.additionalArgs.configPath) &&\n this.additionalArgs.configPath.length > 0\n ? this.additionalArgs.configPath[0]\n : String(this.additionalArgs.configPath)\n )!;\n }\n\n if (\n !this.config.napi.manifestPath &&\n this.additionalArgs.manifestPath &&\n (isString(this.additionalArgs.manifestPath) ||\n (Array.isArray(this.additionalArgs.manifestPath) &&\n this.additionalArgs.manifestPath.length > 0))\n ) {\n this.config.napi.manifestPath = (\n Array.isArray(this.additionalArgs.manifestPath) &&\n this.additionalArgs.manifestPath.length > 0\n ? this.additionalArgs.manifestPath[0]\n : String(this.additionalArgs.manifestPath)\n )!;\n }\n\n if (\n !this.config.napi.npmDir &&\n this.additionalArgs.npmDir &&\n (isString(this.additionalArgs.npmDir) ||\n (Array.isArray(this.additionalArgs.npmDir) &&\n this.additionalArgs.npmDir.length > 0))\n ) {\n this.config.napi.npmDir = (\n Array.isArray(this.additionalArgs.npmDir) &&\n this.additionalArgs.npmDir.length > 0\n ? this.additionalArgs.npmDir[0]\n : String(this.additionalArgs.npmDir)\n )!;\n }\n\n if (!this.config.napi.packageJsonPath) {\n if (\n this.additionalArgs.packageJsonPath &&\n (isString(this.additionalArgs.packageJsonPath) ||\n (Array.isArray(this.additionalArgs.packageJsonPath) &&\n this.additionalArgs.packageJsonPath.length > 0))\n ) {\n this.config.napi.packageJsonPath = (\n Array.isArray(this.additionalArgs.packageJsonPath) &&\n this.additionalArgs.packageJsonPath.length > 0\n ? this.additionalArgs.packageJsonPath[0]\n : String(this.additionalArgs.packageJsonPath)\n )!;\n }\n\n if (!this.config.napi.packageJsonPath) {\n this.config.napi.packageJsonPath = appendPath(\n this.config.root,\n \"package.json\"\n );\n }\n }\n\n if (this.config.napi.target?.platform === \"wasm\") {\n this.dependencies[\"@napi-rs/wasm-runtime\"] = \"^1.1.4\";\n }\n\n let packageJson = {} as Record<string, any>;\n let originalPackageJson = {} as Record<string, any>;\n\n if (this.fs.existsSync(this.config.napi.packageJsonPath)) {\n packageJson = JSON.parse(\n (await this.fs.read(this.config.napi.packageJsonPath)) || \"{}\"\n );\n }\n\n originalPackageJson = { ...packageJson };\n packageJson.napi = {\n binaryName: this.config.napi.binaryName,\n packageName: this.config.napi.packageName,\n targets: (this.config.napi.targets as Target[])?.map(\n target => target.triple\n ),\n npmClient: this.config.napi.npmClient,\n constEnum: this.config.napi.constEnum,\n dtsHeader: this.config.napi.dtsHeader,\n dtsHeaderFile: this.config.napi.dtsHeaderFile,\n ...packageJson.napi,\n wasm:\n this.config.napi.target?.platform === \"wasm\"\n ? defu(\n packageJson.napi?.wasm ?? {},\n this.config.napi.wasm ?? {},\n { initialMemory: 16384 }\n )\n : undefined\n };\n\n if (\n JSON.stringify(packageJson) !== JSON.stringify(originalPackageJson)\n ) {\n await this.fs.write(\n this.config.napi.packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n }\n },\n async prepare() {\n this.debug(\n `Preparing the N-API Rust runtime artifacts for the Powerlines project.`\n );\n\n this.napi = new NapiCli();\n\n if (this.config.napi.npmDir) {\n await this.napi.createNpmDirs({\n cwd: appendPath(this.config.root, this.config.cwd),\n npmDir: formatPath(this, this.config.napi.npmDir),\n configPath: formatPath(this, this.config.napi.configPath),\n packageJsonPath: formatPath(this, this.config.napi.packageJsonPath)\n });\n }\n },\n async build() {\n this.debug(\n `Building the N-API Rust runtime artifacts for the Powerlines project.`\n );\n\n const { task } = await this.napi.build({\n cwd: appendPath(this.config.root, this.config.cwd),\n package: this.config.napi.packageName,\n outputDir: formatPath(this, this.config.napi.outputDir),\n configPath: formatPath(this, this.config.napi.configPath),\n manifestPath: formatPath(this, this.config.napi.manifestPath),\n packageJsonPath: formatPath(this, this.config.napi.packageJsonPath),\n target: this.config.napi.target?.triple,\n profile: this.config.napi.profile,\n release:\n this.config.napi.release ?? this.config.mode === \"production\",\n features: this.config.napi.features,\n noDefaultFeatures: this.config.napi.noDefaultFeatures,\n strip: this.config.napi.strip,\n platform: this.config.napi.platform,\n noDtsHeader: this.config.napi.noDtsHeader,\n jsBinding: this.config.napi.jsBinding,\n dts: this.config.napi.dts,\n dtsCache: this.config.napi.dtsCache ?? !this.config.skipCache,\n verbose: isVerbose(this)\n });\n\n const outputs = await task;\n for (const output of outputs) {\n const code = await this.fs.read(output.path);\n if (code) {\n await this.fs.write(output.path, code);\n }\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,MAAY,UAAO,UAAA,EAAA,KAAA;AACjB,QAAO,CAAC,OAAC,EAAA;EACT,MAAA;EACF,SAAA;YAEE,MAAA;IACG,KAAU;IACd,WAAA;IACO,WAAa,KAAG,OAAA;IACtB,UAAA;IACK,OAAM;IACH,GAAC;IACN,EACH;;EAEE,MAAA,iBAAA;AACE,OAAI,CAAC,KAAE,OAAQ,KAAA,UAAA,KAAA,eAAA,WAAA,SAAA,KAAA,eAAA,OAAA,IAAA,MAAA,QAAA,KAAA,eAAA,OAAA,IAAA,KAAA,eAAA,OAAA,SAAA,GACf,MAAO,OAAE,KAAA,SAAA,YAAA,MAAA,QAAA,KAAA,eAAA,OAAA,IAAA,KAAA,eAAA,OAAA,SAAA,IAAA,KAAA,eAAA,OAAA,KAAA,OAAA,KAAA,eAAA,OAAA,CAAA;OAEP,MAAE,OAAM,KAAA,SAAA,SAAA,KAAA,OAAA,KAAA,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vB,aAAS,KAAA,OAAe,KAAA;IACxB,WAAQ,KAAK,OAAA,KAAe;IAC5B,KAAK,KAAG,OAAO,KAAK;IACpB,UAAI,KAAA,OAAA,KAAA,YAAA,CAAA,KAAA,OAAA;IACJ,SAAA,UAAA,KAAA;;GAEF,MAAK,UAAA,MAAA;AACL,QAAK,MAAK,UAAW,SAAS;IAC5B,MAAM,OAAC,MAAA,KAAe,GAAA,KAAQ,OAAA,KAAA;AAC9B,QAAG,KACD,OAAG,KAAM,GAAA,MAAQ,OAAK,MAAA,KAAe;;;EAI5C,CAAC"}
@@ -0,0 +1,15 @@
1
+
2
+ //#region ../../node_modules/.pnpm/@stryke+convert@0.7.0/node_modules/@stryke/convert/dist/to-array.mjs
3
+ /**
4
+ * Convert `Arrayable<T>` to `Array<T>`
5
+ *
6
+ * @param array - The `Arrayable<T>` to convert
7
+ * @returns An `Array<T>` containing the elements of the input
8
+ */
9
+ function toArray(array) {
10
+ array = array ?? [];
11
+ return Array.isArray(array) ? array : [array];
12
+ }
13
+
14
+ //#endregion
15
+ exports.toArray = toArray;
@@ -0,0 +1,15 @@
1
+ //#region ../../node_modules/.pnpm/@stryke+convert@0.7.0/node_modules/@stryke/convert/dist/to-array.mjs
2
+ /**
3
+ * Convert `Arrayable<T>` to `Array<T>`
4
+ *
5
+ * @param array - The `Arrayable<T>` to convert
6
+ * @returns An `Array<T>` containing the elements of the input
7
+ */
8
+ function toArray(array) {
9
+ array = array ?? [];
10
+ return Array.isArray(array) ? array : [array];
11
+ }
12
+
13
+ //#endregion
14
+ export { toArray };
15
+ //# sourceMappingURL=to-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-array.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+convert@0.7.0/node_modules/@stryke/convert/dist/to-array.mjs"],"sourcesContent":["//#region src/to-array.ts\n/**\n* Convert `Arrayable<T>` to `Array<T>`\n*\n* @param array - The `Arrayable<T>` to convert\n* @returns An `Array<T>` containing the elements of the input\n*/\nfunction toArray(array) {\n\tarray = array ?? [];\n\treturn Array.isArray(array) ? array : [array];\n}\n\n//#endregion\nexport { toArray };\n//# sourceMappingURL=to-array.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;AAOA,SAAS,QAAQ,OAAO;AACvB,SAAQ,SAAU,EAAC;AACnB,QAAO,MAAM,QAAQ,MAAO,GAAE,QAAS,CAAA,MAAM"}
@@ -1,5 +1,6 @@
1
1
  import { Target, TargetTriple } from "./targets.cjs";
2
2
  import { WasmOptions } from "./wasm.cjs";
3
+ import { NapiCli } from "@napi-rs/cli";
3
4
  import { AlloyPluginContext, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
4
5
  import { BabelPluginContext, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
5
6
  import { RequiredKeys } from "@stryke/types/base";
@@ -22,10 +23,28 @@ interface NapiPluginOptions {
22
23
  * Package name in generated JS binding file. Works only with --platform
23
24
  */
24
25
  packageName?: string;
26
+ /**
27
+ * Path to the build output dir, only needed when targets contains wasm32-wasi-*
28
+ *
29
+ * @remarks
30
+ * This is used by the [Artifacts command](https://napi.rs/docs/cli/artifacts). This is required because the plugin needs to copy the generated wasm file to the output dir, and the default output dir is the crate folder, which is not suitable for wasm files. Relative to the project root. If not specified, it will default to the crate folder. This is only used for wasm targets, and will be ignored for non-wasm targets.
31
+ */
32
+ buildOutputDir?: string;
33
+ /**
34
+ * Path to the folder where the npm packages are located.
35
+ *
36
+ * @remarks
37
+ * This is used by the [Artifacts command](https://napi.rs/docs/cli/artifacts)
38
+ */
39
+ npmDir?: string;
25
40
  /**
26
41
  * Build for the target triple, bypassed to `cargo build --target`
27
42
  */
28
43
  target?: TargetTriple | Target;
44
+ /**
45
+ * Specify multiple targets to build for, bypassed to `cargo build --target` with cargo-multi-target. If specified, the plugin will build for all the specified targets and generate bindings for each target. The generated binding files will have the target triple as a suffix, e.g. [name].linux-x64-gnu.node and [name].wasm32-wasi.node.
46
+ */
47
+ targets?: (TargetTriple | Target)[];
29
48
  /**
30
49
  * Build artifacts with the specified Cargo profile
31
50
  */
@@ -92,6 +111,10 @@ interface NapiPluginOptions {
92
111
  * @defaultValue true
93
112
  */
94
113
  platform?: boolean;
114
+ /**
115
+ * Specify a different NPM client for usage when executing NPM actions such as publishing.
116
+ */
117
+ npmClient?: string;
95
118
  /**
96
119
  * Whether to generate const enum for TypeScript bindings
97
120
  */
@@ -104,6 +127,10 @@ interface NapiPluginOptions {
104
127
  * Custom file header for generated type def file (requires typedef feature)
105
128
  */
106
129
  dtsHeader?: string;
130
+ /**
131
+ * Path to the custom file header for generated type def file (requires typedef feature)
132
+ */
133
+ dtsHeaderFile?: string;
107
134
  /**
108
135
  * Disable default file header for generated type def file (requires typedef feature)
109
136
  */
@@ -132,16 +159,22 @@ interface NapiPluginOptions {
132
159
  type NapiPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & {
133
160
  napi: NapiPluginOptions;
134
161
  };
135
- type NapiResolvedPluginOptions = RequiredKeys<Omit<NapiPluginOptions, "targets">, "dts" | "jsBinding" | "manifestPath" | "outputDir" | "platform" | "packageJsonPath"> & {
162
+ type NapiResolvedPluginOptions = Omit<RequiredKeys<NapiPluginOptions, "dts" | "jsBinding" | "manifestPath" | "outputDir" | "platform" | "packageJsonPath">, "target" | "targets"> & {
136
163
  /**
137
164
  * The resolved target triple to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `target` option, and are used internally by the plugin to determine how to build the N-API Rust module for the target.
138
165
  */
139
166
  target: Target;
167
+ /**
168
+ * The resolved list of target triples to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `targets` option, and are used internally by the plugin to determine how to build the N-API Rust module for each target.
169
+ */
170
+ targets: Target[];
140
171
  };
141
172
  type NapiPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & {
142
173
  napi: NapiResolvedPluginOptions;
143
174
  };
144
- interface NapiPluginContext<TResolvedConfig extends NapiPluginResolvedConfig = NapiPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig> {}
175
+ interface NapiPluginContext<TResolvedConfig extends NapiPluginResolvedConfig = NapiPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig> {
176
+ napi: NapiCli;
177
+ }
145
178
  //#endregion
146
179
  export { NapiPluginContext, NapiPluginOptions, NapiPluginResolvedConfig, NapiPluginUserConfig, NapiResolvedPluginOptions };
147
180
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;AAwCA;;;;;;UAAiB,iBAAA;EAkCC;;;EA9BhB,UAAA;EAUA;;;EALA,WAAA;EAeA;;;EAVA,MAAA,GAAS,YAAA,GAAe,MAAA;EAoBb;;;EAfX,OAAA;EA2CA;;;EAtCA,IAAA,GAAO,WAAA;EA0DP;;;EArDA,OAAA;EA2EA;;;EAtEA,QAAA,GAAW,KAAA;EA0FX;;;EArFA,WAAA;EAoGY;;AAGd;;;EAhGE,iBAAA;EAiGA;;;;;EA1FA,SAAA;EA2FE;;;;AAGJ;;;EArFE,GAAA;EAsFA;;;EAjFA,YAAA;EA4Fc;;;EAvFd,UAAA;EAuFA;;;EAlFA,SAAA;EAqFU;;;EAhFV,SAAA;EAiFA;;;EA5EA,eAAA;EA2EqC;;;;;EApErC,QAAA;EAyEe;;;EApEf,SAAA;EAqEmD;;;EAhEnD,WAAA;EAoEE;;;EA/DF,SAAA;EA2DwB;;;EAtDxB,WAAA;EA0DE;;;EArDF,QAAA;;;;EAKA,KAAA;;;;EAKA,YAAA;;;;EAKA,QAAA;;;;EAKA,YAAA;AAAA;AAAA,KAGU,oBAAA,GAAuB,qBAAA,GACjC,qBAAA;EACE,IAAA,EAAM,iBAAA;AAAA;AAAA,KAGE,yBAAA,GAA4B,YAAA,CACtC,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IAAA,CACtC,YAAA,CACE,iBAAA;;;;EAaF,MAAA,EAAQ,MAAA;;;;EAKR,OAAA,EAAS,MAAA;AAAA;AAAA,KAGC,wBAAA,GAA2B,yBAAA,GACrC,yBAAA;EACE,IAAA,EAAM,yBAAA;AAAA;AAAA,UAGO,iBAAA,yBACS,wBAAA,GAA2B,wBAAA,UAGjD,kBAAA,CAAmB,eAAA,GACnB,kBAAA,CAAmB,eAAA;EACrB,IAAA,EAAM,OAAA;AAAA"}
@@ -1,5 +1,6 @@
1
1
  import { Target, TargetTriple } from "./targets.mjs";
2
2
  import { WasmOptions } from "./wasm.mjs";
3
+ import { NapiCli } from "@napi-rs/cli";
3
4
  import { AlloyPluginContext, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
4
5
  import { BabelPluginContext, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
5
6
  import { RequiredKeys } from "@stryke/types/base";
@@ -22,10 +23,28 @@ interface NapiPluginOptions {
22
23
  * Package name in generated JS binding file. Works only with --platform
23
24
  */
24
25
  packageName?: string;
26
+ /**
27
+ * Path to the build output dir, only needed when targets contains wasm32-wasi-*
28
+ *
29
+ * @remarks
30
+ * This is used by the [Artifacts command](https://napi.rs/docs/cli/artifacts). This is required because the plugin needs to copy the generated wasm file to the output dir, and the default output dir is the crate folder, which is not suitable for wasm files. Relative to the project root. If not specified, it will default to the crate folder. This is only used for wasm targets, and will be ignored for non-wasm targets.
31
+ */
32
+ buildOutputDir?: string;
33
+ /**
34
+ * Path to the folder where the npm packages are located.
35
+ *
36
+ * @remarks
37
+ * This is used by the [Artifacts command](https://napi.rs/docs/cli/artifacts)
38
+ */
39
+ npmDir?: string;
25
40
  /**
26
41
  * Build for the target triple, bypassed to `cargo build --target`
27
42
  */
28
43
  target?: TargetTriple | Target;
44
+ /**
45
+ * Specify multiple targets to build for, bypassed to `cargo build --target` with cargo-multi-target. If specified, the plugin will build for all the specified targets and generate bindings for each target. The generated binding files will have the target triple as a suffix, e.g. [name].linux-x64-gnu.node and [name].wasm32-wasi.node.
46
+ */
47
+ targets?: (TargetTriple | Target)[];
29
48
  /**
30
49
  * Build artifacts with the specified Cargo profile
31
50
  */
@@ -92,6 +111,10 @@ interface NapiPluginOptions {
92
111
  * @defaultValue true
93
112
  */
94
113
  platform?: boolean;
114
+ /**
115
+ * Specify a different NPM client for usage when executing NPM actions such as publishing.
116
+ */
117
+ npmClient?: string;
95
118
  /**
96
119
  * Whether to generate const enum for TypeScript bindings
97
120
  */
@@ -104,6 +127,10 @@ interface NapiPluginOptions {
104
127
  * Custom file header for generated type def file (requires typedef feature)
105
128
  */
106
129
  dtsHeader?: string;
130
+ /**
131
+ * Path to the custom file header for generated type def file (requires typedef feature)
132
+ */
133
+ dtsHeaderFile?: string;
107
134
  /**
108
135
  * Disable default file header for generated type def file (requires typedef feature)
109
136
  */
@@ -132,16 +159,22 @@ interface NapiPluginOptions {
132
159
  type NapiPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & {
133
160
  napi: NapiPluginOptions;
134
161
  };
135
- type NapiResolvedPluginOptions = RequiredKeys<Omit<NapiPluginOptions, "targets">, "dts" | "jsBinding" | "manifestPath" | "outputDir" | "platform" | "packageJsonPath"> & {
162
+ type NapiResolvedPluginOptions = Omit<RequiredKeys<NapiPluginOptions, "dts" | "jsBinding" | "manifestPath" | "outputDir" | "platform" | "packageJsonPath">, "target" | "targets"> & {
136
163
  /**
137
164
  * The resolved target triple to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `target` option, and are used internally by the plugin to determine how to build the N-API Rust module for the target.
138
165
  */
139
166
  target: Target;
167
+ /**
168
+ * The resolved list of target triples to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `targets` option, and are used internally by the plugin to determine how to build the N-API Rust module for each target.
169
+ */
170
+ targets: Target[];
140
171
  };
141
172
  type NapiPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & {
142
173
  napi: NapiResolvedPluginOptions;
143
174
  };
144
- interface NapiPluginContext<TResolvedConfig extends NapiPluginResolvedConfig = NapiPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig> {}
175
+ interface NapiPluginContext<TResolvedConfig extends NapiPluginResolvedConfig = NapiPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig> {
176
+ napi: NapiCli;
177
+ }
145
178
  //#endregion
146
179
  export { NapiPluginContext, NapiPluginOptions, NapiPluginResolvedConfig, NapiPluginUserConfig, NapiResolvedPluginOptions };
147
180
  //# sourceMappingURL=plugin.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;AAwCA;;;;;;UAAiB,iBAAA;EAkCC;;;EA9BhB,UAAA;EAUA;;;EALA,WAAA;EAeA;;;EAVA,MAAA,GAAS,YAAA,GAAe,MAAA;EAoBb;;;EAfX,OAAA;EA2CA;;;EAtCA,IAAA,GAAO,WAAA;EA0DP;;;EArDA,OAAA;EA2EA;;;EAtEA,QAAA,GAAW,KAAA;EA0FX;;;EArFA,WAAA;EAoGY;;AAGd;;;EAhGE,iBAAA;EAiGA;;;;;EA1FA,SAAA;EA2FE;;;;AAGJ;;;EArFE,GAAA;EAsFA;;;EAjFA,YAAA;EA4Fc;;;EAvFd,UAAA;EAuFA;;;EAlFA,SAAA;EAqFU;;;EAhFV,SAAA;EAiFA;;;EA5EA,eAAA;EA2EqC;;;;;EApErC,QAAA;EAyEe;;;EApEf,SAAA;EAqEmD;;;EAhEnD,WAAA;EAoEE;;;EA/DF,SAAA;EA2DwB;;;EAtDxB,WAAA;EA0DE;;;EArDF,QAAA;;;;EAKA,KAAA;;;;EAKA,YAAA;;;;EAKA,QAAA;;;;EAKA,YAAA;AAAA;AAAA,KAGU,oBAAA,GAAuB,qBAAA,GACjC,qBAAA;EACE,IAAA,EAAM,iBAAA;AA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M,iBAAA;AAAA;AAAA,KAGE,yBAAA,GAA4B,IAAA,CACtC,YAAA,CACE,iBAAA;;;;EAaF,MAAA,EAAQ,MAAA;;;;EAKR,OAAA,EAAS,MAAA;AAAA;AAAA,KAGC,wBAAA,GAA2B,yBAAA,GACrC,yBAAA;EACE,IAAA,EAAM,yBAAA;AAAA;AAAA,UAGO,iBAAA,yBACS,wBAAA,GAA2B,wBAAA,UAGjD,kBAAA,CAAmB,eAAA,GACnB,kBAAA,CAAmB,eAAA;EACrB,IAAA,EAAM,OAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/types/plugin.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 AlloyPluginContext,\n AlloyPluginResolvedConfig,\n AlloyPluginUserConfig\n} from \"@powerlines/plugin-alloy/types\";\nimport type {\n BabelPluginContext,\n BabelPluginResolvedConfig,\n BabelPluginUserConfig\n} from \"@powerlines/plugin-babel/types\";\nimport { RequiredKeys } from \"@stryke/types/base\";\nimport { Target, TargetTriple } from \"./targets\";\nimport { WasmOptions } from \"./wasm\";\n\n/**\n * The options for the N-API Rust plugin.\n *\n * @remarks\n * These options are based on the options for the N-API Rust CLI, and are used to configure the plugin's behavior when building and generating bindings for N-API Rust modules.\n *\n * @see https://napi.rs/docs/cli/build#options\n */\nexport interface NapiPluginOptions {\n /**\n * Build only the specified binary\n */\n binaryName?: string;\n\n /**\n * Package name in generated JS binding file. Works only with --platform\n */\n packageName?: string;\n\n /**\n * Build for the target triple, bypassed to `cargo build --target`\n */\n target?: TargetTriple | Target;\n\n /**\n * Build artifacts with the specified Cargo profile\n */\n profile?: string;\n\n /**\n * Wasm compilation options. If specified, the plugin will compile the N-API Rust module to WebAssembly and generate the corresponding bindings.\n */\n wasm?: WasmOptions;\n\n /**\n * Build in release mode\n */\n release?: boolean;\n\n /**\n * List of Cargo features to activate\n */\n features?: Array<string>;\n\n /**\n * Activate all available Cargo features\n */\n allFeatures?: boolean;\n\n /**\n * Do not activate the default features\n *\n * @defaultValue false\n */\n noDefaultFeatures?: boolean;\n\n /**\n * Path and filename of generated JS binding file. Only works with {@link platform} flag. Relative to {@link outputPath}.\n *\n * @defaultValue \"binding.js\"\n */\n jsBinding?: string;\n\n /**\n * DTS Binding File\n *\n * The path to the output TypeScript declaration file\n *\n * @defaultValue \"binding.d.ts\"\n */\n dts?: string;\n\n /**\n * The path to the Cargo.toml manifest file\n */\n manifestPath?: string;\n\n /**\n * Path to [NAPI-RS config file](https://napi.rs/docs/cli/napi-config)\n */\n configPath?: string;\n\n /**\n * Path to where all the built files would be put. Default to the crate folder if not specified. Relative to the project root.\n */\n outputDir?: string;\n\n /**\n * \tDirectory for all crate generated artifacts, see `cargo build --target-dir`\n */\n targetDir?: string;\n\n /**\n * Path to the package.json file to read the version and other metadata from, used for generating the JS binding file. If not specified, it will default to the package.json file in the project root.\n */\n packageJsonPath?: string;\n\n /**\n * Add platform triple suffix to generated Node.js binding file, e.g. [name].linux-x64-gnu.node\n *\n * @defaultValue true\n */\n platform?: boolean;\n\n /**\n * Whether to generate const enum for TypeScript bindings\n */\n constEnum?: boolean;\n\n /**\n * Disable generation of JS binding file. Works only with --platform\n */\n noJsBinding?: boolean;\n\n /**\n * Custom file header for generated type def file (requires typedef feature)\n */\n dtsHeader?: string;\n\n /**\n * Disable default file header for generated type def file (requires typedef feature)\n */\n noDtsHeader?: boolean;\n\n /**\n * Enable the DTS cache\n */\n dtsCache?: boolean;\n\n /**\n * Strip the library to minimize file size\n */\n strip?: boolean;\n\n /**\n * Cross-compile for the specified target with cargo-xwin on Windows and cargo-zigbuild on other platforms\n */\n crossCompile?: boolean;\n\n /**\n * Use [cross-rs](https://github.com/cross-rs/cross) instead of cargo\n */\n useCross?: boolean;\n\n /**\n * Use \\@napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets\n */\n useNapiCross?: boolean;\n}\n\nexport type NapiPluginUserConfig = BabelPluginUserConfig &\n AlloyPluginUserConfig & {\n napi: NapiPluginOptions;\n };\n\nexport type NapiResolvedPluginOptions = RequiredKeys<\n Omit<NapiPluginOptions, \"targets\">,\n | \"dts\"\n | \"jsBinding\"\n | \"manifestPath\"\n | \"outputDir\"\n | \"platform\"\n | \"packageJsonPath\"\n> & {\n /**\n * The resolved target triple to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `target` option, and are used internally by the plugin to determine how to build the N-API Rust module for the target.\n */\n target: Target;\n};\n\nexport type NapiPluginResolvedConfig = BabelPluginResolvedConfig &\n AlloyPluginResolvedConfig & {\n napi: NapiResolvedPluginOptions;\n };\n\nexport interface NapiPluginContext<\n TResolvedConfig extends NapiPluginResolvedConfig = NapiPluginResolvedConfig\n>\n extends\n BabelPluginContext<TResolvedConfig>,\n AlloyPluginContext<TResolvedConfig> {}\n"],"mappings":""}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/types/plugin.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 { NapiCli } from \"@napi-rs/cli\";\nimport type {\n AlloyPluginContext,\n AlloyPluginResolvedConfig,\n AlloyPluginUserConfig\n} from \"@powerlines/plugin-alloy/types\";\nimport type {\n BabelPluginContext,\n BabelPluginResolvedConfig,\n BabelPluginUserConfig\n} from \"@powerlines/plugin-babel/types\";\nimport { RequiredKeys } from \"@stryke/types/base\";\nimport { Target, TargetTriple } from \"./targets\";\nimport { WasmOptions } from \"./wasm\";\n\n/**\n * The options for the N-API Rust plugin.\n *\n * @remarks\n * These options are based on the options for the N-API Rust CLI, and are used to configure the plugin's behavior when building and generating bindings for N-API Rust modules.\n *\n * @see https://napi.rs/docs/cli/build#options\n */\nexport interface NapiPluginOptions {\n /**\n * Build only the specified binary\n */\n binaryName?: string;\n\n /**\n * Package name in generated JS binding file. Works only with --platform\n */\n packageName?: string;\n\n /**\n * Path to the build output dir, only needed when targets contains wasm32-wasi-*\n *\n * @remarks\n * This is used by the [Artifacts command](https://napi.rs/docs/cli/artifacts). This is required because the plugin needs to copy the generated wasm file to the output dir, and the default output dir is the crate folder, which is not suitable for wasm files. Relative to the project root. If not specified, it will default to the crate folder. This is only used for wasm targets, and will be ignored for non-wasm targets.\n */\n buildOutputDir?: string;\n\n /**\n * Path to the folder where the npm packages are located.\n *\n * @remarks\n * This is used by the [Artifacts command](https://napi.rs/docs/cli/artifacts)\n */\n npmDir?: string;\n\n /**\n * Build for the target triple, bypassed to `cargo build --target`\n */\n target?: TargetTriple | Target;\n\n /**\n * Specify multiple targets to build for, bypassed to `cargo build --target` with cargo-multi-target. If specified, the plugin will build for all the specified targets and generate bindings for each target. The generated binding files will have the target triple as a suffix, e.g. [name].linux-x64-gnu.node and [name].wasm32-wasi.node.\n */\n targets?: (TargetTriple | Target)[];\n\n /**\n * Build artifacts with the specified Cargo profile\n */\n profile?: string;\n\n /**\n * Wasm compilation options. If specified, the plugin will compile the N-API Rust module to WebAssembly and generate the corresponding bindings.\n */\n wasm?: WasmOptions;\n\n /**\n * Build in release mode\n */\n release?: boolean;\n\n /**\n * List of Cargo features to activate\n */\n features?: Array<string>;\n\n /**\n * Activate all available Cargo features\n */\n allFeatures?: boolean;\n\n /**\n * Do not activate the default features\n *\n * @defaultValue false\n */\n noDefaultFeatures?: boolean;\n\n /**\n * Path and filename of generated JS binding file. Only works with {@link platform} flag. Relative to {@link outputPath}.\n *\n * @defaultValue \"binding.js\"\n */\n jsBinding?: string;\n\n /**\n * DTS Binding File\n *\n * The path to the output TypeScript declaration file\n *\n * @defaultValue \"binding.d.ts\"\n */\n dts?: string;\n\n /**\n * The path to the Cargo.toml manifest file\n */\n manifestPath?: string;\n\n /**\n * Path to [NAPI-RS config file](https://napi.rs/docs/cli/napi-config)\n */\n configPath?: string;\n\n /**\n * Path to where all the built files would be put. Default to the crate folder if not specified. Relative to the project root.\n */\n outputDir?: string;\n\n /**\n * \tDirectory for all crate generated artifacts, see `cargo build --target-dir`\n */\n targetDir?: string;\n\n /**\n * Path to the package.json file to read the version and other metadata from, used for generating the JS binding file. If not specified, it will default to the package.json file in the project root.\n */\n packageJsonPath?: string;\n\n /**\n * Add platform triple suffix to generated Node.js binding file, e.g. [name].linux-x64-gnu.node\n *\n * @defaultValue true\n */\n platform?: boolean;\n\n /**\n * Specify a different NPM client for usage when executing NPM actions such as publishing.\n */\n npmClient?: string;\n\n /**\n * Whether to generate const enum for TypeScript bindings\n */\n constEnum?: boolean;\n\n /**\n * Disable generation of JS binding file. Works only with --platform\n */\n noJsBinding?: boolean;\n\n /**\n * Custom file header for generated type def file (requires typedef feature)\n */\n dtsHeader?: string;\n\n /**\n * Path to the custom file header for generated type def file (requires typedef feature)\n */\n dtsHeaderFile?: string;\n\n /**\n * Disable default file header for generated type def file (requires typedef feature)\n */\n noDtsHeader?: boolean;\n\n /**\n * Enable the DTS cache\n */\n dtsCache?: boolean;\n\n /**\n * Strip the library to minimize file size\n */\n strip?: boolean;\n\n /**\n * Cross-compile for the specified target with cargo-xwin on Windows and cargo-zigbuild on other platforms\n */\n crossCompile?: boolean;\n\n /**\n * Use [cross-rs](https://github.com/cross-rs/cross) instead of cargo\n */\n useCross?: boolean;\n\n /**\n * Use \\@napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets\n */\n useNapiCross?: boolean;\n}\n\nexport type NapiPluginUserConfig = BabelPluginUserConfig &\n AlloyPluginUserConfig & {\n napi: NapiPluginOptions;\n };\n\nexport type NapiResolvedPluginOptions = Omit<\n RequiredKeys<\n NapiPluginOptions,\n | \"dts\"\n | \"jsBinding\"\n | \"manifestPath\"\n | \"outputDir\"\n | \"platform\"\n | \"packageJsonPath\"\n >,\n \"target\" | \"targets\"\n> & {\n /**\n * The resolved target triple to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `target` option, and are used internally by the plugin to determine how to build the N-API Rust module for the target.\n */\n target: Target;\n\n /**\n * The resolved list of target triples to build for, with additional metadata such as platform, architecture, and ABI information. These are derived from the `targets` option, and are used internally by the plugin to determine how to build the N-API Rust module for each target.\n */\n targets: Target[];\n};\n\nexport type NapiPluginResolvedConfig = BabelPluginResolvedConfig &\n AlloyPluginResolvedConfig & {\n napi: NapiResolvedPluginOptions;\n };\n\nexport interface NapiPluginContext<\n TResolvedConfig extends NapiPluginResolvedConfig = NapiPluginResolvedConfig\n>\n extends\n BabelPluginContext<TResolvedConfig>,\n AlloyPluginContext<TResolvedConfig> {\n napi: NapiCli;\n}\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-napi-rs",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "A package containing a Powerlines plugin for integrating with N-API Rust modules.",
6
6
  "keywords": ["napi-rs", "powerlines", "storm-software", "powerlines-plugin"],
@@ -54,6 +54,20 @@
54
54
  "default": "./dist/index.mjs"
55
55
  }
56
56
  },
57
+ "./helpers/format-path": {
58
+ "require": {
59
+ "types": "./dist/helpers/format-path.d.cts",
60
+ "default": "./dist/helpers/format-path.cjs"
61
+ },
62
+ "import": {
63
+ "types": "./dist/helpers/format-path.d.mts",
64
+ "default": "./dist/helpers/format-path.mjs"
65
+ },
66
+ "default": {
67
+ "types": "./dist/helpers/format-path.d.mts",
68
+ "default": "./dist/helpers/format-path.mjs"
69
+ }
70
+ },
57
71
  "./package.json": "./package.json",
58
72
  "./types": {
59
73
  "require": {
@@ -123,9 +137,9 @@
123
137
  "@alloy-js/markdown": "0.23.0-dev.1",
124
138
  "@alloy-js/typescript": "0.23.0-dev.4",
125
139
  "@napi-rs/cli": "^3.6.2",
126
- "@powerlines/plugin-alloy": "^0.26.41",
127
- "@powerlines/plugin-automd": "^0.1.423",
128
- "@powerlines/plugin-plugin": "^0.12.374",
140
+ "@powerlines/plugin-alloy": "^0.26.42",
141
+ "@powerlines/plugin-automd": "^0.1.424",
142
+ "@powerlines/plugin-plugin": "^0.12.375",
129
143
  "@stryke/fs": "^0.33.67",
130
144
  "@stryke/path": "^0.27.5",
131
145
  "@stryke/string-format": "^0.17.10",
@@ -133,11 +147,12 @@
133
147
  "@stryke/types": "^0.11.4",
134
148
  "automd": "^0.4.3",
135
149
  "defu": "^6.1.7",
136
- "powerlines": "^0.43.22"
150
+ "powerlines": "^0.43.23"
137
151
  },
138
152
  "devDependencies": { "@types/node": "^25.6.0" },
139
153
  "peerDependencies": { "@napi-rs/wasm-runtime": ">=1.1.4" },
140
154
  "peerDependenciesMeta": { "@napi-rs/wasm-runtime": { "optional": true } },
141
155
  "publishConfig": { "access": "public" },
142
- "gitHead": "1d29de32c192991600b83c5d7d6e5337751da859"
156
+ "inlinedDependencies": { "@stryke/convert": "0.7.0" },
157
+ "gitHead": "b683603833a7d11e315048f040e7aac22a4586f2"
143
158
  }