deploy: v0.12 fix 存档key名

This commit is contained in:
2026-06-24 03:09:02 +00:00
parent 7a08d49fe3
commit e0a5281119
58743 changed files with 7297269 additions and 39505 deletions
+36
View File
@@ -0,0 +1,36 @@
import { FileSystemApi, FilesMap } from './modules/fs';
import type { FileWatchEvent } from './modules/fs';
import { ShellApi, ShellInfo, ShellProcess } from './modules/shell';
import { PreviewApi, PreviewInfo } from './modules/preview';
export type { ShellInfo, PreviewInfo, FilesMap, ShellProcess, FileWatchEvent };
export interface ChannelOptions {
iframe: HTMLIFrameElement;
/**
* A custom Nodebox runtime URL
*/
runtimeUrl?: string;
/**
* A custom Sandpack CDN URL.
*/
cdnUrl?: string;
}
/**
* Create a new Node emulator instance
*/
export declare class Nodebox {
private readonly options;
private channel;
private isConnected;
private url;
private fileSystemApi;
private shellApi;
private previewApi;
constructor(options: ChannelOptions);
/**
* Connect to the deployed Node Emulator instance.
*/
connect(): Promise<void>;
get fs(): FileSystemApi;
get shell(): ShellApi;
get preview(): PreviewApi;
}
+4
View File
@@ -0,0 +1,4 @@
export * from './messages';
export * from './Nodebox';
export * from './runtime-protocol.types';
export type { IFileStats } from './modules/fs';
+1082
View File
File diff suppressed because it is too large Load Diff
+1068
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -0,0 +1,3 @@
declare type Scope = 'preview' | 'emulator' | 'runtime' | 'bridge' | 'runtime:worker';
export declare function createDebug(scope: Scope): (message: string, ...data: any[]) => void;
export {};
+98
View File
@@ -0,0 +1,98 @@
import type { FileSystemEvents } from './modules/fs';
import type { ShellEvents } from './modules/shell';
import type { PreviewInfo } from './modules/preview';
import type { PreviewEvents } from './modules/preview';
export interface ConsumerEvents extends FileSystemEvents, ShellEvents, PreviewEvents {
connect: {
cdnUrl?: string | null;
};
}
declare type WatcherEvent = {
type: 'create';
path: string;
} | {
type: 'remove';
path: string;
} | {
type: 'change';
path: string;
} | {
type: 'rename';
oldPath: string;
newPath: string;
} | {
type: 'close';
};
export declare type FSWatchEvent = WatcherEvent & {
watcherId: string;
};
export declare type WorkerStatusUpdate = {
state: 'downloading_manifest';
} | {
state: 'downloaded_module';
name: string;
version: string;
totalPending: number;
} | {
state: 'starting_command';
} | {
state: 'command_running';
};
export interface WorkerEvents {
'internal/handshake/done': void;
'internal/operation/done': {
operationId: string;
listenerPayload: unknown;
};
'internal/operation/failed': {
operationId: string;
error: Error;
};
'runtime/ready': void;
'worker/progress': {
workerId?: string;
status: WorkerStatusUpdate;
};
'worker/tty': {
workerId: string;
payload: {
data: string;
type: 'out' | 'err';
};
};
'worker/exit': {
workerId: string;
exitCode: number;
error?: {
message: string;
};
};
'preview/port/ready': PreviewInfo;
'fs/watch-event': FSWatchEvent;
}
declare type OperationEvent<Payload> = Payload & {
operationId: string;
};
declare type MaybePromise<T> = T | Promise<T>;
export declare class MessageReceiver {
private emitter;
private senderPort;
constructor();
private waitForHandshake;
private addMessageListener;
on<Event extends keyof ConsumerEvents & string>(event: Event, listener: (message: ConsumerEvents[Event] extends [infer PayloadType, infer _] ? PayloadType : ConsumerEvents[Event]) => MaybePromise<ConsumerEvents[Event] extends [infer _, infer ReturnType] ? ReturnType | undefined : void>, options?: AddEventListenerOptions): void;
send<Event extends keyof WorkerEvents & string>(event: Event, ...data: WorkerEvents[Event] extends Record<string, unknown> ? [WorkerEvents[Event]] : [undefined?]): void;
}
export declare class MessageSender {
private readonly target;
private emitter;
private channel;
private receiverPort;
private receiverReadyPromise;
constructor(target: Window);
handshake(): Promise<void>;
on<Event extends keyof WorkerEvents & string>(event: Event, listener: (message: MessageEvent<WorkerEvents[Event]>) => void, options?: AddEventListenerOptions): void;
off<Event extends keyof WorkerEvents & string>(event: Event, listener: (message: MessageEvent<WorkerEvents[Event]>) => void, options?: AddEventListenerOptions): void;
send<Event extends keyof ConsumerEvents & string>(event: Event, ...data: ConsumerEvents[Event] extends [infer PayloadType, infer _] ? [PayloadType] : ConsumerEvents[Event] extends Record<string, unknown> ? [ConsumerEvents[Event]] : [undefined?]): Promise<ConsumerEvents[Event] extends [infer _, infer ReturnType] ? OperationEvent<ReturnType> | undefined : void>;
}
export {};
+121
View File
@@ -0,0 +1,121 @@
/// <reference types="node" />
import type { MessageSender, FSWatchEvent } from '../messages';
declare type FSEncoding = BufferEncoding | 'buffer';
export declare type FileContent = Uint8Array | string;
export interface FilesMap {
[filePath: string]: FileContent;
}
export interface FileWatchOptions {
recursive?: boolean;
}
export declare type FileWatchEvent = Omit<FSWatchEvent, 'watcherId'>;
export interface IFileStats {
type: 'dir' | 'file' | 'link';
size: number;
ino: number;
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
blocks: number;
mode: number;
}
export interface FileSystemEvents {
'fs/init': {
files: FilesMap;
};
'fs/readFile': [{
path: string;
encoding?: undefined;
}, {
data: Uint8Array;
}] | [{
path: string;
encoding?: 'buffer';
}, {
data: Uint8Array;
}] | [{
path: string;
encoding?: FSEncoding;
}, {
data: string | FileContent;
}];
'fs/writeFile': {
path: string;
content: FileContent;
encoding?: BufferEncoding;
recursive?: boolean;
};
'fs/readdir': [
{
path: string;
},
{
data: string[];
}
];
'fs/stat': [
{
path: string;
},
{
data: IFileStats;
}
];
'fs/mkdir': {
path: string;
recursive?: boolean;
};
'fs/rm': {
path: string;
force?: boolean;
recursive?: boolean;
};
'fs/watch': {
watcherId: string;
includes: string[];
excludes: string[];
};
'fs/unwatch': {
watcherId: string;
};
}
declare type WriteFileOptions = BufferEncoding | {
encoding?: BufferEncoding;
recursive?: boolean;
};
export declare class FileSystemApi {
private readonly channel;
constructor(channel: MessageSender);
/**
* Initialize the File System worker with the files.
*/
init(files: FilesMap): Promise<void>;
/**
* Read a file at the given path.
*/
readFile(path: string, encoding?: undefined): Promise<Uint8Array>;
readFile(path: string, encoding: 'buffer'): Promise<Uint8Array>;
readFile(path: string, encoding: BufferEncoding): Promise<string>;
/**
* Write a file at the given path.
* Replaces the file content if the file already exists.
*/
writeFile(path: string, content: FileContent): Promise<void>;
writeFile(path: string, content: FileContent, options: WriteFileOptions): Promise<void>;
readdir(path: string): Promise<string[]>;
mkdir(path: string, options?: {
recursive?: boolean;
}): Promise<void>;
stat(path: string): Promise<IFileStats>;
rm(path: string, options?: {
force?: boolean;
recursive?: boolean;
}): Promise<void>;
/**
* Subscribe to changes at the given file or directory.
*/
watch(includes: string[], excludes: string[], listener?: (evt?: FileWatchEvent) => void): Promise<{
dispose: () => Promise<void>;
}>;
}
export {};
+22
View File
@@ -0,0 +1,22 @@
import type { MessageSender } from '../messages';
export interface PreviewEvents {
'preview/get/info': [
{
port?: number;
sourceShellId?: string;
},
PreviewInfo
];
}
export declare type PreviewInfo = {
url: string;
sourceShellId: string;
port: number;
};
export declare class PreviewApi {
private readonly channel;
constructor(channel: MessageSender);
private waitFor;
getByShellId(sourceShellId: string, timeout?: number): Promise<PreviewInfo>;
waitForPort(port: number, timeout?: number): Promise<PreviewInfo>;
}
+57
View File
@@ -0,0 +1,57 @@
import { Emitter } from 'strict-event-emitter';
import type { MessageSender, WorkerStatusUpdate } from '../messages';
export interface ShellEvents {
'shell/runCommand': [
{
command: string;
args: Array<string>;
options: ShellCommandOptions;
},
ShellInfo
];
'shell/exit': ShellInfo;
'shell/stdin': {
data: string | Uint8Array;
workerId: string;
};
}
export interface ShellCommandOptions {
cwd?: string;
env?: Record<string, string>;
}
export declare type ShellInfo = {
id: string;
};
export declare class ShellApi {
private readonly channel;
constructor(channel: MessageSender);
create(): ShellProcess;
}
export declare class ShellProcess {
private readonly channel;
id?: string;
state: 'running' | 'idle';
stdout: Emitter<{
data: [string];
}>;
stderr: Emitter<{
data: [string];
}>;
stdin: {
write: (data: string | Uint8Array) => Promise<void>;
};
constructor(channel: MessageSender);
private forwardStdEvents;
/**
* Evaluates a given module in the File
*/
runCommand(command: string, args: Array<string>, options?: ShellCommandOptions): Promise<ShellInfo>;
on(message: 'exit', listener: (exitCode: number, error?: {
message: string;
}) => void): Promise<void>;
on(message: 'progress', listener: (status: WorkerStatusUpdate) => void): Promise<void>;
/**
* Terminates the shell process.
*/
kill(): Promise<void>;
}
+13
View File
@@ -0,0 +1,13 @@
export declare const INJECT_MESSAGE_TYPE = "INJECT_AND_INVOKE";
export declare const PREVIEW_LOADED_MESSAGE_TYPE = "PREVIEW_LOADED";
export interface Message {
type: string;
}
declare type BaseScope = Record<string, unknown>;
export interface InjectMessage<Scope = BaseScope> {
uid: string;
type: typeof INJECT_MESSAGE_TYPE;
code: string;
scope: Scope;
}
export {};