@dcloudio/uni-cli-shared 3.0.0-alpha-3021320211109002 → 3.0.0-alpha-3021320211115001
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/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/easycom.d.ts +7 -1
- package/dist/easycom.js +25 -6
- package/dist/env/define.d.ts +3 -0
- package/dist/env/define.js +6 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.js +8 -0
- package/dist/filter.d.ts +16 -0
- package/dist/filter.js +60 -0
- package/dist/hbx/alias.js +9 -1
- package/dist/hbx/env.js +4 -1
- package/dist/hbx/index.js +0 -7
- package/dist/hbx/log.d.ts +2 -0
- package/dist/hbx/log.js +36 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/json/app/manifest/confusion.d.ts +3 -0
- package/dist/json/app/manifest/confusion.js +56 -14
- package/dist/json/app/manifest/env.d.ts +1 -1
- package/dist/json/app/manifest/index.d.ts +1 -0
- package/dist/json/app/manifest/index.js +5 -1
- package/dist/json/app/manifest/nvue.d.ts +3 -3
- package/dist/json/app/pages/index.d.ts +0 -1
- package/dist/json/app/pages/index.js +0 -11
- package/dist/json/manifest.d.ts +1 -1
- package/dist/json/manifest.js +9 -3
- package/dist/json/mp/index.d.ts +1 -0
- package/dist/json/mp/index.js +11 -0
- package/dist/json/mp/jsonFile.d.ts +8 -6
- package/dist/json/mp/jsonFile.js +68 -16
- package/dist/json/mp/pages.d.ts +1 -0
- package/dist/json/mp/pages.js +17 -3
- package/dist/json/mp/types.d.ts +1 -0
- package/dist/json/pages.js +0 -4
- package/dist/logs/console.js +5 -2
- package/dist/logs/format.js +6 -0
- package/dist/messages/index.d.ts +3 -0
- package/dist/messages/index.js +3 -0
- package/dist/mp/constants.d.ts +2 -0
- package/dist/mp/constants.js +5 -0
- package/dist/mp/event.d.ts +2 -1
- package/dist/mp/event.js +18 -3
- package/dist/mp/imports.d.ts +5 -0
- package/dist/mp/imports.js +63 -0
- package/dist/mp/index.d.ts +5 -0
- package/dist/mp/index.js +7 -0
- package/dist/mp/nvue.d.ts +1 -0
- package/dist/mp/nvue.js +18 -0
- package/dist/mp/style.d.ts +1 -0
- package/dist/mp/style.js +9 -0
- package/dist/mp/template.d.ts +55 -0
- package/dist/mp/template.js +73 -0
- package/dist/mp/transformImports.d.ts +14 -0
- package/dist/mp/transformImports.js +175 -0
- package/dist/postcss/plugins/stylePluginScoped.d.ts +1 -1
- package/dist/postcss/plugins/uniapp.d.ts +1 -1
- package/dist/postcss/plugins/uniapp.js +51 -21
- package/dist/preprocess/context.js +1 -0
- package/dist/utils.d.ts +9 -1
- package/dist/utils.js +93 -8
- package/dist/vite/features.d.ts +1 -1
- package/dist/vite/index.d.ts +2 -3
- package/dist/vite/plugins/copy.d.ts +1 -1
- package/dist/vite/plugins/cssScoped.d.ts +1 -1
- package/dist/vite/plugins/inject.d.ts +1 -1
- package/dist/vite/plugins/inject.js +2 -2
- package/dist/vite/plugins/vitejs/config.d.ts +1 -1
- package/dist/vite/plugins/vitejs/index.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugin.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/asset.js +28 -21
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -4
- package/dist/vite/plugins/vitejs/plugins/css.js +15 -24
- package/dist/vite/plugins/vitejs/server/moduleGraph.d.ts +1 -1
- package/dist/vite/plugins/vitejs/server/moduleGraph.js +0 -3
- package/dist/vite/utils/ast.d.ts +1 -1
- package/dist/vite/utils/index.d.ts +1 -1
- package/dist/vite/utils/plugin.d.ts +4 -4
- package/dist/vite/utils/plugin.js +2 -2
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +14 -0
- package/dist/vue/transforms/index.d.ts +10 -0
- package/dist/vue/transforms/index.js +36 -0
- package/dist/vue/transforms/transformComponent.d.ts +3 -0
- package/dist/vue/transforms/transformComponent.js +26 -0
- package/dist/vue/transforms/transformEvent.d.ts +2 -0
- package/dist/vue/transforms/transformEvent.js +22 -0
- package/dist/vue/transforms/transformPageHead.d.ts +2 -0
- package/dist/vue/transforms/transformPageHead.js +11 -0
- package/dist/vue/transforms/transformRef.d.ts +2 -0
- package/dist/vue/transforms/transformRef.js +32 -0
- package/dist/vue/transforms/transformTag.d.ts +2 -0
- package/dist/vue/transforms/transformTag.js +18 -0
- package/dist/vue/transforms/vModel.d.ts +12 -0
- package/dist/vue/transforms/vModel.js +33 -0
- package/dist/vue/transforms/vOn.d.ts +15 -0
- package/dist/vue/transforms/vOn.js +88 -0
- package/dist/vue/utils.d.ts +9 -0
- package/dist/vue/utils.js +66 -0
- package/lib/nvue.css +34 -0
- package/package.json +27 -6
- package/LICENSE +0 -202
- package/dist/json/app/pages/nvue.d.ts +0 -1
- package/dist/json/app/pages/nvue.js +0 -88
- package/dist/renderjs.d.ts +0 -16
- package/dist/renderjs.js +0 -44
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { RollupError } from 'rollup';
|
|
1
2
|
import { Plugin } from '../plugin';
|
|
2
3
|
import { ResolvedConfig } from '../config';
|
|
3
|
-
import { RollupError } from 'rollup';
|
|
4
4
|
import * as Postcss from 'postcss';
|
|
5
5
|
export interface CSSOptions {
|
|
6
6
|
/**
|
|
@@ -33,9 +33,9 @@ export declare function cssPlugin(config: ResolvedConfig): Plugin;
|
|
|
33
33
|
/**
|
|
34
34
|
* Plugin applied after user plugins
|
|
35
35
|
*/
|
|
36
|
-
export declare function cssPostPlugin(config: ResolvedConfig, {
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
37
|
+
chunkCssFilename: (id: string) => string | void;
|
|
38
|
+
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
39
39
|
}): Plugin;
|
|
40
40
|
export declare const cssUrlRE: RegExp;
|
|
41
41
|
export interface StylePreprocessorResults {
|
|
@@ -26,13 +26,11 @@ exports.cssUrlRE = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectC
|
|
|
26
26
|
const fs_1 = __importDefault(require("fs"));
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
28
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
29
|
-
const utils_1 = require("../utils");
|
|
30
|
-
const postcss_load_config_1 = __importDefault(require("postcss-load-config"));
|
|
31
29
|
const chalk_1 = __importDefault(require("chalk"));
|
|
30
|
+
const postcss_load_config_1 = __importDefault(require("postcss-load-config"));
|
|
31
|
+
const utils_1 = require("../utils");
|
|
32
32
|
const asset_1 = require("./asset");
|
|
33
33
|
const esbuild_1 = require("esbuild");
|
|
34
|
-
const utils_2 = require("../../../../utils");
|
|
35
|
-
const constants_1 = require("../../../../constants");
|
|
36
34
|
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
37
35
|
exports.cssLangRE = new RegExp(cssLangs);
|
|
38
36
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
@@ -77,7 +75,7 @@ function cssPlugin(config) {
|
|
|
77
75
|
}
|
|
78
76
|
const resolved = await resolveUrl(url, importer);
|
|
79
77
|
if (resolved) {
|
|
80
|
-
return (0, asset_1.fileToUrl)(resolved, config, this);
|
|
78
|
+
return (0, asset_1.fileToUrl)(resolved, config, this, true);
|
|
81
79
|
}
|
|
82
80
|
return url;
|
|
83
81
|
};
|
|
@@ -100,12 +98,6 @@ function cssPlugin(config) {
|
|
|
100
98
|
};
|
|
101
99
|
}
|
|
102
100
|
exports.cssPlugin = cssPlugin;
|
|
103
|
-
function normalizeCssChunkFilename(id, extname = '.css') {
|
|
104
|
-
return (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, id
|
|
105
|
-
.split('?')[0]
|
|
106
|
-
.replace(constants_1.EXTNAME_VUE_RE, extname)
|
|
107
|
-
.replace(constants_1.EXTNAME_JS_RE, extname)));
|
|
108
|
-
}
|
|
109
101
|
function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
110
102
|
if (!cssModuleIds) {
|
|
111
103
|
cssModuleIds = new Set();
|
|
@@ -137,7 +129,7 @@ function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
|
137
129
|
/**
|
|
138
130
|
* Plugin applied after user plugins
|
|
139
131
|
*/
|
|
140
|
-
function cssPostPlugin(config, {
|
|
132
|
+
function cssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
141
133
|
// styles initialization in buildStart causes a styling loss in watch
|
|
142
134
|
const styles = new Map();
|
|
143
135
|
let cssChunks;
|
|
@@ -146,7 +138,7 @@ function cssPostPlugin(config, { appCss, extname }) {
|
|
|
146
138
|
buildStart() {
|
|
147
139
|
cssChunks = new Map();
|
|
148
140
|
},
|
|
149
|
-
async transform(css, id
|
|
141
|
+
async transform(css, id) {
|
|
150
142
|
if (!exports.cssLangRE.test(id) || commonjsProxyRE.test(id)) {
|
|
151
143
|
return;
|
|
152
144
|
}
|
|
@@ -162,15 +154,10 @@ function cssPostPlugin(config, { appCss, extname }) {
|
|
|
162
154
|
},
|
|
163
155
|
async generateBundle() {
|
|
164
156
|
const moduleIds = Array.from(this.getModuleIds());
|
|
165
|
-
const mainPath = (0, utils_2.resolveMainPathOnce)(process.env.UNI_INPUT_DIR);
|
|
166
157
|
moduleIds.forEach((id) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
cssChunks.set(
|
|
170
|
-
}
|
|
171
|
-
else if (id.includes('mpType=page')) {
|
|
172
|
-
// 页面样式
|
|
173
|
-
cssChunks.set(normalizeCssChunkFilename(id, extname), findCssModuleIds.call(this, id));
|
|
158
|
+
const filename = chunkCssFilename(id);
|
|
159
|
+
if (filename) {
|
|
160
|
+
cssChunks.set(filename, findCssModuleIds.call(this, id));
|
|
174
161
|
}
|
|
175
162
|
});
|
|
176
163
|
if (!cssChunks.size) {
|
|
@@ -194,8 +181,12 @@ function cssPostPlugin(config, { appCss, extname }) {
|
|
|
194
181
|
.join('\n');
|
|
195
182
|
};
|
|
196
183
|
for (const filename of cssChunks.keys()) {
|
|
197
|
-
|
|
198
|
-
|
|
184
|
+
const cssCode = genCssCode(filename);
|
|
185
|
+
let source = await processChunkCSS(chunkCssCode(filename, cssCode), {
|
|
186
|
+
dirname: path_1.default.dirname(filename),
|
|
187
|
+
inlined: false,
|
|
188
|
+
minify: true,
|
|
189
|
+
});
|
|
199
190
|
this.emitFile({
|
|
200
191
|
fileName: filename,
|
|
201
192
|
type: 'asset',
|
|
@@ -554,7 +545,7 @@ const scss = async (source, root, options, resolvers) => {
|
|
|
554
545
|
rebaseUrls(resolved, options.filename, options.alias).then(done);
|
|
555
546
|
}
|
|
556
547
|
else {
|
|
557
|
-
done(null);
|
|
548
|
+
done && done(null);
|
|
558
549
|
}
|
|
559
550
|
});
|
|
560
551
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ModuleNode } from 'vite';
|
|
1
|
+
export type { ModuleNode } from 'vite';
|
package/dist/vite/utils/ast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Literal, BaseNode, Property, Identifier, CallExpression, MemberExpression, MethodDefinition, ExportSpecifier } from 'estree';
|
|
1
|
+
import type { Literal, BaseNode, Property, Identifier, CallExpression, MemberExpression, MethodDefinition, ExportSpecifier } from 'estree';
|
|
2
2
|
import { Node, ElementNode, DirectiveNode, 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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, ResolvedConfig } from 'vite';
|
|
1
|
+
import type { Plugin, ResolvedConfig } from 'vite';
|
|
2
2
|
export declare type CreateUniViteFilterPlugin = (opts: UniViteFilterPluginOptions) => Plugin;
|
|
3
3
|
export interface UniViteFilterPluginOptions {
|
|
4
4
|
resolvedConfig: ResolvedConfig;
|
|
@@ -6,9 +6,9 @@ export interface UniViteFilterPluginOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function injectAssetPlugin(config: ResolvedConfig): void;
|
|
8
8
|
export declare function injectCssPlugin(config: ResolvedConfig): void;
|
|
9
|
-
export declare function injectCssPostPlugin(config: ResolvedConfig, {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare function injectCssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
10
|
+
chunkCssFilename: (id: string) => string | void;
|
|
11
|
+
chunkCssCode: (filename: string, cssCode: string) => string;
|
|
12
12
|
}): void;
|
|
13
13
|
export declare function replacePlugins(plugins: Plugin[], config: ResolvedConfig): void;
|
|
14
14
|
export declare function removePlugins(plugins: string | string[], config: ResolvedConfig): void;
|
|
@@ -11,8 +11,8 @@ function injectCssPlugin(config) {
|
|
|
11
11
|
replacePlugins([(0, css_1.cssPlugin)(config)], config);
|
|
12
12
|
}
|
|
13
13
|
exports.injectCssPlugin = injectCssPlugin;
|
|
14
|
-
function injectCssPostPlugin(config, {
|
|
15
|
-
replacePlugins([(0, css_1.cssPostPlugin)(config, {
|
|
14
|
+
function injectCssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
15
|
+
replacePlugins([(0, css_1.cssPostPlugin)(config, { chunkCssFilename, chunkCssCode })], config);
|
|
16
16
|
}
|
|
17
17
|
exports.injectCssPostPlugin = injectCssPostPlugin;
|
|
18
18
|
function replacePlugins(plugins, config) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./transforms"), exports);
|
|
14
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './transformRef';
|
|
2
|
+
export * from './transformPageHead';
|
|
3
|
+
export * from './transformComponent';
|
|
4
|
+
export * from './transformEvent';
|
|
5
|
+
export * from './transformTag';
|
|
6
|
+
export { ATTR_DATASET_EVENT_OPTS, createTransformOn, defaultMatch as matchTransformOn, } from './vOn';
|
|
7
|
+
export { createTransformModel, defaultMatch as matchTransformModel, } from './vModel';
|
|
8
|
+
export declare const transformMatchMedia: import("@vue/compiler-core").NodeTransform;
|
|
9
|
+
export declare const transformTapToClick: import("@vue/compiler-core").NodeTransform;
|
|
10
|
+
export declare const transformComponentLink: (node: import("@vue/compiler-core").RootNode | import("@vue/compiler-core").TemplateChildNode, context: import("@vue/compiler-core").TransformContext) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.transformComponentLink = exports.transformTapToClick = exports.transformMatchMedia = exports.matchTransformModel = exports.createTransformModel = exports.matchTransformOn = exports.createTransformOn = exports.ATTR_DATASET_EVENT_OPTS = void 0;
|
|
14
|
+
const transformTag_1 = require("./transformTag");
|
|
15
|
+
const transformEvent_1 = require("./transformEvent");
|
|
16
|
+
const transformComponent_1 = require("./transformComponent");
|
|
17
|
+
const constants_1 = require("../../mp/constants");
|
|
18
|
+
__exportStar(require("./transformRef"), exports);
|
|
19
|
+
__exportStar(require("./transformPageHead"), exports);
|
|
20
|
+
__exportStar(require("./transformComponent"), exports);
|
|
21
|
+
__exportStar(require("./transformEvent"), exports);
|
|
22
|
+
__exportStar(require("./transformTag"), exports);
|
|
23
|
+
var vOn_1 = require("./vOn");
|
|
24
|
+
Object.defineProperty(exports, "ATTR_DATASET_EVENT_OPTS", { enumerable: true, get: function () { return vOn_1.ATTR_DATASET_EVENT_OPTS; } });
|
|
25
|
+
Object.defineProperty(exports, "createTransformOn", { enumerable: true, get: function () { return vOn_1.createTransformOn; } });
|
|
26
|
+
Object.defineProperty(exports, "matchTransformOn", { enumerable: true, get: function () { return vOn_1.defaultMatch; } });
|
|
27
|
+
var vModel_1 = require("./vModel");
|
|
28
|
+
Object.defineProperty(exports, "createTransformModel", { enumerable: true, get: function () { return vModel_1.createTransformModel; } });
|
|
29
|
+
Object.defineProperty(exports, "matchTransformModel", { enumerable: true, get: function () { return vModel_1.defaultMatch; } });
|
|
30
|
+
exports.transformMatchMedia = (0, transformTag_1.createTransformTag)({
|
|
31
|
+
'match-media': 'uni-match-media',
|
|
32
|
+
});
|
|
33
|
+
exports.transformTapToClick = (0, transformEvent_1.createTransformEvent)({
|
|
34
|
+
tap: 'click',
|
|
35
|
+
});
|
|
36
|
+
exports.transformComponentLink = (0, transformComponent_1.createTransformComponentLink)(constants_1.COMPONENT_BIND_LINK);
|
|
@@ -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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransformEvent = void 0;
|
|
4
|
+
const ast_1 = require("../../vite/utils/ast");
|
|
5
|
+
function createTransformEvent(options) {
|
|
6
|
+
return function transformEvent(node) {
|
|
7
|
+
if (!(0, ast_1.isElementNode)(node)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
node.props.forEach((prop) => {
|
|
11
|
+
const { name, arg } = prop;
|
|
12
|
+
if (name === 'on' && arg && (0, ast_1.isSimpleExpressionNode)(arg)) {
|
|
13
|
+
const eventType = options[arg.content];
|
|
14
|
+
if (eventType) {
|
|
15
|
+
// e.g tap => click
|
|
16
|
+
arg.content = eventType;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.createTransformEvent = createTransformEvent;
|
|
@@ -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,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 = 'data-' + utils_1.VUE_REF;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
;
|
|
24
|
+
refProp.arg.content = 'data-' + 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,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,9 @@
|
|
|
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 isUserComponent(node: RootNode | TemplateChildNode, context: TransformContext): node is ComponentNode;
|
|
5
|
+
export declare function createAttributeNode(name: string, content: string): AttributeNode;
|
|
6
|
+
export declare function addStaticClass(node: ElementNode, clazz: string): string | number | undefined;
|
|
7
|
+
export declare function createDirectiveNode(name: string, arg: string, exp: string | ExpressionNode): DirectiveNode;
|
|
8
|
+
export declare function createOnDirectiveNode(name: string, value: string): DirectiveNode;
|
|
9
|
+
export declare function createBindDirectiveNode(name: string, value: string | ExpressionNode): DirectiveNode;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
6
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
7
|
+
exports.VUE_REF = 'r';
|
|
8
|
+
exports.VUE_REF_IN_FOR = 'r-i-f';
|
|
9
|
+
function isUserComponent(node, context) {
|
|
10
|
+
return (node.type === 1 /* ELEMENT */ &&
|
|
11
|
+
node.tagType === 1 /* COMPONENT */ &&
|
|
12
|
+
!(0, uni_shared_1.isComponentTag)(node.tag) &&
|
|
13
|
+
!(0, compiler_core_1.isCoreComponent)(node.tag) &&
|
|
14
|
+
!context.isBuiltInComponent(node.tag));
|
|
15
|
+
}
|
|
16
|
+
exports.isUserComponent = isUserComponent;
|
|
17
|
+
function createAttributeNode(name, content) {
|
|
18
|
+
return {
|
|
19
|
+
type: 6 /* ATTRIBUTE */,
|
|
20
|
+
loc: compiler_core_1.locStub,
|
|
21
|
+
name,
|
|
22
|
+
value: {
|
|
23
|
+
type: 2 /* TEXT */,
|
|
24
|
+
loc: compiler_core_1.locStub,
|
|
25
|
+
content,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.createAttributeNode = createAttributeNode;
|
|
30
|
+
function createClassAttribute(clazz) {
|
|
31
|
+
return createAttributeNode('class', clazz);
|
|
32
|
+
}
|
|
33
|
+
function addStaticClass(node, clazz) {
|
|
34
|
+
const classProp = node.props.find((prop) => prop.type === 6 /* ATTRIBUTE */ && prop.name === 'class');
|
|
35
|
+
if (!classProp) {
|
|
36
|
+
return node.props.unshift(createClassAttribute(clazz));
|
|
37
|
+
}
|
|
38
|
+
if (classProp.value) {
|
|
39
|
+
return (classProp.value.content = classProp.value.content + ' ' + clazz);
|
|
40
|
+
}
|
|
41
|
+
classProp.value = {
|
|
42
|
+
type: 2 /* TEXT */,
|
|
43
|
+
loc: compiler_core_1.locStub,
|
|
44
|
+
content: clazz,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.addStaticClass = addStaticClass;
|
|
48
|
+
function createDirectiveNode(name, arg, exp) {
|
|
49
|
+
return {
|
|
50
|
+
type: 7 /* DIRECTIVE */,
|
|
51
|
+
name,
|
|
52
|
+
modifiers: [],
|
|
53
|
+
loc: compiler_core_1.locStub,
|
|
54
|
+
arg: (0, compiler_core_1.createSimpleExpression)(arg, true),
|
|
55
|
+
exp: (0, shared_1.isString)(exp) ? (0, compiler_core_1.createSimpleExpression)(exp, false) : exp,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.createDirectiveNode = createDirectiveNode;
|
|
59
|
+
function createOnDirectiveNode(name, value) {
|
|
60
|
+
return createDirectiveNode('on', name, value);
|
|
61
|
+
}
|
|
62
|
+
exports.createOnDirectiveNode = createOnDirectiveNode;
|
|
63
|
+
function createBindDirectiveNode(name, value) {
|
|
64
|
+
return createDirectiveNode('bind', name, value);
|
|
65
|
+
}
|
|
66
|
+
exports.createBindDirectiveNode = createBindDirectiveNode;
|
package/lib/nvue.css
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
label,
|
|
2
|
+
scroll-view,
|
|
3
|
+
swiper-item,
|
|
4
|
+
view {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
flex-grow: 0;
|
|
9
|
+
flex-basis: auto;
|
|
10
|
+
align-items: stretch;
|
|
11
|
+
align-content: flex-start;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
image,
|
|
15
|
+
input,
|
|
16
|
+
scroll-view,
|
|
17
|
+
swiper,
|
|
18
|
+
swiper-item,
|
|
19
|
+
text,
|
|
20
|
+
textarea,
|
|
21
|
+
video,
|
|
22
|
+
view {
|
|
23
|
+
position: relative;
|
|
24
|
+
border: 0 solid #000;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
swiper-item {
|
|
29
|
+
position: absolute;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
button {
|
|
33
|
+
margin: 0;
|
|
34
|
+
}
|