Initial commit - Dutchie dispensary scraper

This commit is contained in:
Kelly
2025-11-28 19:45:44 -07:00
commit 5757a8e9bd
23375 changed files with 3788799 additions and 0 deletions

View File

@@ -0,0 +1 @@
/** @const */ export declare const DEFAULT_ENCODING = "utf-8";

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** @const */ exports.DEFAULT_ENCODING = 'utf-8';
//# sourceMappingURL=defaultEncoding.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"defaultEncoding.js","sourceRoot":"","sources":["../../../src/encoding/defaultEncoding.ts"],"names":[],"mappings":";;AACA,aAAa,CAAc,QAAA,gBAAgB,GAAG,OAAO,CAAC"}

View File

@@ -0,0 +1,16 @@
import { Decoder } from '../common/Decoder';
import { Encoder } from '../common/Encoder';
declare type XCoderFactory<Tncoder = Encoder | Decoder> = ({ fatal: boolean }: {
fatal: any;
}) => Tncoder;
declare type Encoders = {
[s: string]: XCoderFactory<Encoder>;
};
declare type Decoders = {
[s: string]: XCoderFactory<Decoder>;
};
/** @type {Object.<string, function({fatal:boolean}): Encoder>} */
/** @type {Object.<string, function({fatal:boolean}): Decoder>} */
export declare const encoders: Encoders;
export declare const decoders: Decoders;
export {};

View File

