@module-federation/dts-plugin 0.1.4 → 0.1.5

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.
@@ -1,105 +0,0 @@
1
- "use strict";
2
- (() => {
3
- // node_modules/.pnpm/isomorphic-ws@5.0.0_ws@8.5.0/node_modules/isomorphic-ws/browser.js
4
- var ws = null;
5
- if (typeof WebSocket !== "undefined") {
6
- ws = WebSocket;
7
- } else if (typeof MozWebSocket !== "undefined") {
8
- ws = MozWebSocket;
9
- } else if (typeof global !== "undefined") {
10
- ws = global.WebSocket || global.MozWebSocket;
11
- } else if (typeof window !== "undefined") {
12
- ws = window.WebSocket || window.MozWebSocket;
13
- } else if (typeof self !== "undefined") {
14
- ws = self.WebSocket || self.MozWebSocket;
15
- }
16
- var browser_default = ws;
17
-
18
- // packages/dts-plugin/src/server/constant.ts
19
- var DEFAULT_WEB_SOCKET_PORT = 16322;
20
- var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
21
-
22
- // packages/dts-plugin/src/server/message/Message.ts
23
- var Message = class {
24
- constructor(type, kind) {
25
- this.type = type;
26
- this.kind = kind;
27
- this.time = Date.now();
28
- }
29
- };
30
-
31
- // packages/dts-plugin/src/server/message/Action/Action.ts
32
- var Action = class extends Message {
33
- constructor(content, kind) {
34
- super("Action", kind);
35
- const { payload } = content;
36
- this.payload = payload;
37
- }
38
- };
39
-
40
- // packages/dts-plugin/src/server/message/Action/AddWebClient.ts
41
- var AddWebClientAction = class extends Action {
42
- constructor(payload) {
43
- super(
44
- {
45
- payload
46
- },
47
- "ADD_WEB_CLIENT" /* ADD_WEB_CLIENT */
48
- );
49
- }
50
- };
51
-
52
- // packages/dts-plugin/src/server/WebClient.ts
53
- var WebClient = class {
54
- constructor(options) {
55
- this._webSocket = null;
56
- this._name = options.name;
57
- this.logPrefix = options.logPrefix || "";
58
- this._connect();
59
- }
60
- _connect() {
61
- console.log(
62
- `${this.logPrefix}Trying to connect to {cyan ws://127.0.0.1:${DEFAULT_WEB_SOCKET_PORT}}...}`
63
- );
64
- this._webSocket = new browser_default(
65
- `ws://127.0.0.1:${DEFAULT_WEB_SOCKET_PORT}?WEB_SOCKET_CONNECT_MAGIC_ID=${WEB_SOCKET_CONNECT_MAGIC_ID}`
66
- );
67
- this._webSocket.onopen = () => {
68
- console.log(
69
- `${this.logPrefix}Connected to {cyan ws://127.0.0.1:${DEFAULT_WEB_SOCKET_PORT}} success!`
70
- );
71
- const startWebClient = new AddWebClientAction({
72
- name: this._name
73
- });
74
- this._webSocket && this._webSocket.send(JSON.stringify(startWebClient));
75
- };
76
- this._webSocket.onmessage = (message) => {
77
- console.log(message);
78
- const parsedMessage = JSON.parse(
79
- message.data.toString()
80
- );
81
- if (parsedMessage.type === "API") {
82
- if (parsedMessage.kind === "RELOAD_WEB_CLIENT" /* RELOAD_WEB_CLIENT */) {
83
- const {
84
- payload: { name }
85
- } = parsedMessage;
86
- if (name !== this._name) {
87
- return;
88
- }
89
- this._reload();
90
- }
91
- }
92
- };
93
- this._webSocket.onerror = (err) => {
94
- console.error(`${this.logPrefix}err: ${err}`);
95
- };
96
- }
97
- _reload() {
98
- console.log(`${this.logPrefix}reload`);
99
- location.reload();
100
- }
101
- };
102
-
103
- // packages/dts-plugin/src/server/launchWebClient.ts
104
- new WebClient(__WEB_CLIENT_OPTIONS__);
105
- })();
package/dist/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { WebpackPluginInstance, Compiler } from 'webpack';
2
- import { moduleFederationPlugin } from '@module-federation/sdk';
3
-
4
- declare class DtsPlugin implements WebpackPluginInstance {
5
- options: moduleFederationPlugin.ModuleFederationPluginOptions;
6
- constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
7
- apply(compiler: Compiler): void;
8
- }
9
-
10
- export { DtsPlugin };