smartmanifest/ts/index.ts

78 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

2023-06-11 20:16:28 +00:00
import * as plugins from './smartmanifest.plugins.js';
2019-05-27 11:13:41 +00:00
2019-05-27 11:35:07 +00:00
export interface ISmartManifestConstructorOptions {
name: string;
short_name: string;
start_url?: '/';
2023-06-11 20:16:28 +00:00
display?: 'standalone';
orientation?: 'any';
2019-05-27 11:35:07 +00:00
background_color?: string;
theme_color?: string;
2020-01-30 11:50:35 +00:00
icons?: Array<{
src: string;
type: string;
sizes: string;
2023-06-11 22:42:30 +00:00
purpose?: 'any' | 'maskable' | 'monochrome';
2020-01-30 11:50:35 +00:00
}>;
related_applications?: Array<{
platform: 'play' | string;
id: string;
}>;
2023-06-11 20:25:12 +00:00
scope: string;
lang: string;
display_override: 'window-controls-overlay'[];
2019-05-27 11:35:07 +00:00
}
const defaultConstructorOptions: ISmartManifestConstructorOptions = {
name: 'UNNAMED APP',
short_name: 'UNNAMED',
start_url: '/',
display: 'standalone',
orientation: 'any',
2020-01-30 11:50:35 +00:00
background_color: '#000000',
theme_color: '#000000',
2019-05-27 11:35:07 +00:00
icons: [
{
2020-01-30 11:50:35 +00:00
src: '/assetbroker/manifest/icon-large.png',
2019-05-27 11:35:07 +00:00
type: 'image/png',
2023-06-11 20:16:28 +00:00
sizes: '1024x1024',
2023-06-11 22:42:30 +00:00
purpose: 'any',
2020-01-30 11:50:35 +00:00
},
{
src: '/assetbroker/manifest/icon-144x144.png',
sizes: '144x144',
2023-06-11 20:16:28 +00:00
type: 'image/png',
2020-01-30 11:50:35 +00:00
},
{
src: '/assetbroker/manifest/icon-512x512.png',
sizes: '512x512',
2023-06-11 20:16:28 +00:00
type: 'image/png',
},
2020-01-30 11:50:35 +00:00
],
2023-06-11 20:16:28 +00:00
related_applications: [],
2023-06-11 20:25:12 +00:00
scope: '/',
lang: 'en',
display_override: ['window-controls-overlay'],
2019-06-15 16:10:09 +00:00
};
2019-05-27 11:35:07 +00:00
export class SmartManifest {
public options: ISmartManifestConstructorOptions;
constructor(optionsArg: ISmartManifestConstructorOptions) {
this.options = {
...defaultConstructorOptions,
2023-06-11 20:16:28 +00:00
...optionsArg,
2019-05-27 11:35:07 +00:00
};
}
public jsonString(): string {
return JSON.stringify(this.options);
}
/**
* get the manifest data as javascriptObject
*/
public getData() {
return JSON.parse(JSON.stringify(this.options));
}
}