1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function getAndroidAssetSuffix(scale) {
|
21 | switch (scale) {
|
22 | case 0.75:
|
23 | return 'ldpi';
|
24 |
|
25 | case 1:
|
26 | return 'mdpi';
|
27 |
|
28 | case 1.5:
|
29 | return 'hdpi';
|
30 |
|
31 | case 2:
|
32 | return 'xhdpi';
|
33 |
|
34 | case 3:
|
35 | return 'xxhdpi';
|
36 |
|
37 | case 4:
|
38 | return 'xxxhdpi';
|
39 |
|
40 | default:
|
41 | throw new Error('no such scale');
|
42 | }
|
43 | }
|
44 |
|
45 |
|
46 | const drawableFileTypes = new Set(['gif', 'jpeg', 'jpg', 'png', 'svg', 'webp', 'xml']);
|
47 |
|
48 | function getAndroidResourceFolderName(asset, scale) {
|
49 | if (!drawableFileTypes.has(asset.type)) {
|
50 | return 'raw';
|
51 | }
|
52 |
|
53 | const suffix = getAndroidAssetSuffix(scale);
|
54 |
|
55 | if (!suffix) {
|
56 | throw new Error(`Don't know which android drawable suffix to use for asset: ${JSON.stringify(asset)}`);
|
57 | }
|
58 |
|
59 | const androidFolder = `drawable-${suffix}`;
|
60 | return androidFolder;
|
61 | }
|
62 |
|
63 | function getAndroidResourceIdentifier(asset) {
|
64 | const folderPath = getBasePath(asset);
|
65 | return `${folderPath}/${asset.name}`.toLowerCase().replace(/\//g, '_')
|
66 | .replace(/([^a-z0-9_])/g, '')
|
67 | .replace(/^assets_/, '');
|
68 | }
|
69 |
|
70 | function getBasePath(asset) {
|
71 | let basePath = asset.httpServerLocation;
|
72 |
|
73 | if (basePath[0] === '/') {
|
74 | basePath = basePath.substr(1);
|
75 | }
|
76 |
|
77 | return basePath;
|
78 | }
|
79 |
|
80 | var _default = {
|
81 | getAndroidAssetSuffix,
|
82 | getAndroidResourceFolderName,
|
83 | getAndroidResourceIdentifier,
|
84 | getBasePath
|
85 | };
|
86 | exports.default = _default; |
\ | No newline at end of file |