@dcloudio/uni-cli-shared 3.0.0-alpha-3050420220804008 → 3.0.0-alpha-3060020220830001

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.
@@ -8,6 +8,8 @@ const DEFAULT_KEYS = [
8
8
  'APP_PLUS',
9
9
  'APP_PLUS_NVUE',
10
10
  'APP_VUE',
11
+ 'APP_ANDROID',
12
+ 'APP_IOS',
11
13
  'H5',
12
14
  'MP',
13
15
  'MP_360',
@@ -52,6 +54,16 @@ function initPreContext(platform, userPreContext) {
52
54
  vueContext.APP_VUE = true;
53
55
  nvueContext.APP_NVUE = true;
54
56
  nvueContext.APP_PLUS_NVUE = true;
57
+ if (process.env.UNI_APP_PLATFORM === 'android') {
58
+ defaultContext.APP_ANDROID = true;
59
+ }
60
+ else if (process.env.UNI_APP_PLATFORM === 'ios') {
61
+ defaultContext.APP_IOS = true;
62
+ }
63
+ else {
64
+ defaultContext.APP_ANDROID = true;
65
+ defaultContext.APP_IOS = true;
66
+ }
55
67
  }
56
68
  else if (platform.startsWith('mp-')) {
57
69
  defaultContext.MP = true;
package/dist/resolve.d.ts CHANGED
@@ -5,3 +5,4 @@ export declare function getBuiltInPaths(): string[];
5
5
  export declare function resolveBuiltIn(path: string): string;
6
6
  export declare function resolveVueI18nRuntime(): string;
7
7
  export declare function resolveComponentsLibPath(): string;
8
+ export declare function resolveUtsModule(id: string, importer: string, platform: typeof process.env.UNI_UTS_PLATFORM): string | undefined;
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.resolveComponentsLibPath = exports.resolveVueI18nRuntime = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = exports.requireResolve = void 0;
6
+ exports.resolveUtsModule = 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"));
@@ -22,18 +22,6 @@ function resolveWithSymlinks(id, basedir) {
22
22
  extensions: constants_1.extensions,
23
23
  // necessary to work with pnpm
24
24
  preserveSymlinks: true,
25
- pathFilter(pkg, filepath, relativePath) {
26
- if (pkg.uni_modules && pkg.uni_modules.type === 'uts') {
27
- if (process.env.UNI_APP_PLATFORM === 'app-android' ||
28
- process.env.UNI_APP_PLATFORM === 'app-ios') {
29
- const file = process.env.UNI_APP_PLATFORM + '/index.uts';
30
- if (fs_1.default.existsSync(path_1.default.join(filepath.replace(relativePath, ''), file))) {
31
- return file;
32
- }
33
- }
34
- }
35
- return relativePath;
36
- },
37
25
  });
38
26
  }
39
27
  function relativeFile(from, to) {
@@ -116,3 +104,37 @@ function resolveComponentsLibPath() {
116
104
  return componentsLibPath;
117
105
  }
118
106
  exports.resolveComponentsLibPath = resolveComponentsLibPath;
107
+ // 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
108
+ function resolveUtsModule(id, importer, platform) {
109
+ id = path_1.default.resolve(importer, id);
110
+ if (id.includes('utssdk') || id.includes('uni_modules')) {
111
+ const parts = (0, utils_1.normalizePath)(id).split('/');
112
+ const parentDir = parts[parts.length - 2];
113
+ if (parentDir === 'uni_modules' || parentDir === 'utssdk') {
114
+ const index = path_1.default.resolve(id, 'index.uts');
115
+ if (fs_1.default.existsSync(index)) {
116
+ return index;
117
+ }
118
+ if (parentDir === 'uni_modules' &&
119
+ !fs_1.default.existsSync(path_1.default.join(id, 'utssdk'))) {
120
+ // uni_modules/test-plugin/utssdk不存在
121
+ return;
122
+ }
123
+ const platformDir = path_1.default.resolve(id, parentDir === 'uni_modules' ? 'utssdk' : '', platform);
124
+ // App平台仅支持 uts
125
+ if (platform === 'app-android' || platform === 'app-ios') {
126
+ return resolveUtsFile(platformDir, ['.uts']);
127
+ }
128
+ return resolveUtsFile(platformDir);
129
+ }
130
+ }
131
+ }
132
+ exports.resolveUtsModule = resolveUtsModule;
133
+ function resolveUtsFile(dir, extensions = ['.uts', '.ts', '.js']) {
134
+ for (let i = 0; i < extensions.length; i++) {
135
+ const indexFile = path_1.default.join(dir, 'index' + extensions[i]);
136
+ if (fs_1.default.existsSync(indexFile)) {
137
+ return indexFile;
138
+ }
139
+ }
140
+ }
package/dist/utils.d.ts CHANGED
@@ -11,3 +11,8 @@ export declare function removeExt(str: string): string;
11
11
  export declare function normalizeNodeModules(str: string): string;
12
12
  export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
13
13
  export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): ParserPlugin[];
