@webspatial/builder 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,37 @@
1
- 'use strict';const _0xaaff49=_0x9632;function _0x4051(){const _0x288280=['3288324uTrqEW','svg2img','bitmap','defineProperty','3429920MOrZnj','getWidth','__esModule','1745160HhfACE','createImg','jimp','ImageHelper','getHeight','isFullyOpaque','webp2PngBuffer','data','1861644LRGmiC','@resvg/resvg-js','sharp','width','toFormat','42166MsQreG','2360721GBGgCl','asPng','14XlsdeU','2uCgwNY','Resvg','png','16286490ULZqVu'];_0x4051=function(){return _0x288280;};return _0x4051();}(function(_0xa1c1fb,_0x28d130){const _0x494928=_0x9632,_0x4f808e=_0xa1c1fb();while(!![]){try{const _0x16e2d5=parseInt(_0x494928(0x184))/0x1+-parseInt(_0x494928(0x16c))/0x2*(parseInt(_0x494928(0x185))/0x3)+parseInt(_0x494928(0x170))/0x4+-parseInt(_0x494928(0x174))/0x5+-parseInt(_0x494928(0x17f))/0x6+-parseInt(_0x494928(0x187))/0x7*(parseInt(_0x494928(0x177))/0x8)+parseInt(_0x494928(0x16f))/0x9;if(_0x16e2d5===_0x28d130)break;else _0x4f808e['push'](_0x4f808e['shift']());}catch(_0x3ef674){_0x4f808e['push'](_0x4f808e['shift']());}}}(_0x4051,0x6ef02));function _0x9632(_0x1d103f,_0x422567){const _0x40512d=_0x4051();return _0x9632=function(_0x96325f,_0x53d8ad){_0x96325f=_0x96325f-0x16c;let _0x4ace38=_0x40512d[_0x96325f];return _0x4ace38;},_0x9632(_0x1d103f,_0x422567);}Object[_0xaaff49(0x173)](exports,_0xaaff49(0x176),{'value':!![]}),exports['ImageHelper']=void 0x0;const Jimp=require(_0xaaff49(0x179)),sharp=require(_0xaaff49(0x181)),resvg_js_1=require(_0xaaff49(0x180));class ImageHelper{static[_0xaaff49(0x178)](_0x49b7bd){return new Jimp(_0x49b7bd,_0x49b7bd,0x0);}static async[_0xaaff49(0x17d)](_0x4fecba){const _0x5e7190=_0xaaff49;return await sharp(_0x4fecba)[_0x5e7190(0x183)](_0x5e7190(0x16e))['toBuffer']();}static async[_0xaaff49(0x171)](_0x42b25a){const _0x46c661=_0xaaff49,_0x2f5f9f={'fitTo':{'mode':_0x46c661(0x182),'value':0x400}},_0x2e05e9=new resvg_js_1[(_0x46c661(0x16d))](_0x42b25a,_0x2f5f9f),_0x3cce55=_0x2e05e9['render'](),_0x596c2e=_0x3cce55[_0x46c661(0x186)]();return _0x596c2e;}static[_0xaaff49(0x17c)](_0x19b990){const _0x1cb519=_0xaaff49,_0x4f2380=_0x19b990[_0x1cb519(0x175)]()*_0x19b990[_0x1cb519(0x17b)]();for(var _0x1b2543=0x0;_0x1b2543<_0x4f2380;_0x1b2543++){const _0x16b233=_0x1b2543*0x4+0x3;if(_0x19b990[_0x1cb519(0x172)][_0x1cb519(0x17e)][_0x16b233]<0xff)return![];}return!![];}}exports[_0xaaff49(0x17a)]=ImageHelper;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageHelper = void 0;
4
+ const Jimp = require("jimp");
5
+ const sharp = require("sharp");
6
+ const resvg_js_1 = require("@resvg/resvg-js");
7
+ class ImageHelper {
8
+ static createImg(size) {
9
+ return new Jimp(size, size, 0x00000000);
10
+ }
11
+ static async webp2PngBuffer(buffer) {
12
+ return await sharp(buffer).toFormat('png').toBuffer();
13
+ }
14
+ static async svg2img(svg) {
15
+ const opt = {
16
+ fitTo: {
17
+ mode: 'width',
18
+ value: 1024, // Generate the SVG with 1024px width, for larger icons.
19
+ },
20
+ };
21
+ const resvg = new resvg_js_1.Resvg(svg, opt);
22
+ const pngData = resvg.render();
23
+ const pngBuffer = pngData.asPng();
24
+ return pngBuffer;
25
+ }
26
+ static isFullyOpaque(image) {
27
+ const pixelNum = image.getWidth() * image.getHeight();
28
+ for (var i = 0; i < pixelNum; i++) {
29
+ const idx = i * 4 + 3;
30
+ if (image.bitmap.data[idx] < 255) {
31
+ return false;
32
+ }
33
+ }
34
+ return true;
35
+ }
36
+ }
37
+ exports.ImageHelper = ImageHelper;
@@ -1 +1,102 @@
1
- 'use strict';const _0x4d263e=_0x54ab;function _0x54ab(_0x29cc91,_0x2bb464){const _0xe703f3=_0xe703();return _0x54ab=function(_0x54ab81,_0x5077df){_0x54ab81=_0x54ab81-0x98;let _0x5340e0=_0xe703f3[_0x54ab81];return _0x5340e0;},_0x54ab(_0x29cc91,_0x2bb464);}(function(_0x1884c5,_0xd4716d){const _0x3f49bd=_0x54ab,_0x2bcb0d=_0x1884c5();while(!![]){try{const _0x49315c=-parseInt(_0x3f49bd(0xb9))/0x1*(parseInt(_0x3f49bd(0x9c))/0x2)+parseInt(_0x3f49bd(0xae))/0x3*(parseInt(_0x3f49bd(0xad))/0x4)+parseInt(_0x3f49bd(0xa0))/0x5+-parseInt(_0x3f49bd(0xc9))/0x6*(parseInt(_0x3f49bd(0xaf))/0x7)+parseInt(_0x3f49bd(0xa2))/0x8*(parseInt(_0x3f49bd(0xba))/0x9)+-parseInt(_0x3f49bd(0xaa))/0xa+parseInt(_0x3f49bd(0xc4))/0xb;if(_0x49315c===_0xd4716d)break;else _0x2bcb0d['push'](_0x2bcb0d['shift']());}catch(_0x19b824){_0x2bcb0d['push'](_0x2bcb0d['shift']());}}}(_0xe703,0x79b04));Object[_0x4d263e(0xbb)](exports,_0x4d263e(0xc2),{'value':!![]}),exports[_0x4d263e(0xa5)]=exports['MIDDLE_APPICON_DIRECTORY']=exports[_0x4d263e(0xc8)]=exports[_0x4d263e(0x9e)]=exports[_0x4d263e(0xb4)]=exports['PROJECT_TEST_DIRECTORY']=exports['PROJECT_EXPORT_DIRECTORY']=exports[_0x4d263e(0xca)]=exports[_0x4d263e(0xa6)]=void 0x0;const fs=require('fs'),path_1=require('path'),file_1=require(_0x4d263e(0xac)),load_1=require(_0x4d263e(0xa9)),child_process_1=require(_0x4d263e(0xb8));function _0xe703(){const _0x21d4b2=['resize','ASSET_DIRECTORY','checkPlatformPath','3646010aWlYJd','generateIcon','26776CaCJge','copyDir','json','ResourceManager','PROJECT_DIRECTORY','icons','/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset','./load','8719480RLrDfR','loadImageFromNet','./file','428MZViBA','8082gdhFXM','36071GxorMt','../../../','moveProjectFrom','web-spatial/Assets.xcassets',',\x20now\x20WebSpatial\x20only\x20support\x20','WEB_PROJECT_DIRECTORY','PROJECT_TEST_DIRECTORY','PROJECT_EXPORT_DIRECTORY','existsSync','child_process','97511gpLUtn','1377SPwrqd','defineProperty','loadImageFromDisk','not\x20support\x20platform\x20','cwd','includes','rm\x20-rf\x20','execSync','__esModule','web-spatial/static-web','15947382FjTZyf','join','mkdirSync','visionos','BACK_APPICON_DIRECTORY','738SQWYhT','PROJECT_BUILD_DIRECTORY','log','startsWith','\x20&&\x20pnpm\x20add\x20@webspatial/platform-','./build','cd\x20','node_modules/@webspatial/platform-','platform-','20iYjkDR'];_0xe703=function(){return _0x21d4b2;};return _0xe703();}exports['PROJECT_DIRECTORY']='',exports[_0x4d263e(0xca)]='',exports['PROJECT_EXPORT_DIRECTORY']='',exports[_0x4d263e(0xb5)]='',exports[_0x4d263e(0xb4)]=_0x4d263e(0xc3),exports[_0x4d263e(0x9e)]=_0x4d263e(0xb2),exports[_0x4d263e(0xc8)]=exports[_0x4d263e(0x9e)]+_0x4d263e(0xa8),exports['MIDDLE_APPICON_DIRECTORY']=exports[_0x4d263e(0x9e)]+'/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset';const supportPlatform=[_0x4d263e(0xc7)];class ResourceManager{static async[_0x4d263e(0xb1)](_0x4e3c16){const _0x25c98d=_0x4d263e,_0x1b3cc0=(0x0,path_1[_0x25c98d(0xc5)])(process[_0x25c98d(0xbe)](),_0x4e3c16),_0x2c2cab=(0x0,path_1[_0x25c98d(0xc5)])(exports[_0x25c98d(0xa6)],exports['WEB_PROJECT_DIRECTORY']);!fs[_0x25c98d(0xb7)](_0x2c2cab)?fs[_0x25c98d(0xc6)](_0x2c2cab,{'recursive':!![]}):(0x0,file_1['clearDir'])(_0x2c2cab);try{(0x0,file_1[_0x25c98d(0xa3)])(_0x1b3cc0,_0x2c2cab);}catch(_0x5b2739){console[_0x25c98d(0xcb)](_0x5b2739);}}static async[_0x4d263e(0xa1)](_0x134b36){const _0x130ec5=_0x4d263e,_0x1f17d1=_0x134b36[_0x130ec5(0xa4)],_0x3d12ff=_0x1f17d1[_0x130ec5(0xa7)][0x0]['src'],_0x3a95d1=!_0x3d12ff[_0x130ec5(0xcc)]('http')?await(0x0,load_1[_0x130ec5(0xbc)])(_0x3d12ff):await(0x0,load_1[_0x130ec5(0xab)])(_0x3d12ff);return _0x3a95d1[_0x130ec5(0x9d)](0x400,0x400),_0x3a95d1;}static[_0x4d263e(0x9f)](_0x283074){const _0x53afcb=_0x4d263e,_0x901326=_0x283074!==null&&_0x283074!==void 0x0?_0x283074:supportPlatform[0x0];if(!supportPlatform[_0x53afcb(0xbf)](_0x901326))throw new Error(_0x53afcb(0xbd)+_0x901326+_0x53afcb(0xb3)+supportPlatform['join'](','));let _0x3cb872=(0x0,path_1[_0x53afcb(0xc5)])(process['cwd'](),_0x53afcb(0x9a)+_0x901326);!fs['existsSync'](_0x3cb872)&&(_0x3cb872=(0x0,path_1[_0x53afcb(0xc5)])(__dirname,'../../../node_modules/@webspatial/platform-'+_0x901326));const _0x5071c8=fs[_0x53afcb(0xb7)](_0x3cb872);!_0x5071c8&&(0x0,child_process_1['execSync'])(_0x53afcb(0x99)+(0x0,path_1['join'])(__dirname,_0x53afcb(0xb0))+_0x53afcb(0xcd)+_0x901326);let _0x359211=(0x0,path_1[_0x53afcb(0xc5)])(__dirname,'../../temp'),_0x2bae05=(0x0,path_1['join'])(_0x359211,_0x53afcb(0x9b)+_0x901326);fs[_0x53afcb(0xb7)](_0x359211)&&(0x0,child_process_1[_0x53afcb(0xc1)])(_0x53afcb(0xc0)+_0x359211),fs[_0x53afcb(0xc6)](_0x359211),fs[_0x53afcb(0xc6)](_0x2bae05),(0x0,file_1['copyDir'])(_0x3cb872,_0x2bae05),exports['PROJECT_DIRECTORY']=_0x2bae05,exports[_0x53afcb(0xca)]=(0x0,path_1[_0x53afcb(0xc5)])(exports[_0x53afcb(0xa6)],_0x53afcb(0x98)),exports[_0x53afcb(0xb6)]=(0x0,path_1[_0x53afcb(0xc5)])(exports[_0x53afcb(0xa6)],'./export'),exports[_0x53afcb(0xb5)]=(0x0,path_1[_0x53afcb(0xc5)])(exports[_0x53afcb(0xca)],'./test');}}exports[_0x4d263e(0xa5)]=ResourceManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResourceManager = exports.MIDDLE_APPICON_DIRECTORY = exports.BACK_APPICON_DIRECTORY = exports.ASSET_DIRECTORY = exports.WEB_PROJECT_DIRECTORY = exports.PROJECT_TEST_DIRECTORY = exports.PROJECT_EXPORT_DIRECTORY = exports.PROJECT_BUILD_DIRECTORY = exports.PROJECT_DIRECTORY = void 0;
4
+ const fs = require("fs");
5
+ const path_1 = require("path");
6
+ const file_1 = require("./file");
7
+ const load_1 = require("./load");
8
+ const child_process_1 = require("child_process");
9
+ exports.PROJECT_DIRECTORY = '';
10
+ exports.PROJECT_BUILD_DIRECTORY = '';
11
+ exports.PROJECT_EXPORT_DIRECTORY = '';
12
+ exports.PROJECT_TEST_DIRECTORY = '';
13
+ exports.WEB_PROJECT_DIRECTORY = 'web-spatial/static-web';
14
+ exports.ASSET_DIRECTORY = 'web-spatial/Assets.xcassets';
15
+ exports.BACK_APPICON_DIRECTORY = exports.ASSET_DIRECTORY +
16
+ '/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset';
17
+ exports.MIDDLE_APPICON_DIRECTORY = exports.ASSET_DIRECTORY +
18
+ '/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset';
19
+ const supportPlatform = ['visionos'];
20
+ class ResourceManager {
21
+ static async moveProjectFrom(dir) {
22
+ // Copy the web project to the static-web directory under the xcode project
23
+ const fromDirectory = (0, path_1.join)(process.cwd(), dir);
24
+ const targetDirctory = (0, path_1.join)(exports.PROJECT_DIRECTORY, exports.WEB_PROJECT_DIRECTORY);
25
+ // Ensure `targetDirectory` exists.
26
+ if (!fs.existsSync(targetDirctory)) {
27
+ fs.mkdirSync(targetDirctory, { recursive: true });
28
+ }
29
+ else {
30
+ // If a directory already exists, clear it first
31
+ (0, file_1.clearDir)(targetDirctory);
32
+ }
33
+ try {
34
+ (0, file_1.copyDir)(fromDirectory, targetDirctory);
35
+ }
36
+ catch (err) {
37
+ console.log(err);
38
+ }
39
+ }
40
+ static async generateIcon(info) {
41
+ const manifestJson = info.json;
42
+ const imgUrl = manifestJson.icons[0].src;
43
+ const icon = !imgUrl.startsWith('http')
44
+ ? await (0, load_1.loadImageFromDisk)(imgUrl)
45
+ : await (0, load_1.loadImageFromNet)(imgUrl);
46
+ icon.resize(1024, 1024);
47
+ return icon;
48
+ }
49
+ /**
50
+ * @description Check and set the platform path to ensure the existence of the specified platform module.
51
+ * If the module does not exist, it will be installed automatically.
52
+ * Also set the project directory, build directory, and export directory.
53
+ * @param platform The name of the platform to check, defaulting to 'visionos'
54
+ */
55
+ static checkPlatformPath(platform) {
56
+ const usePlatform = platform !== null && platform !== void 0 ? platform : supportPlatform[0];
57
+ if (!supportPlatform.includes(usePlatform)) {
58
+ throw new Error(`not support platform ${usePlatform}, now WebSpatial only support ${supportPlatform.join(',')}`);
59
+ }
60
+ let modulePath = (0, path_1.join)(process.cwd(), `node_modules/@webspatial/platform-${usePlatform}`);
61
+ // If the module does not exist in the current working directory, try to get it from the cli directory
62
+ if (!fs.existsSync(modulePath)) {
63
+ modulePath = (0, path_1.join)(__dirname, `../../../node_modules/@webspatial/platform-${usePlatform}`);
64
+ }
65
+ const hasModule = fs.existsSync(modulePath);
66
+ // If the module does not exist, execute the npm installation command
67
+ if (!hasModule) {
68
+ (0, child_process_1.execSync)(`cd ${(0, path_1.join)(__dirname, '../../../')} && pnpm add @webspatial/platform-${usePlatform}`);
69
+ }
70
+ let tempDir = (0, path_1.join)(__dirname, `../../temp`);
71
+ let tempPlatformDir = (0, path_1.join)(tempDir, `platform-${usePlatform}`);
72
+ let tempProjectDir = (0, path_1.join)(tempPlatformDir, './project');
73
+ let temBuildDir = (0, path_1.join)(tempPlatformDir, './build');
74
+ let temExportDir = (0, path_1.join)(tempPlatformDir, './export');
75
+ let temTestDir = (0, path_1.join)(tempPlatformDir, './test');
76
+ if (!fs.existsSync(tempDir)) {
77
+ fs.mkdirSync(tempDir);
78
+ }
79
+ if (!fs.existsSync(tempPlatformDir)) {
80
+ fs.mkdirSync(tempPlatformDir);
81
+ }
82
+ if (fs.existsSync(tempProjectDir)) {
83
+ (0, child_process_1.execSync)(`rm -rf ${tempProjectDir}`);
84
+ }
85
+ if (!fs.existsSync(temBuildDir)) {
86
+ fs.mkdirSync(temBuildDir);
87
+ }
88
+ if (!fs.existsSync(temExportDir)) {
89
+ fs.mkdirSync(temExportDir);
90
+ }
91
+ if (!fs.existsSync(temTestDir)) {
92
+ fs.mkdirSync(temTestDir);
93
+ }
94
+ fs.mkdirSync(tempProjectDir);
95
+ (0, file_1.copyDir)(modulePath, tempProjectDir);
96
+ exports.PROJECT_DIRECTORY = tempProjectDir;
97
+ exports.PROJECT_BUILD_DIRECTORY = temBuildDir;
98
+ exports.PROJECT_EXPORT_DIRECTORY = temExportDir;
99
+ exports.PROJECT_TEST_DIRECTORY = temTestDir;
100
+ }
101
+ }
102
+ exports.ResourceManager = ResourceManager;
@@ -1 +1,121 @@
1
- 'use strict';const _0x412202=_0x2a20;(function(_0x1d5120,_0x242393){const _0x43d2c2=_0x2a20,_0x4450f5=_0x1d5120();while(!![]){try{const _0x350e05=-parseInt(_0x43d2c2(0x11e))/0x1+-parseInt(_0x43d2c2(0x122))/0x2+-parseInt(_0x43d2c2(0x131))/0x3*(-parseInt(_0x43d2c2(0x121))/0x4)+-parseInt(_0x43d2c2(0x130))/0x5+parseInt(_0x43d2c2(0x12b))/0x6*(-parseInt(_0x43d2c2(0x11f))/0x7)+parseInt(_0x43d2c2(0x128))/0x8+parseInt(_0x43d2c2(0x11b))/0x9;if(_0x350e05===_0x242393)break;else _0x4450f5['push'](_0x4450f5['shift']());}catch(_0x392f8e){_0x4450f5['push'](_0x4450f5['shift']());}}}(_0x595c,0xe8bb9));Object[_0x412202(0x12d)](exports,_0x412202(0x10f),{'value':!![]}),exports[_0x412202(0x125)]=loadJsonFromNet,exports[_0x412202(0x117)]=loadJsonFromDisk,exports[_0x412202(0x10a)]=loadImageFromNet,exports[_0x412202(0x124)]=loadImageFromDisk,exports[_0x412202(0x127)]=loadFileString;const fs=require('fs'),FetchUtils_1_1=require('../utils/FetchUtils-1'),CustomError_1=require('../utils/CustomError'),Jimp=require(_0x412202(0x123)),imageHelper_1=require(_0x412202(0x120));function _0x2a20(_0x52aa64,_0x381d2c){const _0x595ced=_0x595c();return _0x2a20=function(_0x2a2014,_0x4f51a7){_0x2a2014=_0x2a2014-0x10a;let _0x5ceec3=_0x595ced[_0x2a2014];return _0x5ceec3;},_0x2a20(_0x52aa64,_0x381d2c);}async function loadJsonFromNet(_0xe33a4){const _0x280977=_0x412202,_0x169b62=await FetchUtils_1_1['fetchUtils'][_0x280977(0x113)](_0xe33a4,{'encoding':_0x280977(0x132)});if(_0x169b62[_0x280977(0x111)]!==0xc8)throw new CustomError_1[(_0x280977(0x11a))]({'code':0xbbc,'message':'Failed\x20to\x20download\x20Web\x20Manifest\x20'+_0xe33a4+'.'+(_0x280977(0x10e)+_0x169b62[_0x280977(0x111)]+_0x280977(0x12a)),'message_staring_params':{'web_manifest_url':_0xe33a4,'status':_0x169b62['status']}});try{let _0xefdf8;return _0x169b62[_0x280977(0x114)]?_0xefdf8=await _0x169b62[_0x280977(0x114)]():[_0x280977(0x10d),'deflate','br'][_0x280977(0x118)](_0x169b62[_0x280977(0x11c)][_0x280977(0x10c)])?_0xefdf8=FetchUtils_1_1[_0x280977(0x13a)]['decompressResponseBuffer'](Buffer[_0x280977(0x137)](_0x169b62[_0x280977(0x135)],_0x280977(0x132)),_0x169b62[_0x280977(0x11c)][_0x280977(0x10c)])['toString']():_0xefdf8=Buffer[_0x280977(0x137)](_0x169b62['data'],'binary')['toString'](),JSON[_0x280977(0x134)](_0xefdf8[_0x280977(0x12f)]());}catch(_0x3a0641){throw new CustomError_1['CustomError']({'code':0xbbd,'message':_0x280977(0x12e),'message_staring_params':{}});}}async function loadJsonFromDisk(_0x5b4445){const _0x384d52=_0x412202,_0x18aac7=await loadFileString(_0x5b4445[_0x384d52(0x126)]());return JSON[_0x384d52(0x134)](_0x18aac7);}async function loadImageFromNet(_0x5915c7){const _0x34e16e=_0x412202,_0x5dcc2b=await FetchUtils_1_1[_0x34e16e(0x13a)][_0x34e16e(0x113)](_0x5915c7,{'encoding':_0x34e16e(0x132)});if(_0x5dcc2b[_0x34e16e(0x111)]!==0xc8)throw new CustomError_1[(_0x34e16e(0x11a))]({'code':0x7d2,'message':_0x34e16e(0x115)+_0x5dcc2b['status'],'message_staring_params':{'icon_url':_0x5915c7,'status':_0x5dcc2b[_0x34e16e(0x111)]}});const _0x3880f7=_0x5dcc2b[_0x34e16e(0x11c)]['get']?_0x5dcc2b[_0x34e16e(0x11c)][_0x34e16e(0x11d)](_0x34e16e(0x110)):_0x5dcc2b['headers']['content-type'];if(!(_0x3880f7===null||_0x3880f7===void 0x0?void 0x0:_0x3880f7[_0x34e16e(0x119)](_0x34e16e(0x139))))throw new CustomError_1[(_0x34e16e(0x11a))]({'code':0x7d3,'message':_0x34e16e(0x129)+(_0x34e16e(0x138)+_0x3880f7+'\x22'),'message_staring_params':{'icon_url':_0x5915c7,'contentType':_0x3880f7}});let _0x4ceeb1;_0x5dcc2b['arrayBuffer']?_0x4ceeb1=await _0x5dcc2b['arrayBuffer']():[_0x34e16e(0x10d),_0x34e16e(0x10b),'br'][_0x34e16e(0x118)](_0x5dcc2b[_0x34e16e(0x11c)][_0x34e16e(0x10c)])?_0x4ceeb1=FetchUtils_1_1[_0x34e16e(0x13a)][_0x34e16e(0x12c)](Buffer[_0x34e16e(0x137)](_0x5dcc2b[_0x34e16e(0x135)],_0x34e16e(0x132)),_0x5dcc2b[_0x34e16e(0x11c)][_0x34e16e(0x10c)]):_0x4ceeb1=Buffer[_0x34e16e(0x137)](_0x5dcc2b[_0x34e16e(0x135)],'binary');if(_0x3880f7[_0x34e16e(0x119)](_0x34e16e(0x133))){const _0x45ba99=new TextDecoder();try{_0x4ceeb1=await imageHelper_1[_0x34e16e(0x112)]['svg2img'](_0x45ba99['decode'](_0x4ceeb1));}catch(_0x2fa5b9){throw new CustomError_1['CustomError']({'code':0x7d4,'message':'Problem\x20reading\x20'+_0x5915c7+':\x20'+_0x2fa5b9,'message_staring_params':{'icon_url':_0x5915c7,'error':_0x2fa5b9}});}}return _0x3880f7[_0x34e16e(0x119)](_0x34e16e(0x116))&&(_0x4ceeb1=await imageHelper_1['ImageHelper']['webp2PngBuffer'](_0x4ceeb1)),await Jimp[_0x34e16e(0x136)](Buffer[_0x34e16e(0x137)](_0x4ceeb1));}function _0x595c(){const _0x4b29fc=['loadImageFromDisk','loadJsonFromNet','toString','loadFileString','1900624LlZzZN','Received\x20icon\x20with\x20invalid\x20Content-Type.',',\x20please\x20check\x20the\x20Web\x20Manifest\x20access\x20address','12XpDace','decompressResponseBuffer','defineProperty','Manifest\x20file\x20embedded\x20in\x20the\x20website\x20is\x20not\x20a\x20legal\x20JSON\x20file,\x20please\x20reconfigure','trim','1925080fdftlV','6rWZElU','binary','image/svg','parse','data','read','from','\x20Responded\x20with\x20Content-Type\x20\x22','image/','fetchUtils','loadImageFromNet','deflate','content-encoding','gzip','The\x20response\x20status\x20is\x20','__esModule','content-type','status','ImageHelper','fetch','text','Failed\x20to\x20download\x20icon.\x20Responded\x20with\x20status\x20','image/webp','loadJsonFromDisk','includes','startsWith','CustomError','30371058dOVEKD','headers','get','633421wflrlG','5036591zowQhe','./imageHelper','2272476RSfbmK','2675284KKVZUr','jimp'];_0x595c=function(){return _0x4b29fc;};return _0x595c();}async function loadImageFromDisk(_0x1362b5){const _0x15ef22=_0x412202;return await Jimp[_0x15ef22(0x136)](_0x1362b5);}async function loadFileString(_0x4c44cb){const _0x28d6ea=_0x412202;let _0x4e24d4=await fs['promises']['readFile'](_0x4c44cb['toString']());return _0x4e24d4[_0x28d6ea(0x126)]();}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadJsonFromNet = loadJsonFromNet;
4
+ exports.loadJsonFromDisk = loadJsonFromDisk;
5
+ exports.loadImageFromNet = loadImageFromNet;
6
+ exports.loadImageFromDisk = loadImageFromDisk;
7
+ exports.loadFileString = loadFileString;
8
+ const fs = require("fs");
9
+ const FetchUtils_1_1 = require("../utils/FetchUtils-1");
10
+ const CustomError_1 = require("../utils/CustomError");
11
+ const Jimp = require("jimp");
12
+ const imageHelper_1 = require("./imageHelper");
13
+ async function loadJsonFromNet(url) {
14
+ const response = await FetchUtils_1_1.fetchUtils.fetch(url, { encoding: 'binary' });
15
+ if (response.status !== 200) {
16
+ throw new CustomError_1.CustomError({
17
+ code: 3004,
18
+ message: `Failed to download Web Manifest ${url}.` +
19
+ `The response status is ${response.status}, please check the Web Manifest access address`,
20
+ // eslint-disable-next-line @typescript-eslint/camelcase
21
+ message_staring_params: {
22
+ web_manifest_url: url,
23
+ status: response.status,
24
+ },
25
+ });
26
+ }
27
+ try {
28
+ let body;
29
+ if (response.text) {
30
+ body = await response.text();
31
+ }
32
+ else {
33
+ if (['gzip', 'deflate', 'br'].includes(response.headers['content-encoding'])) {
34
+ body = FetchUtils_1_1.fetchUtils
35
+ .decompressResponseBuffer(Buffer.from(response.data, 'binary'), response.headers['content-encoding'])
36
+ .toString();
37
+ }
38
+ else {
39
+ body = Buffer.from(response.data, 'binary').toString();
40
+ }
41
+ }
42
+ return JSON.parse(body.trim());
43
+ }
44
+ catch (err) {
45
+ throw new CustomError_1.CustomError({
46
+ code: 3005,
47
+ // eslint-disable-next-line @typescript-eslint/camelcase
48
+ message: 'Manifest file embedded in the website is not a legal JSON file, please reconfigure',
49
+ message_staring_params: {},
50
+ });
51
+ }
52
+ }
53
+ async function loadJsonFromDisk(url) {
54
+ const jsonString = await loadFileString(url.toString());
55
+ return JSON.parse(jsonString);
56
+ }
57
+ async function loadImageFromNet(src) {
58
+ const response = await FetchUtils_1_1.fetchUtils.fetch(src, { encoding: 'binary' });
59
+ if (response.status !== 200) {
60
+ // throw new Error(
61
+ // `Failed to download icon ${iconUrl}. Responded with status ${response.status}`);
62
+ throw new CustomError_1.CustomError({
63
+ code: 2002,
64
+ message: `Failed to download icon. Responded with status ${response.status}`,
65
+ // eslint-disable-next-line @typescript-eslint/camelcase
66
+ message_staring_params: { icon_url: src, status: response.status },
67
+ });
68
+ }
69
+ const contentType = response.headers.get
70
+ ? response.headers.get('content-type')
71
+ : response.headers['content-type'];
72
+ if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('image/'))) {
73
+ // throw new Error(`Received icon "${iconUrl}" with invalid Content-Type.` +
74
+ // ` Responded with Content-Type "${contentType}"`);
75
+ throw new CustomError_1.CustomError({
76
+ code: 2003,
77
+ message: `Received icon with invalid Content-Type.` +
78
+ ` Responded with Content-Type "${contentType}"`,
79
+ // eslint-disable-next-line @typescript-eslint/camelcase
80
+ message_staring_params: { icon_url: src, contentType },
81
+ });
82
+ }
83
+ let body;
84
+ if (response.arrayBuffer) {
85
+ body = await response.arrayBuffer();
86
+ }
87
+ else {
88
+ if (['gzip', 'deflate', 'br'].includes(response.headers['content-encoding'])) {
89
+ body = FetchUtils_1_1.fetchUtils.decompressResponseBuffer(Buffer.from(response.data, 'binary'), response.headers['content-encoding']);
90
+ }
91
+ else {
92
+ body = Buffer.from(response.data, 'binary');
93
+ }
94
+ }
95
+ if (contentType.startsWith('image/svg')) {
96
+ const textDecoder = new TextDecoder();
97
+ try {
98
+ body = await imageHelper_1.ImageHelper.svg2img(textDecoder.decode(body));
99
+ }
100
+ catch (error) {
101
+ // throw new Error(`Problem reading ${iconUrl}: ${error}`);
102
+ throw new CustomError_1.CustomError({
103
+ code: 2004,
104
+ message: `Problem reading ${src}: ${error}`,
105
+ // eslint-disable-next-line @typescript-eslint/camelcase
106
+ message_staring_params: { icon_url: src, error },
107
+ });
108
+ }
109
+ }
110
+ if (contentType.startsWith('image/webp')) {
111
+ body = await imageHelper_1.ImageHelper.webp2PngBuffer(body);
112
+ }
113
+ return await Jimp.read(Buffer.from(body));
114
+ }
115
+ async function loadImageFromDisk(src) {
116
+ return await Jimp.read(src);
117
+ }
118
+ async function loadFileString(url) {
119
+ let file = await fs.promises.readFile(url.toString());
120
+ return file.toString();
121
+ }
@@ -1,9 +1,9 @@
1
1
  export interface PWAInitArgs {
2
- 'manifest-url'?: string;
2
+ manifestUrl?: string;
3
3
  manifest?: string;
4
4
  project?: string;
5
5
  base: string;
6
- 'bundle-id'?: string;
6
+ bundleId?: string;
7
7
  }
