@dxos/esbuild-plugins 2.28.3-dev.08b5c548 → 2.28.3-dev.830652d0
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.
- package/.eslintrc.js +8 -0
- package/.rush/temp/package-deps_build.json +7 -6
- package/.rush/temp/package-deps_build:test.json +7 -6
- package/.rush/temp/package-deps_prerelease.json +7 -6
- package/.rush/temp/shrinkwrap-deps.json +183 -2
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/node-globals-polyfill-plugin.js +1 -1
- package/dist/src/node-globals-polyfill-plugin.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
- package/polyfills/Buffer.js +1951 -1950
- package/polyfills/process.js +147 -137
- package/src/index.ts +2 -3
- package/src/node-globals-polyfill-plugin.ts +1 -1
package/polyfills/process.js
CHANGED
|
@@ -2,207 +2,217 @@
|
|
|
2
2
|
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
|
5
|
-
window.global = window
|
|
5
|
+
window.global = window;
|
|
6
6
|
|
|
7
|
-
function defaultSetTimout() {
|
|
8
|
-
throw new Error('setTimeout has not been defined')
|
|
7
|
+
function defaultSetTimout () {
|
|
8
|
+
throw new Error('setTimeout has not been defined');
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
function defaultClearTimeout () {
|
|
12
|
+
throw new Error('clearTimeout has not been defined');
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
var
|
|
14
|
+
|
|
15
|
+
var cachedSetTimeout = defaultSetTimout;
|
|
16
|
+
var cachedClearTimeout = defaultClearTimeout;
|
|
15
17
|
if (typeof global.setTimeout === 'function') {
|
|
16
|
-
cachedSetTimeout = setTimeout
|
|
18
|
+
cachedSetTimeout = setTimeout;
|
|
17
19
|
}
|
|
18
20
|
if (typeof global.clearTimeout === 'function') {
|
|
19
|
-
cachedClearTimeout = clearTimeout
|
|
21
|
+
cachedClearTimeout = clearTimeout;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
function runTimeout(fun) {
|
|
24
|
+
function runTimeout (fun) {
|
|
23
25
|
if (cachedSetTimeout === setTimeout) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
//normal enviroments in sane situations
|
|
27
|
+
return setTimeout(fun, 0);
|
|
26
28
|
}
|
|
27
29
|
// if setTimeout wasn't available but was latter defined
|
|
28
30
|
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
(cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) &&
|
|
32
|
+
setTimeout
|
|
31
33
|
) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
cachedSetTimeout = setTimeout;
|
|
35
|
+
return setTimeout(fun, 0);
|
|
34
36
|
}
|
|
35
37
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
39
|
+
return cachedSetTimeout(fun, 0);
|
|
38
40
|
} catch (e) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
try {
|
|
42
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
43
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
// 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
|
|
46
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
47
|
+
}
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
|
|
51
|
+
function runClearTimeout (marker) {
|
|
49
52
|
if (cachedClearTimeout === clearTimeout) {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
//normal enviroments in sane situations
|
|
54
|
+
return clearTimeout(marker);
|
|
52
55
|
}
|
|
53
56
|
// if clearTimeout wasn't available but was latter defined
|
|
54
57
|
if (
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
(cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) &&
|
|
59
|
+
clearTimeout
|
|
57
60
|
) {
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
cachedClearTimeout = clearTimeout;
|
|
62
|
+
return clearTimeout(marker);
|
|
60
63
|
}
|
|
61
64
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
66
|
+
return cachedClearTimeout(marker);
|
|
64
67
|
} catch (e) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
try {
|
|
69
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
70
|
+
return cachedClearTimeout.call(null, marker);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
// 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.
|
|
73
|
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
74
|
+
return cachedClearTimeout.call(this, marker);
|
|
75
|
+
}
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
var queue = []
|
|
76
|
-
var draining = false
|
|
77
|
-
var currentQueue
|
|
78
|
-
var queueIndex = -1
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
var queue = [];
|
|
80
|
+
var draining = false;
|
|
81
|
+
var currentQueue;
|
|
82
|
+
var queueIndex = -1;
|
|
83
|
+
|
|
84
|
+
function cleanUpNextTick () {
|
|
81
85
|
if (!draining || !currentQueue) {
|
|
82
|
-
|
|
86
|
+
return;
|
|
83
87
|
}
|
|
84
|
-
draining = false
|
|
88
|
+
draining = false;
|
|
85
89
|
if (currentQueue.length) {
|
|
86
|
-
|
|
90
|
+
queue = currentQueue.concat(queue);
|
|
87
91
|
} else {
|
|
88
|
-
|
|
92
|
+
queueIndex = -1;
|
|
89
93
|
}
|
|
90
94
|
if (queue.length) {
|
|
91
|
-
|
|
95
|
+
drainQueue();
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
function drainQueue() {
|
|
99
|
+
function drainQueue () {
|
|
96
100
|
if (draining) {
|
|
97
|
-
|
|
101
|
+
return;
|
|
98
102
|
}
|
|
99
|
-
var timeout = runTimeout(cleanUpNextTick)
|
|
100
|
-
draining = true
|
|
103
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
104
|
+
draining = true;
|
|
101
105
|
|
|
102
|
-
var len = queue.length
|
|
106
|
+
var len = queue.length;
|
|
103
107
|
while (len) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
108
|
+
currentQueue = queue;
|
|
109
|
+
queue = [];
|
|
110
|
+
while (++queueIndex < len) {
|
|
111
|
+
if (currentQueue) {
|
|
112
|
+
currentQueue[queueIndex].run();
|
|
110
113
|
}
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
}
|
|
115
|
+
queueIndex = -1;
|
|
116
|
+
len = queue.length;
|
|
113
117
|
}
|
|
114
|
-
currentQueue = null
|
|
115
|
-
draining = false
|
|
116
|
-
runClearTimeout(timeout)
|
|
118
|
+
currentQueue = null;
|
|
119
|
+
draining = false;
|
|
120
|
+
runClearTimeout(timeout);
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
|
|
123
|
+
function nextTick (fun) {
|
|
124
|
+
var args = new Array(arguments.length - 1);
|
|
120
125
|
if (arguments.length > 1) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
127
|
+
args[i - 1] = arguments[i];
|
|
128
|
+
}
|
|
124
129
|
}
|
|
125
|
-
queue.push(new Item(fun, args))
|
|
130
|
+
queue.push(new Item(fun, args));
|
|
126
131
|
if (queue.length === 1 && !draining) {
|
|
127
|
-
|
|
132
|
+
runTimeout(drainQueue);
|
|
128
133
|
}
|
|
129
134
|
}
|
|
135
|
+
|
|
130
136
|
// v8 likes predictible objects
|
|
131
|
-
function Item(fun, array) {
|
|
132
|
-
this.fun = fun
|
|
133
|
-
this.array = array
|
|
137
|
+
function Item (fun, array) {
|
|
138
|
+
this.fun = fun;
|
|
139
|
+
this.array = array;
|
|
134
140
|
}
|
|
135
|
-
Item.prototype.run = function() {
|
|
136
|
-
this.fun.apply(null, this.array)
|
|
137
|
-
}
|
|
138
|
-
var title = 'browser'
|
|
139
|
-
var platform = 'browser'
|
|
140
|
-
var browser = true
|
|
141
|
-
var env = {}
|
|
142
|
-
var argv = []
|
|
143
|
-
var version = '' // empty string to avoid regexp issues
|
|
144
|
-
var versions = {}
|
|
145
|
-
var release = {}
|
|
146
|
-
var config = {}
|
|
147
141
|
|
|
148
|
-
function
|
|
142
|
+
Item.prototype.run = function () {
|
|
143
|
+
this.fun.apply(null, this.array);
|
|
144
|
+
};
|
|
145
|
+
var title = 'browser';
|
|
146
|
+
var platform = 'browser';
|
|
147
|
+
var browser = true;
|
|
148
|
+
var env = {};
|
|
149
|
+
var argv = [];
|
|
150
|
+
var version = ''; // empty string to avoid regexp issues
|
|
151
|
+
var versions = {};
|
|
152
|
+
var release = {};
|
|
153
|
+
var config = {};
|
|
154
|
+
|
|
155
|
+
function noop () {}
|
|
149
156
|
|
|
150
|
-
var on = noop
|
|
151
|
-
var addListener = noop
|
|
152
|
-
var once = noop
|
|
153
|
-
var off = noop
|
|
154
|
-
var removeListener = noop
|
|
155
|
-
var removeAllListeners = noop
|
|
156
|
-
var emit = noop
|
|
157
|
+
var on = noop;
|
|
158
|
+
var addListener = noop;
|
|
159
|
+
var once = noop;
|
|
160
|
+
var off = noop;
|
|
161
|
+
var removeListener = noop;
|
|
162
|
+
var removeAllListeners = noop;
|
|
163
|
+
var emit = noop;
|
|
157
164
|
|
|
158
|
-
function binding(name) {
|
|
159
|
-
throw new Error('process.binding is not supported')
|
|
165
|
+
function binding (name) {
|
|
166
|
+
throw new Error('process.binding is not supported');
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
function cwd() {
|
|
163
|
-
return '/'
|
|
169
|
+
function cwd () {
|
|
170
|
+
return '/';
|
|
164
171
|
}
|
|
165
|
-
|
|
166
|
-
|
|
172
|
+
|
|
173
|
+
function chdir (dir) {
|
|
174
|
+
throw new Error('process.chdir is not supported');
|
|
167
175
|
}
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
|
|
177
|
+
function umask () {
|
|
178
|
+
return 0;
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
|
173
|
-
var performance = global.performance || {}
|
|
182
|
+
var performance = global.performance || {};
|
|
174
183
|
var performanceNow =
|
|
175
184
|
performance.now ||
|
|
176
185
|
performance.mozNow ||
|
|
177
186
|
performance.msNow ||
|
|
178
187
|
performance.oNow ||
|
|
179
188
|
performance.webkitNow ||
|
|
180
|
-
function() {
|
|
181
|
-
|
|
182
|
-
}
|
|
189
|
+
function () {
|
|
190
|
+
return new Date().getTime();
|
|
191
|
+
};
|
|
183
192
|
|
|
184
193
|
// generate timestamp or delta
|
|
185
194
|
// see http://nodejs.org/api/process.html#process_process_hrtime
|
|
186
|
-
function hrtime(previousTimestamp) {
|
|
187
|
-
var clocktime = performanceNow.call(performance) * 1e-3
|
|
188
|
-
var seconds = Math.floor(clocktime)
|
|
189
|
-
var nanoseconds = Math.floor((clocktime % 1) * 1e9)
|
|
195
|
+
function hrtime (previousTimestamp) {
|
|
196
|
+
var clocktime = performanceNow.call(performance) * 1e-3;
|
|
197
|
+
var seconds = Math.floor(clocktime);
|
|
198
|
+
var nanoseconds = Math.floor((clocktime % 1) * 1e9);
|
|
190
199
|
if (previousTimestamp) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
200
|
+
seconds = seconds - previousTimestamp[0];
|
|
201
|
+
nanoseconds = nanoseconds - previousTimestamp[1];
|
|
202
|
+
if (nanoseconds < 0) {
|
|
203
|
+
seconds--;
|
|
204
|
+
nanoseconds += 1e9;
|
|
205
|
+
}
|
|
197
206
|
}
|
|
198
|
-
return [seconds, nanoseconds]
|
|
207
|
+
return [seconds, nanoseconds];
|
|
199
208
|
}
|
|
200
209
|
|
|
201
|
-
var startTime = new Date()
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
var
|
|
205
|
-
|
|
210
|
+
var startTime = new Date();
|
|
211
|
+
|
|
212
|
+
function uptime () {
|
|
213
|
+
var currentTime = new Date();
|
|
214
|
+
var dif = currentTime - startTime;
|
|
215
|
+
return dif / 1000;
|
|
206
216
|
}
|
|
207
217
|
|
|
208
218
|
window.setImmediate = nextTick;
|
|
@@ -231,20 +241,20 @@ export var process = {
|
|
|
231
241
|
release: release,
|
|
232
242
|
config: config,
|
|
233
243
|
uptime: uptime,
|
|
234
|
-
}
|
|
244
|
+
};
|
|
235
245
|
|
|
236
246
|
// replace process.env.VAR with define
|
|
237
247
|
|
|
238
|
-
const defines = {}
|
|
248
|
+
const defines = {};
|
|
239
249
|
Object.keys(defines).forEach((key) => {
|
|
240
|
-
const segs = key.split('.')
|
|
241
|
-
let target = process
|
|
250
|
+
const segs = key.split('.');
|
|
251
|
+
let target = process;
|
|
242
252
|
for (let i = 0; i < segs.length; i++) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
253
|
+
const seg = segs[i];
|
|
254
|
+
if (i === segs.length - 1) {
|
|
255
|
+
target[seg] = defines[key];
|
|
256
|
+
} else {
|
|
257
|
+
target = target[seg] || (target[seg] = {});
|
|
258
|
+
}
|
|
249
259
|
}
|
|
250
|
-
})
|
|
260
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './node-globals-polyfill-plugin';
|
|
6
|
-
export * from './node-modules-plugin';
|
|
7
5
|
export * from './fix-graceful-fs-plugin';
|
|
8
|
-
export * from './node-globals-polyfill-plugin';
|
|
9
6
|
export * from './fix-memdown-plugin';
|
|
7
|
+
export * from './node-globals-polyfill-plugin';
|
|
8
|
+
export * from './node-modules-plugin';
|
|
@@ -13,7 +13,7 @@ export function NodeGlobalsPolyfillPlugin (): Plugin {
|
|
|
13
13
|
name: 'node-globals-polyfill',
|
|
14
14
|
setup ({ initialOptions }) {
|
|
15
15
|
const polyfills = [
|
|
16
|
-
// TODO
|
|
16
|
+
// TODO: Use `buffer` module from NPM.
|
|
17
17
|
resolve(__dirname, '../../polyfills/process.js'),
|
|
18
18
|
resolve(__dirname, '../../polyfills/Buffer.js')
|
|
19
19
|
];
|