@chrtco/sdk 0.10.55 → 0.10.57
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/CHANGELOG.md +38 -8
- package/README.md +31 -10
- package/dist/atlas/browser.cjs +5 -21
- package/dist/atlas/browser.cjs.map +1 -1
- package/dist/atlas/browser.js +5 -21
- package/dist/atlas/browser.js.map +1 -1
- package/dist/index.cjs +347 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2467 -2173
- package/dist/index.d.ts +2467 -2173
- package/dist/index.js +326 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,8 +7,16 @@ All notable changes to `@chrtco/sdk` will be documented in this file.
|
|
|
7
7
|
### Changed
|
|
8
8
|
- **The paper-chart symbol family is `int1`, "INT-1"**, after the standard it draws (IHO INT 1);
|
|
9
9
|
it was `raster`, "CHRTraster". `SymbolFamily` is `"s52" | "s101" | "chrt" | "int1"` and
|
|
10
|
-
`SYMBOL_FAMILIES` lists `int1`. The style records `chrt:symbol-set: "int1"
|
|
11
|
-
`CHRT INT-1
|
|
10
|
+
`SYMBOL_FAMILIES` lists `int1`. The style records `chrt:symbol-set: "int1"`, is named
|
|
11
|
+
`CHRT INT-1 …` and declares INT-1's own sheet, `int1-{palette}`. The old `raster-{palette}` sheets
|
|
12
|
+
are still served, as the same sheets.
|
|
13
|
+
- **Every family and look declares the sheet that holds what it draws.** `uschart1` declares
|
|
14
|
+
`uschart1-{palette}` (INT-1's artwork and the marks in that palette's ink), and a look declares
|
|
15
|
+
`{family}-look_{look}` (the family's day sheet for `paper`, its black & white sheet for the
|
|
16
|
+
engravings, plus every image the look paints), so MapLibre Native draws them from the style alone.
|
|
17
|
+
`withLook` used to swap `-day` for `-eink_mono`.
|
|
18
|
+
- **`generateCustomStyle` draws a `look` over DAY** whatever palettes the custom style curated
|
|
19
|
+
(another palette would throw), reporting `themeFellBack` when a theme was asked for.
|
|
12
20
|
|
|
13
21
|
### Added
|
|
14
22
|
- **Decorative looks: `generateStyle("DAY", { look })`**, `"paper"` (the U.S. paper chart as last
|
|
@@ -16,21 +24,43 @@ All notable changes to `@chrtco/sdk` will be documented in this file.
|
|
|
16
24
|
with the colourist's wash, laid as flat tints). Applied last; drawn over DAY only (another palette
|
|
17
25
|
throws). Moved from CHRTpaper, which draws the same looks: `withLook`, `lookImages`,
|
|
18
26
|
`CHART_LOOKS`, `parseChartLook`, `styleLook`, `LOOK_TONES`, `LOOK_FONTS`, `WASH_TONES`,
|
|
19
|
-
`WASH_TINTS`.
|
|
20
|
-
`provideChartLookImages(map)` from
|
|
27
|
+
`WASH_TINTS`. A served style finds their images on its sprite sheet; a GL JS map with a locally
|
|
28
|
+
generated style can paint them instead with `provideChartLookImages(map)` from
|
|
29
|
+
`@chrtco/sdk/atlas/browser`.
|
|
21
30
|
- **Symbol family `uschart1`, "U.S. Chart No. 1"**: INT-1 with the aids as U.S. Chart No. 1's NOAA
|
|
22
31
|
column draws them (diamond buoys with the shape in the label, filled daybeacons, magenta discs and
|
|
23
32
|
flares). By day and on e-ink by day; INT-1's artwork at dusk and night. Moved from CHRTpaper's
|
|
24
33
|
Classic Paper set: `withClassicMarks`, `classicInkFor`, `classicIconExpression`,
|
|
25
|
-
`classicMarkImages`, `usChart1ImageSpecs`.
|
|
34
|
+
`classicMarkImages`, `usChart1ImageSpecs`.
|
|
35
|
+
- **The Style API takes them:** `styleUrl({ symbols: 'int1' | 'uschart1', look })` and
|
|
36
|
+
`fetchStyle()`; `ChrtSymbolSet` gains `int1` and `uschart1`, `StyleUrlOptions.look` is new. The
|
|
37
|
+
offline style's `symbols` takes `int1` and `uschart1` too.
|
|
38
|
+
- **Chart mode's band lock, as CHRTpaper draws it: `withChartReduction(layers, floor)`.** The chart
|
|
39
|
+
drawn as at a band's floor zoom and reduced with the land below it: every size (text, icons,
|
|
40
|
+
lines, halos, px offsets) is its size at the floor times 2^(zoom − floor), every other zoom curve
|
|
41
|
+
and every filter decides as at the floor, down to `MAX_REDUCTION_LEVELS` (2) out. At and past the
|
|
42
|
+
floor the style is unchanged, and ids, order and types never change. With it: `CHART_LOCK_BANDS`
|
|
43
|
+
(Overview … Berthing and their floors), `chartLockMinZoom`, `chartLockStyleMode` (the strict
|
|
44
|
+
`chartMode` for a band-only lock; Berthing is Harbor's made strict at 6) and
|
|
45
|
+
`chartLockSourceMaxzoom` (a band-only lock's tiles held at the floor), and `chartLockDecisionZoom`
|
|
46
|
+
(a finer-data lock decides a hair under its floor, so the next band's cells are not holes in a
|
|
47
|
+
reduction whose tiles do not hold that band yet).
|
|
48
|
+
- **The band lock on a served style: the Style API's `?lock={band}` / `?lock={band}:only`** (online
|
|
49
|
+
and offline), and `styleUrl({ lock })`. `withServedChartLock(style, lock, chartSource)` locks a
|
|
50
|
+
generated style as the routes do (reduction last, over every layer; a band-only lock's chart
|
|
51
|
+
source `maxzoom` held at the floor; `chrt:lock`, `chrt:lock-band`, `chrt:lock-floor`,
|
|
52
|
+
`chrt:lock-min-zoom` and `chrt:lock-band-only` in the metadata, `chrt:render-mode` left
|
|
53
|
+
`continuous`), after generating with `chartLockGeneratorOptions(lock)`. `CHART_LOCK_PARAMS`,
|
|
54
|
+
`parseChartLock`, `chartLockParam`, `servedChartLockMetadata`. A client stops zoom-out at
|
|
55
|
+
`chrt:lock-min-zoom`: a style cannot set a map's minimum zoom. `?mode=chart:{band}` is unchanged.
|
|
26
56
|
- **`STYLE_CATALOGUE`** — every theme (`STYLE_THEMES`: day, dusk, night and the three e-ink
|
|
27
57
|
palettes), look (`STYLE_LOOKS`) and symbol family, with labels, in presentation order.
|
|
28
58
|
|
|
29
59
|
### Deprecated
|
|
30
60
|
- **`raster` as a symbol family id.** Still accepted wherever it was — `generateStyle({ symbolSet })`,
|
|
31
|
-
`parseSymbolFamily`
|
|
32
|
-
|
|
33
|
-
`
|
|
61
|
+
`parseSymbolFamily`, `ChrtSymbolSet`, the Style API's and the offline style's `symbols` — and
|
|
62
|
+
means exactly `int1`. `LEGACY_SYMBOL_FAMILY_ALIASES`, `normalizeSymbolFamily`,
|
|
63
|
+
`SymbolFamilyInput`.
|
|
34
64
|
|
|
35
65
|
### Added
|
|
36
66
|
- **`generateStyle({ dangerDepthRounding: 'down' })`** — the depth beside a rock, wreck or
|
package/README.md
CHANGED
|
@@ -212,24 +212,42 @@ await chrt.styleUrl({ symbols: 's101' }); // served — symbols, theme: 'day
|
|
|
212
212
|
| `s52` (default) | IHO S-52 Presentation Library — spec-exact ATON/LIGHTS selection |
|
|
213
213
|
| `s101` | official IHO S-101 Portrayal Catalogue artwork |
|
|
214
214
|
| `chrt` | CHRT house set — colour-true silhouettes, capability badges |
|
|
215
|
-
| `int1` | INT-1 — the IHO INT 1 symbols, as paper charts draw them
|
|
215
|
+
| `int1` | INT-1 — the IHO INT 1 symbols, as paper charts draw them |
|
|
216
|
+
| `uschart1` | U.S. Chart No. 1 — INT-1 with diamond buoys and filled daybeacons, as U.S. paper charts drew them, by day and on e-ink by day (INT-1's artwork at dusk and night) |
|
|
216
217
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
`raster` is INT-1's id before 2026-11. It is deprecated but still accepted everywhere it was,
|
|
219
|
+
local and served, and means exactly `int1`. Its sprite sheets (`/v1/sprites/raster-*`) are still
|
|
220
|
+
served, as INT-1's.
|
|
220
221
|
|
|
221
222
|
### Looks
|
|
222
223
|
|
|
223
224
|
`chrt.style({ look: 'paper' | 'engraved' | 'handcolored' })` restyles the day chart as a period
|
|
224
225
|
chart: the U.S. paper chart as last printed, the 1860s Coast Survey engraving, or the engraving
|
|
225
226
|
hand-coloured. Every danger, aid, light and sounding still draws. A look is drawn over the DAY
|
|
226
|
-
palette only.
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
palette only. The served style takes the same look as `chrt.styleUrl({ look: 'engraved' })`
|
|
228
|
+
(`?look=`; with a theme other than `day` it is a 400).
|
|
229
|
+
|
|
230
|
+
A style declares a sprite sheet that holds every image it draws: `{family}-{theme}`, or under a
|
|
231
|
+
look `{family}-look_{look}`. A GL JS map that generates its style locally can instead paint the
|
|
232
|
+
look's images (and U.S. Chart No. 1's marks) on demand: call `provideChartLookImages(map)` from
|
|
233
|
+
`@chrtco/sdk/atlas/browser` once per map. `STYLE_CATALOGUE` lists the themes (e-ink included),
|
|
234
|
+
looks and symbol families with their labels.
|
|
229
235
|
|
|
230
236
|
`s101`, `chrt` and `int1` need their images loaded at runtime via `loadS101SymbolImages` /
|
|
231
237
|
`loadChrtSymbolImages` / `loadChrtRasterSymbolImages` from `@chrtco/sdk/atlas/browser`.
|
|
232
238
|
|
|
239
|
+
### Chart mode: a locked scale band
|
|
240
|
+
|
|
241
|
+
`chrt.styleUrl({ lock: 'harbor' })` (`?lock=`) draws one scale band's chart as a printed chart of
|
|
242
|
+
that band reads: at the band's floor zoom as usual, and zoomed out of it REDUCED, every mark
|
|
243
|
+
shrinking with the land, two zoom levels out at most. `'{band}'` keeps a finer chart where one
|
|
244
|
+
exists; `'{band}:only'` draws the band alone. Bands: `overview` (floor 5) · `general` (7) ·
|
|
245
|
+
`coastal` (9) · `approach` (11) · `harbor` (13) · `berthing` (14). **Stop zoom-out at the
|
|
246
|
+
document's `metadata["chrt:lock-min-zoom"]`** (floor − 2): a style cannot set a map's minimum
|
|
247
|
+
zoom, so the client must. `withServedChartLock(style, lock, region)` applies the same lock to a
|
|
248
|
+
locally generated style (with `chartLockGeneratorOptions(lock)` spread into `chrt.style()`'s
|
|
249
|
+
options); `parseChartLock` and `CHART_LOCK_PARAMS` are the vocabulary.
|
|
250
|
+
|
|
233
251
|
### Custom styles
|
|
234
252
|
|
|
235
253
|
`chrt.style()` returns a standard MapLibre style object you can mutate. For a fully custom look,
|
|
@@ -383,8 +401,8 @@ same number. Construct a `Chrt` per user, or pass `safetyDepth` per call.
|
|
|
383
401
|
**With no `vessel`, CHRT sends no depth at all** rather than guessing a draft — filtering on an
|
|
384
402
|
invented one would silently drop real hazards.
|
|
385
403
|
|
|
386
|
-
> Not yet reachable from the *served* style: `styleUrl()` takes
|
|
387
|
-
>
|
|
404
|
+
> Not yet reachable from the *served* style: `styleUrl()` takes no safety depth, so a non-JS
|
|
405
|
+
> client cannot currently get per-user depth shading.
|
|
388
406
|
|
|
389
407
|
## API Reference
|
|
390
408
|
|
|
@@ -525,7 +543,10 @@ the other atlas style options. Non-JS clients want `styleUrl()` instead.
|
|
|
525
543
|
URL of the **served** S-52 style — the CHRTstyle Style API at
|
|
526
544
|
`{tileBaseUrl}/v1/styles/{region}/style.json`. `async`: it pre-mints the tile token so the style
|
|
527
545
|
request (which MapLibre does not retry) carries auth. Options: `theme`
|
|
528
|
-
(`'day' | 'dusk' | 'night' | 'eink_color' | 'eink_mono' | 'eink_night'`), `symbols
|
|
546
|
+
(`'day' | 'dusk' | 'night' | 'eink_color' | 'eink_mono' | 'eink_night'`), `symbols`
|
|
547
|
+
(`'s52' | 's101' | 'chrt' | 'int1' | 'uschart1'`; `'raster'` deprecated, means `'int1'`), `look`
|
|
548
|
+
(`'paper' | 'engraved' | 'handcolored'`, day only), `mode`, `lock`, `land`, `relief`, `units`. Always
|
|
549
|
+
pair with `transformRequest()`.
|
|
529
550
|
|
|
530
551
|
The served document honours the CHRTstyle custom style bound to your key (a **Dev+** feature; Free
|
|
531
552
|
keys and keys with no bound style get the default themes). This is the style path for any client that
|
package/dist/atlas/browser.cjs
CHANGED
|
@@ -19276,7 +19276,7 @@ var PIXEL_RATIO2 = 2;
|
|
|
19276
19276
|
var DB_NAME = "chrt-s52-atlas";
|
|
19277
19277
|
var DB_VERSION = 1;
|
|
19278
19278
|
var STORE_NAME = "bitmaps";
|
|
19279
|
-
var PARAM_VERSION = "
|
|
19279
|
+
var PARAM_VERSION = "v7";
|
|
19280
19280
|
function computeAtlasVersion() {
|
|
19281
19281
|
let h = 2166136261;
|
|
19282
19282
|
const mix = (s) => {
|
|
@@ -19296,24 +19296,9 @@ var ATLAS_VERSION = /* @__PURE__ */ computeAtlasVersion();
|
|
|
19296
19296
|
function makeKey(colorTable, name) {
|
|
19297
19297
|
return `${ATLAS_VERSION}:${colorTable}:${name}`;
|
|
19298
19298
|
}
|
|
19299
|
-
function
|
|
19300
|
-
|
|
19301
|
-
|
|
19302
|
-
`width="${renderSize}" height="${renderSize}"`
|
|
19303
|
-
);
|
|
19304
|
-
}
|
|
19305
|
-
function prepareSvg2(name, rawSvg, colorTable, renderSize) {
|
|
19306
|
-
const themed = applyColorTheme(rawSvg, colorTable);
|
|
19307
|
-
if (S52_LINE_SYMBOL_NAMES.has(name)) return themed;
|
|
19308
|
-
return upsampleSvg2(applyStrokeBoost(themed, S52_STROKE_BOOST), renderSize);
|
|
19309
|
-
}
|
|
19310
|
-
function rasterSize2(name, svg2) {
|
|
19311
|
-
if (S52_LINE_SYMBOL_NAMES.has(name)) {
|
|
19312
|
-
const size = readSvgSize(svg2);
|
|
19313
|
-
if (size) return size;
|
|
19314
|
-
}
|
|
19315
|
-
const square = renderSizeFor(name);
|
|
19316
|
-
return { w: square, h: square };
|
|
19299
|
+
function s52CacheRaster(name, rawSvg, colorTable) {
|
|
19300
|
+
const svg2 = prepareSvg(name, rawSvg, colorTable, renderSizeFor(name));
|
|
19301
|
+
return { svg: svg2, size: rasterSize(name, svg2) };
|
|
19317
19302
|
}
|
|
19318
19303
|
function hasIndexedDB() {
|
|
19319
19304
|
return typeof indexedDB !== "undefined";
|
|
@@ -19431,8 +19416,7 @@ async function loadS52SymbolImagesCached(map, colorTable = "DAY", opts = {}) {
|
|
|
19431
19416
|
missing.map(async (name) => {
|
|
19432
19417
|
const rawSvg = ALL_S52_SVGS[name];
|
|
19433
19418
|
if (!rawSvg) return;
|
|
19434
|
-
const themed =
|
|
19435
|
-
const size = rasterSize2(name, themed);
|
|
19419
|
+
const { svg: themed, size } = s52CacheRaster(name, rawSvg, colorTable);
|
|
19436
19420
|
const img = await decodeSvgToImage(themed, size);
|
|
19437
19421
|
if (!img) return;
|
|
19438
19422
|
if (isMapLive(map)) addImageToMap(map, name, img);
|