corba.js 0.1.9 → 0.1.10

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 (138) hide show
  1. package/lib/idl/src/idl/cc/typeIDLtoCC.d.ts +6 -0
  2. package/lib/idl/src/idl/cc/typeIDLtoGIOPCC.d.ts +3 -0
  3. package/lib/idl/src/idl/cc/write-code.d.ts +2 -0
  4. package/lib/idl/src/idl/cc/write-interface.d.ts +5 -0
  5. package/lib/idl/src/idl/cc/write-skeleton.d.ts +2 -0
  6. package/lib/idl/src/idl/cc/write-stub.d.ts +2 -0
  7. package/lib/idl/src/idl/idl-lexer.d.ts +19 -0
  8. package/lib/idl/src/idl/idl-node.d.ts +102 -0
  9. package/lib/idl/src/idl/idl-parser.d.ts +3 -0
  10. package/lib/idl/src/idl/idl.d.ts +1 -0
  11. package/lib/idl/src/idl/ts/typeIDLtoGIOPTS.d.ts +3 -0
  12. package/lib/idl/src/idl/ts/typeIDLtoTS.d.ts +3 -0
  13. package/lib/idl/src/idl/ts/write-interface.d.ts +2 -0
  14. package/lib/idl/src/idl/ts/write-skeleton.d.ts +2 -0
  15. package/lib/idl/src/idl/ts/write-stub.d.ts +2 -0
  16. package/lib/idl/src/idl/ts/write-value.d.ts +2 -0
  17. package/lib/idl/src/idl/ts/write-valueimpl.d.ts +2 -0
  18. package/lib/idl/src/idl/ts/write-valuetype.d.ts +2 -0
  19. package/lib/idl/src/idl/util.d.ts +23 -0
  20. package/lib/idl/src/index.d.ts +5 -0
  21. package/lib/idl/src/net/browser.d.ts +7 -0
  22. package/lib/idl/src/net/index.d.ts +3 -0
  23. package/lib/idl/src/net/tcp.d.ts +11 -0
  24. package/lib/idl/src/net/tls.d.ts +24 -0
  25. package/lib/idl/src/net/ws.d.ts +44 -0
  26. package/lib/idl/src/orb/asn1.d.ts +48 -0
  27. package/lib/idl/src/orb/connection.d.ts +24 -0
  28. package/lib/idl/src/orb/giop.d.ts +283 -0
  29. package/lib/idl/src/orb/index.d.ts +3 -0
  30. package/lib/idl/src/orb/ior.d.ts +89 -0
  31. package/lib/idl/src/orb/orb.d.ts +143 -0
  32. package/lib/idl/src/orb/protocol.d.ts +6 -0
  33. package/lib/idl/src/orb/uint8map.d.ts +14 -0
  34. package/lib/idl/src/orb/url.d.ts +55 -0
  35. package/lib/src/idl/cc/typeIDLtoCC.d.ts +6 -0
  36. package/lib/src/idl/cc/typeIDLtoCC.js +127 -0
  37. package/lib/src/idl/cc/typeIDLtoCC.js.map +1 -0
  38. package/lib/src/idl/cc/typeIDLtoGIOPCC.d.ts +3 -0
  39. package/lib/src/idl/cc/typeIDLtoGIOPCC.js +127 -0
  40. package/lib/src/idl/cc/typeIDLtoGIOPCC.js.map +1 -0
  41. package/lib/src/idl/cc/write-code.d.ts +2 -0
  42. package/lib/src/idl/cc/write-code.js +213 -0
  43. package/lib/src/idl/cc/write-code.js.map +1 -0
  44. package/lib/src/idl/cc/write-interface.d.ts +5 -0
  45. package/lib/src/idl/cc/write-interface.js +228 -0
  46. package/lib/src/idl/cc/write-interface.js.map +1 -0
  47. package/lib/src/idl/cc/write-skeleton.d.ts +2 -0
  48. package/lib/src/idl/cc/write-skeleton.js +43 -0
  49. package/lib/src/idl/cc/write-skeleton.js.map +1 -0
  50. package/lib/src/idl/cc/write-stub.d.ts +2 -0
  51. package/lib/src/idl/cc/write-stub.js +91 -0
  52. package/lib/src/idl/cc/write-stub.js.map +1 -0
  53. package/lib/src/idl/idl-lexer.d.ts +19 -0
  54. package/lib/src/idl/idl-lexer.js +234 -0
  55. package/lib/src/idl/idl-lexer.js.map +1 -0
  56. package/lib/src/idl/idl-node.d.ts +102 -0
  57. package/lib/src/idl/idl-node.js +214 -0
  58. package/lib/src/idl/idl-node.js.map +1 -0
  59. package/lib/src/idl/idl-parser.d.ts +3 -0
  60. package/lib/src/idl/idl-parser.js +1210 -0
  61. package/lib/src/idl/idl-parser.js.map +1 -0
  62. package/lib/src/idl/idl.d.ts +1 -0
  63. package/lib/src/idl/idl.js +219 -0
  64. package/lib/src/idl/idl.js.map +1 -0
  65. package/lib/src/idl/ts/typeIDLtoGIOPTS.d.ts +3 -0
  66. package/lib/src/idl/ts/typeIDLtoGIOPTS.js +101 -0
  67. package/lib/src/idl/ts/typeIDLtoGIOPTS.js.map +1 -0
  68. package/lib/src/idl/ts/typeIDLtoTS.d.ts +3 -0
  69. package/lib/src/idl/ts/typeIDLtoTS.js +92 -0
  70. package/lib/src/idl/ts/typeIDLtoTS.js.map +1 -0
  71. package/lib/src/idl/ts/write-interface.d.ts +2 -0
  72. package/lib/src/idl/ts/write-interface.js +214 -0
  73. package/lib/src/idl/ts/write-interface.js.map +1 -0
  74. package/lib/src/idl/ts/write-skeleton.d.ts +2 -0
  75. package/lib/src/idl/ts/write-skeleton.js +118 -0
  76. package/lib/src/idl/ts/write-skeleton.js.map +1 -0
  77. package/lib/src/idl/ts/write-stub.d.ts +2 -0
  78. package/lib/src/idl/ts/write-stub.js +118 -0
  79. package/lib/src/idl/ts/write-stub.js.map +1 -0
  80. package/lib/src/idl/ts/write-value.d.ts +2 -0
  81. package/lib/src/idl/ts/write-value.js +208 -0
  82. package/lib/src/idl/ts/write-value.js.map +1 -0
  83. package/lib/src/idl/ts/write-valueimpl.d.ts +2 -0
  84. package/lib/src/idl/ts/write-valueimpl.js +159 -0
  85. package/lib/src/idl/ts/write-valueimpl.js.map +1 -0
  86. package/lib/src/idl/ts/write-valuetype.d.ts +2 -0
  87. package/lib/src/idl/ts/write-valuetype.js +99 -0
  88. package/lib/src/idl/ts/write-valuetype.js.map +1 -0
  89. package/lib/src/idl/util.d.ts +23 -0
  90. package/lib/src/idl/util.js +84 -0
  91. package/lib/src/idl/util.js.map +1 -0
  92. package/lib/src/index.d.ts +5 -0
  93. package/lib/src/index.js +6 -0
  94. package/lib/src/index.js.map +1 -0
  95. package/lib/src/net/browser.d.ts +7 -0
  96. package/lib/src/net/browser.js +55 -0
  97. package/lib/src/net/browser.js.map +1 -0
  98. package/lib/src/net/index.d.ts +3 -0
  99. package/lib/src/net/index.js +4 -0
  100. package/lib/src/net/index.js.map +1 -0
  101. package/lib/src/net/tcp.d.ts +11 -0
  102. package/lib/src/net/tcp.js +66 -0
  103. package/lib/src/net/tcp.js.map +1 -0
  104. package/lib/src/net/tls.d.ts +24 -0
  105. package/lib/src/net/tls.js +69 -0
  106. package/lib/src/net/tls.js.map +1 -0
  107. package/lib/src/net/ws.d.ts +44 -0
  108. package/lib/src/net/ws.js +158 -0
  109. package/lib/src/net/ws.js.map +1 -0
  110. package/lib/src/orb/asn1.d.ts +48 -0
  111. package/lib/src/orb/asn1.js +60 -0
  112. package/lib/src/orb/asn1.js.map +1 -0
  113. package/lib/src/orb/connection.d.ts +24 -0
  114. package/lib/src/orb/connection.js +19 -0
  115. package/lib/src/orb/connection.js.map +1 -0
  116. package/lib/src/orb/giop.d.ts +283 -0
  117. package/lib/src/orb/giop.js +1301 -0
  118. package/lib/src/orb/giop.js.map +1 -0
  119. package/lib/src/orb/index.d.ts +3 -0
  120. package/lib/src/orb/index.js +4 -0
  121. package/lib/src/orb/index.js.map +1 -0
  122. package/lib/src/orb/ior.d.ts +89 -0
  123. package/lib/src/orb/ior.js +113 -0
  124. package/lib/src/orb/ior.js.map +1 -0
  125. package/lib/src/orb/orb.d.ts +143 -0
  126. package/lib/src/orb/orb.js +693 -0
  127. package/lib/src/orb/orb.js.map +1 -0
  128. package/lib/src/orb/protocol.d.ts +6 -0
  129. package/lib/src/orb/protocol.js +2 -0
  130. package/lib/src/orb/protocol.js.map +1 -0
  131. package/lib/src/orb/uint8map.d.ts +14 -0
  132. package/lib/src/orb/uint8map.js +48 -0
  133. package/lib/src/orb/uint8map.js.map +1 -0
  134. package/lib/src/orb/url.d.ts +55 -0
  135. package/lib/src/orb/url.js +255 -0
  136. package/lib/src/orb/url.js.map +1 -0
  137. package/package.json +79 -71
  138. package/m13-es-transformer.cjs +0 -190
