smartmanifest/ts/index.ts

57 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-05-27 11:13:41 +00:00
import * as plugins from './smartmanifest.plugins';
2019-05-27 11:35:07 +00:00
export interface ISmartManifestConstructorOptions {
name: string;
short_name: string;
start_url?: '/';
display?: string;
orientation?: string;
background_color?: string;
theme_color?: string;
icons?: [
{
src: string;
type: string;
sizes: string;
}
];
}
const defaultConstructorOptions: ISmartManifestConstructorOptions = {
name: 'UNNAMED APP',
short_name: 'UNNAMED',
start_url: '/',
display: 'standalone',
orientation: 'any',
background_color: '#fff',
theme_color: '#f78f21',
icons: [
{
src: '/assets/icon-large.png',
type: 'image/png',
2019-06-15 16:10:09 +00:00
sizes: '1024x1024'
2019-05-27 11:35:07 +00:00
}
]
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,
...optionsArg
};
}
public jsonString(): string {
return JSON.stringify(this.options);
}
/**
* get the manifest data as javascriptObject
*/
public getData() {
return JSON.parse(JSON.stringify(this.options));
}
}