execonvert 0.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +194 -0
  3. package/THIRD_PARTY_NOTICES.md +42 -0
  4. package/bin/execonvert.js +21 -0
  5. package/dist/cli/app/public/THIRD_PARTY_NOTICES.md +32 -0
  6. package/dist/cli/app/public/base.elpx +0 -0
  7. package/dist/cli/app/public/exe_math_assets.zip +0 -0
  8. package/dist/cli/app/public/exelearning/app/common/common_i18n.js +79 -0
  9. package/dist/cli/app/public/exelearning/app/common/exe_powered_logo/exe_powered_logo.png +0 -0
  10. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.ca.js +79 -0
  11. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.de.js +79 -0
  12. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.en.js +79 -0
  13. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.eo.js +79 -0
  14. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.es.js +79 -0
  15. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.eu.js +79 -0
  16. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.gl.js +79 -0
  17. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.it.js +79 -0
  18. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.pt.js +79 -0
  19. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.ro.js +79 -0
  20. package/dist/cli/app/public/exelearning/app/common/i18n/common_i18n.va.js +79 -0
  21. package/dist/cli/app/public/exelearning/bundles/common.zip +0 -0
  22. package/dist/cli/app/public/exelearning/bundles/content-css.zip +0 -0
  23. package/dist/cli/app/public/exelearning/bundles/idevices.zip +0 -0
  24. package/dist/cli/app/public/exelearning/bundles/libs.zip +0 -0
  25. package/dist/cli/app/public/exelearning/bundles/manifest.json +110 -0
  26. package/dist/cli/app/public/exelearning/bundles/themes/base.zip +0 -0
  27. package/dist/cli/app/public/exelearning/bundles/themes/flux.zip +0 -0
  28. package/dist/cli/app/public/exelearning/bundles/themes/neo.zip +0 -0
  29. package/dist/cli/app/public/exelearning/bundles/themes/nova.zip +0 -0
  30. package/dist/cli/app/public/exelearning/bundles/themes/universal.zip +0 -0
  31. package/dist/cli/app/public/exelearning/bundles/themes/zen.zip +0 -0
  32. package/dist/cli/app/public/exelearning/exporters.bundle.js +12638 -0
  33. package/dist/cli/app/public/exelearning/importers.bundle.js +14061 -0
  34. package/dist/cli/app/public/exelearning/runtime-source.json +10 -0
  35. package/dist/cli/app/public/favicon.svg +11 -0
  36. package/dist/cli/app/public/idevices/text/text.css +16 -0
  37. package/dist/cli/app/public/idevices/text/text.html +3 -0
  38. package/dist/cli/app/public/idevices/text/text.js +291 -0
  39. package/dist/cli/app/public/info/cli.html +955 -0
  40. package/dist/cli/app/public/info/docx.svg +7 -0
  41. package/dist/cli/app/public/info/elpx-icon.png +0 -0
  42. package/dist/cli/app/public/info/exe-old.png +0 -0
  43. package/dist/cli/app/public/info/execonvert-cli-icon.svg +16 -0
  44. package/dist/cli/app/public/info/execonvert-icon.svg +11 -0
  45. package/dist/cli/app/public/info/index.html +723 -0
  46. package/dist/cli/app/public/info/markdown.svg +1 -0
  47. package/dist/cli/app/public/info/pdf.svg +14 -0
  48. package/dist/cli/app/public/libs/exe_math/LICENSE +202 -0
  49. package/dist/cli/app/public/libs/exe_math/a11y/assistive-mml.js +1 -0
  50. package/dist/cli/app/public/libs/exe_math/a11y/complexity.js +1 -0
  51. package/dist/cli/app/public/libs/exe_math/a11y/explorer.js +1 -0
  52. package/dist/cli/app/public/libs/exe_math/a11y/semantic-enrich.js +1 -0
  53. package/dist/cli/app/public/libs/exe_math/a11y/speech.js +1 -0
  54. package/dist/cli/app/public/libs/exe_math/a11y/sre.js +1 -0
  55. package/dist/cli/app/public/libs/exe_math/adaptors/jsdom.js +1 -0
  56. package/dist/cli/app/public/libs/exe_math/adaptors/linkedom.js +1 -0
  57. package/dist/cli/app/public/libs/exe_math/adaptors/liteDOM.js +1 -0
  58. package/dist/cli/app/public/libs/exe_math/core.js +1 -0
  59. package/dist/cli/app/public/libs/exe_math/input/asciimath.js +1 -0
  60. package/dist/cli/app/public/libs/exe_math/input/mml/entities.js +1 -0
  61. package/dist/cli/app/public/libs/exe_math/input/mml/extensions/mml3.js +1 -0
  62. package/dist/cli/app/public/libs/exe_math/input/mml/extensions/mml3.sef.json +1 -0
  63. package/dist/cli/app/public/libs/exe_math/input/mml.js +1 -0
  64. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/action.js +1 -0
  65. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/ams.js +1 -0
  66. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/amscd.js +1 -0
  67. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/autoload.js +1 -0
  68. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/bbm.js +1 -0
  69. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/bboldx.js +1 -0
  70. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/bbox.js +1 -0
  71. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/begingroup.js +1 -0
  72. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/boldsymbol.js +1 -0
  73. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/braket.js +1 -0
  74. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/bussproofs.js +1 -0
  75. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/cancel.js +1 -0
  76. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/cases.js +1 -0
  77. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/centernot.js +1 -0
  78. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/color.js +1 -0
  79. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/colortbl.js +1 -0
  80. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/colorv2.js +1 -0
  81. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/configmacros.js +1 -0
  82. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/dsfont.js +1 -0
  83. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/empheq.js +1 -0
  84. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/enclose.js +1 -0
  85. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/extpfeil.js +1 -0
  86. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/gensymb.js +1 -0
  87. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/html.js +1 -0
  88. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/mathtools.js +1 -0
  89. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/mhchem.js +34 -0
  90. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/newcommand.js +1 -0
  91. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/noerrors.js +1 -0
  92. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/noundefined.js +1 -0
  93. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/physics.js +1 -0
  94. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/require.js +1 -0
  95. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/setoptions.js +1 -0
  96. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/tagformat.js +1 -0
  97. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/texhtml.js +1 -0
  98. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/textcomp.js +1 -0
  99. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/textmacros.js +1 -0
  100. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/unicode.js +1 -0
  101. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/units.js +1 -0
  102. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/upgreek.js +1 -0
  103. package/dist/cli/app/public/libs/exe_math/input/tex/extensions/verb.js +1 -0
  104. package/dist/cli/app/public/libs/exe_math/input/tex-base.js +1 -0
  105. package/dist/cli/app/public/libs/exe_math/input/tex.js +1 -0
  106. package/dist/cli/app/public/libs/exe_math/loader.js +1 -0
  107. package/dist/cli/app/public/libs/exe_math/output/chtml.js +1 -0
  108. package/dist/cli/app/public/libs/exe_math/output/svg.js +1 -0
  109. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/af.json +146 -0
  110. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/base.json +137 -0
  111. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/ca.json +140 -0
  112. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/da.json +140 -0
  113. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/de.json +146 -0
  114. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/en.json +158 -0
  115. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/es.json +140 -0
  116. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/euro.json +32 -0
  117. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/fr.json +146 -0
  118. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/hi.json +146 -0
  119. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/it.json +146 -0
  120. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/ko.json +146 -0
  121. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/nb.json +146 -0
  122. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/nemeth.json +125 -0
  123. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/nn.json +146 -0
  124. package/dist/cli/app/public/libs/exe_math/sre/mathmaps/sv.json +146 -0
  125. package/dist/cli/app/public/libs/exe_math/sre/require.d.mts +1 -0
  126. package/dist/cli/app/public/libs/exe_math/sre/require.mjs +2 -0
  127. package/dist/cli/app/public/libs/exe_math/sre/speech-worker.js +1 -0
  128. package/dist/cli/app/public/libs/exe_math/startup.js +1 -0
  129. package/dist/cli/app/public/libs/exe_math/tex-mml-svg.js +1 -0
  130. package/dist/cli/app/public/libs/exe_math/ui/lazy.js +1 -0
  131. package/dist/cli/app/public/libs/exe_math/ui/menu.js +1 -0
  132. package/dist/cli/app/public/libs/exe_math/ui/safe.js +1 -0
  133. package/dist/cli/cli/execonvert.js +807 -0
  134. package/dist/cli/cli/runtime.js +237 -0
  135. package/dist/cli/package.json +3 -0
  136. package/dist/cli/src/converter.js +5078 -0
  137. package/dist/cli/src/docx-import.js +1121 -0
  138. package/dist/cli/src/elpx-markdown.js +201 -0
  139. package/dist/cli/src/i18n.js +485 -0
  140. package/dist/cli/src/index.js +1 -0
  141. package/dist/cli/src/legacy-elp.js +846 -0
  142. package/dist/cli/src/markdown-import.js +26 -0
  143. package/package.json +68 -0
