penambahan web socket

This commit is contained in:
2025-09-18 19:01:22 +07:00
parent 1d053646a9
commit d7bb2eb5bb
15070 changed files with 2402916 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
export declare const builtnNodeModules: string[];
export declare const hybridNodeModules: string[];
export declare const unsupportedNodeModules: string[];

View File

@@ -0,0 +1,81 @@
export const builtnNodeModules = [
"_stream_duplex",
"_stream_passthrough",
"_stream_readable",
"_stream_transform",
"_stream_writable",
"_tls_common",
"_tls_wrap",
// Missing exports: Server, createServer
"assert",
// Missing exports: CallTracker, partialDeepStrictEqual
"assert/strict",
// Missing exports: CallTracker, partialDeepStrictEqual
"async_hooks",
"buffer",
"constants",
// Missing exports: EXTENSIONLESS_FORMAT_JAVASCRIPT, EXTENSIONLESS_FORMAT_WASM, O_DIRECT, O_NOATIME, RTLD_DEEPBIND, SIGPOLL, SIGPWR, SIGSTKFLT, defaultCipherList
"crypto",
"diagnostics_channel",
"dns",
"dns/promises",
"events",
// Missing exports: captureRejections, init
"fs/promises",
"module",
"net",
"path",
"path/posix",
"path/win32",
"querystring",
"stream",
"stream/consumers",
"stream/promises",
"stream/web",
"string_decoder",
"timers",
"timers/promises",
"tls",
"url",
"util",
"util/types",
"zlib"
];
export const hybridNodeModules = [
"console",
"process"
// Missing exports: abort, allowedNodeEnvironmentFlags, arch, argv, argv0, assert, availableMemory, binding, chdir, config, constrainedMemory, cpuUsage, cwd, debugPort, dlopen, domain, emitWarning, execArgv, execPath, exitCode, finalization, getActiveResourcesInfo, getegid, geteuid, getgid, getgroups, getuid, hasUncaughtExceptionCaptureCallback, hrtime, initgroups, kill, loadEnvFile, memoryUsage, moduleLoadList, openStdin, pid, ppid, reallyExit, ref, release, report, resourceUsage, setSourceMapsEnabled, setUncaughtExceptionCaptureCallback, setegid, seteuid, setgid, setgroups, setuid, sourceMapsEnabled, stderr, stdin, stdout, title, umask, unref, uptime, version, versions
];
export const unsupportedNodeModules = [
"_http_agent",
"_http_client",
"_http_common",
"_http_incoming",
"_http_outgoing",
"_http_server",
"_stream_wrap",
"child_process",
"cluster",
"dgram",
"domain",
"fs",
"http",
"http2",
"https",
"inspector",
"inspector/promises",
"os",
"perf_hooks",
"punycode",
"readline",
"readline/promises",
"repl",
"sys",
"trace_events",
"tty",
"v8",
"vm",
"wasi",
"worker_threads",
"sqlite"
];

View File

@@ -0,0 +1,3 @@
export declare const builtnNodeModules: string[];
export declare const hybridNodeModules: never[];
export declare const unsupportedNodeModules: string[];

View File

