rollup-packages-polyfill-core 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/LICENSE.md +26 -26
  2. package/dist/es/index.js +81 -0
  3. package/dist/es/modules.js +58 -0
  4. package/dist/es/polyfills.js +3 -0
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.js +115 -0
  7. package/dist/modules.d.ts +1 -0
  8. package/dist/modules.js +60 -0
  9. package/dist/polyfills.d.ts +53 -0
  10. package/dist/polyfills.js +5 -0
  11. package/package.json +54 -10
  12. package/{ReadMe.md → readme.md} +85 -85
  13. package/browser-test/index.js +0 -20
  14. package/browser-test/main.js +0 -44
  15. package/index.js +0 -83
  16. package/polyfills/LICENSE-browserify-fs.txt +0 -472
  17. package/polyfills/LICENSE-buffer-es6.txt +0 -69
  18. package/polyfills/LICENSE-crypto-browserify.txt +0 -355
  19. package/polyfills/LICENSE-process-es6.txt +0 -32
  20. package/polyfills/__http-lib/capability.js +0 -52
  21. package/polyfills/__http-lib/request.js +0 -278
  22. package/polyfills/__http-lib/response.js +0 -185
  23. package/polyfills/__http-lib/to-arraybuffer.js +0 -30
  24. package/polyfills/__readable-stream/buffer-list.js +0 -59
  25. package/polyfills/__readable-stream/duplex.js +0 -45
  26. package/polyfills/__readable-stream/passthrough.js +0 -15
  27. package/polyfills/__readable-stream/readable.js +0 -896
  28. package/polyfills/__readable-stream/transform.js +0 -174
  29. package/polyfills/__readable-stream/writable.js +0 -483
  30. package/polyfills/__zlib-lib/LICENSE +0 -21
  31. package/polyfills/__zlib-lib/adler32.js +0 -31
  32. package/polyfills/__zlib-lib/binding.js +0 -290
  33. package/polyfills/__zlib-lib/crc32.js +0 -40
  34. package/polyfills/__zlib-lib/deflate.js +0 -1862
  35. package/polyfills/__zlib-lib/inffast.js +0 -325
  36. package/polyfills/__zlib-lib/inflate.js +0 -1650
  37. package/polyfills/__zlib-lib/inftrees.js +0 -329
  38. package/polyfills/__zlib-lib/messages.js +0 -11
  39. package/polyfills/__zlib-lib/trees.js +0 -1220
  40. package/polyfills/__zlib-lib/utils.js +0 -73
  41. package/polyfills/__zlib-lib/zstream.js +0 -28
  42. package/polyfills/assert.js +0 -488
  43. package/polyfills/buffer-es6.js +0 -1985
  44. package/polyfills/console.js +0 -13
  45. package/polyfills/constants.js +0 -498
  46. package/polyfills/domain.js +0 -100
  47. package/polyfills/empty.js +0 -1
  48. package/polyfills/events.js +0 -481
  49. package/polyfills/global.js +0 -3
  50. package/polyfills/http.js +0 -167
  51. package/polyfills/inherits.js +0 -25
  52. package/polyfills/os.js +0 -126
  53. package/polyfills/path.js +0 -234
  54. package/polyfills/process-es6.js +0 -223
  55. package/polyfills/punycode.js +0 -475
  56. package/polyfills/querystring.js +0 -147
  57. package/polyfills/setimmediate.js +0 -185
  58. package/polyfills/stream.js +0 -110
  59. package/polyfills/string-decoder.js +0 -220
  60. package/polyfills/timers.js +0 -76
  61. package/polyfills/tty.js +0 -20
  62. package/polyfills/url.js +0 -785
  63. package/polyfills/util.js +0 -716
  64. package/polyfills/vm.js +0 -202
  65. package/polyfills/zlib.js +0 -635
  66. package/rollup.config.mjs +0 -18
  67. package/scripts/build-constants.js +0 -18
  68. package/scripts/build-polyfills.js +0 -52
  69. package/scripts/collect-polyfills.js +0 -17
  70. package/src/index.ts +0 -92
  71. package/src/modules.ts +0 -61
  72. package/src/polyfills.ts +0 -1
  73. package/test/examples/assert.js +0 -12
  74. package/test/examples/constants.js +0 -7
  75. package/test/examples/crypto-broken.js +0 -2
  76. package/test/examples/crypto.js +0 -7
  77. package/test/examples/domain.js +0 -33
  78. package/test/examples/events.js +0 -7
  79. package/test/examples/os.js +0 -7
  80. package/test/examples/path.js +0 -11
  81. package/test/examples/stream.js +0 -31
  82. package/test/examples/string-decoder.js +0 -19
  83. package/test/examples/url-file-url-to-path.js +0 -11
  84. package/test/examples/url-format.js +0 -13
  85. package/test/examples/url-parse.js +0 -14
  86. package/test/examples/zlib.js +0 -24
  87. package/test/index.js +0 -77
  88. package/tsconfig.json +0 -14
