@skillstech/thunderlang 1.2.0 → 1.3.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.
- package/CHANGELOG.md +131 -0
- package/dist/core.cjs +2080 -278
- package/dist/index.cjs +12742 -10943
- package/dist/learn.cjs +2716 -345
- package/package.json +1 -1
- package/src/cli.mjs +31 -6
- package/src/core/ThunderRuntime.cs +1367 -0
- package/src/core/check.mjs +158 -2
- package/src/core/cli.mjs +148 -8
- package/src/core/csharp-run.mjs +184 -0
- package/src/core/diagnostics.mjs +13 -1
- package/src/core/engine-core.mjs +285 -2
- package/src/core/engine-values.mjs +1 -1
- package/src/core/format.mjs +191 -3
- package/src/core/go-run.mjs +106 -0
- package/src/core/index.mjs +2 -1
- package/src/core/java/thunder/T.java +6 -0
- package/src/core/java/thunder/ThunderRuntime.java +1374 -0
- package/src/core/java-run.mjs +89 -0
- package/src/core/parser.mjs +331 -5
- package/src/core/project.mjs +31 -6
- package/src/core/react-run.mjs +96 -0
- package/src/core/runtime-go/thunder_runtime.go +3038 -0
- package/src/core/runtime-react.mjs +133 -0
- package/src/core/rust/thunder_runtime.rs +1645 -0
- package/src/core/rust-run.mjs +192 -0
- package/src/core/screen-values.mjs +30 -0
- package/src/core/target-csharp.mjs +484 -0
- package/src/core/target-go.mjs +555 -0
- package/src/core/target-java.mjs +587 -0
- package/src/core/target-react.mjs +270 -0
- package/src/core/target-rust.mjs +534 -0
- package/src/core/target-typescript.mjs +2 -2
- package/src/core.d.ts +18 -0
- package/src/core.mjs +1 -0
- package/src/emit.mjs +1 -1
- package/src/faithful.mjs +30 -0
- package/src/libraries.mjs +10 -3
- package/src/model.mjs +50 -8
- package/src/read-level.mjs +48 -2
- package/src/read-repo-fs.mjs +3 -1
- package/src/read.mjs +28 -5
- package/src/replay-cli.mjs +123 -0
- package/src/say-less.mjs +152 -11
- package/src/screens.mjs +833 -0
- package/src/steps.mjs +430 -19
- package/src/term.mjs +43 -0
package/src/term.mjs
CHANGED
|
@@ -87,3 +87,46 @@ export function paintHelp(text, on = useColor()) {
|
|
|
87
87
|
return line;
|
|
88
88
|
}).join('\n');
|
|
89
89
|
}
|
|
90
|
+
|
|
91
|
+
// ── Thunder Core in the terminal: the same roles as the editor and the site ─────────────────────────────────────
|
|
92
|
+
const CORE_LEADS = new Set(['Set', 'say', 'Say', 'print', 'Keep', 'Increase', 'Decrease', 'Add', 'Remove', 'Sort', 'Reverse', 'When', 'If', 'Otherwise', 'For', 'Repeat', 'Stop', 'Give', 'Receive', 'Test', 'Expect', 'Use', 'Never', 'To', 'A', 'An']);
|
|
93
|
+
const CORE_JOIN = new Set(['to', 'with', 'by', 'from', 'as', 'at', 'least', 'most', 'more', 'less', 'than', 'each', 'while', 'until', 'times', 'of', 'where', 'sorted', 'descending', 'be', 'fail', 'fails', 'is', 'and', 'or', 'not', 'has', 'allow', 'back', 'in', 'when', 'if', 'this']);
|
|
94
|
+
const CORE_VALUES = new Set(['yes', 'no', 'nothing', 'true', 'false']);
|
|
95
|
+
const CORE_KINDS = new Set(['text', 'money', 'number', 'whole', 'date', 'optional', 'list', 'map']);
|
|
96
|
+
const TOKENS = /("(?:[^"\\]|\\.)*"?)|((?<=\s)#.*$)|(-?\$\d[\d,]*(?:\.\d+)?|\d+(?:\.\d+)?%?)|([A-Za-z_][A-Za-z0-9_]*)|(\s+)|(.)/g;
|
|
97
|
+
const ansi = (code, s, on) => (on ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
98
|
+
|
|
99
|
+
/** Color one line of Thunder Core: statement words, joining words, values, text (with its {holes}), names, comments. */
|
|
100
|
+
export function paintThunderLine(line, on = useColor()) {
|
|
101
|
+
if (!on) return line;
|
|
102
|
+
if (/^\s*#/.test(line)) return ansi('2', line, on);
|
|
103
|
+
const fnDef = /^\s*To [a-z]/.test(line);
|
|
104
|
+
const recDef = /^\s*An? [A-Z]\w*(?: [A-Z]\w*)* has:/.test(line);
|
|
105
|
+
const fieldLine = /^\s*[a-z][a-z0-9_]*(?: [a-z][a-z0-9_]*)*:\s+\S/.test(line);
|
|
106
|
+
const kindLine = /^\s+[A-Z][\w ]* is (?:an? )?(?:optional )?(?:text|money|number|whole number|date|yes\/no|list|map)\b/.test(line);
|
|
107
|
+
let out = '', leading = true, inName = false, beforeColon = fieldLine, first = true;
|
|
108
|
+
for (const m of line.matchAll(TOKENS)) {
|
|
109
|
+
const [t, str, comment, num, word, space] = m;
|
|
110
|
+
if (space) { out += t; continue; }
|
|
111
|
+
if (str) { out += ansi('32', t.replace(/\{[^{}"]+\}/g, (h) => `\x1b[1;33m${h}\x1b[0;32m`), on); leading = false; continue; }
|
|
112
|
+
if (comment) { out += ansi('2', t, on); continue; }
|
|
113
|
+
if (num) { out += ansi('33', t, on); leading = false; continue; }
|
|
114
|
+
if (!word) { if (t === ':') { beforeColon = false; inName = false; } out += t; leading = false; continue; }
|
|
115
|
+
let code = null;
|
|
116
|
+
if (beforeColon) code = '36';
|
|
117
|
+
else if (kindLine && first) code = '36';
|
|
118
|
+
else if (kindLine && (CORE_KINDS.has(t) || CORE_VALUES.has(t))) code = '36;1';
|
|
119
|
+
else if (leading && CORE_LEADS.has(t)) { code = '1;35'; inName = fnDef && t === 'To'; }
|
|
120
|
+
else if (inName) code = '34';
|
|
121
|
+
else if (CORE_VALUES.has(t)) code = '33';
|
|
122
|
+
else if (t === 'each' && /^\s*For each/.test(line)) code = '1;35';
|
|
123
|
+
else if (CORE_JOIN.has(t)) code = '35';
|
|
124
|
+
else if (/^[A-Z]/.test(t) && (recDef || !first)) code = '36';
|
|
125
|
+
out += code ? ansi(code, t, on) : t;
|
|
126
|
+
leading = false; first = false;
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Color a whole Thunder Core program (plain when color is off). */
|
|
132
|
+
export const paintThunder = (text, on = useColor()) => (on ? String(text).split('\n').map((l) => paintThunderLine(l, on)).join('\n') : text);
|