@@ -0,0 +1,110 @@
export const builtnNodeModules = [
"_http_agent",
"_http_common",
// Missing exports: freeParser, isLenient, parsers, prepareError
"_http_outgoing",
"_http_server",
// Missing exports: Server, ServerResponse, httpServerPreClose, kConnectionsCheckingInterval, kServerResponse, setupConnectionsTracking, storeHTTPOptions
"_stream_duplex",
// Missing exports: from, fromWeb, toWeb
"_stream_passthrough",
"_stream_readable",
// Missing exports: ReadableState, from, fromWeb, toWeb, wrap
"_stream_transform",
"_stream_writable",
// Missing exports: WritableState, fromWeb, toWeb
"_tls_common",
// Missing exports: SecureContext, translatePeerCertificate
"_tls_wrap",
"assert",
// Missing exports: CallTracker, partialDeepStrictEqual
"assert/strict",
// Missing exports: CallTracker, partialDeepStrictEqual
"async_hooks",
"buffer",
// Missing exports: File, resolveObjectURL
"child_process",
"cluster",
"console",
// Missing exports: context, createTask
"constants",
// Missing exports: EXTENSIONLESS_FORMAT_JAVASCRIPT, EXTENSIONLESS_FORMAT_WASM, O_DIRECT, O_NOATIME, defaultCipherList
"crypto",
// Missing exports: Cipher, Decipher
"dgram",
"diagnostics_channel",
// Missing exports: Channel
"dns",
// Missing exports: getDefaultResultOrder, lookupService
"dns/promises",
// Missing exports: getDefaultResultOrder, lookupService
"domain",
"events",
// Missing exports: captureRejections, getMaxListeners, init, usingDomains
"fs",
// Missing exports: FileReadStream, FileWriteStream, fchmod, fchmodSync, fchown, fchownSync, glob, globSync, lchmod, lchmodSync, lchown, lchownSync, openAsBlob
"fs/promises",
// Missing exports: glob, lchmod, lchown, lutimes, statfs
"http",
// Missing exports: CloseEvent, MessageEvent, WebSocket, setMaxIdleHTTPParsers
"http2",
// Missing exports: performServerHandshake
"https",
"inspector",
"inspector/promises",
"module",
// Missing exports: SourceMap, constants, enableCompileCache, findPackageJSON, flushCompileCache, getCompileCacheDir, getSourceMapsSupport, runMain, setSourceMapsSupport, stripTypeScriptTypes, syncBuiltinESMExports
"net",
"os",
"path",
// Missing exports: matchesGlob
"path/posix",
// Missing exports: matchesGlob
"path/win32",
// Missing exports: matchesGlob
"perf_hooks",
// Missing exports: Performance, PerformanceMark, PerformanceMeasure, PerformanceObserverEntryList, PerformanceResourceTiming, createHistogram
"process",
// Missing exports: assert, availableMemory, binding, config, constrainedMemory, debugPort, domain, exitCode, features, finalization, getActiveResourcesInfo, getgroups, hasUncaughtExceptionCaptureCallback, initgroups, loadEnvFile, moduleLoadList, openStdin, ppid, reallyExit, ref, release, report, resourceUsage, setSourceMapsEnabled, setUncaughtExceptionCaptureCallback, setegid, seteuid, setgid, setgroups, setuid, sourceMapsEnabled, title, unref, uptime
"punycode",
"querystring",
"readline",
"readline/promises",
"repl",
// Missing exports: Recoverable, writer
"sqlite",
// Missing exports: StatementSync
"stream",
// Missing exports: destroy, promises
"stream/consumers",
"stream/promises",
"stream/web",
"string_decoder",
"sys",
// Missing exports: MIMEParams, MIMEType, getCallSite, getSystemErrorMap, getSystemErrorMessage, parseEnv, transferableAbortController, transferableAbortSignal
"timers",
// Missing exports: active, enroll, unenroll
"timers/promises",
"tls",
// Missing exports: SecureContext, convertALPNProtocols
"trace_events",
"tty",
"url",
"util",
// Missing exports: MIMEParams, MIMEType, getCallSite, getSystemErrorMap, getSystemErrorMessage, parseEnv, transferableAbortController, transferableAbortSignal
"util/types",
// Missing exports: isExternal
"v8",
// Missing exports: GCProfiler, promiseHooks, queryObjects, setHeapSnapshotNearHeapLimit, startupSnapshot
"vm",
"wasi",
"worker_threads",
// Missing exports: isInternalThread, isMarkedAsUntransferable, markAsUncloneable, postMessageToThread
"zlib"
];
export const hybridNodeModules = [];
export const unsupportedNodeModules = [
"_http_client",
"_http_incoming",
"_stream_wrap"
];

View File

@@ -0,0 +1,3 @@
export declare const builtnNodeModules: string[];
export declare const hybridNodeModules: never[];
export declare const unsupportedNodeModules: string[];

