first commit

This commit is contained in:
monjack
2025-06-20 18:01:48 +08:00
commit 6daa6d65c1
24611 changed files with 2512443 additions and 0 deletions

21
app_vue/node_modules/vue-loader/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

138
app_vue/node_modules/vue-loader/README.md generated vendored Normal file
View File

@ -0,0 +1,138 @@
# vue-loader [![ci](https://github.com/vuejs/vue-loader/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/vuejs/vue-loader/actions/workflows/ci.yml)
> webpack loader for Vue Single-File Components
- [Documentation](https://vue-loader.vuejs.org)
## v17.2.1+ Only Options
- `experimentalInlineMatchResource: boolean`: enable [Inline matchResource](https://webpack.js.org/api/loaders/#inline-matchresource) for rule matching for vue-loader.
## v16+ Only Options
- `reactivityTransform: boolean`: enable [Vue Reactivity Transform](https://github.com/vuejs/rfcs/discussions/369) (SFCs only).
- ~~`refSugar: boolean`: **removed.** use `reactivityTransform` instead.~~
- `customElement: boolean | RegExp`: enable custom elements mode. An SFC loaded in custom elements mode inlines its `<style>` tags as strings under the component's `styles` option. When used with `defineCustomElement` from Vue core, the styles will be injected into the custom element's shadow root.
- Default is `/\.ce\.vue$/`
- Setting to `true` will process all `.vue` files in custom element mode.
- `enableTsInTemplate: boolean` (16.8+): allow TS expressions in templates when `<script>` has `lang="ts"`. Defaults to `true`.
- When used with `ts-loader`, due to `ts-loader`'s cache invalidation behavior, it sometimes prevents the template from being hot-reloaded in isolation, causing the component to reload despite only the template being edited. If this is annoying, you can set this option to `false` (and avoid using TS expressions in templates).
- Alternatively, leave this option on (by default) and use [`esbuild-loader`](https://github.com/privatenumber/esbuild-loader) to transpile TS instead, which doesn't suffer from this problem (it's also a lot faster). However, do note you will need to rely on TS type checking from other sources (e.g. IDE or `vue-tsc`).
## What is Vue Loader?
`vue-loader` is a loader for [webpack](https://webpack.js.org/) that allows you to author Vue components in a format called [Single-File Components (SFCs)](./docs/spec.md):
```vue
<template>
<div class="example">{{ msg }}</div>
</template>
<script>
export default {
data() {
return {
msg: 'Hello world!',
}
},
}
</script>
<style>
.example {
color: red;
}
</style>
```
There are many cool features provided by `vue-loader`:
- Allows using other webpack loaders for each part of a Vue component, for example Sass for `<style>` and Pug for `<template>`;
- Allows custom blocks in a `.vue` file that can have custom loader chains applied to them;
- Treat static assets referenced in `<style>` and `<template>` as module dependencies and handle them with webpack loaders;
- Simulate scoped CSS for each component;
- State-preserving hot-reloading during development.
In a nutshell, the combination of webpack and `vue-loader` gives you a modern, flexible and extremely powerful front-end workflow for authoring Vue.js applications.
## How It Works
> The following section is for maintainers and contributors who are interested in the internal implementation details of `vue-loader`, and is **not** required knowledge for end users.
`vue-loader` is not a simple source transform loader. It handles each language blocks inside an SFC with its own dedicated loader chain (you can think of each block as a "virtual module"), and finally assembles the blocks together into the final module. Here's a brief overview of how the whole thing works:
1. `vue-loader` parses the SFC source code into an _SFC Descriptor_ using `@vue/compiler-sfc`. It then generates an import for each language block so the actual returned module code looks like this:
```js
// code returned from the main loader for 'source.vue'
// import the <template> block
import render from 'source.vue?vue&type=template'
// import the <script> block
import script from 'source.vue?vue&type=script'
export * from 'source.vue?vue&type=script'
// import <style> blocks
import 'source.vue?vue&type=style&index=1'
script.render = render
export default script
```
Notice how the code is importing `source.vue` itself, but with different request queries for each block.
2. We want the content in `script` block to be treated like `.js` files (and if it's `<script lang="ts">`, we want to to be treated like `.ts` files). Same for other language blocks. So we want webpack to apply any configured module rules that matches `.js` also to requests that look like `source.vue?vue&type=script`. This is what `VueLoaderPlugin` (`src/plugins.ts`) does: for each module rule in the webpack config, it creates a modified clone that targets corresponding Vue language block requests.
Suppose we have configured `babel-loader` for all `*.js` files. That rule will be cloned and applied to Vue SFC `<script>` blocks as well. Internally to webpack, a request like
```js
import script from 'source.vue?vue&type=script'
```
Will expand to:
```js
import script from 'babel-loader!vue-loader!source.vue?vue&type=script'
```
Notice the `vue-loader` is also matched because `vue-loader` are applied to `.vue` files.
Similarly, if you have configured `style-loader` + `css-loader` + `sass-loader` for `*.scss` files:
```html
<style scoped lang="scss">
```
Will be returned by `vue-loader` as:
```js
import 'source.vue?vue&type=style&index=1&scoped&lang=scss'
```
And webpack will expand it to:
```js
import 'style-loader!css-loader!sass-loader!vue-loader!source.vue?vue&type=style&index=1&scoped&lang=scss'
```
3. When processing the expanded requests, the main `vue-loader` will get invoked again. This time though, the loader notices that the request has queries and is targeting a specific block only. So it selects (`src/select.ts`) the inner content of the target block and passes it on to the loaders matched after it.
4. For the `<script>` block, this is pretty much it. For `<template>` and `<style>` blocks though, a few extra tasks need to be performed:
- We need to compile the template using the Vue template compiler;
- We need to post-process the CSS in `<style scoped>` blocks, **after** `css-loader` but **before** `style-loader`.
Technically, these are additional loaders (`src/templateLoader.ts` and `src/stylePostLoader.ts`) that need to be injected into the expanded loader chain. It would be very complicated if the end users have to configure this themselves, so `VueLoaderPlugin` also injects a global [Pitching Loader](https://webpack.js.org/api/loaders/#pitching-loader) (`src/pitcher.ts`) that intercepts Vue `<template>` and `<style>` requests and injects the necessary loaders. The final requests look like the following:
```js
// <template lang="pug">
import 'vue-loader/template-loader!pug-loader!source.vue?vue&type=template'
// <style scoped lang="scss">
import 'style-loader!vue-loader/style-post-loader!css-loader!sass-loader!vue-loader!source.vue?vue&type=style&index=1&scoped&lang=scss'
```

7
app_vue/node_modules/vue-loader/dist/compiler.d.ts generated vendored Normal file
View File

@ -0,0 +1,7 @@
declare module 'vue/compiler-sfc' {
interface SFCDescriptor {
id: string;
}
}
import * as _compiler from 'vue/compiler-sfc';
export declare let compiler: typeof _compiler;

17
app_vue/node_modules/vue-loader/dist/compiler.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compiler = void 0;
try {
// Vue 3.2.13+ ships the SFC compiler directly under the `vue` package
// making it no longer necessary to have @vue/compiler-sfc separately installed.
exports.compiler = require('vue/compiler-sfc');
}
catch (e) {
try {
exports.compiler = require('@vue/compiler-sfc');
}
catch (e) {
throw new Error(`@vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc ` +
`to be present in the dependency tree.`);
}
}

1
app_vue/node_modules/vue-loader/dist/cssModules.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export declare function genCSSModulesCode(id: string, index: number, request: string, moduleName: string | boolean, needsHotReload: boolean): string;

21
app_vue/node_modules/vue-loader/dist/cssModules.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.genCSSModulesCode = void 0;
function genCSSModulesCode(id, index, request, moduleName, needsHotReload) {
const styleVar = `style${index}`;
let code = `\nimport ${styleVar} from ${request}`;
// inject variable
const name = typeof moduleName === 'string' ? moduleName : '$style';
code += `\ncssModules["${name}"] = ${styleVar}`;
if (needsHotReload) {
code += `
if (module.hot) {
module.hot.accept(${request}, () => {
cssModules["${name}"] = ${styleVar}
__VUE_HMR_RUNTIME__.rerender("${id}")
})
}`;
}
return code;
}
exports.genCSSModulesCode = genCSSModulesCode;

View File

@ -0,0 +1,4 @@
import type { CompilerOptions, SFCDescriptor } from 'vue/compiler-sfc';
export declare const descriptorCache: Map<string, SFCDescriptor>;
export declare function setDescriptor(filename: string, entry: SFCDescriptor): void;
export declare function getDescriptor(filename: string, compilerOptions?: CompilerOptions): SFCDescriptor;

View File

@ -0,0 +1,54 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.getDescriptor = exports.setDescriptor = exports.descriptorCache = void 0;
const fs = __importStar(require("fs"));
const compiler_1 = require("./compiler");
const { parse } = compiler_1.compiler;
exports.descriptorCache = new Map();
function setDescriptor(filename, entry) {
exports.descriptorCache.set(cleanQuery(filename), entry);
}
exports.setDescriptor = setDescriptor;
function getDescriptor(filename, compilerOptions) {
filename = cleanQuery(filename);
if (exports.descriptorCache.has(filename)) {
return exports.descriptorCache.get(filename);
}
// This function should only be called after the descriptor has been
// cached by the main loader.
// If this is somehow called without a cache hit, it's probably due to sub
// loaders being run in separate threads. The only way to deal with this is to
// read from disk directly...
const source = fs.readFileSync(filename, 'utf-8');
const { descriptor } = parse(source, {
filename,
sourceMap: true,
templateParseOptions: compilerOptions,
});
exports.descriptorCache.set(filename, descriptor);
return descriptor;
}
exports.getDescriptor = getDescriptor;
function cleanQuery(str) {
const i = str.indexOf('?');
return i > 0 ? str.slice(0, i) : str;
}

View File

@ -0,0 +1,2 @@
declare const _default: (sfc: any, props: [string, string][]) => any;
export default _default;

11
app_vue/node_modules/vue-loader/dist/exportHelper.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// runtime helper for setting properties on components
// in a tree-shakable way
exports.default = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};

View File

@ -0,0 +1,2 @@
import type { CompilerError } from 'vue/compiler-sfc';
export declare function formatError(err: SyntaxError | CompilerError, source: string, file: string): void;

17
app_vue/node_modules/vue-loader/dist/formatError.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatError = void 0;
const compiler_1 = require("./compiler");
const chalk = require("chalk");
const { generateCodeFrame } = compiler_1.compiler;
function formatError(err, source, file) {
const loc = err.loc;
if (!loc) {
return;
}
const locString = `:${loc.start.line}:${loc.start.column}`;
const filePath = chalk.gray(`at ${file}${locString}`);
const codeframe = generateCodeFrame(source, loc.start.offset, loc.end.offset);
err.message = `\n${chalk.red(`VueCompilerError: ${err.message}`)}\n${filePath}\n${chalk.yellow(codeframe)}\n`;
}
exports.formatError = formatError;

1
app_vue/node_modules/vue-loader/dist/hotReload.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export declare function genHotReloadCode(id: string, templateRequest: string | undefined): string;

26
app_vue/node_modules/vue-loader/dist/hotReload.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
"use strict";
// __VUE_HMR_RUNTIME__ is injected to global scope by @vue/runtime-core
Object.defineProperty(exports, "__esModule", { value: true });
exports.genHotReloadCode = void 0;
function genHotReloadCode(id, templateRequest) {
return `
/* hot reload */
if (module.hot) {
__exports__.__hmrId = "${id}"
const api = __VUE_HMR_RUNTIME__
module.hot.accept()
if (!api.createRecord('${id}', __exports__)) {
api.reload('${id}', __exports__)
}
${templateRequest ? genTemplateHotReloadCode(id, templateRequest) : ''}
}
`;
}
exports.genHotReloadCode = genHotReloadCode;
function genTemplateHotReloadCode(id, request) {
return `
module.hot.accept(${request}, () => {
api.rerender('${id}', render)
})
`;
}

31
app_vue/node_modules/vue-loader/dist/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,31 @@
import type { LoaderContext } from 'webpack';
import type { TemplateCompiler, CompilerOptions, SFCTemplateCompileOptions, SFCScriptCompileOptions } from 'vue/compiler-sfc';
import VueLoaderPlugin from './plugin';
export { VueLoaderPlugin };
export interface VueLoaderOptions {
babelParserPlugins?: SFCScriptCompileOptions['babelParserPlugins'];
transformAssetUrls?: SFCTemplateCompileOptions['transformAssetUrls'];
compiler?: TemplateCompiler | string;
compilerOptions?: CompilerOptions;
/**
* TODO remove in 3.4
* @deprecated
*/
reactivityTransform?: boolean;
/**
* @experimental
*/
propsDestructure?: boolean;
/**
* @experimental
*/
defineModel?: boolean;
customElement?: boolean | RegExp;
hotReload?: boolean;
exposeFilename?: boolean;
appendExtension?: boolean;
enableTsInTemplate?: boolean;
experimentalInlineMatchResource?: boolean;
isServerBuild?: boolean;
}
export default function loader(this: LoaderContext<VueLoaderOptions>, source: string): string | void;

282
app_vue/node_modules/vue-loader/dist/index.js generated vendored Normal file
View File

@ -0,0 +1,282 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.VueLoaderPlugin = void 0;
const path = __importStar(require("path"));
const qs = __importStar(require("querystring"));
const hash = require("hash-sum");
const compiler_1 = require("./compiler");
const select_1 = require("./select");
const hotReload_1 = require("./hotReload");
const cssModules_1 = require("./cssModules");
const formatError_1 = require("./formatError");
const plugin_1 = __importDefault(require("./plugin"));
exports.VueLoaderPlugin = plugin_1.default;
const resolveScript_1 = require("./resolveScript");
const descriptorCache_1 = require("./descriptorCache");
const util_1 = require("./util");
let errorEmitted = false;
const { parse } = compiler_1.compiler;
const exportHelperPath = require.resolve('./exportHelper');
function loader(source) {
var _a;
const loaderContext = this;
// check if plugin is installed
if (!errorEmitted &&
!loaderContext['thread-loader'] &&
!loaderContext[plugin_1.default.NS]) {
loaderContext.emitError(new Error(`vue-loader was used without the corresponding plugin. ` +
`Make sure to include VueLoaderPlugin in your webpack config.`));
errorEmitted = true;
}
const stringifyRequest = (r) => (0, util_1.stringifyRequest)(loaderContext, r);
const { mode, target, sourceMap, rootContext, resourcePath, resourceQuery: _resourceQuery = '', _compiler, } = loaderContext;
const isWebpack5 = (0, util_1.testWebpack5)(_compiler);
const rawQuery = _resourceQuery.slice(1);
const incomingQuery = qs.parse(rawQuery);
const resourceQuery = rawQuery ? `&${rawQuery}` : '';
const options = ((0, util_1.getOptions)(loaderContext) || {});
const enableInlineMatchResource = isWebpack5 && Boolean(options.experimentalInlineMatchResource);
const isServer = (_a = options.isServerBuild) !== null && _a !== void 0 ? _a : target === 'node';
const isProduction = mode === 'production' || process.env.NODE_ENV === 'production';
const filename = resourcePath.replace(/\?.*$/, '');
const { descriptor, errors } = parse(source, {
filename,
sourceMap,
templateParseOptions: options.compilerOptions,
});
const asCustomElement = typeof options.customElement === 'boolean'
? options.customElement
: (options.customElement || /\.ce\.vue$/).test(filename);
// cache descriptor
(0, descriptorCache_1.setDescriptor)(filename, descriptor);
if (errors.length) {
errors.forEach((err) => {
(0, formatError_1.formatError)(err, source, resourcePath);
loaderContext.emitError(err);
});
return ``;
}
// module id for scoped CSS & hot-reload
const rawShortFilePath = path
.relative(rootContext || process.cwd(), filename)
.replace(/^(\.\.[\/\\])+/, '');
const shortFilePath = rawShortFilePath.replace(/\\/g, '/');
const id = hash(isProduction
? shortFilePath + '\n' + source.replace(/\r\n/g, '\n')
: shortFilePath);
// if the query has a type field, this is a language block request
// e.g. foo.vue?type=template&id=xxxxx
// and we will return early
if (incomingQuery.type) {
return (0, select_1.selectBlock)(descriptor, id, options, loaderContext, incomingQuery, !!options.appendExtension);
}
// feature information
const hasScoped = descriptor.styles.some((s) => s.scoped);
const needsHotReload = !isServer &&
!isProduction &&
!!(descriptor.script || descriptor.scriptSetup || descriptor.template) &&
options.hotReload !== false;
// extra properties to attach to the script object
// we need to do this in a tree-shaking friendly manner
const propsToAttach = [];
// script
let scriptImport = `const script = {}`;
let isTS = false;
const { script, scriptSetup } = descriptor;
if (script || scriptSetup) {
const lang = (script === null || script === void 0 ? void 0 : script.lang) || (scriptSetup === null || scriptSetup === void 0 ? void 0 : scriptSetup.lang);
isTS = !!(lang && /tsx?/.test(lang));
const externalQuery = Boolean(script && !scriptSetup && script.src)
? `&external`
: ``;
const src = (script && !scriptSetup && script.src) || resourcePath;
const attrsQuery = attrsToQuery((scriptSetup || script).attrs, 'js');
const query = `?vue&type=script${attrsQuery}${resourceQuery}${externalQuery}`;
let scriptRequest;
if (enableInlineMatchResource) {
scriptRequest = stringifyRequest((0, util_1.genMatchResource)(this, src, query, lang || 'js'));
}
else {
scriptRequest = stringifyRequest(src + query);
}
scriptImport =
`import script from ${scriptRequest}\n` +
// support named exports
`export * from ${scriptRequest}`;
}
// template
let templateImport = ``;
let templateRequest;
const renderFnName = isServer ? `ssrRender` : `render`;
const useInlineTemplate = (0, resolveScript_1.canInlineTemplate)(descriptor, isProduction);
if (descriptor.template && !useInlineTemplate) {
const src = descriptor.template.src || resourcePath;
const externalQuery = Boolean(descriptor.template.src) ? `&external` : ``;
const idQuery = `&id=${id}`;
const scopedQuery = hasScoped ? `&scoped=true` : ``;
const attrsQuery = attrsToQuery(descriptor.template.attrs);
const tsQuery = options.enableTsInTemplate !== false && isTS ? `&ts=true` : ``;
const query = `?vue&type=template${idQuery}${scopedQuery}${tsQuery}${attrsQuery}${resourceQuery}${externalQuery}`;
if (enableInlineMatchResource) {
templateRequest = stringifyRequest((0, util_1.genMatchResource)(this, src, query, options.enableTsInTemplate !== false && isTS ? 'ts' : 'js'));
}
else {
templateRequest = stringifyRequest(src + query);
}
templateImport = `import { ${renderFnName} } from ${templateRequest}`;
propsToAttach.push([renderFnName, renderFnName]);
}
// styles
let stylesCode = ``;
let hasCSSModules = false;
const nonWhitespaceRE = /\S+/;
if (descriptor.styles.length) {
descriptor.styles
.filter((style) => style.src || nonWhitespaceRE.test(style.content))
.forEach((style, i) => {
const src = style.src || resourcePath;
const attrsQuery = attrsToQuery(style.attrs, 'css');
const lang = String(style.attrs.lang || 'css');
// make sure to only pass id when necessary so that we don't inject
// duplicate tags when multiple components import the same css file
const idQuery = !style.src || style.scoped ? `&id=${id}` : ``;
const inlineQuery = asCustomElement ? `&inline` : ``;
const externalQuery = Boolean(style.src) ? `&external` : ``;
const query = `?vue&type=style&index=${i}${idQuery}${inlineQuery}${attrsQuery}${resourceQuery}${externalQuery}`;
let styleRequest;
if (enableInlineMatchResource) {
styleRequest = stringifyRequest((0, util_1.genMatchResource)(this, src, query, lang));
}
else {
styleRequest = stringifyRequest(src + query);
}
if (style.module) {
if (asCustomElement) {
loaderContext.emitError(new Error(`<style module> is not supported in custom element mode.`));
}
if (!hasCSSModules) {
stylesCode += `\nconst cssModules = {}`;
propsToAttach.push([`__cssModules`, `cssModules`]);
hasCSSModules = true;
}
stylesCode += (0, cssModules_1.genCSSModulesCode)(id, i, styleRequest, style.module, needsHotReload);
}
else {
if (asCustomElement) {
stylesCode += `\nimport _style_${i} from ${styleRequest}`;
}
else {
stylesCode += `\nimport ${styleRequest}`;
}
}
// TODO SSR critical CSS collection
});
if (asCustomElement) {
propsToAttach.push([
`styles`,
`[${descriptor.styles.map((_, i) => `_style_${i}`)}]`,
]);
}
}
let code = [templateImport, scriptImport, stylesCode]
.filter(Boolean)
.join('\n');
// attach scope Id for runtime use
if (hasScoped) {
propsToAttach.push([`__scopeId`, `"data-v-${id}"`]);
}
// Expose filename. This is used by the devtools and Vue runtime warnings.
if (!isProduction) {
// Expose the file's full path in development, so that it can be opened
// from the devtools.
propsToAttach.push([
`__file`,
JSON.stringify(rawShortFilePath.replace(/\\/g, '/')),
]);
}
else if (options.exposeFilename) {
// Libraries can opt-in to expose their components' filenames in production builds.
// For security reasons, only expose the file's basename in production.
propsToAttach.push([`__file`, JSON.stringify(path.basename(resourcePath))]);
}
// custom blocks
if (descriptor.customBlocks && descriptor.customBlocks.length) {
code += `\n/* custom blocks */\n`;
code +=
descriptor.customBlocks
.map((block, i) => {
const src = block.attrs.src || resourcePath;
const attrsQuery = attrsToQuery(block.attrs);
const blockTypeQuery = `&blockType=${qs.escape(block.type)}`;
const issuerQuery = block.attrs.src
? `&issuerPath=${qs.escape(resourcePath)}`
: '';
const externalQuery = Boolean(block.attrs.src) ? `&external` : ``;
const query = `?vue&type=custom&index=${i}${blockTypeQuery}${issuerQuery}${attrsQuery}${resourceQuery}${externalQuery}`;
let customRequest;
if (enableInlineMatchResource) {
customRequest = stringifyRequest((0, util_1.genMatchResource)(this, src, query, block.attrs.lang));
}
else {
customRequest = stringifyRequest(src + query);
}
return (`import block${i} from ${customRequest}\n` +
`if (typeof block${i} === 'function') block${i}(script)`);
})
.join(`\n`) + `\n`;
}
// finalize
if (!propsToAttach.length) {
code += `\n\nconst __exports__ = script;`;
}
else {
code += `\n\nimport exportComponent from ${stringifyRequest(exportHelperPath)}`;
code += `\nconst __exports__ = /*#__PURE__*/exportComponent(script, [${propsToAttach
.map(([key, val]) => `['${key}',${val}]`)
.join(',')}])`;
}
if (needsHotReload) {
code += (0, hotReload_1.genHotReloadCode)(id, templateRequest);
}
code += `\n\nexport default __exports__`;
return code;
}
exports.default = loader;
// these are built-in query parameters so should be ignored
// if the user happen to add them as attrs
const ignoreList = ['id', 'index', 'src', 'type'];
function attrsToQuery(attrs, langFallback) {
let query = ``;
for (const name in attrs) {
const value = attrs[name];
if (!ignoreList.includes(name)) {
query += `&${qs.escape(name)}=${value ? qs.escape(String(value)) : ``}`;
}
}
if (langFallback && !(`lang` in attrs)) {
query += `&lang=${langFallback}`;
}
return query;
}

4
app_vue/node_modules/vue-loader/dist/pitcher.d.ts generated vendored Normal file
View File

@ -0,0 +1,4 @@
import type { LoaderDefinitionFunction } from 'webpack';
declare const pitcher: LoaderDefinitionFunction;
export declare const pitch: () => string | undefined;
export default pitcher;

149
app_vue/node_modules/vue-loader/dist/pitcher.js generated vendored Normal file
View File

@ -0,0 +1,149 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.pitch = void 0;
const qs = __importStar(require("querystring"));
const util_1 = require("./util");
const selfPath = require.resolve('./index');
// const templateLoaderPath = require.resolve('./templateLoader')
const stylePostLoaderPath = require.resolve('./stylePostLoader');
const styleInlineLoaderPath = require.resolve('./styleInlineLoader');
const isESLintLoader = (l) => /(\/|\\|@)eslint-loader/.test(l.path);
const isNullLoader = (l) => /(\/|\\|@)null-loader/.test(l.path);
const isCSSLoader = (l) => /(\/|\\|@)css-loader/.test(l.path);
const isCacheLoader = (l) => /(\/|\\|@)cache-loader/.test(l.path);
const isNotPitcher = (l) => l.path !== __filename;
const pitcher = (code) => code;
// This pitching loader is responsible for intercepting all vue block requests
// and transform it into appropriate requests.
const pitch = function () {
var _a;
const context = this;
const rawLoaders = context.loaders.filter(isNotPitcher);
let loaders = rawLoaders;
// do not inject if user uses null-loader to void the type (#1239)
if (loaders.some(isNullLoader)) {
return;
}
const query = qs.parse(context.resourceQuery.slice(1));
const isInlineBlock = /\.vue$/.test(context.resourcePath);
// eslint-loader may get matched multiple times
// if this is an inline block, since the whole file itself is being linted,
// remove eslint-loader to avoid duplicate linting.
if (isInlineBlock) {
loaders = loaders.filter((l) => !isESLintLoader(l));
}
// Important: dedupe loaders since both the original rule
// and the cloned rule would match a source import request or a
// resourceQuery-only rule that intends to target a custom block with no lang
const seen = new Map();
loaders = loaders.filter((loader) => {
const identifier = typeof loader === 'string'
? loader
: // Dedupe based on both path and query if available. This is important
// in Vue CLI so that postcss-loaders with different options can co-exist
loader.path + loader.query;
if (!seen.has(identifier)) {
seen.set(identifier, true);
return true;
}
});
// Inject style-post-loader before css-loader for scoped CSS and trimming
const isWebpack5 = (0, util_1.testWebpack5)(context._compiler);
const options = ((0, util_1.getOptions)(context) || {});
if (query.type === `style`) {
if (isWebpack5 && ((_a = context._compiler) === null || _a === void 0 ? void 0 : _a.options.experiments.css)) {
// If user enables `experiments.css`, then we are trying to emit css code directly.
// Although we can target requests like `xxx.vue?type=style` to match `type: "css"`,
// it will make the plugin a mess.
if (!options.experimentalInlineMatchResource) {
context.emitError(new Error('`experimentalInlineMatchResource` should be enabled if `experiments.css` enabled currently'));
return '';
}
if (query.inline || query.module) {
context.emitError(new Error('`inline` or `module` is currently not supported with `experiments.css` enabled'));
return '';
}
const loaderString = [stylePostLoaderPath, ...loaders]
.map((loader) => {
return typeof loader === 'string' ? loader : loader.request;
})
.join('!');
const styleRequest = (0, util_1.stringifyRequest)(context, `${context.resourcePath}${query.lang ? `.${query.lang}` : ''}${context.resourceQuery}!=!-!${loaderString}!${context.resource}`);
return `@import ${styleRequest};`;
}
const cssLoaderIndex = loaders.findIndex(isCSSLoader);
if (cssLoaderIndex > -1) {
// if inlined, ignore any loaders after css-loader and replace w/ inline
// loader
const afterLoaders = query.inline != null
? [styleInlineLoaderPath]
: loaders.slice(0, cssLoaderIndex + 1);
const beforeLoaders = loaders.slice(cssLoaderIndex + 1);
return genProxyModule([...afterLoaders, stylePostLoaderPath, ...beforeLoaders], context, !!query.module || query.inline != null, query.lang || 'css');
}
}
// if a custom block has no other matching loader other than vue-loader itself
// or cache-loader, we should ignore it
if (query.type === `custom` && shouldIgnoreCustomBlock(loaders)) {
return ``;
}
// Rewrite request. Technically this should only be done when we have deduped
// loaders. But somehow this is required for block source maps to work.
return genProxyModule(loaders, context, query.type !== 'template', query.ts ? 'ts' : query.lang);
};
exports.pitch = pitch;
function genProxyModule(loaders, context, exportDefault = true, lang = 'js') {
const request = genRequest(loaders, lang, context);
// return a proxy module which simply re-exports everything from the
// actual request. Note for template blocks the compiled module has no
// default export.
return ((exportDefault ? `export { default } from ${request}; ` : ``) +
`export * from ${request}`);
}
function genRequest(loaders, lang, context) {
const isWebpack5 = (0, util_1.testWebpack5)(context._compiler);
const options = ((0, util_1.getOptions)(context) || {});
const enableInlineMatchResource = isWebpack5 && options.experimentalInlineMatchResource;
const loaderStrings = loaders.map((loader) => {
return typeof loader === 'string' ? loader : loader.request;
});
const resource = context.resourcePath + context.resourceQuery;
if (enableInlineMatchResource) {
return (0, util_1.stringifyRequest)(context, `${context.resourcePath}${lang ? `.${lang}` : ''}${context.resourceQuery}!=!-!${[...loaderStrings, resource].join('!')}`);
}
return (0, util_1.stringifyRequest)(context, '-!' + [...loaderStrings, resource].join('!'));
}
function shouldIgnoreCustomBlock(loaders) {
const actualLoaders = loaders.filter((loader) => {
// vue-loader
if (loader.path === selfPath) {
return false;
}
// cache-loader
if (isCacheLoader(loader)) {
return false;
}
return true;
});
return actualLoaders.length === 0;
}
exports.default = pitcher;

6
app_vue/node_modules/vue-loader/dist/plugin.d.ts generated vendored Normal file
View File

@ -0,0 +1,6 @@
import type { Compiler } from 'webpack';
declare class Plugin {
static NS: string;
apply(compiler: Compiler): void;
}
export default Plugin;

20
app_vue/node_modules/vue-loader/dist/plugin.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("./util");
const NS = 'vue-loader';
class Plugin {
apply(compiler) {
let Ctor;
if ((0, util_1.testWebpack5)(compiler)) {
// webpack5 and upper
Ctor = require('./pluginWebpack5').default;
}
else {
// webpack4 and lower
Ctor = require('./pluginWebpack4').default;
}
new Ctor().apply(compiler);
}
}
Plugin.NS = NS;
exports.default = Plugin;

View File

@ -0,0 +1,6 @@
import type { Compiler } from 'webpack';
declare class VueLoaderPlugin {
static NS: string;
apply(compiler: Compiler): void;
}
export default VueLoaderPlugin;

237
app_vue/node_modules/vue-loader/dist/pluginWebpack4.js generated vendored Normal file
View File

@ -0,0 +1,237 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 });
const qs = __importStar(require("querystring"));
const resolveScript_1 = require("./resolveScript");
const fs = require("fs");
const compiler_1 = require("./compiler");
const descriptorCache_1 = require("./descriptorCache");
const util_1 = require("./util");
const RuleSet = require('webpack/lib/RuleSet');
const id = 'vue-loader-plugin';
const NS = 'vue-loader';
class VueLoaderPlugin {
apply(compiler) {
// inject NS for plugin installation check in the main loader
compiler.hooks.compilation.tap(id, (compilation) => {
compilation.hooks.normalModuleLoader.tap(id, (loaderContext) => {
loaderContext[NS] = true;
});
});
const rawRules = compiler.options.module.rules;
// use webpack's RuleSet utility to normalize user rules
const rules = new RuleSet(rawRules).rules;
// find the rule that applies to vue files
let vueRuleIndex = rawRules.findIndex(createMatcher(`foo.vue`));
if (vueRuleIndex < 0) {
vueRuleIndex = rawRules.findIndex(createMatcher(`foo.vue.html`));
}
const vueRule = rules[vueRuleIndex];
if (!vueRule) {
throw new Error(`[VueLoaderPlugin Error] No matching rule for .vue files found.\n` +
`Make sure there is at least one root-level rule that matches .vue or .vue.html files.`);
}
if (vueRule.oneOf) {
throw new Error(`[VueLoaderPlugin Error] vue-loader currently does not support vue rules with oneOf.`);
}
// get the normlized "use" for vue files
const vueUse = vueRule.use;
// get vue-loader options
const vueLoaderUseIndex = vueUse.findIndex((u) => {
// FIXME: this code logic is incorrect when project paths starts with `vue-loader-something`
return /^vue-loader|(\/|\\|@)vue-loader/.test(u.loader || '');
});
if (vueLoaderUseIndex < 0) {
throw new Error(`[VueLoaderPlugin Error] No matching use for vue-loader is found.\n` +
`Make sure the rule matching .vue files include vue-loader in its use.`);
}
const vueLoaderUse = vueUse[vueLoaderUseIndex];
const vueLoaderOptions = (vueLoaderUse.options =
vueLoaderUse.options || {});
// for each user rule (except the vue rule), create a cloned rule
// that targets the corresponding language blocks in *.vue files.
const clonedRules = rules.filter((r) => r !== vueRule).map(cloneRule);
// rule for template compiler
const templateCompilerRule = {
loader: require.resolve('./templateLoader'),
resourceQuery: (query) => {
const parsed = qs.parse(query.slice(1));
return parsed.vue != null && parsed.type === 'template';
},
options: Object.assign({ ident: vueLoaderUse.ident }, vueLoaderOptions),
};
// for each rule that matches plain .js/.ts files, also create a clone and
// match it against the compiled template code inside *.vue files, so that
// compiled vue render functions receive the same treatment as user code
// (mostly babel)
const matchesJS = createMatcher(`test.js`);
const matchesTS = createMatcher(`test.ts`);
const jsRulesForRenderFn = rules
.filter((r) => r !== vueRule && (matchesJS(r) || matchesTS(r)))
.map(cloneRuleForRenderFn);
// pitcher for block requests (for injecting stylePostLoader and deduping
// loaders matched for src imports)
const pitcher = {
loader: require.resolve('./pitcher'),
resourceQuery: (query) => {
const parsed = qs.parse(query.slice(1));
return parsed.vue != null;
},
};
// replace original rules
compiler.options.module.rules = [
pitcher,
...jsRulesForRenderFn,
templateCompilerRule,
...clonedRules,
...rules,
];
// 3.3 HMR support for imported types
if ((0, util_1.needHMR)(vueLoaderOptions, compiler.options) &&
compiler_1.compiler.invalidateTypeCache) {
let watcher;
const WatchPack = require('watchpack');
compiler.hooks.afterCompile.tap(id, (compilation) => {
if (compilation.compiler === compiler) {
// type-only imports can be tree-shaken and not registered as a
// watched file at all, so we have to manually ensure they are watched.
const files = [...resolveScript_1.typeDepToSFCMap.keys()];
const oldWatcher = watcher;
watcher = new WatchPack({ aggregateTimeout: 0 });
watcher.once('aggregated', (changes, removals) => {
for (const file of changes) {
// bust compiler-sfc type dep cache
compiler_1.compiler.invalidateTypeCache(file);
const affectedSFCs = resolveScript_1.typeDepToSFCMap.get(file);
if (affectedSFCs) {
for (const sfc of affectedSFCs) {
// bust script resolve cache
const desc = descriptorCache_1.descriptorCache.get(sfc);
if (desc)
resolveScript_1.clientCache.delete(desc);
// force update importing SFC
fs.writeFileSync(sfc, fs.readFileSync(sfc, 'utf-8'));
}
}
}
for (const file of removals) {
compiler_1.compiler.invalidateTypeCache(file);
}
});
watcher.watch({ files, startTime: Date.now() });
if (oldWatcher) {
oldWatcher.close();
}
}
});
compiler.hooks.watchClose.tap(id, () => {
if (watcher) {
watcher.close();
}
});
// In some cases, e.g. in this project's tests,
// even though needsHMR() returns true, webpack is not watching, thus no watchClose hook is called.
// So we need to close the watcher when webpack is done.
compiler.hooks.done.tap(id, () => {
if (watcher) {
watcher.close();
}
});
}
}
}
VueLoaderPlugin.NS = NS;
function createMatcher(fakeFile) {
return (rule) => {
// #1201 we need to skip the `include` check when locating the vue rule
const clone = Object.assign({}, rule);
delete clone.include;
const normalized = RuleSet.normalizeRule(clone, {}, '');
return !rule.enforce && normalized.resource && normalized.resource(fakeFile);
};
}
function cloneRule(rule) {
const resource = rule.resource;
const resourceQuery = rule.resourceQuery;
// Assuming `test` and `resourceQuery` tests are executed in series and
// synchronously (which is true based on RuleSet's implementation), we can
// save the current resource being matched from `test` so that we can access
// it in `resourceQuery`. This ensures when we use the normalized rule's
// resource check, include/exclude are matched correctly.
let currentResource;
const res = Object.assign(Object.assign({}, rule), { resource: (resource) => {
currentResource = resource;
return true;
}, resourceQuery: (query) => {
const parsed = qs.parse(query.slice(1));
if (parsed.vue == null) {
return false;
}
if (resource && parsed.lang == null) {
return false;
}
const fakeResourcePath = `${currentResource}.${parsed.lang}`;
if (resource && !resource(fakeResourcePath)) {
return false;
}
if (resourceQuery && !resourceQuery(query)) {
return false;
}
return true;
} });
if (rule.rules) {
res.rules = rule.rules.map(cloneRule);
}
if (rule.oneOf) {
res.oneOf = rule.oneOf.map(cloneRule);
}
return res;
}
function cloneRuleForRenderFn(rule) {
const resource = rule.resource;
const resourceQuery = rule.resourceQuery;
let currentResource;
const res = Object.assign(Object.assign({}, rule), { resource: (resource) => {
currentResource = resource;
return true;
}, resourceQuery: (query) => {
const parsed = qs.parse(query.slice(1));
if (parsed.vue == null || parsed.type !== 'template') {
return false;
}
const fakeResourcePath = `${currentResource}.${parsed.ts ? `ts` : `js`}`;
if (resource && !resource(fakeResourcePath)) {
return false;
}
if (resourceQuery && !resourceQuery(query)) {
return false;
}
return true;
} });
if (rule.rules) {
res.rules = rule.rules.map(cloneRuleForRenderFn);
}
if (rule.oneOf) {
res.oneOf = rule.oneOf.map(cloneRuleForRenderFn);
}
return res;
}
exports.default = VueLoaderPlugin;

View File

@ -0,0 +1,6 @@
import type { Compiler } from 'webpack';
declare class VueLoaderPlugin {
static NS: string;
apply(compiler: Compiler): void;
}
export default VueLoaderPlugin;

314
app_vue/node_modules/vue-loader/dist/pluginWebpack5.js generated vendored Normal file
View File

@ -0,0 +1,314 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 });
const qs = __importStar(require("querystring"));
const util_1 = require("./util");
const resolveScript_1 = require("./resolveScript");
const compiler_1 = require("./compiler");
const descriptorCache_1 = require("./descriptorCache");
const id = 'vue-loader-plugin';
const NS = 'vue-loader';
const NormalModule = require('webpack/lib/NormalModule');
const BasicEffectRulePlugin = require('webpack/lib/rules/BasicEffectRulePlugin');
const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin');
const UseEffectRulePlugin = require('webpack/lib/rules/UseEffectRulePlugin');
const RuleSetCompiler = require('webpack/lib/rules/RuleSetCompiler');
let objectMatcherRulePlugins = [];
try {
const ObjectMatcherRulePlugin = require('webpack/lib/rules/ObjectMatcherRulePlugin');
objectMatcherRulePlugins.push(new ObjectMatcherRulePlugin('assert', 'assertions'), new ObjectMatcherRulePlugin('descriptionData'));
}
catch (e) {
const DescriptionDataMatcherRulePlugin = require('webpack/lib/rules/DescriptionDataMatcherRulePlugin');
objectMatcherRulePlugins.push(new DescriptionDataMatcherRulePlugin());
}
const ruleSetCompiler = new RuleSetCompiler([
new BasicMatcherRulePlugin('test', 'resource'),
new BasicMatcherRulePlugin('mimetype'),
new BasicMatcherRulePlugin('dependency'),
new BasicMatcherRulePlugin('include', 'resource'),
new BasicMatcherRulePlugin('exclude', 'resource', true),
new BasicMatcherRulePlugin('conditions'),
new BasicMatcherRulePlugin('resource'),
new BasicMatcherRulePlugin('resourceQuery'),
new BasicMatcherRulePlugin('resourceFragment'),
new BasicMatcherRulePlugin('realResource'),
new BasicMatcherRulePlugin('issuer'),
new BasicMatcherRulePlugin('compiler'),
new BasicMatcherRulePlugin('issuerLayer'),
...objectMatcherRulePlugins,
new BasicEffectRulePlugin('type'),
new BasicEffectRulePlugin('sideEffects'),
new BasicEffectRulePlugin('parser'),
new BasicEffectRulePlugin('resolve'),
new BasicEffectRulePlugin('generator'),
new BasicEffectRulePlugin('layer'),
new UseEffectRulePlugin(),
]);
class VueLoaderPlugin {
apply(compiler) {
// @ts-ignore
const normalModule = compiler.webpack.NormalModule || NormalModule;
// add NS marker so that the loader can detect and report missing plugin
compiler.hooks.compilation.tap(id, (compilation) => {
normalModule
.getCompilationHooks(compilation)
.loader.tap(id, (loaderContext) => {
loaderContext[NS] = true;
});
});
const rules = compiler.options.module.rules;
let rawVueRule;
let vueRules = [];
for (const rawRule of rules) {
// skip rules with 'enforce'. eg. rule for eslint-loader
if (rawRule.enforce) {
continue;
}
vueRules = match(rawRule, 'foo.vue');
if (!vueRules.length) {
vueRules = match(rawRule, 'foo.vue.html');
}
if (vueRules.length > 0) {
if (rawRule.oneOf) {
throw new Error(`[VueLoaderPlugin Error] vue-loader currently does not support vue rules with oneOf.`);
}
rawVueRule = rawRule;
break;
}
}
if (!vueRules.length) {
throw new Error(`[VueLoaderPlugin Error] No matching rule for .vue files found.\n` +
`Make sure there is at least one root-level rule that matches .vue or .vue.html files.`);
}
// get the normalized "use" for vue files
const vueUse = vueRules
.filter((rule) => rule.type === 'use')
.map((rule) => rule.value);
// get vue-loader options
const vueLoaderUseIndex = vueUse.findIndex((u) => {
// FIXME: this code logic is incorrect when project paths starts with `vue-loader-something`
return /^vue-loader|(\/|\\|@)vue-loader/.test(u.loader);
});
if (vueLoaderUseIndex < 0) {
throw new Error(`[VueLoaderPlugin Error] No matching use for vue-loader is found.\n` +
`Make sure the rule matching .vue files include vue-loader in its use.`);
}
// make sure vue-loader options has a known ident so that we can share
// options by reference in the template-loader by using a ref query like
// template-loader??vue-loader-options
const vueLoaderUse = vueUse[vueLoaderUseIndex];
const vueLoaderOptions = (vueLoaderUse.options =
vueLoaderUse.options || {});
const enableInlineMatchResource = vueLoaderOptions.experimentalInlineMatchResource;
// for each user rule (except the vue rule), create a cloned rule
// that targets the corresponding language blocks in *.vue files.
const refs = new Map();
const clonedRules = rules
.filter((r) => r !== rawVueRule)
.map((rawRule) => cloneRule(rawRule, refs, langBlockRuleCheck, langBlockRuleResource));
// fix conflict with config.loader and config.options when using config.use
delete rawVueRule.loader;
delete rawVueRule.options;
rawVueRule.use = vueUse;
// rule for template compiler
const templateCompilerRule = {
loader: require.resolve('./templateLoader'),
resourceQuery: (query) => {
if (!query) {
return false;
}
const parsed = qs.parse(query.slice(1));
return parsed.vue != null && parsed.type === 'template';
},
options: vueLoaderOptions,
};
// for each rule that matches plain .js files, also create a clone and
// match it against the compiled template code inside *.vue files, so that
// compiled vue render functions receive the same treatment as user code
// (mostly babel)
const jsRulesForRenderFn = rules
.filter((r) => r !== rawVueRule &&
(match(r, 'test.js').length > 0 || match(r, 'test.ts').length > 0))
.map((rawRule) => cloneRule(rawRule, refs, jsRuleCheck, jsRuleResource));
// global pitcher (responsible for injecting template compiler loader & CSS
// post loader)
const pitcher = {
loader: require.resolve('./pitcher'),
resourceQuery: (query) => {
if (!query) {
return false;
}
const parsed = qs.parse(query.slice(1));
return parsed.vue != null;
},
options: vueLoaderOptions,
};
// replace original rules
if (enableInlineMatchResource) {
// Match rules using `vue-loader`
const vueLoaderRules = rules.filter((rule) => {
const matchOnce = (use) => {
let loaderString = '';
if (!use) {
return loaderString;
}
if (typeof use === 'string') {
loaderString = use;
}
else if (Array.isArray(use)) {
loaderString = matchOnce(use[0]);
}
else if (typeof use === 'object' && use.loader) {
loaderString = use.loader;
}
return loaderString;
};
const loader = rule.loader || matchOnce(rule.use);
return (loader === require('../package.json').name ||
loader.startsWith(require.resolve('./index')));
});
compiler.options.module.rules = [
pitcher,
...rules.filter((rule) => !vueLoaderRules.includes(rule)),
templateCompilerRule,
...clonedRules,
...vueLoaderRules,
];
}
else {
compiler.options.module.rules = [
pitcher,
...jsRulesForRenderFn,
templateCompilerRule,
...clonedRules,
...rules,
];
}
// 3.3 HMR support for imported types
if ((0, util_1.needHMR)(vueLoaderOptions, compiler.options) &&
compiler_1.compiler.invalidateTypeCache) {
compiler.hooks.afterCompile.tap(id, (compilation) => {
if (compilation.compiler === compiler) {
for (const file of resolveScript_1.typeDepToSFCMap.keys()) {
compilation.fileDependencies.add(file);
}
}
});
compiler.hooks.watchRun.tap(id, () => {
if (!compiler.modifiedFiles)
return;
for (const file of compiler.modifiedFiles) {
compiler_1.compiler.invalidateTypeCache(file);
const affectedSFCs = resolveScript_1.typeDepToSFCMap.get(file);
if (affectedSFCs) {
for (const sfc of affectedSFCs) {
// bust script resolve cache
const desc = descriptorCache_1.descriptorCache.get(sfc);
if (desc)
resolveScript_1.clientCache.delete(desc);
// force update importing SFC
// @ts-ignore
compiler.fileTimestamps.set(sfc, {
safeTime: Date.now(),
timestamp: Date.now(),
});
}
}
}
for (const file of compiler.removedFiles) {
compiler_1.compiler.invalidateTypeCache(file);
}
});
}
}
}
VueLoaderPlugin.NS = NS;
const matcherCache = new WeakMap();
function match(rule, fakeFile) {
let ruleSet = matcherCache.get(rule);
if (!ruleSet) {
// skip the `include` check when locating the vue rule
const clonedRawRule = Object.assign({}, rule);
delete clonedRawRule.include;
ruleSet = ruleSetCompiler.compile([clonedRawRule]);
matcherCache.set(rule, ruleSet);
}
return ruleSet.exec({
resource: fakeFile,
});
}
const langBlockRuleCheck = (query, rule) => {
return (query.type === 'custom' || !rule.conditions.length || query.lang != null);
};
const langBlockRuleResource = (query, resource) => `${resource}.${query.lang}`;
const jsRuleCheck = (query) => {
return query.type === 'template';
};
const jsRuleResource = (query, resource) => `${resource}.${query.ts ? `ts` : `js`}`;
let uid = 0;
function cloneRule(rawRule, refs, ruleCheck, ruleResource) {
const compiledRule = ruleSetCompiler.compileRule(`clonedRuleSet-${++uid}`, rawRule, refs);
// do not process rule with enforce
if (!rawRule.enforce) {
const ruleUse = compiledRule.effects
.filter((effect) => effect.type === 'use')
.map((effect) => effect.value);
// fix conflict with config.loader and config.options when using config.use
delete rawRule.loader;
delete rawRule.options;
rawRule.use = ruleUse;
}
let currentResource;
const res = Object.assign(Object.assign({}, rawRule), { resource: (resources) => {
currentResource = resources;
return true;
}, resourceQuery: (query) => {
if (!query) {
return false;
}
const parsed = qs.parse(query.slice(1));
if (parsed.vue == null) {
return false;
}
if (!ruleCheck(parsed, compiledRule)) {
return false;
}
const fakeResourcePath = ruleResource(parsed, currentResource);
for (const condition of compiledRule.conditions) {
// add support for resourceQuery
const request = condition.property === 'resourceQuery' ? query : fakeResourcePath;
if (condition && !condition.fn(request)) {
return false;
}
}
return true;
} });
delete res.test;
if (rawRule.rules) {
res.rules = rawRule.rules.map((rule) => cloneRule(rule, refs, ruleCheck, ruleResource));
}
if (rawRule.oneOf) {
res.oneOf = rawRule.oneOf.map((rule) => cloneRule(rule, refs, ruleCheck, ruleResource));
}
return res;
}
exports.default = VueLoaderPlugin;

View File

@ -0,0 +1,13 @@
import type { LoaderContext } from 'webpack';
import type { SFCDescriptor, SFCScriptBlock } from 'vue/compiler-sfc';
import type { VueLoaderOptions } from 'src';
export declare const clientCache: WeakMap<SFCDescriptor, SFCScriptBlock | null>;
export declare const typeDepToSFCMap: Map<string, Set<string>>;
/**
* inline template mode can only be enabled if:
* - is production (separate compilation needed for HMR during dev)
* - template has no pre-processor (separate loader chain required)
* - template is not using src
*/
export declare function canInlineTemplate(descriptor: SFCDescriptor, isProd: boolean): boolean;
export declare function resolveScript(descriptor: SFCDescriptor, scopeId: string, options: VueLoaderOptions, loaderContext: LoaderContext<VueLoaderOptions>): SFCScriptBlock | null;

86
app_vue/node_modules/vue-loader/dist/resolveScript.js generated vendored Normal file
View File

@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveScript = exports.canInlineTemplate = exports.typeDepToSFCMap = exports.clientCache = void 0;
const util_1 = require("./util");
const compiler_1 = require("./compiler");
const { compileScript } = compiler_1.compiler;
exports.clientCache = new WeakMap();
const serverCache = new WeakMap();
exports.typeDepToSFCMap = new Map();
/**
* inline template mode can only be enabled if:
* - is production (separate compilation needed for HMR during dev)
* - template has no pre-processor (separate loader chain required)
* - template is not using src
*/
function canInlineTemplate(descriptor, isProd) {
const templateLang = descriptor.template && descriptor.template.lang;
const templateSrc = descriptor.template && descriptor.template.src;
return isProd && !!descriptor.scriptSetup && !templateLang && !templateSrc;
}
exports.canInlineTemplate = canInlineTemplate;
function resolveScript(descriptor, scopeId, options, loaderContext) {
var _a;
if (!descriptor.script && !descriptor.scriptSetup) {
return null;
}
const isProd = loaderContext.mode === 'production' || process.env.NODE_ENV === 'production';
const isServer = (_a = options.isServerBuild) !== null && _a !== void 0 ? _a : loaderContext.target === 'node';
const enableInline = canInlineTemplate(descriptor, isProd);
const cacheToUse = isServer ? serverCache : exports.clientCache;
const cached = cacheToUse.get(descriptor);
if (cached) {
return cached;
}
let resolved = null;
let templateCompiler;
if (typeof options.compiler === 'string') {
templateCompiler = require(options.compiler);
}
else {
templateCompiler = options.compiler;
}
try {
resolved = compileScript(descriptor, {
id: scopeId,
isProd,
inlineTemplate: enableInline,
// @ts-ignore this has been removed in 3.4
reactivityTransform: options.reactivityTransform,
propsDestructure: options.propsDestructure,
defineModel: options.defineModel,
babelParserPlugins: options.babelParserPlugins,
templateOptions: {
ssr: isServer,
compiler: templateCompiler,
compilerOptions: Object.assign(Object.assign({}, options.compilerOptions), (0, util_1.resolveTemplateTSOptions)(descriptor, options)),
transformAssetUrls: options.transformAssetUrls || true,
},
});
}
catch (e) {
loaderContext.emitError(e);
}
if (!isProd && (resolved === null || resolved === void 0 ? void 0 : resolved.deps)) {
for (const [key, sfcs] of exports.typeDepToSFCMap) {
if (sfcs.has(descriptor.filename) && !resolved.deps.includes(key)) {
sfcs.delete(descriptor.filename);
if (!sfcs.size) {
exports.typeDepToSFCMap.delete(key);
}
}
}
for (const dep of resolved.deps) {
const existingSet = exports.typeDepToSFCMap.get(dep);
if (!existingSet) {
exports.typeDepToSFCMap.set(dep, new Set([descriptor.filename]));
}
else {
existingSet.add(descriptor.filename);
}
}
}
cacheToUse.set(descriptor, resolved);
return resolved;
}
exports.resolveScript = resolveScript;

6
app_vue/node_modules/vue-loader/dist/select.d.ts generated vendored Normal file
View File

@ -0,0 +1,6 @@
/// <reference types="node" />
import type { LoaderContext } from 'webpack';
import type { SFCDescriptor } from 'vue/compiler-sfc';
import type { ParsedUrlQuery } from 'querystring';
import type { VueLoaderOptions } from 'src';
export declare function selectBlock(descriptor: SFCDescriptor, scopeId: string, options: VueLoaderOptions, loaderContext: LoaderContext<VueLoaderOptions>, query: ParsedUrlQuery, appendExtension: boolean): void;

41
app_vue/node_modules/vue-loader/dist/select.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.selectBlock = void 0;
const resolveScript_1 = require("./resolveScript");
function selectBlock(descriptor, scopeId, options, loaderContext, query, appendExtension) {
// template
if (query.type === `template`) {
// if we are receiving a query with type it can only come from a *.vue file
// that contains that block, so the block is guaranteed to exist.
const template = descriptor.template;
if (appendExtension) {
loaderContext.resourcePath += '.' + (template.lang || 'html');
}
loaderContext.callback(null, template.content, template.map);
return;
}
// script
if (query.type === `script`) {
const script = (0, resolveScript_1.resolveScript)(descriptor, scopeId, options, loaderContext);
if (appendExtension) {
loaderContext.resourcePath += '.' + (script.lang || 'js');
}
loaderContext.callback(null, script.content, script.map);
return;
}
// styles
if (query.type === `style` && query.index != null) {
const style = descriptor.styles[Number(query.index)];
if (appendExtension) {
loaderContext.resourcePath += '.' + (style.lang || 'css');
}
loaderContext.callback(null, style.content, style.map);
return;
}
// custom
if (query.type === 'custom' && query.index != null) {
const block = descriptor.customBlocks[Number(query.index)];
loaderContext.callback(null, block.content, block.map);
}
}
exports.selectBlock = selectBlock;

View File

@ -0,0 +1,3 @@
import type { LoaderDefinitionFunction } from 'webpack';
declare const StyleInineLoader: LoaderDefinitionFunction;
export default StyleInineLoader;

View File

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const StyleInineLoader = function (source) {
// TODO minify this?
return `export default ${JSON.stringify(source)}`;
};
exports.default = StyleInineLoader;

View File

@ -0,0 +1,3 @@
import type { LoaderDefinitionFunction } from 'webpack';
declare const StylePostLoader: LoaderDefinitionFunction;
export default StylePostLoader;

View File

@ -0,0 +1,51 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 });
const qs = __importStar(require("querystring"));
const compiler_1 = require("./compiler");
const { compileStyle } = compiler_1.compiler;
// This is a post loader that handles scoped CSS transforms.
// Injected right before css-loader by the global pitcher (../pitch.js)
// for any <style scoped> selection requests initiated from within vue files.
const StylePostLoader = function (source, inMap) {
const query = qs.parse(this.resourceQuery.slice(1));
// skip normal CSS files
if (!('vue' in query) || query.type !== 'style' || !query.id) {
this.callback(null, source, inMap);
return;
}
const { code, map, errors } = compileStyle({
source: source,
filename: this.resourcePath,
id: `data-v-${query.id}`,
map: inMap,
scoped: !!query.scoped,
trim: true,
isProd: this.mode === 'production' || process.env.NODE_ENV === 'production',
});
if (errors.length) {
this.callback(errors[0]);
}
else {
this.callback(null, code, map);
}
};
exports.default = StylePostLoader;

