smartmanifest/readme.md
2024-04-14 17:56:20 +02:00

119 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# @push.rocks/smartmanifest
a module for creating web app manifests
## Install
To start using `@push.rocks/smartmanifest`, first, you need to install it through npm or yarn. Heres how you can do it using npm:
```sh
npm install @push.rocks/smartmanifest --save
```
Or, if you are using yarn, you can do:
```sh
yarn add @push.rocks/smartmanifest
```
This will add `@push.rocks/smartmanifest` to your project dependencies and you're ready to start using it to generate web app manifests with ease.
## Usage
The `@push.rocks/smartmanifest` module simplifies the creation of web app manifests, providing a straightforward TypeScript interface to construct and output manifest files, which are essential for modern web applications. Heres how to get started:
### Basic Example
Create an instance of `SmartManifest` by importing the module and configuring it with essential manifest properties:
```typescript
// Import the module
import { SmartManifest, ISmartManifestConstructorOptions } from '@push.rocks/smartmanifest';
// Define manifest options
const manifestOptions: ISmartManifestConstructorOptions = {
name: 'Your App Name',
short_name: 'AppName',
start_url: '/',
display: 'standalone',
theme_color: '#000000',
background_color: '#ffffff',
icons: [
{
src: 'icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png'
}
]
};
// Create SmartManifest instance
const yourAppManifest = new SmartManifest(manifestOptions);
// Output the manifest as a JSON string
console.log(yourAppManifest.jsonString());
```
This example shows the creation of a simple web app manifest using `@push.rocks/smartmanifest`. Essential attributes such as `name`, `short_name`, `start_url`, `display`, `theme_color`, `background_color`, and `icons` are specified in the `ISmartManifestConstructorOptions`.
### Advanced Configuration
The module also allows for more advanced configuration of the manifest, supporting fields for orientation, related applications, and even custom extensions. For example, setting the manifest to encourage the application to be shown in a fullscreen mode with a specific orientation or setting related applications for app stores:
```typescript
import { SmartManifest, ISmartManifestConstructorOptions } from '@push.rocks/smartmanifest';
const advancedManifestOptions: ISmartManifestConstructorOptions = {
name: 'Advanced App',
short_name: 'AdvApp',
display: 'fullscreen',
orientation: 'landscape',
related_applications: [
{
platform: 'play',
id: 'com.example.app'
}
],
// Further customization here
};
const advancedAppManifest = new SmartManifest(advancedManifestOptions);
console.log(advancedAppManifest.jsonString());
```
### Working with Icons
The icons field in the manifest is particularly important for ensuring your application has a compelling presence on the user's home screen and within task switchers across various platforms. `@push.rocks/smartmanifest` allows you to specify multiple icons, different dimensions, and purposes (for example, any, maskable, or monochrome).
### Using the Output
Once you have generated the JSON string representation of your web app's manifest, you can write this to a `manifest.json` file at the root of your web project or serve it dynamically via a web server. Ensuring the manifest is correctly linked within your application's `<head>` section with `<link rel="manifest" href="/manifest.json">` is crucial for the web app to be recognized as such by browsers and platforms.
### Conclusion
By leveraging `@push.rocks/smartmanifest`, developers can streamline the generation of web app manifests, ensuring their applications meet the criteria for progressive web apps (PWAs) and providing a superior user experience across devices and platforms. The use of TypeScript for configuration encapsulates the complexity of manifest generation, making the process more intuitive and error-free.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.