@ekhein/sekiro-node-client 1.0.5 → 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.
@@ -1,5 +1,3 @@
1
- import "../chunk-ADS4GRIL.js";
2
-
3
1
  // src/decorators/action.decorator.ts
4
2
  function Action() {
5
3
  return function(target, method, descriptor) {
@@ -1,7 +1,12 @@
1
- import {
2
- Fork
3
- } from "../chunk-3KTEWZC4.js";
4
- import "../chunk-ADS4GRIL.js";
1
+ // src/decorators/bootstrap.decorator.ts
2
+ function Fork(count = 1, host, prot, clientId) {
3
+ return function(Client) {
4
+ for (let i = 1; i <= count; i++) {
5
+ const group = Array(Client.name, i).join("::");
6
+ new Client(group, host, prot, clientId);
7
+ }
8
+ };
9
+ }
5
10
  export {
6
11
  Fork
7
12
  };
package/dist/main.js CHANGED
@@ -1,9 +1,62 @@
1
1
  import {
2
- SekiroClient
3
- } from "./chunk-MDQJHW6K.js";
4
- import "./chunk-4IXLXWNL.js";
5
- import "./chunk-JB43IB4T.js";
6
- import "./chunk-ADS4GRIL.js";
2
+ Logger
3
+ } from "./chunk-4IXLXWNL.js";
4
+ import {
5
+ Result
6
+ } from "./chunk-JB43IB4T.js";
7
+
8
+ // src/main.ts
9
+ import { format } from "util";
10
+ import { randomUUID } from "crypto";
11
+ import { WebSocket } from "partysocket";
12
+ import { WebSocket as Client } from "ws";
13
+ var SekiroClient = class extends WebSocket {
14
+ constructor(scope, host = "192.168.2.102", prot = 5612, clientId = randomUUID().replace(/-/g, "")) {
15
+ super("wss://", [], {
16
+ debug: false,
17
+ maxEnqueuedMessages: -1,
18
+ WebSocket: class extends Client {
19
+ constructor() {
20
+ const site = format("ws://%s:%s", host, prot);
21
+ const wsURL = new URL("/business-demo/register", site);
22
+ wsURL.searchParams.append("group", scope);
23
+ wsURL.searchParams.append("clientId", clientId);
24
+ super(wsURL);
25
+ }
26
+ }
27
+ });
28
+ this.scope = scope;
29
+ this.host = host;
30
+ this.prot = prot;
31
+ this.clientId = clientId;
32
+ super.addEventListener("open", this.onOpen.bind(this));
33
+ super.addEventListener("message", this.onData.bind(this));
34
+ super.addEventListener("close", this.onClose.bind(this));
35
+ super.addEventListener("error", this.onError.bind(this));
36
+ }
37
+ logger = new Logger(this);
38
+ async onOpen(event) {
39
+ this.logger.info("Connection established");
40
+ }
41
+ async onClose(event) {
42
+ this.logger.warn("Connection closed");
43
+ }
44
+ async onError(event) {
45
+ this.logger.warn("WebSocket error:", event.message);
46
+ }
47
+ async onData(event) {
48
+ this.logger.info("Received request", event.data);
49
+ const request = JSON.parse(event.data);
50
+ try {
51
+ const data = await this.handlers.get(request.action)?.apply(this, [request]);
52
+ const pack = Result.success(request, data);
53
+ this.send(pack);
54
+ } catch (error) {
55
+ const pack = Result.unknown(request, error.message);
56
+ this.send(pack);
57
+ }
58
+ }
59
+ };
7
60
  export {
8
61
  SekiroClient
9
62
  };
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Logger
3
3
  } from "../chunk-4IXLXWNL.js";
4
- import "../chunk-ADS4GRIL.js";
5
4
  export {
6
5
  Logger
7
6
  };
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Result
3
3
  } from "../chunk-JB43IB4T.js";
