@markw65/monkeyc-optimizer 1.1.16 → 1.1.18
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/README.md +24 -11
- package/build/api.cjs +33 -33
- package/build/{chunk-TQHOJQYY.cjs → chunk-TM6GLTGC.cjs} +418 -220
- package/build/{chunk-VVIZ2ADY.cjs → chunk-YCLY27QH.cjs} +17 -6
- package/build/optimizer.cjs +19 -17
- package/build/sdk-util.cjs +14 -14
- package/build/src/optimizer.d.ts +12 -2
- package/build/src/worker-pool.d.ts +1 -1
- package/build/src/worker-task.d.ts +18 -3
- package/build/worker-pool.cjs +35 -0
- package/build/worker-thread.cjs +40 -0
- package/package.json +3 -1
- package/build/chunk-K32K3YD4.cjs +0 -145
- package/build/chunk-WIPYYCBN.cjs +0 -54
|
@@ -26,24 +26,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_TM6GLTGC_exports = {};
|
|
30
|
+
__export(chunk_TM6GLTGC_exports, {
|
|
31
31
|
buildOptimizedProject: () => buildOptimizedProject,
|
|
32
32
|
defaultConfig: () => defaultConfig,
|
|
33
33
|
generateApiMirTests: () => generateApiMirTests,
|
|
34
|
+
generateOneConfig: () => generateOneConfig,
|
|
34
35
|
generateOptimizedProject: () => generateOptimizedProject,
|
|
35
36
|
getConfig: () => getConfig,
|
|
36
37
|
getProjectAnalysis: () => getProjectAnalysis,
|
|
37
38
|
get_jungle: () => get_jungle,
|
|
38
39
|
init_optimizer: () => init_optimizer,
|
|
40
|
+
init_worker_pool: () => init_worker_pool,
|
|
41
|
+
init_worker_task: () => init_worker_task,
|
|
39
42
|
isErrorWithLocation: () => isErrorWithLocation,
|
|
40
43
|
launchSimulator: () => launchSimulator,
|
|
41
44
|
manifestProducts: () => manifestProducts,
|
|
42
45
|
mctree: () => import_prettier_plugin_monkeyc.mctree,
|
|
43
|
-
|
|
46
|
+
performTask: () => performTask,
|
|
47
|
+
runTaskInPool: () => runTaskInPool,
|
|
48
|
+
simulateProgram: () => simulateProgram,
|
|
49
|
+
startPool: () => startPool,
|
|
50
|
+
stopPool: () => stopPool
|
|
44
51
|
});
|
|
45
|
-
module.exports = __toCommonJS(
|
|
46
|
-
var
|
|
52
|
+
module.exports = __toCommonJS(chunk_TM6GLTGC_exports);
|
|
53
|
+
var import_chunk_YCLY27QH = require("./chunk-YCLY27QH.cjs");
|
|
47
54
|
var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
|
|
48
55
|
var path = __toESM(require("path"));
|
|
49
56
|
var fs = __toESM(require("fs/promises"));
|
|
@@ -58,6 +65,10 @@ var crypto2 = __toESM(require("crypto"));
|
|
|
58
65
|
var fs3 = __toESM(require("fs/promises"));
|
|
59
66
|
var path4 = __toESM(require("path"));
|
|
60
67
|
var Prettier = __toESM(require("prettier"));
|
|
68
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
69
|
+
var import_node_events = require("node:events");
|
|
70
|
+
var import_node_worker_threads = require("node:worker_threads");
|
|
71
|
+
var os = __toESM(require("node:os"));
|
|
61
72
|
async function build_project(product, options, lineCallback) {
|
|
62
73
|
const {
|
|
63
74
|
workspace,
|
|
@@ -72,7 +83,7 @@ async function build_project(product, options, lineCallback) {
|
|
|
72
83
|
typeCheckLevel,
|
|
73
84
|
returnCommand
|
|
74
85
|
} = options;
|
|
75
|
-
const sdk = await (0,
|
|
86
|
+
const sdk = await (0, import_chunk_YCLY27QH.getSdkPath)();
|
|
76
87
|
const extraArgs = [];
|
|
77
88
|
if (compilerOptions) {
|
|
78
89
|
extraArgs.push(...compilerOptions.split(/\s+/));
|
|
@@ -113,8 +124,11 @@ async function build_project(product, options, lineCallback) {
|
|
|
113
124
|
if (!program || !jungleFiles || !developerKeyPath || !workspace) {
|
|
114
125
|
throw new Error("Required arguments were missing!");
|
|
115
126
|
}
|
|
116
|
-
const exe =
|
|
127
|
+
const exe = "java";
|
|
117
128
|
const args = [
|
|
129
|
+
["-Xms1g", "-Dfile.encoding=UTF-8", "-Dapple.awt.UIElement=true"],
|
|
130
|
+
["-cp", path.resolve(sdk, "bin", "monkeybrains.jar")],
|
|
131
|
+
["com.garmin.monkeybrains.Monkeybrains"],
|
|
118
132
|
["-o", program],
|
|
119
133
|
["-f", jungleFiles],
|
|
120
134
|
["-y", developerKeyPath],
|
|
@@ -134,7 +148,7 @@ async function build_project(product, options, lineCallback) {
|
|
|
134
148
|
var init_build = (0, import_chunk_IAUHYWVN.__esm)({
|
|
135
149
|
"src/build.ts"() {
|
|
136
150
|
"use strict";
|
|
137
|
-
(0,
|
|
151
|
+
(0, import_chunk_YCLY27QH.init_sdk_util)();
|
|
138
152
|
(0, import_chunk_IAUHYWVN.init_util)();
|
|
139
153
|
}
|
|
140
154
|
});
|
|
@@ -594,7 +608,7 @@ var require_has_flag = (0, import_chunk_IAUHYWVN.__commonJS)({
|
|
|
594
608
|
var require_supports_color = (0, import_chunk_IAUHYWVN.__commonJS)({
|
|
595
609
|
"node_modules/supports-color/index.js"(exports, module2) {
|
|
596
610
|
"use strict";
|
|
597
|
-
var
|
|
611
|
+
var os2 = (0, import_chunk_IAUHYWVN.__require)("os");
|
|
598
612
|
var tty = (0, import_chunk_IAUHYWVN.__require)("tty");
|
|
599
613
|
var hasFlag = require_has_flag();
|
|
600
614
|
var { env } = process;
|
|
@@ -642,7 +656,7 @@ var require_supports_color = (0, import_chunk_IAUHYWVN.__commonJS)({
|
|
|
642
656
|
return min;
|
|
643
657
|
}
|
|
644
658
|
if (process.platform === "win32") {
|
|
645
|
-
const osRelease =
|
|
659
|
+
const osRelease = os2.release().split(".");
|
|
646
660
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
647
661
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
648
662
|
}
|
|
@@ -1221,7 +1235,7 @@ var require_extract_zip = (0, import_chunk_IAUHYWVN.__commonJS)({
|
|
|
1221
1235
|
var path5 = (0, import_chunk_IAUHYWVN.__require)("path");
|
|
1222
1236
|
var { promisify } = (0, import_chunk_IAUHYWVN.__require)("util");
|
|
1223
1237
|
var stream = (0, import_chunk_IAUHYWVN.__require)("stream");
|
|
1224
|
-
var yauzl = (0,
|
|
1238
|
+
var yauzl = (0, import_chunk_YCLY27QH.require_yauzl)();
|
|
1225
1239
|
var openZip = promisify(yauzl.open);
|
|
1226
1240
|
var pipeline = promisify(stream.pipeline);
|
|
1227
1241
|
var Extractor = class {
|
|
@@ -2943,10 +2957,10 @@ var init_jungle = (0, import_chunk_IAUHYWVN.__esm)({
|
|
|
2943
2957
|
});
|
|
2944
2958
|
async function readManifest(manifest) {
|
|
2945
2959
|
const data = await fs.readFile(manifest);
|
|
2946
|
-
return
|
|
2960
|
+
return import_chunk_YCLY27QH.xml_util_exports.parseXml(data.toString(), manifest);
|
|
2947
2961
|
}
|
|
2948
2962
|
async function writeManifest(filename, xml) {
|
|
2949
|
-
return fs.writeFile(filename,
|
|
2963
|
+
return fs.writeFile(filename, import_chunk_YCLY27QH.xml_util_exports.writeXml(xml));
|
|
2950
2964
|
}
|
|
2951
2965
|
function manifestProducts(manifest) {
|
|
2952
2966
|
if (manifest.body instanceof Error) {
|
|
@@ -2972,20 +2986,20 @@ function manifestBarrelName(manifestName, manifest) {
|
|
|
2972
2986
|
}
|
|
2973
2987
|
const barrel = manifest.body.children("iq:barrel");
|
|
2974
2988
|
if (!barrel.elements.length) {
|
|
2975
|
-
throw new
|
|
2989
|
+
throw new import_chunk_YCLY27QH.xml_util_exports.PeggyError(
|
|
2976
2990
|
`Missing 'iq:barrel' in manifest`,
|
|
2977
2991
|
manifest.body.elements[0].loc
|
|
2978
2992
|
);
|
|
2979
2993
|
}
|
|
2980
2994
|
const modules = barrel.attrs().map((a) => a.module).filter((a) => a != null);
|
|
2981
2995
|
if (!modules.length) {
|
|
2982
|
-
throw new
|
|
2996
|
+
throw new import_chunk_YCLY27QH.xml_util_exports.PeggyError(
|
|
2983
2997
|
`Missing 'module' attribute in barrel manifest`,
|
|
2984
2998
|
barrel.elements[0].loc
|
|
2985
2999
|
);
|
|
2986
3000
|
}
|
|
2987
3001
|
if (modules.length !== 1) {
|
|
2988
|
-
throw new
|
|
3002
|
+
throw new import_chunk_YCLY27QH.xml_util_exports.PeggyError(
|
|
2989
3003
|
`Manifest defines multiple modules`,
|
|
2990
3004
|
modules[0].loc
|
|
2991
3005
|
);
|
|
@@ -3022,13 +3036,13 @@ async function checkManifest(manifest, products) {
|
|
|
3022
3036
|
const id = attrs.id?.value.value;
|
|
3023
3037
|
if (typeof id !== "string" || id.length < 32 || !/^[-_0-9a-f.]+$/.test(id)) {
|
|
3024
3038
|
ok = false;
|
|
3025
|
-
attrs.id =
|
|
3039
|
+
attrs.id = import_chunk_YCLY27QH.xml_util_exports.makeAttribute(
|
|
3026
3040
|
"id",
|
|
3027
3041
|
"08070f9d-8b4e-40a4-9c49-fe67a2a55dec"
|
|
3028
3042
|
);
|
|
3029
3043
|
}
|
|
3030
3044
|
const type = attrs.type?.value.value.replace(/-/g, "").toLowerCase();
|
|
3031
|
-
const deviceInfo = await (0,
|
|
3045
|
+
const deviceInfo = await (0, import_chunk_YCLY27QH.getDeviceInfo)();
|
|
3032
3046
|
const allowedProducts = products.sort().filter(
|
|
3033
3047
|
(p) => deviceInfo[p] && deviceInfo[p].appTypes.find((at) => {
|
|
3034
3048
|
const t = at.type.toLowerCase();
|
|
@@ -3045,7 +3059,7 @@ async function checkManifest(manifest, products) {
|
|
|
3045
3059
|
type: "element",
|
|
3046
3060
|
name: "iq:product",
|
|
3047
3061
|
attr: {
|
|
3048
|
-
id:
|
|
3062
|
+
id: import_chunk_YCLY27QH.xml_util_exports.makeAttribute("id", id2)
|
|
3049
3063
|
}
|
|
3050
3064
|
};
|
|
3051
3065
|
})
|
|
@@ -3069,16 +3083,16 @@ async function checkManifest(manifest, products) {
|
|
|
3069
3083
|
var init_manifest = (0, import_chunk_IAUHYWVN.__esm)({
|
|
3070
3084
|
"src/manifest.ts"() {
|
|
3071
3085
|
"use strict";
|
|
3072
|
-
(0,
|
|
3086
|
+
(0, import_chunk_YCLY27QH.init_sdk_util)();
|
|
3073
3087
|
}
|
|
3074
3088
|
});
|
|
3075
3089
|
function isJNode(obj) {
|
|
3076
|
-
return (0,
|
|
3090
|
+
return (0, import_chunk_YCLY27QH.hasProperty)(obj, "type");
|
|
3077
3091
|
}
|
|
3078
3092
|
async function default_jungle() {
|
|
3079
3093
|
const assignments = [];
|
|
3080
|
-
const devices = await (0,
|
|
3081
|
-
const languages = await (0,
|
|
3094
|
+
const devices = await (0, import_chunk_YCLY27QH.getDeviceInfo)();
|
|
3095
|
+
const languages = await (0, import_chunk_YCLY27QH.getLanguages)();
|
|
3082
3096
|
const literal = (value) => ({ type: "Literal", value });
|
|
3083
3097
|
const qname = (name) => ({
|
|
3084
3098
|
type: "QualifiedName",
|
|
@@ -3108,11 +3122,11 @@ async function default_jungle() {
|
|
|
3108
3122
|
);
|
|
3109
3123
|
}
|
|
3110
3124
|
const shape = match[1];
|
|
3111
|
-
if (!(0,
|
|
3125
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(done, shape)) {
|
|
3112
3126
|
rezAndLang(shape, `resources-${shape}`, "base");
|
|
3113
3127
|
done[shape] = true;
|
|
3114
3128
|
}
|
|
3115
|
-
if (!(0,
|
|
3129
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(done, deviceFamily)) {
|
|
3116
3130
|
rezAndLang(deviceFamily, `resources-${deviceFamily}`, shape);
|
|
3117
3131
|
done[deviceFamily] = true;
|
|
3118
3132
|
}
|
|
@@ -3125,7 +3139,7 @@ function process_assignments(assignments, current) {
|
|
|
3125
3139
|
return assignments.reduce((state, a) => {
|
|
3126
3140
|
const { node, dot, dotnames } = a.names.reduce(
|
|
3127
3141
|
(r, name) => {
|
|
3128
|
-
if (!(0,
|
|
3142
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(r.node, name))
|
|
3129
3143
|
r.node[name] = {};
|
|
3130
3144
|
r.dotnames.push(name);
|
|
3131
3145
|
r.node = r.node[name];
|
|
@@ -3185,7 +3199,7 @@ function evaluate_locals(assignments) {
|
|
|
3185
3199
|
const process_list = (values) => {
|
|
3186
3200
|
for (let i = values.length; i--; ) {
|
|
3187
3201
|
const v = values[i];
|
|
3188
|
-
if (v.type === "QualifiedName" && v.names.length === 1 && (0,
|
|
3202
|
+
if (v.type === "QualifiedName" && v.names.length === 1 && (0, import_chunk_YCLY27QH.hasProperty)(locals, v.names[0])) {
|
|
3189
3203
|
values.splice(i, 1, ...locals[v.names[0]]);
|
|
3190
3204
|
} else if (v.type === "SubList") {
|
|
3191
3205
|
process_list(v.values);
|
|
@@ -3320,7 +3334,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
3320
3334
|
/[\\/]\*\*([^\\/])/g,
|
|
3321
3335
|
"/**/*$1"
|
|
3322
3336
|
);
|
|
3323
|
-
if (!(0,
|
|
3337
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(cache.resolvedPaths, resolved)) {
|
|
3324
3338
|
if (/[*?[\]{}]/.test(resolved)) {
|
|
3325
3339
|
cache.resolvedPaths[resolved] = (0, import_chunk_IAUHYWVN.globSome)(resolved, () => true);
|
|
3326
3340
|
} else {
|
|
@@ -3367,7 +3381,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
3367
3381
|
resolve_literal_list(qualifier, "excludeAnnotations");
|
|
3368
3382
|
const annotations = {};
|
|
3369
3383
|
Object.entries(qualifier).forEach(([k, v]) => {
|
|
3370
|
-
if ((0,
|
|
3384
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(v, "annotations")) {
|
|
3371
3385
|
annotations[k] = v["annotations"];
|
|
3372
3386
|
resolve_literal_list(annotations, k);
|
|
3373
3387
|
delete qualifier[k];
|
|
@@ -3388,7 +3402,7 @@ async function read_resource_files(targets, cache) {
|
|
|
3388
3402
|
if (!p.qualifier.resourcePath)
|
|
3389
3403
|
return null;
|
|
3390
3404
|
const key = p.qualifier.resourcePath.join(";");
|
|
3391
|
-
if (!(0,
|
|
3405
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(resourceGroupPromises, key)) {
|
|
3392
3406
|
resourceGroupPromises[key] = Promise.all(
|
|
3393
3407
|
p.qualifier.resourcePath.map(
|
|
3394
3408
|
(pattern) => (0, import_chunk_IAUHYWVN.globa)(pattern, { mark: true })
|
|
@@ -3401,9 +3415,9 @@ async function read_resource_files(targets, cache) {
|
|
|
3401
3415
|
).then(
|
|
3402
3416
|
(paths) => Promise.all(
|
|
3403
3417
|
paths.flat().filter((file) => file.endsWith(".xml")).map((file) => {
|
|
3404
|
-
if (!(0,
|
|
3418
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(cache.resources, file)) {
|
|
3405
3419
|
cache.resources[file] = fs2.readFile(file).then(
|
|
3406
|
-
(data) =>
|
|
3420
|
+
(data) => import_chunk_YCLY27QH.xml_util_exports.parseXml(data.toString(), file)
|
|
3407
3421
|
);
|
|
3408
3422
|
}
|
|
3409
3423
|
return Promise.resolve(cache.resources[file]).then(
|
|
@@ -3472,9 +3486,9 @@ async function find_build_instructions(targets, resourceGroups, buildDependencie
|
|
|
3472
3486
|
if (!p.qualifier.resourcePath)
|
|
3473
3487
|
return;
|
|
3474
3488
|
const key = p.qualifier.resourcePath.join(";");
|
|
3475
|
-
if (!(0,
|
|
3489
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(resourceGroups, key))
|
|
3476
3490
|
return;
|
|
3477
|
-
if (!(0,
|
|
3491
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(resourceGroups[key], "buildInstructions")) {
|
|
3478
3492
|
resourceGroups[key].buildInstructions = (await Promise.all(
|
|
3479
3493
|
resourceGroups[key].resourceFiles.map(
|
|
3480
3494
|
({ path: path5, resources }) => find_build_instructions_in_resource(
|
|
@@ -3511,7 +3525,7 @@ function identify_optimizer_groups(targets, options) {
|
|
|
3511
3525
|
if (option === "*") {
|
|
3512
3526
|
return [];
|
|
3513
3527
|
} else {
|
|
3514
|
-
return strs.filter((a) => !(0,
|
|
3528
|
+
return strs.filter((a) => !(0, import_chunk_YCLY27QH.hasProperty)(option, a));
|
|
3515
3529
|
}
|
|
3516
3530
|
};
|
|
3517
3531
|
const ignoreRegExpOption = (str) => {
|
|
@@ -3534,7 +3548,7 @@ function identify_optimizer_groups(targets, options) {
|
|
|
3534
3548
|
target.qualifier.sourcePath.forEach((path5) => {
|
|
3535
3549
|
const m = path5.match(ignoredSourcePathsRe);
|
|
3536
3550
|
const key2 = m ? "key-" + m.slice(1).join("") : path5;
|
|
3537
|
-
if (!(0,
|
|
3551
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(state.keys, key2)) {
|
|
3538
3552
|
state.keys[key2] = {};
|
|
3539
3553
|
}
|
|
3540
3554
|
state.keys[key2][path5] = true;
|
|
@@ -3598,7 +3612,7 @@ function identify_optimizer_groups(targets, options) {
|
|
|
3598
3612
|
}
|
|
3599
3613
|
return toSortedEntries(value);
|
|
3600
3614
|
});
|
|
3601
|
-
if (!(0,
|
|
3615
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(groups, serialized)) {
|
|
3602
3616
|
groups[serialized] = {
|
|
3603
3617
|
key: "group" + key.toString().padStart(3, "0"),
|
|
3604
3618
|
optimizerConfig
|
|
@@ -3627,7 +3641,7 @@ function find_barrels(barrelPath) {
|
|
|
3627
3641
|
);
|
|
3628
3642
|
}
|
|
3629
3643
|
function resolve_barrel(barrel, barrelDir, products, options, cache, buildDependencies) {
|
|
3630
|
-
if ((0,
|
|
3644
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(cache.barrels, barrel)) {
|
|
3631
3645
|
return cache.barrels[barrel];
|
|
3632
3646
|
}
|
|
3633
3647
|
let promise = Promise.resolve();
|
|
@@ -3695,7 +3709,7 @@ function resolve_barrels(product, qualifier, barrels, products, options, cache,
|
|
|
3695
3709
|
return result;
|
|
3696
3710
|
}, {});
|
|
3697
3711
|
};
|
|
3698
|
-
if ((0,
|
|
3712
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(cache.barrelMap, barrelMapKey)) {
|
|
3699
3713
|
setBarrelMap(cache.barrelMap[barrelMapKey]);
|
|
3700
3714
|
return null;
|
|
3701
3715
|
}
|
|
@@ -3727,7 +3741,7 @@ function resolve_barrels(product, qualifier, barrels, products, options, cache,
|
|
|
3727
3741
|
resolvedBarrel.manifest,
|
|
3728
3742
|
resolvedBarrel.xml
|
|
3729
3743
|
);
|
|
3730
|
-
if (!(0,
|
|
3744
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(barrelMap, name))
|
|
3731
3745
|
return;
|
|
3732
3746
|
const bmapName = barrelMap[name];
|
|
3733
3747
|
if (bmapName) {
|
|
@@ -3783,7 +3797,7 @@ async function get_jungle_and_barrels(jungleFiles, defaultProducts, options, cac
|
|
|
3783
3797
|
if (!options.workspace) {
|
|
3784
3798
|
options.workspace = path2.dirname(manifest);
|
|
3785
3799
|
}
|
|
3786
|
-
if (!(0,
|
|
3800
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(cache.resources, manifest)) {
|
|
3787
3801
|
cache.resources[manifest] = readManifest(manifest);
|
|
3788
3802
|
}
|
|
3789
3803
|
const xml = await Promise.resolve(cache.resources[manifest]);
|
|
@@ -3825,7 +3839,7 @@ async function get_jungle_and_barrels(jungleFiles, defaultProducts, options, cac
|
|
|
3825
3839
|
});
|
|
3826
3840
|
};
|
|
3827
3841
|
products.forEach((product) => {
|
|
3828
|
-
if ((0,
|
|
3842
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(state, product)) {
|
|
3829
3843
|
const sp = state[product];
|
|
3830
3844
|
if (sp && !Array.isArray(sp) && sp.products) {
|
|
3831
3845
|
sp.products.forEach((p) => add_one(p, product));
|
|
@@ -3872,9 +3886,9 @@ var init_jungles = (0, import_chunk_IAUHYWVN.__esm)({
|
|
|
3872
3886
|
"use strict";
|
|
3873
3887
|
import_extract_zip = (0, import_chunk_IAUHYWVN.__toESM)(require_extract_zip());
|
|
3874
3888
|
init_jungle();
|
|
3875
|
-
(0,
|
|
3889
|
+
(0, import_chunk_YCLY27QH.init_api)();
|
|
3876
3890
|
init_manifest();
|
|
3877
|
-
(0,
|
|
3891
|
+
(0, import_chunk_YCLY27QH.init_sdk_util)();
|
|
3878
3892
|
(0, import_chunk_IAUHYWVN.init_util)();
|
|
3879
3893
|
}
|
|
3880
3894
|
});
|
|
@@ -3882,8 +3896,8 @@ async function launchSimulator(force = true) {
|
|
|
3882
3896
|
try {
|
|
3883
3897
|
if (!force && await checkIfSimulatorRunning())
|
|
3884
3898
|
return;
|
|
3885
|
-
const sdk = await (0,
|
|
3886
|
-
const child = force || process.platform !== "darwin" ? (0, import_child_process.execFile)(path3.resolve(sdk, "bin",
|
|
3899
|
+
const sdk = await (0, import_chunk_YCLY27QH.getSdkPath)();
|
|
3900
|
+
const child = force || process.platform !== "darwin" ? (0, import_child_process.execFile)(path3.resolve(sdk, "bin", import_chunk_YCLY27QH.isWin ? "simulator" : "connectiq")) : (0, import_child_process.execFile)("/usr/bin/open", [
|
|
3887
3901
|
"-g",
|
|
3888
3902
|
"-a",
|
|
3889
3903
|
path3.resolve(
|
|
@@ -3927,14 +3941,14 @@ function checkIfSimulatorRunningOn(port) {
|
|
|
3927
3941
|
function simulateProgram(prg, device, test = false, logger) {
|
|
3928
3942
|
const args = [prg, device];
|
|
3929
3943
|
if (test) {
|
|
3930
|
-
args.push(
|
|
3944
|
+
args.push(import_chunk_YCLY27QH.isWin ? "/t" : "-t");
|
|
3931
3945
|
if (typeof test === "string") {
|
|
3932
3946
|
args.push(test);
|
|
3933
3947
|
}
|
|
3934
3948
|
}
|
|
3935
|
-
return (0,
|
|
3949
|
+
return (0, import_chunk_YCLY27QH.getSdkPath)().then(
|
|
3936
3950
|
(sdk) => (0, import_chunk_IAUHYWVN.spawnByLine)(
|
|
3937
|
-
path3.resolve(sdk, "bin",
|
|
3951
|
+
path3.resolve(sdk, "bin", import_chunk_YCLY27QH.isWin ? "monkeydo.bat" : "monkeydo"),
|
|
3938
3952
|
args,
|
|
3939
3953
|
logger || ((line) => console.log(line))
|
|
3940
3954
|
).then(() => {
|
|
@@ -3945,7 +3959,7 @@ function simulateProgram(prg, device, test = false, logger) {
|
|
|
3945
3959
|
var init_launch = (0, import_chunk_IAUHYWVN.__esm)({
|
|
3946
3960
|
"src/launch.ts"() {
|
|
3947
3961
|
"use strict";
|
|
3948
|
-
(0,
|
|
3962
|
+
(0, import_chunk_YCLY27QH.init_sdk_util)();
|
|
3949
3963
|
(0, import_chunk_IAUHYWVN.init_util)();
|
|
3950
3964
|
}
|
|
3951
3965
|
});
|
|
@@ -3964,7 +3978,7 @@ async function getVSCodeSettings(path5) {
|
|
|
3964
3978
|
}
|
|
3965
3979
|
}
|
|
3966
3980
|
function isErrorWithLocation(e) {
|
|
3967
|
-
return (0,
|
|
3981
|
+
return (0, import_chunk_YCLY27QH.hasProperty)(e, "location");
|
|
3968
3982
|
}
|
|
3969
3983
|
function getConfig(options) {
|
|
3970
3984
|
const config = { ...defaultConfig, ...options || {} };
|
|
@@ -3981,7 +3995,7 @@ function getConfig(options) {
|
|
|
3981
3995
|
if (key in config)
|
|
3982
3996
|
return promise;
|
|
3983
3997
|
return promise.then(
|
|
3984
|
-
(v) => v || getVSCodeSettings(`${
|
|
3998
|
+
(v) => v || getVSCodeSettings(`${import_chunk_YCLY27QH.appSupport}/Code/User/settings.json`).then(
|
|
3985
3999
|
(globals) => getVSCodeSettings(
|
|
3986
4000
|
`${config.workspace}/.vscode/settings.json`
|
|
3987
4001
|
).then((locals) => ({ ...globals, ...locals }))
|
|
@@ -4001,7 +4015,7 @@ async function buildOptimizedProject(product, options) {
|
|
|
4001
4015
|
config.products = [product];
|
|
4002
4016
|
} else {
|
|
4003
4017
|
delete config.testBuild;
|
|
4004
|
-
if (!(0,
|
|
4018
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(config, "releaseBuild")) {
|
|
4005
4019
|
config.releaseBuild = true;
|
|
4006
4020
|
}
|
|
4007
4021
|
}
|
|
@@ -4057,7 +4071,7 @@ async function createLocalBarrels(targets, options) {
|
|
|
4057
4071
|
);
|
|
4058
4072
|
const sha1 = crypto2.createHash("sha1").update(rawBarrelDir, "binary").digest("base64").replace(/[/=+]/g, "");
|
|
4059
4073
|
const optBarrelDir = path4.resolve(barrelDir, `${barrel}-${sha1}`);
|
|
4060
|
-
if (!(0,
|
|
4074
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(optBarrels, barrel)) {
|
|
4061
4075
|
optBarrels[barrel] = {
|
|
4062
4076
|
rawBarrelDir,
|
|
4063
4077
|
manifest,
|
|
@@ -4124,13 +4138,14 @@ async function generateOptimizedProject(options) {
|
|
|
4124
4138
|
};
|
|
4125
4139
|
}
|
|
4126
4140
|
let dropBarrels = false;
|
|
4141
|
+
let configsToBuild = 0;
|
|
4127
4142
|
const configKey = (p) => p.group.key + (config.releaseBuild ? "-release" : "-debug");
|
|
4128
4143
|
targets.forEach((p) => {
|
|
4129
4144
|
if (!p.group) {
|
|
4130
4145
|
throw new Error(`Missing group in build target ${p.product}`);
|
|
4131
4146
|
}
|
|
4132
4147
|
const key = configKey(p);
|
|
4133
|
-
if (!(0,
|
|
4148
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(buildConfigs, key)) {
|
|
4134
4149
|
p.group.dir = key;
|
|
4135
4150
|
if (p.group.optimizerConfig.barrelMap && !p.group.optimizerConfig.optBarrels) {
|
|
4136
4151
|
dropBarrels = true;
|
|
@@ -4146,6 +4161,7 @@ async function generateOptimizedProject(options) {
|
|
|
4146
4161
|
if (!buildConfigs[key]) {
|
|
4147
4162
|
buildConfigs[key] = p.group.optimizerConfig;
|
|
4148
4163
|
products[key] = [];
|
|
4164
|
+
configsToBuild++;
|
|
4149
4165
|
}
|
|
4150
4166
|
products[key].push(p.product);
|
|
4151
4167
|
}
|
|
@@ -4160,151 +4176,176 @@ async function generateOptimizedProject(options) {
|
|
|
4160
4176
|
)) && !dropBarrels;
|
|
4161
4177
|
let hasTests = false;
|
|
4162
4178
|
let diagnostics = {};
|
|
4163
|
-
const
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
return buildConfig ? generateOneConfig(buildConfig, xml, dependencyFiles, {
|
|
4167
|
-
...config,
|
|
4168
|
-
outputPath
|
|
4169
|
-
}).catch((e) => {
|
|
4170
|
-
if (!e.stack) {
|
|
4171
|
-
e = new Error(e.toString());
|
|
4172
|
-
}
|
|
4173
|
-
e.products = products[key];
|
|
4174
|
-
throw e;
|
|
4175
|
-
}).then((t) => {
|
|
4176
|
-
if (t.hasTests)
|
|
4177
|
-
hasTests = true;
|
|
4178
|
-
if (t.diagnostics) {
|
|
4179
|
-
diagnostics = { ...diagnostics, ...t.diagnostics };
|
|
4180
|
-
}
|
|
4181
|
-
}) : fs3.rm(path4.resolve(workspace, outputPath), {
|
|
4182
|
-
recursive: true,
|
|
4183
|
-
force: true
|
|
4184
|
-
});
|
|
4185
|
-
});
|
|
4186
|
-
if (!manifestOk) {
|
|
4187
|
-
if (dropBarrels) {
|
|
4188
|
-
manifestDropBarrels(xml);
|
|
4189
|
-
}
|
|
4190
|
-
const manifestFile = path4.join(jungle_dir, "manifest.xml");
|
|
4191
|
-
promises.push(writeManifest(manifestFile, xml));
|
|
4192
|
-
relative_manifest = "manifest.xml";
|
|
4193
|
-
}
|
|
4194
|
-
const parts = [`project.manifest=${relative_manifest}`];
|
|
4195
|
-
const map_field = (base, name, mapper = null) => {
|
|
4196
|
-
const obj = base[name];
|
|
4197
|
-
if (!obj)
|
|
4198
|
-
return null;
|
|
4199
|
-
const map_one = (s) => mapper ? mapper(s) : s;
|
|
4200
|
-
const map = (s) => Array.isArray(s) ? `[${s.map(map_one).join(";")}]` : map_one(s);
|
|
4201
|
-
return `${obj.map(map).join(";")}`;
|
|
4202
|
-
};
|
|
4203
|
-
const process_field = (prefix, base, name, mapper = null) => {
|
|
4204
|
-
const mapped = map_field(base, name, mapper);
|
|
4205
|
-
if (!mapped)
|
|
4206
|
-
return;
|
|
4207
|
-
parts.push(`${prefix}${name} = ${mapped}`);
|
|
4208
|
-
};
|
|
4209
|
-
const languagesToInclude = Object.fromEntries(
|
|
4210
|
-
(manifestLanguages(xml) || []).map((lang) => [lang, true])
|
|
4179
|
+
const jungleFiles = path4.join(
|
|
4180
|
+
jungle_dir,
|
|
4181
|
+
`${config.releaseBuild ? "release" : "debug"}.jungle`
|
|
4211
4182
|
);
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4183
|
+
let poolStarted;
|
|
4184
|
+
try {
|
|
4185
|
+
if (configsToBuild > 1) {
|
|
4186
|
+
poolStarted = startPool();
|
|
4187
|
+
}
|
|
4188
|
+
const promises = Object.keys(buildConfigs).sort().map((key) => {
|
|
4189
|
+
const buildConfig = buildConfigs[key];
|
|
4190
|
+
const outputPath = path4.join(config.outputPath, key);
|
|
4191
|
+
return buildConfig ? runTaskInPool({
|
|
4192
|
+
type: "generateOneConfig",
|
|
4193
|
+
data: {
|
|
4194
|
+
buildConfig,
|
|
4195
|
+
manifestXML: xml,
|
|
4196
|
+
dependencyFiles,
|
|
4197
|
+
config: {
|
|
4198
|
+
...config,
|
|
4199
|
+
outputPath
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
}).catch((e) => {
|
|
4203
|
+
if (!e.stack) {
|
|
4204
|
+
e = new Error(e.toString());
|
|
4205
|
+
}
|
|
4206
|
+
e.products = products[key];
|
|
4207
|
+
throw e;
|
|
4208
|
+
}).then((t) => {
|
|
4209
|
+
if (t.hasTests)
|
|
4210
|
+
hasTests = true;
|
|
4211
|
+
if (t.diagnostics) {
|
|
4212
|
+
diagnostics = { ...diagnostics, ...t.diagnostics };
|
|
4213
|
+
}
|
|
4214
|
+
}) : fs3.rm(path4.resolve(workspace, outputPath), {
|
|
4215
|
+
recursive: true,
|
|
4216
|
+
force: true
|
|
4217
|
+
});
|
|
4218
|
+
});
|
|
4219
|
+
if (!manifestOk) {
|
|
4220
|
+
if (dropBarrels) {
|
|
4221
|
+
manifestDropBarrels(xml);
|
|
4222
|
+
}
|
|
4223
|
+
const manifestFile = path4.join(jungle_dir, "manifest.xml");
|
|
4224
|
+
promises.push(writeManifest(manifestFile, xml));
|
|
4225
|
+
relative_manifest = "manifest.xml";
|
|
4226
|
+
}
|
|
4227
|
+
const parts = [`project.manifest=${relative_manifest}`];
|
|
4228
|
+
const map_field = (base, name, mapper = null) => {
|
|
4229
|
+
const obj = base[name];
|
|
4230
|
+
if (!obj)
|
|
4231
|
+
return null;
|
|
4232
|
+
const map_one = (s) => mapper ? mapper(s) : s;
|
|
4233
|
+
const map = (s) => Array.isArray(s) ? `[${s.map(map_one).join(";")}]` : map_one(s);
|
|
4234
|
+
return `${obj.map(map).join(";")}`;
|
|
4235
|
+
};
|
|
4236
|
+
const process_field = (prefix, base, name, mapper = null) => {
|
|
4237
|
+
const mapped = map_field(base, name, mapper);
|
|
4238
|
+
if (!mapped)
|
|
4239
|
+
return;
|
|
4240
|
+
parts.push(`${prefix}${name} = ${mapped}`);
|
|
4241
|
+
};
|
|
4242
|
+
const languagesToInclude = Object.fromEntries(
|
|
4243
|
+
(manifestLanguages(xml) || []).map((lang) => [lang, true])
|
|
4246
4244
|
);
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4245
|
+
const unsupportedLangsCache = {};
|
|
4246
|
+
let availableDefaults = null;
|
|
4247
|
+
const nextAvailableDefault = () => {
|
|
4248
|
+
if (!availableDefaults) {
|
|
4249
|
+
availableDefaults = Object.keys(
|
|
4250
|
+
Object.values(devices).reduce((m, d) => {
|
|
4251
|
+
m[d.deviceFamily] = true;
|
|
4252
|
+
const match = d.deviceFamily.match(/^(\w+)-\d+x\d+/);
|
|
4253
|
+
if (match)
|
|
4254
|
+
m[match[1]] = true;
|
|
4255
|
+
return m;
|
|
4256
|
+
}, {})
|
|
4257
|
+
).sort();
|
|
4258
|
+
availableDefaults.unshift("base");
|
|
4259
|
+
}
|
|
4260
|
+
return availableDefaults.shift();
|
|
4261
|
+
};
|
|
4262
|
+
targets.forEach((target) => {
|
|
4263
|
+
if (!buildConfigs[configKey(target)])
|
|
4264
|
+
return;
|
|
4265
|
+
const { product, qualifier, group } = target;
|
|
4266
|
+
if (!group) {
|
|
4267
|
+
throw new Error(`Missing group in target ${target.product}`);
|
|
4268
|
+
}
|
|
4269
|
+
const prefix = `${product}.`;
|
|
4270
|
+
process_field(
|
|
4271
|
+
prefix,
|
|
4272
|
+
qualifier,
|
|
4273
|
+
"sourcePath",
|
|
4274
|
+
(s) => path4.join(
|
|
4275
|
+
group.dir,
|
|
4276
|
+
"source",
|
|
4277
|
+
relative_path_no_dotdot(path4.relative(workspace, s))
|
|
4278
|
+
).replace(/([\\/]\*\*)[\\/]\*/g, "$1")
|
|
4264
4279
|
);
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4280
|
+
if (group.optimizerConfig.optBarrels) {
|
|
4281
|
+
parts.push(
|
|
4282
|
+
`${prefix}barrelPath = ${Object.values(
|
|
4283
|
+
group.optimizerConfig.optBarrels
|
|
4284
|
+
).map(
|
|
4285
|
+
(value) => `[${value.jungleFiles.map((j) => relative_path(path4.join(value.optBarrelDir, j))).join(";")}]`
|
|
4286
|
+
).join(";")}`
|
|
4287
|
+
);
|
|
4288
|
+
}
|
|
4289
|
+
if (group.optimizerConfig.barrelMap) {
|
|
4290
|
+
parts.push(
|
|
4291
|
+
`${prefix}sourcePath = ${[`$(${prefix}sourcePath)`].concat(
|
|
4292
|
+
Object.entries(group.optimizerConfig.barrelMap).map(([barrel, resolvedBarrel]) => {
|
|
4293
|
+
const root = path4.dirname(resolvedBarrel.jungles[0]);
|
|
4294
|
+
return (resolvedBarrel.qualifier.sourcePath || []).map(
|
|
4295
|
+
(s) => path4.join(
|
|
4296
|
+
group.dir,
|
|
4297
|
+
"barrels",
|
|
4298
|
+
barrel,
|
|
4299
|
+
path4.relative(root, s)
|
|
4300
|
+
).replace(/([\\/]\*\*)[\\/]\*/g, "$1")
|
|
4301
|
+
);
|
|
4302
|
+
}).flat().sort().filter((s, i, arr) => !i || s !== arr[i - 1])
|
|
4303
|
+
).join(";")}`
|
|
4304
|
+
);
|
|
4305
|
+
}
|
|
4306
|
+
process_field(prefix, qualifier, "resourcePath", relative_path);
|
|
4307
|
+
process_field(prefix, qualifier, "excludeAnnotations");
|
|
4308
|
+
const qlang = qualifier.lang;
|
|
4309
|
+
if (qlang) {
|
|
4310
|
+
const devLang = devices[product].languages;
|
|
4311
|
+
const unsupportedLangs = Object.keys(qlang).sort().map((key) => {
|
|
4312
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(devLang, key) || !(0, import_chunk_YCLY27QH.hasProperty)(languagesToInclude, key)) {
|
|
4313
|
+
return null;
|
|
4314
|
+
}
|
|
4315
|
+
const mapped = map_field(qlang, key, relative_path);
|
|
4316
|
+
if (!mapped)
|
|
4317
|
+
return null;
|
|
4318
|
+
return [key, mapped];
|
|
4319
|
+
}).filter((a) => a != null);
|
|
4320
|
+
let keysToSkip = null;
|
|
4321
|
+
if (unsupportedLangs.length) {
|
|
4322
|
+
const key = JSON.stringify(unsupportedLangs);
|
|
4323
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(unsupportedLangsCache, key)) {
|
|
4324
|
+
const base = nextAvailableDefault();
|
|
4325
|
+
if (base) {
|
|
4326
|
+
unsupportedLangs.forEach(
|
|
4327
|
+
([key2, value]) => parts.push(`${base}.lang.${key2} = ${value}`)
|
|
4328
|
+
);
|
|
4329
|
+
unsupportedLangsCache[key] = `${base}.lang`;
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(unsupportedLangsCache, key)) {
|
|
4333
|
+
keysToSkip = Object.fromEntries(unsupportedLangs);
|
|
4334
|
+
parts.push(`${prefix}lang = $(${unsupportedLangsCache[key]})`);
|
|
4290
4335
|
}
|
|
4291
4336
|
}
|
|
4292
|
-
|
|
4293
|
-
keysToSkip
|
|
4294
|
-
|
|
4295
|
-
}
|
|
4337
|
+
Object.keys(qlang).forEach((key) => {
|
|
4338
|
+
(0, import_chunk_YCLY27QH.hasProperty)(keysToSkip, key) || !(0, import_chunk_YCLY27QH.hasProperty)(languagesToInclude, key) || process_field(`${prefix}lang.`, qlang, key, relative_path);
|
|
4339
|
+
});
|
|
4296
4340
|
}
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4341
|
+
});
|
|
4342
|
+
promises.push(fs3.writeFile(jungleFiles, parts.join("\n")));
|
|
4343
|
+
await Promise.all(promises);
|
|
4344
|
+
} finally {
|
|
4345
|
+
if (poolStarted) {
|
|
4346
|
+
stopPool();
|
|
4300
4347
|
}
|
|
4301
|
-
}
|
|
4302
|
-
const jungleFiles = path4.join(
|
|
4303
|
-
jungle_dir,
|
|
4304
|
-
`${config.releaseBuild ? "release" : "debug"}.jungle`
|
|
4305
|
-
);
|
|
4306
|
-
promises.push(fs3.writeFile(jungleFiles, parts.join("\n")));
|
|
4307
|
-
await Promise.all(promises);
|
|
4348
|
+
}
|
|
4308
4349
|
return {
|
|
4309
4350
|
jungleFiles,
|
|
4310
4351
|
xml,
|
|
@@ -4421,7 +4462,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
4421
4462
|
const opt_time = await (0, import_chunk_IAUHYWVN.first_modified)(
|
|
4422
4463
|
Object.values(fnMap).map((v) => v.output)
|
|
4423
4464
|
);
|
|
4424
|
-
if (source_time < opt_time &&
|
|
4465
|
+
if (source_time < opt_time && 1678298050134 < opt_time) {
|
|
4425
4466
|
return { hasTests, diagnostics: prevDiagnostics };
|
|
4426
4467
|
}
|
|
4427
4468
|
}
|
|
@@ -4433,7 +4474,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
4433
4474
|
editorconfig: true
|
|
4434
4475
|
})
|
|
4435
4476
|
]);
|
|
4436
|
-
return (0,
|
|
4477
|
+
return (0, import_chunk_YCLY27QH.optimizeMonkeyC)(fnMap, resourcesMap, manifestXML, config).then(
|
|
4437
4478
|
(diagnostics) => {
|
|
4438
4479
|
const options = { ...prettierConfig, ...config.prettier || {} };
|
|
4439
4480
|
return Promise.all(
|
|
@@ -4442,7 +4483,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
4442
4483
|
const dir = path4.dirname(name);
|
|
4443
4484
|
await fs3.mkdir(dir, { recursive: true });
|
|
4444
4485
|
options.filepath = name;
|
|
4445
|
-
const opt_source = (0,
|
|
4486
|
+
const opt_source = (0, import_chunk_YCLY27QH.formatAst)(info.ast, info.monkeyCSource, options);
|
|
4446
4487
|
await fs3.writeFile(name, opt_source);
|
|
4447
4488
|
return info.hasTests;
|
|
4448
4489
|
})
|
|
@@ -4453,7 +4494,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
4453
4494
|
JSON.stringify({
|
|
4454
4495
|
hasTests: hasTests2,
|
|
4455
4496
|
diagnostics,
|
|
4456
|
-
optimizerVersion: "1.1.
|
|
4497
|
+
optimizerVersion: "1.1.18",
|
|
4457
4498
|
...Object.fromEntries(
|
|
4458
4499
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
4459
4500
|
)
|
|
@@ -4481,7 +4522,7 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
4481
4522
|
);
|
|
4482
4523
|
if (analysis) {
|
|
4483
4524
|
Object.entries(fnMap).forEach(([k, v]) => {
|
|
4484
|
-
if ((0,
|
|
4525
|
+
if ((0, import_chunk_YCLY27QH.hasProperty)(analysis.fnMap, k)) {
|
|
4485
4526
|
const old = analysis.fnMap[k];
|
|
4486
4527
|
if (old.monkeyCSource)
|
|
4487
4528
|
v.monkeyCSource = old.monkeyCSource;
|
|
@@ -4490,14 +4531,14 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
4490
4531
|
}
|
|
4491
4532
|
});
|
|
4492
4533
|
}
|
|
4493
|
-
if (!await (0,
|
|
4534
|
+
if (!await (0, import_chunk_YCLY27QH.getFileASTs)(fnMap)) {
|
|
4494
4535
|
return { fnMap, paths };
|
|
4495
4536
|
}
|
|
4496
4537
|
const resourcesMap = {};
|
|
4497
4538
|
const addResources = (name, resources) => {
|
|
4498
4539
|
if (!resources)
|
|
4499
4540
|
return;
|
|
4500
|
-
if (!(0,
|
|
4541
|
+
if (!(0, import_chunk_YCLY27QH.hasProperty)(resourcesMap, name)) {
|
|
4501
4542
|
resourcesMap[name] = { ...resources };
|
|
4502
4543
|
} else {
|
|
4503
4544
|
Object.assign(resourcesMap[name], resources);
|
|
@@ -4511,26 +4552,26 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
4511
4552
|
);
|
|
4512
4553
|
}
|
|
4513
4554
|
});
|
|
4514
|
-
const state = await (0,
|
|
4515
|
-
(0,
|
|
4555
|
+
const state = await (0, import_chunk_YCLY27QH.analyze)(fnMap, resourcesMap, manifestXML, options);
|
|
4556
|
+
(0, import_chunk_YCLY27QH.reportMissingSymbols)(state, options);
|
|
4516
4557
|
let typeMap = null;
|
|
4517
4558
|
if (state.config?.propagateTypes && state.config.trustDeclaredTypes && state.config.checkTypes !== "OFF" && Object.values(state.fnMap).every((ast) => ast != null)) {
|
|
4518
4559
|
const gistate = {
|
|
4519
4560
|
state,
|
|
4520
4561
|
stack: [],
|
|
4521
|
-
typeChecker: state.config.typeCheckLevel?.toLowerCase() === "strict" ?
|
|
4562
|
+
typeChecker: state.config.typeCheckLevel?.toLowerCase() === "strict" ? import_chunk_YCLY27QH.subtypeOf : import_chunk_YCLY27QH.couldBeWeak,
|
|
4522
4563
|
checkTypes: state.config?.checkTypes || "WARNING"
|
|
4523
4564
|
};
|
|
4524
4565
|
state.pre = (node) => {
|
|
4525
4566
|
switch (node.type) {
|
|
4526
4567
|
case "FunctionDeclaration": {
|
|
4527
4568
|
const self = state.top().sn;
|
|
4528
|
-
const istate = (0,
|
|
4569
|
+
const istate = (0, import_chunk_YCLY27QH.buildTypeInfo)(state, self, false);
|
|
4529
4570
|
if (istate) {
|
|
4530
4571
|
istate.state = state;
|
|
4531
4572
|
istate.typeChecker = gistate.typeChecker;
|
|
4532
4573
|
istate.checkTypes = gistate.checkTypes;
|
|
4533
|
-
(0,
|
|
4574
|
+
(0, import_chunk_YCLY27QH.evaluate)(istate, node.body);
|
|
4534
4575
|
if (istate.typeMap) {
|
|
4535
4576
|
if (typeMap == null) {
|
|
4536
4577
|
typeMap = istate.typeMap;
|
|
@@ -4547,7 +4588,7 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
4547
4588
|
return null;
|
|
4548
4589
|
};
|
|
4549
4590
|
Object.values(state.fnMap).forEach((f) => {
|
|
4550
|
-
(0,
|
|
4591
|
+
(0, import_chunk_YCLY27QH.collectNamespaces)(f.ast, state);
|
|
4551
4592
|
});
|
|
4552
4593
|
delete state.pre;
|
|
4553
4594
|
}
|
|
@@ -4556,7 +4597,7 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
4556
4597
|
async function generateApiMirTests(options) {
|
|
4557
4598
|
const config = { ...defaultConfig, ...options || {} };
|
|
4558
4599
|
const tests = [];
|
|
4559
|
-
const api = await (0,
|
|
4600
|
+
const api = await (0, import_chunk_YCLY27QH.getApiMapping)();
|
|
4560
4601
|
if (!api) {
|
|
4561
4602
|
throw new Error("Failed to read api.mir");
|
|
4562
4603
|
}
|
|
@@ -4568,12 +4609,12 @@ async function generateApiMirTests(options) {
|
|
|
4568
4609
|
return;
|
|
4569
4610
|
const d = decl[0];
|
|
4570
4611
|
if (d.type === "EnumStringMember" || d.type === "VariableDeclarator" && d.node.kind === "const") {
|
|
4571
|
-
const init = (0,
|
|
4612
|
+
const init = (0, import_chunk_YCLY27QH.isStateNode)(d) ? d.node.init : d.init;
|
|
4572
4613
|
if (!init) {
|
|
4573
4614
|
throw new Error(`Missing init for ${node.fullName}.${key}`);
|
|
4574
4615
|
}
|
|
4575
|
-
tests.push([`${node.fullName}.${key}`, (0,
|
|
4576
|
-
} else if ((0,
|
|
4616
|
+
tests.push([`${node.fullName}.${key}`, (0, import_chunk_YCLY27QH.formatAst)(init)]);
|
|
4617
|
+
} else if ((0, import_chunk_YCLY27QH.isStateNode)(d)) {
|
|
4577
4618
|
findConstants(d);
|
|
4578
4619
|
}
|
|
4579
4620
|
});
|
|
@@ -4600,20 +4641,21 @@ async function generateApiMirTests(options) {
|
|
|
4600
4641
|
var defaultConfig, configOptionsToCheck;
|
|
4601
4642
|
var init_optimizer = (0, import_chunk_IAUHYWVN.__esm)({
|
|
4602
4643
|
"src/optimizer.ts"() {
|
|
4603
|
-
(0,
|
|
4644
|
+
(0, import_chunk_YCLY27QH.init_api)();
|
|
4604
4645
|
init_build();
|
|
4605
4646
|
init_jungles();
|
|
4606
4647
|
init_launch();
|
|
4607
4648
|
init_manifest();
|
|
4608
|
-
(0,
|
|
4609
|
-
(0,
|
|
4610
|
-
(0,
|
|
4611
|
-
(0,
|
|
4612
|
-
(0,
|
|
4613
|
-
(0,
|
|
4649
|
+
(0, import_chunk_YCLY27QH.init_mc_rewrite)();
|
|
4650
|
+
(0, import_chunk_YCLY27QH.init_sdk_util)();
|
|
4651
|
+
(0, import_chunk_YCLY27QH.init_type_flow)();
|
|
4652
|
+
(0, import_chunk_YCLY27QH.init_could_be)();
|
|
4653
|
+
(0, import_chunk_YCLY27QH.init_interp)();
|
|
4654
|
+
(0, import_chunk_YCLY27QH.init_sub_type)();
|
|
4614
4655
|
(0, import_chunk_IAUHYWVN.init_util)();
|
|
4615
|
-
(
|
|
4616
|
-
(0,
|
|
4656
|
+
init_worker_pool();
|
|
4657
|
+
(0, import_chunk_YCLY27QH.init_optimizer_types)();
|
|
4658
|
+
(0, import_chunk_YCLY27QH.init_types)();
|
|
4617
4659
|
defaultConfig = {
|
|
4618
4660
|
outputPath: "bin/optimized",
|
|
4619
4661
|
workspace: "./"
|
|
@@ -4642,19 +4684,175 @@ var init_optimizer = (0, import_chunk_IAUHYWVN.__esm)({
|
|
|
4642
4684
|
];
|
|
4643
4685
|
}
|
|
4644
4686
|
});
|
|
4687
|
+
async function performTask(task) {
|
|
4688
|
+
const type = task.type;
|
|
4689
|
+
const handler = Object.prototype.hasOwnProperty.call(workerTaskHandlers, type) && workerTaskHandlers[type];
|
|
4690
|
+
if (!handler) {
|
|
4691
|
+
throw new Error(`Invalid task type ${type}`);
|
|
4692
|
+
}
|
|
4693
|
+
return handler(task.data);
|
|
4694
|
+
}
|
|
4695
|
+
var workerTaskHandlers;
|
|
4696
|
+
var init_worker_task = (0, import_chunk_IAUHYWVN.__esm)({
|
|
4697
|
+
"src/worker-task.ts"() {
|
|
4698
|
+
"use strict";
|
|
4699
|
+
init_optimizer();
|
|
4700
|
+
(0, import_chunk_YCLY27QH.init_sdk_util)();
|
|
4701
|
+
workerTaskHandlers = {
|
|
4702
|
+
buildOptimizedProject(data) {
|
|
4703
|
+
return buildOptimizedProject(data.product, data.options);
|
|
4704
|
+
},
|
|
4705
|
+
generateOptimizedProject(data) {
|
|
4706
|
+
return generateOptimizedProject(data.options);
|
|
4707
|
+
},
|
|
4708
|
+
generateOneConfig(data) {
|
|
4709
|
+
if (data.buildConfig.resourceMap) {
|
|
4710
|
+
Object.values(data.buildConfig.resourceMap).forEach(
|
|
4711
|
+
(doc) => Object.setPrototypeOf(doc, import_chunk_YCLY27QH.xml_util_exports.Document.prototype)
|
|
4712
|
+
);
|
|
4713
|
+
}
|
|
4714
|
+
if (data.manifestXML) {
|
|
4715
|
+
Object.setPrototypeOf(data.manifestXML, import_chunk_YCLY27QH.xml_util_exports.Document.prototype);
|
|
4716
|
+
}
|
|
4717
|
+
return generateOneConfig(
|
|
4718
|
+
data.buildConfig,
|
|
4719
|
+
data.manifestXML,
|
|
4720
|
+
data.dependencyFiles,
|
|
4721
|
+
data.config
|
|
4722
|
+
);
|
|
4723
|
+
}
|
|
4724
|
+
};
|
|
4725
|
+
}
|
|
4726
|
+
});
|
|
4727
|
+
function startPool(parallelism) {
|
|
4728
|
+
if (pool)
|
|
4729
|
+
return false;
|
|
4730
|
+
if (!parallelism) {
|
|
4731
|
+
parallelism = os.cpus().length;
|
|
4732
|
+
parallelism = os.cpus().length / (parallelism > 4 ? 4 : 2);
|
|
4733
|
+
}
|
|
4734
|
+
const workers = Math.ceil(parallelism);
|
|
4735
|
+
if (workers > 1) {
|
|
4736
|
+
pool = new WorkerPool(workers);
|
|
4737
|
+
}
|
|
4738
|
+
return true;
|
|
4739
|
+
}
|
|
4740
|
+
function stopPool() {
|
|
4741
|
+
if (pool) {
|
|
4742
|
+
pool.close();
|
|
4743
|
+
pool = null;
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
function runTaskInPool(task) {
|
|
4747
|
+
const p = pool;
|
|
4748
|
+
if (p) {
|
|
4749
|
+
return new Promise(
|
|
4750
|
+
(resolve5, reject) => p.runTask(task, (err, result) => {
|
|
4751
|
+
if (err)
|
|
4752
|
+
reject(err);
|
|
4753
|
+
else
|
|
4754
|
+
resolve5(result);
|
|
4755
|
+
})
|
|
4756
|
+
);
|
|
4757
|
+
}
|
|
4758
|
+
return performTask(task);
|
|
4759
|
+
}
|
|
4760
|
+
var kTaskInfo, kWorkerFreedEvent, WorkerPoolTaskInfo, WorkerPool, pool;
|
|
4761
|
+
var init_worker_pool = (0, import_chunk_IAUHYWVN.__esm)({
|
|
4762
|
+
"src/worker-pool.ts"() {
|
|
4763
|
+
init_worker_task();
|
|
4764
|
+
kTaskInfo = Symbol("kTaskInfo");
|
|
4765
|
+
kWorkerFreedEvent = Symbol("kWorkerFreedEvent");
|
|
4766
|
+
WorkerPoolTaskInfo = class extends import_node_async_hooks.AsyncResource {
|
|
4767
|
+
constructor(callback) {
|
|
4768
|
+
super("WorkerPoolTaskInfo");
|
|
4769
|
+
this.callback = callback;
|
|
4770
|
+
}
|
|
4771
|
+
done(err, result) {
|
|
4772
|
+
this.runInAsyncScope(this.callback, null, err, result);
|
|
4773
|
+
this.emitDestroy();
|
|
4774
|
+
}
|
|
4775
|
+
};
|
|
4776
|
+
WorkerPool = class extends import_node_events.EventEmitter {
|
|
4777
|
+
constructor(numThreads) {
|
|
4778
|
+
super();
|
|
4779
|
+
this.numThreads = numThreads;
|
|
4780
|
+
this.numThreads = numThreads;
|
|
4781
|
+
this.workers = [];
|
|
4782
|
+
this.freeWorkers = [];
|
|
4783
|
+
this.tasks = [];
|
|
4784
|
+
for (let i = 0; i < numThreads; i++)
|
|
4785
|
+
this.addNewWorker();
|
|
4786
|
+
this.on(kWorkerFreedEvent, () => {
|
|
4787
|
+
if (this.tasks.length > 0) {
|
|
4788
|
+
const { task, callback } = this.tasks.shift();
|
|
4789
|
+
this.runTask(task, callback);
|
|
4790
|
+
}
|
|
4791
|
+
});
|
|
4792
|
+
}
|
|
4793
|
+
workers;
|
|
4794
|
+
freeWorkers;
|
|
4795
|
+
tasks;
|
|
4796
|
+
addNewWorker() {
|
|
4797
|
+
const worker = new import_node_worker_threads.Worker(
|
|
4798
|
+
//new URL("worker-thread.cjs", import.meta.url)
|
|
4799
|
+
`${__dirname}/worker-thread.cjs`
|
|
4800
|
+
);
|
|
4801
|
+
worker.on("message", (result) => {
|
|
4802
|
+
worker[kTaskInfo].done(null, result);
|
|
4803
|
+
worker[kTaskInfo] = null;
|
|
4804
|
+
this.freeWorkers.push(worker);
|
|
4805
|
+
this.emit(kWorkerFreedEvent);
|
|
4806
|
+
});
|
|
4807
|
+
worker.on("error", (err) => {
|
|
4808
|
+
if (worker[kTaskInfo])
|
|
4809
|
+
worker[kTaskInfo].done(err, null);
|
|
4810
|
+
else
|
|
4811
|
+
this.emit("error", err);
|
|
4812
|
+
this.workers.splice(this.workers.indexOf(worker), 1);
|
|
4813
|
+
this.addNewWorker();
|
|
4814
|
+
});
|
|
4815
|
+
this.workers.push(worker);
|
|
4816
|
+
this.freeWorkers.push(worker);
|
|
4817
|
+
this.emit(kWorkerFreedEvent);
|
|
4818
|
+
}
|
|
4819
|
+
runTask(task, callback) {
|
|
4820
|
+
const worker = this.freeWorkers.pop();
|
|
4821
|
+
if (!worker) {
|
|
4822
|
+
this.tasks.push({ task, callback });
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4825
|
+
worker[kTaskInfo] = new WorkerPoolTaskInfo(callback);
|
|
4826
|
+
worker.postMessage(task);
|
|
4827
|
+
}
|
|
4828
|
+
close() {
|
|
4829
|
+
for (const worker of this.workers)
|
|
4830
|
+
worker.terminate();
|
|
4831
|
+
}
|
|
4832
|
+
};
|
|
4833
|
+
pool = null;
|
|
4834
|
+
}
|
|
4835
|
+
});
|
|
4645
4836
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4646
4837
|
0 && (module.exports = {
|
|
4647
4838
|
buildOptimizedProject,
|
|
4648
4839
|
defaultConfig,
|
|
4649
4840
|
generateApiMirTests,
|
|
4841
|
+
generateOneConfig,
|
|
4650
4842
|
generateOptimizedProject,
|
|
4651
4843
|
getConfig,
|
|
4652
4844
|
getProjectAnalysis,
|
|
4653
4845
|
get_jungle,
|
|
4654
4846
|
init_optimizer,
|
|
4847
|
+
init_worker_pool,
|
|
4848
|
+
init_worker_task,
|
|
4655
4849
|
isErrorWithLocation,
|
|
4656
4850
|
launchSimulator,
|
|
4657
4851
|
manifestProducts,
|
|
4658
4852
|
mctree,
|
|
4659
|
-
|
|
4853
|
+
performTask,
|
|
4854
|
+
runTaskInPool,
|
|
4855
|
+
simulateProgram,
|
|
4856
|
+
startPool,
|
|
4857
|
+
stopPool
|
|
4660
4858
|
});
|