@scelar/nodepod 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +43 -0
- package/README.md +240 -0
- package/dist/child_process-BJOMsZje.js +8233 -0
- package/dist/child_process-BJOMsZje.js.map +1 -0
- package/dist/child_process-Cj8vOcuc.cjs +7434 -0
- package/dist/child_process-Cj8vOcuc.cjs.map +1 -0
- package/dist/index-Cb1Cgdnd.js +35308 -0
- package/dist/index-Cb1Cgdnd.js.map +1 -0
- package/dist/index-DsMGS-xc.cjs +37195 -0
- package/dist/index-DsMGS-xc.cjs.map +1 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +59 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +95 -0
- package/src/__tests__/smoke.test.ts +11 -0
- package/src/constants/cdn-urls.ts +18 -0
- package/src/constants/config.ts +236 -0
- package/src/cross-origin.ts +26 -0
- package/src/engine-factory.ts +176 -0
- package/src/engine-types.ts +56 -0
- package/src/helpers/byte-encoding.ts +39 -0
- package/src/helpers/digest.ts +9 -0
- package/src/helpers/event-loop.ts +96 -0
- package/src/helpers/wasm-cache.ts +133 -0
- package/src/iframe-sandbox.ts +141 -0
- package/src/index.ts +192 -0
- package/src/isolation-helpers.ts +148 -0
- package/src/memory-volume.ts +941 -0
- package/src/module-transformer.ts +368 -0
- package/src/packages/archive-extractor.ts +248 -0
- package/src/packages/browser-bundler.ts +284 -0
- package/src/packages/installer.ts +396 -0
- package/src/packages/registry-client.ts +131 -0
- package/src/packages/version-resolver.ts +411 -0
- package/src/polyfills/assert.ts +384 -0
- package/src/polyfills/async_hooks.ts +144 -0
- package/src/polyfills/buffer.ts +628 -0
- package/src/polyfills/child_process.ts +2288 -0
- package/src/polyfills/chokidar.ts +336 -0
- package/src/polyfills/cluster.ts +106 -0
- package/src/polyfills/console.ts +136 -0
- package/src/polyfills/constants.ts +123 -0
- package/src/polyfills/crypto.ts +885 -0
- package/src/polyfills/dgram.ts +87 -0
- package/src/polyfills/diagnostics_channel.ts +76 -0
- package/src/polyfills/dns.ts +134 -0
- package/src/polyfills/domain.ts +68 -0
- package/src/polyfills/esbuild.ts +854 -0
- package/src/polyfills/events.ts +276 -0
- package/src/polyfills/fs.ts +2888 -0
- package/src/polyfills/fsevents.ts +79 -0
- package/src/polyfills/http.ts +1449 -0
- package/src/polyfills/http2.ts +199 -0
- package/src/polyfills/https.ts +76 -0
- package/src/polyfills/inspector.ts +62 -0
- package/src/polyfills/lightningcss.ts +105 -0
- package/src/polyfills/module.ts +191 -0
- package/src/polyfills/net.ts +353 -0
- package/src/polyfills/os.ts +238 -0
- package/src/polyfills/path.ts +206 -0
- package/src/polyfills/perf_hooks.ts +102 -0
- package/src/polyfills/process.ts +690 -0
- package/src/polyfills/punycode.ts +159 -0
- package/src/polyfills/querystring.ts +93 -0
- package/src/polyfills/quic.ts +118 -0
- package/src/polyfills/readdirp.ts +229 -0
- package/src/polyfills/readline.ts +692 -0
- package/src/polyfills/repl.ts +134 -0
- package/src/polyfills/rollup.ts +119 -0
- package/src/polyfills/sea.ts +33 -0
- package/src/polyfills/sqlite.ts +78 -0
- package/src/polyfills/stream.ts +1620 -0
- package/src/polyfills/string_decoder.ts +25 -0
- package/src/polyfills/tailwindcss-oxide.ts +309 -0
- package/src/polyfills/test.ts +197 -0
- package/src/polyfills/timers.ts +32 -0
- package/src/polyfills/tls.ts +105 -0
- package/src/polyfills/trace_events.ts +50 -0
- package/src/polyfills/tty.ts +71 -0
- package/src/polyfills/url.ts +174 -0
- package/src/polyfills/util.ts +559 -0
- package/src/polyfills/v8.ts +126 -0
- package/src/polyfills/vm.ts +132 -0
- package/src/polyfills/volume-registry.ts +15 -0
- package/src/polyfills/wasi.ts +44 -0
- package/src/polyfills/worker_threads.ts +326 -0
- package/src/polyfills/ws.ts +595 -0
- package/src/polyfills/zlib.ts +881 -0
- package/src/request-proxy.ts +716 -0
- package/src/script-engine.ts +3375 -0
- package/src/sdk/nodepod-fs.ts +93 -0
- package/src/sdk/nodepod-process.ts +86 -0
- package/src/sdk/nodepod-terminal.ts +350 -0
- package/src/sdk/nodepod.ts +509 -0
- package/src/sdk/types.ts +70 -0
- package/src/shell/commands/bun.ts +121 -0
- package/src/shell/commands/directory.ts +297 -0
- package/src/shell/commands/file-ops.ts +525 -0
- package/src/shell/commands/git.ts +2142 -0
- package/src/shell/commands/node.ts +80 -0
- package/src/shell/commands/npm.ts +198 -0
- package/src/shell/commands/pm-types.ts +45 -0
- package/src/shell/commands/pnpm.ts +82 -0
- package/src/shell/commands/search.ts +264 -0
- package/src/shell/commands/shell-env.ts +352 -0
- package/src/shell/commands/text-processing.ts +1152 -0
- package/src/shell/commands/yarn.ts +84 -0
- package/src/shell/shell-builtins.ts +19 -0
- package/src/shell/shell-helpers.ts +250 -0
- package/src/shell/shell-interpreter.ts +514 -0
- package/src/shell/shell-parser.ts +429 -0
- package/src/shell/shell-types.ts +85 -0
- package/src/syntax-transforms.ts +561 -0
- package/src/threading/engine-worker.ts +64 -0
- package/src/threading/inline-worker.ts +372 -0
- package/src/threading/offload-types.ts +112 -0
- package/src/threading/offload-worker.ts +383 -0
- package/src/threading/offload.ts +271 -0
- package/src/threading/process-context.ts +92 -0
- package/src/threading/process-handle.ts +275 -0
- package/src/threading/process-manager.ts +956 -0
- package/src/threading/process-worker-entry.ts +854 -0
- package/src/threading/shared-vfs.ts +352 -0
- package/src/threading/sync-channel.ts +135 -0
- package/src/threading/task-queue.ts +177 -0
- package/src/threading/vfs-bridge.ts +231 -0
- package/src/threading/worker-pool.ts +233 -0
- package/src/threading/worker-protocol.ts +358 -0
- package/src/threading/worker-vfs.ts +218 -0
- package/src/types/externals.d.ts +38 -0
- package/src/types/fs-streams.ts +142 -0
- package/src/types/manifest.ts +17 -0
- package/src/worker-sandbox.ts +90 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// stub - not available in browser
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from "./events";
|
|
5
|
+
|
|
6
|
+
/* ------------------------------------------------------------------ */
|
|
7
|
+
/* Sessions */
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
|
|
10
|
+
export interface Http2Session extends EventEmitter {
|
|
11
|
+
close(done?: () => void): void;
|
|
12
|
+
destroy(_err?: Error, _code?: number): void;
|
|
13
|
+
readonly destroyed: boolean;
|
|
14
|
+
readonly encrypted: boolean;
|
|
15
|
+
readonly closed: boolean;
|
|
16
|
+
ping(_cb: (err: Error | null, dur: number, buf: Uint8Array) => void): boolean;
|
|
17
|
+
ref(): void;
|
|
18
|
+
unref(): void;
|
|
19
|
+
setTimeout(_ms: number, _cb?: () => void): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Http2Session = function Http2Session(this: any) {
|
|
23
|
+
if (!this) return;
|
|
24
|
+
EventEmitter.call(this);
|
|
25
|
+
} as unknown as { new(): Http2Session; prototype: any };
|
|
26
|
+
|
|
27
|
+
Object.setPrototypeOf(Http2Session.prototype, EventEmitter.prototype);
|
|
28
|
+
|
|
29
|
+
Http2Session.prototype.close = function close(done?: () => void): void {
|
|
30
|
+
if (done) setTimeout(done, 0);
|
|
31
|
+
};
|
|
32
|
+
Http2Session.prototype.destroy = function destroy(_err?: Error, _code?: number): void {};
|
|
33
|
+
Object.defineProperty(Http2Session.prototype, 'destroyed', { get() { return false; }, configurable: true });
|
|
34
|
+
Object.defineProperty(Http2Session.prototype, 'encrypted', { get() { return false; }, configurable: true });
|
|
35
|
+
Object.defineProperty(Http2Session.prototype, 'closed', { get() { return false; }, configurable: true });
|
|
36
|
+
Http2Session.prototype.ping = function ping(
|
|
37
|
+
_cb: (err: Error | null, dur: number, buf: Uint8Array) => void,
|
|
38
|
+
): boolean { return false; };
|
|
39
|
+
Http2Session.prototype.ref = function ref(): void {};
|
|
40
|
+
Http2Session.prototype.unref = function unref(): void {};
|
|
41
|
+
Http2Session.prototype.setTimeout = function setTimeout(_ms: number, _cb?: () => void): void {};
|
|
42
|
+
|
|
43
|
+
export interface ClientHttp2Session extends Http2Session {}
|
|
44
|
+
|
|
45
|
+
export const ClientHttp2Session = function ClientHttp2Session(this: any) {
|
|
46
|
+
if (!this) return;
|
|
47
|
+
(Http2Session as any).call(this);
|
|
48
|
+
} as unknown as { new(): ClientHttp2Session; prototype: any };
|
|
49
|
+
|
|
50
|
+
Object.setPrototypeOf(ClientHttp2Session.prototype, Http2Session.prototype);
|
|
51
|
+
|
|
52
|
+
export interface ServerHttp2Session extends Http2Session {}
|
|
53
|
+
|
|
54
|
+
export const ServerHttp2Session = function ServerHttp2Session(this: any) {
|
|
55
|
+
if (!this) return;
|
|
56
|
+
(Http2Session as any).call(this);
|
|
57
|
+
} as unknown as { new(): ServerHttp2Session; prototype: any };
|
|
58
|
+
|
|
59
|
+
Object.setPrototypeOf(ServerHttp2Session.prototype, Http2Session.prototype);
|
|
60
|
+
|
|
61
|
+
/* ------------------------------------------------------------------ */
|
|
62
|
+
/* Streams */
|
|
63
|
+
/* ------------------------------------------------------------------ */
|
|
64
|
+
|
|
65
|
+
export interface Http2Stream extends EventEmitter {
|
|
66
|
+
close(_code?: number, _cb?: () => void): void;
|
|
67
|
+
readonly id: number;
|
|
68
|
+
readonly pending: boolean;
|
|
69
|
+
readonly destroyed: boolean;
|
|
70
|
+
readonly closed: boolean;
|
|
71
|
+
priority(_opts: unknown): void;
|
|
72
|
+
setTimeout(_ms: number, _cb?: () => void): void;
|
|
73
|
+
end(_data?: unknown, _enc?: string, _cb?: () => void): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const Http2Stream = function Http2Stream(this: any) {
|
|
77
|
+
if (!this) return;
|
|
78
|
+
EventEmitter.call(this);
|
|
79
|
+
} as unknown as { new(): Http2Stream; prototype: any };
|
|
80
|
+
|
|
81
|
+
Object.setPrototypeOf(Http2Stream.prototype, EventEmitter.prototype);
|
|
82
|
+
|
|
83
|
+
Http2Stream.prototype.close = function close(_code?: number, _cb?: () => void): void {};
|
|
84
|
+
Object.defineProperty(Http2Stream.prototype, 'id', { get() { return 0; }, configurable: true });
|
|
85
|
+
Object.defineProperty(Http2Stream.prototype, 'pending', { get() { return false; }, configurable: true });
|
|
86
|
+
Object.defineProperty(Http2Stream.prototype, 'destroyed', { get() { return false; }, configurable: true });
|
|
87
|
+
Object.defineProperty(Http2Stream.prototype, 'closed', { get() { return false; }, configurable: true });
|
|
88
|
+
Http2Stream.prototype.priority = function priority(_opts: unknown): void {};
|
|
89
|
+
Http2Stream.prototype.setTimeout = function setTimeout(_ms: number, _cb?: () => void): void {};
|
|
90
|
+
Http2Stream.prototype.end = function end(_data?: unknown, _enc?: string, _cb?: () => void): void {};
|
|
91
|
+
|
|
92
|
+
/* ------------------------------------------------------------------ */
|
|
93
|
+
/* Request / Response */
|
|
94
|
+
/* ------------------------------------------------------------------ */
|
|
95
|
+
|
|
96
|
+
export interface Http2ServerRequest extends EventEmitter {}
|
|
97
|
+
|
|
98
|
+
export const Http2ServerRequest = function Http2ServerRequest(this: any) {
|
|
99
|
+
if (!this) return;
|
|
100
|
+
EventEmitter.call(this);
|
|
101
|
+
} as unknown as { new(): Http2ServerRequest; prototype: any };
|
|
102
|
+
|
|
103
|
+
Object.setPrototypeOf(Http2ServerRequest.prototype, EventEmitter.prototype);
|
|
104
|
+
|
|
105
|
+
export interface Http2ServerResponse extends EventEmitter {
|
|
106
|
+
writeHead(_code: number, _hdrs?: object): this;
|
|
107
|
+
end(_data?: unknown): void;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const Http2ServerResponse = function Http2ServerResponse(this: any) {
|
|
111
|
+
if (!this) return;
|
|
112
|
+
EventEmitter.call(this);
|
|
113
|
+
} as unknown as { new(): Http2ServerResponse; prototype: any };
|
|
114
|
+
|
|
115
|
+
Object.setPrototypeOf(Http2ServerResponse.prototype, EventEmitter.prototype);
|
|
116
|
+
|
|
117
|
+
Http2ServerResponse.prototype.writeHead = function writeHead(_code: number, _hdrs?: object) { return this; };
|
|
118
|
+
Http2ServerResponse.prototype.end = function end(_data?: unknown): void {};
|
|
119
|
+
|
|
120
|
+
/* ------------------------------------------------------------------ */
|
|
121
|
+
/* Factories */
|
|
122
|
+
/* ------------------------------------------------------------------ */
|
|
123
|
+
|
|
124
|
+
export function createServer(
|
|
125
|
+
_opts?: unknown,
|
|
126
|
+
_handler?: unknown,
|
|
127
|
+
): EventEmitter {
|
|
128
|
+
return new EventEmitter();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function createSecureServer(
|
|
132
|
+
_opts?: unknown,
|
|
133
|
+
_handler?: unknown,
|
|
134
|
+
): EventEmitter {
|
|
135
|
+
return new EventEmitter();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function connect(
|
|
139
|
+
_authority: string,
|
|
140
|
+
_opts?: unknown,
|
|
141
|
+
_cb?: () => void,
|
|
142
|
+
): ClientHttp2Session {
|
|
143
|
+
return new ClientHttp2Session();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* ------------------------------------------------------------------ */
|
|
147
|
+
/* Constants */
|
|
148
|
+
/* ------------------------------------------------------------------ */
|
|
149
|
+
|
|
150
|
+
export const constants = {
|
|
151
|
+
NGHTTP2_SESSION_SERVER: 0,
|
|
152
|
+
NGHTTP2_SESSION_CLIENT: 1,
|
|
153
|
+
HTTP2_HEADER_STATUS: ":status",
|
|
154
|
+
HTTP2_HEADER_METHOD: ":method",
|
|
155
|
+
HTTP2_HEADER_AUTHORITY: ":authority",
|
|
156
|
+
HTTP2_HEADER_SCHEME: ":scheme",
|
|
157
|
+
HTTP2_HEADER_PATH: ":path",
|
|
158
|
+
HTTP_STATUS_OK: 200,
|
|
159
|
+
HTTP_STATUS_NOT_FOUND: 404,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/* ------------------------------------------------------------------ */
|
|
163
|
+
/* Settings helpers */
|
|
164
|
+
/* ------------------------------------------------------------------ */
|
|
165
|
+
|
|
166
|
+
export function getDefaultSettings(): object {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function getPackedSettings(_settings?: object): Uint8Array {
|
|
171
|
+
return new Uint8Array(0);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function getUnpackedSettings(_buf: Uint8Array): object {
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export const sensitiveHeaders = Symbol("sensitiveHeaders");
|
|
179
|
+
|
|
180
|
+
/* ------------------------------------------------------------------ */
|
|
181
|
+
/* Default export */
|
|
182
|
+
/* ------------------------------------------------------------------ */
|
|
183
|
+
|
|
184
|
+
export default {
|
|
185
|
+
Http2Session,
|
|
186
|
+
ClientHttp2Session,
|
|
187
|
+
ServerHttp2Session,
|
|
188
|
+
Http2Stream,
|
|
189
|
+
Http2ServerRequest,
|
|
190
|
+
Http2ServerResponse,
|
|
191
|
+
createServer,
|
|
192
|
+
createSecureServer,
|
|
193
|
+
connect,
|
|
194
|
+
constants,
|
|
195
|
+
getDefaultSettings,
|
|
196
|
+
getPackedSettings,
|
|
197
|
+
getUnpackedSettings,
|
|
198
|
+
sensitiveHeaders,
|
|
199
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Thin facade over http that forces https protocol on client requests
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Server,
|
|
6
|
+
IncomingMessage,
|
|
7
|
+
ServerResponse,
|
|
8
|
+
ClientRequest,
|
|
9
|
+
createServer,
|
|
10
|
+
STATUS_CODES,
|
|
11
|
+
METHODS,
|
|
12
|
+
getServer,
|
|
13
|
+
getAllServers,
|
|
14
|
+
setServerListenCallback,
|
|
15
|
+
setServerCloseCallback,
|
|
16
|
+
_buildClientRequest,
|
|
17
|
+
Agent,
|
|
18
|
+
globalAgent,
|
|
19
|
+
} from './http';
|
|
20
|
+
|
|
21
|
+
import type { ConnectionOptions, AgentConfig } from './http';
|
|
22
|
+
|
|
23
|
+
// Re-export all shared types and classes under HTTPS naming
|
|
24
|
+
export {
|
|
25
|
+
Server,
|
|
26
|
+
IncomingMessage,
|
|
27
|
+
ServerResponse,
|
|
28
|
+
ClientRequest,
|
|
29
|
+
createServer,
|
|
30
|
+
STATUS_CODES,
|
|
31
|
+
METHODS,
|
|
32
|
+
getServer,
|
|
33
|
+
getAllServers,
|
|
34
|
+
setServerListenCallback,
|
|
35
|
+
setServerCloseCallback,
|
|
36
|
+
Agent,
|
|
37
|
+
globalAgent,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type { ConnectionOptions, AgentConfig };
|
|
41
|
+
|
|
42
|
+
export function request(
|
|
43
|
+
target: string | URL | ConnectionOptions,
|
|
44
|
+
optsOrCb?: ConnectionOptions | ((res: IncomingMessage) => void),
|
|
45
|
+
cb?: (res: IncomingMessage) => void
|
|
46
|
+
): ClientRequest {
|
|
47
|
+
return _buildClientRequest(target, optsOrCb, cb, 'https');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function get(
|
|
51
|
+
target: string | URL | ConnectionOptions,
|
|
52
|
+
optsOrCb?: ConnectionOptions | ((res: IncomingMessage) => void),
|
|
53
|
+
cb?: (res: IncomingMessage) => void
|
|
54
|
+
): ClientRequest {
|
|
55
|
+
const cr = _buildClientRequest(target, optsOrCb, cb, 'https');
|
|
56
|
+
cr.end();
|
|
57
|
+
return cr;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
Server,
|
|
62
|
+
IncomingMessage,
|
|
63
|
+
ServerResponse,
|
|
64
|
+
ClientRequest,
|
|
65
|
+
createServer,
|
|
66
|
+
request,
|
|
67
|
+
get,
|
|
68
|
+
STATUS_CODES,
|
|
69
|
+
METHODS,
|
|
70
|
+
getServer,
|
|
71
|
+
getAllServers,
|
|
72
|
+
setServerListenCallback,
|
|
73
|
+
setServerCloseCallback,
|
|
74
|
+
Agent,
|
|
75
|
+
globalAgent,
|
|
76
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// stub - not available in browser
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from "./events";
|
|
5
|
+
|
|
6
|
+
/* ------------------------------------------------------------------ */
|
|
7
|
+
/* Session */
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
|
|
10
|
+
export interface Session extends EventEmitter {
|
|
11
|
+
connect(): void;
|
|
12
|
+
connectToMainThread(): void;
|
|
13
|
+
disconnect(): void;
|
|
14
|
+
post(
|
|
15
|
+
_method: string,
|
|
16
|
+
_params?: object,
|
|
17
|
+
_cb?: (err: Error | null, result?: object) => void,
|
|
18
|
+
): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Session = function Session(this: any) {
|
|
22
|
+
if (!this) return;
|
|
23
|
+
EventEmitter.call(this);
|
|
24
|
+
} as unknown as { new(): Session; prototype: any };
|
|
25
|
+
|
|
26
|
+
Object.setPrototypeOf(Session.prototype, EventEmitter.prototype);
|
|
27
|
+
|
|
28
|
+
Session.prototype.connect = function connect(): void {};
|
|
29
|
+
Session.prototype.connectToMainThread = function connectToMainThread(): void {};
|
|
30
|
+
Session.prototype.disconnect = function disconnect(): void {};
|
|
31
|
+
Session.prototype.post = function post(
|
|
32
|
+
_method: string,
|
|
33
|
+
_params?: object,
|
|
34
|
+
_cb?: (err: Error | null, result?: object) => void,
|
|
35
|
+
): void {
|
|
36
|
+
if (_cb) setTimeout(() => _cb(null, {}), 0);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/* ------------------------------------------------------------------ */
|
|
40
|
+
/* Module-level helpers */
|
|
41
|
+
/* ------------------------------------------------------------------ */
|
|
42
|
+
|
|
43
|
+
export function open(_port?: number, _host?: string, _wait?: boolean): void {}
|
|
44
|
+
export function close(): void {}
|
|
45
|
+
export function url(): string | undefined {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
export function waitForDebugger(): void {}
|
|
49
|
+
export { nativeConsole as console };
|
|
50
|
+
|
|
51
|
+
/* ------------------------------------------------------------------ */
|
|
52
|
+
/* Default export */
|
|
53
|
+
/* ------------------------------------------------------------------ */
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
Session,
|
|
57
|
+
open,
|
|
58
|
+
close,
|
|
59
|
+
url,
|
|
60
|
+
waitForDebugger,
|
|
61
|
+
console: nativeConsole,
|
|
62
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Lazy-loads lightningcss-wasm from CDN since native .node binaries can't run in browser.
|
|
2
|
+
// Feature flags are inlined for synchronous access; actual transform/bundle delegates to WASM.
|
|
3
|
+
|
|
4
|
+
import { CDN_LIGHTNINGCSS_WASM, cdnImport } from "../constants/cdn-urls";
|
|
5
|
+
|
|
6
|
+
// Bitfield constants -- must be available synchronously before WASM loads
|
|
7
|
+
|
|
8
|
+
export const Features = {
|
|
9
|
+
Nesting: 1,
|
|
10
|
+
NotSelectorList: 2,
|
|
11
|
+
DirSelector: 4,
|
|
12
|
+
LangSelectorList: 8,
|
|
13
|
+
IsSelector: 16,
|
|
14
|
+
TextDecorationThicknessPercent: 32,
|
|
15
|
+
MediaIntervalSyntax: 64,
|
|
16
|
+
MediaRangeSyntax: 128,
|
|
17
|
+
CustomMediaQueries: 256,
|
|
18
|
+
ClampFunction: 512,
|
|
19
|
+
ColorFunction: 1024,
|
|
20
|
+
OklabColors: 2048,
|
|
21
|
+
LabColors: 4096,
|
|
22
|
+
P3Colors: 8192,
|
|
23
|
+
HexAlphaColors: 16384,
|
|
24
|
+
SpaceSeparatedColorNotation: 32768,
|
|
25
|
+
FontFamilySystemUi: 65536,
|
|
26
|
+
DoublePositionGradients: 131072,
|
|
27
|
+
VendorPrefixes: 262144,
|
|
28
|
+
LogicalProperties: 524288,
|
|
29
|
+
LightDark: 1048576,
|
|
30
|
+
// Composite flags
|
|
31
|
+
Selectors: 31,
|
|
32
|
+
MediaQueries: 448,
|
|
33
|
+
Colors: 1113088,
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
let wasmMod: any = null;
|
|
37
|
+
let initPromise: Promise<void> | null = null;
|
|
38
|
+
|
|
39
|
+
async function ensureInit(): Promise<void> {
|
|
40
|
+
if (wasmMod) return;
|
|
41
|
+
if (initPromise) return initPromise;
|
|
42
|
+
|
|
43
|
+
initPromise = (async () => {
|
|
44
|
+
try {
|
|
45
|
+
const mod = await cdnImport(CDN_LIGHTNINGCSS_WASM);
|
|
46
|
+
if (typeof mod.default === "function") {
|
|
47
|
+
await mod.default();
|
|
48
|
+
} else if (typeof mod.init === "function") {
|
|
49
|
+
await mod.init();
|
|
50
|
+
}
|
|
51
|
+
wasmMod = mod;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
initPromise = null;
|
|
54
|
+
throw new Error(`lightningcss: WASM initialization failed -- ${err}`);
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
|
|
58
|
+
return initPromise;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// start eagerly so WASM is ready by the time transform() is called
|
|
62
|
+
ensureInit();
|
|
63
|
+
|
|
64
|
+
export function transform(opts: any): any {
|
|
65
|
+
if (!wasmMod) throw new Error("lightningcss: WASM not ready yet — call await init() first");
|
|
66
|
+
return wasmMod.transform(opts);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function transformStyleAttribute(opts: any): any {
|
|
70
|
+
if (!wasmMod) throw new Error("lightningcss: WASM not ready yet");
|
|
71
|
+
return wasmMod.transformStyleAttribute(opts);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function bundle(opts: any): any {
|
|
75
|
+
if (!wasmMod) throw new Error("lightningcss: WASM not ready yet");
|
|
76
|
+
return wasmMod.bundle(opts);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function bundleAsync(opts: any): Promise<any> {
|
|
80
|
+
await ensureInit();
|
|
81
|
+
return wasmMod.bundleAsync(opts);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function composeVisitors(visitors: any[]): any {
|
|
85
|
+
if (!wasmMod) throw new Error("lightningcss: WASM not ready yet");
|
|
86
|
+
return wasmMod.composeVisitors(visitors);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function browserslistToTargets(browserslist: any): any {
|
|
90
|
+
if (wasmMod?.browserslistToTargets) return wasmMod.browserslistToTargets(browserslist);
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { ensureInit as init };
|
|
95
|
+
|
|
96
|
+
export default {
|
|
97
|
+
transform,
|
|
98
|
+
transformStyleAttribute,
|
|
99
|
+
bundle,
|
|
100
|
+
bundleAsync,
|
|
101
|
+
composeVisitors,
|
|
102
|
+
Features,
|
|
103
|
+
browserslistToTargets,
|
|
104
|
+
init: ensureInit,
|
|
105
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Module polyfill (builtinModules, createRequire, Module class)
|
|
2
|
+
|
|
3
|
+
export const builtinModules: string[] = [
|
|
4
|
+
"assert",
|
|
5
|
+
"assert/strict",
|
|
6
|
+
"async_hooks",
|
|
7
|
+
"buffer",
|
|
8
|
+
"child_process",
|
|
9
|
+
"cluster",
|
|
10
|
+
"console",
|
|
11
|
+
"constants",
|
|
12
|
+
"crypto",
|
|
13
|
+
"dgram",
|
|
14
|
+
"diagnostics_channel",
|
|
15
|
+
"dns",
|
|
16
|
+
"dns/promises",
|
|
17
|
+
"domain",
|
|
18
|
+
"events",
|
|
19
|
+
"fs",
|
|
20
|
+
"fs/promises",
|
|
21
|
+
"http",
|
|
22
|
+
"http2",
|
|
23
|
+
"https",
|
|
24
|
+
"inspector",
|
|
25
|
+
"inspector/promises",
|
|
26
|
+
"module",
|
|
27
|
+
"net",
|
|
28
|
+
"os",
|
|
29
|
+
"path",
|
|
30
|
+
"path/posix",
|
|
31
|
+
"path/win32",
|
|
32
|
+
"perf_hooks",
|
|
33
|
+
"process",
|
|
34
|
+
"punycode",
|
|
35
|
+
"querystring",
|
|
36
|
+
"quic",
|
|
37
|
+
"readline",
|
|
38
|
+
"readline/promises",
|
|
39
|
+
"repl",
|
|
40
|
+
"sea",
|
|
41
|
+
"sqlite",
|
|
42
|
+
"stream",
|
|
43
|
+
"stream/consumers",
|
|
44
|
+
"stream/promises",
|
|
45
|
+
"stream/web",
|
|
46
|
+
"string_decoder",
|
|
47
|
+
"sys",
|
|
48
|
+
"test",
|
|
49
|
+
"timers",
|
|
50
|
+
"timers/promises",
|
|
51
|
+
"tls",
|
|
52
|
+
"trace_events",
|
|
53
|
+
"tty",
|
|
54
|
+
"url",
|
|
55
|
+
"util",
|
|
56
|
+
"util/types",
|
|
57
|
+
"v8",
|
|
58
|
+
"vm",
|
|
59
|
+
"wasi",
|
|
60
|
+
"worker_threads",
|
|
61
|
+
"zlib",
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export function isBuiltin(id: string): boolean {
|
|
65
|
+
const stripped = id.startsWith("node:") ? id.slice(5) : id;
|
|
66
|
+
if (builtinModules.includes(stripped)) return true;
|
|
67
|
+
const slash = stripped.indexOf("/");
|
|
68
|
+
if (slash !== -1) {
|
|
69
|
+
return builtinModules.includes(stripped.slice(0, slash));
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function createRequire(origin: string): (specifier: string) => unknown {
|
|
75
|
+
return function requireFrom(specifier: string): unknown {
|
|
76
|
+
throw new Error(`Cannot resolve module '${specifier}' from '${origin}'`);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const _cache: Record<string, unknown> = {};
|
|
81
|
+
|
|
82
|
+
export const _extensions: Record<string, unknown> = {
|
|
83
|
+
".js": () => {},
|
|
84
|
+
".json": () => {},
|
|
85
|
+
".node": () => {},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const _pathCache: Record<string, string> = {};
|
|
89
|
+
|
|
90
|
+
export function _resolveFilename(
|
|
91
|
+
request: string,
|
|
92
|
+
_parent?: unknown,
|
|
93
|
+
_isMain?: boolean,
|
|
94
|
+
_options?: unknown,
|
|
95
|
+
): string {
|
|
96
|
+
return request;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function _nodeModulePaths(from: string): string[] {
|
|
100
|
+
const parts = from.split("/").filter(Boolean);
|
|
101
|
+
const paths: string[] = [];
|
|
102
|
+
for (let i = parts.length; i > 0; i--) {
|
|
103
|
+
const dir = "/" + parts.slice(0, i).join("/");
|
|
104
|
+
if (parts[i - 1] !== "node_modules") {
|
|
105
|
+
paths.push(dir + "/node_modules");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
paths.push("/node_modules");
|
|
109
|
+
return paths;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function _load(
|
|
113
|
+
request: string,
|
|
114
|
+
_parent?: unknown,
|
|
115
|
+
_isMain?: boolean,
|
|
116
|
+
): unknown {
|
|
117
|
+
// wired up by ScriptEngine.buildResolver at runtime
|
|
118
|
+
throw new Error(`Cannot load module '${request}'`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function _findPath(
|
|
122
|
+
request: string,
|
|
123
|
+
_paths?: string[],
|
|
124
|
+
_isMain?: boolean,
|
|
125
|
+
): string | false {
|
|
126
|
+
return request;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function wrap(script: string): string {
|
|
130
|
+
return (
|
|
131
|
+
"(function (exports, require, module, __filename, __dirname) { " +
|
|
132
|
+
script +
|
|
133
|
+
"\n});"
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const wrapper = [
|
|
138
|
+
"(function (exports, require, module, __filename, __dirname) { ",
|
|
139
|
+
"\n});",
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
export function syncBuiltinESMExports(): void {
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function Module(this: any, id?: string, parent?: any) {
|
|
146
|
+
this.id = id || "";
|
|
147
|
+
this.filename = id || "";
|
|
148
|
+
this.loaded = false;
|
|
149
|
+
this.parent = parent || null;
|
|
150
|
+
this.children = [];
|
|
151
|
+
this.exports = {};
|
|
152
|
+
this.paths = [];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Next.js accesses Module.prototype.require
|
|
156
|
+
Module.prototype.require = function (specifier: string): unknown {
|
|
157
|
+
throw new Error(
|
|
158
|
+
`Cannot resolve module '${specifier}' from '${this.filename}'`,
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
Module.prototype.load = function (_filename: string): void {
|
|
163
|
+
this.loaded = true;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
Module.prototype._compile = function (
|
|
167
|
+
_content: string,
|
|
168
|
+
_filename: string,
|
|
169
|
+
): void {
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
Module.createRequire = createRequire;
|
|
173
|
+
Module.builtinModules = builtinModules;
|
|
174
|
+
Module.isBuiltin = isBuiltin;
|
|
175
|
+
Module._cache = _cache;
|
|
176
|
+
Module._extensions = _extensions;
|
|
177
|
+
Module._pathCache = _pathCache;
|
|
178
|
+
Module._resolveFilename = _resolveFilename;
|
|
179
|
+
Module._nodeModulePaths = _nodeModulePaths;
|
|
180
|
+
Module._load = _load;
|
|
181
|
+
Module._findPath = _findPath;
|
|
182
|
+
Module.syncBuiltinESMExports = syncBuiltinESMExports;
|
|
183
|
+
Module.wrap = wrap;
|
|
184
|
+
Module.wrapper = wrapper;
|
|
185
|
+
Module.Module = Module;
|
|
186
|
+
Module.runMain = function () {};
|
|
187
|
+
Module._preloadModules = function (_requests?: string[]) {};
|
|
188
|
+
Module._initPaths = function () {};
|
|
189
|
+
Module.globalPaths = ["/node_modules"];
|
|
190
|
+
|
|
191
|
+
export default Module;
|