@geolonia/embed 5.2.1 → 6.0.0-pre.2

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 +38 -19
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +24 -1
  4. package/dist/embed +1 -1
  5. package/dist/embed-chunks/4ada77b78cc0cc5ccef9.js +1 -0
  6. package/dist/embed-chunks/8176630945512b29f294.js +2 -0
  7. package/dist/embed-chunks/c783fffcd28083f7d5cb.js +2 -0
  8. package/dist/embed-chunks/f2124097fda51d0079ee.js +1 -0
  9. package/dist/embed-core.d.ts +6 -7
  10. package/dist/embed-core.js +1 -1
  11. package/dist/embed.d.ts +2 -4
  12. package/dist/embed.js +1 -1
  13. package/dist/lib/parse-atts.d.ts +19 -0
  14. package/dist/lib/render.d.ts +1 -1
  15. package/dist/lib/util.d.ts +14 -55
  16. package/dist/types.d.ts +155 -1
  17. package/dist/version.d.ts +1 -1
  18. package/e2e/auto-render.spec.ts +44 -0
  19. package/e2e/basic.spec.ts +9 -50
  20. package/e2e/cleanup.spec.ts +43 -0
  21. package/e2e/data-attributes.spec.ts +56 -0
  22. package/e2e/globals.spec.ts +51 -0
  23. package/e2e/helper.ts +170 -4
  24. package/e2e/iframe.spec.ts +35 -0
  25. package/e2e/lazy-loading.spec.ts +32 -0
  26. package/e2e/legacy-constructor.spec.ts +102 -0
  27. package/e2e/plugin.spec.ts +25 -0
  28. package/e2e/pmtiles.spec.ts +13 -0
  29. package/package.json +8 -13
  30. package/playwright.config.ts +6 -32
  31. package/src/embed-core.ts +12 -14
  32. package/src/embed.ts +2 -4
  33. package/src/lib/parse-atts.test.ts +186 -18
  34. package/src/lib/parse-atts.ts +151 -5
  35. package/src/lib/render.ts +50 -12
  36. package/src/lib/util.ts +37 -350
  37. package/src/types.ts +155 -1
  38. package/src/version.ts +1 -0
  39. package/typedoc.json +13 -0
  40. package/vitest.config.ts +7 -0
  41. package/dist/embed-chunks/12cbd0d1cb4cf744c32f.js +0 -2
  42. package/dist/embed-chunks/8a521e8312a5b4da123d.js +0 -2
  43. package/dist/lib/CustomAttributionControl.d.ts +0 -47
  44. package/dist/lib/controls/geolonia-control.d.ts +0 -7
  45. package/dist/lib/geolonia-map.d.ts +0 -30
  46. package/dist/lib/geolonia-marker.d.ts +0 -9
  47. package/dist/lib/keyring.d.ts +0 -45
  48. package/dist/lib/maplibre-util.d.ts +0 -25
  49. package/dist/lib/simplestyle-vector.d.ts +0 -26
  50. package/dist/lib/simplestyle.d.ts +0 -31
  51. package/e2e/external-style.spec.ts +0 -25
  52. package/e2e/map.spec.ts +0 -69
  53. package/src/lib/CustomAttributionControl.ts +0 -394
  54. package/src/lib/controls/geolonia-control.ts +0 -38
  55. package/src/lib/geolonia-map.ts +0 -429
  56. package/src/lib/geolonia-marker.ts +0 -53
  57. package/src/lib/keyring.test.ts +0 -127
  58. package/src/lib/keyring.ts +0 -136
  59. package/src/lib/maplibre-util.ts +0 -137
  60. package/src/lib/marker.svg +0 -1
  61. package/src/lib/simplestyle-vector.ts +0 -257
  62. package/src/lib/simplestyle.test.ts +0 -289
  63. package/src/lib/simplestyle.ts +0 -435
  64. package/src/lib/util.test.ts +0 -364
  65. /package/dist/embed-chunks/{12cbd0d1cb4cf744c32f.js.LICENSE.txt → 8176630945512b29f294.js.LICENSE.txt} +0 -0
  66. /package/dist/embed-chunks/{8a521e8312a5b4da123d.js.LICENSE.txt → c783fffcd28083f7d5cb.js.LICENSE.txt} +0 -0