View File

@@ -0,0 +1,110 @@
export const builtnNodeModules = [
"_http_agent",
"_http_common",
// Missing exports: freeParser, isLenient, parsers, prepareError
"_http_outgoing",
"_http_server",
// Missing exports: Server, ServerResponse, httpServerPreClose, kConnectionsCheckingInterval, kServerResponse, setupConnectionsTracking, storeHTTPOptions
"_stream_duplex",
// Missing exports: from, fromWeb, toWeb
"_stream_passthrough",
"_stream_readable",
// Missing exports: ReadableState, from, fromWeb, toWeb, wrap
"_stream_transform",
"_stream_writable",
// Missing exports: WritableState, fromWeb, toWeb
"_tls_common",
// Missing exports: SecureContext, translatePeerCertificate
"_tls_wrap",
"assert",
// Missing exports: CallTracker, partialDeepStrictEqual
"assert/strict",
// Missing exports: CallTracker, partialDeepStrictEqual
"async_hooks",
"buffer",
// Missing exports: File, resolveObjectURL
"child_process",
"cluster",
"console",
// Missing exports: context, createTask
"constants",
// Missing exports: EXTENSIONLESS_FORMAT_JAVASCRIPT, EXTENSIONLESS_FORMAT_WASM, O_DIRECT, O_NOATIME, defaultCipherList
"crypto",
// Missing exports: Cipher, Decipher
"dgram",
"diagnostics_channel",
// Missing exports: Channel
"dns",
// Missing exports: getDefaultResultOrder, lookupService
"dns/promises",
// Missing exports: getDefaultResultOrder, lookupService
"domain",
"events",
// Missing exports: captureRejections, getMaxListeners, init, usingDomains
"fs",
// Missing exports: FileReadStream, FileWriteStream, fchmod, fchmodSync, fchown, fchownSync, glob, globSync, lchmod, lchmodSync, lchown, lchownSync, openAsBlob
"fs/promises",
// Missing exports: glob, lchmod, lchown, lutimes, statfs
"http",
// Missing exports: CloseEvent, MessageEvent, WebSocket, setMaxIdleHTTPParsers
"http2",
// Missing exports: performServerHandshake
"https",
"inspector",
"inspector/promises",
"module",
// Missing exports: SourceMap, constants, enableCompileCache, findPackageJSON, flushCompileCache, getCompileCacheDir, getSourceMapsSupport, runMain, setSourceMapsSupport, stripTypeScriptTypes, syncBuiltinESMExports
"net",
"os",
"path",
// Missing exports: matchesGlob
"path/posix",
// Missing exports: matchesGlob
"path/win32",
// Missing exports: matchesGlob
"perf_hooks",
// Missing exports: Performance, PerformanceMark, PerformanceMeasure, PerformanceObserverEntryList, PerformanceResourceTiming, createHistogram
"process",
// Missing exports: assert, availableMemory, binding, config, constrainedMemory, debugPort, domain, exitCode, features, finalization, getActiveResourcesInfo, getgroups, hasUncaughtExceptionCaptureCallback, initgroups, loadEnvFile, moduleLoadList, openStdin, ppid, reallyExit, ref, release, report, resourceUsage, setSourceMapsEnabled, setUncaughtExceptionCaptureCallback, setegid, seteuid, setgid, setgroups, setuid, sourceMapsEnabled, title, unref, uptime
"punycode",
"querystring",
"readline",
"readline/promises",
"repl",
// Missing exports: Recoverable, writer
"sqlite",
// Missing exports: StatementSync
"stream",
// Missing exports: destroy, promises
"stream/consumers",
"stream/promises",
"stream/web",
"string_decoder",
"sys",
// Missing exports: MIMEParams, MIMEType, getCallSite, getSystemErrorMap, getSystemErrorMessage, parseEnv, transferableAbortController, transferableAbortSignal
"timers",
// Missing exports: active, enroll, unenroll
"timers/promises",
"tls",
// Missing exports: SecureContext, convertALPNProtocols
"trace_events",
"tty",
"url",
"util",
// Missing exports: MIMEParams, MIMEType, getCallSite, getSystemErrorMap, getSystemErrorMessage, parseEnv, transferableAbortController, transferableAbortSignal
"util/types",
// Missing exports: isExternal
"v8",
// Missing exports: GCProfiler, promiseHooks, queryObjects, setHeapSnapshotNearHeapLimit, startupSnapshot
"vm",
"wasi",
"worker_threads",
// Missing exports: isInternalThread, isMarkedAsUntransferable, markAsUncloneable, postMessageToThread
"zlib"
];
export const hybridNodeModules = [];
export const unsupportedNodeModules = [
"_http_client",
"_http_incoming",
"_stream_wrap"
];

View File

@@ -0,0 +1,3 @@
export declare const builtnNodeModules: string[];
export declare const hybridNodeModules: never[];
export declare const unsupportedNodeModules: string[];

View File

@@ -0,0 +1,77 @@
export const builtnNodeModules = [
"assert",
// Missing exports: CallTracker, partialDeepStrictEqual
"async_hooks",
// Missing exports: asyncWrapProviders, createHook, executionAsyncId, executionAsyncResource, triggerAsyncId
"buffer",
"events",
"util"
// Missing exports: getCallSites, getSystemErrorMap, getSystemErrorMessage, getSystemErrorName, isBoolean, isBuffer, isDate, isError, isFunction, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, parseEnv, styleText
];
export const hybridNodeModules = [];
export const unsupportedNodeModules = [
"_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/strict",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"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/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
"sqlite"
];

View File

@@ -0,0 +1,2 @@
import type { Preset } from "unenv";
export declare const unenvDenoPreset: Preset;

View File

@@ -0,0 +1,20 @@
import { builtnNodeModules } from "./node-compat/deno.mjs";
export const unenvDenoPreset = {
meta: {
name: "nitro-deno",
url: import.meta.url
},
external: builtnNodeModules.map((m) => `node:${m}`),
alias: {
// (native)
...Object.fromEntries(
[...builtnNodeModules, "sys"].flatMap((m) => [
[m, `node:${m}`],
[`node:${m}`, `node:${m}`]
])
)
},
inject: {
performance: false
}
};

View File

@@ -0,0 +1,5 @@
import type { Preset } from "unenv";
import type { Plugin } from "rollup";
export declare const unenvCfExternals: Preset;
export declare const unenvWorkerdWithNodeCompat: Preset;
export declare const workerdHybridNodeCompatPlugin: Plugin;

View File

@@ -0,0 +1,61 @@
import { fileURLToPath } from "mlly";
import { join } from "pathe";
import { builtnNodeModules, hybridNodeModules } from "./node-compat/cloudflare.mjs";
const workerdDir = fileURLToPath(new URL("workerd/", import.meta.url));
const resolvePresetRuntime = (m) => join(workerdDir, `${m}.mjs`);
export const unenvCfExternals = {
meta: {
name: "nitro-cloudflare:externals",
url: import.meta.url
},
external: [
"cloudflare:email",
"cloudflare:sockets",
"cloudflare:workers",
"cloudflare:workflows"
]
};
export const unenvWorkerdWithNodeCompat = {
meta: {
name: "nitro-cloudflare:node-compat",
url: import.meta.url
},
external: builtnNodeModules.map((m) => `node:${m}`),
alias: {
// (native)
...Object.fromEntries(
builtnNodeModules.flatMap((m) => [
[m, `node:${m}`],
[`node:${m}`, `node:${m}`]
])
),
// (hybrid)
...Object.fromEntries(
hybridNodeModules.flatMap((m) => {
const resolved = resolvePresetRuntime(m);
return [
[`node:${m}`, resolved],
[m, resolved]
];
})
)
}
};
export const workerdHybridNodeCompatPlugin = {
name: "nitro:cloudflare:hybrid-node-compat",
resolveId(id) {
if (id.startsWith("cloudflare:")) {
return { id, external: true, moduleSideEffects: false };
}
if (id.startsWith("#workerd/node:")) {
return {
id: id.slice("#workerd/".length),
external: true,
moduleSideEffects: false
};
}
if (id.startsWith(workerdDir)) {
return { id, moduleSideEffects: false };
}
}
};

