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
package/polyfills/os.js DELETED
@@ -1,126 +0,0 @@
1
- /*
2
- The MIT License (MIT)
3
-
4
- Copyright (c) 2016 CoderPuppy
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
-
24
- */
25
- var _endianness;
26
- export function endianness() {
27
- if (typeof _endianness === 'undefined') {
28
- var a = new ArrayBuffer(2);
29
- var b = new Uint8Array(a);
30
- var c = new Uint16Array(a);
31
- b[0] = 1;
32
- b[1] = 2;
33
- if (c[0] === 258) {
34
- _endianness = 'BE';
35
- } else if (c[0] === 513){
36
- _endianness = 'LE';
37
- } else {
38
- throw new Error('unable to figure out endianess');
39
- }
40
- }
41
- return _endianness;
42
- }
43
-
44
- export function hostname() {
45
- if (typeof global.location !== 'undefined') {
46
- return global.location.hostname
47
- } else return '';
48
- }
49
-
50
- export function loadavg() {
51
- return [];
52
- }
53
-
54
- export function uptime() {
55
- return 0;
56
- }
57
-
58
- export function freemem() {
59
- return Number.MAX_VALUE;
60
- }
61
-
62
- export function totalmem() {
63
- return Number.MAX_VALUE;
64
- }
65
-
66
- export function cpus() {
67
- return [];
68
- }
69
-
70
- export function type() {
71
- return 'Browser';
72
- }
73
-
74
- export function release () {
75
- if (typeof global.navigator !== 'undefined') {
76
- return global.navigator.appVersion;
77
- }
78
- return '';
79
- }
80
-
81
- export function networkInterfaces () {
82
- return {};
83
- }
84
-
85
- export function getNetworkInterfaces () {
86
- return {};
87
- }
88
-
89
- export function arch() {
90
- return 'javascript';
91
- }
92
-
93
- export function platform() {
94
- return 'browser';
95
- }
96
-
97
- export function tmpDir() {
98
- return '/tmp';
99
- }
100
- export var tmpdir = tmpDir;
101
-
102
- export var EOL = '\n';
103
-
104
- export function homedir(){
105
- return '$HOME'
106
- }
107
-
108
- export default {
109
- homedir: homedir,
110
- EOL: EOL,
111
- arch: arch,
112
- platform: platform,
113
- tmpdir: tmpdir,
114
- tmpDir: tmpDir,
115
- networkInterfaces:networkInterfaces,
116
- getNetworkInterfaces: getNetworkInterfaces,
117
- release: release,
118
- type: type,
119
- cpus: cpus,
120
- totalmem: totalmem,
121
- freemem: freemem,
122
- uptime: uptime,
123
- loadavg: loadavg,
124
- hostname: hostname,
125
- endianness: endianness,
126
- }
package/polyfills/path.js DELETED
@@ -1,234 +0,0 @@
1
- // Copyright Joyent, Inc. and other Node contributors.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a
4
- // copy of this software and associated documentation files (the
5
- // "Software"), to deal in the Software without restriction, including
6
- // without limitation the rights to use, copy, modify, merge, publish,
7
- // distribute, sublicense, and/or sell copies of the Software, and to permit
8
- // persons to whom the Software is furnished to do so, subject to the
9
- // following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included
12
- // in all copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- // resolves . and .. elements in a path array with directory names there
23
- // must be no slashes, empty elements, or device names (c:\) in the array
24
- // (so also no leading and trailing slashes - it does not distinguish
25
- // relative and absolute paths)
26
- function normalizeArray(parts, allowAboveRoot) {
27
- // if the path tries to go above the root, `up` ends up > 0
28
- var up = 0;
29
- for (var i = parts.length - 1; i >= 0; i--) {
30
- var last = parts[i];
31
- if (last === '.') {
32
- parts.splice(i, 1);
33
- } else if (last === '..') {
34
- parts.splice(i, 1);
35
- up++;
36
- } else if (up) {
37
- parts.splice(i, 1);
38
- up--;
39
- }
40
- }
41
-
42
- // if the path is allowed to go above the root, restore leading ..s
43
- if (allowAboveRoot) {
44
- for (; up--; up) {
45
- parts.unshift('..');
46
- }
47
- }
48
-
49
- return parts;
50
- }
51
-
52
- // Split a filename into [root, dir, basename, ext], unix version
53
- // 'root' is just a slash, or nothing.
54
- var splitPathRe =
55
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
56
- var splitPath = function(filename) {
57
- return splitPathRe.exec(filename).slice(1);
58
- };
59
-
60
- // path.resolve([from ...], to)
61
- // posix version
62
- export function resolve() {
63
- var resolvedPath = '',
64
- resolvedAbsolute = false;
65
-
66
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
67
- var path = (i >= 0) ? arguments[i] : '/';
68
-
69
- // Skip empty and invalid entries
70
- if (typeof path !== 'string') {
71
- throw new TypeError('Arguments to path.resolve must be strings');
72
- } else if (!path) {
73
- continue;
74
- }
75
-
76
- resolvedPath = path + '/' + resolvedPath;
77
- resolvedAbsolute = path.charAt(0) === '/';
78
- }
79
-
80
- // At this point the path should be resolved to a full absolute path, but
81
- // handle relative paths to be safe (might happen when process.cwd() fails)
82
-
83
- // Normalize the path
84
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
85
- return !!p;
86
- }), !resolvedAbsolute).join('/');
87
-
88
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
89
- };
90
-
91
- // path.normalize(path)
92
- // posix version
93
- export function normalize(path) {
94
- var isPathAbsolute = isAbsolute(path),
95
- trailingSlash = substr(path, -1) === '/';
96
-
97
- // Normalize the path
98
- path = normalizeArray(filter(path.split('/'), function(p) {
99
- return !!p;
100
- }), !isPathAbsolute).join('/');
101
-
102
- if (!path && !isPathAbsolute) {
103
- path = '.';
104
- }
105
- if (path && trailingSlash) {
106
- path += '/';
107
- }
108
-
109
- return (isPathAbsolute ? '/' : '') + path;
110
- };
111
-
112
- // posix version
113
- export function isAbsolute(path) {
114
- return path.charAt(0) === '/';
115
- }
116
-
117
- // posix version
118
- export function join() {
119
- var paths = Array.prototype.slice.call(arguments, 0);
120
- return normalize(filter(paths, function(p, index) {
121
- if (typeof p !== 'string') {
122
- throw new TypeError('Arguments to path.join must be strings');
123
- }
124
- return p;
125
- }).join('/'));
126
- }
127
-
128
-
129
- // path.relative(from, to)
130
- // posix version
131
- export function relative(from, to) {
132
- from = resolve(from).substr(1);
133
- to = resolve(to).substr(1);
134
-
135
- function trim(arr) {
136
- var start = 0;
137
- for (; start < arr.length; start++) {
138
- if (arr[start] !== '') break;
139
- }
140
-
141
- var end = arr.length - 1;
142
- for (; end >= 0; end--) {
143
- if (arr[end] !== '') break;
144
- }
145
-
146
- if (start > end) return [];
147
- return arr.slice(start, end - start + 1);
148
- }
149
-
150
- var fromParts = trim(from.split('/'));
151
- var toParts = trim(to.split('/'));
152
-
153
- var length = Math.min(fromParts.length, toParts.length);
154
- var samePartsLength = length;
155
- for (var i = 0; i < length; i++) {
156
- if (fromParts[i] !== toParts[i]) {
157
- samePartsLength = i;
158
- break;
159
- }
160
- }
161
-
162
- var outputParts = [];
163
- for (var i = samePartsLength; i < fromParts.length; i++) {
164
- outputParts.push('..');
165
- }
166
-
167
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
168
-
169
- return outputParts.join('/');
170
- }
171
-
172
- export var sep = '/';
173
- export var delimiter = ':';
174
-
175
- export function dirname(path) {
176
- var result = splitPath(path),
177
- root = result[0],
178
- dir = result[1];
179
-
180
- if (!root && !dir) {
181
- // No dirname whatsoever
182
- return '.';
183
- }
184
-
185
- if (dir) {
186
- // It has a dirname, strip trailing slash
187
- dir = dir.substr(0, dir.length - 1);
188
- }
189
-
190
- return root + dir;
191
- }
192
-
193
- export function basename(path, ext) {
194
- var f = splitPath(path)[2];
195
- // TODO: make this comparison case-insensitive on windows?
196
- if (ext && f.substr(-1 * ext.length) === ext) {
197
- f = f.substr(0, f.length - ext.length);
198
- }
199
- return f;
200
- }
201
-
202
-
203
- export function extname(path) {
204
- return splitPath(path)[3];
205
- }
206
- export default {
207
- extname: extname,
208
- basename: basename,
209
- dirname: dirname,
210
- sep: sep,
211
- delimiter: delimiter,
212
- relative: relative,
213
- join: join,
214
- isAbsolute: isAbsolute,
215
- normalize: normalize,
216
- resolve: resolve
217
- };
218
- function filter (xs, f) {
219
- if (xs.filter) return xs.filter(f);
220
- var res = [];
221
- for (var i = 0; i < xs.length; i++) {
222
- if (f(xs[i], i, xs)) res.push(xs[i]);
223
- }
224
- return res;
225
- }
226
-
227
- // String.prototype.substr - negative index don't work in IE8
228
- var substr = 'ab'.substr(-1) === 'b' ?
229
- function (str, start, len) { return str.substr(start, len) } :
230
- function (str, start, len) {
231
- if (start < 0) start = str.length + start;
232
- return str.substr(start, len);
233
- }
234
- ;
@@ -1,223 +0,0 @@
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 ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
26
- cachedSetTimeout = setTimeout;
27
- return setTimeout(fun, 0);
28
- }
29
- try {
30
- // when when somebody has screwed with setTimeout but no I.E. maddness
31
- return cachedSetTimeout(fun, 0);
32
- } catch(e){
33
- try {
34
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
35
- return cachedSetTimeout.call(null, fun, 0);
36
- } catch(e){
37
- // 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
38
- return cachedSetTimeout.call(this, fun, 0);
39
- }
40
- }
41
-
42
-
43
- }
44
- function runClearTimeout(marker) {
45
- if (cachedClearTimeout === clearTimeout) {
46
- //normal enviroments in sane situations
47
- return clearTimeout(marker);
48
- }
49
- // if clearTimeout wasn't available but was latter defined
50
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
51
- cachedClearTimeout = clearTimeout;
52
- return clearTimeout(marker);
53
- }
54
- try {
55
- // when when somebody has screwed with setTimeout but no I.E. maddness
56
- return cachedClearTimeout(marker);
57
- } catch (e){
58
- try {
59
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
60
- return cachedClearTimeout.call(null, marker);
61
- } catch (e){
62
- // 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.
63
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
64
- return cachedClearTimeout.call(this, marker);
65
- }
66
- }
67
-
68
-
69
-
70
- }
71
- var queue = [];
72
- var draining = false;
73
- var currentQueue;
74
- var queueIndex = -1;
75
-
76
- function cleanUpNextTick() {
77
- if (!draining || !currentQueue) {
78
- return;
79
- }
80
- draining = false;
81
- if (currentQueue.length) {
82
- queue = currentQueue.concat(queue);
83
- } else {
84
- queueIndex = -1;
85
- }
86
- if (queue.length) {
87
- drainQueue();
88
- }
89
- }
90
-
91
- function drainQueue() {
92
- if (draining) {
93
- return;
94
- }
95
- var timeout = runTimeout(cleanUpNextTick);
96
- draining = true;
97
-
98
- var len = queue.length;
99
- while(len) {
100
- currentQueue = queue;
101
- queue = [];
102
- while (++queueIndex < len) {
103
- if (currentQueue) {
104
- currentQueue[queueIndex].run();
105
- }
106
- }
107
- queueIndex = -1;
108
- len = queue.length;
109
- }
110
- currentQueue = null;
111
- draining = false;
112
- runClearTimeout(timeout);
113
- }
114
- function nextTick(fun) {
115
- var args = new Array(arguments.length - 1);
116
- if (arguments.length > 1) {
117
- for (var i = 1; i < arguments.length; i++) {
118
- args[i - 1] = arguments[i];
119
- }
120
- }
121
- queue.push(new Item(fun, args));
122
- if (queue.length === 1 && !draining) {
123
- runTimeout(drainQueue);
124
- }
125
- }
126
- // v8 likes predictible objects
127
- function Item(fun, array) {
128
- this.fun = fun;
129
- this.array = array;
130
- }
131
- Item.prototype.run = function () {
132
- this.fun.apply(null, this.array);
133
- };
134
- var title = 'browser';
135
- var platform = 'browser';
136
- var browser = true;
137
- var env = {};
138
- var argv = [];
139
- var version = ''; // empty string to avoid regexp issues
140
- var versions = {};
141
- var release = {};
142
- var config = {};
143
-
144
- function noop() {}
145
-
146
- var on = noop;
147
- var addListener = noop;
148
- var once = noop;
149
- var off = noop;
150
- var removeListener = noop;
151
- var removeAllListeners = noop;
152
- var emit = noop;
153
-
154
- function binding(name) {
155
- throw new Error('process.binding is not supported');
156
- }
157
-
158
- function cwd () { return '/' }
159
- function chdir (dir) {
160
- throw new Error('process.chdir is not supported');
161
- }function umask() { return 0; }
162
-
163
- // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
164
- var performance = global.performance || {};
165
- var performanceNow =
166
- performance.now ||
167
- performance.mozNow ||
168
- performance.msNow ||
169
- performance.oNow ||
170
- performance.webkitNow ||
171
- function(){ return (new Date()).getTime() };
172
-
173
- // generate timestamp or delta
174
- // see http://nodejs.org/api/process.html#process_process_hrtime
175
- function hrtime(previousTimestamp){
176
- var clocktime = performanceNow.call(performance)*1e-3;
177
- var seconds = Math.floor(clocktime);
178
- var nanoseconds = Math.floor((clocktime%1)*1e9);
179
- if (previousTimestamp) {
180
- seconds = seconds - previousTimestamp[0];
181
- nanoseconds = nanoseconds - previousTimestamp[1];
182
- if (nanoseconds<0) {
183
- seconds--;
184
- nanoseconds += 1e9;
185
- }
186
- }
187
- return [seconds,nanoseconds]
188
- }
189
-
190
- var startTime = new Date();
191
- function uptime() {
192
- var currentTime = new Date();
193
- var dif = currentTime - startTime;
194
- return dif / 1000;
195
- }
196
-
197
- var browser$1 = {
198
- nextTick: nextTick,
199
- title: title,
200
- browser: browser,
201
- env: env,
202
- argv: argv,
203
- version: version,
204
- versions: versions,
205
- on: on,
206
- addListener: addListener,
207
- once: once,
208
- off: off,
209
- removeListener: removeListener,
210
- removeAllListeners: removeAllListeners,
211
- emit: emit,
212
- binding: binding,
213
- cwd: cwd,
214
- chdir: chdir,
215
- umask: umask,
216
- hrtime: hrtime,
217
- platform: platform,
218
- release: release,
219
- config: config,
220
- uptime: uptime
221
- };
222
-
223
- export { addListener, argv, binding, browser, chdir, config, cwd, browser$1 as default, emit, env, hrtime, nextTick, off, on, once, platform, release, removeAllListeners, removeListener, title, umask, uptime, version, versions };