14
+ export declare function pathToGlob(pathString: string, glob: string, options?: {
15
+ windows?: boolean;
16
+ escape?: boolean;
17
+ }): string;
18
+ export declare function resolveSourceMapPath(dir: string, platform: UniApp.PLATFORM): string;
package/dist/utils.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.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
6
+ exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -78,3 +78,15 @@ function normalizeParsePlugins(importer, babelParserPlugins) {
78
78
  return plugins;
79
79
  }
80
80
  exports.normalizeParsePlugins = normalizeParsePlugins;
81
+ function pathToGlob(pathString, glob, options = {}) {
82
+ const isWindows = 'windows' in options ? options.windows : /^win/.test(process.platform);
83
+ const useEscape = options.escape;
84
+ const str = isWindows ? pathString.replace(/\\/g, '/') : pathString;
85
+ let safeStr = str.replace(/[\\*?[\]{}()!]/g, isWindows || !useEscape ? '[$&]' : '\\$&');
86
+ return path_1.default.posix.join(safeStr, glob);
87
+ }
88
+ exports.pathToGlob = pathToGlob;
89
+ function resolveSourceMapPath(dir, platform) {
90
+ return path_1.default.resolve(dir, '../.sourcemap/' + platform);
91
+ }
92
+ exports.resolveSourceMapPath = resolveSourceMapPath;
package/dist/watcher.js CHANGED
@@ -8,6 +8,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const chokidar_1 = require("chokidar");
10
10
  const shared_1 = require("@vue/shared");
11
+ const utils_1 = require("./utils");
11
12
  class FileWatcher {
12
13
  constructor({ src, dest, transform, verbose }) {
13
14
  this.src = !(0, shared_1.isArray)(src) ? [src] : src;
@@ -19,7 +20,9 @@ class FileWatcher {
19
20
  if (!this.watcher) {
20
21
  const copy = this.copy.bind(this);
21
22
  const remove = this.remove.bind(this);
22
- this.watcher = (0, chokidar_1.watch)(this.src, watchOptions)
23
+ // escape chokidar cwd
24
+ const src = this.src.map((src) => (0, utils_1.pathToGlob)(path_1.default.resolve(watchOptions.cwd), src));
25
+ this.watcher = (0, chokidar_1.watch)(src, watchOptions)
23
26
  .on('add', copy)
24
27
  .on('addDir', copy)
25
28
  .on('change', copy)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3050420220804008",
3
+ "version": "3.0.0-alpha-3060020220830001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,8 +22,8 @@
22
22
  "@babel/core": "^7.17.9",
23
23
  "@babel/parser": "^7.17.9",
24
24
  "@babel/types": "^7.17.0",
25
- "@dcloudio/uni-i18n": "3.0.0-alpha-3050420220804008",
26
- "@dcloudio/uni-shared": "3.0.0-alpha-3050420220804008",
25
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3060020220830001",
26
+ "@dcloudio/uni-shared": "3.0.0-alpha-3060020220830001",
27
27
  "@intlify/core-base": "9.1.9",
28
28
  "@intlify/shared": "9.1.9",
29
29
  "@intlify/vue-devtools": "9.1.9",
@@ -33,7 +33,7 @@
33
33
  "@vue/compiler-sfc": "3.2.37",
34
34
  "@vue/server-renderer": "3.2.37",
35
35
  "@vue/shared": "3.2.37",
36
- "autoprefixer": "^10.4.7",
36
+ "autoprefixer": "^10.4.8",
37
37
  "base64url": "^3.0.1",
38
38
  "chokidar": "^3.5.3",
39
39
  "compare-versions": "^3.6.0",
package/lib/.DS_Store DELETED
Binary file
Binary file