@widy/sdk 1.0.7 → 1.0.8
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/rsBuildHotReloadPlugin.d.ts +7 -0
- package/dist/rsBuildHotReloadPlugin.d.ts.map +1 -0
- package/dist/rsBuildHotReloadPlugin.js +47 -0
- package/dist/rsBuildHotReloadPlugin.js.map +1 -0
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RsbuildPlugin } from "@rsbuild/core";
|
|
2
|
+
export declare function rsBuildHotReloadPlugin({ port, delay, entryFilePath, }: {
|
|
3
|
+
port?: number;
|
|
4
|
+
delay?: number;
|
|
5
|
+
entryFilePath: string;
|
|
6
|
+
}): RsbuildPlugin;
|
|
7
|
+
//# sourceMappingURL=rsBuildHotReloadPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsBuildHotReloadPlugin.d.ts","sourceRoot":"","sources":["../src/rsBuildHotReloadPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,wBAAgB,sBAAsB,CAAC,EACtC,IAAW,EACX,KAAW,EACX,aAAa,GACb,EAAE;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACtB,GAAG,aAAa,CA8ChB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { WebSocketServer } from "ws";
|
|
2
|
+
export function rsBuildHotReloadPlugin({ port = 4777, delay = 400, entryFilePath, }) {
|
|
3
|
+
const isWatch = process.argv.includes("--watch");
|
|
4
|
+
const ws = new WebSocketServer({ port });
|
|
5
|
+
return {
|
|
6
|
+
name: "hot-reload-widget",
|
|
7
|
+
setup(api) {
|
|
8
|
+
if (!isWatch)
|
|
9
|
+
return;
|
|
10
|
+
api.transform({}, ({ code, resourcePath }) => {
|
|
11
|
+
if (resourcePath === entryFilePath) {
|
|
12
|
+
const hotReloadSnippet = `
|
|
13
|
+
(function() {
|
|
14
|
+
function connect() {
|
|
15
|
+
const ws = new WebSocket('ws://localhost:${port}');
|
|
16
|
+
|
|
17
|
+
ws.addEventListener('message', (event) => {
|
|
18
|
+
if (event.data === 'hot-reload-widget') {
|
|
19
|
+
setTimeout(() => window.location.reload(), ${delay});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
ws.addEventListener('close', () => {
|
|
24
|
+
setTimeout(connect, 1000);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
ws.addEventListener('error', () => {
|
|
28
|
+
ws.close();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
connect();
|
|
32
|
+
})();`;
|
|
33
|
+
return `${code}\n\n${hotReloadSnippet}`;
|
|
34
|
+
}
|
|
35
|
+
return code;
|
|
36
|
+
});
|
|
37
|
+
api.onAfterBuild(() => {
|
|
38
|
+
ws.clients.forEach((client) => {
|
|
39
|
+
if (client.readyState === client.OPEN) {
|
|
40
|
+
client.send("hot-reload-widget");
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=rsBuildHotReloadPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsBuildHotReloadPlugin.js","sourceRoot":"","sources":["../src/rsBuildHotReloadPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAErC,MAAM,UAAU,sBAAsB,CAAC,EACtC,IAAI,GAAG,IAAI,EACX,KAAK,GAAG,GAAG,EACX,aAAa,GAKb;IACA,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,EAAE,GAAG,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,OAAO;QACN,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,GAAG;YACR,IAAI,CAAC,OAAO;gBAAE,OAAO;YAErB,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE;gBAC5C,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;oBACpC,MAAM,gBAAgB,GAAG;;;kDAGoB,IAAI;;;;qDAID,KAAK;;;;;;;;;;;;;YAa9C,CAAC;oBACR,OAAO,GAAG,IAAI,OAAO,gBAAgB,EAAE,CAAC;gBACzC,CAAC;gBACD,OAAO,IAAI,CAAC;YACb,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE;gBACrB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC7B,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;wBACvC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;oBAClC,CAAC;gBACF,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widy/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A TypeScript SDK for Widy widget integrations.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "ik1s3v",
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@biomejs/biome": "2.4.9",
|
|
30
|
+
"@types/node": "^25.6.0",
|
|
31
|
+
"@types/ws": "^8.18.1",
|
|
30
32
|
"typescript": "^6.0.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@rsbuild/core": "^2.0.0",
|
|
36
|
+
"ws": "^8.20.0"
|
|
31
37
|
}
|
|
32
38
|
}
|