View File

@ -0,0 +1,3 @@
import type { LoaderDefinitionFunction } from 'webpack';
declare const TemplateLoader: LoaderDefinitionFunction;
export default TemplateLoader;

91
app_vue/node_modules/vue-loader/dist/templateLoader.js generated vendored Normal file
View File

@ -0,0 +1,91 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 });
const qs = __importStar(require("querystring"));
const formatError_1 = require("./formatError");
const descriptorCache_1 = require("./descriptorCache");
const resolveScript_1 = require("./resolveScript");
const util_1 = require("./util");
const compiler_1 = require("./compiler");
const { compileTemplate } = compiler_1.compiler;
// Loader that compiles raw template into JavaScript functions.
// This is injected by the global pitcher (../pitch) for template
// selection requests initiated from vue files.
const TemplateLoader = function (source, inMap) {
var _a;
source = String(source);
const loaderContext = this;
// although this is not the main vue-loader, we can get access to the same
// vue-loader options because we've set an ident in the plugin and used that
// ident to create the request for this loader in the pitcher.
const options = ((0, util_1.getOptions)(loaderContext) || {});
const isServer = (_a = options.isServerBuild) !== null && _a !== void 0 ? _a : loaderContext.target === 'node';
const isProd = loaderContext.mode === 'production' || process.env.NODE_ENV === 'production';
const query = qs.parse(loaderContext.resourceQuery.slice(1));
const scopeId = query.id;
const descriptor = (0, descriptorCache_1.getDescriptor)(loaderContext.resourcePath, options.compilerOptions);
const script = (0, resolveScript_1.resolveScript)(descriptor, query.id, options, loaderContext);
let templateCompiler;
if (typeof options.compiler === 'string') {
templateCompiler = require(options.compiler);
}
else {
templateCompiler = options.compiler;
}
const compiled = compileTemplate({
source,
ast: descriptor.template && !descriptor.template.lang
? descriptor.template.ast
: undefined,
filename: loaderContext.resourcePath,
inMap,
id: scopeId,
scoped: !!query.scoped,
slotted: descriptor.slotted,
isProd,
ssr: isServer,
ssrCssVars: descriptor.cssVars,
compiler: templateCompiler,
compilerOptions: Object.assign(Object.assign(Object.assign({}, options.compilerOptions), { scopeId: query.scoped ? `data-v-${scopeId}` : undefined, bindingMetadata: script ? script.bindings : undefined }), (0, util_1.resolveTemplateTSOptions)(descriptor, options)),
transformAssetUrls: options.transformAssetUrls || true,
});
// tips
if (compiled.tips.length) {
compiled.tips.forEach((tip) => {
loaderContext.emitWarning(new Error(tip));
});
}
// errors
if (compiled.errors && compiled.errors.length) {
compiled.errors.forEach((err) => {
if (typeof err === 'string') {
loaderContext.emitError(new Error(err));
}
else {
(0, formatError_1.formatError)(err, inMap ? inMap.sourcesContent[0] : source, loaderContext.resourcePath);
loaderContext.emitError(err);
}
});
}
const { code, map } = compiled;
loaderContext.callback(null, code, map);
};
exports.default = TemplateLoader;

