@napi-rs/cli 3.0.0-alpha.89 → 3.0.0-alpha.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@ var require_fast_content_type_parse = __commonJS({
43
43
  var defaultContentType = { type: "", parameters: new NullObject() };
44
44
  Object.freeze(defaultContentType.parameters);
45
45
  Object.freeze(defaultContentType);
46
- function parse5(header) {
46
+ function parse6(header) {
47
47
  if (typeof header !== "string") {
48
48
  throw new TypeError("argument header is required and must be a string");
49
49
  }
@@ -61,7 +61,7 @@ var require_fast_content_type_parse = __commonJS({
61
61
  }
62
62
  let key;
63
63
  let match;
64
- let value;
64
+ let value2;
65
65
  paramRE.lastIndex = index;
66
66
  while (match = paramRE.exec(header)) {
67
67
  if (match.index !== index) {
@@ -69,12 +69,12 @@ var require_fast_content_type_parse = __commonJS({
69
69
  }
70
70
  index += match[0].length;
71
71
  key = match[1].toLowerCase();
72
- value = match[2];
73
- if (value[0] === '"') {
74
- value = value.slice(1, value.length - 1);
75
- quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1"));
72
+ value2 = match[2];
73
+ if (value2[0] === '"') {
74
+ value2 = value2.slice(1, value2.length - 1);
75
+ quotedPairRE.test(value2) && (value2 = value2.replace(quotedPairRE, "$1"));
76
76
  }
77
- result.parameters[key] = value;
77
+ result.parameters[key] = value2;
78
78
  }
79
79
  if (index !== header.length) {
80
80
  throw new TypeError("invalid parameter format");
@@ -99,7 +99,7 @@ var require_fast_content_type_parse = __commonJS({
99
99
  }
100
100
  let key;
101
101
  let match;
102
- let value;
102
+ let value2;
103
103
  paramRE.lastIndex = index;
104
104
  while (match = paramRE.exec(header)) {
105
105
  if (match.index !== index) {
@@ -107,20 +107,20 @@ var require_fast_content_type_parse = __commonJS({
107
107
  }
108
108
  index += match[0].length;
109
109
  key = match[1].toLowerCase();
110
- value = match[2];
111
- if (value[0] === '"') {
112
- value = value.slice(1, value.length - 1);
113
- quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1"));
110
+ value2 = match[2];
111
+ if (value2[0] === '"') {
112
+ value2 = value2.slice(1, value2.length - 1);
113
+ quotedPairRE.test(value2) && (value2 = value2.replace(quotedPairRE, "$1"));
114
114
  }
115
- result.parameters[key] = value;
115
+ result.parameters[key] = value2;
116
116
  }
117
117
  if (index !== header.length) {
118
118
  return defaultContentType;
119
119
  }
120
120
  return result;
121
121
  }
122
- module2.exports.default = { parse: parse5, safeParse: safeParse2 };
123
- module2.exports.parse = parse5;
122
+ module2.exports.default = { parse: parse6, safeParse: safeParse2 };
123
+ module2.exports.parse = parse6;
124
124
  module2.exports.safeParse = safeParse2;
125
125
  module2.exports.defaultContentType = defaultContentType;
126
126
  }
@@ -135,7 +135,7 @@ __export(index_exports, {
135
135
  module.exports = __toCommonJS(index_exports);
136
136
 
137
137
  // dist/api/artifacts.js
138
- var import_node_path = require("node:path");
138
+ var import_node_path2 = require("node:path");
139
139
  var colors2 = __toESM(require("colorette"), 1);
140
140
 
141
141
  // dist/def/artifacts.js
@@ -206,7 +206,7 @@ var import_node_util = require("node:util");
206
206
  // package.json
207
207
  var package_default = {
208
208
  name: "@napi-rs/cli",
209
- version: "3.0.0-alpha.89",
209
+ version: "3.0.0-alpha.90",
210
210
  description: "Cli tools for napi-rs",
211
211
  author: "LongYinan <lynweklm@gmail.com>",
212
212
  homepage: "https://github.com/napi-rs/napi-rs",
@@ -224,12 +224,12 @@ var package_default = {
224
224
  exports: {
225
225
  ".": {
226
226
  import: {
227
- default: "./dist/index.js",
228
- types: "./dist/index.d.ts"
227
+ types: "./dist/index.d.ts",
228
+ default: "./dist/index.js"
229
229
  },
230
230
  require: {
231
- default: "./dist/index.cjs",
232
- types: "./dist/index.d.ts"
231
+ types: "./dist/index.d.ts",
232
+ default: "./dist/index.cjs"
233
233
  }
234
234
  },
235
235
  "./package.json": {
@@ -276,22 +276,22 @@ var package_default = {
276
276
  "@inquirer/prompts": "^7.4.0",
277
277
  "@napi-rs/cross-toolchain": "^0.0.19",
278
278
  "@napi-rs/wasm-tools": "^0.0.3",
279
- "@octokit/rest": "^22.0.0",
280
279
  clipanion: "^4.0.0-rc.4",
281
280
  colorette: "^2.0.20",
282
281
  debug: "^4.4.0",
283
282
  emnapi: "^1.4.0",
283
+ "find-up": "^7.0.0",
284
284
  "js-yaml": "^4.1.0",
285
- "lodash-es": "^4.17.21",
286
285
  semver: "^7.7.1",
287
- toml: "^3.0.0",
288
286
  typanion: "^3.14.0",
289
287
  "wasm-sjlj": "^1.0.6"
290
288
  },
291
289
  devDependencies: {
292
290
  "@emnapi/core": "^1.4.0",
293
291
  "@emnapi/runtime": "^1.4.0",
294
- "@oxc-node/core": "^0.0.28",
292
+ "@octokit/rest": "^22.0.0",
293
+ "@oxc-node/core": "^0.0.29",
294
+ "@std/toml": "npm:@jsr/std__toml@^1.0.8",
295
295
  "@types/debug": "^4.1.12",
296
296
  "@types/inquirer": "^9.0.7",
297
297
  "@types/js-yaml": "^4.0.9",
@@ -301,6 +301,7 @@ var package_default = {
301
301
  ava: "^6.2.0",
302
302
  "env-paths": "^3.0.0",
303
303
  esbuild: "^0.25.2",
304
+ "lodash-es": "^4.17.21",
304
305
  prettier: "^3.5.3",
305
306
  tslib: "^2.8.1",
306
307
  typescript: "^5.8.2"
@@ -335,7 +336,7 @@ var package_default = {
335
336
  "**/__tests__/**/*.spec.ts"
336
337
  ]
337
338
  },
338
- gitHead: "aa9e13df1f2f59a35c5f4270a50a63bb94a39332"
339
+ gitHead: "aeefd091b10e59e6eee8cae01337d19daee679f1"
339
340
  };
340
341
 
341
342
  // dist/utils/misc.js
@@ -377,9 +378,6 @@ var CLI_VERSION = package_default.version;
377
378
 
378
379
  // dist/utils/target.js
379
380
  var import_node_child_process = require("node:child_process");
380
- var UNIVERSAL_TARGETS = {
381
- "universal-apple-darwin": ["aarch64-apple-darwin", "x86_64-apple-darwin"]
382
- };
383
381
  var AVAILABLE_TARGETS = [
384
382
  "aarch64-apple-darwin",
385
383
  "aarch64-linux-android",
@@ -421,14 +419,6 @@ var CpuToNodeArch = {
421
419
  riscv64gc: "riscv64",
422
420
  powerpc64le: "ppc64"
423
421
  };
424
- var NodeArchToCpu = {
425
- x64: "x86_64",
426
- arm64: "aarch64",
427
- ia32: "i686",
428
- arm: "armv7",
429
- riscv64: "riscv64gc",
430
- ppc64: "powerpc64le"
431
- };
432
422
  var SysToNodePlatform = {
433
423
  linux: "linux",
434
424
  freebsd: "freebsd",
@@ -565,10 +555,10 @@ async function parseMetadata(manifestPath) {
565
555
  childProcess.stderr.on("data", (data) => {
566
556
  stderr += data;
567
557
  });
568
- await new Promise((resolve7) => {
558
+ await new Promise((resolve8) => {
569
559
  childProcess.on("close", (code) => {
570
560
  status = code ?? 0;
571
- resolve7();
561
+ resolve8();
572
562
  });
573
563
  });
574
564
  if (error) {
@@ -610,19 +600,19 @@ var objectProto = Object.prototype;
610
600
  var hasOwnProperty = objectProto.hasOwnProperty;
611
601
  var nativeObjectToString = objectProto.toString;
612
602
  var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
613
- function getRawTag(value) {
614
- var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
603
+ function getRawTag(value2) {
604
+ var isOwn = hasOwnProperty.call(value2, symToStringTag), tag = value2[symToStringTag];
615
605
  try {
616
- value[symToStringTag] = void 0;
606
+ value2[symToStringTag] = void 0;
617
607
  var unmasked = true;
618
608
  } catch (e) {
619
609
  }
620
- var result = nativeObjectToString.call(value);
610
+ var result = nativeObjectToString.call(value2);
621
611
  if (unmasked) {
622
612
  if (isOwn) {
623
- value[symToStringTag] = tag;
613
+ value2[symToStringTag] = tag;
624
614
  } else {
625
- delete value[symToStringTag];
615
+ delete value2[symToStringTag];
626
616
  }
627
617
  }
628
618
  return result;
@@ -632,8 +622,8 @@ var getRawTag_default = getRawTag;
632
622
  // ../node_modules/lodash-es/_objectToString.js
633
623
  var objectProto2 = Object.prototype;
634
624
  var nativeObjectToString2 = objectProto2.toString;
635
- function objectToString(value) {
636
- return nativeObjectToString2.call(value);
625
+ function objectToString(value2) {
626
+ return nativeObjectToString2.call(value2);
637
627
  }
638
628
  var objectToString_default = objectToString;
639
629
 
@@ -641,24 +631,24 @@ var objectToString_default = objectToString;
641
631
  var nullTag = "[object Null]";
642
632
  var undefinedTag = "[object Undefined]";
643
633
  var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
644
- function baseGetTag(value) {
645
- if (value == null) {
646
- return value === void 0 ? undefinedTag : nullTag;
634
+ function baseGetTag(value2) {
635
+ if (value2 == null) {
636
+ return value2 === void 0 ? undefinedTag : nullTag;
647
637
  }
648
- return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
638
+ return symToStringTag2 && symToStringTag2 in Object(value2) ? getRawTag_default(value2) : objectToString_default(value2);
649
639
  }
650
640
  var baseGetTag_default = baseGetTag;
651
641
 
652
642
  // ../node_modules/lodash-es/isObjectLike.js
653
- function isObjectLike(value) {
654
- return value != null && typeof value == "object";
643
+ function isObjectLike(value2) {
644
+ return value2 != null && typeof value2 == "object";
655
645
  }
656
646
  var isObjectLike_default = isObjectLike;
657
647
 
658
648
  // ../node_modules/lodash-es/isSymbol.js
659
649
  var symbolTag = "[object Symbol]";
660
- function isSymbol(value) {
661
- return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
650
+ function isSymbol(value2) {
651
+ return typeof value2 == "symbol" || isObjectLike_default(value2) && baseGetTag_default(value2) == symbolTag;
662
652
  }
663
653
  var isSymbol_default = isSymbol;
664
654
 
@@ -680,31 +670,31 @@ var isArray_default = isArray;
680
670
  var INFINITY = 1 / 0;
681
671
  var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
682
672
  var symbolToString = symbolProto ? symbolProto.toString : void 0;
683
- function baseToString(value) {
684
- if (typeof value == "string") {
685
- return value;
673
+ function baseToString(value2) {
674
+ if (typeof value2 == "string") {
675
+ return value2;
686
676
  }
687
- if (isArray_default(value)) {
688
- return arrayMap_default(value, baseToString) + "";
677
+ if (isArray_default(value2)) {
678
+ return arrayMap_default(value2, baseToString) + "";
689
679
  }
690
- if (isSymbol_default(value)) {
691
- return symbolToString ? symbolToString.call(value) : "";
680
+ if (isSymbol_default(value2)) {
681
+ return symbolToString ? symbolToString.call(value2) : "";
692
682
  }
693
- var result = value + "";
694
- return result == "0" && 1 / value == -INFINITY ? "-0" : result;
683
+ var result = value2 + "";
684
+ return result == "0" && 1 / value2 == -INFINITY ? "-0" : result;
695
685
  }
696
686
  var baseToString_default = baseToString;
697
687
 
698
688
  // ../node_modules/lodash-es/isObject.js
699
- function isObject(value) {
700
- var type = typeof value;
701
- return value != null && (type == "object" || type == "function");
689
+ function isObject(value2) {
690
+ var type = typeof value2;
691
+ return value2 != null && (type == "object" || type == "function");
702
692
  }
703
693
  var isObject_default = isObject;
704
694
 
705
695
  // ../node_modules/lodash-es/identity.js
706
- function identity(value) {
707
- return value;
696
+ function identity(value2) {
697
+ return value2;
708
698
  }
709
699
  var identity_default = identity;
710
700
 
@@ -713,11 +703,11 @@ var asyncTag = "[object AsyncFunction]";
713
703
  var funcTag = "[object Function]";
714
704
  var genTag = "[object GeneratorFunction]";
715
705
  var proxyTag = "[object Proxy]";
716
- function isFunction(value) {
717
- if (!isObject_default(value)) {
706
+ function isFunction(value2) {
707
+ if (!isObject_default(value2)) {
718
708
  return false;
719
709
  }
720
- var tag = baseGetTag_default(value);
710
+ var tag = baseGetTag_default(value2);
721
711
  return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
722
712
  }
723
713
  var isFunction_default = isFunction;
@@ -764,12 +754,12 @@ var hasOwnProperty2 = objectProto3.hasOwnProperty;
764
754
  var reIsNative = RegExp(
765
755
  "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
766
756
  );
767
- function baseIsNative(value) {
768
- if (!isObject_default(value) || isMasked_default(value)) {
757
+ function baseIsNative(value2) {
758
+ if (!isObject_default(value2) || isMasked_default(value2)) {
769
759
  return false;
770
760
  }
771
- var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
772
- return pattern.test(toSource_default(value));
761
+ var pattern = isFunction_default(value2) ? reIsNative : reIsHostCtor;
762
+ return pattern.test(toSource_default(value2));
773
763
  }
774
764
  var baseIsNative_default = baseIsNative;
775
765
 
@@ -781,8 +771,8 @@ var getValue_default = getValue;
781
771
 
782
772
  // ../node_modules/lodash-es/_getNative.js
783
773
  function getNative(object, key) {
784
- var value = getValue_default(object, key);
785
- return baseIsNative_default(value) ? value : void 0;
774
+ var value2 = getValue_default(object, key);
775
+ return baseIsNative_default(value2) ? value2 : void 0;
786
776
  }
787
777
  var getNative_default = getNative;
788
778
 
@@ -859,9 +849,9 @@ function shortOut(func) {
859
849
  var shortOut_default = shortOut;
860
850
 
861
851
  // ../node_modules/lodash-es/constant.js
862
- function constant(value) {
852
+ function constant(value2) {
863
853
  return function() {
864
- return value;
854
+ return value2;
865
855
  };
866
856
  }
867
857
  var constant_default = constant;
@@ -907,41 +897,41 @@ var arrayEach_default = arrayEach;
907
897
  // ../node_modules/lodash-es/_isIndex.js
908
898
  var MAX_SAFE_INTEGER = 9007199254740991;
909
899
  var reIsUint = /^(?:0|[1-9]\d*)$/;
910
- function isIndex(value, length) {
911
- var type = typeof value;
900
+ function isIndex(value2, length) {
901
+ var type = typeof value2;
912
902
  length = length == null ? MAX_SAFE_INTEGER : length;
913
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
903
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value2)) && (value2 > -1 && value2 % 1 == 0 && value2 < length);
914
904
  }
915
905
  var isIndex_default = isIndex;
916
906
 
917
907
  // ../node_modules/lodash-es/_baseAssignValue.js
918
- function baseAssignValue(object, key, value) {
908
+ function baseAssignValue(object, key, value2) {
919
909
  if (key == "__proto__" && defineProperty_default) {
920
910
  defineProperty_default(object, key, {
921
911
  "configurable": true,
922
912
  "enumerable": true,
923
- "value": value,
913
+ "value": value2,
924
914
  "writable": true
925
915
  });
926
916
  } else {
927
- object[key] = value;
917
+ object[key] = value2;
928
918
  }
929
919
  }
930
920
  var baseAssignValue_default = baseAssignValue;
931
921
 
932
922
  // ../node_modules/lodash-es/eq.js
933
- function eq(value, other) {
934
- return value === other || value !== value && other !== other;
923
+ function eq(value2, other) {
924
+ return value2 === other || value2 !== value2 && other !== other;
935
925
  }
936
926
  var eq_default = eq;
937
927
 
938
928
  // ../node_modules/lodash-es/_assignValue.js
939
929
  var objectProto4 = Object.prototype;
940
930
  var hasOwnProperty3 = objectProto4.hasOwnProperty;
941
- function assignValue(object, key, value) {
931
+ function assignValue(object, key, value2) {
942
932
  var objValue = object[key];
943
- if (!(hasOwnProperty3.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
944
- baseAssignValue_default(object, key, value);
933
+ if (!(hasOwnProperty3.call(object, key) && eq_default(objValue, value2)) || value2 === void 0 && !(key in object)) {
934
+ baseAssignValue_default(object, key, value2);
945
935
  }
946
936
  }
947
937
  var assignValue_default = assignValue;
@@ -995,25 +985,25 @@ var baseRest_default = baseRest;
995
985
 
996
986
  // ../node_modules/lodash-es/isLength.js
997
987
  var MAX_SAFE_INTEGER2 = 9007199254740991;
998
- function isLength(value) {
999
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
988
+ function isLength(value2) {
989
+ return typeof value2 == "number" && value2 > -1 && value2 % 1 == 0 && value2 <= MAX_SAFE_INTEGER2;
1000
990
  }
1001
991
  var isLength_default = isLength;
1002
992
 
1003
993
  // ../node_modules/lodash-es/isArrayLike.js
1004
- function isArrayLike(value) {
1005
- return value != null && isLength_default(value.length) && !isFunction_default(value);
994
+ function isArrayLike(value2) {
995
+ return value2 != null && isLength_default(value2.length) && !isFunction_default(value2);
1006
996
  }
1007
997
  var isArrayLike_default = isArrayLike;
1008
998
 
1009
999
  // ../node_modules/lodash-es/_isIterateeCall.js
1010
- function isIterateeCall(value, index, object) {
1000
+ function isIterateeCall(value2, index, object) {
1011
1001
  if (!isObject_default(object)) {
1012
1002
  return false;
1013
1003
  }
1014
1004
  var type = typeof index;
1015
1005
  if (type == "number" ? isArrayLike_default(object) && isIndex_default(index, object.length) : type == "string" && index in object) {
1016
- return eq_default(object[index], value);
1006
+ return eq_default(object[index], value2);
1017
1007
  }
1018
1008
  return false;
1019
1009
  }
@@ -1042,9 +1032,9 @@ var createAssigner_default = createAssigner;
1042
1032
 
1043
1033
  // ../node_modules/lodash-es/_isPrototype.js
1044
1034
  var objectProto5 = Object.prototype;
1045
- function isPrototype(value) {
1046
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
1047
- return value === proto;
1035
+ function isPrototype(value2) {
1036
+ var Ctor = value2 && value2.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
1037
+ return value2 === proto;
1048
1038
  }
1049
1039
  var isPrototype_default = isPrototype;
1050
1040
 
@@ -1060,8 +1050,8 @@ var baseTimes_default = baseTimes;
1060
1050
 
1061
1051
  // ../node_modules/lodash-es/_baseIsArguments.js
1062
1052
  var argsTag = "[object Arguments]";
1063
- function baseIsArguments(value) {
1064
- return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
1053
+ function baseIsArguments(value2) {
1054
+ return isObjectLike_default(value2) && baseGetTag_default(value2) == argsTag;
1065
1055
  }
1066
1056
  var baseIsArguments_default = baseIsArguments;
1067
1057
 
@@ -1071,8 +1061,8 @@ var hasOwnProperty4 = objectProto6.hasOwnProperty;
1071
1061
  var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
1072
1062
  var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
1073
1063
  return arguments;
1074
- }()) ? baseIsArguments_default : function(value) {
1075
- return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
1064
+ }()) ? baseIsArguments_default : function(value2) {
1065
+ return isObjectLike_default(value2) && hasOwnProperty4.call(value2, "callee") && !propertyIsEnumerable.call(value2, "callee");
1076
1066
  };
1077
1067
  var isArguments_default = isArguments;
1078
1068
 
@@ -1119,15 +1109,15 @@ var uint32Tag = "[object Uint32Array]";
1119
1109
  var typedArrayTags = {};
1120
1110
  typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
1121
1111
  typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
1122
- function baseIsTypedArray(value) {
1123
- return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
1112
+ function baseIsTypedArray(value2) {
1113
+ return isObjectLike_default(value2) && isLength_default(value2.length) && !!typedArrayTags[baseGetTag_default(value2)];
1124
1114
  }
1125
1115
  var baseIsTypedArray_default = baseIsTypedArray;
1126
1116
 
1127
1117
  // ../node_modules/lodash-es/_baseUnary.js
1128
1118
  function baseUnary(func) {
1129
- return function(value) {
1130
- return func(value);
1119
+ return function(value2) {
1120
+ return func(value2);
1131
1121
  };
1132
1122
  }
1133
1123
  var baseUnary_default = baseUnary;
@@ -1157,10 +1147,10 @@ var isTypedArray_default = isTypedArray;
1157
1147
  // ../node_modules/lodash-es/_arrayLikeKeys.js
1158
1148
  var objectProto7 = Object.prototype;
1159
1149
  var hasOwnProperty5 = objectProto7.hasOwnProperty;
1160
- function arrayLikeKeys(value, inherited) {
1161
- var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
1162
- for (var key in value) {
1163
- if ((inherited || hasOwnProperty5.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
1150
+ function arrayLikeKeys(value2, inherited) {
1151
+ var isArr = isArray_default(value2), isArg = !isArr && isArguments_default(value2), isBuff = !isArr && !isArg && isBuffer_default(value2), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value2), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value2.length, String) : [], length = result.length;
1152
+ for (var key in value2) {
1153
+ if ((inherited || hasOwnProperty5.call(value2, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
1164
1154
  (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1165
1155
  isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1166
1156
  isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
@@ -1245,15 +1235,15 @@ var keysIn_default = keysIn;
1245
1235
  // ../node_modules/lodash-es/_isKey.js
1246
1236
  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
1247
1237
  var reIsPlainProp = /^\w*$/;
1248
- function isKey(value, object) {
1249
- if (isArray_default(value)) {
1238
+ function isKey(value2, object) {
1239
+ if (isArray_default(value2)) {
1250
1240
  return false;
1251
1241
  }
1252
- var type = typeof value;
1253
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol_default(value)) {
1242
+ var type = typeof value2;
1243
+ if (type == "number" || type == "symbol" || type == "boolean" || value2 == null || isSymbol_default(value2)) {
1254
1244
  return true;
1255
1245
  }
1256
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
1246
+ return reIsPlainProp.test(value2) || !reIsDeepProp.test(value2) || object != null && value2 in Object(object);
1257
1247
  }
1258
1248
  var isKey_default = isKey;
1259
1249
 
@@ -1301,10 +1291,10 @@ var hashHas_default = hashHas;
1301
1291
 
1302
1292
  // ../node_modules/lodash-es/_hashSet.js
1303
1293
  var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
1304
- function hashSet(key, value) {
1294
+ function hashSet(key, value2) {
1305
1295
  var data = this.__data__;
1306
1296
  this.size += this.has(key) ? 0 : 1;
1307
- data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
1297
+ data[key] = nativeCreate_default && value2 === void 0 ? HASH_UNDEFINED2 : value2;
1308
1298
  return this;
1309
1299
  }
1310
1300
  var hashSet_default = hashSet;
@@ -1377,13 +1367,13 @@ function listCacheHas(key) {
1377
1367
  var listCacheHas_default = listCacheHas;
1378
1368
 
1379
1369
  // ../node_modules/lodash-es/_listCacheSet.js
1380
- function listCacheSet(key, value) {
1370
+ function listCacheSet(key, value2) {
1381
1371
  var data = this.__data__, index = assocIndexOf_default(data, key);
1382
1372
  if (index < 0) {
1383
1373
  ++this.size;
1384
- data.push([key, value]);
1374
+ data.push([key, value2]);
1385
1375
  } else {
1386
- data[index][1] = value;
1376
+ data[index][1] = value2;
1387
1377
  }
1388
1378
  return this;
1389
1379
  }
@@ -1421,9 +1411,9 @@ function mapCacheClear() {
1421
1411
  var mapCacheClear_default = mapCacheClear;
1422
1412
 
1423
1413
  // ../node_modules/lodash-es/_isKeyable.js
1424
- function isKeyable(value) {
1425
- var type = typeof value;
1426
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
1414
+ function isKeyable(value2) {
1415
+ var type = typeof value2;
1416
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value2 !== "__proto__" : value2 === null;
1427
1417
  }
1428
1418
  var isKeyable_default = isKeyable;
1429
1419
 
@@ -1455,9 +1445,9 @@ function mapCacheHas(key) {
1455
1445
  var mapCacheHas_default = mapCacheHas;
1456
1446
 
1457
1447
  // ../node_modules/lodash-es/_mapCacheSet.js
1458
- function mapCacheSet(key, value) {
1448
+ function mapCacheSet(key, value2) {
1459
1449
  var data = getMapData_default(this, key), size = data.size;
1460
- data.set(key, value);
1450
+ data.set(key, value2);
1461
1451
  this.size += data.size == size ? 0 : 1;
1462
1452
  return this;
1463
1453
  }
@@ -1530,28 +1520,28 @@ var stringToPath = memoizeCapped_default(function(string) {
1530
1520
  var stringToPath_default = stringToPath;
1531
1521
 
1532
1522
  // ../node_modules/lodash-es/toString.js
1533
- function toString(value) {
1534
- return value == null ? "" : baseToString_default(value);
1523
+ function toString(value2) {
1524
+ return value2 == null ? "" : baseToString_default(value2);
1535
1525
  }
1536
1526
  var toString_default = toString;
1537
1527
 
1538
1528
  // ../node_modules/lodash-es/_castPath.js
1539
- function castPath(value, object) {
1540
- if (isArray_default(value)) {
1541
- return value;
1529
+ function castPath(value2, object) {
1530
+ if (isArray_default(value2)) {
1531
+ return value2;
1542
1532
  }
1543
- return isKey_default(value, object) ? [value] : stringToPath_default(toString_default(value));
1533
+ return isKey_default(value2, object) ? [value2] : stringToPath_default(toString_default(value2));
1544
1534
  }
1545
1535
  var castPath_default = castPath;
1546
1536
 
1547
1537
  // ../node_modules/lodash-es/_toKey.js
1548
1538
  var INFINITY2 = 1 / 0;
1549
- function toKey(value) {
1550
- if (typeof value == "string" || isSymbol_default(value)) {
1551
- return value;
1539
+ function toKey(value2) {
1540
+ if (typeof value2 == "string" || isSymbol_default(value2)) {
1541
+ return value2;
1552
1542
  }
1553
- var result = value + "";
1554
- return result == "0" && 1 / value == -INFINITY2 ? "-0" : result;
1543
+ var result = value2 + "";
1544
+ return result == "0" && 1 / value2 == -INFINITY2 ? "-0" : result;
1555
1545
  }
1556
1546
  var toKey_default = toKey;
1557
1547
 
@@ -1585,8 +1575,8 @@ var arrayPush_default = arrayPush;
1585
1575
 
1586
1576
  // ../node_modules/lodash-es/_isFlattenable.js
1587
1577
  var spreadableSymbol = Symbol_default ? Symbol_default.isConcatSpreadable : void 0;
1588
- function isFlattenable(value) {
1589
- return isArray_default(value) || isArguments_default(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
1578
+ function isFlattenable(value2) {
1579
+ return isArray_default(value2) || isArguments_default(value2) || !!(spreadableSymbol && value2 && value2[spreadableSymbol]);
1590
1580
  }
1591
1581
  var isFlattenable_default = isFlattenable;
1592
1582
 
@@ -1596,15 +1586,15 @@ function baseFlatten(array, depth, predicate, isStrict, result) {
1596
1586
  predicate || (predicate = isFlattenable_default);
1597
1587
  result || (result = []);
1598
1588
  while (++index < length) {
1599
- var value = array[index];
1600
- if (depth > 0 && predicate(value)) {
1589
+ var value2 = array[index];
1590
+ if (depth > 0 && predicate(value2)) {
1601
1591
  if (depth > 1) {
1602
- baseFlatten(value, depth - 1, predicate, isStrict, result);
1592
+ baseFlatten(value2, depth - 1, predicate, isStrict, result);
1603
1593
  } else {
1604
- arrayPush_default(result, value);
1594
+ arrayPush_default(result, value2);
1605
1595
  }
1606
1596
  } else if (!isStrict) {
1607
- result[result.length] = value;
1597
+ result[result.length] = value2;
1608
1598
  }
1609
1599
  }
1610
1600
  return result;
@@ -1635,11 +1625,11 @@ var objectProto12 = Object.prototype;
1635
1625
  var funcToString3 = funcProto3.toString;
1636
1626
  var hasOwnProperty10 = objectProto12.hasOwnProperty;
1637
1627
  var objectCtorString = funcToString3.call(Object);
1638
- function isPlainObject(value) {
1639
- if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag2) {
1628
+ function isPlainObject(value2) {
1629
+ if (!isObjectLike_default(value2) || baseGetTag_default(value2) != objectTag2) {
1640
1630
  return false;
1641
1631
  }
1642
- var proto = getPrototype_default(value);
1632
+ var proto = getPrototype_default(value2);
1643
1633
  if (proto === null) {
1644
1634
  return true;
1645
1635
  }
@@ -1697,18 +1687,18 @@ var stackHas_default = stackHas;
1697
1687
 
1698
1688
  // ../node_modules/lodash-es/_stackSet.js
1699
1689
  var LARGE_ARRAY_SIZE = 200;
1700
- function stackSet(key, value) {
1690
+ function stackSet(key, value2) {
1701
1691
  var data = this.__data__;
1702
1692
  if (data instanceof ListCache_default) {
1703
1693
  var pairs = data.__data__;
1704
1694
  if (!Map_default || pairs.length < LARGE_ARRAY_SIZE - 1) {
1705
- pairs.push([key, value]);
1695
+ pairs.push([key, value2]);
1706
1696
  this.size = ++data.size;
1707
1697
  return this;
1708
1698
  }
1709
1699
  data = this.__data__ = new MapCache_default(pairs);
1710
1700
  }
1711
- data.set(key, value);
1701
+ data.set(key, value2);
1712
1702
  this.size = data.size;
1713
1703
  return this;
1714
1704
  }
@@ -1758,9 +1748,9 @@ var cloneBuffer_default = cloneBuffer;
1758
1748
  function arrayFilter(array, predicate) {
1759
1749
  var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
1760
1750
  while (++index < length) {
1761
- var value = array[index];
1762
- if (predicate(value, index, array)) {
1763
- result[resIndex++] = value;
1751
+ var value2 = array[index];
1752
+ if (predicate(value2, index, array)) {
1753
+ result[resIndex++] = value2;
1764
1754
  }
1765
1755
  }
1766
1756
  return result;
@@ -1857,8 +1847,8 @@ var setCtorString = toSource_default(Set_default);
1857
1847
  var weakMapCtorString = toSource_default(WeakMap_default);
1858
1848
  var getTag = baseGetTag_default;
1859
1849
  if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag2 || Map_default && getTag(new Map_default()) != mapTag2 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag2 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
1860
- getTag = function(value) {
1861
- var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
1850
+ getTag = function(value2) {
1851
+ var result = baseGetTag_default(value2), Ctor = result == objectTag3 ? value2.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
1862
1852
  if (ctorString) {
1863
1853
  switch (ctorString) {
1864
1854
  case dataViewCtorString:
@@ -1997,8 +1987,8 @@ var initCloneObject_default = initCloneObject;
1997
1987
 
1998
1988
  // ../node_modules/lodash-es/_baseIsMap.js
1999
1989
  var mapTag4 = "[object Map]";
2000
- function baseIsMap(value) {
2001
- return isObjectLike_default(value) && getTag_default(value) == mapTag4;
1990
+ function baseIsMap(value2) {
1991
+ return isObjectLike_default(value2) && getTag_default(value2) == mapTag4;
2002
1992
  }
2003
1993
  var baseIsMap_default = baseIsMap;
2004
1994
 
@@ -2009,8 +1999,8 @@ var isMap_default = isMap;
2009
1999
 
2010
2000
  // ../node_modules/lodash-es/_baseIsSet.js
2011
2001
  var setTag4 = "[object Set]";
2012
- function baseIsSet(value) {
2013
- return isObjectLike_default(value) && getTag_default(value) == setTag4;
2002
+ function baseIsSet(value2) {
2003
+ return isObjectLike_default(value2) && getTag_default(value2) == setTag4;
2014
2004
  }
2015
2005
  var baseIsSet_default = baseIsSet;
2016
2006
 
@@ -2052,63 +2042,63 @@ var uint32Tag3 = "[object Uint32Array]";
2052
2042
  var cloneableTags = {};
2053
2043
  cloneableTags[argsTag3] = cloneableTags[arrayTag2] = cloneableTags[arrayBufferTag3] = cloneableTags[dataViewTag4] = cloneableTags[boolTag3] = cloneableTags[dateTag3] = cloneableTags[float32Tag3] = cloneableTags[float64Tag3] = cloneableTags[int8Tag3] = cloneableTags[int16Tag3] = cloneableTags[int32Tag3] = cloneableTags[mapTag5] = cloneableTags[numberTag3] = cloneableTags[objectTag4] = cloneableTags[regexpTag3] = cloneableTags[setTag5] = cloneableTags[stringTag3] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
2054
2044
  cloneableTags[errorTag2] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
2055
- function baseClone(value, bitmask, customizer, key, object, stack) {
2045
+ function baseClone(value2, bitmask, customizer, key, object, stack) {
2056
2046
  var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
2057
2047
  if (customizer) {
2058
- result = object ? customizer(value, key, object, stack) : customizer(value);
2048
+ result = object ? customizer(value2, key, object, stack) : customizer(value2);
2059
2049
  }
2060
2050
  if (result !== void 0) {
2061
2051
  return result;
2062
2052
  }
2063
- if (!isObject_default(value)) {
2064
- return value;
2053
+ if (!isObject_default(value2)) {
2054
+ return value2;
2065
2055
  }
2066
- var isArr = isArray_default(value);
2056
+ var isArr = isArray_default(value2);
2067
2057
  if (isArr) {
2068
- result = initCloneArray_default(value);
2058
+ result = initCloneArray_default(value2);
2069
2059
  if (!isDeep) {
2070
- return copyArray_default(value, result);
2060
+ return copyArray_default(value2, result);
2071
2061
  }
2072
2062
  } else {
2073
- var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
2074
- if (isBuffer_default(value)) {
2075
- return cloneBuffer_default(value, isDeep);
2063
+ var tag = getTag_default(value2), isFunc = tag == funcTag3 || tag == genTag2;
2064
+ if (isBuffer_default(value2)) {
2065
+ return cloneBuffer_default(value2, isDeep);
2076
2066
  }
2077
2067
  if (tag == objectTag4 || tag == argsTag3 || isFunc && !object) {
2078
- result = isFlat || isFunc ? {} : initCloneObject_default(value);
2068
+ result = isFlat || isFunc ? {} : initCloneObject_default(value2);
2079
2069
  if (!isDeep) {
2080
- return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
2070
+ return isFlat ? copySymbolsIn_default(value2, baseAssignIn_default(result, value2)) : copySymbols_default(value2, baseAssign_default(result, value2));
2081
2071
  }
2082
2072
  } else {
2083
2073
  if (!cloneableTags[tag]) {
2084
- return object ? value : {};
2074
+ return object ? value2 : {};
2085
2075
  }
2086
- result = initCloneByTag_default(value, tag, isDeep);
2076
+ result = initCloneByTag_default(value2, tag, isDeep);
2087
2077
  }
2088
2078
  }
2089
2079
  stack || (stack = new Stack_default());
2090
- var stacked = stack.get(value);
2080
+ var stacked = stack.get(value2);
2091
2081
  if (stacked) {
2092
2082
  return stacked;
2093
2083
  }
2094
- stack.set(value, result);
2095
- if (isSet_default(value)) {
2096
- value.forEach(function(subValue) {
2097
- result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2084
+ stack.set(value2, result);
2085
+ if (isSet_default(value2)) {
2086
+ value2.forEach(function(subValue) {
2087
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value2, stack));
2098
2088
  });
2099
- } else if (isMap_default(value)) {
2100
- value.forEach(function(subValue, key2) {
2101
- result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
2089
+ } else if (isMap_default(value2)) {
2090
+ value2.forEach(function(subValue, key2) {
2091
+ result.set(key2, baseClone(subValue, bitmask, customizer, key2, value2, stack));
2102
2092
  });
2103
2093
  }
2104
2094
  var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
2105
- var props = isArr ? void 0 : keysFunc(value);
2106
- arrayEach_default(props || value, function(subValue, key2) {
2095
+ var props = isArr ? void 0 : keysFunc(value2);
2096
+ arrayEach_default(props || value2, function(subValue, key2) {
2107
2097
  if (props) {
2108
2098
  key2 = subValue;
2109
- subValue = value[key2];
2099
+ subValue = value2[key2];
2110
2100
  }
2111
- assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
2101
+ assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value2, stack));
2112
2102
  });
2113
2103
  return result;
2114
2104
  }
@@ -2116,15 +2106,15 @@ var baseClone_default = baseClone;
2116
2106
 
2117
2107
  // ../node_modules/lodash-es/_setCacheAdd.js
2118
2108
  var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
2119
- function setCacheAdd(value) {
2120
- this.__data__.set(value, HASH_UNDEFINED3);
2109
+ function setCacheAdd(value2) {
2110
+ this.__data__.set(value2, HASH_UNDEFINED3);
2121
2111
  return this;
2122
2112
  }
2123
2113
  var setCacheAdd_default = setCacheAdd;
2124
2114
 
2125
2115
  // ../node_modules/lodash-es/_setCacheHas.js
2126
- function setCacheHas(value) {
2127
- return this.__data__.has(value);
2116
+ function setCacheHas(value2) {
2117
+ return this.__data__.has(value2);
2128
2118
  }
2129
2119
  var setCacheHas_default = setCacheHas;
2130
2120
 
@@ -2209,8 +2199,8 @@ var equalArrays_default = equalArrays;
2209
2199
  // ../node_modules/lodash-es/_mapToArray.js
2210
2200
  function mapToArray(map) {
2211
2201
  var index = -1, result = Array(map.size);
2212
- map.forEach(function(value, key) {
2213
- result[++index] = [key, value];
2202
+ map.forEach(function(value2, key) {
2203
+ result[++index] = [key, value2];
2214
2204
  });
2215
2205
  return result;
2216
2206
  }
@@ -2219,8 +2209,8 @@ var mapToArray_default = mapToArray;
2219
2209
  // ../node_modules/lodash-es/_setToArray.js
2220
2210
  function setToArray(set) {
2221
2211
  var index = -1, result = Array(set.size);
2222
- set.forEach(function(value) {
2223
- result[++index] = value;
2212
+ set.forEach(function(value2) {
2213
+ result[++index] = value2;
2224
2214
  });
2225
2215
  return result;
2226
2216
  }
@@ -2379,14 +2369,14 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2379
2369
  var baseIsEqualDeep_default = baseIsEqualDeep;
2380
2370
 
2381
2371
  // ../node_modules/lodash-es/_baseIsEqual.js
2382
- function baseIsEqual(value, other, bitmask, customizer, stack) {
2383
- if (value === other) {
2372
+ function baseIsEqual(value2, other, bitmask, customizer, stack) {
2373
+ if (value2 === other) {
2384
2374
  return true;
2385
2375
  }
2386
- if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
2387
- return value !== value && other !== other;
2376
+ if (value2 == null || other == null || !isObjectLike_default(value2) && !isObjectLike_default(other)) {
2377
+ return value2 !== value2 && other !== other;
2388
2378
  }
2389
- return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
2379
+ return baseIsEqualDeep_default(value2, other, bitmask, customizer, baseIsEqual, stack);
2390
2380
  }
2391
2381
  var baseIsEqual_default = baseIsEqual;
2392
2382
 
@@ -2427,8 +2417,8 @@ function baseIsMatch(object, source, matchData, customizer) {
2427
2417
  var baseIsMatch_default = baseIsMatch;
2428
2418
 
2429
2419
  // ../node_modules/lodash-es/_isStrictComparable.js
2430
- function isStrictComparable(value) {
2431
- return value === value && !isObject_default(value);
2420
+ function isStrictComparable(value2) {
2421
+ return value2 === value2 && !isObject_default(value2);
2432
2422
  }
2433
2423
  var isStrictComparable_default = isStrictComparable;
2434
2424
 
@@ -2436,8 +2426,8 @@ var isStrictComparable_default = isStrictComparable;
2436
2426
  function getMatchData(object) {
2437
2427
  var result = keys_default(object), length = result.length;
2438
2428
  while (length--) {
2439
- var key = result[length], value = object[key];
2440
- result[length] = [key, value, isStrictComparable_default(value)];
2429
+ var key = result[length], value2 = object[key];
2430
+ result[length] = [key, value2, isStrictComparable_default(value2)];
2441
2431
  }
2442
2432
  return result;
2443
2433
  }
@@ -2534,17 +2524,17 @@ function property(path2) {
2534
2524
  var property_default = property;
2535
2525
 
2536
2526
  // ../node_modules/lodash-es/_baseIteratee.js
2537
- function baseIteratee(value) {
2538
- if (typeof value == "function") {
2539
- return value;
2527
+ function baseIteratee(value2) {
2528
+ if (typeof value2 == "function") {
2529
+ return value2;
2540
2530
  }
2541
- if (value == null) {
2531
+ if (value2 == null) {
2542
2532
  return identity_default;
2543
2533
  }
2544
- if (typeof value == "object") {
2545
- return isArray_default(value) ? baseMatchesProperty_default(value[0], value[1]) : baseMatches_default(value);
2534
+ if (typeof value2 == "object") {
2535
+ return isArray_default(value2) ? baseMatchesProperty_default(value2[0], value2[1]) : baseMatches_default(value2);
2546
2536
  }
2547
- return property_default(value);
2537
+ return property_default(value2);
2548
2538
  }
2549
2539
  var baseIteratee_default = baseIteratee;
2550
2540
 
@@ -2598,16 +2588,16 @@ var baseEach = createBaseEach_default(baseForOwn_default);
2598
2588
  var baseEach_default = baseEach;
2599
2589
 
2600
2590
  // ../node_modules/lodash-es/_assignMergeValue.js
2601
- function assignMergeValue(object, key, value) {
2602
- if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
2603
- baseAssignValue_default(object, key, value);
2591
+ function assignMergeValue(object, key, value2) {
2592
+ if (value2 !== void 0 && !eq_default(object[key], value2) || value2 === void 0 && !(key in object)) {
2593
+ baseAssignValue_default(object, key, value2);
2604
2594
  }
2605
2595
  }
2606
2596
  var assignMergeValue_default = assignMergeValue;
2607
2597
 
2608
2598
  // ../node_modules/lodash-es/isArrayLikeObject.js
2609
- function isArrayLikeObject(value) {
2610
- return isObjectLike_default(value) && isArrayLike_default(value);
2599
+ function isArrayLikeObject(value2) {
2600
+ return isObjectLike_default(value2) && isArrayLike_default(value2);
2611
2601
  }
2612
2602
  var isArrayLikeObject_default = isArrayLikeObject;
2613
2603
 
@@ -2624,8 +2614,8 @@ function safeGet(object, key) {
2624
2614
  var safeGet_default = safeGet;
2625
2615
 
2626
2616
  // ../node_modules/lodash-es/toPlainObject.js
2627
- function toPlainObject(value) {
2628
- return copyObject_default(value, keysIn_default(value));
2617
+ function toPlainObject(value2) {
2618
+ return copyObject_default(value2, keysIn_default(value2));
2629
2619
  }
2630
2620
  var toPlainObject_default = toPlainObject;
2631
2621
 
@@ -2705,8 +2695,8 @@ var last_default = last;
2705
2695
  // ../node_modules/lodash-es/_baseMap.js
2706
2696
  function baseMap(collection, iteratee) {
2707
2697
  var index = -1, result = isArrayLike_default(collection) ? Array(collection.length) : [];
2708
- baseEach_default(collection, function(value, key, collection2) {
2709
- result[++index] = iteratee(value, key, collection2);
2698
+ baseEach_default(collection, function(value2, key, collection2) {
2699
+ result[++index] = iteratee(value2, key, collection2);
2710
2700
  });
2711
2701
  return result;
2712
2702
  }
@@ -2719,8 +2709,8 @@ function parent(object, path2) {
2719
2709
  var parent_default = parent;
2720
2710
 
2721
2711
  // ../node_modules/lodash-es/isNil.js
2722
- function isNil(value) {
2723
- return value == null;
2712
+ function isNil(value2) {
2713
+ return value2 == null;
2724
2714
  }
2725
2715
  var isNil_default = isNil;
2726
2716
 
@@ -2762,8 +2752,8 @@ function baseUnset(object, path2) {
2762
2752
  var baseUnset_default = baseUnset;
2763
2753
 
2764
2754
  // ../node_modules/lodash-es/_customOmitClone.js
2765
- function customOmitClone(value) {
2766
- return isPlainObject_default(value) ? void 0 : value;
2755
+ function customOmitClone(value2) {
2756
+ return isPlainObject_default(value2) ? void 0 : value2;
2767
2757
  }
2768
2758
  var customOmitClone_default = customOmitClone;
2769
2759
 
@@ -2795,14 +2785,14 @@ var omit = flatRest_default(function(object, paths) {
2795
2785
  var omit_default = omit;
2796
2786
 
2797
2787
  // ../node_modules/lodash-es/_baseSet.js
2798
- function baseSet(object, path2, value, customizer) {
2788
+ function baseSet(object, path2, value2, customizer) {
2799
2789
  if (!isObject_default(object)) {
2800
2790
  return object;
2801
2791
  }
2802
2792
  path2 = castPath_default(path2, object);
2803
2793
  var index = -1, length = path2.length, lastIndex = length - 1, nested = object;
2804
2794
  while (nested != null && ++index < length) {
2805
- var key = toKey_default(path2[index]), newValue = value;
2795
+ var key = toKey_default(path2[index]), newValue = value2;
2806
2796
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
2807
2797
  return object;
2808
2798
  }
@@ -2824,9 +2814,9 @@ var baseSet_default = baseSet;
2824
2814
  function basePickBy(object, paths, predicate) {
2825
2815
  var index = -1, length = paths.length, result = {};
2826
2816
  while (++index < length) {
2827
- var path2 = paths[index], value = baseGet_default(object, path2);
2828
- if (predicate(value, path2)) {
2829
- baseSet_default(result, castPath_default(path2, object), value);
2817
+ var path2 = paths[index], value2 = baseGet_default(object, path2);
2818
+ if (predicate(value2, path2)) {
2819
+ baseSet_default(result, castPath_default(path2, object), value2);
2830
2820
  }
2831
2821
  }
2832
2822
  return result;
@@ -2842,8 +2832,8 @@ function pickBy(object, predicate) {
2842
2832
  return [prop];
2843
2833
  });
2844
2834
  predicate = baseIteratee_default(predicate);
2845
- return basePickBy_default(object, props, function(value, path2) {
2846
- return predicate(value, path2[0]);
2835
+ return basePickBy_default(object, props, function(value2, path2) {
2836
+ return predicate(value2, path2[0]);
2847
2837
  });
2848
2838
  }
2849
2839
  var pickBy_default = pickBy;
@@ -2866,14 +2856,14 @@ function baseSortBy(array, comparer) {
2866
2856
  var baseSortBy_default = baseSortBy;
2867
2857
 
2868
2858
  // ../node_modules/lodash-es/_compareAscending.js
2869
- function compareAscending(value, other) {
2870
- if (value !== other) {
2871
- var valIsDefined = value !== void 0, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol_default(value);
2859
+ function compareAscending(value2, other) {
2860
+ if (value2 !== other) {
2861
+ var valIsDefined = value2 !== void 0, valIsNull = value2 === null, valIsReflexive = value2 === value2, valIsSymbol = isSymbol_default(value2);
2872
2862
  var othIsDefined = other !== void 0, othIsNull = other === null, othIsReflexive = other === other, othIsSymbol = isSymbol_default(other);
2873
- if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
2863
+ if (!othIsNull && !othIsSymbol && !valIsSymbol && value2 > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
2874
2864
  return 1;
2875
2865
  }
2876
- if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
2866
+ if (!valIsNull && !valIsSymbol && !othIsSymbol && value2 < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
2877
2867
  return -1;
2878
2868
  }
2879
2869
  }
@@ -2903,8 +2893,8 @@ function baseOrderBy(collection, iteratees, orders) {
2903
2893
  if (iteratees.length) {
2904
2894
  iteratees = arrayMap_default(iteratees, function(iteratee) {
2905
2895
  if (isArray_default(iteratee)) {
2906
- return function(value) {
2907
- return baseGet_default(value, iteratee.length === 1 ? iteratee[0] : iteratee);
2896
+ return function(value2) {
2897
+ return baseGet_default(value2, iteratee.length === 1 ? iteratee[0] : iteratee);
2908
2898
  };
2909
2899
  }
2910
2900
  return iteratee;
@@ -2914,11 +2904,11 @@ function baseOrderBy(collection, iteratees, orders) {
2914
2904
  }
2915
2905
  var index = -1;
2916
2906
  iteratees = arrayMap_default(iteratees, baseUnary_default(baseIteratee_default));
2917
- var result = baseMap_default(collection, function(value, key, collection2) {
2907
+ var result = baseMap_default(collection, function(value2, key, collection2) {
2918
2908
  var criteria = arrayMap_default(iteratees, function(iteratee) {
2919
- return iteratee(value);
2909
+ return iteratee(value2);
2920
2910
  });
2921
- return { "criteria": criteria, "index": ++index, "value": value };
2911
+ return { "criteria": criteria, "index": ++index, "value": value2 };
2922
2912
  });
2923
2913
  return baseSortBy_default(result, function(object, other) {
2924
2914
  return compareMultiple_default(object, other, orders);
@@ -2928,7 +2918,7 @@ var baseOrderBy_default = baseOrderBy;
2928
2918
 
2929
2919
  // ../node_modules/lodash-es/_basePick.js
2930
2920
  function basePick(object, paths) {
2931
- return basePickBy_default(object, paths, function(value, path2) {
2921
+ return basePickBy_default(object, paths, function(value2, path2) {
2932
2922
  return hasIn_default(object, path2);
2933
2923
  });
2934
2924
  }
@@ -3246,18 +3236,26 @@ function correctStringIdent(src, ident) {
3246
3236
  return result;
3247
3237
  }
3248
3238
 
3239
+ // dist/utils/read-config.js
3240
+ var import_node_path = require("node:path");
3241
+ async function readConfig(options) {
3242
+ const resolvePath = (...paths) => (0, import_node_path.resolve)(options.cwd, ...paths);
3243
+ const config = await readNapiConfig(resolvePath(options.configPath ?? options.packageJsonPath ?? "package.json"), options.configPath ? resolvePath(options.configPath) : void 0);
3244
+ return config;
3245
+ }
3246
+
3249
3247
  // dist/api/artifacts.js
3250
3248
  var debug2 = debugFactory("artifacts");
3251
3249
  async function collectArtifacts(userOptions) {
3252
3250
  const options = applyDefaultArtifactsOptions(userOptions);
3253
- const packageJsonPath = (0, import_node_path.join)(options.cwd, options.packageJsonPath);
3251
+ const packageJsonPath = (0, import_node_path2.join)(options.cwd, options.packageJsonPath);
3254
3252
  const { targets, binaryName, packageName } = await readNapiConfig(packageJsonPath);
3255
- const distDirs = targets.map((platform) => (0, import_node_path.join)(options.cwd, options.npmDir, platform.platformArchABI));
3253
+ const distDirs = targets.map((platform) => (0, import_node_path2.join)(options.cwd, options.npmDir, platform.platformArchABI));
3256
3254
  const universalSourceBins = new Set(targets.filter((platform) => platform.arch === "universal").flatMap((p) => UniArchsByPlatform[p.platform]?.map((a) => `${p.platform}-${a}`)).filter(Boolean));
3257
- await collectNodeBinaries((0, import_node_path.join)(options.cwd, options.outputDir)).then((output) => Promise.all(output.map(async (filePath) => {
3255
+ await collectNodeBinaries((0, import_node_path2.join)(options.cwd, options.outputDir)).then((output) => Promise.all(output.map(async (filePath) => {
3258
3256
  debug2.info(`Read [${colors2.yellowBright(filePath)}]`);
3259
3257
  const sourceContent = await readFileAsync(filePath);
3260
- const parsedName = (0, import_node_path.parse)(filePath);
3258
+ const parsedName = (0, import_node_path2.parse)(filePath);
3261
3259
  const terms = parsedName.name.split(".");
3262
3260
  const platformArchABI = terms.pop();
3263
3261
  const _binaryName = terms.join(".");
@@ -3273,41 +3271,41 @@ async function collectArtifacts(userOptions) {
3273
3271
  if (!dir) {
3274
3272
  throw new Error(`No dist dir found for ${filePath}`);
3275
3273
  }
3276
- const distFilePath = (0, import_node_path.join)(dir, parsedName.base);
3274
+ const distFilePath = (0, import_node_path2.join)(dir, parsedName.base);
3277
3275
  debug2.info(`Write file content to [${colors2.yellowBright(distFilePath)}]`);
3278
3276
  await writeFileAsync(distFilePath, sourceContent);
3279
- const distFilePathLocal = (0, import_node_path.join)((0, import_node_path.parse)(packageJsonPath).dir, parsedName.base);
3277
+ const distFilePathLocal = (0, import_node_path2.join)((0, import_node_path2.parse)(packageJsonPath).dir, parsedName.base);
3280
3278
  debug2.info(`Write file content to [${colors2.yellowBright(distFilePathLocal)}]`);
3281
3279
  await writeFileAsync(distFilePathLocal, sourceContent);
3282
3280
  })));
3283
3281
  const wasiTarget = targets.find((t) => t.platform === "wasi");
3284
3282
  if (wasiTarget) {
3285
- const wasiDir = (0, import_node_path.join)(options.cwd, options.npmDir, wasiTarget.platformArchABI);
3286
- const cjsFile = (0, import_node_path.join)(options.buildOutputDir ?? options.cwd, `${binaryName}.wasi.cjs`);
3287
- const workerFile = (0, import_node_path.join)(options.buildOutputDir ?? options.cwd, `wasi-worker.mjs`);
3288
- const browserEntry = (0, import_node_path.join)(options.buildOutputDir ?? options.cwd, `${binaryName}.wasi-browser.js`);
3289
- const browserWorkerFile = (0, import_node_path.join)(options.buildOutputDir ?? options.cwd, `wasi-worker-browser.mjs`);
3283
+ const wasiDir = (0, import_node_path2.join)(options.cwd, options.npmDir, wasiTarget.platformArchABI);
3284
+ const cjsFile = (0, import_node_path2.join)(options.buildOutputDir ?? options.cwd, `${binaryName}.wasi.cjs`);
3285
+ const workerFile = (0, import_node_path2.join)(options.buildOutputDir ?? options.cwd, `wasi-worker.mjs`);
3286
+ const browserEntry = (0, import_node_path2.join)(options.buildOutputDir ?? options.cwd, `${binaryName}.wasi-browser.js`);
3287
+ const browserWorkerFile = (0, import_node_path2.join)(options.buildOutputDir ?? options.cwd, `wasi-worker-browser.mjs`);
3290
3288
  debug2.info(`Move wasi binding file [${colors2.yellowBright(cjsFile)}] to [${colors2.yellowBright(wasiDir)}]`);
3291
- await writeFileAsync((0, import_node_path.join)(wasiDir, `${binaryName}.wasi.cjs`), await readFileAsync(cjsFile));
3289
+ await writeFileAsync((0, import_node_path2.join)(wasiDir, `${binaryName}.wasi.cjs`), await readFileAsync(cjsFile));
3292
3290
  debug2.info(`Move wasi worker file [${colors2.yellowBright(workerFile)}] to [${colors2.yellowBright(wasiDir)}]`);
3293
- await writeFileAsync((0, import_node_path.join)(wasiDir, `wasi-worker.mjs`), await readFileAsync(workerFile));
3291
+ await writeFileAsync((0, import_node_path2.join)(wasiDir, `wasi-worker.mjs`), await readFileAsync(workerFile));
3294
3292
  debug2.info(`Move wasi browser entry file [${colors2.yellowBright(browserEntry)}] to [${colors2.yellowBright(wasiDir)}]`);
3295
3293
  await writeFileAsync(
3296
- (0, import_node_path.join)(wasiDir, `${binaryName}.wasi-browser.js`),
3294
+ (0, import_node_path2.join)(wasiDir, `${binaryName}.wasi-browser.js`),
3297
3295
  // https://github.com/vitejs/vite/issues/8427
3298
3296
  (await readFileAsync(browserEntry, "utf8")).replace(`new URL('./wasi-worker-browser.mjs', import.meta.url)`, `new URL('${packageName}-wasm32-wasi/wasi-worker-browser.mjs', import.meta.url)`)
3299
3297
  );
3300
3298
  debug2.info(`Move wasi browser worker file [${colors2.yellowBright(browserWorkerFile)}] to [${colors2.yellowBright(wasiDir)}]`);
3301
- await writeFileAsync((0, import_node_path.join)(wasiDir, `wasi-worker-browser.mjs`), await readFileAsync(browserWorkerFile));
3299
+ await writeFileAsync((0, import_node_path2.join)(wasiDir, `wasi-worker-browser.mjs`), await readFileAsync(browserWorkerFile));
3302
3300
  }
3303
3301
  }
3304
3302
  async function collectNodeBinaries(root2) {
3305
3303
  const files = await readdirAsync(root2, { withFileTypes: true });
3306
- const nodeBinaries = files.filter((file) => file.isFile() && (file.name.endsWith(".node") || file.name.endsWith(".wasm"))).map((file) => (0, import_node_path.join)(root2, file.name));
3304
+ const nodeBinaries = files.filter((file) => file.isFile() && (file.name.endsWith(".node") || file.name.endsWith(".wasm"))).map((file) => (0, import_node_path2.join)(root2, file.name));
3307
3305
  const dirs = files.filter((file) => file.isDirectory());
3308
3306
  for (const dir of dirs) {
3309
3307
  if (dir.name !== "node_modules") {
3310
- nodeBinaries.push(...await collectNodeBinaries((0, import_node_path.join)(root2, dir.name)));
3308
+ nodeBinaries.push(...await collectNodeBinaries((0, import_node_path2.join)(root2, dir.name)));
3311
3309
  }
3312
3310
  }
3313
3311
  return nodeBinaries;
@@ -3319,1017 +3317,13 @@ var import_node_crypto = require("node:crypto");
3319
3317
  var import_node_fs3 = require("node:fs");
3320
3318
  var import_node_module = require("node:module");
3321
3319
  var import_node_os = require("node:os");
3322
- var import_node_path2 = require("node:path");
3320
+ var import_node_path3 = require("node:path");
3323
3321
  var colors3 = __toESM(require("colorette"), 1);
3324
3322
  var import_wasm_sjlj = require("wasm-sjlj");
3325
3323
 
3326
- // dist/api/templates/.gitignore.js
3327
- var gitIgnore = `# Created by https://www.toptal.com/developers/gitignore/api/node
3328
- # Edit at https://www.toptal.com/developers/gitignore?templates=node
3329
-
3330
- ### Node ###
3331
- # Logs
3332
- logs
3333
- *.log
3334
- npm-debug.log*
3335
- yarn-debug.log*
3336
- yarn-error.log*
3337
- lerna-debug.log*
3338
-
3339
- # Diagnostic reports (https://nodejs.org/api/report.html)
3340
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
3341
-
3342
- # Runtime data
3343
- pids
3344
- *.pid
3345
- *.seed
3346
- *.pid.lock
3347
-
3348
- # Directory for instrumented libs generated by jscoverage/JSCover
3349
- lib-cov
3350
-
3351
- # Coverage directory used by tools like istanbul
3352
- coverage
3353
- *.lcov
3354
-
3355
- # nyc test coverage
3356
- .nyc_output
3357
-
3358
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
3359
- .grunt
3360
-
3361
- # Bower dependency directory (https://bower.io/)
3362
- bower_components
3363
-
3364
- # node-waf configuration
3365
- .lock-wscript
3366
-
3367
- # Compiled binary addons (https://nodejs.org/api/addons.html)
3368
- build/Release
3369
-
3370
- # Dependency directories
3371
- node_modules/
3372
- jspm_packages/
3373
-
3374
- # TypeScript v1 declaration files
3375
- typings/
3376
-
3377
- # TypeScript cache
3378
- *.tsbuildinfo
3379
-
3380
- # Optional npm cache directory
3381
- .npm
3382
-
3383
- # Optional eslint cache
3384
- .eslintcache
3385
-
3386
- # Microbundle cache
3387
- .rpt2_cache/
3388
- .rts2_cache_cjs/
3389
- .rts2_cache_es/
3390
- .rts2_cache_umd/
3391
-
3392
- # Optional REPL history
3393
- .node_repl_history
3394
-
3395
- # Output of 'npm pack'
3396
- *.tgz
3397
-
3398
- # Yarn Integrity file
3399
- .yarn-integrity
3400
-
3401
- # dotenv environment variables file
3402
- .env
3403
- .env.test
3404
-
3405
- # parcel-bundler cache (https://parceljs.org/)
3406
- .cache
3407
-
3408
- # Next.js build output
3409
- .next
3410
-
3411
- # Nuxt.js build / generate output
3412
- .nuxt
3413
- dist
3414
-
3415
- # Gatsby files
3416
- .cache/
3417
- # Comment in the public line in if your project uses Gatsby and not Next.js
3418
- # https://nextjs.org/blog/next-9-1#public-directory-support
3419
- # public
3420
-
3421
- # vuepress build output
3422
- .vuepress/dist
3423
-
3424
- # Serverless directories
3425
- .serverless/
3426
-
3427
- # FuseBox cache
3428
- .fusebox/
3429
-
3430
- # DynamoDB Local files
3431
- .dynamodb/
3432
-
3433
- # TernJS port file
3434
- .tern-port
3435
-
3436
- # Stores VSCode versions used for testing VSCode extensions
3437
- .vscode-test
3438
-
3439
- # End of https://www.toptal.com/developers/gitignore/api/node
3440
-
3441
- # Created by https://www.toptal.com/developers/gitignore/api/macos
3442
- # Edit at https://www.toptal.com/developers/gitignore?templates=macos
3443
-
3444
- ### macOS ###
3445
- # General
3446
- .DS_Store
3447
- .AppleDouble
3448
- .LSOverride
3449
-
3450
- # Icon must end with two \r
3451
- Icon
3452
-
3453
-
3454
- # Thumbnails
3455
- ._*
3456
-
3457
- # Files that might appear in the root of a volume
3458
- .DocumentRevisions-V100
3459
- .fseventsd
3460
- .Spotlight-V100
3461
- .TemporaryItems
3462
- .Trashes
3463
- .VolumeIcon.icns
3464
- .com.apple.timemachine.donotpresent
3465
-
3466
- # Directories potentially created on remote AFP share
3467
- .AppleDB
3468
- .AppleDesktop
3469
- Network Trash Folder
3470
- Temporary Items
3471
- .apdisk
3472
-
3473
- ### macOS Patch ###
3474
- # iCloud generated files
3475
- *.icloud
3476
-
3477
- # End of https://www.toptal.com/developers/gitignore/api/macos
3478
-
3479
- # Created by https://www.toptal.com/developers/gitignore/api/windows
3480
- # Edit at https://www.toptal.com/developers/gitignore?templates=windows
3481
-
3482
- ### Windows ###
3483
- # Windows thumbnail cache files
3484
- Thumbs.db
3485
- Thumbs.db:encryptable
3486
- ehthumbs.db
3487
- ehthumbs_vista.db
3488
-
3489
- # Dump file
3490
- *.stackdump
3491
-
3492
- # Folder config file
3493
- [Dd]esktop.ini
3494
-
3495
- # Recycle Bin used on file shares
3496
- $RECYCLE.BIN/
3497
-
3498
- # Windows Installer files
3499
- *.cab
3500
- *.msi
3501
- *.msix
3502
- *.msm
3503
- *.msp
3504
-
3505
- # Windows shortcuts
3506
- *.lnk
3507
-
3508
- # End of https://www.toptal.com/developers/gitignore/api/windows
3509
-
3510
- #Added by cargo
3511
-
3512
- /target
3513
- Cargo.lock
3514
-
3515
- .pnp.*
3516
- .yarn/*
3517
- !.yarn/patches
3518
- !.yarn/plugins
3519
- !.yarn/releases
3520
- !.yarn/sdks
3521
- !.yarn/versions
3522
-
3523
- *.node
3524
- *.wasm
3525
- `;
3526
-
3527
- // dist/api/templates/.npmignore.js
3528
- var npmIgnore = `target
3529
- Cargo.lock
3530
- .cargo
3531
- .github
3532
- npm
3533
- .eslintrc
3534
- .prettierignore
3535
- rustfmt.toml
3536
- yarn.lock
3537
- *.node
3538
- .yarn
3539
- __test__
3540
- renovate.json
3541
- `;
3542
-
3543
- // dist/api/templates/build.rs.js
3544
- var createBuildRs = () => `fn main() {
3545
- napi_build::setup();
3546
- }
3547
- `;
3548
-
3549
- // dist/api/templates/cargo.toml.js
3550
- var createCargoToml = ({ name, license, features, deriveFeatures }) => `[package]
3551
- name = "${name.replace("@", "").replace("/", "_").toLowerCase()}"
3552
- version = "1.0.0"
3553
- edition = "2021"
3554
- license = "${license}"
3555
-
3556
- [lib]
3557
- crate-type = ["cdylib"]
3558
-
3559
- [dependencies.napi]
3560
- version = "2"
3561
- default-features = false
3562
- # see https://nodejs.org/api/n-api.html#node-api-version-matrix
3563
- features = ${JSON.stringify(features)}
3564
-
3565
- [dependencies.napi-derive]
3566
- version = "2"
3567
- features = ${JSON.stringify(deriveFeatures)}
3568
-
3569
- [build-dependencies]
3570
- napi-build = "2"
3571
-
3572
- [profile.release]
3573
- lto = true
3574
- strip = "symbols"
3575
- `;
3576
-
3577
3324
  // dist/api/templates/ci.yml.js
3578
3325
  var import_js_yaml = require("js-yaml");
3579
3326
 
3580
- // dist/api/templates/ci-template.js
3581
- var YAML = (packageManager, wasiTargetName) => `
3582
- name: CI
3583
-
3584
- env:
3585
- DEBUG: 'napi:*'
3586
- MACOSX_DEPLOYMENT_TARGET: '10.13'
3587
-
3588
- permissions:
3589
- contents: write
3590
- id-token: write
3591
-
3592
- on:
3593
- push:
3594
- branches:
3595
- - main
3596
- tags-ignore:
3597
- - '**'
3598
- paths-ignore:
3599
- - '**/*.md'
3600
- - 'LICENSE'
3601
- - '**/*.gitignore'
3602
- - '.editorconfig'
3603
- - 'docs/**'
3604
- pull_request:
3605
-
3606
- jobs:
3607
- build:
3608
-
3609
- strategy:
3610
- fail-fast: false
3611
- matrix:
3612
- settings:
3613
- - host: macos-latest
3614
- target: 'x86_64-apple-darwin'
3615
- build: ${packageManager} build --platform --target x86_64-apple-darwin
3616
- - host: windows-latest
3617
- build: ${packageManager} build --platform
3618
- target: 'x86_64-pc-windows-msvc'
3619
- - host: windows-latest
3620
- build: |
3621
- ${packageManager} build --platform --target i686-pc-windows-msvc
3622
- ${packageManager} test
3623
- target: 'i686-pc-windows-msvc'
3624
- - host: ubuntu-latest
3625
- target: 'x86_64-unknown-linux-gnu'
3626
- build: ${packageManager} build --platform --target x86_64-unknown-linux-gnu --use-napi-cross
3627
- - host: ubuntu-latest
3628
- target: 'x86_64-unknown-linux-musl'
3629
- build: ${packageManager} build --platform --target x86_64-unknown-linux-musl -x
3630
- - host: macos-latest
3631
- target: 'aarch64-apple-darwin'
3632
- build: ${packageManager} build --platform --target aarch64-apple-darwin
3633
- - host: ubuntu-latest
3634
- target: 'aarch64-unknown-linux-gnu'
3635
- build: ${packageManager} build --platform --target aarch64-unknown-linux-gnu --use-napi-cross
3636
- - host: ubuntu-latest
3637
- target: 'armv7-unknown-linux-gnueabihf'
3638
- build: ${packageManager} build --platform --target armv7-unknown-linux-gnueabihf --use-napi-cross
3639
- - host: ubuntu-latest
3640
- target: 'armv7-unknown-linux-musleabihf'
3641
- build: ${packageManager} build --platform --target armv7-unknown-linux-musleabihf -x
3642
- - host: ubuntu-latest
3643
- target: 'aarch64-linux-android'
3644
- build: ${packageManager} build --platform --target aarch64-linux-android
3645
- - host: ubuntu-latest
3646
- target: 'armv7-linux-androideabi'
3647
- build: ${packageManager} build --platform --target armv7-linux-androideabi
3648
- - host: ubuntu-latest
3649
- target: 'aarch64-unknown-linux-musl'
3650
- build: ${packageManager} build --platform --target aarch64-unknown-linux-musl -x
3651
- - host: windows-latest
3652
- target: 'aarch64-pc-windows-msvc'
3653
- build: ${packageManager} build --platform --target aarch64-pc-windows-msvc
3654
- - host: ubuntu-latest
3655
- target: 'riscv64gc-unknown-linux-gnu'
3656
- setup: |
3657
- sudo apt-get update
3658
- sudo apt-get install gcc-riscv64-linux-gnu -y
3659
- build: ${packageManager} build --platform --target riscv64gc-unknown-linux-gnu
3660
- - host: ubuntu-latest
3661
- target: 'powerpc64le-unknown-linux-gnu'
3662
- setup: |
3663
- sudo apt-get update
3664
- sudo apt-get install gcc-powerpc64le-linux-gnu -y
3665
- build: ${packageManager} build --platform --target powerpc64le-unknown-linux-gnu
3666
- - host: ubuntu-latest
3667
- target: 's390x-unknown-linux-gnu'
3668
- setup: |
3669
- sudo apt-get update
3670
- sudo apt-get install gcc-s390x-linux-gnu -y
3671
- build: ${packageManager} build --platform --target s390x-unknown-linux-gnu
3672
- - host: ubuntu-latest
3673
- target: '${wasiTargetName}'
3674
- build: ${packageManager} build --platform --target ${wasiTargetName}
3675
-
3676
- name: stable - \${{ matrix.settings.target }} - node@20
3677
- runs-on: \${{ matrix.settings.host }}
3678
-
3679
- steps:
3680
- - uses: actions/checkout@v4
3681
-
3682
- - name: Setup node
3683
- uses: actions/setup-node@v4
3684
- with:
3685
- node-version: 20
3686
- cache: ${packageManager}
3687
-
3688
- - name: Install
3689
- uses: dtolnay/rust-toolchain@stable
3690
- with:
3691
- toolchain: stable
3692
- targets: \${{ matrix.settings.target }}
3693
-
3694
- - name: Cache cargo
3695
- uses: actions/cache@v4
3696
- with:
3697
- path: |
3698
- ~/.cargo/registry/index/
3699
- ~/.cargo/registry/cache/
3700
- ~/.cargo/git/db/
3701
- ~/.napi-rs
3702
- .cargo-cache
3703
- target/
3704
- key: \${{ matrix.settings.target }}-cargo-\${{ matrix.settings.host }}
3705
-
3706
- - uses: goto-bus-stop/setup-zig@v2
3707
- if: \${{ contains(matrix.settings.target, 'musl') }}
3708
- with:
3709
- version: 0.13.0
3710
-
3711
- - name: Install cargo-zigbuild
3712
- uses: taiki-e/install-action@v2
3713
- if: \${{ contains(matrix.settings.target, 'musl') }}
3714
- env:
3715
- GITHUB_TOKEN: \${{ github.token }}
3716
- with:
3717
- tool: cargo-zigbuild
3718
-
3719
- - name: Setup toolchain
3720
- run: \${{ matrix.settings.setup }}
3721
- if: \${{ matrix.settings.setup }}
3722
- shell: bash
3723
-
3724
- - name: Setup node x86
3725
- if: matrix.settings.target == 'i686-pc-windows-msvc'
3726
- run: yarn config set supportedArchitectures.cpu "ia32"
3727
- shell: bash
3728
-
3729
- - name: 'Install dependencies'
3730
- run: ${packageManager} install
3731
-
3732
- - name: Setup node x86
3733
- uses: actions/setup-node@v4
3734
- if: matrix.settings.target == 'i686-pc-windows-msvc'
3735
- with:
3736
- node-version: 20
3737
- architecture: x86
3738
-
3739
- - name: 'Build'
3740
- run: \${{ matrix.settings.build }}
3741
- shell: bash
3742
-
3743
- - name: Upload artifact
3744
- uses: actions/upload-artifact@v4
3745
- if: matrix.settings.target != '${wasiTargetName}'
3746
- with:
3747
- name: bindings-\${{ matrix.settings.target }}
3748
- path: "*.node"
3749
- if-no-files-found: error
3750
-
3751
- - name: Upload artifact
3752
- uses: actions/upload-artifact@v4
3753
- if: matrix.settings.target == '${wasiTargetName}'
3754
- with:
3755
- name: bindings-\${{ matrix.settings.target }}
3756
- path: "*.wasm"
3757
- if-no-files-found: error
3758
-
3759
- build-freebsd:
3760
- runs-on: ubuntu-latest
3761
- name: Build FreeBSD
3762
- steps:
3763
- - uses: actions/checkout@v4
3764
- - name: Build
3765
- id: build
3766
- uses: cross-platform-actions/action@v0.25.0
3767
- env:
3768
- DEBUG: 'napi:*'
3769
- RUSTUP_IO_THREADS: 1
3770
- with:
3771
- operating_system: freebsd
3772
- version: '14.1'
3773
- memory: 8G
3774
- cpu_count: 3
3775
- environment_variables: 'DEBUG RUSTUP_IO_THREADS'
3776
- shell: bash
3777
- run: |
3778
- sudo pkg install -y -f curl node libnghttp2 npm
3779
- sudo npm install -g ${packageManager} --ignore-scripts
3780
- curl https://sh.rustup.rs -sSf --output rustup.sh
3781
- sh rustup.sh -y --profile minimal --default-toolchain stable
3782
- source "$HOME/.cargo/env"
3783
- echo "~~~~ rustc --version ~~~~"
3784
- rustc --version
3785
- echo "~~~~ node -v ~~~~"
3786
- node -v
3787
- echo "~~~~ yarn --version ~~~~"
3788
- yarn --version
3789
- pwd
3790
- ls -lah
3791
- whoami
3792
- env
3793
- freebsd-version
3794
- ${packageManager} install
3795
- ${packageManager} build
3796
- strip -x *.node
3797
- yarn test
3798
- rm -rf node_modules
3799
- rm -rf target
3800
- rm -rf .yarn/cache
3801
- - name: Upload artifact
3802
- uses: actions/upload-artifact@v4
3803
- with:
3804
- name: bindings-freebsd
3805
- path: "*.node"
3806
- if-no-files-found: error
3807
-
3808
- test-macOS-windows-binding:
3809
- name: Test bindings on \${{ matrix.settings.target }} - node@\${{ matrix.node }}
3810
- needs:
3811
- - build
3812
- strategy:
3813
- fail-fast: false
3814
- matrix:
3815
- settings:
3816
- - host: macos-latest
3817
- target: 'x86_64-apple-darwin'
3818
- architecture: x64
3819
- - host: macos-latest
3820
- target: 'aarch64-apple-darwin'
3821
- architecture: arm64
3822
- - host: windows-latest
3823
- target: 'x86_64-pc-windows-msvc'
3824
- architecture: x64
3825
- node: ['18', '20']
3826
- runs-on: \${{ matrix.settings.host }}
3827
-
3828
- steps:
3829
- - uses: actions/checkout@v4
3830
-
3831
- - name: Setup node
3832
- uses: actions/setup-node@v4
3833
- with:
3834
- node-version: \${{ matrix.node }}
3835
- cache: '${packageManager}'
3836
- architecture: \${{ matrix.settings.architecture }}
3837
-
3838
- - name: 'Install dependencies'
3839
- run: ${packageManager} install
3840
-
3841
- - name: Download artifacts
3842
- uses: actions/download-artifact@v4
3843
- with:
3844
- name: bindings-\${{ matrix.settings.target }}
3845
- path: .
3846
-
3847
- - name: List packages
3848
- run: ls -R .
3849
- shell: bash
3850
-
3851
- - name: Test bindings
3852
- run: ${packageManager} run test
3853
-
3854
- test-linux-x64-gnu-binding:
3855
- name: Test bindings on Linux-x64-gnu - node@\${{ matrix.node }}
3856
- needs:
3857
- - build
3858
- strategy:
3859
- fail-fast: false
3860
- matrix:
3861
- node: ['18', '20']
3862
- runs-on: ubuntu-latest
3863
-
3864
- steps:
3865
- - uses: actions/checkout@v4
3866
-
3867
- - name: Setup node
3868
- uses: actions/setup-node@v4
3869
- with:
3870
- node-version: \${{ matrix.node }}
3871
- cache: '${packageManager}'
3872
-
3873
- - name: 'Install dependencies'
3874
- run: ${packageManager} install
3875
-
3876
- - name: Download artifacts
3877
- uses: actions/download-artifact@v4
3878
- with:
3879
- name: bindings-x86_64-unknown-linux-gnu
3880
- path: .
3881
-
3882
- - name: List packages
3883
- run: ls -R .
3884
- shell: bash
3885
-
3886
- - name: Test bindings
3887
- run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-slim ${packageManager} run test
3888
-
3889
- test-linux-x64-musl-binding:
3890
- name: Test bindings on x86_64-unknown-linux-musl - node@\${{ matrix.node }}
3891
- needs:
3892
- - build
3893
- strategy:
3894
- fail-fast: false
3895
- matrix:
3896
- node: ['18', '20']
3897
- runs-on: ubuntu-latest
3898
-
3899
- steps:
3900
- - uses: actions/checkout@v4
3901
-
3902
- - name: Setup node
3903
- uses: actions/setup-node@v4
3904
- with:
3905
- node-version: \${{ matrix.node }}
3906
- cache: '${packageManager}'
3907
-
3908
- - name: 'Install dependencies'
3909
- run: |
3910
- yarn config set supportedArchitectures.libc "musl"
3911
- ${packageManager} install
3912
-
3913
- - name: Download artifacts
3914
- uses: actions/download-artifact@v4
3915
- with:
3916
- name: bindings-x86_64-unknown-linux-musl
3917
- path: .
3918
-
3919
- - name: List packages
3920
- run: ls -R .
3921
- shell: bash
3922
-
3923
- - name: Test bindings
3924
- run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-alpine ${packageManager} run test
3925
-
3926
- test-linux-aarch64-gnu-binding:
3927
- name: Test bindings on aarch64-unknown-linux-gnu - node@\${{ matrix.node }}
3928
- needs:
3929
- - build
3930
- strategy:
3931
- fail-fast: false
3932
- matrix:
3933
- node: ['20']
3934
- runs-on: ubuntu-latest
3935
-
3936
- steps:
3937
- - uses: actions/checkout@v4
3938
-
3939
- - name: Download artifacts
3940
- uses: actions/download-artifact@v4
3941
- with:
3942
- name: bindings-aarch64-unknown-linux-gnu
3943
- path: .
3944
-
3945
- - name: List packages
3946
- run: ls -R .
3947
- shell: bash
3948
-
3949
- - name: Install dependencies
3950
- run: |
3951
- yarn config set supportedArchitectures.cpu "arm64"
3952
- yarn config set supportedArchitectures.libc "glibc"
3953
- ${packageManager} install
3954
-
3955
- - name: Set up QEMU
3956
- uses: docker/setup-qemu-action@v3
3957
- with:
3958
- platforms: arm64
3959
- - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
3960
-
3961
- - name: Setup and run tests
3962
- uses: addnab/docker-run-action@v3
3963
- with:
3964
- image: node:\${{ matrix.node }}-slim
3965
- options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
3966
- run: ${packageManager} run test
3967
-
3968
- test-linux-aarch64-musl-binding:
3969
- name: Test bindings on aarch64-unknown-linux-musl - node@\${{ matrix.node }}
3970
- needs:
3971
- - build
3972
- strategy:
3973
- fail-fast: false
3974
- matrix:
3975
- node: ['18', '20']
3976
-
3977
- runs-on: ubuntu-latest
3978
-
3979
- steps:
3980
- - uses: actions/checkout@v4
3981
-
3982
- - name: Download artifacts
3983
- uses: actions/download-artifact@v4
3984
- with:
3985
- name: bindings-aarch64-unknown-linux-musl
3986
- path: .
3987
-
3988
- - name: List packages
3989
- run: ls -R .
3990
- shell: bash
3991
-
3992
- - name: Install dependencies
3993
- run: |
3994
- yarn config set supportedArchitectures.cpu "arm64"
3995
- yarn config set supportedArchitectures.libc "musl"
3996
- ${packageManager} install
3997
-
3998
- - name: Set up QEMU
3999
- uses: docker/setup-qemu-action@v3
4000
- with:
4001
- platforms: arm64
4002
- - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
4003
-
4004
- - name: Setup and run tests
4005
- uses: addnab/docker-run-action@v3
4006
- with:
4007
- image: node:\${{ matrix.node }}-alpine
4008
- options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
4009
- run: ${packageManager} run test
4010
-
4011
- test-linux-arm-gnueabihf-binding:
4012
- name: Test bindings on armv7-unknown-linux-gnueabihf - node@\${{ matrix.node }}
4013
- needs:
4014
- - build
4015
- strategy:
4016
- fail-fast: false
4017
- matrix:
4018
- node: ['18', '20']
4019
- runs-on: ubuntu-latest
4020
-
4021
- steps:
4022
- - uses: actions/checkout@v4
4023
-
4024
- - name: Download artifacts
4025
- uses: actions/download-artifact@v4
4026
- with:
4027
- name: bindings-armv7-unknown-linux-gnueabihf
4028
- path: .
4029
-
4030
- - name: List packages
4031
- run: ls -R .
4032
- shell: bash
4033
-
4034
- - name: Install dependencies
4035
- run: |
4036
- yarn config set supportedArchitectures.cpu "arm"
4037
- ${packageManager} install
4038
-
4039
- - name: Set up QEMU
4040
- uses: docker/setup-qemu-action@v3
4041
- with:
4042
- platforms: arm
4043
- - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
4044
-
4045
- - name: Setup and run tests
4046
- uses: addnab/docker-run-action@v3
4047
- with:
4048
- image: node:\${{ matrix.node }}-bullseye-slim
4049
- options: --platform linux/arm/v7 -v \${{ github.workspace }}:/build -w /build
4050
- run: ${packageManager} test
4051
-
4052
- universal-macOS:
4053
- name: Build universal macOS binary
4054
- needs:
4055
- - build
4056
- runs-on: macos-latest
4057
-
4058
- steps:
4059
- - uses: actions/checkout@v4
4060
-
4061
- - name: Setup node
4062
- uses: actions/setup-node@v4
4063
- with:
4064
- node-version: 20
4065
- cache: ${packageManager}
4066
-
4067
- - name: 'Install dependencies'
4068
- run: ${packageManager} install
4069
-
4070
- - name: Download macOS x64 artifact
4071
- uses: actions/download-artifact@v4
4072
- with:
4073
- name: bindings-x86_64-apple-darwin
4074
- path: .
4075
- - name: Download macOS arm64 artifact
4076
- uses: actions/download-artifact@v4
4077
- with:
4078
- name: bindings-aarch64-apple-darwin
4079
- path: .
4080
-
4081
- - name: Combine binaries
4082
- run: ${packageManager} napi universalize
4083
-
4084
- - name: Upload artifact
4085
- uses: actions/upload-artifact@v4
4086
- with:
4087
- name: bindings-universal-apple-darwin
4088
- path: "*.node"
4089
- if-no-files-found: error
4090
-
4091
- test-wasi-nodejs:
4092
- name: Test bindings on wasi - node@\${{ matrix.node }}
4093
- needs:
4094
- - build
4095
- strategy:
4096
- fail-fast: false
4097
- matrix:
4098
- node: ['18', '20']
4099
- runs-on: ubuntu-latest
4100
- steps:
4101
- - uses: actions/checkout@v4
4102
- - name: Download artifacts
4103
- uses: actions/download-artifact@v4
4104
- with:
4105
- name: bindings-${wasiTargetName}
4106
- path: .
4107
- - name: List packages
4108
- run: ls -R .
4109
- - uses: actions/setup-node@v4
4110
- with:
4111
- node-version: \${{ matrix.node }}
4112
- cache: ${packageManager}
4113
- - name: 'Install dependencies'
4114
- run: ${packageManager} install
4115
- - name: Test
4116
- run: ${packageManager} test
4117
- env:
4118
- NAPI_RS_FORCE_WASI: true
4119
-
4120
- publish:
4121
- name: Publish
4122
- runs-on: ubuntu-latest
4123
- needs:
4124
- - test-linux-x64-gnu-binding
4125
- - test-linux-x64-musl-binding
4126
- - test-linux-aarch64-gnu-binding
4127
- - test-linux-arm-gnueabihf-binding
4128
- - test-macOS-windows-binding
4129
- - test-linux-aarch64-musl-binding
4130
- - test-wasi-nodejs
4131
- - build-freebsd
4132
-
4133
- steps:
4134
- - uses: actions/checkout@v4
4135
-
4136
- - name: Setup node
4137
- uses: actions/setup-node@v4
4138
- with:
4139
- node-version: 20
4140
- cache: '${packageManager}'
4141
- registry-url: 'https://registry.npmjs.org'
4142
-
4143
- - name: 'Install dependencies'
4144
- run: ${packageManager} install
4145
-
4146
- - name: Download all artifacts
4147
- uses: actions/download-artifact@v4
4148
- with:
4149
- path: artifacts
4150
-
4151
- - name: Move artifacts
4152
- run: ${packageManager} artifacts
4153
-
4154
- - name: List packages
4155
- run: ls -R ./npm
4156
- shell: bash
4157
-
4158
- - name: Publish
4159
- run: |
4160
- if git log -1 --pretty=%B | grep "^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$";
4161
- then
4162
- npm publish --access public --provenance
4163
- elif git log -1 --pretty=%B | grep "^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+";
4164
- then
4165
- npm publish --tag next --access public --provenance
4166
- else
4167
- echo "Not a release, skipping publish"
4168
- fi
4169
- env:
4170
- GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
4171
- NODE_AUTH_TOKEN: \${{ secrets.NPM_TOKEN }}
4172
- `;
4173
-
4174
- // dist/api/templates/ci.yml.js
4175
- var BUILD_FREEBSD = "build-freebsd";
4176
- var TEST_MACOS_WINDOWS = "test-macOS-windows-binding";
4177
- var TEST_LINUX_X64_GNU = "test-linux-x64-gnu-binding";
4178
- var TEST_LINUX_X64_MUSL = "test-linux-x64-musl-binding";
4179
- var TEST_LINUX_AARCH64_GNU = "test-linux-aarch64-gnu-binding";
4180
- var TEST_LINUX_AARCH64_MUSL = "test-linux-aarch64-musl-binding";
4181
- var TEST_LINUX_ARM_GNUEABIHF = "test-linux-arm-gnueabihf-binding";
4182
- var TEST_WASI = "test-wasi-nodejs";
4183
- var UNIVERSAL_MACOS = "universal-macOS";
4184
- var createGithubActionsCIYml = (targets, packageManager, wasiTargetName) => {
4185
- const allTargets = new Set(targets.flatMap((t) => {
4186
- const platform = parseTriple(t);
4187
- if (platform.arch === "universal") {
4188
- const srcTriples = UniArchsByPlatform[platform.platform]?.map((arch) => t.replace("universal", NodeArchToCpu[arch]));
4189
- return [t, ...srcTriples ?? []];
4190
- }
4191
- return [t];
4192
- }));
4193
- const fullTemplate = (0, import_js_yaml.load)(YAML(packageManager, wasiTargetName));
4194
- const requiredSteps = [];
4195
- const enableWindowsX86 = allTargets.has("x86_64-pc-windows-msvc");
4196
- const enableMacOSX86 = allTargets.has("x86_64-apple-darwin");
4197
- const enableLinuxX86Gnu = allTargets.has("x86_64-unknown-linux-gnu");
4198
- const enableLinuxX86Musl = allTargets.has("x86_64-unknown-linux-musl");
4199
- const enableLinuxArm8Gnu = allTargets.has("aarch64-unknown-linux-gnu");
4200
- const enableLinuxArm8Musl = allTargets.has("aarch64-unknown-linux-musl");
4201
- const enableLinuxArm7 = allTargets.has("armv7-unknown-linux-gnueabihf");
4202
- const enableFreeBSD = allTargets.has("x86_64-unknown-freebsd");
4203
- const enableMacOSUni = allTargets.has("universal-apple-darwin");
4204
- const enableWasi = allTargets.has("wasm32-wasi-preview1-threads") || allTargets.has("wasm32-wasip1-threads") || allTargets.has("wasm32-wasip2");
4205
- fullTemplate.jobs.build.strategy.matrix.settings = fullTemplate.jobs.build.strategy.matrix.settings.filter(({ target }) => allTargets.has(target));
4206
- if (!fullTemplate.jobs.build.strategy.matrix.settings.length) {
4207
- delete fullTemplate.jobs.build.strategy.matrix;
4208
- }
4209
- if (!enableFreeBSD) {
4210
- delete fullTemplate.jobs[BUILD_FREEBSD];
4211
- } else {
4212
- requiredSteps.push(BUILD_FREEBSD);
4213
- }
4214
- if (!enableWindowsX86 && !enableMacOSX86) {
4215
- delete fullTemplate.jobs[TEST_MACOS_WINDOWS];
4216
- } else {
4217
- const filterTargets = /* @__PURE__ */ new Set();
4218
- if (enableWindowsX86) {
4219
- filterTargets.add("windows-latest");
4220
- }
4221
- if (enableMacOSUni || enableMacOSX86) {
4222
- filterTargets.add("macos-latest");
4223
- }
4224
- fullTemplate.jobs[TEST_MACOS_WINDOWS].strategy.matrix.settings = fullTemplate.jobs[TEST_MACOS_WINDOWS].strategy.matrix.settings.filter(({ host }) => filterTargets.has(host));
4225
- requiredSteps.push(TEST_MACOS_WINDOWS);
4226
- }
4227
- if (!enableLinuxX86Gnu) {
4228
- delete fullTemplate.jobs[TEST_LINUX_X64_GNU];
4229
- } else {
4230
- requiredSteps.push(TEST_LINUX_X64_GNU);
4231
- }
4232
- if (!enableLinuxX86Musl) {
4233
- delete fullTemplate.jobs[TEST_LINUX_X64_MUSL];
4234
- } else {
4235
- requiredSteps.push(TEST_LINUX_X64_MUSL);
4236
- }
4237
- if (!enableLinuxArm8Gnu) {
4238
- delete fullTemplate.jobs[TEST_LINUX_AARCH64_GNU];
4239
- } else {
4240
- requiredSteps.push(TEST_LINUX_AARCH64_GNU);
4241
- }
4242
- if (!enableLinuxArm8Musl) {
4243
- delete fullTemplate.jobs[TEST_LINUX_AARCH64_MUSL];
4244
- } else {
4245
- requiredSteps.push(TEST_LINUX_AARCH64_MUSL);
4246
- }
4247
- if (!enableLinuxArm7) {
4248
- delete fullTemplate.jobs[TEST_LINUX_ARM_GNUEABIHF];
4249
- } else {
4250
- requiredSteps.push(TEST_LINUX_ARM_GNUEABIHF);
4251
- }
4252
- if (!enableMacOSUni) {
4253
- delete fullTemplate.jobs[UNIVERSAL_MACOS];
4254
- } else {
4255
- requiredSteps.push(UNIVERSAL_MACOS);
4256
- }
4257
- if (!enableWasi) {
4258
- delete fullTemplate.jobs[TEST_WASI];
4259
- } else {
4260
- requiredSteps.push(TEST_WASI);
4261
- }
4262
- fullTemplate.jobs.publish.needs = requiredSteps;
4263
- try {
4264
- return (0, import_js_yaml.dump)(fullTemplate, {
4265
- lineWidth: 1e3
4266
- });
4267
- } catch (err) {
4268
- console.info(fullTemplate);
4269
- throw err;
4270
- }
4271
- };
4272
-
4273
- // dist/api/templates/lib.rs.js
4274
- var createLibRs = () => `use napi_derive::napi;
4275
-
4276
- #[napi]
4277
- pub fn sum(a: i32, b: i32) -> i32 {
4278
- a + b
4279
- }
4280
- `;
4281
-
4282
- // dist/api/templates/package.json.js
4283
- var createPackageJson = async ({ name, binaryName, targets, license, engineRequirement, cliVersion, testFramework }) => {
4284
- const hasWasmTarget = targets.some((t) => t.includes("wasm"));
4285
- const universalTargets = targets.filter((t) => t in UNIVERSAL_TARGETS);
4286
- const unifiedtargets = universalTargets.length ? targets.filter((target) => !universalTargets.some((t) => {
4287
- return UNIVERSAL_TARGETS[t].includes(target);
4288
- })) : targets;
4289
- const content = {
4290
- name,
4291
- version: "0.0.0",
4292
- license,
4293
- engines: {
4294
- node: engineRequirement
4295
- },
4296
- type: "commonjs",
4297
- main: "index.js",
4298
- types: "index.d.ts",
4299
- browser: "browser.js",
4300
- module: void 0,
4301
- exports: void 0,
4302
- napi: {
4303
- binaryName,
4304
- targets: unifiedtargets
4305
- },
4306
- scripts: {
4307
- test: testFramework,
4308
- build: "napi build --release --platform --strip",
4309
- "build:debug": "napi build",
4310
- prepublishOnly: "napi prepublish -t npm",
4311
- artifacts: "napi artifacts",
4312
- version: "napi version"
4313
- },
4314
- devDependencies: {
4315
- "@napi-rs/cli": `^${cliVersion}`
4316
- }
4317
- };
4318
- if (testFramework === "ava") {
4319
- const avaMeta = await fetch(`https://registry.npmjs.org/ava`).then((res) => res.json());
4320
- content.devDependencies["ava"] = `^${avaMeta["dist-tags"].latest}`;
4321
- content.ava = {
4322
- timeout: "1m"
4323
- };
4324
- }
4325
- if (hasWasmTarget) {
4326
- const wasmRuntime = await fetch(`https://registry.npmjs.org/@napi-rs/wasm-runtime`).then((res) => res.json());
4327
- const latest = wasmRuntime["dist-tags"].latest;
4328
- content.devDependencies["@napi-rs/wasm-runtime"] = `^${latest}`;
4329
- }
4330
- return JSON.stringify(content, null, 2);
4331
- };
4332
-
4333
3327
  // dist/api/templates/js-binding.js
4334
3328
  function createCjsBinding(localName, pkgName, idents) {
4335
3329
  return `${bindingHeader}
@@ -4543,9 +3537,9 @@ if (!nativeBinding) {
4543
3537
  }
4544
3538
 
4545
3539
  // dist/api/templates/load-wasi-template.js
4546
- var createWasiBrowserBinding = (wasiFilename, initialMemory = 4e3, maximumMemory = 65536, fs2 = false, asyncInit = false) => {
4547
- const fsImport = fs2 ? `import { memfs } from '@napi-rs/wasm-runtime/fs'` : "";
4548
- const wasiCreation = fs2 ? `
3540
+ var createWasiBrowserBinding = (wasiFilename, initialMemory = 4e3, maximumMemory = 65536, fs3 = false, asyncInit = false) => {
3541
+ const fsImport = fs3 ? `import { memfs } from '@napi-rs/wasm-runtime/fs'` : "";
3542
+ const wasiCreation = fs3 ? `
4549
3543
  export const { fs: __fs, vol: __volume } = memfs()
4550
3544
 
4551
3545
  const __wasi = new __WASI({
@@ -4558,7 +3552,7 @@ const __wasi = new __WASI({
4558
3552
  const __wasi = new __WASI({
4559
3553
  version: 'preview1',
4560
3554
  })`;
4561
- const workerFsHandler = fs2 ? ` worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
3555
+ const workerFsHandler = fs3 ? ` worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
4562
3556
  ` : "";
4563
3557
  const emnapiInstantiateImport = asyncInit ? `instantiateNapiModule as __emnapiInstantiateNapiModule` : `instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync`;
4564
3558
  const emnapiInstantiateCall = asyncInit ? `await __emnapiInstantiateNapiModule` : `__emnapiInstantiateNapiModuleSync`;
@@ -4769,12 +3763,12 @@ globalThis.onmessage = function (e) {
4769
3763
  handler.handle(e);
4770
3764
  };
4771
3765
  `;
4772
- var createWasiBrowserWorkerBinding = (fs2) => {
4773
- const fsImport = fs2 ? `import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
3766
+ var createWasiBrowserWorkerBinding = (fs3) => {
3767
+ const fsImport = fs3 ? `import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
4774
3768
  import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
4775
3769
 
4776
3770
  const fs = createFsProxy(__memfsExported)` : `import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'`;
4777
- const wasiCreation = fs2 ? `const wasi = new WASI({
3771
+ const wasiCreation = fs3 ? `const wasi = new WASI({
4778
3772
  fs,
4779
3773
  preopens: {
4780
3774
  '/': '/',
@@ -4833,7 +3827,7 @@ async function buildProject(rawOptions) {
4833
3827
  ...rawOptions,
4834
3828
  cwd: rawOptions.cwd ?? process.cwd()
4835
3829
  };
4836
- const resolvePath = (...paths) => (0, import_node_path2.resolve)(options.cwd, ...paths);
3830
+ const resolvePath = (...paths) => (0, import_node_path3.resolve)(options.cwd, ...paths);
4837
3831
  const manifestPath = resolvePath(options.manifestPath ?? "Cargo.toml");
4838
3832
  const metadata = await parseMetadata(manifestPath);
4839
3833
  const crate = metadata.packages.find((p) => {
@@ -4869,8 +3863,8 @@ var Builder = class {
4869
3863
  this.config = config;
4870
3864
  this.options = options;
4871
3865
  this.target = options.target ? parseTriple(options.target) : process.env.CARGO_BUILD_TARGET ? parseTriple(process.env.CARGO_BUILD_TARGET) : getSystemDefaultTarget();
4872
- this.crateDir = (0, import_node_path2.parse)(crate.manifest_path).dir;
4873
- this.outputDir = (0, import_node_path2.resolve)(this.options.cwd, options.outputDir ?? this.crateDir);
3866
+ this.crateDir = (0, import_node_path3.parse)(crate.manifest_path).dir;
3867
+ this.outputDir = (0, import_node_path3.resolve)(this.options.cwd, options.outputDir ?? this.crateDir);
4874
3868
  this.targetDir = options.targetDir ?? process.env.CARGO_BUILD_TARGET_DIR ?? metadata.target_directory;
4875
3869
  this.enableTypeDef = this.crate.dependencies.some((dep) => dep.name === "napi-derive" && (dep.uses_default_features || dep.features.includes("type-def")));
4876
3870
  if (!this.enableTypeDef) {
@@ -4914,9 +3908,9 @@ var Builder = class {
4914
3908
  const alias = {
4915
3909
  "s390x-unknown-linux-gnu": "s390x-ibm-linux-gnu"
4916
3910
  };
4917
- const toolchainPath = (0, import_node_path2.join)((0, import_node_os.homedir)(), ".napi-rs", "cross-toolchain", version2, this.target.triple);
3911
+ const toolchainPath = (0, import_node_path3.join)((0, import_node_os.homedir)(), ".napi-rs", "cross-toolchain", version2, this.target.triple);
4918
3912
  (0, import_node_fs3.mkdirSync)(toolchainPath, { recursive: true });
4919
- if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(toolchainPath, "package.json"))) {
3913
+ if ((0, import_node_fs3.existsSync)((0, import_node_path3.join)(toolchainPath, "package.json"))) {
4920
3914
  debug3(`Toolchain ${toolchainPath} exists, skip extracting`);
4921
3915
  } else {
4922
3916
  const tarArchive = download(process.arch, this.target.triple);
@@ -4925,29 +3919,29 @@ var Builder = class {
4925
3919
  const upperCaseTarget = targetToEnvVar(this.target.triple);
4926
3920
  const crossTargetName = alias[this.target.triple] ?? this.target.triple;
4927
3921
  const linkerEnv = `CARGO_TARGET_${upperCaseTarget}_LINKER`;
4928
- this.envs[linkerEnv] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-gcc`);
3922
+ this.envs[linkerEnv] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-gcc`);
4929
3923
  if (!process.env.TARGET_SYSROOT) {
4930
- this.envs[`TARGET_SYSROOT`] = (0, import_node_path2.join)(toolchainPath, crossTargetName, "sysroot");
3924
+ this.envs[`TARGET_SYSROOT`] = (0, import_node_path3.join)(toolchainPath, crossTargetName, "sysroot");
4931
3925
  }
4932
3926
  if (!process.env.TARGET_AR) {
4933
- this.envs[`TARGET_AR`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-ar`);
3927
+ this.envs[`TARGET_AR`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-ar`);
4934
3928
  }
4935
3929
  if (!process.env.TARGET_RANLIB) {
4936
- this.envs[`TARGET_RANLIB`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-ranlib`);
3930
+ this.envs[`TARGET_RANLIB`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-ranlib`);
4937
3931
  }
4938
3932
  if (!process.env.TARGET_READELF) {
4939
- this.envs[`TARGET_READELF`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-readelf`);
3933
+ this.envs[`TARGET_READELF`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-readelf`);
4940
3934
  }
4941
3935
  if (!process.env.TARGET_C_INCLUDE_PATH) {
4942
- this.envs[`TARGET_C_INCLUDE_PATH`] = (0, import_node_path2.join)(toolchainPath, crossTargetName, "sysroot", "usr", "include/");
3936
+ this.envs[`TARGET_C_INCLUDE_PATH`] = (0, import_node_path3.join)(toolchainPath, crossTargetName, "sysroot", "usr", "include/");
4943
3937
  }
4944
3938
  if (!process.env.CC && !process.env.TARGET_CC) {
4945
- this.envs[`CC`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-gcc`);
4946
- this.envs[`TARGET_CC`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-gcc`);
3939
+ this.envs[`CC`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-gcc`);
3940
+ this.envs[`TARGET_CC`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-gcc`);
4947
3941
  }
4948
3942
  if (!process.env.CXX && !process.env.TARGET_CXX) {
4949
- this.envs[`CXX`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-g++`);
4950
- this.envs[`TARGET_CXX`] = (0, import_node_path2.join)(toolchainPath, "bin", `${crossTargetName}-g++`);
3943
+ this.envs[`CXX`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-g++`);
3944
+ this.envs[`TARGET_CXX`] = (0, import_node_path3.join)(toolchainPath, "bin", `${crossTargetName}-g++`);
4951
3945
  }
4952
3946
  if (process.env.CC?.startsWith("clang") && (process.env.TARGET_CC?.startsWith("clang") || !process.env.TARGET_CC) || process.env.TARGET_CC?.startsWith("clang")) {
4953
3947
  const CFLAGS = process.env.CFLAGS ?? "";
@@ -4968,7 +3962,7 @@ var Builder = class {
4968
3962
  debug3(" %i", `cargo ${this.args.join(" ")}`);
4969
3963
  const controller = new AbortController();
4970
3964
  const watch = this.options.watch;
4971
- const buildTask = new Promise((resolve7, reject) => {
3965
+ const buildTask = new Promise((resolve8, reject) => {
4972
3966
  if (this.options.useCross && this.options.crossCompile) {
4973
3967
  throw new Error("`--use-cross` and `--cross-compile` can not be used together");
4974
3968
  }
@@ -4982,7 +3976,7 @@ var Builder = class {
4982
3976
  buildProcess.once("exit", (code) => {
4983
3977
  if (code === 0) {
4984
3978
  debug3("%i", `Build crate ${this.crate.name} successfully!`);
4985
- resolve7();
3979
+ resolve8();
4986
3980
  } else {
4987
3981
  reject(new Error(`Build failed with exit code ${code}`));
4988
3982
  }
@@ -5115,19 +4109,19 @@ var Builder = class {
5115
4109
  });
5116
4110
  }
5117
4111
  if (this.target.platform === "wasi") {
5118
- const emnapi = (0, import_node_path2.join)(require2.resolve("emnapi"), "..", "lib", "wasm32-wasi-threads");
4112
+ const emnapi = (0, import_node_path3.join)(require2.resolve("emnapi"), "..", "lib", "wasm32-wasi-threads");
5119
4113
  this.envs.EMNAPI_LINK_DIR = emnapi;
5120
4114
  this.envs.SETJMP_LINK_DIR = import_wasm_sjlj.lib;
5121
4115
  const { WASI_SDK_PATH } = process.env;
5122
4116
  if (WASI_SDK_PATH && (0, import_node_fs3.existsSync)(WASI_SDK_PATH)) {
5123
- this.envs.CARGO_TARGET_WASM32_WASI_PREVIEW1_THREADS_LINKER = (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "wasm-ld");
5124
- this.envs.CARGO_TARGET_WASM32_WASIP1_LINKER = (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "wasm-ld");
5125
- this.envs.CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER = (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "wasm-ld");
5126
- this.envs.CARGO_TARGET_WASM32_WASIP2_LINKER = (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "wasm-ld");
5127
- this.setEnvIfNotExists("CC", (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "clang"));
5128
- this.setEnvIfNotExists("CXX", (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "clang++"));
5129
- this.setEnvIfNotExists("AR", (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "ar"));
5130
- this.setEnvIfNotExists("RANLIB", (0, import_node_path2.join)(WASI_SDK_PATH, "bin", "ranlib"));
4117
+ this.envs.CARGO_TARGET_WASM32_WASI_PREVIEW1_THREADS_LINKER = (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "wasm-ld");
4118
+ this.envs.CARGO_TARGET_WASM32_WASIP1_LINKER = (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "wasm-ld");
4119
+ this.envs.CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER = (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "wasm-ld");
4120
+ this.envs.CARGO_TARGET_WASM32_WASIP2_LINKER = (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "wasm-ld");
4121
+ this.setEnvIfNotExists("CC", (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "clang"));
4122
+ this.setEnvIfNotExists("CXX", (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "clang++"));
4123
+ this.setEnvIfNotExists("AR", (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "ar"));
4124
+ this.setEnvIfNotExists("RANLIB", (0, import_node_path3.join)(WASI_SDK_PATH, "bin", "ranlib"));
5131
4125
  this.setEnvIfNotExists("CFLAGS", `--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread -mllvm -wasm-enable-sjlj -I${import_wasm_sjlj.include}`);
5132
4126
  this.setEnvIfNotExists("CXXFLAGS", `--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread -mllvm -wasm-enable-sjlj -I${import_wasm_sjlj.include}`);
5133
4127
  this.setEnvIfNotExists(`LDFLAGS`, `-fuse-ld=${WASI_SDK_PATH}/bin/wasm-ld --target=wasm32-wasi-threads`);
@@ -5141,7 +4135,7 @@ var Builder = class {
5141
4135
  }
5142
4136
  setForceBuildEnvs(typeDefTmpFolder) {
5143
4137
  this.metadata.packages.forEach((crate) => {
5144
- if (crate.dependencies.some((d) => d.name === "napi-derive") && !(0, import_node_fs3.existsSync)((0, import_node_path2.join)(typeDefTmpFolder, crate.name))) {
4138
+ if (crate.dependencies.some((d) => d.name === "napi-derive") && !(0, import_node_fs3.existsSync)((0, import_node_path3.join)(typeDefTmpFolder, crate.name))) {
5145
4139
  this.envs[`NAPI_FORCE_BUILD_${crate.name.replace(/-/g, "_").toUpperCase()}`] = Date.now().toString();
5146
4140
  }
5147
4141
  });
@@ -5186,7 +4180,7 @@ var Builder = class {
5186
4180
  return this;
5187
4181
  }
5188
4182
  generateIntermediateTypeDefFolder() {
5189
- let folder = (0, import_node_path2.join)(this.targetDir, "napi-rs", `${this.crate.name}-${(0, import_node_crypto.createHash)("sha256").update(this.crate.manifest_path).update(CLI_VERSION).digest("hex").substring(0, 8)}`);
4183
+ let folder = (0, import_node_path3.join)(this.targetDir, "napi-rs", `${this.crate.name}-${(0, import_node_crypto.createHash)("sha256").update(this.crate.manifest_path).update(CLI_VERSION).digest("hex").substring(0, 8)}`);
5190
4184
  if (!this.options.dtsCache) {
5191
4185
  (0, import_node_fs3.rmSync)(folder, { recursive: true, force: true });
5192
4186
  folder += `_${Date.now()}`;
@@ -5225,9 +4219,9 @@ var Builder = class {
5225
4219
  return;
5226
4220
  }
5227
4221
  const profile = this.options.profile ?? (this.options.release ? "release" : "debug");
5228
- const src = (0, import_node_path2.join)(this.targetDir, this.target.triple, profile, srcName);
4222
+ const src = (0, import_node_path3.join)(this.targetDir, this.target.triple, profile, srcName);
5229
4223
  debug3(`Copy artifact from: [${src}]`);
5230
- const dest = (0, import_node_path2.join)(this.outputDir, destName);
4224
+ const dest = (0, import_node_path3.join)(this.outputDir, destName);
5231
4225
  const isWasm = dest.endsWith(".wasm");
5232
4226
  try {
5233
4227
  if (await fileExists(dest)) {
@@ -5258,7 +4252,7 @@ var Builder = class {
5258
4252
  kind: dest.endsWith(".node") ? "node" : isWasm ? "wasm" : "exe",
5259
4253
  path: dest
5260
4254
  });
5261
- return wasmBinaryName ? (0, import_node_path2.join)(this.outputDir, wasmBinaryName) : null;
4255
+ return wasmBinaryName ? (0, import_node_path3.join)(this.outputDir, wasmBinaryName) : null;
5262
4256
  } catch (e) {
5263
4257
  throw new Error("Failed to copy artifact", { cause: e });
5264
4258
  }
@@ -5293,7 +4287,7 @@ var Builder = class {
5293
4287
  if (!this.enableTypeDef || !await dirExistsAsync(typeDefDir)) {
5294
4288
  return [];
5295
4289
  }
5296
- const dest = (0, import_node_path2.join)(this.outputDir, this.options.dts ?? "index.d.ts");
4290
+ const dest = (0, import_node_path3.join)(this.outputDir, this.options.dts ?? "index.d.ts");
5297
4291
  let header = "";
5298
4292
  let dts = "";
5299
4293
  let exports2 = [];
@@ -5301,7 +4295,7 @@ var Builder = class {
5301
4295
  const dtsHeader = this.options.dtsHeader ?? this.config.dtsHeader;
5302
4296
  if (this.config.dtsHeaderFile) {
5303
4297
  try {
5304
- header = await readFileAsync((0, import_node_path2.join)(this.options.cwd, this.config.dtsHeaderFile), "utf-8");
4298
+ header = await readFileAsync((0, import_node_path3.join)(this.options.cwd, this.config.dtsHeaderFile), "utf-8");
5305
4299
  } catch (e) {
5306
4300
  debug3.warn(`Failed to read dts header file ${this.config.dtsHeaderFile}`, e);
5307
4301
  }
@@ -5320,7 +4314,7 @@ var Builder = class {
5320
4314
  if (!file.isFile()) {
5321
4315
  continue;
5322
4316
  }
5323
- const { dts: fileDts, exports: fileExports } = await processTypeDef((0, import_node_path2.join)(typeDefDir, file.name), this.options.constEnum ?? this.config.constEnum ?? true);
4317
+ const { dts: fileDts, exports: fileExports } = await processTypeDef((0, import_node_path3.join)(typeDefDir, file.name), this.options.constEnum ?? this.config.constEnum ?? true);
5324
4318
  dts += fileDts;
5325
4319
  exports2.push(...fileExports);
5326
4320
  }
@@ -5355,7 +4349,7 @@ export declare class ExternalObject<T> {
5355
4349
  const createBinding = this.options.esm ? createEsmBinding : createCjsBinding;
5356
4350
  const binding = createBinding(this.config.binaryName, this.config.packageName, idents);
5357
4351
  try {
5358
- const dest = (0, import_node_path2.join)(this.outputDir, name);
4352
+ const dest = (0, import_node_path3.join)(this.outputDir, name);
5359
4353
  debug3("Writing js binding to:");
5360
4354
  debug3(" %i", dest);
5361
4355
  await writeFileAsync(dest, binding, "utf-8");
@@ -5366,12 +4360,12 @@ export declare class ExternalObject<T> {
5366
4360
  }
5367
4361
  async writeWasiBinding(distFileName, idents) {
5368
4362
  if (distFileName) {
5369
- const { name, dir } = (0, import_node_path2.parse)(distFileName);
5370
- const bindingPath = (0, import_node_path2.join)(dir, `${this.config.binaryName}.wasi.cjs`);
5371
- const browserBindingPath = (0, import_node_path2.join)(dir, `${this.config.binaryName}.wasi-browser.js`);
5372
- const workerPath = (0, import_node_path2.join)(dir, "wasi-worker.mjs");
5373
- const browserWorkerPath = (0, import_node_path2.join)(dir, "wasi-worker-browser.mjs");
5374
- const browserEntryPath = (0, import_node_path2.join)(dir, "browser.js");
4363
+ const { name, dir } = (0, import_node_path3.parse)(distFileName);
4364
+ const bindingPath = (0, import_node_path3.join)(dir, `${this.config.binaryName}.wasi.cjs`);
4365
+ const browserBindingPath = (0, import_node_path3.join)(dir, `${this.config.binaryName}.wasi-browser.js`);
4366
+ const workerPath = (0, import_node_path3.join)(dir, "wasi-worker.mjs");
4367
+ const browserWorkerPath = (0, import_node_path3.join)(dir, "wasi-worker-browser.mjs");
4368
+ const browserEntryPath = (0, import_node_path3.join)(dir, "browser.js");
5375
4369
  const exportsCode = `module.exports = __napiModule.exports
5376
4370
  ` + idents.map((ident) => `module.exports.${ident} = __napiModule.exports.${ident}`).join("\n");
5377
4371
  await writeFileAsync(bindingPath, createWasiBinding(name, this.config.packageName, this.config.wasm?.initialMemory, this.config.wasm?.maximumMemory) + exportsCode + "\n", "utf8");
@@ -5391,15 +4385,15 @@ export declare class ExternalObject<T> {
5391
4385
  }
5392
4386
  return [];
5393
4387
  }
5394
- setEnvIfNotExists(env, value) {
4388
+ setEnvIfNotExists(env, value2) {
5395
4389
  if (!process.env[env]) {
5396
- this.envs[env] = value;
4390
+ this.envs[env] = value2;
5397
4391
  }
5398
4392
  }
5399
4393
  };
5400
4394
 
5401
4395
  // dist/api/create-npm-dirs.js
5402
- var import_node_path3 = require("node:path");
4396
+ var import_node_path4 = require("node:path");
5403
4397
  var import_semver = require("semver");
5404
4398
 
5405
4399
  // dist/def/create-npm-dirs.js
@@ -5465,12 +4459,12 @@ async function createNpmDirs(userOptions) {
5465
4459
  }
5466
4460
  await writeFileAsync(file, content);
5467
4461
  }
5468
- const packageJsonPath = (0, import_node_path3.resolve)(options.cwd, options.packageJsonPath);
5469
- const npmPath = (0, import_node_path3.resolve)(options.cwd, options.npmDir);
4462
+ const packageJsonPath = (0, import_node_path4.resolve)(options.cwd, options.packageJsonPath);
4463
+ const npmPath = (0, import_node_path4.resolve)(options.cwd, options.npmDir);
5470
4464
  debug4(`Read content from [${options.configPath ?? packageJsonPath}]`);
5471
- const { targets, binaryName, packageName, packageJson } = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path3.resolve)(options.cwd, options.configPath) : void 0);
4465
+ const { targets, binaryName, packageName, packageJson } = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path4.resolve)(options.cwd, options.configPath) : void 0);
5472
4466
  for (const target of targets) {
5473
- const targetDir = (0, import_node_path3.join)(npmPath, `${target.platformArchABI}`);
4467
+ const targetDir = (0, import_node_path4.join)(npmPath, `${target.platformArchABI}`);
5474
4468
  await mkdirAsync2(targetDir);
5475
4469
  const binaryFileName = target.arch === "wasm32" ? `${binaryName}.${target.platformArchABI}.wasm` : `${binaryName}.${target.platformArchABI}.node`;
5476
4470
  const scopedPackageJson = {
@@ -5521,9 +4515,9 @@ async function createNpmDirs(userOptions) {
5521
4515
  } else if (target.abi === "musl") {
5522
4516
  scopedPackageJson.libc = ["musl"];
5523
4517
  }
5524
- const targetPackageJson = (0, import_node_path3.join)(targetDir, "package.json");
4518
+ const targetPackageJson = (0, import_node_path4.join)(targetDir, "package.json");
5525
4519
  await writeFileAsync2(targetPackageJson, JSON.stringify(scopedPackageJson, null, 2) + "\n");
5526
- const targetReadme = (0, import_node_path3.join)(targetDir, "README.md");
4520
+ const targetReadme = (0, import_node_path4.join)(targetDir, "README.md");
5527
4521
  await writeFileAsync2(targetReadme, readme(packageName, target));
5528
4522
  debug4.info(`${packageName} -${target.platformArchABI} created`);
5529
4523
  }
@@ -5537,7 +4531,11 @@ This is the **${target.triple}** binary for \`${packageName}\`
5537
4531
 
5538
4532
  // dist/api/new.js
5539
4533
  var import_node_child_process5 = require("node:child_process");
5540
- var import_node_path4 = __toESM(require("node:path"), 1);
4534
+ var import_node_fs5 = require("node:fs");
4535
+ var import_node_os2 = require("node:os");
4536
+ var import_node_path6 = __toESM(require("node:path"), 1);
4537
+ var import_node_fs6 = require("node:fs");
4538
+ var import_js_yaml3 = require("js-yaml");
5541
4539
 
5542
4540
  // dist/def/new.js
5543
4541
  var import_clipanion3 = require("clipanion");
@@ -5615,195 +4613,1495 @@ function applyDefaultNewOptions(options) {
5615
4613
  };
5616
4614
  }
5617
4615
 
5618
- // dist/api/new.js
5619
- var debug5 = debugFactory("new");
5620
- function processOptions(options) {
5621
- debug5("Processing options...");
5622
- if (!options.path) {
5623
- throw new Error("Please provide the path as the argument");
4616
+ // dist/api/rename.js
4617
+ var import_node_fs4 = require("node:fs");
4618
+ var import_promises = require("node:fs/promises");
4619
+ var import_node_path5 = require("node:path");
4620
+
4621
+ // ../node_modules/@std/toml/stringify.js
4622
+ function joinKeys(keys2) {
4623
+ return keys2.map((str) => {
4624
+ return str.length === 0 || str.match(/[^A-Za-z0-9_-]/) ? JSON.stringify(str) : str;
4625
+ }).join(".");
4626
+ }
4627
+ var Dumper = class {
4628
+ maxPad = 0;
4629
+ srcObject;
4630
+ output = [];
4631
+ #arrayTypeCache = /* @__PURE__ */ new Map();
4632
+ constructor(srcObjc) {
4633
+ this.srcObject = srcObjc;
4634
+ }
4635
+ dump(fmtOptions = {}) {
4636
+ this.output = this.#printObject(this.srcObject);
4637
+ this.output = this.#format(fmtOptions);
4638
+ return this.output;
4639
+ }
4640
+ #printObject(obj, keys2 = []) {
4641
+ const out = [];
4642
+ const props = Object.keys(obj);
4643
+ const inlineProps = [];
4644
+ const multilineProps = [];
4645
+ for (const prop of props) {
4646
+ if (this.#isSimplySerializable(obj[prop])) {
4647
+ inlineProps.push(prop);
4648
+ } else {
4649
+ multilineProps.push(prop);
4650
+ }
4651
+ }
4652
+ const sortedProps = inlineProps.concat(multilineProps);
4653
+ for (const prop of sortedProps) {
4654
+ const value2 = obj[prop];
4655
+ if (value2 instanceof Date) {
4656
+ out.push(this.#dateDeclaration([
4657
+ prop
4658
+ ], value2));
4659
+ } else if (typeof value2 === "string" || value2 instanceof RegExp) {
4660
+ out.push(this.#strDeclaration([
4661
+ prop
4662
+ ], value2.toString()));
4663
+ } else if (typeof value2 === "number") {
4664
+ out.push(this.#numberDeclaration([
4665
+ prop
4666
+ ], value2));
4667
+ } else if (typeof value2 === "boolean") {
4668
+ out.push(this.#boolDeclaration([
4669
+ prop
4670
+ ], value2));
4671
+ } else if (value2 instanceof Array) {
4672
+ const arrayType = this.#getTypeOfArray(value2);
4673
+ if (arrayType === "ONLY_PRIMITIVE") {
4674
+ out.push(this.#arrayDeclaration([
4675
+ prop
4676
+ ], value2));
4677
+ } else if (arrayType === "ONLY_OBJECT_EXCLUDING_ARRAY") {
4678
+ for (let i = 0; i < value2.length; i++) {
4679
+ out.push("");
4680
+ out.push(this.#headerGroup([
4681
+ ...keys2,
4682
+ prop
4683
+ ]));
4684
+ out.push(...this.#printObject(value2[i], [
4685
+ ...keys2,
4686
+ prop
4687
+ ]));
4688
+ }
4689
+ } else {
4690
+ const str = value2.map((x) => this.#printAsInlineValue(x)).join(",");
4691
+ out.push(`${this.#declaration([
4692
+ prop
4693
+ ])}[${str}]`);
4694
+ }
4695
+ } else if (typeof value2 === "object") {
4696
+ out.push("");
4697
+ out.push(this.#header([
4698
+ ...keys2,
4699
+ prop
4700
+ ]));
4701
+ if (value2) {
4702
+ const toParse = value2;
4703
+ out.push(...this.#printObject(toParse, [
4704
+ ...keys2,
4705
+ prop
4706
+ ]));
4707
+ }
4708
+ }
4709
+ }
4710
+ out.push("");
4711
+ return out;
5624
4712
  }
5625
- options.path = import_node_path4.default.resolve(process.cwd(), options.path);
5626
- debug5(`Resolved target path to: ${options.path}`);
5627
- if (!options.name) {
5628
- options.name = import_node_path4.default.parse(options.path).base;
5629
- debug5(`No project name provided, fix it to dir name: ${options.name}`);
4713
+ #isPrimitive(value2) {
4714
+ return value2 instanceof Date || value2 instanceof RegExp || [
4715
+ "string",
4716
+ "number",
4717
+ "boolean"
4718
+ ].includes(typeof value2);
5630
4719
  }
5631
- if (!options.targets?.length) {
5632
- if (options.enableAllTargets) {
5633
- options.targets = AVAILABLE_TARGETS.concat();
5634
- debug5("Enable all targets");
5635
- } else if (options.enableDefaultTargets) {
5636
- options.targets = DEFAULT_TARGETS.concat();
5637
- debug5("Enable default targets");
5638
- } else {
5639
- throw new Error("At least one target must be enabled");
4720
+ #getTypeOfArray(arr) {
4721
+ if (this.#arrayTypeCache.has(arr)) {
4722
+ return this.#arrayTypeCache.get(arr);
5640
4723
  }
4724
+ const type = this.#doGetTypeOfArray(arr);
4725
+ this.#arrayTypeCache.set(arr, type);
4726
+ return type;
5641
4727
  }
5642
- if (options.targets.some((target) => target === "wasm32-wasi-preview1-threads")) {
5643
- const out = (0, import_node_child_process5.execSync)(`rustup target list`, {
5644
- encoding: "utf8"
5645
- });
5646
- if (out.includes("wasm32-wasip1-threads")) {
5647
- options.targets.map((target) => target === "wasm32-wasi-preview1-threads" ? "wasm32-wasip1-threads" : target);
4728
+ #doGetTypeOfArray(arr) {
4729
+ if (!arr.length) {
4730
+ return "ONLY_PRIMITIVE";
5648
4731
  }
5649
- }
5650
- return applyDefaultNewOptions(options);
5651
- }
5652
- async function newProject(userOptions) {
5653
- debug5("Will create napi-rs project with given options:");
5654
- debug5(userOptions);
5655
- const options = processOptions(userOptions);
5656
- debug5("Targets to be enabled:");
5657
- debug5(options.targets);
5658
- const outputs = await generateFiles(options);
5659
- await ensurePath(options.path, options.dryRun);
5660
- await dumpOutputs(outputs, options.dryRun);
5661
- debug5(`Project created at: ${options.path}`);
5662
- }
5663
- async function ensurePath(path2, dryRun = false) {
5664
- const stat2 = await statAsync(path2, {}).catch(() => void 0);
5665
- if (stat2) {
5666
- if (stat2.isFile()) {
5667
- throw new Error(`Path ${path2} for creating new napi-rs project already exists and it's not a directory.`);
5668
- } else if (stat2.isDirectory()) {
5669
- const files = await readdirAsync(path2);
5670
- if (files.length) {
5671
- throw new Error(`Path ${path2} for creating new napi-rs project already exists and it's not empty.`);
4732
+ const onlyPrimitive = this.#isPrimitive(arr[0]);
4733
+ if (arr[0] instanceof Array) {
4734
+ return "MIXED";
4735
+ }
4736
+ for (let i = 1; i < arr.length; i++) {
4737
+ if (onlyPrimitive !== this.#isPrimitive(arr[i]) || arr[i] instanceof Array) {
4738
+ return "MIXED";
5672
4739
  }
5673
4740
  }
5674
- }
5675
- if (!dryRun) {
5676
- try {
5677
- debug5(`Try to create target directory: ${path2}`);
5678
- if (!dryRun) {
5679
- await mkdirAsync(path2, { recursive: true });
4741
+ return onlyPrimitive ? "ONLY_PRIMITIVE" : "ONLY_OBJECT_EXCLUDING_ARRAY";
4742
+ }
4743
+ #printAsInlineValue(value2) {
4744
+ if (value2 instanceof Date) {
4745
+ return `"${this.#printDate(value2)}"`;
4746
+ } else if (typeof value2 === "string" || value2 instanceof RegExp) {
4747
+ return JSON.stringify(value2.toString());
4748
+ } else if (typeof value2 === "number") {
4749
+ return value2;
4750
+ } else if (typeof value2 === "boolean") {
4751
+ return value2.toString();
4752
+ } else if (value2 instanceof Array) {
4753
+ const str = value2.map((x) => this.#printAsInlineValue(x)).join(",");
4754
+ return `[${str}]`;
4755
+ } else if (typeof value2 === "object") {
4756
+ if (!value2) {
4757
+ throw new Error("Should never reach");
4758
+ }
4759
+ const str = Object.keys(value2).map((key) => {
4760
+ return `${joinKeys([
4761
+ key
4762
+ ])} = ${// deno-lint-ignore no-explicit-any
4763
+ this.#printAsInlineValue(value2[key])}`;
4764
+ }).join(",");
4765
+ return `{${str}}`;
4766
+ }
4767
+ throw new Error("Should never reach");
4768
+ }
4769
+ #isSimplySerializable(value2) {
4770
+ return typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean" || value2 instanceof RegExp || value2 instanceof Date || value2 instanceof Array && this.#getTypeOfArray(value2) !== "ONLY_OBJECT_EXCLUDING_ARRAY";
4771
+ }
4772
+ #header(keys2) {
4773
+ return `[${joinKeys(keys2)}]`;
4774
+ }
4775
+ #headerGroup(keys2) {
4776
+ return `[[${joinKeys(keys2)}]]`;
4777
+ }
4778
+ #declaration(keys2) {
4779
+ const title = joinKeys(keys2);
4780
+ if (title.length > this.maxPad) {
4781
+ this.maxPad = title.length;
4782
+ }
4783
+ return `${title} = `;
4784
+ }
4785
+ #arrayDeclaration(keys2, value2) {
4786
+ return `${this.#declaration(keys2)}${JSON.stringify(value2)}`;
4787
+ }
4788
+ #strDeclaration(keys2, value2) {
4789
+ return `${this.#declaration(keys2)}${JSON.stringify(value2)}`;
4790
+ }
4791
+ #numberDeclaration(keys2, value2) {
4792
+ if (Number.isNaN(value2)) {
4793
+ return `${this.#declaration(keys2)}nan`;
4794
+ }
4795
+ switch (value2) {
4796
+ case Infinity:
4797
+ return `${this.#declaration(keys2)}inf`;
4798
+ case -Infinity:
4799
+ return `${this.#declaration(keys2)}-inf`;
4800
+ default:
4801
+ return `${this.#declaration(keys2)}${value2}`;
4802
+ }
4803
+ }
4804
+ #boolDeclaration(keys2, value2) {
4805
+ return `${this.#declaration(keys2)}${value2}`;
4806
+ }
4807
+ #printDate(value2) {
4808
+ function dtPad(v, lPad = 2) {
4809
+ return v.padStart(lPad, "0");
4810
+ }
4811
+ const m = dtPad((value2.getUTCMonth() + 1).toString());
4812
+ const d = dtPad(value2.getUTCDate().toString());
4813
+ const h = dtPad(value2.getUTCHours().toString());
4814
+ const min = dtPad(value2.getUTCMinutes().toString());
4815
+ const s = dtPad(value2.getUTCSeconds().toString());
4816
+ const ms = dtPad(value2.getUTCMilliseconds().toString(), 3);
4817
+ const fData = `${value2.getUTCFullYear()}-${m}-${d}T${h}:${min}:${s}.${ms}`;
4818
+ return fData;
4819
+ }
4820
+ #dateDeclaration(keys2, value2) {
4821
+ return `${this.#declaration(keys2)}${this.#printDate(value2)}`;
4822
+ }
4823
+ #format(options = {}) {
4824
+ const { keyAlignment = false } = options;
4825
+ const rDeclaration = /^(\".*\"|[^=]*)\s=/;
4826
+ const out = [];
4827
+ for (let i = 0; i < this.output.length; i++) {
4828
+ const l = this.output[i];
4829
+ if (l[0] === "[" && l[1] !== "[") {
4830
+ if (this.output[i + 1] === "" && this.output[i + 2]?.slice(0, l.length) === l.slice(0, -1) + ".") {
4831
+ i += 1;
4832
+ continue;
4833
+ }
4834
+ out.push(l);
4835
+ } else {
4836
+ if (keyAlignment) {
4837
+ const m = rDeclaration.exec(l);
4838
+ if (m && m[1]) {
4839
+ out.push(l.replace(m[1], m[1].padEnd(this.maxPad)));
4840
+ } else {
4841
+ out.push(l);
4842
+ }
4843
+ } else {
4844
+ out.push(l);
4845
+ }
4846
+ }
4847
+ }
4848
+ const cleanedOutput = [];
4849
+ for (let i = 0; i < out.length; i++) {
4850
+ const l = out[i];
4851
+ if (!(l === "" && out[i + 1] === "")) {
4852
+ cleanedOutput.push(l);
5680
4853
  }
5681
- } catch (e) {
5682
- throw new Error(`Failed to create target directory: ${path2}`, {
5683
- cause: e
5684
- });
5685
4854
  }
4855
+ return cleanedOutput;
5686
4856
  }
4857
+ };
4858
+ function stringify(obj, options) {
4859
+ return new Dumper(obj).dump(options).join("\n");
5687
4860
  }
5688
- async function generateFiles(options) {
5689
- const packageJson = await generatePackageJson(options);
5690
- return [
5691
- generateCargoToml,
5692
- generateLibRs,
5693
- generateBuildRs,
5694
- generateGithubWorkflow,
5695
- generateIgnoreFiles
5696
- ].flatMap((generator) => {
5697
- const output = generator(options);
5698
- if (!output) {
5699
- return [];
5700
- }
5701
- if (Array.isArray(output)) {
5702
- return output.map((o) => ({
5703
- ...o,
5704
- target: import_node_path4.default.join(options.path, o.target)
5705
- }));
5706
- } else {
5707
- return [{ ...output, target: import_node_path4.default.join(options.path, output.target) }];
4861
+
4862
+ // ../node_modules/@jsr/std__collections/_utils.js
4863
+ function filterInPlace(array, predicate) {
4864
+ let outputIndex = 0;
4865
+ for (const cur of array) {
4866
+ if (!predicate(cur)) {
4867
+ continue;
5708
4868
  }
5709
- }).concat([
5710
- { ...packageJson, target: import_node_path4.default.join(options.path, packageJson.target) }
5711
- ]);
5712
- }
5713
- function generateCargoToml(options) {
5714
- return {
5715
- target: "./Cargo.toml",
5716
- content: createCargoToml({
5717
- name: options.name,
5718
- license: options.license,
5719
- features: [`napi${options.minNodeApiVersion}`],
5720
- deriveFeatures: options.enableTypeDef ? ["type-def"] : []
5721
- })
5722
- };
5723
- }
5724
- function generateLibRs(_options) {
5725
- return {
5726
- target: "./src/lib.rs",
5727
- content: createLibRs()
5728
- };
5729
- }
5730
- function generateBuildRs(_options) {
5731
- return {
5732
- target: "./build.rs",
5733
- content: createBuildRs()
5734
- };
5735
- }
5736
- async function generatePackageJson(options) {
5737
- return {
5738
- target: "./package.json",
5739
- content: await createPackageJson({
5740
- name: options.name,
5741
- binaryName: getBinaryName(options.name),
5742
- targets: options.targets,
5743
- license: options.license,
5744
- engineRequirement: napiEngineRequirement(options.minNodeApiVersion),
5745
- cliVersion: CLI_VERSION,
5746
- testFramework: options.testFramework
5747
- })
5748
- };
5749
- }
5750
- function generateGithubWorkflow(options) {
5751
- if (!options.enableGithubActions) {
5752
- return null;
4869
+ array[outputIndex] = cur;
4870
+ outputIndex += 1;
5753
4871
  }
5754
- return {
5755
- target: "./.github/workflows/ci.yml",
5756
- content: createGithubActionsCIYml(options.targets, options.packageManager, options.targets.find((t) => t.includes("wasm32-wasi")) ?? "wasm32-wasi-preview1-threads")
5757
- };
4872
+ array.splice(outputIndex);
4873
+ return array;
5758
4874
  }
5759
- function generateIgnoreFiles(_options) {
5760
- return [
5761
- {
5762
- target: "./.gitignore",
5763
- content: gitIgnore
5764
- },
5765
- {
5766
- target: "./.npmignore",
5767
- content: npmIgnore
5768
- }
5769
- ];
4875
+
4876
+ // ../node_modules/@jsr/std__collections/deep_merge.js
4877
+ function deepMerge(record, other, options) {
4878
+ return deepMergeInternal(record, other, /* @__PURE__ */ new Set(), options);
5770
4879
  }
5771
- async function dumpOutputs(outputs, dryRun) {
5772
- for (const output of outputs) {
5773
- if (!output) {
4880
+ function deepMergeInternal(record, other, seen, options) {
4881
+ const result = {};
4882
+ const keys2 = /* @__PURE__ */ new Set([
4883
+ ...getKeys(record),
4884
+ ...getKeys(other)
4885
+ ]);
4886
+ for (const key of keys2) {
4887
+ if (key === "__proto__") {
5774
4888
  continue;
5775
4889
  }
5776
- debug5(`Writing project file: ${output.target}`);
5777
- if (dryRun) {
5778
- debug5(output.content);
4890
+ const a = record[key];
4891
+ if (!Object.hasOwn(other, key)) {
4892
+ result[key] = a;
5779
4893
  continue;
5780
4894
  }
5781
- try {
5782
- await mkdirAsync(import_node_path4.default.dirname(output.target), { recursive: true });
5783
- await writeFileAsync(output.target, output.content, "utf-8");
5784
- } catch (e) {
5785
- throw new Error(`Failed to write file: ${output.target}`, { cause: e });
4895
+ const b = other[key];
4896
+ if (isNonNullObject(a) && isNonNullObject(b) && !seen.has(a) && !seen.has(b)) {
4897
+ seen.add(a);
4898
+ seen.add(b);
4899
+ result[key] = mergeObjects(a, b, seen, options);
4900
+ continue;
5786
4901
  }
4902
+ result[key] = b;
5787
4903
  }
4904
+ return result;
5788
4905
  }
5789
- function getBinaryName(name) {
5790
- return name.split("/").pop();
5791
- }
5792
-
5793
- // dist/api/pre-publish.js
5794
- var import_node_child_process6 = require("node:child_process");
5795
- var import_node_fs4 = require("node:fs");
5796
- var import_node_path6 = require("node:path");
5797
-
5798
- // ../node_modules/@octokit/rest/node_modules/universal-user-agent/index.js
5799
- function getUserAgent() {
5800
- if (typeof navigator === "object" && "userAgent" in navigator) {
5801
- return navigator.userAgent;
5802
- }
5803
- if (typeof process === "object" && process.version !== void 0) {
5804
- return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;
4906
+ function mergeObjects(left, right, seen, options = {
4907
+ arrays: "merge",
4908
+ sets: "merge",
4909
+ maps: "merge"
4910
+ }) {
4911
+ if (isMergeable(left) && isMergeable(right)) {
4912
+ return deepMergeInternal(left, right, seen, options);
4913
+ }
4914
+ if (isIterable(left) && isIterable(right)) {
4915
+ if (Array.isArray(left) && Array.isArray(right)) {
4916
+ if (options.arrays === "merge") {
4917
+ return left.concat(right);
4918
+ }
4919
+ return right;
4920
+ }
4921
+ if (left instanceof Map && right instanceof Map) {
4922
+ if (options.maps === "merge") {
4923
+ return new Map([
4924
+ ...left,
4925
+ ...right
4926
+ ]);
4927
+ }
4928
+ return right;
4929
+ }
4930
+ if (left instanceof Set && right instanceof Set) {
4931
+ if (options.sets === "merge") {
4932
+ return /* @__PURE__ */ new Set([
4933
+ ...left,
4934
+ ...right
4935
+ ]);
4936
+ }
4937
+ return right;
4938
+ }
5805
4939
  }
5806
- return "<environment undetectable>";
4940
+ return right;
4941
+ }
4942
+ function isMergeable(value2) {
4943
+ return Object.getPrototypeOf(value2) === Object.prototype;
4944
+ }
4945
+ function isIterable(value2) {
4946
+ return typeof value2[Symbol.iterator] === "function";
4947
+ }
4948
+ function isNonNullObject(value2) {
4949
+ return value2 !== null && typeof value2 === "object";
4950
+ }
4951
+ function getKeys(record) {
4952
+ const result = Object.getOwnPropertySymbols(record);
4953
+ filterInPlace(result, (key) => Object.prototype.propertyIsEnumerable.call(record, key));
4954
+ result.push(...Object.keys(record));
4955
+ return result;
4956
+ }
4957
+
4958
+ // ../node_modules/@std/toml/_parser.js
4959
+ function isLeap(yearNumber) {
4960
+ return yearNumber % 4 === 0 && yearNumber % 100 !== 0 || yearNumber % 400 === 0;
4961
+ }
4962
+ var Scanner = class {
4963
+ #whitespace = /[ \t]/;
4964
+ #position = 0;
4965
+ #source;
4966
+ constructor(source) {
4967
+ this.#source = source;
4968
+ }
4969
+ get position() {
4970
+ return this.#position;
4971
+ }
4972
+ get source() {
4973
+ return this.#source;
4974
+ }
4975
+ /**
4976
+ * Get current character
4977
+ * @param index - relative index from current position
4978
+ */
4979
+ char(index = 0) {
4980
+ return this.#source[this.#position + index] ?? "";
4981
+ }
4982
+ /**
4983
+ * Get sliced string
4984
+ * @param start - start position relative from current position
4985
+ * @param end - end position relative from current position
4986
+ */
4987
+ slice(start, end) {
4988
+ return this.#source.slice(this.#position + start, this.#position + end);
4989
+ }
4990
+ /**
4991
+ * Move position to next
4992
+ */
4993
+ next(count = 1) {
4994
+ this.#position += count;
4995
+ }
4996
+ skipWhitespaces() {
4997
+ while (this.#whitespace.test(this.char()) && !this.eof()) {
4998
+ this.next();
4999
+ }
5000
+ if (!this.isCurrentCharEOL() && /\s/.test(this.char())) {
5001
+ const escaped = "\\u" + this.char().charCodeAt(0).toString(16);
5002
+ const position = this.#position;
5003
+ throw new SyntaxError(`Cannot parse the TOML: It contains invalid whitespace at position '${position}': \`${escaped}\``);
5004
+ }
5005
+ }
5006
+ nextUntilChar(options = {
5007
+ skipComments: true
5008
+ }) {
5009
+ while (!this.eof()) {
5010
+ const char = this.char();
5011
+ if (this.#whitespace.test(char) || this.isCurrentCharEOL()) {
5012
+ this.next();
5013
+ } else if (options.skipComments && this.char() === "#") {
5014
+ while (!this.isCurrentCharEOL() && !this.eof()) {
5015
+ this.next();
5016
+ }
5017
+ } else {
5018
+ break;
5019
+ }
5020
+ }
5021
+ }
5022
+ /**
5023
+ * Position reached EOF or not
5024
+ */
5025
+ eof() {
5026
+ return this.#position >= this.#source.length;
5027
+ }
5028
+ isCurrentCharEOL() {
5029
+ return this.char() === "\n" || this.startsWith("\r\n");
5030
+ }
5031
+ startsWith(searchString) {
5032
+ return this.#source.startsWith(searchString, this.#position);
5033
+ }
5034
+ match(regExp) {
5035
+ if (!regExp.sticky) {
5036
+ throw new Error(`RegExp ${regExp} does not have a sticky 'y' flag`);
5037
+ }
5038
+ regExp.lastIndex = this.#position;
5039
+ return this.#source.match(regExp);
5040
+ }
5041
+ };
5042
+ function success(body) {
5043
+ return {
5044
+ ok: true,
5045
+ body
5046
+ };
5047
+ }
5048
+ function failure() {
5049
+ return {
5050
+ ok: false
5051
+ };
5052
+ }
5053
+ function unflat(keys2, values = {}) {
5054
+ return keys2.reduceRight((acc, key) => ({
5055
+ [key]: acc
5056
+ }), values);
5057
+ }
5058
+ function isObject2(value2) {
5059
+ return typeof value2 === "object" && value2 !== null;
5060
+ }
5061
+ function getTargetValue(target, keys2) {
5062
+ const key = keys2[0];
5063
+ if (!key) {
5064
+ throw new Error("Cannot parse the TOML: key length is not a positive number");
5065
+ }
5066
+ return target[key];
5067
+ }
5068
+ function deepAssignTable(target, table2) {
5069
+ const { keys: keys2, type, value: value2 } = table2;
5070
+ const currentValue = getTargetValue(target, keys2);
5071
+ if (currentValue === void 0) {
5072
+ return Object.assign(target, unflat(keys2, value2));
5073
+ }
5074
+ if (Array.isArray(currentValue)) {
5075
+ const last2 = currentValue.at(-1);
5076
+ deepAssign(last2, {
5077
+ type,
5078
+ keys: keys2.slice(1),
5079
+ value: value2
5080
+ });
5081
+ return target;
5082
+ }
5083
+ if (isObject2(currentValue)) {
5084
+ deepAssign(currentValue, {
5085
+ type,
5086
+ keys: keys2.slice(1),
5087
+ value: value2
5088
+ });
5089
+ return target;
5090
+ }
5091
+ throw new Error("Unexpected assign");
5092
+ }
5093
+ function deepAssignTableArray(target, table2) {
5094
+ const { type, keys: keys2, value: value2 } = table2;
5095
+ const currentValue = getTargetValue(target, keys2);
5096
+ if (currentValue === void 0) {
5097
+ return Object.assign(target, unflat(keys2, [
5098
+ value2
5099
+ ]));
5100
+ }
5101
+ if (Array.isArray(currentValue)) {
5102
+ currentValue.push(value2);
5103
+ return target;
5104
+ }
5105
+ if (isObject2(currentValue)) {
5106
+ deepAssign(currentValue, {
5107
+ type,
5108
+ keys: keys2.slice(1),
5109
+ value: value2
5110
+ });
5111
+ return target;
5112
+ }
5113
+ throw new Error("Unexpected assign");
5114
+ }
5115
+ function deepAssign(target, body) {
5116
+ switch (body.type) {
5117
+ case "Block":
5118
+ return deepMerge(target, body.value);
5119
+ case "Table":
5120
+ return deepAssignTable(target, body);
5121
+ case "TableArray":
5122
+ return deepAssignTableArray(target, body);
5123
+ }
5124
+ }
5125
+ function or(parsers) {
5126
+ return (scanner) => {
5127
+ for (const parse6 of parsers) {
5128
+ const result = parse6(scanner);
5129
+ if (result.ok) return result;
5130
+ }
5131
+ return failure();
5132
+ };
5133
+ }
5134
+ function join4(parser, separator) {
5135
+ const Separator = character(separator);
5136
+ return (scanner) => {
5137
+ const out = [];
5138
+ const first = parser(scanner);
5139
+ if (!first.ok) return success(out);
5140
+ out.push(first.body);
5141
+ while (!scanner.eof()) {
5142
+ if (!Separator(scanner).ok) break;
5143
+ const result = parser(scanner);
5144
+ if (!result.ok) {
5145
+ throw new SyntaxError(`Invalid token after "${separator}"`);
5146
+ }
5147
+ out.push(result.body);
5148
+ }
5149
+ return success(out);
5150
+ };
5151
+ }
5152
+ function join1(parser, separator) {
5153
+ const Separator = character(separator);
5154
+ return (scanner) => {
5155
+ const first = parser(scanner);
5156
+ if (!first.ok) return failure();
5157
+ const out = [
5158
+ first.body
5159
+ ];
5160
+ while (!scanner.eof()) {
5161
+ if (!Separator(scanner).ok) break;
5162
+ const result = parser(scanner);
5163
+ if (!result.ok) {
5164
+ throw new SyntaxError(`Invalid token after "${separator}"`);
5165
+ }
5166
+ out.push(result.body);
5167
+ }
5168
+ return success(out);
5169
+ };
5170
+ }
5171
+ function kv(keyParser, separator, valueParser) {
5172
+ const Separator = character(separator);
5173
+ return (scanner) => {
5174
+ const position = scanner.position;
5175
+ const key = keyParser(scanner);
5176
+ if (!key.ok) return failure();
5177
+ const sep2 = Separator(scanner);
5178
+ if (!sep2.ok) {
5179
+ throw new SyntaxError(`key/value pair doesn't have "${separator}"`);
5180
+ }
5181
+ const value2 = valueParser(scanner);
5182
+ if (!value2.ok) {
5183
+ const lineEndIndex = scanner.source.indexOf("\n", scanner.position);
5184
+ const endPosition = lineEndIndex > 0 ? lineEndIndex : scanner.source.length;
5185
+ const line = scanner.source.slice(position, endPosition);
5186
+ throw new SyntaxError(`Cannot parse value on line '${line}'`);
5187
+ }
5188
+ return success(unflat(key.body, value2.body));
5189
+ };
5190
+ }
5191
+ function merge2(parser) {
5192
+ return (scanner) => {
5193
+ const result = parser(scanner);
5194
+ if (!result.ok) return failure();
5195
+ let body = {};
5196
+ for (const record of result.body) {
5197
+ if (typeof record === "object" && record !== null) {
5198
+ body = deepMerge(body, record);
5199
+ }
5200
+ }
5201
+ return success(body);
5202
+ };
5203
+ }
5204
+ function repeat(parser) {
5205
+ return (scanner) => {
5206
+ const body = [];
5207
+ while (!scanner.eof()) {
5208
+ const result = parser(scanner);
5209
+ if (!result.ok) break;
5210
+ body.push(result.body);
5211
+ scanner.nextUntilChar();
5212
+ }
5213
+ if (body.length === 0) return failure();
5214
+ return success(body);
5215
+ };
5216
+ }
5217
+ function surround(left, parser, right) {
5218
+ const Left = character(left);
5219
+ const Right = character(right);
5220
+ return (scanner) => {
5221
+ if (!Left(scanner).ok) {
5222
+ return failure();
5223
+ }
5224
+ const result = parser(scanner);
5225
+ if (!result.ok) {
5226
+ throw new SyntaxError(`Invalid token after "${left}"`);
5227
+ }
5228
+ if (!Right(scanner).ok) {
5229
+ throw new SyntaxError(`Not closed by "${right}" after started with "${left}"`);
5230
+ }
5231
+ return success(result.body);
5232
+ };
5233
+ }
5234
+ function character(str) {
5235
+ return (scanner) => {
5236
+ scanner.skipWhitespaces();
5237
+ if (!scanner.startsWith(str)) return failure();
5238
+ scanner.next(str.length);
5239
+ scanner.skipWhitespaces();
5240
+ return success(void 0);
5241
+ };
5242
+ }
5243
+ var BARE_KEY_REGEXP = /[A-Za-z0-9_-]+/y;
5244
+ function bareKey(scanner) {
5245
+ scanner.skipWhitespaces();
5246
+ const key = scanner.match(BARE_KEY_REGEXP)?.[0];
5247
+ if (!key) return failure();
5248
+ scanner.next(key.length);
5249
+ return success(key);
5250
+ }
5251
+ function escapeSequence(scanner) {
5252
+ if (scanner.char() !== "\\") return failure();
5253
+ scanner.next();
5254
+ switch (scanner.char()) {
5255
+ case "b":
5256
+ scanner.next();
5257
+ return success("\b");
5258
+ case "t":
5259
+ scanner.next();
5260
+ return success(" ");
5261
+ case "n":
5262
+ scanner.next();
5263
+ return success("\n");
5264
+ case "f":
5265
+ scanner.next();
5266
+ return success("\f");
5267
+ case "r":
5268
+ scanner.next();
5269
+ return success("\r");
5270
+ case "u":
5271
+ case "U": {
5272
+ const codePointLen = scanner.char() === "u" ? 4 : 6;
5273
+ const codePoint = parseInt("0x" + scanner.slice(1, 1 + codePointLen), 16);
5274
+ const str = String.fromCodePoint(codePoint);
5275
+ scanner.next(codePointLen + 1);
5276
+ return success(str);
5277
+ }
5278
+ case '"':
5279
+ scanner.next();
5280
+ return success('"');
5281
+ case "\\":
5282
+ scanner.next();
5283
+ return success("\\");
5284
+ default:
5285
+ throw new SyntaxError(`Invalid escape sequence: \\${scanner.char()}`);
5286
+ }
5287
+ }
5288
+ function basicString(scanner) {
5289
+ scanner.skipWhitespaces();
5290
+ if (scanner.char() !== '"') return failure();
5291
+ scanner.next();
5292
+ const acc = [];
5293
+ while (scanner.char() !== '"' && !scanner.eof()) {
5294
+ if (scanner.char() === "\n") {
5295
+ throw new SyntaxError("Single-line string cannot contain EOL");
5296
+ }
5297
+ const escapedChar = escapeSequence(scanner);
5298
+ if (escapedChar.ok) {
5299
+ acc.push(escapedChar.body);
5300
+ } else {
5301
+ acc.push(scanner.char());
5302
+ scanner.next();
5303
+ }
5304
+ }
5305
+ if (scanner.eof()) {
5306
+ throw new SyntaxError(`Single-line string is not closed:
5307
+ ${acc.join("")}`);
5308
+ }
5309
+ scanner.next();
5310
+ return success(acc.join(""));
5311
+ }
5312
+ function literalString(scanner) {
5313
+ scanner.skipWhitespaces();
5314
+ if (scanner.char() !== "'") return failure();
5315
+ scanner.next();
5316
+ const acc = [];
5317
+ while (scanner.char() !== "'" && !scanner.eof()) {
5318
+ if (scanner.char() === "\n") {
5319
+ throw new SyntaxError("Single-line string cannot contain EOL");
5320
+ }
5321
+ acc.push(scanner.char());
5322
+ scanner.next();
5323
+ }
5324
+ if (scanner.eof()) {
5325
+ throw new SyntaxError(`Single-line string is not closed:
5326
+ ${acc.join("")}`);
5327
+ }
5328
+ scanner.next();
5329
+ return success(acc.join(""));
5330
+ }
5331
+ function multilineBasicString(scanner) {
5332
+ scanner.skipWhitespaces();
5333
+ if (!scanner.startsWith('"""')) return failure();
5334
+ scanner.next(3);
5335
+ if (scanner.char() === "\n") {
5336
+ scanner.next();
5337
+ } else if (scanner.startsWith("\r\n")) {
5338
+ scanner.next(2);
5339
+ }
5340
+ const acc = [];
5341
+ while (!scanner.startsWith('"""') && !scanner.eof()) {
5342
+ if (scanner.startsWith("\\\n")) {
5343
+ scanner.next();
5344
+ scanner.nextUntilChar({
5345
+ skipComments: false
5346
+ });
5347
+ continue;
5348
+ } else if (scanner.startsWith("\\\r\n")) {
5349
+ scanner.next();
5350
+ scanner.nextUntilChar({
5351
+ skipComments: false
5352
+ });
5353
+ continue;
5354
+ }
5355
+ const escapedChar = escapeSequence(scanner);
5356
+ if (escapedChar.ok) {
5357
+ acc.push(escapedChar.body);
5358
+ } else {
5359
+ acc.push(scanner.char());
5360
+ scanner.next();
5361
+ }
5362
+ }
5363
+ if (scanner.eof()) {
5364
+ throw new SyntaxError(`Multi-line string is not closed:
5365
+ ${acc.join("")}`);
5366
+ }
5367
+ if (scanner.char(3) === '"') {
5368
+ acc.push('"');
5369
+ scanner.next();
5370
+ }
5371
+ scanner.next(3);
5372
+ return success(acc.join(""));
5373
+ }
5374
+ function multilineLiteralString(scanner) {
5375
+ scanner.skipWhitespaces();
5376
+ if (!scanner.startsWith("'''")) return failure();
5377
+ scanner.next(3);
5378
+ if (scanner.char() === "\n") {
5379
+ scanner.next();
5380
+ } else if (scanner.startsWith("\r\n")) {
5381
+ scanner.next(2);
5382
+ }
5383
+ const acc = [];
5384
+ while (!scanner.startsWith("'''") && !scanner.eof()) {
5385
+ acc.push(scanner.char());
5386
+ scanner.next();
5387
+ }
5388
+ if (scanner.eof()) {
5389
+ throw new SyntaxError(`Multi-line string is not closed:
5390
+ ${acc.join("")}`);
5391
+ }
5392
+ if (scanner.char(3) === "'") {
5393
+ acc.push("'");
5394
+ scanner.next();
5395
+ }
5396
+ scanner.next(3);
5397
+ return success(acc.join(""));
5398
+ }
5399
+ var BOOLEAN_REGEXP = /(?:true|false)\b/y;
5400
+ function boolean(scanner) {
5401
+ scanner.skipWhitespaces();
5402
+ const match = scanner.match(BOOLEAN_REGEXP);
5403
+ if (!match) return failure();
5404
+ const string = match[0];
5405
+ scanner.next(string.length);
5406
+ const value2 = string === "true";
5407
+ return success(value2);
5408
+ }
5409
+ var INFINITY_MAP = /* @__PURE__ */ new Map([
5410
+ [
5411
+ "inf",
5412
+ Infinity
5413
+ ],
5414
+ [
5415
+ "+inf",
5416
+ Infinity
5417
+ ],
5418
+ [
5419
+ "-inf",
5420
+ -Infinity
5421
+ ]
5422
+ ]);
5423
+ var INFINITY_REGEXP = /[+-]?inf\b/y;
5424
+ function infinity(scanner) {
5425
+ scanner.skipWhitespaces();
5426
+ const match = scanner.match(INFINITY_REGEXP);
5427
+ if (!match) return failure();
5428
+ const string = match[0];
5429
+ scanner.next(string.length);
5430
+ const value2 = INFINITY_MAP.get(string);
5431
+ return success(value2);
5432
+ }
5433
+ var NAN_REGEXP = /[+-]?nan\b/y;
5434
+ function nan(scanner) {
5435
+ scanner.skipWhitespaces();
5436
+ const match = scanner.match(NAN_REGEXP);
5437
+ if (!match) return failure();
5438
+ const string = match[0];
5439
+ scanner.next(string.length);
5440
+ const value2 = NaN;
5441
+ return success(value2);
5442
+ }
5443
+ var dottedKey = join1(or([
5444
+ bareKey,
5445
+ basicString,
5446
+ literalString
5447
+ ]), ".");
5448
+ var BINARY_REGEXP = /0b[01]+(?:_[01]+)*\b/y;
5449
+ function binary(scanner) {
5450
+ scanner.skipWhitespaces();
5451
+ const match = scanner.match(BINARY_REGEXP)?.[0];
5452
+ if (!match) return failure();
5453
+ scanner.next(match.length);
5454
+ const value2 = match.slice(2).replaceAll("_", "");
5455
+ const number = parseInt(value2, 2);
5456
+ return isNaN(number) ? failure() : success(number);
5457
+ }
5458
+ var OCTAL_REGEXP = /0o[0-7]+(?:_[0-7]+)*\b/y;
5459
+ function octal(scanner) {
5460
+ scanner.skipWhitespaces();
5461
+ const match = scanner.match(OCTAL_REGEXP)?.[0];
5462
+ if (!match) return failure();
5463
+ scanner.next(match.length);
5464
+ const value2 = match.slice(2).replaceAll("_", "");
5465
+ const number = parseInt(value2, 8);
5466
+ return isNaN(number) ? failure() : success(number);
5467
+ }
5468
+ var HEX_REGEXP = /0x[0-9a-f]+(?:_[0-9a-f]+)*\b/yi;
5469
+ function hex(scanner) {
5470
+ scanner.skipWhitespaces();
5471
+ const match = scanner.match(HEX_REGEXP)?.[0];
5472
+ if (!match) return failure();
5473
+ scanner.next(match.length);
5474
+ const value2 = match.slice(2).replaceAll("_", "");
5475
+ const number = parseInt(value2, 16);
5476
+ return isNaN(number) ? failure() : success(number);
5477
+ }
5478
+ var INTEGER_REGEXP = /[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;
5479
+ function integer(scanner) {
5480
+ scanner.skipWhitespaces();
5481
+ const match = scanner.match(INTEGER_REGEXP)?.[0];
5482
+ if (!match) return failure();
5483
+ scanner.next(match.length);
5484
+ const value2 = match.replaceAll("_", "");
5485
+ const int = parseInt(value2, 10);
5486
+ return success(int);
5487
+ }
5488
+ var FLOAT_REGEXP = /[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/yi;
5489
+ function float(scanner) {
5490
+ scanner.skipWhitespaces();
5491
+ const match = scanner.match(FLOAT_REGEXP)?.[0];
5492
+ if (!match) return failure();
5493
+ scanner.next(match.length);
5494
+ const value2 = match.replaceAll("_", "");
5495
+ const float2 = parseFloat(value2);
5496
+ if (isNaN(float2)) return failure();
5497
+ return success(float2);
5498
+ }
5499
+ var DATE_TIME_REGEXP = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;
5500
+ function dateTime(scanner) {
5501
+ scanner.skipWhitespaces();
5502
+ const match = scanner.match(DATE_TIME_REGEXP);
5503
+ if (!match) return failure();
5504
+ const string = match[0];
5505
+ scanner.next(string.length);
5506
+ const groups = match.groups;
5507
+ if (groups.month == "02") {
5508
+ const days = parseInt(groups.day);
5509
+ if (days > 29) {
5510
+ throw new SyntaxError(`Invalid date string "${match}"`);
5511
+ }
5512
+ const year = parseInt(groups.year);
5513
+ if (days > 28 && !isLeap(year)) {
5514
+ throw new SyntaxError(`Invalid date string "${match}"`);
5515
+ }
5516
+ }
5517
+ const date = new Date(string.trim());
5518
+ if (isNaN(date.getTime())) {
5519
+ throw new SyntaxError(`Invalid date string "${match}"`);
5520
+ }
5521
+ return success(date);
5522
+ }
5523
+ var LOCAL_TIME_REGEXP = /(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;
5524
+ function localTime(scanner) {
5525
+ scanner.skipWhitespaces();
5526
+ const match = scanner.match(LOCAL_TIME_REGEXP)?.[0];
5527
+ if (!match) return failure();
5528
+ scanner.next(match.length);
5529
+ return success(match);
5530
+ }
5531
+ function arrayValue(scanner) {
5532
+ scanner.skipWhitespaces();
5533
+ if (scanner.char() !== "[") return failure();
5534
+ scanner.next();
5535
+ const array = [];
5536
+ while (!scanner.eof()) {
5537
+ scanner.nextUntilChar();
5538
+ const result = value(scanner);
5539
+ if (!result.ok) break;
5540
+ array.push(result.body);
5541
+ scanner.skipWhitespaces();
5542
+ if (scanner.char() !== ",") break;
5543
+ scanner.next();
5544
+ }
5545
+ scanner.nextUntilChar();
5546
+ if (scanner.char() !== "]") throw new SyntaxError("Array is not closed");
5547
+ scanner.next();
5548
+ return success(array);
5549
+ }
5550
+ function inlineTable(scanner) {
5551
+ scanner.nextUntilChar();
5552
+ if (scanner.char(1) === "}") {
5553
+ scanner.next(2);
5554
+ return success({});
5555
+ }
5556
+ const pairs = surround("{", join4(pair, ","), "}")(scanner);
5557
+ if (!pairs.ok) return failure();
5558
+ let table2 = {};
5559
+ for (const pair2 of pairs.body) {
5560
+ table2 = deepMerge(table2, pair2);
5561
+ }
5562
+ return success(table2);
5563
+ }
5564
+ var value = or([
5565
+ multilineBasicString,
5566
+ multilineLiteralString,
5567
+ basicString,
5568
+ literalString,
5569
+ boolean,
5570
+ infinity,
5571
+ nan,
5572
+ dateTime,
5573
+ localTime,
5574
+ binary,
5575
+ octal,
5576
+ hex,
5577
+ float,
5578
+ integer,
5579
+ arrayValue,
5580
+ inlineTable
5581
+ ]);
5582
+ var pair = kv(dottedKey, "=", value);
5583
+ function block(scanner) {
5584
+ scanner.nextUntilChar();
5585
+ const result = merge2(repeat(pair))(scanner);
5586
+ if (result.ok) return success({
5587
+ type: "Block",
5588
+ value: result.body
5589
+ });
5590
+ return failure();
5591
+ }
5592
+ var tableHeader = surround("[", dottedKey, "]");
5593
+ function table(scanner) {
5594
+ scanner.nextUntilChar();
5595
+ const header = tableHeader(scanner);
5596
+ if (!header.ok) return failure();
5597
+ scanner.nextUntilChar();
5598
+ const b = block(scanner);
5599
+ return success({
5600
+ type: "Table",
5601
+ keys: header.body,
5602
+ value: b.ok ? b.body.value : {}
5603
+ });
5604
+ }
5605
+ var tableArrayHeader = surround("[[", dottedKey, "]]");
5606
+ function tableArray(scanner) {
5607
+ scanner.nextUntilChar();
5608
+ const header = tableArrayHeader(scanner);
5609
+ if (!header.ok) return failure();
5610
+ scanner.nextUntilChar();
5611
+ const b = block(scanner);
5612
+ return success({
5613
+ type: "TableArray",
5614
+ keys: header.body,
5615
+ value: b.ok ? b.body.value : {}
5616
+ });
5617
+ }
5618
+ function toml(scanner) {
5619
+ const blocks = repeat(or([
5620
+ block,
5621
+ tableArray,
5622
+ table
5623
+ ]))(scanner);
5624
+ if (!blocks.ok) return success({});
5625
+ const body = blocks.body.reduce(deepAssign, {});
5626
+ return success(body);
5627
+ }
5628
+ function createParseErrorMessage(scanner, message) {
5629
+ const string = scanner.source.slice(0, scanner.position);
5630
+ const lines = string.split("\n");
5631
+ const row = lines.length;
5632
+ const column = lines.at(-1)?.length ?? 0;
5633
+ return `Parse error on line ${row}, column ${column}: ${message}`;
5634
+ }
5635
+ function parserFactory(parser) {
5636
+ return (tomlString) => {
5637
+ const scanner = new Scanner(tomlString);
5638
+ try {
5639
+ const result = parser(scanner);
5640
+ if (result.ok && scanner.eof()) return result.body;
5641
+ const message = `Unexpected character: "${scanner.char()}"`;
5642
+ throw new SyntaxError(createParseErrorMessage(scanner, message));
5643
+ } catch (error) {
5644
+ if (error instanceof Error) {
5645
+ throw new SyntaxError(createParseErrorMessage(scanner, error.message));
5646
+ }
5647
+ const message = "Invalid error type caught";
5648
+ throw new SyntaxError(createParseErrorMessage(scanner, message));
5649
+ }
5650
+ };
5651
+ }
5652
+
5653
+ // ../node_modules/@std/toml/parse.js
5654
+ function parse4(tomlString) {
5655
+ return parserFactory(toml)(tomlString);
5656
+ }
5657
+
5658
+ // dist/api/rename.js
5659
+ var import_js_yaml2 = require("js-yaml");
5660
+ var import_find_up = require("find-up");
5661
+
5662
+ // dist/def/rename.js
5663
+ var import_clipanion4 = require("clipanion");
5664
+ var BaseRenameCommand = class extends import_clipanion4.Command {
5665
+ static paths = [["rename"]];
5666
+ static usage = import_clipanion4.Command.Usage({
5667
+ description: "Rename the NAPI-RS project"
5668
+ });
5669
+ cwd = import_clipanion4.Option.String("--cwd", process.cwd(), {
5670
+ description: "The working directory of where napi command will be executed in, all other paths options are relative to this path"
5671
+ });
5672
+ configPath = import_clipanion4.Option.String("--config-path,-c", {
5673
+ description: "Path to `napi` config json file"
5674
+ });
5675
+ packageJsonPath = import_clipanion4.Option.String("--package-json-path", "package.json", {
5676
+ description: "Path to `package.json`"
5677
+ });
5678
+ npmDir = import_clipanion4.Option.String("--npm-dir", "npm", {
5679
+ description: "Path to the folder where the npm packages put"
5680
+ });
5681
+ $$name = import_clipanion4.Option.String("--name,-n", {
5682
+ description: "The new name of the project"
5683
+ });
5684
+ binaryName = import_clipanion4.Option.String("--binary-name,-b", {
5685
+ description: "The new binary name *.node files"
5686
+ });
5687
+ packageName = import_clipanion4.Option.String("--package-name", {
5688
+ description: "The new package name of the project"
5689
+ });
5690
+ manifestPath = import_clipanion4.Option.String("--manifest-path", "Cargo.toml", {
5691
+ description: "Path to `Cargo.toml`"
5692
+ });
5693
+ repository = import_clipanion4.Option.String("--repository", {
5694
+ description: "The new repository of the project"
5695
+ });
5696
+ description = import_clipanion4.Option.String("--description", {
5697
+ description: "The new description of the project"
5698
+ });
5699
+ getOptions() {
5700
+ return {
5701
+ cwd: this.cwd,
5702
+ configPath: this.configPath,
5703
+ packageJsonPath: this.packageJsonPath,
5704
+ npmDir: this.npmDir,
5705
+ name: this.$$name,
5706
+ binaryName: this.binaryName,
5707
+ packageName: this.packageName,
5708
+ manifestPath: this.manifestPath,
5709
+ repository: this.repository,
5710
+ description: this.description
5711
+ };
5712
+ }
5713
+ };
5714
+ function applyDefaultRenameOptions(options) {
5715
+ return {
5716
+ cwd: process.cwd(),
5717
+ packageJsonPath: "package.json",
5718
+ npmDir: "npm",
5719
+ manifestPath: "Cargo.toml",
5720
+ ...options
5721
+ };
5722
+ }
5723
+
5724
+ // dist/api/rename.js
5725
+ async function renameProject(userOptions) {
5726
+ const options = applyDefaultRenameOptions(userOptions);
5727
+ const napiConfig = await readConfig(options);
5728
+ const oldName = napiConfig.binaryName;
5729
+ const packageJsonPath = (0, import_node_path5.resolve)(options.cwd, options.packageJsonPath);
5730
+ const cargoTomlPath = (0, import_node_path5.resolve)(options.cwd, options.manifestPath);
5731
+ const packageJsonContent = await readFileAsync(packageJsonPath, "utf8");
5732
+ const packageJsonData = JSON.parse(packageJsonContent);
5733
+ merge_default(packageJsonData, omitBy_default(pick_default(options, ["name", "description", "author", "license"]), isNil_default), {
5734
+ napi: omitBy_default({
5735
+ binaryName: options.binaryName,
5736
+ packageName: options.packageName
5737
+ }, isNil_default)
5738
+ });
5739
+ if (options.configPath) {
5740
+ const configPath = (0, import_node_path5.resolve)(options.cwd, options.configPath);
5741
+ const configContent = await readFileAsync(configPath, "utf8");
5742
+ const configData = JSON.parse(configContent);
5743
+ configData.binaryName = options.binaryName;
5744
+ configData.packageName = options.packageName;
5745
+ await writeFileAsync(configPath, JSON.stringify(configData, null, 2));
5746
+ }
5747
+ await writeFileAsync(packageJsonPath, JSON.stringify(packageJsonData, null, 2));
5748
+ const tomlContent = await readFileAsync(cargoTomlPath, "utf8");
5749
+ const cargoToml = parse4(tomlContent);
5750
+ if (cargoToml.package && options.binaryName) {
5751
+ const sanitizedName = options.binaryName.replace("@", "").replace("/", "_").replace(/-/g, "_").toLowerCase();
5752
+ cargoToml.package.name = sanitizedName;
5753
+ }
5754
+ const updatedTomlContent = stringify(cargoToml);
5755
+ await writeFileAsync(cargoTomlPath, updatedTomlContent);
5756
+ if (oldName !== options.binaryName) {
5757
+ const githubActionsPath = await (0, import_find_up.findUp)(".github", {
5758
+ cwd: options.cwd,
5759
+ type: "directory"
5760
+ });
5761
+ if (githubActionsPath) {
5762
+ const githubActionsCIYmlPath = (0, import_node_path5.join)(githubActionsPath, "workflows", "CI.yml");
5763
+ if ((0, import_node_fs4.existsSync)(githubActionsCIYmlPath)) {
5764
+ const githubActionsContent = await readFileAsync(githubActionsCIYmlPath, "utf8");
5765
+ const githubActionsData = (0, import_js_yaml2.load)(githubActionsContent);
5766
+ if (githubActionsData.env?.APP_NAME) {
5767
+ githubActionsData.env.APP_NAME = options.binaryName;
5768
+ await writeFileAsync(githubActionsCIYmlPath, (0, import_js_yaml2.dump)(githubActionsData, {
5769
+ lineWidth: -1,
5770
+ noRefs: true,
5771
+ sortKeys: false
5772
+ }));
5773
+ }
5774
+ }
5775
+ }
5776
+ const oldWasiBrowserBindingPath = (0, import_node_path5.join)(options.cwd, `${oldName}.wasi-browser.js`);
5777
+ if ((0, import_node_fs4.existsSync)(oldWasiBrowserBindingPath)) {
5778
+ await (0, import_promises.rename)(oldWasiBrowserBindingPath, (0, import_node_path5.join)(options.cwd, `${options.binaryName}.wasi-browser.js`));
5779
+ }
5780
+ const oldWasiBindingPath = (0, import_node_path5.join)(options.cwd, `${oldName}.wasi.cjs`);
5781
+ if ((0, import_node_fs4.existsSync)(oldWasiBindingPath)) {
5782
+ await (0, import_promises.rename)(oldWasiBindingPath, (0, import_node_path5.join)(options.cwd, `${options.binaryName}.wasi.cjs`));
5783
+ }
5784
+ const gitAttributesPath = (0, import_node_path5.join)(options.cwd, ".gitattributes");
5785
+ if ((0, import_node_fs4.existsSync)(gitAttributesPath)) {
5786
+ const gitAttributesContent = await readFileAsync(gitAttributesPath, "utf8");
5787
+ const gitAttributesData = gitAttributesContent.split("\n").map((line) => {
5788
+ return line.replace(`${oldName}.wasi-browser.js`, `${options.binaryName}.wasi-browser.js`).replace(`${oldName}.wasi.cjs`, `${options.binaryName}.wasi.cjs`);
5789
+ }).join("\n");
5790
+ await writeFileAsync(gitAttributesPath, gitAttributesData);
5791
+ }
5792
+ }
5793
+ }
5794
+
5795
+ // dist/api/new.js
5796
+ var debug5 = debugFactory("new");
5797
+ var TEMPLATE_REPOS = {
5798
+ yarn: "https://github.com/napi-rs/package-template",
5799
+ pnpm: "https://github.com/napi-rs/package-template-pnpm"
5800
+ };
5801
+ async function checkGitCommand() {
5802
+ try {
5803
+ await new Promise((resolve8) => {
5804
+ const cp = (0, import_node_child_process5.exec)("git --version");
5805
+ cp.on("error", () => {
5806
+ resolve8(false);
5807
+ });
5808
+ cp.on("exit", (code) => {
5809
+ if (code === 0) {
5810
+ resolve8(true);
5811
+ } else {
5812
+ resolve8(false);
5813
+ }
5814
+ });
5815
+ });
5816
+ return true;
5817
+ } catch {
5818
+ return false;
5819
+ }
5820
+ }
5821
+ async function ensureCacheDir(packageManager) {
5822
+ const cacheDir = import_node_path6.default.join((0, import_node_os2.homedir)(), ".napi-rs", "template", packageManager);
5823
+ await mkdirAsync(cacheDir, { recursive: true });
5824
+ return cacheDir;
5825
+ }
5826
+ async function downloadTemplate(packageManager, cacheDir) {
5827
+ const repoUrl = TEMPLATE_REPOS[packageManager];
5828
+ const templatePath = import_node_path6.default.join(cacheDir, "repo");
5829
+ if ((0, import_node_fs5.existsSync)(templatePath)) {
5830
+ debug5(`Template cache found at ${templatePath}, updating...`);
5831
+ try {
5832
+ await new Promise((resolve8, reject) => {
5833
+ const cp = (0, import_node_child_process5.exec)("git fetch origin", { cwd: templatePath });
5834
+ cp.on("error", reject);
5835
+ cp.on("exit", (code) => {
5836
+ if (code === 0) {
5837
+ resolve8();
5838
+ } else {
5839
+ reject(new Error(`Failed to fetch latest changes, git process exited with code ${code}`));
5840
+ }
5841
+ });
5842
+ });
5843
+ (0, import_node_child_process5.execSync)("git reset --hard origin/main", {
5844
+ cwd: templatePath,
5845
+ stdio: "ignore"
5846
+ });
5847
+ debug5("Template updated successfully");
5848
+ } catch (error) {
5849
+ debug5(`Failed to update template: ${error}`);
5850
+ throw new Error(`Failed to update template from ${repoUrl}: ${error}`);
5851
+ }
5852
+ } else {
5853
+ debug5(`Cloning template from ${repoUrl}...`);
5854
+ try {
5855
+ (0, import_node_child_process5.execSync)(`git clone ${repoUrl} repo`, { cwd: cacheDir, stdio: "inherit" });
5856
+ debug5("Template cloned successfully");
5857
+ } catch (error) {
5858
+ throw new Error(`Failed to clone template from ${repoUrl}: ${error}`);
5859
+ }
5860
+ }
5861
+ }
5862
+ async function copyDirectory(src, dest, includeWasiBindings) {
5863
+ await mkdirAsync(dest, { recursive: true });
5864
+ const entries = await import_node_fs6.promises.readdir(src, { withFileTypes: true });
5865
+ for (const entry of entries) {
5866
+ const srcPath = import_node_path6.default.join(src, entry.name);
5867
+ const destPath = import_node_path6.default.join(dest, entry.name);
5868
+ if (entry.name === ".git") {
5869
+ continue;
5870
+ }
5871
+ if (entry.isDirectory()) {
5872
+ await copyDirectory(srcPath, destPath, includeWasiBindings);
5873
+ } else {
5874
+ if (!includeWasiBindings && (entry.name.endsWith(".wasi-browser.js") || entry.name.endsWith(".wasi.cjs") || entry.name.endsWith("wasi-worker.browser.mjs ") || entry.name.endsWith("wasi-worker.mjs") || entry.name.endsWith("browser.js"))) {
5875
+ continue;
5876
+ }
5877
+ await import_node_fs6.promises.copyFile(srcPath, destPath);
5878
+ }
5879
+ }
5880
+ }
5881
+ async function filterTargetsInPackageJson(filePath, enabledTargets) {
5882
+ const content = await import_node_fs6.promises.readFile(filePath, "utf-8");
5883
+ const packageJson = JSON.parse(content);
5884
+ if (packageJson.napi?.targets) {
5885
+ packageJson.napi.targets = packageJson.napi.targets.filter((target) => enabledTargets.includes(target));
5886
+ }
5887
+ await import_node_fs6.promises.writeFile(filePath, JSON.stringify(packageJson, null, 2) + "\n");
5888
+ }
5889
+ async function filterTargetsInGithubActions(filePath, enabledTargets) {
5890
+ const content = await import_node_fs6.promises.readFile(filePath, "utf-8");
5891
+ const yaml = (0, import_js_yaml3.load)(content);
5892
+ const macOSAndWindowsTargets = /* @__PURE__ */ new Set([
5893
+ "x86_64-pc-windows-msvc",
5894
+ "aarch64-pc-windows-msvc",
5895
+ "x86_64-apple-darwin"
5896
+ ]);
5897
+ const linuxTargets = /* @__PURE__ */ new Set([
5898
+ "x86_64-unknown-linux-gnu",
5899
+ "x86_64-unknown-linux-musl",
5900
+ "aarch64-unknown-linux-gnu",
5901
+ "aarch64-unknown-linux-musl",
5902
+ "armv7-unknown-linux-gnueabihf",
5903
+ "armv7-unknown-linux-musleabihf",
5904
+ "riscv64gc-unknown-linux-gnu",
5905
+ "powerpc64le-unknown-linux-gnu",
5906
+ "s390x-unknown-linux-gnu",
5907
+ "aarch64-linux-android",
5908
+ "armv7-linux-androideabi"
5909
+ ]);
5910
+ const hasLinuxTargets = enabledTargets.some((target) => linuxTargets.has(target));
5911
+ if (yaml?.jobs?.build?.strategy?.matrix?.settings) {
5912
+ yaml.jobs.build.strategy.matrix.settings = yaml.jobs.build.strategy.matrix.settings.filter((setting) => {
5913
+ if (setting.target) {
5914
+ return enabledTargets.includes(setting.target);
5915
+ }
5916
+ return true;
5917
+ });
5918
+ }
5919
+ const jobsToRemove = [];
5920
+ if (enabledTargets.every((target) => !macOSAndWindowsTargets.has(target))) {
5921
+ jobsToRemove.push("test-macOS-windows-binding");
5922
+ } else {
5923
+ if (yaml?.jobs?.["test-macOS-windows-binding"]?.strategy?.matrix?.settings) {
5924
+ yaml.jobs["test-macOS-windows-binding"].strategy.matrix.settings = yaml.jobs["test-macOS-windows-binding"].strategy.matrix.settings.filter((setting) => {
5925
+ if (setting.target) {
5926
+ return enabledTargets.includes(setting.target);
5927
+ }
5928
+ return true;
5929
+ });
5930
+ }
5931
+ }
5932
+ if (!hasLinuxTargets) {
5933
+ if (yaml?.jobs?.["test-linux-binding"]) {
5934
+ jobsToRemove.push("test-linux-binding");
5935
+ }
5936
+ } else {
5937
+ if (yaml?.jobs?.["test-linux-binding"]?.strategy?.matrix?.target) {
5938
+ yaml.jobs["test-linux-binding"].strategy.matrix.target = yaml.jobs["test-linux-binding"].strategy.matrix.target.filter((target) => {
5939
+ if (target) {
5940
+ return enabledTargets.includes(target);
5941
+ }
5942
+ return true;
5943
+ });
5944
+ }
5945
+ }
5946
+ if (!enabledTargets.includes("wasm32-wasip1-threads")) {
5947
+ jobsToRemove.push("test-wasi");
5948
+ }
5949
+ if (!enabledTargets.includes("x86_64-unknown-freebsd")) {
5950
+ jobsToRemove.push("build-freebsd");
5951
+ }
5952
+ for (const [jobName, jobConfig] of Object.entries(yaml.jobs || {})) {
5953
+ if (jobName.startsWith("test-") && jobName !== "test-macOS-windows-binding" && jobName !== "test-linux-x64-gnu-binding") {
5954
+ const job = jobConfig;
5955
+ if (job.strategy?.matrix?.settings?.[0]?.target) {
5956
+ const target = job.strategy.matrix.settings[0].target;
5957
+ if (!enabledTargets.includes(target)) {
5958
+ jobsToRemove.push(jobName);
5959
+ }
5960
+ }
5961
+ }
5962
+ }
5963
+ for (const jobName of jobsToRemove) {
5964
+ delete yaml.jobs[jobName];
5965
+ }
5966
+ if (Array.isArray(yaml.jobs?.publish?.needs)) {
5967
+ yaml.jobs.publish.needs = yaml.jobs.publish.needs.filter((need) => !jobsToRemove.includes(need));
5968
+ }
5969
+ const updatedYaml = (0, import_js_yaml3.dump)(yaml, {
5970
+ lineWidth: -1,
5971
+ noRefs: true,
5972
+ sortKeys: false
5973
+ });
5974
+ await import_node_fs6.promises.writeFile(filePath, updatedYaml);
5975
+ }
5976
+ function processOptions(options) {
5977
+ debug5("Processing options...");
5978
+ if (!options.path) {
5979
+ throw new Error("Please provide the path as the argument");
5980
+ }
5981
+ options.path = import_node_path6.default.resolve(process.cwd(), options.path);
5982
+ debug5(`Resolved target path to: ${options.path}`);
5983
+ if (!options.name) {
5984
+ options.name = import_node_path6.default.parse(options.path).base;
5985
+ debug5(`No project name provided, fix it to dir name: ${options.name}`);
5986
+ }
5987
+ if (!options.targets?.length) {
5988
+ if (options.enableAllTargets) {
5989
+ options.targets = AVAILABLE_TARGETS.concat();
5990
+ debug5("Enable all targets");
5991
+ } else if (options.enableDefaultTargets) {
5992
+ options.targets = DEFAULT_TARGETS.concat();
5993
+ debug5("Enable default targets");
5994
+ } else {
5995
+ throw new Error("At least one target must be enabled");
5996
+ }
5997
+ }
5998
+ if (options.targets.some((target) => target === "wasm32-wasi-preview1-threads")) {
5999
+ const out = (0, import_node_child_process5.execSync)(`rustup target list`, {
6000
+ encoding: "utf8"
6001
+ });
6002
+ if (out.includes("wasm32-wasip1-threads")) {
6003
+ options.targets = options.targets.map((target) => target === "wasm32-wasi-preview1-threads" ? "wasm32-wasip1-threads" : target);
6004
+ }
6005
+ }
6006
+ return applyDefaultNewOptions(options);
6007
+ }
6008
+ async function newProject(userOptions) {
6009
+ debug5("Will create napi-rs project with given options:");
6010
+ debug5(userOptions);
6011
+ const options = processOptions(userOptions);
6012
+ debug5("Targets to be enabled:");
6013
+ debug5(options.targets);
6014
+ if (!await checkGitCommand()) {
6015
+ throw new Error("Git is not installed or not available in PATH. Please install Git to continue.");
6016
+ }
6017
+ const packageManager = options.packageManager;
6018
+ await ensurePath(options.path, options.dryRun);
6019
+ if (!options.dryRun) {
6020
+ try {
6021
+ const cacheDir = await ensureCacheDir(packageManager);
6022
+ await downloadTemplate(packageManager, cacheDir);
6023
+ const templatePath = import_node_path6.default.join(cacheDir, "repo");
6024
+ await copyDirectory(templatePath, options.path, options.targets.includes("wasm32-wasip1-threads"));
6025
+ await renameProject({
6026
+ cwd: options.path,
6027
+ name: options.name,
6028
+ binaryName: getBinaryName(options.name)
6029
+ });
6030
+ const packageJsonPath = import_node_path6.default.join(options.path, "package.json");
6031
+ if ((0, import_node_fs5.existsSync)(packageJsonPath)) {
6032
+ await filterTargetsInPackageJson(packageJsonPath, options.targets);
6033
+ }
6034
+ const ciPath = import_node_path6.default.join(options.path, ".github", "workflows", "CI.yml");
6035
+ if ((0, import_node_fs5.existsSync)(ciPath) && options.enableGithubActions) {
6036
+ await filterTargetsInGithubActions(ciPath, options.targets);
6037
+ } else if (!options.enableGithubActions && (0, import_node_fs5.existsSync)(import_node_path6.default.join(options.path, ".github"))) {
6038
+ await import_node_fs6.promises.rm(import_node_path6.default.join(options.path, ".github"), {
6039
+ recursive: true,
6040
+ force: true
6041
+ });
6042
+ }
6043
+ const pkgJsonContent = await import_node_fs6.promises.readFile(packageJsonPath, "utf-8");
6044
+ const pkgJson = JSON.parse(pkgJsonContent);
6045
+ if (!pkgJson.engines) {
6046
+ pkgJson.engines = {};
6047
+ }
6048
+ pkgJson.engines.node = napiEngineRequirement(options.minNodeApiVersion);
6049
+ if (options.license && pkgJson.license !== options.license) {
6050
+ pkgJson.license = options.license;
6051
+ }
6052
+ if (options.testFramework !== "ava") {
6053
+ debug5(`Test framework ${options.testFramework} requested but not yet implemented`);
6054
+ }
6055
+ await import_node_fs6.promises.writeFile(packageJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
6056
+ } catch (error) {
6057
+ throw new Error(`Failed to create project: ${error}`);
6058
+ }
6059
+ }
6060
+ debug5(`Project created at: ${options.path}`);
6061
+ }
6062
+ async function ensurePath(path2, dryRun = false) {
6063
+ const stat2 = await statAsync(path2, {}).catch(() => void 0);
6064
+ if (stat2) {
6065
+ if (stat2.isFile()) {
6066
+ throw new Error(`Path ${path2} for creating new napi-rs project already exists and it's not a directory.`);
6067
+ } else if (stat2.isDirectory()) {
6068
+ const files = await readdirAsync(path2);
6069
+ if (files.length) {
6070
+ throw new Error(`Path ${path2} for creating new napi-rs project already exists and it's not empty.`);
6071
+ }
6072
+ }
6073
+ }
6074
+ if (!dryRun) {
6075
+ try {
6076
+ debug5(`Try to create target directory: ${path2}`);
6077
+ if (!dryRun) {
6078
+ await mkdirAsync(path2, { recursive: true });
6079
+ }
6080
+ } catch (e) {
6081
+ throw new Error(`Failed to create target directory: ${path2}`, {
6082
+ cause: e
6083
+ });
6084
+ }
6085
+ }
6086
+ }
6087
+ function getBinaryName(name) {
6088
+ return name.split("/").pop();
6089
+ }
6090
+
6091
+ // dist/api/pre-publish.js
6092
+ var import_node_child_process6 = require("node:child_process");
6093
+ var import_node_fs7 = require("node:fs");
6094
+ var import_node_path8 = require("node:path");
6095
+
6096
+ // ../node_modules/@octokit/rest/node_modules/universal-user-agent/index.js
6097
+ function getUserAgent() {
6098
+ if (typeof navigator === "object" && "userAgent" in navigator) {
6099
+ return navigator.userAgent;
6100
+ }
6101
+ if (typeof process === "object" && process.version !== void 0) {
6102
+ return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;
6103
+ }
6104
+ return "<environment undetectable>";
5807
6105
  }
5808
6106
 
5809
6107
  // ../node_modules/@octokit/rest/node_modules/before-after-hook/lib/register.js
@@ -5935,13 +6233,13 @@ function lowercaseKeys(object) {
5935
6233
  return newObj;
5936
6234
  }, {});
5937
6235
  }
5938
- function isPlainObject2(value) {
5939
- if (typeof value !== "object" || value === null) return false;
5940
- if (Object.prototype.toString.call(value) !== "[object Object]") return false;
5941
- const proto = Object.getPrototypeOf(value);
6236
+ function isPlainObject2(value2) {
6237
+ if (typeof value2 !== "object" || value2 === null) return false;
6238
+ if (Object.prototype.toString.call(value2) !== "[object Object]") return false;
6239
+ const proto = Object.getPrototypeOf(value2);
5942
6240
  if (proto === null) return true;
5943
6241
  const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
5944
- return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
6242
+ return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value2);
5945
6243
  }
5946
6244
  function mergeDeep(defaults, options) {
5947
6245
  const result = Object.assign({}, defaults);
@@ -5963,7 +6261,7 @@ function removeUndefinedProperties(obj) {
5963
6261
  }
5964
6262
  return obj;
5965
6263
  }
5966
- function merge2(defaults, route, options) {
6264
+ function merge3(defaults, route, options) {
5967
6265
  if (typeof route === "string") {
5968
6266
  let [method, url] = route.split(" ");
5969
6267
  options = Object.assign(url ? { method, url } : { url: method }, options);
@@ -6030,57 +6328,57 @@ function encodeUnreserved(str) {
6030
6328
  return "%" + c.charCodeAt(0).toString(16).toUpperCase();
6031
6329
  });
6032
6330
  }
6033
- function encodeValue(operator, value, key) {
6034
- value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
6331
+ function encodeValue(operator, value2, key) {
6332
+ value2 = operator === "+" || operator === "#" ? encodeReserved(value2) : encodeUnreserved(value2);
6035
6333
  if (key) {
6036
- return encodeUnreserved(key) + "=" + value;
6334
+ return encodeUnreserved(key) + "=" + value2;
6037
6335
  } else {
6038
- return value;
6336
+ return value2;
6039
6337
  }
6040
6338
  }
6041
- function isDefined(value) {
6042
- return value !== void 0 && value !== null;
6339
+ function isDefined(value2) {
6340
+ return value2 !== void 0 && value2 !== null;
6043
6341
  }
6044
6342
  function isKeyOperator(operator) {
6045
6343
  return operator === ";" || operator === "&" || operator === "?";
6046
6344
  }
6047
6345
  function getValues(context, operator, key, modifier) {
6048
- var value = context[key], result = [];
6049
- if (isDefined(value) && value !== "") {
6050
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
6051
- value = value.toString();
6346
+ var value2 = context[key], result = [];
6347
+ if (isDefined(value2) && value2 !== "") {
6348
+ if (typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean") {
6349
+ value2 = value2.toString();
6052
6350
  if (modifier && modifier !== "*") {
6053
- value = value.substring(0, parseInt(modifier, 10));
6351
+ value2 = value2.substring(0, parseInt(modifier, 10));
6054
6352
  }
6055
6353
  result.push(
6056
- encodeValue(operator, value, isKeyOperator(operator) ? key : "")
6354
+ encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
6057
6355
  );
6058
6356
  } else {
6059
6357
  if (modifier === "*") {
6060
- if (Array.isArray(value)) {
6061
- value.filter(isDefined).forEach(function(value2) {
6358
+ if (Array.isArray(value2)) {
6359
+ value2.filter(isDefined).forEach(function(value22) {
6062
6360
  result.push(
6063
- encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
6361
+ encodeValue(operator, value22, isKeyOperator(operator) ? key : "")
6064
6362
  );
6065
6363
  });
6066
6364
  } else {
6067
- Object.keys(value).forEach(function(k) {
6068
- if (isDefined(value[k])) {
6069
- result.push(encodeValue(operator, value[k], k));
6365
+ Object.keys(value2).forEach(function(k) {
6366
+ if (isDefined(value2[k])) {
6367
+ result.push(encodeValue(operator, value2[k], k));
6070
6368
  }
6071
6369
  });
6072
6370
  }
6073
6371
  } else {
6074
6372
  const tmp = [];
6075
- if (Array.isArray(value)) {
6076
- value.filter(isDefined).forEach(function(value2) {
6077
- tmp.push(encodeValue(operator, value2));
6373
+ if (Array.isArray(value2)) {
6374
+ value2.filter(isDefined).forEach(function(value22) {
6375
+ tmp.push(encodeValue(operator, value22));
6078
6376
  });
6079
6377
  } else {
6080
- Object.keys(value).forEach(function(k) {
6081
- if (isDefined(value[k])) {
6378
+ Object.keys(value2).forEach(function(k) {
6379
+ if (isDefined(value2[k])) {
6082
6380
  tmp.push(encodeUnreserved(k));
6083
- tmp.push(encodeValue(operator, value[k].toString()));
6381
+ tmp.push(encodeValue(operator, value2[k].toString()));
6084
6382
  }
6085
6383
  });
6086
6384
  }
@@ -6093,12 +6391,12 @@ function getValues(context, operator, key, modifier) {
6093
6391
  }
6094
6392
  } else {
6095
6393
  if (operator === ";") {
6096
- if (isDefined(value)) {
6394
+ if (isDefined(value2)) {
6097
6395
  result.push(encodeUnreserved(key));
6098
6396
  }
6099
- } else if (value === "" && (operator === "&" || operator === "?")) {
6397
+ } else if (value2 === "" && (operator === "&" || operator === "?")) {
6100
6398
  result.push(encodeUnreserved(key) + "=");
6101
- } else if (value === "") {
6399
+ } else if (value2 === "") {
6102
6400
  result.push("");
6103
6401
  }
6104
6402
  }
@@ -6147,7 +6445,7 @@ function expand(template, context) {
6147
6445
  return template.replace(/\/$/, "");
6148
6446
  }
6149
6447
  }
6150
- function parse4(options) {
6448
+ function parse5(options) {
6151
6449
  let method = options.method.toUpperCase();
6152
6450
  let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
6153
6451
  let headers = Object.assign({}, options.headers);
@@ -6211,16 +6509,16 @@ function parse4(options) {
6211
6509
  );
6212
6510
  }
6213
6511
  function endpointWithDefaults(defaults, route, options) {
6214
- return parse4(merge2(defaults, route, options));
6512
+ return parse5(merge3(defaults, route, options));
6215
6513
  }
6216
6514
  function withDefaults(oldDefaults, newDefaults) {
6217
- const DEFAULTS2 = merge2(oldDefaults, newDefaults);
6515
+ const DEFAULTS2 = merge3(oldDefaults, newDefaults);
6218
6516
  const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
6219
6517
  return Object.assign(endpoint2, {
6220
6518
  DEFAULTS: DEFAULTS2,
6221
6519
  defaults: withDefaults.bind(null, DEFAULTS2),
6222
- merge: merge2.bind(null, DEFAULTS2),
6223
- parse: parse4
6520
+ merge: merge3.bind(null, DEFAULTS2),
6521
+ parse: parse5
6224
6522
  });
6225
6523
  }
6226
6524
  var endpoint = withDefaults(null, DEFAULTS);
@@ -6274,13 +6572,13 @@ var defaults_default = {
6274
6572
  "user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}`
6275
6573
  }
6276
6574
  };
6277
- function isPlainObject3(value) {
6278
- if (typeof value !== "object" || value === null) return false;
6279
- if (Object.prototype.toString.call(value) !== "[object Object]") return false;
6280
- const proto = Object.getPrototypeOf(value);
6575
+ function isPlainObject3(value2) {
6576
+ if (typeof value2 !== "object" || value2 === null) return false;
6577
+ if (Object.prototype.toString.call(value2) !== "[object Object]") return false;
6578
+ const proto = Object.getPrototypeOf(value2);
6281
6579
  if (proto === null) return true;
6282
6580
  const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
6283
- return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
6581
+ return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value2);
6284
6582
  }
6285
6583
  async function fetchWrapper(requestOptions) {
6286
6584
  const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
@@ -6293,9 +6591,9 @@ async function fetchWrapper(requestOptions) {
6293
6591
  const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false;
6294
6592
  const body = isPlainObject3(requestOptions.body) || Array.isArray(requestOptions.body) ? JSON.stringify(requestOptions.body) : requestOptions.body;
6295
6593
  const requestHeaders = Object.fromEntries(
6296
- Object.entries(requestOptions.headers).map(([name, value]) => [
6594
+ Object.entries(requestOptions.headers).map(([name, value2]) => [
6297
6595
  name,
6298
- String(value)
6596
+ String(value2)
6299
6597
  ])
6300
6598
  );
6301
6599
  let fetchResponse;
@@ -6335,8 +6633,8 @@ async function fetchWrapper(requestOptions) {
6335
6633
  const status = fetchResponse.status;
6336
6634
  const url = fetchResponse.url;
6337
6635
  const responseHeaders = {};
6338
- for (const [key, value] of fetchResponse.headers) {
6339
- responseHeaders[key] = value;
6636
+ for (const [key, value2] of fetchResponse.headers) {
6637
+ responseHeaders[key] = value2;
6340
6638
  }
6341
6639
  const octokitResponse = {
6342
6640
  url,
@@ -9009,8 +9307,8 @@ var handler = {
9009
9307
  ownKeys({ scope }) {
9010
9308
  return [...endpointMethodsMap.get(scope).keys()];
9011
9309
  },
9012
- set(target, methodName, value) {
9013
- return target.cache[methodName] = value;
9310
+ set(target, methodName, value2) {
9311
+ return target.cache[methodName] = value2;
9014
9312
  },
9015
9313
  get({ octokit, scope, cache }, methodName) {
9016
9314
  if (cache[methodName]) {
@@ -9112,37 +9410,37 @@ var Octokit2 = Octokit.plugin(requestLog, legacyRestEndpointMethods, paginateRes
9112
9410
  );
9113
9411
 
9114
9412
  // dist/def/pre-publish.js
9115
- var import_clipanion4 = require("clipanion");
9116
- var BasePrePublishCommand = class extends import_clipanion4.Command {
9413
+ var import_clipanion5 = require("clipanion");
9414
+ var BasePrePublishCommand = class extends import_clipanion5.Command {
9117
9415
  static paths = [["pre-publish"], ["prepublish"]];
9118
- static usage = import_clipanion4.Command.Usage({
9416
+ static usage = import_clipanion5.Command.Usage({
9119
9417
  description: "Update package.json and copy addons into per platform packages"
9120
9418
  });
9121
- cwd = import_clipanion4.Option.String("--cwd", process.cwd(), {
9419
+ cwd = import_clipanion5.Option.String("--cwd", process.cwd(), {
9122
9420
  description: "The working directory of where napi command will be executed in, all other paths options are relative to this path"
9123
9421
  });
9124
- configPath = import_clipanion4.Option.String("--config-path,-c", {
9422
+ configPath = import_clipanion5.Option.String("--config-path,-c", {
9125
9423
  description: "Path to `napi` config json file"
9126
9424
  });
9127
- packageJsonPath = import_clipanion4.Option.String("--package-json-path", "package.json", {
9425
+ packageJsonPath = import_clipanion5.Option.String("--package-json-path", "package.json", {
9128
9426
  description: "Path to `package.json`"
9129
9427
  });
9130
- npmDir = import_clipanion4.Option.String("--npm-dir,-p", "npm", {
9428
+ npmDir = import_clipanion5.Option.String("--npm-dir,-p", "npm", {
9131
9429
  description: "Path to the folder where the npm packages put"
9132
9430
  });
9133
- tagStyle = import_clipanion4.Option.String("--tag-style,--tagstyle,-t", "lerna", {
9431
+ tagStyle = import_clipanion5.Option.String("--tag-style,--tagstyle,-t", "lerna", {
9134
9432
  description: "git tag style, `npm` or `lerna`"
9135
9433
  });
9136
- ghRelease = import_clipanion4.Option.Boolean("--gh-release", true, {
9434
+ ghRelease = import_clipanion5.Option.Boolean("--gh-release", true, {
9137
9435
  description: "Whether create GitHub release"
9138
9436
  });
9139
- ghReleaseName = import_clipanion4.Option.String("--gh-release-name", {
9437
+ ghReleaseName = import_clipanion5.Option.String("--gh-release-name", {
9140
9438
  description: "GitHub release name"
9141
9439
  });
9142
- ghReleaseId = import_clipanion4.Option.String("--gh-release-id", {
9440
+ ghReleaseId = import_clipanion5.Option.String("--gh-release-id", {
9143
9441
  description: "Existing GitHub release id"
9144
9442
  });
9145
- dryRun = import_clipanion4.Option.Boolean("--dry-run", false, {
9443
+ dryRun = import_clipanion5.Option.Boolean("--dry-run", false, {
9146
9444
  description: "Dry run without touching file system"
9147
9445
  });
9148
9446
  getOptions() {
@@ -9172,25 +9470,25 @@ function applyDefaultPrePublishOptions(options) {
9172
9470
  }
9173
9471
 
9174
9472
  // dist/api/version.js
9175
- var import_node_path5 = require("node:path");
9473
+ var import_node_path7 = require("node:path");
9176
9474
 
9177
9475
  // dist/def/version.js
9178
- var import_clipanion5 = require("clipanion");
9179
- var BaseVersionCommand = class extends import_clipanion5.Command {
9476
+ var import_clipanion6 = require("clipanion");
9477
+ var BaseVersionCommand = class extends import_clipanion6.Command {
9180
9478
  static paths = [["version"]];
9181
- static usage = import_clipanion5.Command.Usage({
9479
+ static usage = import_clipanion6.Command.Usage({
9182
9480
  description: "Update version in created npm packages"
9183
9481
  });
9184
- cwd = import_clipanion5.Option.String("--cwd", process.cwd(), {
9482
+ cwd = import_clipanion6.Option.String("--cwd", process.cwd(), {
9185
9483
  description: "The working directory of where napi command will be executed in, all other paths options are relative to this path"
9186
9484
  });
9187
- configPath = import_clipanion5.Option.String("--config-path,-c", {
9485
+ configPath = import_clipanion6.Option.String("--config-path,-c", {
9188
9486
  description: "Path to `napi` config json file"
9189
9487
  });
9190
- packageJsonPath = import_clipanion5.Option.String("--package-json-path", "package.json", {
9488
+ packageJsonPath = import_clipanion6.Option.String("--package-json-path", "package.json", {
9191
9489
  description: "Path to `package.json`"
9192
9490
  });
9193
- npmDir = import_clipanion5.Option.String("--npm-dir", "npm", {
9491
+ npmDir = import_clipanion6.Option.String("--npm-dir", "npm", {
9194
9492
  description: "Path to the folder where the npm packages put"
9195
9493
  });
9196
9494
  getOptions() {
@@ -9215,12 +9513,12 @@ function applyDefaultVersionOptions(options) {
9215
9513
  var debug6 = debugFactory("version");
9216
9514
  async function version(userOptions) {
9217
9515
  const options = applyDefaultVersionOptions(userOptions);
9218
- const packageJsonPath = (0, import_node_path5.resolve)(options.cwd, options.packageJsonPath);
9219
- const config = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path5.resolve)(options.cwd, options.configPath) : void 0);
9516
+ const packageJsonPath = (0, import_node_path7.resolve)(options.cwd, options.packageJsonPath);
9517
+ const config = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path7.resolve)(options.cwd, options.configPath) : void 0);
9220
9518
  for (const target of config.targets) {
9221
- const pkgDir = (0, import_node_path5.resolve)(options.cwd, options.npmDir, target.platformArchABI);
9519
+ const pkgDir = (0, import_node_path7.resolve)(options.cwd, options.npmDir, target.platformArchABI);
9222
9520
  debug6(`Update version to %i in [%i]`, config.packageJson.version, pkgDir);
9223
- await updatePackageJson((0, import_node_path5.join)(pkgDir, "package.json"), {
9521
+ await updatePackageJson((0, import_node_path7.join)(pkgDir, "package.json"), {
9224
9522
  version: config.packageJson.version
9225
9523
  });
9226
9524
  }
@@ -9232,8 +9530,8 @@ async function prePublish(userOptions) {
9232
9530
  debug7("Receive pre-publish options:");
9233
9531
  debug7(" %O", userOptions);
9234
9532
  const options = applyDefaultPrePublishOptions(userOptions);
9235
- const packageJsonPath = (0, import_node_path6.resolve)(options.cwd, options.packageJsonPath);
9236
- const { packageJson, targets, packageName, binaryName, npmClient } = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path6.resolve)(options.cwd, options.configPath) : void 0);
9533
+ const packageJsonPath = (0, import_node_path8.resolve)(options.cwd, options.packageJsonPath);
9534
+ const { packageJson, targets, packageName, binaryName, npmClient } = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path8.resolve)(options.cwd, options.configPath) : void 0);
9237
9535
  async function createGhRelease(packageName2, version2) {
9238
9536
  if (!options.ghRelease) {
9239
9537
  return {
@@ -9310,12 +9608,12 @@ async function prePublish(userOptions) {
9310
9608
  }
9311
9609
  const { owner, repo, pkgInfo, octokit } = options.ghReleaseId ? getRepoInfo(packageName, packageJson.version) : await createGhRelease(packageName, packageJson.version);
9312
9610
  for (const target of targets) {
9313
- const pkgDir = (0, import_node_path6.resolve)(options.cwd, options.npmDir, `${target.platformArchABI}`);
9611
+ const pkgDir = (0, import_node_path8.resolve)(options.cwd, options.npmDir, `${target.platformArchABI}`);
9314
9612
  const ext = target.platform === "wasi" || target.platform === "wasm" ? "wasm" : "node";
9315
9613
  const filename = `${binaryName}.${target.platformArchABI}.${ext}`;
9316
- const dstPath = (0, import_node_path6.join)(pkgDir, filename);
9614
+ const dstPath = (0, import_node_path8.join)(pkgDir, filename);
9317
9615
  if (!options.dryRun) {
9318
- if (!(0, import_node_fs4.existsSync)(dstPath)) {
9616
+ if (!(0, import_node_fs7.existsSync)(dstPath)) {
9319
9617
  debug7.warn(`%s doesn't exist`, dstPath);
9320
9618
  continue;
9321
9619
  }
@@ -9331,7 +9629,7 @@ async function prePublish(userOptions) {
9331
9629
  owner,
9332
9630
  tag: pkgInfo.tag
9333
9631
  })).data.id;
9334
- const dstFileStats = (0, import_node_fs4.statSync)(dstPath);
9632
+ const dstFileStats = (0, import_node_fs7.statSync)(dstPath);
9335
9633
  const assetInfo = await octokit.repos.uploadReleaseAsset({
9336
9634
  owner,
9337
9635
  repo,
@@ -9366,107 +9664,9 @@ function parseTag(tag) {
9366
9664
  };
9367
9665
  }
9368
9666
 
9369
- // dist/api/rename.js
9370
- var import_node_path7 = require("node:path");
9371
-
9372
- // dist/def/rename.js
9373
- var import_clipanion6 = require("clipanion");
9374
- var BaseRenameCommand = class extends import_clipanion6.Command {
9375
- static paths = [["rename"]];
9376
- static usage = import_clipanion6.Command.Usage({
9377
- description: "Rename the NAPI-RS project"
9378
- });
9379
- cwd = import_clipanion6.Option.String("--cwd", process.cwd(), {
9380
- description: "The working directory of where napi command will be executed in, all other paths options are relative to this path"
9381
- });
9382
- configPath = import_clipanion6.Option.String("--config-path,-c", {
9383
- description: "Path to `napi` config json file"
9384
- });
9385
- packageJsonPath = import_clipanion6.Option.String("--package-json-path", "package.json", {
9386
- description: "Path to `package.json`"
9387
- });
9388
- npmDir = import_clipanion6.Option.String("--npm-dir", "npm", {
9389
- description: "Path to the folder where the npm packages put"
9390
- });
9391
- $$name = import_clipanion6.Option.String("--name,-n", {
9392
- description: "The new name of the project"
9393
- });
9394
- binaryName = import_clipanion6.Option.String("--binary-name,-b", {
9395
- description: "The new binary name *.node files"
9396
- });
9397
- packageName = import_clipanion6.Option.String("--package-name", {
9398
- description: "The new package name of the project"
9399
- });
9400
- manifestPath = import_clipanion6.Option.String("--manifest-path", "Cargo.toml", {
9401
- description: "Path to `Cargo.toml`"
9402
- });
9403
- repository = import_clipanion6.Option.String("--repository", {
9404
- description: "The new repository of the project"
9405
- });
9406
- description = import_clipanion6.Option.String("--description", {
9407
- description: "The new description of the project"
9408
- });
9409
- getOptions() {
9410
- return {
9411
- cwd: this.cwd,
9412
- configPath: this.configPath,
9413
- packageJsonPath: this.packageJsonPath,
9414
- npmDir: this.npmDir,
9415
- name: this.$$name,
9416
- binaryName: this.binaryName,
9417
- packageName: this.packageName,
9418
- manifestPath: this.manifestPath,
9419
- repository: this.repository,
9420
- description: this.description
9421
- };
9422
- }
9423
- };
9424
- function applyDefaultRenameOptions(options) {
9425
- return {
9426
- cwd: process.cwd(),
9427
- packageJsonPath: "package.json",
9428
- npmDir: "npm",
9429
- manifestPath: "Cargo.toml",
9430
- ...options
9431
- };
9432
- }
9433
-
9434
- // dist/api/rename.js
9435
- async function renameProject(userOptions) {
9436
- const options = applyDefaultRenameOptions(userOptions);
9437
- const packageJsonPath = (0, import_node_path7.resolve)(options.cwd, options.packageJsonPath);
9438
- const cargoTomlPath = (0, import_node_path7.resolve)(options.cwd, options.manifestPath);
9439
- const packageJsonContent = await readFileAsync(packageJsonPath, "utf8");
9440
- const packageJsonData = JSON.parse(packageJsonContent);
9441
- merge_default(packageJsonData, omitBy_default(pick_default(options, ["name", "description", "author", "license"]), isNil_default), {
9442
- napi: omitBy_default({
9443
- binaryName: options.binaryName,
9444
- packageName: options.packageName
9445
- }, isNil_default)
9446
- });
9447
- if (options.configPath) {
9448
- const configPath = (0, import_node_path7.resolve)(options.cwd, options.configPath);
9449
- const configContent = await readFileAsync(configPath, "utf8");
9450
- const configData = JSON.parse(configContent);
9451
- configData.binaryName = options.binaryName;
9452
- configData.packageName = options.packageName;
9453
- await writeFileAsync(configPath, JSON.stringify(configData, null, 2));
9454
- }
9455
- await writeFileAsync(packageJsonPath, JSON.stringify(packageJsonData, null, 2));
9456
- let tomlContent = await readFileAsync(cargoTomlPath, "utf8");
9457
- tomlContent = tomlContent.replace(/name\s?=\s?"([\w+])"/, `name = "${options.binaryName}"`);
9458
- await writeFileAsync(cargoTomlPath, tomlContent);
9459
- await createNpmDirs({
9460
- cwd: options.cwd,
9461
- packageJsonPath: options.packageJsonPath,
9462
- npmDir: options.npmDir,
9463
- dryRun: false
9464
- });
9465
- }
9466
-
9467
9667
  // dist/api/universalize.js
9468
9668
  var import_node_child_process7 = require("node:child_process");
9469
- var import_node_path8 = require("node:path");
9669
+ var import_node_path9 = require("node:path");
9470
9670
 
9471
9671
  // dist/def/universalize.js
9472
9672
  var import_clipanion7 = require("clipanion");
@@ -9516,13 +9716,13 @@ var universalizers = {
9516
9716
  };
9517
9717
  async function universalizeBinaries(userOptions) {
9518
9718
  const options = applyDefaultUniversalizeOptions(userOptions);
9519
- const packageJsonPath = (0, import_node_path8.join)(options.cwd, options.packageJsonPath);
9520
- const config = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path8.resolve)(options.cwd, options.configPath) : void 0);
9719
+ const packageJsonPath = (0, import_node_path9.join)(options.cwd, options.packageJsonPath);
9720
+ const config = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path9.resolve)(options.cwd, options.configPath) : void 0);
9521
9721
  const target = config.targets.find((t) => t.platform === process.platform && t.arch === "universal");
9522
9722
  if (!target) {
9523
9723
  throw new Error(`'universal' arch for platform '${process.platform}' not found in config!`);
9524
9724
  }
9525
- const srcFiles = UniArchsByPlatform[process.platform]?.map((arch) => (0, import_node_path8.resolve)(options.cwd, options.outputDir, `${config.binaryName}.${process.platform}-${arch}.node`));
9725
+ const srcFiles = UniArchsByPlatform[process.platform]?.map((arch) => (0, import_node_path9.resolve)(options.cwd, options.outputDir, `${config.binaryName}.${process.platform}-${arch}.node`));
9526
9726
  if (!srcFiles || !universalizers[process.platform]) {
9527
9727
  throw new Error(`'universal' arch for platform '${process.platform}' not supported.`);
9528
9728
  }
@@ -9533,7 +9733,7 @@ async function universalizeBinaries(userOptions) {
9533
9733
  if (notFoundFiles.length) {
9534
9734
  throw new Error(`Some binary files were not found: ${JSON.stringify(notFoundFiles)}`);
9535
9735
  }
9536
- const output = (0, import_node_path8.resolve)(options.cwd, options.outputDir, `${config.binaryName}.${process.platform}-universal.node`);
9736
+ const output = (0, import_node_path9.resolve)(options.cwd, options.outputDir, `${config.binaryName}.${process.platform}-universal.node`);
9537
9737
  universalizers[process.platform]?.(srcFiles, output);
9538
9738
  debug8(`Produced universal binary: ${output}`);
9539
9739
  }