Initial
This commit is contained in:
201
resources/app/node_modules/b4a/LICENSE
generated
vendored
Normal file
201
resources/app/node_modules/b4a/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
499
resources/app/node_modules/b4a/browser.js
generated
vendored
Normal file
499
resources/app/node_modules/b4a/browser.js
generated
vendored
Normal file
@@ -0,0 +1,499 @@
|
||||
const ascii = require('./lib/ascii')
|
||||
const base64 = require('./lib/base64')
|
||||
const hex = require('./lib/hex')
|
||||
const utf8 = require('./lib/utf8')
|
||||
const utf16le = require('./lib/utf16le')
|
||||
|
||||
const LE = new Uint8Array(Uint16Array.of(0xff).buffer)[0] === 0xff
|
||||
|
||||
function codecFor (encoding) {
|
||||
switch (encoding) {
|
||||
case 'ascii':
|
||||
return ascii
|
||||
case 'base64':
|
||||
return base64
|
||||
case 'hex':
|
||||
return hex
|
||||
case 'utf8':
|
||||
case 'utf-8':
|
||||
case undefined:
|
||||
return utf8
|
||||
case 'ucs2':
|
||||
case 'ucs-2':
|
||||
case 'utf16le':
|
||||
case 'utf-16le':
|
||||
return utf16le
|
||||
default:
|
||||
throw new Error(`Unknown encoding: ${encoding}`)
|
||||
}
|
||||
}
|
||||
|
||||
function isBuffer (value) {
|
||||
return value instanceof Uint8Array
|
||||
}
|
||||
|
||||
function isEncoding (encoding) {
|
||||
try {
|
||||
codecFor(encoding)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function alloc (size, fill, encoding) {
|
||||
const buffer = new Uint8Array(size)
|
||||
if (fill !== undefined) exports.fill(buffer, fill, 0, buffer.byteLength, encoding)
|
||||
return buffer
|
||||
}
|
||||
|
||||
function allocUnsafe (size) {
|
||||
return new Uint8Array(size)
|
||||
}
|
||||
|
||||
function allocUnsafeSlow (size) {
|
||||
return new Uint8Array(size)
|
||||
}
|
||||
|
||||
function byteLength (string, encoding) {
|
||||
return codecFor(encoding).byteLength(string)
|
||||
}
|
||||
|
||||
function compare (a, b) {
|
||||
if (a === b) return 0
|
||||
|
||||
const len = Math.min(a.byteLength, b.byteLength)
|
||||
|
||||
a = new DataView(a.buffer, a.byteOffset, a.byteLength)
|
||||
b = new DataView(b.buffer, b.byteOffset, b.byteLength)
|
||||
|
||||
let i = 0
|
||||
|
||||
for (let n = len - (len % 4); i < n; i += 4) {
|
||||
const x = a.getUint32(i, LE)
|
||||
const y = b.getUint32(i, LE)
|
||||
if (x !== y) break
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
const x = a.getUint8(i)
|
||||
const y = b.getUint8(i)
|
||||
if (x < y) return -1
|
||||
if (x > y) return 1
|
||||
}
|
||||
|
||||
return a.byteLength > b.byteLength ? 1 : a.byteLength < b.byteLength ? -1 : 0
|
||||
}
|
||||
|
||||
function concat (buffers, totalLength) {
|
||||
if (totalLength === undefined) {
|
||||
totalLength = buffers.reduce((len, buffer) => len + buffer.byteLength, 0)
|
||||
}
|
||||
|
||||
const result = new Uint8Array(totalLength)
|
||||
|
||||
let offset = 0
|
||||
for (const buffer of buffers) {
|
||||
if (offset + buffer.byteLength > result.byteLength) {
|
||||
const sub = buffer.subarray(0, result.byteLength - offset)
|
||||
result.set(sub, offset)
|
||||
return result
|
||||
}
|
||||
result.set(buffer, offset)
|
||||
offset += buffer.byteLength
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function copy (source, target, targetStart = 0, start = 0, end = source.byteLength) {
|
||||
if (end > 0 && end < start) return 0
|
||||
if (end === start) return 0
|
||||
if (source.byteLength === 0 || target.byteLength === 0) return 0
|
||||
|
||||
if (targetStart < 0) throw new RangeError('targetStart is out of range')
|
||||
if (start < 0 || start >= source.byteLength) throw new RangeError('sourceStart is out of range')
|
||||
if (end < 0) throw new RangeError('sourceEnd is out of range')
|
||||
|
||||
if (targetStart >= target.byteLength) targetStart = target.byteLength
|
||||
if (end > source.byteLength) end = source.byteLength
|
||||
if (target.byteLength - targetStart < end - start) {
|
||||
end = target.length - targetStart + start
|
||||
}
|
||||
|
||||
const len = end - start
|
||||
|
||||
if (source === target) {
|
||||
target.copyWithin(targetStart, start, end)
|
||||
} else {
|
||||
target.set(source.subarray(start, end), targetStart)
|
||||
}
|
||||
|
||||
return len
|
||||
}
|
||||
|
||||
function equals (a, b) {
|
||||
if (a === b) return true
|
||||
if (a.byteLength !== b.byteLength) return false
|
||||
|
||||
const len = a.byteLength
|
||||
|
||||
a = new DataView(a.buffer, a.byteOffset, a.byteLength)
|
||||
b = new DataView(b.buffer, b.byteOffset, b.byteLength)
|
||||
|
||||
let i = 0
|
||||
|
||||
for (let n = len - (len % 4); i < n; i += 4) {
|
||||
if (a.getUint32(i, LE) !== b.getUint32(i, LE)) return false
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (a.getUint8(i) !== b.getUint8(i)) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function fill (buffer, value, offset, end, encoding) {
|
||||
if (typeof value === 'string') {
|
||||
// fill(buffer, string, encoding)
|
||||
if (typeof offset === 'string') {
|
||||
encoding = offset
|
||||
offset = 0
|
||||
end = buffer.byteLength
|
||||
|
||||
// fill(buffer, string, offset, encoding)
|
||||
} else if (typeof end === 'string') {
|
||||
encoding = end
|
||||
end = buffer.byteLength
|
||||
}
|
||||
} else if (typeof value === 'number') {
|
||||
value = value & 0xff
|
||||
} else if (typeof value === 'boolean') {
|
||||
value = +value
|
||||
}
|
||||
|
||||
if (offset < 0 || buffer.byteLength < offset || buffer.byteLength < end) {
|
||||
throw new RangeError('Out of range index')
|
||||
}
|
||||
|
||||
if (offset === undefined) offset = 0
|
||||
if (end === undefined) end = buffer.byteLength
|
||||
|
||||
if (end <= offset) return buffer
|
||||
|
||||
if (!value) value = 0
|
||||
|
||||
if (typeof value === 'number') {
|
||||
for (let i = offset; i < end; ++i) {
|
||||
buffer[i] = value
|
||||
}
|
||||
} else {
|
||||
value = isBuffer(value) ? value : from(value, encoding)
|
||||
|
||||
const len = value.byteLength
|
||||
|
||||
for (let i = 0; i < end - offset; ++i) {
|
||||
buffer[i + offset] = value[i % len]
|
||||
}
|
||||
}
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
function from (value, encodingOrOffset, length) {
|
||||
// from(string, encoding)
|
||||
if (typeof value === 'string') return fromString(value, encodingOrOffset)
|
||||
|
||||
// from(array)
|
||||
if (Array.isArray(value)) return fromArray(value)
|
||||
|
||||
// from(buffer)
|
||||
if (ArrayBuffer.isView(value)) return fromBuffer(value)
|
||||
|
||||
// from(arrayBuffer[, byteOffset[, length]])
|
||||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
function fromString (string, encoding) {
|
||||
const codec = codecFor(encoding)
|
||||
const buffer = new Uint8Array(codec.byteLength(string))
|
||||
codec.write(buffer, string, 0, buffer.byteLength)
|
||||
return buffer
|
||||
}
|
||||
|
||||
function fromArray (array) {
|
||||
const buffer = new Uint8Array(array.length)
|
||||
buffer.set(array)
|
||||
return buffer
|
||||
}
|
||||
|
||||
function fromBuffer (buffer) {
|
||||
const copy = new Uint8Array(buffer.byteLength)
|
||||
copy.set(buffer)
|
||||
return copy
|
||||
}
|
||||
|
||||
function fromArrayBuffer (arrayBuffer, byteOffset, length) {
|
||||
return new Uint8Array(arrayBuffer, byteOffset, length)
|
||||
}
|
||||
|
||||
function includes (buffer, value, byteOffset, encoding) {
|
||||
return indexOf(buffer, value, byteOffset, encoding) !== -1
|
||||
}
|
||||
|
||||
function bidirectionalIndexOf (buffer, value, byteOffset, encoding, first) {
|
||||
if (buffer.byteLength === 0) return -1
|
||||
|
||||
if (typeof byteOffset === 'string') {
|
||||
encoding = byteOffset
|
||||
byteOffset = 0
|
||||
} else if (byteOffset === undefined) {
|
||||
byteOffset = first ? 0 : (buffer.length - 1)
|
||||
} else if (byteOffset < 0) {
|
||||
byteOffset += buffer.byteLength
|
||||
}
|
||||
|
||||
if (byteOffset >= buffer.byteLength) {
|
||||
if (first) return -1
|
||||
else byteOffset = buffer.byteLength - 1
|
||||
} else if (byteOffset < 0) {
|
||||
if (first) byteOffset = 0
|
||||
else return -1
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
value = from(value, encoding)
|
||||
} else if (typeof value === 'number') {
|
||||
value = value & 0xff
|
||||
|
||||
if (first) {
|
||||
return buffer.indexOf(value, byteOffset)
|
||||
} else {
|
||||
return buffer.lastIndexOf(value, byteOffset)
|
||||
}
|
||||
}
|
||||
|
||||
if (value.byteLength === 0) return -1
|
||||
|
||||
if (first) {
|
||||
let foundIndex = -1
|
||||
|
||||
for (let i = byteOffset; i < buffer.byteLength; i++) {
|
||||
if (buffer[i] === value[foundIndex === -1 ? 0 : i - foundIndex]) {
|
||||
if (foundIndex === -1) foundIndex = i
|
||||
if (i - foundIndex + 1 === value.byteLength) return foundIndex
|
||||
} else {
|
||||
if (foundIndex !== -1) i -= i - foundIndex
|
||||
foundIndex = -1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (byteOffset + value.byteLength > buffer.byteLength) {
|
||||
byteOffset = buffer.byteLength - value.byteLength
|
||||
}
|
||||
|
||||
for (let i = byteOffset; i >= 0; i--) {
|
||||
let found = true
|
||||
|
||||
for (let j = 0; j < value.byteLength; j++) {
|
||||
if (buffer[i + j] !== value[j]) {
|
||||
found = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (found) return i
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
function indexOf (buffer, value, byteOffset, encoding) {
|
||||
return bidirectionalIndexOf(buffer, value, byteOffset, encoding, true /* first */)
|
||||
}
|
||||
|
||||
function lastIndexOf (buffer, value, byteOffset, encoding) {
|
||||
return bidirectionalIndexOf(buffer, value, byteOffset, encoding, false /* last */)
|
||||
}
|
||||
|
||||
function swap (buffer, n, m) {
|
||||
const i = buffer[n]
|
||||
buffer[n] = buffer[m]
|
||||
buffer[m] = i
|
||||
}
|
||||
|
||||
function swap16 (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
if (len % 2 !== 0) throw new RangeError('Buffer size must be a multiple of 16-bits')
|
||||
|
||||
for (let i = 0; i < len; i += 2) swap(buffer, i, i + 1)
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
function swap32 (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
if (len % 4 !== 0) throw new RangeError('Buffer size must be a multiple of 32-bits')
|
||||
|
||||
for (let i = 0; i < len; i += 4) {
|
||||
swap(buffer, i, i + 3)
|
||||
swap(buffer, i + 1, i + 2)
|
||||
}
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
function swap64 (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
if (len % 8 !== 0) throw new RangeError('Buffer size must be a multiple of 64-bits')
|
||||
|
||||
for (let i = 0; i < len; i += 8) {
|
||||
swap(buffer, i, i + 7)
|
||||
swap(buffer, i + 1, i + 6)
|
||||
swap(buffer, i + 2, i + 5)
|
||||
swap(buffer, i + 3, i + 4)
|
||||
}
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
function toBuffer (buffer) {
|
||||
return buffer
|
||||
}
|
||||
|
||||
function toString (buffer, encoding, start = 0, end = buffer.byteLength) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
if (start >= len) return ''
|
||||
if (end <= start) return ''
|
||||
if (start < 0) start = 0
|
||||
if (end > len) end = len
|
||||
|
||||
if (start !== 0 || end < len) buffer = buffer.subarray(start, end)
|
||||
|
||||
return codecFor(encoding).toString(buffer)
|
||||
}
|
||||
|
||||
function write (buffer, string, offset, length, encoding) {
|
||||
// write(buffer, string)
|
||||
if (offset === undefined) {
|
||||
encoding = 'utf8'
|
||||
|
||||
// write(buffer, string, encoding)
|
||||
} else if (length === undefined && typeof offset === 'string') {
|
||||
encoding = offset
|
||||
offset = undefined
|
||||
|
||||
// write(buffer, string, offset, encoding)
|
||||
} else if (encoding === undefined && typeof length === 'string') {
|
||||
encoding = length
|
||||
length = undefined
|
||||
}
|
||||
|
||||
return codecFor(encoding).write(buffer, string, offset, length)
|
||||
}
|
||||
|
||||
function writeDoubleLE (buffer, value, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
view.setFloat64(offset, value, true)
|
||||
|
||||
return offset + 8
|
||||
}
|
||||
|
||||
function writeFloatLE (buffer, value, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
view.setFloat32(offset, value, true)
|
||||
|
||||
return offset + 4
|
||||
}
|
||||
|
||||
function writeUInt32LE (buffer, value, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
view.setUint32(offset, value, true)
|
||||
|
||||
return offset + 4
|
||||
}
|
||||
|
||||
function writeInt32LE (buffer, value, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
view.setInt32(offset, value, true)
|
||||
|
||||
return offset + 4
|
||||
}
|
||||
|
||||
function readDoubleLE (buffer, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
|
||||
return view.getFloat64(offset, true)
|
||||
}
|
||||
|
||||
function readFloatLE (buffer, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
|
||||
return view.getFloat32(offset, true)
|
||||
}
|
||||
|
||||
function readUInt32LE (buffer, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
|
||||
return view.getUint32(offset, true)
|
||||
}
|
||||
|
||||
function readInt32LE (buffer, offset) {
|
||||
if (offset === undefined) offset = 0
|
||||
|
||||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
|
||||
return view.getInt32(offset, true)
|
||||
}
|
||||
|
||||
module.exports = exports = {
|
||||
isBuffer,
|
||||
isEncoding,
|
||||
alloc,
|
||||
allocUnsafe,
|
||||
allocUnsafeSlow,
|
||||
byteLength,
|
||||
compare,
|
||||
concat,
|
||||
copy,
|
||||
equals,
|
||||
fill,
|
||||
from,
|
||||
includes,
|
||||
indexOf,
|
||||
lastIndexOf,
|
||||
swap16,
|
||||
swap32,
|
||||
swap64,
|
||||
toBuffer,
|
||||
toString,
|
||||
write,
|
||||
writeDoubleLE,
|
||||
writeFloatLE,
|
||||
writeUInt32LE,
|
||||
writeInt32LE,
|
||||
readDoubleLE,
|
||||
readFloatLE,
|
||||
readUInt32LE,
|
||||
readInt32LE
|
||||
}
|
||||
148
resources/app/node_modules/b4a/index.js
generated
vendored
Normal file
148
resources/app/node_modules/b4a/index.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
function isBuffer (value) {
|
||||
return Buffer.isBuffer(value) || value instanceof Uint8Array
|
||||
}
|
||||
|
||||
function isEncoding (encoding) {
|
||||
return Buffer.isEncoding(encoding)
|
||||
}
|
||||
|
||||
function alloc (size, fill, encoding) {
|
||||
return Buffer.alloc(size, fill, encoding)
|
||||
}
|
||||
|
||||
function allocUnsafe (size) {
|
||||
return Buffer.allocUnsafe(size)
|
||||
}
|
||||
|
||||
function allocUnsafeSlow (size) {
|
||||
return Buffer.allocUnsafeSlow(size)
|
||||
}
|
||||
|
||||
function byteLength (string, encoding) {
|
||||
return Buffer.byteLength(string, encoding)
|
||||
}
|
||||
|
||||
function compare (a, b) {
|
||||
return Buffer.compare(a, b)
|
||||
}
|
||||
|
||||
function concat (buffers, totalLength) {
|
||||
return Buffer.concat(buffers, totalLength)
|
||||
}
|
||||
|
||||
function copy (source, target, targetStart, start, end) {
|
||||
return toBuffer(source).copy(target, targetStart, start, end)
|
||||
}
|
||||
|
||||
function equals (a, b) {
|
||||
return toBuffer(a).equals(b)
|
||||
}
|
||||
|
||||
function fill (buffer, value, offset, end, encoding) {
|
||||
return toBuffer(buffer).fill(value, offset, end, encoding)
|
||||
}
|
||||
|
||||
function from (value, encodingOrOffset, length) {
|
||||
return Buffer.from(value, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
function includes (buffer, value, byteOffset, encoding) {
|
||||
return toBuffer(buffer).includes(value, byteOffset, encoding)
|
||||
}
|
||||
|
||||
function indexOf (buffer, value, byfeOffset, encoding) {
|
||||
return toBuffer(buffer).indexOf(value, byfeOffset, encoding)
|
||||
}
|
||||
|
||||
function lastIndexOf (buffer, value, byteOffset, encoding) {
|
||||
return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding)
|
||||
}
|
||||
|
||||
function swap16 (buffer) {
|
||||
return toBuffer(buffer).swap16()
|
||||
}
|
||||
|
||||
function swap32 (buffer) {
|
||||
return toBuffer(buffer).swap32()
|
||||
}
|
||||
|
||||
function swap64 (buffer) {
|
||||
return toBuffer(buffer).swap64()
|
||||
}
|
||||
|
||||
function toBuffer (buffer) {
|
||||
if (Buffer.isBuffer(buffer)) return buffer
|
||||
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
}
|
||||
|
||||
function toString (buffer, encoding, start, end) {
|
||||
return toBuffer(buffer).toString(encoding, start, end)
|
||||
}
|
||||
|
||||
function write (buffer, string, offset, length, encoding) {
|
||||
return toBuffer(buffer).write(string, offset, length, encoding)
|
||||
}
|
||||
|
||||
function writeDoubleLE (buffer, value, offset) {
|
||||
return toBuffer(buffer).writeDoubleLE(value, offset)
|
||||
}
|
||||
|
||||
function writeFloatLE (buffer, value, offset) {
|
||||
return toBuffer(buffer).writeFloatLE(value, offset)
|
||||
}
|
||||
|
||||
function writeUInt32LE (buffer, value, offset) {
|
||||
return toBuffer(buffer).writeUInt32LE(value, offset)
|
||||
}
|
||||
|
||||
function writeInt32LE (buffer, value, offset) {
|
||||
return toBuffer(buffer).writeInt32LE(value, offset)
|
||||
}
|
||||
|
||||
function readDoubleLE (buffer, offset) {
|
||||
return toBuffer(buffer).readDoubleLE(offset)
|
||||
}
|
||||
|
||||
function readFloatLE (buffer, offset) {
|
||||
return toBuffer(buffer).readFloatLE(offset)
|
||||
}
|
||||
|
||||
function readUInt32LE (buffer, offset) {
|
||||
return toBuffer(buffer).readUInt32LE(offset)
|
||||
}
|
||||
|
||||
function readInt32LE (buffer, offset) {
|
||||
return toBuffer(buffer).readInt32LE(offset)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isBuffer,
|
||||
isEncoding,
|
||||
alloc,
|
||||
allocUnsafe,
|
||||
allocUnsafeSlow,
|
||||
byteLength,
|
||||
compare,
|
||||
concat,
|
||||
copy,
|
||||
equals,
|
||||
fill,
|
||||
from,
|
||||
includes,
|
||||
indexOf,
|
||||
lastIndexOf,
|
||||
swap16,
|
||||
swap32,
|
||||
swap64,
|
||||
toBuffer,
|
||||
toString,
|
||||
write,
|
||||
writeDoubleLE,
|
||||
writeFloatLE,
|
||||
writeUInt32LE,
|
||||
writeInt32LE,
|
||||
readDoubleLE,
|
||||
readFloatLE,
|
||||
readUInt32LE,
|
||||
readInt32LE
|
||||
}
|
||||
31
resources/app/node_modules/b4a/lib/ascii.js
generated
vendored
Normal file
31
resources/app/node_modules/b4a/lib/ascii.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
function byteLength (string) {
|
||||
return string.length
|
||||
}
|
||||
|
||||
function toString (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
let result = ''
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
result += String.fromCharCode(buffer[i])
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function write (buffer, string, offset = 0, length = byteLength(string)) {
|
||||
const len = Math.min(length, buffer.byteLength - offset)
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
buffer[offset + i] = string.charCodeAt(i)
|
||||
}
|
||||
|
||||
return len
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
byteLength,
|
||||
toString,
|
||||
write
|
||||
}
|
||||
65
resources/app/node_modules/b4a/lib/base64.js
generated
vendored
Normal file
65
resources/app/node_modules/b4a/lib/base64.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||
|
||||
const codes = new Uint8Array(256)
|
||||
|
||||
for (let i = 0; i < alphabet.length; i++) {
|
||||
codes[alphabet.charCodeAt(i)] = i
|
||||
}
|
||||
|
||||
codes[/* - */ 0x2d] = 62
|
||||
codes[/* _ */ 0x5f] = 63
|
||||
|
||||
function byteLength (string) {
|
||||
let len = string.length
|
||||
|
||||
if (string.charCodeAt(len - 1) === 0x3d) len--
|
||||
if (len > 1 && string.charCodeAt(len - 1) === 0x3d) len--
|
||||
|
||||
return (len * 3) >>> 2
|
||||
}
|
||||
|
||||
function toString (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
let result = ''
|
||||
|
||||
for (let i = 0; i < len; i += 3) {
|
||||
result += (
|
||||
alphabet[buffer[i] >> 2] +
|
||||
alphabet[((buffer[i] & 3) << 4) | (buffer[i + 1] >> 4)] +
|
||||
alphabet[((buffer[i + 1] & 15) << 2) | (buffer[i + 2] >> 6)] +
|
||||
alphabet[buffer[i + 2] & 63]
|
||||
)
|
||||
}
|
||||
|
||||
if (len % 3 === 2) {
|
||||
result = result.substring(0, result.length - 1) + '='
|
||||
} else if (len % 3 === 1) {
|
||||
result = result.substring(0, result.length - 2) + '=='
|
||||
}
|
||||
|
||||
return result
|
||||
};
|
||||
|
||||
function write (buffer, string, offset = 0, length = byteLength(string)) {
|
||||
const len = Math.min(length, buffer.byteLength - offset)
|
||||
|
||||
for (let i = 0, j = 0; j < len; i += 4) {
|
||||
const a = codes[string.charCodeAt(i)]
|
||||
const b = codes[string.charCodeAt(i + 1)]
|
||||
const c = codes[string.charCodeAt(i + 2)]
|
||||
const d = codes[string.charCodeAt(i + 3)]
|
||||
|
||||
buffer[j++] = (a << 2) | (b >> 4)
|
||||
buffer[j++] = ((b & 15) << 4) | (c >> 2)
|
||||
buffer[j++] = ((c & 3) << 6) | (d & 63)
|
||||
}
|
||||
|
||||
return len
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
byteLength,
|
||||
toString,
|
||||
write
|
||||
}
|
||||
51
resources/app/node_modules/b4a/lib/hex.js
generated
vendored
Normal file
51
resources/app/node_modules/b4a/lib/hex.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
function byteLength (string) {
|
||||
return string.length >>> 1
|
||||
}
|
||||
|
||||
function toString (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
buffer = new DataView(buffer.buffer, buffer.byteOffset, len)
|
||||
|
||||
let result = ''
|
||||
let i = 0
|
||||
|
||||
for (let n = len - (len % 4); i < n; i += 4) {
|
||||
result += buffer.getUint32(i).toString(16).padStart(8, '0')
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
result += buffer.getUint8(i).toString(16).padStart(2, '0')
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function write (buffer, string, offset = 0, length = byteLength(string)) {
|
||||
const len = Math.min(length, buffer.byteLength - offset)
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const a = hexValue(string.charCodeAt(i * 2))
|
||||
const b = hexValue(string.charCodeAt(i * 2 + 1))
|
||||
|
||||
if (a === undefined || b === undefined) {
|
||||
return buffer.subarray(0, i)
|
||||
}
|
||||
|
||||
buffer[offset + i] = (a << 4) | b
|
||||
}
|
||||
|
||||
return len
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
byteLength,
|
||||
toString,
|
||||
write
|
||||
}
|
||||
|
||||
function hexValue (char) {
|
||||
if (char >= 0x30 && char <= 0x39) return char - 0x30
|
||||
if (char >= 0x41 && char <= 0x46) return char - 0x41 + 10
|
||||
if (char >= 0x61 && char <= 0x66) return char - 0x61 + 10
|
||||
}
|
||||
40
resources/app/node_modules/b4a/lib/utf16le.js
generated
vendored
Normal file
40
resources/app/node_modules/b4a/lib/utf16le.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
function byteLength (string) {
|
||||
return string.length * 2
|
||||
}
|
||||
|
||||
function toString (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
let result = ''
|
||||
|
||||
for (let i = 0; i < len - 1; i += 2) {
|
||||
result += String.fromCharCode(buffer[i] + (buffer[i + 1] * 256))
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function write (buffer, string, offset = 0, length = byteLength(string)) {
|
||||
const len = Math.min(length, buffer.byteLength - offset)
|
||||
|
||||
let units = len
|
||||
|
||||
for (let i = 0; i < string.length; ++i) {
|
||||
if ((units -= 2) < 0) break
|
||||
|
||||
const c = string.charCodeAt(i)
|
||||
const hi = c >> 8
|
||||
const lo = c % 256
|
||||
|
||||
buffer[offset + i * 2] = lo
|
||||
buffer[offset + i * 2 + 1] = hi
|
||||
}
|
||||
|
||||
return len
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
byteLength,
|
||||
toString,
|
||||
write
|
||||
}
|
||||
145
resources/app/node_modules/b4a/lib/utf8.js
generated
vendored
Normal file
145
resources/app/node_modules/b4a/lib/utf8.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
function byteLength (string) {
|
||||
let length = 0
|
||||
|
||||
for (let i = 0, n = string.length; i < n; i++) {
|
||||
const code = string.charCodeAt(i)
|
||||
|
||||
if (code >= 0xd800 && code <= 0xdbff && i + 1 < n) {
|
||||
const code = string.charCodeAt(i + 1)
|
||||
|
||||
if (code >= 0xdc00 && code <= 0xdfff) {
|
||||
length += 4
|
||||
i++
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if (code <= 0x7f) length += 1
|
||||
else if (code <= 0x7ff) length += 2
|
||||
else length += 3
|
||||
}
|
||||
|
||||
return length
|
||||
}
|
||||
|
||||
let toString
|
||||
|
||||
if (typeof TextDecoder !== 'undefined') {
|
||||
const decoder = new TextDecoder()
|
||||
|
||||
toString = function toString (buffer) {
|
||||
return decoder.decode(buffer)
|
||||
}
|
||||
} else {
|
||||
toString = function toString (buffer) {
|
||||
const len = buffer.byteLength
|
||||
|
||||
let output = ''
|
||||
let i = 0
|
||||
|
||||
while (i < len) {
|
||||
let byte = buffer[i]
|
||||
|
||||
if (byte <= 0x7f) {
|
||||
output += String.fromCharCode(byte)
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
let bytesNeeded = 0
|
||||
let codePoint = 0
|
||||
|
||||
if (byte <= 0xdf) {
|
||||
bytesNeeded = 1
|
||||
codePoint = byte & 0x1f
|
||||
} else if (byte <= 0xef) {
|
||||
bytesNeeded = 2
|
||||
codePoint = byte & 0x0f
|
||||
} else if (byte <= 0xf4) {
|
||||
bytesNeeded = 3
|
||||
codePoint = byte & 0x07
|
||||
}
|
||||
|
||||
if (len - i - bytesNeeded > 0) {
|
||||
let k = 0
|
||||
|
||||
while (k < bytesNeeded) {
|
||||
byte = buffer[i + k + 1]
|
||||
codePoint = (codePoint << 6) | (byte & 0x3f)
|
||||
k += 1
|
||||
}
|
||||
} else {
|
||||
codePoint = 0xfffd
|
||||
bytesNeeded = len - i
|
||||
}
|
||||
|
||||
output += String.fromCodePoint(codePoint)
|
||||
i += bytesNeeded + 1
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
||||
|
||||
let write
|
||||
|
||||
if (typeof TextEncoder !== 'undefined') {
|
||||
const encoder = new TextEncoder()
|
||||
|
||||
write = function write (buffer, string, offset = 0, length = byteLength(string)) {
|
||||
const len = Math.min(length, buffer.byteLength - offset)
|
||||
encoder.encodeInto(string, buffer.subarray(offset, offset + len))
|
||||
return len
|
||||
}
|
||||
} else {
|
||||
write = function write (buffer, string, offset = 0, length = byteLength(string)) {
|
||||
const len = Math.min(length, buffer.byteLength - offset)
|
||||
|
||||
buffer = buffer.subarray(offset, offset + len)
|
||||
|
||||
let i = 0
|
||||
let j = 0
|
||||
|
||||
while (i < string.length) {
|
||||
const code = string.codePointAt(i)
|
||||
|
||||
if (code <= 0x7f) {
|
||||
buffer[j++] = code
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
let count = 0
|
||||
let bits = 0
|
||||
|
||||
if (code <= 0x7ff) {
|
||||
count = 6
|
||||
bits = 0xc0
|
||||
} else if (code <= 0xffff) {
|
||||
count = 12
|
||||
bits = 0xe0
|
||||
} else if (code <= 0x1fffff) {
|
||||
count = 18
|
||||
bits = 0xf0
|
||||
}
|
||||
|
||||
buffer[j++] = bits | (code >> count)
|
||||
count -= 6
|
||||
|
||||
while (count >= 0) {
|
||||
buffer[j++] = 0x80 | ((code >> count) & 0x3f)
|
||||
count -= 6
|
||||
}
|
||||
|
||||
i += code >= 0x10000 ? 2 : 1
|
||||
}
|
||||
|
||||
return len
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
byteLength,
|
||||
toString,
|
||||
write
|
||||
}
|
||||
26
resources/app/node_modules/b4a/package.json
generated
vendored
Normal file
26
resources/app/node_modules/b4a/package.json
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "b4a",
|
||||
"version": "1.6.6",
|
||||
"description": "Bridging the gap between buffers and typed arrays",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"browser.js",
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"browser": {
|
||||
"./index.js": "./browser.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/b4a.git"
|
||||
},
|
||||
"author": "Holepunch",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://github.com/holepunchto/b4a#readme",
|
||||
"devDependencies": {
|
||||
"brittle": "^1.3.5",
|
||||
"nanobench": "^2.1.1",
|
||||
"standard": "^16.0.3"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user