@@ -0,0 +1,170 @@
"use strict";
// This is free and unencumbered software released into the public domain.
// See LICENSE.md for more information.
Object.defineProperty(exports, "__esModule", { value: true });
var big5_1 = require("../coders/big5");
var euc_jp_1 = require("../coders/euc-jp");
var euc_kr_1 = require("../coders/euc-kr");
var gb18030_1 = require("../coders/gb18030");
var iso_2022_jp_1 = require("../coders/iso-2022-jp");
var shift_jis_1 = require("../coders/shift-jis");
var single_byte_1 = require("../coders/single-byte");
var utf_16_1 = require("../coders/utf-16");
var utf_8_1 = require("../coders/utf-8");
var x_user_defined_1 = require("../coders/x-user-defined");
var encodings_1 = require("./encodings");
var indexes_1 = require("./indexes");
var encoding_indexes_provider_1 = require("./encoding-indexes-provider");
//
// Utilities
//
// import './encoding/utilities';
//
// Implementation of Encoding specification
// https://encoding.spec.whatwg.org/
//
//
// 4. Terminology
//
// import './encoding/terminology';
//
// 5. Encodings
//
// import "./encoding/encodings";
//
// 6. Indexes
//
// import './encoding/indexes';
var encodingIndexes = encoding_indexes_provider_1.getEncodingIndexes();
// Registry of of encoder/decoder factories, by encoding name.
/** @type {Object.<string, function({fatal:boolean}): Encoder>} */
// const encoders: Encoders = {};
/** @type {Object.<string, function({fatal:boolean}): Decoder>} */
// const decoders: Decoders = {};
//
// 10. Legacy single-byte encodings
//
// 10.1 single-byte decoder
// 10.2 single-byte encoder
exports.encoders = {
// 9.1 utf-8
// 9.1.1 utf-8 decoder
// 9.1.2 utf-8 encoder
/** @param {{fatal: boolean}} options */
'UTF-8': function (options) { return new utf_8_1.UTF8Encoder(options); },
//
// 11. Legacy multi-byte Chinese (simplified) encodings
//
// 11.1 gbk
// 11.1.1 gbk decoder
// gbk's decoder is gb18030's decoder.
// 11.1.2 gbk encoder
// gbk's encoder is gb18030's encoder with its gbk flag set.
/** @param {{fatal: boolean}} options */
'GBK': function (options) { return new gb18030_1.GB18030Encoder(options, true); },
// 11.2 gb18030
// 11.2.1 gb18030 decoder
// 11.2.2 gb18030 encoder
/** @param {{fatal: boolean}} options */
'gb18030': function (options) { return new gb18030_1.GB18030Encoder(options); },
//
// 12. Legacy multi-byte Chinese (traditional) encodings
//
// 12.1 Big5
// 12.1.1 Big5 decoder
// 12.1.2 Big5 encoder
/** @param {{fatal: boolean}} options */
'Big5': function (options) { return new big5_1.Big5Encoder(options); },
//
// 13. Legacy multi-byte Japanese encodings
//
// 13.1 euc-jp
// 13.1.1 euc-jp decoder
// 13.1.2 euc-jp encoder
/** @param {{fatal: boolean}} options */
'EUC-JP': function (options) { return new euc_jp_1.EUCJPEncoder(options); },
// 13.2 iso-2022-jp
// 13.2.1 iso-2022-jp decoder
// 13.2.2 iso-2022-jp encoder
/** @param {{fatal: boolean}} options */
'ISO-2022-JP': function (options) { return new iso_2022_jp_1.ISO2022JPEncoder(options); },
// 13.3 Shift_JIS
// 13.3.1 Shift_JIS decoder
// 13.3.2 Shift_JIS encoder
/** @param {{fatal: boolean}} options */
'Shift_JIS': function (options) { return new shift_jis_1.ShiftJISEncoder(options); },
//
// 14. Legacy multi-byte Korean encodings
//
// 14.1 euc-kr
// 14.1.1 euc-kr decoder
// 14.1.2 euc-kr encoder
/** @param {{fatal: boolean}} options */
'EUC-KR': function (options) { return new euc_kr_1.EUCKREncoder(options); },
//
// 15. Legacy miscellaneous encodings
//
// 15.1 replacement
// Not needed - API throws RangeError
// 15.2 Common infrastructure for utf-16be and utf-16le
// 15.2.1 shared utf-16 decoder
// 15.2.2 shared utf-16 encoder
// 15.3 utf-16be
// 15.3.1 utf-16be decoder
/** @param {{fatal: boolean}} options */
'UTF-16BE': function (options) { return new utf_16_1.UTF16Encoder(true, options); },
// 15.3.2 utf-16be encoder
// 15.4 utf-16le
// 15.4.1 utf-16le decoder
/** @param {{fatal: boolean}} options */
'UTF-16LE': function (options) { return new utf_16_1.UTF16Encoder(false, options); },
// 15.4.2 utf-16le encoder
// 15.5 x-user-defined
// 15.5.1 x-user-defined decoder
// 15.5.2 x-user-defined encoder
/** @param {{fatal: boolean}} options */
'x-user-defined': function (options) { return new x_user_defined_1.XUserDefinedEncoder(options); },
};
exports.decoders = {
/** @param {{fatal: boolean}} options */
'UTF-8': function (options) { return new utf_8_1.UTF8Decoder(options); },
/** @param {{fatal: boolean}} options */
'GBK': function (options) { return new gb18030_1.GB18030Decoder(options); },
/** @param {{fatal: boolean}} options */
'gb18030': function (options) { return new gb18030_1.GB18030Decoder(options); },
/** @param {{fatal: boolean}} options */
'Big5': function (options) { return new big5_1.Big5Decoder(options); },
/** @param {{fatal: boolean}} options */
'EUC-JP': function (options) { return new euc_jp_1.EUCJPDecoder(options); },
/** @param {{fatal: boolean}} options */
'ISO-2022-JP': function (options) { return new iso_2022_jp_1.ISO2022JPDecoder(options); },
/** @param {{fatal: boolean}} options */
'Shift_JIS': function (options) { return new shift_jis_1.ShiftJISDecoder(options); },
/** @param {{fatal: boolean}} options */
'EUC-KR': function (options) { return new euc_kr_1.EUCKRDecoder(options); },
/** @param {{fatal: boolean}} options */
'UTF-16BE': function (options) { return new utf_16_1.UTF16Decoder(true, options); },
/** @param {{fatal: boolean}} options */
'UTF-16LE': function (options) { return new utf_16_1.UTF16Decoder(false, options); },
/** @param {{fatal: boolean}} options */
'x-user-defined': function (options) { return new x_user_defined_1.XUserDefinedDecoder(options); },
};
if (encodingIndexes) {
encodings_1.encodings.forEach(function (category) {
if (category.heading !== 'Legacy single-byte encodings')
return;
category.encodings.forEach(function (encoding) {
var name = encoding.name;
var idx = indexes_1.index(name.toLowerCase());
/** @param {{fatal: boolean}} options */
exports.decoders[name] = function (options) {
return new single_byte_1.SingleByteDecoder(idx, options);
};
/** @param {{fatal: boolean}} options */
exports.encoders[name] = function (options) {
return new single_byte_1.SingleByteEncoder(idx, options);
};
});
});
}
//# sourceMappingURL=encoding-factory.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encoding-factory.js","sourceRoot":"","sources":["../../../src/encoding/encoding-factory.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,uCAAuC;;AAEvC,uCAA0D;AAC1D,2CAA8D;AAC9D,2CAA8D;AAC9D,6CAAmE;AACnE,qDAA2E;AAC3E,iDAAuE;AACvE,qDAA6E;AAC7E,2CAA8D;AAC9D,yCAA2D;AAC3D,2DAAoF;AAGpF,yCAAwC;AACxC,qCAAkC;AAClC,yEAAiE;AAGjE,EAAE;AACF,YAAY;AACZ,EAAE;AAEF,iCAAiC;AAEjC,EAAE;AACF,2CAA2C;AAC3C,oCAAoC;AACpC,EAAE;AAEF,EAAE;AACF,iBAAiB;AACjB,EAAE;AAEF,mCAAmC;AAEnC,EAAE;AACF,eAAe;AACf,EAAE;AAEF,iCAAiC;AAEjC,EAAE;AACF,aAAa;AACb,EAAE;AAEF,+BAA+B;AAE/B,IAAM,eAAe,GAAG,8CAAkB,EA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AwC;YACxC,gBAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,OAA4B;gBACrD,OAAO,IAAI,+BAAiB,CAAC,GAAe,EAAE,OAAO,CAAC,CAAC;YACzD,CAAC,CAAC;YACF,wCAAwC;YACxC,gBAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,OAA4B;gBACrD,OAAO,IAAI,+BAAiB,CAAC,GAAe,EAAE,OAAO,CAAC,CAAC;YACzD,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}