8
8
  export interface ManifestInfo {
9
9
  json: Record<string, any>;
package/dist/lib/types.js CHANGED
@@ -1 +1,2 @@
1
- 'use strict';function _0x1a61(_0x1bff02,_0x34859b){var _0x56b672=_0x56b6();return _0x1a61=function(_0x1a6166,_0x5e5502){_0x1a6166=_0x1a6166-0x116;var _0x140e5c=_0x56b672[_0x1a6166];return _0x140e5c;},_0x1a61(_0x1bff02,_0x34859b);}var _0x5afae7=_0x1a61;(function(_0x5b0a7e,_0x43f965){var _0xd8ad69=_0x1a61,_0x493ffa=_0x5b0a7e();while(!![]){try{var _0x3727c2=parseInt(_0xd8ad69(0x117))/0x1*(parseInt(_0xd8ad69(0x120))/0x2)+parseInt(_0xd8ad69(0x11e))/0x3*(-parseInt(_0xd8ad69(0x11c))/0x4)+-parseInt(_0xd8ad69(0x119))/0x5+parseInt(_0xd8ad69(0x11f))/0x6+parseInt(_0xd8ad69(0x118))/0x7*(-parseInt(_0xd8ad69(0x11d))/0x8)+-parseInt(_0xd8ad69(0x11b))/0x9*(-parseInt(_0xd8ad69(0x121))/0xa)+-parseInt(_0xd8ad69(0x122))/0xb;if(_0x3727c2===_0x43f965)break;else _0x493ffa['push'](_0x493ffa['shift']());}catch(_0x3dd899){_0x493ffa['push'](_0x493ffa['shift']());}}}(_0x56b6,0xb3852));Object[_0x5afae7(0x11a)](exports,_0x5afae7(0x116),{'value':!![]});function _0x56b6(){var _0x1545a7=['19467195rSPcAE','__esModule','646815TtDlhc','187558HLMdvW','310690EUxXRh','defineProperty','12013623UhYnXt','339548jHKGpE','136sXYVXg','9HXZlzj','7774164jAdtnx','2CBTutB','10ZjtcxM'];_0x56b6=function(){return _0x1545a7;};return _0x56b6();}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,11 @@
1
- 'use strict';var _0x465331=_0x1316;(function(_0x5e4a2f,_0x21c326){var _0x22719f=_0x1316,_0x4b05af=_0x5e4a2f();while(!![]){try{var _0x486c55=-parseInt(_0x22719f(0x72))/0x1*(parseInt(_0x22719f(0x7a))/0x2)+-parseInt(_0x22719f(0x75))/0x3+parseInt(_0x22719f(0x71))/0x4+-parseInt(_0x22719f(0x74))/0x5*(-parseInt(_0x22719f(0x7b))/0x6)+-parseInt(_0x22719f(0x73))/0x7*(-parseInt(_0x22719f(0x7e))/0x8)+parseInt(_0x22719f(0x79))/0x9+-parseInt(_0x22719f(0x76))/0xa*(parseInt(_0x22719f(0x77))/0xb);if(_0x486c55===_0x21c326)break;else _0x4b05af['push'](_0x4b05af['shift']());}catch(_0x418129){_0x4b05af['push'](_0x4b05af['shift']());}}}(_0x1112,0x19931));function _0x1316(_0x317a1a,_0x52ea75){var _0x11127a=_0x1112();return _0x1316=function(_0x131687,_0x2f80a3){_0x131687=_0x131687-0x71;var _0xbbb44d=_0x11127a[_0x131687];return _0xbbb44d;},_0x1316(_0x317a1a,_0x52ea75);}Object[_0x465331(0x7c)](exports,'__esModule',{'value':!![]}),exports['CustomError']=void 0x0;class CustomError extends Error{constructor(_0x34b546,_0x42073a){var _0x268920=_0x465331;super(JSON['stringify'](_0x34b546)),this[_0x268920(0x78)]=_0x34b546,this[_0x268920(0x7f)]=_0x42073a||_0x268920(0x7d);}}function _0x1112(){var _0x408bfc=['10cEFTdw','66wPdYWZ','defineProperty','info','17160okCXrg','type','367468xIkxuR','34419ojBaCe','532aEUSPO','19385SMlJKm','98826OPdvTU','10NFtWVu','1214444fVDSnf','customMessage','1103940lNtsGj'];_0x1112=function(){return _0x408bfc;};return _0x1112();}exports['CustomError']=CustomError;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomError = void 0;
4
+ class CustomError extends Error {
5
+ constructor(customMessage, type) {
6
+ super(JSON.stringify(customMessage));
7
+ this.customMessage = customMessage;
8
+ this.type = type || 'info';
9
+ }
10
+ }
11
+ exports.CustomError = CustomError;
@@ -1 +1,25 @@
1
- 'use strict';function _0xf659(_0x177ebc,_0x57be84){const _0x2d4d51=_0x2d4d();return _0xf659=function(_0xf6592a,_0x45a5b2){_0xf6592a=_0xf6592a-0xda;let _0x586768=_0x2d4d51[_0xf6592a];return _0x586768;},_0xf659(_0x177ebc,_0x57be84);}const _0x1e181f=_0xf659;(function(_0x46ad35,_0x2f536d){const _0x3986ce=_0xf659,_0x2697fa=_0x46ad35();while(!![]){try{const _0x25e875=parseInt(_0x3986ce(0xda))/0x1*(parseInt(_0x3986ce(0xee))/0x2)+parseInt(_0x3986ce(0xe3))/0x3*(-parseInt(_0x3986ce(0xea))/0x4)+-parseInt(_0x3986ce(0xed))/0x5*(parseInt(_0x3986ce(0xe7))/0x6)+parseInt(_0x3986ce(0xe2))/0x7*(parseInt(_0x3986ce(0xe9))/0x8)+-parseInt(_0x3986ce(0xdf))/0x9+-parseInt(_0x3986ce(0xec))/0xa*(parseInt(_0x3986ce(0xdc))/0xb)+parseInt(_0x3986ce(0xe8))/0xc*(parseInt(_0x3986ce(0xe6))/0xd);if(_0x25e875===_0x2f536d)break;else _0x2697fa['push'](_0x2697fa['shift']());}catch(_0x445449){_0x2697fa['push'](_0x2697fa['shift']());}}}(_0x2d4d,0x9eaa3));Object[_0x1e181f(0xe0)](exports,_0x1e181f(0xe5),{'value':!![]}),exports[_0x1e181f(0xdd)]=void 0x0;class FetchUtils{constructor(){const _0x3544e1=_0x1e181f;this['fetchEngine']=null,this['fetch']=null,this[_0x3544e1(0xef)]=null,this['decompressResponseBuffer']=null;}[_0x1e181f(0xe1)](_0x19c3a6){this['fetchEngine']=_0x19c3a6;}[_0x1e181f(0xf0)](_0x48390d){const _0x1d78ba=_0x1e181f;this[_0x1d78ba(0xdb)]=_0x48390d;}[_0x1e181f(0xeb)](_0x265be1){this['downloadFile']=_0x265be1;}[_0x1e181f(0xe4)](_0x5d6cbb){const _0x393a8e=_0x1e181f;this[_0x393a8e(0xde)]=_0x5d6cbb;}}const fetchUtils=new FetchUtils();exports[_0x1e181f(0xdd)]=fetchUtils;function _0x2d4d(){const _0x1d5f12=['__esModule','127309TXlNIx','12xQEAFE','2220duOOgk','40ebOCho','132SqCVLf','setDownloadFile','842360LHbTBd','1608645vAOJfS','2JXPwda','downloadFile','setFetch','714874zFjVYB','fetch','11ZBVNSu','fetchUtils','decompressResponseBuffer','7517484gwQsvk','defineProperty','setFetchEngine','825335BUbWxq','82113eTjQFJ','setDecompressResponseBuffer'];_0x2d4d=function(){return _0x1d5f12;};return _0x2d4d();}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchUtils = void 0;
4
+ class FetchUtils {
5
+ constructor() {
6
+ this.fetchEngine = null;
7
+ this.fetch = null;
8
+ this.downloadFile = null;
9
+ this.decompressResponseBuffer = null;
10
+ }
11
+ setFetchEngine(newFetchEngine) {
12
+ this.fetchEngine = newFetchEngine;
13
+ }
14
+ setFetch(newFetch) {
15
+ this.fetch = newFetch;
16
+ }
17
+ setDownloadFile(newDownloadFile) {
18
+ this.downloadFile = newDownloadFile;
19
+ }
20
+ setDecompressResponseBuffer(newDecompressResponseBuffer) {
21
+ this.decompressResponseBuffer = newDecompressResponseBuffer;
22
+ }
23
+ }
24
+ const fetchUtils = new FetchUtils();
25
+ exports.fetchUtils = fetchUtils;
@@ -1 +1,98 @@
1
- 'use strict';var _0x266923=_0x3eaa;(function(_0x8c73e5,_0x428b31){var _0x17bc62=_0x3eaa,_0x32c5ef=_0x8c73e5();while(!![]){try{var _0x169f80=-parseInt(_0x17bc62(0x149))/0x1+-parseInt(_0x17bc62(0x14c))/0x2*(-parseInt(_0x17bc62(0x165))/0x3)+parseInt(_0x17bc62(0x15d))/0x4*(parseInt(_0x17bc62(0x167))/0x5)+parseInt(_0x17bc62(0x14f))/0x6+parseInt(_0x17bc62(0x154))/0x7+parseInt(_0x17bc62(0x157))/0x8+parseInt(_0x17bc62(0x159))/0x9;if(_0x169f80===_0x428b31)break;else _0x32c5ef['push'](_0x32c5ef['shift']());}catch(_0x3c7618){_0x32c5ef['push'](_0x32c5ef['shift']());}}}(_0x595f,0xc5c0b));function _0x595f(){var _0x5f212b=['log','430884rulcmS','__esModule','\x1b[0m','setVerbose','prefix','inverse','ERROR\x20','red','3PzcpmL','output','5VlwsCB','warn','700397qMUTRa','\x1b[36m','verbose','221474bABtnl','newLog','info','4357140pjKhlO','tag','WARNING\x20','ConsoleLog','yellow','1641276IjxxjQ','defineProperty','dim','289200hzIjqb','error','2656134sMObYy','concat','\x1b[31m'];_0x595f=function(){return _0x5f212b;};return _0x595f();}function _0x3eaa(_0x5e5ce0,_0x2bc479){var _0x595f23=_0x595f();return _0x3eaa=function(_0x3eaa9c,_0x4fc847){_0x3eaa9c=_0x3eaa9c-0x148;var _0xfa59bc=_0x595f23[_0x3eaa9c];return _0xfa59bc;},_0x3eaa(_0x5e5ce0,_0x2bc479);}Object[_0x266923(0x155)](exports,_0x266923(0x15e),{'value':!![]}),exports[_0x266923(0x152)]=void 0x0;class ConsoleLog{constructor(_0x4b1ef3='',_0x22be61=![],_0x3ee38c=console){var _0x2097ed=_0x266923;this[_0x2097ed(0x150)]=_0x4b1ef3,this['verbose']=_0x22be61,this['prefix']=this[_0x2097ed(0x162)](_0x4b1ef3),this[_0x2097ed(0x166)]=_0x3ee38c;}['debug'](_0x1346dd,..._0x382156){var _0x332823=_0x266923;if(!this[_0x332823(0x14b)])return;this[_0x332823(0x15c)](this[_0x332823(0x166)][_0x332823(0x15c)],this[_0x332823(0x156)](_0x1346dd),..._0x382156);}[_0x266923(0x14e)](_0xa0473c,..._0x132244){var _0x4c7d81=_0x266923;this['log'](this[_0x4c7d81(0x166)][_0x4c7d81(0x15c)],_0xa0473c,..._0x132244);}[_0x266923(0x148)](_0x11da2a,..._0x44c687){var _0x3b6b32=_0x266923;this['log'](this[_0x3b6b32(0x166)][_0x3b6b32(0x148)],this['yellow'](_0x3b6b32(0x151)+_0x11da2a),..._0x44c687);}[_0x266923(0x158)](_0x325bc5,..._0x101834){var _0x3768ac=_0x266923;this[_0x3768ac(0x166)]['error']('\x0a'),this['log'](this[_0x3768ac(0x166)][_0x3768ac(0x158)],this['red'](_0x3768ac(0x163)+_0x325bc5),..._0x101834),this[_0x3768ac(0x166)][_0x3768ac(0x158)]('\x0a');}[_0x266923(0x160)](_0x2084ce){var _0x57b4bf=_0x266923;this[_0x57b4bf(0x14b)]=_0x2084ce;}[_0x266923(0x14d)](_0xaf5348){var _0x57e7e0=_0x266923;return this[_0x57e7e0(0x150)]&&(_0xaf5348=this[_0x57e7e0(0x150)]+'\x20'+_0xaf5348),new ConsoleLog(_0xaf5348,this[_0x57e7e0(0x14b)],this['output']);}[_0x266923(0x15c)](_0x2ebedb,_0x308117,..._0x34452f){var _0x5814c4=_0x266923;this[_0x5814c4(0x161)]&&(_0x308117=this[_0x5814c4(0x161)]+'\x20'+_0x308117),_0x34452f?_0x2ebedb(...[_0x308117][_0x5814c4(0x15a)](_0x34452f)):_0x2ebedb(_0x308117);}[_0x266923(0x162)](_0x47ca6f){return'\x1b[7m'+_0x47ca6f+'\x1b[0m';}['dim'](_0x8c97c9){var _0x510fe0=_0x266923;return _0x510fe0(0x14a)+_0x8c97c9+'\x1b[0m';}[_0x266923(0x153)](_0x433cbe){return'\x1b[33m'+_0x433cbe+'\x1b[0m';}[_0x266923(0x164)](_0x5bb7d8){var _0x502f35=_0x266923;return _0x502f35(0x15b)+_0x5bb7d8+_0x502f35(0x15f);}}exports[_0x266923(0x152)]=ConsoleLog;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleLog = void 0;
4
+ /**
5
+ * An utility class to print nice Log messages.
6
+ */
7
+ class ConsoleLog {
8
+ /**
9
+ * Creates a new Log instance
10
+ * @param tag The tag used when logging. Printed at the beggining of a log message.
11
+ * @param verbose If the Log is verbose. Debug messages are only printed on verbose logs.
12
+ * @param output Where to output the log messages.
13
+ */
14
+ constructor(tag = '', verbose = false, output = console) {
15
+ this.tag = tag;
16
+ this.verbose = verbose;
17
+ this.prefix = this.inverse(tag);
18
+ this.output = output;
19
+ }
20
+ /**
21
+ * Prints a debug message to the Log. Message is ignored if the Log is not set to verbose.
22
+ * @param message The message the be printed.
23
+ * @param args Extra arguments for the console.
24
+ */
25
+ debug(message, ...args) {
26
+ if (!this.verbose) {
27
+ return;
28
+ }
29
+ this.log(this.output.log, this.dim(message), ...args);
30
+ }
31
+ /**
32
+ * Prints an info message to the Log. Message is ignored if the Log is not set to verbose.
33
+ * @param message The message the be printed.
34
+ * @param args Extra arguments for the console.
35
+ */
36
+ info(message, ...args) {
37
+ this.log(this.output.log, message, ...args);
38
+ }
39
+ /**
40
+ * Prints an warning message to the Log. Message is ignored if the Log is not set to verbose.
41
+ * @param message The message the be printed.
42
+ * @param args Extra arguments for the console.
43
+ */
44
+ warn(message, ...args) {
45
+ this.log(this.output.warn, this.yellow('WARNING ' + message), ...args);
46
+ }
47
+ /**
48
+ * Prints an error message to the Log. Message is ignored if the Log is not set to verbose.
49
+ * @param message The message the be printed.
50
+ * @param args Extra arguments for the console.
51
+ */
52
+ error(message, ...args) {
53
+ this.output.error('\n');
54
+ this.log(this.output.error, this.red('ERROR ' + message), ...args);
55
+ this.output.error('\n');
56
+ }
57
+ /**
58
+ * Sets the verbose.
59
+ * @param verbose The verbose value to set.
60
+ */
61
+ setVerbose(verbose) {
62
+ this.verbose = verbose;
63
+ }
64
+ /**
65
+ * Creates a new Log using the same output and verbositity of the current Log.
66
+ * @param newTag The tag the be used on the new Log instance.
67
+ */
68
+ newLog(newTag) {
69
+ if (this.tag) {
70
+ newTag = this.tag + ' ' + newTag;
71
+ }
72
+ return new ConsoleLog(newTag, this.verbose, this.output);
73
+ }
74
+ log(fn, message, ...args) {
75
+ if (this.prefix) {
76
+ message = this.prefix + ' ' + message;
77
+ }
78
+ if (args) {
79
+ fn(...[message].concat(args));
80
+ }
81
+ else {
82
+ fn(message);
83
+ }
84
+ }
85
+ inverse(input) {
86
+ return `\x1b[7m${input}\x1b[0m`;
87
+ }
88
+ dim(input) {
89
+ return `\x1b[36m${input}\x1b[0m`;
90
+ }
91
+ yellow(input) {
92
+ return `\x1b[33m${input}\x1b[0m`;
93
+ }
94
+ red(input) {
95
+ return `\x1b[31m${input}\x1b[0m`;
96
+ }
97
+ }
98
+ exports.ConsoleLog = ConsoleLog;
@@ -1 +1,56 @@
1
- 'use strict';const _0x4a2536=_0xcc7f;(function(_0x19b3e5,_0x4eb197){const _0x2ed957=_0xcc7f,_0x50b293=_0x19b3e5();while(!![]){try{const _0x449019=-parseInt(_0x2ed957(0x1c9))/0x1*(parseInt(_0x2ed957(0x1b4))/0x2)+parseInt(_0x2ed957(0x1c1))/0x3+parseInt(_0x2ed957(0x1b2))/0x4*(-parseInt(_0x2ed957(0x1bb))/0x5)+parseInt(_0x2ed957(0x1b9))/0x6+parseInt(_0x2ed957(0x1ce))/0x7+parseInt(_0x2ed957(0x1b5))/0x8*(-parseInt(_0x2ed957(0x1b0))/0x9)+-parseInt(_0x2ed957(0x1b8))/0xa*(parseInt(_0x2ed957(0x1c4))/0xb);if(_0x449019===_0x4eb197)break;else _0x50b293['push'](_0x50b293['shift']());}catch(_0x39cdb0){_0x50b293['push'](_0x50b293['shift']());}}}(_0x3faa,0x7edbf));Object['defineProperty'](exports,_0x4a2536(0x1bc),{'value':!![]}),exports[_0x4a2536(0x1be)]=fetch,exports['downloadFile']=downloadFile,exports[_0x4a2536(0x1cc)]=decompressResponseBuffer;function _0x3faa(){const _0x1fc2cf=['Z_SYNC_FLUSH','388998kruSKL','Content-Length','186376aChSkJ','unzipSync','6NtlJmX','32qPrRlu','constants','length','6400jQwwls','4375116DLvWlU','finish','20ZTqbsu','__esModule','createWriteStream','fetch','Mozilla/5.0\x20(X11;\x20Linux\x20x86_64;\x20PICO\x204\x20OS5.5.0\x20like\x20Quest)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20PicoBrowser/3.3.24\x20Chrome/105.0.5195.68\x20VR\x20Safari/537.36\x20\x20OculusBrowser/7.0','test','2771625uhXAOa','headers','follow','14069kdXsKa','error','get','brotliDecompressSync','data','247519hmbKWW','pipe','fetch-h2','decompressResponseBuffer','readable','5508545tpeaLs'];_0x3faa=function(){return _0x1fc2cf;};return _0x3faa();}const fetch_h2_1=require(_0x4a2536(0x1cb)),fs=require('fs'),zlib=require('zlib'),userAgent=_0x4a2536(0x1bf),fetchh2Ctx=(0x0,fetch_h2_1['context'])({'userAgent':userAgent,'overwriteUserAgent':!![]}),fetchh2=fetchh2Ctx['fetch'];async function fetch(_0x5b6294,_0x1ea635){const _0x406741=_0x4a2536;return await fetchh2(_0x5b6294,_0x1ea635?{'redirect':_0x406741(0x1c3),..._0x1ea635}:{'redirect':_0x406741(0x1c3)});}async function downloadFile(_0x34f418,_0x50c06a,_0x1bd227){const _0x42fdfa=_0x4a2536;let _0x409aa0,_0x291725;_0x409aa0=await fetchh2(_0x34f418,{'redirect':_0x42fdfa(0x1c3)}),_0x291725=await _0x409aa0[_0x42fdfa(0x1cd)]();const _0x1ec1a7=_0x409aa0[_0x42fdfa(0x1c2)][_0x42fdfa(0x1c6)](_0x42fdfa(0x1b1)),_0x1c3d98=_0x1ec1a7?parseInt(_0x1ec1a7):-0x1,_0x4e1350=fs[_0x42fdfa(0x1bd)](_0x50c06a);let _0x312916=0x0;await new Promise((_0x223602,_0x4f25ae)=>{const _0x190c94=_0x42fdfa;_0x291725[_0x190c94(0x1ca)](_0x4e1350),_0x1bd227&&_0x291725['on'](_0x190c94(0x1c8),_0x275ab8=>{const _0x5bbe97=_0x190c94;_0x312916=_0x312916+_0x275ab8[_0x5bbe97(0x1b7)],_0x1bd227(_0x312916,_0x1c3d98);}),_0x291725['on'](_0x190c94(0x1c5),_0xae8774=>{_0x4f25ae(_0xae8774);}),_0x4e1350['on'](_0x190c94(0x1ba),()=>{_0x223602();});});}function _0xcc7f(_0x1d30fd,_0x13c78b){const _0x3faa26=_0x3faa();return _0xcc7f=function(_0xcc7f2f,_0x47f7c0){_0xcc7f2f=_0xcc7f2f-0x1b0;let _0x512143=_0x3faa26[_0xcc7f2f];return _0x512143;},_0xcc7f(_0x1d30fd,_0x13c78b);}function decompressResponseBuffer(_0x5e6c37,_0xb8a19a){const _0x1f412b=_0x4a2536;let _0xaf8482=_0x5e6c37;if(/\bgzip\b/[_0x1f412b(0x1c0)](_0xb8a19a)||/\bdeflate\b/[_0x1f412b(0x1c0)](_0xb8a19a))_0xaf8482=zlib[_0x1f412b(0x1b3)](_0x5e6c37,{'flush':zlib['constants'][_0x1f412b(0x1cf)],'finishFlush':zlib[_0x1f412b(0x1b6)][_0x1f412b(0x1cf)]});else/\bbr\b/[_0x1f412b(0x1c0)](_0xb8a19a)&&(_0xaf8482=zlib[_0x1f412b(0x1c7)](_0x5e6c37));return _0xaf8482;}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetch = fetch;
4
+ exports.downloadFile = downloadFile;
5
+ exports.decompressResponseBuffer = decompressResponseBuffer;
6
+ const fetch_h2_1 = require("fetch-h2");
7
+ const fs = require("fs");
8
+ const zlib = require("zlib");
9
+ // const userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0';
10
+ const userAgent = 'Mozilla/5.0 (X11; Linux x86_64; PICO 4 OS5.5.0 like Quest) AppleWebKit/537.36 (KHTML, like Gecko) PicoBrowser/3.3.24 Chrome/105.0.5195.68 VR Safari/537.36 OculusBrowser/7.0';
11
+ const fetchh2Ctx = (0, fetch_h2_1.context)({ userAgent: userAgent, overwriteUserAgent: true });
12
+ const fetchh2 = fetchh2Ctx.fetch;
13
+ async function fetch(input, headers) {
14
+ return await fetchh2(input, headers ? { redirect: 'follow', ...headers } : { redirect: 'follow' });
15
+ }
16
+ async function downloadFile(url, path, progressCallback) {
17
+ let result;
18
+ let readableStream;
19
+ result = await fetchh2(url, { redirect: 'follow' });
20
+ readableStream = await result.readable();
21
+ // Try to determine the file size via the `Content-Length` header. This may not be available
22
+ // for all cases.
23
+ const contentLength = result.headers.get('Content-Length');
24
+ const fileSize = contentLength ? parseInt(contentLength) : -1;
25
+ const fileStream = fs.createWriteStream(path);
26
+ let received = 0;
27
+ await new Promise((resolve, reject) => {
28
+ readableStream.pipe(fileStream);
29
+ // Even though we're piping the chunks, we intercept them to check for the download progress.
30
+ if (progressCallback) {
31
+ readableStream.on('data', chunk => {
32
+ received = received + chunk.length;
33
+ progressCallback(received, fileSize);
34
+ });
35
+ }
36
+ readableStream.on('error', err => {
37
+ reject(err);
38
+ });
39
+ fileStream.on('finish', () => {
40
+ resolve();
41
+ });
42
+ });
43
+ }
44
+ function decompressResponseBuffer(buffer, contentEncoding) {
45
+ let result = buffer;
46
+ if (/\bgzip\b/.test(contentEncoding) || /\bdeflate\b/.test(contentEncoding)) {
47
+ result = zlib.unzipSync(buffer, {
48
+ flush: zlib.constants.Z_SYNC_FLUSH,
49
+ finishFlush: zlib.constants.Z_SYNC_FLUSH,
50
+ });
51
+ }
52
+ else if (/\bbr\b/.test(contentEncoding)) {
53
+ result = zlib.brotliDecompressSync(buffer);
54
+ }
55
+ return result;
56
+ }
@@ -9,6 +9,7 @@ export default class CliHistory {
9
9
  static recordManifest(manifest: Record<string, any>): void;
10
10
  static recordSimulator(simulator: string): void;
11
11
  static checkManifest(manifest: Record<string, any>): boolean;
12
+ static checkTestAppIsExist(): boolean;
12
13
  private static compareObjects;
13
14
  static checkCommand(cmd: string): boolean;
14
15
  static write(): void;