Class PWAServiceWorker
java.lang.Object
com.iizix.pwa.PWAServiceWorker
The generated Service Worker of one application,
/app/<appID>/sw.js (work order CC-PWA-V5C-APP-WORKER; design CC-DESIGN-APP-URL-V2 section 2.5, PWA-DESIGN section 4.1): two lines of text, no file. The first defines self.IIZI_SW, the object the shared worker /iiziSW.js reads to know which application it serves - the application ID, the scope /app/<appID>/, the stamp v of the application's directory, the server's version and build, and the application's language codes; the second imports /iiziSW.js, so that the Push protocol stays in one file, shared by the root worker and every application worker. The Browser installs a new worker exactly when these bytes change: the stamp changes when the directory does, the build when the server does.In development mode a devel member is added, and the worker's fetch handler then passes everything through: a cache must never hide a hot deploy from the developer.
Pure text over its arguments: the wiring - the route, the stamp, the languages - is the application directory's (order V5-E).
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the worker in the application's directory.static final StringThe shared worker the generated one imports, at the web root.static final StringThe prefix of every application directory: the one constant the route, the manifest and the worker share (decision V5B-D-9).Method Summary
Field Details
FILE_NAME
IMPORT
The shared worker the generated one imports, at the web root.- See Also:
PREFIX
The prefix of every application directory: the one constant the route, the manifest and the worker share (decision V5B-D-9).- See Also:
Method Details
scope
Gets the scope of an application's worker: its directory,/app/<appID>/.- Parameters:
appID- The application ID, valid.- Returns:
- The scope path, ending in a slash.
- Throws:
IllegalArgumentException- If the application ID is not a valid one.
script
public static String script(String appID, String stamp, String build, Collection<String> languages, boolean devel) Generates the text of/app/<appID>/sw.js.self.IIZI_SW={appId:'icu',scope:'/app/icu/',v:'0123456789abcdef',build:'1.0.0.20351',langs:['en','fr']}; importScripts('/iiziSW.js');- Parameters:
appID- The canonical application ID.stamp- The stampvof the application's directory, never null.build- The server's version and build,SystemConfig.VERSION_BUILD.languages- The language codes of the application, in the order the directory has them; null or empty for an application with a single, default language.devel- The development mode flag,SystemConfig.isDevelopmentMode.- Returns:
- The script text, two lines ending in a newline.
- Throws:
IllegalArgumentException- If the application ID is not a valid one, or the stamp or build is null.