View File

@@ -0,0 +1,4 @@
export declare type EncodingIndexMap = {
[x: string]: number[];
};
export declare function getEncodingIndexes(): EncodingIndexMap;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var getGlobalScope_1 = require("../helper/getGlobalScope");
var _encodingIndexes;
function checkForEncodingIndexes() {
if (typeof TextEncodingIndexes !== 'undefined')
return TextEncodingIndexes.encodingIndexes;
var glo = getGlobalScope_1.getGlobalScope();
if (!glo)
return null;
if ('TextEncodingIndexes' in glo)
return global['TextEncodingIndexes']['encodingIndexes'];
if ('encoding-indexes' in glo)
return global['encodingIndexes'];
return null;
}
function getEncodingIndexes() {
if (_encodingIndexes) {
return _encodingIndexes;
}
var indexes = checkForEncodingIndexes();
if (!indexes) {
return null;
}
_encodingIndexes = indexes;
return indexes;
}
exports.getEncodingIndexes = getEncodingIndexes;
//# sourceMappingURL=encoding-indexes-provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encoding-indexes-provider.js","sourceRoot":"","sources":["../../../src/encoding/encoding-indexes-provider.ts"],"names":[],"mappings":";;AAAA,2DAA0D;AAS1D,IAAI,gBAAkC,CAAC;AAEvC,SAAS,uBAAuB;IAE9B,IAAI,OAAO,mBAAmB,KAAK,WAAW;QAC5C,OAAO,mBAAmB,CAAC,eAAe,CAAC;IAE7C,IAAM,GAAG,GAAG,+BAAc,EAAE,CAAC;IAE7B,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAEtB,IAAI,qBAAqB,IAAI,GAAG;QAC9B,OAAO,MAAM,CAAC,qBAAqB,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAE1D,IAAI,kBAAkB,IAAI,GAAG;QAC3B,OAAO,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAEnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,kBAAkB;IAEhC,IAAI,gBAAgB,EAAE;QACpB,OAAO,gBAAgB,CAAC;KACzB;IAED,IAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,gBAAgB,GAAG,OAAO,CAAC;IAE3B,OAAO,OAAO,CAAC;AACjB,CAAC;AAfD,gDAeC"}

View File

@@ -0,0 +1,35 @@
/**
* @param {boolean} fatal If true, decoding errors raise an exception.
* @param {number=} opt_code_point Override the standard fallback code point.
* @return {number} The code point to insert on a decoding error.
*/
export declare function decoderError(fatal: boolean, opt_code_point?: number | undefined): number;
/**
* @param {number} code_point The code point that could not be encoded.
* @return {number} Always throws, no value is actually returned.
*/
export declare function encoderError(code_point: number): number;
/**
* @param {string} label The encoding label.
* @return {?{name:string,labels:Array.<string>}}
*/
export declare function getEncoding(label: string): {
name: string;
labels: Array<string>;
} | null;
/**
* Encodings table: https://encoding.spec.whatwg.org/encodings.json
* @const
* @type {!Array.<{
* heading: string,
* encodings: Array.<{name:string,labels:Array.<string>}>
* }>}
*/
declare const encodings: {
heading: string;
encodings: {
name: string;
labels: string[];
}[];
}[];
export { encodings };

View File

