@liascript/exporter 3.0.0--1.0.3 → 3.0.1--1.0.3

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 (72) hide show
  1. package/dist/assets/capacitor/{index.bfe7363b.js → index.a7f021f7.js} +1 -1
  2. package/dist/assets/capacitor/index.html +1 -1
  3. package/dist/assets/capacitor/{jszip.min.f6eda75b.js → jszip.min.43389eb1.js} +1 -1
  4. package/dist/assets/capacitor/{trystero-ipfs.min.b27a61d7.js → trystero-ipfs.min.f25fe3e7.js} +1 -1
  5. package/dist/assets/indexeddb/{index.599a57d6.js → index.4aceca2f.js} +1 -1
  6. package/dist/assets/indexeddb/index.html +1 -1
  7. package/dist/assets/indexeddb/{jszip.min.63142cc8.js → jszip.min.4fbcc13f.js} +1 -1
  8. package/dist/assets/scorm2004/{index.7a5820ab.js → index.33bec53a.js} +1 -1
  9. package/dist/assets/scorm2004/index.html +1 -1
  10. package/dist/assets/scorm2004/{jszip.min.63142cc8.js → jszip.min.4fbcc13f.js} +1 -1
  11. package/dist/assets/xapi/{index.018a032a.js → index.f2e89e49.js} +1 -1
  12. package/dist/assets/xapi/index.html +1 -1
  13. package/dist/assets/xapi/{jszip.min.eaecf580.js → jszip.min.19c66d77.js} +1 -1
  14. package/dist/index.js +47 -47
  15. package/dist/server/presets.json +94 -0
  16. package/dist/server/presets.yaml +120 -0
  17. package/dist/server/public/app.js +1 -0
  18. package/dist/server/public/assets/android.svg +38 -0
  19. package/dist/server/public/assets/cmi.svg +154 -0
  20. package/dist/server/public/assets/docx.svg +20 -0
  21. package/dist/server/public/assets/edX.svg +75 -0
  22. package/dist/server/public/assets/edx.svg +75 -0
  23. package/dist/server/public/assets/epub.svg +18 -0
  24. package/dist/server/public/assets/icon.svg +82 -0
  25. package/dist/server/public/assets/ilias.png +0 -0
  26. package/dist/server/public/assets/json.svg +4 -0
  27. package/dist/server/public/assets/learnworlds.png +0 -0
  28. package/dist/server/public/assets/moodle.svg +190 -0
  29. package/dist/server/public/assets/opal.png +0 -0
  30. package/dist/server/public/assets/openolat.png +0 -0
  31. package/dist/server/public/assets/pdf.svg +4 -0
  32. package/dist/server/public/assets/rdf.svg +4 -0
  33. package/dist/server/public/assets/scorm.png +0 -0
  34. package/dist/server/public/assets/web.png +0 -0
  35. package/dist/server/public/assets/xapi.png +0 -0
  36. package/dist/server/public/i18n.js +1 -0
  37. package/dist/server/public/index.html +1587 -0
  38. package/dist/server/public/locales/de.json +247 -0
  39. package/dist/server/public/locales/en.json +247 -0
  40. package/dist/server/public/status.html +251 -0
  41. package/dist/server/public/styles.css +712 -0
  42. package/package.json +5 -1
  43. package/.parcelrc +0 -3
  44. package/DESKTOP_APP_README.md +0 -58
  45. package/DOCKERHUB_DESCRIPTION.md +0 -52
  46. package/Dockerfile +0 -129
  47. package/PLAYSTORE_GUIDE.md +0 -172
  48. package/action.yml +0 -157
  49. package/custom.css +0 -10
  50. package/electron-builder.json +0 -149
  51. package/src/cli.ts +0 -69
  52. package/src/colorize.ts +0 -115
  53. package/src/export/android.ts +0 -419
  54. package/src/export/docx.ts +0 -1025
  55. package/src/export/epub.ts +0 -1306
  56. package/src/export/h5p.ts +0 -390
  57. package/src/export/helper.ts +0 -360
  58. package/src/export/ims.ts +0 -191
  59. package/src/export/pdf.ts +0 -406
  60. package/src/export/presets.ts +0 -220
  61. package/src/export/project.ts +0 -829
  62. package/src/export/rdf.ts +0 -551
  63. package/src/export/scorm12.ts +0 -167
  64. package/src/export/scorm2004.ts +0 -140
  65. package/src/export/web.ts +0 -306
  66. package/src/export/xapi.ts +0 -424
  67. package/src/exporter.ts +0 -296
  68. package/src/index.ts +0 -96
  69. package/src/parser.ts +0 -373
  70. package/src/presets.yaml +0 -219
  71. package/src/types.ts +0 -82
  72. package/tsconfig.json +0 -24