@@ -0,0 +1,237 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { DOMParser, parseHTML } from 'linkedom';
4
+ let configured = false;
5
+ const require = createRequire(import.meta.url);
6
+ let cliPdfWindow = null;
7
+ class CliXmlSerializer {
8
+ serializeToString(node) {
9
+ if (node && typeof node === 'object') {
10
+ const candidate = node;
11
+ if (typeof candidate.outerHTML === 'string') {
12
+ return candidate.outerHTML;
13
+ }
14
+ if (candidate.documentElement?.outerHTML) {
15
+ return candidate.documentElement.outerHTML;
16
+ }
17
+ if (typeof candidate.toString === 'function') {
18
+ return candidate.toString();
19
+ }
20
+ }
21
+ return String(node ?? '');
22
+ }
23
+ }
24
+ function installReplaceWithPolyfill(window) {
25
+ const toFragment = (referenceNode, nodes) => {
26
+ const document = (referenceNode.ownerDocument || window.document);
27
+ const fragment = document.createDocumentFragment();
28
+ for (const node of nodes) {
29
+ if (typeof node === 'string') {
30
+ fragment.appendChild(document.createTextNode(node));
31
+ continue;
32
+ }
33
+ fragment.appendChild(node);
34
+ }
35
+ return fragment;
36
+ };
37
+ const installOn = (ctor) => {
38
+ if (!ctor || typeof ctor !== 'function') {
39
+ return;
40
+ }
41
+ const prototype = ctor.prototype;
42
+ if (!prototype) {
43
+ return;
44
+ }
45
+ if (typeof prototype.replaceWith !== 'function') {
46
+ Object.defineProperty(prototype, 'replaceWith', {
47
+ configurable: true,
48
+ writable: true,
49
+ value: function replaceWith(...nodes) {
50
+ const parent = this.parentNode;
51
+ if (!parent) {
52
+ return;
53
+ }
54
+ parent.replaceChild(toFragment(this, nodes), this);
55
+ },
56
+ });
57
+ }
58
+ if (typeof prototype.append !== 'function') {
59
+ Object.defineProperty(prototype, 'append', {
60
+ configurable: true,
61
+ writable: true,
62
+ value: function append(...nodes) {
63
+ this.appendChild(toFragment(this, nodes));
64
+ },
65
+ });
66
+ }
67
+ if (typeof prototype.prepend !== 'function') {
68
+ Object.defineProperty(prototype, 'prepend', {
69
+ configurable: true,
70
+ writable: true,
71
+ value: function prepend(...nodes) {
72
+ this.insertBefore(toFragment(this, nodes), this.firstChild);
73
+ },
74
+ });
75
+ }
76
+ if (typeof prototype.before !== 'function') {
77
+ Object.defineProperty(prototype, 'before', {
78
+ configurable: true,
79
+ writable: true,
80
+ value: function before(...nodes) {
81
+ const parent = this.parentNode;
82
+ if (!parent) {
83
+ return;
84
+ }
85
+ parent.insertBefore(toFragment(this, nodes), this);
86
+ },
87
+ });
88
+ }
89
+ if (typeof prototype.after !== 'function') {
90
+ Object.defineProperty(prototype, 'after', {
91
+ configurable: true,
92
+ writable: true,
93
+ value: function after(...nodes) {
94
+ const parent = this.parentNode;
95
+ if (!parent) {
96
+ return;
97
+ }
98
+ parent.insertBefore(toFragment(this, nodes), this.nextSibling);
99
+ },
100
+ });
101
+ }
102
+ };
103
+ installOn(window.Element);
104
+ installOn(window.Text);
105
+ installOn(window.CharacterData);
106
+ installOn(window.DocumentType);
107
+ }
108
+ function setupCliDom() {
109
+ if (configured) {
110
+ return;
111
+ }
112
+ const { window } = parseHTML('<!doctype html><html><head></head><body></body></html>');
113
+ const globals = {
114
+ window,
115
+ document: window.document,
116
+ DOMParser: typeof window.DOMParser === 'function' ? window.DOMParser : DOMParser,
117
+ XMLSerializer: typeof window.XMLSerializer === 'function' ? window.XMLSerializer : CliXmlSerializer,
118
+ Image: window.Image,
119
+ Node: window.Node,
120
+ Text: window.Text,
121
+ Element: window.Element,
122
+ HTMLElement: window.HTMLElement,
123
+ HTMLImageElement: window.HTMLImageElement,
124
+ HTMLTableElement: window.HTMLTableElement,
125
+ HTMLTableCellElement: window.HTMLTableCellElement,
126
+ HTMLLinkElement: window.HTMLLinkElement,
127
+ HTMLScriptElement: window.HTMLScriptElement,
128
+ Document: window.Document,
129
+ DocumentFragment: window.DocumentFragment,
130
+ NodeFilter: window.NodeFilter ?? {
131
+ SHOW_ALL: -1,
132
+ SHOW_ELEMENT: 1,
133
+ SHOW_TEXT: 4,
134
+ },
135
+ };
136
+ for (const [key, value] of Object.entries(globals)) {
137
+ if (!(key in globalThis) || globalThis[key] == null) {
138
+ Object.defineProperty(globalThis, key, {
139
+ configurable: true,
140
+ writable: true,
141
+ value,
142
+ });
143
+ }
144
+ }
145
+ for (const key of Object.getOwnPropertyNames(window)) {
146
+ if (!/^(HTML.*Element|SVG.*Element|Document|DocumentFragment|Node|Text|Element|XML.*|DOMImplementation)$/.test(key)) {
147
+ continue;
148
+ }
149
+ const value = window[key];
150
+ if (value == null) {
151
+ continue;
152
+ }
153
+ if (!(key in globalThis) || globalThis[key] == null) {
154
+ Object.defineProperty(globalThis, key, {
155
+ configurable: true,
156
+ writable: true,
157
+ value,
158
+ });
159
+ }
160
+ }
161
+ for (const key of ['HTMLOListElement', 'HTMLObjectElement']) {
162
+ if (!(key in globalThis) || globalThis[key] == null) {
163
+ Object.defineProperty(globalThis, key, {
164
+ configurable: true,
165
+ writable: true,
166
+ value: window.HTMLElement,
167
+ });
168
+ }
169
+ }
170
+ if (window.document.compatMode !== 'CSS1Compat') {
171
+ Object.defineProperty(window.document, 'compatMode', {
172
+ configurable: true,
173
+ value: 'CSS1Compat',
174
+ });
175
+ }
176
+ installReplaceWithPolyfill(window);
177
+ configured = true;
178
+ }
179
+ function installCliFetch() {
180
+ const nativeFetch = globalThis.fetch.bind(globalThis);
181
+ globalThis.fetch = (async (input, init) => {
182
+ if (typeof input === 'string' && input.startsWith('/')) {
183
+ const relativePath = input.replace(/^\/+/, '');
184
+ const fileUrl = new URL(`../app/public/${relativePath}`, import.meta.url);
185
+ const data = await readFile(fileUrl);
186
+ return new Response(data, { status: 200 });
187
+ }
188
+ if (input instanceof URL && input.protocol === 'file:') {
189
+ const data = await readFile(input);
190
+ return new Response(data, { status: 200 });
191
+ }
192
+ return nativeFetch(input, init);
193
+ });
194
+ }
195
+ function installCliPdfWindowFactory() {
196
+ Object.defineProperty(globalThis, '__execonvertRequire', {
197
+ configurable: true,
198
+ writable: true,
199
+ value: require,
200
+ });
201
+ Object.defineProperty(globalThis, '__execonvertCreatePdfWindow', {
202
+ configurable: true,
203
+ writable: true,
204
+ value: () => {
205
+ if (cliPdfWindow) {
206
+ return cliPdfWindow;
207
+ }
208
+ const originalEmitWarning = process.emitWarning.bind(process);
209
+ process.emitWarning = ((warning, ...args) => {
210
+ const warningCode = typeof args[0] === 'string' && /^DEP\d+$/i.test(args[0])
211
+ ? args[0]
212
+ : typeof args[1] === 'string' && /^DEP\d+$/i.test(args[1])
213
+ ? args[1]
214
+ : undefined;
215
+ const warningMessage = typeof warning === 'string' ? warning : warning.message;
216
+ if (warningCode === 'DEP0040' && warningMessage.includes('`punycode` module is deprecated')) {
217
+ return;
218
+ }
219
+ return originalEmitWarning(warning, ...args);
220
+ });
221
+ try {
222
+ const jsdom = require('jsdom');
223
+ const documentFromJsdom = jsdom.jsdom('<!doctype html><html><body></body></html>');
224
+ cliPdfWindow = documentFromJsdom.defaultView;
225
+ }
226
+ finally {
227
+ process.emitWarning = originalEmitWarning;
228
+ }
229
+ return cliPdfWindow;
230
+ },
231
+ });
232
+ }
233
+ export function installCliRuntime() {
234
+ setupCliDom();
235
+ installCliFetch();
236
+ installCliPdfWindowFactory();
237
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }