@dcloudio/uni-cli-shared 3.0.0-alpha-3021220211105004 → 3.0.0-alpha-3021320211109002

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 (76) hide show
  1. package/dist/constants.d.ts +0 -2
  2. package/dist/constants.js +1 -3
  3. package/dist/easycom.d.ts +0 -3
  4. package/dist/easycom.js +2 -22
  5. package/dist/env/define.d.ts +0 -2
  6. package/dist/env/define.js +0 -5
  7. package/dist/hbx/log.js +1 -1
  8. package/dist/index.d.ts +2 -4
  9. package/dist/index.js +2 -4
  10. package/dist/json/app/pages/nvue.js +1 -1
  11. package/dist/json/manifest.d.ts +1 -1
  12. package/dist/json/manifest.js +3 -9
  13. package/dist/json/mp/index.d.ts +0 -1
  14. package/dist/json/mp/index.js +0 -11
  15. package/dist/json/mp/jsonFile.d.ts +6 -7
  16. package/dist/json/mp/jsonFile.js +13 -56
  17. package/dist/json/mp/pages.d.ts +0 -1
  18. package/dist/json/mp/pages.js +3 -17
  19. package/dist/json/mp/types.d.ts +0 -1
  20. package/dist/messages/index.d.ts +0 -2
  21. package/dist/messages/index.js +0 -2
  22. package/dist/mp/event.d.ts +1 -2
  23. package/dist/mp/event.js +3 -18
  24. package/dist/mp/index.d.ts +0 -5
  25. package/dist/mp/index.js +0 -7
  26. package/dist/postcss/plugins/uniapp.js +19 -49
  27. package/dist/preprocess/context.js +0 -1
  28. package/dist/renderjs.d.ts +16 -0
  29. package/dist/renderjs.js +44 -0
  30. package/dist/utils.d.ts +1 -6
  31. package/dist/utils.js +8 -39
  32. package/dist/vite/index.d.ts +3 -2
  33. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
  34. package/dist/vite/plugins/vitejs/plugins/asset.js +21 -28
  35. package/dist/vite/plugins/vitejs/plugins/css.d.ts +3 -3
  36. package/dist/vite/plugins/vitejs/plugins/css.js +22 -13
  37. package/dist/vite/utils/plugin.d.ts +3 -3
  38. package/dist/vite/utils/plugin.js +2 -2
  39. package/package.json +4 -7
  40. package/dist/exports.d.ts +0 -1
  41. package/dist/exports.js +0 -8
  42. package/dist/filter.d.ts +0 -16
  43. package/dist/filter.js +0 -60
  44. package/dist/mp/constants.d.ts +0 -2
  45. package/dist/mp/constants.js +0 -5
  46. package/dist/mp/imports.d.ts +0 -5
  47. package/dist/mp/imports.js +0 -63
  48. package/dist/mp/nvue.d.ts +0 -1
  49. package/dist/mp/nvue.js +0 -18
  50. package/dist/mp/style.d.ts +0 -1
  51. package/dist/mp/style.js +0 -10
  52. package/dist/mp/template.d.ts +0 -55
  53. package/dist/mp/template.js +0 -73
  54. package/dist/mp/transformImports.d.ts +0 -14
  55. package/dist/mp/transformImports.js +0 -175
  56. package/dist/vue/index.d.ts +0 -2
  57. package/dist/vue/index.js +0 -14
  58. package/dist/vue/transforms/index.d.ts +0 -10
  59. package/dist/vue/transforms/index.js +0 -36
  60. package/dist/vue/transforms/transformComponent.d.ts +0 -3
  61. package/dist/vue/transforms/transformComponent.js +0 -26
  62. package/dist/vue/transforms/transformEvent.d.ts +0 -2
  63. package/dist/vue/transforms/transformEvent.js +0 -22
  64. package/dist/vue/transforms/transformPageHead.d.ts +0 -2
  65. package/dist/vue/transforms/transformPageHead.js +0 -11
  66. package/dist/vue/transforms/transformRef.d.ts +0 -2
  67. package/dist/vue/transforms/transformRef.js +0 -32
  68. package/dist/vue/transforms/transformTag.d.ts +0 -3
  69. package/dist/vue/transforms/transformTag.js +0 -45
  70. package/dist/vue/transforms/vModel.d.ts +0 -12
  71. package/dist/vue/transforms/vModel.js +0 -33
  72. package/dist/vue/transforms/vOn.d.ts +0 -15
  73. package/dist/vue/transforms/vOn.js +0 -88
  74. package/dist/vue/utils.d.ts +0 -9
  75. package/dist/vue/utils.js +0 -66
  76. package/lib/nvue.css +0 -34