package/src/exporter.ts DELETED
@@ -1,296 +0,0 @@
1
- // @ts-expect-error - Elm module has no type definitions
2
- import { Elm } from '../LiaScript/src/elm/Worker.elm'
3
-
4
- import * as WEB from './export/web'
5
- import * as SCORM12 from './export/scorm12'
6
- import * as SCORM2004 from './export/scorm2004'
7
- import * as PDF from './export/pdf'
8
- import * as EPUB from './export/epub'
9
- import * as DOCX from './export/docx'
10
- import * as helper from './export/helper'
11
- import * as IMS from './export/ims'
12
- import * as ANDROID from './export/android'
13
- import * as PROJECT from './export/project'
14
- import * as RDF from './export/rdf'
15
- import * as XAPI from './export/xapi'
16
-
17
- import {
18
- ExportFormat,
19
- HelperCommand,
20
- ElmApp,
21
- ElmWorker,
22
- ProjectCollection,
23
- } from './types'
24
- import { Arguments } from './parser'
25
-
26
- import YAML from 'yaml'
27
- import path from 'path'
28
- import fs from 'fs-extra'
29
- import fetch from 'node-fetch'
30
-
31
- /**
32
- * Main exporter class that orchestrates the export process
33
- */
34
- export class Exporter {
35
- private collection: ProjectCollection | null = null
36
- private embed: string | undefined = undefined
37
-
38
- /**
39
- * Executes the export process for the given arguments
40
- */
41
- async run(argument: Arguments): Promise<void> {
42
- const app: ElmApp = (Elm as unknown as { Worker: ElmWorker }).Worker.init({
43
- flags: { cmd: '' },
44
- })
45
-
46
- this.setupHelperPort(app, argument)
47
- this.setupOutputPort(app, argument)
48
-
49
- await this.initiateExport(app, argument)
50
- }
51
-
52
- /**
53
- * Sets up the helper port for file loading and debugging
54
- */
55
- private setupHelperPort(app: ElmApp, argument: Arguments): void {
56
- app.ports.helper.subscribe(async ([cmd, param]) => {
57
- switch (cmd) {
58
- case HelperCommand.DEBUG:
59
- console.warn('DEBUG', param)
60
- break
61
- case HelperCommand.FILE:
62
- const template = path.resolve(path.dirname(argument.input), param)
63
- console.warn('loading:', template)
64
- const data = fs.readFileSync(template, 'utf8')
65
- app.ports.input.send([HelperCommand.TEMPLATE, param, data])
66
- break
67
- default:
68
- console.warn('unknown command:', cmd, param)
69
- }
70
- })
71
- }
72
-
73
- /**
74
- * Sets up the output port for handling export results
75
- */
76
- private setupOutputPort(app: ElmApp, argument: Arguments): void {
77
- app.ports.output.subscribe((event) => {
78
- let [ok, json] = event
79
-
80
- if (!ok) {
81
- console.warn('Export failed:', json)
82
- return
83
- }
84
-
85
- this.handleExportOutput(argument, json, app)
86
- })
87
- }
88
-
89
- /**
90
- * Routes output to the appropriate exporter based on format
91
- */
92
- private handleExportOutput(
93
- argument: Arguments,
94
- json: any,
95
- app: ElmApp,
96
- ): void {
97
- switch (argument.format) {
98
- case ExportFormat.JSON:
99
- case ExportFormat.FULL_JSON:
100
- this.exportJson(argument, json)
101
- break
102
- case RDF.format:
103
- RDF.exporter(argument, JSON.parse(json))
104
- break
105
- case SCORM12.format:
106
- this.exportScorm12(argument, JSON.parse(json))
107
- break
108
- case SCORM2004.format:
109
- this.exportScorm2004(argument, JSON.parse(json))
110
- break
111
- case IMS.format:
112
- IMS.exporter(argument, JSON.parse(json))
113
- break
114
- case WEB.format:
115
- WEB.exporter(argument, JSON.parse(json))
116
- break
117
- case PDF.format:
118
- PDF.exporter(argument)
119
- break
120
- case EPUB.format:
121
- EPUB.exporter(argument, JSON.parse(json))
122
- break
123
- case DOCX.format:
124
- DOCX.exporter(argument)
125
- break
126
- case ANDROID.format:
127
- ANDROID.exporter(argument, JSON.parse(json))
128
- break
129
- case XAPI.format:
130
- XAPI.exporter(argument, JSON.parse(json))
131
- break
132
- case PROJECT.format:
133
- this.handleProjectExport(argument, JSON.parse(json), app)
134
- break
135
- default:
136
- console.warn('unknown output format', argument.format)
137
- }
138
- }
139
-
140
- /**
141
- * Exports to JSON format
142
- */
143
- private exportJson(argument: Arguments, string: string): void {
144
- fs.writeFile(argument.output + '.json', string, function (err) {
145
- if (err) console.error(err)
146
- })
147
- }
148
-
149
- /**
150
- * Exports to SCORM 1.2 format with embedded content if configured
151
- */
152
- private exportScorm12(argument: Arguments, json: any): void {
153
- if (argument['scorm-embed']) {
154
- argument['scorm-embed'] = this.embed
155
- }
156
- SCORM12.exporter(argument, json)
157
- }
158
-
159
- /**
160
- * Exports to SCORM 2004 format with embedded content if configured
161
- */
162
- private exportScorm2004(argument: Arguments, json: any): void {
163
- if (argument['scorm-embed']) {
164
- argument['scorm-embed'] = this.embed
165
- }
166
- SCORM2004.exporter(argument, json)
167
- }
168
-
169
- /**
170
- * Handles multi-course project exports
171
- */
172
- private handleProjectExport(
173
- argument: Arguments,
174
- string: string,
175
- app: ElmApp,
176
- ): void {
177
- if (this.collection) {
178
- try {
179
- PROJECT.storeNext(this.collection, JSON.parse(string))
180
-
181
- const next = PROJECT.getNext(this.collection)
182
-
183
- if (next) {
184
- console.warn('loading:', next)
185
- app.ports.input.send([ExportFormat.FULL_JSON, next])
186
- } else {
187
- PROJECT.exporter(argument, this.collection)
188
- }
189
- } catch (e: unknown) {
190
- console.warn('project export error:', e)
191
- }
192
- }
193
- }
194
-
195
- /**
196
- * Initiates the export process based on input type and format
197
- */
198
- private async initiateExport(
199
- app: ElmApp,
200
- argument: Arguments,
201
- ): Promise<void> {
202
- try {
203
- const format = this.determineInternalFormat(argument.format)
204
-
205
- if (argument.format === PROJECT.format) {
206
- await this.handleProjectInput(app, argument, format)
207
- } else if (!helper.isURL(argument.input)) {
208
- await this.handleFileInput(app, argument, format)
209
- } else if (argument.format === PDF.format) {
210
- await PDF.exporter(argument)
211
- } else if (argument.format === DOCX.format) {
212
- await DOCX.exporter(argument)
213
- } else if (argument.format === RDF.format) {
214
- await this.handleUrlInput(app, argument, format)
215
- } else {
216
- console.warn('URLs are not allowed as input')
217
- }
218
- } catch (err: unknown) {
219
- console.error(err)
220
- }
221
- }
222
-
223
- /**
224
- * Determines the internal format for processing
225
- * Some exporters need fulljson as intermediate format
226
- */
227
- private determineInternalFormat(format: string): string {
228
- return format == SCORM12.format ||
229
- format == SCORM2004.format ||
230
- format == PDF.format ||
231
- format == EPUB.format ||
232
- format == DOCX.format ||
233
- format == WEB.format ||
234
- format == IMS.format ||
235
- format == ANDROID.format ||
236
- //format == IOS.format ||
237
- format == RDF.format ||
238
- format == XAPI.format ||
239
- format == PROJECT.format ||
240
- format == EPUB.format
241
- ? ExportFormat.FULL_JSON
242
- : format
243
- }
244
-
245
- /**
246
- * Handles project (multi-course) input
247
- */
248
- private async handleProjectInput(
249
- app: ElmApp,
250
- argument: Arguments,
251
- format: string,
252
- ): Promise<void> {
253
- const file = fs.readFileSync(argument.input, 'utf8')
254
- this.collection = YAML.parse(file)
255
-
256
- if (this.collection) {
257
- const next = PROJECT.getNext(this.collection)
258
-
259
- if (next === null) {
260
- PROJECT.exporter(argument, this.collection)
261
- } else {
262
- console.warn('loading:', next)
263
- app.ports.input.send([format, next])
264
- }
265
- }
266
- }
267
-
268
- /**
269
- * Handles file-based input
270
- */
271
- private async handleFileInput(
272
- app: ElmApp,
273
- argument: Arguments,
274
- format: string,
275
- ): Promise<void> {
276
- const data = fs.readFileSync(argument.input, 'utf8')
277
- this.embed = data
278
- app.ports.input.send([format, data])
279
- }
280
-
281
- /**
282
- * Handles URL-based input
283
- */
284
- private async handleUrlInput(
285
- app: ElmApp,
286
- argument: Arguments,
287
- format: string,
288
- ): Promise<void> {
289
- const resp = await fetch(argument.input, {})
290
- const data = await resp.text()
291
-
292
- if (data) {
293
- app.ports.input.send([format, data])
294
- }
295
- }
296
- }
package/src/index.ts DELETED
@@ -1,96 +0,0 @@
1
- /**
2
- * LiaScript-Exporter - Main Entry Point
3
- *
4
- * This module coordinates the command-line interface, argument parsing,
5
- * and export orchestration for converting LiaScript markdown files to
6
- * various output formats.
7
- */
8
-
9
- import packageJson from '../package.json'
10
- // @ts-expect-error - xhr2 has no type definitions
11
- import XMLHttpRequest from 'xhr2'
12
- // @ts-expect-error - minimist has no type definitions
13
- import minimist from 'minimist'
14
-
15
- import { displayHelp } from './cli'
16
- import {
17
- parseArguments,
18
- validateAndNormalize,
19
- parsePresetsArguments,
20
- } from './parser'
21
- import { Exporter } from './exporter'
22
- import { startServer } from './server/server'
23
- import * as PRESETS from './export/presets'
24
-
25
- // Setup global XMLHttpRequest for Node.js environment
26
- global.XMLHttpRequest = XMLHttpRequest
27
-
28
- const argv = minimist(process.argv.slice(2))
29
-
30
- /**
31
- * Main execution flow
32
- */
33
- async function main(): Promise<void> {
34
- // Check for serve command first (positional argument)
35
- const command = argv._[0]
36
-
37
- if (command === 'serve' || process.env.MODE === 'serve') {
38
- const port = argv.port || argv.p || 3000
39
- await startServer(port)
40
- } else if (argv.v || argv.version) {
41
- console.log('version:', packageJson.version)
42
- } else if (argv.h || argv.help) {
43
- displayHelp()
44
- } else if ((argv.f || argv.format) === 'presets') {
45
- // Handle presets mode
46
- handlePresetsMode()
47
- } else if (argv.i || argv.input) {
48
- const args = parseArguments()
49
- const validatedArgs = validateAndNormalize(args)
50
- const exporter = new Exporter()
51
- await exporter.run(validatedArgs)
52
- } else {
53
- console.warn('No input defined')
54
- displayHelp()
55
- }
56
- }
57
-
58
- /**
59
- * Handle preset mode operations
60
- */
61
- async function handlePresetsMode(): Promise<void> {
62
- // Get all remaining arguments as potential preset IDs
63
- const presetFlags = Object.keys(argv).filter(
64
- (key) =>
65
- key !== '_' &&
66
- key !== 'f' &&
67
- key !== 'format' &&
68
- key !== 'o' &&
69
- key !== 'output' &&
70
- key !== 'i' &&
71
- key !== 'input',
72
- )
73
-
74
- // Check if a preset ID is specified (as a flag like --moodle)
75
- const presetId = presetFlags.length > 0 ? presetFlags[0] : null
76
-
77
- if (!presetId) {
78
- // No preset specified, list all presets
79
- PRESETS.listPresets()
80
- } else if (!argv.i && !argv.input) {
81
- // Preset specified but no input file, show preset configuration
82
- PRESETS.showPresetConfig(presetId)
83
- } else {
84
- // Preset specified with input file, execute export with preset
85
- const args = parsePresetsArguments(presetId)
86
- const validatedArgs = validateAndNormalize(args)
87
- const exporter = new Exporter()
88
- await exporter.run(validatedArgs)
89
- }
90
- }
91
-
92
- // Execute main function
93
- main().catch((error) => {
94
- console.error('Fatal error:', error)
95
- process.exit(1)
96
- })