@geolonia/embed 4.3.0 → 5.0.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 (63) hide show
  1. package/.github/workflows/build.yml +99 -36
  2. package/.nvmrc +1 -1
  3. package/.prettierrc.json +4 -0
  4. package/.tool-versions +1 -1
  5. package/README.md +7 -1
  6. package/dist/e2e/basic.spec.d.ts +8 -0
  7. package/dist/e2e/helper.d.ts +4 -0
  8. package/dist/embed +2 -1
  9. package/dist/embed-chunks/2489af4328c51b71e92d.js +2 -0
  10. package/dist/embed-chunks/6e05bbf5f391fda5b858.js +1 -0
  11. package/dist/embed.js +2 -1
  12. package/dist/embed.js.LICENSE.txt +4 -0
  13. package/dist/playwright.config.d.ts +9 -0
  14. package/dist/{embed.d.ts → src/embed.d.ts} +3 -1
  15. package/dist/{lib → src/lib}/geolonia-map.d.ts +10 -2
  16. package/dist/{lib → src/lib}/geolonia-marker.d.ts +1 -2
  17. package/dist/{lib → src/lib}/maplibre-util.d.ts +1 -3
  18. package/dist/{lib → src/lib}/util.d.ts +6 -3
  19. package/dist/src/lib/util.test.d.ts +1 -0
  20. package/dist/src/testability.test.d.ts +1 -0
  21. package/dist/src/version.d.ts +1 -0
  22. package/e2e/basic.spec.ts +52 -0
  23. package/e2e/helper.ts +12 -0
  24. package/e2e/map.spec.ts +69 -0
  25. package/eslint.config.js +232 -0
  26. package/package.json +25 -12
  27. package/playwright.config.ts +79 -0
  28. package/src/embed.ts +13 -7
  29. package/src/lib/CustomAttributionControl.ts +52 -29
  30. package/src/lib/geolonia-map.ts +144 -38
  31. package/src/lib/geolonia-marker.ts +9 -6
  32. package/src/lib/keyring.test.ts +18 -0
  33. package/src/lib/keyring.ts +11 -13
  34. package/src/lib/maplibre-util.ts +31 -19
  35. package/src/lib/parse-atts.test.ts +2 -1
  36. package/src/lib/render.ts +18 -7
  37. package/src/lib/simplestyle-vector.ts +42 -13
  38. package/src/lib/simplestyle.test.ts +80 -69
  39. package/src/lib/simplestyle.ts +61 -43
  40. package/src/lib/util.test.ts +108 -21
  41. package/src/lib/util.ts +115 -32
  42. package/src/testability.test.ts +46 -0
  43. package/tsconfig.json +3 -1
  44. package/webpack.config.js +10 -1
  45. package/.eslintignore +0 -3
  46. package/.eslintrc.js +0 -14
  47. package/.prettierrc.js +0 -1
  48. package/dist/embed-chunks/b52b89229e47dc93c64b.js +0 -2
  49. package/dist/embed-chunks/d0f087405f7ae2fcf1c1.js +0 -1
  50. package/dist/version.d.ts +0 -1
  51. /package/dist/{lib/keyring.test.d.ts → e2e/map.spec.d.ts} +0 -0
  52. /package/dist/embed-chunks/{b52b89229e47dc93c64b.js.LICENSE.txt → 2489af4328c51b71e92d.js.LICENSE.txt} +0 -0
  53. /package/dist/{lib → src/lib}/CustomAttributionControl.d.ts +0 -0
  54. /package/dist/{lib → src/lib}/controls/geolonia-control.d.ts +0 -0
  55. /package/dist/{lib → src/lib}/keyring.d.ts +0 -0
  56. /package/dist/{lib/parse-atts.test.d.ts → src/lib/keyring.test.d.ts} +0 -0
  57. /package/dist/{lib → src/lib}/parse-atts.d.ts +0 -0
  58. /package/dist/{lib/simplestyle.test.d.ts → src/lib/parse-atts.test.d.ts} +0 -0
  59. /package/dist/{lib → src/lib}/render.d.ts +0 -0
  60. /package/dist/{lib → src/lib}/simplestyle-vector.d.ts +0 -0
  61. /package/dist/{lib → src/lib}/simplestyle.d.ts +0 -0
  62. /package/dist/{lib/util.test.d.ts → src/lib/simplestyle.test.d.ts} +0 -0
  63. /package/dist/{types-internal.d.ts → src/types-internal.d.ts} +0 -0
@@ -11,28 +11,40 @@ on:
11
11
  branches: [master]
12
12
 
13
13
  jobs:
14
+ act-test:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Block obsolete job execution
18
+ run: |
19
+ if [ -n "$ACT" ]; then
20
+ echo "Running in act, some jobs are skipped"
21
+ exit 1
22
+ else
23
+ exit 0
24
+ fi
25
+ continue-on-error: true
14
26
  build:
15
27
  runs-on: ubuntu-latest
