🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

vite-plugin-node-polyfills

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-node-polyfills - npm Package Compare versions

Comparing version
0.23.1
to
0.24.0
+113
dist/index.d.ts
import stdLibBrowser from 'node-stdlib-browser';
import type { Plugin } from 'vite';
export declare type BuildTarget = 'build' | 'dev';
export declare type BooleanOrBuildTarget = boolean | BuildTarget;
export declare type ModuleName = keyof typeof stdLibBrowser;
export declare type ModuleNameWithoutNodePrefix<T = ModuleName> = T extends `node:${infer P}` ? P : never;
export declare type PolyfillOptions = {
/**
* Includes specific modules. If empty, includes all modules
* @example
*
* ```ts
* nodePolyfills({
* include: ['fs', 'path'],
* })
* ```
*/
include?: ModuleNameWithoutNodePrefix[];
/**
* @example
*
* ```ts
* nodePolyfills({
* exclude: ['fs', 'path'],
* })
* ```
*/
exclude?: ModuleNameWithoutNodePrefix[];
/**
* Specify whether specific globals should be polyfilled.
*
* @example
*
* ```ts
* nodePolyfills({
* globals: {
* Buffer: false,
* global: true,
* process: 'build',
* },
* })
* ```
*/
globals?: {
Buffer?: BooleanOrBuildTarget;
global?: BooleanOrBuildTarget;
process?: BooleanOrBuildTarget;
};
/**
* Specify alternative modules to use in place of the default polyfills.
*
* @example
*
* ```ts
* nodePolyfills({
* overrides: {
* fs: 'memfs',
* },
* })
* ```
*/
overrides?: {
[Key in ModuleNameWithoutNodePrefix]?: string;
};
/**
* Specify whether the Node protocol version of an import (e.g. `node:buffer`) should be polyfilled too.
*
* @default true
*/
protocolImports?: boolean;
};
export declare type PolyfillOptionsResolved = {
include: ModuleNameWithoutNodePrefix[];
exclude: ModuleNameWithoutNodePrefix[];
globals: {
Buffer: BooleanOrBuildTarget;
global: BooleanOrBuildTarget;
process: BooleanOrBuildTarget;
};
overrides: {
[Key in ModuleNameWithoutNodePrefix]?: string;
};
protocolImports: boolean;
};
/**
* Returns a Vite plugin to polyfill Node's Core Modules for browser environments. Supports `node:` protocol imports.
*
* @example
*
* ```ts
* // vite.config.ts
* import { defineConfig } from 'vite'
* import { nodePolyfills } from 'vite-plugin-node-polyfills'
*
* export default defineConfig({
* plugins: [
* nodePolyfills({
* // Specific modules that should not be polyfilled.
* exclude: [],
* // Whether to polyfill specific globals.
* globals: {
* Buffer: true, // can also be 'build', 'dev', or false
* global: true,
* process: true,
* },
* // Whether to polyfill `node:` protocol imports.
* protocolImports: true,
* }),
* ],
* })
* ```
*/
export declare const nodePolyfills: (options?: PolyfillOptions) => Plugin;
import type { BooleanOrBuildTarget, ModuleName, ModuleNameWithoutNodePrefix } from './index';
export declare const compareModuleNames: (moduleA: ModuleName, moduleB: ModuleName) => boolean;
export declare const isEnabled: (value: BooleanOrBuildTarget, mode: 'build' | 'dev') => boolean;
export declare const isNodeProtocolImport: (name: string) => boolean;
export declare const toRegExp: (text: string) => RegExp;
export declare const withoutNodeProtocol: (name: ModuleName) => ModuleNameWithoutNodePrefix;
+2
-3

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

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ge=require("@rollup/plugin-inject"),_e=require("node-stdlib-browser"),ve=require("node-stdlib-browser/helpers/rollup/plugin"),Re=require("node-stdlib-browser/helpers/esbuild/plugin"),ye=require("node:module"),w=require("node:fs"),c=require("node:url"),se=require("node:path"),Ee=require("node:assert"),we=require("node:process"),Pe=require("node:v8"),j=require("node:util");var I=typeof document<"u"?document.currentScript:null;const _=e=>e&&e.__esModule?e:{default:e},q=_(ge),Te=_(_e),xe=_(Re),Le=_(w),W=_(se),g=_(Ee),v=_(we),Oe=_(Pe),F=["_http_agent","_http_client","_http_common","_http_incoming","_http_outgoing","_http_server","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_wrap","_stream_writable","_tls_common","_tls_wrap","assert","assert/strict","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","dns/promises","domain","events","fs","fs/promises","http","http2","https","inspector","inspector/promises","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","readline/promises","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","sys","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib"],$e={}.hasOwnProperty,je=/^([A-Z][a-z\d]*)+$/,Ie=new Set(["string","function","number","object","Function","Object","boolean","bigint","symbol"]),ie=new Map,Ue="__node_internal_";let G;function S(e,t="and"){return e.length<3?e.join(` ${t} `):`${e.slice(0,-1).join(", ")}, ${t} ${e.at(-1)}`}function p(e,t,n){return ie.set(e,t),Ne(n,e)}function Ne(e,t){return function(...o){const i=Error.stackTraceLimit;D()&&(Error.stackTraceLimit=0);const r=new e;D()&&(Error.stackTraceLimit=i);const s=Ae(t,o,r);return Object.defineProperties(r,{message:{value:s,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),be(r),r.code=t,r}}function D(){try{if(Oe.default.startupSnapshot.isBuildingSnapshot())return!1}catch{}const e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):$e.call(e,"writable")&&e.writable!==void 0?e.writable:e.set!==void 0}function Se(e){const t=Ue+e.name;return Object.defineProperty(e,"name",{value:t}),e}const be=Se(function(e){const t=D();return t&&(G=Error.stackTraceLimit,Error.stackTraceLimit=Number.POSITIVE_INFINITY),Error.captureStackTrace(e),t&&(Error.stackTraceLimit=G),e});function Ae(e,t,n){const o=ie.get(e);if(g.default(o!==void 0,"expected `message` to be found"),typeof o=="function")return g.default(o.length<=t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${o.length}).`),Reflect.apply(o,n,t);const i=/%[dfijoOs]/g;let r=0;for(;i.exec(o)!==null;)r++;return g.default(r===t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r}).`),t.length===0?o:(t.unshift(o),Reflect.apply(j.format,null,t))}function De(e){if(e==null)return String(e);if(typeof e=="function"&&e.name)return`function ${e.name}`;if(typeof e=="object")return e.constructor&&e.constructor.name?`an instance of ${e.constructor.name}`:`${j.inspect(e,{depth:-1})}`;let t=j.inspect(e,{colors:!1});return t.length>28&&(t=`${t.slice(0,25)}...`),`type ${typeof e} (${t})`}p("ERR_INVALID_ARG_TYPE",(e,t,n)=>{g.default(typeof e=="string","'name' must be a string"),Array.isArray(t)||(t=[t]);let o="The ";if(e.endsWith(" argument"))o+=`${e} `;else{const l=e.includes(".")?"property":"argument";o+=`"${e}" ${l} `}o+="must be ";const i=[],r=[],s=[];for(const l of t)g.default(typeof l=="string","All expected entries have to be of type string"),Ie.has(l)?i.push(l.toLowerCase()):je.exec(l)===null?(g.default(l!=="object",'The value "object" should be written as "Object"'),s.push(l)):r.push(l);if(r.length>0){const l=i.indexOf("object");l!==-1&&(i.slice(l,1),r.push("Object"))}return i.length>0&&(o+=`${i.length>1?"one of type":"of type"} ${S(i,"or")}`,(r.length>0||s.length>0)&&(o+=" or ")),r.length>0&&(o+=`an instance of ${S(r,"or")}`,s.length>0&&(o+=" or ")),s.length>0&&(s.length>1?o+=`one of ${S(s,"or")}`:(s[0]?.toLowerCase()!==s[0]&&(o+="an "),o+=`${s[0]}`)),o+=`. Received ${De(n)}`,o},TypeError);const N=p("ERR_INVALID_MODULE_SPECIFIER",(e,t,n)=>`Invalid module "${e}" ${t}${n?` imported from ${n}`:""}`,TypeError),M=p("ERR_INVALID_PACKAGE_CONFIG",(e,t,n)=>`Invalid package config ${e}${t?` while importing ${t}`:""}${n?`. ${n}`:""}`,Error),ke=p("ERR_INVALID_PACKAGE_TARGET",(e,t,n,o=!1,i)=>{const r=typeof n=="string"&&!o&&n.length>0&&!n.startsWith("./");return t==="."?(g.default(o===!1),`Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i?` imported from ${i}`:""}${r?'; targets must start with "./"':""}`):`Invalid "${o?"imports":"exports"}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i?` imported from ${i}`:""}${r?'; targets must start with "./"':""}`},Error),C=p("ERR_MODULE_NOT_FOUND",(e,t,n=!1)=>`Cannot find ${n?"module":"package"} '${e}' imported from ${t}`,Error);p("ERR_NETWORK_IMPORT_DISALLOWED","import of '%s' by %s is not supported: %s",Error);const We=p("ERR_PACKAGE_IMPORT_NOT_DEFINED",(e,t,n)=>`Package import specifier "${e}" is not defined${t?` in package ${t||""}package.json`:""} imported from ${n}`,TypeError),Fe=p("ERR_PACKAGE_PATH_NOT_EXPORTED",(e,t,n)=>t==="."?`No "exports" main defined in ${e}package.json${n?` imported from ${n}`:""}`:`Package subpath '${t}' is not defined by "exports" in ${e}package.json${n?` imported from ${n}`:""}`,Error),Me=p("ERR_UNSUPPORTED_DIR_IMPORT","Directory import '%s' is not supported resolving ES modules imported from %s",Error),z=p("ERR_UNSUPPORTED_RESOLVE_REQUEST",'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',TypeError),Ce=p("ERR_UNKNOWN_FILE_EXTENSION",(e,t)=>`Unknown file extension "${e}" for ${t}`,TypeError);p("ERR_INVALID_ARG_VALUE",(e,t,n="is invalid")=>{let o=j.inspect(t);return o.length>128&&(o=`${o.slice(0,128)}...`),`The ${e.includes(".")?"property":"argument"} '${e}' ${n}. Received ${o}`},TypeError);const P={}.hasOwnProperty,B=new Map;function le(e,{base:t,specifier:n}){const o=B.get(e);if(o)return o;let i;try{i=Le.default.readFileSync(W.default.toNamespacedPath(e),"utf8")}catch(s){const l=s;if(l.code!=="ENOENT")throw l}const r={exists:!1,pjsonPath:e,main:void 0,name:void 0,type:"none",exports:void 0,imports:void 0};if(i!==void 0){let s;try{s=JSON.parse(i)}catch(l){const a=new M(e,(t?`"${n}" from `:"")+c.fileURLToPath(t||n),l.message);throw a.cause=l,a}r.exists=!0,P.call(s,"name")&&typeof s.name=="string"&&(r.name=s.name),P.call(s,"main")&&typeof s.main=="string"&&(r.main=s.main),P.call(s,"exports")&&(r.exports=s.exports),P.call(s,"imports")&&(r.imports=s.imports),P.call(s,"type")&&(s.type==="commonjs"||s.type==="module")&&(r.type=s.type)}return B.set(e,r),r}function U(e){let t=new URL("package.json",e);for(;!t.pathname.endsWith("node_modules/package.json");){const i=le(c.fileURLToPath(t),{specifier:e});if(i.exists)return i;const r=t;if(t=new URL("../package.json",t),t.pathname===r.pathname)break}return{pjsonPath:c.fileURLToPath(t),exists:!1,type:"none"}}const qe={}.hasOwnProperty,Ge={__proto__:null,".json":"json",".cjs":"commonjs",".cts":"commonjs",".js":"module",".ts":"module",".mts":"module",".mjs":"module"},K={__proto__:null,"data:":Be,"file:":Ve,"node:":()=>"builtin"};function ze(e){return e&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e)?"module":e==="application/json"?"json":null}function Be(e){const{1:t}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname)||[null,null,null];return ze(t)}function Ke(e){const t=e.pathname;let n=t.length;for(;n--;){const o=t.codePointAt(n);if(o===47)return"";if(o===46)return t.codePointAt(n-1)===47?"":t.slice(n)}return""}function Ve(e,t,n){const o=Ke(e);if(o===".js"){const{type:s}=U(e);return s!=="none"?s:"commonjs"}if(o===""){const{type:s}=U(e);return s==="none"||s==="commonjs"?"commonjs":"module"}const i=Ge[o];if(i)return i;if(n)return;const r=c.fileURLToPath(e);throw new Ce(o,r)}function Xe(e,t){const n=e.protocol;return qe.call(K,n)&&K[n](e,t,!0)||null}const L=RegExp.prototype[Symbol.replace],ce={}.hasOwnProperty,V=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,X=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,He=/^\.|%|\\/,O=/\*/g,Ze=/%2f|%5c/i,H=new Set,Qe=/[/\\]{2}/;function Z(e,t,n,o,i,r,s){if(v.default.noDeprecation)return;const l=c.fileURLToPath(o),a=Qe.exec(s?e:t)!==null;v.default.emitWarning(`Use of deprecated ${a?"double slash":"leading or trailing slash matching"} resolving "${e}" for module request "${t}" ${t===n?"":`matched to "${n}" `}in the "${i?"imports":"exports"}" field module resolution of the package at ${l}${r?` imported from ${c.fileURLToPath(r)}`:""}.`,"DeprecationWarning","DEP0166")}function Q(e,t,n,o){if(v.default.noDeprecation||Xe(e,{parentURL:n.href})!=="module")return;const r=c.fileURLToPath(e.href),s=c.fileURLToPath(new c.URL(".",t)),l=c.fileURLToPath(n);o?W.default.resolve(s,o)!==r&&v.default.emitWarning(`Package ${s} has a "main" field set to "${o}", excluding the full filename and extension to the resolved file at "${r.slice(s.length)}", imported from ${l}.
Automatic extension resolution of the "main" field is deprecated for ES modules.`,"DeprecationWarning","DEP0151"):v.default.emitWarning(`No "main" or "exports" field defined in the package.json for ${s} resolving the main entry point "${r.slice(s.length)}", imported from ${l}.
Default "index" lookups for the main are deprecated for ES modules.`,"DeprecationWarning","DEP0151")}function fe(e){try{return w.statSync(e)}catch{}}function b(e){const t=w.statSync(e,{throwIfNoEntry:!1}),n=t?t.isFile():void 0;return n??!1}function Ye(e,t,n){let o;if(t.main!==void 0){if(o=new c.URL(t.main,e),b(o))return o;const s=[`./${t.main}.js`,`./${t.main}.json`,`./${t.main}.node`,`./${t.main}/index.js`,`./${t.main}/index.json`,`./${t.main}/index.node`];let l=-1;for(;++l<s.length&&(o=new c.URL(s[l],e),!b(o));)o=void 0;if(o)return Q(o,e,n,t.main),o}const i=["./index.js","./index.json","./index.node"];let r=-1;for(;++r<i.length&&(o=new c.URL(i[r],e),!b(o));)o=void 0;if(o)return Q(o,e,n,t.main),o;throw new C(c.fileURLToPath(new c.URL(".",e)),c.fileURLToPath(n))}function Je(e,t,n){if(Ze.exec(e.pathname)!==null)throw new N(e.pathname,String.raw`must not include encoded "/" or "\" characters`,c.fileURLToPath(t));let o;try{o=c.fileURLToPath(e)}catch(r){throw Object.defineProperty(r,"input",{value:String(e)}),Object.defineProperty(r,"module",{value:String(t)}),r}const i=fe(o.endsWith("/")?o.slice(-1):o);if(i&&i.isDirectory()){const r=new Me(o,c.fileURLToPath(t));throw r.url=String(e),r}if(!i||!i.isFile()){const r=new C(o||e.pathname,t&&c.fileURLToPath(t),!0);throw r.url=String(e),r}{const r=w.realpathSync(o),{search:s,hash:l}=e;e=c.pathToFileURL(r+(o.endsWith(W.default.sep)?"/":"")),e.search=s,e.hash=l}return e}function et(e,t,n){return new We(e,t&&c.fileURLToPath(new c.URL(".",t)),c.fileURLToPath(n))}function A(e,t,n){return new Fe(c.fileURLToPath(new c.URL(".",t)),e,n&&c.fileURLToPath(n))}function tt(e,t,n,o,i){const r=`request is not a valid match in pattern "${t}" for the "${o?"imports":"exports"}" resolution of ${c.fileURLToPath(n)}`;throw new N(e,r,i&&c.fileURLToPath(i))}function T(e,t,n,o,i){return t=typeof t=="object"&&t!==null?JSON.stringify(t,null,""):`${t}`,new ke(c.fileURLToPath(new c.URL(".",n)),e,t,o,i&&c.fileURLToPath(i))}function nt(e,t,n,o,i,r,s,l,a){if(t!==""&&!r&&e.at(-1)!=="/")throw T(n,e,o,s,i);if(!e.startsWith("./")){if(s&&!e.startsWith("../")&&!e.startsWith("/")){let m=!1;try{new c.URL(e),m=!0}catch{}if(!m){const h=r?L.call(O,e,()=>t):e+t;return ue(h,o,a)}}throw T(n,e,o,s,i)}if(V.exec(e.slice(2))!==null)if(X.exec(e.slice(2))===null){if(!l){const m=r?n.replace("*",()=>t):n+t,h=r?L.call(O,e,()=>t):e;Z(h,m,n,o,s,i,!0)}}else throw T(n,e,o,s,i);const d=new c.URL(e,o),f=d.pathname,u=new c.URL(".",o).pathname;if(!f.startsWith(u))throw T(n,e,o,s,i);if(t==="")return d;if(V.exec(t)!==null){const m=r?n.replace("*",()=>t):n+t;if(X.exec(t)===null){if(!l){const h=r?L.call(O,e,()=>t):e;Z(h,m,n,o,s,i,!1)}}else tt(m,n,o,s,i)}return r?new c.URL(L.call(O,d.href,()=>t)):new c.URL(t,d)}function ot(e){const t=Number(e);return`${t}`!==e?!1:t>=0&&t<4294967295}function E(e,t,n,o,i,r,s,l,a){if(typeof t=="string")return nt(t,n,o,e,i,r,s,l,a);if(Array.isArray(t)){const d=t;if(d.length===0)return null;let f,u=-1;for(;++u<d.length;){const m=d[u];let h;try{h=E(e,m,n,o,i,r,s,l,a)}catch(R){const x=R;if(f=x,x.code==="ERR_INVALID_PACKAGE_TARGET")continue;throw R}if(h!==void 0){if(h===null){f=null;continue}return h}}if(f==null)return null;throw f}if(typeof t=="object"&&t!==null){const d=Object.getOwnPropertyNames(t);let f=-1;for(;++f<d.length;){const u=d[f];if(ot(u))throw new M(c.fileURLToPath(e),c.fileURLToPath(i),'"exports" cannot contain numeric property keys.')}for(f=-1;++f<d.length;){const u=d[f];if(u==="default"||a&&a.has(u)){const m=t[u],h=E(e,m,n,o,i,r,s,l,a);if(h===void 0)continue;return h}}return null}if(t===null)return null;throw T(o,t,e,s,i)}function rt(e,t,n){if(typeof e=="string"||Array.isArray(e))return!0;if(typeof e!="object"||e===null)return!1;const o=Object.getOwnPropertyNames(e);let i=!1,r=0,s=-1;for(;++s<o.length;){const l=o[s],a=l===""||l[0]!==".";if(r++===0)i=a;else if(i!==a)throw new M(c.fileURLToPath(t),c.fileURLToPath(n),`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return i}function st(e,t,n){if(v.default.noDeprecation)return;const o=c.fileURLToPath(t);H.has(o+"|"+e)||(H.add(o+"|"+e),v.default.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${o}${n?` imported from ${c.fileURLToPath(n)}`:""}. Mapping specifiers ending in "/" is no longer supported.`,"DeprecationWarning","DEP0155"))}function Y(e,t,n,o,i){let r=n.exports;if(rt(r,e,o)&&(r={".":r}),ce.call(r,t)&&!t.includes("*")&&!t.endsWith("/")){const f=r[t],u=E(e,f,"",t,o,!1,!1,!1,i);if(u==null)throw A(t,e,o);return u}let s="",l="";const a=Object.getOwnPropertyNames(r);let d=-1;for(;++d<a.length;){const f=a[d],u=f.indexOf("*");if(u!==-1&&t.startsWith(f.slice(0,u))){t.endsWith("/")&&st(t,e,o);const m=f.slice(u+1);t.length>=f.length&&t.endsWith(m)&&ae(s,f)===1&&f.lastIndexOf("*")===u&&(s=f,l=t.slice(u,t.length-m.length))}}if(s){const f=r[s],u=E(e,f,l,s,o,!0,!1,t.endsWith("/"),i);if(u==null)throw A(t,e,o);return u}throw A(t,e,o)}function ae(e,t){const n=e.indexOf("*"),o=t.indexOf("*"),i=n===-1?e.length:n+1,r=o===-1?t.length:o+1;return i>r?-1:r>i||n===-1?1:o===-1||e.length>t.length?-1:t.length>e.length?1:0}function it(e,t,n){if(e==="#"||e.startsWith("#/")||e.endsWith("/")){const r="is not a valid internal imports specifier name";throw new N(e,r,c.fileURLToPath(t))}let o;const i=U(t);if(i.exists){o=c.pathToFileURL(i.pjsonPath);const r=i.imports;if(r)if(ce.call(r,e)&&!e.includes("*")){const s=E(o,r[e],"",e,t,!1,!0,!1,n);if(s!=null)return s}else{let s="",l="";const a=Object.getOwnPropertyNames(r);let d=-1;for(;++d<a.length;){const f=a[d],u=f.indexOf("*");if(u!==-1&&e.startsWith(f.slice(0,-1))){const m=f.slice(u+1);e.length>=f.length&&e.endsWith(m)&&ae(s,f)===1&&f.lastIndexOf("*")===u&&(s=f,l=e.slice(u,e.length-m.length))}}if(s){const f=r[s],u=E(o,f,l,s,t,!0,!0,!1,n);if(u!=null)return u}}}throw et(e,o,t)}function lt(e,t){let n=e.indexOf("/"),o=!0,i=!1;e[0]==="@"&&(i=!0,n===-1||e.length===0?o=!1:n=e.indexOf("/",n+1));const r=n===-1?e:e.slice(0,n);if(He.exec(r)!==null&&(o=!1),!o)throw new N(e,"is not a valid package name",c.fileURLToPath(t));const s="."+(n===-1?"":e.slice(n));return{packageName:r,packageSubpath:s,isScoped:i}}function ue(e,t,n){if(F.includes(e))return new c.URL("node:"+e);const{packageName:o,packageSubpath:i,isScoped:r}=lt(e,t),s=U(t);if(s.exists&&s.name===o&&s.exports!==void 0&&s.exports!==null){const f=c.pathToFileURL(s.pjsonPath);return Y(f,i,s,t,n)}let l=new c.URL("./node_modules/"+o+"/package.json",t),a=c.fileURLToPath(l),d;do{const f=fe(a.slice(0,-13));if(!f||!f.isDirectory()){d=a,l=new c.URL((r?"../../../../node_modules/":"../../../node_modules/")+o+"/package.json",l),a=c.fileURLToPath(l);continue}const u=le(a,{base:t,specifier:e});return u.exports!==void 0&&u.exports!==null?Y(l,i,u,t,n):i==="."?Ye(l,u,t):new c.URL(i,l)}while(a.length!==d.length);throw new C(o,c.fileURLToPath(t),!1)}function ct(e){return e[0]==="."&&(e.length===1||e[1]==="/"||e[1]==="."&&(e.length===2||e[2]==="/"))}function ft(e){return e===""?!1:e[0]==="/"?!0:ct(e)}function at(e,t,n,o){const i=t.protocol,r=i==="data:";let s;if(ft(e))try{s=new c.URL(e,t)}catch(l){const a=new z(e,t);throw a.cause=l,a}else if(i==="file:"&&e[0]==="#")s=it(e,t,n);else try{s=new c.URL(e)}catch(l){if(r&&!F.includes(e)){const a=new z(e,t);throw a.cause=l,a}s=ue(e,t,n)}return g.default(s!==void 0,"expected to be defined"),s.protocol!=="file:"?s:Je(s,t)}const ut=new Set(["node","import"]),dt=process.platform==="win32",ht=new Set(["ERR_MODULE_NOT_FOUND","ERR_UNSUPPORTED_DIR_IMPORT","MODULE_NOT_FOUND","ERR_PACKAGE_PATH_NOT_EXPORTED","ERR_PACKAGE_IMPORT_NOT_DEFINED"]),de=globalThis.__EXSOLVE_CACHE__||=new Map;function he(e,t){const n=wt(e);if("external"in n)return n.external;const o=n.specifier,i=n.url,r=n.absolutePath;let s,l;if(t?.cache!==!1&&(s=Rt(r||o,t),l=t?.cache&&typeof t?.cache=="object"?t.cache:de),l){const h=l.get(s);if(typeof h=="string")return h;if(h instanceof Error){if(t?.try)return;throw h}}if(r)try{if(w.statSync(r).isFile())return l&&l.set(s,i.href),i.href}catch(h){if(h?.code!=="ENOENT")throw l&&l.set(s,h),h}const a=t?.conditions?new Set(t.conditions):ut,d=me(t?.from),f=t?.suffixes||[""],u=t?.extensions?["",...t.extensions]:[""];let m;for(const h of d){for(const R of f){for(const x of u)if(m=gt(yt(o||i.href,R)+x,h,a),m)break;if(m)break}if(m)break}if(!m){const h=new Error(`Cannot resolve module "${e}" (from: ${d.map(R=>vt(R)).join(", ")})`);if(h.code="ERR_MODULE_NOT_FOUND",l&&l.set(s,h),t?.try)return;throw h}return l&&l.set(s,m.href),m.href}function mt(e,t){const n=he(e,t);if(!n||!n.startsWith("file://")&&t?.try)return;const o=c.fileURLToPath(n);return dt?Et(o):o}function pt(e){return e?.from&&(e={...e,from:me(e?.from)}),{resolveModuleURL:(t,n)=>he(t,{...e,...n}),resolveModulePath:(t,n)=>mt(t,{...e,...n}),clearResolveCache:()=>{e?.cache!==!1&&(e?.cache&&typeof e?.cache=="object"?e.cache.clear():de.clear())}}}function gt(e,t,n){try{return at(e,t,n)}catch(o){if(!ht.has(o?.code))throw o}}function me(e){const t=(Array.isArray(e)?e:[e]).flatMap(n=>_t(n));return t.length===0?[c.pathToFileURL("./")]:t}function _t(e){if(!e)return[];if(e instanceof URL)return[e];if(typeof e!="string")return[];if(/^(?:node|data|http|https|file):/.test(e))return new URL(e);try{return e.endsWith("/")||w.statSync(e).isDirectory()?c.pathToFileURL(e+"/"):c.pathToFileURL(e)}catch{return[c.pathToFileURL(e+"/"),c.pathToFileURL(e)]}}function vt(e){try{return c.fileURLToPath(e)}catch{return e}}function Rt(e,t){return JSON.stringify([e,(t?.conditions||["node","import"]).sort(),t?.extensions,t?.from,t?.suffixes])}function yt(e,t){return!e||!t||t==="/"?e:(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t)}function Et(e){return e.replace(/\\/g,"/").replace(/^[a-z]:\//,t=>t.toUpperCase())}function wt(e){if(typeof e=="string"){if(e.startsWith("file:")){const t=new URL(e);return{url:t,absolutePath:c.fileURLToPath(t)}}return se.isAbsolute(e)?{url:c.pathToFileURL(e),absolutePath:e}:/^(?:node|data|http|https):/.test(e)?{external:e}:F.includes(e)&&!e.includes(":")?{external:`node:${e}`}:{specifier:e}}if(e instanceof URL)return e.protocol==="file:"?{url:e,absolutePath:c.fileURLToPath(e)}:{external:e.href};throw new TypeError("id must be a `string` or `URL`")}const Pt=/^[A-Za-z]:\//;function pe(e=""){return e&&e.replace(/\\/g,"/").replace(Pt,t=>t.toUpperCase())}const Tt=/^[/\\]{2}/,xt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Lt=/^[A-Za-z]:$/,Ot=function(e){if(e.length===0)return".";e=pe(e);const t=e.match(Tt),n=J(e),o=e[e.length-1]==="/";return e=jt(e,!n),e.length===0?n?"/":o?"./":".":(o&&(e+="/"),Lt.test(e)&&(e+="/"),t?n?`//${e}`:`//./${e}`:n&&!J(e)?`/${e}`:e)},$t=function(...e){let t="";for(const n of e)if(n)if(t.length>0){const o=t[t.length-1]==="/",i=n[0]==="/";o&&i?t+=n.slice(1):t+=o||i?n:`/${n}`}else t+=n;return Ot(t)};function jt(e,t){let n="",o=0,i=-1,r=0,s=null;for(let l=0;l<=e.length;++l){if(l<e.length)s=e[l];else{if(s==="/")break;s="/"}if(s==="/"){if(!(i===l-1||r===1))if(r===2){if(n.length<2||o!==2||n[n.length-1]!=="."||n[n.length-2]!=="."){if(n.length>2){const a=n.lastIndexOf("/");a===-1?(n="",o=0):(n=n.slice(0,a),o=n.length-1-n.lastIndexOf("/")),i=l,r=0;continue}else if(n.length>0){n="",o=0,i=l,r=0;continue}}t&&(n+=n.length>0?"/..":"..",o=2)}else n.length>0?n+=`/${e.slice(i+1,l)}`:n=e.slice(i+1,l),o=l-i-1;i=l,r=0}else s==="."&&r!==-1?++r:r=-1}return n}const J=function(e){return xt.test(e)},It=new Set(["/","\\",void 0]),ee=Symbol.for("pathe:normalizedAlias");function Ut(e){if(e[ee])return e;const t=Object.fromEntries(Object.entries(e).sort(([n],[o])=>St(n,o)));for(const n in t)for(const o in t)o===n||n.startsWith(o)||t[n]?.startsWith(o)&&It.has(t[n][o.length])&&(t[n]=t[o]+t[n].slice(o.length));return Object.defineProperty(t,ee,{value:!0,enumerable:!1}),t}function Nt(e,t){const n=pe(e);t=Ut(t);for(const[o,i]of Object.entries(t)){if(!n.startsWith(o))continue;const r=te(o)?o.slice(0,-1):o;if(te(n[r.length]))return $t(i,n.slice(o.length))}return n}function St(e,t){return t.split("/").length-e.split("/").length}function te(e="/"){const t=e[e.length-1];return t==="/"||t==="\\"}var bt="2.0.0-20250317-133939-bd867e9";const At={_http_agent:"unenv/mock/proxy-cjs",_http_client:"unenv/mock/proxy-cjs",_http_common:"unenv/mock/proxy-cjs",_http_incoming:"unenv/mock/proxy-cjs",_http_outgoing:"unenv/mock/proxy-cjs",_http_server:"unenv/mock/proxy-cjs",_stream_duplex:"unenv/mock/proxy-cjs",_stream_passthrough:"unenv/mock/proxy-cjs",_stream_readable:"unenv/mock/proxy-cjs",_stream_transform:"unenv/mock/proxy-cjs",_stream_wrap:"unenv/mock/proxy-cjs",_stream_writable:"unenv/mock/proxy-cjs",_tls_common:"unenv/mock/proxy-cjs",_tls_wrap:"unenv/mock/proxy-cjs",assert:"unenv/node/assert","assert/strict":"unenv/node/assert/strict",async_hooks:"unenv/node/async_hooks",buffer:"unenv/node/buffer",child_process:"unenv/node/child_process",cluster:"unenv/node/cluster",console:"unenv/node/console",constants:"unenv/node/constants",crypto:"unenv/node/crypto",dgram:"unenv/node/dgram",diagnostics_channel:"unenv/node/diagnostics_channel",dns:"unenv/node/dns","dns/promises":"unenv/node/dns/promises",domain:"unenv/node/domain",events:"unenv/node/events",fs:"unenv/node/fs","fs/promises":"unenv/node/fs/promises",http:"unenv/node/http",http2:"unenv/node/http2",https:"unenv/node/https",inspector:"unenv/node/inspector","inspector/promises":"unenv/node/inspector/promises",module:"unenv/node/module",net:"unenv/node/net",os:"unenv/node/os",path:"unenv/node/path","path/posix":"unenv/node/path","path/win32":"unenv/node/path",perf_hooks:"unenv/node/perf_hooks",process:"unenv/node/process",punycode:"unenv/node/punycode",querystring:"unenv/node/querystring",readline:"unenv/node/readline","readline/promises":"unenv/node/readline/promises",repl:"unenv/node/repl",stream:"unenv/node/stream","stream/consumers":"unenv/node/stream/consumers","stream/promises":"unenv/node/stream/promises","stream/web":"unenv/node/stream/web",string_decoder:"unenv/node/string_decoder",sys:"unenv/node/util",timers:"unenv/node/timers","timers/promises":"unenv/node/timers/promises",tls:"unenv/node/tls",trace_events:"unenv/node/trace_events",tty:"unenv/node/tty",url:"unenv/node/url",util:"unenv/node/util","util/types":"unenv/node/util/types",v8:"unenv/node/v8",vm:"unenv/node/vm",wasi:"unenv/node/wasi",worker_threads:"unenv/node/worker_threads",zlib:"unenv/node/zlib"},Dt={process:"unenv/node/process",global:"unenv/polyfill/globalthis",Buffer:["node:buffer","Buffer"],clearImmediate:["node:timers","clearImmediate"],setImmediate:["node:timers","setImmediate"]},kt={"cross-fetch":"unenv/npm/cross-fetch",debug:"unenv/npm/debug",fsevents:"unenv/npm/fsevents",inherits:"unenv/npm/inherits","node-fetch":"unenv/npm/node-fetch","node-fetch-native":"unenv/npm/node-fetch","whatwg-url":"unenv/npm/whatwg-url","cross-fetch/polyfill":"unenv/mock/empty","node-fetch-native/polyfill":"unenv/mock/empty","isomorphic-fetch":"unenv/mock/empty"},Wt=(e={})=>{const t=[];if(t.push(Ft(e)),e.presets&&t.push(...e.presets),e.overrides&&t.push(e.overrides),e.resolve)for(const o of t)o.meta?.url&&ne(o,[o.meta.url],e);const n=Mt(...t);return e.resolve&&ne(n,t.map(o=>o.meta?.url).filter(o=>o!==void 0),e),{env:n,presets:t}};function Ft(e){const t={meta:{name:"unenv",version:bt,url:typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.src||new URL("index.cjs",document.baseURI).href},alias:{},inject:{},external:[],polyfill:[]};return e.nodeCompat!==!1&&(Object.assign(t.inject,Dt),Object.assign(t.alias,{...Object.fromEntries(Object.entries(At).flatMap(([n,o])=>[[n,o],[`node:${n}`,o]]))})),e.npmShims&&Object.assign(t.alias,kt),t}function ne(e,t,n={}){if(!n.resolve)return;const{resolveModulePath:o}=pt({from:[...n.resolve===!0?[]:n.resolve.paths||[],...t,typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.src||new URL("index.cjs",document.baseURI).href,process.cwd()+"/"]}),i=r=>{if(!r||(e.alias&&(r=Nt(r,e.alias)),r.startsWith("node:")))return r;if(ye.builtinModules.includes(r))return`node:${r}`;let s=o(r,{try:!0});return!s&&r.startsWith("unenv/")&&(s=o(r.replace("unenv/","unenv-nightly/"),{try:!0})),s||r};for(const r in e.alias)e.alias[r]=i(e.alias[r]);if(e.polyfill)for(let r=0;r<e.polyfill.length;r++)e.polyfill[r]=i(e.polyfill[r]);for(const r in e.inject){const s=e.inject[r];if(Array.isArray(s)){const[l,...a]=s;e.inject[r]=[i(l),...a]}else e.inject[r]=i(s)}return e}function Mt(...e){const t={alias:{},inject:{},polyfill:[],external:[]};for(const n of e){if(n.alias){const o=Object.keys(n.alias).sort((i,r)=>r.split("/").length-i.split("/").length||r.length-i.length);for(const i of o)t.alias[i]=n.alias[i]}if(n.inject)for(const[o,i]of Object.entries(n.inject))Array.isArray(i)?t.inject[o]=i:i===!1?delete t.inject[o]:t.inject[o]=i;n.polyfill&&t.polyfill.push(...n.polyfill.filter(Boolean)),n.external&&t.external.push(...n.external)}return t.polyfill=oe(t.polyfill),t.external=oe(t.external),t}function oe(e){const t=new Set(e);for(const n of e)n.startsWith("!")&&(t.delete(n),t.delete(n.slice(1)));return[...t]}const re=(e,t)=>k(e)===k(t),y=(e,t)=>e?e===!0?!0:e===t:!1,Ct=e=>e.startsWith("node:"),k=e=>e.replace(/^node:/,""),$=[{code:"export { Buffer } from 'buffer'",moduleId:"virtual:buffer",moduleIdRegex:/^virtual:buffer$/,moduleIdResolved:"\0virtual:buffer",namespace:"virtual-buffer"},{code:"export { default as process } from 'process'",moduleId:"virtual:process",moduleIdRegex:/^virtual:process$/,moduleIdResolved:"\0virtual:process",namespace:"virtual-process"}],qt=(e={})=>{const t={include:[],exclude:[],overrides:{},protocolImports:!0,...e,globals:{Buffer:!0,global:!0,process:!0,...e.globals}},{env:n,presets:o}=Wt({nodeCompat:!0,npmShims:!0,resolve:!0}),i=s=>t.include.length>0?!t.include.some(l=>re(s,l)):t.exclude.some(l=>re(s,l)),r=s=>{if(y(t.globals.Buffer,"dev")&&/^buffer$/.test(s))return"vite-plugin-node-polyfills/shims/buffer";if(y(t.globals.global,"dev")&&/^global$/.test(s))return"vite-plugin-node-polyfills/shims/global";if(y(t.globals.process,"dev")&&/^process$/.test(s))return"vite-plugin-node-polyfills/shims/process";if(s in t.overrides)return t.overrides[s]};return Object.entries(Te.default).reduce((s,[l,a])=>(!t.protocolImports&&Ct(l)||i(l)||(s[l]=r(k(l))||a),s),{}),[{name:"vite-plugin-node-polyfills",config:(s,l)=>{l.command;const a={...y(t.globals.Buffer,"build")?{Buffer:"vite-plugin-node-polyfills/shims/buffer"}:{},...y(t.globals.global,"build")?{global:"vite-plugin-node-polyfills/shims/global"}:{},...y(t.globals.process,"build")?{process:"vite-plugin-node-polyfills/shims/process"}:{}};return{build:{rollupOptions:{onwarn:(d,f)=>{ve.handleCircularDependancyWarning(d,()=>{if(s.build?.rollupOptions?.onwarn)return s.build.rollupOptions.onwarn(d,f);f(d)})},plugins:Object.keys(a).length>0?[q.default(n.inject)]:[]}},optimizeDeps:{esbuildOptions:{inject:[...$.map(d=>d.moduleId)],plugins:[xe.default(n.alias),{name:"vite-plugin-node-polyfills-shims-resolver",async setup(d){for(const f of $)d.onResolve({filter:f.moduleIdRegex},()=>({external:!1,namespace:f.namespace,path:f.moduleId})),d.onLoad({filter:f.moduleIdRegex,namespace:f.namespace},()=>({contents:f.code,loader:"js"}))}}]}},resolve:{alias:{...n.alias}}}}},{name:"virtual-shims-resolver",resolveId(s){for(const l of $)if(s===l.moduleId)return l.moduleIdResolved},load(s){for(const l of $)if(s===l.moduleIdResolved)return{code:l.code}}},q.default(n.inject)]};exports.nodePolyfills=qt;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("node:module"),x=require("@rollup/plugin-inject"),O=require("node-stdlib-browser"),P=require("node-stdlib-browser/helpers/rollup/plugin"),R=require("node-stdlib-browser/helpers/esbuild/plugin");var h=typeof document<"u"?document.currentScript:null;const g=l=>l&&l.__esModule?l:{default:l},S=g(x),q=g(O),w=g(R),_=(l,e)=>b(l)===b(e),s=(l,e)=>l?l===!0?!0:l===e:!1,$=l=>l.startsWith("node:"),I=l=>{const e=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${e}$`)},b=l=>l.replace(/^node:/,""),a={buffer:["import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'","globalThis.Buffer = globalThis.Buffer || __buffer_polyfill"],global:["import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'","globalThis.global = globalThis.global || __global_polyfill"],process:["import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'","globalThis.process = globalThis.process || __process_polyfill"]},D=(l={})=>{const e={include:[],exclude:[],overrides:{},protocolImports:!0,...l,globals:{Buffer:!0,global:!0,process:!0,...l.globals}},y=o=>e.include.length>0?!e.include.some(r=>_(o,r)):e.exclude.some(r=>_(o,r)),B=o=>{if(s(e.globals.Buffer,"dev")&&/^buffer$/.test(o))return"vite-plugin-node-polyfills/shims/buffer";if(s(e.globals.global,"dev")&&/^global$/.test(o))return"vite-plugin-node-polyfills/shims/global";if(s(e.globals.process,"dev")&&/^process$/.test(o))return"vite-plugin-node-polyfills/shims/process";if(o in e.overrides)return e.overrides[o]},u=Object.entries(q.default).reduce((o,[r,i])=>(!e.protocolImports&&$(r)||y(r)||(o[r]=B(b(r))||i),o),{}),f=T.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:h&&h.src||new URL("index.cjs",document.baseURI).href),p=[...s(e.globals.Buffer,"dev")?[f.resolve("vite-plugin-node-polyfills/shims/buffer")]:[],...s(e.globals.global,"dev")?[f.resolve("vite-plugin-node-polyfills/shims/global")]:[],...s(e.globals.process,"dev")?[f.resolve("vite-plugin-node-polyfills/shims/process")]:[]],d=[...s(e.globals.Buffer,"dev")?a.buffer:[],...s(e.globals.global,"dev")?a.global:[],...s(e.globals.process,"dev")?a.process:[],""].join(`
`);return{name:"vite-plugin-node-polyfills",config(o,r){const i=r.command==="serve",v=!!this?.meta?.rolldownVersion,m={...i&&s(e.globals.Buffer,"dev")?{Buffer:"Buffer"}:{},...i&&s(e.globals.global,"dev")?{global:"global"}:{},...i&&s(e.globals.process,"dev")?{process:"process"}:{}},c={...s(e.globals.Buffer,"build")?{Buffer:"vite-plugin-node-polyfills/shims/buffer"}:{},...s(e.globals.global,"build")?{global:"vite-plugin-node-polyfills/shims/global"}:{},...s(e.globals.process,"build")?{process:"vite-plugin-node-polyfills/shims/process"}:{}};return{build:{rollupOptions:{onwarn:(t,n)=>{P.handleCircularDependancyWarning(t,()=>{if(o.build?.rollupOptions?.onwarn)return o.build.rollupOptions.onwarn(t,n);n(t)})},...Object.keys(c).length>0?v?{inject:c}:{plugins:[S.default(c)]}:{}}},esbuild:{banner:i?d:void 0},optimizeDeps:{exclude:[...p],...v?{rollupOptions:{define:m,resolve:{alias:{...u}},plugins:[{name:"vite-plugin-node-polyfills:optimizer",banner:i?d:void 0}]}}:{esbuildOptions:{banner:i?{js:d}:void 0,define:m,inject:[...p],plugins:[w.default(u),{name:"vite-plugin-node-polyfills-shims-resolver",setup(t){for(const n of p){const j=I(n);t.onResolve({filter:j},()=>({external:!1,path:n}))}}}]}}},resolve:{alias:{...u}}}}}};exports.nodePolyfills=D;
//# sourceMappingURL=index.cjs.map
+109
-1421

@@ -1,1350 +0,24 @@

import G from "@rollup/plugin-inject";
import pe from "node-stdlib-browser";
import { handleCircularDependancyWarning as ge } from "node-stdlib-browser/helpers/rollup/plugin";
import ve from "node-stdlib-browser/helpers/esbuild/plugin";
import { builtinModules as _e } from "node:module";
import ye, { statSync as N, realpathSync as Ee } from "node:fs";
import { pathToFileURL as v, fileURLToPath as a, URL as p } from "node:url";
import M, { isAbsolute as Re } from "node:path";
import _ from "node:assert";
import y from "node:process";
import we from "node:v8";
import { format as xe, inspect as L } from "node:util";
const C = [
"_http_agent",
"_http_client",
"_http_common",
"_http_incoming",
"_http_outgoing",
"_http_server",
"_stream_duplex",
"_stream_passthrough",
"_stream_readable",
"_stream_transform",
"_stream_wrap",
"_stream_writable",
"_tls_common",
"_tls_wrap",
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"http2",
"https",
"inspector",
"inspector/promises",
"module",
"net",
"os",
"path",
"path/posix",
"path/win32",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"readline/promises",
"repl",
"stream",
"stream/consumers",
"stream/promises",
"stream/web",
"string_decoder",
"sys",
"timers",
"timers/promises",
"tls",
"trace_events",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib"
], $e = {}.hasOwnProperty, Oe = /^([A-Z][a-z\d]*)+$/, je = /* @__PURE__ */ new Set([
"string",
"function",
"number",
"object",
// Accept 'Function' and 'Object' as alternative to the lower cased version.
"Function",
"Object",
"boolean",
"bigint",
"symbol"
]), se = /* @__PURE__ */ new Map(), Pe = "__node_internal_";
let z;
function A(e, t = "and") {
return e.length < 3 ? e.join(` ${t} `) : `${e.slice(0, -1).join(", ")}, ${t} ${e.at(-1)}`;
}
function g(e, t, n) {
return se.set(e, t), Te(n, e);
}
function Te(e, t) {
return function(...r) {
const i = Error.stackTraceLimit;
k() && (Error.stackTraceLimit = 0);
const o = new e();
k() && (Error.stackTraceLimit = i);
const s = Se(t, r, o);
return Object.defineProperties(o, {
// Note: no need to implement `kIsNodeError` symbol, would be hard,
// probably.
message: {
value: s,
enumerable: !1,
writable: !0,
configurable: !0
},
toString: {
/** @this {Error} */
value() {
return `${this.name} [${t}]: ${this.message}`;
},
enumerable: !1,
writable: !0,
configurable: !0
}
}), Ne(o), o.code = t, o;
};
}
function k() {
try {
if (we.startupSnapshot.isBuildingSnapshot())
return !1;
} catch {
}
const e = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
return e === void 0 ? Object.isExtensible(Error) : $e.call(e, "writable") && e.writable !== void 0 ? e.writable : e.set !== void 0;
}
function Ie(e) {
const t = Pe + e.name;
return Object.defineProperty(e, "name", { value: t }), e;
}
const Ne = Ie(function(e) {
const t = k();
return t && (z = Error.stackTraceLimit, Error.stackTraceLimit = Number.POSITIVE_INFINITY), Error.captureStackTrace(e), t && (Error.stackTraceLimit = z), e;
});
function Se(e, t, n) {
const r = se.get(e);
if (_(r !== void 0, "expected `message` to be found"), typeof r == "function")
return _(
r.length <= t.length,
// Default options do not count.
`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`
), Reflect.apply(r, n, t);
const i = /%[dfijoOs]/g;
let o = 0;
for (; i.exec(r) !== null; )
o++;
return _(
o === t.length,
`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${o}).`
), t.length === 0 ? r : (t.unshift(r), Reflect.apply(xe, null, t));
}
function Ae(e) {
if (e == null)
return String(e);
if (typeof e == "function" && e.name)
return `function ${e.name}`;
if (typeof e == "object")
return e.constructor && e.constructor.name ? `an instance of ${e.constructor.name}` : `${L(e, { depth: -1 })}`;
let t = L(e, { colors: !1 });
return t.length > 28 && (t = `${t.slice(0, 25)}...`), `type ${typeof e} (${t})`;
}
g(
"ERR_INVALID_ARG_TYPE",
(e, t, n) => {
_(typeof e == "string", "'name' must be a string"), Array.isArray(t) || (t = [t]);
let r = "The ";
if (e.endsWith(" argument"))
r += `${e} `;
else {
const l = e.includes(".") ? "property" : "argument";
r += `"${e}" ${l} `;
}
r += "must be ";
const i = [], o = [], s = [];
for (const l of t)
_(
typeof l == "string",
"All expected entries have to be of type string"
), je.has(l) ? i.push(l.toLowerCase()) : Oe.exec(l) === null ? (_(
l !== "object",
'The value "object" should be written as "Object"'
), s.push(l)) : o.push(l);
if (o.length > 0) {
const l = i.indexOf("object");
l !== -1 && (i.slice(l, 1), o.push("Object"));
}
return i.length > 0 && (r += `${i.length > 1 ? "one of type" : "of type"} ${A(
i,
"or"
)}`, (o.length > 0 || s.length > 0) && (r += " or ")), o.length > 0 && (r += `an instance of ${A(o, "or")}`, s.length > 0 && (r += " or ")), s.length > 0 && (s.length > 1 ? r += `one of ${A(s, "or")}` : (s[0]?.toLowerCase() !== s[0] && (r += "an "), r += `${s[0]}`)), r += `. Received ${Ae(n)}`, r;
},
TypeError
);
const S = g(
"ERR_INVALID_MODULE_SPECIFIER",
/**
* @param {string} request
* @param {string} reason
* @param {string} [base]
*/
(e, t, n) => `Invalid module "${e}" ${t}${n ? ` imported from ${n}` : ""}`,
TypeError
), U = g(
"ERR_INVALID_PACKAGE_CONFIG",
(e, t, n) => `Invalid package config ${e}${t ? ` while importing ${t}` : ""}${n ? `. ${n}` : ""}`,
Error
), be = g(
"ERR_INVALID_PACKAGE_TARGET",
(e, t, n, r = !1, i) => {
const o = typeof n == "string" && !r && n.length > 0 && !n.startsWith("./");
return t === "." ? (_(r === !1), `Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i ? ` imported from ${i}` : ""}${o ? '; targets must start with "./"' : ""}`) : `Invalid "${r ? "imports" : "exports"}" target ${JSON.stringify(
n
)} defined for '${t}' in the package config ${e}package.json${i ? ` imported from ${i}` : ""}${o ? '; targets must start with "./"' : ""}`;
},
Error
), F = g(
"ERR_MODULE_NOT_FOUND",
(e, t, n = !1) => `Cannot find ${n ? "module" : "package"} '${e}' imported from ${t}`,
Error
);
g(
"ERR_NETWORK_IMPORT_DISALLOWED",
"import of '%s' by %s is not supported: %s",
Error
);
const De = g(
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
(e, t, n) => `Package import specifier "${e}" is not defined${t ? ` in package ${t || ""}package.json` : ""} imported from ${n}`,
TypeError
), Le = g(
"ERR_PACKAGE_PATH_NOT_EXPORTED",
/**
* @param {string} packagePath
* @param {string} subpath
* @param {string} [base]
*/
(e, t, n) => t === "." ? `No "exports" main defined in ${e}package.json${n ? ` imported from ${n}` : ""}` : `Package subpath '${t}' is not defined by "exports" in ${e}package.json${n ? ` imported from ${n}` : ""}`,
Error
), ke = g(
"ERR_UNSUPPORTED_DIR_IMPORT",
"Directory import '%s' is not supported resolving ES modules imported from %s",
Error
), K = g(
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
TypeError
), We = g(
"ERR_UNKNOWN_FILE_EXTENSION",
(e, t) => `Unknown file extension "${e}" for ${t}`,
TypeError
);
g(
"ERR_INVALID_ARG_VALUE",
(e, t, n = "is invalid") => {
let r = L(t);
return r.length > 128 && (r = `${r.slice(0, 128)}...`), `The ${e.includes(".") ? "property" : "argument"} '${e}' ${n}. Received ${r}`;
},
TypeError
// Note: extra classes have been shaken out.
// , RangeError
);
const x = {}.hasOwnProperty, V = /* @__PURE__ */ new Map();
function ie(e, { base: t, specifier: n }) {
const r = V.get(e);
if (r)
return r;
let i;
try {
i = ye.readFileSync(M.toNamespacedPath(e), "utf8");
} catch (s) {
const l = s;
if (l.code !== "ENOENT")
throw l;
}
const o = {
exists: !1,
pjsonPath: e,
main: void 0,
name: void 0,
type: "none",
// Ignore unknown types for forwards compatibility
exports: void 0,
imports: void 0
};
if (i !== void 0) {
let s;
try {
s = JSON.parse(i);
} catch (l) {
const f = new U(
e,
(t ? `"${n}" from ` : "") + a(t || n),
l.message
);
throw f.cause = l, f;
}
o.exists = !0, x.call(s, "name") && typeof s.name == "string" && (o.name = s.name), x.call(s, "main") && typeof s.main == "string" && (o.main = s.main), x.call(s, "exports") && (o.exports = s.exports), x.call(s, "imports") && (o.imports = s.imports), x.call(s, "type") && (s.type === "commonjs" || s.type === "module") && (o.type = s.type);
}
return V.set(e, o), o;
}
function I(e) {
let t = new URL("package.json", e);
for (; !t.pathname.endsWith("node_modules/package.json"); ) {
const i = ie(a(t), {
specifier: e
});
if (i.exists)
return i;
const o = t;
if (t = new URL("../package.json", t), t.pathname === o.pathname)
break;
}
return {
pjsonPath: a(t),
exists: !1,
type: "none"
};
}
const Me = {}.hasOwnProperty, Ce = {
__proto__: null,
".json": "json",
".cjs": "commonjs",
".cts": "commonjs",
".js": "module",
".ts": "module",
".mts": "module",
".mjs": "module"
}, B = {
__proto__: null,
"data:": Fe,
"file:": ze,
"node:": () => "builtin"
};
function Ue(e) {
return e && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e) ? "module" : e === "application/json" ? "json" : null;
}
function Fe(e) {
const { 1: t } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
e.pathname
) || [null, null, null];
return Ue(t);
}
function Ge(e) {
const t = e.pathname;
let n = t.length;
for (; n--; ) {
const r = t.codePointAt(n);
if (r === 47)
return "";
if (r === 46)
return t.codePointAt(n - 1) === 47 ? "" : t.slice(n);
}
return "";
}
function ze(e, t, n) {
const r = Ge(e);
if (r === ".js") {
const { type: s } = I(e);
return s !== "none" ? s : "commonjs";
}
if (r === "") {
const { type: s } = I(e);
return s === "none" || s === "commonjs" ? "commonjs" : "module";
}
const i = Ce[r];
if (i)
return i;
if (n)
return;
const o = a(e);
throw new We(r, o);
}
function Ke(e, t) {
const n = e.protocol;
return Me.call(B, n) && B[n](e, t, !0) || null;
}
const j = RegExp.prototype[Symbol.replace], le = {}.hasOwnProperty, q = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i, X = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i, Ve = /^\.|%|\\/, P = /\*/g, Be = /%2f|%5c/i, H = /* @__PURE__ */ new Set(), qe = /[/\\]{2}/;
function Z(e, t, n, r, i, o, s) {
if (y.noDeprecation)
return;
const l = a(r), f = qe.exec(s ? e : t) !== null;
y.emitWarning(
`Use of deprecated ${f ? "double slash" : "leading or trailing slash matching"} resolving "${e}" for module request "${t}" ${t === n ? "" : `matched to "${n}" `}in the "${i ? "imports" : "exports"}" field module resolution of the package at ${l}${o ? ` imported from ${a(o)}` : ""}.`,
"DeprecationWarning",
"DEP0166"
);
}
function Q(e, t, n, r) {
if (y.noDeprecation || Ke(e, { parentURL: n.href }) !== "module")
return;
const o = a(e.href), s = a(new p(".", t)), l = a(n);
r ? M.resolve(s, r) !== o && y.emitWarning(
`Package ${s} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${o.slice(
s.length
)}", imported from ${l}.
Automatic extension resolution of the "main" field is deprecated for ES modules.`,
"DeprecationWarning",
"DEP0151"
) : y.emitWarning(
`No "main" or "exports" field defined in the package.json for ${s} resolving the main entry point "${o.slice(
s.length
)}", imported from ${l}.
Default "index" lookups for the main are deprecated for ES modules.`,
"DeprecationWarning",
"DEP0151"
);
}
function ce(e) {
try {
return N(e);
} catch {
}
}
function b(e) {
const t = N(e, { throwIfNoEntry: !1 }), n = t ? t.isFile() : void 0;
return n ?? !1;
}
function Xe(e, t, n) {
let r;
if (t.main !== void 0) {
if (r = new p(t.main, e), b(r))
return r;
const s = [
`./${t.main}.js`,
`./${t.main}.json`,
`./${t.main}.node`,
`./${t.main}/index.js`,
`./${t.main}/index.json`,
`./${t.main}/index.node`
];
let l = -1;
for (; ++l < s.length && (r = new p(s[l], e), !b(r)); )
r = void 0;
if (r)
return Q(
r,
e,
n,
t.main
), r;
}
const i = ["./index.js", "./index.json", "./index.node"];
let o = -1;
for (; ++o < i.length && (r = new p(i[o], e), !b(r)); )
r = void 0;
if (r)
return Q(r, e, n, t.main), r;
throw new F(
a(new p(".", e)),
a(n)
);
}
function He(e, t, n) {
if (Be.exec(e.pathname) !== null)
throw new S(
e.pathname,
String.raw`must not include encoded "/" or "\" characters`,
a(t)
);
let r;
try {
r = a(e);
} catch (o) {
throw Object.defineProperty(o, "input", { value: String(e) }), Object.defineProperty(o, "module", { value: String(t) }), o;
}
const i = ce(
r.endsWith("/") ? r.slice(-1) : r
);
if (i && i.isDirectory()) {
const o = new ke(r, a(t));
throw o.url = String(e), o;
}
if (!i || !i.isFile()) {
const o = new F(
r || e.pathname,
t && a(t),
!0
);
throw o.url = String(e), o;
}
{
const o = Ee(r), { search: s, hash: l } = e;
e = v(o + (r.endsWith(M.sep) ? "/" : "")), e.search = s, e.hash = l;
}
return e;
}
function Ze(e, t, n) {
return new De(
e,
t && a(new p(".", t)),
a(n)
);
}
function D(e, t, n) {
return new Le(
a(new p(".", t)),
e,
n && a(n)
);
}
function Qe(e, t, n, r, i) {
const o = `request is not a valid match in pattern "${t}" for the "${r ? "imports" : "exports"}" resolution of ${a(n)}`;
throw new S(
e,
o,
i && a(i)
);
}
function $(e, t, n, r, i) {
return t = typeof t == "object" && t !== null ? JSON.stringify(t, null, "") : `${t}`, new be(
a(new p(".", n)),
e,
t,
r,
i && a(i)
);
}
function Ye(e, t, n, r, i, o, s, l, f) {
if (t !== "" && !o && e.at(-1) !== "/")
throw $(n, e, r, s, i);
if (!e.startsWith("./")) {
if (s && !e.startsWith("../") && !e.startsWith("/")) {
let h = !1;
try {
new p(e), h = !0;
} catch {
}
if (!h) {
const m = o ? j.call(
P,
e,
() => t
) : e + t;
return ue(m, r, f);
}
}
throw $(n, e, r, s, i);
}
if (q.exec(e.slice(2)) !== null)
if (X.exec(e.slice(2)) === null) {
if (!l) {
const h = o ? n.replace("*", () => t) : n + t, m = o ? j.call(
P,
e,
() => t
) : e;
Z(
m,
h,
n,
r,
s,
i,
!0
);
}
} else
throw $(n, e, r, s, i);
const d = new p(e, r), c = d.pathname, u = new p(".", r).pathname;
if (!c.startsWith(u))
throw $(n, e, r, s, i);
if (t === "")
return d;
if (q.exec(t) !== null) {
const h = o ? n.replace("*", () => t) : n + t;
if (X.exec(t) === null) {
if (!l) {
const m = o ? j.call(
P,
e,
() => t
) : e;
Z(
m,
h,
n,
r,
s,
i,
!1
);
}
} else
Qe(h, n, r, s, i);
}
return o ? new p(
j.call(
P,
d.href,
() => t
)
) : new p(t, d);
}
function Je(e) {
const t = Number(e);
return `${t}` !== e ? !1 : t >= 0 && t < 4294967295;
}
function w(e, t, n, r, i, o, s, l, f) {
if (typeof t == "string")
return Ye(
t,
n,
r,
e,
i,
o,
s,
l,
f
);
if (Array.isArray(t)) {
const d = t;
if (d.length === 0)
return null;
let c, u = -1;
for (; ++u < d.length; ) {
const h = d[u];
let m;
try {
m = w(
e,
h,
n,
r,
i,
o,
s,
l,
f
);
} catch (E) {
const O = E;
if (c = O, O.code === "ERR_INVALID_PACKAGE_TARGET")
continue;
throw E;
}
if (m !== void 0) {
if (m === null) {
c = null;
continue;
}
return m;
}
}
if (c == null)
return null;
throw c;
}
if (typeof t == "object" && t !== null) {
const d = Object.getOwnPropertyNames(t);
let c = -1;
for (; ++c < d.length; ) {
const u = d[c];
if (Je(u))
throw new U(
a(e),
a(i),
'"exports" cannot contain numeric property keys.'
);
}
for (c = -1; ++c < d.length; ) {
const u = d[c];
if (u === "default" || f && f.has(u)) {
const h = t[u], m = w(
e,
h,
n,
r,
i,
o,
s,
l,
f
);
if (m === void 0)
continue;
return m;
}
}
return null;
}
if (t === null)
return null;
throw $(
r,
t,
e,
s,
i
);
}
function et(e, t, n) {
if (typeof e == "string" || Array.isArray(e))
return !0;
if (typeof e != "object" || e === null)
return !1;
const r = Object.getOwnPropertyNames(e);
let i = !1, o = 0, s = -1;
for (; ++s < r.length; ) {
const l = r[s], f = l === "" || l[0] !== ".";
if (o++ === 0)
i = f;
else if (i !== f)
throw new U(
a(t),
a(n),
`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
);
}
return i;
}
function tt(e, t, n) {
if (y.noDeprecation)
return;
const r = a(t);
H.has(r + "|" + e) || (H.add(r + "|" + e), y.emitWarning(
`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n ? ` imported from ${a(n)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
"DeprecationWarning",
"DEP0155"
));
}
function Y(e, t, n, r, i) {
let o = n.exports;
if (et(o, e, r) && (o = { ".": o }), le.call(o, t) && !t.includes("*") && !t.endsWith("/")) {
const c = o[t], u = w(
e,
c,
"",
t,
r,
!1,
!1,
!1,
i
);
if (u == null)
throw D(t, e, r);
return u;
}
let s = "", l = "";
const f = Object.getOwnPropertyNames(o);
let d = -1;
for (; ++d < f.length; ) {
const c = f[d], u = c.indexOf("*");
if (u !== -1 && t.startsWith(c.slice(0, u))) {
t.endsWith("/") && tt(
t,
e,
r
);
const h = c.slice(u + 1);
t.length >= c.length && t.endsWith(h) && fe(s, c) === 1 && c.lastIndexOf("*") === u && (s = c, l = t.slice(
u,
t.length - h.length
));
}
}
if (s) {
const c = o[s], u = w(
e,
c,
l,
s,
r,
!0,
!1,
t.endsWith("/"),
i
);
if (u == null)
throw D(t, e, r);
return u;
}
throw D(t, e, r);
}
function fe(e, t) {
const n = e.indexOf("*"), r = t.indexOf("*"), i = n === -1 ? e.length : n + 1, o = r === -1 ? t.length : r + 1;
return i > o ? -1 : o > i || n === -1 ? 1 : r === -1 || e.length > t.length ? -1 : t.length > e.length ? 1 : 0;
}
function nt(e, t, n) {
if (e === "#" || e.startsWith("#/") || e.endsWith("/")) {
const o = "is not a valid internal imports specifier name";
throw new S(e, o, a(t));
}
let r;
const i = I(t);
if (i.exists) {
r = v(i.pjsonPath);
const o = i.imports;
if (o)
if (le.call(o, e) && !e.includes("*")) {
const s = w(
r,
o[e],
"",
e,
t,
!1,
!0,
!1,
n
);
if (s != null)
return s;
} else {
let s = "", l = "";
const f = Object.getOwnPropertyNames(o);
let d = -1;
for (; ++d < f.length; ) {
const c = f[d], u = c.indexOf("*");
if (u !== -1 && e.startsWith(c.slice(0, -1))) {
const h = c.slice(u + 1);
e.length >= c.length && e.endsWith(h) && fe(s, c) === 1 && c.lastIndexOf("*") === u && (s = c, l = e.slice(
u,
e.length - h.length
));
}
}
if (s) {
const c = o[s], u = w(
r,
c,
l,
s,
t,
!0,
!0,
!1,
n
);
if (u != null)
return u;
}
}
}
throw Ze(e, r, t);
}
function rt(e, t) {
let n = e.indexOf("/"), r = !0, i = !1;
e[0] === "@" && (i = !0, n === -1 || e.length === 0 ? r = !1 : n = e.indexOf("/", n + 1));
const o = n === -1 ? e : e.slice(0, n);
if (Ve.exec(o) !== null && (r = !1), !r)
throw new S(
e,
"is not a valid package name",
a(t)
);
const s = "." + (n === -1 ? "" : e.slice(n));
return { packageName: o, packageSubpath: s, isScoped: i };
}
function ue(e, t, n) {
if (C.includes(e))
return new p("node:" + e);
const { packageName: r, packageSubpath: i, isScoped: o } = rt(
e,
t
), s = I(t);
if (s.exists && s.name === r && s.exports !== void 0 && s.exports !== null) {
const c = v(s.pjsonPath);
return Y(
c,
i,
s,
t,
n
);
}
let l = new p(
"./node_modules/" + r + "/package.json",
t
), f = a(l), d;
do {
const c = ce(f.slice(0, -13));
if (!c || !c.isDirectory()) {
d = f, l = new p(
(o ? "../../../../node_modules/" : "../../../node_modules/") + r + "/package.json",
l
), f = a(l);
continue;
}
const u = ie(f, { base: t, specifier: e });
return u.exports !== void 0 && u.exports !== null ? Y(
l,
i,
u,
t,
n
) : i === "." ? Xe(l, u, t) : new p(i, l);
} while (f.length !== d.length);
throw new F(r, a(t), !1);
}
function ot(e) {
return e[0] === "." && (e.length === 1 || e[1] === "/" || e[1] === "." && (e.length === 2 || e[2] === "/"));
}
function st(e) {
return e === "" ? !1 : e[0] === "/" ? !0 : ot(e);
}
function it(e, t, n, r) {
const i = t.protocol, o = i === "data:";
let s;
if (st(e))
try {
s = new p(e, t);
} catch (l) {
const f = new K(e, t);
throw f.cause = l, f;
}
else if (i === "file:" && e[0] === "#")
s = nt(e, t, n);
else
try {
s = new p(e);
} catch (l) {
if (o && !C.includes(e)) {
const f = new K(e, t);
throw f.cause = l, f;
}
s = ue(e, t, n);
}
return _(s !== void 0, "expected to be defined"), s.protocol !== "file:" ? s : He(s, t);
}
const lt = /* @__PURE__ */ new Set(["node", "import"]), ct = process.platform === "win32", ft = /* @__PURE__ */ new Set([
"ERR_MODULE_NOT_FOUND",
"ERR_UNSUPPORTED_DIR_IMPORT",
"MODULE_NOT_FOUND",
"ERR_PACKAGE_PATH_NOT_EXPORTED",
"ERR_PACKAGE_IMPORT_NOT_DEFINED"
]), ae = /* eslint-disable-next-line unicorn/no-unreadable-iife */ globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
function de(e, t) {
const n = _t(e);
if ("external" in n)
return n.external;
const r = n.specifier, i = n.url, o = n.absolutePath;
let s, l;
if (t?.cache !== !1 && (s = pt(o || r, t), l = t?.cache && typeof t?.cache == "object" ? t.cache : ae), l) {
const m = l.get(s);
if (typeof m == "string")
return m;
if (m instanceof Error) {
if (t?.try)
return;
throw m;
}
}
if (o)
try {
if (N(o).isFile())
return l && l.set(s, i.href), i.href;
} catch (m) {
if (m?.code !== "ENOENT")
throw l && l.set(s, m), m;
}
const f = t?.conditions ? new Set(t.conditions) : lt, d = me(t?.from), c = t?.suffixes || [""], u = t?.extensions ? ["", ...t.extensions] : [""];
let h;
for (const m of d) {
for (const E of c) {
for (const O of u)
if (h = dt(
gt(r || i.href, E) + O,
m,
f
), h)
break;
if (h)
break;
}
if (h)
break;
}
if (!h) {
const m = new Error(
`Cannot resolve module "${e}" (from: ${d.map((E) => ht(E)).join(", ")})`
);
if (m.code = "ERR_MODULE_NOT_FOUND", l && l.set(s, m), t?.try)
return;
throw m;
}
return l && l.set(s, h.href), h.href;
}
function ut(e, t) {
const n = de(e, t);
if (!n || !n.startsWith("file://") && t?.try)
return;
const r = a(n);
return ct ? vt(r) : r;
}
function at(e) {
return e?.from && (e = {
...e,
from: me(e?.from)
}), {
resolveModuleURL: (t, n) => de(t, { ...e, ...n }),
resolveModulePath: (t, n) => ut(t, { ...e, ...n }),
clearResolveCache: () => {
e?.cache !== !1 && (e?.cache && typeof e?.cache == "object" ? e.cache.clear() : ae.clear());
}
};
}
function dt(e, t, n) {
try {
return it(e, t, n);
} catch (r) {
if (!ft.has(r?.code))
throw r;
}
}
function me(e) {
const t = (Array.isArray(e) ? e : [e]).flatMap(
(n) => mt(n)
);
return t.length === 0 ? [v("./")] : t;
}
function mt(e) {
if (!e)
return [];
if (e instanceof URL)
return [e];
if (typeof e != "string")
return [];
if (/^(?:node|data|http|https|file):/.test(e))
return new URL(e);
try {
return e.endsWith("/") || N(e).isDirectory() ? v(e + "/") : v(e);
} catch {
return [v(e + "/"), v(e)];
}
}
function ht(e) {
try {
return a(e);
} catch {
return e;
}
}
function pt(e, t) {
return JSON.stringify([
e,
(t?.conditions || ["node", "import"]).sort(),
t?.extensions,
t?.from,
t?.suffixes
]);
}
function gt(e, t) {
return !e || !t || t === "/" ? e : (e.endsWith("/") ? e : e + "/") + (t.startsWith("/") ? t.slice(1) : t);
}
function vt(e) {
return e.replace(/\\/g, "/").replace(/^[a-z]:\//, (t) => t.toUpperCase());
}
function _t(e) {
if (typeof e == "string") {
if (e.startsWith("file:")) {
const t = new URL(e);
return { url: t, absolutePath: a(t) };
}
return Re(e) ? { url: v(e), absolutePath: e } : /^(?:node|data|http|https):/.test(e) ? { external: e } : C.includes(e) && !e.includes(":") ? { external: `node:${e}` } : { specifier: e };
}
if (e instanceof URL)
return e.protocol === "file:" ? { url: e, absolutePath: a(e) } : { external: e.href };
throw new TypeError("id must be a `string` or `URL`");
}
const yt = /^[A-Za-z]:\//;
function he(e = "") {
return e && e.replace(/\\/g, "/").replace(yt, (t) => t.toUpperCase());
}
const Et = /^[/\\]{2}/, Rt = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, wt = /^[A-Za-z]:$/, xt = function(e) {
if (e.length === 0)
return ".";
e = he(e);
const t = e.match(Et), n = J(e), r = e[e.length - 1] === "/";
return e = Ot(e, !n), e.length === 0 ? n ? "/" : r ? "./" : "." : (r && (e += "/"), wt.test(e) && (e += "/"), t ? n ? `//${e}` : `//./${e}` : n && !J(e) ? `/${e}` : e);
}, $t = function(...e) {
let t = "";
for (const n of e)
if (n)
if (t.length > 0) {
const r = t[t.length - 1] === "/", i = n[0] === "/";
r && i ? t += n.slice(1) : t += r || i ? n : `/${n}`;
} else
t += n;
return xt(t);
};
function Ot(e, t) {
let n = "", r = 0, i = -1, o = 0, s = null;
for (let l = 0; l <= e.length; ++l) {
if (l < e.length)
s = e[l];
else {
if (s === "/")
break;
s = "/";
}
if (s === "/") {
if (!(i === l - 1 || o === 1))
if (o === 2) {
if (n.length < 2 || r !== 2 || n[n.length - 1] !== "." || n[n.length - 2] !== ".") {
if (n.length > 2) {
const f = n.lastIndexOf("/");
f === -1 ? (n = "", r = 0) : (n = n.slice(0, f), r = n.length - 1 - n.lastIndexOf("/")), i = l, o = 0;
continue;
} else if (n.length > 0) {
n = "", r = 0, i = l, o = 0;
continue;
}
}
t && (n += n.length > 0 ? "/.." : "..", r = 2);
} else
n.length > 0 ? n += `/${e.slice(i + 1, l)}` : n = e.slice(i + 1, l), r = l - i - 1;
i = l, o = 0;
} else
s === "." && o !== -1 ? ++o : o = -1;
}
return n;
}
const J = function(e) {
return Rt.test(e);
}, jt = /* @__PURE__ */ new Set([
"/",
"\\",
void 0
]), ee = Symbol.for("pathe:normalizedAlias");
function Pt(e) {
if (e[ee])
return e;
const t = Object.fromEntries(Object.entries(e).sort(([n], [r]) => It(n, r)));
for (const n in t)
for (const r in t)
r === n || n.startsWith(r) || t[n]?.startsWith(r) && jt.has(t[n][r.length]) && (t[n] = t[r] + t[n].slice(r.length));
return Object.defineProperty(t, ee, {
value: !0,
enumerable: !1
}), t;
}
function Tt(e, t) {
const n = he(e);
t = Pt(t);
for (const [r, i] of Object.entries(t)) {
if (!n.startsWith(r))
continue;
const o = te(r) ? r.slice(0, -1) : r;
if (te(n[o.length]))
return $t(i, n.slice(r.length));
}
return n;
}
function It(e, t) {
return t.split("/").length - e.split("/").length;
}
function te(e = "/") {
const t = e[e.length - 1];
return t === "/" || t === "\\";
}
var Nt = "2.0.0-20250317-133939-bd867e9";
const St = {
_http_agent: "unenv/mock/proxy-cjs",
_http_client: "unenv/mock/proxy-cjs",
_http_common: "unenv/mock/proxy-cjs",
_http_incoming: "unenv/mock/proxy-cjs",
_http_outgoing: "unenv/mock/proxy-cjs",
_http_server: "unenv/mock/proxy-cjs",
_stream_duplex: "unenv/mock/proxy-cjs",
_stream_passthrough: "unenv/mock/proxy-cjs",
_stream_readable: "unenv/mock/proxy-cjs",
_stream_transform: "unenv/mock/proxy-cjs",
_stream_wrap: "unenv/mock/proxy-cjs",
_stream_writable: "unenv/mock/proxy-cjs",
_tls_common: "unenv/mock/proxy-cjs",
_tls_wrap: "unenv/mock/proxy-cjs",
assert: "unenv/node/assert",
"assert/strict": "unenv/node/assert/strict",
async_hooks: "unenv/node/async_hooks",
buffer: "unenv/node/buffer",
child_process: "unenv/node/child_process",
cluster: "unenv/node/cluster",
console: "unenv/node/console",
constants: "unenv/node/constants",
crypto: "unenv/node/crypto",
dgram: "unenv/node/dgram",
diagnostics_channel: "unenv/node/diagnostics_channel",
dns: "unenv/node/dns",
"dns/promises": "unenv/node/dns/promises",
domain: "unenv/node/domain",
events: "unenv/node/events",
fs: "unenv/node/fs",
"fs/promises": "unenv/node/fs/promises",
http: "unenv/node/http",
http2: "unenv/node/http2",
https: "unenv/node/https",
inspector: "unenv/node/inspector",
"inspector/promises": "unenv/node/inspector/promises",
module: "unenv/node/module",
net: "unenv/node/net",
os: "unenv/node/os",
path: "unenv/node/path",
"path/posix": "unenv/node/path",
"path/win32": "unenv/node/path",
perf_hooks: "unenv/node/perf_hooks",
process: "unenv/node/process",
punycode: "unenv/node/punycode",
querystring: "unenv/node/querystring",
readline: "unenv/node/readline",
"readline/promises": "unenv/node/readline/promises",
repl: "unenv/node/repl",
stream: "unenv/node/stream",
"stream/consumers": "unenv/node/stream/consumers",
"stream/promises": "unenv/node/stream/promises",
"stream/web": "unenv/node/stream/web",
string_decoder: "unenv/node/string_decoder",
sys: "unenv/node/util",
timers: "unenv/node/timers",
"timers/promises": "unenv/node/timers/promises",
tls: "unenv/node/tls",
trace_events: "unenv/node/trace_events",
tty: "unenv/node/tty",
url: "unenv/node/url",
util: "unenv/node/util",
"util/types": "unenv/node/util/types",
v8: "unenv/node/v8",
vm: "unenv/node/vm",
wasi: "unenv/node/wasi",
worker_threads: "unenv/node/worker_threads",
zlib: "unenv/node/zlib"
}, At = {
process: "unenv/node/process",
global: "unenv/polyfill/globalthis",
Buffer: ["node:buffer", "Buffer"],
clearImmediate: ["node:timers", "clearImmediate"],
setImmediate: ["node:timers", "setImmediate"]
}, bt = {
"cross-fetch": "unenv/npm/cross-fetch",
debug: "unenv/npm/debug",
fsevents: "unenv/npm/fsevents",
inherits: "unenv/npm/inherits",
"node-fetch": "unenv/npm/node-fetch",
"node-fetch-native": "unenv/npm/node-fetch",
"whatwg-url": "unenv/npm/whatwg-url",
"cross-fetch/polyfill": "unenv/mock/empty",
"node-fetch-native/polyfill": "unenv/mock/empty",
"isomorphic-fetch": "unenv/mock/empty"
}, Dt = (e = {}) => {
const t = [];
if (t.push(Lt(e)), e.presets && t.push(...e.presets), e.overrides && t.push(e.overrides), e.resolve)
for (const r of t)
r.meta?.url && ne(r, [r.meta.url], e);
const n = kt(...t);
return e.resolve && ne(n, t.map((r) => r.meta?.url).filter((r) => r !== void 0), e), {
env: n,
presets: t
};
};
function Lt(e) {
const t = {
meta: {
name: "unenv",
version: Nt,
url: import.meta.url
},
alias: {},
inject: {},
external: [],
polyfill: []
};
return e.nodeCompat !== !1 && (Object.assign(t.inject, At), Object.assign(t.alias, { ...Object.fromEntries(Object.entries(St).flatMap(([n, r]) => [[n, r], [`node:${n}`, r]])) })), e.npmShims && Object.assign(t.alias, bt), t;
}
function ne(e, t, n = {}) {
if (!n.resolve)
return;
const { resolveModulePath: r } = at({ from: [
...n.resolve === !0 ? [] : n.resolve.paths || [],
...t,
import.meta.url,
process.cwd() + "/"
] }), i = (o) => {
if (!o || (e.alias && (o = Tt(o, e.alias)), o.startsWith("node:")))
return o;
if (_e.includes(o))
return `node:${o}`;
let s = r(o, { try: !0 });
return !s && o.startsWith("unenv/") && (s = r(o.replace("unenv/", "unenv-nightly/"), { try: !0 })), s || o;
};
for (const o in e.alias)
e.alias[o] = i(e.alias[o]);
if (e.polyfill)
for (let o = 0; o < e.polyfill.length; o++)
e.polyfill[o] = i(e.polyfill[o]);
for (const o in e.inject) {
const s = e.inject[o];
if (Array.isArray(s)) {
const [l, ...f] = s;
e.inject[o] = [i(l), ...f];
} else
e.inject[o] = i(s);
}
return e;
}
function kt(...e) {
const t = {
alias: {},
inject: {},
polyfill: [],
external: []
};
for (const n of e) {
if (n.alias) {
const r = Object.keys(n.alias).sort((i, o) => o.split("/").length - i.split("/").length || o.length - i.length);
for (const i of r)
t.alias[i] = n.alias[i];
}
if (n.inject)
for (const [r, i] of Object.entries(n.inject))
Array.isArray(i) ? t.inject[r] = i : i === !1 ? delete t.inject[r] : t.inject[r] = i;
n.polyfill && t.polyfill.push(...n.polyfill.filter(Boolean)), n.external && t.external.push(...n.external);
}
return t.polyfill = re(t.polyfill), t.external = re(t.external), t;
}
function re(e) {
const t = new Set(e);
for (const n of e)
n.startsWith("!") && (t.delete(n), t.delete(n.slice(1)));
return [...t];
}
const oe = (e, t) => W(e) === W(t), R = (e, t) => e ? e === !0 ? !0 : e === t : !1, Wt = (e) => e.startsWith("node:"), W = (e) => e.replace(/^node:/, ""), T = [
{
code: "export { Buffer } from 'buffer'",
moduleId: "virtual:buffer",
moduleIdRegex: /^virtual:buffer$/,
moduleIdResolved: "\0virtual:buffer",
namespace: "virtual-buffer"
},
{
code: "export { default as process } from 'process'",
moduleId: "virtual:process",
moduleIdRegex: /^virtual:process$/,
moduleIdResolved: "\0virtual:process",
namespace: "virtual-process"
}
], Zt = (e = {}) => {
const t = {
import { createRequire as B } from "node:module";
import x from "@rollup/plugin-inject";
import j from "node-stdlib-browser";
import { handleCircularDependancyWarning as O } from "node-stdlib-browser/helpers/rollup/plugin";
import T from "node-stdlib-browser/helpers/esbuild/plugin";
const v = (s, l) => c(s) === c(l), o = (s, l) => s ? s === !0 ? !0 : s === l : !1, $ = (s) => s.startsWith("node:"), w = (s) => {
const l = s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return new RegExp(`^${l}$`);
}, c = (s) => s.replace(/^node:/, ""), g = {
buffer: [
"import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'",
"globalThis.Buffer = globalThis.Buffer || __buffer_polyfill"
],
global: [
"import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'",
"globalThis.global = globalThis.global || __global_polyfill"
],
process: [
"import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'",
"globalThis.process = globalThis.process || __process_polyfill"
]
}, D = (s = {}) => {
const l = {
include: [],

@@ -1354,3 +28,3 @@ exclude: [],

protocolImports: !0,
...e,
...s,
globals: {

@@ -1360,27 +34,36 @@ Buffer: !0,

process: !0,
...e.globals
...s.globals
}
}, { env: n, presets: r } = Dt({
nodeCompat: !0,
npmShims: !0,
resolve: !0
}), i = (s) => t.include.length > 0 ? !t.include.some((l) => oe(s, l)) : t.exclude.some((l) => oe(s, l)), o = (s) => {
if (R(t.globals.Buffer, "dev") && /^buffer$/.test(s))
}, h = (e) => l.include.length > 0 ? !l.include.some((r) => v(e, r)) : l.exclude.some((r) => v(e, r)), y = (e) => {
if (o(l.globals.Buffer, "dev") && /^buffer$/.test(e))
return "vite-plugin-node-polyfills/shims/buffer";
if (R(t.globals.global, "dev") && /^global$/.test(s))
if (o(l.globals.global, "dev") && /^global$/.test(e))
return "vite-plugin-node-polyfills/shims/global";
if (R(t.globals.process, "dev") && /^process$/.test(s))
if (o(l.globals.process, "dev") && /^process$/.test(e))
return "vite-plugin-node-polyfills/shims/process";
if (s in t.overrides)
return t.overrides[s];
};
return Object.entries(pe).reduce((s, [l, f]) => (!t.protocolImports && Wt(l) || i(l) || (s[l] = o(W(l)) || f), s), {}), [{
if (e in l.overrides)
return l.overrides[e];
}, p = Object.entries(j).reduce((e, [r, i]) => (!l.protocolImports && $(r) || h(r) || (e[r] = y(c(r)) || i), e), {}), f = B(import.meta.url), u = [
...o(l.globals.Buffer, "dev") ? [f.resolve("vite-plugin-node-polyfills/shims/buffer")] : [],
...o(l.globals.global, "dev") ? [f.resolve("vite-plugin-node-polyfills/shims/global")] : [],
...o(l.globals.process, "dev") ? [f.resolve("vite-plugin-node-polyfills/shims/process")] : []
], b = [
...o(l.globals.Buffer, "dev") ? g.buffer : [],
...o(l.globals.global, "dev") ? g.global : [],
...o(l.globals.process, "dev") ? g.process : [],
""
].join(`
`);
return {
name: "vite-plugin-node-polyfills",
config: (s, l) => {
l.command;
const f = {
config(e, r) {
const i = r.command === "serve", d = !!this?.meta?.rolldownVersion, m = {
...i && o(l.globals.Buffer, "dev") ? { Buffer: "Buffer" } : {},
...i && o(l.globals.global, "dev") ? { global: "global" } : {},
...i && o(l.globals.process, "dev") ? { process: "process" } : {}
}, a = {
// https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md#vite
...R(t.globals.Buffer, "build") ? { Buffer: "vite-plugin-node-polyfills/shims/buffer" } : {},
...R(t.globals.global, "build") ? { global: "vite-plugin-node-polyfills/shims/global" } : {},
...R(t.globals.process, "build") ? { process: "vite-plugin-node-polyfills/shims/process" } : {}
...o(l.globals.Buffer, "build") ? { Buffer: "vite-plugin-node-polyfills/shims/buffer" } : {},
...o(l.globals.global, "build") ? { global: "vite-plugin-node-polyfills/shims/global" } : {},
...o(l.globals.process, "build") ? { process: "vite-plugin-node-polyfills/shims/process" } : {}
};

@@ -1390,43 +73,62 @@ return {

rollupOptions: {
onwarn: (d, c) => {
ge(d, () => {
if (s.build?.rollupOptions?.onwarn)
return s.build.rollupOptions.onwarn(d, c);
c(d);
onwarn: (t, n) => {
O(t, () => {
if (e.build?.rollupOptions?.onwarn)
return e.build.rollupOptions.onwarn(t, n);
n(t);
});
},
plugins: Object.keys(f).length > 0 ? [G(n.inject)] : []
...Object.keys(a).length > 0 ? d ? { inject: a } : { plugins: [x(a)] } : {}
}
},
esbuild: {
// In dev, the global polyfills need to be injected as a banner in order for isolated scripts (such as Vue SFCs) to have access to them.
banner: i ? b : void 0
},
optimizeDeps: {
esbuildOptions: {
// https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md?plain=1#L203-L209
// define: {
// ...((isDev && isEnabled(optionsResolved.globals.Buffer, 'dev')) ? { Buffer: 'globalThis.Buffer' } : {}),
// ...((isDev && isEnabled(optionsResolved.globals.global, 'dev')) ? { global: 'globalThis' } : {}),
// ...((isDev && isEnabled(optionsResolved.globals.process, 'dev')) ? { process: 'globalThis.process' } : {}),
// },
inject: [
...T.map((d) => d.moduleId)
],
plugins: [
ve(n.alias),
// Supress the 'injected path "..." cannot be marked as external' error in Vite 4 (emitted by esbuild).
// https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1469
{
name: "vite-plugin-node-polyfills-shims-resolver",
async setup(d) {
for (const c of T)
d.onResolve({ filter: c.moduleIdRegex }, () => ({
// https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1468
external: !1,
namespace: c.namespace,
path: c.moduleId
})), d.onLoad({ filter: c.moduleIdRegex, namespace: c.namespace }, () => ({
contents: c.code,
loader: "js"
}));
exclude: [
...u
],
...d ? {
rollupOptions: {
define: m,
resolve: {
// https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md?plain=1#L150
alias: {
...p
}
}
]
},
plugins: [
{
name: "vite-plugin-node-polyfills:optimizer",
banner: i ? b : void 0
}
]
}
} : {
esbuildOptions: {
banner: i ? { js: b } : void 0,
define: m,
inject: [
...u
],
plugins: [
T(p),
// Supress the 'injected path "..." cannot be marked as external' error in Vite 4 (emitted by esbuild).
// https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1469
{
name: "vite-plugin-node-polyfills-shims-resolver",
setup(t) {
for (const n of u) {
const _ = w(n);
t.onResolve({ filter: _ }, () => ({
// https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1468
external: !1,
path: n
}));
}
}
}
]
}
}

@@ -1437,3 +139,3 @@ },

alias: {
...n.alias
...p
}

@@ -1443,21 +145,7 @@ }

}
}, {
name: "virtual-shims-resolver",
resolveId(s) {
for (const l of T)
if (s === l.moduleId)
return l.moduleIdResolved;
},
load(s) {
for (const l of T)
if (s === l.moduleIdResolved)
return {
code: l.code
};
}
}, G(n.inject)];
};
};
export {
Zt as nodePolyfills
D as nodePolyfills
};
//# sourceMappingURL=index.js.map
{
"name": "vite-plugin-node-polyfills",
"type": "module",
"version": "0.23.1",
"version": "0.24.0",
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",

@@ -88,3 +88,3 @@ "author": "David Myers <hello@davidmyers.dev>",

"vitest": "^1.2.2",
"vite-plugin-node-polyfills": "0.23.1"
"vite-plugin-node-polyfills": "0.24.0"
},

@@ -91,0 +91,0 @@ "publishConfig": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display