{"version":3,"sources":["webpack:////Users/wangyi/Desktop/opensource/rcpress/node_modules/register-service-worker/index.js","webpack:///../@rcpress/core/lib/web/index.js","webpack:///../@rcpress/core/lib/web/serviceWorker/SWUpdateEvent.js","webpack:///../@rcpress/core/lib/web/serviceWorker/index.js","webpack:///../@rcpress/core/lib/web/shared/noop.js","webpack:///./docs/.rcpress/components/ImgWidthBase.jsx"],"names":["SWUpdateEvent","registration","Object","defineProperty","value","configurable","writable","update","worker","waiting","Promise","resolve","console","log","reject","channel","MessageChannel","port1","onmessage","event","data","error","postMessage","type","port2","swUpdateObject","ready","noop","cached","updated","offline","useSWHook","dispatch","args","payload","useSWRegistry","state","useEffect","process","resolvePathWithBase","filePath","base","replace","url","width","height","rest","ctx","siteData"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;AAEA;AACA;AACA;AACA;;AAEA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA,0DAA0D,EAAE;AAC5D;AACA,EAAE;;AAEK;AACP;;AAEA,sDAAsD;AACtD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;;AAEO;AACP;AACA;AACA;AACA,KAAK;AACL;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrHA;AACA;AACA;;;;;;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AAb,IAAqB,GAA3B,CAF1B;AAGE,WAAK,EAAEG,KAHT;AAIE,YAAM,EAAEC;AAJV,OADF;AAQD,GAVH,CADa;AAAA,C;;AAAA;;;;;;;;;;0BAJTN,mB","file":"guide/README.md~zh/guide/README.md.server-bundle.js","sourcesContent":["// Register a service worker to serve assets from local cache.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on the \"N+1\" visit to a page, since previously\n// cached resources are updated in the background.\n\nvar isLocalhost = function () { return Boolean(\n  window.location.hostname === 'localhost' ||\n    // [::1] is the IPv6 localhost address.\n    window.location.hostname === '[::1]' ||\n    // 127.0.0.1/8 is considered localhost for IPv4.\n    window.location.hostname.match(\n      /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n    )\n); }\n\nexport function register (swUrl, hooks) {\n  if ( hooks === void 0 ) hooks = {};\n\n  var registrationOptions = hooks.registrationOptions; if ( registrationOptions === void 0 ) registrationOptions = {};\n  delete hooks.registrationOptions\n\n  var emit = function (hook) {\n    var args = [], len = arguments.length - 1;\n    while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];\n\n    if (hooks && hooks[hook]) {\n      hooks[hook].apply(hooks, args)\n    }\n  }\n\n  if ('serviceWorker' in navigator) {\n    window.addEventListener('load', function () {\n      if (isLocalhost()) {\n        // This is running on localhost. Lets check if a service worker still exists or not.\n        checkValidServiceWorker(swUrl, emit, registrationOptions)\n        navigator.serviceWorker.ready.then(function (registration) {\n          emit('ready', registration)\n        })\n      } else {\n        // Is not local host. Just register service worker\n        registerValidSW(swUrl, emit, registrationOptions)\n      }\n    })\n  }\n}\n\nfunction registerValidSW (swUrl, emit, registrationOptions) {\n  navigator.serviceWorker\n    .register(swUrl, registrationOptions)\n    .then(function (registration) {\n      emit('registered', registration)\n      if (registration.waiting) {\n        emit('updated', registration)\n        return\n      }\n      registration.onupdatefound = function () {\n        emit('updatefound', registration)\n        var installingWorker = registration.installing\n        installingWorker.onstatechange = function () {\n          if (installingWorker.state === 'installed') {\n            if (navigator.serviceWorker.controller) {\n              // At this point, the old content will have been purged and\n              // the fresh content will have been added to the cache.\n              // It's the perfect time to display a \"New content is\n              // available; please refresh.\" message in your web app.\n              emit('updated', registration)\n            } else {\n              // At this point, everything has been precached.\n              // It's the perfect time to display a\n              // \"Content is cached for offline use.\" message.\n              emit('cached', registration)\n            }\n          }\n        }\n      }\n    })\n    .catch(function (error) {\n      emit('error', error)\n    })\n}\n\nfunction checkValidServiceWorker (swUrl, emit, registrationOptions) {\n  // Check if the service worker can be found.\n  fetch(swUrl)\n    .then(function (response) {\n      // Ensure service worker exists, and that we really are getting a JS file.\n      if (response.status === 404) {\n        // No service worker found.\n        emit('error', new Error((\"Service worker not found at \" + swUrl)))\n        unregister()\n      } else if (response.headers.get('content-type').indexOf('javascript') === -1) {\n        emit('error', new Error(\n          \"Expected \" + swUrl + \" to have javascript content-type, \" +\n          \"but received \" + (response.headers.get('content-type'))))\n        unregister()\n      } else {\n        // Service worker found. Proceed as normal.\n        registerValidSW(swUrl, emit, registrationOptions)\n      }\n    })\n    .catch(function (error) {\n      if (!navigator.onLine) {\n        emit('offline')\n      } else {\n        emit('error', error)\n      }\n    })\n}\n\nexport function unregister () {\n  if ('serviceWorker' in navigator) {\n    navigator.serviceWorker.ready.then(function (registration) {\n      registration.unregister()\n    })\n  }\n}\n","export { useSWRegistry } from './serviceWorker';\nexport { useSWHook } from './serviceWorker';\nexport { default as useSiteContext } from './context';\nexport { SiteContext } from './context';\n","export default class SWUpdateEvent {\n  constructor(registration) {\n    Object.defineProperty(this, 'registration', {\n      value: registration,\n      configurable: true,\n      writable: true\n    });\n  }\n\n  /**\n   * Check if the new service worker exists or not.\n   */\n  update() {\n    return this.registration.update();\n  }\n\n  /**\n   * Activate new service worker to work 'location.reload()' with new data.\n   */\n  skipWaiting() {\n    const worker = this.registration.waiting;\n    if (!worker) {\n      return Promise.resolve();\n    }\n\n    console.log('[rcpress:sw] Doing worker.skipWaiting().');\n    return new Promise((resolve, reject) => {\n      const channel = new MessageChannel();\n\n      channel.port1.onmessage = event => {\n        console.log('[rcpress:sw] Done worker.skipWaiting().');\n        if (event.data.error) {\n          reject(event.data.error);\n        } else {\n          resolve(event.data);\n        }\n      };\n\n      worker.postMessage({ type: 'skip-waiting' }, [channel.port2]);\n    });\n  }\n}\n","import { useEffect } from 'react';\nimport { noop } from '../shared/noop';\nimport SWUpdateEvent from './SWUpdateEvent';\nimport { register } from 'register-service-worker';\n\nlet swUpdateObject = {\n  ready: noop,\n  cached: noop,\n  updated: noop,\n  offline: noop,\n  error: noop\n};\n\nexport const useSWHook = () => {\n  const dispatch = args => {\n    swUpdateObject[args.type] = args.payload;\n  };\n\n  return [swUpdateObject, dispatch];\n};\n\nexport const useSWRegistry = () => {\n  const state = swUpdateObject;\n  useEffect(() => {\n    // Register service worker\n    if (\n      process.env.NODE_ENV === 'production' &&\n      SW_ENABLED &&\n      window.location.protocol === 'https:'\n    ) {\n      register(`${BASE_URL}/service-worker.js`, {\n        ready() {\n          console.log('[rcpress:sw] Service worker is active.');\n          state.ready();\n        },\n        cached(registration) {\n          console.log('[rcpress:sw] Content has been cached for offline use.');\n          state.cached(new SWUpdateEvent(registration));\n        },\n        updated(registration) {\n          console.log('[rcpress:sw] Content updated.');\n          state.updated(new SWUpdateEvent(registration));\n        },\n        offline() {\n          console.log('[rcpress:sw] No internet connection found. App is running in offline mode.');\n          state.offline();\n        },\n        error(err) {\n          console.error('[rcpress:sw] Error during service worker registration:', err);\n          state.error(err);\n        }\n      });\n    }\n  }, []);\n};\n","export default {};\nexport const noop = () => {};\n","import React from 'react';\nimport { SiteContext } from '@rcpress/core';\n\nconst resolvePathWithBase = (filePath, base) => {\n  return (base + '/' + filePath).replace(/\\/\\//g, '/');\n};\n\nexport default ({ url, width, height, ...rest }) => (\n  <SiteContext.Consumer>\n    {ctx => {\n      return (\n        <img\n          {...rest}\n          src={resolvePathWithBase(url, ctx.siteData.base || '/')}\n          width={width}\n          height={height}\n        />\n      );\n    }}\n  </SiteContext.Consumer>\n);\n"],"sourceRoot":""}