Socket
Socket
Sign inDemoInstall

@web/dev-server-core

Package Overview
Dependencies
Maintainers
7
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/dev-server-core - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

8

dist/dom5/index.d.ts

@@ -14,6 +14,6 @@ /**

*/
export * from './modification';
export * from './predicates';
export * from './util';
export * from './walking';
export * from './modification.js';
export * from './predicates.js';
export * from './util.js';
export * from './walking.js';
//# sourceMappingURL=index.d.ts.map

@@ -30,6 +30,6 @@ "use strict";

*/
__exportStar(require("./modification"), exports);
__exportStar(require("./predicates"), exports);
__exportStar(require("./util"), exports);
__exportStar(require("./walking"), exports);
__exportStar(require("./modification.js"), exports);
__exportStar(require("./predicates.js"), exports);
__exportStar(require("./util.js"), exports);
__exportStar(require("./walking.js"), exports);
//# sourceMappingURL=index.js.map

@@ -14,4 +14,4 @@ /**

*/
import { Predicate } from './predicates';
import { GetChildNodes } from './util';
import { Predicate } from './predicates.js';
import { GetChildNodes } from './util.js';
/**

@@ -18,0 +18,0 @@ * Applies `mapfn` to `node` and the tree below `node`, yielding a flattened

@@ -17,4 +17,4 @@ "use strict";

exports.queryAll = exports.query = exports.prior = exports.previousSiblings = exports.ancestors = exports.depthFirstReversed = exports.depthFirst = exports.treeMap = void 0;
const predicates_1 = require("./predicates");
const util_1 = require("./util");
const predicates_js_1 = require("./predicates.js");
const util_js_1 = require("./util.js");
/**

@@ -35,3 +35,3 @@ * Applies `mapfn` to `node` and the tree below `node`, yielding a flattened

*/
function* depthFirst(node, getChildNodes = util_1.defaultChildNodes) {
function* depthFirst(node, getChildNodes = util_js_1.defaultChildNodes) {
yield node;

@@ -53,3 +53,3 @@ const childNodes = getChildNodes(node);

*/
function* depthFirstReversed(node, getChildNodes = util_1.defaultChildNodes) {
function* depthFirstReversed(node, getChildNodes = util_js_1.defaultChildNodes) {
const childNodes = getChildNodes(node);

@@ -141,3 +141,3 @@ if (childNodes !== undefined) {

*/
function query(node, predicate, getChildNodes = util_1.defaultChildNodes) {
function query(node, predicate, getChildNodes = util_js_1.defaultChildNodes) {
for (const result of queryAll(node, predicate, getChildNodes)) {

@@ -153,4 +153,4 @@ return result;

*/
function* queryAll(node, predicate, getChildNodes = util_1.defaultChildNodes) {
const elementPredicate = predicates_1.predicates.AND(predicates_1.isElement, predicate);
function* queryAll(node, predicate, getChildNodes = util_js_1.defaultChildNodes) {
const elementPredicate = predicates_js_1.predicates.AND(predicates_js_1.isElement, predicate);
for (const desc of depthFirst(node, getChildNodes)) {

@@ -157,0 +157,0 @@ if (elementPredicate(desc)) {

@@ -21,4 +21,4 @@ "use strict";

const clone_1 = __importDefault(require("clone"));
const predicates_1 = require("./predicates");
const walking_1 = require("./walking");
const predicates_js_1 = require("./predicates.js");
const walking_js_1 = require("./walking.js");
function newTextNode(value) {

@@ -87,3 +87,3 @@ return {

if (newNode) {
if ((0, predicates_1.isDocumentFragment)(newNode)) {
if ((0, predicates_js_1.isDocumentFragment)(newNode)) {
if (newNode.childNodes) {

@@ -160,3 +160,3 @@ newNodes = Array.from(newNode.childNodes);

function removeFakeRootElements(ast) {
const injectedNodes = (0, walking_1.queryAll)(ast, predicates_1.predicates.AND(node => !node.__location, predicates_1.predicates.hasMatchingTagName(/^(html|head|body)$/i)), undefined,
const injectedNodes = (0, walking_js_1.queryAll)(ast, predicates_js_1.predicates.AND(node => !node.__location, predicates_js_1.predicates.hasMatchingTagName(/^(html|head|body)$/i)), undefined,
// Don't descend past 3 levels 'document > html > head|body'

@@ -163,0 +163,0 @@ node => (node.parentNode && node.parentNode.parentNode ? undefined : node.childNodes));

@@ -18,3 +18,3 @@ "use strict";

exports.predicates = exports.isCommentNode = exports.isTextNode = exports.isElement = exports.isDocumentFragment = exports.isDocument = exports.hasSpaceSeparatedAttrValue = void 0;
const util_1 = require("./util");
const util_js_1 = require("./util.js");
/**

@@ -28,3 +28,3 @@ * Match the text inside an element, textnode, or comment

return function (node) {
return (0, util_1.getTextContent)(node) === value;
return (0, util_js_1.getTextContent)(node) === value;
};

@@ -86,3 +86,3 @@ }

return function (node) {
return (0, util_1.getAttributeIndex)(node, attr) > -1;
return (0, util_js_1.getAttributeIndex)(node, attr) > -1;
};

@@ -92,3 +92,3 @@ }

return function (node) {
return (0, util_1.getAttribute)(node, attr) === value;
return (0, util_js_1.getAttribute)(node, attr) === value;
};

@@ -123,3 +123,3 @@ }

return function (element) {
const attributeValue = (0, util_1.getAttribute)(element, name);
const attributeValue = (0, util_js_1.getAttribute)(element, name);
if (typeof attributeValue !== 'string') {

@@ -126,0 +126,0 @@ return false;

@@ -17,5 +17,5 @@ "use strict";

exports.defaultChildNodes = exports.setTextContent = exports.normalize = exports.removeAttribute = exports.setAttribute = exports.hasAttribute = exports.getAttributeIndex = exports.getAttribute = exports.getTextContent = void 0;
const modification_1 = require("./modification");
const predicates_1 = require("./predicates");
const walking_1 = require("./walking");
const modification_js_1 = require("./modification.js");
const predicates_js_1 = require("./predicates.js");
const walking_js_1 = require("./walking.js");
/**

@@ -27,9 +27,9 @@ * Return the text value of a node or element

function getTextContent(node) {
if ((0, predicates_1.isCommentNode)(node)) {
if ((0, predicates_js_1.isCommentNode)(node)) {
return node.data || '';
}
if ((0, predicates_1.isTextNode)(node)) {
if ((0, predicates_js_1.isTextNode)(node)) {
return node.value || '';
}
const subtree = (0, walking_1.nodeWalkAll)(node, predicates_1.isTextNode);
const subtree = (0, walking_js_1.nodeWalkAll)(node, predicates_js_1.isTextNode);
return subtree.map(getTextContent).join('');

@@ -96,3 +96,3 @@ }

if (text) {
const tn = modification_1.constructors.text(text);
const tn = modification_js_1.constructors.text(text);
tn.parentNode = parent;

@@ -109,3 +109,3 @@ parent.childNodes.splice(start, 0, tn);

function normalize(node) {
if (!((0, predicates_1.isElement)(node) || (0, predicates_1.isDocument)(node) || (0, predicates_1.isDocumentFragment)(node))) {
if (!((0, predicates_js_1.isElement)(node) || (0, predicates_js_1.isDocument)(node) || (0, predicates_js_1.isDocumentFragment)(node))) {
return;

@@ -119,3 +119,3 @@ }

n = node.childNodes[i];
if ((0, predicates_1.isTextNode)(n)) {
if ((0, predicates_js_1.isTextNode)(n)) {
if (textRangeStart === -1) {

@@ -147,10 +147,10 @@ textRangeStart = i;

function setTextContent(node, value) {
if ((0, predicates_1.isCommentNode)(node)) {
if ((0, predicates_js_1.isCommentNode)(node)) {
node.data = value;
}
else if ((0, predicates_1.isTextNode)(node)) {
else if ((0, predicates_js_1.isTextNode)(node)) {
node.value = value;
}
else {
const tn = modification_1.constructors.text(value);
const tn = modification_js_1.constructors.text(value);
tn.parentNode = node;

@@ -157,0 +157,0 @@ node.childNodes = [tn];

@@ -14,4 +14,4 @@ /**

*/
import { Predicate } from './predicates';
import { GetChildNodes } from './util';
import { Predicate } from './predicates.js';
import { GetChildNodes } from './util.js';
/**

@@ -18,0 +18,0 @@ * Applies `mapfn` to `node` and the tree below `node`, returning a flattened

@@ -40,5 +40,5 @@ "use strict";

exports.queryAll = exports.query = exports.nodeWalkAncestors = exports.nodeWalkAllPrior = exports.nodeWalkPrior = exports.nodeWalkAll = exports.nodeWalk = exports.treeMap = void 0;
const iteration = __importStar(require("./iteration"));
const predicates_1 = require("./predicates");
const util_1 = require("./util");
const iteration = __importStar(require("./iteration.js"));
const predicates_js_1 = require("./predicates.js");
const util_js_1 = require("./util.js");
/**

@@ -74,3 +74,3 @@ * Applies `mapfn` to `node` and the tree below `node`, returning a flattened

*/
function nodeWalk(node, predicate, getChildNodes = util_1.defaultChildNodes) {
function nodeWalk(node, predicate, getChildNodes = util_js_1.defaultChildNodes) {
return find(iteration.depthFirst(node, getChildNodes), predicate);

@@ -84,3 +84,3 @@ }

*/
function nodeWalkAll(node, predicate, matches, getChildNodes = util_1.defaultChildNodes) {
function nodeWalkAll(node, predicate, matches, getChildNodes = util_js_1.defaultChildNodes) {
return filter(iteration.depthFirst(node, getChildNodes), predicate, matches);

@@ -134,4 +134,4 @@ }

*/
function query(node, predicate, getChildNodes = util_1.defaultChildNodes) {
const elementPredicate = predicates_1.predicates.AND(predicates_1.isElement, predicate);
function query(node, predicate, getChildNodes = util_js_1.defaultChildNodes) {
const elementPredicate = predicates_js_1.predicates.AND(predicates_js_1.isElement, predicate);
return nodeWalk(node, elementPredicate, getChildNodes);

@@ -143,4 +143,4 @@ }

*/
function queryAll(node, predicate, matches, getChildNodes = util_1.defaultChildNodes) {
const elementPredicate = predicates_1.predicates.AND(predicates_1.isElement, predicate);
function queryAll(node, predicate, matches, getChildNodes = util_js_1.defaultChildNodes) {
const elementPredicate = predicates_js_1.predicates.AND(predicates_js_1.isElement, predicate);
return nodeWalkAll(node, elementPredicate, matches, getChildNodes);

@@ -147,0 +147,0 @@ }

@@ -6,10 +6,10 @@ export { FSWatcher } from 'chokidar';

export { WebSocket };
export { DevServer } from './server/DevServer';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager';
export { getRequestBrowserPath, getRequestFilePath, getResponseBody, getHtmlPath, isInlineScriptRequest, } from './utils';
export { Logger, ErrorWithLocation } from './logger/Logger';
export { PluginSyntaxError } from './logger/PluginSyntaxError';
export { PluginError } from './logger/PluginError';
export { DevServer } from './server/DevServer.js';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin.js';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig.js';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager.js';
export { getRequestBrowserPath, getRequestFilePath, getResponseBody, getHtmlPath, isInlineScriptRequest, } from './utils.js';
export { Logger, ErrorWithLocation } from './logger/Logger.js';
export { PluginSyntaxError } from './logger/PluginSyntaxError.js';
export { PluginError } from './logger/PluginError.js';
//# sourceMappingURL=index.d.ts.map

@@ -16,16 +16,16 @@ "use strict";

exports.WebSocket = ws_1.default;
var DevServer_1 = require("./server/DevServer");
Object.defineProperty(exports, "DevServer", { enumerable: true, get: function () { return DevServer_1.DevServer; } });
var WebSocketsManager_1 = require("./web-sockets/WebSocketsManager");
Object.defineProperty(exports, "WebSocketsManager", { enumerable: true, get: function () { return WebSocketsManager_1.WebSocketsManager; } });
var utils_1 = require("./utils");
Object.defineProperty(exports, "getRequestBrowserPath", { enumerable: true, get: function () { return utils_1.getRequestBrowserPath; } });
Object.defineProperty(exports, "getRequestFilePath", { enumerable: true, get: function () { return utils_1.getRequestFilePath; } });
Object.defineProperty(exports, "getResponseBody", { enumerable: true, get: function () { return utils_1.getResponseBody; } });
Object.defineProperty(exports, "getHtmlPath", { enumerable: true, get: function () { return utils_1.getHtmlPath; } });
Object.defineProperty(exports, "isInlineScriptRequest", { enumerable: true, get: function () { return utils_1.isInlineScriptRequest; } });
var PluginSyntaxError_1 = require("./logger/PluginSyntaxError");
Object.defineProperty(exports, "PluginSyntaxError", { enumerable: true, get: function () { return PluginSyntaxError_1.PluginSyntaxError; } });
var PluginError_1 = require("./logger/PluginError");
Object.defineProperty(exports, "PluginError", { enumerable: true, get: function () { return PluginError_1.PluginError; } });
var DevServer_js_1 = require("./server/DevServer.js");
Object.defineProperty(exports, "DevServer", { enumerable: true, get: function () { return DevServer_js_1.DevServer; } });
var WebSocketsManager_js_1 = require("./web-sockets/WebSocketsManager.js");
Object.defineProperty(exports, "WebSocketsManager", { enumerable: true, get: function () { return WebSocketsManager_js_1.WebSocketsManager; } });
var utils_js_1 = require("./utils.js");
Object.defineProperty(exports, "getRequestBrowserPath", { enumerable: true, get: function () { return utils_js_1.getRequestBrowserPath; } });
Object.defineProperty(exports, "getRequestFilePath", { enumerable: true, get: function () { return utils_js_1.getRequestFilePath; } });
Object.defineProperty(exports, "getResponseBody", { enumerable: true, get: function () { return utils_js_1.getResponseBody; } });
Object.defineProperty(exports, "getHtmlPath", { enumerable: true, get: function () { return utils_js_1.getHtmlPath; } });
Object.defineProperty(exports, "isInlineScriptRequest", { enumerable: true, get: function () { return utils_js_1.isInlineScriptRequest; } });
var PluginSyntaxError_js_1 = require("./logger/PluginSyntaxError.js");
Object.defineProperty(exports, "PluginSyntaxError", { enumerable: true, get: function () { return PluginSyntaxError_js_1.PluginSyntaxError; } });
var PluginError_js_1 = require("./logger/PluginError.js");
Object.defineProperty(exports, "PluginError", { enumerable: true, get: function () { return PluginError_js_1.PluginError; } });
//# sourceMappingURL=index.js.map
import { Middleware } from 'koa';
import { Logger } from '../logger/Logger';
import { Logger } from '../logger/Logger.js';
/**

@@ -4,0 +4,0 @@ * Serves index.html when a non-file request within the scope of the app index is made.

@@ -8,3 +8,3 @@ "use strict";

const path_1 = __importDefault(require("path"));
const utils_1 = require("../utils");
const utils_js_1 = require("../utils.js");
/**

@@ -17,3 +17,3 @@ * Serves index.html when a non-file request within the scope of the app index is made.

const relativeAppIndex = path_1.default.relative(rootDir, resolvedAppIndex);
const appIndexBrowserPath = `/${(0, utils_1.toBrowserPath)(relativeAppIndex)}`;
const appIndexBrowserPath = `/${(0, utils_js_1.toBrowserPath)(relativeAppIndex)}`;
const appIndexBrowserPathPrefix = path_1.default.dirname(appIndexBrowserPath);

@@ -20,0 +20,0 @@ return (ctx, next) => {

@@ -10,3 +10,3 @@ "use strict";

const util_1 = require("util");
const utils_1 = require("../utils");
const utils_js_1 = require("../utils.js");
const fsStat = (0, util_1.promisify)(fs_1.default.stat);

@@ -76,3 +76,3 @@ async function fileExists(filePath) {

catch (error) {
if (error instanceof utils_1.RequestCancelledError) {
if (error instanceof utils_js_1.RequestCancelledError) {
// no need to do anything if the request was cancelled

@@ -79,0 +79,0 @@ return;

import { FSWatcher } from 'chokidar';
import { Middleware } from 'koa';
import { DevServerCoreConfig } from '../server/DevServerCoreConfig';
import { Logger } from '../logger/Logger';
import { DevServerCoreConfig } from '../server/DevServerCoreConfig.js';
import { Logger } from '../logger/Logger.js';
/**

@@ -6,0 +6,0 @@ * Sets up a middleware which allows plugins to transform files before they are served to the browser.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pluginTransformMiddleware = void 0;
const PluginTransformCache_1 = require("./PluginTransformCache");
const utils_1 = require("../utils");
const PluginTransformCache_js_1 = require("./PluginTransformCache.js");
const utils_js_1 = require("../utils.js");
/**

@@ -11,3 +11,3 @@ * Sets up a middleware which allows plugins to transform files before they are served to the browser.

var _a;
const cache = new PluginTransformCache_1.PluginTransformCache(fileWatcher, config.rootDir);
const cache = new PluginTransformCache_js_1.PluginTransformCache(fileWatcher, config.rootDir);
const transformPlugins = ((_a = config.plugins) !== null && _a !== void 0 ? _a : []).filter(p => 'transform' in p);

@@ -41,3 +41,3 @@ if (transformPlugins.length === 0) {

// ensure response body is turned into a string or buffer
await (0, utils_1.getResponseBody)(context);
await (0, utils_js_1.getResponseBody)(context);
let disableCache = false;

@@ -68,3 +68,3 @@ let transformedCode = false;

logger.debug(`Added cache key "${cacheKey}" to plugin transform cache`);
const filePath = (0, utils_1.getRequestFilePath)(context.url, config.rootDir);
const filePath = (0, utils_js_1.getRequestFilePath)(context.url, config.rootDir);
cache.set(filePath, context.body, context.response.headers, cacheKey);

@@ -74,3 +74,3 @@ }

catch (e) {
if (e instanceof utils_1.RequestCancelledError) {
if (e instanceof utils_js_1.RequestCancelledError) {
return undefined;

@@ -77,0 +77,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

const koa_static_1 = __importDefault(require("koa-static"));
const utils_1 = require("../utils");
const utils_js_1 = require("../utils.js");
/**

@@ -27,4 +27,4 @@ * Creates multiple middleware used for serving files.

const serveCustomRootDirMiddleware = async (ctx, next) => {
if ((0, utils_1.isOutsideRootDir)(ctx.path)) {
const { normalizedPath, newRootDir } = (0, utils_1.resolvePathOutsideRootDir)(ctx.path, rootDir);
if ((0, utils_js_1.isOutsideRootDir)(ctx.path)) {
const { normalizedPath, newRootDir } = (0, utils_js_1.resolvePathOutsideRootDir)(ctx.path, rootDir);
await (0, koa_send_1.default)(ctx, normalizedPath, Object.assign(Object.assign({}, koaStaticOptions), { root: newRootDir }));

@@ -31,0 +31,0 @@ return;

@@ -8,3 +8,3 @@ "use strict";

const fs_1 = __importDefault(require("fs"));
const utils_1 = require("../utils");
const utils_js_1 = require("../utils.js");
/**

@@ -18,3 +18,3 @@ * Sets up a middleware which tracks served files and sends a reload message to any

if (ctx.response.status !== 404) {
let filePath = (0, utils_1.getRequestFilePath)(ctx.url, rootDir);
let filePath = (0, utils_js_1.getRequestFilePath)(ctx.url, rootDir);
// if the request ends with a / it might be an index.html, check if it exists

@@ -21,0 +21,0 @@ // and watch it

import { MimeTypeMappings } from '../server/DevServerCoreConfig';
import { Plugin } from './Plugin';
import { Plugin } from './Plugin.js';
export declare function mimeTypesPlugin(mappings: MimeTypeMappings): Plugin;
//# sourceMappingURL=mimeTypesPlugin.d.ts.map

@@ -9,3 +9,3 @@ "use strict";

const path_1 = require("path");
const utils_1 = require("../utils");
const utils_js_1 = require("../utils.js");
function createMatcher(rootDir, pattern) {

@@ -28,3 +28,3 @@ const resolvedPattern = !(0, path_1.isAbsolute)(pattern) && !pattern.startsWith('*') ? path_1.posix.join(rootDir, pattern) : pattern;

resolveMimeType(context) {
const filePath = (0, utils_1.getRequestFilePath)(context.url, rootDir);
const filePath = (0, utils_js_1.getRequestFilePath)(context.url, rootDir);
for (const matcher of matchers) {

@@ -31,0 +31,0 @@ if (matcher.fn(filePath)) {

@@ -1,3 +0,3 @@

import { Plugin } from './Plugin';
import { Logger } from '../logger/Logger';
import { Plugin } from './Plugin.js';
import { Logger } from '../logger/Logger.js';
export type ResolveImport = (source: string, code: string, line: number, column: number) => string | undefined | Promise<string | undefined>;

@@ -4,0 +4,0 @@ export declare function transformImports(code: string, filePath: string, resolveImport: ResolveImport): Promise<string>;

@@ -11,7 +11,7 @@ "use strict";

const es_module_lexer_1 = require("es-module-lexer");
const dom5_1 = require("../dom5");
const index_js_1 = require("../dom5/index.js");
const parse5_1 = require("parse5");
const PluginSyntaxError_1 = require("../logger/PluginSyntaxError");
const utils_1 = require("../utils");
const parseDynamicImport_1 = require("./parseDynamicImport");
const PluginSyntaxError_js_1 = require("../logger/PluginSyntaxError.js");
const utils_js_1 = require("../utils.js");
const parseDynamicImport_js_1 = require("./parseDynamicImport.js");
const CONCAT_NO_PACKAGE_ERROR = 'Dynamic import with a concatenated string should start with a valid full package name.';

@@ -84,3 +84,3 @@ /**

const lexerError = error;
throw new PluginSyntaxError_1.PluginSyntaxError('Syntax error', filePath, code, code.slice(0, lexerError.idx).split('\n').length, lexerError.idx - code.lastIndexOf('\n', lexerError.idx - 1));
throw new PluginSyntaxError_js_1.PluginSyntaxError('Syntax error', filePath, code, code.slice(0, lexerError.idx).split('\n').length, lexerError.idx - code.lastIndexOf('\n', lexerError.idx - 1));
}

@@ -105,3 +105,3 @@ throw error;

// dynamic import
const { importString, importSpecifier, stringLiteral, concatenatedString, dynamicStart, dynamicEnd, } = (0, parseDynamicImport_1.parseDynamicImport)(code, start, end);
const { importString, importSpecifier, stringLiteral, concatenatedString, dynamicStart, dynamicEnd, } = (0, parseDynamicImport_js_1.parseDynamicImport)(code, start, end);
const lines = code.slice(0, dynamicStart).split('\n');

@@ -129,3 +129,3 @@ const line = lines.length;

async function transformModuleImportsWithPlugins(logger, context, jsCode, rootDir, resolvePlugins) {
const filePath = path_1.default.join(rootDir, (0, utils_1.toFilePath)(context.path));
const filePath = path_1.default.join(rootDir, (0, utils_js_1.toFilePath)(context.path));
async function resolveImport(source, code, column, line) {

@@ -184,9 +184,9 @@ var _a;

const documentAst = (0, parse5_1.parse)(context.body);
const inlineModuleNodes = (0, dom5_1.queryAll)(documentAst, dom5_1.predicates.AND(dom5_1.predicates.hasTagName('script'), dom5_1.predicates.hasAttrValue('type', 'module'), dom5_1.predicates.NOT(dom5_1.predicates.hasAttr('src'))));
const inlineModuleNodes = (0, index_js_1.queryAll)(documentAst, index_js_1.predicates.AND(index_js_1.predicates.hasTagName('script'), index_js_1.predicates.hasAttrValue('type', 'module'), index_js_1.predicates.NOT(index_js_1.predicates.hasAttr('src'))));
let transformed = false;
for (const node of inlineModuleNodes) {
const code = (0, dom5_1.getTextContent)(node);
const code = (0, index_js_1.getTextContent)(node);
const resolvedCode = await transformModuleImportsWithPlugins(logger, context, code, rootDir, importPlugins);
if (code !== resolvedCode) {
(0, dom5_1.setTextContent)(node, resolvedCode);
(0, index_js_1.setTextContent)(node, resolvedCode);
transformed = true;

@@ -193,0 +193,0 @@ }

@@ -1,4 +0,4 @@

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { Logger } from '../logger/Logger';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { Logger } from '../logger/Logger.js';
export declare function addPlugins(logger: Logger, config: DevServerCoreConfig): void;
//# sourceMappingURL=addPlugins.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addPlugins = void 0;
const transformModuleImportsPlugin_1 = require("../plugins/transformModuleImportsPlugin");
const webSocketsPlugin_1 = require("../web-sockets/webSocketsPlugin");
const mimeTypesPlugin_1 = require("../plugins/mimeTypesPlugin");
const transformModuleImportsPlugin_js_1 = require("../plugins/transformModuleImportsPlugin.js");
const webSocketsPlugin_js_1 = require("../web-sockets/webSocketsPlugin.js");
const mimeTypesPlugin_js_1 = require("../plugins/mimeTypesPlugin.js");
function addPlugins(logger, config) {

@@ -13,10 +13,10 @@ var _a, _b;

if (config.mimeTypes && Object.keys(config.mimeTypes).length > 0) {
config.plugins.unshift((0, mimeTypesPlugin_1.mimeTypesPlugin)(config.mimeTypes));
config.plugins.unshift((0, mimeTypesPlugin_js_1.mimeTypesPlugin)(config.mimeTypes));
}
if (config.injectWebSocket && ((_a = config.plugins) === null || _a === void 0 ? void 0 : _a.some(pl => pl.injectWebSocket))) {
config.plugins.unshift((0, webSocketsPlugin_1.webSocketsPlugin)());
config.plugins.unshift((0, webSocketsPlugin_js_1.webSocketsPlugin)());
}
if ((_b = config.plugins) === null || _b === void 0 ? void 0 : _b.some(pl => 'resolveImport' in pl || 'transformImport' in pl)) {
// transform module imports must happen after all other plugins did their regular transforms
config.plugins.push((0, transformModuleImportsPlugin_1.transformModuleImportsPlugin)(logger, config.plugins, config.rootDir));
config.plugins.push((0, transformModuleImportsPlugin_js_1.transformModuleImportsPlugin)(logger, config.plugins, config.rootDir));
}

@@ -23,0 +23,0 @@ }

import { Middleware } from 'koa';
import { FSWatcher } from 'chokidar';
import { DevServerCoreConfig } from './DevServerCoreConfig';
import { Logger } from '../logger/Logger';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { Logger } from '../logger/Logger.js';
/**

@@ -6,0 +6,0 @@ * Creates middlewares based on the given configuration. The middlewares can be

@@ -8,11 +8,11 @@ "use strict";

const koa_etag_1 = __importDefault(require("koa-etag"));
const basePathMiddleware_1 = require("../middleware/basePathMiddleware");
const etagCacheMiddleware_1 = require("../middleware/etagCacheMiddleware");
const historyApiFallbackMiddleware_1 = require("../middleware/historyApiFallbackMiddleware");
const pluginMimeTypeMiddleware_1 = require("../middleware/pluginMimeTypeMiddleware");
const pluginServeMiddleware_1 = require("../middleware/pluginServeMiddleware");
const pluginTransformMiddleware_1 = require("../middleware/pluginTransformMiddleware");
const watchServedFilesMiddleware_1 = require("../middleware/watchServedFilesMiddleware");
const pluginFileParsedMiddleware_1 = require("../middleware/pluginFileParsedMiddleware");
const serveFilesMiddleware_1 = require("../middleware/serveFilesMiddleware");
const basePathMiddleware_js_1 = require("../middleware/basePathMiddleware.js");
const etagCacheMiddleware_js_1 = require("../middleware/etagCacheMiddleware.js");
const historyApiFallbackMiddleware_js_1 = require("../middleware/historyApiFallbackMiddleware.js");
const pluginMimeTypeMiddleware_js_1 = require("../middleware/pluginMimeTypeMiddleware.js");
const pluginServeMiddleware_js_1 = require("../middleware/pluginServeMiddleware.js");
const pluginTransformMiddleware_js_1 = require("../middleware/pluginTransformMiddleware.js");
const watchServedFilesMiddleware_js_1 = require("../middleware/watchServedFilesMiddleware.js");
const pluginFileParsedMiddleware_js_1 = require("../middleware/pluginFileParsedMiddleware.js");
const serveFilesMiddleware_js_1 = require("../middleware/serveFilesMiddleware.js");
/**

@@ -32,3 +32,3 @@ * Creates middlewares based on the given configuration. The middlewares can be

if (config.basePath) {
middlewares.push((0, basePathMiddleware_1.basePathMiddleware)(config.basePath));
middlewares.push((0, basePathMiddleware_js_1.basePathMiddleware)(config.basePath));
}

@@ -41,6 +41,6 @@ // adds custom user's middlewares

// watch files that are served
middlewares.push((0, watchServedFilesMiddleware_1.watchServedFilesMiddleware)(fileWatcher, config.rootDir));
middlewares.push((0, watchServedFilesMiddleware_js_1.watchServedFilesMiddleware)(fileWatcher, config.rootDir));
}
// serves 304 responses if resource hasn't changed
middlewares.push((0, etagCacheMiddleware_1.etagCacheMiddleware)());
middlewares.push((0, etagCacheMiddleware_js_1.etagCacheMiddleware)());
// adds etag headers for caching

@@ -50,10 +50,10 @@ middlewares.push((0, koa_etag_1.default)());

if (config.appIndex) {
middlewares.push((0, historyApiFallbackMiddleware_1.historyApiFallbackMiddleware)(config.appIndex, config.rootDir, logger));
middlewares.push((0, historyApiFallbackMiddleware_js_1.historyApiFallbackMiddleware)(config.appIndex, config.rootDir, logger));
}
const plugins = (_b = config.plugins) !== null && _b !== void 0 ? _b : [];
middlewares.push((0, pluginFileParsedMiddleware_1.pluginFileParsedMiddleware)(plugins));
middlewares.push((0, pluginTransformMiddleware_1.pluginTransformMiddleware)(logger, config, fileWatcher));
middlewares.push((0, pluginMimeTypeMiddleware_1.pluginMimeTypeMiddleware)(logger, plugins));
middlewares.push((0, pluginServeMiddleware_1.pluginServeMiddleware)(logger, plugins));
middlewares.push(...(0, serveFilesMiddleware_1.serveFilesMiddleware)(config.rootDir));
middlewares.push((0, pluginFileParsedMiddleware_js_1.pluginFileParsedMiddleware)(plugins));
middlewares.push((0, pluginTransformMiddleware_js_1.pluginTransformMiddleware)(logger, config, fileWatcher));
middlewares.push((0, pluginMimeTypeMiddleware_js_1.pluginMimeTypeMiddleware)(logger, plugins));
middlewares.push((0, pluginServeMiddleware_js_1.pluginServeMiddleware)(logger, plugins));
middlewares.push(...(0, serveFilesMiddleware_js_1.serveFilesMiddleware)(config.rootDir));
return middlewares;

@@ -60,0 +60,0 @@ }

@@ -5,4 +5,4 @@ /// <reference types="node" />

import net from 'net';
import { DevServerCoreConfig } from './DevServerCoreConfig';
import { Logger } from '../logger/Logger';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { Logger } from '../logger/Logger.js';
/**

@@ -9,0 +9,0 @@ * Creates a koa server with middlewares, but does not start it. Returns the koa app and

@@ -13,4 +13,4 @@ "use strict";

const net_1 = __importDefault(require("net"));
const createMiddleware_1 = require("./createMiddleware");
const addPlugins_1 = require("./addPlugins");
const createMiddleware_js_1 = require("./createMiddleware.js");
const addPlugins_js_1 = require("./addPlugins.js");
/**

@@ -39,3 +39,3 @@ * A request handler that returns a 301 HTTP Redirect to the same location as the original

});
(0, addPlugins_1.addPlugins)(logger, cfg);
(0, addPlugins_js_1.addPlugins)(logger, cfg);
// special case the legacy plugin, if it is given make sure the resolve module imports plugin

@@ -52,3 +52,3 @@ // runs before the legacy plugin because it compiles away module syntax. ideally we have a

}
const middleware = (0, createMiddleware_1.createMiddleware)(cfg, logger, fileWatcher);
const middleware = (0, createMiddleware_js_1.createMiddleware)(cfg, logger, fileWatcher);
for (const m of middleware) {

@@ -55,0 +55,0 @@ app.use(m);

@@ -5,5 +5,5 @@ /// <reference types="node" />

import chokidar from 'chokidar';
import { DevServerCoreConfig } from './DevServerCoreConfig';
import { Logger } from '../logger/Logger';
import { WebSocketsManager } from '../web-sockets/WebSocketsManager';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { Logger } from '../logger/Logger.js';
import { WebSocketsManager } from '../web-sockets/WebSocketsManager.js';
export declare class DevServer {

@@ -10,0 +10,0 @@ config: DevServerCoreConfig;

@@ -9,6 +9,6 @@ "use strict";

const util_1 = require("util");
const createServer_1 = require("./createServer");
const WebSocketsManager_1 = require("../web-sockets/WebSocketsManager");
const createServer_js_1 = require("./createServer.js");
const WebSocketsManager_js_1 = require("../web-sockets/WebSocketsManager.js");
class DevServer {
constructor(config, logger, fileWatcher = chokidar_1.default.watch([])) {
constructor(config, logger, fileWatcher = chokidar_1.default.watch([], config.chokidarOptions)) {
this.config = config;

@@ -23,7 +23,7 @@ this.logger = logger;

throw new Error('Missing logger.');
const { app, server } = (0, createServer_1.createServer)(this.logger, this.config, this.fileWatcher, !!config.middlewareMode);
const { app, server } = (0, createServer_js_1.createServer)(this.logger, this.config, this.fileWatcher, !!config.middlewareMode);
this.koaApp = app;
if (server) {
this.server = server;
this.webSockets = new WebSocketsManager_1.WebSocketsManager(this.server);
this.webSockets = new WebSocketsManager_js_1.WebSocketsManager(this.server);
this.server.on('connection', connection => {

@@ -38,3 +38,3 @@ this.connections.add(connection);

this.config.middlewareMode.server) {
this.webSockets = new WebSocketsManager_1.WebSocketsManager(this.config.middlewareMode.server);
this.webSockets = new WebSocketsManager_js_1.WebSocketsManager(this.config.middlewareMode.server);
}

@@ -41,0 +41,0 @@ }

@@ -5,2 +5,3 @@ /// <reference types="node" />

import { Server } from 'net';
import chokidar from 'chokidar';
export type MimeTypeMappings = Record<string, string>;

@@ -68,3 +69,7 @@ export interface DevServerCoreConfig {

disableFileWatcher?: boolean;
/**
* Additional options you want to provide to chokidar file watcher
*/
chokidarOptions?: chokidar.WatchOptions;
}
//# sourceMappingURL=DevServerCoreConfig.d.ts.map

@@ -1,6 +0,5 @@

import { RequestInit } from 'node-fetch';
import { DevServer } from './server/DevServer';
import { DevServerCoreConfig } from './server/DevServerCoreConfig';
import { Logger } from './logger/Logger';
import { Plugin } from './plugins/Plugin';
import { DevServer } from './server/DevServer.js';
import { DevServerCoreConfig } from './server/DevServerCoreConfig.js';
import { Logger } from './logger/Logger.js';
import { Plugin } from './plugins/Plugin.js';
export declare function virtualFilesPlugin(servedFiles: Record<string, string>): Plugin;

@@ -7,0 +6,0 @@ export declare function createTestServer(config: Partial<DevServerCoreConfig>, _mockLogger?: Logger): Promise<{

@@ -10,4 +10,3 @@ "use strict";

const nanocolors_1 = require("nanocolors");
const node_fetch_1 = __importDefault(require("node-fetch"));
const DevServer_1 = require("./server/DevServer");
const DevServer_js_1 = require("./server/DevServer.js");
const defaultConfig = {

@@ -43,3 +42,3 @@ hostname: 'localhost',

});
const server = new DevServer_1.DevServer(Object.assign(Object.assign(Object.assign({}, defaultConfig), config), { rootDir: config.rootDir, port }), _mockLogger);
const server = new DevServer_js_1.DevServer(Object.assign(Object.assign(Object.assign({}, defaultConfig), config), { rootDir: config.rootDir, port }), _mockLogger);
await server.start();

@@ -55,3 +54,3 @@ const url = new URL('http://localhost');

async function fetchText(url, init) {
const response = await (0, node_fetch_1.default)(url, init);
const response = await fetch(url, init);
(0, chai_1.expect)(response.status).to.equal(200);

@@ -58,0 +57,0 @@ return response.text();

/// <reference types="node" />
import { Server } from 'net';
import WebSocket from 'ws';
import { EventEmitter } from './EventEmitter';
import { EventEmitter } from './EventEmitter.js';
export declare const NAME_WEB_SOCKET_IMPORT = "/__web-dev-server__web-socket.js";

@@ -6,0 +6,0 @@ export declare const NAME_WEB_SOCKET_API = "wds";

@@ -8,3 +8,3 @@ "use strict";

const ws_1 = __importDefault(require("ws"));
const EventEmitter_1 = require("./EventEmitter");
const EventEmitter_js_1 = require("./EventEmitter.js");
exports.NAME_WEB_SOCKET_IMPORT = '/__web-dev-server__web-socket.js';

@@ -16,3 +16,3 @@ exports.NAME_WEB_SOCKET_API = 'wds';

*/
class WebSocketsManager extends EventEmitter_1.EventEmitter {
class WebSocketsManager extends EventEmitter_js_1.EventEmitter {
constructor(server) {

@@ -19,0 +19,0 @@ super();

@@ -1,4 +0,4 @@

import { Plugin } from '../plugins/Plugin';
import { Plugin } from '../plugins/Plugin.js';
export declare const webSocketScript: string;
export declare function webSocketsPlugin(): Plugin;
//# sourceMappingURL=webSocketsPlugin.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webSocketsPlugin = exports.webSocketScript = void 0;
const WebSocketsManager_1 = require("./WebSocketsManager");
const WebSocketsManager_js_1 = require("./WebSocketsManager.js");
const parse5_utils_1 = require("@web/parse5-utils");
exports.webSocketScript = `<!-- injected by web-dev-server -->
<script type="module" src="${WebSocketsManager_1.NAME_WEB_SOCKET_IMPORT}"></script>`;
<script type="module" src="${WebSocketsManager_js_1.NAME_WEB_SOCKET_IMPORT}"></script>`;
function webSocketsPlugin() {

@@ -12,8 +12,8 @@ return {

resolveImport({ source }) {
if (source === WebSocketsManager_1.NAME_WEB_SOCKET_IMPORT) {
return WebSocketsManager_1.NAME_WEB_SOCKET_IMPORT;
if (source === WebSocketsManager_js_1.NAME_WEB_SOCKET_IMPORT) {
return WebSocketsManager_js_1.NAME_WEB_SOCKET_IMPORT;
}
},
serve(context) {
if (context.path === WebSocketsManager_1.NAME_WEB_SOCKET_IMPORT) {
if (context.path === WebSocketsManager_js_1.NAME_WEB_SOCKET_IMPORT) {
// this code is inlined because TS compiles to CJS but we need this to be ESM

@@ -130,3 +130,3 @@ return `

const { protocol, host } = new URL(import.meta.url);
const webSocketUrl = \`ws\${protocol === 'https:' ? 's' : ''}://\${host}/${WebSocketsManager_1.NAME_WEB_SOCKET_API}\`;
const webSocketUrl = \`ws\${protocol === 'https:' ? 's' : ''}://\${host}/${WebSocketsManager_js_1.NAME_WEB_SOCKET_API}\`;

@@ -133,0 +133,0 @@ export let webSocket;

// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/index';
export * from './dist/index.js';
{
"name": "@web/dev-server-core",
"version": "0.7.0",
"version": "0.7.1",
"publishConfig": {

@@ -42,3 +42,3 @@ "access": "public"

"start:import-asset": "node demo/import-asset/start-server.js",
"test": "mocha \"test/**/*.test.{ts,js,mjs,cjs}\" --require ts-node/register",
"test": "mocha \"test/**/*.test.{ts,js,mjs,cjs}\" --require ts-node/register --exit --reporter dot",
"test:watch": "mocha \"test/**/*.test.{ts,js,mjs,cjs}\" --require ts-node/register --watch --watch-files src,test"

@@ -89,5 +89,4 @@ },

"nanoid": "^3.1.25",
"node-fetch": "3.0.0-beta.9",
"portfinder": "^1.0.32"
}
}

@@ -14,5 +14,5 @@ /**

*/
export * from './modification';
export * from './predicates';
export * from './util';
export * from './walking';
export * from './modification.js';
export * from './predicates.js';
export * from './util.js';
export * from './walking.js';

@@ -15,4 +15,4 @@ /**

import { isElement, Predicate, predicates as p } from './predicates';
import { defaultChildNodes, GetChildNodes } from './util';
import { isElement, Predicate, predicates as p } from './predicates.js';
import { defaultChildNodes, GetChildNodes } from './util.js';

@@ -19,0 +19,0 @@ /**

@@ -16,4 +16,4 @@ /**

import { isDocumentFragment, predicates as p } from './predicates';
import { queryAll } from './walking';
import { isDocumentFragment, predicates as p } from './predicates.js';
import { queryAll } from './walking.js';

@@ -20,0 +20,0 @@ function newTextNode(value: string): any {

@@ -16,3 +16,3 @@ /* eslint-disable */

import { getAttribute, getAttributeIndex, getTextContent } from './util';
import { getAttribute, getAttributeIndex, getTextContent } from './util.js';

@@ -19,0 +19,0 @@ /**

@@ -15,5 +15,11 @@ /**

import { constructors } from './modification';
import { isCommentNode, isDocument, isDocumentFragment, isElement, isTextNode } from './predicates';
import { nodeWalkAll } from './walking';
import { constructors } from './modification.js';
import {
isCommentNode,
isDocument,
isDocumentFragment,
isElement,
isTextNode,
} from './predicates.js';
import { nodeWalkAll } from './walking.js';

@@ -20,0 +26,0 @@ /**

@@ -15,5 +15,5 @@ /**

import * as iteration from './iteration';
import { isElement, Predicate, predicates as p } from './predicates';
import { defaultChildNodes, GetChildNodes } from './util';
import * as iteration from './iteration.js';
import { isElement, Predicate, predicates as p } from './predicates.js';
import { defaultChildNodes, GetChildNodes } from './util.js';

@@ -20,0 +20,0 @@ /**

@@ -8,6 +8,6 @@ // reexports of types from internal libraries

export { DevServer } from './server/DevServer';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager';
export { DevServer } from './server/DevServer.js';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin.js';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig.js';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager.js';
export {

@@ -19,5 +19,5 @@ getRequestBrowserPath,

isInlineScriptRequest,
} from './utils';
export { Logger, ErrorWithLocation } from './logger/Logger';
export { PluginSyntaxError } from './logger/PluginSyntaxError';
export { PluginError } from './logger/PluginError';
} from './utils.js';
export { Logger, ErrorWithLocation } from './logger/Logger.js';
export { PluginSyntaxError } from './logger/PluginSyntaxError.js';
export { PluginError } from './logger/PluginError.js';
import { Middleware } from 'koa';
import path from 'path';
import { toBrowserPath } from '../utils';
import { Logger } from '../logger/Logger';
import { toBrowserPath } from '../utils.js';
import { Logger } from '../logger/Logger.js';

@@ -6,0 +6,0 @@ /**

@@ -5,3 +5,3 @@ import LRUCache from 'lru-cache';

import { promisify } from 'util';
import { RequestCancelledError } from '../utils';
import { RequestCancelledError } from '../utils.js';

@@ -8,0 +8,0 @@ const fsStat = promisify(fs.stat);

import { FSWatcher } from 'chokidar';
import { Middleware } from 'koa';
import { DevServerCoreConfig } from '../server/DevServerCoreConfig';
import { PluginTransformCache } from './PluginTransformCache';
import { getRequestFilePath, getResponseBody, RequestCancelledError } from '../utils';
import { Logger } from '../logger/Logger';
import type { PluginSyntaxError } from '../logger/PluginSyntaxError';
import { DevServerCoreConfig } from '../server/DevServerCoreConfig.js';
import { PluginTransformCache } from './PluginTransformCache.js';
import { getRequestFilePath, getResponseBody, RequestCancelledError } from '../utils.js';
import { Logger } from '../logger/Logger.js';
import type { PluginSyntaxError } from '../logger/PluginSyntaxError.js';

@@ -10,0 +10,0 @@ /**

import { Middleware } from 'koa';
import send from 'koa-send';
import koaStatic, { Options as KoaStaticOptions } from 'koa-static';
import { isOutsideRootDir, resolvePathOutsideRootDir } from '../utils';
import { isOutsideRootDir, resolvePathOutsideRootDir } from '../utils.js';

@@ -6,0 +6,0 @@ /**

@@ -5,3 +5,3 @@ import { Middleware } from 'koa';

import { getRequestFilePath } from '../utils';
import { getRequestFilePath } from '../utils.js';

@@ -8,0 +8,0 @@ /**

@@ -5,4 +5,4 @@ import picoMatch from 'picomatch';

import { MimeTypeMappings } from '../server/DevServerCoreConfig';
import { Plugin } from './Plugin';
import { getRequestFilePath } from '../utils';
import { Plugin } from './Plugin.js';
import { getRequestFilePath } from '../utils.js';

@@ -9,0 +9,0 @@ function createMatcher(rootDir: string, pattern: string) {

@@ -7,9 +7,9 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

import { queryAll, predicates, getTextContent, setTextContent } from '../dom5';
import { queryAll, predicates, getTextContent, setTextContent } from '../dom5/index.js';
import { parse as parseHtml, serialize as serializeHtml } from 'parse5';
import { Plugin } from './Plugin';
import { PluginSyntaxError } from '../logger/PluginSyntaxError';
import { toFilePath } from '../utils';
import { Logger } from '../logger/Logger';
import { parseDynamicImport } from './parseDynamicImport';
import { Plugin } from './Plugin.js';
import { PluginSyntaxError } from '../logger/PluginSyntaxError.js';
import { toFilePath } from '../utils.js';
import { Logger } from '../logger/Logger.js';
import { parseDynamicImport } from './parseDynamicImport.js';

@@ -16,0 +16,0 @@ export type ResolveImport = (

@@ -1,6 +0,6 @@

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { transformModuleImportsPlugin } from '../plugins/transformModuleImportsPlugin';
import { webSocketsPlugin } from '../web-sockets/webSocketsPlugin';
import { mimeTypesPlugin } from '../plugins/mimeTypesPlugin';
import { Logger } from '../logger/Logger';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { transformModuleImportsPlugin } from '../plugins/transformModuleImportsPlugin.js';
import { webSocketsPlugin } from '../web-sockets/webSocketsPlugin.js';
import { mimeTypesPlugin } from '../plugins/mimeTypesPlugin.js';
import { Logger } from '../logger/Logger.js';

@@ -7,0 +7,0 @@ export function addPlugins(logger: Logger, config: DevServerCoreConfig) {

@@ -5,13 +5,13 @@ import { Middleware } from 'koa';

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { basePathMiddleware } from '../middleware/basePathMiddleware';
import { etagCacheMiddleware } from '../middleware/etagCacheMiddleware';
import { historyApiFallbackMiddleware } from '../middleware/historyApiFallbackMiddleware';
import { pluginMimeTypeMiddleware } from '../middleware/pluginMimeTypeMiddleware';
import { pluginServeMiddleware } from '../middleware/pluginServeMiddleware';
import { pluginTransformMiddleware } from '../middleware/pluginTransformMiddleware';
import { Logger } from '../logger/Logger';
import { watchServedFilesMiddleware } from '../middleware/watchServedFilesMiddleware';
import { pluginFileParsedMiddleware } from '../middleware/pluginFileParsedMiddleware';
import { serveFilesMiddleware } from '../middleware/serveFilesMiddleware';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { basePathMiddleware } from '../middleware/basePathMiddleware.js';
import { etagCacheMiddleware } from '../middleware/etagCacheMiddleware.js';
import { historyApiFallbackMiddleware } from '../middleware/historyApiFallbackMiddleware.js';
import { pluginMimeTypeMiddleware } from '../middleware/pluginMimeTypeMiddleware.js';
import { pluginServeMiddleware } from '../middleware/pluginServeMiddleware.js';
import { pluginTransformMiddleware } from '../middleware/pluginTransformMiddleware.js';
import { Logger } from '../logger/Logger.js';
import { watchServedFilesMiddleware } from '../middleware/watchServedFilesMiddleware.js';
import { pluginFileParsedMiddleware } from '../middleware/pluginFileParsedMiddleware.js';
import { serveFilesMiddleware } from '../middleware/serveFilesMiddleware.js';

@@ -18,0 +18,0 @@ /**

@@ -9,6 +9,6 @@ import Koa from 'koa';

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { createMiddleware } from './createMiddleware';
import { Logger } from '../logger/Logger';
import { addPlugins } from './addPlugins';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { createMiddleware } from './createMiddleware.js';
import { Logger } from '../logger/Logger.js';
import { addPlugins } from './addPlugins.js';

@@ -15,0 +15,0 @@ /**

@@ -6,6 +6,6 @@ import Koa from 'koa';

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { createServer } from './createServer';
import { Logger } from '../logger/Logger';
import { WebSocketsManager } from '../web-sockets/WebSocketsManager';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { createServer } from './createServer.js';
import { Logger } from '../logger/Logger.js';
import { WebSocketsManager } from '../web-sockets/WebSocketsManager.js';

@@ -22,3 +22,3 @@ export class DevServer {

public logger: Logger,
public fileWatcher = chokidar.watch([]),
public fileWatcher = chokidar.watch([], config.chokidarOptions),
) {

@@ -25,0 +25,0 @@ if (!config) throw new Error('Missing config.');

import { Middleware } from 'koa';
import { Plugin } from '../plugins/Plugin';
import { Server } from 'net';
import chokidar from 'chokidar';

@@ -70,2 +71,7 @@ export type MimeTypeMappings = Record<string, string>;

disableFileWatcher?: boolean;
/**
* Additional options you want to provide to chokidar file watcher
*/
chokidarOptions?: chokidar.WatchOptions;
}
import portfinder from 'portfinder';
import { expect } from 'chai';
import { green, red, yellow } from 'nanocolors';
import fetch, { RequestInit } from 'node-fetch';
import { DevServer } from './server/DevServer';
import { DevServerCoreConfig } from './server/DevServerCoreConfig';
import { Logger } from './logger/Logger';
import { Plugin } from './plugins/Plugin';
import { DevServer } from './server/DevServer.js';
import { DevServerCoreConfig } from './server/DevServerCoreConfig.js';
import { Logger } from './logger/Logger.js';
import { Plugin } from './plugins/Plugin.js';

@@ -11,0 +10,0 @@ const defaultConfig: Omit<DevServerCoreConfig, 'port' | 'rootDir'> = {

import { Server } from 'net';
import WebSocket from 'ws';
import { EventEmitter } from './EventEmitter';
import { EventEmitter } from './EventEmitter.js';

@@ -5,0 +5,0 @@ export const NAME_WEB_SOCKET_IMPORT = '/__web-dev-server__web-socket.js';

@@ -1,3 +0,3 @@

import { Plugin } from '../plugins/Plugin';
import { NAME_WEB_SOCKET_IMPORT, NAME_WEB_SOCKET_API } from './WebSocketsManager';
import { Plugin } from '../plugins/Plugin.js';
import { NAME_WEB_SOCKET_IMPORT, NAME_WEB_SOCKET_API } from './WebSocketsManager.js';
import { appendToDocument, isHtmlFragment } from '@web/parse5-utils';

@@ -4,0 +4,0 @@

// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/test-helpers';
export * from './dist/test-helpers.js';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc