@dcloudio/uni-cli-shared 0.0.1-nvue3.3030820220125001

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 (236) hide show
  1. package/dist/checkUpdate.d.ts +30 -0
  2. package/dist/checkUpdate.js +243 -0
  3. package/dist/constants.d.ts +19 -0
  4. package/dist/constants.js +43 -0
  5. package/dist/deps.d.ts +19 -0
  6. package/dist/deps.js +39 -0
  7. package/dist/easycom.d.ts +29 -0
  8. package/dist/easycom.js +202 -0
  9. package/dist/env/define.d.ts +15 -0
  10. package/dist/env/define.js +45 -0
  11. package/dist/env/index.d.ts +2 -0
  12. package/dist/env/index.js +8 -0
  13. package/dist/env/provide.d.ts +9 -0
  14. package/dist/env/provide.js +24 -0
  15. package/dist/esbuild.d.ts +3 -0
  16. package/dist/esbuild.js +42 -0
  17. package/dist/exports.d.ts +1 -0
  18. package/dist/exports.js +8 -0
  19. package/dist/filter.d.ts +16 -0
  20. package/dist/filter.js +60 -0
  21. package/dist/fs.d.ts +1 -0
  22. package/dist/fs.js +25 -0
  23. package/dist/hbx/alias.d.ts +5 -0
  24. package/dist/hbx/alias.js +75 -0
  25. package/dist/hbx/env.d.ts +6 -0
  26. package/dist/hbx/env.js +44 -0
  27. package/dist/hbx/index.d.ts +3 -0
  28. package/dist/hbx/index.js +36 -0
  29. package/dist/hbx/log.d.ts +6 -0
  30. package/dist/hbx/log.js +99 -0
  31. package/dist/i18n.d.ts +10 -0
  32. package/dist/i18n.js +94 -0
  33. package/dist/index.d.ts +25 -0
  34. package/dist/index.js +40 -0
  35. package/dist/json/app/index.d.ts +3 -0
  36. package/dist/json/app/index.js +17 -0
  37. package/dist/json/app/manifest/arguments.d.ts +2 -0
  38. package/dist/json/app/manifest/arguments.js +36 -0
  39. package/dist/json/app/manifest/confusion.d.ts +4 -0
  40. package/dist/json/app/manifest/confusion.js +77 -0
  41. package/dist/json/app/manifest/defaultManifestJson.d.ts +1 -0
  42. package/dist/json/app/manifest/defaultManifestJson.js +41 -0
  43. package/dist/json/app/manifest/env.d.ts +3 -0
  44. package/dist/json/app/manifest/env.js +24 -0
  45. package/dist/json/app/manifest/i18n.d.ts +1 -0
  46. package/dist/json/app/manifest/i18n.js +14 -0
  47. package/dist/json/app/manifest/index.d.ts +4 -0
  48. package/dist/json/app/manifest/index.js +49 -0
  49. package/dist/json/app/manifest/launchwebview.d.ts +1 -0
  50. package/dist/json/app/manifest/launchwebview.js +32 -0
  51. package/dist/json/app/manifest/merge.d.ts +1 -0
  52. package/dist/json/app/manifest/merge.js +17 -0
  53. package/dist/json/app/manifest/nvue.d.ts +4 -0
  54. package/dist/json/app/manifest/nvue.js +43 -0
  55. package/dist/json/app/manifest/plus.d.ts +1 -0
  56. package/dist/json/app/manifest/plus.js +83 -0
  57. package/dist/json/app/manifest/safearea.d.ts +1 -0
  58. package/dist/json/app/manifest/safearea.js +28 -0
  59. package/dist/json/app/manifest/splashscreen.d.ts +5 -0
  60. package/dist/json/app/manifest/splashscreen.js +44 -0
  61. package/dist/json/app/manifest/statusbar.d.ts +1 -0
  62. package/dist/json/app/manifest/statusbar.js +14 -0
  63. package/dist/json/app/manifest/tabBar.d.ts +1 -0
  64. package/dist/json/app/manifest/tabBar.js +27 -0
  65. package/dist/json/app/manifest/uniApp.d.ts +1 -0
  66. package/dist/json/app/manifest/uniApp.js +19 -0
  67. package/dist/json/app/pages/code.d.ts +3 -0
  68. package/dist/json/app/pages/code.js +44 -0
  69. package/dist/json/app/pages/definePage.d.ts +2 -0
  70. package/dist/json/app/pages/definePage.js +42 -0
  71. package/dist/json/app/pages/index.d.ts +3 -0
  72. package/dist/json/app/pages/index.js +28 -0
  73. package/dist/json/app/pages/uniConfig.d.ts +1 -0
  74. package/dist/json/app/pages/uniConfig.js +69 -0
  75. package/dist/json/app/pages/uniRoutes.d.ts +1 -0
  76. package/dist/json/app/pages/uniRoutes.js +8 -0
  77. package/dist/json/index.d.ts +5 -0
  78. package/dist/json/index.js +17 -0
  79. package/dist/json/json.d.ts +1 -0
  80. package/dist/json/json.js +9 -0
  81. package/dist/json/manifest.d.ts +28 -0
  82. package/dist/json/manifest.js +64 -0
  83. package/dist/json/mp/index.d.ts +4 -0
  84. package/dist/json/mp/index.js +19 -0
  85. package/dist/json/mp/jsonFile.d.ts +23 -0
  86. package/dist/json/mp/jsonFile.js +127 -0
  87. package/dist/json/mp/pages.d.ts +17 -0
  88. package/dist/json/mp/pages.js +126 -0
  89. package/dist/json/mp/project.d.ts +14 -0
  90. package/dist/json/mp/project.js +81 -0
  91. package/dist/json/mp/types.d.ts +118 -0
  92. package/dist/json/mp/types.js +2 -0
  93. package/dist/json/mp/utils.d.ts +3 -0
  94. package/dist/json/mp/utils.js +66 -0
  95. package/dist/json/pages.d.ts +30 -0
  96. package/dist/json/pages.js +383 -0
  97. package/dist/logs/console.d.ts +4 -0
  98. package/dist/logs/console.js +49 -0
  99. package/dist/logs/format.d.ts +11 -0
  100. package/dist/logs/format.js +82 -0
  101. package/dist/logs/index.d.ts +1 -0
  102. package/dist/logs/index.js +7 -0
  103. package/dist/messages/index.d.ts +20 -0
  104. package/dist/messages/index.js +23 -0
  105. package/dist/mp/ast.d.ts +4 -0
  106. package/dist/mp/ast.js +12 -0
  107. package/dist/mp/constants.d.ts +5 -0
  108. package/dist/mp/constants.js +8 -0
  109. package/dist/mp/event.d.ts +5 -0
  110. package/dist/mp/event.js +35 -0
  111. package/dist/mp/externalClasses.d.ts +5 -0
  112. package/dist/mp/externalClasses.js +42 -0
  113. package/dist/mp/imports.d.ts +12 -0
  114. package/dist/mp/imports.js +72 -0
  115. package/dist/mp/index.d.ts +11 -0
  116. package/dist/mp/index.js +38 -0
  117. package/dist/mp/nvue.d.ts +1 -0
  118. package/dist/mp/nvue.js +18 -0
  119. package/dist/mp/plugin.d.ts +2 -0
  120. package/dist/mp/plugin.js +13 -0
  121. package/dist/mp/style.d.ts +1 -0
  122. package/dist/mp/style.js +9 -0
  123. package/dist/mp/tags.d.ts +1 -0
  124. package/dist/mp/tags.js +117 -0
  125. package/dist/mp/template.d.ts +73 -0
  126. package/dist/mp/template.js +73 -0
  127. package/dist/mp/usingComponents.d.ts +65 -0
  128. package/dist/mp/usingComponents.js +402 -0
  129. package/dist/mp/wxs.d.ts +2 -0
  130. package/dist/mp/wxs.js +55 -0
  131. package/dist/platform.d.ts +2 -0
  132. package/dist/platform.js +31 -0
  133. package/dist/postcss/index.d.ts +10 -0
  134. package/dist/postcss/index.js +19 -0
  135. package/dist/postcss/plugins/stylePluginScoped.d.ts +3 -0
  136. package/dist/postcss/plugins/stylePluginScoped.js +176 -0
  137. package/dist/postcss/plugins/uniapp.d.ts +11 -0
  138. package/dist/postcss/plugins/uniapp.js +110 -0
  139. package/dist/preprocess/context.d.ts +3 -0
  140. package/dist/preprocess/context.js +81 -0
  141. package/dist/preprocess/index.d.ts +9 -0
  142. package/dist/preprocess/index.js +28 -0
  143. package/dist/resolve.d.ts +6 -0
  144. package/dist/resolve.js +102 -0
  145. package/dist/scripts.d.ts +10 -0
  146. package/dist/scripts.js +44 -0
  147. package/dist/ssr.d.ts +4 -0
  148. package/dist/ssr.js +20 -0
  149. package/dist/url.d.ts +2 -0
  150. package/dist/url.js +15 -0
  151. package/dist/utils.d.ts +13 -0
  152. package/dist/utils.js +80 -0
  153. package/dist/vite/features.d.ts +41 -0
  154. package/dist/vite/features.js +191 -0
  155. package/dist/vite/index.d.ts +36 -0
  156. package/dist/vite/index.js +17 -0
  157. package/dist/vite/plugins/console.d.ts +8 -0
  158. package/dist/vite/plugins/console.js +42 -0
  159. package/dist/vite/plugins/copy.d.ts +11 -0
  160. package/dist/vite/plugins/copy.js +51 -0
  161. package/dist/vite/plugins/cssScoped.d.ts +6 -0
  162. package/dist/vite/plugins/cssScoped.js +54 -0
  163. package/dist/vite/plugins/dynamicImportPolyfill.d.ts +2 -0
  164. package/dist/vite/plugins/dynamicImportPolyfill.js +15 -0
  165. package/dist/vite/plugins/index.d.ts +10 -0
  166. package/dist/vite/plugins/index.js +32 -0
  167. package/dist/vite/plugins/inject.d.ts +12 -0
  168. package/dist/vite/plugins/inject.js +207 -0
  169. package/dist/vite/plugins/jsonJs.d.ts +3 -0
  170. package/dist/vite/plugins/jsonJs.js +52 -0
  171. package/dist/vite/plugins/mainJs.d.ts +2 -0
  172. package/dist/vite/plugins/mainJs.js +29 -0
  173. package/dist/vite/plugins/vitejs/config.d.ts +1 -0
  174. package/dist/vite/plugins/vitejs/config.js +2 -0
  175. package/dist/vite/plugins/vitejs/constants.d.ts +8 -0
  176. package/dist/vite/plugins/vitejs/constants.js +11 -0
  177. package/dist/vite/plugins/vitejs/index.d.ts +1 -0
  178. package/dist/vite/plugins/vitejs/index.js +2 -0
  179. package/dist/vite/plugins/vitejs/plugin.d.ts +1 -0
  180. package/dist/vite/plugins/vitejs/plugin.js +2 -0
  181. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +40 -0
  182. package/dist/vite/plugins/vitejs/plugins/asset.js +270 -0
  183. package/dist/vite/plugins/vitejs/plugins/css.d.ts +48 -0
  184. package/dist/vite/plugins/vitejs/plugins/css.js +760 -0
  185. package/dist/vite/plugins/vitejs/server/moduleGraph.d.ts +1 -0
  186. package/dist/vite/plugins/vitejs/server/moduleGraph.js +2 -0
  187. package/dist/vite/plugins/vitejs/utils.d.ts +29 -0
  188. package/dist/vite/plugins/vitejs/utils.js +129 -0
  189. package/dist/vite/utils/ast.d.ts +17 -0
  190. package/dist/vite/utils/ast.js +85 -0
  191. package/dist/vite/utils/index.d.ts +7 -0
  192. package/dist/vite/utils/index.js +23 -0
  193. package/dist/vite/utils/plugin.d.ts +11 -0
  194. package/dist/vite/utils/plugin.js +45 -0
  195. package/dist/vite/utils/url.d.ts +28 -0
  196. package/dist/vite/utils/url.js +69 -0
  197. package/dist/vite/utils/utils.d.ts +3 -0
  198. package/dist/vite/utils/utils.js +14 -0
  199. package/dist/vue/babel.d.ts +3 -0
  200. package/dist/vue/babel.js +17 -0
  201. package/dist/vue/index.d.ts +4 -0
  202. package/dist/vue/index.js +19 -0
  203. package/dist/vue/transforms/index.d.ts +13 -0
  204. package/dist/vue/transforms/index.js +48 -0
  205. package/dist/vue/transforms/templateTransformAssetUrl.d.ts +33 -0
  206. package/dist/vue/transforms/templateTransformAssetUrl.js +150 -0
  207. package/dist/vue/transforms/templateTransformSrcset.d.ts +4 -0
  208. package/dist/vue/transforms/templateTransformSrcset.js +122 -0
  209. package/dist/vue/transforms/templateUtils.d.ts +9 -0
  210. package/dist/vue/transforms/templateUtils.js +41 -0
  211. package/dist/vue/transforms/transformComponent.d.ts +3 -0
  212. package/dist/vue/transforms/transformComponent.js +26 -0
  213. package/dist/vue/transforms/transformEvent.d.ts +2 -0
  214. package/dist/vue/transforms/transformEvent.js +28 -0
  215. package/dist/vue/transforms/transformPageHead.d.ts +2 -0
  216. package/dist/vue/transforms/transformPageHead.js +11 -0
  217. package/dist/vue/transforms/transformRef.d.ts +2 -0
  218. package/dist/vue/transforms/transformRef.js +32 -0
  219. package/dist/vue/transforms/transformTag.d.ts +2 -0
  220. package/dist/vue/transforms/transformTag.js +18 -0
  221. package/dist/vue/transforms/vModel.d.ts +12 -0
  222. package/dist/vue/transforms/vModel.js +33 -0
  223. package/dist/vue/transforms/vOn.d.ts +15 -0
  224. package/dist/vue/transforms/vOn.js +88 -0
  225. package/dist/vue/utils.d.ts +31 -0
  226. package/dist/vue/utils.js +120 -0
  227. package/dist/watcher.d.ts +30 -0
  228. package/dist/watcher.js +92 -0
  229. package/lib/crypto.js +65 -0
  230. package/lib/nvue.css +34 -0
  231. package/lib/preprocess/LICENSE +13 -0
  232. package/lib/preprocess/README.md +410 -0
  233. package/lib/preprocess/lib/preprocess.js +437 -0
  234. package/lib/preprocess/lib/regexrules.js +121 -0
  235. package/lib/preprocess/package.json +68 -0
  236. package/package.json +68 -0
