1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const is_color_1 = __importDefault(require("is-color"));
|
7 | const Errors_1 = require("./Errors");
|
8 | const Presets_1 = __importDefault(require("./validators/Presets"));
|
9 | function isObject(item) {
|
10 | return typeof item === 'object' && !Array.isArray(item) && item !== null;
|
11 | }
|
12 | function createPWAManifestFromExpoConfig(appJson) {
|
13 | if (!isObject(appJson)) {
|
14 | throw new Error('app.json must be an object');
|
15 | }
|
16 | const { web = {} } = appJson.expo || appJson || {};
|
17 | return {
|
18 |
|
19 | background_color: web.backgroundColor,
|
20 | description: web.description,
|
21 | dir: web.dir,
|
22 | display: web.display,
|
23 | lang: web.lang,
|
24 | name: web.name,
|
25 | orientation: web.orientation,
|
26 | prefer_related_applications: web.preferRelatedApplications,
|
27 | related_applications: web.relatedApplications,
|
28 | scope: web.scope,
|
29 | short_name: web.shortName,
|
30 | start_url: web.startUrl,
|
31 | theme_color: web.themeColor,
|
32 | crossorigin: web.crossorigin,
|
33 | startupImages: web.startupImages,
|
34 | icons: web.icons,
|
35 | };
|
36 | }
|
37 | exports.createPWAManifestFromExpoConfig = createPWAManifestFromExpoConfig;
|
38 | function validateManifest(manifest) {
|
39 | if (!manifest)
|
40 | return;
|
41 | Presets_1.default(manifest, 'dir', 'display', 'orientation', 'crossorigin');
|
42 | for (const property of ['background_color', 'theme_color']) {
|
43 |
|
44 | const color = manifest[property];
|
45 | if (color && !is_color_1.default(color)) {
|
46 | throw new Errors_1.PresetError(property, color);
|
47 | }
|
48 | }
|
49 | }
|
50 | exports.validateManifest = validateManifest;
|
51 |
|
\ | No newline at end of file |