9
app_vue/node_modules/vue-loader/dist/util.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
import type { Compiler, LoaderContext } from 'webpack';
import type { SFCDescriptor, CompilerOptions } from 'vue/compiler-sfc';
import type { VueLoaderOptions } from '.';
export declare function needHMR(vueLoaderOptions: VueLoaderOptions, compilerOptions: Compiler['options']): boolean;
export declare function resolveTemplateTSOptions(descriptor: SFCDescriptor, options: VueLoaderOptions): CompilerOptions | null;
export declare function getOptions(loaderContext: LoaderContext<VueLoaderOptions>): any;
export declare function stringifyRequest(loaderContext: LoaderContext<VueLoaderOptions>, request: string): string;
export declare function genMatchResource(context: LoaderContext<VueLoaderOptions>, resourcePath: string, resourceQuery?: string, lang?: string): string;
export declare const testWebpack5: (compiler?: Compiler | undefined) => boolean;

178
app_vue/node_modules/vue-loader/dist/util.js generated vendored Normal file
View File

@ -0,0 +1,178 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.testWebpack5 = exports.genMatchResource = exports.stringifyRequest = exports.getOptions = exports.resolveTemplateTSOptions = exports.needHMR = void 0;
const querystring_1 = __importDefault(require("querystring"));
const path = __importStar(require("path"));
function needHMR(vueLoaderOptions, compilerOptions) {
var _a;
const isServer = (_a = vueLoaderOptions.isServerBuild) !== null && _a !== void 0 ? _a : compilerOptions.target === 'node';
const isProduction = compilerOptions.mode === 'production' ||
process.env.NODE_ENV === 'production';
return !isServer && !isProduction && vueLoaderOptions.hotReload !== false;
}
exports.needHMR = needHMR;
function resolveTemplateTSOptions(descriptor, options) {
var _a, _b, _c;
if (options.enableTsInTemplate === false)
return null;
const lang = ((_a = descriptor.script) === null || _a === void 0 ? void 0 : _a.lang) || ((_b = descriptor.scriptSetup) === null || _b === void 0 ? void 0 : _b.lang);
const isTS = !!(lang && /tsx?$/.test(lang));
let expressionPlugins = ((_c = options === null || options === void 0 ? void 0 : options.compilerOptions) === null || _c === void 0 ? void 0 : _c.expressionPlugins) || [];
if (isTS && !expressionPlugins.includes('typescript')) {
expressionPlugins = [...expressionPlugins, 'typescript'];
}
return {
isTS,
expressionPlugins,
};
}
exports.resolveTemplateTSOptions = resolveTemplateTSOptions;
// loader utils removed getOptions in 3.x, but it's not available on webpack 4
// loader context
function getOptions(loaderContext) {
const query = loaderContext.query;
if (typeof query === 'string' && query !== '') {
return parseQuery(query);
}
if (!query || typeof query !== 'object') {
// Not object-like queries are not supported.
return {};
}
return query;
}
exports.getOptions = getOptions;
const specialValues = {
null: null,
true: true,
false: false,
};
function parseQuery(query) {
if (query.substr(0, 1) !== '?') {
throw new Error("A valid query string passed to parseQuery should begin with '?'");
}
query = query.substr(1);
if (!query) {
return {};
}
if (query.substr(0, 1) === '{' && query.substr(-1) === '}') {
return JSON.parse(query);
}
const queryArgs = query.split(/[,&]/g);
const result = Object.create(null);
queryArgs.forEach((arg) => {
const idx = arg.indexOf('=');
if (idx >= 0) {
let name = arg.substr(0, idx);
let value = decodeURIComponent(arg.substr(idx + 1));
// eslint-disable-next-line no-prototype-builtins
if (specialValues.hasOwnProperty(value)) {
value = specialValues[value];
}
if (name.substr(-2) === '[]') {
name = decodeURIComponent(name.substr(0, name.length - 2));
if (!Array.isArray(result[name])) {
result[name] = [];
}
result[name].push(value);
}
else {
name = decodeURIComponent(name);
result[name] = value;
}
}
else {
if (arg.substr(0, 1) === '-') {
result[decodeURIComponent(arg.substr(1))] = false;
}
else if (arg.substr(0, 1) === '+') {
result[decodeURIComponent(arg.substr(1))] = true;
}
else {
result[decodeURIComponent(arg)] = true;
}
}
});
return result;
}
const matchRelativePath = /^\.\.?[/\\]/;
function isAbsolutePath(str) {
return path.posix.isAbsolute(str) || path.win32.isAbsolute(str);
}
function isRelativePath(str) {
return matchRelativePath.test(str);
}
function stringifyRequest(loaderContext, request) {
const splitted = request.split('!');
const context = loaderContext.context ||
// @ts-ignore
(loaderContext.options && loaderContext.options.context);
return JSON.stringify(splitted
.map((part) => {
// First, separate singlePath from query, because the query might contain paths again
const splittedPart = part.match(/^(.*?)(\?.*)/);
const query = splittedPart ? splittedPart[2] : '';
let singlePath = splittedPart ? splittedPart[1] : part;
if (isAbsolutePath(singlePath) && context) {
singlePath = path.relative(context, singlePath);
if (isAbsolutePath(singlePath)) {
// If singlePath still matches an absolute path, singlePath was on a different drive than context.
// In this case, we leave the path platform-specific without replacing any separators.
// @see https://github.com/webpack/loader-utils/pull/14
return singlePath + query;
}
if (isRelativePath(singlePath) === false) {
// Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
singlePath = './' + singlePath;
}
}
return singlePath.replace(/\\/g, '/') + query;
})
.join('!'));
}
exports.stringifyRequest = stringifyRequest;
function genMatchResource(context, resourcePath, resourceQuery, lang) {
resourceQuery = resourceQuery || '';
const loaders = [];
const parsedQuery = querystring_1.default.parse(resourceQuery.slice(1));
// process non-external resources
if ('vue' in parsedQuery && !('external' in parsedQuery)) {
const currentRequest = context.loaders
.slice(context.loaderIndex)
.map((obj) => obj.request);
loaders.push(...currentRequest);
}
const loaderString = loaders.join('!');
return `${resourcePath}${lang ? `.${lang}` : ''}${resourceQuery}!=!${loaderString ? `${loaderString}!` : ''}${resourcePath}${resourceQuery}`;
}
exports.genMatchResource = genMatchResource;
const testWebpack5 = (compiler) => {
var _a;
if (!compiler) {
return false;
}
const webpackVersion = (_a = compiler === null || compiler === void 0 ? void 0 : compiler.webpack) === null || _a === void 0 ? void 0 : _a.version;
return Boolean(webpackVersion && Number(webpackVersion.split('.')[0]) > 4);
};
exports.testWebpack5 = testWebpack5;

