@dcloudio/uni-cli-shared 3.0.0-alpha-3030220211217005 → 3.0.0-alpha-3030220211217009
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/env/define.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/preprocess/context.d.ts +1 -1
- package/dist/preprocess/context.js +11 -3
- package/dist/scripts.d.ts +10 -0
- package/dist/scripts.js +30 -0
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +25 -1
- package/dist/vite/plugins/vitejs/plugins/asset.js +65 -2
- package/dist/vue/utils.d.ts +1 -1
- package/lib/preprocess/lib/preprocess.js +7 -3
- package/package.json +5 -5
package/dist/env/define.js
CHANGED
|
@@ -8,6 +8,7 @@ function initDefine(stringifyBoolean = false) {
|
|
|
8
8
|
const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
|
|
9
9
|
const isDebug = !!manifestJson.debug;
|
|
10
10
|
return {
|
|
11
|
+
...initCustomDefine(),
|
|
11
12
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
12
13
|
'process.env.UNI_DEBUG': stringifyBoolean
|
|
13
14
|
? JSON.stringify(isDebug)
|
|
@@ -29,3 +30,16 @@ function initDefine(stringifyBoolean = false) {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
exports.initDefine = initDefine;
|
|
33
|
+
function initCustomDefine() {
|
|
34
|
+
let define = {};
|
|
35
|
+
if (process.env.UNI_CUSTOM_DEFINE) {
|
|
36
|
+
try {
|
|
37
|
+
define = JSON.parse(process.env.UNI_CUSTOM_DEFINE);
|
|
38
|
+
}
|
|
39
|
+
catch (e) { }
|
|
40
|
+
}
|
|
41
|
+
return Object.keys(define).reduce((res, name) => {
|
|
42
|
+
res['process.env.' + name] = JSON.stringify(define[name]);
|
|
43
|
+
return res;
|
|
44
|
+
}, {});
|
|
45
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./postcss"), exports);
|
|
|
31
31
|
__exportStar(require("./filter"), exports);
|
|
32
32
|
__exportStar(require("./esbuild"), exports);
|
|
33
33
|
__exportStar(require("./resolve"), exports);
|
|
34
|
+
__exportStar(require("./scripts"), exports);
|
|
34
35
|
var messages_1 = require("./messages");
|
|
35
36
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
36
37
|
__exportStar(require("./exports"), exports);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function getPreVueContext(): any;
|
|
2
2
|
export declare function getPreNVueContext(): any;
|
|
3
|
-
export declare function initPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean>): void;
|
|
3
|
+
export declare function initPreContext(platform: UniApp.PLATFORM, userPreContext?: Record<string, boolean> | string): void;
|
|
@@ -60,9 +60,17 @@ function initPreContext(platform, userPreContext) {
|
|
|
60
60
|
defaultContext.QUICKAPP_WEBVIEW = true;
|
|
61
61
|
}
|
|
62
62
|
if (userPreContext) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
if ((0, shared_1.isString)(userPreContext)) {
|
|
64
|
+
try {
|
|
65
|
+
userPreContext = JSON.parse(userPreContext);
|
|
66
|
+
}
|
|
67
|
+
catch (e) { }
|
|
68
|
+
}
|
|
69
|
+
if ((0, shared_1.isPlainObject)(userPreContext)) {
|
|
70
|
+
Object.keys(userPreContext).forEach((key) => {
|
|
71
|
+
defaultContext[normalizeKey(key)] = !!userPreContext[key];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
(0, shared_1.extend)(preVueContext, defaultContext, vueContext);
|
|
68
76
|
(0, shared_1.extend)(preNVueContext, defaultContext, nvueContext);
|
package/dist/scripts.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseScripts = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
function parseScripts(name, pkgPath) {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
if (!fs_1.default.existsSync(pkgPath)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
|
|
14
|
+
const options = (_b = (_a = pkg['uni-app']) === null || _a === void 0 ? void 0 : _a.scripts) === null || _b === void 0 ? void 0 : _b[name];
|
|
15
|
+
if (!options) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!((_c = options.env) === null || _c === void 0 ? void 0 : _c.UNI_PLATFORM)) {
|
|
19
|
+
console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
const { UNI_PLATFORM, ...define } = options.env;
|
|
23
|
+
return {
|
|
24
|
+
name: name,
|
|
25
|
+
platform: UNI_PLATFORM,
|
|
26
|
+
define,
|
|
27
|
+
context: options.define || {},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.parseScripts = parseScripts;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Plugin } from '../plugin';
|
|
3
3
|
import { ResolvedConfig } from '../config';
|
|
4
|
-
import { PluginContext, RenderedChunk } from 'rollup';
|
|
4
|
+
import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
|
|
5
5
|
export declare const assetUrlRE: RegExp;
|
|
6
6
|
export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
|
|
7
7
|
/**
|
|
@@ -12,5 +12,29 @@ export declare function registerAssetToChunk(chunk: RenderedChunk, file: string)
|
|
|
12
12
|
export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
|
|
13
13
|
export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext, canInline?: boolean): string;
|
|
14
14
|
export declare function getAssetFilename(hash: string, config: ResolvedConfig): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* converts the source filepath of the asset to the output filename based on the assetFileNames option. \
|
|
17
|
+
* this function imitates the behavior of rollup.js. \
|
|
18
|
+
* https://rollupjs.org/guide/en/#outputassetfilenames
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const content = Buffer.from('text');
|
|
23
|
+
* const fileName = assetFileNamesToFileName(
|
|
24
|
+
* 'assets/[name].[hash][extname]',
|
|
25
|
+
* '/path/to/file.txt',
|
|
26
|
+
* getAssetHash(content),
|
|
27
|
+
* content
|
|
28
|
+
* )
|
|
29
|
+
* // fileName: 'assets/file.982d9e3e.txt'
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
|
|
33
|
+
* @param file filepath of the asset
|
|
34
|
+
* @param contentHash hash of the asset. used for `'[hash]'` placeholder
|
|
35
|
+
* @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
|
|
36
|
+
* @returns output filename
|
|
37
|
+
*/
|
|
38
|
+
export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;
|
|
15
39
|
export declare function getAssetHash(content: Buffer): string;
|
|
16
40
|
export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): string;
|
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.urlToBuiltUrl = exports.getAssetHash = exports.getAssetFilename = exports.fileToUrl = exports.checkPublicFile = exports.registerAssetToChunk = exports.assetPlugin = exports.chunkToEmittedAssetsMap = exports.assetUrlRE = void 0;
|
|
25
|
+
exports.urlToBuiltUrl = exports.getAssetHash = exports.assetFileNamesToFileName = exports.getAssetFilename = exports.fileToUrl = exports.checkPublicFile = exports.registerAssetToChunk = exports.assetPlugin = exports.chunkToEmittedAssetsMap = exports.assetUrlRE = void 0;
|
|
26
26
|
const path_1 = __importDefault(require("path"));
|
|
27
27
|
const url_1 = require("url");
|
|
28
28
|
const lite_1 = __importDefault(require("mime/lite"));
|
|
@@ -142,6 +142,66 @@ function getAssetFilename(hash, config) {
|
|
|
142
142
|
return (_a = assetHashToFilenameMap.get(config)) === null || _a === void 0 ? void 0 : _a.get(hash);
|
|
143
143
|
}
|
|
144
144
|
exports.getAssetFilename = getAssetFilename;
|
|
145
|
+
/**
|
|
146
|
+
* converts the source filepath of the asset to the output filename based on the assetFileNames option. \
|
|
147
|
+
* this function imitates the behavior of rollup.js. \
|
|
148
|
+
* https://rollupjs.org/guide/en/#outputassetfilenames
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const content = Buffer.from('text');
|
|
153
|
+
* const fileName = assetFileNamesToFileName(
|
|
154
|
+
* 'assets/[name].[hash][extname]',
|
|
155
|
+
* '/path/to/file.txt',
|
|
156
|
+
* getAssetHash(content),
|
|
157
|
+
* content
|
|
158
|
+
* )
|
|
159
|
+
* // fileName: 'assets/file.982d9e3e.txt'
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
|
|
163
|
+
* @param file filepath of the asset
|
|
164
|
+
* @param contentHash hash of the asset. used for `'[hash]'` placeholder
|
|
165
|
+
* @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
|
|
166
|
+
* @returns output filename
|
|
167
|
+
*/
|
|
168
|
+
function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
|
|
169
|
+
const basename = path_1.default.basename(file);
|
|
170
|
+
// placeholders for `assetFileNames`
|
|
171
|
+
// `hash` is slightly different from the rollup's one
|
|
172
|
+
const extname = path_1.default.extname(basename);
|
|
173
|
+
const ext = extname.substring(1);
|
|
174
|
+
const name = basename.slice(0, -extname.length);
|
|
175
|
+
const hash = contentHash;
|
|
176
|
+
if (typeof assetFileNames === 'function') {
|
|
177
|
+
assetFileNames = assetFileNames({
|
|
178
|
+
name: file,
|
|
179
|
+
source: content,
|
|
180
|
+
type: 'asset',
|
|
181
|
+
});
|
|
182
|
+
if (typeof assetFileNames !== 'string') {
|
|
183
|
+
throw new TypeError('assetFileNames must return a string');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else if (typeof assetFileNames !== 'string') {
|
|
187
|
+
throw new TypeError('assetFileNames must be a string or a function');
|
|
188
|
+
}
|
|
189
|
+
const fileName = assetFileNames.replace(/\[\w+\]/g, (placeholder) => {
|
|
190
|
+
switch (placeholder) {
|
|
191
|
+
case '[ext]':
|
|
192
|
+
return ext;
|
|
193
|
+
case '[extname]':
|
|
194
|
+
return extname;
|
|
195
|
+
case '[hash]':
|
|
196
|
+
return hash;
|
|
197
|
+
case '[name]':
|
|
198
|
+
return name;
|
|
199
|
+
}
|
|
200
|
+
throw new Error(`invalid placeholder ${placeholder} in assetFileNames "${assetFileNames}"`);
|
|
201
|
+
});
|
|
202
|
+
return fileName;
|
|
203
|
+
}
|
|
204
|
+
exports.assetFileNamesToFileName = assetFileNamesToFileName;
|
|
145
205
|
/**
|
|
146
206
|
* Register an asset to be emitted as part of the bundle (if necessary)
|
|
147
207
|
* and returns the resolved public URL
|
|
@@ -167,7 +227,10 @@ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canI
|
|
|
167
227
|
const contentHash = getAssetHash(content);
|
|
168
228
|
const { search, hash } = (0, url_1.parse)(id);
|
|
169
229
|
const postfix = (search || '') + (hash || '');
|
|
170
|
-
const
|
|
230
|
+
const inputDir = (0, utils_1.normalizePath)(process.env.UNI_INPUT_DIR);
|
|
231
|
+
let fileName = file.startsWith(inputDir)
|
|
232
|
+
? path_1.default.posix.relative(inputDir, file)
|
|
233
|
+
: assetFileNamesToFileName(path_1.default.posix.join(config.build.assetsDir, '[name].[hash][extname]'), file, contentHash, content);
|
|
171
234
|
if (!map.has(contentHash)) {
|
|
172
235
|
map.set(contentHash, fileName);
|
|
173
236
|
}
|
package/dist/vue/utils.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function isUserComponent(node: RootNode | TemplateChildNode, cont
|
|
|
7
7
|
}): node is ComponentNode;
|
|
8
8
|
export declare function createAttributeNode(name: string, content: string): AttributeNode;
|
|
9
9
|
export declare function addStaticClass(node: ElementNode, clazz: string): string | number | undefined;
|
|
10
|
-
export declare function createDirectiveNode(name: string, arg: string, exp
|
|
10
|
+
export declare function createDirectiveNode(name: string, arg: string, exp?: string | ExpressionNode): DirectiveNode;
|
|
11
11
|
export declare function createOnDirectiveNode(name: string, value: string): DirectiveNode;
|
|
12
12
|
export declare function createBindDirectiveNode(name: string, value: string | ExpressionNode): DirectiveNode;
|
|
13
13
|
export declare function createUniVueTransformAssetUrls(base: string): {
|
|
@@ -381,9 +381,13 @@ function getTestTemplate(test) {
|
|
|
381
381
|
return new Function("context", "with (context||{}){ return ( " + test + " ); }");
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
384
|
+
// fixed by xxxxxx
|
|
385
|
+
function testPasses(test, context) {
|
|
386
|
+
var testFn = getTestTemplate(test)
|
|
387
|
+
try {
|
|
388
|
+
return testFn(context, getDeepPropFromObj)
|
|
389
|
+
} catch (e) {}
|
|
390
|
+
return false
|
|
387
391
|
}
|
|
388
392
|
|
|
389
393
|
function getFileContents(path, failSilent, requesterPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3030220211217009",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/parser": "^7.16.4",
|
|
22
22
|
"@babel/types": "^7.16.0",
|
|
23
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
24
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
25
|
-
"@rollup/pluginutils": "^4.1.
|
|
23
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3030220211217009",
|
|
24
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030220211217009",
|
|
25
|
+
"@rollup/pluginutils": "^4.1.2",
|
|
26
26
|
"@vue/compiler-core": "3.2.26",
|
|
27
27
|
"@vue/compiler-dom": "3.2.26",
|
|
28
28
|
"@vue/compiler-sfc": "3.2.26",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"@types/mime": "^2.0.3",
|
|
62
62
|
"@types/module-alias": "^2.0.1",
|
|
63
63
|
"@types/stylus": "^0.48.36",
|
|
64
|
-
"postcss": "^8.
|
|
64
|
+
"postcss": "^8.4.5"
|
|
65
65
|
}
|
|
66
66
|
}
|