@olane/o-protocol 0.1.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/.babelrc +6 -0
- package/README.md +24 -0
- package/dist/address/index.d.ts +1 -0
- package/dist/address/index.js +18 -0
- package/dist/address/index.js.map +1 -0
- package/dist/address/o-address.d.ts +4 -0
- package/dist/address/o-address.js +3 -0
- package/dist/address/o-address.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -0
- package/dist/dependency/index.d.ts +1 -0
- package/dist/dependency/index.js +18 -0
- package/dist/dependency/index.js.map +1 -0
- package/dist/dependency/o-dependency.d.ts +7 -0
- package/dist/dependency/o-dependency.js +3 -0
- package/dist/dependency/o-dependency.js.map +1 -0
- package/dist/enums/index.d.ts +1 -0
- package/dist/enums/index.js +18 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/o-protocol-methods.enum.d.ts +8 -0
- package/dist/enums/o-protocol-methods.enum.js +13 -0
- package/dist/enums/o-protocol-methods.enum.js.map +1 -0
- package/dist/handshake/index.d.ts +1 -0
- package/dist/handshake/index.js +18 -0
- package/dist/handshake/index.js.map +1 -0
- package/dist/handshake/o-handshake.d.ts +18 -0
- package/dist/handshake/o-handshake.js +3 -0
- package/dist/handshake/o-handshake.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/json-rpc/index.d.ts +1 -0
- package/dist/json-rpc/index.js +18 -0
- package/dist/json-rpc/index.js.map +1 -0
- package/dist/json-rpc/json-rpc.d.ts +58 -0
- package/dist/json-rpc/json-rpc.js +10 -0
- package/dist/json-rpc/json-rpc.js.map +1 -0
- package/dist/method/index.d.ts +1 -0
- package/dist/method/index.js +18 -0
- package/dist/method/index.js.map +1 -0
- package/dist/method/o-method.d.ts +8 -0
- package/dist/method/o-method.js +3 -0
- package/dist/method/o-method.js.map +1 -0
- package/dist/parameter/index.d.ts +1 -0
- package/dist/parameter/index.js +18 -0
- package/dist/parameter/index.js.map +1 -0
- package/dist/parameter/o-parameter.d.ts +7 -0
- package/dist/parameter/o-parameter.js +3 -0
- package/dist/parameter/o-parameter.js.map +1 -0
- package/dist/register/index.d.ts +1 -0
- package/dist/register/index.js +18 -0
- package/dist/register/index.js.map +1 -0
- package/dist/register/o-register.d.ts +13 -0
- package/dist/register/o-register.js +3 -0
- package/dist/register/o-register.js.map +1 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/router/index.js +18 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/o-router.d.ts +11 -0
- package/dist/router/o-router.js +3 -0
- package/dist/router/o-router.js.map +1 -0
- package/dist/schema.ts +193 -0
- package/package.json +73 -0
- package/schema/v1.0.0/schema.ts +159 -0
- package/src/address/index.ts +1 -0
- package/src/address/o-address.ts +4 -0
- package/src/config.ts +1 -0
- package/src/dependency/index.ts +1 -0
- package/src/dependency/o-dependency.ts +8 -0
- package/src/enums/index.ts +1 -0
- package/src/enums/o-protocol-methods.enum.ts +8 -0
- package/src/handshake/index.ts +1 -0
- package/src/handshake/o-handshake.ts +24 -0
- package/src/index.ts +10 -0
- package/src/json-rpc/index.ts +1 -0
- package/src/json-rpc/json-rpc.ts +100 -0
- package/src/method/index.ts +1 -0
- package/src/method/o-method.ts +9 -0
- package/src/parameter/index.ts +1 -0
- package/src/parameter/o-parameter.ts +7 -0
- package/src/register/index.ts +1 -0
- package/src/register/o-register.ts +15 -0
- package/src/router/index.ts +1 -0
- package/src/router/o-router.ts +12 -0
- package/ts-aggregator-loader.js +91 -0
- package/tsconfig.json +29 -0
- package/webpack.config.js +30 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Track processed files to avoid circular dependencies
|
|
5
|
+
const processedFiles = new Set();
|
|
6
|
+
const aggregatedContent = [];
|
|
7
|
+
|
|
8
|
+
function resolveImportPath(importPath, currentFile) {
|
|
9
|
+
if (importPath.startsWith('.')) {
|
|
10
|
+
// Relative import
|
|
11
|
+
const resolvedPath = path.resolve(path.dirname(currentFile), importPath);
|
|
12
|
+
|
|
13
|
+
// Try different extensions
|
|
14
|
+
const extensions = ['.ts', '.tsx', '.js', '.jsx'];
|
|
15
|
+
for (const ext of extensions) {
|
|
16
|
+
const fullPath = resolvedPath + ext;
|
|
17
|
+
if (fs.existsSync(fullPath)) {
|
|
18
|
+
return fullPath;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Try index files
|
|
23
|
+
for (const ext of extensions) {
|
|
24
|
+
const fullPath = path.join(resolvedPath, `index${ext}`);
|
|
25
|
+
if (fs.existsSync(fullPath)) {
|
|
26
|
+
return fullPath;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function extractImports(content) {
|
|
34
|
+
const importRegex = /import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*(?:\{[^}]*\}|\*\s+as\s+\w+|\w+))*\s+from\s+)?['"`]([^'"`]+)['"`]/g;
|
|
35
|
+
const imports = [];
|
|
36
|
+
let match;
|
|
37
|
+
|
|
38
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
39
|
+
imports.push(match[1]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return imports;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function processFile(filePath, baseDir) {
|
|
46
|
+
if (processedFiles.has(filePath)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
processedFiles.add(filePath);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
54
|
+
|
|
55
|
+
// Extract imports
|
|
56
|
+
const imports = extractImports(content);
|
|
57
|
+
|
|
58
|
+
// Process local imports first
|
|
59
|
+
for (const importPath of imports) {
|
|
60
|
+
const resolvedPath = resolveImportPath(importPath, filePath);
|
|
61
|
+
if (resolvedPath && resolvedPath.startsWith(baseDir) && !resolvedPath.includes('node_modules')) {
|
|
62
|
+
processFile(resolvedPath, baseDir);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
aggregatedContent.push(content.replace(/import[\s\S]*?;/g, ''));
|
|
66
|
+
aggregatedContent.push(''); // Empty line for separation
|
|
67
|
+
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Error processing file ${filePath}:`, error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = function(source) {
|
|
74
|
+
const callback = this.async();
|
|
75
|
+
const resourcePath = this.resourcePath;
|
|
76
|
+
const baseDir = path.dirname(resourcePath);
|
|
77
|
+
|
|
78
|
+
// Reset for each build
|
|
79
|
+
processedFiles.clear();
|
|
80
|
+
aggregatedContent.length = 0;
|
|
81
|
+
|
|
82
|
+
// Process the entry file and all its dependencies
|
|
83
|
+
processFile(resourcePath, baseDir);
|
|
84
|
+
|
|
85
|
+
// console.log('Aggregated Content::::', aggregatedContent.length);
|
|
86
|
+
|
|
87
|
+
// Return the aggregated content
|
|
88
|
+
const result = aggregatedContent.join('\n');
|
|
89
|
+
fs.appendFileSync('dist/schema.ts', result);
|
|
90
|
+
callback(null, result);
|
|
91
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "ES2023",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"noImplicitAny": false,
|
|
16
|
+
"strictBindCallApply": false,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"noFallthroughCasesInSwitch": false,
|
|
19
|
+
"esModuleInterop": true,
|
|
20
|
+
"moduleResolution": "node",
|
|
21
|
+
"resolveJsonModule": true,
|
|
22
|
+
"declarationMap": false,
|
|
23
|
+
"paths": {
|
|
24
|
+
"*": ["node_modules/*"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"include": ["src/**/*"],
|
|
28
|
+
"exclude": ["node_modules", "dist"]
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: './src/index.ts',
|
|
5
|
+
module: {
|
|
6
|
+
rules: [
|
|
7
|
+
{
|
|
8
|
+
test: /\.ts$/,
|
|
9
|
+
use: [
|
|
10
|
+
{
|
|
11
|
+
loader: 'babel-loader',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
loader: path.resolve(__dirname, 'ts-aggregator-loader.js'),
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
exclude: /node_modules|index.ts/,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
resolve: {
|
|
22
|
+
extensions: ['.ts', '.js'],
|
|
23
|
+
},
|
|
24
|
+
output: {
|
|
25
|
+
filename: 'index.js',
|
|
26
|
+
path: path.resolve(__dirname, 'dist'),
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
mode: 'production',
|
|
30
|
+
};
|