View File

@ -0,0 +1,415 @@
/**
Basic foreground colors.
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
*/
declare type ForegroundColor =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
| 'grey'
| 'blackBright'
| 'redBright'
| 'greenBright'
| 'yellowBright'
| 'blueBright'
| 'magentaBright'
| 'cyanBright'
| 'whiteBright';
/**
Basic background colors.
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
*/
declare type BackgroundColor =
| 'bgBlack'
| 'bgRed'
| 'bgGreen'
| 'bgYellow'
| 'bgBlue'
| 'bgMagenta'
| 'bgCyan'
| 'bgWhite'
| 'bgGray'
| 'bgGrey'
| 'bgBlackBright'
| 'bgRedBright'
| 'bgGreenBright'
| 'bgYellowBright'
| 'bgBlueBright'
| 'bgMagentaBright'
| 'bgCyanBright'
| 'bgWhiteBright';
/**
Basic colors.
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
*/
declare type Color = ForegroundColor | BackgroundColor;
declare type Modifiers =
| 'reset'
| 'bold'
| 'dim'
| 'italic'
| 'underline'
| 'inverse'
| 'hidden'
| 'strikethrough'
| 'visible';
declare namespace chalk {
/**
Levels:
- `0` - All colors disabled.
- `1` - Basic 16 colors support.
- `2` - ANSI 256 colors support.
- `3` - Truecolor 16 million colors support.
*/
type Level = 0 | 1 | 2 | 3;
interface Options {
/**
Specify the color support for Chalk.
By default, color support is automatically detected based on the environment.
Levels:
- `0` - All colors disabled.
- `1` - Basic 16 colors support.
- `2` - ANSI 256 colors support.
- `3` - Truecolor 16 million colors support.
*/
level?: Level;
}
/**
Return a new Chalk instance.
*/
type Instance = new (options?: Options) => Chalk;
/**
Detect whether the terminal supports color.
*/
interface ColorSupport {
/**
The color level used by Chalk.
*/
level: Level;
/**
Return whether Chalk supports basic 16 colors.
*/
hasBasic: boolean;
/**
Return whether Chalk supports ANSI 256 colors.
*/
has256: boolean;
/**
Return whether Chalk supports Truecolor 16 million colors.
*/
has16m: boolean;
}
interface ChalkFunction {
/**
Use a template string.
@remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
@example
```
import chalk = require('chalk');
log(chalk`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
```
@example
```
import chalk = require('chalk');
log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
```
*/
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
(...text: unknown[]): string;
}
interface Chalk extends ChalkFunction {
/**
Return a new Chalk instance.
*/
Instance: Instance;
/**
The color support for Chalk.
By default, color support is automatically detected based on the environment.
Levels:
- `0` - All colors disabled.
- `1` - Basic 16 colors support.
- `2` - ANSI 256 colors support.
- `3` - Truecolor 16 million colors support.
*/
level: Level;
/**
Use HEX value to set text color.
@param color - Hexadecimal value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.hex('#DEADED');
```
*/
hex(color: string): Chalk;
/**
Use keyword color value to set text color.
@param color - Keyword value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.keyword('orange');
```
*/
keyword(color: string): Chalk;
/**
Use RGB values to set text color.
*/
rgb(red: number, green: number, blue: number): Chalk;
/**
Use HSL values to set text color.
*/
hsl(hue: number, saturation: number, lightness: number): Chalk;
/**
Use HSV values to set text color.
*/
hsv(hue: number, saturation: number, value: number): Chalk;
/**
Use HWB values to set text color.
*/
hwb(hue: number, whiteness: number, blackness: number): Chalk;
/**
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
30 <= code && code < 38 || 90 <= code && code < 98
For example, 31 for red, 91 for redBright.
*/
ansi(code: number): Chalk;
/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
*/
ansi256(index: number): Chalk;
/**
Use HEX value to set background color.
@param color - Hexadecimal value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.bgHex('#DEADED');
```
*/
bgHex(color: string): Chalk;
/**
Use keyword color value to set background color.
@param color - Keyword value representing the desired color.
@example
```
import chalk = require('chalk');
chalk.bgKeyword('orange');
```
*/
bgKeyword(color: string): Chalk;
/**
Use RGB values to set background color.
*/
bgRgb(red: number, green: number, blue: number): Chalk;
/**
Use HSL values to set background color.
*/
bgHsl(hue: number, saturation: number, lightness: number): Chalk;
/**
Use HSV values to set background color.
*/
bgHsv(hue: number, saturation: number, value: number): Chalk;
/**
Use HWB values to set background color.
*/
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
/**
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
30 <= code && code < 38 || 90 <= code && code < 98
For example, 31 for red, 91 for redBright.
Use the foreground code, not the background code (for example, not 41, nor 101).
*/
bgAnsi(code: number): Chalk;
/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
*/
bgAnsi256(index: number): Chalk;
/**
Modifier: Resets the current color chain.
*/
readonly reset: Chalk;
/**
Modifier: Make text bold.
*/
readonly bold: Chalk;
/**
Modifier: Emitting only a small amount of light.
*/
readonly dim: Chalk;
/**
Modifier: Make text italic. (Not widely supported)
*/
readonly italic: Chalk;
/**
Modifier: Make text underline. (Not widely supported)
*/
readonly underline: Chalk;
/**
Modifier: Inverse background and foreground colors.
*/
readonly inverse: Chalk;
/**
Modifier: Prints the text, but makes it invisible.
*/
readonly hidden: Chalk;
/**
Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
*/
readonly strikethrough: Chalk;
/**
Modifier: Prints the text only when Chalk has a color support level > 0.
Can be useful for things that are purely cosmetic.
*/
readonly visible: Chalk;
readonly black: Chalk;
readonly red: Chalk;
readonly green: Chalk;
readonly yellow: Chalk;
readonly blue: Chalk;
readonly magenta: Chalk;
readonly cyan: Chalk;
readonly white: Chalk;
/*
Alias for `blackBright`.
*/
readonly gray: Chalk;
/*
Alias for `blackBright`.
*/
readonly grey: Chalk;
readonly blackBright: Chalk;
readonly redBright: Chalk;
readonly greenBright: Chalk;
readonly yellowBright: Chalk;
readonly blueBright: Chalk;
readonly magentaBright: Chalk;
readonly cyanBright: Chalk;
readonly whiteBright: Chalk;
readonly bgBlack: Chalk;
readonly bgRed: Chalk;
readonly bgGreen: Chalk;
readonly bgYellow: Chalk;
readonly bgBlue: Chalk;
readonly bgMagenta: Chalk;
readonly bgCyan: Chalk;
readonly bgWhite: Chalk;
/*
Alias for `bgBlackBright`.
*/
readonly bgGray: Chalk;
/*
Alias for `bgBlackBright`.
*/
readonly bgGrey: Chalk;
readonly bgBlackBright: Chalk;
readonly bgRedBright: Chalk;
readonly bgGreenBright: Chalk;
readonly bgYellowBright: Chalk;
readonly bgBlueBright: Chalk;
readonly bgMagentaBright: Chalk;
readonly bgCyanBright: Chalk;
readonly bgWhiteBright: Chalk;
}
}
/**
Main Chalk object that allows to chain styles together.
Call the last one as a method with a string argument.
Order doesn't matter, and later styles take precedent in case of a conflict.
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
*/
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
supportsColor: chalk.ColorSupport | false;
Level: chalk.Level;
Color: Color;
ForegroundColor: ForegroundColor;
BackgroundColor: BackgroundColor;
Modifiers: Modifiers;
stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
};
export = chalk;

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,68 @@
{
"name": "chalk",
"version": "4.1.2",
"description": "Terminal string styling done right",
"license": "MIT",
"repository": "chalk/chalk",
"funding": "https://github.com/chalk/chalk?sponsor=1",
"main": "source",
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && nyc ava && tsd",
"bench": "matcha benchmark.js"
},
"files": [
"source",
"index.d.ts"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"str",
"ansi",
"style",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"devDependencies": {
"ava": "^2.4.0",
"coveralls": "^3.0.7",
"execa": "^4.0.0",
"import-fresh": "^3.1.0",
"matcha": "^0.7.0",
"nyc": "^15.0.0",
"resolve-from": "^5.0.0",
"tsd": "^0.7.4",
"xo": "^0.28.2"
},
"xo": {
"rules": {
"unicorn/prefer-string-slice": "off",
"unicorn/prefer-includes": "off",
"@typescript-eslint/member-ordering": "off",
"no-redeclare": "off",
"unicorn/string-content": "off",
"unicorn/better-regex": "off"
}
}
}

