@ianlangs/mathscript 1.6.0 → 1.6.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.
package/mpm/mpm.js CHANGED
@@ -4,6 +4,16 @@ import path from "path"
4
4
  import https from "https"
5
5
  import { execSync } from "child_process"
6
6
 
7
+ if (process.argv[2] === "-v" || process.argv[2] === "--version") {
8
+ await (async () => {
9
+ const url = "https://unpkg.com/@ianlangs/mathscript/package.json"
10
+ const res = await fetch(url)
11
+ const pkg = await res.json()
12
+ console.log(`MS versión = ${pkg.version}`)
13
+ process.exit(0)
14
+ })()
15
+ }
16
+
7
17
  const args = process.argv.slice(2)
8
18
  const CWD = process.cwd()
9
19
  const MODULES_DIR = path.join(CWD, "ms_modules")
package/mpm/mpm.ms CHANGED
@@ -4,6 +4,16 @@ import path from "path"
4
4
  import https from "https"
5
5
  import { execSync } from "child_process"
6
6
 
7
+ if (process.argv[2] === "-v" || process.argv[2] === "--version") {
8
+ await (async () => {
9
+ const url = "https://unpkg.com/@ianlangs/mathscript/package.json"
10
+ const res = await fetch(url)
11
+ const pkg = await res.json()
12
+ console.log(`MS versión = ${pkg.version}`)
13
+ process.exit(0)
14
+ })()
15
+ }
16
+
7
17
  const args = process.argv.slice(2)
8
18
  const CWD = process.cwd()
9
19
  const MODULES_DIR = path.join(CWD, "ms_modules")
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@ianlangs/mathscript",
4
- "version": "1.6.0",
4
+ "version": "1.6.3",
5
5
  "description": "superset de js",
6
6
  "main": "src/transpile.js",
7
7
  "scripts": {
package/src/msc.js CHANGED
@@ -2,6 +2,16 @@
2
2
  import fs from 'fs'
3
3
  import { transpile } from './transpile.js'
4
4
 
5
+ if (process.argv[2] === "-v" || process.argv[2] === "--version") {
6
+ await (async () => {
7
+ const url = "https://unpkg.com/@ianlangs/mathscript/package.json"
8
+ const res = await fetch(url)
9
+ const pkg = await res.json()
10
+ console.log(`MS versión = ${pkg.version}`)
11
+ process.exit(0)
12
+ })()
13
+ }
14
+
5
15
  function init(files) {
6
16
  const config = { Files: files }
7
17
  fs.writeFileSync('msconfig.json', JSON.stringify(config, null, 4))
package/src/msnode.js CHANGED
@@ -2,6 +2,17 @@
2
2
  import fs from 'fs'
3
3
  import { transpile } from './transpile.js'
4
4
 
5
+ if (process.argv[2] === "-v" || process.argv[2] === "--version") {
6
+ await (async () => {
7
+ const url = "https://unpkg.com/@ianlangs/mathscript/package.json"
8
+ const res = await fetch(url)
9
+ const pkg = await res.json()
10
+ console.log(`MS versión = ${pkg.version}`)
11
+ process.exit(0)
12
+ })()
13
+ }
14
+
15
+
5
16
  const file = process.argv[2]
6
17
 
7
18
  if (!file) {
package/src/web-t.js CHANGED
@@ -0,0 +1,43 @@
1
+ import { transpile } from "./web-t.js"
2
+
3
+ const editor = document.getElementById("editor")
4
+ const runButton = document.getElementById("runButton")
5
+ const consoleDiv = document.getElementById("console")
6
+
7
+ function clearConsole() {
8
+ consoleDiv.innerHTML = ""
9
+ }
10
+
11
+ function logToConsole(msg) {
12
+ const line = document.createElement("div")
13
+ line.textContent = msg
14
+ consoleDiv.appendChild(line)
15
+ }
16
+
17
+ runButton.addEventListener("click", () => {
18
+ clearConsole()
19
+
20
+ const code = editor.value
21
+
22
+ const result = transpile(code, "playground.ms")
23
+
24
+ if (result.errors.length > 0) {
25
+ result.errors.forEach(err => logToConsole(err))
26
+ return
27
+ }
28
+
29
+ // Capturar console.log
30
+ const originalLog = console.log
31
+ console.log = (...args) => {
32
+ logToConsole(args.join(" "))
33
+ originalLog(...args)
34
+ }
35
+
36
+ try {
37
+ eval(result.code)
38
+ } catch (e) {
39
+ logToConsole("[RUNTIME ERROR] " + e.message)
40
+ }
41
+
42
+ console.log = originalLog
43
+ })