tjs-lang 0.2.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 (91) hide show
  1. package/CONTEXT.md +594 -0
  2. package/LICENSE +190 -0
  3. package/README.md +220 -0
  4. package/bin/benchmarks.ts +351 -0
  5. package/bin/dev.ts +205 -0
  6. package/bin/docs.js +170 -0
  7. package/bin/install-cursor.sh +71 -0
  8. package/bin/install-vscode.sh +71 -0
  9. package/bin/select-local-models.d.ts +1 -0
  10. package/bin/select-local-models.js +28 -0
  11. package/bin/select-local-models.ts +31 -0
  12. package/demo/autocomplete.test.ts +232 -0
  13. package/demo/docs.json +186 -0
  14. package/demo/examples.test.ts +598 -0
  15. package/demo/index.html +91 -0
  16. package/demo/src/autocomplete.ts +482 -0
  17. package/demo/src/capabilities.ts +859 -0
  18. package/demo/src/demo-nav.ts +2097 -0
  19. package/demo/src/examples.test.ts +161 -0
  20. package/demo/src/examples.ts +476 -0
  21. package/demo/src/imports.test.ts +196 -0
  22. package/demo/src/imports.ts +421 -0
  23. package/demo/src/index.ts +639 -0
  24. package/demo/src/module-store.ts +635 -0
  25. package/demo/src/module-sw.ts +132 -0
  26. package/demo/src/playground.ts +949 -0
  27. package/demo/src/service-host.ts +389 -0
  28. package/demo/src/settings.ts +440 -0
  29. package/demo/src/style.ts +280 -0
  30. package/demo/src/tjs-playground.ts +1605 -0
  31. package/demo/src/ts-examples.ts +478 -0
  32. package/demo/src/ts-playground.ts +1092 -0
  33. package/demo/static/favicon.svg +30 -0
  34. package/demo/static/photo-1.jpg +0 -0
  35. package/demo/static/photo-2.jpg +0 -0
  36. package/demo/static/texts/ai-history.txt +9 -0
  37. package/demo/static/texts/coffee-origins.txt +9 -0
  38. package/demo/static/texts/renewable-energy.txt +9 -0
  39. package/dist/index.js +256 -0
  40. package/dist/index.js.map +37 -0
  41. package/dist/tjs-batteries.js +4 -0
  42. package/dist/tjs-batteries.js.map +15 -0
  43. package/dist/tjs-full.js +256 -0
  44. package/dist/tjs-full.js.map +37 -0
  45. package/dist/tjs-transpiler.js +220 -0
  46. package/dist/tjs-transpiler.js.map +21 -0
  47. package/dist/tjs-vm.js +4 -0
  48. package/dist/tjs-vm.js.map +14 -0
  49. package/docs/CNAME +1 -0
  50. package/docs/favicon.svg +30 -0
  51. package/docs/index.html +91 -0
  52. package/docs/index.js +10468 -0
  53. package/docs/index.js.map +92 -0
  54. package/docs/photo-1.jpg +0 -0
  55. package/docs/photo-1.webp +0 -0
  56. package/docs/photo-2.jpg +0 -0
  57. package/docs/photo-2.webp +0 -0
  58. package/docs/texts/ai-history.txt +9 -0
  59. package/docs/texts/coffee-origins.txt +9 -0
  60. package/docs/texts/renewable-energy.txt +9 -0
  61. package/docs/tjs-lang.svg +31 -0
  62. package/docs/tosijs-agent.svg +31 -0
  63. package/editors/README.md +325 -0
  64. package/editors/ace/ajs-mode.js +328 -0
  65. package/editors/ace/ajs-mode.ts +269 -0
  66. package/editors/ajs-syntax.ts +212 -0
  67. package/editors/build-grammars.ts +510 -0
  68. package/editors/codemirror/ajs-language.js +287 -0
  69. package/editors/codemirror/ajs-language.ts +1447 -0
  70. package/editors/codemirror/autocomplete.test.ts +531 -0
  71. package/editors/codemirror/component.ts +404 -0
  72. package/editors/monaco/ajs-monarch.js +243 -0
  73. package/editors/monaco/ajs-monarch.ts +225 -0
  74. package/editors/tjs-syntax.ts +115 -0
  75. package/editors/vscode/language-configuration.json +37 -0
  76. package/editors/vscode/package.json +65 -0
  77. package/editors/vscode/syntaxes/ajs-injection.tmLanguage.json +107 -0
  78. package/editors/vscode/syntaxes/ajs.tmLanguage.json +252 -0
  79. package/editors/vscode/syntaxes/tjs.tmLanguage.json +333 -0
  80. package/package.json +83 -0
  81. package/src/cli/commands/check.ts +41 -0
  82. package/src/cli/commands/convert.ts +133 -0
  83. package/src/cli/commands/emit.ts +260 -0
  84. package/src/cli/commands/run.ts +68 -0
  85. package/src/cli/commands/test.ts +194 -0
  86. package/src/cli/commands/types.ts +20 -0
  87. package/src/cli/create-app.ts +236 -0
  88. package/src/cli/playground.ts +250 -0
  89. package/src/cli/tjs.ts +166 -0
  90. package/src/cli/tjsx.ts +160 -0
  91. package/tjs-lang.svg +31 -0
