Skip to content

Commit 9e3df37

Browse files
author
Rob Tjalma
authored
Merge pull request #94 from com-pas/service-worker-and-401
Change Workbox config to excluded index.html and also compas url's.
2 parents e0b3f4a + 010bfb5 commit 9e3df37

File tree

5 files changed

+36
-18
lines changed

5 files changed

+36
-18
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<!-- Original URL from Google: https://fonts.googleapis.com/css?family=Material+Icons+Outlined&display=block -->
1414
<link href="public/google/icons/material-icons-outlined.css" rel="stylesheet">
1515
<link href="public/css/normalize.css" rel="stylesheet">
16-
<link rel="manifest" href="manifest.json">
16+
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
1717
<link rel="icon" type="image/png" sizes="16x16" href="public/favicon-16x16.png">
1818
<link rel="icon" type="image/png" sizes="32x32" href="public/favicon-32x32.png">
1919
<link rel="icon" type="image/png" sizes="192x192" href="public/icon-192x192.png">

package.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"release:patch": "standard-version --release-as patch",
6666
"release:major": "standard-version --release-as major",
6767
"build": "npm run test && npm run build:notest && cp .nojekyll build/",
68-
"build:notest": "npm run doc && snowpack build && workbox generateSW workbox-config.cjs",
68+
"build:notest": "npm run doc && npm run build:only",
69+
"build:only": "snowpack build && workbox generateSW workbox-config.cjs",
6970
"start": "snowpack dev"
7071
},
7172
"devDependencies": {
@@ -128,18 +129,28 @@
128129
]
129130
},
130131
"snowpack": {
132+
"buildOptions": {
133+
"clean": true
134+
},
131135
"exclude": [
132136
"**/node_modules/**/*",
133-
"**/*.@(spec|test).@(js|mjs)",
134-
"test/**/*",
135-
"out-tsc/**/*",
136137
".editorconfig",
137138
".eslintrc.cjs",
138-
".gitignore",
139139
".travis.yml",
140-
"karma.conf.cjs",
141-
"package*",
142-
"tsconfig.json"
140+
"**/karma.conf.cjs",
141+
"**/Dockerfile",
142+
"**/package*.json",
143+
"**/tsconfig.json",
144+
"**/workbox-config.cjs",
145+
"**/*.@(spec|test).@(js|mjs)",
146+
"**/__snapshots__/**/*",
147+
"**/coverage/**/*",
148+
"**/out-tsc/**/*",
149+
"**/test/**/*",
150+
".gitignore",
151+
"**/.git/**",
152+
"**/.github/**",
153+
"**/.idea/**"
143154
],
144155
"plugins": [
145156
"@snowpack/plugin-typescript"

src/compas/CompasSession.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ export function renderCompasSessionDialogs(doc: Document | null, docName: string
153153

154154
let pingTimer: NodeJS.Timeout | null = null;
155155

156-
async function executeKeepAlivePing() {
157-
await CompasUserInfoService().ping()
158-
.finally(() => pingTimer = null)
156+
function resetKeepAlivePing() {
157+
pingTimer = null;
159158
}
160159

161160
function schedulePing() {
162-
if (!pingTimer) {
161+
if (pingTimer === null) {
163162
// Every minute we will send a Ping to the CoMPAS Services while the user is still active.
164163
// This to keep the connection alive so long the user is working.
165-
pingTimer = setTimeout(executeKeepAlivePing, (60 * 1000));
164+
CompasUserInfoService().ping().finally(() => console.debug('Ping executed.'))
165+
pingTimer = setTimeout(resetKeepAlivePing, (60 * 1000));
166166
}
167167
}
168168

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"compilerOptions": {
33
"target": "es2020",
44
"module": "esnext",

workbox-config.cjs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
module.exports = {
2+
cacheId: 'compas',
23
globDirectory: 'build/',
34
globPatterns: [
5+
'_snowpack/**/*.{md,js,png,xml,pdf,css,html,info,json,ico,svg,wasm}',
46
'public/**/*.{md,js,png,xml,pdf,css,html,info,json,ico,svg,wasm}',
57
'src/**/*.{md,js,png,xml,pdf,css,html,info,json,ico,svg,wasm}',
6-
'web_modules/**/*.{md,js,png,xml,pdf,css,html,info,json,ico,svg,wasm}',
7-
'*.{md,js,png,xml,pdf,css,html,info,json,ico,svg,wasm}',
8+
'*.{md,json,ico,xml}',
89
],
910
swDest: 'build/sw.js',
1011
runtimeCaching: [
1112
{
12-
urlPattern: /.*/,
13+
urlPattern: /\/(_snowpack|public|src)\/.*/,
1314
handler: 'NetworkFirst',
15+
options: {
16+
cacheName: 'compas-runtime-http',
17+
fetchOptions: {
18+
credentials: 'include',
19+
},
20+
}
1421
},
1522
],
1623
skipWaiting: true,

0 commit comments

Comments
 (0)