@liascript/exporter 2.3.0--0.10.1 → 2.4.1--0.10.4

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.
Files changed (47) hide show
  1. package/README.md +4 -0
  2. package/dist/assets/capacitor/Browser.51cc85cf.js +1 -0
  3. package/dist/assets/capacitor/index.2f2f5f28.js +2 -0
  4. package/dist/assets/{indexeddb/index.57ee398c.js → capacitor/index.e28f5e0c.js} +1 -1
  5. package/dist/assets/capacitor/index.html +1 -1
  6. package/dist/assets/capacitor/vendor/browser-matrix.min.js +18 -0
  7. package/dist/assets/capacitor/vendor/browser-matrix.min.js.map +1 -0
  8. package/dist/assets/indexeddb/Browser.51cc85cf.js +1 -0
  9. package/dist/assets/indexeddb/index.545f79a7.js +1 -0
  10. package/dist/assets/indexeddb/index.6609a7cb.js +1 -0
  11. package/dist/assets/indexeddb/index.986c0463.js +16 -0
  12. package/dist/assets/indexeddb/index.html +1 -1
  13. package/dist/assets/pdf/{index.8cfb3ae9.css → index.dfda5f81.css} +1 -1
  14. package/dist/assets/pdf/index.html +1 -1
  15. package/dist/assets/scorm1.2/index.545f79a7.js +1 -0
  16. package/dist/assets/scorm1.2/index.986c0463.js +16 -0
  17. package/dist/assets/scorm1.2/index.e6a0d4e2.js +1 -0
  18. package/dist/assets/scorm1.2/index.html +1 -1
  19. package/dist/assets/scorm2004/index.3d72e0c8.js +1 -0
  20. package/dist/assets/scorm2004/index.545f79a7.js +1 -0
  21. package/dist/assets/scorm2004/index.986c0463.js +16 -0
  22. package/dist/assets/scorm2004/index.html +1 -1
  23. package/dist/assets/web/index.48219c18.js +1 -0
  24. package/dist/assets/web/index.545f79a7.js +1 -0
  25. package/dist/assets/web/index.986c0463.js +16 -0
  26. package/dist/assets/web/index.html +1 -1
  27. package/dist/index.js +27 -9
  28. package/package.json +1 -1
  29. package/src/export/android.ts +40 -18
  30. package/src/export/ios.ts +149 -0
  31. package/src/export/windows.ts +151 -0
  32. package/src/index.ts +11 -2
  33. package/dist/assets/capacitor/Browser.94ce77da.js +0 -1
  34. package/dist/assets/capacitor/index.57ee398c.js +0 -1
  35. package/dist/assets/capacitor/index.6e6bc8ac.js +0 -2
  36. package/dist/assets/indexeddb/Browser.94ce77da.js +0 -1
  37. package/dist/assets/indexeddb/index.7769615a.js +0 -16
  38. package/dist/assets/indexeddb/index.9a879192.js +0 -1
  39. package/dist/assets/scorm1.2/index.184d7e9f.js +0 -1
  40. package/dist/assets/scorm1.2/index.57ee398c.js +0 -1
  41. package/dist/assets/scorm1.2/index.7769615a.js +0 -16
  42. package/dist/assets/scorm2004/index.40bdf751.js +0 -1
  43. package/dist/assets/scorm2004/index.57ee398c.js +0 -1
  44. package/dist/assets/scorm2004/index.7769615a.js +0 -16
  45. package/dist/assets/web/index.57ee398c.js +0 -1
  46. package/dist/assets/web/index.7769615a.js +0 -16
  47. package/dist/assets/web/index.e88b51b7.js +0 -1
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en"><head><title>Lia</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link rel="stylesheet" href="index.44dcebf0.css"><script defer type="module" src="index.57ee398c.js"></script><script defer type="module" src="index.db5b7a49.js"></script><script defer type="module" src="index.4d6fa6c6.js"></script><script defer type="module" src="index.e88b51b7.js"></script><script defer type="module" src="index.15b24674.js"></script><script defer type="module" src="index.14817ef5.js"></script><script defer type="module" src="index.7769615a.js"></script><script defer type="module" src="index.1df2912f.js"></script><script defer type="module" src="index.2b3e8b9a.js"></script><link rel="icon shortcut" sizes="192x192" href="up_/up_/assets/logo_192.png"><meta name="mobile-web-app-capable" content="yes"><meta name="application-name" content="Lia"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="apple-mobile-web-app-title" content="LiaScript"><meta name="msapplication-TileImage" content="up_/up_/assets/logo_192.png"><meta name="msapplication-TileColor" content="#0071c5"><meta name="msapplication-tap-highlight" content="no"><meta name="theme-color" content="#000000"><meta name="description" content="LiaScript is a service for running free and interactive online courses, build with its own Markup-language. So check out the following course ;-)"><link rel="apple-touch-icon" href="logo.abbc2cae.png"><link rel="icon" href="logo.abbc2cae.png" type="image/png"><style>.lds-dual-ring{display:inline-block;height:150px;width:150px}.lds-dual-ring:after{animation:lds-dual-ring 1.2s linear infinite;border-color:#000 #0000;border-radius:50%;border-style:solid;border-width:5px;content:" ";display:block;height:128px;margin:1px;width:128px}@keyframes lds-dual-ring{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}</style><link rel="stylesheet" href="index.da081100.css"></head><body> <noscript> This page requires JavaScript to be enabled! </noscript> </body></html>
1
+ <!DOCTYPE html><html lang="en"><head><title>Lia</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link rel="stylesheet" href="index.44dcebf0.css"><script defer type="module" src="index.545f79a7.js"></script><script defer type="module" src="index.db5b7a49.js"></script><script defer type="module" src="index.4d6fa6c6.js"></script><script defer type="module" src="index.48219c18.js"></script><script defer type="module" src="index.15b24674.js"></script><script defer type="module" src="index.14817ef5.js"></script><script defer type="module" src="index.986c0463.js"></script><script defer type="module" src="index.1df2912f.js"></script><script defer type="module" src="index.2b3e8b9a.js"></script><link rel="icon shortcut" sizes="192x192" href="up_/up_/assets/logo_192.png"><meta name="mobile-web-app-capable" content="yes"><meta name="application-name" content="Lia"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="apple-mobile-web-app-title" content="LiaScript"><meta name="msapplication-TileImage" content="up_/up_/assets/logo_192.png"><meta name="msapplication-TileColor" content="#0071c5"><meta name="msapplication-tap-highlight" content="no"><meta name="theme-color" content="#000000"><meta name="description" content="LiaScript is a service for running free and interactive online courses, build with its own Markup-language. So check out the following course ;-)"><link rel="apple-touch-icon" href="logo.abbc2cae.png"><link rel="icon" href="logo.abbc2cae.png" type="image/png"><style>.lds-dual-ring{display:inline-block;height:150px;width:150px}.lds-dual-ring:after{animation:lds-dual-ring 1.2s linear infinite;border-color:#000 #0000;border-radius:50%;border-style:solid;border-width:5px;content:" ";display:block;height:128px;margin:1px;width:128px}@keyframes lds-dual-ring{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}</style><link rel="stylesheet" href="index.da081100.css"></head><body> <noscript> This page requires JavaScript to be enabled! </noscript> </body></html>
package/dist/index.js CHANGED
@@ -11656,8 +11656,12 @@ type alias Process =
11656
11656
  var $author$project$Lia$Markdown$Survey$Types$Categorical = {
11657
11657
  $: 'Categorical'
11658
11658
  };
11659
+ var $author$project$Lia$Markdown$Survey$Types$Quantitative = {
11660
+ $: 'Quantitative'
11661
+ };
11662
+ var $author$project$Lia$Markdown$Survey$Types$isNumber = A2($elm$core$Basics$composeR, $elm$core$String$split(' '), A2($elm$core$Basics$composeR, $elm$core$List$head, A2($elm$core$Basics$composeR, $elm$core$Maybe$andThen($elm$core$String$toInt), $elm$core$Basics$neq($elm$core$Maybe$Nothing))));
11659
11663
  var $author$project$Lia$Markdown$Survey$Types$analyseType = function(ids) {
11660
- return $author$project$Lia$Markdown$Survey$Types$Categorical;
11664
+ return A2($elm$core$List$all, $author$project$Lia$Markdown$Survey$Types$isNumber, ids) ? $author$project$Lia$Markdown$Survey$Types$Quantitative : $author$project$Lia$Markdown$Survey$Types$Categorical;
11661
11665
  };
11662
11666
  var $author$project$Lia$Markdown$Survey$Parser$toVector = F2(function(bool, definition) {
11663
11667
  return A3($author$project$Lia$Markdown$Survey$Types$Vector, bool, definition, $author$project$Lia$Markdown$Survey$Types$analyseType(A2($elm$core$List$map, $elm$core$Tuple$first, definition)));
@@ -12716,8 +12720,10 @@ async function $3eed299f4b9e5004$export$372e2d09604f52f0(argument, json) {
12716
12720
  await $9Afec$fsextra.copy($9Afec$path.join(__dirname, './assets/capacitor'), $9Afec$path.join(tmpPath, './dist'));
12717
12721
  // copy logo and splash
12718
12722
  await $9Afec$fsextra.copy($9Afec$path.join(__dirname, './resources'), $9Afec$path.join(tmpPath, '../resources'));
12719
- // copy base path or readme-directory into temp
12720
- await $9Afec$fsextra.copy(argument.path, $9Afec$path.join(tmpPath, './dist/'), {
12723
+ if (argument['android-preview']) // create a link, this way, the app can be updated interactively
12724
+ await $9Afec$fsextra.symlink($9Afec$path.resolve(argument.path), $9Afec$path.join(tmpPath, './dist/res'), 'dir');
12725
+ else // copy base path or readme-directory into temp
12726
+ await $9Afec$fsextra.copy($9Afec$path.resolve(argument.path), $9Afec$path.join(tmpPath, './dist/res'), {
12721
12727
  filter: $320134ce32dd9048$export$3032dc2899b8ea9b
12722
12728
  });
12723
12729
  await $320134ce32dd9048$export$552bfb764b5cd2b4($9Afec$path.join(tmpPath, '../capacitor.config.json'), `{
@@ -12725,6 +12731,8 @@ async function $3eed299f4b9e5004$export$372e2d09604f52f0(argument, json) {
12725
12731
  "appName": "${argument['android-appName'] || json.lia.str_title}",
12726
12732
  "bundledWebRuntime": true,
12727
12733
  "webDir": "pro/dist",
12734
+ "linuxAndroidStudioPath": "${argument['android-sdk']}",
12735
+ "windowsAndroidStudioPath": "${argument['android-sdk']}",
12728
12736
  "plugins": {
12729
12737
  "SplashScreen": {
12730
12738
  "launchShowDuration": ${argument['android-splashDuration'] || 0}
@@ -12746,7 +12754,7 @@ async function $3eed299f4b9e5004$export$372e2d09604f52f0(argument, json) {
12746
12754
  }
12747
12755
  }`);
12748
12756
  let index = $9Afec$fsextra.readFileSync($9Afec$path.join(tmpPath, 'dist/index.html'), 'utf8');
12749
- index = $320134ce32dd9048$export$a976684a0efeb93f(`<script> if (!window.LIA) { window.LIA = {} } window.LIA.defaultCourseURL = "./${$9Afec$path.basename(argument.readme)}"</script>`, index);
12757
+ index = $320134ce32dd9048$export$a976684a0efeb93f(`<script> if (!window.LIA) { window.LIA = {} } window.LIA.defaultCourseURL = "./res/${$9Afec$path.basename(argument.readme)}"</script>`, index);
12750
12758
  try {
12751
12759
  await $320134ce32dd9048$export$552bfb764b5cd2b4($9Afec$path.join(tmpPath, 'dist/index.html'), index);
12752
12760
  } catch (e) {
@@ -12755,7 +12763,10 @@ async function $3eed299f4b9e5004$export$372e2d09604f52f0(argument, json) {
12755
12763
  }
12756
12764
  $3eed299f4b9e5004$var$execute(`cd ${tmpPath} && cd .. && npm i && npx cap add android && npx capacitor-resources -p "android" ${argument['android-icon'] ? '--icon ' + $9Afec$path.resolve(argument['android-icon']) : ''} ${argument['android-splash'] ? '--splash ' + $9Afec$path.resolve(argument['android-splash']) : ''}`, async function() {
12757
12765
  await $3eed299f4b9e5004$var$sdk(tmpPath, argument['android-sdk']);
12758
- $3eed299f4b9e5004$var$execute(`cd ${tmpPath} && cd .. && cd android && ./gradlew assembleDebug`, function() {
12766
+ if (argument['android-preview']) $3eed299f4b9e5004$var$execute(`cd ${tmpPath} && cd .. && npx cap open android`, ()=>{
12767
+ console.log('ready');
12768
+ });
12769
+ else $3eed299f4b9e5004$var$execute(`cd ${tmpPath} && cd .. && cd android && ./gradlew assembleDebug`, function() {
12759
12770
  console.warn('DONE');
12760
12771
  $9Afec$fsextra.copy($9Afec$path.join(tmpPath, '../android/app/build/outputs/apk/debug/app-debug.apk'), argument.output + '.apk');
12761
12772
  });
@@ -12781,13 +12792,14 @@ function $3eed299f4b9e5004$var$execute(cmd, callback) {
12781
12792
 
12782
12793
 
12783
12794
 
12795
+ // import * as IOS from './export/ios'
12784
12796
  $parcel$global.XMLHttpRequest = $9Afec$xhr2;
12785
12797
 
12786
12798
 
12787
12799
 
12788
12800
  const $ccdb061a5468de1f$var$argv = $9Afec$minimist(process.argv.slice(2));
12789
12801
  // -------------------------------Main Execution-------------------------------
12790
- if ($ccdb061a5468de1f$var$argv.v || $ccdb061a5468de1f$var$argv.version) console.log('version: 2.2.0--0.10.1');
12802
+ if ($ccdb061a5468de1f$var$argv.v || $ccdb061a5468de1f$var$argv.version) console.log('version: 2.4.1--0.10.4');
12791
12803
  else if ($ccdb061a5468de1f$var$argv.h || $ccdb061a5468de1f$var$argv.help) $ccdb061a5468de1f$var$help();
12792
12804
  else if ($ccdb061a5468de1f$var$argv.i || $ccdb061a5468de1f$var$argv.input) $ccdb061a5468de1f$var$run($ccdb061a5468de1f$var$parseArguments());
12793
12805
  else {
@@ -12833,14 +12845,18 @@ function $ccdb061a5468de1f$var$run(argument) {
12833
12845
  case 'android':
12834
12846
  $3eed299f4b9e5004$export$372e2d09604f52f0(argument, JSON.parse(string));
12835
12847
  break;
12836
- default:
12848
+ /*
12849
+ case 'ios': {
12850
+ IOS.exporter(argument, JSON.parse(string))
12851
+ break
12852
+ }*/ default:
12837
12853
  console.warn('unknown output format', argument.format);
12838
12854
  }
12839
12855
  });
12840
12856
  try {
12841
12857
  // the format is changed only locally, the SCORM and web exporters simply
12842
12858
  // require some meta data from the parsed json output
12843
- const format = argument.format == 'scorm1.2' || argument.format == 'scorm2004' || argument.format == 'pdf' || argument.format == 'web' || argument.format == 'ims' || argument.format == 'android' ? 'fulljson' : argument.format;
12859
+ const format = argument.format == 'scorm1.2' || argument.format == 'scorm2004' || argument.format == 'pdf' || argument.format == 'web' || argument.format == 'ims' || argument.format == 'android' || argument.format == 'ios' ? 'fulljson' : argument.format;
12844
12860
  if (!$320134ce32dd9048$export$bab98af026af71ac(argument.input)) {
12845
12861
  const data = $9Afec$fsextra.readFileSync(argument.input, 'utf8');
12846
12862
  app.ports.input.send([
@@ -12886,6 +12902,7 @@ function $ccdb061a5468de1f$var$help() {
12886
12902
  console.log('--android-icon Optional icon with 1024x1024 px');
12887
12903
  console.log('--android-splash Optional splash image with 2732x2732 px');
12888
12904
  console.log('--android-splashDuration Duration for splash-screen default 0 milliseconds');
12905
+ console.log('--android-preview Open course in Android-Studio');
12889
12906
  console.log('\nPDF settings:\n');
12890
12907
  console.log('--pdf-stylesheet Inject an local CSS for changing the appearance.');
12891
12908
  console.log('--pdf-theme LiaScript themes: default, turquoise, blue, red, yellow');
@@ -12953,7 +12970,8 @@ function $ccdb061a5468de1f$var$parseArguments() {
12953
12970
  'android-appName': $ccdb061a5468de1f$var$argv['android-appName'],
12954
12971
  'android-icon': $ccdb061a5468de1f$var$argv['android-icon'],
12955
12972
  'android-splash': $ccdb061a5468de1f$var$argv['android-splash'],
12956
- 'android-splashDuration': $ccdb061a5468de1f$var$argv['android-splashDuration']
12973
+ 'android-splashDuration': $ccdb061a5468de1f$var$argv['android-splashDuration'],
12974
+ 'android-preview': $ccdb061a5468de1f$var$argv['android-preview']
12957
12975
  };
12958
12976
  argument.format = argument.format.toLowerCase();
12959
12977
  if (argument.format == 'android') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liascript/exporter",
3
- "version": "2.3.0--0.10.1",
3
+ "version": "2.4.1--0.10.4",
4
4
  "description": "A generic exporter for LiaScript",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -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
- // copy base path or readme-directory into temp
43
- await fs.copy(argument.path, path.join(tmpPath, './dist/'), {
44
- filter: helper.filterHidden,
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 = "./${path.basename(
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
- execute(
110
- `cd ${tmpPath} && cd .. && cd android && ./gradlew assembleDebug`,
111
- function () {
112
- console.warn('DONE')
113
- fs.copy(
114
- path.join(
115
- tmpPath,
116
- '../android/app/build/outputs/apk/debug/app-debug.apk'
117
- ),
118
- argument.output + '.apk'
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
 
@@ -17,7 +18,7 @@ const argv = require('minimist')(process.argv.slice(2))
17
18
 
18
19
  // -------------------------------Main Execution-------------------------------
19
20
  if (argv.v || argv.version) {
20
- console.log('version: 2.2.0--0.10.1')
21
+ console.log('version: 2.4.1--0.10.4')
21
22
  } else if (argv.h || argv.help) {
22
23
  help()
23
24
  } else if (argv.i || argv.input) {
@@ -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()