View File

@@ -0,0 +1,26 @@
export const assert: any;
export const clear: any;
export const context: any;
export const count: any;
export const countReset: any;
export const createTask: any;
export const debug: any;
export const dir: any;
export const dirxml: any;
export const error: any;
export const group: any;
export const groupCollapsed: any;
export const groupEnd: any;
export const info: any;
export const log: any;
export const profile: any;
export const profileEnd: any;
export const table: any;
export const time: any;
export const timeEnd: any;
export const timeLog: any;
export const timeStamp: any;
export const trace: any;
export const warn: any;
export default consoleModule;
declare const consoleModule: any;

View File

@@ -0,0 +1,69 @@
import workerdConsole from "#workerd/node:console";
import {
Console,
_ignoreErrors,
_stderr,
_stderrErrorHandler,
_stdout,
_stdoutErrorHandler,
_times,
} from "unenv/node/console";
export {
Console,
_ignoreErrors,
_stderr,
_stderrErrorHandler,
_stdout,
_stdoutErrorHandler,
_times,
} from "unenv/node/console";
export const {
assert,
clear,
context,
count,
countReset,
createTask,
debug,
dir,
dirxml,
error,
group,
groupCollapsed,
groupEnd,
info,
log,
profile,
profileEnd,
table,
time,
timeEnd,
timeLog,
timeStamp,
trace,
warn,
} = workerdConsole;
const consolePolyfill = {
Console,
_ignoreErrors,
_stderr,
_stderrErrorHandler,
_stdout,
_stdoutErrorHandler,
_times,
};
const consoleModule = /*@__PURE__*/ new Proxy(workerdConsole, {
get(target, prop) {
if (Reflect.has(target, prop)) {
return Reflect.get(target, prop);
}
return Reflect.get(consolePolyfill, prop);
},
});
export default consoleModule;

View File

@@ -0,0 +1,107 @@
export default mixedProcess;
export const abort: any;
export const addListener: any;
export const allowedNodeEnvironmentFlags: any;
export const hasUncaughtExceptionCaptureCallback: any;
export const setUncaughtExceptionCaptureCallback: any;
export const loadEnvFile: any;
export const sourceMapsEnabled: any;
export const arch: any;
export const argv: any;
export const argv0: any;
export const chdir: any;
export const config: any;
export const connected: any;
export const constrainedMemory: any;
export const availableMemory: any;
export const cpuUsage: any;
export const cwd: any;
export const debugPort: any;
export const dlopen: any;
export const disconnect: any;
export const emit: any;
export const emitWarning: any;
export const env: any;
export const eventNames: any;
export const execArgv: any;
export const execPath: any;
export const exit: any;
export const finalization: any;
export const features: any;
export const getBuiltinModule: any;
export const getActiveResourcesInfo: any;
export const getMaxListeners: any;
export const hrtime: any;
export const kill: any;
export const listeners: any;
export const listenerCount: any;
export const memoryUsage: any;
export const nextTick: any;
export const on: any;
export const off: any;
export const once: any;
export const pid: any;
export const platform: any;
export const ppid: any;
export const prependListener: any;
export const prependOnceListener: any;
export const rawListeners: any;
export const release: any;
export const removeAllListeners: any;
export const removeListener: any;
export const report: any;
export const resourceUsage: any;
export const setMaxListeners: any;
export const setSourceMapsEnabled: any;
export const stderr: any;
export const stdin: any;
export const stdout: any;
export const title: any;
export const umask: any;
export const uptime: any;
export const version: any;
export const versions: any;
export const domain: any;
export const initgroups: any;
export const moduleLoadList: any;
export const reallyExit: any;
export const openStdin: any;
export const assert: any;
export const binding: any;
export const send: any;
export const exitCode: any;
export const channel: any;
export const getegid: any;
export const geteuid: any;
export const getgid: any;
export const getgroups: any;
export const getuid: any;
export const setegid: any;
export const seteuid: any;
export const setgid: any;
export const setgroups: any;
export const setuid: any;
export const permission: any;
export const mainModule: any;
export const _events: any;
export const _eventsCount: any;
export const _exiting: any;
export const _maxListeners: any;
export const _debugEnd: any;
export const _debugProcess: any;
export const _fatalException: any;
export const _getActiveHandles: any;
export const _getActiveRequests: any;
export const _kill: any;
export const _preload_modules: any;
export const _rawDebug: any;
export const _startProfilerIdleNotifier: any;
export const _stopProfilerIdleNotifier: any;
export const _tickCallback: any;
export const _disconnect: any;
export const _handleQueue: any;
export const _pendingMessage: any;
export const _channel: any;
export const _send: any;
export const _linkedBinding: any;
declare const mixedProcess: any;