View File

@ -0,0 +1,341 @@
<h1 align="center">
<br>
<br>
<img width="320" src="media/logo.svg" alt="Chalk">
<br>
<br>
<br>
</h1>
> Terminal string styling done right
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
<br>
---
<div align="center">
<p>
<p>
<sup>
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
</sup>
</p>
<sup>Special thanks to:</sup>
<br>
<br>
<a href="https://standardresume.co/tech">
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
</a>
<br>
<br>
<a href="https://retool.com/?utm_campaign=sindresorhus">
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
</a>
<br>
<br>
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
<div>
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
</div>
<b>All your environment variables, in one place</b>
<div>
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
<br>
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
</div>
</a>
<br>
<a href="https://uibakery.io/?utm_source=chalk&utm_medium=sponsor&utm_campaign=github">
<div>
<img src="https://sindresorhus.com/assets/thanks/uibakery-logo.jpg" width="270" alt="UI Bakery">
</div>
</a>
</p>
</div>
---
<br>
## Highlights
- Expressive API
- Highly performant
- Ability to nest styles
- [256/Truecolor color support](#256-and-truecolor-color-support)
- Auto-detects color support
- Doesn't extend `String.prototype`
- Clean and focused
- Actively maintained
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
## Install
```console
$ npm install chalk
```
## Usage
```js
const chalk = require('chalk');
console.log(chalk.blue('Hello world!'));
```
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
const chalk = require('chalk');
const log = console.log;
// Combine styled and normal strings
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
// Compose multiple styles using the chainable API
log(chalk.blue.bgRed.bold('Hello world!'));
// Pass in multiple arguments
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
// Nest styles
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
// Nest styles of the same type even (color, underline, background)
log(chalk.green(
'I am a green line ' +
chalk.blue.underline.bold('with a blue substring') +
' that becomes green again!'
));
// ES2015 template literal
log(`
CPU: ${chalk.red('90%')}
RAM: ${chalk.green('40%')}
DISK: ${chalk.yellow('70%')}
`);
// ES2015 tagged template literal
log(chalk`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
// Use RGB colors in terminal emulators that support it.
log(chalk.keyword('orange')('Yay for orange colored text!'));
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
log(chalk.hex('#DEADED').bold('Bold gray!'));
```
Easily define your own themes:
```js
const chalk = require('chalk');
const error = chalk.bold.red;
const warning = chalk.keyword('orange');
console.log(error('Error!'));
console.log(warning('Warning!'));
```
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
```js
const name = 'Sindre';
console.log(chalk.green('Hello %s'), name);
//=> 'Hello Sindre'
```
## API
### chalk.`<style>[.<style>...](string, [string...])`
Example: `chalk.red.bold.underline('Hello', 'world');`
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
Multiple arguments will be separated by space.
### chalk.level
Specifies the level of color support.
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
If you need to change this in a reusable module, create a new instance:
```js
const ctx = new chalk.Instance({level: 0});
```
| Level | Description |
| :---: | :--- |
| `0` | All colors disabled |
| `1` | Basic color support (16 colors) |
| `2` | 256 color support |
| `3` | Truecolor support (16 million colors) |
### chalk.supportsColor
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
### chalk.stderr and chalk.stderr.supportsColor
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
## Styles
### Modifiers
- `reset` - Resets the current color chain.
- `bold` - Make text bold.
- `dim` - Emitting only a small amount of light.
- `italic` - Make text italic. *(Not widely supported)*
- `underline` - Make text underline. *(Not widely supported)*
- `inverse`- Inverse background and foreground colors.
- `hidden` - Prints the text, but makes it invisible.
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `blackBright` (alias: `gray`, `grey`)
- `redBright`
- `greenBright`
- `yellowBright`
- `blueBright`
- `magentaBright`
- `cyanBright`
- `whiteBright`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
- `bgRedBright`
- `bgGreenBright`
- `bgYellowBright`
- `bgBlueBright`
- `bgMagentaBright`
- `bgCyanBright`
- `bgWhiteBright`
## Tagged template literal
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
```js
const chalk = require('chalk');
const miles = 18;
const calculateFeet = miles => miles * 5280;
console.log(chalk`
There are {bold 5280 feet} in a mile.
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
`);
```
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
```js
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
```
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
## 256 and Truecolor color support
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
Examples:
- `chalk.hex('#DEADED').underline('Hello, world!')`
- `chalk.keyword('orange')('Some orange text')`
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
- `chalk.bgKeyword('orange')('Some orange text')`
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
The following color models can be used:
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
## Windows
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
## Origin story
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
## chalk for enterprise
Available as part of the Tidelift Subscription.
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

View File

@ -0,0 +1,229 @@
'use strict';
const ansiStyles = require('ansi-styles');
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
const {
stringReplaceAll,
stringEncaseCRLFWithFirstIndex
} = require('./util');
const {isArray} = Array;
// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = [
'ansi',
'ansi',
'ansi256',
'ansi16m'
];
const styles = Object.create(null);
const applyOptions = (object, options = {}) => {
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
throw new Error('The `level` option should be an integer from 0 to 3');
}
// Detect level if not set manually
const colorLevel = stdoutColor ? stdoutColor.level : 0;
object.level = options.level === undefined ? colorLevel : options.level;
};
class ChalkClass {
constructor(options) {
// eslint-disable-next-line no-constructor-return
return chalkFactory(options);
}
}
const chalkFactory = options => {
const chalk = {};
applyOptions(chalk, options);
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
Object.setPrototypeOf(chalk, Chalk.prototype);
Object.setPrototypeOf(chalk.template, chalk);
chalk.template.constructor = () => {
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
};
chalk.template.Instance = ChalkClass;
return chalk.template;
};
function Chalk(options) {
return chalkFactory(options);
}
for (const [styleName, style] of Object.entries(ansiStyles)) {
styles[styleName] = {
get() {
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
Object.defineProperty(this, styleName, {value: builder});
return builder;
}
};
}
styles.visible = {
get() {
const builder = createBuilder(this, this._styler, true);
Object.defineProperty(this, 'visible', {value: builder});
return builder;
}
};
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
for (const model of usedModels) {
styles[model] = {
get() {
const {level} = this;
return function (...arguments_) {
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
return createBuilder(this, styler, this._isEmpty);
};
}
};
}
for (const model of usedModels) {
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
styles[bgModel] = {
get() {
const {level} = this;
return function (...arguments_) {
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
return createBuilder(this, styler, this._isEmpty);
};
}
};
}
const proto = Object.defineProperties(() => {}, {
...styles,
level: {
enumerable: true,
get() {
return this._generator.level;
},
set(level) {
this._generator.level = level;
}
}
});
const createStyler = (open, close, parent) => {
let openAll;
let closeAll;
if (parent === undefined) {
openAll = open;
closeAll = close;
} else {
openAll = parent.openAll + open;
closeAll = close + parent.closeAll;
}
return {
open,
close,
openAll,
closeAll,
parent
};
};
const createBuilder = (self, _styler, _isEmpty) => {
const builder = (...arguments_) => {
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
return applyStyle(builder, chalkTag(builder, ...arguments_));
}
// Single argument is hot path, implicit coercion is faster than anything
// eslint-disable-next-line no-implicit-coercion
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
};
// We alter the prototype because we must return a function, but there is
// no way to create a function with a different prototype
Object.setPrototypeOf(builder, proto);
builder._generator = self;
builder._styler = _styler;
builder._isEmpty = _isEmpty;
return builder;
};
const applyStyle = (self, string) => {
if (self.level <= 0 || !string) {
return self._isEmpty ? '' : string;
}
let styler = self._styler;
if (styler === undefined) {
return string;
}
const {openAll, closeAll} = styler;
if (string.indexOf('\u001B') !== -1) {
while (styler !== undefined) {
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
string = stringReplaceAll(string, styler.close, styler.open);
styler = styler.parent;
}
}
// We can move both next actions out of loop, because remaining actions in loop won't have
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
const lfIndex = string.indexOf('\n');
if (lfIndex !== -1) {
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
}
return openAll + string + closeAll;
};
let template;
const chalkTag = (chalk, ...strings) => {
const [firstString] = strings;
if (!isArray(firstString) || !isArray(firstString.raw)) {
// If chalk() was called by itself or with a string,
// return the string itself as a string.
return strings.join(' ');
}
const arguments_ = strings.slice(1);
const parts = [firstString.raw[0]];
for (let i = 1; i < firstString.length; i++) {
parts.push(
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
String(firstString.raw[i])
);
}
if (template === undefined) {
template = require('./templates');
}
return template(chalk, parts.join(''));
};
Object.defineProperties(Chalk.prototype, styles);
const chalk = Chalk(); // eslint-disable-line new-cap
chalk.supportsColor = stdoutColor;
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
chalk.stderr.supportsColor = stderrColor;
module.exports = chalk;

