├── .gitattributes
├── .github
├── ISSUE_TEMPLATE.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── pull-request.yml
│ └── scorecards-analysis.yml
├── .gitignore
├── .husky
├── .gitignore
├── pre-commit
└── pre-push
├── .ncurc.js
├── .nvmrc
├── .prettierignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── cdn-details.json
├── demos
├── README.md
└── src
│ ├── workbox-background-sync-demo
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── example.txt
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-broadcast-update-demo
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-cacheable-response
│ ├── index.html
│ ├── package.json
│ ├── server.js
│ └── sw.js
│ ├── workbox-core
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-expiration
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-google-analytics
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-navigation-preload
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-precaching
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ ├── hello-world.1234.txt
│ │ ├── hello-world.5678.txt
│ │ └── test-file.txt
│ ├── sw-1.js
│ ├── sw-2.js
│ └── updateServer.js
│ ├── workbox-range-requests
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-routing
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ ├── demo-img.png
│ │ └── demo-popper.png
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-strategies
│ ├── index.html
│ ├── public
│ │ ├── cache-first.txt
│ │ ├── network-first.txt
│ │ ├── network-only.txt
│ │ └── stale-while-revalidate.txt
│ ├── sw.js
│ └── updateServer.js
│ ├── workbox-streams
│ ├── index.html
│ ├── package.json
│ ├── server.js
│ └── sw.js
│ ├── workbox-sw
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── demo-img.png
│ ├── sw.js
│ └── updateServer.js
│ └── workbox-window
│ ├── index.html
│ ├── package.json
│ ├── sw.js
│ └── updateServer.js
├── gulp-tasks
├── analyze-properties.js
├── build-node-packages.js
├── build-packages.js
├── build-sw-packages.js
├── build-window-packages.js
├── build.js
├── docs.js
├── lint.js
├── publish-cdn.js
├── publish-github.js
├── publish-glitch.js
├── publish-lerna.js
├── publish.js
├── test-integration.js
├── test-node.js
├── test-server.js
├── test.js
├── transpile-typescript.js
└── utils
│ ├── analyse-properties.js
│ ├── cdn-helper.js
│ ├── constants.js
│ ├── get-packages.js
│ ├── github-helper.js
│ ├── node-projects-babel.config.json
│ ├── output-filename-to-package-map.js
│ ├── package-runner.js
│ ├── pkg-path-to-name.js
│ ├── publish-helpers.js
│ ├── rollup-helper.js
│ ├── version-module.js
│ └── versioned-cdn-url.js
├── gulpfile.js
├── infra
├── pr-bot
│ └── aggregate-size-plugin.js
├── templates
│ └── reference-docs
│ │ └── jsdoc
│ │ ├── lang
│ │ └── en.yaml
│ │ ├── lib
│ │ └── publishjob.js
│ │ ├── publish.js
│ │ ├── static
│ │ └── jsdoc.css
│ │ └── views
│ │ ├── augments.hbs
│ │ ├── classes-links.hbs
│ │ ├── details-table-row.hbs
│ │ ├── details-table.hbs
│ │ ├── implements.hbs
│ │ ├── index-all.hbs
│ │ ├── index.hbs
│ │ ├── layout.hbs
│ │ ├── params.hbs
│ │ ├── properties.hbs
│ │ ├── see.hbs
│ │ ├── signature.hbs
│ │ ├── symbol-content.hbs
│ │ ├── symbol-detail.hbs
│ │ ├── symbol-header.hbs
│ │ ├── symbol-index-section.hbs
│ │ ├── symbol-index.hbs
│ │ ├── symbol-labels.hbs
│ │ ├── symbol-overview.hbs
│ │ └── toc-yaml.hbs
├── testing
│ ├── activate-and-control.js
│ ├── activate-sw-safari.js
│ ├── auto-stub-logger.mjs
│ ├── clean-sw.js
│ ├── comlink
│ │ ├── node-interface.js
│ │ ├── sw-interface.js
│ │ └── window-interface.js
│ ├── confirm-directory-contains.js
│ ├── env-it.js
│ ├── expectError.js
│ ├── generate-variant-tests.js
│ ├── helpers
│ │ ├── compareResponses.mjs
│ │ ├── extendable-event-utils.mjs
│ │ ├── generateOpaqueResponse.mjs
│ │ ├── generateUniqueResponse.mjs
│ │ └── sleep.mjs
│ ├── server
│ │ ├── cross-origin-server.js
│ │ ├── index.js
│ │ ├── request-counter.js
│ │ ├── routes
│ │ │ ├── build-file.js
│ │ │ ├── comlink.js
│ │ │ ├── integration-html.js
│ │ │ ├── sw-bundle.js
│ │ │ ├── templates-update.js
│ │ │ ├── templates.js
│ │ │ ├── test-sw.js
│ │ │ ├── test-window.js
│ │ │ ├── unique-etag.js
│ │ │ └── unique-value.js
│ │ ├── static
│ │ │ └── integration.html
│ │ ├── template-data.js
│ │ └── templates
│ │ │ ├── integration.html.njk
│ │ │ ├── sw-clients-claim.js.njk
│ │ │ ├── sw-no-skip-waiting.js.njk
│ │ │ ├── sw-script-version.js.njk
│ │ │ ├── sw-skip-waiting-deferred.js.njk
│ │ │ ├── sw-skip-waiting-on-message.js.njk
│ │ │ ├── sw-skip-waiting.js.njk
│ │ │ ├── sw-window-ready.js.njk
│ │ │ ├── test-sw-runner.js.njk
│ │ │ ├── test-sw.html.njk
│ │ │ └── test-window.html.njk
│ ├── validator
│ │ └── service-worker-runtime.js
│ ├── wait-until.js
│ ├── webdriver
│ │ ├── IframeManager.js
│ │ ├── executeAsyncAndCatch.js
│ │ ├── runUnitTests.js
│ │ ├── unregisterAllSWs.js
│ │ └── windowLoaded.js
│ └── webpack-build-check.js
├── type-overrides.d.ts
└── utils
│ ├── AsyncDebounce.js
│ └── log-helper.js
├── javascript.eslintrc.js
├── jsdoc.conf
├── lerna.json
├── package-lock.json
├── package.json
├── packages
├── workbox-background-sync
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── BackgroundSyncPlugin.ts
│ │ ├── Queue.ts
│ │ ├── QueueStore.ts
│ │ ├── StorableRequest.ts
│ │ ├── _version.ts
│ │ ├── index.ts
│ │ └── lib
│ │ │ ├── QueueDb.ts
│ │ │ ├── QueueStore.ts
│ │ │ └── StorableRequest.ts
│ └── tsconfig.json
├── workbox-broadcast-update
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── BroadcastCacheUpdate.ts
│ │ ├── BroadcastUpdatePlugin.ts
│ │ ├── _version.ts
│ │ ├── index.ts
│ │ ├── responsesAreSame.ts
│ │ └── utils
│ │ │ └── constants.ts
│ └── tsconfig.json
├── workbox-build
│ ├── .ncurc.js
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── _types.js
│ │ ├── cdn-details.json
│ │ ├── generate-sw.ts
│ │ ├── get-manifest.ts
│ │ ├── index.ts
│ │ ├── inject-manifest.ts
│ │ ├── lib
│ │ │ ├── additional-manifest-entries-transform.ts
│ │ │ ├── bundle.ts
│ │ │ ├── cdn-utils.ts
│ │ │ ├── copy-workbox-libraries.ts
│ │ │ ├── errors.ts
│ │ │ ├── escape-regexp.ts
│ │ │ ├── get-composite-details.ts
│ │ │ ├── get-file-details.ts
│ │ │ ├── get-file-hash.ts
│ │ │ ├── get-file-manifest-entries.ts
│ │ │ ├── get-file-size.ts
│ │ │ ├── get-source-map-url.ts
│ │ │ ├── get-string-details.ts
│ │ │ ├── get-string-hash.ts
│ │ │ ├── maximum-size-transform.ts
│ │ │ ├── modify-url-prefix-transform.ts
│ │ │ ├── module-registry.ts
│ │ │ ├── no-revision-for-urls-matching-transform.ts
│ │ │ ├── populate-sw-template.ts
│ │ │ ├── rebase-path.ts
│ │ │ ├── replace-and-update-source-map.ts
│ │ │ ├── runtime-caching-converter.ts
│ │ │ ├── stringify-without-comments.ts
│ │ │ ├── transform-manifest.ts
│ │ │ ├── translate-url-to-sourcemap-paths.ts
│ │ │ ├── validate-options.ts
│ │ │ └── write-sw-using-default-template.ts
│ │ ├── rollup-plugin-off-main-thread.d.ts
│ │ ├── schema
│ │ │ ├── GenerateSWOptions.json
│ │ │ ├── GetManifestOptions.json
│ │ │ ├── InjectManifestOptions.json
│ │ │ ├── WebpackGenerateSWOptions.json
│ │ │ └── WebpackInjectManifestOptions.json
│ │ ├── strip-comments.d.ts
│ │ ├── templates
│ │ │ └── sw-template.ts
│ │ └── types.ts
│ └── tsconfig.json
├── workbox-cacheable-response
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── CacheableResponse.ts
│ │ ├── CacheableResponsePlugin.ts
│ │ ├── _version.ts
│ │ └── index.ts
│ └── tsconfig.json
├── workbox-cli
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── app.ts
│ │ ├── bin.ts
│ │ └── lib
│ │ │ ├── cleanup-stack-trace.ts
│ │ │ ├── constants.ts
│ │ │ ├── errors.ts
│ │ │ ├── help-text.ts
│ │ │ ├── logger.ts
│ │ │ ├── questions
│ │ │ ├── ask-config-location.ts
│ │ │ ├── ask-extensions-to-cache.ts
│ │ │ ├── ask-questions.ts
│ │ │ ├── ask-root-of-web-app.ts
│ │ │ ├── ask-start_url-query-params.ts
│ │ │ ├── ask-sw-dest.ts
│ │ │ └── ask-sw-src.ts
│ │ │ ├── read-config.ts
│ │ │ └── run-wizard.ts
│ └── tsconfig.json
├── workbox-core
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── _private.ts
│ │ ├── _private
│ │ │ ├── Deferred.ts
│ │ │ ├── WorkboxError.ts
│ │ │ ├── assert.ts
│ │ │ ├── cacheMatchIgnoreParams.ts
│ │ │ ├── cacheNames.ts
│ │ │ ├── canConstructReadableStream.ts
│ │ │ ├── canConstructResponseFromBodyStream.ts
│ │ │ ├── dontWaitFor.ts
│ │ │ ├── executeQuotaErrorCallbacks.ts
│ │ │ ├── getFriendlyURL.ts
│ │ │ ├── logger.ts
│ │ │ ├── resultingClientExists.ts
│ │ │ ├── timeout.ts
│ │ │ └── waitUntil.ts
│ │ ├── _version.ts
│ │ ├── cacheNames.ts
│ │ ├── clientsClaim.ts
│ │ ├── copyResponse.ts
│ │ ├── index.ts
│ │ ├── models
│ │ │ ├── messages
│ │ │ │ ├── messageGenerator.ts
│ │ │ │ └── messages.ts
│ │ │ ├── pluginEvents.ts
│ │ │ └── quotaErrorCallbacks.ts
│ │ ├── registerQuotaErrorCallback.ts
│ │ ├── setCacheNameDetails.ts
│ │ ├── skipWaiting.ts
│ │ ├── types.ts
│ │ └── utils
│ │ │ ├── pluginUtils.ts
│ │ │ └── welcome.ts
│ └── tsconfig.json
├── workbox-expiration
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── CacheExpiration.ts
│ │ ├── ExpirationPlugin.ts
│ │ ├── _version.ts
│ │ ├── index.ts
│ │ └── models
│ │ │ └── CacheTimestampsModel.ts
│ └── tsconfig.json
├── workbox-google-analytics
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── _version.ts
│ │ ├── index.ts
│ │ ├── initialize.ts
│ │ └── utils
│ │ │ └── constants.ts
│ └── tsconfig.json
├── workbox-navigation-preload
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── _version.ts
│ │ ├── disable.ts
│ │ ├── enable.ts
│ │ ├── index.ts
│ │ └── isSupported.ts
│ └── tsconfig.json
├── workbox-precaching
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── PrecacheController.ts
│ │ ├── PrecacheFallbackPlugin.ts
│ │ ├── PrecacheRoute.ts
│ │ ├── PrecacheStrategy.ts
│ │ ├── _types.ts
│ │ ├── _version.ts
│ │ ├── addPlugins.ts
│ │ ├── addRoute.ts
│ │ ├── cleanupOutdatedCaches.ts
│ │ ├── createHandlerBoundToURL.ts
│ │ ├── getCacheKeyForURL.ts
│ │ ├── index.ts
│ │ ├── matchPrecache.ts
│ │ ├── precache.ts
│ │ ├── precacheAndRoute.ts
│ │ └── utils
│ │ │ ├── PrecacheCacheKeyPlugin.ts
│ │ │ ├── PrecacheInstallReportPlugin.ts
│ │ │ ├── createCacheKey.ts
│ │ │ ├── deleteOutdatedCaches.ts
│ │ │ ├── generateURLVariations.ts
│ │ │ ├── getCacheKeyForURL.ts
│ │ │ ├── getOrCreatePrecacheController.ts
│ │ │ ├── printCleanupDetails.ts
│ │ │ ├── printInstallDetails.ts
│ │ │ └── removeIgnoredSearchParams.ts
│ └── tsconfig.json
├── workbox-range-requests
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── RangeRequestsPlugin.ts
│ │ ├── _version.ts
│ │ ├── createPartialResponse.ts
│ │ ├── index.ts
│ │ └── utils
│ │ │ ├── calculateEffectiveBoundaries.ts
│ │ │ └── parseRangeHeader.ts
│ └── tsconfig.json
├── workbox-recipes
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── _version.ts
│ │ ├── googleFontsCache.ts
│ │ ├── imageCache.ts
│ │ ├── index.ts
│ │ ├── offlineFallback.ts
│ │ ├── pageCache.ts
│ │ ├── staticResourceCache.ts
│ │ └── warmStrategyCache.ts
│ └── tsconfig.json
├── workbox-routing
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── NavigationRoute.ts
│ │ ├── RegExpRoute.ts
│ │ ├── Route.ts
│ │ ├── Router.ts
│ │ ├── _types.ts
│ │ ├── _version.ts
│ │ ├── index.ts
│ │ ├── registerRoute.ts
│ │ ├── setCatchHandler.ts
│ │ ├── setDefaultHandler.ts
│ │ └── utils
│ │ │ ├── constants.ts
│ │ │ ├── getOrCreateDefaultRouter.ts
│ │ │ └── normalizeHandler.ts
│ └── tsconfig.json
├── workbox-strategies
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── CacheFirst.ts
│ │ ├── CacheOnly.ts
│ │ ├── NetworkFirst.ts
│ │ ├── NetworkOnly.ts
│ │ ├── StaleWhileRevalidate.ts
│ │ ├── Strategy.ts
│ │ ├── StrategyHandler.ts
│ │ ├── _version.ts
│ │ ├── index.ts
│ │ ├── plugins
│ │ │ └── cacheOkAndOpaquePlugin.ts
│ │ └── utils
│ │ │ └── messages.ts
│ └── tsconfig.json
├── workbox-streams
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── _types.ts
│ │ ├── _version.ts
│ │ ├── concatenate.ts
│ │ ├── concatenateToResponse.ts
│ │ ├── index.ts
│ │ ├── isSupported.ts
│ │ ├── strategy.ts
│ │ └── utils
│ │ │ └── createHeaders.ts
│ └── tsconfig.json
├── workbox-sw
│ ├── README.md
│ ├── _types.mjs
│ ├── _version.mjs
│ ├── controllers
│ │ └── WorkboxSW.mjs
│ ├── index.mjs
│ ├── package-lock.json
│ └── package.json
├── workbox-webpack-plugin
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── generate-sw.ts
│ │ ├── index.ts
│ │ ├── inject-manifest.ts
│ │ └── lib
│ │ │ ├── get-asset-hash.ts
│ │ │ ├── get-manifest-entries-from-compilation.ts
│ │ │ ├── get-script-files-for-chunks.ts
│ │ │ ├── get-sourcemap-asset-name.ts
│ │ │ ├── relative-to-output-path.ts
│ │ │ └── resolve-webpack-url.ts
│ └── tsconfig.json
└── workbox-window
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ ├── Workbox.ts
│ ├── _version.ts
│ ├── index.ts
│ ├── messageSW.ts
│ └── utils
│ │ ├── WorkboxEvent.ts
│ │ ├── WorkboxEventTarget.ts
│ │ └── urlsMatch.ts
│ └── tsconfig.json
├── prettier.config.js
├── test
├── all
│ └── node
│ │ ├── test-exports.js
│ │ ├── test-jsdocs.js
│ │ ├── test-package.js
│ │ ├── test-prod-builds.js
│ │ └── test-yarn-installation.js
├── workbox-background-sync
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ └── basic-example
│ │ │ ├── example.txt
│ │ │ ├── index.html
│ │ │ └── sw.js
│ └── sw
│ │ ├── lib
│ │ ├── test-QueueDb.mjs
│ │ ├── test-QueueStore.mjs
│ │ └── test-StorableRequest.mjs
│ │ ├── test-BackgroundSyncPlugin.mjs
│ │ └── test-Queue.mjs
├── workbox-broadcast-update
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ ├── index.html
│ │ └── sw.js
│ └── sw
│ │ ├── test-BroadcastCacheUpdate.mjs
│ │ ├── test-BroadcastUpdatePlugin.mjs
│ │ └── test-responsesAreSame.mjs
├── workbox-build
│ ├── node
│ │ ├── dependency-check.js
│ │ ├── generate-sw.js
│ │ ├── get-manifest.js
│ │ ├── inject-manifest.js
│ │ └── lib
│ │ │ ├── additional-manifest-entries-transform.js
│ │ │ ├── bundle.js
│ │ │ ├── cdn-utils.js
│ │ │ ├── copy-workbox-libraries.js
│ │ │ ├── escape-regexp.js
│ │ │ ├── get-composite-details.js
│ │ │ ├── get-file-details.js
│ │ │ ├── get-file-hash.js
│ │ │ ├── get-file-manifest-entries.js
│ │ │ ├── get-file-size.js
│ │ │ ├── get-string-details.js
│ │ │ ├── get-string-hash.js
│ │ │ ├── modify-url-prefix-transform.js
│ │ │ ├── module-registry.js
│ │ │ ├── no-revision-for-urls-matching-transform.js
│ │ │ ├── populate-sw-template.js
│ │ │ ├── replace-and-update-source-map.js
│ │ │ ├── runtime-caching-converter.js
│ │ │ ├── transform-manifest.js
│ │ │ ├── translate-url-to-sourcemap-paths.js
│ │ │ ├── validate-options.js
│ │ │ └── write-sw-using-default-template.js
│ └── static
│ │ ├── example-project-1
│ │ ├── .hidden-directory
│ │ │ ├── hello.html
│ │ │ └── hello.js
│ │ ├── images
│ │ │ ├── example-jpeg.jpg
│ │ │ └── web-fundamentals-icon192x192.png
│ │ ├── index.html
│ │ ├── page-1.html
│ │ ├── page-2.html
│ │ ├── styles
│ │ │ ├── stylesheet-1.css
│ │ │ └── stylesheet-2.css
│ │ └── webpackEntry.js
│ │ ├── expected-source-map.js.map
│ │ └── sw-injections
│ │ ├── bad-multiple-injection.js
│ │ ├── bad-no-injection.js
│ │ ├── basic-with-invalid-sourcemap.js.nolint
│ │ ├── basic-with-sourcemap-data-url.js.nolint
│ │ ├── basic-with-sourcemap.js.map
│ │ ├── basic-with-sourcemap.js.nolint
│ │ ├── basic.js
│ │ ├── custom-injection-point.js
│ │ ├── multiple-calls.js
│ │ ├── precache-and-route-options.js
│ │ └── sample-import.js
├── workbox-cacheable-response
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ └── cacheable-response-plugin
│ │ │ ├── example-1.txt
│ │ │ └── sw.js
│ └── sw
│ │ ├── test-CacheableResponse.mjs
│ │ └── test-CacheableResponsePlugin.mjs
├── workbox-cli
│ └── node
│ │ ├── app.js
│ │ ├── dependency-check.js
│ │ └── lib
│ │ ├── cleanup-stack-trace.js
│ │ ├── help-text.js
│ │ ├── logger.js
│ │ ├── questions
│ │ ├── ask-config-location.js
│ │ ├── ask-extensions-to-cache.js
│ │ ├── ask-questions.js
│ │ ├── ask-root-of-web-app.js
│ │ ├── ask-start_url-query-params.js
│ │ ├── ask-sw-dest.js
│ │ └── ask-sw-src.js
│ │ └── run-wizard.js
├── workbox-core
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ ├── core-in-browser
│ │ │ ├── index.html
│ │ │ └── sw.js
│ │ └── logger.html
│ └── sw
│ │ ├── _private
│ │ ├── test-Deferred.mjs
│ │ ├── test-assert.mjs
│ │ ├── test-cacheMatchIgnoreParams.mjs
│ │ ├── test-executeQuotaErrorCallbacks.mjs
│ │ ├── test-getFriendlyURL.mjs
│ │ ├── test-logger.mjs
│ │ ├── test-resultingClientExists.mjs
│ │ ├── test-timeout.mjs
│ │ └── test-waitUntil.mjs
│ │ ├── models
│ │ └── messages
│ │ │ └── test-messageGenerator.mjs
│ │ ├── test-cacheNames.mjs
│ │ ├── test-clientsClaim.mjs
│ │ ├── test-copyResponse.mjs
│ │ ├── test-registerQuotaErrorCallback.mjs
│ │ └── test-skipWaiting.mjs
├── workbox-expiration
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ ├── expiration-plugin
│ │ │ ├── example-1.txt
│ │ │ ├── example-2.txt
│ │ │ ├── sw-deletion.js
│ │ │ ├── sw-max-age-seconds.js
│ │ │ └── sw-max-entries.js
│ │ └── isURLExpired.html
│ └── sw
│ │ ├── test-CacheExpiration.mjs
│ │ ├── test-CacheTimestampsModel.mjs
│ │ └── test-ExpirationPlugin.mjs
├── workbox-google-analytics
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ └── basic-example
│ │ │ ├── index.html
│ │ │ └── sw.js
│ └── sw
│ │ └── test-initialize.mjs
├── workbox-navigation-preload
│ ├── integration
│ │ ├── test-disable.js
│ │ ├── test-enable.js
│ │ └── test-sw.js
│ ├── static
│ │ ├── sw-custom-header.js
│ │ ├── sw-default-header.js
│ │ └── sw-disable.js
│ └── sw
│ │ ├── test-disable.mjs
│ │ ├── test-enable.mjs
│ │ └── test-isSupported.mjs
├── workbox-precaching
│ ├── integration
│ │ ├── test-cleanup-outdated-caches.js
│ │ ├── test-precache-and-update.js
│ │ └── test-sw.js
│ ├── static
│ │ ├── addToCacheList.html
│ │ ├── cleanup-outdated-caches
│ │ │ ├── sw.js
│ │ │ └── test.txt
│ │ ├── precache-and-update
│ │ │ ├── hashed-file.abcd1234.txt
│ │ │ ├── index.html
│ │ │ ├── styles
│ │ │ │ └── index.css
│ │ │ ├── sw-1.js
│ │ │ └── sw-2.js
│ │ ├── precache.html
│ │ └── project
│ │ │ ├── example-2.html
│ │ │ ├── example-a.html
│ │ │ ├── example-b.html
│ │ │ ├── example-timestamp.html
│ │ │ ├── example.html
│ │ │ └── index.html
│ └── sw
│ │ ├── resetDefaultPrecacheController.mjs
│ │ ├── test-PrecacheController.mjs
│ │ ├── test-PrecacheFallbackPlugin.mjs
│ │ ├── test-PrecacheRoute.mjs
│ │ ├── test-PrecacheStrategy.mjs
│ │ ├── test-addPlugins.mjs
│ │ ├── test-addRoute.mjs
│ │ ├── test-cleanupOutdatedCaches.mjs
│ │ ├── test-createHandlerBoundToURL.mjs
│ │ ├── test-getCacheKeyForURL.mjs
│ │ ├── test-matchPrecache.mjs
│ │ ├── test-precache.mjs
│ │ ├── test-precacheAndRoute.mjs
│ │ └── utils
│ │ ├── test-deleteOutdatedCaches.mjs
│ │ ├── test-printCleanupDetails.mjs
│ │ └── test-printInstallDetails.mjs
├── workbox-range-requests
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ ├── index.html
│ │ └── sw.js
│ └── sw
│ │ ├── test-RangeRequestsPlugin.mjs
│ │ ├── test-createPartialResponse.mjs
│ │ └── utils
│ │ ├── test-calculateEffectiveBoundaries.mjs
│ │ └── test-parseRangeHeader.mjs
├── workbox-routing
│ ├── integration
│ │ ├── test-navigation-route.js
│ │ ├── test-routing-basic.js
│ │ ├── test-routing-regex.js
│ │ └── test-sw.js
│ ├── static
│ │ ├── demo-img.png
│ │ ├── routing-basic
│ │ │ ├── index.html
│ │ │ └── sw.js
│ │ ├── routing-navigation
│ │ │ ├── index.html
│ │ │ └── sw.js
│ │ ├── routing-regex
│ │ │ ├── index.html
│ │ │ └── sw.js
│ │ ├── routing.html
│ │ └── sw.js
│ └── sw
│ │ ├── test-NavigationRoute.mjs
│ │ ├── test-RegExpRoute.mjs
│ │ ├── test-Route.mjs
│ │ ├── test-Router.mjs
│ │ ├── test-registerRoute.mjs
│ │ ├── test-setCatchHandler.mjs
│ │ ├── test-setDefaultHandler.mjs
│ │ └── utils
│ │ └── test-normalizeHandler.mjs
├── workbox-strategies
│ ├── integration
│ │ ├── test-cacheFirst.js
│ │ ├── test-cacheOnly.js
│ │ ├── test-networkFirst.js
│ │ ├── test-networkOnly.js
│ │ ├── test-staleWhileRevalidate.js
│ │ └── test-sw.js
│ ├── static
│ │ ├── cache-first
│ │ │ ├── example.txt
│ │ │ └── sw.js
│ │ ├── cache-only
│ │ │ └── sw.js
│ │ ├── network-first
│ │ │ └── sw.js
│ │ ├── network-only
│ │ │ └── sw.js
│ │ └── stale-while-revalidate
│ │ │ └── sw.js
│ └── sw
│ │ ├── plugins
│ │ └── test-cacheOkAndOpaquePlugin.mjs
│ │ ├── test-CacheFirst.mjs
│ │ ├── test-CacheOnly.mjs
│ │ ├── test-NetworkFirst.mjs
│ │ ├── test-NetworkOnly.mjs
│ │ ├── test-StaleWhileRevalidate.mjs
│ │ ├── test-Strategy.mjs
│ │ ├── test-StrategyHandler.mjs
│ │ └── test-UsageWithRouter.mjs
├── workbox-streams
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ ├── 4.txt
│ │ ├── index.html
│ │ └── sw.js
│ └── sw
│ │ ├── test-isSupported.mjs
│ │ └── utils
│ │ └── test-createHeaders.mjs
├── workbox-sw
│ ├── integration
│ │ └── test-all.js
│ ├── static
│ │ ├── example.css
│ │ ├── example.js
│ │ ├── index.html
│ │ ├── integration
│ │ │ ├── index.html
│ │ │ ├── invalid-sw.js
│ │ │ └── valid-sw.js
│ │ └── sw.js
│ └── sw
│ │ └── controllers
│ │ └── test-WorkboxSW.mjs
├── workbox-webpack-plugin
│ ├── node
│ │ ├── dependency-check.js
│ │ ├── v4
│ │ │ ├── generate-sw.js
│ │ │ ├── inject-manifest.js
│ │ │ └── lib
│ │ │ │ └── create-webpack-asset-plugin.js
│ │ └── v5
│ │ │ ├── generate-sw.js
│ │ │ ├── inject-manifest.js
│ │ │ ├── lib
│ │ │ └── create-webpack-asset-plugin.js
│ │ │ └── static
│ │ │ └── expected-service-worker.js.map
│ └── static
│ │ ├── bad-multiple-injection.js
│ │ ├── example-project-1
│ │ ├── images
│ │ │ ├── example-jpeg.jpg
│ │ │ └── web-fundamentals-icon192x192.png
│ │ ├── index.html
│ │ ├── page-1.html
│ │ ├── page-2.html
│ │ ├── splitChunksEntry.js
│ │ ├── styles
│ │ │ ├── stylesheet-1.css
│ │ │ └── stylesheet-2.css
│ │ └── webpackEntry.js
│ │ ├── expected-service-worker.js.map
│ │ ├── injected-manifest.js
│ │ ├── injected-manifest.json
│ │ ├── module-import-sw.js
│ │ ├── sw-src-define-plugin.js
│ │ ├── sw-src-missing-sourcemap.js
│ │ ├── sw-src.js
│ │ ├── sw.ts
│ │ └── wasm-project
│ │ ├── add.wasm
│ │ ├── index.js
│ │ └── worker.js
└── workbox-window
│ ├── integration
│ └── test-all.js
│ ├── static
│ └── index.html
│ └── window
│ ├── sw-error.js
│ ├── sw-message-reply.js
│ └── test-Workbox.mjs
├── tsconfig.json
└── typescript.eslintrc.js
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js text eol=lf
2 | *.mjs text eol=lf
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Welcome! Please use this template for reporting bugs or requesting features. For questions about using Workbox, the best place to ask is Stack Overflow, tagged with `[workbox]`: https://stackoverflow.com/questions/ask?tags=workbox
2 |
3 | **Library Affected**:
4 | _workbox-sw, workbox-build, etc._
5 |
6 | **Browser & Platform**:
7 | _E.g. Google Chrome v51.0.1 for Android, or "all browsers"._
8 |
9 | **Issue or Feature Request Description**:
10 | _Your request here._
11 |
12 | _When reporting bugs, please include relevant JavaScript Console logs and links to public URLs at which the issue could be reproduced._
13 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | **Prior to creating a pull request, please follow all the steps in the [contributing guide](https://github.com/GoogleChrome/workbox/blob/v6/CONTRIBUTING.md).**
2 |
3 | Fixes #_issue number_
4 |
5 | _Description of what's changed/fixed._
6 |
--------------------------------------------------------------------------------
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Please see https://typicode.github.io/husky/#/?id=command-not-found
4 | # if you have trouble running this command.
5 |
6 | . "$(dirname "$0")/_/husky.sh"
7 |
8 | npm run lint-staged
9 |
--------------------------------------------------------------------------------
/.husky/pre-push:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Please see https://typicode.github.io/husky/#/?id=command-not-found
4 | # if you have trouble running this command.
5 |
6 | . "$(dirname "$0")/_/husky.sh"
7 |
8 | npm run lint
9 |
--------------------------------------------------------------------------------
/.ncurc.js:
--------------------------------------------------------------------------------
1 | // We use `npx npm-check-updates` to find updates to dependencies.
2 | // Some dependencies have breaking changes that we can't resolve.
3 | // This config file excludes those dependencies from the checks
4 | // until we're able to remediate our code to deal with them.
5 |
6 | module.exports = {
7 | reject: [
8 | // See https://github.com/GoogleChrome/workbox/issues/2479
9 | 'service-worker-mock',
10 | ],
11 | };
12 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | 20
2 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | _version.ts
2 | .nyc_output
3 | .vscode
4 | *.hbs
5 | *.log
6 | build
7 | coverage
8 | docs
9 | generated-release-files
10 | node_modules
11 | package-lock.json
12 | packages/**/*.d.ts
13 | packages/**/*.js
14 | packages/**/*.mjs
15 | packages/workbox-build/src/schema/*.json
16 | temp
17 | test/workbox-webpack-plugin/static/injected-manifest.json
18 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | All Google open source projects are covered by our [community guidelines](https://opensource.google/conduct/) which define the kind of respectful behavior we expect of all participants.
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2018 Google LLC
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/cdn-details.json:
--------------------------------------------------------------------------------
1 | {
2 | "origin": "https://storage.googleapis.com",
3 | "bucketName": "workbox-cdn",
4 | "releasesDir": "releases"
5 | }
6 |
--------------------------------------------------------------------------------
/demos/README.md:
--------------------------------------------------------------------------------
1 | # workbox-module-demos
2 |
3 | Contains sample demos that are deployed to Glitch at https://glitch.com/@philkrie/workbox-demos and used as examples at https://developers.google.com/web/tools/workbox/modules
4 |
--------------------------------------------------------------------------------
/demos/src/workbox-background-sync-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-background-sync",
3 | "version": "1.0.0",
4 | "description": "Workbox Background Sync Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-background-sync-demo/public/example.txt:
--------------------------------------------------------------------------------
1 | example text
--------------------------------------------------------------------------------
/demos/src/workbox-background-sync-demo/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | // Note: Ignore the error that Glitch raises about workbox being undefined.
6 | workbox.setConfig({
7 | debug: true,
8 | });
9 |
10 | const bgSyncPlugin = new workbox.backgroundSync.BackgroundSyncPlugin(
11 | 'myQueueName',
12 | );
13 |
14 | workbox.routing.registerRoute(
15 | ({url}) => url.pathname === '/example.txt',
16 | new workbox.strategies.NetworkOnly({
17 | plugins: [bgSyncPlugin],
18 | }),
19 | );
20 |
21 | workbox.core.skipWaiting();
22 | workbox.core.clientsClaim();
23 |
--------------------------------------------------------------------------------
/demos/src/workbox-broadcast-update-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-broadcast-update",
3 | "version": "1.0.0",
4 | "description": "Workbox Broadcast Update Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-cacheable-response/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-cacheable-response",
3 | "version": "1.0.0",
4 | "description": "Workbox Cacheable Response Demo Listener",
5 | "main": "server.js",
6 | "scripts": {
7 | "start": "node server.js"
8 | },
9 | "dependencies": {
10 | "express": "^4.17.1"
11 | },
12 | "engines": {
13 | "node": "8.x"
14 | },
15 | "license": "MIT"
16 | }
17 |
--------------------------------------------------------------------------------
/demos/src/workbox-cacheable-response/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | const cacheable = new workbox.cacheableResponse.CacheableResponse({
10 | statuses: [200],
11 | headers: {
12 | 'X-Is-Cacheable': 'true',
13 | },
14 | });
15 |
16 | const handleCachableResponse = (event) => {
17 | return fetch(event.request).then((response) => {
18 | if (cacheable.isResponseCacheable(response)) {
19 | console.log('Response meets the criteria');
20 | } else {
21 | console.log('Response does NOT meet the criteria');
22 | }
23 |
24 | return response;
25 | });
26 | };
27 |
28 | self.addEventListener('fetch', (event) => {
29 | switch (new URL(event.request.url).pathname) {
30 | case '/api/is-response-cacheable':
31 | event.respondWith(handleCachableResponse(event));
32 | break;
33 | }
34 | });
35 |
36 | workbox.core.skipWaiting();
37 | workbox.core.clientsClaim();
38 |
--------------------------------------------------------------------------------
/demos/src/workbox-core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-core",
3 | "version": "1.0.0",
4 | "description": "Workbox Core Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-expiration/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-expiration",
3 | "version": "1.0.0",
4 | "description": "Workbox Expiration Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-google-analytics/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-google-analytics",
3 | "version": "1.0.0",
4 | "description": "Workbox Google Analytics Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-google-analytics/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | workbox.googleAnalytics.initialize();
10 |
11 | workbox.core.skipWaiting();
12 | workbox.core.clientsClaim();
13 |
--------------------------------------------------------------------------------
/demos/src/workbox-navigation-preload/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-navigation-preload",
3 | "version": "1.0.0",
4 | "description": "Workbox Navigation Preload Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-navigation-preload/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | // Enable navigation preload.
10 | workbox.navigationPreload.enable();
11 |
12 | // Swap in NetworkOnly, CacheFirst, or StaleWhileRevalidate as needed.
13 | const strategy = new workbox.strategies.NetworkFirst({
14 | cacheName: 'cached-navigations',
15 | plugins: [
16 | // Any plugins, like workbox.expiration, etc.
17 | ],
18 | });
19 |
20 | const navigationRoute = new workbox.routing.NavigationRoute(strategy, {
21 | // Optionally, provide a allowlist/denylist of RegExps to determine
22 | // which paths will match this route.
23 | // allowlist: [],
24 | // denylist: [],
25 | });
26 |
27 | workbox.routing.registerRoute(navigationRoute);
28 |
29 | workbox.core.skipWaiting();
30 | workbox.core.clientsClaim();
31 |
--------------------------------------------------------------------------------
/demos/src/workbox-precaching/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-precaching",
3 | "version": "1.0.0",
4 | "description": "Workbox Precaching Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-precaching/public/hello-world.1234.txt:
--------------------------------------------------------------------------------
1 | Hello, World!
2 |
3 | I'm the first version of this file.
--------------------------------------------------------------------------------
/demos/src/workbox-precaching/public/hello-world.5678.txt:
--------------------------------------------------------------------------------
1 | Hello, World!
2 |
3 | I'm the second version of this file.
--------------------------------------------------------------------------------
/demos/src/workbox-precaching/public/test-file.txt:
--------------------------------------------------------------------------------
1 | #Danger
2 |
3 | This file is not revisioned.
--------------------------------------------------------------------------------
/demos/src/workbox-precaching/sw-1.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | workbox.precaching.precacheAndRoute([
10 | {url: '/', revision: '1'},
11 | {url: 'test-file.txt', revision: '1'},
12 | 'hello-world.1234.txt',
13 | ]);
14 |
--------------------------------------------------------------------------------
/demos/src/workbox-precaching/sw-2.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | workbox.precaching.precacheAndRoute([
10 | {url: '/', revision: '2'},
11 | {url: 'test-file.txt', revision: '2'},
12 | 'hello-world.5678.txt',
13 | ]);
14 |
--------------------------------------------------------------------------------
/demos/src/workbox-range-requests/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-range-requests",
3 | "version": "1.0.0",
4 | "description": "Workbox Range Requests Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-range-requests/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | workbox.routing.registerRoute(
10 | new RegExp('/range-request-example'),
11 | new workbox.strategies.CacheOnly({
12 | cacheName: 'range-requests-demo',
13 | plugins: [new workbox.rangeRequests.RangeRequestsPlugin()],
14 | }),
15 | );
16 |
17 | workbox.core.skipWaiting();
18 | workbox.core.clientsClaim();
19 |
--------------------------------------------------------------------------------
/demos/src/workbox-routing/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-routing",
3 | "version": "1.0.0",
4 | "description": "Workbox Routing Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-routing/public/demo-img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GoogleChrome/workbox/e26d8d7507f9412ba029922f3d9920e68710f2cf/demos/src/workbox-routing/public/demo-img.png
--------------------------------------------------------------------------------
/demos/src/workbox-routing/public/demo-popper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GoogleChrome/workbox/e26d8d7507f9412ba029922f3d9920e68710f2cf/demos/src/workbox-routing/public/demo-popper.png
--------------------------------------------------------------------------------
/demos/src/workbox-strategies/public/cache-first.txt:
--------------------------------------------------------------------------------
1 | Hello from CacheFirst
--------------------------------------------------------------------------------
/demos/src/workbox-strategies/public/network-first.txt:
--------------------------------------------------------------------------------
1 | Hello from NetworkFirst
--------------------------------------------------------------------------------
/demos/src/workbox-strategies/public/network-only.txt:
--------------------------------------------------------------------------------
1 | Hello from NetworkOnly
--------------------------------------------------------------------------------
/demos/src/workbox-strategies/public/stale-while-revalidate.txt:
--------------------------------------------------------------------------------
1 | Hello from StaleWhileRevalidate
--------------------------------------------------------------------------------
/demos/src/workbox-streams/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-streams",
3 | "version": "1.0.0",
4 | "description": "Workbox Streams Demo Git Listener",
5 | "scripts": {
6 | "start": "node server.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-sw/README.md:
--------------------------------------------------------------------------------
1 | # workbox-sw-demo
2 |
--------------------------------------------------------------------------------
/demos/src/workbox-sw/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-sw",
3 | "version": "1.0.0",
4 | "description": "Workbox SW Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-sw/public/demo-img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GoogleChrome/workbox/e26d8d7507f9412ba029922f3d9920e68710f2cf/demos/src/workbox-sw/public/demo-img.png
--------------------------------------------------------------------------------
/demos/src/workbox-sw/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | // Note: Ignore the error that Glitch raises about workbox being undefined.
6 | workbox.setConfig({
7 | debug: true,
8 | });
9 |
10 | workbox.precaching.precacheAndRoute([
11 | 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css',
12 | ]);
13 |
14 | // Demonstrates using default cache
15 | workbox.routing.registerRoute(
16 | new RegExp('.*\\.(?:js)'),
17 | new workbox.strategies.NetworkFirst(),
18 | );
19 |
20 | // Demonstrates a custom cache name for a route.
21 | workbox.routing.registerRoute(
22 | new RegExp('.*\\.(?:png|jpg|jpeg|svg|gif)'),
23 | new workbox.strategies.CacheFirst({
24 | cacheName: 'image-cache',
25 | plugins: [
26 | new workbox.expiration.ExpirationPlugin({
27 | maxEntries: 3,
28 | }),
29 | ],
30 | }),
31 | );
32 |
--------------------------------------------------------------------------------
/demos/src/workbox-window/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-window",
3 | "version": "1.0.0",
4 | "description": "Workbox Window Demo Git Listener",
5 | "scripts": {
6 | "start": "node updateServer.js"
7 | },
8 | "dependencies": {
9 | "express": "^4.17.1"
10 | },
11 | "engines": {
12 | "node": "8.x"
13 | },
14 | "license": "MIT"
15 | }
16 |
--------------------------------------------------------------------------------
/demos/src/workbox-window/sw.js:
--------------------------------------------------------------------------------
1 | importScripts(
2 | 'https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js',
3 | );
4 |
5 | workbox.setConfig({
6 | debug: true,
7 | });
8 |
9 | const SW_VERSION = '5.0.0';
10 |
11 | addEventListener('message', (event) => {
12 | if (event.data.type === 'GET_VERSION') {
13 | event.ports[0].postMessage(SW_VERSION);
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/gulp-tasks/analyze-properties.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const AnalyseBuildForProperties = require('./utils/analyse-properties');
10 |
11 | async function analyze_properties() {
12 | const analysisTool = new AnalyseBuildForProperties();
13 | const results = await analysisTool.run();
14 | for (const result of results) {
15 | analysisTool.printDetails(result);
16 | }
17 | }
18 |
19 | module.exports = {
20 | analyze_properties,
21 | };
22 |
--------------------------------------------------------------------------------
/gulp-tasks/lint.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const {parallel} = require('gulp');
10 | const execa = require('execa');
11 |
12 | async function lint_js() {
13 | await execa(
14 | 'eslint',
15 | [
16 | '**/*.{js,mjs}',
17 | '--config',
18 | 'javascript.eslintrc.js',
19 | '--ignore-path',
20 | '.gitignore',
21 | ],
22 | {preferLocal: true},
23 | );
24 | }
25 |
26 | async function lint_ts() {
27 | await execa(
28 | 'eslint',
29 | [
30 | '**/*.ts',
31 | '--config',
32 | 'typescript.eslintrc.js',
33 | '--ignore-path',
34 | '.gitignore',
35 | ],
36 | {preferLocal: true},
37 | );
38 | }
39 |
40 | module.exports = {
41 | lint_js,
42 | lint_ts,
43 | // Temporarily disable lint_ts until we upgrade our ESLint dependencies.
44 | lint: parallel(lint_js, lint_ts),
45 | };
46 |
--------------------------------------------------------------------------------
/gulp-tasks/test.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const {parallel, series} = require('gulp');
10 |
11 | const {lint} = require('./lint');
12 | const {test_integration} = require('./test-integration');
13 | const {test_node} = require('./test-node');
14 | const logHelper = require('../infra/utils/log-helper');
15 |
16 | async function logSkip() {
17 | logHelper.log('Skipping test suite due to --skipTests');
18 | }
19 |
20 | function runTestsUnlessSkipped() {
21 | if (global.cliOptions.skipTests) {
22 | return logSkip;
23 | } else {
24 | // The node and integration tests both muck with process.env.NODE_ENV,
25 | // and therefore can't be run in parallel.
26 | return parallel(lint, series(test_node, test_integration));
27 | }
28 | }
29 |
30 | module.exports = {
31 | test: runTestsUnlessSkipped(),
32 | };
33 |
--------------------------------------------------------------------------------
/gulp-tasks/utils/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | module.exports = {
10 | // This is a directory that should not be commited
11 | // to git and will be removed and rebuilt between
12 | // test runs.
13 | PACKAGE_BUILD_DIRNAME: 'build',
14 | GENERATED_RELEASE_FILES_DIRNAME: 'generated-release-files',
15 |
16 | // This is used in the publish-bundle step to avoid doing anything
17 | // with tags that have known issues.
18 | MIN_RELEASE_TAG_TO_PUBLISH: 'v6.1.5',
19 | GITHUB_OWNER: 'GoogleChrome',
20 | GITHUB_REPO: 'workbox',
21 |
22 | // This is the environments that we should use for NODE_ENV.
23 | BUILD_TYPES: {
24 | dev: 'dev',
25 | prod: 'production',
26 | },
27 | };
28 |
--------------------------------------------------------------------------------
/gulp-tasks/utils/get-packages.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const {globSync} = require('glob');
10 | const path = require('path');
11 |
12 | const DEFAULT_ROOT = path.join(__dirname, '..', '..');
13 |
14 | const getPackages = ({type, root = DEFAULT_ROOT} = {}) => {
15 | const pathToPkgJsons = globSync('packages/*/package.json', {cwd: root});
16 |
17 | return pathToPkgJsons
18 | .map((pathToPkgJson) => {
19 | const pkg = require(`${path.resolve(root)}/${pathToPkgJson}`);
20 | return pkg;
21 | })
22 | .filter((pkg) => {
23 | return pkg.workbox && pkg.workbox.packageType === type;
24 | });
25 | };
26 |
27 | module.exports = {
28 | getPackages,
29 | };
30 |
--------------------------------------------------------------------------------
/gulp-tasks/utils/node-projects-babel.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [["@babel/preset-env", {"targets": {"node": "10.0"}}]]
3 | }
4 |
--------------------------------------------------------------------------------
/gulp-tasks/utils/output-filename-to-package-map.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const {getPackages} = require('./get-packages');
10 |
11 | const outputFilenameToPkgMap = {};
12 |
13 | const windowAndSWPackages = [
14 | ...getPackages({type: 'sw'}),
15 | ...getPackages({type: 'window'}),
16 | ];
17 |
18 | windowAndSWPackages.forEach((pkg) => {
19 | // When no `outputFilename` property exists, the package name is used.
20 | const outputFilename = pkg.workbox.outputFilename || pkg.name;
21 |
22 | outputFilenameToPkgMap[outputFilename] = pkg;
23 | });
24 |
25 | module.exports = {
26 | outputFilenameToPkgMap,
27 | };
28 |
--------------------------------------------------------------------------------
/gulp-tasks/utils/pkg-path-to-name.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const path = require('path');
10 |
11 | const packagesPath = path.join(__dirname, '..', '..', 'packages');
12 |
13 | // A helper method that should be used when you want to log
14 | // the package name ONLY.
15 | module.exports = (pkgPath) => {
16 | return path.relative(packagesPath, pkgPath);
17 | };
18 |
--------------------------------------------------------------------------------
/gulp-tasks/utils/versioned-cdn-url.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const cdn = require('../../packages/workbox-build/src/cdn-details.json');
10 | const lernaPkg = require('../../lerna.json');
11 |
12 | module.exports = () =>
13 | `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}` + `/${lernaPkg.version}`;
14 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/augments.hbs:
--------------------------------------------------------------------------------
1 | {{#any augments}}
2 |
{{translateHeading 'augments' augments}}
3 | {{#each augments}}
4 | {{link this}}
5 | {{/each}}
6 | {{/any}}
7 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/classes-links.hbs:
--------------------------------------------------------------------------------
1 | {{#any items}}
2 | {{translateHeading headingKey items}}
3 |
4 | {{#each items}}
5 | {{link longname name}}
6 | {{#if classdesc}}
7 | {{#markdown}}{{resolveLinks classdesc}}{{/markdown}}
8 | {{else}}
9 | {{#markdown}}{{resolveLinks description}}{{/markdown}}
10 | {{/if}}
11 | {{/each}}
12 |
13 | {{/any}}
14 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/details-table.hbs:
--------------------------------------------------------------------------------
1 |
2 | {{#block 'details-table-header'}}
3 |
4 |
5 | {{#if isEnum}}
6 | {{translateHeading 'values' params}}
7 | {{else}}
8 | {{translateHeading 'parameters' params}}
9 | {{/if}}
10 | |
11 |
12 | {{/block}}
13 | {{#block 'details-table-body'}}
14 |
15 | {{#each values}}
16 | {{#embed 'details-table-row'}}{{/embed}}
17 | {{/each}}
18 |
19 | {{/block}}
20 |
21 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/implements.hbs:
--------------------------------------------------------------------------------
1 | {{#any implements}}
2 | {{translateHeading 'implements' implements}}
3 | {{#each implements}}
4 | {{link this}}
5 | {{/each}}
6 | {{/any}}
7 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/index-all.hbs:
--------------------------------------------------------------------------------
1 | {{#extend 'layout'}}
2 | {{#content 'title'}}
3 | Index All
4 | {{/content}}
5 | {{#content 'body-main-content'}}
6 |
7 | {{#each longnames}}
8 | - {{link this}}
9 | {{/each}}
10 |
11 | {{/content}}
12 | {{/extend}}
13 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/index.hbs:
--------------------------------------------------------------------------------
1 | {{#extend 'layout'}}
2 | {{#content 'title'}}
3 | Overview
4 | {{/content}}
5 | {{#content 'body-main-content'}}
6 | {{#if readme}}
7 | {{{ readme }}}
8 | {{else}}
9 | {{#block 'body-symbol-index'}}
10 | {{#embed 'symbol-index'}}{{/embed}}
11 | {{/block}}
12 | {{/if}}
13 | {{/content}}
14 | {{/extend}}
15 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/params.hbs:
--------------------------------------------------------------------------------
1 | {{#any params}}
2 |
3 | {{#withOnly values=(reparentItems this 'params')}}
4 | {{#embed 'details-table'}}{{/embed}}
5 | {{/withOnly}}
6 |
7 | {{/any}}
8 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/properties.hbs:
--------------------------------------------------------------------------------
1 | {{#any (filterProperties properties)}}
2 |
3 | {{#unless isEnum}}
4 | {{translateHeading 'properties' properties}}
5 | {{/unless}}
6 | {{#withOnly values=(reparentItems this 'properties') isEnum=isEnum}}
7 | {{#embed 'details-table'}}{{/embed}}
8 | {{/withOnly}}
9 |
10 | {{/any}}
11 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/see.hbs:
--------------------------------------------------------------------------------
1 | {{#any see}}
2 | {{translateHeading 'see' see}}
3 | {{#each see}}
4 | {{link (see this ../longname)}}
5 | {{/each}}
6 | {{/any}}
7 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/signature.hbs:
--------------------------------------------------------------------------------
1 | {{!--
2 | Note that this section omits the return type for:
3 | + Constructors
4 | + Methods with no explicit return type
5 | --}}
6 | {{#with symbol}}
7 | {{~#if (needsSignature this)~}}
8 | {{!-- CONSTRUCTOR PREFIX --}}
9 | {{#is kind 'class'}}
10 | {{#embed 'constructor-prefix'}}{{/embed}}
11 | {{/is}}
12 | {{name}}{{~formatParams params~}}
13 | {{~#isnt kind 'class'~}}
14 | {{~#if (returnTypes this)~}}
15 | {{~translate 'returnTypesSeparator'~}}
16 | {{describeType (returnTypes this)~}}
17 | {{~/if~}}
18 | {{~/isnt~}}
19 | {{~else~}}
20 | {{~#if type~}}
21 | {{~describeType type.parsedType~}}
22 | {{~/if~}}
23 | {{~/if~}}
24 | {{/with}}
25 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/symbol-detail.hbs:
--------------------------------------------------------------------------------
1 | {{~#unless symbol.hideconstructor~}}
2 |
3 | {{~#with symbol~}}
4 | {{name}}
5 | {{~/with~}}
6 |
7 | {{~/unless~}}
8 | {{!--
9 | Note that we omit the labels for classes, modules, and namespaces, since
10 | these labels would duplicate the labels for the page's main heading.
11 | --}}
12 | {{~#if symbol.kind~}}
13 | {{~#contains 'class' 'module' 'namespace' value=symbol.kind~}}
14 | {{~else~}}
15 | {{~#embed 'symbol-labels'}}{{/embed~}}
16 | {{~/contains~}}
17 | {{~/if~}}
18 | {{~#unless symbol.hideconstructor~}}
19 |
20 | {{~#embed 'signature'}}{{/embed~}}
21 |
22 | {{~/unless~}}
23 | {{#with symbol}}
24 | {{~#unless symbol.hideconstructor~}}
25 | {{#embed 'description'}}{{/embed}}
26 | {{#embed 'params'}}{{/embed}}
27 | {{#embed 'properties'}}{{/embed}}
28 |
29 | {{#embed 'details'}}{{/embed}}
30 |
31 | {{#embed 'examples'}}{{/embed}}
32 | {{~/unless~}}
33 | {{/with}}
34 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/symbol-index-section.hbs:
--------------------------------------------------------------------------------
1 |
2 | {{#each doclets}}
3 |
4 | {{linkLongnameWithSignature this '!symbol-index-name'}}
5 |
6 | {{/each}}
7 |
8 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/symbol-index.hbs:
--------------------------------------------------------------------------------
1 |
2 | {{#eachIndexGroup allLongnamesTree}}
3 |
4 |
5 |
{{@groupName}}
6 |
7 | {{#each (group this 3)}}
8 | {{#withOnly doclets=this}}
9 | {{#embed 'symbol-index-section'}}{{/embed}}
10 | {{/withOnly}}
11 | {{/each}}
12 |
13 |
14 |
15 | {{/eachIndexGroup}}
16 |
17 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/symbol-labels.hbs:
--------------------------------------------------------------------------------
1 | {{~#withOnly allLabels=(labels symbol)~}}
2 | {{~#any allLabels~}}
3 |
4 | {{~#each allLabels~}}
5 | {{text}}
6 | {{~#unless @last}} {{/unless~}}
7 | {{~/each~}}
8 |
9 | {{~/any~}}
10 | {{~/withOnly~}}
11 |
--------------------------------------------------------------------------------
/infra/templates/reference-docs/jsdoc/views/toc-yaml.hbs:
--------------------------------------------------------------------------------
1 | toc:
2 | {{#each symbols~}}
3 | - title: "{{tocYamlName}}"
4 | path: {{../basepath}}/{{basename (url longname) '.html'}}
5 | {{/each}}
6 | - title: "Index of all"
7 | path: {{basepath}}/index-all
8 |
--------------------------------------------------------------------------------
/infra/testing/auto-stub-logger.mjs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import sinon from 'sinon';
10 | import {logger} from '../../packages/workbox-core/_private/logger.mjs';
11 |
12 | const sandbox = sinon.createSandbox();
13 | const stubLogger = () => {
14 | // Logger will be `null` in production mode.
15 | if (logger) {
16 | sandbox.stub(logger);
17 | }
18 | };
19 |
20 | // Silence any early messages (Normally caused by logging from an import at
21 | // the top of a test)
22 | stubLogger();
23 |
24 | // This is part of the "root" mocha suite - meaning it'll reset all the logger
25 | // values before every test.
26 | beforeEach(function () {
27 | sandbox.restore();
28 |
29 | stubLogger();
30 | });
31 |
32 | after(function () {
33 | sandbox.restore();
34 | });
35 |
--------------------------------------------------------------------------------
/infra/testing/clean-sw.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const runInSW = require('./comlink/node-interface');
10 |
11 | module.exports = async (webdriver, testingURL) => {
12 | await webdriver.get(testingURL);
13 | try {
14 | await runInSW('clearAllCaches');
15 | } catch (ignored) {
16 | // There might not yet be a service worker registered, in which case we
17 | // can't call runInSW().
18 | }
19 | const error = await webdriver.executeAsyncScript((cb) => {
20 | navigator.serviceWorker
21 | .getRegistration()
22 | .then((reg) => {
23 | if (reg) {
24 | return reg.unregister();
25 | }
26 | })
27 | .then(() => cb())
28 | .catch((err) => cb(err.message));
29 | });
30 | if (error) {
31 | throw new Error(error);
32 | }
33 | await webdriver.get(testingURL);
34 | };
35 |
--------------------------------------------------------------------------------
/infra/testing/comlink/node-interface.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | module.exports = async (command, ...args) => {
10 | const result = await global.__workbox.webdriver.executeAsyncScript(
11 | (command, args, cb) => {
12 | if (!('_runInSW' in window)) {
13 | cb({error: '_runInSW is not initialized.'});
14 | } else {
15 | window._runInSW[command](...args)
16 | .then((result) => cb(result))
17 | .catch((error) =>
18 | cb({
19 | error: `While running ${command}(${args}): ${error.message}`,
20 | }),
21 | );
22 | }
23 | },
24 | command,
25 | args,
26 | );
27 |
28 | if (result instanceof Object && 'error' in result) {
29 | throw new Error(result.error);
30 | }
31 | return result;
32 | };
33 |
--------------------------------------------------------------------------------
/infra/testing/comlink/window-interface.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | function initComlink() {
10 | const channel = new MessageChannel();
11 | navigator.serviceWorker.controller.postMessage(channel.port2, [
12 | channel.port2,
13 | ]);
14 | window._runInSW = Comlink.wrap(channel.port1);
15 | channel.port1.start();
16 | }
17 |
18 | const scriptEl = document.createElement('script');
19 | scriptEl.src = '/__WORKBOX/comlink.js';
20 | scriptEl.addEventListener('load', () => {
21 | if (navigator.serviceWorker.controller) {
22 | initComlink();
23 | }
24 | navigator.serviceWorker.addEventListener('controllerchange', initComlink);
25 | });
26 | document.body.appendChild(scriptEl);
27 |
--------------------------------------------------------------------------------
/infra/testing/confirm-directory-contains.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const expect = require('chai').expect;
10 | const globby = require('globby');
11 | const upath = require('upath');
12 |
13 | module.exports = async (directory, expectedContents) => {
14 | const relativeFiles = await globby('**', {cwd: directory});
15 | const absoluteFilesWithNativeSeparator = relativeFiles.map((file) =>
16 | upath.resolve(directory, file).replace(/\//g, upath.sep),
17 | );
18 | expect(absoluteFilesWithNativeSeparator).to.have.members(expectedContents);
19 | };
20 |
--------------------------------------------------------------------------------
/infra/testing/expectError.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const expect = require('chai').expect;
10 | const logHelper = require('../utils/log-helper');
11 |
12 | module.exports = async (func, errorName, finalCb) => {
13 | let caughtError = null;
14 | try {
15 | const result = func();
16 | if (result && result instanceof Promise) {
17 | await result;
18 | }
19 | } catch (err) {
20 | caughtError = err;
21 | }
22 |
23 | if (!caughtError) {
24 | throw new Error('Expected error to be thrown but function ran correctly.');
25 | }
26 |
27 | if (caughtError.constructor.name !== 'WorkboxError') {
28 | logHelper.warn(`Unexpected error thrown.`, caughtError);
29 | }
30 |
31 | expect(caughtError.constructor.name).to.equal('WorkboxError');
32 | expect(caughtError.name).to.equal(errorName);
33 |
34 | if (finalCb) {
35 | return finalCb(caughtError);
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/infra/testing/helpers/compareResponses.mjs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const compareResponses = async (first, second, shouldBeSame) => {
10 | const firstBody = await first.clone().text();
11 | const secondBody = await second.clone().text();
12 |
13 | if (shouldBeSame) {
14 | expect(firstBody).to.equal(secondBody);
15 | } else {
16 | expect(firstBody).to.not.equal(secondBody);
17 | }
18 | };
19 |
20 | export {compareResponses};
21 |
--------------------------------------------------------------------------------
/infra/testing/helpers/generateOpaqueResponse.mjs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // Cache a resonse value and clone it instead of re-fetching every time.
10 | let response;
11 |
12 | export const generateOpaqueResponse = async () => {
13 | if (!response) {
14 | response = await fetch('https://google.com', {mode: 'no-cors'});
15 | }
16 | return response.clone();
17 | };
18 |
--------------------------------------------------------------------------------
/infra/testing/helpers/generateUniqueResponse.mjs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | let uid = 0;
10 |
11 | export const generateUniqueResponse = (responseInit = {}) => {
12 | return new Response(`${++uid}`, responseInit);
13 | };
14 |
--------------------------------------------------------------------------------
/infra/testing/helpers/sleep.mjs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | /**
10 | * Asynchronously waits for the passed number of milliseconds.
11 | *
12 | * @param {number} ms
13 | * @return {Promise}
14 | */
15 | export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
16 |
--------------------------------------------------------------------------------
/infra/testing/server/cross-origin-server.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const express = require('express');
10 |
11 | const PORT = 3010;
12 |
13 | let app;
14 | let server;
15 |
16 | function initApp(staticDir) {
17 | app = express();
18 | app.use(express.static(staticDir));
19 | }
20 |
21 | function start(staticDir) {
22 | if (!app) {
23 | initApp(staticDir);
24 | }
25 |
26 | return new Promise((resolve, reject) => {
27 | server = app.listen(PORT, (error) => {
28 | if (error) {
29 | reject(error);
30 | } else {
31 | resolve(`http://localhost:${PORT}`);
32 | }
33 | });
34 | });
35 | }
36 |
37 | function stop() {
38 | if (server) {
39 | server.close();
40 | }
41 | }
42 |
43 | module.exports = {
44 | start,
45 | stop,
46 | };
47 |
--------------------------------------------------------------------------------
/infra/testing/server/routes/comlink.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const match = '/__WORKBOX/comlink.js';
10 |
11 | async function handler(req, res) {
12 | const comlinkMain = require.resolve('comlink');
13 | res.sendFile(comlinkMain);
14 | }
15 |
16 | module.exports = {
17 | handler,
18 | match,
19 | };
20 |
--------------------------------------------------------------------------------
/infra/testing/server/routes/integration-html.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const path = require('path');
10 |
11 | const match = '/*/integration.html';
12 |
13 | async function handler(req, res) {
14 | const filePath = path.join(__dirname, '..', 'static', 'integration.html');
15 | res.sendFile(filePath);
16 | }
17 |
18 | module.exports = {
19 | handler,
20 | match,
21 | };
22 |
--------------------------------------------------------------------------------
/infra/testing/server/routes/templates-update.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const templateData = require('../template-data');
10 |
11 | // An endpoint to update template data from within tests. Any JSON in the
12 | // POST body will be merged with the existing template data.
13 | const match = '/__WORKBOX/updateTemplate';
14 |
15 | async function handler(req, res) {
16 | templateData.assign(req.body);
17 | res.end();
18 | }
19 |
20 | module.exports = {
21 | handler,
22 | match,
23 | method: 'post',
24 | };
25 |
--------------------------------------------------------------------------------
/infra/testing/server/routes/unique-etag.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const match = '/__WORKBOX/uniqueETag';
10 |
11 | let counter = 0;
12 | async function handler(req, res) {
13 | res.set('ETag', ++counter);
14 | res.send(`ETag is ${counter}.`);
15 | }
16 |
17 | module.exports = {
18 | handler,
19 | match,
20 | };
21 |
--------------------------------------------------------------------------------
/infra/testing/server/routes/unique-value.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const match = '/__WORKBOX/uniqueValue';
10 |
11 | let counter = 0;
12 | async function handler(req, res) {
13 | res.send(`Unique value is ${counter++}.`);
14 | }
15 |
16 | module.exports = {
17 | handler,
18 | match,
19 | };
20 |
--------------------------------------------------------------------------------
/infra/testing/server/static/integration.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Integration Test Harness
4 |
5 |
6 | You need to manually register the service worker.
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/infra/testing/server/template-data.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // We have to use global variables instead of local variables because
10 | // at the moment we're using `clear-require` to reset all modules between
11 | // tests, which means all local variables get reset, but globals persist.
12 | global.__uid = 0;
13 | global.__templateData = {
14 | ENV: process.env.NODE_ENV,
15 | uniqueID: () => {
16 | return ++global.__uid;
17 | },
18 | };
19 |
20 | const get = () => {
21 | return Object.assign({}, global.__templateData);
22 | };
23 |
24 | const assign = (newData) => {
25 | Object.assign(global.__templateData, newData);
26 | };
27 |
28 | module.exports = {get, assign};
29 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/integration.html.njk:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 | {{ title }}
13 |
16 |
17 |
18 | {{ body }}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-clients-claim.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
11 | addEventListener('install', (event) => event.waitUntil(skipWaiting()));
12 | addEventListener('activate', (event) => event.waitUntil(
13 | clients.claim().catch((error) => console.error(error))));
14 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-no-skip-waiting.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-script-version.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
11 | addEventListener('install', (event) => event.waitUntil(skipWaiting()));
12 | addEventListener('activate', (event) => event.waitUntil(clients.claim()));
13 |
14 | addEventListener('message', async (event) => {
15 | // Assert the type and meta are correct.
16 | if (event.data.type === 'GET_VERSION' &&
17 | event.data.meta === 'workbox-window') {
18 | event.ports[0].postMessage('{{ version }}');
19 | }
20 | });
21 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-skip-waiting-deferred.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
11 | addEventListener('install', (event) => {
12 | const doneInstalling = new Promise((resolve) => {
13 | setTimeout(() => {
14 | skipWaiting();
15 | resolve();
16 | }, 500);
17 | });
18 | event.waitUntil(doneInstalling);
19 | });
20 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-skip-waiting-on-message.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
11 | addEventListener('message', (event) => {
12 | if (event.data.type === 'SKIP_WAITING') {
13 | skipWaiting();
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-skip-waiting.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
11 | addEventListener('install', (event) => event.waitUntil(skipWaiting()));
12 |
--------------------------------------------------------------------------------
/infra/testing/server/templates/sw-window-ready.js.njk:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // {{ version }}
10 |
11 | addEventListener('install', (event) => event.waitUntil(skipWaiting()));
12 | addEventListener('activate', (event) => event.waitUntil(clients.claim()));
13 |
14 | addEventListener('message', async (event) => {
15 | // Assert the type and meta are correct.
16 | if (event.data.type === 'WINDOW_READY' &&
17 | event.data.meta === 'workbox-window') {
18 | const windows = await clients.matchAll({
19 | type: 'window',
20 | includeUncontrolled: true,
21 | });
22 | for (const win of windows) {
23 | win.postMessage({type: 'sw:message:ready'});
24 | }
25 | }
26 | });
27 |
--------------------------------------------------------------------------------
/infra/testing/wait-until.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | module.exports = async (fn, retries = 20, intervalMillis = 50) => {
10 | for (let i = 0; i < retries; i++) {
11 | const result = await fn();
12 | if (result) {
13 | return;
14 | }
15 | await new Promise((resolve) => setTimeout(resolve, intervalMillis));
16 | }
17 | throw new Error(`${fn} didn't return true after ${retries} retries.`);
18 | };
19 |
--------------------------------------------------------------------------------
/infra/testing/webdriver/executeAsyncAndCatch.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // Store local references of these globals.
10 | const {webdriver} = global.__workbox;
11 |
12 | /**
13 | * Executes the passed function (and args) async and logs any errors that
14 | * occur. Errors are assumed to be passed to the callback as an object
15 | * with the `error` property.
16 | *
17 | * @param {...*} args
18 | * @return {*}
19 | */
20 | const executeAsyncAndCatch = async (...args) => {
21 | const result = await webdriver.executeAsyncScript(...args);
22 |
23 | if (result && result.error) {
24 | console.error(result.error);
25 | throw new Error('Error executing async script');
26 | }
27 | return result;
28 | };
29 |
30 | module.exports = {executeAsyncAndCatch};
31 |
--------------------------------------------------------------------------------
/infra/testing/webdriver/unregisterAllSWs.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const {executeAsyncAndCatch} = require('./executeAsyncAndCatch');
10 |
11 | /**
12 | * Unregisters any active SWs so the next page load can start clean.
13 | * Note: a new page load is needed before controlling SWs stop being active.
14 | */
15 | const unregisterAllSWs = async () => {
16 | await executeAsyncAndCatch(async (cb) => {
17 | try {
18 | const regs = await navigator.serviceWorker.getRegistrations();
19 | for (const reg of regs) {
20 | await reg.unregister();
21 | }
22 | cb();
23 | } catch (error) {
24 | cb({error: error.stack});
25 | }
26 | });
27 | };
28 |
29 | module.exports = {unregisterAllSWs};
30 |
--------------------------------------------------------------------------------
/infra/testing/webdriver/windowLoaded.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const {executeAsyncAndCatch} = require('./executeAsyncAndCatch');
10 |
11 | /**
12 | * Waits for the current window to load if it's not already loaded.
13 | */
14 | const windowLoaded = async () => {
15 | // Wait for the window to load, so the `Workbox` global is available.
16 | await executeAsyncAndCatch(async (cb) => {
17 | const loaded = () => {
18 | if (!window.Workbox) {
19 | cb({
20 | error: `window.Workbox is undefined; location is ${location.href}`,
21 | });
22 | } else {
23 | cb();
24 | }
25 | };
26 |
27 | try {
28 | if (document.readyState === 'complete') {
29 | loaded();
30 | } else {
31 | addEventListener('load', () => loaded());
32 | }
33 | } catch (error) {
34 | cb({error: error.stack});
35 | }
36 | });
37 | };
38 |
39 | module.exports = {windowLoaded};
40 |
--------------------------------------------------------------------------------
/infra/testing/webpack-build-check.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | function joinMessages(errorsOrWarnings) {
10 | if (errorsOrWarnings[0].message) {
11 | return errorsOrWarnings.map((item) => item.message).join('\n');
12 | } else {
13 | return errorsOrWarnings.join('\n');
14 | }
15 | }
16 |
17 | module.exports = (webpackError, stats) => {
18 | if (webpackError) {
19 | throw new Error(webpackError.message);
20 | }
21 |
22 | const statsJson = stats.toJson('verbose');
23 |
24 | if (statsJson.errors.length > 0) {
25 | throw new Error(joinMessages(statsJson.errors));
26 | }
27 |
28 | if (statsJson.warnings.length > 0) {
29 | throw new Error(joinMessages(statsJson.warnings));
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/infra/utils/AsyncDebounce.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | class AsyncDebounce {
10 | constructor(fn) {
11 | this._fn = fn;
12 | this._needsRecall = false;
13 | }
14 |
15 | call() {
16 | if (!this._promise) {
17 | /* eslint-disable no-async-promise-executor */
18 | this._promise = new Promise(async (resolve) => {
19 | do {
20 | this._needsRecall = false;
21 | await this._fn.call();
22 | } while (this._needsRecall !== false);
23 |
24 | this._promise = null;
25 | resolve();
26 | });
27 | } else {
28 | this._needsRecall = true;
29 | }
30 | return this._promise;
31 | }
32 | }
33 |
34 | module.exports = {AsyncDebounce};
35 |
--------------------------------------------------------------------------------
/infra/utils/log-helper.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | const chalk = require('chalk');
10 |
11 | const prefix = function () {
12 | return chalk.inverse(`[Workbox]:`);
13 | };
14 |
15 | module.exports = {
16 | highlight: chalk.bgCyan,
17 |
18 | debug: (...args) => {
19 | console.log(prefix(), chalk.dim(...args));
20 | },
21 |
22 | log: (...args) => {
23 | console.log(prefix(), ...args);
24 | },
25 |
26 | warn: (...args) => {
27 | console.warn(prefix(), chalk.yellow(...args));
28 | },
29 |
30 | error: (...args) => {
31 | console.error('\n');
32 | console.error(prefix(), chalk.red(...args));
33 | console.error('\n');
34 | },
35 | };
36 |
--------------------------------------------------------------------------------
/jsdoc.conf:
--------------------------------------------------------------------------------
1 | {
2 | "source": {
3 | "include": [
4 | "packages"
5 | ],
6 | "exclude": [
7 | "packages/workbox-cli"
8 | ],
9 | "includePattern": ".+\\.(js(doc|x)?|mjs)$",
10 | "excludePattern": "((^|\\/|\\\\)packages\\/.*\\/build(\\/|\\\\)|(^|\\/|\\\\)test(\\/|\\\\)|(^|\\/|\\\\)node_modules(\\/|\\\\)|(^|\\/|\\\\)demo(\\/|\\\\))"
11 | },
12 | "opts": {
13 | "recurse": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "lerna": "5.6.2",
3 | "packages": ["packages/*"],
4 | "version": "7.3.0"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/workbox-background-sync/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-background-sync
2 |
--------------------------------------------------------------------------------
/packages/workbox-background-sync/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-background-sync",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "Queues failed requests and uses the Background Sync API to replay them when the network is available",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw",
18 | "background",
19 | "sync",
20 | "workbox-plugin"
21 | ],
22 | "workbox": {
23 | "browserNamespace": "workbox.backgroundSync",
24 | "packageType": "sw"
25 | },
26 | "main": "index.js",
27 | "module": "index.mjs",
28 | "types": "index.d.ts",
29 | "dependencies": {
30 | "idb": "^7.0.1",
31 | "workbox-core": "7.3.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/workbox-background-sync/src/QueueStore.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import './_version.js';
10 |
11 | // This is a temporary workaround to expose something from ./lib/ via our
12 | // top-level public API.
13 | // TODO: In Workbox v7, move the actual code from ./lib/ to this file.
14 | export {QueueStore} from './lib/QueueStore';
15 |
--------------------------------------------------------------------------------
/packages/workbox-background-sync/src/StorableRequest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import './_version.js';
10 |
11 | // This is a temporary workaround to expose something from ./lib/ via our
12 | // top-level public API.
13 | // TODO: In Workbox v7, move the actual code from ./lib/ to this file.
14 | export {StorableRequest} from './lib/StorableRequest';
15 |
--------------------------------------------------------------------------------
/packages/workbox-background-sync/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:background-sync:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-background-sync/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "outDir": "./",
6 | "rootDir": "./src",
7 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
8 | },
9 | "include": ["src/**/*.ts"],
10 | "references": [{"path": "../workbox-core/"}]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-broadcast-update
2 |
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-broadcast-update",
3 | "version": "7.3.0",
4 | "lockfileVersion": 3,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "workbox-broadcast-update",
9 | "version": "7.3.0",
10 | "license": "MIT",
11 | "dependencies": {
12 | "workbox-core": "7.3.0"
13 | }
14 | },
15 | "node_modules/workbox-core": {
16 | "version": "7.3.0",
17 | "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-7.3.0.tgz",
18 | "integrity": "sha512-Z+mYrErfh4t3zi7NVTvOuACB0A/jA3bgxUN3PwtAVHvfEsZxV9Iju580VEETug3zYJRc0Dmii/aixI/Uxj8fmw==",
19 | "license": "MIT"
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-broadcast-update",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "A service worker helper library that uses the Broadcast Channel API to announce when a cached response has updated",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw",
18 | "workbox-plugin"
19 | ],
20 | "workbox": {
21 | "browserNamespace": "workbox.broadcastUpdate",
22 | "packageType": "sw"
23 | },
24 | "main": "index.js",
25 | "module": "index.mjs",
26 | "types": "index.d.ts",
27 | "dependencies": {
28 | "workbox-core": "7.3.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:broadcast-update:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {
10 | BroadcastCacheUpdate,
11 | BroadcastCacheUpdateOptions,
12 | } from './BroadcastCacheUpdate.js';
13 | import {BroadcastUpdatePlugin} from './BroadcastUpdatePlugin.js';
14 | import {responsesAreSame} from './responsesAreSame.js';
15 |
16 | import './_version.js';
17 |
18 | /**
19 | * @module workbox-broadcast-update
20 | */
21 |
22 | export {
23 | BroadcastCacheUpdate,
24 | BroadcastCacheUpdateOptions,
25 | BroadcastUpdatePlugin,
26 | responsesAreSame,
27 | };
28 |
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/src/utils/constants.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import '../_version.js';
10 |
11 | export const CACHE_UPDATED_MESSAGE_TYPE = 'CACHE_UPDATED';
12 | export const CACHE_UPDATED_MESSAGE_META = 'workbox-broadcast-update';
13 | export const NOTIFY_ALL_CLIENTS = true;
14 | export const DEFAULT_HEADERS_TO_CHECK: string[] = [
15 | 'content-length',
16 | 'etag',
17 | 'last-modified',
18 | ];
19 |
--------------------------------------------------------------------------------
/packages/workbox-broadcast-update/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "outDir": "./",
6 | "rootDir": "./src",
7 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
8 | },
9 | "include": ["src/**/*.ts"],
10 | "references": [{"path": "../workbox-core/"}]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/workbox-build/.ncurc.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2020 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // We use `npx npm-check-updates` to find updates to dependencies.
10 | // Some dependencies have breaking changes that we can't resolve.
11 | // This config file excludes those dependencies from the checks
12 | // until we're able to remediate our code to deal with them.
13 | module.exports = {
14 | reject: [
15 | // joi v16 is the last release to support Node v10:
16 | // https://github.com/sideway/joi/issues/2262
17 | '@hapi/joi',
18 | ],
19 | };
20 |
--------------------------------------------------------------------------------
/packages/workbox-build/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developer.chrome.com/docs/workbox/modules/workbox-build
2 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/cdn-details.json:
--------------------------------------------------------------------------------
1 | {
2 | "origin": "https://storage.googleapis.com",
3 | "bucketName": "workbox-cdn",
4 | "releasesDir": "releases",
5 | "latestVersion": "7.3.0"
6 | }
7 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {copyWorkboxLibraries} from './lib/copy-workbox-libraries';
10 | import {getModuleURL} from './lib/cdn-utils';
11 | import {generateSW} from './generate-sw';
12 | import {getManifest} from './get-manifest';
13 | import {injectManifest} from './inject-manifest';
14 |
15 | /**
16 | * @module workbox-build
17 | */
18 | export {
19 | copyWorkboxLibraries,
20 | generateSW,
21 | getManifest,
22 | getModuleURL,
23 | injectManifest,
24 | };
25 |
26 | export * from './types';
27 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/escape-regexp.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
10 | export function escapeRegExp(str: string): string {
11 | return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
12 | }
13 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/get-composite-details.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import crypto from 'crypto';
10 |
11 | import {FileDetails} from '../types';
12 |
13 | export function getCompositeDetails(
14 | compositeURL: string,
15 | dependencyDetails: Array,
16 | ): FileDetails {
17 | let totalSize = 0;
18 | let compositeHash = '';
19 |
20 | for (const fileDetails of dependencyDetails) {
21 | totalSize += fileDetails.size;
22 | compositeHash += fileDetails.hash;
23 | }
24 |
25 | const md5 = crypto.createHash('md5');
26 | md5.update(compositeHash);
27 | const hashOfHashes = md5.digest('hex');
28 |
29 | return {
30 | file: compositeURL,
31 | hash: hashOfHashes,
32 | size: totalSize,
33 | };
34 | }
35 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/get-file-hash.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import fse from 'fs-extra';
10 |
11 | import {getStringHash} from './get-string-hash';
12 | import {errors} from './errors';
13 |
14 | export function getFileHash(file: string): string {
15 | try {
16 | const buffer = fse.readFileSync(file);
17 | return getStringHash(buffer);
18 | } catch (err) {
19 | throw new Error(
20 | errors['unable-to-get-file-hash'] +
21 | ` '${err instanceof Error && err.message ? err.message : ''}'`,
22 | );
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/get-file-size.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import fse from 'fs-extra';
10 |
11 | import {errors} from './errors';
12 |
13 | export function getFileSize(file: string): number | null {
14 | try {
15 | const stat = fse.statSync(file);
16 | if (!stat.isFile()) {
17 | return null;
18 | }
19 | return stat.size;
20 | } catch (err) {
21 | throw new Error(
22 | errors['unable-to-get-file-size'] +
23 | ` '${err instanceof Error && err.message ? err.message : ''}'`,
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/get-source-map-url.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2022 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // Adapted from https://github.com/lydell/source-map-url/blob/master/source-map-url.js
10 | // See https://github.com/GoogleChrome/workbox/issues/3019
11 | const innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/;
12 | const regex = RegExp(
13 | '(?:' +
14 | '/\\*' +
15 | '(?:\\s*\r?\n(?://)?)?' +
16 | '(?:' +
17 | innerRegex.source +
18 | ')' +
19 | '\\s*' +
20 | '\\*/' +
21 | '|' +
22 | '//(?:' +
23 | innerRegex.source +
24 | ')' +
25 | ')' +
26 | '\\s*',
27 | );
28 |
29 | export function getSourceMapURL(srcContents: string): string | null {
30 | const match = srcContents.match(regex);
31 | return match ? match[1] || match[2] || '' : null;
32 | }
33 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/get-string-details.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {FileDetails} from '../types';
10 | import {getStringHash} from './get-string-hash';
11 |
12 | export function getStringDetails(url: string, str: string): FileDetails {
13 | return {
14 | file: url,
15 | hash: getStringHash(str),
16 | size: str.length,
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/get-string-hash.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import crypto from 'crypto';
10 |
11 | export function getStringHash(input: crypto.BinaryLike): string {
12 | const md5 = crypto.createHash('md5');
13 | md5.update(input);
14 | return md5.digest('hex');
15 | }
16 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/maximum-size-transform.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import prettyBytes from 'pretty-bytes';
10 |
11 | import {ManifestTransform} from '../types';
12 |
13 | export function maximumSizeTransform(
14 | maximumFileSizeToCacheInBytes: number,
15 | ): ManifestTransform {
16 | return (originalManifest) => {
17 | const warnings: Array = [];
18 | const manifest = originalManifest.filter((entry) => {
19 | if (entry.size <= maximumFileSizeToCacheInBytes) {
20 | return true;
21 | }
22 |
23 | warnings.push(
24 | `${entry.url} is ${prettyBytes(entry.size)}, and won't ` +
25 | `be precached. Configure maximumFileSizeToCacheInBytes to change ` +
26 | `this limit.`,
27 | );
28 | return false;
29 | });
30 |
31 | return {manifest, warnings};
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/no-revision-for-urls-matching-transform.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {errors} from './errors';
10 | import {ManifestTransform} from '../types';
11 |
12 | export function noRevisionForURLsMatchingTransform(
13 | regexp: RegExp,
14 | ): ManifestTransform {
15 | if (!(regexp instanceof RegExp)) {
16 | throw new Error(errors['invalid-dont-cache-bust']);
17 | }
18 |
19 | return (originalManifest) => {
20 | const manifest = originalManifest.map((entry) => {
21 | if (typeof entry.url !== 'string') {
22 | throw new Error(errors['manifest-entry-bad-url']);
23 | }
24 |
25 | if (entry.url.match(regexp)) {
26 | entry.revision = null;
27 | }
28 |
29 | return entry;
30 | });
31 |
32 | return {manifest};
33 | };
34 | }
35 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/rebase-path.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import upath from 'upath';
10 |
11 | export function rebasePath({
12 | baseDirectory,
13 | file,
14 | }: {
15 | baseDirectory: string;
16 | file: string;
17 | }): string {
18 | // The initial path is relative to the current directory, so make it absolute.
19 | const absolutePath = upath.resolve(file);
20 |
21 | // Convert the absolute path so that it's relative to the baseDirectory.
22 | const relativePath = upath.relative(baseDirectory, absolutePath);
23 |
24 | // Remove any leading ./ as it won't work in a glob pattern.
25 | const normalizedPath = upath.normalize(relativePath);
26 |
27 | return normalizedPath;
28 | }
29 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/lib/stringify-without-comments.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import objectStringify from 'stringify-object';
10 | import stripComments from 'strip-comments';
11 |
12 | export function stringifyWithoutComments(obj: {[key: string]: any}): string {
13 | return objectStringify(obj, {
14 | // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult
15 | transform: (_obj: {[key: string]: any}, _prop, str) => {
16 | if (typeof _prop !== 'symbol' && typeof _obj[_prop] === 'function') {
17 | // Can't typify correctly stripComments
18 | return stripComments(str); // eslint-disable-line
19 | }
20 | return str;
21 | },
22 | });
23 | }
24 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/rollup-plugin-off-main-thread.d.ts:
--------------------------------------------------------------------------------
1 | declare module '@surma/rollup-plugin-off-main-thread';
2 |
--------------------------------------------------------------------------------
/packages/workbox-build/src/strip-comments.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'strip-comments';
2 |
--------------------------------------------------------------------------------
/packages/workbox-build/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "esModuleInterop": true,
6 | "module": "CommonJS",
7 | "outDir": "./build",
8 | "resolveJsonModule": true,
9 | "rootDir": "./src",
10 | "target": "ES2018",
11 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
12 | },
13 | "files": ["src/cdn-details.json"],
14 | "include": ["src/**/*.ts", "src/schema/*.json"],
15 | "references": [
16 | {"path": "../workbox-background-sync/"},
17 | {"path": "../workbox-broadcast-update/"},
18 | {"path": "../workbox-cacheable-response/"},
19 | {"path": "../workbox-core/"},
20 | {"path": "../workbox-expiration/"},
21 | {"path": "../workbox-google-analytics/"}
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/packages/workbox-cacheable-response/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-cacheable-response
2 |
--------------------------------------------------------------------------------
/packages/workbox-cacheable-response/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-cacheable-response",
3 | "version": "7.3.0",
4 | "lockfileVersion": 3,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "workbox-cacheable-response",
9 | "version": "7.3.0",
10 | "license": "MIT",
11 | "dependencies": {
12 | "workbox-core": "7.3.0"
13 | }
14 | },
15 | "node_modules/workbox-core": {
16 | "version": "7.3.0",
17 | "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-7.3.0.tgz",
18 | "integrity": "sha512-Z+mYrErfh4t3zi7NVTvOuACB0A/jA3bgxUN3PwtAVHvfEsZxV9Iju580VEETug3zYJRc0Dmii/aixI/Uxj8fmw==",
19 | "license": "MIT"
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/workbox-cacheable-response/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-cacheable-response",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "This library takes a Response object and determines whether it's cacheable based on a specific configuration.",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw",
18 | "workbox-plugin"
19 | ],
20 | "workbox": {
21 | "browserNamespace": "workbox.cacheableResponse",
22 | "packageType": "sw"
23 | },
24 | "main": "index.js",
25 | "module": "index.mjs",
26 | "types": "index.d.ts",
27 | "dependencies": {
28 | "workbox-core": "7.3.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/workbox-cacheable-response/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:cacheable-response:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-cacheable-response/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {
10 | CacheableResponse,
11 | CacheableResponseOptions,
12 | } from './CacheableResponse.js';
13 | import {CacheableResponsePlugin} from './CacheableResponsePlugin.js';
14 |
15 | import './_version.js';
16 |
17 | /**
18 | * @module workbox-cacheable-response
19 | */
20 |
21 | export {CacheableResponse, CacheableResponseOptions, CacheableResponsePlugin};
22 |
--------------------------------------------------------------------------------
/packages/workbox-cacheable-response/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "outDir": "./",
6 | "rootDir": "./src",
7 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
8 | },
9 | "include": ["src/**/*.ts"],
10 | "references": [{"path": "../workbox-core/"}]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/workbox-cli/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-cli
2 |
--------------------------------------------------------------------------------
/packages/workbox-cli/src/lib/cleanup-stack-trace.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | // Helper to parse out less relevant info from an Error's stack trace.
10 | // Removes the initial portion, since that's obtained from error.message.
11 | // Removes every stack frame earlier than the last instance of moduleName,
12 | // since that's just frames related to the Node runtime/loader.
13 | export function cleanupStackTrace(error: Error, moduleName: string): string {
14 | if (!error.stack) {
15 | return '';
16 | }
17 | const frames = error.stack.split(`\n`);
18 | let startFrame: number | undefined;
19 | let lastFrame = 0;
20 | frames.forEach((frame, index) => {
21 | if (startFrame === undefined && frame.includes(` at `)) {
22 | startFrame = index;
23 | }
24 |
25 | if (frame.includes(`${moduleName}:`)) {
26 | lastFrame = index;
27 | }
28 | });
29 | return frames.slice(startFrame, lastFrame + 1).join(`\n`);
30 | }
31 |
--------------------------------------------------------------------------------
/packages/workbox-cli/src/lib/constants.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | export const constants = {
10 | defaultConfigFile: 'workbox-config.js',
11 | ignoredDirectories: ['node_modules'],
12 | ignoredFileExtensions: ['map'],
13 | ignoreURLParametersMatching: [/^utm_/, /^fbclid$/],
14 | };
15 |
--------------------------------------------------------------------------------
/packages/workbox-cli/src/lib/logger.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import chalk from 'chalk';
10 |
11 | export const logger = {
12 | debug: (...args: string[]): void => console.log(chalk.gray(...args)),
13 | log: (...args: string[]): void => console.log(...args),
14 | warn: (...args: string[]): void => console.warn(chalk.yellow(...args)),
15 | error: (...args: string[]): void => console.error(chalk.red.bold(...args)),
16 | };
17 |
--------------------------------------------------------------------------------
/packages/workbox-cli/src/lib/questions/ask-sw-src.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {Answers} from 'inquirer';
10 | import inquirer from 'inquirer';
11 | import {oneLine as ol} from 'common-tags';
12 |
13 | // The key used for the question/answer.
14 | const name = 'swSrc';
15 |
16 | /**
17 | * @return {Promise} The answers from inquirer.
18 | */
19 | function askQuestion(): Promise {
20 | return inquirer.prompt([
21 | {
22 | name,
23 | message: ol`Where's your existing service worker file? To be used with
24 | injectManifest, it should include a call to
25 | 'self.__WB_MANIFEST'`,
26 | type: 'input',
27 | },
28 | ]);
29 | }
30 |
31 | export async function askSWSrc(): Promise {
32 | const answers = await askQuestion();
33 | // When prompt type is input the return is string or null
34 | return answers[name] ? (answers[name] as string).trim() : null;
35 | }
36 |
--------------------------------------------------------------------------------
/packages/workbox-cli/src/lib/read-config.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {GenerateSWOptions, InjectManifestOptions} from 'workbox-build';
10 |
11 | // A really light wrapper on top of Node's require() to make it easier to stub
12 | // out reading the configuration during tests.
13 | export function readConfig(
14 | configFile: string,
15 | ): GenerateSWOptions | InjectManifestOptions {
16 | return require(configFile) as GenerateSWOptions | InjectManifestOptions;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/workbox-cli/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "esModuleInterop": true,
5 | "module": "CommonJS",
6 | "outDir": "build",
7 | "rootDir": "src",
8 | "target": "ES2018",
9 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
10 | },
11 | "include": ["src/**/*.ts"],
12 | "references": [{"path": "../workbox-build/"}]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/workbox-core/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-core
2 |
--------------------------------------------------------------------------------
/packages/workbox-core/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-core",
3 | "version": "7.3.0",
4 | "lockfileVersion": 3,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "workbox-core",
9 | "version": "7.3.0",
10 | "license": "MIT"
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/packages/workbox-core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-core",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "This module is used by a number of the other Workbox modules to share common code.",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw"
18 | ],
19 | "workbox": {
20 | "browserNamespace": "workbox.core",
21 | "packageType": "sw"
22 | },
23 | "main": "index.js",
24 | "module": "index.mjs",
25 | "types": "index.d.ts"
26 | }
27 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/_private/Deferred.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import '../_version.js';
10 |
11 | /**
12 | * The Deferred class composes Promises in a way that allows for them to be
13 | * resolved or rejected from outside the constructor. In most cases promises
14 | * should be used directly, but Deferreds can be necessary when the logic to
15 | * resolve a promise must be separate.
16 | *
17 | * @private
18 | */
19 | class Deferred {
20 | promise: Promise;
21 | resolve!: (value: T) => void;
22 | reject!: (reason?: any) => void;
23 |
24 | /**
25 | * Creates a promise and exposes its resolve and reject functions as methods.
26 | */
27 | constructor() {
28 | this.promise = new Promise((resolve, reject) => {
29 | this.resolve = resolve;
30 | this.reject = reject;
31 | });
32 | }
33 | }
34 |
35 | export {Deferred};
36 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/_private/dontWaitFor.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 | Use of this source code is governed by an MIT-style
4 | license that can be found in the LICENSE file or at
5 | https://opensource.org/licenses/MIT.
6 | */
7 |
8 | import '../_version.js';
9 |
10 | /**
11 | * A helper function that prevents a promise from being flagged as unused.
12 | *
13 | * @private
14 | **/
15 | export function dontWaitFor(promise: Promise): void {
16 | // Effective no-op.
17 | void promise.then(() => {});
18 | }
19 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/_private/getFriendlyURL.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import '../_version.js';
10 |
11 | const getFriendlyURL = (url: URL | string): string => {
12 | const urlObj = new URL(String(url), location.href);
13 | // See https://github.com/GoogleChrome/workbox/issues/2323
14 | // We want to include everything, except for the origin if it's same-origin.
15 | return urlObj.href.replace(new RegExp(`^${location.origin}`), '');
16 | };
17 |
18 | export {getFriendlyURL};
19 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/_private/timeout.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 | Use of this source code is governed by an MIT-style
4 | license that can be found in the LICENSE file or at
5 | https://opensource.org/licenses/MIT.
6 | */
7 |
8 | import '../_version.js';
9 |
10 | /**
11 | * Returns a promise that resolves and the passed number of milliseconds.
12 | * This utility is an async/await-friendly version of `setTimeout`.
13 | *
14 | * @param {number} ms
15 | * @return {Promise}
16 | * @private
17 | */
18 |
19 | export function timeout(ms: number): Promise {
20 | return new Promise((resolve) => setTimeout(resolve, ms));
21 | }
22 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/_private/waitUntil.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2020 Google LLC
3 | Use of this source code is governed by an MIT-style
4 | license that can be found in the LICENSE file or at
5 | https://opensource.org/licenses/MIT.
6 | */
7 |
8 | import '../_version.js';
9 |
10 | /**
11 | * A utility method that makes it easier to use `event.waitUntil` with
12 | * async functions and return the result.
13 | *
14 | * @param {ExtendableEvent} event
15 | * @param {Function} asyncFn
16 | * @return {Function}
17 | * @private
18 | */
19 | function waitUntil(
20 | event: ExtendableEvent,
21 | asyncFn: () => Promise,
22 | ): Promise {
23 | const returnPromise = asyncFn();
24 | event.waitUntil(returnPromise);
25 | return returnPromise;
26 | }
27 |
28 | export {waitUntil};
29 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:core:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-core/src/clientsClaim.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import './_version.js';
10 |
11 | // Give TypeScript the correct global.
12 | declare let self: ServiceWorkerGlobalScope;
13 |
14 | /**
15 | * Claim any currently available clients once the service worker
16 | * becomes active. This is normally used in conjunction with `skipWaiting()`.
17 | *
18 | * @memberof workbox-core
19 | */
20 | function clientsClaim(): void {
21 | self.addEventListener('activate', () => self.clients.claim());
22 | }
23 |
24 | export {clientsClaim};
25 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {registerQuotaErrorCallback} from './registerQuotaErrorCallback.js';
10 | import * as _private from './_private.js';
11 | import {cacheNames} from './cacheNames.js';
12 | import {copyResponse} from './copyResponse.js';
13 | import {clientsClaim} from './clientsClaim.js';
14 | import {setCacheNameDetails} from './setCacheNameDetails.js';
15 | import {skipWaiting} from './skipWaiting.js';
16 | import './_version.js';
17 |
18 | /**
19 | * All of the Workbox service worker libraries use workbox-core for shared
20 | * code as well as setting default values that need to be shared (like cache
21 | * names).
22 | *
23 | * @module workbox-core
24 | */
25 | export {
26 | _private,
27 | cacheNames,
28 | clientsClaim,
29 | copyResponse,
30 | registerQuotaErrorCallback,
31 | setCacheNameDetails,
32 | skipWaiting,
33 | };
34 |
35 | export * from './types.js';
36 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/models/messages/messageGenerator.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {messages} from './messages.js';
10 | import '../../_version.js';
11 |
12 | const fallback = (code: string, ...args: any[]) => {
13 | let msg = code;
14 | if (args.length > 0) {
15 | msg += ` :: ${JSON.stringify(args)}`;
16 | }
17 | return msg;
18 | };
19 |
20 | const generatorFunction = (code: string, details = {}) => {
21 | const message = messages[code];
22 | if (!message) {
23 | throw new Error(`Unable to find message for code '${code}'.`);
24 | }
25 |
26 | return message(details);
27 | };
28 |
29 | export const messageGenerator =
30 | process.env.NODE_ENV === 'production' ? fallback : generatorFunction;
31 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/models/pluginEvents.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import '../_version.js';
10 |
11 | export const enum pluginEvents {
12 | CACHE_DID_UPDATE = 'cacheDidUpdate',
13 | CACHE_KEY_WILL_BE_USED = 'cacheKeyWillBeUsed',
14 | CACHE_WILL_UPDATE = 'cacheWillUpdate',
15 | CACHED_RESPONSE_WILL_BE_USED = 'cachedResponseWillBeUsed',
16 | FETCH_DID_FAIL = 'fetchDidFail',
17 | FETCH_DID_SUCCEED = 'fetchDidSucceed',
18 | REQUEST_WILL_FETCH = 'requestWillFetch',
19 | }
20 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/models/quotaErrorCallbacks.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import '../_version.js';
10 |
11 | // Callbacks to be executed whenever there's a quota error.
12 | // Can't change Function type right now.
13 | // eslint-disable-next-line @typescript-eslint/ban-types
14 | const quotaErrorCallbacks: Set = new Set();
15 |
16 | export {quotaErrorCallbacks};
17 |
--------------------------------------------------------------------------------
/packages/workbox-core/src/utils/pluginUtils.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {WorkboxPlugin} from '../types.js';
10 | import '../_version.js';
11 |
12 | export const pluginUtils = {
13 | filter: (plugins: WorkboxPlugin[], callbackName: string): WorkboxPlugin[] => {
14 | return plugins.filter((plugin) => callbackName in plugin);
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/packages/workbox-core/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "outDir": "./",
6 | "rootDir": "./src",
7 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
8 | },
9 | "include": ["src/**/*.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/packages/workbox-expiration/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-expiration
2 |
--------------------------------------------------------------------------------
/packages/workbox-expiration/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-expiration",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "A service worker helper library that expires cached responses based on age or maximum number of entries.",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw",
18 | "workbox-plugin"
19 | ],
20 | "workbox": {
21 | "browserNamespace": "workbox.expiration",
22 | "packageType": "sw"
23 | },
24 | "main": "index.js",
25 | "module": "index.mjs",
26 | "types": "index.d.ts",
27 | "dependencies": {
28 | "idb": "^7.0.1",
29 | "workbox-core": "7.3.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/workbox-expiration/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:expiration:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-expiration/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {CacheExpiration} from './CacheExpiration.js';
10 | import {ExpirationPlugin, ExpirationPluginOptions} from './ExpirationPlugin.js';
11 |
12 | import './_version.js';
13 |
14 | /**
15 | * @module workbox-expiration
16 | */
17 |
18 | export {CacheExpiration, ExpirationPlugin, ExpirationPluginOptions};
19 |
--------------------------------------------------------------------------------
/packages/workbox-expiration/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "outDir": "./",
6 | "rootDir": "./src",
7 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
8 | },
9 | "include": ["src/**/*.ts"],
10 | "references": [{"path": "../workbox-core/"}]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/workbox-google-analytics/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-google-analytics
2 |
--------------------------------------------------------------------------------
/packages/workbox-google-analytics/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:google-analytics:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-google-analytics/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {initialize, GoogleAnalyticsInitializeOptions} from './initialize.js';
10 |
11 | import './_version.js';
12 |
13 | /**
14 | * @module workbox-google-analytics
15 | */
16 |
17 | export {initialize, GoogleAnalyticsInitializeOptions};
18 |
--------------------------------------------------------------------------------
/packages/workbox-google-analytics/src/utils/constants.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import '../_version.js';
10 |
11 | export const QUEUE_NAME = 'workbox-google-analytics';
12 | export const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes
13 | export const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';
14 | export const GTM_HOST = 'www.googletagmanager.com';
15 | export const ANALYTICS_JS_PATH = '/analytics.js';
16 | export const GTAG_JS_PATH = '/gtag/js';
17 | export const GTM_JS_PATH = '/gtm.js';
18 | export const COLLECT_DEFAULT_PATH = '/collect';
19 |
20 | // This RegExp matches all known Measurement Protocol single-hit collect
21 | // endpoints. Most of the time the default path (/collect) is used, but
22 | // occasionally an experimental endpoint is used when testing new features,
23 | // (e.g. /r/collect or /j/collect)
24 | export const COLLECT_PATHS_REGEX = /^\/(\w+\/)?collect/;
25 |
--------------------------------------------------------------------------------
/packages/workbox-google-analytics/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "composite": true,
5 | "outDir": "./",
6 | "rootDir": "./src",
7 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
8 | },
9 | "include": ["src/**/*.ts"],
10 | "references": [
11 | {"path": "../workbox-background-sync/"},
12 | {"path": "../workbox-core/"},
13 | {"path": "../workbox-routing/"},
14 | {"path": "../workbox-strategies/"}
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload
2 |
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-navigation-preload",
3 | "version": "7.3.0",
4 | "lockfileVersion": 3,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "workbox-navigation-preload",
9 | "version": "7.3.0",
10 | "license": "MIT",
11 | "dependencies": {
12 | "workbox-core": "7.3.0"
13 | }
14 | },
15 | "node_modules/workbox-core": {
16 | "version": "7.3.0",
17 | "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-7.3.0.tgz",
18 | "integrity": "sha512-Z+mYrErfh4t3zi7NVTvOuACB0A/jA3bgxUN3PwtAVHvfEsZxV9Iju580VEETug3zYJRc0Dmii/aixI/Uxj8fmw==",
19 | "license": "MIT"
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-navigation-preload",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "This library allows developers to opt-in to using Navigation Preload in their service worker.",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw",
18 | "navigation"
19 | ],
20 | "workbox": {
21 | "browserNamespace": "workbox.navigationPreload",
22 | "packageType": "sw"
23 | },
24 | "main": "index.js",
25 | "module": "index.mjs",
26 | "types": "index.d.ts",
27 | "dependencies": {
28 | "workbox-core": "7.3.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:navigation-preload:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {disable} from './disable.js';
10 | import {enable} from './enable.js';
11 | import {isSupported} from './isSupported.js';
12 | import './_version.js';
13 |
14 | // See https://github.com/GoogleChrome/workbox/issues/2946
15 | interface NavigationPreloadState {
16 | enabled?: boolean;
17 | headerValue?: string;
18 | }
19 |
20 | interface NavigationPreloadManager {
21 | disable(): Promise;
22 | enable(): Promise;
23 | getState(): Promise;
24 | setHeaderValue(value: string): Promise;
25 | }
26 |
27 | declare global {
28 | interface ServiceWorkerRegistration {
29 | readonly navigationPreload: NavigationPreloadManager;
30 | }
31 | }
32 |
33 | /**
34 | * @module workbox-navigation-preload
35 | */
36 |
37 | export {disable, enable, isSupported};
38 |
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/src/isSupported.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2018 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import './_version.js';
10 |
11 | // Give TypeScript the correct global.
12 | declare let self: ServiceWorkerGlobalScope;
13 |
14 | /**
15 | * @return {boolean} Whether or not the current browser supports enabling
16 | * navigation preload.
17 | *
18 | * @memberof workbox-navigation-preload
19 | */
20 | function isSupported(): boolean {
21 | return Boolean(self.registration && self.registration.navigationPreload);
22 | }
23 |
24 | export {isSupported};
25 |
--------------------------------------------------------------------------------
/packages/workbox-navigation-preload/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig",
3 | "compilerOptions": {
4 | "outDir": "./",
5 | "rootDir": "./src",
6 | "tsBuildInfoFile": "./tsconfig.tsbuildinfo"
7 | },
8 | "include": ["src/**/*.ts"],
9 | "references": [{"path": "../workbox-core/"}]
10 | }
11 |
--------------------------------------------------------------------------------
/packages/workbox-precaching/README.md:
--------------------------------------------------------------------------------
1 | This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-precaching
2 |
--------------------------------------------------------------------------------
/packages/workbox-precaching/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workbox-precaching",
3 | "version": "7.3.0",
4 | "license": "MIT",
5 | "author": "Google's Web DevRel Team and Google's Aurora Team",
6 | "description": "This module efficiently precaches assets.",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/googlechrome/workbox.git"
10 | },
11 | "bugs": "https://github.com/googlechrome/workbox/issues",
12 | "homepage": "https://github.com/GoogleChrome/workbox",
13 | "keywords": [
14 | "workbox",
15 | "workboxjs",
16 | "service worker",
17 | "sw"
18 | ],
19 | "workbox": {
20 | "browserNamespace": "workbox.precaching",
21 | "packageType": "sw"
22 | },
23 | "main": "index.js",
24 | "module": "index.mjs",
25 | "types": "index.d.ts",
26 | "dependencies": {
27 | "workbox-core": "7.3.0",
28 | "workbox-routing": "7.3.0",
29 | "workbox-strategies": "7.3.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/workbox-precaching/src/_version.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | try{self['workbox:precaching:7.3.0']&&_()}catch(e){}
--------------------------------------------------------------------------------
/packages/workbox-precaching/src/addPlugins.ts:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 Google LLC
3 |
4 | Use of this source code is governed by an MIT-style
5 | license that can be found in the LICENSE file or at
6 | https://opensource.org/licenses/MIT.
7 | */
8 |
9 | import {WorkboxPlugin} from 'workbox-core/types.js';
10 | import {getOrCreatePrecacheController} from './utils/getOrCreatePrecacheController.js';
11 | import './_version.js';
12 |
13 | /**
14 | * Adds plugins to the precaching strategy.
15 | *
16 | * @param {Array