Initial
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user