@dcloudio/uni-cli-shared 3.0.0-alpha-3021020211012004 → 3.0.0-alpha-3021020211027001

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 (65) hide show
  1. package/dist/constants.d.ts +1 -0
  2. package/dist/constants.js +2 -1
  3. package/dist/easycom.d.ts +3 -0
  4. package/dist/easycom.js +22 -2
  5. package/dist/env/define.d.ts +1 -0
  6. package/dist/env/define.js +4 -0
  7. package/dist/exports.d.ts +1 -0
  8. package/dist/exports.js +8 -0
  9. package/dist/filter.d.ts +16 -0
  10. package/dist/filter.js +60 -0
  11. package/dist/hbx/log.d.ts +1 -0
  12. package/dist/hbx/log.js +10 -1
  13. package/dist/index.d.ts +4 -1
  14. package/dist/index.js +4 -1
  15. package/dist/json/app/pages/nvue.js +1 -1
  16. package/dist/json/manifest.d.ts +1 -1
  17. package/dist/json/manifest.js +9 -3
  18. package/dist/json/mp/index.d.ts +1 -0
  19. package/dist/json/mp/index.js +11 -0
  20. package/dist/json/mp/jsonFile.d.ts +7 -6
  21. package/dist/json/mp/jsonFile.js +56 -13
  22. package/dist/json/mp/pages.d.ts +1 -0
  23. package/dist/json/mp/pages.js +8 -0
  24. package/dist/json/mp/types.d.ts +1 -0
  25. package/dist/json/mp/utils.js +6 -2
  26. package/dist/logs/format.d.ts +1 -0
  27. package/dist/logs/format.js +14 -1
  28. package/dist/logs/index.d.ts +1 -1
  29. package/dist/logs/index.js +2 -1
  30. package/dist/messages/index.d.ts +2 -0
  31. package/dist/messages/index.js +2 -0
  32. package/dist/mp/event.d.ts +5 -0
  33. package/dist/mp/event.js +30 -0
  34. package/dist/mp/imports.d.ts +5 -0
  35. package/dist/mp/imports.js +63 -0
  36. package/dist/mp/index.d.ts +5 -0
  37. package/dist/mp/index.js +19 -0
  38. package/dist/mp/nvue.d.ts +1 -0
  39. package/dist/mp/nvue.js +18 -0
  40. package/dist/mp/style.d.ts +1 -0
  41. package/dist/mp/style.js +10 -0
  42. package/dist/mp/template.d.ts +25 -0
  43. package/dist/mp/template.js +73 -0
  44. package/dist/mp/transformImports.d.ts +14 -0
  45. package/dist/mp/transformImports.js +175 -0
  46. package/dist/postcss/plugins/uniapp.js +1 -1
  47. package/dist/utils.d.ts +4 -1
  48. package/dist/utils.js +31 -7
  49. package/dist/vite/index.d.ts +2 -2
  50. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
  51. package/dist/vite/plugins/vitejs/plugins/asset.js +28 -21
  52. package/dist/vite/plugins/vitejs/plugins/css.d.ts +3 -3
  53. package/dist/vite/plugins/vitejs/plugins/css.js +12 -21
  54. package/dist/vite/utils/plugin.d.ts +3 -3
  55. package/dist/vite/utils/plugin.js +2 -2
  56. package/dist/vue/transforms/index.d.ts +2 -0
  57. package/dist/vue/transforms/index.js +14 -0
  58. package/dist/vue/transforms/transformComponent.d.ts +2 -0
  59. package/dist/vue/transforms/transformComponent.js +25 -0
  60. package/dist/vue/transforms/transformPageHead.d.ts +2 -0
  61. package/dist/vue/transforms/transformPageHead.js +7 -0
  62. package/lib/nvue.css +1 -0
  63. package/package.json +6 -4
  64. package/dist/renderjs.d.ts +0 -16
  65. package/dist/renderjs.js +0 -44
@@ -3,6 +3,7 @@ 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 BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
6
7
  export declare const PAGE_EXTNAME_APP: string[];
7
8
  export declare const PAGE_EXTNAME: string[];
