@liascript/exporter 2.3.0--0.10.1 → 2.4.0--0.10.1
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/README.md +4 -0
- package/dist/assets/capacitor/index.5db0ebe6.js +2 -0
- package/dist/assets/capacitor/{index.57ee398c.js → index.e28f5e0c.js} +1 -1
- package/dist/assets/capacitor/index.html +1 -1
- package/dist/assets/indexeddb/index.dac32534.js +1 -0
- package/dist/assets/{scorm1.2/index.57ee398c.js → indexeddb/index.e28f5e0c.js} +1 -1
- package/dist/assets/indexeddb/index.html +1 -1
- package/dist/assets/scorm1.2/index.93c27cec.js +1 -0
- package/dist/assets/{indexeddb/index.57ee398c.js → scorm1.2/index.e28f5e0c.js} +1 -1
- package/dist/assets/scorm1.2/index.html +1 -1
- package/dist/assets/scorm2004/index.4cb7f453.js +1 -0
- package/dist/assets/scorm2004/{index.57ee398c.js → index.e28f5e0c.js} +1 -1
- package/dist/assets/scorm2004/index.html +1 -1
- package/dist/assets/web/index.76d8a9d4.js +1 -0
- package/dist/assets/web/index.e28f5e0c.js +1 -0
- package/dist/assets/web/index.html +1 -1
- package/dist/index.js +21 -7
- package/package.json +1 -1
- package/src/export/android.ts +40 -18
- package/src/export/ios.ts +149 -0
- package/src/export/windows.ts +151 -0
- package/src/index.ts +10 -1
- package/dist/assets/capacitor/index.6e6bc8ac.js +0 -2
- package/dist/assets/indexeddb/index.9a879192.js +0 -1
- package/dist/assets/scorm1.2/index.184d7e9f.js +0 -1
- package/dist/assets/scorm2004/index.40bdf751.js +0 -1
- package/dist/assets/web/index.57ee398c.js +0 -1
- package/dist/assets/web/index.e88b51b7.js +0 -1
package/package.json
CHANGED
package/src/export/android.ts
CHANGED
|
@@ -19,6 +19,7 @@ export async function exporter(
|
|
|
19
19
|
'android-icon'?: string
|
|
20
20
|
'android-splash'?: string
|
|
21
21
|
'android-splashDuration'?: number
|
|
22
|
+
'android-preview'?: boolean
|
|
22
23
|
},
|
|
23
24
|
json: any
|
|
24
25
|
) {
|
|
@@ -39,10 +40,23 @@ export async function exporter(
|
|
|
39
40
|
path.join(tmpPath, '../resources')
|
|
40
41
|
)
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (argument['android-preview']) {
|
|
44
|
+
// create a link, this way, the app can be updated interactively
|
|
45
|
+
await fs.symlink(
|
|
46
|
+
path.resolve(argument.path),
|
|
47
|
+
path.join(tmpPath, './dist/res'),
|
|
48
|
+
'dir'
|
|
49
|
+
)
|
|
50
|
+
} else {
|
|
51
|
+
// copy base path or readme-directory into temp
|
|
52
|
+
await fs.copy(
|
|
53
|
+
path.resolve(argument.path),
|
|
54
|
+
path.join(tmpPath, './dist/res'),
|
|
55
|
+
{
|
|
56
|
+
filter: helper.filterHidden,
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
46
60
|
|
|
47
61
|
await helper.writeFile(
|
|
48
62
|
path.join(tmpPath, '../capacitor.config.json'),
|
|
@@ -51,6 +65,8 @@ export async function exporter(
|
|
|
51
65
|
"appName": "${argument['android-appName'] || json.lia.str_title}",
|
|
52
66
|
"bundledWebRuntime": true,
|
|
53
67
|
"webDir": "pro/dist",
|
|
68
|
+
"linuxAndroidStudioPath": "${argument['android-sdk']}",
|
|
69
|
+
"windowsAndroidStudioPath": "${argument['android-sdk']}",
|
|
54
70
|
"plugins": {
|
|
55
71
|
"SplashScreen": {
|
|
56
72
|
"launchShowDuration": ${argument['android-splashDuration'] || 0}
|
|
@@ -80,7 +96,7 @@ export async function exporter(
|
|
|
80
96
|
let index = fs.readFileSync(path.join(tmpPath, 'dist/index.html'), 'utf8')
|
|
81
97
|
|
|
82
98
|
index = helper.inject(
|
|
83
|
-
`<script> if (!window.LIA) { window.LIA = {} } window.LIA.defaultCourseURL = "
|
|
99
|
+
`<script> if (!window.LIA) { window.LIA = {} } window.LIA.defaultCourseURL = "./res/${path.basename(
|
|
84
100
|
argument.readme
|
|
85
101
|
)}"</script>`,
|
|
86
102
|
index
|
|
@@ -106,19 +122,25 @@ export async function exporter(
|
|
|
106
122
|
async function () {
|
|
107
123
|
await sdk(tmpPath, argument['android-sdk'])
|
|
108
124
|
|
|
109
|
-
|
|
110
|
-
`cd ${tmpPath} && cd .. &&
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
if (argument['android-preview']) {
|
|
126
|
+
execute(`cd ${tmpPath} && cd .. && npx cap open android`, () => {
|
|
127
|
+
console.log('ready')
|
|
128
|
+
})
|
|
129
|
+
} else {
|
|
130
|
+
execute(
|
|
131
|
+
`cd ${tmpPath} && cd .. && cd android && ./gradlew assembleDebug`,
|
|
132
|
+
function () {
|
|
133
|
+
console.warn('DONE')
|
|
134
|
+
fs.copy(
|
|
135
|
+
path.join(
|
|
136
|
+
tmpPath,
|
|
137
|
+
'../android/app/build/outputs/apk/debug/app-debug.apk'
|
|
138
|
+
),
|
|
139
|
+
argument.output + '.apk'
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
122
144
|
}
|
|
123
145
|
)
|
|
124
146
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import * as helper from './helper'
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const fs = require('fs-extra')
|
|
5
|
+
const { exec } = require('child_process')
|
|
6
|
+
|
|
7
|
+
export async function exporter(
|
|
8
|
+
argument: {
|
|
9
|
+
input: string
|
|
10
|
+
readme: string
|
|
11
|
+
output: string
|
|
12
|
+
format: string
|
|
13
|
+
path: string
|
|
14
|
+
key?: string
|
|
15
|
+
|
|
16
|
+
'ios-appId'?: string
|
|
17
|
+
'ios-appName'?: string
|
|
18
|
+
'ios-icon'?: string
|
|
19
|
+
'ios-splash'?: string
|
|
20
|
+
'ios-splashDuration'?: number
|
|
21
|
+
},
|
|
22
|
+
json: any
|
|
23
|
+
) {
|
|
24
|
+
// make temp folder
|
|
25
|
+
let tmp = await helper.tmpDir()
|
|
26
|
+
|
|
27
|
+
let tmpPath = path.join(tmp, 'pro')
|
|
28
|
+
|
|
29
|
+
// copy assets to temp/dist
|
|
30
|
+
await fs.copy(
|
|
31
|
+
path.join(__dirname, './assets/capacitor'),
|
|
32
|
+
path.join(tmpPath, './dist')
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
// copy logo and splash
|
|
36
|
+
await fs.copy(
|
|
37
|
+
path.join(__dirname, './resources'),
|
|
38
|
+
path.join(tmpPath, '../resources')
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
// copy base path or readme-directory into temp
|
|
42
|
+
await fs.copy(argument.path, path.join(tmpPath, './dist/'), {
|
|
43
|
+
filter: helper.filterHidden,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
await helper.writeFile(
|
|
47
|
+
path.join(tmpPath, '../capacitor.config.json'),
|
|
48
|
+
`{
|
|
49
|
+
"appId": "${argument['ios-appId']}",
|
|
50
|
+
"appName": "${argument['ios-appName'] || json.lia.str_title}",
|
|
51
|
+
"bundledWebRuntime": true,
|
|
52
|
+
"webDir": "pro/dist",
|
|
53
|
+
"plugins": {
|
|
54
|
+
"SplashScreen": {
|
|
55
|
+
"launchShowDuration": ${argument['ios-splashDuration'] || 0}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}`
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
await helper.writeFile(
|
|
62
|
+
path.join(tmpPath, '../package.json'),
|
|
63
|
+
`{
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "npx cap add ios"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@capacitor-community/text-to-speech": "^1.1.2",
|
|
69
|
+
"@capacitor/cli": "^3.4.3",
|
|
70
|
+
"@capacitor/ios": "^3.4.1",
|
|
71
|
+
"capacitor-resources": "^2.0.5"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">= 12"
|
|
75
|
+
}
|
|
76
|
+
}`
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
let index = fs.readFileSync(path.join(tmpPath, 'dist/index.html'), 'utf8')
|
|
80
|
+
|
|
81
|
+
index = helper.inject(
|
|
82
|
+
`<script> if (!window.LIA) { window.LIA = {} } window.LIA.defaultCourseURL = "./${path.basename(
|
|
83
|
+
argument.readme
|
|
84
|
+
)}"</script>`,
|
|
85
|
+
index
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
await helper.writeFile(path.join(tmpPath, 'dist/index.html'), index)
|
|
90
|
+
} catch (e) {
|
|
91
|
+
console.warn(e)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
execute(
|
|
96
|
+
`cd ${tmpPath} && cd .. && npm i && npx cap add ios && npx capacitor-resources -p "ios" ${
|
|
97
|
+
argument['ios-icon'] ? '--icon ' + path.resolve(argument['ios-icon']) : ''
|
|
98
|
+
} ${
|
|
99
|
+
argument['ios-splash']
|
|
100
|
+
? '--splash ' + path.resolve(argument['ios-splash'])
|
|
101
|
+
: ''
|
|
102
|
+
}`,
|
|
103
|
+
async function () {
|
|
104
|
+
// await sdk(tmpPath, argument['android-sdk'])
|
|
105
|
+
|
|
106
|
+
execute(
|
|
107
|
+
`cd ${tmpPath} && cd .. && cd ios && ./gradlew assembleDebug`,
|
|
108
|
+
function () {
|
|
109
|
+
console.warn('DONE')
|
|
110
|
+
fs.copy(
|
|
111
|
+
path.join(
|
|
112
|
+
tmpPath,
|
|
113
|
+
'../android/app/build/outputs/apk/debug/app-debug.apk'
|
|
114
|
+
),
|
|
115
|
+
argument.output + '.apk'
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function sdk(tmpPath: string, uri?: string) {
|
|
124
|
+
if (!uri) return
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
helper.writeFile(
|
|
128
|
+
path.join(tmpPath, '../android/local.properties'),
|
|
129
|
+
`sdk.dir=${uri}`
|
|
130
|
+
)
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.warn(e)
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function execute(cmd: string, callback) {
|
|
138
|
+
exec(cmd, async (error, stdout, stderr) => {
|
|
139
|
+
if (error) {
|
|
140
|
+
console.log(`error: ${error.message}`)
|
|
141
|
+
}
|
|
142
|
+
if (stderr) {
|
|
143
|
+
console.log(`stderr: ${stderr}`)
|
|
144
|
+
}
|
|
145
|
+
console.log(`stdout: ${stdout}`)
|
|
146
|
+
|
|
147
|
+
callback()
|
|
148
|
+
})
|
|
149
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as helper from './helper'
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const fs = require('fs-extra')
|
|
5
|
+
const { exec } = require('child_process')
|
|
6
|
+
|
|
7
|
+
export async function exporter(
|
|
8
|
+
argument: {
|
|
9
|
+
input: string
|
|
10
|
+
readme: string
|
|
11
|
+
output: string
|
|
12
|
+
format: string
|
|
13
|
+
path: string
|
|
14
|
+
key?: string
|
|
15
|
+
|
|
16
|
+
'windows-appId'?: string
|
|
17
|
+
'windows-appName'?: string
|
|
18
|
+
'windows-icon'?: string
|
|
19
|
+
'windows-splash'?: string
|
|
20
|
+
'windows-splashDuration'?: number
|
|
21
|
+
},
|
|
22
|
+
json: any
|
|
23
|
+
) {
|
|
24
|
+
// make temp folder
|
|
25
|
+
let tmp = await helper.tmpDir()
|
|
26
|
+
|
|
27
|
+
let tmpPath = path.join(tmp, 'pro')
|
|
28
|
+
|
|
29
|
+
// copy assets to temp/dist
|
|
30
|
+
await fs.copy(
|
|
31
|
+
path.join(__dirname, './assets/capacitor'),
|
|
32
|
+
path.join(tmpPath, './dist')
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
// copy logo and splash
|
|
36
|
+
await fs.copy(
|
|
37
|
+
path.join(__dirname, './resources'),
|
|
38
|
+
path.join(tmpPath, '../resources')
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
// copy base path or readme-directory into temp
|
|
42
|
+
await fs.copy(argument.path, path.join(tmpPath, './dist/'), {
|
|
43
|
+
filter: helper.filterHidden,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
await helper.writeFile(
|
|
47
|
+
path.join(tmpPath, '../capacitor.config.json'),
|
|
48
|
+
`{
|
|
49
|
+
"appId": "${argument['windows-appId']}",
|
|
50
|
+
"appName": "${argument['windows-appName'] || json.lia.str_title}",
|
|
51
|
+
"bundledWebRuntime": true,
|
|
52
|
+
"webDir": "pro/dist",
|
|
53
|
+
"plugins": {
|
|
54
|
+
"SplashScreen": {
|
|
55
|
+
"launchShowDuration": ${argument['windows-splashDuration'] || 0}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}`
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
await helper.writeFile(
|
|
62
|
+
path.join(tmpPath, '../package.json'),
|
|
63
|
+
`{
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "npx cap add android"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@capacitor-community/text-to-speech": "^1.1.2",
|
|
69
|
+
"@capacitor/android": "^3.4.1",
|
|
70
|
+
"@capacitor/cli": "^3.4.3",
|
|
71
|
+
"capacitor-resources": "^2.0.5"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">= 12"
|
|
75
|
+
}
|
|
76
|
+
}`
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
let index = fs.readFileSync(path.join(tmpPath, 'dist/index.html'), 'utf8')
|
|
80
|
+
|
|
81
|
+
index = helper.inject(
|
|
82
|
+
`<script> if (!window.LIA) { window.LIA = {} } window.LIA.defaultCourseURL = "./${path.basename(
|
|
83
|
+
argument.readme
|
|
84
|
+
)}"</script>`,
|
|
85
|
+
index
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
await helper.writeFile(path.join(tmpPath, 'dist/index.html'), index)
|
|
90
|
+
} catch (e) {
|
|
91
|
+
console.warn(e)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
execute(
|
|
96
|
+
`cd ${tmpPath} && cd .. && npm i && npx cap add android && npx capacitor-resources -p "android" ${
|
|
97
|
+
argument['android-icon']
|
|
98
|
+
? '--icon ' + path.resolve(argument['android-icon'])
|
|
99
|
+
: ''
|
|
100
|
+
} ${
|
|
101
|
+
argument['android-splash']
|
|
102
|
+
? '--splash ' + path.resolve(argument['android-splash'])
|
|
103
|
+
: ''
|
|
104
|
+
}`,
|
|
105
|
+
async function () {
|
|
106
|
+
await sdk(tmpPath, argument['android-sdk'])
|
|
107
|
+
|
|
108
|
+
execute(
|
|
109
|
+
`cd ${tmpPath} && cd .. && cd android && ./gradlew assembleDebug`,
|
|
110
|
+
function () {
|
|
111
|
+
console.warn('DONE')
|
|
112
|
+
fs.copy(
|
|
113
|
+
path.join(
|
|
114
|
+
tmpPath,
|
|
115
|
+
'../android/app/build/outputs/apk/debug/app-debug.apk'
|
|
116
|
+
),
|
|
117
|
+
argument.output + '.apk'
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function sdk(tmpPath: string, uri?: string) {
|
|
126
|
+
if (!uri) return
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
helper.writeFile(
|
|
130
|
+
path.join(tmpPath, '../android/local.properties'),
|
|
131
|
+
`sdk.dir=${uri}`
|
|
132
|
+
)
|
|
133
|
+
} catch (e) {
|
|
134
|
+
console.warn(e)
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function execute(cmd: string, callback) {
|
|
140
|
+
exec(cmd, async (error, stdout, stderr) => {
|
|
141
|
+
if (error) {
|
|
142
|
+
console.log(`error: ${error.message}`)
|
|
143
|
+
}
|
|
144
|
+
if (stderr) {
|
|
145
|
+
console.log(`stderr: ${stderr}`)
|
|
146
|
+
}
|
|
147
|
+
console.log(`stdout: ${stdout}`)
|
|
148
|
+
|
|
149
|
+
callback()
|
|
150
|
+
})
|
|
151
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as PDF from './export/pdf'
|
|
|
8
8
|
import * as helper from './export/helper'
|
|
9
9
|
import * as IMS from './export/ims'
|
|
10
10
|
import * as ANDROID from './export/android'
|
|
11
|
+
// import * as IOS from './export/ios'
|
|
11
12
|
|
|
12
13
|
global.XMLHttpRequest = require('xhr2')
|
|
13
14
|
|
|
@@ -71,6 +72,11 @@ function run(argument) {
|
|
|
71
72
|
ANDROID.exporter(argument, JSON.parse(string))
|
|
72
73
|
break
|
|
73
74
|
}
|
|
75
|
+
/*
|
|
76
|
+
case 'ios': {
|
|
77
|
+
IOS.exporter(argument, JSON.parse(string))
|
|
78
|
+
break
|
|
79
|
+
}*/
|
|
74
80
|
default: {
|
|
75
81
|
console.warn('unknown output format', argument.format)
|
|
76
82
|
}
|
|
@@ -86,7 +92,8 @@ function run(argument) {
|
|
|
86
92
|
argument.format == 'pdf' ||
|
|
87
93
|
argument.format == 'web' ||
|
|
88
94
|
argument.format == 'ims' ||
|
|
89
|
-
argument.format == 'android'
|
|
95
|
+
argument.format == 'android' ||
|
|
96
|
+
argument.format == 'ios'
|
|
90
97
|
? 'fulljson'
|
|
91
98
|
: argument.format
|
|
92
99
|
|
|
@@ -181,6 +188,7 @@ function help() {
|
|
|
181
188
|
console.log(
|
|
182
189
|
'--android-splashDuration Duration for splash-screen default 0 milliseconds'
|
|
183
190
|
)
|
|
191
|
+
console.log('--android-preview Open course in Android-Studio')
|
|
184
192
|
|
|
185
193
|
console.log('\nPDF settings:\n')
|
|
186
194
|
console.log(
|
|
@@ -300,6 +308,7 @@ function parseArguments() {
|
|
|
300
308
|
'android-icon': argv['android-icon'],
|
|
301
309
|
'android-splash': argv['android-splash'],
|
|
302
310
|
'android-splashDuration': argv['android-splashDuration'],
|
|
311
|
+
'android-preview': argv['android-preview'],
|
|
303
312
|
}
|
|
304
313
|
|
|
305
314
|
argument.format = argument.format.toLowerCase()
|