chemicaljs 1.5.0 → 1.6.1
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/README.md +48 -0
- package/dist/baremux/baretypes.d.ts +22 -0
- package/dist/baremux/client.d.ts +73 -0
- package/dist/baremux/connection.d.ts +43 -0
- package/dist/baremux/index.d.ts +9 -0
- package/dist/baremux/index.js +542 -0
- package/dist/baremux/index.js.map +1 -0
- package/dist/baremux/index.mjs +525 -0
- package/dist/baremux/index.mjs.map +1 -0
- package/dist/baremux/snapshot.d.ts +44 -0
- package/dist/baremux/worker.d.ts +1 -0
- package/dist/baremux/worker.js +166 -0
- package/dist/baremux/worker.js.map +1 -0
- package/dist/baremux/workerHandlers.d.ts +5 -0
- package/dist/chemical.js +268 -0
- package/dist/chemical.sw.js +38 -0
- package/dist/epoxy/index.js +1615 -0
- package/dist/epoxy/index.mjs +1562 -0
- package/dist/libcurl/index.cjs +6634 -0
- package/dist/libcurl/index.js +6634 -0
- package/dist/libcurl/index.mjs +6589 -0
- package/dist/scramjet/scramjet.bundle.js +7 -0
- package/dist/scramjet/scramjet.bundle.js.map +7 -0
- package/dist/scramjet/scramjet.client.js +1 -0
- package/dist/scramjet/scramjet.client.js.map +7 -0
- package/dist/scramjet/scramjet.codecs.js +3 -0
- package/dist/scramjet/scramjet.codecs.js.map +7 -0
- package/dist/scramjet/scramjet.config.js +9 -0
- package/dist/scramjet/scramjet.config.js.map +7 -0
- package/dist/scramjet/scramjet.worker.js +42 -0
- package/dist/scramjet/scramjet.worker.js.map +7 -0
- package/dist/uv/sw.js +24 -0
- package/dist/uv/uv.bundle.js +8 -0
- package/dist/uv/uv.bundle.js.map +7 -0
- package/dist/uv/uv.client.js +5 -0
- package/dist/uv/uv.client.js.map +7 -0
- package/dist/uv/uv.config.js +10 -0
- package/dist/uv/uv.handler.js +2 -0
- package/dist/uv/uv.handler.js.map +7 -0
- package/dist/uv/uv.sw.js +45 -0
- package/dist/uv/uv.sw.js.map +7 -0
- package/examples/example/package-lock.json +20 -20
- package/examples/example/package.json +1 -1
- package/examples/example-build/README.md +5 -0
- package/examples/example-build/build.js +13 -0
- package/examples/example-build/index.js +16 -0
- package/examples/example-build/package-lock.json +3893 -0
- package/examples/example-build/package.json +25 -0
- package/examples/example-build/public/index.html +13 -0
- package/examples/example-components/package-lock.json +20 -20
- package/examples/example-components/package.json +1 -1
- package/examples/example-styled/package-lock.json +20 -20
- package/examples/example-styled/package.json +1 -1
- package/examples/example-vite/package-lock.json +28 -28
- package/examples/example-vite/package.json +3 -3
- package/index.js +91 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,9 @@ A example with all the components can be found in [`/example-components/`](https
|
|
|
11
11
|
|
|
12
12
|
A real world styled example can be found in [`/example-styled/`](https://github.com/chemicaljs/chemical/tree/main/examples/example-styled).
|
|
13
13
|
|
|
14
|
+
A example with a build command and an external wisp server can be found in [`/example-build/`](https://github.com/chemicaljs/chemical/tree/main/examples/example-build).
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
### Server
|
|
15
18
|
|
|
16
19
|
Create a new Node.js project and create a script file for the server.
|
|
@@ -73,6 +76,42 @@ chemical.server.listen(port, () => {
|
|
|
73
76
|
});
|
|
74
77
|
```
|
|
75
78
|
|
|
79
|
+
### Build
|
|
80
|
+
|
|
81
|
+
Want to use Chemical without using a custom wisp and/or rammerhead server or without a server at all?
|
|
82
|
+
|
|
83
|
+
Using the build command you can clone all needed assets into your build folder (like BareMux, Libcurl, and proxies enabled). Note that UV and Scramjet will need an external wisp server to function if you do not provide your own and Rammerhead will not work without your own Rammerhead server running.
|
|
84
|
+
|
|
85
|
+
1. Import `ChemicalBuild` and create a new build.
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
const build = new ChemicalBuild({
|
|
89
|
+
path: "dist",
|
|
90
|
+
default: "uv",
|
|
91
|
+
uv: true,
|
|
92
|
+
scramjet: true,
|
|
93
|
+
rammerhead: false,
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. Use `build.write()` to write into the build path.
|
|
98
|
+
|
|
99
|
+
3. Use `build.write(true)` to first empty the build path.
|
|
100
|
+
|
|
101
|
+
Below if a full example of building Chemical.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const build = new ChemicalBuild({
|
|
105
|
+
path: "dist",
|
|
106
|
+
default: "uv",
|
|
107
|
+
uv: true,
|
|
108
|
+
scramjet: true,
|
|
109
|
+
rammerhead: false,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await build.write(true);
|
|
113
|
+
```
|
|
114
|
+
|
|
76
115
|
### Client
|
|
77
116
|
|
|
78
117
|
In your project create a folder to store your static assets. Create an index.html file which will be the homepage of your website.
|
|
@@ -250,5 +289,14 @@ Set the second parameter of `chemicalAction` to the `id` of the iframe.
|
|
|
250
289
|
<iframe controls="my-controls-2" id="my-iframe-2" is="chemical-iframe"></iframe>
|
|
251
290
|
```
|
|
252
291
|
|
|
292
|
+
## Future Additions
|
|
293
|
+
|
|
294
|
+
- Link chemical component
|
|
295
|
+
- Automatically add https:// if needed
|
|
296
|
+
- Search engine option for search
|
|
297
|
+
- Easy tab cloaking
|
|
298
|
+
- Easy about:blank
|
|
299
|
+
- Proxy switcher/searchengine switcher/cloak switcher
|
|
300
|
+
|
|
253
301
|
## License
|
|
254
302
|
Chemical Uses the MIT license.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type BareHeaders = Record<string, string | string[]>;
|
|
2
|
+
export type BareMeta = {};
|
|
3
|
+
export type TransferrableResponse = {
|
|
4
|
+
body: ReadableStream | ArrayBuffer | Blob | string;
|
|
5
|
+
headers: BareHeaders;
|
|
6
|
+
status: number;
|
|
7
|
+
statusText: string;
|
|
8
|
+
};
|
|
9
|
+
export interface BareTransport {
|
|
10
|
+
init: () => Promise<void>;
|
|
11
|
+
ready: boolean;
|
|
12
|
+
connect: (url: URL, origin: string, protocols: string[], requestHeaders: BareHeaders, onopen: (protocol: string) => void, onmessage: (data: Blob | ArrayBuffer | string) => void, onclose: (code: number, reason: string) => void, onerror: (error: string) => void) => [(data: Blob | ArrayBuffer | string) => void, (code: number, reason: string) => void];
|
|
13
|
+
request: (remote: URL, method: string, body: BodyInit | null, headers: BareHeaders, signal: AbortSignal | undefined) => Promise<TransferrableResponse>;
|
|
14
|
+
meta: () => BareMeta;
|
|
15
|
+
}
|
|
16
|
+
export interface BareWebSocketMeta {
|
|
17
|
+
protocol: string;
|
|
18
|
+
setCookies: string[];
|
|
19
|
+
}
|
|
20
|
+
export type BareHTTPProtocol = 'blob:' | 'http:' | 'https:' | string;
|
|
21
|
+
export type BareWSProtocol = 'ws:' | 'wss:' | string;
|
|
22
|
+
export declare const maxRedirects = 20;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BareHeaders, BareTransport } from './baretypes';
|
|
2
|
+
import { WorkerConnection } from './connection';
|
|
3
|
+
export declare function validProtocol(protocol: string): boolean;
|
|
4
|
+
export type WebSocketImpl = {
|
|
5
|
+
new (...args: ConstructorParameters<typeof WebSocket>): WebSocket;
|
|
6
|
+
};
|
|
7
|
+
export declare namespace BareWebSocket {
|
|
8
|
+
type GetReadyStateCallback = () => number;
|
|
9
|
+
type GetSendErrorCallback = () => Error | undefined;
|
|
10
|
+
type GetProtocolCallback = () => string;
|
|
11
|
+
type HeadersType = BareHeaders | Headers | undefined;
|
|
12
|
+
type HeadersProvider = BareHeaders | (() => BareHeaders | Promise<BareHeaders>);
|
|
13
|
+
interface Options {
|
|
14
|
+
/**
|
|
15
|
+
* A provider of request headers to pass to the remote.
|
|
16
|
+
* Usually one of `User-Agent`, `Origin`, and `Cookie`
|
|
17
|
+
* Can be just the headers object or an synchronous/asynchronous function that returns the headers object
|
|
18
|
+
*/
|
|
19
|
+
headers?: BareWebSocket.HeadersProvider;
|
|
20
|
+
/**
|
|
21
|
+
* A hook executed by this function with helper arguments for hooking the readyState property. If a hook isn't provided, bare-client will hook the property on the instance. Hooking it on an instance basis is good for small projects, but ideally the class should be hooked by the user of bare-client.
|
|
22
|
+
*/
|
|
23
|
+
readyStateHook?: ((socket: WebSocket, getReadyState: BareWebSocket.GetReadyStateCallback) => void) | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A hook executed by this function with helper arguments for determining if the send function should throw an error. If a hook isn't provided, bare-client will hook the function on the instance.
|
|
26
|
+
*/
|
|
27
|
+
sendErrorHook?: ((socket: WebSocket, getSendError: BareWebSocket.GetSendErrorCallback) => void) | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* A hook executed by this function with the URL. If a hook isn't provided, bare-client will hook the URL.
|
|
30
|
+
*/
|
|
31
|
+
urlHook?: ((socket: WebSocket, url: URL) => void) | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* A hook executed by this function with a helper for getting the current fake protocol. If a hook isn't provided, bare-client will hook the protocol.
|
|
34
|
+
*/
|
|
35
|
+
protocolHook?: ((socket: WebSocket, getProtocol: BareWebSocket.GetProtocolCallback) => void) | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* A callback executed by this function with an array of cookies. This is called once the metadata from the server is received.
|
|
38
|
+
*/
|
|
39
|
+
setCookiesCallback?: ((setCookies: string[]) => void) | undefined;
|
|
40
|
+
webSocketImpl?: WebSocket;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A Response with additional properties.
|
|
45
|
+
*/
|
|
46
|
+
export interface BareResponse extends Response {
|
|
47
|
+
rawResponse: Response;
|
|
48
|
+
rawHeaders: BareHeaders;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A BareResponse with additional properties.
|
|
52
|
+
*/
|
|
53
|
+
export interface BareResponseFetch extends BareResponse {
|
|
54
|
+
finalURL: string;
|
|
55
|
+
}
|
|
56
|
+
export declare class BareMuxConnection {
|
|
57
|
+
worker: WorkerConnection;
|
|
58
|
+
constructor(workerPath: string);
|
|
59
|
+
getTransport(): Promise<string>;
|
|
60
|
+
setTransport(path: string, options: any[], transferables?: Transferable[]): Promise<void>;
|
|
61
|
+
setManualTransport(functionBody: string, options: any[], transferables?: Transferable[]): Promise<void>;
|
|
62
|
+
setRemoteTransport(transport: BareTransport, name: string): Promise<void>;
|
|
63
|
+
getInnerPort(): MessagePort | Promise<MessagePort>;
|
|
64
|
+
}
|
|
65
|
+
export declare class BareClient {
|
|
66
|
+
worker: WorkerConnection;
|
|
67
|
+
/**
|
|
68
|
+
* Create a BareClient. Calls to fetch and connect will wait for an implementation to be ready.
|
|
69
|
+
*/
|
|
70
|
+
constructor(worker?: string | MessagePort);
|
|
71
|
+
createWebSocket(remote: string | URL, protocols?: string | string[] | undefined, webSocketImpl?: WebSocketImpl, requestHeaders?: BareHeaders, arrayBufferImpl?: ArrayBuffer): WebSocket;
|
|
72
|
+
fetch(url: string | URL, init?: RequestInit): Promise<BareResponseFetch>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BareHeaders, TransferrableResponse } from "./baretypes";
|
|
2
|
+
export type WorkerMessage = {
|
|
3
|
+
type: "fetch" | "websocket" | "set" | "get" | "ping";
|
|
4
|
+
fetch?: {
|
|
5
|
+
remote: string;
|
|
6
|
+
method: string;
|
|
7
|
+
headers: BareHeaders;
|
|
8
|
+
body: ReadableStream | ArrayBuffer | undefined;
|
|
9
|
+
};
|
|
10
|
+
websocket?: {
|
|
11
|
+
url: string;
|
|
12
|
+
origin: string;
|
|
13
|
+
protocols: string[];
|
|
14
|
+
requestHeaders: BareHeaders;
|
|
15
|
+
channel: MessagePort;
|
|
16
|
+
};
|
|
17
|
+
client?: {
|
|
18
|
+
function: string;
|
|
19
|
+
args: any[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type WorkerRequest = {
|
|
23
|
+
message: WorkerMessage;
|
|
24
|
+
port: MessagePort;
|
|
25
|
+
};
|
|
26
|
+
export type WorkerResponse = {
|
|
27
|
+
type: "fetch" | "websocket" | "set" | "get" | "pong" | "error";
|
|
28
|
+
fetch?: TransferrableResponse;
|
|
29
|
+
name?: string;
|
|
30
|
+
error?: Error;
|
|
31
|
+
};
|
|
32
|
+
export type BroadcastMessage = {
|
|
33
|
+
type: "refreshPort";
|
|
34
|
+
};
|
|
35
|
+
export declare function browserSupportsTransferringStreams(): boolean;
|
|
36
|
+
export declare class WorkerConnection {
|
|
37
|
+
channel: BroadcastChannel;
|
|
38
|
+
port: MessagePort | Promise<MessagePort>;
|
|
39
|
+
workerPath: string;
|
|
40
|
+
constructor(worker?: string | MessagePort);
|
|
41
|
+
createChannel(workerPath?: string, inInit?: boolean): void;
|
|
42
|
+
sendMessage(message: WorkerMessage, transferable?: Transferable[]): Promise<WorkerResponse>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './baretypes';
|
|
2
|
+
export * from './client';
|
|
3
|
+
export * from './connection';
|
|
4
|
+
export { BareClient as default } from './client';
|
|
5
|
+
export { WebSocketFields } from "./snapshot";
|
|
6
|
+
export type * from './baretypes';
|
|
7
|
+
export type * from './client';
|
|
8
|
+
export type * from './connection';
|
|
9
|
+
export type * from "./snapshot";
|