@dcloudio/uni-cli-shared 3.0.0-alpha-4020620240822001 → 3.0.0-alpha-4020720240904001

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.
@@ -1,4 +1,4 @@
1
1
  export * from './jsonFile';
2
- export { AppJson, ComponentJson } from './types';
2
+ export { AppJson, ComponentJson, MiniProgramComponentsType } from './types';
3
3
  export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
4
4
  export { parseMiniProgramProjectJson } from './project';
@@ -1,4 +1,4 @@
1
- import type { ComponentJson, PageWindowOptions, UsingComponents } from './types';
1
+ import type { ComponentJson, MiniProgramComponentsType, PageWindowOptions, UsingComponents } from './types';
2
2
  export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
3
3
  export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
4
4
  export declare function hasJsonFile(filename: string): boolean;
@@ -17,11 +17,12 @@ export declare function isMiniProgramUsingComponent(name: string, options: {
17
17
  componentsDir?: string;
18
18
  }): boolean;
19
19
  interface MiniProgramComponents {
20
- [name: string]: 'plugin' | 'component' | 'dynamicLib' | 'ext';
20
+ [name: string]: MiniProgramComponentsType;
21
21
  }
22
22
  export declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: {
23
23
  filename: string;
24
24
  inputDir: string;
25
25
  componentsDir?: string;
26
26
  }): MiniProgramComponents;
27
+ export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string): Record<any, any>;
27
28
  export {};
@@ -3,8 +3,9 @@ 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.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
6
+ exports.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
8
9
  const shared_1 = require("@vue/shared");
9
10
  const utils_1 = require("../../utils");
10
11
  const resolve_1 = require("../../resolve");
@@ -152,9 +153,39 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
152
153
  // mp-toutiao
153
154
  res[name] = 'ext';
154
155
  }
156
+ else if (componentsDir &&
157
+ path.includes(componentsDir + '/') &&
158
+ findUsingComponentsJson(path, componentsDir).renderer === 'xr-frame') {
159
+ // mp-weixin & x-frame
160
+ res[name] = 'xr-frame';
161
+ }
155
162
  else if (componentsDir && path.includes(componentsDir + '/')) {
156
163
  res[name] = 'component';
157
164
  }
158
165
  return res;
159
166
  }, {});
160
167
  }
168
+ function findUsingComponentsJson(pathInpages, componentsDir) {
169
+ // 兼容test case
170
+ if (!process.env.UNI_INPUT_DIR)
171
+ return {};
172
+ let [, dir] = pathInpages.split(componentsDir);
173
+ if (dir === '') {
174
+ console.warn(`${pathInpages} 路径里没有找到对应的 ${componentsDir} 目录`);
175
+ return {};
176
+ }
177
+ dir = '.' + dir;
178
+ const fulldir = path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, dir);
179
+ let filename = path_1.default.parse(pathInpages).name + '.json';
180
+ let jsonPath = path_1.default.resolve(fulldir, filename);
181
+ if (fs_1.default.existsSync(jsonPath)) {
182
+ return require(jsonPath);
183
+ }
184
+ jsonPath = path_1.default.resolve(fulldir, 'index.json');
185
+ if (fs_1.default.existsSync(jsonPath)) {
186
+ return require(jsonPath);
187
+ }
188
+ console.warn(`${pathInpages} 路径下没有找到对应的json文件`);
189
+ return {};
190
+ }
191
+ exports.findUsingComponentsJson = findUsingComponentsJson;
@@ -119,4 +119,5 @@ export interface AppJson {
119
119
  restartStrategy?: RestartStrategy;
120
120
  [name: string]: unknown;
121
121
  }
122
+ export type MiniProgramComponentsType = 'plugin' | 'component' | 'dynamicLib' | 'ext' | 'xr-frame';
122
123
  export {};
@@ -1,7 +1,8 @@
1
1
  import type { EmittedAsset } from 'rollup';
2
2
  import type { ElementNode } from '@vue/compiler-core';
3
+ import type { MiniProgramComponentsType } from '../json/mp/types';
3
4
  type LazyElementFn = (node: ElementNode, context: {
4
- isMiniProgramComponent(name: string): 'plugin' | 'component' | 'dynamicLib' | 'ext' | undefined;
5
+ isMiniProgramComponent(name: string): MiniProgramComponentsType | undefined;
5
6
  }) => {
6
7
  [name: string]: {
7
8
  name: 'on' | 'bind';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4020620240822001",
3
+ "version": "3.0.0-alpha-4020720240904001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "@babel/core": "^7.23.3",
27
27
  "@babel/parser": "^7.23.9",
28
28
  "@babel/types": "^7.20.7",
29
- "@dcloudio/uni-i18n": "3.0.0-alpha-4020620240822001",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4020620240822001",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4020720240904001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4020720240904001",
31
31
  "@intlify/core-base": "9.1.9",
32
32
  "@intlify/shared": "9.1.9",
33
33
  "@intlify/vue-devtools": "9.1.9",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
73
73
  "devDependencies": {
74
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4020620240822001",
74
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4020720240904001",
75
75
  "@types/adm-zip": "^0.5.5",
76
76
  "@types/babel__code-frame": "^7.0.6",
77
77
  "@types/babel__core": "^7.1.19",