4
- import "../chunk-ADS4GRIL.js";
5
4
  export {
6
5
  Result
7
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekhein/sekiro-node-client",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/main.cjs",
@@ -1,13 +0,0 @@
1
- // src/decorators/bootstrap.decorator.ts
2
- function Fork(count = 1, host, prot, clientId) {
3
- return function(Client) {
4
- for (let i = 1; i <= count; i++) {
5
- const group = Array(Client.name, i).join("::");
6
- new Client(group, host, prot, clientId);
7
- }
8
- };
9
- }
10
-
11
- export {
12
- Fork
13
- };
@@ -1,14 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
9
- return result;
10
- };
11
-
12
- export {
13
- __decorateClass
14
- };
@@ -1,63 +0,0 @@
1
- import {
2
- Logger
3
- } from "./chunk-4IXLXWNL.js";
4
- import {
5
- Result
6
- } from "./chunk-JB43IB4T.js";
7
-
8
- // src/main.ts
9
- import { format } from "util";
10
- import { randomUUID } from "crypto";
11
- import { WebSocket } from "partysocket";
12
- import { WebSocket as Client } from "ws";
13
- var SekiroClient = class extends WebSocket {
14
- constructor(scope, host = "192.168.2.102", prot = 5612, clientId = randomUUID().replace(/-/g, "")) {
15
- super("wss://", [], {
16
- debug: false,
17
- maxEnqueuedMessages: -1,
18
- WebSocket: class extends Client {
19
- constructor() {
20
- const site = format("ws://%s:%s", host, prot);
21
- const wsURL = new URL("/business-demo/register", site);
22
- wsURL.searchParams.append("group", scope);
23
- wsURL.searchParams.append("clientId", clientId);
24
- super(wsURL);
25
- }
26
- }
27
- });
28
- this.scope = scope;
29
- this.host = host;
30
- this.prot = prot;
31
- this.clientId = clientId;
32
- super.addEventListener("open", this.onOpen.bind(this));
33
- super.addEventListener("message", this.onData.bind(this));
34
- super.addEventListener("close", this.onClose.bind(this));
35
- super.addEventListener("error", this.onError.bind(this));
36
- }
37
- logger = new Logger(this);
38
- async onOpen(event) {
39
- this.logger.info("Connection established");
40
- }
41
- async onClose(event) {
42
- this.logger.warn("Connection closed");
43
- }
44
- async onError(event) {
45
- this.logger.warn("WebSocket error:", event.message);
46
- }
47
- async onData(event) {
48
- this.logger.info("Received request", event.data);
49
- const request = JSON.parse(event.data);
50
- try {
51
- const data = await this.handlers.get(request.action)?.apply(this, [request]);
52
- const pack = Result.success(request, data);
53
- this.send(pack);
54
- } catch (error) {
55
- const pack = Result.unknown(request, error.message);
56
- this.send(pack);
57
- }
58
- }
59
- };
60
-
61
- export {
62
- SekiroClient
63
- };
package/dist/test.cjs DELETED
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __decorateClass = (decorators, target, key, kind) => {
5
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
- if (decorator = decorators[i])
8
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result) __defProp(target, key, result);
10
- return result;
11
- };
12
-
13
- // src/decorators/bootstrap.decorator.ts
14
- function Fork(count = 1, host, prot, clientId) {
15
- return function(Client2) {
16
- for (let i = 1; i <= count; i++) {
17
- const group = Array(Client2.name, i).join("::");
18
- new Client2(group, host, prot, clientId);
19
- }
20
- };
21
- }
22
-
23
- // src/main.ts
24
- var import_util2 = require("util");
25
- var import_crypto = require("crypto");
26
- var import_partysocket = require("partysocket");
27
- var import_ws = require("ws");
28
-
29
- // src/utils/result.util.ts
30
- var Result = class {
31
- static success({ __sekiro_seq__ }, data) {
32
- return JSON.stringify({ __sekiro_seq__, data, status: 0 });
33
- }
34
- static unknown({ __sekiro_seq__ }, message) {
35
- return JSON.stringify({ __sekiro_seq__, message, status: -1 });
36
- }
37
- };
38
-
39
- // src/utils/logger.util.ts
40
- var import_util = require("util");
41
- var Logger = class {
42
- constructor(context) {
43
- this.context = context;
44
- }
45
- log(level, message) {
46
- const time = (/* @__PURE__ */ new Date()).toLocaleString();
47
- const base = (0, import_util.format)("[%s] [%s] [%s] [%s]", level, time, this.context.scope, this.context.clientId);
48
- switch (level) {
49
- case "INFO":
50
- console.info(base, ...message);
51
- break;
52
- case "WARN":
53
- console.warn(base, ...message);
54
- break;
55
- }
56
- }
57
- info(...message) {
58
- this.log("INFO", message);
59
- }
60
- warn(...message) {
61
- this.log("WARN", message);
62
- }
63
- };
64
-
65
- // src/main.ts
66
- var SekiroClient = class extends import_partysocket.WebSocket {
67
- constructor(scope, host = "192.168.2.102", prot = 5612, clientId = (0, import_crypto.randomUUID)().replace(/-/g, "")) {
68
- super("wss://", [], {
69
- debug: false,
70
- maxEnqueuedMessages: -1,
71
- WebSocket: class extends import_ws.WebSocket {
72
- constructor() {
73
- const site = (0, import_util2.format)("ws://%s:%s", host, prot);
74
- const wsURL = new URL("/business-demo/register", site);
75
- wsURL.searchParams.append("group", scope);
76
- wsURL.searchParams.append("clientId", clientId);
77
- super(wsURL);
78
- }
79
- }
80
- });
81
- this.scope = scope;
82
- this.host = host;
83
- this.prot = prot;
84
- this.clientId = clientId;
85
- super.addEventListener("open", this.onOpen.bind(this));
86
- super.addEventListener("message", this.onData.bind(this));
87
- super.addEventListener("close", this.onClose.bind(this));
88
- super.addEventListener("error", this.onError.bind(this));
89
- }
90
- logger = new Logger(this);
91
- async onOpen(event) {
92
- this.logger.info("Connection established");
93
- }
94
- async onClose(event) {
95
- this.logger.warn("Connection closed");
96
- }
97
- async onError(event) {
98
- this.logger.warn("WebSocket error:", event.message);
99
- }
100
- async onData(event) {
101
- this.logger.info("Received request", event.data);
102
- const request = JSON.parse(event.data);
103
- try {
104
- const data = await this.handlers.get(request.action)?.apply(this, [request]);
105
- const pack = Result.success(request, data);
106
- this.send(pack);
107
- } catch (error) {
108
- const pack = Result.unknown(request, error.message);
109
- this.send(pack);
110
- }
111
- }
112
- };
113
-
114
- // src/test.ts
115
- var Test = class extends SekiroClient {
116
- };
117
- Test = __decorateClass([
118
- Fork(2)
119
- ], Test);
package/dist/test.d.cts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/test.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/test.js DELETED
@@ -1,18 +0,0 @@
1
- import {
2
- SekiroClient
3
- } from "./chunk-MDQJHW6K.js";
4
- import {
5
- Fork
6
- } from "./chunk-3KTEWZC4.js";
7
- import "./chunk-4IXLXWNL.js";
8
- import "./chunk-JB43IB4T.js";
9
- import {
10
- __decorateClass
11
- } from "./chunk-ADS4GRIL.js";
12
-
13
- // src/test.ts
14
- var Test = class extends SekiroClient {
15
- };
16
- Test = __decorateClass([
17
- Fork(2)
18
- ], Test);