View File

@ -0,0 +1,134 @@
'use strict';
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
const ESCAPES = new Map([
['n', '\n'],
['r', '\r'],
['t', '\t'],
['b', '\b'],
['f', '\f'],
['v', '\v'],
['0', '\0'],
['\\', '\\'],
['e', '\u001B'],
['a', '\u0007']
]);
function unescape(c) {
const u = c[0] === 'u';
const bracket = c[1] === '{';
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
return String.fromCharCode(parseInt(c.slice(1), 16));
}
if (u && bracket) {
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
}
return ESCAPES.get(c) || c;
}
function parseArguments(name, arguments_) {
const results = [];
const chunks = arguments_.trim().split(/\s*,\s*/g);
let matches;
for (const chunk of chunks) {
const number = Number(chunk);
if (!Number.isNaN(number)) {
results.push(number);
} else if ((matches = chunk.match(STRING_REGEX))) {
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
} else {
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
}
}
return results;
}
function parseStyle(style) {
STYLE_REGEX.lastIndex = 0;
const results = [];
let matches;
while ((matches = STYLE_REGEX.exec(style)) !== null) {
const name = matches[1];
if (matches[2]) {
const args = parseArguments(name, matches[2]);
results.push([name].concat(args));
} else {
results.push([name]);
}
}
return results;
}
function buildStyle(chalk, styles) {
const enabled = {};
for (const layer of styles) {
for (const style of layer.styles) {
enabled[style[0]] = layer.inverse ? null : style.slice(1);
}
}
let current = chalk;
for (const [styleName, styles] of Object.entries(enabled)) {
if (!Array.isArray(styles)) {
continue;
}
if (!(styleName in current)) {
throw new Error(`Unknown Chalk style: ${styleName}`);
}
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
}
return current;
}
module.exports = (chalk, temporary) => {
const styles = [];
const chunks = [];
let chunk = [];
// eslint-disable-next-line max-params
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
if (escapeCharacter) {
chunk.push(unescape(escapeCharacter));
} else if (style) {
const string = chunk.join('');
chunk = [];
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
styles.push({inverse, styles: parseStyle(style)});
} else if (close) {
if (styles.length === 0) {
throw new Error('Found extraneous } in Chalk template literal');
}
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
chunk = [];
styles.pop();
} else {
chunk.push(character);
}
});
chunks.push(chunk.join(''));
if (styles.length > 0) {
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
throw new Error(errMessage);
}
return chunks.join('');
};

