初始化
This commit is contained in:
202
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/LICENSE
generated
vendored
Normal file
202
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
22
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/bin/uni.js
generated
vendored
Normal file
22
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/bin/uni.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env node
|
||||
const { performance } = require('perf_hooks')
|
||||
global.__vite_start_time = performance.now()
|
||||
const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
|
||||
const filterIndex = process.argv.findIndex((arg) =>
|
||||
/^(?:-f|--filter)$/.test(arg)
|
||||
)
|
||||
if (debugIndex > 0) {
|
||||
let value = process.argv[debugIndex + 1]
|
||||
if (!value || value.startsWith('-')) {
|
||||
value = 'vite:*,uni:*'
|
||||
}
|
||||
process.env.DEBUG = value
|
||||
|
||||
if (filterIndex > 0) {
|
||||
const filter = process.argv[filterIndex + 1]
|
||||
if (filter && !filter.startsWith('-')) {
|
||||
process.env.VITE_DEBUG_FILTER = filter
|
||||
}
|
||||
}
|
||||
}
|
||||
require('../dist/cli/index.js')
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/action.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/action.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { BuildOptions, ServerOptions } from 'vite';
|
||||
import { CliOptions } from '.';
|
||||
export declare function runDev(options: CliOptions & ServerOptions): Promise<undefined>;
|
||||
export declare function runBuild(options: CliOptions & BuildOptions): Promise<void>;
|
||||
147
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/action.js
generated
vendored
Normal file
147
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/action.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runBuild = exports.runDev = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const build_1 = require("./build");
|
||||
const server_1 = require("./server");
|
||||
const utils_1 = require("./utils");
|
||||
const easycom_1 = require("../utils/easycom");
|
||||
const uvue_1 = require("./uvue");
|
||||
async function runDev(options) {
|
||||
(0, shared_1.extend)(options, {
|
||||
watch: {},
|
||||
});
|
||||
if (process.env.UNI_MINIMIZE === 'true') {
|
||||
;
|
||||
options.minify = true;
|
||||
}
|
||||
(0, utils_1.initEnv)('dev', options);
|
||||
if (process.env.UNI_APP_X === 'true' && options.platform === 'app') {
|
||||
return (0, uvue_1.runUVueDev)(options);
|
||||
}
|
||||
const createLogger = await Promise.resolve().then(() => __importStar(require('vite'))).then(({ createLogger }) => createLogger);
|
||||
try {
|
||||
if (options.platform === 'h5') {
|
||||
const server = await (options.ssr
|
||||
? (0, server_1.createSSRServer)(options)
|
||||
: (0, server_1.createServer)(options));
|
||||
(0, easycom_1.initEasycom)(server.watcher);
|
||||
}
|
||||
else {
|
||||
const watcher = (await (0, build_1.build)(options));
|
||||
(0, easycom_1.initEasycom)();
|
||||
let isFirstStart = true;
|
||||
let isFirstEnd = true;
|
||||
watcher.on('event', (event) => {
|
||||
if (event.code === 'BUNDLE_START') {
|
||||
if (isFirstStart) {
|
||||
isFirstStart = false;
|
||||
return;
|
||||
}
|
||||
(0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.start']);
|
||||
}
|
||||
else if (event.code === 'BUNDLE_END') {
|
||||
event.result.close();
|
||||
if (isFirstEnd) {
|
||||
// 首次全量同步
|
||||
if (options.platform === 'app') {
|
||||
process.env.UNI_APP_CHANGED_PAGES = '';
|
||||
process.env.UNI_APP_CHANGED_FILES = '';
|
||||
process.env.UNI_APP_UTS_CHANGED_FILES = '';
|
||||
}
|
||||
isFirstEnd = false;
|
||||
(0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
|
||||
(0, utils_1.showRunPrompt)(options.platform);
|
||||
(0, utils_1.printStartupDuration)(createLogger(options.logLevel), false);
|
||||
if (process.env.UNI_UTS_ERRORS) {
|
||||
console.error(process.env.UNI_UTS_ERRORS);
|
||||
}
|
||||
if (process.env.UNI_UTS_TIPS) {
|
||||
console.warn(process.env.UNI_UTS_TIPS);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (options.platform === 'app') {
|
||||
const files = process.env.UNI_APP_CHANGED_FILES;
|
||||
const pages = process.env.UNI_APP_CHANGED_PAGES;
|
||||
const dex = process.env.UNI_APP_UTS_CHANGED_FILES;
|
||||
const changedFiles = pages || files;
|
||||
process.env.UNI_APP_CHANGED_PAGES = '';
|
||||
process.env.UNI_APP_CHANGED_FILES = '';
|
||||
process.env.UNI_APP_UTS_CHANGED_FILES = '';
|
||||
if ((changedFiles &&
|
||||
!changedFiles.includes(uni_cli_shared_1.APP_CONFIG_SERVICE) &&
|
||||
!changedFiles.includes(uni_cli_shared_1.APP_SERVICE_FILENAME)) ||
|
||||
dex) {
|
||||
if (pages) {
|
||||
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end.pages'].replace('{pages}', changedFiles));
|
||||
}
|
||||
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end.files'].replace('{files}', JSON.stringify(JSON.parse(changedFiles || JSON.stringify([])).concat(JSON.parse(dex || JSON.stringify([]))))));
|
||||
}
|
||||
}
|
||||
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
|
||||
}
|
||||
else if (event.code === 'END') {
|
||||
if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
|
||||
(0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['build.failed']);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (options.platform === 'h5') {
|
||||
console.error(`error when starting dev server:\n${e.stack || e}`);
|
||||
}
|
||||
else {
|
||||
console.error(`error during build:\n${e.stack || e}`);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
exports.runDev = runDev;
|
||||
async function runBuild(options) {
|
||||
(0, utils_1.initEnv)('build', options);
|
||||
if (process.env.UNI_APP_X === 'true') {
|
||||
return (0, uvue_1.runUVueBuild)(options);
|
||||
}
|
||||
try {
|
||||
await (options.ssr && options.platform === 'h5'
|
||||
? (0, build_1.buildSSR)(options)
|
||||
: (0, build_1.build)(options));
|
||||
console.log(uni_cli_shared_1.M['build.done']);
|
||||
if (options.platform !== 'h5') {
|
||||
(0, utils_1.showRunPrompt)(options.platform);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`Build failed with errors.`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
exports.runBuild = runBuild;
|
||||
8
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/build.d.ts
generated
vendored
Normal file
8
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/build.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { BuildOptions, InlineConfig } from 'vite';
|
||||
import { CliOptions } from '.';
|
||||
import { RollupWatcher } from 'rollup';
|
||||
export declare function buildByVite(inlineConfig: InlineConfig): Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
|
||||
export declare function build(options: CliOptions): Promise<RollupWatcher | void>;
|
||||
export declare function buildSSR(options: CliOptions): Promise<void>;
|
||||
export declare function initBuildOptions(options: CliOptions, build: BuildOptions): InlineConfig;
|
||||
export declare function buildApp(options: CliOptions): Promise<RollupWatcher | void>;
|
||||
195
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/build.js
generated
vendored
Normal file
195
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/build.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildApp = exports.initBuildOptions = exports.buildSSR = exports.build = exports.buildByVite = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
async function buildByVite(inlineConfig) {
|
||||
return Promise.resolve().then(() => __importStar(require('vite'))).then(({ build }) => build(inlineConfig));
|
||||
}
|
||||
exports.buildByVite = buildByVite;
|
||||
async function build(options) {
|
||||
if (options.platform === 'app') {
|
||||
return buildApp(options);
|
||||
}
|
||||
return buildByVite((0, utils_1.addConfigFile)(initBuildOptions(options, (0, utils_1.cleanOptions)(options))));
|
||||
}
|
||||
exports.build = build;
|
||||
async function buildSSR(options) {
|
||||
const outputDir = process.env.UNI_OUTPUT_DIR;
|
||||
const ssrClientDir = path_1.default.resolve(outputDir, 'client');
|
||||
process.env.UNI_OUTPUT_DIR = ssrClientDir;
|
||||
const ssrBuildClientOptions = (0, utils_1.cleanOptions)(options);
|
||||
ssrBuildClientOptions.ssrManifest = true;
|
||||
ssrBuildClientOptions.outDir = process.env.UNI_OUTPUT_DIR;
|
||||
process.env.UNI_SSR_CLIENT = 'true';
|
||||
await buildByVite((0, utils_1.addConfigFile)(initBuildOptions(options, ssrBuildClientOptions)));
|
||||
const ssrServerDir = path_1.default.resolve(outputDir, 'server');
|
||||
process.env.UNI_OUTPUT_DIR = ssrServerDir;
|
||||
const ssrBuildServerOptions = (0, utils_1.cleanOptions)(options);
|
||||
ssrBuildServerOptions.ssr = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'entry-server.js');
|
||||
ssrBuildServerOptions.outDir = process.env.UNI_OUTPUT_DIR;
|
||||
process.env.UNI_SSR_CLIENT = '';
|
||||
process.env.UNI_SSR_SERVER = 'true';
|
||||
await buildByVite((0, utils_1.addConfigFile)(initBuildOptions(options, ssrBuildServerOptions)));
|
||||
// copy ssr-manfiest.json to server
|
||||
const assets = ['ssr-manifest.json', 'index.html'];
|
||||
assets.forEach((asset) => {
|
||||
const ssrManifestFile = path_1.default.join(ssrClientDir, asset);
|
||||
if (fs_extra_1.default.existsSync(ssrManifestFile)) {
|
||||
fs_extra_1.default.copyFileSync(ssrManifestFile, path_1.default.join(ssrServerDir, asset));
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.buildSSR = buildSSR;
|
||||
function initBuildOptions(options, build) {
|
||||
return {
|
||||
root: process.env.VITE_ROOT_DIR,
|
||||
configFile: options.config,
|
||||
base: options.base,
|
||||
logLevel: options.logLevel,
|
||||
clearScreen: options.clearScreen,
|
||||
mode: options.mode,
|
||||
build,
|
||||
};
|
||||
}
|
||||
exports.initBuildOptions = initBuildOptions;
|
||||
function buildManifestJson() {
|
||||
const platform = 'app';
|
||||
const inputDir = process.env.UNI_INPUT_DIR;
|
||||
const outputDir = process.env.UNI_OUTPUT_DIR;
|
||||
const pkg = require(path_1.default.resolve(__dirname, '../../package.json'));
|
||||
process.env.UNI_COMPILER_VERSION =
|
||||
process.env.UNI_COMPILER_VERSION ||
|
||||
pkg['uni-app']?.['compilerVersion'] ||
|
||||
'';
|
||||
(0, uni_cli_shared_1.initPreContext)(platform, process.env.UNI_CUSTOM_CONTEXT, process.env.UNI_UTS_PLATFORM, process.env.UNI_APP_X === 'true');
|
||||
const manifestJson = (0, uni_cli_shared_1.normalizeAppManifestJson)((0, uni_cli_shared_1.parseManifestJsonOnce)(inputDir), (0, uni_cli_shared_1.parsePagesJsonOnce)(inputDir, platform));
|
||||
fs_extra_1.default.outputFileSync(path_1.default.resolve(outputDir, 'manifest.json'), JSON.stringify(manifestJson, null, 2));
|
||||
}
|
||||
async function buildApp(options) {
|
||||
if (options.manifest) {
|
||||
return buildManifestJson();
|
||||
}
|
||||
let appWatcher;
|
||||
if (options.watch) {
|
||||
appWatcher = new AppWatcher();
|
||||
}
|
||||
if (process.env.UNI_RENDERER === 'native') {
|
||||
// 纯原生渲染时,main.js + App.vue 需要跟页面分开,独立编译(因为需要包含 Vuex 等共享内容)
|
||||
process.env.UNI_COMPILER = 'nvue';
|
||||
process.env.UNI_RENDERER_NATIVE = 'appService';
|
||||
const nvueAppBuilder = await buildByVite((0, utils_1.addConfigFile)((0, shared_1.extend)({ nvueAppService: true, nvue: true }, initBuildOptions(options, (0, utils_1.cleanOptions)(options)))));
|
||||
if (appWatcher) {
|
||||
appWatcher.setFirstWatcher(nvueAppBuilder);
|
||||
}
|
||||
process.env.UNI_RENDERER_NATIVE = 'pages';
|
||||
const nvueBuilder = await buildByVite((0, utils_1.addConfigFile)((0, shared_1.extend)({ nvue: true }, initBuildOptions(options, (0, utils_1.cleanOptions)(options)))));
|
||||
if (appWatcher) {
|
||||
appWatcher.setSecondWatcher(nvueBuilder);
|
||||
return appWatcher;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 指定为 vue 方便 App 插件初始化 vue 所需插件列表
|
||||
process.env.UNI_COMPILER = 'vue';
|
||||
const vueBuilder = await buildByVite((0, utils_1.addConfigFile)(initBuildOptions(options, (0, utils_1.cleanOptions)(options))));
|
||||
if (appWatcher) {
|
||||
appWatcher.setFirstWatcher(vueBuilder);
|
||||
}
|
||||
// 临时指定为 nvue 方便 App 插件初始化 nvue 所需插件列表
|
||||
process.env.UNI_COMPILER = 'nvue';
|
||||
const nvueBuilder = await buildByVite((0, utils_1.addConfigFile)((0, shared_1.extend)({ nvue: true }, initBuildOptions(options, (0, utils_1.cleanOptions)(options)))));
|
||||
// 还原为 vue
|
||||
process.env.UNI_COMPILER = 'vue';
|
||||
if (appWatcher) {
|
||||
appWatcher.setSecondWatcher(nvueBuilder);
|
||||
return appWatcher;
|
||||
}
|
||||
}
|
||||
exports.buildApp = buildApp;
|
||||
class AppWatcher {
|
||||
constructor() {
|
||||
this._firstStart = false;
|
||||
this._firstEnd = false;
|
||||
this._secondStart = false;
|
||||
this._secondEnd = false;
|
||||
}
|
||||
on(_event, callback) {
|
||||
this._callback = callback;
|
||||
}
|
||||
setFirstWatcher(firstWatcher) {
|
||||
firstWatcher.on('event', (event) => {
|
||||
if (event.code === 'BUNDLE_START') {
|
||||
this._bundleFirstStart(event);
|
||||
}
|
||||
else if (event.code === 'BUNDLE_END') {
|
||||
this._bundleFirstEnd(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
setSecondWatcher(secondWatcher) {
|
||||
secondWatcher.on('event', (event) => {
|
||||
if (event.code === 'BUNDLE_START') {
|
||||
this._bundleSecondStart(event);
|
||||
}
|
||||
else if (event.code === 'BUNDLE_END') {
|
||||
this._bundleSecondEnd(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
_bundleFirstStart(event) {
|
||||
this._firstStart = true;
|
||||
this._bundleStart(event);
|
||||
}
|
||||
_bundleFirstEnd(event) {
|
||||
this._firstEnd = true;
|
||||
this._bundleEnd(event);
|
||||
}
|
||||
_bundleSecondStart(event) {
|
||||
this._secondStart = true;
|
||||
this._bundleStart(event);
|
||||
}
|
||||
_bundleSecondEnd(event) {
|
||||
this._secondEnd = true;
|
||||
this._bundleEnd(event);
|
||||
}
|
||||
_bundleStart(event) {
|
||||
if (this._firstStart && this._secondStart) {
|
||||
this._callback(event);
|
||||
}
|
||||
}
|
||||
_bundleEnd(event) {
|
||||
if (this._firstEnd && this._secondEnd) {
|
||||
this._callback(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/index.d.ts
generated
vendored
Normal file
26
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { LogLevel } from 'vite';
|
||||
export interface CliOptions {
|
||||
'--'?: string[];
|
||||
c?: boolean | string;
|
||||
config?: string;
|
||||
platform?: string;
|
||||
p?: string;
|
||||
ssr?: boolean;
|
||||
base?: string;
|
||||
debug?: boolean | string;
|
||||
d?: boolean | string;
|
||||
filter?: string;
|
||||
f?: string;
|
||||
logLevel?: LogLevel;
|
||||
l?: LogLevel;
|
||||
m?: string;
|
||||
mode?: string;
|
||||
clearScreen?: boolean;
|
||||
autoHost?: string;
|
||||
autoPort?: number;
|
||||
devtools?: boolean;
|
||||
devtoolsHost?: string;
|
||||
devtoolsPort?: number;
|
||||
subpackage?: string;
|
||||
plugin?: boolean;
|
||||
}
|
||||
57
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/index.js
generated
vendored
Normal file
57
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const cac_1 = require("cac");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
const action_1 = require("./action");
|
||||
(0, uni_cli_shared_1.fixBinaryPath)();
|
||||
const cli = (0, cac_1.cac)('uni');
|
||||
cli
|
||||
.option('-c, --config <file>', `[string] use specified config file`)
|
||||
.option('-p, --platform [platform]', '[string] ' + utils_1.PLATFORMS.join(' | '), {
|
||||
default: 'h5',
|
||||
})
|
||||
.option('--base <path>', `[string] public base path (default: /)`)
|
||||
.option('-ssr', '[boolean] server-side rendering', {
|
||||
default: false,
|
||||
})
|
||||
.option('-l, --logLevel <level>', `[string] silent | error | warn | all`)
|
||||
.option('--clearScreen', `[boolean] allow/disable clear screen when logging`)
|
||||
.option('-d, --debug [feat]', `[string | boolean] show debug logs`)
|
||||
.option('-f, --filter <filter>', `[string] filter debug logs`)
|
||||
.option('-m, --mode <mode>', `[string] set env mode`)
|
||||
.option('--minify [minifier]', `[boolean | "terser" | "esbuild"] enable/disable minification, ` +
|
||||
`or specify minifier to use (default: terser)`)
|
||||
.option('--autoHost [autoHost]', `[string] specify automator hostname`)
|
||||
.option('--autoPort [autoPort]', `[number] specify automator port`)
|
||||
.option('--devtools', `[boolean] enable devtools`)
|
||||
.option('--devtoolsHost [devtoolsHost]', `[string] specify devtools hostname`)
|
||||
.option('--devtoolsPort [devtoolsPort]', `[number] specify devtools port`)
|
||||
.option('--subpackage [subpackage]', `[string] specify subpackage to build`)
|
||||
.option('--plugin', `[boolean] build plugin`);
|
||||
cli
|
||||
.command('')
|
||||
.alias('dev')
|
||||
.option('--host [host]', `[string] specify hostname`)
|
||||
.option('--port <port>', `[number] specify port`)
|
||||
.option('--https', `[boolean] use TLS + HTTP/2`)
|
||||
.option('--open [path]', `[boolean | string] open browser on startup`)
|
||||
.option('--cors', `[boolean] enable CORS`)
|
||||
.option('--strictPort', `[boolean] exit if specified port is already in use`)
|
||||
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
||||
.action(action_1.runDev);
|
||||
cli
|
||||
.command('build')
|
||||
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
||||
.option('--assetsInlineLimit <number>', `[number] static asset base64 inline threshold in bytes (default: 4096)`)
|
||||
.option('--sourcemap', `[boolean] output source maps for build (default: false)`)
|
||||
.option('--manifest', `[boolean] emit build manifest json`)
|
||||
.option('--ssrManifest', `[boolean] emit ssr manifest json`)
|
||||
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`, {
|
||||
default: true,
|
||||
})
|
||||
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
||||
.action(action_1.runBuild);
|
||||
cli.help();
|
||||
cli.version(require('../../package.json').version);
|
||||
cli.parse();
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/nvue.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/nvue.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initNVueEnv(): void;
|
||||
24
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/nvue.js
generated
vendored
Normal file
24
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/nvue.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initNVueEnv = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function initNVueEnv() {
|
||||
const manifestJson = (0, uni_cli_shared_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
|
||||
if ((0, uni_cli_shared_1.getAppRenderer)(manifestJson) === 'native') {
|
||||
process.env.UNI_RENDERER = 'native';
|
||||
}
|
||||
const nvueCompiler = (0, uni_cli_shared_1.getNVueCompiler)(manifestJson);
|
||||
if (nvueCompiler === 'uni-app') {
|
||||
process.env.UNI_NVUE_COMPILER = 'uni-app';
|
||||
}
|
||||
else if (nvueCompiler === 'vue') {
|
||||
process.env.UNI_NVUE_COMPILER = 'vue';
|
||||
}
|
||||
if ((0, uni_cli_shared_1.getNVueStyleCompiler)(manifestJson) === 'uni-app') {
|
||||
process.env.UNI_NVUE_STYLE_COMPILER = 'uni-app';
|
||||
}
|
||||
if ((0, uni_cli_shared_1.getAppCodeSpliting)(manifestJson)) {
|
||||
process.env.UNI_APP_CODE_SPLITING = 'true';
|
||||
}
|
||||
}
|
||||
exports.initNVueEnv = initNVueEnv;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/server.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/server.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { ServerOptions, ViteDevServer } from 'vite';
|
||||
import { CliOptions } from '.';
|
||||
export declare function createServer(options: CliOptions & ServerOptions): Promise<ViteDevServer>;
|
||||
export declare function createSSRServer(options: CliOptions & ServerOptions): Promise<ViteDevServer>;
|
||||
228
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/server.js
generated
vendored
Normal file
228
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/server.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createSSRServer = exports.createServer = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const picocolors_1 = __importDefault(require("picocolors"));
|
||||
const express_1 = __importDefault(require("express"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
function createLogger(level, options) {
|
||||
return Promise.resolve().then(() => __importStar(require('vite'))).then(({ createLogger }) => createLogger(level, options));
|
||||
}
|
||||
function createViteServer(inlineConfig) {
|
||||
return Promise.resolve().then(() => __importStar(require('vite'))).then(({ createServer }) => createServer(inlineConfig));
|
||||
}
|
||||
async function createServer(options) {
|
||||
const server = await createViteServer((0, utils_1.addConfigFile)({
|
||||
root: process.env.VITE_ROOT_DIR,
|
||||
configFile: options.config,
|
||||
base: options.base,
|
||||
mode: options.mode,
|
||||
logLevel: options.logLevel || 'info',
|
||||
clearScreen: options.clearScreen,
|
||||
server: (0, utils_1.cleanOptions)(options),
|
||||
}));
|
||||
await server.listen();
|
||||
const logger = server.config.logger;
|
||||
logger.info(picocolors_1.default.cyan(`\n vite v${require('vite/package.json').version}`) +
|
||||
picocolors_1.default.green(` dev server running at:\n`), {
|
||||
clear: !server.config.logger.hasWarned,
|
||||
});
|
||||
server.printUrls();
|
||||
// printUrls 会在 nextTick 中输出
|
||||
process.nextTick(() => (0, utils_1.printStartupDuration)(logger));
|
||||
return server;
|
||||
}
|
||||
exports.createServer = createServer;
|
||||
async function createSSRServer(options) {
|
||||
const app = (0, express_1.default)();
|
||||
/**
|
||||
* @type {import('vite').ViteDevServer}
|
||||
*/
|
||||
const vite = await createViteServer((0, utils_1.addConfigFile)({
|
||||
// custom: don't include HTML middlewares
|
||||
appType: 'custom',
|
||||
root: process.env.VITE_ROOT_DIR,
|
||||
configFile: options.config,
|
||||
base: options.base,
|
||||
mode: options.mode,
|
||||
logLevel: options.logLevel || 'info',
|
||||
clearScreen: options.clearScreen,
|
||||
server: {
|
||||
middlewareMode: true,
|
||||
watch: {
|
||||
// During tests we edit the files too fast and sometimes chokidar
|
||||
// misses change events, so enforce polling for consistency
|
||||
usePolling: true,
|
||||
interval: 100,
|
||||
},
|
||||
},
|
||||
}));
|
||||
// use vite's connect instance as middleware
|
||||
app.use(vite.middlewares);
|
||||
app.use('*', async (req, res) => {
|
||||
try {
|
||||
const { h5 } = (0, uni_cli_shared_1.parseManifestJson)(process.env.UNI_INPUT_DIR);
|
||||
const base = (h5 && h5.router && h5.router.base) || '';
|
||||
const url = req.originalUrl.replace(base, '');
|
||||
const template = await vite.transformIndexHtml(url, fs_1.default.readFileSync(path_1.default.resolve(process.env.VITE_ROOT_DIR, 'index.html'), 'utf-8'));
|
||||
const render = (await vite.ssrLoadModule(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'entry-server.js'))).render;
|
||||
const { title, headMeta, preloadLinks, appHtml, appContext } = await render(url);
|
||||
const icon = template.includes('rel="icon"')
|
||||
? ''
|
||||
: '<link rel="icon" href="data:," />\n';
|
||||
const html = template
|
||||
.replace(/<title>(.*?)<\/title>/, `${icon}<title>${title}</title>`)
|
||||
.replace(`<!--head-meta-->`, headMeta)
|
||||
.replace(`<!--preload-links-->`, preloadLinks)
|
||||
.replace(`<!--app-html-->`, appHtml)
|
||||
.replace(`<!--app-context-->`, appContext);
|
||||
res.status(200).set({ 'Content-Type': 'text/html' }).end(html);
|
||||
}
|
||||
catch (e) {
|
||||
vite && vite.ssrFixStacktrace(e);
|
||||
res.status(500).end(e.stack);
|
||||
}
|
||||
});
|
||||
const logger = await createLogger(options.logLevel);
|
||||
const serverOptions = vite.config.server || {};
|
||||
let port = options.port || serverOptions.port || 5173;
|
||||
let hostname;
|
||||
if (options.host === 'localhost') {
|
||||
// Use a secure default
|
||||
hostname = '127.0.0.1';
|
||||
}
|
||||
else if (options.host === undefined || options.host === true) {
|
||||
// probably passed --host in the CLI, without arguments
|
||||
hostname = undefined; // undefined typically means 0.0.0.0 or :: (listen on all IPs)
|
||||
}
|
||||
else {
|
||||
hostname = options.host;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const onSuccess = () => {
|
||||
printHttpServerUrls(server, vite.config);
|
||||
process.nextTick(() => (0, utils_1.printStartupDuration)(logger));
|
||||
resolve(vite);
|
||||
};
|
||||
const onError = (e) => {
|
||||
if (e.code === 'EADDRINUSE') {
|
||||
if (options.strictPort) {
|
||||
server.off('error', onError);
|
||||
reject(new Error(`Port ${port} is already in use`));
|
||||
}
|
||||
else {
|
||||
logger.info(`Port ${port} is in use, trying another one...`);
|
||||
app.listen(++port, hostname, onSuccess).on('error', onError);
|
||||
}
|
||||
}
|
||||
else {
|
||||
server.off('error', onError);
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
const server = app.listen(port, hostname, onSuccess).on('error', onError);
|
||||
});
|
||||
}
|
||||
exports.createSSRServer = createSSRServer;
|
||||
function printHttpServerUrls(server, config) {
|
||||
printCommonServerUrls(server, config.server, config);
|
||||
}
|
||||
function printCommonServerUrls(server, options, config) {
|
||||
const address = server.address();
|
||||
const isAddressInfo = (x) => x?.address;
|
||||
if (isAddressInfo(address)) {
|
||||
const hostname = resolveHostname(options.host);
|
||||
const protocol = options.https ? 'https' : 'http';
|
||||
printServerUrls(hostname, protocol, address.port, config.base, config.logger.info);
|
||||
}
|
||||
}
|
||||
function printServerUrls(hostname, protocol, port, base, info) {
|
||||
if (hostname.host === '127.0.0.1') {
|
||||
const url = `${protocol}://${hostname.name}:${picocolors_1.default.bold(port)}${base}`;
|
||||
info(` - Local: ${picocolors_1.default.cyan(url)}`);
|
||||
if (hostname.name !== '127.0.0.1') {
|
||||
info(` - Network: ${picocolors_1.default.dim('use `--host` to expose')}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Object.values(os_1.default.networkInterfaces())
|
||||
.flatMap((nInterface) => nInterface ?? [])
|
||||
.filter((detail) => detail &&
|
||||
detail.address &&
|
||||
// Node < v18
|
||||
((typeof detail.family === 'string' && detail.family === 'IPv4') ||
|
||||
// Node >= v18
|
||||
// @ts-ignore
|
||||
(typeof detail.family === 'number' && detail.family === 4)))
|
||||
.map((detail) => {
|
||||
const type = detail.address.includes('127.0.0.1')
|
||||
? ' - Local: '
|
||||
: ' * Network: ';
|
||||
const host = detail.address.replace('127.0.0.1', hostname.name);
|
||||
const url = `${protocol}://${host}:${picocolors_1.default.bold(port)}${base}`;
|
||||
return `${type} ${picocolors_1.default.cyan(url)}`;
|
||||
})
|
||||
.sort((msg1) => {
|
||||
return msg1.indexOf('- Local') > -1 ? -1 : 1;
|
||||
})
|
||||
.forEach((msg, index, arr) => {
|
||||
if (arr.length - 1 === index) {
|
||||
info(msg.replace('* Network', '- Network'));
|
||||
}
|
||||
else {
|
||||
info(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function resolveHostname(optionsHost) {
|
||||
let host;
|
||||
if (optionsHost === undefined || optionsHost === false) {
|
||||
// Use a secure default
|
||||
host = '127.0.0.1';
|
||||
}
|
||||
else if (optionsHost === true) {
|
||||
// If passed --host in the CLI without arguments
|
||||
host = undefined; // undefined typically means 0.0.0.0 or :: (listen on all IPs)
|
||||
}
|
||||
else {
|
||||
host = optionsHost;
|
||||
}
|
||||
// Set host name to localhost when possible, unless the user explicitly asked for '127.0.0.1'
|
||||
const name = (optionsHost !== '127.0.0.1' && host === '127.0.0.1') ||
|
||||
host === '0.0.0.0' ||
|
||||
host === '::' ||
|
||||
host === undefined
|
||||
? 'localhost'
|
||||
: host;
|
||||
return { host, name };
|
||||
}
|
||||
33
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/utils.d.ts
generated
vendored
Normal file
33
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { InlineConfig, Logger } from 'vite';
|
||||
import { CliOptions } from '.';
|
||||
export declare const PLATFORMS: string[];
|
||||
export type PLATFORM = 'app' | 'mp-alipay' | 'mp-baidu' | 'mp-kuaishou' | 'mp-lark' | 'mp-qq' | 'mp-toutiao' | 'mp-weixin' | 'quickapp-webview' | 'quickapp-webview-huawei' | 'quickapp-webview-union';
|
||||
export declare function addConfigFile(inlineConfig: InlineConfig): InlineConfig;
|
||||
export declare function initEnv(type: 'unknown' | 'dev' | 'build', options: CliOptions): void;
|
||||
export declare function cleanOptions(options: CliOptions): {
|
||||
'--'?: string[] | undefined;
|
||||
c?: string | boolean | undefined;
|
||||
config?: string | undefined;
|
||||
platform?: string | undefined;
|
||||
p?: string | undefined;
|
||||
ssr?: boolean | undefined;
|
||||
base?: string | undefined;
|
||||
debug?: string | boolean | undefined;
|
||||
d?: string | boolean | undefined;
|
||||
filter?: string | undefined;
|
||||
f?: string | undefined;
|
||||
logLevel?: import("vite").LogLevel | undefined;
|
||||
l?: import("vite").LogLevel | undefined;
|
||||
m?: string | undefined;
|
||||
mode?: string | undefined;
|
||||
clearScreen?: boolean | undefined;
|
||||
autoHost?: string | undefined;
|
||||
autoPort?: number | undefined;
|
||||
devtools?: boolean | undefined;
|
||||
devtoolsHost?: string | undefined;
|
||||
devtoolsPort?: number | undefined;
|
||||
subpackage?: string | undefined;
|
||||
plugin?: boolean | undefined;
|
||||
};
|
||||
export declare function printStartupDuration(logger: Logger, whitespace?: boolean): void;
|
||||
export declare function showRunPrompt(platform: PLATFORM): void;
|
||||
289
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/utils.js
generated
vendored
Normal file
289
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/utils.js
generated
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.showRunPrompt = exports.printStartupDuration = exports.cleanOptions = exports.initEnv = exports.addConfigFile = exports.PLATFORMS = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const picocolors_1 = __importDefault(require("picocolors"));
|
||||
const perf_hooks_1 = require("perf_hooks");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const nvue_1 = require("./nvue");
|
||||
const uvue_1 = require("./uvue");
|
||||
exports.PLATFORMS = [
|
||||
'app',
|
||||
'h5',
|
||||
'mp-alipay',
|
||||
'mp-baidu',
|
||||
'mp-qq',
|
||||
'mp-lark',
|
||||
'mp-toutiao',
|
||||
'mp-weixin',
|
||||
'quickapp-webview',
|
||||
'quickapp-webview-huawei',
|
||||
'quickapp-webview-union',
|
||||
];
|
||||
function resolveConfigFile() {
|
||||
const viteConfigJs = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'vite.config.js');
|
||||
const viteConfigTs = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'vite.config.ts');
|
||||
if (fs_1.default.existsSync(viteConfigTs)) {
|
||||
return viteConfigTs;
|
||||
}
|
||||
if (fs_1.default.existsSync(viteConfigJs)) {
|
||||
return viteConfigJs;
|
||||
}
|
||||
return path_1.default.resolve(process.env.UNI_CLI_CONTEXT, 'vite.config.js');
|
||||
}
|
||||
function addConfigFile(inlineConfig) {
|
||||
if ((0, uni_cli_shared_1.isInHBuilderX)()) {
|
||||
inlineConfig.configFile = resolveConfigFile();
|
||||
}
|
||||
return inlineConfig;
|
||||
}
|
||||
exports.addConfigFile = addConfigFile;
|
||||
let initialized = false;
|
||||
function initEnv(type, options) {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
if (options.platform === 'mp-360') {
|
||||
console.error(uni_cli_shared_1.M['mp.360.unsupported']);
|
||||
process.exit(0);
|
||||
}
|
||||
if (options.plugin) {
|
||||
process.env.UNI_MP_PLUGIN = 'true';
|
||||
}
|
||||
// TODO 需要识别 mode
|
||||
if (type === 'dev') {
|
||||
process.env.NODE_ENV = 'development';
|
||||
}
|
||||
else if (type === 'build') {
|
||||
if (options.watch) {
|
||||
process.env.NODE_ENV = 'development';
|
||||
}
|
||||
else {
|
||||
process.env.NODE_ENV = 'production';
|
||||
}
|
||||
}
|
||||
if (!options.mode) {
|
||||
options.mode = process.env.NODE_ENV;
|
||||
}
|
||||
// vite 会修改 NODE_ENV,存储在 UNI_NODE_ENV 中,稍后校正 NODE_ENV
|
||||
process.env.UNI_NODE_ENV = process.env.VITE_USER_NODE_ENV =
|
||||
process.env.NODE_ENV;
|
||||
process.env.UNI_CLI_CONTEXT = (0, uni_cli_shared_1.isInHBuilderX)()
|
||||
? path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-cli-vite')
|
||||
: process.cwd();
|
||||
// TODO 待优化
|
||||
initUTSPlatform(options);
|
||||
if (options.platform === 'quickapp-webview-huawei' ||
|
||||
options.platform === 'quickapp-webview-union') {
|
||||
process.env.UNI_SUB_PLATFORM = options.platform;
|
||||
options.platform = 'quickapp-webview';
|
||||
}
|
||||
process.env.VITE_ROOT_DIR =
|
||||
process.env.VITE_ROOT_DIR || process.env.UNI_INPUT_DIR || process.cwd();
|
||||
process.env.UNI_INPUT_DIR =
|
||||
process.env.UNI_INPUT_DIR || path_1.default.resolve(process.cwd(), 'src');
|
||||
initCustomScripts(options);
|
||||
process.env.UNI_PLATFORM = options.platform;
|
||||
const hasOutputDir = !!process.env.UNI_OUTPUT_DIR;
|
||||
if (hasOutputDir) {
|
||||
;
|
||||
options.outDir = process.env.UNI_OUTPUT_DIR;
|
||||
}
|
||||
else {
|
||||
if (!options.outDir) {
|
||||
;
|
||||
options.outDir = path_1.default.resolve(process.cwd(), 'dist', process.env.NODE_ENV === 'production' ? 'build' : 'dev', (0, uni_cli_shared_1.getPlatformDir)());
|
||||
}
|
||||
process.env.UNI_OUTPUT_DIR = options.outDir;
|
||||
}
|
||||
// 兼容 HBuilderX 旧参数
|
||||
if (process.env.UNI_SUBPACKGE) {
|
||||
options.subpackage = process.env.UNI_SUBPACKGE;
|
||||
}
|
||||
if (options.subpackage) {
|
||||
process.env.UNI_SUBPACKAGE = options.subpackage;
|
||||
if (!hasOutputDir) {
|
||||
// 未指定,则自动补充
|
||||
process.env.UNI_OUTPUT_DIR = options.outDir =
|
||||
path_1.default.resolve(process.env.UNI_OUTPUT_DIR, options.subpackage);
|
||||
}
|
||||
}
|
||||
initAutomator(options);
|
||||
initDevtools(options);
|
||||
if (process.env.UNI_PLATFORM === 'app') {
|
||||
(0, nvue_1.initNVueEnv)();
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(uni_cli_shared_1.M['dev.performance'] +
|
||||
(process.env.UNI_PLATFORM.startsWith('mp-')
|
||||
? uni_cli_shared_1.M['dev.performance.mp']
|
||||
: ''));
|
||||
}
|
||||
if (options.sourcemap &&
|
||||
process.env.NODE_ENV === 'production') {
|
||||
process.env.SOURCEMAP = 'true';
|
||||
}
|
||||
(0, uni_cli_shared_1.initModulePaths)();
|
||||
(0, uvue_1.initUVueEnv)();
|
||||
if (process.env.UNI_PLATFORM === 'app') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (
|
||||
// 仅windows
|
||||
uni_cli_shared_1.isWindows &&
|
||||
process.env.UNI_APP_X === 'true' &&
|
||||
process.env.UNI_UTS_PLATFORM === 'app-android') {
|
||||
console.log(uni_cli_shared_1.M['dev.exclusion']);
|
||||
}
|
||||
}
|
||||
const pkg = require('../../package.json');
|
||||
console.log(uni_cli_shared_1.M['app.compiler.version'].replace('{version}', pkg['uni-app']['compilerVersion'] +
|
||||
`(${process.env.UNI_APP_X === 'true' ? 'uni-app x' : 'vue3'})`));
|
||||
}
|
||||
console.log(uni_cli_shared_1.M['compiling']);
|
||||
}
|
||||
exports.initEnv = initEnv;
|
||||
function initUTSPlatform(options) {
|
||||
if (options.platform === 'app-android') {
|
||||
process.env.UNI_UTS_PLATFORM = 'app-android';
|
||||
options.platform = 'app';
|
||||
}
|
||||
else if (options.platform === 'app-ios') {
|
||||
process.env.UNI_UTS_PLATFORM = 'app-ios';
|
||||
options.platform = 'app';
|
||||
}
|
||||
else {
|
||||
// 运行时,可能传入了 UNI_APP_PLATFORM = 'android'|'ios'
|
||||
if (process.env.UNI_APP_PLATFORM === 'android') {
|
||||
process.env.UNI_UTS_PLATFORM = 'app-android';
|
||||
}
|
||||
if (process.env.UNI_APP_PLATFORM === 'ios') {
|
||||
process.env.UNI_UTS_PLATFORM = 'app-ios';
|
||||
}
|
||||
if (options.platform === 'app-plus') {
|
||||
options.platform = 'app';
|
||||
}
|
||||
}
|
||||
if (options.platform === 'h5') {
|
||||
process.env.UNI_UTS_PLATFORM = 'web';
|
||||
}
|
||||
// 非 app 平台,自动补充 UNI_UTS_PLATFORM
|
||||
// app 平台,必须主动传入
|
||||
if (options.platform !== 'app') {
|
||||
if (!process.env.UNI_UTS_PLATFORM) {
|
||||
process.env.UNI_UTS_PLATFORM = options.platform;
|
||||
}
|
||||
}
|
||||
process.env.UNI_UTS_TARGET_LANGUAGE = 'javascript';
|
||||
if (process.env.UNI_UTS_PLATFORM === 'app-android') {
|
||||
process.env.UNI_UTS_TARGET_LANGUAGE = 'kotlin';
|
||||
}
|
||||
else if (process.env.UNI_UTS_PLATFORM === 'app-ios') {
|
||||
process.env.UNI_UTS_TARGET_LANGUAGE = 'swift';
|
||||
}
|
||||
}
|
||||
function initDevtools({ devtools, devtoolsHost, devtoolsPort }) {
|
||||
if (!devtools) {
|
||||
return;
|
||||
}
|
||||
process.env.__VUE_PROD_DEVTOOLS__ = 'true';
|
||||
if (devtoolsHost) {
|
||||
process.env.__VUE_DEVTOOLS_HOST__ = devtoolsHost;
|
||||
}
|
||||
if (devtoolsPort) {
|
||||
process.env.__VUE_DEVTOOLS_PORT__ = devtoolsPort + '';
|
||||
}
|
||||
}
|
||||
function initAutomator({ autoHost, autoPort }) {
|
||||
// 发行分包,插件也不需要自动化测试
|
||||
if (!autoPort || process.env.UNI_SUBPACKAGE || process.env.UNI_MP_PLUGIN) {
|
||||
return;
|
||||
}
|
||||
process.env.UNI_AUTOMATOR_WS_ENDPOINT =
|
||||
'ws://' + (autoHost || resolveHostname()) + ':' + autoPort;
|
||||
}
|
||||
function resolveHostname() {
|
||||
const interfaces = os_1.default.networkInterfaces();
|
||||
const keys = Object.keys(interfaces);
|
||||
for (const key of keys) {
|
||||
const interfaceInfos = interfaces[key];
|
||||
if (!interfaceInfos) {
|
||||
continue;
|
||||
}
|
||||
for (const info of interfaceInfos) {
|
||||
if ((info.family === 'IPv4' ||
|
||||
/* Node >= v18 */ info.family === 4) &&
|
||||
!info.address.includes('127.0.0.1')) {
|
||||
return info.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'localhost';
|
||||
}
|
||||
function cleanOptions(options) {
|
||||
const ret = { ...options };
|
||||
delete ret['--'];
|
||||
delete ret.c;
|
||||
delete ret.config;
|
||||
delete ret.platform;
|
||||
delete ret.p;
|
||||
delete ret.ssr;
|
||||
delete ret.base;
|
||||
delete ret.debug;
|
||||
delete ret.d;
|
||||
delete ret.filter;
|
||||
delete ret.f;
|
||||
delete ret.logLevel;
|
||||
delete ret.l;
|
||||
delete ret.clearScreen;
|
||||
delete ret.m;
|
||||
delete ret.mode;
|
||||
delete ret.autoHost;
|
||||
delete ret.autoPort;
|
||||
return ret;
|
||||
}
|
||||
exports.cleanOptions = cleanOptions;
|
||||
function printStartupDuration(logger, whitespace = true) {
|
||||
// @ts-ignore
|
||||
if (global.__vite_start_time) {
|
||||
// @ts-ignore
|
||||
const startupDuration = perf_hooks_1.performance.now() - global.__vite_start_time;
|
||||
logger.info(`${whitespace ? `\n ` : ''}${picocolors_1.default.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
|
||||
}
|
||||
}
|
||||
exports.printStartupDuration = printStartupDuration;
|
||||
function initCustomScripts(options) {
|
||||
const custom = (0, uni_cli_shared_1.parseScripts)(process.env.UNI_SCRIPT || options.platform, // process.env.UNI_SCRIPT 是 HBuilderX 传递的
|
||||
path_1.default.join(process.env.VITE_ROOT_DIR, 'package.json'));
|
||||
if (!custom) {
|
||||
return;
|
||||
}
|
||||
options.platform = custom.platform;
|
||||
process.env.UNI_CUSTOM_SCRIPT = custom.name;
|
||||
process.env.UNI_CUSTOM_DEFINE = JSON.stringify(custom.define);
|
||||
process.env.UNI_CUSTOM_CONTEXT = JSON.stringify(custom.context);
|
||||
}
|
||||
function showRunPrompt(platform) {
|
||||
if (!(0, uni_cli_shared_1.isInHBuilderX)()) {
|
||||
const devtools = getPlatformDevtools(getOriginalPlatform(platform));
|
||||
const outputDir = path_1.default.relative(process.env.UNI_CLI_CONTEXT, process.env.UNI_OUTPUT_DIR);
|
||||
(0, uni_cli_shared_1.output)('log', `${uni_cli_shared_1.M['prompt.run.message']
|
||||
.replace('{devtools}', uni_cli_shared_1.M[devtools])
|
||||
.replace('{outputDir}', picocolors_1.default.cyan(outputDir))}`);
|
||||
}
|
||||
}
|
||||
exports.showRunPrompt = showRunPrompt;
|
||||
function getOriginalPlatform(platform) {
|
||||
if (platform.startsWith('quickapp-webview') && process.env.UNI_SUB_PLATFORM) {
|
||||
return process.env.UNI_SUB_PLATFORM;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
function getPlatformDevtools(platform) {
|
||||
return `prompt.run.devtools.${platform}`;
|
||||
}
|
||||
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/uvue.d.ts
generated
vendored
Normal file
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/uvue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { BuildOptions, ServerOptions } from 'vite';
|
||||
import { RollupWatcher } from 'rollup';
|
||||
import { CliOptions } from '.';
|
||||
export declare function initUVueEnv(): void;
|
||||
export declare function runUVueDev(options: CliOptions & ServerOptions): Promise<undefined>;
|
||||
export declare function runUVueBuild(options: CliOptions & BuildOptions): Promise<void>;
|
||||
/**
|
||||
* 目前的简易实现逻辑
|
||||
* node层:
|
||||
* 1. 监听项目,生成资源到临时目录 .uts/android, .uts/ios
|
||||
* 2. uvue 文件,做解析,拆分生成 render.kt, css.kt, uts.uvue
|
||||
* 3. static 文件,copy 到最终目录
|
||||
* 4. uvue、vue、uts 文件发生变化,调用 uts 编译器
|
||||
* @param options
|
||||
*/
|
||||
export declare function buildUVue(options: CliOptions): Promise<RollupWatcher | void>;
|
||||
94
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/uvue.js
generated
vendored
Normal file
94
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/cli/uvue.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildUVue = exports.runUVueBuild = exports.runUVueDev = exports.initUVueEnv = void 0;
|
||||
const vite_1 = require("vite");
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const build_1 = require("./build");
|
||||
const utils_1 = require("./utils");
|
||||
const easycom_1 = require("../utils/easycom");
|
||||
function initUVueEnv() {
|
||||
// 直接指定了
|
||||
if (process.env.UNI_APP_X === 'false') {
|
||||
return;
|
||||
}
|
||||
const manifestJson = (0, uni_cli_shared_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
|
||||
const isNVueEnabled = (0, shared_1.hasOwn)(manifestJson, 'uni-app-x');
|
||||
if (!isNVueEnabled) {
|
||||
return;
|
||||
}
|
||||
process.env.UNI_APP_X = 'true';
|
||||
}
|
||||
exports.initUVueEnv = initUVueEnv;
|
||||
async function runUVueDev(options) {
|
||||
if (options.platform !== 'app') {
|
||||
(0, uni_cli_shared_1.output)('error', uni_cli_shared_1.M['uvue.unsupported'].replace('{platform}', options.platform));
|
||||
return process.exit(0);
|
||||
}
|
||||
(0, easycom_1.initEasycom)();
|
||||
const watcher = (await buildUVue(options));
|
||||
let isFirstStart = true;
|
||||
let isFirstEnd = true;
|
||||
watcher.on('event', (event) => {
|
||||
if (event.code === 'BUNDLE_START') {
|
||||
if (isFirstStart) {
|
||||
isFirstStart = false;
|
||||
return;
|
||||
}
|
||||
(0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.start']);
|
||||
// 重置一下,uts编译报错会导致下一次开始差量编译紧接着上一次的差量编译,导致无法正常输出
|
||||
(0, uni_cli_shared_1.resetOutput)('log');
|
||||
}
|
||||
else if (event.code === 'BUNDLE_END') {
|
||||
event.result.close();
|
||||
const dex = process.env.UNI_APP_UTS_CHANGED_FILES;
|
||||
process.env.UNI_APP_UTS_CHANGED_FILES = '';
|
||||
if (isFirstEnd) {
|
||||
// 首次全量同步
|
||||
isFirstEnd = false;
|
||||
(0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
|
||||
(0, utils_1.printStartupDuration)((0, vite_1.createLogger)(options.logLevel), false);
|
||||
return;
|
||||
}
|
||||
if (dex) {
|
||||
const files = JSON.parse(dex);
|
||||
if (!files.length) {
|
||||
// 本次无变动
|
||||
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['uvue.dev.watching.end.empty']);
|
||||
}
|
||||
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end.files'].replace('{files}', JSON.stringify(files)));
|
||||
}
|
||||
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.runUVueDev = runUVueDev;
|
||||
async function runUVueBuild(options) {
|
||||
try {
|
||||
(0, uni_cli_shared_1.initEasycomsOnce)(process.env.UNI_INPUT_DIR, {
|
||||
dirs: [(0, uni_cli_shared_1.resolveComponentsLibPath)()],
|
||||
platform: process.env.UNI_PLATFORM,
|
||||
isX: true,
|
||||
});
|
||||
await buildUVue(options);
|
||||
console.log(uni_cli_shared_1.M['build.done']);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`Build failed with errors.`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
exports.runUVueBuild = runUVueBuild;
|
||||
/**
|
||||
* 目前的简易实现逻辑
|
||||
* node层:
|
||||
* 1. 监听项目,生成资源到临时目录 .uts/android, .uts/ios
|
||||
* 2. uvue 文件,做解析,拆分生成 render.kt, css.kt, uts.uvue
|
||||
* 3. static 文件,copy 到最终目录
|
||||
* 4. uvue、vue、uts 文件发生变化,调用 uts 编译器
|
||||
* @param options
|
||||
*/
|
||||
async function buildUVue(options) {
|
||||
return (0, build_1.buildByVite)((0, utils_1.addConfigFile)((0, shared_1.extend)({ nvueAppService: true, nvue: true }, (0, build_1.initBuildOptions)(options, (0, utils_1.cleanOptions)(options)))));
|
||||
}
|
||||
exports.buildUVue = buildUVue;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/build.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/build.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { UserConfig } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createBuild(options: VitePluginUniResolvedOptions, config: UserConfig): UserConfig['build'];
|
||||
45
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/build.js
generated
vendored
Normal file
45
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/build.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuild = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const shared_1 = require("@vue/shared");
|
||||
function createBuild(options, config) {
|
||||
(0, uni_cli_shared_1.initEasycomsOnce)(options.inputDir, {
|
||||
dirs: [(0, uni_cli_shared_1.resolveComponentsLibPath)()],
|
||||
platform: process.env.UNI_PLATFORM,
|
||||
isX: process.env.UNI_APP_X === 'true',
|
||||
});
|
||||
const rollupOutputOption = config.build?.rollupOptions?.output;
|
||||
const sourcemap = process.env.SOURCEMAP === 'true' ? 'hidden' : config.build?.sourcemap;
|
||||
return {
|
||||
sourcemap,
|
||||
cssTarget: uni_cli_shared_1.cssTarget,
|
||||
chunkSizeWarningLimit: 100000000,
|
||||
minify: config.build && (0, shared_1.hasOwn)(config.build, 'minify')
|
||||
? config.build.minify
|
||||
: process.env.NODE_ENV === 'production'
|
||||
? 'terser'
|
||||
: false,
|
||||
rollupOptions: {
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
|
||||
const { message } = warning;
|
||||
// ignore
|
||||
if (message.includes('"vue"') ||
|
||||
message.includes('"resolveComponent"') ||
|
||||
message.includes('"@dcloudio/uni-h5"')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
warn(warning);
|
||||
},
|
||||
output: {
|
||||
sourcemapExcludeSources: !(0, shared_1.isArray)(rollupOutputOption) &&
|
||||
rollupOutputOption?.sourcemapExcludeSources === false
|
||||
? false
|
||||
: process.env.SOURCEMAP === 'true',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.createBuild = createBuild;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/css.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/css.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { UserConfig } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createCss(options: VitePluginUniResolvedOptions, config: UserConfig): UserConfig['css'];
|
||||
32
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/css.js
generated
vendored
Normal file
32
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/css.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createCss = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function resolveAdditionalData(inputDir, config) {
|
||||
const uniScssFile = path_1.default.resolve(inputDir, 'uni.scss');
|
||||
const userAdditionalData = config.css?.preprocessorOptions?.scss?.additionalData || '';
|
||||
if (!fs_extra_1.default.existsSync(uniScssFile)) {
|
||||
return userAdditionalData;
|
||||
}
|
||||
let content = fs_extra_1.default.readFileSync(uniScssFile, 'utf8');
|
||||
if (content.includes('#endif')) {
|
||||
content = (0, uni_cli_shared_1.preCss)(content);
|
||||
}
|
||||
return content + '\n' + userAdditionalData;
|
||||
}
|
||||
function createCss(options, config) {
|
||||
return {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
charset: false,
|
||||
additionalData: resolveAdditionalData(options.inputDir, config),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.createCss = createCss;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/define.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/define.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { UserConfig } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createDefine(_: VitePluginUniResolvedOptions): UserConfig['define'];
|
||||
14
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/define.js
generated
vendored
Normal file
14
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/define.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createDefine = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function createDefine(_) {
|
||||
return (0, shared_1.extend)({
|
||||
__VUE_I18N_FULL_INSTALL__: true,
|
||||
__VUE_I18N_LEGACY_API__: true,
|
||||
__VUE_I18N_PROD_DEVTOOLS__: false,
|
||||
__INTLIFY_PROD_DEVTOOLS__: false,
|
||||
}, (0, uni_cli_shared_1.initDefine)());
|
||||
}
|
||||
exports.createDefine = createDefine;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/index.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Plugin } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createConfig(options: VitePluginUniResolvedOptions, _uniPlugins: Plugin[]): Plugin['config'];
|
||||
41
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/index.js
generated
vendored
Normal file
41
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/index.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createConfig = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const css_1 = require("./css");
|
||||
const resolve_1 = require("./resolve");
|
||||
const build_1 = require("./build");
|
||||
const optimizeDeps_1 = require("./optimizeDeps");
|
||||
const define_1 = require("./define");
|
||||
function createConfig(options, _uniPlugins) {
|
||||
return (config, env) => {
|
||||
options.command = env.command;
|
||||
let base = config.base;
|
||||
if (!base) {
|
||||
const { h5 } = (0, uni_cli_shared_1.parseManifestJsonOnce)(options.inputDir);
|
||||
base = (h5 && h5.router && h5.router.base) || '';
|
||||
}
|
||||
if (!base) {
|
||||
base = '/';
|
||||
}
|
||||
options.base = base;
|
||||
return {
|
||||
base: process.env.UNI_H5_BASE || base,
|
||||
root: process.env.VITE_ROOT_DIR,
|
||||
// TODO 临时设置为__static__,屏蔽警告:https://github.com/vitejs/vite/blob/824d042535033a5c3d7006978c0d05c201cd1c25/packages/vite/src/node/server/middlewares/transform.ts#L125
|
||||
publicDir: config.publicDir || '__static__',
|
||||
define: (0, define_1.createDefine)(options),
|
||||
resolve: (0, resolve_1.createResolve)(options, config),
|
||||
logLevel: config.logLevel || 'warn',
|
||||
optimizeDeps: (0, optimizeDeps_1.createOptimizeDeps)(options),
|
||||
build: (0, build_1.createBuild)(options, config),
|
||||
css: (0, css_1.createCss)(options, config),
|
||||
esbuild: {
|
||||
include: /\.(tsx?|jsx|uts)$/,
|
||||
exclude: /\.js$/,
|
||||
loader: 'ts',
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.createConfig = createConfig;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/optimizeDeps.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/optimizeDeps.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { UserConfig } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createOptimizeDeps(_options: VitePluginUniResolvedOptions): UserConfig['optimizeDeps'];
|
||||
20
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/optimizeDeps.js
generated
vendored
Normal file
20
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/optimizeDeps.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createOptimizeDeps = void 0;
|
||||
function createOptimizeDeps(_options) {
|
||||
return {
|
||||
exclude: [
|
||||
'vue',
|
||||
'vuex',
|
||||
'vue-i18n',
|
||||
'vue-router',
|
||||
'@dcloudio/uni-app',
|
||||
'@dcloudio/uni-components',
|
||||
'@dcloudio/uni-i18n',
|
||||
'@dcloudio/uni-shared',
|
||||
'@dcloudio/uni-stacktracey',
|
||||
'pinia',
|
||||
],
|
||||
};
|
||||
}
|
||||
exports.createOptimizeDeps = createOptimizeDeps;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/resolve.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/resolve.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { UserConfig, ResolverFunction } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare const customResolver: ResolverFunction;
|
||||
export declare function createResolve(options: VitePluginUniResolvedOptions, _config: UserConfig): UserConfig['resolve'];
|
||||
48
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/resolve.js
generated
vendored
Normal file
48
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/config/resolve.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createResolve = exports.customResolver = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function resolveUTSModuleProxyFile(id, importer) {
|
||||
const file = (0, uni_cli_shared_1.resolveUTSAppModule)(id, importer);
|
||||
if (file) {
|
||||
return file + '?uts-proxy';
|
||||
}
|
||||
}
|
||||
const customResolver = (updatedId, importer) => {
|
||||
const utsImporter = importer
|
||||
? path_1.default.dirname(importer)
|
||||
: process.env.UNI_INPUT_DIR;
|
||||
const utsModuleFile = process.env.UNI_PLATFORM === 'app'
|
||||
? resolveUTSModuleProxyFile(updatedId, utsImporter)
|
||||
: (0, uni_cli_shared_1.resolveUTSModule)(updatedId, utsImporter);
|
||||
if (utsModuleFile) {
|
||||
return uni_cli_shared_1.isWindows ? (0, uni_cli_shared_1.normalizePath)(utsModuleFile) : utsModuleFile;
|
||||
}
|
||||
if (uni_cli_shared_1.isWindows) {
|
||||
return (0, uni_cli_shared_1.normalizePath)((0, uni_cli_shared_1.requireResolve)(updatedId, importer || process.env.UNI_INPUT_DIR));
|
||||
}
|
||||
return (0, uni_cli_shared_1.requireResolve)(updatedId, importer || process.env.UNI_INPUT_DIR);
|
||||
};
|
||||
exports.customResolver = customResolver;
|
||||
function createResolve(options, _config) {
|
||||
return {
|
||||
// 必须使用alias解析,插件定制的resolveId,不会被应用到css等预处理器中
|
||||
alias: [
|
||||
// @ts-ignore because @rollup/plugin-alias' type doesn't allow function
|
||||
// replacement, but its implementation does work with function values.
|
||||
{
|
||||
find: /^(~@|@)\/(.*)/,
|
||||
replacement(_str, _$1, $2) {
|
||||
return (0, uni_cli_shared_1.normalizePath)(path_1.default.resolve(options.inputDir, $2));
|
||||
},
|
||||
customResolver: exports.customResolver,
|
||||
},
|
||||
],
|
||||
extensions: process.env.UNI_APP_X === 'true' ? uni_cli_shared_1.uni_app_x_extensions : uni_cli_shared_1.extensions,
|
||||
};
|
||||
}
|
||||
exports.createResolve = createResolve;
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/env.d.ts
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/env.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { ResolvedConfig } from 'vite';
|
||||
export declare function initEnv(config: ResolvedConfig): void;
|
||||
31
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/env.js
generated
vendored
Normal file
31
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/env.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initEnv = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function initEnv(config) {
|
||||
if (!process.env.UNI_PLATFORM) {
|
||||
process.env.UNI_PLATFORM = 'h5';
|
||||
}
|
||||
if (!process.env.UNI_CLI_CONTEXT) {
|
||||
process.env.UNI_CLI_CONTEXT = process.cwd();
|
||||
}
|
||||
if (!process.env.UNI_INPUT_DIR) {
|
||||
process.env.UNI_INPUT_DIR = path_1.default.resolve(config.root, 'src');
|
||||
}
|
||||
if (!process.env.UNI_OUTPUT_DIR) {
|
||||
process.env.UNI_OUTPUT_DIR = path_1.default.resolve(config.root, config.build.outDir);
|
||||
}
|
||||
process.env.VUE_APP_DARK_MODE =
|
||||
(0, uni_cli_shared_1.getPlatformManifestJsonOnce)().darkmode || false;
|
||||
process.env.BROWSERSLIST_CONFIG = [
|
||||
path_1.default.resolve(process.env.UNI_INPUT_DIR, '.browserslistrc'),
|
||||
path_1.default.resolve(process.env.UNI_CLI_CONTEXT, 'package.json'),
|
||||
path_1.default.resolve(process.cwd(), 'package.json'),
|
||||
].find((file) => fs_1.default.existsSync(file));
|
||||
}
|
||||
exports.initEnv = initEnv;
|
||||
6
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/index.d.ts
generated
vendored
Normal file
6
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Plugin, ResolvedConfig } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createConfigResolved(options: VitePluginUniResolvedOptions): Plugin['configResolved'];
|
||||
export declare function initLogger({ logger, nvue, }: ResolvedConfig & {
|
||||
nvue?: boolean;
|
||||
}): void;
|
||||
61
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/index.js
generated
vendored
Normal file
61
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initLogger = exports.createConfigResolved = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const env_1 = require("./env");
|
||||
const options_1 = require("./options");
|
||||
const plugins_1 = require("./plugins");
|
||||
const resolve_1 = require("../config/resolve");
|
||||
function createConfigResolved(options) {
|
||||
return (config) => {
|
||||
// 如果是混合编译且是 nvue 时,部分逻辑无需执行
|
||||
if (!(0, uni_cli_shared_1.isInHybridNVue)(config)) {
|
||||
(0, env_1.initEnv)(config);
|
||||
}
|
||||
initLogger(config);
|
||||
(0, options_1.initOptions)(options, config);
|
||||
(0, plugins_1.initPlugins)(config, options);
|
||||
if (!(0, uni_cli_shared_1.isInHybridNVue)(config)) {
|
||||
initCheckUpdate();
|
||||
}
|
||||
if (uni_cli_shared_1.isWindows) {
|
||||
// TODO 等 https://github.com/vitejs/vite/issues/3331 修复后,可以移除下列代码
|
||||
// 2.8.0 已修复,但为了兼容旧版本,先不移除
|
||||
const item = config.resolve.alias.find((item) => !(0, shared_1.isString)(item.find) ? item.find.test('@/') : false);
|
||||
if (item) {
|
||||
item.customResolver = resolve_1.customResolver;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.createConfigResolved = createConfigResolved;
|
||||
function initCheckUpdate() {
|
||||
(0, uni_cli_shared_1.checkUpdate)({
|
||||
inputDir: process.env.UNI_INPUT_DIR,
|
||||
compilerVersion: process.env.UNI_COMPILER_VERSION,
|
||||
versionType: process.env.UNI_COMPILER_VERSION_TYPE,
|
||||
});
|
||||
}
|
||||
function initLogger({ logger, nvue, }) {
|
||||
const { info, warn, error } = logger;
|
||||
logger.info = (msg, opts) => {
|
||||
msg = (0, uni_cli_shared_1.formatInfoMsg)(msg, (0, shared_1.extend)(opts || {}, { nvue }));
|
||||
if (msg) {
|
||||
return info(msg, opts);
|
||||
}
|
||||
};
|
||||
logger.warn = (msg, opts) => {
|
||||
msg = (0, uni_cli_shared_1.formatWarnMsg)(msg, opts);
|
||||
if (msg) {
|
||||
return warn(msg, opts);
|
||||
}
|
||||
};
|
||||
logger.error = (msg, opts) => {
|
||||
msg = (0, uni_cli_shared_1.formatErrMsg)(msg, opts);
|
||||
if (msg) {
|
||||
return error(msg, opts);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.initLogger = initLogger;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/options.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
import { ResolvedConfig } from 'vite';
|
||||
export declare function initOptions(options: VitePluginUniResolvedOptions, config: ResolvedConfig): void;
|
||||
19
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/options.js
generated
vendored
Normal file
19
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/options.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initOptions = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const jsonc_parser_1 = require("jsonc-parser");
|
||||
function resolveBase() {
|
||||
const manifest = (0, jsonc_parser_1.parse)(fs_1.default.readFileSync(path_1.default.join(process.env.UNI_INPUT_DIR, 'manifest.json'), 'utf8'));
|
||||
return (manifest.h5 && manifest.h5.router && manifest.h5.router.base) || '/';
|
||||
}
|
||||
function initOptions(options, config) {
|
||||
options.base = resolveBase();
|
||||
options.outputDir = process.env.UNI_OUTPUT_DIR;
|
||||
options.assetsDir = config.build.assetsDir;
|
||||
}
|
||||
exports.initOptions = initOptions;
|
||||
8
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/index.d.ts
generated
vendored
Normal file
8
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ResolvedConfig } from 'vite';
|
||||
import { FilterPattern } from '@rollup/pluginutils';
|
||||
import { VitePluginUniResolvedOptions } from '../..';
|
||||
export interface UniPluginFilterOptions extends VitePluginUniResolvedOptions {
|
||||
include?: FilterPattern;
|
||||
exclude?: FilterPattern;
|
||||
}
|
||||
export declare function initPlugins(config: ResolvedConfig, options: VitePluginUniResolvedOptions): void;
|
||||
54
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/index.js
generated
vendored
Normal file
54
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/index.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initPlugins = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const pre_1 = require("./pre");
|
||||
const json_1 = require("./json");
|
||||
const preCss_1 = require("./preCss");
|
||||
const static_1 = require("./static");
|
||||
const preVue_1 = require("./preVue");
|
||||
const ssr_1 = require("./ssr");
|
||||
const resolveId_1 = require("./resolveId");
|
||||
const debugPlugin = (0, debug_1.default)('uni:plugin');
|
||||
const UNI_H5_RE = /@dcloudio\/uni-h5/;
|
||||
const uniPrePluginOptions = {
|
||||
exclude: [...uni_cli_shared_1.COMMON_EXCLUDE, UNI_H5_RE],
|
||||
};
|
||||
const uniPreCssPluginOptions = {
|
||||
exclude: [...uni_cli_shared_1.COMMON_EXCLUDE, UNI_H5_RE],
|
||||
};
|
||||
function initPlugins(config, options) {
|
||||
const plugins = config.plugins;
|
||||
addPlugin(plugins, (0, resolveId_1.uniResolveIdPlugin)(options), 'vite:resolve', 'pre');
|
||||
addPlugin(plugins, (0, pre_1.uniPrePlugin)(config, (0, shared_1.extend)(uniPrePluginOptions, options)), 0, 'pre');
|
||||
addPlugin(plugins, (0, preCss_1.uniPreCssPlugin)(config, (0, shared_1.extend)(uniPreCssPluginOptions, options)), 'vite:css');
|
||||
addPlugin(plugins, (0, preVue_1.uniPreVuePlugin)(), 'vite:vue', 'pre');
|
||||
addPlugin(plugins, (0, ssr_1.uniSSRPlugin)(config, (0, shared_1.extend)({ exclude: [...uni_cli_shared_1.COMMON_EXCLUDE] }, options)), 'vite:vue');
|
||||
addPlugin(plugins, (0, json_1.uniJsonPlugin)(options), 'vite:json', 'pre');
|
||||
addPlugin(plugins, (0, static_1.uniStaticPlugin)(options, config), 'vite:asset', 'pre');
|
||||
if ((0, uni_cli_shared_1.isInHBuilderX)()) {
|
||||
try {
|
||||
require(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers/lib/bytenode'));
|
||||
const { V } = require(path_1.default.join(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'));
|
||||
addPlugin(plugins, V({ dir: process.env.UNI_INPUT_DIR }), 0, 'pre');
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
if (process.env.DEBUG) {
|
||||
debugPlugin(plugins.length);
|
||||
debugPlugin(plugins.map((p) => p.name));
|
||||
}
|
||||
}
|
||||
exports.initPlugins = initPlugins;
|
||||
function addPlugin(plugins, plugin, index, type = 'post') {
|
||||
if ((0, shared_1.isString)(index)) {
|
||||
index = plugins.findIndex((plugin) => plugin.name === index);
|
||||
}
|
||||
return plugins.splice(index + (type === 'pre' ? 0 : 1), 0, plugin);
|
||||
}
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/json.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/json.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Plugin } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '../..';
|
||||
export declare function uniJsonPlugin(options: VitePluginUniResolvedOptions): Plugin;
|
||||
33
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/json.js
generated
vendored
Normal file
33
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/json.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniJsonPlugin = void 0;
|
||||
const jsonc_parser_1 = require("jsonc-parser");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const jsonExtRE = /\.json($|\?)(?!commonjs-proxy)/;
|
||||
const SPECIAL_QUERY_RE = /[\?&](?:worker|sharedworker|raw|url)\b/;
|
||||
function uniJsonPlugin(options) {
|
||||
return {
|
||||
name: 'uni:json',
|
||||
transform(code, id) {
|
||||
if (!jsonExtRE.test(id))
|
||||
return null;
|
||||
if (SPECIAL_QUERY_RE.test(id))
|
||||
return null;
|
||||
if (id.endsWith('.json.js'))
|
||||
return null;
|
||||
// preprocess
|
||||
if (code.includes('#endif')) {
|
||||
code = (0, uni_cli_shared_1.preJs)(code);
|
||||
}
|
||||
let jsonObj = (0, jsonc_parser_1.parse)(code);
|
||||
if ((0, uni_cli_shared_1.isUniAppLocaleFile)(id)) {
|
||||
jsonObj = jsonObj.common || {};
|
||||
}
|
||||
return {
|
||||
code: JSON.stringify(jsonObj),
|
||||
map: null,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniJsonPlugin = uniJsonPlugin;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/pre.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/pre.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Plugin, ResolvedConfig } from 'vite';
|
||||
import { UniPluginFilterOptions } from '.';
|
||||
export declare function uniPrePlugin(config: ResolvedConfig, options: UniPluginFilterOptions): Plugin;
|
||||
54
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/pre.js
generated
vendored
Normal file
54
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/pre.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniPrePlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugPreJs = (0, debug_1.default)('uni:pre-js');
|
||||
const debugPreHtml = (0, debug_1.default)('uni:pre-html');
|
||||
const debugPreJsTry = (0, debug_1.default)('uni:pre-js-try');
|
||||
const PRE_JS_EXTNAME = ['.json', '.css'].concat(uni_cli_shared_1.EXTNAME_VUE).concat(uni_cli_shared_1.EXTNAME_JS);
|
||||
const PRE_HTML_EXTNAME = uni_cli_shared_1.EXTNAME_VUE;
|
||||
function uniPrePlugin(config, options) {
|
||||
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
||||
const isNVue = config.nvue;
|
||||
const preJsFile = isNVue ? uni_cli_shared_1.preNVueJs : uni_cli_shared_1.preJs;
|
||||
const preHtmlFile = isNVue ? uni_cli_shared_1.preNVueHtml : uni_cli_shared_1.preHtml;
|
||||
return {
|
||||
name: 'uni:pre',
|
||||
transform(code, id) {
|
||||
if (!filter(id)) {
|
||||
return;
|
||||
}
|
||||
const { filename, query } = (0, uni_cli_shared_1.parseVueRequest)(id);
|
||||
const extname = path_1.default.extname(filename);
|
||||
const isHtml = query.type === 'template' || PRE_HTML_EXTNAME.includes(extname);
|
||||
const isJs = PRE_JS_EXTNAME.includes(extname);
|
||||
const isPre = isHtml || isJs;
|
||||
if (isPre) {
|
||||
debugPreJsTry(id);
|
||||
}
|
||||
const hasEndif = isPre && code.includes('#endif');
|
||||
if (!hasEndif) {
|
||||
return;
|
||||
}
|
||||
if (isHtml) {
|
||||
code = preHtmlFile(code);
|
||||
debugPreHtml(id);
|
||||
}
|
||||
if (isJs) {
|
||||
code = preJsFile(code);
|
||||
debugPreJs(id);
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: (0, uni_cli_shared_1.withSourcemap)(config) ? this.getCombinedSourcemap() : null,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniPrePlugin = uniPrePlugin;
|
||||
7
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preCss.d.ts
generated
vendored
Normal file
7
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preCss.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Plugin, ResolvedConfig } from 'vite';
|
||||
import { UniPluginFilterOptions } from '.';
|
||||
/**
|
||||
* preprocess css
|
||||
* @param options
|
||||
*/
|
||||
export declare function uniPreCssPlugin(config: ResolvedConfig, options: UniPluginFilterOptions): Plugin;
|
||||
43
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preCss.js
generated
vendored
Normal file
43
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preCss.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniPreCssPlugin = void 0;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugPre = (0, debug_1.default)('uni:pre-css');
|
||||
const debugPreTry = (0, debug_1.default)('uni:pre-css-try');
|
||||
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|postcss)($|\\?)`;
|
||||
const cssLangRE = new RegExp(cssLangs);
|
||||
/**
|
||||
* preprocess css
|
||||
* @param options
|
||||
*/
|
||||
function uniPreCssPlugin(config, options) {
|
||||
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
||||
const isNVue = config.nvue;
|
||||
const preJsFile = isNVue ? uni_cli_shared_1.preNVueJs : uni_cli_shared_1.preJs;
|
||||
return {
|
||||
name: 'uni:pre-css',
|
||||
transform(code, id) {
|
||||
if (!cssLangRE.test(id)) {
|
||||
return;
|
||||
}
|
||||
if (!filter(id)) {
|
||||
return;
|
||||
}
|
||||
debugPreTry(id);
|
||||
if (!code.includes('#endif')) {
|
||||
return;
|
||||
}
|
||||
debugPre(id);
|
||||
return {
|
||||
code: preJsFile(code),
|
||||
map: (0, uni_cli_shared_1.withSourcemap)(config) ? this.getCombinedSourcemap() : null,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniPreCssPlugin = uniPreCssPlugin;
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preVue.d.ts
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preVue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Plugin } from 'vite';
|
||||
export declare function uniPreVuePlugin(): Plugin;
|
||||
33
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preVue.js
generated
vendored
Normal file
33
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/preVue.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniPreVuePlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function uniPreVuePlugin() {
|
||||
let isNVue = false;
|
||||
return {
|
||||
name: 'uni:pre-vue',
|
||||
config(config) {
|
||||
isNVue = config.nvue;
|
||||
},
|
||||
async transform(code, id) {
|
||||
const { filename, query } = (0, uni_cli_shared_1.parseVueRequest)(id);
|
||||
if (query.vue) {
|
||||
return;
|
||||
}
|
||||
if (!uni_cli_shared_1.EXTNAME_VUE.includes(path_1.default.extname(filename))) {
|
||||
return;
|
||||
}
|
||||
// 清空当前页面已缓存的 filter 信息
|
||||
(0, uni_cli_shared_1.clearMiniProgramTemplateFilter)((0, uni_cli_shared_1.removeExt)((0, uni_cli_shared_1.normalizeMiniProgramFilename)(id, process.env.UNI_INPUT_DIR)));
|
||||
return {
|
||||
code: (0, uni_cli_shared_1.parseVueCode)(code, isNVue).code,
|
||||
map: null,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniPreVuePlugin = uniPreVuePlugin;
|
||||
17
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/resolveId.d.ts
generated
vendored
Normal file
17
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/resolveId.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Plugin } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '../..';
|
||||
declare const BUILT_IN_MODULES: {
|
||||
'vue-router': string;
|
||||
vuex: string;
|
||||
'vue-i18n': string;
|
||||
'@dcloudio/uni-app': string;
|
||||
'@dcloudio/uni-cloud': string;
|
||||
'@dcloudio/uni-i18n': string;
|
||||
'@dcloudio/uni-shared': string;
|
||||
'@dcloudio/uni-stacktracey': string;
|
||||
'@vue/shared': string;
|
||||
pinia: string;
|
||||
};
|
||||
export type BuiltInModulesKey = keyof typeof BUILT_IN_MODULES;
|
||||
export declare function uniResolveIdPlugin(options: VitePluginUniResolvedOptions): Plugin;
|
||||
export {};
|
||||
42
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/resolveId.js
generated
vendored
Normal file
42
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/resolveId.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniResolveIdPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugResolve = (0, debug_1.default)('uni:resolve-id');
|
||||
const BUILT_IN_MODULES = {
|
||||
'vue-router': 'dist/vue-router.esm-bundler.js',
|
||||
vuex: 'dist/vuex.esm-bundler.js',
|
||||
'vue-i18n': 'dist/vue-i18n.esm-bundler.js',
|
||||
'@dcloudio/uni-app': 'dist/uni-app.es.js',
|
||||
'@dcloudio/uni-cloud': 'dist/uni-cloud.es.js',
|
||||
'@dcloudio/uni-i18n': 'dist/uni-i18n.es.js',
|
||||
'@dcloudio/uni-shared': 'dist/uni-shared.es.js',
|
||||
'@dcloudio/uni-stacktracey': 'dist/uni-stacktracey.es.js',
|
||||
'@vue/shared': 'dist/shared.esm-bundler.js',
|
||||
pinia: 'dist/pinia.mjs',
|
||||
};
|
||||
function uniResolveIdPlugin(options) {
|
||||
const resolveCache = {};
|
||||
return {
|
||||
name: 'uni:resolve-id',
|
||||
resolveId(id, importer) {
|
||||
const cache = resolveCache[id];
|
||||
if (cache) {
|
||||
debugResolve('cache', id, cache);
|
||||
return cache;
|
||||
}
|
||||
if (BUILT_IN_MODULES[id]) {
|
||||
return (resolveCache[id] = (0, uni_cli_shared_1.resolveBuiltIn)(path_1.default.join(id, BUILT_IN_MODULES[id])));
|
||||
}
|
||||
if (process.env.UNI_PLATFORM !== 'app') {
|
||||
return (0, uni_cli_shared_1.resolveUTSModule)(id, importer ? path_1.default.dirname(importer) : process.env.UNI_INPUT_DIR);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniResolveIdPlugin = uniResolveIdPlugin;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/ssr.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/ssr.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Plugin, ResolvedConfig } from 'vite';
|
||||
import { UniPluginFilterOptions } from '.';
|
||||
export declare function uniSSRPlugin(config: ResolvedConfig, options: UniPluginFilterOptions): Plugin;
|
||||
63
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/ssr.js
generated
vendored
Normal file
63
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/ssr.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniSSRPlugin = void 0;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
const estree_walker_1 = require("estree-walker");
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugSSR = (0, debug_1.default)('uni:ssr');
|
||||
const KEYED_FUNC_RE = /(ssrRef|shallowSsrRef)/;
|
||||
function uniSSRPlugin(config, options) {
|
||||
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
||||
return {
|
||||
name: 'uni:ssr',
|
||||
transform(code, id) {
|
||||
if (!filter(id))
|
||||
return null;
|
||||
if (!KEYED_FUNC_RE.test(code)) {
|
||||
return;
|
||||
}
|
||||
debugSSR('try', id);
|
||||
const ast = this.parse(code);
|
||||
const s = new magic_string_1.default(code);
|
||||
(0, estree_walker_1.walk)(ast, {
|
||||
enter(node) {
|
||||
if (!(0, uni_cli_shared_1.isCallExpression)(node)) {
|
||||
return;
|
||||
}
|
||||
const { callee, arguments: args } = node;
|
||||
if (args.length !== 1) {
|
||||
return;
|
||||
}
|
||||
const name = (0, uni_cli_shared_1.isIdentifier)(callee)
|
||||
? callee.name
|
||||
: (0, uni_cli_shared_1.isMemberExpression)(callee) && (0, uni_cli_shared_1.isIdentifier)(callee.property)
|
||||
? callee.property.name
|
||||
: '';
|
||||
if (name !== 'ssrRef' && name !== 'shallowSsrRef') {
|
||||
return;
|
||||
}
|
||||
const { end } = node;
|
||||
const key = id + '-' + node.end;
|
||||
debugSSR(key, name);
|
||||
s.appendLeft(end - 1, ", '" + createKey(`${id}-${end}`) + "'");
|
||||
},
|
||||
});
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: (0, uni_cli_shared_1.withSourcemap)(config) ? s.generateMap().toString() : null,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniSSRPlugin = uniSSRPlugin;
|
||||
function createKey(source) {
|
||||
const hash = crypto_1.default.createHash('md5');
|
||||
hash.update(source);
|
||||
return hash.digest('base64').toString();
|
||||
}
|
||||
9
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/static.d.ts
generated
vendored
Normal file
9
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/static.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Plugin, ResolvedConfig } from 'vite';
|
||||
import { UniPluginFilterOptions } from '.';
|
||||
/**
|
||||
* 提供static等目录静态资源加载
|
||||
* @param _options
|
||||
* @param config
|
||||
* @returns
|
||||
*/
|
||||
export declare function uniStaticPlugin(_options: UniPluginFilterOptions, config: ResolvedConfig): Plugin;
|
||||
44
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/static.js
generated
vendored
Normal file
44
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/configResolved/plugins/static.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniStaticPlugin = void 0;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("../../utils");
|
||||
const debugStatic = (0, debug_1.default)('uni:static');
|
||||
/**
|
||||
* 提供static等目录静态资源加载
|
||||
* @param _options
|
||||
* @param config
|
||||
* @returns
|
||||
*/
|
||||
function uniStaticPlugin(_options, config) {
|
||||
const filter = (0, utils_1.createPublicFileFilter)();
|
||||
return {
|
||||
name: 'uni:static',
|
||||
resolveId(id) {
|
||||
if (!config.assetsInclude((0, uni_cli_shared_1.cleanUrl)(id))) {
|
||||
return;
|
||||
}
|
||||
const publicFile = filter(id);
|
||||
if (publicFile) {
|
||||
debugStatic(id);
|
||||
return id;
|
||||
}
|
||||
},
|
||||
async load(id) {
|
||||
if (!config.assetsInclude((0, uni_cli_shared_1.cleanUrl)(id))) {
|
||||
return;
|
||||
}
|
||||
if (filter(id)) {
|
||||
return `export default ${JSON.stringify(fileToUrl(id, config))}`;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniStaticPlugin = uniStaticPlugin;
|
||||
function fileToUrl(id, config) {
|
||||
return config.base + id.slice(1);
|
||||
}
|
||||
26
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/index.d.ts
generated
vendored
Normal file
26
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite';
|
||||
import type { Options as VueOptions } from '@vitejs/plugin-vue';
|
||||
import type ViteLegacyPlugin from '@vitejs/plugin-legacy';
|
||||
import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx';
|
||||
import { CopyOptions } from '@dcloudio/uni-cli-shared';
|
||||
export type ViteLegacyOptions = Parameters<typeof ViteLegacyPlugin>[0];
|
||||
export interface VitePluginUniOptions {
|
||||
uvue?: boolean;
|
||||
vueOptions?: VueOptions;
|
||||
vueJsxOptions?: (VueJSXPluginOptions & {
|
||||
babelPlugins?: any[];
|
||||
}) | boolean;
|
||||
viteLegacyOptions?: ViteLegacyOptions | false;
|
||||
}
|
||||
export interface VitePluginUniResolvedOptions extends VitePluginUniOptions {
|
||||
base: string;
|
||||
command: ResolvedConfig['command'];
|
||||
platform: UniApp.PLATFORM;
|
||||
inputDir: string;
|
||||
outputDir: string;
|
||||
assetsDir: string;
|
||||
devServer?: ViteDevServer;
|
||||
copyOptions?: Required<CopyOptions>;
|
||||
}
|
||||
export { runDev, runBuild } from './cli/action';
|
||||
export default function uniPlugin(rawOptions?: VitePluginUniOptions): Plugin[];
|
||||
149
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/index.js
generated
vendored
Normal file
149
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runBuild = exports.runDev = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
|
||||
const plugin_legacy_1 = __importDefault(require("@vitejs/plugin-legacy"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const config_1 = require("./config");
|
||||
const configResolved_1 = require("./configResolved");
|
||||
const copy_1 = require("./plugins/copy");
|
||||
const move_1 = require("./plugins/move");
|
||||
const utils_1 = require("./utils");
|
||||
const vue_1 = require("./vue");
|
||||
const utils_2 = require("./cli/utils");
|
||||
const plugins_1 = require("./uvue/plugins");
|
||||
const debugUni = (0, debug_1.default)('uni:plugin');
|
||||
const pkg = require(path_1.default.resolve(__dirname, '../package.json'));
|
||||
(0, uni_cli_shared_1.initModuleAlias)();
|
||||
process.env.UNI_COMPILER_VERSION =
|
||||
process.env.UNI_COMPILER_VERSION || pkg['uni-app']?.['compilerVersion'] || '';
|
||||
process.env.UNI_COMPILER_VERSION_TYPE = pkg.version.includes('alpha')
|
||||
? 'a'
|
||||
: 'r';
|
||||
var action_1 = require("./cli/action");
|
||||
Object.defineProperty(exports, "runDev", { enumerable: true, get: function () { return action_1.runDev; } });
|
||||
Object.defineProperty(exports, "runBuild", { enumerable: true, get: function () { return action_1.runBuild; } });
|
||||
let isFirst = true;
|
||||
function uniPlugin(rawOptions = {}) {
|
||||
// 三方插件(如vitest)可能提供了自己的入口命令,需要补充 env 初始化逻辑
|
||||
(0, utils_2.initEnv)('unknown', { platform: process.env.UNI_PLATFORM || 'h5' });
|
||||
const options = {
|
||||
...rawOptions,
|
||||
base: '/',
|
||||
assetsDir: 'assets',
|
||||
inputDir: '',
|
||||
outputDir: '',
|
||||
command: 'serve',
|
||||
platform: 'h5',
|
||||
};
|
||||
options.platform = process.env.UNI_PLATFORM || 'h5';
|
||||
options.inputDir = process.env.UNI_INPUT_DIR;
|
||||
(0, uni_cli_shared_1.initPreContext)(options.platform, process.env.UNI_CUSTOM_CONTEXT, process.env.UNI_UTS_PLATFORM, process.env.UNI_APP_X === 'true');
|
||||
return process.env.UNI_APP_X === 'true' && process.env.UNI_PLATFORM === 'app'
|
||||
? createUVuePlugins(options)
|
||||
: createPlugins(options);
|
||||
}
|
||||
exports.default = uniPlugin;
|
||||
function createPlugins(options) {
|
||||
const plugins = [];
|
||||
const injects = (0, uni_cli_shared_1.parseUniExtApis)(true, process.env.UNI_UTS_PLATFORM, 'javascript');
|
||||
if (Object.keys(injects).length) {
|
||||
plugins.push((0, uni_cli_shared_1.uniViteInjectPlugin)('uni:ext-api-inject', injects));
|
||||
}
|
||||
// 仅限 h5
|
||||
if (options.viteLegacyOptions && options.platform === 'h5') {
|
||||
plugins.push(...(0, plugin_legacy_1.default)((0, vue_1.initPluginViteLegacyOptions)(options)));
|
||||
}
|
||||
const uniPlugins = (0, utils_1.initExtraPlugins)(process.env.UNI_CLI_CONTEXT || process.cwd(), process.env.UNI_PLATFORM || 'h5', options);
|
||||
debugUni(uniPlugins);
|
||||
const uniPluginOptions = (0, utils_1.initPluginUniOptions)(uniPlugins);
|
||||
options.copyOptions = uniPluginOptions.copyOptions;
|
||||
if (options.vueJsxOptions) {
|
||||
plugins.push((0, plugin_vue_jsx_1.default)((0, vue_1.initPluginVueJsxOptions)(options, uniPluginOptions.compilerOptions, uniPluginOptions.jsxOptions)));
|
||||
}
|
||||
plugins.push({
|
||||
name: 'uni',
|
||||
config: (0, config_1.createConfig)(options, uniPlugins),
|
||||
// resolveId: createResolveId(options),
|
||||
configResolved: (0, configResolved_1.createConfigResolved)(options),
|
||||
});
|
||||
plugins.push(...uniPlugins);
|
||||
plugins.push(...(0, utils_1.initFixedEsbuildInitTSConfck)(process.env.UNI_INPUT_DIR));
|
||||
// 执行 build 命令时,vite 强制了 NODE_ENV
|
||||
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/build.ts#L405
|
||||
// const config = await resolveConfig(inlineConfig, 'build', 'production')
|
||||
// 在 @vitejs/plugin-vue 之前校正回来
|
||||
if (process.env.UNI_NODE_ENV &&
|
||||
process.env.UNI_NODE_ENV !== process.env.NODE_ENV) {
|
||||
process.env.NODE_ENV = process.env.UNI_NODE_ENV;
|
||||
}
|
||||
plugins.unshift((0, vue_1.createPluginVueInstance)((0, vue_1.initPluginVueOptions)(options, uniPlugins, uniPluginOptions)));
|
||||
let addCopyPlugin = false;
|
||||
if (options.platform !== 'app') {
|
||||
addCopyPlugin = true;
|
||||
}
|
||||
else {
|
||||
// 仅在 vue 或 纯原生 App.vue 编译时做 copy
|
||||
if (process.env.UNI_COMPILER === 'vue' ||
|
||||
(process.env.UNI_RENDERER === 'native' &&
|
||||
process.env.UNI_RENDERER_NATIVE === 'appService')) {
|
||||
addCopyPlugin = true;
|
||||
}
|
||||
}
|
||||
if (addCopyPlugin) {
|
||||
plugins.push((0, copy_1.uniCopyPlugin)({
|
||||
outputDir: process.env.UNI_OUTPUT_DIR,
|
||||
copyOptions: options.copyOptions,
|
||||
}));
|
||||
}
|
||||
if (process.env.SOURCEMAP === 'true') {
|
||||
// 清空之前的 sourcemap 目录
|
||||
const sourceMapPath = (0, uni_cli_shared_1.resolveSourceMapPath)();
|
||||
if (isFirst) {
|
||||
// 避免重复清空
|
||||
isFirst = false;
|
||||
if (fs_1.default.existsSync(sourceMapPath)) {
|
||||
(0, uni_cli_shared_1.emptyDir)(sourceMapPath);
|
||||
}
|
||||
}
|
||||
plugins.push((0, move_1.uniMovePlugin)({
|
||||
apply: 'build',
|
||||
enforce: 'post',
|
||||
cwd: process.env.UNI_OUTPUT_DIR,
|
||||
pattern: '**/*.js.map',
|
||||
dest: sourceMapPath,
|
||||
}));
|
||||
}
|
||||
(0, utils_1.rewriteCompilerSfcParse)();
|
||||
return plugins;
|
||||
}
|
||||
function createUVuePlugins(options) {
|
||||
const plugins = [];
|
||||
options.uvue = true;
|
||||
const uniPlugins = (0, utils_1.initExtraPlugins)(process.env.UNI_CLI_CONTEXT || process.cwd(), process.env.UNI_PLATFORM || 'h5', options);
|
||||
debugUni(uniPlugins);
|
||||
const uniPluginOptions = (0, utils_1.initPluginUniOptions)(uniPlugins);
|
||||
options.copyOptions = uniPluginOptions.copyOptions;
|
||||
plugins.push((0, plugins_1.uniUVuePlugin)(options));
|
||||
plugins.push(...uniPlugins);
|
||||
plugins.push(...(0, utils_1.initFixedEsbuildInitTSConfck)(process.env.UNI_INPUT_DIR));
|
||||
// 执行 build 命令时,vite 强制了 NODE_ENV
|
||||
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/build.ts#L405
|
||||
// const config = await resolveConfig(inlineConfig, 'build', 'production')
|
||||
// 在 @vitejs/plugin-vue 之前校正回来
|
||||
if (process.env.UNI_NODE_ENV &&
|
||||
process.env.UNI_NODE_ENV !== process.env.NODE_ENV) {
|
||||
process.env.NODE_ENV = process.env.UNI_NODE_ENV;
|
||||
}
|
||||
plugins.push((0, copy_1.uniCopyPlugin)({
|
||||
outputDir: process.env.UNI_OUTPUT_DIR,
|
||||
copyOptions: options.copyOptions,
|
||||
}));
|
||||
return plugins;
|
||||
}
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/copy.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/copy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function uniCopyPlugin({ outputDir, copyOptions, }: Pick<VitePluginUniResolvedOptions, 'outputDir' | 'copyOptions'>): Plugin;
|
||||
59
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/copy.js
generated
vendored
Normal file
59
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/copy.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniCopyPlugin = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugCopy = (0, debug_1.default)('uni:copy');
|
||||
function uniCopyPlugin({ outputDir, copyOptions, }) {
|
||||
const staticDir = uni_cli_shared_1.PUBLIC_DIR + '/**/*';
|
||||
const uniModulesStaticDir = 'uni_modules/*/' + uni_cli_shared_1.PUBLIC_DIR + '/**/*';
|
||||
const assets = [staticDir, uniModulesStaticDir];
|
||||
const subpackages = (0, uni_cli_shared_1.parseSubpackagesRootOnce)(process.env.UNI_INPUT_DIR, process.env.UNI_PLATFORM);
|
||||
subpackages.forEach((root) => {
|
||||
assets.push((0, uni_cli_shared_1.normalizePath)(path_1.default.join(root, staticDir)));
|
||||
assets.push((0, uni_cli_shared_1.normalizePath)(path_1.default.join(root, uniModulesStaticDir)));
|
||||
});
|
||||
copyOptions.assets.forEach((asset) => {
|
||||
assets.push(asset);
|
||||
});
|
||||
const platform = process.env.UNI_PLATFORM;
|
||||
// 非当前平台 static 目录
|
||||
const ignorePlatformStaticDirs = (0, uni_cli_shared_1.getPlatforms)()
|
||||
.filter((p) => {
|
||||
if (platform === 'app') {
|
||||
return p !== 'app' && p !== 'app-plus';
|
||||
}
|
||||
else if (platform === 'h5' || platform === 'web') {
|
||||
return p !== 'h5' && p !== 'web';
|
||||
}
|
||||
return p !== platform;
|
||||
})
|
||||
.map((p) => '/' + uni_cli_shared_1.PUBLIC_DIR + '/' + p);
|
||||
const targets = [
|
||||
{
|
||||
src: assets,
|
||||
dest: outputDir,
|
||||
watchOptions: {
|
||||
ignored(path) {
|
||||
const normalizedPath = (0, uni_cli_shared_1.normalizePath)(path);
|
||||
if (ignorePlatformStaticDirs.find((dir) => normalizedPath.includes(dir))) {
|
||||
return fs_1.default.statSync(normalizedPath).isDirectory();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
targets.push(...copyOptions.targets);
|
||||
debugCopy(targets);
|
||||
return (0, uni_cli_shared_1.uniViteCopyPlugin)({
|
||||
targets,
|
||||
verbose: process.env.DEBUG ? true : false,
|
||||
});
|
||||
}
|
||||
exports.uniCopyPlugin = uniCopyPlugin;
|
||||
19
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/move.d.ts
generated
vendored
Normal file
19
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/move.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { Plugin } from 'vite';
|
||||
interface UniMovePluginOptions {
|
||||
apply: Plugin['apply'];
|
||||
enforce: Plugin['enforce'];
|
||||
/**
|
||||
* 原始根目录
|
||||
*/
|
||||
cwd: string;
|
||||
/**
|
||||
* glob pattern 如:**\/*.js.mp)
|
||||
*/
|
||||
pattern: string;
|
||||
/**
|
||||
* 目标目录
|
||||
*/
|
||||
dest: string;
|
||||
}
|
||||
export declare function uniMovePlugin({ apply, enforce, cwd, pattern, dest, }: UniMovePluginOptions): Plugin;
|
||||
export {};
|
||||
28
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/move.js
generated
vendored
Normal file
28
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/plugins/move.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniMovePlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const fast_glob_1 = __importDefault(require("fast-glob"));
|
||||
function uniMovePlugin({ apply, enforce, cwd, pattern, dest, }) {
|
||||
return {
|
||||
name: 'uni:move',
|
||||
apply,
|
||||
enforce,
|
||||
async writeBundle() {
|
||||
await Promise.all(fast_glob_1.default
|
||||
.sync(pattern, {
|
||||
cwd,
|
||||
})
|
||||
.map((filename) => {
|
||||
return fs_extra_1.default.move(path_1.default.resolve(cwd, filename), path_1.default.resolve(dest, filename), {
|
||||
overwrite: true,
|
||||
});
|
||||
}));
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniMovePlugin = uniMovePlugin;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/resolveId/index.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/resolveId/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Plugin } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function createResolveId(options: VitePluginUniResolvedOptions): Plugin['resolveId'];
|
||||
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/resolveId/index.js
generated
vendored
Normal file
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/resolveId/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createResolveId = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function createResolveId(options) {
|
||||
const inputDir = (0, uni_cli_shared_1.normalizePath)(options.inputDir);
|
||||
return function (id) {
|
||||
if (id.startsWith('@/')) {
|
||||
return inputDir + id.slice(1);
|
||||
}
|
||||
else if (id.startsWith('~@/')) {
|
||||
return inputDir + id.slice(2);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.createResolveId = createResolveId;
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/easycom.d.ts
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/easycom.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { FSWatcher } from 'chokidar';
|
||||
export declare const initEasycom: (watcher?: FSWatcher) => void;
|
||||
38
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/easycom.js
generated
vendored
Normal file
38
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/easycom.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initEasycom = void 0;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
||||
const initEasycom = (watcher) => {
|
||||
const { filter, refresh, options } = (0, uni_cli_shared_1.initEasycomsOnce)(process.env.UNI_INPUT_DIR, {
|
||||
dirs: [(0, uni_cli_shared_1.resolveComponentsLibPath)()],
|
||||
platform: process.env.UNI_PLATFORM,
|
||||
isX: process.env.UNI_APP_X === 'true',
|
||||
});
|
||||
if (!watcher) {
|
||||
// build 模式,手动初始化 watcher
|
||||
debugEasycom('initWatch', options.dirs);
|
||||
watcher = uni_cli_shared_1.chokidar.watch(options.dirs, {
|
||||
ignored: ['**/node_modules/**', '**/.git/**'],
|
||||
ignoreInitial: true,
|
||||
ignorePermissionErrors: true,
|
||||
disableGlobbing: true,
|
||||
});
|
||||
}
|
||||
const refreshEasycom = (0, uni_shared_1.debounce)(refresh, 100, { setTimeout, clearTimeout });
|
||||
watcher.on('all', (eventName, path) => {
|
||||
if (!['add', 'unlink'].includes(eventName)) {
|
||||
return;
|
||||
}
|
||||
if (filter(path)) {
|
||||
debugEasycom('watch', eventName, path);
|
||||
refreshEasycom();
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.initEasycom = initEasycom;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/filter.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/filter.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function createPublicFileFilter(base?: string): (id: unknown) => boolean;
|
||||
15
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/filter.js
generated
vendored
Normal file
15
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/filter.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createPublicFileFilter = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function createPublicFileFilter(base = '/') {
|
||||
const publicDir = (0, uni_cli_shared_1.normalizePath)(path_1.default.join(base, uni_cli_shared_1.PUBLIC_DIR + '/**/*'));
|
||||
const uniModulesDir = (0, uni_cli_shared_1.normalizePath)(path_1.default.join(base, 'uni_modules/*/' + uni_cli_shared_1.PUBLIC_DIR + '/**/*'));
|
||||
return (0, pluginutils_1.createFilter)([publicDir, uniModulesDir]);
|
||||
}
|
||||
exports.createPublicFileFilter = createPublicFileFilter;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/index.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './filter';
|
||||
export * from './plugin';
|
||||
export * from './polyfill';
|
||||
export * from './nvue';
|
||||
20
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/index.js
generated
vendored
Normal file
20
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./filter"), exports);
|
||||
__exportStar(require("./plugin"), exports);
|
||||
__exportStar(require("./polyfill"), exports);
|
||||
__exportStar(require("./nvue"), exports);
|
||||
5
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/nvue.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/nvue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* nvue 需要移除 scoped
|
||||
* @param nvuePages
|
||||
*/
|
||||
export declare function createNVueCompiler(): any;
|
||||
25
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/nvue.js
generated
vendored
Normal file
25
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/nvue.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createNVueCompiler = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const shared_1 = require("@vue/shared");
|
||||
/**
|
||||
* nvue 需要移除 scoped
|
||||
* @param nvuePages
|
||||
*/
|
||||
function createNVueCompiler() {
|
||||
const compileSfc = require((0, uni_cli_shared_1.resolveBuiltIn)('@vue/compiler-sfc'));
|
||||
const { parse } = compileSfc;
|
||||
return (0, shared_1.extend)({}, compileSfc, {
|
||||
parse(source, options = {}) {
|
||||
const result = parse(source, options);
|
||||
result.descriptor.styles.forEach((style) => {
|
||||
if (style.scoped) {
|
||||
delete style.scoped;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.createNVueCompiler = createNVueCompiler;
|
||||
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/plugin.d.ts
generated
vendored
Normal file
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/plugin.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { UniViteCopyPluginTarget, UniVitePlugin } from '@dcloudio/uni-cli-shared';
|
||||
import type { TemplateCompiler } from '@vue/compiler-sfc';
|
||||
import { VitePluginUniResolvedOptions } from '..';
|
||||
export declare function initPluginUniOptions(UniVitePlugins: UniVitePlugin[]): {
|
||||
compiler?: TemplateCompiler;
|
||||
copyOptions: {
|
||||
assets: string[];
|
||||
targets: UniViteCopyPluginTarget[];
|
||||
};
|
||||
transformEvent: Record<string, string>;
|
||||
compilerOptions: Required<Required<UniVitePlugin>['uni']>['compilerOptions'];
|
||||
jsxOptions: Required<Required<UniVitePlugin>['uni']>['jsxOptions'];
|
||||
styleOptions: Required<Required<UniVitePlugin>['uni']>['styleOptions'];
|
||||
};
|
||||
export declare function initExtraPlugins(cliRoot: string, platform: UniApp.PLATFORM, options: VitePluginUniResolvedOptions): Plugin[];
|
||||
122
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/plugin.js
generated
vendored
Normal file
122
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/plugin.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initExtraPlugins = exports.initPluginUniOptions = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
function initPluginUniOptions(UniVitePlugins) {
|
||||
const assets = [];
|
||||
const targets = [];
|
||||
const transformEvent = Object.create(null);
|
||||
const compilerOptions = {};
|
||||
const jsxOptions = {};
|
||||
const styleOptions = {};
|
||||
let compiler;
|
||||
UniVitePlugins.forEach((plugin) => {
|
||||
const { compiler: pluginTemplateCompiler, copyOptions: pluginCopyOptions, compilerOptions: pluginCompilerOptions, jsxOptions: pluginJsxOptions, styleOptions: pluginStyleOpitons, } = plugin.uni || {};
|
||||
if (pluginTemplateCompiler) {
|
||||
compiler = pluginTemplateCompiler;
|
||||
}
|
||||
if (pluginCompilerOptions) {
|
||||
(0, shared_1.extend)(compilerOptions, pluginCompilerOptions);
|
||||
}
|
||||
if (pluginJsxOptions) {
|
||||
(0, shared_1.extend)(jsxOptions, pluginJsxOptions);
|
||||
}
|
||||
if (pluginStyleOpitons) {
|
||||
(0, shared_1.extend)(styleOptions, pluginStyleOpitons);
|
||||
}
|
||||
if (pluginCopyOptions) {
|
||||
let copyOptions = pluginCopyOptions;
|
||||
if ((0, shared_1.isFunction)(pluginCopyOptions)) {
|
||||
copyOptions = pluginCopyOptions();
|
||||
}
|
||||
if (copyOptions.assets) {
|
||||
assets.push(...copyOptions.assets);
|
||||
}
|
||||
if (copyOptions.targets) {
|
||||
targets.push(...copyOptions.targets);
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
compiler,
|
||||
copyOptions: {
|
||||
assets,
|
||||
targets,
|
||||
},
|
||||
transformEvent,
|
||||
compilerOptions,
|
||||
jsxOptions,
|
||||
styleOptions,
|
||||
};
|
||||
}
|
||||
exports.initPluginUniOptions = initPluginUniOptions;
|
||||
function initExtraPlugins(cliRoot, platform, options) {
|
||||
return initPlugins(cliRoot, resolvePlugins(cliRoot, platform, options.uvue), options);
|
||||
}
|
||||
exports.initExtraPlugins = initExtraPlugins;
|
||||
function initPlugin(cliRoot, { id, config: { main } }, options) {
|
||||
let plugin = require(require.resolve(path_1.default.join(id, main || '/lib/uni.plugin.js'), { paths: [cliRoot] }));
|
||||
plugin = plugin.default || plugin;
|
||||
if ((0, shared_1.isFunction)(plugin)) {
|
||||
plugin = plugin(options);
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
function initPlugins(cliRoot, plugins, options) {
|
||||
return plugins
|
||||
.map((plugin) => initPlugin(cliRoot, plugin, options))
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
.map((plugin) => {
|
||||
if ((0, shared_1.isFunction)(plugin)) {
|
||||
return plugin(options);
|
||||
}
|
||||
return plugin;
|
||||
})
|
||||
.flat();
|
||||
}
|
||||
function resolvePlugins(cliRoot, platform, uvue = false) {
|
||||
const pkg = require(path_1.default.join(cliRoot, 'package.json'));
|
||||
return Object.keys(pkg.devDependencies || {})
|
||||
.concat(Object.keys(pkg.dependencies || {}))
|
||||
.map((id) => {
|
||||
try {
|
||||
const pluginPkg = require(require.resolve(id + '/package.json', {
|
||||
paths: [cliRoot],
|
||||
}));
|
||||
const config = pluginPkg['uni-app'];
|
||||
if (!config || !config.name) {
|
||||
return;
|
||||
}
|
||||
const { apply } = config;
|
||||
if ((0, shared_1.isArray)(apply)) {
|
||||
// 注册所有平台
|
||||
apply.forEach((p) => (0, uni_cli_shared_1.registerPlatform)(p));
|
||||
if (!apply.includes(platform)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ((0, shared_1.isString)(apply)) {
|
||||
if (!new RegExp(apply).test(platform)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 插件必须支持 uvue
|
||||
if (uvue && !config.uvue) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
id,
|
||||
name: config.name,
|
||||
config,
|
||||
};
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
12
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/polyfill.d.ts
generated
vendored
Normal file
12
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/polyfill.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Plugin } from 'vite';
|
||||
/**
|
||||
* TODO 临时重写,解决 @vitejs/plugin-vue 的 Bug
|
||||
*/
|
||||
export declare function rewriteCompilerSfcParse(): void;
|
||||
/**
|
||||
* 解决 HBuilderX 项目未包含 package.json 时,initTSConfck 可能导致查找过慢,或递归目录时权限不足报错
|
||||
* 即:未包含 package.json 时,直接移除 initTSConfck 相关逻辑
|
||||
* @param inputDir
|
||||
* @returns
|
||||
*/
|
||||
export declare function initFixedEsbuildInitTSConfck(inputDir: string): Plugin[];
|
||||
71
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/polyfill.js
generated
vendored
Normal file
71
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/utils/polyfill.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initFixedEsbuildInitTSConfck = exports.rewriteCompilerSfcParse = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const shared_1 = require("@vue/shared");
|
||||
/**
|
||||
* TODO 临时重写,解决 @vitejs/plugin-vue 的 Bug
|
||||
*/
|
||||
function rewriteCompilerSfcParse() {
|
||||
// @ts-ignore
|
||||
const compilerSfc = require((0, uni_cli_shared_1.resolveBuiltIn)('@vue/compiler-sfc'));
|
||||
const { parse } = compilerSfc;
|
||||
let extname_vue = process.env.UNI_APP_X === 'true' ? uni_cli_shared_1.X_EXTNAME_VUE : uni_cli_shared_1.EXTNAME_VUE;
|
||||
compilerSfc.parse = (source, options) => {
|
||||
if (options?.filename) {
|
||||
const extname = path_1.default.extname(options.filename);
|
||||
// wxs、filter、renderjs
|
||||
if (extname && !extname_vue.includes(extname)) {
|
||||
const tag = extname.slice(1);
|
||||
source = `<${tag}>` + source + `</${tag}>`;
|
||||
}
|
||||
}
|
||||
return parse(source, options);
|
||||
};
|
||||
}
|
||||
exports.rewriteCompilerSfcParse = rewriteCompilerSfcParse;
|
||||
/**
|
||||
* 解决 HBuilderX 项目未包含 package.json 时,initTSConfck 可能导致查找过慢,或递归目录时权限不足报错
|
||||
* 即:未包含 package.json 时,直接移除 initTSConfck 相关逻辑
|
||||
* @param inputDir
|
||||
* @returns
|
||||
*/
|
||||
function initFixedEsbuildInitTSConfck(inputDir) {
|
||||
if (!(0, uni_cli_shared_1.isInHBuilderX)()) {
|
||||
return [];
|
||||
}
|
||||
if (fs_1.default.existsSync(path_1.default.resolve(inputDir, 'package.json'))) {
|
||||
return [];
|
||||
}
|
||||
// 'vite:esbuild', 'vite:esbuild-transpile' initTSConfck
|
||||
const existsSync = fs_1.default.existsSync;
|
||||
// 根目录 lerna.json 路径
|
||||
const lernaJsonPath = (0, uni_cli_shared_1.normalizePath)(path_1.default.resolve(inputDir, 'lerna.json'));
|
||||
return [
|
||||
{
|
||||
name: 'uni:fixed-HBuilderX-initTSConfck-before',
|
||||
enforce: 'pre',
|
||||
configResolved() {
|
||||
// 在 HBuilderX 项目中,缺少 package.json 时, 确保 searchForWorkspaceRoot 使用项目根目录, 否则 initTSConfck 会查找很费时,且可能访问目录权限报错
|
||||
// https://github.com/vitejs/vite/blob/43b7b78b1834a4c7128d8a5d987f66a4defcbd93/packages/vite/src/node/plugins/esbuild.ts#L407
|
||||
fs_1.default.existsSync = (p) => {
|
||||
if ((0, shared_1.isString)(p)) {
|
||||
// 访问根目录 lerna.json 时,直接返回 true
|
||||
// https://github.com/vitejs/vite/blob/43b7b78b1834a4c7128d8a5d987f66a4defcbd93/packages/vite/src/node/server/searchRoot.ts#L35
|
||||
if (p.endsWith('lerna.json') &&
|
||||
lernaJsonPath === (0, uni_cli_shared_1.normalizePath)(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return existsSync(p);
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
exports.initFixedEsbuildInitTSConfck = initFixedEsbuildInitTSConfck;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/uvue/plugins/index.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/uvue/plugins/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { VitePluginUniResolvedOptions } from '../..';
|
||||
export declare function uniUVuePlugin(options: VitePluginUniResolvedOptions): Plugin;
|
||||
42
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/uvue/plugins/index.js
generated
vendored
Normal file
42
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/uvue/plugins/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniUVuePlugin = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const define_1 = require("../../config/define");
|
||||
const resolve_1 = require("../../config/resolve");
|
||||
const css_1 = require("../../config/css");
|
||||
const configResolved_1 = require("../../configResolved");
|
||||
function uniUVuePlugin(options) {
|
||||
return {
|
||||
name: 'uni:uvue',
|
||||
config(config, env) {
|
||||
options.command = env.command;
|
||||
let base = config.base;
|
||||
if (!base) {
|
||||
const { h5 } = (0, uni_cli_shared_1.parseManifestJsonOnce)(options.inputDir);
|
||||
base = (h5 && h5.router && h5.router.base) || '';
|
||||
}
|
||||
if (!base) {
|
||||
base = '/';
|
||||
}
|
||||
options.base = base;
|
||||
return {
|
||||
base: process.env.UNI_H5_BASE || base,
|
||||
root: process.env.VITE_ROOT_DIR,
|
||||
// TODO 临时设置为__static__,屏蔽警告:https://github.com/vitejs/vite/blob/824d042535033a5c3d7006978c0d05c201cd1c25/packages/vite/src/node/server/middlewares/transform.ts#L125
|
||||
publicDir: config.publicDir || '__static__',
|
||||
define: (0, define_1.createDefine)(options),
|
||||
resolve: (0, resolve_1.createResolve)(options, config),
|
||||
logLevel: config.logLevel || 'warn',
|
||||
optimizeDeps: {
|
||||
disabled: true,
|
||||
},
|
||||
css: (0, css_1.createCss)(options, config),
|
||||
};
|
||||
},
|
||||
configResolved(config) {
|
||||
(0, configResolved_1.initLogger)(config);
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniUVuePlugin = uniUVuePlugin;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/index.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './options';
|
||||
17
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/index.js
generated
vendored
Normal file
17
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./options"), exports);
|
||||
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/options.d.ts
generated
vendored
Normal file
16
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { TemplateCompiler } from '@vue/compiler-sfc';
|
||||
import type { Options as VueOptions } from '@vitejs/plugin-vue';
|
||||
import { UniVitePlugin } from '@dcloudio/uni-cli-shared';
|
||||
import type { ViteLegacyOptions, VitePluginUniResolvedOptions } from '..';
|
||||
/**
|
||||
* 每次创建新的 plugin-vue 实例。因为该插件内部会 cache descriptor,而相同的vue文件在编译到vue页面和nvue页面时,不能共享缓存(条件编译,css scoped等均不同)
|
||||
* @returns
|
||||
*/
|
||||
export declare function createPluginVueInstance(options: VueOptions): any;
|
||||
export declare function initPluginVueOptions(options: VitePluginUniResolvedOptions, UniVitePlugins: UniVitePlugin[], uniPluginOptions: Required<Omit<Required<UniVitePlugin>['uni'], 'compiler'>> & {
|
||||
compiler?: TemplateCompiler;
|
||||
}): VueOptions;
|
||||
export declare function initPluginVueJsxOptions(options: VitePluginUniResolvedOptions, { isCustomElement, }: Required<Required<UniVitePlugin>['uni']>['compilerOptions'], jsxOptions: Required<Required<UniVitePlugin>['uni']>['jsxOptions']): import("@vue/babel-plugin-jsx").VueJSXPluginOptions & {
|
||||
babelPlugins?: any[] | undefined;
|
||||
};
|
||||
export declare function initPluginViteLegacyOptions(options: VitePluginUniResolvedOptions): ViteLegacyOptions;
|
||||
135
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/options.js
generated
vendored
Normal file
135
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/dist/vue/options.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initPluginViteLegacyOptions = exports.initPluginVueJsxOptions = exports.initPluginVueOptions = exports.createPluginVueInstance = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("../utils");
|
||||
const pluginVuePath = require.resolve('@vitejs/plugin-vue');
|
||||
const normalizedPluginVuePath = (0, uni_cli_shared_1.normalizePath)(pluginVuePath);
|
||||
/**
|
||||
* 每次创建新的 plugin-vue 实例。因为该插件内部会 cache descriptor,而相同的vue文件在编译到vue页面和nvue页面时,不能共享缓存(条件编译,css scoped等均不同)
|
||||
* @returns
|
||||
*/
|
||||
function createPluginVueInstance(options) {
|
||||
delete require.cache[pluginVuePath];
|
||||
delete require.cache[normalizedPluginVuePath];
|
||||
const vuePlugin = require('@vitejs/plugin-vue');
|
||||
return vuePlugin(options);
|
||||
}
|
||||
exports.createPluginVueInstance = createPluginVueInstance;
|
||||
function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
|
||||
const vueOptions = options.vueOptions || (options.vueOptions = {});
|
||||
// if (!hasOwn(vueOptions, 'reactivityTransform')) {
|
||||
// vueOptions.reactivityTransform = true
|
||||
// }
|
||||
if (!vueOptions.include) {
|
||||
vueOptions.include = [];
|
||||
}
|
||||
if (!(0, shared_1.isArray)(vueOptions.include)) {
|
||||
vueOptions.include = [vueOptions.include];
|
||||
}
|
||||
vueOptions.include.push(uni_cli_shared_1.EXTNAME_VUE_RE);
|
||||
const styleOptions = vueOptions.style || (vueOptions.style = {});
|
||||
if (!styleOptions.postcssPlugins) {
|
||||
styleOptions.postcssPlugins = [];
|
||||
}
|
||||
// 解析 scoped 中 deep 等特殊语法
|
||||
styleOptions.postcssPlugins.push((0, uni_cli_shared_1.uniPostcssScopedPlugin)());
|
||||
const templateOptions = vueOptions.template || (vueOptions.template = {});
|
||||
const compilerOptions = templateOptions.compilerOptions || (templateOptions.compilerOptions = {});
|
||||
const { compiler, styleOptions: { postcssPlugins }, compilerOptions: { miniProgram, isNativeTag, isCustomElement, nodeTransforms, directiveTransforms, }, } = uniPluginOptions;
|
||||
if (postcssPlugins) {
|
||||
styleOptions.postcssPlugins.push(...postcssPlugins);
|
||||
}
|
||||
if (compiler) {
|
||||
templateOptions.compiler = compiler;
|
||||
}
|
||||
if (miniProgram) {
|
||||
;
|
||||
compilerOptions.miniProgram = miniProgram;
|
||||
}
|
||||
if (isNativeTag) {
|
||||
const userIsNativeTag = compilerOptions.isNativeTag;
|
||||
compilerOptions.isNativeTag = (tag) => {
|
||||
if (isNativeTag(tag)) {
|
||||
return true;
|
||||
}
|
||||
if (userIsNativeTag && userIsNativeTag(tag)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
if (isCustomElement) {
|
||||
const userIsCustomElement = compilerOptions.isCustomElement;
|
||||
compilerOptions.isCustomElement = (tag) => {
|
||||
if (isCustomElement(tag)) {
|
||||
return true;
|
||||
}
|
||||
if (userIsCustomElement && userIsCustomElement(tag)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
compilerOptions.directiveTransforms = {
|
||||
...compilerOptions.directiveTransforms,
|
||||
...directiveTransforms,
|
||||
};
|
||||
if (!compilerOptions.nodeTransforms) {
|
||||
compilerOptions.nodeTransforms = [];
|
||||
}
|
||||
if (options.platform === 'h5') {
|
||||
templateOptions.transformAssetUrls = (0, uni_cli_shared_1.createUniVueTransformAssetUrls)((0, uni_cli_shared_1.isExternalUrl)(options.base) ? options.base : '');
|
||||
}
|
||||
else {
|
||||
// 替换内置的 transformAssetUrls 逻辑
|
||||
templateOptions.transformAssetUrls = {
|
||||
tags: {},
|
||||
};
|
||||
compilerOptions.nodeTransforms.push(...(0, uni_cli_shared_1.getBaseNodeTransforms)(options.base));
|
||||
}
|
||||
if (nodeTransforms) {
|
||||
compilerOptions.nodeTransforms.push(...nodeTransforms);
|
||||
}
|
||||
// const compatConfig = parseCompatConfigOnce(options.inputDir)
|
||||
// compilerOptions.compatConfig = extend(
|
||||
// compilerOptions.compatConfig || {},
|
||||
// compatConfig
|
||||
// )
|
||||
// App,MP 平台不支持使用静态节点
|
||||
compilerOptions.hoistStatic = false;
|
||||
compilerOptions.root = process.env.UNI_INPUT_DIR;
|
||||
// app-nvue 需要启用 customElement 机制来内联 styles
|
||||
if (process.env.UNI_COMPILER === 'nvue') {
|
||||
vueOptions.customElement = true;
|
||||
if (process.env.UNI_RENDERER_NATIVE !== 'appService') {
|
||||
// nvue 需要使用自己的 compiler,来移除 scoped
|
||||
vueOptions.compiler = (0, utils_1.createNVueCompiler)();
|
||||
}
|
||||
}
|
||||
return vueOptions;
|
||||
}
|
||||
exports.initPluginVueOptions = initPluginVueOptions;
|
||||
function initPluginVueJsxOptions(options, { isCustomElement, }, jsxOptions) {
|
||||
const vueJsxOptions = (0, shared_1.isPlainObject)(options.vueJsxOptions)
|
||||
? options.vueJsxOptions
|
||||
: (options.vueJsxOptions = {});
|
||||
if (!(0, shared_1.hasOwn)(vueJsxOptions, 'optimize')) {
|
||||
vueJsxOptions.optimize = true;
|
||||
}
|
||||
vueJsxOptions.isCustomElement = isCustomElement;
|
||||
if (!vueJsxOptions.babelPlugins) {
|
||||
vueJsxOptions.babelPlugins = [];
|
||||
}
|
||||
if ((0, shared_1.isArray)(jsxOptions.babelPlugins)) {
|
||||
vueJsxOptions.babelPlugins.push(...jsxOptions.babelPlugins);
|
||||
}
|
||||
return vueJsxOptions;
|
||||
}
|
||||
exports.initPluginVueJsxOptions = initPluginVueJsxOptions;
|
||||
function initPluginViteLegacyOptions(options) {
|
||||
const viteLegacyOptions = options.viteLegacyOptions || (options.viteLegacyOptions = {});
|
||||
return viteLegacyOptions;
|
||||
}
|
||||
exports.initPluginViteLegacyOptions = initPluginViteLegacyOptions;
|
||||
70
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/package.json
generated
vendored
Normal file
70
uni_modules/UniDevTools/node_modules/@dcloudio/vite-plugin-uni/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "@dcloudio/vite-plugin-uni",
|
||||
"version": "3.0.0-3090520231028001",
|
||||
"description": "uni-app vite plugin",
|
||||
"bin": {
|
||||
"uni": "bin/uni.js"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dcloudio/uni-app.git",
|
||||
"directory": "packages/vite-plugin-uni"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.21.3",
|
||||
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
||||
"@babel/plugin-transform-typescript": "^7.20.7",
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-3090520231028001",
|
||||
"@dcloudio/uni-shared": "3.0.0-3090520231028001",
|
||||
"@rollup/pluginutils": "^4.2.0",
|
||||
"@vitejs/plugin-legacy": "^4.0.3",
|
||||
"@vitejs/plugin-vue": "^4.2.1",
|
||||
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
||||
"@vue/compiler-core": "3.2.47",
|
||||
"@vue/compiler-dom": "3.2.47",
|
||||
"@vue/compiler-sfc": "3.2.47",
|
||||
"@vue/shared": "3.2.47",
|
||||
"cac": "6.7.9",
|
||||
"debug": "^4.3.3",
|
||||
"estree-walker": "^2.0.2",
|
||||
"express": "^4.17.1",
|
||||
"fast-glob": "^3.2.11",
|
||||
"fs-extra": "^10.0.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"jsonc-parser": "^3.0.0",
|
||||
"magic-string": "^0.30.0",
|
||||
"picocolors": "^1.0.0",
|
||||
"terser": "^5.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/estree": "^0.0.51",
|
||||
"@types/express": "^4.17.12",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/sass": "^1.16.0",
|
||||
"@vue/babel-plugin-jsx": "^1.1.1",
|
||||
"chokidar": "^3.5.3",
|
||||
"vite": "^4.0.0",
|
||||
"vue": "3.2.47"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^4.0.0"
|
||||
},
|
||||
"uni-app": {
|
||||
"compilerVersion": "3.95"
|
||||
},
|
||||
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da"
|
||||
}
|
||||
Reference in New Issue
Block a user