@@ -0,0 +1,212 @@
1
+ /**
2
+ * AsyncJS Syntax Definitions
3
+ *
4
+ * Single source of truth for AsyncJS language syntax elements.
5
+ * Used by all editor integrations (Monaco, CodeMirror, Ace, VSCode).
6
+ */
7
+
8
+ /**
9
+ * Keywords supported in AsyncJS
10
+ */
11
+ export const KEYWORDS = [
12
+ 'function',
13
+ 'return',
14
+ 'if',
15
+ 'else',
16
+ 'while',
17
+ 'for',
18
+ 'of',
19
+ 'in',
20
+ 'try',
21
+ 'catch',
22
+ 'finally',
23
+ 'let',
24
+ 'const',
25
+ 'true',
26
+ 'false',
27
+ 'null',
28
+ 'undefined',
29
+ ] as const
30
+
31
+ /**
32
+ * Keywords/constructs that are NOT supported in AsyncJS.
33
+ * These should be highlighted as errors in editors.
34
+ */
35
+ export const FORBIDDEN_KEYWORDS = [
36
+ // Object-oriented constructs
37
+ 'new',
38
+ 'class',
39
+ 'extends',
40
+ 'super',
41
+ 'this',
42
+ 'implements',
43
+ 'interface',
44
+ 'abstract',
45
+ 'static',
46
+ 'private',
47
+ 'protected',
48
+ 'public',
49
+
50
+ // Async constructs (not needed - runtime handles async)
51
+ 'async',
52
+ 'await',
53
+ 'yield',
54
+
55
+ // Module system (not supported)
56
+ 'import',
57
+ 'export',
58
+ 'require',
59
+ 'module',
60
+
61
+ // Other unsupported
62
+ 'var', // use let/const
63
+ 'throw', // use Error() for monadic error flow
64
+ 'switch', // use if/else chains
65
+ 'case',
66
+ 'default', // (as switch keyword)
67
+ 'with',
68
+ 'delete',
69
+ 'void',
70
+ 'typeof', // use type-by-example instead
71
+ 'instanceof',
72
+ 'debugger',
73
+ 'eval',
74
+
75
+ // TypeScript-specific (not supported)
76
+ 'type',
77
+ 'enum',
78
+ 'namespace',
79
+ 'declare',
80
+ 'readonly',
81
+ 'as',
82
+ 'is',
83
+ 'keyof',
84
+ 'infer',
85
+ 'never',
86
+ 'unknown',
87
+ ] as const
88
+
89
+ /**
90
+ * Built-in type constructors that can be used as factories
91
+ * (without 'new' keyword)
92
+ */
93
+ export const TYPE_CONSTRUCTORS = [
94
+ 'Date',
95
+ 'Set',
96
+ 'Map',
97
+ 'Array',
98
+ 'Object',
99
+ 'String',
100
+ 'Number',
101
+ 'Boolean',
102
+ 'RegExp',
103
+ 'Error',
104
+ 'JSON',
105
+ 'Math',
106
+ 'Schema', // AsyncJS-specific
107
+ ] as const
108
+
109
+ /**
110
+ * Built-in atoms available in AsyncJS
111
+ */
112
+ export const BUILTIN_ATOMS = [
113
+ // IO
114
+ 'httpFetch',
115
+ 'llmPredict',
116
+
117
+ // Store
118
+ 'storeGet',
119
+ 'storeSet',
120
+ 'storeQuery',
121
+ 'storeVectorSearch',
122
+
123
+ // Console (logging/warnings/errors)
124
+ 'console', // .log, .warn, .error
125
+ ] as const
126
+
127
+ /**
128
+ * Operators supported in AsyncJS
129
+ */
130
+ export const OPERATORS = [
131
+ // Assignment
132
+ '=',
133
+ '+=',
134
+ '-=',
135
+ '*=',
136
+ '/=',
137
+ '%=',
138
+
139
+ // Comparison
140
+ '==',
141
+ '===',
142
+ '!=',
143
+ '!==',
144
+ '<',
145
+ '>',
146
+ '<=',
147
+ '>=',
148
+
149
+ // Arithmetic
150
+ '+',
151
+ '-',
152
+ '*',
153
+ '/',
154
+ '%',
155
+ '**',
156
+
157
+ // Logical
158
+ '&&',
159
+ '||',
160
+ '??',
161
+ '!',
162
+
163
+ // Bitwise (limited support)
164
+ '&',
165
+ '|',
166
+ '^',
167
+ '~',
168
+ '<<',
169
+ '>>',
170
+ '>>>',
171
+
172
+ // Other
173
+ '?',
174
+ ':',
175
+ '.',
176
+ '?.',
177
+ '?.(',
178
+ '?.[',
179
+ '...',
180
+ ] as const
181
+
182
+ /**
183
+ * Get all forbidden keywords as a Set for efficient lookup
184
+ */
185
+ export const FORBIDDEN_SET = new Set(FORBIDDEN_KEYWORDS)
186
+
187
+ /**
188
+ * Get all keywords as a Set for efficient lookup
189
+ */
190
+ export const KEYWORDS_SET = new Set(KEYWORDS)
191
+
192
+ /**
193
+ * Regex pattern matching any forbidden keyword (word boundary)
194
+ */
195
+ export const FORBIDDEN_PATTERN = new RegExp(
196
+ `\\b(${FORBIDDEN_KEYWORDS.join('|')})\\b`,
197
+ 'g'
198
+ )
199
+
200
+ /**
201
+ * Check if a word is a forbidden keyword
202
+ */
203
+ export function isForbidden(word: string): boolean {
204
+ return FORBIDDEN_SET.has(word as (typeof FORBIDDEN_KEYWORDS)[number])
205
+ }
206
+
207
+ /**
208
+ * Check if a word is a valid keyword
209
+ */
210
+ export function isKeyword(word: string): boolean {
211
+ return KEYWORDS_SET.has(word as (typeof KEYWORDS)[number])
212
+ }