@loaders.gl/wms 3.3.0-alpha.10 → 3.3.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +3487 -33
- package/dist/es5/gml-loader.js +54 -0
- package/dist/es5/gml-loader.js.map +1 -0
- package/dist/es5/index.js +31 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/data-sources/image-data-source.js.map +1 -1
- package/dist/es5/lib/data-sources/{wms-data-source.js → wms-service.js} +182 -65
- package/dist/es5/lib/data-sources/wms-service.js.map +1 -0
- package/dist/es5/lib/gml/parse-gml.js +416 -0
- package/dist/es5/lib/gml/parse-gml.js.map +1 -0
- package/dist/es5/lib/wfs/parse-wfs.js +43 -0
- package/dist/es5/lib/wfs/parse-wfs.js.map +1 -0
- package/dist/es5/lib/wfs/wfs-types.js +2 -0
- package/dist/es5/lib/wfs/wfs-types.js.map +1 -0
- package/dist/es5/lib/{parse-wms.js → wms/parse-wms.js} +33 -2
- package/dist/es5/lib/wms/parse-wms.js.map +1 -0
- package/dist/es5/{wms-types.js → lib/wms/wms-types.js} +0 -0
- package/dist/es5/lib/wms/wms-types.js.map +1 -0
- package/dist/es5/lib/wmts/parse-wmts.js +43 -0
- package/dist/es5/lib/wmts/parse-wmts.js.map +1 -0
- package/dist/es5/lib/wmts/wmts-types.js +2 -0
- package/dist/es5/lib/wmts/wmts-types.js.map +1 -0
- package/dist/es5/wcs-capabilities-loader.js +54 -0
- package/dist/es5/wcs-capabilities-loader.js.map +1 -0
- package/dist/es5/wfs-capabilities-loader.js +54 -0
- package/dist/es5/wfs-capabilities-loader.js.map +1 -0
- package/dist/es5/wms-capabilities-loader.js +2 -2
- package/dist/es5/wms-capabilities-loader.js.map +1 -1
- package/dist/es5/wms-error-loader.js +54 -0
- package/dist/es5/wms-error-loader.js.map +1 -0
- package/dist/es5/wms-feature-info-loader.js +1 -1
- package/dist/es5/wms-feature-info-loader.js.map +1 -1
- package/dist/es5/wms-layer-description-loader.js +3 -3
- package/dist/es5/wms-layer-description-loader.js.map +1 -1
- package/dist/es5/wmts-capabilities-loader.js +54 -0
- package/dist/es5/wmts-capabilities-loader.js.map +1 -0
- package/dist/esm/gml-loader.js +25 -0
- package/dist/esm/gml-loader.js.map +1 -0
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/data-sources/image-data-source.js.map +1 -1
- package/dist/esm/lib/data-sources/wms-service.js +156 -0
- package/dist/esm/lib/data-sources/wms-service.js.map +1 -0
- package/dist/esm/lib/gml/parse-gml.js +348 -0
- package/dist/esm/lib/gml/parse-gml.js.map +1 -0
- package/dist/esm/lib/wfs/parse-wfs.js +32 -0
- package/dist/esm/lib/wfs/parse-wfs.js.map +1 -0
- package/dist/esm/lib/wfs/wfs-types.js +2 -0
- package/dist/esm/lib/wfs/wfs-types.js.map +1 -0
- package/dist/esm/lib/{parse-wms.js → wms/parse-wms.js} +31 -2
- package/dist/esm/lib/wms/parse-wms.js.map +1 -0
- package/dist/esm/{wms-types.js → lib/wms/wms-types.js} +0 -0
- package/dist/esm/lib/wms/wms-types.js.map +1 -0
- package/dist/esm/lib/wmts/parse-wmts.js +32 -0
- package/dist/esm/lib/wmts/parse-wmts.js.map +1 -0
- package/dist/esm/lib/wmts/wmts-types.js +2 -0
- package/dist/esm/lib/wmts/wmts-types.js.map +1 -0
- package/dist/esm/wcs-capabilities-loader.js +25 -0
- package/dist/esm/wcs-capabilities-loader.js.map +1 -0
- package/dist/esm/wfs-capabilities-loader.js +25 -0
- package/dist/esm/wfs-capabilities-loader.js.map +1 -0
- package/dist/esm/wms-capabilities-loader.js +2 -2
- package/dist/esm/wms-capabilities-loader.js.map +1 -1
- package/dist/esm/wms-error-loader.js +25 -0
- package/dist/esm/wms-error-loader.js.map +1 -0
- package/dist/esm/wms-feature-info-loader.js +1 -1
- package/dist/esm/wms-feature-info-loader.js.map +1 -1
- package/dist/esm/wms-layer-description-loader.js +3 -3
- package/dist/esm/wms-layer-description-loader.js.map +1 -1
- package/dist/esm/wmts-capabilities-loader.js +25 -0
- package/dist/esm/wmts-capabilities-loader.js.map +1 -0
- package/package.json +15 -5
- package/src/gml-loader.ts +40 -0
- package/src/index.ts +23 -4
- package/src/lib/data-sources/image-data-source.ts +1 -2
- package/src/lib/data-sources/wms-service.ts +313 -0
- package/src/lib/gml/parse-gml.ts +500 -0
- package/src/lib/wfs/parse-wfs.ts +39 -0
- package/src/lib/wfs/wfs-types.ts +78 -0
- package/src/lib/{parse-wms.ts → wms/parse-wms.ts} +41 -4
- package/src/{wms-types.ts → lib/wms/wms-types.ts} +3 -1
- package/src/lib/wmts/parse-wmts.ts +39 -0
- package/src/lib/wmts/wmts-types.ts +77 -0
- package/src/wcs-capabilities-loader.ts +40 -0
- package/src/wfs-capabilities-loader.ts +40 -0
- package/src/wms-capabilities-loader.ts +1 -1
- package/src/wms-error-loader.ts +40 -0
- package/src/wms-feature-info-loader.ts +1 -1
- package/src/wms-layer-description-loader.ts +4 -4
- package/src/wmts-capabilities-loader.ts +40 -0
- package/dist/es5/lib/data-sources/wms-data-source.js.map +0 -1
- package/dist/es5/lib/parse-wms.js.map +0 -1
- package/dist/es5/wms-types.js.map +0 -1
- package/dist/esm/lib/data-sources/wms-data-source.js +0 -70
- package/dist/esm/lib/data-sources/wms-data-source.js.map +0 -1
- package/dist/esm/lib/parse-wms.js.map +0 -1
- package/dist/esm/wms-types.js.map +0 -1
- package/src/lib/data-sources/wms-data-source.ts +0 -99
package/dist/dist.min.js
CHANGED
|
@@ -1577,7 +1577,7 @@
|
|
|
1577
1577
|
const parser = new import_fast_xml_parser.XMLParser({
|
|
1578
1578
|
ignoreAttributes: false,
|
|
1579
1579
|
attributeNamePrefix: "",
|
|
1580
|
-
...options
|
|
1580
|
+
...options?.xml
|
|
1581
1581
|
});
|
|
1582
1582
|
const parsedXML = parser.parse(text);
|
|
1583
1583
|
return parsedXML;
|
|
@@ -1623,7 +1623,7 @@
|
|
|
1623
1623
|
}
|
|
1624
1624
|
});
|
|
1625
1625
|
|
|
1626
|
-
// src/lib/parse-wms.ts
|
|
1626
|
+
// src/lib/wms/parse-wms.ts
|
|
1627
1627
|
function parseWMSCapabilities(text, options) {
|
|
1628
1628
|
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
1629
1629
|
const xmlCapabilities = parsedXML.WMT_MS_Capabilities || parsedXML.WMS_Capabilities || parsedXML;
|
|
@@ -1658,11 +1658,21 @@
|
|
|
1658
1658
|
srs: xmlLayer?.SRS || [],
|
|
1659
1659
|
layers: []
|
|
1660
1660
|
};
|
|
1661
|
-
|
|
1661
|
+
const xmlLayers = getXMLArray(xmlLayer?.Layer);
|
|
1662
|
+
for (const xmlSubLayer of xmlLayers) {
|
|
1662
1663
|
layer.layers?.push(extractLayer(xmlSubLayer));
|
|
1663
1664
|
}
|
|
1664
1665
|
return layer;
|
|
1665
1666
|
}
|
|
1667
|
+
function getXMLArray(xmlValue) {
|
|
1668
|
+
if (Array.isArray(xmlValue)) {
|
|
1669
|
+
return xmlValue;
|
|
1670
|
+
}
|
|
1671
|
+
if (xmlValue) {
|
|
1672
|
+
return [xmlValue];
|
|
1673
|
+
}
|
|
1674
|
+
return [];
|
|
1675
|
+
}
|
|
1666
1676
|
function parseWMSFeatureInfo(text, options) {
|
|
1667
1677
|
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
1668
1678
|
const xmlFeatureInfo = parsedXML.FeatureInfoResponse?.FIELDS || [];
|
|
@@ -1673,32 +1683,72 @@
|
|
|
1673
1683
|
}
|
|
1674
1684
|
function extractFeature(xmlFeature) {
|
|
1675
1685
|
const xmlFields = xmlFeature || {};
|
|
1676
|
-
return {
|
|
1686
|
+
return {
|
|
1687
|
+
attributes: xmlFields,
|
|
1688
|
+
type: "",
|
|
1689
|
+
bounds: { bottom: 0, top: 0, left: 0, right: 0 }
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
function parseWMSLayerDescription(text, options) {
|
|
1693
|
+
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
1694
|
+
return parsedXML;
|
|
1695
|
+
}
|
|
1696
|
+
function parseWMSError(text, options) {
|
|
1697
|
+
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
1698
|
+
const error = parsedXML?.ServiceExceptionReport?.ServiceException || "Unknown error";
|
|
1699
|
+
return String(error);
|
|
1677
1700
|
}
|
|
1678
1701
|
var init_parse_wms = __esm({
|
|
1679
|
-
"src/lib/parse-wms.ts"() {
|
|
1702
|
+
"src/lib/wms/parse-wms.ts"() {
|
|
1680
1703
|
init_src();
|
|
1681
1704
|
}
|
|
1682
1705
|
});
|
|
1683
1706
|
|
|
1684
|
-
// src/wms-
|
|
1707
|
+
// src/wms-error-loader.ts
|
|
1685
1708
|
function testXMLFile2(text) {
|
|
1686
1709
|
return text.startsWith("<?xml");
|
|
1687
1710
|
}
|
|
1688
|
-
var VERSION2,
|
|
1711
|
+
var VERSION2, WMSErrorLoader;
|
|
1712
|
+
var init_wms_error_loader = __esm({
|
|
1713
|
+
"src/wms-error-loader.ts"() {
|
|
1714
|
+
init_parse_wms();
|
|
1715
|
+
VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1716
|
+
WMSErrorLoader = {
|
|
1717
|
+
name: "WMS Error",
|
|
1718
|
+
id: "wms-capabilities",
|
|
1719
|
+
module: "wms",
|
|
1720
|
+
version: VERSION2,
|
|
1721
|
+
worker: false,
|
|
1722
|
+
extensions: ["xml"],
|
|
1723
|
+
mimeTypes: ["application/vnd.ogc.se_xml", "application/xml", "text/xml"],
|
|
1724
|
+
testText: testXMLFile2,
|
|
1725
|
+
options: {
|
|
1726
|
+
wms: {}
|
|
1727
|
+
},
|
|
1728
|
+
parse: async (arrayBuffer, options) => parseWMSError(new TextDecoder().decode(arrayBuffer), options),
|
|
1729
|
+
parseTextSync: (text, options) => parseWMSError(text, options)
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
|
|
1734
|
+
// src/wms-capabilities-loader.ts
|
|
1735
|
+
function testXMLFile3(text) {
|
|
1736
|
+
return text.startsWith("<?xml");
|
|
1737
|
+
}
|
|
1738
|
+
var VERSION3, WMSCapabilitiesLoader;
|
|
1689
1739
|
var init_wms_capabilities_loader = __esm({
|
|
1690
1740
|
"src/wms-capabilities-loader.ts"() {
|
|
1691
1741
|
init_parse_wms();
|
|
1692
|
-
|
|
1742
|
+
VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1693
1743
|
WMSCapabilitiesLoader = {
|
|
1694
1744
|
name: "WMS Capabilities",
|
|
1695
1745
|
id: "wms-capabilities",
|
|
1696
1746
|
module: "wms",
|
|
1697
|
-
version:
|
|
1747
|
+
version: VERSION3,
|
|
1698
1748
|
worker: false,
|
|
1699
1749
|
extensions: ["xml"],
|
|
1700
1750
|
mimeTypes: ["application/vnd.ogc.wms_xml", "application/xml", "text/xml"],
|
|
1701
|
-
testText:
|
|
1751
|
+
testText: testXMLFile3,
|
|
1702
1752
|
options: {
|
|
1703
1753
|
wms: {}
|
|
1704
1754
|
},
|
|
@@ -1734,17 +1784,17 @@
|
|
|
1734
1784
|
...WMSCapabilitiesLoader,
|
|
1735
1785
|
name: "WMS DescribeLayer",
|
|
1736
1786
|
id: "wms-layer-description",
|
|
1737
|
-
parse: async (arrayBuffer, options) =>
|
|
1738
|
-
parseTextSync: (text, options) =>
|
|
1787
|
+
parse: async (arrayBuffer, options) => parseWMSLayerDescription(new TextDecoder().decode(arrayBuffer), options),
|
|
1788
|
+
parseTextSync: (text, options) => parseWMSLayerDescription(text, options)
|
|
1739
1789
|
};
|
|
1740
1790
|
}
|
|
1741
1791
|
});
|
|
1742
1792
|
|
|
1743
1793
|
// ../images/src/lib/utils/version.ts
|
|
1744
|
-
var
|
|
1794
|
+
var VERSION4;
|
|
1745
1795
|
var init_version = __esm({
|
|
1746
1796
|
"../images/src/lib/utils/version.ts"() {
|
|
1747
|
-
|
|
1797
|
+
VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1748
1798
|
}
|
|
1749
1799
|
});
|
|
1750
1800
|
|
|
@@ -2178,7 +2228,7 @@
|
|
|
2178
2228
|
id: "image",
|
|
2179
2229
|
module: "images",
|
|
2180
2230
|
name: "Images",
|
|
2181
|
-
version:
|
|
2231
|
+
version: VERSION4,
|
|
2182
2232
|
mimeTypes: MIME_TYPES,
|
|
2183
2233
|
extensions: EXTENSIONS,
|
|
2184
2234
|
parse: parseImage,
|
|
@@ -2195,55 +2245,3444 @@
|
|
|
2195
2245
|
}
|
|
2196
2246
|
});
|
|
2197
2247
|
|
|
2198
|
-
// src/lib/data-sources/wms-
|
|
2199
|
-
var
|
|
2200
|
-
var
|
|
2201
|
-
"src/lib/data-sources/wms-
|
|
2248
|
+
// src/lib/data-sources/wms-service.ts
|
|
2249
|
+
var WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS, WMS_GET_MAP_DEFAULT_PARAMETERS, WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS, WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS, WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS, WMSService;
|
|
2250
|
+
var init_wms_service = __esm({
|
|
2251
|
+
"src/lib/data-sources/wms-service.ts"() {
|
|
2202
2252
|
init_src4();
|
|
2203
2253
|
init_src3();
|
|
2204
|
-
|
|
2254
|
+
WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS = {
|
|
2255
|
+
service: "WMS",
|
|
2256
|
+
version: "1.1.1",
|
|
2257
|
+
request: "GetCapabilities"
|
|
2258
|
+
};
|
|
2259
|
+
WMS_GET_MAP_DEFAULT_PARAMETERS = {
|
|
2260
|
+
service: "WMS",
|
|
2261
|
+
version: "1.1.1",
|
|
2262
|
+
request: "GetMap",
|
|
2263
|
+
layers: [],
|
|
2264
|
+
styles: void 0,
|
|
2265
|
+
bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
|
|
2266
|
+
width: 1200,
|
|
2267
|
+
height: 900,
|
|
2268
|
+
srs: "EPSG:4326",
|
|
2269
|
+
format: "image/png"
|
|
2270
|
+
};
|
|
2271
|
+
WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS = {
|
|
2272
|
+
service: "WMS",
|
|
2273
|
+
version: "1.1.1",
|
|
2274
|
+
request: "GetFeatureInfo",
|
|
2275
|
+
layers: [],
|
|
2276
|
+
styles: void 0,
|
|
2277
|
+
bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
|
|
2278
|
+
width: 1200,
|
|
2279
|
+
height: 900,
|
|
2280
|
+
srs: "EPSG:4326",
|
|
2281
|
+
format: "image/png",
|
|
2282
|
+
x: void 0,
|
|
2283
|
+
y: void 0,
|
|
2284
|
+
query_layers: [],
|
|
2285
|
+
info_format: "text/plain"
|
|
2286
|
+
};
|
|
2287
|
+
WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS = {
|
|
2288
|
+
service: "WMS",
|
|
2289
|
+
version: "1.1.1",
|
|
2290
|
+
request: "DescribeLayer"
|
|
2291
|
+
};
|
|
2292
|
+
WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS = {
|
|
2293
|
+
service: "WMS",
|
|
2294
|
+
version: "1.1.1",
|
|
2295
|
+
request: "GetLegendGraphic"
|
|
2296
|
+
};
|
|
2297
|
+
WMSService = class {
|
|
2205
2298
|
constructor(props) {
|
|
2206
2299
|
this.url = props.url;
|
|
2207
2300
|
this.loadOptions = props.loadOptions || {};
|
|
2208
2301
|
this.fetch = props.fetch || fetch;
|
|
2209
2302
|
}
|
|
2210
|
-
|
|
2211
|
-
const
|
|
2303
|
+
getCapabilitiesURL(parameters, extra) {
|
|
2304
|
+
const options = {
|
|
2305
|
+
...WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS,
|
|
2306
|
+
...parameters,
|
|
2307
|
+
...extra
|
|
2308
|
+
};
|
|
2309
|
+
return this.getWMSUrl(options, extra);
|
|
2310
|
+
}
|
|
2311
|
+
getMapURL(parameters, extra) {
|
|
2312
|
+
const options = {
|
|
2313
|
+
...WMS_GET_MAP_DEFAULT_PARAMETERS,
|
|
2314
|
+
...parameters,
|
|
2315
|
+
...extra
|
|
2316
|
+
};
|
|
2317
|
+
return this.getWMSUrl(options, extra);
|
|
2318
|
+
}
|
|
2319
|
+
getFeatureInfoURL(parameters, extra) {
|
|
2320
|
+
const options = {
|
|
2321
|
+
...WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS,
|
|
2322
|
+
...parameters,
|
|
2323
|
+
...extra
|
|
2324
|
+
};
|
|
2325
|
+
return this.getWMSUrl(options, extra);
|
|
2326
|
+
}
|
|
2327
|
+
describeLayerURL(parameters, extra) {
|
|
2328
|
+
const options = {
|
|
2329
|
+
...WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS,
|
|
2330
|
+
...parameters,
|
|
2331
|
+
...extra
|
|
2332
|
+
};
|
|
2333
|
+
return this.getWMSUrl(options, extra);
|
|
2334
|
+
}
|
|
2335
|
+
getLegendGraphicURL(parameters, extra) {
|
|
2336
|
+
const options = {
|
|
2337
|
+
...WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS,
|
|
2338
|
+
...parameters,
|
|
2339
|
+
...extra
|
|
2340
|
+
};
|
|
2341
|
+
return this.getWMSUrl(options, extra);
|
|
2342
|
+
}
|
|
2343
|
+
async getCapabilities(parameters, extra) {
|
|
2344
|
+
const url = this.getCapabilitiesURL(parameters, extra);
|
|
2212
2345
|
const response = await this.fetch(url, this.loadOptions);
|
|
2346
|
+
await this.checkResponse(response);
|
|
2213
2347
|
const arrayBuffer = await response.arrayBuffer();
|
|
2214
2348
|
return await WMSCapabilitiesLoader.parse(arrayBuffer, this.loadOptions);
|
|
2215
2349
|
}
|
|
2216
|
-
async
|
|
2217
|
-
const url = this.
|
|
2350
|
+
async getMap(options, extra) {
|
|
2351
|
+
const url = this.getMapURL(options, extra);
|
|
2218
2352
|
const response = await this.fetch(url, this.loadOptions);
|
|
2353
|
+
await this.checkResponse(response);
|
|
2219
2354
|
const arrayBuffer = await response.arrayBuffer();
|
|
2220
2355
|
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
2221
2356
|
}
|
|
2222
|
-
async getFeatureInfo(options) {
|
|
2223
|
-
const url = this.
|
|
2357
|
+
async getFeatureInfo(options, extra) {
|
|
2358
|
+
const url = this.getFeatureInfoURL(options, extra);
|
|
2224
2359
|
const response = await this.fetch(url, this.loadOptions);
|
|
2360
|
+
await this.checkResponse(response);
|
|
2225
2361
|
const arrayBuffer = await response.arrayBuffer();
|
|
2226
2362
|
return await WMSFeatureInfoLoader.parse(arrayBuffer, this.loadOptions);
|
|
2227
2363
|
}
|
|
2228
|
-
async
|
|
2229
|
-
const url = this.
|
|
2364
|
+
async describeLayer(options, extra) {
|
|
2365
|
+
const url = this.describeLayerURL(options, extra);
|
|
2230
2366
|
const response = await this.fetch(url, this.loadOptions);
|
|
2367
|
+
await this.checkResponse(response);
|
|
2231
2368
|
const arrayBuffer = await response.arrayBuffer();
|
|
2232
2369
|
return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
|
|
2233
2370
|
}
|
|
2234
|
-
async
|
|
2235
|
-
const url = this.
|
|
2371
|
+
async getLegendGraphic(options, extra) {
|
|
2372
|
+
const url = this.getLegendGraphicURL(options, extra);
|
|
2236
2373
|
const response = await this.fetch(url, this.loadOptions);
|
|
2374
|
+
await this.checkResponse(response);
|
|
2237
2375
|
const arrayBuffer = await response.arrayBuffer();
|
|
2238
2376
|
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
2239
2377
|
}
|
|
2240
|
-
|
|
2378
|
+
getWMSUrl(options, extra) {
|
|
2241
2379
|
let url = `${this.url}?REQUEST=${options.request}`;
|
|
2242
2380
|
if (options.layers?.length) {
|
|
2243
2381
|
url += `&LAYERS=[${options.layers.join(",")}]`;
|
|
2244
2382
|
}
|
|
2245
2383
|
return url;
|
|
2246
2384
|
}
|
|
2385
|
+
async checkResponse(response) {
|
|
2386
|
+
if (!response.ok || response.headers["content-type"] === WMSErrorLoader.mimeTypes[0]) {
|
|
2387
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
2388
|
+
const error = await WMSErrorLoader.parse(arrayBuffer, this.loadOptions);
|
|
2389
|
+
throw new Error(error);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
|
|
2396
|
+
// src/lib/wfs/parse-wfs.ts
|
|
2397
|
+
function parseWFSCapabilities(text, options) {
|
|
2398
|
+
options = { ...options, xml: { ...options?.xml, removeNSPrefix: true } };
|
|
2399
|
+
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
2400
|
+
const xmlCapabilities = parsedXML.Capabilities || parsedXML;
|
|
2401
|
+
return uncapitalizeKeys(xmlCapabilities);
|
|
2402
|
+
}
|
|
2403
|
+
function uncapitalizeKeys(object) {
|
|
2404
|
+
if (object && typeof object === "object") {
|
|
2405
|
+
const newObject = {};
|
|
2406
|
+
for (const [key, value] of Object.entries(object)) {
|
|
2407
|
+
newObject[uncapitalize(key)] = uncapitalizeKeys(value);
|
|
2408
|
+
}
|
|
2409
|
+
return newObject;
|
|
2410
|
+
}
|
|
2411
|
+
return object;
|
|
2412
|
+
}
|
|
2413
|
+
function uncapitalize(str) {
|
|
2414
|
+
return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
|
|
2415
|
+
}
|
|
2416
|
+
var init_parse_wfs = __esm({
|
|
2417
|
+
"src/lib/wfs/parse-wfs.ts"() {
|
|
2418
|
+
init_src();
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
|
|
2422
|
+
// src/wfs-capabilities-loader.ts
|
|
2423
|
+
function testXMLFile4(text) {
|
|
2424
|
+
return text.startsWith("<?xml");
|
|
2425
|
+
}
|
|
2426
|
+
var VERSION5, WFSCapabilitiesLoader;
|
|
2427
|
+
var init_wfs_capabilities_loader = __esm({
|
|
2428
|
+
"src/wfs-capabilities-loader.ts"() {
|
|
2429
|
+
init_parse_wfs();
|
|
2430
|
+
VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2431
|
+
WFSCapabilitiesLoader = {
|
|
2432
|
+
name: "WFS Capabilities",
|
|
2433
|
+
id: "wfs-capabilities",
|
|
2434
|
+
module: "wms",
|
|
2435
|
+
version: VERSION5,
|
|
2436
|
+
worker: false,
|
|
2437
|
+
extensions: ["xml"],
|
|
2438
|
+
mimeTypes: ["application/vnd.ogc.wfs_xml", "application/xml", "text/xml"],
|
|
2439
|
+
testText: testXMLFile4,
|
|
2440
|
+
options: {
|
|
2441
|
+
wms: {}
|
|
2442
|
+
},
|
|
2443
|
+
parse: async (arrayBuffer, options) => parseWFSCapabilities(new TextDecoder().decode(arrayBuffer), options),
|
|
2444
|
+
parseTextSync: (text, options) => parseWFSCapabilities(text, options)
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
|
|
2449
|
+
// src/lib/wmts/parse-wmts.ts
|
|
2450
|
+
function parseWMTSCapabilities(text, options) {
|
|
2451
|
+
options = { ...options, xml: { ...options?.xml, removeNSPrefix: true } };
|
|
2452
|
+
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
2453
|
+
const xmlCapabilities = parsedXML.Capabilities || parsedXML;
|
|
2454
|
+
return uncapitalizeKeys2(xmlCapabilities);
|
|
2455
|
+
}
|
|
2456
|
+
function uncapitalizeKeys2(object) {
|
|
2457
|
+
if (object && typeof object === "object") {
|
|
2458
|
+
const newObject = {};
|
|
2459
|
+
for (const [key, value] of Object.entries(object)) {
|
|
2460
|
+
newObject[uncapitalize2(key)] = uncapitalizeKeys2(value);
|
|
2461
|
+
}
|
|
2462
|
+
return newObject;
|
|
2463
|
+
}
|
|
2464
|
+
return object;
|
|
2465
|
+
}
|
|
2466
|
+
function uncapitalize2(str) {
|
|
2467
|
+
return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
|
|
2468
|
+
}
|
|
2469
|
+
var init_parse_wmts = __esm({
|
|
2470
|
+
"src/lib/wmts/parse-wmts.ts"() {
|
|
2471
|
+
init_src();
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
|
|
2475
|
+
// src/wmts-capabilities-loader.ts
|
|
2476
|
+
function testXMLFile5(text) {
|
|
2477
|
+
return text.startsWith("<?xml");
|
|
2478
|
+
}
|
|
2479
|
+
var VERSION6, WMTSCapabilitiesLoader;
|
|
2480
|
+
var init_wmts_capabilities_loader = __esm({
|
|
2481
|
+
"src/wmts-capabilities-loader.ts"() {
|
|
2482
|
+
init_parse_wmts();
|
|
2483
|
+
VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2484
|
+
WMTSCapabilitiesLoader = {
|
|
2485
|
+
name: "WMTS Capabilities",
|
|
2486
|
+
id: "wmts-capabilities",
|
|
2487
|
+
module: "wms",
|
|
2488
|
+
version: VERSION6,
|
|
2489
|
+
worker: false,
|
|
2490
|
+
extensions: ["xml"],
|
|
2491
|
+
mimeTypes: ["application/vnd.ogc.wmts_xml", "application/xml", "text/xml"],
|
|
2492
|
+
testText: testXMLFile5,
|
|
2493
|
+
options: {
|
|
2494
|
+
wms: {}
|
|
2495
|
+
},
|
|
2496
|
+
parse: async (arrayBuffer, options) => parseWMTSCapabilities(new TextDecoder().decode(arrayBuffer), options),
|
|
2497
|
+
parseTextSync: (text, options) => parseWMTSCapabilities(text, options)
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
|
|
2502
|
+
// ../../node_modules/buf-compare/index.js
|
|
2503
|
+
var require_buf_compare = __commonJS({
|
|
2504
|
+
"../../node_modules/buf-compare/index.js"(exports, module) {
|
|
2505
|
+
"use strict";
|
|
2506
|
+
module.exports = Buffer.compare || function(a, b) {
|
|
2507
|
+
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
2508
|
+
throw new TypeError("Arguments must be Buffers");
|
|
2509
|
+
}
|
|
2510
|
+
if (a === b) {
|
|
2511
|
+
return 0;
|
|
2512
|
+
}
|
|
2513
|
+
var x = a.length;
|
|
2514
|
+
var y = b.length;
|
|
2515
|
+
var len = Math.min(x, y);
|
|
2516
|
+
for (var i = 0; i < len; i++) {
|
|
2517
|
+
if (a[i] !== b[i]) {
|
|
2518
|
+
break;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
if (i !== len) {
|
|
2522
|
+
x = a[i];
|
|
2523
|
+
y = b[i];
|
|
2524
|
+
}
|
|
2525
|
+
return x < y ? -1 : y < x ? 1 : 0;
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
});
|
|
2529
|
+
|
|
2530
|
+
// ../../node_modules/is-error/index.js
|
|
2531
|
+
var require_is_error = __commonJS({
|
|
2532
|
+
"../../node_modules/is-error/index.js"(exports, module) {
|
|
2533
|
+
"use strict";
|
|
2534
|
+
var objectToString = Object.prototype.toString;
|
|
2535
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
2536
|
+
var ERROR_TYPE = "[object Error]";
|
|
2537
|
+
module.exports = function isError(err) {
|
|
2538
|
+
if (typeof err !== "object") {
|
|
2539
|
+
return false;
|
|
2540
|
+
}
|
|
2541
|
+
if (err instanceof Error) {
|
|
2542
|
+
return true;
|
|
2543
|
+
}
|
|
2544
|
+
while (err) {
|
|
2545
|
+
if (objectToString.call(err) === ERROR_TYPE) {
|
|
2546
|
+
return true;
|
|
2547
|
+
}
|
|
2548
|
+
err = getPrototypeOf(err);
|
|
2549
|
+
}
|
|
2550
|
+
return false;
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
|
|
2555
|
+
// ../../node_modules/util/support/isBufferBrowser.js
|
|
2556
|
+
var require_isBufferBrowser = __commonJS({
|
|
2557
|
+
"../../node_modules/util/support/isBufferBrowser.js"(exports, module) {
|
|
2558
|
+
module.exports = function isBuffer(arg) {
|
|
2559
|
+
return arg && typeof arg === "object" && typeof arg.copy === "function" && typeof arg.fill === "function" && typeof arg.readUInt8 === "function";
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2563
|
+
|
|
2564
|
+
// ../../node_modules/util/node_modules/inherits/inherits_browser.js
|
|
2565
|
+
var require_inherits_browser = __commonJS({
|
|
2566
|
+
"../../node_modules/util/node_modules/inherits/inherits_browser.js"(exports, module) {
|
|
2567
|
+
if (typeof Object.create === "function") {
|
|
2568
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
2569
|
+
ctor.super_ = superCtor;
|
|
2570
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
2571
|
+
constructor: {
|
|
2572
|
+
value: ctor,
|
|
2573
|
+
enumerable: false,
|
|
2574
|
+
writable: true,
|
|
2575
|
+
configurable: true
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2578
|
+
};
|
|
2579
|
+
} else {
|
|
2580
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
2581
|
+
ctor.super_ = superCtor;
|
|
2582
|
+
var TempCtor = function() {
|
|
2583
|
+
};
|
|
2584
|
+
TempCtor.prototype = superCtor.prototype;
|
|
2585
|
+
ctor.prototype = new TempCtor();
|
|
2586
|
+
ctor.prototype.constructor = ctor;
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2591
|
+
|
|
2592
|
+
// ../../node_modules/util/util.js
|
|
2593
|
+
var require_util2 = __commonJS({
|
|
2594
|
+
"../../node_modules/util/util.js"(exports) {
|
|
2595
|
+
var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors2(obj) {
|
|
2596
|
+
var keys = Object.keys(obj);
|
|
2597
|
+
var descriptors = {};
|
|
2598
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2599
|
+
descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
|
|
2600
|
+
}
|
|
2601
|
+
return descriptors;
|
|
2602
|
+
};
|
|
2603
|
+
var formatRegExp = /%[sdj%]/g;
|
|
2604
|
+
exports.format = function(f) {
|
|
2605
|
+
if (!isString(f)) {
|
|
2606
|
+
var objects = [];
|
|
2607
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
2608
|
+
objects.push(inspect(arguments[i]));
|
|
2609
|
+
}
|
|
2610
|
+
return objects.join(" ");
|
|
2611
|
+
}
|
|
2612
|
+
var i = 1;
|
|
2613
|
+
var args = arguments;
|
|
2614
|
+
var len = args.length;
|
|
2615
|
+
var str = String(f).replace(formatRegExp, function(x2) {
|
|
2616
|
+
if (x2 === "%%")
|
|
2617
|
+
return "%";
|
|
2618
|
+
if (i >= len)
|
|
2619
|
+
return x2;
|
|
2620
|
+
switch (x2) {
|
|
2621
|
+
case "%s":
|
|
2622
|
+
return String(args[i++]);
|
|
2623
|
+
case "%d":
|
|
2624
|
+
return Number(args[i++]);
|
|
2625
|
+
case "%j":
|
|
2626
|
+
try {
|
|
2627
|
+
return JSON.stringify(args[i++]);
|
|
2628
|
+
} catch (_) {
|
|
2629
|
+
return "[Circular]";
|
|
2630
|
+
}
|
|
2631
|
+
default:
|
|
2632
|
+
return x2;
|
|
2633
|
+
}
|
|
2634
|
+
});
|
|
2635
|
+
for (var x = args[i]; i < len; x = args[++i]) {
|
|
2636
|
+
if (isNull(x) || !isObject2(x)) {
|
|
2637
|
+
str += " " + x;
|
|
2638
|
+
} else {
|
|
2639
|
+
str += " " + inspect(x);
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
return str;
|
|
2643
|
+
};
|
|
2644
|
+
exports.deprecate = function(fn, msg) {
|
|
2645
|
+
if (typeof process !== "undefined" && process.noDeprecation === true) {
|
|
2646
|
+
return fn;
|
|
2647
|
+
}
|
|
2648
|
+
if (typeof process === "undefined") {
|
|
2649
|
+
return function() {
|
|
2650
|
+
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
var warned = false;
|
|
2654
|
+
function deprecated() {
|
|
2655
|
+
if (!warned) {
|
|
2656
|
+
if (process.throwDeprecation) {
|
|
2657
|
+
throw new Error(msg);
|
|
2658
|
+
} else if (process.traceDeprecation) {
|
|
2659
|
+
console.trace(msg);
|
|
2660
|
+
} else {
|
|
2661
|
+
console.error(msg);
|
|
2662
|
+
}
|
|
2663
|
+
warned = true;
|
|
2664
|
+
}
|
|
2665
|
+
return fn.apply(this, arguments);
|
|
2666
|
+
}
|
|
2667
|
+
return deprecated;
|
|
2668
|
+
};
|
|
2669
|
+
var debugs = {};
|
|
2670
|
+
var debugEnviron;
|
|
2671
|
+
exports.debuglog = function(set) {
|
|
2672
|
+
if (isUndefined(debugEnviron))
|
|
2673
|
+
debugEnviron = process.env.NODE_DEBUG || "";
|
|
2674
|
+
set = set.toUpperCase();
|
|
2675
|
+
if (!debugs[set]) {
|
|
2676
|
+
if (new RegExp("\\b" + set + "\\b", "i").test(debugEnviron)) {
|
|
2677
|
+
var pid = process.pid;
|
|
2678
|
+
debugs[set] = function() {
|
|
2679
|
+
var msg = exports.format.apply(exports, arguments);
|
|
2680
|
+
console.error("%s %d: %s", set, pid, msg);
|
|
2681
|
+
};
|
|
2682
|
+
} else {
|
|
2683
|
+
debugs[set] = function() {
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
return debugs[set];
|
|
2688
|
+
};
|
|
2689
|
+
function inspect(obj, opts) {
|
|
2690
|
+
var ctx = {
|
|
2691
|
+
seen: [],
|
|
2692
|
+
stylize: stylizeNoColor
|
|
2693
|
+
};
|
|
2694
|
+
if (arguments.length >= 3)
|
|
2695
|
+
ctx.depth = arguments[2];
|
|
2696
|
+
if (arguments.length >= 4)
|
|
2697
|
+
ctx.colors = arguments[3];
|
|
2698
|
+
if (isBoolean(opts)) {
|
|
2699
|
+
ctx.showHidden = opts;
|
|
2700
|
+
} else if (opts) {
|
|
2701
|
+
exports._extend(ctx, opts);
|
|
2702
|
+
}
|
|
2703
|
+
if (isUndefined(ctx.showHidden))
|
|
2704
|
+
ctx.showHidden = false;
|
|
2705
|
+
if (isUndefined(ctx.depth))
|
|
2706
|
+
ctx.depth = 2;
|
|
2707
|
+
if (isUndefined(ctx.colors))
|
|
2708
|
+
ctx.colors = false;
|
|
2709
|
+
if (isUndefined(ctx.customInspect))
|
|
2710
|
+
ctx.customInspect = true;
|
|
2711
|
+
if (ctx.colors)
|
|
2712
|
+
ctx.stylize = stylizeWithColor;
|
|
2713
|
+
return formatValue(ctx, obj, ctx.depth);
|
|
2714
|
+
}
|
|
2715
|
+
exports.inspect = inspect;
|
|
2716
|
+
inspect.colors = {
|
|
2717
|
+
"bold": [1, 22],
|
|
2718
|
+
"italic": [3, 23],
|
|
2719
|
+
"underline": [4, 24],
|
|
2720
|
+
"inverse": [7, 27],
|
|
2721
|
+
"white": [37, 39],
|
|
2722
|
+
"grey": [90, 39],
|
|
2723
|
+
"black": [30, 39],
|
|
2724
|
+
"blue": [34, 39],
|
|
2725
|
+
"cyan": [36, 39],
|
|
2726
|
+
"green": [32, 39],
|
|
2727
|
+
"magenta": [35, 39],
|
|
2728
|
+
"red": [31, 39],
|
|
2729
|
+
"yellow": [33, 39]
|
|
2730
|
+
};
|
|
2731
|
+
inspect.styles = {
|
|
2732
|
+
"special": "cyan",
|
|
2733
|
+
"number": "yellow",
|
|
2734
|
+
"boolean": "yellow",
|
|
2735
|
+
"undefined": "grey",
|
|
2736
|
+
"null": "bold",
|
|
2737
|
+
"string": "green",
|
|
2738
|
+
"date": "magenta",
|
|
2739
|
+
"regexp": "red"
|
|
2740
|
+
};
|
|
2741
|
+
function stylizeWithColor(str, styleType) {
|
|
2742
|
+
var style = inspect.styles[styleType];
|
|
2743
|
+
if (style) {
|
|
2744
|
+
return "[" + inspect.colors[style][0] + "m" + str + "[" + inspect.colors[style][1] + "m";
|
|
2745
|
+
} else {
|
|
2746
|
+
return str;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
function stylizeNoColor(str, styleType) {
|
|
2750
|
+
return str;
|
|
2751
|
+
}
|
|
2752
|
+
function arrayToHash(array) {
|
|
2753
|
+
var hash = {};
|
|
2754
|
+
array.forEach(function(val, idx) {
|
|
2755
|
+
hash[val] = true;
|
|
2756
|
+
});
|
|
2757
|
+
return hash;
|
|
2758
|
+
}
|
|
2759
|
+
function formatValue(ctx, value, recurseTimes) {
|
|
2760
|
+
if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== exports.inspect && !(value.constructor && value.constructor.prototype === value)) {
|
|
2761
|
+
var ret = value.inspect(recurseTimes, ctx);
|
|
2762
|
+
if (!isString(ret)) {
|
|
2763
|
+
ret = formatValue(ctx, ret, recurseTimes);
|
|
2764
|
+
}
|
|
2765
|
+
return ret;
|
|
2766
|
+
}
|
|
2767
|
+
var primitive = formatPrimitive(ctx, value);
|
|
2768
|
+
if (primitive) {
|
|
2769
|
+
return primitive;
|
|
2770
|
+
}
|
|
2771
|
+
var keys = Object.keys(value);
|
|
2772
|
+
var visibleKeys = arrayToHash(keys);
|
|
2773
|
+
if (ctx.showHidden) {
|
|
2774
|
+
keys = Object.getOwnPropertyNames(value);
|
|
2775
|
+
}
|
|
2776
|
+
if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) {
|
|
2777
|
+
return formatError(value);
|
|
2778
|
+
}
|
|
2779
|
+
if (keys.length === 0) {
|
|
2780
|
+
if (isFunction(value)) {
|
|
2781
|
+
var name = value.name ? ": " + value.name : "";
|
|
2782
|
+
return ctx.stylize("[Function" + name + "]", "special");
|
|
2783
|
+
}
|
|
2784
|
+
if (isRegExp(value)) {
|
|
2785
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
2786
|
+
}
|
|
2787
|
+
if (isDate(value)) {
|
|
2788
|
+
return ctx.stylize(Date.prototype.toString.call(value), "date");
|
|
2789
|
+
}
|
|
2790
|
+
if (isError(value)) {
|
|
2791
|
+
return formatError(value);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
var base = "", array = false, braces = ["{", "}"];
|
|
2795
|
+
if (isArray(value)) {
|
|
2796
|
+
array = true;
|
|
2797
|
+
braces = ["[", "]"];
|
|
2798
|
+
}
|
|
2799
|
+
if (isFunction(value)) {
|
|
2800
|
+
var n = value.name ? ": " + value.name : "";
|
|
2801
|
+
base = " [Function" + n + "]";
|
|
2802
|
+
}
|
|
2803
|
+
if (isRegExp(value)) {
|
|
2804
|
+
base = " " + RegExp.prototype.toString.call(value);
|
|
2805
|
+
}
|
|
2806
|
+
if (isDate(value)) {
|
|
2807
|
+
base = " " + Date.prototype.toUTCString.call(value);
|
|
2808
|
+
}
|
|
2809
|
+
if (isError(value)) {
|
|
2810
|
+
base = " " + formatError(value);
|
|
2811
|
+
}
|
|
2812
|
+
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
2813
|
+
return braces[0] + base + braces[1];
|
|
2814
|
+
}
|
|
2815
|
+
if (recurseTimes < 0) {
|
|
2816
|
+
if (isRegExp(value)) {
|
|
2817
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
2818
|
+
} else {
|
|
2819
|
+
return ctx.stylize("[Object]", "special");
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
ctx.seen.push(value);
|
|
2823
|
+
var output;
|
|
2824
|
+
if (array) {
|
|
2825
|
+
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
2826
|
+
} else {
|
|
2827
|
+
output = keys.map(function(key) {
|
|
2828
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
ctx.seen.pop();
|
|
2832
|
+
return reduceToSingleString(output, base, braces);
|
|
2833
|
+
}
|
|
2834
|
+
function formatPrimitive(ctx, value) {
|
|
2835
|
+
if (isUndefined(value))
|
|
2836
|
+
return ctx.stylize("undefined", "undefined");
|
|
2837
|
+
if (isString(value)) {
|
|
2838
|
+
var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
|
|
2839
|
+
return ctx.stylize(simple, "string");
|
|
2840
|
+
}
|
|
2841
|
+
if (isNumber2(value))
|
|
2842
|
+
return ctx.stylize("" + value, "number");
|
|
2843
|
+
if (isBoolean(value))
|
|
2844
|
+
return ctx.stylize("" + value, "boolean");
|
|
2845
|
+
if (isNull(value))
|
|
2846
|
+
return ctx.stylize("null", "null");
|
|
2847
|
+
}
|
|
2848
|
+
function formatError(value) {
|
|
2849
|
+
return "[" + Error.prototype.toString.call(value) + "]";
|
|
2850
|
+
}
|
|
2851
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
2852
|
+
var output = [];
|
|
2853
|
+
for (var i = 0, l = value.length; i < l; ++i) {
|
|
2854
|
+
if (hasOwnProperty(value, String(i))) {
|
|
2855
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
|
|
2856
|
+
} else {
|
|
2857
|
+
output.push("");
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
keys.forEach(function(key) {
|
|
2861
|
+
if (!key.match(/^\d+$/)) {
|
|
2862
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
|
|
2863
|
+
}
|
|
2864
|
+
});
|
|
2865
|
+
return output;
|
|
2866
|
+
}
|
|
2867
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
2868
|
+
var name, str, desc;
|
|
2869
|
+
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
2870
|
+
if (desc.get) {
|
|
2871
|
+
if (desc.set) {
|
|
2872
|
+
str = ctx.stylize("[Getter/Setter]", "special");
|
|
2873
|
+
} else {
|
|
2874
|
+
str = ctx.stylize("[Getter]", "special");
|
|
2875
|
+
}
|
|
2876
|
+
} else {
|
|
2877
|
+
if (desc.set) {
|
|
2878
|
+
str = ctx.stylize("[Setter]", "special");
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
if (!hasOwnProperty(visibleKeys, key)) {
|
|
2882
|
+
name = "[" + key + "]";
|
|
2883
|
+
}
|
|
2884
|
+
if (!str) {
|
|
2885
|
+
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
2886
|
+
if (isNull(recurseTimes)) {
|
|
2887
|
+
str = formatValue(ctx, desc.value, null);
|
|
2888
|
+
} else {
|
|
2889
|
+
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
2890
|
+
}
|
|
2891
|
+
if (str.indexOf("\n") > -1) {
|
|
2892
|
+
if (array) {
|
|
2893
|
+
str = str.split("\n").map(function(line) {
|
|
2894
|
+
return " " + line;
|
|
2895
|
+
}).join("\n").substr(2);
|
|
2896
|
+
} else {
|
|
2897
|
+
str = "\n" + str.split("\n").map(function(line) {
|
|
2898
|
+
return " " + line;
|
|
2899
|
+
}).join("\n");
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
} else {
|
|
2903
|
+
str = ctx.stylize("[Circular]", "special");
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
if (isUndefined(name)) {
|
|
2907
|
+
if (array && key.match(/^\d+$/)) {
|
|
2908
|
+
return str;
|
|
2909
|
+
}
|
|
2910
|
+
name = JSON.stringify("" + key);
|
|
2911
|
+
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
2912
|
+
name = name.substr(1, name.length - 2);
|
|
2913
|
+
name = ctx.stylize(name, "name");
|
|
2914
|
+
} else {
|
|
2915
|
+
name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
2916
|
+
name = ctx.stylize(name, "string");
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
return name + ": " + str;
|
|
2920
|
+
}
|
|
2921
|
+
function reduceToSingleString(output, base, braces) {
|
|
2922
|
+
var numLinesEst = 0;
|
|
2923
|
+
var length = output.reduce(function(prev, cur) {
|
|
2924
|
+
numLinesEst++;
|
|
2925
|
+
if (cur.indexOf("\n") >= 0)
|
|
2926
|
+
numLinesEst++;
|
|
2927
|
+
return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
|
|
2928
|
+
}, 0);
|
|
2929
|
+
if (length > 60) {
|
|
2930
|
+
return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1];
|
|
2931
|
+
}
|
|
2932
|
+
return braces[0] + base + " " + output.join(", ") + " " + braces[1];
|
|
2933
|
+
}
|
|
2934
|
+
function isArray(ar) {
|
|
2935
|
+
return Array.isArray(ar);
|
|
2936
|
+
}
|
|
2937
|
+
exports.isArray = isArray;
|
|
2938
|
+
function isBoolean(arg) {
|
|
2939
|
+
return typeof arg === "boolean";
|
|
2940
|
+
}
|
|
2941
|
+
exports.isBoolean = isBoolean;
|
|
2942
|
+
function isNull(arg) {
|
|
2943
|
+
return arg === null;
|
|
2944
|
+
}
|
|
2945
|
+
exports.isNull = isNull;
|
|
2946
|
+
function isNullOrUndefined(arg) {
|
|
2947
|
+
return arg == null;
|
|
2948
|
+
}
|
|
2949
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
|
2950
|
+
function isNumber2(arg) {
|
|
2951
|
+
return typeof arg === "number";
|
|
2952
|
+
}
|
|
2953
|
+
exports.isNumber = isNumber2;
|
|
2954
|
+
function isString(arg) {
|
|
2955
|
+
return typeof arg === "string";
|
|
2956
|
+
}
|
|
2957
|
+
exports.isString = isString;
|
|
2958
|
+
function isSymbol(arg) {
|
|
2959
|
+
return typeof arg === "symbol";
|
|
2960
|
+
}
|
|
2961
|
+
exports.isSymbol = isSymbol;
|
|
2962
|
+
function isUndefined(arg) {
|
|
2963
|
+
return arg === void 0;
|
|
2964
|
+
}
|
|
2965
|
+
exports.isUndefined = isUndefined;
|
|
2966
|
+
function isRegExp(re) {
|
|
2967
|
+
return isObject2(re) && objectToString(re) === "[object RegExp]";
|
|
2968
|
+
}
|
|
2969
|
+
exports.isRegExp = isRegExp;
|
|
2970
|
+
function isObject2(arg) {
|
|
2971
|
+
return typeof arg === "object" && arg !== null;
|
|
2972
|
+
}
|
|
2973
|
+
exports.isObject = isObject2;
|
|
2974
|
+
function isDate(d) {
|
|
2975
|
+
return isObject2(d) && objectToString(d) === "[object Date]";
|
|
2976
|
+
}
|
|
2977
|
+
exports.isDate = isDate;
|
|
2978
|
+
function isError(e) {
|
|
2979
|
+
return isObject2(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
|
|
2980
|
+
}
|
|
2981
|
+
exports.isError = isError;
|
|
2982
|
+
function isFunction(arg) {
|
|
2983
|
+
return typeof arg === "function";
|
|
2984
|
+
}
|
|
2985
|
+
exports.isFunction = isFunction;
|
|
2986
|
+
function isPrimitive(arg) {
|
|
2987
|
+
return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || typeof arg === "undefined";
|
|
2988
|
+
}
|
|
2989
|
+
exports.isPrimitive = isPrimitive;
|
|
2990
|
+
exports.isBuffer = require_isBufferBrowser();
|
|
2991
|
+
function objectToString(o) {
|
|
2992
|
+
return Object.prototype.toString.call(o);
|
|
2993
|
+
}
|
|
2994
|
+
function pad(n) {
|
|
2995
|
+
return n < 10 ? "0" + n.toString(10) : n.toString(10);
|
|
2996
|
+
}
|
|
2997
|
+
var months = [
|
|
2998
|
+
"Jan",
|
|
2999
|
+
"Feb",
|
|
3000
|
+
"Mar",
|
|
3001
|
+
"Apr",
|
|
3002
|
+
"May",
|
|
3003
|
+
"Jun",
|
|
3004
|
+
"Jul",
|
|
3005
|
+
"Aug",
|
|
3006
|
+
"Sep",
|
|
3007
|
+
"Oct",
|
|
3008
|
+
"Nov",
|
|
3009
|
+
"Dec"
|
|
3010
|
+
];
|
|
3011
|
+
function timestamp() {
|
|
3012
|
+
var d = new Date();
|
|
3013
|
+
var time = [
|
|
3014
|
+
pad(d.getHours()),
|
|
3015
|
+
pad(d.getMinutes()),
|
|
3016
|
+
pad(d.getSeconds())
|
|
3017
|
+
].join(":");
|
|
3018
|
+
return [d.getDate(), months[d.getMonth()], time].join(" ");
|
|
3019
|
+
}
|
|
3020
|
+
exports.log = function() {
|
|
3021
|
+
console.log("%s - %s", timestamp(), exports.format.apply(exports, arguments));
|
|
3022
|
+
};
|
|
3023
|
+
exports.inherits = require_inherits_browser();
|
|
3024
|
+
exports._extend = function(origin, add) {
|
|
3025
|
+
if (!add || !isObject2(add))
|
|
3026
|
+
return origin;
|
|
3027
|
+
var keys = Object.keys(add);
|
|
3028
|
+
var i = keys.length;
|
|
3029
|
+
while (i--) {
|
|
3030
|
+
origin[keys[i]] = add[keys[i]];
|
|
3031
|
+
}
|
|
3032
|
+
return origin;
|
|
3033
|
+
};
|
|
3034
|
+
function hasOwnProperty(obj, prop) {
|
|
3035
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
3036
|
+
}
|
|
3037
|
+
var kCustomPromisifiedSymbol = typeof Symbol !== "undefined" ? Symbol("util.promisify.custom") : void 0;
|
|
3038
|
+
exports.promisify = function promisify(original) {
|
|
3039
|
+
if (typeof original !== "function")
|
|
3040
|
+
throw new TypeError('The "original" argument must be of type Function');
|
|
3041
|
+
if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
|
|
3042
|
+
var fn = original[kCustomPromisifiedSymbol];
|
|
3043
|
+
if (typeof fn !== "function") {
|
|
3044
|
+
throw new TypeError('The "util.promisify.custom" argument must be of type Function');
|
|
3045
|
+
}
|
|
3046
|
+
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
|
3047
|
+
value: fn,
|
|
3048
|
+
enumerable: false,
|
|
3049
|
+
writable: false,
|
|
3050
|
+
configurable: true
|
|
3051
|
+
});
|
|
3052
|
+
return fn;
|
|
3053
|
+
}
|
|
3054
|
+
function fn() {
|
|
3055
|
+
var promiseResolve, promiseReject;
|
|
3056
|
+
var promise = new Promise(function(resolve, reject) {
|
|
3057
|
+
promiseResolve = resolve;
|
|
3058
|
+
promiseReject = reject;
|
|
3059
|
+
});
|
|
3060
|
+
var args = [];
|
|
3061
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
3062
|
+
args.push(arguments[i]);
|
|
3063
|
+
}
|
|
3064
|
+
args.push(function(err, value) {
|
|
3065
|
+
if (err) {
|
|
3066
|
+
promiseReject(err);
|
|
3067
|
+
} else {
|
|
3068
|
+
promiseResolve(value);
|
|
3069
|
+
}
|
|
3070
|
+
});
|
|
3071
|
+
try {
|
|
3072
|
+
original.apply(this, args);
|
|
3073
|
+
} catch (err) {
|
|
3074
|
+
promiseReject(err);
|
|
3075
|
+
}
|
|
3076
|
+
return promise;
|
|
3077
|
+
}
|
|
3078
|
+
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
|
|
3079
|
+
if (kCustomPromisifiedSymbol)
|
|
3080
|
+
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
|
3081
|
+
value: fn,
|
|
3082
|
+
enumerable: false,
|
|
3083
|
+
writable: false,
|
|
3084
|
+
configurable: true
|
|
3085
|
+
});
|
|
3086
|
+
return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
|
|
3087
|
+
};
|
|
3088
|
+
exports.promisify.custom = kCustomPromisifiedSymbol;
|
|
3089
|
+
function callbackifyOnRejected(reason, cb) {
|
|
3090
|
+
if (!reason) {
|
|
3091
|
+
var newReason = new Error("Promise was rejected with a falsy value");
|
|
3092
|
+
newReason.reason = reason;
|
|
3093
|
+
reason = newReason;
|
|
3094
|
+
}
|
|
3095
|
+
return cb(reason);
|
|
3096
|
+
}
|
|
3097
|
+
function callbackify(original) {
|
|
3098
|
+
if (typeof original !== "function") {
|
|
3099
|
+
throw new TypeError('The "original" argument must be of type Function');
|
|
3100
|
+
}
|
|
3101
|
+
function callbackified() {
|
|
3102
|
+
var args = [];
|
|
3103
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
3104
|
+
args.push(arguments[i]);
|
|
3105
|
+
}
|
|
3106
|
+
var maybeCb = args.pop();
|
|
3107
|
+
if (typeof maybeCb !== "function") {
|
|
3108
|
+
throw new TypeError("The last argument must be of type Function");
|
|
3109
|
+
}
|
|
3110
|
+
var self2 = this;
|
|
3111
|
+
var cb = function() {
|
|
3112
|
+
return maybeCb.apply(self2, arguments);
|
|
3113
|
+
};
|
|
3114
|
+
original.apply(this, args).then(function(ret) {
|
|
3115
|
+
process.nextTick(cb, null, ret);
|
|
3116
|
+
}, function(rej) {
|
|
3117
|
+
process.nextTick(callbackifyOnRejected, rej, cb);
|
|
3118
|
+
});
|
|
3119
|
+
}
|
|
3120
|
+
Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
|
|
3121
|
+
Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
|
|
3122
|
+
return callbackified;
|
|
3123
|
+
}
|
|
3124
|
+
exports.callbackify = callbackify;
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
|
|
3128
|
+
// ../../node_modules/base64-js/index.js
|
|
3129
|
+
var require_base64_js = __commonJS({
|
|
3130
|
+
"../../node_modules/base64-js/index.js"(exports) {
|
|
3131
|
+
"use strict";
|
|
3132
|
+
exports.byteLength = byteLength;
|
|
3133
|
+
exports.toByteArray = toByteArray;
|
|
3134
|
+
exports.fromByteArray = fromByteArray;
|
|
3135
|
+
var lookup = [];
|
|
3136
|
+
var revLookup = [];
|
|
3137
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
3138
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3139
|
+
for (i = 0, len = code.length; i < len; ++i) {
|
|
3140
|
+
lookup[i] = code[i];
|
|
3141
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
3142
|
+
}
|
|
3143
|
+
var i;
|
|
3144
|
+
var len;
|
|
3145
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
3146
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
3147
|
+
function getLens(b64) {
|
|
3148
|
+
var len2 = b64.length;
|
|
3149
|
+
if (len2 % 4 > 0) {
|
|
3150
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
3151
|
+
}
|
|
3152
|
+
var validLen = b64.indexOf("=");
|
|
3153
|
+
if (validLen === -1)
|
|
3154
|
+
validLen = len2;
|
|
3155
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
3156
|
+
return [validLen, placeHoldersLen];
|
|
3157
|
+
}
|
|
3158
|
+
function byteLength(b64) {
|
|
3159
|
+
var lens = getLens(b64);
|
|
3160
|
+
var validLen = lens[0];
|
|
3161
|
+
var placeHoldersLen = lens[1];
|
|
3162
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
3163
|
+
}
|
|
3164
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
3165
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
3166
|
+
}
|
|
3167
|
+
function toByteArray(b64) {
|
|
3168
|
+
var tmp;
|
|
3169
|
+
var lens = getLens(b64);
|
|
3170
|
+
var validLen = lens[0];
|
|
3171
|
+
var placeHoldersLen = lens[1];
|
|
3172
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
3173
|
+
var curByte = 0;
|
|
3174
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
3175
|
+
var i2;
|
|
3176
|
+
for (i2 = 0; i2 < len2; i2 += 4) {
|
|
3177
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
3178
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
3179
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
3180
|
+
arr[curByte++] = tmp & 255;
|
|
3181
|
+
}
|
|
3182
|
+
if (placeHoldersLen === 2) {
|
|
3183
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
3184
|
+
arr[curByte++] = tmp & 255;
|
|
3185
|
+
}
|
|
3186
|
+
if (placeHoldersLen === 1) {
|
|
3187
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
3188
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
3189
|
+
arr[curByte++] = tmp & 255;
|
|
3190
|
+
}
|
|
3191
|
+
return arr;
|
|
3192
|
+
}
|
|
3193
|
+
function tripletToBase64(num) {
|
|
3194
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
3195
|
+
}
|
|
3196
|
+
function encodeChunk(uint8, start, end) {
|
|
3197
|
+
var tmp;
|
|
3198
|
+
var output = [];
|
|
3199
|
+
for (var i2 = start; i2 < end; i2 += 3) {
|
|
3200
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
3201
|
+
output.push(tripletToBase64(tmp));
|
|
3202
|
+
}
|
|
3203
|
+
return output.join("");
|
|
3204
|
+
}
|
|
3205
|
+
function fromByteArray(uint8) {
|
|
3206
|
+
var tmp;
|
|
3207
|
+
var len2 = uint8.length;
|
|
3208
|
+
var extraBytes = len2 % 3;
|
|
3209
|
+
var parts = [];
|
|
3210
|
+
var maxChunkLength = 16383;
|
|
3211
|
+
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
3212
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
3213
|
+
}
|
|
3214
|
+
if (extraBytes === 1) {
|
|
3215
|
+
tmp = uint8[len2 - 1];
|
|
3216
|
+
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
|
|
3217
|
+
} else if (extraBytes === 2) {
|
|
3218
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
3219
|
+
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
|
|
3220
|
+
}
|
|
3221
|
+
return parts.join("");
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
});
|
|
3225
|
+
|
|
3226
|
+
// ../../node_modules/ieee754/index.js
|
|
3227
|
+
var require_ieee754 = __commonJS({
|
|
3228
|
+
"../../node_modules/ieee754/index.js"(exports) {
|
|
3229
|
+
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
3230
|
+
var e, m;
|
|
3231
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
3232
|
+
var eMax = (1 << eLen) - 1;
|
|
3233
|
+
var eBias = eMax >> 1;
|
|
3234
|
+
var nBits = -7;
|
|
3235
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
3236
|
+
var d = isLE ? -1 : 1;
|
|
3237
|
+
var s = buffer[offset + i];
|
|
3238
|
+
i += d;
|
|
3239
|
+
e = s & (1 << -nBits) - 1;
|
|
3240
|
+
s >>= -nBits;
|
|
3241
|
+
nBits += eLen;
|
|
3242
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
3243
|
+
}
|
|
3244
|
+
m = e & (1 << -nBits) - 1;
|
|
3245
|
+
e >>= -nBits;
|
|
3246
|
+
nBits += mLen;
|
|
3247
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
3248
|
+
}
|
|
3249
|
+
if (e === 0) {
|
|
3250
|
+
e = 1 - eBias;
|
|
3251
|
+
} else if (e === eMax) {
|
|
3252
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
3253
|
+
} else {
|
|
3254
|
+
m = m + Math.pow(2, mLen);
|
|
3255
|
+
e = e - eBias;
|
|
3256
|
+
}
|
|
3257
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
3258
|
+
};
|
|
3259
|
+
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
3260
|
+
var e, m, c;
|
|
3261
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
3262
|
+
var eMax = (1 << eLen) - 1;
|
|
3263
|
+
var eBias = eMax >> 1;
|
|
3264
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
3265
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
3266
|
+
var d = isLE ? 1 : -1;
|
|
3267
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
3268
|
+
value = Math.abs(value);
|
|
3269
|
+
if (isNaN(value) || value === Infinity) {
|
|
3270
|
+
m = isNaN(value) ? 1 : 0;
|
|
3271
|
+
e = eMax;
|
|
3272
|
+
} else {
|
|
3273
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
3274
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
3275
|
+
e--;
|
|
3276
|
+
c *= 2;
|
|
3277
|
+
}
|
|
3278
|
+
if (e + eBias >= 1) {
|
|
3279
|
+
value += rt / c;
|
|
3280
|
+
} else {
|
|
3281
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
3282
|
+
}
|
|
3283
|
+
if (value * c >= 2) {
|
|
3284
|
+
e++;
|
|
3285
|
+
c /= 2;
|
|
3286
|
+
}
|
|
3287
|
+
if (e + eBias >= eMax) {
|
|
3288
|
+
m = 0;
|
|
3289
|
+
e = eMax;
|
|
3290
|
+
} else if (e + eBias >= 1) {
|
|
3291
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
3292
|
+
e = e + eBias;
|
|
3293
|
+
} else {
|
|
3294
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
3295
|
+
e = 0;
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
3299
|
+
}
|
|
3300
|
+
e = e << mLen | m;
|
|
3301
|
+
eLen += mLen;
|
|
3302
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
3303
|
+
}
|
|
3304
|
+
buffer[offset + i - d] |= s * 128;
|
|
3305
|
+
};
|
|
3306
|
+
}
|
|
3307
|
+
});
|
|
3308
|
+
|
|
3309
|
+
// ../../node_modules/buffer/index.js
|
|
3310
|
+
var require_buffer = __commonJS({
|
|
3311
|
+
"../../node_modules/buffer/index.js"(exports) {
|
|
3312
|
+
"use strict";
|
|
3313
|
+
var base64 = require_base64_js();
|
|
3314
|
+
var ieee754 = require_ieee754();
|
|
3315
|
+
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
3316
|
+
exports.Buffer = Buffer2;
|
|
3317
|
+
exports.SlowBuffer = SlowBuffer;
|
|
3318
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
3319
|
+
var K_MAX_LENGTH = 2147483647;
|
|
3320
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
3321
|
+
Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
3322
|
+
if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
3323
|
+
console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
|
|
3324
|
+
}
|
|
3325
|
+
function typedArraySupport() {
|
|
3326
|
+
try {
|
|
3327
|
+
var arr = new Uint8Array(1);
|
|
3328
|
+
var proto = { foo: function() {
|
|
3329
|
+
return 42;
|
|
3330
|
+
} };
|
|
3331
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
3332
|
+
Object.setPrototypeOf(arr, proto);
|
|
3333
|
+
return arr.foo() === 42;
|
|
3334
|
+
} catch (e) {
|
|
3335
|
+
return false;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
Object.defineProperty(Buffer2.prototype, "parent", {
|
|
3339
|
+
enumerable: true,
|
|
3340
|
+
get: function() {
|
|
3341
|
+
if (!Buffer2.isBuffer(this))
|
|
3342
|
+
return void 0;
|
|
3343
|
+
return this.buffer;
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
Object.defineProperty(Buffer2.prototype, "offset", {
|
|
3347
|
+
enumerable: true,
|
|
3348
|
+
get: function() {
|
|
3349
|
+
if (!Buffer2.isBuffer(this))
|
|
3350
|
+
return void 0;
|
|
3351
|
+
return this.byteOffset;
|
|
3352
|
+
}
|
|
3353
|
+
});
|
|
3354
|
+
function createBuffer(length) {
|
|
3355
|
+
if (length > K_MAX_LENGTH) {
|
|
3356
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
3357
|
+
}
|
|
3358
|
+
var buf = new Uint8Array(length);
|
|
3359
|
+
Object.setPrototypeOf(buf, Buffer2.prototype);
|
|
3360
|
+
return buf;
|
|
3361
|
+
}
|
|
3362
|
+
function Buffer2(arg, encodingOrOffset, length) {
|
|
3363
|
+
if (typeof arg === "number") {
|
|
3364
|
+
if (typeof encodingOrOffset === "string") {
|
|
3365
|
+
throw new TypeError('The "string" argument must be of type string. Received type number');
|
|
3366
|
+
}
|
|
3367
|
+
return allocUnsafe(arg);
|
|
3368
|
+
}
|
|
3369
|
+
return from(arg, encodingOrOffset, length);
|
|
3370
|
+
}
|
|
3371
|
+
Buffer2.poolSize = 8192;
|
|
3372
|
+
function from(value, encodingOrOffset, length) {
|
|
3373
|
+
if (typeof value === "string") {
|
|
3374
|
+
return fromString(value, encodingOrOffset);
|
|
3375
|
+
}
|
|
3376
|
+
if (ArrayBuffer.isView(value)) {
|
|
3377
|
+
return fromArrayView(value);
|
|
3378
|
+
}
|
|
3379
|
+
if (value == null) {
|
|
3380
|
+
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
|
|
3381
|
+
}
|
|
3382
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
3383
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
3384
|
+
}
|
|
3385
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
3386
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
3387
|
+
}
|
|
3388
|
+
if (typeof value === "number") {
|
|
3389
|
+
throw new TypeError('The "value" argument must not be of type number. Received type number');
|
|
3390
|
+
}
|
|
3391
|
+
var valueOf = value.valueOf && value.valueOf();
|
|
3392
|
+
if (valueOf != null && valueOf !== value) {
|
|
3393
|
+
return Buffer2.from(valueOf, encodingOrOffset, length);
|
|
3394
|
+
}
|
|
3395
|
+
var b = fromObject(value);
|
|
3396
|
+
if (b)
|
|
3397
|
+
return b;
|
|
3398
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
3399
|
+
return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
3400
|
+
}
|
|
3401
|
+
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
|
|
3402
|
+
}
|
|
3403
|
+
Buffer2.from = function(value, encodingOrOffset, length) {
|
|
3404
|
+
return from(value, encodingOrOffset, length);
|
|
3405
|
+
};
|
|
3406
|
+
Object.setPrototypeOf(Buffer2.prototype, Uint8Array.prototype);
|
|
3407
|
+
Object.setPrototypeOf(Buffer2, Uint8Array);
|
|
3408
|
+
function assertSize(size) {
|
|
3409
|
+
if (typeof size !== "number") {
|
|
3410
|
+
throw new TypeError('"size" argument must be of type number');
|
|
3411
|
+
} else if (size < 0) {
|
|
3412
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
function alloc(size, fill, encoding) {
|
|
3416
|
+
assertSize(size);
|
|
3417
|
+
if (size <= 0) {
|
|
3418
|
+
return createBuffer(size);
|
|
3419
|
+
}
|
|
3420
|
+
if (fill !== void 0) {
|
|
3421
|
+
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
|
|
3422
|
+
}
|
|
3423
|
+
return createBuffer(size);
|
|
3424
|
+
}
|
|
3425
|
+
Buffer2.alloc = function(size, fill, encoding) {
|
|
3426
|
+
return alloc(size, fill, encoding);
|
|
3427
|
+
};
|
|
3428
|
+
function allocUnsafe(size) {
|
|
3429
|
+
assertSize(size);
|
|
3430
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
3431
|
+
}
|
|
3432
|
+
Buffer2.allocUnsafe = function(size) {
|
|
3433
|
+
return allocUnsafe(size);
|
|
3434
|
+
};
|
|
3435
|
+
Buffer2.allocUnsafeSlow = function(size) {
|
|
3436
|
+
return allocUnsafe(size);
|
|
3437
|
+
};
|
|
3438
|
+
function fromString(string, encoding) {
|
|
3439
|
+
if (typeof encoding !== "string" || encoding === "") {
|
|
3440
|
+
encoding = "utf8";
|
|
3441
|
+
}
|
|
3442
|
+
if (!Buffer2.isEncoding(encoding)) {
|
|
3443
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
3444
|
+
}
|
|
3445
|
+
var length = byteLength(string, encoding) | 0;
|
|
3446
|
+
var buf = createBuffer(length);
|
|
3447
|
+
var actual = buf.write(string, encoding);
|
|
3448
|
+
if (actual !== length) {
|
|
3449
|
+
buf = buf.slice(0, actual);
|
|
3450
|
+
}
|
|
3451
|
+
return buf;
|
|
3452
|
+
}
|
|
3453
|
+
function fromArrayLike(array) {
|
|
3454
|
+
var length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
3455
|
+
var buf = createBuffer(length);
|
|
3456
|
+
for (var i = 0; i < length; i += 1) {
|
|
3457
|
+
buf[i] = array[i] & 255;
|
|
3458
|
+
}
|
|
3459
|
+
return buf;
|
|
3460
|
+
}
|
|
3461
|
+
function fromArrayView(arrayView) {
|
|
3462
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
3463
|
+
var copy = new Uint8Array(arrayView);
|
|
3464
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
3465
|
+
}
|
|
3466
|
+
return fromArrayLike(arrayView);
|
|
3467
|
+
}
|
|
3468
|
+
function fromArrayBuffer(array, byteOffset, length) {
|
|
3469
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
3470
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
3471
|
+
}
|
|
3472
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
3473
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
3474
|
+
}
|
|
3475
|
+
var buf;
|
|
3476
|
+
if (byteOffset === void 0 && length === void 0) {
|
|
3477
|
+
buf = new Uint8Array(array);
|
|
3478
|
+
} else if (length === void 0) {
|
|
3479
|
+
buf = new Uint8Array(array, byteOffset);
|
|
3480
|
+
} else {
|
|
3481
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
3482
|
+
}
|
|
3483
|
+
Object.setPrototypeOf(buf, Buffer2.prototype);
|
|
3484
|
+
return buf;
|
|
3485
|
+
}
|
|
3486
|
+
function fromObject(obj) {
|
|
3487
|
+
if (Buffer2.isBuffer(obj)) {
|
|
3488
|
+
var len = checked(obj.length) | 0;
|
|
3489
|
+
var buf = createBuffer(len);
|
|
3490
|
+
if (buf.length === 0) {
|
|
3491
|
+
return buf;
|
|
3492
|
+
}
|
|
3493
|
+
obj.copy(buf, 0, 0, len);
|
|
3494
|
+
return buf;
|
|
3495
|
+
}
|
|
3496
|
+
if (obj.length !== void 0) {
|
|
3497
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
3498
|
+
return createBuffer(0);
|
|
3499
|
+
}
|
|
3500
|
+
return fromArrayLike(obj);
|
|
3501
|
+
}
|
|
3502
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
3503
|
+
return fromArrayLike(obj.data);
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
function checked(length) {
|
|
3507
|
+
if (length >= K_MAX_LENGTH) {
|
|
3508
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
3509
|
+
}
|
|
3510
|
+
return length | 0;
|
|
3511
|
+
}
|
|
3512
|
+
function SlowBuffer(length) {
|
|
3513
|
+
if (+length != length) {
|
|
3514
|
+
length = 0;
|
|
3515
|
+
}
|
|
3516
|
+
return Buffer2.alloc(+length);
|
|
3517
|
+
}
|
|
3518
|
+
Buffer2.isBuffer = function isBuffer(b) {
|
|
3519
|
+
return b != null && b._isBuffer === true && b !== Buffer2.prototype;
|
|
3520
|
+
};
|
|
3521
|
+
Buffer2.compare = function compare(a, b) {
|
|
3522
|
+
if (isInstance(a, Uint8Array))
|
|
3523
|
+
a = Buffer2.from(a, a.offset, a.byteLength);
|
|
3524
|
+
if (isInstance(b, Uint8Array))
|
|
3525
|
+
b = Buffer2.from(b, b.offset, b.byteLength);
|
|
3526
|
+
if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
|
|
3527
|
+
throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
|
|
3528
|
+
}
|
|
3529
|
+
if (a === b)
|
|
3530
|
+
return 0;
|
|
3531
|
+
var x = a.length;
|
|
3532
|
+
var y = b.length;
|
|
3533
|
+
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
3534
|
+
if (a[i] !== b[i]) {
|
|
3535
|
+
x = a[i];
|
|
3536
|
+
y = b[i];
|
|
3537
|
+
break;
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
if (x < y)
|
|
3541
|
+
return -1;
|
|
3542
|
+
if (y < x)
|
|
3543
|
+
return 1;
|
|
3544
|
+
return 0;
|
|
3545
|
+
};
|
|
3546
|
+
Buffer2.isEncoding = function isEncoding(encoding) {
|
|
3547
|
+
switch (String(encoding).toLowerCase()) {
|
|
3548
|
+
case "hex":
|
|
3549
|
+
case "utf8":
|
|
3550
|
+
case "utf-8":
|
|
3551
|
+
case "ascii":
|
|
3552
|
+
case "latin1":
|
|
3553
|
+
case "binary":
|
|
3554
|
+
case "base64":
|
|
3555
|
+
case "ucs2":
|
|
3556
|
+
case "ucs-2":
|
|
3557
|
+
case "utf16le":
|
|
3558
|
+
case "utf-16le":
|
|
3559
|
+
return true;
|
|
3560
|
+
default:
|
|
3561
|
+
return false;
|
|
3562
|
+
}
|
|
3563
|
+
};
|
|
3564
|
+
Buffer2.concat = function concat(list, length) {
|
|
3565
|
+
if (!Array.isArray(list)) {
|
|
3566
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
3567
|
+
}
|
|
3568
|
+
if (list.length === 0) {
|
|
3569
|
+
return Buffer2.alloc(0);
|
|
3570
|
+
}
|
|
3571
|
+
var i;
|
|
3572
|
+
if (length === void 0) {
|
|
3573
|
+
length = 0;
|
|
3574
|
+
for (i = 0; i < list.length; ++i) {
|
|
3575
|
+
length += list[i].length;
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
var buffer = Buffer2.allocUnsafe(length);
|
|
3579
|
+
var pos = 0;
|
|
3580
|
+
for (i = 0; i < list.length; ++i) {
|
|
3581
|
+
var buf = list[i];
|
|
3582
|
+
if (isInstance(buf, Uint8Array)) {
|
|
3583
|
+
if (pos + buf.length > buffer.length) {
|
|
3584
|
+
Buffer2.from(buf).copy(buffer, pos);
|
|
3585
|
+
} else {
|
|
3586
|
+
Uint8Array.prototype.set.call(buffer, buf, pos);
|
|
3587
|
+
}
|
|
3588
|
+
} else if (!Buffer2.isBuffer(buf)) {
|
|
3589
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
3590
|
+
} else {
|
|
3591
|
+
buf.copy(buffer, pos);
|
|
3592
|
+
}
|
|
3593
|
+
pos += buf.length;
|
|
3594
|
+
}
|
|
3595
|
+
return buffer;
|
|
3596
|
+
};
|
|
3597
|
+
function byteLength(string, encoding) {
|
|
3598
|
+
if (Buffer2.isBuffer(string)) {
|
|
3599
|
+
return string.length;
|
|
3600
|
+
}
|
|
3601
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
3602
|
+
return string.byteLength;
|
|
3603
|
+
}
|
|
3604
|
+
if (typeof string !== "string") {
|
|
3605
|
+
throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string);
|
|
3606
|
+
}
|
|
3607
|
+
var len = string.length;
|
|
3608
|
+
var mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
3609
|
+
if (!mustMatch && len === 0)
|
|
3610
|
+
return 0;
|
|
3611
|
+
var loweredCase = false;
|
|
3612
|
+
for (; ; ) {
|
|
3613
|
+
switch (encoding) {
|
|
3614
|
+
case "ascii":
|
|
3615
|
+
case "latin1":
|
|
3616
|
+
case "binary":
|
|
3617
|
+
return len;
|
|
3618
|
+
case "utf8":
|
|
3619
|
+
case "utf-8":
|
|
3620
|
+
return utf8ToBytes(string).length;
|
|
3621
|
+
case "ucs2":
|
|
3622
|
+
case "ucs-2":
|
|
3623
|
+
case "utf16le":
|
|
3624
|
+
case "utf-16le":
|
|
3625
|
+
return len * 2;
|
|
3626
|
+
case "hex":
|
|
3627
|
+
return len >>> 1;
|
|
3628
|
+
case "base64":
|
|
3629
|
+
return base64ToBytes(string).length;
|
|
3630
|
+
default:
|
|
3631
|
+
if (loweredCase) {
|
|
3632
|
+
return mustMatch ? -1 : utf8ToBytes(string).length;
|
|
3633
|
+
}
|
|
3634
|
+
encoding = ("" + encoding).toLowerCase();
|
|
3635
|
+
loweredCase = true;
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
Buffer2.byteLength = byteLength;
|
|
3640
|
+
function slowToString(encoding, start, end) {
|
|
3641
|
+
var loweredCase = false;
|
|
3642
|
+
if (start === void 0 || start < 0) {
|
|
3643
|
+
start = 0;
|
|
3644
|
+
}
|
|
3645
|
+
if (start > this.length) {
|
|
3646
|
+
return "";
|
|
3647
|
+
}
|
|
3648
|
+
if (end === void 0 || end > this.length) {
|
|
3649
|
+
end = this.length;
|
|
3650
|
+
}
|
|
3651
|
+
if (end <= 0) {
|
|
3652
|
+
return "";
|
|
3653
|
+
}
|
|
3654
|
+
end >>>= 0;
|
|
3655
|
+
start >>>= 0;
|
|
3656
|
+
if (end <= start) {
|
|
3657
|
+
return "";
|
|
3658
|
+
}
|
|
3659
|
+
if (!encoding)
|
|
3660
|
+
encoding = "utf8";
|
|
3661
|
+
while (true) {
|
|
3662
|
+
switch (encoding) {
|
|
3663
|
+
case "hex":
|
|
3664
|
+
return hexSlice(this, start, end);
|
|
3665
|
+
case "utf8":
|
|
3666
|
+
case "utf-8":
|
|
3667
|
+
return utf8Slice(this, start, end);
|
|
3668
|
+
case "ascii":
|
|
3669
|
+
return asciiSlice(this, start, end);
|
|
3670
|
+
case "latin1":
|
|
3671
|
+
case "binary":
|
|
3672
|
+
return latin1Slice(this, start, end);
|
|
3673
|
+
case "base64":
|
|
3674
|
+
return base64Slice(this, start, end);
|
|
3675
|
+
case "ucs2":
|
|
3676
|
+
case "ucs-2":
|
|
3677
|
+
case "utf16le":
|
|
3678
|
+
case "utf-16le":
|
|
3679
|
+
return utf16leSlice(this, start, end);
|
|
3680
|
+
default:
|
|
3681
|
+
if (loweredCase)
|
|
3682
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
3683
|
+
encoding = (encoding + "").toLowerCase();
|
|
3684
|
+
loweredCase = true;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
Buffer2.prototype._isBuffer = true;
|
|
3689
|
+
function swap(b, n, m) {
|
|
3690
|
+
var i = b[n];
|
|
3691
|
+
b[n] = b[m];
|
|
3692
|
+
b[m] = i;
|
|
3693
|
+
}
|
|
3694
|
+
Buffer2.prototype.swap16 = function swap16() {
|
|
3695
|
+
var len = this.length;
|
|
3696
|
+
if (len % 2 !== 0) {
|
|
3697
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
3698
|
+
}
|
|
3699
|
+
for (var i = 0; i < len; i += 2) {
|
|
3700
|
+
swap(this, i, i + 1);
|
|
3701
|
+
}
|
|
3702
|
+
return this;
|
|
3703
|
+
};
|
|
3704
|
+
Buffer2.prototype.swap32 = function swap32() {
|
|
3705
|
+
var len = this.length;
|
|
3706
|
+
if (len % 4 !== 0) {
|
|
3707
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
3708
|
+
}
|
|
3709
|
+
for (var i = 0; i < len; i += 4) {
|
|
3710
|
+
swap(this, i, i + 3);
|
|
3711
|
+
swap(this, i + 1, i + 2);
|
|
3712
|
+
}
|
|
3713
|
+
return this;
|
|
3714
|
+
};
|
|
3715
|
+
Buffer2.prototype.swap64 = function swap64() {
|
|
3716
|
+
var len = this.length;
|
|
3717
|
+
if (len % 8 !== 0) {
|
|
3718
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
3719
|
+
}
|
|
3720
|
+
for (var i = 0; i < len; i += 8) {
|
|
3721
|
+
swap(this, i, i + 7);
|
|
3722
|
+
swap(this, i + 1, i + 6);
|
|
3723
|
+
swap(this, i + 2, i + 5);
|
|
3724
|
+
swap(this, i + 3, i + 4);
|
|
3725
|
+
}
|
|
3726
|
+
return this;
|
|
3727
|
+
};
|
|
3728
|
+
Buffer2.prototype.toString = function toString() {
|
|
3729
|
+
var length = this.length;
|
|
3730
|
+
if (length === 0)
|
|
3731
|
+
return "";
|
|
3732
|
+
if (arguments.length === 0)
|
|
3733
|
+
return utf8Slice(this, 0, length);
|
|
3734
|
+
return slowToString.apply(this, arguments);
|
|
3735
|
+
};
|
|
3736
|
+
Buffer2.prototype.toLocaleString = Buffer2.prototype.toString;
|
|
3737
|
+
Buffer2.prototype.equals = function equals(b) {
|
|
3738
|
+
if (!Buffer2.isBuffer(b))
|
|
3739
|
+
throw new TypeError("Argument must be a Buffer");
|
|
3740
|
+
if (this === b)
|
|
3741
|
+
return true;
|
|
3742
|
+
return Buffer2.compare(this, b) === 0;
|
|
3743
|
+
};
|
|
3744
|
+
Buffer2.prototype.inspect = function inspect() {
|
|
3745
|
+
var str = "";
|
|
3746
|
+
var max = exports.INSPECT_MAX_BYTES;
|
|
3747
|
+
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
3748
|
+
if (this.length > max)
|
|
3749
|
+
str += " ... ";
|
|
3750
|
+
return "<Buffer " + str + ">";
|
|
3751
|
+
};
|
|
3752
|
+
if (customInspectSymbol) {
|
|
3753
|
+
Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect;
|
|
3754
|
+
}
|
|
3755
|
+
Buffer2.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
3756
|
+
if (isInstance(target, Uint8Array)) {
|
|
3757
|
+
target = Buffer2.from(target, target.offset, target.byteLength);
|
|
3758
|
+
}
|
|
3759
|
+
if (!Buffer2.isBuffer(target)) {
|
|
3760
|
+
throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target);
|
|
3761
|
+
}
|
|
3762
|
+
if (start === void 0) {
|
|
3763
|
+
start = 0;
|
|
3764
|
+
}
|
|
3765
|
+
if (end === void 0) {
|
|
3766
|
+
end = target ? target.length : 0;
|
|
3767
|
+
}
|
|
3768
|
+
if (thisStart === void 0) {
|
|
3769
|
+
thisStart = 0;
|
|
3770
|
+
}
|
|
3771
|
+
if (thisEnd === void 0) {
|
|
3772
|
+
thisEnd = this.length;
|
|
3773
|
+
}
|
|
3774
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
3775
|
+
throw new RangeError("out of range index");
|
|
3776
|
+
}
|
|
3777
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
3778
|
+
return 0;
|
|
3779
|
+
}
|
|
3780
|
+
if (thisStart >= thisEnd) {
|
|
3781
|
+
return -1;
|
|
3782
|
+
}
|
|
3783
|
+
if (start >= end) {
|
|
3784
|
+
return 1;
|
|
3785
|
+
}
|
|
3786
|
+
start >>>= 0;
|
|
3787
|
+
end >>>= 0;
|
|
3788
|
+
thisStart >>>= 0;
|
|
3789
|
+
thisEnd >>>= 0;
|
|
3790
|
+
if (this === target)
|
|
3791
|
+
return 0;
|
|
3792
|
+
var x = thisEnd - thisStart;
|
|
3793
|
+
var y = end - start;
|
|
3794
|
+
var len = Math.min(x, y);
|
|
3795
|
+
var thisCopy = this.slice(thisStart, thisEnd);
|
|
3796
|
+
var targetCopy = target.slice(start, end);
|
|
3797
|
+
for (var i = 0; i < len; ++i) {
|
|
3798
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
3799
|
+
x = thisCopy[i];
|
|
3800
|
+
y = targetCopy[i];
|
|
3801
|
+
break;
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
if (x < y)
|
|
3805
|
+
return -1;
|
|
3806
|
+
if (y < x)
|
|
3807
|
+
return 1;
|
|
3808
|
+
return 0;
|
|
3809
|
+
};
|
|
3810
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
3811
|
+
if (buffer.length === 0)
|
|
3812
|
+
return -1;
|
|
3813
|
+
if (typeof byteOffset === "string") {
|
|
3814
|
+
encoding = byteOffset;
|
|
3815
|
+
byteOffset = 0;
|
|
3816
|
+
} else if (byteOffset > 2147483647) {
|
|
3817
|
+
byteOffset = 2147483647;
|
|
3818
|
+
} else if (byteOffset < -2147483648) {
|
|
3819
|
+
byteOffset = -2147483648;
|
|
3820
|
+
}
|
|
3821
|
+
byteOffset = +byteOffset;
|
|
3822
|
+
if (numberIsNaN(byteOffset)) {
|
|
3823
|
+
byteOffset = dir ? 0 : buffer.length - 1;
|
|
3824
|
+
}
|
|
3825
|
+
if (byteOffset < 0)
|
|
3826
|
+
byteOffset = buffer.length + byteOffset;
|
|
3827
|
+
if (byteOffset >= buffer.length) {
|
|
3828
|
+
if (dir)
|
|
3829
|
+
return -1;
|
|
3830
|
+
else
|
|
3831
|
+
byteOffset = buffer.length - 1;
|
|
3832
|
+
} else if (byteOffset < 0) {
|
|
3833
|
+
if (dir)
|
|
3834
|
+
byteOffset = 0;
|
|
3835
|
+
else
|
|
3836
|
+
return -1;
|
|
3837
|
+
}
|
|
3838
|
+
if (typeof val === "string") {
|
|
3839
|
+
val = Buffer2.from(val, encoding);
|
|
3840
|
+
}
|
|
3841
|
+
if (Buffer2.isBuffer(val)) {
|
|
3842
|
+
if (val.length === 0) {
|
|
3843
|
+
return -1;
|
|
3844
|
+
}
|
|
3845
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
3846
|
+
} else if (typeof val === "number") {
|
|
3847
|
+
val = val & 255;
|
|
3848
|
+
if (typeof Uint8Array.prototype.indexOf === "function") {
|
|
3849
|
+
if (dir) {
|
|
3850
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
3851
|
+
} else {
|
|
3852
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
3856
|
+
}
|
|
3857
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
3858
|
+
}
|
|
3859
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
3860
|
+
var indexSize = 1;
|
|
3861
|
+
var arrLength = arr.length;
|
|
3862
|
+
var valLength = val.length;
|
|
3863
|
+
if (encoding !== void 0) {
|
|
3864
|
+
encoding = String(encoding).toLowerCase();
|
|
3865
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
3866
|
+
if (arr.length < 2 || val.length < 2) {
|
|
3867
|
+
return -1;
|
|
3868
|
+
}
|
|
3869
|
+
indexSize = 2;
|
|
3870
|
+
arrLength /= 2;
|
|
3871
|
+
valLength /= 2;
|
|
3872
|
+
byteOffset /= 2;
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
function read(buf, i2) {
|
|
3876
|
+
if (indexSize === 1) {
|
|
3877
|
+
return buf[i2];
|
|
3878
|
+
} else {
|
|
3879
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
var i;
|
|
3883
|
+
if (dir) {
|
|
3884
|
+
var foundIndex = -1;
|
|
3885
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
3886
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
3887
|
+
if (foundIndex === -1)
|
|
3888
|
+
foundIndex = i;
|
|
3889
|
+
if (i - foundIndex + 1 === valLength)
|
|
3890
|
+
return foundIndex * indexSize;
|
|
3891
|
+
} else {
|
|
3892
|
+
if (foundIndex !== -1)
|
|
3893
|
+
i -= i - foundIndex;
|
|
3894
|
+
foundIndex = -1;
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
} else {
|
|
3898
|
+
if (byteOffset + valLength > arrLength)
|
|
3899
|
+
byteOffset = arrLength - valLength;
|
|
3900
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
3901
|
+
var found = true;
|
|
3902
|
+
for (var j = 0; j < valLength; j++) {
|
|
3903
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
3904
|
+
found = false;
|
|
3905
|
+
break;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
if (found)
|
|
3909
|
+
return i;
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
return -1;
|
|
3913
|
+
}
|
|
3914
|
+
Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
3915
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
3916
|
+
};
|
|
3917
|
+
Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
3918
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
3919
|
+
};
|
|
3920
|
+
Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
3921
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
3922
|
+
};
|
|
3923
|
+
function hexWrite(buf, string, offset, length) {
|
|
3924
|
+
offset = Number(offset) || 0;
|
|
3925
|
+
var remaining = buf.length - offset;
|
|
3926
|
+
if (!length) {
|
|
3927
|
+
length = remaining;
|
|
3928
|
+
} else {
|
|
3929
|
+
length = Number(length);
|
|
3930
|
+
if (length > remaining) {
|
|
3931
|
+
length = remaining;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
var strLen = string.length;
|
|
3935
|
+
if (length > strLen / 2) {
|
|
3936
|
+
length = strLen / 2;
|
|
3937
|
+
}
|
|
3938
|
+
for (var i = 0; i < length; ++i) {
|
|
3939
|
+
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
3940
|
+
if (numberIsNaN(parsed))
|
|
3941
|
+
return i;
|
|
3942
|
+
buf[offset + i] = parsed;
|
|
3943
|
+
}
|
|
3944
|
+
return i;
|
|
3945
|
+
}
|
|
3946
|
+
function utf8Write(buf, string, offset, length) {
|
|
3947
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
3948
|
+
}
|
|
3949
|
+
function asciiWrite(buf, string, offset, length) {
|
|
3950
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
3951
|
+
}
|
|
3952
|
+
function base64Write(buf, string, offset, length) {
|
|
3953
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
3954
|
+
}
|
|
3955
|
+
function ucs2Write(buf, string, offset, length) {
|
|
3956
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
3957
|
+
}
|
|
3958
|
+
Buffer2.prototype.write = function write(string, offset, length, encoding) {
|
|
3959
|
+
if (offset === void 0) {
|
|
3960
|
+
encoding = "utf8";
|
|
3961
|
+
length = this.length;
|
|
3962
|
+
offset = 0;
|
|
3963
|
+
} else if (length === void 0 && typeof offset === "string") {
|
|
3964
|
+
encoding = offset;
|
|
3965
|
+
length = this.length;
|
|
3966
|
+
offset = 0;
|
|
3967
|
+
} else if (isFinite(offset)) {
|
|
3968
|
+
offset = offset >>> 0;
|
|
3969
|
+
if (isFinite(length)) {
|
|
3970
|
+
length = length >>> 0;
|
|
3971
|
+
if (encoding === void 0)
|
|
3972
|
+
encoding = "utf8";
|
|
3973
|
+
} else {
|
|
3974
|
+
encoding = length;
|
|
3975
|
+
length = void 0;
|
|
3976
|
+
}
|
|
3977
|
+
} else {
|
|
3978
|
+
throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
3979
|
+
}
|
|
3980
|
+
var remaining = this.length - offset;
|
|
3981
|
+
if (length === void 0 || length > remaining)
|
|
3982
|
+
length = remaining;
|
|
3983
|
+
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
3984
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
3985
|
+
}
|
|
3986
|
+
if (!encoding)
|
|
3987
|
+
encoding = "utf8";
|
|
3988
|
+
var loweredCase = false;
|
|
3989
|
+
for (; ; ) {
|
|
3990
|
+
switch (encoding) {
|
|
3991
|
+
case "hex":
|
|
3992
|
+
return hexWrite(this, string, offset, length);
|
|
3993
|
+
case "utf8":
|
|
3994
|
+
case "utf-8":
|
|
3995
|
+
return utf8Write(this, string, offset, length);
|
|
3996
|
+
case "ascii":
|
|
3997
|
+
case "latin1":
|
|
3998
|
+
case "binary":
|
|
3999
|
+
return asciiWrite(this, string, offset, length);
|
|
4000
|
+
case "base64":
|
|
4001
|
+
return base64Write(this, string, offset, length);
|
|
4002
|
+
case "ucs2":
|
|
4003
|
+
case "ucs-2":
|
|
4004
|
+
case "utf16le":
|
|
4005
|
+
case "utf-16le":
|
|
4006
|
+
return ucs2Write(this, string, offset, length);
|
|
4007
|
+
default:
|
|
4008
|
+
if (loweredCase)
|
|
4009
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
4010
|
+
encoding = ("" + encoding).toLowerCase();
|
|
4011
|
+
loweredCase = true;
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
};
|
|
4015
|
+
Buffer2.prototype.toJSON = function toJSON() {
|
|
4016
|
+
return {
|
|
4017
|
+
type: "Buffer",
|
|
4018
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
4019
|
+
};
|
|
4020
|
+
};
|
|
4021
|
+
function base64Slice(buf, start, end) {
|
|
4022
|
+
if (start === 0 && end === buf.length) {
|
|
4023
|
+
return base64.fromByteArray(buf);
|
|
4024
|
+
} else {
|
|
4025
|
+
return base64.fromByteArray(buf.slice(start, end));
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
function utf8Slice(buf, start, end) {
|
|
4029
|
+
end = Math.min(buf.length, end);
|
|
4030
|
+
var res = [];
|
|
4031
|
+
var i = start;
|
|
4032
|
+
while (i < end) {
|
|
4033
|
+
var firstByte = buf[i];
|
|
4034
|
+
var codePoint = null;
|
|
4035
|
+
var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
4036
|
+
if (i + bytesPerSequence <= end) {
|
|
4037
|
+
var secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
4038
|
+
switch (bytesPerSequence) {
|
|
4039
|
+
case 1:
|
|
4040
|
+
if (firstByte < 128) {
|
|
4041
|
+
codePoint = firstByte;
|
|
4042
|
+
}
|
|
4043
|
+
break;
|
|
4044
|
+
case 2:
|
|
4045
|
+
secondByte = buf[i + 1];
|
|
4046
|
+
if ((secondByte & 192) === 128) {
|
|
4047
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
4048
|
+
if (tempCodePoint > 127) {
|
|
4049
|
+
codePoint = tempCodePoint;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
break;
|
|
4053
|
+
case 3:
|
|
4054
|
+
secondByte = buf[i + 1];
|
|
4055
|
+
thirdByte = buf[i + 2];
|
|
4056
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
4057
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
4058
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
4059
|
+
codePoint = tempCodePoint;
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
break;
|
|
4063
|
+
case 4:
|
|
4064
|
+
secondByte = buf[i + 1];
|
|
4065
|
+
thirdByte = buf[i + 2];
|
|
4066
|
+
fourthByte = buf[i + 3];
|
|
4067
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
4068
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
4069
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
4070
|
+
codePoint = tempCodePoint;
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
if (codePoint === null) {
|
|
4076
|
+
codePoint = 65533;
|
|
4077
|
+
bytesPerSequence = 1;
|
|
4078
|
+
} else if (codePoint > 65535) {
|
|
4079
|
+
codePoint -= 65536;
|
|
4080
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
4081
|
+
codePoint = 56320 | codePoint & 1023;
|
|
4082
|
+
}
|
|
4083
|
+
res.push(codePoint);
|
|
4084
|
+
i += bytesPerSequence;
|
|
4085
|
+
}
|
|
4086
|
+
return decodeCodePointsArray(res);
|
|
4087
|
+
}
|
|
4088
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
4089
|
+
function decodeCodePointsArray(codePoints) {
|
|
4090
|
+
var len = codePoints.length;
|
|
4091
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
4092
|
+
return String.fromCharCode.apply(String, codePoints);
|
|
4093
|
+
}
|
|
4094
|
+
var res = "";
|
|
4095
|
+
var i = 0;
|
|
4096
|
+
while (i < len) {
|
|
4097
|
+
res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
|
|
4098
|
+
}
|
|
4099
|
+
return res;
|
|
4100
|
+
}
|
|
4101
|
+
function asciiSlice(buf, start, end) {
|
|
4102
|
+
var ret = "";
|
|
4103
|
+
end = Math.min(buf.length, end);
|
|
4104
|
+
for (var i = start; i < end; ++i) {
|
|
4105
|
+
ret += String.fromCharCode(buf[i] & 127);
|
|
4106
|
+
}
|
|
4107
|
+
return ret;
|
|
4108
|
+
}
|
|
4109
|
+
function latin1Slice(buf, start, end) {
|
|
4110
|
+
var ret = "";
|
|
4111
|
+
end = Math.min(buf.length, end);
|
|
4112
|
+
for (var i = start; i < end; ++i) {
|
|
4113
|
+
ret += String.fromCharCode(buf[i]);
|
|
4114
|
+
}
|
|
4115
|
+
return ret;
|
|
4116
|
+
}
|
|
4117
|
+
function hexSlice(buf, start, end) {
|
|
4118
|
+
var len = buf.length;
|
|
4119
|
+
if (!start || start < 0)
|
|
4120
|
+
start = 0;
|
|
4121
|
+
if (!end || end < 0 || end > len)
|
|
4122
|
+
end = len;
|
|
4123
|
+
var out = "";
|
|
4124
|
+
for (var i = start; i < end; ++i) {
|
|
4125
|
+
out += hexSliceLookupTable[buf[i]];
|
|
4126
|
+
}
|
|
4127
|
+
return out;
|
|
4128
|
+
}
|
|
4129
|
+
function utf16leSlice(buf, start, end) {
|
|
4130
|
+
var bytes = buf.slice(start, end);
|
|
4131
|
+
var res = "";
|
|
4132
|
+
for (var i = 0; i < bytes.length - 1; i += 2) {
|
|
4133
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
4134
|
+
}
|
|
4135
|
+
return res;
|
|
4136
|
+
}
|
|
4137
|
+
Buffer2.prototype.slice = function slice(start, end) {
|
|
4138
|
+
var len = this.length;
|
|
4139
|
+
start = ~~start;
|
|
4140
|
+
end = end === void 0 ? len : ~~end;
|
|
4141
|
+
if (start < 0) {
|
|
4142
|
+
start += len;
|
|
4143
|
+
if (start < 0)
|
|
4144
|
+
start = 0;
|
|
4145
|
+
} else if (start > len) {
|
|
4146
|
+
start = len;
|
|
4147
|
+
}
|
|
4148
|
+
if (end < 0) {
|
|
4149
|
+
end += len;
|
|
4150
|
+
if (end < 0)
|
|
4151
|
+
end = 0;
|
|
4152
|
+
} else if (end > len) {
|
|
4153
|
+
end = len;
|
|
4154
|
+
}
|
|
4155
|
+
if (end < start)
|
|
4156
|
+
end = start;
|
|
4157
|
+
var newBuf = this.subarray(start, end);
|
|
4158
|
+
Object.setPrototypeOf(newBuf, Buffer2.prototype);
|
|
4159
|
+
return newBuf;
|
|
4160
|
+
};
|
|
4161
|
+
function checkOffset(offset, ext, length) {
|
|
4162
|
+
if (offset % 1 !== 0 || offset < 0)
|
|
4163
|
+
throw new RangeError("offset is not uint");
|
|
4164
|
+
if (offset + ext > length)
|
|
4165
|
+
throw new RangeError("Trying to access beyond buffer length");
|
|
4166
|
+
}
|
|
4167
|
+
Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
4168
|
+
offset = offset >>> 0;
|
|
4169
|
+
byteLength2 = byteLength2 >>> 0;
|
|
4170
|
+
if (!noAssert)
|
|
4171
|
+
checkOffset(offset, byteLength2, this.length);
|
|
4172
|
+
var val = this[offset];
|
|
4173
|
+
var mul = 1;
|
|
4174
|
+
var i = 0;
|
|
4175
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
4176
|
+
val += this[offset + i] * mul;
|
|
4177
|
+
}
|
|
4178
|
+
return val;
|
|
4179
|
+
};
|
|
4180
|
+
Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
4181
|
+
offset = offset >>> 0;
|
|
4182
|
+
byteLength2 = byteLength2 >>> 0;
|
|
4183
|
+
if (!noAssert) {
|
|
4184
|
+
checkOffset(offset, byteLength2, this.length);
|
|
4185
|
+
}
|
|
4186
|
+
var val = this[offset + --byteLength2];
|
|
4187
|
+
var mul = 1;
|
|
4188
|
+
while (byteLength2 > 0 && (mul *= 256)) {
|
|
4189
|
+
val += this[offset + --byteLength2] * mul;
|
|
4190
|
+
}
|
|
4191
|
+
return val;
|
|
4192
|
+
};
|
|
4193
|
+
Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
4194
|
+
offset = offset >>> 0;
|
|
4195
|
+
if (!noAssert)
|
|
4196
|
+
checkOffset(offset, 1, this.length);
|
|
4197
|
+
return this[offset];
|
|
4198
|
+
};
|
|
4199
|
+
Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
4200
|
+
offset = offset >>> 0;
|
|
4201
|
+
if (!noAssert)
|
|
4202
|
+
checkOffset(offset, 2, this.length);
|
|
4203
|
+
return this[offset] | this[offset + 1] << 8;
|
|
4204
|
+
};
|
|
4205
|
+
Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
4206
|
+
offset = offset >>> 0;
|
|
4207
|
+
if (!noAssert)
|
|
4208
|
+
checkOffset(offset, 2, this.length);
|
|
4209
|
+
return this[offset] << 8 | this[offset + 1];
|
|
4210
|
+
};
|
|
4211
|
+
Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
4212
|
+
offset = offset >>> 0;
|
|
4213
|
+
if (!noAssert)
|
|
4214
|
+
checkOffset(offset, 4, this.length);
|
|
4215
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
4216
|
+
};
|
|
4217
|
+
Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
4218
|
+
offset = offset >>> 0;
|
|
4219
|
+
if (!noAssert)
|
|
4220
|
+
checkOffset(offset, 4, this.length);
|
|
4221
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
4222
|
+
};
|
|
4223
|
+
Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
4224
|
+
offset = offset >>> 0;
|
|
4225
|
+
byteLength2 = byteLength2 >>> 0;
|
|
4226
|
+
if (!noAssert)
|
|
4227
|
+
checkOffset(offset, byteLength2, this.length);
|
|
4228
|
+
var val = this[offset];
|
|
4229
|
+
var mul = 1;
|
|
4230
|
+
var i = 0;
|
|
4231
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
4232
|
+
val += this[offset + i] * mul;
|
|
4233
|
+
}
|
|
4234
|
+
mul *= 128;
|
|
4235
|
+
if (val >= mul)
|
|
4236
|
+
val -= Math.pow(2, 8 * byteLength2);
|
|
4237
|
+
return val;
|
|
4238
|
+
};
|
|
4239
|
+
Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
4240
|
+
offset = offset >>> 0;
|
|
4241
|
+
byteLength2 = byteLength2 >>> 0;
|
|
4242
|
+
if (!noAssert)
|
|
4243
|
+
checkOffset(offset, byteLength2, this.length);
|
|
4244
|
+
var i = byteLength2;
|
|
4245
|
+
var mul = 1;
|
|
4246
|
+
var val = this[offset + --i];
|
|
4247
|
+
while (i > 0 && (mul *= 256)) {
|
|
4248
|
+
val += this[offset + --i] * mul;
|
|
4249
|
+
}
|
|
4250
|
+
mul *= 128;
|
|
4251
|
+
if (val >= mul)
|
|
4252
|
+
val -= Math.pow(2, 8 * byteLength2);
|
|
4253
|
+
return val;
|
|
4254
|
+
};
|
|
4255
|
+
Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
4256
|
+
offset = offset >>> 0;
|
|
4257
|
+
if (!noAssert)
|
|
4258
|
+
checkOffset(offset, 1, this.length);
|
|
4259
|
+
if (!(this[offset] & 128))
|
|
4260
|
+
return this[offset];
|
|
4261
|
+
return (255 - this[offset] + 1) * -1;
|
|
4262
|
+
};
|
|
4263
|
+
Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
4264
|
+
offset = offset >>> 0;
|
|
4265
|
+
if (!noAssert)
|
|
4266
|
+
checkOffset(offset, 2, this.length);
|
|
4267
|
+
var val = this[offset] | this[offset + 1] << 8;
|
|
4268
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
4269
|
+
};
|
|
4270
|
+
Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
4271
|
+
offset = offset >>> 0;
|
|
4272
|
+
if (!noAssert)
|
|
4273
|
+
checkOffset(offset, 2, this.length);
|
|
4274
|
+
var val = this[offset + 1] | this[offset] << 8;
|
|
4275
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
4276
|
+
};
|
|
4277
|
+
Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
4278
|
+
offset = offset >>> 0;
|
|
4279
|
+
if (!noAssert)
|
|
4280
|
+
checkOffset(offset, 4, this.length);
|
|
4281
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
4282
|
+
};
|
|
4283
|
+
Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
4284
|
+
offset = offset >>> 0;
|
|
4285
|
+
if (!noAssert)
|
|
4286
|
+
checkOffset(offset, 4, this.length);
|
|
4287
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
4288
|
+
};
|
|
4289
|
+
Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
4290
|
+
offset = offset >>> 0;
|
|
4291
|
+
if (!noAssert)
|
|
4292
|
+
checkOffset(offset, 4, this.length);
|
|
4293
|
+
return ieee754.read(this, offset, true, 23, 4);
|
|
4294
|
+
};
|
|
4295
|
+
Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
4296
|
+
offset = offset >>> 0;
|
|
4297
|
+
if (!noAssert)
|
|
4298
|
+
checkOffset(offset, 4, this.length);
|
|
4299
|
+
return ieee754.read(this, offset, false, 23, 4);
|
|
4300
|
+
};
|
|
4301
|
+
Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
4302
|
+
offset = offset >>> 0;
|
|
4303
|
+
if (!noAssert)
|
|
4304
|
+
checkOffset(offset, 8, this.length);
|
|
4305
|
+
return ieee754.read(this, offset, true, 52, 8);
|
|
4306
|
+
};
|
|
4307
|
+
Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
4308
|
+
offset = offset >>> 0;
|
|
4309
|
+
if (!noAssert)
|
|
4310
|
+
checkOffset(offset, 8, this.length);
|
|
4311
|
+
return ieee754.read(this, offset, false, 52, 8);
|
|
4312
|
+
};
|
|
4313
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
4314
|
+
if (!Buffer2.isBuffer(buf))
|
|
4315
|
+
throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
4316
|
+
if (value > max || value < min)
|
|
4317
|
+
throw new RangeError('"value" argument is out of bounds');
|
|
4318
|
+
if (offset + ext > buf.length)
|
|
4319
|
+
throw new RangeError("Index out of range");
|
|
4320
|
+
}
|
|
4321
|
+
Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
4322
|
+
value = +value;
|
|
4323
|
+
offset = offset >>> 0;
|
|
4324
|
+
byteLength2 = byteLength2 >>> 0;
|
|
4325
|
+
if (!noAssert) {
|
|
4326
|
+
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
4327
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
4328
|
+
}
|
|
4329
|
+
var mul = 1;
|
|
4330
|
+
var i = 0;
|
|
4331
|
+
this[offset] = value & 255;
|
|
4332
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
4333
|
+
this[offset + i] = value / mul & 255;
|
|
4334
|
+
}
|
|
4335
|
+
return offset + byteLength2;
|
|
4336
|
+
};
|
|
4337
|
+
Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
4338
|
+
value = +value;
|
|
4339
|
+
offset = offset >>> 0;
|
|
4340
|
+
byteLength2 = byteLength2 >>> 0;
|
|
4341
|
+
if (!noAssert) {
|
|
4342
|
+
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
4343
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
4344
|
+
}
|
|
4345
|
+
var i = byteLength2 - 1;
|
|
4346
|
+
var mul = 1;
|
|
4347
|
+
this[offset + i] = value & 255;
|
|
4348
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
4349
|
+
this[offset + i] = value / mul & 255;
|
|
4350
|
+
}
|
|
4351
|
+
return offset + byteLength2;
|
|
4352
|
+
};
|
|
4353
|
+
Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
4354
|
+
value = +value;
|
|
4355
|
+
offset = offset >>> 0;
|
|
4356
|
+
if (!noAssert)
|
|
4357
|
+
checkInt(this, value, offset, 1, 255, 0);
|
|
4358
|
+
this[offset] = value & 255;
|
|
4359
|
+
return offset + 1;
|
|
4360
|
+
};
|
|
4361
|
+
Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
4362
|
+
value = +value;
|
|
4363
|
+
offset = offset >>> 0;
|
|
4364
|
+
if (!noAssert)
|
|
4365
|
+
checkInt(this, value, offset, 2, 65535, 0);
|
|
4366
|
+
this[offset] = value & 255;
|
|
4367
|
+
this[offset + 1] = value >>> 8;
|
|
4368
|
+
return offset + 2;
|
|
4369
|
+
};
|
|
4370
|
+
Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
4371
|
+
value = +value;
|
|
4372
|
+
offset = offset >>> 0;
|
|
4373
|
+
if (!noAssert)
|
|
4374
|
+
checkInt(this, value, offset, 2, 65535, 0);
|
|
4375
|
+
this[offset] = value >>> 8;
|
|
4376
|
+
this[offset + 1] = value & 255;
|
|
4377
|
+
return offset + 2;
|
|
4378
|
+
};
|
|
4379
|
+
Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
4380
|
+
value = +value;
|
|
4381
|
+
offset = offset >>> 0;
|
|
4382
|
+
if (!noAssert)
|
|
4383
|
+
checkInt(this, value, offset, 4, 4294967295, 0);
|
|
4384
|
+
this[offset + 3] = value >>> 24;
|
|
4385
|
+
this[offset + 2] = value >>> 16;
|
|
4386
|
+
this[offset + 1] = value >>> 8;
|
|
4387
|
+
this[offset] = value & 255;
|
|
4388
|
+
return offset + 4;
|
|
4389
|
+
};
|
|
4390
|
+
Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
4391
|
+
value = +value;
|
|
4392
|
+
offset = offset >>> 0;
|
|
4393
|
+
if (!noAssert)
|
|
4394
|
+
checkInt(this, value, offset, 4, 4294967295, 0);
|
|
4395
|
+
this[offset] = value >>> 24;
|
|
4396
|
+
this[offset + 1] = value >>> 16;
|
|
4397
|
+
this[offset + 2] = value >>> 8;
|
|
4398
|
+
this[offset + 3] = value & 255;
|
|
4399
|
+
return offset + 4;
|
|
4400
|
+
};
|
|
4401
|
+
Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
4402
|
+
value = +value;
|
|
4403
|
+
offset = offset >>> 0;
|
|
4404
|
+
if (!noAssert) {
|
|
4405
|
+
var limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
4406
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
4407
|
+
}
|
|
4408
|
+
var i = 0;
|
|
4409
|
+
var mul = 1;
|
|
4410
|
+
var sub = 0;
|
|
4411
|
+
this[offset] = value & 255;
|
|
4412
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
4413
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
4414
|
+
sub = 1;
|
|
4415
|
+
}
|
|
4416
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
4417
|
+
}
|
|
4418
|
+
return offset + byteLength2;
|
|
4419
|
+
};
|
|
4420
|
+
Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
4421
|
+
value = +value;
|
|
4422
|
+
offset = offset >>> 0;
|
|
4423
|
+
if (!noAssert) {
|
|
4424
|
+
var limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
4425
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
4426
|
+
}
|
|
4427
|
+
var i = byteLength2 - 1;
|
|
4428
|
+
var mul = 1;
|
|
4429
|
+
var sub = 0;
|
|
4430
|
+
this[offset + i] = value & 255;
|
|
4431
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
4432
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
4433
|
+
sub = 1;
|
|
4434
|
+
}
|
|
4435
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
4436
|
+
}
|
|
4437
|
+
return offset + byteLength2;
|
|
4438
|
+
};
|
|
4439
|
+
Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
4440
|
+
value = +value;
|
|
4441
|
+
offset = offset >>> 0;
|
|
4442
|
+
if (!noAssert)
|
|
4443
|
+
checkInt(this, value, offset, 1, 127, -128);
|
|
4444
|
+
if (value < 0)
|
|
4445
|
+
value = 255 + value + 1;
|
|
4446
|
+
this[offset] = value & 255;
|
|
4447
|
+
return offset + 1;
|
|
4448
|
+
};
|
|
4449
|
+
Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
4450
|
+
value = +value;
|
|
4451
|
+
offset = offset >>> 0;
|
|
4452
|
+
if (!noAssert)
|
|
4453
|
+
checkInt(this, value, offset, 2, 32767, -32768);
|
|
4454
|
+
this[offset] = value & 255;
|
|
4455
|
+
this[offset + 1] = value >>> 8;
|
|
4456
|
+
return offset + 2;
|
|
4457
|
+
};
|
|
4458
|
+
Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
4459
|
+
value = +value;
|
|
4460
|
+
offset = offset >>> 0;
|
|
4461
|
+
if (!noAssert)
|
|
4462
|
+
checkInt(this, value, offset, 2, 32767, -32768);
|
|
4463
|
+
this[offset] = value >>> 8;
|
|
4464
|
+
this[offset + 1] = value & 255;
|
|
4465
|
+
return offset + 2;
|
|
4466
|
+
};
|
|
4467
|
+
Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
4468
|
+
value = +value;
|
|
4469
|
+
offset = offset >>> 0;
|
|
4470
|
+
if (!noAssert)
|
|
4471
|
+
checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
4472
|
+
this[offset] = value & 255;
|
|
4473
|
+
this[offset + 1] = value >>> 8;
|
|
4474
|
+
this[offset + 2] = value >>> 16;
|
|
4475
|
+
this[offset + 3] = value >>> 24;
|
|
4476
|
+
return offset + 4;
|
|
4477
|
+
};
|
|
4478
|
+
Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
4479
|
+
value = +value;
|
|
4480
|
+
offset = offset >>> 0;
|
|
4481
|
+
if (!noAssert)
|
|
4482
|
+
checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
4483
|
+
if (value < 0)
|
|
4484
|
+
value = 4294967295 + value + 1;
|
|
4485
|
+
this[offset] = value >>> 24;
|
|
4486
|
+
this[offset + 1] = value >>> 16;
|
|
4487
|
+
this[offset + 2] = value >>> 8;
|
|
4488
|
+
this[offset + 3] = value & 255;
|
|
4489
|
+
return offset + 4;
|
|
4490
|
+
};
|
|
4491
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
4492
|
+
if (offset + ext > buf.length)
|
|
4493
|
+
throw new RangeError("Index out of range");
|
|
4494
|
+
if (offset < 0)
|
|
4495
|
+
throw new RangeError("Index out of range");
|
|
4496
|
+
}
|
|
4497
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
4498
|
+
value = +value;
|
|
4499
|
+
offset = offset >>> 0;
|
|
4500
|
+
if (!noAssert) {
|
|
4501
|
+
checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
|
|
4502
|
+
}
|
|
4503
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
4504
|
+
return offset + 4;
|
|
4505
|
+
}
|
|
4506
|
+
Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
4507
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
4508
|
+
};
|
|
4509
|
+
Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
4510
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
4511
|
+
};
|
|
4512
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
4513
|
+
value = +value;
|
|
4514
|
+
offset = offset >>> 0;
|
|
4515
|
+
if (!noAssert) {
|
|
4516
|
+
checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
|
|
4517
|
+
}
|
|
4518
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
4519
|
+
return offset + 8;
|
|
4520
|
+
}
|
|
4521
|
+
Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
4522
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
4523
|
+
};
|
|
4524
|
+
Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
4525
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
4526
|
+
};
|
|
4527
|
+
Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
|
|
4528
|
+
if (!Buffer2.isBuffer(target))
|
|
4529
|
+
throw new TypeError("argument should be a Buffer");
|
|
4530
|
+
if (!start)
|
|
4531
|
+
start = 0;
|
|
4532
|
+
if (!end && end !== 0)
|
|
4533
|
+
end = this.length;
|
|
4534
|
+
if (targetStart >= target.length)
|
|
4535
|
+
targetStart = target.length;
|
|
4536
|
+
if (!targetStart)
|
|
4537
|
+
targetStart = 0;
|
|
4538
|
+
if (end > 0 && end < start)
|
|
4539
|
+
end = start;
|
|
4540
|
+
if (end === start)
|
|
4541
|
+
return 0;
|
|
4542
|
+
if (target.length === 0 || this.length === 0)
|
|
4543
|
+
return 0;
|
|
4544
|
+
if (targetStart < 0) {
|
|
4545
|
+
throw new RangeError("targetStart out of bounds");
|
|
4546
|
+
}
|
|
4547
|
+
if (start < 0 || start >= this.length)
|
|
4548
|
+
throw new RangeError("Index out of range");
|
|
4549
|
+
if (end < 0)
|
|
4550
|
+
throw new RangeError("sourceEnd out of bounds");
|
|
4551
|
+
if (end > this.length)
|
|
4552
|
+
end = this.length;
|
|
4553
|
+
if (target.length - targetStart < end - start) {
|
|
4554
|
+
end = target.length - targetStart + start;
|
|
4555
|
+
}
|
|
4556
|
+
var len = end - start;
|
|
4557
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
|
|
4558
|
+
this.copyWithin(targetStart, start, end);
|
|
4559
|
+
} else {
|
|
4560
|
+
Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
|
|
4561
|
+
}
|
|
4562
|
+
return len;
|
|
4563
|
+
};
|
|
4564
|
+
Buffer2.prototype.fill = function fill(val, start, end, encoding) {
|
|
4565
|
+
if (typeof val === "string") {
|
|
4566
|
+
if (typeof start === "string") {
|
|
4567
|
+
encoding = start;
|
|
4568
|
+
start = 0;
|
|
4569
|
+
end = this.length;
|
|
4570
|
+
} else if (typeof end === "string") {
|
|
4571
|
+
encoding = end;
|
|
4572
|
+
end = this.length;
|
|
4573
|
+
}
|
|
4574
|
+
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
4575
|
+
throw new TypeError("encoding must be a string");
|
|
4576
|
+
}
|
|
4577
|
+
if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
|
|
4578
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
4579
|
+
}
|
|
4580
|
+
if (val.length === 1) {
|
|
4581
|
+
var code = val.charCodeAt(0);
|
|
4582
|
+
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
|
|
4583
|
+
val = code;
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
} else if (typeof val === "number") {
|
|
4587
|
+
val = val & 255;
|
|
4588
|
+
} else if (typeof val === "boolean") {
|
|
4589
|
+
val = Number(val);
|
|
4590
|
+
}
|
|
4591
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
4592
|
+
throw new RangeError("Out of range index");
|
|
4593
|
+
}
|
|
4594
|
+
if (end <= start) {
|
|
4595
|
+
return this;
|
|
4596
|
+
}
|
|
4597
|
+
start = start >>> 0;
|
|
4598
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
4599
|
+
if (!val)
|
|
4600
|
+
val = 0;
|
|
4601
|
+
var i;
|
|
4602
|
+
if (typeof val === "number") {
|
|
4603
|
+
for (i = start; i < end; ++i) {
|
|
4604
|
+
this[i] = val;
|
|
4605
|
+
}
|
|
4606
|
+
} else {
|
|
4607
|
+
var bytes = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding);
|
|
4608
|
+
var len = bytes.length;
|
|
4609
|
+
if (len === 0) {
|
|
4610
|
+
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
4611
|
+
}
|
|
4612
|
+
for (i = 0; i < end - start; ++i) {
|
|
4613
|
+
this[i + start] = bytes[i % len];
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
return this;
|
|
4617
|
+
};
|
|
4618
|
+
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
4619
|
+
function base64clean(str) {
|
|
4620
|
+
str = str.split("=")[0];
|
|
4621
|
+
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
4622
|
+
if (str.length < 2)
|
|
4623
|
+
return "";
|
|
4624
|
+
while (str.length % 4 !== 0) {
|
|
4625
|
+
str = str + "=";
|
|
4626
|
+
}
|
|
4627
|
+
return str;
|
|
4628
|
+
}
|
|
4629
|
+
function utf8ToBytes(string, units) {
|
|
4630
|
+
units = units || Infinity;
|
|
4631
|
+
var codePoint;
|
|
4632
|
+
var length = string.length;
|
|
4633
|
+
var leadSurrogate = null;
|
|
4634
|
+
var bytes = [];
|
|
4635
|
+
for (var i = 0; i < length; ++i) {
|
|
4636
|
+
codePoint = string.charCodeAt(i);
|
|
4637
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
4638
|
+
if (!leadSurrogate) {
|
|
4639
|
+
if (codePoint > 56319) {
|
|
4640
|
+
if ((units -= 3) > -1)
|
|
4641
|
+
bytes.push(239, 191, 189);
|
|
4642
|
+
continue;
|
|
4643
|
+
} else if (i + 1 === length) {
|
|
4644
|
+
if ((units -= 3) > -1)
|
|
4645
|
+
bytes.push(239, 191, 189);
|
|
4646
|
+
continue;
|
|
4647
|
+
}
|
|
4648
|
+
leadSurrogate = codePoint;
|
|
4649
|
+
continue;
|
|
4650
|
+
}
|
|
4651
|
+
if (codePoint < 56320) {
|
|
4652
|
+
if ((units -= 3) > -1)
|
|
4653
|
+
bytes.push(239, 191, 189);
|
|
4654
|
+
leadSurrogate = codePoint;
|
|
4655
|
+
continue;
|
|
4656
|
+
}
|
|
4657
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
4658
|
+
} else if (leadSurrogate) {
|
|
4659
|
+
if ((units -= 3) > -1)
|
|
4660
|
+
bytes.push(239, 191, 189);
|
|
4661
|
+
}
|
|
4662
|
+
leadSurrogate = null;
|
|
4663
|
+
if (codePoint < 128) {
|
|
4664
|
+
if ((units -= 1) < 0)
|
|
4665
|
+
break;
|
|
4666
|
+
bytes.push(codePoint);
|
|
4667
|
+
} else if (codePoint < 2048) {
|
|
4668
|
+
if ((units -= 2) < 0)
|
|
4669
|
+
break;
|
|
4670
|
+
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
|
|
4671
|
+
} else if (codePoint < 65536) {
|
|
4672
|
+
if ((units -= 3) < 0)
|
|
4673
|
+
break;
|
|
4674
|
+
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
|
4675
|
+
} else if (codePoint < 1114112) {
|
|
4676
|
+
if ((units -= 4) < 0)
|
|
4677
|
+
break;
|
|
4678
|
+
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
|
|
4679
|
+
} else {
|
|
4680
|
+
throw new Error("Invalid code point");
|
|
4681
|
+
}
|
|
4682
|
+
}
|
|
4683
|
+
return bytes;
|
|
4684
|
+
}
|
|
4685
|
+
function asciiToBytes(str) {
|
|
4686
|
+
var byteArray = [];
|
|
4687
|
+
for (var i = 0; i < str.length; ++i) {
|
|
4688
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
4689
|
+
}
|
|
4690
|
+
return byteArray;
|
|
4691
|
+
}
|
|
4692
|
+
function utf16leToBytes(str, units) {
|
|
4693
|
+
var c, hi, lo;
|
|
4694
|
+
var byteArray = [];
|
|
4695
|
+
for (var i = 0; i < str.length; ++i) {
|
|
4696
|
+
if ((units -= 2) < 0)
|
|
4697
|
+
break;
|
|
4698
|
+
c = str.charCodeAt(i);
|
|
4699
|
+
hi = c >> 8;
|
|
4700
|
+
lo = c % 256;
|
|
4701
|
+
byteArray.push(lo);
|
|
4702
|
+
byteArray.push(hi);
|
|
4703
|
+
}
|
|
4704
|
+
return byteArray;
|
|
4705
|
+
}
|
|
4706
|
+
function base64ToBytes(str) {
|
|
4707
|
+
return base64.toByteArray(base64clean(str));
|
|
4708
|
+
}
|
|
4709
|
+
function blitBuffer(src, dst, offset, length) {
|
|
4710
|
+
for (var i = 0; i < length; ++i) {
|
|
4711
|
+
if (i + offset >= dst.length || i >= src.length)
|
|
4712
|
+
break;
|
|
4713
|
+
dst[i + offset] = src[i];
|
|
4714
|
+
}
|
|
4715
|
+
return i;
|
|
4716
|
+
}
|
|
4717
|
+
function isInstance(obj, type) {
|
|
4718
|
+
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
4719
|
+
}
|
|
4720
|
+
function numberIsNaN(obj) {
|
|
4721
|
+
return obj !== obj;
|
|
4722
|
+
}
|
|
4723
|
+
var hexSliceLookupTable = function() {
|
|
4724
|
+
var alphabet = "0123456789abcdef";
|
|
4725
|
+
var table = new Array(256);
|
|
4726
|
+
for (var i = 0; i < 16; ++i) {
|
|
4727
|
+
var i16 = i * 16;
|
|
4728
|
+
for (var j = 0; j < 16; ++j) {
|
|
4729
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
4730
|
+
}
|
|
4731
|
+
}
|
|
4732
|
+
return table;
|
|
4733
|
+
}();
|
|
4734
|
+
}
|
|
4735
|
+
});
|
|
4736
|
+
|
|
4737
|
+
// ../../node_modules/core-assert/index.js
|
|
4738
|
+
var require_core_assert = __commonJS({
|
|
4739
|
+
"../../node_modules/core-assert/index.js"(exports, module) {
|
|
4740
|
+
"use strict";
|
|
4741
|
+
function isPrimitive(arg) {
|
|
4742
|
+
return arg === null || typeof arg !== "object" && typeof arg !== "function";
|
|
4743
|
+
}
|
|
4744
|
+
var compare = require_buf_compare();
|
|
4745
|
+
var isError = require_is_error();
|
|
4746
|
+
var util = require_util2();
|
|
4747
|
+
var Buffer2 = require_buffer().Buffer;
|
|
4748
|
+
var pSlice = Array.prototype.slice;
|
|
4749
|
+
var assert2 = module.exports = ok;
|
|
4750
|
+
assert2.AssertionError = function AssertionError(options) {
|
|
4751
|
+
this.name = "AssertionError";
|
|
4752
|
+
this.actual = options.actual;
|
|
4753
|
+
this.expected = options.expected;
|
|
4754
|
+
this.operator = options.operator;
|
|
4755
|
+
if (options.message) {
|
|
4756
|
+
this.message = options.message;
|
|
4757
|
+
this.generatedMessage = false;
|
|
4758
|
+
} else {
|
|
4759
|
+
this.message = getMessage(this);
|
|
4760
|
+
this.generatedMessage = true;
|
|
4761
|
+
}
|
|
4762
|
+
var stackStartFunction = options.stackStartFunction || fail;
|
|
4763
|
+
Error.captureStackTrace(this, stackStartFunction);
|
|
4764
|
+
};
|
|
4765
|
+
util.inherits(assert2.AssertionError, Error);
|
|
4766
|
+
function truncate(s, n) {
|
|
4767
|
+
if (typeof s === "string") {
|
|
4768
|
+
return s.length < n ? s : s.slice(0, n);
|
|
4769
|
+
} else {
|
|
4770
|
+
return s;
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
function getMessage(self2) {
|
|
4774
|
+
return truncate(util.inspect(self2.actual), 128) + " " + self2.operator + " " + truncate(util.inspect(self2.expected), 128);
|
|
4775
|
+
}
|
|
4776
|
+
function fail(actual, expected, message, operator, stackStartFunction) {
|
|
4777
|
+
throw new assert2.AssertionError({
|
|
4778
|
+
message,
|
|
4779
|
+
actual,
|
|
4780
|
+
expected,
|
|
4781
|
+
operator,
|
|
4782
|
+
stackStartFunction
|
|
4783
|
+
});
|
|
4784
|
+
}
|
|
4785
|
+
assert2.fail = fail;
|
|
4786
|
+
function ok(value, message) {
|
|
4787
|
+
if (!value)
|
|
4788
|
+
fail(value, true, message, "==", assert2.ok);
|
|
4789
|
+
}
|
|
4790
|
+
assert2.ok = ok;
|
|
4791
|
+
assert2.equal = function equal(actual, expected, message) {
|
|
4792
|
+
if (actual != expected)
|
|
4793
|
+
fail(actual, expected, message, "==", assert2.equal);
|
|
4794
|
+
};
|
|
4795
|
+
assert2.notEqual = function notEqual(actual, expected, message) {
|
|
4796
|
+
if (actual == expected) {
|
|
4797
|
+
fail(actual, expected, message, "!=", assert2.notEqual);
|
|
4798
|
+
}
|
|
4799
|
+
};
|
|
4800
|
+
assert2.deepEqual = function deepEqual(actual, expected, message) {
|
|
4801
|
+
if (!_deepEqual(actual, expected, false)) {
|
|
4802
|
+
fail(actual, expected, message, "deepEqual", assert2.deepEqual);
|
|
4803
|
+
}
|
|
4804
|
+
};
|
|
4805
|
+
assert2.deepStrictEqual = function deepStrictEqual2(actual, expected, message) {
|
|
4806
|
+
if (!_deepEqual(actual, expected, true)) {
|
|
4807
|
+
fail(actual, expected, message, "deepStrictEqual", assert2.deepStrictEqual);
|
|
4808
|
+
}
|
|
4809
|
+
};
|
|
4810
|
+
function _deepEqual(actual, expected, strict) {
|
|
4811
|
+
if (actual === expected) {
|
|
4812
|
+
return true;
|
|
4813
|
+
} else if (actual instanceof Buffer2 && expected instanceof Buffer2) {
|
|
4814
|
+
return compare(actual, expected) === 0;
|
|
4815
|
+
} else if (util.isDate(actual) && util.isDate(expected)) {
|
|
4816
|
+
return actual.getTime() === expected.getTime();
|
|
4817
|
+
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
|
|
4818
|
+
return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase;
|
|
4819
|
+
} else if ((actual === null || typeof actual !== "object") && (expected === null || typeof expected !== "object")) {
|
|
4820
|
+
return strict ? actual === expected : actual == expected;
|
|
4821
|
+
} else {
|
|
4822
|
+
return objEquiv(actual, expected, strict);
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
function isArguments(object) {
|
|
4826
|
+
return Object.prototype.toString.call(object) == "[object Arguments]";
|
|
4827
|
+
}
|
|
4828
|
+
function objEquiv(a, b, strict) {
|
|
4829
|
+
if (a === null || a === void 0 || b === null || b === void 0)
|
|
4830
|
+
return false;
|
|
4831
|
+
if (isPrimitive(a) || isPrimitive(b))
|
|
4832
|
+
return a === b;
|
|
4833
|
+
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
|
|
4834
|
+
return false;
|
|
4835
|
+
var aIsArgs = isArguments(a), bIsArgs = isArguments(b);
|
|
4836
|
+
if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs)
|
|
4837
|
+
return false;
|
|
4838
|
+
if (aIsArgs) {
|
|
4839
|
+
a = pSlice.call(a);
|
|
4840
|
+
b = pSlice.call(b);
|
|
4841
|
+
return _deepEqual(a, b, strict);
|
|
4842
|
+
}
|
|
4843
|
+
var ka = Object.keys(a), kb = Object.keys(b), key, i;
|
|
4844
|
+
if (ka.length !== kb.length)
|
|
4845
|
+
return false;
|
|
4846
|
+
ka.sort();
|
|
4847
|
+
kb.sort();
|
|
4848
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
|
4849
|
+
if (ka[i] !== kb[i])
|
|
4850
|
+
return false;
|
|
4851
|
+
}
|
|
4852
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
|
4853
|
+
key = ka[i];
|
|
4854
|
+
if (!_deepEqual(a[key], b[key], strict))
|
|
4855
|
+
return false;
|
|
4856
|
+
}
|
|
4857
|
+
return true;
|
|
4858
|
+
}
|
|
4859
|
+
assert2.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
|
4860
|
+
if (_deepEqual(actual, expected, false)) {
|
|
4861
|
+
fail(actual, expected, message, "notDeepEqual", assert2.notDeepEqual);
|
|
4862
|
+
}
|
|
4863
|
+
};
|
|
4864
|
+
assert2.notDeepStrictEqual = notDeepStrictEqual;
|
|
4865
|
+
function notDeepStrictEqual(actual, expected, message) {
|
|
4866
|
+
if (_deepEqual(actual, expected, true)) {
|
|
4867
|
+
fail(actual, expected, message, "notDeepStrictEqual", notDeepStrictEqual);
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
assert2.strictEqual = function strictEqual(actual, expected, message) {
|
|
4871
|
+
if (actual !== expected) {
|
|
4872
|
+
fail(actual, expected, message, "===", assert2.strictEqual);
|
|
4873
|
+
}
|
|
4874
|
+
};
|
|
4875
|
+
assert2.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
|
4876
|
+
if (actual === expected) {
|
|
4877
|
+
fail(actual, expected, message, "!==", assert2.notStrictEqual);
|
|
4878
|
+
}
|
|
4879
|
+
};
|
|
4880
|
+
function expectedException(actual, expected) {
|
|
4881
|
+
if (!actual || !expected) {
|
|
4882
|
+
return false;
|
|
4883
|
+
}
|
|
4884
|
+
if (Object.prototype.toString.call(expected) == "[object RegExp]") {
|
|
4885
|
+
return expected.test(actual);
|
|
4886
|
+
}
|
|
4887
|
+
try {
|
|
4888
|
+
if (actual instanceof expected) {
|
|
4889
|
+
return true;
|
|
4890
|
+
}
|
|
4891
|
+
} catch (e) {
|
|
4892
|
+
}
|
|
4893
|
+
if (Error.isPrototypeOf && Error.isPrototypeOf(expected)) {
|
|
4894
|
+
return false;
|
|
4895
|
+
}
|
|
4896
|
+
return expected.call({}, actual) === true;
|
|
4897
|
+
}
|
|
4898
|
+
function _tryBlock(block) {
|
|
4899
|
+
var error;
|
|
4900
|
+
try {
|
|
4901
|
+
block();
|
|
4902
|
+
} catch (e) {
|
|
4903
|
+
error = e;
|
|
4904
|
+
}
|
|
4905
|
+
return error;
|
|
4906
|
+
}
|
|
4907
|
+
function _throws(shouldThrow, block, expected, message) {
|
|
4908
|
+
var actual;
|
|
4909
|
+
if (typeof block !== "function") {
|
|
4910
|
+
throw new TypeError('"block" argument must be a function');
|
|
4911
|
+
}
|
|
4912
|
+
if (typeof expected === "string") {
|
|
4913
|
+
message = expected;
|
|
4914
|
+
expected = null;
|
|
4915
|
+
}
|
|
4916
|
+
actual = _tryBlock(block);
|
|
4917
|
+
message = (expected && expected.name ? " (" + expected.name + ")." : ".") + (message ? " " + message : ".");
|
|
4918
|
+
if (shouldThrow && !actual) {
|
|
4919
|
+
fail(actual, expected, "Missing expected exception" + message);
|
|
4920
|
+
}
|
|
4921
|
+
var userProvidedMessage = typeof message === "string";
|
|
4922
|
+
var isUnwantedException = !shouldThrow && isError(actual);
|
|
4923
|
+
var isUnexpectedException = !shouldThrow && actual && !expected;
|
|
4924
|
+
if (isUnwantedException && userProvidedMessage && expectedException(actual, expected) || isUnexpectedException) {
|
|
4925
|
+
fail(actual, expected, "Got unwanted exception" + message);
|
|
4926
|
+
}
|
|
4927
|
+
if (shouldThrow && actual && expected && !expectedException(actual, expected) || !shouldThrow && actual) {
|
|
4928
|
+
throw actual;
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
assert2.throws = function(block, error, message) {
|
|
4932
|
+
_throws(true, block, error, message);
|
|
4933
|
+
};
|
|
4934
|
+
assert2.doesNotThrow = function(block, error, message) {
|
|
4935
|
+
_throws(false, block, error, message);
|
|
4936
|
+
};
|
|
4937
|
+
assert2.ifError = function(err) {
|
|
4938
|
+
if (err)
|
|
4939
|
+
throw err;
|
|
4940
|
+
};
|
|
4941
|
+
Object.defineProperty(assert2, "__deepEqual", { value: _deepEqual });
|
|
4942
|
+
}
|
|
4943
|
+
});
|
|
4944
|
+
|
|
4945
|
+
// ../../node_modules/deep-strict-equal/index.js
|
|
4946
|
+
var require_deep_strict_equal = __commonJS({
|
|
4947
|
+
"../../node_modules/deep-strict-equal/index.js"(exports, module) {
|
|
4948
|
+
"use strict";
|
|
4949
|
+
var __deepEqual = require_core_assert().__deepEqual;
|
|
4950
|
+
module.exports = function(a, b) {
|
|
4951
|
+
return __deepEqual(a, b, true);
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
});
|
|
4955
|
+
|
|
4956
|
+
// ../../node_modules/@turf/clone/main.es.js
|
|
4957
|
+
function clone(geojson) {
|
|
4958
|
+
if (!geojson)
|
|
4959
|
+
throw new Error("geojson is required");
|
|
4960
|
+
switch (geojson.type) {
|
|
4961
|
+
case "Feature":
|
|
4962
|
+
return cloneFeature(geojson);
|
|
4963
|
+
case "FeatureCollection":
|
|
4964
|
+
return cloneFeatureCollection(geojson);
|
|
4965
|
+
case "Point":
|
|
4966
|
+
case "LineString":
|
|
4967
|
+
case "Polygon":
|
|
4968
|
+
case "MultiPoint":
|
|
4969
|
+
case "MultiLineString":
|
|
4970
|
+
case "MultiPolygon":
|
|
4971
|
+
case "GeometryCollection":
|
|
4972
|
+
return cloneGeometry(geojson);
|
|
4973
|
+
default:
|
|
4974
|
+
throw new Error("unknown GeoJSON type");
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
function cloneFeature(geojson) {
|
|
4978
|
+
var cloned = { type: "Feature" };
|
|
4979
|
+
Object.keys(geojson).forEach(function(key) {
|
|
4980
|
+
switch (key) {
|
|
4981
|
+
case "type":
|
|
4982
|
+
case "properties":
|
|
4983
|
+
case "geometry":
|
|
4984
|
+
return;
|
|
4985
|
+
default:
|
|
4986
|
+
cloned[key] = geojson[key];
|
|
4987
|
+
}
|
|
4988
|
+
});
|
|
4989
|
+
cloned.properties = cloneProperties(geojson.properties);
|
|
4990
|
+
cloned.geometry = cloneGeometry(geojson.geometry);
|
|
4991
|
+
return cloned;
|
|
4992
|
+
}
|
|
4993
|
+
function cloneProperties(properties) {
|
|
4994
|
+
var cloned = {};
|
|
4995
|
+
if (!properties)
|
|
4996
|
+
return cloned;
|
|
4997
|
+
Object.keys(properties).forEach(function(key) {
|
|
4998
|
+
var value = properties[key];
|
|
4999
|
+
if (typeof value === "object") {
|
|
5000
|
+
if (value === null) {
|
|
5001
|
+
cloned[key] = null;
|
|
5002
|
+
} else if (value.length) {
|
|
5003
|
+
cloned[key] = value.map(function(item) {
|
|
5004
|
+
return item;
|
|
5005
|
+
});
|
|
5006
|
+
} else {
|
|
5007
|
+
cloned[key] = cloneProperties(value);
|
|
5008
|
+
}
|
|
5009
|
+
} else
|
|
5010
|
+
cloned[key] = value;
|
|
5011
|
+
});
|
|
5012
|
+
return cloned;
|
|
5013
|
+
}
|
|
5014
|
+
function cloneFeatureCollection(geojson) {
|
|
5015
|
+
var cloned = { type: "FeatureCollection" };
|
|
5016
|
+
Object.keys(geojson).forEach(function(key) {
|
|
5017
|
+
switch (key) {
|
|
5018
|
+
case "type":
|
|
5019
|
+
case "features":
|
|
5020
|
+
return;
|
|
5021
|
+
default:
|
|
5022
|
+
cloned[key] = geojson[key];
|
|
5023
|
+
}
|
|
5024
|
+
});
|
|
5025
|
+
cloned.features = geojson.features.map(function(feature2) {
|
|
5026
|
+
return cloneFeature(feature2);
|
|
5027
|
+
});
|
|
5028
|
+
return cloned;
|
|
5029
|
+
}
|
|
5030
|
+
function cloneGeometry(geometry) {
|
|
5031
|
+
var geom = { type: geometry.type };
|
|
5032
|
+
if (geometry.bbox)
|
|
5033
|
+
geom.bbox = geometry.bbox;
|
|
5034
|
+
if (geometry.type === "GeometryCollection") {
|
|
5035
|
+
geom.geometries = geometry.geometries.map(function(geom2) {
|
|
5036
|
+
return cloneGeometry(geom2);
|
|
5037
|
+
});
|
|
5038
|
+
return geom;
|
|
5039
|
+
}
|
|
5040
|
+
geom.coordinates = deepSlice(geometry.coordinates);
|
|
5041
|
+
return geom;
|
|
5042
|
+
}
|
|
5043
|
+
function deepSlice(coords) {
|
|
5044
|
+
if (typeof coords[0] !== "object") {
|
|
5045
|
+
return coords.slice();
|
|
5046
|
+
}
|
|
5047
|
+
return coords.map(function(coord) {
|
|
5048
|
+
return deepSlice(coord);
|
|
5049
|
+
});
|
|
5050
|
+
}
|
|
5051
|
+
var main_es_default;
|
|
5052
|
+
var init_main_es = __esm({
|
|
5053
|
+
"../../node_modules/@turf/clone/main.es.js"() {
|
|
5054
|
+
main_es_default = clone;
|
|
5055
|
+
}
|
|
5056
|
+
});
|
|
5057
|
+
|
|
5058
|
+
// ../../node_modules/@turf/helpers/main.es.js
|
|
5059
|
+
function featureCollection(features, options) {
|
|
5060
|
+
options = options || {};
|
|
5061
|
+
if (!isObject(options))
|
|
5062
|
+
throw new Error("options is invalid");
|
|
5063
|
+
var bbox = options.bbox;
|
|
5064
|
+
var id = options.id;
|
|
5065
|
+
if (!features)
|
|
5066
|
+
throw new Error("No features passed");
|
|
5067
|
+
if (!Array.isArray(features))
|
|
5068
|
+
throw new Error("features must be an Array");
|
|
5069
|
+
if (bbox)
|
|
5070
|
+
validateBBox(bbox);
|
|
5071
|
+
if (id)
|
|
5072
|
+
validateId(id);
|
|
5073
|
+
var fc = { type: "FeatureCollection" };
|
|
5074
|
+
if (id)
|
|
5075
|
+
fc.id = id;
|
|
5076
|
+
if (bbox)
|
|
5077
|
+
fc.bbox = bbox;
|
|
5078
|
+
fc.features = features;
|
|
5079
|
+
return fc;
|
|
5080
|
+
}
|
|
5081
|
+
function isNumber(num) {
|
|
5082
|
+
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
5083
|
+
}
|
|
5084
|
+
function isObject(input) {
|
|
5085
|
+
return !!input && input.constructor === Object;
|
|
5086
|
+
}
|
|
5087
|
+
function validateBBox(bbox) {
|
|
5088
|
+
if (!bbox)
|
|
5089
|
+
throw new Error("bbox is required");
|
|
5090
|
+
if (!Array.isArray(bbox))
|
|
5091
|
+
throw new Error("bbox must be an Array");
|
|
5092
|
+
if (bbox.length !== 4 && bbox.length !== 6)
|
|
5093
|
+
throw new Error("bbox must be an Array of 4 or 6 numbers");
|
|
5094
|
+
bbox.forEach(function(num) {
|
|
5095
|
+
if (!isNumber(num))
|
|
5096
|
+
throw new Error("bbox must only contain numbers");
|
|
5097
|
+
});
|
|
5098
|
+
}
|
|
5099
|
+
function validateId(id) {
|
|
5100
|
+
if (!id)
|
|
5101
|
+
throw new Error("id is required");
|
|
5102
|
+
if (["string", "number"].indexOf(typeof id) === -1)
|
|
5103
|
+
throw new Error("id must be a number or a string");
|
|
5104
|
+
}
|
|
5105
|
+
var earthRadius, factors, unitsFactors;
|
|
5106
|
+
var init_main_es2 = __esm({
|
|
5107
|
+
"../../node_modules/@turf/helpers/main.es.js"() {
|
|
5108
|
+
earthRadius = 63710088e-1;
|
|
5109
|
+
factors = {
|
|
5110
|
+
meters: earthRadius,
|
|
5111
|
+
metres: earthRadius,
|
|
5112
|
+
millimeters: earthRadius * 1e3,
|
|
5113
|
+
millimetres: earthRadius * 1e3,
|
|
5114
|
+
centimeters: earthRadius * 100,
|
|
5115
|
+
centimetres: earthRadius * 100,
|
|
5116
|
+
kilometers: earthRadius / 1e3,
|
|
5117
|
+
kilometres: earthRadius / 1e3,
|
|
5118
|
+
miles: earthRadius / 1609.344,
|
|
5119
|
+
nauticalmiles: earthRadius / 1852,
|
|
5120
|
+
inches: earthRadius * 39.37,
|
|
5121
|
+
yards: earthRadius / 1.0936,
|
|
5122
|
+
feet: earthRadius * 3.28084,
|
|
5123
|
+
radians: 1,
|
|
5124
|
+
degrees: earthRadius / 111325
|
|
5125
|
+
};
|
|
5126
|
+
unitsFactors = {
|
|
5127
|
+
meters: 1,
|
|
5128
|
+
metres: 1,
|
|
5129
|
+
millimeters: 1e3,
|
|
5130
|
+
millimetres: 1e3,
|
|
5131
|
+
centimeters: 100,
|
|
5132
|
+
centimetres: 100,
|
|
5133
|
+
kilometers: 1 / 1e3,
|
|
5134
|
+
kilometres: 1 / 1e3,
|
|
5135
|
+
miles: 1 / 1609.344,
|
|
5136
|
+
nauticalmiles: 1 / 1852,
|
|
5137
|
+
inches: 39.37,
|
|
5138
|
+
yards: 1 / 1.0936,
|
|
5139
|
+
feet: 3.28084,
|
|
5140
|
+
radians: 1 / earthRadius,
|
|
5141
|
+
degrees: 1 / 111325
|
|
5142
|
+
};
|
|
5143
|
+
}
|
|
5144
|
+
});
|
|
5145
|
+
|
|
5146
|
+
// ../../node_modules/@turf/invariant/main.es.js
|
|
5147
|
+
function getCoords(coords) {
|
|
5148
|
+
if (!coords)
|
|
5149
|
+
throw new Error("coords is required");
|
|
5150
|
+
if (coords.type === "Feature" && coords.geometry !== null)
|
|
5151
|
+
return coords.geometry.coordinates;
|
|
5152
|
+
if (coords.coordinates)
|
|
5153
|
+
return coords.coordinates;
|
|
5154
|
+
if (Array.isArray(coords))
|
|
5155
|
+
return coords;
|
|
5156
|
+
throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");
|
|
5157
|
+
}
|
|
5158
|
+
var init_main_es3 = __esm({
|
|
5159
|
+
"../../node_modules/@turf/invariant/main.es.js"() {
|
|
5160
|
+
init_main_es2();
|
|
5161
|
+
}
|
|
5162
|
+
});
|
|
5163
|
+
|
|
5164
|
+
// ../../node_modules/@turf/boolean-clockwise/main.es.js
|
|
5165
|
+
function booleanClockwise(line) {
|
|
5166
|
+
if (!line)
|
|
5167
|
+
throw new Error("line is required");
|
|
5168
|
+
var type = line.geometry ? line.geometry.type : line.type;
|
|
5169
|
+
if (!Array.isArray(line) && type !== "LineString")
|
|
5170
|
+
throw new Error("geometry must be a LineString");
|
|
5171
|
+
var ring = getCoords(line);
|
|
5172
|
+
var sum = 0;
|
|
5173
|
+
var i = 1;
|
|
5174
|
+
var prev, cur;
|
|
5175
|
+
while (i < ring.length) {
|
|
5176
|
+
prev = cur || ring[0];
|
|
5177
|
+
cur = ring[i];
|
|
5178
|
+
sum += (cur[0] - prev[0]) * (cur[1] + prev[1]);
|
|
5179
|
+
i++;
|
|
5180
|
+
}
|
|
5181
|
+
return sum > 0;
|
|
5182
|
+
}
|
|
5183
|
+
var main_es_default2;
|
|
5184
|
+
var init_main_es4 = __esm({
|
|
5185
|
+
"../../node_modules/@turf/boolean-clockwise/main.es.js"() {
|
|
5186
|
+
init_main_es3();
|
|
5187
|
+
main_es_default2 = booleanClockwise;
|
|
5188
|
+
}
|
|
5189
|
+
});
|
|
5190
|
+
|
|
5191
|
+
// ../../node_modules/@turf/meta/main.es.js
|
|
5192
|
+
function featureEach(geojson, callback) {
|
|
5193
|
+
if (geojson.type === "Feature") {
|
|
5194
|
+
callback(geojson, 0);
|
|
5195
|
+
} else if (geojson.type === "FeatureCollection") {
|
|
5196
|
+
for (var i = 0; i < geojson.features.length; i++) {
|
|
5197
|
+
if (callback(geojson.features[i], i) === false)
|
|
5198
|
+
break;
|
|
5199
|
+
}
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
function geomEach(geojson, callback) {
|
|
5203
|
+
var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
5204
|
+
for (i = 0; i < stop; i++) {
|
|
5205
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[i].geometry : isFeature ? geojson.geometry : geojson;
|
|
5206
|
+
featureProperties = isFeatureCollection ? geojson.features[i].properties : isFeature ? geojson.properties : {};
|
|
5207
|
+
featureBBox = isFeatureCollection ? geojson.features[i].bbox : isFeature ? geojson.bbox : void 0;
|
|
5208
|
+
featureId = isFeatureCollection ? geojson.features[i].id : isFeature ? geojson.id : void 0;
|
|
5209
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
5210
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
5211
|
+
for (g = 0; g < stopG; g++) {
|
|
5212
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
|
|
5213
|
+
if (geometry === null) {
|
|
5214
|
+
if (callback(null, featureIndex, featureProperties, featureBBox, featureId) === false)
|
|
5215
|
+
return false;
|
|
5216
|
+
continue;
|
|
5217
|
+
}
|
|
5218
|
+
switch (geometry.type) {
|
|
5219
|
+
case "Point":
|
|
5220
|
+
case "LineString":
|
|
5221
|
+
case "MultiPoint":
|
|
5222
|
+
case "Polygon":
|
|
5223
|
+
case "MultiLineString":
|
|
5224
|
+
case "MultiPolygon": {
|
|
5225
|
+
if (callback(geometry, featureIndex, featureProperties, featureBBox, featureId) === false)
|
|
5226
|
+
return false;
|
|
5227
|
+
break;
|
|
5228
|
+
}
|
|
5229
|
+
case "GeometryCollection": {
|
|
5230
|
+
for (j = 0; j < geometry.geometries.length; j++) {
|
|
5231
|
+
if (callback(geometry.geometries[j], featureIndex, featureProperties, featureBBox, featureId) === false)
|
|
5232
|
+
return false;
|
|
5233
|
+
}
|
|
5234
|
+
break;
|
|
5235
|
+
}
|
|
5236
|
+
default:
|
|
5237
|
+
throw new Error("Unknown Geometry Type");
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
featureIndex++;
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
var init_main_es5 = __esm({
|
|
5244
|
+
"../../node_modules/@turf/meta/main.es.js"() {
|
|
5245
|
+
init_main_es2();
|
|
5246
|
+
}
|
|
5247
|
+
});
|
|
5248
|
+
|
|
5249
|
+
// ../../node_modules/@turf/rewind/main.es.js
|
|
5250
|
+
function rewind(geojson, options) {
|
|
5251
|
+
options = options || {};
|
|
5252
|
+
if (!isObject(options))
|
|
5253
|
+
throw new Error("options is invalid");
|
|
5254
|
+
var reverse = options.reverse || false;
|
|
5255
|
+
var mutate = options.mutate || false;
|
|
5256
|
+
if (!geojson)
|
|
5257
|
+
throw new Error("<geojson> is required");
|
|
5258
|
+
if (typeof reverse !== "boolean")
|
|
5259
|
+
throw new Error("<reverse> must be a boolean");
|
|
5260
|
+
if (typeof mutate !== "boolean")
|
|
5261
|
+
throw new Error("<mutate> must be a boolean");
|
|
5262
|
+
if (mutate === false)
|
|
5263
|
+
geojson = main_es_default(geojson);
|
|
5264
|
+
var results = [];
|
|
5265
|
+
switch (geojson.type) {
|
|
5266
|
+
case "GeometryCollection":
|
|
5267
|
+
geomEach(geojson, function(geometry) {
|
|
5268
|
+
rewindFeature(geometry, reverse);
|
|
5269
|
+
});
|
|
5270
|
+
return geojson;
|
|
5271
|
+
case "FeatureCollection":
|
|
5272
|
+
featureEach(geojson, function(feature2) {
|
|
5273
|
+
featureEach(rewindFeature(feature2, reverse), function(result) {
|
|
5274
|
+
results.push(result);
|
|
5275
|
+
});
|
|
5276
|
+
});
|
|
5277
|
+
return featureCollection(results);
|
|
5278
|
+
}
|
|
5279
|
+
return rewindFeature(geojson, reverse);
|
|
5280
|
+
}
|
|
5281
|
+
function rewindFeature(geojson, reverse) {
|
|
5282
|
+
var type = geojson.type === "Feature" ? geojson.geometry.type : geojson.type;
|
|
5283
|
+
switch (type) {
|
|
5284
|
+
case "GeometryCollection":
|
|
5285
|
+
geomEach(geojson, function(geometry) {
|
|
5286
|
+
rewindFeature(geometry, reverse);
|
|
5287
|
+
});
|
|
5288
|
+
return geojson;
|
|
5289
|
+
case "LineString":
|
|
5290
|
+
rewindLineString(getCoords(geojson), reverse);
|
|
5291
|
+
return geojson;
|
|
5292
|
+
case "Polygon":
|
|
5293
|
+
rewindPolygon(getCoords(geojson), reverse);
|
|
5294
|
+
return geojson;
|
|
5295
|
+
case "MultiLineString":
|
|
5296
|
+
getCoords(geojson).forEach(function(lineCoords) {
|
|
5297
|
+
rewindLineString(lineCoords, reverse);
|
|
5298
|
+
});
|
|
5299
|
+
return geojson;
|
|
5300
|
+
case "MultiPolygon":
|
|
5301
|
+
getCoords(geojson).forEach(function(lineCoords) {
|
|
5302
|
+
rewindPolygon(lineCoords, reverse);
|
|
5303
|
+
});
|
|
5304
|
+
return geojson;
|
|
5305
|
+
case "Point":
|
|
5306
|
+
case "MultiPoint":
|
|
5307
|
+
return geojson;
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
function rewindLineString(coords, reverse) {
|
|
5311
|
+
if (main_es_default2(coords) === reverse)
|
|
5312
|
+
coords.reverse();
|
|
5313
|
+
}
|
|
5314
|
+
function rewindPolygon(coords, reverse) {
|
|
5315
|
+
if (main_es_default2(coords[0]) !== reverse) {
|
|
5316
|
+
coords[0].reverse();
|
|
5317
|
+
}
|
|
5318
|
+
for (var i = 1; i < coords.length; i++) {
|
|
5319
|
+
if (main_es_default2(coords[i]) === reverse) {
|
|
5320
|
+
coords[i].reverse();
|
|
5321
|
+
}
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
var main_es_default3;
|
|
5325
|
+
var init_main_es6 = __esm({
|
|
5326
|
+
"../../node_modules/@turf/rewind/main.es.js"() {
|
|
5327
|
+
init_main_es();
|
|
5328
|
+
init_main_es4();
|
|
5329
|
+
init_main_es5();
|
|
5330
|
+
init_main_es3();
|
|
5331
|
+
init_main_es2();
|
|
5332
|
+
main_es_default3 = rewind;
|
|
5333
|
+
}
|
|
5334
|
+
});
|
|
5335
|
+
|
|
5336
|
+
// src/lib/gml/parse-gml.ts
|
|
5337
|
+
function noTransform(...coords) {
|
|
5338
|
+
return coords;
|
|
5339
|
+
}
|
|
5340
|
+
function parseGML(text, options) {
|
|
5341
|
+
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
5342
|
+
options = { transformCoords: noTransform, stride: 2, ...options };
|
|
5343
|
+
const context = createChildContext(parsedXML, options, {});
|
|
5344
|
+
return parseGMLToGeometry(parsedXML, options, context);
|
|
5345
|
+
}
|
|
5346
|
+
function parseGMLToGeometry(inputXML, options, context) {
|
|
5347
|
+
const childContext = createChildContext(inputXML, options, context);
|
|
5348
|
+
let geometry = null;
|
|
5349
|
+
const [name, xml] = getFirstKeyValue(inputXML);
|
|
5350
|
+
switch (name) {
|
|
5351
|
+
case "gml:LineString":
|
|
5352
|
+
geometry = {
|
|
5353
|
+
type: "LineString",
|
|
5354
|
+
coordinates: parseLinearRingOrLineString(xml, options, childContext)
|
|
5355
|
+
};
|
|
5356
|
+
break;
|
|
5357
|
+
case "gml:Polygon":
|
|
5358
|
+
case "gml:Rectangle":
|
|
5359
|
+
geometry = {
|
|
5360
|
+
type: "Polygon",
|
|
5361
|
+
coordinates: parsePolygonOrRectangle(xml, options, childContext)
|
|
5362
|
+
};
|
|
5363
|
+
break;
|
|
5364
|
+
case "gml:Surface":
|
|
5365
|
+
geometry = {
|
|
5366
|
+
type: "MultiPolygon",
|
|
5367
|
+
coordinates: parseSurface(xml, options, childContext)
|
|
5368
|
+
};
|
|
5369
|
+
break;
|
|
5370
|
+
case "gml:MultiSurface":
|
|
5371
|
+
geometry = {
|
|
5372
|
+
type: "MultiPolygon",
|
|
5373
|
+
coordinates: parseMultiSurface(xml, options, childContext)
|
|
5374
|
+
};
|
|
5375
|
+
break;
|
|
5376
|
+
default:
|
|
5377
|
+
return null;
|
|
5378
|
+
}
|
|
5379
|
+
return main_es_default3(geometry, { mutate: true });
|
|
5380
|
+
}
|
|
5381
|
+
function parseCoords(s, options, context) {
|
|
5382
|
+
const stride = context.srsDimension || options.stride || 2;
|
|
5383
|
+
const coords = s.replace(/\s+/g, " ").trim().split(" ");
|
|
5384
|
+
if (coords.length === 0 || coords.length % stride !== 0) {
|
|
5385
|
+
throw new Error(`invalid coordinates list (stride ${stride})`);
|
|
5386
|
+
}
|
|
5387
|
+
const points = [];
|
|
5388
|
+
for (let i = 0; i < coords.length - 1; i += stride) {
|
|
5389
|
+
const point2 = coords.slice(i, i + stride).map(parseFloat);
|
|
5390
|
+
points.push(options.transformCoords?.(...point2) || point2);
|
|
5391
|
+
}
|
|
5392
|
+
return points;
|
|
5393
|
+
}
|
|
5394
|
+
function parsePosList(xml, options, context) {
|
|
5395
|
+
const childContext = createChildContext(xml, options, context);
|
|
5396
|
+
const coords = textOf(xml);
|
|
5397
|
+
if (!coords) {
|
|
5398
|
+
throw new Error("invalid gml:posList element");
|
|
5399
|
+
}
|
|
5400
|
+
return parseCoords(coords, options, childContext);
|
|
5401
|
+
}
|
|
5402
|
+
function parsePos(xml, options, context) {
|
|
5403
|
+
const childContext = createChildContext(xml, options, context);
|
|
5404
|
+
const coords = textOf(xml);
|
|
5405
|
+
if (!coords) {
|
|
5406
|
+
throw new Error("invalid gml:pos element");
|
|
5407
|
+
}
|
|
5408
|
+
const points = parseCoords(coords, options, childContext);
|
|
5409
|
+
if (points.length !== 1) {
|
|
5410
|
+
throw new Error("gml:pos must have 1 point");
|
|
5411
|
+
}
|
|
5412
|
+
return points[0];
|
|
5413
|
+
}
|
|
5414
|
+
function parsePoint(xml, options, context) {
|
|
5415
|
+
const childContext = createChildContext(xml, options, context);
|
|
5416
|
+
const pos = findIn(xml, "gml:pos");
|
|
5417
|
+
if (!pos) {
|
|
5418
|
+
throw new Error("invalid gml:Point element, expected a gml:pos subelement");
|
|
5419
|
+
}
|
|
5420
|
+
return parsePos(pos, options, childContext);
|
|
5421
|
+
}
|
|
5422
|
+
function parseLinearRingOrLineString(xml, options, context) {
|
|
5423
|
+
const childContext = createChildContext(xml, options, context);
|
|
5424
|
+
let points = [];
|
|
5425
|
+
const posList = findIn(xml, "gml:posList");
|
|
5426
|
+
if (posList) {
|
|
5427
|
+
points = parsePosList(posList, options, childContext);
|
|
5428
|
+
} else {
|
|
5429
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
5430
|
+
switch (childName) {
|
|
5431
|
+
case "gml:Point":
|
|
5432
|
+
points.push(parsePoint(childXML, options, childContext));
|
|
5433
|
+
break;
|
|
5434
|
+
case "gml:pos":
|
|
5435
|
+
points.push(parsePos(childXML, options, childContext));
|
|
5436
|
+
break;
|
|
5437
|
+
default:
|
|
5438
|
+
continue;
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
if (points.length === 0) {
|
|
5443
|
+
throw new Error(`${xml.name} must have > 0 points`);
|
|
5444
|
+
}
|
|
5445
|
+
return points;
|
|
5446
|
+
}
|
|
5447
|
+
function parseCurveSegments(xml, options, context) {
|
|
5448
|
+
const points = [];
|
|
5449
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
5450
|
+
switch (childName) {
|
|
5451
|
+
case "gml:LineStringSegment":
|
|
5452
|
+
const points2 = parseLinearRingOrLineString(childXML, options, context);
|
|
5453
|
+
const end = points[points.length - 1];
|
|
5454
|
+
const start = points2[0];
|
|
5455
|
+
if (end && start && (0, import_deep_strict_equal.default)(end, start)) {
|
|
5456
|
+
points2.shift();
|
|
5457
|
+
}
|
|
5458
|
+
points.push(...points2);
|
|
5459
|
+
break;
|
|
5460
|
+
default:
|
|
5461
|
+
continue;
|
|
5462
|
+
}
|
|
5463
|
+
}
|
|
5464
|
+
if (points.length === 0) {
|
|
5465
|
+
throw new Error("gml:Curve > gml:segments must have > 0 points");
|
|
5466
|
+
}
|
|
5467
|
+
return points;
|
|
5468
|
+
}
|
|
5469
|
+
function parseRing(xml, options, context) {
|
|
5470
|
+
const childContext = createChildContext(xml, options, context);
|
|
5471
|
+
const points = [];
|
|
5472
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
5473
|
+
switch (childName) {
|
|
5474
|
+
case "gml:curveMember":
|
|
5475
|
+
let points2;
|
|
5476
|
+
const lineString2 = findIn(childXML, "gml:LineString");
|
|
5477
|
+
if (lineString2) {
|
|
5478
|
+
points2 = parseLinearRingOrLineString(lineString2, options, childContext);
|
|
5479
|
+
} else {
|
|
5480
|
+
const segments = findIn(childXML, "gml:Curve", "gml:segments");
|
|
5481
|
+
if (!segments) {
|
|
5482
|
+
throw new Error(`invalid ${childName} element`);
|
|
5483
|
+
}
|
|
5484
|
+
points2 = parseCurveSegments(segments, options, childContext);
|
|
5485
|
+
}
|
|
5486
|
+
const end = points[points.length - 1];
|
|
5487
|
+
const start = points2[0];
|
|
5488
|
+
if (end && start && (0, import_deep_strict_equal.default)(end, start)) {
|
|
5489
|
+
points2.shift();
|
|
5490
|
+
}
|
|
5491
|
+
points.push(...points2);
|
|
5492
|
+
break;
|
|
5493
|
+
}
|
|
5494
|
+
}
|
|
5495
|
+
if (points.length < 4) {
|
|
5496
|
+
throw new Error(`${xml.name} must have >= 4 points`);
|
|
5497
|
+
}
|
|
5498
|
+
return points;
|
|
5499
|
+
}
|
|
5500
|
+
function parseExteriorOrInterior(xml, options, context) {
|
|
5501
|
+
const linearRing = findIn(xml, "gml:LinearRing");
|
|
5502
|
+
if (linearRing) {
|
|
5503
|
+
return parseLinearRingOrLineString(linearRing, options, context);
|
|
5504
|
+
}
|
|
5505
|
+
const ring = findIn(xml, "gml:Ring");
|
|
5506
|
+
if (!ring) {
|
|
5507
|
+
throw new Error(`invalid ${xml.name} element`);
|
|
5508
|
+
}
|
|
5509
|
+
return parseRing(ring, options, context);
|
|
5510
|
+
}
|
|
5511
|
+
function parsePolygonOrRectangle(xml, options, context) {
|
|
5512
|
+
const childContext = createChildContext(xml, options, context);
|
|
5513
|
+
const exterior = findIn(xml, "gml:exterior");
|
|
5514
|
+
if (!exterior) {
|
|
5515
|
+
throw new Error(`invalid ${xml.name} element`);
|
|
5516
|
+
}
|
|
5517
|
+
const pointLists = [parseExteriorOrInterior(exterior, options, childContext)];
|
|
5518
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
5519
|
+
switch (childName) {
|
|
5520
|
+
case "gml:interior":
|
|
5521
|
+
pointLists.push(parseExteriorOrInterior(childXML, options, childContext));
|
|
5522
|
+
break;
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
return pointLists;
|
|
5526
|
+
}
|
|
5527
|
+
function parseSurface(xml, options, context) {
|
|
5528
|
+
const childContext = createChildContext(xml, options, context);
|
|
5529
|
+
const patches = findIn(xml, "gml:patches");
|
|
5530
|
+
if (!patches) {
|
|
5531
|
+
throw new Error(`invalid ${xml.name} element`);
|
|
5532
|
+
}
|
|
5533
|
+
const polygons = [];
|
|
5534
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
5535
|
+
switch (childName) {
|
|
5536
|
+
case "gml:PolygonPatch":
|
|
5537
|
+
case "gml:Rectangle":
|
|
5538
|
+
polygons.push(parsePolygonOrRectangle(childXML, options, childContext));
|
|
5539
|
+
break;
|
|
5540
|
+
default:
|
|
5541
|
+
continue;
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
if (polygons.length === 0) {
|
|
5545
|
+
throw new Error(`${xml.name} must have > 0 polygons`);
|
|
5546
|
+
}
|
|
5547
|
+
return polygons;
|
|
5548
|
+
}
|
|
5549
|
+
function parseCompositeSurface(xml, options, context) {
|
|
5550
|
+
const childContext = createChildContext(xml, options, context);
|
|
5551
|
+
const polygons = [];
|
|
5552
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
5553
|
+
switch (childName) {
|
|
5554
|
+
case "gml:surfaceMember":
|
|
5555
|
+
case "gml:surfaceMembers":
|
|
5556
|
+
const [c2Name, c2Xml] = getFirstKeyValue(childXML);
|
|
5557
|
+
switch (c2Name) {
|
|
5558
|
+
case "gml:Surface":
|
|
5559
|
+
polygons.push(...parseSurface(c2Xml, options, childContext));
|
|
5560
|
+
break;
|
|
5561
|
+
case "gml:Polygon":
|
|
5562
|
+
polygons.push(parsePolygonOrRectangle(c2Xml, options, childContext));
|
|
5563
|
+
break;
|
|
5564
|
+
}
|
|
5565
|
+
break;
|
|
5566
|
+
}
|
|
5567
|
+
}
|
|
5568
|
+
if (polygons.length === 0) {
|
|
5569
|
+
throw new Error(`${xml.name} must have > 0 polygons`);
|
|
5570
|
+
}
|
|
5571
|
+
return polygons;
|
|
5572
|
+
}
|
|
5573
|
+
function parseMultiSurface(xml, options, context) {
|
|
5574
|
+
let el = xml;
|
|
5575
|
+
const surfaceMembers = findIn(xml, "gml:LinearRing");
|
|
5576
|
+
if (surfaceMembers) {
|
|
5577
|
+
el = surfaceMembers;
|
|
5578
|
+
}
|
|
5579
|
+
const polygons = [];
|
|
5580
|
+
for (const [childName, childXML] of Object.entries(el)) {
|
|
5581
|
+
switch (childName) {
|
|
5582
|
+
case "gml:Surface":
|
|
5583
|
+
const polygons2 = parseSurface(childXML, options, context);
|
|
5584
|
+
polygons.push(...polygons2);
|
|
5585
|
+
break;
|
|
5586
|
+
case "gml:surfaceMember":
|
|
5587
|
+
const polygons3 = parseSurfaceMember(childXML, options, context);
|
|
5588
|
+
polygons.push(...polygons3);
|
|
5589
|
+
break;
|
|
5590
|
+
case "gml:surfaceMembers":
|
|
5591
|
+
const polygonXML = findIn(childXML, "gml:Polygon");
|
|
5592
|
+
for (const surfaceMemberXML of polygonXML) {
|
|
5593
|
+
const polygons32 = parseSurfaceMember(surfaceMemberXML, options, context);
|
|
5594
|
+
polygons.push(...polygons32);
|
|
5595
|
+
}
|
|
5596
|
+
break;
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
if (polygons.length === 0) {
|
|
5600
|
+
throw new Error(`${xml.name} must have > 0 polygons`);
|
|
5601
|
+
}
|
|
5602
|
+
return polygons;
|
|
5603
|
+
}
|
|
5604
|
+
function parseSurfaceMember(xml, options, context) {
|
|
5605
|
+
const [childName, childXml] = getFirstKeyValue(xml);
|
|
5606
|
+
switch (childName) {
|
|
5607
|
+
case "gml:CompositeSurface":
|
|
5608
|
+
return parseCompositeSurface(childXml, options, context);
|
|
5609
|
+
case "gml:Surface":
|
|
5610
|
+
return parseSurface(childXml, options, context);
|
|
5611
|
+
case "gml:Polygon":
|
|
5612
|
+
return [parsePolygonOrRectangle(childXml, options, context)];
|
|
5613
|
+
}
|
|
5614
|
+
throw new Error(`${childName} must have polygons`);
|
|
5615
|
+
}
|
|
5616
|
+
function textOf(el) {
|
|
5617
|
+
if (typeof el !== "string") {
|
|
5618
|
+
throw new Error("expected string");
|
|
5619
|
+
}
|
|
5620
|
+
return el;
|
|
5621
|
+
}
|
|
5622
|
+
function findIn(root, ...tags) {
|
|
5623
|
+
let el = root;
|
|
5624
|
+
for (const tag of tags) {
|
|
5625
|
+
const child = el[tag];
|
|
5626
|
+
if (!child) {
|
|
5627
|
+
return null;
|
|
5628
|
+
}
|
|
5629
|
+
el = child;
|
|
5630
|
+
}
|
|
5631
|
+
return el;
|
|
5632
|
+
}
|
|
5633
|
+
function getFirstKeyValue(object) {
|
|
5634
|
+
if (object && typeof object === "object") {
|
|
5635
|
+
for (const [key, value] of Object.entries(object)) {
|
|
5636
|
+
return [key, value];
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5639
|
+
return ["", null];
|
|
5640
|
+
}
|
|
5641
|
+
function createChildContext(xml, options, context) {
|
|
5642
|
+
const srsDimensionAttribute = xml.attributes && xml.attributes.srsDimension;
|
|
5643
|
+
if (srsDimensionAttribute) {
|
|
5644
|
+
const srsDimension = parseInt(srsDimensionAttribute);
|
|
5645
|
+
if (Number.isNaN(srsDimension) || srsDimension <= 0) {
|
|
5646
|
+
throw new Error(`invalid srsDimension attribute value "${srsDimensionAttribute}", expected a positive integer`);
|
|
5647
|
+
}
|
|
5648
|
+
const childContext = Object.create(context);
|
|
5649
|
+
childContext.srsDimension = srsDimension;
|
|
5650
|
+
return childContext;
|
|
5651
|
+
}
|
|
5652
|
+
return context;
|
|
5653
|
+
}
|
|
5654
|
+
var import_deep_strict_equal;
|
|
5655
|
+
var init_parse_gml = __esm({
|
|
5656
|
+
"src/lib/gml/parse-gml.ts"() {
|
|
5657
|
+
init_src();
|
|
5658
|
+
import_deep_strict_equal = __toModule(require_deep_strict_equal());
|
|
5659
|
+
init_main_es6();
|
|
5660
|
+
}
|
|
5661
|
+
});
|
|
5662
|
+
|
|
5663
|
+
// src/gml-loader.ts
|
|
5664
|
+
function testXMLFile6(text) {
|
|
5665
|
+
return text.startsWith("<?xml");
|
|
5666
|
+
}
|
|
5667
|
+
var VERSION7, GMLLoader;
|
|
5668
|
+
var init_gml_loader = __esm({
|
|
5669
|
+
"src/gml-loader.ts"() {
|
|
5670
|
+
init_parse_gml();
|
|
5671
|
+
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
5672
|
+
GMLLoader = {
|
|
5673
|
+
name: "GML",
|
|
5674
|
+
id: "gml",
|
|
5675
|
+
module: "wms",
|
|
5676
|
+
version: VERSION7,
|
|
5677
|
+
worker: false,
|
|
5678
|
+
extensions: ["xml"],
|
|
5679
|
+
mimeTypes: ["application/vnd.ogc.gml_xml", "application/xml", "text/xml"],
|
|
5680
|
+
testText: testXMLFile6,
|
|
5681
|
+
options: {
|
|
5682
|
+
gml: {}
|
|
5683
|
+
},
|
|
5684
|
+
parse: async (arrayBuffer, options) => parseGML(new TextDecoder().decode(arrayBuffer), options),
|
|
5685
|
+
parseTextSync: (text, options) => parseGML(text, options)
|
|
2247
5686
|
};
|
|
2248
5687
|
}
|
|
2249
5688
|
});
|
|
@@ -2251,17 +5690,25 @@
|
|
|
2251
5690
|
// src/index.ts
|
|
2252
5691
|
var src_exports = {};
|
|
2253
5692
|
__export(src_exports, {
|
|
5693
|
+
GMLLoader: () => GMLLoader,
|
|
5694
|
+
WFSCapabilitiesLoader: () => WFSCapabilitiesLoader,
|
|
2254
5695
|
WMSCapabilitiesLoader: () => WMSCapabilitiesLoader,
|
|
5696
|
+
WMSErrorLoader: () => WMSErrorLoader,
|
|
2255
5697
|
WMSFeatureInfoLoader: () => WMSFeatureInfoLoader,
|
|
2256
5698
|
WMSLayerDescriptionLoader: () => WMSLayerDescriptionLoader,
|
|
2257
|
-
|
|
5699
|
+
WMSService: () => WMSService,
|
|
5700
|
+
WMTSCapabilitiesLoader: () => WMTSCapabilitiesLoader
|
|
2258
5701
|
});
|
|
2259
5702
|
var init_src4 = __esm({
|
|
2260
5703
|
"src/index.ts"() {
|
|
5704
|
+
init_wms_error_loader();
|
|
2261
5705
|
init_wms_capabilities_loader();
|
|
2262
5706
|
init_wms_feature_info_loader();
|
|
2263
5707
|
init_wms_layer_description_loader();
|
|
2264
|
-
|
|
5708
|
+
init_wms_service();
|
|
5709
|
+
init_wfs_capabilities_loader();
|
|
5710
|
+
init_wmts_capabilities_loader();
|
|
5711
|
+
init_gml_loader();
|
|
2265
5712
|
}
|
|
2266
5713
|
});
|
|
2267
5714
|
|
|
@@ -2275,3 +5722,10 @@
|
|
|
2275
5722
|
});
|
|
2276
5723
|
require_bundle();
|
|
2277
5724
|
})();
|
|
5725
|
+
/*!
|
|
5726
|
+
* The buffer module from node.js, for the browser.
|
|
5727
|
+
*
|
|
5728
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5729
|
+
* @license MIT
|
|
5730
|
+
*/
|
|
5731
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|