@@ -3,8 +3,6 @@ export declare const EXTNAME_JS: string[];
3
3
  export declare const EXTNAME_VUE: string[];
4
4
  export declare const EXTNAME_VUE_RE: RegExp;
5
5
  export declare const EXTNAME_JS_RE: RegExp;
6
- export declare const ASSETS_INLINE_LIMIT: number;
7
- export declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
8
6
  export declare const PAGE_EXTNAME_APP: string[];
9
7
  export declare const PAGE_EXTNAME: string[];
10
8
  export declare const H5_API_STYLE_PATH = "@dcloudio/uni-h5/style/api/";
package/dist/constants.js CHANGED
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.ASSETS_INLINE_LIMIT = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
3
+ 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.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE = 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_VUE = ['.vue', '.nvue'];
7
7
  exports.EXTNAME_VUE_RE = /\.(vue|nvue)$/;
8
8
  exports.EXTNAME_JS_RE = /\.[jt]sx?$/;
9
- exports.ASSETS_INLINE_LIMIT = 40 * 1024;
10
- exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
11
9
  // APP 平台解析页面后缀的优先级
12
10
  exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
13
11
  // 其他平台解析页面后缀的优先级
package/dist/easycom.d.ts CHANGED
@@ -20,7 +20,4 @@ export declare function initEasycoms(inputDir: string, platform: UniApp.PLATFORM
20
20
  };
21
21
  export declare const initEasycomsOnce: typeof initEasycoms;
22
22
  export declare function matchEasycom(tag: string): string | false | undefined;
23
- export declare function addImportDeclaration(importDeclarations: string[], local: string, source: string, imported?: string): string;
24
- export declare function genResolveEasycomCode(importDeclarations: string[], code: string, name: string): string;
25
- export declare const UNI_EASYCOM_EXCLUDE: RegExp[];
26
23
  export {};
package/dist/easycom.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.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
6
+ exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = 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"));
@@ -13,7 +13,7 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
13
13
  const utils_1 = require("./utils");
14
14
  const pages_1 = require("./json/pages");
15
15
  const messages_1 = require("./messages");
16
- const debugEasycom = (0, debug_1.default)('vite:uni:easycom');
16
+ const debugEasycom = (0, debug_1.default)('uni:easycom');
17
17
  const easycoms = [];
18
18
  const easycomsCache = new Map();
19
19
  const easycomsInvalidCache = new Set();
