@npm9912/v-map 0.1.0
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/LICENSE +21 -0
- package/README.md +185 -0
- package/dist/cjs/_commonjsHelpers-B83fTs8d.js +36 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/cesium-provider-BiFFyAl9.js +2598 -0
- package/dist/cjs/deck-provider-Ctq3Q8a1.js +47824 -0
- package/dist/cjs/geotiff-CEwvF9cG.js +47 -0
- package/dist/cjs/geotiff-source-RaNzzWkC.js +1522 -0
- package/dist/cjs/index-B1oGO1g-.js +10658 -0
- package/dist/cjs/index-B8LHqjyg.js +1765 -0
- package/dist/cjs/index-BIL4VsgP.js +310 -0
- package/dist/cjs/index-Blku2QY8.js +167 -0
- package/dist/cjs/index-CJvvX4yx.js +21 -0
- package/dist/cjs/index-CbVT-Con.js +699 -0
- package/dist/cjs/index-ISOEpMC3.js +20478 -0
- package/dist/cjs/index-JSwBbvGA.js +1621 -0
- package/dist/cjs/index.browser-DQhD8Jwl.js +6873 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/layer-extension-B_olS0rc.js +65 -0
- package/dist/cjs/leaflet-provider-DOqfs7g5.js +1815 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/main-dist-7TykwFci.js +2655 -0
- package/dist/cjs/messages-D7h4m8Tx.js +186 -0
- package/dist/cjs/openlayers-provider-Dfeg6L4n.js +1604 -0
- package/dist/cjs/polygon-layer-B9PrN7vr.js +1300 -0
- package/dist/cjs/scenegraph-layer-DwNoxQdi.js +2530 -0
- package/dist/cjs/styleconfig-CVRqArk-.js +23 -0
- package/dist/cjs/v-map-builder.cjs.entry.js +3786 -0
- package/dist/cjs/v-map-layer-geojson_12.cjs.entry.js +40894 -0
- package/dist/cjs/v-map-layer-helper-iAzxAg9I.js +285 -0
- package/dist/cjs/v-map-layer-terrain-geotiff.cjs.entry.js +258 -0
- package/dist/cjs/v-map-layercontrol.cjs.entry.js +247 -0
- package/dist/cjs/v-map.cjs.js +25 -0
- package/dist/cjs/v-map.v-map-layer-osm.v-map-layergroup-BsXp3BoL.js +582 -0
- package/dist/cjs/v-map_3.cjs.entry.js +12 -0
- package/dist/collection/collection-manifest.json +30 -0
- package/dist/collection/components/v-map/v-map.css +3 -0
- package/dist/collection/components/v-map/v-map.js +467 -0
- package/dist/collection/components/v-map/v-map.test.js +33 -0
- package/dist/collection/components/v-map-builder/v-map-builder.css +1 -0
- package/dist/collection/components/v-map-builder/v-map-builder.js +913 -0
- package/dist/collection/components/v-map-builder/v-map-builder.test.js +56 -0
- package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.js +862 -0
- package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.test.js +42 -0
- package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.css +4 -0
- package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.js +500 -0
- package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.test.js +38 -0
- package/dist/collection/components/v-map-layer-google/v-map-layer-google.css +1 -0
- package/dist/collection/components/v-map-layer-google/v-map-layer-google.js +442 -0
- package/dist/collection/components/v-map-layer-osm/error-api.test.js +108 -0
- package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.css +4 -0
- package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.js +311 -0
- package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.test.js +36 -0
- package/dist/collection/components/v-map-layer-scatterplot/v-map-layer-scatterplot.css +1 -0
- package/dist/collection/components/v-map-layer-scatterplot/v-map-layer-scatterplot.js +305 -0
- package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.css +3 -0
- package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.js +548 -0
- package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.test.js +36 -0
- package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.css +3 -0
- package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.js +735 -0
- package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.test.js +42 -0
- package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.css +3 -0
- package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.js +449 -0
- package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.test.js +50 -0
- package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.css +1 -0
- package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.js +448 -0
- package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.test.js +39 -0
- package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.css +1 -0
- package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.js +489 -0
- package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.test.js +43 -0
- package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.css +1 -0
- package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.js +811 -0
- package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.test.js +34 -0
- package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.css +1 -0
- package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.js +453 -0
- package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.test.js +36 -0
- package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.css +1 -0
- package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.js +331 -0
- package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.test.js +28 -0
- package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.css +74 -0
- package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.js +277 -0
- package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.test.js +134 -0
- package/dist/collection/components/v-map-layergroup/v-map-layergroup.css +4 -0
- package/dist/collection/components/v-map-layergroup/v-map-layergroup.js +212 -0
- package/dist/collection/components/v-map-layergroup/v-map-layergroup.test.js +39 -0
- package/dist/collection/components/v-map-style/v-map-style.css +38 -0
- package/dist/collection/components/v-map-style/v-map-style.js +492 -0
- package/dist/collection/components/v-map-style/v-map-style.unit.js +62 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/layer/v-map-layer-helper.js +281 -0
- package/dist/collection/layer/v-map-layer-helper.unit.js +234 -0
- package/dist/collection/lib/cesium-loader.js +58 -0
- package/dist/collection/lib/ensure-importmap.js +12 -0
- package/dist/collection/lib/ensure-importmap.unit.js +57 -0
- package/dist/collection/lib/versions.gen.js +6 -0
- package/dist/collection/lib/vstyle.js +8 -0
- package/dist/collection/map-provider/cesium/CesiumGeoTIFFTerrainProvider.js +285 -0
- package/dist/collection/map-provider/cesium/CesiumLayerGroups.js +159 -0
- package/dist/collection/map-provider/cesium/GeoTIFFImageryProvider.js +192 -0
- package/dist/collection/map-provider/cesium/GeoTIFFImageryProvider.test.js +57 -0
- package/dist/collection/map-provider/cesium/cesium-provider.js +1408 -0
- package/dist/collection/map-provider/cesium/i-layer.js +1 -0
- package/dist/collection/map-provider/cesium/layer-manager.js +467 -0
- package/dist/collection/map-provider/deck/DeckGLGeoTIFFLayer.js +483 -0
- package/dist/collection/map-provider/deck/DeckGLGeoTIFFTerrainLayer.js +410 -0
- package/dist/collection/map-provider/deck/LayerGroupWithModel.js +169 -0
- package/dist/collection/map-provider/deck/LayerGroups.js +192 -0
- package/dist/collection/map-provider/deck/LayerModel.js +1 -0
- package/dist/collection/map-provider/deck/RenderableGroup.js +1 -0
- package/dist/collection/map-provider/deck/deck-provider.js +1563 -0
- package/dist/collection/map-provider/geotiff/geotiff-source.js +172 -0
- package/dist/collection/map-provider/geotiff/utils/AABB2D.js +24 -0
- package/dist/collection/map-provider/geotiff/utils/BVHNode2D.js +166 -0
- package/dist/collection/map-provider/geotiff/utils/GeoTIFFTileProcessor.js +484 -0
- package/dist/collection/map-provider/geotiff/utils/Triangle.js +1 -0
- package/dist/collection/map-provider/geotiff/utils/Triangulation.js +321 -0
- package/dist/collection/map-provider/geotiff/utils/colormap-utils.js +190 -0
- package/dist/collection/map-provider/geotiff/utils/normalization-utils.js +122 -0
- package/dist/collection/map-provider/geotiff/utils/sampling-utils.js +108 -0
- package/dist/collection/map-provider/leaflet/GeoTIFFGridLayer.js +147 -0
- package/dist/collection/map-provider/leaflet/WCSGridLayer.js +124 -0
- package/dist/collection/map-provider/leaflet/google-map-tiles-layer.js +352 -0
- package/dist/collection/map-provider/leaflet/leaflet-helpers.js +94 -0
- package/dist/collection/map-provider/leaflet/leaflet-provider.js +1095 -0
- package/dist/collection/map-provider/ol/CustomGeoTiff.js +145 -0
- package/dist/collection/map-provider/ol/openlayers-helper.js +26 -0
- package/dist/collection/map-provider/ol/openlayers-provider.js +1427 -0
- package/dist/collection/map-provider/provider-factory.js +44 -0
- package/dist/collection/map-provider/provider-factory.unit.js +66 -0
- package/dist/collection/testing/browser-test-utils.js +49 -0
- package/dist/collection/testing/e2e-testing.js +122 -0
- package/dist/collection/testing/e2e-utils.js +70 -0
- package/dist/collection/testing/geotiff-test-server.js +100 -0
- package/dist/collection/testing/mocks/geostyler-lyrx-parser.js +12 -0
- package/dist/collection/testing/mocks/geostyler-mapbox-parser.js +12 -0
- package/dist/collection/testing/mocks/geostyler-qgis-parser.js +12 -0
- package/dist/collection/testing/mocks/geostyler-sld-parser.js +13 -0
- package/dist/collection/testing/mocks/geostyler-style.js +5 -0
- package/dist/collection/testing/setupTests.browser.js +1 -0
- package/dist/collection/testing/setupTests.stencil.js +20 -0
- package/dist/collection/testing/setupTests.vitest.js +59 -0
- package/dist/collection/testing/stencil-testing-wrapper.js +43 -0
- package/dist/collection/testing/styleMock.js +1 -0
- package/dist/collection/types/color.js +1 -0
- package/dist/collection/types/cssmode.js +1 -0
- package/dist/collection/types/flavour.js +1 -0
- package/dist/collection/types/layerconfig.js +1 -0
- package/dist/collection/types/lonlat.js +1 -0
- package/dist/collection/types/mapinitoptions.js +1 -0
- package/dist/collection/types/mapprovider.js +1 -0
- package/dist/collection/types/provideroptions.js +1 -0
- package/dist/collection/types/styleconfig.js +19 -0
- package/dist/collection/types/styling.js +13 -0
- package/dist/collection/types/styling.unit.js +37 -0
- package/dist/collection/types/vmaplayer.js +1 -0
- package/dist/collection/utils/async-mutex.js +28 -0
- package/dist/collection/utils/diff.js +142 -0
- package/dist/collection/utils/diff.unit.js +59 -0
- package/dist/collection/utils/dom-env.js +43 -0
- package/dist/collection/utils/dom-env.unit.js +92 -0
- package/dist/collection/utils/events.js +8 -0
- package/dist/collection/utils/logger.js +183 -0
- package/dist/collection/utils/logger.unit.js +98 -0
- package/dist/collection/utils/messages.js +12 -0
- package/dist/collection/utils/spatial-utils.js +27 -0
- package/dist/collection/utils/spatial-utils.unit.js +24 -0
- package/dist/components/_commonjsHelpers.js +1 -0
- package/dist/components/cesium-provider.js +1 -0
- package/dist/components/deck-provider.js +1 -0
- package/dist/components/events.js +1 -0
- package/dist/components/geotiff-source.js +1 -0
- package/dist/components/geotiff.js +4 -0
- package/dist/components/index.browser.js +15 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +1 -0
- package/dist/components/index3.js +1 -0
- package/dist/components/index4.js +1 -0
- package/dist/components/index5.js +1 -0
- package/dist/components/index6.js +1 -0
- package/dist/components/index7.js +1 -0
- package/dist/components/index8.js +7 -0
- package/dist/components/layer-extension.js +1 -0
- package/dist/components/leaflet-provider.js +1 -0
- package/dist/components/main-dist.js +1 -0
- package/dist/components/messages.js +1 -0
- package/dist/components/openlayers-provider.js +1 -0
- package/dist/components/polygon-layer.js +1 -0
- package/dist/components/scenegraph-layer.js +1 -0
- package/dist/components/styleconfig.js +1 -0
- package/dist/components/styling.js +1 -0
- package/dist/components/v-map-builder.d.ts +11 -0
- package/dist/components/v-map-builder.js +2 -0
- package/dist/components/v-map-layer-geojson.d.ts +11 -0
- package/dist/components/v-map-layer-geojson.js +1 -0
- package/dist/components/v-map-layer-geojson2.js +1 -0
- package/dist/components/v-map-layer-geotiff.d.ts +11 -0
- package/dist/components/v-map-layer-geotiff.js +1 -0
- package/dist/components/v-map-layer-geotiff2.js +1 -0
- package/dist/components/v-map-layer-google.d.ts +11 -0
- package/dist/components/v-map-layer-google.js +1 -0
- package/dist/components/v-map-layer-google2.js +1 -0
- package/dist/components/v-map-layer-helper.js +1 -0
- package/dist/components/v-map-layer-osm.d.ts +11 -0
- package/dist/components/v-map-layer-osm.js +1 -0
- package/dist/components/v-map-layer-osm2.js +1 -0
- package/dist/components/v-map-layer-scatterplot.d.ts +11 -0
- package/dist/components/v-map-layer-scatterplot.js +1 -0
- package/dist/components/v-map-layer-scatterplot2.js +1 -0
- package/dist/components/v-map-layer-terrain-geotiff.d.ts +11 -0
- package/dist/components/v-map-layer-terrain-geotiff.js +1 -0
- package/dist/components/v-map-layer-terrain.d.ts +11 -0
- package/dist/components/v-map-layer-terrain.js +1 -0
- package/dist/components/v-map-layer-terrain2.js +1 -0
- package/dist/components/v-map-layer-tile3d.d.ts +11 -0
- package/dist/components/v-map-layer-tile3d.js +1 -0
- package/dist/components/v-map-layer-tile3d2.js +1 -0
- package/dist/components/v-map-layer-wcs.d.ts +11 -0
- package/dist/components/v-map-layer-wcs.js +1 -0
- package/dist/components/v-map-layer-wcs2.js +1 -0
- package/dist/components/v-map-layer-wfs.d.ts +11 -0
- package/dist/components/v-map-layer-wfs.js +1 -0
- package/dist/components/v-map-layer-wfs2.js +1 -0
- package/dist/components/v-map-layer-wkt.d.ts +11 -0
- package/dist/components/v-map-layer-wkt.js +1 -0
- package/dist/components/v-map-layer-wkt2.js +1 -0
- package/dist/components/v-map-layer-wms.d.ts +11 -0
- package/dist/components/v-map-layer-wms.js +1 -0
- package/dist/components/v-map-layer-wms2.js +1 -0
- package/dist/components/v-map-layer-xyz.d.ts +11 -0
- package/dist/components/v-map-layer-xyz.js +1 -0
- package/dist/components/v-map-layer-xyz2.js +1 -0
- package/dist/components/v-map-layercontrol.d.ts +11 -0
- package/dist/components/v-map-layercontrol.js +1 -0
- package/dist/components/v-map-layergroup.d.ts +11 -0
- package/dist/components/v-map-layergroup.js +1 -0
- package/dist/components/v-map-layergroup2.js +1 -0
- package/dist/components/v-map-style.d.ts +11 -0
- package/dist/components/v-map-style.js +1 -0
- package/dist/components/v-map-style2.js +10 -0
- package/dist/components/v-map.d.ts +11 -0
- package/dist/components/v-map.js +1 -0
- package/dist/components/v-map2.js +1 -0
- package/dist/esm/_commonjsHelpers-E-ZsRS8r.js +32 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/cesium-provider-BJfAup3w.js +2596 -0
- package/dist/esm/deck-provider-C7U9VDEq.js +47709 -0
- package/dist/esm/geotiff-BEWxTIfH.js +45 -0
- package/dist/esm/geotiff-source-esnDnC-u.js +1516 -0
- package/dist/esm/index-B1zwA4IC.js +685 -0
- package/dist/esm/index-BBpiaTpT.js +165 -0
- package/dist/esm/index-BIEmlzCf.js +1697 -0
- package/dist/esm/index-BUHa4Jj0.js +307 -0
- package/dist/esm/index-DbSdn93t.js +20461 -0
- package/dist/esm/index-RpJarvr_.js +10656 -0
- package/dist/esm/index-jN06TXUp.js +14 -0
- package/dist/esm/index-jzneDarq.js +1613 -0
- package/dist/esm/index.browser-DhQAXuA7.js +6860 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/layer-extension-CZXK5goK.js +63 -0
- package/dist/esm/leaflet-provider-Q41TB6ku.js +1794 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/main-dist-CwnA7_Xn.js +2652 -0
- package/dist/esm/messages-CMKJzsgL.js +180 -0
- package/dist/esm/openlayers-provider-CMsDsQTQ.js +1602 -0
- package/dist/esm/polygon-layer-ByhxGhWC.js +1295 -0
- package/dist/esm/scenegraph-layer-09K_B6DT.js +2526 -0
- package/dist/esm/styleconfig-B-bAcABs.js +21 -0
- package/dist/esm/v-map-builder.entry.js +3784 -0
- package/dist/esm/v-map-layer-geojson_12.entry.js +40881 -0
- package/dist/esm/v-map-layer-helper-Dys44Cgo.js +283 -0
- package/dist/esm/v-map-layer-terrain-geotiff.entry.js +256 -0
- package/dist/esm/v-map-layercontrol.entry.js +245 -0
- package/dist/esm/v-map.js +21 -0
- package/dist/esm/v-map.v-map-layer-osm.v-map-layergroup-B4pFHuSf.js +572 -0
- package/dist/esm/v-map_3.entry.js +4 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/cesium-augment.d.ts +5 -0
- package/dist/types/components/v-map/v-map.d.ts +70 -0
- package/dist/types/components/v-map/v-map.test.d.ts +1 -0
- package/dist/types/components/v-map-builder/v-map-builder.d.ts +48 -0
- package/dist/types/components/v-map-builder/v-map-builder.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-geojson/v-map-layer-geojson.d.ts +129 -0
- package/dist/types/components/v-map-layer-geojson/v-map-layer-geojson.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-geotiff/v-map-layer-geotiff.d.ts +74 -0
- package/dist/types/components/v-map-layer-geotiff/v-map-layer-geotiff.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-google/v-map-layer-google.d.ts +78 -0
- package/dist/types/components/v-map-layer-osm/error-api.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-osm/v-map-layer-osm.d.ts +50 -0
- package/dist/types/components/v-map-layer-osm/v-map-layer-osm.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-scatterplot/v-map-layer-scatterplot.d.ts +54 -0
- package/dist/types/components/v-map-layer-terrain/v-map-layer-terrain.d.ts +74 -0
- package/dist/types/components/v-map-layer-terrain/v-map-layer-terrain.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.d.ts +117 -0
- package/dist/types/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-tile3d/v-map-layer-tile3d.d.ts +69 -0
- package/dist/types/components/v-map-layer-tile3d/v-map-layer-tile3d.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wcs/v-map-layer-wcs.d.ts +47 -0
- package/dist/types/components/v-map-layer-wcs/v-map-layer-wcs.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wfs/v-map-layer-wfs.d.ts +59 -0
- package/dist/types/components/v-map-layer-wfs/v-map-layer-wfs.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wkt/v-map-layer-wkt.d.ts +132 -0
- package/dist/types/components/v-map-layer-wkt/v-map-layer-wkt.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wms/v-map-layer-wms.d.ts +76 -0
- package/dist/types/components/v-map-layer-wms/v-map-layer-wms.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-xyz/v-map-layer-xyz.d.ts +59 -0
- package/dist/types/components/v-map-layer-xyz/v-map-layer-xyz.test.d.ts +1 -0
- package/dist/types/components/v-map-layercontrol/v-map-layercontrol.d.ts +44 -0
- package/dist/types/components/v-map-layercontrol/v-map-layercontrol.test.d.ts +1 -0
- package/dist/types/components/v-map-layergroup/v-map-layergroup.d.ts +31 -0
- package/dist/types/components/v-map-layergroup/v-map-layergroup.test.d.ts +1 -0
- package/dist/types/components/v-map-style/v-map-style.d.ts +75 -0
- package/dist/types/components/v-map-style/v-map-style.unit.d.ts +1 -0
- package/dist/types/components.d.ts +2391 -0
- package/dist/types/globals.d.ts +16 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/layer/v-map-layer-helper.d.ts +45 -0
- package/dist/types/layer/v-map-layer-helper.unit.d.ts +1 -0
- package/dist/types/leaflet-augment.d.ts +15 -0
- package/dist/types/lib/cesium-loader.d.ts +3 -0
- package/dist/types/lib/ensure-importmap.d.ts +3 -0
- package/dist/types/lib/ensure-importmap.unit.d.ts +1 -0
- package/dist/types/lib/versions.gen.d.ts +5 -0
- package/dist/types/lib/vstyle.d.ts +44 -0
- package/dist/types/map-provider/cesium/CesiumGeoTIFFTerrainProvider.d.ts +92 -0
- package/dist/types/map-provider/cesium/CesiumLayerGroups.d.ts +64 -0
- package/dist/types/map-provider/cesium/GeoTIFFImageryProvider.d.ts +75 -0
- package/dist/types/map-provider/cesium/GeoTIFFImageryProvider.test.d.ts +1 -0
- package/dist/types/map-provider/cesium/cesium-provider.d.ts +87 -0
- package/dist/types/map-provider/cesium/i-layer.d.ts +11 -0
- package/dist/types/map-provider/cesium/layer-manager.d.ts +31 -0
- package/dist/types/map-provider/deck/DeckGLGeoTIFFLayer.d.ts +91 -0
- package/dist/types/map-provider/deck/DeckGLGeoTIFFTerrainLayer.d.ts +82 -0
- package/dist/types/map-provider/deck/LayerGroupWithModel.d.ts +55 -0
- package/dist/types/map-provider/deck/LayerGroups.d.ts +63 -0
- package/dist/types/map-provider/deck/LayerModel.d.ts +8 -0
- package/dist/types/map-provider/deck/RenderableGroup.d.ts +20 -0
- package/dist/types/map-provider/deck/deck-provider.d.ts +92 -0
- package/dist/types/map-provider/geotiff/geotiff-source.d.ts +30 -0
- package/dist/types/map-provider/geotiff/utils/AABB2D.d.ts +28 -0
- package/dist/types/map-provider/geotiff/utils/BVHNode2D.d.ts +36 -0
- package/dist/types/map-provider/geotiff/utils/GeoTIFFTileProcessor.d.ts +116 -0
- package/dist/types/map-provider/geotiff/utils/Triangle.d.ts +5 -0
- package/dist/types/map-provider/geotiff/utils/Triangulation.d.ts +94 -0
- package/dist/types/map-provider/geotiff/utils/colormap-utils.d.ts +47 -0
- package/dist/types/map-provider/geotiff/utils/normalization-utils.d.ts +39 -0
- package/dist/types/map-provider/geotiff/utils/sampling-utils.d.ts +13 -0
- package/dist/types/map-provider/leaflet/GeoTIFFGridLayer.d.ts +34 -0
- package/dist/types/map-provider/leaflet/WCSGridLayer.d.ts +38 -0
- package/dist/types/map-provider/leaflet/google-map-tiles-layer.d.ts +73 -0
- package/dist/types/map-provider/leaflet/leaflet-helpers.d.ts +6 -0
- package/dist/types/map-provider/leaflet/leaflet-provider.d.ts +73 -0
- package/dist/types/map-provider/ol/CustomGeoTiff.d.ts +14 -0
- package/dist/types/map-provider/ol/openlayers-helper.d.ts +2 -0
- package/dist/types/map-provider/ol/openlayers-provider.d.ts +80 -0
- package/dist/types/map-provider/provider-factory.d.ts +12 -0
- package/dist/types/map-provider/provider-factory.unit.d.ts +1 -0
- package/dist/types/namespaces.d.ts +3 -0
- package/dist/types/ol-augment.d.ts +3 -0
- package/dist/types/ol-override.d.ts +7 -0
- package/dist/types/ol.d.ts +10 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/dist/types/testing/browser-test-utils.d.ts +6 -0
- package/dist/types/testing/e2e-testing.d.ts +5 -0
- package/dist/types/testing/e2e-utils.d.ts +4 -0
- package/dist/types/testing/geotiff-test-server.d.ts +5 -0
- package/dist/types/testing/mocks/geostyler-lyrx-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-mapbox-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-qgis-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-sld-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-style.d.ts +5 -0
- package/dist/types/testing/setupTests.browser.d.ts +1 -0
- package/dist/types/testing/setupTests.stencil.d.ts +1 -0
- package/dist/types/testing/setupTests.vitest.d.ts +1 -0
- package/dist/types/testing/stencil-testing-wrapper.d.ts +3 -0
- package/dist/types/types/color.d.ts +1 -0
- package/dist/types/types/cssmode.d.ts +1 -0
- package/dist/types/types/flavour.d.ts +1 -0
- package/dist/types/types/layerconfig.d.ts +207 -0
- package/dist/types/types/lonlat.d.ts +1 -0
- package/dist/types/types/mapinitoptions.d.ts +4 -0
- package/dist/types/types/mapprovider.d.ts +46 -0
- package/dist/types/types/provideroptions.d.ts +8 -0
- package/dist/types/types/styleconfig.d.ts +27 -0
- package/dist/types/types/styling.d.ts +24 -0
- package/dist/types/types/styling.unit.d.ts +1 -0
- package/dist/types/types/vmaplayer.d.ts +10 -0
- package/dist/types/utils/async-mutex.d.ts +7 -0
- package/dist/types/utils/diff.d.ts +64 -0
- package/dist/types/utils/diff.unit.d.ts +1 -0
- package/dist/types/utils/dom-env.d.ts +5 -0
- package/dist/types/utils/dom-env.unit.d.ts +1 -0
- package/dist/types/utils/events.d.ts +29 -0
- package/dist/types/utils/logger.d.ts +47 -0
- package/dist/types/utils/logger.unit.d.ts +1 -0
- package/dist/types/utils/messages.d.ts +12 -0
- package/dist/types/utils/spatial-utils.d.ts +6 -0
- package/dist/types/utils/spatial-utils.unit.d.ts +1 -0
- package/dist/types/versions.d.ts +7 -0
- package/dist/v-map/index.esm.js +0 -0
- package/dist/v-map/p--vVleK-M.js +1 -0
- package/dist/v-map/p-09d10db0.entry.js +1 -0
- package/dist/v-map/p-5eba6058.entry.js +10 -0
- package/dist/v-map/p-6b102336.entry.js +1 -0
- package/dist/v-map/p-B-bAcABs.js +1 -0
- package/dist/v-map/p-BBpiaTpT.js +1 -0
- package/dist/v-map/p-BdijL4Av.js +1 -0
- package/dist/v-map/p-Be3r33VF.js +4 -0
- package/dist/v-map/p-BeFu0ap4.js +1 -0
- package/dist/v-map/p-BxFJezdK.js +1 -0
- package/dist/v-map/p-CMKJzsgL.js +1 -0
- package/dist/v-map/p-CXfA_q8m.js +1 -0
- package/dist/v-map/p-CZqY0yW4.js +1 -0
- package/dist/v-map/p-CafTHT9i.js +1 -0
- package/dist/v-map/p-DCTHyf58.js +1 -0
- package/dist/v-map/p-DQuL1Twl.js +1 -0
- package/dist/v-map/p-DR9McdNX.js +1 -0
- package/dist/v-map/p-Dckgonw8.js +1 -0
- package/dist/v-map/p-DhQAXuA7.js +15 -0
- package/dist/v-map/p-DmICdG34.js +7 -0
- package/dist/v-map/p-DrOQ9V4h.js +1 -0
- package/dist/v-map/p-DvHXtWUg.js +1 -0
- package/dist/v-map/p-E-ZsRS8r.js +1 -0
- package/dist/v-map/p-MyTSFnEk.js +1 -0
- package/dist/v-map/p-RpJarvr_.js +1 -0
- package/dist/v-map/p-WaMDUuAz.js +1 -0
- package/dist/v-map/p-aa410e64.entry.js +2 -0
- package/dist/v-map/p-c21c93fe.entry.js +1 -0
- package/dist/v-map/p-jzneDarq.js +2 -0
- package/dist/v-map/p-uiIP-taz.js +1 -0
- package/dist/v-map/v-map.esm.js +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +193 -0
|
@@ -0,0 +1,3786 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-JSwBbvGA.js');
|
|
4
|
+
var messages = require('./messages-D7h4m8Tx.js');
|
|
5
|
+
|
|
6
|
+
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
7
|
+
function isNothing(subject) {
|
|
8
|
+
return (typeof subject === 'undefined') || (subject === null);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function isObject(subject) {
|
|
13
|
+
return (typeof subject === 'object') && (subject !== null);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function toArray(sequence) {
|
|
18
|
+
if (Array.isArray(sequence)) return sequence;
|
|
19
|
+
else if (isNothing(sequence)) return [];
|
|
20
|
+
|
|
21
|
+
return [ sequence ];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function extend(target, source) {
|
|
26
|
+
var index, length, key, sourceKeys;
|
|
27
|
+
|
|
28
|
+
if (source) {
|
|
29
|
+
sourceKeys = Object.keys(source);
|
|
30
|
+
|
|
31
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
32
|
+
key = sourceKeys[index];
|
|
33
|
+
target[key] = source[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return target;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function repeat(string, count) {
|
|
42
|
+
var result = '', cycle;
|
|
43
|
+
|
|
44
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
45
|
+
result += string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
function isNegativeZero(number) {
|
|
53
|
+
return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var isNothing_1 = isNothing;
|
|
58
|
+
var isObject_1 = isObject;
|
|
59
|
+
var toArray_1 = toArray;
|
|
60
|
+
var repeat_1 = repeat;
|
|
61
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
62
|
+
var extend_1 = extend;
|
|
63
|
+
|
|
64
|
+
var common = {
|
|
65
|
+
isNothing: isNothing_1,
|
|
66
|
+
isObject: isObject_1,
|
|
67
|
+
toArray: toArray_1,
|
|
68
|
+
repeat: repeat_1,
|
|
69
|
+
isNegativeZero: isNegativeZero_1,
|
|
70
|
+
extend: extend_1
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// YAML error class. http://stackoverflow.com/questions/8458984
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
function formatError(exception, compact) {
|
|
77
|
+
var where = '', message = exception.reason || '(unknown reason)';
|
|
78
|
+
|
|
79
|
+
if (!exception.mark) return message;
|
|
80
|
+
|
|
81
|
+
if (exception.mark.name) {
|
|
82
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')';
|
|
86
|
+
|
|
87
|
+
if (!compact && exception.mark.snippet) {
|
|
88
|
+
where += '\n\n' + exception.mark.snippet;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return message + ' ' + where;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function YAMLException$1(reason, mark) {
|
|
96
|
+
// Super constructor
|
|
97
|
+
Error.call(this);
|
|
98
|
+
|
|
99
|
+
this.name = 'YAMLException';
|
|
100
|
+
this.reason = reason;
|
|
101
|
+
this.mark = mark;
|
|
102
|
+
this.message = formatError(this, false);
|
|
103
|
+
|
|
104
|
+
// Include stack trace in error object
|
|
105
|
+
if (Error.captureStackTrace) {
|
|
106
|
+
// Chrome and NodeJS
|
|
107
|
+
Error.captureStackTrace(this, this.constructor);
|
|
108
|
+
} else {
|
|
109
|
+
// FF, IE 10+ and Safari 6+. Fallback for others
|
|
110
|
+
this.stack = (new Error()).stack || '';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
// Inherit from Error
|
|
116
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
117
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
121
|
+
return this.name + ': ' + formatError(this, compact);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var exception = YAMLException$1;
|
|
126
|
+
|
|
127
|
+
// get snippet for a single line, respecting maxLength
|
|
128
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
129
|
+
var head = '';
|
|
130
|
+
var tail = '';
|
|
131
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
132
|
+
|
|
133
|
+
if (position - lineStart > maxHalfLength) {
|
|
134
|
+
head = ' ... ';
|
|
135
|
+
lineStart = position - maxHalfLength + head.length;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (lineEnd - position > maxHalfLength) {
|
|
139
|
+
tail = ' ...';
|
|
140
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail,
|
|
145
|
+
pos: position - lineStart + head.length // relative position
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
function padStart(string, max) {
|
|
151
|
+
return common.repeat(' ', max - string.length) + string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
function makeSnippet(mark, options) {
|
|
156
|
+
options = Object.create(options || null);
|
|
157
|
+
|
|
158
|
+
if (!mark.buffer) return null;
|
|
159
|
+
|
|
160
|
+
if (!options.maxLength) options.maxLength = 79;
|
|
161
|
+
if (typeof options.indent !== 'number') options.indent = 1;
|
|
162
|
+
if (typeof options.linesBefore !== 'number') options.linesBefore = 3;
|
|
163
|
+
if (typeof options.linesAfter !== 'number') options.linesAfter = 2;
|
|
164
|
+
|
|
165
|
+
var re = /\r?\n|\r|\0/g;
|
|
166
|
+
var lineStarts = [ 0 ];
|
|
167
|
+
var lineEnds = [];
|
|
168
|
+
var match;
|
|
169
|
+
var foundLineNo = -1;
|
|
170
|
+
|
|
171
|
+
while ((match = re.exec(mark.buffer))) {
|
|
172
|
+
lineEnds.push(match.index);
|
|
173
|
+
lineStarts.push(match.index + match[0].length);
|
|
174
|
+
|
|
175
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
176
|
+
foundLineNo = lineStarts.length - 2;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
181
|
+
|
|
182
|
+
var result = '', i, line;
|
|
183
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
184
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
185
|
+
|
|
186
|
+
for (i = 1; i <= options.linesBefore; i++) {
|
|
187
|
+
if (foundLineNo - i < 0) break;
|
|
188
|
+
line = getLine(
|
|
189
|
+
mark.buffer,
|
|
190
|
+
lineStarts[foundLineNo - i],
|
|
191
|
+
lineEnds[foundLineNo - i],
|
|
192
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
193
|
+
maxLineLength
|
|
194
|
+
);
|
|
195
|
+
result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) +
|
|
196
|
+
' | ' + line.str + '\n' + result;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
200
|
+
result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) +
|
|
201
|
+
' | ' + line.str + '\n';
|
|
202
|
+
result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n';
|
|
203
|
+
|
|
204
|
+
for (i = 1; i <= options.linesAfter; i++) {
|
|
205
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
206
|
+
line = getLine(
|
|
207
|
+
mark.buffer,
|
|
208
|
+
lineStarts[foundLineNo + i],
|
|
209
|
+
lineEnds[foundLineNo + i],
|
|
210
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
211
|
+
maxLineLength
|
|
212
|
+
);
|
|
213
|
+
result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) +
|
|
214
|
+
' | ' + line.str + '\n';
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return result.replace(/\n$/, '');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
var snippet = makeSnippet;
|
|
222
|
+
|
|
223
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
224
|
+
'kind',
|
|
225
|
+
'multi',
|
|
226
|
+
'resolve',
|
|
227
|
+
'construct',
|
|
228
|
+
'instanceOf',
|
|
229
|
+
'predicate',
|
|
230
|
+
'represent',
|
|
231
|
+
'representName',
|
|
232
|
+
'defaultStyle',
|
|
233
|
+
'styleAliases'
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
var YAML_NODE_KINDS = [
|
|
237
|
+
'scalar',
|
|
238
|
+
'sequence',
|
|
239
|
+
'mapping'
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
function compileStyleAliases(map) {
|
|
243
|
+
var result = {};
|
|
244
|
+
|
|
245
|
+
if (map !== null) {
|
|
246
|
+
Object.keys(map).forEach(function (style) {
|
|
247
|
+
map[style].forEach(function (alias) {
|
|
248
|
+
result[String(alias)] = style;
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function Type$1(tag, options) {
|
|
257
|
+
options = options || {};
|
|
258
|
+
|
|
259
|
+
Object.keys(options).forEach(function (name) {
|
|
260
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
261
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// TODO: Add tag format check.
|
|
266
|
+
this.options = options; // keep original options in case user wants to extend this type later
|
|
267
|
+
this.tag = tag;
|
|
268
|
+
this.kind = options['kind'] || null;
|
|
269
|
+
this.resolve = options['resolve'] || function () { return true; };
|
|
270
|
+
this.construct = options['construct'] || function (data) { return data; };
|
|
271
|
+
this.instanceOf = options['instanceOf'] || null;
|
|
272
|
+
this.predicate = options['predicate'] || null;
|
|
273
|
+
this.represent = options['represent'] || null;
|
|
274
|
+
this.representName = options['representName'] || null;
|
|
275
|
+
this.defaultStyle = options['defaultStyle'] || null;
|
|
276
|
+
this.multi = options['multi'] || false;
|
|
277
|
+
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
|
278
|
+
|
|
279
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
280
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
var type = Type$1;
|
|
285
|
+
|
|
286
|
+
/*eslint-disable max-len*/
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
function compileList(schema, name) {
|
|
293
|
+
var result = [];
|
|
294
|
+
|
|
295
|
+
schema[name].forEach(function (currentType) {
|
|
296
|
+
var newIndex = result.length;
|
|
297
|
+
|
|
298
|
+
result.forEach(function (previousType, previousIndex) {
|
|
299
|
+
if (previousType.tag === currentType.tag &&
|
|
300
|
+
previousType.kind === currentType.kind &&
|
|
301
|
+
previousType.multi === currentType.multi) {
|
|
302
|
+
|
|
303
|
+
newIndex = previousIndex;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
result[newIndex] = currentType;
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
function compileMap(/* lists... */) {
|
|
315
|
+
var result = {
|
|
316
|
+
scalar: {},
|
|
317
|
+
sequence: {},
|
|
318
|
+
mapping: {},
|
|
319
|
+
fallback: {},
|
|
320
|
+
multi: {
|
|
321
|
+
scalar: [],
|
|
322
|
+
sequence: [],
|
|
323
|
+
mapping: [],
|
|
324
|
+
fallback: []
|
|
325
|
+
}
|
|
326
|
+
}, index, length;
|
|
327
|
+
|
|
328
|
+
function collectType(type) {
|
|
329
|
+
if (type.multi) {
|
|
330
|
+
result.multi[type.kind].push(type);
|
|
331
|
+
result.multi['fallback'].push(type);
|
|
332
|
+
} else {
|
|
333
|
+
result[type.kind][type.tag] = result['fallback'][type.tag] = type;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
338
|
+
arguments[index].forEach(collectType);
|
|
339
|
+
}
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
function Schema$1(definition) {
|
|
345
|
+
return this.extend(definition);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
Schema$1.prototype.extend = function extend(definition) {
|
|
350
|
+
var implicit = [];
|
|
351
|
+
var explicit = [];
|
|
352
|
+
|
|
353
|
+
if (definition instanceof type) {
|
|
354
|
+
// Schema.extend(type)
|
|
355
|
+
explicit.push(definition);
|
|
356
|
+
|
|
357
|
+
} else if (Array.isArray(definition)) {
|
|
358
|
+
// Schema.extend([ type1, type2, ... ])
|
|
359
|
+
explicit = explicit.concat(definition);
|
|
360
|
+
|
|
361
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
362
|
+
// Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] })
|
|
363
|
+
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
364
|
+
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
365
|
+
|
|
366
|
+
} else {
|
|
367
|
+
throw new exception('Schema.extend argument should be a Type, [ Type ], ' +
|
|
368
|
+
'or a schema definition ({ implicit: [...], explicit: [...] })');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
implicit.forEach(function (type$1) {
|
|
372
|
+
if (!(type$1 instanceof type)) {
|
|
373
|
+
throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (type$1.loadKind && type$1.loadKind !== 'scalar') {
|
|
377
|
+
throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (type$1.multi) {
|
|
381
|
+
throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.');
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
explicit.forEach(function (type$1) {
|
|
386
|
+
if (!(type$1 instanceof type)) {
|
|
387
|
+
throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
var result = Object.create(Schema$1.prototype);
|
|
392
|
+
|
|
393
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
394
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
395
|
+
|
|
396
|
+
result.compiledImplicit = compileList(result, 'implicit');
|
|
397
|
+
result.compiledExplicit = compileList(result, 'explicit');
|
|
398
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
399
|
+
|
|
400
|
+
return result;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
var schema = Schema$1;
|
|
405
|
+
|
|
406
|
+
var str = new type('tag:yaml.org,2002:str', {
|
|
407
|
+
kind: 'scalar',
|
|
408
|
+
construct: function (data) { return data !== null ? data : ''; }
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
var seq = new type('tag:yaml.org,2002:seq', {
|
|
412
|
+
kind: 'sequence',
|
|
413
|
+
construct: function (data) { return data !== null ? data : []; }
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
var map = new type('tag:yaml.org,2002:map', {
|
|
417
|
+
kind: 'mapping',
|
|
418
|
+
construct: function (data) { return data !== null ? data : {}; }
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
var failsafe = new schema({
|
|
422
|
+
explicit: [
|
|
423
|
+
str,
|
|
424
|
+
seq,
|
|
425
|
+
map
|
|
426
|
+
]
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
function resolveYamlNull(data) {
|
|
430
|
+
if (data === null) return true;
|
|
431
|
+
|
|
432
|
+
var max = data.length;
|
|
433
|
+
|
|
434
|
+
return (max === 1 && data === '~') ||
|
|
435
|
+
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function constructYamlNull() {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function isNull(object) {
|
|
443
|
+
return object === null;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
var _null = new type('tag:yaml.org,2002:null', {
|
|
447
|
+
kind: 'scalar',
|
|
448
|
+
resolve: resolveYamlNull,
|
|
449
|
+
construct: constructYamlNull,
|
|
450
|
+
predicate: isNull,
|
|
451
|
+
represent: {
|
|
452
|
+
canonical: function () { return '~'; },
|
|
453
|
+
lowercase: function () { return 'null'; },
|
|
454
|
+
uppercase: function () { return 'NULL'; },
|
|
455
|
+
camelcase: function () { return 'Null'; },
|
|
456
|
+
empty: function () { return ''; }
|
|
457
|
+
},
|
|
458
|
+
defaultStyle: 'lowercase'
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
function resolveYamlBoolean(data) {
|
|
462
|
+
if (data === null) return false;
|
|
463
|
+
|
|
464
|
+
var max = data.length;
|
|
465
|
+
|
|
466
|
+
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
|
|
467
|
+
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function constructYamlBoolean(data) {
|
|
471
|
+
return data === 'true' ||
|
|
472
|
+
data === 'True' ||
|
|
473
|
+
data === 'TRUE';
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function isBoolean(object) {
|
|
477
|
+
return Object.prototype.toString.call(object) === '[object Boolean]';
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
var bool = new type('tag:yaml.org,2002:bool', {
|
|
481
|
+
kind: 'scalar',
|
|
482
|
+
resolve: resolveYamlBoolean,
|
|
483
|
+
construct: constructYamlBoolean,
|
|
484
|
+
predicate: isBoolean,
|
|
485
|
+
represent: {
|
|
486
|
+
lowercase: function (object) { return object ? 'true' : 'false'; },
|
|
487
|
+
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
|
|
488
|
+
camelcase: function (object) { return object ? 'True' : 'False'; }
|
|
489
|
+
},
|
|
490
|
+
defaultStyle: 'lowercase'
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
function isHexCode(c) {
|
|
494
|
+
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
|
|
495
|
+
((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
|
|
496
|
+
((0x61/* a */ <= c) && (c <= 0x66/* f */));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function isOctCode(c) {
|
|
500
|
+
return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function isDecCode(c) {
|
|
504
|
+
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function resolveYamlInteger(data) {
|
|
508
|
+
if (data === null) return false;
|
|
509
|
+
|
|
510
|
+
var max = data.length,
|
|
511
|
+
index = 0,
|
|
512
|
+
hasDigits = false,
|
|
513
|
+
ch;
|
|
514
|
+
|
|
515
|
+
if (!max) return false;
|
|
516
|
+
|
|
517
|
+
ch = data[index];
|
|
518
|
+
|
|
519
|
+
// sign
|
|
520
|
+
if (ch === '-' || ch === '+') {
|
|
521
|
+
ch = data[++index];
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (ch === '0') {
|
|
525
|
+
// 0
|
|
526
|
+
if (index + 1 === max) return true;
|
|
527
|
+
ch = data[++index];
|
|
528
|
+
|
|
529
|
+
// base 2, base 8, base 16
|
|
530
|
+
|
|
531
|
+
if (ch === 'b') {
|
|
532
|
+
// base 2
|
|
533
|
+
index++;
|
|
534
|
+
|
|
535
|
+
for (; index < max; index++) {
|
|
536
|
+
ch = data[index];
|
|
537
|
+
if (ch === '_') continue;
|
|
538
|
+
if (ch !== '0' && ch !== '1') return false;
|
|
539
|
+
hasDigits = true;
|
|
540
|
+
}
|
|
541
|
+
return hasDigits && ch !== '_';
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
if (ch === 'x') {
|
|
546
|
+
// base 16
|
|
547
|
+
index++;
|
|
548
|
+
|
|
549
|
+
for (; index < max; index++) {
|
|
550
|
+
ch = data[index];
|
|
551
|
+
if (ch === '_') continue;
|
|
552
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
553
|
+
hasDigits = true;
|
|
554
|
+
}
|
|
555
|
+
return hasDigits && ch !== '_';
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
if (ch === 'o') {
|
|
560
|
+
// base 8
|
|
561
|
+
index++;
|
|
562
|
+
|
|
563
|
+
for (; index < max; index++) {
|
|
564
|
+
ch = data[index];
|
|
565
|
+
if (ch === '_') continue;
|
|
566
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
567
|
+
hasDigits = true;
|
|
568
|
+
}
|
|
569
|
+
return hasDigits && ch !== '_';
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// base 10 (except 0)
|
|
574
|
+
|
|
575
|
+
// value should not start with `_`;
|
|
576
|
+
if (ch === '_') return false;
|
|
577
|
+
|
|
578
|
+
for (; index < max; index++) {
|
|
579
|
+
ch = data[index];
|
|
580
|
+
if (ch === '_') continue;
|
|
581
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
hasDigits = true;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// Should have digits and should not end with `_`
|
|
588
|
+
if (!hasDigits || ch === '_') return false;
|
|
589
|
+
|
|
590
|
+
return true;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function constructYamlInteger(data) {
|
|
594
|
+
var value = data, sign = 1, ch;
|
|
595
|
+
|
|
596
|
+
if (value.indexOf('_') !== -1) {
|
|
597
|
+
value = value.replace(/_/g, '');
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
ch = value[0];
|
|
601
|
+
|
|
602
|
+
if (ch === '-' || ch === '+') {
|
|
603
|
+
if (ch === '-') sign = -1;
|
|
604
|
+
value = value.slice(1);
|
|
605
|
+
ch = value[0];
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (value === '0') return 0;
|
|
609
|
+
|
|
610
|
+
if (ch === '0') {
|
|
611
|
+
if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
|
|
612
|
+
if (value[1] === 'x') return sign * parseInt(value.slice(2), 16);
|
|
613
|
+
if (value[1] === 'o') return sign * parseInt(value.slice(2), 8);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return sign * parseInt(value, 10);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function isInteger(object) {
|
|
620
|
+
return (Object.prototype.toString.call(object)) === '[object Number]' &&
|
|
621
|
+
(object % 1 === 0 && !common.isNegativeZero(object));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
var int = new type('tag:yaml.org,2002:int', {
|
|
625
|
+
kind: 'scalar',
|
|
626
|
+
resolve: resolveYamlInteger,
|
|
627
|
+
construct: constructYamlInteger,
|
|
628
|
+
predicate: isInteger,
|
|
629
|
+
represent: {
|
|
630
|
+
binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
|
|
631
|
+
octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); },
|
|
632
|
+
decimal: function (obj) { return obj.toString(10); },
|
|
633
|
+
/* eslint-disable max-len */
|
|
634
|
+
hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
|
|
635
|
+
},
|
|
636
|
+
defaultStyle: 'decimal',
|
|
637
|
+
styleAliases: {
|
|
638
|
+
binary: [ 2, 'bin' ],
|
|
639
|
+
octal: [ 8, 'oct' ],
|
|
640
|
+
decimal: [ 10, 'dec' ],
|
|
641
|
+
hexadecimal: [ 16, 'hex' ]
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
646
|
+
// 2.5e4, 2.5 and integers
|
|
647
|
+
'^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
|
|
648
|
+
// .2e4, .2
|
|
649
|
+
// special case, seems not from spec
|
|
650
|
+
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
|
|
651
|
+
// .inf
|
|
652
|
+
'|[-+]?\\.(?:inf|Inf|INF)' +
|
|
653
|
+
// .nan
|
|
654
|
+
'|\\.(?:nan|NaN|NAN))$');
|
|
655
|
+
|
|
656
|
+
function resolveYamlFloat(data) {
|
|
657
|
+
if (data === null) return false;
|
|
658
|
+
|
|
659
|
+
if (!YAML_FLOAT_PATTERN.test(data) ||
|
|
660
|
+
// Quick hack to not allow integers end with `_`
|
|
661
|
+
// Probably should update regexp & check speed
|
|
662
|
+
data[data.length - 1] === '_') {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function constructYamlFloat(data) {
|
|
670
|
+
var value, sign;
|
|
671
|
+
|
|
672
|
+
value = data.replace(/_/g, '').toLowerCase();
|
|
673
|
+
sign = value[0] === '-' ? -1 : 1;
|
|
674
|
+
|
|
675
|
+
if ('+-'.indexOf(value[0]) >= 0) {
|
|
676
|
+
value = value.slice(1);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (value === '.inf') {
|
|
680
|
+
return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
681
|
+
|
|
682
|
+
} else if (value === '.nan') {
|
|
683
|
+
return NaN;
|
|
684
|
+
}
|
|
685
|
+
return sign * parseFloat(value, 10);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
690
|
+
|
|
691
|
+
function representYamlFloat(object, style) {
|
|
692
|
+
var res;
|
|
693
|
+
|
|
694
|
+
if (isNaN(object)) {
|
|
695
|
+
switch (style) {
|
|
696
|
+
case 'lowercase': return '.nan';
|
|
697
|
+
case 'uppercase': return '.NAN';
|
|
698
|
+
case 'camelcase': return '.NaN';
|
|
699
|
+
}
|
|
700
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
701
|
+
switch (style) {
|
|
702
|
+
case 'lowercase': return '.inf';
|
|
703
|
+
case 'uppercase': return '.INF';
|
|
704
|
+
case 'camelcase': return '.Inf';
|
|
705
|
+
}
|
|
706
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
707
|
+
switch (style) {
|
|
708
|
+
case 'lowercase': return '-.inf';
|
|
709
|
+
case 'uppercase': return '-.INF';
|
|
710
|
+
case 'camelcase': return '-.Inf';
|
|
711
|
+
}
|
|
712
|
+
} else if (common.isNegativeZero(object)) {
|
|
713
|
+
return '-0.0';
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
res = object.toString(10);
|
|
717
|
+
|
|
718
|
+
// JS stringifier can build scientific format without dots: 5e-100,
|
|
719
|
+
// while YAML requres dot: 5.e-100. Fix it with simple hack
|
|
720
|
+
|
|
721
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function isFloat(object) {
|
|
725
|
+
return (Object.prototype.toString.call(object) === '[object Number]') &&
|
|
726
|
+
(object % 1 !== 0 || common.isNegativeZero(object));
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
var float = new type('tag:yaml.org,2002:float', {
|
|
730
|
+
kind: 'scalar',
|
|
731
|
+
resolve: resolveYamlFloat,
|
|
732
|
+
construct: constructYamlFloat,
|
|
733
|
+
predicate: isFloat,
|
|
734
|
+
represent: representYamlFloat,
|
|
735
|
+
defaultStyle: 'lowercase'
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
var json = failsafe.extend({
|
|
739
|
+
implicit: [
|
|
740
|
+
_null,
|
|
741
|
+
bool,
|
|
742
|
+
int,
|
|
743
|
+
float
|
|
744
|
+
]
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
var core = json;
|
|
748
|
+
|
|
749
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
750
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
751
|
+
'-([0-9][0-9])' + // [2] month
|
|
752
|
+
'-([0-9][0-9])$'); // [3] day
|
|
753
|
+
|
|
754
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
755
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
756
|
+
'-([0-9][0-9]?)' + // [2] month
|
|
757
|
+
'-([0-9][0-9]?)' + // [3] day
|
|
758
|
+
'(?:[Tt]|[ \\t]+)' + // ...
|
|
759
|
+
'([0-9][0-9]?)' + // [4] hour
|
|
760
|
+
':([0-9][0-9])' + // [5] minute
|
|
761
|
+
':([0-9][0-9])' + // [6] second
|
|
762
|
+
'(?:\\.([0-9]*))?' + // [7] fraction
|
|
763
|
+
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
|
764
|
+
'(?::([0-9][0-9]))?))?$'); // [11] tz_minute
|
|
765
|
+
|
|
766
|
+
function resolveYamlTimestamp(data) {
|
|
767
|
+
if (data === null) return false;
|
|
768
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
769
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function constructYamlTimestamp(data) {
|
|
774
|
+
var match, year, month, day, hour, minute, second, fraction = 0,
|
|
775
|
+
delta = null, tz_hour, tz_minute, date;
|
|
776
|
+
|
|
777
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
778
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
779
|
+
|
|
780
|
+
if (match === null) throw new Error('Date resolve error');
|
|
781
|
+
|
|
782
|
+
// match: [1] year [2] month [3] day
|
|
783
|
+
|
|
784
|
+
year = +(match[1]);
|
|
785
|
+
month = +(match[2]) - 1; // JS month starts with 0
|
|
786
|
+
day = +(match[3]);
|
|
787
|
+
|
|
788
|
+
if (!match[4]) { // no hour
|
|
789
|
+
return new Date(Date.UTC(year, month, day));
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// match: [4] hour [5] minute [6] second [7] fraction
|
|
793
|
+
|
|
794
|
+
hour = +(match[4]);
|
|
795
|
+
minute = +(match[5]);
|
|
796
|
+
second = +(match[6]);
|
|
797
|
+
|
|
798
|
+
if (match[7]) {
|
|
799
|
+
fraction = match[7].slice(0, 3);
|
|
800
|
+
while (fraction.length < 3) { // milli-seconds
|
|
801
|
+
fraction += '0';
|
|
802
|
+
}
|
|
803
|
+
fraction = +fraction;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
|
807
|
+
|
|
808
|
+
if (match[9]) {
|
|
809
|
+
tz_hour = +(match[10]);
|
|
810
|
+
tz_minute = +(match[11] || 0);
|
|
811
|
+
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
|
812
|
+
if (match[9] === '-') delta = -delta;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
816
|
+
|
|
817
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
818
|
+
|
|
819
|
+
return date;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function representYamlTimestamp(object /*, style*/) {
|
|
823
|
+
return object.toISOString();
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
var timestamp = new type('tag:yaml.org,2002:timestamp', {
|
|
827
|
+
kind: 'scalar',
|
|
828
|
+
resolve: resolveYamlTimestamp,
|
|
829
|
+
construct: constructYamlTimestamp,
|
|
830
|
+
instanceOf: Date,
|
|
831
|
+
represent: representYamlTimestamp
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
function resolveYamlMerge(data) {
|
|
835
|
+
return data === '<<' || data === null;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
var merge = new type('tag:yaml.org,2002:merge', {
|
|
839
|
+
kind: 'scalar',
|
|
840
|
+
resolve: resolveYamlMerge
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
/*eslint-disable no-bitwise*/
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
|
850
|
+
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
function resolveYamlBinary(data) {
|
|
854
|
+
if (data === null) return false;
|
|
855
|
+
|
|
856
|
+
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
|
857
|
+
|
|
858
|
+
// Convert one by one.
|
|
859
|
+
for (idx = 0; idx < max; idx++) {
|
|
860
|
+
code = map.indexOf(data.charAt(idx));
|
|
861
|
+
|
|
862
|
+
// Skip CR/LF
|
|
863
|
+
if (code > 64) continue;
|
|
864
|
+
|
|
865
|
+
// Fail on illegal characters
|
|
866
|
+
if (code < 0) return false;
|
|
867
|
+
|
|
868
|
+
bitlen += 6;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// If there are any bits left, source was corrupted
|
|
872
|
+
return (bitlen % 8) === 0;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function constructYamlBinary(data) {
|
|
876
|
+
var idx, tailbits,
|
|
877
|
+
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
|
|
878
|
+
max = input.length,
|
|
879
|
+
map = BASE64_MAP,
|
|
880
|
+
bits = 0,
|
|
881
|
+
result = [];
|
|
882
|
+
|
|
883
|
+
// Collect by 6*4 bits (3 bytes)
|
|
884
|
+
|
|
885
|
+
for (idx = 0; idx < max; idx++) {
|
|
886
|
+
if ((idx % 4 === 0) && idx) {
|
|
887
|
+
result.push((bits >> 16) & 0xFF);
|
|
888
|
+
result.push((bits >> 8) & 0xFF);
|
|
889
|
+
result.push(bits & 0xFF);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// Dump tail
|
|
896
|
+
|
|
897
|
+
tailbits = (max % 4) * 6;
|
|
898
|
+
|
|
899
|
+
if (tailbits === 0) {
|
|
900
|
+
result.push((bits >> 16) & 0xFF);
|
|
901
|
+
result.push((bits >> 8) & 0xFF);
|
|
902
|
+
result.push(bits & 0xFF);
|
|
903
|
+
} else if (tailbits === 18) {
|
|
904
|
+
result.push((bits >> 10) & 0xFF);
|
|
905
|
+
result.push((bits >> 2) & 0xFF);
|
|
906
|
+
} else if (tailbits === 12) {
|
|
907
|
+
result.push((bits >> 4) & 0xFF);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
return new Uint8Array(result);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function representYamlBinary(object /*, style*/) {
|
|
914
|
+
var result = '', bits = 0, idx, tail,
|
|
915
|
+
max = object.length,
|
|
916
|
+
map = BASE64_MAP;
|
|
917
|
+
|
|
918
|
+
// Convert every three bytes to 4 ASCII characters.
|
|
919
|
+
|
|
920
|
+
for (idx = 0; idx < max; idx++) {
|
|
921
|
+
if ((idx % 3 === 0) && idx) {
|
|
922
|
+
result += map[(bits >> 18) & 0x3F];
|
|
923
|
+
result += map[(bits >> 12) & 0x3F];
|
|
924
|
+
result += map[(bits >> 6) & 0x3F];
|
|
925
|
+
result += map[bits & 0x3F];
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
bits = (bits << 8) + object[idx];
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// Dump tail
|
|
932
|
+
|
|
933
|
+
tail = max % 3;
|
|
934
|
+
|
|
935
|
+
if (tail === 0) {
|
|
936
|
+
result += map[(bits >> 18) & 0x3F];
|
|
937
|
+
result += map[(bits >> 12) & 0x3F];
|
|
938
|
+
result += map[(bits >> 6) & 0x3F];
|
|
939
|
+
result += map[bits & 0x3F];
|
|
940
|
+
} else if (tail === 2) {
|
|
941
|
+
result += map[(bits >> 10) & 0x3F];
|
|
942
|
+
result += map[(bits >> 4) & 0x3F];
|
|
943
|
+
result += map[(bits << 2) & 0x3F];
|
|
944
|
+
result += map[64];
|
|
945
|
+
} else if (tail === 1) {
|
|
946
|
+
result += map[(bits >> 2) & 0x3F];
|
|
947
|
+
result += map[(bits << 4) & 0x3F];
|
|
948
|
+
result += map[64];
|
|
949
|
+
result += map[64];
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
return result;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function isBinary(obj) {
|
|
956
|
+
return Object.prototype.toString.call(obj) === '[object Uint8Array]';
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
var binary = new type('tag:yaml.org,2002:binary', {
|
|
960
|
+
kind: 'scalar',
|
|
961
|
+
resolve: resolveYamlBinary,
|
|
962
|
+
construct: constructYamlBinary,
|
|
963
|
+
predicate: isBinary,
|
|
964
|
+
represent: representYamlBinary
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
968
|
+
var _toString$2 = Object.prototype.toString;
|
|
969
|
+
|
|
970
|
+
function resolveYamlOmap(data) {
|
|
971
|
+
if (data === null) return true;
|
|
972
|
+
|
|
973
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
|
|
974
|
+
object = data;
|
|
975
|
+
|
|
976
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
977
|
+
pair = object[index];
|
|
978
|
+
pairHasKey = false;
|
|
979
|
+
|
|
980
|
+
if (_toString$2.call(pair) !== '[object Object]') return false;
|
|
981
|
+
|
|
982
|
+
for (pairKey in pair) {
|
|
983
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
984
|
+
if (!pairHasKey) pairHasKey = true;
|
|
985
|
+
else return false;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
if (!pairHasKey) return false;
|
|
990
|
+
|
|
991
|
+
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
992
|
+
else return false;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
function constructYamlOmap(data) {
|
|
999
|
+
return data !== null ? data : [];
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
var omap = new type('tag:yaml.org,2002:omap', {
|
|
1003
|
+
kind: 'sequence',
|
|
1004
|
+
resolve: resolveYamlOmap,
|
|
1005
|
+
construct: constructYamlOmap
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
var _toString$1 = Object.prototype.toString;
|
|
1009
|
+
|
|
1010
|
+
function resolveYamlPairs(data) {
|
|
1011
|
+
if (data === null) return true;
|
|
1012
|
+
|
|
1013
|
+
var index, length, pair, keys, result,
|
|
1014
|
+
object = data;
|
|
1015
|
+
|
|
1016
|
+
result = new Array(object.length);
|
|
1017
|
+
|
|
1018
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1019
|
+
pair = object[index];
|
|
1020
|
+
|
|
1021
|
+
if (_toString$1.call(pair) !== '[object Object]') return false;
|
|
1022
|
+
|
|
1023
|
+
keys = Object.keys(pair);
|
|
1024
|
+
|
|
1025
|
+
if (keys.length !== 1) return false;
|
|
1026
|
+
|
|
1027
|
+
result[index] = [ keys[0], pair[keys[0]] ];
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
return true;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
function constructYamlPairs(data) {
|
|
1034
|
+
if (data === null) return [];
|
|
1035
|
+
|
|
1036
|
+
var index, length, pair, keys, result,
|
|
1037
|
+
object = data;
|
|
1038
|
+
|
|
1039
|
+
result = new Array(object.length);
|
|
1040
|
+
|
|
1041
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1042
|
+
pair = object[index];
|
|
1043
|
+
|
|
1044
|
+
keys = Object.keys(pair);
|
|
1045
|
+
|
|
1046
|
+
result[index] = [ keys[0], pair[keys[0]] ];
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
return result;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
var pairs = new type('tag:yaml.org,2002:pairs', {
|
|
1053
|
+
kind: 'sequence',
|
|
1054
|
+
resolve: resolveYamlPairs,
|
|
1055
|
+
construct: constructYamlPairs
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1059
|
+
|
|
1060
|
+
function resolveYamlSet(data) {
|
|
1061
|
+
if (data === null) return true;
|
|
1062
|
+
|
|
1063
|
+
var key, object = data;
|
|
1064
|
+
|
|
1065
|
+
for (key in object) {
|
|
1066
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
1067
|
+
if (object[key] !== null) return false;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
return true;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function constructYamlSet(data) {
|
|
1075
|
+
return data !== null ? data : {};
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
var set = new type('tag:yaml.org,2002:set', {
|
|
1079
|
+
kind: 'mapping',
|
|
1080
|
+
resolve: resolveYamlSet,
|
|
1081
|
+
construct: constructYamlSet
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
var _default = core.extend({
|
|
1085
|
+
implicit: [
|
|
1086
|
+
timestamp,
|
|
1087
|
+
merge
|
|
1088
|
+
],
|
|
1089
|
+
explicit: [
|
|
1090
|
+
binary,
|
|
1091
|
+
omap,
|
|
1092
|
+
pairs,
|
|
1093
|
+
set
|
|
1094
|
+
]
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
/*eslint-disable max-len,no-use-before-define*/
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1109
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1110
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1111
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
var CHOMPING_CLIP = 1;
|
|
1115
|
+
var CHOMPING_STRIP = 2;
|
|
1116
|
+
var CHOMPING_KEEP = 3;
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1120
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1121
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1122
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1123
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
function _class(obj) { return Object.prototype.toString.call(obj); }
|
|
1127
|
+
|
|
1128
|
+
function is_EOL(c) {
|
|
1129
|
+
return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function is_WHITE_SPACE(c) {
|
|
1133
|
+
return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
function is_WS_OR_EOL(c) {
|
|
1137
|
+
return (c === 0x09/* Tab */) ||
|
|
1138
|
+
(c === 0x20/* Space */) ||
|
|
1139
|
+
(c === 0x0A/* LF */) ||
|
|
1140
|
+
(c === 0x0D/* CR */);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
function is_FLOW_INDICATOR(c) {
|
|
1144
|
+
return c === 0x2C/* , */ ||
|
|
1145
|
+
c === 0x5B/* [ */ ||
|
|
1146
|
+
c === 0x5D/* ] */ ||
|
|
1147
|
+
c === 0x7B/* { */ ||
|
|
1148
|
+
c === 0x7D/* } */;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function fromHexCode(c) {
|
|
1152
|
+
var lc;
|
|
1153
|
+
|
|
1154
|
+
if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
|
|
1155
|
+
return c - 0x30;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/*eslint-disable no-bitwise*/
|
|
1159
|
+
lc = c | 0x20;
|
|
1160
|
+
|
|
1161
|
+
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
|
1162
|
+
return lc - 0x61 + 10;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
return -1;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function escapedHexLen(c) {
|
|
1169
|
+
if (c === 0x78/* x */) { return 2; }
|
|
1170
|
+
if (c === 0x75/* u */) { return 4; }
|
|
1171
|
+
if (c === 0x55/* U */) { return 8; }
|
|
1172
|
+
return 0;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
function fromDecimalCode(c) {
|
|
1176
|
+
if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
|
|
1177
|
+
return c - 0x30;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
return -1;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
function simpleEscapeSequence(c) {
|
|
1184
|
+
/* eslint-disable indent */
|
|
1185
|
+
return (c === 0x30/* 0 */) ? '\x00' :
|
|
1186
|
+
(c === 0x61/* a */) ? '\x07' :
|
|
1187
|
+
(c === 0x62/* b */) ? '\x08' :
|
|
1188
|
+
(c === 0x74/* t */) ? '\x09' :
|
|
1189
|
+
(c === 0x09/* Tab */) ? '\x09' :
|
|
1190
|
+
(c === 0x6E/* n */) ? '\x0A' :
|
|
1191
|
+
(c === 0x76/* v */) ? '\x0B' :
|
|
1192
|
+
(c === 0x66/* f */) ? '\x0C' :
|
|
1193
|
+
(c === 0x72/* r */) ? '\x0D' :
|
|
1194
|
+
(c === 0x65/* e */) ? '\x1B' :
|
|
1195
|
+
(c === 0x20/* Space */) ? ' ' :
|
|
1196
|
+
(c === 0x22/* " */) ? '\x22' :
|
|
1197
|
+
(c === 0x2F/* / */) ? '/' :
|
|
1198
|
+
(c === 0x5C/* \ */) ? '\x5C' :
|
|
1199
|
+
(c === 0x4E/* N */) ? '\x85' :
|
|
1200
|
+
(c === 0x5F/* _ */) ? '\xA0' :
|
|
1201
|
+
(c === 0x4C/* L */) ? '\u2028' :
|
|
1202
|
+
(c === 0x50/* P */) ? '\u2029' : '';
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
function charFromCodepoint(c) {
|
|
1206
|
+
if (c <= 0xFFFF) {
|
|
1207
|
+
return String.fromCharCode(c);
|
|
1208
|
+
}
|
|
1209
|
+
// Encode UTF-16 surrogate pair
|
|
1210
|
+
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
|
1211
|
+
return String.fromCharCode(
|
|
1212
|
+
((c - 0x010000) >> 10) + 0xD800,
|
|
1213
|
+
((c - 0x010000) & 0x03FF) + 0xDC00
|
|
1214
|
+
);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
var simpleEscapeCheck = new Array(256); // integer, for fast access
|
|
1218
|
+
var simpleEscapeMap = new Array(256);
|
|
1219
|
+
for (var i = 0; i < 256; i++) {
|
|
1220
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1221
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
function State$1(input, options) {
|
|
1226
|
+
this.input = input;
|
|
1227
|
+
|
|
1228
|
+
this.filename = options['filename'] || null;
|
|
1229
|
+
this.schema = options['schema'] || _default;
|
|
1230
|
+
this.onWarning = options['onWarning'] || null;
|
|
1231
|
+
// (Hidden) Remove? makes the loader to expect YAML 1.1 documents
|
|
1232
|
+
// if such documents have no explicit %YAML directive
|
|
1233
|
+
this.legacy = options['legacy'] || false;
|
|
1234
|
+
|
|
1235
|
+
this.json = options['json'] || false;
|
|
1236
|
+
this.listener = options['listener'] || null;
|
|
1237
|
+
|
|
1238
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1239
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1240
|
+
|
|
1241
|
+
this.length = input.length;
|
|
1242
|
+
this.position = 0;
|
|
1243
|
+
this.line = 0;
|
|
1244
|
+
this.lineStart = 0;
|
|
1245
|
+
this.lineIndent = 0;
|
|
1246
|
+
|
|
1247
|
+
// position of first leading tab in the current line,
|
|
1248
|
+
// used to make sure there are no tabs in the indentation
|
|
1249
|
+
this.firstTabInLine = -1;
|
|
1250
|
+
|
|
1251
|
+
this.documents = [];
|
|
1252
|
+
|
|
1253
|
+
/*
|
|
1254
|
+
this.version;
|
|
1255
|
+
this.checkLineBreaks;
|
|
1256
|
+
this.tagMap;
|
|
1257
|
+
this.anchorMap;
|
|
1258
|
+
this.tag;
|
|
1259
|
+
this.anchor;
|
|
1260
|
+
this.kind;
|
|
1261
|
+
this.result;*/
|
|
1262
|
+
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
function generateError(state, message) {
|
|
1267
|
+
var mark = {
|
|
1268
|
+
name: state.filename,
|
|
1269
|
+
buffer: state.input.slice(0, -1), // omit trailing \0
|
|
1270
|
+
position: state.position,
|
|
1271
|
+
line: state.line,
|
|
1272
|
+
column: state.position - state.lineStart
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
mark.snippet = snippet(mark);
|
|
1276
|
+
|
|
1277
|
+
return new exception(message, mark);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
function throwError(state, message) {
|
|
1281
|
+
throw generateError(state, message);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function throwWarning(state, message) {
|
|
1285
|
+
if (state.onWarning) {
|
|
1286
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
var directiveHandlers = {
|
|
1292
|
+
|
|
1293
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
1294
|
+
|
|
1295
|
+
var match, major, minor;
|
|
1296
|
+
|
|
1297
|
+
if (state.version !== null) {
|
|
1298
|
+
throwError(state, 'duplication of %YAML directive');
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
if (args.length !== 1) {
|
|
1302
|
+
throwError(state, 'YAML directive accepts exactly one argument');
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1306
|
+
|
|
1307
|
+
if (match === null) {
|
|
1308
|
+
throwError(state, 'ill-formed argument of the YAML directive');
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
major = parseInt(match[1], 10);
|
|
1312
|
+
minor = parseInt(match[2], 10);
|
|
1313
|
+
|
|
1314
|
+
if (major !== 1) {
|
|
1315
|
+
throwError(state, 'unacceptable YAML version of the document');
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
state.version = args[0];
|
|
1319
|
+
state.checkLineBreaks = (minor < 2);
|
|
1320
|
+
|
|
1321
|
+
if (minor !== 1 && minor !== 2) {
|
|
1322
|
+
throwWarning(state, 'unsupported YAML version of the document');
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
|
|
1326
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
1327
|
+
|
|
1328
|
+
var handle, prefix;
|
|
1329
|
+
|
|
1330
|
+
if (args.length !== 2) {
|
|
1331
|
+
throwError(state, 'TAG directive accepts exactly two arguments');
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
handle = args[0];
|
|
1335
|
+
prefix = args[1];
|
|
1336
|
+
|
|
1337
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1338
|
+
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1342
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1346
|
+
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
try {
|
|
1350
|
+
prefix = decodeURIComponent(prefix);
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
throwError(state, 'tag prefix is malformed: ' + prefix);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
state.tagMap[handle] = prefix;
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1361
|
+
var _position, _length, _character, _result;
|
|
1362
|
+
|
|
1363
|
+
if (start < end) {
|
|
1364
|
+
_result = state.input.slice(start, end);
|
|
1365
|
+
|
|
1366
|
+
if (checkJson) {
|
|
1367
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1368
|
+
_character = _result.charCodeAt(_position);
|
|
1369
|
+
if (!(_character === 0x09 ||
|
|
1370
|
+
(0x20 <= _character && _character <= 0x10FFFF))) {
|
|
1371
|
+
throwError(state, 'expected valid JSON character');
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1375
|
+
throwError(state, 'the stream contains non-printable characters');
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
state.result += _result;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1383
|
+
var sourceKeys, key, index, quantity;
|
|
1384
|
+
|
|
1385
|
+
if (!common.isObject(source)) {
|
|
1386
|
+
throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
sourceKeys = Object.keys(source);
|
|
1390
|
+
|
|
1391
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1392
|
+
key = sourceKeys[index];
|
|
1393
|
+
|
|
1394
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1395
|
+
destination[key] = source[key];
|
|
1396
|
+
overridableKeys[key] = true;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode,
|
|
1402
|
+
startLine, startLineStart, startPos) {
|
|
1403
|
+
|
|
1404
|
+
var index, quantity;
|
|
1405
|
+
|
|
1406
|
+
// The output is a plain object here, so keys can only be strings.
|
|
1407
|
+
// We need to convert keyNode to a string, but doing so can hang the process
|
|
1408
|
+
// (deeply nested arrays that explode exponentially using aliases).
|
|
1409
|
+
if (Array.isArray(keyNode)) {
|
|
1410
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1411
|
+
|
|
1412
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1413
|
+
if (Array.isArray(keyNode[index])) {
|
|
1414
|
+
throwError(state, 'nested arrays are not supported inside keys');
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
|
|
1418
|
+
keyNode[index] = '[object Object]';
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
// Avoid code execution in load() via toString property
|
|
1424
|
+
// (still use its own toString for arrays, timestamps,
|
|
1425
|
+
// and whatever user schema extensions happen to have @@toStringTag)
|
|
1426
|
+
if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
|
|
1427
|
+
keyNode = '[object Object]';
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
keyNode = String(keyNode);
|
|
1432
|
+
|
|
1433
|
+
if (_result === null) {
|
|
1434
|
+
_result = {};
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
if (keyTag === 'tag:yaml.org,2002:merge') {
|
|
1438
|
+
if (Array.isArray(valueNode)) {
|
|
1439
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1440
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1443
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1444
|
+
}
|
|
1445
|
+
} else {
|
|
1446
|
+
if (!state.json &&
|
|
1447
|
+
!_hasOwnProperty$1.call(overridableKeys, keyNode) &&
|
|
1448
|
+
_hasOwnProperty$1.call(_result, keyNode)) {
|
|
1449
|
+
state.line = startLine || state.line;
|
|
1450
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1451
|
+
state.position = startPos || state.position;
|
|
1452
|
+
throwError(state, 'duplicated mapping key');
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
// used for this specific key only because Object.defineProperty is slow
|
|
1456
|
+
if (keyNode === '__proto__') {
|
|
1457
|
+
Object.defineProperty(_result, keyNode, {
|
|
1458
|
+
configurable: true,
|
|
1459
|
+
enumerable: true,
|
|
1460
|
+
writable: true,
|
|
1461
|
+
value: valueNode
|
|
1462
|
+
});
|
|
1463
|
+
} else {
|
|
1464
|
+
_result[keyNode] = valueNode;
|
|
1465
|
+
}
|
|
1466
|
+
delete overridableKeys[keyNode];
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
return _result;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function readLineBreak(state) {
|
|
1473
|
+
var ch;
|
|
1474
|
+
|
|
1475
|
+
ch = state.input.charCodeAt(state.position);
|
|
1476
|
+
|
|
1477
|
+
if (ch === 0x0A/* LF */) {
|
|
1478
|
+
state.position++;
|
|
1479
|
+
} else if (ch === 0x0D/* CR */) {
|
|
1480
|
+
state.position++;
|
|
1481
|
+
if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
|
|
1482
|
+
state.position++;
|
|
1483
|
+
}
|
|
1484
|
+
} else {
|
|
1485
|
+
throwError(state, 'a line break is expected');
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
state.line += 1;
|
|
1489
|
+
state.lineStart = state.position;
|
|
1490
|
+
state.firstTabInLine = -1;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1494
|
+
var lineBreaks = 0,
|
|
1495
|
+
ch = state.input.charCodeAt(state.position);
|
|
1496
|
+
|
|
1497
|
+
while (ch !== 0) {
|
|
1498
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1499
|
+
if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) {
|
|
1500
|
+
state.firstTabInLine = state.position;
|
|
1501
|
+
}
|
|
1502
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
if (allowComments && ch === 0x23/* # */) {
|
|
1506
|
+
do {
|
|
1507
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1508
|
+
} while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
if (is_EOL(ch)) {
|
|
1512
|
+
readLineBreak(state);
|
|
1513
|
+
|
|
1514
|
+
ch = state.input.charCodeAt(state.position);
|
|
1515
|
+
lineBreaks++;
|
|
1516
|
+
state.lineIndent = 0;
|
|
1517
|
+
|
|
1518
|
+
while (ch === 0x20/* Space */) {
|
|
1519
|
+
state.lineIndent++;
|
|
1520
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1521
|
+
}
|
|
1522
|
+
} else {
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1528
|
+
throwWarning(state, 'deficient indentation');
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
return lineBreaks;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
function testDocumentSeparator(state) {
|
|
1535
|
+
var _position = state.position,
|
|
1536
|
+
ch;
|
|
1537
|
+
|
|
1538
|
+
ch = state.input.charCodeAt(_position);
|
|
1539
|
+
|
|
1540
|
+
// Condition state.position === state.lineStart is tested
|
|
1541
|
+
// in parent on each call, for efficiency. No needs to test here again.
|
|
1542
|
+
if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
|
|
1543
|
+
ch === state.input.charCodeAt(_position + 1) &&
|
|
1544
|
+
ch === state.input.charCodeAt(_position + 2)) {
|
|
1545
|
+
|
|
1546
|
+
_position += 3;
|
|
1547
|
+
|
|
1548
|
+
ch = state.input.charCodeAt(_position);
|
|
1549
|
+
|
|
1550
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1551
|
+
return true;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
return false;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
function writeFoldedLines(state, count) {
|
|
1559
|
+
if (count === 1) {
|
|
1560
|
+
state.result += ' ';
|
|
1561
|
+
} else if (count > 1) {
|
|
1562
|
+
state.result += common.repeat('\n', count - 1);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1568
|
+
var preceding,
|
|
1569
|
+
following,
|
|
1570
|
+
captureStart,
|
|
1571
|
+
captureEnd,
|
|
1572
|
+
hasPendingContent,
|
|
1573
|
+
_line,
|
|
1574
|
+
_lineStart,
|
|
1575
|
+
_lineIndent,
|
|
1576
|
+
_kind = state.kind,
|
|
1577
|
+
_result = state.result,
|
|
1578
|
+
ch;
|
|
1579
|
+
|
|
1580
|
+
ch = state.input.charCodeAt(state.position);
|
|
1581
|
+
|
|
1582
|
+
if (is_WS_OR_EOL(ch) ||
|
|
1583
|
+
is_FLOW_INDICATOR(ch) ||
|
|
1584
|
+
ch === 0x23/* # */ ||
|
|
1585
|
+
ch === 0x26/* & */ ||
|
|
1586
|
+
ch === 0x2A/* * */ ||
|
|
1587
|
+
ch === 0x21/* ! */ ||
|
|
1588
|
+
ch === 0x7C/* | */ ||
|
|
1589
|
+
ch === 0x3E/* > */ ||
|
|
1590
|
+
ch === 0x27/* ' */ ||
|
|
1591
|
+
ch === 0x22/* " */ ||
|
|
1592
|
+
ch === 0x25/* % */ ||
|
|
1593
|
+
ch === 0x40/* @ */ ||
|
|
1594
|
+
ch === 0x60/* ` */) {
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
|
|
1599
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1600
|
+
|
|
1601
|
+
if (is_WS_OR_EOL(following) ||
|
|
1602
|
+
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
state.kind = 'scalar';
|
|
1608
|
+
state.result = '';
|
|
1609
|
+
captureStart = captureEnd = state.position;
|
|
1610
|
+
hasPendingContent = false;
|
|
1611
|
+
|
|
1612
|
+
while (ch !== 0) {
|
|
1613
|
+
if (ch === 0x3A/* : */) {
|
|
1614
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1615
|
+
|
|
1616
|
+
if (is_WS_OR_EOL(following) ||
|
|
1617
|
+
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
} else if (ch === 0x23/* # */) {
|
|
1622
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1623
|
+
|
|
1624
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
} else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
|
|
1629
|
+
withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1630
|
+
break;
|
|
1631
|
+
|
|
1632
|
+
} else if (is_EOL(ch)) {
|
|
1633
|
+
_line = state.line;
|
|
1634
|
+
_lineStart = state.lineStart;
|
|
1635
|
+
_lineIndent = state.lineIndent;
|
|
1636
|
+
skipSeparationSpace(state, false, -1);
|
|
1637
|
+
|
|
1638
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1639
|
+
hasPendingContent = true;
|
|
1640
|
+
ch = state.input.charCodeAt(state.position);
|
|
1641
|
+
continue;
|
|
1642
|
+
} else {
|
|
1643
|
+
state.position = captureEnd;
|
|
1644
|
+
state.line = _line;
|
|
1645
|
+
state.lineStart = _lineStart;
|
|
1646
|
+
state.lineIndent = _lineIndent;
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
if (hasPendingContent) {
|
|
1652
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1653
|
+
writeFoldedLines(state, state.line - _line);
|
|
1654
|
+
captureStart = captureEnd = state.position;
|
|
1655
|
+
hasPendingContent = false;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1659
|
+
captureEnd = state.position + 1;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1666
|
+
|
|
1667
|
+
if (state.result) {
|
|
1668
|
+
return true;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
state.kind = _kind;
|
|
1672
|
+
state.result = _result;
|
|
1673
|
+
return false;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1677
|
+
var ch,
|
|
1678
|
+
captureStart, captureEnd;
|
|
1679
|
+
|
|
1680
|
+
ch = state.input.charCodeAt(state.position);
|
|
1681
|
+
|
|
1682
|
+
if (ch !== 0x27/* ' */) {
|
|
1683
|
+
return false;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
state.kind = 'scalar';
|
|
1687
|
+
state.result = '';
|
|
1688
|
+
state.position++;
|
|
1689
|
+
captureStart = captureEnd = state.position;
|
|
1690
|
+
|
|
1691
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1692
|
+
if (ch === 0x27/* ' */) {
|
|
1693
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1694
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1695
|
+
|
|
1696
|
+
if (ch === 0x27/* ' */) {
|
|
1697
|
+
captureStart = state.position;
|
|
1698
|
+
state.position++;
|
|
1699
|
+
captureEnd = state.position;
|
|
1700
|
+
} else {
|
|
1701
|
+
return true;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
} else if (is_EOL(ch)) {
|
|
1705
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1706
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1707
|
+
captureStart = captureEnd = state.position;
|
|
1708
|
+
|
|
1709
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1710
|
+
throwError(state, 'unexpected end of the document within a single quoted scalar');
|
|
1711
|
+
|
|
1712
|
+
} else {
|
|
1713
|
+
state.position++;
|
|
1714
|
+
captureEnd = state.position;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
throwError(state, 'unexpected end of the stream within a single quoted scalar');
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1722
|
+
var captureStart,
|
|
1723
|
+
captureEnd,
|
|
1724
|
+
hexLength,
|
|
1725
|
+
hexResult,
|
|
1726
|
+
tmp,
|
|
1727
|
+
ch;
|
|
1728
|
+
|
|
1729
|
+
ch = state.input.charCodeAt(state.position);
|
|
1730
|
+
|
|
1731
|
+
if (ch !== 0x22/* " */) {
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
state.kind = 'scalar';
|
|
1736
|
+
state.result = '';
|
|
1737
|
+
state.position++;
|
|
1738
|
+
captureStart = captureEnd = state.position;
|
|
1739
|
+
|
|
1740
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1741
|
+
if (ch === 0x22/* " */) {
|
|
1742
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1743
|
+
state.position++;
|
|
1744
|
+
return true;
|
|
1745
|
+
|
|
1746
|
+
} else if (ch === 0x5C/* \ */) {
|
|
1747
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1748
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1749
|
+
|
|
1750
|
+
if (is_EOL(ch)) {
|
|
1751
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1752
|
+
|
|
1753
|
+
// TODO: rework to inline fn with no type cast?
|
|
1754
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1755
|
+
state.result += simpleEscapeMap[ch];
|
|
1756
|
+
state.position++;
|
|
1757
|
+
|
|
1758
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1759
|
+
hexLength = tmp;
|
|
1760
|
+
hexResult = 0;
|
|
1761
|
+
|
|
1762
|
+
for (; hexLength > 0; hexLength--) {
|
|
1763
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1764
|
+
|
|
1765
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1766
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1767
|
+
|
|
1768
|
+
} else {
|
|
1769
|
+
throwError(state, 'expected hexadecimal character');
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
state.result += charFromCodepoint(hexResult);
|
|
1774
|
+
|
|
1775
|
+
state.position++;
|
|
1776
|
+
|
|
1777
|
+
} else {
|
|
1778
|
+
throwError(state, 'unknown escape sequence');
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
captureStart = captureEnd = state.position;
|
|
1782
|
+
|
|
1783
|
+
} else if (is_EOL(ch)) {
|
|
1784
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1785
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1786
|
+
captureStart = captureEnd = state.position;
|
|
1787
|
+
|
|
1788
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1789
|
+
throwError(state, 'unexpected end of the document within a double quoted scalar');
|
|
1790
|
+
|
|
1791
|
+
} else {
|
|
1792
|
+
state.position++;
|
|
1793
|
+
captureEnd = state.position;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
throwError(state, 'unexpected end of the stream within a double quoted scalar');
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1801
|
+
var readNext = true,
|
|
1802
|
+
_line,
|
|
1803
|
+
_lineStart,
|
|
1804
|
+
_pos,
|
|
1805
|
+
_tag = state.tag,
|
|
1806
|
+
_result,
|
|
1807
|
+
_anchor = state.anchor,
|
|
1808
|
+
following,
|
|
1809
|
+
terminator,
|
|
1810
|
+
isPair,
|
|
1811
|
+
isExplicitPair,
|
|
1812
|
+
isMapping,
|
|
1813
|
+
overridableKeys = Object.create(null),
|
|
1814
|
+
keyNode,
|
|
1815
|
+
keyTag,
|
|
1816
|
+
valueNode,
|
|
1817
|
+
ch;
|
|
1818
|
+
|
|
1819
|
+
ch = state.input.charCodeAt(state.position);
|
|
1820
|
+
|
|
1821
|
+
if (ch === 0x5B/* [ */) {
|
|
1822
|
+
terminator = 0x5D;/* ] */
|
|
1823
|
+
isMapping = false;
|
|
1824
|
+
_result = [];
|
|
1825
|
+
} else if (ch === 0x7B/* { */) {
|
|
1826
|
+
terminator = 0x7D;/* } */
|
|
1827
|
+
isMapping = true;
|
|
1828
|
+
_result = {};
|
|
1829
|
+
} else {
|
|
1830
|
+
return false;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
if (state.anchor !== null) {
|
|
1834
|
+
state.anchorMap[state.anchor] = _result;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1838
|
+
|
|
1839
|
+
while (ch !== 0) {
|
|
1840
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1841
|
+
|
|
1842
|
+
ch = state.input.charCodeAt(state.position);
|
|
1843
|
+
|
|
1844
|
+
if (ch === terminator) {
|
|
1845
|
+
state.position++;
|
|
1846
|
+
state.tag = _tag;
|
|
1847
|
+
state.anchor = _anchor;
|
|
1848
|
+
state.kind = isMapping ? 'mapping' : 'sequence';
|
|
1849
|
+
state.result = _result;
|
|
1850
|
+
return true;
|
|
1851
|
+
} else if (!readNext) {
|
|
1852
|
+
throwError(state, 'missed comma between flow collection entries');
|
|
1853
|
+
} else if (ch === 0x2C/* , */) {
|
|
1854
|
+
// "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
|
|
1855
|
+
throwError(state, "expected the node content, but found ','");
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
keyTag = keyNode = valueNode = null;
|
|
1859
|
+
isPair = isExplicitPair = false;
|
|
1860
|
+
|
|
1861
|
+
if (ch === 0x3F/* ? */) {
|
|
1862
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1863
|
+
|
|
1864
|
+
if (is_WS_OR_EOL(following)) {
|
|
1865
|
+
isPair = isExplicitPair = true;
|
|
1866
|
+
state.position++;
|
|
1867
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
_line = state.line; // Save the current line.
|
|
1872
|
+
_lineStart = state.lineStart;
|
|
1873
|
+
_pos = state.position;
|
|
1874
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1875
|
+
keyTag = state.tag;
|
|
1876
|
+
keyNode = state.result;
|
|
1877
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1878
|
+
|
|
1879
|
+
ch = state.input.charCodeAt(state.position);
|
|
1880
|
+
|
|
1881
|
+
if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
|
|
1882
|
+
isPair = true;
|
|
1883
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1884
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1885
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1886
|
+
valueNode = state.result;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
if (isMapping) {
|
|
1890
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1891
|
+
} else if (isPair) {
|
|
1892
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1893
|
+
} else {
|
|
1894
|
+
_result.push(keyNode);
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1898
|
+
|
|
1899
|
+
ch = state.input.charCodeAt(state.position);
|
|
1900
|
+
|
|
1901
|
+
if (ch === 0x2C/* , */) {
|
|
1902
|
+
readNext = true;
|
|
1903
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1904
|
+
} else {
|
|
1905
|
+
readNext = false;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
throwError(state, 'unexpected end of the stream within a flow collection');
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1913
|
+
var captureStart,
|
|
1914
|
+
folding,
|
|
1915
|
+
chomping = CHOMPING_CLIP,
|
|
1916
|
+
didReadContent = false,
|
|
1917
|
+
detectedIndent = false,
|
|
1918
|
+
textIndent = nodeIndent,
|
|
1919
|
+
emptyLines = 0,
|
|
1920
|
+
atMoreIndented = false,
|
|
1921
|
+
tmp,
|
|
1922
|
+
ch;
|
|
1923
|
+
|
|
1924
|
+
ch = state.input.charCodeAt(state.position);
|
|
1925
|
+
|
|
1926
|
+
if (ch === 0x7C/* | */) {
|
|
1927
|
+
folding = false;
|
|
1928
|
+
} else if (ch === 0x3E/* > */) {
|
|
1929
|
+
folding = true;
|
|
1930
|
+
} else {
|
|
1931
|
+
return false;
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
state.kind = 'scalar';
|
|
1935
|
+
state.result = '';
|
|
1936
|
+
|
|
1937
|
+
while (ch !== 0) {
|
|
1938
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1939
|
+
|
|
1940
|
+
if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
|
|
1941
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1942
|
+
chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1943
|
+
} else {
|
|
1944
|
+
throwError(state, 'repeat of a chomping mode identifier');
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1948
|
+
if (tmp === 0) {
|
|
1949
|
+
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
|
|
1950
|
+
} else if (!detectedIndent) {
|
|
1951
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1952
|
+
detectedIndent = true;
|
|
1953
|
+
} else {
|
|
1954
|
+
throwError(state, 'repeat of an indentation width identifier');
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
} else {
|
|
1958
|
+
break;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1963
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
|
1964
|
+
while (is_WHITE_SPACE(ch));
|
|
1965
|
+
|
|
1966
|
+
if (ch === 0x23/* # */) {
|
|
1967
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
|
1968
|
+
while (!is_EOL(ch) && (ch !== 0));
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
while (ch !== 0) {
|
|
1973
|
+
readLineBreak(state);
|
|
1974
|
+
state.lineIndent = 0;
|
|
1975
|
+
|
|
1976
|
+
ch = state.input.charCodeAt(state.position);
|
|
1977
|
+
|
|
1978
|
+
while ((!detectedIndent || state.lineIndent < textIndent) &&
|
|
1979
|
+
(ch === 0x20/* Space */)) {
|
|
1980
|
+
state.lineIndent++;
|
|
1981
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1985
|
+
textIndent = state.lineIndent;
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
if (is_EOL(ch)) {
|
|
1989
|
+
emptyLines++;
|
|
1990
|
+
continue;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
// End of the scalar.
|
|
1994
|
+
if (state.lineIndent < textIndent) {
|
|
1995
|
+
|
|
1996
|
+
// Perform the chomping.
|
|
1997
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1998
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
|
1999
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
2000
|
+
if (didReadContent) { // i.e. only if the scalar is not empty.
|
|
2001
|
+
state.result += '\n';
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
// Break this `while` cycle and go to the funciton's epilogue.
|
|
2006
|
+
break;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
// Folded style: use fancy rules to handle line breaks.
|
|
2010
|
+
if (folding) {
|
|
2011
|
+
|
|
2012
|
+
// Lines starting with white space characters (more-indented lines) are not folded.
|
|
2013
|
+
if (is_WHITE_SPACE(ch)) {
|
|
2014
|
+
atMoreIndented = true;
|
|
2015
|
+
// except for the first content line (cf. Example 8.1)
|
|
2016
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
|
2017
|
+
|
|
2018
|
+
// End of more-indented block.
|
|
2019
|
+
} else if (atMoreIndented) {
|
|
2020
|
+
atMoreIndented = false;
|
|
2021
|
+
state.result += common.repeat('\n', emptyLines + 1);
|
|
2022
|
+
|
|
2023
|
+
// Just one line break - perceive as the same line.
|
|
2024
|
+
} else if (emptyLines === 0) {
|
|
2025
|
+
if (didReadContent) { // i.e. only if we have already read some scalar content.
|
|
2026
|
+
state.result += ' ';
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
// Several line breaks - perceive as different lines.
|
|
2030
|
+
} else {
|
|
2031
|
+
state.result += common.repeat('\n', emptyLines);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
// Literal style: just add exact number of line breaks between content lines.
|
|
2035
|
+
} else {
|
|
2036
|
+
// Keep all line breaks except the header line break.
|
|
2037
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
didReadContent = true;
|
|
2041
|
+
detectedIndent = true;
|
|
2042
|
+
emptyLines = 0;
|
|
2043
|
+
captureStart = state.position;
|
|
2044
|
+
|
|
2045
|
+
while (!is_EOL(ch) && (ch !== 0)) {
|
|
2046
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
captureSegment(state, captureStart, state.position, false);
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
return true;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
function readBlockSequence(state, nodeIndent) {
|
|
2056
|
+
var _line,
|
|
2057
|
+
_tag = state.tag,
|
|
2058
|
+
_anchor = state.anchor,
|
|
2059
|
+
_result = [],
|
|
2060
|
+
following,
|
|
2061
|
+
detected = false,
|
|
2062
|
+
ch;
|
|
2063
|
+
|
|
2064
|
+
// there is a leading tab before this token, so it can't be a block sequence/mapping;
|
|
2065
|
+
// it can still be flow sequence/mapping or a scalar
|
|
2066
|
+
if (state.firstTabInLine !== -1) return false;
|
|
2067
|
+
|
|
2068
|
+
if (state.anchor !== null) {
|
|
2069
|
+
state.anchorMap[state.anchor] = _result;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
ch = state.input.charCodeAt(state.position);
|
|
2073
|
+
|
|
2074
|
+
while (ch !== 0) {
|
|
2075
|
+
if (state.firstTabInLine !== -1) {
|
|
2076
|
+
state.position = state.firstTabInLine;
|
|
2077
|
+
throwError(state, 'tab characters must not be used in indentation');
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
if (ch !== 0x2D/* - */) {
|
|
2081
|
+
break;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
2085
|
+
|
|
2086
|
+
if (!is_WS_OR_EOL(following)) {
|
|
2087
|
+
break;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
detected = true;
|
|
2091
|
+
state.position++;
|
|
2092
|
+
|
|
2093
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2094
|
+
if (state.lineIndent <= nodeIndent) {
|
|
2095
|
+
_result.push(null);
|
|
2096
|
+
ch = state.input.charCodeAt(state.position);
|
|
2097
|
+
continue;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
_line = state.line;
|
|
2102
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
2103
|
+
_result.push(state.result);
|
|
2104
|
+
skipSeparationSpace(state, true, -1);
|
|
2105
|
+
|
|
2106
|
+
ch = state.input.charCodeAt(state.position);
|
|
2107
|
+
|
|
2108
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
|
|
2109
|
+
throwError(state, 'bad indentation of a sequence entry');
|
|
2110
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
2111
|
+
break;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
if (detected) {
|
|
2116
|
+
state.tag = _tag;
|
|
2117
|
+
state.anchor = _anchor;
|
|
2118
|
+
state.kind = 'sequence';
|
|
2119
|
+
state.result = _result;
|
|
2120
|
+
return true;
|
|
2121
|
+
}
|
|
2122
|
+
return false;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
2126
|
+
var following,
|
|
2127
|
+
allowCompact,
|
|
2128
|
+
_line,
|
|
2129
|
+
_keyLine,
|
|
2130
|
+
_keyLineStart,
|
|
2131
|
+
_keyPos,
|
|
2132
|
+
_tag = state.tag,
|
|
2133
|
+
_anchor = state.anchor,
|
|
2134
|
+
_result = {},
|
|
2135
|
+
overridableKeys = Object.create(null),
|
|
2136
|
+
keyTag = null,
|
|
2137
|
+
keyNode = null,
|
|
2138
|
+
valueNode = null,
|
|
2139
|
+
atExplicitKey = false,
|
|
2140
|
+
detected = false,
|
|
2141
|
+
ch;
|
|
2142
|
+
|
|
2143
|
+
// there is a leading tab before this token, so it can't be a block sequence/mapping;
|
|
2144
|
+
// it can still be flow sequence/mapping or a scalar
|
|
2145
|
+
if (state.firstTabInLine !== -1) return false;
|
|
2146
|
+
|
|
2147
|
+
if (state.anchor !== null) {
|
|
2148
|
+
state.anchorMap[state.anchor] = _result;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
ch = state.input.charCodeAt(state.position);
|
|
2152
|
+
|
|
2153
|
+
while (ch !== 0) {
|
|
2154
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
2155
|
+
state.position = state.firstTabInLine;
|
|
2156
|
+
throwError(state, 'tab characters must not be used in indentation');
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
2160
|
+
_line = state.line; // Save the current line.
|
|
2161
|
+
|
|
2162
|
+
//
|
|
2163
|
+
// Explicit notation case. There are two separate blocks:
|
|
2164
|
+
// first for the key (denoted by "?") and second for the value (denoted by ":")
|
|
2165
|
+
//
|
|
2166
|
+
if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
|
|
2167
|
+
|
|
2168
|
+
if (ch === 0x3F/* ? */) {
|
|
2169
|
+
if (atExplicitKey) {
|
|
2170
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2171
|
+
keyTag = keyNode = valueNode = null;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
detected = true;
|
|
2175
|
+
atExplicitKey = true;
|
|
2176
|
+
allowCompact = true;
|
|
2177
|
+
|
|
2178
|
+
} else if (atExplicitKey) {
|
|
2179
|
+
// i.e. 0x3A/* : */ === character after the explicit key.
|
|
2180
|
+
atExplicitKey = false;
|
|
2181
|
+
allowCompact = true;
|
|
2182
|
+
|
|
2183
|
+
} else {
|
|
2184
|
+
throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
state.position += 1;
|
|
2188
|
+
ch = following;
|
|
2189
|
+
|
|
2190
|
+
//
|
|
2191
|
+
// Implicit notation case. Flow-style node as the key first, then ":", and the value.
|
|
2192
|
+
//
|
|
2193
|
+
} else {
|
|
2194
|
+
_keyLine = state.line;
|
|
2195
|
+
_keyLineStart = state.lineStart;
|
|
2196
|
+
_keyPos = state.position;
|
|
2197
|
+
|
|
2198
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
2199
|
+
// Neither implicit nor explicit notation.
|
|
2200
|
+
// Reading is done. Go to the epilogue.
|
|
2201
|
+
break;
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
if (state.line === _line) {
|
|
2205
|
+
ch = state.input.charCodeAt(state.position);
|
|
2206
|
+
|
|
2207
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2208
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
if (ch === 0x3A/* : */) {
|
|
2212
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2213
|
+
|
|
2214
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
2215
|
+
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
if (atExplicitKey) {
|
|
2219
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2220
|
+
keyTag = keyNode = valueNode = null;
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
detected = true;
|
|
2224
|
+
atExplicitKey = false;
|
|
2225
|
+
allowCompact = false;
|
|
2226
|
+
keyTag = state.tag;
|
|
2227
|
+
keyNode = state.result;
|
|
2228
|
+
|
|
2229
|
+
} else if (detected) {
|
|
2230
|
+
throwError(state, 'can not read an implicit mapping pair; a colon is missed');
|
|
2231
|
+
|
|
2232
|
+
} else {
|
|
2233
|
+
state.tag = _tag;
|
|
2234
|
+
state.anchor = _anchor;
|
|
2235
|
+
return true; // Keep the result of `composeNode`.
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
} else if (detected) {
|
|
2239
|
+
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
|
|
2240
|
+
|
|
2241
|
+
} else {
|
|
2242
|
+
state.tag = _tag;
|
|
2243
|
+
state.anchor = _anchor;
|
|
2244
|
+
return true; // Keep the result of `composeNode`.
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
//
|
|
2249
|
+
// Common reading code for both explicit and implicit notations.
|
|
2250
|
+
//
|
|
2251
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
2252
|
+
if (atExplicitKey) {
|
|
2253
|
+
_keyLine = state.line;
|
|
2254
|
+
_keyLineStart = state.lineStart;
|
|
2255
|
+
_keyPos = state.position;
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
2259
|
+
if (atExplicitKey) {
|
|
2260
|
+
keyNode = state.result;
|
|
2261
|
+
} else {
|
|
2262
|
+
valueNode = state.result;
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
if (!atExplicitKey) {
|
|
2267
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
2268
|
+
keyTag = keyNode = valueNode = null;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
skipSeparationSpace(state, true, -1);
|
|
2272
|
+
ch = state.input.charCodeAt(state.position);
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
|
|
2276
|
+
throwError(state, 'bad indentation of a mapping entry');
|
|
2277
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
2278
|
+
break;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
//
|
|
2283
|
+
// Epilogue.
|
|
2284
|
+
//
|
|
2285
|
+
|
|
2286
|
+
// Special case: last mapping's node contains only the key in explicit notation.
|
|
2287
|
+
if (atExplicitKey) {
|
|
2288
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
// Expose the resulting mapping.
|
|
2292
|
+
if (detected) {
|
|
2293
|
+
state.tag = _tag;
|
|
2294
|
+
state.anchor = _anchor;
|
|
2295
|
+
state.kind = 'mapping';
|
|
2296
|
+
state.result = _result;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
return detected;
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
function readTagProperty(state) {
|
|
2303
|
+
var _position,
|
|
2304
|
+
isVerbatim = false,
|
|
2305
|
+
isNamed = false,
|
|
2306
|
+
tagHandle,
|
|
2307
|
+
tagName,
|
|
2308
|
+
ch;
|
|
2309
|
+
|
|
2310
|
+
ch = state.input.charCodeAt(state.position);
|
|
2311
|
+
|
|
2312
|
+
if (ch !== 0x21/* ! */) return false;
|
|
2313
|
+
|
|
2314
|
+
if (state.tag !== null) {
|
|
2315
|
+
throwError(state, 'duplication of a tag property');
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2319
|
+
|
|
2320
|
+
if (ch === 0x3C/* < */) {
|
|
2321
|
+
isVerbatim = true;
|
|
2322
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2323
|
+
|
|
2324
|
+
} else if (ch === 0x21/* ! */) {
|
|
2325
|
+
isNamed = true;
|
|
2326
|
+
tagHandle = '!!';
|
|
2327
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2328
|
+
|
|
2329
|
+
} else {
|
|
2330
|
+
tagHandle = '!';
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
_position = state.position;
|
|
2334
|
+
|
|
2335
|
+
if (isVerbatim) {
|
|
2336
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
|
2337
|
+
while (ch !== 0 && ch !== 0x3E/* > */);
|
|
2338
|
+
|
|
2339
|
+
if (state.position < state.length) {
|
|
2340
|
+
tagName = state.input.slice(_position, state.position);
|
|
2341
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2342
|
+
} else {
|
|
2343
|
+
throwError(state, 'unexpected end of the stream within a verbatim tag');
|
|
2344
|
+
}
|
|
2345
|
+
} else {
|
|
2346
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2347
|
+
|
|
2348
|
+
if (ch === 0x21/* ! */) {
|
|
2349
|
+
if (!isNamed) {
|
|
2350
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2351
|
+
|
|
2352
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2353
|
+
throwError(state, 'named tag handle cannot contain such characters');
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
isNamed = true;
|
|
2357
|
+
_position = state.position + 1;
|
|
2358
|
+
} else {
|
|
2359
|
+
throwError(state, 'tag suffix cannot contain exclamation marks');
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
tagName = state.input.slice(_position, state.position);
|
|
2367
|
+
|
|
2368
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2369
|
+
throwError(state, 'tag suffix cannot contain flow indicator characters');
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2374
|
+
throwError(state, 'tag name cannot contain such characters: ' + tagName);
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
try {
|
|
2378
|
+
tagName = decodeURIComponent(tagName);
|
|
2379
|
+
} catch (err) {
|
|
2380
|
+
throwError(state, 'tag name is malformed: ' + tagName);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
if (isVerbatim) {
|
|
2384
|
+
state.tag = tagName;
|
|
2385
|
+
|
|
2386
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
2387
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2388
|
+
|
|
2389
|
+
} else if (tagHandle === '!') {
|
|
2390
|
+
state.tag = '!' + tagName;
|
|
2391
|
+
|
|
2392
|
+
} else if (tagHandle === '!!') {
|
|
2393
|
+
state.tag = 'tag:yaml.org,2002:' + tagName;
|
|
2394
|
+
|
|
2395
|
+
} else {
|
|
2396
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
return true;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
function readAnchorProperty(state) {
|
|
2403
|
+
var _position,
|
|
2404
|
+
ch;
|
|
2405
|
+
|
|
2406
|
+
ch = state.input.charCodeAt(state.position);
|
|
2407
|
+
|
|
2408
|
+
if (ch !== 0x26/* & */) return false;
|
|
2409
|
+
|
|
2410
|
+
if (state.anchor !== null) {
|
|
2411
|
+
throwError(state, 'duplication of an anchor property');
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2415
|
+
_position = state.position;
|
|
2416
|
+
|
|
2417
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2418
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
if (state.position === _position) {
|
|
2422
|
+
throwError(state, 'name of an anchor node must contain at least one character');
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
2426
|
+
return true;
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
function readAlias(state) {
|
|
2430
|
+
var _position, alias,
|
|
2431
|
+
ch;
|
|
2432
|
+
|
|
2433
|
+
ch = state.input.charCodeAt(state.position);
|
|
2434
|
+
|
|
2435
|
+
if (ch !== 0x2A/* * */) return false;
|
|
2436
|
+
|
|
2437
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2438
|
+
_position = state.position;
|
|
2439
|
+
|
|
2440
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2441
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
if (state.position === _position) {
|
|
2445
|
+
throwError(state, 'name of an alias node must contain at least one character');
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
alias = state.input.slice(_position, state.position);
|
|
2449
|
+
|
|
2450
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
2451
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
state.result = state.anchorMap[alias];
|
|
2455
|
+
skipSeparationSpace(state, true, -1);
|
|
2456
|
+
return true;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2460
|
+
var allowBlockStyles,
|
|
2461
|
+
allowBlockScalars,
|
|
2462
|
+
allowBlockCollections,
|
|
2463
|
+
indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
|
|
2464
|
+
atNewLine = false,
|
|
2465
|
+
hasContent = false,
|
|
2466
|
+
typeIndex,
|
|
2467
|
+
typeQuantity,
|
|
2468
|
+
typeList,
|
|
2469
|
+
type,
|
|
2470
|
+
flowIndent,
|
|
2471
|
+
blockIndent;
|
|
2472
|
+
|
|
2473
|
+
if (state.listener !== null) {
|
|
2474
|
+
state.listener('open', state);
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
state.tag = null;
|
|
2478
|
+
state.anchor = null;
|
|
2479
|
+
state.kind = null;
|
|
2480
|
+
state.result = null;
|
|
2481
|
+
|
|
2482
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections =
|
|
2483
|
+
CONTEXT_BLOCK_OUT === nodeContext ||
|
|
2484
|
+
CONTEXT_BLOCK_IN === nodeContext;
|
|
2485
|
+
|
|
2486
|
+
if (allowToSeek) {
|
|
2487
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2488
|
+
atNewLine = true;
|
|
2489
|
+
|
|
2490
|
+
if (state.lineIndent > parentIndent) {
|
|
2491
|
+
indentStatus = 1;
|
|
2492
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2493
|
+
indentStatus = 0;
|
|
2494
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2495
|
+
indentStatus = -1;
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
if (indentStatus === 1) {
|
|
2501
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2502
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2503
|
+
atNewLine = true;
|
|
2504
|
+
allowBlockCollections = allowBlockStyles;
|
|
2505
|
+
|
|
2506
|
+
if (state.lineIndent > parentIndent) {
|
|
2507
|
+
indentStatus = 1;
|
|
2508
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2509
|
+
indentStatus = 0;
|
|
2510
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2511
|
+
indentStatus = -1;
|
|
2512
|
+
}
|
|
2513
|
+
} else {
|
|
2514
|
+
allowBlockCollections = false;
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
if (allowBlockCollections) {
|
|
2520
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2524
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2525
|
+
flowIndent = parentIndent;
|
|
2526
|
+
} else {
|
|
2527
|
+
flowIndent = parentIndent + 1;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
blockIndent = state.position - state.lineStart;
|
|
2531
|
+
|
|
2532
|
+
if (indentStatus === 1) {
|
|
2533
|
+
if (allowBlockCollections &&
|
|
2534
|
+
(readBlockSequence(state, blockIndent) ||
|
|
2535
|
+
readBlockMapping(state, blockIndent, flowIndent)) ||
|
|
2536
|
+
readFlowCollection(state, flowIndent)) {
|
|
2537
|
+
hasContent = true;
|
|
2538
|
+
} else {
|
|
2539
|
+
if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
|
|
2540
|
+
readSingleQuotedScalar(state, flowIndent) ||
|
|
2541
|
+
readDoubleQuotedScalar(state, flowIndent)) {
|
|
2542
|
+
hasContent = true;
|
|
2543
|
+
|
|
2544
|
+
} else if (readAlias(state)) {
|
|
2545
|
+
hasContent = true;
|
|
2546
|
+
|
|
2547
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
2548
|
+
throwError(state, 'alias node should not have any properties');
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2552
|
+
hasContent = true;
|
|
2553
|
+
|
|
2554
|
+
if (state.tag === null) {
|
|
2555
|
+
state.tag = '?';
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
if (state.anchor !== null) {
|
|
2560
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
} else if (indentStatus === 0) {
|
|
2564
|
+
// Special case: block sequences are allowed to have same indentation level as the parent.
|
|
2565
|
+
// http://www.yaml.org/spec/1.2/spec.html#id2799784
|
|
2566
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
if (state.tag === null) {
|
|
2571
|
+
if (state.anchor !== null) {
|
|
2572
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
} else if (state.tag === '?') {
|
|
2576
|
+
// Implicit resolving is not allowed for non-scalar types, and '?'
|
|
2577
|
+
// non-specific tag is only automatically assigned to plain scalars.
|
|
2578
|
+
//
|
|
2579
|
+
// We only need to check kind conformity in case user explicitly assigns '?'
|
|
2580
|
+
// tag, for example like this: "!<?> [0]"
|
|
2581
|
+
//
|
|
2582
|
+
if (state.result !== null && state.kind !== 'scalar') {
|
|
2583
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2587
|
+
type = state.implicitTypes[typeIndex];
|
|
2588
|
+
|
|
2589
|
+
if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
|
|
2590
|
+
state.result = type.construct(state.result);
|
|
2591
|
+
state.tag = type.tag;
|
|
2592
|
+
if (state.anchor !== null) {
|
|
2593
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2594
|
+
}
|
|
2595
|
+
break;
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
} else if (state.tag !== '!') {
|
|
2599
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
|
|
2600
|
+
type = state.typeMap[state.kind || 'fallback'][state.tag];
|
|
2601
|
+
} else {
|
|
2602
|
+
// looking for multi type
|
|
2603
|
+
type = null;
|
|
2604
|
+
typeList = state.typeMap.multi[state.kind || 'fallback'];
|
|
2605
|
+
|
|
2606
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2607
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2608
|
+
type = typeList[typeIndex];
|
|
2609
|
+
break;
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
if (!type) {
|
|
2615
|
+
throwError(state, 'unknown tag !<' + state.tag + '>');
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
if (state.result !== null && type.kind !== state.kind) {
|
|
2619
|
+
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched
|
|
2623
|
+
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
|
|
2624
|
+
} else {
|
|
2625
|
+
state.result = type.construct(state.result, state.tag);
|
|
2626
|
+
if (state.anchor !== null) {
|
|
2627
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
if (state.listener !== null) {
|
|
2633
|
+
state.listener('close', state);
|
|
2634
|
+
}
|
|
2635
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
function readDocument(state) {
|
|
2639
|
+
var documentStart = state.position,
|
|
2640
|
+
_position,
|
|
2641
|
+
directiveName,
|
|
2642
|
+
directiveArgs,
|
|
2643
|
+
hasDirectives = false,
|
|
2644
|
+
ch;
|
|
2645
|
+
|
|
2646
|
+
state.version = null;
|
|
2647
|
+
state.checkLineBreaks = state.legacy;
|
|
2648
|
+
state.tagMap = Object.create(null);
|
|
2649
|
+
state.anchorMap = Object.create(null);
|
|
2650
|
+
|
|
2651
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2652
|
+
skipSeparationSpace(state, true, -1);
|
|
2653
|
+
|
|
2654
|
+
ch = state.input.charCodeAt(state.position);
|
|
2655
|
+
|
|
2656
|
+
if (state.lineIndent > 0 || ch !== 0x25/* % */) {
|
|
2657
|
+
break;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
hasDirectives = true;
|
|
2661
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2662
|
+
_position = state.position;
|
|
2663
|
+
|
|
2664
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2665
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2669
|
+
directiveArgs = [];
|
|
2670
|
+
|
|
2671
|
+
if (directiveName.length < 1) {
|
|
2672
|
+
throwError(state, 'directive name must not be less than one character in length');
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
while (ch !== 0) {
|
|
2676
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2677
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
if (ch === 0x23/* # */) {
|
|
2681
|
+
do { ch = state.input.charCodeAt(++state.position); }
|
|
2682
|
+
while (ch !== 0 && !is_EOL(ch));
|
|
2683
|
+
break;
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
if (is_EOL(ch)) break;
|
|
2687
|
+
|
|
2688
|
+
_position = state.position;
|
|
2689
|
+
|
|
2690
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2691
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
if (ch !== 0) readLineBreak(state);
|
|
2698
|
+
|
|
2699
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
2700
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2701
|
+
} else {
|
|
2702
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
skipSeparationSpace(state, true, -1);
|
|
2707
|
+
|
|
2708
|
+
if (state.lineIndent === 0 &&
|
|
2709
|
+
state.input.charCodeAt(state.position) === 0x2D/* - */ &&
|
|
2710
|
+
state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
|
|
2711
|
+
state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
|
|
2712
|
+
state.position += 3;
|
|
2713
|
+
skipSeparationSpace(state, true, -1);
|
|
2714
|
+
|
|
2715
|
+
} else if (hasDirectives) {
|
|
2716
|
+
throwError(state, 'directives end mark is expected');
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2720
|
+
skipSeparationSpace(state, true, -1);
|
|
2721
|
+
|
|
2722
|
+
if (state.checkLineBreaks &&
|
|
2723
|
+
PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2724
|
+
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
state.documents.push(state.result);
|
|
2728
|
+
|
|
2729
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2730
|
+
|
|
2731
|
+
if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
|
|
2732
|
+
state.position += 3;
|
|
2733
|
+
skipSeparationSpace(state, true, -1);
|
|
2734
|
+
}
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
if (state.position < (state.length - 1)) {
|
|
2739
|
+
throwError(state, 'end of the stream or a document separator is expected');
|
|
2740
|
+
} else {
|
|
2741
|
+
return;
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
|
|
2746
|
+
function loadDocuments(input, options) {
|
|
2747
|
+
input = String(input);
|
|
2748
|
+
options = options || {};
|
|
2749
|
+
|
|
2750
|
+
if (input.length !== 0) {
|
|
2751
|
+
|
|
2752
|
+
// Add tailing `\n` if not exists
|
|
2753
|
+
if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
|
|
2754
|
+
input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
|
|
2755
|
+
input += '\n';
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
// Strip BOM
|
|
2759
|
+
if (input.charCodeAt(0) === 0xFEFF) {
|
|
2760
|
+
input = input.slice(1);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
var state = new State$1(input, options);
|
|
2765
|
+
|
|
2766
|
+
var nullpos = input.indexOf('\0');
|
|
2767
|
+
|
|
2768
|
+
if (nullpos !== -1) {
|
|
2769
|
+
state.position = nullpos;
|
|
2770
|
+
throwError(state, 'null byte is not allowed in input');
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
// Use 0 as string terminator. That significantly simplifies bounds check.
|
|
2774
|
+
state.input += '\0';
|
|
2775
|
+
|
|
2776
|
+
while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
|
|
2777
|
+
state.lineIndent += 1;
|
|
2778
|
+
state.position += 1;
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
while (state.position < (state.length - 1)) {
|
|
2782
|
+
readDocument(state);
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
return state.documents;
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
function load$1(input, options) {
|
|
2790
|
+
var documents = loadDocuments(input, options);
|
|
2791
|
+
|
|
2792
|
+
if (documents.length === 0) {
|
|
2793
|
+
/*eslint-disable no-undefined*/
|
|
2794
|
+
return undefined;
|
|
2795
|
+
} else if (documents.length === 1) {
|
|
2796
|
+
return documents[0];
|
|
2797
|
+
}
|
|
2798
|
+
throw new exception('expected a single document in the stream, but found more');
|
|
2799
|
+
}
|
|
2800
|
+
var load_1 = load$1;
|
|
2801
|
+
|
|
2802
|
+
var loader = {
|
|
2803
|
+
load: load_1
|
|
2804
|
+
};
|
|
2805
|
+
var load = loader.load;
|
|
2806
|
+
|
|
2807
|
+
const EPS = 1e-9;
|
|
2808
|
+
function toBoolString(v) {
|
|
2809
|
+
if (v == null)
|
|
2810
|
+
return undefined;
|
|
2811
|
+
if (typeof v === 'boolean')
|
|
2812
|
+
return v ? 'true' : 'false';
|
|
2813
|
+
const s = String(v).toLowerCase();
|
|
2814
|
+
if (s === 'true' || s === '1')
|
|
2815
|
+
return 'true';
|
|
2816
|
+
if (s === 'false' || s === '0')
|
|
2817
|
+
return 'false';
|
|
2818
|
+
return s;
|
|
2819
|
+
}
|
|
2820
|
+
function toNumOrUndef(v) {
|
|
2821
|
+
if (v == null)
|
|
2822
|
+
return undefined;
|
|
2823
|
+
const n = typeof v === 'number' ? v : Number(v);
|
|
2824
|
+
return Number.isFinite(n) ? n : undefined;
|
|
2825
|
+
}
|
|
2826
|
+
/** stable JSON for objects (key-sorted) */
|
|
2827
|
+
function stableStringify(obj) {
|
|
2828
|
+
if (obj == null)
|
|
2829
|
+
return undefined;
|
|
2830
|
+
if (typeof obj !== 'object')
|
|
2831
|
+
return JSON.stringify(obj);
|
|
2832
|
+
const keys = Object.keys(obj).sort();
|
|
2833
|
+
const acc = {};
|
|
2834
|
+
for (const k of keys)
|
|
2835
|
+
acc[k] = obj[k];
|
|
2836
|
+
return JSON.stringify(acc);
|
|
2837
|
+
}
|
|
2838
|
+
function eqNum(a, b) {
|
|
2839
|
+
if (a == null && b == null)
|
|
2840
|
+
return true;
|
|
2841
|
+
if (a == null || b == null)
|
|
2842
|
+
return false;
|
|
2843
|
+
return Math.abs(a - b) <= EPS;
|
|
2844
|
+
}
|
|
2845
|
+
function eqStr(a, b) {
|
|
2846
|
+
return (a ?? undefined) === (b ?? undefined);
|
|
2847
|
+
}
|
|
2848
|
+
/** Compare fields relevant for rendering; returns patch (only changed fields) */
|
|
2849
|
+
function diffRelevantFields(a, b) {
|
|
2850
|
+
const changes = {};
|
|
2851
|
+
if (a.type !== b.type)
|
|
2852
|
+
changes.type = { old: a.type, new: b.type };
|
|
2853
|
+
const aVisible = toBoolString(a.visible);
|
|
2854
|
+
const bVisible = toBoolString(b.visible);
|
|
2855
|
+
if (!eqStr(aVisible, bVisible))
|
|
2856
|
+
changes.visible = { old: aVisible, new: bVisible };
|
|
2857
|
+
const aOpacity = toNumOrUndef(a.opacity);
|
|
2858
|
+
const bOpacity = toNumOrUndef(b.opacity);
|
|
2859
|
+
if (!eqNum(aOpacity, bOpacity))
|
|
2860
|
+
changes.opacity = { old: aOpacity, new: bOpacity };
|
|
2861
|
+
const aZ = toNumOrUndef(a.zIndex);
|
|
2862
|
+
const bZ = toNumOrUndef(b.zIndex);
|
|
2863
|
+
if (!eqNum(aZ, bZ))
|
|
2864
|
+
changes.zIndex = { old: aZ, new: bZ };
|
|
2865
|
+
if (!eqStr(a.url, b.url))
|
|
2866
|
+
changes.url = { old: a.url, new: b.url };
|
|
2867
|
+
if (!eqStr(a.layers, b.layers))
|
|
2868
|
+
changes.layers = { old: a.layers, new: b.layers };
|
|
2869
|
+
const aTiled = toBoolString(a.tiled);
|
|
2870
|
+
const bTiled = toBoolString(b.tiled);
|
|
2871
|
+
if (!eqStr(aTiled, bTiled))
|
|
2872
|
+
changes.tiled = { old: aTiled, new: bTiled };
|
|
2873
|
+
const aStyle = stableStringify(a.style);
|
|
2874
|
+
const bStyle = stableStringify(b.style);
|
|
2875
|
+
if (!eqStr(aStyle, bStyle))
|
|
2876
|
+
changes.style = { old: a.style, new: b.style };
|
|
2877
|
+
const aData = stableStringify(a.data);
|
|
2878
|
+
const bData = stableStringify(b.data);
|
|
2879
|
+
if (!eqStr(aData, bData))
|
|
2880
|
+
changes.data = { old: a.data, new: b.data };
|
|
2881
|
+
return changes;
|
|
2882
|
+
}
|
|
2883
|
+
/** Longest Common Subsequence for stable move detection (by IDs) */
|
|
2884
|
+
function lcs(a, b) {
|
|
2885
|
+
const m = a.length, n = b.length;
|
|
2886
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
2887
|
+
for (let i = m - 1; i >= 0; i--) {
|
|
2888
|
+
for (let j = n - 1; j >= 0; j--) {
|
|
2889
|
+
dp[i][j] =
|
|
2890
|
+
a[i] === b[j]
|
|
2891
|
+
? dp[i + 1][j + 1] + 1
|
|
2892
|
+
: Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
const seq = [];
|
|
2896
|
+
let i = 0, j = 0;
|
|
2897
|
+
while (i < m && j < n) {
|
|
2898
|
+
if (a[i] === b[j]) {
|
|
2899
|
+
seq.push(a[i]);
|
|
2900
|
+
i++;
|
|
2901
|
+
j++;
|
|
2902
|
+
}
|
|
2903
|
+
else if (dp[i + 1][j] >= dp[i][j + 1])
|
|
2904
|
+
i++;
|
|
2905
|
+
else
|
|
2906
|
+
j++;
|
|
2907
|
+
}
|
|
2908
|
+
return seq;
|
|
2909
|
+
}
|
|
2910
|
+
/** Computes added/removed/updated/moved/unchanged */
|
|
2911
|
+
function diffLayers(oldLayers, newLayers) {
|
|
2912
|
+
const oldById = new Map(oldLayers.map(l => [l.id, l]));
|
|
2913
|
+
const newById = new Map(newLayers.map(l => [l.id, l]));
|
|
2914
|
+
const added = [];
|
|
2915
|
+
const removed = [];
|
|
2916
|
+
const updated = [];
|
|
2917
|
+
const unchangedIds = [];
|
|
2918
|
+
for (const newL of newLayers) {
|
|
2919
|
+
const oldL = oldById.get(newL.id);
|
|
2920
|
+
if (!oldL) {
|
|
2921
|
+
added.push(newL);
|
|
2922
|
+
continue;
|
|
2923
|
+
}
|
|
2924
|
+
const changes = diffRelevantFields(oldL, newL);
|
|
2925
|
+
if (Object.keys(changes).length)
|
|
2926
|
+
updated.push({ id: newL.id, changes });
|
|
2927
|
+
else
|
|
2928
|
+
unchangedIds.push(newL.id);
|
|
2929
|
+
}
|
|
2930
|
+
for (const oldL of oldLayers) {
|
|
2931
|
+
if (!newById.has(oldL.id))
|
|
2932
|
+
removed.push(oldL);
|
|
2933
|
+
}
|
|
2934
|
+
const oldIds = oldLayers.filter(l => newById.has(l.id)).map(l => l.id);
|
|
2935
|
+
const newIds = newLayers.filter(l => oldById.has(l.id)).map(l => l.id);
|
|
2936
|
+
const seq = lcs(oldIds, newIds);
|
|
2937
|
+
const keep = new Set(seq);
|
|
2938
|
+
const moved = [];
|
|
2939
|
+
for (const id of newIds) {
|
|
2940
|
+
if (!keep.has(id) && !added.find(a => a.id === id)) {
|
|
2941
|
+
const from = oldIds.indexOf(id);
|
|
2942
|
+
const to = newIds.indexOf(id);
|
|
2943
|
+
if (from !== -1 && to !== -1)
|
|
2944
|
+
moved.push({ id, from, to });
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
return { added, removed, updated, moved, unchangedIds };
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
const vMapBuilderCss = () => `:host{display:block;height:100%}.root{height:100%}`;
|
|
2951
|
+
|
|
2952
|
+
const MSG_COMPONENT = 'v-map-builder - ';
|
|
2953
|
+
const VMapBuilder = class {
|
|
2954
|
+
constructor(hostRef) {
|
|
2955
|
+
index.registerInstance(this, hostRef);
|
|
2956
|
+
this.configReady = index.createEvent(this, "configReady", 7);
|
|
2957
|
+
this.configError = index.createEvent(this, "configError", 7);
|
|
2958
|
+
}
|
|
2959
|
+
get hostEl() { return index.getElement(this); }
|
|
2960
|
+
/**
|
|
2961
|
+
* Configuration object for the map builder. Can be any structure that will be normalized to BuilderConfig.
|
|
2962
|
+
*/
|
|
2963
|
+
mapconfig;
|
|
2964
|
+
/**
|
|
2965
|
+
* Event emitted when the map configuration has been successfully parsed and is ready to use.
|
|
2966
|
+
*/
|
|
2967
|
+
configReady;
|
|
2968
|
+
/**
|
|
2969
|
+
* Event emitted when there is an error parsing the map configuration.
|
|
2970
|
+
*/
|
|
2971
|
+
configError;
|
|
2972
|
+
current;
|
|
2973
|
+
//componentWillLoad() {
|
|
2974
|
+
async componentDidLoad() {
|
|
2975
|
+
messages.log(MSG_COMPONENT + messages.MESSAGES.COMPONENT_DID_LOAD);
|
|
2976
|
+
this.parseFromSlot();
|
|
2977
|
+
}
|
|
2978
|
+
async onMapConfigChanged(_oldValue, _newValue) {
|
|
2979
|
+
messages.log(MSG_COMPONENT + 'onMapConfigChanged');
|
|
2980
|
+
this.parseFromSlot();
|
|
2981
|
+
}
|
|
2982
|
+
parseFromSlot() {
|
|
2983
|
+
messages.log(MSG_COMPONENT + 'parseFromSlot');
|
|
2984
|
+
try {
|
|
2985
|
+
const script = this.hostEl.querySelector('script[type*="json"], script[type*="yaml"], script[type*="yml"]');
|
|
2986
|
+
if (!script)
|
|
2987
|
+
throw new Error('No configuration <script> found.');
|
|
2988
|
+
const mime = (script.type || '').toLowerCase();
|
|
2989
|
+
const text = script.textContent ?? '';
|
|
2990
|
+
const raw = mime.includes('json') ? JSON.parse(text) : load(text);
|
|
2991
|
+
const cfg = this.normalize(raw);
|
|
2992
|
+
this.applyDiff(this.current, cfg);
|
|
2993
|
+
this.current = cfg;
|
|
2994
|
+
messages.log(MSG_COMPONENT + 'emit configReady');
|
|
2995
|
+
this.configReady.emit(cfg);
|
|
2996
|
+
}
|
|
2997
|
+
catch (e) {
|
|
2998
|
+
const err = e;
|
|
2999
|
+
const message = err?.message || 'Unknown error';
|
|
3000
|
+
this.configError.emit({
|
|
3001
|
+
message,
|
|
3002
|
+
errors: err?.errors,
|
|
3003
|
+
});
|
|
3004
|
+
this.hostEl.dispatchEvent(new CustomEvent(messages.VMapEvents.Error, {
|
|
3005
|
+
detail: {
|
|
3006
|
+
type: 'validation',
|
|
3007
|
+
message,
|
|
3008
|
+
cause: e,
|
|
3009
|
+
},
|
|
3010
|
+
bubbles: true,
|
|
3011
|
+
composed: true,
|
|
3012
|
+
}));
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
normalizeLayerType(rawType) {
|
|
3016
|
+
const type = String(rawType ?? '').toLowerCase();
|
|
3017
|
+
switch (type) {
|
|
3018
|
+
case 'osm':
|
|
3019
|
+
case 'wms':
|
|
3020
|
+
case 'wms-tiled':
|
|
3021
|
+
case 'geojson':
|
|
3022
|
+
case 'xyz':
|
|
3023
|
+
case 'terrain':
|
|
3024
|
+
case 'wfs':
|
|
3025
|
+
case 'wcs':
|
|
3026
|
+
case 'google':
|
|
3027
|
+
case 'geotiff':
|
|
3028
|
+
case 'tile3d':
|
|
3029
|
+
case 'scatterplot':
|
|
3030
|
+
case 'wkt':
|
|
3031
|
+
return type;
|
|
3032
|
+
default:
|
|
3033
|
+
return 'custom';
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
toOptionalString(value) {
|
|
3037
|
+
if (value === undefined || value === null)
|
|
3038
|
+
return undefined;
|
|
3039
|
+
return typeof value === 'string' ? value : String(value);
|
|
3040
|
+
}
|
|
3041
|
+
toOptionalNumber(value) {
|
|
3042
|
+
if (value === undefined || value === null || value === '')
|
|
3043
|
+
return undefined;
|
|
3044
|
+
const num = typeof value === 'number' ? value : Number(value);
|
|
3045
|
+
return Number.isFinite(num) ? num : undefined;
|
|
3046
|
+
}
|
|
3047
|
+
toOptionalBoolean(value) {
|
|
3048
|
+
if (value === undefined || value === null || value === '')
|
|
3049
|
+
return undefined;
|
|
3050
|
+
if (typeof value === 'boolean')
|
|
3051
|
+
return value;
|
|
3052
|
+
const normalized = String(value).trim().toLowerCase();
|
|
3053
|
+
if (['true', '1', 'yes', 'y'].includes(normalized))
|
|
3054
|
+
return true;
|
|
3055
|
+
if (['false', '0', 'no', 'n'].includes(normalized))
|
|
3056
|
+
return false;
|
|
3057
|
+
return undefined;
|
|
3058
|
+
}
|
|
3059
|
+
toCsv(value) {
|
|
3060
|
+
if (value === undefined || value === null)
|
|
3061
|
+
return undefined;
|
|
3062
|
+
if (Array.isArray(value)) {
|
|
3063
|
+
return value
|
|
3064
|
+
.map(entry => this.toOptionalString(entry))
|
|
3065
|
+
.filter((entry) => entry != null && entry !== '')
|
|
3066
|
+
.join(',');
|
|
3067
|
+
}
|
|
3068
|
+
return this.toOptionalString(value);
|
|
3069
|
+
}
|
|
3070
|
+
cleanRecord(record) {
|
|
3071
|
+
if (!record)
|
|
3072
|
+
return undefined;
|
|
3073
|
+
const result = {};
|
|
3074
|
+
for (const [key, value] of Object.entries(record)) {
|
|
3075
|
+
if (value !== undefined && value !== null) {
|
|
3076
|
+
result[key] = value;
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
return Object.keys(result).length ? result : undefined;
|
|
3080
|
+
}
|
|
3081
|
+
normalizeLayer(rawLayer, groupIndex, layerIndex) {
|
|
3082
|
+
const type = this.normalizeLayerType(rawLayer?.type ?? rawLayer?.layerType);
|
|
3083
|
+
const layerId = String(rawLayer?.id ?? `${groupIndex + 1}-${layerIndex + 1}`);
|
|
3084
|
+
const base = {
|
|
3085
|
+
id: layerId,
|
|
3086
|
+
type,
|
|
3087
|
+
visible: rawLayer?.visible,
|
|
3088
|
+
opacity: rawLayer?.opacity,
|
|
3089
|
+
zIndex: rawLayer?.zIndex,
|
|
3090
|
+
};
|
|
3091
|
+
if (rawLayer?.style != null) {
|
|
3092
|
+
base.style = rawLayer.style;
|
|
3093
|
+
}
|
|
3094
|
+
const data = {};
|
|
3095
|
+
const setBase = (key, value) => {
|
|
3096
|
+
if (value !== undefined && value !== null) {
|
|
3097
|
+
// NormalizedLayer has [key: string]: unknown index signature
|
|
3098
|
+
base[key] = value;
|
|
3099
|
+
}
|
|
3100
|
+
};
|
|
3101
|
+
switch (type) {
|
|
3102
|
+
case 'wms':
|
|
3103
|
+
case 'wms-tiled': {
|
|
3104
|
+
const url = this.toOptionalString(rawLayer?.url);
|
|
3105
|
+
const layers = this.toOptionalString(rawLayer?.layers ?? rawLayer?.sublayers);
|
|
3106
|
+
const tiled = type === 'wms-tiled'
|
|
3107
|
+
? true
|
|
3108
|
+
: this.toOptionalBoolean(rawLayer?.tiled);
|
|
3109
|
+
setBase('url', url);
|
|
3110
|
+
setBase('layers', layers);
|
|
3111
|
+
if (tiled !== undefined)
|
|
3112
|
+
setBase('tiled', tiled);
|
|
3113
|
+
const params = rawLayer?.params ?? rawLayer?.extraParams;
|
|
3114
|
+
Object.assign(data, this.cleanRecord({
|
|
3115
|
+
styles: rawLayer?.styles,
|
|
3116
|
+
format: rawLayer?.format,
|
|
3117
|
+
transparent: this.toOptionalBoolean(rawLayer?.transparent),
|
|
3118
|
+
tiled,
|
|
3119
|
+
version: rawLayer?.version,
|
|
3120
|
+
time: rawLayer?.time,
|
|
3121
|
+
params,
|
|
3122
|
+
}) ?? {});
|
|
3123
|
+
break;
|
|
3124
|
+
}
|
|
3125
|
+
case 'geojson': {
|
|
3126
|
+
setBase('url', this.toOptionalString(rawLayer?.url));
|
|
3127
|
+
Object.assign(data, this.cleanRecord({
|
|
3128
|
+
geojson: rawLayer?.geojson ?? rawLayer?.data,
|
|
3129
|
+
fillColor: rawLayer?.fillColor,
|
|
3130
|
+
fillOpacity: this.toOptionalNumber(rawLayer?.fillOpacity),
|
|
3131
|
+
strokeColor: rawLayer?.strokeColor,
|
|
3132
|
+
strokeWidth: this.toOptionalNumber(rawLayer?.strokeWidth),
|
|
3133
|
+
strokeOpacity: this.toOptionalNumber(rawLayer?.strokeOpacity),
|
|
3134
|
+
pointRadius: this.toOptionalNumber(rawLayer?.pointRadius),
|
|
3135
|
+
pointColor: rawLayer?.pointColor,
|
|
3136
|
+
iconUrl: rawLayer?.iconUrl,
|
|
3137
|
+
iconSize: rawLayer?.iconSize,
|
|
3138
|
+
textProperty: rawLayer?.textProperty,
|
|
3139
|
+
textColor: rawLayer?.textColor,
|
|
3140
|
+
textSize: this.toOptionalNumber(rawLayer?.textSize),
|
|
3141
|
+
}) ?? {});
|
|
3142
|
+
break;
|
|
3143
|
+
}
|
|
3144
|
+
case 'xyz': {
|
|
3145
|
+
setBase('url', this.toOptionalString(rawLayer?.url));
|
|
3146
|
+
Object.assign(data, this.cleanRecord({
|
|
3147
|
+
attributions: rawLayer?.attributions,
|
|
3148
|
+
maxZoom: this.toOptionalNumber(rawLayer?.maxZoom),
|
|
3149
|
+
tileSize: this.toOptionalNumber(rawLayer?.tileSize),
|
|
3150
|
+
subdomains: this.toCsv(rawLayer?.subdomains),
|
|
3151
|
+
}) ?? {});
|
|
3152
|
+
break;
|
|
3153
|
+
}
|
|
3154
|
+
case 'terrain': {
|
|
3155
|
+
const nested = (rawLayer?.data != null && typeof rawLayer.data === 'object'
|
|
3156
|
+
? rawLayer.data
|
|
3157
|
+
: {});
|
|
3158
|
+
Object.assign(data, this.cleanRecord({
|
|
3159
|
+
elevationData: rawLayer?.elevationData ??
|
|
3160
|
+
rawLayer?.url ??
|
|
3161
|
+
nested.elevationData,
|
|
3162
|
+
texture: rawLayer?.texture ?? nested.texture,
|
|
3163
|
+
elevationDecoder: rawLayer?.elevationDecoder ?? nested.elevationDecoder,
|
|
3164
|
+
wireframe: this.toOptionalBoolean(rawLayer?.wireframe ?? nested.wireframe),
|
|
3165
|
+
color: rawLayer?.color ?? nested.color,
|
|
3166
|
+
minZoom: this.toOptionalNumber(rawLayer?.minZoom ?? nested.minZoom),
|
|
3167
|
+
maxZoom: this.toOptionalNumber(rawLayer?.maxZoom ?? nested.maxZoom),
|
|
3168
|
+
meshMaxError: this.toOptionalNumber(rawLayer?.meshMaxError ?? nested.meshMaxError),
|
|
3169
|
+
}) ?? {});
|
|
3170
|
+
break;
|
|
3171
|
+
}
|
|
3172
|
+
case 'wfs': {
|
|
3173
|
+
const url = this.toOptionalString(rawLayer?.url);
|
|
3174
|
+
setBase('url', url);
|
|
3175
|
+
Object.assign(data, this.cleanRecord({
|
|
3176
|
+
url,
|
|
3177
|
+
typeName: rawLayer?.typeName ?? rawLayer?.layerName,
|
|
3178
|
+
version: rawLayer?.version,
|
|
3179
|
+
outputFormat: rawLayer?.outputFormat ?? rawLayer?.format,
|
|
3180
|
+
srsName: rawLayer?.srsName ?? rawLayer?.crs,
|
|
3181
|
+
params: rawLayer?.params,
|
|
3182
|
+
}) ?? {});
|
|
3183
|
+
break;
|
|
3184
|
+
}
|
|
3185
|
+
case 'wcs': {
|
|
3186
|
+
const url = this.toOptionalString(rawLayer?.url);
|
|
3187
|
+
setBase('url', url);
|
|
3188
|
+
Object.assign(data, this.cleanRecord({
|
|
3189
|
+
url,
|
|
3190
|
+
coverageName: rawLayer?.coverageName,
|
|
3191
|
+
format: rawLayer?.format,
|
|
3192
|
+
version: rawLayer?.version,
|
|
3193
|
+
projection: rawLayer?.projection,
|
|
3194
|
+
resolutions: rawLayer?.resolutions,
|
|
3195
|
+
params: rawLayer?.params,
|
|
3196
|
+
}) ?? {});
|
|
3197
|
+
break;
|
|
3198
|
+
}
|
|
3199
|
+
case 'google': {
|
|
3200
|
+
Object.assign(data, this.cleanRecord({
|
|
3201
|
+
apiKey: rawLayer?.apiKey ?? rawLayer?.api_key,
|
|
3202
|
+
mapType: rawLayer?.mapType,
|
|
3203
|
+
language: rawLayer?.language,
|
|
3204
|
+
region: rawLayer?.region,
|
|
3205
|
+
scale: rawLayer?.scale,
|
|
3206
|
+
libraries: this.toCsv(rawLayer?.libraries),
|
|
3207
|
+
maxZoom: this.toOptionalNumber(rawLayer?.maxZoom),
|
|
3208
|
+
styles: rawLayer?.styles,
|
|
3209
|
+
}) ?? {});
|
|
3210
|
+
break;
|
|
3211
|
+
}
|
|
3212
|
+
case 'geotiff': {
|
|
3213
|
+
setBase('url', this.toOptionalString(rawLayer?.url));
|
|
3214
|
+
break;
|
|
3215
|
+
}
|
|
3216
|
+
case 'tile3d': {
|
|
3217
|
+
setBase('url', this.toOptionalString(rawLayer?.url));
|
|
3218
|
+
Object.assign(data, this.cleanRecord({
|
|
3219
|
+
tilesetOptions: rawLayer?.tilesetOptions ?? rawLayer?.options ?? rawLayer?.data,
|
|
3220
|
+
style: rawLayer?.style ?? rawLayer?.cesiumStyle,
|
|
3221
|
+
}) ?? {});
|
|
3222
|
+
break;
|
|
3223
|
+
}
|
|
3224
|
+
case 'scatterplot': {
|
|
3225
|
+
Object.assign(data, this.cleanRecord({
|
|
3226
|
+
url: this.toOptionalString(rawLayer?.url),
|
|
3227
|
+
data: rawLayer?.data,
|
|
3228
|
+
getFillColor: rawLayer?.getFillColor,
|
|
3229
|
+
getRadius: this.toOptionalNumber(rawLayer?.getRadius),
|
|
3230
|
+
}) ?? {});
|
|
3231
|
+
break;
|
|
3232
|
+
}
|
|
3233
|
+
case 'wkt': {
|
|
3234
|
+
Object.assign(data, this.cleanRecord({
|
|
3235
|
+
wkt: rawLayer?.wkt,
|
|
3236
|
+
url: this.toOptionalString(rawLayer?.url),
|
|
3237
|
+
fillColor: rawLayer?.fillColor,
|
|
3238
|
+
fillOpacity: this.toOptionalNumber(rawLayer?.fillOpacity),
|
|
3239
|
+
strokeColor: rawLayer?.strokeColor,
|
|
3240
|
+
strokeWidth: this.toOptionalNumber(rawLayer?.strokeWidth),
|
|
3241
|
+
strokeOpacity: this.toOptionalNumber(rawLayer?.strokeOpacity),
|
|
3242
|
+
pointRadius: this.toOptionalNumber(rawLayer?.pointRadius),
|
|
3243
|
+
pointColor: rawLayer?.pointColor,
|
|
3244
|
+
iconUrl: rawLayer?.iconUrl,
|
|
3245
|
+
iconSize: rawLayer?.iconSize,
|
|
3246
|
+
textProperty: rawLayer?.textProperty,
|
|
3247
|
+
textColor: rawLayer?.textColor,
|
|
3248
|
+
textSize: this.toOptionalNumber(rawLayer?.textSize),
|
|
3249
|
+
}) ?? {});
|
|
3250
|
+
break;
|
|
3251
|
+
}
|
|
3252
|
+
case 'osm':
|
|
3253
|
+
setBase('url', this.toOptionalString(rawLayer?.url));
|
|
3254
|
+
break;
|
|
3255
|
+
default: {
|
|
3256
|
+
const payload = rawLayer?.data && typeof rawLayer.data === 'object'
|
|
3257
|
+
? rawLayer.data
|
|
3258
|
+
: rawLayer;
|
|
3259
|
+
if (payload && typeof payload === 'object') {
|
|
3260
|
+
Object.assign(data, this.cleanRecord(payload) ?? {});
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
base.data = this.cleanRecord(data);
|
|
3265
|
+
return base;
|
|
3266
|
+
}
|
|
3267
|
+
normalize(raw) {
|
|
3268
|
+
const rawObj = (raw != null && typeof raw === 'object' ? raw : {});
|
|
3269
|
+
const map = (rawObj.map != null && typeof rawObj.map === 'object' ? rawObj.map : rawObj);
|
|
3270
|
+
const norm = {
|
|
3271
|
+
map: {
|
|
3272
|
+
flavour: String(map.flavour ?? 'ol'),
|
|
3273
|
+
id: String(map.id ?? 'map1'),
|
|
3274
|
+
zoom: Number(map.zoom ?? 2),
|
|
3275
|
+
center: String(map.center ?? '0,0'),
|
|
3276
|
+
style: String(map.style ?? ''),
|
|
3277
|
+
styles: this.normalizeStyles(map.styles),
|
|
3278
|
+
layerGroups: (Array.isArray(map.layerGroups) ? map.layerGroups : []).map((g, gi) => ({
|
|
3279
|
+
groupTitle: String(g.groupTitle ?? g.group ?? g.title ?? `Group ${gi + 1}`),
|
|
3280
|
+
basemapid: String(g.basemapid ?? ''),
|
|
3281
|
+
visible: g.visible,
|
|
3282
|
+
layers: (Array.isArray(g.layers) ? g.layers : []).map((l, li) => this.normalizeLayer(l, gi, li)),
|
|
3283
|
+
})),
|
|
3284
|
+
},
|
|
3285
|
+
};
|
|
3286
|
+
return norm;
|
|
3287
|
+
}
|
|
3288
|
+
normalizeStyles(input) {
|
|
3289
|
+
const list = Array.isArray(input) ? input : input ? [input] : [];
|
|
3290
|
+
return list
|
|
3291
|
+
.map((entry, index) => this.normalizeStyle(entry, index))
|
|
3292
|
+
.filter((style) => Boolean(style));
|
|
3293
|
+
}
|
|
3294
|
+
normalizeStyle(entry, index) {
|
|
3295
|
+
if (entry == null)
|
|
3296
|
+
return undefined;
|
|
3297
|
+
const raw = typeof entry === 'object' && entry !== null
|
|
3298
|
+
? entry
|
|
3299
|
+
: { content: entry };
|
|
3300
|
+
const keySource = raw.key ?? raw.id ?? raw.name;
|
|
3301
|
+
const key = String(keySource != null ? keySource : `style-${index + 1}`);
|
|
3302
|
+
const format = String(raw.format ?? 'sld').toLowerCase();
|
|
3303
|
+
let layerTargets;
|
|
3304
|
+
if (Array.isArray(raw.layerTargets)) {
|
|
3305
|
+
const targets = raw.layerTargets
|
|
3306
|
+
.map((target) => String(target).trim())
|
|
3307
|
+
.filter(Boolean);
|
|
3308
|
+
layerTargets = targets.length ? targets.join(',') : undefined;
|
|
3309
|
+
}
|
|
3310
|
+
else if (typeof raw.layerTargets === 'string') {
|
|
3311
|
+
const targets = raw.layerTargets
|
|
3312
|
+
.split(',')
|
|
3313
|
+
.map(target => target.trim())
|
|
3314
|
+
.filter(Boolean);
|
|
3315
|
+
layerTargets = targets.length ? targets.join(',') : undefined;
|
|
3316
|
+
}
|
|
3317
|
+
const autoApply = raw.autoApply == null
|
|
3318
|
+
? undefined
|
|
3319
|
+
: typeof raw.autoApply === 'boolean'
|
|
3320
|
+
? raw.autoApply
|
|
3321
|
+
: String(raw.autoApply).toLowerCase() !== 'false';
|
|
3322
|
+
let src = raw.src != null ? String(raw.src).trim() : undefined;
|
|
3323
|
+
if (src === '')
|
|
3324
|
+
src = undefined;
|
|
3325
|
+
let content = raw.content != null ? String(raw.content) : undefined;
|
|
3326
|
+
if (!src && !content && typeof raw.source === 'string') {
|
|
3327
|
+
const source = raw.source.trim();
|
|
3328
|
+
if (source) {
|
|
3329
|
+
if (/^(https?:)?\/\//.test(source) ||
|
|
3330
|
+
source.startsWith('/') ||
|
|
3331
|
+
source.startsWith('./') ||
|
|
3332
|
+
source.startsWith('../')) {
|
|
3333
|
+
src = source;
|
|
3334
|
+
}
|
|
3335
|
+
else {
|
|
3336
|
+
content = source;
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
if (!src && !content) {
|
|
3341
|
+
if (typeof entry === 'string') {
|
|
3342
|
+
content = String(entry);
|
|
3343
|
+
}
|
|
3344
|
+
else {
|
|
3345
|
+
messages.log(`${MSG_COMPONENT}normalizeStyle: skipping style without src/content (key=${key})`);
|
|
3346
|
+
return undefined;
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
return {
|
|
3350
|
+
key,
|
|
3351
|
+
format,
|
|
3352
|
+
src,
|
|
3353
|
+
content,
|
|
3354
|
+
layerTargets,
|
|
3355
|
+
autoApply,
|
|
3356
|
+
id: raw.id != null ? String(raw.id) : undefined,
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
syncStyles(mapEl, styles) {
|
|
3360
|
+
const selector = 'v-map-style[data-builder-style="true"]';
|
|
3361
|
+
const existing = Array.from(mapEl.querySelectorAll(selector));
|
|
3362
|
+
const existingByKey = new Map();
|
|
3363
|
+
for (const el of existing) {
|
|
3364
|
+
const key = el.getAttribute('data-builder-style-id');
|
|
3365
|
+
if (key)
|
|
3366
|
+
existingByKey.set(key, el);
|
|
3367
|
+
}
|
|
3368
|
+
const processed = new Set();
|
|
3369
|
+
const anchor = Array.from(mapEl.children).find(child => {
|
|
3370
|
+
if (child.tagName.toLowerCase() !== 'v-map-style')
|
|
3371
|
+
return true;
|
|
3372
|
+
return (child.getAttribute('data-builder-style') !== 'true');
|
|
3373
|
+
});
|
|
3374
|
+
styles.forEach((style, index) => {
|
|
3375
|
+
const key = style.key || `style-${index + 1}`;
|
|
3376
|
+
let el = existingByKey.get(key);
|
|
3377
|
+
if (!el || el.parentElement !== mapEl) {
|
|
3378
|
+
el = document.createElement('v-map-style');
|
|
3379
|
+
el.setAttribute('data-builder-style', 'true');
|
|
3380
|
+
el.setAttribute('data-builder-style-id', key);
|
|
3381
|
+
}
|
|
3382
|
+
else {
|
|
3383
|
+
el.setAttribute('data-builder-style', 'true');
|
|
3384
|
+
el.setAttribute('data-builder-style-id', key);
|
|
3385
|
+
}
|
|
3386
|
+
processed.add(key);
|
|
3387
|
+
this.ensureAttr(el, 'format', style.format);
|
|
3388
|
+
this.ensureAttr(el, 'layer-targets', style.layerTargets);
|
|
3389
|
+
if (style.autoApply !== undefined) {
|
|
3390
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- setting Stencil web component property
|
|
3391
|
+
el.autoApply = style.autoApply;
|
|
3392
|
+
}
|
|
3393
|
+
else {
|
|
3394
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- setting Stencil web component property
|
|
3395
|
+
el.autoApply = true;
|
|
3396
|
+
}
|
|
3397
|
+
const autoApplyAttr = style.autoApply === true ? '' : undefined;
|
|
3398
|
+
this.ensureAttr(el, 'auto-apply', autoApplyAttr);
|
|
3399
|
+
this.ensureAttr(el, 'id', style.id);
|
|
3400
|
+
this.ensureAttr(el, 'src', style.src);
|
|
3401
|
+
this.ensureAttr(el, 'content', style.content);
|
|
3402
|
+
const reference = anchor && anchor.parentElement === mapEl ? anchor : null;
|
|
3403
|
+
if (!el.isConnected || el.parentElement !== mapEl) {
|
|
3404
|
+
mapEl.insertBefore(el, reference);
|
|
3405
|
+
}
|
|
3406
|
+
else if (reference) {
|
|
3407
|
+
mapEl.insertBefore(el, reference);
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
for (const el of existing) {
|
|
3411
|
+
const key = el.getAttribute('data-builder-style-id') || '';
|
|
3412
|
+
if (!processed.has(key)) {
|
|
3413
|
+
mapEl.removeChild(el);
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
ensureAttr(el, name, value) {
|
|
3418
|
+
const v = value == null ? undefined : String(value);
|
|
3419
|
+
const cur = el.getAttribute(name);
|
|
3420
|
+
if (v == null) {
|
|
3421
|
+
if (cur != null)
|
|
3422
|
+
el.removeAttribute(name);
|
|
3423
|
+
return;
|
|
3424
|
+
}
|
|
3425
|
+
if (cur !== v)
|
|
3426
|
+
el.setAttribute(name, v);
|
|
3427
|
+
}
|
|
3428
|
+
ensureGroup(mapEl, title, basemapid, visible, index) {
|
|
3429
|
+
let el = Array.from(mapEl.children).find(ch => ch.tagName.toLowerCase() === 'v-map-layergroup' &&
|
|
3430
|
+
ch.getAttribute('group-title') === title);
|
|
3431
|
+
if (!el) {
|
|
3432
|
+
el = document.createElement('v-map-layergroup');
|
|
3433
|
+
el.setAttribute('group-title', title);
|
|
3434
|
+
mapEl.insertBefore(el, (index != null ? mapEl.children[index] : null) || null);
|
|
3435
|
+
}
|
|
3436
|
+
this.ensureAttr(el, 'visible', visible);
|
|
3437
|
+
if (basemapid) {
|
|
3438
|
+
this.ensureAttr(el, 'basemapid', basemapid);
|
|
3439
|
+
}
|
|
3440
|
+
return el;
|
|
3441
|
+
}
|
|
3442
|
+
toKebabCase(value) {
|
|
3443
|
+
return value
|
|
3444
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
3445
|
+
.replace(/[\s_]+/g, '-')
|
|
3446
|
+
.toLowerCase();
|
|
3447
|
+
}
|
|
3448
|
+
createLayerEl(layer) {
|
|
3449
|
+
const data = (layer.data || {});
|
|
3450
|
+
const common = {
|
|
3451
|
+
id: layer.id,
|
|
3452
|
+
visible: layer.visible,
|
|
3453
|
+
opacity: layer.opacity,
|
|
3454
|
+
'z-index': layer.zIndex,
|
|
3455
|
+
...(layer.style ? { style: JSON.stringify(layer.style) } : {}),
|
|
3456
|
+
};
|
|
3457
|
+
const add = (attribute, value, opts) => {
|
|
3458
|
+
if (value === undefined || value === null)
|
|
3459
|
+
return;
|
|
3460
|
+
if (opts?.json && typeof value !== 'string') {
|
|
3461
|
+
try {
|
|
3462
|
+
common[attribute] = JSON.stringify(value);
|
|
3463
|
+
}
|
|
3464
|
+
catch {
|
|
3465
|
+
common[attribute] = String(value);
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
else {
|
|
3469
|
+
common[attribute] = value;
|
|
3470
|
+
}
|
|
3471
|
+
};
|
|
3472
|
+
let el;
|
|
3473
|
+
switch (layer.type) {
|
|
3474
|
+
case 'osm':
|
|
3475
|
+
el = document.createElement('v-map-layer-osm');
|
|
3476
|
+
break;
|
|
3477
|
+
case 'wms':
|
|
3478
|
+
case 'wms-tiled': {
|
|
3479
|
+
el = document.createElement('v-map-layer-wms');
|
|
3480
|
+
add('url', layer.url ?? data.url);
|
|
3481
|
+
add('layers', layer.layers ?? data.layers);
|
|
3482
|
+
const tiledValue = layer.type === 'wms-tiled'
|
|
3483
|
+
? true
|
|
3484
|
+
: data.tiled ?? layer.tiled ?? undefined;
|
|
3485
|
+
add('tiled', tiledValue);
|
|
3486
|
+
add('styles', data.styles);
|
|
3487
|
+
add('format', data.format);
|
|
3488
|
+
add('transparent', data.transparent);
|
|
3489
|
+
add('version', data.version);
|
|
3490
|
+
add('time', data.time);
|
|
3491
|
+
if (data.params)
|
|
3492
|
+
add('params', typeof data.params === 'string'
|
|
3493
|
+
? data.params
|
|
3494
|
+
: JSON.stringify(data.params));
|
|
3495
|
+
break;
|
|
3496
|
+
}
|
|
3497
|
+
case 'geojson': {
|
|
3498
|
+
el = document.createElement('v-map-layer-geojson');
|
|
3499
|
+
add('url', layer.url ?? data.url);
|
|
3500
|
+
const geojsonPayload = data.geojson ?? data.data;
|
|
3501
|
+
if (geojsonPayload !== undefined) {
|
|
3502
|
+
add('geojson', typeof geojsonPayload === 'string'
|
|
3503
|
+
? geojsonPayload
|
|
3504
|
+
: JSON.stringify(geojsonPayload));
|
|
3505
|
+
}
|
|
3506
|
+
add('fill-color', data.fillColor);
|
|
3507
|
+
add('fill-opacity', data.fillOpacity);
|
|
3508
|
+
add('stroke-color', data.strokeColor);
|
|
3509
|
+
add('stroke-width', data.strokeWidth);
|
|
3510
|
+
add('stroke-opacity', data.strokeOpacity);
|
|
3511
|
+
add('point-radius', data.pointRadius);
|
|
3512
|
+
add('point-color', data.pointColor);
|
|
3513
|
+
add('icon-url', data.iconUrl);
|
|
3514
|
+
add('icon-size', data.iconSize);
|
|
3515
|
+
add('text-property', data.textProperty);
|
|
3516
|
+
add('text-color', data.textColor);
|
|
3517
|
+
add('text-size', data.textSize);
|
|
3518
|
+
break;
|
|
3519
|
+
}
|
|
3520
|
+
case 'xyz': {
|
|
3521
|
+
el = document.createElement('v-map-layer-xyz');
|
|
3522
|
+
add('url', layer.url ?? data.url);
|
|
3523
|
+
add('attributions', data.attributions);
|
|
3524
|
+
add('max-zoom', data.maxZoom);
|
|
3525
|
+
add('tile-size', data.tileSize);
|
|
3526
|
+
add('subdomains', data.subdomains);
|
|
3527
|
+
break;
|
|
3528
|
+
}
|
|
3529
|
+
case 'terrain': {
|
|
3530
|
+
el = document.createElement('v-map-layer-terrain');
|
|
3531
|
+
add('elevation-data', data.elevationData);
|
|
3532
|
+
add('texture', data.texture);
|
|
3533
|
+
if (data.elevationDecoder)
|
|
3534
|
+
add('elevation-decoder', data.elevationDecoder, { json: typeof data.elevationDecoder !== 'string' });
|
|
3535
|
+
add('wireframe', data.wireframe);
|
|
3536
|
+
if (data.color) {
|
|
3537
|
+
add('color', Array.isArray(data.color) ? JSON.stringify(data.color) : data.color);
|
|
3538
|
+
}
|
|
3539
|
+
add('min-zoom', data.minZoom);
|
|
3540
|
+
add('max-zoom', data.maxZoom);
|
|
3541
|
+
add('mesh-max-error', data.meshMaxError);
|
|
3542
|
+
break;
|
|
3543
|
+
}
|
|
3544
|
+
case 'wfs': {
|
|
3545
|
+
el = document.createElement('v-map-layer-wfs');
|
|
3546
|
+
add('url', data.url ?? layer.url);
|
|
3547
|
+
add('type-name', data.typeName);
|
|
3548
|
+
add('version', data.version);
|
|
3549
|
+
add('output-format', data.outputFormat);
|
|
3550
|
+
add('srs-name', data.srsName);
|
|
3551
|
+
if (data.params)
|
|
3552
|
+
add('params', typeof data.params === 'string'
|
|
3553
|
+
? data.params
|
|
3554
|
+
: JSON.stringify(data.params));
|
|
3555
|
+
break;
|
|
3556
|
+
}
|
|
3557
|
+
case 'wcs': {
|
|
3558
|
+
el = document.createElement('v-map-layer-wcs');
|
|
3559
|
+
add('url', data.url ?? layer.url);
|
|
3560
|
+
add('coverage-name', data.coverageName);
|
|
3561
|
+
add('format', data.format);
|
|
3562
|
+
add('version', data.version);
|
|
3563
|
+
add('projection', data.projection);
|
|
3564
|
+
if (data.resolutions)
|
|
3565
|
+
add('resolutions', typeof data.resolutions === 'string'
|
|
3566
|
+
? data.resolutions
|
|
3567
|
+
: JSON.stringify(data.resolutions));
|
|
3568
|
+
if (data.params)
|
|
3569
|
+
add('params', typeof data.params === 'string'
|
|
3570
|
+
? data.params
|
|
3571
|
+
: JSON.stringify(data.params));
|
|
3572
|
+
break;
|
|
3573
|
+
}
|
|
3574
|
+
case 'google': {
|
|
3575
|
+
el = document.createElement('v-map-layer-google');
|
|
3576
|
+
add('api-key', data.apiKey);
|
|
3577
|
+
add('map-type', data.mapType);
|
|
3578
|
+
add('language', data.language);
|
|
3579
|
+
add('region', data.region);
|
|
3580
|
+
add('scale', data.scale);
|
|
3581
|
+
add('libraries', data.libraries);
|
|
3582
|
+
add('max-zoom', data.maxZoom);
|
|
3583
|
+
if (data.styles)
|
|
3584
|
+
add('styles', typeof data.styles === 'string'
|
|
3585
|
+
? data.styles
|
|
3586
|
+
: JSON.stringify(data.styles));
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3589
|
+
case 'geotiff': {
|
|
3590
|
+
el = document.createElement('v-map-layer-geotiff');
|
|
3591
|
+
add('url', layer.url ?? data.url);
|
|
3592
|
+
break;
|
|
3593
|
+
}
|
|
3594
|
+
case 'tile3d': {
|
|
3595
|
+
el = document.createElement('v-map-layer-tile3d');
|
|
3596
|
+
add('url', layer.url ?? data.url);
|
|
3597
|
+
if (data.tilesetOptions)
|
|
3598
|
+
add('tileset-options', typeof data.tilesetOptions === 'string'
|
|
3599
|
+
? data.tilesetOptions
|
|
3600
|
+
: JSON.stringify(data.tilesetOptions));
|
|
3601
|
+
break;
|
|
3602
|
+
}
|
|
3603
|
+
case 'scatterplot': {
|
|
3604
|
+
el = document.createElement('v-map-layer-scatterplot');
|
|
3605
|
+
add('url', data.url);
|
|
3606
|
+
if (data.data)
|
|
3607
|
+
add('data', typeof data.data === 'string'
|
|
3608
|
+
? data.data
|
|
3609
|
+
: JSON.stringify(data.data));
|
|
3610
|
+
add('get-fill-color', data.getFillColor);
|
|
3611
|
+
add('get-radius', data.getRadius);
|
|
3612
|
+
break;
|
|
3613
|
+
}
|
|
3614
|
+
case 'wkt': {
|
|
3615
|
+
el = document.createElement('v-map-layer-wkt');
|
|
3616
|
+
if (data.wkt)
|
|
3617
|
+
add('wkt', typeof data.wkt === 'string' ? data.wkt : JSON.stringify(data.wkt));
|
|
3618
|
+
add('url', data.url);
|
|
3619
|
+
add('fill-color', data.fillColor);
|
|
3620
|
+
add('fill-opacity', data.fillOpacity);
|
|
3621
|
+
add('stroke-color', data.strokeColor);
|
|
3622
|
+
add('stroke-width', data.strokeWidth);
|
|
3623
|
+
add('stroke-opacity', data.strokeOpacity);
|
|
3624
|
+
add('point-radius', data.pointRadius);
|
|
3625
|
+
add('point-color', data.pointColor);
|
|
3626
|
+
add('icon-url', data.iconUrl);
|
|
3627
|
+
add('icon-size', data.iconSize);
|
|
3628
|
+
add('text-property', data.textProperty);
|
|
3629
|
+
add('text-color', data.textColor);
|
|
3630
|
+
add('text-size', data.textSize);
|
|
3631
|
+
break;
|
|
3632
|
+
}
|
|
3633
|
+
default: {
|
|
3634
|
+
el = document.createElement('v-map-layer-custom');
|
|
3635
|
+
el.setAttribute('type', layer.type);
|
|
3636
|
+
if (data && typeof data === 'object') {
|
|
3637
|
+
for (const [key, value] of Object.entries(data)) {
|
|
3638
|
+
add(this.toKebabCase(key), typeof value === 'object' && value !== null
|
|
3639
|
+
? JSON.stringify(value)
|
|
3640
|
+
: value);
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
for (const [key, value] of Object.entries(common)) {
|
|
3646
|
+
this.ensureAttr(el, key, value);
|
|
3647
|
+
}
|
|
3648
|
+
return el;
|
|
3649
|
+
}
|
|
3650
|
+
patchLayer(el, patch, next) {
|
|
3651
|
+
for (const [field, change] of Object.entries(patch)) {
|
|
3652
|
+
const nv = change.new;
|
|
3653
|
+
switch (field) {
|
|
3654
|
+
case 'visible':
|
|
3655
|
+
this.ensureAttr(el, 'visible', nv);
|
|
3656
|
+
break;
|
|
3657
|
+
case 'opacity':
|
|
3658
|
+
this.ensureAttr(el, 'opacity', nv);
|
|
3659
|
+
break;
|
|
3660
|
+
case 'zIndex':
|
|
3661
|
+
this.ensureAttr(el, 'z-index', nv);
|
|
3662
|
+
break;
|
|
3663
|
+
case 'url':
|
|
3664
|
+
this.ensureAttr(el, 'url', nv);
|
|
3665
|
+
break;
|
|
3666
|
+
case 'layers':
|
|
3667
|
+
this.ensureAttr(el, 'layers', nv);
|
|
3668
|
+
break;
|
|
3669
|
+
case 'tiled':
|
|
3670
|
+
this.ensureAttr(el, 'tiled', nv);
|
|
3671
|
+
break;
|
|
3672
|
+
case 'style':
|
|
3673
|
+
this.ensureAttr(el, 'style', nv ? JSON.stringify(nv) : undefined);
|
|
3674
|
+
break;
|
|
3675
|
+
case 'data':
|
|
3676
|
+
if ([
|
|
3677
|
+
'terrain',
|
|
3678
|
+
'wfs',
|
|
3679
|
+
'wcs',
|
|
3680
|
+
'wms',
|
|
3681
|
+
'wms-tiled',
|
|
3682
|
+
'geojson',
|
|
3683
|
+
'xyz',
|
|
3684
|
+
'google',
|
|
3685
|
+
'tile3d',
|
|
3686
|
+
'scatterplot',
|
|
3687
|
+
'wkt',
|
|
3688
|
+
].includes(next.type)) {
|
|
3689
|
+
const parent = el.parentElement;
|
|
3690
|
+
const newEl = this.createLayerEl(next);
|
|
3691
|
+
parent.replaceChild(newEl, el);
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3694
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- custom web component method not in DOM typings
|
|
3695
|
+
el.setData?.(nv);
|
|
3696
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- custom web component method not in DOM typings
|
|
3697
|
+
if (!el.setData) {
|
|
3698
|
+
const s = typeof nv === 'object' ? JSON.stringify(nv) : nv;
|
|
3699
|
+
this.ensureAttr(el, 'data', s);
|
|
3700
|
+
}
|
|
3701
|
+
break;
|
|
3702
|
+
case 'type':
|
|
3703
|
+
const parent = el.parentElement;
|
|
3704
|
+
const newEl = this.createLayerEl(next);
|
|
3705
|
+
parent.replaceChild(newEl, el);
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
applyDiff(_prev, next) {
|
|
3711
|
+
const container = this.hostEl;
|
|
3712
|
+
let mapEl = Array.from(container.children).find(ch => ch.tagName.toLowerCase() === 'v-map');
|
|
3713
|
+
if (!mapEl) {
|
|
3714
|
+
mapEl = document.createElement('v-map');
|
|
3715
|
+
container.appendChild(mapEl);
|
|
3716
|
+
}
|
|
3717
|
+
this.ensureAttr(mapEl, 'flavour', next.map.flavour);
|
|
3718
|
+
this.ensureAttr(mapEl, 'id', next.map.id);
|
|
3719
|
+
this.ensureAttr(mapEl, 'zoom', String(next.map.zoom));
|
|
3720
|
+
this.ensureAttr(mapEl, 'center', next.map.center);
|
|
3721
|
+
this.ensureAttr(mapEl, 'style', next.map.style);
|
|
3722
|
+
this.syncStyles(mapEl, next.map.styles || []);
|
|
3723
|
+
const nextTitles = new Set(next.map.layerGroups.map(g => g.groupTitle));
|
|
3724
|
+
Array.from(mapEl.children).forEach(ch => {
|
|
3725
|
+
if (ch.tagName.toLowerCase() !== 'v-map-layergroup')
|
|
3726
|
+
return;
|
|
3727
|
+
const t = ch.getAttribute('group-title') || '';
|
|
3728
|
+
if (!nextTitles.has(t))
|
|
3729
|
+
mapEl.removeChild(ch);
|
|
3730
|
+
});
|
|
3731
|
+
next.map.layerGroups.forEach((group, gi) => {
|
|
3732
|
+
const groupEl = this.ensureGroup(mapEl, group.groupTitle, group.basemapid, group.visible, gi);
|
|
3733
|
+
const oldLayers = [];
|
|
3734
|
+
Array.from(groupEl.children).forEach(ch => {
|
|
3735
|
+
const id = ch.getAttribute('id') || '';
|
|
3736
|
+
const type = ch.tagName
|
|
3737
|
+
.toLowerCase()
|
|
3738
|
+
.replace('v-map-layer-', '');
|
|
3739
|
+
oldLayers.push({ id, type });
|
|
3740
|
+
});
|
|
3741
|
+
const { removed, updated, moved } = diffLayers(oldLayers, group.layers);
|
|
3742
|
+
for (const r of removed) {
|
|
3743
|
+
const el = Array.from(groupEl.children).find(ch => ch.getAttribute('id') === r.id);
|
|
3744
|
+
if (el)
|
|
3745
|
+
groupEl.removeChild(el);
|
|
3746
|
+
}
|
|
3747
|
+
for (const m of moved) {
|
|
3748
|
+
const el = Array.from(groupEl.children).find(ch => ch.getAttribute('id') === m.id);
|
|
3749
|
+
if (el)
|
|
3750
|
+
groupEl.insertBefore(el, groupEl.children[m.to] || null);
|
|
3751
|
+
}
|
|
3752
|
+
for (const u of updated) {
|
|
3753
|
+
const el = Array.from(groupEl.children).find(ch => ch.getAttribute('id') === u.id);
|
|
3754
|
+
if (!el)
|
|
3755
|
+
continue;
|
|
3756
|
+
const nextLayer = group.layers.find(l => l.id === u.id);
|
|
3757
|
+
this.patchLayer(el, u.changes, nextLayer);
|
|
3758
|
+
}
|
|
3759
|
+
group.layers.forEach((l, idx) => {
|
|
3760
|
+
const exists = Array.from(groupEl.children).some(ch => ch.getAttribute('id') === l.id);
|
|
3761
|
+
if (!exists) {
|
|
3762
|
+
const el = this.createLayerEl(l);
|
|
3763
|
+
groupEl.insertBefore(el, groupEl.children[idx] || null);
|
|
3764
|
+
}
|
|
3765
|
+
});
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
onSlotChange = () => {
|
|
3769
|
+
messages.log(MSG_COMPONENT + 'onSlotChange');
|
|
3770
|
+
this.parseFromSlot();
|
|
3771
|
+
//this.observeAssignedNodes();
|
|
3772
|
+
//this.readGeoJsonFromSlot();
|
|
3773
|
+
};
|
|
3774
|
+
render() {
|
|
3775
|
+
messages.log(MSG_COMPONENT + messages.MESSAGES.COMPONENT_RENDER);
|
|
3776
|
+
return (index.h("div", { key: '0e041d9d068e0b31b1d1245888e8aa3668b22625', class: "root" }, index.h("slot", { key: '0141bfb2be32531f9673bc8d0759943dd7ac63b1', name: "mapconfig", onSlotchange: this.onSlotChange }), index.h("slot", { key: '2df1c8fe43ea7ee4db3fc57875f0cec126b1fa97' })));
|
|
3777
|
+
}
|
|
3778
|
+
static get watchers() { return {
|
|
3779
|
+
"mapconfig": [{
|
|
3780
|
+
"onMapConfigChanged": 0
|
|
3781
|
+
}]
|
|
3782
|
+
}; }
|
|
3783
|
+
};
|
|
3784
|
+
VMapBuilder.style = vMapBuilderCss();
|
|
3785
|
+
|
|
3786
|
+
exports.v_map_builder = VMapBuilder;
|