@sanctumterra/raknet 1.0.0
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/.swcrc +17 -0
- package/build.js +102 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +53 -0
- package/package.json +30 -0
- package/tsconfig.json +21 -0
package/.swcrc
ADDED
package/build.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const swc = require("@swc/core");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const ignoredPaths = [
|
|
6
|
+
'.git',
|
|
7
|
+
'node_modules',
|
|
8
|
+
'tsconfig.json',
|
|
9
|
+
'package.json',
|
|
10
|
+
'dist',
|
|
11
|
+
'package-lock.json',
|
|
12
|
+
'yarn.lock',
|
|
13
|
+
'.swcrc',
|
|
14
|
+
'.gitignore',
|
|
15
|
+
'tokens',
|
|
16
|
+
'build.js'
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const allowedExtensions = ['.ts', '.js', '.mjs', '.cjs', '.tsx', '.jsx', '.json'];
|
|
20
|
+
|
|
21
|
+
const mkdirSyncRecursive = (directory) => {
|
|
22
|
+
const parentDirectory = path.dirname(directory);
|
|
23
|
+
if (!fs.existsSync(parentDirectory)) {
|
|
24
|
+
mkdirSyncRecursive(parentDirectory);
|
|
25
|
+
}
|
|
26
|
+
if (!fs.existsSync(directory)) {
|
|
27
|
+
fs.mkdirSync(directory);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const compile = async (filePath) => {
|
|
32
|
+
const sourceCode = fs.readFileSync(filePath, "utf-8");
|
|
33
|
+
const { code } = await swc.transform(sourceCode, {
|
|
34
|
+
filename: path.basename(filePath),
|
|
35
|
+
jsc: {
|
|
36
|
+
parser: {
|
|
37
|
+
syntax: "typescript",
|
|
38
|
+
tsx: true,
|
|
39
|
+
dynamicImport: true,
|
|
40
|
+
decorators: true
|
|
41
|
+
},
|
|
42
|
+
target: "es2021",
|
|
43
|
+
loose: true,
|
|
44
|
+
externalHelpers: true
|
|
45
|
+
},
|
|
46
|
+
module: {
|
|
47
|
+
type: "commonjs"
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return code;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const compileDirectory = async (srcDir, outDir) => {
|
|
54
|
+
try {
|
|
55
|
+
const files = fs.readdirSync(srcDir);
|
|
56
|
+
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
const fullPath = path.join(srcDir, file);
|
|
59
|
+
const outPath = path.join(outDir, file.replace(/\.(ts|tsx)$/, '.js'));
|
|
60
|
+
|
|
61
|
+
if (ignoredPaths.includes(file)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const stats = fs.lstatSync(fullPath);
|
|
67
|
+
if (stats.isDirectory()) {
|
|
68
|
+
if (!fs.existsSync(outPath)) mkdirSyncRecursive(outPath);
|
|
69
|
+
await compileDirectory(fullPath, outPath);
|
|
70
|
+
} else {
|
|
71
|
+
const ext = path.extname(file).toLowerCase();
|
|
72
|
+
if (!allowedExtensions.includes(ext)) {
|
|
73
|
+
console.log(`Skipping file with unsupported extension: ${fullPath}`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (ext === ".json") {
|
|
78
|
+
mkdirSyncRecursive(path.dirname(outPath));
|
|
79
|
+
fs.copyFileSync(fullPath, outPath);
|
|
80
|
+
} else {
|
|
81
|
+
const compiledCode = await compile(fullPath);
|
|
82
|
+
mkdirSyncRecursive(path.dirname(outPath));
|
|
83
|
+
fs.writeFileSync(outPath, compiledCode);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error(`Error processing ${fullPath}:`, error.message);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(`Error reading directory ${srcDir}:`, error.message);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const srcDir = process.cwd();
|
|
96
|
+
const outDir = path.join(srcDir, 'dist');
|
|
97
|
+
|
|
98
|
+
compileDirectory(srcDir, outDir).then(() => {
|
|
99
|
+
console.log("Compilation complete.");
|
|
100
|
+
}).catch(err => {
|
|
101
|
+
console.error("Compilation failed:", err);
|
|
102
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { FrameHandler } from "./src/client/FrameHandler";
|
|
3
|
+
import { PacketHandler } from "./src/client/PacketHandler";
|
|
4
|
+
import { Queue } from "./src/client/Queue";
|
|
5
|
+
import { Proto } from "./src/packets/proto";
|
|
6
|
+
import { NewConnectionRequest } from "./src/packets/raknet/NewConnectionRequest";
|
|
7
|
+
import { OhMyNewIncommingConnection } from "./src/packets/raknet/OhMyNewIncommingConnection";
|
|
8
|
+
import { Serialize } from "./src/packets/serialize";
|
|
9
|
+
import { Logger } from "./src/utils/Logger";
|
|
10
|
+
import { RakNetClient } from "./src/client/RaknetClient";
|
|
11
|
+
export { PacketHandler, FrameHandler, Queue, Proto, NewConnectionRequest, OhMyNewIncommingConnection, Serialize, Logger, RakNetClient };
|
|
12
|
+
export default RakNetClient;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
FrameHandler: function() {
|
|
13
|
+
return _FrameHandler.FrameHandler;
|
|
14
|
+
},
|
|
15
|
+
Logger: function() {
|
|
16
|
+
return _Logger.Logger;
|
|
17
|
+
},
|
|
18
|
+
NewConnectionRequest: function() {
|
|
19
|
+
return _NewConnectionRequest.NewConnectionRequest;
|
|
20
|
+
},
|
|
21
|
+
OhMyNewIncommingConnection: function() {
|
|
22
|
+
return _OhMyNewIncommingConnection.OhMyNewIncommingConnection;
|
|
23
|
+
},
|
|
24
|
+
PacketHandler: function() {
|
|
25
|
+
return _PacketHandler.PacketHandler;
|
|
26
|
+
},
|
|
27
|
+
Proto: function() {
|
|
28
|
+
return _proto.Proto;
|
|
29
|
+
},
|
|
30
|
+
Queue: function() {
|
|
31
|
+
return _Queue.Queue;
|
|
32
|
+
},
|
|
33
|
+
RakNetClient: function() {
|
|
34
|
+
return _RaknetClient.RakNetClient;
|
|
35
|
+
},
|
|
36
|
+
Serialize: function() {
|
|
37
|
+
return _serialize.Serialize;
|
|
38
|
+
},
|
|
39
|
+
default: function() {
|
|
40
|
+
return _default;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
require("reflect-metadata");
|
|
44
|
+
const _FrameHandler = require("./src/client/FrameHandler");
|
|
45
|
+
const _PacketHandler = require("./src/client/PacketHandler");
|
|
46
|
+
const _Queue = require("./src/client/Queue");
|
|
47
|
+
const _proto = require("./src/packets/proto");
|
|
48
|
+
const _NewConnectionRequest = require("./src/packets/raknet/NewConnectionRequest");
|
|
49
|
+
const _OhMyNewIncommingConnection = require("./src/packets/raknet/OhMyNewIncommingConnection");
|
|
50
|
+
const _serialize = require("./src/packets/serialize");
|
|
51
|
+
const _Logger = require("./src/utils/Logger");
|
|
52
|
+
const _RaknetClient = require("./src/client/RaknetClient");
|
|
53
|
+
const _default = _RaknetClient.RakNetClient;
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sanctumterra/raknet",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"emitDeclarationOnly": true,
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "node ./dist/index.js",
|
|
10
|
+
"tsc": "tsc",
|
|
11
|
+
"build": "tsc --build tsconfig.json && npm run ./build.js",
|
|
12
|
+
"dev": "npm run ./build.js && node ./dist/index.js",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@swc/core": "^1.6.13",
|
|
20
|
+
"@swc/helpers": "^0.5.11",
|
|
21
|
+
"@types/node": "^20.14.10",
|
|
22
|
+
"typescript": "^5.5.3"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@serenityjs/binarystream": "^2.6.6",
|
|
26
|
+
"@serenityjs/raknet": "^0.3.6",
|
|
27
|
+
"chalk": "^4.1.2",
|
|
28
|
+
"path": "^0.12.7"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"emitDecoratorMetadata": true,
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"paths": {
|
|
13
|
+
"*": ["./*"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"ts-node": {
|
|
17
|
+
"swc": true,
|
|
18
|
+
"transpileOnly": true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|