@rpack-dev/core 0.1.19 → 0.1.20-e0d3509
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/dist/docs.json +9193 -7346
- package/dist/rpack-core-esm.bundle.js +1 -1
- package/dist/rpack-core-umd.bundle.js +1 -1
- package/dist/rpack-core.d.ts +77 -41
- package/package.json +2 -1
package/dist/rpack-core.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare class RPack {
|
|
|
17
17
|
*/
|
|
18
18
|
static createInstance(defaultInstance?: boolean): Promise<RPack>;
|
|
19
19
|
static getInstance(): RPack;
|
|
20
|
-
private readonly
|
|
20
|
+
private readonly environment;
|
|
21
21
|
private readonly loadPromise;
|
|
22
22
|
private readonly platform;
|
|
23
23
|
private readonly version;
|
|
@@ -46,7 +46,10 @@ declare class RPack {
|
|
|
46
46
|
getRegistryManager(): RegistryManager;
|
|
47
47
|
getPluginManager(): PluginManager;
|
|
48
48
|
getNetworkManager(): NetworkManager;
|
|
49
|
+
getEnvironment(): EnvironmentInfo;
|
|
49
50
|
isPluginThread(): boolean;
|
|
51
|
+
isHost(): boolean;
|
|
52
|
+
isClient(): boolean;
|
|
50
53
|
/**
|
|
51
54
|
* Shorthand for getNetworkManager().getPlugin().
|
|
52
55
|
*
|
|
@@ -80,9 +83,9 @@ export declare abstract class RPPlatform {
|
|
|
80
83
|
export declare abstract class RPackThread {
|
|
81
84
|
private readonly threadId;
|
|
82
85
|
private readonly messenger;
|
|
83
|
-
protected constructor(threadId: string, messenger: Messenger<
|
|
86
|
+
protected constructor(threadId: string, messenger: Messenger<P2CPackets, C2PPackets>);
|
|
84
87
|
getThreadId(): string;
|
|
85
|
-
getMessenger(): Messenger<
|
|
88
|
+
getMessenger(): Messenger<P2CPackets, C2PPackets>;
|
|
86
89
|
abstract disable(): Promise<void>;
|
|
87
90
|
abstract terminate(): Promise<void>;
|
|
88
91
|
}
|
|
@@ -171,7 +174,7 @@ export declare class ArrayUtils {
|
|
|
171
174
|
*/
|
|
172
175
|
static naturalSort<T>(array: T[], func?: (element: T) => string): T[];
|
|
173
176
|
}
|
|
174
|
-
export declare class
|
|
177
|
+
export declare class AsyncIteratorMirror<T, E> implements AsyncIterableIterator<T> {
|
|
175
178
|
private readonly it;
|
|
176
179
|
private readonly converter;
|
|
177
180
|
constructor(it: Iterator<T>);
|
|
@@ -228,7 +231,7 @@ export declare class DevPluginSource implements PluginSource {
|
|
|
228
231
|
getPluginArchive(groupId: string, pluginId: string, version: string): Promise<PluginArchive>;
|
|
229
232
|
removeServer(client: DevPluginServerClient): void;
|
|
230
233
|
}
|
|
231
|
-
export declare class
|
|
234
|
+
export declare class FilteredIterator<T> implements IterableIterator<T> {
|
|
232
235
|
private readonly it;
|
|
233
236
|
private readonly filter;
|
|
234
237
|
constructor(it: Iterator<T>, filter: (t: T) => boolean);
|
|
@@ -242,7 +245,7 @@ export declare class FilteredIterableIterator<T> implements IterableIterator<T>
|
|
|
242
245
|
return(value?: any): IteratorResult<T>;
|
|
243
246
|
throw(e?: any): IteratorResult<T>;
|
|
244
247
|
}
|
|
245
|
-
export declare class
|
|
248
|
+
export declare class LazyBatchedAsyncIterator<T> implements AsyncIterableIterator<T> {
|
|
246
249
|
private readonly supplier;
|
|
247
250
|
private readonly completeHandler?;
|
|
248
251
|
private readonly errorHandler?;
|
|
@@ -269,6 +272,11 @@ export declare class LazyPromise<T> {
|
|
|
269
272
|
isComplete(): boolean;
|
|
270
273
|
isErrored(): boolean;
|
|
271
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* A Proxy handler that functions as a wrapper around an object.
|
|
277
|
+
* This class turns function return values on the wrapped object
|
|
278
|
+
* into Promise objects to match Registry return types.
|
|
279
|
+
*/
|
|
272
280
|
export declare class LocalObject<T extends object> implements ProxyHandler<T> {
|
|
273
281
|
get(target: T, p: string | symbol, receiver: any): any;
|
|
274
282
|
}
|
|
@@ -327,6 +335,18 @@ export declare class LocalRemoteMap<Local, Remote> {
|
|
|
327
335
|
hasRemote(key: string): boolean;
|
|
328
336
|
deleteRemote(key: string): boolean;
|
|
329
337
|
}
|
|
338
|
+
export declare class MappedIterator<T, K> implements IterableIterator<K> {
|
|
339
|
+
private readonly it;
|
|
340
|
+
private readonly map;
|
|
341
|
+
constructor(it: Iterator<T>, map: (t: T) => K);
|
|
342
|
+
[Symbol.iterator](): IterableIterator<K>;
|
|
343
|
+
next(...args: [
|
|
344
|
+
] | [
|
|
345
|
+
any
|
|
346
|
+
]): IteratorResult<K>;
|
|
347
|
+
return(value?: any): IteratorResult<K>;
|
|
348
|
+
throw(e?: any): IteratorResult<K>;
|
|
349
|
+
}
|
|
330
350
|
export declare class Messenger<InPackets extends PacketsType<InPackets>, OutPackets extends PacketsType<OutPackets>> {
|
|
331
351
|
private readonly handlerLists;
|
|
332
352
|
private readonly sender;
|
|
@@ -347,26 +367,29 @@ export declare class Messenger<InPackets extends PacketsType<InPackets>, OutPack
|
|
|
347
367
|
sendPacket<K extends keyof OutPackets>(packet: OutPackets[K]): void;
|
|
348
368
|
sendPacketWithNoncePromise<O extends keyof OnlyNoncePackets<OutPackets>, I extends keyof OnlyNoncePackets<InPackets>>(outPacketKey: O, outPacket: Omit<OutPackets[O], "nonce" | "id">, inPacket: I, timeout?: number): Promise<InPackets[I]>;
|
|
349
369
|
static cast<SIn extends TIn, SOut extends TOut, TIn extends PacketsType<TIn>, TOut extends PacketsType<TOut>>(source: Messenger<SIn, SOut>): Messenger<TIn, TOut>;
|
|
370
|
+
private static filterTransferable;
|
|
371
|
+
static transferableSend<T, In extends PacketsType<In>, Out extends PacketsType<Out>>(detection: (value: any) => boolean, target: MessageTarget<T>): Messenger<In, Out>;
|
|
372
|
+
static websocket<In extends PacketsType<In>, Out extends PacketsType<Out>>(websocket: WebSocket): Messenger<In, Out>;
|
|
350
373
|
}
|
|
351
374
|
export declare class NetworkManager {
|
|
352
|
-
static readonly
|
|
375
|
+
static readonly CORE_THREAD_ID = "core";
|
|
353
376
|
private readonly rpack;
|
|
354
|
-
private
|
|
377
|
+
private coreMessenger?;
|
|
355
378
|
private threads?;
|
|
356
379
|
private readonly pluginRegistry;
|
|
357
380
|
private plugin;
|
|
358
381
|
private threadId;
|
|
359
382
|
private readonly wellKnownMap;
|
|
360
383
|
private readonly wellKnownReverseMap;
|
|
361
|
-
constructor(rpack: RPack, threadId: string,
|
|
384
|
+
constructor(rpack: RPack, threadId: string, coreMessenger?: Messenger<C2PPackets, P2CPackets>);
|
|
362
385
|
private mapWellKnown;
|
|
363
386
|
__initPlugin(pluginKey: string, scriptUrl: string): Promise<void>;
|
|
364
387
|
getRPack(): RPack;
|
|
365
|
-
|
|
388
|
+
getCoreMessenger(): Messenger<C2PPackets, P2CPackets> | undefined;
|
|
366
389
|
getCurrentThreadId(): string;
|
|
367
390
|
getPlugin<T extends RPPlugin>(key: string): Promise<RegistryDataFiltered<T> | undefined>;
|
|
368
391
|
getPluginRegistry(): Registry<RPPlugin, string>;
|
|
369
|
-
__initRemotes(threadId: string, messenger: Messenger<
|
|
392
|
+
__initRemotes(threadId: string, messenger: Messenger<C2PPackets | P2CPackets, C2PPackets | P2CPackets>): void;
|
|
370
393
|
__createThread(pluginKey: string, scriptUrl: string): Promise<string>;
|
|
371
394
|
private ensureJSONInner;
|
|
372
395
|
private ensureJSON;
|
|
@@ -685,7 +708,6 @@ export declare class Utils {
|
|
|
685
708
|
static getEnumConstants<E extends string | number>(enumClass: {
|
|
686
709
|
[x: string]: E;
|
|
687
710
|
}): E[];
|
|
688
|
-
static presentOrDefault<T>(value: T | undefined, defaultValue: T): T;
|
|
689
711
|
/**
|
|
690
712
|
* Generates a random integer
|
|
691
713
|
* between 0 (inclusive) and `to` (exclusive)
|
|
@@ -718,6 +740,7 @@ export declare class Utils {
|
|
|
718
740
|
* @returns a random element
|
|
719
741
|
*/
|
|
720
742
|
static pickRandomElement<T>(array: T[]): T;
|
|
743
|
+
static withDefaults<D extends object>(data: D, defaults: D): D;
|
|
721
744
|
}
|
|
722
745
|
export declare class ZipPluginArchive extends PluginArchive {
|
|
723
746
|
private zip;
|
|
@@ -794,6 +817,15 @@ export declare namespace Registry {
|
|
|
794
817
|
function withDefaultOptions(options?: Partial<RegistryOptions>): RegistryOptions;
|
|
795
818
|
function withPublicDefaultOptions(options?: Partial<RegistryOptions>): PublicRegistryOptions;
|
|
796
819
|
}
|
|
820
|
+
export interface C2PHelloRequestPacket extends NoncePacket {
|
|
821
|
+
id: "thread:hello_request";
|
|
822
|
+
threadId: string;
|
|
823
|
+
pluginKey: string;
|
|
824
|
+
scriptUrl: string;
|
|
825
|
+
}
|
|
826
|
+
export interface C2PShutdownRequestPacket extends NoncePacket {
|
|
827
|
+
id: "thread:shutdown_request";
|
|
828
|
+
}
|
|
797
829
|
export interface DevPluginSourceR2SHelloRPackPacket {
|
|
798
830
|
id: "hello_request_rpack";
|
|
799
831
|
rpackChannel: string;
|
|
@@ -841,14 +873,18 @@ export interface DevPluginSourceServerManifest {
|
|
|
841
873
|
};
|
|
842
874
|
websocketRefresh?: boolean;
|
|
843
875
|
}
|
|
844
|
-
export interface
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
876
|
+
export interface EnvironmentInfo {
|
|
877
|
+
isPluginThread(): boolean;
|
|
878
|
+
isHost(): boolean;
|
|
879
|
+
isClient(): boolean;
|
|
880
|
+
getEnvironmentType(): EnvironmentType;
|
|
881
|
+
getThreadId(): string;
|
|
849
882
|
}
|
|
850
|
-
export interface
|
|
851
|
-
|
|
883
|
+
export interface MessageTarget<T = any> {
|
|
884
|
+
postMessage(message: any, options?: {
|
|
885
|
+
transfer?: T[];
|
|
886
|
+
}): void;
|
|
887
|
+
onmessage: ((event: MessageEvent<any>) => void) | null;
|
|
852
888
|
}
|
|
853
889
|
export interface MultiSetRegistry<Data, Key extends JSONLike = string> extends RegistryBase {
|
|
854
890
|
append(key: Key, value: Data): Promise<string>;
|
|
@@ -869,6 +905,15 @@ export interface MultiSetRegistryEntry<Data, Key extends JSONLike> {
|
|
|
869
905
|
export interface NoncePacket {
|
|
870
906
|
nonce: string;
|
|
871
907
|
}
|
|
908
|
+
export interface P2CHelloResponsePacket extends NoncePacket {
|
|
909
|
+
id: "thread:hello_response";
|
|
910
|
+
}
|
|
911
|
+
export interface P2CPluginLoadPacket extends NoncePacket {
|
|
912
|
+
id: "thread:plugin_load";
|
|
913
|
+
}
|
|
914
|
+
export interface P2CShutdownResponsePacket extends NoncePacket {
|
|
915
|
+
id: "thread:shutdown_response";
|
|
916
|
+
}
|
|
872
917
|
export interface Packet {
|
|
873
918
|
id: string;
|
|
874
919
|
}
|
|
@@ -1154,19 +1199,14 @@ export interface TableOptions<N extends number> {
|
|
|
1154
1199
|
padding?: string;
|
|
1155
1200
|
textAlign?: "left" | "center" | "right";
|
|
1156
1201
|
}
|
|
1157
|
-
export interface W2HHelloResponsePacket extends NoncePacket {
|
|
1158
|
-
id: "thread:hello_response";
|
|
1159
|
-
}
|
|
1160
|
-
export interface W2HPluginLoadPacket extends NoncePacket {
|
|
1161
|
-
id: "thread:plugin_load";
|
|
1162
|
-
}
|
|
1163
|
-
export interface W2HShutdownResponsePacket extends NoncePacket {
|
|
1164
|
-
id: "thread:shutdown_response";
|
|
1165
|
-
}
|
|
1166
1202
|
export type BatchResult<T> = {
|
|
1167
1203
|
done: boolean;
|
|
1168
1204
|
values: T[];
|
|
1169
1205
|
};
|
|
1206
|
+
export type C2PPackets = {
|
|
1207
|
+
"thread:hello_request": C2PHelloRequestPacket;
|
|
1208
|
+
"thread:shutdown_request": C2PShutdownRequestPacket;
|
|
1209
|
+
} & ProxyPackets & RegistryPackets;
|
|
1170
1210
|
/**
|
|
1171
1211
|
* A type alias representing a constructor signature for creating instances of type `T`.
|
|
1172
1212
|
*
|
|
@@ -1187,6 +1227,7 @@ export type DeserializedFilter<T> = Pick<T, {
|
|
|
1187
1227
|
[K in keyof T]: T[K] extends ((...args: infer P) => Promise<Serializable | void>) ? P extends [
|
|
1188
1228
|
] ? K : P[number] extends Serializable ? K : never : never;
|
|
1189
1229
|
}[keyof T]>;
|
|
1230
|
+
export type EnvironmentType = "host" | "client";
|
|
1190
1231
|
export type ErrorType = Error | EvalError | RangeError | ReferenceError | SyntaxError | TypeError | URIError;
|
|
1191
1232
|
export type FixedLengthArray<T, L extends number, TObj = [
|
|
1192
1233
|
T,
|
|
@@ -1196,14 +1237,10 @@ export type FixedLengthArray<T, L extends number, TObj = [
|
|
|
1196
1237
|
[I: number]: T;
|
|
1197
1238
|
[Symbol.iterator]: () => IterableIterator<T>;
|
|
1198
1239
|
};
|
|
1199
|
-
export type H2WPackets = {
|
|
1200
|
-
"thread:hello_request": H2WHelloRequestPacket;
|
|
1201
|
-
"thread:shutdown_request": H2WShutdownRequestPacket;
|
|
1202
|
-
} & ProxyPackets & RegistryPackets;
|
|
1203
1240
|
export type JSONLike = string | number | boolean | null | {
|
|
1204
1241
|
[key: string]: JSONLike;
|
|
1205
1242
|
} | JSONLike[];
|
|
1206
|
-
export type KnownModules = "@rpack-dev/core" | "@rpack-dev/platform-browser";
|
|
1243
|
+
export type KnownModules = "@rpack-dev/core" | "@rpack-dev/platform-browser/bridge" | "@rpack-dev/platform-browser/worker";
|
|
1207
1244
|
export type MappedDeserializedData<T> = T extends SerializedUndefined ? undefined : T extends SerializedJSON ? JSONLike : T extends SerializedRegistry ? Registry<any, any> : T extends SerializedError ? ErrorType : T extends SerializedObject ? SerializableObject : T extends SerializedRegistryEntry ? RegistryObject<any> : T extends SerializedFunction ? SerializableFunction : T extends {
|
|
1208
1245
|
"type": "well_known";
|
|
1209
1246
|
"kind": "RPack";
|
|
@@ -1236,6 +1273,11 @@ export type OnlyNoncePacketTypes<Packets extends PacketsType<Packets>> = {
|
|
|
1236
1273
|
export type OnlyNoncePackets<Packets extends PacketsType<Packets>> = {
|
|
1237
1274
|
[Key in OnlyNoncePacketTypes<Packets>]: Packets[Key] & NoncePacket;
|
|
1238
1275
|
};
|
|
1276
|
+
export type P2CPackets = {
|
|
1277
|
+
"thread:hello_response": P2CHelloResponsePacket;
|
|
1278
|
+
"thread:plugin_load": P2CPluginLoadPacket;
|
|
1279
|
+
"thread:shutdown_response": P2CShutdownResponsePacket;
|
|
1280
|
+
} & ProxyPackets & RegistryPackets;
|
|
1239
1281
|
export type PacketHandler<T> = (packet: T) => unknown | false;
|
|
1240
1282
|
export type PacketHandlers<T> = {
|
|
1241
1283
|
[Key in keyof T]?: (T[Key] extends void ? () => (void | false) : PacketHandler<T[Key]>)[];
|
|
@@ -1250,11 +1292,10 @@ export type PromisesOnly<T> = {
|
|
|
1250
1292
|
export type ProxyCleanupTarget = "object" | "iterator" | "array" | "function";
|
|
1251
1293
|
export type PublicRegistryOptions = typeof DefaultPublicRegistryOptions;
|
|
1252
1294
|
export type RPackConstructorOptions = {
|
|
1253
|
-
pluginThread: boolean;
|
|
1254
1295
|
loadPromise: Promise<void>;
|
|
1296
|
+
environment: EnvironmentInfo;
|
|
1255
1297
|
platform: RPPlatform;
|
|
1256
|
-
|
|
1257
|
-
hostMessenger?: Messenger<H2WPackets, W2HPackets>;
|
|
1298
|
+
hostMessenger?: Messenger<C2PPackets, P2CPackets>;
|
|
1258
1299
|
version: RPVersion;
|
|
1259
1300
|
};
|
|
1260
1301
|
export type RegistryDataFiltered<Data> = Data extends Serializable ? Data : {
|
|
@@ -1272,11 +1313,6 @@ export type Serializable = undefined | JSONLike | RegistryType | ErrorType | Wel
|
|
|
1272
1313
|
export type SerializableFunction = (...args: Serializable[]) => Promise<Serializable>;
|
|
1273
1314
|
export type SerializableObject = Record<string, SerializableFunction>;
|
|
1274
1315
|
export type SerializedData = SerializedUndefined | SerializedJSON | SerializedRegistry | SerializedError | SerializedObject | SerializedFunction | SerializedWellKnown;
|
|
1275
|
-
export type W2HPackets = {
|
|
1276
|
-
"thread:hello_response": W2HHelloResponsePacket;
|
|
1277
|
-
"thread:plugin_load": W2HPluginLoadPacket;
|
|
1278
|
-
"thread:shutdown_response": W2HShutdownResponsePacket;
|
|
1279
|
-
} & ProxyPackets & RegistryPackets;
|
|
1280
1316
|
export type WellKnownType = RPack | NetworkManager | ProxyManager | RegistryManager;
|
|
1281
1317
|
|
|
1282
1318
|
export {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpack-dev/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20-e0d3509",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "LGPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/rpack-dev/rpack-dev.git"
|
|
9
9
|
},
|
|
10
|
+
"sideEffects": false,
|
|
10
11
|
"scripts": {
|
|
11
12
|
"test": "tsx node_modules/jasmine/bin/jasmine --config=jasmine.json",
|
|
12
13
|
"prebuild:barrel": "ctix build",
|