![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@gasket/plugin-manifest
Advanced tools
Adds support for a custom manifest.json
to be provided for your application.
This allows your application to take full advantage of being a Progressive Web
Application. This is useful for progressive web applications, and works best
when paired with @gasket/plugin-workbox
and @gasket/plugin-service-worker
.
npm i @gasket/plugin-manifest
Update your gasket
file plugin configuration:
// gasket.js
+ import pluginManifest from '@gasket/plugin-manifest';
export default makeGasket({
plugins: [
+ pluginManifest
]
});
By default, this plugin will serve {}
as your manifest.json
. Consumers of
this plugin have 2 options in augmenting this object. The first is through
gasket.js
:
// gasket.js
export default makeGasket({
manifest: {
short_name: 'PWAwesome',
name: 'Progressive Web Application'
}
});
If you want to serve manifest.json
from a custom path, the plugin can be
configured as follows.
// gasket.js
export default makeGasket({
manifest: {
// other options
path: '/custom/path/manifest.json' // default: /manifest.json
}
});
If you want to generate a manifest.json
file at build time for use with a static app, the plugin can be configured with the staticOutput
option:
// gasket.js
export default makeGasket({
manifest: {
// other options
staticOutput: '/custom/path/manifest.json'
}
});
You will also need to include a link to your manifest.json
file on your static html pages:
<link src="/manifest.json" rel="manifest">
Users also have the option to pass in a boolean value of true
, which defaults the path to public/manifest.json
.
Another option to adjust the manifest is through a lifecycle hook. This
lifecycle method is executed every time an incoming http request is made that
matches either manifest.json
or the service worker script (which is sw.js
by
default).
// sample-plugin.js
/**
* Generate a manifest.json that will be deeply merged into the existing ones.
* In this example, we check if the requesting IP address is valid using an
* arbitrary function.
*
* @param {Gasket} gasket The Gasket API
* @param {Object} manifest Waterfall manifest to adjust
* @param {Request} req Incoming HTTP Request
* @return {Promise<Object>} updated manifest
*/
export default {
name: 'sample-plugin',
hooks: {
manifest: async function (gasket, manifest, { req }) {
const whitelisted = await checkAgainstRemoteWhitelist(req.ip);
return {
...manifest,
orientation: gasket.config.orientation,
theme_color: (req.secure && whitelisted) ? '#00ff00' : '#ff0000'
};
}
}
It is important to note that conflicting objects from gasket.js
and a
manifest
hook will be resolved by using the data from the hook.
Once the manifest.json
has been resolved, it is suggested that consumers of
this plugin take advantage of the workbox
hook. For example: here we cache any
icons that the application might use at runtime:
// sample-plugin.js
/**
* Returns a config partial which will be merged
* @param {Gasket} gasket The gasket API
* @param {Object} config workbox config
* @param {Request} req incoming HTTP request
* @returns {Object} config which will be deeply merged
*/
export default {
name: 'sample-plugin',
hooks: {
workbox: function (gasket, config, req) {
const { icons = [] } = req.manifest;
return {
runtimeCaching: icons.map(icon => ({
urlPattern: icon.src,
handler: 'staleWhileRevalidate'
}))
};
};
}
FAQs
The web app manifest for progressive Gasket applications
The npm package @gasket/plugin-manifest receives a total of 53 weekly downloads. As such, @gasket/plugin-manifest popularity was classified as not popular.
We found that @gasket/plugin-manifest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.