@dxos/esbuild-plugins 0.1.57-main.e87098f → 0.1.57
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/package.json +5 -1
- package/polyfills/Buffer.js +1306 -1362
- package/polyfills/process.js +32 -156
package/polyfills/process.js
CHANGED
|
@@ -1,167 +1,45 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _window = this || self || window;
|
|
6
|
-
_window.global = _window;
|
|
7
|
-
|
|
8
|
-
function defaultSetTimout () {
|
|
9
|
-
throw new Error('setTimeout has not been defined');
|
|
10
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
5
|
+
// !!! Duplicated in @dxos/node-std
|
|
6
|
+
// TODO(dmaretskyi): Unify.
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (typeof global.setTimeout === 'function') {
|
|
19
|
-
cachedSetTimeout = setTimeout;
|
|
20
|
-
}
|
|
21
|
-
if (typeof global.clearTimeout === 'function') {
|
|
22
|
-
cachedClearTimeout = clearTimeout;
|
|
23
|
-
}
|
|
8
|
+
// shim for using process in browser
|
|
9
|
+
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
if (cachedSetTimeout === setTimeout) {
|
|
27
|
-
//normal enviroments in sane situations
|
|
28
|
-
return setTimeout(fun, 0);
|
|
29
|
-
}
|
|
30
|
-
// if setTimeout wasn't available but was latter defined
|
|
31
|
-
if (
|
|
32
|
-
(cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) &&
|
|
33
|
-
setTimeout
|
|
34
|
-
) {
|
|
35
|
-
cachedSetTimeout = setTimeout;
|
|
36
|
-
return setTimeout(fun, 0);
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
40
|
-
return cachedSetTimeout(fun, 0);
|
|
41
|
-
} catch (e) {
|
|
42
|
-
try {
|
|
43
|
-
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
44
|
-
return cachedSetTimeout.call(null, fun, 0);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
// 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
|
|
47
|
-
return cachedSetTimeout.call(this, fun, 0);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
11
|
+
globalThis.global = globalThis;
|
|
51
12
|
|
|
52
|
-
|
|
53
|
-
if (cachedClearTimeout === clearTimeout) {
|
|
54
|
-
//normal enviroments in sane situations
|
|
55
|
-
return clearTimeout(marker);
|
|
56
|
-
}
|
|
57
|
-
// if clearTimeout wasn't available but was latter defined
|
|
58
|
-
if (
|
|
59
|
-
(cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) &&
|
|
60
|
-
clearTimeout
|
|
61
|
-
) {
|
|
62
|
-
cachedClearTimeout = clearTimeout;
|
|
63
|
-
return clearTimeout(marker);
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
67
|
-
return cachedClearTimeout(marker);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
try {
|
|
70
|
-
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
71
|
-
return cachedClearTimeout.call(null, marker);
|
|
72
|
-
} catch (e) {
|
|
73
|
-
// 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.
|
|
74
|
-
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
75
|
-
return cachedClearTimeout.call(this, marker);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var queue = [];
|
|
81
|
-
var draining = false;
|
|
82
|
-
var currentQueue;
|
|
83
|
-
var queueIndex = -1;
|
|
13
|
+
/* eslint-disable */
|
|
84
14
|
|
|
85
|
-
function
|
|
86
|
-
if
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
draining = false;
|
|
90
|
-
if (currentQueue.length) {
|
|
91
|
-
queue = currentQueue.concat(queue);
|
|
15
|
+
function nextTick (fun, ...args) {
|
|
16
|
+
if(args.length > 0) {
|
|
17
|
+
queueMicrotask(() => fun(...args));
|
|
92
18
|
} else {
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
if (queue.length) {
|
|
96
|
-
drainQueue();
|
|
19
|
+
queueMicrotask(fun);
|
|
97
20
|
}
|
|
98
21
|
}
|
|
99
22
|
|
|
100
|
-
function drainQueue () {
|
|
101
|
-
if (draining) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
var timeout = runTimeout(cleanUpNextTick);
|
|
105
|
-
draining = true;
|
|
106
23
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
queueIndex = -1;
|
|
117
|
-
len = queue.length;
|
|
118
|
-
}
|
|
119
|
-
currentQueue = null;
|
|
120
|
-
draining = false;
|
|
121
|
-
runClearTimeout(timeout);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function nextTick (fun) {
|
|
125
|
-
var args = new Array(arguments.length - 1);
|
|
126
|
-
if (arguments.length > 1) {
|
|
127
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
128
|
-
args[i - 1] = arguments[i];
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
queue.push(new Item(fun, args));
|
|
132
|
-
if (queue.length === 1 && !draining) {
|
|
133
|
-
runTimeout(drainQueue);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// v8 likes predictible objects
|
|
138
|
-
function Item (fun, array) {
|
|
139
|
-
this.fun = fun;
|
|
140
|
-
this.array = array;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
Item.prototype.run = function () {
|
|
144
|
-
this.fun.apply(null, this.array);
|
|
145
|
-
};
|
|
146
|
-
var title = 'browser';
|
|
147
|
-
var platform = 'browser';
|
|
148
|
-
var browser = true;
|
|
149
|
-
var env = {};
|
|
150
|
-
var argv = [];
|
|
151
|
-
var version = ''; // empty string to avoid regexp issues
|
|
152
|
-
var versions = {};
|
|
153
|
-
var release = {};
|
|
154
|
-
var config = {};
|
|
24
|
+
const title = 'browser';
|
|
25
|
+
const platform = 'browser';
|
|
26
|
+
const browser = true;
|
|
27
|
+
const env = {};
|
|
28
|
+
const argv = [];
|
|
29
|
+
const version = ''; // empty string to avoid regexp issues
|
|
30
|
+
const versions = {};
|
|
31
|
+
const release = {};
|
|
32
|
+
const config = {};
|
|
155
33
|
|
|
156
34
|
function noop () {}
|
|
157
35
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
36
|
+
const on = noop;
|
|
37
|
+
const addListener = noop;
|
|
38
|
+
const once = noop;
|
|
39
|
+
const off = noop;
|
|
40
|
+
const removeListener = noop;
|
|
41
|
+
const removeAllListeners = noop;
|
|
42
|
+
const emit = noop;
|
|
165
43
|
|
|
166
44
|
function binding (name) {
|
|
167
45
|
throw new Error('process.binding is not supported');
|
|
@@ -180,7 +58,7 @@ function umask () {
|
|
|
180
58
|
}
|
|
181
59
|
|
|
182
60
|
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
|
183
|
-
var performance =
|
|
61
|
+
var performance = globalThis.performance || {};
|
|
184
62
|
var performanceNow =
|
|
185
63
|
performance.now ||
|
|
186
64
|
performance.mozNow ||
|
|
@@ -216,9 +94,7 @@ function uptime () {
|
|
|
216
94
|
return dif / 1000;
|
|
217
95
|
}
|
|
218
96
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
export var process = {
|
|
97
|
+
export var process = (globalThis.process ??= {
|
|
222
98
|
nextTick: nextTick,
|
|
223
99
|
title: title,
|
|
224
100
|
browser: browser,
|
|
@@ -242,7 +118,7 @@ export var process = {
|
|
|
242
118
|
release: release,
|
|
243
119
|
config: config,
|
|
244
120
|
uptime: uptime,
|
|
245
|
-
};
|
|
121
|
+
});
|
|
246
122
|
|
|
247
123
|
// replace process.env.VAR with define
|
|
248
124
|
|