@webspatial/builder 0.1.20 → 0.1.22
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/index.js +5 -0
- package/dist/lib/cmds/build.js +4 -3
- package/dist/lib/cmds/test.d.ts +1 -0
- package/dist/lib/cmds/test.js +129 -0
- package/dist/lib/pwa/config.js +8 -1
- package/dist/lib/pwa/validate.js +8 -36
- package/dist/lib/resource/index.d.ts +3 -1
- package/dist/lib/resource/index.js +37 -27
- package/dist/lib/xcode/manifestSwiftTemplate.d.ts +1 -1
- package/dist/lib/xcode/manifestSwiftTemplate.js +1 -1
- package/dist/lib/xcode/xcodeproject.js +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const version_1 = require("./lib/cmds/version");
|
|
|
8
8
|
const fetch_1 = require("./lib/utils/fetch");
|
|
9
9
|
const launch_1 = require("./lib/cmds/launch");
|
|
10
10
|
const shutdown_1 = require("./lib/cmds/shutdown");
|
|
11
|
+
const test_1 = require("./lib/cmds/test");
|
|
11
12
|
module.exports = async () => {
|
|
12
13
|
if ((0, semver_1.major)(process.versions.node) < 14) {
|
|
13
14
|
throw new Error(`Current Node.js version is ${process.versions.node}.` +
|
|
@@ -96,4 +97,8 @@ async function setupCommands(program) {
|
|
|
96
97
|
console.log(options);
|
|
97
98
|
await (0, shutdown_1.shutdown)(options);
|
|
98
99
|
});
|
|
100
|
+
program.command('test').action(async (options) => {
|
|
101
|
+
console.log(options);
|
|
102
|
+
(0, test_1.test)();
|
|
103
|
+
});
|
|
99
104
|
}
|
package/dist/lib/cmds/build.js
CHANGED
|
@@ -12,7 +12,7 @@ const history_1 = require("../utils/history");
|
|
|
12
12
|
async function build(args) {
|
|
13
13
|
var _a;
|
|
14
14
|
console.log('------------------- parse start -------------------');
|
|
15
|
-
resource_1.ResourceManager.
|
|
15
|
+
resource_1.ResourceManager.initPlatform(args['platform']);
|
|
16
16
|
const manifestInfo = await doPwa(args);
|
|
17
17
|
const icon = await doReadyProject((_a = args['project']) !== null && _a !== void 0 ? _a : 'dist', manifestInfo);
|
|
18
18
|
await doXcode(args, icon, manifestInfo);
|
|
@@ -22,7 +22,7 @@ async function build(args) {
|
|
|
22
22
|
}
|
|
23
23
|
// build and upload ipa to App Store Connect
|
|
24
24
|
async function store(args) {
|
|
25
|
-
resource_1.ResourceManager.
|
|
25
|
+
resource_1.ResourceManager.initPlatform(args['platform']);
|
|
26
26
|
(0, check_1.checkStoreParams)(args);
|
|
27
27
|
/*
|
|
28
28
|
There are two ways to upload ipa to App Store Connect:
|
|
@@ -45,8 +45,8 @@ async function run(args) {
|
|
|
45
45
|
var _a;
|
|
46
46
|
const runCmd = JSON.stringify(args);
|
|
47
47
|
history_1.default.init(runCmd);
|
|
48
|
+
resource_1.ResourceManager.setupTempPath(args['platform']);
|
|
48
49
|
console.log('------------------- parse start -------------------');
|
|
49
|
-
resource_1.ResourceManager.checkPlatformPath(args['platform']);
|
|
50
50
|
const manifestInfo = await doPwa(args, true);
|
|
51
51
|
history_1.default.recordManifest(manifestInfo.json);
|
|
52
52
|
/*
|
|
@@ -64,6 +64,7 @@ async function run(args) {
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
resource_1.ResourceManager.pullPlatformModule(args['platform']);
|
|
67
68
|
const icon = await doReadyProject((_a = args['project']) !== null && _a !== void 0 ? _a : 'dist', manifestInfo);
|
|
68
69
|
await doXcode(args, icon, manifestInfo, true);
|
|
69
70
|
console.log('------------------- parse end -------------------');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function test(): void;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test = test;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
function configStartUrl(manifestStartUrl, base, manifestUrl, isNet) {
|
|
6
|
+
let start_url = manifestStartUrl !== null && manifestStartUrl !== void 0 ? manifestStartUrl : '/index.html';
|
|
7
|
+
if (!start_url.match(/\.html(\?|$)/)) {
|
|
8
|
+
const [path, query] = start_url.split('?');
|
|
9
|
+
start_url = path.endsWith('/') ? `${path}index.html` : `${path}/index.html`;
|
|
10
|
+
if (query)
|
|
11
|
+
start_url += `?${query}`;
|
|
12
|
+
}
|
|
13
|
+
const isStartUrl = validateURL(start_url);
|
|
14
|
+
const hasBase = base.length > 0;
|
|
15
|
+
if (hasBase) {
|
|
16
|
+
const isBaseUrl = validateURL(base);
|
|
17
|
+
if (!isStartUrl && !isBaseUrl) {
|
|
18
|
+
const staticWebRoot = (0, path_1.resolve)('./static-web');
|
|
19
|
+
let resolvedPath = (0, path_1.join)(base, start_url);
|
|
20
|
+
const normalizedPath = (0, path_1.normalize)(resolvedPath);
|
|
21
|
+
const safePath = (0, path_1.join)(staticWebRoot, normalizedPath);
|
|
22
|
+
start_url = (0, path_1.relative)(process.cwd(), safePath)
|
|
23
|
+
.replace(/^(\.\.\/)+/, './')
|
|
24
|
+
.replace(/\/$/, '');
|
|
25
|
+
}
|
|
26
|
+
else if (isStartUrl && !isBaseUrl) {
|
|
27
|
+
const startUrl = new URL(start_url);
|
|
28
|
+
const fullPath = (0, path_1.join)(base, startUrl.pathname) + startUrl.search + startUrl.hash;
|
|
29
|
+
let newBase = new URL('/', startUrl.origin);
|
|
30
|
+
start_url = new URL(fullPath, newBase).href;
|
|
31
|
+
}
|
|
32
|
+
else if (!isStartUrl && isBaseUrl) {
|
|
33
|
+
if (start_url.startsWith('/')) {
|
|
34
|
+
const baseUrl = new URL(base);
|
|
35
|
+
start_url = baseUrl.origin + (0, path_1.join)(baseUrl.pathname, start_url);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
start_url = new URL(start_url, base).href;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (isStartUrl && isBaseUrl) {
|
|
42
|
+
const startUrl = new URL(start_url);
|
|
43
|
+
const baseUrl = new URL(base);
|
|
44
|
+
const startFullPath = startUrl.pathname + startUrl.search + startUrl.hash;
|
|
45
|
+
start_url = new URL(startFullPath, baseUrl.origin + baseUrl.pathname).href;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (isNet) {
|
|
50
|
+
const murl = new URL(manifestUrl);
|
|
51
|
+
if (!isStartUrl) {
|
|
52
|
+
const newStartUrl = new URL(start_url, murl.origin);
|
|
53
|
+
start_url = newStartUrl.href;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const startUrl = new URL(start_url);
|
|
57
|
+
start_url =
|
|
58
|
+
murl.origin + startUrl.pathname + startUrl.search + startUrl.hash;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (!isStartUrl) {
|
|
62
|
+
const staticWebRoot = (0, path_1.resolve)('./static-web');
|
|
63
|
+
const resolvedPath = (0, path_1.resolve)(staticWebRoot, start_url);
|
|
64
|
+
const normalizedPath = (0, path_1.normalize)(resolvedPath);
|
|
65
|
+
const safePath = (0, path_1.join)(staticWebRoot, normalizedPath);
|
|
66
|
+
start_url = (0, path_1.relative)(process.cwd(), safePath)
|
|
67
|
+
.replace(/^(\.\.\/)+/, './')
|
|
68
|
+
.replace(/\/$/, '');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return start_url;
|
|
72
|
+
}
|
|
73
|
+
function configScope(start_url, scope) {
|
|
74
|
+
const isStartUrl = validateURL(start_url);
|
|
75
|
+
const isUrl = validateURL(scope);
|
|
76
|
+
if (isStartUrl && isUrl) {
|
|
77
|
+
const scopeURL = new URL(scope);
|
|
78
|
+
const startURL = new URL(start_url);
|
|
79
|
+
if (scopeURL.host !== startURL.host || start_url.indexOf(scope) !== 0) {
|
|
80
|
+
scope = parseRouter(start_url);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (isStartUrl && !isUrl) {
|
|
84
|
+
scope = new URL(scope, start_url).href;
|
|
85
|
+
}
|
|
86
|
+
else if (!isStartUrl && isUrl) {
|
|
87
|
+
const cleanPath = start_url.replace(/\/[^\/]+$/, '');
|
|
88
|
+
scope = (0, path_1.normalize)(cleanPath + '/');
|
|
89
|
+
}
|
|
90
|
+
// else {
|
|
91
|
+
// scope = join(parseRouter(start_url), scope)
|
|
92
|
+
// }
|
|
93
|
+
// scope = scope
|
|
94
|
+
return scope;
|
|
95
|
+
}
|
|
96
|
+
function validateURL(url) {
|
|
97
|
+
try {
|
|
98
|
+
new URL(url);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function parseRouter(url) {
|
|
106
|
+
let urlParts = url.split('/');
|
|
107
|
+
urlParts.pop();
|
|
108
|
+
let pathUrl = urlParts.join();
|
|
109
|
+
while (pathUrl.indexOf(',') >= 0) {
|
|
110
|
+
pathUrl = pathUrl.replace(',', '/');
|
|
111
|
+
}
|
|
112
|
+
return pathUrl;
|
|
113
|
+
}
|
|
114
|
+
function testStartUrl() {
|
|
115
|
+
console.log(configStartUrl('/', '', '/manifest.json', false));
|
|
116
|
+
console.log(configStartUrl('http://www.baidu.com', '', 'http://www.baidu.com/manifest.json', true));
|
|
117
|
+
console.log(configStartUrl('/', '/', '/manifest.json', false));
|
|
118
|
+
console.log(configStartUrl('/a.html?a=1', '/', '/manifest.json', false));
|
|
119
|
+
console.log(configStartUrl('http://www.baidu.com/test/a.html?a=1', '/xx', '/manifest.json', false));
|
|
120
|
+
console.log(configStartUrl('http://www.baidu.com/a.html?a=1', 'http://www.google.com/test', '/manifest.json', false));
|
|
121
|
+
console.log(configStartUrl('/test/index.html', '/public/aaa', '/manifest.json', false));
|
|
122
|
+
}
|
|
123
|
+
function testScope() {
|
|
124
|
+
console.log(configScope('/test/index.html', '/test'));
|
|
125
|
+
}
|
|
126
|
+
function test() {
|
|
127
|
+
// testStartUrl()
|
|
128
|
+
// testScope()
|
|
129
|
+
}
|
package/dist/lib/pwa/config.js
CHANGED
|
@@ -34,7 +34,7 @@ function configStartUrl(manifestJson, base, manifestUrl, isNet) {
|
|
|
34
34
|
const isBaseUrl = (0, validate_1.validateURL)(base);
|
|
35
35
|
if (!isStartUrl && !isBaseUrl) {
|
|
36
36
|
const staticWebRoot = (0, path_1.resolve)('./static-web');
|
|
37
|
-
const resolvedPath = (0, path_1.
|
|
37
|
+
const resolvedPath = (0, path_1.join)(base, start_url);
|
|
38
38
|
const normalizedPath = (0, path_1.normalize)(resolvedPath);
|
|
39
39
|
const safePath = (0, path_1.join)(staticWebRoot, normalizedPath);
|
|
40
40
|
start_url = (0, path_1.relative)(process.cwd(), safePath)
|
|
@@ -86,6 +86,13 @@ function configStartUrl(manifestJson, base, manifestUrl, isNet) {
|
|
|
86
86
|
.replace(/\/$/, '');
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
if (!start_url.match(/\.html(\?|$)/) &&
|
|
90
|
+
!(start_url.startsWith('http://') || start_url.startsWith('https://'))) {
|
|
91
|
+
const [path, query] = start_url.split('?');
|
|
92
|
+
start_url = path.endsWith('/') ? `${path}index.html` : `${path}/index.html`;
|
|
93
|
+
if (query)
|
|
94
|
+
start_url += `?${query}`;
|
|
95
|
+
}
|
|
89
96
|
return start_url;
|
|
90
97
|
}
|
|
91
98
|
function configScope(manifestJson) {
|
package/dist/lib/pwa/validate.js
CHANGED
|
@@ -44,46 +44,18 @@ function checkManifestJson(manifestJson, isDev = false) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function checkStartUrl(startUrl, manifestUrl, isNet, isDev = false) {
|
|
47
|
-
var isNetWeb = false;
|
|
48
47
|
if (isDev) {
|
|
49
48
|
return startUrl.startsWith('https://') || startUrl.startsWith('http://');
|
|
50
49
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
}
|
|
50
|
+
if (startUrl.startsWith('http://')) {
|
|
51
|
+
throw new CustomError_1.CustomError({
|
|
52
|
+
code: 4000,
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
54
|
+
message: 'In the Web Spatial App Manifest, the start_url must use https',
|
|
55
|
+
message_staring_params: {},
|
|
56
|
+
});
|
|
85
57
|
}
|
|
86
|
-
return
|
|
58
|
+
return startUrl.startsWith('https://');
|
|
87
59
|
}
|
|
88
60
|
async function checkIcons(manifest, manifestUrl, isDev = false) {
|
|
89
61
|
var _a, _b;
|
|
@@ -12,11 +12,13 @@ export declare const LOGO_DIRECTORY: string;
|
|
|
12
12
|
export declare class ResourceManager {
|
|
13
13
|
static moveProjectFrom(dir: string): Promise<void>;
|
|
14
14
|
static generateIcon(info: ManifestInfo): Promise<Jimp>;
|
|
15
|
+
static initPlatform(platform: string): void;
|
|
16
|
+
static setupTempPath(platform: string): void;
|
|
15
17
|
/**
|
|
16
18
|
* @description Check and set the platform path to ensure the existence of the specified platform module.
|
|
17
19
|
* If the module does not exist, it will be installed automatically.
|
|
18
20
|
* Also set the project directory, build directory, and export directory.
|
|
19
21
|
* @param platform The name of the platform to check, defaulting to 'visionos'
|
|
20
22
|
*/
|
|
21
|
-
static
|
|
23
|
+
static pullPlatformModule(platform: string): void;
|
|
22
24
|
}
|
|
@@ -47,13 +47,39 @@ class ResourceManager {
|
|
|
47
47
|
icon.resize(1024, 1024);
|
|
48
48
|
return icon;
|
|
49
49
|
}
|
|
50
|
+
static initPlatform(platform) {
|
|
51
|
+
this.setupTempPath(platform);
|
|
52
|
+
this.pullPlatformModule(platform);
|
|
53
|
+
}
|
|
54
|
+
static setupTempPath(platform) {
|
|
55
|
+
const usePlatform = platform !== null && platform !== void 0 ? platform : supportPlatform[0];
|
|
56
|
+
if (!supportPlatform.includes(usePlatform)) {
|
|
57
|
+
throw new Error(`not support platform ${usePlatform}, now WebSpatial only support ${supportPlatform.join(',')}`);
|
|
58
|
+
}
|
|
59
|
+
let tempDir = './node_modules/.webspatial-builder-temp';
|
|
60
|
+
let tempPlatformDir = (0, path_1.join)(tempDir, `platform-${usePlatform}`);
|
|
61
|
+
let tempProjectDir = (0, path_1.join)(tempPlatformDir, './project');
|
|
62
|
+
let temBuildDir = (0, path_1.join)(tempPlatformDir, './build');
|
|
63
|
+
let temExportDir = (0, path_1.join)(tempPlatformDir, './export');
|
|
64
|
+
let temTestDir = (0, path_1.join)(tempPlatformDir, './test');
|
|
65
|
+
if (!fs.existsSync(tempDir)) {
|
|
66
|
+
fs.mkdirSync(tempDir);
|
|
67
|
+
}
|
|
68
|
+
if (!fs.existsSync(tempPlatformDir)) {
|
|
69
|
+
fs.mkdirSync(tempPlatformDir);
|
|
70
|
+
}
|
|
71
|
+
exports.PROJECT_DIRECTORY = tempProjectDir;
|
|
72
|
+
exports.PROJECT_BUILD_DIRECTORY = temBuildDir;
|
|
73
|
+
exports.PROJECT_EXPORT_DIRECTORY = temExportDir;
|
|
74
|
+
exports.PROJECT_TEST_DIRECTORY = temTestDir;
|
|
75
|
+
}
|
|
50
76
|
/**
|
|
51
77
|
* @description Check and set the platform path to ensure the existence of the specified platform module.
|
|
52
78
|
* If the module does not exist, it will be installed automatically.
|
|
53
79
|
* Also set the project directory, build directory, and export directory.
|
|
54
80
|
* @param platform The name of the platform to check, defaulting to 'visionos'
|
|
55
81
|
*/
|
|
56
|
-
static
|
|
82
|
+
static pullPlatformModule(platform) {
|
|
57
83
|
const usePlatform = platform !== null && platform !== void 0 ? platform : supportPlatform[0];
|
|
58
84
|
if (!supportPlatform.includes(usePlatform)) {
|
|
59
85
|
throw new Error(`not support platform ${usePlatform}, now WebSpatial only support ${supportPlatform.join(',')}`);
|
|
@@ -68,36 +94,20 @@ class ResourceManager {
|
|
|
68
94
|
if (!hasModule) {
|
|
69
95
|
(0, child_process_1.execSync)(`cd ${(0, path_1.join)(__dirname, '../../../')} && pnpm add @webspatial/platform-${usePlatform}`);
|
|
70
96
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
let tempProjectDir = (0, path_1.join)(tempPlatformDir, './project');
|
|
74
|
-
let temBuildDir = (0, path_1.join)(tempPlatformDir, './build');
|
|
75
|
-
let temExportDir = (0, path_1.join)(tempPlatformDir, './export');
|
|
76
|
-
let temTestDir = (0, path_1.join)(tempPlatformDir, './test');
|
|
77
|
-
if (!fs.existsSync(tempDir)) {
|
|
78
|
-
fs.mkdirSync(tempDir);
|
|
79
|
-
}
|
|
80
|
-
if (!fs.existsSync(tempPlatformDir)) {
|
|
81
|
-
fs.mkdirSync(tempPlatformDir);
|
|
82
|
-
}
|
|
83
|
-
if (fs.existsSync(tempProjectDir)) {
|
|
84
|
-
(0, child_process_1.execSync)(`rm -rf ${tempProjectDir}`);
|
|
97
|
+
if (fs.existsSync(exports.PROJECT_DIRECTORY)) {
|
|
98
|
+
(0, child_process_1.execSync)(`rm -rf ${exports.PROJECT_DIRECTORY}`);
|
|
85
99
|
}
|
|
86
|
-
if (!fs.existsSync(
|
|
87
|
-
fs.mkdirSync(
|
|
100
|
+
if (!fs.existsSync(exports.PROJECT_BUILD_DIRECTORY)) {
|
|
101
|
+
fs.mkdirSync(exports.PROJECT_BUILD_DIRECTORY);
|
|
88
102
|
}
|
|
89
|
-
if (!fs.existsSync(
|
|
90
|
-
fs.mkdirSync(
|
|
103
|
+
if (!fs.existsSync(exports.PROJECT_EXPORT_DIRECTORY)) {
|
|
104
|
+
fs.mkdirSync(exports.PROJECT_EXPORT_DIRECTORY);
|
|
91
105
|
}
|
|
92
|
-
if (!fs.existsSync(
|
|
93
|
-
fs.mkdirSync(
|
|
106
|
+
if (!fs.existsSync(exports.PROJECT_TEST_DIRECTORY)) {
|
|
107
|
+
fs.mkdirSync(exports.PROJECT_TEST_DIRECTORY);
|
|
94
108
|
}
|
|
95
|
-
fs.mkdirSync(
|
|
96
|
-
(0, file_1.copyDir)(modulePath,
|
|
97
|
-
exports.PROJECT_DIRECTORY = tempProjectDir;
|
|
98
|
-
exports.PROJECT_BUILD_DIRECTORY = temBuildDir;
|
|
99
|
-
exports.PROJECT_EXPORT_DIRECTORY = temExportDir;
|
|
100
|
-
exports.PROJECT_TEST_DIRECTORY = temTestDir;
|
|
109
|
+
fs.mkdirSync(exports.PROJECT_DIRECTORY);
|
|
110
|
+
(0, file_1.copyDir)(modulePath, exports.PROJECT_DIRECTORY);
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
exports.ResourceManager = ResourceManager;
|
|
@@ -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 var useMainScene: Bool = USE_MAIN_SCENE\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: \"/\") ? \"
|
|
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 var useMainScene: Bool = USE_MAIN_SCENE\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";
|
|
@@ -37,7 +37,7 @@ struct PWAManager: Codable {
|
|
|
37
37
|
}
|
|
38
38
|
let startUrl = Bundle.main.url(forResource: start_url, withExtension: "", subdirectory: "")
|
|
39
39
|
start_url = startUrl!.absoluteString
|
|
40
|
-
scope = URL(string: (scope.starts(with: "/") ? "
|
|
40
|
+
scope = URL(string: (scope.starts(with: "/") ? "." : "./") + scope, relativeTo: Bundle.main.executableURL)!.absoluteString
|
|
41
41
|
isLocal = true
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -193,7 +193,7 @@ class XcodeProject {
|
|
|
193
193
|
var _a;
|
|
194
194
|
xcodeProject.updateProductName(manifest.name);
|
|
195
195
|
// set PRODUCT_BUNDLE_IDENTIFIER need ""
|
|
196
|
-
if (manifest.id
|
|
196
|
+
if (manifest.id) {
|
|
197
197
|
xcodeProject.updateBuildProperty('PRODUCT_BUNDLE_IDENTIFIER', `"${manifest.id}"`);
|
|
198
198
|
}
|
|
199
199
|
this.updateDeeplink((_a = manifest.protocol_handlers) !== null && _a !== void 0 ? _a : []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webspatial/builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
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": "^0.1.
|
|
43
|
+
"@webspatial/platform-visionos": "^0.1.22"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-terser": "^0.4.3",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"start": "tsc -w",
|
|
68
|
+
"test": "npm run build && bin/bundlepwa.js test",
|
|
68
69
|
"test1": "npm run build && bin/bundlepwa.js build --manifest=../testLocal/manifest.json --project=../testLocal --export=./export --version=1.0 --teamId=teamId",
|
|
69
70
|
"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",
|
|
70
71
|
"test3": "npm run build && bin/bundlepwa.js publish --name=webspatial --version=1.0 --u=username --p=password",
|