@@ -0,0 +1,431 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @param {boolean} fatal If true, decoding errors raise an exception.
* @param {number=} opt_code_point Override the standard fallback code point.
* @return {number} The code point to insert on a decoding error.
*/
function decoderError(fatal, opt_code_point) {
if (opt_code_point === void 0) { opt_code_point = undefined; }
if (fatal)
throw TypeError("Decoder error");
return opt_code_point || 0xfffd;
}
exports.decoderError = decoderError;
/**
* @param {number} code_point The code point that could not be encoded.
* @return {number} Always throws, no value is actually returned.
*/
function encoderError(code_point) {
throw TypeError("The code point " + code_point + " could not be encoded.");
}
exports.encoderError = encoderError;
// 5.2 Names and labels
// TODO: Define @typedef for Encoding: {name:string,labels:Array.<string>}
// https://github.com/google/closure-compiler/issues/247
/**
* @param {string} label The encoding label.
* @return {?{name:string,labels:Array.<string>}}
*/
function getEncoding(label) {
// 1. Remove any leading and trailing ASCII whitespace from label.
var keyLabel = String(label).trim().toLowerCase();
// 2. If label is an ASCII case-insensitive match for any of the
// labels listed in the table below, return the corresponding
// encoding, and failure otherwise.
if (keyLabel in label_to_encoding) {
return label_to_encoding[keyLabel];
}
return null;
}
exports.getEncoding = getEncoding;
/**
* Encodings table: https://encoding.spec.whatwg.org/encodings.json
* @const
* @type {!Array.<{
* heading: string,
* encodings: Array.<{name:string,labels:Array.<string>}>
* }>}
*/
var encodings = [
{
encodings: [
{
labels: ["unicode-1-1-utf-8", "utf-8", "utf8"],
name: "UTF-8",
},
],
heading: "The Encoding",
},
{
encodings: [
{
labels: ["866", "cp866", "csibm866", "ibm866"],
name: "IBM866",
},
{
labels: [
"csisolatin2",
"iso-8859-2",
"iso-ir-101",
"iso8859-2",
"iso88592",
"iso_8859-2",
"iso_8859-2:1987",
"l2",
"latin2",
],
name: "ISO-8859-2",
},
{
labels: [
"csisolatin3",
"iso-8859-3",
"iso-ir-109",
"iso8859-3",
"iso88593",
"iso_8859-3",
"iso_8859-3:1988",
"l3",
"latin3",
],
name: "ISO-8859-3",
},
{
labels: [
"csisolatin4",
"iso-8859-4",
"iso-ir-110",
"iso8859-4",
"iso88594",
"iso_8859-4",
"iso_8859-4:1988",
"l4",
"latin4",
],
name: "ISO-8859-4",
},
{
labels: [
"csisolatincyrillic",
"cyrillic",
"iso-8859-5",
"iso-ir-144",
"iso8859-5",
"iso88595",
"iso_8859-5",
"iso_8859-5:1988",
],
name: "ISO-8859-5",
},
{
labels: [
"arabic",
"asmo-708",
"csiso88596e",
"csiso88596i",
"csisolatinarabic",
"ecma-114",
"iso-8859-6",
"iso-8859-6-e",
"iso-8859-6-i",
"iso-ir-127",
"iso8859-6",
"iso88596",
"iso_8859-6",
"iso_8859-6:1987",
],
name: "ISO-8859-6",
},
{
labels: [
"csisolatingreek",
"ecma-118",
"elot_928",
"greek",
"greek8",
"iso-8859-7",
"iso-ir-126",
"iso8859-7",
"iso88597",
"iso_8859-7",
"iso_8859-7:1987",
"sun_eu_greek",
],
name: "ISO-8859-7",
},
{
labels: [
"csiso88598e",
"csisolatinhebrew",
"hebrew",
"iso-8859-8",
"iso-8859-8-e",
"iso-ir-138",
"iso8859-8",
"iso88598",
"iso_8859-8",
"iso_8859-8:1988",
"visual",
],
name: "ISO-8859-8",
},
{
labels: ["csiso88598i", "iso-8859-8-i", "logical"],
name: "ISO-8859-8-I",
},
{
labels: [
"csisolatin6",
"iso-8859-10",
"iso-ir-157",
"iso8859-10",
"iso885910",
"l6",
"latin6",
],
name: "ISO-8859-10",
},
{
labels: ["iso-8859-13", "iso8859-13", "iso885913"],
name: "ISO-8859-13",
},
{
labels: ["iso-8859-14", "iso8859-14", "iso885914"],
name: "ISO-8859-14",
},
{
labels: [
"csisolatin9",
"iso-8859-15",
"iso8859-15",
"iso885915",
"iso_8859-15",
"l9",
],
name: "ISO-8859-15",
},
{
labels: ["iso-8859-16"],
name: "ISO-8859-16",
},
{
labels: ["cskoi8r", "koi", "koi8", "koi8-r", "koi8_r"],
name: "KOI8-R",
},
{
labels: ["koi8-ru", "koi8-u"],
name: "KOI8-U",
},
{
labels: ["csmacintosh", "mac", "macintosh", "x-mac-roman"],
name: "macintosh",
},
{
labels: [
"dos-874",
"iso-8859-11",
"iso8859-11",
"iso885911",
"tis-620",
"windows-874",
],
name: "windows-874",
},
{
labels: ["cp1250", "windows-1250", "x-cp1250"],
name: "windows-1250",
},
{
labels: ["cp1251", "windows-1251", "x-cp1251"],
name: "windows-1251",
},
{
labels: [
"ansi_x3.4-1968",
"cp1252",
"cp819",
"ibm819",
"iso-ir-100",
"windows-1252",
"x-cp1252",
],
name: "windows-1252",
},
{
labels: [
"ascii",
"us-ascii",
"iso-8859-1",
"iso8859-1",
"iso88591",
"iso_8859-1",
"iso_8859-1:1987",
"l1",
"latin1",
"csisolatin1",
],
name: "iso-8859-1",
},
{
labels: ["cp1253", "windows-1253", "x-cp1253"],
name: "windows-1253",
},
{
labels: [
"cp1254",
"csisolatin5",
"iso-8859-9",
"iso-ir-148",
"iso8859-9",
"iso88599",
"iso_8859-9",
"iso_8859-9:1989",
"l5",
"latin5",
"windows-1254",
"x-cp1254",
],
name: "windows-1254",
},
{
labels: ["cp1255", "windows-1255", "x-cp1255"],
name: "windows-1255",
},
{
labels: ["cp1256", "windows-1256", "x-cp1256"],
name: "windows-1256",
},
{
labels: ["cp1257", "windows-1257", "x-cp1257"],
name: "windows-1257",
},
{
labels: ["cp1258", "windows-1258", "x-cp1258"],
name: "windows-1258",
},
{
labels: ["x-mac-cyrillic", "x-mac-ukrainian"],
name: "x-mac-cyrillic",
},
],
heading: "Legacy single-byte encodings",
},
{
encodings: [
{
labels: [
"chinese",
"csgb2312",
"csiso58gb231280",
"gb2312",
"gb_2312",
"gb_2312-80",
"gbk",
"iso-ir-58",
"x-gbk",
],
name: "GBK",
},
{
labels: ["gb18030"],
name: "gb18030",
},
],
heading: "Legacy multi-byte Chinese (simplified) encodings",
},
{
encodings: [
{
labels: ["big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5"],
name: "Big5",
},
],
heading: "Legacy multi-byte Chinese (traditional) encodings",
},
{
encodings: [
{
labels: ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"],
name: "EUC-JP",
},
{
labels: ["csiso2022jp", "iso-2022-jp"],
name: "ISO-2022-JP",
},
{
labels: [
"csshiftjis",
"ms932",
"ms_kanji",
"shift-jis",
"shift_jis",
"sjis",
"windows-31j",
"x-sjis",
],
name: "Shift_JIS",
},
],
heading: "Legacy multi-byte Japanese encodings",
},
{
encodings: [
{
labels: [
"cseuckr",
"csksc56011987",
"euc-kr",
"iso-ir-149",
"korean",
"ks_c_5601-1987",
"ks_c_5601-1989",
"ksc5601",
"ksc_5601",
"windows-949",
],
name: "EUC-KR",
},
],
heading: "Legacy multi-byte Korean encodings",
},
{
encodings: [
{
labels: [
"csiso2022kr",
"hz-gb-2312",
"iso-2022-cn",
"iso-2022-cn-ext",
"iso-2022-kr",
],
name: "replacement",
},
{
labels: ["utf-16be"],
name: "UTF-16BE",
},
{
labels: ["utf-16", "utf-16le"],
name: "UTF-16LE",
},
{
labels: ["x-user-defined"],
name: "x-user-defined",
},
],
heading: "Legacy miscellaneous encodings",
},
];
exports.encodings = encodings;
// Label to encoding registry.
/** @type {Object.<string,{name:string,labels:Array.<string>}>} */
var label_to_encoding = {};
encodings.forEach(function (category) {
category.encodings.forEach(function (encoding) {
encoding.labels.forEach(function (label) {
label_to_encoding[label] = encoding;
});
});
});
//# sourceMappingURL=encodings.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
/** @const */
export declare const finished = -1;

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// 5.1 Encoders and decoders
/** @const */
exports.finished = -1;
//# sourceMappingURL=finished.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"finished.js","sourceRoot":"","sources":["../../../src/encoding/finished.ts"],"names":[],"mappings":";;AAAA,4BAA4B;AAC5B,aAAa;AACA,QAAA,QAAQ,GAAG,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,45 @@
/**
* @param {number} pointer The |pointer| to search for.
* @param {(!Array.<?number>|undefined)} index The |index| to search within.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in |index|.
*/
export declare function indexCodePointFor(pointer: number, index: (Array<number | null> | undefined)): number | null;
/**
* @param {number} code_point The |code point| to search for.
* @param {!Array.<?number>} index The |index| to search within.
* @return {?number} The first pointer corresponding to |code point| in
* |index|, or null if |code point| is not in |index|.
*/
export declare function indexPointerFor(code_point: number, index: Array<number | null>): number | null;
/**
* @param {string} name Name of the index.
* @return {(!Array.<number>|!Array.<Array.<number>>)}
* */
export declare function index(name: string): number[] | number[][];
/**
* @param {number} pointer The |pointer| to search for in the gb18030 index.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in the gb18030 index.
*/
export declare function indexGB18030RangesCodePointFor(pointer: number): number | null;
/**
* @param {number} code_point The |code point| to locate in the gb18030 index.
* @return {number} The first pointer corresponding to |code point| in the
* gb18030 index.
*/
export declare function indexGB18030RangesPointerFor(code_point: number): number;
/**
* @param {number} code_point The |code_point| to search for in the Shift_JIS
* index.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in the Shift_JIS index.
*/
export declare function indexShiftJISPointerFor(code_point: number): number | null;
/**
* @param {number} code_point The |code_point| to search for in the big5
* index.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in the big5 index.
*/
export declare function indexBig5PointerFor(code_point: number): number | null;