package/dist/utils.js ADDED
@@ -0,0 +1,80 @@
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.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const os_1 = __importDefault(require("os"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const shared_1 = require("@vue/shared");
11
+ var hash_sum_1 = require("hash-sum");
12
+ Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_sum_1).default; } });
13
+ const constants_1 = require("./constants");
14
+ try {
15
+ exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
16
+ }
17
+ catch (_a) { }
18
+ exports.isWindows = os_1.default.platform() === 'win32';
19
+ function normalizePath(id) {
20
+ return exports.isWindows ? id.replace(/\\/g, '/') : id;
21
+ }
22
+ exports.normalizePath = normalizePath;
23
+ function checkElementNodeTag(node, tag) {
24
+ return !!node && node.type === 1 /* ELEMENT */ && node.tag === tag;
25
+ }
26
+ exports.checkElementNodeTag = checkElementNodeTag;
27
+ function normalizeIdentifier(str) {
28
+ return (0, shared_1.capitalize)((0, shared_1.camelize)(str.replace(/\//g, '-')));
29
+ }
30
+ exports.normalizeIdentifier = normalizeIdentifier;
31
+ function normalizePagePath(pagePath, platform) {
32
+ const absoltePagePath = path_1.default.resolve(process.env.UNI_INPUT_DIR, pagePath);
33
+ let extnames = constants_1.PAGE_EXTNAME;
34
+ if (platform === 'app') {
35
+ extnames = constants_1.PAGE_EXTNAME_APP;
36
+ }
37
+ for (let i = 0; i < extnames.length; i++) {
38
+ const extname = extnames[i];
39
+ if (fs_1.default.existsSync(absoltePagePath + extname)) {
40
+ return pagePath + extname;
41
+ }
42
+ }
43
+ console.error(`${pagePath} not found`);
44
+ }
45
+ exports.normalizePagePath = normalizePagePath;
46
+ function removeExt(str) {
47
+ return str.split('?')[0].replace(/\.\w+$/g, '');
48
+ }
49
+ exports.removeExt = removeExt;
50
+ const NODE_MODULES_REGEX = /(\.\.\/)?node_modules/g;
51
+ function normalizeNodeModules(str) {
52
+ str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');
53
+ // HBuilderX 内置模块路径转换
54
+ str = str.replace(/.*\/plugins\/uniapp-cli-vite\/node[-_]modules/, 'node-modules');
55
+ if (process.env.UNI_PLATFORM === 'mp-alipay') {
56
+ str = str.replace('node-modules/@', 'node-modules/npm-scope-');
57
+ }
58
+ return str;
59
+ }
60
+ exports.normalizeNodeModules = normalizeNodeModules;
61
+ function normalizeMiniProgramFilename(filename, inputDir) {
62
+ if (!inputDir || !path_1.default.isAbsolute(filename)) {
63
+ return normalizeNodeModules(filename);
64
+ }
65
+ return normalizeNodeModules(path_1.default.relative(inputDir, filename));
66
+ }
67
+ exports.normalizeMiniProgramFilename = normalizeMiniProgramFilename;
68
+ function normalizeParsePlugins(importer, babelParserPlugins) {
69
+ const isTS = constants_1.EXTNAME_TS_RE.test(importer.split('?')[0]);
70
+ const plugins = [];
71
+ if (isTS) {
72
+ plugins.push('jsx');
73
+ }
74
+ if (babelParserPlugins)
75
+ plugins.push(...babelParserPlugins);
76
+ if (isTS)
77
+ plugins.push('typescript', 'decorators-legacy');
78
+ return plugins;
79
+ }
80
+ exports.normalizeParsePlugins = normalizeParsePlugins;
@@ -0,0 +1,41 @@
1
+ import type { ConfigEnv } from 'vite';
2
+ export declare type FEATURE_DEFINES = ReturnType<typeof initFeatures>;
3
+ interface InitFeaturesOptions {
4
+ pagesJson: UniApp.PagesJson;
5
+ manifestJson: any;
6
+ inputDir: string;
7
+ platform: UniApp.PLATFORM;
8
+ command: ConfigEnv['command'];
9
+ ssr: boolean;
10
+ }
11
+ export declare function initFeatures(options: InitFeaturesOptions): {
12
+ __VUE_OPTIONS_API__: boolean;
13
+ __VUE_PROD_DEVTOOLS__: boolean;
14
+ __UNI_FEATURE_WX__: boolean;
15
+ __UNI_FEATURE_WXS__: boolean;
16
+ __UNI_FEATURE_RPX__: boolean;
17
+ __UNI_FEATURE_PROMISE__: boolean;
18
+ __UNI_FEATURE_LONGPRESS__: boolean;
19
+ __UNI_FEATURE_I18N_EN__: boolean;
20
+ __UNI_FEATURE_I18N_ES__: boolean;
21
+ __UNI_FEATURE_I18N_FR__: boolean;
22
+ __UNI_FEATURE_I18N_ZH_HANS__: boolean;
23
+ __UNI_FEATURE_I18N_ZH_HANT__: boolean;
24
+ __UNI_FEATURE_UNI_CLOUD__: boolean;
25
+ __UNI_FEATURE_I18N_LOCALE__: boolean;
26
+ __UNI_FEATURE_NVUE__: boolean;
27
+ __UNI_FEATURE_ROUTER_MODE__: "\"hash\"" | "\"history\"";
28
+ __UNI_FEATURE_PAGES__: boolean;
29
+ __UNI_FEATURE_TABBAR__: boolean;
30
+ __UNI_FEATURE_TABBAR_MIDBUTTON__: boolean;
31
+ __UNI_FEATURE_TOPWINDOW__: boolean;
32
+ __UNI_FEATURE_LEFTWINDOW__: boolean;
33
+ __UNI_FEATURE_RIGHTWINDOW__: boolean;
34
+ __UNI_FEATURE_RESPONSIVE__: boolean;
35
+ __UNI_FEATURE_NAVIGATIONBAR__: boolean;
36
+ __UNI_FEATURE_PULL_DOWN_REFRESH__: boolean;
37
+ __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: boolean;
38
+ __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: boolean;
39
+ __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__: boolean;
40
+ };
41
+ export {};
@@ -0,0 +1,191 @@
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.initFeatures = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const shared_1 = require("@vue/shared");
10
+ function initProjectFeature({ inputDir }) {
11
+ const features = {
12
+ i18nLocale: false,
13
+ i18nEn: true,
14
+ i18nEs: true,
15
+ i18nFr: true,
16
+ i18nZhHans: true,
17
+ i18nZhHant: true,
18
+ uniCloud: false,
19
+ };
20
+ const localesDir = path_1.default.resolve(inputDir, 'locale');
21
+ if (fs_1.default.existsSync(localesDir)) {
22
+ if (fs_1.default.readdirSync(localesDir).find((file) => path_1.default.extname(file) === '.json')) {
23
+ features.i18nLocale = true;
24
+ }
25
+ }
26
+ if (process.env.UNI_CLOUD_PROVIDER) {
27
+ try {
28
+ const providers = JSON.parse(process.env.UNI_CLOUD_PROVIDER);
29
+ if (providers.length) {
30
+ features.uniCloud = true;
31
+ }
32
+ }
33
+ catch (e) { }
34
+ }
35
+ return features;
36
+ }
37
+ function initPagesFeature({ pagesJson, command, inputDir, ssr, }) {
38
+ const features = {
39
+ nvue: true,
40
+ pages: true,
41
+ tabBar: true,
42
+ tabBarMidButton: true,
43
+ topWindow: false,
44
+ leftWindow: false,
45
+ rightWindow: false,
46
+ navigationBar: true,
47
+ pullDownRefresh: false,
48
+ navigationBarButtons: true,
49
+ navigationBarSearchInput: true,
50
+ navigationBarTransparent: true,
51
+ };
52
+ const { tabBar, pages, topWindow, leftWindow, rightWindow, globalStyle } = pagesJson;
53
+ // ssr 时强制启用多页面(需要用到router)
54
+ if (!ssr && pages && pages.length === 1) {
55
+ features.pages = false;
56
+ }
57
+ if (!(tabBar && tabBar.list && tabBar.list.length)) {
58
+ features.tabBar = false;
59
+ features.tabBarMidButton = false;
60
+ }
61
+ if (features.tabBar && !tabBar.midButton) {
62
+ features.tabBarMidButton = false;
63
+ }
64
+ if (topWindow && topWindow.path) {
65
+ features.topWindow = true;
66
+ }
67
+ if (leftWindow && leftWindow.path) {
68
+ features.leftWindow = true;
69
+ }
70
+ if (rightWindow && rightWindow.path) {
71
+ features.rightWindow = true;
72
+ }
73
+ if (globalStyle.enablePullDownRefresh) {
74
+ features.pullDownRefresh = true;
75
+ }
76
+ else {
77
+ if (pages.find((page) => page.style && page.style.enablePullDownRefresh)) {
78
+ features.pullDownRefresh = true;
79
+ }
80
+ }
81
+ if (command === 'build') {
82
+ if (!pages.find((page) => fs_1.default.existsSync(path_1.default.resolve(inputDir, page.path + '.nvue')))) {
83
+ features.nvue = false;
84
+ }
85
+ let isNavigationCustom = false;
86
+ if (globalStyle.navigationBar.style === 'custom') {
87
+ isNavigationCustom = true; // 全局custom
88
+ if (pages.find((page) => page.style.navigationBar.style === 'default')) {
89
+ isNavigationCustom = false;
90
+ }
91
+ }
92
+ else {
93
+ // 所有页面均custom
94
+ if (pages.every((page) => page.style.navigationBar.style === 'custom')) {
95
+ isNavigationCustom = true;
96
+ }
97
+ }
98
+ if (isNavigationCustom) {
99
+ features.navigationBar = false;
100
+ features.navigationBarButtons = false;
101
+ features.navigationBarSearchInput = false;
102
+ features.navigationBarTransparent = false;
103
+ }
104
+ else {
105
+ if (!pages.find((page) => (0, shared_1.isArray)(page.style.navigationBar.buttons) &&
106
+ page.style.navigationBar.buttons.length)) {
107
+ features.navigationBarButtons = false;
108
+ }
109
+ if (!globalStyle.navigationBar.searchInput &&
110
+ !pages.find((page) => page.style.navigationBar.searchInput)) {
111
+ features.navigationBarSearchInput = false;
112
+ }
113
+ if (globalStyle.navigationBar.type !== 'transparent' &&
114
+ !pages.find((page) => page.style.navigationBar.type === 'transparent')) {
115
+ features.navigationBarTransparent = false;
116
+ }
117
+ }
118
+ }
119
+ return features;
120
+ }
121
+ function initManifestFeature({ manifestJson, command, platform, }) {
122
+ const features = {
123
+ wx: false,
124
+ wxs: true,
125
+ rpx: true,
126
+ promise: false,
127
+ longpress: true,
128
+ routerMode: '"hash"',
129
+ vueOptionsApi: true,
130
+ vueProdDevTools: false,
131
+ };
132
+ if (command === 'build') {
133
+ // TODO 需要预编译一遍?
134
+ // features.wxs = false
135
+ // features.longpress = false
136
+ }
137
+ if (manifestJson.h5 &&
138
+ manifestJson.h5.router &&
139
+ manifestJson.h5.router.mode === 'history') {
140
+ features.routerMode = '"history"';
141
+ }
142
+ // TODO other features
143
+ return features;
144
+ }
145
+ function initFeatures(options) {
146
+ const { wx, wxs, rpx, nvue, uniCloud, i18nEn, i18nEs, i18nFr, i18nZhHans, i18nZhHant, i18nLocale, vueOptionsApi, vueProdDevTools, pages, tabBar, tabBarMidButton, promise, longpress, routerMode, topWindow, leftWindow, rightWindow, navigationBar, pullDownRefresh, navigationBarButtons, navigationBarSearchInput, navigationBarTransparent, } = (0, shared_1.extend)(initManifestFeature(options), initPagesFeature(options), initProjectFeature(options));
147
+ const features = {
148
+ // vue
149
+ __VUE_OPTIONS_API__: vueOptionsApi,
150
+ __VUE_PROD_DEVTOOLS__: vueProdDevTools,
151
+ // uni
152
+ __UNI_FEATURE_WX__: wx,
153
+ __UNI_FEATURE_WXS__: wxs,
154
+ __UNI_FEATURE_RPX__: rpx,
155
+ __UNI_FEATURE_PROMISE__: promise,
156
+ __UNI_FEATURE_LONGPRESS__: longpress,
157
+ __UNI_FEATURE_I18N_EN__: i18nEn,
158
+ __UNI_FEATURE_I18N_ES__: i18nEs,
159
+ __UNI_FEATURE_I18N_FR__: i18nFr,
160
+ __UNI_FEATURE_I18N_ZH_HANS__: i18nZhHans,
161
+ __UNI_FEATURE_I18N_ZH_HANT__: i18nZhHant,
162
+ // 以下特性,编译器已自动识别是否需要启用
163
+ __UNI_FEATURE_UNI_CLOUD__: uniCloud,
164
+ __UNI_FEATURE_I18N_LOCALE__: i18nLocale,
165
+ __UNI_FEATURE_NVUE__: nvue,
166
+ __UNI_FEATURE_ROUTER_MODE__: routerMode,
167
+ __UNI_FEATURE_PAGES__: pages,
168
+ __UNI_FEATURE_TABBAR__: tabBar,
169
+ __UNI_FEATURE_TABBAR_MIDBUTTON__: tabBarMidButton,
170
+ __UNI_FEATURE_TOPWINDOW__: topWindow,
171
+ __UNI_FEATURE_LEFTWINDOW__: leftWindow,
172
+ __UNI_FEATURE_RIGHTWINDOW__: rightWindow,
173
+ __UNI_FEATURE_RESPONSIVE__: topWindow || leftWindow || rightWindow,
174
+ __UNI_FEATURE_NAVIGATIONBAR__: navigationBar,
175
+ __UNI_FEATURE_PULL_DOWN_REFRESH__: pullDownRefresh,
176
+ __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: navigationBarButtons,
177
+ __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: navigationBarSearchInput,
178
+ __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__: navigationBarTransparent, // 是否启用透明标题栏
179
+ };
180
+ // ssr nodejs features
181
+ if (options.ssr) {
182
+ Object.keys(features).forEach((name) => {
183
+ const value = features[name];
184
+ (0, shared_1.extend)(globalThis, {
185
+ [name]: (0, shared_1.isString)(value) ? JSON.parse(value) : value,
186
+ });
187
+ });
188
+ }
189
+ return features;
190
+ }
191
+ exports.initFeatures = initFeatures;
@@ -0,0 +1,36 @@
1
+ import type { Plugin } from 'vite';
2
+ import type { EmittedAsset } from 'rollup';
3
+ import type { ParserOptions } from '@vue/compiler-core';
4
+ import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
5
+ import { UniViteCopyPluginOptions } from './plugins/copy';
6
+ export declare const cssTarget = "chrome53";
7
+ export interface CopyOptions {
8
+ /**
9
+ * 静态资源,配置的目录,在 uni_modules 中同样支持
10
+ */
11
+ assets?: string[];
12
+ targets?: UniViteCopyPluginOptions['targets'];
13
+ }
14
+ interface UniVitePluginUniOptions {
15
+ compiler?: TemplateCompiler;
16
+ styleOptions?: Pick<SFCStyleCompileOptions, 'postcssPlugins'>;
17
+ compilerOptions?: {
18
+ miniProgram?: {
19
+ emitFile?: (emittedFile: EmittedAsset) => string;
20
+ };
21
+ isNativeTag?: ParserOptions['isNativeTag'];
22
+ isCustomElement?: ParserOptions['isCustomElement'];
23
+ directiveTransforms?: CompilerOptions['directiveTransforms'];
24
+ nodeTransforms?: CompilerOptions['nodeTransforms'];
25
+ };
26
+ jsxOptions?: {
27
+ babelPlugins?: any[];
28
+ };
29
+ copyOptions?: CopyOptions | (() => CopyOptions);
30
+ }
31
+ export interface UniVitePlugin extends Plugin {
32
+ uni?: UniVitePluginUniOptions;
33
+ }
34
+ export * from './utils';
35
+ export * from './plugins';
36
+ export * from './features';
@@ -0,0 +1,17 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.cssTarget = void 0;
14
+ exports.cssTarget = 'chrome53';
15
+ __exportStar(require("./utils"), exports);
16
+ __exportStar(require("./plugins"), exports);
17
+ __exportStar(require("./features"), exports);
@@ -0,0 +1,8 @@
1
+ import { Plugin } from 'vite';
2
+ import { FilterPattern } from '@rollup/pluginutils';
3
+ export interface ConsoleOptions {
4
+ filename?: (filename: string) => string;
5
+ include?: FilterPattern;
6
+ exclude?: FilterPattern;
7
+ }
8
+ export declare function uniConsolePlugin(options: ConsoleOptions): Plugin;
@@ -0,0 +1,42 @@
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.uniConsolePlugin = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const pluginutils_1 = require("@rollup/pluginutils");
9
+ const utils_1 = require("../utils");
10
+ const console_1 = require("../../logs/console");
11
+ const utils_2 = require("../../vite/utils/utils");
12
+ const debugConsole = (0, debug_1.default)('uni:console');
13
+ function uniConsolePlugin(options) {
14
+ const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
15
+ let resolvedConfig;
16
+ return {
17
+ name: 'uni:console',
18
+ enforce: 'pre',
19
+ configResolved(config) {
20
+ resolvedConfig = config;
21
+ },
22
+ transform(code, id) {
23
+ if (!filter(id))
24
+ return null;
25
+ if (!(0, utils_1.isJsFile)(id))
26
+ return null;
27
+ let { filename } = (0, utils_1.parseVueRequest)(id);
28
+ if (options.filename) {
29
+ filename = options.filename(filename);
30
+ }
31
+ if (!filename) {
32
+ return null;
33
+ }
34
+ if (!code.includes('console.')) {
35
+ return null;
36
+ }
37
+ debugConsole(id);
38
+ return (0, console_1.rewriteConsoleExpr)(id, filename, code, (0, utils_2.withSourcemap)(resolvedConfig));
39
+ },
40
+ };
41
+ }
42
+ exports.uniConsolePlugin = uniConsolePlugin;
@@ -0,0 +1,11 @@
1
+ import type { WatchOptions } from 'chokidar';
2
+ import type { Plugin } from 'vite';
3
+ import { FileWatcherOptions } from '../../watcher';
4
+ export declare type UniViteCopyPluginTarget = Omit<FileWatcherOptions, 'verbose'> & {
5
+ watchOptions?: WatchOptions;
6
+ };
7
+ export interface UniViteCopyPluginOptions {
8
+ targets: UniViteCopyPluginTarget[];
9
+ verbose: boolean;
10
+ }
11
+ export declare function uniViteCopyPlugin({ targets, verbose, }: UniViteCopyPluginOptions): Plugin;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uniViteCopyPlugin = void 0;
4
+ const watcher_1 = require("../../watcher");
5
+ const messages_1 = require("../../messages");
6
+ function uniViteCopyPlugin({ targets, verbose, }) {
7
+ let resolvedConfig;
8
+ let inited = false;
9
+ return {
10
+ name: 'uni:copy',
11
+ apply: 'build',
12
+ configResolved(config) {
13
+ resolvedConfig = config;
14
+ },
15
+ writeBundle() {
16
+ if (inited) {
17
+ return;
18
+ }
19
+ if (resolvedConfig.build.ssr) {
20
+ return;
21
+ }
22
+ inited = true;
23
+ return new Promise((resolve) => {
24
+ Promise.all(targets.map(({ watchOptions, ...target }) => {
25
+ return new Promise((resolve) => {
26
+ new watcher_1.FileWatcher({
27
+ verbose,
28
+ ...target,
29
+ }).watch({
30
+ cwd: process.env.UNI_INPUT_DIR,
31
+ ...watchOptions,
32
+ }, (watcher) => {
33
+ if (process.env.NODE_ENV !== 'development') {
34
+ // 生产模式下,延迟 close,否则会影响 chokidar 初始化的 add 等事件
35
+ setTimeout(() => {
36
+ watcher.close().then(() => resolve(void 0));
37
+ }, 1000);
38
+ }
39
+ else {
40
+ resolve(void 0);
41
+ }
42
+ }, () => {
43
+ console.log(messages_1.M['dev.watching.end']);
44
+ });
45
+ });
46
+ })).then(() => resolve());
47
+ });
48
+ },
49
+ };
50
+ }
51
+ exports.uniViteCopyPlugin = uniViteCopyPlugin;
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite';
2
+ interface UniCssScopedPluginOptions {
3
+ filter: (id: string) => boolean;
4
+ }
5
+ export declare function uniCssScopedPlugin({ filter }?: UniCssScopedPluginOptions): Plugin;
6
+ export {};
@@ -0,0 +1,54 @@
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.uniCssScopedPlugin = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const debug_1 = __importDefault(require("debug"));
9
+ const constants_1 = require("../../constants");
10
+ const preprocess_1 = require("../../preprocess");
11
+ const debugScoped = (0, debug_1.default)('uni:scoped');
12
+ const SCOPED_RE = /<style\s[^>]*scoped[^>]*>/i;
13
+ function addScoped(code) {
14
+ if (SCOPED_RE.test(code)) {
15
+ return code;
16
+ }
17
+ return code.replace(/(<style\b[^><]*)>/gi, '$1 scoped>');
18
+ }
19
+ function uniCssScopedPlugin({ filter } = { filter: () => false }) {
20
+ return {
21
+ name: 'uni:css-scoped',
22
+ enforce: 'pre',
23
+ transform(code, id) {
24
+ if (!filter(id))
25
+ return null;
26
+ debugScoped(id);
27
+ return {
28
+ code: addScoped(code),
29
+ map: null,
30
+ };
31
+ },
32
+ // 仅 h5
33
+ handleHotUpdate(ctx) {
34
+ if (!constants_1.EXTNAME_VUE.includes(path_1.default.extname(ctx.file))) {
35
+ return;
36
+ }
37
+ const scoped = !ctx.file.endsWith('App.vue');
38
+ debugScoped('hmr', ctx.file);
39
+ const oldRead = ctx.read;
40
+ ctx.read = async () => {
41
+ let code = await oldRead();
42
+ // hotUpdate preprocess
43
+ if (code.includes('#endif')) {
44
+ code = (0, preprocess_1.preJs)((0, preprocess_1.preHtml)(code));
45
+ }
46
+ if (scoped) {
47
+ code = addScoped(code);
48
+ }
49
+ return code;
50
+ };
51
+ },
52
+ };
53
+ }
54
+ exports.uniCssScopedPlugin = uniCssScopedPlugin;
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function dynamicImportPolyfill(): Plugin;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dynamicImportPolyfill = void 0;
4
+ function dynamicImportPolyfill() {
5
+ return {
6
+ name: 'dynamic-import-polyfill',
7
+ renderDynamicImport() {
8
+ return {
9
+ left: '(',
10
+ right: ')',
11
+ };
12
+ },
13
+ };
14
+ }
15
+ exports.dynamicImportPolyfill = dynamicImportPolyfill;
@@ -0,0 +1,10 @@
1
+ export * from './cssScoped';
2
+ export * from './copy';
3
+ export * from './inject';
4
+ export * from './mainJs';
5
+ export * from './jsonJs';
6
+ export * from './console';
7
+ export * from './dynamicImportPolyfill';
8
+ export { assetPlugin, getAssetHash } from './vitejs/plugins/asset';
9
+ export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
10
+ export { generateCodeFrame } from './vitejs/utils';
@@ -0,0 +1,32 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.assetPlugin = void 0;
14
+ __exportStar(require("./cssScoped"), exports);
15
+ __exportStar(require("./copy"), exports);
16
+ __exportStar(require("./inject"), exports);
17
+ __exportStar(require("./mainJs"), exports);
18
+ __exportStar(require("./jsonJs"), exports);
19
+ __exportStar(require("./console"), exports);
20
+ __exportStar(require("./dynamicImportPolyfill"), exports);
21
+ var asset_1 = require("./vitejs/plugins/asset");
22
+ Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
23
+ Object.defineProperty(exports, "getAssetHash", { enumerable: true, get: function () { return asset_1.getAssetHash; } });
24
+ var css_1 = require("./vitejs/plugins/css");
25
+ Object.defineProperty(exports, "isCSSRequest", { enumerable: true, get: function () { return css_1.isCSSRequest; } });
26
+ Object.defineProperty(exports, "cssPlugin", { enumerable: true, get: function () { return css_1.cssPlugin; } });
27
+ Object.defineProperty(exports, "cssPostPlugin", { enumerable: true, get: function () { return css_1.cssPostPlugin; } });
28
+ Object.defineProperty(exports, "minifyCSS", { enumerable: true, get: function () { return css_1.minifyCSS; } });
29
+ Object.defineProperty(exports, "cssLangRE", { enumerable: true, get: function () { return css_1.cssLangRE; } });
30
+ Object.defineProperty(exports, "commonjsProxyRE", { enumerable: true, get: function () { return css_1.commonjsProxyRE; } });
31
+ var utils_1 = require("./vitejs/utils");
32
+ Object.defineProperty(exports, "generateCodeFrame", { enumerable: true, get: function () { return utils_1.generateCodeFrame; } });
@@ -0,0 +1,12 @@
1
+ import type { Plugin } from 'vite';
2
+ import { FilterPattern } from '@rollup/pluginutils';
3
+ declare type Injectment = string | [string, string];
4
+ export interface InjectOptions {
5
+ sourceMap?: boolean;
6
+ callback?: (imports: Map<any, any>, mod: [string, string]) => void;
7
+ include?: FilterPattern;
8
+ exclude?: FilterPattern;
9
+ [str: string]: Injectment | FilterPattern | Boolean | Function | undefined;
10
+ }
11
+ export declare function uniViteInjectPlugin(name: string, options: InjectOptions): Plugin;
12
+ export {};