@@ -1,190 +0,0 @@
1
- const typescript = require("typescript")
2
- const path = require("path")
3
- const { existsSync } = require("fs")
4
- const { normalize } = require("path")
5
- // import * as typescript from 'typescript'
6
- // import * as path from 'path'
7
- // import { existsSync } from 'fs'
8
- // import { normalize } from 'path'
9
-
10
- // this transformer applies the baseUrl & paths rules from the tsconfig.json file
11
- // and appends .js to imports/exports, so that the typescript compiler's output
12
- // can be used directly in ES6 module workflows without additional bundlers
13
-
14
- // how TypeScript's rootDirs, baseUrl & paths work is documented in the TypeScript
15
- // source in src/compiler/moduleNameResolver.ts as follows:
16
- // * if a baseUrl is given, then absolute paths will be prefixed with the baseUrl
17
- // * "paths": { PATTERN: [SUBSTITUTION, ...], ... }
18
- // * PATTERN and SUBSTITUTION can have 0-1 '*' (which means that we can just split at '*')
19
- // * if multiple patterns match, match with the longest prefix is choosen
20
- // * the * in PATTERN is to be replaced with the * in SUBSTITUTION
21
-
22
- const transformer = (program) => (transformationContext) => (sourceFile) => {
23
-
24
- function transformAST(node) {
25
-
26
- if (isImportExportDeclaration(node)) {
27
-
28
- const compilerOptions = program.getCompilerOptions()
29
-
30
- if (compilerOptions.baseUrl &&
31
- !node.moduleSpecifier.text.startsWith('.')
32
- ) {
33
- let newModuleName = resolveBaseUrlAndPath(program, node)
34
- if (newModuleName !== undefined) {
35
- if (!newModuleName.endsWith(".js")) {
36
- newModuleName += ".js"
37
- }
38
- const newModuleSpecifier = typescript.factory.createStringLiteral(newModuleName)
39
- if (typescript.isImportDeclaration(node)) {
40
- return typescript.factory.updateImportDeclaration(node, node.modifiers, node.importClause, newModuleSpecifier, node.assertClause)
41
- } else if (typescript.isExportDeclaration(node)) {
42
- return typescript.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, node.exportClause, newModuleSpecifier, node.assertClause)
43
- }
44
- }
45
- }
46
-
47
- if (shouldMutateModuleSpecifier(node)) {
48
- const newModuleSpecifier = typescript.factory.createStringLiteral(`${node.moduleSpecifier.text}.js`)
49
- if (typescript.isImportDeclaration(node)) {
50
- return typescript.factory.updateImportDeclaration(node, node.modifiers, node.importClause, newModuleSpecifier, node.assertClause)
51
- } else if (typescript.isExportDeclaration(node)) {
52
- return typescript.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, node.exportClause, newModuleSpecifier, node.assertClause)
53
- }
54
- }
55
- }
56
-
57
- return typescript.visitEachChild(node, transformAST, transformationContext)
58
- }
59
-
60
- function isImportExportDeclaration(node) {
61
- return (typescript.isImportDeclaration(node) || typescript.isExportDeclaration(node))
62
- && node.moduleSpecifier !== undefined
63
- && typescript.isStringLiteral(node.moduleSpecifier)
64
- }
65
-
66
- function shouldMutateModuleSpecifier(node) {
67
- // only when path is relative
68
- if (!node.moduleSpecifier.text.startsWith('./') &&
69
- !node.moduleSpecifier.text.startsWith('../')) {
70
- return false
71
- }
72
- // only when module specifier has no extension
73
- if (path.extname(node.moduleSpecifier.text) !== '') {
74
- return false
75
- }
76
- return true
77
- }
78
-
79
- return typescript.visitNode(sourceFile, transformAST)
80
- }
81
-
82
- function resolveBaseUrlAndPath(program, node) {
83
- let moduleName = node.moduleSpecifier.text
84
- const compilerOptions = program.getCompilerOptions()
85
- if (compilerOptions?.baseUrl == undefined) {
86
- return undefined
87
- }
88
-
89
- let filename = (node?.parent?.fileName) ?? node?.original?.parent?.fileName
90
- if (filename === undefined) {
91
- return
92
- }
93
-
94
- if (filename.startsWith(compilerOptions.baseUrl)) {
95
-
96
- for (let adjustedModuleName of tsPathResolver(compilerOptions, moduleName)) {
97
- let found = false
98
- for (let ext of ["ts", "tsx", "js", "jsx"]) {
99
- const absoluteModuleName = normalize(`${compilerOptions.baseUrl}/${adjustedModuleName}.${ext}`)
100
- if (existsSync(`${absoluteModuleName}`)) {
101
- found = true
102
- break
103
- }
104
- }
105
- if (!found) {
106
- continue
107
- }
108
-
109
- const relativeModuleName = fromToFile(filename.substring(compilerOptions.baseUrl.length + 1), adjustedModuleName)
110
- return relativeModuleName
111
- }
112
- }
113
- }
114
-
115
- function tsPathResolver(config, moduleName) {
116
- if (config.baseUrl === undefined || config.paths === undefined) {
117
- return [moduleName]
118
- }
119
- if (moduleName.charAt(0) == ".") {
120
- return [moduleName]
121
- }
122
-
123
- // find the best pattern
124
- let bestPattern
125
- let bestPatternsHeadLength = 0
126
-
127
- for (let pattern in config.paths) {
128
- const asterisk = pattern.indexOf("*")
129
- if (asterisk !== -1) {
130
- const pathHead = pattern.substring(0, asterisk)
131
- const pathTail = pattern.substring(asterisk + 1)
132
- if (pathHead.length > bestPatternsHeadLength &&
133
- moduleName.startsWith(pathHead) &&
134
- moduleName.endsWith(pathTail)
135
- ) {
136
- bestPatternsHeadLength = pathHead.length
137
- bestPattern = pattern
138
- }
139
- } else {
140
- if (pattern.length >= bestPatternsHeadLength &&
141
- pattern === moduleName
142
- ) {
143
- bestPatternsHeadLength = pattern.length
144
- bestPattern = moduleName
145
- }
146
- }
147
- }
148
-
149
- // apply the best pattern's substitutions
150
- if (bestPattern !== undefined) {
151
- const asterisk = bestPattern.indexOf("*")
152
- if (asterisk !== -1) {
153
- const pathTail = bestPattern.substring(asterisk + 1)
154
- const middle = moduleName.substring(asterisk, moduleName.length - pathTail.length)
155
- const substitutions = config.paths[bestPattern]
156
- return substitutions.map(substitution => {
157
- const subAsterisk = substitution.indexOf("*")
158
- const subHead = substitution.substring(0, subAsterisk)
159
- const subTail = substitution.substring(subAsterisk + 1)
160
- return `${subHead}${middle}${subTail}`
161
- })
162
- } else {
163
- return config.paths[bestPattern]
164
- }
165
- }
166
- return [moduleName]
167
- }
168
-
169
- function fromToFile(fromFile, toFile) {
170
- const fromFileParts = fromFile.split("/")
171
- const toFileParts = toFile.split("/")
172
-
173
- const maxDepth = Math.min(fromFileParts.length, toFileParts.length)
174
- let equalUntilDepth = 0
175
- while (equalUntilDepth < maxDepth && fromFileParts[equalUntilDepth] == toFileParts[equalUntilDepth]) {
176
- ++equalUntilDepth
177
- }
178
-
179
- let relativeModuleName = "../".repeat(fromFileParts.length - equalUntilDepth - 1) // -1 is the file itself
180
- if (relativeModuleName.length == 0) {
181
- relativeModuleName = "./"
182
- }
183
-
184
- for (; equalUntilDepth < toFileParts.length; ++equalUntilDepth) {
185
- relativeModuleName += toFileParts[equalUntilDepth] + "/"
186
- }
187
- return relativeModuleName = relativeModuleName.substring(0, relativeModuleName.length - 1) // strip last "/"
188
- }
189
-
190
- module.exports = transformer