View File

@@ -0,0 +1,154 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var getArrayVal_1 = require("../helper/getArrayVal");
var utilities_1 = require("./utilities");
var encoding_indexes_provider_1 = require("./encoding-indexes-provider");
/**
* @param {number} pointer The |pointer| to search for.
* @param {(!Array.<?number>|undefined)} index The |index| to search within.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in |index|.
*/
function indexCodePointFor(pointer, index) {
if (!index)
return null;
return index[pointer] || null;
}
exports.indexCodePointFor = indexCodePointFor;
/**
* @param {number} code_point The |code point| to search for.
* @param {!Array.<?number>} index The |index| to search within.
* @return {?number} The first pointer corresponding to |code point| in
* |index|, or null if |code point| is not in |index|.
*/
function indexPointerFor(code_point, index) {
var pointer = index.indexOf(code_point);
return pointer === -1 ? null : pointer;
}
exports.indexPointerFor = indexPointerFor;
/**
* @param {string} name Name of the index.
* @return {(!Array.<number>|!Array.<Array.<number>>)}
* */
function index(name) {
var encodingIndexes = encoding_indexes_provider_1.getEncodingIndexes();
if (!encodingIndexes) {
throw Error("Indexes missing." +
" Did you forget to include encoding-indexes.js first?");
}
return encodingIndexes[name];
}
exports.index = index;
/**
* @param {number} pointer The |pointer| to search for in the gb18030 index.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in the gb18030 index.
*/
function indexGB18030RangesCodePointFor(pointer) {
// 1. If pointer is greater than 39419 and less than 189000, or
// pointer is greater than 1237575, return null.
if ((pointer > 39419 && pointer < 189000) || (pointer > 1237575))
return null;
// 2. If pointer is 7457, return code point U+E7C7.
if (pointer === 7457)
return 0xE7C7;
// 3. Let offset be the last pointer in index gb18030 ranges that
// is equal to or less than pointer and let code point offset be
// its corresponding code point.
var offset = 0;
var code_point_offset = 0;
var idx = index('gb18030-ranges');
for (var i = 0; i < idx.length; ++i) {
/** @type {!Array.<number>} */
var entry = getArrayVal_1.getArrayVal(idx[i]);
if (entry[0] <= pointer) {
offset = entry[0];
code_point_offset = entry[1];
}
else {
break;
}
}
// 4. Return a code point whose value is code point offset +
// pointer offset.
return code_point_offset + pointer - offset;
}
exports.indexGB18030RangesCodePointFor = indexGB18030RangesCodePointFor;
/**
* @param {number} code_point The |code point| to locate in the gb18030 index.
* @return {number} The first pointer corresponding to |code point| in the
* gb18030 index.
*/
function indexGB18030RangesPointerFor(code_point) {
// 1. If code point is U+E7C7, return pointer 7457.
if (code_point === 0xE7C7)
return 7457;
// 2. Let offset be the last code point in index gb18030 ranges
// that is equal to or less than code point and let pointer offset
// be its corresponding pointer.
var offset = 0;
var pointer_offset = 0;
var idx = index('gb18030-ranges');
for (var i = 0; i < idx.length; ++i) {
var idxVal = idx[i];
/** @type {!Array.<number>} */
var entry = getArrayVal_1.getArrayVal(idxVal);
if (entry[1] <= code_point) {
offset = entry[1];
pointer_offset = entry[0];
}
else {
break;
}
}
// 3. Return a pointer whose value is pointer offset + code point
// offset.
return pointer_offset + code_point - offset;
}
exports.indexGB18030RangesPointerFor = indexGB18030RangesPointerFor;
/**
* @param {number} code_point The |code_point| to search for in the Shift_JIS
* index.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in the Shift_JIS index.
*/
function indexShiftJISPointerFor(code_point) {
// 1. Let index be index jis0208 excluding all entries whose
// pointer is in the range 8272 to 8835, inclusive.
shift_jis_index = shift_jis_index ||
index('jis0208').map(function (code_point, pointer) {
return utilities_1.inRange(pointer, 8272, 8835) ? null : code_point;
});
var index_ = shift_jis_index;
// 2. Return the index pointer for code point in index.
return index_.indexOf(code_point);
}
exports.indexShiftJISPointerFor = indexShiftJISPointerFor;
var shift_jis_index;
/**
* @param {number} code_point The |code_point| to search for in the big5
* index.
* @return {?number} The code point corresponding to |pointer| in |index|,
* or null if |code point| is not in the big5 index.
*/
function indexBig5PointerFor(code_point) {
// 1. Let index be index Big5 excluding all entries whose pointer
big5_index_no_hkscs = big5_index_no_hkscs ||
index('big5').map(function (code_point, pointer) {
return (pointer < (0xA1 - 0x81) * 157) ? null : code_point;
});
var index_ = big5_index_no_hkscs;
// 2. If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or
// U+5345, return the last pointer corresponding to code point in
// index.
if (code_point === 0x2550 || code_point === 0x255E ||
code_point === 0x2561 || code_point === 0x256A ||
code_point === 0x5341 || code_point === 0x5345) {
return index_.lastIndexOf(code_point);
}
// 3. Return the index pointer for code point in index.
return indexPointerFor(code_point, index_);
}
exports.indexBig5PointerFor = indexBig5PointerFor;
var big5_index_no_hkscs;
//# sourceMappingURL=indexes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"indexes.js","sourceRoot":"","sources":["../../../src/encoding/indexes.ts"],"names":[],"mappings":";;AAAA,qDAAoD;AACpD,yCAAsC;AACtC,yEAAiE;AAEjE;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,OAAe,EAAE,KAAyC;IAC1F,IAAI,CAAC,KAAK;QAA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,CAAC,GAAG,CAAC,UAAU,UAAU,EAAE,OAAO;YAC9D,OAAO,mBAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,IAAM,MAAM,GAAG,eAAe,CAAC;IAE/B,uDAAuD;IACvD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC;AAXD,0DAWC;AACD,IAAI,eAAe,CAAC;AAEpB;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,UAAkB;IACpD,iEAAiE;IACjE,mBAAmB,GAAG,mBAAmB;QACtC,KAAK,CAAC,MAAM,CAAc,CAAC,GAAG,CAAC,UAAC,UAAU,EAAE,OAAO;YAClD,OAAA,CAAC,OAAO,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU;QAAnD,CAAmD,CACpD,CAAC;IACJ,IAAM,MAAM,GAAG,mBAAmB,CAAC;IAEnC,iEAAiE;IACjE,iEAAiE;IACjE,SAAS;IACT,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,MAAM;QAChD,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,MAAM;QAC9C,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,MAAM,EAAE;QAChD,OAAO,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;KACvC;IAED,uDAAuD;IACvD,OAAO,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAnBD,kDAmBC;AACD,IAAI,mBAAmB,CAAC"}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TextDecoder_1 = require("../common/TextDecoder");
var TextEncoder_1 = require("../common/TextEncoder");
if (!global['TextEncoder'])
global['TextEncoder'] = TextEncoder_1.TextEncoder;
if (!global['TextDecoder'])
global['TextDecoder'] = TextDecoder_1.TextDecoder;
//# sourceMappingURL=polyfill.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../../src/encoding/polyfill.ts"],"names":[],"mappings":";;AAAA,qDAAoD;AACpD,qDAAoD;AAEpD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACxB,MAAM,CAAC,aAAa,CAAC,GAAG,yBAAW,CAAC;AACtC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACxB,MAAM,CAAC,aAAa,CAAC,GAAG,yBAAW,CAAC"}

