mbler 0.2.7-rc.2 → 0.2.7-rc.4

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