mbler 0.2.0 → 0.2.2
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/build.d.ts +145 -0
- package/dist/build.esm.js +1312 -0
- package/dist/build.esm.js.map +1 -0
- package/dist/build.js +1339 -0
- package/dist/build.js.map +1 -0
- package/dist/index.d.ts +11 -144
- package/dist/index.esm.js +150 -964
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +148 -965
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as typescript from 'typescript';
|
|
2
|
+
import { watch as watch$1 } from 'chokidar';
|
|
3
|
+
import * as rollup from 'rollup';
|
|
4
|
+
import { LanguagePlugin } from '@volar/language-core';
|
|
5
|
+
|
|
6
|
+
interface MblerConfigScript {
|
|
7
|
+
ui?: boolean;
|
|
8
|
+
lang?: 'ts' | 'mcx' | 'js';
|
|
9
|
+
main: string;
|
|
10
|
+
UseBeta?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface MblerConfigOutdir {
|
|
13
|
+
behavior?: string;
|
|
14
|
+
resources?: string;
|
|
15
|
+
dist: string;
|
|
16
|
+
}
|
|
17
|
+
interface MblerConfigData {
|
|
18
|
+
name: string;
|
|
19
|
+
outdir?: MblerConfigOutdir;
|
|
20
|
+
description: string;
|
|
21
|
+
version: string;
|
|
22
|
+
mcVersion: string | string[];
|
|
23
|
+
script?: MblerConfigScript;
|
|
24
|
+
minify?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface CliParam {
|
|
27
|
+
params: string[];
|
|
28
|
+
opts: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 运行 MCX TypeScript 编译器
|
|
33
|
+
* 为 .mcx 文件提供 TypeScript 类型检查支持
|
|
34
|
+
*/
|
|
35
|
+
declare function runTSC(tscpath?: string): void;
|
|
36
|
+
|
|
37
|
+
declare class Build {
|
|
38
|
+
private baseBuildDir;
|
|
39
|
+
private resolve;
|
|
40
|
+
private isWatch;
|
|
41
|
+
currentConfig: MblerConfigData | null;
|
|
42
|
+
srcDirs: {
|
|
43
|
+
[key in 'behavior' | 'resources']: string;
|
|
44
|
+
} | null;
|
|
45
|
+
outdirs: {
|
|
46
|
+
[key in 'behavior' | 'resources' | 'dist']: string;
|
|
47
|
+
} | null;
|
|
48
|
+
mcxTs: typeof typescript;
|
|
49
|
+
mcxLanguagePluginCreator: ((ts: typeof typescript) => LanguagePlugin<unknown>) | null;
|
|
50
|
+
constructor(opts: Record<string, string>, baseBuildDir: string, resolve: (a: number) => void, isWatch?: boolean);
|
|
51
|
+
/**
|
|
52
|
+
* Start the watch mode.
|
|
53
|
+
* This will perform an initial build (if not already done) and then
|
|
54
|
+
* start filesystem and rollup watchers.
|
|
55
|
+
* Returns the watcher handles once they are created so that callers
|
|
56
|
+
* (for example tests) can clean them up later.
|
|
57
|
+
*/
|
|
58
|
+
watch(): Promise<null | undefined>;
|
|
59
|
+
start(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Handles returned from the currently-active watchers.
|
|
62
|
+
* Set by {@link createWatcher} and exposed via {@link getWatchers}
|
|
63
|
+
* so that external callers can close them when necessary (e.g. tests).
|
|
64
|
+
*/
|
|
65
|
+
private watchers;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the watcher handles if watch mode has been started.
|
|
68
|
+
* Can be safely called even before `watch()` has been invoked.
|
|
69
|
+
*/
|
|
70
|
+
getWatchers(): {
|
|
71
|
+
rollup: rollup.RollupWatcher;
|
|
72
|
+
chokidar: ReturnType<typeof watch$1>;
|
|
73
|
+
} | null;
|
|
74
|
+
/**
|
|
75
|
+
* Close any active watchers. The build process does not automatically
|
|
76
|
+
* terminate the watchers unless the process exits; tests or CLI wrappers
|
|
77
|
+
* can call this method to clean up resources.
|
|
78
|
+
*/
|
|
79
|
+
closeWatchers(): void;
|
|
80
|
+
private rollupPlugin;
|
|
81
|
+
init: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Which modules are present in the current project.
|
|
84
|
+
* - "behavior" when only behavior code exists
|
|
85
|
+
* - "resources" when only resource files exist
|
|
86
|
+
* - "all" when both are present
|
|
87
|
+
* This field is populated during `handlerOtherAddon`.
|
|
88
|
+
*/
|
|
89
|
+
module: 'behavior' | 'resources' | 'all' | null;
|
|
90
|
+
/**
|
|
91
|
+
* Determine whether a path refers to a regular file or a directory.
|
|
92
|
+
* Follows symbolic links recursively. Throws if the path exists but
|
|
93
|
+
* is not one of the expected types.
|
|
94
|
+
*
|
|
95
|
+
* @param filePath file system path to inspect
|
|
96
|
+
* @returns "file" or "directory"
|
|
97
|
+
*/
|
|
98
|
+
private fileType;
|
|
99
|
+
/**
|
|
100
|
+
* Perform a single build of the project located at {@link baseBuildDir}.
|
|
101
|
+
* The process is roughly:
|
|
102
|
+
* 1. load and validate the configuration file
|
|
103
|
+
* 2. prepare source and output directory information
|
|
104
|
+
* 3. copy addon files (behavior/resources)
|
|
105
|
+
* 4. generate manifest.json files
|
|
106
|
+
* 5. run rollup to bundle any script entry point
|
|
107
|
+
*
|
|
108
|
+
* If anything goes wrong the promise returned by the public wrapper
|
|
109
|
+
* (`build()` function exported at the bottom of this file) will be
|
|
110
|
+
* resolved with a non-zero code and appropriate log entries will be
|
|
111
|
+
* emitted.
|
|
112
|
+
*/
|
|
113
|
+
private build;
|
|
114
|
+
/**
|
|
115
|
+
* Create and return a Rollup build instance configured for the
|
|
116
|
+
* project's script. The Rollup configuration mirrors the options
|
|
117
|
+
* used by the CLI when running manual builds.
|
|
118
|
+
*
|
|
119
|
+
* Returns undefined if the project does not define a script section
|
|
120
|
+
* (in which case nothing needs to be bundled).
|
|
121
|
+
*/
|
|
122
|
+
private createRollup;
|
|
123
|
+
/**
|
|
124
|
+
* Internal helper invoked by {@link watch}.
|
|
125
|
+
* Ensures a build has been run before starting the watchers.
|
|
126
|
+
*/
|
|
127
|
+
private _watch;
|
|
128
|
+
private isParent;
|
|
129
|
+
private isChange;
|
|
130
|
+
private createRollupWatcher;
|
|
131
|
+
private onChange;
|
|
132
|
+
private createWatcher;
|
|
133
|
+
private handlerManifest;
|
|
134
|
+
private loadData;
|
|
135
|
+
/**
|
|
136
|
+
* Copy the various files (behavior/resources) into the corresponding
|
|
137
|
+
* output directories and determine which modules exist in the project
|
|
138
|
+
* by inspecting the source directories.
|
|
139
|
+
*/
|
|
140
|
+
private handlerOtherAddon;
|
|
141
|
+
}
|
|
142
|
+
declare function build(cliParam: CliParam, work: string): Promise<number>;
|
|
143
|
+
declare function watch(cliParam: CliParam, work: string): Promise<number>;
|
|
144
|
+
|
|
145
|
+
export { Build, runTSC as McxTsc, build, watch };
|