View File

@@ -0,0 +1,16 @@
/**
* An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.
* @param {number} a The number to test.
* @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.
*/
export declare function isASCIIByte(a: number): boolean;
/**
* An ASCII code point is a code point in the range U+0000 to
* U+007F, inclusive.
*/
export declare const isASCIICodePoint: typeof isASCIIByte;
/**
* End-of-stream is a special token that signifies no more tokens
* are in the stream.
* @const
*/ export declare const end_of_stream = -1;

View File

@@ -0,0 +1,29 @@
"use strict";
//
// Implementation of Encoding specification
// https://encoding.spec.whatwg.org/
//
Object.defineProperty(exports, "__esModule", { value: true });
//
// 4. Terminology
//
/**
* An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.
* @param {number} a The number to test.
* @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.
*/
function isASCIIByte(a) {
return 0x00 <= a && a <= 0x7F;
}
exports.isASCIIByte = isASCIIByte;
/**
* An ASCII code point is a code point in the range U+0000 to
* U+007F, inclusive.
*/
exports.isASCIICodePoint = isASCIIByte;
/**
* End-of-stream is a special token that signifies no more tokens
* are in the stream.
* @const
*/ exports.end_of_stream = -1;
//# sourceMappingURL=terminology.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"terminology.js","sourceRoot":"","sources":["../../../src/encoding/terminology.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,2CAA2C;AAC3C,oCAAoC;AACpC,EAAE;;AAEF,EAAE;AACF,iBAAiB;AACjB,EAAE;AAEF;;;;GAIG;AACH,SAAgB,WAAW,CAAC,CAAS;IACnC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAChC,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACU,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAG5C;;;;GAIG,CAAc,QAAA,aAAa,GAAG,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,30 @@
/**
* @param {number} a The number to test.
* @param {number} min The minimum value in the range, inclusive.
* @param {number} max The maximum value in the range, inclusive.
* @return {boolean} True if a >= min and a <= max.
*/
export declare function inRange(a: number, min: number, max: number): boolean;
/**
* @param {!Array.<*>} array The array to check.
* @param {*} item The item to look for in the array.
* @return {boolean} True if the item appears in the array.
*/
export declare function includes(array: Array<any>, item: any): boolean;
/**
* @param {*} o
* @return {Object}
*/
export declare function ToDictionary(o: any): {
[x: string]: any;
};
/**
* @param {string} string Input string of UTF-16 code units.
* @return {!Array.<number>} Code points.
*/
export declare function stringToCodePoints(string: string): Array<number>;
/**
* @param {!Array.<number>} code_points Array of code points.
* @return {string} string String of UTF-16 code units.
*/
export declare function codePointsToString(code_points: Array<number>): string;