16
28
  strategy:
17
29
  matrix:
18
- node-version: ['18.x']
30
+ node-version: ['22.x']
19
31
  steps:
20
- - uses: actions/checkout@v3
32
+ - uses: actions/checkout@v4
21
33
  - name: Use Node.js ${{ matrix.node-version }}
22
- uses: actions/setup-node@v3
34
+ uses: actions/setup-node@v4
23
35
  with:
24
36
  node-version: ${{ matrix.node-version }}
25
37
  - name: Cache node_modules
26
- uses: actions/cache@v3
38
+ uses: actions/cache@v4
27
39
  with:
28
40
  path: node_modules
29
- key: modules-cache-v1-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
30
- - run: yarn install
31
- - run: yarn lint
32
- - run: yarn test
33
- - run: yarn build
41
+ key: modules-cache-v1-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
42
+ - run: npm install
43
+ - run: npm run lint
44
+ - run: npm run test
45
+ - run: npm run build
34
46
  - name: save the built
35
- uses: actions/upload-artifact@v3
47
+ uses: actions/upload-artifact@v4
36
48
  if: "!failure()"
37
49
  with:
38
50
  retention-days: 1
@@ -46,18 +58,19 @@ jobs:
46
58
  runs-on: ubuntu-latest
47
59
  needs:
48
60
  - build
61
+ - act-test
49
62
  if: ${{ github.ref == 'refs/heads/master' }}
50
63
  steps:
51
- - uses: actions/checkout@v3
52
- - uses: actions/setup-node@v3
64
+ - uses: actions/checkout@v4
65
+ - uses: actions/setup-node@v4
53
66
  with:
54
- node-version: '18.x'
67
+ node-version: '22.x'
55
68
  - name: Clean repo
56
69
  run: |
57
70
  git checkout --orphan gh-pages
58
71
  git rm -rf . > /dev/null 2>&1
59
72
  - name: load the built
60
- uses: actions/download-artifact@v3
73
+ uses: actions/download-artifact@v4
61
74
  with:
62
75
  name: the-built
63
76
  - name: Setup and deploy Github Pages
@@ -75,17 +88,18 @@ jobs:
75
88
  runs-on: ubuntu-latest
76
89
  needs:
77
90
  - build
91
+ - act-test
78
92
  if: startsWith(github.ref, 'refs/tags/v')
79
93
  steps:
80
- - uses: actions/checkout@v3
81
- - uses: actions/setup-node@v3
94
+ - uses: actions/checkout@v4
95
+ - uses: actions/setup-node@v4
82
96
  with:
83
97
  tag_name: 'v%s'
84
- node-version: '18.x'
98
+ node-version: '22.x'
85
99
  registry-url: 'https://registry.npmjs.org'
86
100
  scope: '@geolonia'
87
101
  - name: load the built
88
- uses: actions/download-artifact@v3
102
+ uses: actions/download-artifact@v4
89
103
  with:
90
104
  name: the-built
91
105
  - name: 'Publish to NPM (latest)'
@@ -98,23 +112,72 @@ jobs:
98
112
  run: npm publish --access=public --tag=next
99
113
  env:
100
114
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
101
- - name: 'Checkout geolonia/cdn.geolonia.com'
102
- uses: actions/checkout@v3
115
+ deploy:
116
+ needs: build
117
+ runs-on: ubuntu-latest
118
+ if: startsWith(github.ref, 'refs/tags/v')
119
+
120
+ # These permissions are needed to interact with GitHub's OIDC Token endpoint.
121
+ permissions:
122
+ id-token: write
123
+ contents: read
124
+
125
+ steps:
126
+ - uses: actions/checkout@v4
103
127
  with:
104
- token: ${{ secrets.PAT_FOR_CDN_GEOLONIA_COM }}
105
- repository: geolonia/cdn.geolonia.com
106
- path: ./cdn.geolonia.com
107
- - name: 'Build Embed API'
108
- run: npm run build:embed
109
- working-directory: ./cdn.geolonia.com
110
- - name: 'Create PR in geolonia/cdn.geolonia.com'
111
- uses: peter-evans/create-pull-request@v4
128
+ fetch-depth: 0
129
+
130
+ - uses: actions/download-artifact@v4
131
+ with: { name: the-built, path: ./ }
132
+
133
+ - name: Read version
134
+ id: version
135
+ run: |
136
+ TAG=${GITHUB_REF#refs/tags/}
137
+ VERSION=${TAG#v}
138
+ MAJOR=$(echo $VERSION | cut -d. -f1)
139
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
140
+ echo "major_version=$MAJOR" >> "$GITHUB_OUTPUT"
141
+
142
+ - name: Restore timestamps
143
+ uses: chetan/git-restore-mtime-action@v1
144
+
145
+ - name: Configure AWS Credentials for test
146
+ if: ${{ env.ACT }}
147
+ uses: aws-actions/configure-aws-credentials@v1
112
148
  with:
113
- token: ${{ secrets.PAT_FOR_CDN_GEOLONIA_COM }}
114
- path: ./cdn.geolonia.com
115
- title: "Release @geolonia/embed"
116
- body: |
117
- Release @geolonia/embed
118
- https://github.com/geolonia/embed の GitHub Actions によって自動作成
119
- labels: 🚀♻️リリース定期タスク
120
- reviewers: keichan34
149
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
150
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
151
+ aws-region: ${{ env.AWS_REGION }}
152
+
153
+ - name: Configure AWS Credentials for deploy
154
+ if: ${{ !env.ACT }}
155
+ uses: aws-actions/configure-aws-credentials@v1
156
+ with:
157
+ aws-region: ap-northeast-1
158
+ role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE }}
159
+
160
+ - name: Deploy to S3
161
+ run: |
162
+ # Note: The default max-age is set at 3600 seconds or 1 hour. After 1 hour,
163
+ # the client will mark the resource as stale, and require a refresh.
164
+ # In most cases, this will result in a if-modified-since conditional request.
165
+
166
+ # For resources that are immutable (for example, embed-chunks), the max-age is set to immutable.
167
+ # For resources that will be manually invalidated, an addition s-maxage so CloudFront keeps the file in its cache as long as possible.
168
+
169
+ # Deploy embed chunks -- because they have fingerprints in the filename, they're immutable
170
+ aws s3 sync ./dist/embed-chunks s3://${{ secrets.CDN_BUCKET }}/embed/v${{ steps.version.outputs.major_version }}/embed-chunks --cache-control "public,max-age=31536000,immutable"
171
+ aws s3 sync ./dist/embed-chunks s3://${{ secrets.CDN_BUCKET }}/embed/v${{ steps.version.outputs.version }}/embed-chunks --cache-control "public,max-age=31536000,immutable"
172
+
173
+ # Deploy main embed entrypoint
174
+ # I used to use s-maxage here, but after testing decided to revert back to only using max-age.
175
+ # If you use s-maxage that is much longer than max-age, the age header will be longer than
176
+ # max-age, and the browser will think that the file is expired. Using max-age will make
177
+ # CloudFront fetch a new file every 3600 seconds, resetting the Age header
178
+ aws s3 cp ./dist/embed s3://${{ secrets.CDN_BUCKET }}/embed/v${{ steps.version.outputs.major_version }}/embed --cache-control "public,max-age=3600" --content-type "application/javascript; charset=UTF-8"
179
+ aws s3 cp ./dist/embed.js.LICENSE.txt s3://${{ secrets.CDN_BUCKET }}/embed/v${{ steps.version.outputs.major_version }}/embed.js.LICENSE.txt --cache-control "public,max-age=3600" --content-type "text/plain; charset=UTF-8"
180
+ aws s3 cp ./dist/embed s3://${{ secrets.CDN_BUCKET }}/embed/v${{ steps.version.outputs.version }}/embed --cache-control "public,max-age=3600" --content-type "application/javascript; charset=UTF-8"
181
+ aws s3 cp ./dist/embed.js.LICENSE.txt s3://${{ secrets.CDN_BUCKET }}/embed/v${{ steps.version.outputs.version }}/embed.js.LICENSE.txt --cache-control "public,max-age=3600" --content-type "text/plain; charset=UTF-8"
182
+
183
+ aws cloudfront create-invalidation --distribution-id "${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }}" --paths "/embed/v${{ steps.version.outputs.major_version }}/embed" "/embed/v${{ steps.version.outputs.version }}/embed"
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v18
1
+ v22
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "semi": true
4
+ }
package/.tool-versions CHANGED
@@ -1 +1 @@
1
- nodejs 18.16.0
1
+ nodejs 22.21.0
package/README.md CHANGED
@@ -46,10 +46,16 @@ You can see more examples at [https://geolonia.github.io/embed/](https://geoloni
46
46
 
47
47
  ## Development
48
48
 
49
+ ### Requirements
50
+
51
+ - node.js >= 22.18
52
+
53
+ ### How to build
54
+
49
55
  ```shell
50
56
  $ git clone git@github.com:geolonia/embed.git
51
57
  $ cd embed
52
- $ yarn
58
+ $ npm install
53
59
  $ npm start # run dev server
54
60
  $ npm test # run tests
55
61
  $ npm run build # build production bundle
@@ -0,0 +1,8 @@
1
+ import { Geolonia } from '../src/embed';
2
+ declare global {
3
+ interface Window {
4
+ geolonia: Geolonia;
5
+ maplibregl?: Geolonia;
6
+ mapboxgl?: Geolonia;
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ import { Page } from '@playwright/test';
2
+ export declare const TEST_URL = "http://localhost:3000/e2e";
3
+ export declare const LOAD_TIMEOUT = 5000;
4
+ export declare function waitForMapLoad(page: Page, selector?: string): Promise<void>;