@@ -29,22 +29,18 @@ jobs:
29
29
  matrix:
30
30
  node-version: ['22.x']
31
31
  steps:
32
- - uses: actions/checkout@v4
32
+ - uses: actions/checkout@v6
33
33
  - name: Use Node.js ${{ matrix.node-version }}
34
- uses: actions/setup-node@v4
34
+ uses: actions/setup-node@v6
35
35
  with:
36
36
  node-version: ${{ matrix.node-version }}
37
- - name: Cache node_modules
38
- uses: actions/cache@v4
39
- with:
40
- path: node_modules
41
- key: modules-cache-v1-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
42
- - run: npm install
37
+ cache: 'npm'
38
+ - run: npm ci
43
39
  - run: npm run lint
44
40
  - run: npm run test
45
41
  - run: npm run build
46
42
  - name: save the built
47
- uses: actions/upload-artifact@v4
43
+ uses: actions/upload-artifact@v7
48
44
  if: "!failure()"
49
45
  with:
50
46
  retention-days: 1
@@ -53,6 +49,29 @@ jobs:
53
49
  dist/
54
50
  docs/
55
51
 
52
+ e2e:
53
+ runs-on: ubuntu-latest
54
+ timeout-minutes: 30
55
+ needs: build
56
+ steps:
57
+ - uses: actions/checkout@v6
58
+ - uses: actions/setup-node@v6
59
+ with:
60
+ node-version: '22.x'
61
+ cache: 'npm'
62
+ - run: npm ci
63
+ - name: Install Playwright
64
+ run: npx playwright install --with-deps chromium
65
+ - name: Run e2e tests
66
+ run: npm run e2e
67
+ - name: Upload Playwright report
68
+ uses: actions/upload-artifact@v7
69
+ if: ${{ !cancelled() }}
70
+ with:
71
+ name: playwright-report
72
+ path: playwright-report/
73
+ retention-days: 7
74
+
56
75
  gh-pages:
57
76
  name: 'Host with GitHub Pages'
58
77
  runs-on: ubuntu-latest
@@ -61,8 +80,8 @@ jobs:
61
80
  - act-test
62
81
  if: ${{ github.ref == 'refs/heads/master' }}
63
82
  steps:
64
- - uses: actions/checkout@v4
65
- - uses: actions/setup-node@v4
83
+ - uses: actions/checkout@v6
84
+ - uses: actions/setup-node@v6
66
85
  with:
67
86
  node-version: '22.x'
68
87
  - name: Clean repo
@@ -70,7 +89,7 @@ jobs:
70
89
  git checkout --orphan gh-pages
71
90
  git rm -rf . > /dev/null 2>&1
72
91
  - name: load the built
73
- uses: actions/download-artifact@v4
92
+ uses: actions/download-artifact@v8
74
93
  with:
75
94
  name: the-built
76
95
  - name: Setup and deploy Github Pages
@@ -91,18 +110,18 @@ jobs:
91
110
  contents: read
92
111
  needs:
93
112
  - build
113
+ - e2e
94
114
  - act-test
95
115
  if: startsWith(github.ref, 'refs/tags/v')
96
116
  steps:
97
- - uses: actions/checkout@v4
98
- - uses: actions/setup-node@v4
117
+ - uses: actions/checkout@v6
118
+ - uses: actions/setup-node@v6
99
119
  with:
100
- tag_name: 'v%s'
101
120
  node-version: '22.x'
102
121
  registry-url: 'https://registry.npmjs.org'
103
122
  scope: '@geolonia'
104
123
  - name: load the built
105
- uses: actions/download-artifact@v4
124
+ uses: actions/download-artifact@v8
106
125
  with:
107
126
  name: the-built
108
127
 
@@ -118,7 +137,7 @@ jobs:
118
137
  run: npm publish --access=public --tag=next
119
138
 
120
139
  deploy:
121
- needs: build
140
+ needs: [build, e2e]
122
141
  runs-on: ubuntu-latest
