@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
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initAppStatusbar = void 0;
4
+ function initAppStatusbar(manifestJson, pagesJson) {
5
+ var _a;
6
+ const { titleColor = '#000', backgroundColor = '#000000' } = ((_a = pagesJson.globalStyle) === null || _a === void 0 ? void 0 : _a.navigationBar) || {};
7
+ manifestJson.plus.statusbar = {
8
+ immersed: 'supportedDevice',
9
+ style: titleColor === '#000' ? 'dark' : 'light',
10
+ background: backgroundColor,
11
+ };
12
+ return manifestJson;
13
+ }
14
+ exports.initAppStatusbar = initAppStatusbar;
@@ -0,0 +1 @@
1
+ export declare function initTabBar(entryPagePath: string, manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initTabBar = void 0;
4
+ const uni_shared_1 = require("@dcloudio/uni-shared");
5
+ const TABBAR_WHITE = 'rgba(255,255,255,0.4)';
6
+ const TABBAR_BLACK = 'rgba(0,0,0,0.4)';
7
+ function initTabBar(entryPagePath, manifestJson, pagesJson) {
8
+ var _a, _b;
9
+ if (!((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length)) {
10
+ return;
11
+ }
12
+ const tabBar = JSON.parse(JSON.stringify(pagesJson.tabBar));
13
+ tabBar.borderStyle = (tabBar.borderStyle === 'white' ? TABBAR_WHITE : TABBAR_BLACK);
14
+ if (!tabBar.selectedColor) {
15
+ tabBar.selectedColor = uni_shared_1.SELECTED_COLOR;
16
+ }
17
+ tabBar.height = `${parseFloat(tabBar.height) || uni_shared_1.TABBAR_HEIGHT}px`;
18
+ // 首页是 tabBar 页面
19
+ const item = tabBar.list.find((page) => page.pagePath === entryPagePath);
20
+ if (item) {
21
+ ;
22
+ tabBar.child = ['lauchwebview'];
23
+ tabBar.selected = tabBar.list.indexOf(item);
24
+ }
25
+ manifestJson.plus.tabBar = tabBar;
26
+ }
27
+ exports.initTabBar = initTabBar;
@@ -0,0 +1 @@
1
+ export declare function initUniApp(manifestJson: Record<string, any>): void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initUniApp = void 0;
4
+ const nvue_1 = require("./nvue");
5
+ function initUniApp(manifestJson) {
6
+ manifestJson.plus['uni-app'] = {
7
+ control: 'uni-v3',
8
+ vueVersion: '3',
9
+ compilerVersion: process.env.UNI_COMPILER_VERSION,
10
+ nvueCompiler: (0, nvue_1.getNVueCompiler)(manifestJson),
11
+ renderer: 'auto',
12
+ nvue: {
13
+ 'flex-direction': (0, nvue_1.getNVueFlexDirection)(manifestJson),
14
+ },
15
+ nvueLaunchMode: manifestJson.plus.nvueLaunchMode === 'fast' ? 'fast' : 'normal',
16
+ };
17
+ delete manifestJson.plus.nvueLaunchMode;
18
+ }
19
+ exports.initUniApp = initUniApp;
@@ -0,0 +1,3 @@
1
+ export declare const polyfillCode = "\nif (typeof Promise !== 'undefined' && !Promise.prototype.finally) {\n Promise.prototype.finally = function(callback) {\n const promise = this.constructor\n return this.then(\n value => promise.resolve(callback()).then(() => value),\n reason => promise.resolve(callback()).then(() => {\n throw reason\n })\n )\n }\n}\n";
2
+ export declare const restoreGlobalCode = "\nimport * as vue from 'vue'\nif(uni.restoreGlobal){\n uni.restoreGlobal(vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)\n}\n";
3
+ export declare const globalCode: string;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.globalCode = exports.restoreGlobalCode = exports.polyfillCode = void 0;
4
+ exports.polyfillCode = `
5
+ if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
6
+ Promise.prototype.finally = function(callback) {
7
+ const promise = this.constructor
8
+ return this.then(
9
+ value => promise.resolve(callback()).then(() => value),
10
+ reason => promise.resolve(callback()).then(() => {
11
+ throw reason
12
+ })
13
+ )
14
+ }
15
+ }
16
+ `;
17
+ exports.restoreGlobalCode = `
18
+ import * as vue from 'vue'
19
+ if(uni.restoreGlobal){
20
+ uni.restoreGlobal(vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
21
+ }
22
+ `;
23
+ const GLOBALS = [
24
+ 'global',
25
+ 'window',
26
+ 'document',
27
+ 'frames',
28
+ 'self',
29
+ 'location',
30
+ 'navigator',
31
+ 'localStorage',
32
+ 'history',
33
+ 'Caches',
34
+ 'screen',
35
+ 'alert',
36
+ 'confirm',
37
+ 'prompt',
38
+ 'fetch',
39
+ 'XMLHttpRequest',
40
+ 'WebSocket',
41
+ 'webkit',
42
+ 'print',
43
+ ];
44
+ exports.globalCode = GLOBALS.map((g) => `${g}:u`).join(',');
@@ -0,0 +1,2 @@
1
+ export declare function definePageCode(pagesJson: Record<string, any>): string;
2
+ export declare function defineNVuePageCode(pagesJson: Record<string, any>): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineNVuePageCode = exports.definePageCode = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ function definePageCode(pagesJson) {
6
+ const importPagesCode = [];
7
+ const definePagesCode = [];
8
+ pagesJson.pages.forEach((page) => {
9
+ if (page.style.isNVue) {
10
+ return;
11
+ }
12
+ const pagePath = page.path;
13
+ const pageIdentifier = (0, utils_1.normalizeIdentifier)(pagePath);
14
+ const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath, 'app');
15
+ if (pagePathWithExtname) {
16
+ if (process.env.UNI_APP_CODE_SPLITING) {
17
+ // 拆分页面
18
+ importPagesCode.push(`const ${pageIdentifier} = ()=>import('./${pagePathWithExtname}')`);
19
+ }
20
+ else {
21
+ importPagesCode.push(`import ${pageIdentifier} from './${pagePathWithExtname}'`);
22
+ }
23
+ definePagesCode.push(`__definePage('${pagePath}',${pageIdentifier})`);
24
+ }
25
+ });
26
+ return importPagesCode.join('\n') + '\n' + definePagesCode.join('\n');
27
+ }
28
+ exports.definePageCode = definePageCode;
29
+ function defineNVuePageCode(pagesJson) {
30
+ const importNVuePagesCode = [];
31
+ pagesJson.pages.forEach((page) => {
32
+ if (!page.style.isNVue) {
33
+ return;
34
+ }
35
+ const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
36
+ if (pagePathWithExtname) {
37
+ importNVuePagesCode.push(`import('./${pagePathWithExtname}').then(()=>{})`);
38
+ }
39
+ });
40
+ return importNVuePagesCode.join('\n');
41
+ }
42
+ exports.defineNVuePageCode = defineNVuePageCode;
@@ -0,0 +1,3 @@
1
+ export declare function normalizeAppPagesJson(pagesJson: Record<string, any>): string;
2
+ export declare function normalizeAppNVuePagesJson(pagesJson: Record<string, any>): string;
3
+ export declare function normalizeAppConfigService(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeAppConfigService = exports.normalizeAppNVuePagesJson = exports.normalizeAppPagesJson = void 0;
4
+ const code_1 = require("./code");
5
+ const definePage_1 = require("./definePage");
6
+ const uniConfig_1 = require("./uniConfig");
7
+ const uniRoutes_1 = require("./uniRoutes");
8
+ function normalizeAppPagesJson(pagesJson) {
9
+ return code_1.polyfillCode + code_1.restoreGlobalCode + (0, definePage_1.definePageCode)(pagesJson);
10
+ }
11
+ exports.normalizeAppPagesJson = normalizeAppPagesJson;
12
+ function normalizeAppNVuePagesJson(pagesJson) {
13
+ return (0, definePage_1.defineNVuePageCode)(pagesJson);
14
+ }
15
+ exports.normalizeAppNVuePagesJson = normalizeAppNVuePagesJson;
16
+ function normalizeAppConfigService(pagesJson, manifestJson) {
17
+ return `
18
+ ;(function(){
19
+ let u=void 0,isReady=false,onReadyCallbacks=[],isServiceReady=false,onServiceReadyCallbacks=[];
20
+ const __uniConfig = ${(0, uniConfig_1.normalizeAppUniConfig)(pagesJson, manifestJson)};
21
+ const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
22
+ __uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
23
+ __uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
24
+ service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:16})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,${code_1.globalCode}}}}});
25
+ })();
26
+ `;
27
+ }
28
+ exports.normalizeAppConfigService = normalizeAppConfigService;
@@ -0,0 +1 @@
1
+ export declare function normalizeAppUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
@@ -0,0 +1,69 @@
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.normalizeAppUniConfig = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const i18n_1 = require("../../../i18n");
9
+ const manifest_1 = require("../../manifest");
10
+ const manifest_2 = require("../manifest");
11
+ const arguments_1 = require("../manifest/arguments");
12
+ const splashscreen_1 = require("../manifest/splashscreen");
13
+ function normalizeAppUniConfig(pagesJson, manifestJson) {
14
+ var _a;
15
+ const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
16
+ const config = {
17
+ pages: [],
18
+ globalStyle: pagesJson.globalStyle,
19
+ nvue: {
20
+ compiler: (0, manifest_2.getNVueCompiler)(manifestJson),
21
+ styleCompiler: (0, manifest_2.getNVueStyleCompiler)(manifestJson),
22
+ 'flex-direction': (0, manifest_2.getNVueFlexDirection)(manifestJson),
23
+ },
24
+ renderer: ((_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.renderer) === 'native' ? 'native' : 'auto',
25
+ appname: manifestJson.name || '',
26
+ splashscreen: {
27
+ alwaysShowBeforeRender,
28
+ autoclose,
29
+ },
30
+ compilerVersion: process.env.UNI_COMPILER_VERSION,
31
+ ...parseEntryPagePath(pagesJson),
32
+ networkTimeout: (0, manifest_1.normalizeNetworkTimeout)(manifestJson.networkTimeout),
33
+ tabBar: pagesJson.tabBar,
34
+ locales: (0, i18n_1.initLocales)(path_1.default.join(process.env.UNI_INPUT_DIR, 'locale')),
35
+ };
36
+ // TODO 待支持分包
37
+ return JSON.stringify(config);
38
+ }
39
+ exports.normalizeAppUniConfig = normalizeAppUniConfig;
40
+ function parseEntryPagePath(pagesJson) {
41
+ var _a;
42
+ const res = {
43
+ entryPagePath: '',
44
+ entryPageQuery: '',
45
+ realEntryPagePath: '',
46
+ };
47
+ if (!pagesJson.pages.length) {
48
+ return res;
49
+ }
50
+ res.entryPagePath = pagesJson.pages[0].path;
51
+ const argsJsonStr = (0, arguments_1.parseArguments)(pagesJson);
52
+ if (argsJsonStr) {
53
+ try {
54
+ const args = JSON.parse(argsJsonStr);
55
+ const entryPagePath = args.path || args.pathName;
56
+ const realEntryPagePath = res.entryPagePath;
57
+ if (entryPagePath && realEntryPagePath !== entryPagePath) {
58
+ res.entryPagePath = entryPagePath;
59
+ res.entryPageQuery = args.query ? '?' + args.query : '';
60
+ // non tabBar page
61
+ if (!(((_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) || []).find((page) => page.pagePath === entryPagePath)) {
62
+ res.realEntryPagePath = realEntryPagePath;
63
+ }
64
+ }
65
+ }
66
+ catch (e) { }
67
+ }
68
+ return res;
69
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizeAppUniRoutes(pagesJson: UniApp.PagesJson): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeAppUniRoutes = void 0;
4
+ const pages_1 = require("../../pages");
5
+ function normalizeAppUniRoutes(pagesJson) {
6
+ return JSON.stringify((0, pages_1.normalizePagesRoute)(pagesJson));
7
+ }
8
+ exports.normalizeAppUniRoutes = normalizeAppUniRoutes;
@@ -0,0 +1,5 @@
1
+ export * from './mp';
2
+ export * from './app';
3
+ export * from './json';
4
+ export * from './pages';
5
+ export * from './manifest';
@@ -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
+ __exportStar(require("./mp"), exports);
14
+ __exportStar(require("./app"), exports);
15
+ __exportStar(require("./json"), exports);
16
+ __exportStar(require("./pages"), exports);
17
+ __exportStar(require("./manifest"), exports);
@@ -0,0 +1 @@
1
+ export declare function parseJson(jsonStr: string, shouldPre?: boolean): any;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseJson = void 0;
4
+ const jsonc_parser_1 = require("jsonc-parser");
5
+ const preprocess_1 = require("../preprocess");
6
+ function parseJson(jsonStr, shouldPre = false) {
7
+ return (0, jsonc_parser_1.parse)(shouldPre ? (0, preprocess_1.preJson)(jsonStr) : jsonStr);
8
+ }
9
+ exports.parseJson = parseJson;
@@ -0,0 +1,28 @@
1
+ export declare const parseManifestJson: (inputDir: string) => any;
2
+ export declare const parseManifestJsonOnce: (inputDir: string) => any;
3
+ export declare const parseRpx2UnitOnce: (inputDir: string, platform?: UniApp.PLATFORM) => any;
4
+ interface CompilerCompatConfig {
5
+ MODE?: 2 | 3;
6
+ }
7
+ declare function parseCompatConfig(_inputDir: string): CompilerCompatConfig;
8
+ export declare const parseCompatConfigOnce: typeof parseCompatConfig;
9
+ declare const defaultNetworkTimeout: {
10
+ request: number;
11
+ connectSocket: number;
12
+ uploadFile: number;
13
+ downloadFile: number;
14
+ };
15
+ export declare function normalizeNetworkTimeout(networkTimeout?: Partial<typeof defaultNetworkTimeout>): {
16
+ request: number;
17
+ connectSocket: number;
18
+ uploadFile: number;
19
+ downloadFile: number;
20
+ };
21
+ export declare function getUniStatistics(inputDir: string, platform: UniApp.PLATFORM): any;
22
+ export declare function getRouterOptions(manifestJson: Record<string, any>): {
23
+ mode?: 'history' | 'hash';
24
+ base?: string;
25
+ };
26
+ export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
27
+ export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
28
+ export {};
@@ -0,0 +1,64 @@
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.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const shared_1 = require("@vue/shared");
10
+ const uni_shared_1 = require("@dcloudio/uni-shared");
11
+ const json_1 = require("./json");
12
+ const parseManifestJson = (inputDir) => {
13
+ return (0, json_1.parseJson)(fs_1.default.readFileSync(path_1.default.join(inputDir, 'manifest.json'), 'utf8'));
14
+ };
15
+ exports.parseManifestJson = parseManifestJson;
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);
26
+ });
27
+ function parseCompatConfig(_inputDir) {
28
+ // 不支持 mode:2
29
+ return { MODE: 3 }; //parseManifestJsonOnce(inputDir).compatConfig || {}
30
+ }
31
+ exports.parseCompatConfigOnce = (0, uni_shared_1.once)(parseCompatConfig);
32
+ const defaultNetworkTimeout = {
33
+ request: 60000,
34
+ connectSocket: 60000,
35
+ uploadFile: 60000,
36
+ downloadFile: 60000,
37
+ };
38
+ function normalizeNetworkTimeout(networkTimeout) {
39
+ return {
40
+ ...defaultNetworkTimeout,
41
+ ...networkTimeout,
42
+ };
43
+ }
44
+ exports.normalizeNetworkTimeout = normalizeNetworkTimeout;
45
+ function getUniStatistics(inputDir, platform) {
46
+ const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
47
+ return (0, shared_1.extend)({}, manifest.uniStatistics, manifest[platform] && manifest[platform].uniStatistics);
48
+ }
49
+ exports.getUniStatistics = getUniStatistics;
50
+ function getRouterOptions(manifestJson) {
51
+ var _a;
52
+ return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.router);
53
+ }
54
+ exports.getRouterOptions = getRouterOptions;
55
+ function isEnableTreeShaking(manifestJson) {
56
+ var _a, _b, _c;
57
+ return ((_c = (_b = (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.treeShaking) === null || _c === void 0 ? void 0 : _c.enable) !== false;
58
+ }
59
+ exports.isEnableTreeShaking = isEnableTreeShaking;
60
+ function getDevServerOptions(manifestJson) {
61
+ var _a;
62
+ return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.devServer);
63
+ }
64
+ exports.getDevServerOptions = getDevServerOptions;
@@ -0,0 +1,4 @@
1
+ export * from './jsonFile';
2
+ export { AppJson } from './types';
3
+ export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
4
+ export { parseMiniProgramProjectJson } from './project';
@@ -0,0 +1,19 @@
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.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = exports.mergeMiniProgramAppJson = void 0;
14
+ __exportStar(require("./jsonFile"), exports);
15
+ var pages_1 = require("./pages");
16
+ Object.defineProperty(exports, "mergeMiniProgramAppJson", { enumerable: true, get: function () { return pages_1.mergeMiniProgramAppJson; } });
17
+ Object.defineProperty(exports, "parseMiniProgramPagesJson", { enumerable: true, get: function () { return pages_1.parseMiniProgramPagesJson; } });
18
+ var project_1 = require("./project");
19
+ Object.defineProperty(exports, "parseMiniProgramProjectJson", { enumerable: true, get: function () { return project_1.parseMiniProgramProjectJson; } });
@@ -0,0 +1,23 @@
1
+ import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
2
+ export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
3
+ export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
4
+ export declare function hasJsonFile(filename: string): boolean;
5
+ export declare function getComponentJsonFilenames(): string[];
6
+ export declare function findJsonFile(filename: string): Record<string, any> | undefined;
7
+ export declare function findUsingComponents(filename: string): UsingComponents | undefined;
8
+ export declare function normalizeJsonFilename(filename: string): string;
9
+ export declare function findChangedJsonFiles(): Map<string, string>;
10
+ export declare function addMiniProgramAppJson(appJson: Record<string, any>): void;
11
+ export declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void;
12
+ export declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void;
13
+ export declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void;
14
+ export declare function isMiniProgramUsingComponent(name: string, options: {
15
+ filename: string;
16
+ inputDir: string;
17
+ componentsDir?: string;
18
+ }): boolean;
19
+ export declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: {
20
+ filename: string;
21
+ inputDir: string;
22
+ componentsDir?: string;
23
+ }): string[];
@@ -0,0 +1,127 @@
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.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const shared_1 = require("@vue/shared");
9
+ const utils_1 = require("../../utils");
10
+ const resolve_1 = require("../../resolve");
11
+ const utils_2 = require("../../vue/utils");
12
+ let appJsonCache = {};
13
+ const jsonFilesCache = new Map();
14
+ const jsonPagesCache = new Map();
15
+ const jsonComponentsCache = new Map();
16
+ const jsonUsingComponentsCache = new Map();
17
+ function isMiniProgramPageFile(file, inputDir) {
18
+ if (inputDir && path_1.default.isAbsolute(file)) {
19
+ file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
20
+ }
21
+ return jsonPagesCache.has((0, utils_1.removeExt)(file));
22
+ }
23
+ exports.isMiniProgramPageFile = isMiniProgramPageFile;
24
+ function isMiniProgramPageSfcFile(file, inputDir) {
25
+ return (0, utils_2.isVueSfcFile)(file) && isMiniProgramPageFile(file, inputDir);
26
+ }
27
+ exports.isMiniProgramPageSfcFile = isMiniProgramPageSfcFile;
28
+ function hasJsonFile(filename) {
29
+ return (filename === 'app' ||
30
+ jsonPagesCache.has(filename) ||
31
+ jsonComponentsCache.has(filename));
32
+ }
33
+ exports.hasJsonFile = hasJsonFile;
34
+ function getComponentJsonFilenames() {
35
+ return [...jsonComponentsCache.keys()];
36
+ }
37
+ exports.getComponentJsonFilenames = getComponentJsonFilenames;
38
+ function findJsonFile(filename) {
39
+ if (filename === 'app') {
40
+ return appJsonCache;
41
+ }
42
+ return jsonPagesCache.get(filename) || jsonComponentsCache.get(filename);
43
+ }
44
+ exports.findJsonFile = findJsonFile;
45
+ function findUsingComponents(filename) {
46
+ return jsonUsingComponentsCache.get(filename);
47
+ }
48
+ exports.findUsingComponents = findUsingComponents;
49
+ function normalizeJsonFilename(filename) {
50
+ return (0, utils_1.normalizeNodeModules)(filename);
51
+ }
52
+ exports.normalizeJsonFilename = normalizeJsonFilename;
53
+ function findChangedJsonFiles() {
54
+ const changedJsonFiles = new Map();
55
+ function findChangedFile(filename, json) {
56
+ const newJson = JSON.parse(JSON.stringify(json));
57
+ if (!newJson.usingComponents) {
58
+ newJson.usingComponents = {};
59
+ }
60
+ (0, shared_1.extend)(newJson.usingComponents, jsonUsingComponentsCache.get(filename));
61
+ const usingComponents = newJson.usingComponents;
62
+ // 格式化为相对路径,这样作为分包也可以直接运行
63
+ Object.keys(usingComponents).forEach((name) => {
64
+ const componentFilename = usingComponents[name];
65
+ if (componentFilename.startsWith('/')) {
66
+ usingComponents[name] = (0, resolve_1.relativeFile)(filename, componentFilename.slice(1));
67
+ }
68
+ });
69
+ const jsonStr = JSON.stringify(newJson, null, 2);
70
+ if (jsonFilesCache.get(filename) !== jsonStr) {
71
+ changedJsonFiles.set(filename, jsonStr);
72
+ jsonFilesCache.set(filename, jsonStr);
73
+ }
74
+ }
75
+ function findChangedFiles(jsonsCache) {
76
+ for (const name of jsonsCache.keys()) {
77
+ findChangedFile(name, jsonsCache.get(name));
78
+ }
79
+ }
80
+ findChangedFile('app', appJsonCache);
81
+ findChangedFiles(jsonPagesCache);
82
+ findChangedFiles(jsonComponentsCache);
83
+ return changedJsonFiles;
84
+ }
85
+ exports.findChangedJsonFiles = findChangedJsonFiles;
86
+ function addMiniProgramAppJson(appJson) {
87
+ appJsonCache = appJson;
88
+ }
89
+ exports.addMiniProgramAppJson = addMiniProgramAppJson;
90
+ function addMiniProgramPageJson(filename, json) {
91
+ jsonPagesCache.set(filename, json);
92
+ }
93
+ exports.addMiniProgramPageJson = addMiniProgramPageJson;
94
+ function addMiniProgramComponentJson(filename, json) {
95
+ jsonComponentsCache.set(filename, json);
96
+ }
97
+ exports.addMiniProgramComponentJson = addMiniProgramComponentJson;
98
+ function addMiniProgramUsingComponents(filename, json) {
99
+ jsonUsingComponentsCache.set(filename, json);
100
+ }
101
+ exports.addMiniProgramUsingComponents = addMiniProgramUsingComponents;
102
+ function isMiniProgramUsingComponent(name, options) {
103
+ return findMiniProgramUsingComponents(options).includes(name);
104
+ }
105
+ exports.isMiniProgramUsingComponent = isMiniProgramUsingComponent;
106
+ function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }) {
107
+ if (!componentsDir) {
108
+ return [];
109
+ }
110
+ const globalUsingComponents = appJsonCache && appJsonCache.usingComponents;
111
+ const miniProgramComponents = [];
112
+ if (globalUsingComponents) {
113
+ miniProgramComponents.push(...findMiniProgramUsingComponent(globalUsingComponents, componentsDir));
114
+ }
115
+ const jsonFile = findJsonFile((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(filename, inputDir)));
116
+ if (jsonFile === null || jsonFile === void 0 ? void 0 : jsonFile.usingComponents) {
117
+ miniProgramComponents.push(...findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir));
118
+ }
119
+ return miniProgramComponents;
120
+ }
121
+ exports.findMiniProgramUsingComponents = findMiniProgramUsingComponents;
122
+ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
123
+ return Object.keys(usingComponents).filter((name) => {
124
+ const path = usingComponents[name];
125
+ return path.includes(componentsDir + '/');
126
+ });
127
+ }
@@ -0,0 +1,17 @@
1
+ import { AppJson, NetworkTimeout, PageWindowOptions } from './types';
2
+ interface ParsePagesJsonOptions {
3
+ debug?: boolean;
4
+ darkmode?: boolean;
5
+ subpackages: boolean;
6
+ windowOptionsMap?: Record<string, string>;
7
+ tabBarOptionsMap?: Record<string, string>;
8
+ tabBarItemOptionsMap?: Record<string, string>;
9
+ networkTimeout?: NetworkTimeout;
10
+ }
11
+ export declare function parseMiniProgramPagesJson(jsonStr: string, platform: UniApp.PLATFORM, options?: ParsePagesJsonOptions): {
12
+ appJson: AppJson;
13
+ pageJsons: Record<string, PageWindowOptions>;
14
+ nvuePages: string[];
15
+ };
16
+ export declare function mergeMiniProgramAppJson(appJson: Record<string, any>, platformJson?: Record<string, any>): void;
17
+ export {};