corba.js 0.1.5 → 0.1.6

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 (126) hide show
  1. package/lib/idl/idl.cjs +2735 -0
  2. package/lib/idl/idl.cjs.map +1 -0
  3. package/lib/idl/src/idl/idl-lexer.d.ts +19 -0
  4. package/lib/idl/src/idl/idl-node.d.ts +101 -0
  5. package/lib/idl/src/idl/idl-parser.d.ts +3 -0
  6. package/lib/idl/src/idl/idl.d.ts +1 -0
  7. package/lib/idl/src/idl/util.d.ts +25 -0
  8. package/lib/idl/src/idl/write-interface.d.ts +2 -0
  9. package/lib/idl/src/idl/write-skeleton.d.ts +2 -0
  10. package/lib/idl/src/idl/write-stub.d.ts +2 -0
  11. package/lib/idl/src/idl/write-value.d.ts +2 -0
  12. package/lib/idl/src/idl/write-valueimpl.d.ts +2 -0
  13. package/lib/idl/src/idl/write-valuetype.d.ts +2 -0
  14. package/lib/idl/src/index.d.ts +5 -0
  15. package/lib/idl/src/net/browser.d.ts +7 -0
  16. package/lib/idl/src/net/index.d.ts +3 -0
  17. package/lib/idl/src/net/tcp.d.ts +11 -0
  18. package/lib/idl/src/net/tls.d.ts +24 -0
  19. package/lib/idl/src/net/ws.d.ts +42 -0
  20. package/lib/idl/src/orb/asn1.d.ts +48 -0
  21. package/lib/idl/src/orb/connection.d.ts +24 -0
  22. package/lib/idl/src/orb/giop.d.ts +276 -0
  23. package/lib/idl/src/orb/index.d.ts +3 -0
  24. package/lib/idl/src/orb/ior.d.ts +89 -0
  25. package/lib/idl/src/orb/orb.d.ts +143 -0
  26. package/lib/idl/src/orb/protocol.d.ts +6 -0
  27. package/lib/idl/src/orb/uint8map.d.ts +14 -0
  28. package/lib/idl/src/orb/url.d.ts +55 -0
  29. package/lib/idl/test/access.spec.d.ts +1 -0
  30. package/lib/idl/test/attribute.spec.d.ts +1 -0
  31. package/lib/idl/test/basics.spec.d.ts +1 -0
  32. package/lib/idl/test/disconnect.spec.d.ts +1 -0
  33. package/lib/idl/test/eventtarget.spec.d.ts +1 -0
  34. package/lib/idl/test/fake.d.ts +31 -0
  35. package/lib/idl/test/giop.spec.d.ts +1 -0
  36. package/lib/idl/test/idl/idl.spec.d.ts +1 -0
  37. package/lib/idl/test/idl_module.spec.d.ts +1 -0
  38. package/lib/idl/test/initialreferences.spec.d.ts +1 -0
  39. package/lib/idl/test/net/tls.spec.d.ts +1 -0
  40. package/lib/idl/test/net/ws.spec.d.ts +1 -0
  41. package/lib/idl/test/net/wss.spec.d.ts +1 -0
  42. package/lib/idl/test/object_by_reference.spec.d.ts +1 -0
  43. package/lib/idl/test/orb/asn1.spec.d.ts +1 -0
  44. package/lib/idl/test/orb/url.spec.d.ts +1 -0
  45. package/lib/idl/test/stub.spec.d.ts +1 -0
  46. package/lib/idl/test/util.d.ts +5 -0
  47. package/lib/idl/test/valuetype.spec.d.ts +1 -0
  48. package/lib/src/idl/idl-lexer.d.ts +19 -0
  49. package/lib/src/idl/idl-lexer.js +234 -0
  50. package/lib/src/idl/idl-lexer.js.map +1 -0
  51. package/lib/src/idl/idl-node.d.ts +101 -0
  52. package/lib/src/idl/idl-node.js +212 -0
  53. package/lib/src/idl/idl-node.js.map +1 -0
  54. package/lib/src/idl/idl-parser.d.ts +3 -0
  55. package/lib/src/idl/idl-parser.js +1087 -0
  56. package/lib/src/idl/idl-parser.js.map +1 -0
  57. package/lib/src/idl/idl.d.ts +1 -0
  58. package/lib/src/idl/idl.js +180 -0
  59. package/lib/src/idl/idl.js.map +1 -0
  60. package/lib/src/idl/util.d.ts +25 -0
  61. package/lib/src/idl/util.js +239 -0
  62. package/lib/src/idl/util.js.map +1 -0
  63. package/lib/src/idl/write-interface.d.ts +2 -0
  64. package/lib/src/idl/write-interface.js +111 -0
  65. package/lib/src/idl/write-interface.js.map +1 -0
  66. package/lib/src/idl/write-skeleton.d.ts +2 -0
  67. package/lib/src/idl/write-skeleton.js +116 -0
  68. package/lib/src/idl/write-skeleton.js.map +1 -0
  69. package/lib/src/idl/write-stub.d.ts +2 -0
  70. package/lib/src/idl/write-stub.js +116 -0
  71. package/lib/src/idl/write-stub.js.map +1 -0
  72. package/lib/src/idl/write-value.d.ts +2 -0
  73. package/lib/src/idl/write-value.js +205 -0
  74. package/lib/src/idl/write-value.js.map +1 -0
  75. package/lib/src/idl/write-valueimpl.d.ts +2 -0
  76. package/lib/src/idl/write-valueimpl.js +158 -0
  77. package/lib/src/idl/write-valueimpl.js.map +1 -0
  78. package/lib/src/idl/write-valuetype.d.ts +2 -0
  79. package/lib/src/idl/write-valuetype.js +98 -0
  80. package/lib/src/idl/write-valuetype.js.map +1 -0
  81. package/lib/src/index.d.ts +5 -0
  82. package/lib/src/index.js +6 -0
  83. package/lib/src/index.js.map +1 -0
  84. package/lib/src/net/browser.d.ts +7 -0
  85. package/lib/src/net/browser.js +55 -0
  86. package/lib/src/net/browser.js.map +1 -0
  87. package/lib/src/net/index.d.ts +3 -0
  88. package/lib/src/net/index.js +4 -0
  89. package/lib/src/net/index.js.map +1 -0
  90. package/lib/src/net/tcp.d.ts +11 -0
  91. package/lib/src/net/tcp.js +66 -0
  92. package/lib/src/net/tcp.js.map +1 -0
  93. package/lib/src/net/tls.d.ts +24 -0
  94. package/lib/src/net/tls.js +69 -0
  95. package/lib/src/net/tls.js.map +1 -0
  96. package/lib/src/net/ws.d.ts +42 -0
  97. package/lib/src/net/ws.js +158 -0
  98. package/lib/src/net/ws.js.map +1 -0
  99. package/lib/src/orb/asn1.d.ts +48 -0
  100. package/lib/src/orb/asn1.js +60 -0
  101. package/lib/src/orb/asn1.js.map +1 -0
  102. package/lib/src/orb/connection.d.ts +24 -0
  103. package/lib/src/orb/connection.js +19 -0
  104. package/lib/src/orb/connection.js.map +1 -0
  105. package/lib/src/orb/giop.d.ts +276 -0
  106. package/lib/src/orb/giop.js +1205 -0
  107. package/lib/src/orb/giop.js.map +1 -0
  108. package/lib/src/orb/index.d.ts +3 -0
  109. package/lib/src/orb/index.js +4 -0
  110. package/lib/src/orb/index.js.map +1 -0
  111. package/lib/src/orb/ior.d.ts +89 -0
  112. package/lib/src/orb/ior.js +110 -0
  113. package/lib/src/orb/ior.js.map +1 -0
  114. package/lib/src/orb/orb.d.ts +143 -0
  115. package/lib/src/orb/orb.js +693 -0
  116. package/lib/src/orb/orb.js.map +1 -0
  117. package/lib/src/orb/protocol.d.ts +6 -0
  118. package/lib/src/orb/protocol.js +2 -0
  119. package/lib/src/orb/protocol.js.map +1 -0
  120. package/lib/src/orb/uint8map.d.ts +14 -0
  121. package/lib/src/orb/uint8map.js +48 -0
  122. package/lib/src/orb/uint8map.js.map +1 -0
  123. package/lib/src/orb/url.d.ts +55 -0
  124. package/lib/src/orb/url.js +252 -0
  125. package/lib/src/orb/url.js.map +1 -0
  126. package/package.json +6 -6