View File

@@ -0,0 +1,144 @@
// https://github.com/cloudflare/workerd/blob/main/src/node/internal/process.ts
// https://github.com/unjs/unenv/blob/main/src/runtime/node/process.ts
import workerdProcess from "#workerd/node:process";
import { env as WorkerEnv } from "cloudflare:workers";
import { Process as UnenvProcess } from "unenv/node/internal/process/process";
import { env as UnenvEnv } from "unenv/node/internal/process/env";
import { hrtime as UnenvHrTime } from "unenv/node/internal/process/hrtime";
// Polyfill for unenv (without Node.js compatibility)
globalThis.__env__ = WorkerEnv;
const mixedProcess = new UnenvProcess({
env: UnenvEnv,
hrtime: UnenvHrTime,
nextTick: workerdProcess.nextTick,
});
// https://github.com/cloudflare/workerd/blob/main/src/node/internal/process.ts#L94
for (const key of ["exit", "getBuiltinModule", "platform"]) {
if (key in workerdProcess) {
mixedProcess[key] = workerdProcess[key];
}
}
if (workerdProcess.features) {
Object.defineProperty(mixedProcess, "features", {
get() {
return workerdProcess.features;
},
});
}
export default mixedProcess;
export const {
abort,
addListener,
allowedNodeEnvironmentFlags,
hasUncaughtExceptionCaptureCallback,
setUncaughtExceptionCaptureCallback,
loadEnvFile,
sourceMapsEnabled,
arch,
argv,
argv0,
chdir,
config,
connected,
constrainedMemory,
availableMemory,
cpuUsage,
cwd,
debugPort,
dlopen,
disconnect,
emit,
emitWarning,
env,
eventNames,
execArgv,
execPath,
exit,
finalization,
features,
getBuiltinModule,
getActiveResourcesInfo,
getMaxListeners,
hrtime,
kill,
listeners,
listenerCount,
memoryUsage,
nextTick,
on,
off,
once,
pid,
platform,
ppid,
prependListener,
prependOnceListener,
rawListeners,
release,
removeAllListeners,
removeListener,
report,
resourceUsage,
setMaxListeners,
setSourceMapsEnabled,
stderr,
stdin,
stdout,
title,
umask,
uptime,
version,
versions,
domain,
initgroups,
moduleLoadList,
reallyExit,
openStdin,
assert,
binding,
send,
exitCode,
channel,
getegid,
geteuid,
getgid,
getgroups,
getuid,
setegid,
seteuid,
setgid,
setgroups,
setuid,
permission,
mainModule,
_events,
_eventsCount,
_exiting,
_maxListeners,
_debugEnd,
_debugProcess,
_fatalException,
_getActiveHandles,
_getActiveRequests,
_kill,
_preload_modules,
_rawDebug,
_startProfilerIdleNotifier,
_stopProfilerIdleNotifier,
_tickCallback,
_disconnect,
_handleQueue,
_pendingMessage,
_channel,
_send,
_linkedBinding,
} = mixedProcess;