@dcloudio/uni-cli-shared 3.0.0-alpha-3060720221018007 → 3.0.0-alpha-3060820221027001

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.
@@ -27,3 +27,4 @@ export declare const BASE_COMPONENTS_STYLE_PATH = "@dcloudio/uni-components/styl
27
27
  export declare const COMMON_EXCLUDE: RegExp[];
28
28
  export declare const KNOWN_ASSET_TYPES: string[];
29
29
  export declare const DEFAULT_ASSETS_RE: RegExp;
30
+ export declare const TEXT_STYLE: string[];
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
3
+ exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
4
4
  exports.PUBLIC_DIR = 'static';
5
5
  exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
6
6
  exports.EXTNAME_TS = ['.ts', '.tsx'];
@@ -77,3 +77,4 @@ exports.KNOWN_ASSET_TYPES = [
77
77
  'txt',
78
78
  ];
79
79
  exports.DEFAULT_ASSETS_RE = new RegExp(`\\.(` + exports.KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
80
+ exports.TEXT_STYLE = ['black', 'white'];
package/dist/hbx/env.js CHANGED
@@ -21,7 +21,8 @@ exports.isInHBuilderX = (0, uni_shared_1.once)(() => {
21
21
  return false;
22
22
  });
23
23
  exports.runByHBuilderX = (0, uni_shared_1.once)(() => {
24
- return !!process.env.UNI_HBUILDERX_PLUGINS && !!process.env.RUN_BY_HBUILDERX;
24
+ return (!!process.env.UNI_HBUILDERX_PLUGINS &&
25
+ (!!process.env.RUN_BY_HBUILDERX || !!process.env.HX_Version));
25
26
  });
26
27
  /**
27
28
  * 增加 node_modules
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './env';
5
5
  export * from './hbx';
6
6
  export * from './ssr';
7
7
  export * from './vue';
8
+ export * from './uts';
8
9
  export * from './logs';
9
10
  export * from './i18n';
10
11
  export * from './deps';
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ __exportStar(require("./env"), exports);
22
22
  __exportStar(require("./hbx"), exports);
23
23
  __exportStar(require("./ssr"), exports);
24
24
  __exportStar(require("./vue"), exports);
25
+ __exportStar(require("./uts"), exports);
25
26
  __exportStar(require("./logs"), exports);
26
27
  __exportStar(require("./i18n"), exports);
27
28
  __exportStar(require("./deps"), exports);
@@ -29,8 +29,11 @@ const launchwebview_1 = require("./launchwebview");
29
29
  const checksystemwebview_1 = require("./checksystemwebview");
30
30
  const tabBar_1 = require("./tabBar");
31
31
  const i18n_1 = require("./i18n");
32
+ const theme_1 = require("../../theme");
32
33
  function normalizeAppManifestJson(userManifestJson, pagesJson) {
33
- const manifestJson = (0, merge_1.initRecursiveMerge)((0, statusbar_1.initAppStatusbar)((0, defaultManifestJson_1.initDefaultManifestJson)(), pagesJson), userManifestJson);
34
+ const manifestJson = (0, merge_1.initRecursiveMerge)((0, defaultManifestJson_1.initDefaultManifestJson)(), userManifestJson);
35
+ pagesJson = (0, theme_1.initTheme)(manifestJson, pagesJson);
36
+ (0, statusbar_1.initAppStatusbar)(manifestJson, pagesJson);
34
37
  (0, arguments_1.initArguments)(manifestJson, pagesJson);
35
38
  (0, plus_1.initPlus)(manifestJson, pagesJson);
36
39
  (0, nvue_1.initNVue)(manifestJson, pagesJson);
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initAppStatusbar = void 0;
4
4
  function initAppStatusbar(manifestJson, pagesJson) {
5
5
  var _a;
6
- const { titleColor = '#000', backgroundColor = '#000000' } = ((_a = pagesJson.globalStyle) === null || _a === void 0 ? void 0 : _a.navigationBar) || {};
6
+ const { titleColor = '#000000', backgroundColor = '#000000' } = ((_a = pagesJson.globalStyle) === null || _a === void 0 ? void 0 : _a.navigationBar) || {};
7
7
  manifestJson.plus.statusbar = {
8
8
  immersed: 'supportedDevice',
9
- style: titleColor === '#000' ? 'dark' : 'light',
9
+ style: titleColor === '#000000' ? 'dark' : 'light',
10
10
  background: backgroundColor,
11
11
  };
12
12
  return manifestJson;
@@ -2,19 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initTabBar = void 0;
4
4
  const uni_shared_1 = require("@dcloudio/uni-shared");
5
- const borderStyles = {
6
- black: 'rgba(0,0,0,0.4)',
7
- white: 'rgba(255,255,255,0.4)',
8
- };
9
5
  function initTabBar(entryPagePath, manifestJson, pagesJson) {
10
6
  var _a, _b;
11
7
  if (!((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length)) {
12
8
  return;
13
9
  }
14
10
  const tabBar = JSON.parse(JSON.stringify(pagesJson.tabBar));
15
- if (tabBar.borderStyle in borderStyles) {
16
- tabBar.borderStyle = borderStyles[tabBar.borderStyle];
17
- }
11
+ tabBar.borderStyle = (0, uni_shared_1.normalizeTabBarStyles)(tabBar.borderStyle);
18
12
  if (!tabBar.selectedColor) {
19
13
  tabBar.selectedColor = uni_shared_1.SELECTED_COLOR;
20
14
  }
@@ -10,9 +10,11 @@ const manifest_1 = require("../../manifest");
10
10
  const manifest_2 = require("../manifest");
11
11
  const arguments_1 = require("../manifest/arguments");
12
12
  const splashscreen_1 = require("../manifest/splashscreen");
13
+ const theme_1 = require("../../theme");
13
14
  function normalizeAppUniConfig(pagesJson, manifestJson) {
14
15
  var _a;
15
16
  const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
17
+ const platformConfig = manifestJson[process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM] || {};
16
18
  const config = {
17
19
  pages: [],
18
20
  globalStyle: pagesJson.globalStyle,
@@ -32,6 +34,8 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
32
34
  networkTimeout: (0, manifest_1.normalizeNetworkTimeout)(manifestJson.networkTimeout),
33
35
  tabBar: pagesJson.tabBar,
34
36
  locales: (0, i18n_1.initLocales)(path_1.default.join(process.env.UNI_INPUT_DIR, 'locale')),
37
+ darkmode: platformConfig.darkmode || false,
38
+ themeConfig: (0, theme_1.normalizeThemeConfigOnce)(platformConfig),
35
39
  };
36
40
  // TODO 待支持分包
37
41
  return JSON.stringify(config);
@@ -3,3 +3,4 @@ export * from './app';
3
3
  export * from './json';
4
4
  export * from './pages';
5
5
  export * from './manifest';
6
+ export * from './theme';
@@ -19,3 +19,4 @@ __exportStar(require("./app"), exports);
19
19
  __exportStar(require("./json"), exports);
20
20
  __exportStar(require("./pages"), exports);
21
21
  __exportStar(require("./manifest"), exports);
22
+ __exportStar(require("./theme"), exports);
@@ -12,6 +12,8 @@ const pages_1 = require("../pages");
12
12
  const utils_1 = require("./utils");
13
13
  const utils_2 = require("../../utils");
14
14
  const project_1 = require("./project");
15
+ const manifest_1 = require("../manifest");
16
+ const theme_1 = require("../theme");
15
17
  function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
16
18
  return parsePagesJson(jsonStr, platform, options);
17
19
  }
@@ -37,11 +39,11 @@ exports.mergeMiniProgramAppJson = mergeMiniProgramAppJson;
37
39
  function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
38
40
  subpackages: false,
39
41
  }) {
40
- const appJson = {
42
+ let appJson = {
41
43
  pages: [],
42
44
  };
43
- const pageJsons = {};
44
- const nvuePages = [];
45
+ let pageJsons = {};
46
+ let nvuePages = [];
45
47
  // preprocess
46
48
  const pagesJson = (0, json_1.parseJson)(jsonStr, true);
47
49
  if (!pagesJson) {
@@ -127,6 +129,11 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
127
129
  appJson.darkmode = true;
128
130
  appJson.themeLocation = 'theme.json';
129
131
  }
132
+ else {
133
+ const manifestJson = (0, manifest_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
134
+ appJson = (0, theme_1.initTheme)(manifestJson, appJson);
135
+ pageJsons = (0, theme_1.initTheme)(manifestJson, pageJsons);
136
+ }
130
137
  return {
131
138
  appJson,
132
139
  pageJsons,
@@ -13,6 +13,8 @@ const json_1 = require("./json");
13
13
  const utils_2 = require("../vue/utils");
14
14
  const vite_1 = require("../vite");
15
15
  const constants_1 = require("../constants");
16
+ const theme_1 = require("./theme");
17
+ const manifest_1 = require("./manifest");
16
18
  const pagesCacheSet = new Set();
17
19
  function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
18
20
  if (inputDir && path_1.default.isAbsolute(file)) {
@@ -109,7 +111,9 @@ function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages:
109
111
  // 缓存页面列表
110
112
  pagesCacheSet.clear();
111
113
  pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
112
- return pagesJson;
114
+ return process.env.UNI_PLATFORM === 'app' || !process.env.UNI_INPUT_DIR
115
+ ? pagesJson
116
+ : (0, theme_1.initTheme)((0, manifest_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR), pagesJson);
113
117
  }
114
118
  exports.normalizePagesJson = normalizePagesJson;
115
119
  function validatePages(pagesJson, jsonStr) {
@@ -271,8 +275,13 @@ function normalizeNavigationBar(pageStyle) {
271
275
  delete navigationBar.titleText;
272
276
  }
273
277
  if (!navigationBar.titleColor && (0, shared_1.hasOwn)(navigationBar, 'textStyle')) {
274
- navigationBar.titleColor =
275
- navigationBar.textStyle === 'black' ? '#000000' : '#ffffff';
278
+ const textStyle = navigationBar.textStyle;
279
+ if (constants_1.TEXT_STYLE.includes(textStyle)) {
280
+ navigationBar.titleColor = (0, uni_shared_1.normalizeTitleColor)(textStyle);
281
+ }
282
+ else {
283
+ navigationBar.titleColor = navigationBar.textStyle;
284
+ }
276
285
  delete navigationBar.textStyle;
277
286
  }
278
287
  if (pageStyle.navigationBarShadow &&
@@ -280,8 +289,9 @@ function normalizeNavigationBar(pageStyle) {
280
289
  navigationBar.shadowColorType = pageStyle.navigationBarShadow.colorType;
281
290
  delete pageStyle.navigationBarShadow;
282
291
  }
292
+ const parsedNavigationBar = (0, theme_1.initTheme)((0, manifest_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR), navigationBar);
283
293
  if ((0, shared_1.isArray)(navigationBar.buttons)) {
284
- navigationBar.buttons = navigationBar.buttons.map((btn) => normalizeNavigationBarButton(btn, navigationBar.type, navigationBar.titleColor));
294
+ navigationBar.buttons = navigationBar.buttons.map((btn) => normalizeNavigationBarButton(btn, navigationBar.type, parsedNavigationBar.titleColor));
285
295
  }
286
296
  if ((0, shared_1.isPlainObject)(navigationBar.searchInput)) {
287
297
  navigationBar.searchInput = normalizeNavigationBarSearchInput(navigationBar.searchInput);
@@ -0,0 +1,3 @@
1
+ export declare const parseThemeJson: (themeLocation?: string) => UniApp.ThemeJson;
2
+ export declare const normalizeThemeConfigOnce: (manifestJsonPlatform?: Record<string, any>) => UniApp.ThemeJson;
3
+ export declare function initTheme<T extends object>(manifestJson: Record<string, any>, pagesJson: T): T;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initTheme = exports.normalizeThemeConfigOnce = exports.parseThemeJson = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const json_1 = require("./json");
10
+ const uni_shared_1 = require("@dcloudio/uni-shared");
11
+ const parseThemeJson = (themeLocation = 'theme.json') => {
12
+ if (!themeLocation) {
13
+ return {};
14
+ }
15
+ themeLocation = path_1.default.join(process.env.UNI_INPUT_DIR, themeLocation);
16
+ if (!fs_1.default.existsSync(themeLocation)) {
17
+ return {};
18
+ }
19
+ const jsonStr = fs_1.default.readFileSync(themeLocation, 'utf8');
20
+ return (0, json_1.parseJson)(jsonStr, true);
21
+ };
22
+ exports.parseThemeJson = parseThemeJson;
23
+ exports.normalizeThemeConfigOnce = (0, uni_shared_1.once)((manifestJsonPlatform = {}) => (0, exports.parseThemeJson)(manifestJsonPlatform.themeLocation));
24
+ function initTheme(manifestJson, pagesJson) {
25
+ const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
26
+ const manifestPlatform = manifestJson['plus'] || manifestJson[platform] || {};
27
+ const themeConfig = (0, exports.normalizeThemeConfigOnce)(manifestPlatform);
28
+ return (0, uni_shared_1.normalizeStyles)(pagesJson, themeConfig);
29
+ }
30
+ exports.initTheme = initTheme;
package/dist/resolve.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as UTSCompiler from '@dcloudio/uni-uts-v1';
2
1
  export declare function requireResolve(filename: string, basedir: string): string;
3
2
  export declare function relativeFile(from: string, to: string): string;
4
3
  export declare const resolveMainPathOnce: (inputDir: string) => string;
@@ -6,13 +5,3 @@ export declare function getBuiltInPaths(): string[];
6
5
  export declare function resolveBuiltIn(path: string): string;
7
6
  export declare function resolveVueI18nRuntime(): string;
8
7
  export declare function resolveComponentsLibPath(): string;
9
- /**
10
- * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
11
- * @param id
12
- * @param importer
13
- * @returns
14
- */
15
- export declare function resolveUtsAppModule(id: string, importer: string): string | undefined;
16
- export declare function resolveUtsModuleProxyFile(id: string, importer: string): string | undefined;
17
- export declare function resolveUtsModule(id: string, importer: string, platform: typeof process.env.UNI_UTS_PLATFORM): string | undefined;
18
- export declare function resolveUTSCompiler(): typeof UTSCompiler;
package/dist/resolve.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveUTSCompiler = exports.resolveUtsModule = exports.resolveUtsModuleProxyFile = exports.resolveUtsAppModule = exports.resolveComponentsLibPath = exports.resolveVueI18nRuntime = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = exports.requireResolve = void 0;
6
+ exports.resolveComponentsLibPath = exports.resolveVueI18nRuntime = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = exports.requireResolve = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const debug_1 = __importDefault(require("debug"));
@@ -104,96 +104,3 @@ function resolveComponentsLibPath() {
104
104
  return componentsLibPath;
105
105
  }
106
106
  exports.resolveComponentsLibPath = resolveComponentsLibPath;
107
- /**
108
- * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
109
- * @param id
110
- * @param importer
111
- * @returns
112
- */
113
- function resolveUtsAppModule(id, importer) {
114
- id = path_1.default.resolve(importer, id);
115
- if (id.includes('utssdk') || id.includes('uni_modules')) {
116
- const parts = (0, utils_1.normalizePath)(id).split('/');
117
- const parentDir = parts[parts.length - 2];
118
- if (parentDir === 'uni_modules' || parentDir === 'utssdk') {
119
- const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
120
- if (fs_1.default.existsSync(path_1.default.resolve(id, basedir, 'index.uts'))) {
121
- return id;
122
- }
123
- const resolvePlatformDir = (p) => {
124
- return path_1.default.resolve(id, basedir, p);
125
- };
126
- const extname = ['.uts'];
127
- if (resolveUtsFile(resolvePlatformDir('app-android'), extname)) {
128
- return id;
129
- }
130
- if (resolveUtsFile(resolvePlatformDir('app-ios'), extname)) {
131
- return id;
132
- }
133
- }
134
- }
135
- }
136
- exports.resolveUtsAppModule = resolveUtsAppModule;
137
- function resolveUtsModuleProxyFile(id, importer) {
138
- const file = resolveUtsAppModule(id, importer);
139
- if (file) {
140
- return '\0' + file + '?uts-proxy';
141
- }
142
- }
143
- exports.resolveUtsModuleProxyFile = resolveUtsModuleProxyFile;
144
- // 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
145
- function resolveUtsModule(id, importer, platform) {
146
- if (process.env.UNI_PLATFORM === 'app') {
147
- return resolveUtsAppModule(id, importer);
148
- }
149
- id = path_1.default.resolve(importer, id);
150
- if (id.includes('utssdk') || id.includes('uni_modules')) {
151
- const parts = (0, utils_1.normalizePath)(id).split('/');
152
- const parentDir = parts[parts.length - 2];
153
- if (parentDir === 'uni_modules' || parentDir === 'utssdk') {
154
- const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
155
- const resolvePlatformDir = (p) => {
156
- return path_1.default.resolve(id, basedir, p);
157
- };
158
- let index = resolveUtsFile(resolvePlatformDir(platform));
159
- if (index) {
160
- return index;
161
- }
162
- index = path_1.default.resolve(id, basedir, 'index.uts');
163
- if (fs_1.default.existsSync(index)) {
164
- return index;
165
- }
166
- }
167
- }
168
- }
169
- exports.resolveUtsModule = resolveUtsModule;
170
- function resolveUtsFile(dir, extensions = ['.uts', '.ts', '.js']) {
171
- for (let i = 0; i < extensions.length; i++) {
172
- const indexFile = path_1.default.join(dir, 'index' + extensions[i]);
173
- if (fs_1.default.existsSync(indexFile)) {
174
- return indexFile;
175
- }
176
- }
177
- }
178
- function resolveUTSCompiler() {
179
- let compilerPath = '';
180
- if ((0, env_1.isInHBuilderX)()) {
181
- try {
182
- compilerPath = require.resolve(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts-v1'));
183
- }
184
- catch (e) { }
185
- }
186
- if (!compilerPath) {
187
- try {
188
- compilerPath = require.resolve('@dcloudio/uni-uts-v1', {
189
- paths: [process.env.UNI_CLI_CONTEXT],
190
- });
191
- }
192
- catch (e) { }
193
- }
194
- if (!compilerPath) {
195
- throw 'uts compiler is not found';
196
- }
197
- return require(compilerPath);
198
- }
199
- exports.resolveUTSCompiler = resolveUTSCompiler;
@@ -25,10 +25,7 @@ function parseUniExtApis(vite = true) {
25
25
  }
26
26
  const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api'];
27
27
  if (exports) {
28
- Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}` +
29
- (vite || !process.env.UNI_UTS_PLATFORM
30
- ? ''
31
- : `/utssdk/${process.env.UNI_UTS_PLATFORM}/index`), exports));
28
+ Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports));
32
29
  }
33
30
  });
34
31
  return injects;
package/dist/uts.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import * as UTSCompiler from '@dcloudio/uni-uts-v1';
2
+ /**
3
+ * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
4
+ * @param id
5
+ * @param importer
6
+ * @returns
7
+ */
8
+ export declare function resolveUtsAppModule(id: string, importer: string): string | undefined;
9
+ export declare function resolveUtsModule(id: string, importer: string): string | undefined;
10
+ export declare function resolveUTSCompiler(): typeof UTSCompiler;
package/dist/uts.js ADDED
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveUTSCompiler = exports.resolveUtsModule = exports.resolveUtsAppModule = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const hbx_1 = require("./hbx");
10
+ const utils_1 = require("./utils");
11
+ /**
12
+ * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
13
+ * @param id
14
+ * @param importer
15
+ * @returns
16
+ */
17
+ function resolveUtsAppModule(id, importer) {
18
+ id = path_1.default.resolve(importer, id);
19
+ if (id.includes('utssdk') || id.includes('uni_modules')) {
20
+ const parts = (0, utils_1.normalizePath)(id).split('/');
21
+ const parentDir = parts[parts.length - 2];
22
+ if (parentDir === 'uni_modules' || parentDir === 'utssdk') {
23
+ const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
24
+ if (fs_1.default.existsSync(path_1.default.resolve(id, basedir, 'index.uts'))) {
25
+ return id;
26
+ }
27
+ const resolvePlatformDir = (p) => {
28
+ return path_1.default.resolve(id, basedir, p);
29
+ };
30
+ const extname = ['.uts'];
31
+ if (resolveUtsFile(resolvePlatformDir('app-android'), extname)) {
32
+ return id;
33
+ }
34
+ if (resolveUtsFile(resolvePlatformDir('app-ios'), extname)) {
35
+ return id;
36
+ }
37
+ }
38
+ }
39
+ }
40
+ exports.resolveUtsAppModule = resolveUtsAppModule;
41
+ // 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
42
+ function resolveUtsModule(id, importer) {
43
+ if (process.env.UNI_PLATFORM === 'app' ||
44
+ process.env.UNI_PLATFORM === 'app-plus') {
45
+ return resolveUtsAppModule(id, importer);
46
+ }
47
+ id = path_1.default.resolve(importer, id);
48
+ if (id.includes('utssdk') || id.includes('uni_modules')) {
49
+ const parts = (0, utils_1.normalizePath)(id).split('/');
50
+ const parentDir = parts[parts.length - 2];
51
+ if (parentDir === 'uni_modules' || parentDir === 'utssdk') {
52
+ const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
53
+ const resolvePlatformDir = (p) => {
54
+ return path_1.default.resolve(id, basedir, p);
55
+ };
56
+ let index = resolveUtsFile(resolvePlatformDir(process.env.UNI_UTS_PLATFORM));
57
+ if (index) {
58
+ return index;
59
+ }
60
+ index = path_1.default.resolve(id, basedir, 'index.uts');
61
+ if (fs_1.default.existsSync(index)) {
62
+ return index;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ exports.resolveUtsModule = resolveUtsModule;
68
+ function resolveUtsFile(dir, extensions = ['.uts', '.ts', '.js']) {
69
+ for (let i = 0; i < extensions.length; i++) {
70
+ const indexFile = path_1.default.join(dir, 'index' + extensions[i]);
71
+ if (fs_1.default.existsSync(indexFile)) {
72
+ return indexFile;
73
+ }
74
+ }
75
+ }
76
+ function resolveUTSCompiler() {
77
+ let compilerPath = '';
78
+ if ((0, hbx_1.isInHBuilderX)()) {
79
+ try {
80
+ compilerPath = require.resolve(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts-v1'));
81
+ }
82
+ catch (e) { }
83
+ }
84
+ if (!compilerPath) {
85
+ try {
86
+ compilerPath = require.resolve('@dcloudio/uni-uts-v1', {
87
+ paths: [process.env.UNI_CLI_CONTEXT],
88
+ });
89
+ }
90
+ catch (e) { }
91
+ }
92
+ if (!compilerPath) {
93
+ throw 'uts compiler is not found';
94
+ }
95
+ return require(compilerPath);
96
+ }
97
+ exports.resolveUTSCompiler = resolveUTSCompiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3060720221018007",
3
+ "version": "3.0.0-alpha-3060820221027001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "@babel/core": "^7.18.13",
26
26
  "@babel/parser": "^7.18.13",
27
27
  "@babel/types": "^7.17.0",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3060720221018007",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3060720221018007",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3060820221027001",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3060820221027001",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3060720221018007",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3060820221027001",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",
package/lib/.DS_Store DELETED
Binary file
Binary file