@cocos/ccbuild 2.0.3-alpha.2 → 2.0.3-alpha.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.
Files changed (27) hide show
  1. package/CHANGELOG.md +212 -0
  2. package/README.md +16 -37
  3. package/modules/build-engine/lib/engine-js/index.d.ts.map +1 -1
  4. package/modules/build-engine/lib/engine-js/index.js +4 -1
  5. package/modules/build-engine/lib/engine-js/index.js.map +1 -1
  6. package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.d.ts +33 -33
  7. package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.d.ts.map +1 -1
  8. package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.js +72 -43
  9. package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.js.map +1 -1
  10. package/modules/build-engine/lib/engine-ts/engine-builder.d.ts.map +1 -1
  11. package/modules/build-engine/lib/engine-ts/engine-builder.js +3 -1
  12. package/modules/build-engine/lib/engine-ts/engine-builder.js.map +1 -1
  13. package/modules/build-engine/lib/engine-ts/plugins/external-wasm-loader.js +1 -1
  14. package/modules/build-engine/lib/engine-ts/plugins/external-wasm-loader.js.map +1 -1
  15. package/modules/build-engine/lib/engine-ts/plugins/interface.d.ts +14 -14
  16. package/modules/build-engine/lib/index.d.ts +88 -86
  17. package/modules/build-engine/lib/index.d.ts.map +1 -1
  18. package/modules/build-engine/lib/index.js +53 -38
  19. package/modules/build-engine/lib/index.js.map +1 -1
  20. package/modules/stats-query/lib/config-interface.d.ts +61 -61
  21. package/modules/stats-query/lib/index.d.ts +54 -54
  22. package/modules/stats-query/lib/index.js +38 -38
  23. package/package.json +16 -13
  24. package/static/helper-dynamic-constants.txt +13 -13
  25. package/static/helper-file-decorator.ts +20 -20
  26. package/static/helper-global-exporter.txt +8 -8
  27. package/static/lib.dom.d.ts +2330 -2330
@@ -1,11 +1,11 @@
1
1
  export interface Config {
2
- /**
3
- * Engine features. Keys are feature IDs.
2
+ /**
3
+ * Engine features. Keys are feature IDs.
4
4
  */
5
5
  features: Record<string, Feature>;
6
- /**
7
- * Describe how to generate the index module `'cc'`.
8
- * Currently not used.
6
+ /**
7
+ * Describe how to generate the index module `'cc'`.
8
+ * Currently not used.
9
9
  */
10
10
  index?: IndexConfig;
11
11
  moduleOverrides?: Array<{
@@ -13,58 +13,58 @@ export interface Config {
13
13
  overrides: Record<string, string>;
14
14
  isVirtualModule: boolean;
15
15
  }>;
16
- /**
17
- * Included files for quick-compiler.
16
+ /**
17
+ * Included files for quick-compiler.
18
18
  */
19
19
  includes: Array<string>;
20
- /**
21
- * The constants config for engine and user.
20
+ /**
21
+ * The constants config for engine and user.
22
22
  */
23
23
  constants: IConstantConfig;
24
- /**
25
- * The decorators to be optimize when build engine.
24
+ /**
25
+ * The decorators to be optimize when build engine.
26
26
  */
27
27
  optimizeDecorators: IOptimizeDecorators;
28
28
  }
29
29
  export interface IndexConfig {
30
30
  modules?: Record<string, {
31
- /**
32
- * If specified, export contents of the module into a namespace specified by `ns`
33
- * and then export that namespace into `'cc'`.
34
- * If not specified, contents of the module will be directly exported into `'cc'`.
31
+ /**
32
+ * If specified, export contents of the module into a namespace specified by `ns`
33
+ * and then export that namespace into `'cc'`.
34
+ * If not specified, contents of the module will be directly exported into `'cc'`.
35
35
  */
36
36
  ns?: string;
37
- /**
38
- * If `true`, accesses the exports of this module from `'cc'` will be marked as deprecated.
37
+ /**
38
+ * If `true`, accesses the exports of this module from `'cc'` will be marked as deprecated.
39
39
  */
40
40
  deprecated?: boolean;
41
41
  }>;
42
42
  }
43
43
  export type Test = string;
44
- /**
45
- * An engine feature.
44
+ /**
45
+ * An engine feature.
46
46
  */
47
47
  export interface Feature {
48
- /**
49
- * Modules to be included in this feature in their IDs.
50
- * The ID of a module is its relative path(no extension) under /exports/.
48
+ /**
49
+ * Modules to be included in this feature in their IDs.
50
+ * The ID of a module is its relative path(no extension) under /exports/.
51
51
  */
52
52
  modules: string[];
53
- /**
54
- * Flags to set when this feature is enabled.
53
+ /**
54
+ * Flags to set when this feature is enabled.
55
55
  */
56
56
  intrinsicFlags?: Record<string, unknown>;
57
- /**
58
- * List of uuid that the feature depend on.
57
+ /**
58
+ * List of uuid that the feature depend on.
59
59
  */
60
60
  dependentAssets?: string[];
61
- /**
62
- * List of module that the feature depend on.
61
+ /**
62
+ * List of module that the feature depend on.
63
63
  */
64
64
  dependentModules?: string[];
65
- /**
66
- * Whether it is a native only feature, default is false.
67
- * @default false
65
+ /**
66
+ * Whether it is a native only feature, default is false.
67
+ * @default false
68
68
  */
69
69
  isNativeOnly?: boolean;
70
70
  }
@@ -75,42 +75,42 @@ export interface Context {
75
75
  }
76
76
  export type ConstantTypeName = 'boolean' | 'number';
77
77
  export interface IConstantInfo {
78
- /**
79
- * The comment of the constant.
80
- * Which is used to generate the consts.d.ts file.
78
+ /**
79
+ * The comment of the constant.
80
+ * Which is used to generate the consts.d.ts file.
81
81
  */
82
82
  readonly comment: string;
83
- /**
84
- * The type of the constant for generating consts.d.ts file.
83
+ /**
84
+ * The type of the constant for generating consts.d.ts file.
85
85
  */
86
86
  readonly type: ConstantTypeName;
87
- /**
88
- * The default value of the constant.
89
- * It can be a boolean, number or string.
90
- * When it's a string type, the value is the result of eval().
87
+ /**
88
+ * The default value of the constant.
89
+ * It can be a boolean, number or string.
90
+ * When it's a string type, the value is the result of eval().
91
91
  */
92
92
  value: boolean | string | number;
93
- /**
94
- * Whether exported to global as a `CC_XXXX` constant.
95
- * eg. WECHAT is exported to global.CC_WECHAT
96
- * NOTE: this is a feature of compatibility with Cocos 2.x engine.
97
- * Default is false.
98
- *
99
- * @default false
93
+ /**
94
+ * Whether exported to global as a `CC_XXXX` constant.
95
+ * eg. WECHAT is exported to global.CC_WECHAT
96
+ * NOTE: this is a feature of compatibility with Cocos 2.x engine.
97
+ * Default is false.
98
+ *
99
+ * @default false
100
100
  */
101
101
  ccGlobal?: boolean;
102
- /**
103
- * Whether exported to developer.
104
- * If true, it's only exported to engine.
102
+ /**
103
+ * Whether exported to developer.
104
+ * If true, it's only exported to engine.
105
105
  */
106
106
  readonly internal: boolean;
107
- /**
108
- * Some constant can't specify the value in the Editor, Preview or Test environment,
109
- * so we need to dynamically judge them in runtime.
110
- * These values are specified in a helper called `helper-dynamic-constants.ts`.
111
- * Default is false.
112
- *
113
- * @default false
107
+ /**
108
+ * Some constant can't specify the value in the Editor, Preview or Test environment,
109
+ * so we need to dynamically judge them in runtime.
110
+ * These values are specified in a helper called `helper-dynamic-constants.ts`.
111
+ * Default is false.
112
+ *
113
+ * @default false
114
114
  */
115
115
  dynamic?: boolean;
116
116
  }
@@ -118,12 +118,12 @@ export interface IConstantConfig {
118
118
  [ConstantName: string]: IConstantInfo;
119
119
  }
120
120
  export interface IOptimizeDecorators {
121
- /**
122
- * The decorators which should be optimized when they only decorate class fields.
121
+ /**
122
+ * The decorators which should be optimized when they only decorate class fields.
123
123
  */
124
124
  fieldDecorators: string[];
125
- /**
126
- * The decorators which should be removed directly when they only work in Cocos Creator editor.
125
+ /**
126
+ * The decorators which should be removed directly when they only work in Cocos Creator editor.
127
127
  */
128
128
  editorDecorators: string[];
129
129
  }
@@ -1,77 +1,77 @@
1
1
  import { Context } from './config-interface';
2
2
  import * as ConfigInterface from './config-interface';
3
3
  export { ConfigInterface };
4
- /**
5
- * Query any any stats of the engine.
4
+ /**
5
+ * Query any any stats of the engine.
6
6
  */
7
7
  export declare class StatsQuery {
8
- /**
9
- * @param engine Path to the engine root.
8
+ /**
9
+ * @param engine Path to the engine root.
10
10
  */
11
11
  static create(engine: string): Promise<StatsQuery>;
12
- /**
13
- * Constant manager for engine and user.
12
+ /**
13
+ * Constant manager for engine and user.
14
14
  */
15
15
  constantManager: StatsQuery.ConstantManager;
16
- /**
17
- * Gets the path to the engine root.
16
+ /**
17
+ * Gets the path to the engine root.
18
18
  */
19
19
  get path(): string;
20
- /**
21
- * Gets the path to tsconfig.
20
+ /**
21
+ * Gets the path to tsconfig.
22
22
  */
23
23
  get tsConfigPath(): string;
24
- /**
25
- * Gets all optimzie decorators
24
+ /**
25
+ * Gets all optimzie decorators
26
26
  */
27
27
  getOptimizeDecorators(): ConfigInterface.IOptimizeDecorators;
28
- /**
29
- * Gets all features defined.
28
+ /**
29
+ * Gets all features defined.
30
30
  */
31
31
  getFeatures(): string[];
32
- /**
33
- * Returns if the specified feature is defined.
34
- * @param feature Feature ID.
32
+ /**
33
+ * Returns if the specified feature is defined.
34
+ * @param feature Feature ID.
35
35
  */
36
36
  hasFeature(feature: string): boolean;
37
- /**
38
- * Gets all feature units included in specified features.
39
- * @param featureIds Feature ID.
37
+ /**
38
+ * Gets all feature units included in specified features.
39
+ * @param featureIds Feature ID.
40
40
  */
41
41
  getUnitsOfFeatures(featureIds: string[]): string[];
42
42
  getIntrinsicFlagsOfFeatures(featureIds: string[]): Record<string, string | number | boolean>;
43
- /**
44
- * Gets all feature units in their names.
43
+ /**
44
+ * Gets all feature units in their names.
45
45
  */
46
46
  getFeatureUnits(): string[];
47
- /**
48
- * Gets the path to source file of the feature unit.
49
- * @param moduleId Name of the feature unit.
47
+ /**
48
+ * Gets the path to source file of the feature unit.
49
+ * @param moduleId Name of the feature unit.
50
50
  */
51
51
  getFeatureUnitFile(featureUnit: string): string;
52
- /**
53
- * Gets all editor public modules in their names.
52
+ /**
53
+ * Gets all editor public modules in their names.
54
54
  */
55
55
  getEditorPublicModules(): string[];
56
- /**
57
- * Gets the path to source file of the editor-public module.
58
- * @param moduleName Name of the public module.
56
+ /**
57
+ * Gets the path to source file of the editor-public module.
58
+ * @param moduleName Name of the public module.
59
59
  */
60
60
  getEditorPublicModuleFile(moduleName: string): string;
61
- /**
62
- * Gets the source of `'cc'`.
63
- * @param featureUnits Involved feature units.
64
- * @param mapper If exists, map the feature unit name into another module request.
61
+ /**
62
+ * Gets the source of `'cc'`.
63
+ * @param featureUnits Involved feature units.
64
+ * @param mapper If exists, map the feature unit name into another module request.
65
65
  */
66
66
  evaluateIndexModuleSource(featureUnits: string[], mapper?: (featureUnit: string) => string): string;
67
- /**
68
- * Evaluates the source of `'internal-constants'`(`'cc/env'`),
69
- * @param context
67
+ /**
68
+ * Evaluates the source of `'internal-constants'`(`'cc/env'`),
69
+ * @param context
70
70
  */
71
71
  evaluateEnvModuleSourceFromRecord(record: Record<string, unknown>): string;
72
- /**
73
- * Evaluates module overrides under specified context.
74
- * @param context
72
+ /**
73
+ * Evaluates module overrides under specified context.
74
+ * @param context
75
75
  */
76
76
  evaluateModuleOverrides(context: Context): Record<string, string>;
77
77
  private static _readModulesInDir;
@@ -113,24 +113,24 @@ export declare namespace StatsQuery {
113
113
  WEBGPU: boolean;
114
114
  WASM_SUPPORT_MODE: number;
115
115
  FORCE_BANNING_BULLET_WASM: boolean;
116
- /**
117
- * Whether cull the asm.js module.
118
- * If this is true, the external modules ending with '.asm.js' or 'js.mem' will be culled.
119
- *
120
- * @default false
116
+ /**
117
+ * Whether cull the asm.js module.
118
+ * If this is true, the external modules ending with '.asm.js' or 'js.mem' will be culled.
119
+ *
120
+ * @default false
121
121
  */
122
122
  CULL_ASM_JS_MODULE: boolean;
123
- /**
124
- * An internal constant to indicate whether need a fallback of wasm.
125
- * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.
126
- * This is useful when we use wasm on different version of Safari browsers.
127
- *
128
- * @default false
123
+ /**
124
+ * An internal constant to indicate whether need a fallback of wasm.
125
+ * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.
126
+ * This is useful when we use wasm on different version of Safari browsers.
127
+ *
128
+ * @default false
129
129
  */
130
130
  WASM_FALLBACK: boolean;
131
- /**
132
- * An internal constant to indicate whether we use wasm assets as minigame subpackage.
133
- * This is useful when we need to reduce code size.
131
+ /**
132
+ * An internal constant to indicate whether we use wasm assets as minigame subpackage.
133
+ * This is useful when we need to reduce code size.
134
134
  */
135
135
  WASM_SUBPACKAGE: boolean;
136
136
  }
@@ -73,12 +73,12 @@ const json5_1 = __importDefault(require("json5"));
73
73
  const dedent_1 = __importDefault(require("dedent"));
74
74
  const ConfigInterface = __importStar(require("./config-interface"));
75
75
  exports.ConfigInterface = ConfigInterface;
76
- /**
77
- * Query any any stats of the engine.
76
+ /**
77
+ * Query any any stats of the engine.
78
78
  */
79
79
  class StatsQuery {
80
- /**
81
- * @param engine Path to the engine root.
80
+ /**
81
+ * @param engine Path to the engine root.
82
82
  */
83
83
  static create(engine) {
84
84
  return __awaiter(this, void 0, void 0, function* () {
@@ -91,33 +91,33 @@ class StatsQuery {
91
91
  return query;
92
92
  });
93
93
  }
94
- /**
95
- * Gets the path to the engine root.
94
+ /**
95
+ * Gets the path to the engine root.
96
96
  */
97
97
  get path() {
98
98
  return this._engine;
99
99
  }
100
- /**
101
- * Gets the path to tsconfig.
100
+ /**
101
+ * Gets the path to tsconfig.
102
102
  */
103
103
  get tsConfigPath() {
104
104
  return path_1.default.join(this._engine, 'tsconfig.json');
105
105
  }
106
- /**
107
- * Gets all optimzie decorators
106
+ /**
107
+ * Gets all optimzie decorators
108
108
  */
109
109
  getOptimizeDecorators() {
110
110
  return this._config.optimizeDecorators;
111
111
  }
112
- /**
113
- * Gets all features defined.
112
+ /**
113
+ * Gets all features defined.
114
114
  */
115
115
  getFeatures() {
116
116
  return Object.keys(this._features);
117
117
  }
118
- /**
119
- * Returns if the specified feature is defined.
120
- * @param feature Feature ID.
118
+ /**
119
+ * Returns if the specified feature is defined.
120
+ * @param feature Feature ID.
121
121
  */
122
122
  hasFeature(feature) {
123
123
  return !!this._features[feature];
@@ -126,9 +126,9 @@ class StatsQuery {
126
126
  // public isNativeOnlyFeature (feature: string) {
127
127
  // return !!this._features[feature].isNativeOnly;
128
128
  // }
129
- /**
130
- * Gets all feature units included in specified features.
131
- * @param featureIds Feature ID.
129
+ /**
130
+ * Gets all feature units included in specified features.
131
+ * @param featureIds Feature ID.
132
132
  */
133
133
  getUnitsOfFeatures(featureIds) {
134
134
  var _a;
@@ -149,36 +149,36 @@ class StatsQuery {
149
149
  }
150
150
  return flags;
151
151
  }
152
- /**
153
- * Gets all feature units in their names.
152
+ /**
153
+ * Gets all feature units in their names.
154
154
  */
155
155
  getFeatureUnits() {
156
156
  return Object.keys(this._featureUnits);
157
157
  }
158
- /**
159
- * Gets the path to source file of the feature unit.
160
- * @param moduleId Name of the feature unit.
158
+ /**
159
+ * Gets the path to source file of the feature unit.
160
+ * @param moduleId Name of the feature unit.
161
161
  */
162
162
  getFeatureUnitFile(featureUnit) {
163
163
  return this._featureUnits[featureUnit];
164
164
  }
165
- /**
166
- * Gets all editor public modules in their names.
165
+ /**
166
+ * Gets all editor public modules in their names.
167
167
  */
168
168
  getEditorPublicModules() {
169
169
  return Object.keys(this._editorPublicModules);
170
170
  }
171
- /**
172
- * Gets the path to source file of the editor-public module.
173
- * @param moduleName Name of the public module.
171
+ /**
172
+ * Gets the path to source file of the editor-public module.
173
+ * @param moduleName Name of the public module.
174
174
  */
175
175
  getEditorPublicModuleFile(moduleName) {
176
176
  return this._editorPublicModules[moduleName];
177
177
  }
178
- /**
179
- * Gets the source of `'cc'`.
180
- * @param featureUnits Involved feature units.
181
- * @param mapper If exists, map the feature unit name into another module request.
178
+ /**
179
+ * Gets the source of `'cc'`.
180
+ * @param featureUnits Involved feature units.
181
+ * @param mapper If exists, map the feature unit name into another module request.
182
182
  */
183
183
  evaluateIndexModuleSource(featureUnits, mapper) {
184
184
  return featureUnits.map(featureUnit => {
@@ -194,16 +194,16 @@ class StatsQuery {
194
194
  return `export * from '${(_b = mapper === null || mapper === void 0 ? void 0 : mapper(featureUnit)) !== null && _b !== void 0 ? _b : featureUnit}';`;
195
195
  }).join('\n');
196
196
  }
197
- /**
198
- * Evaluates the source of `'internal-constants'`(`'cc/env'`),
199
- * @param context
197
+ /**
198
+ * Evaluates the source of `'internal-constants'`(`'cc/env'`),
199
+ * @param context
200
200
  */
201
201
  evaluateEnvModuleSourceFromRecord(record) {
202
202
  return Object.entries(record).map(([k, v]) => `export const ${k} = ${v};`).join('\n');
203
203
  }
204
- /**
205
- * Evaluates module overrides under specified context.
206
- * @param context
204
+ /**
205
+ * Evaluates module overrides under specified context.
206
+ * @param context
207
207
  */
208
208
  evaluateModuleOverrides(context) {
209
209
  var _a;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@cocos/ccbuild",
3
- "version": "2.0.3-alpha.2",
3
+ "version": "2.0.3-alpha.4",
4
4
  "description": "The next generation of build tool for Cocos engine.",
5
5
  "main": "./lib/src/index.js",
6
6
  "types": "./lib/src/index.d.ts",
7
7
  "files": [
8
- "lib/src**/*",
8
+ "lib/src/**/*",
9
9
  "static/**/*",
10
10
  "CHANGELOG.md",
11
11
  "README.md",
@@ -21,9 +21,13 @@
21
21
  "build",
22
22
  "compile"
23
23
  ],
24
+ "workspaces": [
25
+ "./modules/*"
26
+ ],
24
27
  "author": "PP_Pro",
25
28
  "license": "MIT",
26
29
  "dependencies": {
30
+ "@types/resolve": "^1.20.2",
27
31
  "@typescript-eslint/eslint-plugin": "^5.52.0",
28
32
  "@typescript-eslint/parser": "^5.52.0",
29
33
  "dedent": "^0.7.0",
@@ -34,11 +38,18 @@
34
38
  "json5": "^2.2.3",
35
39
  "resolve": "^1.22.1",
36
40
  "typescript": "^4.3.5",
41
+ "semver": "~7.5.3",
42
+ "rollup": "^2.79.1",
43
+ "@rollup/plugin-babel": "^6.0.3",
44
+ "@rollup/plugin-commonjs": "^11.1.0",
45
+ "@rollup/plugin-json": "^4.1.0",
46
+ "@rollup/plugin-node-resolve": "^7.1.3",
47
+ "@rollup/plugin-virtual": "^3.0.1",
48
+ "@rollup/plugin-typescript": "~11.1.2",
49
+ "rollup-plugin-terser": "^7.0.2",
37
50
  "path": "~0.12.7",
38
51
  "commander": "~11.0.0",
39
52
  "ejs": "~3.1.9",
40
- "@types/resolve": "^1.20.2",
41
- "semver": "~7.5.3",
42
53
  "@babel/core": "^7.20.12",
43
54
  "@babel/parser": "^7.20.13",
44
55
  "@babel/plugin-syntax-decorators": "^7.19.0",
@@ -49,15 +60,7 @@
49
60
  "@cocos/babel-plugin-dynamic-import-vars": "^1.0.2",
50
61
  "@cocos/creator-programming-babel-preset-cc": "1.0.1-alpha.4",
51
62
  "@babel/plugin-transform-modules-systemjs": "~7.22.5",
52
- "@babel/helper-module-imports": "7.18.6",
53
- "rollup": "^2.79.1",
54
- "@rollup/plugin-babel": "^6.0.3",
55
- "@rollup/plugin-commonjs": "^11.1.0",
56
- "@rollup/plugin-json": "^4.1.0",
57
- "@rollup/plugin-node-resolve": "^7.1.3",
58
- "@rollup/plugin-virtual": "^3.0.1",
59
- "@rollup/plugin-typescript": "~11.1.2",
60
- "rollup-plugin-terser": "^7.0.2"
63
+ "@babel/helper-module-imports": "7.18.6"
61
64
  },
62
65
  "exports": {
63
66
  ".": {
@@ -1,13 +1,13 @@
1
- function defined (name) {
2
- const _global = typeof window === 'undefined' ? global : window;
3
- return typeof _global[name] === 'object';
4
- }
5
-
6
- export const TEST = tryDefineGlobal('CC_TEST', defined('tap') || defined('QUnit'));
7
- export const EDITOR = tryDefineGlobal('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
8
- export const PREVIEW = tryDefineGlobal('CC_PREVIEW', !EDITOR);
9
- export const JSB = tryDefineGlobal('CC_JSB', defined('jsb'));
10
- export const NATIVE = JSB;
11
- export const HTML5 = !(EDITOR && NATIVE);
12
- export const DEV = tryDefineGlobal('CC_DEV', true);
13
- export const EDITOR_NOT_IN_PREVIEW = EDITOR && !tryDefineGlobal('isPreviewProcess',false);
1
+ function defined (name) {
2
+ const _global = typeof window === 'undefined' ? global : window;
3
+ return typeof _global[name] === 'object';
4
+ }
5
+
6
+ export const TEST = tryDefineGlobal('CC_TEST', defined('tap') || defined('QUnit'));
7
+ export const EDITOR = tryDefineGlobal('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
8
+ export const PREVIEW = tryDefineGlobal('CC_PREVIEW', !EDITOR);
9
+ export const JSB = tryDefineGlobal('CC_JSB', defined('jsb'));
10
+ export const NATIVE = JSB;
11
+ export const HTML5 = !(EDITOR && NATIVE);
12
+ export const DEV = tryDefineGlobal('CC_DEV', true);
13
+ export const EDITOR_NOT_IN_PREVIEW = EDITOR && !tryDefineGlobal('isPreviewProcess',false);
@@ -1,21 +1,21 @@
1
-
2
- /**
3
- * TsPropertyDecorator cannot access the property descriptor, sometimes we need to access the initializer in property descriptor.
4
- * This helper helps receive the initializer from EngineCompiler, and generate a BabelPropertyDecorator in runtime.
5
- * @param decoratorOrFactory A TsPropertyDecorator or a decorator factory
6
- * @param initializer the property initializer generate from engine compiler
7
- * @param factoryArgs if `decoratorOrFactory` is a factory, then we may need some arguments for this factory method.
8
- * @returns BabelPropertyDecorator
9
- */
10
- export function CCBuildTsFieldDecoratorHelper (decoratorOrFactory: Function, initializer: Function, ...factoryArgs: any[]): PropertyDecorator {
11
- if (factoryArgs.length > 0) {
12
- const decorator = decoratorOrFactory(...factoryArgs);
13
- return (target, propertyKey) => {
14
- decorator(target, propertyKey, initializer);
15
- };
16
- } else {
17
- return (target, propertyKey) => {
18
- decoratorOrFactory(target, propertyKey, initializer);
19
- };
20
- }
1
+
2
+ /**
3
+ * TsPropertyDecorator cannot access the property descriptor, sometimes we need to access the initializer in property descriptor.
4
+ * This helper helps receive the initializer from EngineCompiler, and generate a BabelPropertyDecorator in runtime.
5
+ * @param decoratorOrFactory A TsPropertyDecorator or a decorator factory
6
+ * @param initializer the property initializer generate from engine compiler
7
+ * @param factoryArgs if `decoratorOrFactory` is a factory, then we may need some arguments for this factory method.
8
+ * @returns BabelPropertyDecorator
9
+ */
10
+ export function CCBuildTsFieldDecoratorHelper (decoratorOrFactory: Function, initializer: Function | null, ...factoryArgs: any[]): PropertyDecorator {
11
+ if (factoryArgs.length > 0) {
12
+ const decorator = decoratorOrFactory(...factoryArgs);
13
+ return (target, propertyKey) => {
14
+ decorator(target, propertyKey, initializer);
15
+ };
16
+ } else {
17
+ return (target, propertyKey) => {
18
+ decoratorOrFactory(target, propertyKey, initializer);
19
+ };
20
+ }
21
21
  }
@@ -1,9 +1,9 @@
1
- function tryDefineGlobal (name, value) {
2
- const _global = typeof window === 'undefined' ? global : window;
3
- if (typeof _global[name] === 'undefined') {
4
- return (_global[name] = value);
5
- } else {
6
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
7
- return _global[name];
8
- }
1
+ function tryDefineGlobal (name, value) {
2
+ const _global = typeof window === 'undefined' ? global : window;
3
+ if (typeof _global[name] === 'undefined') {
4
+ return (_global[name] = value);
5
+ } else {
6
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
7
+ return _global[name];
8
+ }
9
9
  }