8
9
  export declare const H5_API_STYLE_PATH = "@dcloudio/uni-h5/style/api/";
package/dist/constants.js CHANGED
@@ -1,11 +1,12 @@
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.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.BINDING_COMPONENTS = 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.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
9
10
  // APP 平台解析页面后缀的优先级
10
11
  exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
11
12
  // 其他平台解析页面后缀的优先级
package/dist/easycom.d.ts CHANGED
@@ -20,4 +20,7 @@ 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[];
23
26
  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.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
6
+ exports.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = 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)('uni:easycom');
16
+ const debugEasycom = (0, debug_1.default)('vite:uni:easycom');
17
17
  const easycoms = [];
18
18
  const easycomsCache = new Map();
19
19
  const easycomsInvalidCache = new Set();
@@ -178,3 +178,23 @@ 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,5 +1,6 @@
1
1
  export declare function initDefine(stringifyBoolean?: boolean): {
2
2
  'process.env.NODE_ENV': string;
3
+ 'process.env.UNI_DEBUG': string | boolean;
3
4
  'process.env.UNI_APP_ID': string;
4
5
  'process.env.UNI_APP_NAME': string;
5
6
  'process.env.UNI_PLATFORM': string;
@@ -6,8 +6,12 @@ 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;
9
10
  return {
10
11
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
12
+ 'process.env.UNI_DEBUG': stringifyBoolean
13
+ ? JSON.stringify(isDebug)
14
+ : isDebug,
11
15
  'process.env.UNI_APP_ID': JSON.stringify(manifestJson.appid || ''),
12
16
  'process.env.UNI_APP_NAME': JSON.stringify(manifestJson.name || ''),
13
17
  'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
@@ -0,0 +1 @@
1
+ export { default as chokidar } from 'chokidar';
@@ -0,0 +1,8 @@
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.chokidar = void 0;
7
+ var chokidar_1 = require("chokidar");
8
+ Object.defineProperty(exports, "chokidar", { enumerable: true, get: function () { return __importDefault(chokidar_1).default; } });
@@ -0,0 +1,16 @@
1
+ export declare function isWxs(id: string): boolean;
2
+ export declare function isSjs(id: string): boolean;
3
+ export declare function isRenderjs(id: string): boolean;
4
+ declare type FilterType = 'wxs' | 'renderjs' | 'sjs';
5
+ export declare function parseRenderjs(id: string): {
6
+ type: FilterType;
7
+ name: string;
8
+ filename: string;
9
+ } | {
10
+ readonly type: "";
11
+ readonly name: "";
12
+ readonly filename: "";
13
+ };
14
+ export declare function missingModuleName(type: FilterType, code: string): string;
15
+ export declare function parseFilterNames(lang: string, code: string): string[];
16
+ export {};
package/dist/filter.js ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFilterNames = exports.missingModuleName = exports.parseRenderjs = exports.isRenderjs = exports.isSjs = exports.isWxs = void 0;
4
+ const url_1 = require("./vite/utils/url");
5
+ const WXS_RE = /vue&type=wxs/;
6
+ function isWxs(id) {
7
+ return WXS_RE.test(id);
8
+ }
9
+ exports.isWxs = isWxs;
10
+ const SJS_RE = /vue&type=sjs/;
11
+ function isSjs(id) {
12
+ return SJS_RE.test(id);
13
+ }
14
+ exports.isSjs = isSjs;
15
+ const RENDERJS_RE = /vue&type=renderjs/;
16
+ function isRenderjs(id) {
17
+ return RENDERJS_RE.test(id);
18
+ }
19
+ exports.isRenderjs = isRenderjs;
20
+ function parseRenderjs(id) {
21
+ if (isWxs(id) || isRenderjs(id) || isSjs(id)) {
22
+ const { query, filename } = (0, url_1.parseVueRequest)(id);
23
+ return {
24
+ type: query.type,
25
+ name: query.name,
26
+ filename,
27
+ };
28
+ }
29
+ return {
30
+ type: '',
31
+ name: '',
32
+ filename: '',
33
+ };
34
+ }
35
+ exports.parseRenderjs = parseRenderjs;
36
+ function missingModuleName(type, code) {
37
+ return `<script module="missing module name" lang="${type}">
38
+ ${code}
39
+ </script>`;
40
+ }
41
+ exports.missingModuleName = missingModuleName;
42
+ const moduleRE = /module=["'](.*?)["']/;
43
+ function parseFilterNames(lang, code) {
44
+ const names = [];
45
+ const scriptTags = code.match(/<script\b[^>]*>/gm);
46
+ if (!scriptTags) {
47
+ return names;
48
+ }
49
+ const langRE = new RegExp(`lang=["']${lang}["']`);
50
+ scriptTags.forEach((scriptTag) => {
51
+ if (langRE.test(scriptTag)) {
52
+ const matches = scriptTag.match(moduleRE);
53
+ if (matches) {
54
+ names.push(matches[1]);
55
+ }
56
+ }
57
+ });
58
+ return names;
59
+ }
60
+ exports.parseFilterNames = parseFilterNames;
package/dist/hbx/log.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { Formatter } from '../logs/format';
2
2
  export declare const h5ServeFormatter: Formatter;
3
3
  export declare const removeInfoFormatter: Formatter;
4
+ export declare const removeWarnFormatter: Formatter;
package/dist/hbx/log.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeInfoFormatter = exports.h5ServeFormatter = void 0;
3
+ exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = void 0;
4
4
  const SIGNAL_H5_LOCAL = ' > Local:';
5
5
  const SIGNAL_H5_NETWORK = ' > Network:';
6
6
  const networkLogs = [];
@@ -40,3 +40,12 @@ exports.removeInfoFormatter = {
40
40
  return '';
41
41
  },
42
42
  };
43
+ const REMOVED_WARN_MSGS = ['warnings when minifying css:'];
44
+ exports.removeWarnFormatter = {
45
+ test(msg) {
46
+ return !!REMOVED_WARN_MSGS.find((m) => msg.includes(m));
47
+ },
48
+ format() {
49
+ return '';
50
+ },
51
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './fs';
2
+ export * from './mp';
2
3
  export * from './env';
3
4
  export * from './hbx';
4
5
  export * from './logs';
@@ -12,7 +13,9 @@ export * from './easycom';
12
13
  export * from './constants';
13
14
  export * from './preprocess';
14
15
  export * from './postcss';
15
- export * from './renderjs';
16
+ export * from './filter';
16
17
  export * from './esbuild';
18
+ export * from './vue/transforms';
17
19
  export { M } from './messages';
20
+ export * from './exports';
18
21
  export { checkUpdate } from './checkUpdate';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.checkUpdate = exports.M = void 0;
14
14
  __exportStar(require("./fs"), exports);
15
+ __exportStar(require("./mp"), exports);
15
16
  __exportStar(require("./env"), exports);
16
17
  __exportStar(require("./hbx"), exports);
17
18
  __exportStar(require("./logs"), exports);
@@ -25,9 +26,11 @@ __exportStar(require("./easycom"), exports);
25
26
  __exportStar(require("./constants"), exports);
26
27
  __exportStar(require("./preprocess"), exports);
27
28
  __exportStar(require("./postcss"), exports);
28
- __exportStar(require("./renderjs"), exports);
29
+ __exportStar(require("./filter"), exports);
29
30
  __exportStar(require("./esbuild"), exports);
31
+ __exportStar(require("./vue/transforms"), exports);
30
32
  var messages_1 = require("./messages");
31
33
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
34
+ __exportStar(require("./exports"), exports);
32
35
  var checkUpdate_1 = require("./checkUpdate");
33
36
  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)(path.split('?')[0]);
23
+ const subNVuePath = (0, utils_1.removeExt)((0, utils_1.normalizePath)(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) => any;
3
+ export declare const parseRpx2UnitOnce: (inputDir: string, platform?: UniApp.PLATFORM) => any;
4
4
  interface CompilerCompatConfig {
5
5
  MODE?: 2 | 3;
6
6
  }
@@ -14,9 +14,15 @@ 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) => {
18
- const { h5 } = (0, exports.parseManifestJsonOnce)(inputDir);
19
- return (0, shared_1.extend)({}, uni_shared_1.defaultRpx2Unit, (h5 && h5.rpx) || {});
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);
20
26
  });
