Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web/dev-server-core

Package Overview
Dependencies
Maintainers
7
Versions
85
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.2.1 to 0.2.2

dist/plugins/transformModuleImportsPlugin.d.ts

6

CHANGELOG.md
# @web/dev-server-core
## 0.2.2
### Patch Changes
- bc1741d: expose getHtmlPath function
## 0.2.1

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

2

dist/dom5/modification.d.ts

@@ -22,3 +22,3 @@ declare function newTextNode(value: string): any;

export declare function removeFakeRootElements(ast: Node): void;
export declare function append(parent: Node, newNode: Node): void;
export declare function append(parent: any, newNode: any): void;
export declare const constructors: {

@@ -25,0 +25,0 @@ text: typeof newTextNode;

export { DevServer } from './server/DevServer';
export { Plugin } from './Plugin';
export { DevServerCoreConfig, MimeTypeMappings } from './DevServerCoreConfig';
export { getRequestBrowserPath, getRequestFilePath, getResponseBody, isInlineScriptRequest, } from './utils';
export { getRequestBrowserPath, getRequestFilePath, getResponseBody, getHtmlPath, isInlineScriptRequest, } from './utils';
export { Logger } from './logger/Logger';

@@ -6,0 +6,0 @@ export { EventStreamManager } from './event-stream/EventStreamManager';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginError = exports.PluginSyntaxError = exports.Server = exports.Koa = exports.FSWatcher = exports.EventStreamManager = exports.isInlineScriptRequest = exports.getResponseBody = exports.getRequestFilePath = exports.getRequestBrowserPath = exports.DevServer = void 0;
exports.PluginError = exports.PluginSyntaxError = exports.Server = exports.Koa = exports.FSWatcher = exports.EventStreamManager = exports.isInlineScriptRequest = exports.getHtmlPath = exports.getResponseBody = exports.getRequestFilePath = exports.getRequestBrowserPath = exports.DevServer = void 0;
var DevServer_1 = require("./server/DevServer");

@@ -14,2 +14,3 @@ Object.defineProperty(exports, "DevServer", { enumerable: true, get: function () { return DevServer_1.DevServer; } });

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; } });

@@ -16,0 +17,0 @@ var EventStreamManager_1 = require("./event-stream/EventStreamManager");

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

const lru_cache_1 = __importDefault(require("lru-cache"));
const fs_1 = __importDefault(require("fs"));
const util_1 = require("util");
const utils_1 = require("../utils");
const fsAccess = util_1.promisify(fs_1.default.access);
async function fileExists(filePath) {
try {
await fsAccess(filePath);
return true;
}
catch (_a) {
return false;
}
}
class PluginTransformCache {

@@ -46,2 +58,6 @@ constructor(fileWatcher, rootDir) {

const filePath = utils_1.getRequestFilePath(context, this.rootDir);
if (!(await fileExists(filePath))) {
// only cache files on the file system
return;
}
if (typeof body === 'string') {

@@ -48,0 +64,0 @@ let cacheKeysForFilePath = this.cacheKeysPerFilePath.get(filePath);

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

}): ResolveResult | Promise<ResolveResult>;
transformImport?(args: {
source: string;
context: Context;
}): ResolveResult | Promise<ResolveResult>;
resolveMimeType?(context: Context): ResolveMimeTypeResult | Promise<ResolveMimeTypeResult>;
}
//# sourceMappingURL=Plugin.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPlugins = void 0;
const resolveModuleImportsPlugin_1 = require("../plugins/resolveModuleImportsPlugin");
const transformModuleImportsPlugin_1 = require("../plugins/transformModuleImportsPlugin");
const eventStreamPlugin_1 = require("../event-stream/eventStreamPlugin");

