@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.
Files changed (66) hide show
  1. package/.github/workflows/build.yml +9 -4
  2. package/.vscode/settings.json +27 -0
  3. package/CHANGELOG.md +9 -0
  4. package/README.md +71 -2
  5. package/dist/embed +1 -1
  6. package/dist/embed-chunks/12cbd0d1cb4cf744c32f.js +2 -0
  7. package/dist/embed-chunks/1492645e3d07fd3de940.js +1 -0
  8. package/dist/embed-chunks/8a521e8312a5b4da123d.js +2 -0
  9. package/dist/embed-chunks/8a521e8312a5b4da123d.js.LICENSE.txt +6 -0
  10. package/dist/embed-core.d.ts +14 -0
  11. package/dist/embed-core.js +2 -0
  12. package/dist/embed-core.js.LICENSE.txt +4 -0
  13. package/dist/{src/embed.d.ts → embed.d.ts} +2 -37
  14. package/dist/embed.js +1 -1
  15. package/dist/embed.js.LICENSE.txt +1 -1
  16. package/dist/lib/keyring.d.ts +45 -0
  17. package/dist/{src/lib → lib}/parse-atts.d.ts +1 -1
  18. package/dist/{src/lib → lib}/simplestyle.d.ts +2 -0
  19. package/dist/{src/lib → lib}/util.d.ts +3 -3
  20. package/dist/types.d.ts +38 -0
  21. package/dist/version.d.ts +1 -0
  22. package/e2e/basic.spec.ts +6 -1
  23. package/e2e/external-style.spec.ts +25 -0
  24. package/e2e/map.spec.ts +12 -12
  25. package/package.json +15 -8
  26. package/src/embed-core.ts +22 -0
  27. package/src/embed.ts +2 -42
  28. package/src/lib/geolonia-map.ts +4 -3
  29. package/src/lib/geolonia-marker.ts +1 -1
  30. package/src/lib/keyring.test.ts +58 -15
  31. package/src/lib/keyring.ts +53 -1
  32. package/src/lib/parse-atts.test.ts +2 -2
  33. package/src/lib/parse-atts.ts +5 -1
  34. package/src/lib/render.ts +1 -1
  35. package/src/lib/simplestyle.test.ts +94 -56
  36. package/src/lib/simplestyle.ts +75 -17
  37. package/src/lib/util.test.ts +136 -96
  38. package/src/lib/util.ts +55 -10
  39. package/src/testability.test.ts +13 -10
  40. package/src/types.ts +44 -0
  41. package/tsconfig.build.json +9 -0
  42. package/tsconfig.json +1 -0
  43. package/vitest.config.ts +8 -0
  44. package/webpack.config.js +45 -14
  45. package/.mocharc.js +0 -9
  46. package/dist/e2e/basic.spec.d.ts +0 -8
  47. package/dist/e2e/helper.d.ts +0 -4
  48. package/dist/e2e/map.spec.d.ts +0 -1
  49. package/dist/embed-chunks/2489af4328c51b71e92d.js +0 -2
  50. package/dist/playwright.config.d.ts +0 -9
  51. package/dist/src/lib/keyring.d.ts +0 -29
  52. package/dist/src/lib/keyring.test.d.ts +0 -1
  53. package/dist/src/lib/parse-atts.test.d.ts +0 -1
  54. package/dist/src/lib/simplestyle.test.d.ts +0 -1
  55. package/dist/src/lib/util.test.d.ts +0 -1
  56. package/dist/src/testability.test.d.ts +0 -1
  57. package/dist/src/version.d.ts +0 -1
  58. /package/dist/embed-chunks/{2489af4328c51b71e92d.js.LICENSE.txt → 12cbd0d1cb4cf744c32f.js.LICENSE.txt} +0 -0
  59. /package/dist/{src/lib → lib}/CustomAttributionControl.d.ts +0 -0
  60. /package/dist/{src/lib → lib}/controls/geolonia-control.d.ts +0 -0
  61. /package/dist/{src/lib → lib}/geolonia-map.d.ts +0 -0
  62. /package/dist/{src/lib → lib}/geolonia-marker.d.ts +0 -0
  63. /package/dist/{src/lib → lib}/maplibre-util.d.ts +0 -0
  64. /package/dist/{src/lib → lib}/render.d.ts +0 -0
  65. /package/dist/{src/lib → lib}/simplestyle-vector.d.ts +0 -0
  66. /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
- env:
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
- env:
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/v1/embed?geolonia-api-key=YOUR-API-KEY"></script>
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/v1/embed"></script>
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