@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,208 @@
1
- 'use strict';const _0x138855=_0x2599;(function(_0x3277e6,_0x37f5b0){const _0x400734=_0x2599,_0x4c60bf=_0x3277e6();while(!![]){try{const _0x35b248=parseInt(_0x400734(0x82))/0x1*(parseInt(_0x400734(0xc7))/0x2)+-parseInt(_0x400734(0x97))/0x3*(-parseInt(_0x400734(0x93))/0x4)+parseInt(_0x400734(0xc6))/0x5+parseInt(_0x400734(0x84))/0x6*(parseInt(_0x400734(0x9b))/0x7)+parseInt(_0x400734(0x8e))/0x8*(parseInt(_0x400734(0xba))/0x9)+parseInt(_0x400734(0x9c))/0xa+-parseInt(_0x400734(0x8a))/0xb*(parseInt(_0x400734(0xb2))/0xc);if(_0x35b248===_0x37f5b0)break;else _0x4c60bf['push'](_0x4c60bf['shift']());}catch(_0x4b311b){_0x4c60bf['push'](_0x4c60bf['shift']());}}}(_0x309d,0xabff7));Object[_0x138855(0xc5)](exports,_0x138855(0x87),{'value':!![]}),exports['safelist']=void 0x0,exports[_0x138855(0xaf)]=configId,exports[_0x138855(0xa3)]=configStartUrl,exports[_0x138855(0xc0)]=configScope,exports[_0x138855(0xc9)]=configDisplay,exports['configMainScene']=configMainScene,exports[_0x138855(0x94)]=configDeeplink;const utils_1=require('../utils/utils'),validate_1=require('./validate'),path_1=require('path');function _0x2599(_0x1acc5a,_0x3f5d54){const _0x309d4a=_0x309d();return _0x2599=function(_0x2599d7,_0x5cce06){_0x2599d7=_0x2599d7-0x7d;let _0x186532=_0x309d4a[_0x2599d7];return _0x186532;},_0x2599(_0x1acc5a,_0x3f5d54);}function configId(_0x5f1b13,_0x566af4){const _0x6cbf5e=_0x138855;if(_0x566af4)_0x5f1b13['id']=_0x566af4;else try{const _0x4182be=new URL(_0x5f1b13['id']);let _0x1fe323=_0x4182be[_0x6cbf5e(0xc4)]['split']('.')['reverse']();_0x5f1b13['id']=_0x1fe323[_0x6cbf5e(0xb0)]('.');}catch(_0x380e87){throw new Error(_0x6cbf5e(0x80)+_0x5f1b13['id']+_0x6cbf5e(0xaa));}}function configStartUrl(_0x252201,_0xe11d80,_0x585c8a,_0x37f44a){const _0x27389e=_0x138855;var _0x1b0735;let _0xd50255=(_0x1b0735=_0x252201[_0x27389e(0xb6)])!==null&&_0x1b0735!==void 0x0?_0x1b0735:'/';const _0x176728=(0x0,validate_1[_0x27389e(0xb8)])(_0xd50255),_0x4feee0=_0xe11d80[_0x27389e(0xb3)]>0x0;if(_0x4feee0){const _0x5a325a=(0x0,validate_1[_0x27389e(0xb8)])(_0xe11d80);if(!_0x176728&&!_0x5a325a){const _0x168944=(0x0,path_1[_0x27389e(0x7e)])(_0x27389e(0xc2)),_0x37eb88=(0x0,path_1[_0x27389e(0x7e)])(_0x168944,_0xe11d80,_0xd50255),_0xc2e2cb=(0x0,path_1['normalize'])(_0x37eb88),_0x9fbffc=(0x0,path_1[_0x27389e(0xb0)])(_0x168944,_0xc2e2cb);_0xd50255=(0x0,path_1[_0x27389e(0xca)])(process['cwd'](),_0x9fbffc)[_0x27389e(0xb1)](/^(\.\.\/)+/,'./')[_0x27389e(0xb1)](/\/$/,'');}else{if(_0x176728&&!_0x5a325a){const _0x3a0f9e=new URL(_0xd50255),_0x27d702=_0x3a0f9e[_0x27389e(0x83)]+_0x3a0f9e[_0x27389e(0xa4)]+_0x3a0f9e['hash'];let _0x4adaa1=new URL(_0xe11d80,_0x3a0f9e[_0x27389e(0x9e)]);_0xd50255=new URL(_0x27d702,_0x4adaa1)[_0x27389e(0x92)];}else{if(!_0x176728&&_0x5a325a){if(_0xd50255['startsWith']('/')){const _0x2de9d2=new URL(_0xe11d80);_0xd50255=_0x2de9d2['origin']+(0x0,path_1[_0x27389e(0xb0)])(_0x2de9d2['pathname'],_0xd50255);}else _0xd50255=new URL(_0xd50255,_0xe11d80)[_0x27389e(0x92)];}else{if(_0x176728&&_0x5a325a){const _0x1e6b02=new URL(_0xd50255),_0x243daf=new URL(_0xe11d80),_0x1ea35d=_0x1e6b02['pathname']+_0x1e6b02['search']+_0x1e6b02[_0x27389e(0x9f)];_0xd50255=new URL(_0x1ea35d,_0x243daf[_0x27389e(0x9e)]+_0x243daf[_0x27389e(0x83)])[_0x27389e(0x92)];}}}}}else{if(_0x37f44a){const _0x18e065=new URL(_0x585c8a);if(!_0x176728){const _0xebb035=new URL(_0xd50255,_0x18e065[_0x27389e(0x9e)]);_0xd50255=_0xebb035[_0x27389e(0x92)];}else{const _0x3dae3f=new URL(_0xd50255);_0xd50255=_0x18e065['origin']+_0x3dae3f[_0x27389e(0x83)]+_0x3dae3f[_0x27389e(0xa4)]+_0x3dae3f['hash'];}}else{if(!_0x176728){const _0x3d7b4d=(0x0,path_1['resolve'])(_0x27389e(0xc2)),_0x563fac=(0x0,path_1['resolve'])(_0x3d7b4d,_0xd50255),_0x20704e=(0x0,path_1['normalize'])(_0x563fac),_0x5cfe46=(0x0,path_1[_0x27389e(0xb0)])(_0x3d7b4d,_0x20704e);_0xd50255=(0x0,path_1[_0x27389e(0xca)])(process['cwd'](),_0x5cfe46)[_0x27389e(0xb1)](/^(\.\.\/)+/,'./')[_0x27389e(0xb1)](/\/$/,'');}}}return _0xd50255;}function configScope(_0x2c88e9){const _0x2f6b5f=_0x138855;var _0x1653c9;let _0x3c1573=(_0x1653c9=_0x2c88e9['scope'])!==null&&_0x1653c9!==void 0x0?_0x1653c9:'/';const _0x4c6720=(0x0,validate_1[_0x2f6b5f(0xb8)])(_0x2c88e9['start_url']),_0x4744a9=(0x0,validate_1[_0x2f6b5f(0xb8)])(_0x3c1573);if(_0x4c6720&&_0x4744a9){const _0x35937d=new URL(_0x3c1573),_0x1e1181=new URL(_0x2c88e9['start_url']);(_0x35937d['host']!==_0x1e1181['host']||_0x2c88e9[_0x2f6b5f(0xb6)][_0x2f6b5f(0xbd)](_0x3c1573)!==0x0)&&(_0x3c1573=(0x0,utils_1[_0x2f6b5f(0xc3)])(_0x2c88e9[_0x2f6b5f(0xb6)]));}else{if(_0x4c6720&&!_0x4744a9)_0x3c1573=new URL(_0x3c1573,_0x2c88e9[_0x2f6b5f(0xb6)])[_0x2f6b5f(0x92)];else{if(!_0x4c6720&&_0x4744a9){const _0x4fe520=_0x2c88e9[_0x2f6b5f(0xb6)][_0x2f6b5f(0xb1)](/\/[^\/]+$/,'');_0x3c1573=(0x0,path_1['normalize'])(_0x4fe520+'/');}else _0x3c1573=(0x0,path_1[_0x2f6b5f(0xb0)])((0x0,utils_1[_0x2f6b5f(0xc3)])(_0x2c88e9['start_url']),_0x3c1573);}}_0x2c88e9[_0x2f6b5f(0x86)]=_0x3c1573;}function configDisplay(_0x4978ee){const _0x39298e=_0x138855;let _0xb23ed6=_0x4978ee[_0x39298e(0xbb)];const _0x452926=[_0x39298e(0x95),_0x39298e(0x88),_0x39298e(0x8f)];!_0x452926[_0x39298e(0xac)](_0xb23ed6)&&(_0xb23ed6='standalone');if(_0x4978ee[_0x39298e(0x89)]&&_0x4978ee[_0x39298e(0x89)]['length']>0x0){const _0x3acd26=_0x4978ee[_0x39298e(0x89)][_0x39298e(0xb4)]((_0xece9c5,_0x90f47)=>({'mode':_0xece9c5,'index':_0x90f47}))[_0x39298e(0xa7)](({mode:_0x17522a})=>_0x452926['includes'](_0x17522a))['sort']((_0x5ec8e9,_0x31e72c)=>_0x5ec8e9[_0x39298e(0xae)]-_0x31e72c[_0x39298e(0xae)]);_0x3acd26[_0x39298e(0xb3)]>0x0&&(_0xb23ed6=_0x3acd26[0x0][_0x39298e(0xa2)]);}_0x4978ee['display']=_0xb23ed6;}function _0x309d(){const _0x13f1dc=['join','replace','3168IGIvoA','length','map','ftps','start_url','protocol_handlers','validateURL','sms','2772666LrczNU','display','urn','indexOf','nntp','string','configScope','object','./static-web','parseRouter','host','defineProperty','854590nnXcNR','1931068flJlox','height','configDisplay','relative','ftp','smsto','tel','geo','resolve','url','id:','dynamic','1pWNCnN','pathname','42inYmsd','safelist','scope','__esModule','standalone','display_override','108053szTocc','magnet','default_size','bitcoin','24vmhODa','fullscreen','mainScene','width','href','4FCYKfb','configDeeplink','minimal-ui','matrix','442227cvlZSE','protocol','defaultSize','mms','398461hJlRWP','6912310TeOIjA','webcal','origin','hash','resizability','automatic','mode','configStartUrl','search','web+','sip','filter','xr_main_scene','ssh','\x20\x20is\x20not\x20a\x20valid\x20url','wtai','includes','ircs','index','configId'];_0x309d=function(){return _0x13f1dc;};return _0x309d();}function configMainScene(_0x2b707a){const _0x336464=_0x138855;var _0x2a5ee4,_0x8f78fa;const _0x235883=[_0x336464(0xa1),'contentMinSize','contentSize'];let _0x31ed15={'defaultSize':{'width':0x500,'height':0x500},'resizability':_0x336464(0xa1)};if(_0x2b707a[_0x336464(0xa8)]){if(typeof _0x2b707a['xr_main_scene']===_0x336464(0xc1))_0x31ed15[_0x336464(0x99)]['width']=Number((_0x2a5ee4=_0x2b707a[_0x336464(0xa8)][_0x336464(0x8c)])===null||_0x2a5ee4===void 0x0?void 0x0:_0x2a5ee4[_0x336464(0x91)])>0x0?_0x2b707a['xr_main_scene']['default_size'][_0x336464(0x91)]:0x500,_0x31ed15[_0x336464(0x99)][_0x336464(0xc8)]=Number((_0x8f78fa=_0x2b707a[_0x336464(0xa8)]['default_size'])===null||_0x8f78fa===void 0x0?void 0x0:_0x8f78fa[_0x336464(0xc8)])>0x0?_0x2b707a[_0x336464(0xa8)][_0x336464(0x8c)][_0x336464(0xc8)]:0x500,_0x31ed15['resizability']=_0x235883['includes'](_0x2b707a['xr_main_scene'][_0x336464(0xa0)])?_0x2b707a[_0x336464(0xa8)][_0x336464(0xa0)]:_0x336464(0xa1),_0x2b707a[_0x336464(0x90)]=_0x31ed15;else typeof _0x2b707a['xr_main_scene']===_0x336464(0xbf)&&(_0x2b707a['mainScene']=_0x336464(0x81));}}function configDeeplink(_0x34092a){const _0x1d70a6=_0x138855;if(_0x34092a['protocol_handlers']&&_0x34092a['protocol_handlers']['length']>0x0)for(var _0x455322=0x0;_0x455322<_0x34092a[_0x1d70a6(0xb7)][_0x1d70a6(0xb3)];_0x455322++){const _0x29bc64=_0x34092a['protocol_handlers'][_0x455322];if(_0x29bc64[_0x1d70a6(0x98)]&&(exports[_0x1d70a6(0x85)][_0x1d70a6(0xac)](_0x29bc64[_0x1d70a6(0x98)])||_0x29bc64[_0x1d70a6(0x98)][_0x1d70a6(0xbd)](_0x1d70a6(0xa5))===0x0)){if(!((0x0,validate_1[_0x1d70a6(0xb8)])(_0x29bc64['url'])&&_0x29bc64[_0x1d70a6(0x7f)][_0x1d70a6(0xbd)](_0x34092a[_0x1d70a6(0x86)])<0x0))continue;}_0x34092a[_0x1d70a6(0xb7)]['splice'](_0x455322,0x1),_0x455322--;}}exports[_0x138855(0x85)]=[_0x138855(0x8d),_0x138855(0xcb),_0x138855(0xb5),_0x138855(0x7d),'im','irc',_0x138855(0xad),_0x138855(0x8b),'mailto',_0x138855(0x96),_0x138855(0x9a),'news',_0x138855(0xbe),'openpgp4fpr','sftp',_0x138855(0xa6),_0x138855(0xb9),_0x138855(0xcc),_0x138855(0xa9),_0x138855(0xcd),_0x138855(0xbc),_0x138855(0x9d),_0x138855(0xab),'xmpp'];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safelist = void 0;
4
+ exports.configId = configId;
5
+ exports.configStartUrl = configStartUrl;
6
+ exports.configScope = configScope;
7
+ exports.configDisplay = configDisplay;
8
+ exports.configMainScene = configMainScene;
9
+ exports.configDeeplink = configDeeplink;
10
+ const utils_1 = require("../utils/utils");
11
+ const validate_1 = require("./validate");
12
+ const path_1 = require("path");
13
+ function configId(manifestJson, bundleId) {
14
+ if (bundleId) {
15
+ manifestJson.id = bundleId;
16
+ }
17
+ else {
18
+ try {
19
+ const url = new URL(manifestJson.id);
20
+ let arr = url.host.split('.').reverse();
21
+ manifestJson.id = arr.join('.');
22
+ }
23
+ catch (e) {
24
+ throw new Error(`id:${manifestJson.id} is not a valid url`);
25
+ }
26
+ }
27
+ }
28
+ function configStartUrl(manifestJson, base, manifestUrl, isNet) {
29
+ var _a;
30
+ let start_url = (_a = manifestJson.start_url) !== null && _a !== void 0 ? _a : '/index.html';
31
+ const isStartUrl = (0, validate_1.validateURL)(start_url);
32
+ const hasBase = base.length > 0;
33
+ if (hasBase) {
34
+ const isBaseUrl = (0, validate_1.validateURL)(base);
35
+ if (!isStartUrl && !isBaseUrl) {
36
+ const staticWebRoot = (0, path_1.resolve)('./static-web');
37
+ const resolvedPath = (0, path_1.resolve)(staticWebRoot, base, start_url);
38
+ const normalizedPath = (0, path_1.normalize)(resolvedPath);
39
+ const safePath = (0, path_1.join)(staticWebRoot, normalizedPath);
40
+ start_url = (0, path_1.relative)(process.cwd(), safePath)
41
+ .replace(/^(\.\.\/)+/, './')
42
+ .replace(/\/$/, '');
43
+ }
44
+ else if (isStartUrl && !isBaseUrl) {
45
+ const startUrl = new URL(start_url);
46
+ const fullPath = startUrl.pathname + startUrl.search + startUrl.hash;
47
+ let newBase = new URL(base, startUrl.origin);
48
+ start_url = new URL(fullPath, newBase).href;
49
+ }
50
+ else if (!isStartUrl && isBaseUrl) {
51
+ if (start_url.startsWith('/')) {
52
+ const baseUrl = new URL(base);
53
+ start_url = baseUrl.origin + (0, path_1.join)(baseUrl.pathname, start_url);
54
+ }
55
+ else {
56
+ start_url = new URL(start_url, base).href;
57
+ }
58
+ }
59
+ else if (isStartUrl && isBaseUrl) {
60
+ const startUrl = new URL(start_url);
61
+ const baseUrl = new URL(base);
62
+ const startFullPath = startUrl.pathname + startUrl.search + startUrl.hash;
63
+ start_url = new URL(startFullPath, baseUrl.origin + baseUrl.pathname).href;
64
+ }
65
+ }
66
+ else {
67
+ if (isNet) {
68
+ const murl = new URL(manifestUrl);
69
+ if (!isStartUrl) {
70
+ const newStartUrl = new URL(start_url, murl.origin);
71
+ start_url = newStartUrl.href;
72
+ }
73
+ else {
74
+ const startUrl = new URL(start_url);
75
+ start_url =
76
+ murl.origin + startUrl.pathname + startUrl.search + startUrl.hash;
77
+ }
78
+ }
79
+ else if (!isStartUrl) {
80
+ const staticWebRoot = (0, path_1.resolve)('./static-web');
81
+ const resolvedPath = (0, path_1.resolve)(staticWebRoot, start_url);
82
+ const normalizedPath = (0, path_1.normalize)(resolvedPath);
83
+ const safePath = (0, path_1.join)(staticWebRoot, normalizedPath);
84
+ start_url = (0, path_1.relative)(process.cwd(), safePath)
85
+ .replace(/^(\.\.\/)+/, './')
86
+ .replace(/\/$/, '');
87
+ }
88
+ }
89
+ return start_url;
90
+ }
91
+ function configScope(manifestJson) {
92
+ var _a;
93
+ let scope = (_a = manifestJson.scope) !== null && _a !== void 0 ? _a : '/';
94
+ const isStartUrl = (0, validate_1.validateURL)(manifestJson.start_url);
95
+ const isUrl = (0, validate_1.validateURL)(scope);
96
+ if (isStartUrl && isUrl) {
97
+ const scopeURL = new URL(scope);
98
+ const startURL = new URL(manifestJson.start_url);
99
+ if (scopeURL.host !== startURL.host ||
100
+ manifestJson.start_url.indexOf(scope) !== 0) {
101
+ scope = (0, utils_1.parseRouter)(manifestJson.start_url);
102
+ }
103
+ }
104
+ else if (isStartUrl && !isUrl) {
105
+ scope = new URL(scope, manifestJson.start_url).href;
106
+ }
107
+ else if (!isStartUrl && isUrl) {
108
+ const cleanPath = manifestJson.start_url.replace(/\/[^\/]+$/, '');
109
+ scope = (0, path_1.normalize)(cleanPath + '/');
110
+ }
111
+ else {
112
+ scope = (0, path_1.join)((0, utils_1.parseRouter)(manifestJson.start_url), scope);
113
+ }
114
+ manifestJson.scope = scope;
115
+ }
116
+ function configDisplay(manifestJson) {
117
+ let display = manifestJson.display;
118
+ const modes = ['minimal-ui', 'standalone', 'fullscreen'];
119
+ if (!modes.includes(display)) {
120
+ display = 'standalone';
121
+ }
122
+ if (manifestJson.display_override &&
123
+ manifestJson.display_override.length > 0) {
124
+ const validModes = manifestJson.display_override
125
+ .map((mode, index) => ({ mode, index }))
126
+ .filter(({ mode }) => modes.includes(mode))
127
+ .sort((a, b) => a.index - b.index);
128
+ if (validModes.length > 0) {
129
+ display = validModes[0].mode;
130
+ }
131
+ }
132
+ manifestJson.display = display;
133
+ }
134
+ function configMainScene(manifestJson) {
135
+ var _a, _b;
136
+ const resizabilities = ['automatic', 'contentMinSize', 'contentSize'];
137
+ let mainScene = {
138
+ defaultSize: {
139
+ width: 1280,
140
+ height: 1280,
141
+ },
142
+ resizability: 'automatic',
143
+ };
144
+ if (manifestJson.xr_main_scene) {
145
+ if (typeof manifestJson.xr_main_scene === 'object') {
146
+ mainScene.defaultSize.width =
147
+ Number((_a = manifestJson.xr_main_scene.default_size) === null || _a === void 0 ? void 0 : _a.width) > 0
148
+ ? manifestJson.xr_main_scene.default_size.width
149
+ : 1280;
150
+ mainScene.defaultSize.height =
151
+ Number((_b = manifestJson.xr_main_scene.default_size) === null || _b === void 0 ? void 0 : _b.height) > 0
152
+ ? manifestJson.xr_main_scene.default_size.height
153
+ : 1280;
154
+ mainScene.resizability = resizabilities.includes(manifestJson.xr_main_scene.resizability)
155
+ ? manifestJson.xr_main_scene.resizability
156
+ : 'automatic';
157
+ manifestJson.mainScene = mainScene;
158
+ }
159
+ else if (typeof manifestJson.xr_main_scene === 'string') {
160
+ manifestJson.mainScene = 'dynamic'; // only support this
161
+ }
162
+ // other type like string should be ignored
163
+ }
164
+ }
165
+ function configDeeplink(manifestJson) {
166
+ if (manifestJson.protocol_handlers &&
167
+ manifestJson.protocol_handlers.length > 0) {
168
+ for (var i = 0; i < manifestJson.protocol_handlers.length; i++) {
169
+ const item = manifestJson.protocol_handlers[i];
170
+ // The DeepLink protocol must be on the security list or start with web+
171
+ if (item.protocol &&
172
+ (exports.safelist.includes(item.protocol) ||
173
+ item.protocol.indexOf('web+') === 0)) {
174
+ // If the URL is an absolute path, it must be within the scope range
175
+ if (!((0, validate_1.validateURL)(item.url) && item.url.indexOf(manifestJson.scope) < 0))
176
+ continue;
177
+ }
178
+ manifestJson.protocol_handlers.splice(i, 1);
179
+ i--;
180
+ }
181
+ }
182
+ }
183
+ exports.safelist = [
184
+ 'bitcoin',
185
+ 'ftp',
186
+ 'ftps',
187
+ 'geo',
188
+ 'im',
189
+ 'irc',
190
+ 'ircs',
191
+ 'magnet',
192
+ 'mailto',
193
+ 'matrix',
194
+ 'mms',
195
+ 'news',
196
+ 'nntp',
197
+ 'openpgp4fpr',
198
+ 'sftp',
199
+ 'sip',
200
+ 'sms',
201
+ 'smsto',
202
+ 'ssh',
203
+ 'tel',
204
+ 'urn',
205
+ 'webcal',
206
+ 'wtai',
207
+ 'xmpp',
208
+ ];
@@ -1 +1,92 @@
1
- 'use strict';function _0x3155(){const _0x1e5154=['generator','CliLog','minimal-ui','932070aZjLtD','defaultBundleId','configDisplay','210uVbfJh','852mKNzhH','join','configStartUrl','1101eLNlXA','public/manifest.json','json','configId','PWAGenerator','path','loadJsonFromNet','bundleId','37818XjfcDx','defaultManifestJson','cwd','checkIcons','checkId','configDeeplink','standalone','manifestUrl','start_url','validate','defineProperty','../utils/utils','manifest','useDefaultManifestJson','300953EHOsAt','loadJsonFromDisk','16746pIvvjT','reset\x20manifest.json:\x20ok','./config','__esModule','checkStartUrl','configScope','check\x20manifest.json:\x20ok','config','413890UPNgiW','com.webspatial.test','DisplayModes','13840Movvnv','../resource/load','manifest.json\x20or\x20manifest.webmanifest\x20not\x20found,\x20use\x20default\x20in\x20run\x20mode','WebSpatialTest','log','525AnFyHx','public/manifest.webmanifest','configMainScene','existsSync'];_0x3155=function(){return _0x1e5154;};return _0x3155();}const _0x12e3aa=_0x2f48;(function(_0x48bc57,_0x125c88){const _0x17372c=_0x2f48,_0x282665=_0x48bc57();while(!![]){try{const _0x3d0ea0=-parseInt(_0x17372c(0x1fa))/0x1+parseInt(_0x17372c(0x204))/0x2+-parseInt(_0x17372c(0x1e4))/0x3*(parseInt(_0x17372c(0x1e1))/0x4)+-parseInt(_0x17372c(0x1d6))/0x5*(-parseInt(_0x17372c(0x1fc))/0x6)+parseInt(_0x17372c(0x1e0))/0x7*(parseInt(_0x17372c(0x1d1))/0x8)+parseInt(_0x17372c(0x1ec))/0x9+parseInt(_0x17372c(0x1dd))/0xa;if(_0x3d0ea0===_0x125c88)break;else _0x282665['push'](_0x282665['shift']());}catch(_0xf7444b){_0x282665['push'](_0x282665['shift']());}}}(_0x3155,0x41f69));Object[_0x12e3aa(0x1f6)](exports,_0x12e3aa(0x1ff),{'value':!![]}),exports[_0x12e3aa(0x1e8)]=void 0x0;const path_1=require(_0x12e3aa(0x1e9)),config_1=require(_0x12e3aa(0x1fe)),load_1=require(_0x12e3aa(0x1d2)),validate_1=require('./validate'),fs=require('fs'),utils_1=require(_0x12e3aa(0x1f7));class PWAGenerator{static async[_0x12e3aa(0x1da)](_0x3bf6b8,_0x324d02=![]){const _0x4ae1a0=_0x12e3aa;let _0x2baa42=await this[_0x4ae1a0(0x1f5)](_0x3bf6b8,_0x324d02);return console[_0x4ae1a0(0x1d5)](_0x4ae1a0(0x202)),await this[_0x4ae1a0(0x203)](_0x2baa42,_0x3bf6b8,_0x324d02),console['log'](_0x4ae1a0(0x1fd)),_0x2baa42;}static async[_0x12e3aa(0x1f5)](_0xf16a5a,_0x181979=![]){const _0x5280c6=_0x12e3aa;var _0x3b5c1d,_0x48acf3;let _0x4caef6={},_0x49cbf0='',_0x23dd66=![],_0x5d63ff=![];if(_0xf16a5a[_0x5280c6(0x1f3)])_0x49cbf0=_0xf16a5a[_0x5280c6(0x1f3)],_0x23dd66=!![],_0x4caef6=await(0x0,load_1[_0x5280c6(0x1ea)])(_0xf16a5a[_0x5280c6(0x1f3)]);else{_0xf16a5a[_0x5280c6(0x1f8)]?_0x49cbf0=(0x0,path_1[_0x5280c6(0x1e2)])(process[_0x5280c6(0x1ee)](),_0xf16a5a[_0x5280c6(0x1f8)]):(_0x49cbf0=(0x0,path_1[_0x5280c6(0x1e2)])(process[_0x5280c6(0x1ee)](),_0x5280c6(0x1e5)),!fs[_0x5280c6(0x1d9)](_0x49cbf0)&&(_0x49cbf0=(0x0,path_1[_0x5280c6(0x1e2)])(process[_0x5280c6(0x1ee)](),_0x5280c6(0x1d7))));if(!fs[_0x5280c6(0x1d9)](_0x49cbf0)){if(_0x181979)_0x5d63ff=!![],utils_1[_0x5280c6(0x1db)]['warn'](_0x5280c6(0x1d3));else throw new Error('manifest.json\x20or\x20manifest.webmanifest\x20not\x20found');}_0x4caef6=_0x5d63ff?this[_0x5280c6(0x1ed)]:await(0x0,load_1[_0x5280c6(0x1fb)])(_0x49cbf0),this[_0x5280c6(0x1f9)]=_0x5d63ff;}(0x0,validate_1['checkManifestJson'])(_0x4caef6,_0x181979);let _0x5d6386=(0x0,config_1[_0x5280c6(0x1e3)])(_0x4caef6,(_0x3b5c1d=_0xf16a5a['base'])!==null&&_0x3b5c1d!==void 0x0?_0x3b5c1d:'',_0x49cbf0,_0x23dd66);var _0x427317=(0x0,validate_1[_0x5280c6(0x200)])(_0x5d6386,_0x49cbf0,_0x23dd66,_0x181979);_0x4caef6[_0x5280c6(0x1f4)]=_0x5d6386;if(!_0x181979)(0x0,validate_1[_0x5280c6(0x1f0)])(_0x4caef6,(_0x48acf3=_0xf16a5a[_0x5280c6(0x1eb)])!==null&&_0x48acf3!==void 0x0?_0x48acf3:'');return await(0x0,validate_1[_0x5280c6(0x1ef)])(_0x4caef6,_0x49cbf0,_0x181979),{'json':_0x4caef6,'url':_0x49cbf0,'fromNet':_0x427317};}static['config'](_0x5e5620,_0x4ced87,_0x2a20a9){const _0x52d014=_0x12e3aa;var _0x4eadb1;let _0x459a53=(_0x4eadb1=_0x4ced87[_0x52d014(0x1eb)])!==null&&_0x4eadb1!==void 0x0?_0x4eadb1:'';_0x2a20a9&&!_0x5e5620[_0x52d014(0x1e6)]['id']&&(_0x459a53=this[_0x52d014(0x1de)]),(0x0,config_1[_0x52d014(0x1e7)])(_0x5e5620[_0x52d014(0x1e6)],_0x459a53),(0x0,config_1[_0x52d014(0x201)])(_0x5e5620['json']),(0x0,config_1[_0x52d014(0x1df)])(_0x5e5620[_0x52d014(0x1e6)]),(0x0,config_1[_0x52d014(0x1f1)])(_0x5e5620[_0x52d014(0x1e6)]),(0x0,config_1[_0x52d014(0x1d8)])(_0x5e5620[_0x52d014(0x1e6)]);}}function _0x2f48(_0x169df1,_0xf97bde){const _0x315584=_0x3155();return _0x2f48=function(_0x2f48a7,_0x59e765){_0x2f48a7=_0x2f48a7-0x1d0;let _0x263e82=_0x315584[_0x2f48a7];return _0x263e82;},_0x2f48(_0x169df1,_0xf97bde);}exports[_0x12e3aa(0x1e8)]=PWAGenerator,PWAGenerator[_0x12e3aa(0x1d0)]=[_0x12e3aa(0x1f2),_0x12e3aa(0x1dc)],PWAGenerator['defaultBundleId']=_0x12e3aa(0x205),PWAGenerator['defaultManifestJson']={'name':_0x12e3aa(0x1d4),'display':_0x12e3aa(0x1dc),'start_url':'/','scope':'/'},PWAGenerator[_0x12e3aa(0x1f9)]=![];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PWAGenerator = void 0;
4
+ const path_1 = require("path");
5
+ const config_1 = require("./config");
6
+ const load_1 = require("../resource/load");
7
+ const validate_1 = require("./validate");
8
+ const fs = require("fs");
9
+ const utils_1 = require("../utils/utils");
10
+ class PWAGenerator {
11
+ static async generator(args, isDev = false) {
12
+ let manifestInfo = await this.validate(args, isDev);
13
+ console.log('check manifest.json: ok');
14
+ await this.config(manifestInfo, args, isDev);
15
+ console.log('reset manifest.json: ok');
16
+ return manifestInfo;
17
+ }
18
+ static async validate(args, isDev = false) {
19
+ var _a, _b;
20
+ let manifest = {};
21
+ let url = '';
22
+ let fromNet = false;
23
+ let useDefault = false;
24
+ // load manifest.json
25
+ if (args['manifestUrl']) {
26
+ url = args['manifestUrl'];
27
+ fromNet = true;
28
+ manifest = await (0, load_1.loadJsonFromNet)(args['manifestUrl']);
29
+ }
30
+ else {
31
+ if (args['manifest']) {
32
+ url = (0, path_1.join)(process.cwd(), args['manifest']);
33
+ }
34
+ else {
35
+ url = (0, path_1.join)(process.cwd(), 'public/manifest.json');
36
+ if (!fs.existsSync(url)) {
37
+ url = (0, path_1.join)(process.cwd(), 'public/manifest.webmanifest');
38
+ }
39
+ }
40
+ if (!fs.existsSync(url)) {
41
+ if (isDev) {
42
+ useDefault = true;
43
+ utils_1.CliLog.warn('manifest.json or manifest.webmanifest not found, use default in run mode');
44
+ }
45
+ else {
46
+ throw new Error('manifest.json or manifest.webmanifest not found');
47
+ }
48
+ }
49
+ manifest = useDefault
50
+ ? this.defaultManifestJson
51
+ : await (0, load_1.loadJsonFromDisk)(url);
52
+ this.useDefaultManifestJson = useDefault;
53
+ }
54
+ // check manifest.json
55
+ (0, validate_1.checkManifestJson)(manifest, isDev);
56
+ let start_url = (0, config_1.configStartUrl)(manifest, (_a = args['base']) !== null && _a !== void 0 ? _a : '', url, fromNet);
57
+ var isNetWeb = (0, validate_1.checkStartUrl)(start_url, url, fromNet, isDev);
58
+ manifest.start_url = start_url;
59
+ if (!isDev)
60
+ (0, validate_1.checkId)(manifest, (_b = args['bundleId']) !== null && _b !== void 0 ? _b : '');
61
+ await (0, validate_1.checkIcons)(manifest, url, isDev);
62
+ return {
63
+ json: manifest,
64
+ url,
65
+ fromNet: isNetWeb,
66
+ };
67
+ }
68
+ // generate manifest
69
+ static config(manifestInfo, args, isDev) {
70
+ var _a;
71
+ let bundleId = (_a = args['bundleId']) !== null && _a !== void 0 ? _a : '';
72
+ if (isDev && !manifestInfo.json.id) {
73
+ bundleId = this.defaultBundleId;
74
+ }
75
+ (0, config_1.configId)(manifestInfo.json, bundleId);
76
+ (0, config_1.configScope)(manifestInfo.json);
77
+ (0, config_1.configDisplay)(manifestInfo.json);
78
+ (0, config_1.configDeeplink)(manifestInfo.json);
79
+ (0, config_1.configMainScene)(manifestInfo.json);
80
+ }
81
+ }
82
+ exports.PWAGenerator = PWAGenerator;
83
+ // Supported display modes for TWA
84
+ PWAGenerator.DisplayModes = ['standalone', 'minimal-ui'];
85
+ PWAGenerator.defaultBundleId = 'com.webspatial.test';
86
+ PWAGenerator.defaultManifestJson = {
87
+ name: 'WebSpatialTest',
88
+ display: 'minimal-ui',
89
+ start_url: '/index.html',
90
+ scope: '/',
91
+ };
92
+ PWAGenerator.useDefaultManifestJson = false;
@@ -1 +1,240 @@
1
- 'use strict';const _0x2cbd88=_0x4509;function _0x4509(_0x181088,_0x5cdde2){const _0x150aca=_0x150a();return _0x4509=function(_0x4509b1,_0x3c039b){_0x4509b1=_0x4509b1-0x15c;let _0x37477a=_0x150aca[_0x4509b1];return _0x37477a;},_0x4509(_0x181088,_0x5cdde2);}(function(_0x2d4eb0,_0x351910){const _0x3636a7=_0x4509,_0x4bc5d6=_0x2d4eb0();while(!![]){try{const _0x34ffa9=-parseInt(_0x3636a7(0x161))/0x1+-parseInt(_0x3636a7(0x18a))/0x2*(parseInt(_0x3636a7(0x18c))/0x3)+parseInt(_0x3636a7(0x180))/0x4*(-parseInt(_0x3636a7(0x186))/0x5)+parseInt(_0x3636a7(0x184))/0x6*(parseInt(_0x3636a7(0x15c))/0x7)+-parseInt(_0x3636a7(0x174))/0x8*(parseInt(_0x3636a7(0x193))/0x9)+-parseInt(_0x3636a7(0x16f))/0xa+parseInt(_0x3636a7(0x17d))/0xb;if(_0x34ffa9===_0x351910)break;else _0x4bc5d6['push'](_0x4bc5d6['shift']());}catch(_0x5176a6){_0x4bc5d6['push'](_0x4bc5d6['shift']());}}}(_0x150a,0x8b3ce));Object[_0x2cbd88(0x185)](exports,_0x2cbd88(0x16b),{'value':!![]}),exports[_0x2cbd88(0x162)]=checkManifestJson,exports[_0x2cbd88(0x167)]=checkStartUrl,exports[_0x2cbd88(0x175)]=checkIcons,exports['checkId']=checkId,exports[_0x2cbd88(0x18f)]=validateBundleId,exports['validateURL']=validateURL;function _0x150a(){const _0xe9331f=['Local\x20manifest\x20cannot\x20package\x20network\x20project','2182836iBTkTP','icon\x20not\x20found,\x20use\x20default\x20in\x20run\x20mode','3myalqs','In\x20the\x20Web\x20Spatial\x20App\x20Manifest,\x20the\x20icons\x20property\x20must\x20be\x20provided\x20and\x20it\x20should\x20include\x20at\x20least\x20one\x20icon\x20object','warn','validateBundleId','../resource/imageHelper','../utils/CustomError','In\x20the\x20Web\x20Spatial\x20App\x20Manifest,\x20the\x20start_url\x20must\x20use\x20https','1333917ENoKVz','CustomError','3871DCKmhp','indexOf','In\x20the\x20Web\x20Spatial\x20App\x20Manifest,\x20the\x20bundle\x20ID\x20must\x20be\x20in\x20reverse\x20domain\x20format\x20(e.g.\x20com.example.app)\x20and\x20no\x20longer\x20than\x20128\x20characters','http://','CliLog','617432ubpZAM','checkManifestJson','icons','../utils/utils','startsWith','split','checkStartUrl','maskable','In\x20the\x20Web\x20Spatial\x20App\x20on\x20VisionPro,\x20the\x20icon\x20must\x20be\x20greater\x20than\x20or\x20equal\x20to\x201024x1024,\x20and\x20the\x20purpose\x20parameter\x20must\x20include\x20maskable','push','__esModule','path','ImageHelper','In\x20the\x20Web\x20Spatial\x20App\x20on\x20VisionPro,\x20must\x20be\x20a\x20fully\x20opaque\x20bitmap.','3424010HjxkEH','loadImageFromNet','src','getWidth','In\x20the\x20Web\x20Spatial\x20App\x20Manifest,\x20the\x20id\x20or\x20start_url\x20must\x20be\x20a\x20valid\x20URL,\x20or\x20provide\x20it\x20use\x20--bundle-id','24psvUdq','checkIcons','In\x20the\x20WebSpatial\x20App\x20Manifest,\x20the\x20start_url\x20must\x20be\x20the\x20same\x20origin\x20with\x20manifest','length','1024x1024','http','parseRouter','host','purpose','37373127aTMZli','join','icon\x20does\x20not\x20meet\x20the\x20standard,\x20use\x20default\x20icon\x20in\x20run\x20mode','12wNeVmC','sizes','In\x20the\x20Web\x20Spatial\x20App\x20Manifest,\x20it\x20is\x20necessary\x20to\x20provide\x20the\x20name\x20property\x20or\x20short_name\x20property\x20(preferably\x20both)','https://','186gyzLEq','defineProperty','580820sAvxmg','name','start_url'];_0x150a=function(){return _0xe9331f;};return _0x150a();}const path_1=require(_0x2cbd88(0x16c)),CustomError_1=require(_0x2cbd88(0x191)),utils_1=require(_0x2cbd88(0x164)),imageHelper_1=require(_0x2cbd88(0x190)),load_1=require('../resource/load'),utils_2=require('../utils/utils');function checkManifestJson(_0x6d6290,_0x4628d9=![]){const _0x4f14ab=_0x2cbd88;var _0x52d361;const _0x4e1205=[];!_0x6d6290[_0x4f14ab(0x187)]&&!_0x6d6290['short_name']&&!_0x4628d9&&_0x4e1205['push']({'code':0xbbe,'message':_0x4f14ab(0x182),'message_staring_params':{}});!((_0x52d361=_0x6d6290[_0x4f14ab(0x163)])===null||_0x52d361===void 0x0?void 0x0:_0x52d361[_0x4f14ab(0x177)])&&!_0x4628d9&&_0x4e1205[_0x4f14ab(0x16a)]({'code':0xbbf,'message':_0x4f14ab(0x18d),'message_staring_params':{}});!_0x6d6290[_0x4f14ab(0x188)]&&!_0x4628d9&&_0x4e1205[_0x4f14ab(0x16a)]({'code':0xbc0,'message':'In\x20the\x20Web\x20Spatial\x20App\x20Manifest,\x20the\x20start_url\x20property\x20must\x20be\x20provided','message_staring_params':{}});if(_0x4e1205[_0x4f14ab(0x177)])throw new CustomError_1[(_0x4f14ab(0x194))](_0x4e1205);}function checkStartUrl(_0x482bf5,_0x1313e8,_0x16ac9c,_0x512287=![]){const _0xec6bd6=_0x2cbd88;var _0x5b8f88=![];if(_0x512287)return _0x482bf5['startsWith'](_0xec6bd6(0x183))||_0x482bf5[_0xec6bd6(0x165)](_0xec6bd6(0x15f));if(_0x16ac9c){if(_0x482bf5[_0xec6bd6(0x165)]('https://')){const _0x26dc3c=new URL(_0x482bf5),_0x47617f=new URL(_0x1313e8);if(_0x26dc3c[_0xec6bd6(0x17b)]!==_0x47617f[_0xec6bd6(0x17b)])throw new CustomError_1[(_0xec6bd6(0x194))]({'code':0xfa0,'message':_0xec6bd6(0x176),'message_staring_params':{}});}else{if(_0x482bf5[_0xec6bd6(0x165)]('http://'))throw new CustomError_1['CustomError']({'code':0xfa0,'message':_0xec6bd6(0x192),'message_staring_params':{}});}}else{if(_0x482bf5['startsWith'](_0xec6bd6(0x183))||_0x482bf5['startsWith'](_0xec6bd6(0x15f)))throw new CustomError_1[(_0xec6bd6(0x194))]({'code':0xfa0,'message':_0xec6bd6(0x189),'message_staring_params':{}});}return _0x5b8f88;}async function checkIcons(_0x5718fc,_0x501a55,_0x619aa0=![]){const _0xb7fc45=_0x2cbd88;var _0x2dd6f3,_0x2a219c;if(!((_0x2dd6f3=_0x5718fc[_0xb7fc45(0x163)])===null||_0x2dd6f3===void 0x0?void 0x0:_0x2dd6f3[_0xb7fc45(0x177)])&&_0x619aa0){_0x5718fc[_0xb7fc45(0x163)]=[{'src':(0x0,path_1[_0xb7fc45(0x17e)])(__dirname,'../../assets/icon-default.png'),'sizes':_0xb7fc45(0x178),'purpose':_0xb7fc45(0x168)}],utils_2['CliLog'][_0xb7fc45(0x18e)](_0xb7fc45(0x18b));return;}const _0x218780=(0x0,utils_1[_0xb7fc45(0x17a)])(_0x501a55);let _0x34776d,_0x526641,_0x20b976,_0x5eadb8=0x0;for(var _0x5dcbf3=0x0;_0x5dcbf3<_0x5718fc[_0xb7fc45(0x163)][_0xb7fc45(0x177)];_0x5dcbf3++){const _0x12df49=_0x5718fc[_0xb7fc45(0x163)][_0x5dcbf3];let _0x574481=((_0x2a219c=_0x12df49[_0xb7fc45(0x17c)])===null||_0x2a219c===void 0x0?void 0x0:_0x2a219c[_0xb7fc45(0x15d)](_0xb7fc45(0x168)))>=0x0;if(!_0x574481)continue;let _0x301dd0=![],_0x21c63a=_0x12df49[_0xb7fc45(0x171)],_0x363a57,_0x154169=0x0;!validateURL(_0x21c63a)&&(_0x21c63a=(0x0,path_1['join'])(_0x218780,_0x21c63a));if(_0x12df49[_0xb7fc45(0x181)]){const _0x28577b=_0x12df49[_0xb7fc45(0x181)][_0xb7fc45(0x166)]('\x20');_0x28577b['forEach'](_0xacc9f1=>{const _0x5a1761=_0xb7fc45;let _0x162c3e=_0xacc9f1[_0x5a1761(0x166)]('x');Number(_0x162c3e[0x0])>=0x400&&Number(_0x162c3e[0x1])>=0x400&&(_0x301dd0=!![],Number(_0x162c3e[0x0])>_0x154169&&(_0x154169=Number(_0x162c3e[0x0])));});}else _0x363a57=!_0x21c63a[_0xb7fc45(0x165)](_0xb7fc45(0x179))?await(0x0,load_1['loadImageFromDisk'])(_0x21c63a):await(0x0,load_1[_0xb7fc45(0x170)])(_0x21c63a),_0x363a57[_0xb7fc45(0x172)]()>=0x400&&_0x363a57['getHeight']()>=0x400&&(_0x301dd0=!![],_0x363a57[_0xb7fc45(0x172)]()>_0x154169&&(_0x154169=_0x363a57[_0xb7fc45(0x172)]()));_0x301dd0&&_0x574481&&(_0x154169>_0x5eadb8&&(_0x5eadb8=_0x154169,_0x34776d=_0x363a57,_0x526641=_0x21c63a,_0x20b976=_0x12df49[_0xb7fc45(0x17c)]));}if(_0x5eadb8===0x0){if(_0x619aa0){_0x5718fc[_0xb7fc45(0x163)]=[{'src':(0x0,path_1[_0xb7fc45(0x17e)])(__dirname,'../../assets/icon-default.png'),'sizes':_0xb7fc45(0x178),'purpose':_0xb7fc45(0x168)}],utils_2['CliLog'][_0xb7fc45(0x18e)](_0xb7fc45(0x169)),utils_2[_0xb7fc45(0x160)][_0xb7fc45(0x18e)](_0xb7fc45(0x17f));return;}throw new CustomError_1[(_0xb7fc45(0x194))]({'code':0xfa0,'message':'In\x20the\x20Web\x20Spatial\x20App\x20on\x20VisionPro,\x20the\x20icon\x20must\x20be\x20greater\x20than\x20or\x20equal\x20to\x201024x1024,\x20and\x20the\x20purpose\x20parameter\x20must\x20include\x20maskable','message_staring_params':{}});}else _0x526641&&(_0x34776d=!_0x526641[_0xb7fc45(0x165)](_0xb7fc45(0x179))?await(0x0,load_1['loadImageFromDisk'])(_0x526641):await(0x0,load_1['loadImageFromNet'])(_0x526641));if(_0x34776d&&!imageHelper_1[_0xb7fc45(0x16d)]['isFullyOpaque'](_0x34776d)){if(_0x619aa0){utils_2[_0xb7fc45(0x160)][_0xb7fc45(0x18e)]('In\x20the\x20Web\x20Spatial\x20App\x20on\x20VisionPro,\x20the\x20icon\x20must\x20be\x20greater\x20than\x20or\x20equal\x20to\x201024x1024,\x20and\x20the\x20purpose\x20parameter\x20must\x20include\x20maskable');return;}throw new CustomError_1[(_0xb7fc45(0x194))]({'code':0xfa0,'message':_0xb7fc45(0x16e),'message_staring_params':{}});}_0x5718fc[_0xb7fc45(0x163)]=[{'src':_0x526641,'sizes':_0x5eadb8+'x'+_0x5eadb8,'purpose':_0x20b976}];}function checkId(_0x27e541,_0xc04af7){const _0x2ab1cc=_0x2cbd88;if(_0xc04af7){if(!validateBundleId(_0xc04af7))throw new CustomError_1[(_0x2ab1cc(0x194))]({'code':0xfa0,'message':_0x2ab1cc(0x15e),'message_staring_params':{}});return;}!_0x27e541['id']&&(_0x27e541['id']=_0x27e541[_0x2ab1cc(0x188)]);if(!validateURL(_0x27e541['id'])&&!_0xc04af7)throw new CustomError_1['CustomError']({'code':0xfa0,'message':_0x2ab1cc(0x173),'message_staring_params':{}});}function validateBundleId(_0x31f661){const _0x4717b3=/^(?=.{1,128}$)(?!.*\.\.)(?!^\.|.*\.$)[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)+$/;return _0x4717b3['test'](_0x31f661);}function validateURL(_0x2664bc){try{return new URL(_0x2664bc),!![];}catch(_0x9f0ec2){return![];}}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkManifestJson = checkManifestJson;
4
+ exports.checkStartUrl = checkStartUrl;
5
+ exports.checkIcons = checkIcons;
6
+ exports.checkId = checkId;
7
+ exports.validateBundleId = validateBundleId;
8
+ exports.validateURL = validateURL;
9
+ const path_1 = require("path");
10
+ const CustomError_1 = require("../utils/CustomError");
11
+ const utils_1 = require("../utils/utils");
12
+ const imageHelper_1 = require("../resource/imageHelper");
13
+ const load_1 = require("../resource/load");
14
+ const utils_2 = require("../utils/utils");
15
+ function checkManifestJson(manifestJson, isDev = false) {
16
+ var _a;
17
+ const errors = [];
18
+ if (!manifestJson.name && !manifestJson['short_name'] && !isDev) {
19
+ errors.push({
20
+ code: 3006,
21
+ message: 'In the Web Spatial App Manifest, it is necessary to provide the name property or short_name property (preferably both)',
22
+ // eslint-disable-next-line @typescript-eslint/camelcase
23
+ message_staring_params: {},
24
+ });
25
+ }
26
+ if (!((_a = manifestJson.icons) === null || _a === void 0 ? void 0 : _a.length) && !isDev) {
27
+ errors.push({
28
+ code: 3007,
29
+ message: 'In the Web Spatial App Manifest, the icons property must be provided and it should include at least one icon object',
30
+ // eslint-disable-next-line @typescript-eslint/camelcase
31
+ message_staring_params: {},
32
+ });
33
+ }
34
+ if (!manifestJson['start_url'] && !isDev) {
35
+ errors.push({
36
+ code: 3008,
37
+ message: 'In the Web Spatial App Manifest, the start_url property must be provided',
38
+ // eslint-disable-next-line @typescript-eslint/camelcase
39
+ message_staring_params: {},
40
+ });
41
+ }
42
+ if (errors.length) {
43
+ throw new CustomError_1.CustomError(errors);
44
+ }
45
+ }
46
+ function checkStartUrl(startUrl, manifestUrl, isNet, isDev = false) {
47
+ var isNetWeb = false;
48
+ if (isDev) {
49
+ return startUrl.startsWith('https://') || startUrl.startsWith('http://');
50
+ }
51
+ if (isNet) {
52
+ // Determine whether it is of the same origin as the manifest
53
+ if (startUrl.startsWith('https://')) {
54
+ const urlStart = new URL(startUrl);
55
+ const urlManifest = new URL(manifestUrl);
56
+ // The start_url and manifest need to be of the same origin
57
+ if (urlStart.host !== urlManifest.host) {
58
+ throw new CustomError_1.CustomError({
59
+ code: 4000,
60
+ // eslint-disable-next-line @typescript-eslint/camelcase
61
+ message: 'In the WebSpatial App Manifest, the start_url must be the same origin with manifest',
62
+ message_staring_params: {},
63
+ });
64
+ }
65
+ }
66
+ // Start_url must be HTTPS protocol
67
+ else if (startUrl.startsWith('http://')) {
68
+ throw new CustomError_1.CustomError({
69
+ code: 4000,
70
+ // eslint-disable-next-line @typescript-eslint/camelcase
71
+ message: 'In the Web Spatial App Manifest, the start_url must use https',
72
+ message_staring_params: {},
73
+ });
74
+ }
75
+ }
76
+ else {
77
+ if (startUrl.startsWith('https://') || startUrl.startsWith('http://')) {
78
+ throw new CustomError_1.CustomError({
79
+ code: 4000,
80
+ // eslint-disable-next-line @typescript-eslint/camelcase
81
+ message: 'Local manifest cannot package network project',
82
+ message_staring_params: {},
83
+ });
84
+ }
85
+ }
86
+ return isNetWeb;
87
+ }
88
+ async function checkIcons(manifest, manifestUrl, isDev = false) {
89
+ var _a, _b;
90
+ if (!((_a = manifest.icons) === null || _a === void 0 ? void 0 : _a.length) && isDev) {
91
+ manifest.icons = [
92
+ {
93
+ src: (0, path_1.join)(__dirname, '../../assets/icon-default.png'),
94
+ sizes: '1024x1024',
95
+ purpose: 'maskable',
96
+ },
97
+ ];
98
+ utils_2.CliLog.warn('icon not found, use default in run mode');
99
+ return;
100
+ }
101
+ const relativeUrl = (0, utils_1.parseRouter)(manifestUrl);
102
+ let maxSizeImage;
103
+ let maxSizeImageUrl;
104
+ let maxSizePurpose;
105
+ let maxSize = 0;
106
+ for (var i = 0; i < manifest.icons.length; i++) {
107
+ const item = manifest.icons[i];
108
+ let hasMaskable = ((_b = item.purpose) === null || _b === void 0 ? void 0 : _b.indexOf('maskable')) >= 0;
109
+ if (!hasMaskable)
110
+ continue;
111
+ let has1024 = false;
112
+ let imgUrl = item.src;
113
+ let image;
114
+ let imageSize = 0;
115
+ if (!validateURL(imgUrl)) {
116
+ imgUrl = (0, path_1.join)(relativeUrl, imgUrl);
117
+ }
118
+ // If size has been configured, determine the size; otherwise, download the icon for judgment
119
+ if (item.sizes) {
120
+ const mulSize = item.sizes.split(' ');
121
+ mulSize.forEach((size) => {
122
+ let wh = size.split('x');
123
+ if (Number(wh[0]) >= 1024 && Number(wh[1]) >= 1024) {
124
+ has1024 = true;
125
+ if (Number(wh[0]) > imageSize) {
126
+ imageSize = Number(wh[0]);
127
+ }
128
+ }
129
+ });
130
+ }
131
+ else {
132
+ image = !imgUrl.startsWith('http')
133
+ ? await (0, load_1.loadImageFromDisk)(imgUrl)
134
+ : await (0, load_1.loadImageFromNet)(imgUrl);
135
+ if (image.getWidth() >= 1024 && image.getHeight() >= 1024) {
136
+ has1024 = true;
137
+ if (image.getWidth() > imageSize) {
138
+ imageSize = image.getWidth();
139
+ }
140
+ }
141
+ }
142
+ // Download all the icons used, check their width and height, and if they meet the size and maskability requirements, finally check their alpha
143
+ if (has1024 && hasMaskable) {
144
+ if (imageSize > maxSize) {
145
+ maxSize = imageSize;
146
+ maxSizeImage = image;
147
+ maxSizeImageUrl = imgUrl;
148
+ maxSizePurpose = item.purpose;
149
+ }
150
+ }
151
+ }
152
+ // There is no icon that satisfies both size>=1024 and purpose including Maskable
153
+ if (maxSize === 0) {
154
+ if (isDev) {
155
+ manifest.icons = [
156
+ {
157
+ src: (0, path_1.join)(__dirname, '../../assets/icon-default.png'),
158
+ sizes: '1024x1024',
159
+ purpose: 'maskable',
160
+ },
161
+ ];
162
+ utils_2.CliLog.warn('In the Web Spatial App on VisionPro, the icon must be greater than or equal to 1024x1024, and the purpose parameter must include maskable');
163
+ utils_2.CliLog.warn('icon does not meet the standard, use default icon in run mode');
164
+ return;
165
+ }
166
+ throw new CustomError_1.CustomError({
167
+ code: 4000,
168
+ // eslint-disable-next-line @typescript-eslint/camelcase
169
+ message: 'In the Web Spatial App on VisionPro, the icon must be greater than or equal to 1024x1024, and the purpose parameter must include maskable',
170
+ message_staring_params: {},
171
+ });
172
+ }
173
+ else if (maxSizeImageUrl) {
174
+ maxSizeImage = !maxSizeImageUrl.startsWith('http')
175
+ ? await (0, load_1.loadImageFromDisk)(maxSizeImageUrl)
176
+ : await (0, load_1.loadImageFromNet)(maxSizeImageUrl);
177
+ }
178
+ // Check if the image is completely opaque
179
+ if (maxSizeImage && !imageHelper_1.ImageHelper.isFullyOpaque(maxSizeImage)) {
180
+ if (isDev) {
181
+ utils_2.CliLog.warn('In the Web Spatial App on VisionPro, the icon must be greater than or equal to 1024x1024, and the purpose parameter must include maskable');
182
+ return;
183
+ }
184
+ throw new CustomError_1.CustomError({
185
+ code: 4000,
186
+ // eslint-disable-next-line @typescript-eslint/camelcase
187
+ message: 'In the Web Spatial App on VisionPro, must be a fully opaque bitmap.',
188
+ message_staring_params: {},
189
+ });
190
+ }
191
+ manifest.icons = [
192
+ {
193
+ src: maxSizeImageUrl,
194
+ sizes: maxSize + 'x' + maxSize,
195
+ purpose: maxSizePurpose,
196
+ },
197
+ ];
198
+ }
199
+ function checkId(manifest, bundleId) {
200
+ if (bundleId) {
201
+ if (!validateBundleId(bundleId)) {
202
+ throw new CustomError_1.CustomError({
203
+ code: 4000,
204
+ // eslint-disable-next-line @typescript-eslint/camelcase
205
+ message: 'In the Web Spatial App Manifest, the bundle ID must be in reverse domain format (e.g. com.example.app) and no longer than 128 characters',
206
+ message_staring_params: {},
207
+ });
208
+ }
209
+ return;
210
+ }
211
+ if (!manifest.id) {
212
+ manifest.id = manifest.start_url;
213
+ }
214
+ if (!validateURL(manifest.id) && !bundleId) {
215
+ throw new CustomError_1.CustomError({
216
+ code: 4000,
217
+ // eslint-disable-next-line @typescript-eslint/camelcase
218
+ message: 'In the Web Spatial App Manifest, the id or start_url must be a valid URL, or provide it use --bundle-id',
219
+ message_staring_params: {},
220
+ });
221
+ }
222
+ }
223
+ function validateBundleId(bundleId) {
224
+ // iOS official specification regex (supports reverse domain name format validation)
225
+ // 1. Allowed: letters/numbers/hyphens/underscores/dots
226
+ // 2. Disallow: consecutive dots/leading or trailing dots
227
+ // 3. Each part starts with a letter or underscore
228
+ // 4. Total length 1-128 characters
229
+ const iosBundleIdRegex = /^(?=.{1,128}$)(?!.*\.\.)(?!^\.|.*\.$)[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)+$/;
230
+ return iosBundleIdRegex.test(bundleId);
231
+ }
232
+ function validateURL(url) {
233
+ try {
234
+ new URL(url);
235
+ return true;
236
+ }
237
+ catch (error) {
238
+ return false;
239
+ }
240
+ }
@@ -1 +1,45 @@
1
- 'use strict';const _0x5c4e1a=_0x290d;function _0x42fa(){const _0x4665ce=['9dIDDYL','isDirectory','373788tHuhzw','isFile','1624916dCUTpN','readFileSync','log','existsSync','copyDir','1365966kJKJOv','statSync','writeFileSync','2100917qSuNRL','894055CrquQe','unlinkSync','1OzOHaE','4814200GhmVhQ','2113488TfIlBp','readdirSync','clearDir','forEach','mkdirSync'];_0x42fa=function(){return _0x4665ce;};return _0x42fa();}function _0x290d(_0x41eae3,_0x46df6b){const _0x42faa8=_0x42fa();return _0x290d=function(_0x290d86,_0x3e6045){_0x290d86=_0x290d86-0xb7;let _0x7ad0ac=_0x42faa8[_0x290d86];return _0x7ad0ac;},_0x290d(_0x41eae3,_0x46df6b);}(function(_0x883330,_0x2bf61a){const _0x5bb372=_0x290d,_0x2d0258=_0x883330();while(!![]){try{const _0x4a7f21=-parseInt(_0x5bb372(0xc2))/0x1*(parseInt(_0x5bb372(0xbc))/0x2)+parseInt(_0x5bb372(0xc4))/0x3+parseInt(_0x5bb372(0xb7))/0x4+-parseInt(_0x5bb372(0xc0))/0x5+-parseInt(_0x5bb372(0xcb))/0x6+-parseInt(_0x5bb372(0xbf))/0x7+parseInt(_0x5bb372(0xc3))/0x8*(parseInt(_0x5bb372(0xc9))/0x9);if(_0x4a7f21===_0x2bf61a)break;else _0x2d0258['push'](_0x2d0258['shift']());}catch(_0xb77d7e){_0x2d0258['push'](_0x2d0258['shift']());}}}(_0x42fa,0x77355));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[_0x5c4e1a(0xbb)]=copyDir,exports[_0x5c4e1a(0xc6)]=clearDir;const fs=require('fs');function copyDir(_0x5ebf48,_0x20f2b8){const _0x1e8163=_0x5c4e1a,_0x23c260=fs[_0x1e8163(0xc5)](_0x5ebf48);_0x23c260[_0x1e8163(0xc7)](_0x5f2699=>{const _0x1f53b7=_0x1e8163,_0x104b3d=_0x5ebf48+'/'+_0x5f2699,_0x3af5d3=_0x20f2b8+'/'+_0x5f2699,_0x7918e5=fs[_0x1f53b7(0xbd)](_0x104b3d);if(_0x7918e5[_0x1f53b7(0xcc)]())try{fs[_0x1f53b7(0xbe)](_0x3af5d3,fs[_0x1f53b7(0xb8)](_0x104b3d));}catch(_0x455450){console[_0x1f53b7(0xb9)](_0x455450);}else _0x7918e5[_0x1f53b7(0xca)]()&&(!fs[_0x1f53b7(0xba)](_0x3af5d3)&&fs[_0x1f53b7(0xc8)](_0x3af5d3,{'recursive':!![]}),copyDir(_0x104b3d,_0x3af5d3));});}function clearDir(_0x288daa){const _0x2f490d=_0x5c4e1a,_0x24ee89=fs[_0x2f490d(0xc5)](_0x288daa);_0x24ee89['forEach'](_0x4d8fb7=>{const _0x56187c=_0x2f490d,_0xe5c0ae=_0x288daa+'/'+_0x4d8fb7,_0x3b3b9d=fs['statSync'](_0xe5c0ae);if(_0x3b3b9d[_0x56187c(0xcc)]())try{fs[_0x56187c(0xc1)](_0xe5c0ae);}catch(_0x5c853e){console[_0x56187c(0xb9)](_0x5c853e);}else _0x3b3b9d[_0x56187c(0xca)]()&&clearDir(_0xe5c0ae);});}
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyDir = copyDir;
4
+ exports.clearDir = clearDir;
5
+ const fs = require("fs");
6
+ function copyDir(from, to) {
7
+ const paths = fs.readdirSync(from);
8
+ paths.forEach(path => {
9
+ const _from = from + '/' + path;
10
+ const _to = to + '/' + path;
11
+ const stat = fs.statSync(_from);
12
+ if (stat.isFile()) {
13
+ try {
14
+ fs.writeFileSync(_to, fs.readFileSync(_from));
15
+ }
16
+ catch (err) {
17
+ console.log(err);
18
+ }
19
+ }
20
+ else if (stat.isDirectory()) {
21
+ if (!fs.existsSync(_to)) {
22
+ fs.mkdirSync(_to, { recursive: true });
23
+ }
24
+ copyDir(_from, _to);
25
+ }
26
+ });
27
+ }
28
+ function clearDir(from) {
29
+ const paths = fs.readdirSync(from);
30
+ paths.forEach(path => {
31
+ const _from = from + '/' + path;
32
+ const stat = fs.statSync(_from);
33
+ if (stat.isFile()) {
34
+ try {
35
+ fs.unlinkSync(_from);
36
+ }
37
+ catch (err) {
38
+ console.log(err);
39
+ }
40
+ }
41
+ else if (stat.isDirectory()) {
42
+ clearDir(_from);
43
+ }
44
+ });
45
+ }