@nodetool-ai/sandbox-runtime 0.0.0-stage → 0.8.9-beta.1

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 (218) hide show
  1. package/README.md +24 -2
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/host-access-gate.d.ts +24 -0
  4. package/dist/host-access-gate.d.ts.map +1 -0
  5. package/dist/host-access-gate.js +31 -0
  6. package/dist/host-access-gate.js.map +1 -0
  7. package/dist/index.d.ts +32 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +318 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/js-sandbox-worker/engine.d.ts +4 -0
  12. package/dist/js-sandbox-worker/engine.d.ts.map +1 -0
  13. package/dist/js-sandbox-worker/engine.js +82 -0
  14. package/dist/js-sandbox-worker/engine.js.map +1 -0
  15. package/dist/js-sandbox-worker/host.d.ts +136 -0
  16. package/dist/js-sandbox-worker/host.d.ts.map +1 -0
  17. package/dist/js-sandbox-worker/host.js +482 -0
  18. package/dist/js-sandbox-worker/host.js.map +1 -0
  19. package/dist/js-sandbox-worker/interpreter.d.ts +276 -0
  20. package/dist/js-sandbox-worker/interpreter.d.ts.map +1 -0
  21. package/dist/js-sandbox-worker/interpreter.js +1318 -0
  22. package/dist/js-sandbox-worker/interpreter.js.map +1 -0
  23. package/dist/js-sandbox-worker/protocol.d.ts +168 -0
  24. package/dist/js-sandbox-worker/protocol.d.ts.map +1 -0
  25. package/dist/js-sandbox-worker/protocol.js +217 -0
  26. package/dist/js-sandbox-worker/protocol.js.map +1 -0
  27. package/dist/js-sandbox-worker/worker-entry.d.ts +26 -0
  28. package/dist/js-sandbox-worker/worker-entry.d.ts.map +1 -0
  29. package/dist/js-sandbox-worker/worker-entry.js +308 -0
  30. package/dist/js-sandbox-worker/worker-entry.js.map +1 -0
  31. package/dist/limits.d.ts +77 -0
  32. package/dist/limits.d.ts.map +1 -0
  33. package/dist/limits.js +56 -0
  34. package/dist/limits.js.map +1 -0
  35. package/dist/sandbox-bootstrap-modules.d.ts +54 -0
  36. package/dist/sandbox-bootstrap-modules.d.ts.map +1 -0
  37. package/dist/sandbox-bootstrap-modules.js +104 -0
  38. package/dist/sandbox-bootstrap-modules.js.map +1 -0
  39. package/dist/sandbox-bytes.d.ts +43 -0
  40. package/dist/sandbox-bytes.d.ts.map +1 -0
  41. package/dist/sandbox-bytes.js +61 -0
  42. package/dist/sandbox-bytes.js.map +1 -0
  43. package/dist/sandbox-canvas-api.d.ts +30 -0
  44. package/dist/sandbox-canvas-api.d.ts.map +1 -0
  45. package/dist/sandbox-canvas-api.js +81 -0
  46. package/dist/sandbox-canvas-api.js.map +1 -0
  47. package/dist/sandbox-constants.d.ts +5 -0
  48. package/dist/sandbox-constants.d.ts.map +1 -0
  49. package/dist/sandbox-constants.js +13 -0
  50. package/dist/sandbox-constants.js.map +1 -0
  51. package/dist/sandbox-json-transport.d.ts +107 -0
  52. package/dist/sandbox-json-transport.d.ts.map +1 -0
  53. package/dist/sandbox-json-transport.js +324 -0
  54. package/dist/sandbox-json-transport.js.map +1 -0
  55. package/dist/timeline-capture.d.ts +21 -0
  56. package/dist/timeline-capture.d.ts.map +1 -0
  57. package/dist/timeline-capture.js +564 -0
  58. package/dist/timeline-capture.js.map +1 -0
  59. package/dist/utils/type-guards.d.ts +26 -0
  60. package/dist/utils/type-guards.d.ts.map +1 -0
  61. package/dist/utils/type-guards.js +44 -0
  62. package/dist/utils/type-guards.js.map +1 -0
  63. package/package.json +138 -4
  64. package/vendor/README.md +17 -0
  65. package/vendor/quickjs/LICENSE +21 -0
  66. package/vendor/quickjs/PROVENANCE.json +8 -0
  67. package/vendor/quickjs/adapter/fetch.d.ts +56 -0
  68. package/vendor/quickjs/adapter/fetch.js +140 -0
  69. package/vendor/quickjs/createTimeInterval.d.ts +9 -0
  70. package/vendor/quickjs/createTimeInterval.js +22 -0
  71. package/vendor/quickjs/createVirtualFileSystem.d.ts +13 -0
  72. package/vendor/quickjs/createVirtualFileSystem.js +191 -0
  73. package/vendor/quickjs/index.d.ts +77 -0
  74. package/vendor/quickjs/index.js +77 -0
  75. package/vendor/quickjs/loadAsyncQuickJs.d.ts +12 -0
  76. package/vendor/quickjs/loadAsyncQuickJs.js +66 -0
  77. package/vendor/quickjs/loadQuickJs.d.ts +12 -0
  78. package/vendor/quickjs/loadQuickJs.js +73 -0
  79. package/vendor/quickjs/modules/assert.d.ts +2 -0
  80. package/vendor/quickjs/modules/assert.js +47 -0
  81. package/vendor/quickjs/modules/buffer.d.ts +2 -0
  82. package/vendor/quickjs/modules/buffer.js +106 -0
  83. package/vendor/quickjs/modules/build/test-lib.js +2 -0
  84. package/vendor/quickjs/modules/events.d.ts +2 -0
  85. package/vendor/quickjs/modules/events.js +4 -0
  86. package/vendor/quickjs/modules/fs.d.ts +2 -0
  87. package/vendor/quickjs/modules/fs.js +76 -0
  88. package/vendor/quickjs/modules/fs_promises.d.ts +2 -0
  89. package/vendor/quickjs/modules/fs_promises.js +328 -0
  90. package/vendor/quickjs/modules/module.d.ts +2 -0
  91. package/vendor/quickjs/modules/module.js +33 -0
  92. package/vendor/quickjs/modules/nodeCompatibility/headers.d.ts +2 -0
  93. package/vendor/quickjs/modules/nodeCompatibility/headers.js +58 -0
  94. package/vendor/quickjs/modules/nodeCompatibility/request.d.ts +2 -0
  95. package/vendor/quickjs/modules/nodeCompatibility/request.js +5 -0
  96. package/vendor/quickjs/modules/nodeCompatibility/response.d.ts +2 -0
  97. package/vendor/quickjs/modules/nodeCompatibility/response.js +5 -0
  98. package/vendor/quickjs/modules/path.d.ts +2 -0
  99. package/vendor/quickjs/modules/path.js +504 -0
  100. package/vendor/quickjs/modules/process.d.ts +2 -0
  101. package/vendor/quickjs/modules/process.js +309 -0
  102. package/vendor/quickjs/modules/punycode.d.ts +2 -0
  103. package/vendor/quickjs/modules/punycode.js +443 -0
  104. package/vendor/quickjs/modules/querystring.d.ts +2 -0
  105. package/vendor/quickjs/modules/querystring.js +15 -0
  106. package/vendor/quickjs/modules/string_decoder.d.ts +2 -0
  107. package/vendor/quickjs/modules/string_decoder.js +223 -0
  108. package/vendor/quickjs/modules/timers.d.ts +2 -0
  109. package/vendor/quickjs/modules/timers.js +10 -0
  110. package/vendor/quickjs/modules/timers_promises.d.ts +2 -0
  111. package/vendor/quickjs/modules/timers_promises.js +40 -0
  112. package/vendor/quickjs/modules/url.d.ts +2 -0
  113. package/vendor/quickjs/modules/url.js +104 -0
  114. package/vendor/quickjs/modules/util.d.ts +2 -0
  115. package/vendor/quickjs/modules/util.js +233 -0
  116. package/vendor/quickjs/package.json +3 -0
  117. package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.d.ts +4 -0
  118. package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.js +76 -0
  119. package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.d.ts +3 -0
  120. package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.js +22 -0
  121. package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.d.ts +12 -0
  122. package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.js +9 -0
  123. package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.d.ts +4 -0
  124. package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.js +30 -0
  125. package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.d.ts +2 -0
  126. package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.js +12 -0
  127. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.d.ts +3 -0
  128. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.js +11 -0
  129. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.d.ts +4 -0
  130. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.js +10 -0
  131. package/vendor/quickjs/sandbox/expose/expose.d.ts +3 -0
  132. package/vendor/quickjs/sandbox/expose/expose.js +155 -0
  133. package/vendor/quickjs/sandbox/expose/isES2015Class.d.ts +1 -0
  134. package/vendor/quickjs/sandbox/expose/isES2015Class.js +4 -0
  135. package/vendor/quickjs/sandbox/expose/isObject.d.ts +1 -0
  136. package/vendor/quickjs/sandbox/expose/isObject.js +4 -0
  137. package/vendor/quickjs/sandbox/expose/pendingHostPromises.d.ts +6 -0
  138. package/vendor/quickjs/sandbox/expose/pendingHostPromises.js +40 -0
  139. package/vendor/quickjs/sandbox/getMaxIntervalAmount.d.ts +8 -0
  140. package/vendor/quickjs/sandbox/getMaxIntervalAmount.js +12 -0
  141. package/vendor/quickjs/sandbox/getMaxTimeoutAmount.d.ts +8 -0
  142. package/vendor/quickjs/sandbox/getMaxTimeoutAmount.js +12 -0
  143. package/vendor/quickjs/sandbox/handleEvalError.d.ts +2 -0
  144. package/vendor/quickjs/sandbox/handleEvalError.js +21 -0
  145. package/vendor/quickjs/sandbox/handleToNative/handleToNative.d.ts +9 -0
  146. package/vendor/quickjs/sandbox/handleToNative/handleToNative.js +153 -0
  147. package/vendor/quickjs/sandbox/handleToNative/serializer/index.d.ts +10 -0
  148. package/vendor/quickjs/sandbox/handleToNative/serializer/index.js +36 -0
  149. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.d.ts +2 -0
  150. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.js +4 -0
  151. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.d.ts +2 -0
  152. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.js +16 -0
  153. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.d.ts +2 -0
  154. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.js +16 -0
  155. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.d.ts +2 -0
  156. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.js +18 -0
  157. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.d.ts +2 -0
  158. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.js +17 -0
  159. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.d.ts +2 -0
  160. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.js +18 -0
  161. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.d.ts +2 -0
  162. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.js +16 -0
  163. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.d.ts +2 -0
  164. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.js +17 -0
  165. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.d.ts +2 -0
  166. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.js +17 -0
  167. package/vendor/quickjs/sandbox/helper.d.ts +2 -0
  168. package/vendor/quickjs/sandbox/helper.js +14 -0
  169. package/vendor/quickjs/sandbox/provide/provideConsole.d.ts +6 -0
  170. package/vendor/quickjs/sandbox/provide/provideConsole.js +53 -0
  171. package/vendor/quickjs/sandbox/provide/provideEnv.d.ts +3 -0
  172. package/vendor/quickjs/sandbox/provide/provideEnv.js +10 -0
  173. package/vendor/quickjs/sandbox/provide/provideFs.d.ts +4 -0
  174. package/vendor/quickjs/sandbox/provide/provideFs.js +159 -0
  175. package/vendor/quickjs/sandbox/provide/provideHttp.d.ts +9 -0
  176. package/vendor/quickjs/sandbox/provide/provideHttp.js +42 -0
  177. package/vendor/quickjs/sandbox/provide/provideTimingFunctions.d.ts +7 -0
  178. package/vendor/quickjs/sandbox/provide/provideTimingFunctions.js +119 -0
  179. package/vendor/quickjs/sandbox/setupFileSystem.d.ts +3 -0
  180. package/vendor/quickjs/sandbox/setupFileSystem.js +13 -0
  181. package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.d.ts +4 -0
  182. package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.js +76 -0
  183. package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.d.ts +3 -0
  184. package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.js +22 -0
  185. package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.d.ts +12 -0
  186. package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.js +9 -0
  187. package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.d.ts +4 -0
  188. package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.js +30 -0
  189. package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.d.ts +2 -0
  190. package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.js +12 -0
  191. package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.d.ts +3 -0
  192. package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.js +11 -0
  193. package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.d.ts +4 -0
  194. package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.js +10 -0
  195. package/vendor/quickjs/types/CodeFunctionInput.d.ts +12 -0
  196. package/vendor/quickjs/types/CodeFunctionInput.js +1 -0
  197. package/vendor/quickjs/types/ErrorResponse.d.ts +9 -0
  198. package/vendor/quickjs/types/ErrorResponse.js +1 -0
  199. package/vendor/quickjs/types/LoadQuickJsOptions.d.ts +3 -0
  200. package/vendor/quickjs/types/LoadQuickJsOptions.js +1 -0
  201. package/vendor/quickjs/types/OkResponse.d.ts +4 -0
  202. package/vendor/quickjs/types/OkResponse.js +1 -0
  203. package/vendor/quickjs/types/OkResponseCheck.d.ts +3 -0
  204. package/vendor/quickjs/types/OkResponseCheck.js +1 -0
  205. package/vendor/quickjs/types/Prettify.d.ts +3 -0
  206. package/vendor/quickjs/types/Prettify.js +1 -0
  207. package/vendor/quickjs/types/RuntimeOptions.d.ts +87 -0
  208. package/vendor/quickjs/types/RuntimeOptions.js +1 -0
  209. package/vendor/quickjs/types/SandboxEvalCode.d.ts +5 -0
  210. package/vendor/quickjs/types/SandboxEvalCode.js +1 -0
  211. package/vendor/quickjs/types/SandboxFunction.d.ts +16 -0
  212. package/vendor/quickjs/types/SandboxFunction.js +1 -0
  213. package/vendor/quickjs/types/SandboxOptions.d.ts +152 -0
  214. package/vendor/quickjs/types/SandboxOptions.js +1 -0
  215. package/vendor/quickjs/types/SandboxValidateCode.d.ts +9 -0
  216. package/vendor/quickjs/types/SandboxValidateCode.js +1 -0
  217. package/vendor/quickjs/types/Serializer.d.ts +2 -0
  218. package/vendor/quickjs/types/Serializer.js +1 -0
