@tomtom-org/maps-sdk-plugin-map-theme 0.3.7 → 0.3.9
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 +140 -0
- package/README.md +1 -1
- package/dist/index.es.js +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# @tomtom-org/maps-sdk-plugin-map-theme
|
|
2
|
+
|
|
3
|
+
## 0.3.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2823](https://github.com/tomtom-internal/maps-sdk-js/pull/2823) [`d1b906f`](https://github.com/tomtom-internal/maps-sdk-js/commit/d1b906f460c33607bf9789475ad85bff339b7c3b) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The package ships its `CHANGELOG.md`, as the SDK does, so you can read what changed between two releases from `node_modules`
|
|
8
|
+
|
|
9
|
+
- [#2813](https://github.com/tomtom-internal/maps-sdk-js/pull/2813) [`c186703`](https://github.com/tomtom-internal/maps-sdk-js/commit/c1867038e9a38e300ea72e8812419204bf008e73) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - CSS `var()` cycles and runaway expansion are bounded, and every property on a cycle is invalid, as in a browser
|
|
10
|
+
|
|
11
|
+
- Image themes sample the whole image, so a wide image no longer reads only a few columns
|
|
12
|
+
|
|
13
|
+
## 0.3.8
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#2803](https://github.com/tomtom-internal/maps-sdk-js/pull/2803) [`1a62c72`](https://github.com/tomtom-internal/maps-sdk-js/commit/1a62c72eb372d037397bb88485ea731763f3e554) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The README links the repository's security policy page, which sends a vulnerability report to TomTom's HackerOne program
|
|
18
|
+
|
|
19
|
+
## 0.3.7
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#2742](https://github.com/tomtom-internal/maps-sdk-js/pull/2742) [`2fcc1ab`](https://github.com/tomtom-internal/maps-sdk-js/commit/2fcc1abc07bcdf89aff3942ff1207637ed00f419) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The `license` field reads `SEE LICENSE IN LICENSE.txt`, the form npm and license scanners recognise, so they point to the package's own `LICENSE.txt` instead of reporting an unknown license
|
|
24
|
+
|
|
25
|
+
- [#2730](https://github.com/tomtom-internal/maps-sdk-js/pull/2730) [`2869cd2`](https://github.com/tomtom-internal/maps-sdk-js/commit/2869cd2ce72d7e9a781a12561dca47683264c0da) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - map-theme: `deriveMapColors` picks `land` by OKLCH chroma and from the theme's side of mid-lightness, so a cream stays the land of a light theme and a navy the land of a dark one
|
|
26
|
+
|
|
27
|
+
- map-theme: a colour of OKLCH chroma 0.08 or less can be `land`, where an HSL saturation of 0.4 or less was the bar, which left out pale creams HSL rates as saturated and gave their light themes a dark grey land
|
|
28
|
+
- map-theme: a dark theme takes a dark colour as `land` before a light neutral, and a light theme a light colour before a dark neutral
|
|
29
|
+
|
|
30
|
+
- [#2734](https://github.com/tomtom-internal/maps-sdk-js/pull/2734) [`9a12d95`](https://github.com/tomtom-internal/maps-sdk-js/commit/9a12d95c22e60e69fb1891237344ca259aa236a5) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - Installs beside `@tomtom-org/maps-sdk` 1.0.0 and every later 1.x release: the peer range on the SDK runs up to `<2.0.0` instead of stopping below 1.0.0
|
|
31
|
+
|
|
32
|
+
- [#2697](https://github.com/tomtom-internal/maps-sdk-js/pull/2697) [`3d9c9a3`](https://github.com/tomtom-internal/maps-sdk-js/commit/3d9c9a34b897cf8eb791096620ed3e18dead1966) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The package page on npm and the API reference of its entry points say the plugin is in Public Preview until its 1.0.0 release, as its guides already do
|
|
33
|
+
|
|
34
|
+
## 0.3.6
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- [#2693](https://github.com/tomtom-internal/maps-sdk-js/pull/2693) [`db69794`](https://github.com/tomtom-internal/maps-sdk-js/commit/db69794e00011a820e2046a161e5390d07b8bb7a) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - Plugins are side-effect free, so your bundler drops every part of a plugin your app doesn't use
|
|
39
|
+
|
|
40
|
+
- Each plugin declares `"sideEffects": false`, and its knob catalogue and other module-level tables are dropped when nothing reads them
|
|
41
|
+
- flyover takes `@turf/turf` as a peer dependency, the copy the SDK already requires, instead of bundling its own
|
|
42
|
+
- The plugins' bundles keep their module-level names, as the SDK's do, so Sandpack and builds that transpile `node_modules` with Babel run their loops correctly
|
|
43
|
+
|
|
44
|
+
## 0.3.5
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- [#2590](https://github.com/tomtom-internal/maps-sdk-js/pull/2590) [`75fb3ea`](https://github.com/tomtom-internal/maps-sdk-js/commit/75fb3eab4d38b2aad8f4f671c3fd84f78ffc19f3) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - license: the privacy clause of `LICENSE.txt` now links the TomTom Privacy Policy, https://www.tomtom.com/privacy/
|
|
49
|
+
|
|
50
|
+
- [#2614](https://github.com/tomtom-internal/maps-sdk-js/pull/2614) [`fe596fc`](https://github.com/tomtom-internal/maps-sdk-js/commit/fe596fcb2d1c5a05dddb77547f48debc1b856a12) Thanks [@JulianChinAFoeng-TomTom](https://github.com/JulianChinAFoeng-TomTom)! - tests: each package's unit test run now fails when its coverage drops below the goals in `TESTING.md`
|
|
51
|
+
|
|
52
|
+
## 0.3.4
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- [#2522](https://github.com/tomtom-internal/maps-sdk-js/pull/2522) [`9f01f52`](https://github.com/tomtom-internal/maps-sdk-js/commit/9f01f52ee6f5a4ca23a2a44586c6cfac3595937f) Thanks [@AlvaroGraca-TomTom](https://github.com/AlvaroGraca-TomTom)! - No code change: this version is on the `latest` npm tag, which the previous one missed
|
|
57
|
+
|
|
58
|
+
## 0.3.3
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- [#2519](https://github.com/tomtom-internal/maps-sdk-js/pull/2519) [`7b854b3`](https://github.com/tomtom-internal/maps-sdk-js/commit/7b854b30bc25fdac5d9afe1975d6961a0bb137f5) Thanks [@AlvaroGraca-TomTom](https://github.com/AlvaroGraca-TomTom)! - No code change: this version is on the `latest` npm tag, which the previous one missed
|
|
63
|
+
|
|
64
|
+
## 0.3.2
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- [#2517](https://github.com/tomtom-internal/maps-sdk-js/pull/2517) [`49611d0`](https://github.com/tomtom-internal/maps-sdk-js/commit/49611d0ac91dc0b584e3d059d1f654208bdead6c) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The README's install line adds the `culori` peer dependency, and its quickstart links the SDK setup it starts from
|
|
69
|
+
|
|
70
|
+
## 0.3.1
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- [#2506](https://github.com/tomtom-internal/maps-sdk-js/pull/2506) [`12099bd`](https://github.com/tomtom-internal/maps-sdk-js/commit/12099bdc040f3ce2d3990266bfb42024cda7956c) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The package ships without source maps, so a stack trace through the plugin points into its minified bundle
|
|
75
|
+
- An app's own source maps still lead a trace to the plugin's frames (`dist/index.es.js:1:2345`); share such a trace in a report and TomTom maps it back to the source
|
|
76
|
+
|
|
77
|
+
- [#2507](https://github.com/tomtom-internal/maps-sdk-js/pull/2507) [`9ab7e7c`](https://github.com/tomtom-internal/maps-sdk-js/commit/9ab7e7c4e5e97950f9c6ba06ff228ac99393a3d4) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - **Breaking:** map: each standard style ID is the Orbis style it loads, in camelCase
|
|
78
|
+
- map: `standardLight`, `standardDark`, `drivingLight`, `drivingDark` and `satellite` are `streetLight`, `streetDark`, `streetLightDriving`, `streetDarkDriving` and `streetSatellite`; `monoLight` and `monoDark` stay
|
|
79
|
+
- agent-toolkit: `setMapStandardStyle` takes the new IDs, `resetState` reverts to `streetLight`, and the plugin needs SDK 1.0.0-rc.0
|
|
80
|
+
- map-theme, landmarks-3d: their docs name the new IDs
|
|
81
|
+
|
|
82
|
+
## 0.3.0
|
|
83
|
+
|
|
84
|
+
### Minor Changes
|
|
85
|
+
|
|
86
|
+
- [#2477](https://github.com/tomtom-internal/maps-sdk-js/pull/2477) [`5b00d34`](https://github.com/tomtom-internal/maps-sdk-js/commit/5b00d34ea25ef436fe6ae53fa46b986837e4fcf7) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - **Breaking:** map: a shape's edge is its outline and a label's is its halo, in every module
|
|
87
|
+
- map: the map colour `labelOutline` is `labelHalo`, knob id `colors.labelHalo`
|
|
88
|
+
- map: PlacesModule `cluster.badge.strokeColor` and `strokeWidth` are `outlineColor` and `outlineWidth`, knob ids `cluster.badge.outlineColor` and `cluster.badge.outlineWidth`
|
|
89
|
+
- map-theme: `deriveMapColors`, `deriveMapColorsFromCss` and `deriveMapColorsFromImage` return `labelHalo` in place of `labelOutline`, and need SDK 0.64.0
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies:
|
|
94
|
+
- @tomtom-org/maps-sdk@0.64.0
|
|
95
|
+
|
|
96
|
+
## 0.2.3
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- [#2466](https://github.com/tomtom-internal/maps-sdk-js/pull/2466) [`9959fff`](https://github.com/tomtom-internal/maps-sdk-js/commit/9959fffc945a70012a8f8c6b2cbd69ce46cbf274) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - map-theme: the docs point the derived colours at `StylingFoundationsModule.setMapColors`, the module's new name
|
|
101
|
+
- Updated dependencies:
|
|
102
|
+
- @tomtom-org/maps-sdk@0.63.0
|
|
103
|
+
|
|
104
|
+
## 0.2.2
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- [#2413](https://github.com/tomtom-internal/maps-sdk-js/pull/2413) [`94e5baa`](https://github.com/tomtom-internal/maps-sdk-js/commit/94e5baaf8399ac8acf62266a8b707f45ac6e4db0) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - `LICENSE.txt` is the SDK's current license agreement, the same file `@tomtom-org/maps-sdk` ships, in place of the 29 May 2026 version
|
|
109
|
+
|
|
110
|
+
- [#2413](https://github.com/tomtom-internal/maps-sdk-js/pull/2413) [`94e5baa`](https://github.com/tomtom-internal/maps-sdk-js/commit/94e5baaf8399ac8acf62266a8b707f45ac6e4db0) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - The README points to `LICENSE.txt`, as the other plugins' READMEs do
|
|
111
|
+
- Updated dependencies:
|
|
112
|
+
- @tomtom-org/maps-sdk@0.61.0
|
|
113
|
+
|
|
114
|
+
## 0.2.1
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- [#2369](https://github.com/tomtom-internal/maps-sdk-js/pull/2369) [`eff4132`](https://github.com/tomtom-internal/maps-sdk-js/commit/eff413219167de194d83e26e38b2e50ab750009c) Thanks [@AlvaroGraca-TomTom](https://github.com/AlvaroGraca-TomTom)! - The API reference of `deriveMapColorsFromCss` and `deriveMapColorsFromImage` carries a usage example, and the guide names the inputs that make them throw
|
|
119
|
+
|
|
120
|
+
## 0.2.0
|
|
121
|
+
|
|
122
|
+
### Minor Changes
|
|
123
|
+
|
|
124
|
+
- [#2101](https://github.com/tomtom-internal/maps-sdk-js/pull/2101) [`f066146`](https://github.com/tomtom-internal/maps-sdk-js/commit/f066146bed70481f8bb3c705b808bda634b7b905) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)!
|
|
125
|
+
|
|
126
|
+
- **Breaking:** `deriveMapColors`, `deriveMapColorsFromCss` and `deriveMapColorsFromImage` return `accent`, which `setMapColors` rejects before `@tomtom-org/maps-sdk` 0.59.0
|
|
127
|
+
- `deriveMapColors`, `deriveMapColorsFromCss` and `deriveMapColorsFromImage` derive `accent`, the colour routes, geometries and place pins take: the most colourful colour left that reads 3:1 on land and sits 30° of hue from the major roads, else their complement
|
|
128
|
+
- The peer dependency on `@tomtom-org/maps-sdk` is the range `>=0.59.0 <1.0.0`, the first release with the accent
|
|
129
|
+
|
|
130
|
+
## 0.1.0
|
|
131
|
+
|
|
132
|
+
### Minor Changes
|
|
133
|
+
|
|
134
|
+
- [#2257](https://github.com/tomtom-internal/maps-sdk-js/pull/2257) [`a1db8f2`](https://github.com/tomtom-internal/maps-sdk-js/commit/a1db8f2899bca6036c00ac135973e03ec31a53b2) Thanks [@AlvaroGraca-TomTom](https://github.com/AlvaroGraca-TomTom)! - First release: theme a TomTomMap from a brand's colours, a website's, a described mood, an artist's palette or an image, by assigning them to the SDK's ten map colours ([#2094](https://github.com/tomtom-internal/maps-sdk-js/issues/2094))
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- [#2094](https://github.com/tomtom-internal/maps-sdk-js/pull/2094) [`ddd6a97`](https://github.com/tomtom-internal/maps-sdk-js/commit/ddd6a9749bc140ba90fbc6abf8e6bf648b64db9a) Thanks [@DanielForniessoria-TomTom](https://github.com/DanielForniessoria-TomTom)! - New plugin: `deriveMapColors` assigns a few colours (a brand, a website, an artist, a mood) to the ten map colours, `deriveMapColorsFromCss` does it from the colours a stylesheet paints with most (`cssColors`), and `deriveMapColorsFromImage` from an image's `dominantColors`; apply the result with `styling.setMapColors`, after switching to the style `mapColorsLightDark` names light or dark
|
|
139
|
+
- Updated dependencies:
|
|
140
|
+
- @tomtom-org/maps-sdk@0.58.0
|
package/README.md
CHANGED
|
@@ -44,4 +44,4 @@ See `LICENSE.txt`.
|
|
|
44
44
|
|
|
45
45
|
## Security
|
|
46
46
|
|
|
47
|
-
To report a security vulnerability, follow [
|
|
47
|
+
To report a security vulnerability, follow our [security policy](https://github.com/tomtom-international/maps-sdk-js/security/policy), which keeps it private.
|
package/dist/index.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clampRgb,differenceEuclidean,differenceHueNaive,formatHex,modeHsl,modeLrgb,modeOklab,modeOklch,modeRgb,parse,useMode,wcagContrast,wcagLuminance}from"culori/fn";import{formatStyleHsl,hueDistance,toHsl}from"@tomtom-org/maps-sdk/map";useMode(modeRgb),useMode(modeLrgb),useMode(modeHsl),useMode(modeOklab);var toOklch=useMode(modeOklch),oklabDistance=/* @__PURE__ */differenceEuclidean("oklab"),isSameColor=(e,t)=>oklabDistance(e,t)<.035,rgbFromBytes=([e,t,o])=>({mode:"rgb",r:e/255,g:t/255,b:o/255}),mapThemeModes=["light","dark","auto"],schemeMarker=(e,t)=>new RegExp(String.raw`prefers-color-scheme\s*:\s*${e}|\.(?:theme-)?${e}(?:-(?:mode|theme))?(?![\w-])|\[data-[\w-]+=["']?${e}["']?\]`,t),COLOR_SCHEMES=["light","dark"],SCHEME_MARKERS={light:/* @__PURE__ */schemeMarker("light","i"),dark:/* @__PURE__ */schemeMarker("dark","i")},ANY_SCHEME_MARKER=/* @__PURE__ */schemeMarker("(?:light|dark)","gi"),PAGE_ROOT=/^(?:(?::root|html|body)\s*)+$/,PAGE_BACKGROUND=/^background(-color)?$/,NON_PAINTING_TEXT=/url\((?:"[^"]*"|'[^']*'|[^)]*)\)|"[^"]*"|'[^']*'/gi,HEX_COLOR=/#[\da-f]{3,8}\b/,COLOR_FUNCTION=/\b(?:rgba?|hsla?|oklab|oklch)\([^()]*\)/,COLOR_NAME=/\b[a-z]+\b/,COLOR_TOKEN=/* @__PURE__ */(()=>new RegExp([HEX_COLOR,COLOR_FUNCTION,COLOR_NAME].map(({source:e})=>e).join("|"),"i"))(),COLOR_TOKENS=/* @__PURE__ */new RegExp(COLOR_TOKEN,"gi"),VARIABLE_REFERENCE=/var\(\s*(--[\w-]+)\s*(?:,([^()]*(?:\([^()]*\)[^()]*)*))?\)/g,USAGE_WEIGHTS=[[/^(background|fill|accent-color|caret-color)|^color$/,1],[/^(border|outline|stroke|column-rule|text-decoration)/,.3],[/shadow$/,.1]],BRAND_NAME=/brand|primary|accent/i,isCustomProperty=e=>e.startsWith("--"),isPageRoot=e=>""===e||e.split(",").some(e=>PAGE_ROOT.test(e.trim())),scopeKey=(e,t)=>`${isPageRoot(e)?"":e}\0${t}`,schemeOf=e=>COLOR_SCHEMES.find(t=>e.some(e=>SCHEME_MARKERS[t].test(e))),scanCharacter=(e,t,o)=>{const r=e[t];if(o.escaped)o.escaped=!1;else if("\\"===r)o.escaped=!0;else if(o.quote)r===o.quote&&(o.quote=void 0);else if('"'===r||"'"===r)o.quote=r;else if("("===r)o.parentheses++;else if(")"===r)o.parentheses=Math.max(0,o.parentheses-1);else if(o.parentheses||"{"!==r){if(!o.parentheses&&(";"===r||"}"===r)){const s=e.slice(o.start,t);return o.start=t+1,{text:s,closesRule:"}"===r}}}else o.preludes.push(e.slice(o.start,t).trim()),o.start=t+1},declarationOf=(e,t)=>{const o=e.indexOf(":"),r=t.at(-1);if(o<=0||void 0===r)return;const s=e.slice(0,o).trim();return{property:isCustomProperty(s)?s:s.toLowerCase(),value:e.slice(o+1).trim(),selector:r.replace(ANY_SCHEME_MARKER,"").replace(/\s+/g," ").trim(),scheme:schemeOf(t)}},resolveVariables=(e,t,o,r=0)=>r>8?e:e.replace(VARIABLE_REFERENCE,(e,s,a="")=>{const l=o.get(scopeKey(t,s))??o.get(scopeKey("",s));return resolveVariables(l??a,t,o,r+1)}),tally=(e,t,o)=>{for(const[r]of t.replace(NON_PAINTING_TEXT," ").matchAll(COLOR_TOKENS)){const t=parse(r);if(!t||(t.alpha??1)<1)continue;const s=clampRgb(t),a=formatHex(s),l=e.get(a)??{hex:a,weight:0,color:toOklch(s)};l.weight+=o,e.set(a,l)}},weightOf=(e,t)=>isCustomProperty(e)?COLOR_TOKEN.exec(t)?.[0]!==t.trim()?0:BRAND_NAME.test(e)?1:.5:USAGE_WEIGHTS.find(([t])=>t.test(e))?.[1]??0,isNeutral=e=>e.c<.03,byWeight=(e,t)=>t.weight-e.weight,mergeShades=e=>{const t=[];for(const o of[...e].toSorted(byWeight)){const e=t.find(e=>{return t=e.color,r=o.color,isNeutral(t)||isNeutral(r)?isNeutral(t)&&isNeutral(r)&&Math.abs(t.l-r.l)<.06:Math.abs(differenceHueNaive({h:t.h??0},{h:r.h??0}))<20&&Math.abs(t.l-r.l)<.2;var t,r});e?e.weight+=o.weight:t.push({...o})}return t.toSorted(byWeight)},pickSwatches=(e,t)=>{const o=(e=>{const[t,...o]=e,r=o.find(e=>Math.abs(e.color.l-t.color.l)>=.4);return r?[t,r,...o.filter(e=>e!==r)]:e})(e.filter(e=>isNeutral(e.color))),r=e.filter(e=>!isNeutral(e.color)),s=Math.min(t,Math.max(Math.min(o.length,2),t-r.length));return[...o.slice(0,s),...r.slice(0,t-s)].toSorted(byWeight).map(e=>e.hex)},pageMode=(e,t)=>{const o=e.filter(({property:e})=>PAGE_BACKGROUND.test(e)),r=o.findLast(({selector:e})=>isPageRoot(e)),s=/* @__PURE__ */new Map;r&&tally(s,resolveVariables(r.value,r.selector,t),1);const a=/* @__PURE__ */new Map;for(const{value:n,selector:i}of o)tally(a,resolveVariables(n,i,t),1);const[l]=s.size?s.values():[...a.values()].filter(e=>isNeutral(e.color)).toSorted(byWeight);return l&&l.color.l<.5?"dark":"light"},readStylesheet=(e,{mode:t="auto",colorCount:o=6}={})=>{const r=((e,t)=>{const o=(e=>{const t=e.replace(/\/\*[\s\S]*?\*\//g,""),o={preludes:[],start:0,parentheses:0,escaped:!1},r=[];for(let s=0;s<t.length;s++){const e=scanCharacter(t,s,o);if(!e)continue;const a=declarationOf(e.text,o.preludes);a&&r.push(a),e.closesRule&&o.preludes.pop()}return r})(e),r=({selector:e,property:t})=>scopeKey(e,t),s=new Set(o.filter(({scheme:e})=>e===t).map(r));return o.filter(e=>e.scheme?e.scheme===t:!s.has(r(e)))})(e,t),s=(e=>new Map(e.filter(({property:e})=>isCustomProperty(e)).map(({selector:e,property:t,value:o})=>[scopeKey(e,t),o])))(r),a=/* @__PURE__ */new Map;for(const{property:l,value:n,selector:i}of r){const e=resolveVariables(n,i,s),t=weightOf(l,e);t&&tally(a,e,t)}return{colors:pickSwatches(mergeShades(a.values()),o),mode:"auto"===t?pageMode(r,s):t}},cssColors=(e,t={})=>readStylesheet(e,t).colors,WATER_HUES=[170,260],WIDER_WATER_HUES=[150,280],VEGETATION_HUES=[70,170],isInHues=(e,[t,o])=>void 0!==e.h&&e.h>=t&&e.h<=o,hsl=(e,t,o)=>formatStyleHsl({h:e,s:t,l:o}),parseColor=e=>{const t=toHsl(e);return t&&{...t,css:e,chroma:toOklch(t).c}},RoleAssigner=class{pool;dark;land;constructor(e,t){this.pool=[...e];const o=e.reduce((e,t)=>e+t.l,0)/e.length;var r;this.dark="dark"===t||"auto"===t&&o<.45,this.land=(r=this.take(this.pickLand())??e[0]).s<=.14?r:parseColor(hsl(r.h,.14,r.l))??r}pickLand(){const e=e=>e.toSorted((e,t)=>this.dark?e.l-t.l:t.l-e.l)[0],t=e=>e.l<.5===this.dark;return e(this.pool.filter(e=>e.chroma<=.08).filter(t))??e(this.pool.filter(t))??e(this.pool)}take(e){if(e)return this.pool.splice(this.pool.indexOf(e),1),e}takeMostColorful(e){const t=this.pool.filter(e).toSorted((e,t)=>t.chroma-e.chroma),o=t.find(e=>!isInHues(e,WIDER_WATER_HUES)&&!isInHues(e,VEGETATION_HUES));return this.take(o??t[0])}takeHue(e){const t=this.pool.filter(t=>t.s>=.12&&isInHues(t,e));return this.take(t.toSorted((e,t)=>t.s-e.s)[0])}takeMostContrasting(){const e=e=>wcagContrast(e,this.land),t=this.pool.toSorted((t,o)=>e(o)-e(t))[0];return t&&e(t)>=4.5?this.take(t):void 0}shade(e,t={}){return hsl(t.h??this.land.h,t.s??this.land.s,this.land.l+(this.dark?1:-1)*e)}labelShade(e,t){const o=this.shade(e,{s:t});return wcagContrast(o,this.land)>=4.5?o:this.shade(-e,{s:t})}},deriveMapColors=(e,t={})=>{const o=e.map(parseColor).filter(e=>void 0!==e),r=o.filter((e,t)=>!o.slice(0,t).some(t=>isSameColor(t,e)));if(!r.length)throw new RangeError("deriveMapColors needs at least one parseable CSS colour.");const s=new RoleAssigner(r,t.mode??"auto"),{dark:a,land:l}=s,n=s.takeMostColorful(e=>e.s>=.2)??parseColor(s.shade(a?.55:.45,{s:.7}))??l,i=(s.takeHue(WATER_HUES)??s.takeHue(WIDER_WATER_HUES))?.css??s.shade(a?.12:.14,{h:205,s:Math.max(.35,l.s)}),c=s.takeHue(VEGETATION_HUES)?.css??s.shade(a?.08:.09,{h:110,s:Math.max(.18,.6*l.s)}),h=s.takeMostContrasting()?.css??s.labelShade(a?.8:.78,Math.min(l.s,.2)),d=((e,t)=>{const{dark:o,land:r}=e,s=e=>void 0!==e&&wcagContrast(e,r)>=3,a=e.takeMostColorful(e=>e.s>=.3&&s(e)&&hueDistance(e,t)>=30);if(a)return a.css;const l=(t.h??0)+180;return(o?[.62,.7,.78]:[.38,.3,.22]).map(e=>parseColor(hsl(l,.7,e))).find(s)?.css??hsl(l,.7,o?.85:.15)})(s,n),m=parseColor(c)??l;return{land:l.css,water:i,vegetation:c,park:hsl(m.h,m.s,m.l+(a?.04:.05)),artificial:s.shade(a?.04:.03),roadMajor:n.css,road:s.shade(a?.1:-.08,{s:.5*l.s}),roadOutline:s.shade(a?.24:.22,{s:.6*l.s}),label:h,labelHalo:s.shade(-.03),accent:d}},mapColorsLightDark=({land:e,label:t})=>wcagLuminance(t)>wcagLuminance(e)?"dark":"light",deriveMapColorsFromCss=(e,t={})=>{const{colors:o,mode:r}=readStylesheet(e,t);if(!o.length)throw new RangeError("deriveMapColorsFromCss: the stylesheet paints with no opaque colour to take a theme from.");return deriveMapColors(o,{mode:r})},squaredDistance=(e,t)=>(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2,nearestIndex=(e,t)=>{let o=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s++){const a=squaredDistance(e,t[s]);a<r&&(r=a,o=s)}return o},dominantColors=(e,t=6)=>{const o=(({data:e})=>{const t=Math.floor(e.length/4),o=Math.max(1,Math.floor(t/4096)),r=[];for(let s=0;s<t;s+=o){const t=4*s;e[t+3]<128||r.push([e[t],e[t+1],e[t+2]])}return r})(e);if(!o.length)return[];const{centroids:r,sizes:s}=((e,t)=>{let o=t,r=[];for(let s=0;s<8;s++){const t=o.map(()=>[0,0,0]);r=o.map(()=>0);for(const s of e){const e=nearestIndex(s,o);r[e]++,t[e][0]+=s[0],t[e][1]+=s[1],t[e][2]+=s[2]}o=o.map((e,o)=>r[o]?t[o].map(e=>e/r[o]):e)}return{centroids:o,sizes:r}})(o,((e,t)=>{const o=e=>wcagLuminance(rgbFromBytes(e)),r=[[...e.toSorted((e,t)=>o(e)-o(t))[Math.floor(e.length/2)]]];for(;r.length<t;){let t=e[0],o=-1;for(const s of e){const e=squaredDistance(s,r[nearestIndex(s,r)]);e>o&&(o=e,t=s)}if(0===o)break;r.push([...t])}return r})(o,Math.min(t,o.length)));return((e,t)=>{const o=[];for(const[r,s]of e.entries()){if(!t[r])continue;const e=o.find(e=>isSameColor(rgbFromBytes(e.rgb),rgbFromBytes(s)));e?e.size+=t[r]:o.push({rgb:s,size:t[r]})}return o})(r,s).toSorted((e,t)=>t.size-e.size).map(e=>formatHex(rgbFromBytes(e.rgb)))},deriveMapColorsFromImage=async(e,t={})=>{const o=(e=>"object"==typeof e&&"data"in e)(e)?e:await(async e=>{if("undefined"==typeof document)throw new TypeError("deriveMapColorsFromImage needs a DOM to decode images; pass ImagePixels instead.");const t=await(async e=>{return"string"==typeof e?(t=e,new Promise((e,o)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>e(r),r.onerror=()=>o(/* @__PURE__ */new Error(`deriveMapColorsFromImage: could not load '${t}'.`)),r.src=t})):e instanceof Blob?createImageBitmap(e):e;var t})(e),o=document.createElement("canvas");o.width=64,o.height=64;const r=o.getContext("2d");if(!r)throw new Error("deriveMapColorsFromImage: no 2D canvas context available.");r.drawImage(t,0,0,64,64);try{return r.getImageData(0,0,64,64)}catch{throw new Error("deriveMapColorsFromImage: the image is not CORS-readable (canvas tainted). Serve it with Access-Control-Allow-Origin or pass a Blob/File.")}})(e),r=dominantColors(o,t.colorCount);if(!r.length)throw new RangeError("deriveMapColorsFromImage: the image has no opaque pixels to take colours from.");return deriveMapColors(r,t)};export{cssColors,deriveMapColors,deriveMapColorsFromCss,deriveMapColorsFromImage,dominantColors,mapColorsLightDark,mapThemeModes};
|
|
1
|
+
import{clampRgb,differenceEuclidean,differenceHueNaive,formatHex,modeHsl,modeLrgb,modeOklab,modeOklch,modeRgb,parse,useMode,wcagContrast,wcagLuminance}from"culori/fn";import{formatStyleHsl,hueDistance,toHsl}from"@tomtom-org/maps-sdk/map";useMode(modeRgb),useMode(modeLrgb),useMode(modeHsl),useMode(modeOklab);var toOklch=useMode(modeOklch),oklabDistance=/* @__PURE__ */differenceEuclidean("oklab"),isSameColor=(e,t)=>oklabDistance(e,t)<.035,rgbFromBytes=([e,t,o])=>({mode:"rgb",r:e/255,g:t/255,b:o/255}),mapThemeModes=["light","dark","auto"],schemeMarker=(e,t)=>new RegExp(String.raw`prefers-color-scheme\s*:\s*${e}|\.(?:theme-)?${e}(?:-(?:mode|theme))?(?![\w-])|\[data-[\w-]+=["']?${e}["']?\]`,t),COLOR_SCHEMES=["light","dark"],SCHEME_MARKERS={light:/* @__PURE__ */schemeMarker("light","i"),dark:/* @__PURE__ */schemeMarker("dark","i")},ANY_SCHEME_MARKER=/* @__PURE__ */schemeMarker("(?:light|dark)","gi"),PAGE_ROOT=/^(?:(?::root|html|body)\s*)+$/,PAGE_BACKGROUND=/^background(-color)?$/,NON_PAINTING_TEXT=/url\((?:"[^"]*"|'[^']*'|[^)]*)\)|"[^"]*"|'[^']*'/gi,HEX_COLOR=/#[\da-f]{3,8}\b/,COLOR_FUNCTION=/\b(?:rgba?|hsla?|oklab|oklch)\([^()]*\)/,COLOR_NAME=/\b[a-z]+\b/,COLOR_TOKEN=/* @__PURE__ */(()=>new RegExp([HEX_COLOR,COLOR_FUNCTION,COLOR_NAME].map(({source:e})=>e).join("|"),"i"))(),COLOR_TOKENS=/* @__PURE__ */new RegExp(COLOR_TOKEN,"gi"),VARIABLE_REFERENCE=/var\(\s*(--[\w-]+)\s*(?:,([^()]*(?:\([^()]*\)[^()]*)*))?\)/g,USAGE_WEIGHTS=[[/^(background|fill|accent-color|caret-color)|^color$/,1],[/^(border|outline|stroke|column-rule|text-decoration)/,.3],[/shadow$/,.1]],BRAND_NAME=/brand|primary|accent/i,isCustomProperty=e=>e.startsWith("--"),isPageRoot=e=>""===e||e.split(",").some(e=>PAGE_ROOT.test(e.trim())),scopeKey=(e,t)=>`${isPageRoot(e)?"":e}\0${t}`,schemeOf=e=>COLOR_SCHEMES.find(t=>e.some(e=>SCHEME_MARKERS[t].test(e))),scanCharacter=(e,t,o)=>{const r=e[t];if(o.escaped)o.escaped=!1;else if("\\"===r)o.escaped=!0;else if(o.quote)r===o.quote&&(o.quote=void 0);else if('"'===r||"'"===r)o.quote=r;else if("("===r)o.parentheses++;else if(")"===r)o.parentheses=Math.max(0,o.parentheses-1);else if(o.parentheses||"{"!==r){if(!o.parentheses&&(";"===r||"}"===r)){const s=e.slice(o.start,t);return o.start=t+1,{text:s,closesRule:"}"===r}}}else o.preludes.push(e.slice(o.start,t).trim()),o.start=t+1},declarationOf=(e,t)=>{const o=e.indexOf(":"),r=t.at(-1);if(o<=0||void 0===r)return;const s=e.slice(0,o).trim();return{property:isCustomProperty(s)?s:s.toLowerCase(),value:e.slice(o+1).trim(),selector:r.replace(ANY_SCHEME_MARKER,"").replace(/\s+/g," ").trim(),scheme:schemeOf(t)}},tally=(e,t,o,r)=>{for(const[s]of t.replace(NON_PAINTING_TEXT," ").matchAll(COLOR_TOKENS)){const t=r(s);if(!t)continue;const{hex:a}=t,n=e.get(a)??{...t,weight:0};n.weight+=o,e.set(a,n)}},weightOf=(e,t)=>isCustomProperty(e)?COLOR_TOKEN.exec(t)?.[0]!==t.trim()?0:BRAND_NAME.test(e)?1:.5:USAGE_WEIGHTS.find(([t])=>t.test(e))?.[1]??0,isNeutral=e=>e.c<.03,byWeight=(e,t)=>t.weight-e.weight,mergeShades=e=>{const t=[];for(const o of[...e].toSorted(byWeight)){const e=t.find(e=>{return t=e.color,r=o.color,isNeutral(t)||isNeutral(r)?isNeutral(t)&&isNeutral(r)&&Math.abs(t.l-r.l)<.06:Math.abs(differenceHueNaive({h:t.h??0},{h:r.h??0}))<20&&Math.abs(t.l-r.l)<.2;var t,r});e?e.weight+=o.weight:t.push({...o})}return t.toSorted(byWeight)},pickSwatches=(e,t)=>{const o=(e=>{const[t,...o]=e,r=o.find(e=>Math.abs(e.color.l-t.color.l)>=.4);return r?[t,r,...o.filter(e=>e!==r)]:e})(e.filter(e=>isNeutral(e.color))),r=e.filter(e=>!isNeutral(e.color)),s=Math.min(t,Math.max(Math.min(o.length,2),t-r.length));return[...o.slice(0,s),...r.slice(0,t-s)].toSorted(byWeight).map(e=>e.hex)},pageMode=(e,t,o)=>{const r=e.filter(({property:e})=>PAGE_BACKGROUND.test(e)),s=r.findLast(({selector:e})=>isPageRoot(e)),a=/* @__PURE__ */new Map;s&&tally(a,t(s.value,s.selector),1,o);const n=/* @__PURE__ */new Map;for(const{value:i,selector:c}of r)tally(n,t(i,c),1,o);const[l]=a.size?a.values():[...n.values()].filter(e=>isNeutral(e.color)).toSorted(byWeight);return l&&l.color.l<.5?"dark":"light"},readStylesheet=(e,{mode:t="auto",colorCount:o=6}={})=>{const r=((e,t)=>{const o=(e=>{const t=e.replace(/\/\*[\s\S]*?\*\//g,""),o={preludes:[],start:0,parentheses:0,escaped:!1},r=[];for(let s=0;s<t.length;s++){const e=scanCharacter(t,s,o);if(!e)continue;const a=declarationOf(e.text,o.preludes);a&&r.push(a),e.closesRule&&o.preludes.pop()}return r})(e),r=({selector:e,property:t})=>scopeKey(e,t),s=new Set(o.filter(({scheme:e})=>e===t).map(r));return o.filter(e=>e.scheme?e.scheme===t:!s.has(r(e)))})(e,t),{resolve:s,onCycle:a}=(e=>{const t=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Set,s=(a,n)=>o.size>8?a:a.replace(VARIABLE_REFERENCE,(a,l,i="")=>((a,n)=>{const l=scopeKey(n,a);if(t.has(l))return t.get(l);const i=e.get(l)??e.get(scopeKey("",a));if(void 0===i)return;if(o.has(l)){const e=[...o];for(const t of e.slice(e.indexOf(l)))r.add(t);return}o.add(l);const c=s(i,n);o.delete(l);const h=r.has(l)||c.length>1e4?void 0:c;return t.set(l,h),h})(l,n)??s(i,n));return{resolve:s,onCycle:(e,t)=>r.has(scopeKey(t,e))}})((e=>new Map(e.filter(({property:e})=>isCustomProperty(e)).map(({selector:e,property:t,value:o})=>[scopeKey(e,t),o])))(r)),n=(()=>{const e=/* @__PURE__ */new Map;return t=>{if(e.has(t))return e.get(t);const o=parse(t),r=o&&(o.alpha??1)>=1?clampRgb(o):void 0,s=r&&{hex:formatHex(r),color:toOklch(r)};return e.set(t,s),s}})(),l=/* @__PURE__ */new Map;for(const{property:i,value:c,selector:h}of r){const e=s(c,h),t=a(i,h)?0:weightOf(i,e);t&&tally(l,e,t,n)}return{colors:pickSwatches(mergeShades(l.values()),o),mode:"auto"===t?pageMode(r,s,n):t}},cssColors=(e,t={})=>readStylesheet(e,t).colors,WATER_HUES=[170,260],WIDER_WATER_HUES=[150,280],VEGETATION_HUES=[70,170],isInHues=(e,[t,o])=>void 0!==e.h&&e.h>=t&&e.h<=o,hsl=(e,t,o)=>formatStyleHsl({h:e,s:t,l:o}),parseColor=e=>{const t=toHsl(e);return t&&{...t,css:e,chroma:toOklch(t).c}},RoleAssigner=class{pool;dark;land;constructor(e,t){this.pool=[...e];const o=e.reduce((e,t)=>e+t.l,0)/e.length;var r;this.dark="dark"===t||"auto"===t&&o<.45,this.land=(r=this.take(this.pickLand())??e[0]).s<=.14?r:parseColor(hsl(r.h,.14,r.l))??r}pickLand(){const e=e=>e.toSorted((e,t)=>this.dark?e.l-t.l:t.l-e.l)[0],t=e=>e.l<.5===this.dark;return e(this.pool.filter(e=>e.chroma<=.08).filter(t))??e(this.pool.filter(t))??e(this.pool)}take(e){if(e)return this.pool.splice(this.pool.indexOf(e),1),e}takeMostColorful(e){const t=this.pool.filter(e).toSorted((e,t)=>t.chroma-e.chroma),o=t.find(e=>!isInHues(e,WIDER_WATER_HUES)&&!isInHues(e,VEGETATION_HUES));return this.take(o??t[0])}takeHue(e){const t=this.pool.filter(t=>t.s>=.12&&isInHues(t,e));return this.take(t.toSorted((e,t)=>t.s-e.s)[0])}takeMostContrasting(){const e=e=>wcagContrast(e,this.land),t=this.pool.toSorted((t,o)=>e(o)-e(t))[0];return t&&e(t)>=4.5?this.take(t):void 0}shade(e,t={}){return hsl(t.h??this.land.h,t.s??this.land.s,this.land.l+(this.dark?1:-1)*e)}labelShade(e,t){const o=this.shade(e,{s:t});return wcagContrast(o,this.land)>=4.5?o:this.shade(-e,{s:t})}},deriveMapColors=(e,t={})=>{const o=e.map(parseColor).filter(e=>void 0!==e),r=o.filter((e,t)=>!o.slice(0,t).some(t=>isSameColor(t,e)));if(!r.length)throw new RangeError("deriveMapColors needs at least one parseable CSS colour.");const s=new RoleAssigner(r,t.mode??"auto"),{dark:a,land:n}=s,l=s.takeMostColorful(e=>e.s>=.2)??parseColor(s.shade(a?.55:.45,{s:.7}))??n,i=(s.takeHue(WATER_HUES)??s.takeHue(WIDER_WATER_HUES))?.css??s.shade(a?.12:.14,{h:205,s:Math.max(.35,n.s)}),c=s.takeHue(VEGETATION_HUES)?.css??s.shade(a?.08:.09,{h:110,s:Math.max(.18,.6*n.s)}),h=s.takeMostContrasting()?.css??s.labelShade(a?.8:.78,Math.min(n.s,.2)),d=((e,t)=>{const{dark:o,land:r}=e,s=e=>void 0!==e&&wcagContrast(e,r)>=3,a=e.takeMostColorful(e=>e.s>=.3&&s(e)&&hueDistance(e,t)>=30);if(a)return a.css;const n=(t.h??0)+180;return(o?[.62,.7,.78]:[.38,.3,.22]).map(e=>parseColor(hsl(n,.7,e))).find(s)?.css??hsl(n,.7,o?.85:.15)})(s,l),m=parseColor(c)??n;return{land:n.css,water:i,vegetation:c,park:hsl(m.h,m.s,m.l+(a?.04:.05)),artificial:s.shade(a?.04:.03),roadMajor:l.css,road:s.shade(a?.1:-.08,{s:.5*n.s}),roadOutline:s.shade(a?.24:.22,{s:.6*n.s}),label:h,labelHalo:s.shade(-.03),accent:d}},mapColorsLightDark=({land:e,label:t})=>wcagLuminance(t)>wcagLuminance(e)?"dark":"light",deriveMapColorsFromCss=(e,t={})=>{const{colors:o,mode:r}=readStylesheet(e,t);if(!o.length)throw new RangeError("deriveMapColorsFromCss: the stylesheet paints with no opaque colour to take a theme from.");return deriveMapColors(o,{mode:r})},squaredDistance=(e,t)=>(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2,nearestIndex=(e,t)=>{let o=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s++){const a=squaredDistance(e,t[s]);a<r&&(r=a,o=s)}return o},dominantColors=(e,t=6)=>{const o=(({data:e,width:t,height:o})=>{if(!t||!o)return[];const r=Math.max(1,Math.min(t,4096,Math.ceil(Math.sqrt(4096*t/o)))),s=Math.max(1,Math.min(o,Math.floor(4096/r))),a=[];for(let n=0;n<s;n++){const l=Math.floor((n+.5)*o/s);for(let o=0;o<r;o++){const s=4*(l*t+Math.floor((o+.5)*t/r));e[s+3]<128||a.push([e[s],e[s+1],e[s+2]])}}return a})(e);if(!o.length)return[];const{centroids:r,sizes:s}=((e,t)=>{let o=t,r=[];for(let s=0;s<8;s++){const t=o.map(()=>[0,0,0]);r=o.map(()=>0);for(const s of e){const e=nearestIndex(s,o);r[e]++,t[e][0]+=s[0],t[e][1]+=s[1],t[e][2]+=s[2]}o=o.map((e,o)=>r[o]?t[o].map(e=>e/r[o]):e)}return{centroids:o,sizes:r}})(o,((e,t)=>{const o=[[...e.map(e=>({sample:e,luminance:wcagLuminance(rgbFromBytes(e))})).sort((e,t)=>e.luminance-t.luminance)[Math.floor(e.length/2)].sample]];for(;o.length<t;){let t=e[0],r=-1;for(const s of e){const e=squaredDistance(s,o[nearestIndex(s,o)]);e>r&&(r=e,t=s)}if(0===r)break;o.push([...t])}return o})(o,Math.min(t,o.length)));return((e,t)=>{const o=[];for(const[r,s]of e.entries()){if(!t[r])continue;const e=o.find(e=>isSameColor(rgbFromBytes(e.rgb),rgbFromBytes(s)));e?e.size+=t[r]:o.push({rgb:s,size:t[r]})}return o})(r,s).toSorted((e,t)=>t.size-e.size).map(e=>formatHex(rgbFromBytes(e.rgb)))},deriveMapColorsFromImage=async(e,t={})=>{const o=(e=>"object"==typeof e&&"data"in e)(e)?e:await(async e=>{if("undefined"==typeof document)throw new TypeError("deriveMapColorsFromImage needs a DOM to decode images; pass ImagePixels instead.");const t=await(async e=>{return"string"==typeof e?(t=e,new Promise((e,o)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>e(r),r.onerror=()=>o(/* @__PURE__ */new Error(`deriveMapColorsFromImage: could not load '${t}'.`)),r.src=t})):e instanceof Blob?createImageBitmap(e):e;var t})(e),o=document.createElement("canvas");o.width=64,o.height=64;const r=o.getContext("2d");if(!r)throw new Error("deriveMapColorsFromImage: no 2D canvas context available.");r.drawImage(t,0,0,64,64),e instanceof Blob&&"close"in t&&t.close();try{return r.getImageData(0,0,64,64)}catch{throw new Error("deriveMapColorsFromImage: the image is not CORS-readable (canvas tainted). Serve it with Access-Control-Allow-Origin or pass a Blob/File.")}})(e),r=dominantColors(o,t.colorCount);if(!r.length)throw new RangeError("deriveMapColorsFromImage: the image has no opaque pixels to take colours from.");return deriveMapColors(r,t)};export{cssColors,deriveMapColors,deriveMapColorsFromCss,deriveMapColorsFromImage,dominantColors,mapColorsLightDark,mapThemeModes};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tomtom-org/maps-sdk-plugin-map-theme",
|
|
3
3
|
"author": "TomTom International B.V.",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.9",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Theme a TomTomMap from wherever a look comes from — a brand's colours, a website's, a described mood, an artist's palette, or an image — by assigning them to the SDK's map colours",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
"typescript": "^6.0.3",
|
|
21
21
|
"vite": "^8.3.4",
|
|
22
22
|
"vitest": "^5.0.5",
|
|
23
|
-
"@tomtom-org/maps-sdk": "1.0.0-rc.
|
|
23
|
+
"@tomtom-org/maps-sdk": "1.0.0-rc.6"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
27
|
"package.json",
|
|
28
28
|
"README.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
29
30
|
"LICENSE.txt",
|
|
30
31
|
"THIRD_PARTY.txt",
|
|
31
32
|
"!**/*.map"
|