@loaders.gl/polyfills 4.0.0-alpha.22 → 4.0.0-alpha.24
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 +2 -2
- package/dist/bundle.js +0 -5
- package/dist/index.js +0 -93
- package/dist/lib/encoding-indexes.js +0 -35
- package/dist/lib/encoding.js +0 -2779
- package/dist/libs/encoding-indexes-asian.js +0 -14
- package/dist/node/buffer/btoa.node.js +0 -14
- package/dist/node/buffer/to-array-buffer.node.js +0 -12
- package/dist/node/fetch/fetch.node.js +0 -146
- package/dist/node/fetch/headers.node.js +0 -106
- package/dist/node/fetch/response.node.js +0 -76
- package/dist/node/fetch/utils/decode-data-uri.node.js +0 -65
- package/dist/node/fetch/utils/stream-utils.node.js +0 -73
- package/dist/node/file/blob-stream-controller.js +0 -63
- package/dist/node/file/blob-stream.js +0 -37
- package/dist/node/file/blob.js +0 -160
- package/dist/node/file/file-reader.js +0 -35
- package/dist/node/file/file.js +0 -37
- package/dist/node/file/install-file-polyfills.js +0 -27
- package/dist/node/file/readable-stream.js +0 -11
- package/dist/node/images/encode-image.node.js +0 -41
- package/dist/node/images/parse-image.node.js +0 -41
- package/dist/promise/all-settled.js +0 -24
- package/dist/utils/assert.js +0 -9
- package/dist/utils/globals.js +0 -36
package/dist/node/file/blob.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlobPolyfill = void 0;
|
|
4
|
-
// Forked from @gozala's web-blob under MIT license https://github.com/Gozala/web-blob
|
|
5
|
-
const blob_stream_1 = require("./blob-stream");
|
|
6
|
-
/**
|
|
7
|
-
* Forked from @gozala's web-blob under MIT license
|
|
8
|
-
* @see https://github.com/Gozala/web-blob
|
|
9
|
-
*/
|
|
10
|
-
class BlobPolyfill {
|
|
11
|
-
/**
|
|
12
|
-
* @param [init]
|
|
13
|
-
* @param [options]
|
|
14
|
-
*/
|
|
15
|
-
constructor(init = [], options = {}) {
|
|
16
|
-
this.parts = [];
|
|
17
|
-
this.size = 0;
|
|
18
|
-
for (const part of init) {
|
|
19
|
-
if (typeof part === 'string') {
|
|
20
|
-
const bytes = new TextEncoder().encode(part);
|
|
21
|
-
this.parts.push(bytes);
|
|
22
|
-
this.size += bytes.byteLength;
|
|
23
|
-
}
|
|
24
|
-
else if (part instanceof BlobPolyfill) {
|
|
25
|
-
this.size += part.size;
|
|
26
|
-
// @ts-ignore - `parts` is marked private so TS will complain about
|
|
27
|
-
// accessing it.
|
|
28
|
-
this.parts.push(...part.parts);
|
|
29
|
-
}
|
|
30
|
-
else if (part instanceof ArrayBuffer) {
|
|
31
|
-
this.parts.push(new Uint8Array(part));
|
|
32
|
-
this.size += part.byteLength;
|
|
33
|
-
}
|
|
34
|
-
else if (part instanceof Uint8Array) {
|
|
35
|
-
this.parts.push(part);
|
|
36
|
-
this.size += part.byteLength;
|
|
37
|
-
}
|
|
38
|
-
else if (ArrayBuffer.isView(part)) {
|
|
39
|
-
const { buffer, byteOffset, byteLength } = part;
|
|
40
|
-
this.parts.push(new Uint8Array(buffer, byteOffset, byteLength));
|
|
41
|
-
this.size += byteLength;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const bytes = new TextEncoder().encode(String(part));
|
|
45
|
-
this.parts.push(bytes);
|
|
46
|
-
this.size += bytes.byteLength;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/** @private */
|
|
50
|
-
this.type = readType(options.type);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Returns a new Blob object containing the data in the specified range of
|
|
54
|
-
* bytes of the blob on which it's called.
|
|
55
|
-
* @param start=0 - An index into the Blob indicating the first
|
|
56
|
-
* byte to include in the new Blob. If you specify a negative value, it's
|
|
57
|
-
* treated as an offset from the end of the Blob toward the beginning. For
|
|
58
|
-
* example, `-10` would be the 10th from last byte in the Blob. The default
|
|
59
|
-
* value is `0`. If you specify a value for start that is larger than the
|
|
60
|
-
* size of the source Blob, the returned Blob has size 0 and contains no
|
|
61
|
-
* data.
|
|
62
|
-
* @param end - An index into the `Blob` indicating the first byte
|
|
63
|
-
* that will *not* be included in the new `Blob` (i.e. the byte exactly at
|
|
64
|
-
* this index is not included). If you specify a negative value, it's treated
|
|
65
|
-
* as an offset from the end of the Blob toward the beginning. For example,
|
|
66
|
-
* `-10` would be the 10th from last byte in the `Blob`. The default value is
|
|
67
|
-
* size.
|
|
68
|
-
* @param type - The content type to assign to the new Blob;
|
|
69
|
-
* this will be the value of its type property. The default value is an empty
|
|
70
|
-
* string.
|
|
71
|
-
*/
|
|
72
|
-
slice(start = 0, end = this.size, type = '') {
|
|
73
|
-
const { size, parts: parts } = this;
|
|
74
|
-
let offset = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
|
|
75
|
-
let limit = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
|
|
76
|
-
const span = Math.max(limit - offset, 0);
|
|
77
|
-
const blob = new BlobPolyfill([], { type });
|
|
78
|
-
if (span === 0) {
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
return blob;
|
|
81
|
-
}
|
|
82
|
-
let blobSize = 0;
|
|
83
|
-
const blobParts = [];
|
|
84
|
-
for (const part of parts) {
|
|
85
|
-
const { byteLength } = part;
|
|
86
|
-
if (offset > 0 && byteLength <= offset) {
|
|
87
|
-
offset -= byteLength;
|
|
88
|
-
limit -= byteLength;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const chunk = part.subarray(offset, Math.min(byteLength, limit));
|
|
92
|
-
blobParts.push(chunk);
|
|
93
|
-
blobSize += chunk.byteLength;
|
|
94
|
-
// no longer need to take that into account
|
|
95
|
-
offset = 0;
|
|
96
|
-
// don't add the overflow to new blobParts
|
|
97
|
-
if (blobSize >= span) {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
blob.parts = blobParts;
|
|
103
|
-
blob.size = blobSize;
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
return blob;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Returns a promise that resolves with an ArrayBuffer containing the entire
|
|
109
|
-
* contents of the Blob as binary data.
|
|
110
|
-
*/
|
|
111
|
-
// eslint-disable-next-line require-await
|
|
112
|
-
async arrayBuffer() {
|
|
113
|
-
return this._toArrayBuffer();
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Returns a promise that resolves with a USVString containing the entire
|
|
117
|
-
* contents of the Blob interpreted as UTF-8 text.
|
|
118
|
-
*/
|
|
119
|
-
// eslint-disable-next-line require-await
|
|
120
|
-
async text() {
|
|
121
|
-
const decoder = new TextDecoder();
|
|
122
|
-
let text = '';
|
|
123
|
-
for (const part of this.parts) {
|
|
124
|
-
text += decoder.decode(part);
|
|
125
|
-
}
|
|
126
|
-
return text;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
*/
|
|
130
|
-
// @ts-ignore
|
|
131
|
-
stream() {
|
|
132
|
-
return new blob_stream_1.BlobStream(this.parts);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* @returns {string}
|
|
136
|
-
*/
|
|
137
|
-
toString() {
|
|
138
|
-
return '[object Blob]';
|
|
139
|
-
}
|
|
140
|
-
get [Symbol.toStringTag]() {
|
|
141
|
-
return 'Blob';
|
|
142
|
-
}
|
|
143
|
-
_toArrayBuffer() {
|
|
144
|
-
const buffer = new ArrayBuffer(this.size);
|
|
145
|
-
const bytes = new Uint8Array(buffer);
|
|
146
|
-
let offset = 0;
|
|
147
|
-
for (const part of this.parts) {
|
|
148
|
-
bytes.set(part, offset);
|
|
149
|
-
offset += part.byteLength;
|
|
150
|
-
}
|
|
151
|
-
return buffer;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.BlobPolyfill = BlobPolyfill;
|
|
155
|
-
/**
|
|
156
|
-
*/
|
|
157
|
-
function readType(input = '') {
|
|
158
|
-
const type = String(input).toLowerCase();
|
|
159
|
-
return /[^\u0020-\u007E]/.test(type) ? '' : type;
|
|
160
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileReaderPolyfill = void 0;
|
|
4
|
-
const btoa_node_1 = require("../buffer/btoa.node");
|
|
5
|
-
class FileReaderPolyfill {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.onload = null;
|
|
8
|
-
}
|
|
9
|
-
abort() {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
async readAsArrayBuffer(blob) {
|
|
13
|
-
const arrayBuffer = await blob.arrayBuffer();
|
|
14
|
-
if (this.onload) {
|
|
15
|
-
this.onload({ target: { result: arrayBuffer } });
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async readAsBinaryString(blob) {
|
|
19
|
-
throw Error('Not implemented');
|
|
20
|
-
}
|
|
21
|
-
async readAsDataURL(blob) {
|
|
22
|
-
const text = await blob.text();
|
|
23
|
-
const dataUrl = `data://;base64,${(0, btoa_node_1.atob)(text)}`;
|
|
24
|
-
if (this.onload) {
|
|
25
|
-
this.onload({ target: { result: dataUrl } });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async readAsText(blob) {
|
|
29
|
-
const text = await blob.text();
|
|
30
|
-
if (this.onload) {
|
|
31
|
-
this.onload({ target: { result: text } });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.FileReaderPolyfill = FileReaderPolyfill;
|
package/dist/node/file/file.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilePolyfill = void 0;
|
|
4
|
-
// Forked from @gozala's web-file under MIT license https://github.com/Gozala/web-file
|
|
5
|
-
const blob_1 = require("./blob");
|
|
6
|
-
/**
|
|
7
|
-
* Forked from @gozala's web-file under MIT license
|
|
8
|
-
* @see https://github.com/Gozala/web-file
|
|
9
|
-
*/
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
class FilePolyfill extends blob_1.BlobPolyfill {
|
|
12
|
-
/**
|
|
13
|
-
* @param init
|
|
14
|
-
* @param name - A USVString representing the file name or the path
|
|
15
|
-
* to the file.
|
|
16
|
-
* @param [options]
|
|
17
|
-
*/
|
|
18
|
-
constructor(init, name, options = {}) {
|
|
19
|
-
super(init, options);
|
|
20
|
-
// implements File {
|
|
21
|
-
// public API
|
|
22
|
-
/** The name of the file referenced by the File object. */
|
|
23
|
-
this.name = '';
|
|
24
|
-
/** The path the URL of the File is relative to. */
|
|
25
|
-
this.webkitRelativePath = '';
|
|
26
|
-
// Per File API spec https://w3c.github.io/FileAPI/#file-constructor
|
|
27
|
-
// Every "/" character of file name must be replaced with a ":".
|
|
28
|
-
/** @private */
|
|
29
|
-
this.name = String(name).replace(/\//g, ':');
|
|
30
|
-
/** @private */
|
|
31
|
-
this.lastModified = options?.lastModified || Date.now();
|
|
32
|
-
}
|
|
33
|
-
get [Symbol.toStringTag]() {
|
|
34
|
-
return 'File';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.FilePolyfill = FilePolyfill;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installFilePolyfills = void 0;
|
|
4
|
-
// import {ReadableStreamPolyfill} from './readable-stream';
|
|
5
|
-
const blob_1 = require("./blob");
|
|
6
|
-
const file_reader_1 = require("./file-reader");
|
|
7
|
-
const file_1 = require("./file");
|
|
8
|
-
function installFilePolyfills() {
|
|
9
|
-
if (typeof ReadableStream === 'undefined' && global) {
|
|
10
|
-
// @ts-ignore;
|
|
11
|
-
// global.ReadableStream = ReadableStreamPolyfill;
|
|
12
|
-
}
|
|
13
|
-
if (typeof Blob === 'undefined' && global) {
|
|
14
|
-
// @ts-ignore;
|
|
15
|
-
global.Blob = blob_1.BlobPolyfill;
|
|
16
|
-
}
|
|
17
|
-
if (typeof FileReader === 'undefined' && global) {
|
|
18
|
-
// @ts-ignore;
|
|
19
|
-
global.FileReader = file_reader_1.FileReaderPolyfill;
|
|
20
|
-
}
|
|
21
|
-
// Install minimal Node.js File polyfill
|
|
22
|
-
if (typeof File === 'undefined' && global) {
|
|
23
|
-
// @ts-ignore;
|
|
24
|
-
global.File = file_1.FilePolyfill;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.installFilePolyfills = installFilePolyfills;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReadableStreamPolyfill = void 0;
|
|
4
|
-
const web_streams_polyfill_1 = require("web-streams-polyfill");
|
|
5
|
-
// Want a polyfill, but please don't install it
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
delete global.ReadableStream;
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
class ReadableStreamPolyfill extends web_streams_polyfill_1.ReadableStream {
|
|
10
|
-
}
|
|
11
|
-
exports.ReadableStreamPolyfill = ReadableStreamPolyfill;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Use stackgl modules for DOM-less reading and writing of images
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.encodeImageNode = exports.encodeImageToStreamNode = void 0;
|
|
8
|
-
const save_pixels_1 = __importDefault(require("save-pixels"));
|
|
9
|
-
const ndarray_1 = __importDefault(require("ndarray"));
|
|
10
|
-
const to_array_buffer_node_1 = require("../buffer/to-array-buffer.node");
|
|
11
|
-
/**
|
|
12
|
-
* Returns data bytes representing a compressed image in PNG or JPG format,
|
|
13
|
-
* This data can be saved using file system (f) methods or
|
|
14
|
-
* used in a request.
|
|
15
|
-
* @param image to save
|
|
16
|
-
* @param options
|
|
17
|
-
* @param options.type='png' - png, jpg or image/png, image/jpg are valid
|
|
18
|
-
* @param options.dataURI - Whether to include a data URI header
|
|
19
|
-
* @return {*} bytes
|
|
20
|
-
*/
|
|
21
|
-
function encodeImageToStreamNode(image, options) {
|
|
22
|
-
// Support MIME type strings
|
|
23
|
-
const type = options.type ? options.type.replace('image/', '') : 'jpeg';
|
|
24
|
-
const pixels = (0, ndarray_1.default)(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
|
|
25
|
-
// Note: savePixels returns a stream
|
|
26
|
-
return (0, save_pixels_1.default)(pixels, type, options);
|
|
27
|
-
}
|
|
28
|
-
exports.encodeImageToStreamNode = encodeImageToStreamNode;
|
|
29
|
-
function encodeImageNode(image, options) {
|
|
30
|
-
const imageStream = encodeImageToStreamNode(image, options);
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
const buffers = [];
|
|
33
|
-
imageStream.on('data', (buffer) => buffers.push(buffer));
|
|
34
|
-
// TODO - convert to arraybuffer?
|
|
35
|
-
imageStream.on('end', () => {
|
|
36
|
-
const buffer = Buffer.concat(buffers);
|
|
37
|
-
resolve((0, to_array_buffer_node_1.bufferToArrayBuffer)(buffer));
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
exports.encodeImageNode = encodeImageNode;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.parseImageNode = exports.NODE_FORMAT_SUPPORT = void 0;
|
|
8
|
-
const get_pixels_1 = __importDefault(require("get-pixels"));
|
|
9
|
-
/** Declares which image format mime types this loader polyfill supports */
|
|
10
|
-
exports.NODE_FORMAT_SUPPORT = ['image/png', 'image/jpeg', 'image/gif'];
|
|
11
|
-
async function parseImageNode(arrayBuffer, mimeType) {
|
|
12
|
-
if (!mimeType) {
|
|
13
|
-
throw new Error('MIMEType is required to parse image under Node.js');
|
|
14
|
-
}
|
|
15
|
-
const buffer = arrayBuffer instanceof Buffer ? arrayBuffer : Buffer.from(arrayBuffer);
|
|
16
|
-
const ndarray = await getPixelsAsync(buffer, mimeType);
|
|
17
|
-
return ndarray;
|
|
18
|
-
}
|
|
19
|
-
exports.parseImageNode = parseImageNode;
|
|
20
|
-
// TODO - check if getPixels callback is asynchronous if provided with buffer input
|
|
21
|
-
// if not, parseImage can be a sync function
|
|
22
|
-
function getPixelsAsync(buffer, mimeType) {
|
|
23
|
-
return new Promise((resolve) => (0, get_pixels_1.default)(buffer, mimeType, (err, ndarray) => {
|
|
24
|
-
if (err) {
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
27
|
-
const shape = [...ndarray.shape];
|
|
28
|
-
const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
|
|
29
|
-
const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
|
|
30
|
-
// extract width/height etc
|
|
31
|
-
resolve({
|
|
32
|
-
shape,
|
|
33
|
-
data,
|
|
34
|
-
width: ndarray.shape[0],
|
|
35
|
-
height: ndarray.shape[1],
|
|
36
|
-
components: ndarray.shape[2],
|
|
37
|
-
// TODO - error
|
|
38
|
-
layers: layers ? [layers] : []
|
|
39
|
-
});
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allSettled = exports.FULFILLED_STATUS = exports.REJECTED_STATUS = void 0;
|
|
4
|
-
exports.REJECTED_STATUS = 'rejected';
|
|
5
|
-
exports.FULFILLED_STATUS = 'fulfilled';
|
|
6
|
-
/**
|
|
7
|
-
* Handle list of promises and return all values regardless of results.
|
|
8
|
-
* Polyfill for Promise.allSettled() method.
|
|
9
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
|
|
10
|
-
* @param promises
|
|
11
|
-
*/
|
|
12
|
-
function allSettled(promises) {
|
|
13
|
-
const mappedPromises = promises.map((promise) => {
|
|
14
|
-
return promise
|
|
15
|
-
.then((value) => {
|
|
16
|
-
return { status: exports.FULFILLED_STATUS, value };
|
|
17
|
-
})
|
|
18
|
-
.catch((reason) => {
|
|
19
|
-
return { status: exports.REJECTED_STATUS, reason };
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
return Promise.all(mappedPromises);
|
|
23
|
-
}
|
|
24
|
-
exports.allSettled = allSettled;
|
package/dist/utils/assert.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assert = void 0;
|
|
4
|
-
function assert(condition, message) {
|
|
5
|
-
if (!condition) {
|
|
6
|
-
throw new Error(`@loaders.gl/polyfills assertion ${message}`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.assert = assert;
|
package/dist/utils/globals.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
// in the Software without restriction, including without limitation the rights
|
|
7
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
// furnished to do so, subject to the following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included in
|
|
12
|
-
// all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
// THE SOFTWARE.
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.global = exports.isBrowser = void 0;
|
|
23
|
-
// Purpose: include this in your module to avoids adding dependencies on
|
|
24
|
-
// micro modules like 'global' and 'is-browser';
|
|
25
|
-
/* eslint-disable no-restricted-globals */
|
|
26
|
-
const isBrowser =
|
|
27
|
-
// @ts-ignore process.browser
|
|
28
|
-
typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
|
|
29
|
-
exports.isBrowser = isBrowser;
|
|
30
|
-
const globals = {
|
|
31
|
-
self: typeof self !== 'undefined' && self,
|
|
32
|
-
window: typeof window !== 'undefined' && window,
|
|
33
|
-
global: typeof global !== 'undefined' && global
|
|
34
|
-
};
|
|
35
|
-
const global_ = (globals.global || globals.self || globals.window);
|
|
36
|
-
exports.global = global_;
|