@webspatial/builder 1.3.0 → 1.4.0
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/utils/utils.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CliLog = void 0;
|
|
4
4
|
exports.parseRouter = parseRouter;
|
|
5
|
+
exports.getInstalledPackageVersion = getInstalledPackageVersion;
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
5
8
|
const Log_1 = require("./Log");
|
|
6
9
|
function parseRouter(url) {
|
|
7
10
|
let urlParts = url.split('/');
|
|
@@ -12,4 +15,35 @@ function parseRouter(url) {
|
|
|
12
15
|
}
|
|
13
16
|
return pathUrl;
|
|
14
17
|
}
|
|
18
|
+
// Why not `require('@scope/pkg/package.json')`?
|
|
19
|
+
// Many packages define `exports` which can block direct access to `package.json`.
|
|
20
|
+
// This function resolves the package entrypoint first, then walks up to find the
|
|
21
|
+
// package root `package.json` on disk.
|
|
22
|
+
function getInstalledPackageVersion(packageName, resolveFromDir = process.cwd()) {
|
|
23
|
+
let entry;
|
|
24
|
+
try {
|
|
25
|
+
// Let Node resolve the package from the given directory.
|
|
26
|
+
entry = require.resolve(packageName, { paths: [resolveFromDir] });
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
let dir = (0, path_1.dirname)(entry);
|
|
32
|
+
// Walk up parent directories until we hit the package root.
|
|
33
|
+
// The `20` is a safety cap to avoid pathological cases (e.g. unexpected paths).
|
|
34
|
+
for (let i = 0; i < 20; i += 1) {
|
|
35
|
+
const packageJsonPath = (0, path_1.join)(dir, 'package.json');
|
|
36
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
37
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
38
|
+
if ((pkg === null || pkg === void 0 ? void 0 : pkg.name) === packageName) {
|
|
39
|
+
return typeof pkg.version === 'string' ? pkg.version : null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const parent = (0, path_1.dirname)(dir);
|
|
43
|
+
if (parent === dir)
|
|
44
|
+
break;
|
|
45
|
+
dir = parent;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
15
49
|
exports.CliLog = new Log_1.ConsoleLog('webspatial-builder');
|
|
@@ -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: XSceneOptionsJSB = .init(\n defaultSize: .init(\n width: SceneWidth,\n height: SceneHeight,\n depth: SceneDepth\n ),\n type: .SceneType,\n resizability: SceneResizability,\n worldScaling: .WorldScaling,\n worldAlignment: .WorldAlignment,\n baseplateVisibility: .BaseplateVisibility\n )\n private var
|
|
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: XSceneOptionsJSB = .init(\n defaultSize: .init(\n width: SceneWidth,\n height: SceneHeight,\n depth: SceneDepth\n ),\n type: .SceneType,\n resizability: SceneResizability,\n worldScaling: .WorldScaling,\n worldAlignment: .WorldAlignment,\n baseplateVisibility: .BaseplateVisibility\n )\n var useMainScene: Bool = true\n private var shellVersion: String = \"WS_SHELL_VERSION\"\n private var sdkVersion: String = \"WS_SDK_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, relativeTo: startUrl)!.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 getShellVersion() -> String {\n return shellVersion\n }\n \n func getSdkVersion() -> String {\n return sdkVersion\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";
|
|
@@ -31,7 +31,9 @@ struct PWAManager: Codable {
|
|
|
31
31
|
worldAlignment: .WorldAlignment,
|
|
32
32
|
baseplateVisibility: .BaseplateVisibility
|
|
33
33
|
)
|
|
34
|
-
|
|
34
|
+
var useMainScene: Bool = true
|
|
35
|
+
private var shellVersion: String = "WS_SHELL_VERSION"
|
|
36
|
+
private var sdkVersion: String = "WS_SDK_VERSION"
|
|
35
37
|
|
|
36
38
|
mutating func _init() {
|
|
37
39
|
let urlType = start_url.split(separator: "://").first
|
|
@@ -41,7 +43,7 @@ struct PWAManager: Codable {
|
|
|
41
43
|
}
|
|
42
44
|
let startUrl = Bundle.main.url(forResource: start_url, withExtension: "", subdirectory: "")
|
|
43
45
|
start_url = startUrl!.absoluteString
|
|
44
|
-
scope = URL(string:
|
|
46
|
+
scope = URL(string: scope, relativeTo: startUrl)!.absoluteString
|
|
45
47
|
isLocal = true
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -95,8 +97,12 @@ struct PWAManager: Codable {
|
|
|
95
97
|
return resource
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
func
|
|
99
|
-
return
|
|
100
|
+
func getShellVersion() -> String {
|
|
101
|
+
return shellVersion
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
func getSdkVersion() -> String {
|
|
105
|
+
return sdkVersion
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
|
|
@@ -6,6 +6,7 @@ const path_1 = require("path");
|
|
|
6
6
|
const load_1 = require("../resource/load");
|
|
7
7
|
const imageHelper_1 = require("../resource/imageHelper");
|
|
8
8
|
const manifestSwiftTemplate_1 = require("./manifestSwiftTemplate");
|
|
9
|
+
const utils_1 = require("../utils/utils");
|
|
9
10
|
const xcode = require('xcode');
|
|
10
11
|
const exportOptionsXML = `<?xml version="1.0" encoding="UTF-8"?>
|
|
11
12
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -226,12 +227,14 @@ class XcodeProject {
|
|
|
226
227
|
return newInfoPlist;
|
|
227
228
|
}
|
|
228
229
|
static async modifySwift(manifest) {
|
|
229
|
-
var _a;
|
|
230
|
+
var _a, _b;
|
|
230
231
|
const manifestSwiftPath = (0, path_1.join)(resource_1.PROJECT_DIRECTORY, './web-spatial/manifest.swift');
|
|
231
232
|
const xcodePackageJsonPath = (0, path_1.join)(resource_1.PROJECT_DIRECTORY, 'package.json');
|
|
232
233
|
const packageJson = await (0, load_1.loadJsonFromDisk)(xcodePackageJsonPath);
|
|
233
234
|
let manifestSwift = manifestSwiftTemplate_1.manifestSwiftTemplate;
|
|
234
|
-
manifestSwift = manifestSwift.replace('
|
|
235
|
+
manifestSwift = manifestSwift.replace('WS_SHELL_VERSION', (_a = packageJson.version) !== null && _a !== void 0 ? _a : '0.0.0');
|
|
236
|
+
manifestSwift = manifestSwift.replace('WS_SDK_VERSION', (_b = (0, utils_1.getInstalledPackageVersion)('@webspatial/core-sdk')) !== null && _b !== void 0 ? _b : '0.0.0');
|
|
237
|
+
console.log('versions:', packageJson.version, (0, utils_1.getInstalledPackageVersion)('@webspatial/core-sdk'));
|
|
235
238
|
manifestSwift = manifestSwift.replace('START_URL', manifest.start_url);
|
|
236
239
|
manifestSwift = manifestSwift.replace('SCOPE', manifest.scope);
|
|
237
240
|
manifestSwift = manifestSwift.replace('AppName', manifest.name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webspatial/builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Client CLI tool to Generate XRApp project for Apple Vision Pro",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"engines": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"sharp": "^0.33.5",
|
|
42
42
|
"valid-url": "^1.0.9",
|
|
43
43
|
"xcode": "^3.0.1",
|
|
44
|
-
"@webspatial/platform-visionos": "^1.
|
|
44
|
+
"@webspatial/platform-visionos": "^1.4.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rollup/plugin-terser": "^0.4.3",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"scripts": {
|
|
68
68
|
"start": "tsc -w",
|
|
69
69
|
"test": "tsc",
|
|
70
|
+
"test:unit": "tsc && node --test \"test/**/*.test.js\"",
|
|
70
71
|
"test0": "npm run build && bin/bundlepwa.js test",
|
|
71
72
|
"test1": "npm run build && bin/bundlepwa.js build --manifest=../testLocal/manifest.json --project=../testLocal --export=./export --version=1.0 --teamId=teamId",
|
|
72
73
|
"test2": "npm run build && bin/bundlepwa.js publish --manifest=../pack-test/pwa_test.json --project=../pack-test --version=1.0 --teamId=teamId --u=username --p=password",
|