Add barcode-detector-api-polyfill dependency and update environment variable declarations in SvelteKit project
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
import { Stream } from "../../common/Stream";
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {Decoder}
|
||||
* @param {{fatal: boolean}} options
|
||||
*/
|
||||
export declare class ShiftJISDecoder {
|
||||
readonly fatal: boolean;
|
||||
Shift_JIS_lead: number;
|
||||
constructor(options: {
|
||||
fatal: boolean;
|
||||
});
|
||||
/**
|
||||
* @param {Stream} stream The stream of bytes being decoded.
|
||||
* @param {number} bite The next byte read from the stream.
|
||||
* @return {?(number|!Array.<number>)} The next code point(s)
|
||||
* decoded, or null if not enough data exists in the input
|
||||
* stream to decode a complete code point.
|
||||
*/
|
||||
handler(stream: Stream, bite: number): (number | Array<number>) | null;
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
import { decoderError } from "../../encoding/encodings";
|
||||
import { finished } from "../../encoding/finished";
|
||||
import { index, indexCodePointFor } from "../../encoding/indexes";
|
||||
import { end_of_stream, isASCIIByte } from "../../encoding/terminology";
|
||||
import { inRange } from "../../encoding/utilities";
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {Decoder}
|
||||
* @param {{fatal: boolean}} options
|
||||
*/
|
||||
export class ShiftJISDecoder {
|
||||
constructor(options) {
|
||||
this.fatal = options.fatal;
|
||||
// Shift_JIS's decoder has an associated Shift_JIS lead (initially
|
||||
// 0x00).
|
||||
/** @type {number} */ this.Shift_JIS_lead = 0x00;
|
||||
}
|
||||
/**
|
||||
* @param {Stream} stream The stream of bytes being decoded.
|
||||
* @param {number} bite The next byte read from the stream.
|
||||
* @return {?(number|!Array.<number>)} The next code point(s)
|
||||
* decoded, or null if not enough data exists in the input
|
||||
* stream to decode a complete code point.
|
||||
*/
|
||||
handler(stream, bite) {
|
||||
// 1. If byte is end-of-stream and Shift_JIS lead is not 0x00,
|
||||
// set Shift_JIS lead to 0x00 and return error.
|
||||
if (bite === end_of_stream && this.Shift_JIS_lead !== 0x00) {
|
||||
this.Shift_JIS_lead = 0x00;
|
||||
return decoderError(this.fatal);
|
||||
}
|
||||
// 2. If byte is end-of-stream and Shift_JIS lead is 0x00,
|
||||
// return finished.
|
||||
if (bite === end_of_stream && this.Shift_JIS_lead === 0x00)
|
||||
return finished;
|
||||
// 3. If Shift_JIS lead is not 0x00, let lead be Shift_JIS lead,
|
||||
// let pointer be null, set Shift_JIS lead to 0x00, and then run
|
||||
// these substeps:
|
||||
if (this.Shift_JIS_lead !== 0x00) {
|
||||
const lead = this.Shift_JIS_lead;
|
||||
let pointer = null;
|
||||
this.Shift_JIS_lead = 0x00;
|
||||
// 1. Let offset be 0x40, if byte is less than 0x7F, and 0x41
|
||||
// otherwise.
|
||||
const offset = (bite < 0x7F) ? 0x40 : 0x41;
|
||||
// 2. Let lead offset be 0x81, if lead is less than 0xA0, and
|
||||
// 0xC1 otherwise.
|
||||
const lead_offset = (lead < 0xA0) ? 0x81 : 0xC1;
|
||||
// 3. If byte is in the range 0x40 to 0x7E, inclusive, or 0x80
|
||||
// to 0xFC, inclusive, set pointer to (lead − lead offset) ×
|
||||
// 188 + byte − offset.
|
||||
if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFC))
|
||||
pointer = (lead - lead_offset) * 188 + bite - offset;
|
||||
// 4. If pointer is in the range 8836 to 10715, inclusive,
|
||||
// return a code point whose value is 0xE000 − 8836 + pointer.
|
||||
if (inRange(pointer, 8836, 10715))
|
||||
return 0xE000 - 8836 + pointer;
|
||||
// 5. Let code point be null, if pointer is null, and the
|
||||
// index code point for pointer in index jis0208 otherwise.
|
||||
const code_point = (pointer === null) ? null :
|
||||
indexCodePointFor(pointer, index('jis0208'));
|
||||
// 6. If code point is null and byte is an ASCII byte, prepend
|
||||
// byte to stream.
|
||||
if (code_point === null && isASCIIByte(bite))
|
||||
stream.prepend(bite);
|
||||
// 7. If code point is null, return error.
|
||||
if (code_point === null)
|
||||
return decoderError(this.fatal);
|
||||
// 8. Return a code point whose value is code point.
|
||||
return code_point;
|
||||
}
|
||||
// 4. If byte is an ASCII byte or 0x80, return a code point
|
||||
// whose value is byte.
|
||||
if (isASCIIByte(bite) || bite === 0x80)
|
||||
return bite;
|
||||
// 5. If byte is in the range 0xA1 to 0xDF, inclusive, return a
|
||||
// code point whose value is 0xFF61 − 0xA1 + byte.
|
||||
if (inRange(bite, 0xA1, 0xDF))
|
||||
return 0xFF61 - 0xA1 + bite;
|
||||
// 6. If byte is in the range 0x81 to 0x9F, inclusive, or 0xE0
|
||||
// to 0xFC, inclusive, set Shift_JIS lead to byte and return
|
||||
// continue.
|
||||
if (inRange(bite, 0x81, 0x9F) || inRange(bite, 0xE0, 0xFC)) {
|
||||
this.Shift_JIS_lead = bite;
|
||||
return null;
|
||||
}
|
||||
// 7. Return error.
|
||||
return decoderError(this.fatal);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ShiftJISDecoder.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ShiftJISDecoder.js","sourceRoot":"","sources":["../../../../src/coders/shift-jis/ShiftJISDecoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAM1B,YAAY,OAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,kEAAkE;QAClE,SAAS;QACT,qBAAqB,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IACnD,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAE,MAAc,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AEjC,yDAAyD;YACzD,2DAA2D;YAC3D,MAAM,UAAU,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC5C,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAa,CAAC,CAAC;YAE3D,8DAA8D;YAC9D,kBAAkB;YAClB,IAAI,UAAU,KAAK,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC;gBAC1C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEvB,0CAA0C;YAC1C,IAAI,UAAU,KAAK,IAAI;gBACrB,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAElC,oDAAoD;YACpD,OAAO,UAAU,CAAC;SACnB;QAED,2DAA2D;QAC3D,uBAAuB;QACvB,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,IAAI;YACpC,OAAO,IAAI,CAAC;QAEd,+DAA+D;QAC/D,kDAAkD;QAClD,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;YAC3B,OAAO,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;QAE9B,8DAA8D;QAC9D,4DAA4D;QAC5D,YAAY;QACZ,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;YAC1D,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,OAAO,IAAI,CAAC;SACb;QAED,mBAAmB;QACnB,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF"}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { Stream } from "../../common/Stream";
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {Encoder}
|
||||
* @param {{fatal: boolean}} options
|
||||
*/
|
||||
export declare class ShiftJISEncoder {
|
||||
readonly fatal: boolean;
|
||||
constructor(options: {
|
||||
fatal: boolean;
|
||||
});
|
||||
/**
|
||||
* @param {Stream} stream Input stream.
|
||||
* @param {number} code_point Next code point read from the stream.
|
||||
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
||||
*/
|
||||
handler(stream: Stream, code_point: number): (number | Array<number>);
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
import { encoderError } from "../../encoding/encodings";
|
||||
import { finished } from "../../encoding/finished";
|
||||
import { indexShiftJISPointerFor } from "../../encoding/indexes";
|
||||
import { end_of_stream, isASCIICodePoint } from "../../encoding/terminology";
|
||||
import { inRange } from "../../encoding/utilities";
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {Encoder}
|
||||
* @param {{fatal: boolean}} options
|
||||
*/
|
||||
export class ShiftJISEncoder {
|
||||
constructor(options) {
|
||||
this.fatal = options.fatal;
|
||||
}
|
||||
/**
|
||||
* @param {Stream} stream Input stream.
|
||||
* @param {number} code_point Next code point read from the stream.
|
||||
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
||||
*/
|
||||
handler(stream, code_point) {
|
||||
// 1. If code point is end-of-stream, return finished.
|
||||
if (code_point === end_of_stream)
|
||||
return finished;
|
||||
// 2. If code point is an ASCII code point or U+0080, return a
|
||||
// byte whose value is code point.
|
||||
if (isASCIICodePoint(code_point) || code_point === 0x0080)
|
||||
return code_point;
|
||||
// 3. If code point is U+00A5, return byte 0x5C.
|
||||
if (code_point === 0x00A5)
|
||||
return 0x5C;
|
||||
// 4. If code point is U+203E, return byte 0x7E.
|
||||
if (code_point === 0x203E)
|
||||
return 0x7E;
|
||||
// 5. If code point is in the range U+FF61 to U+FF9F, inclusive,
|
||||
// return a byte whose value is code point − 0xFF61 + 0xA1.
|
||||
if (inRange(code_point, 0xFF61, 0xFF9F))
|
||||
return code_point - 0xFF61 + 0xA1;
|
||||
// 6. If code point is U+2212, set it to U+FF0D.
|
||||
if (code_point === 0x2212)
|
||||
code_point = 0xFF0D;
|
||||
// 7. Let pointer be the index Shift_JIS pointer for code point.
|
||||
const pointer = indexShiftJISPointerFor(code_point);
|
||||
// 8. If pointer is null, return error with code point.
|
||||
if (pointer === null)
|
||||
return encoderError(code_point);
|
||||
// 9. Let lead be Math.floor(pointer / 188).
|
||||
const lead = Math.floor(pointer / 188);
|
||||
// 10. Let lead offset be 0x81, if lead is less than 0x1F, and
|
||||
// 0xC1 otherwise.
|
||||
const lead_offset = (lead < 0x1F) ? 0x81 : 0xC1;
|
||||
// 11. Let trail be pointer % 188.
|
||||
const trail = pointer % 188;
|
||||
// 12. Let offset be 0x40, if trail is less than 0x3F, and 0x41
|
||||
// otherwise.
|
||||
const offset = (trail < 0x3F) ? 0x40 : 0x41;
|
||||
// 13. Return two bytes whose values are lead + lead offset and
|
||||
// trail + offset.
|
||||
return [lead + lead_offset, trail + offset];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ShiftJISEncoder.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ShiftJISEncoder.js","sourceRoot":"","sources":["../../../../src/coders/shift-jis/ShiftJISEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAI1B,YAAY,OAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAc,EAAE,UAAkB;QACxC,sDAAsD;QACtD,IAAI,UAAU,KAAK,aAAa;YAC9B,OAAO,QAAQ,CAAC;QAElB,8DAA8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||
export * from './ShiftJISEncoder';
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export * from './ShiftJISDecoder';
|
||||
export * from './ShiftJISEncoder';
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/coders/shift-jis/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
||||
Reference in New Issue
Block a user