@@ -178,23 +178,3 @@ function initAutoScanEasycoms(dirs, rootDir, extensions) {
178
178
  function normalizeCompath(compath, rootDir) {
179
179
  return (0, utils_1.normalizePath)(path_1.default.relative(rootDir, compath));
180
180
  }
181
- function addImportDeclaration(importDeclarations, local, source, imported) {
182
- importDeclarations.push(createImportDeclaration(local, source, imported));
183
- return local;
184
- }
185
- exports.addImportDeclaration = addImportDeclaration;
186
- function createImportDeclaration(local, source, imported) {
187
- if (imported) {
188
- return `import {${imported} as ${local}} from '${source}';`;
189
- }
190
- return `import ${local} from '${source}';`;
191
- }
192
- const RESOLVE_EASYCOM_IMPORT_CODE = `import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';`;
193
- function genResolveEasycomCode(importDeclarations, code, name) {
194
- if (!importDeclarations.includes(RESOLVE_EASYCOM_IMPORT_CODE)) {
195
- importDeclarations.push(RESOLVE_EASYCOM_IMPORT_CODE);
196
- }
197
- return `resolveEasycom(${code.replace('_resolveComponent', '__resolveDynamicComponent')}, ${name})`;
198
- }
199
- exports.genResolveEasycomCode = genResolveEasycomCode;
200
- exports.UNI_EASYCOM_EXCLUDE = [/App.vue$/, /@dcloudio\/uni-h5/];
@@ -1,10 +1,8 @@
1
1
  export declare function initDefine(stringifyBoolean?: boolean): {
2
2
  'process.env.NODE_ENV': string;
3
- 'process.env.UNI_DEBUG': string | boolean;
4
3
  'process.env.UNI_APP_ID': string;
5
4
  'process.env.UNI_APP_NAME': string;
6
5
  'process.env.UNI_PLATFORM': string;
7
- 'process.env.UNI_COMPILER_VERSION': string;
8
6
  'process.env.RUN_BY_HBUILDERX': string | boolean;
9
7
  'process.env.UNI_AUTOMATOR_WS_ENDPOINT': string;
10
8
  'process.env.UNI_CLOUD_PROVIDER': string;
@@ -6,16 +6,11 @@ const json_1 = require("../json");
6
6
  function initDefine(stringifyBoolean = false) {
7
7
  const manifestJson = (0, json_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
8
8
  const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
9
- const isDebug = !!manifestJson.debug;
10
9
  return {
11
10
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
12
- 'process.env.UNI_DEBUG': stringifyBoolean
13
- ? JSON.stringify(isDebug)
14
- : isDebug,
15
11
  'process.env.UNI_APP_ID': JSON.stringify(manifestJson.appid || ''),
16
12
  'process.env.UNI_APP_NAME': JSON.stringify(manifestJson.name || ''),
17
13
  'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
18
- 'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION),
19
14
  'process.env.RUN_BY_HBUILDERX': stringifyBoolean
20
15
  ? JSON.stringify(isRunByHBuilderX)
21
16
  : isRunByHBuilderX,
package/dist/hbx/log.js CHANGED
@@ -40,7 +40,7 @@ exports.removeInfoFormatter = {
40
40
  return '';
41
41
  },
42
42
  };
43
- const REMOVED_WARN_MSGS = [];
43
+ const REMOVED_WARN_MSGS = ['warnings when minifying css:'];
44
44
  exports.removeWarnFormatter = {
45
45
  test(msg) {
46
46
  return !!REMOVED_WARN_MSGS.find((m) => msg.includes(m));
package/dist/index.d.ts CHANGED
@@ -2,9 +2,8 @@ export * from './fs';
2
2
  export * from './mp';
3
3
  export * from './env';
4
4
  export * from './hbx';
5
- export * from './ssr';
6
- export * from './vue';
7
5
  export * from './logs';
6
+ export * from './ssr';
8
7
  export * from './i18n';
9
8
  export * from './deps';
10
9
  export * from './json';
@@ -14,8 +13,7 @@ export * from './easycom';
14
13
  export * from './constants';
15
14
  export * from './preprocess';
16
15
  export * from './postcss';
17
- export * from './filter';
16
+ export * from './renderjs';
18
17
  export * from './esbuild';
19
18
  export { M } from './messages';
20
- export * from './exports';
21
19
  export { checkUpdate } from './checkUpdate';
package/dist/index.js CHANGED
@@ -15,9 +15,8 @@ __exportStar(require("./fs"), exports);
15
15
  __exportStar(require("./mp"), exports);
16
16
  __exportStar(require("./env"), exports);
17
17
  __exportStar(require("./hbx"), exports);
18
- __exportStar(require("./ssr"), exports);
19
- __exportStar(require("./vue"), exports);
20
18
  __exportStar(require("./logs"), exports);
19
+ __exportStar(require("./ssr"), exports);
21
20
  __exportStar(require("./i18n"), exports);
22
21
  __exportStar(require("./deps"), exports);
23
22
  __exportStar(require("./json"), exports);
@@ -27,10 +26,9 @@ __exportStar(require("./easycom"), exports);
27
26
  __exportStar(require("./constants"), exports);
28
27
  __exportStar(require("./preprocess"), exports);
29
28
  __exportStar(require("./postcss"), exports);
30
- __exportStar(require("./filter"), exports);
29
+ __exportStar(require("./renderjs"), exports);
31
30
  __exportStar(require("./esbuild"), exports);
32
31
  var messages_1 = require("./messages");
33
32
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
34
- __exportStar(require("./exports"), exports);
35
33
  var checkUpdate_1 = require("./checkUpdate");
36
34
  Object.defineProperty(exports, "checkUpdate", { enumerable: true, get: function () { return checkUpdate_1.checkUpdate; } });
@@ -20,7 +20,7 @@ function initWebpackNVueEntry(pages) {
20
20
  if (!path) {
21
21
  return;
22
22
  }
23
- const subNVuePath = (0, utils_1.removeExt)((0, utils_1.normalizePath)(path.split('?')[0]));
23
+ const subNVuePath = (0, utils_1.removeExt)(path.split('?')[0]);
24
24
  process.UNI_NVUE_ENTRY[subNVuePath] = genWebpackBase64Code(genNVueEntryCode(subNVuePath));
25
25
  });
26
26
  });
@@ -1,6 +1,6 @@
1
1
  export declare const parseManifestJson: (inputDir: string) => any;
2
2
  export declare const parseManifestJsonOnce: (inputDir: string) => any;
3
- export declare const parseRpx2UnitOnce: (inputDir: string, platform?: UniApp.PLATFORM) => any;
3
+ export declare const parseRpx2UnitOnce: (inputDir: string) => any;
4
4
  interface CompilerCompatConfig {
5
5
  MODE?: 2 | 3;
6
6
  }
@@ -14,15 +14,9 @@ const parseManifestJson = (inputDir) => {
14
14
  };
15
15
  exports.parseManifestJson = parseManifestJson;
16
16
  exports.parseManifestJsonOnce = (0, uni_shared_1.once)(exports.parseManifestJson);
17
- exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir, platform = 'h5') => {
18
- const rpx2unit = platform === 'h5' || platform === 'app'
19
- ? uni_shared_1.defaultRpx2Unit
20
- : uni_shared_1.defaultMiniProgramRpx2Unit;
21
- const platformOptions = (0, exports.parseManifestJsonOnce)(inputDir)[platform];
22
- if (platformOptions && platformOptions.rpx) {
23
- return (0, shared_1.extend)({}, rpx2unit, platformOptions);
24
- }
25
- return (0, shared_1.extend)({}, rpx2unit);
17
+ exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir) => {
18
+ const { h5 } = (0, exports.parseManifestJsonOnce)(inputDir);
19
+ return (0, shared_1.extend)({}, uni_shared_1.defaultRpx2Unit, (h5 && h5.rpx) || {});
26
20
  });
27
21
  function parseCompatConfig(_inputDir) {
28
22
  // 不支持 mode:2
@@ -1,4 +1,3 @@
1
- export * from './jsonFile';
2
1
  export { AppJson } from './types';
3
2
  export { parseMiniProgramPagesJson } from './pages';
4
3
  export { parseMiniProgramProjectJson } from './project';
@@ -1,17 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
2
  Object.defineProperty(exports, "__esModule", { value: true });
13
3
  exports.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = void 0;
14
- __exportStar(require("./jsonFile"), exports);
15
4
  var pages_1 = require("./pages");
16
5
  Object.defineProperty(exports, "parseMiniProgramPagesJson", { enumerable: true, get: function () { return pages_1.parseMiniProgramPagesJson; } });
17
6
  var project_1 = require("./project");
@@ -1,8 +1,7 @@
1
1
  import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
2
- export declare function hasJsonFile(filename: string): boolean;
3
- export declare function normalizeJsonFilename(filename: string): string;
4
- export declare function findChangedJsonFiles(): Map<string, string>;
5
- export declare function addMiniProgramAppJson(appJson: Record<string, any>): void;
6
- export declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void;
7
- export declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void;
8
- export declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void;
2
+ export declare const jsonPagesCache: Map<string, PageWindowOptions>;
3
+ export declare const jsonComponentsCache: Map<string, ComponentJson>;
4
+ export declare const jsonUsingComponentsCache: Map<string, UsingComponents>;
5
+ export declare function addPageJson(filename: string, json: PageWindowOptions): void;
6
+ export declare function addComponentJson(filename: string, json: ComponentJson): void;
7
+ export declare function addUsingComponents(filename: string, json: UsingComponents): void;
@@ -1,61 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.hasJsonFile = void 0;
4
- const shared_1 = require("@vue/shared");
5
- const utils_1 = require("../../utils");
6
- let appJsonCache = {};
7
- const jsonFilesCache = new Map();
8
- const jsonPagesCache = new Map();
9
- const jsonComponentsCache = new Map();
10
- const jsonUsingComponentsCache = new Map();
11
- function hasJsonFile(filename) {
12
- return (filename === 'app' ||
13
- jsonPagesCache.has(filename) ||
14
- jsonComponentsCache.has(filename));
3
+ exports.addUsingComponents = exports.addComponentJson = exports.addPageJson = exports.jsonUsingComponentsCache = exports.jsonComponentsCache = exports.jsonPagesCache = void 0;
4
+ exports.jsonPagesCache = new Map();
5
+ exports.jsonComponentsCache = new Map();
6
+ exports.jsonUsingComponentsCache = new Map();
7
+ function addPageJson(filename, json) {
8
+ exports.jsonPagesCache.set(filename, json);
15
9
  }
16
- exports.hasJsonFile = hasJsonFile;
17
- function normalizeJsonFilename(filename) {
18
- return (0, utils_1.normalizeNodeModules)(filename);
10
+ exports.addPageJson = addPageJson;
11
+ function addComponentJson(filename, json) {
12
+ exports.jsonComponentsCache.set(filename, json);
19
13
  }
20
- exports.normalizeJsonFilename = normalizeJsonFilename;
21
- function findChangedJsonFiles() {
22
- const changedJsonFiles = new Map();
23
- function findChangedFile(name, json) {
24
- const newJson = (0, shared_1.extend)({}, json);
25
- if (!newJson.usingComponents) {
26
- newJson.usingComponents = {};
27
- }
28
- (0, shared_1.extend)(newJson.usingComponents, jsonUsingComponentsCache.get(name));
29
- const jsonStr = JSON.stringify(newJson, null, 2);
30
- if (jsonFilesCache.get(name) !== jsonStr) {
31
- changedJsonFiles.set(name, jsonStr);
32
- jsonFilesCache.set(name, jsonStr);
33
- }
34
- }
35
- function findChangedFiles(jsonsCache) {
36
- for (const name of jsonsCache.keys()) {
37
- findChangedFile(name, jsonsCache.get(name));
38
- }
39
- }
40
- findChangedFile('app', appJsonCache);
41
- findChangedFiles(jsonPagesCache);
42
- findChangedFiles(jsonComponentsCache);
43
- return changedJsonFiles;
14
+ exports.addComponentJson = addComponentJson;
15
+ function addUsingComponents(filename, json) {
16
+ exports.jsonUsingComponentsCache.set(filename, json);
44
17
  }
45
- exports.findChangedJsonFiles = findChangedJsonFiles;
46
- function addMiniProgramAppJson(appJson) {
47
- appJsonCache = appJson;
48
- }
49
- exports.addMiniProgramAppJson = addMiniProgramAppJson;
50
- function addMiniProgramPageJson(filename, json) {
51
- jsonPagesCache.set(filename, json);
52
- }
53
- exports.addMiniProgramPageJson = addMiniProgramPageJson;
54
- function addMiniProgramComponentJson(filename, json) {
55
- jsonComponentsCache.set(filename, json);
56
- }
57
- exports.addMiniProgramComponentJson = addMiniProgramComponentJson;
58
- function addMiniProgramUsingComponents(filename, json) {
59
- jsonUsingComponentsCache.set(filename, json);
60
- }
61
- exports.addMiniProgramUsingComponents = addMiniProgramUsingComponents;
18
+ exports.addUsingComponents = addUsingComponents;
@@ -11,6 +11,5 @@ interface ParsePagesJsonOptions {
11
11
  export declare function parseMiniProgramPagesJson(jsonStr: string, platform: UniApp.PLATFORM, options?: ParsePagesJsonOptions): {
12
12
  appJson: AppJson;
13
13
  pageJsons: Record<string, PageWindowOptions>;
14
- nvuePages: string[];
15
14
  };
16
15
  export {};
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseMiniProgramPagesJson = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
7
  const path_1 = __importDefault(require("path"));
9
8
  const shared_1 = require("@vue/shared");
10
9
  const json_1 = require("../json");
@@ -15,32 +14,20 @@ function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: f
15
14
  return parsePagesJson(jsonStr, platform, options);
16
15
  }
17
16
  exports.parseMiniProgramPagesJson = parseMiniProgramPagesJson;
18
- function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
17
+ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, } = {
19
18
  subpackages: false,
20
19
  }) {
21
20
  const appJson = {
22
21
  pages: [],
23
22
  };
24
23
  const pageJsons = {};
25
- const nvuePages = [];
26
24
  // preprocess
27
25
  const pagesJson = (0, json_1.parseJson)(jsonStr, true);
28
26
  if (!pagesJson) {
29
27
  throw new Error(`[vite] Error: pages.json parse failed.\n`);
30
28
  }
31
29
  function addPageJson(pagePath, style) {
32
- const filename = path_1.default.join(process.env.UNI_INPUT_DIR, pagePath);
33
- if (fs_1.default.existsSync(filename + '.nvue') &&
34
- !fs_1.default.existsSync(filename + '.vue')) {
35
- nvuePages.push(pagePath);
36
- }
37
- const windowOptions = {};
38
- if (platform === 'mp-baidu') {
39
- // 仅百度小程序需要页面配置 component:true
40
- // 快手小程序反而不能配置 component:true,故不能统一添加,目前硬编码处理
41
- windowOptions.component = true;
42
- }
43
- pageJsons[pagePath] = (0, shared_1.extend)(windowOptions, (0, utils_1.parseWindowOptions)(style, platform, windowOptionsMap));
30
+ pageJsons[pagePath] = (0, utils_1.parseWindowOptions)(style, platform, windowOptionsMap);
44
31
  }
45
32
  // pages
46
33
  (0, pages_1.validatePages)(pagesJson, jsonStr);
@@ -78,7 +65,7 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
78
65
  }
79
66
  // tabBar
80
67
  if (pagesJson.tabBar) {
81
- const tabBar = (0, utils_1.parseTabBar)(pagesJson.tabBar, platform, tabBarOptionsMap, tabBarItemOptionsMap);
68
+ const tabBar = (0, utils_1.parseTabBar)(pagesJson.tabBar, platform);
82
69
  if (tabBar) {
83
70
  appJson.tabBar = tabBar;
84
71
  }
@@ -102,6 +89,5 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
102
89
  return {
103
90
  appJson,
104
91
  pageJsons,
105
- nvuePages,
106
92
  };
107
93
  }
@@ -18,7 +18,6 @@ interface ShareWindowOptions {
18
18
  declare type Style = 'v2' | string;
19
19
  declare type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string;
20
20
  export interface PageWindowOptions extends ShareWindowOptions {
21
- component?: true;
22
21
  disableScroll?: boolean;
23
22
  usingComponents?: UsingComponents;
24
23
  initialRenderingCache?: 'static' | string;
@@ -13,6 +13,4 @@ export declare const M: {
13
13
  'i18n.fallbackLocale.default': string;
14
14
  'i18n.fallbackLocale.missing': string;
15
15
  'easycom.conflict': string;
16
- 'mp.component.args[0]': string;
17
- 'mp.component.args[1]': string;
18
16
  };
@@ -16,6 +16,4 @@ exports.M = {
16
16
  'i18n.fallbackLocale.default': '当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}',
17
17
  'i18n.fallbackLocale.missing': '当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件',
18
18
  'easycom.conflict': 'easycom组件冲突:',
19
- 'mp.component.args[0]': '{0}的第一个参数必须为静态字符串',
20
- 'mp.component.args[1]': '{0}需要两个参数',
21
19
  };
@@ -1,5 +1,4 @@
1
- export declare function formatMiniProgramEvent(eventName: string, { isCatch, isCapture, isComponent, }: {
1
+ export declare function formatMiniProgramEvent(eventName: string, { isCatch, isCapture, }: {
2
2
  isCatch?: boolean;
3
3
  isCapture?: boolean;
4
- isComponent?: boolean;
5
4
  }): string;
package/dist/mp/event.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatMiniProgramEvent = void 0;
4
- function formatMiniProgramEvent(eventName, { isCatch, isCapture, isComponent, }) {
5
- if (!isComponent && eventName === 'click') {
6
- eventName = 'tap';
7
- }
4
+ function formatMiniProgramEvent(eventName, { isCatch, isCapture, }) {
8
5
  let eventType = 'bind';
9
6
  if (isCatch) {
10
7
  eventType = 'catch';
@@ -12,19 +9,7 @@ function formatMiniProgramEvent(eventName, { isCatch, isCapture, isComponent, })
12
9
  if (isCapture) {
13
10
  return `capture-${eventType}:${eventName}`;
14
11
  }
15
- // bind:foo-bar
16
- return eventType + (isSimpleExpr(eventName) ? '' : ':') + eventName;
12
+ // 原生组件不支持 bind:input 等写法,统一使用 bindinput
13
+ return `${eventType}${eventName}`;
17
14
  }
18
15
  exports.formatMiniProgramEvent = formatMiniProgramEvent;
19
- function isSimpleExpr(name) {
20
- if (name.startsWith('_')) {
21
- return false;
22
- }
23
- if (name.indexOf('-') > -1) {
24
- return false;
25
- }
26
- if (name.indexOf(':') > -1) {
27
- return false;
28
- }
29
- return true;
30
- }
@@ -1,6 +1 @@
1
- export * from './nvue';
2
1
  export * from './event';
3
- export * from './style';
4
- export * from './template';
5
- export * from './constants';
6
- export { transformVueComponentImports } from './transformImports';
package/dist/mp/index.js CHANGED
@@ -10,11 +10,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.transformVueComponentImports = void 0;
14
- __exportStar(require("./nvue"), exports);
15
13
  __exportStar(require("./event"), exports);
16
- __exportStar(require("./style"), exports);
17
- __exportStar(require("./template"), exports);
18
- __exportStar(require("./constants"), exports);
19
- var transformImports_1 = require("./transformImports");
20
- Object.defineProperty(exports, "transformVueComponentImports", { enumerable: true, get: function () { return transformImports_1.transformVueComponentImports; } });
@@ -7,8 +7,9 @@ const shared_1 = require("@vue/shared");
7
7
  const postcss_1 = require("postcss");
8
8
  const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
9
9
  const uni_shared_1 = require("@dcloudio/uni-shared");
10
- const manifest_1 = require("../../json/manifest");
11
- const defaultUniAppCssProcessorOptions = (0, shared_1.extend)({}, uni_shared_1.defaultRpx2Unit);
10
+ const defaultUniAppCssProcessorOptions = (0, shared_1.extend)({
11
+ page: 'body',
12
+ }, uni_shared_1.defaultRpx2Unit);
12
13
  const BG_PROPS = [
13
14
  'background',
14
15
  'background-clip',
@@ -20,14 +21,22 @@ const BG_PROPS = [
20
21
  'background-size',
21
22
  'background-attachment',
22
23
  ];
23
- function transform(selector, state, { rewriteTag }) {
24
+ function transform(selector, page, state) {
24
25
  if (selector.type !== 'tag') {
25
26
  return;
26
27
  }
27
28
  const { value } = selector;
28
- selector.value = rewriteTag(value);
29
- if (value === 'page' && selector.value === 'uni-page-body') {
30
- state.bg = true;
29
+ if ((0, uni_shared_1.isBuiltInComponent)(value)) {
30
+ selector.value = uni_shared_1.COMPONENT_SELECTOR_PREFIX + value;
31
+ }
32
+ else if (value === 'page') {
33
+ if (!page) {
34
+ return;
35
+ }
36
+ selector.value = page;
37
+ if (page !== 'body') {
38
+ state.bg = true;
39
+ }
31
40
  }
32
41
  }
33
42
  function createBodyBackgroundRule(origRule) {
@@ -41,10 +50,10 @@ function createBodyBackgroundRule(origRule) {
41
50
  origRule.after((0, postcss_1.rule)({ selector: 'body' }).append(bgDecls));
42
51
  }
43
52
  }
44
- function walkRules(options) {
53
+ function walkRules(page) {
45
54
  return (rule) => {
46
55
  const state = { bg: false };
47
- rule.selector = (0, postcss_selector_parser_1.default)((selectors) => selectors.walk((selector) => transform(selector, state, options))).processSync(rule.selector);
56
+ rule.selector = (0, postcss_selector_parser_1.default)((selectors) => selectors.walk((selector) => transform(selector, page, state))).processSync(rule.selector);
48
57
  state.bg && createBodyBackgroundRule(rule);
49
58
  };
50
59
  }
@@ -57,42 +66,8 @@ function walkDecls(rpx2unit) {
57
66
  decl.value = rpx2unit(decl.value);
58
67
  };
59
68
  }
60
- const baiduTags = {
61
- navigator: 'nav',
62
- };
63
- function rewriteBaiduTags(tag) {
64
- return baiduTags[tag] || tag;
65
- }
66
- function rewriteUniH5Tags(tag) {
67
- if (tag === 'page') {
68
- return 'uni-page-body';
69
- }
70
- if ((0, uni_shared_1.isBuiltInComponent)(tag)) {
71
- return uni_shared_1.COMPONENT_SELECTOR_PREFIX + tag;
72
- }
73
- return tag;
74
- }
75
- function rewriteUniAppTags(tag) {
76
- if (tag === 'page') {
77
- return 'body';
78
- }
79
- if ((0, uni_shared_1.isBuiltInComponent)(tag)) {
80
- return uni_shared_1.COMPONENT_SELECTOR_PREFIX + tag;
81
- }
82
- return tag;
83
- }
84
- const transforms = {
85
- h5: rewriteUniH5Tags,
86
- app: rewriteUniAppTags,
87
- 'mp-baidu': rewriteBaiduTags,
88
- };
89
69
  const uniapp = (opts) => {
90
- const platform = process.env.UNI_PLATFORM;
91
- if (!opts) {
92
- const inputDir = process.env.UNI_INPUT_DIR;
93
- opts = (0, shared_1.extend)((0, manifest_1.parseRpx2UnitOnce)(inputDir, platform));
94
- }
95
- const { unit, unitRatio, unitPrecision } = (0, shared_1.extend)({}, defaultUniAppCssProcessorOptions, opts || {});
70
+ const { page, unit, unitRatio, unitPrecision } = (0, shared_1.extend)({}, defaultUniAppCssProcessorOptions, opts || {});
96
71
  const rpx2unit = (0, uni_shared_1.createRpx2Unit)(unit, unitRatio, unitPrecision);
97
72
  return {
98
73
  postcssPlugin: 'uni-app',
@@ -100,12 +75,7 @@ const uniapp = (opts) => {
100
75
  return {
101
76
  OnceExit(root) {
102
77
  root.walkDecls(walkDecls(rpx2unit));
103
- const rewriteTag = transforms[platform];
104
- if (rewriteTag) {
105
- root.walkRules(walkRules({
106
- rewriteTag,
107
- }));
108
- }
78
+ root.walkRules(walkRules(page));
109
79
  },
110
80
  };
111
81
  },
@@ -14,7 +14,6 @@ const DEFAULT_KEYS = [
14
14
  'MP_ALIPAY',
15
15
  'MP_BAIDU',
16
16
  'MP_QQ',
17
- 'MP_LARK',
18
17
  'MP_TOUTIAO',
19
18
  'MP_WEIXIN',
20
19
  'MP_KUAISHOU',
@@ -0,0 +1,16 @@
1
+ export declare function isWxs(id: string): boolean;
2
+ export declare function isRenderjs(id: string): boolean;
3
+ export declare function parseRenderjs(id: string): {
4
+ readonly type: "wxs";
5
+ readonly name: string;
6
+ readonly filename: string;
7
+ } | {
8
+ readonly type: "renderjs";
9
+ readonly name: string;
10
+ readonly filename: string;
11
+ } | {
12
+ readonly type: "";
13
+ readonly name: "";
14
+ readonly filename: "";
15
+ };
16
+ export declare function missingModuleName(type: 'wxs' | 'renderjs', code: string): string;