Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
solichatuszhrh authored Jan 13, 2024
1 parent 85a7d9f commit f4a425c
Show file tree
Hide file tree
Showing 58 changed files with 40,109 additions and 0 deletions.
28,209 changes: 28,209 additions & 0 deletions docs/shinylive/webr/R.bin.data

Large diffs are not rendered by default.

1,846 changes: 1,846 additions & 0 deletions docs/shinylive/webr/R.bin.js

Large diffs are not rendered by default.

Binary file added docs/shinylive/webr/R.bin.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions docs/shinylive/webr/esbuild.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Binary file added docs/shinylive/webr/libRblas.so
Binary file not shown.
Binary file added docs/shinylive/webr/libRlapack.so
Binary file not shown.
15 changes: 15 additions & 0 deletions docs/shinylive/webr/repl/App.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Readline } from 'xterm-readline';
import './App.css';
export interface TerminalInterface {
println: Readline['println'];
read: Readline['read'];
write: Readline['write'];
}
export interface FilesInterface {
refreshFilesystem: () => Promise<void>;
openFileInEditor: (name: string, path: string, readOnly: boolean) => Promise<void>;
}
export interface PlotInterface {
newPlot: () => void;
drawImage: (img: ImageBitmap) => void;
}
26 changes: 26 additions & 0 deletions docs/shinylive/webr/repl/components/Editor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { WebR } from '../../webR/webr-main';
import { EditorState } from '@codemirror/state';
import { FilesInterface, TerminalInterface } from '../App';
import './Editor.css';
export type EditorFile = {
name: string;
path: string;
ref: {
editorState: EditorState;
scrollTop?: number;
scrollLeft?: number;
};
};
export declare function FileTabs({ files, activeFileIdx, setActiveFileIdx, closeFile }: {
files: EditorFile[];
activeFileIdx: number;
setActiveFileIdx: React.Dispatch<React.SetStateAction<number>>;
closeFile: (e: React.SyntheticEvent, index: number) => void;
}): React.JSX.Element;
export declare function Editor({ webR, terminalInterface, filesInterface, }: {
webR: WebR;
terminalInterface: TerminalInterface;
filesInterface: FilesInterface;
}): React.JSX.Element;
export default Editor;
19 changes: 19 additions & 0 deletions docs/shinylive/webr/repl/components/Files.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { WebR } from '../../webR/webr-main';
import type { FSNode } from '../../webR/webr-main';
import { FilesInterface } from '../App';
import './Files.css';
interface ITreeNode {
id: number;
name: string;
children?: ITreeNode[];
metadata?: {
[x: string]: string | number | null | undefined;
};
}
export declare function createTreeFromFSNode(fsNode: FSNode): ITreeNode;
export declare function Files({ webR, filesInterface, }: {
webR: WebR;
filesInterface: FilesInterface;
}): React.JSX.Element;
export default Files;
7 changes: 7 additions & 0 deletions docs/shinylive/webr/repl/components/Plot.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import './Plot.css';
import { PlotInterface } from '../App';
export declare function Plot({ plotInterface, }: {
plotInterface: PlotInterface;
}): React.JSX.Element;
export default Plot;
9 changes: 9 additions & 0 deletions docs/shinylive/webr/repl/components/Terminal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { TerminalInterface } from '../App';
import { WebR } from '../../webR/webr-main';
import 'xterm/css/xterm.css';
export declare function Terminal({ webR, terminalInterface, }: {
webR: WebR;
terminalInterface: TerminalInterface;
}): React.JSX.Element;
export default Terminal;
11 changes: 11 additions & 0 deletions docs/shinylive/webr/repl/components/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Text } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
export type CursorPosition = {
line: number;
col: number;
};
export declare function offsetToPosition(cmDoc: Text, offset: number): CursorPosition;
export declare function positionToOffset(cmDoc: Text, pos: CursorPosition): number;
export declare function getSelectedText(cmView: EditorView): string;
export declare function getCurrentLineText(cmView: EditorView): string;
export declare function moveCursorToNextLine(cmView: EditorView): void;
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/packages/webr.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/console.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/error.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/proxy.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/robj.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/utils.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/webr-main.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/webr-r.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions docs/shinylive/webr/tests/webR/webr-worker.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
21 changes: 21 additions & 0 deletions docs/shinylive/webr/webR/chan/channel-common.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SharedBufferChannelMain, SharedBufferChannelWorker } from './channel-shared';
import { ServiceWorkerChannelMain, ServiceWorkerChannelWorker } from './channel-service';
import { PostMessageChannelMain, PostMessageChannelWorker } from './channel-postmessage';
import { WebROptions } from '../webr-main';
export declare const ChannelType: {
readonly Automatic: 0;
readonly SharedArrayBuffer: 1;
readonly ServiceWorker: 2;
readonly PostMessage: 3;
};
export type ChannelInitMessage = {
type: string;
data: {
config: Required<WebROptions>;
channelType: Exclude<(typeof ChannelType)[keyof typeof ChannelType], typeof ChannelType.Automatic>;
clientId?: string;
location?: string;
};
};
export declare function newChannelMain(data: Required<WebROptions>): SharedBufferChannelMain | ServiceWorkerChannelMain | PostMessageChannelMain;
export declare function newChannelWorker(msg: ChannelInitMessage): SharedBufferChannelWorker | ServiceWorkerChannelWorker | PostMessageChannelWorker;
26 changes: 26 additions & 0 deletions docs/shinylive/webr/webR/chan/channel-postmessage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Message } from './message';
import { WebROptions } from '../webr-main';
import { ChannelMain } from './channel';
export declare class PostMessageChannelMain extends ChannelMain {
#private;
initialised: Promise<unknown>;
resolve: (_?: unknown) => void;
close: () => void;
constructor(config: Required<WebROptions>);
interrupt(): void;
}
export declare class PostMessageChannelWorker {
#private;
constructor();
resolve(): void;
write(msg: Message, transfer?: [Transferable]): void;
writeSystem(msg: Message, transfer?: [Transferable]): void;
read(): Message;
inputOrDispatch(): number;
run(_args: string[]): void;
setDispatchHandler(dispatch: (msg: Message) => void): void;
request(msg: Message, transferables?: [Transferable]): Promise<any>;
setInterrupt(_: () => void): void;
handleInterrupt(): void;
onMessageFromMainThread(message: Message): void;
}
30 changes: 30 additions & 0 deletions docs/shinylive/webr/webR/chan/channel-service.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Message, Response } from './message';
import { ChannelMain, ChannelWorker } from './channel';
import { WebROptions } from '../webr-main';
export declare class ServiceWorkerChannelMain extends ChannelMain {
#private;
initialised: Promise<unknown>;
resolve: (_?: unknown) => void;
close: () => void;
constructor(config: Required<WebROptions>);
activeRegistration(): ServiceWorker;
interrupt(): void;
}
export declare class ServiceWorkerChannelWorker implements ChannelWorker {
#private;
onMessageFromMainThread: (msg: Message) => void;
constructor(data: {
clientId?: string;
location?: string;
});
resolve(): void;
write(msg: Message, transfer?: [Transferable]): void;
writeSystem(msg: Message, transfer?: [Transferable]): void;
syncRequest(message: Message): Response;
read(): Message;
inputOrDispatch(): number;
run(args: string[]): void;
setInterrupt(interrupt: () => void): void;
handleInterrupt(): void;
setDispatchHandler(dispatch: (msg: Message) => void): void;
}
25 changes: 25 additions & 0 deletions docs/shinylive/webr/webR/chan/channel-shared.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Message } from './message';
import { ChannelMain, ChannelWorker } from './channel';
import { WebROptions } from '../webr-main';
export declare class SharedBufferChannelMain extends ChannelMain {
#private;
initialised: Promise<unknown>;
resolve: (_?: unknown) => void;
close: () => void;
constructor(config: Required<WebROptions>);
interrupt(): void;
}
export declare class SharedBufferChannelWorker implements ChannelWorker {
#private;
onMessageFromMainThread: (msg: Message) => void;
constructor();
resolve(): void;
write(msg: Message, transfer?: [Transferable]): void;
writeSystem(msg: Message, transfer?: [Transferable]): void;
read(): Message;
inputOrDispatch(): number;
run(args: string[]): void;
setInterrupt(interrupt: () => void): void;
handleInterrupt(): void;
setDispatchHandler(dispatch: (msg: Message) => void): void;
}
44 changes: 44 additions & 0 deletions docs/shinylive/webr/webR/chan/channel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Interfaces for the webR main and worker thread communication channels.
* @module Channel
*/
import { AsyncQueue } from './queue';
import { Message, Response } from './message';
import { WebRPayload } from '../payload';
export declare abstract class ChannelMain {
#private;
inputQueue: AsyncQueue<Message>;
outputQueue: AsyncQueue<Message>;
systemQueue: AsyncQueue<Message>;
abstract initialised: Promise<unknown>;
abstract close(): void;
abstract interrupt(): void;
read(): Promise<Message>;
flush(): Promise<Message[]>;
readSystem(): Promise<Message>;
write(msg: Message): void;
request(msg: Message, transferables?: [Transferable]): Promise<WebRPayload>;
protected putClosedMessage(): void;
protected resolveResponse(msg: Response): void;
}
export interface ChannelWorker {
resolve(): void;
write(msg: Message, transfer?: [Transferable]): void;
writeSystem(msg: Message, transfer?: [Transferable]): void;
read(): Message;
handleInterrupt(): void;
setInterrupt(interrupt: () => void): void;
run(args: string[]): void;
inputOrDispatch: () => number;
setDispatchHandler: (dispatch: (msg: Message) => void) => void;
onMessageFromMainThread: (msg: Message) => void;
}
/**
* Handler functions dealing with setup and commmunication over a Service Worker.
*/
export interface ServiceWorkerHandlers {
handleActivate: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any;
handleFetch: (this: ServiceWorkerGlobalScope, ev: FetchEvent) => any;
handleInstall: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any;
handleMessage: (this: ServiceWorkerGlobalScope, ev: ExtendableMessageEvent) => any;
}
50 changes: 50 additions & 0 deletions docs/shinylive/webr/webR/chan/message.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* WebR communication channel messaging and request types.
* @module Message
*/
import { UUID } from './task-common';
/** A webR communication channel message. */
export interface Message {
type: string;
data?: any;
}
/** A webR communication channel request. */
export interface Request {
type: 'request';
data: {
uuid: UUID;
msg: Message;
};
}
/** A webR communication channel response. */
export interface Response {
type: 'response';
data: {
uuid: UUID;
resp: unknown;
};
}
/** @internal */
export declare function newRequest(msg: Message, transferables?: [Transferable]): Request;
/** @internal */
export declare function newResponse(uuid: UUID, resp: unknown, transferables?: [Transferable]): Response;
/** A webR communication channel sync-request.
* @internal
*/
export interface SyncRequest {
type: 'sync-request';
data: {
msg: Message;
reqData: SyncRequestData;
};
}
/** Transfer data required when using sync-request with SharedArrayBuffer.
* @internal */
export interface SyncRequestData {
taskId?: number;
sizeBuffer: Int32Array;
signalBuffer: Int32Array;
dataBuffer: Uint8Array;
}
/** @internal */
export declare function newSyncRequest(msg: Message, data: SyncRequestData): SyncRequest;
17 changes: 17 additions & 0 deletions docs/shinylive/webr/webR/chan/queue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @module Queue
*/
/**
* Asynchronous queue mechanism to be used by the communication channels.
* @typeParam T The type of item to be stored in the queue.
*/
export declare class AsyncQueue<T> {
#private;
constructor();
reset(): void;
put(t: T): void;
get(): Promise<T>;
isEmpty(): boolean;
isBlocked(): boolean;
get length(): number;
}
6 changes: 6 additions & 0 deletions docs/shinylive/webr/webR/chan/serviceworker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ServiceWorkerHandlers } from './channel';
export declare function handleInstall(): void;
export declare function handleActivate(event: ExtendableEvent): void;
export declare function handleFetch(event: FetchEvent): boolean;
export declare function handleMessage(event: ExtendableMessageEvent): boolean;
export declare const webRHandlers: ServiceWorkerHandlers;
17 changes: 17 additions & 0 deletions docs/shinylive/webr/webR/chan/task-common.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export declare const SZ_BUF_DOESNT_FIT = 0;
export declare const SZ_BUF_FITS_IDX = 1;
export declare const SZ_BUF_SIZE_IDX = 0;
export interface Endpoint extends EventSource {
postMessage(message: any, transfer?: Transferable[]): void;
start?: () => void;
}
export interface EventSource {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: {}): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: {}): void;
}
export declare function toWireValue(value: any): [any, Transferable[]];
export declare function transfer<T>(obj: T, transfers: Transferable[]): T;
export type UUID = string;
export declare function isUUID(x: any): x is UUID;
export declare const UUID_LENGTH = 63;
export declare function generateUUID(): UUID;
15 changes: 15 additions & 0 deletions docs/shinylive/webr/webR/chan/task-main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Endpoint } from './task-common';
import { SyncRequestData } from './message';
/**
* Respond to a blocking request. Most of the work has already been done in
* asynclink, we are just responsible here for getting the return value back to
* the requester through this slightly convoluted Atomics protocol.
* @param {Endpoint} endpoint A message port to receive messages from. Other
* thread is blocked, so we can't send messages back.
* @param {SyncRequestData} data The message that was recieved. We will use it
* to read out the buffers to write the answer into. NOTE: requester
* owns buffers.
* @param {any} response The value we want to send back to the requester. We
* have to encode it into data_buffer.
*/
export declare function syncResponse(endpoint: Endpoint, data: SyncRequestData, response: any): Promise<void>;
Loading

0 comments on commit f4a425c

Please sign in to comment.