@nodetool-ai/sandbox-runtime 0.0.0-stage → 0.8.9-bootstrap.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 (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,328 @@
1
+ export default `
2
+ import { resolve as pathResolve } from 'node:path'
3
+
4
+ export const access = (path, mode) => new Promise((resolve, reject) => {
5
+ try {
6
+ __fs.accessSync(pathResolve(path), mode)
7
+ resolve()
8
+ } catch (err) {
9
+ reject(err)
10
+ }
11
+ })
12
+
13
+ export const appendFile = (path, data, options) => new Promise((resolve, reject) => {
14
+ __fs.appendFile(pathResolve(path), data, options, (err) => {
15
+ if (err) {
16
+ reject(err)
17
+ } else {
18
+ resolve()
19
+ }
20
+ })
21
+ })
22
+
23
+ export const chmod = (path, mode) => new Promise((resolve, reject) => {
24
+ try {
25
+ __fs.chmodSync(pathResolve(path), mode)
26
+ resolve()
27
+ } catch (err) {
28
+ reject(err)
29
+ }
30
+ })
31
+
32
+ export const chown = (path, uid, gid) => new Promise((resolve, reject) => {
33
+ try {
34
+ __fs.chownSync(pathResolve(path), uid, gid)
35
+ resolve()
36
+ } catch (err) {
37
+ reject(err)
38
+ }
39
+ })
40
+
41
+ export const close = (fd) => new Promise((resolve, reject) => {
42
+ __fs.close(fd, (err) => {
43
+ if (err) {
44
+ reject(err)
45
+ } else {
46
+ resolve()
47
+ }
48
+ })
49
+ })
50
+
51
+ export const copyFile = (src, dest, mode) => new Promise((resolve, reject) => {
52
+ __fs.copyFile(pathResolve(src), pathResolve(dest), mode, (err) => {
53
+ if (err) {
54
+ reject(err)
55
+ } else {
56
+ resolve()
57
+ }
58
+ })
59
+ })
60
+
61
+ export const createReadStream = (...params) => __fs.createReadStream(...params)
62
+ export const createWriteStream = (...params) => __fs.createWriteStream(...params)
63
+
64
+ export const exists = (path) => new Promise((resolve) => {
65
+ __fs.exists(pathResolve(path), (exists) => {
66
+ resolve(exists)
67
+ })
68
+ })
69
+
70
+ export const fchmod = (path, mode) => new Promise((resolve, reject) => {
71
+ try {
72
+ __fs.fchmodSync(pathResolve(path), mode)
73
+ resolve()
74
+ } catch (err) {
75
+ reject(err)
76
+ }
77
+ })
78
+
79
+ export const fchown = (path, uid, gid) => new Promise((resolve, reject) => {
80
+ try {
81
+ __fs.fchownSync(pathResolve(path), uid, gid)
82
+ resolve()
83
+ } catch (err) {
84
+ reject(err)
85
+ }
86
+ })
87
+
88
+ export const fdatasync = (fd) => new Promise((resolve, reject) => {
89
+ __fs.fdatasync(fd, (err) => {
90
+ if (err) {
91
+ reject(err)
92
+ } else {
93
+ resolve()
94
+ }
95
+ })
96
+ })
97
+
98
+ export const fstat = (path) => new Promise((resolve, reject) => {
99
+ try {
100
+ const stats = __fs.fstatSync(pathResolve(path))
101
+ resolve(stats)
102
+ } catch (err) {
103
+ reject(err)
104
+ }
105
+ })
106
+
107
+ export const fsync = (fd) => new Promise((resolve, reject) => {
108
+ __fs.fsync(fd, (err) => {
109
+ if (err) {
110
+ reject(err)
111
+ } else {
112
+ resolve()
113
+ }
114
+ })
115
+ })
116
+
117
+ export const ftruncate = (fd, len) => new Promise((resolve, reject) => {
118
+ try {
119
+ __fs.ftruncateSync(fd, len)
120
+ resolve()
121
+ } catch (err) {
122
+ reject(err)
123
+ }
124
+ })
125
+
126
+ export const futimes = (fd, atime, mtime) => new Promise((resolve, reject) => {
127
+ try {
128
+ __fs.futimesSync(fd, atime, mtime)
129
+ resolve()
130
+ } catch (err) {
131
+ reject(err)
132
+ }
133
+ })
134
+
135
+ export const lchmod = (path, mode) => new Promise((resolve, reject) => {
136
+ try {
137
+ __fs.lchmodSync(pathResolve(path), mode)
138
+ resolve()
139
+ } catch (err) {
140
+ reject(err)
141
+ }
142
+ })
143
+
144
+ export const lchown = (path, uid, gid) => new Promise((resolve, reject) => {
145
+ try {
146
+ __fs.lchownSync(pathResolve(path), uid, gid)
147
+ resolve()
148
+ } catch (err) {
149
+ reject(err)
150
+ }
151
+ })
152
+
153
+ export const link = (existingPath, newPath) => new Promise((resolve, reject) => {
154
+ try {
155
+ __fs.linkSync(pathResolve(existingPath), pathResolve(newPath))
156
+ resolve()
157
+ } catch (err) {
158
+ reject(err)
159
+ }
160
+ })
161
+
162
+ export const lstat = (path) => new Promise((resolve, reject) => {
163
+ try {
164
+ const stats = __fs.lstatSync(pathResolve(path))
165
+ resolve(stats)
166
+ } catch (err) {
167
+ reject(err)
168
+ }
169
+ })
170
+
171
+ export const mkdir = (path, options) => new Promise((resolve, reject) => {
172
+ try {
173
+ const res = __fs.mkdirSync(pathResolve(path), options)
174
+ resolve(res)
175
+ } catch(err) {
176
+ reject(err)
177
+ }
178
+ })
179
+
180
+ export const mkdtemp = (prefix, options) => new Promise((resolve, reject) => {
181
+ try {
182
+ const res = __fs.mkdtempSync(prefix, options)
183
+ resolve(res)
184
+ } catch(err) {
185
+ reject(err)
186
+ }
187
+ })
188
+
189
+ export const open = (path, flags, mode) => new Promise((resolve, reject) => {
190
+ __fs.open(pathResolve(path), flags, mode, (err, fd) => {
191
+ if (err) {
192
+ reject(err)
193
+ } else {
194
+ resolve(fd)
195
+ }
196
+ })
197
+ })
198
+
199
+ export const readdir = (path, options) => new Promise((resolve, reject) => {
200
+ try {
201
+ const res = __fs.readdirSync(pathResolve(path), options)
202
+ resolve(res)
203
+ } catch(err) {
204
+ reject(err)
205
+ }
206
+ })
207
+
208
+ export const read = (fd, buffer, offset, length, position) => new Promise((resolve, reject) => {
209
+ __fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
210
+ if (err) {
211
+ reject(err)
212
+ } else {
213
+ resolve({ bytesRead, buffer })
214
+ }
215
+ })
216
+ })
217
+
218
+ export const readFile = (path, options) => new Promise((resolve, reject) => {
219
+ try {
220
+ const res = __fs.readFileSync(pathResolve(path), options)
221
+ resolve(res)
222
+ } catch (err) {
223
+ reject(err)
224
+ }
225
+ })
226
+
227
+ export const readlink = (path, options) => new Promise((resolve, reject) => {
228
+ try {
229
+ const linkString = __fs.readlinkSync(pathResolve(path), options)
230
+ resolve(linkString)
231
+ } catch (err) {
232
+ reject(err)
233
+ }
234
+ })
235
+
236
+ export const realpath = (path, options) => new Promise((resolve, reject) => {
237
+ try {
238
+ const resolvedPath = __fs.realpathSync(pathResolve(path), options)
239
+ resolve(resolvedPath)
240
+ } catch (err) {
241
+ reject(err)
242
+ }
243
+ })
244
+
245
+ export const rename = (oldPath, newPath) => new Promise((resolve, reject) => {
246
+ __fs.rename(pathResolve(oldPath), pathResolve(newPath), (err) => {
247
+ if (err) {
248
+ reject(err)
249
+ } else {
250
+ resolve()
251
+ }
252
+ })
253
+ })
254
+
255
+ export const rmdir = (path) => new Promise((resolve, reject) => {
256
+ try {
257
+ const res = __fs.rmdirSync(pathResolve(path))
258
+ resolve(res)
259
+ } catch(err) {
260
+ reject(err)
261
+ }
262
+ })
263
+
264
+ export const stat = (path) => new Promise((resolve, reject) => {
265
+ try {
266
+ const stats = __fs.statSync(pathResolve(path))
267
+ resolve(stats)
268
+ } catch (err) {
269
+ reject(err)
270
+ }
271
+ })
272
+
273
+ export const symlink = (target, path, type) => new Promise((resolve, reject) => {
274
+ try {
275
+ __fs.symlinkSync(target, pathResolve(path), type)
276
+ resolve()
277
+ } catch (err) {
278
+ reject(err)
279
+ }
280
+ })
281
+
282
+ export const truncate = (path, len) => new Promise((resolve, reject) => {
283
+ try {
284
+ __fs.truncateSync(pathResolve(path), len)
285
+ resolve()
286
+ } catch (err) {
287
+ reject(err)
288
+ }
289
+ })
290
+
291
+ export const unlink = (path) => new Promise((resolve, reject) => {
292
+ try {
293
+ __fs.unlinkSync(pathResolve(path))
294
+ resolve()
295
+ } catch (err) {
296
+ reject(err)
297
+ }
298
+ })
299
+
300
+ export const utimes = (path, atime, mtime) => new Promise((resolve, reject) => {
301
+ try {
302
+ __fs.utimesSync(pathResolve(path), atime, mtime)
303
+ resolve()
304
+ } catch (err) {
305
+ reject(err)
306
+ }
307
+ })
308
+
309
+ export const write = (fd, buffer, offset, length, position) => new Promise((resolve, reject) => {
310
+ __fs.write(fd, buffer, offset, length, position, (err, written, buffer) => {
311
+ if (err) {
312
+ reject(err)
313
+ } else {
314
+ resolve({ written, buffer })
315
+ }
316
+ })
317
+ })
318
+
319
+ export const writeFile = (file, data, options) => new Promise((resolve, reject) => {
320
+ try{
321
+ const res = __fs.writeFileSync(pathResolve(file), data, options)
322
+ return resolve(res)
323
+ }catch(err) {
324
+ return reject(err)
325
+ }
326
+
327
+ })
328
+ `;
@@ -0,0 +1,2 @@
1
+ declare const _default: "\nimport { resolve } from 'node:path'\nimport { readFileSync } from 'node:fs'\n\nexport const builtinModules = ['node:assert', 'node:fs', 'node:module', 'node:path', 'node:util']\n\nexport const createRequire = parentFilename => {\n const parts = baseName.split('/')\n\tparts.pop()\n\tconst parent = parts.join('/')\n\n\treturn fileName => {\n console.log('custom require', fileName)\n\t\tconst filePath = resolve('/',parent, fileName)\n\t\treturn readFileSync(filePath)\n\t}\n}\n\nexport const isBuiltin = moduleName =>\n\tbuiltinModules.some(module => module.replace('node:', '') === moduleName.replace('node:', ''))\n\nexport const register = () => {\n\tconsole.error('node:module method register is not available in sandbox')\n\tthrow new Error('node:module method register is not available in sandbox')\n}\n\nexport const syncBuiltinESMExports = () => {\n\tconsole.error('node:module method syncBuiltinESMExports is not available in sandbox')\n\tthrow new Error('node:module method syncBuiltinESMExports is not available in sandbox')\n}\n\nexport default { builtinModules, createRequire, isBuiltin, register, syncBuiltinESMExports }\n";
2
+ export default _default;
@@ -0,0 +1,33 @@
1
+ export default `
2
+ import { resolve } from 'node:path'
3
+ import { readFileSync } from 'node:fs'
4
+
5
+ export const builtinModules = ['node:assert', 'node:fs', 'node:module', 'node:path', 'node:util']
6
+
7
+ export const createRequire = parentFilename => {
8
+ const parts = baseName.split('/')
9
+ parts.pop()
10
+ const parent = parts.join('/')
11
+
12
+ return fileName => {
13
+ console.log('custom require', fileName)
14
+ const filePath = resolve('/',parent, fileName)
15
+ return readFileSync(filePath)
16
+ }
17
+ }
18
+
19
+ export const isBuiltin = moduleName =>
20
+ builtinModules.some(module => module.replace('node:', '') === moduleName.replace('node:', ''))
21
+
22
+ export const register = () => {
23
+ console.error('node:module method register is not available in sandbox')
24
+ throw new Error('node:module method register is not available in sandbox')
25
+ }
26
+
27
+ export const syncBuiltinESMExports = () => {
28
+ console.error('node:module method syncBuiltinESMExports is not available in sandbox')
29
+ throw new Error('node:module method syncBuiltinESMExports is not available in sandbox')
30
+ }
31
+
32
+ export default { builtinModules, createRequire, isBuiltin, register, syncBuiltinESMExports }
33
+ `;
@@ -0,0 +1,2 @@
1
+ declare const _default: "if (typeof globalThis.Headers === 'undefined') {\nclass Headers {\n constructor(init) {\n this.map = {};\n\n if (init instanceof Headers) {\n init.forEach((value, name) => {\n this.append(name, value);\n });\n } else if (init) {\n Object.getOwnPropertyNames(init).forEach(name => {\n this.append(name, init[name]);\n });\n }\n }\n\n append(name, value) {\n name = name.toLowerCase();\n if (this.map[name]) {\n this.map[name].push(value);\n } else {\n this.map[name] = [value];\n }\n }\n\n delete(name) {\n delete this.map[name.toLowerCase()];\n }\n\n get(name) {\n name = name.toLowerCase();\n return this.map[name] ? this.map[name][0] : null;\n }\n\n getAll(name) {\n return this.map[name.toLowerCase()] || [];\n }\n\n has(name) {\n return this.map.hasOwnProperty(name.toLowerCase());\n }\n\n set(name, value) {\n this.map[name.toLowerCase()] = [value];\n }\n \n forEach(callback, thisArg) {\n Object.getOwnPropertyNames(this.map).forEach(name => {\n this.map[name].forEach(value => {\n callback.call(thisArg, value, name, this);\n });\n });\n }\n}\nglobalThis.Headers = Headers;\n}\nexport default globalThis.Headers;\n";
2
+ export default _default;
@@ -0,0 +1,58 @@
1
+ export default `if (typeof globalThis.Headers === 'undefined') {
2
+ class Headers {
3
+ constructor(init) {
4
+ this.map = {};
5
+
6
+ if (init instanceof Headers) {
7
+ init.forEach((value, name) => {
8
+ this.append(name, value);
9
+ });
10
+ } else if (init) {
11
+ Object.getOwnPropertyNames(init).forEach(name => {
12
+ this.append(name, init[name]);
13
+ });
14
+ }
15
+ }
16
+
17
+ append(name, value) {
18
+ name = name.toLowerCase();
19
+ if (this.map[name]) {
20
+ this.map[name].push(value);
21
+ } else {
22
+ this.map[name] = [value];
23
+ }
24
+ }
25
+
26
+ delete(name) {
27
+ delete this.map[name.toLowerCase()];
28
+ }
29
+
30
+ get(name) {
31
+ name = name.toLowerCase();
32
+ return this.map[name] ? this.map[name][0] : null;
33
+ }
34
+
35
+ getAll(name) {
36
+ return this.map[name.toLowerCase()] || [];
37
+ }
38
+
39
+ has(name) {
40
+ return this.map.hasOwnProperty(name.toLowerCase());
41
+ }
42
+
43
+ set(name, value) {
44
+ this.map[name.toLowerCase()] = [value];
45
+ }
46
+
47
+ forEach(callback, thisArg) {
48
+ Object.getOwnPropertyNames(this.map).forEach(name => {
49
+ this.map[name].forEach(value => {
50
+ callback.call(thisArg, value, name, this);
51
+ });
52
+ });
53
+ }
54
+ }
55
+ globalThis.Headers = Headers;
56
+ }
57
+ export default globalThis.Headers;
58
+ `;
@@ -0,0 +1,2 @@
1
+ declare const _default: "\nconst RequestClass = typeof Request !== 'undefined' ? Request : class Request {};\nglobalThis.Request = RequestClass;\nexport default RequestClass;\n";
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ export default `
2
+ const RequestClass = typeof Request !== 'undefined' ? Request : class Request {};
3
+ globalThis.Request = RequestClass;
4
+ export default RequestClass;
5
+ `;
@@ -0,0 +1,2 @@
1
+ declare const _default: "\nconst ResponseClass = typeof Response !== 'undefined' ? Response : class Response {};\nglobalThis.Response = ResponseClass;\nexport default ResponseClass;\n";
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ export default `
2
+ const ResponseClass = typeof Response !== 'undefined' ? Response : class Response {};
3
+ globalThis.Response = ResponseClass;
4
+ export default ResponseClass;
5
+ `;
@@ -0,0 +1,2 @@
1
+ declare const _default: "\n\nexport function assertPath(path) {\n\tif (typeof path !== 'string') {\n\t\tthrow new TypeError('Path must be a string. Received ' + JSON.stringify(path))\n\t}\n}\n\n// Resolves . and .. elements in a path with directory names\nexport function normalizeStringPosix(path, allowAboveRoot) {\n\tvar res = ''\n\tvar lastSegmentLength = 0\n\tvar lastSlash = -1\n\tvar dots = 0\n\tvar code\n\tfor (var i = 0; i <= path.length; ++i) {\n\t\tif (i < path.length) code = path.charCodeAt(i)\n\t\telse if (code === 47 /*/*/) break\n\t\telse code = 47 /*/*/\n\t\tif (code === 47 /*/*/) {\n\t\t\tif (lastSlash === i - 1 || dots === 1) {\n\t\t\t\t// NOOP\n\t\t\t} else if (lastSlash !== i - 1 && dots === 2) {\n\t\t\t\tif (\n\t\t\t\t\tres.length < 2 ||\n\t\t\t\t\tlastSegmentLength !== 2 ||\n\t\t\t\t\tres.charCodeAt(res.length - 1) !== 46 /*.*/ ||\n\t\t\t\t\tres.charCodeAt(res.length - 2) !== 46 /*.*/\n\t\t\t\t) {\n\t\t\t\t\tif (res.length > 2) {\n\t\t\t\t\t\tvar lastSlashIndex = res.lastIndexOf('/')\n\t\t\t\t\t\tif (lastSlashIndex !== res.length - 1) {\n\t\t\t\t\t\t\tif (lastSlashIndex === -1) {\n\t\t\t\t\t\t\t\tres = ''\n\t\t\t\t\t\t\t\tlastSegmentLength = 0\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tres = res.slice(0, lastSlashIndex)\n\t\t\t\t\t\t\t\tlastSegmentLength = res.length - 1 - res.lastIndexOf('/')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlastSlash = i\n\t\t\t\t\t\t\tdots = 0\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (res.length === 2 || res.length === 1) {\n\t\t\t\t\t\tres = ''\n\t\t\t\t\t\tlastSegmentLength = 0\n\t\t\t\t\t\tlastSlash = i\n\t\t\t\t\t\tdots = 0\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (allowAboveRoot) {\n\t\t\t\t\tif (res.length > 0) res += '/..'\n\t\t\t\t\telse res = '..'\n\t\t\t\t\tlastSegmentLength = 2\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (res.length > 0) res += '/' + path.slice(lastSlash + 1, i)\n\t\t\t\telse res = path.slice(lastSlash + 1, i)\n\t\t\t\tlastSegmentLength = i - lastSlash - 1\n\t\t\t}\n\t\t\tlastSlash = i\n\t\t\tdots = 0\n\t\t} else if (code === 46 /*.*/ && dots !== -1) {\n\t\t\t++dots\n\t\t} else {\n\t\t\tdots = -1\n\t\t}\n\t}\n\treturn res\n}\n\nfunction _format(sep, pathObject) {\n\tvar dir = pathObject.dir || pathObject.root\n\tvar base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '')\n\tif (!dir) {\n\t\treturn base\n\t}\n\tif (dir === pathObject.root) {\n\t\treturn dir + base\n\t}\n\treturn dir + sep + base\n}\n\n// path.resolve([from ...], to)\nexport const resolve = function resolve() {\n\tvar resolvedPath = ''\n\tvar resolvedAbsolute = false\n\tvar cwd\n\n\tfor (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n\t\tvar path\n\t\tif (i >= 0) path = arguments[i]\n\t\telse {\n\t\t\tif (cwd === undefined) cwd = process.cwd()\n\t\t\tpath = cwd\n\t\t}\n\n\t\tassertPath(path)\n\n\t\t// Skip empty entries\n\t\tif (path.length === 0) {\n\t\t\tcontinue\n\t\t}\n\n\t\tresolvedPath = path + '/' + resolvedPath\n\t\tresolvedAbsolute = path.charCodeAt(0) === 47 /*/*/\n\t}\n\n\t// At this point the path should be resolved to a full absolute path, but\n\t// handle relative paths to be safe (might happen when process.cwd() fails)\n\n\t// Normalize the path\n\tresolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute)\n\n\tif (resolvedAbsolute) {\n\t\tif (resolvedPath.length > 0) return '/' + resolvedPath\n\t\telse return '/'\n\t} else if (resolvedPath.length > 0) {\n\t\treturn resolvedPath\n\t} else {\n\t\treturn '.'\n\t}\n}\n\nexport const normalize = function normalize(path) {\n\tassertPath(path)\n\n\tif (path.length === 0) return '.'\n\n\tvar isAbsolute = path.charCodeAt(0) === 47 /*/*/\n\tvar trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/\n\n\t// Normalize the path\n\tpath = normalizeStringPosix(path, !isAbsolute)\n\n\tif (path.length === 0 && !isAbsolute) path = '.'\n\tif (path.length > 0 && trailingSeparator) path += '/'\n\n\tif (isAbsolute) return '/' + path\n\treturn path\n}\n\nexport const isAbsolute = function isAbsolute(path) {\n\tassertPath(path)\n\treturn path.length > 0 && path.charCodeAt(0) === 47 /*/*/\n}\n\nexport const join = function join() {\n\tif (arguments.length === 0) return '.'\n\tvar joined\n\tfor (var i = 0; i < arguments.length; ++i) {\n\t\tvar arg = arguments[i]\n\t\tassertPath(arg)\n\t\tif (arg.length > 0) {\n\t\t\tif (joined === undefined) joined = arg\n\t\t\telse joined += '/' + arg\n\t\t}\n\t}\n\tif (joined === undefined) return '.'\n\treturn normalize(joined)\n}\n\nexport const relative = function relative(from, to) {\n\tassertPath(from)\n\tassertPath(to)\n\n\tif (from === to) return ''\n\n\tfrom = resolve(from)\n\tto = resolve(to)\n\n\tif (from === to) return ''\n\n\t// Trim any leading backslashes\n\tvar fromStart = 1\n\tfor (; fromStart < from.length; ++fromStart) {\n\t\tif (from.charCodeAt(fromStart) !== 47 /*/*/) break\n\t}\n\tvar fromEnd = from.length\n\tvar fromLen = fromEnd - fromStart\n\n\t// Trim any leading backslashes\n\tvar toStart = 1\n\tfor (; toStart < to.length; ++toStart) {\n\t\tif (to.charCodeAt(toStart) !== 47 /*/*/) break\n\t}\n\tvar toEnd = to.length\n\tvar toLen = toEnd - toStart\n\n\t// Compare paths to find the longest common path from root\n\tvar length = fromLen < toLen ? fromLen : toLen\n\tvar lastCommonSep = -1\n\tvar i = 0\n\tfor (; i <= length; ++i) {\n\t\tif (i === length) {\n\t\t\tif (toLen > length) {\n\t\t\t\tif (to.charCodeAt(toStart + i) === 47 /*/*/) {\n\t\t\t\t\t// We get here if `from` is the exact base path for `to`.\n\t\t\t\t\t// For example: from='/foo/bar'; to='/foo/bar/baz'\n\t\t\t\t\treturn to.slice(toStart + i + 1)\n\t\t\t\t} else if (i === 0) {\n\t\t\t\t\t// We get here if `from` is the root\n\t\t\t\t\t// For example: from='/'; to='/foo'\n\t\t\t\t\treturn to.slice(toStart + i)\n\t\t\t\t}\n\t\t\t} else if (fromLen > length) {\n\t\t\t\tif (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n\t\t\t\t\t// We get here if `to` is the exact base path for `from`.\n\t\t\t\t\t// For example: from='/foo/bar/baz'; to='/foo/bar'\n\t\t\t\t\tlastCommonSep = i\n\t\t\t\t} else if (i === 0) {\n\t\t\t\t\t// We get here if `to` is the root.\n\t\t\t\t\t// For example: from='/foo'; to='/'\n\t\t\t\t\tlastCommonSep = 0\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tvar fromCode = from.charCodeAt(fromStart + i)\n\t\tvar toCode = to.charCodeAt(toStart + i)\n\t\tif (fromCode !== toCode) break\n\t\telse if (fromCode === 47 /*/*/) lastCommonSep = i\n\t}\n\n\tvar out = ''\n\t// Generate the relative path based on the path difference between `to`\n\t// and `from`\n\tfor (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n\t\tif (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n\t\t\tif (out.length === 0) out += '..'\n\t\t\telse out += '/..'\n\t\t}\n\t}\n\n\t// Lastly, append the rest of the destination (`to`) path that comes after\n\t// the common path parts\n\tif (out.length > 0) return out + to.slice(toStart + lastCommonSep)\n\telse {\n\t\ttoStart += lastCommonSep\n\t\tif (to.charCodeAt(toStart) === 47 /*/*/) ++toStart\n\t\treturn to.slice(toStart)\n\t}\n}\n\nexport const _makeLong = function _makeLong(path) {\n\treturn path\n}\n\nexport const dirname = function dirname(path) {\n\tassertPath(path)\n\tif (path.length === 0) return '.'\n\tvar code = path.charCodeAt(0)\n\tvar hasRoot = code === 47 /*/*/\n\tvar end = -1\n\tvar matchedSlash = true\n\tfor (var i = path.length - 1; i >= 1; --i) {\n\t\tcode = path.charCodeAt(i)\n\t\tif (code === 47 /*/*/) {\n\t\t\tif (!matchedSlash) {\n\t\t\t\tend = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\t// We saw the first non-path separator\n\t\t\tmatchedSlash = false\n\t\t}\n\t}\n\n\tif (end === -1) return hasRoot ? '/' : '.'\n\tif (hasRoot && end === 1) return '//'\n\treturn path.slice(0, end)\n}\n\nexport const basename = function basename(path, ext) {\n\tif (ext !== undefined && typeof ext !== 'string') throw new TypeError('\"ext\" argument must be a string')\n\tassertPath(path)\n\n\tvar start = 0\n\tvar end = -1\n\tvar matchedSlash = true\n\tvar i\n\n\tif (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n\t\tif (ext.length === path.length && ext === path) return ''\n\t\tvar extIdx = ext.length - 1\n\t\tvar firstNonSlashEnd = -1\n\t\tfor (i = path.length - 1; i >= 0; --i) {\n\t\t\tvar code = path.charCodeAt(i)\n\t\t\tif (code === 47 /*/*/) {\n\t\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t\t// separators at the end of the string, stop now\n\t\t\t\tif (!matchedSlash) {\n\t\t\t\t\tstart = i + 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (firstNonSlashEnd === -1) {\n\t\t\t\t\t// We saw the first non-path separator, remember this index in case\n\t\t\t\t\t// we need it if the extension ends up not matching\n\t\t\t\t\tmatchedSlash = false\n\t\t\t\t\tfirstNonSlashEnd = i + 1\n\t\t\t\t}\n\t\t\t\tif (extIdx >= 0) {\n\t\t\t\t\t// Try to match the explicit extension\n\t\t\t\t\tif (code === ext.charCodeAt(extIdx)) {\n\t\t\t\t\t\tif (--extIdx === -1) {\n\t\t\t\t\t\t\t// We matched the extension, so mark this as the end of our path\n\t\t\t\t\t\t\t// component\n\t\t\t\t\t\t\tend = i\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Extension does not match, so our result is the entire path\n\t\t\t\t\t\t// component\n\t\t\t\t\t\textIdx = -1\n\t\t\t\t\t\tend = firstNonSlashEnd\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (start === end) end = firstNonSlashEnd\n\t\telse if (end === -1) end = path.length\n\t\treturn path.slice(start, end)\n\t} else {\n\t\tfor (i = path.length - 1; i >= 0; --i) {\n\t\t\tif (path.charCodeAt(i) === 47 /*/*/) {\n\t\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t\t// separators at the end of the string, stop now\n\t\t\t\tif (!matchedSlash) {\n\t\t\t\t\tstart = i + 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if (end === -1) {\n\t\t\t\t// We saw the first non-path separator, mark this as the end of our\n\t\t\t\t// path component\n\t\t\t\tmatchedSlash = false\n\t\t\t\tend = i + 1\n\t\t\t}\n\t\t}\n\n\t\tif (end === -1) return ''\n\t\treturn path.slice(start, end)\n\t}\n}\n\nexport const extname = function extname(path) {\n\tassertPath(path)\n\tvar startDot = -1\n\tvar startPart = 0\n\tvar end = -1\n\tvar matchedSlash = true\n\t// Track the state of characters (if any) we see before our first dot and\n\t// after any path separator we find\n\tvar preDotState = 0\n\tfor (var i = path.length - 1; i >= 0; --i) {\n\t\tvar code = path.charCodeAt(i)\n\t\tif (code === 47 /*/*/) {\n\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t// separators at the end of the string, stop now\n\t\t\tif (!matchedSlash) {\n\t\t\t\tstartPart = i + 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif (end === -1) {\n\t\t\t// We saw the first non-path separator, mark this as the end of our\n\t\t\t// extension\n\t\t\tmatchedSlash = false\n\t\t\tend = i + 1\n\t\t}\n\t\tif (code === 46 /*.*/) {\n\t\t\t// If this is our first dot, mark it as the start of our extension\n\t\t\tif (startDot === -1) startDot = i\n\t\t\telse if (preDotState !== 1) preDotState = 1\n\t\t} else if (startDot !== -1) {\n\t\t\t// We saw a non-dot and non-path separator before our dot, so we should\n\t\t\t// have a good chance at having a non-empty extension\n\t\t\tpreDotState = -1\n\t\t}\n\t}\n\n\tif (\n\t\tstartDot === -1 ||\n\t\tend === -1 ||\n\t\t// We saw a non-dot character immediately before the dot\n\t\tpreDotState === 0 ||\n\t\t// The (right-most) trimmed path component is exactly '..'\n\t\t(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)\n\t) {\n\t\treturn ''\n\t}\n\treturn path.slice(startDot, end)\n}\n\nexport const format = function format(pathObject) {\n\tif (pathObject === null || typeof pathObject !== 'object') {\n\t\tthrow new TypeError('The \"pathObject\" argument must be of type Object. Received type ' + typeof pathObject)\n\t}\n\treturn _format('/', pathObject)\n}\n\nexport const parse = function parse(path) {\n\tassertPath(path)\n\n\tvar ret = { root: '', dir: '', base: '', ext: '', name: '' }\n\tif (path.length === 0) return ret\n\tvar code = path.charCodeAt(0)\n\tvar isAbsolute = code === 47 /*/*/\n\tvar start\n\tif (isAbsolute) {\n\t\tret.root = '/'\n\t\tstart = 1\n\t} else {\n\t\tstart = 0\n\t}\n\tvar startDot = -1\n\tvar startPart = 0\n\tvar end = -1\n\tvar matchedSlash = true\n\tvar i = path.length - 1\n\n\t// Track the state of characters (if any) we see before our first dot and\n\t// after any path separator we find\n\tvar preDotState = 0\n\n\t// Get non-dir info\n\tfor (; i >= start; --i) {\n\t\tcode = path.charCodeAt(i)\n\t\tif (code === 47 /*/*/) {\n\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t// separators at the end of the string, stop now\n\t\t\tif (!matchedSlash) {\n\t\t\t\tstartPart = i + 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif (end === -1) {\n\t\t\t// We saw the first non-path separator, mark this as the end of our\n\t\t\t// extension\n\t\t\tmatchedSlash = false\n\t\t\tend = i + 1\n\t\t}\n\t\tif (code === 46 /*.*/) {\n\t\t\t// If this is our first dot, mark it as the start of our extension\n\t\t\tif (startDot === -1) startDot = i\n\t\t\telse if (preDotState !== 1) preDotState = 1\n\t\t} else if (startDot !== -1) {\n\t\t\t// We saw a non-dot and non-path separator before our dot, so we should\n\t\t\t// have a good chance at having a non-empty extension\n\t\t\tpreDotState = -1\n\t\t}\n\t}\n\n\tif (\n\t\tstartDot === -1 ||\n\t\tend === -1 ||\n\t\t// We saw a non-dot character immediately before the dot\n\t\tpreDotState === 0 ||\n\t\t// The (right-most) trimmed path component is exactly '..'\n\t\t(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)\n\t) {\n\t\tif (end !== -1) {\n\t\t\tif (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end)\n\t\t\telse ret.base = ret.name = path.slice(startPart, end)\n\t\t}\n\t} else {\n\t\tif (startPart === 0 && isAbsolute) {\n\t\t\tret.name = path.slice(1, startDot)\n\t\t\tret.base = path.slice(1, end)\n\t\t} else {\n\t\t\tret.name = path.slice(startPart, startDot)\n\t\t\tret.base = path.slice(startPart, end)\n\t\t}\n\t\tret.ext = path.slice(startDot, end)\n\t}\n\n\tif (startPart > 0) ret.dir = path.slice(0, startPart - 1)\n\telse if (isAbsolute) ret.dir = '/'\n\n\treturn ret\n}\n\nexport const sep = '/'\nexport const delimiter = ':'\nexport const win32 = null\nexport const posix = {\n\tparse,\n\tformat,\n\textname,\n\tbasename,\n\tdirname,\n\t_makeLong,\n\trelative,\n\tjoin,\n\tisAbsolute,\n\tnormalize,\n\tresolve,\n\t_format,\n\tnormalizeStringPosix,\n\tassertPath,\n}";
2
+ export default _default;