21
27
  function parseCompatConfig(_inputDir) {
22
28
  // 不支持 mode:2
@@ -1,3 +1,4 @@
1
+ export * from './jsonFile';
1
2
  export { AppJson } from './types';
2
3
  export { parseMiniProgramPagesJson } from './pages';
3
4
  export { parseMiniProgramProjectJson } from './project';
@@ -1,6 +1,17 @@
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
+ };
2
12
  Object.defineProperty(exports, "__esModule", { value: true });
3
13
  exports.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = void 0;
14
+ __exportStar(require("./jsonFile"), exports);
4
15
  var pages_1 = require("./pages");
5
16
  Object.defineProperty(exports, "parseMiniProgramPagesJson", { enumerable: true, get: function () { return pages_1.parseMiniProgramPagesJson; } });
6
17
  var project_1 = require("./project");
@@ -1,7 +1,8 @@
1
1
  import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
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;
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;
@@ -1,18 +1,61 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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);
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));
9
15
  }
10
- exports.addPageJson = addPageJson;
11
- function addComponentJson(filename, json) {
12
- exports.jsonComponentsCache.set(filename, json);
16
+ exports.hasJsonFile = hasJsonFile;
17
+ function normalizeJsonFilename(filename) {
18
+ return (0, utils_1.normalizeNodeModules)(filename);
13
19
  }
14
- exports.addComponentJson = addComponentJson;
15
- function addUsingComponents(filename, json) {
16
- exports.jsonUsingComponentsCache.set(filename, json);
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;
17
44
  }
18
- exports.addUsingComponents = addUsingComponents;
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;
@@ -11,5 +11,6 @@ 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[];
14
15
  };
