@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,176 @@
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
+ const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
7
+ const scopedPlugin = () => {
8
+ return {
9
+ postcssPlugin: 'uni-sfc-scoped',
10
+ prepare({ processor: { plugins } }) {
11
+ const hasVueSfcScoped = !!plugins.find((plugin) => plugin.postcssPlugin === 'vue-sfc-scoped');
12
+ return {
13
+ Rule(rule) {
14
+ processRule(rule, hasVueSfcScoped);
15
+ },
16
+ };
17
+ },
18
+ };
19
+ };
20
+ const processedRules = new WeakSet();
21
+ function processRule(rule, hasVueSfcScoped) {
22
+ if (processedRules.has(rule) ||
23
+ (rule.parent &&
24
+ rule.parent.type === 'atrule' &&
25
+ /-?keyframes$/.test(rule.parent.name))) {
26
+ return;
27
+ }
28
+ processedRules.add(rule);
29
+ rule.selector = (0, postcss_selector_parser_1.default)((selectorRoot) => {
30
+ selectorRoot.each((selector) => {
31
+ hasVueSfcScoped
32
+ ? rewriteDeprecatedSelector(selector)
33
+ : rewriteSelector(selector, selectorRoot);
34
+ });
35
+ }).processSync(rule.selector);
36
+ }
37
+ /**
38
+ * @param selector
39
+ * @returns
40
+ */
41
+ function rewriteDeprecatedSelector(selector) {
42
+ const nodes = [];
43
+ let deepNode;
44
+ selector.each((n) => {
45
+ if (deepNode) {
46
+ nodes.push(n);
47
+ selector.removeChild(n);
48
+ }
49
+ else {
50
+ const { type, value } = n;
51
+ if (type === 'pseudo' && value === '::v-deep') {
52
+ deepNode = n;
53
+ }
54
+ else if (type === 'combinator' &&
55
+ (value === '>>>' || value === '/deep/')) {
56
+ deepNode = n;
57
+ }
58
+ }
59
+ });
60
+ if (!deepNode) {
61
+ return;
62
+ }
63
+ if (deepNode.type === 'combinator') {
64
+ const index = selector.index(deepNode);
65
+ if (index > 0) {
66
+ selector.insertBefore(deepNode, postcss_selector_parser_1.default.combinator({ value: ' ' }));
67
+ }
68
+ }
69
+ // remove first combinator
70
+ // ::v-deep a{color:red;} => :deep(a){color:red;}
71
+ const firstNode = nodes[0];
72
+ if (firstNode && firstNode.type === 'combinator' && firstNode.value === ' ') {
73
+ nodes.shift();
74
+ }
75
+ selector.insertBefore(deepNode, postcss_selector_parser_1.default.pseudo({
76
+ value: ':deep',
77
+ nodes: [postcss_selector_parser_1.default.selector({ value: '', nodes })],
78
+ }));
79
+ selector.removeChild(deepNode);
80
+ }
81
+ function rewriteSelector(selector, selectorRoot) {
82
+ let node = null;
83
+ // find the last child node to insert attribute selector
84
+ selector.each((n) => {
85
+ // DEPRECATED ">>>" and "/deep/" combinator
86
+ if (n.type === 'combinator' &&
87
+ (n.value === '>>>' || n.value === '/deep/')) {
88
+ n.value = ' ';
89
+ n.spaces.before = n.spaces.after = '';
90
+ // warn(
91
+ // `the >>> and /deep/ combinators have been deprecated. ` +
92
+ // `Use :deep() instead.`
93
+ // )
94
+ return false;
95
+ }
96
+ if (n.type === 'pseudo') {
97
+ const { value } = n;
98
+ // deep: inject [id] attribute at the node before the ::v-deep
99
+ // combinator.
100
+ if (value === ':deep' || value === '::v-deep') {
101
+ if (n.nodes.length) {
102
+ // .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar
103
+ // replace the current node with ::v-deep's inner selector
104
+ let last = n;
105
+ n.nodes[0].each((ss) => {
106
+ selector.insertAfter(last, ss);
107
+ last = ss;
108
+ });
109
+ // insert a space combinator before if it doesn't already have one
110
+ const prev = selector.at(selector.index(n) - 1);
111
+ if (!prev || !isSpaceCombinator(prev)) {
112
+ selector.insertAfter(n, postcss_selector_parser_1.default.combinator({
113
+ value: ' ',
114
+ }));
115
+ }
116
+ selector.removeChild(n);
117
+ }
118
+ else {
119
+ // DEPRECATED usage
120
+ // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
121
+ // warn(
122
+ // `::v-deep usage as a combinator has ` +
123
+ // `been deprecated. Use :deep(<inner-selector>) instead.`
124
+ // )
125
+ const prev = selector.at(selector.index(n) - 1);
126
+ if (prev && isSpaceCombinator(prev)) {
127
+ selector.removeChild(prev);
128
+ }
129
+ selector.removeChild(n);
130
+ }
131
+ return false;
132
+ }
133
+ // slot: use selector inside `::v-slotted` and inject [id + '-s']
134
+ // instead.
135
+ // ::v-slotted(.foo) -> .foo[xxxxxxx-s]
136
+ if (value === ':slotted' || value === '::v-slotted') {
137
+ rewriteSelector(n.nodes[0], selectorRoot);
138
+ let last = n;
139
+ n.nodes[0].each((ss) => {
140
+ selector.insertAfter(last, ss);
141
+ last = ss;
142
+ });
143
+ // selector.insertAfter(n, n.nodes[0])
144
+ selector.removeChild(n);
145
+ // since slotted attribute already scopes the selector there's no
146
+ // need for the non-slot attribute.
147
+ return false;
148
+ }
149
+ // global: replace with inner selector and do not inject [id].
150
+ // ::v-global(.foo) -> .foo
151
+ if (value === ':global' || value === '::v-global') {
152
+ selectorRoot.insertAfter(selector, n.nodes[0]);
153
+ selectorRoot.removeChild(selector);
154
+ return false;
155
+ }
156
+ }
157
+ if (n.type !== 'pseudo' && n.type !== 'combinator') {
158
+ node = n;
159
+ }
160
+ });
161
+ if (node) {
162
+ ;
163
+ node.spaces.after = '';
164
+ }
165
+ else {
166
+ // For deep selectors & standalone pseudo selectors,
167
+ // the attribute selectors are prepended rather than appended.
168
+ // So all leading spaces must be eliminated to avoid problems.
169
+ selector.first.spaces.before = '';
170
+ }
171
+ }
172
+ function isSpaceCombinator(node) {
173
+ return node.type === 'combinator' && /^\s+$/.test(node.value);
174
+ }
175
+ scopedPlugin.postcss = true;
176
+ exports.default = scopedPlugin;
@@ -0,0 +1,11 @@
1
+ import type { Plugin } from 'postcss';
2
+ export interface UniAppCssProcessorOptions {
3
+ unit?: string;
4
+ unitRatio?: number;
5
+ unitPrecision?: number;
6
+ }
7
+ declare const uniapp: {
8
+ (opts?: UniAppCssProcessorOptions | undefined): Plugin;
9
+ postcss: boolean;
10
+ };
11
+ export default uniapp;
@@ -0,0 +1,110 @@
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
+ const shared_1 = require("@vue/shared");
7
+ const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
8
+ const uni_shared_1 = require("@dcloudio/uni-shared");
9
+ const defaultUniAppCssProcessorOptions = (0, shared_1.extend)({}, uni_shared_1.defaultRpx2Unit);
10
+ const BG_PROPS = [
11
+ 'background',
12
+ 'background-clip',
13
+ 'background-color',
14
+ 'background-image',
15
+ 'background-origin',
16
+ 'background-position',
17
+ 'background-repeat',
18
+ 'background-size',
19
+ 'background-attachment',
20
+ ];
21
+ function transform(selector, state, { rewriteTag }) {
22
+ if (selector.type !== 'tag') {
23
+ return;
24
+ }
25
+ const { value } = selector;
26
+ selector.value = rewriteTag(value);
27
+ if (value === 'page' && selector.value === 'uni-page-body') {
28
+ state.bg = true;
29
+ }
30
+ }
31
+ function createBodyBackgroundRule(origRule) {
32
+ const bgDecls = [];
33
+ origRule.walkDecls((decl) => {
34
+ if (BG_PROPS.indexOf(decl.prop) !== -1) {
35
+ bgDecls.push(decl.clone());
36
+ }
37
+ });
38
+ if (bgDecls.length) {
39
+ const { rule } = require('postcss');
40
+ origRule.after(rule({ selector: 'body' }).append(bgDecls));
41
+ }
42
+ }
43
+ function walkRules(options) {
44
+ return (rule) => {
45
+ const state = { bg: false };
46
+ rule.selector = (0, postcss_selector_parser_1.default)((selectors) => selectors.walk((selector) => transform(selector, state, options))).processSync(rule.selector);
47
+ state.bg && createBodyBackgroundRule(rule);
48
+ };
49
+ }
50
+ function walkDecls(rpx2unit) {
51
+ return (decl) => {
52
+ const { value } = decl;
53
+ if (value.indexOf('rpx') === -1 && value.indexOf('upx') === -1) {
54
+ return;
55
+ }
56
+ decl.value = rpx2unit(decl.value);
57
+ };
58
+ }
59
+ const baiduTags = {
60
+ navigator: 'nav',
61
+ };
62
+ function rewriteBaiduTags(tag) {
63
+ return baiduTags[tag] || tag;
64
+ }
65
+ function rewriteUniH5Tags(tag) {
66
+ if (tag === 'page') {
67
+ return 'uni-page-body';
68
+ }
69
+ if ((0, uni_shared_1.isBuiltInComponent)(tag)) {
70
+ return uni_shared_1.COMPONENT_SELECTOR_PREFIX + tag;
71
+ }
72
+ return tag;
73
+ }
74
+ function rewriteUniAppTags(tag) {
75
+ if (tag === 'page') {
76
+ return 'body';
77
+ }
78
+ if ((0, uni_shared_1.isBuiltInComponent)(tag)) {
79
+ return uni_shared_1.COMPONENT_SELECTOR_PREFIX + tag;
80
+ }
81
+ return tag;
82
+ }
83
+ const transforms = {
84
+ h5: rewriteUniH5Tags,
85
+ app: rewriteUniAppTags,
86
+ 'mp-baidu': rewriteBaiduTags,
87
+ };
88
+ const uniapp = (opts) => {
89
+ const platform = process.env.UNI_PLATFORM;
90
+ const { unit, unitRatio, unitPrecision } = (0, shared_1.extend)({}, defaultUniAppCssProcessorOptions, opts);
91
+ const rpx2unit = (0, uni_shared_1.createRpx2Unit)(unit, unitRatio, unitPrecision);
92
+ return {
93
+ postcssPlugin: 'uni-app',
94
+ prepare() {
95
+ return {
96
+ OnceExit(root) {
97
+ root.walkDecls(walkDecls(rpx2unit));
98
+ const rewriteTag = transforms[platform];
99
+ if (rewriteTag) {
100
+ root.walkRules(walkRules({
101
+ rewriteTag,
102
+ }));
103
+ }
104
+ },
105
+ };
106
+ },
107
+ };
108
+ };
109
+ uniapp.postcss = true;
110
+ exports.default = uniapp;
@@ -0,0 +1,3 @@
1
+ export declare function getPreVueContext(): any;
2
+ export declare function getPreNVueContext(): any;
3
+ export declare function initPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean> | string): void;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initPreContext = exports.getPreNVueContext = exports.getPreVueContext = void 0;
4
+ const shared_1 = require("@vue/shared");
5
+ const DEFAULT_KEYS = [
6
+ 'APP',
7
+ 'APP_NVUE',
8
+ 'APP_PLUS',
9
+ 'APP_PLUS_NVUE',
10
+ 'APP_VUE',
11
+ 'H5',
12
+ 'MP',
13
+ 'MP_360',
14
+ 'MP_ALIPAY',
15
+ 'MP_BAIDU',
16
+ 'MP_QQ',
17
+ 'MP_LARK',
18
+ 'MP_TOUTIAO',
19
+ 'MP_WEIXIN',
20
+ 'MP_KUAISHOU',
21
+ 'MP_JD',
22
+ 'QUICKAPP_NATIVE',
23
+ 'QUICKAPP_WEBVIEW',
24
+ 'QUICKAPP_WEBVIEW_HUAWEI',
25
+ 'QUICKAPP_WEBVIEW_UNION',
26
+ 'VUE2',
27
+ 'VUE3',
28
+ ];
29
+ const preVueContext = Object.create(null);
30
+ const preNVueContext = Object.create(null);
31
+ function getPreVueContext() {
32
+ return preVueContext;
33
+ }
34
+ exports.getPreVueContext = getPreVueContext;
35
+ function getPreNVueContext() {
36
+ return preNVueContext;
37
+ }
38
+ exports.getPreNVueContext = getPreNVueContext;
39
+ function initPreContext(platform, userPreContext) {
40
+ const vueContext = Object.create(null);
41
+ const nvueContext = Object.create(null);
42
+ const defaultContext = Object.create(null);
43
+ DEFAULT_KEYS.forEach((key) => {
44
+ defaultContext[key] = false;
45
+ });
46
+ defaultContext[normalizeKey(platform)] = true;
47
+ vueContext.VUE3 = true;
48
+ nvueContext.VUE2 = true;
49
+ if (platform === 'app' || platform === 'app-plus') {
50
+ defaultContext.APP = true;
51
+ defaultContext.APP_PLUS = true;
52
+ vueContext.APP_VUE = true;
53
+ nvueContext.APP_NVUE = true;
54
+ nvueContext.APP_PLUS_NVUE = true;
55
+ }
56
+ else if (platform.startsWith('mp-')) {
57
+ defaultContext.MP = true;
58
+ }
59
+ else if (platform.startsWith('quickapp-webview')) {
60
+ defaultContext.QUICKAPP_WEBVIEW = true;
61
+ }
62
+ if (userPreContext) {
63
+ if ((0, shared_1.isString)(userPreContext)) {
64
+ try {
65
+ userPreContext = JSON.parse(userPreContext);
66
+ }
67
+ catch (e) { }
68
+ }
69
+ if ((0, shared_1.isPlainObject)(userPreContext)) {
70
+ Object.keys(userPreContext).forEach((key) => {
71
+ defaultContext[normalizeKey(key)] = !!userPreContext[key];
72
+ });
73
+ }
74
+ }
75
+ (0, shared_1.extend)(preVueContext, defaultContext, vueContext);
76
+ (0, shared_1.extend)(preNVueContext, defaultContext, nvueContext);
77
+ }
78
+ exports.initPreContext = initPreContext;
79
+ function normalizeKey(name) {
80
+ return name.replace(/-/g, '_').toUpperCase();
81
+ }
@@ -0,0 +1,9 @@
1
+ export { initPreContext } from './context';
2
+ export declare function preJs(jsCode: string): any;
3
+ export declare function preHtml(htmlCode: string): any;
4
+ export declare const preCss: typeof preJs;
5
+ export declare const preJson: typeof preJs;
6
+ export declare function preNVueJs(jsCode: string): any;
7
+ export declare function preNVueHtml(htmlCode: string): any;
8
+ export declare const preNVueCss: typeof preNVueJs;
9
+ export declare const preNVueJson: typeof preNVueJs;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preNVueJson = exports.preNVueCss = exports.preNVueHtml = exports.preNVueJs = exports.preJson = exports.preCss = exports.preHtml = exports.preJs = exports.initPreContext = void 0;
4
+ const context_1 = require("./context");
5
+ /* eslint-disable no-restricted-globals */
6
+ const { preprocess } = require('../../lib/preprocess');
7
+ var context_2 = require("./context");
8
+ Object.defineProperty(exports, "initPreContext", { enumerable: true, get: function () { return context_2.initPreContext; } });
9
+ function preJs(jsCode) {
10
+ return preprocess(jsCode, (0, context_1.getPreVueContext)(), { type: 'js' });
11
+ }
12
+ exports.preJs = preJs;
13
+ function preHtml(htmlCode) {
14
+ return preprocess(htmlCode, (0, context_1.getPreVueContext)(), { type: 'html' });
15
+ }
16
+ exports.preHtml = preHtml;
17
+ exports.preCss = preJs;
18
+ exports.preJson = preJs;
19
+ function preNVueJs(jsCode) {
20
+ return preprocess(jsCode, (0, context_1.getPreNVueContext)(), { type: 'js' });
21
+ }
22
+ exports.preNVueJs = preNVueJs;
23
+ function preNVueHtml(htmlCode) {
24
+ return preprocess(htmlCode, (0, context_1.getPreNVueContext)(), { type: 'html' });
25
+ }
26
+ exports.preNVueHtml = preNVueHtml;
27
+ exports.preNVueCss = preNVueJs;
28
+ exports.preNVueJson = preNVueJs;
@@ -0,0 +1,6 @@
1
+ export declare function requireResolve(filename: string, basedir: string): string;
2
+ export declare function relativeFile(from: string, to: string): string;
3
+ export declare const resolveMainPathOnce: (inputDir: string) => string;
4
+ export declare function getBuiltInPaths(): string[];
5
+ export declare function resolveBuiltIn(path: string): string;
6
+ export declare function resolveComponentsLibPath(): string;
@@ -0,0 +1,102 @@
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.resolveComponentsLibPath = exports.resolveBuiltIn = exports.getBuiltInPaths = exports.resolveMainPathOnce = exports.relativeFile = exports.requireResolve = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const debug_1 = __importDefault(require("debug"));
10
+ const resolve_1 = __importDefault(require("resolve"));
11
+ const uni_shared_1 = require("@dcloudio/uni-shared");
12
+ const utils_1 = require("./utils");
13
+ const env_1 = require("./hbx/env");
14
+ const constants_1 = require("./constants");
15
+ function requireResolve(filename, basedir) {
16
+ return resolveWithSymlinks(filename, basedir);
17
+ }
18
+ exports.requireResolve = requireResolve;
19
+ function resolveWithSymlinks(id, basedir) {
20
+ return resolve_1.default.sync(id, {
21
+ basedir,
22
+ extensions: constants_1.extensions,
23
+ // necessary to work with pnpm
24
+ preserveSymlinks: true,
25
+ });
26
+ }
27
+ function relativeFile(from, to) {
28
+ const relativePath = (0, utils_1.normalizePath)(path_1.default.relative(path_1.default.dirname(from), to));
29
+ return relativePath.startsWith('.') ? relativePath : './' + relativePath;
30
+ }
31
+ exports.relativeFile = relativeFile;
32
+ exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
33
+ const mainTsPath = path_1.default.resolve(inputDir, 'main.ts');
34
+ if (fs_1.default.existsSync(mainTsPath)) {
35
+ return (0, utils_1.normalizePath)(mainTsPath);
36
+ }
37
+ return (0, utils_1.normalizePath)(path_1.default.resolve(inputDir, 'main.js'));
38
+ });
39
+ const ownerModules = ['@dcloudio/uni-app', '@dcloudio/vite-plugin-uni'];
40
+ const paths = [];
41
+ function resolveNodeModulePath(modulePath) {
42
+ const nodeModulesPaths = [];
43
+ const nodeModulesPath = path_1.default.join(modulePath, 'node_modules');
44
+ if (fs_1.default.existsSync(nodeModulesPath)) {
45
+ nodeModulesPaths.push(nodeModulesPath);
46
+ }
47
+ const index = modulePath.lastIndexOf('node_modules');
48
+ if (index > -1) {
49
+ nodeModulesPaths.push(path_1.default.join(modulePath.substr(0, index), 'node_modules'));
50
+ }
51
+ return nodeModulesPaths;
52
+ }
53
+ function initPaths() {
54
+ const cliContext = process.env.UNI_CLI_CONTEXT;
55
+ if (cliContext) {
56
+ const pathSet = new Set();
57
+ pathSet.add(path_1.default.join(cliContext, 'node_modules'));
58
+ if (!(0, env_1.isInHBuilderX)()) {
59
+ ;
60
+ [`@dcloudio/uni-` + process.env.UNI_PLATFORM, ...ownerModules].forEach((ownerModule) => {
61
+ let pkgPath = '';
62
+ try {
63
+ pkgPath = require.resolve(ownerModule + '/package.json', {
64
+ paths: [cliContext],
65
+ });
66
+ }
67
+ catch (e) { }
68
+ if (pkgPath) {
69
+ resolveNodeModulePath(path_1.default.dirname(pkgPath)).forEach((nodeModulePath) => {
70
+ pathSet.add(nodeModulePath);
71
+ });
72
+ }
73
+ });
74
+ }
75
+ paths.push(...pathSet);
76
+ (0, debug_1.default)('uni-paths')(paths);
77
+ }
78
+ }
79
+ function getBuiltInPaths() {
80
+ if (!paths.length) {
81
+ initPaths();
82
+ }
83
+ return paths;
84
+ }
85
+ exports.getBuiltInPaths = getBuiltInPaths;
86
+ function resolveBuiltIn(path) {
87
+ return require.resolve(path, { paths: getBuiltInPaths() });
88
+ }
89
+ exports.resolveBuiltIn = resolveBuiltIn;
90
+ let componentsLibPath = '';
91
+ function resolveComponentsLibPath() {
92
+ if (!componentsLibPath) {
93
+ if ((0, env_1.isInHBuilderX)()) {
94
+ componentsLibPath = path_1.default.join(resolveBuiltIn('@dcloudio/uni-components/package.json'), '../lib');
95
+ }
96
+ else {
97
+ componentsLibPath = path_1.default.join(resolveWithSymlinks('@dcloudio/uni-components/package.json', process.env.UNI_INPUT_DIR), '../lib');
98
+ }
99
+ }
100
+ return componentsLibPath;
101
+ }
102
+ exports.resolveComponentsLibPath = resolveComponentsLibPath;
@@ -0,0 +1,10 @@
1
+ export declare function parseScripts(name: string, pkgPath: string): {
2
+ name: string;
3
+ platform: keyof UniApp.PagesJsonPagePlatformStyle;
4
+ define: {
5
+ [name: string]: string;
6
+ };
7
+ context: {
8
+ [name: string]: boolean;
9
+ };
10
+ } | undefined;
@@ -0,0 +1,44 @@
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.parseScripts = void 0;
7
+ const shared_1 = require("@vue/shared");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ function parseScripts(name, pkgPath) {
10
+ var _a, _b;
11
+ if (!fs_1.default.existsSync(pkgPath)) {
12
+ return;
13
+ }
14
+ const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
15
+ const scripts = ((_a = pkg['uni-app']) === null || _a === void 0 ? void 0 : _a.scripts) || {};
16
+ const options = scripts[name];
17
+ if (!options) {
18
+ return;
19
+ }
20
+ if (!((_b = options.env) === null || _b === void 0 ? void 0 : _b.UNI_PLATFORM)) {
21
+ console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
22
+ process.exit(0);
23
+ }
24
+ const { UNI_PLATFORM, ...define } = options.env;
25
+ const context = options.define || {};
26
+ // 补充当前编译环境未定义的其他编译环境 define
27
+ Object.keys(scripts).forEach((scriptName) => {
28
+ if (scriptName !== name) {
29
+ const scriptDefine = scripts[scriptName].define || {};
30
+ Object.keys(scriptDefine).forEach((key) => {
31
+ if (!(0, shared_1.hasOwn)(context, key)) {
32
+ context[key] = false;
33
+ }
34
+ });
35
+ }
36
+ });
37
+ return {
38
+ name: name,
39
+ platform: UNI_PLATFORM,
40
+ define,
41
+ context,
42
+ };
43
+ }
44
+ exports.parseScripts = parseScripts;
package/dist/ssr.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const stripOptions: {
2
+ include: string[];
3
+ functions: string[];
4
+ };
package/dist/ssr.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripOptions = void 0;
4
+ exports.stripOptions = {
5
+ include: ['**/*.js', '**/*.ts', '**/*.tsx', '**/*.vue'],
6
+ functions: [
7
+ 'onBeforeMount',
8
+ 'onMounted',
9
+ 'onBeforeUpdate',
10
+ 'onUpdated',
11
+ 'onActivated',
12
+ 'onDeactivated',
13
+ 'onBeforeActivate',
14
+ 'onBeforeDeactivate',
15
+ 'onBeforeUnmount',
16
+ 'onUnmounted',
17
+ 'onRenderTracked',
18
+ 'onRenderTriggered',
19
+ ],
20
+ };
package/dist/url.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function encodeBase64Url(str: string): string;
2
+ export declare function decodeBase64Url(str: string): string;
package/dist/url.js ADDED
@@ -0,0 +1,15 @@
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.decodeBase64Url = exports.encodeBase64Url = void 0;
7
+ const base64url_1 = __importDefault(require("base64url"));
8
+ function encodeBase64Url(str) {
9
+ return base64url_1.default.encode(str);
10
+ }
11
+ exports.encodeBase64Url = encodeBase64Url;
12
+ function decodeBase64Url(str) {
13
+ return base64url_1.default.decode(str);
14
+ }
15
+ exports.decodeBase64Url = decodeBase64Url;
@@ -0,0 +1,13 @@
1
+ export { default as hash } from 'hash-sum';
2
+ import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
3
+ import { ParserPlugin } from '@babel/parser';
4
+ export declare let isRunningWithYarnPnp: boolean;
5
+ export declare const isWindows: boolean;
6
+ export declare function normalizePath(id: string): string;
7
+ export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
8
+ export declare function normalizeIdentifier(str: string): string;
9
+ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLATFORM): string | undefined;
10
+ export declare function removeExt(str: string): string;
11
+ export declare function normalizeNodeModules(str: string): string;
12
+ export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
13
+ export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): ParserPlugin[];