123
142
  if: startsWith(github.ref, 'refs/tags/v')
124
143
 
@@ -128,11 +147,11 @@ jobs:
128
147
  contents: read
129
148
 
130
149
  steps:
131
- - uses: actions/checkout@v4
150
+ - uses: actions/checkout@v6
132
151
  with:
133
152
  fetch-depth: 0
134
153
 
135
- - uses: actions/download-artifact@v4
154
+ - uses: actions/download-artifact@v8
136
155
  with: { name: the-built, path: ./ }
137
156
 
138
157
  - name: Read version
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## @geolonia/embed
4
4
 
5
+ ### v6.0.0-pre.0
6
+
7
+ コア実装を `@geolonia/maps-core` に委譲し、embed は「HTML 埋め込みラッパー」に専念する構成へ移行しました。
8
+
9
+ - **Refactor**: 地図コア(`GeoloniaMap` / `GeoloniaMarker` / `SimpleStyle` / `SimpleStyleVector` / `keyring` / attribution・logo コントロール等)を [`@geolonia/maps-core`](https://github.com/geolonia/maps-core) に移管。embed 側には `data-*` 属性のパースと DOM 自動走査・遅延読み込み・プラグイン機構といったラッパー機能のみを残しました。
10
+ - **Breaking**: `GeoloniaMap` コンストラクタは `GeoloniaMapOptions` オブジェクトのみを受け取ります。DOM 要素や CSS セレクタ文字列の直接指定は廃止されました(`new geolonia.Map({ container })` を使用してください)。
11
+ - **Breaking**: `keyring.parse()`(DOM スキャン)は廃止されました。API キーは `<script src="...?geolonia-api-key=KEY">` から embed が読み取り、`keyring.setApiKey()` で maps-core に渡します(既存の script タグ方式は引き続き動作します)。
12
+ - **Internal**: maps-core が内包する依存(pmtiles / sanitize-html / tinycolor2 / turf / gesture-handling 等)を embed の直接依存から削除しました。
13
+
5
14
  ### nightly
6
15
 
7
16
  - **Feature**: Added support for external style.json URLs in `data-style` attribute
package/README.md CHANGED
@@ -51,7 +51,7 @@ npm install @geolonia/embed
51
51
  ```typescript
52
52
  import { GeoloniaMap, keyring } from "@geolonia/embed/core";
53
53
 
54
- keyring.apiKey = "YOUR-API-KEY";
54
+ keyring.setApiKey("YOUR-API-KEY");
55
55
 
56
56
  const map = new GeoloniaMap({
57
57
  container: "#map",
@@ -108,6 +108,29 @@ The `data-style` attribute accepts:
108
108
  - **Relative paths**: `./custom-style.json`, `/styles/my-style.json`
109
109
  - **Files ending in .json**: Automatically resolved to absolute URLs
110
110
 
111
+ #### data-lang attribute
112
+
113
+ The `data-lang` attribute controls the language of map labels:
114
+
115
+ - `ja` — Japanese labels
116
+ - `en` (or any other non-Japanese value) — English labels
117
+ - `auto` — follow the browser language (`navigator.languages`)
118
+ - **omitted** — same as `auto` (follows the browser language)
119
+
120
+ Only `ja` / `ja-jp` resolve to Japanese; every other value resolves to English.
121
+
122
+ **Important:** when neither `data-lang` nor `lang` is specified, the language follows the browser setting. On a non-Japanese browser this loads the English style (`en.json`). Set it explicitly to force a language:
123
+
124
+ ```html
125
+ <div class="geolonia" data-lang="ja" ...></div>
126
+ ```
127
+
128
+ When using the JavaScript API (`new GeoloniaMap({...})`), pass `lang` in the options instead of a `data-lang` attribute:
129
+
130
+ ```ts
131
+ const map = new GeoloniaMap({ container: "#map", lang: "ja" });
132
+ ```
133
+
111
134
  You can see more examples at [https://geolonia.github.io/embed/](https://geolonia.github.io/embed/).
112
135
 
113
136
  # Contributing