@rpack-dev/core 0.2.0-canary.2 → 0.2.0-canary.4
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 +14760 -13141
- package/dist/rpack-core-esm.bundle.js +1 -1
- package/dist/rpack-core-umd.bundle.js +1 -1
- package/dist/rpack-core.d.ts +85 -33
- package/package.json +1 -1
package/dist/rpack-core.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare class RPack {
|
|
|
24
24
|
private readonly platform;
|
|
25
25
|
private readonly version;
|
|
26
26
|
private lateInitCallbacks;
|
|
27
|
+
private readonly hostManager;
|
|
27
28
|
private readonly threadManager;
|
|
28
29
|
private readonly permissionManager;
|
|
29
30
|
private readonly proxyManager;
|
|
@@ -47,6 +48,13 @@ declare class RPack {
|
|
|
47
48
|
* @return an RPVersion instance
|
|
48
49
|
*/
|
|
49
50
|
getVersion(): RPVersion;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the current HostManager instance.
|
|
53
|
+
*
|
|
54
|
+
* This class is used when dealing with the host environment.
|
|
55
|
+
* It can also be used to create an embedded host instance.
|
|
56
|
+
*/
|
|
57
|
+
getHostManager(): HostManager;
|
|
50
58
|
/**
|
|
51
59
|
* Retrieves the current ThreadManager instance.
|
|
52
60
|
*
|
|
@@ -80,6 +88,7 @@ declare class RPack {
|
|
|
80
88
|
isPluginThread(): boolean;
|
|
81
89
|
isHost(): boolean;
|
|
82
90
|
isClient(): boolean;
|
|
91
|
+
getHost(): RPackHost | undefined;
|
|
83
92
|
/**
|
|
84
93
|
* Shorthand for getNetworkManager().getPlugin().
|
|
85
94
|
*
|
|
@@ -105,6 +114,7 @@ export declare abstract class RPPlatform {
|
|
|
105
114
|
private readonly id;
|
|
106
115
|
protected constructor(id: string);
|
|
107
116
|
abstract createRPackInstance(constructor: (options: RPackConstructorOptions) => Promise<RPack>): Promise<RPack>;
|
|
117
|
+
abstract createEmbeddedHost(): Promise<HostCreateResult>;
|
|
108
118
|
abstract createRPackThread(threadId: string, pluginKey: string): Promise<RPackLocalThread>;
|
|
109
119
|
abstract restart(): void;
|
|
110
120
|
abstract addWindowFocusHandler(handler: () => void): void;
|
|
@@ -298,6 +308,20 @@ export declare class DevPluginSource implements PluginSource {
|
|
|
298
308
|
getPluginArchive(groupId: string, pluginId: string, version: string): Promise<PluginArchive>;
|
|
299
309
|
removeServer(client: DevPluginServerClient): void;
|
|
300
310
|
}
|
|
311
|
+
export declare class HostManager {
|
|
312
|
+
private readonly rpack;
|
|
313
|
+
private connectedHost;
|
|
314
|
+
private readonly localInstance?;
|
|
315
|
+
constructor(rpack: RPack, localInstance?: RPackHost);
|
|
316
|
+
getRPack(): RPack;
|
|
317
|
+
createEmbeddedHost(): Promise<RPackHost>;
|
|
318
|
+
getClientId(): string | undefined;
|
|
319
|
+
/**
|
|
320
|
+
* Returns the current RPackHost instance.
|
|
321
|
+
*/
|
|
322
|
+
getHost(): RPackHost | undefined;
|
|
323
|
+
disconnect(): Promise<void>;
|
|
324
|
+
}
|
|
301
325
|
export declare class IteratorHelper<T, TReturn = undefined, TNext = unknown> implements IteratorObject<T, TReturn, TNext>, Iterator<T, TReturn, TNext>, Disposable {
|
|
302
326
|
private it;
|
|
303
327
|
private disposed;
|
|
@@ -470,18 +494,6 @@ export declare class LocalRemoteMap<Local, Remote> {
|
|
|
470
494
|
hasRemote(key: string): boolean;
|
|
471
495
|
deleteRemote(key: string): boolean;
|
|
472
496
|
}
|
|
473
|
-
export declare class MappedIterator<T, K> implements IterableIterator<K> {
|
|
474
|
-
private readonly it;
|
|
475
|
-
private readonly map;
|
|
476
|
-
constructor(it: Iterator<T>, map: (t: T) => K);
|
|
477
|
-
[Symbol.iterator](): IterableIterator<K>;
|
|
478
|
-
next(...args: [
|
|
479
|
-
] | [
|
|
480
|
-
any
|
|
481
|
-
]): IteratorResult<K>;
|
|
482
|
-
return(value?: any): IteratorResult<K>;
|
|
483
|
-
throw(e?: any): IteratorResult<K>;
|
|
484
|
-
}
|
|
485
497
|
export declare class Messenger<InPackets extends PacketsType<InPackets>, OutPackets extends PacketsType<OutPackets>> {
|
|
486
498
|
private readonly handlerLists;
|
|
487
499
|
private readonly sender;
|
|
@@ -497,9 +509,20 @@ export declare class Messenger<InPackets extends PacketsType<InPackets>, OutPack
|
|
|
497
509
|
removeHandler<K extends keyof InPackets>(key: K, handler: PacketHandler<InPackets[K]>): boolean;
|
|
498
510
|
private promiseHandlerImpl;
|
|
499
511
|
addPromiseNonceHandler<K extends keyof OnlyNoncePackets<InPackets>>(key: K, nonce: string, timeout?: number): Promise<InPackets[K]>;
|
|
512
|
+
addResponsePromiseNonceHandler<K extends keyof OnlyResponsePackets<InPackets>>(key: K, nonce: string, timeout?: number): Promise<ResponsePacketValue<InPackets[K]>>;
|
|
500
513
|
addPromiseHandler<K extends keyof InPackets>(key: K, timeout?: number): Promise<InPackets[K]>;
|
|
501
514
|
receivePacket<K extends keyof InPackets>(packet: InPackets[K]): void;
|
|
502
515
|
sendPacket<K extends keyof OutPackets>(packet: OutPackets[K]): void;
|
|
516
|
+
sendNoncePacket<O extends keyof OnlyNoncePackets<OutPackets>>(outPacketKey: O, outPacket: Omit<OutPackets[O], "nonce" | "id">): SentNoncePacket<InPackets, OutPackets>;
|
|
517
|
+
/**
|
|
518
|
+
* Sends a packet with a nonce, and expects a response packet with the same nonce.
|
|
519
|
+
* @param outPacketKey the outgoing packet's id
|
|
520
|
+
* @param outPacket the outgoing packet (without some fields such as `id` and `nonce`)
|
|
521
|
+
* @param inPacket the incoming packet's id
|
|
522
|
+
* @param timeout an optional timeout
|
|
523
|
+
*
|
|
524
|
+
* @deprecated use {@link sendNoncePacket `sendNoncePacket(outPacketKey, outPacket)`}`.`{@link SentNoncePacket.expect `expect(inPacket, timeout)`}
|
|
525
|
+
*/
|
|
503
526
|
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]>;
|
|
504
527
|
/**
|
|
505
528
|
* Shorthand for sending a response packet that has a value with the messenger.
|
|
@@ -746,6 +769,7 @@ export declare class RemoteObject<T extends object> implements ProxyHandler<T> {
|
|
|
746
769
|
}
|
|
747
770
|
export declare class RemoteProxyManager {
|
|
748
771
|
private readonly parent;
|
|
772
|
+
private readonly rpack;
|
|
749
773
|
private readonly thread;
|
|
750
774
|
private readonly messenger;
|
|
751
775
|
private readonly objects;
|
|
@@ -846,6 +870,13 @@ export declare class RemoteRegistryManager {
|
|
|
846
870
|
requestGetAllEntries<Data, Key extends JSONLike>(registryId: string, executingThread: Thread | null, ownerThread?: Thread): RemoteAsyncIterator<RegistryEntry<Data, Key>>;
|
|
847
871
|
requestGetAll<Data>(registryId: string, executingThread: Thread | null, ownerThread?: Thread): RemoteAsyncIterator<Data>;
|
|
848
872
|
}
|
|
873
|
+
export declare class SentNoncePacket<InPackets extends PacketsType<InPackets>, OutPackets extends PacketsType<OutPackets>> {
|
|
874
|
+
private readonly messenger;
|
|
875
|
+
private readonly nonce;
|
|
876
|
+
constructor(messenger: Messenger<InPackets, OutPackets>, nonce: string);
|
|
877
|
+
expect<I extends keyof OnlyNoncePackets<InPackets>>(inPacket: I, timeout?: number): Promise<InPackets[I]>;
|
|
878
|
+
expectResponse<I extends keyof OnlyResponsePackets<InPackets>>(inPacket: I, timeout?: number, rpack?: RPack, thread?: Thread): Promise<ResponsePacketValue<InPackets[I]>>;
|
|
879
|
+
}
|
|
849
880
|
export declare class SerializationManager {
|
|
850
881
|
private readonly rpack;
|
|
851
882
|
private readonly wellKnownMap;
|
|
@@ -861,6 +892,9 @@ export declare class SerializationManager {
|
|
|
861
892
|
}): MappedSerializedData<T>;
|
|
862
893
|
deserialize<T extends RegistrySerializedData>(thread: Thread, serialized: T): MappedDeserializedData<T>;
|
|
863
894
|
}
|
|
895
|
+
export declare class SerializationUtils {
|
|
896
|
+
static deserializeStatic<T extends RegistrySerializedData>(serialized: T): MappedDeserializedData<T>;
|
|
897
|
+
}
|
|
864
898
|
/**
|
|
865
899
|
* A collection of string-related utilities.
|
|
866
900
|
*/
|
|
@@ -887,22 +921,29 @@ export declare class StringUtils {
|
|
|
887
921
|
* to check for permissions.
|
|
888
922
|
*
|
|
889
923
|
* If this is run in a client environment, and the target thread represents a local client thread,
|
|
890
|
-
* {@link isClient isClient()} will return `true`, but {@link getClientId getClientId()}
|
|
924
|
+
* {@link isClient isClient()} will return `true`, but {@link getClientId getClientId()} may return
|
|
925
|
+
* `undefined` (if the client is not connected to a host). Use {@link isLocal isLocal()} to check
|
|
926
|
+
* whether this Thread object is referring to a local thread.
|
|
927
|
+
*
|
|
928
|
+
* When referring to a thread in the host environment ({@link isHost isHost()} returned true), then
|
|
929
|
+
* the {@link getClientId getClientId()} will return `undefined`.
|
|
891
930
|
*
|
|
892
931
|
* Note that this class does not represent any state; it is purely
|
|
893
932
|
* for convenient access to this information and the relevant methods.
|
|
894
933
|
*/
|
|
895
934
|
export declare class Thread {
|
|
896
935
|
private readonly rpack;
|
|
936
|
+
private readonly environment;
|
|
897
937
|
private readonly threadId;
|
|
898
|
-
private readonly clientId
|
|
938
|
+
private readonly clientId;
|
|
899
939
|
/**
|
|
900
940
|
* Creates a new NetworkThread
|
|
901
941
|
* @param rpack the RPack instance
|
|
902
942
|
* @param threadId the thread ID on the host or client
|
|
903
|
-
* @param clientId an optional client ID (
|
|
943
|
+
* @param clientId an optional client ID (absent when referring to the host or the local client), represents which client this thread is on
|
|
944
|
+
* @param environment the environment of this thread
|
|
904
945
|
*/
|
|
905
|
-
constructor(rpack: RPack, threadId: string, clientId?: string);
|
|
946
|
+
constructor(rpack: RPack, environment: EnvironmentType, threadId: string, clientId?: string);
|
|
906
947
|
/**
|
|
907
948
|
* Determines whether this thread is from the host.
|
|
908
949
|
*
|
|
@@ -916,6 +957,12 @@ export declare class Thread {
|
|
|
916
957
|
* @return `true` if this is a client thread, `false` otherwise
|
|
917
958
|
*/
|
|
918
959
|
isClient(): boolean;
|
|
960
|
+
/**
|
|
961
|
+
* Retrieves the environment of this thread.
|
|
962
|
+
*
|
|
963
|
+
* @return the environment of this thread
|
|
964
|
+
*/
|
|
965
|
+
getEnvironmentType(): EnvironmentType;
|
|
919
966
|
/**
|
|
920
967
|
* Determines if this thread is from the current environment.
|
|
921
968
|
*
|
|
@@ -980,7 +1027,7 @@ export declare class ThreadManager {
|
|
|
980
1027
|
constructor(rpack: RPack);
|
|
981
1028
|
getLocalThread(threadId: string): Thread;
|
|
982
1029
|
getThread(serialized: RawThread): Thread;
|
|
983
|
-
getThread(threadId: string, clientId?: string): Thread;
|
|
1030
|
+
getThread(environment: EnvironmentType, threadId: string, clientId?: string): Thread;
|
|
984
1031
|
getCurrentThread(): Thread;
|
|
985
1032
|
getLocalCoreThread(): Thread;
|
|
986
1033
|
private __handleSharedPackets;
|
|
@@ -1285,13 +1332,6 @@ export interface EnvironmentInfo {
|
|
|
1285
1332
|
* Returns the current Thread ID.
|
|
1286
1333
|
*/
|
|
1287
1334
|
getThreadId(): string;
|
|
1288
|
-
/**
|
|
1289
|
-
* Returns the current client ID.
|
|
1290
|
-
*
|
|
1291
|
-
* If this method is called from a host environment,
|
|
1292
|
-
* then it will return `undefined`.
|
|
1293
|
-
*/
|
|
1294
|
-
getClientId(): string | undefined;
|
|
1295
1335
|
/**
|
|
1296
1336
|
* Returns the Messenger instance used to
|
|
1297
1337
|
* communicate with the current core thread.
|
|
@@ -1308,10 +1348,6 @@ export interface EnvironmentInfo {
|
|
|
1308
1348
|
*/
|
|
1309
1349
|
getHostMessenger(): Messenger<H2CPackets, C2HPackets> | null;
|
|
1310
1350
|
}
|
|
1311
|
-
export interface H2CHelloResponsePacket extends NoncePacket {
|
|
1312
|
-
id: "host:hello_response";
|
|
1313
|
-
accepted: boolean;
|
|
1314
|
-
}
|
|
1315
1351
|
export interface H2CHostPackets {
|
|
1316
1352
|
"host:hello_response": H2CHelloResponsePacket;
|
|
1317
1353
|
}
|
|
@@ -1320,6 +1356,10 @@ export interface Host {
|
|
|
1320
1356
|
perm: string;
|
|
1321
1357
|
threadId?: string;
|
|
1322
1358
|
}
|
|
1359
|
+
export interface HostCreateResult {
|
|
1360
|
+
host: RPackHost;
|
|
1361
|
+
messenger: Messenger<H2CPackets, C2HPackets>;
|
|
1362
|
+
}
|
|
1323
1363
|
export interface Local {
|
|
1324
1364
|
type: "local";
|
|
1325
1365
|
perm: string;
|
|
@@ -1485,8 +1525,10 @@ export interface ProxyIteratorNextRequestPacket extends NoncePacket {
|
|
|
1485
1525
|
}
|
|
1486
1526
|
export interface ProxyIteratorNextResponsePacket extends NoncePacket {
|
|
1487
1527
|
id: "proxy:iterator_next_response";
|
|
1488
|
-
|
|
1489
|
-
|
|
1528
|
+
value?: {
|
|
1529
|
+
done: boolean;
|
|
1530
|
+
value: SerializedData;
|
|
1531
|
+
};
|
|
1490
1532
|
error?: SerializedData;
|
|
1491
1533
|
}
|
|
1492
1534
|
export interface ProxyMethodRequestPacket extends NoncePacket {
|
|
@@ -1524,8 +1566,11 @@ export interface ProxyRefreshObjectResponsePacket extends NoncePacket {
|
|
|
1524
1566
|
error?: SerializedData;
|
|
1525
1567
|
}
|
|
1526
1568
|
export interface RPackHost {
|
|
1569
|
+
isEmbedded(): boolean;
|
|
1570
|
+
disconnect(): Promise<void>;
|
|
1527
1571
|
}
|
|
1528
1572
|
export interface RawThread {
|
|
1573
|
+
environment: EnvironmentType;
|
|
1529
1574
|
threadId: string;
|
|
1530
1575
|
clientId: string | null;
|
|
1531
1576
|
}
|
|
@@ -1783,6 +1828,9 @@ export type FixedLengthArray<T, L extends number, TObj = [
|
|
|
1783
1828
|
[I: number]: T;
|
|
1784
1829
|
[Symbol.iterator]: () => IterableIterator<T>;
|
|
1785
1830
|
};
|
|
1831
|
+
export type H2CHelloResponsePacket = ResponsePacket<"host:hello_response", {
|
|
1832
|
+
clientId: string;
|
|
1833
|
+
}>;
|
|
1786
1834
|
export type H2CPackets = H2CHostPackets & ProxyPackets & RegistryPackets & PermissionPackets;
|
|
1787
1835
|
export type JSONLike = string | number | boolean | null | {
|
|
1788
1836
|
[key: string]: JSONLike;
|
|
@@ -1826,9 +1874,12 @@ export type OnlyNoncePacketTypes<Packets extends PacketsType<Packets>> = {
|
|
|
1826
1874
|
export type OnlyNoncePackets<Packets extends PacketsType<Packets>> = {
|
|
1827
1875
|
[Key in OnlyNoncePacketTypes<Packets>]: Packets[Key] & NoncePacket;
|
|
1828
1876
|
};
|
|
1829
|
-
export type OnlyResponsePacketTypes<Packets extends PacketsType<Packets>> =
|
|
1877
|
+
export type OnlyResponsePacketTypes<Packets extends PacketsType<Packets>> = {
|
|
1830
1878
|
[Key in keyof Packets]: Packets[Key] extends ResponsePacket<unknown, unknown> ? Key : never;
|
|
1831
|
-
}[keyof Packets]
|
|
1879
|
+
}[keyof Packets];
|
|
1880
|
+
export type OnlyResponsePackets<Packets extends PacketsType<Packets>> = {
|
|
1881
|
+
[Key in OnlyResponsePacketTypes<Packets>]: Packets[Key] & ResponsePacket<Key, any>;
|
|
1882
|
+
};
|
|
1832
1883
|
export type P2CCheckPermissionRequestBody = Host | Client | Local;
|
|
1833
1884
|
export type P2CCheckPermissionRequestPacket = P2CCheckPermissionRequestBody & {
|
|
1834
1885
|
id: "permission:check_permission_request";
|
|
@@ -1856,6 +1907,7 @@ export type RPackConstructorOptions = {
|
|
|
1856
1907
|
platform: RPPlatform;
|
|
1857
1908
|
hostMessenger?: Messenger<C2PPackets, P2CPackets>;
|
|
1858
1909
|
version: RPVersion;
|
|
1910
|
+
localHostInstance?: RPackHost;
|
|
1859
1911
|
};
|
|
1860
1912
|
export type RegistryDataFiltered<Data> = Data extends Serializable ? Data : {
|
|
1861
1913
|
readonly [Key in keyof Data]: Data[Key] extends Serializable ? Data[Key] : Data[Key] extends (...args: any) => Promise<any> ? Data[Key] : Data[Key] extends (...args: infer P) => infer R ? (...args: P) => Promise<R> : never;
|
|
@@ -1877,7 +1929,7 @@ export type ResponsePacket<Id, Value = SerializedData> = {
|
|
|
1877
1929
|
id: Id;
|
|
1878
1930
|
value?: Value;
|
|
1879
1931
|
error?: SerializedData;
|
|
1880
|
-
};
|
|
1932
|
+
} & NoncePacket;
|
|
1881
1933
|
export type ResponsePacketValue<T> = T extends ResponsePacket<unknown, infer Value> ? Value : never;
|
|
1882
1934
|
export type SenderFunction<T> = (packet: T[keyof T]) => void;
|
|
1883
1935
|
export type Serializable = undefined | JSONLike | RegistryType | ErrorType | WellKnownType | SerializableFunction | Thread;
|