15
16
  export {};
@@ -4,6 +4,7 @@ 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"));
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const shared_1 = require("@vue/shared");
9
10
  const json_1 = require("../json");
@@ -21,12 +22,18 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
21
22
  pages: [],
22
23
  };
23
24
  const pageJsons = {};
25
+ const nvuePages = [];
24
26
  // preprocess
25
27
  const pagesJson = (0, json_1.parseJson)(jsonStr, true);
26
28
  if (!pagesJson) {
27
29
  throw new Error(`[vite] Error: pages.json parse failed.\n`);
28
30
  }
29
31
  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
+ }
30
37
  pageJsons[pagePath] = (0, utils_1.parseWindowOptions)(style, platform, windowOptionsMap);
31
38
  }
32
39
  // pages
@@ -89,5 +96,6 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
89
96
  return {
90
97
  appJson,
91
98
  pageJsons,
99
+ nvuePages,
92
100
  };
93
101
  }
@@ -18,6 +18,7 @@ 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;
21
22
  disableScroll?: boolean;
22
23
  usingComponents?: UsingComponents;
23
24
  initialRenderingCache?: 'static' | string;
@@ -23,11 +23,15 @@ function convert(to, from, map) {
23
23
  }
24
24
  function parseWindowOptions(style, platform, windowOptionsMap) {
25
25
  if (!style) {
26
- return {};
26
+ return {
27
+ component: true,
28
+ };
27
29
  }
28
30
  const platformStyle = style[platform] || {};
29
31
  (0, pages_1.removePlatformStyle)(trimJson(style));
30
- const res = {};
32
+ const res = {
33
+ component: true,
34
+ };
31
35
  if (windowOptionsMap) {
32
36
  return (0, shared_1.extend)(convert(res, style, windowOptionsMap), platformStyle);
33
37
  }
@@ -4,3 +4,4 @@ export interface Formatter {
4
4
  }
5
5
  export declare function formatErrMsg(msg: string): string;
6
6
  export declare function formatInfoMsg(msg: string): string;
7
+ export declare function formatWarnMsg(msg: string): string;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatInfoMsg = exports.formatErrMsg = void 0;
3
+ exports.formatWarnMsg = exports.formatInfoMsg = exports.formatErrMsg = void 0;
4
4
  const uni_shared_1 = require("@dcloudio/uni-shared");
5
5
  const env_1 = require("../hbx/env");
6
6
  const alias_1 = require("../hbx/alias");
7
7
  const log_1 = require("../hbx/log");
8
8
  const errFormatters = [];
9
9
  const infoFormatters = [];
10
+ const warnFormatters = [];
10
11
  const initErrFormattersOnce = (0, uni_shared_1.once)(() => {
11
12
  if ((0, env_1.isInHBuilderX)()) {
12
13
  errFormatters.push(alias_1.moduleAliasFormatter);
@@ -23,6 +24,9 @@ const initInfoFormattersOnce = (0, uni_shared_1.once)(() => {
23
24
  }
24
25
  infoFormatters.push(log_1.removeInfoFormatter);
25
26
  });
27
+ const initWarnFormattersOnce = (0, uni_shared_1.once)(() => {
28
+ warnFormatters.push(log_1.removeWarnFormatter);
29
+ });
26
30
  function formatErrMsg(msg) {
27
31
  initErrFormattersOnce();
28
32
  const formatter = errFormatters.find(({ test }) => test(msg));
@@ -41,3 +45,12 @@ function formatInfoMsg(msg) {
41
45
  return msg;
42
46
  }
43
47
  exports.formatInfoMsg = formatInfoMsg;
48
+ function formatWarnMsg(msg) {
49
+ initWarnFormattersOnce();
50
+ const formatter = warnFormatters.find(({ test }) => test(msg));
51
+ if (formatter) {
52
+ return formatter.format(msg);
53
+ }
54
+ return msg;
55
+ }
56
+ exports.formatWarnMsg = formatWarnMsg;
@@ -1 +1 @@
1
- export { formatErrMsg, formatInfoMsg } from './format';
1
+ export { formatErrMsg, formatInfoMsg, formatWarnMsg } from './format';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatInfoMsg = exports.formatErrMsg = void 0;
3
+ exports.formatWarnMsg = exports.formatInfoMsg = exports.formatErrMsg = void 0;
4
4
  var format_1 = require("./format");
5
5
  Object.defineProperty(exports, "formatErrMsg", { enumerable: true, get: function () { return format_1.formatErrMsg; } });
6
6
  Object.defineProperty(exports, "formatInfoMsg", { enumerable: true, get: function () { return format_1.formatInfoMsg; } });
7
+ Object.defineProperty(exports, "formatWarnMsg", { enumerable: true, get: function () { return format_1.formatWarnMsg; } });
@@ -13,4 +13,6 @@ 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;
16
18
  };
@@ -16,4 +16,6 @@ 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}需要两个参数',
19
21
  };
@@ -0,0 +1,5 @@
1
+ export declare function formatMiniProgramEvent(eventName: string, { isCatch, isCapture, isComponent, }: {
2
+ isCatch?: boolean;
3
+ isCapture?: boolean;
4
+ isComponent?: boolean;
5
+ }): string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatMiniProgramEvent = void 0;
4
+ function formatMiniProgramEvent(eventName, { isCatch, isCapture, isComponent, }) {
5
+ if (!isComponent && eventName === 'click') {
6
+ eventName = 'tap';
7
+ }
8
+ let eventType = 'bind';
9
+ if (isCatch) {
10
+ eventType = 'catch';
11
+ }
12
+ if (isCapture) {
13
+ return `capture-${eventType}:${eventName}`;
14
+ }
15
+ // bind:foo-bar
16
+ return eventType + (isSimpleExpr(eventName) ? '' : ':') + eventName;
17
+ }
18
+ 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
+ }
@@ -0,0 +1,5 @@
1
+ import { PluginContext } from 'rollup';
2
+ import { ImportSpecifier } from 'es-module-lexer';
3
+ export declare function findVueComponentImports(source: string, importer: string, resolve: PluginContext['resolve']): Promise<(ImportSpecifier & {
4
+ i: string;
5
+ })[]>;