@geolonia/embed 4.3.0 → 5.0.0

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 (47) hide show
  1. package/.eslintrc.js +3 -0
  2. package/.github/workflows/build.yml +89 -28
  3. package/dist/e2e/basic.spec.d.ts +8 -0
  4. package/dist/e2e/helper.d.ts +4 -0
  5. package/dist/embed +2 -1
  6. package/dist/embed-chunks/416af3373e37004e65f4.js +1 -0
  7. package/dist/embed-chunks/488aacb380a87ea633f6.js +2 -0
  8. package/dist/embed.js +2 -1
  9. package/dist/embed.js.LICENSE.txt +4 -0
  10. package/dist/playwright.config.d.ts +9 -0
  11. package/dist/{lib → src/lib}/geolonia-map.d.ts +10 -1
  12. package/dist/{lib → src/lib}/maplibre-util.d.ts +1 -3
  13. package/dist/{lib → src/lib}/util.d.ts +5 -3
  14. package/dist/src/lib/util.test.d.ts +1 -0
  15. package/dist/src/testability.test.d.ts +1 -0
  16. package/dist/src/version.d.ts +1 -0
  17. package/e2e/basic.spec.ts +52 -0
  18. package/e2e/helper.ts +12 -0
  19. package/e2e/map.spec.ts +69 -0
  20. package/package.json +8 -4
  21. package/playwright.config.ts +79 -0
  22. package/src/embed.ts +1 -1
  23. package/src/lib/geolonia-map.ts +23 -4
  24. package/src/lib/parse-atts.test.ts +2 -0
  25. package/src/lib/simplestyle.ts +7 -10
  26. package/src/lib/util.test.ts +40 -2
  27. package/src/lib/util.ts +29 -2
  28. package/src/testability.test.ts +43 -0
  29. package/tsconfig.json +3 -1
  30. package/dist/embed-chunks/b52b89229e47dc93c64b.js +0 -2
  31. package/dist/embed-chunks/d0f087405f7ae2fcf1c1.js +0 -1
  32. package/dist/version.d.ts +0 -1
  33. /package/dist/{lib/keyring.test.d.ts → e2e/map.spec.d.ts} +0 -0
  34. /package/dist/embed-chunks/{b52b89229e47dc93c64b.js.LICENSE.txt → 488aacb380a87ea633f6.js.LICENSE.txt} +0 -0
  35. /package/dist/{embed.d.ts → src/embed.d.ts} +0 -0
  36. /package/dist/{lib → src/lib}/CustomAttributionControl.d.ts +0 -0
  37. /package/dist/{lib → src/lib}/controls/geolonia-control.d.ts +0 -0
  38. /package/dist/{lib → src/lib}/geolonia-marker.d.ts +0 -0
  39. /package/dist/{lib → src/lib}/keyring.d.ts +0 -0
  40. /package/dist/{lib/parse-atts.test.d.ts → src/lib/keyring.test.d.ts} +0 -0
  41. /package/dist/{lib → src/lib}/parse-atts.d.ts +0 -0
  42. /package/dist/{lib/simplestyle.test.d.ts → src/lib/parse-atts.test.d.ts} +0 -0
  43. /package/dist/{lib → src/lib}/render.d.ts +0 -0
  44. /package/dist/{lib → src/lib}/simplestyle-vector.d.ts +0 -0
  45. /package/dist/{lib → src/lib}/simplestyle.d.ts +0 -0
  46. /package/dist/{lib/util.test.d.ts → src/lib/simplestyle.test.d.ts} +0 -0
  47. /package/dist/{types-internal.d.ts → src/types-internal.d.ts} +0 -0
package/.eslintrc.js CHANGED
@@ -11,4 +11,7 @@ module.exports = {
11
11
  sourceType: 'module',
12
12
  project: './tsconfig.json',
13
13
  },
14
+ rules: {
15
+ '@typescript-eslint/ban-ts-comment': 'off',
16
+ },
14
17
  };
@@ -11,19 +11,31 @@ 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
30
  node-version: ['18.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
41
  key: modules-cache-v1-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
@@ -32,7 +44,7 @@ jobs:
32
44
  - run: yarn test
33
45
  - run: yarn 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,10 +58,11 @@ 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
67
  node-version: '18.x'
55
68
  - name: Clean repo
@@ -57,7 +70,7 @@ jobs:
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
98
  node-version: '18.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,70 @@ 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: arn:aws:iam::762706324393:role/github-actions-embed-deploy
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 }}/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 }}/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 }}/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 s3://${{ secrets.CDN_BUCKET }}/v${{ steps.version.outputs.version }}/embed --cache-control "public,max-age=3600" --content-type "application/javascript; charset=UTF-8"
180
+
181
+ aws cloudfront create-invalidation --distribution-id "E1ZFNBWBSCLVFC" --paths "/v${{ steps.version.outputs.major_version }}/embed" "/v${{ steps.version.outputs.version }}/embed"
@@ -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>;