@dcloudio/uni-cli-shared 3.0.0-4000820240401001 → 3.0.0-4010420240430002
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.
- package/dist/deps.d.ts +2 -0
- package/dist/deps.js +3 -0
- package/dist/easycom.js +4 -3
- package/dist/hbx/alias.js +26 -5
- package/dist/hbx/index.d.ts +1 -1
- package/dist/hbx/log.d.ts +1 -1
- package/dist/hbx/log.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/json/app/pages/code.d.ts +1 -1
- package/dist/json/mp/index.d.ts +1 -1
- package/dist/json/mp/jsonFile.d.ts +1 -1
- package/dist/json/mp/pages.d.ts +1 -1
- package/dist/json/mp/project.js +2 -2
- package/dist/json/mp/types.d.ts +1 -1
- package/dist/json/mp/utils.d.ts +1 -1
- package/dist/json/uni-x/uniConfig.js +4 -0
- package/dist/logs/console.d.ts +2 -4
- package/dist/logs/console.js +7 -4
- package/dist/logs/format.d.ts +1 -1
- package/dist/mp/ast.d.ts +1 -1
- package/dist/mp/externalClasses.d.ts +1 -1
- package/dist/mp/imports.d.ts +2 -2
- package/dist/mp/plugin.d.ts +1 -1
- package/dist/mp/tags.js +5 -6
- package/dist/mp/usingComponents.d.ts +1 -1
- package/dist/postcss/index.d.ts +1 -1
- package/dist/uni_modules.d.ts +23 -0
- package/dist/uni_modules.js +80 -12
- package/dist/utils.d.ts +3 -5
- package/dist/utils.js +7 -7
- package/dist/uts.d.ts +3 -4
- package/dist/uts.js +28 -42
- package/dist/utsUtils.d.ts +2 -0
- package/dist/utsUtils.js +44 -0
- package/dist/vite/autoImport.d.ts +1 -1
- package/dist/vite/autoImport.js +1 -0
- package/dist/vite/features.d.ts +1 -0
- package/dist/vite/features.js +31 -28
- package/dist/vite/index.d.ts +2 -1
- package/dist/vite/plugins/console.d.ts +2 -2
- package/dist/vite/plugins/copy.d.ts +1 -1
- package/dist/vite/plugins/easycom.d.ts +2 -2
- package/dist/vite/plugins/index.d.ts +1 -0
- package/dist/vite/plugins/index.js +3 -1
- package/dist/vite/plugins/inject.d.ts +1 -1
- package/dist/vite/plugins/inject.js +2 -2
- package/dist/vite/plugins/jsonJs.d.ts +3 -3
- package/dist/vite/plugins/mainJs.d.ts +2 -2
- package/dist/vite/plugins/sfc.d.ts +6 -0
- package/dist/vite/plugins/sfc.js +136 -0
- package/dist/vite/plugins/uts/ext-api.d.ts +2 -1
- package/dist/vite/plugins/uts/ext-api.js +4 -5
- package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
- package/dist/vite/plugins/uts/uni_modules.js +20 -7
- package/dist/vite/plugins/uts/uvue.js +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +2 -2
- package/dist/vite/plugins/vitejs/plugins/asset.js +1 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -4
- package/dist/vite/plugins/vitejs/plugins/css.js +10 -2
- package/dist/vite/plugins/vitejs/utils.d.ts +1 -1
- package/dist/vite/utils/ast.d.ts +2 -2
- package/dist/vite/utils/ast.js +7 -6
- package/dist/vite/utils/utils.d.ts +2 -2
- package/dist/vue/babel.d.ts +1 -1
- package/dist/vue/parse.d.ts +1 -1
- package/dist/vue/parse.js +8 -7
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +1 -0
- package/dist/vue/transforms/templateTransformAssetUrl.d.ts +1 -1
- package/dist/vue/transforms/templateTransformAssetUrl.js +8 -8
- package/dist/vue/transforms/templateTransformSrcset.d.ts +2 -2
- package/dist/vue/transforms/templateTransformSrcset.js +7 -7
- package/dist/vue/transforms/templateUtils.d.ts +1 -1
- package/dist/vue/transforms/transformComponent.d.ts +2 -2
- package/dist/vue/transforms/transformComponent.js +7 -3
- package/dist/vue/transforms/transformEvent.d.ts +1 -1
- package/dist/vue/transforms/transformPageHead.d.ts +1 -1
- package/dist/vue/transforms/transformRef.d.ts +1 -1
- package/dist/vue/transforms/transformRef.js +1 -1
- package/dist/vue/transforms/transformRefresherSlot.d.ts +8 -0
- package/dist/vue/transforms/transformRefresherSlot.js +58 -0
- package/dist/vue/transforms/transformTag.d.ts +1 -1
- package/dist/vue/transforms/transformUTSComponent.d.ts +1 -1
- package/dist/vue/transforms/transformUTSComponent.js +2 -2
- package/dist/vue/transforms/vModel.d.ts +1 -1
- package/dist/vue/transforms/vOn.d.ts +1 -1
- package/dist/vue/transforms/vOn.js +4 -4
- package/dist/vue/utils.d.ts +4 -1
- package/dist/vue/utils.js +47 -8
- package/dist/watcher.d.ts +1 -1
- package/lib/@vue/compiler-sfc/LICENSE +21 -0
- package/lib/@vue/compiler-sfc/README.md +80 -0
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +20665 -0
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.d.ts +543 -0
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +48237 -0
- package/lib/@vue/compiler-sfc/package.json +67 -0
- package/package.json +20 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
3
|
-
import { Plugin } from '../plugin';
|
|
4
|
-
import { ResolvedConfig } from '../config';
|
|
3
|
+
import type { Plugin } from '../plugin';
|
|
4
|
+
import type { ResolvedConfig } from '../config';
|
|
5
5
|
export declare const assetUrlRE: RegExp;
|
|
6
6
|
export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
|
|
7
7
|
/**
|
|
@@ -33,9 +33,9 @@ const lite_1 = __importDefault(require("mime/lite"));
|
|
|
33
33
|
const fs_extra_1 = __importStar(require("fs-extra"));
|
|
34
34
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
35
35
|
const crypto_1 = require("crypto");
|
|
36
|
+
const shared_1 = require("@vue/shared");
|
|
36
37
|
const utils_1 = require("../utils");
|
|
37
38
|
const utils_2 = require("../../../../vite/utils/utils");
|
|
38
|
-
const shared_1 = require("@vue/shared");
|
|
39
39
|
const utils_3 = require("../../../../utils");
|
|
40
40
|
exports.assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g;
|
|
41
41
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { SFCDescriptor } from '@vue/compiler-sfc';
|
|
2
|
+
import type { ExistingRawSourceMap, RollupError } from 'rollup';
|
|
3
|
+
import type { Plugin } from '../plugin';
|
|
4
|
+
import type { ResolvedConfig } from '../config';
|
|
4
5
|
import * as Postcss from 'postcss';
|
|
5
|
-
import { SFCDescriptor } from '@vue/compiler-sfc';
|
|
6
6
|
export interface CSSOptions {
|
|
7
7
|
/**
|
|
8
8
|
* https://github.com/css-modules/postcss-modules
|
|
@@ -131,8 +131,13 @@ function cssPlugin(config, options = { isAndroidX: false }) {
|
|
|
131
131
|
return (0, asset_1.fileToUrl)(resolved, config, options?.isAndroidX
|
|
132
132
|
? {
|
|
133
133
|
emitFile(emittedFile) {
|
|
134
|
+
const fileName = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, emittedFile.fileName);
|
|
135
|
+
// 忽略static(可能有只读文件,写入覆盖只读会报错权限)
|
|
136
|
+
if ((0, utils_1.normalizePath)(fileName).includes('/static/')) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
134
139
|
// 直接写入目标目录
|
|
135
|
-
fs_extra_1.default.outputFileSync(
|
|
140
|
+
fs_extra_1.default.outputFileSync(fileName, emittedFile.source);
|
|
136
141
|
},
|
|
137
142
|
}
|
|
138
143
|
: this, true);
|
|
@@ -602,7 +607,6 @@ async function resolvePostcssConfig(config) {
|
|
|
602
607
|
else {
|
|
603
608
|
const searchPath = (0, shared_1.isString)(inlineOptions) ? inlineOptions : config.root;
|
|
604
609
|
try {
|
|
605
|
-
// @ts-ignore
|
|
606
610
|
result = await (0, postcss_load_config_1.default)({}, searchPath);
|
|
607
611
|
}
|
|
608
612
|
catch (e) {
|
|
@@ -1136,5 +1140,9 @@ function rewriteScssReadFileSync() {
|
|
|
1136
1140
|
}
|
|
1137
1141
|
return content;
|
|
1138
1142
|
});
|
|
1143
|
+
// TODO 在 web 端,目前使用的是 vite 内置的 css 预处理
|
|
1144
|
+
// 最新的 vite less 使用的是 readFile,https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/css.ts#L2336
|
|
1145
|
+
// 拦截 readFile 的话,要考虑的细节较多,暂不实现了
|
|
1146
|
+
// 稍后 web 端,也直接内部定制 css 的预处理
|
|
1139
1147
|
}
|
|
1140
1148
|
exports.rewriteScssReadFileSync = rewriteScssReadFileSync;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
|
|
2
|
-
import { Position, SourceLocation } from '@vue/compiler-core';
|
|
2
|
+
import type { Position, SourceLocation } from '@vue/compiler-core';
|
|
3
3
|
import { LinesAndColumns } from 'lines-and-columns';
|
|
4
4
|
export declare function slash(p: string): string;
|
|
5
5
|
export declare const bareImportRE: RegExp;
|
package/dist/vite/utils/ast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { AssignmentExpression, BaseNode, CallExpression, ExportSpecifier, Identifier, Literal, MemberExpression, MethodDefinition, Property } from 'estree';
|
|
2
|
+
import { type AttributeNode, type CompoundExpressionNode, type DirectiveNode, type ElementNode, type Node, type SimpleExpressionNode } from '@vue/compiler-core';
|
|
3
3
|
export declare const isProperty: (node: BaseNode) => node is Property;
|
|
4
4
|
export declare const isIdentifier: (node: BaseNode) => node is Identifier;
|
|
5
5
|
export declare const isAssignmentExpression: (node: BaseNode) => node is AssignmentExpression;
|
package/dist/vite/utils/ast.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCompoundExpressionNode = exports.isSimpleExpressionNode = exports.isDirectiveNode = exports.isAttributeNode = exports.isElementNode = exports.parseVue = exports.createCallExpression = exports.createIdentifier = exports.createLiteral = exports.isReference = exports.isExportSpecifier = exports.isMethodDefinition = exports.isMemberExpression = exports.isCallExpression = exports.isAssignmentExpression = exports.isIdentifier = exports.isProperty = void 0;
|
|
4
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
4
5
|
const compiler_dom_1 = require("@vue/compiler-dom");
|
|
5
6
|
const isProperty = (node) => node.type === 'Property';
|
|
6
7
|
exports.isProperty = isProperty;
|
|
@@ -64,7 +65,7 @@ function parseVue(code, errors) {
|
|
|
64
65
|
return (0, compiler_dom_1.parse)(code, {
|
|
65
66
|
isNativeTag: () => true,
|
|
66
67
|
isPreTag: () => true,
|
|
67
|
-
|
|
68
|
+
parseMode: 'sfc',
|
|
68
69
|
onError: (e) => {
|
|
69
70
|
errors.push(e);
|
|
70
71
|
},
|
|
@@ -72,22 +73,22 @@ function parseVue(code, errors) {
|
|
|
72
73
|
}
|
|
73
74
|
exports.parseVue = parseVue;
|
|
74
75
|
function isElementNode(node) {
|
|
75
|
-
return node.type ===
|
|
76
|
+
return node.type === compiler_core_1.NodeTypes.ELEMENT;
|
|
76
77
|
}
|
|
77
78
|
exports.isElementNode = isElementNode;
|
|
78
79
|
function isAttributeNode(node) {
|
|
79
|
-
return node.type ===
|
|
80
|
+
return node.type === compiler_core_1.NodeTypes.ATTRIBUTE;
|
|
80
81
|
}
|
|
81
82
|
exports.isAttributeNode = isAttributeNode;
|
|
82
83
|
function isDirectiveNode(node) {
|
|
83
|
-
return node.type ===
|
|
84
|
+
return node.type === compiler_core_1.NodeTypes.DIRECTIVE;
|
|
84
85
|
}
|
|
85
86
|
exports.isDirectiveNode = isDirectiveNode;
|
|
86
87
|
function isSimpleExpressionNode(node) {
|
|
87
|
-
return node.type ===
|
|
88
|
+
return node.type === compiler_core_1.NodeTypes.SIMPLE_EXPRESSION;
|
|
88
89
|
}
|
|
89
90
|
exports.isSimpleExpressionNode = isSimpleExpressionNode;
|
|
90
91
|
function isCompoundExpressionNode(node) {
|
|
91
|
-
return node.type ===
|
|
92
|
+
return node.type === compiler_core_1.NodeTypes.COMPOUND_EXPRESSION;
|
|
92
93
|
}
|
|
93
94
|
exports.isCompoundExpressionNode = isCompoundExpressionNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigEnv, ResolvedConfig, UserConfig } from 'vite';
|
|
2
|
-
import { RollupError } from 'rollup';
|
|
3
|
-
import { CompilerError } from '@vue/compiler-sfc';
|
|
2
|
+
import type { RollupError } from 'rollup';
|
|
3
|
+
import type { CompilerError } from '@vue/compiler-sfc';
|
|
4
4
|
import { codeFrameColumns } from '@babel/code-frame';
|
|
5
5
|
export declare function withSourcemap(config: ResolvedConfig): boolean;
|
|
6
6
|
export declare function isInHybridNVue(config: UserConfig | ResolvedConfig): boolean;
|
package/dist/vue/babel.d.ts
CHANGED
package/dist/vue/parse.d.ts
CHANGED
package/dist/vue/parse.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseWxsCode = exports.parseWxsNodes = exports.parseBlockCode = exports.parseVueCode = void 0;
|
|
7
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
7
8
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
9
|
const ast_1 = require("../vite/utils/ast");
|
|
9
10
|
const BLOCK_RE = /<\/block>/;
|
|
@@ -28,7 +29,7 @@ function parseVueCode(code, isNVue = false) {
|
|
|
28
29
|
code = parseWxsCode(wxsNodes, code);
|
|
29
30
|
// add watch
|
|
30
31
|
for (const wxsNode of wxsNodes) {
|
|
31
|
-
const srcProp = wxsNode.props.find((prop) => prop.type ===
|
|
32
|
+
const srcProp = wxsNode.props.find((prop) => prop.type === compiler_core_1.NodeTypes.ATTRIBUTE && prop.name === 'src');
|
|
32
33
|
if (srcProp && srcProp.value) {
|
|
33
34
|
files.push(srcProp.value.content);
|
|
34
35
|
}
|
|
@@ -44,10 +45,10 @@ function traverseNode(node, blockNodes) {
|
|
|
44
45
|
if ((0, ast_1.isElementNode)(node) && node.tag === 'block') {
|
|
45
46
|
blockNodes.push(node);
|
|
46
47
|
}
|
|
47
|
-
if (node.type ===
|
|
48
|
-
node.type ===
|
|
49
|
-
node.type ===
|
|
50
|
-
node.type ===
|
|
48
|
+
if (node.type === compiler_core_1.NodeTypes.IF_BRANCH ||
|
|
49
|
+
node.type === compiler_core_1.NodeTypes.FOR ||
|
|
50
|
+
node.type === compiler_core_1.NodeTypes.ELEMENT ||
|
|
51
|
+
node.type === compiler_core_1.NodeTypes.ROOT) {
|
|
51
52
|
traverseChildren(node, blockNodes);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -73,10 +74,10 @@ function parseBlockNode(code, blocks) {
|
|
|
73
74
|
return magicString.toString();
|
|
74
75
|
}
|
|
75
76
|
function parseWxsNodes(ast) {
|
|
76
|
-
return ast.children.filter((node) => node.type ===
|
|
77
|
+
return ast.children.filter((node) => node.type === compiler_core_1.NodeTypes.ELEMENT &&
|
|
77
78
|
node.tag === 'script' &&
|
|
78
79
|
node.props.find((prop) => prop.name === 'lang' &&
|
|
79
|
-
prop.type ===
|
|
80
|
+
prop.type === compiler_core_1.NodeTypes.ATTRIBUTE &&
|
|
80
81
|
prop.value &&
|
|
81
82
|
WXS_ATTRS.includes(prop.value.content)));
|
|
82
83
|
}
|
|
@@ -4,6 +4,7 @@ export * from './transformComponent';
|
|
|
4
4
|
export * from './transformEvent';
|
|
5
5
|
export * from './transformTag';
|
|
6
6
|
export * from './transformUTSComponent';
|
|
7
|
+
export * from './transformRefresherSlot';
|
|
7
8
|
export { createAssetUrlTransformWithOptions } from './templateTransformAssetUrl';
|
|
8
9
|
export { createSrcsetTransformWithOptions } from './templateTransformSrcset';
|
|
9
10
|
export { STRINGIFY_JSON, ATTR_DATASET_EVENT_OPTS, createTransformOn, defaultMatch as matchTransformOn, } from './vOn';
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./transformComponent"), exports);
|
|
|
26
26
|
__exportStar(require("./transformEvent"), exports);
|
|
27
27
|
__exportStar(require("./transformTag"), exports);
|
|
28
28
|
__exportStar(require("./transformUTSComponent"), exports);
|
|
29
|
+
__exportStar(require("./transformRefresherSlot"), exports);
|
|
29
30
|
var templateTransformAssetUrl_1 = require("./templateTransformAssetUrl");
|
|
30
31
|
Object.defineProperty(exports, "createAssetUrlTransformWithOptions", { enumerable: true, get: function () { return templateTransformAssetUrl_1.createAssetUrlTransformWithOptions; } });
|
|
31
32
|
var templateTransformSrcset_1 = require("./templateTransformSrcset");
|
|
@@ -51,7 +51,7 @@ exports.createAssetUrlTransformWithOptions = createAssetUrlTransformWithOptions;
|
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptions) => {
|
|
54
|
-
if (node.type ===
|
|
54
|
+
if (node.type === compiler_core_1.NodeTypes.ELEMENT) {
|
|
55
55
|
if (!node.props.length) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -69,7 +69,7 @@ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptio
|
|
|
69
69
|
// - 非 static 资源转换为 import
|
|
70
70
|
const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
|
|
71
71
|
node.props.forEach((attr, index) => {
|
|
72
|
-
if (attr.type !==
|
|
72
|
+
if (attr.type !== compiler_core_1.NodeTypes.ATTRIBUTE ||
|
|
73
73
|
!assetAttrs.includes(attr.name) ||
|
|
74
74
|
!attr.value ||
|
|
75
75
|
(0, templateUtils_1.isExternalUrl)(attr.value.content) ||
|
|
@@ -104,7 +104,7 @@ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptio
|
|
|
104
104
|
// absolute url (e.g. webpack file-loader)
|
|
105
105
|
const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
|
|
106
106
|
node.props[index] = {
|
|
107
|
-
type:
|
|
107
|
+
type: compiler_core_1.NodeTypes.DIRECTIVE,
|
|
108
108
|
name: 'bind',
|
|
109
109
|
arg: (0, compiler_core_1.createSimpleExpression)(attr.name, true, attr.loc),
|
|
110
110
|
exp,
|
|
@@ -126,7 +126,7 @@ function getImportsExpressionExp(path, hash, loc, context) {
|
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
128
|
name = `_imports_${context.imports.length}`;
|
|
129
|
-
exp = (0, compiler_core_1.createSimpleExpression)(name, false, loc,
|
|
129
|
+
exp = (0, compiler_core_1.createSimpleExpression)(name, false, loc, compiler_core_1.ConstantTypes.CAN_HOIST);
|
|
130
130
|
context.imports.push({ exp, path });
|
|
131
131
|
}
|
|
132
132
|
if (!hash) {
|
|
@@ -135,16 +135,16 @@ function getImportsExpressionExp(path, hash, loc, context) {
|
|
|
135
135
|
const hashExp = `${name} + '${hash}'`;
|
|
136
136
|
const existingHoistIndex = context.hoists.findIndex((h) => {
|
|
137
137
|
return (h &&
|
|
138
|
-
h.type ===
|
|
138
|
+
h.type === compiler_core_1.NodeTypes.SIMPLE_EXPRESSION &&
|
|
139
139
|
!h.isStatic &&
|
|
140
140
|
h.content === hashExp);
|
|
141
141
|
});
|
|
142
142
|
if (existingHoistIndex > -1) {
|
|
143
|
-
return (0, compiler_core_1.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc,
|
|
143
|
+
return (0, compiler_core_1.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc, compiler_core_1.ConstantTypes.CAN_HOIST);
|
|
144
144
|
}
|
|
145
|
-
return context.hoist((0, compiler_core_1.createSimpleExpression)(hashExp, false, loc,
|
|
145
|
+
return context.hoist((0, compiler_core_1.createSimpleExpression)(hashExp, false, loc, compiler_core_1.ConstantTypes.CAN_HOIST));
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
return (0, compiler_core_1.createSimpleExpression)(`''`, false, loc,
|
|
148
|
+
return (0, compiler_core_1.createSimpleExpression)(`''`, false, loc, compiler_core_1.ConstantTypes.CAN_HOIST);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeTransform } from '@vue/compiler-core';
|
|
2
|
-
import { AssetURLOptions } from './templateTransformAssetUrl';
|
|
1
|
+
import { type NodeTransform } from '@vue/compiler-core';
|
|
2
|
+
import { type AssetURLOptions } from './templateTransformAssetUrl';
|
|
3
3
|
export declare const createSrcsetTransformWithOptions: (options: Required<AssetURLOptions>) => NodeTransform;
|
|
4
4
|
export declare const transformSrcset: NodeTransform;
|
|
@@ -16,10 +16,10 @@ const createSrcsetTransformWithOptions = (options) => {
|
|
|
16
16
|
};
|
|
17
17
|
exports.createSrcsetTransformWithOptions = createSrcsetTransformWithOptions;
|
|
18
18
|
const transformSrcset = (node, context, options = templateTransformAssetUrl_1.defaultAssetUrlOptions) => {
|
|
19
|
-
if (node.type ===
|
|
19
|
+
if (node.type === compiler_core_1.NodeTypes.ELEMENT) {
|
|
20
20
|
if (srcsetTags.includes(node.tag) && node.props.length) {
|
|
21
21
|
node.props.forEach((attr, index) => {
|
|
22
|
-
if (attr.name === 'srcset' && attr.type ===
|
|
22
|
+
if (attr.name === 'srcset' && attr.type === compiler_core_1.NodeTypes.ATTRIBUTE) {
|
|
23
23
|
if (!attr.value)
|
|
24
24
|
return;
|
|
25
25
|
const value = attr.value.content;
|
|
@@ -80,17 +80,17 @@ const transformSrcset = (node, context, options = templateTransformAssetUrl_1.de
|
|
|
80
80
|
if (path) {
|
|
81
81
|
const existingImportsIndex = context.imports.findIndex((i) => i.path === path);
|
|
82
82
|
if (existingImportsIndex > -1) {
|
|
83
|
-
exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${existingImportsIndex}`, false, attr.loc,
|
|
83
|
+
exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${existingImportsIndex}`, false, attr.loc, compiler_core_1.ConstantTypes.CAN_HOIST);
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${context.imports.length}`, false, attr.loc,
|
|
86
|
+
exp = (0, compiler_core_1.createSimpleExpression)(`_imports_${context.imports.length}`, false, attr.loc, compiler_core_1.ConstantTypes.CAN_HOIST);
|
|
87
87
|
context.imports.push({ exp, path });
|
|
88
88
|
}
|
|
89
89
|
compoundExpression.children.push(exp);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
const exp = (0, compiler_core_1.createSimpleExpression)(`"${url}"`, false, attr.loc,
|
|
93
|
+
const exp = (0, compiler_core_1.createSimpleExpression)(`"${url}"`, false, attr.loc, compiler_core_1.ConstantTypes.CAN_HOIST);
|
|
94
94
|
compoundExpression.children.push(exp);
|
|
95
95
|
}
|
|
96
96
|
const isNotLast = imageCandidates.length - 1 > index;
|
|
@@ -105,9 +105,9 @@ const transformSrcset = (node, context, options = templateTransformAssetUrl_1.de
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
const hoisted = context.hoist(compoundExpression);
|
|
108
|
-
hoisted.constType =
|
|
108
|
+
hoisted.constType = compiler_core_1.ConstantTypes.CAN_HOIST;
|
|
109
109
|
node.props[index] = {
|
|
110
|
-
type:
|
|
110
|
+
type: compiler_core_1.NodeTypes.DIRECTIVE,
|
|
111
111
|
name: 'bind',
|
|
112
112
|
arg: (0, compiler_core_1.createSimpleExpression)('srcset', true, attr.loc),
|
|
113
113
|
exp: hoisted,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { UrlWithStringQuery } from 'url';
|
|
2
|
+
import { type UrlWithStringQuery } from 'url';
|
|
3
3
|
export declare function isRelativeUrl(url: string): boolean;
|
|
4
4
|
export declare function isExternalUrl(url: string): boolean;
|
|
5
5
|
export declare function isDataUrl(url: string): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NodeTypes, RootNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
|
|
2
|
-
import { COMPONENT_BIND_LINK, COMPONENT_ON_LINK } from '../../mp/constants';
|
|
1
|
+
import { NodeTypes, type RootNode, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
|
|
2
|
+
import type { COMPONENT_BIND_LINK, COMPONENT_ON_LINK } from '../../mp/constants';
|
|
3
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;
|
|
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTransformComponentLink = void 0;
|
|
4
4
|
const compiler_core_1 = require("@vue/compiler-core");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
function createTransformComponentLink(name, type =
|
|
6
|
+
function createTransformComponentLink(name, type = compiler_core_1.NodeTypes.DIRECTIVE) {
|
|
7
7
|
return function transformComponentLink(node, context) {
|
|
8
8
|
if (!(0, utils_1.isUserComponent)(node, context)) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
// 新版本的 vue,识别 template 有差异,可能认为是自定义组件
|
|
12
|
+
if (node.tag === 'template') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (type === compiler_core_1.NodeTypes.DIRECTIVE) {
|
|
12
16
|
node.props.push({
|
|
13
|
-
type:
|
|
17
|
+
type: compiler_core_1.NodeTypes.DIRECTIVE,
|
|
14
18
|
name: 'on',
|
|
15
19
|
modifiers: [],
|
|
16
20
|
loc: compiler_core_1.locStub,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DirectiveNode, ElementNode, NodeTransform } from '@vue/compiler-core';
|
|
1
|
+
import type { DirectiveNode, ElementNode, NodeTransform } from '@vue/compiler-core';
|
|
2
2
|
export declare function createTransformEvent(options: Record<string, string | ((node: ElementNode, dir: DirectiveNode) => string)>): NodeTransform;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeTransform } from '@vue/compiler-core';
|
|
1
|
+
import type { NodeTransform } from '@vue/compiler-core';
|
|
2
2
|
export declare const transformPageHead: NodeTransform;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RootNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
|
|
1
|
+
import { type RootNode, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
|
|
2
2
|
export declare function transformRef(node: RootNode | TemplateChildNode, context: TransformContext): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type RootNode, type TemplateChildNode } from '@vue/compiler-core';
|
|
2
|
+
/**
|
|
3
|
+
* 将scroll-view、list-view内的<view slot="refresher">转为vue支持的用法,此transform需要再较早时机执行,暂时放在transformTag前。此时node.tag还没有加上v-uni-前缀
|
|
4
|
+
* @param node
|
|
5
|
+
* @param context
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformRefresherSlot(node: RootNode | TemplateChildNode): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformRefresherSlot = void 0;
|
|
4
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
5
|
+
const ast_1 = require("../../vite/utils/ast");
|
|
6
|
+
/**
|
|
7
|
+
* 将scroll-view、list-view内的<view slot="refresher">转为vue支持的用法,此transform需要再较早时机执行,暂时放在transformTag前。此时node.tag还没有加上v-uni-前缀
|
|
8
|
+
* @param node
|
|
9
|
+
* @param context
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function transformRefresherSlot(node) {
|
|
13
|
+
if (!(0, ast_1.isElementNode)(node)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (node.tag !== 'scroll-view' && node.tag !== 'list-view') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let refresher = null, refresherIndex = -1;
|
|
20
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
21
|
+
const child = node.children[i];
|
|
22
|
+
if (!(0, ast_1.isElementNode)(child)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (child.props.find((prop) => (0, ast_1.isAttributeNode)(prop) &&
|
|
26
|
+
prop.name === 'slot' &&
|
|
27
|
+
prop.value?.content === 'refresher')) {
|
|
28
|
+
refresher = child;
|
|
29
|
+
refresherIndex = i;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (!refresher) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
node.children.splice(refresherIndex, 1, {
|
|
37
|
+
type: compiler_core_1.NodeTypes.ELEMENT,
|
|
38
|
+
tag: 'template',
|
|
39
|
+
tagType: compiler_core_1.ElementTypes.TEMPLATE,
|
|
40
|
+
props: [
|
|
41
|
+
{
|
|
42
|
+
type: compiler_core_1.NodeTypes.DIRECTIVE,
|
|
43
|
+
name: 'slot',
|
|
44
|
+
loc: compiler_core_1.locStub,
|
|
45
|
+
arg: {
|
|
46
|
+
loc: compiler_core_1.locStub,
|
|
47
|
+
type: compiler_core_1.NodeTypes.SIMPLE_EXPRESSION,
|
|
48
|
+
content: 'refresher',
|
|
49
|
+
isStatic: true,
|
|
50
|
+
constType: compiler_core_1.ConstantTypes.CAN_STRINGIFY,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
children: [refresher],
|
|
55
|
+
loc: compiler_core_1.locStub,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.transformRefresherSlot = transformRefresherSlot;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeTransform } from '@vue/compiler-core';
|
|
1
|
+
import type { NodeTransform } from '@vue/compiler-core';
|
|
2
2
|
export declare function createTransformTag(opts: Record<string, string>): NodeTransform;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformUTSComponent = void 0;
|
|
4
4
|
const ast_1 = require("../../vite/utils/ast");
|
|
5
|
-
const
|
|
5
|
+
const utsUtils_1 = require("../../utsUtils");
|
|
6
6
|
/**
|
|
7
7
|
* 将uts组件保存到自定义组件列表中
|
|
8
8
|
* @param node
|
|
@@ -13,7 +13,7 @@ const transformUTSComponent = (node, context) => {
|
|
|
13
13
|
if (!(0, ast_1.isElementNode)(node)) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
if ((0,
|
|
16
|
+
if ((0, utsUtils_1.matchUTSComponent)(node.tag)) {
|
|
17
17
|
if (!context.root.components.includes(node.tag)) {
|
|
18
18
|
context.components.add(node.tag);
|
|
19
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
|
|
1
|
+
import type { DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
|
|
2
2
|
export declare function defaultMatch(node: ElementNode, context: TransformContext): boolean;
|
|
3
3
|
interface CreateTransformModelOptions {
|
|
4
4
|
match: typeof defaultMatch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type DirectiveTransform, type ElementNode, type ExpressionNode, type TransformContext } from '@vue/compiler-core';
|
|
2
2
|
export declare function defaultMatch(name: string, node: ElementNode, context: TransformContext): boolean;
|
|
3
3
|
interface CreateTransformOnOptions {
|
|
4
4
|
match: typeof defaultMatch;
|
|
@@ -27,7 +27,7 @@ function createTransformOn(baseTransformOn, { match } = {
|
|
|
27
27
|
}
|
|
28
28
|
const value = res.props[0].value;
|
|
29
29
|
res.props[0].value = createCustomEventExpr();
|
|
30
|
-
addEventOpts(node.tagType ===
|
|
30
|
+
addEventOpts(node.tagType === compiler_core_1.ElementTypes.COMPONENT
|
|
31
31
|
? (0, uni_shared_1.customizeEvent)(arg.content)
|
|
32
32
|
: arg.content, value, node, context);
|
|
33
33
|
return res;
|
|
@@ -39,7 +39,7 @@ function createCustomEventExpr() {
|
|
|
39
39
|
}
|
|
40
40
|
exports.createCustomEventExpr = createCustomEventExpr;
|
|
41
41
|
function addEventOpts(event, value, node, context) {
|
|
42
|
-
const attrName = node.tagType ===
|
|
42
|
+
const attrName = node.tagType === compiler_core_1.ElementTypes.COMPONENT
|
|
43
43
|
? ATTR_DATA_EVENT_OPTS
|
|
44
44
|
: exports.ATTR_DATASET_EVENT_OPTS;
|
|
45
45
|
const opts = (0, compiler_core_1.findProp)(node, attrName, true);
|
|
@@ -69,7 +69,7 @@ function createDataEventOptsProp(name, event, exp, context) {
|
|
|
69
69
|
children.push(')');
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
type:
|
|
72
|
+
type: compiler_core_1.NodeTypes.DIRECTIVE,
|
|
73
73
|
name: 'bind',
|
|
74
74
|
loc: compiler_core_1.locStub,
|
|
75
75
|
modifiers: [],
|
|
@@ -78,7 +78,7 @@ function createDataEventOptsProp(name, event, exp, context) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
const builtInEvents = [
|
|
81
|
-
'__l',
|
|
81
|
+
'__l', // 快手使用了该事件
|
|
82
82
|
'tap',
|
|
83
83
|
'longtap',
|
|
84
84
|
'longpress',
|
package/dist/vue/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttributeNode, ComponentNode, DirectiveNode, ElementNode, RootNode,
|
|
1
|
+
import { type AttributeNode, type ComponentNode, type DirectiveNode, type ElementNode, type ExpressionNode, type Position, type RootNode, type SourceLocation, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
|
|
2
2
|
export declare const VUE_REF = "r";
|
|
3
3
|
export declare const VUE_REF_IN_FOR = "r-i-f";
|
|
4
4
|
export declare function isVueSfcFile(id: string): boolean;
|
|
@@ -29,3 +29,6 @@ export declare function createUniVueTransformAssetUrls(base: string): {
|
|
|
29
29
|
};
|
|
30
30
|
export declare function getBaseNodeTransforms(base: string): import("@vue/compiler-core").NodeTransform[];
|
|
31
31
|
export declare function renameProp(name: string, prop?: DirectiveNode | AttributeNode): void;
|
|
32
|
+
export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
|
|
33
|
+
export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
34
|
+
export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
|