@teambit/react 0.0.744 → 0.0.747
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/env-template/public/{168.js → 725.js} +2 -2
- package/artifacts/env-template/public/assets-manifest.json +9 -11
- package/artifacts/env-template/public/{compositions.554800e08ed6a116ca98.js → compositions.5a9806c7f868366ddf75.js} +1 -1
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/{overview.979fd36ad16dfbbc11de.js → overview.3b5374fd9d4e1443bb10.js} +1 -1
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/{preview-root.addb7d0cbec141028f61.js → preview-root.84b4be339239153bab32.js} +1 -1
- package/artifacts/preview/teambit_react_react-preview.js +2 -2
- package/{compositions-1653827208409.js → compositions-1653967602594.js} +0 -0
- package/dist/react.templates.js +11 -1
- package/dist/react.templates.js.map +1 -1
- package/dist/templates/react-workspace-blog/index.d.ts +2 -0
- package/dist/templates/react-workspace-blog/index.js +44 -0
- package/dist/templates/react-workspace-blog/index.js.map +1 -0
- package/dist/typescript/tsconfig.json +1 -0
- package/dist/webpack/webpack.config.base.prod.js +23 -48
- package/dist/webpack/webpack.config.base.prod.js.map +1 -1
- package/{overview-1653827208409.js → overview-1653967602594.js} +0 -0
- package/package-tar/teambit-react-0.0.747.tgz +0 -0
- package/package.json +25 -26
- package/{preview-1653827208409.js → preview-1653967602594.js} +2 -2
- package/templates/react-workspace-blog/index.ts +25 -0
- package/typescript/tsconfig.json +1 -0
- package/webpack/webpack.config.base.prod.ts +0 -16
- package/artifacts/env-template/public/service-worker.js +0 -1
- package/artifacts/env-template/public/workbox-ca45de73.js +0 -1
- package/package-tar/teambit-react-0.0.744.tgz +0 -0
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.747",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/react/react",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.react",
|
|
8
8
|
"name": "react",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.747"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"react-error-boundary": "^3.0.0",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"css-minimizer-webpack-plugin": "3.0.2",
|
|
22
22
|
"terser-webpack-plugin": "5.2.0",
|
|
23
23
|
"webpack": "5.51.1",
|
|
24
|
-
"workbox-webpack-plugin": "6.2.4",
|
|
25
24
|
"mini-css-extract-plugin": "2.2.2",
|
|
26
25
|
"react-dev-utils": "11.0.4",
|
|
27
26
|
"style-loader": "^2.0.0",
|
|
@@ -81,38 +80,38 @@
|
|
|
81
80
|
"@teambit/react.instructions.react.adding-compositions": "0.0.6",
|
|
82
81
|
"@teambit/react.instructions.react.adding-tests": "0.0.6",
|
|
83
82
|
"@teambit/design.ui.pages.standalone-not-found-page": "0.0.357",
|
|
84
|
-
"@teambit/preview": "0.0.
|
|
83
|
+
"@teambit/preview": "0.0.747",
|
|
85
84
|
"@teambit/react.ui.error-fallback": "0.0.111",
|
|
86
85
|
"@teambit/react.ui.loader-fallback": "0.0.89",
|
|
87
86
|
"@teambit/compositions.ui.hooks.use-composition": "0.0.163",
|
|
88
87
|
"@teambit/design.ui.tooltip": "0.0.352",
|
|
89
|
-
"@teambit/builder": "0.0.
|
|
90
|
-
"@teambit/bundler": "0.0.
|
|
91
|
-
"@teambit/compiler": "0.0.
|
|
88
|
+
"@teambit/builder": "0.0.747",
|
|
89
|
+
"@teambit/bundler": "0.0.747",
|
|
90
|
+
"@teambit/compiler": "0.0.747",
|
|
92
91
|
"@teambit/component.modules.component-url": "0.0.124",
|
|
93
|
-
"@teambit/component": "0.0.
|
|
94
|
-
"@teambit/dependency-resolver": "0.0.
|
|
95
|
-
"@teambit/envs": "0.0.
|
|
96
|
-
"@teambit/eslint": "0.0.
|
|
97
|
-
"@teambit/formatter": "0.0.
|
|
98
|
-
"@teambit/jest": "0.0.
|
|
99
|
-
"@teambit/linter": "0.0.
|
|
92
|
+
"@teambit/component": "0.0.747",
|
|
93
|
+
"@teambit/dependency-resolver": "0.0.747",
|
|
94
|
+
"@teambit/envs": "0.0.747",
|
|
95
|
+
"@teambit/eslint": "0.0.747",
|
|
96
|
+
"@teambit/formatter": "0.0.298",
|
|
97
|
+
"@teambit/jest": "0.0.747",
|
|
98
|
+
"@teambit/linter": "0.0.747",
|
|
100
99
|
"@teambit/logger": "0.0.586",
|
|
101
|
-
"@teambit/pkg": "0.0.
|
|
102
|
-
"@teambit/prettier": "0.0.
|
|
100
|
+
"@teambit/pkg": "0.0.747",
|
|
101
|
+
"@teambit/prettier": "0.0.298",
|
|
103
102
|
"@teambit/react.ui.highlighter.component-metadata.bit-component-meta": "0.0.21",
|
|
104
|
-
"@teambit/schema": "0.0.
|
|
105
|
-
"@teambit/tester": "0.0.
|
|
106
|
-
"@teambit/typescript": "0.0.
|
|
107
|
-
"@teambit/webpack": "0.0.
|
|
108
|
-
"@teambit/workspace": "0.0.
|
|
109
|
-
"@teambit/application": "0.0.
|
|
103
|
+
"@teambit/schema": "0.0.747",
|
|
104
|
+
"@teambit/tester": "0.0.747",
|
|
105
|
+
"@teambit/typescript": "0.0.747",
|
|
106
|
+
"@teambit/webpack": "0.0.747",
|
|
107
|
+
"@teambit/workspace": "0.0.747",
|
|
108
|
+
"@teambit/application": "0.0.389",
|
|
110
109
|
"@teambit/cli": "0.0.493",
|
|
111
|
-
"@teambit/generator": "0.0.
|
|
112
|
-
"@teambit/graphql": "0.0.
|
|
110
|
+
"@teambit/generator": "0.0.747",
|
|
111
|
+
"@teambit/graphql": "0.0.747",
|
|
113
112
|
"@teambit/react.ui.highlighter-provider": "0.0.189",
|
|
114
|
-
"@teambit/compositions": "0.0.
|
|
115
|
-
"@teambit/ui": "0.0.
|
|
113
|
+
"@teambit/compositions": "0.0.747",
|
|
114
|
+
"@teambit/ui": "0.0.747",
|
|
116
115
|
"@teambit/react.eslint-config-bit-react": "0.0.567",
|
|
117
116
|
"@teambit/mdx.modules.mdx-loader": "0.0.489",
|
|
118
117
|
"@teambit/react.babel.bit-react-transformer": "0.0.501",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.react_react@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.react_react@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.react_react@0.0.747/dist/react.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.react_react@0.0.747/dist/react.docs.mdx')]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
|
|
2
|
+
import { generateFiles as generateCommonFiles } from '../workspace-common';
|
|
3
|
+
|
|
4
|
+
export const reactWorkspaceBlogTemplate: WorkspaceTemplate = {
|
|
5
|
+
name: 'react-blog',
|
|
6
|
+
description: 'React workspace with components for a Blog',
|
|
7
|
+
generateFiles: async (context: WorkspaceContext) => {
|
|
8
|
+
return generateCommonFiles(context);
|
|
9
|
+
},
|
|
10
|
+
fork: () => {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
id: 'teambit.blog/starter/starter-blog',
|
|
14
|
+
targetName: 'starter/starter-blog',
|
|
15
|
+
path: 'starter/starter-blog',
|
|
16
|
+
},
|
|
17
|
+
{ id: 'teambit.blog/blog', targetName: 'blog', path: 'blog' },
|
|
18
|
+
{
|
|
19
|
+
id: 'teambit.blog/starter/blog-posts/post-one',
|
|
20
|
+
targetName: 'blog-posts/post-one',
|
|
21
|
+
path: 'blog-posts/post-one',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
},
|
|
25
|
+
};
|
package/typescript/tsconfig.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
|
|
2
1
|
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
3
2
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
4
3
|
import { Configuration } from 'webpack';
|
|
@@ -121,21 +120,6 @@ export default function (dev?: boolean): Configuration {
|
|
|
121
120
|
// }),
|
|
122
121
|
// Generate a service worker script that will precache, and keep up to date,
|
|
123
122
|
// the HTML & assets that are part of the webpack build.
|
|
124
|
-
new WorkboxWebpackPlugin.GenerateSW({
|
|
125
|
-
clientsClaim: true,
|
|
126
|
-
exclude: [/\.map$/, /asset-manifest\.json$/],
|
|
127
|
-
// importWorkboxFrom: 'cdn',
|
|
128
|
-
navigateFallback: 'public/index.html',
|
|
129
|
-
navigateFallbackDenylist: [
|
|
130
|
-
// Exclude URLs starting with /_, as they're likely an API call
|
|
131
|
-
new RegExp('^/_'),
|
|
132
|
-
// Exclude any URLs whose last part seems to be a file extension
|
|
133
|
-
// as they're likely a resource and not a SPA route.
|
|
134
|
-
// URLs containing a "?" character won't be blacklisted as they're likely
|
|
135
|
-
// a route with query params (e.g. auth callbacks).
|
|
136
|
-
new RegExp('/[^/?]+\\.[^/]+$'),
|
|
137
|
-
],
|
|
138
|
-
}),
|
|
139
123
|
].filter(Boolean),
|
|
140
124
|
// Turn off performance processing because we utilize
|
|
141
125
|
// our own hints via the FileSizeReporter
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
if(!self.define){const e=e=>{"require"!==e&&(e+=".js");let s=Promise.resolve();return r[e]||(s=new Promise((async s=>{if("document"in self){const r=document.createElement("script");r.src=e,document.head.appendChild(r),r.onload=s}else importScripts(e),s()}))),s.then((()=>{if(!r[e])throw new Error(`Module ${e} didn’t register its module`);return r[e]}))},s=(s,r)=>{Promise.all(s.map(e)).then((e=>r(1===e.length?e[0]:e)))},r={require:Promise.resolve(s)};self.define=(s,i,o)=>{r[s]||(r[s]=Promise.resolve().then((()=>{let r={};const c={uri:location.origin+s.slice(1)};return Promise.all(i.map((s=>{switch(s){case"exports":return r;case"module":return c;default:return e(s)}}))).then((e=>{const s=o(...e);return r.default||(r.default=s),r}))})))}}define("./service-worker.js",["./workbox-ca45de73"],(function(e){"use strict";self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()})),e.clientsClaim(),e.precacheAndRoute([{url:"149.js",revision:"4f0f2be57eaa671f6c50f371b4832768"},{url:"168.js",revision:"e391f75905dba1cb6d7826b88d3321a8"},{url:"516.js",revision:"cac2b9d14f27e37d4ac1b5f085dd8427"},{url:"588.js",revision:"414f513e3c0b54c3befca0a1386eb5b6"},{url:"677.js",revision:"e26f7a9eb3c7b4f6512413b5eda7b371"},{url:"compositions.554800e08ed6a116ca98.js",revision:null},{url:"compositions.html",revision:"46c1a3e49929d845cd5e891e8166d88f"},{url:"overview.979fd36ad16dfbbc11de.js",revision:null},{url:"overview.html",revision:"6ffd6f63bcaa2c60913019696284838b"},{url:"peers.edfbd1f8ec8a3331b9ac.js",revision:null},{url:"preview-root.addb7d0cbec141028f61.js",revision:null},{url:"runtime.js",revision:"9766ace9b1bfbc909a57d2232976e462"},{url:"static/css/295.04419670.css",revision:null},{url:"static/css/compositions.4138c069.css",revision:null},{url:"static/css/previewRoot.c0db5bec.css",revision:null}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("public/index.html"),{denylist:[/^\/_/,/\/[^/?]+\.[^/]+$/]}))}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
define("./workbox-ca45de73.js",["exports"],(function(t){"use strict";try{self["workbox:core:6.2.4"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:6.2.4"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class r{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class i extends r{constructor(t,e,s){super((({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)}),e,s)}}class o{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",(t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map((e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})})));t.waitUntil(s),t.ports&&t.ports[0]&&s.then((()=>t.ports[0].postMessage(!0)))}}))}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let o=i&&i.handler;const c=t.method;if(!o&&this.i.has(c)&&(o=this.i.get(c)),!o)return;let a;try{a=o.handle({url:s,request:t,event:e,params:r})}catch(t){a=Promise.reject(t)}const h=i&&i.catchHandler;return a instanceof Promise&&(this.o||h)&&(a=a.catch((async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:r})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n}))),a}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const r=this.t.get(s.method)||[];for(const i of r){let r;const o=i.match({url:t,sameOrigin:e,request:s,event:n});if(o)return r=o,(Array.isArray(r)&&0===r.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(r=void 0),{route:i,params:r}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let c;const a=()=>(c||(c=new o,c.addFetchListener(),c.addCacheListener()),c);function h(t,e,n){let o;if("string"==typeof t){const s=new URL(t,location.href);o=new r((({url:t})=>t.href===s.href),e,n)}else if(t instanceof RegExp)o=new i(t,e,n);else if("function"==typeof t)o=new r(t,e,n);else{if(!(t instanceof r))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});o=t}return a().registerRoute(o),o}const u={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},l=t=>[u.prefix,t,u.suffix].filter((t=>t&&t.length>0)).join("-"),f=t=>t||l(u.precache),w=t=>t||l(u.runtime);function d(t,e){const s=e();return t.waitUntil(s),s}try{self["workbox:precaching:6.2.4"]&&_()}catch(t){}function p(t){if(!t)throw new s("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const r=new URL(n,location.href),i=new URL(n,location.href);return r.searchParams.set("__WB_REVISION__",e),{cacheKey:r.href,url:i.href}}class y{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:t,state:e})=>{e&&(e.originalRequest=t)},this.cachedResponseWillBeUsed=async({event:t,state:e,cachedResponse:s})=>{if("install"===t.type&&e&&e.originalRequest&&e.originalRequest instanceof Request){const t=e.originalRequest.url;s?this.notUpdatedURLs.push(t):this.updatedURLs.push(t)}return s}}}class g{constructor({precacheController:t}){this.cacheKeyWillBeUsed=async({request:t,params:e})=>{const s=e&&e.cacheKey||this.h.getCacheKeyForURL(t.url);return s?new Request(s):t},this.h=t}}let R;async function m(t,e){let n=null;if(t.url){n=new URL(t.url).origin}if(n!==self.location.origin)throw new s("cross-origin-copy-response",{origin:n});const r=t.clone(),i={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},o=e?e(i):i,c=function(){if(void 0===R){const t=new Response("");if("body"in t)try{new Response(t.body),R=!0}catch(t){R=!1}R=!1}return R}()?r.body:await r.blob();return new Response(c,o)}function v(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class q{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}const U=new Set;try{self["workbox:strategies:6.2.4"]&&_()}catch(t){}function b(t){return"string"==typeof t?new Request(t):t}class L{constructor(t,e){this.u={},Object.assign(this,e),this.event=e.event,this.l=t,this.p=new q,this.g=[],this.R=[...t.plugins],this.m=new Map;for(const t of this.R)this.m.set(t,{});this.event.waitUntil(this.p.promise)}async fetch(t){const{event:e}=this;let n=b(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const i=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.l.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw r&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:r.clone(),request:i.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=b(t);let s;const{cacheName:n,matchOptions:r}=this.l,i=await this.getCacheKey(e,"read"),o=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(i,o);for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:n,matchOptions:r,cachedResponse:s,request:i,event:this.event})||void 0;return s}async cachePut(t,e){const n=b(t);var r;await(r=0,new Promise((t=>setTimeout(t,r))));const i=await this.getCacheKey(n,"write");if(!e)throw new s("cache-put-with-no-response",{url:(o=i.url,new URL(String(o),location.href).href.replace(new RegExp(`^${location.origin}`),""))});var o;const c=await this.v(e);if(!c)return!1;const{cacheName:a,matchOptions:h}=this.l,u=await self.caches.open(a),l=this.hasCallback("cacheDidUpdate"),f=l?await async function(t,e,s,n){const r=v(e.url,s);if(e.url===r)return t.match(e,n);const i=Object.assign(Object.assign({},n),{ignoreSearch:!0}),o=await t.keys(e,i);for(const e of o)if(r===v(e.url,s))return t.match(e,n)}(u,i.clone(),["__WB_REVISION__"],h):null;try{await u.put(i,l?c.clone():c)}catch(t){if(t instanceof Error)throw"QuotaExceededError"===t.name&&await async function(){for(const t of U)await t()}(),t}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:a,oldResponse:f,newResponse:c.clone(),request:i,event:this.event});return!0}async getCacheKey(t,e){if(!this.u[e]){let s=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))s=b(await t({mode:e,request:s,event:this.event,params:this.params}));this.u[e]=s}return this.u[e]}hasCallback(t){for(const e of this.l.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.l.plugins)if("function"==typeof e[t]){const s=this.m.get(e),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return e[t](r)};yield n}}waitUntil(t){return this.g.push(t),t}async doneWaiting(){let t;for(;t=this.g.shift();)await t}destroy(){this.p.resolve(null)}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class E extends class{constructor(t={}){this.cacheName=w(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,n="params"in t?t.params:void 0,r=new L(this,{event:e,request:s,params:n}),i=this.q(r,s,e);return[i,this.U(i,r,s,e)]}async q(t,e,n){let r;await t.runCallbacks("handlerWillStart",{event:n,request:e});try{if(r=await this.L(e,t),!r||"error"===r.type)throw new s("no-response",{url:e.url})}catch(s){if(s instanceof Error)for(const i of t.iterateCallbacks("handlerDidError"))if(r=await i({error:s,event:n,request:e}),r)break;if(!r)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))r=await s({event:n,request:e,response:r});return r}async U(t,e,s,n){let r,i;try{r=await t}catch(i){}try{await e.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await e.doneWaiting()}catch(t){t instanceof Error&&(i=t)}if(await e.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:i}),e.destroy(),i)throw i}}{constructor(t={}){t.cacheName=f(t.cacheName),super(t),this._=!1!==t.fallbackToNetwork,this.plugins.push(E.copyRedirectedCacheableResponsesPlugin)}async L(t,e){const s=await e.cacheMatch(t);return s||(e.event&&"install"===e.event.type?await this.C(t,e):await this.O(t,e))}async O(t,e){let n;if(!this._)throw new s("missing-precache-entry",{cacheName:this.cacheName,url:t.url});return n=await e.fetch(t),n}async C(t,e){this.N();const n=await e.fetch(t);if(!await e.cachePut(t,n.clone()))throw new s("bad-precaching-response",{url:t.url,status:n.status});return n}N(){let t=null,e=0;for(const[s,n]of this.plugins.entries())n!==E.copyRedirectedCacheableResponsesPlugin&&(n===E.defaultPrecacheCacheabilityPlugin&&(t=s),n.cacheWillUpdate&&e++);0===e?this.plugins.push(E.defaultPrecacheCacheabilityPlugin):e>1&&null!==t&&this.plugins.splice(t,1)}}E.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:t})=>!t||t.status>=400?null:t},E.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:t})=>t.redirected?await m(t):t};class x{constructor({cacheName:t,plugins:e=[],fallbackToNetwork:s=!0}={}){this.k=new Map,this.j=new Map,this.T=new Map,this.l=new E({cacheName:f(t),plugins:[...e,new g({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this.l}precache(t){this.addToCacheList(t),this.W||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this.W=!0)}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:r}=p(n),i="string"!=typeof n&&n.revision?"reload":"default";if(this.k.has(r)&&this.k.get(r)!==t)throw new s("add-to-cache-list-conflicting-entries",{firstEntry:this.k.get(r),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.T.has(t)&&this.T.get(t)!==n.integrity)throw new s("add-to-cache-list-conflicting-integrities",{url:r});this.T.set(t,n.integrity)}if(this.k.set(r,t),this.j.set(r,i),e.length>0){const t=`Workbox is precaching URLs without revision info: ${e.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(t)}}}install(t){return d(t,(async()=>{const e=new y;this.strategy.plugins.push(e);for(const[e,s]of this.k){const n=this.T.get(s),r=this.j.get(e),i=new Request(e,{integrity:n,cache:r,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:s},request:i,event:t}))}const{updatedURLs:s,notUpdatedURLs:n}=e;return{updatedURLs:s,notUpdatedURLs:n}}))}activate(t){return d(t,(async()=>{const t=await self.caches.open(this.strategy.cacheName),e=await t.keys(),s=new Set(this.k.values()),n=[];for(const r of e)s.has(r.url)||(await t.delete(r),n.push(r.url));return{deletedURLs:n}}))}getURLsToCacheKeys(){return this.k}getCachedURLs(){return[...this.k.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.k.get(e.href)}async matchPrecache(t){const e=t instanceof Request?t.url:t,s=this.getCacheKeyForURL(e);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(t){const e=this.getCacheKeyForURL(t);if(!e)throw new s("non-precached-url",{url:t});return s=>(s.request=new Request(t),s.params=Object.assign({cacheKey:e},s.params),this.strategy.handle(s))}}let C;const O=()=>(C||(C=new x),C);class N extends r{constructor(t,e){super((({request:s})=>{const n=t.getURLsToCacheKeys();for(const t of function*(t,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const i=new URL(t,location.href);i.hash="",yield i.href;const o=function(t,e=[]){for(const s of[...t.searchParams.keys()])e.some((t=>t.test(s)))&&t.searchParams.delete(s);return t}(i,e);if(yield o.href,s&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=s,yield t.href}if(n){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(r){const t=r({url:i});for(const e of t)yield e.href}}(s.url,e)){const e=n.get(t);if(e)return{cacheKey:e}}}),t.strategy)}}t.NavigationRoute=class extends r{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super((t=>this.K(t)),t),this.M=e,this.P=s}K({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.P)if(t.test(s))return!1;return!!this.M.some((t=>t.test(s)))}},t.clientsClaim=function(){self.addEventListener("activate",(()=>self.clients.claim()))},t.createHandlerBoundToURL=function(t){return O().createHandlerBoundToURL(t)},t.precacheAndRoute=function(t,e){!function(t){O().precache(t)}(t),function(t){const e=O();h(new N(e,t))}(e)},t.registerRoute=h}));
|
|
Binary file
|