feat: init
This commit is contained in:
51
node_modules/unplugin/dist/context-CKhLGGrj.mjs
generated
vendored
Normal file
51
node_modules/unplugin/dist/context-CKhLGGrj.mjs
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { t as parse } from "./parse-DN2jPtpt.mjs";
|
||||
import { resolve } from "node:path";
|
||||
import { Buffer } from "node:buffer";
|
||||
|
||||
//#region src/rspack/context.ts
|
||||
function createBuildContext(compiler, compilation, loaderContext, inputSourceMap) {
|
||||
return {
|
||||
getNativeBuildContext() {
|
||||
return {
|
||||
framework: "rspack",
|
||||
compiler,
|
||||
compilation,
|
||||
loaderContext,
|
||||
inputSourceMap
|
||||
};
|
||||
},
|
||||
addWatchFile(file) {
|
||||
const resolvedPath = resolve(process.cwd(), file);
|
||||
compilation.fileDependencies.add(resolvedPath);
|
||||
loaderContext?.addDependency(resolvedPath);
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(compilation.fileDependencies);
|
||||
},
|
||||
parse,
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
const { sources } = compilation.compiler.webpack;
|
||||
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function createContext(loader) {
|
||||
return {
|
||||
error: (error) => loader.emitError(normalizeMessage(error)),
|
||||
warn: (message) => loader.emitWarning(normalizeMessage(message))
|
||||
};
|
||||
}
|
||||
function normalizeMessage(error) {
|
||||
const err = new Error(typeof error === "string" ? error : error.message);
|
||||
if (typeof error === "object") {
|
||||
err.stack = error.stack;
|
||||
err.cause = error.meta;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { createContext as n, normalizeMessage as r, createBuildContext as t };
|
||||
65
node_modules/unplugin/dist/context-MD-xQmYI.mjs
generated
vendored
Normal file
65
node_modules/unplugin/dist/context-MD-xQmYI.mjs
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { t as parse } from "./parse-DN2jPtpt.mjs";
|
||||
import { createRequire } from "node:module";
|
||||
import { resolve } from "node:path";
|
||||
import { Buffer } from "node:buffer";
|
||||
import process from "node:process";
|
||||
|
||||
//#region src/webpack/context.ts
|
||||
function contextOptionsFromCompilation(compilation) {
|
||||
return {
|
||||
addWatchFile(file) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
|
||||
}
|
||||
};
|
||||
}
|
||||
const require = createRequire(import.meta.url);
|
||||
function getSource(fileSource) {
|
||||
return new (require("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
|
||||
}
|
||||
function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
|
||||
return {
|
||||
parse,
|
||||
addWatchFile(id) {
|
||||
options.addWatchFile(resolve(process.cwd(), id));
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
|
||||
compilation.emitAsset(outFileName, getSource(emittedFile.source));
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return options.getWatchFiles();
|
||||
},
|
||||
getNativeBuildContext() {
|
||||
return {
|
||||
framework: "webpack",
|
||||
compiler,
|
||||
compilation,
|
||||
loaderContext,
|
||||
inputSourceMap
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function createContext(loader) {
|
||||
return {
|
||||
error: (error) => loader.emitError(normalizeMessage(error)),
|
||||
warn: (message) => loader.emitWarning(normalizeMessage(message))
|
||||
};
|
||||
}
|
||||
function normalizeMessage(error) {
|
||||
const err = new Error(typeof error === "string" ? error : error.message);
|
||||
if (typeof error === "object") {
|
||||
err.stack = error.stack;
|
||||
err.cause = error.meta;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { normalizeMessage as i, createBuildContext as n, createContext as r, contextOptionsFromCompilation as t };
|
||||
210
node_modules/unplugin/dist/index.d.mts
generated
vendored
Normal file
210
node_modules/unplugin/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
import VirtualModulesPlugin from "webpack-virtual-modules";
|
||||
import { CompilationContext, JsPlugin } from "@farmfe/core";
|
||||
import { Compilation, Compiler as RspackCompiler, LoaderContext, RspackPluginInstance } from "@rspack/core";
|
||||
import { BunPlugin, PluginBuilder } from "bun";
|
||||
import { BuildOptions, Loader, Plugin as EsbuildPlugin, PluginBuild } from "esbuild";
|
||||
import { Plugin as RolldownPlugin } from "rolldown";
|
||||
import { EmittedAsset, Plugin as RollupPlugin, PluginContextMeta, SourceMapInput } from "rollup";
|
||||
import { Plugin as UnloaderPlugin } from "unloader";
|
||||
import { Plugin as VitePlugin } from "vite";
|
||||
import { Compilation as Compilation$1, Compiler as WebpackCompiler, LoaderContext as LoaderContext$1, WebpackPluginInstance } from "webpack";
|
||||
|
||||
//#region src/types.d.ts
|
||||
type Thenable<T> = T | Promise<T>;
|
||||
/**
|
||||
* Null or whatever
|
||||
*/
|
||||
type Nullable<T> = T | null | undefined;
|
||||
/**
|
||||
* Array, or not yet
|
||||
*/
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
interface SourceMapCompact {
|
||||
file?: string | undefined;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sourceRoot?: string | undefined;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[] | undefined;
|
||||
version: number;
|
||||
}
|
||||
type TransformResult = string | {
|
||||
code: string;
|
||||
map?: SourceMapInput | SourceMapCompact | null | undefined;
|
||||
} | null | undefined | void;
|
||||
interface ExternalIdResult {
|
||||
id: string;
|
||||
external?: boolean | undefined;
|
||||
}
|
||||
type NativeBuildContext = {
|
||||
framework: "webpack";
|
||||
compiler: WebpackCompiler;
|
||||
compilation?: Compilation$1 | undefined;
|
||||
loaderContext?: LoaderContext$1<{
|
||||
unpluginName: string;
|
||||
}> | undefined;
|
||||
inputSourceMap?: any;
|
||||
} | {
|
||||
framework: "esbuild";
|
||||
build: PluginBuild;
|
||||
} | {
|
||||
framework: "rspack";
|
||||
compiler: RspackCompiler;
|
||||
compilation: Compilation;
|
||||
loaderContext?: LoaderContext | undefined;
|
||||
inputSourceMap?: any;
|
||||
} | {
|
||||
framework: "farm";
|
||||
context: CompilationContext;
|
||||
} | {
|
||||
framework: "bun";
|
||||
build: PluginBuilder;
|
||||
};
|
||||
interface UnpluginBuildContext {
|
||||
addWatchFile: (id: string) => void;
|
||||
emitFile: (emittedFile: EmittedAsset) => void;
|
||||
getWatchFiles: () => string[];
|
||||
parse: (input: string, options?: any) => any;
|
||||
getNativeBuildContext?: (() => NativeBuildContext) | undefined;
|
||||
}
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type FilterPattern = Arrayable<StringOrRegExp>;
|
||||
type StringFilter = FilterPattern | {
|
||||
include?: FilterPattern | undefined;
|
||||
exclude?: FilterPattern | undefined;
|
||||
};
|
||||
interface HookFilter {
|
||||
id?: StringFilter | undefined;
|
||||
code?: StringFilter | undefined;
|
||||
}
|
||||
interface ObjectHook<T extends HookFnMap[keyof HookFnMap], F extends keyof HookFilter> {
|
||||
filter?: Pick<HookFilter, F> | undefined;
|
||||
handler: T;
|
||||
}
|
||||
type Hook<T extends HookFnMap[keyof HookFnMap], F extends keyof HookFilter> = T | ObjectHook<T, F>;
|
||||
interface HookFnMap {
|
||||
buildStart: (this: UnpluginBuildContext) => Thenable<void>;
|
||||
buildEnd: (this: UnpluginBuildContext) => Thenable<void>;
|
||||
transform: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
|
||||
load: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
|
||||
resolveId: (this: UnpluginBuildContext & UnpluginContext, id: string, importer: string | undefined, options: {
|
||||
isEntry: boolean;
|
||||
}) => Thenable<string | ExternalIdResult | null | undefined>;
|
||||
writeBundle: (this: void) => Thenable<void>;
|
||||
}
|
||||
interface UnpluginOptions {
|
||||
name: string;
|
||||
enforce?: "post" | "pre" | undefined;
|
||||
buildStart?: HookFnMap["buildStart"] | undefined;
|
||||
buildEnd?: HookFnMap["buildEnd"] | undefined;
|
||||
transform?: Hook<HookFnMap["transform"], "code" | "id"> | undefined;
|
||||
load?: Hook<HookFnMap["load"], "id"> | undefined;
|
||||
resolveId?: Hook<HookFnMap["resolveId"], "id"> | undefined;
|
||||
writeBundle?: HookFnMap["writeBundle"] | undefined;
|
||||
watchChange?: ((this: UnpluginBuildContext, id: string, change: {
|
||||
event: "create" | "update" | "delete";
|
||||
}) => void) | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be loaded.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*
|
||||
* @deprecated Use `load.filter` instead.
|
||||
*/
|
||||
loadInclude?: ((id: string) => boolean | null | undefined) | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be transformed.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*
|
||||
* @deprecated Use `transform.filter` instead.
|
||||
*/
|
||||
transformInclude?: ((id: string) => boolean | null | undefined) | undefined;
|
||||
rollup?: Partial<RollupPlugin> | undefined;
|
||||
webpack?: ((compiler: WebpackCompiler) => void) | undefined;
|
||||
rspack?: ((compiler: RspackCompiler) => void) | undefined;
|
||||
vite?: Partial<VitePlugin> | undefined;
|
||||
unloader?: Partial<UnloaderPlugin> | undefined;
|
||||
rolldown?: Partial<RolldownPlugin> | undefined;
|
||||
esbuild?: {
|
||||
onResolveFilter?: RegExp | undefined;
|
||||
onLoadFilter?: RegExp | undefined;
|
||||
loader?: Loader | ((code: string, id: string) => Loader) | undefined;
|
||||
setup?: ((build: PluginBuild) => void | Promise<void>) | undefined;
|
||||
config?: ((options: BuildOptions) => void) | undefined;
|
||||
} | undefined;
|
||||
farm?: Partial<JsPlugin> | undefined;
|
||||
bun?: Partial<BunPlugin> | undefined;
|
||||
}
|
||||
interface ResolvedUnpluginOptions extends UnpluginOptions {
|
||||
__vfs?: VirtualModulesPlugin | undefined;
|
||||
__vfsModules?: Map<string, Promise<unknown>> | Set<string> | undefined;
|
||||
__virtualModulePrefix: string;
|
||||
}
|
||||
type UnpluginFactory<UserOptions, Nested extends boolean = boolean> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
|
||||
type UnpluginFactoryOutput<UserOptions, Return> = undefined extends UserOptions ? (options?: UserOptions | undefined) => Return : (options: UserOptions) => Return;
|
||||
interface UnpluginInstance<UserOptions, Nested extends boolean = boolean> {
|
||||
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<RollupPlugin> : RollupPlugin>;
|
||||
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<VitePlugin> : VitePlugin>;
|
||||
rolldown: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<RolldownPlugin> : RolldownPlugin>;
|
||||
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
|
||||
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
|
||||
esbuild: UnpluginFactoryOutput<UserOptions, EsbuildPlugin>;
|
||||
unloader: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<UnloaderPlugin> : UnloaderPlugin>;
|
||||
farm: UnpluginFactoryOutput<UserOptions, JsPlugin>;
|
||||
bun: UnpluginFactoryOutput<UserOptions, BunPlugin>;
|
||||
raw: UnpluginFactory<UserOptions, Nested>;
|
||||
}
|
||||
type UnpluginContextMeta = Partial<PluginContextMeta> & ({
|
||||
framework: "rollup" | "vite" | "rolldown" | "farm" | "unloader";
|
||||
} | {
|
||||
framework: "webpack";
|
||||
webpack: {
|
||||
compiler: WebpackCompiler;
|
||||
};
|
||||
} | {
|
||||
framework: "esbuild"; /** Set the host plugin name of esbuild when returning multiple plugins */
|
||||
esbuildHostName?: string | undefined;
|
||||
} | {
|
||||
framework: "bun"; /** Set the host plugin name of bun when returning multiple plugins */
|
||||
bunHostName?: string | undefined;
|
||||
} | {
|
||||
framework: "rspack";
|
||||
rspack: {
|
||||
compiler: RspackCompiler;
|
||||
};
|
||||
});
|
||||
interface UnpluginMessage {
|
||||
name?: string | undefined;
|
||||
id?: string | undefined;
|
||||
message: string;
|
||||
stack?: string | undefined;
|
||||
code?: string | undefined;
|
||||
plugin?: string | undefined;
|
||||
pluginCode?: unknown | undefined;
|
||||
loc?: {
|
||||
column: number;
|
||||
file?: string | undefined;
|
||||
line: number;
|
||||
} | undefined;
|
||||
meta?: any;
|
||||
}
|
||||
interface UnpluginContext {
|
||||
error: (message: string | UnpluginMessage) => void;
|
||||
warn: (message: string | UnpluginMessage) => void;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/define.d.ts
|
||||
declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
|
||||
declare function createEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["esbuild"];
|
||||
declare function createRollupPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rollup"];
|
||||
declare function createVitePlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["vite"];
|
||||
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rolldown"];
|
||||
declare function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["webpack"];
|
||||
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rspack"];
|
||||
declare function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["farm"];
|
||||
declare function createUnloaderPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["unloader"];
|
||||
declare function createBunPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["bun"];
|
||||
//#endregion
|
||||
//#region src/utils/parse.d.ts
|
||||
declare function setParseImpl(customParse: (code: string, opts?: any) => any): void;
|
||||
//#endregion
|
||||
export { Arrayable, type BunPlugin, type EsbuildPlugin, ExternalIdResult, FilterPattern, Hook, HookFilter, HookFnMap, NativeBuildContext, Nullable, ObjectHook, ResolvedUnpluginOptions, type RolldownPlugin, type RollupPlugin, type RspackCompiler, type RspackPluginInstance, SourceMapCompact, StringFilter, StringOrRegExp, Thenable, TransformResult, type UnloaderPlugin, UnpluginBuildContext, UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginFactoryOutput, UnpluginInstance, UnpluginMessage, UnpluginOptions, type VitePlugin, type WebpackCompiler, type WebpackPluginInstance, createBunPlugin, createEsbuildPlugin, createFarmPlugin, createRolldownPlugin, createRollupPlugin, createRspackPlugin, createUnloaderPlugin, createUnplugin, createVitePlugin, createWebpackPlugin, setParseImpl };
|
||||
1210
node_modules/unplugin/dist/index.mjs
generated
vendored
Normal file
1210
node_modules/unplugin/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
119
node_modules/unplugin/dist/parse-DN2jPtpt.mjs
generated
vendored
Normal file
119
node_modules/unplugin/dist/parse-DN2jPtpt.mjs
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
import { resolve } from "node:path";
|
||||
import picomatch from "picomatch";
|
||||
|
||||
//#region src/utils/general.ts
|
||||
function toArray(array) {
|
||||
array = array || [];
|
||||
if (Array.isArray(array)) return array;
|
||||
return [array];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils/filter.ts
|
||||
const BACKSLASH_REGEX = /\\/g;
|
||||
function normalize$1(path) {
|
||||
return path.replace(BACKSLASH_REGEX, "/");
|
||||
}
|
||||
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
||||
function isAbsolute$1(path) {
|
||||
return ABSOLUTE_PATH_REGEX.test(path);
|
||||
}
|
||||
function getMatcherString(glob, cwd) {
|
||||
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
||||
return normalize$1(resolve(cwd, glob));
|
||||
}
|
||||
function patternToIdFilter(pattern) {
|
||||
if (pattern instanceof RegExp) return (id) => {
|
||||
const normalizedId = normalize$1(id);
|
||||
const result = pattern.test(normalizedId);
|
||||
pattern.lastIndex = 0;
|
||||
return result;
|
||||
};
|
||||
const matcher = picomatch(getMatcherString(pattern, process.cwd()), { dot: true });
|
||||
return (id) => {
|
||||
return matcher(normalize$1(id));
|
||||
};
|
||||
}
|
||||
function patternToCodeFilter(pattern) {
|
||||
if (pattern instanceof RegExp) return (code) => {
|
||||
const result = pattern.test(code);
|
||||
pattern.lastIndex = 0;
|
||||
return result;
|
||||
};
|
||||
return (code) => code.includes(pattern);
|
||||
}
|
||||
function createFilter(exclude, include) {
|
||||
if (!exclude && !include) return;
|
||||
return (input) => {
|
||||
if (exclude?.some((filter) => filter(input))) return false;
|
||||
if (include?.some((filter) => filter(input))) return true;
|
||||
return !(include && include.length > 0);
|
||||
};
|
||||
}
|
||||
function normalizeFilter(filter) {
|
||||
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
||||
if (Array.isArray(filter)) return { include: filter };
|
||||
return {
|
||||
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
||||
include: filter.include ? toArray(filter.include) : void 0
|
||||
};
|
||||
}
|
||||
function createIdFilter(filter) {
|
||||
if (!filter) return;
|
||||
const { exclude, include } = normalizeFilter(filter);
|
||||
const excludeFilter = exclude?.map(patternToIdFilter);
|
||||
const includeFilter = include?.map(patternToIdFilter);
|
||||
return createFilter(excludeFilter, includeFilter);
|
||||
}
|
||||
function createCodeFilter(filter) {
|
||||
if (!filter) return;
|
||||
const { exclude, include } = normalizeFilter(filter);
|
||||
const excludeFilter = exclude?.map(patternToCodeFilter);
|
||||
const includeFilter = include?.map(patternToCodeFilter);
|
||||
return createFilter(excludeFilter, includeFilter);
|
||||
}
|
||||
function createFilterForId(filter) {
|
||||
const filterFunction = createIdFilter(filter);
|
||||
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
||||
}
|
||||
function createFilterForTransform(idFilter, codeFilter) {
|
||||
if (!idFilter && !codeFilter) return;
|
||||
const idFilterFunction = createIdFilter(idFilter);
|
||||
const codeFilterFunction = createCodeFilter(codeFilter);
|
||||
return (id, code) => {
|
||||
let fallback = true;
|
||||
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
||||
if (!fallback) return false;
|
||||
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
||||
return fallback;
|
||||
};
|
||||
}
|
||||
function normalizeObjectHook(name, hook) {
|
||||
let handler;
|
||||
let filter;
|
||||
if (typeof hook === "function") handler = hook;
|
||||
else {
|
||||
handler = hook.handler;
|
||||
const hookFilter = hook.filter;
|
||||
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
||||
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
||||
}
|
||||
return {
|
||||
handler,
|
||||
filter: filter || (() => true)
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils/parse.ts
|
||||
let parseImpl;
|
||||
function parse(code, opts = {}) {
|
||||
if (!parseImpl) throw new Error("Parse implementation is not set. Please call setParseImpl first.");
|
||||
return parseImpl(code, opts);
|
||||
}
|
||||
function setParseImpl(customParse) {
|
||||
parseImpl = customParse;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { toArray as i, setParseImpl as n, normalizeObjectHook as r, parse as t };
|
||||
6
node_modules/unplugin/dist/rspack/loaders/load.d.mts
generated
vendored
Normal file
6
node_modules/unplugin/dist/rspack/loaders/load.d.mts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "@rspack/core";
|
||||
|
||||
//#region src/rspack/loaders/load.d.ts
|
||||
declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { load as default };
|
||||
27
node_modules/unplugin/dist/rspack/loaders/load.mjs
generated
vendored
Normal file
27
node_modules/unplugin/dist/rspack/loaders/load.mjs
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { r as normalizeObjectHook } from "../../parse-DN2jPtpt.mjs";
|
||||
import { t as normalizeAbsolutePath } from "../../webpack-like-Djrmy9eu.mjs";
|
||||
import { n as createContext, t as createBuildContext } from "../../context-CKhLGGrj.mjs";
|
||||
import { i as isVirtualModuleId, n as decodeVirtualModuleId } from "../../utils-BMHLEWml.mjs";
|
||||
|
||||
//#region src/rspack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id) return callback(null, source, map);
|
||||
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
|
||||
const context = createContext(this);
|
||||
const { handler } = normalizeObjectHook("load", plugin.load);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, this._compilation && createBuildContext(this._compiler, this._compilation, this), context), normalizeAbsolutePath(id));
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, res.map ?? map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { load as default };
|
||||
6
node_modules/unplugin/dist/rspack/loaders/transform.d.mts
generated
vendored
Normal file
6
node_modules/unplugin/dist/rspack/loaders/transform.d.mts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "@rspack/core";
|
||||
|
||||
//#region src/rspack/loaders/transform.d.ts
|
||||
declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
25
node_modules/unplugin/dist/rspack/loaders/transform.mjs
generated
vendored
Normal file
25
node_modules/unplugin/dist/rspack/loaders/transform.mjs
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { r as normalizeObjectHook } from "../../parse-DN2jPtpt.mjs";
|
||||
import { n as createContext, t as createBuildContext } from "../../context-CKhLGGrj.mjs";
|
||||
|
||||
//#region src/rspack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
if (!plugin?.transform) return callback(null, source, map);
|
||||
const id = this.resource;
|
||||
const context = createContext(this);
|
||||
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
||||
if (!filter(this.resource, source)) return callback(null, source, map);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, this._compilation && createBuildContext(this._compiler, this._compilation, this, map), context), source, id);
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
54
node_modules/unplugin/dist/utils-BMHLEWml.mjs
generated
vendored
Normal file
54
node_modules/unplugin/dist/utils-BMHLEWml.mjs
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { basename, dirname, resolve } from "node:path";
|
||||
import fs from "node:fs";
|
||||
|
||||
//#region src/rspack/utils.ts
|
||||
function encodeVirtualModuleId(id, plugin) {
|
||||
return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
|
||||
}
|
||||
function decodeVirtualModuleId(encoded, _plugin) {
|
||||
return decodeURIComponent(basename(encoded));
|
||||
}
|
||||
function isVirtualModuleId(encoded, plugin) {
|
||||
return dirname(encoded) === plugin.__virtualModulePrefix;
|
||||
}
|
||||
var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin {
|
||||
name = "FakeVirtualModulesPlugin";
|
||||
static counters = /* @__PURE__ */ new Map();
|
||||
static initCleanup = false;
|
||||
constructor(plugin) {
|
||||
this.plugin = plugin;
|
||||
if (!FakeVirtualModulesPlugin.initCleanup) {
|
||||
FakeVirtualModulesPlugin.initCleanup = true;
|
||||
process.once("exit", () => {
|
||||
FakeVirtualModulesPlugin.counters.forEach((_, dir) => {
|
||||
fs.rmSync(dir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
apply(compiler) {
|
||||
const dir = this.plugin.__virtualModulePrefix;
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
const counter = FakeVirtualModulesPlugin.counters.get(dir) ?? 0;
|
||||
FakeVirtualModulesPlugin.counters.set(dir, counter + 1);
|
||||
compiler.hooks.shutdown.tap(this.name, () => {
|
||||
const counter = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
|
||||
if (counter === 0) {
|
||||
FakeVirtualModulesPlugin.counters.delete(dir);
|
||||
fs.rmSync(dir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
} else FakeVirtualModulesPlugin.counters.set(dir, counter);
|
||||
});
|
||||
}
|
||||
async writeModule(file) {
|
||||
return fs.promises.writeFile(file, "");
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
export { isVirtualModuleId as i, decodeVirtualModuleId as n, encodeVirtualModuleId as r, FakeVirtualModulesPlugin as t };
|
||||
33
node_modules/unplugin/dist/webpack-like-Djrmy9eu.mjs
generated
vendored
Normal file
33
node_modules/unplugin/dist/webpack-like-Djrmy9eu.mjs
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { r as normalizeObjectHook } from "./parse-DN2jPtpt.mjs";
|
||||
import { isAbsolute, normalize } from "node:path";
|
||||
|
||||
//#region src/utils/webpack-like.ts
|
||||
function transformUse(data, plugin, transformLoader) {
|
||||
if (data.resource == null) return [];
|
||||
const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
|
||||
if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
|
||||
const { filter } = normalizeObjectHook("load", plugin.transform);
|
||||
if (!filter(id)) return [];
|
||||
return [{
|
||||
loader: transformLoader,
|
||||
options: { plugin },
|
||||
ident: plugin.name
|
||||
}];
|
||||
}
|
||||
/**
|
||||
* Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
|
||||
* the input path to the native os format. This is useful in cases where we want to normalize
|
||||
* the `id` argument of a hook. Any absolute ids should be in the default format
|
||||
* of the operating system. Any relative imports or node_module imports should remain
|
||||
* untouched.
|
||||
*
|
||||
* @param path - Path to normalize.
|
||||
* @returns a new normalized path.
|
||||
*/
|
||||
function normalizeAbsolutePath(path) {
|
||||
if (isAbsolute(path)) return normalize(path);
|
||||
else return path;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { transformUse as n, normalizeAbsolutePath as t };
|
||||
6
node_modules/unplugin/dist/webpack/loaders/load.d.mts
generated
vendored
Normal file
6
node_modules/unplugin/dist/webpack/loaders/load.d.mts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "webpack";
|
||||
|
||||
//#region src/webpack/loaders/load.d.ts
|
||||
declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { load as default };
|
||||
28
node_modules/unplugin/dist/webpack/loaders/load.mjs
generated
vendored
Normal file
28
node_modules/unplugin/dist/webpack/loaders/load.mjs
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { r as normalizeObjectHook } from "../../parse-DN2jPtpt.mjs";
|
||||
import { t as normalizeAbsolutePath } from "../../webpack-like-Djrmy9eu.mjs";
|
||||
import { n as createBuildContext, r as createContext } from "../../context-MD-xQmYI.mjs";
|
||||
|
||||
//#region src/webpack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id) return callback(null, source, map);
|
||||
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
||||
const context = createContext(this);
|
||||
const { handler } = normalizeObjectHook("load", plugin.load);
|
||||
const res = await handler.call(Object.assign({}, createBuildContext({
|
||||
addWatchFile: (file) => {
|
||||
this.addDependency(file);
|
||||
},
|
||||
getWatchFiles: () => {
|
||||
return this.getDependencies();
|
||||
}
|
||||
}, this._compiler, this._compilation, this), context), normalizeAbsolutePath(id));
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, res.map ?? map);
|
||||
else callback(null, res, map);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { load as default };
|
||||
6
node_modules/unplugin/dist/webpack/loaders/transform.d.mts
generated
vendored
Normal file
6
node_modules/unplugin/dist/webpack/loaders/transform.d.mts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "webpack";
|
||||
|
||||
//#region src/webpack/loaders/transform.d.ts
|
||||
declare function transform(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
31
node_modules/unplugin/dist/webpack/loaders/transform.mjs
generated
vendored
Normal file
31
node_modules/unplugin/dist/webpack/loaders/transform.mjs
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { r as normalizeObjectHook } from "../../parse-DN2jPtpt.mjs";
|
||||
import { n as createBuildContext, r as createContext } from "../../context-MD-xQmYI.mjs";
|
||||
|
||||
//#region src/webpack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
if (!plugin?.transform) return callback(null, source, map);
|
||||
const context = createContext(this);
|
||||
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
||||
if (!filter(this.resource, source)) return callback(null, source, map);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, createBuildContext({
|
||||
addWatchFile: (file) => {
|
||||
this.addDependency(file);
|
||||
},
|
||||
getWatchFiles: () => {
|
||||
return this.getDependencies();
|
||||
}
|
||||
}, this._compiler, this._compilation, this, map), context), source, this.resource);
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
Reference in New Issue
Block a user