@live-codes/browser-compilers 0.4.6 → 0.4.11

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-codes/browser-compilers",
3
- "version": "0.4.6",
3
+ "version": "0.4.11",
4
4
  "description": "Compilers that run in the browser, for use in livecodes.io",
5
5
  "author": "Hatem Hosny",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@ function mkdirp(dir) {
21
21
  }
22
22
  }
23
23
 
24
- var vendor_modules = path.resolve(__dirname + '/../vendor_modules/src');
24
+ var vendor_modules_src = path.resolve(__dirname + '/../vendor_modules/src');
25
25
  var targetDir = path.resolve(__dirname + '/../dist');
26
26
 
27
27
  /** @type {Partial<esbuild.BuildOptions>} */
@@ -75,21 +75,21 @@ esbuild.buildSync({
75
75
  // asciidoctor.css
76
76
  mkdirp(targetDir + '/asciidoctor.css');
77
77
  fs.copyFileSync(
78
- path.resolve(vendor_modules + '/asciidoctor.css/asciidoctor.css'),
78
+ path.resolve(vendor_modules_src + '/asciidoctor.css/asciidoctor.css'),
79
79
  path.resolve(targetDir + '/asciidoctor.css/asciidoctor.css'),
80
80
  );
81
81
 
82
82
  // stylus
83
83
  mkdirp(targetDir + '/stylus');
84
84
  fs.copyFileSync(
85
- path.resolve(vendor_modules + '/stylus/stylus.min.js'),
85
+ path.resolve(vendor_modules_src + '/stylus/stylus.min.js'),
86
86
  path.resolve(targetDir + '/stylus/stylus.min.js'),
87
87
  );
88
88
 
89
89
  // pug
90
90
  mkdirp(targetDir + '/pug');
91
91
  fs.copyFileSync(
92
- path.resolve(vendor_modules + '/pug/pug.min.js'),
92
+ path.resolve(vendor_modules_src + '/pug/pug.min.js'),
93
93
  path.resolve(targetDir + '/pug/pug.min.js'),
94
94
  );
95
95
 
@@ -147,7 +147,7 @@ esbuild.buildSync({
147
147
  // clientside-haml-js
148
148
  mkdirp(targetDir + '/clientside-haml-js');
149
149
  fs.copyFileSync(
150
- path.resolve(vendor_modules + '/clientside-haml-js/haml.js'),
150
+ path.resolve(vendor_modules_src + '/clientside-haml-js/haml.js'),
151
151
  path.resolve(targetDir + '/clientside-haml-js/haml.js'),
152
152
  );
153
153
 
@@ -163,12 +163,12 @@ esbuild.build({
163
163
  // livescript
164
164
  mkdirp(targetDir + '/livescript');
165
165
  fs.copyFileSync(
166
- path.resolve(vendor_modules + '/livescript/livescript-min.js'),
166
+ path.resolve(vendor_modules_src + '/livescript/livescript-min.js'),
167
167
  path.resolve(targetDir + '/livescript/livescript-min.js'),
168
168
  );
169
169
  // prelude.ls (livescript base library)
170
170
  fs.copyFileSync(
171
- path.resolve(vendor_modules + '/livescript/prelude-browser-min.js'),
171
+ path.resolve(vendor_modules_src + '/livescript/prelude-browser-min.js'),
172
172
  path.resolve(targetDir + '/livescript/prelude-browser-min.js'),
173
173
  );
174
174
 
@@ -208,6 +208,33 @@ esbuild.build({
208
208
  // JSCPP
209
209
  mkdirp(targetDir + '/jscpp');
210
210
  fs.copyFileSync(
211
- path.resolve(vendor_modules + '/jscpp/JSCPP.es5.min.js'),
211
+ path.resolve(vendor_modules_src + '/jscpp/JSCPP.es5.min.js'),
212
212
  path.resolve(targetDir + '/jscpp/JSCPP.es5.min.js'),
213
213
  );
214
+
215
+ // wacl
216
+ mkdirp(targetDir + '/wacl');
217
+ mkdirp(targetDir + '/wacl/tcl');
218
+ fs.copyFileSync(
219
+ path.resolve(vendor_modules_src + '/wacl/tcl/wacl.js'),
220
+ path.resolve(targetDir + '/wacl/tcl/wacl.js'),
221
+ );
222
+ fs.copyFileSync(
223
+ path.resolve(vendor_modules_src + '/wacl/tcl/wacl.wasm'),
224
+ path.resolve(targetDir + '/wacl/tcl/wacl.wasm'),
225
+ );
226
+ fs.copyFileSync(
227
+ path.resolve(vendor_modules_src + '/wacl/tcl/wacl-custom.data'),
228
+ path.resolve(targetDir + '/wacl/tcl/wacl-custom.data'),
229
+ );
230
+ fs.copyFileSync(
231
+ path.resolve(vendor_modules_src + '/wacl/tcl/wacl-library.data'),
232
+ path.resolve(targetDir + '/wacl/tcl/wacl-library.data'),
233
+ );
234
+
235
+ // turbopascal
236
+ mkdirp(targetDir + '/turbopascal');
237
+ fs.copyFileSync(
238
+ path.resolve(vendor_modules_src + '/turbopascal/turbopascal.js'),
239
+ path.resolve(targetDir + '/turbopascal/turbopascal.js'),
240
+ );
@@ -46,6 +46,10 @@ Stylus: [MIT License](https://github.com/stylus/stylus/blob/59bc665db295981d4e3f
46
46
 
47
47
  Svelte: [MIT License](https://github.com/sveltejs/svelte/blob/dafbdc286eef3de2243088a9a826e6899e20465c/LICENSE)
48
48
 
49
- wasm-refmt:[MIT License](https://github.com/xtuc/webassemblyjs/blob/45f733aa96476d74c8ac57598e13406a48a6fdc8/LICENSE)
49
+ turbopascal: [BSD 2-Clause License](https://github.com/MikeRalphson/turbopascal/blob/cfcc5ee6d93f32664bb6127aa751c68841ca5c1d/LICENSE)
50
+
51
+ wacl: [BSD 3-Clause License](https://github.com/ecky-l/wacl/blob/9daacabb0102a9986f33263261350edfeebdd83b/LICENSE)
52
+
53
+ wasm-refmt: [MIT License](https://github.com/xtuc/webassemblyjs/blob/45f733aa96476d74c8ac57598e13406a48a6fdc8/LICENSE)
50
54
 
51
55
  Windi CSS: [MIT License](https://github.com/windicss/windicss/blob/bcd50d877e62630f191602ddeabd9f677cc6d90c/LICENSE)
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013, Lawrence Kesteloot
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ - Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ - Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,85 @@
1
+ // @ts-nocheck
2
+ // based on https://github.com/MikeRalphson/turbopascal/blob/master/tpc.js
3
+ const turbopascal = {
4
+ createCompiler: (options = {}) =>
5
+ new Promise((resolve) => {
6
+ const inputCallback =
7
+ options.inputCallback ||
8
+ ((callback) => {
9
+ const input = window.prompt('please supply the input');
10
+ callback(input);
11
+ });
12
+ const outputCallback = options.outputCallback || console.log;
13
+ const errorCallback = options.errorCallback || console.warn;
14
+
15
+ requirejs.config({
16
+ baseUrl: 'https://cdn.jsdelivr.net/npm/turbopascal@1.0.3',
17
+ paths: {
18
+ underscore: 'https://cdn.jsdelivr.net/npm/underscore@1.13.2/underscore-umd.min',
19
+ },
20
+ });
21
+
22
+ require([
23
+ 'Stream',
24
+ 'Lexer',
25
+ 'CommentStripper',
26
+ 'Parser',
27
+ 'Compiler',
28
+ 'Machine',
29
+ 'SymbolTable',
30
+ ], function (Stream, Lexer, CommentStripper, Parser, Compiler, Machine, SymbolTable) {
31
+ function compile(source, run, DEBUG_TRACE) {
32
+ let result = { parsed: false, compiled: false };
33
+ if (!source) return result;
34
+
35
+ let stream = new Stream(source);
36
+ let lexer = new CommentStripper(new Lexer(stream));
37
+ let parser = new Parser(lexer);
38
+
39
+ try {
40
+ // Create the symbol table of built-in constants, functions, and procedures.
41
+ let builtinSymbolTable = SymbolTable.makeBuiltinSymbolTable();
42
+
43
+ // Parse the program into a parse tree. Create the symbol table as we go.
44
+ let root = parser.parse(builtinSymbolTable);
45
+ result.tree = root.print('');
46
+ result.parsed = true;
47
+
48
+ // Compile to bytecode.
49
+ let compiler = new Compiler();
50
+ let bytecode = compiler.compile(root);
51
+ result.compiled = true;
52
+ result.bytecode = bytecode;
53
+ result.pSrc = bytecode.print();
54
+
55
+ if (run) {
56
+ // Execute the bytecode.
57
+ let machine = new Machine(bytecode, this.keyboard);
58
+ if (DEBUG_TRACE) {
59
+ machine.setDebugCallback(function (state) {
60
+ $state.append(state + '\\n');
61
+ });
62
+ }
63
+ machine.setFinishCallback(function (runningTime) {});
64
+ machine.setOutputCallback(function (line) {
65
+ outputCallback(line);
66
+ });
67
+ machine.setOutChCallback(function (line) {
68
+ outputCallback(line);
69
+ });
70
+ machine.setInputCallback(function (callback) {
71
+ inputCallback(callback);
72
+ });
73
+ machine.run();
74
+ }
75
+ } catch (e) {
76
+ // Print errors.
77
+ const msg = e.getMessage() || e.message || e;
78
+ errorCallback(msg);
79
+ }
80
+ return result;
81
+ }
82
+ resolve(compile);
83
+ });
84
+ }),
85
+ };
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2017, ecky-l
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ from https://github.com/ecky-l/ecky-l.github.io/tree/master/wacl/releases
2
+ https://ecky-l.github.io/wacl/releases/wacl.zip
@@ -0,0 +1,22 @@
1
+
2
+ Directory for custom Tcl code
3
+ =============================
4
+
5
+ This directory is turned into a .data file during the build process and loaded
6
+ at startup together with (in parallel to) the wacl-library.data file. Both
7
+ of these data files are mounted to /usr/lib on startup and are put on the
8
+ $auto_path of Wacl.
9
+
10
+ You can put your own packages and tcl code here in this directory. It will be
11
+ available in Wacl on the auto_path, i.e. if the directories here contain
12
+ a pkgIndex.tcl file with the usual signature (see the Tcl documentation for
13
+ the pkg_mkIndex command), you can load them with [package require ...] inside
14
+ Wacl.
15
+
16
+ It is not necessary to completely build Wacl when your Tcl packages change.
17
+ In order to update the contents of wacl-custom.data, you just need to put
18
+ your updated Tcl packages here and then run
19
+
20
+ python $(EMSCRIPTEN)/tools/file_packager.py wacl-custom.data --preload custom@/usr/lib/ >
21
+
22
+ (you need python and the emscripten SDK on your PATH, though).