@ekhein/sekiro-node-client 2.0.2 → 2.0.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.
@@ -1,4 +1,7 @@
1
- export function Action() {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Action = Action;
4
+ function Action() {
2
5
  return function (target, method, descriptor) {
3
6
  if (!target.handlers)
4
7
  target.handlers = new Map();
@@ -1,4 +1,7 @@
1
- export function Fork(count = 1, host, prot, clientId) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Fork = Fork;
4
+ function Fork(count = 1, host, prot, clientId) {
2
5
  return function (Client) {
3
6
  for (let pid = 1; pid <= count; pid++) {
4
7
  new Client(Client.name, pid, host, prot, clientId);
@@ -1,2 +1,7 @@
1
- export { Fork } from "./fork.decorator";
2
- export { Action } from "./action.decorator";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Action = exports.Fork = void 0;
4
+ var fork_decorator_1 = require("./fork.decorator");
5
+ Object.defineProperty(exports, "Fork", { enumerable: true, get: function () { return fork_decorator_1.Fork; } });
6
+ var action_decorator_1 = require("./action.decorator");
7
+ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return action_decorator_1.Action; } });
package/dist/main.js CHANGED
@@ -1,25 +1,27 @@
1
- import { format } from 'util';
2
- import { randomUUID } from 'crypto';
3
- import { WebSocket } from 'partysocket';
4
- import { WebSocket as Client } from 'ws';
5
- import { Result } from './utils/result.util';
6
- import { Logger } from './utils/logger.util';
7
- export class SekiroClient extends WebSocket {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SekiroClient = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const partysocket_1 = require("partysocket");
6
+ const ws_1 = require("ws");
7
+ const result_util_1 = require("./utils/result.util");
8
+ const logger_util_1 = require("./utils/logger.util");
9
+ class SekiroClient extends partysocket_1.WebSocket {
8
10
  scope;
9
11
  pid;
10
12
  host;
11
13
  prot;
12
14
  clientId;
13
- logger = new Logger(this);
14
- constructor(scope, pid, host = "192.168.2.102", prot = 5612, clientId = randomUUID().replace(/-/g, "")) {
15
+ logger = new logger_util_1.Logger(this);
16
+ constructor(scope, pid, host = "192.168.2.102", prot = 5612, clientId = (0, crypto_1.randomUUID)().replace(/-/g, "")) {
15
17
  super("wss://", [], {
16
18
  debug: false,
17
19
  maxEnqueuedMessages: -1,
18
- WebSocket: class extends Client {
20
+ WebSocket: class extends ws_1.WebSocket {
19
21
  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);
22
+ const group = String(scope).toLowerCase();
23
+ const wsURL = new URL("/business-demo/register", "ws://" + host + ":" + prot);
24
+ wsURL.searchParams.append("group", group);
23
25
  wsURL.searchParams.append("clientId", clientId);
24
26
  super(wsURL);
25
27
  }
@@ -52,12 +54,13 @@ export class SekiroClient extends WebSocket {
52
54
  if (!handler)
53
55
  throw new Error("No handler for this action");
54
56
  const data = await handler.call(this, request.params);
55
- const pack = Result.success(request, data);
57
+ const pack = result_util_1.Result.success(request, data);
56
58
  this.send(pack);
57
59
  }
58
60
  catch (error) {
59
- const pack = Result.unknown(request, error.message);
61
+ const pack = result_util_1.Result.unknown(request, error.message);
60
62
  this.send(pack);
61
63
  }
62
64
  }
63
65
  }
66
+ exports.SekiroClient = SekiroClient;
@@ -1,5 +1,8 @@
1
- import { format } from "util";
2
- export class Logger {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ const util_1 = require("util");
5
+ class Logger {
3
6
  context;
4
7
  constructor(context) {
5
8
  this.context = context;
@@ -9,7 +12,7 @@ export class Logger {
9
12
  const pid = String(this.context.pid).padStart(2, "0");
10
13
  const scope = String(this.context.scope);
11
14
  const clientId = String(this.context.clientId);
12
- const base = format("[%s] [%s] [%s] [%s] [%s]", level, time, scope, pid, clientId);
15
+ const base = (0, util_1.format)("[%s] [%s] [%s] [%s] [%s]", level, time, scope, pid, clientId);
13
16
  switch (level) {
14
17
  case "INFO":
15
18
  console.info(base, ...message);
@@ -26,3 +29,4 @@ export class Logger {
26
29
  this.log("WARN", message);
27
30
  }
28
31
  }
32
+ exports.Logger = Logger;
@@ -1,4 +1,7 @@
1
- export class Result {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Result = void 0;
4
+ class Result {
2
5
  static success({ __sekiro_seq__ }, data) {
3
6
  return (JSON.stringify({ __sekiro_seq__, data, status: 0 }));
4
7
  }
@@ -6,3 +9,4 @@ export class Result {
6
9
  return (JSON.stringify({ __sekiro_seq__, message, status: -1 }));
7
10
  }
8
11
  }
12
+ exports.Result = Result;
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@ekhein/sekiro-node-client",
3
- "version": "2.0.2",
4
- "type": "module",
3
+ "version": "2.0.4",
5
4
  "license": "MIT",
6
5
  "author": "ekhein",
7
6
  "main": "./dist/main.js",