@@ -0,0 +1,158 @@
1
+ import * as fs from "fs";
2
+ import { Type } from "./idl-node.js";
3
+ import { filenamePrefix, filename, filenameLocal, hasNative, hasValueType, writeIndent, typeIDLtoTS, FileType } from "./util.js";
4
+ export function writeTSValueImpl(specification) {
5
+ let out = fs.createWriteStream(filenamePrefix + "_valueimpl.ts");
6
+ out.write(`// This file is generated by the corba.js IDL compiler from '${filename}'.\n\n`);
7
+ out.write("import { ORB } from 'corba.js'\n");
8
+ if (!hasValueType(specification)) {
9
+ out.write("// no valuetype's defined in IDL");
10
+ return;
11
+ }
12
+ out.write(`import * as value from "./${filenameLocal}_value"\n\n`);
13
+ out.write(`import * as valuetype from "./${filenameLocal}_valuetype"\n\n`);
14
+ out.write(`import * as _interface from "./${filenameLocal}"\n\n`);
15
+ if (hasNative(specification)) {
16
+ out.write("declare global {\n");
17
+ for (let definition of specification.child) {
18
+ switch (definition.type) {
19
+ case Type.TKN_NATIVE:
20
+ {
21
+ let native = definition;
22
+ let nativeName = native.text;
23
+ if (nativeName.length <= 4 ||
24
+ nativeName.substring(nativeName.length - 4) !== "_ptr") {
25
+ out.write(" interface " + nativeName + " {}\n");
26
+ }
27
+ }
28
+ break;
29
+ }
30
+ }
31
+ out.write("}\n\n");
32
+ }
33
+ writeTSValueImplDefinitions(out, specification);
34
+ }
35
+ function hasOperationDeclarations(value_dcl) {
36
+ for (let i = 1; i < value_dcl.child.length; ++i) {
37
+ let value_element = value_dcl.child[i];
38
+ if (value_element.type === Type.SYN_OPERATION_DECLARATION) {
39
+ return true;
40
+ }
41
+ }
42
+ let value_header = value_dcl.child[0];
43
+ let inheritance_spec = value_header.child[2];
44
+ if (inheritance_spec !== undefined) {
45
+ if (inheritance_spec.child[1].child[0].type === Type.TKN_VALUETYPE) {
46
+ let value_dcl = inheritance_spec.child[1].child[0];
47
+ if (hasOperationDeclarations(value_dcl)) {
48
+ return true;
49
+ }
50
+ }
51
+ }
52
+ return false;
53
+ }
54
+ function writeTSValueImplDefinitions(out, specification, prefix = "", indent = 0) {
55
+ for (let definition of specification.child) {
56
+ switch (definition.type) {
57
+ case Type.TKN_MODULE:
58
+ {
59
+ out.write("export namespace " + definition.text + " {\n\n");
60
+ writeTSValueImplDefinitions(out, definition, prefix + definition.text + ".", indent + 1);
61
+ out.write("} // namespace " + definition.text + "\n\n");
62
+ }
63
+ break;
64
+ case Type.TKN_NATIVE:
65
+ {
66
+ }
67
+ break;
68
+ case Type.TKN_VALUETYPE:
69
+ {
70
+ let value_dcl = definition;
71
+ let value_header = value_dcl.child[0];
72
+ let custom = value_header.child[0];
73
+ let identifier = value_header.child[1].text;
74
+ let inheritance_spec = value_header.child[2];
75
+ writeIndent(out, indent);
76
+ out.write("export ");
77
+ if (hasOperationDeclarations(value_dcl))
78
+ out.write("abstract ");
79
+ else if (inheritance_spec !== undefined) {
80
+ if (inheritance_spec.child[1].child[0].type === Type.TKN_VALUETYPE) {
81
+ let value_dcl = inheritance_spec.child[1].child[0];
82
+ if (hasOperationDeclarations(value_dcl))
83
+ out.write("abstract ");
84
+ }
85
+ }
86
+ out.write("class " + identifier);
87
+ if (inheritance_spec !== undefined) {
88
+ if (inheritance_spec.child.length > 2)
89
+ throw Error("multiple inheritance is not supported for TypeScript");
90
+ out.write(" extends " + inheritance_spec.child[1].text);
91
+ }
92
+ out.write(` implements valuetype.${prefix}${identifier} {\n`);
93
+ for (let i = 1; i < value_dcl.child.length; ++i) {
94
+ let value_element = value_dcl.child[i];
95
+ if (value_element.type === Type.SYN_STATE_MEMBER) {
96
+ let state_member = value_element;
97
+ let attribute = state_member.child[0];
98
+ let type = state_member.child[1];
99
+ let declarators = state_member.child[2];
100
+ for (let declarator of declarators.child) {
101
+ writeIndent(out, indent + 1);
102
+ out.write(declarator.text + "!: " + typeIDLtoTS(type, FileType.VALUETYPE) + "\n");
103
+ }
104
+ }
105
+ }
106
+ out.write("\n");
107
+ writeIndent(out, indent + 1);
108
+ out.write(`constructor(init?: Partial<value.${prefix}${identifier}>) {\n`);
109
+ if (inheritance_spec) {
110
+ writeIndent(out, indent + 2);
111
+ out.write("super(init)\n");
112
+ }
113
+ writeIndent(out, indent + 2);
114
+ out.write(`value.${prefix}init${identifier}(this, init)\n`);
115
+ writeIndent(out, indent + 1);
116
+ out.write("}\n");
117
+ for (let i = 1; i < value_dcl.child.length; ++i) {
118
+ let value_element = value_dcl.child[i];
119
+ if (value_element.type === Type.SYN_OPERATION_DECLARATION) {
120
+ let op_decl = value_element;
121
+ let attribute = op_decl.child[0];
122
+ let type = op_decl.child[1];
123
+ let op_identifier = op_decl.child[2].text;
124
+ let parameter_decls = op_decl.child[3].child;
125
+ writeIndent(out, indent + 1);
126
+ out.write("abstract ");
127
+ out.write(op_identifier + "(");
128
+ let comma = false;
129
+ for (let parameter_dcl of parameter_decls) {
130
+ let attribute = parameter_dcl.child[0].type;
131
+ let type = parameter_dcl.child[1];
132
+ let param_identifier = parameter_dcl.child[2].text;
133
+ if (attribute !== Type.TKN_IN) {
134
+ throw Error("corba.js currently only supports 'in' parameters");
135
+ }
136
+ if (comma) {
137
+ out.write(", ");
138
+ }
139
+ else {
140
+ comma = true;
141
+ }
142
+ out.write(param_identifier);
143
+ out.write(": ");
144
+ out.write(typeIDLtoTS(type));
145
+ }
146
+ out.write("): ");
147
+ out.write(typeIDLtoTS(type));
148
+ out.write("\n");
149
+ }
150
+ }
151
+ writeIndent(out, indent);
152
+ out.write("}\n\n");
153
+ }
154
+ break;
155
+ }
156
+ }
157
+ }
158
+ //# sourceMappingURL=write-valueimpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-valueimpl.js","sourceRoot":"","sources":["../../../src/idl/write-valueimpl.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,IAAI,EAAQ,sBAAkB;AACvC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAc;AAE7H,MAAM,UAAU,gBAAgB,CAAC,aAAmB;IAChD,IAAI,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,GAAG,eAAe,CAAC,CAAA;IAChE,GAAG,CAAC,KAAK,CAAC,gEAAgE,QAAQ,QAAQ,CAAC,CAAA;IAC3F,GAAG,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAA;IAC7C,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE;QAC9B,GAAG,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAA;QAC7C,OAAM;KACT;IACD,GAAG,CAAC,KAAK,CAAC,6BAA6B,aAAa,aAAa,CAAC,CAAA;IAClE,GAAG,CAAC,KAAK,CAAC,iCAAiC,aAAa,iBAAiB,CAAC,CAAA;IAC1E,GAAG,CAAC,KAAK,CAAC,kCAAkC,aAAa,OAAO,CAAC,CAAA;IAEjE,IAAI,SAAS,CAAC,aAAa,CAAC,EAAE;QAC1B,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAA;QAC/B,KAAK,IAAI,UAAU,IAAI,aAAa,CAAC,KAAK,EAAE;YACxC,QAA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AAI,CAAC,CAAC,CAAA;4BAC5B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;yBAClB;qBACJ;oBACD,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;oBACxB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;iBACrB;gBAAC,MAAK;SACV;KACJ;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Node } from "./idl-node";
2
+ export declare function writeTSValueType(specification: Node): void;
@@ -0,0 +1,98 @@
1
+ import * as fs from "fs";
2
+ import { Type } from "./idl-node.js";
3
+ import { filenamePrefix, filename, filenameLocal, hasNative, hasValueType, writeIndent, typeIDLtoTS, FileType } from "./util.js";
4
+ export function writeTSValueType(specification) {
5
+ let out = fs.createWriteStream(filenamePrefix + "_valuetype.ts");
6
+ out.write("// This file is generated by the corba.js IDL compiler from '" + filename + "'.\n\n");
7
+ out.write("import { ORB } from 'corba.js'\n");
8
+ if (!hasValueType(specification)) {
9
+ out.write("// no valuetype's defined in IDL");
10
+ return;
11
+ }
12
+ out.write(`import * as value from "./${filenameLocal}_value\"\n\n`);
13
+ if (hasNative(specification)) {
14
+ out.write("declare global {\n");
15
+ for (let definition of specification.child) {
16
+ if (definition.type === Type.TKN_NATIVE) {
17
+ let native = definition;
18
+ let nativeName = native.text;
19
+ if (nativeName.length <= 4 ||
20
+ nativeName.substring(nativeName.length - 4) !== "_ptr") {
21
+ out.write(" interface " + nativeName + " {}\n");
22
+ }
23
+ }
24
+ }
25
+ out.write("}\n\n");
26
+ }
27
+ writeTSValueTypeDefinitions(out, specification);
28
+ }
29
+ function writeTSValueTypeDefinitions(out, specification, prefix = "", indent = 0) {
30
+ for (let definition of specification.child) {
31
+ switch (definition.type) {
32
+ case Type.TKN_MODULE:
33
+ {
34
+ out.write(`export namespace ${definition.text} {\n\n`);
35
+ writeTSValueTypeDefinitions(out, definition, prefix + definition.text + ".", indent + 1);
36
+ out.write(`} // namespace ${definition.text}\n\n`);
37
+ }
38
+ break;
39
+ case Type.TKN_NATIVE:
40
+ {
41
+ }
42
+ break;
43
+ case Type.TKN_VALUETYPE:
44
+ {
45
+ let value_dcl = definition;
46
+ let value_header = value_dcl.child[0];
47
+ let custom = value_header.child[0];
48
+ let identifier = value_header.child[1].text;
49
+ let inheritance_spec = value_header.child[2];
50
+ writeIndent(out, indent);
51
+ out.write(`export interface ${identifier} extends value.${prefix}${identifier}`);
52
+ if (inheritance_spec !== undefined) {
53
+ if (inheritance_spec.child.length > 2)
54
+ throw Error("multiple inheritance is not supported for TypeScript");
55
+ out.write(", " + inheritance_spec.child[1].text);
56
+ }
57
+ out.write(" {\n");
58
+ for (let i = 1; i < value_dcl.child.length; ++i) {
59
+ let value_element = value_dcl.child[i];
60
+ if (value_element.type === Type.SYN_OPERATION_DECLARATION) {
61
+ let op_decl = value_element;
62
+ let attribute = op_decl.child[0];
63
+ let type = op_decl.child[1];
64
+ let op_identifier = op_decl.child[2].text;
65
+ let parameter_decls = op_decl.child[3].child;
66
+ writeIndent(out, indent + 1);
67
+ out.write(op_identifier + "(");
68
+ let comma = false;
69
+ for (let parameter_dcl of parameter_decls) {
70
+ let attribute = parameter_dcl.child[0].type;
71
+ let type = parameter_dcl.child[1];
72
+ let param_identifier = parameter_dcl.child[2].text;
73
+ if (attribute !== Type.TKN_IN) {
74
+ throw Error("corba.js currently only supports 'in' parameters");
75
+ }
76
+ if (comma) {
77
+ out.write(", ");
78
+ }
79
+ else {
80
+ comma = true;
81
+ }
82
+ out.write(param_identifier);
83
+ out.write(": ");
84
+ out.write(typeIDLtoTS(type, FileType.VALUETYPE));
85
+ }
86
+ out.write("): ");
87
+ out.write(typeIDLtoTS(type, FileType.VALUETYPE));
88
+ out.write("\n");
89
+ }
90
+ }
91
+ writeIndent(out, indent);
92
+ out.write("}\n\n");
93
+ }
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ //# sourceMappingURL=write-valuetype.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-valuetype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AAC,CAAC,CAAE,CAAC,IAAI,CAAA;gCACpD,IAAI,SAAS,KAAK,IAAI,CAAC,MAAM,EAAE;oCAC3B,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAA;iCAClE;gCACD,IAAI,KAAK,EAAE;oCACP,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;iCAClB;qCAAM;oCACH,KAAK,GAAG,IAAI,CAAA;iCACf;gCACD,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;gCAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gCACf,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;6BACnD;4BACD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;4BAChB,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;4BAChD,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;yBAClB;qBACJ;oBACD,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;oBACxB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;iBAErB;gBAAC,MAAK;SACV;KACJ;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './orb/uint8map';
2
+ export * from './orb/url';
3
+ export * from './orb/asn1';
4
+ export * from './orb/giop';
5
+ export * from './orb/orb';
@@ -0,0 +1,6 @@
1
+ export * from "./orb/uint8map.js";
2
+ export * from "./orb/url.js";
3
+ export * from "./orb/asn1.js";
4
+ export * from "./orb/giop.js";
5
+ export * from "./orb/orb.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,8BAA0B;AAC1B,8BAA0B;AAC1B,6BAAyB"}
@@ -0,0 +1,7 @@
1
+ import { ORB } from "../orb/index";
2
+ import { Connection } from "../orb/connection";
3
+ import { Protocol } from "../orb/protocol";
4
+ export declare class WsProtocol implements Protocol {
5
+ connect(orb: ORB, host: string, port: number): Promise<Connection>;
6
+ close(): Promise<void>;
7
+ }
@@ -0,0 +1,55 @@
1
+ import { Connection } from "../orb/connection.js";
2
+ export class WsProtocol {
3
+ async connect(orb, host, port) {
4
+ return new Promise((resolve, reject) => {
5
+ const socket = new WebSocket(`ws://${host}:${port}`);
6
+ socket.binaryType = "arraybuffer";
7
+ const connection = new WsConnection(orb, socket);
8
+ orb.addConnection(connection);
9
+ socket.onopen = () => {
10
+ socket.onmessage = async (msg) => {
11
+ if (msg.data instanceof Blob) {
12
+ orb.socketRcvd(connection, await msg.data.arrayBuffer());
13
+ }
14
+ else {
15
+ orb.socketRcvd(connection, msg.data);
16
+ }
17
+ };
18
+ socket.onerror = (event) => {
19
+ orb.socketError(connection, new Error(`WebSocket connection error with ${socket.url}`));
20
+ };
21
+ socket.onclose = (event) => orb.socketClosed(connection);
22
+ resolve(connection);
23
+ };
24
+ socket.onerror = (event) => {
25
+ reject(new Error(`Failed to connect to ${socket.url}`));
26
+ };
27
+ });
28
+ }
29
+ async close() { }
30
+ }
31
+ class WsConnection extends Connection {
32
+ constructor(orb, socket) {
33
+ super(orb);
34
+ this.socket = socket;
35
+ }
36
+ get localAddress() {
37
+ return "browser";
38
+ }
39
+ get localPort() {
40
+ return 0;
41
+ }
42
+ get remoteAddress() {
43
+ return this.socket.url;
44
+ }
45
+ get remotePort() {
46
+ return 0;
47
+ }
48
+ close() {
49
+ this.socket.close();
50
+ }
51
+ send(buffer) {
52
+ this.socket.send(buffer);
53
+ }
54
+ }
55
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/net/browser.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,UAAU,EAAE,6BAAyB;AAG9C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AE,CAAC,CAAC,CAAA;YAC3D,CAAC,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IACD,KAAK,CAAC,KAAK,KAAK,CAAC;CACpB;AAED,MAAM,YAAa,SAAQ,UAAU;IAGjC,YAAY,GAAQ,EAAE,MAAiB;QACnC,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,IAAI,YAAY;QACZ,OAAO,SAAS,CAAA;IACpB,CAAC;IACD,IAAI,SAAS;QACT,OAAO,CAAC,CAAA;IACZ,CAAC;IACD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;IAC1B,CAAC;IACD,IAAI,UAAU;QACV,OAAO,CAAC,CAAA;IACZ,CAAC;IAED,KAAK;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;IACD,IAAI,CAAC,MAAmB;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ export * from './tcp';
2
+ export * from './tls';
3
+ export * from './ws';
@@ -0,0 +1,4 @@
1
+ export * from "./tcp.js";
2
+ export * from "./tls.js";
3
+ export * from "./ws.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/net/index.ts"],"names":[],"mappings":"AAAA,yBAAqB;AACrB,yBAAqB;AACrB,wBAAoB"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { ORB } from "../orb/index";
3
+ import { Server } from "net";
4
+ import { Connection } from "../orb/connection";
5
+ import { Protocol } from "../orb/protocol";
6
+ export declare class TcpProtocol implements Protocol {
7
+ serverSocket?: Server;
8
+ connect(orb: ORB, hostname: string, port: number): Promise<Connection>;
9
+ listen(orb: ORB, hostname: string, port: number): void;
10
+ close(): Promise<void>;
11
+ }
@@ -0,0 +1,66 @@
1
+ import { Socket, createServer } from "net";
2
+ import { Connection } from "../orb/connection.js";
3
+ const InitialInitiatorRequestIdBiDirectionalIIOP = 0;
4
+ const InitialResponderRequestIdBiDirectionalIIOP = 1;
5
+ export class TcpProtocol {
6
+ async connect(orb, hostname, port) {
7
+ return new Promise((resolve, reject) => {
8
+ const socket = new Socket();
9
+ socket.setNoDelay();
10
+ socket.once("error", (error) => reject(error));
11
+ socket.connect(port, hostname, () => {
12
+ const connection = new TcpConnection(socket, orb);
13
+ connection.requestId = InitialInitiatorRequestIdBiDirectionalIIOP;
14
+ socket.on("error", (error) => orb.socketError(connection, error));
15
+ socket.on("close", (hadError) => orb.socketClosed(connection));
16
+ socket.on("data", (data) => orb.socketRcvd(connection, data.buffer));
17
+ orb.addConnection(connection);
18
+ resolve(connection);
19
+ });
20
+ });
21
+ }
22
+ listen(orb, hostname, port) {
23
+ this.serverSocket = createServer((socket) => {
24
+ console.log(`accepted connection from ${socket.remoteAddress}:${socket.remotePort}`);
25
+ const connection = new TcpConnection(socket, orb);
26
+ connection.requestId = InitialResponderRequestIdBiDirectionalIIOP;
27
+ socket.setNoDelay();
28
+ socket.on("error", (error) => orb.socketError(connection, error));
29
+ socket.on("close", (hadError) => orb.socketClosed(connection));
30
+ socket.on("data", (data) => orb.socketRcvd(connection, data.buffer));
31
+ orb.addConnection(connection);
32
+ });
33
+ this.serverSocket.listen(port, hostname);
34
+ }
35
+ async close() {
36
+ if (this.serverSocket === undefined)
37
+ throw Error(`internal error: close() without server socket`);
38
+ this.serverSocket.close();
39
+ this.serverSocket = undefined;
40
+ }
41
+ }
42
+ class TcpConnection extends Connection {
43
+ constructor(socket, orb) {
44
+ super(orb);
45
+ this.socket = socket;
46
+ }
47
+ get localAddress() {
48
+ return this.socket.localAddress;
49
+ }
50
+ get localPort() {
51
+ return this.socket.localPort;
52
+ }
53
+ get remoteAddress() {
54
+ return this.socket.remoteAddress;
55
+ }
56
+ get remotePort() {
57
+ return this.socket.remotePort;
58
+ }
59
+ close() {
60
+ this.socket.destroy();
61
+ }
62
+ send(buffer) {
63
+ this.socket.write(new Uint8Array(buffer));
64
+ }
65
+ }
66
+ //# sourceMappingURL=tcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/net/tcp.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,MAAM,EAAU,YAAY,EAAE,MAAM,KAAK,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,6BAAyB;AAG9C,MAAM,0CAA0C,GAAG,CAAC,CAAA;AACpD,MAAM,0CAA0C,GAAG,CAAC,CAAA;AAcpD,MAAM,OAAO,WAAW;IAGpB,KAAK,CAAC,OAAO,CAAC,GAAQ,EAAE,QAAgB,EAAE,IAAY;QAClD,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAChD,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;YAC3B,MAAM,CAAC,UAAU,EAAE,CAAA;YACnB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;YACrD,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE;gBAChC,MAAM,UAAU,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;gBACjD,UAAU,CAAC,SAAS,GAAG,0CAA0C,CAAA;gBAEjE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;gBACxE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,QAAiB,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAA;gBACvE,MAAM,CAAC,EAAE,CA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AAC,YAAY,KAAK,SAAS;YAC/B,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAChE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAA;IACjC,CAAC;CACJ;AAED,MAAM,aAAc,SAAQ,UAAU;IAGlC,YAAY,MAAc,EAAE,GAAQ;QAChC,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,YAAa,CAAA;IACpC,CAAC;IACD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,SAAU,CAAA;IACjC,CAAC;IACD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,aAAc,CAAA;IACrC,CAAC;IACD,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAW,CAAA;IAClC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;IACD,IAAI,CAAC,MAAmB;QACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7C,CAAC;CACJ"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import { ORB } from "../orb/index";
3
+ import { Server, TlsOptions, TLSSocket } from "tls";
4
+ import { Connection } from "../orb/connection";
5
+ import { Protocol } from "../orb/protocol";
6
+ export declare class TlsProtocol implements Protocol {
7
+ options: TlsOptions;
8
+ serverSocket?: Server;
9
+ constructor(options?: TlsOptions);
10
+ connect(orb: ORB, hostname: string, port: number): Promise<Connection>;
11
+ listen(orb: ORB, hostname: string, port: number): Promise<void>;
12
+ close(): Promise<void>;
13
+ }
14
+ export declare class TlsConnection extends Connection {
15
+ socket: TLSSocket;
16
+ constructor(socket: TLSSocket, orb: ORB);
17
+ get peerCertificate(): import("tls").PeerCertificate;
18
+ get localAddress(): string;
19
+ get localPort(): number;
20
+ get remoteAddress(): string;
21
+ get remotePort(): number;
22
+ close(): void;
23
+ send(buffer: ArrayBuffer): void;
24
+ }
@@ -0,0 +1,69 @@
1
+ import { connect, createServer } from "tls";
2
+ import { Connection } from "../orb/connection.js";
3
+ const InitialInitiatorRequestIdBiDirectionalIIOP = 0;
4
+ const InitialResponderRequestIdBiDirectionalIIOP = 1;
5
+ export class TlsProtocol {
6
+ constructor(options = {}) {
7
+ this.options = options;
8
+ }
9
+ async connect(orb, hostname, port) {
10
+ return new Promise((resolve, reject) => {
11
+ const socket = connect(port, hostname, {}, () => {
12
+ const connection = new TlsConnection(socket, orb);
13
+ connection.requestId = InitialInitiatorRequestIdBiDirectionalIIOP;
14
+ socket.on("error", (error) => orb.socketError(connection, error));
15
+ socket.on("close", (hadError) => orb.socketClosed(connection));
16
+ socket.on("data", (data) => orb.socketRcvd(connection, data.buffer));
17
+ orb.addConnection(connection);
18
+ resolve(connection);
19
+ });
20
+ });
21
+ }
22
+ async listen(orb, hostname, port) {
23
+ this.serverSocket = createServer(this.options, (socket) => {
24
+ const connection = new TlsConnection(socket, orb);
25
+ connection.requestId = InitialResponderRequestIdBiDirectionalIIOP;
26
+ socket.on("error", (error) => orb.socketError(connection, error));
27
+ socket.on("close", (hadError) => orb.socketClosed(connection));
28
+ socket.on("data", (data) => orb.socketRcvd(connection, data.buffer));
29
+ orb.addConnection(connection);
30
+ });
31
+ return new Promise((resolve, reject) => {
32
+ this.serverSocket.listen(port, hostname, () => resolve());
33
+ });
34
+ }
35
+ async close() {
36
+ if (this.serverSocket === undefined)
37
+ throw Error(`internal error: close() without server socket`);
38
+ this.serverSocket.close();
39
+ this.serverSocket = undefined;
40
+ }
41
+ }
42
+ export class TlsConnection extends Connection {
43
+ constructor(socket, orb) {
44
+ super(orb);
45
+ this.socket = socket;
46
+ }
47
+ get peerCertificate() {
48
+ return this.socket.getPeerCertificate();
49
+ }
50
+ get localAddress() {
51
+ return this.socket.localAddress;
52
+ }
53
+ get localPort() {
54
+ return this.socket.localPort;
55
+ }
56
+ get remoteAddress() {
57
+ return this.socket.remoteAddress;
58
+ }
59
+ get remotePort() {
60
+ return this.socket.remotePort;
61
+ }
62
+ close() {
63
+ this.socket.destroy();
64
+ }
65
+ send(buffer) {
66
+ this.socket.write(new Uint8Array(buffer));
67
+ }
68
+ }
69
+ //# sourceMappingURL=tls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls.js","sourceRoot":"","sources":["../../../src/net/tls.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAiC,MAAM,KAAK,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,6BAAyB;AAG9C,MAAM,0CAA0C,GAAG,CAAC,CAAA;AACpD,MAAM,0CAA0C,GAAG,CAAC,CAAA;AAEpD,MAAM,OAAO,WAAW;IAIpB,YAAY,UAAsB,EAAE;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAGD,KAAK,CAAC,OAAO,CAAC,GAAQ,EAAE,QAAgB,EAAE,IAAY;QAElD,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAKhD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE;gBAC5C,MAAM,UAAU,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;gBACjD,UAAU,CAAC,SAAS,GAAG,0CAA0C,CAAA;gBAEjE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;gBACxE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,QAAiB,EAAE,EAAE,CAAC,GAAG,CAA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,EAAE,CAAC,CAAA;QAC9D,CAAC,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;YAC/B,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAChE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAA;IACjC,CAAC;CACJ;AAED,MAAM,OAAO,aAAc,SAAQ,UAAU;IAGzC,YAAY,MAAiB,EAAE,GAAQ;QACnC,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAA;IAC3C,CAAC;IACD,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,YAAa,CAAA;IACpC,CAAC;IACD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,SAAU,CAAA;IACjC,CAAC;IACD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,aAAc,CAAA;IACrC,CAAC;IACD,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAW,CAAA;IAClC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;IACD,IAAI,CAAC,MAAmB;QACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7C,CAAC;CACJ"}
@@ -0,0 +1,42 @@
1
+ /// <reference types="node" />
2
+ import { ORB } from "../orb/index";
3
+ import { Connection } from "../orb/connection";
4
+ import { Protocol } from "../orb/protocol";
5
+ import * as http from "http";
6
+ import * as https from "https";
7
+ import { connection as WebSocketConnection } from "websocket";
8
+ export declare abstract class WsProtocolBase<S extends http.Server, O extends http.ServerOptions> implements Protocol {
9
+ serverSocket?: S;
10
+ serverOptions?: O;
11
+ constructor(options?: O);
12
+ abstract getUrl(host: string, port: number): string;
13
+ abstract createServer(): S;
14
+ abstract createConnection(orb: ORB, connection: WebSocketConnection): WsConnection;
15
+ connect(orb: ORB, host: string, port: number): Promise<Connection>;
16
+ listen(orb: ORB, port: number): void;
17
+ close(): Promise<void>;
18
+ }
19
+ export declare class WsProtocol extends WsProtocolBase<http.Server, http.ServerOptions> {
20
+ createServer(): http.Server;
21
+ createConnection(orb: ORB, connection: WebSocketConnection): WsConnection;
22
+ getUrl(host: string, port: number): string;
23
+ }
24
+ export declare class WssProtocol extends WsProtocolBase<https.Server, https.ServerOptions> {
25
+ createServer(): https.Server;
26
+ createConnection(orb: ORB, connection: WebSocketConnection): WsConnection;
27
+ getUrl(host: string, port: number): string;
28
+ }
29
+ export declare class WsConnection extends Connection {
30
+ protected wsConnection: WebSocketConnection;
31
+ constructor(orb: ORB, connection: WebSocketConnection);
32
+ get localAddress(): string;
33
+ get localPort(): number;
34
+ get remoteAddress(): string;
35
+ get remotePort(): number;
36
+ close(): void;
37
+ send(buffer: ArrayBuffer): void;
38
+ }
39
+ export declare class WssConnection extends WsConnection {
40
+ constructor(orb: ORB, connection: WebSocketConnection);
41
+ get peerCertificate(): import("tls").PeerCertificate;
42
+ }