Spaces:
Configuration error
Configuration error
luigi12345
commited on
Commit
•
82c35a0
1
Parent(s):
0f38029
5185c28ecedf020500e04c7e4fc8c53c35ecdb580b593a6dd23e23ccf19a325e
Browse files- workers1/auto3d/node_modules/@esbuild-plugins/node-globals-polyfill/process.js +245 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-globals-polyfill/src/index.test.ts +155 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-globals-polyfill/src/index.ts +84 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts +8 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js +127 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts +2 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js +183 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts +2 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js +61 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts +8 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js +120 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts +2 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js +178 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts +2 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js +57 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js.map +1 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/package.json +33 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.test.ts +200 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.ts +133 -0
- workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/src/polyfills.ts +151 -0
- workers1/auto3d/node_modules/@fastify/busboy/LICENSE +19 -0
- workers1/auto3d/node_modules/@fastify/busboy/README.md +271 -0
- workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/LICENSE +19 -0
- workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js +213 -0
- workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js +100 -0
- workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js +13 -0
- workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts +164 -0
- workers1/auto3d/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js +228 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/main.d.ts +196 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/main.js +85 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/types/multipart.js +306 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/types/urlencoded.js +190 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/utils/Decoder.js +54 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/utils/basename.js +14 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/utils/decodeText.js +114 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/utils/getLimit.js +16 -0
- workers1/auto3d/node_modules/@fastify/busboy/lib/utils/parseParams.js +196 -0
- workers1/auto3d/node_modules/@fastify/busboy/package.json +86 -0
- workers1/auto3d/node_modules/@jridgewell/resolve-uri/LICENSE +19 -0
workers1/auto3d/node_modules/@esbuild-plugins/node-globals-polyfill/process.js
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// shim for using process in browser
|
2 |
+
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
3 |
+
|
4 |
+
function defaultSetTimout() {
|
5 |
+
throw new Error('setTimeout has not been defined')
|
6 |
+
}
|
7 |
+
function defaultClearTimeout() {
|
8 |
+
throw new Error('clearTimeout has not been defined')
|
9 |
+
}
|
10 |
+
var cachedSetTimeout = defaultSetTimout
|
11 |
+
var cachedClearTimeout = defaultClearTimeout
|
12 |
+
if (typeof global.setTimeout === 'function') {
|
13 |
+
cachedSetTimeout = setTimeout
|
14 |
+
}
|
15 |
+
if (typeof global.clearTimeout === 'function') {
|
16 |
+
cachedClearTimeout = clearTimeout
|
17 |
+
}
|
18 |
+
|
19 |
+
function runTimeout(fun) {
|
20 |
+
if (cachedSetTimeout === setTimeout) {
|
21 |
+
//normal enviroments in sane situations
|
22 |
+
return setTimeout(fun, 0)
|
23 |
+
}
|
24 |
+
// if setTimeout wasn't available but was latter defined
|
25 |
+
if (
|
26 |
+
(cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) &&
|
27 |
+
setTimeout
|
28 |
+
) {
|
29 |
+
cachedSetTimeout = setTimeout
|
30 |
+
return setTimeout(fun, 0)
|
31 |
+
}
|
32 |
+
try {
|
33 |
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
34 |
+
return cachedSetTimeout(fun, 0)
|
35 |
+
} catch (e) {
|
36 |
+
try {
|
37 |
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
38 |
+
return cachedSetTimeout.call(null, fun, 0)
|
39 |
+
} catch (e) {
|
40 |
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
41 |
+
return cachedSetTimeout.call(this, fun, 0)
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
function runClearTimeout(marker) {
|
46 |
+
if (cachedClearTimeout === clearTimeout) {
|
47 |
+
//normal enviroments in sane situations
|
48 |
+
return clearTimeout(marker)
|
49 |
+
}
|
50 |
+
// if clearTimeout wasn't available but was latter defined
|
51 |
+
if (
|
52 |
+
(cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) &&
|
53 |
+
clearTimeout
|
54 |
+
) {
|
55 |
+
cachedClearTimeout = clearTimeout
|
56 |
+
return clearTimeout(marker)
|
57 |
+
}
|
58 |
+
try {
|
59 |
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
60 |
+
return cachedClearTimeout(marker)
|
61 |
+
} catch (e) {
|
62 |
+
try {
|
63 |
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
64 |
+
return cachedClearTimeout.call(null, marker)
|
65 |
+
} catch (e) {
|
66 |
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
67 |
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
68 |
+
return cachedClearTimeout.call(this, marker)
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
var queue = []
|
73 |
+
var draining = false
|
74 |
+
var currentQueue
|
75 |
+
var queueIndex = -1
|
76 |
+
|
77 |
+
function cleanUpNextTick() {
|
78 |
+
if (!draining || !currentQueue) {
|
79 |
+
return
|
80 |
+
}
|
81 |
+
draining = false
|
82 |
+
if (currentQueue.length) {
|
83 |
+
queue = currentQueue.concat(queue)
|
84 |
+
} else {
|
85 |
+
queueIndex = -1
|
86 |
+
}
|
87 |
+
if (queue.length) {
|
88 |
+
drainQueue()
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
function drainQueue() {
|
93 |
+
if (draining) {
|
94 |
+
return
|
95 |
+
}
|
96 |
+
var timeout = runTimeout(cleanUpNextTick)
|
97 |
+
draining = true
|
98 |
+
|
99 |
+
var len = queue.length
|
100 |
+
while (len) {
|
101 |
+
currentQueue = queue
|
102 |
+
queue = []
|
103 |
+
while (++queueIndex < len) {
|
104 |
+
if (currentQueue) {
|
105 |
+
currentQueue[queueIndex].run()
|
106 |
+
}
|
107 |
+
}
|
108 |
+
queueIndex = -1
|
109 |
+
len = queue.length
|
110 |
+
}
|
111 |
+
currentQueue = null
|
112 |
+
draining = false
|
113 |
+
runClearTimeout(timeout)
|
114 |
+
}
|
115 |
+
function nextTick(fun) {
|
116 |
+
var args = new Array(arguments.length - 1)
|
117 |
+
if (arguments.length > 1) {
|
118 |
+
for (var i = 1; i < arguments.length; i++) {
|
119 |
+
args[i - 1] = arguments[i]
|
120 |
+
}
|
121 |
+
}
|
122 |
+
queue.push(new Item(fun, args))
|
123 |
+
if (queue.length === 1 && !draining) {
|
124 |
+
runTimeout(drainQueue)
|
125 |
+
}
|
126 |
+
}
|
127 |
+
// v8 likes predictible objects
|
128 |
+
function Item(fun, array) {
|
129 |
+
this.fun = fun
|
130 |
+
this.array = array
|
131 |
+
}
|
132 |
+
Item.prototype.run = function() {
|
133 |
+
this.fun.apply(null, this.array)
|
134 |
+
}
|
135 |
+
var title = 'browser'
|
136 |
+
var platform = 'browser'
|
137 |
+
var browser = true
|
138 |
+
var env = {}
|
139 |
+
var argv = []
|
140 |
+
var version = '' // empty string to avoid regexp issues
|
141 |
+
var versions = {}
|
142 |
+
var release = {}
|
143 |
+
var config = {}
|
144 |
+
|
145 |
+
function noop() {}
|
146 |
+
|
147 |
+
var on = noop
|
148 |
+
var addListener = noop
|
149 |
+
var once = noop
|
150 |
+
var off = noop
|
151 |
+
var removeListener = noop
|
152 |
+
var removeAllListeners = noop
|
153 |
+
var emit = noop
|
154 |
+
|
155 |
+
function binding(name) {
|
156 |
+
throw new Error('process.binding is not supported')
|
157 |
+
}
|
158 |
+
|
159 |
+
function cwd() {
|
160 |
+
return '/'
|
161 |
+
}
|
162 |
+
function chdir(dir) {
|
163 |
+
throw new Error('process.chdir is not supported')
|
164 |
+
}
|
165 |
+
function umask() {
|
166 |
+
return 0
|
167 |
+
}
|
168 |
+
|
169 |
+
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
170 |
+
var performance = global.performance || {}
|
171 |
+
var performanceNow =
|
172 |
+
performance.now ||
|
173 |
+
performance.mozNow ||
|
174 |
+
performance.msNow ||
|
175 |
+
performance.oNow ||
|
176 |
+
performance.webkitNow ||
|
177 |
+
function() {
|
178 |
+
return new Date().getTime()
|
179 |
+
}
|
180 |
+
|
181 |
+
// generate timestamp or delta
|
182 |
+
// see http://nodejs.org/api/process.html#process_process_hrtime
|
183 |
+
function hrtime(previousTimestamp) {
|
184 |
+
var clocktime = performanceNow.call(performance) * 1e-3
|
185 |
+
var seconds = Math.floor(clocktime)
|
186 |
+
var nanoseconds = Math.floor((clocktime % 1) * 1e9)
|
187 |
+
if (previousTimestamp) {
|
188 |
+
seconds = seconds - previousTimestamp[0]
|
189 |
+
nanoseconds = nanoseconds - previousTimestamp[1]
|
190 |
+
if (nanoseconds < 0) {
|
191 |
+
seconds--
|
192 |
+
nanoseconds += 1e9
|
193 |
+
}
|
194 |
+
}
|
195 |
+
return [seconds, nanoseconds]
|
196 |
+
}
|
197 |
+
|
198 |
+
var startTime = new Date()
|
199 |
+
function uptime() {
|
200 |
+
var currentTime = new Date()
|
201 |
+
var dif = currentTime - startTime
|
202 |
+
return dif / 1000
|
203 |
+
}
|
204 |
+
|
205 |
+
export var process = {
|
206 |
+
nextTick: nextTick,
|
207 |
+
title: title,
|
208 |
+
browser: browser,
|
209 |
+
env: env,
|
210 |
+
argv: argv,
|
211 |
+
version: version,
|
212 |
+
versions: versions,
|
213 |
+
on: on,
|
214 |
+
addListener: addListener,
|
215 |
+
once: once,
|
216 |
+
off: off,
|
217 |
+
removeListener: removeListener,
|
218 |
+
removeAllListeners: removeAllListeners,
|
219 |
+
emit: emit,
|
220 |
+
binding: binding,
|
221 |
+
cwd: cwd,
|
222 |
+
chdir: chdir,
|
223 |
+
umask: umask,
|
224 |
+
hrtime: hrtime,
|
225 |
+
platform: platform,
|
226 |
+
release: release,
|
227 |
+
config: config,
|
228 |
+
uptime: uptime,
|
229 |
+
}
|
230 |
+
|
231 |
+
// replace process.env.VAR with define
|
232 |
+
|
233 |
+
const defines = {}
|
234 |
+
Object.keys(defines).forEach((key) => {
|
235 |
+
const segs = key.split('.')
|
236 |
+
let target = process
|
237 |
+
for (let i = 0; i < segs.length; i++) {
|
238 |
+
const seg = segs[i]
|
239 |
+
if (i === segs.length - 1) {
|
240 |
+
target[seg] = defines[key]
|
241 |
+
} else {
|
242 |
+
target = target[seg] || (target[seg] = {})
|
243 |
+
}
|
244 |
+
}
|
245 |
+
})
|
workers1/auto3d/node_modules/@esbuild-plugins/node-globals-polyfill/src/index.test.ts
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { build } from 'esbuild'
|
2 |
+
import { writeFiles } from 'test-support'
|
3 |
+
import { NodeGlobalsPolyfillPlugin } from '.'
|
4 |
+
|
5 |
+
require('debug').enable(require('../package.json').name)
|
6 |
+
|
7 |
+
test('process works', async () => {
|
8 |
+
const {
|
9 |
+
unlink,
|
10 |
+
paths: [ENTRY],
|
11 |
+
} = await writeFiles({
|
12 |
+
'entry.ts': `process.version`,
|
13 |
+
})
|
14 |
+
const res = await build({
|
15 |
+
entryPoints: [ENTRY],
|
16 |
+
write: false,
|
17 |
+
format: 'esm',
|
18 |
+
target: 'es2017',
|
19 |
+
bundle: true,
|
20 |
+
inject: [require.resolve('../process')],
|
21 |
+
})
|
22 |
+
const output = res.outputFiles[0].text
|
23 |
+
// console.log(output)
|
24 |
+
eval(output)
|
25 |
+
unlink()
|
26 |
+
})
|
27 |
+
|
28 |
+
test('process is tree shaken', async () => {
|
29 |
+
const {
|
30 |
+
unlink,
|
31 |
+
paths: [ENTRY],
|
32 |
+
} = await writeFiles({
|
33 |
+
'entry.ts': `console.log('hei')`,
|
34 |
+
})
|
35 |
+
const res = await build({
|
36 |
+
entryPoints: [ENTRY],
|
37 |
+
write: false,
|
38 |
+
format: 'esm',
|
39 |
+
target: 'es2017',
|
40 |
+
bundle: true,
|
41 |
+
inject: [require.resolve('../process')],
|
42 |
+
})
|
43 |
+
const output = res.outputFiles[0].text
|
44 |
+
expect(output).not.toContain('process')
|
45 |
+
unlink()
|
46 |
+
})
|
47 |
+
|
48 |
+
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
49 |
+
test('process env vars are replaced with ones from define', async () => {
|
50 |
+
const {
|
51 |
+
unlink,
|
52 |
+
paths: [ENTRY],
|
53 |
+
} = await writeFiles({
|
54 |
+
'entry.ts': `if (process.env.VAR !== 'hello') { throw new Error('process.env.VAR not right: ' + process.env.VAR) }`,
|
55 |
+
})
|
56 |
+
const res = await build({
|
57 |
+
entryPoints: [ENTRY],
|
58 |
+
write: false,
|
59 |
+
format: 'esm',
|
60 |
+
target: 'es2017',
|
61 |
+
bundle: true,
|
62 |
+
define: {
|
63 |
+
'process.env.VAR': '"hello"',
|
64 |
+
},
|
65 |
+
plugins: [NodeGlobalsPolyfillPlugin({})],
|
66 |
+
})
|
67 |
+
const output = res.outputFiles[0].text
|
68 |
+
eval(output)
|
69 |
+
unlink()
|
70 |
+
})
|
71 |
+
|
72 |
+
test('Buffer works', async () => {
|
73 |
+
const {
|
74 |
+
unlink,
|
75 |
+
paths: [ENTRY],
|
76 |
+
} = await writeFiles({
|
77 |
+
'entry.ts': `console.log(Buffer.from('xxx').toString())`,
|
78 |
+
})
|
79 |
+
const res = await build({
|
80 |
+
entryPoints: [ENTRY],
|
81 |
+
write: false,
|
82 |
+
format: 'esm',
|
83 |
+
target: 'es2017',
|
84 |
+
bundle: true,
|
85 |
+
inject: [require.resolve('../Buffer')],
|
86 |
+
})
|
87 |
+
const output = res.outputFiles[0].text
|
88 |
+
// console.log(output)
|
89 |
+
eval(output)
|
90 |
+
unlink()
|
91 |
+
})
|
92 |
+
|
93 |
+
test('Buffer is tree shaken', async () => {
|
94 |
+
const {
|
95 |
+
unlink,
|
96 |
+
paths: [ENTRY],
|
97 |
+
} = await writeFiles({
|
98 |
+
'entry.ts': `console.log('hei')`,
|
99 |
+
})
|
100 |
+
const res = await build({
|
101 |
+
entryPoints: [ENTRY],
|
102 |
+
write: false,
|
103 |
+
format: 'esm',
|
104 |
+
target: 'es2017',
|
105 |
+
bundle: true,
|
106 |
+
inject: [require.resolve('../Buffer')],
|
107 |
+
})
|
108 |
+
const output = res.outputFiles[0].text
|
109 |
+
expect(output).not.toContain('Buffer')
|
110 |
+
unlink()
|
111 |
+
})
|
112 |
+
|
113 |
+
test('Buffer works using plugin', async () => {
|
114 |
+
const {
|
115 |
+
unlink,
|
116 |
+
paths: [ENTRY],
|
117 |
+
} = await writeFiles({
|
118 |
+
'entry.ts': `
|
119 |
+
let buf = new Buffer(256);
|
120 |
+
let len = buf.write("Simply Easy Learning");
|
121 |
+
console.log("Octets written : "+ len);`,
|
122 |
+
})
|
123 |
+
const res = await build({
|
124 |
+
entryPoints: [ENTRY],
|
125 |
+
write: false,
|
126 |
+
format: 'esm',
|
127 |
+
target: 'es2017',
|
128 |
+
bundle: true,
|
129 |
+
plugins: [NodeGlobalsPolyfillPlugin({ buffer: true })],
|
130 |
+
})
|
131 |
+
const output = res.outputFiles[0].text
|
132 |
+
// console.log(output)
|
133 |
+
eval(output)
|
134 |
+
unlink()
|
135 |
+
})
|
136 |
+
test('process works using plugin', async () => {
|
137 |
+
const {
|
138 |
+
unlink,
|
139 |
+
paths: [ENTRY],
|
140 |
+
} = await writeFiles({
|
141 |
+
'entry.ts': `console.log(process.cwd())`,
|
142 |
+
})
|
143 |
+
const res = await build({
|
144 |
+
entryPoints: [ENTRY],
|
145 |
+
write: false,
|
146 |
+
format: 'esm',
|
147 |
+
target: 'es2017',
|
148 |
+
bundle: true,
|
149 |
+
plugins: [NodeGlobalsPolyfillPlugin({ process: true })],
|
150 |
+
})
|
151 |
+
const output = res.outputFiles[0].text
|
152 |
+
// console.log(output)
|
153 |
+
eval(output)
|
154 |
+
unlink()
|
155 |
+
})
|
workers1/auto3d/node_modules/@esbuild-plugins/node-globals-polyfill/src/index.ts
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import path from 'path'
|
2 |
+
import fs from 'fs'
|
3 |
+
import * as esbuild from 'esbuild'
|
4 |
+
|
5 |
+
export function NodeGlobalsPolyfillPlugin({
|
6 |
+
buffer = false,
|
7 |
+
// define = {},
|
8 |
+
process = true,
|
9 |
+
} = {}): esbuild.Plugin {
|
10 |
+
return {
|
11 |
+
name: 'node-globals-polyfill',
|
12 |
+
setup({ initialOptions, onResolve, onLoad }) {
|
13 |
+
onResolve({ filter: /_node-buffer-polyfill_\.js/ }, (arg) => {
|
14 |
+
return {
|
15 |
+
path: path.resolve(__dirname, '../Buffer.js'),
|
16 |
+
}
|
17 |
+
})
|
18 |
+
onResolve({ filter: /_node-process-polyfill_\.js/ }, (arg) => {
|
19 |
+
return {
|
20 |
+
path: path.resolve(__dirname, '../process.js'),
|
21 |
+
}
|
22 |
+
})
|
23 |
+
|
24 |
+
// TODO esbuild cannot use virtual modules for inject: https://github.com/evanw/esbuild/issues/2762
|
25 |
+
// onLoad({ filter: /_virtual-process-polyfill_\.js/ }, (arg) => {
|
26 |
+
// const data = fs
|
27 |
+
// .readFileSync(path.resolve(__dirname, '../process.js'))
|
28 |
+
// .toString()
|
29 |
+
|
30 |
+
// const keys = Object.keys(define)
|
31 |
+
// return {
|
32 |
+
// loader: 'js',
|
33 |
+
// contents: data.replace(
|
34 |
+
// `const defines = {}`,
|
35 |
+
// 'const defines = {\n' +
|
36 |
+
// keys
|
37 |
+
// .filter((x) => x.startsWith('process.'))
|
38 |
+
// .sort((a, b) => a.length - b.length)
|
39 |
+
// .map(
|
40 |
+
// (k) =>
|
41 |
+
// ` ${JSON.stringify(k).replace(
|
42 |
+
// 'process.',
|
43 |
+
// '',
|
44 |
+
// )}: ${define[k]},`,
|
45 |
+
// )
|
46 |
+
// .join('\n') +
|
47 |
+
// '\n}',
|
48 |
+
// ),
|
49 |
+
// }
|
50 |
+
// })
|
51 |
+
onResolve({ filter: /_virtual-process-polyfill_\.js/ }, () => {
|
52 |
+
return {
|
53 |
+
path: path.resolve(__dirname, '../process.js'),
|
54 |
+
}
|
55 |
+
})
|
56 |
+
onResolve({ filter: /_virtual-buffer-polyfill_\.js/ }, () => {
|
57 |
+
return {
|
58 |
+
path: path.resolve(__dirname, '../_buffer.js'),
|
59 |
+
}
|
60 |
+
})
|
61 |
+
|
62 |
+
const polyfills: string[] = []
|
63 |
+
if (process) {
|
64 |
+
polyfills.push(
|
65 |
+
path.resolve(__dirname, '../_virtual-process-polyfill_.js'),
|
66 |
+
)
|
67 |
+
}
|
68 |
+
if (buffer) {
|
69 |
+
polyfills.push(
|
70 |
+
path.resolve(__dirname, '../_virtual-buffer-polyfill_.js'),
|
71 |
+
)
|
72 |
+
}
|
73 |
+
if (initialOptions.inject) {
|
74 |
+
initialOptions.inject.push(...polyfills)
|
75 |
+
// handle duplicate plugin
|
76 |
+
initialOptions.inject = [...new Set(initialOptions.inject)]
|
77 |
+
} else {
|
78 |
+
initialOptions.inject = [...polyfills]
|
79 |
+
}
|
80 |
+
},
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
export default NodeGlobalsPolyfillPlugin
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Plugin } from 'esbuild';
|
2 |
+
export interface NodePolyfillsOptions {
|
3 |
+
name?: string;
|
4 |
+
namespace?: string;
|
5 |
+
}
|
6 |
+
export declare function NodeModulesPolyfillPlugin(options?: NodePolyfillsOptions): Plugin;
|
7 |
+
export default NodeModulesPolyfillPlugin;
|
8 |
+
//# sourceMappingURL=index.d.ts.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;AAkB/C,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,yBAAyB,CACrC,OAAO,GAAE,oBAAyB,GACnC,MAAM,CAwFR;AAmBD,eAAe,yBAAyB,CAAA"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 |
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 |
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5 |
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 |
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 |
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 |
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 |
+
});
|
10 |
+
};
|
11 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13 |
+
};
|
14 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15 |
+
exports.NodeModulesPolyfillPlugin = void 0;
|
16 |
+
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
|
17 |
+
const fs_1 = __importDefault(require("fs"));
|
18 |
+
const path_1 = __importDefault(require("path"));
|
19 |
+
const polyfills_1 = require("./polyfills");
|
20 |
+
// import { NodeResolvePlugin } from '@esbuild-plugins/node-resolve'
|
21 |
+
const NAME = 'node-modules-polyfills';
|
22 |
+
const NAMESPACE = NAME;
|
23 |
+
function removeEndingSlash(importee) {
|
24 |
+
if (importee && importee.slice(-1) === '/') {
|
25 |
+
importee = importee.slice(0, -1);
|
26 |
+
}
|
27 |
+
return importee;
|
28 |
+
}
|
29 |
+
function NodeModulesPolyfillPlugin(options = {}) {
|
30 |
+
const { namespace = NAMESPACE, name = NAME } = options;
|
31 |
+
if (namespace.endsWith('commonjs')) {
|
32 |
+
throw new Error(`namespace ${namespace} must not end with commonjs`);
|
33 |
+
}
|
34 |
+
// this namespace is needed to make ES modules expose their default export to require: require('assert') will give you import('assert').default
|
35 |
+
const commonjsNamespace = namespace + '-commonjs';
|
36 |
+
const polyfilledBuiltins = polyfills_1.builtinsPolyfills();
|
37 |
+
const polyfilledBuiltinsNames = [...polyfilledBuiltins.keys()];
|
38 |
+
return {
|
39 |
+
name,
|
40 |
+
setup: function setup({ onLoad, onResolve, initialOptions }) {
|
41 |
+
var _a;
|
42 |
+
// polyfills contain global keyword, it must be defined
|
43 |
+
if ((initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define) && !((_a = initialOptions.define) === null || _a === void 0 ? void 0 : _a.global)) {
|
44 |
+
initialOptions.define['global'] = 'globalThis';
|
45 |
+
}
|
46 |
+
else if (!(initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define)) {
|
47 |
+
initialOptions.define = { global: 'globalThis' };
|
48 |
+
}
|
49 |
+
// TODO these polyfill module cannot import anything, is that ok?
|
50 |
+
function loader(args) {
|
51 |
+
return __awaiter(this, void 0, void 0, function* () {
|
52 |
+
try {
|
53 |
+
const argsPath = args.path.replace(/^node:/, '');
|
54 |
+
const isCommonjs = args.namespace.endsWith('commonjs');
|
55 |
+
const resolved = polyfilledBuiltins.get(removeEndingSlash(argsPath));
|
56 |
+
const contents = yield (yield fs_1.default.promises.readFile(resolved)).toString();
|
57 |
+
let resolveDir = path_1.default.dirname(resolved);
|
58 |
+
if (isCommonjs) {
|
59 |
+
return {
|
60 |
+
loader: 'js',
|
61 |
+
contents: commonJsTemplate({
|
62 |
+
importPath: argsPath,
|
63 |
+
}),
|
64 |
+
resolveDir,
|
65 |
+
};
|
66 |
+
}
|
67 |
+
return {
|
68 |
+
loader: 'js',
|
69 |
+
contents,
|
70 |
+
resolveDir,
|
71 |
+
};
|
72 |
+
}
|
73 |
+
catch (e) {
|
74 |
+
console.error('node-modules-polyfill', e);
|
75 |
+
return {
|
76 |
+
contents: `export {}`,
|
77 |
+
loader: 'js',
|
78 |
+
};
|
79 |
+
}
|
80 |
+
});
|
81 |
+
}
|
82 |
+
onLoad({ filter: /.*/, namespace }, loader);
|
83 |
+
onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);
|
84 |
+
const filter = new RegExp([
|
85 |
+
...polyfilledBuiltinsNames,
|
86 |
+
...polyfilledBuiltinsNames.map((n) => `node:${n}`),
|
87 |
+
]
|
88 |
+
.map(escape_string_regexp_1.default)
|
89 |
+
.join('|'));
|
90 |
+
function resolver(args) {
|
91 |
+
return __awaiter(this, void 0, void 0, function* () {
|
92 |
+
const argsPath = args.path.replace(/^node:/, '');
|
93 |
+
const ignoreRequire = args.namespace === commonjsNamespace;
|
94 |
+
if (!polyfilledBuiltins.has(argsPath)) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
const isCommonjs = !ignoreRequire && args.kind === 'require-call';
|
98 |
+
return {
|
99 |
+
namespace: isCommonjs ? commonjsNamespace : namespace,
|
100 |
+
path: argsPath,
|
101 |
+
};
|
102 |
+
});
|
103 |
+
}
|
104 |
+
onResolve({ filter }, resolver);
|
105 |
+
// onResolve({ filter: /.*/, namespace }, resolver)
|
106 |
+
},
|
107 |
+
};
|
108 |
+
}
|
109 |
+
exports.NodeModulesPolyfillPlugin = NodeModulesPolyfillPlugin;
|
110 |
+
function commonJsTemplate({ importPath }) {
|
111 |
+
return `
|
112 |
+
const polyfill = require('${importPath}')
|
113 |
+
|
114 |
+
if (polyfill && polyfill.default) {
|
115 |
+
module.exports = polyfill.default
|
116 |
+
for (let k in polyfill) {
|
117 |
+
module.exports[k] = polyfill[k]
|
118 |
+
}
|
119 |
+
} else if (polyfill) {
|
120 |
+
module.exports = polyfill
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
`;
|
125 |
+
}
|
126 |
+
exports.default = NodeModulesPolyfillPlugin;
|
127 |
+
//# sourceMappingURL=index.js.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.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,EAAE,MAAM,CAAC,CAAA;YAC9D,MAAM,MAAM,GAAG,IAAI,MAAM,CACrB;gBACI,GAAG,uBAAuB;gBAC1B,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;aACrD;iBACI,GAAG,CAAC,8BAAkB,CAAC;iBACvB,IAAI,CAAC,GAAG,CAAC,CACjB,CAAA;YACD,SAAe,QAAQ,CAAC,IAAmB;;oBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;oBAChD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,KAAK,iBAAiB,CAAA;oBAE1D,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;wBACnC,OAAM;qBACT;oBAED,MAAM,UAAU,GACZ,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;oBAElD,OAAO;wBACH,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;wBACrD,IAAI,EAAE,QAAQ;qBACjB,CAAA;gBACL,CAAC;aAAA;YACD,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;YAC/B,mDAAmD;QACvD,CAAC;KACJ,CAAA;AACL,CAAC;AA1FD,8DA0FC;AAED,SAAS,gBAAgB,CAAC,EAAE,UAAU,EAAE;IACpC,OAAO;4BACiB,UAAU;;;;;;;;;;;;CAYrC,CAAA;AACD,CAAC;AAED,kBAAe,yBAAyB,CAAA"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export {};
|
2 |
+
//# sourceMappingURL=index.test.d.ts.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 |
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 |
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5 |
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 |
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 |
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 |
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 |
+
});
|
10 |
+
};
|
11 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13 |
+
};
|
14 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15 |
+
const esbuild_1 = require("esbuild");
|
16 |
+
const test_support_1 = require("test-support");
|
17 |
+
const fs_1 = __importDefault(require("fs"));
|
18 |
+
const _1 = __importDefault(require("."));
|
19 |
+
const node_globals_polyfill_1 = __importDefault(require("@esbuild-plugins/node-globals-polyfill"));
|
20 |
+
require('debug').enable(require('../package.json').name);
|
21 |
+
test('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
22 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
23 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
24 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
25 |
+
});
|
26 |
+
// const outfile = randomOutputFile()
|
27 |
+
const res = yield esbuild_1.build({
|
28 |
+
entryPoints: [ENTRY],
|
29 |
+
write: false,
|
30 |
+
format: 'esm',
|
31 |
+
target: 'es2017',
|
32 |
+
bundle: true,
|
33 |
+
plugins: [_1.default()],
|
34 |
+
});
|
35 |
+
eval(res.outputFiles[0].text);
|
36 |
+
// console.log(res.outputFiles[0].text)
|
37 |
+
unlink();
|
38 |
+
}));
|
39 |
+
test('works with SafeBuffer and other package consumers', () => __awaiter(void 0, void 0, void 0, function* () {
|
40 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
41 |
+
'entry.ts': `import {Buffer as SafeBuffer} from './safe-buffer'; console.log(SafeBuffer);`,
|
42 |
+
'safe-buffer.ts': fs_1.default
|
43 |
+
.readFileSync(require.resolve('safe-buffer'))
|
44 |
+
.toString(),
|
45 |
+
});
|
46 |
+
// const outfile = randomOutputFile()
|
47 |
+
const res = yield esbuild_1.build({
|
48 |
+
entryPoints: [ENTRY],
|
49 |
+
write: false,
|
50 |
+
format: 'esm',
|
51 |
+
target: 'es2017',
|
52 |
+
bundle: true,
|
53 |
+
plugins: [_1.default()],
|
54 |
+
});
|
55 |
+
// console.log(
|
56 |
+
// res.outputFiles[0].text
|
57 |
+
// .split('\n')
|
58 |
+
// .map((x, i) => i + ' ' + x)
|
59 |
+
// .join('\n'),
|
60 |
+
// )
|
61 |
+
eval(res.outputFiles[0].text);
|
62 |
+
unlink();
|
63 |
+
}));
|
64 |
+
test('events works', () => __awaiter(void 0, void 0, void 0, function* () {
|
65 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
66 |
+
'entry.ts': `
|
67 |
+
import EventEmitter from 'events';
|
68 |
+
|
69 |
+
class Test extends EventEmitter {
|
70 |
+
constructor() { };
|
71 |
+
}
|
72 |
+
console.log(Test)
|
73 |
+
`,
|
74 |
+
});
|
75 |
+
// const outfile = randomOutputFile()
|
76 |
+
const res = yield esbuild_1.build({
|
77 |
+
entryPoints: [ENTRY],
|
78 |
+
write: false,
|
79 |
+
format: 'esm',
|
80 |
+
target: 'es2017',
|
81 |
+
bundle: true,
|
82 |
+
plugins: [_1.default()],
|
83 |
+
});
|
84 |
+
// console.log(res.outputFiles[0].text)
|
85 |
+
eval(res.outputFiles[0].text);
|
86 |
+
unlink();
|
87 |
+
}));
|
88 |
+
test('require can use default export', () => __awaiter(void 0, void 0, void 0, function* () {
|
89 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
90 |
+
'entry.ts': `
|
91 |
+
const assert = require('assert')
|
92 |
+
// console.log(assert)
|
93 |
+
assert('ok')
|
94 |
+
`,
|
95 |
+
});
|
96 |
+
// const outfile = randomOutputFile()
|
97 |
+
const res = yield esbuild_1.build({
|
98 |
+
entryPoints: [ENTRY],
|
99 |
+
write: false,
|
100 |
+
format: 'esm',
|
101 |
+
target: 'es2017',
|
102 |
+
bundle: true,
|
103 |
+
plugins: [_1.default()],
|
104 |
+
});
|
105 |
+
// console.log(res.outputFiles[0].text)
|
106 |
+
eval(res.outputFiles[0].text);
|
107 |
+
unlink();
|
108 |
+
}));
|
109 |
+
test.skip('crypto', () => __awaiter(void 0, void 0, void 0, function* () {
|
110 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
111 |
+
'entry.ts': `import { randomBytes } from 'crypto'; console.log(randomBytes(20).toString('hex'))`,
|
112 |
+
});
|
113 |
+
// const outfile = randomOutputFile()
|
114 |
+
const res = yield esbuild_1.build({
|
115 |
+
entryPoints: [ENTRY],
|
116 |
+
write: false,
|
117 |
+
format: 'esm',
|
118 |
+
target: 'es2017',
|
119 |
+
bundle: true,
|
120 |
+
plugins: [_1.default()],
|
121 |
+
});
|
122 |
+
eval(res.outputFiles[0].text);
|
123 |
+
// console.log(res.outputFiles[0].text)
|
124 |
+
unlink();
|
125 |
+
}));
|
126 |
+
test.skip('fs', () => __awaiter(void 0, void 0, void 0, function* () {
|
127 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
128 |
+
'entry.ts': `import { readFile } from 'fs'; console.log(readFile(''))`,
|
129 |
+
});
|
130 |
+
// const outfile = randomOutputFile()
|
131 |
+
const res = yield esbuild_1.build({
|
132 |
+
entryPoints: [ENTRY],
|
133 |
+
write: false,
|
134 |
+
format: 'esm',
|
135 |
+
target: 'es2017',
|
136 |
+
bundle: true,
|
137 |
+
plugins: [_1.default()],
|
138 |
+
});
|
139 |
+
eval(res.outputFiles[0].text);
|
140 |
+
// console.log(res.outputFiles[0].text)
|
141 |
+
unlink();
|
142 |
+
}));
|
143 |
+
test('does not include global keyword', () => __awaiter(void 0, void 0, void 0, function* () {
|
144 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
145 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
146 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
147 |
+
});
|
148 |
+
// const outfile = randomOutputFile()
|
149 |
+
const res = yield esbuild_1.build({
|
150 |
+
entryPoints: [ENTRY],
|
151 |
+
write: false,
|
152 |
+
format: 'esm',
|
153 |
+
target: 'es2017',
|
154 |
+
bundle: true,
|
155 |
+
plugins: [_1.default()],
|
156 |
+
});
|
157 |
+
const text = res.outputFiles[0].text;
|
158 |
+
eval(text);
|
159 |
+
expect(text).not.toContain(/\bglobal\b/);
|
160 |
+
// console.log(res.outputFiles[0].text)
|
161 |
+
unlink();
|
162 |
+
}));
|
163 |
+
test('works with globals polyfills', () => __awaiter(void 0, void 0, void 0, function* () {
|
164 |
+
const { unlink, paths: [ENTRY], } = yield test_support_1.writeFiles({
|
165 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
166 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
167 |
+
});
|
168 |
+
// const outfile = randomOutputFile()
|
169 |
+
const res = yield esbuild_1.build({
|
170 |
+
entryPoints: [ENTRY],
|
171 |
+
write: false,
|
172 |
+
format: 'esm',
|
173 |
+
target: 'es2017',
|
174 |
+
bundle: true,
|
175 |
+
plugins: [_1.default(), node_globals_polyfill_1.default()],
|
176 |
+
});
|
177 |
+
const text = res.outputFiles[0].text;
|
178 |
+
eval(text);
|
179 |
+
console.log(text);
|
180 |
+
// console.log(res.outputFiles[0].text)
|
181 |
+
unlink();
|
182 |
+
}));
|
183 |
+
//# sourceMappingURL=index.test.js.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/index.test.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
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AAK,CAAC;QACpB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,CAAC,UAA0B,EAAE,EAAE,+BAA0B,EAAE,CAAC;KACxE,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACpC,IAAI,CAAC,IAAI,CAAC,CAAA;IACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACjB,uCAAuC;IACvC,MAAM,EAAE,CAAA;AACZ,CAAC,CAAA,CAAC,CAAA"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export declare function builtinsPolyfills(): Map<any, any>;
|
2 |
+
//# sourceMappingURL=polyfills.d.ts.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAQA,wBAAgB,iBAAiB,kBA8IhC"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
// Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
|
3 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4 |
+
exports.builtinsPolyfills = void 0;
|
5 |
+
const EMPTY_PATH = require.resolve('rollup-plugin-node-polyfills/polyfills/empty.js');
|
6 |
+
function builtinsPolyfills() {
|
7 |
+
const libs = new Map();
|
8 |
+
libs.set('process', require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'));
|
9 |
+
libs.set('buffer', require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'));
|
10 |
+
libs.set('util', require.resolve('rollup-plugin-node-polyfills/polyfills/util'));
|
11 |
+
libs.set('sys', libs.get('util'));
|
12 |
+
libs.set('events', require.resolve('rollup-plugin-node-polyfills/polyfills/events'));
|
13 |
+
libs.set('stream', require.resolve('rollup-plugin-node-polyfills/polyfills/stream'));
|
14 |
+
libs.set('path', require.resolve('rollup-plugin-node-polyfills/polyfills/path'));
|
15 |
+
libs.set('querystring', require.resolve('rollup-plugin-node-polyfills/polyfills/qs'));
|
16 |
+
libs.set('punycode', require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'));
|
17 |
+
libs.set('url', require.resolve('rollup-plugin-node-polyfills/polyfills/url'));
|
18 |
+
libs.set('string_decoder', require.resolve('rollup-plugin-node-polyfills/polyfills/string-decoder'));
|
19 |
+
libs.set('http', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
|
20 |
+
libs.set('https', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
|
21 |
+
libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'));
|
22 |
+
libs.set('assert', require.resolve('rollup-plugin-node-polyfills/polyfills/assert'));
|
23 |
+
libs.set('constants', require.resolve('rollup-plugin-node-polyfills/polyfills/constants'));
|
24 |
+
libs.set('_stream_duplex', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/duplex'));
|
25 |
+
libs.set('_stream_passthrough', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough'));
|
26 |
+
libs.set('_stream_readable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/readable'));
|
27 |
+
libs.set('_stream_writable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/writable'));
|
28 |
+
libs.set('_stream_transform', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/transform'));
|
29 |
+
libs.set('timers', require.resolve('rollup-plugin-node-polyfills/polyfills/timers'));
|
30 |
+
libs.set('console', require.resolve('rollup-plugin-node-polyfills/polyfills/console'));
|
31 |
+
libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'));
|
32 |
+
libs.set('zlib', require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'));
|
33 |
+
libs.set('tty', require.resolve('rollup-plugin-node-polyfills/polyfills/tty'));
|
34 |
+
libs.set('domain', require.resolve('rollup-plugin-node-polyfills/polyfills/domain'));
|
35 |
+
// not shimmed
|
36 |
+
libs.set('dns', EMPTY_PATH);
|
37 |
+
libs.set('dgram', EMPTY_PATH);
|
38 |
+
libs.set('child_process', EMPTY_PATH);
|
39 |
+
libs.set('cluster', EMPTY_PATH);
|
40 |
+
libs.set('module', EMPTY_PATH);
|
41 |
+
libs.set('net', EMPTY_PATH);
|
42 |
+
libs.set('readline', EMPTY_PATH);
|
43 |
+
libs.set('repl', EMPTY_PATH);
|
44 |
+
libs.set('tls', EMPTY_PATH);
|
45 |
+
libs.set('fs', EMPTY_PATH);
|
46 |
+
libs.set('crypto', EMPTY_PATH);
|
47 |
+
// libs.set(
|
48 |
+
// 'fs',
|
49 |
+
// require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
|
50 |
+
// )
|
51 |
+
// TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
|
52 |
+
// libs.set(
|
53 |
+
// 'crypto',
|
54 |
+
// require.resolve(
|
55 |
+
// 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
|
56 |
+
// ),
|
57 |
+
// )
|
58 |
+
return libs;
|
59 |
+
}
|
60 |
+
exports.builtinsPolyfills = builtinsPolyfills;
|
61 |
+
//# sourceMappingURL=polyfills.js.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/dist/polyfills.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":";AAAA,mGAAmG;;;AAInG,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAC9B,iDAAiD,CACpD,CAAA;AAED,SAAgB,iBAAiB;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IAEtB,IAAI,CAAC,GAAG,CACJ,SAAS,EACT,OAAO,CAAC,OAAO,CAAC,oDAAoD,CAAC,CACxE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,mDAAmD,CAAC,CACvE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CACjE,CAAA;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,+CAA+C,CAAC,CACnE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,+CAA+C,CAAC,CACnE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CACjE,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,aAAa,EACb,OAAO,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAC/D,CAAA;IACD,IAAI,CAAC,GAAG,CACJ,UAAU,EACV,OAAO,CAAC,OAAO,CAAC,iDAAiD,CAAC,CACrE,CAAA;IACD,IAA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T,IAAI;IAEJ,OAAO,IAAI,CAAA;AACf,CAAC;AA9ID,8CA8IC"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Plugin } from 'esbuild';
|
2 |
+
export interface NodePolyfillsOptions {
|
3 |
+
name?: string;
|
4 |
+
namespace?: string;
|
5 |
+
}
|
6 |
+
export declare function NodeModulesPolyfillPlugin(options?: NodePolyfillsOptions): Plugin;
|
7 |
+
export default NodeModulesPolyfillPlugin;
|
8 |
+
//# sourceMappingURL=index.d.ts.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;AAkB/C,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,yBAAyB,CACrC,OAAO,GAAE,oBAAyB,GACnC,MAAM,CAwFR;AAmBD,eAAe,yBAAyB,CAAA"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2 |
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3 |
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4 |
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 |
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 |
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7 |
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 |
+
});
|
9 |
+
};
|
10 |
+
import escapeStringRegexp from 'escape-string-regexp';
|
11 |
+
import fs from 'fs';
|
12 |
+
import path from 'path';
|
13 |
+
import { builtinsPolyfills } from './polyfills';
|
14 |
+
// import { NodeResolvePlugin } from '@esbuild-plugins/node-resolve'
|
15 |
+
const NAME = 'node-modules-polyfills';
|
16 |
+
const NAMESPACE = NAME;
|
17 |
+
function removeEndingSlash(importee) {
|
18 |
+
if (importee && importee.slice(-1) === '/') {
|
19 |
+
importee = importee.slice(0, -1);
|
20 |
+
}
|
21 |
+
return importee;
|
22 |
+
}
|
23 |
+
export function NodeModulesPolyfillPlugin(options = {}) {
|
24 |
+
const { namespace = NAMESPACE, name = NAME } = options;
|
25 |
+
if (namespace.endsWith('commonjs')) {
|
26 |
+
throw new Error(`namespace ${namespace} must not end with commonjs`);
|
27 |
+
}
|
28 |
+
// this namespace is needed to make ES modules expose their default export to require: require('assert') will give you import('assert').default
|
29 |
+
const commonjsNamespace = namespace + '-commonjs';
|
30 |
+
const polyfilledBuiltins = builtinsPolyfills();
|
31 |
+
const polyfilledBuiltinsNames = [...polyfilledBuiltins.keys()];
|
32 |
+
return {
|
33 |
+
name,
|
34 |
+
setup: function setup({ onLoad, onResolve, initialOptions }) {
|
35 |
+
var _a;
|
36 |
+
// polyfills contain global keyword, it must be defined
|
37 |
+
if ((initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define) && !((_a = initialOptions.define) === null || _a === void 0 ? void 0 : _a.global)) {
|
38 |
+
initialOptions.define['global'] = 'globalThis';
|
39 |
+
}
|
40 |
+
else if (!(initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.define)) {
|
41 |
+
initialOptions.define = { global: 'globalThis' };
|
42 |
+
}
|
43 |
+
// TODO these polyfill module cannot import anything, is that ok?
|
44 |
+
function loader(args) {
|
45 |
+
return __awaiter(this, void 0, void 0, function* () {
|
46 |
+
try {
|
47 |
+
const argsPath = args.path.replace(/^node:/, '');
|
48 |
+
const isCommonjs = args.namespace.endsWith('commonjs');
|
49 |
+
const resolved = polyfilledBuiltins.get(removeEndingSlash(argsPath));
|
50 |
+
const contents = yield (yield fs.promises.readFile(resolved)).toString();
|
51 |
+
let resolveDir = path.dirname(resolved);
|
52 |
+
if (isCommonjs) {
|
53 |
+
return {
|
54 |
+
loader: 'js',
|
55 |
+
contents: commonJsTemplate({
|
56 |
+
importPath: argsPath,
|
57 |
+
}),
|
58 |
+
resolveDir,
|
59 |
+
};
|
60 |
+
}
|
61 |
+
return {
|
62 |
+
loader: 'js',
|
63 |
+
contents,
|
64 |
+
resolveDir,
|
65 |
+
};
|
66 |
+
}
|
67 |
+
catch (e) {
|
68 |
+
console.error('node-modules-polyfill', e);
|
69 |
+
return {
|
70 |
+
contents: `export {}`,
|
71 |
+
loader: 'js',
|
72 |
+
};
|
73 |
+
}
|
74 |
+
});
|
75 |
+
}
|
76 |
+
onLoad({ filter: /.*/, namespace }, loader);
|
77 |
+
onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);
|
78 |
+
const filter = new RegExp([
|
79 |
+
...polyfilledBuiltinsNames,
|
80 |
+
...polyfilledBuiltinsNames.map((n) => `node:${n}`),
|
81 |
+
]
|
82 |
+
.map(escapeStringRegexp)
|
83 |
+
.join('|'));
|
84 |
+
function resolver(args) {
|
85 |
+
return __awaiter(this, void 0, void 0, function* () {
|
86 |
+
const argsPath = args.path.replace(/^node:/, '');
|
87 |
+
const ignoreRequire = args.namespace === commonjsNamespace;
|
88 |
+
if (!polyfilledBuiltins.has(argsPath)) {
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
const isCommonjs = !ignoreRequire && args.kind === 'require-call';
|
92 |
+
return {
|
93 |
+
namespace: isCommonjs ? commonjsNamespace : namespace,
|
94 |
+
path: argsPath,
|
95 |
+
};
|
96 |
+
});
|
97 |
+
}
|
98 |
+
onResolve({ filter }, resolver);
|
99 |
+
// onResolve({ filter: /.*/, namespace }, resolver)
|
100 |
+
},
|
101 |
+
};
|
102 |
+
}
|
103 |
+
function commonJsTemplate({ importPath }) {
|
104 |
+
return `
|
105 |
+
const polyfill = require('${importPath}')
|
106 |
+
|
107 |
+
if (polyfill && polyfill.default) {
|
108 |
+
module.exports = polyfill.default
|
109 |
+
for (let k in polyfill) {
|
110 |
+
module.exports[k] = polyfill[k]
|
111 |
+
}
|
112 |
+
} else if (polyfill) {
|
113 |
+
module.exports = polyfill
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
`;
|
118 |
+
}
|
119 |
+
export default NodeModulesPolyfillPlugin;
|
120 |
+
//# sourceMappingURL=index.js.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,kBAAkB,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,MAAM,IAAI,CAAA;AAC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AC9D,MAAM,MAAM,GAAG,IAAI,MAAM,CACrB;gBACI,GAAG,uBAAuB;gBAC1B,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;aACrD;iBACI,GAAG,CAAC,kBAAkB,CAAC;iBACvB,IAAI,CAAC,GAAG,CAAC,CACjB,CAAA;YACD,SAAe,QAAQ,CAAC,IAAmB;;oBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;oBAChD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,KAAK,iBAAiB,CAAA;oBAE1D,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;wBACnC,OAAM;qBACT;oBAED,MAAM,UAAU,GACZ,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;oBAElD,OAAO;wBACH,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;wBACrD,IAAI,EAAE,QAAQ;qBACjB,CAAA;gBACL,CAAC;aAAA;YACD,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;YAC/B,mDAAmD;QACvD,CAAC;KACJ,CAAA;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE,UAAU,EAAE;IACpC,OAAO;4BACiB,UAAU;;;;;;;;;;;;CAYrC,CAAA;AACD,CAAC;AAED,eAAe,yBAAyB,CAAA"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export {};
|
2 |
+
//# sourceMappingURL=index.test.d.ts.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2 |
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3 |
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4 |
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 |
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 |
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7 |
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 |
+
});
|
9 |
+
};
|
10 |
+
import { build } from 'esbuild';
|
11 |
+
import { writeFiles } from 'test-support';
|
12 |
+
import fs from 'fs';
|
13 |
+
import NodeModulesPolyfillsPlugin from '.';
|
14 |
+
import NodeGlobalsPolyfillsPlugin from '@esbuild-plugins/node-globals-polyfill';
|
15 |
+
require('debug').enable(require('../package.json').name);
|
16 |
+
test('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
17 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
18 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
19 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
20 |
+
});
|
21 |
+
// const outfile = randomOutputFile()
|
22 |
+
const res = yield build({
|
23 |
+
entryPoints: [ENTRY],
|
24 |
+
write: false,
|
25 |
+
format: 'esm',
|
26 |
+
target: 'es2017',
|
27 |
+
bundle: true,
|
28 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
29 |
+
});
|
30 |
+
eval(res.outputFiles[0].text);
|
31 |
+
// console.log(res.outputFiles[0].text)
|
32 |
+
unlink();
|
33 |
+
}));
|
34 |
+
test('works with SafeBuffer and other package consumers', () => __awaiter(void 0, void 0, void 0, function* () {
|
35 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
36 |
+
'entry.ts': `import {Buffer as SafeBuffer} from './safe-buffer'; console.log(SafeBuffer);`,
|
37 |
+
'safe-buffer.ts': fs
|
38 |
+
.readFileSync(require.resolve('safe-buffer'))
|
39 |
+
.toString(),
|
40 |
+
});
|
41 |
+
// const outfile = randomOutputFile()
|
42 |
+
const res = yield build({
|
43 |
+
entryPoints: [ENTRY],
|
44 |
+
write: false,
|
45 |
+
format: 'esm',
|
46 |
+
target: 'es2017',
|
47 |
+
bundle: true,
|
48 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
49 |
+
});
|
50 |
+
// console.log(
|
51 |
+
// res.outputFiles[0].text
|
52 |
+
// .split('\n')
|
53 |
+
// .map((x, i) => i + ' ' + x)
|
54 |
+
// .join('\n'),
|
55 |
+
// )
|
56 |
+
eval(res.outputFiles[0].text);
|
57 |
+
unlink();
|
58 |
+
}));
|
59 |
+
test('events works', () => __awaiter(void 0, void 0, void 0, function* () {
|
60 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
61 |
+
'entry.ts': `
|
62 |
+
import EventEmitter from 'events';
|
63 |
+
|
64 |
+
class Test extends EventEmitter {
|
65 |
+
constructor() { };
|
66 |
+
}
|
67 |
+
console.log(Test)
|
68 |
+
`,
|
69 |
+
});
|
70 |
+
// const outfile = randomOutputFile()
|
71 |
+
const res = yield build({
|
72 |
+
entryPoints: [ENTRY],
|
73 |
+
write: false,
|
74 |
+
format: 'esm',
|
75 |
+
target: 'es2017',
|
76 |
+
bundle: true,
|
77 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
78 |
+
});
|
79 |
+
// console.log(res.outputFiles[0].text)
|
80 |
+
eval(res.outputFiles[0].text);
|
81 |
+
unlink();
|
82 |
+
}));
|
83 |
+
test('require can use default export', () => __awaiter(void 0, void 0, void 0, function* () {
|
84 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
85 |
+
'entry.ts': `
|
86 |
+
const assert = require('assert')
|
87 |
+
// console.log(assert)
|
88 |
+
assert('ok')
|
89 |
+
`,
|
90 |
+
});
|
91 |
+
// const outfile = randomOutputFile()
|
92 |
+
const res = yield build({
|
93 |
+
entryPoints: [ENTRY],
|
94 |
+
write: false,
|
95 |
+
format: 'esm',
|
96 |
+
target: 'es2017',
|
97 |
+
bundle: true,
|
98 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
99 |
+
});
|
100 |
+
// console.log(res.outputFiles[0].text)
|
101 |
+
eval(res.outputFiles[0].text);
|
102 |
+
unlink();
|
103 |
+
}));
|
104 |
+
test.skip('crypto', () => __awaiter(void 0, void 0, void 0, function* () {
|
105 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
106 |
+
'entry.ts': `import { randomBytes } from 'crypto'; console.log(randomBytes(20).toString('hex'))`,
|
107 |
+
});
|
108 |
+
// const outfile = randomOutputFile()
|
109 |
+
const res = yield build({
|
110 |
+
entryPoints: [ENTRY],
|
111 |
+
write: false,
|
112 |
+
format: 'esm',
|
113 |
+
target: 'es2017',
|
114 |
+
bundle: true,
|
115 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
116 |
+
});
|
117 |
+
eval(res.outputFiles[0].text);
|
118 |
+
// console.log(res.outputFiles[0].text)
|
119 |
+
unlink();
|
120 |
+
}));
|
121 |
+
test.skip('fs', () => __awaiter(void 0, void 0, void 0, function* () {
|
122 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
123 |
+
'entry.ts': `import { readFile } from 'fs'; console.log(readFile(''))`,
|
124 |
+
});
|
125 |
+
// const outfile = randomOutputFile()
|
126 |
+
const res = yield build({
|
127 |
+
entryPoints: [ENTRY],
|
128 |
+
write: false,
|
129 |
+
format: 'esm',
|
130 |
+
target: 'es2017',
|
131 |
+
bundle: true,
|
132 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
133 |
+
});
|
134 |
+
eval(res.outputFiles[0].text);
|
135 |
+
// console.log(res.outputFiles[0].text)
|
136 |
+
unlink();
|
137 |
+
}));
|
138 |
+
test('does not include global keyword', () => __awaiter(void 0, void 0, void 0, function* () {
|
139 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
140 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
141 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
142 |
+
});
|
143 |
+
// const outfile = randomOutputFile()
|
144 |
+
const res = yield build({
|
145 |
+
entryPoints: [ENTRY],
|
146 |
+
write: false,
|
147 |
+
format: 'esm',
|
148 |
+
target: 'es2017',
|
149 |
+
bundle: true,
|
150 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
151 |
+
});
|
152 |
+
const text = res.outputFiles[0].text;
|
153 |
+
eval(text);
|
154 |
+
expect(text).not.toContain(/\bglobal\b/);
|
155 |
+
// console.log(res.outputFiles[0].text)
|
156 |
+
unlink();
|
157 |
+
}));
|
158 |
+
test('works with globals polyfills', () => __awaiter(void 0, void 0, void 0, function* () {
|
159 |
+
const { unlink, paths: [ENTRY], } = yield writeFiles({
|
160 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
161 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
162 |
+
});
|
163 |
+
// const outfile = randomOutputFile()
|
164 |
+
const res = yield build({
|
165 |
+
entryPoints: [ENTRY],
|
166 |
+
write: false,
|
167 |
+
format: 'esm',
|
168 |
+
target: 'es2017',
|
169 |
+
bundle: true,
|
170 |
+
plugins: [NodeModulesPolyfillsPlugin(), NodeGlobalsPolyfillsPlugin()],
|
171 |
+
});
|
172 |
+
const text = res.outputFiles[0].text;
|
173 |
+
eval(text);
|
174 |
+
console.log(text);
|
175 |
+
// console.log(res.outputFiles[0].text)
|
176 |
+
unlink();
|
177 |
+
}));
|
178 |
+
//# sourceMappingURL=index.test.js.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/index.test.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,0BAA0B,MAAM,GAAG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AI;QACZ,OAAO,EAAE,CAAC,0BAA0B,EAAE,EAAE,0BAA0B,EAAE,CAAC;KACxE,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACpC,IAAI,CAAC,IAAI,CAAC,CAAA;IACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACjB,uCAAuC;IACvC,MAAM,EAAE,CAAA;AACZ,CAAC,CAAA,CAAC,CAAA"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export declare function builtinsPolyfills(): Map<any, any>;
|
2 |
+
//# sourceMappingURL=polyfills.d.ts.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAQA,wBAAgB,iBAAiB,kBA8IhC"}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
|
2 |
+
const EMPTY_PATH = require.resolve('rollup-plugin-node-polyfills/polyfills/empty.js');
|
3 |
+
export function builtinsPolyfills() {
|
4 |
+
const libs = new Map();
|
5 |
+
libs.set('process', require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'));
|
6 |
+
libs.set('buffer', require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'));
|
7 |
+
libs.set('util', require.resolve('rollup-plugin-node-polyfills/polyfills/util'));
|
8 |
+
libs.set('sys', libs.get('util'));
|
9 |
+
libs.set('events', require.resolve('rollup-plugin-node-polyfills/polyfills/events'));
|
10 |
+
libs.set('stream', require.resolve('rollup-plugin-node-polyfills/polyfills/stream'));
|
11 |
+
libs.set('path', require.resolve('rollup-plugin-node-polyfills/polyfills/path'));
|
12 |
+
libs.set('querystring', require.resolve('rollup-plugin-node-polyfills/polyfills/qs'));
|
13 |
+
libs.set('punycode', require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'));
|
14 |
+
libs.set('url', require.resolve('rollup-plugin-node-polyfills/polyfills/url'));
|
15 |
+
libs.set('string_decoder', require.resolve('rollup-plugin-node-polyfills/polyfills/string-decoder'));
|
16 |
+
libs.set('http', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
|
17 |
+
libs.set('https', require.resolve('rollup-plugin-node-polyfills/polyfills/http'));
|
18 |
+
libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'));
|
19 |
+
libs.set('assert', require.resolve('rollup-plugin-node-polyfills/polyfills/assert'));
|
20 |
+
libs.set('constants', require.resolve('rollup-plugin-node-polyfills/polyfills/constants'));
|
21 |
+
libs.set('_stream_duplex', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/duplex'));
|
22 |
+
libs.set('_stream_passthrough', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough'));
|
23 |
+
libs.set('_stream_readable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/readable'));
|
24 |
+
libs.set('_stream_writable', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/writable'));
|
25 |
+
libs.set('_stream_transform', require.resolve('rollup-plugin-node-polyfills/polyfills/readable-stream/transform'));
|
26 |
+
libs.set('timers', require.resolve('rollup-plugin-node-polyfills/polyfills/timers'));
|
27 |
+
libs.set('console', require.resolve('rollup-plugin-node-polyfills/polyfills/console'));
|
28 |
+
libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'));
|
29 |
+
libs.set('zlib', require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'));
|
30 |
+
libs.set('tty', require.resolve('rollup-plugin-node-polyfills/polyfills/tty'));
|
31 |
+
libs.set('domain', require.resolve('rollup-plugin-node-polyfills/polyfills/domain'));
|
32 |
+
// not shimmed
|
33 |
+
libs.set('dns', EMPTY_PATH);
|
34 |
+
libs.set('dgram', EMPTY_PATH);
|
35 |
+
libs.set('child_process', EMPTY_PATH);
|
36 |
+
libs.set('cluster', EMPTY_PATH);
|
37 |
+
libs.set('module', EMPTY_PATH);
|
38 |
+
libs.set('net', EMPTY_PATH);
|
39 |
+
libs.set('readline', EMPTY_PATH);
|
40 |
+
libs.set('repl', EMPTY_PATH);
|
41 |
+
libs.set('tls', EMPTY_PATH);
|
42 |
+
libs.set('fs', EMPTY_PATH);
|
43 |
+
libs.set('crypto', EMPTY_PATH);
|
44 |
+
// libs.set(
|
45 |
+
// 'fs',
|
46 |
+
// require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
|
47 |
+
// )
|
48 |
+
// TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
|
49 |
+
// libs.set(
|
50 |
+
// 'crypto',
|
51 |
+
// require.resolve(
|
52 |
+
// 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
|
53 |
+
// ),
|
54 |
+
// )
|
55 |
+
return libs;
|
56 |
+
}
|
57 |
+
//# sourceMappingURL=polyfills.js.map
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/esm/polyfills.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@esbuild-plugins/node-modules-polyfill",
|
3 |
+
"version": "0.2.2",
|
4 |
+
"description": "",
|
5 |
+
"main": "dist/index.js",
|
6 |
+
"module": "esm/index.js",
|
7 |
+
"types": "dist/index.d.ts",
|
8 |
+
"repository": "https://github.com/remorses/esbuild-plugins.git",
|
9 |
+
"scripts": {
|
10 |
+
"build": "tsc && tsc -m es6 --outDir esm",
|
11 |
+
"watch": "tsc -w"
|
12 |
+
},
|
13 |
+
"files": [
|
14 |
+
"dist",
|
15 |
+
"src",
|
16 |
+
"esm"
|
17 |
+
],
|
18 |
+
"keywords": [],
|
19 |
+
"author": "Tommaso De Rossi, morse <[email protected]>",
|
20 |
+
"license": "ISC",
|
21 |
+
"devDependencies": {
|
22 |
+
"safe-buffer": "^5.2.1",
|
23 |
+
"test-support": "*",
|
24 |
+
"@esbuild-plugins/node-globals-polyfill": "*"
|
25 |
+
},
|
26 |
+
"dependencies": {
|
27 |
+
"escape-string-regexp": "^4.0.0",
|
28 |
+
"rollup-plugin-node-polyfills": "^0.2.1"
|
29 |
+
},
|
30 |
+
"peerDependencies": {
|
31 |
+
"esbuild": "*"
|
32 |
+
}
|
33 |
+
}
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.test.ts
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { build } from 'esbuild'
|
2 |
+
import { writeFiles } from 'test-support'
|
3 |
+
import fs from 'fs'
|
4 |
+
import NodeModulesPolyfillsPlugin from '.'
|
5 |
+
import NodeGlobalsPolyfillsPlugin from '@esbuild-plugins/node-globals-polyfill'
|
6 |
+
|
7 |
+
require('debug').enable(require('../package.json').name)
|
8 |
+
|
9 |
+
test('works', async () => {
|
10 |
+
const {
|
11 |
+
unlink,
|
12 |
+
paths: [ENTRY],
|
13 |
+
} = await writeFiles({
|
14 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
15 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
16 |
+
})
|
17 |
+
// const outfile = randomOutputFile()
|
18 |
+
const res = await build({
|
19 |
+
entryPoints: [ENTRY],
|
20 |
+
write: false,
|
21 |
+
format: 'esm',
|
22 |
+
target: 'es2017',
|
23 |
+
bundle: true,
|
24 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
25 |
+
})
|
26 |
+
eval(res.outputFiles[0].text)
|
27 |
+
// console.log(res.outputFiles[0].text)
|
28 |
+
unlink()
|
29 |
+
})
|
30 |
+
|
31 |
+
test('works with SafeBuffer and other package consumers', async () => {
|
32 |
+
const {
|
33 |
+
unlink,
|
34 |
+
paths: [ENTRY],
|
35 |
+
} = await writeFiles({
|
36 |
+
'entry.ts': `import {Buffer as SafeBuffer} from './safe-buffer'; console.log(SafeBuffer);`,
|
37 |
+
'safe-buffer.ts': fs
|
38 |
+
.readFileSync(require.resolve('safe-buffer'))
|
39 |
+
.toString(),
|
40 |
+
})
|
41 |
+
// const outfile = randomOutputFile()
|
42 |
+
const res = await build({
|
43 |
+
entryPoints: [ENTRY],
|
44 |
+
write: false,
|
45 |
+
format: 'esm',
|
46 |
+
target: 'es2017',
|
47 |
+
bundle: true,
|
48 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
49 |
+
})
|
50 |
+
// console.log(
|
51 |
+
// res.outputFiles[0].text
|
52 |
+
// .split('\n')
|
53 |
+
// .map((x, i) => i + ' ' + x)
|
54 |
+
// .join('\n'),
|
55 |
+
// )
|
56 |
+
eval(res.outputFiles[0].text)
|
57 |
+
unlink()
|
58 |
+
})
|
59 |
+
|
60 |
+
test('events works', async () => {
|
61 |
+
const {
|
62 |
+
unlink,
|
63 |
+
paths: [ENTRY],
|
64 |
+
} = await writeFiles({
|
65 |
+
'entry.ts': `
|
66 |
+
import EventEmitter from 'events';
|
67 |
+
|
68 |
+
class Test extends EventEmitter {
|
69 |
+
constructor() { };
|
70 |
+
}
|
71 |
+
console.log(Test)
|
72 |
+
`,
|
73 |
+
})
|
74 |
+
// const outfile = randomOutputFile()
|
75 |
+
const res = await build({
|
76 |
+
entryPoints: [ENTRY],
|
77 |
+
write: false,
|
78 |
+
format: 'esm',
|
79 |
+
target: 'es2017',
|
80 |
+
bundle: true,
|
81 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
82 |
+
})
|
83 |
+
// console.log(res.outputFiles[0].text)
|
84 |
+
eval(res.outputFiles[0].text)
|
85 |
+
unlink()
|
86 |
+
})
|
87 |
+
|
88 |
+
test('require can use default export', async () => {
|
89 |
+
const {
|
90 |
+
unlink,
|
91 |
+
paths: [ENTRY],
|
92 |
+
} = await writeFiles({
|
93 |
+
'entry.ts': `
|
94 |
+
const assert = require('assert')
|
95 |
+
// console.log(assert)
|
96 |
+
assert('ok')
|
97 |
+
`,
|
98 |
+
})
|
99 |
+
// const outfile = randomOutputFile()
|
100 |
+
const res = await build({
|
101 |
+
entryPoints: [ENTRY],
|
102 |
+
write: false,
|
103 |
+
format: 'esm',
|
104 |
+
target: 'es2017',
|
105 |
+
bundle: true,
|
106 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
107 |
+
})
|
108 |
+
// console.log(res.outputFiles[0].text)
|
109 |
+
eval(res.outputFiles[0].text)
|
110 |
+
unlink()
|
111 |
+
})
|
112 |
+
|
113 |
+
test.skip('crypto', async () => {
|
114 |
+
const {
|
115 |
+
unlink,
|
116 |
+
paths: [ENTRY],
|
117 |
+
} = await writeFiles({
|
118 |
+
'entry.ts': `import { randomBytes } from 'crypto'; console.log(randomBytes(20).toString('hex'))`,
|
119 |
+
})
|
120 |
+
// const outfile = randomOutputFile()
|
121 |
+
const res = await build({
|
122 |
+
entryPoints: [ENTRY],
|
123 |
+
write: false,
|
124 |
+
format: 'esm',
|
125 |
+
target: 'es2017',
|
126 |
+
bundle: true,
|
127 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
128 |
+
})
|
129 |
+
eval(res.outputFiles[0].text)
|
130 |
+
// console.log(res.outputFiles[0].text)
|
131 |
+
unlink()
|
132 |
+
})
|
133 |
+
test.skip('fs', async () => {
|
134 |
+
const {
|
135 |
+
unlink,
|
136 |
+
paths: [ENTRY],
|
137 |
+
} = await writeFiles({
|
138 |
+
'entry.ts': `import { readFile } from 'fs'; console.log(readFile(''))`,
|
139 |
+
})
|
140 |
+
// const outfile = randomOutputFile()
|
141 |
+
const res = await build({
|
142 |
+
entryPoints: [ENTRY],
|
143 |
+
write: false,
|
144 |
+
format: 'esm',
|
145 |
+
target: 'es2017',
|
146 |
+
bundle: true,
|
147 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
148 |
+
})
|
149 |
+
eval(res.outputFiles[0].text)
|
150 |
+
// console.log(res.outputFiles[0].text)
|
151 |
+
unlink()
|
152 |
+
})
|
153 |
+
|
154 |
+
test('does not include global keyword', async () => {
|
155 |
+
const {
|
156 |
+
unlink,
|
157 |
+
paths: [ENTRY],
|
158 |
+
} = await writeFiles({
|
159 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
160 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
161 |
+
})
|
162 |
+
// const outfile = randomOutputFile()
|
163 |
+
const res = await build({
|
164 |
+
entryPoints: [ENTRY],
|
165 |
+
write: false,
|
166 |
+
format: 'esm',
|
167 |
+
target: 'es2017',
|
168 |
+
bundle: true,
|
169 |
+
plugins: [NodeModulesPolyfillsPlugin()],
|
170 |
+
})
|
171 |
+
const text = res.outputFiles[0].text
|
172 |
+
eval(text)
|
173 |
+
expect(text).not.toContain(/\bglobal\b/)
|
174 |
+
// console.log(res.outputFiles[0].text)
|
175 |
+
unlink()
|
176 |
+
})
|
177 |
+
|
178 |
+
test('works with globals polyfills', async () => {
|
179 |
+
const {
|
180 |
+
unlink,
|
181 |
+
paths: [ENTRY],
|
182 |
+
} = await writeFiles({
|
183 |
+
'entry.ts': `import {x} from './utils'; console.log(x);`,
|
184 |
+
'utils.ts': `import path from 'path'; import { Buffer } from 'buffer'; export const x = path.resolve(Buffer.from('x').toString());`,
|
185 |
+
})
|
186 |
+
// const outfile = randomOutputFile()
|
187 |
+
const res = await build({
|
188 |
+
entryPoints: [ENTRY],
|
189 |
+
write: false,
|
190 |
+
format: 'esm',
|
191 |
+
target: 'es2017',
|
192 |
+
bundle: true,
|
193 |
+
plugins: [NodeModulesPolyfillsPlugin(), NodeGlobalsPolyfillsPlugin()],
|
194 |
+
})
|
195 |
+
const text = res.outputFiles[0].text
|
196 |
+
eval(text)
|
197 |
+
console.log(text)
|
198 |
+
// console.log(res.outputFiles[0].text)
|
199 |
+
unlink()
|
200 |
+
})
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/src/index.ts
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { OnResolveArgs, Plugin } from 'esbuild'
|
2 |
+
import escapeStringRegexp from 'escape-string-regexp'
|
3 |
+
import fs from 'fs'
|
4 |
+
import path from 'path'
|
5 |
+
import esbuild from 'esbuild'
|
6 |
+
import { builtinsPolyfills } from './polyfills'
|
7 |
+
|
8 |
+
// import { NodeResolvePlugin } from '@esbuild-plugins/node-resolve'
|
9 |
+
const NAME = 'node-modules-polyfills'
|
10 |
+
const NAMESPACE = NAME
|
11 |
+
|
12 |
+
function removeEndingSlash(importee) {
|
13 |
+
if (importee && importee.slice(-1) === '/') {
|
14 |
+
importee = importee.slice(0, -1)
|
15 |
+
}
|
16 |
+
return importee
|
17 |
+
}
|
18 |
+
|
19 |
+
export interface NodePolyfillsOptions {
|
20 |
+
name?: string
|
21 |
+
namespace?: string
|
22 |
+
}
|
23 |
+
|
24 |
+
export function NodeModulesPolyfillPlugin(
|
25 |
+
options: NodePolyfillsOptions = {},
|
26 |
+
): Plugin {
|
27 |
+
const { namespace = NAMESPACE, name = NAME } = options
|
28 |
+
if (namespace.endsWith('commonjs')) {
|
29 |
+
throw new Error(`namespace ${namespace} must not end with commonjs`)
|
30 |
+
}
|
31 |
+
// this namespace is needed to make ES modules expose their default export to require: require('assert') will give you import('assert').default
|
32 |
+
const commonjsNamespace = namespace + '-commonjs'
|
33 |
+
const polyfilledBuiltins = builtinsPolyfills()
|
34 |
+
const polyfilledBuiltinsNames = [...polyfilledBuiltins.keys()]
|
35 |
+
|
36 |
+
return {
|
37 |
+
name,
|
38 |
+
setup: function setup({ onLoad, onResolve, initialOptions }) {
|
39 |
+
// polyfills contain global keyword, it must be defined
|
40 |
+
if (initialOptions?.define && !initialOptions.define?.global) {
|
41 |
+
initialOptions.define['global'] = 'globalThis'
|
42 |
+
} else if (!initialOptions?.define) {
|
43 |
+
initialOptions.define = { global: 'globalThis' }
|
44 |
+
}
|
45 |
+
|
46 |
+
// TODO these polyfill module cannot import anything, is that ok?
|
47 |
+
async function loader(
|
48 |
+
args: esbuild.OnLoadArgs,
|
49 |
+
): Promise<esbuild.OnLoadResult> {
|
50 |
+
try {
|
51 |
+
const argsPath = args.path.replace(/^node:/, '')
|
52 |
+
const isCommonjs = args.namespace.endsWith('commonjs')
|
53 |
+
|
54 |
+
const resolved = polyfilledBuiltins.get(
|
55 |
+
removeEndingSlash(argsPath),
|
56 |
+
)
|
57 |
+
const contents = await (
|
58 |
+
await fs.promises.readFile(resolved)
|
59 |
+
).toString()
|
60 |
+
let resolveDir = path.dirname(resolved)
|
61 |
+
|
62 |
+
if (isCommonjs) {
|
63 |
+
return {
|
64 |
+
loader: 'js',
|
65 |
+
contents: commonJsTemplate({
|
66 |
+
importPath: argsPath,
|
67 |
+
}),
|
68 |
+
resolveDir,
|
69 |
+
}
|
70 |
+
}
|
71 |
+
return {
|
72 |
+
loader: 'js',
|
73 |
+
contents,
|
74 |
+
resolveDir,
|
75 |
+
}
|
76 |
+
} catch (e) {
|
77 |
+
console.error('node-modules-polyfill', e)
|
78 |
+
return {
|
79 |
+
contents: `export {}`,
|
80 |
+
loader: 'js',
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
onLoad({ filter: /.*/, namespace }, loader)
|
85 |
+
onLoad({ filter: /.*/, namespace: commonjsNamespace }, loader)
|
86 |
+
const filter = new RegExp(
|
87 |
+
[
|
88 |
+
...polyfilledBuiltinsNames,
|
89 |
+
...polyfilledBuiltinsNames.map((n) => `node:${n}`),
|
90 |
+
]
|
91 |
+
.map(escapeStringRegexp)
|
92 |
+
.join('|'), // TODO builtins could end with slash, keep in mind in regex
|
93 |
+
)
|
94 |
+
async function resolver(args: OnResolveArgs) {
|
95 |
+
const argsPath = args.path.replace(/^node:/, '')
|
96 |
+
const ignoreRequire = args.namespace === commonjsNamespace
|
97 |
+
|
98 |
+
if (!polyfilledBuiltins.has(argsPath)) {
|
99 |
+
return
|
100 |
+
}
|
101 |
+
|
102 |
+
const isCommonjs =
|
103 |
+
!ignoreRequire && args.kind === 'require-call'
|
104 |
+
|
105 |
+
return {
|
106 |
+
namespace: isCommonjs ? commonjsNamespace : namespace,
|
107 |
+
path: argsPath,
|
108 |
+
}
|
109 |
+
}
|
110 |
+
onResolve({ filter }, resolver)
|
111 |
+
// onResolve({ filter: /.*/, namespace }, resolver)
|
112 |
+
},
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
function commonJsTemplate({ importPath }) {
|
117 |
+
return `
|
118 |
+
const polyfill = require('${importPath}')
|
119 |
+
|
120 |
+
if (polyfill && polyfill.default) {
|
121 |
+
module.exports = polyfill.default
|
122 |
+
for (let k in polyfill) {
|
123 |
+
module.exports[k] = polyfill[k]
|
124 |
+
}
|
125 |
+
} else if (polyfill) {
|
126 |
+
module.exports = polyfill
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
`
|
131 |
+
}
|
132 |
+
|
133 |
+
export default NodeModulesPolyfillPlugin
|
workers1/auto3d/node_modules/@esbuild-plugins/node-modules-polyfill/src/polyfills.ts
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Taken from https://github.com/ionic-team/rollup-plugin-node-polyfills/blob/master/src/modules.ts
|
2 |
+
|
3 |
+
import { NodePolyfillsOptions } from '.'
|
4 |
+
|
5 |
+
const EMPTY_PATH = require.resolve(
|
6 |
+
'rollup-plugin-node-polyfills/polyfills/empty.js',
|
7 |
+
)
|
8 |
+
|
9 |
+
export function builtinsPolyfills() {
|
10 |
+
const libs = new Map()
|
11 |
+
|
12 |
+
libs.set(
|
13 |
+
'process',
|
14 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/process-es6'),
|
15 |
+
)
|
16 |
+
libs.set(
|
17 |
+
'buffer',
|
18 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/buffer-es6'),
|
19 |
+
)
|
20 |
+
libs.set(
|
21 |
+
'util',
|
22 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/util'),
|
23 |
+
)
|
24 |
+
libs.set('sys', libs.get('util'))
|
25 |
+
libs.set(
|
26 |
+
'events',
|
27 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/events'),
|
28 |
+
)
|
29 |
+
libs.set(
|
30 |
+
'stream',
|
31 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/stream'),
|
32 |
+
)
|
33 |
+
libs.set(
|
34 |
+
'path',
|
35 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/path'),
|
36 |
+
)
|
37 |
+
libs.set(
|
38 |
+
'querystring',
|
39 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/qs'),
|
40 |
+
)
|
41 |
+
libs.set(
|
42 |
+
'punycode',
|
43 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/punycode'),
|
44 |
+
)
|
45 |
+
libs.set(
|
46 |
+
'url',
|
47 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/url'),
|
48 |
+
)
|
49 |
+
libs.set(
|
50 |
+
'string_decoder',
|
51 |
+
require.resolve(
|
52 |
+
'rollup-plugin-node-polyfills/polyfills/string-decoder',
|
53 |
+
),
|
54 |
+
)
|
55 |
+
libs.set(
|
56 |
+
'http',
|
57 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/http'),
|
58 |
+
)
|
59 |
+
libs.set(
|
60 |
+
'https',
|
61 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/http'),
|
62 |
+
)
|
63 |
+
libs.set('os', require.resolve('rollup-plugin-node-polyfills/polyfills/os'))
|
64 |
+
libs.set(
|
65 |
+
'assert',
|
66 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/assert'),
|
67 |
+
)
|
68 |
+
libs.set(
|
69 |
+
'constants',
|
70 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/constants'),
|
71 |
+
)
|
72 |
+
libs.set(
|
73 |
+
'_stream_duplex',
|
74 |
+
require.resolve(
|
75 |
+
'rollup-plugin-node-polyfills/polyfills/readable-stream/duplex',
|
76 |
+
),
|
77 |
+
)
|
78 |
+
libs.set(
|
79 |
+
'_stream_passthrough',
|
80 |
+
require.resolve(
|
81 |
+
'rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough',
|
82 |
+
),
|
83 |
+
)
|
84 |
+
libs.set(
|
85 |
+
'_stream_readable',
|
86 |
+
require.resolve(
|
87 |
+
'rollup-plugin-node-polyfills/polyfills/readable-stream/readable',
|
88 |
+
),
|
89 |
+
)
|
90 |
+
libs.set(
|
91 |
+
'_stream_writable',
|
92 |
+
require.resolve(
|
93 |
+
'rollup-plugin-node-polyfills/polyfills/readable-stream/writable',
|
94 |
+
),
|
95 |
+
)
|
96 |
+
libs.set(
|
97 |
+
'_stream_transform',
|
98 |
+
require.resolve(
|
99 |
+
'rollup-plugin-node-polyfills/polyfills/readable-stream/transform',
|
100 |
+
),
|
101 |
+
)
|
102 |
+
libs.set(
|
103 |
+
'timers',
|
104 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/timers'),
|
105 |
+
)
|
106 |
+
libs.set(
|
107 |
+
'console',
|
108 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/console'),
|
109 |
+
)
|
110 |
+
libs.set('vm', require.resolve('rollup-plugin-node-polyfills/polyfills/vm'))
|
111 |
+
libs.set(
|
112 |
+
'zlib',
|
113 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/zlib'),
|
114 |
+
)
|
115 |
+
libs.set(
|
116 |
+
'tty',
|
117 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/tty'),
|
118 |
+
)
|
119 |
+
libs.set(
|
120 |
+
'domain',
|
121 |
+
require.resolve('rollup-plugin-node-polyfills/polyfills/domain'),
|
122 |
+
)
|
123 |
+
|
124 |
+
// not shimmed
|
125 |
+
libs.set('dns', EMPTY_PATH)
|
126 |
+
libs.set('dgram', EMPTY_PATH)
|
127 |
+
libs.set('child_process', EMPTY_PATH)
|
128 |
+
libs.set('cluster', EMPTY_PATH)
|
129 |
+
libs.set('module', EMPTY_PATH)
|
130 |
+
libs.set('net', EMPTY_PATH)
|
131 |
+
libs.set('readline', EMPTY_PATH)
|
132 |
+
libs.set('repl', EMPTY_PATH)
|
133 |
+
libs.set('tls', EMPTY_PATH)
|
134 |
+
libs.set('fs', EMPTY_PATH)
|
135 |
+
libs.set('crypto', EMPTY_PATH)
|
136 |
+
|
137 |
+
// libs.set(
|
138 |
+
// 'fs',
|
139 |
+
// require.resolve('rollup-plugin-node-polyfills/polyfills/browserify-fs'),
|
140 |
+
// )
|
141 |
+
|
142 |
+
// TODO enable crypto and fs https://github.com/ionic-team/rollup-plugin-node-polyfills/issues/20
|
143 |
+
// libs.set(
|
144 |
+
// 'crypto',
|
145 |
+
// require.resolve(
|
146 |
+
// 'rollup-plugin-node-polyfills/polyfills/crypto-browserify',
|
147 |
+
// ),
|
148 |
+
// )
|
149 |
+
|
150 |
+
return libs
|
151 |
+
}
|
workers1/auto3d/node_modules/@fastify/busboy/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright Brian White. All rights reserved.
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to
|
5 |
+
deal in the Software without restriction, including without limitation the
|
6 |
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7 |
+
sell copies of the Software, and to permit persons to whom the Software is
|
8 |
+
furnished to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in
|
11 |
+
all copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19 |
+
IN THE SOFTWARE.
|
workers1/auto3d/node_modules/@fastify/busboy/README.md
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# busboy
|
2 |
+
|
3 |
+
<div align="center">
|
4 |
+
|
5 |
+
[![Build Status](https://github.com/fastify/busboy/actions/workflows/ci.yml/badge.svg)](https://github.com/fastify/busboy/actions)
|
6 |
+
[![Coverage Status](https://coveralls.io/repos/fastify/busboy/badge.svg?branch=master)](https://coveralls.io/r/fastify/busboy?branch=master)
|
7 |
+
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
|
8 |
+
[![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/.github/blob/main/SECURITY.md)
|
9 |
+
|
10 |
+
</div>
|
11 |
+
|
12 |
+
<div align="center">
|
13 |
+
|
14 |
+
[![NPM version](https://img.shields.io/npm/v/@fastify/busboy.svg?style=flat)](https://www.npmjs.com/package/@fastify/busboy)
|
15 |
+
[![NPM downloads](https://img.shields.io/npm/dm/@fastify/busboy.svg?style=flat)](https://www.npmjs.com/package/@fastify/busboy)
|
16 |
+
|
17 |
+
</div>
|
18 |
+
|
19 |
+
Description
|
20 |
+
===========
|
21 |
+
|
22 |
+
A Node.js module for parsing incoming HTML form data.
|
23 |
+
|
24 |
+
This is an officially supported fork by [fastify](https://github.com/fastify/) organization of the amazing library [originally created](https://github.com/mscdex/busboy) by Brian White,
|
25 |
+
aimed at addressing long-standing issues with it.
|
26 |
+
|
27 |
+
Benchmark (Mean time for 500 Kb payload, 2000 cycles, 1000 cycle warmup):
|
28 |
+
|
29 |
+
| Library | Version | Mean time in nanoseconds (less is better) |
|
30 |
+
|-----------------------|---------|-------------------------------------------|
|
31 |
+
| busboy | 0.3.1 | `340114` |
|
32 |
+
| @fastify/busboy | 1.0.0 | `270984` |
|
33 |
+
|
34 |
+
[Changelog](https://github.com/fastify/busboy/blob/master/CHANGELOG.md) since busboy 0.31.
|
35 |
+
|
36 |
+
Requirements
|
37 |
+
============
|
38 |
+
|
39 |
+
* [Node.js](http://nodejs.org/) 10+
|
40 |
+
|
41 |
+
|
42 |
+
Install
|
43 |
+
=======
|
44 |
+
|
45 |
+
npm i @fastify/busboy
|
46 |
+
|
47 |
+
|
48 |
+
Examples
|
49 |
+
========
|
50 |
+
|
51 |
+
* Parsing (multipart) with default options:
|
52 |
+
|
53 |
+
```javascript
|
54 |
+
const http = require('node:http');
|
55 |
+
const { inspect } = require('node:util');
|
56 |
+
const Busboy = require('busboy');
|
57 |
+
|
58 |
+
http.createServer((req, res) => {
|
59 |
+
if (req.method === 'POST') {
|
60 |
+
const busboy = new Busboy({ headers: req.headers });
|
61 |
+
busboy.on('file', (fieldname, file, filename, encoding, mimetype) => {
|
62 |
+
console.log(`File [${fieldname}]: filename: ${filename}, encoding: ${encoding}, mimetype: ${mimetype}`);
|
63 |
+
file.on('data', data => {
|
64 |
+
console.log(`File [${fieldname}] got ${data.length} bytes`);
|
65 |
+
});
|
66 |
+
file.on('end', () => {
|
67 |
+
console.log(`File [${fieldname}] Finished`);
|
68 |
+
});
|
69 |
+
});
|
70 |
+
busboy.on('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => {
|
71 |
+
console.log(`Field [${fieldname}]: value: ${inspect(val)}`);
|
72 |
+
});
|
73 |
+
busboy.on('finish', () => {
|
74 |
+
console.log('Done parsing form!');
|
75 |
+
res.writeHead(303, { Connection: 'close', Location: '/' });
|
76 |
+
res.end();
|
77 |
+
});
|
78 |
+
req.pipe(busboy);
|
79 |
+
} else if (req.method === 'GET') {
|
80 |
+
res.writeHead(200, { Connection: 'close' });
|
81 |
+
res.end(`<html><head></head><body>
|
82 |
+
<form method="POST" enctype="multipart/form-data">
|
83 |
+
<input type="text" name="textfield"><br>
|
84 |
+
<input type="file" name="filefield"><br>
|
85 |
+
<input type="submit">
|
86 |
+
</form>
|
87 |
+
</body></html>`);
|
88 |
+
}
|
89 |
+
}).listen(8000, () => {
|
90 |
+
console.log('Listening for requests');
|
91 |
+
});
|
92 |
+
|
93 |
+
// Example output, using http://nodejs.org/images/ryan-speaker.jpg as the file:
|
94 |
+
//
|
95 |
+
// Listening for requests
|
96 |
+
// File [filefield]: filename: ryan-speaker.jpg, encoding: binary
|
97 |
+
// File [filefield] got 11971 bytes
|
98 |
+
// Field [textfield]: value: 'testing! :-)'
|
99 |
+
// File [filefield] Finished
|
100 |
+
// Done parsing form!
|
101 |
+
```
|
102 |
+
|
103 |
+
* Save all incoming files to disk:
|
104 |
+
|
105 |
+
```javascript
|
106 |
+
const http = require('node:http');
|
107 |
+
const path = require('node:path');
|
108 |
+
const os = require('node:os');
|
109 |
+
const fs = require('node:fs');
|
110 |
+
|
111 |
+
const Busboy = require('busboy');
|
112 |
+
|
113 |
+
http.createServer(function(req, res) {
|
114 |
+
if (req.method === 'POST') {
|
115 |
+
const busboy = new Busboy({ headers: req.headers });
|
116 |
+
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
|
117 |
+
var saveTo = path.join(os.tmpdir(), path.basename(fieldname));
|
118 |
+
file.pipe(fs.createWriteStream(saveTo));
|
119 |
+
});
|
120 |
+
busboy.on('finish', function() {
|
121 |
+
res.writeHead(200, { 'Connection': 'close' });
|
122 |
+
res.end("That's all folks!");
|
123 |
+
});
|
124 |
+
return req.pipe(busboy);
|
125 |
+
}
|
126 |
+
res.writeHead(404);
|
127 |
+
res.end();
|
128 |
+
}).listen(8000, function() {
|
129 |
+
console.log('Listening for requests');
|
130 |
+
});
|
131 |
+
```
|
132 |
+
|
133 |
+
* Parsing (urlencoded) with default options:
|
134 |
+
|
135 |
+
```javascript
|
136 |
+
const http = require('node:http');
|
137 |
+
const { inspect } = require('node:util');
|
138 |
+
|
139 |
+
const Busboy = require('busboy');
|
140 |
+
|
141 |
+
http.createServer(function(req, res) {
|
142 |
+
if (req.method === 'POST') {
|
143 |
+
const busboy = new Busboy({ headers: req.headers });
|
144 |
+
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
|
145 |
+
console.log('File [' + fieldname + ']: filename: ' + filename);
|
146 |
+
file.on('data', function(data) {
|
147 |
+
console.log('File [' + fieldname + '] got ' + data.length + ' bytes');
|
148 |
+
});
|
149 |
+
file.on('end', function() {
|
150 |
+
console.log('File [' + fieldname + '] Finished');
|
151 |
+
});
|
152 |
+
});
|
153 |
+
busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
|
154 |
+
console.log('Field [' + fieldname + ']: value: ' + inspect(val));
|
155 |
+
});
|
156 |
+
busboy.on('finish', function() {
|
157 |
+
console.log('Done parsing form!');
|
158 |
+
res.writeHead(303, { Connection: 'close', Location: '/' });
|
159 |
+
res.end();
|
160 |
+
});
|
161 |
+
req.pipe(busboy);
|
162 |
+
} else if (req.method === 'GET') {
|
163 |
+
res.writeHead(200, { Connection: 'close' });
|
164 |
+
res.end('<html><head></head><body>\
|
165 |
+
<form method="POST">\
|
166 |
+
<input type="text" name="textfield"><br />\
|
167 |
+
<select name="selectfield">\
|
168 |
+
<option value="1">1</option>\
|
169 |
+
<option value="10">10</option>\
|
170 |
+
<option value="100">100</option>\
|
171 |
+
<option value="9001">9001</option>\
|
172 |
+
</select><br />\
|
173 |
+
<input type="checkbox" name="checkfield">Node.js rules!<br />\
|
174 |
+
<input type="submit">\
|
175 |
+
</form>\
|
176 |
+
</body></html>');
|
177 |
+
}
|
178 |
+
}).listen(8000, function() {
|
179 |
+
console.log('Listening for requests');
|
180 |
+
});
|
181 |
+
|
182 |
+
// Example output:
|
183 |
+
//
|
184 |
+
// Listening for requests
|
185 |
+
// Field [textfield]: value: 'testing! :-)'
|
186 |
+
// Field [selectfield]: value: '9001'
|
187 |
+
// Field [checkfield]: value: 'on'
|
188 |
+
// Done parsing form!
|
189 |
+
```
|
190 |
+
|
191 |
+
|
192 |
+
API
|
193 |
+
===
|
194 |
+
|
195 |
+
_Busboy_ is a _Writable_ stream
|
196 |
+
|
197 |
+
Busboy (special) events
|
198 |
+
-----------------------
|
199 |
+
|
200 |
+
* **file**(< _string_ >fieldname, < _ReadableStream_ >stream, < _string_ >filename, < _string_ >transferEncoding, < _string_ >mimeType) - Emitted for each new file form field found. `transferEncoding` contains the 'Content-Transfer-Encoding' value for the file stream. `mimeType` contains the 'Content-Type' value for the file stream.
|
201 |
+
* Note: if you listen for this event, you should always handle the `stream` no matter if you care about the file contents or not (e.g. you can simply just do `stream.resume();` if you want to discard the contents), otherwise the 'finish' event will never fire on the Busboy instance. However, if you don't care about **any** incoming files, you can simply not listen for the 'file' event at all and any/all files will be automatically and safely discarded (these discarded files do still count towards `files` and `parts` limits).
|
202 |
+
* If a configured file size limit was reached, `stream` will both have a boolean property `truncated` (best checked at the end of the stream) and emit a 'limit' event to notify you when this happens.
|
203 |
+
* The property `bytesRead` informs about the number of bytes that have been read so far.
|
204 |
+
|
205 |
+
* **field**(< _string_ >fieldname, < _string_ >value, < _boolean_ >fieldnameTruncated, < _boolean_ >valueTruncated, < _string_ >transferEncoding, < _string_ >mimeType) - Emitted for each new non-file field found.
|
206 |
+
|
207 |
+
* **partsLimit**() - Emitted when specified `parts` limit has been reached. No more 'file' or 'field' events will be emitted.
|
208 |
+
|
209 |
+
* **filesLimit**() - Emitted when specified `files` limit has been reached. No more 'file' events will be emitted.
|
210 |
+
|
211 |
+
* **fieldsLimit**() - Emitted when specified `fields` limit has been reached. No more 'field' events will be emitted.
|
212 |
+
|
213 |
+
|
214 |
+
Busboy methods
|
215 |
+
--------------
|
216 |
+
|
217 |
+
* **(constructor)**(< _object_ >config) - Creates and returns a new Busboy instance.
|
218 |
+
|
219 |
+
* The constructor takes the following valid `config` settings:
|
220 |
+
|
221 |
+
* **headers** - _object_ - These are the HTTP headers of the incoming request, which are used by individual parsers.
|
222 |
+
|
223 |
+
* **autoDestroy** - _boolean_ - Whether this stream should automatically call .destroy() on itself after ending. (Default: false).
|
224 |
+
|
225 |
+
* **highWaterMark** - _integer_ - highWaterMark to use for this Busboy instance (Default: WritableStream default).
|
226 |
+
|
227 |
+
* **fileHwm** - _integer_ - highWaterMark to use for file streams (Default: ReadableStream default).
|
228 |
+
|
229 |
+
* **defCharset** - _string_ - Default character set to use when one isn't defined (Default: 'utf8').
|
230 |
+
|
231 |
+
* **preservePath** - _boolean_ - If paths in the multipart 'filename' field shall be preserved. (Default: false).
|
232 |
+
|
233 |
+
* **isPartAFile** - __function__ - Use this function to override the default file detection functionality. It has following parameters:
|
234 |
+
|
235 |
+
* fieldName - __string__ The name of the field.
|
236 |
+
|
237 |
+
* contentType - __string__ The content-type of the part, e.g. `text/plain`, `image/jpeg`, `application/octet-stream`
|
238 |
+
|
239 |
+
* fileName - __string__ The name of a file supplied by the part.
|
240 |
+
|
241 |
+
(Default: `(fieldName, contentType, fileName) => (contentType === 'application/octet-stream' || fileName !== undefined)`)
|
242 |
+
|
243 |
+
* **limits** - _object_ - Various limits on incoming data. Valid properties are:
|
244 |
+
|
245 |
+
* **fieldNameSize** - _integer_ - Max field name size (in bytes) (Default: 100 bytes).
|
246 |
+
|
247 |
+
* **fieldSize** - _integer_ - Max field value size (in bytes) (Default: 1 MiB, which is 1024 x 1024 bytes).
|
248 |
+
|
249 |
+
* **fields** - _integer_ - Max number of non-file fields (Default: Infinity).
|
250 |
+
|
251 |
+
* **fileSize** - _integer_ - For multipart forms, the max file size (in bytes) (Default: Infinity).
|
252 |
+
|
253 |
+
* **files** - _integer_ - For multipart forms, the max number of file fields (Default: Infinity).
|
254 |
+
|
255 |
+
* **parts** - _integer_ - For multipart forms, the max number of parts (fields + files) (Default: Infinity).
|
256 |
+
|
257 |
+
* **headerPairs** - _integer_ - For multipart forms, the max number of header key=>value pairs to parse **Default:** 2000
|
258 |
+
|
259 |
+
* **headerSize** - _integer_ - For multipart forms, the max size of a multipart header **Default:** 81920.
|
260 |
+
|
261 |
+
* The constructor can throw errors:
|
262 |
+
|
263 |
+
* **Busboy expected an options-Object.** - Busboy expected an Object as first parameters.
|
264 |
+
|
265 |
+
* **Busboy expected an options-Object with headers-attribute.** - The first parameter is lacking of a headers-attribute.
|
266 |
+
|
267 |
+
* **Limit $limit is not a valid number** - Busboy expected the desired limit to be of type number. Busboy throws this Error to prevent a potential security issue by falling silently back to the Busboy-defaults. Potential source for this Error can be the direct use of environment variables without transforming them to the type number.
|
268 |
+
|
269 |
+
* **Unsupported Content-Type.** - The `Content-Type` isn't one Busboy can parse.
|
270 |
+
|
271 |
+
* **Missing Content-Type-header.** - The provided headers don't include `Content-Type` at all.
|
workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright Brian White. All rights reserved.
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to
|
5 |
+
deal in the Software without restriction, including without limitation the
|
6 |
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7 |
+
sell copies of the Software, and to permit persons to whom the Software is
|
8 |
+
furnished to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in
|
11 |
+
all copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19 |
+
IN THE SOFTWARE.
|
workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
const WritableStream = require('node:stream').Writable
|
4 |
+
const inherits = require('node:util').inherits
|
5 |
+
|
6 |
+
const StreamSearch = require('../../streamsearch/sbmh')
|
7 |
+
|
8 |
+
const PartStream = require('./PartStream')
|
9 |
+
const HeaderParser = require('./HeaderParser')
|
10 |
+
|
11 |
+
const DASH = 45
|
12 |
+
const B_ONEDASH = Buffer.from('-')
|
13 |
+
const B_CRLF = Buffer.from('\r\n')
|
14 |
+
const EMPTY_FN = function () {}
|
15 |
+
|
16 |
+
function Dicer (cfg) {
|
17 |
+
if (!(this instanceof Dicer)) { return new Dicer(cfg) }
|
18 |
+
WritableStream.call(this, cfg)
|
19 |
+
|
20 |
+
if (!cfg || (!cfg.headerFirst && typeof cfg.boundary !== 'string')) { throw new TypeError('Boundary required') }
|
21 |
+
|
22 |
+
if (typeof cfg.boundary === 'string') { this.setBoundary(cfg.boundary) } else { this._bparser = undefined }
|
23 |
+
|
24 |
+
this._headerFirst = cfg.headerFirst
|
25 |
+
|
26 |
+
this._dashes = 0
|
27 |
+
this._parts = 0
|
28 |
+
this._finished = false
|
29 |
+
this._realFinish = false
|
30 |
+
this._isPreamble = true
|
31 |
+
this._justMatched = false
|
32 |
+
this._firstWrite = true
|
33 |
+
this._inHeader = true
|
34 |
+
this._part = undefined
|
35 |
+
this._cb = undefined
|
36 |
+
this._ignoreData = false
|
37 |
+
this._partOpts = { highWaterMark: cfg.partHwm }
|
38 |
+
this._pause = false
|
39 |
+
|
40 |
+
const self = this
|
41 |
+
this._hparser = new HeaderParser(cfg)
|
42 |
+
this._hparser.on('header', function (header) {
|
43 |
+
self._inHeader = false
|
44 |
+
self._part.emit('header', header)
|
45 |
+
})
|
46 |
+
}
|
47 |
+
inherits(Dicer, WritableStream)
|
48 |
+
|
49 |
+
Dicer.prototype.emit = function (ev) {
|
50 |
+
if (ev === 'finish' && !this._realFinish) {
|
51 |
+
if (!this._finished) {
|
52 |
+
const self = this
|
53 |
+
process.nextTick(function () {
|
54 |
+
self.emit('error', new Error('Unexpected end of multipart data'))
|
55 |
+
if (self._part && !self._ignoreData) {
|
56 |
+
const type = (self._isPreamble ? 'Preamble' : 'Part')
|
57 |
+
self._part.emit('error', new Error(type + ' terminated early due to unexpected end of multipart data'))
|
58 |
+
self._part.push(null)
|
59 |
+
process.nextTick(function () {
|
60 |
+
self._realFinish = true
|
61 |
+
self.emit('finish')
|
62 |
+
self._realFinish = false
|
63 |
+
})
|
64 |
+
return
|
65 |
+
}
|
66 |
+
self._realFinish = true
|
67 |
+
self.emit('finish')
|
68 |
+
self._realFinish = false
|
69 |
+
})
|
70 |
+
}
|
71 |
+
} else { WritableStream.prototype.emit.apply(this, arguments) }
|
72 |
+
}
|
73 |
+
|
74 |
+
Dicer.prototype._write = function (data, encoding, cb) {
|
75 |
+
// ignore unexpected data (e.g. extra trailer data after finished)
|
76 |
+
if (!this._hparser && !this._bparser) { return cb() }
|
77 |
+
|
78 |
+
if (this._headerFirst && this._isPreamble) {
|
79 |
+
if (!this._part) {
|
80 |
+
this._part = new PartStream(this._partOpts)
|
81 |
+
if (this.listenerCount('preamble') !== 0) { this.emit('preamble', this._part) } else { this._ignore() }
|
82 |
+
}
|
83 |
+
const r = this._hparser.push(data)
|
84 |
+
if (!this._inHeader && r !== undefined && r < data.length) { data = data.slice(r) } else { return cb() }
|
85 |
+
}
|
86 |
+
|
87 |
+
// allows for "easier" testing
|
88 |
+
if (this._firstWrite) {
|
89 |
+
this._bparser.push(B_CRLF)
|
90 |
+
this._firstWrite = false
|
91 |
+
}
|
92 |
+
|
93 |
+
this._bparser.push(data)
|
94 |
+
|
95 |
+
if (this._pause) { this._cb = cb } else { cb() }
|
96 |
+
}
|
97 |
+
|
98 |
+
Dicer.prototype.reset = function () {
|
99 |
+
this._part = undefined
|
100 |
+
this._bparser = undefined
|
101 |
+
this._hparser = undefined
|
102 |
+
}
|
103 |
+
|
104 |
+
Dicer.prototype.setBoundary = function (boundary) {
|
105 |
+
const self = this
|
106 |
+
this._bparser = new StreamSearch('\r\n--' + boundary)
|
107 |
+
this._bparser.on('info', function (isMatch, data, start, end) {
|
108 |
+
self._oninfo(isMatch, data, start, end)
|
109 |
+
})
|
110 |
+
}
|
111 |
+
|
112 |
+
Dicer.prototype._ignore = function () {
|
113 |
+
if (this._part && !this._ignoreData) {
|
114 |
+
this._ignoreData = true
|
115 |
+
this._part.on('error', EMPTY_FN)
|
116 |
+
// we must perform some kind of read on the stream even though we are
|
117 |
+
// ignoring the data, otherwise node's Readable stream will not emit 'end'
|
118 |
+
// after pushing null to the stream
|
119 |
+
this._part.resume()
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
Dicer.prototype._oninfo = function (isMatch, data, start, end) {
|
124 |
+
let buf; const self = this; let i = 0; let r; let shouldWriteMore = true
|
125 |
+
|
126 |
+
if (!this._part && this._justMatched && data) {
|
127 |
+
while (this._dashes < 2 && (start + i) < end) {
|
128 |
+
if (data[start + i] === DASH) {
|
129 |
+
++i
|
130 |
+
++this._dashes
|
131 |
+
} else {
|
132 |
+
if (this._dashes) { buf = B_ONEDASH }
|
133 |
+
this._dashes = 0
|
134 |
+
break
|
135 |
+
}
|
136 |
+
}
|
137 |
+
if (this._dashes === 2) {
|
138 |
+
if ((start + i) < end && this.listenerCount('trailer') !== 0) { this.emit('trailer', data.slice(start + i, end)) }
|
139 |
+
this.reset()
|
140 |
+
this._finished = true
|
141 |
+
// no more parts will be added
|
142 |
+
if (self._parts === 0) {
|
143 |
+
self._realFinish = true
|
144 |
+
self.emit('finish')
|
145 |
+
self._realFinish = false
|
146 |
+
}
|
147 |
+
}
|
148 |
+
if (this._dashes) { return }
|
149 |
+
}
|
150 |
+
if (this._justMatched) { this._justMatched = false }
|
151 |
+
if (!this._part) {
|
152 |
+
this._part = new PartStream(this._partOpts)
|
153 |
+
this._part._read = function (n) {
|
154 |
+
self._unpause()
|
155 |
+
}
|
156 |
+
if (this._isPreamble && this.listenerCount('preamble') !== 0) {
|
157 |
+
this.emit('preamble', this._part)
|
158 |
+
} else if (this._isPreamble !== true && this.listenerCount('part') !== 0) {
|
159 |
+
this.emit('part', this._part)
|
160 |
+
} else {
|
161 |
+
this._ignore()
|
162 |
+
}
|
163 |
+
if (!this._isPreamble) { this._inHeader = true }
|
164 |
+
}
|
165 |
+
if (data && start < end && !this._ignoreData) {
|
166 |
+
if (this._isPreamble || !this._inHeader) {
|
167 |
+
if (buf) { shouldWriteMore = this._part.push(buf) }
|
168 |
+
shouldWriteMore = this._part.push(data.slice(start, end))
|
169 |
+
if (!shouldWriteMore) { this._pause = true }
|
170 |
+
} else if (!this._isPreamble && this._inHeader) {
|
171 |
+
if (buf) { this._hparser.push(buf) }
|
172 |
+
r = this._hparser.push(data.slice(start, end))
|
173 |
+
if (!this._inHeader && r !== undefined && r < end) { this._oninfo(false, data, start + r, end) }
|
174 |
+
}
|
175 |
+
}
|
176 |
+
if (isMatch) {
|
177 |
+
this._hparser.reset()
|
178 |
+
if (this._isPreamble) { this._isPreamble = false } else {
|
179 |
+
if (start !== end) {
|
180 |
+
++this._parts
|
181 |
+
this._part.on('end', function () {
|
182 |
+
if (--self._parts === 0) {
|
183 |
+
if (self._finished) {
|
184 |
+
self._realFinish = true
|
185 |
+
self.emit('finish')
|
186 |
+
self._realFinish = false
|
187 |
+
} else {
|
188 |
+
self._unpause()
|
189 |
+
}
|
190 |
+
}
|
191 |
+
})
|
192 |
+
}
|
193 |
+
}
|
194 |
+
this._part.push(null)
|
195 |
+
this._part = undefined
|
196 |
+
this._ignoreData = false
|
197 |
+
this._justMatched = true
|
198 |
+
this._dashes = 0
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
Dicer.prototype._unpause = function () {
|
203 |
+
if (!this._pause) { return }
|
204 |
+
|
205 |
+
this._pause = false
|
206 |
+
if (this._cb) {
|
207 |
+
const cb = this._cb
|
208 |
+
this._cb = undefined
|
209 |
+
cb()
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
module.exports = Dicer
|
workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
const EventEmitter = require('node:events').EventEmitter
|
4 |
+
const inherits = require('node:util').inherits
|
5 |
+
const getLimit = require('../../../lib/utils/getLimit')
|
6 |
+
|
7 |
+
const StreamSearch = require('../../streamsearch/sbmh')
|
8 |
+
|
9 |
+
const B_DCRLF = Buffer.from('\r\n\r\n')
|
10 |
+
const RE_CRLF = /\r\n/g
|
11 |
+
const RE_HDR = /^([^:]+):[ \t]?([\x00-\xFF]+)?$/ // eslint-disable-line no-control-regex
|
12 |
+
|
13 |
+
function HeaderParser (cfg) {
|
14 |
+
EventEmitter.call(this)
|
15 |
+
|
16 |
+
cfg = cfg || {}
|
17 |
+
const self = this
|
18 |
+
this.nread = 0
|
19 |
+
this.maxed = false
|
20 |
+
this.npairs = 0
|
21 |
+
this.maxHeaderPairs = getLimit(cfg, 'maxHeaderPairs', 2000)
|
22 |
+
this.maxHeaderSize = getLimit(cfg, 'maxHeaderSize', 80 * 1024)
|
23 |
+
this.buffer = ''
|
24 |
+
this.header = {}
|
25 |
+
this.finished = false
|
26 |
+
this.ss = new StreamSearch(B_DCRLF)
|
27 |
+
this.ss.on('info', function (isMatch, data, start, end) {
|
28 |
+
if (data && !self.maxed) {
|
29 |
+
if (self.nread + end - start >= self.maxHeaderSize) {
|
30 |
+
end = self.maxHeaderSize - self.nread + start
|
31 |
+
self.nread = self.maxHeaderSize
|
32 |
+
self.maxed = true
|
33 |
+
} else { self.nread += (end - start) }
|
34 |
+
|
35 |
+
self.buffer += data.toString('binary', start, end)
|
36 |
+
}
|
37 |
+
if (isMatch) { self._finish() }
|
38 |
+
})
|
39 |
+
}
|
40 |
+
inherits(HeaderParser, EventEmitter)
|
41 |
+
|
42 |
+
HeaderParser.prototype.push = function (data) {
|
43 |
+
const r = this.ss.push(data)
|
44 |
+
if (this.finished) { return r }
|
45 |
+
}
|
46 |
+
|
47 |
+
HeaderParser.prototype.reset = function () {
|
48 |
+
this.finished = false
|
49 |
+
this.buffer = ''
|
50 |
+
this.header = {}
|
51 |
+
this.ss.reset()
|
52 |
+
}
|
53 |
+
|
54 |
+
HeaderParser.prototype._finish = function () {
|
55 |
+
if (this.buffer) { this._parseHeader() }
|
56 |
+
this.ss.matches = this.ss.maxMatches
|
57 |
+
const header = this.header
|
58 |
+
this.header = {}
|
59 |
+
this.buffer = ''
|
60 |
+
this.finished = true
|
61 |
+
this.nread = this.npairs = 0
|
62 |
+
this.maxed = false
|
63 |
+
this.emit('header', header)
|
64 |
+
}
|
65 |
+
|
66 |
+
HeaderParser.prototype._parseHeader = function () {
|
67 |
+
if (this.npairs === this.maxHeaderPairs) { return }
|
68 |
+
|
69 |
+
const lines = this.buffer.split(RE_CRLF)
|
70 |
+
const len = lines.length
|
71 |
+
let m, h
|
72 |
+
|
73 |
+
for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
|
74 |
+
if (lines[i].length === 0) { continue }
|
75 |
+
if (lines[i][0] === '\t' || lines[i][0] === ' ') {
|
76 |
+
// folded header content
|
77 |
+
// RFC2822 says to just remove the CRLF and not the whitespace following
|
78 |
+
// it, so we follow the RFC and include the leading whitespace ...
|
79 |
+
if (h) {
|
80 |
+
this.header[h][this.header[h].length - 1] += lines[i]
|
81 |
+
continue
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
const posColon = lines[i].indexOf(':')
|
86 |
+
if (
|
87 |
+
posColon === -1 ||
|
88 |
+
posColon === 0
|
89 |
+
) {
|
90 |
+
return
|
91 |
+
}
|
92 |
+
m = RE_HDR.exec(lines[i])
|
93 |
+
h = m[1].toLowerCase()
|
94 |
+
this.header[h] = this.header[h] || []
|
95 |
+
this.header[h].push((m[2] || ''))
|
96 |
+
if (++this.npairs === this.maxHeaderPairs) { break }
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
module.exports = HeaderParser
|
workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
const inherits = require('node:util').inherits
|
4 |
+
const ReadableStream = require('node:stream').Readable
|
5 |
+
|
6 |
+
function PartStream (opts) {
|
7 |
+
ReadableStream.call(this, opts)
|
8 |
+
}
|
9 |
+
inherits(PartStream, ReadableStream)
|
10 |
+
|
11 |
+
PartStream.prototype._read = function (n) {}
|
12 |
+
|
13 |
+
module.exports = PartStream
|
workers1/auto3d/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Type definitions for dicer 0.2
|
2 |
+
// Project: https://github.com/mscdex/dicer
|
3 |
+
// Definitions by: BendingBender <https://github.com/BendingBender>
|
4 |
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 |
+
// TypeScript Version: 2.2
|
6 |
+
/// <reference types="node" />
|
7 |
+
|
8 |
+
import stream = require("stream");
|
9 |
+
|
10 |
+
// tslint:disable:unified-signatures
|
11 |
+
|
12 |
+
/**
|
13 |
+
* A very fast streaming multipart parser for node.js.
|
14 |
+
* Dicer is a WritableStream
|
15 |
+
*
|
16 |
+
* Dicer (special) events:
|
17 |
+
* - on('finish', ()) - Emitted when all parts have been parsed and the Dicer instance has been ended.
|
18 |
+
* - on('part', (stream: PartStream)) - Emitted when a new part has been found.
|
19 |
+
* - on('preamble', (stream: PartStream)) - Emitted for preamble if you should happen to need it (can usually be ignored).
|
20 |
+
* - on('trailer', (data: Buffer)) - Emitted when trailing data was found after the terminating boundary (as with the preamble, this can usually be ignored too).
|
21 |
+
*/
|
22 |
+
export class Dicer extends stream.Writable {
|
23 |
+
/**
|
24 |
+
* Creates and returns a new Dicer instance with the following valid config settings:
|
25 |
+
*
|
26 |
+
* @param config The configuration to use
|
27 |
+
*/
|
28 |
+
constructor(config: Dicer.Config);
|
29 |
+
/**
|
30 |
+
* Sets the boundary to use for parsing and performs some initialization needed for parsing.
|
31 |
+
* You should only need to use this if you set headerFirst to true in the constructor and are parsing the boundary from the preamble header.
|
32 |
+
*
|
33 |
+
* @param boundary The boundary to use
|
34 |
+
*/
|
35 |
+
setBoundary(boundary: string): void;
|
36 |
+
addListener(event: "finish", listener: () => void): this;
|
37 |
+
addListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
38 |
+
addListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
39 |
+
addListener(event: "trailer", listener: (data: Buffer) => void): this;
|
40 |
+
addListener(event: "close", listener: () => void): this;
|
41 |
+
addListener(event: "drain", listener: () => void): this;
|
42 |
+
addListener(event: "error", listener: (err: Error) => void): this;
|
43 |
+
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
44 |
+
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
45 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
46 |
+
on(event: "finish", listener: () => void): this;
|
47 |
+
on(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
48 |
+
on(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
49 |
+
on(event: "trailer", listener: (data: Buffer) => void): this;
|
50 |
+
on(event: "close", listener: () => void): this;
|
51 |
+
on(event: "drain", listener: () => void): this;
|
52 |
+
on(event: "error", listener: (err: Error) => void): this;
|
53 |
+
on(event: "pipe", listener: (src: stream.Readable) => void): this;
|
54 |
+
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
55 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
56 |
+
once(event: "finish", listener: () => void): this;
|
57 |
+
once(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
58 |
+
once(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
59 |
+
once(event: "trailer", listener: (data: Buffer) => void): this;
|
60 |
+
once(event: "close", listener: () => void): this;
|
61 |
+
once(event: "drain", listener: () => void): this;
|
62 |
+
once(event: "error", listener: (err: Error) => void): this;
|
63 |
+
once(event: "pipe", listener: (src: stream.Readable) => void): this;
|
64 |
+
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
65 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
66 |
+
prependListener(event: "finish", listener: () => void): this;
|
67 |
+
prependListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
68 |
+
prependListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
69 |
+
prependListener(event: "trailer", listener: (data: Buffer) => void): this;
|
70 |
+
prependListener(event: "close", listener: () => void): this;
|
71 |
+
prependListener(event: "drain", listener: () => void): this;
|
72 |
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
73 |
+
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
74 |
+
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
75 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
76 |
+
prependOnceListener(event: "finish", listener: () => void): this;
|
77 |
+
prependOnceListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
78 |
+
prependOnceListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
79 |
+
prependOnceListener(event: "trailer", listener: (data: Buffer) => void): this;
|
80 |
+
prependOnceListener(event: "close", listener: () => void): this;
|
81 |
+
prependOnceListener(event: "drain", listener: () => void): this;
|
82 |
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
83 |
+
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
84 |
+
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
85 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
86 |
+
removeListener(event: "finish", listener: () => void): this;
|
87 |
+
removeListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
88 |
+
removeListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
89 |
+
removeListener(event: "trailer", listener: (data: Buffer) => void): this;
|
90 |
+
removeListener(event: "close", listener: () => void): this;
|
91 |
+
removeListener(event: "drain", listener: () => void): this;
|
92 |
+
removeListener(event: "error", listener: (err: Error) => void): this;
|
93 |
+
removeListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
94 |
+
removeListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
95 |
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
96 |
+
}
|
97 |
+
|
98 |
+
declare namespace Dicer {
|
99 |
+
interface Config {
|
100 |
+
/**
|
101 |
+
* This is the boundary used to detect the beginning of a new part.
|
102 |
+
*/
|
103 |
+
boundary?: string | undefined;
|
104 |
+
/**
|
105 |
+
* If true, preamble header parsing will be performed first.
|
106 |
+
*/
|
107 |
+
headerFirst?: boolean | undefined;
|
108 |
+
/**
|
109 |
+
* The maximum number of header key=>value pairs to parse Default: 2000 (same as node's http).
|
110 |
+
*/
|
111 |
+
maxHeaderPairs?: number | undefined;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* PartStream is a _ReadableStream_
|
116 |
+
*
|
117 |
+
* PartStream (special) events:
|
118 |
+
* - on('header', (header: object)) - An object containing the header for this particular part. Each property value is an array of one or more string values.
|
119 |
+
*/
|
120 |
+
interface PartStream extends stream.Readable {
|
121 |
+
addListener(event: "header", listener: (header: object) => void): this;
|
122 |
+
addListener(event: "close", listener: () => void): this;
|
123 |
+
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
124 |
+
addListener(event: "end", listener: () => void): this;
|
125 |
+
addListener(event: "readable", listener: () => void): this;
|
126 |
+
addListener(event: "error", listener: (err: Error) => void): this;
|
127 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
128 |
+
on(event: "header", listener: (header: object) => void): this;
|
129 |
+
on(event: "close", listener: () => void): this;
|
130 |
+
on(event: "data", listener: (chunk: Buffer | string) => void): this;
|
131 |
+
on(event: "end", listener: () => void): this;
|
132 |
+
on(event: "readable", listener: () => void): this;
|
133 |
+
on(event: "error", listener: (err: Error) => void): this;
|
134 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
135 |
+
once(event: "header", listener: (header: object) => void): this;
|
136 |
+
once(event: "close", listener: () => void): this;
|
137 |
+
once(event: "data", listener: (chunk: Buffer | string) => void): this;
|
138 |
+
once(event: "end", listener: () => void): this;
|
139 |
+
once(event: "readable", listener: () => void): this;
|
140 |
+
once(event: "error", listener: (err: Error) => void): this;
|
141 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
142 |
+
prependListener(event: "header", listener: (header: object) => void): this;
|
143 |
+
prependListener(event: "close", listener: () => void): this;
|
144 |
+
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
145 |
+
prependListener(event: "end", listener: () => void): this;
|
146 |
+
prependListener(event: "readable", listener: () => void): this;
|
147 |
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
148 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
149 |
+
prependOnceListener(event: "header", listener: (header: object) => void): this;
|
150 |
+
prependOnceListener(event: "close", listener: () => void): this;
|
151 |
+
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
152 |
+
prependOnceListener(event: "end", listener: () => void): this;
|
153 |
+
prependOnceListener(event: "readable", listener: () => void): this;
|
154 |
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
155 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
156 |
+
removeListener(event: "header", listener: (header: object) => void): this;
|
157 |
+
removeListener(event: "close", listener: () => void): this;
|
158 |
+
removeListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
159 |
+
removeListener(event: "end", listener: () => void): this;
|
160 |
+
removeListener(event: "readable", listener: () => void): this;
|
161 |
+
removeListener(event: "error", listener: (err: Error) => void): this;
|
162 |
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
163 |
+
}
|
164 |
+
}
|
workers1/auto3d/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js
ADDED
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright Brian White. All rights reserved.
|
5 |
+
*
|
6 |
+
* @see https://github.com/mscdex/streamsearch
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to
|
10 |
+
* deal in the Software without restriction, including without limitation the
|
11 |
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 |
+
* sell copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in
|
16 |
+
* all copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
24 |
+
* IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* Based heavily on the Streaming Boyer-Moore-Horspool C++ implementation
|
27 |
+
* by Hongli Lai at: https://github.com/FooBarWidget/boyer-moore-horspool
|
28 |
+
*/
|
29 |
+
const EventEmitter = require('node:events').EventEmitter
|
30 |
+
const inherits = require('node:util').inherits
|
31 |
+
|
32 |
+
function SBMH (needle) {
|
33 |
+
if (typeof needle === 'string') {
|
34 |
+
needle = Buffer.from(needle)
|
35 |
+
}
|
36 |
+
|
37 |
+
if (!Buffer.isBuffer(needle)) {
|
38 |
+
throw new TypeError('The needle has to be a String or a Buffer.')
|
39 |
+
}
|
40 |
+
|
41 |
+
const needleLength = needle.length
|
42 |
+
|
43 |
+
if (needleLength === 0) {
|
44 |
+
throw new Error('The needle cannot be an empty String/Buffer.')
|
45 |
+
}
|
46 |
+
|
47 |
+
if (needleLength > 256) {
|
48 |
+
throw new Error('The needle cannot have a length bigger than 256.')
|
49 |
+
}
|
50 |
+
|
51 |
+
this.maxMatches = Infinity
|
52 |
+
this.matches = 0
|
53 |
+
|
54 |
+
this._occ = new Array(256)
|
55 |
+
.fill(needleLength) // Initialize occurrence table.
|
56 |
+
this._lookbehind_size = 0
|
57 |
+
this._needle = needle
|
58 |
+
this._bufpos = 0
|
59 |
+
|
60 |
+
this._lookbehind = Buffer.alloc(needleLength)
|
61 |
+
|
62 |
+
// Populate occurrence table with analysis of the needle,
|
63 |
+
// ignoring last letter.
|
64 |
+
for (var i = 0; i < needleLength - 1; ++i) { // eslint-disable-line no-var
|
65 |
+
this._occ[needle[i]] = needleLength - 1 - i
|
66 |
+
}
|
67 |
+
}
|
68 |
+
inherits(SBMH, EventEmitter)
|
69 |
+
|
70 |
+
SBMH.prototype.reset = function () {
|
71 |
+
this._lookbehind_size = 0
|
72 |
+
this.matches = 0
|
73 |
+
this._bufpos = 0
|
74 |
+
}
|
75 |
+
|
76 |
+
SBMH.prototype.push = function (chunk, pos) {
|
77 |
+
if (!Buffer.isBuffer(chunk)) {
|
78 |
+
chunk = Buffer.from(chunk, 'binary')
|
79 |
+
}
|
80 |
+
const chlen = chunk.length
|
81 |
+
this._bufpos = pos || 0
|
82 |
+
let r
|
83 |
+
while (r !== chlen && this.matches < this.maxMatches) { r = this._sbmh_feed(chunk) }
|
84 |
+
return r
|
85 |
+
}
|
86 |
+
|
87 |
+
SBMH.prototype._sbmh_feed = function (data) {
|
88 |
+
const len = data.length
|
89 |
+
const needle = this._needle
|
90 |
+
const needleLength = needle.length
|
91 |
+
const lastNeedleChar = needle[needleLength - 1]
|
92 |
+
|
93 |
+
// Positive: points to a position in `data`
|
94 |
+
// pos == 3 points to data[3]
|
95 |
+
// Negative: points to a position in the lookbehind buffer
|
96 |
+
// pos == -2 points to lookbehind[lookbehind_size - 2]
|
97 |
+
let pos = -this._lookbehind_size
|
98 |
+
let ch
|
99 |
+
|
100 |
+
if (pos < 0) {
|
101 |
+
// Lookbehind buffer is not empty. Perform Boyer-Moore-Horspool
|
102 |
+
// search with character lookup code that considers both the
|
103 |
+
// lookbehind buffer and the current round's haystack data.
|
104 |
+
//
|
105 |
+
// Loop until
|
106 |
+
// there is a match.
|
107 |
+
// or until
|
108 |
+
// we've moved past the position that requires the
|
109 |
+
// lookbehind buffer. In this case we switch to the
|
110 |
+
// optimized loop.
|
111 |
+
// or until
|
112 |
+
// the character to look at lies outside the haystack.
|
113 |
+
while (pos < 0 && pos <= len - needleLength) {
|
114 |
+
ch = this._sbmh_lookup_char(data, pos + needleLength - 1)
|
115 |
+
|
116 |
+
if (
|
117 |
+
ch === lastNeedleChar &&
|
118 |
+
this._sbmh_memcmp(data, pos, needleLength - 1)
|
119 |
+
) {
|
120 |
+
this._lookbehind_size = 0
|
121 |
+
++this.matches
|
122 |
+
this.emit('info', true)
|
123 |
+
|
124 |
+
return (this._bufpos = pos + needleLength)
|
125 |
+
}
|
126 |
+
pos += this._occ[ch]
|
127 |
+
}
|
128 |
+
|
129 |
+
// No match.
|
130 |
+
|
131 |
+
if (pos < 0) {
|
132 |
+
// There's too few data for Boyer-Moore-Horspool to run,
|
133 |
+
// so let's use a different algorithm to skip as much as
|
134 |
+
// we can.
|
135 |
+
// Forward pos until
|
136 |
+
// the trailing part of lookbehind + data
|
137 |
+
// looks like the beginning of the needle
|
138 |
+
// or until
|
139 |
+
// pos == 0
|
140 |
+
while (pos < 0 && !this._sbmh_memcmp(data, pos, len - pos)) { ++pos }
|
141 |
+
}
|
142 |
+
|
143 |
+
if (pos >= 0) {
|
144 |
+
// Discard lookbehind buffer.
|
145 |
+
this.emit('info', false, this._lookbehind, 0, this._lookbehind_size)
|
146 |
+
this._lookbehind_size = 0
|
147 |
+
} else {
|
148 |
+
// Cut off part of the lookbehind buffer that has
|
149 |
+
// been processed and append the entire haystack
|
150 |
+
// into it.
|
151 |
+
const bytesToCutOff = this._lookbehind_size + pos
|
152 |
+
if (bytesToCutOff > 0) {
|
153 |
+
// The cut off data is guaranteed not to contain the needle.
|
154 |
+
this.emit('info', false, this._lookbehind, 0, bytesToCutOff)
|
155 |
+
}
|
156 |
+
|
157 |
+
this._lookbehind.copy(this._lookbehind, 0, bytesToCutOff,
|
158 |
+
this._lookbehind_size - bytesToCutOff)
|
159 |
+
this._lookbehind_size -= bytesToCutOff
|
160 |
+
|
161 |
+
data.copy(this._lookbehind, this._lookbehind_size)
|
162 |
+
this._lookbehind_size += len
|
163 |
+
|
164 |
+
this._bufpos = len
|
165 |
+
return len
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
pos += (pos >= 0) * this._bufpos
|
170 |
+
|
171 |
+
// Lookbehind buffer is now empty. We only need to check if the
|
172 |
+
// needle is in the haystack.
|
173 |
+
if (data.indexOf(needle, pos) !== -1) {
|
174 |
+
pos = data.indexOf(needle, pos)
|
175 |
+
++this.matches
|
176 |
+
if (pos > 0) { this.emit('info', true, data, this._bufpos, pos) } else { this.emit('info', true) }
|
177 |
+
|
178 |
+
return (this._bufpos = pos + needleLength)
|
179 |
+
} else {
|
180 |
+
pos = len - needleLength
|
181 |
+
}
|
182 |
+
|
183 |
+
// There was no match. If there's trailing haystack data that we cannot
|
184 |
+
// match yet using the Boyer-Moore-Horspool algorithm (because the trailing
|
185 |
+
// data is less than the needle size) then match using a modified
|
186 |
+
// algorithm that starts matching from the beginning instead of the end.
|
187 |
+
// Whatever trailing data is left after running this algorithm is added to
|
188 |
+
// the lookbehind buffer.
|
189 |
+
while (
|
190 |
+
pos < len &&
|
191 |
+
(
|
192 |
+
data[pos] !== needle[0] ||
|
193 |
+
(
|
194 |
+
(Buffer.compare(
|
195 |
+
data.subarray(pos, pos + len - pos),
|
196 |
+
needle.subarray(0, len - pos)
|
197 |
+
) !== 0)
|
198 |
+
)
|
199 |
+
)
|
200 |
+
) {
|
201 |
+
++pos
|
202 |
+
}
|
203 |
+
if (pos < len) {
|
204 |
+
data.copy(this._lookbehind, 0, pos, pos + (len - pos))
|
205 |
+
this._lookbehind_size = len - pos
|
206 |
+
}
|
207 |
+
|
208 |
+
// Everything until pos is guaranteed not to contain needle data.
|
209 |
+
if (pos > 0) { this.emit('info', false, data, this._bufpos, pos < len ? pos : len) }
|
210 |
+
|
211 |
+
this._bufpos = len
|
212 |
+
return len
|
213 |
+
}
|
214 |
+
|
215 |
+
SBMH.prototype._sbmh_lookup_char = function (data, pos) {
|
216 |
+
return (pos < 0)
|
217 |
+
? this._lookbehind[this._lookbehind_size + pos]
|
218 |
+
: data[pos]
|
219 |
+
}
|
220 |
+
|
221 |
+
SBMH.prototype._sbmh_memcmp = function (data, pos, len) {
|
222 |
+
for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
|
223 |
+
if (this._sbmh_lookup_char(data, pos + i) !== this._needle[i]) { return false }
|
224 |
+
}
|
225 |
+
return true
|
226 |
+
}
|
227 |
+
|
228 |
+
module.exports = SBMH
|
workers1/auto3d/node_modules/@fastify/busboy/lib/main.d.ts
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Definitions by: Jacob Baskin <https://github.com/jacobbaskin>
|
2 |
+
// BendingBender <https://github.com/BendingBender>
|
3 |
+
// Igor Savin <https://github.com/kibertoad>
|
4 |
+
|
5 |
+
/// <reference types="node" />
|
6 |
+
|
7 |
+
import * as http from 'http';
|
8 |
+
import { Readable, Writable } from 'stream';
|
9 |
+
export { Dicer } from "../deps/dicer/lib/dicer";
|
10 |
+
|
11 |
+
export const Busboy: BusboyConstructor;
|
12 |
+
export default Busboy;
|
13 |
+
|
14 |
+
export interface BusboyConfig {
|
15 |
+
/**
|
16 |
+
* These are the HTTP headers of the incoming request, which are used by individual parsers.
|
17 |
+
*/
|
18 |
+
headers: BusboyHeaders;
|
19 |
+
/**
|
20 |
+
* `highWaterMark` to use for this Busboy instance.
|
21 |
+
* @default WritableStream default.
|
22 |
+
*/
|
23 |
+
highWaterMark?: number | undefined;
|
24 |
+
/**
|
25 |
+
* highWaterMark to use for file streams.
|
26 |
+
* @default ReadableStream default.
|
27 |
+
*/
|
28 |
+
fileHwm?: number | undefined;
|
29 |
+
/**
|
30 |
+
* Default character set to use when one isn't defined.
|
31 |
+
* @default 'utf8'
|
32 |
+
*/
|
33 |
+
defCharset?: string | undefined;
|
34 |
+
/**
|
35 |
+
* Detect if a Part is a file.
|
36 |
+
*
|
37 |
+
* By default a file is detected if contentType
|
38 |
+
* is application/octet-stream or fileName is not
|
39 |
+
* undefined.
|
40 |
+
*
|
41 |
+
* Modify this to handle e.g. Blobs.
|
42 |
+
*/
|
43 |
+
isPartAFile?: (fieldName: string | undefined, contentType: string | undefined, fileName: string | undefined) => boolean;
|
44 |
+
/**
|
45 |
+
* If paths in the multipart 'filename' field shall be preserved.
|
46 |
+
* @default false
|
47 |
+
*/
|
48 |
+
preservePath?: boolean | undefined;
|
49 |
+
/**
|
50 |
+
* Various limits on incoming data.
|
51 |
+
*/
|
52 |
+
limits?:
|
53 |
+
| {
|
54 |
+
/**
|
55 |
+
* Max field name size (in bytes)
|
56 |
+
* @default 100 bytes
|
57 |
+
*/
|
58 |
+
fieldNameSize?: number | undefined;
|
59 |
+
/**
|
60 |
+
* Max field value size (in bytes)
|
61 |
+
* @default 1MB
|
62 |
+
*/
|
63 |
+
fieldSize?: number | undefined;
|
64 |
+
/**
|
65 |
+
* Max number of non-file fields
|
66 |
+
* @default Infinity
|
67 |
+
*/
|
68 |
+
fields?: number | undefined;
|
69 |
+
/**
|
70 |
+
* For multipart forms, the max file size (in bytes)
|
71 |
+
* @default Infinity
|
72 |
+
*/
|
73 |
+
fileSize?: number | undefined;
|
74 |
+
/**
|
75 |
+
* For multipart forms, the max number of file fields
|
76 |
+
* @default Infinity
|
77 |
+
*/
|
78 |
+
files?: number | undefined;
|
79 |
+
/**
|
80 |
+
* For multipart forms, the max number of parts (fields + files)
|
81 |
+
* @default Infinity
|
82 |
+
*/
|
83 |
+
parts?: number | undefined;
|
84 |
+
/**
|
85 |
+
* For multipart forms, the max number of header key=>value pairs to parse
|
86 |
+
* @default 2000
|
87 |
+
*/
|
88 |
+
headerPairs?: number | undefined;
|
89 |
+
|
90 |
+
/**
|
91 |
+
* For multipart forms, the max size of a header part
|
92 |
+
* @default 81920
|
93 |
+
*/
|
94 |
+
headerSize?: number | undefined;
|
95 |
+
}
|
96 |
+
| undefined;
|
97 |
+
}
|
98 |
+
|
99 |
+
export type BusboyHeaders = { 'content-type': string } & http.IncomingHttpHeaders;
|
100 |
+
|
101 |
+
export interface BusboyFileStream extends
|
102 |
+
Readable {
|
103 |
+
|
104 |
+
truncated: boolean;
|
105 |
+
|
106 |
+
/**
|
107 |
+
* The number of bytes that have been read so far.
|
108 |
+
*/
|
109 |
+
bytesRead: number;
|
110 |
+
}
|
111 |
+
|
112 |
+
export interface Busboy extends Writable {
|
113 |
+
addListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
114 |
+
|
115 |
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
116 |
+
|
117 |
+
on<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
118 |
+
|
119 |
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
120 |
+
|
121 |
+
once<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
122 |
+
|
123 |
+
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
124 |
+
|
125 |
+
removeListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
126 |
+
|
127 |
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
128 |
+
|
129 |
+
off<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
130 |
+
|
131 |
+
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
132 |
+
|
133 |
+
prependListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
134 |
+
|
135 |
+
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
136 |
+
|
137 |
+
prependOnceListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
138 |
+
|
139 |
+
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
140 |
+
}
|
141 |
+
|
142 |
+
export interface BusboyEvents {
|
143 |
+
/**
|
144 |
+
* Emitted for each new file form field found.
|
145 |
+
*
|
146 |
+
* * Note: if you listen for this event, you should always handle the `stream` no matter if you care about the
|
147 |
+
* file contents or not (e.g. you can simply just do `stream.resume();` if you want to discard the contents),
|
148 |
+
* otherwise the 'finish' event will never fire on the Busboy instance. However, if you don't care about **any**
|
149 |
+
* incoming files, you can simply not listen for the 'file' event at all and any/all files will be automatically
|
150 |
+
* and safely discarded (these discarded files do still count towards `files` and `parts` limits).
|
151 |
+
* * If a configured file size limit was reached, `stream` will both have a boolean property `truncated`
|
152 |
+
* (best checked at the end of the stream) and emit a 'limit' event to notify you when this happens.
|
153 |
+
*
|
154 |
+
* @param listener.transferEncoding Contains the 'Content-Transfer-Encoding' value for the file stream.
|
155 |
+
* @param listener.mimeType Contains the 'Content-Type' value for the file stream.
|
156 |
+
*/
|
157 |
+
file: (
|
158 |
+
fieldname: string,
|
159 |
+
stream: BusboyFileStream,
|
160 |
+
filename: string,
|
161 |
+
transferEncoding: string,
|
162 |
+
mimeType: string,
|
163 |
+
) => void;
|
164 |
+
/**
|
165 |
+
* Emitted for each new non-file field found.
|
166 |
+
*/
|
167 |
+
field: (
|
168 |
+
fieldname: string,
|
169 |
+
value: string,
|
170 |
+
fieldnameTruncated: boolean,
|
171 |
+
valueTruncated: boolean,
|
172 |
+
transferEncoding: string,
|
173 |
+
mimeType: string,
|
174 |
+
) => void;
|
175 |
+
finish: () => void;
|
176 |
+
/**
|
177 |
+
* Emitted when specified `parts` limit has been reached. No more 'file' or 'field' events will be emitted.
|
178 |
+
*/
|
179 |
+
partsLimit: () => void;
|
180 |
+
/**
|
181 |
+
* Emitted when specified `files` limit has been reached. No more 'file' events will be emitted.
|
182 |
+
*/
|
183 |
+
filesLimit: () => void;
|
184 |
+
/**
|
185 |
+
* Emitted when specified `fields` limit has been reached. No more 'field' events will be emitted.
|
186 |
+
*/
|
187 |
+
fieldsLimit: () => void;
|
188 |
+
error: (error: unknown) => void;
|
189 |
+
}
|
190 |
+
|
191 |
+
export interface BusboyConstructor {
|
192 |
+
(options: BusboyConfig): Busboy;
|
193 |
+
|
194 |
+
new(options: BusboyConfig): Busboy;
|
195 |
+
}
|
196 |
+
|
workers1/auto3d/node_modules/@fastify/busboy/lib/main.js
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
const WritableStream = require('node:stream').Writable
|
4 |
+
const { inherits } = require('node:util')
|
5 |
+
const Dicer = require('../deps/dicer/lib/Dicer')
|
6 |
+
|
7 |
+
const MultipartParser = require('./types/multipart')
|
8 |
+
const UrlencodedParser = require('./types/urlencoded')
|
9 |
+
const parseParams = require('./utils/parseParams')
|
10 |
+
|
11 |
+
function Busboy (opts) {
|
12 |
+
if (!(this instanceof Busboy)) { return new Busboy(opts) }
|
13 |
+
|
14 |
+
if (typeof opts !== 'object') {
|
15 |
+
throw new TypeError('Busboy expected an options-Object.')
|
16 |
+
}
|
17 |
+
if (typeof opts.headers !== 'object') {
|
18 |
+
throw new TypeError('Busboy expected an options-Object with headers-attribute.')
|
19 |
+
}
|
20 |
+
if (typeof opts.headers['content-type'] !== 'string') {
|
21 |
+
throw new TypeError('Missing Content-Type-header.')
|
22 |
+
}
|
23 |
+
|
24 |
+
const {
|
25 |
+
headers,
|
26 |
+
...streamOptions
|
27 |
+
} = opts
|
28 |
+
|
29 |
+
this.opts = {
|
30 |
+
autoDestroy: false,
|
31 |
+
...streamOptions
|
32 |
+
}
|
33 |
+
WritableStream.call(this, this.opts)
|
34 |
+
|
35 |
+
this._done = false
|
36 |
+
this._parser = this.getParserByHeaders(headers)
|
37 |
+
this._finished = false
|
38 |
+
}
|
39 |
+
inherits(Busboy, WritableStream)
|
40 |
+
|
41 |
+
Busboy.prototype.emit = function (ev) {
|
42 |
+
if (ev === 'finish') {
|
43 |
+
if (!this._done) {
|
44 |
+
this._parser?.end()
|
45 |
+
return
|
46 |
+
} else if (this._finished) {
|
47 |
+
return
|
48 |
+
}
|
49 |
+
this._finished = true
|
50 |
+
}
|
51 |
+
WritableStream.prototype.emit.apply(this, arguments)
|
52 |
+
}
|
53 |
+
|
54 |
+
Busboy.prototype.getParserByHeaders = function (headers) {
|
55 |
+
const parsed = parseParams(headers['content-type'])
|
56 |
+
|
57 |
+
const cfg = {
|
58 |
+
defCharset: this.opts.defCharset,
|
59 |
+
fileHwm: this.opts.fileHwm,
|
60 |
+
headers,
|
61 |
+
highWaterMark: this.opts.highWaterMark,
|
62 |
+
isPartAFile: this.opts.isPartAFile,
|
63 |
+
limits: this.opts.limits,
|
64 |
+
parsedConType: parsed,
|
65 |
+
preservePath: this.opts.preservePath
|
66 |
+
}
|
67 |
+
|
68 |
+
if (MultipartParser.detect.test(parsed[0])) {
|
69 |
+
return new MultipartParser(this, cfg)
|
70 |
+
}
|
71 |
+
if (UrlencodedParser.detect.test(parsed[0])) {
|
72 |
+
return new UrlencodedParser(this, cfg)
|
73 |
+
}
|
74 |
+
throw new Error('Unsupported Content-Type.')
|
75 |
+
}
|
76 |
+
|
77 |
+
Busboy.prototype._write = function (chunk, encoding, cb) {
|
78 |
+
this._parser.write(chunk, cb)
|
79 |
+
}
|
80 |
+
|
81 |
+
module.exports = Busboy
|
82 |
+
module.exports.default = Busboy
|
83 |
+
module.exports.Busboy = Busboy
|
84 |
+
|
85 |
+
module.exports.Dicer = Dicer
|
workers1/auto3d/node_modules/@fastify/busboy/lib/types/multipart.js
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
// TODO:
|
4 |
+
// * support 1 nested multipart level
|
5 |
+
// (see second multipart example here:
|
6 |
+
// http://www.w3.org/TR/html401/interact/forms.html#didx-multipartform-data)
|
7 |
+
// * support limits.fieldNameSize
|
8 |
+
// -- this will require modifications to utils.parseParams
|
9 |
+
|
10 |
+
const { Readable } = require('node:stream')
|
11 |
+
const { inherits } = require('node:util')
|
12 |
+
|
13 |
+
const Dicer = require('../../deps/dicer/lib/Dicer')
|
14 |
+
|
15 |
+
const parseParams = require('../utils/parseParams')
|
16 |
+
const decodeText = require('../utils/decodeText')
|
17 |
+
const basename = require('../utils/basename')
|
18 |
+
const getLimit = require('../utils/getLimit')
|
19 |
+
|
20 |
+
const RE_BOUNDARY = /^boundary$/i
|
21 |
+
const RE_FIELD = /^form-data$/i
|
22 |
+
const RE_CHARSET = /^charset$/i
|
23 |
+
const RE_FILENAME = /^filename$/i
|
24 |
+
const RE_NAME = /^name$/i
|
25 |
+
|
26 |
+
Multipart.detect = /^multipart\/form-data/i
|
27 |
+
function Multipart (boy, cfg) {
|
28 |
+
let i
|
29 |
+
let len
|
30 |
+
const self = this
|
31 |
+
let boundary
|
32 |
+
const limits = cfg.limits
|
33 |
+
const isPartAFile = cfg.isPartAFile || ((fieldName, contentType, fileName) => (contentType === 'application/octet-stream' || fileName !== undefined))
|
34 |
+
const parsedConType = cfg.parsedConType || []
|
35 |
+
const defCharset = cfg.defCharset || 'utf8'
|
36 |
+
const preservePath = cfg.preservePath
|
37 |
+
const fileOpts = { highWaterMark: cfg.fileHwm }
|
38 |
+
|
39 |
+
for (i = 0, len = parsedConType.length; i < len; ++i) {
|
40 |
+
if (Array.isArray(parsedConType[i]) &&
|
41 |
+
RE_BOUNDARY.test(parsedConType[i][0])) {
|
42 |
+
boundary = parsedConType[i][1]
|
43 |
+
break
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
function checkFinished () {
|
48 |
+
if (nends === 0 && finished && !boy._done) {
|
49 |
+
finished = false
|
50 |
+
self.end()
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if (typeof boundary !== 'string') { throw new Error('Multipart: Boundary not found') }
|
55 |
+
|
56 |
+
const fieldSizeLimit = getLimit(limits, 'fieldSize', 1 * 1024 * 1024)
|
57 |
+
const fileSizeLimit = getLimit(limits, 'fileSize', Infinity)
|
58 |
+
const filesLimit = getLimit(limits, 'files', Infinity)
|
59 |
+
const fieldsLimit = getLimit(limits, 'fields', Infinity)
|
60 |
+
const partsLimit = getLimit(limits, 'parts', Infinity)
|
61 |
+
const headerPairsLimit = getLimit(limits, 'headerPairs', 2000)
|
62 |
+
const headerSizeLimit = getLimit(limits, 'headerSize', 80 * 1024)
|
63 |
+
|
64 |
+
let nfiles = 0
|
65 |
+
let nfields = 0
|
66 |
+
let nends = 0
|
67 |
+
let curFile
|
68 |
+
let curField
|
69 |
+
let finished = false
|
70 |
+
|
71 |
+
this._needDrain = false
|
72 |
+
this._pause = false
|
73 |
+
this._cb = undefined
|
74 |
+
this._nparts = 0
|
75 |
+
this._boy = boy
|
76 |
+
|
77 |
+
const parserCfg = {
|
78 |
+
boundary,
|
79 |
+
maxHeaderPairs: headerPairsLimit,
|
80 |
+
maxHeaderSize: headerSizeLimit,
|
81 |
+
partHwm: fileOpts.highWaterMark,
|
82 |
+
highWaterMark: cfg.highWaterMark
|
83 |
+
}
|
84 |
+
|
85 |
+
this.parser = new Dicer(parserCfg)
|
86 |
+
this.parser.on('drain', function () {
|
87 |
+
self._needDrain = false
|
88 |
+
if (self._cb && !self._pause) {
|
89 |
+
const cb = self._cb
|
90 |
+
self._cb = undefined
|
91 |
+
cb()
|
92 |
+
}
|
93 |
+
}).on('part', function onPart (part) {
|
94 |
+
if (++self._nparts > partsLimit) {
|
95 |
+
self.parser.removeListener('part', onPart)
|
96 |
+
self.parser.on('part', skipPart)
|
97 |
+
boy.hitPartsLimit = true
|
98 |
+
boy.emit('partsLimit')
|
99 |
+
return skipPart(part)
|
100 |
+
}
|
101 |
+
|
102 |
+
// hack because streams2 _always_ doesn't emit 'end' until nextTick, so let
|
103 |
+
// us emit 'end' early since we know the part has ended if we are already
|
104 |
+
// seeing the next part
|
105 |
+
if (curField) {
|
106 |
+
const field = curField
|
107 |
+
field.emit('end')
|
108 |
+
field.removeAllListeners('end')
|
109 |
+
}
|
110 |
+
|
111 |
+
part.on('header', function (header) {
|
112 |
+
let contype
|
113 |
+
let fieldname
|
114 |
+
let parsed
|
115 |
+
let charset
|
116 |
+
let encoding
|
117 |
+
let filename
|
118 |
+
let nsize = 0
|
119 |
+
|
120 |
+
if (header['content-type']) {
|
121 |
+
parsed = parseParams(header['content-type'][0])
|
122 |
+
if (parsed[0]) {
|
123 |
+
contype = parsed[0].toLowerCase()
|
124 |
+
for (i = 0, len = parsed.length; i < len; ++i) {
|
125 |
+
if (RE_CHARSET.test(parsed[i][0])) {
|
126 |
+
charset = parsed[i][1].toLowerCase()
|
127 |
+
break
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
if (contype === undefined) { contype = 'text/plain' }
|
134 |
+
if (charset === undefined) { charset = defCharset }
|
135 |
+
|
136 |
+
if (header['content-disposition']) {
|
137 |
+
parsed = parseParams(header['content-disposition'][0])
|
138 |
+
if (!RE_FIELD.test(parsed[0])) { return skipPart(part) }
|
139 |
+
for (i = 0, len = parsed.length; i < len; ++i) {
|
140 |
+
if (RE_NAME.test(parsed[i][0])) {
|
141 |
+
fieldname = parsed[i][1]
|
142 |
+
} else if (RE_FILENAME.test(parsed[i][0])) {
|
143 |
+
filename = parsed[i][1]
|
144 |
+
if (!preservePath) { filename = basename(filename) }
|
145 |
+
}
|
146 |
+
}
|
147 |
+
} else { return skipPart(part) }
|
148 |
+
|
149 |
+
if (header['content-transfer-encoding']) { encoding = header['content-transfer-encoding'][0].toLowerCase() } else { encoding = '7bit' }
|
150 |
+
|
151 |
+
let onData,
|
152 |
+
onEnd
|
153 |
+
|
154 |
+
if (isPartAFile(fieldname, contype, filename)) {
|
155 |
+
// file/binary field
|
156 |
+
if (nfiles === filesLimit) {
|
157 |
+
if (!boy.hitFilesLimit) {
|
158 |
+
boy.hitFilesLimit = true
|
159 |
+
boy.emit('filesLimit')
|
160 |
+
}
|
161 |
+
return skipPart(part)
|
162 |
+
}
|
163 |
+
|
164 |
+
++nfiles
|
165 |
+
|
166 |
+
if (boy.listenerCount('file') === 0) {
|
167 |
+
self.parser._ignore()
|
168 |
+
return
|
169 |
+
}
|
170 |
+
|
171 |
+
++nends
|
172 |
+
const file = new FileStream(fileOpts)
|
173 |
+
curFile = file
|
174 |
+
file.on('end', function () {
|
175 |
+
--nends
|
176 |
+
self._pause = false
|
177 |
+
checkFinished()
|
178 |
+
if (self._cb && !self._needDrain) {
|
179 |
+
const cb = self._cb
|
180 |
+
self._cb = undefined
|
181 |
+
cb()
|
182 |
+
}
|
183 |
+
})
|
184 |
+
file._read = function (n) {
|
185 |
+
if (!self._pause) { return }
|
186 |
+
self._pause = false
|
187 |
+
if (self._cb && !self._needDrain) {
|
188 |
+
const cb = self._cb
|
189 |
+
self._cb = undefined
|
190 |
+
cb()
|
191 |
+
}
|
192 |
+
}
|
193 |
+
boy.emit('file', fieldname, file, filename, encoding, contype)
|
194 |
+
|
195 |
+
onData = function (data) {
|
196 |
+
if ((nsize += data.length) > fileSizeLimit) {
|
197 |
+
const extralen = fileSizeLimit - nsize + data.length
|
198 |
+
if (extralen > 0) { file.push(data.slice(0, extralen)) }
|
199 |
+
file.truncated = true
|
200 |
+
file.bytesRead = fileSizeLimit
|
201 |
+
part.removeAllListeners('data')
|
202 |
+
file.emit('limit')
|
203 |
+
return
|
204 |
+
} else if (!file.push(data)) { self._pause = true }
|
205 |
+
|
206 |
+
file.bytesRead = nsize
|
207 |
+
}
|
208 |
+
|
209 |
+
onEnd = function () {
|
210 |
+
curFile = undefined
|
211 |
+
file.push(null)
|
212 |
+
}
|
213 |
+
} else {
|
214 |
+
// non-file field
|
215 |
+
if (nfields === fieldsLimit) {
|
216 |
+
if (!boy.hitFieldsLimit) {
|
217 |
+
boy.hitFieldsLimit = true
|
218 |
+
boy.emit('fieldsLimit')
|
219 |
+
}
|
220 |
+
return skipPart(part)
|
221 |
+
}
|
222 |
+
|
223 |
+
++nfields
|
224 |
+
++nends
|
225 |
+
let buffer = ''
|
226 |
+
let truncated = false
|
227 |
+
curField = part
|
228 |
+
|
229 |
+
onData = function (data) {
|
230 |
+
if ((nsize += data.length) > fieldSizeLimit) {
|
231 |
+
const extralen = (fieldSizeLimit - (nsize - data.length))
|
232 |
+
buffer += data.toString('binary', 0, extralen)
|
233 |
+
truncated = true
|
234 |
+
part.removeAllListeners('data')
|
235 |
+
} else { buffer += data.toString('binary') }
|
236 |
+
}
|
237 |
+
|
238 |
+
onEnd = function () {
|
239 |
+
curField = undefined
|
240 |
+
if (buffer.length) { buffer = decodeText(buffer, 'binary', charset) }
|
241 |
+
boy.emit('field', fieldname, buffer, false, truncated, encoding, contype)
|
242 |
+
--nends
|
243 |
+
checkFinished()
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
/* As of node@2efe4ab761666 (v0.10.29+/v0.11.14+), busboy had become
|
248 |
+
broken. Streams2/streams3 is a huge black box of confusion, but
|
249 |
+
somehow overriding the sync state seems to fix things again (and still
|
250 |
+
seems to work for previous node versions).
|
251 |
+
*/
|
252 |
+
part._readableState.sync = false
|
253 |
+
|
254 |
+
part.on('data', onData)
|
255 |
+
part.on('end', onEnd)
|
256 |
+
}).on('error', function (err) {
|
257 |
+
if (curFile) { curFile.emit('error', err) }
|
258 |
+
})
|
259 |
+
}).on('error', function (err) {
|
260 |
+
boy.emit('error', err)
|
261 |
+
}).on('finish', function () {
|
262 |
+
finished = true
|
263 |
+
checkFinished()
|
264 |
+
})
|
265 |
+
}
|
266 |
+
|
267 |
+
Multipart.prototype.write = function (chunk, cb) {
|
268 |
+
const r = this.parser.write(chunk)
|
269 |
+
if (r && !this._pause) {
|
270 |
+
cb()
|
271 |
+
} else {
|
272 |
+
this._needDrain = !r
|
273 |
+
this._cb = cb
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
Multipart.prototype.end = function () {
|
278 |
+
const self = this
|
279 |
+
|
280 |
+
if (self.parser.writable) {
|
281 |
+
self.parser.end()
|
282 |
+
} else if (!self._boy._done) {
|
283 |
+
process.nextTick(function () {
|
284 |
+
self._boy._done = true
|
285 |
+
self._boy.emit('finish')
|
286 |
+
})
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
function skipPart (part) {
|
291 |
+
part.resume()
|
292 |
+
}
|
293 |
+
|
294 |
+
function FileStream (opts) {
|
295 |
+
Readable.call(this, opts)
|
296 |
+
|
297 |
+
this.bytesRead = 0
|
298 |
+
|
299 |
+
this.truncated = false
|
300 |
+
}
|
301 |
+
|
302 |
+
inherits(FileStream, Readable)
|
303 |
+
|
304 |
+
FileStream.prototype._read = function (n) {}
|
305 |
+
|
306 |
+
module.exports = Multipart
|
workers1/auto3d/node_modules/@fastify/busboy/lib/types/urlencoded.js
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
const Decoder = require('../utils/Decoder')
|
4 |
+
const decodeText = require('../utils/decodeText')
|
5 |
+
const getLimit = require('../utils/getLimit')
|
6 |
+
|
7 |
+
const RE_CHARSET = /^charset$/i
|
8 |
+
|
9 |
+
UrlEncoded.detect = /^application\/x-www-form-urlencoded/i
|
10 |
+
function UrlEncoded (boy, cfg) {
|
11 |
+
const limits = cfg.limits
|
12 |
+
const parsedConType = cfg.parsedConType
|
13 |
+
this.boy = boy
|
14 |
+
|
15 |
+
this.fieldSizeLimit = getLimit(limits, 'fieldSize', 1 * 1024 * 1024)
|
16 |
+
this.fieldNameSizeLimit = getLimit(limits, 'fieldNameSize', 100)
|
17 |
+
this.fieldsLimit = getLimit(limits, 'fields', Infinity)
|
18 |
+
|
19 |
+
let charset
|
20 |
+
for (var i = 0, len = parsedConType.length; i < len; ++i) { // eslint-disable-line no-var
|
21 |
+
if (Array.isArray(parsedConType[i]) &&
|
22 |
+
RE_CHARSET.test(parsedConType[i][0])) {
|
23 |
+
charset = parsedConType[i][1].toLowerCase()
|
24 |
+
break
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
if (charset === undefined) { charset = cfg.defCharset || 'utf8' }
|
29 |
+
|
30 |
+
this.decoder = new Decoder()
|
31 |
+
this.charset = charset
|
32 |
+
this._fields = 0
|
33 |
+
this._state = 'key'
|
34 |
+
this._checkingBytes = true
|
35 |
+
this._bytesKey = 0
|
36 |
+
this._bytesVal = 0
|
37 |
+
this._key = ''
|
38 |
+
this._val = ''
|
39 |
+
this._keyTrunc = false
|
40 |
+
this._valTrunc = false
|
41 |
+
this._hitLimit = false
|
42 |
+
}
|
43 |
+
|
44 |
+
UrlEncoded.prototype.write = function (data, cb) {
|
45 |
+
if (this._fields === this.fieldsLimit) {
|
46 |
+
if (!this.boy.hitFieldsLimit) {
|
47 |
+
this.boy.hitFieldsLimit = true
|
48 |
+
this.boy.emit('fieldsLimit')
|
49 |
+
}
|
50 |
+
return cb()
|
51 |
+
}
|
52 |
+
|
53 |
+
let idxeq; let idxamp; let i; let p = 0; const len = data.length
|
54 |
+
|
55 |
+
while (p < len) {
|
56 |
+
if (this._state === 'key') {
|
57 |
+
idxeq = idxamp = undefined
|
58 |
+
for (i = p; i < len; ++i) {
|
59 |
+
if (!this._checkingBytes) { ++p }
|
60 |
+
if (data[i] === 0x3D/* = */) {
|
61 |
+
idxeq = i
|
62 |
+
break
|
63 |
+
} else if (data[i] === 0x26/* & */) {
|
64 |
+
idxamp = i
|
65 |
+
break
|
66 |
+
}
|
67 |
+
if (this._checkingBytes && this._bytesKey === this.fieldNameSizeLimit) {
|
68 |
+
this._hitLimit = true
|
69 |
+
break
|
70 |
+
} else if (this._checkingBytes) { ++this._bytesKey }
|
71 |
+
}
|
72 |
+
|
73 |
+
if (idxeq !== undefined) {
|
74 |
+
// key with assignment
|
75 |
+
if (idxeq > p) { this._key += this.decoder.write(data.toString('binary', p, idxeq)) }
|
76 |
+
this._state = 'val'
|
77 |
+
|
78 |
+
this._hitLimit = false
|
79 |
+
this._checkingBytes = true
|
80 |
+
this._val = ''
|
81 |
+
this._bytesVal = 0
|
82 |
+
this._valTrunc = false
|
83 |
+
this.decoder.reset()
|
84 |
+
|
85 |
+
p = idxeq + 1
|
86 |
+
} else if (idxamp !== undefined) {
|
87 |
+
// key with no assignment
|
88 |
+
++this._fields
|
89 |
+
let key; const keyTrunc = this._keyTrunc
|
90 |
+
if (idxamp > p) { key = (this._key += this.decoder.write(data.toString('binary', p, idxamp))) } else { key = this._key }
|
91 |
+
|
92 |
+
this._hitLimit = false
|
93 |
+
this._checkingBytes = true
|
94 |
+
this._key = ''
|
95 |
+
this._bytesKey = 0
|
96 |
+
this._keyTrunc = false
|
97 |
+
this.decoder.reset()
|
98 |
+
|
99 |
+
if (key.length) {
|
100 |
+
this.boy.emit('field', decodeText(key, 'binary', this.charset),
|
101 |
+
'',
|
102 |
+
keyTrunc,
|
103 |
+
false)
|
104 |
+
}
|
105 |
+
|
106 |
+
p = idxamp + 1
|
107 |
+
if (this._fields === this.fieldsLimit) { return cb() }
|
108 |
+
} else if (this._hitLimit) {
|
109 |
+
// we may not have hit the actual limit if there are encoded bytes...
|
110 |
+
if (i > p) { this._key += this.decoder.write(data.toString('binary', p, i)) }
|
111 |
+
p = i
|
112 |
+
if ((this._bytesKey = this._key.length) === this.fieldNameSizeLimit) {
|
113 |
+
// yep, we actually did hit the limit
|
114 |
+
this._checkingBytes = false
|
115 |
+
this._keyTrunc = true
|
116 |
+
}
|
117 |
+
} else {
|
118 |
+
if (p < len) { this._key += this.decoder.write(data.toString('binary', p)) }
|
119 |
+
p = len
|
120 |
+
}
|
121 |
+
} else {
|
122 |
+
idxamp = undefined
|
123 |
+
for (i = p; i < len; ++i) {
|
124 |
+
if (!this._checkingBytes) { ++p }
|
125 |
+
if (data[i] === 0x26/* & */) {
|
126 |
+
idxamp = i
|
127 |
+
break
|
128 |
+
}
|
129 |
+
if (this._checkingBytes && this._bytesVal === this.fieldSizeLimit) {
|
130 |
+
this._hitLimit = true
|
131 |
+
break
|
132 |
+
} else if (this._checkingBytes) { ++this._bytesVal }
|
133 |
+
}
|
134 |
+
|
135 |
+
if (idxamp !== undefined) {
|
136 |
+
++this._fields
|
137 |
+
if (idxamp > p) { this._val += this.decoder.write(data.toString('binary', p, idxamp)) }
|
138 |
+
this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
|
139 |
+
decodeText(this._val, 'binary', this.charset),
|
140 |
+
this._keyTrunc,
|
141 |
+
this._valTrunc)
|
142 |
+
this._state = 'key'
|
143 |
+
|
144 |
+
this._hitLimit = false
|
145 |
+
this._checkingBytes = true
|
146 |
+
this._key = ''
|
147 |
+
this._bytesKey = 0
|
148 |
+
this._keyTrunc = false
|
149 |
+
this.decoder.reset()
|
150 |
+
|
151 |
+
p = idxamp + 1
|
152 |
+
if (this._fields === this.fieldsLimit) { return cb() }
|
153 |
+
} else if (this._hitLimit) {
|
154 |
+
// we may not have hit the actual limit if there are encoded bytes...
|
155 |
+
if (i > p) { this._val += this.decoder.write(data.toString('binary', p, i)) }
|
156 |
+
p = i
|
157 |
+
if ((this._val === '' && this.fieldSizeLimit === 0) ||
|
158 |
+
(this._bytesVal = this._val.length) === this.fieldSizeLimit) {
|
159 |
+
// yep, we actually did hit the limit
|
160 |
+
this._checkingBytes = false
|
161 |
+
this._valTrunc = true
|
162 |
+
}
|
163 |
+
} else {
|
164 |
+
if (p < len) { this._val += this.decoder.write(data.toString('binary', p)) }
|
165 |
+
p = len
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
cb()
|
170 |
+
}
|
171 |
+
|
172 |
+
UrlEncoded.prototype.end = function () {
|
173 |
+
if (this.boy._done) { return }
|
174 |
+
|
175 |
+
if (this._state === 'key' && this._key.length > 0) {
|
176 |
+
this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
|
177 |
+
'',
|
178 |
+
this._keyTrunc,
|
179 |
+
false)
|
180 |
+
} else if (this._state === 'val') {
|
181 |
+
this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
|
182 |
+
decodeText(this._val, 'binary', this.charset),
|
183 |
+
this._keyTrunc,
|
184 |
+
this._valTrunc)
|
185 |
+
}
|
186 |
+
this.boy._done = true
|
187 |
+
this.boy.emit('finish')
|
188 |
+
}
|
189 |
+
|
190 |
+
module.exports = UrlEncoded
|
workers1/auto3d/node_modules/@fastify/busboy/lib/utils/Decoder.js
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
const RE_PLUS = /\+/g
|
4 |
+
|
5 |
+
const HEX = [
|
6 |
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
7 |
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
8 |
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
9 |
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
|
10 |
+
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
11 |
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
12 |
+
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
13 |
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
14 |
+
]
|
15 |
+
|
16 |
+
function Decoder () {
|
17 |
+
this.buffer = undefined
|
18 |
+
}
|
19 |
+
Decoder.prototype.write = function (str) {
|
20 |
+
// Replace '+' with ' ' before decoding
|
21 |
+
str = str.replace(RE_PLUS, ' ')
|
22 |
+
let res = ''
|
23 |
+
let i = 0; let p = 0; const len = str.length
|
24 |
+
for (; i < len; ++i) {
|
25 |
+
if (this.buffer !== undefined) {
|
26 |
+
if (!HEX[str.charCodeAt(i)]) {
|
27 |
+
res += '%' + this.buffer
|
28 |
+
this.buffer = undefined
|
29 |
+
--i // retry character
|
30 |
+
} else {
|
31 |
+
this.buffer += str[i]
|
32 |
+
++p
|
33 |
+
if (this.buffer.length === 2) {
|
34 |
+
res += String.fromCharCode(parseInt(this.buffer, 16))
|
35 |
+
this.buffer = undefined
|
36 |
+
}
|
37 |
+
}
|
38 |
+
} else if (str[i] === '%') {
|
39 |
+
if (i > p) {
|
40 |
+
res += str.substring(p, i)
|
41 |
+
p = i
|
42 |
+
}
|
43 |
+
this.buffer = ''
|
44 |
+
++p
|
45 |
+
}
|
46 |
+
}
|
47 |
+
if (p < len && this.buffer === undefined) { res += str.substring(p) }
|
48 |
+
return res
|
49 |
+
}
|
50 |
+
Decoder.prototype.reset = function () {
|
51 |
+
this.buffer = undefined
|
52 |
+
}
|
53 |
+
|
54 |
+
module.exports = Decoder
|
workers1/auto3d/node_modules/@fastify/busboy/lib/utils/basename.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
module.exports = function basename (path) {
|
4 |
+
if (typeof path !== 'string') { return '' }
|
5 |
+
for (var i = path.length - 1; i >= 0; --i) { // eslint-disable-line no-var
|
6 |
+
switch (path.charCodeAt(i)) {
|
7 |
+
case 0x2F: // '/'
|
8 |
+
case 0x5C: // '\'
|
9 |
+
path = path.slice(i + 1)
|
10 |
+
return (path === '..' || path === '.' ? '' : path)
|
11 |
+
}
|
12 |
+
}
|
13 |
+
return (path === '..' || path === '.' ? '' : path)
|
14 |
+
}
|
workers1/auto3d/node_modules/@fastify/busboy/lib/utils/decodeText.js
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
// Node has always utf-8
|
4 |
+
const utf8Decoder = new TextDecoder('utf-8')
|
5 |
+
const textDecoders = new Map([
|
6 |
+
['utf-8', utf8Decoder],
|
7 |
+
['utf8', utf8Decoder]
|
8 |
+
])
|
9 |
+
|
10 |
+
function getDecoder (charset) {
|
11 |
+
let lc
|
12 |
+
while (true) {
|
13 |
+
switch (charset) {
|
14 |
+
case 'utf-8':
|
15 |
+
case 'utf8':
|
16 |
+
return decoders.utf8
|
17 |
+
case 'latin1':
|
18 |
+
case 'ascii': // TODO: Make these a separate, strict decoder?
|
19 |
+
case 'us-ascii':
|
20 |
+
case 'iso-8859-1':
|
21 |
+
case 'iso8859-1':
|
22 |
+
case 'iso88591':
|
23 |
+
case 'iso_8859-1':
|
24 |
+
case 'windows-1252':
|
25 |
+
case 'iso_8859-1:1987':
|
26 |
+
case 'cp1252':
|
27 |
+
case 'x-cp1252':
|
28 |
+
return decoders.latin1
|
29 |
+
case 'utf16le':
|
30 |
+
case 'utf-16le':
|
31 |
+
case 'ucs2':
|
32 |
+
case 'ucs-2':
|
33 |
+
return decoders.utf16le
|
34 |
+
case 'base64':
|
35 |
+
return decoders.base64
|
36 |
+
default:
|
37 |
+
if (lc === undefined) {
|
38 |
+
lc = true
|
39 |
+
charset = charset.toLowerCase()
|
40 |
+
continue
|
41 |
+
}
|
42 |
+
return decoders.other.bind(charset)
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
const decoders = {
|
48 |
+
utf8: (data, sourceEncoding) => {
|
49 |
+
if (data.length === 0) {
|
50 |
+
return ''
|
51 |
+
}
|
52 |
+
if (typeof data === 'string') {
|
53 |
+
data = Buffer.from(data, sourceEncoding)
|
54 |
+
}
|
55 |
+
return data.utf8Slice(0, data.length)
|
56 |
+
},
|
57 |
+
|
58 |
+
latin1: (data, sourceEncoding) => {
|
59 |
+
if (data.length === 0) {
|
60 |
+
return ''
|
61 |
+
}
|
62 |
+
if (typeof data === 'string') {
|
63 |
+
return data
|
64 |
+
}
|
65 |
+
return data.latin1Slice(0, data.length)
|
66 |
+
},
|
67 |
+
|
68 |
+
utf16le: (data, sourceEncoding) => {
|
69 |
+
if (data.length === 0) {
|
70 |
+
return ''
|
71 |
+
}
|
72 |
+
if (typeof data === 'string') {
|
73 |
+
data = Buffer.from(data, sourceEncoding)
|
74 |
+
}
|
75 |
+
return data.ucs2Slice(0, data.length)
|
76 |
+
},
|
77 |
+
|
78 |
+
base64: (data, sourceEncoding) => {
|
79 |
+
if (data.length === 0) {
|
80 |
+
return ''
|
81 |
+
}
|
82 |
+
if (typeof data === 'string') {
|
83 |
+
data = Buffer.from(data, sourceEncoding)
|
84 |
+
}
|
85 |
+
return data.base64Slice(0, data.length)
|
86 |
+
},
|
87 |
+
|
88 |
+
other: (data, sourceEncoding) => {
|
89 |
+
if (data.length === 0) {
|
90 |
+
return ''
|
91 |
+
}
|
92 |
+
if (typeof data === 'string') {
|
93 |
+
data = Buffer.from(data, sourceEncoding)
|
94 |
+
}
|
95 |
+
|
96 |
+
if (textDecoders.has(this.toString())) {
|
97 |
+
try {
|
98 |
+
return textDecoders.get(this).decode(data)
|
99 |
+
} catch {}
|
100 |
+
}
|
101 |
+
return typeof data === 'string'
|
102 |
+
? data
|
103 |
+
: data.toString()
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
function decodeText (text, sourceEncoding, destEncoding) {
|
108 |
+
if (text) {
|
109 |
+
return getDecoder(destEncoding)(text, sourceEncoding)
|
110 |
+
}
|
111 |
+
return text
|
112 |
+
}
|
113 |
+
|
114 |
+
module.exports = decodeText
|
workers1/auto3d/node_modules/@fastify/busboy/lib/utils/getLimit.js
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict'
|
2 |
+
|
3 |
+
module.exports = function getLimit (limits, name, defaultLimit) {
|
4 |
+
if (
|
5 |
+
!limits ||
|
6 |
+
limits[name] === undefined ||
|
7 |
+
limits[name] === null
|
8 |
+
) { return defaultLimit }
|
9 |
+
|
10 |
+
if (
|
11 |
+
typeof limits[name] !== 'number' ||
|
12 |
+
isNaN(limits[name])
|
13 |
+
) { throw new TypeError('Limit ' + name + ' is not a valid number') }
|
14 |
+
|
15 |
+
return limits[name]
|
16 |
+
}
|
workers1/auto3d/node_modules/@fastify/busboy/lib/utils/parseParams.js
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* eslint-disable object-property-newline */
|
2 |
+
'use strict'
|
3 |
+
|
4 |
+
const decodeText = require('./decodeText')
|
5 |
+
|
6 |
+
const RE_ENCODED = /%[a-fA-F0-9][a-fA-F0-9]/g
|
7 |
+
|
8 |
+
const EncodedLookup = {
|
9 |
+
'%00': '\x00', '%01': '\x01', '%02': '\x02', '%03': '\x03', '%04': '\x04',
|
10 |
+
'%05': '\x05', '%06': '\x06', '%07': '\x07', '%08': '\x08', '%09': '\x09',
|
11 |
+
'%0a': '\x0a', '%0A': '\x0a', '%0b': '\x0b', '%0B': '\x0b', '%0c': '\x0c',
|
12 |
+
'%0C': '\x0c', '%0d': '\x0d', '%0D': '\x0d', '%0e': '\x0e', '%0E': '\x0e',
|
13 |
+
'%0f': '\x0f', '%0F': '\x0f', '%10': '\x10', '%11': '\x11', '%12': '\x12',
|
14 |
+
'%13': '\x13', '%14': '\x14', '%15': '\x15', '%16': '\x16', '%17': '\x17',
|
15 |
+
'%18': '\x18', '%19': '\x19', '%1a': '\x1a', '%1A': '\x1a', '%1b': '\x1b',
|
16 |
+
'%1B': '\x1b', '%1c': '\x1c', '%1C': '\x1c', '%1d': '\x1d', '%1D': '\x1d',
|
17 |
+
'%1e': '\x1e', '%1E': '\x1e', '%1f': '\x1f', '%1F': '\x1f', '%20': '\x20',
|
18 |
+
'%21': '\x21', '%22': '\x22', '%23': '\x23', '%24': '\x24', '%25': '\x25',
|
19 |
+
'%26': '\x26', '%27': '\x27', '%28': '\x28', '%29': '\x29', '%2a': '\x2a',
|
20 |
+
'%2A': '\x2a', '%2b': '\x2b', '%2B': '\x2b', '%2c': '\x2c', '%2C': '\x2c',
|
21 |
+
'%2d': '\x2d', '%2D': '\x2d', '%2e': '\x2e', '%2E': '\x2e', '%2f': '\x2f',
|
22 |
+
'%2F': '\x2f', '%30': '\x30', '%31': '\x31', '%32': '\x32', '%33': '\x33',
|
23 |
+
'%34': '\x34', '%35': '\x35', '%36': '\x36', '%37': '\x37', '%38': '\x38',
|
24 |
+
'%39': '\x39', '%3a': '\x3a', '%3A': '\x3a', '%3b': '\x3b', '%3B': '\x3b',
|
25 |
+
'%3c': '\x3c', '%3C': '\x3c', '%3d': '\x3d', '%3D': '\x3d', '%3e': '\x3e',
|
26 |
+
'%3E': '\x3e', '%3f': '\x3f', '%3F': '\x3f', '%40': '\x40', '%41': '\x41',
|
27 |
+
'%42': '\x42', '%43': '\x43', '%44': '\x44', '%45': '\x45', '%46': '\x46',
|
28 |
+
'%47': '\x47', '%48': '\x48', '%49': '\x49', '%4a': '\x4a', '%4A': '\x4a',
|
29 |
+
'%4b': '\x4b', '%4B': '\x4b', '%4c': '\x4c', '%4C': '\x4c', '%4d': '\x4d',
|
30 |
+
'%4D': '\x4d', '%4e': '\x4e', '%4E': '\x4e', '%4f': '\x4f', '%4F': '\x4f',
|
31 |
+
'%50': '\x50', '%51': '\x51', '%52': '\x52', '%53': '\x53', '%54': '\x54',
|
32 |
+
'%55': '\x55', '%56': '\x56', '%57': '\x57', '%58': '\x58', '%59': '\x59',
|
33 |
+
'%5a': '\x5a', '%5A': '\x5a', '%5b': '\x5b', '%5B': '\x5b', '%5c': '\x5c',
|
34 |
+
'%5C': '\x5c', '%5d': '\x5d', '%5D': '\x5d', '%5e': '\x5e', '%5E': '\x5e',
|
35 |
+
'%5f': '\x5f', '%5F': '\x5f', '%60': '\x60', '%61': '\x61', '%62': '\x62',
|
36 |
+
'%63': '\x63', '%64': '\x64', '%65': '\x65', '%66': '\x66', '%67': '\x67',
|
37 |
+
'%68': '\x68', '%69': '\x69', '%6a': '\x6a', '%6A': '\x6a', '%6b': '\x6b',
|
38 |
+
'%6B': '\x6b', '%6c': '\x6c', '%6C': '\x6c', '%6d': '\x6d', '%6D': '\x6d',
|
39 |
+
'%6e': '\x6e', '%6E': '\x6e', '%6f': '\x6f', '%6F': '\x6f', '%70': '\x70',
|
40 |
+
'%71': '\x71', '%72': '\x72', '%73': '\x73', '%74': '\x74', '%75': '\x75',
|
41 |
+
'%76': '\x76', '%77': '\x77', '%78': '\x78', '%79': '\x79', '%7a': '\x7a',
|
42 |
+
'%7A': '\x7a', '%7b': '\x7b', '%7B': '\x7b', '%7c': '\x7c', '%7C': '\x7c',
|
43 |
+
'%7d': '\x7d', '%7D': '\x7d', '%7e': '\x7e', '%7E': '\x7e', '%7f': '\x7f',
|
44 |
+
'%7F': '\x7f', '%80': '\x80', '%81': '\x81', '%82': '\x82', '%83': '\x83',
|
45 |
+
'%84': '\x84', '%85': '\x85', '%86': '\x86', '%87': '\x87', '%88': '\x88',
|
46 |
+
'%89': '\x89', '%8a': '\x8a', '%8A': '\x8a', '%8b': '\x8b', '%8B': '\x8b',
|
47 |
+
'%8c': '\x8c', '%8C': '\x8c', '%8d': '\x8d', '%8D': '\x8d', '%8e': '\x8e',
|
48 |
+
'%8E': '\x8e', '%8f': '\x8f', '%8F': '\x8f', '%90': '\x90', '%91': '\x91',
|
49 |
+
'%92': '\x92', '%93': '\x93', '%94': '\x94', '%95': '\x95', '%96': '\x96',
|
50 |
+
'%97': '\x97', '%98': '\x98', '%99': '\x99', '%9a': '\x9a', '%9A': '\x9a',
|
51 |
+
'%9b': '\x9b', '%9B': '\x9b', '%9c': '\x9c', '%9C': '\x9c', '%9d': '\x9d',
|
52 |
+
'%9D': '\x9d', '%9e': '\x9e', '%9E': '\x9e', '%9f': '\x9f', '%9F': '\x9f',
|
53 |
+
'%a0': '\xa0', '%A0': '\xa0', '%a1': '\xa1', '%A1': '\xa1', '%a2': '\xa2',
|
54 |
+
'%A2': '\xa2', '%a3': '\xa3', '%A3': '\xa3', '%a4': '\xa4', '%A4': '\xa4',
|
55 |
+
'%a5': '\xa5', '%A5': '\xa5', '%a6': '\xa6', '%A6': '\xa6', '%a7': '\xa7',
|
56 |
+
'%A7': '\xa7', '%a8': '\xa8', '%A8': '\xa8', '%a9': '\xa9', '%A9': '\xa9',
|
57 |
+
'%aa': '\xaa', '%Aa': '\xaa', '%aA': '\xaa', '%AA': '\xaa', '%ab': '\xab',
|
58 |
+
'%Ab': '\xab', '%aB': '\xab', '%AB': '\xab', '%ac': '\xac', '%Ac': '\xac',
|
59 |
+
'%aC': '\xac', '%AC': '\xac', '%ad': '\xad', '%Ad': '\xad', '%aD': '\xad',
|
60 |
+
'%AD': '\xad', '%ae': '\xae', '%Ae': '\xae', '%aE': '\xae', '%AE': '\xae',
|
61 |
+
'%af': '\xaf', '%Af': '\xaf', '%aF': '\xaf', '%AF': '\xaf', '%b0': '\xb0',
|
62 |
+
'%B0': '\xb0', '%b1': '\xb1', '%B1': '\xb1', '%b2': '\xb2', '%B2': '\xb2',
|
63 |
+
'%b3': '\xb3', '%B3': '\xb3', '%b4': '\xb4', '%B4': '\xb4', '%b5': '\xb5',
|
64 |
+
'%B5': '\xb5', '%b6': '\xb6', '%B6': '\xb6', '%b7': '\xb7', '%B7': '\xb7',
|
65 |
+
'%b8': '\xb8', '%B8': '\xb8', '%b9': '\xb9', '%B9': '\xb9', '%ba': '\xba',
|
66 |
+
'%Ba': '\xba', '%bA': '\xba', '%BA': '\xba', '%bb': '\xbb', '%Bb': '\xbb',
|
67 |
+
'%bB': '\xbb', '%BB': '\xbb', '%bc': '\xbc', '%Bc': '\xbc', '%bC': '\xbc',
|
68 |
+
'%BC': '\xbc', '%bd': '\xbd', '%Bd': '\xbd', '%bD': '\xbd', '%BD': '\xbd',
|
69 |
+
'%be': '\xbe', '%Be': '\xbe', '%bE': '\xbe', '%BE': '\xbe', '%bf': '\xbf',
|
70 |
+
'%Bf': '\xbf', '%bF': '\xbf', '%BF': '\xbf', '%c0': '\xc0', '%C0': '\xc0',
|
71 |
+
'%c1': '\xc1', '%C1': '\xc1', '%c2': '\xc2', '%C2': '\xc2', '%c3': '\xc3',
|
72 |
+
'%C3': '\xc3', '%c4': '\xc4', '%C4': '\xc4', '%c5': '\xc5', '%C5': '\xc5',
|
73 |
+
'%c6': '\xc6', '%C6': '\xc6', '%c7': '\xc7', '%C7': '\xc7', '%c8': '\xc8',
|
74 |
+
'%C8': '\xc8', '%c9': '\xc9', '%C9': '\xc9', '%ca': '\xca', '%Ca': '\xca',
|
75 |
+
'%cA': '\xca', '%CA': '\xca', '%cb': '\xcb', '%Cb': '\xcb', '%cB': '\xcb',
|
76 |
+
'%CB': '\xcb', '%cc': '\xcc', '%Cc': '\xcc', '%cC': '\xcc', '%CC': '\xcc',
|
77 |
+
'%cd': '\xcd', '%Cd': '\xcd', '%cD': '\xcd', '%CD': '\xcd', '%ce': '\xce',
|
78 |
+
'%Ce': '\xce', '%cE': '\xce', '%CE': '\xce', '%cf': '\xcf', '%Cf': '\xcf',
|
79 |
+
'%cF': '\xcf', '%CF': '\xcf', '%d0': '\xd0', '%D0': '\xd0', '%d1': '\xd1',
|
80 |
+
'%D1': '\xd1', '%d2': '\xd2', '%D2': '\xd2', '%d3': '\xd3', '%D3': '\xd3',
|
81 |
+
'%d4': '\xd4', '%D4': '\xd4', '%d5': '\xd5', '%D5': '\xd5', '%d6': '\xd6',
|
82 |
+
'%D6': '\xd6', '%d7': '\xd7', '%D7': '\xd7', '%d8': '\xd8', '%D8': '\xd8',
|
83 |
+
'%d9': '\xd9', '%D9': '\xd9', '%da': '\xda', '%Da': '\xda', '%dA': '\xda',
|
84 |
+
'%DA': '\xda', '%db': '\xdb', '%Db': '\xdb', '%dB': '\xdb', '%DB': '\xdb',
|
85 |
+
'%dc': '\xdc', '%Dc': '\xdc', '%dC': '\xdc', '%DC': '\xdc', '%dd': '\xdd',
|
86 |
+
'%Dd': '\xdd', '%dD': '\xdd', '%DD': '\xdd', '%de': '\xde', '%De': '\xde',
|
87 |
+
'%dE': '\xde', '%DE': '\xde', '%df': '\xdf', '%Df': '\xdf', '%dF': '\xdf',
|
88 |
+
'%DF': '\xdf', '%e0': '\xe0', '%E0': '\xe0', '%e1': '\xe1', '%E1': '\xe1',
|
89 |
+
'%e2': '\xe2', '%E2': '\xe2', '%e3': '\xe3', '%E3': '\xe3', '%e4': '\xe4',
|
90 |
+
'%E4': '\xe4', '%e5': '\xe5', '%E5': '\xe5', '%e6': '\xe6', '%E6': '\xe6',
|
91 |
+
'%e7': '\xe7', '%E7': '\xe7', '%e8': '\xe8', '%E8': '\xe8', '%e9': '\xe9',
|
92 |
+
'%E9': '\xe9', '%ea': '\xea', '%Ea': '\xea', '%eA': '\xea', '%EA': '\xea',
|
93 |
+
'%eb': '\xeb', '%Eb': '\xeb', '%eB': '\xeb', '%EB': '\xeb', '%ec': '\xec',
|
94 |
+
'%Ec': '\xec', '%eC': '\xec', '%EC': '\xec', '%ed': '\xed', '%Ed': '\xed',
|
95 |
+
'%eD': '\xed', '%ED': '\xed', '%ee': '\xee', '%Ee': '\xee', '%eE': '\xee',
|
96 |
+
'%EE': '\xee', '%ef': '\xef', '%Ef': '\xef', '%eF': '\xef', '%EF': '\xef',
|
97 |
+
'%f0': '\xf0', '%F0': '\xf0', '%f1': '\xf1', '%F1': '\xf1', '%f2': '\xf2',
|
98 |
+
'%F2': '\xf2', '%f3': '\xf3', '%F3': '\xf3', '%f4': '\xf4', '%F4': '\xf4',
|
99 |
+
'%f5': '\xf5', '%F5': '\xf5', '%f6': '\xf6', '%F6': '\xf6', '%f7': '\xf7',
|
100 |
+
'%F7': '\xf7', '%f8': '\xf8', '%F8': '\xf8', '%f9': '\xf9', '%F9': '\xf9',
|
101 |
+
'%fa': '\xfa', '%Fa': '\xfa', '%fA': '\xfa', '%FA': '\xfa', '%fb': '\xfb',
|
102 |
+
'%Fb': '\xfb', '%fB': '\xfb', '%FB': '\xfb', '%fc': '\xfc', '%Fc': '\xfc',
|
103 |
+
'%fC': '\xfc', '%FC': '\xfc', '%fd': '\xfd', '%Fd': '\xfd', '%fD': '\xfd',
|
104 |
+
'%FD': '\xfd', '%fe': '\xfe', '%Fe': '\xfe', '%fE': '\xfe', '%FE': '\xfe',
|
105 |
+
'%ff': '\xff', '%Ff': '\xff', '%fF': '\xff', '%FF': '\xff'
|
106 |
+
}
|
107 |
+
|
108 |
+
function encodedReplacer (match) {
|
109 |
+
return EncodedLookup[match]
|
110 |
+
}
|
111 |
+
|
112 |
+
const STATE_KEY = 0
|
113 |
+
const STATE_VALUE = 1
|
114 |
+
const STATE_CHARSET = 2
|
115 |
+
const STATE_LANG = 3
|
116 |
+
|
117 |
+
function parseParams (str) {
|
118 |
+
const res = []
|
119 |
+
let state = STATE_KEY
|
120 |
+
let charset = ''
|
121 |
+
let inquote = false
|
122 |
+
let escaping = false
|
123 |
+
let p = 0
|
124 |
+
let tmp = ''
|
125 |
+
const len = str.length
|
126 |
+
|
127 |
+
for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
|
128 |
+
const char = str[i]
|
129 |
+
if (char === '\\' && inquote) {
|
130 |
+
if (escaping) { escaping = false } else {
|
131 |
+
escaping = true
|
132 |
+
continue
|
133 |
+
}
|
134 |
+
} else if (char === '"') {
|
135 |
+
if (!escaping) {
|
136 |
+
if (inquote) {
|
137 |
+
inquote = false
|
138 |
+
state = STATE_KEY
|
139 |
+
} else { inquote = true }
|
140 |
+
continue
|
141 |
+
} else { escaping = false }
|
142 |
+
} else {
|
143 |
+
if (escaping && inquote) { tmp += '\\' }
|
144 |
+
escaping = false
|
145 |
+
if ((state === STATE_CHARSET || state === STATE_LANG) && char === "'") {
|
146 |
+
if (state === STATE_CHARSET) {
|
147 |
+
state = STATE_LANG
|
148 |
+
charset = tmp.substring(1)
|
149 |
+
} else { state = STATE_VALUE }
|
150 |
+
tmp = ''
|
151 |
+
continue
|
152 |
+
} else if (state === STATE_KEY &&
|
153 |
+
(char === '*' || char === '=') &&
|
154 |
+
res.length) {
|
155 |
+
state = char === '*'
|
156 |
+
? STATE_CHARSET
|
157 |
+
: STATE_VALUE
|
158 |
+
res[p] = [tmp, undefined]
|
159 |
+
tmp = ''
|
160 |
+
continue
|
161 |
+
} else if (!inquote && char === ';') {
|
162 |
+
state = STATE_KEY
|
163 |
+
if (charset) {
|
164 |
+
if (tmp.length) {
|
165 |
+
tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
|
166 |
+
'binary',
|
167 |
+
charset)
|
168 |
+
}
|
169 |
+
charset = ''
|
170 |
+
} else if (tmp.length) {
|
171 |
+
tmp = decodeText(tmp, 'binary', 'utf8')
|
172 |
+
}
|
173 |
+
if (res[p] === undefined) { res[p] = tmp } else { res[p][1] = tmp }
|
174 |
+
tmp = ''
|
175 |
+
++p
|
176 |
+
continue
|
177 |
+
} else if (!inquote && (char === ' ' || char === '\t')) { continue }
|
178 |
+
}
|
179 |
+
tmp += char
|
180 |
+
}
|
181 |
+
if (charset && tmp.length) {
|
182 |
+
tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
|
183 |
+
'binary',
|
184 |
+
charset)
|
185 |
+
} else if (tmp) {
|
186 |
+
tmp = decodeText(tmp, 'binary', 'utf8')
|
187 |
+
}
|
188 |
+
|
189 |
+
if (res[p] === undefined) {
|
190 |
+
if (tmp) { res[p] = tmp }
|
191 |
+
} else { res[p][1] = tmp }
|
192 |
+
|
193 |
+
return res
|
194 |
+
}
|
195 |
+
|
196 |
+
module.exports = parseParams
|
workers1/auto3d/node_modules/@fastify/busboy/package.json
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@fastify/busboy",
|
3 |
+
"version": "2.1.1",
|
4 |
+
"private": false,
|
5 |
+
"author": "Brian White <[email protected]>",
|
6 |
+
"contributors": [
|
7 |
+
{
|
8 |
+
"name": "Igor Savin",
|
9 |
+
"email": "[email protected]",
|
10 |
+
"url": "https://github.com/kibertoad"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"name": "Aras Abbasi",
|
14 |
+
"email": "[email protected]",
|
15 |
+
"url": "https://github.com/uzlopak"
|
16 |
+
}
|
17 |
+
],
|
18 |
+
"description": "A streaming parser for HTML form data for node.js",
|
19 |
+
"main": "lib/main",
|
20 |
+
"type": "commonjs",
|
21 |
+
"types": "lib/main.d.ts",
|
22 |
+
"scripts": {
|
23 |
+
"bench:busboy": "cd benchmarks && npm install && npm run benchmark-fastify",
|
24 |
+
"bench:dicer": "node bench/dicer/dicer-bench-multipart-parser.js",
|
25 |
+
"coveralls": "nyc report --reporter=lcov",
|
26 |
+
"lint": "npm run lint:standard",
|
27 |
+
"lint:everything": "npm run lint && npm run test:types",
|
28 |
+
"lint:fix": "standard --fix",
|
29 |
+
"lint:standard": "standard --verbose | snazzy",
|
30 |
+
"test:mocha": "tap",
|
31 |
+
"test:types": "tsd",
|
32 |
+
"test:coverage": "nyc npm run test",
|
33 |
+
"test": "npm run test:mocha"
|
34 |
+
},
|
35 |
+
"engines": {
|
36 |
+
"node": ">=14"
|
37 |
+
},
|
38 |
+
"devDependencies": {
|
39 |
+
"@types/node": "^20.1.0",
|
40 |
+
"busboy": "^1.0.0",
|
41 |
+
"photofinish": "^1.8.0",
|
42 |
+
"snazzy": "^9.0.0",
|
43 |
+
"standard": "^17.0.0",
|
44 |
+
"tap": "^16.3.8",
|
45 |
+
"tinybench": "^2.5.1",
|
46 |
+
"tsd": "^0.30.0",
|
47 |
+
"typescript": "^5.0.2"
|
48 |
+
},
|
49 |
+
"keywords": [
|
50 |
+
"uploads",
|
51 |
+
"forms",
|
52 |
+
"multipart",
|
53 |
+
"form-data"
|
54 |
+
],
|
55 |
+
"license": "MIT",
|
56 |
+
"repository": {
|
57 |
+
"type": "git",
|
58 |
+
"url": "git+https://github.com/fastify/busboy.git"
|
59 |
+
},
|
60 |
+
"tsd": {
|
61 |
+
"directory": "test/types",
|
62 |
+
"compilerOptions": {
|
63 |
+
"esModuleInterop": false,
|
64 |
+
"module": "commonjs",
|
65 |
+
"target": "ES2017"
|
66 |
+
}
|
67 |
+
},
|
68 |
+
"standard": {
|
69 |
+
"globals": [
|
70 |
+
"describe",
|
71 |
+
"it"
|
72 |
+
],
|
73 |
+
"ignore": [
|
74 |
+
"bench"
|
75 |
+
]
|
76 |
+
},
|
77 |
+
"files": [
|
78 |
+
"README.md",
|
79 |
+
"LICENSE",
|
80 |
+
"lib/*",
|
81 |
+
"deps/encoding/*",
|
82 |
+
"deps/dicer/lib",
|
83 |
+
"deps/streamsearch/",
|
84 |
+
"deps/dicer/LICENSE"
|
85 |
+
]
|
86 |
+
}
|
workers1/auto3d/node_modules/@jridgewell/resolve-uri/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2019 Justin Ridgewell <[email protected]>
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
+
of this software and associated documentation files (the "Software"), to deal
|
5 |
+
in the Software without restriction, including without limitation the rights
|
6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
+
copies of the Software, and to permit persons to whom the Software is
|
8 |
+
furnished to do so, subject to the following conditions:
|
9 |
+
|
10 |
+
The above copyright notice and this permission notice shall be included in
|
11 |
+
all copies or substantial portions of the Software.
|
12 |
+
|
13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19 |
+
SOFTWARE.
|