View File

@ -0,0 +1,39 @@
'use strict';
const stringReplaceAll = (string, substring, replacer) => {
let index = string.indexOf(substring);
if (index === -1) {
return string;
}
const substringLength = substring.length;
let endIndex = 0;
let returnValue = '';
do {
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
endIndex = index + substringLength;
index = string.indexOf(substring, endIndex);
} while (index !== -1);
returnValue += string.substr(endIndex);
return returnValue;
};
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
let endIndex = 0;
let returnValue = '';
do {
const gotCR = string[index - 1] === '\r';
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
endIndex = index + 1;
index = string.indexOf('\n', endIndex);
} while (index !== -1);
returnValue += string.substr(endIndex);
return returnValue;
};
module.exports = {
stringReplaceAll,
stringEncaseCRLFWithFirstIndex
};

102
app_vue/node_modules/vue-loader/package.json generated vendored Normal file
View File

@ -0,0 +1,102 @@
{
"name": "vue-loader",
"version": "17.4.2",
"license": "MIT",
"author": "Evan You",
"repository": "vuejs/vue-loader",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"dev": "tsc --watch",
"build": "tsc",
"pretest": "tsc",
"test": "jest",
"pretest:match-resource": "tsc",
"test:match-resource": "INLINE_MATCH_RESOURCE=true jest",
"pretest:webpack4": "tsc",
"test:webpack4": "WEBPACK4=true jest",
"dev-example": "node example/devServer.js --config example/webpack.config.js --inline --hot",
"build-example": "rm -rf example/dist && webpack --config example/webpack.config.js --env.prod",
"build-example-ssr": "rm -rf example/dist-ssr && webpack --config example/webpack.config.js --env.prod --env.ssr && node example/ssr.js",
"lint": "prettier --write --parser typescript \"{src,test}/**/*.{j,t}s\"",
"prepublishOnly": "tsc && conventional-changelog -p angular -i CHANGELOG.md -s -r 2"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.js": [
"prettier --write"
],
"*.ts": [
"prettier --parser=typescript --write"
]
},
"dependencies": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"watchpack": "^2.4.0"
},
"peerDependencies": {
"webpack": "^4.1.0 || ^5.0.0-0"
},
"peerDependenciesMeta": {
"@vue/compiler-sfc": {
"optional": true
},
"vue": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.11.5",
"@intlify/vue-i18n-loader": "^3.0.0",
"@types/estree": "^0.0.45",
"@types/hash-sum": "^1.0.0",
"@types/jest": "^26.0.13",
"@types/jsdom": "^16.2.13",
"@types/mini-css-extract-plugin": "^0.9.1",
"@types/webpack-merge": "^4.1.5",
"babel-loader": "^8.1.0",
"cache-loader": "^4.1.0",
"conventional-changelog-cli": "^2.1.1",
"css-loader": "^4.3.0",
"file-loader": "^6.1.0",
"html-webpack-plugin": "^4.5.0",
"html-webpack-plugin-v5": "npm:html-webpack-plugin@^5.3.2",
"jest": "^26.4.1",
"jsdom": "^16.4.0",
"lint-staged": "^10.3.0",
"markdown-loader": "^6.0.0",
"memfs": "^3.1.2",
"mini-css-extract-plugin": "^1.6.2",
"normalize-newline": "^3.0.0",
"null-loader": "^4.0.1",
"postcss-loader": "^4.0.4",
"prettier": "^2.1.1",
"pug": "^2.0.0",
"pug-plain-loader": "^1.0.0",
"source-map": "^0.6.1",
"style-loader": "^2.0.0",
"stylus": "^0.54.7",
"stylus-loader": "^4.1.1",
"sugarss": "^3.0.1",
"ts-jest": "^26.2.0",
"ts-loader": "^8.0.6",
"ts-loader-v9": "npm:ts-loader@^9.2.4",
"typescript": "^4.4.3",
"url-loader": "^4.1.0",
"vue": "^3.4.3",
"vue-i18n": "^9.1.7",
"webpack": "^5.79.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.3",
"webpack-merge": "^5.1.4",
"webpack4": "npm:webpack@^4.46.0",
"yorkie": "^2.0.0"
}
}