Skip to content

Commit

Permalink
Renaming workbox-runtime-caching to workbox-strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Gaunt committed Nov 14, 2017
1 parent d0d8b12 commit 64898a0
Show file tree
Hide file tree
Showing 42 changed files with 57 additions and 58 deletions.
2 changes: 1 addition & 1 deletion demos/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const workboxModules = [
'workbox-precaching',
'workbox-range-requests',
'workbox-routing',
'workbox-runtime-caching',
'workbox-strategies',
'workbox-sw',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</section>

<script>
navigator.serviceWorker.register('/demo/workbox-runtime-caching/sw.js');
navigator.serviceWorker.register('/demo/workbox-strategies/sw.js');
const cacheOnlyEmpty = document.querySelector('.cache-only-empty-cache');
cacheOnlyEmpty.addEventListener('click', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

self.addEventListener('fetch', (event) => {
switch (new URL(event.request.url).pathname) {
case '/demo/workbox-runtime-caching/cache-only-empty-cache.txt':
case '/demo/workbox-strategies/cache-only-empty-cache.txt':
const cacheOnlyEmpty = new workbox.strategies.CacheOnly();
event.respondWith(cacheOnlyEmpty.handle({event}));
break;
case '/demo/workbox-runtime-caching/cache-only-populated-cache':
case '/demo/workbox-strategies/cache-only-populated-cache':
const cacheOnlyPopulated = new workbox.strategies.CacheOnly();
event.respondWith(cacheOnlyPopulated.handle({event}));
break;
case '/demo/workbox-runtime-caching/cache-first.txt':
case '/demo/workbox-strategies/cache-first.txt':
const cacheFirst = new workbox.strategies.CacheFirst();
event.respondWith(cacheFirst.handle({event}));
break;
case '/demo/workbox-runtime-caching/network-only.txt':
case '/demo/workbox-strategies/network-only.txt':
const networkOnly = new workbox.strategies.NetworkOnly();
event.respondWith(networkOnly.handle({event}));
break;
case '/demo/workbox-runtime-caching/network-first.txt':
case '/demo/workbox-strategies/network-first.txt':
const networkFirst = new workbox.strategies.NetworkFirst();
event.respondWith(networkFirst.handle({event}));
break;
case '/demo/workbox-runtime-caching/network-first-404.txt':
case '/demo/workbox-strategies/network-first-404.txt':
const networkFirstInvalid = new workbox.strategies.NetworkFirst();
event.respondWith(networkFirstInvalid.handle({event}));
break;
case '/demo/workbox-runtime-caching/stale-while-revalidate.txt':
case '/demo/workbox-strategies/stale-while-revalidate.txt':
const staleWhileRevalidate = new workbox.strategies.StaleWhileRevalidate();
event.respondWith(staleWhileRevalidate.handle({event}));
break;
Expand All @@ -44,7 +44,7 @@ self.addEventListener('install', (event) => {
caches.open(workbox.core.cacheNames.runtime)
.then((cache) => {
return cache.put(
new Request('/demo/workbox-runtime-caching/cache-only-populated-cache'),
new Request('/demo/workbox-strategies/cache-only-populated-cache'),
new Response('Hello from the populated cache.')
);
})
Expand Down
1 change: 1 addition & 0 deletions gulp-tasks/demos.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gulp.task('demos:groupBuildFiles', async () => {

const localBuildPath = path.join(__dirname, '..', 'demos', 'public',
constants.LOCAL_BUILDS_DIR);
await fs.remove(localBuildPath);
await fs.ensureDir(localBuildPath);

// Copy files from the source code and move into the grouped build
Expand Down
2 changes: 1 addition & 1 deletion infra/pr-bot/aggregate-size-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AggregateSizePlugin extends PluginInterface {
`workbox-core`,
`workbox-precaching`,
`workbox-routing`,
`workbox-runtime-caching`,
`workbox-strategies`,
`workbox-sw`,
];
const files = packagesToAggregate.map((pkgName) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"workbox-core": "^3.0.0-alpha.24",
"workbox-precaching": "^3.0.0-alpha.24",
"workbox-routing": "^3.0.0-alpha.24",
"workbox-runtime-caching": "^3.0.0-alpha.24",
"workbox-strategies": "^3.0.0-alpha.24",
"workbox-sw": "^3.0.0-alpha.24"
},
"main": "build/index.js",
Expand Down
4 changes: 1 addition & 3 deletions packages/workbox-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/workbox-google-analytics/_default.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {QueuePlugin} from 'workbox-background-sync/QueuePlugin.mjs';
import {cacheNames} from 'workbox-core/_private/cacheNames.mjs';
import {Route} from 'workbox-routing/Route.mjs';
import {Router} from 'workbox-routing/Router.mjs';
import {NetworkFirst} from 'workbox-runtime-caching/NetworkFirst.mjs';
import {NetworkOnly} from 'workbox-runtime-caching/NetworkOnly.mjs';
import {NetworkFirst} from 'workbox-strategies/NetworkFirst.mjs';
import {NetworkOnly} from 'workbox-strategies/NetworkOnly.mjs';
import {
QUEUE_NAME,
MAX_RETENTION_TIME,
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"workbox-background-sync": "^3.0.0-alpha.24",
"workbox-core": "^3.0.0-alpha.24",
"workbox-routing": "^3.0.0-alpha.24",
"workbox-runtime-caching": "^3.0.0-alpha.24"
"workbox-strategies": "^3.0.0-alpha.24"
}
}
1 change: 0 additions & 1 deletion packages/workbox-runtime-caching/_version.mjs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CacheFirst {
const logs = [];
if (process.env.NODE_ENV !== 'production') {
assert.isInstance(event, FetchEvent, {
moduleName: 'workbox-runtime-caching',
moduleName: 'workbox-strategies',
className: 'CacheFirst',
funcName: 'handle',
paramName: 'event',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CacheOnly {
async handle({event}) {
if (process.env.NODE_ENV !== 'production') {
assert.isInstance(event, FetchEvent, {
moduleName: 'workbox-runtime-caching',
moduleName: 'workbox-strategies',
className: 'CacheOnly',
funcName: 'handle',
paramName: 'event',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class NetworkFirst {
if (process.env.NODE_ENV !== 'production') {
if (this._networkTimeoutSeconds) {
assert.isType(this._networkTimeoutSeconds, 'number', {
moduleName: 'workbox-runtime-caching',
moduleName: 'workbox-strategies',
className: 'NetworkFirst',
funcName: 'constructor',
paramName: 'networkTimeoutSeconds',
Expand All @@ -93,7 +93,7 @@ class NetworkFirst {
const logs = [];
if (process.env.NODE_ENV !== 'production') {
assert.isInstance(event, FetchEvent, {
moduleName: 'workbox-runtime-caching',
moduleName: 'workbox-strategies',
className: 'NetworkFirst',
funcName: 'handle',
paramName: 'event',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class NetworkOnly {
async handle({event}) {
if (process.env.NODE_ENV !== 'production') {
assert.isInstance(event, FetchEvent, {
moduleName: 'workbox-runtime-caching',
moduleName: 'workbox-strategies',
className: 'NetworkOnly',
funcName: 'handle',
paramName: 'event',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class StaleWhileRevalidate {
const logs = [];
if (process.env.NODE_ENV !== 'production') {
assert.isInstance(event, FetchEvent, {
moduleName: 'workbox-runtime-caching',
moduleName: 'workbox-strategies',
className: 'StaleWhileRevalidate',
funcName: 'handle',
paramName: 'event',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/workbox-strategies/_version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
try{self.workbox.v['workbox:strategies:3.0.0-alpha.24']=1;}catch(e){} // eslint-disable-line
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "workbox-runtime-caching",
"name": "workbox-strategies",
"version": "3.0.0-alpha.24",
"license": "Apache-2.0",
"author": "Google's Web DevRel Team",
Expand All @@ -16,15 +16,15 @@
"routing"
],
"scripts": {
"build": "gulp build-packages --package workbox-runtime-caching",
"build": "gulp build-packages --package workbox-strategies",
"version": "npm run build",
"prepare": "npm run build"
},
"workbox": {
"browserNamespace": "workbox.strategies",
"packageType": "browser"
},
"main": "build/workbox-runtime-caching.prod.js",
"main": "build/workbox-strategies.prod.js",
"module": "index.mjs",
"dependencies": {
"workbox-cache-expiration": "^3.0.0-alpha.24",
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-sw/controllers/WorkboxSW.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const MODULE_KEY_TO_NAME_MAPPING = {
core: 'core',
expiration: 'cache-expiration',
googleAnalytics: 'google-analytics',
strategies: 'runtime-caching',
strategies: 'strategies',
precaching: 'precaching',
routing: 'routing',
};
Expand Down
2 changes: 1 addition & 1 deletion test/workbox-build/node/dependency-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe(`[workbox-build] Test Dependencies`, function() {
'workbox-core',
'workbox-precaching',
'workbox-routing',
'workbox-runtime-caching',
'workbox-strategies',
'workbox-sw',
],
}, (unusedDeps) => {
Expand Down
8 changes: 4 additions & 4 deletions test/workbox-build/node/entry-points/generate-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function()
'workbox-routing.dev.js.map',
'workbox-routing.prod.js',
'workbox-routing.prod.js.map',
'workbox-runtime-caching.dev.js',
'workbox-runtime-caching.dev.js.map',
'workbox-runtime-caching.prod.js',
'workbox-runtime-caching.prod.js.map',
'workbox-strategies.dev.js',
'workbox-strategies.dev.js.map',
'workbox-strategies.prod.js',
'workbox-strategies.prod.js.map',
'workbox-sw.js',
'workbox-sw.js.map',
]);
Expand Down
2 changes: 1 addition & 1 deletion test/workbox-google-analytics/node/test-index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {reset as iDBReset} from 'shelving-mock-indexeddb';
import {eventsDoneWaiting, resetEventListeners} from '../../../infra/testing/sw-env-mocks/event-listeners.js';
import {Queue} from '../../../packages/workbox-background-sync/Queue.mjs';
import {cacheNames} from '../../../packages/workbox-core/_private/cacheNames.mjs';
import {NetworkFirst, NetworkOnly} from '../../../packages/workbox-runtime-caching/index.mjs';
import {NetworkFirst, NetworkOnly} from '../../../packages/workbox-strategies/index.mjs';
import * as googleAnalytics from '../../../packages/workbox-google-analytics/index.mjs';
import {
MAX_RETENTION_TIME,
Expand Down
4 changes: 2 additions & 2 deletions test/workbox-runtime-caching/node/test-CacheFirst.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {expect} from 'chai';
import {_private} from '../../../packages/workbox-core/index.mjs';
import {compareResponses} from '../utils/response-comparisons.mjs';

import {CacheFirst} from '../../../packages/workbox-runtime-caching/CacheFirst.mjs';
import {CacheFirst} from '../../../packages/workbox-strategies/CacheFirst.mjs';

describe(`[workbox-runtime-caching] CacheFirst`, function() {
describe(`[workbox-strategies] CacheFirst`, function() {
let sandbox = sinon.sandbox.create();

beforeEach(async function() {
Expand Down
4 changes: 2 additions & 2 deletions test/workbox-runtime-caching/node/test-CacheOnly.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {expect} from 'chai';
import {_private} from '../../../packages/workbox-core/index.mjs';
import {compareResponses} from '../utils/response-comparisons.mjs';

import {CacheOnly} from '../../../packages/workbox-runtime-caching/CacheOnly.mjs';
import {CacheOnly} from '../../../packages/workbox-strategies/CacheOnly.mjs';

describe(`[workbox-runtime-caching] CacheOnly`, function() {
describe(`[workbox-strategies] CacheOnly`, function() {
let sandbox = sinon.sandbox.create();

beforeEach(async function() {
Expand Down
6 changes: 3 additions & 3 deletions test/workbox-runtime-caching/node/test-NetworkFirst.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {devOnly} from '../../../infra/testing/env-it';
import {_private} from '../../../packages/workbox-core/index.mjs';
import {compareResponses} from '../utils/response-comparisons.mjs';

import {NetworkFirst} from '../../../packages/workbox-runtime-caching/NetworkFirst.mjs';
import {NetworkFirst} from '../../../packages/workbox-strategies/NetworkFirst.mjs';

describe(`[workbox-runtime-caching] NetworkFirst`, function() {
describe(`[workbox-strategies] NetworkFirst`, function() {
let sandbox = sinon.sandbox.create();

beforeEach(async function() {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe(`[workbox-runtime-caching] NetworkFirst`, function() {
return expectError(() => new NetworkFirst({networkTimeoutSeconds: 'invalid'}), 'incorrect-type', (err) => {
expect(err.details.paramName).to.deep.equal('networkTimeoutSeconds');
expect(err.details.expectedType).to.deep.equal('number');
expect(err.details.moduleName).to.deep.equal('workbox-runtime-caching');
expect(err.details.moduleName).to.deep.equal('workbox-strategies');
expect(err.details.className).to.deep.equal('NetworkFirst');
expect(err.details.funcName).to.deep.equal('constructor');
});
Expand Down
4 changes: 2 additions & 2 deletions test/workbox-runtime-caching/node/test-NetworkOnly.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {expect} from 'chai';

import {_private} from '../../../packages/workbox-core/index.mjs';

import {NetworkOnly} from '../../../packages/workbox-runtime-caching/NetworkOnly.mjs';
import {NetworkOnly} from '../../../packages/workbox-strategies/NetworkOnly.mjs';

describe(`[workbox-runtime-caching] NetworkOnly`, function() {
describe(`[workbox-strategies] NetworkOnly`, function() {
let sandbox = sinon.sandbox.create();

beforeEach(async function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {expect} from 'chai';
import {_private} from '../../../packages/workbox-core/index.mjs';
import {compareResponses} from '../utils/response-comparisons.mjs';

import {StaleWhileRevalidate} from '../../../packages/workbox-runtime-caching/StaleWhileRevalidate.mjs';
import {StaleWhileRevalidate} from '../../../packages/workbox-strategies/StaleWhileRevalidate.mjs';

describe(`[workbox-runtime-caching] StaleWhileRevalidate`, function() {
describe(`[workbox-strategies] StaleWhileRevalidate`, function() {
let sandbox = sinon.sandbox.create();

beforeEach(async function() {
Expand Down
12 changes: 6 additions & 6 deletions test/workbox-runtime-caching/node/test-UsageWithRouter.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {CacheFirst} from '../../../packages/workbox-runtime-caching/CacheFirst.mjs';
import {CacheOnly} from '../../../packages/workbox-runtime-caching/CacheOnly.mjs';
import {NetworkFirst} from '../../../packages/workbox-runtime-caching/NetworkFirst.mjs';
import {NetworkOnly} from '../../../packages/workbox-runtime-caching/NetworkOnly.mjs';
import {StaleWhileRevalidate} from '../../../packages/workbox-runtime-caching/StaleWhileRevalidate.mjs';
import {CacheFirst} from '../../../packages/workbox-strategies/CacheFirst.mjs';
import {CacheOnly} from '../../../packages/workbox-strategies/CacheOnly.mjs';
import {NetworkFirst} from '../../../packages/workbox-strategies/NetworkFirst.mjs';
import {NetworkOnly} from '../../../packages/workbox-strategies/NetworkOnly.mjs';
import {StaleWhileRevalidate} from '../../../packages/workbox-strategies/StaleWhileRevalidate.mjs';
import {Router} from '../../../packages/workbox-routing/Router.mjs';
import {Route} from '../../../packages/workbox-routing/Route.mjs';

describe(`[workbox-runtime-caching] Usages with Router`, function() {
describe(`[workbox-strategies] Usages with Router`, function() {
[CacheFirst, CacheOnly, NetworkFirst, NetworkOnly, StaleWhileRevalidate].forEach((StrategyClass) => {
it(`should show Router and '${StrategyClass.name}' will work together`, function() {
const router = new Router();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from 'chai';
import plugin from '../../../packages/workbox-runtime-caching/plugins/cacheOkAndOpaquePlugin.mjs';
import plugin from '../../../packages/workbox-strategies/plugins/cacheOkAndOpaquePlugin.mjs';

describe(`[workbox-runtime-caching] cacheOkAndOpaquePlugin`, function() {
describe(`[workbox-strategies] cacheOkAndOpaquePlugin`, function() {
it(`should return null if status is not ok and status is not opaque`, function() {
const response = new Response('Hello', {
status: 404,
Expand Down
6 changes: 3 additions & 3 deletions test/workbox-runtime-caching/node/test-default.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {expect} from 'chai';
import {CacheFirst, CacheOnly, NetworkFirst, NetworkOnly, StaleWhileRevalidate} from '../../../packages/workbox-runtime-caching/_public.mjs';
import strategies from '../../../packages/workbox-runtime-caching/_default.mjs';
import {CacheFirst, CacheOnly, NetworkFirst, NetworkOnly, StaleWhileRevalidate} from '../../../packages/workbox-strategies/_public.mjs';
import strategies from '../../../packages/workbox-strategies/_default.mjs';
import {CacheExpirationPlugin} from '../../../packages/workbox-cache-expiration/CacheExpirationPlugin.mjs';

describe(`[workbox-runtime-caching] Default Export`, function() {
describe(`[workbox-strategies] Default Export`, function() {
const CUSTOM_PLUGIN = {};
describe(`cacheFirst()`, function() {
it(`should return a CacheFirst instance`, function() {
Expand Down
2 changes: 1 addition & 1 deletion test/workbox-sw/node/test-WorkboxSW.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe(`[workbox-sw] WorkboxSW`, function() {
if (url.includes('workbox-precaching')) {
self.workbox.precaching = fakeWorkbox.precaching;
}
if (url.includes('workbox-runtime-caching')) {
if (url.includes('workbox-strategies')) {
self.workbox.strategies = fakeWorkbox.strategies;
}
});
Expand Down

0 comments on commit 64898a0

Please sign in to comment.