@bicharts/chart-host 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LWVJSMWU.mjs → chunk-C4T7RY6K.mjs} +51 -22
- package/dist/chunk-C4T7RY6K.mjs.map +7 -0
- package/dist/chunk-KZWXXNUU.mjs +9 -0
- package/dist/chunk-KZWXXNUU.mjs.map +7 -0
- package/dist/{chunk-22B22PJU.mjs → chunk-X7PWWEGM.mjs} +1 -1
- package/dist/{geoNaRegions-SAINMZXG.mjs → geo-us-states.mjs} +4 -8
- package/dist/{geoUsZip3.generated-56OL4TTZ.mjs → geo-us-zip3.mjs} +2 -2
- package/dist/geo-world.mjs +8 -0
- package/dist/geo-world.mjs.map +7 -0
- package/dist/geo.mjs +9 -9
- package/dist/geoUsZip3.generated-7KMAASNB.mjs +8 -0
- package/dist/geoUsZip3.generated-7KMAASNB.mjs.map +7 -0
- package/dist/index.mjs +8 -1
- package/dist/react.mjs +2 -1
- package/dist/react.mjs.map +1 -1
- package/dist/types/geo-us-states.d.ts +1 -0
- package/dist/types/geo-us-zip3.d.ts +1 -0
- package/dist/types/geo-world.d.ts +1 -0
- package/dist/types/geoLazy.d.ts +24 -3
- package/dist/types/index.d.ts +1 -1
- package/package.json +16 -1
- package/dist/chunk-LWVJSMWU.mjs.map +0 -7
- package/dist/chunk-MHDS4Q5G.mjs +0 -9
- package/dist/chunk-MHDS4Q5G.mjs.map +0 -7
- /package/dist/{chunk-22B22PJU.mjs.map → chunk-X7PWWEGM.mjs.map} +0 -0
- /package/dist/{geoNaRegions-SAINMZXG.mjs.map → geo-us-states.mjs.map} +0 -0
- /package/dist/{geoUsZip3.generated-56OL4TTZ.mjs.map → geo-us-zip3.mjs.map} +0 -0
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
+
import {
|
|
3
|
+
NA_ISO3,
|
|
4
|
+
NA_LAT_MAX,
|
|
5
|
+
clipFeatureToLat
|
|
6
|
+
} from "./chunk-X7PWWEGM.mjs";
|
|
2
7
|
|
|
3
8
|
// src/contract.ts
|
|
4
9
|
var HOST_CONTRACT_VERSION = "1.0.0";
|
|
@@ -75,8 +80,11 @@ function resolveOptions(p) {
|
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
// src/geoLazy.ts
|
|
78
|
-
var
|
|
79
|
-
|
|
83
|
+
var byKind = /* @__PURE__ */ new Map();
|
|
84
|
+
var byAsset = /* @__PURE__ */ new Map();
|
|
85
|
+
var _na;
|
|
86
|
+
function geoAssetFor(geoKind) {
|
|
87
|
+
if (!geoKind) return null;
|
|
80
88
|
const k = geoKind.toLowerCase();
|
|
81
89
|
if (/^country/.test(k)) return "world";
|
|
82
90
|
if (k === "north-america") return "world";
|
|
@@ -84,37 +92,55 @@ function assetFor(geoKind) {
|
|
|
84
92
|
if (k === "us-zip5") return "us-zip3";
|
|
85
93
|
return null;
|
|
86
94
|
}
|
|
95
|
+
function northAmerica(world) {
|
|
96
|
+
if (!_na) {
|
|
97
|
+
_na = {
|
|
98
|
+
type: "FeatureCollection",
|
|
99
|
+
features: world.features.filter((f) => NA_ISO3.has(f?.id) && f?.geometry && f.geometry.type !== "Point").map((f) => clipFeatureToLat(f, NA_LAT_MAX)).filter((f) => f !== null)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return _na;
|
|
103
|
+
}
|
|
104
|
+
function fromAssets(key) {
|
|
105
|
+
const asset = geoAssetFor(key);
|
|
106
|
+
if (!asset) return void 0;
|
|
107
|
+
const geo = byAsset.get(asset);
|
|
108
|
+
if (!geo) return void 0;
|
|
109
|
+
return key === "north-america" ? northAmerica(geo) : geo;
|
|
110
|
+
}
|
|
87
111
|
async function loadGeo(geoKind) {
|
|
88
112
|
if (!geoKind) return void 0;
|
|
89
113
|
const key = geoKind.toLowerCase();
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
const already = geoFromCache(key);
|
|
115
|
+
if (already) return already;
|
|
116
|
+
const asset = geoAssetFor(key);
|
|
92
117
|
if (!asset) return void 0;
|
|
93
|
-
let geo;
|
|
94
118
|
if (asset === "us-states") {
|
|
95
|
-
|
|
119
|
+
byAsset.set(asset, (await import("./geoUsStates.generated-2ZZRXWWJ.mjs")).US_STATES);
|
|
96
120
|
} else if (asset === "us-zip3") {
|
|
97
|
-
|
|
121
|
+
byAsset.set(asset, (await import("./geoUsZip3.generated-7KMAASNB.mjs")).US_ZIP3);
|
|
98
122
|
} else {
|
|
99
|
-
|
|
100
|
-
if (key === "north-america") {
|
|
101
|
-
const { NA_ISO3, NA_LAT_MAX, clipFeatureToLat } = await import("./geoNaRegions-SAINMZXG.mjs");
|
|
102
|
-
geo = {
|
|
103
|
-
type: "FeatureCollection",
|
|
104
|
-
features: WORLD_110M.features.filter((f) => NA_ISO3.has(f?.id) && f?.geometry && f.geometry.type !== "Point").map((f) => clipFeatureToLat(f, NA_LAT_MAX)).filter((f) => f !== null)
|
|
105
|
-
};
|
|
106
|
-
} else {
|
|
107
|
-
geo = WORLD_110M;
|
|
108
|
-
}
|
|
123
|
+
byAsset.set(asset, (await import("./geoWorld110m.generated-O2WOIRYY.mjs")).WORLD_110M);
|
|
109
124
|
}
|
|
110
|
-
|
|
111
|
-
return geo;
|
|
125
|
+
return fromAssets(key);
|
|
112
126
|
}
|
|
113
127
|
function geoFromCache(geoKind) {
|
|
114
|
-
|
|
128
|
+
if (!geoKind) return void 0;
|
|
129
|
+
const key = geoKind.toLowerCase();
|
|
130
|
+
return byKind.get(key) ?? fromAssets(key);
|
|
115
131
|
}
|
|
116
132
|
function registerGeo(geoKind, geo) {
|
|
117
|
-
if (geoKind && geo)
|
|
133
|
+
if (geoKind && geo) byKind.set(geoKind.toLowerCase(), geo);
|
|
134
|
+
}
|
|
135
|
+
function registerGeoAsset(asset, geo) {
|
|
136
|
+
if (!asset || !geo) return;
|
|
137
|
+
byAsset.set(asset, geo);
|
|
138
|
+
if (asset === "world") _na = void 0;
|
|
139
|
+
}
|
|
140
|
+
function clearGeoCache() {
|
|
141
|
+
byKind.clear();
|
|
142
|
+
byAsset.clear();
|
|
143
|
+
_na = void 0;
|
|
118
144
|
}
|
|
119
145
|
|
|
120
146
|
// ../shape-core/dist/chunk-U5UKZYHK.mjs
|
|
@@ -1393,12 +1419,15 @@ export {
|
|
|
1393
1419
|
COLOR_SCALE_SELF_CLAMP_PCT_MIN,
|
|
1394
1420
|
COLOR_SCALE_SELF_CLAMP_PCT_MAX,
|
|
1395
1421
|
resolveOptions,
|
|
1422
|
+
geoAssetFor,
|
|
1396
1423
|
loadGeo,
|
|
1397
1424
|
geoFromCache,
|
|
1398
1425
|
registerGeo,
|
|
1426
|
+
registerGeoAsset,
|
|
1427
|
+
clearGeoCache,
|
|
1399
1428
|
buildRenderPayload,
|
|
1400
1429
|
createMarkResolver,
|
|
1401
1430
|
compileRenderFn,
|
|
1402
1431
|
createChartHost
|
|
1403
1432
|
};
|
|
1404
|
-
//# sourceMappingURL=chunk-
|
|
1433
|
+
//# sourceMappingURL=chunk-C4T7RY6K.mjs.map
|