@geolonia/embed 5.0.3 → 5.2.1
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/.github/workflows/build.yml +9 -4
- package/.vscode/settings.json +27 -0
- package/CHANGELOG.md +9 -0
- package/README.md +71 -2
- package/dist/embed +1 -1
- package/dist/embed-chunks/12cbd0d1cb4cf744c32f.js +2 -0
- package/dist/embed-chunks/1492645e3d07fd3de940.js +1 -0
- package/dist/embed-chunks/8a521e8312a5b4da123d.js +2 -0
- package/dist/embed-chunks/8a521e8312a5b4da123d.js.LICENSE.txt +6 -0
- package/dist/embed-core.d.ts +14 -0
- package/dist/embed-core.js +2 -0
- package/dist/embed-core.js.LICENSE.txt +4 -0
- package/dist/{src/embed.d.ts → embed.d.ts} +2 -37
- package/dist/embed.js +1 -1
- package/dist/embed.js.LICENSE.txt +1 -1
- package/dist/lib/keyring.d.ts +45 -0
- package/dist/{src/lib → lib}/parse-atts.d.ts +1 -1
- package/dist/{src/lib → lib}/simplestyle.d.ts +2 -0
- package/dist/{src/lib → lib}/util.d.ts +3 -3
- package/dist/types.d.ts +38 -0
- package/dist/version.d.ts +1 -0
- package/e2e/basic.spec.ts +6 -1
- package/e2e/external-style.spec.ts +25 -0
- package/e2e/map.spec.ts +12 -12
- package/package.json +15 -8
- package/src/embed-core.ts +22 -0
- package/src/embed.ts +2 -42
- package/src/lib/geolonia-map.ts +4 -3
- package/src/lib/geolonia-marker.ts +1 -1
- package/src/lib/keyring.test.ts +58 -15
- package/src/lib/keyring.ts +53 -1
- package/src/lib/parse-atts.test.ts +2 -2
- package/src/lib/parse-atts.ts +5 -1
- package/src/lib/render.ts +1 -1
- package/src/lib/simplestyle.test.ts +94 -56
- package/src/lib/simplestyle.ts +75 -17
- package/src/lib/util.test.ts +136 -96
- package/src/lib/util.ts +55 -10
- package/src/testability.test.ts +13 -10
- package/src/types.ts +44 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -0
- package/vitest.config.ts +8 -0
- package/webpack.config.js +45 -14
- package/.mocharc.js +0 -9
- package/dist/e2e/basic.spec.d.ts +0 -8
- package/dist/e2e/helper.d.ts +0 -4
- package/dist/e2e/map.spec.d.ts +0 -1
- package/dist/embed-chunks/2489af4328c51b71e92d.js +0 -2
- package/dist/playwright.config.d.ts +0 -9
- package/dist/src/lib/keyring.d.ts +0 -29
- package/dist/src/lib/keyring.test.d.ts +0 -1
- package/dist/src/lib/parse-atts.test.d.ts +0 -1
- package/dist/src/lib/simplestyle.test.d.ts +0 -1
- package/dist/src/lib/util.test.d.ts +0 -1
- package/dist/src/testability.test.d.ts +0 -1
- package/dist/src/version.d.ts +0 -1
- /package/dist/embed-chunks/{2489af4328c51b71e92d.js.LICENSE.txt → 12cbd0d1cb4cf744c32f.js.LICENSE.txt} +0 -0
- /package/dist/{src/lib → lib}/CustomAttributionControl.d.ts +0 -0
- /package/dist/{src/lib → lib}/controls/geolonia-control.d.ts +0 -0
- /package/dist/{src/lib → lib}/geolonia-map.d.ts +0 -0
- /package/dist/{src/lib → lib}/geolonia-marker.d.ts +0 -0
- /package/dist/{src/lib → lib}/maplibre-util.d.ts +0 -0
- /package/dist/{src/lib → lib}/render.d.ts +0 -0
- /package/dist/{src/lib → lib}/simplestyle-vector.d.ts +0 -0
- /package/dist/{src/types-internal.d.ts → types-internal.d.ts} +0 -0
|
@@ -86,6 +86,9 @@ jobs:
|
|
|
86
86
|
publish:
|
|
87
87
|
name: 'Publish npm package'
|
|
88
88
|
runs-on: ubuntu-latest
|
|
89
|
+
permissions:
|
|
90
|
+
id-token: write
|
|
91
|
+
contents: read
|
|
89
92
|
needs:
|
|
90
93
|
- build
|
|
91
94
|
- act-test
|
|
@@ -102,16 +105,18 @@ jobs:
|
|
|
102
105
|
uses: actions/download-artifact@v4
|
|
103
106
|
with:
|
|
104
107
|
name: the-built
|
|
108
|
+
|
|
109
|
+
- name: Update npm
|
|
110
|
+
run: npm install -g npm@latest
|
|
111
|
+
|
|
105
112
|
- name: 'Publish to NPM (latest)'
|
|
106
113
|
if: "!contains(github.ref, '-pre.')"
|
|
107
114
|
run: npm publish --access=public
|
|
108
|
-
|
|
109
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
115
|
+
|
|
110
116
|
- name: 'Publish to NPM (next)'
|
|
111
117
|
if: "contains(github.ref, '-pre.')"
|
|
112
118
|
run: npm publish --access=public --tag=next
|
|
113
|
-
|
|
114
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
119
|
+
|
|
115
120
|
deploy:
|
|
116
121
|
needs: build
|
|
117
122
|
runs-on: ubuntu-latest
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": [
|
|
3
|
+
"atts",
|
|
4
|
+
"chunkhash",
|
|
5
|
+
"Codepen",
|
|
6
|
+
"codesandbox",
|
|
7
|
+
"customtile",
|
|
8
|
+
"deckgl",
|
|
9
|
+
"Geolonia",
|
|
10
|
+
"hibiya",
|
|
11
|
+
"linestring",
|
|
12
|
+
"mapbox",
|
|
13
|
+
"mapboxgl",
|
|
14
|
+
"maplibregl",
|
|
15
|
+
"mbgl",
|
|
16
|
+
"Neue",
|
|
17
|
+
"Noto",
|
|
18
|
+
"openmaptiles",
|
|
19
|
+
"pickable",
|
|
20
|
+
"pmtiles",
|
|
21
|
+
"recalc",
|
|
22
|
+
"rgba",
|
|
23
|
+
"simplestyle",
|
|
24
|
+
"styledata",
|
|
25
|
+
"tileserver"
|
|
26
|
+
]
|
|
27
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
### nightly
|
|
6
6
|
|
|
7
|
+
- **Feature**: Added support for external style.json URLs in `data-style` attribute
|
|
8
|
+
- You can now specify full URLs: `data-style="https://tile.openstreetmap.jp/styles/osm-bright/style.json"`
|
|
9
|
+
- Relative paths are also supported: `data-style="./custom-style.json"`
|
|
10
|
+
- Files ending in `.json` are automatically resolved to absolute URLs
|
|
11
|
+
- External styles work without a Geolonia API key
|
|
12
|
+
- API key is now only required for Geolonia's hosted styles and tiles
|
|
13
|
+
- Added Mixed Content warnings for HTTP styles on HTTPS pages
|
|
14
|
+
- Added CORS error guidance for external styles
|
|
15
|
+
- **Improvement**: API key scope is now limited to Geolonia domains only (security enhancement)
|
|
7
16
|
- Renamed as `@geolonia/embed`
|
|
8
17
|
- plugin system
|
|
9
18
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Specify `.geolonia` class for target elements.
|
|
|
23
23
|
<html>
|
|
24
24
|
<body>
|
|
25
25
|
<div class="geolonia" ...></div>
|
|
26
|
-
<script src="https://cdn.geolonia.com/
|
|
26
|
+
<script src="https://cdn.geolonia.com/embed/v5/embed?geolonia-api-key=YOUR-API-KEY"></script>
|
|
27
27
|
</body>
|
|
28
28
|
</html>
|
|
29
29
|
```
|
|
@@ -35,11 +35,79 @@ Or
|
|
|
35
35
|
<html>
|
|
36
36
|
<body>
|
|
37
37
|
<div class="geolonia" data-key="YOUR-API-KEY" ...></div>
|
|
38
|
-
<script src="https://cdn.geolonia.com/
|
|
38
|
+
<script src="https://cdn.geolonia.com/embed/v5/embed"></script>
|
|
39
39
|
</body>
|
|
40
40
|
</html>
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
### Using with npm (for React, Next.js, Astro, Fresh, etc.)
|
|
44
|
+
|
|
45
|
+
For modern web frameworks, use `@geolonia/embed/core` — a side-effect-free entry point designed for programmatic use.
|
|
46
|
+
|
|
47
|
+
```shell
|
|
48
|
+
npm install @geolonia/embed
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { GeoloniaMap, keyring } from "@geolonia/embed/core";
|
|
53
|
+
|
|
54
|
+
keyring.apiKey = "YOUR-API-KEY";
|
|
55
|
+
|
|
56
|
+
const map = new GeoloniaMap({
|
|
57
|
+
container: "#map",
|
|
58
|
+
style: "geolonia/gsi",
|
|
59
|
+
center: [139.7671, 35.6812],
|
|
60
|
+
zoom: 14,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Unlike the default `@geolonia/embed` entry point, `/core` does **not** automatically scan the DOM or set `window.geolonia`. This makes it safe to use in SSR environments and avoids double-initialization issues in frameworks like React, Preact, and Vue.
|
|
65
|
+
|
|
66
|
+
### Using External Styles Without API Key
|
|
67
|
+
|
|
68
|
+
You can use external style.json URLs without a Geolonia API key. This is useful when:
|
|
69
|
+
- Using open-source tile servers like OpenStreetMap Japan
|
|
70
|
+
- Self-hosting your own tiles and styles
|
|
71
|
+
- Distributing maps without API key dependencies
|
|
72
|
+
|
|
73
|
+
**Note:** Geolonia API key is only required when using Geolonia's hosted styles and tiles.
|
|
74
|
+
|
|
75
|
+
```html
|
|
76
|
+
<!DOCTYPE html>
|
|
77
|
+
<html>
|
|
78
|
+
<body>
|
|
79
|
+
<!-- Using OpenStreetMap Japan tiles (no API key needed) -->
|
|
80
|
+
<!-- Note: tile.openstreetmap.jp is for non-commercial use only -->
|
|
81
|
+
<div
|
|
82
|
+
class="geolonia"
|
|
83
|
+
data-lat="35.6812"
|
|
84
|
+
data-lng="139.7671"
|
|
85
|
+
data-zoom="14"
|
|
86
|
+
data-style="https://tile.openstreetmap.jp/styles/osm-bright/style.json"
|
|
87
|
+
></div>
|
|
88
|
+
<script src="https://cdn.geolonia.com/embed/v5/embed"></script>
|
|
89
|
+
</body>
|
|
90
|
+
</html>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
You can also use npm/unpkg/jsDelivr for self-hosted or CDN distribution:
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<!-- Using npm CDN (unpkg) -->
|
|
97
|
+
<script src="https://unpkg.com/@geolonia/embed@latest/dist/embed.js"></script>
|
|
98
|
+
|
|
99
|
+
<!-- Using jsDelivr -->
|
|
100
|
+
<script src="https://cdn.jsdelivr.net/npm/@geolonia/embed@latest/dist/embed.js"></script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### data-style attribute
|
|
104
|
+
|
|
105
|
+
The `data-style` attribute accepts:
|
|
106
|
+
- **Geolonia style names**: `geolonia/basic`, `geolonia/gsi` (requires API key)
|
|
107
|
+
- **Full URLs**: `https://example.com/style.json`
|
|
108
|
+
- **Relative paths**: `./custom-style.json`, `/styles/my-style.json`
|
|
109
|
+
- **Files ending in .json**: Automatically resolved to absolute URLs
|
|
110
|
+
|
|
43
111
|
You can see more examples at [https://geolonia.github.io/embed/](https://geolonia.github.io/embed/).
|
|
44
112
|
|
|
45
113
|
# Contributing
|
|
@@ -58,6 +126,7 @@ $ cd embed
|
|
|
58
126
|
$ npm install
|
|
59
127
|
$ npm start # run dev server
|
|
60
128
|
$ npm test # run tests
|
|
129
|
+
$ npm run e2e # run e2e tests
|
|
61
130
|
$ npm run build # build production bundle
|
|
62
131
|
```
|
|
63
132
|
|