@@ -1,185 +0,0 @@
1
- import {overrideMimeType} from './capability';
2
- import {inherits} from 'util';
3
- import {Readable} from 'stream';
4
-
5
- var rStates = {
6
- UNSENT: 0,
7
- OPENED: 1,
8
- HEADERS_RECEIVED: 2,
9
- LOADING: 3,
10
- DONE: 4
11
- }
12
- export {
13
- rStates as readyStates
14
- };
15
- export function IncomingMessage(xhr, response, mode) {
16
- var self = this
17
- Readable.call(self)
18
-
19
- self._mode = mode
20
- self.headers = {}
21
- self.rawHeaders = []
22
- self.trailers = {}
23
- self.rawTrailers = []
24
-
25
- // Fake the 'close' event, but only once 'end' fires
26
- self.on('end', function() {
27
- // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
28
- process.nextTick(function() {
29
- self.emit('close')
30
- })
31
- })
32
- var read;
33
- if (mode === 'fetch') {
34
- self._fetchResponse = response
35
-
36
- self.url = response.url
37
- self.statusCode = response.status
38
- self.statusMessage = response.statusText
39
- // backwards compatible version of for (<item> of <iterable>):
40
- // for (var <item>,_i,_it = <iterable>[Symbol.iterator](); <item> = (_i = _it.next()).value,!_i.done;)
41
- for (var header, _i, _it = response.headers[Symbol.iterator](); header = (_i = _it.next()).value, !_i.done;) {
42
- self.headers[header[0].toLowerCase()] = header[1]
43
- self.rawHeaders.push(header[0], header[1])
44
- }
45
-
46
- // TODO: this doesn't respect backpressure. Once WritableStream is available, this can be fixed
47
- var reader = response.body.getReader()
48
-
49
- read = function () {
50
- reader.read().then(function(result) {
51
- if (self._destroyed)
52
- return
53
- if (result.done) {
54
- self.push(null)
55
- return
56
- }
57
- self.push(new Buffer(result.value))
58
- read()
59
- })
60
- }
61
- read()
62
-
63
- } else {
64
- self._xhr = xhr
65
- self._pos = 0
66
-
67
- self.url = xhr.responseURL
68
- self.statusCode = xhr.status
69
- self.statusMessage = xhr.statusText
70
- var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
71
- headers.forEach(function(header) {
72
- var matches = header.match(/^([^:]+):\s*(.*)/)
73
- if (matches) {
74
- var key = matches[1].toLowerCase()
75
- if (key === 'set-cookie') {
76
- if (self.headers[key] === undefined) {
77
- self.headers[key] = []
78
- }
79
- self.headers[key].push(matches[2])
80
- } else if (self.headers[key] !== undefined) {
81
- self.headers[key] += ', ' + matches[2]
82
- } else {
83
- self.headers[key] = matches[2]
84
- }
85
- self.rawHeaders.push(matches[1], matches[2])
86
- }
87
- })
88
-
89
- self._charset = 'x-user-defined'
90
- if (!overrideMimeType) {
91
- var mimeType = self.rawHeaders['mime-type']
92
- if (mimeType) {
93
- var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
94
- if (charsetMatch) {
95
- self._charset = charsetMatch[1].toLowerCase()
96
- }
97
- }
98
- if (!self._charset)
99
- self._charset = 'utf-8' // best guess
100
- }
101
- }
102
- }
103
-
104
- inherits(IncomingMessage, Readable)
105
-
106
- IncomingMessage.prototype._read = function() {}
107
-
108
- IncomingMessage.prototype._onXHRProgress = function() {
109
- var self = this
110
-
111
- var xhr = self._xhr
112
-
113
- var response = null
114
- switch (self._mode) {
115
- case 'text:vbarray': // For IE9
116
- if (xhr.readyState !== rStates.DONE)
117
- break
118
- try {
119
- // This fails in IE8
120
- response = new global.VBArray(xhr.responseBody).toArray()
121
- } catch (e) {
122
- // pass
123
- }
124
- if (response !== null) {
125
- self.push(new Buffer(response))
126
- break
127
- }
128
- // Falls through in IE8
129
- case 'text':
130
- try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
131
- response = xhr.responseText
132
- } catch (e) {
133
- self._mode = 'text:vbarray'
134
- break
135
- }
136
- if (response.length > self._pos) {
137
- var newData = response.substr(self._pos)
138
- if (self._charset === 'x-user-defined') {
139
- var buffer = new Buffer(newData.length)
140
- for (var i = 0; i < newData.length; i++)
141
- buffer[i] = newData.charCodeAt(i) & 0xff
142
-
143
- self.push(buffer)
144
- } else {
145
- self.push(newData, self._charset)
146
- }
147
- self._pos = response.length
148
- }
149
- break
150
- case 'arraybuffer':
151
- if (xhr.readyState !== rStates.DONE || !xhr.response)
152
- break
153
- response = xhr.response
154
- self.push(new Buffer(new Uint8Array(response)))
155
- break
156
- case 'moz-chunked-arraybuffer': // take whole
157
- response = xhr.response
158
- if (xhr.readyState !== rStates.LOADING || !response)
159
- break
160
- self.push(new Buffer(new Uint8Array(response)))
161
- break
162
- case 'ms-stream':
163
- response = xhr.response
164
- if (xhr.readyState !== rStates.LOADING)
165
- break
166
- var reader = new global.MSStreamReader()
167
- reader.onprogress = function() {
168
- if (reader.result.byteLength > self._pos) {
169
- self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
170
- self._pos = reader.result.byteLength
171
- }
172
- }
173
- reader.onload = function() {
174
- self.push(null)
175
- }
176
- // reader.onerror = ??? // TODO: this
177
- reader.readAsArrayBuffer(response)
178
- break
179
- }
180
-
181
- // The ms-stream case handles end separately in reader.onload()
182
- if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
183
- self.push(null)
184
- }
185
- }
@@ -1,30 +0,0 @@
1
- // from https://github.com/jhiesey/to-arraybuffer/blob/6502d9850e70ba7935a7df4ad86b358fc216f9f0/index.js
2
-
3
- // MIT License
4
- // Copyright (c) 2016 John Hiesey
5
- import {isBuffer} from 'buffer';
6
- export default function (buf) {
7
- // If the buffer is backed by a Uint8Array, a faster version will work
8
- if (buf instanceof Uint8Array) {
9
- // If the buffer isn't a subarray, return the underlying ArrayBuffer
10
- if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
11
- return buf.buffer
12
- } else if (typeof buf.buffer.slice === 'function') {
13
- // Otherwise we need to get a proper copy
14
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
15
- }
16
- }
17
-
18
- if (isBuffer(buf)) {
19
- // This is the slow version that will work with any Buffer
20
- // implementation (even in old browsers)
21
- var arrayCopy = new Uint8Array(buf.length)
22
- var len = buf.length
23
- for (var i = 0; i < len; i++) {
24
- arrayCopy[i] = buf[i]
25
- }
26
- return arrayCopy.buffer
27
- } else {
28
- throw new Error('Argument must be a Buffer')
29
- }
30
- }
@@ -1,59 +0,0 @@
1
- import {Buffer} from 'buffer';
2
-
3
- export default BufferList;
4
-
5
- function BufferList() {
6
- this.head = null;
7
- this.tail = null;
8
- this.length = 0;
9
- }
10
-
11
- BufferList.prototype.push = function (v) {
12
- var entry = { data: v, next: null };
13
- if (this.length > 0) this.tail.next = entry;else this.head = entry;
14
- this.tail = entry;
15
- ++this.length;
16
- };
17
-
18
- BufferList.prototype.unshift = function (v) {
19
- var entry = { data: v, next: this.head };
20
- if (this.length === 0) this.tail = entry;
21
- this.head = entry;
22
- ++this.length;
23
- };
24
-
25
- BufferList.prototype.shift = function () {
26
- if (this.length === 0) return;
27
- var ret = this.head.data;
28
- if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
29
- --this.length;
30
- return ret;
31
- };
32
-
33
- BufferList.prototype.clear = function () {
34
- this.head = this.tail = null;
35
- this.length = 0;
36
- };
37
-
38
- BufferList.prototype.join = function (s) {
39
- if (this.length === 0) return '';
40
- var p = this.head;
41
- var ret = '' + p.data;
42
- while (p = p.next) {
43
- ret += s + p.data;
44
- }return ret;
45
- };
46
-
47
- BufferList.prototype.concat = function (n) {
48
- if (this.length === 0) return Buffer.alloc(0);
49
- if (this.length === 1) return this.head.data;
50
- var ret = Buffer.allocUnsafe(n >>> 0);
51
- var p = this.head;
52
- var i = 0;
53
- while (p) {
54
- p.data.copy(ret, i);
55
- i += p.data.length;
56
- p = p.next;
57
- }
58
- return ret;
59
- };
@@ -1,45 +0,0 @@
1
-
2
- import {inherits} from 'util';
3
- import {nextTick} from 'process';
4
- import {Readable} from '\0polyfill-node._stream_readable';
5
- import {Writable} from '\0polyfill-node._stream_writable';
6
-
7
-
8
- inherits(Duplex, Readable);
9
-
10
- var keys = Object.keys(Writable.prototype);
11
- for (var v = 0; v < keys.length; v++) {
12
- var method = keys[v];
13
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
14
- }
15
- export default Duplex;
16
- export function Duplex(options) {
17
- if (!(this instanceof Duplex)) return new Duplex(options);
18
-
19
- Readable.call(this, options);
20
- Writable.call(this, options);
21
-
22
- if (options && options.readable === false) this.readable = false;
23
-
24
- if (options && options.writable === false) this.writable = false;
25
-
26
- this.allowHalfOpen = true;
27
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
28
-
29
- this.once('end', onend);
30
- }
31
-
32
- // the no-half-open enforcer
33
- function onend() {
34
- // if we allow half-open state, or if the writable side ended,
35
- // then we're ok.
36
- if (this.allowHalfOpen || this._writableState.ended) return;
37
-
38
- // no more data can be written.
39
- // But allow more writes to happen in this tick.
40
- nextTick(onEndNT, this);
41
- }
42
-
43
- function onEndNT(self) {
44
- self.end();
45
- }
@@ -1,15 +0,0 @@
1
-
2
- import {Transform} from '\0polyfill-node._stream_transform';
3
-
4
- import {inherits} from 'util';
5
- inherits(PassThrough, Transform);
6
- export default PassThrough;
7
- export function PassThrough(options) {
8
- if (!(this instanceof PassThrough)) return new PassThrough(options);
9
-
10
- Transform.call(this, options);
11
- }
12
-
13
- PassThrough.prototype._transform = function (chunk, encoding, cb) {
14
- cb(null, chunk);
15
- };