@@ -0,0 +1,504 @@
1
+ export default `
2
+
3
+ export function assertPath(path) {
4
+ if (typeof path !== 'string') {
5
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path))
6
+ }
7
+ }
8
+
9
+ // Resolves . and .. elements in a path with directory names
10
+ export function normalizeStringPosix(path, allowAboveRoot) {
11
+ var res = ''
12
+ var lastSegmentLength = 0
13
+ var lastSlash = -1
14
+ var dots = 0
15
+ var code
16
+ for (var i = 0; i <= path.length; ++i) {
17
+ if (i < path.length) code = path.charCodeAt(i)
18
+ else if (code === 47 /*/*/) break
19
+ else code = 47 /*/*/
20
+ if (code === 47 /*/*/) {
21
+ if (lastSlash === i - 1 || dots === 1) {
22
+ // NOOP
23
+ } else if (lastSlash !== i - 1 && dots === 2) {
24
+ if (
25
+ res.length < 2 ||
26
+ lastSegmentLength !== 2 ||
27
+ res.charCodeAt(res.length - 1) !== 46 /*.*/ ||
28
+ res.charCodeAt(res.length - 2) !== 46 /*.*/
29
+ ) {
30
+ if (res.length > 2) {
31
+ var lastSlashIndex = res.lastIndexOf('/')
32
+ if (lastSlashIndex !== res.length - 1) {
33
+ if (lastSlashIndex === -1) {
34
+ res = ''
35
+ lastSegmentLength = 0
36
+ } else {
37
+ res = res.slice(0, lastSlashIndex)
38
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/')
39
+ }
40
+ lastSlash = i
41
+ dots = 0
42
+ continue
43
+ }
44
+ } else if (res.length === 2 || res.length === 1) {
45
+ res = ''
46
+ lastSegmentLength = 0
47
+ lastSlash = i
48
+ dots = 0
49
+ continue
50
+ }
51
+ }
52
+ if (allowAboveRoot) {
53
+ if (res.length > 0) res += '/..'
54
+ else res = '..'
55
+ lastSegmentLength = 2
56
+ }
57
+ } else {
58
+ if (res.length > 0) res += '/' + path.slice(lastSlash + 1, i)
59
+ else res = path.slice(lastSlash + 1, i)
60
+ lastSegmentLength = i - lastSlash - 1
61
+ }
62
+ lastSlash = i
63
+ dots = 0
64
+ } else if (code === 46 /*.*/ && dots !== -1) {
65
+ ++dots
66
+ } else {
67
+ dots = -1
68
+ }
69
+ }
70
+ return res
71
+ }
72
+
73
+ function _format(sep, pathObject) {
74
+ var dir = pathObject.dir || pathObject.root
75
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '')
76
+ if (!dir) {
77
+ return base
78
+ }
79
+ if (dir === pathObject.root) {
80
+ return dir + base
81
+ }
82
+ return dir + sep + base
83
+ }
84
+
85
+ // path.resolve([from ...], to)
86
+ export const resolve = function resolve() {
87
+ var resolvedPath = ''
88
+ var resolvedAbsolute = false
89
+ var cwd
90
+
91
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
92
+ var path
93
+ if (i >= 0) path = arguments[i]
94
+ else {
95
+ if (cwd === undefined) cwd = process.cwd()
96
+ path = cwd
97
+ }
98
+
99
+ assertPath(path)
100
+
101
+ // Skip empty entries
102
+ if (path.length === 0) {
103
+ continue
104
+ }
105
+
106
+ resolvedPath = path + '/' + resolvedPath
107
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/
108
+ }
109
+
110
+ // At this point the path should be resolved to a full absolute path, but
111
+ // handle relative paths to be safe (might happen when process.cwd() fails)
112
+
113
+ // Normalize the path
114
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute)
115
+
116
+ if (resolvedAbsolute) {
117
+ if (resolvedPath.length > 0) return '/' + resolvedPath
118
+ else return '/'
119
+ } else if (resolvedPath.length > 0) {
120
+ return resolvedPath
121
+ } else {
122
+ return '.'
123
+ }
124
+ }
125
+
126
+ export const normalize = function normalize(path) {
127
+ assertPath(path)
128
+
129
+ if (path.length === 0) return '.'
130
+
131
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/
132
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/
133
+
134
+ // Normalize the path
135
+ path = normalizeStringPosix(path, !isAbsolute)
136
+
137
+ if (path.length === 0 && !isAbsolute) path = '.'
138
+ if (path.length > 0 && trailingSeparator) path += '/'
139
+
140
+ if (isAbsolute) return '/' + path
141
+ return path
142
+ }
143
+
144
+ export const isAbsolute = function isAbsolute(path) {
145
+ assertPath(path)
146
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/
147
+ }
148
+
149
+ export const join = function join() {
150
+ if (arguments.length === 0) return '.'
151
+ var joined
152
+ for (var i = 0; i < arguments.length; ++i) {
153
+ var arg = arguments[i]
154
+ assertPath(arg)
155
+ if (arg.length > 0) {
156
+ if (joined === undefined) joined = arg
157
+ else joined += '/' + arg
158
+ }
159
+ }
160
+ if (joined === undefined) return '.'
161
+ return normalize(joined)
162
+ }
163
+
164
+ export const relative = function relative(from, to) {
165
+ assertPath(from)
166
+ assertPath(to)
167
+
168
+ if (from === to) return ''
169
+
170
+ from = resolve(from)
171
+ to = resolve(to)
172
+
173
+ if (from === to) return ''
174
+
175
+ // Trim any leading backslashes
176
+ var fromStart = 1
177
+ for (; fromStart < from.length; ++fromStart) {
178
+ if (from.charCodeAt(fromStart) !== 47 /*/*/) break
179
+ }
180
+ var fromEnd = from.length
181
+ var fromLen = fromEnd - fromStart
182
+
183
+ // Trim any leading backslashes
184
+ var toStart = 1
185
+ for (; toStart < to.length; ++toStart) {
186
+ if (to.charCodeAt(toStart) !== 47 /*/*/) break
187
+ }
188
+ var toEnd = to.length
189
+ var toLen = toEnd - toStart
190
+
191
+ // Compare paths to find the longest common path from root
192
+ var length = fromLen < toLen ? fromLen : toLen
193
+ var lastCommonSep = -1
194
+ var i = 0
195
+ for (; i <= length; ++i) {
196
+ if (i === length) {
197
+ if (toLen > length) {
198
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
199
+ // We get here if \`from\` is the exact base path for \`to\`.
200
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
201
+ return to.slice(toStart + i + 1)
202
+ } else if (i === 0) {
203
+ // We get here if \`from\` is the root
204
+ // For example: from='/'; to='/foo'
205
+ return to.slice(toStart + i)
206
+ }
207
+ } else if (fromLen > length) {
208
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
209
+ // We get here if \`to\` is the exact base path for \`from\`.
210
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
211
+ lastCommonSep = i
212
+ } else if (i === 0) {
213
+ // We get here if \`to\` is the root.
214
+ // For example: from='/foo'; to='/'
215
+ lastCommonSep = 0
216
+ }
217
+ }
218
+ break
219
+ }
220
+ var fromCode = from.charCodeAt(fromStart + i)
221
+ var toCode = to.charCodeAt(toStart + i)
222
+ if (fromCode !== toCode) break
223
+ else if (fromCode === 47 /*/*/) lastCommonSep = i
224
+ }
225
+
226
+ var out = ''
227
+ // Generate the relative path based on the path difference between \`to\`
228
+ // and \`from\`
229
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
230
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
231
+ if (out.length === 0) out += '..'
232
+ else out += '/..'
233
+ }
234
+ }
235
+
236
+ // Lastly, append the rest of the destination (\`to\`) path that comes after
237
+ // the common path parts
238
+ if (out.length > 0) return out + to.slice(toStart + lastCommonSep)
239
+ else {
240
+ toStart += lastCommonSep
241
+ if (to.charCodeAt(toStart) === 47 /*/*/) ++toStart
242
+ return to.slice(toStart)
243
+ }
244
+ }
245
+
246
+ export const _makeLong = function _makeLong(path) {
247
+ return path
248
+ }
249
+
250
+ export const dirname = function dirname(path) {
251
+ assertPath(path)
252
+ if (path.length === 0) return '.'
253
+ var code = path.charCodeAt(0)
254
+ var hasRoot = code === 47 /*/*/
255
+ var end = -1
256
+ var matchedSlash = true
257
+ for (var i = path.length - 1; i >= 1; --i) {
258
+ code = path.charCodeAt(i)
259
+ if (code === 47 /*/*/) {
260
+ if (!matchedSlash) {
261
+ end = i
262
+ break
263
+ }
264
+ } else {
265
+ // We saw the first non-path separator
266
+ matchedSlash = false
267
+ }
268
+ }
269
+
270
+ if (end === -1) return hasRoot ? '/' : '.'
271
+ if (hasRoot && end === 1) return '//'
272
+ return path.slice(0, end)
273
+ }
274
+
275
+ export const basename = function basename(path, ext) {
276
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string')
277
+ assertPath(path)
278
+
279
+ var start = 0
280
+ var end = -1
281
+ var matchedSlash = true
282
+ var i
283
+
284
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
285
+ if (ext.length === path.length && ext === path) return ''
286
+ var extIdx = ext.length - 1
287
+ var firstNonSlashEnd = -1
288
+ for (i = path.length - 1; i >= 0; --i) {
289
+ var code = path.charCodeAt(i)
290
+ if (code === 47 /*/*/) {
291
+ // If we reached a path separator that was not part of a set of path
292
+ // separators at the end of the string, stop now
293
+ if (!matchedSlash) {
294
+ start = i + 1
295
+ break
296
+ }
297
+ } else {
298
+ if (firstNonSlashEnd === -1) {
299
+ // We saw the first non-path separator, remember this index in case
300
+ // we need it if the extension ends up not matching
301
+ matchedSlash = false
302
+ firstNonSlashEnd = i + 1
303
+ }
304
+ if (extIdx >= 0) {
305
+ // Try to match the explicit extension
306
+ if (code === ext.charCodeAt(extIdx)) {
307
+ if (--extIdx === -1) {
308
+ // We matched the extension, so mark this as the end of our path
309
+ // component
310
+ end = i
311
+ }
312
+ } else {
313
+ // Extension does not match, so our result is the entire path
314
+ // component
315
+ extIdx = -1
316
+ end = firstNonSlashEnd
317
+ }
318
+ }
319
+ }
320
+ }
321
+
322
+ if (start === end) end = firstNonSlashEnd
323
+ else if (end === -1) end = path.length
324
+ return path.slice(start, end)
325
+ } else {
326
+ for (i = path.length - 1; i >= 0; --i) {
327
+ if (path.charCodeAt(i) === 47 /*/*/) {
328
+ // If we reached a path separator that was not part of a set of path
329
+ // separators at the end of the string, stop now
330
+ if (!matchedSlash) {
331
+ start = i + 1
332
+ break
333
+ }
334
+ } else if (end === -1) {
335
+ // We saw the first non-path separator, mark this as the end of our
336
+ // path component
337
+ matchedSlash = false
338
+ end = i + 1
339
+ }
340
+ }
341
+
342
+ if (end === -1) return ''
343
+ return path.slice(start, end)
344
+ }
345
+ }
346
+
347
+ export const extname = function extname(path) {
348
+ assertPath(path)
349
+ var startDot = -1
350
+ var startPart = 0
351
+ var end = -1
352
+ var matchedSlash = true
353
+ // Track the state of characters (if any) we see before our first dot and
354
+ // after any path separator we find
355
+ var preDotState = 0
356
+ for (var i = path.length - 1; i >= 0; --i) {
357
+ var code = path.charCodeAt(i)
358
+ if (code === 47 /*/*/) {
359
+ // If we reached a path separator that was not part of a set of path
360
+ // separators at the end of the string, stop now
361
+ if (!matchedSlash) {
362
+ startPart = i + 1
363
+ break
364
+ }
365
+ continue
366
+ }
367
+ if (end === -1) {
368
+ // We saw the first non-path separator, mark this as the end of our
369
+ // extension
370
+ matchedSlash = false
371
+ end = i + 1
372
+ }
373
+ if (code === 46 /*.*/) {
374
+ // If this is our first dot, mark it as the start of our extension
375
+ if (startDot === -1) startDot = i
376
+ else if (preDotState !== 1) preDotState = 1
377
+ } else if (startDot !== -1) {
378
+ // We saw a non-dot and non-path separator before our dot, so we should
379
+ // have a good chance at having a non-empty extension
380
+ preDotState = -1
381
+ }
382
+ }
383
+
384
+ if (
385
+ startDot === -1 ||
386
+ end === -1 ||
387
+ // We saw a non-dot character immediately before the dot
388
+ preDotState === 0 ||
389
+ // The (right-most) trimmed path component is exactly '..'
390
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
391
+ ) {
392
+ return ''
393
+ }
394
+ return path.slice(startDot, end)
395
+ }
396
+
397
+ export const format = function format(pathObject) {
398
+ if (pathObject === null || typeof pathObject !== 'object') {
399
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject)
400
+ }
401
+ return _format('/', pathObject)
402
+ }
403
+
404
+ export const parse = function parse(path) {
405
+ assertPath(path)
406
+
407
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' }
408
+ if (path.length === 0) return ret
409
+ var code = path.charCodeAt(0)
410
+ var isAbsolute = code === 47 /*/*/
411
+ var start
412
+ if (isAbsolute) {
413
+ ret.root = '/'
414
+ start = 1
415
+ } else {
416
+ start = 0
417
+ }
418
+ var startDot = -1
419
+ var startPart = 0
420
+ var end = -1
421
+ var matchedSlash = true
422
+ var i = path.length - 1
423
+
424
+ // Track the state of characters (if any) we see before our first dot and
425
+ // after any path separator we find
426
+ var preDotState = 0
427
+
428
+ // Get non-dir info
429
+ for (; i >= start; --i) {
430
+ code = path.charCodeAt(i)
431
+ if (code === 47 /*/*/) {
432
+ // If we reached a path separator that was not part of a set of path
433
+ // separators at the end of the string, stop now
434
+ if (!matchedSlash) {
435
+ startPart = i + 1
436
+ break
437
+ }
438
+ continue
439
+ }
440
+ if (end === -1) {
441
+ // We saw the first non-path separator, mark this as the end of our
442
+ // extension
443
+ matchedSlash = false
444
+ end = i + 1
445
+ }
446
+ if (code === 46 /*.*/) {
447
+ // If this is our first dot, mark it as the start of our extension
448
+ if (startDot === -1) startDot = i
449
+ else if (preDotState !== 1) preDotState = 1
450
+ } else if (startDot !== -1) {
451
+ // We saw a non-dot and non-path separator before our dot, so we should
452
+ // have a good chance at having a non-empty extension
453
+ preDotState = -1
454
+ }
455
+ }
456
+
457
+ if (
458
+ startDot === -1 ||
459
+ end === -1 ||
460
+ // We saw a non-dot character immediately before the dot
461
+ preDotState === 0 ||
462
+ // The (right-most) trimmed path component is exactly '..'
463
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
464
+ ) {
465
+ if (end !== -1) {
466
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end)
467
+ else ret.base = ret.name = path.slice(startPart, end)
468
+ }
469
+ } else {
470
+ if (startPart === 0 && isAbsolute) {
471
+ ret.name = path.slice(1, startDot)
472
+ ret.base = path.slice(1, end)
473
+ } else {
474
+ ret.name = path.slice(startPart, startDot)
475
+ ret.base = path.slice(startPart, end)
476
+ }
477
+ ret.ext = path.slice(startDot, end)
478
+ }
479
+
480
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1)
481
+ else if (isAbsolute) ret.dir = '/'
482
+
483
+ return ret
484
+ }
485
+
486
+ export const sep = '/'
487
+ export const delimiter = ':'
488
+ export const win32 = null
489
+ export const posix = {
490
+ parse,
491
+ format,
492
+ extname,
493
+ basename,
494
+ dirname,
495
+ _makeLong,
496
+ relative,
497
+ join,
498
+ isAbsolute,
499
+ normalize,
500
+ resolve,
501
+ _format,
502
+ normalizeStringPosix,
503
+ assertPath,
504
+ }`;
@@ -0,0 +1,2 @@
1
+ declare const _default: "\n\nfunction unimplemented(name) {\n\tthrow new Error('Node.js process ' + name + ' is not supported')\n}\n\nvar title = 'quickjs-emscripten'\nvar arch = 'wasm'\nvar platform = 'wasi'\nvar env = globalThis.env\nvar argv = globalThis.argv || globalThis.args\nvar execArgv = []\nvar version = 'v16.8.0'\nvar versions = {}\n\nvar emitWarning = (message, type) => {\n\tconsole.warn((type ? type + ': ' : '') + message)\n}\n\nvar binding = name => {\n\tunimplemented('binding')\n}\n\nvar umask = mask => 0\n\nvar cwd = () => './'\nvar chdir = dir => {\n\tunimplemented('chdir')\n}\n\nvar release = {\n\tname: 'quickjs-emscripten',\n\tsourceUrl: '',\n\theadersUrl: '',\n\tlibUrl: '',\n}\n\nfunction noop() {}\n\nvar _rawDebug = noop\nvar moduleLoadList = []\nfunction _linkedBinding(name) {\n\tunimplemented('_linkedBinding')\n}\nvar domain = {}\nvar _exiting = false\nvar config = {}\nfunction dlopen(name) {\n\tunimplemented('dlopen')\n}\nfunction _getActiveRequests() {\n\treturn []\n}\nfunction _getActiveHandles() {\n\treturn []\n}\nvar reallyExit = noop\nvar _kill = noop\nvar cpuUsage = () => ({})\nvar resourceUsage = cpuUsage\nvar memoryUsage = cpuUsage\nvar kill = noop\nvar exit = globalThis.exit\nvar openStdin = noop\nvar allowedNodeEnvironmentFlags = {}\nfunction assert(condition, message) {\n\tif (!condition) {\n\t\tthrow new Error(message || 'assertion error')\n\t}\n}\nvar features = {\n\tinspector: false,\n\tdebug: false,\n\tuv: false,\n\tipv6: false,\n\ttls_alpn: false,\n\ttls_sni: false,\n\ttls_ocsp: false,\n\ttls: false,\n\tcached_builtins: true,\n}\nvar _fatalExceptions = noop\nvar setUncaughtExceptionCaptureCallback = noop\nfunction hasUncaughtExceptionCaptureCallback() {\n\treturn false\n}\nvar _tickCallback = noop\nvar _debugProcess = noop\nvar _debugEnd = noop\nvar _startProfilerIdleNotifier = noop\nvar _stopProfilerIdleNotifier = noop\nvar stdout = undefined\nvar stderr = undefined\nvar stdin = undefined\nvar abort = noop\nvar pid = 2\nvar ppid = 1\nvar execPath = 'wasmedge-quickjs'\nvar debugPort = 9229\nvar argv0 = 'wasmedge-quickjs'\nvar _preload_modules = []\nvar setSourceMapsEnabled = noop\n\nvar _performance = {\n\tnow: undefined,\n\ttiming: undefined,\n}\nif (_performance.now === undefined) {\n\tvar nowOffset = Date.now()\n\n\tif (_performance.timing && _performance.timing.navigationStart) {\n\t\tnowOffset = _performance.timing.navigationStart\n\t}\n\t_performance.now = () => Date.now() - nowOffset\n}\n\nfunction uptime() {\n\treturn _performance.now() / 1000\n}\n\nvar nanoPerSec = 1000000000\nfunction hrtime(previousTimestamp) {\n\tvar baseNow = Math.floor((Date.now() - _performance.now()) * 1e-3)\n\tvar clocktime = _performance.now() * 1e-3\n\tvar seconds = Math.floor(clocktime) + baseNow\n\tvar nanoseconds = Math.floor((clocktime % 1) * 1e9)\n\tif (previousTimestamp) {\n\t\tseconds = seconds - previousTimestamp[0]\n\t\tnanoseconds = nanoseconds - previousTimestamp[1]\n\t\tif (nanoseconds < 0) {\n\t\t\tseconds--\n\t\t\tnanoseconds += nanoPerSec\n\t\t}\n\t}\n\treturn [seconds, nanoseconds]\n}\n\nhrtime.bigint = time => {\n\tvar diff = hrtime(time)\n\tif (typeof BigInt === 'undefined') {\n\t\treturn diff[0] * nanoPerSec + diff[1]\n\t}\n\treturn BigInt(diff[0] * nanoPerSec) + BigInt(diff[1])\n}\n\nvar _maxListeners = 10\nvar _events = {}\nvar _eventsCount = 0\nfunction on() {\n\treturn process\n}\nvar addListener = on\nvar once = on\nvar off = on\nvar removeListener = on\nvar removeAllListeners = on\nvar emit = noop\nvar prependListener = on\nvar prependOnceListener = on\nfunction listeners(name) {\n\treturn []\n}\nvar process = {\n\tversion: version,\n\tversions: versions,\n\tarch: arch,\n\tplatform: platform,\n\trelease: release,\n\t_rawDebug: _rawDebug,\n\tmoduleLoadList: moduleLoadList,\n\tbinding: binding,\n\t_linkedBinding: _linkedBinding,\n\t_events: _events,\n\t_eventsCount: _eventsCount,\n\t_maxListeners: _maxListeners,\n\ton: on,\n\taddListener: addListener,\n\tonce: once,\n\toff: off,\n\tremoveListener: removeListener,\n\tremoveAllListeners: removeAllListeners,\n\temit: emit,\n\tprependListener: prependListener,\n\tprependOnceListener: prependOnceListener,\n\tlisteners: listeners,\n\tdomain: domain,\n\t_exiting: _exiting,\n\tconfig: config,\n\tdlopen: dlopen,\n\tuptime: uptime,\n\t_getActiveRequests: _getActiveRequests,\n\t_getActiveHandles: _getActiveHandles,\n\treallyExit: reallyExit,\n\t_kill: _kill,\n\tcpuUsage: cpuUsage,\n\tresourceUsage: resourceUsage,\n\tmemoryUsage: memoryUsage,\n\tkill: kill,\n\texit: exit,\n\topenStdin: openStdin,\n\tallowedNodeEnvironmentFlags: allowedNodeEnvironmentFlags,\n\tassert: assert,\n\tfeatures: features,\n\t_fatalExceptions: _fatalExceptions,\n\tsetUncaughtExceptionCaptureCallback: setUncaughtExceptionCaptureCallback,\n\thasUncaughtExceptionCaptureCallback: hasUncaughtExceptionCaptureCallback,\n\temitWarning: emitWarning,\n\tnextTick: globalThis.nextTick,\n\t_tickCallback: _tickCallback,\n\t_debugProcess: _debugProcess,\n\t_debugEnd: _debugEnd,\n\t_startProfilerIdleNotifier: _startProfilerIdleNotifier,\n\t_stopProfilerIdleNotifier: _stopProfilerIdleNotifier,\n\tstdout: stdout,\n\tstdin: stdin,\n\tstderr: stderr,\n\tabort: abort,\n\tumask: umask,\n\tchdir: chdir,\n\tcwd: cwd,\n\tenv: env,\n\ttitle: title,\n\targv: argv,\n\texecArgv: execArgv,\n\tpid: pid,\n\tppid: ppid,\n\texecPath: execPath,\n\tdebugPort: debugPort,\n\thrtime: hrtime,\n\targv0: argv0,\n\t_preload_modules: _preload_modules,\n\tsetSourceMapsEnabled: setSourceMapsEnabled,\n}\n\nconst nextTick = globalThis.nextTick\n\nexport {\n\t_debugEnd,\n\t_debugProcess,\n\t_events,\n\t_eventsCount,\n\t_exiting,\n\t_fatalExceptions,\n\t_getActiveHandles,\n\t_getActiveRequests,\n\t_kill,\n\t_linkedBinding,\n\t_maxListeners,\n\t_preload_modules,\n\t_rawDebug,\n\t_startProfilerIdleNotifier,\n\t_stopProfilerIdleNotifier,\n\t_tickCallback,\n\tabort,\n\taddListener,\n\tallowedNodeEnvironmentFlags,\n\tarch,\n\targv,\n\targv0,\n\tassert,\n\tbinding,\n\tchdir,\n\tconfig,\n\tcpuUsage,\n\tcwd,\n\tdebugPort,\n\tprocess as default,\n\tdlopen,\n\tdomain,\n\temit,\n\temitWarning,\n\tenv,\n\texecArgv,\n\texecPath,\n\texit,\n\tfeatures,\n\thasUncaughtExceptionCaptureCallback,\n\thrtime,\n\tkill,\n\tlisteners,\n\tmemoryUsage,\n\tmoduleLoadList,\n\tnextTick,\n\toff,\n\ton,\n\tonce,\n\topenStdin,\n\tpid,\n\tplatform,\n\tppid,\n\tprependListener,\n\tprependOnceListener,\n\treallyExit,\n\trelease,\n\tremoveAllListeners,\n\tremoveListener,\n\tresourceUsage,\n\tsetSourceMapsEnabled,\n\tsetUncaughtExceptionCaptureCallback,\n\tstderr,\n\tstdin,\n\tstdout,\n\ttitle,\n\tumask,\n\tuptime,\n\tversion,\n\tversions,\n}\n";
2
+ export default _default;