@markw65/monkeyc-optimizer 1.0.9 → 1.0.12
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 +31 -0
- package/build/api.cjs +1149 -1061
- package/build/optimizer.cjs +4890 -1863
- package/build/sdk-util.cjs +36 -37
- package/build/src/api.d.ts +8 -0
- package/build/src/build.d.ts +6 -0
- package/build/src/estree-types.d.ts +324 -0
- package/build/src/jungles.d.ts +51 -0
- package/build/src/launch.d.ts +2 -0
- package/build/src/manifest.d.ts +71 -0
- package/build/src/mc-rewrite.d.ts +7 -0
- package/build/src/negative-fixups.d.ts +1 -0
- package/build/src/optimizer.d.ts +177 -0
- package/build/src/sdk-util.d.ts +14 -0
- package/build/src/util.d.ts +14 -0
- package/build/util.cjs +121 -109
- package/package.json +11 -3
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { get_jungle, Target, ResolvedJungle } from "./jungles";
|
|
2
|
+
import { launchSimulator, simulateProgram } from "./launch";
|
|
3
|
+
import { copyRecursiveAsNeeded } from "./util";
|
|
4
|
+
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
5
|
+
export { copyRecursiveAsNeeded, launchSimulator, simulateProgram, get_jungle, ResolvedJungle, mctree, };
|
|
6
|
+
export declare const defaultConfig: {
|
|
7
|
+
outputPath: string;
|
|
8
|
+
workspace: string;
|
|
9
|
+
};
|
|
10
|
+
declare global {
|
|
11
|
+
type BuildConfig = {
|
|
12
|
+
workspace?: string;
|
|
13
|
+
jungleFiles?: string;
|
|
14
|
+
developerKeyPath?: string;
|
|
15
|
+
typeCheckLevel?: string;
|
|
16
|
+
compilerOptions?: string;
|
|
17
|
+
compilerWarnings?: boolean;
|
|
18
|
+
simulatorBuild?: boolean;
|
|
19
|
+
releaseBuild?: boolean;
|
|
20
|
+
testBuild?: boolean;
|
|
21
|
+
products?: string[];
|
|
22
|
+
buildDir?: string;
|
|
23
|
+
outputPath?: string;
|
|
24
|
+
program?: string;
|
|
25
|
+
skipOptimization?: boolean;
|
|
26
|
+
checkManifest?: boolean;
|
|
27
|
+
device?: string;
|
|
28
|
+
ignoredExcludeAnnotations?: string;
|
|
29
|
+
ignoredAnnotations?: string;
|
|
30
|
+
ignoredSourcePaths?: string;
|
|
31
|
+
returnCommand?: boolean;
|
|
32
|
+
_cache?: {
|
|
33
|
+
barrels?: Record<string, ResolvedJungle>;
|
|
34
|
+
barrelMap?: Record<string, Record<string, ResolvedJungle>>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type StateNodeDecl = StateNode | mctree.EnumStringMember | mctree.TypedIdentifier | mctree.EnumDeclaration | mctree.TypedefDeclaration | mctree.VariableDeclarator;
|
|
38
|
+
type StateNodeDecls = {
|
|
39
|
+
[key: string]: StateNodeDecl[];
|
|
40
|
+
};
|
|
41
|
+
type ProgramStateNode = {
|
|
42
|
+
type: "Program";
|
|
43
|
+
node: null | undefined;
|
|
44
|
+
name: "$";
|
|
45
|
+
fullName: "$";
|
|
46
|
+
decls?: StateNodeDecls;
|
|
47
|
+
stack?: null | undefined;
|
|
48
|
+
};
|
|
49
|
+
type ModuleStateNode = {
|
|
50
|
+
type: "ModuleDeclaration";
|
|
51
|
+
name: string;
|
|
52
|
+
fullName: string;
|
|
53
|
+
node: mctree.ModuleDeclaration;
|
|
54
|
+
stack?: ProgramStateStack;
|
|
55
|
+
decls?: StateNodeDecls;
|
|
56
|
+
};
|
|
57
|
+
type ClassStateNode = {
|
|
58
|
+
type: "ClassDeclaration";
|
|
59
|
+
name: string;
|
|
60
|
+
fullName: string;
|
|
61
|
+
node: mctree.ClassDeclaration;
|
|
62
|
+
decls?: StateNodeDecls;
|
|
63
|
+
stack?: ProgramStateStack;
|
|
64
|
+
superClass: ClassStateNode[] | true;
|
|
65
|
+
};
|
|
66
|
+
type FunctionStateNode = {
|
|
67
|
+
type: "FunctionDeclaration";
|
|
68
|
+
name: string;
|
|
69
|
+
fullName: string;
|
|
70
|
+
node: mctree.FunctionDeclaration;
|
|
71
|
+
stack?: ProgramStateStack;
|
|
72
|
+
decls?: undefined;
|
|
73
|
+
};
|
|
74
|
+
type BlockStateNode = {
|
|
75
|
+
type: "BlockStatement";
|
|
76
|
+
name?: null | undefined;
|
|
77
|
+
fullName?: null | undefined;
|
|
78
|
+
node: mctree.BlockStatement;
|
|
79
|
+
decls?: StateNodeDecls;
|
|
80
|
+
stack?: null | undefined;
|
|
81
|
+
};
|
|
82
|
+
type StateNode = ProgramStateNode | FunctionStateNode | BlockStateNode | ClassStateNode | ModuleStateNode;
|
|
83
|
+
type ProgramStateStack = StateNode[];
|
|
84
|
+
export type ProgramState = {
|
|
85
|
+
allFunctions?: FunctionStateNode[];
|
|
86
|
+
allClasses?: ClassStateNode[];
|
|
87
|
+
stack?: ProgramStateStack;
|
|
88
|
+
shouldExclude?: (node: any) => any;
|
|
89
|
+
pre?: (node: mctree.Node) => null | false | (keyof mctree.NodeAll)[];
|
|
90
|
+
post?: (node: mctree.Node) => null | false | mctree.Node;
|
|
91
|
+
lookup?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack) => [string, StateNodeDecl[], ProgramStateStack];
|
|
92
|
+
traverse?: (node: mctree.Node) => void | boolean | mctree.Node;
|
|
93
|
+
exposed?: {
|
|
94
|
+
[key: string]: true;
|
|
95
|
+
};
|
|
96
|
+
calledFunctions?: {
|
|
97
|
+
[key: string]: unknown[];
|
|
98
|
+
};
|
|
99
|
+
localsStack?: {
|
|
100
|
+
node?: mctree.Node;
|
|
101
|
+
map?: {
|
|
102
|
+
[key: string]: true | string;
|
|
103
|
+
};
|
|
104
|
+
inners?: {
|
|
105
|
+
[key: string]: true;
|
|
106
|
+
};
|
|
107
|
+
}[];
|
|
108
|
+
index?: {
|
|
109
|
+
[key: string]: unknown[];
|
|
110
|
+
};
|
|
111
|
+
constants?: {
|
|
112
|
+
[key: string]: mctree.Literal;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
type ExcludeAnnotationsMap = {
|
|
116
|
+
[key: string]: boolean;
|
|
117
|
+
};
|
|
118
|
+
type FilesToOptimizeMap = {
|
|
119
|
+
[key: string]: {
|
|
120
|
+
output: string;
|
|
121
|
+
excludeAnnotations: ExcludeAnnotationsMap;
|
|
122
|
+
monkeyCSource?: string;
|
|
123
|
+
ast?: mctree.Program;
|
|
124
|
+
parserError?: Error;
|
|
125
|
+
hasTests?: boolean;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
var lastModifiedSource: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @param {string | null} product
|
|
133
|
+
* @param {BuildConfig} options
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
export declare function buildOptimizedProject(product: string | null, options: BuildConfig): Promise<{
|
|
137
|
+
exe: string;
|
|
138
|
+
args: string[];
|
|
139
|
+
program: string;
|
|
140
|
+
product: string;
|
|
141
|
+
hasTests: boolean;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @param {BuildConfig} options
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
export declare function generateOptimizedProject(options: BuildConfig): Promise<{
|
|
149
|
+
jungleFiles: string;
|
|
150
|
+
program: string;
|
|
151
|
+
hasTests?: undefined;
|
|
152
|
+
} | {
|
|
153
|
+
jungleFiles: string;
|
|
154
|
+
program: string;
|
|
155
|
+
hasTests: boolean;
|
|
156
|
+
}>;
|
|
157
|
+
export declare type PreAnalysis = {
|
|
158
|
+
fnMap: FilesToOptimizeMap;
|
|
159
|
+
paths: string[];
|
|
160
|
+
};
|
|
161
|
+
declare type RequiredNonNull<T> = {
|
|
162
|
+
[K1 in keyof T]-?: {
|
|
163
|
+
[K2 in keyof T[K1]]-?: NonNullable<T[K1][K2]>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export declare type Analysis = {
|
|
167
|
+
fnMap: RequiredNonNull<FilesToOptimizeMap>;
|
|
168
|
+
paths: string[];
|
|
169
|
+
state: ProgramState;
|
|
170
|
+
};
|
|
171
|
+
export declare function getProjectAnalysis(targets: Target[], analysis: PreAnalysis | null, options: BuildConfig): Promise<Analysis | PreAnalysis>;
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @param {BuildConfig} options
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
export declare function generateApiMirTests(options: BuildConfig): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const isWin: boolean;
|
|
2
|
+
export declare const appSupport: string;
|
|
3
|
+
export declare const connectiq: string;
|
|
4
|
+
export declare function getSdkPath(): Promise<string>;
|
|
5
|
+
export declare function getDeviceInfo(): Promise<{
|
|
6
|
+
[key: string]: {
|
|
7
|
+
appTypes: {
|
|
8
|
+
memoryLimit: number;
|
|
9
|
+
type: string;
|
|
10
|
+
}[];
|
|
11
|
+
deviceFamily: string;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
export declare function getLanguages(): Promise<any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function globa(pattern: string, options?: {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
}): Promise<Array<string>>;
|
|
4
|
+
export declare function last_modified(inputs: string[]): Promise<number>;
|
|
5
|
+
export declare function first_modified(inputs: string[]): Promise<number>;
|
|
6
|
+
export declare function pushUnique<T>(arr: T[], value: T): void;
|
|
7
|
+
declare type LineHandler = (line: string) => void;
|
|
8
|
+
export declare function spawnByLine(command: string, args: string[], lineHandlers: LineHandler | LineHandler[], options?: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
export declare function readByLine(file: string, lineHandler: LineHandler): Promise<unknown>;
|
|
12
|
+
export declare function promiseAll<T>(promiseFn: (i: number) => Promise<T>, parallelism: number): Promise<T[]>;
|
|
13
|
+
export declare function copyRecursiveAsNeeded(source: string, target: string, filter?: (src: string, tgt: string) => boolean): Promise<void>;
|
|
14
|
+
export {};
|
package/build/util.cjs
CHANGED
|
@@ -3940,6 +3940,18 @@ module.exports = require("util");
|
|
|
3940
3940
|
/******/ }
|
|
3941
3941
|
/******/
|
|
3942
3942
|
/************************************************************************/
|
|
3943
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
3944
|
+
/******/ (() => {
|
|
3945
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
3946
|
+
/******/ __webpack_require__.n = (module) => {
|
|
3947
|
+
/******/ var getter = module && module.__esModule ?
|
|
3948
|
+
/******/ () => (module['default']) :
|
|
3949
|
+
/******/ () => (module);
|
|
3950
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
3951
|
+
/******/ return getter;
|
|
3952
|
+
/******/ };
|
|
3953
|
+
/******/ })();
|
|
3954
|
+
/******/
|
|
3943
3955
|
/******/ /* webpack/runtime/define property getters */
|
|
3944
3956
|
/******/ (() => {
|
|
3945
3957
|
/******/ // define getter functions for harmony exports
|
|
@@ -3952,6 +3964,18 @@ module.exports = require("util");
|
|
|
3952
3964
|
/******/ };
|
|
3953
3965
|
/******/ })();
|
|
3954
3966
|
/******/
|
|
3967
|
+
/******/ /* webpack/runtime/global */
|
|
3968
|
+
/******/ (() => {
|
|
3969
|
+
/******/ __webpack_require__.g = (function() {
|
|
3970
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
3971
|
+
/******/ try {
|
|
3972
|
+
/******/ return this || new Function('return this')();
|
|
3973
|
+
/******/ } catch (e) {
|
|
3974
|
+
/******/ if (typeof window === 'object') return window;
|
|
3975
|
+
/******/ }
|
|
3976
|
+
/******/ })();
|
|
3977
|
+
/******/ })();
|
|
3978
|
+
/******/
|
|
3955
3979
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
3956
3980
|
/******/ (() => {
|
|
3957
3981
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
@@ -3996,12 +4020,12 @@ var external_fs_ = __webpack_require__(6231);
|
|
|
3996
4020
|
const promises_namespaceObject = require("fs/promises");
|
|
3997
4021
|
// EXTERNAL MODULE: ./node_modules/glob/glob.js
|
|
3998
4022
|
var glob = __webpack_require__(2884);
|
|
4023
|
+
var glob_default = /*#__PURE__*/__webpack_require__.n(glob);
|
|
3999
4024
|
// EXTERNAL MODULE: external "path"
|
|
4000
4025
|
var external_path_ = __webpack_require__(1423);
|
|
4001
4026
|
;// CONCATENATED MODULE: external "readline"
|
|
4002
4027
|
const external_readline_namespaceObject = require("readline");
|
|
4003
|
-
;// CONCATENATED MODULE: ./src/util.
|
|
4004
|
-
|
|
4028
|
+
;// CONCATENATED MODULE: ./src/util.ts
|
|
4005
4029
|
|
|
4006
4030
|
|
|
4007
4031
|
|
|
@@ -4010,144 +4034,132 @@ const external_readline_namespaceObject = require("readline");
|
|
|
4010
4034
|
|
|
4011
4035
|
// Write it this way so that webpack.DefinePlugin doesn't
|
|
4012
4036
|
// recognize global.lastModifiedSource.
|
|
4013
|
-
|
|
4014
|
-
|
|
4037
|
+
// @ts-ignore
|
|
4038
|
+
__webpack_require__.g["lastModifiedSource" + ""] = 0;
|
|
4015
4039
|
function globa(pattern, options) {
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4040
|
+
return new Promise((resolve, reject) => {
|
|
4041
|
+
glob_default().glob(pattern, options, (er, files) => {
|
|
4042
|
+
if (er) {
|
|
4043
|
+
reject(files);
|
|
4044
|
+
}
|
|
4045
|
+
else {
|
|
4046
|
+
resolve(files);
|
|
4047
|
+
}
|
|
4048
|
+
});
|
|
4023
4049
|
});
|
|
4024
|
-
});
|
|
4025
4050
|
}
|
|
4026
|
-
|
|
4027
4051
|
async function modified_times(inputs, missing) {
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
})
|
|
4037
|
-
);
|
|
4052
|
+
return Promise.all(inputs.map(async (path) => {
|
|
4053
|
+
try {
|
|
4054
|
+
const stat = await promises_namespaceObject.stat(path);
|
|
4055
|
+
return stat.mtimeMs;
|
|
4056
|
+
}
|
|
4057
|
+
catch (e) {
|
|
4058
|
+
return missing;
|
|
4059
|
+
}
|
|
4060
|
+
}));
|
|
4038
4061
|
}
|
|
4039
|
-
|
|
4040
4062
|
async function last_modified(inputs) {
|
|
4041
|
-
|
|
4063
|
+
return Math.max(...(await modified_times(inputs, Infinity)));
|
|
4042
4064
|
}
|
|
4043
|
-
|
|
4044
4065
|
async function first_modified(inputs) {
|
|
4045
|
-
|
|
4066
|
+
return Math.min(...(await modified_times(inputs, 0)));
|
|
4046
4067
|
}
|
|
4047
|
-
|
|
4048
4068
|
function pushUnique(arr, value) {
|
|
4049
|
-
|
|
4050
|
-
|
|
4069
|
+
if (arr.find((v) => v === value) != null)
|
|
4070
|
+
return;
|
|
4071
|
+
arr.push(value);
|
|
4051
4072
|
}
|
|
4052
|
-
|
|
4053
4073
|
// return a promise that will process the output of command
|
|
4054
4074
|
// line-by-line via lineHandlers.
|
|
4055
4075
|
function spawnByLine(command, args, lineHandlers, options) {
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
+
const [lineHandler, errHandler] = Array.isArray(lineHandlers)
|
|
4077
|
+
? lineHandlers
|
|
4078
|
+
: [lineHandlers, (line) => console.error(line)];
|
|
4079
|
+
return new Promise((resolve, reject) => {
|
|
4080
|
+
const proc = external_child_process_namespaceObject.spawn(command, args, {
|
|
4081
|
+
...(options || {}),
|
|
4082
|
+
shell: false,
|
|
4083
|
+
});
|
|
4084
|
+
const rl = external_readline_namespaceObject.createInterface({
|
|
4085
|
+
input: proc.stdout,
|
|
4086
|
+
});
|
|
4087
|
+
const rle = external_readline_namespaceObject.createInterface({
|
|
4088
|
+
input: proc.stderr,
|
|
4089
|
+
});
|
|
4090
|
+
proc.on("error", reject);
|
|
4091
|
+
rle.on("line", errHandler);
|
|
4092
|
+
rl.on("line", lineHandler);
|
|
4093
|
+
proc.on("close", (code) => {
|
|
4094
|
+
if (code == 0)
|
|
4095
|
+
resolve();
|
|
4096
|
+
reject(code);
|
|
4097
|
+
});
|
|
4076
4098
|
});
|
|
4077
|
-
});
|
|
4078
4099
|
}
|
|
4079
|
-
|
|
4080
4100
|
// return a promise that will process file
|
|
4081
4101
|
// line-by-line via lineHandler.
|
|
4082
4102
|
function readByLine(file, lineHandler) {
|
|
4083
|
-
|
|
4084
|
-
(fh) =>
|
|
4085
|
-
new Promise((resolve, _reject) => {
|
|
4103
|
+
return promises_namespaceObject.open(file, "r").then((fh) => new Promise((resolve, _reject) => {
|
|
4086
4104
|
const stream = fh.createReadStream();
|
|
4087
4105
|
const rl = external_readline_namespaceObject.createInterface({
|
|
4088
|
-
|
|
4106
|
+
input: stream,
|
|
4089
4107
|
});
|
|
4090
4108
|
rl.on("line", lineHandler);
|
|
4091
4109
|
stream.on("close", resolve);
|
|
4092
|
-
|
|
4093
|
-
);
|
|
4110
|
+
}));
|
|
4094
4111
|
}
|
|
4095
|
-
|
|
4096
4112
|
async function promiseAll(promiseFn, parallelism) {
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4113
|
+
parallelism = parallelism || 4;
|
|
4114
|
+
const serializer = [];
|
|
4115
|
+
const results = [];
|
|
4116
|
+
let done = false;
|
|
4117
|
+
let i = 0;
|
|
4118
|
+
const next = () => {
|
|
4119
|
+
const index = i++;
|
|
4120
|
+
if (done)
|
|
4121
|
+
return null;
|
|
4122
|
+
const promise = promiseFn(index);
|
|
4123
|
+
if (!promise) {
|
|
4124
|
+
done = true;
|
|
4125
|
+
return null;
|
|
4126
|
+
}
|
|
4127
|
+
return promise
|
|
4128
|
+
.then((r) => {
|
|
4129
|
+
results[index] = r;
|
|
4130
|
+
})
|
|
4131
|
+
.then(next);
|
|
4132
|
+
};
|
|
4133
|
+
while (i < parallelism) {
|
|
4134
|
+
serializer.push(next());
|
|
4109
4135
|
}
|
|
4110
|
-
return
|
|
4111
|
-
.then((r) => {
|
|
4112
|
-
results[index] = r;
|
|
4113
|
-
})
|
|
4114
|
-
.then(next);
|
|
4115
|
-
};
|
|
4116
|
-
while (i < parallelism) {
|
|
4117
|
-
serializer.push(next());
|
|
4118
|
-
}
|
|
4119
|
-
return Promise.all(serializer).then(() => results);
|
|
4136
|
+
return Promise.all(serializer).then(() => results);
|
|
4120
4137
|
}
|
|
4121
|
-
|
|
4122
4138
|
async function copyRecursiveAsNeeded(source, target, filter) {
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
var tgt = external_path_.join(target, file);
|
|
4138
|
-
return copyRecursiveAsNeeded(src, tgt, filter);
|
|
4139
|
-
})
|
|
4140
|
-
);
|
|
4141
|
-
} else {
|
|
4142
|
-
if (filter && !filter(source, target)) {
|
|
4143
|
-
return;
|
|
4139
|
+
const fstat = promises_namespaceObject.stat;
|
|
4140
|
+
const sstat = await fstat(source);
|
|
4141
|
+
if (sstat.isDirectory()) {
|
|
4142
|
+
const stat = await fstat(target).catch(() => null);
|
|
4143
|
+
if (!stat || !stat.isDirectory()) {
|
|
4144
|
+
stat && (await promises_namespaceObject.rm(target, { force: true }));
|
|
4145
|
+
await promises_namespaceObject.mkdir(target, { recursive: true });
|
|
4146
|
+
}
|
|
4147
|
+
const files = await promises_namespaceObject.readdir(source);
|
|
4148
|
+
return Promise.all(files.map((file) => {
|
|
4149
|
+
var src = external_path_.join(source, file);
|
|
4150
|
+
var tgt = external_path_.join(target, file);
|
|
4151
|
+
return copyRecursiveAsNeeded(src, tgt, filter);
|
|
4152
|
+
})).then(() => { });
|
|
4144
4153
|
}
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4154
|
+
else {
|
|
4155
|
+
if (filter && !filter(source, target)) {
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
const tstat = await fstat(target).catch(() => null);
|
|
4159
|
+
if (!tstat || tstat.mtimeMs < sstat.mtimeMs) {
|
|
4160
|
+
return promises_namespaceObject.copyFile(source, target, external_fs_.constants.COPYFILE_FICLONE);
|
|
4161
|
+
}
|
|
4149
4162
|
}
|
|
4150
|
-
}
|
|
4151
4163
|
}
|
|
4152
4164
|
|
|
4153
4165
|
})();
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markw65/monkeyc-optimizer",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"description": "Source to source optimizer for Garmin Monkey C code",
|
|
6
6
|
"main": "build/optimizer.cjs",
|
|
7
|
+
"types": "build/src/optimizer.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": "./build/optimizer.cjs",
|
|
9
10
|
"./*.js": "./build/*.cjs"
|
|
@@ -20,19 +21,26 @@
|
|
|
20
21
|
"build/optimizer.cjs",
|
|
21
22
|
"build/util.cjs",
|
|
22
23
|
"build/sdk-util.cjs",
|
|
23
|
-
"build/api.cjs"
|
|
24
|
+
"build/api.cjs",
|
|
25
|
+
"build/src/*.d.ts"
|
|
24
26
|
],
|
|
25
27
|
"author": "markw65",
|
|
26
28
|
"license": "MIT",
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@markw65/prettier-plugin-monkeyc": "^1.0.
|
|
30
|
+
"@markw65/prettier-plugin-monkeyc": "^1.0.19"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
33
|
+
"@types/glob": "^7.2.0",
|
|
34
|
+
"@types/prettier": "^2.6.1",
|
|
35
|
+
"@types/xml2js": "^0.4.11",
|
|
31
36
|
"eslint": "^8.12.0",
|
|
37
|
+
"extract-zip": "^2.0.1",
|
|
32
38
|
"glob": "^7.2.0",
|
|
33
39
|
"peggy": "^1.2.0",
|
|
34
40
|
"prettier": "^2.6.2",
|
|
35
41
|
"prettier-plugin-pegjs": "^0.5.0",
|
|
42
|
+
"ts-loader": "^9.3.0",
|
|
43
|
+
"typescript": "^4.6.4",
|
|
36
44
|
"webpack": "^5.72.0",
|
|
37
45
|
"webpack-cli": "^4.9.2",
|
|
38
46
|
"xml2js": "^0.4.23"
|