@@ -13,4 +13,4 @@ const mimeTypesPlugin_1 = require("../plugins/mimeTypesPlugin");

}
if ((_a = config.plugins) === null || _a === void 0 ? void 0 : _a.some(pl => 'resolveImport' in pl)) {
plugins.push(resolveModuleImportsPlugin_1.resolveModuleImportsPlugin(config.plugins, config.rootDir));
if ((_a = config.plugins) === null || _a === void 0 ? void 0 : _a.some(pl => 'resolveImport' in pl || 'transformImport' in pl)) {
plugins.push(transformModuleImportsPlugin_1.transformModuleImportsPlugin(config.plugins, config.rootDir));
}

@@ -17,0 +17,0 @@ if (config.eventStream && ((_b = config.plugins) === null || _b === void 0 ? void 0 : _b.some(pl => pl.injectEventStream))) {

@@ -5,2 +5,4 @@ import { RequestInit } from 'node-fetch';

import { Logger } from './logger/Logger';
import { Plugin } from './Plugin';
export declare function virtualFilesPlugin(servedFiles: Record<string, string>): Plugin;
export declare function createTestServer(config: Partial<DevServerCoreConfig>, _mockLogger?: Logger): Promise<{

@@ -7,0 +9,0 @@ server: DevServer;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.expectNotIncludes = exports.expectIncludes = exports.fetchText = exports.timeout = exports.createTestServer = void 0;
exports.expectNotIncludes = exports.expectIncludes = exports.fetchText = exports.timeout = exports.createTestServer = exports.virtualFilesPlugin = void 0;
const portfinder_1 = __importDefault(require("portfinder"));

@@ -35,2 +35,13 @@ const chai_1 = require("chai");

};
function virtualFilesPlugin(servedFiles) {
return {
name: 'test-helpers-virtual-files',
serve(context) {
if (context.path in servedFiles) {
return servedFiles[context.path];
}
},
};
}
exports.virtualFilesPlugin = virtualFilesPlugin;
async function createTestServer(config, _mockLogger = mockLogger) {

@@ -37,0 +48,0 @@ if (!config.rootDir) {

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

export declare function toFilePath(browserPath: string): string;
export declare function getHtmlPath(path: string): string;
export declare class RequestCancelledError extends Error {

@@ -16,0 +17,0 @@ }

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequestFilePath = exports.getRequestBrowserPath = exports.isInlineScriptRequest = exports.getResponseBody = exports.RequestCancelledError = exports.toFilePath = exports.toBrowserPath = void 0;
exports.getRequestFilePath = exports.getRequestBrowserPath = exports.isInlineScriptRequest = exports.getResponseBody = exports.RequestCancelledError = exports.getHtmlPath = exports.toFilePath = exports.toBrowserPath = void 0;
const is_stream_1 = __importDefault(require("is-stream"));

@@ -31,2 +31,6 @@ const get_stream_1 = __importDefault(require("get-stream"));

exports.toFilePath = toFilePath;
function getHtmlPath(path) {
return path.endsWith('/') ? `${path}index.html` : path;
}
exports.getHtmlPath = getHtmlPath;
class RequestCancelledError extends Error {

@@ -33,0 +37,0 @@ }

{
"name": "@web/dev-server-core",
"version": "0.2.1",
"version": "0.2.2",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -173,3 +173,3 @@ /**

export function append(parent: Node, newNode: Node) {
export function append(parent: any, newNode: any) {
const index = (parent.childNodes && parent.childNodes.length) || 0;

@@ -176,0 +176,0 @@ insertNode(parent, index, newNode);

@@ -8,2 +8,3 @@ export { DevServer } from './server/DevServer';

getResponseBody,
getHtmlPath,
isInlineScriptRequest,

@@ -10,0 +11,0 @@ } from './utils';

import LRUCache from 'lru-cache';
import { FSWatcher } from 'chokidar';
import { Context } from 'koa';
import fs from 'fs';
import { promisify } from 'util';
import { getResponseBody, getRequestFilePath, RequestCancelledError } from '../utils';
const fsAccess = promisify(fs.access);
async function fileExists(filePath: string) {
try {
await fsAccess(filePath);
return true;
} catch {
return false;
}
}
interface CacheEntry {

@@ -53,2 +66,7 @@ body: string;

if (!(await fileExists(filePath))) {
// only cache files on the file system
return;
}
if (typeof body === 'string') {

@@ -55,0 +73,0 @@ let cacheKeysForFilePath = this.cacheKeysPerFilePath.get(filePath);

@@ -41,3 +41,7 @@ import { FSWatcher } from 'chokidar';

}): ResolveResult | Promise<ResolveResult>;
transformImport?(args: {
source: string;
context: Context;
}): ResolveResult | Promise<ResolveResult>;
resolveMimeType?(context: Context): ResolveMimeTypeResult | Promise<ResolveMimeTypeResult>;
}
import { DevServerCoreConfig } from '../DevServerCoreConfig';
import { Plugin } from '../Plugin';
import { resolveModuleImportsPlugin } from '../plugins/resolveModuleImportsPlugin';
import { transformModuleImportsPlugin } from '../plugins/transformModuleImportsPlugin';
import { eventStreamPlugin } from '../event-stream/eventStreamPlugin';

@@ -14,4 +14,4 @@ import { mimeTypesPlugin } from '../plugins/mimeTypesPlugin';

if (config.plugins?.some(pl => 'resolveImport' in pl)) {
plugins.push(resolveModuleImportsPlugin(config.plugins, config.rootDir));
if (config.plugins?.some(pl => 'resolveImport' in pl || 'transformImport' in pl)) {
plugins.push(transformModuleImportsPlugin(config.plugins, config.rootDir));
}

@@ -18,0 +18,0 @@

@@ -9,2 +9,3 @@ import portfinder from 'portfinder';

import { Logger } from './logger/Logger';
import { Plugin } from './Plugin';

@@ -35,2 +36,13 @@ const defaultConfig: Omit<DevServerCoreConfig, 'port' | 'rootDir'> = {

export function virtualFilesPlugin(servedFiles: Record<string, string>): Plugin {
return {
name: 'test-helpers-virtual-files',
serve(context) {
if (context.path in servedFiles) {
return servedFiles[context.path];
}
},
};
}
export async function createTestServer(

@@ -37,0 +49,0 @@ config: Partial<DevServerCoreConfig>,

@@ -27,2 +27,6 @@ import { Context } from 'koa';

export function getHtmlPath(path: string) {
return path.endsWith('/') ? `${path}index.html` : path;
}
export class RequestCancelledError extends Error {}

@@ -29,0 +33,0 @@

import cjsEntrypoint from './dist/test-helpers.js';
const { expectNotIncludes, expectIncludes, fetchText, timeout, createTestServer } = cjsEntrypoint;
const {
expectNotIncludes,
expectIncludes,
fetchText,
timeout,
createTestServer,
virtualFilesPlugin,
} = cjsEntrypoint;
export { expectNotIncludes, expectIncludes, fetchText, timeout, createTestServer };
export {
expectNotIncludes,
expectIncludes,
fetchText,
timeout,
createTestServer,
virtualFilesPlugin,
};

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