0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00

Update Vite to latest (#1597)

This commit is contained in:
Drew Powers 2021-10-19 12:47:36 -06:00 committed by Drew Powers
parent 94a513adc6
commit a1c594fc95
24 changed files with 3561 additions and 437 deletions

View file

View file

@ -66,7 +66,6 @@
"@babel/traverse": "^7.15.4",
"@web/rollup-plugin-html": "^1.10.1",
"astring": "^1.7.5",
"cheerio": "^1.0.0-rc.10",
"ci-info": "^3.2.0",
"connect": "^3.7.0",
"es-module-lexer": "^0.7.1",
@ -92,7 +91,7 @@
"strip-indent": "^4.0.0",
"supports-esm": "^1.0.0",
"tiny-glob": "^0.2.8",
"vite": "^2.6.7",
"vite": "^2.6.10",
"yargs-parser": "^20.2.9",
"zod": "^3.8.1"
},
@ -110,7 +109,7 @@
"@types/yargs-parser": "^20.2.1",
"chai": "^4.3.4",
"cheerio": "^1.0.0-rc.10",
"mocha": "^9.1.2"
"mocha": "^9.1.3"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0",

View file

@ -4,13 +4,11 @@ import type { AstroConfig, ComponentInstance, GetStaticPathsResult, Params, Prop
import type { AstroGlobal, TopLevelAstro, SSRResult } from '../../@types/astro-runtime';
import type { LogOptions } from '../logger';
import cheerio from 'cheerio';
import * as eslexer from 'es-module-lexer';
import { fileURLToPath } from 'url';
import fs from 'fs';
import path from 'path';
import { renderPage, renderSlot } from '../../runtime/server/index.js';
import { parseNpmName, canonicalURL as getCanonicalURL, codeFrame } from '../util.js';
import { canonicalURL as getCanonicalURL, codeFrame } from '../util.js';
import { generatePaginateFunction } from './paginate.js';
import { getParams, validateGetStaticPathsModule, validateGetStaticPathsResult } from './routing.js';
@ -35,10 +33,6 @@ interface SSROptions {
viteServer: ViteDevServer;
}
// note: not every request has a Vite browserHash. if we ever receive one, hang onto it
// this prevents client-side errors such as the "double React bug" (https://reactjs.org/warnings/invalid-hook-call-warning.html#mismatching-versions-of-react-and-react-dom)
let browserHash: string | undefined;
const cache = new Map<string, Promise<Renderer>>();
// TODO: improve validation and error handling here.
@ -117,11 +111,7 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
}
// 3. render page
if (!browserHash && (viteServer as any)._optimizeDepsMetadata?.browserHash) browserHash = (viteServer as any)._optimizeDepsMetadata.browserHash; // note: this is "private" and may change over time
const fullURL = new URL(pathname, origin);
const Component = await mod.default;
const ext = path.posix.extname(filePath.pathname);
if (!Component) throw new Error(`Expected an exported Astro component but received typeof ${typeof Component}`);
if (!Component.isAstroComponentFactory) throw new Error(`Unable to SSR non-Astro component (${route?.component})`);
@ -145,8 +135,8 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
},
slots: Object.fromEntries(Object.entries(slots || {}).map(([slotName]) => [slotName, true])),
privateRenderSlotDoNotUse(slotName: string) {
return renderSlot(result, slots ? slots[slotName] : null)
}
return renderSlot(result, slots ? slots[slotName] : null);
},
} as unknown as AstroGlobal;
},
_metadata: { renderers },
@ -156,12 +146,7 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
// 4. modify response
if (mode === 'development') {
// inject Astro HMR code
html = injectAstroHMR(html);
// inject Vite HMR code
html = injectViteClient(html);
// replace client hydration scripts
html = resolveNpmImports(html);
html = await viteServer.transformIndexHtml(fileURLToPath(filePath), html, pathname);
}
// 5. finish
@ -189,55 +174,3 @@ ${frame}
throw e;
}
}
/** Injects Vite client code */
function injectViteClient(html: string): string {
return html.replace('<head>', `<head><script type="module" src="/@vite/client"></script>`);
}
/** Injects Astro HMR client code */
function injectAstroHMR(html: string): string {
return html.replace('<head>', `<head><script type="module" src="/@astro/runtime/client/hmr"></script>`);
}
/** Convert npm specifier into Vite URL */
function resolveViteNpmPackage(spec: string): string {
const pkg = parseNpmName(spec);
if (!pkg) return spec;
let viteURL = '/node_modules/.vite/'; // start with /node_modules/.vite
viteURL += `${pkg.name}${pkg.subpath ? pkg.subpath.substr(1) : ''}`.replace(/[\/\.]/g, '_'); // flatten package name by replacing slashes (and dots) with underscores
viteURL += '.js'; // add .js
if (browserHash) viteURL += `?v=${browserHash}`; // add browserHash (if provided)
return viteURL;
}
/** Replaces npm imports with Vite-friendly paths */
function resolveNpmImports(html: string): string {
const $ = cheerio.load(html);
// find all <script type="module">
const moduleScripts = $('script[type="module"]');
if (!moduleScripts.length) return html; // if none, return
// for each <script>, update all npm imports with Vite-friendly imports
moduleScripts.each((_, el) => {
let code = $(el).html() || '';
if (!code || $(el).attr('src')) return;
try {
const scan = () => eslexer.parse(code)[0].filter(({ n }) => n && parseNpmName(n));
let specs = scan();
while (specs.length) {
const next = specs[0];
let pkgName = resolveViteNpmPackage(next.n as string);
if (next.d !== -1) pkgName = JSON.stringify(pkgName); // if dynamic import, stringify
code = code.substring(0, next.s) + pkgName + code.substring(next.e);
specs = scan();
}
$(el).html(code);
} catch (err) {
// if invalid JS, ignore (error will be thrown elsewhere)
}
});
return $.html();
}

View file

@ -59,5 +59,17 @@ export default function astro({ config, devServer }: AstroPluginOptions): Plugin
return devServer.handleHotUpdate(context);
}
},
transformIndexHtml(html) {
return [
{
injectTo: 'head-prepend',
tag: 'script',
attrs: {
type: 'module',
src: '/@astro/runtime/client/hmr',
},
},
];
},
};
}

View file

@ -1,5 +1,5 @@
import type { Plugin } from '../core/vite';
import type { TransformResult } from 'rollup';
import type { Plugin } from '../core/vite';
import type { AstroConfig, Renderer } from '../@types/astro-core';
import type { LogOptions } from '../core/logger';

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
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.

2150
packages/astro/vendor/vite/LICENSE.md vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -106,8 +106,8 @@ code {
<pre class="stack"></pre>
<div class="tip">
Click outside or fix the code to dismiss.<br>
You can also disable this overlay with
<code>hmr: { overlay: false }</code> in <code>vite.config.js.</code>
You can also disable this overlay by setting
<code>server.hmr.overlay</code> to <code>false</code> in <code>vite.config.js.</code>
</div>
</div>
`;

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
'use strict';
var build = require('./dep-d8f4aa6e.js');
var build = require('./dep-35df7f96.js');
var require$$1 = require('crypto');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
@ -29179,4 +29179,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
}, [selfsigned]);
exports.index = index;
//# sourceMappingURL=dep-76a5a694.js.map
//# sourceMappingURL=dep-34d2edc0.js.map

View file

@ -90,155 +90,155 @@ function commonjsRequire (path) {
var ansiStyles$2 = {exports: {}};
var colorName$1 = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
var colorName$1 = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};
/* MIT license */
@ -20248,7 +20248,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
replacer: urlReplacer
}));
if (isModule) {
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-077e5c0c.js'); }).then(function (n) { return n.index; })).default({
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-dab866a6.js'); }).then(function (n) { return n.index; })).default({
...modulesOptions,
getJSON(cssFileName, _modules, outputFileName) {
modules = _modules;
@ -21213,7 +21213,7 @@ const assetAttrsConfig = {
const isAsyncScriptMap = new WeakMap();
async function traverseHtml(html, filePath, visitor) {
// lazy load compiler
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-68d11c39.js'); }).then(function (n) { return n.compilerDom_cjs; });
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-a5b4350d.js'); }).then(function (n) { return n.compilerDom_cjs; });
// @vue/compiler-core doesn't like lowercase doctypes
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
try {
@ -21596,14 +21596,16 @@ function toPublicPath(filename, config) {
return isExternalUrl(filename) ? filename : config.base + filename;
}
const headInjectRE = /([ \t]*)<\/head>/;
const headPrependInjectRE = [/([ \t]*)<head[^>]*>/, /<!doctype html>/i];
const headPrependInjectRE = /([ \t]*)<head[^>]*>/;
const doctypePrependInjectRE = /<!doctype html>/i;
function injectToHead(html, tags, prepend = false) {
if (prepend) {
// inject after head or doctype
for (const re of headPrependInjectRE) {
if (re.test(html)) {
return html.replace(re, (match, p1) => `${match}\n${serializeTags(tags, incrementIndent(p1))}`);
}
if (headPrependInjectRE.test(html)) {
return html.replace(headPrependInjectRE, (match, p1) => `${match}\n${serializeTags(tags, incrementIndent(p1))}`);
}
else if (doctypePrependInjectRE.test(html)) {
return html.replace(doctypePrependInjectRE, `$&\n${serializeTags(tags)}`);
}
}
else {
@ -49058,7 +49060,7 @@ function readFileIfExists(value) {
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
*/
async function createCertificate() {
const { generate } = await Promise.resolve().then(function () { return require('./dep-76a5a694.js'); }).then(function (n) { return n.index; });
const { generate } = await Promise.resolve().then(function () { return require('./dep-34d2edc0.js'); }).then(function (n) { return n.index; });
const pems = generate(null, {
algorithm: 'sha256',
days: 30,
@ -60347,155 +60349,155 @@ var ansiStyles = {exports: {}};
var conversions$2 = {exports: {}};
var colorName = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
var colorName = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};
/* MIT license */
@ -66452,7 +66454,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
mod.ssrModule = ssrModule;
const ssrImportMeta = {
// The filesystem URL, matching native Node.js modules
url: require$$0$8.pathToFileURL(mod.file).toString(),
url: require$$0$8.pathToFileURL(mod.file).toString()
};
urlStack = urlStack.concat(url);
const isCircular = (url) => urlStack.includes(url);
@ -66537,10 +66539,15 @@ async function nodeImport(id, importer, config) {
}
// rollup-style default import interop for cjs
function proxyESM(id, mod) {
const defaultExport = mod.__esModule ? mod.default : mod.default ? mod.default : mod
const defaultExport = mod.__esModule
? mod.default
: mod.default
? mod.default
: mod;
return new Proxy(mod, {
get(mod, prop) {
if (prop === 'default') return defaultExport;
if (prop === 'default')
return defaultExport;
return mod[prop];
}
});
@ -92070,4 +92077,4 @@ exports.send = send$1;
exports.sortUserPlugins = sortUserPlugins;
exports.source = source;
exports.transformWithEsbuild = transformWithEsbuild;
//# sourceMappingURL=dep-d8f4aa6e.js.map
//# sourceMappingURL=dep-35df7f96.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
'use strict';
var build = require('./dep-d8f4aa6e.js');
var build = require('./dep-35df7f96.js');
function _mergeNamespaces(n, m) {
for (var i = 0; i < m.length; i++) {
@ -8731,4 +8731,4 @@ var compilerDom_cjs$1 = /*#__PURE__*/_mergeNamespaces({
}, [compilerDom_cjs$2]);
exports.compilerDom_cjs = compilerDom_cjs$1;
//# sourceMappingURL=dep-68d11c39.js.map
//# sourceMappingURL=dep-a5b4350d.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
'use strict';
var require$$0 = require('postcss');
var build$2 = require('./dep-d8f4aa6e.js');
var build$2 = require('./dep-35df7f96.js');
var path$4 = require('path');
var require$$1 = require('crypto');
var fs = require('fs');
@ -11401,4 +11401,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
}, [build$1.exports]);
exports.index = index;
//# sourceMappingURL=dep-077e5c0c.js.map
//# sourceMappingURL=dep-dab866a6.js.map

View file

@ -1,7 +1,7 @@
'use strict';
var require$$0 = require('events');
var build = require('./chunks/dep-d8f4aa6e.js');
var build = require('./chunks/dep-35df7f96.js');
var perf_hooks = require('perf_hooks');
require('fs');
require('path');
@ -682,7 +682,7 @@ cli
.action(async (root, options) => {
// output structure is preserved even after bundling so require()
// is ok here
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-d8f4aa6e.js'); }).then(function (n) { return n.index$1; });
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-35df7f96.js'); }).then(function (n) { return n.index$1; });
try {
const server = await createServer({
root,
@ -731,7 +731,7 @@ cli
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
.action(async (root, options) => {
const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-d8f4aa6e.js'); }).then(function (n) { return n.build$1; });
const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-35df7f96.js'); }).then(function (n) { return n.build$1; });
const buildOptions = cleanOptions(options);
try {
await build$1({
@ -754,7 +754,7 @@ cli
.command('optimize [root]')
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
.action(async (root, options) => {
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-d8f4aa6e.js'); }).then(function (n) { return n.index; });
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-35df7f96.js'); }).then(function (n) { return n.index; });
try {
const config = await build.resolveConfig({
root,

View file

@ -1,8 +1,14 @@
/// <reference types="node" />
import { Agent } from 'http';
import { BuildOptions as BuildOptions_2 } from 'esbuild';
import { ClientRequest } from 'http';
import { ClientRequestArgs } from 'http';
import { CustomPluginOptions } from 'rollup';
import { Duplex } from 'stream';
import { DuplexOptions } from 'stream';
import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
import { EventEmitter } from 'events';
import * as events from 'events';
import * as fs from 'fs';
import * as http from 'http';
@ -12,6 +18,7 @@ import { InputOptions } from 'rollup';
import { LoadResult } from 'rollup';
import { ModuleFormat } from 'rollup';
import * as net from 'net';
import { OutgoingHttpHeaders } from 'http';
import { OutputBundle } from 'rollup';
import { OutputChunk } from 'rollup';
import { PartialResolvedId } from 'rollup';
@ -24,18 +31,22 @@ import { RollupError } from 'rollup';
import { RollupOptions } from 'rollup';
import { RollupOutput } from 'rollup';
import { RollupWatcher } from 'rollup';
import { SecureContextOptions } from 'tls';
import { Server } from 'http';
import { Server as Server_2 } from 'net';
import { Server as Server_2 } from 'https';
import { Server as Server_3 } from 'net';
import { ServerResponse } from 'http';
import { Socket } from 'net';
import { SourceDescription } from 'rollup';
import { SourceMap } from 'rollup';
import * as stream from 'stream';
import { TransformPluginContext } from 'rollup';
import { TransformResult as TransformResult_2 } from 'esbuild';
import { TransformResult as TransformResult_3 } from 'rollup';
import { URL } from 'url';
import * as url from 'url';
import { WatcherOptions } from 'rollup';
import WebSocket from 'ws';
import { ZlibOptions } from 'zlib';
export declare interface Alias {
find: string | RegExp
@ -1177,7 +1188,7 @@ export declare type PluginOption = Plugin | false | null | undefined;
*/
export declare function preview(config: ResolvedConfig, serverOptions: Pick<ServerOptions, 'port' | 'host'>): Promise<Server>;
export declare function printHttpServerUrls(server: Server_2, config: ResolvedConfig): void;
export declare function printHttpServerUrls(server: Server_3, config: ResolvedConfig): void;
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
/**
@ -2058,6 +2069,507 @@ export declare interface WatchOptions {
| boolean
}
export declare namespace WebSocket {
// WebSocket socket.
export class WebSocket extends EventEmitter {
/** The connection is not yet open. */
static readonly CONNECTING: 0
/** The connection is open and ready to communicate. */
static readonly OPEN: 1
/** The connection is in the process of closing. */
static readonly CLOSING: 2
/** The connection is closed. */
static readonly CLOSED: 3
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
readonly bufferedAmount: number
readonly extensions: string
readonly protocol: string
/** The current state of the connection */
readonly readyState:
| typeof WebSocket.CONNECTING
| typeof WebSocket.OPEN
| typeof WebSocket.CLOSING
| typeof WebSocket.CLOSED
readonly url: string
/** The connection is not yet open. */
readonly CONNECTING: 0
/** The connection is open and ready to communicate. */
readonly OPEN: 1
/** The connection is in the process of closing. */
readonly CLOSING: 2
/** The connection is closed. */
readonly CLOSED: 3
onopen: (event: WebSocket.OpenEvent) => void
onerror: (event: WebSocket.ErrorEvent) => void
onclose: (event: WebSocket.CloseEvent) => void
onmessage: (event: WebSocket.MessageEvent) => void
constructor(
address: string | URL,
options?: WebSocket.ClientOptions | ClientRequestArgs
)
constructor(
address: string | URL,
protocols?: string | string[],
options?: WebSocket.ClientOptions | ClientRequestArgs
)
close(code?: number, data?: string): void
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
send(data: any, cb?: (err?: Error) => void): void
send(
data: any,
options: {
mask?: boolean | undefined
binary?: boolean | undefined
compress?: boolean | undefined
fin?: boolean | undefined
},
cb?: (err?: Error) => void
): void
terminate(): void
// HTML5 WebSocket events
addEventListener(
method: 'message',
cb: (event: { data: any; type: string; target: WebSocket }) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: 'close',
cb: (event: {
wasClean: boolean
code: number
reason: string
target: WebSocket
}) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: 'error',
cb: (event: {
error: any
message: any
type: string
target: WebSocket
}) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: 'open',
cb: (event: { target: WebSocket }) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: string,
listener: () => void,
options?: WebSocket.EventListenerOptions
): void
removeEventListener(
method: 'message',
cb?: (event: { data: any; type: string; target: WebSocket }) => void
): void
removeEventListener(
method: 'close',
cb?: (event: {
wasClean: boolean
code: number
reason: string
target: WebSocket
}) => void
): void
removeEventListener(
method: 'error',
cb?: (event: {
error: any
message: any
type: string
target: WebSocket
}) => void
): void
removeEventListener(
method: 'open',
cb?: (event: { target: WebSocket }) => void
): void
removeEventListener(method: string, listener?: () => void): void
// Events
on(
event: 'close',
listener: (this: WebSocket, code: number, reason: string) => void
): this
on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
on(
event: 'upgrade',
listener: (this: WebSocket, request: IncomingMessage) => void
): this
on(
event: 'message',
listener: (this: WebSocket, data: WebSocket.Data) => void
): this
on(event: 'open', listener: (this: WebSocket) => void): this
on(
event: 'ping' | 'pong',
listener: (this: WebSocket, data: Buffer) => void
): this
on(
event: 'unexpected-response',
listener: (
this: WebSocket,
request: ClientRequest,
response: IncomingMessage
) => void
): this
on(
event: string | symbol,
listener: (this: WebSocket, ...args: any[]) => void
): this
once(
event: 'close',
listener: (this: WebSocket, code: number, reason: string) => void
): this
once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
once(
event: 'upgrade',
listener: (this: WebSocket, request: IncomingMessage) => void
): this
once(
event: 'message',
listener: (this: WebSocket, data: WebSocket.Data) => void
): this
once(event: 'open', listener: (this: WebSocket) => void): this
once(
event: 'ping' | 'pong',
listener: (this: WebSocket, data: Buffer) => void
): this
once(
event: 'unexpected-response',
listener: (
this: WebSocket,
request: ClientRequest,
response: IncomingMessage
) => void
): this
once(
event: string | symbol,
listener: (this: WebSocket, ...args: any[]) => void
): this
off(
event: 'close',
listener: (this: WebSocket, code: number, reason: string) => void
): this
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
off(
event: 'upgrade',
listener: (this: WebSocket, request: IncomingMessage) => void
): this
off(
event: 'message',
listener: (this: WebSocket, data: WebSocket.Data) => void
): this
off(event: 'open', listener: (this: WebSocket) => void): this
off(
event: 'ping' | 'pong',
listener: (this: WebSocket, data: Buffer) => void
): this
off(
event: 'unexpected-response',
listener: (
this: WebSocket,
request: ClientRequest,
response: IncomingMessage
) => void
): this
off(
event: string | symbol,
listener: (this: WebSocket, ...args: any[]) => void
): this
addListener(
event: 'close',
listener: (code: number, message: string) => void
): this
addListener(event: 'error', listener: (err: Error) => void): this
addListener(
event: 'upgrade',
listener: (request: IncomingMessage) => void
): this
addListener(
event: 'message',
listener: (data: WebSocket.Data) => void
): this
addListener(event: 'open', listener: () => void): this
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
addListener(
event: 'unexpected-response',
listener: (request: ClientRequest, response: IncomingMessage) => void
): this
addListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
removeListener(
event: 'close',
listener: (code: number, message: string) => void
): this
removeListener(event: 'error', listener: (err: Error) => void): this
removeListener(
event: 'upgrade',
listener: (request: IncomingMessage) => void
): this
removeListener(
event: 'message',
listener: (data: WebSocket.Data) => void
): this
removeListener(event: 'open', listener: () => void): this
removeListener(
event: 'ping' | 'pong',
listener: (data: Buffer) => void
): this
removeListener(
event: 'unexpected-response',
listener: (request: ClientRequest, response: IncomingMessage) => void
): this
removeListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
}
/**
* Data represents the message payload received over the WebSocket.
*/
export type Data = string | Buffer | ArrayBuffer | Buffer[]
/**
* CertMeta represents the accepted types for certificate & key data.
*/
export type CertMeta = string | string[] | Buffer | Buffer[]
/**
* VerifyClientCallbackSync is a synchronous callback used to inspect the
* incoming message. The return value (boolean) of the function determines
* whether or not to accept the handshake.
*/
export type VerifyClientCallbackSync = (info: {
origin: string
secure: boolean
req: IncomingMessage
}) => boolean
/**
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
* incoming message. The return value (boolean) of the function determines
* whether or not to accept the handshake.
*/
export type VerifyClientCallbackAsync = (
info: { origin: string; secure: boolean; req: IncomingMessage },
callback: (
res: boolean,
code?: number,
message?: string,
headers?: OutgoingHttpHeaders
) => void
) => void
export interface ClientOptions extends SecureContextOptions {
protocol?: string | undefined
followRedirects?: boolean | undefined
handshakeTimeout?: number | undefined
maxRedirects?: number | undefined
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
localAddress?: string | undefined
protocolVersion?: number | undefined
headers?: { [key: string]: string } | undefined
origin?: string | undefined
agent?: Agent | undefined
host?: string | undefined
family?: number | undefined
checkServerIdentity?(servername: string, cert: CertMeta): boolean
rejectUnauthorized?: boolean | undefined
maxPayload?: number | undefined
}
export interface PerMessageDeflateOptions {
serverNoContextTakeover?: boolean | undefined
clientNoContextTakeover?: boolean | undefined
serverMaxWindowBits?: number | undefined
clientMaxWindowBits?: number | undefined
zlibDeflateOptions?:
| {
flush?: number | undefined
finishFlush?: number | undefined
chunkSize?: number | undefined
windowBits?: number | undefined
level?: number | undefined
memLevel?: number | undefined
strategy?: number | undefined
dictionary?: Buffer | Buffer[] | DataView | undefined
info?: boolean | undefined
}
| undefined
zlibInflateOptions?: ZlibOptions | undefined
threshold?: number | undefined
concurrencyLimit?: number | undefined
}
export interface OpenEvent {
type: string
target: WebSocket
}
export interface ErrorEvent {
error: any
message: string
type: string
target: WebSocket
}
export interface CloseEvent {
wasClean: boolean
code: number
reason: string
type: string
target: WebSocket
}
export interface MessageEvent {
data: Data
type: string
target: WebSocket
}
export interface EventListenerOptions {
once?: boolean | undefined
}
export interface ServerOptions {
host?: string | undefined
port?: number | undefined
backlog?: number | undefined
server?: Server | Server_2 | undefined
verifyClient?:
| VerifyClientCallbackAsync
| VerifyClientCallbackSync
| undefined
handleProtocols?: any
path?: string | undefined
noServer?: boolean | undefined
clientTracking?: boolean | undefined
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
maxPayload?: number | undefined
}
export interface AddressInfo {
address: string
family: string
port: number
}
// WebSocket Server
export class Server extends EventEmitter {
options: ServerOptions
path: string
clients: Set<WebSocket>
constructor(options?: ServerOptions, callback?: () => void)
address(): AddressInfo | string
close(cb?: (err?: Error) => void): void
handleUpgrade(
request: IncomingMessage,
socket: Socket,
upgradeHead: Buffer,
callback: (client: WebSocket, request: IncomingMessage) => void
): void
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
// Events
on(
event: 'connection',
cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void
): this
on(event: 'error', cb: (this: Server, error: Error) => void): this
on(
event: 'headers',
cb: (this: Server, headers: string[], request: IncomingMessage) => void
): this
on(event: 'close' | 'listening', cb: (this: Server) => void): this
on(
event: string | symbol,
listener: (this: Server, ...args: any[]) => void
): this
once(
event: 'connection',
cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void
): this
once(event: 'error', cb: (this: Server, error: Error) => void): this
once(
event: 'headers',
cb: (this: Server, headers: string[], request: IncomingMessage) => void
): this
once(event: 'close' | 'listening', cb: (this: Server) => void): this
once(event: string | symbol, listener: (...args: any[]) => void): this
off(
event: 'connection',
cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void
): this
off(event: 'error', cb: (this: Server, error: Error) => void): this
off(
event: 'headers',
cb: (this: Server, headers: string[], request: IncomingMessage) => void
): this
off(event: 'close' | 'listening', cb: (this: Server) => void): this
off(
event: string | symbol,
listener: (this: Server, ...args: any[]) => void
): this
addListener(
event: 'connection',
cb: (client: WebSocket, request: IncomingMessage) => void
): this
addListener(event: 'error', cb: (err: Error) => void): this
addListener(
event: 'headers',
cb: (headers: string[], request: IncomingMessage) => void
): this
addListener(event: 'close' | 'listening', cb: () => void): this
addListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
removeListener(event: 'connection', cb: (client: WebSocket) => void): this
removeListener(event: 'error', cb: (err: Error) => void): this
removeListener(
event: 'headers',
cb: (headers: string[], request: IncomingMessage) => void
): this
removeListener(event: 'close' | 'listening', cb: () => void): this
removeListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
}
// WebSocket stream
export function createWebSocketStream(
websocket: WebSocket,
options?: DuplexOptions
): Duplex
}
export declare interface WebSocketServer {
on: WebSocket.Server['on'];
off: WebSocket.Server['off'];

View file

@ -2,7 +2,7 @@
Object.defineProperty(exports, '__esModule', { value: true });
var build = require('./chunks/dep-d8f4aa6e.js');
var build = require('./chunks/dep-35df7f96.js');
require('fs');
require('path');
require('events');

View file

@ -1,6 +1,6 @@
{
"name": "vite",
"version": "2.6.7",
"version": "2.6.10",
"license": "MIT",
"author": "Evan You",
"description": "Native-ESM powered web dev build tool",
@ -29,10 +29,8 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/#readme",
"scripts": {
"predev": "rimraf dist",
"dev": "rollup -c -w",
"prebuild": "rimraf dist && npm run lint",
"build": "run-s build-bundle build-types",
"dev": "rimraf dist && rollup -c -w",
"build": "rimraf dist && npm run lint && run-s build-bundle build-types",
"build-bundle": "rollup -c",
"build-types": "run-s build-temp-types patch-types roll-types",
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
@ -56,6 +54,8 @@
},
"devDependencies": {
"@ampproject/remapping": "^1.0.1",
"@babel/parser": "^7.15.8",
"@babel/types": "^7.15.6",
"@rollup/plugin-alias": "^3.1.5",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-dynamic-import-vars": "^1.4.0",

532
packages/astro/vendor/vite/types/ws.d.ts vendored Normal file
View file

@ -0,0 +1,532 @@
// Inlined to avoid extra dependency
// MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
// Type definitions for ws 7.4
// Project: https://github.com/websockets/ws
// Definitions by: Paul Loyd <https://github.com/loyd>
// Margus Lamp <https://github.com/mlamp>
// Philippe D'Alva <https://github.com/TitaneBoy>
// reduckted <https://github.com/reduckted>
// teidesu <https://github.com/teidesu>
// Bartosz Wojtkowiak <https://github.com/wojtkowiak>
// Kyle Hensel <https://github.com/k-yle>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { EventEmitter } from 'events'
import {
Agent,
ClientRequest,
ClientRequestArgs,
IncomingMessage,
OutgoingHttpHeaders,
Server as HTTPServer
} from 'http'
import { Server as HTTPSServer } from 'https'
import { Socket } from 'net'
import { Duplex, DuplexOptions } from 'stream'
import { SecureContextOptions } from 'tls'
import { URL } from 'url'
import { ZlibOptions } from 'zlib'
export declare namespace WebSocket {
// WebSocket socket.
export class WebSocket extends EventEmitter {
/** The connection is not yet open. */
static readonly CONNECTING: 0
/** The connection is open and ready to communicate. */
static readonly OPEN: 1
/** The connection is in the process of closing. */
static readonly CLOSING: 2
/** The connection is closed. */
static readonly CLOSED: 3
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
readonly bufferedAmount: number
readonly extensions: string
readonly protocol: string
/** The current state of the connection */
readonly readyState:
| typeof WebSocket.CONNECTING
| typeof WebSocket.OPEN
| typeof WebSocket.CLOSING
| typeof WebSocket.CLOSED
readonly url: string
/** The connection is not yet open. */
readonly CONNECTING: 0
/** The connection is open and ready to communicate. */
readonly OPEN: 1
/** The connection is in the process of closing. */
readonly CLOSING: 2
/** The connection is closed. */
readonly CLOSED: 3
onopen: (event: WebSocket.OpenEvent) => void
onerror: (event: WebSocket.ErrorEvent) => void
onclose: (event: WebSocket.CloseEvent) => void
onmessage: (event: WebSocket.MessageEvent) => void
constructor(
address: string | URL,
options?: WebSocket.ClientOptions | ClientRequestArgs
)
constructor(
address: string | URL,
protocols?: string | string[],
options?: WebSocket.ClientOptions | ClientRequestArgs
)
close(code?: number, data?: string): void
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
send(data: any, cb?: (err?: Error) => void): void
send(
data: any,
options: {
mask?: boolean | undefined
binary?: boolean | undefined
compress?: boolean | undefined
fin?: boolean | undefined
},
cb?: (err?: Error) => void
): void
terminate(): void
// HTML5 WebSocket events
addEventListener(
method: 'message',
cb: (event: { data: any; type: string; target: WebSocket }) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: 'close',
cb: (event: {
wasClean: boolean
code: number
reason: string
target: WebSocket
}) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: 'error',
cb: (event: {
error: any
message: any
type: string
target: WebSocket
}) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: 'open',
cb: (event: { target: WebSocket }) => void,
options?: WebSocket.EventListenerOptions
): void
addEventListener(
method: string,
listener: () => void,
options?: WebSocket.EventListenerOptions
): void
removeEventListener(
method: 'message',
cb?: (event: { data: any; type: string; target: WebSocket }) => void
): void
removeEventListener(
method: 'close',
cb?: (event: {
wasClean: boolean
code: number
reason: string
target: WebSocket
}) => void
): void
removeEventListener(
method: 'error',
cb?: (event: {
error: any
message: any
type: string
target: WebSocket
}) => void
): void
removeEventListener(
method: 'open',
cb?: (event: { target: WebSocket }) => void
): void
removeEventListener(method: string, listener?: () => void): void
// Events
on(
event: 'close',
listener: (this: WebSocket, code: number, reason: string) => void
): this
on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
on(
event: 'upgrade',
listener: (this: WebSocket, request: IncomingMessage) => void
): this
on(
event: 'message',
listener: (this: WebSocket, data: WebSocket.Data) => void
): this
on(event: 'open', listener: (this: WebSocket) => void): this
on(
event: 'ping' | 'pong',
listener: (this: WebSocket, data: Buffer) => void
): this
on(
event: 'unexpected-response',
listener: (
this: WebSocket,
request: ClientRequest,
response: IncomingMessage
) => void
): this
on(
event: string | symbol,
listener: (this: WebSocket, ...args: any[]) => void
): this
once(
event: 'close',
listener: (this: WebSocket, code: number, reason: string) => void
): this
once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
once(
event: 'upgrade',
listener: (this: WebSocket, request: IncomingMessage) => void
): this
once(
event: 'message',
listener: (this: WebSocket, data: WebSocket.Data) => void
): this
once(event: 'open', listener: (this: WebSocket) => void): this
once(
event: 'ping' | 'pong',
listener: (this: WebSocket, data: Buffer) => void
): this
once(
event: 'unexpected-response',
listener: (
this: WebSocket,
request: ClientRequest,
response: IncomingMessage
) => void
): this
once(
event: string | symbol,
listener: (this: WebSocket, ...args: any[]) => void
): this
off(
event: 'close',
listener: (this: WebSocket, code: number, reason: string) => void
): this
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
off(
event: 'upgrade',
listener: (this: WebSocket, request: IncomingMessage) => void
): this
off(
event: 'message',
listener: (this: WebSocket, data: WebSocket.Data) => void
): this
off(event: 'open', listener: (this: WebSocket) => void): this
off(
event: 'ping' | 'pong',
listener: (this: WebSocket, data: Buffer) => void
): this
off(
event: 'unexpected-response',
listener: (
this: WebSocket,
request: ClientRequest,
response: IncomingMessage
) => void
): this
off(
event: string | symbol,
listener: (this: WebSocket, ...args: any[]) => void
): this
addListener(
event: 'close',
listener: (code: number, message: string) => void
): this
addListener(event: 'error', listener: (err: Error) => void): this
addListener(
event: 'upgrade',
listener: (request: IncomingMessage) => void
): this
addListener(
event: 'message',
listener: (data: WebSocket.Data) => void
): this
addListener(event: 'open', listener: () => void): this
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
addListener(
event: 'unexpected-response',
listener: (request: ClientRequest, response: IncomingMessage) => void
): this
addListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
removeListener(
event: 'close',
listener: (code: number, message: string) => void
): this
removeListener(event: 'error', listener: (err: Error) => void): this
removeListener(
event: 'upgrade',
listener: (request: IncomingMessage) => void
): this
removeListener(
event: 'message',
listener: (data: WebSocket.Data) => void
): this
removeListener(event: 'open', listener: () => void): this
removeListener(
event: 'ping' | 'pong',
listener: (data: Buffer) => void
): this
removeListener(
event: 'unexpected-response',
listener: (request: ClientRequest, response: IncomingMessage) => void
): this
removeListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
}
/**
* Data represents the message payload received over the WebSocket.
*/
type Data = string | Buffer | ArrayBuffer | Buffer[]
/**
* CertMeta represents the accepted types for certificate & key data.
*/
type CertMeta = string | string[] | Buffer | Buffer[]
/**
* VerifyClientCallbackSync is a synchronous callback used to inspect the
* incoming message. The return value (boolean) of the function determines
* whether or not to accept the handshake.
*/
type VerifyClientCallbackSync = (info: {
origin: string
secure: boolean
req: IncomingMessage
}) => boolean
/**
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
* incoming message. The return value (boolean) of the function determines
* whether or not to accept the handshake.
*/
type VerifyClientCallbackAsync = (
info: { origin: string; secure: boolean; req: IncomingMessage },
callback: (
res: boolean,
code?: number,
message?: string,
headers?: OutgoingHttpHeaders
) => void
) => void
interface ClientOptions extends SecureContextOptions {
protocol?: string | undefined
followRedirects?: boolean | undefined
handshakeTimeout?: number | undefined
maxRedirects?: number | undefined
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
localAddress?: string | undefined
protocolVersion?: number | undefined
headers?: { [key: string]: string } | undefined
origin?: string | undefined
agent?: Agent | undefined
host?: string | undefined
family?: number | undefined
checkServerIdentity?(servername: string, cert: CertMeta): boolean
rejectUnauthorized?: boolean | undefined
maxPayload?: number | undefined
}
interface PerMessageDeflateOptions {
serverNoContextTakeover?: boolean | undefined
clientNoContextTakeover?: boolean | undefined
serverMaxWindowBits?: number | undefined
clientMaxWindowBits?: number | undefined
zlibDeflateOptions?:
| {
flush?: number | undefined
finishFlush?: number | undefined
chunkSize?: number | undefined
windowBits?: number | undefined
level?: number | undefined
memLevel?: number | undefined
strategy?: number | undefined
dictionary?: Buffer | Buffer[] | DataView | undefined
info?: boolean | undefined
}
| undefined
zlibInflateOptions?: ZlibOptions | undefined
threshold?: number | undefined
concurrencyLimit?: number | undefined
}
interface OpenEvent {
type: string
target: WebSocket
}
interface ErrorEvent {
error: any
message: string
type: string
target: WebSocket
}
interface CloseEvent {
wasClean: boolean
code: number
reason: string
type: string
target: WebSocket
}
interface MessageEvent {
data: Data
type: string
target: WebSocket
}
interface EventListenerOptions {
once?: boolean | undefined
}
interface ServerOptions {
host?: string | undefined
port?: number | undefined
backlog?: number | undefined
server?: HTTPServer | HTTPSServer | undefined
verifyClient?:
| VerifyClientCallbackAsync
| VerifyClientCallbackSync
| undefined
handleProtocols?: any
path?: string | undefined
noServer?: boolean | undefined
clientTracking?: boolean | undefined
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
maxPayload?: number | undefined
}
interface AddressInfo {
address: string
family: string
port: number
}
// WebSocket Server
export class Server extends EventEmitter {
options: ServerOptions
path: string
clients: Set<WebSocket>
constructor(options?: ServerOptions, callback?: () => void)
address(): AddressInfo | string
close(cb?: (err?: Error) => void): void
handleUpgrade(
request: IncomingMessage,
socket: Socket,
upgradeHead: Buffer,
callback: (client: WebSocket, request: IncomingMessage) => void
): void
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
// Events
on(
event: 'connection',
cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void
): this
on(event: 'error', cb: (this: Server, error: Error) => void): this
on(
event: 'headers',
cb: (this: Server, headers: string[], request: IncomingMessage) => void
): this
on(event: 'close' | 'listening', cb: (this: Server) => void): this
on(
event: string | symbol,
listener: (this: Server, ...args: any[]) => void
): this
once(
event: 'connection',
cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void
): this
once(event: 'error', cb: (this: Server, error: Error) => void): this
once(
event: 'headers',
cb: (this: Server, headers: string[], request: IncomingMessage) => void
): this
once(event: 'close' | 'listening', cb: (this: Server) => void): this
once(event: string | symbol, listener: (...args: any[]) => void): this
off(
event: 'connection',
cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void
): this
off(event: 'error', cb: (this: Server, error: Error) => void): this
off(
event: 'headers',
cb: (this: Server, headers: string[], request: IncomingMessage) => void
): this
off(event: 'close' | 'listening', cb: (this: Server) => void): this
off(
event: string | symbol,
listener: (this: Server, ...args: any[]) => void
): this
addListener(
event: 'connection',
cb: (client: WebSocket, request: IncomingMessage) => void
): this
addListener(event: 'error', cb: (err: Error) => void): this
addListener(
event: 'headers',
cb: (headers: string[], request: IncomingMessage) => void
): this
addListener(event: 'close' | 'listening', cb: () => void): this
addListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
removeListener(event: 'connection', cb: (client: WebSocket) => void): this
removeListener(event: 'error', cb: (err: Error) => void): this
removeListener(
event: 'headers',
cb: (headers: string[], request: IncomingMessage) => void
): this
removeListener(event: 'close' | 'listening', cb: () => void): this
removeListener(
event: string | symbol,
listener: (...args: any[]) => void
): this
}
// WebSocket stream
function createWebSocketStream(
websocket: WebSocket,
options?: DuplexOptions
): Duplex
}

View file

@ -7538,10 +7538,10 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
mocha@^9.1.2:
version "9.1.2"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.1.2.tgz#93f53175b0f0dc4014bd2d612218fccfcf3534d3"
integrity sha512-ta3LtJ+63RIBP03VBjMGtSqbe6cWXRejF9SyM9Zyli1CKZJZ+vfCTj3oW24V7wAphMJdpOFLoMI3hjJ1LWbs0w==
mocha@^9.1.3:
version "9.1.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.1.3.tgz#8a623be6b323810493d8c8f6f7667440fa469fdb"
integrity sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==
dependencies:
"@ungap/promise-all-settled" "1.1.2"
ansi-colors "4.1.1"
@ -11071,7 +11071,7 @@ vfile@^5.0.0:
unist-util-stringify-position "^3.0.0"
vfile-message "^3.0.0"
vite@^2.6.7:
vite@^2.6.10:
version "2.6.10"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.6.10.tgz#7a4f420c6e2c7d9062c7f9ce4578a817c72b3842"
integrity sha512-XbevwpDJMs3lKiGEj0UQScsOCpwHIjFgfzPnFVkPgnxsF9oPv1uGyckLg58XkXv6LnO46KN9yZqJzINFmAxtUg==