@webspatial/builder 1.0.0 → 1.0.2
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.
- package/dist/lib/cmds/build.js +9 -11
- package/dist/lib/pwa/config.js +25 -20
- package/dist/lib/pwa/index.js +8 -5
- package/dist/lib/pwa/validate.js +3 -1
- package/dist/lib/utils/history.js +3 -0
- package/dist/lib/xcode/manifestSwiftTemplate.d.ts +1 -1
- package/dist/lib/xcode/manifestSwiftTemplate.js +0 -1
- package/dist/lib/xcode/xcodeproject.js +14 -13
- package/dist/lib/xcode/xcrun.d.ts +1 -0
- package/dist/lib/xcode/xcrun.js +7 -0
- package/package.json +2 -2
package/dist/lib/cmds/build.js
CHANGED
|
@@ -56,17 +56,15 @@ async function run(args) {
|
|
|
56
56
|
If it is the same, it will be defaulted as already compiled, and the compilation will be skipped and the application will be launched directly.
|
|
57
57
|
*/
|
|
58
58
|
// fixme: the cache not invalidate when npm version change
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// }
|
|
69
|
-
// }
|
|
59
|
+
if (manifestInfo.fromNet || args['tryWithoutBuild'] === 'true') {
|
|
60
|
+
// If this command is a new command, go through the build process; otherwise, go through the launch process
|
|
61
|
+
if (history_1.default.checkManifest(manifestInfo.json) &&
|
|
62
|
+
history_1.default.checkTestAppIsExist()) {
|
|
63
|
+
console.log('Same as the previous record');
|
|
64
|
+
await xcode_1.XcodeManager.runWithHistory();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
70
68
|
resource_1.ResourceManager.pullPlatformModule(args['platform']);
|
|
71
69
|
const icon = await doReadyProject((_a = args['project']) !== null && _a !== void 0 ? _a : 'dist', manifestInfo);
|
|
72
70
|
await doXcode(args, icon, manifestInfo, true);
|
package/dist/lib/pwa/config.js
CHANGED
|
@@ -140,34 +140,39 @@ function configDisplay(manifestJson) {
|
|
|
140
140
|
}
|
|
141
141
|
function configMainScene(manifestJson) {
|
|
142
142
|
var _a, _b;
|
|
143
|
-
const resizabilities = ['
|
|
143
|
+
const resizabilities = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight'];
|
|
144
144
|
let mainScene = {
|
|
145
145
|
defaultSize: {
|
|
146
146
|
width: 1280,
|
|
147
147
|
height: 1280,
|
|
148
148
|
},
|
|
149
|
-
resizability:
|
|
149
|
+
resizability: {},
|
|
150
150
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
151
|
+
let hasResizability = false;
|
|
152
|
+
if (manifestJson.xr_main_scene &&
|
|
153
|
+
typeof manifestJson.xr_main_scene === 'object') {
|
|
154
|
+
mainScene.defaultSize.width =
|
|
155
|
+
Number((_a = manifestJson.xr_main_scene.default_size) === null || _a === void 0 ? void 0 : _a.width) > 0
|
|
156
|
+
? manifestJson.xr_main_scene.default_size.width
|
|
157
|
+
: 1280;
|
|
158
|
+
mainScene.defaultSize.height =
|
|
159
|
+
Number((_b = manifestJson.xr_main_scene.default_size) === null || _b === void 0 ? void 0 : _b.height) > 0
|
|
160
|
+
? manifestJson.xr_main_scene.default_size.height
|
|
161
|
+
: 1280;
|
|
162
|
+
if (typeof manifestJson.xr_main_scene.resizability === 'object') {
|
|
163
|
+
for (var i = 0; i < resizabilities.length; i++) {
|
|
164
|
+
if (manifestJson.xr_main_scene.resizability[resizabilities[i]] >= 0) {
|
|
165
|
+
hasResizability = true;
|
|
166
|
+
mainScene.resizability[resizabilities[i]] =
|
|
167
|
+
manifestJson.xr_main_scene.resizability[resizabilities[i]];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
168
170
|
}
|
|
169
|
-
// other type like string should be ignored
|
|
170
171
|
}
|
|
172
|
+
if (!hasResizability) {
|
|
173
|
+
mainScene.resizability = null;
|
|
174
|
+
}
|
|
175
|
+
manifestJson.xr_main_scene = mainScene;
|
|
171
176
|
}
|
|
172
177
|
function configDeeplink(manifestJson) {
|
|
173
178
|
if (manifestJson.protocol_handlers &&
|
package/dist/lib/pwa/index.js
CHANGED
|
@@ -68,12 +68,15 @@ class PWAGenerator {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
static compareManifest(manifest) {
|
|
71
|
-
var _a, _b, _c
|
|
72
|
-
manifest.name =
|
|
73
|
-
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
manifest.name =
|
|
73
|
+
manifest.name && manifest.name.length > 0
|
|
74
|
+
? manifest.name
|
|
75
|
+
: this.defaultManifestJson.name;
|
|
76
|
+
manifest.display = (_a = manifest.display) !== null && _a !== void 0 ? _a : this.defaultManifestJson.display;
|
|
74
77
|
manifest.start_url =
|
|
75
|
-
(
|
|
76
|
-
manifest.scope = (
|
|
78
|
+
(_b = manifest.start_url) !== null && _b !== void 0 ? _b : this.defaultManifestJson.start_url;
|
|
79
|
+
manifest.scope = (_c = manifest.scope) !== null && _c !== void 0 ? _c : this.defaultManifestJson.scope;
|
|
77
80
|
return manifest;
|
|
78
81
|
}
|
|
79
82
|
// generate manifest
|
package/dist/lib/pwa/validate.js
CHANGED
|
@@ -15,7 +15,9 @@ const utils_2 = require("../utils/utils");
|
|
|
15
15
|
function checkManifestJson(manifestJson, isDev = false) {
|
|
16
16
|
var _a;
|
|
17
17
|
const errors = [];
|
|
18
|
-
if (!manifestJson.name
|
|
18
|
+
if ((!manifestJson.name || manifestJson.name.length === 0) &&
|
|
19
|
+
!manifestJson['short_name'] &&
|
|
20
|
+
!isDev) {
|
|
19
21
|
errors.push({
|
|
20
22
|
code: 3006,
|
|
21
23
|
message: 'In the Web Spatial App Manifest, it is necessary to provide the name property or short_name property (preferably both)',
|
|
@@ -63,6 +63,9 @@ class CliHistory {
|
|
|
63
63
|
}
|
|
64
64
|
// Compare whether two objects are equal
|
|
65
65
|
static compareObjects(obj1, obj2) {
|
|
66
|
+
if (obj1 === null || obj2 === null) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
66
69
|
// 1. Check if the number of properties is the same
|
|
67
70
|
const keys1 = Object.keys(obj1);
|
|
68
71
|
const keys2 = Object.keys(obj2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const manifestSwiftTemplate = "\nimport Foundation\n\nvar pwaManager = PWAManager()\n\nstruct PWAManager: Codable {\n var isLocal: Bool = false\n var start_url: String = \"START_URL\"\n var scope: String = \"SCOPE\"\n var id: String = \"AppID\"\n\n var name: String = \"AppName\"\n var short_name: String = \"name\"\n var description: String = \"Description\"\n\n var display: PWADisplayMode = .minimal\n var display_override: [PWADisplayMode] = []\n var protocol_handlers: [PWAProtocol] = [PWAProtocol(protocolValue: \"\", url: \"\")]\n var mainScene: WindowContainerOptions = .init(\n defaultSize: .init(\n width: SceneWidth,\n height: SceneHeight\n ),\n resizability: SceneResizability\n )\n
|
|
1
|
+
export declare const manifestSwiftTemplate = "\nimport Foundation\n\nvar pwaManager = PWAManager()\n\nstruct PWAManager: Codable {\n var isLocal: Bool = false\n var start_url: String = \"START_URL\"\n var scope: String = \"SCOPE\"\n var id: String = \"AppID\"\n\n var name: String = \"AppName\"\n var short_name: String = \"name\"\n var description: String = \"Description\"\n\n var display: PWADisplayMode = .minimal\n var display_override: [PWADisplayMode] = []\n var protocol_handlers: [PWAProtocol] = [PWAProtocol(protocolValue: \"\", url: \"\")]\n var mainScene: WindowContainerOptions = .init(\n defaultSize: .init(\n width: SceneWidth,\n height: SceneHeight\n ),\n resizability: SceneResizability\n )\n private var version: String = \"PACKAGE_VERSION\"\n\n mutating func _init() {\n let urlType = start_url.split(separator: \"://\").first\n if !(urlType == \"http\" || urlType == \"https\") {\n if scope == \"\" || scope == \"/\" {\n scope = \"./\"\n }\n let startUrl = Bundle.main.url(forResource: start_url, withExtension: \"\", subdirectory: \"\")\n start_url = startUrl!.absoluteString\n scope = URL(string: (scope.starts(with: \"/\") ? \".\" : \"./\") + scope, relativeTo: Bundle.main.executableURL)!.absoluteString\n isLocal = true\n }\n\n if display_override.count > 0 {\n display = display_override[0]\n }\n\n for i in 0 ... protocol_handlers.count - 1 {\n let item = protocol_handlers[i]\n protocol_handlers[i].updateUrl(scope + item.url)\n }\n }\n\n func checkInScope(url: String) -> Bool {\n return url.starts(with: scope)\n }\n\n // web+spatial://test\n func checkInDeeplink(url: String) -> String {\n var linkUrl: String = url\n for item in protocol_handlers {\n if linkUrl.starts(with: item.protocolValue) {\n let queryString: String = linkUrl.replacingOccurrences(of: item.protocolValue, with: \"\").addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!\n linkUrl = item.url.replacingOccurrences(of: \"%s\", with: item.protocolValue + queryString)\n }\n }\n logger.debug(linkUrl)\n return linkUrl\n }\n\n func getLocalResourceURL(url: String) -> String {\n let path = String(url.split(separator: \"file://\").first!.split(separator: \"?\").first!)\n let newUrl = URL(string: url)\n let fileManager = FileManager.default\n if fileManager.fileExists(atPath: newUrl!.path) {\n return url\n }\n var resource: String = Bundle.main.url(forResource: newUrl?.path, withExtension: \"\", subdirectory: \"\")?.absoluteString ?? \"\"\n if resource == \"\" {\n resource = Bundle.main.url(forResource: \"static-web\" + path, withExtension: \"\", subdirectory: \"\")?.absoluteString ?? \"\"\n }\n if resource == \"\" {\n return url\n }\n if newUrl?.query() != nil {\n resource += \"?\" + (newUrl?.query())!\n }\n if newUrl?.fragment() != nil {\n resource += \"#\" + (newUrl?.fragment())!\n }\n return resource\n }\n \n func getVersion() -> String {\n return version\n }\n}\n\nenum PWADisplayMode: Codable {\n case minimal\n case standalone\n case fullscreen\n}\n\nstruct PWAProtocol: Codable {\n var protocolValue: String = \"\"\n var url: String = \"\"\n\n mutating func updateUrl(_ str: String) {\n url = str\n }\n}\n\n";
|
|
@@ -231,20 +231,21 @@ class XcodeProject {
|
|
|
231
231
|
}
|
|
232
232
|
manifestSwift = manifestSwift.replace('PWAProtocol(protocolValue: "", url: "")', deeplinkString);
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
234
|
+
manifestSwift = manifestSwift.replace('SceneWidth', manifest.xr_main_scene.defaultSize.width);
|
|
235
|
+
manifestSwift = manifestSwift.replace('SceneHeight', manifest.xr_main_scene.defaultSize.height);
|
|
236
|
+
let res = 'nil';
|
|
237
|
+
const resizabilities = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight'];
|
|
238
|
+
if (manifest.xr_main_scene.resizability) {
|
|
239
|
+
res = 'ResizeRange(';
|
|
240
|
+
for (var i = 0; i < resizabilities.length; i++) {
|
|
241
|
+
if (manifest.xr_main_scene.resizability[resizabilities[i]] >= 0) {
|
|
242
|
+
res += `${resizabilities[i]}: ${manifest.xr_main_scene.resizability[resizabilities[i]]},`;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
res = res.substring(0, res.length - 1);
|
|
246
|
+
res += ')';
|
|
247
247
|
}
|
|
248
|
+
manifestSwift = manifestSwift.replace('SceneResizability', res);
|
|
248
249
|
fs.writeFileSync(manifestSwiftPath, manifestSwift, 'utf-8');
|
|
249
250
|
}
|
|
250
251
|
}
|
|
@@ -30,6 +30,7 @@ export default class Xcrun {
|
|
|
30
30
|
static shutdownSimulator(): Promise<void>;
|
|
31
31
|
private static launchSimulator;
|
|
32
32
|
private static buildTestApp;
|
|
33
|
+
private static terminateApp;
|
|
33
34
|
private static installApp;
|
|
34
35
|
private static launchApp;
|
|
35
36
|
private static parseDestinationDevices;
|
package/dist/lib/xcode/xcrun.js
CHANGED
|
@@ -110,6 +110,10 @@ class Xcrun {
|
|
|
110
110
|
console.log(`use simulator: ${device.deviceId}`);
|
|
111
111
|
// launch visionOS simulator
|
|
112
112
|
this.launchSimulator(device);
|
|
113
|
+
try {
|
|
114
|
+
this.terminateApp(device.deviceId, appInfo.id);
|
|
115
|
+
}
|
|
116
|
+
catch (_a) { }
|
|
113
117
|
// install app
|
|
114
118
|
console.log('installing app');
|
|
115
119
|
this.installApp(resource_1.PROJECT_TEST_DIRECTORY, device.deviceId, appInfo.name);
|
|
@@ -169,6 +173,9 @@ class Xcrun {
|
|
|
169
173
|
console.log('------------------- build end -------------------');
|
|
170
174
|
return true;
|
|
171
175
|
}
|
|
176
|
+
static terminateApp(deviceId, appId) {
|
|
177
|
+
(0, child_process_1.execSync)(new XcrunCMD().simctl().terminate(deviceId, appId).line);
|
|
178
|
+
}
|
|
172
179
|
static installApp(path, deviceId, appName) {
|
|
173
180
|
const appFile = (0, path_1.join)(path, `Build/Products/Debug-xrsimulator/${appName}.app`);
|
|
174
181
|
let cmd = new XcrunCMD().simctl();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webspatial/builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Client CLI tool to Generate XRApp project for Apple Vision Pro",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"engines": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"sharp": "^0.33.5",
|
|
41
41
|
"valid-url": "^1.0.9",
|
|
42
42
|
"xcode": "^3.0.1",
|
|
43
|
-
"@webspatial/platform-visionos": "^1.0.
|
|
43
|
+
"@webspatial/platform-visionos": "^1.0.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-terser": "^0.4.3",
|