Skip to content
This repository was archived by the owner on Sep 9, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const getWorker = (file, content, options) => {
if (options.mode === 'shared') {
return `new SharedWorker(${publicWorkerPath}, options)`;
}

if (options.mode === 'service') {
return `('serviceWorker' in navigator)
? navigator.serviceWorker.register(${publicWorkerPath}, options)
: Promise.reject(
new Error('navigator.serviceWorker is not supported in this browser')
)
`;
}
}

if (options.inline) {
Expand Down
3 changes: 3 additions & 0 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"name": {
"type": "string"
},
"mode": {
"type": "string"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we specify enumeration here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think so will do (need to look it up again first 😛 ). Otherwise needs to throw in the code

},
"inline": {
"type": "boolean"
},
Expand Down