View File

@@ -0,0 +1,119 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @param {number} a The number to test.
* @param {number} min The minimum value in the range, inclusive.
* @param {number} max The maximum value in the range, inclusive.
* @return {boolean} True if a >= min and a <= max.
*/
function inRange(a, min, max) {
return min <= a && a <= max;
}
exports.inRange = inRange;
/**
* @param {!Array.<*>} array The array to check.
* @param {*} item The item to look for in the array.
* @return {boolean} True if the item appears in the array.
*/
function includes(array, item) {
return array.indexOf(item) !== -1;
}
exports.includes = includes;
/**
* @param {*} o
* @return {Object}
*/
function ToDictionary(o) {
if (o === undefined || o === null)
return {};
if (o === Object(o))
return o;
throw TypeError('Could not convert argument to dictionary');
}
exports.ToDictionary = ToDictionary;
/**
* @param {string} string Input string of UTF-16 code units.
* @return {!Array.<number>} Code points.
*/
function stringToCodePoints(string) {
// https://heycam.github.io/webidl/#dfn-obtain-unicode
// 1. Let S be the DOMString value.
var s = String(string);
// 2. Let n be the length of S.
var n = s.length;
// 3. Initialize i to 0.
var i = 0;
// 4. Initialize U to be an empty sequence of Unicode characters.
var u = [];
// 5. While i < n:
while (i < n) {
// 1. Let c be the code unit in S at index i.
var c = s.charCodeAt(i);
// 2. Depending on the value of c:
// c < 0xD800 or c > 0xDFFF
if (c < 0xD800 || c > 0xDFFF) {
// Append to U the Unicode character with code point c.
u.push(c);
}
// 0xDC00 ≤ c ≤ 0xDFFF
else if (0xDC00 <= c && c <= 0xDFFF) {
// Append to U a U+FFFD REPLACEMENT CHARACTER.
u.push(0xFFFD);
}
// 0xD800 ≤ c ≤ 0xDBFF
else if (0xD800 <= c && c <= 0xDBFF) {
// 1. If i = n1, then append to U a U+FFFD REPLACEMENT
// CHARACTER.
if (i === n - 1) {
u.push(0xFFFD);
}
// 2. Otherwise, i < n1:
else {
// 1. Let d be the code unit in S at index i+1.
var d = s.charCodeAt(i + 1);
// 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:
if (0xDC00 <= d && d <= 0xDFFF) {
// 1. Let a be c & 0x3FF.
var a = c & 0x3FF;
// 2. Let b be d & 0x3FF.
var b = d & 0x3FF;
// 3. Append to U the Unicode character with code point
// 2^16+2^10*a+b.
u.push(0x10000 + (a << 10) + b);
// 4. Set i to i+1.
i += 1;
}
// 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a
// U+FFFD REPLACEMENT CHARACTER.
else {
u.push(0xFFFD);
}
}
}
// 3. Set i to i+1.
i += 1;
}
// 6. Return U.
return u;
}
exports.stringToCodePoints = stringToCodePoints;
/**
* @param {!Array.<number>} code_points Array of code points.
* @return {string} string String of UTF-16 code units.
*/
function codePointsToString(code_points) {
var s = '';
for (var i = 0; i < code_points.length; ++i) {
var cp = code_points[i];
if (cp <= 0xFFFF) {
s += String.fromCharCode(cp);
}
else {
cp -= 0x10000;
s += String.fromCharCode((cp >> 10) + 0xD800, (cp & 0x3FF) + 0xDC00);
}
}
return s;
}
exports.codePointsToString = codePointsToString;
//# sourceMappingURL=utilities.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/encoding/utilities.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IACzD,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;AAC9B,CAAC;AAFD,0BAEC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,KAAiB,EAAE,IAAS;IACnD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC,CAAC;AAFD,4BAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,CAAM;IACjC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7C,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,SAAS,CAAC,0CAA0C,CAAC,CAAC;AAC9D,CAAC;AAJD,oCAIC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,sDAAsD;IAEtD,mCAAmC;IACnC,IAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzB,+BAA+B;IAC/B,IAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAEnB,wBAAwB;IACxB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,iEAAiE;IACjE,IAAM,CAAC,GAAG,EAAE,CAAC;IAEb,kBAAkB;IAClB,OAAO,CAAC,GAAG,CAAC,E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