@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.
Files changed (88) hide show
  1. package/.babelrc +6 -0
  2. package/README.md +24 -0
  3. package/dist/address/index.d.ts +1 -0
  4. package/dist/address/index.js +18 -0
  5. package/dist/address/index.js.map +1 -0
  6. package/dist/address/o-address.d.ts +4 -0
  7. package/dist/address/o-address.js +3 -0
  8. package/dist/address/o-address.js.map +1 -0
  9. package/dist/config.d.ts +1 -0
  10. package/dist/config.js +5 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/dependency/index.d.ts +1 -0
  13. package/dist/dependency/index.js +18 -0
  14. package/dist/dependency/index.js.map +1 -0
  15. package/dist/dependency/o-dependency.d.ts +7 -0
  16. package/dist/dependency/o-dependency.js +3 -0
  17. package/dist/dependency/o-dependency.js.map +1 -0
  18. package/dist/enums/index.d.ts +1 -0
  19. package/dist/enums/index.js +18 -0
  20. package/dist/enums/index.js.map +1 -0
  21. package/dist/enums/o-protocol-methods.enum.d.ts +8 -0
  22. package/dist/enums/o-protocol-methods.enum.js +13 -0
  23. package/dist/enums/o-protocol-methods.enum.js.map +1 -0
  24. package/dist/handshake/index.d.ts +1 -0
  25. package/dist/handshake/index.js +18 -0
  26. package/dist/handshake/index.js.map +1 -0
  27. package/dist/handshake/o-handshake.d.ts +18 -0
  28. package/dist/handshake/o-handshake.js +3 -0
  29. package/dist/handshake/o-handshake.js.map +1 -0
  30. package/dist/index.d.ts +10 -0
  31. package/dist/index.js +27 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/json-rpc/index.d.ts +1 -0
  34. package/dist/json-rpc/index.js +18 -0
  35. package/dist/json-rpc/index.js.map +1 -0
  36. package/dist/json-rpc/json-rpc.d.ts +58 -0
  37. package/dist/json-rpc/json-rpc.js +10 -0
  38. package/dist/json-rpc/json-rpc.js.map +1 -0
  39. package/dist/method/index.d.ts +1 -0
  40. package/dist/method/index.js +18 -0
  41. package/dist/method/index.js.map +1 -0
  42. package/dist/method/o-method.d.ts +8 -0
  43. package/dist/method/o-method.js +3 -0
  44. package/dist/method/o-method.js.map +1 -0
  45. package/dist/parameter/index.d.ts +1 -0
  46. package/dist/parameter/index.js +18 -0
  47. package/dist/parameter/index.js.map +1 -0
  48. package/dist/parameter/o-parameter.d.ts +7 -0
  49. package/dist/parameter/o-parameter.js +3 -0
  50. package/dist/parameter/o-parameter.js.map +1 -0
  51. package/dist/register/index.d.ts +1 -0
  52. package/dist/register/index.js +18 -0
  53. package/dist/register/index.js.map +1 -0
  54. package/dist/register/o-register.d.ts +13 -0
  55. package/dist/register/o-register.js +3 -0
  56. package/dist/register/o-register.js.map +1 -0
  57. package/dist/router/index.d.ts +1 -0
  58. package/dist/router/index.js +18 -0
  59. package/dist/router/index.js.map +1 -0
  60. package/dist/router/o-router.d.ts +11 -0
  61. package/dist/router/o-router.js +3 -0
  62. package/dist/router/o-router.js.map +1 -0
  63. package/dist/schema.ts +193 -0
  64. package/package.json +73 -0
  65. package/schema/v1.0.0/schema.ts +159 -0
  66. package/src/address/index.ts +1 -0
  67. package/src/address/o-address.ts +4 -0
  68. package/src/config.ts +1 -0
  69. package/src/dependency/index.ts +1 -0
  70. package/src/dependency/o-dependency.ts +8 -0
  71. package/src/enums/index.ts +1 -0
  72. package/src/enums/o-protocol-methods.enum.ts +8 -0
  73. package/src/handshake/index.ts +1 -0
  74. package/src/handshake/o-handshake.ts +24 -0
  75. package/src/index.ts +10 -0
  76. package/src/json-rpc/index.ts +1 -0
  77. package/src/json-rpc/json-rpc.ts +100 -0
  78. package/src/method/index.ts +1 -0
  79. package/src/method/o-method.ts +9 -0
  80. package/src/parameter/index.ts +1 -0
  81. package/src/parameter/o-parameter.ts +7 -0
  82. package/src/register/index.ts +1 -0
  83. package/src/register/o-register.ts +15 -0
  84. package/src/router/index.ts +1 -0
  85. package/src/router/o-router.ts +12 -0
  86. package/ts-aggregator-loader.js +91 -0
  87. package/tsconfig.json +29 -0
  88. 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
+ };