@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,150 @@
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.transformAssetUrl = exports.createAssetUrlTransformWithOptions = exports.normalizeOptions = exports.defaultAssetUrlOptions = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const compiler_core_1 = require("@vue/compiler-core");
9
+ const templateUtils_1 = require("./templateUtils");
10
+ const shared_1 = require("@vue/shared");
11
+ exports.defaultAssetUrlOptions = {
12
+ base: null,
13
+ includeAbsolute: false,
14
+ tags: {
15
+ video: ['src', 'poster'],
16
+ source: ['src'],
17
+ img: ['src'],
18
+ image: ['xlink:href', 'href'],
19
+ use: ['xlink:href', 'href'],
20
+ },
21
+ };
22
+ const normalizeOptions = (options) => {
23
+ if (Object.keys(options).some((key) => (0, shared_1.isArray)(options[key]))) {
24
+ // legacy option format which directly passes in tags config
25
+ return {
26
+ ...exports.defaultAssetUrlOptions,
27
+ tags: options,
28
+ };
29
+ }
30
+ return {
31
+ ...exports.defaultAssetUrlOptions,
32
+ ...options,
33
+ };
34
+ };
35
+ exports.normalizeOptions = normalizeOptions;
36
+ const createAssetUrlTransformWithOptions = (options) => {
37
+ return (node, context) => exports.transformAssetUrl(node, context, options);
38
+ };
39
+ exports.createAssetUrlTransformWithOptions = createAssetUrlTransformWithOptions;
40
+ /**
41
+ * A `@vue/compiler-core` plugin that transforms relative asset urls into
42
+ * either imports or absolute urls.
43
+ *
44
+ * ``` js
45
+ * // Before
46
+ * createVNode('img', { src: './logo.png' })
47
+ *
48
+ * // After
49
+ * import _imports_0 from './logo.png'
50
+ * createVNode('img', { src: _imports_0 })
51
+ * ```
52
+ */
53
+ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptions) => {
54
+ if (node.type === 1 /* ELEMENT */) {
55
+ if (!node.props.length) {
56
+ return;
57
+ }
58
+ const tags = options.tags || exports.defaultAssetUrlOptions.tags;
59
+ const attrs = tags[node.tag];
60
+ const wildCardAttrs = tags['*'];
61
+ if (!attrs && !wildCardAttrs) {
62
+ return;
63
+ }
64
+ // 策略:
65
+ // h5 平台保留原始策略
66
+ // 非 h5 平台
67
+ // - 绝对路径 static 资源不做转换
68
+ // - 相对路径 static 资源转换为绝对路径
69
+ // - 非 static 资源转换为 import
70
+ const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
71
+ node.props.forEach((attr, index) => {
72
+ if (attr.type !== 6 /* ATTRIBUTE */ ||
73
+ !assetAttrs.includes(attr.name) ||
74
+ !attr.value ||
75
+ (0, templateUtils_1.isExternalUrl)(attr.value.content) ||
76
+ (0, templateUtils_1.isDataUrl)(attr.value.content) ||
77
+ attr.value.content[0] === '#') {
78
+ return;
79
+ }
80
+ // fixed by xxxxxx 区分 static 资源
81
+ const isStaticAsset = attr.value.content.indexOf('/static/') > -1;
82
+ // 绝对路径的静态资源不作处理
83
+ if (isStaticAsset && !(0, templateUtils_1.isRelativeUrl)(attr.value.content)) {
84
+ return;
85
+ }
86
+ const url = (0, templateUtils_1.parseUrl)(attr.value.content);
87
+ if (options.base && attr.value.content[0] === '.' && isStaticAsset) {
88
+ // explicit base - directly rewrite relative urls into absolute url
89
+ // to avoid generating extra imports
90
+ // Allow for full hostnames provided in options.base
91
+ const base = (0, templateUtils_1.parseUrl)(options.base);
92
+ const protocol = base.protocol || '';
93
+ const host = base.host ? protocol + '//' + base.host : '';
94
+ const basePath = base.path || '/';
95
+ // when packaged in the browser, path will be using the posix-
96
+ // only version provided by rollup-plugin-node-builtins.
97
+ attr.value.content =
98
+ host +
99
+ (path_1.default.posix || path_1.default).join(basePath, url.path + (url.hash || ''));
100
+ return;
101
+ }
102
+ // otherwise, transform the url into an import.
103
+ // this assumes a bundler will resolve the import into the correct
104
+ // absolute url (e.g. webpack file-loader)
105
+ const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
106
+ node.props[index] = {
107
+ type: 7 /* DIRECTIVE */,
108
+ name: 'bind',
109
+ arg: (0, compiler_core_1.createSimpleExpression)(attr.name, true, attr.loc),
110
+ exp,
111
+ modifiers: [],
112
+ loc: attr.loc,
113
+ };
114
+ });
115
+ }
116
+ };
117
+ exports.transformAssetUrl = transformAssetUrl;
118
+ function getImportsExpressionExp(path, hash, loc, context) {
119
+ if (path) {
120
+ let name;
121
+ let exp;
122
+ const existingIndex = context.imports.findIndex((i) => i.path === path);
123
+ if (existingIndex > -1) {
124
+ name = `_imports_${existingIndex}`;
125
+ exp = context.imports[existingIndex].exp;
126
+ }
127
+ else {
128
+ name = `_imports_${context.imports.length}`;
129
+ exp = (0, compiler_core_1.createSimpleExpression)(name, false, loc, 2 /* CAN_HOIST */);
130
+ context.imports.push({ exp, path });
131
+ }
132
+ if (!hash) {
133
+ return exp;
134
+ }
135
+ const hashExp = `${name} + '${hash}'`;
136
+ const existingHoistIndex = context.hoists.findIndex((h) => {
137
+ return (h &&
138
+ h.type === 4 /* SIMPLE_EXPRESSION */ &&
139
+ !h.isStatic &&
140
+ h.content === hashExp);
141
+ });
142
+ if (existingHoistIndex > -1) {
143
+ return (0, compiler_core_1.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc, 2 /* CAN_HOIST */);
144
+ }
145
+ return context.hoist((0, compiler_core_1.createSimpleExpression)(hashExp, false, loc, 2 /* CAN_HOIST */));
146
+ }
147
+ else {
148
+ return (0, compiler_core_1.createSimpleExpression)(`''`, false, loc, 2 /* CAN_HOIST */);
149
+ }
150
+ }
@@ -0,0 +1,4 @@
1
+ import { NodeTransform } from '@vue/compiler-core';
2
+ import { AssetURLOptions } from './templateTransformAssetUrl';
3
+ export declare const createSrcsetTransformWithOptions: (options: Required<AssetURLOptions>) => NodeTransform;
4
+ export declare const transformSrcset: NodeTransform;
@@ -0,0 +1,122 @@
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.transformSrcset = exports.createSrcsetTransformWithOptions = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const compiler_core_1 = require("@vue/compiler-core");
9
+ const templateUtils_1 = require("./templateUtils");
10
+ const templateTransformAssetUrl_1 = require("./templateTransformAssetUrl");
11
+ const srcsetTags = ['img', 'source'];
12
+ // http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
13
+ const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
14
+ const createSrcsetTransformWithOptions = (options) => {
15
+ return (node, context) => exports.transformSrcset(node, context, options);
16
+ };
17
+ exports.createSrcsetTransformWithOptions = createSrcsetTransformWithOptions;
18
+ const transformSrcset = (node, context, options = templateTransformAssetUrl_1.defaultAssetUrlOptions) => {
19
+ if (node.type === 1 /* ELEMENT */) {
20
+ if (srcsetTags.includes(node.tag) && node.props.length) {
21
+ node.props.forEach((attr, index) => {
22
+ if (attr.name === 'srcset' && attr.type === 6 /* ATTRIBUTE */) {
23
+ if (!attr.value)
24
+ return;
25
+ const value = attr.value.content;
26
+ if (!value)
27
+ return;
28
+ const imageCandidates = value
29
+ .split(',')
30
+ .map((s) => {
31
+ // The attribute value arrives here with all whitespace, except
32
+ // normal spaces, represented by escape sequences
33
+ const [url, descriptor] = s
34
+ .replace(escapedSpaceCharacters, ' ')
35
+ .trim()
36
+ .split(' ', 2);
37
+ return { url, descriptor };
38
+ });
39
+ // data urls contains comma after the ecoding so we need to re-merge
40
+ // them
41
+ for (let i = 0; i < imageCandidates.length; i++) {
42
+ const { url } = imageCandidates[i];
43
+ if ((0, templateUtils_1.isDataUrl)(url)) {
44
+ imageCandidates[i + 1].url =
45
+ url + ',' + imageCandidates[i + 1].url;
46
+ imageCandidates.splice(i, 1);
47
+ }
48
+ }
49
+ const hasQualifiedUrl = imageCandidates.some(({ url }) => {
50
+ return (!(0, templateUtils_1.isExternalUrl)(url) &&
51
+ !(0, templateUtils_1.isDataUrl)(url) &&
52
+ (options.includeAbsolute || (0, templateUtils_1.isRelativeUrl)(url)));
53
+ });
54
+ // When srcset does not contain any qualified URLs, skip transforming
55
+ if (!hasQualifiedUrl) {
56
+ return;
57
+ }
58
+ if (options.base) {
59
+ const base = options.base;
60
+ const set = [];
61
+ imageCandidates.forEach(({ url, descriptor }) => {
62
+ descriptor = descriptor ? ` ${descriptor}` : ``;
63
+ if ((0, templateUtils_1.isRelativeUrl)(url)) {
64
+ set.push((path_1.default.posix || path_1.default).join(base, url) + descriptor);
65
+ }
66
+ else {
67
+ set.push(url + descriptor);
68
+ }
69
+ });
70
+ attr.value.content = set.join(', ');
71
+ return;
72
+ }
73
+ const compoundExpression = (0, compiler_core_1.createCompoundExpression)([], attr.loc);
74
+ imageCandidates.forEach(({ url, descriptor }, index) => {
75
+ if (!(0, templateUtils_1.isExternalUrl)(url) &&
76
+ !(0, templateUtils_1.isDataUrl)(url) &&
77
+ (options.includeAbsolute || (0, templateUtils_1.isRelativeUrl)(url))) {
78
+ const { path } = (0, templateUtils_1.parseUrl)(url);
79
+ let exp;
80
+ if (path) {
81
+ const existingImportsIndex = context.imports.findIndex((i) => i.path === path);
82
+ if (existingImportsIndex > -1) {
83
+ exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${existingImportsIndex}`, false, attr.loc, 2 /* CAN_HOIST */);
84
+ }
85
+ else {
86
+ exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${context.imports.length}`, false, attr.loc, 2 /* CAN_HOIST */);
87
+ context.imports.push({ exp, path });
88
+ }
89
+ compoundExpression.children.push(exp);
90
+ }
91
+ }
92
+ else {
93
+ const exp = (0, compiler_core_1.createSimpleExpression)(`"${url}"`, false, attr.loc, 2 /* CAN_HOIST */);
94
+ compoundExpression.children.push(exp);
95
+ }
96
+ const isNotLast = imageCandidates.length - 1 > index;
97
+ if (descriptor && isNotLast) {
98
+ compoundExpression.children.push(` + ' ${descriptor}, ' + `);
99
+ }
100
+ else if (descriptor) {
101
+ compoundExpression.children.push(` + ' ${descriptor}'`);
102
+ }
103
+ else if (isNotLast) {
104
+ compoundExpression.children.push(` + ', ' + `);
105
+ }
106
+ });
107
+ const hoisted = context.hoist(compoundExpression);
108
+ hoisted.constType = 2 /* CAN_HOIST */;
109
+ node.props[index] = {
110
+ type: 7 /* DIRECTIVE */,
111
+ name: 'bind',
112
+ arg: (0, compiler_core_1.createSimpleExpression)('srcset', true, attr.loc),
113
+ exp: hoisted,
114
+ modifiers: [],
115
+ loc: attr.loc,
116
+ };
117
+ }
118
+ });
119
+ }
120
+ }
121
+ };
122
+ exports.transformSrcset = transformSrcset;
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import { UrlWithStringQuery } from 'url';
3
+ export declare function isRelativeUrl(url: string): boolean;
4
+ export declare function isExternalUrl(url: string): boolean;
5
+ export declare function isDataUrl(url: string): boolean;
6
+ /**
7
+ * Parses string url into URL object.
8
+ */
9
+ export declare function parseUrl(url: string): UrlWithStringQuery;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseUrl = exports.isDataUrl = exports.isExternalUrl = exports.isRelativeUrl = void 0;
4
+ const url_1 = require("url");
5
+ const shared_1 = require("@vue/shared");
6
+ function isRelativeUrl(url) {
7
+ const firstChar = url.charAt(0);
8
+ return firstChar === '.' || firstChar === '~' || firstChar === '@';
9
+ }
10
+ exports.isRelativeUrl = isRelativeUrl;
11
+ const externalRE = /^(https?:)?\/\//;
12
+ function isExternalUrl(url) {
13
+ return externalRE.test(url);
14
+ }
15
+ exports.isExternalUrl = isExternalUrl;
16
+ const dataUrlRE = /^\s*data:/i;
17
+ function isDataUrl(url) {
18
+ return dataUrlRE.test(url);
19
+ }
20
+ exports.isDataUrl = isDataUrl;
21
+ /**
22
+ * Parses string url into URL object.
23
+ */
24
+ function parseUrl(url) {
25
+ const firstChar = url.charAt(0);
26
+ if (firstChar === '~') {
27
+ const secondChar = url.charAt(1);
28
+ url = url.slice(secondChar === '/' ? 2 : 1);
29
+ }
30
+ return parseUriParts(url);
31
+ }
32
+ exports.parseUrl = parseUrl;
33
+ /**
34
+ * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
35
+ * @param urlString an url as a string
36
+ */
37
+ function parseUriParts(urlString) {
38
+ // A TypeError is thrown if urlString is not a string
39
+ // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
40
+ return (0, url_1.parse)((0, shared_1.isString)(urlString) ? urlString : '', false, true);
41
+ }
@@ -0,0 +1,3 @@
1
+ import { NodeTypes, RootNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
2
+ import { COMPONENT_BIND_LINK, COMPONENT_ON_LINK } from '../../mp/constants';
3
+ export declare function createTransformComponentLink(name: typeof COMPONENT_BIND_LINK | typeof COMPONENT_ON_LINK, type?: NodeTypes.ATTRIBUTE | NodeTypes.DIRECTIVE): (node: RootNode | TemplateChildNode, context: TransformContext) => void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransformComponentLink = void 0;
4
+ const compiler_core_1 = require("@vue/compiler-core");
5
+ const utils_1 = require("../utils");
6
+ function createTransformComponentLink(name, type = 7 /* DIRECTIVE */) {
7
+ return function transformComponentLink(node, context) {
8
+ if (!(0, utils_1.isUserComponent)(node, context)) {
9
+ return;
10
+ }
11
+ if (type === 7 /* DIRECTIVE */) {
12
+ node.props.push({
13
+ type: 7 /* DIRECTIVE */,
14
+ name: 'on',
15
+ modifiers: [],
16
+ loc: compiler_core_1.locStub,
17
+ arg: (0, compiler_core_1.createSimpleExpression)(name, true),
18
+ exp: (0, compiler_core_1.createSimpleExpression)('__l', true),
19
+ });
20
+ }
21
+ else {
22
+ node.props.push((0, utils_1.createAttributeNode)(name, '__l'));
23
+ }
24
+ };
25
+ }
26
+ exports.createTransformComponentLink = createTransformComponentLink;
@@ -0,0 +1,2 @@
1
+ import { DirectiveNode, ElementNode, NodeTransform } from '@vue/compiler-core';
2
+ export declare function createTransformEvent(options: Record<string, string | ((node: ElementNode, dir: DirectiveNode) => string)>): NodeTransform;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransformEvent = void 0;
4
+ const shared_1 = require("@vue/shared");
5
+ const ast_1 = require("../../vite/utils/ast");
6
+ function createTransformEvent(options) {
7
+ return function transformEvent(node) {
8
+ if (!(0, ast_1.isElementNode)(node)) {
9
+ return;
10
+ }
11
+ node.props.forEach((prop) => {
12
+ const { name, arg } = prop;
13
+ if (name === 'on' && arg && (0, ast_1.isSimpleExpressionNode)(arg)) {
14
+ const eventType = options[arg.content];
15
+ if (eventType) {
16
+ // e.g tap => click
17
+ if ((0, shared_1.isFunction)(eventType)) {
18
+ arg.content = eventType(node, prop);
19
+ }
20
+ else {
21
+ arg.content = eventType;
22
+ }
23
+ }
24
+ }
25
+ });
26
+ };
27
+ }
28
+ exports.createTransformEvent = createTransformEvent;
@@ -0,0 +1,2 @@
1
+ import { NodeTransform } from '@vue/compiler-core';
2
+ export declare const transformPageHead: NodeTransform;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformPageHead = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const transformPageHead = (node, context) => {
6
+ // 发现是page-meta下的head,直接remove该节点
7
+ (0, utils_1.checkElementNodeTag)(node, 'head') &&
8
+ (0, utils_1.checkElementNodeTag)(context.parent, 'page-meta') &&
9
+ context.removeNode(node);
10
+ };
11
+ exports.transformPageHead = transformPageHead;
@@ -0,0 +1,2 @@
1
+ import { RootNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
2
+ export declare function transformRef(node: RootNode | TemplateChildNode, context: TransformContext): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformRef = void 0;
4
+ const compiler_core_1 = require("@vue/compiler-core");
5
+ const utils_1 = require("../utils");
6
+ function transformRef(node, context) {
7
+ if (!(0, utils_1.isUserComponent)(node, context)) {
8
+ return;
9
+ }
10
+ addVueRef(node, context);
11
+ }
12
+ exports.transformRef = transformRef;
13
+ function addVueRef(node, context) {
14
+ // 仅配置了 ref 属性的,才需要增补 vue-ref
15
+ const refProp = (0, compiler_core_1.findProp)(node, 'ref');
16
+ if (!refProp) {
17
+ return;
18
+ }
19
+ if (refProp.type === 6 /* ATTRIBUTE */) {
20
+ refProp.name = 'u-' + utils_1.VUE_REF;
21
+ }
22
+ else {
23
+ ;
24
+ refProp.arg.content = 'u-' + utils_1.VUE_REF;
25
+ }
26
+ return (0, utils_1.addStaticClass)(node,
27
+ // ref-in-for
28
+ // ref
29
+ context.inVFor
30
+ ? utils_1.VUE_REF_IN_FOR
31
+ : utils_1.VUE_REF);
32
+ }
@@ -0,0 +1,2 @@
1
+ import { NodeTransform } from '@vue/compiler-core';
2
+ export declare function createTransformTag(opts: Record<string, string>): NodeTransform;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransformTag = void 0;
4
+ const ast_1 = require("../../vite/utils/ast");
5
+ function createTransformTag(opts) {
6
+ return function transformTag(node, context) {
7
+ if (!(0, ast_1.isElementNode)(node)) {
8
+ return;
9
+ }
10
+ const oldTag = node.tag;
11
+ const newTag = opts[oldTag];
12
+ if (!newTag) {
13
+ return;
14
+ }
15
+ node.tag = newTag;
16
+ };
17
+ }
18
+ exports.createTransformTag = createTransformTag;
@@ -0,0 +1,12 @@
1
+ import { DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
2
+ export declare function defaultMatch(node: ElementNode, context: TransformContext): boolean;
3
+ interface CreateTransformModelOptions {
4
+ match: typeof defaultMatch;
5
+ }
6
+ /**
7
+ * 百度、快手小程序的自定义组件,不支持动态事件绑定,故 v-model 也需要调整
8
+ * @param baseTransformModel
9
+ * @returns
10
+ */
11
+ export declare function createTransformModel(baseTransformModel: DirectiveTransform, { match }?: CreateTransformModelOptions): DirectiveTransform;
12
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransformModel = exports.defaultMatch = void 0;
4
+ const utils_1 = require("../utils");
5
+ const vOn_1 = require("./vOn");
6
+ function defaultMatch(node, context) {
7
+ return (0, utils_1.isUserComponent)(node, context);
8
+ }
9
+ exports.defaultMatch = defaultMatch;
10
+ /**
11
+ * 百度、快手小程序的自定义组件,不支持动态事件绑定,故 v-model 也需要调整
12
+ * @param baseTransformModel
13
+ * @returns
14
+ */
15
+ function createTransformModel(baseTransformModel, { match } = {
16
+ match: defaultMatch,
17
+ }) {
18
+ return (dir, node, context, augmentor) => {
19
+ const res = baseTransformModel(dir, node, context, augmentor);
20
+ if (!match(node, context)) {
21
+ return res;
22
+ }
23
+ const props = res.props;
24
+ if (props[1]) {
25
+ // input,textarea 的 v-model 事件可能会被合并到已有的 input 中
26
+ const { arg, exp } = props[1];
27
+ (0, vOn_1.addEventOpts)(arg.content, exp, node);
28
+ props[1].exp = (0, vOn_1.createCustomEventExpr)();
29
+ }
30
+ return res;
31
+ };
32
+ }
33
+ exports.createTransformModel = createTransformModel;
@@ -0,0 +1,15 @@
1
+ import { ExpressionNode, DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
2
+ export declare function defaultMatch(name: string, node: ElementNode, context: TransformContext): boolean;
3
+ interface CreateTransformOnOptions {
4
+ match: typeof defaultMatch;
5
+ }
6
+ /**
7
+ * 百度、快手小程序的自定义组件,不支持动态事件绑定,故转换为静态事件 + dataset
8
+ * @param baseTransformOn
9
+ * @returns
10
+ */
11
+ export declare function createTransformOn(baseTransformOn: DirectiveTransform, { match }?: CreateTransformOnOptions): DirectiveTransform;
12
+ export declare function createCustomEventExpr(): import("@vue/compiler-core").SimpleExpressionNode;
13
+ export declare function addEventOpts(event: string, value: ExpressionNode, node: ElementNode): void;
14
+ export declare const ATTR_DATASET_EVENT_OPTS = "data-e-o";
15
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ATTR_DATASET_EVENT_OPTS = exports.addEventOpts = exports.createCustomEventExpr = exports.createTransformOn = exports.defaultMatch = void 0;
4
+ const compiler_core_1 = require("@vue/compiler-core");
5
+ const utils_1 = require("../utils");
6
+ function defaultMatch(name, node, context) {
7
+ return isCustomEvent(name) && (0, utils_1.isUserComponent)(node, context);
8
+ }
9
+ exports.defaultMatch = defaultMatch;
10
+ /**
11
+ * 百度、快手小程序的自定义组件,不支持动态事件绑定,故转换为静态事件 + dataset
12
+ * @param baseTransformOn
13
+ * @returns
14
+ */
15
+ function createTransformOn(baseTransformOn, { match } = {
16
+ match: defaultMatch,
17
+ }) {
18
+ return (dir, node, context, augmentor) => {
19
+ const res = baseTransformOn(dir, node, context, augmentor);
20
+ const { name, arg, exp } = dir;
21
+ if (name !== 'on' || !arg || !exp || !(0, compiler_core_1.isStaticExp)(arg)) {
22
+ return res;
23
+ }
24
+ if (!match(arg.content, node, context)) {
25
+ return res;
26
+ }
27
+ const value = res.props[0].value;
28
+ res.props[0].value = createCustomEventExpr();
29
+ addEventOpts(arg.content, value, node);
30
+ return res;
31
+ };
32
+ }
33
+ exports.createTransformOn = createTransformOn;
34
+ function createCustomEventExpr() {
35
+ return (0, compiler_core_1.createSimpleExpression)('__e', true);
36
+ }
37
+ exports.createCustomEventExpr = createCustomEventExpr;
38
+ function addEventOpts(event, value, node) {
39
+ const attrName = node.tagType === 1 /* COMPONENT */
40
+ ? ATTR_DATA_EVENT_OPTS
41
+ : exports.ATTR_DATASET_EVENT_OPTS;
42
+ const opts = (0, compiler_core_1.findProp)(node, attrName, true);
43
+ if (!opts) {
44
+ node.props.push(createDataEventOptsProp(attrName, event, value));
45
+ }
46
+ else {
47
+ const children = opts.exp.children;
48
+ children.splice(children.length - 2, 0, createDataEventOptsProperty(event, value));
49
+ }
50
+ }
51
+ exports.addEventOpts = addEventOpts;
52
+ const ATTR_DATA_EVENT_OPTS = 'eO';
53
+ exports.ATTR_DATASET_EVENT_OPTS = 'data-e-o';
54
+ function createDataEventOptsProperty(event, exp) {
55
+ return (0, compiler_core_1.createCompoundExpression)([`'${event}'`, ': ', exp, ',']);
56
+ }
57
+ function createDataEventOptsProp(name, event, exp) {
58
+ return {
59
+ type: 7 /* DIRECTIVE */,
60
+ name: 'bind',
61
+ loc: compiler_core_1.locStub,
62
+ modifiers: [],
63
+ arg: (0, compiler_core_1.createSimpleExpression)(name, true),
64
+ exp: (0, compiler_core_1.createCompoundExpression)([
65
+ '{',
66
+ createDataEventOptsProperty(event, exp),
67
+ '}',
68
+ ]),
69
+ };
70
+ }
71
+ const builtInEvents = [
72
+ '__l',
73
+ 'tap',
74
+ 'longtap',
75
+ 'longpress',
76
+ 'touchstart',
77
+ 'touchmove',
78
+ 'touchcancel',
79
+ 'touchend',
80
+ 'touchforcechange',
81
+ 'transitionend',
82
+ 'animationstart',
83
+ 'animationiteration',
84
+ 'animationend',
85
+ ];
86
+ function isCustomEvent(name) {
87
+ return !builtInEvents.includes(name);
88
+ }
@@ -0,0 +1,31 @@
1
+ import { AttributeNode, ComponentNode, DirectiveNode, ElementNode, RootNode, ExpressionNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
2
+ export declare const VUE_REF = "r";
3
+ export declare const VUE_REF_IN_FOR = "r-i-f";
4
+ export declare function isVueSfcFile(id: string): boolean;
5
+ export declare function isUserComponent(node: RootNode | TemplateChildNode, context: {
6
+ isBuiltInComponent: TransformContext['isBuiltInComponent'];
7
+ }): node is ComponentNode;
8
+ export declare function createAttributeNode(name: string, content: string): AttributeNode;
9
+ export declare function addStaticClass(node: ElementNode, clazz: string): string | number | undefined;
10
+ export declare function createDirectiveNode(name: string, arg: string, exp?: string | ExpressionNode): DirectiveNode;
11
+ export declare function createOnDirectiveNode(name: string, value: string): DirectiveNode;
12
+ export declare function createBindDirectiveNode(name: string, value: string | ExpressionNode): DirectiveNode;
13
+ export declare function createUniVueTransformAssetUrls(base: string): {
14
+ base: string;
15
+ includeAbsolute: boolean;
16
+ tags: {
17
+ audio: string[];
18
+ video: string[];
19
+ img: string[];
20
+ image: string[];
21
+ 'cover-image': string[];
22
+ 'v-uni-audio': string[];
23
+ 'v-uni-video': string[];
24
+ 'v-uni-image': string[];
25
+ 'v-uni-cover-image': string[];
26
+ 'u-image': string[];
27
+ 'u-video': string[];
28
+ };
29
+ };
30
+ export declare function getBaseNodeTransforms(base: string): import("@vue/compiler-core").NodeTransform[];
31
+ export declare function renameProp(name: string, prop?: DirectiveNode | AttributeNode): void;