@webspatial/builder 0.1.16 → 0.1.18

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 _0x360231=_0x1f82;(function(_0x3fb342,_0x2c5b63){const _0x1caf17=_0x1f82,_0x40f92f=_0x3fb342();while(!![]){try{const _0x1f68a4=parseInt(_0x1caf17(0x157))/0x1+parseInt(_0x1caf17(0x14c))/0x2*(parseInt(_0x1caf17(0x14a))/0x3)+parseInt(_0x1caf17(0x155))/0x4+-parseInt(_0x1caf17(0x143))/0x5+parseInt(_0x1caf17(0x145))/0x6*(-parseInt(_0x1caf17(0x14e))/0x7)+parseInt(_0x1caf17(0x148))/0x8+-parseInt(_0x1caf17(0x14f))/0x9*(parseInt(_0x1caf17(0x13f))/0xa);if(_0x1f68a4===_0x2c5b63)break;else _0x40f92f['push'](_0x40f92f['shift']());}catch(_0x33e134){_0x40f92f['push'](_0x40f92f['shift']());}}}(_0x4700,0x3ac87));Object[_0x360231(0x149)](exports,_0x360231(0x141),{'value':!![]}),exports['ImageHelper']=void 0x0;function _0x4700(){const _0x4fd85d=['defineProperty','69NusKLi','jimp','3374fiHfxb','toFormat','24829RGVDLp','216981DkLqcp','@resvg/resvg-js','webp2PngBuffer','asPng','width','sharp','702076JWZkdx','Resvg','438888RPwHdL','60naTFaD','getHeight','__esModule','png','1047735XceJIT','isFullyOpaque','246wmPWer','bitmap','svg2img','697560zpeDGR'];_0x4700=function(){return _0x4fd85d;};return _0x4700();}const Jimp=require(_0x360231(0x14b)),sharp=require(_0x360231(0x154)),resvg_js_1=require(_0x360231(0x150));class ImageHelper{static['createImg'](_0x1b5aca){return new Jimp(_0x1b5aca,_0x1b5aca,0x0);}static async[_0x360231(0x151)](_0x21895d){const _0x2d4605=_0x360231;return await sharp(_0x21895d)[_0x2d4605(0x14d)](_0x2d4605(0x142))['toBuffer']();}static async[_0x360231(0x147)](_0x5cad18){const _0x226a45=_0x360231,_0x26fdf2={'fitTo':{'mode':_0x226a45(0x153),'value':0x400}},_0x3b2eba=new resvg_js_1[(_0x226a45(0x156))](_0x5cad18,_0x26fdf2),_0x53bb1e=_0x3b2eba['render'](),_0x540464=_0x53bb1e[_0x226a45(0x152)]();return _0x540464;}static[_0x360231(0x144)](_0x61591b){const _0x1e5622=_0x360231,_0x5c46a0=_0x61591b['getWidth']()*_0x61591b[_0x1e5622(0x140)]();for(var _0x3bf998=0x0;_0x3bf998<_0x5c46a0;_0x3bf998++){const _0x444302=_0x3bf998*0x4+0x3;if(_0x61591b[_0x1e5622(0x146)]['data'][_0x444302]<0xff)return![];}return!![];}}function _0x1f82(_0x2f4f14,_0x29571f){const _0x470018=_0x4700();return _0x1f82=function(_0x1f8237,_0x3c3a87){_0x1f8237=_0x1f8237-0x13f;let _0x2641ff=_0x470018[_0x1f8237];return _0x2641ff;},_0x1f82(_0x2f4f14,_0x29571f);}exports['ImageHelper']=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';function _0x3cf0(){const _0x2bf71b=['path','defineProperty','PROJECT_EXPORT_DIRECTORY','/AppIcon.solidimagestack/Back.solidimagestacklayer/Content.imageset',',\x20now\x20WebSpatial\x20only\x20support\x20','8sGIlpm','\x20&&\x20pnpm\x20add\x20@webspatial/platform-','3260asGVYo','generateIcon','../../../node_modules/@webspatial/platform-','visionos','123XHbwYD','./export','src','14jQhSUS','BACK_APPICON_DIRECTORY','__esModule','moveProjectFrom','ResourceManager','18491EsMOND','execSync','529015eldApW','./load','http','child_process','mkdirSync','/AppIcon.solidimagestack/Middle.solidimagestacklayer/Content.imageset','5286720GDFLXn','loadImageFromNet','icons','PROJECT_DIRECTORY','PROJECT_BUILD_DIRECTORY','616224MlSNyi','web-spatial/static-web','startsWith','not\x20support\x20platform\x20','ASSET_DIRECTORY','rm\x20-rf\x20','PROJECT_TEST_DIRECTORY','log','28vsiRLc','join','cwd','../../../','2508642ZsOdgy','includes','copyDir','cd\x20','509538KZshfs','../../temp','WEB_PROJECT_DIRECTORY','14682kFmXpx','MIDDLE_APPICON_DIRECTORY','web-spatial/Assets.xcassets','existsSync','./test','node_modules/@webspatial/platform-','./build','checkPlatformPath'];_0x3cf0=function(){return _0x2bf71b;};return _0x3cf0();}const _0x1ae7f5=_0x2d8c;(function(_0x1a2e18,_0xe77114){const _0x503513=_0x2d8c,_0x110610=_0x1a2e18();while(!![]){try{const _0x2eb56d=parseInt(_0x503513(0x8a))/0x1+-parseInt(_0x503513(0x9d))/0x2*(-parseInt(_0x503513(0x75))/0x3)+parseInt(_0x503513(0x92))/0x4*(parseInt(_0x503513(0x7f))/0x5)+-parseInt(_0x503513(0x9a))/0x6*(-parseInt(_0x503513(0x78))/0x7)+parseInt(_0x503513(0xaa))/0x8*(-parseInt(_0x503513(0x96))/0x9)+parseInt(_0x503513(0xac))/0xa*(-parseInt(_0x503513(0x7d))/0xb)+-parseInt(_0x503513(0x85))/0xc;if(_0x2eb56d===_0xe77114)break;else _0x110610['push'](_0x110610['shift']());}catch(_0x19c714){_0x110610['push'](_0x110610['shift']());}}}(_0x3cf0,0x88cf0));Object[_0x1ae7f5(0xa6)](exports,_0x1ae7f5(0x7a),{'value':!![]}),exports[_0x1ae7f5(0x7c)]=exports[_0x1ae7f5(0x9e)]=exports[_0x1ae7f5(0x79)]=exports[_0x1ae7f5(0x8e)]=exports['WEB_PROJECT_DIRECTORY']=exports[_0x1ae7f5(0x90)]=exports['PROJECT_EXPORT_DIRECTORY']=exports[_0x1ae7f5(0x89)]=exports[_0x1ae7f5(0x88)]=void 0x0;const fs=require('fs'),path_1=require(_0x1ae7f5(0xa5)),file_1=require('./file'),load_1=require(_0x1ae7f5(0x80)),child_process_1=require(_0x1ae7f5(0x82));exports[_0x1ae7f5(0x88)]='',exports[_0x1ae7f5(0x89)]='',exports[_0x1ae7f5(0xa7)]='',exports[_0x1ae7f5(0x90)]='',exports[_0x1ae7f5(0x9c)]=_0x1ae7f5(0x8b),exports['ASSET_DIRECTORY']=_0x1ae7f5(0x9f),exports[_0x1ae7f5(0x79)]=exports[_0x1ae7f5(0x8e)]+_0x1ae7f5(0xa8),exports[_0x1ae7f5(0x9e)]=exports[_0x1ae7f5(0x8e)]+_0x1ae7f5(0x84);const supportPlatform=[_0x1ae7f5(0x74)];function _0x2d8c(_0x3dc301,_0x16d1c2){const _0x3cf072=_0x3cf0();return _0x2d8c=function(_0x2d8cf1,_0x2a1e7b){_0x2d8cf1=_0x2d8cf1-0x72;let _0x59ef33=_0x3cf072[_0x2d8cf1];return _0x59ef33;},_0x2d8c(_0x3dc301,_0x16d1c2);}class ResourceManager{static async[_0x1ae7f5(0x7b)](_0x5a7165){const _0x2030a8=_0x1ae7f5,_0x5f2ab1=(0x0,path_1['join'])(process['cwd'](),_0x5a7165),_0x35b67d=(0x0,path_1[_0x2030a8(0x93)])(exports['PROJECT_DIRECTORY'],exports[_0x2030a8(0x9c)]);!fs[_0x2030a8(0xa0)](_0x35b67d)?fs[_0x2030a8(0x83)](_0x35b67d,{'recursive':!![]}):(0x0,file_1['clearDir'])(_0x35b67d);try{(0x0,file_1[_0x2030a8(0x98)])(_0x5f2ab1,_0x35b67d);}catch(_0x5f4ec5){console[_0x2030a8(0x91)](_0x5f4ec5);}}static async[_0x1ae7f5(0x72)](_0x473506){const _0x40ca73=_0x1ae7f5,_0x22cd5d=_0x473506['json'],_0x4f6e87=_0x22cd5d[_0x40ca73(0x87)][0x0][_0x40ca73(0x77)],_0x118704=!_0x4f6e87[_0x40ca73(0x8c)](_0x40ca73(0x81))?await(0x0,load_1['loadImageFromDisk'])(_0x4f6e87):await(0x0,load_1[_0x40ca73(0x86)])(_0x4f6e87);return _0x118704['resize'](0x400,0x400),_0x118704;}static[_0x1ae7f5(0xa4)](_0xf9a619){const _0x507ce3=_0x1ae7f5,_0x35de5d=_0xf9a619!==null&&_0xf9a619!==void 0x0?_0xf9a619:supportPlatform[0x0];if(!supportPlatform[_0x507ce3(0x97)](_0x35de5d))throw new Error(_0x507ce3(0x8d)+_0x35de5d+_0x507ce3(0xa9)+supportPlatform[_0x507ce3(0x93)](','));let _0x255d78=(0x0,path_1[_0x507ce3(0x93)])(process[_0x507ce3(0x94)](),_0x507ce3(0xa2)+_0x35de5d);!fs[_0x507ce3(0xa0)](_0x255d78)&&(_0x255d78=(0x0,path_1[_0x507ce3(0x93)])(__dirname,_0x507ce3(0x73)+_0x35de5d));const _0x46c696=fs[_0x507ce3(0xa0)](_0x255d78);!_0x46c696&&(0x0,child_process_1[_0x507ce3(0x7e)])(_0x507ce3(0x99)+(0x0,path_1[_0x507ce3(0x93)])(__dirname,_0x507ce3(0x95))+_0x507ce3(0xab)+_0x35de5d);let _0x1e29a6=(0x0,path_1['join'])(__dirname,_0x507ce3(0x9b)),_0x3eb0ba=(0x0,path_1['join'])(_0x1e29a6,'platform-'+_0x35de5d);fs[_0x507ce3(0xa0)](_0x1e29a6)&&(0x0,child_process_1[_0x507ce3(0x7e)])(_0x507ce3(0x8f)+_0x1e29a6),fs[_0x507ce3(0x83)](_0x1e29a6),fs[_0x507ce3(0x83)](_0x3eb0ba),(0x0,file_1[_0x507ce3(0x98)])(_0x255d78,_0x3eb0ba),exports[_0x507ce3(0x88)]=_0x3eb0ba,exports[_0x507ce3(0x89)]=(0x0,path_1[_0x507ce3(0x93)])(exports[_0x507ce3(0x88)],_0x507ce3(0xa3)),exports['PROJECT_EXPORT_DIRECTORY']=(0x0,path_1[_0x507ce3(0x93)])(exports['PROJECT_DIRECTORY'],_0x507ce3(0x76)),exports['PROJECT_TEST_DIRECTORY']=(0x0,path_1[_0x507ce3(0x93)])(exports['PROJECT_BUILD_DIRECTORY'],_0x507ce3(0xa1));}}exports[_0x1ae7f5(0x7c)]=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';function _0x278d(){const _0x3d7782=['from','1472415tMfLmM','ImageHelper','data','Failed\x20to\x20download\x20Web\x20Manifest\x20','967596mOlcFr','Problem\x20reading\x20','./imageHelper','1149078wuFsJO','gzip','headers',',\x20please\x20check\x20the\x20Web\x20Manifest\x20access\x20address','loadFileString','loadJsonFromNet','content-type','content-encoding','The\x20response\x20status\x20is\x20','defineProperty','includes','startsWith','loadImageFromNet','decompressResponseBuffer','readFile','../utils/CustomError','deflate','image/svg','status','read','__esModule','fetchUtils','951860fwLhpr','CustomError','2358099lLZbeP','loadImageFromDisk','promises','3503948NdapdC','text','get','image/webp','fetch','binary','toString','jimp','trim','image/','1288554rSLXje','../utils/FetchUtils-1','arrayBuffer','loadJsonFromDisk','6KucEHp','40ASOEPg'];_0x278d=function(){return _0x3d7782;};return _0x278d();}const _0x1d4eb0=_0x1a73;(function(_0x3c4b79,_0x439b43){const _0x3dba2=_0x1a73,_0x14a2ac=_0x3c4b79();while(!![]){try{const _0x3463d8=-parseInt(_0x3dba2(0x13d))/0x1+-parseInt(_0x3dba2(0x15a))/0x2+-parseInt(_0x3dba2(0x14c))/0x3+parseInt(_0x3dba2(0x142))/0x4+parseInt(_0x3dba2(0x153))/0x5+-parseInt(_0x3dba2(0x150))/0x6*(-parseInt(_0x3dba2(0x157))/0x7)+-parseInt(_0x3dba2(0x151))/0x8*(-parseInt(_0x3dba2(0x13f))/0x9);if(_0x3463d8===_0x439b43)break;else _0x14a2ac['push'](_0x14a2ac['shift']());}catch(_0x5ca907){_0x14a2ac['push'](_0x14a2ac['shift']());}}}(_0x278d,0xa1d34));Object[_0x1d4eb0(0x163)](exports,_0x1d4eb0(0x13b),{'value':!![]}),exports[_0x1d4eb0(0x15f)]=loadJsonFromNet,exports[_0x1d4eb0(0x14f)]=loadJsonFromDisk,exports[_0x1d4eb0(0x166)]=loadImageFromNet,exports[_0x1d4eb0(0x140)]=loadImageFromDisk,exports[_0x1d4eb0(0x15e)]=loadFileString;const fs=require('fs'),FetchUtils_1_1=require(_0x1d4eb0(0x14d)),CustomError_1=require(_0x1d4eb0(0x136)),Jimp=require(_0x1d4eb0(0x149)),imageHelper_1=require(_0x1d4eb0(0x159));async function loadJsonFromNet(_0x1e7ab9){const _0xfe08c3=_0x1d4eb0,_0x3b3d38=await FetchUtils_1_1[_0xfe08c3(0x13c)][_0xfe08c3(0x146)](_0x1e7ab9,{'encoding':'binary'});if(_0x3b3d38['status']!==0xc8)throw new CustomError_1['CustomError']({'code':0xbbc,'message':_0xfe08c3(0x156)+_0x1e7ab9+'.'+(_0xfe08c3(0x162)+_0x3b3d38[_0xfe08c3(0x139)]+_0xfe08c3(0x15d)),'message_staring_params':{'web_manifest_url':_0x1e7ab9,'status':_0x3b3d38[_0xfe08c3(0x139)]}});try{let _0x1f43c4;return _0x3b3d38[_0xfe08c3(0x143)]?_0x1f43c4=await _0x3b3d38[_0xfe08c3(0x143)]():['gzip',_0xfe08c3(0x137),'br'][_0xfe08c3(0x164)](_0x3b3d38['headers']['content-encoding'])?_0x1f43c4=FetchUtils_1_1[_0xfe08c3(0x13c)][_0xfe08c3(0x167)](Buffer[_0xfe08c3(0x152)](_0x3b3d38['data'],_0xfe08c3(0x147)),_0x3b3d38[_0xfe08c3(0x15c)][_0xfe08c3(0x161)])[_0xfe08c3(0x148)]():_0x1f43c4=Buffer['from'](_0x3b3d38[_0xfe08c3(0x155)],_0xfe08c3(0x147))[_0xfe08c3(0x148)](),JSON['parse'](_0x1f43c4[_0xfe08c3(0x14a)]());}catch(_0xeb9b4e){throw new CustomError_1[(_0xfe08c3(0x13e))]({'code':0xbbd,'message':'Manifest\x20file\x20embedded\x20in\x20the\x20website\x20is\x20not\x20a\x20legal\x20JSON\x20file,\x20please\x20reconfigure','message_staring_params':{}});}}function _0x1a73(_0xa6864a,_0x467a67){const _0x278de4=_0x278d();return _0x1a73=function(_0x1a7348,_0x3deaa1){_0x1a7348=_0x1a7348-0x135;let _0x5035d5=_0x278de4[_0x1a7348];return _0x5035d5;},_0x1a73(_0xa6864a,_0x467a67);}async function loadJsonFromDisk(_0x383dbd){const _0x29bca9=_0x1d4eb0,_0x16e00d=await loadFileString(_0x383dbd[_0x29bca9(0x148)]());return JSON['parse'](_0x16e00d);}async function loadImageFromNet(_0xeeca2){const _0x5680f7=_0x1d4eb0,_0xc26c79=await FetchUtils_1_1[_0x5680f7(0x13c)][_0x5680f7(0x146)](_0xeeca2,{'encoding':_0x5680f7(0x147)});if(_0xc26c79[_0x5680f7(0x139)]!==0xc8)throw new CustomError_1[(_0x5680f7(0x13e))]({'code':0x7d2,'message':'Failed\x20to\x20download\x20icon.\x20Responded\x20with\x20status\x20'+_0xc26c79[_0x5680f7(0x139)],'message_staring_params':{'icon_url':_0xeeca2,'status':_0xc26c79[_0x5680f7(0x139)]}});const _0x2a4435=_0xc26c79[_0x5680f7(0x15c)]['get']?_0xc26c79[_0x5680f7(0x15c)][_0x5680f7(0x144)](_0x5680f7(0x160)):_0xc26c79[_0x5680f7(0x15c)][_0x5680f7(0x160)];if(!(_0x2a4435===null||_0x2a4435===void 0x0?void 0x0:_0x2a4435[_0x5680f7(0x165)](_0x5680f7(0x14b))))throw new CustomError_1[(_0x5680f7(0x13e))]({'code':0x7d3,'message':'Received\x20icon\x20with\x20invalid\x20Content-Type.'+('\x20Responded\x20with\x20Content-Type\x20\x22'+_0x2a4435+'\x22'),'message_staring_params':{'icon_url':_0xeeca2,'contentType':_0x2a4435}});let _0x3c611f;_0xc26c79[_0x5680f7(0x14e)]?_0x3c611f=await _0xc26c79['arrayBuffer']():[_0x5680f7(0x15b),_0x5680f7(0x137),'br'][_0x5680f7(0x164)](_0xc26c79['headers']['content-encoding'])?_0x3c611f=FetchUtils_1_1['fetchUtils']['decompressResponseBuffer'](Buffer['from'](_0xc26c79[_0x5680f7(0x155)],'binary'),_0xc26c79['headers'][_0x5680f7(0x161)]):_0x3c611f=Buffer[_0x5680f7(0x152)](_0xc26c79[_0x5680f7(0x155)],_0x5680f7(0x147));if(_0x2a4435['startsWith'](_0x5680f7(0x138))){const _0x4b90b9=new TextDecoder();try{_0x3c611f=await imageHelper_1['ImageHelper']['svg2img'](_0x4b90b9['decode'](_0x3c611f));}catch(_0x54588b){throw new CustomError_1[(_0x5680f7(0x13e))]({'code':0x7d4,'message':_0x5680f7(0x158)+_0xeeca2+':\x20'+_0x54588b,'message_staring_params':{'icon_url':_0xeeca2,'error':_0x54588b}});}}return _0x2a4435[_0x5680f7(0x165)](_0x5680f7(0x145))&&(_0x3c611f=await imageHelper_1[_0x5680f7(0x154)]['webp2PngBuffer'](_0x3c611f)),await Jimp[_0x5680f7(0x13a)](Buffer[_0x5680f7(0x152)](_0x3c611f));}async function loadImageFromDisk(_0x431507){const _0x1bc95e=_0x1d4eb0;return await Jimp[_0x1bc95e(0x13a)](_0x431507);}async function loadFileString(_0x432dba){const _0x4f5b95=_0x1d4eb0;let _0x2bc07b=await fs[_0x4f5b95(0x141)][_0x4f5b95(0x135)](_0x432dba[_0x4f5b95(0x148)]());return _0x2bc07b['toString']();}
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
+ }
package/dist/lib/types.js CHANGED
@@ -1 +1,2 @@
1
- 'use strict';var _0x123650=_0x38fc;function _0x7f73(){var _0x32d583=['7ZivIXK','10928258BxrjCl','43687rSHRPW','48Juxfol','1452744APtdRB','3664287LSZZrq','18658PoYtck','defineProperty','20PuWzgf','5429032rRwEop','5rAbqyt','3596121wSTpbB'];_0x7f73=function(){return _0x32d583;};return _0x7f73();}(function(_0x287a0e,_0x2d93b9){var _0x418390=_0x38fc,_0x20f217=_0x287a0e();while(!![]){try{var _0x5cfe94=parseInt(_0x418390(0x11d))/0x1*(-parseInt(_0x418390(0x123))/0x2)+parseInt(_0x418390(0x128))/0x3+parseInt(_0x418390(0x126))/0x4+parseInt(_0x418390(0x127))/0x5*(parseInt(_0x418390(0x121))/0x6)+parseInt(_0x418390(0x11f))/0x7*(-parseInt(_0x418390(0x120))/0x8)+parseInt(_0x418390(0x122))/0x9*(-parseInt(_0x418390(0x125))/0xa)+-parseInt(_0x418390(0x11e))/0xb;if(_0x5cfe94===_0x2d93b9)break;else _0x20f217['push'](_0x20f217['shift']());}catch(_0x4577e2){_0x20f217['push'](_0x20f217['shift']());}}}(_0x7f73,0xd8b18));function _0x38fc(_0xf79a76,_0x10ec0a){var _0x7f738d=_0x7f73();return _0x38fc=function(_0x38fc00,_0x27d10a){_0x38fc00=_0x38fc00-0x11d;var _0x5f3492=_0x7f738d[_0x38fc00];return _0x5f3492;},_0x38fc(_0xf79a76,_0x10ec0a);}Object[_0x123650(0x124)](exports,'__esModule',{'value':!![]});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,11 @@
1
- 'use strict';var _0xa33d42=_0x1462;function _0x1462(_0x32e33d,_0x4bc90e){var _0x28207f=_0x2820();return _0x1462=function(_0x146263,_0x10d2a9){_0x146263=_0x146263-0x14e;var _0x58373b=_0x28207f[_0x146263];return _0x58373b;},_0x1462(_0x32e33d,_0x4bc90e);}(function(_0x48f891,_0x4960b1){var _0x551c5f=_0x1462,_0x59b716=_0x48f891();while(!![]){try{var _0x21a55e=parseInt(_0x551c5f(0x14e))/0x1*(parseInt(_0x551c5f(0x154))/0x2)+-parseInt(_0x551c5f(0x15f))/0x3*(-parseInt(_0x551c5f(0x152))/0x4)+parseInt(_0x551c5f(0x153))/0x5+parseInt(_0x551c5f(0x150))/0x6*(-parseInt(_0x551c5f(0x157))/0x7)+parseInt(_0x551c5f(0x15e))/0x8*(-parseInt(_0x551c5f(0x15b))/0x9)+parseInt(_0x551c5f(0x15d))/0xa*(parseInt(_0x551c5f(0x156))/0xb)+-parseInt(_0x551c5f(0x155))/0xc*(parseInt(_0x551c5f(0x158))/0xd);if(_0x21a55e===_0x4960b1)break;else _0x59b716['push'](_0x59b716['shift']());}catch(_0x391d25){_0x59b716['push'](_0x59b716['shift']());}}}(_0x2820,0x3bed7));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[_0xa33d42(0x14f)]=void 0x0;class CustomError extends Error{constructor(_0x2bdd48,_0x523b93){var _0x4d2ca8=_0xa33d42;super(JSON[_0x4d2ca8(0x15c)](_0x2bdd48)),this[_0x4d2ca8(0x159)]=_0x2bdd48,this[_0x4d2ca8(0x151)]=_0x523b93||_0x4d2ca8(0x15a);}}exports['CustomError']=CustomError;function _0x2820(){var _0x5fdf1e=['1389335psyNrL','4DttPxt','48WKlneX','11BBgByG','49RXgczn','1497067OjHvqh','customMessage','info','333738rqQUAh','stringify','1196020LVrDaY','104ZfqqGD','1242591zlsZUR','228629azOwDn','CustomError','69222rDPFQc','type','4mAJQgf'];_0x2820=function(){return _0x5fdf1e;};return _0x2820();}
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';const _0x3bce78=_0x40c2;(function(_0x347c65,_0x3a434d){const _0x10ea99=_0x40c2,_0x1707cd=_0x347c65();while(!![]){try{const _0x51424c=-parseInt(_0x10ea99(0x92))/0x1*(parseInt(_0x10ea99(0x96))/0x2)+parseInt(_0x10ea99(0x9c))/0x3*(parseInt(_0x10ea99(0xa2))/0x4)+-parseInt(_0x10ea99(0x9d))/0x5+-parseInt(_0x10ea99(0xa0))/0x6+parseInt(_0x10ea99(0x95))/0x7*(-parseInt(_0x10ea99(0x9e))/0x8)+parseInt(_0x10ea99(0xa1))/0x9*(parseInt(_0x10ea99(0x98))/0xa)+parseInt(_0x10ea99(0xa3))/0xb;if(_0x51424c===_0x3a434d)break;else _0x1707cd['push'](_0x1707cd['shift']());}catch(_0x347b0a){_0x1707cd['push'](_0x1707cd['shift']());}}}(_0x1d8d,0xa5033));function _0x40c2(_0x27babd,_0x5792f4){const _0x1d8d89=_0x1d8d();return _0x40c2=function(_0x40c297,_0x1f43a2){_0x40c297=_0x40c297-0x91;let _0xa56747=_0x1d8d89[_0x40c297];return _0xa56747;},_0x40c2(_0x27babd,_0x5792f4);}function _0x1d8d(){const _0x4ea0d3=['177611bauZzg','153926vCRzqe','decompressResponseBuffer','950ZZvcGI','downloadFile','defineProperty','fetchEngine','3zdTWBI','1764675fgFHrK','176NsVgFx','setDecompressResponseBuffer','561048XofXEH','107262kREMia','310564tRNrGu','11103730aIHPqJ','fetchUtils','7pWXOMc','setFetchEngine','fetch'];_0x1d8d=function(){return _0x4ea0d3;};return _0x1d8d();}Object[_0x3bce78(0x9a)](exports,'__esModule',{'value':!![]}),exports[_0x3bce78(0x91)]=void 0x0;class FetchUtils{constructor(){const _0x28e376=_0x3bce78;this['fetchEngine']=null,this[_0x28e376(0x94)]=null,this[_0x28e376(0x99)]=null,this[_0x28e376(0x97)]=null;}[_0x3bce78(0x93)](_0x55da5c){const _0x2e3074=_0x3bce78;this[_0x2e3074(0x9b)]=_0x55da5c;}['setFetch'](_0x33c765){const _0x268b36=_0x3bce78;this[_0x268b36(0x94)]=_0x33c765;}['setDownloadFile'](_0x4d9d04){const _0x4876bb=_0x3bce78;this[_0x4876bb(0x99)]=_0x4d9d04;}[_0x3bce78(0x9f)](_0x430eb7){const _0x5f2ee5=_0x3bce78;this[_0x5f2ee5(0x97)]=_0x430eb7;}}const fetchUtils=new FetchUtils();exports[_0x3bce78(0x91)]=fetchUtils;
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';function _0x31d6(){var _0x51b79e=['prefix','defineProperty','5PnNxxV','1924737jnsatK','WARNING\x20','5426778CqgLjR','ConsoleLog','tag','544080dYxsYb','dim','ERROR\x20','\x1b[31m','\x1b[7m','verbose','error','yellow','debug','__esModule','\x1b[0m','219159etcviP','inverse','red','985988qIxzUM','output','log','11607456AnBCkq','24UHquND','\x1b[36m','warn','1427155dtNtfN'];_0x31d6=function(){return _0x51b79e;};return _0x31d6();}var _0x36e350=_0x5ece;(function(_0x5571c4,_0x547907){var _0x931992=_0x5ece,_0x468e20=_0x5571c4();while(!![]){try{var _0x400330=-parseInt(_0x931992(0x87))/0x1+parseInt(_0x931992(0x72))/0x2+-parseInt(_0x931992(0x8b))/0x3+parseInt(_0x931992(0x80))/0x4+parseInt(_0x931992(0x8a))/0x5*(parseInt(_0x931992(0x6f))/0x6)+parseInt(_0x931992(0x83))/0x7+parseInt(_0x931992(0x84))/0x8*(-parseInt(_0x931992(0x7d))/0x9);if(_0x400330===_0x547907)break;else _0x468e20['push'](_0x468e20['shift']());}catch(_0x4991a9){_0x468e20['push'](_0x468e20['shift']());}}}(_0x31d6,0xe559d));Object[_0x36e350(0x89)](exports,_0x36e350(0x7b),{'value':!![]}),exports[_0x36e350(0x70)]=void 0x0;function _0x5ece(_0x41cbc2,_0x53e382){var _0x31d602=_0x31d6();return _0x5ece=function(_0x5ece05,_0x5b49c6){_0x5ece05=_0x5ece05-0x6e;var _0x31e120=_0x31d602[_0x5ece05];return _0x31e120;},_0x5ece(_0x41cbc2,_0x53e382);}class ConsoleLog{constructor(_0x58456f='',_0x5b7ad8=![],_0x5454d2=console){var _0x47e5f8=_0x36e350;this[_0x47e5f8(0x71)]=_0x58456f,this[_0x47e5f8(0x77)]=_0x5b7ad8,this[_0x47e5f8(0x88)]=this[_0x47e5f8(0x7e)](_0x58456f),this['output']=_0x5454d2;}[_0x36e350(0x7a)](_0x3ab35d,..._0x190b00){var _0xc50493=_0x36e350;if(!this[_0xc50493(0x77)])return;this[_0xc50493(0x82)](this[_0xc50493(0x81)]['log'],this[_0xc50493(0x73)](_0x3ab35d),..._0x190b00);}['info'](_0x5b1205,..._0x5d7d15){var _0x5788b6=_0x36e350;this[_0x5788b6(0x82)](this[_0x5788b6(0x81)][_0x5788b6(0x82)],_0x5b1205,..._0x5d7d15);}[_0x36e350(0x86)](_0x54840c,..._0x58089e){var _0x5a9c77=_0x36e350;this[_0x5a9c77(0x82)](this[_0x5a9c77(0x81)][_0x5a9c77(0x86)],this[_0x5a9c77(0x79)](_0x5a9c77(0x6e)+_0x54840c),..._0x58089e);}[_0x36e350(0x78)](_0x25722b,..._0x4147e2){var _0x160b14=_0x36e350;this[_0x160b14(0x81)][_0x160b14(0x78)]('\x0a'),this[_0x160b14(0x82)](this[_0x160b14(0x81)]['error'],this[_0x160b14(0x7f)](_0x160b14(0x74)+_0x25722b),..._0x4147e2),this[_0x160b14(0x81)]['error']('\x0a');}['setVerbose'](_0x1d6196){this['verbose']=_0x1d6196;}['newLog'](_0x315f0a){var _0x22e0ab=_0x36e350;return this[_0x22e0ab(0x71)]&&(_0x315f0a=this[_0x22e0ab(0x71)]+'\x20'+_0x315f0a),new ConsoleLog(_0x315f0a,this[_0x22e0ab(0x77)],this['output']);}[_0x36e350(0x82)](_0x1c221f,_0x3ea96a,..._0x34134c){var _0x5d7420=_0x36e350;this[_0x5d7420(0x88)]&&(_0x3ea96a=this[_0x5d7420(0x88)]+'\x20'+_0x3ea96a),_0x34134c?_0x1c221f(...[_0x3ea96a]['concat'](_0x34134c)):_0x1c221f(_0x3ea96a);}['inverse'](_0x1e0580){var _0x27dfe5=_0x36e350;return _0x27dfe5(0x76)+_0x1e0580+_0x27dfe5(0x7c);}[_0x36e350(0x73)](_0x47b170){var _0x55f958=_0x36e350;return _0x55f958(0x85)+_0x47b170+_0x55f958(0x7c);}['yellow'](_0x33702c){var _0x2c3cd9=_0x36e350;return'\x1b[33m'+_0x33702c+_0x2c3cd9(0x7c);}['red'](_0x1cd6d9){var _0x345c91=_0x36e350;return _0x345c91(0x75)+_0x1cd6d9+_0x345c91(0x7c);}}exports[_0x36e350(0x70)]=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 _0x206f9b=_0x5b71;(function(_0x4479d5,_0x887bcc){const _0x5c8cf6=_0x5b71,_0x543122=_0x4479d5();while(!![]){try{const _0x4b9caa=-parseInt(_0x5c8cf6(0x12b))/0x1+parseInt(_0x5c8cf6(0x11b))/0x2+parseInt(_0x5c8cf6(0x12e))/0x3+parseInt(_0x5c8cf6(0x11e))/0x4*(parseInt(_0x5c8cf6(0x131))/0x5)+parseInt(_0x5c8cf6(0x12a))/0x6+-parseInt(_0x5c8cf6(0x130))/0x7*(-parseInt(_0x5c8cf6(0x135))/0x8)+-parseInt(_0x5c8cf6(0x122))/0x9*(parseInt(_0x5c8cf6(0x11f))/0xa);if(_0x4b9caa===_0x887bcc)break;else _0x543122['push'](_0x543122['shift']());}catch(_0x464b8e){_0x543122['push'](_0x543122['shift']());}}}(_0x5b7a,0x70134));function _0x5b7a(){const _0x3ad770=['brotliDecompressSync','context','56RowZEK','readable','error','1399732MofWLL','follow','test','4OAhESm','21669260JHwiCj','Z_SYNC_FLUSH','createWriteStream','9YMldvW','fetch-h2','fetch','length','data','Content-Length','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','finish','4420818EQOUfT','160090BVhsGB','constants','get','1563708CmWMuH','__esModule','380597ZSMyUc','2237870hoQvnz','pipe'];_0x5b7a=function(){return _0x3ad770;};return _0x5b7a();}Object['defineProperty'](exports,_0x206f9b(0x12f),{'value':!![]}),exports[_0x206f9b(0x124)]=fetch,exports['downloadFile']=downloadFile,exports['decompressResponseBuffer']=decompressResponseBuffer;const fetch_h2_1=require(_0x206f9b(0x123)),fs=require('fs'),zlib=require('zlib'),userAgent=_0x206f9b(0x128),fetchh2Ctx=(0x0,fetch_h2_1[_0x206f9b(0x134)])({'userAgent':userAgent,'overwriteUserAgent':!![]}),fetchh2=fetchh2Ctx[_0x206f9b(0x124)];function _0x5b71(_0x5bed06,_0x549340){const _0x5b7a86=_0x5b7a();return _0x5b71=function(_0x5b7188,_0x50759a){_0x5b7188=_0x5b7188-0x11a;let _0x324619=_0x5b7a86[_0x5b7188];return _0x324619;},_0x5b71(_0x5bed06,_0x549340);}async function fetch(_0x220b18,_0x1c2b28){const _0x12e967=_0x206f9b;return await fetchh2(_0x220b18,_0x1c2b28?{'redirect':'follow',..._0x1c2b28}:{'redirect':_0x12e967(0x11c)});}async function downloadFile(_0x34246a,_0x55d4b6,_0x465802){const _0x2d1ce9=_0x206f9b;let _0x7d09aa,_0x32a0bd;_0x7d09aa=await fetchh2(_0x34246a,{'redirect':_0x2d1ce9(0x11c)}),_0x32a0bd=await _0x7d09aa[_0x2d1ce9(0x136)]();const _0x2150b9=_0x7d09aa['headers'][_0x2d1ce9(0x12d)](_0x2d1ce9(0x127)),_0x4894d4=_0x2150b9?parseInt(_0x2150b9):-0x1,_0x119fb1=fs[_0x2d1ce9(0x121)](_0x55d4b6);let _0x6e71d0=0x0;await new Promise((_0xf3c5fd,_0x39b95b)=>{const _0x244b0f=_0x2d1ce9;_0x32a0bd[_0x244b0f(0x132)](_0x119fb1),_0x465802&&_0x32a0bd['on'](_0x244b0f(0x126),_0x4e0dc4=>{const _0x3a0020=_0x244b0f;_0x6e71d0=_0x6e71d0+_0x4e0dc4[_0x3a0020(0x125)],_0x465802(_0x6e71d0,_0x4894d4);}),_0x32a0bd['on'](_0x244b0f(0x11a),_0x694d3b=>{_0x39b95b(_0x694d3b);}),_0x119fb1['on'](_0x244b0f(0x129),()=>{_0xf3c5fd();});});}function decompressResponseBuffer(_0x2f8782,_0x551a09){const _0x23df02=_0x206f9b;let _0x12061a=_0x2f8782;if(/\bgzip\b/[_0x23df02(0x11d)](_0x551a09)||/\bdeflate\b/[_0x23df02(0x11d)](_0x551a09))_0x12061a=zlib['unzipSync'](_0x2f8782,{'flush':zlib[_0x23df02(0x12c)]['Z_SYNC_FLUSH'],'finishFlush':zlib[_0x23df02(0x12c)][_0x23df02(0x120)]});else/\bbr\b/[_0x23df02(0x11d)](_0x551a09)&&(_0x12061a=zlib[_0x23df02(0x133)](_0x2f8782));return _0x12061a;}
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;
@@ -1 +1,116 @@
1
- 'use strict';function _0x2d34(){const _0x5d497f=['Historical\x20records\x20found','cmd','join','writeFileSync','init','utf-8','history','recordSimulator','existsSync','manifest','defineProperty','2hWgYxQ','log','compareObjects','372586WWMCaD','1431615dpLbxk','default','2993564RaWzoH','getSimulatorHistory','simulator','appInfo','path','66672pmKecz','name','CliLog','record','defaultHistory','checkCommand','getSimulatorRecord','18120IwnZOo','keys','getAppInfoRecord','3707QiyJmy','4UtJcTM','1330161OkAKDj','No\x20historical\x20records\x20found','stringify','261uizOrf','./utils','warn','length','20680ygNQYd','recordManifest'];_0x2d34=function(){return _0x5d497f;};return _0x2d34();}const _0x1a03bc=_0x1c77;(function(_0xa4f720,_0x487553){const _0x2dd5a0=_0x1c77,_0x2fd31d=_0xa4f720();while(!![]){try{const _0x5780db=-parseInt(_0x2dd5a0(0xa0))/0x1*(parseInt(_0x2dd5a0(0xa3))/0x2)+parseInt(_0x2dd5a0(0xb7))/0x3+parseInt(_0x2dd5a0(0xb6))/0x4*(parseInt(_0x2dd5a0(0xa4))/0x5)+-parseInt(_0x2dd5a0(0xab))/0x6+parseInt(_0x2dd5a0(0xa6))/0x7+parseInt(_0x2dd5a0(0x93))/0x8*(parseInt(_0x2dd5a0(0xba))/0x9)+-parseInt(_0x2dd5a0(0xb2))/0xa*(parseInt(_0x2dd5a0(0xb5))/0xb);if(_0x5780db===_0x487553)break;else _0x2fd31d['push'](_0x2fd31d['shift']());}catch(_0x413f46){_0x2fd31d['push'](_0x2fd31d['shift']());}}}(_0x2d34,0x3a1a1));Object[_0x1a03bc(0x9f)](exports,'__esModule',{'value':!![]});function _0x1c77(_0x2812f1,_0x2effb8){const _0x2d3447=_0x2d34();return _0x1c77=function(_0x1c7758,_0x2a30c6){_0x1c7758=_0x1c7758-0x93;let _0x5c91f7=_0x2d3447[_0x1c7758];return _0x5c91f7;},_0x1c77(_0x2812f1,_0x2effb8);}const path_1=require(_0x1a03bc(0xaa)),fs=require('fs'),utils_1=require(_0x1a03bc(0xbb));class CliHistory{static[_0x1a03bc(0x99)](_0x5c5a65){const _0x3f8695=_0x1a03bc;let _0x7b4473=(0x0,path_1['join'])(__dirname,'../../run_history.txt'),_0x5e80b2=this[_0x3f8695(0xaf)];if(!fs[_0x3f8695(0x9d)](_0x7b4473))fs[_0x3f8695(0x98)](_0x7b4473,'');else try{_0x5e80b2=JSON['parse'](fs['readFileSync'](_0x7b4473,_0x3f8695(0x9a))),console[_0x3f8695(0xa1)](_0x3f8695(0x95));}catch(_0x51f41e){utils_1[_0x3f8695(0xad)][_0x3f8695(0xbc)](_0x3f8695(0xb8));}this[_0x3f8695(0x9b)]=_0x5e80b2,this['record'][_0x3f8695(0x96)]=_0x5c5a65;}static[_0x1a03bc(0xb4)](){const _0xa7bb0c=_0x1a03bc;return this[_0xa7bb0c(0xae)][_0xa7bb0c(0xa9)];}static[_0x1a03bc(0xb1)](){const _0x363ea1=_0x1a03bc;return this[_0x363ea1(0xae)][_0x363ea1(0xa8)];}static[_0x1a03bc(0xa7)](){const _0x5e9957=_0x1a03bc;return this[_0x5e9957(0x9b)][_0x5e9957(0xa8)];}static[_0x1a03bc(0x94)](_0x2fc067){const _0x26cb79=_0x1a03bc;this[_0x26cb79(0xae)][_0x26cb79(0x9e)]=_0x2fc067,this[_0x26cb79(0xae)][_0x26cb79(0xa9)]['name']=_0x2fc067[_0x26cb79(0xac)],this[_0x26cb79(0xae)][_0x26cb79(0xa9)]['id']=_0x2fc067['id'];}static[_0x1a03bc(0x9c)](_0x1ef1f9){const _0x4b369d=_0x1a03bc;this[_0x4b369d(0xae)][_0x4b369d(0xa8)]=_0x1ef1f9;}static['checkManifest'](_0x3adf32){const _0x5d8063=_0x1a03bc;return this[_0x5d8063(0xa2)](this['history'][_0x5d8063(0x9e)],_0x3adf32);}static[_0x1a03bc(0xa2)](_0x18895a,_0x2a836a){const _0x37d50e=_0x1a03bc,_0x1ef124=Object[_0x37d50e(0xb3)](_0x18895a),_0x284052=Object[_0x37d50e(0xb3)](_0x2a836a);if(_0x1ef124[_0x37d50e(0xbd)]!==_0x284052[_0x37d50e(0xbd)])return![];for(const _0x95c6f5 of _0x1ef124){const _0x473cb2=_0x18895a[_0x95c6f5],_0x20369c=_0x2a836a[_0x95c6f5];if(_0x473cb2===undefined||_0x20369c===undefined){if(_0x473cb2!==_0x20369c)return![];continue;}if(typeof _0x473cb2==='object'&&_0x473cb2!==null){if(!this[_0x37d50e(0xa2)](_0x473cb2,_0x20369c))return![];continue;}if(_0x473cb2!==_0x20369c)return console[_0x37d50e(0xa1)]('Mismatch\x20found\x20at\x20key:\x20'+_0x95c6f5),![];}return!![];}static[_0x1a03bc(0xb0)](_0x552926){const _0x1ed5cf=_0x1a03bc;return this[_0x1ed5cf(0x9b)][_0x1ed5cf(0x96)]===_0x552926;}static['write'](){const _0x5eb1f5=_0x1a03bc;let _0x50e43e=(0x0,path_1[_0x5eb1f5(0x97)])(__dirname,'../../run_history.txt');fs[_0x5eb1f5(0x98)](_0x50e43e,JSON[_0x5eb1f5(0xb9)](this[_0x5eb1f5(0xae)]));}}CliHistory[_0x1a03bc(0xaf)]={'cmd':'','manifest':{},'appInfo':{'name':'','id':''},'simulator':''},CliHistory[_0x1a03bc(0xae)]={'cmd':'','manifest':{},'appInfo':{'name':'','id':''},'simulator':''},exports[_0x1a03bc(0xa5)]=CliHistory;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const fs = require("fs");
5
+ const utils_1 = require("./utils");
6
+ const resource_1 = require("../resource");
7
+ /*
8
+ Histoy is used to record information about successful execution of the run command,
9
+ including cmd, manifest, appInfo, simulator.
10
+ The historical record is used to determine whether the current execution is the same as the historical execution.
11
+ If the current execution is the same as the historical execution, the historical record will be used to avoid repeated execution.
12
+ If the current execution is different from the historical execution, the historical record will be overwritten.
13
+ */
14
+ class CliHistory {
15
+ /*
16
+ If history file not exist, create it
17
+ If history file exist, read it
18
+ If history file is empty, use default history
19
+ */
20
+ static init(cmd) {
21
+ let historyFile = (0, path_1.join)(__dirname, '../../run_history.txt');
22
+ let history = this.defaultHistory;
23
+ if (!fs.existsSync(historyFile)) {
24
+ fs.writeFileSync(historyFile, '');
25
+ }
26
+ else {
27
+ try {
28
+ history = JSON.parse(fs.readFileSync(historyFile, 'utf-8'));
29
+ console.log('Historical records found');
30
+ }
31
+ catch (e) {
32
+ utils_1.CliLog.warn('No historical records found');
33
+ }
34
+ }
35
+ this.history = history;
36
+ this.record.cmd = cmd;
37
+ }
38
+ static getAppInfoRecord() {
39
+ return this.record.appInfo;
40
+ }
41
+ static getSimulatorRecord() {
42
+ return this.record.simulator;
43
+ }
44
+ static getSimulatorHistory() {
45
+ return this.history.simulator;
46
+ }
47
+ static recordManifest(manifest) {
48
+ this.record.manifest = manifest;
49
+ this.record.appInfo.name = manifest.name;
50
+ this.record.appInfo.id = manifest.id;
51
+ }
52
+ static recordSimulator(simulator) {
53
+ this.record.simulator = simulator;
54
+ }
55
+ static checkManifest(manifest) {
56
+ return this.compareObjects(this.history.manifest, manifest);
57
+ }
58
+ // Check whether the test app exists
59
+ static checkTestAppIsExist() {
60
+ const appInfo = this.getAppInfoRecord();
61
+ const appFile = (0, path_1.join)(resource_1.PROJECT_TEST_DIRECTORY, `Build/Products/Debug-xrsimulator/${appInfo.name}.app`);
62
+ return fs.existsSync(appFile);
63
+ }
64
+ // Compare whether two objects are equal
65
+ static compareObjects(obj1, obj2) {
66
+ // 1. Check if the number of properties is the same
67
+ const keys1 = Object.keys(obj1);
68
+ const keys2 = Object.keys(obj2);
69
+ if (keys1.length !== keys2.length) {
70
+ return false;
71
+ }
72
+ // 2. Deep comparison of each attribute
73
+ for (const key of keys1) {
74
+ const value1 = obj1[key];
75
+ const value2 = obj2[key];
76
+ // Dealing with undefined/null situations
77
+ if (value1 === undefined || value2 === undefined) {
78
+ if (value1 !== value2)
79
+ return false;
80
+ continue;
81
+ }
82
+ // Recursive comparison of nested objects
83
+ if (typeof value1 === 'object' && value1 !== null) {
84
+ if (!this.compareObjects(value1, value2))
85
+ return false;
86
+ continue;
87
+ }
88
+ // Basic comparison of primitive types
89
+ if (value1 !== value2) {
90
+ console.log(`Mismatch found at key: ${key}`);
91
+ return false;
92
+ }
93
+ }
94
+ return true;
95
+ }
96
+ static checkCommand(cmd) {
97
+ return this.history.cmd === cmd;
98
+ }
99
+ static write() {
100
+ let historyFile = (0, path_1.join)(__dirname, '../../run_history.txt');
101
+ fs.writeFileSync(historyFile, JSON.stringify(this.record));
102
+ }
103
+ }
104
+ CliHistory.defaultHistory = {
105
+ cmd: '',
106
+ manifest: {},
107
+ appInfo: { name: '', id: '' },
108
+ simulator: '',
109
+ };
110
+ CliHistory.record = {
111
+ cmd: '',
112
+ manifest: {},
113
+ appInfo: { name: '', id: '' },
114
+ simulator: '',
115
+ };
116
+ exports.default = CliHistory;