@lwc/hmr-client 10.0.0 → 10.0.1-test.267
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/__tests__/api.spec.d.ts +1 -0
- package/dist/client/client.d.ts +38 -0
- package/dist/client/hot-module-handler.d.ts +16 -0
- package/dist/client/index.d.ts +18 -0
- package/dist/client/index.spec.d.ts +1 -0
- package/dist/consoleLogger.d.ts +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/json-web-socket.d.ts +11 -0
- package/dist/utils/module-util.d.ts +10 -0
- package/dist/utils/typed-event-target.d.ts +14 -0
- package/dist/utils/typed-event-target.spec.d.ts +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import JSONWebSocket from '../utils/json-web-socket';
|
|
2
|
+
import { TypedEventTarget } from '../utils/typed-event-target';
|
|
3
|
+
import { HotModuleHandler } from './hot-module-handler';
|
|
4
|
+
type HmrClientEvent = {
|
|
5
|
+
modulePath: string;
|
|
6
|
+
};
|
|
7
|
+
type HmrClientEvents = {
|
|
8
|
+
'hmr:update': HmrClientEvent;
|
|
9
|
+
'hmr:delete': HmrClientEvent;
|
|
10
|
+
'hmr:create': HmrClientEvent;
|
|
11
|
+
'hmr:hot-swapped': HmrClientEvent;
|
|
12
|
+
'hmr:close': void;
|
|
13
|
+
};
|
|
14
|
+
export declare class HMRClient {
|
|
15
|
+
moduleHandlerHooks: HotModuleHandler;
|
|
16
|
+
ws: JSONWebSocket;
|
|
17
|
+
private eventTarget;
|
|
18
|
+
constructor(ws: JSONWebSocket, moduleHandlerHooks: HotModuleHandler);
|
|
19
|
+
/**
|
|
20
|
+
* Register all modules that have been registered at this point.
|
|
21
|
+
* This function is usually called upon hmr-client initialization.
|
|
22
|
+
*/
|
|
23
|
+
registerAllModules(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Register any new modules that have been registered.
|
|
26
|
+
*/
|
|
27
|
+
registerPendingModules(): void;
|
|
28
|
+
messageCallback(data: unknown): void;
|
|
29
|
+
/**
|
|
30
|
+
* Send a message to the dev server to send a hot module.
|
|
31
|
+
* The send and receive messages are asyncronous.
|
|
32
|
+
* @param modulePath the module to be fetched
|
|
33
|
+
*/
|
|
34
|
+
fetchModule(modulePath: string): void;
|
|
35
|
+
addEventListener: TypedEventTarget<HmrClientEvents>['addEventListener'];
|
|
36
|
+
removeEventListener: TypedEventTarget<HmrClientEvents>['removeEventListener'];
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This interface defines capabilities that need to be implemented by the container to handle hot module
|
|
3
|
+
* updates.
|
|
4
|
+
*/
|
|
5
|
+
export interface HotModuleHandler {
|
|
6
|
+
/**
|
|
7
|
+
* Fetch all dependencies that are required for a hot module before its evaluation.
|
|
8
|
+
* @param moduleSpecifiers List of dependent modules specifiers.
|
|
9
|
+
*/
|
|
10
|
+
fetchDependencies(moduleSpecifiers: string[]): Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Evalaute a given Javascript source code.
|
|
13
|
+
* @param source Javascript in string format.
|
|
14
|
+
*/
|
|
15
|
+
evaluateModule(ownerModuleId: string, hotModulePath: string, source: string): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Auth_Challenge, Auth_Response } from '@lwc/lwc-dev-server-types';
|
|
2
|
+
import { HotModuleHandler } from './hot-module-handler';
|
|
3
|
+
import { HMRClient } from './client';
|
|
4
|
+
type AuthConfig = {
|
|
5
|
+
authChallengeData: Auth_Challenge;
|
|
6
|
+
authResponseCallback: (response: Auth_Response) => boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the hmr-client.
|
|
10
|
+
* @param url The lightning dev preview server to connect to. Provide the fully qualified WebSocketServer url, for example 'wss://localhost:8999'
|
|
11
|
+
* @param target The type of client being served. Currently only supports 'LEX.
|
|
12
|
+
* @param hotModuleHandler Callback hooks that the hmr-client will utilize to handle hot modules. The callbacks are implemented by the container.
|
|
13
|
+
* @param authConfig Optional authentication configuration if the hmr-client needs to establish an authenticated connection.
|
|
14
|
+
*
|
|
15
|
+
* @returns {HMRClient} the HMR Client
|
|
16
|
+
*/
|
|
17
|
+
export declare function initializeClient(url: string, _target: string, hotModuleHandler: HotModuleHandler, authConfig?: AuthConfig): Promise<HMRClient>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function debounce(callback: Function, delay: number): () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper on WebSocket to handle JSON serialization/deserialization
|
|
3
|
+
*/
|
|
4
|
+
export default class JSONWebSocket {
|
|
5
|
+
socket: WebSocket;
|
|
6
|
+
private constructor();
|
|
7
|
+
send(data: object): void;
|
|
8
|
+
onMessage(callback: (data: unknown) => void): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
static init(url: string, protocols?: string[] | string): Promise<JSONWebSocket>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function extractDescriptorsFromSource(src: string): {
|
|
2
|
+
parentDescriptor: string;
|
|
3
|
+
deps: string[];
|
|
4
|
+
} | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Adapt source provided by dev server to LEX format.
|
|
7
|
+
* Note: This logic comes from [core:]BundleModuleDefFactory.processCompiledCode()
|
|
8
|
+
* @param src compiled module file
|
|
9
|
+
*/
|
|
10
|
+
export declare function adaptSourceForLex(src: string, hotModulePath: string, parentDescriptor: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type NonVoidKeys<T> = {
|
|
2
|
+
[P in keyof T]: T[P] extends void ? P : never;
|
|
3
|
+
}[keyof T];
|
|
4
|
+
export declare class TypedEventTarget<T extends {
|
|
5
|
+
[k: string]: any;
|
|
6
|
+
}> {
|
|
7
|
+
#private;
|
|
8
|
+
constructor();
|
|
9
|
+
addEventListener<K extends Extract<keyof T, string>>(type: K, listener: (event: CustomEvent<T[K]>) => void): void;
|
|
10
|
+
removeEventListener<K extends Extract<keyof T, string>>(type: K, listener: (event: CustomEvent<T[K]>) => void): void;
|
|
11
|
+
dispatch<K extends NonVoidKeys<T>>(type: K): boolean;
|
|
12
|
+
dispatch<K extends Extract<keyof T, string>>(type: K, detail: T[K]): boolean;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/hmr-client",
|
|
3
3
|
"description": "Provide hot module reloading capabilities to @lwc/engine-dom.",
|
|
4
|
-
"version": "10.0.
|
|
4
|
+
"version": "10.0.1-test.267+03d683d",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lwc dev server",
|
|
7
7
|
"lwc hmr plugin"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"clean": "rimraf dist/ && rimraf node_modules/"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@lwc/lwc-dev-server-types": "10.0.
|
|
22
|
+
"@lwc/lwc-dev-server-types": "10.0.1-test.267+03d683d",
|
|
23
23
|
"@types/websocket": "^1.0.10"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -35,5 +35,6 @@
|
|
|
35
35
|
"expose": [
|
|
36
36
|
"@lwc/hmr-client"
|
|
37
37
|
]
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "03d683dddcb5e7bb2e7eb92393df32432c1cd661"
|
|
39
40
|
}
|