plainscript-lang 1.0.361 → 1.0.362
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/README.md +4 -4
- package/compiler/cli.js +3 -3
- package/compiler/generator.js +54 -24
- package/compiler/parser.js +7 -7
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +2 -2
- package/docs/GAME-PROMPT.md +3 -3
- package/docs/PLAINSCRIPT-SPEC.md +1 -1
- package/docs/index.html +5 -5
- package/examples/ai-providers.pln +1 -1
- package/examples/arrays.pln +1 -1
- package/examples/async-errors.pln +1 -1
- package/examples/auth-api.pln +1 -1
- package/examples/auth-sessions.pln +1 -1
- package/examples/basics.pln +1 -1
- package/examples/bots.pln +1 -1
- package/examples/browser-interactive/README.md +1 -1
- package/examples/browser-interactive/src/interactive.pln +1 -1
- package/examples/cache-and-jobs.pln +1 -1
- package/examples/cache-schedule.pln +1 -1
- package/examples/canvas-game/README.md +1 -1
- package/examples/canvas-game/src/game.pln +1 -1
- package/examples/collections.pln +1 -1
- package/examples/concurrency.pln +1 -1
- package/examples/conditions.pln +1 -1
- package/examples/database.pln +1 -1
- package/examples/day2.pln +1 -1
- package/examples/day3.pln +1 -1
- package/examples/deployment.pln +1 -1
- package/examples/email-send.pln +1 -1
- package/examples/error-handling.pln +1 -1
- package/examples/expressions.pln +1 -1
- package/examples/file-uploads.pln +1 -1
- package/examples/files-and-config.pln +1 -1
- package/examples/files.pln +1 -1
- package/examples/football-backend/app.pln +1 -1
- package/examples/functions.pln +1 -1
- package/examples/hello.pln +1 -1
- package/examples/http-client.pln +1 -1
- package/examples/http.pln +1 -1
- package/examples/id-verification/app.pln +1 -1
- package/examples/javascript-library/README.md +1 -1
- package/examples/javascript-library/src/interop.pln +1 -1
- package/examples/json.pln +1 -1
- package/examples/loops.pln +1 -1
- package/examples/modules/app.pln +1 -1
- package/examples/modules/main.pln +1 -1
- package/examples/modules/math.pln +1 -1
- package/examples/mongo.pln +1 -1
- package/examples/objects.pln +1 -1
- package/examples/ocr.pln +1 -1
- package/examples/packages.pln +1 -1
- package/examples/record-kinds.pln +1 -1
- package/examples/records.pln +1 -1
- package/examples/rest-api-fetch.pln +1 -1
- package/examples/rest-api.pln +1 -1
- package/examples/scheduled-tasks.pln +1 -1
- package/examples/search-and-filter.pln +1 -1
- package/examples/server.pln +1 -1
- package/examples/sessions-and-cookies.pln +1 -1
- package/examples/sqlite.pln +1 -1
- package/examples/start.pln +1 -1
- package/examples/stdlib.pln +1 -1
- package/examples/string-verbs.pln +1 -1
- package/examples/telegram-ai-bot.pln +1 -1
- package/examples/telegram-bot.pln +1 -1
- package/examples/testing.pln +1 -1
- package/examples/three-dimensional/README.md +1 -1
- package/examples/three-dimensional/src/scene.pln +1 -1
- package/examples/web-api.pln +1 -1
- package/examples/web-app.pln +1 -1
- package/examples/websocket-server.pln +1 -1
- package/examples/websocket.pln +1 -1
- package/examples/whatsapp-bot/pairing.pln +1 -1
- package/examples/whatsapp-bot/qr.pln +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ done
|
|
|
122
122
|
</tr>
|
|
123
123
|
</table>
|
|
124
124
|
|
|
125
|
-
**Current version:** `v1.0.
|
|
125
|
+
**Current version:** `v1.0.362` - the `plainscript-lang` npm package, with a TypeScript-style production build (`plainscript build` → `dist/`, source names and structure preserved).
|
|
126
126
|
|
|
127
127
|
---
|
|
128
128
|
|
|
@@ -237,7 +237,7 @@ For projects that need custom output or source directories, add a `plainscript.c
|
|
|
237
237
|
"build": "plainscript build",
|
|
238
238
|
"prepare": "plainscript build"
|
|
239
239
|
},
|
|
240
|
-
"devDependencies": { "plainscript-lang": "^1.0.
|
|
240
|
+
"devDependencies": { "plainscript-lang": "^1.0.362" }
|
|
241
241
|
}
|
|
242
242
|
```
|
|
243
243
|
|
|
@@ -628,7 +628,7 @@ Portable databases (SQLite native or WebAssembly):
|
|
|
628
628
|
database "app.db" // probes better-sqlite3, falls back to sql.js
|
|
629
629
|
```
|
|
630
630
|
|
|
631
|
-
`plainscript install` verifies that `better-sqlite3` actually loads. If the native module cannot be used, PlainScript warns and continues on the pure-JavaScript WebAssembly engine (`sql.js`) - the same program runs unchanged. An engine can be forced explicitly:
|
|
631
|
+
`plainscript install` verifies that `better-sqlite3` actually loads. Since 1.0.362 the native engine ships as an **optional dependency**: installing `plainscript-lang` can never fail because a native binary is missing for the platform (e.g. Android/Termux), and programs that never open a database start without it. If the native module cannot be used, PlainScript warns and continues on the pure-JavaScript WebAssembly engine (`sql.js`) - the same program runs unchanged. An engine can be forced explicitly:
|
|
632
632
|
|
|
633
633
|
```
|
|
634
634
|
database "app.db" using "native" // hard requirement: better-sqlite3
|
|
@@ -1097,7 +1097,7 @@ See [`examples/whatsapp-bot/`](./examples/whatsapp-bot/) for ready-to-link progr
|
|
|
1097
1097
|
| PlainScript | Compiles to |
|
|
1098
1098
|
|---|---|
|
|
1099
1099
|
| `use express` | `const express = require('express');` |
|
|
1100
|
-
| `use sqlite` | `
|
|
1100
|
+
| `use sqlite` | `let Database; … require('better-sqlite3')` (lazily loaded - the native engine is an optional backend) |
|
|
1101
1101
|
| `use fs` | `const fs = require('fs');` |
|
|
1102
1102
|
| `use path` | `const path = require('path');` |
|
|
1103
1103
|
|
package/compiler/cli.js
CHANGED
|
@@ -506,7 +506,7 @@ function buildOne(filePath, srcDir, outDir, options = {}) {
|
|
|
506
506
|
|
|
507
507
|
// `plainscript build <file.pln> -o <out.js>` - compile one entry to an explicit
|
|
508
508
|
// output path (same compilation pipeline as buildOne, including source maps
|
|
509
|
-
// when requested). Valuable for browser payloads such as the v1.0.
|
|
509
|
+
// when requested). Valuable for browser payloads such as the v1.0.362
|
|
510
510
|
// requestAnimationFrame / addEventListener helpers, which are meant to run as
|
|
511
511
|
// a single script tag.
|
|
512
512
|
function writeOneFile(filePath, outputFile) {
|
|
@@ -631,7 +631,7 @@ done
|
|
|
631
631
|
route get "/api/status"
|
|
632
632
|
reply json
|
|
633
633
|
status is "ok"
|
|
634
|
-
version is "1.0.
|
|
634
|
+
version is "1.0.362"
|
|
635
635
|
done
|
|
636
636
|
done
|
|
637
637
|
|
|
@@ -1014,7 +1014,7 @@ async function main() {
|
|
|
1014
1014
|
switch (command) {
|
|
1015
1015
|
case 'run': await cmdRun(fileArg, positional.slice(2)); break;
|
|
1016
1016
|
case 'build': {
|
|
1017
|
-
// v1.0.
|
|
1017
|
+
// v1.0.362 - optional -o/--output <path>. "-o" is a single-dash flag, so
|
|
1018
1018
|
// it survives the "--filtered" positional list; pull it out here before
|
|
1019
1019
|
// building the positional file argument for cmdBuild.
|
|
1020
1020
|
let outputPath = null;
|
package/compiler/generator.js
CHANGED
|
@@ -6,7 +6,15 @@ const { SourceMapGenerator } = require('./sourcemap');
|
|
|
6
6
|
// Known runtime packages and their require() statements.
|
|
7
7
|
const KNOWN_PACKAGES = {
|
|
8
8
|
express: `const express = require('express');`,
|
|
9
|
-
|
|
9
|
+
// v1.0.362 - better-sqlite3 is an OPTIONAL runtime backend. The require
|
|
10
|
+
// must not run at module load: on platforms without a usable native
|
|
11
|
+
// binary (e.g. Android/Termux) `plainscript` must still compile and run
|
|
12
|
+
// programs that never touch SQLite. `Database` is resolved lazily and only
|
|
13
|
+
// errors with a teaching message when a program actually constructs a
|
|
14
|
+
// native database.
|
|
15
|
+
sqlite: `let Database;
|
|
16
|
+
try { Database = require('better-sqlite3'); }
|
|
17
|
+
catch (__e) { Database = function () { throw new Error('PlainScript: the native SQLite engine (better-sqlite3) is not usable on this machine (' + (__e && __e.message ? __e.message : __e) + ').\\nInstall it with: npm install better-sqlite3\\nOr use the portable engine instead: database "' + (arguments[0] || ':memory:') + '" using "wasm"'); }; }`,
|
|
10
18
|
fs: `const fs = require('fs');`,
|
|
11
19
|
path: `const path = require('path');`,
|
|
12
20
|
axios: `const axios = require('axios');`,
|
|
@@ -88,7 +96,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
88
96
|
` }`,
|
|
89
97
|
`}`,
|
|
90
98
|
].join('\n'),
|
|
91
|
-
// v1.0.
|
|
99
|
+
// v1.0.362 - DOM browser runtime (select/selectAll/parseHTML). Browser
|
|
92
100
|
// globals are guarded so the generated JS explains the problem when it is
|
|
93
101
|
// run under Node instead of failing with a ReferenceError midpoint.
|
|
94
102
|
dom: [
|
|
@@ -107,7 +115,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
107
115
|
` return template.content;`,
|
|
108
116
|
`}`,
|
|
109
117
|
].join('\n'),
|
|
110
|
-
// v1.0.
|
|
118
|
+
// v1.0.362 - input runtime: pointer coordinates, gamepads, dropped files.
|
|
111
119
|
input: [
|
|
112
120
|
`function __localPoint(e, canvas) {`,
|
|
113
121
|
` if (typeof document === 'undefined') throw new Error('localPoint(...) needs a browser (document is not defined in Node).');`,
|
|
@@ -125,7 +133,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
125
133
|
` return [...(event && event.dataTransfer ? event.dataTransfer.files : [])];`,
|
|
126
134
|
`}`,
|
|
127
135
|
].join('\n'),
|
|
128
|
-
// v1.0.
|
|
136
|
+
// v1.0.362 - asset-loading runtime (images, JSON, bytes, data URLs). All
|
|
129
137
|
// helpers return promises; the STDLIB entries await them.
|
|
130
138
|
assets: [
|
|
131
139
|
`function __loadImage(url) {`,
|
|
@@ -162,7 +170,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
162
170
|
` });`,
|
|
163
171
|
`}`,
|
|
164
172
|
].join('\n'),
|
|
165
|
-
// v1.0.
|
|
173
|
+
// v1.0.362 - Web Audio runtime. The AudioContext is created once and shared
|
|
166
174
|
// (browsers cap the number), and resumed on demand because autoplay policies
|
|
167
175
|
// start it suspended.
|
|
168
176
|
audio: [
|
|
@@ -205,7 +213,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
205
213
|
` });`,
|
|
206
214
|
`}`,
|
|
207
215
|
].join('\n'),
|
|
208
|
-
// v1.0.
|
|
216
|
+
// v1.0.362 - WebGL runtime: context selection plus the three compile/link/
|
|
209
217
|
// buffer helpers behind the gl* stdlib entries.
|
|
210
218
|
gl: [
|
|
211
219
|
`function __glContext(canvas) {`,
|
|
@@ -1345,7 +1353,12 @@ const BUILTIN_DECLARATIONS = {
|
|
|
1345
1353
|
` }`,
|
|
1346
1354
|
` console.error('PlainScript: native SQLite unavailable (' + __sqliteNativeReason + '); using the WebAssembly engine instead.');`,
|
|
1347
1355
|
` }`,
|
|
1348
|
-
`
|
|
1356
|
+
` let initSqlJs;`,
|
|
1357
|
+
` try {`,
|
|
1358
|
+
` initSqlJs = require('sql.js');`,
|
|
1359
|
+
` } catch (__e) {`,
|
|
1360
|
+
` throw new Error('Database: SQLite is not available on this machine. The native engine (better-sqlite3) could not be loaded and the WebAssembly engine (sql.js) is not installed.\\nInstall them with: npm install better-sqlite3 sql.js');`,
|
|
1361
|
+
` }`,
|
|
1349
1362
|
` const SQL = await initSqlJs();`,
|
|
1350
1363
|
` let raw;`,
|
|
1351
1364
|
` try {`,
|
|
@@ -1379,8 +1392,14 @@ const BUILTIN_DECLARATIONS = {
|
|
|
1379
1392
|
` };`,
|
|
1380
1393
|
`}`,
|
|
1381
1394
|
`function __sqliteWrapWasm(db, file) {`,
|
|
1395
|
+
` // v1.0.362 - sql.js's export() ends an open transaction, so persisting`,
|
|
1396
|
+
` // mid-transaction would break the explicit COMMIT that follows. While a`,
|
|
1397
|
+
` // transaction is active, writes are only flushed to disk once, after the`,
|
|
1398
|
+
` // COMMIT succeeds (the wrapper's own persist at that point covers it).`,
|
|
1399
|
+
` let __sqliteTxn = 0;`,
|
|
1382
1400
|
` const persist = () => {`,
|
|
1383
1401
|
` if (file === ':memory:') return;`,
|
|
1402
|
+
` if (__sqliteTxn > 0) return;`,
|
|
1384
1403
|
` try {`,
|
|
1385
1404
|
` require('fs').writeFileSync(file, Buffer.from(db.export()));`,
|
|
1386
1405
|
` } catch (error) {`,
|
|
@@ -1420,15 +1439,19 @@ const BUILTIN_DECLARATIONS = {
|
|
|
1420
1439
|
` transaction(fn) {`,
|
|
1421
1440
|
` return () => {`,
|
|
1422
1441
|
` db.run('BEGIN');`,
|
|
1442
|
+
` __sqliteTxn++;`,
|
|
1443
|
+
` let out;`,
|
|
1423
1444
|
` try {`,
|
|
1424
|
-
`
|
|
1445
|
+
` out = fn();`,
|
|
1425
1446
|
` db.run('COMMIT');`,
|
|
1426
|
-
` persist();`,
|
|
1427
|
-
` return out;`,
|
|
1428
1447
|
` } catch (error) {`,
|
|
1429
1448
|
` try { db.run('ROLLBACK'); } catch (_) {}`,
|
|
1430
1449
|
` throw error;`,
|
|
1450
|
+
` } finally {`,
|
|
1451
|
+
` __sqliteTxn--;`,
|
|
1431
1452
|
` }`,
|
|
1453
|
+
` persist();`,
|
|
1454
|
+
` return out;`,
|
|
1432
1455
|
` };`,
|
|
1433
1456
|
` },`,
|
|
1434
1457
|
` };`,
|
|
@@ -2664,7 +2687,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
2664
2687
|
file: (args, context) => `new File(${args.map(a => generateExpr(a, context)).join(', ')})`,
|
|
2665
2688
|
formData: (_args) => `new FormData()`,
|
|
2666
2689
|
|
|
2667
|
-
// ── v1.0.
|
|
2690
|
+
// ── v1.0.362 - browser DOM (IOPL-native). All helpers guard their browser
|
|
2668
2691
|
// global, so the generated output throws a clear teaching error under Node.
|
|
2669
2692
|
select: (args, context) => {
|
|
2670
2693
|
ensureBuiltin(context, 'dom');
|
|
@@ -2682,7 +2705,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
2682
2705
|
return `__parseHTML(${generateExpr(args[0], context)})`;
|
|
2683
2706
|
},
|
|
2684
2707
|
|
|
2685
|
-
// ── v1.0.
|
|
2708
|
+
// ── v1.0.362 - browser input (IOPL-native).
|
|
2686
2709
|
localPoint: (args, context) => {
|
|
2687
2710
|
ensureBuiltin(context, 'input');
|
|
2688
2711
|
requireArgs('localPoint', args, 2, 'localPoint(event, canvas)');
|
|
@@ -2698,7 +2721,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
2698
2721
|
return `__droppedFiles(${generateExpr(args[0], context)})`;
|
|
2699
2722
|
},
|
|
2700
2723
|
|
|
2701
|
-
// ── v1.0.
|
|
2724
|
+
// ── v1.0.362 - browser assets (IOPL-native). Each awaitable helper is
|
|
2702
2725
|
// awaited here, so the surrounding function/handler is marked async.
|
|
2703
2726
|
loadImage: (args, context) => {
|
|
2704
2727
|
ensureBuiltin(context, 'assets');
|
|
@@ -2731,7 +2754,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
2731
2754
|
return `(await __readDataUrl(${generateExpr(args[0], context)}))`;
|
|
2732
2755
|
},
|
|
2733
2756
|
|
|
2734
|
-
// ── v1.0.
|
|
2757
|
+
// ── v1.0.362 - Web Audio (IOPL-native).
|
|
2735
2758
|
audioContext: (_args, context) => {
|
|
2736
2759
|
ensureBuiltin(context, 'audio');
|
|
2737
2760
|
return `__audioContext()`;
|
|
@@ -2742,7 +2765,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
2742
2765
|
return `__audioTone(${args.map(a => generateExpr(a, context)).join(', ')})`;
|
|
2743
2766
|
},
|
|
2744
2767
|
|
|
2745
|
-
// ── v1.0.
|
|
2768
|
+
// ── v1.0.362 - WebSocket send helper (works with any WebSocket-like object,
|
|
2746
2769
|
// browser or Node): strings go through verbatim, everything else is JSON.
|
|
2747
2770
|
webSocketSend: (args, context) => {
|
|
2748
2771
|
requireArgs('webSocketSend', args, 2, 'webSocketSend(socket, { type: "move", x: 10 })');
|
|
@@ -2751,7 +2774,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
2751
2774
|
return `${ws}.send(typeof (${value}) === 'string' ? (${value}) : JSON.stringify(${value}))`;
|
|
2752
2775
|
},
|
|
2753
2776
|
|
|
2754
|
-
// ── v1.0.
|
|
2777
|
+
// ── v1.0.362 - WebGL (IOPL-native).
|
|
2755
2778
|
webglContext: (args, context) => {
|
|
2756
2779
|
ensureBuiltin(context, 'gl');
|
|
2757
2780
|
requireOneArg('webglContext', args);
|
|
@@ -2956,12 +2979,19 @@ function emitRequire(context, moduleName, alias) {
|
|
|
2956
2979
|
}
|
|
2957
2980
|
const known = KNOWN_PACKAGES[bareName];
|
|
2958
2981
|
if (known) {
|
|
2959
|
-
const boundAs = known.match(/const (\w+)/)[1];
|
|
2982
|
+
const boundAs = known.match(/(?:const|let) (\w+)/)[1];
|
|
2960
2983
|
if (alias !== boundAs) {
|
|
2961
2984
|
throw new Error(
|
|
2962
2985
|
`"${bareName}" is part of PlainScript's built-in runtime and is already available as "${boundAs}". Remove "as ${alias}".`
|
|
2963
2986
|
);
|
|
2964
2987
|
}
|
|
2988
|
+
const key = `${npmName}\0${alias}`;
|
|
2989
|
+
if (context.requires.has(key)) return '';
|
|
2990
|
+
context.requires.add(key);
|
|
2991
|
+
// Canonical binding, e.g. express to express, sqlite to Database. Using
|
|
2992
|
+
// the KNOWN entry keeps sqlite's lazy loader (better-sqlite3 is an
|
|
2993
|
+
// optional backend) instead of emitting a fresh eager require.
|
|
2994
|
+
return known;
|
|
2965
2995
|
}
|
|
2966
2996
|
const key = `${npmName}\0${alias}`;
|
|
2967
2997
|
if (context.requires.has(key)) return '';
|
|
@@ -3880,16 +3910,16 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
3880
3910
|
// v2.2.0 - mongo "<connection>" [db "<name>"]: MongoDB client bound to "db".
|
|
3881
3911
|
// Uses the mongodb driver; subsequent query/insert/update/delete/execute
|
|
3882
3912
|
// statements compile to MongoDB collection operations.
|
|
3913
|
+
// v1.0.362 - mongodb is an optional backend: the require lives inside
|
|
3914
|
+
// __mongoOpen (it is only evaluated when a database is actually opened),
|
|
3915
|
+
// so programs that never use it start without needing the module.
|
|
3883
3916
|
case 'MongoStatement': {
|
|
3884
3917
|
_sqlDriver = 'mongo';
|
|
3885
3918
|
_sqlClientVar = 'db';
|
|
3886
3919
|
markAsync(context);
|
|
3887
3920
|
ensureBuiltin(context, 'mongodb');
|
|
3888
3921
|
const dbArg = node.dbName ? `, ${generateExpr(node.dbName, context)}` : '';
|
|
3889
|
-
return
|
|
3890
|
-
emitRequire(context, 'mongodb'),
|
|
3891
|
-
`${indent}const db = await __mongoOpen(${generateExpr(node.connection, context)}${dbArg});`,
|
|
3892
|
-
].filter(Boolean).map(line => line.startsWith('const ') ? `${indent}${line}` : line).join('\n');
|
|
3922
|
+
return `${indent}const db = await __mongoOpen(${generateExpr(node.connection, context)}${dbArg});`;
|
|
3893
3923
|
}
|
|
3894
3924
|
|
|
3895
3925
|
case 'QueryStatement':
|
|
@@ -4136,7 +4166,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
4136
4166
|
].join('\n');
|
|
4137
4167
|
}
|
|
4138
4168
|
|
|
4139
|
-
// v1.0.
|
|
4169
|
+
// v1.0.362 - every frame … done: one requestAnimationFrame loop. The next
|
|
4140
4170
|
// frame is scheduled after the body so the body always runs once per
|
|
4141
4171
|
// frame; an awaiting body makes the callback async automatically.
|
|
4142
4172
|
case 'EveryFrameStatement': {
|
|
@@ -4153,7 +4183,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
4153
4183
|
].join('\n');
|
|
4154
4184
|
}
|
|
4155
4185
|
|
|
4156
|
-
// v1.0.
|
|
4186
|
+
// v1.0.362 - after <n> <unit> … done: one-shot setTimeout. The delay is an
|
|
4157
4187
|
// expression scaled by the unit; an awaiting body makes the callback async.
|
|
4158
4188
|
case 'AfterStatement': {
|
|
4159
4189
|
const delay = generateExpr(node.delay, context);
|
|
@@ -4290,7 +4320,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
4290
4320
|
return `${indent}__emitter.on(${event}, (${node.paramName}) => {\n${body}\n${indent}});`;
|
|
4291
4321
|
}
|
|
4292
4322
|
|
|
4293
|
-
// v1.0.
|
|
4323
|
+
// v1.0.362 - when <target> "<event>" happens [as <name>] … done: DOM event
|
|
4294
4324
|
// listener. The handler param defaults to "event"; an awaiting body makes
|
|
4295
4325
|
// the callback async automatically.
|
|
4296
4326
|
case 'WhenTargetedStatement': {
|
package/compiler/parser.js
CHANGED
|
@@ -545,7 +545,7 @@ function parse(tokens) {
|
|
|
545
545
|
peekAt(2).type === TOKEN.IDENTIFIER && TIME_UNITS[peekAt(2).value]) {
|
|
546
546
|
return parseEvery();
|
|
547
547
|
}
|
|
548
|
-
// v1.0.
|
|
548
|
+
// v1.0.362 - every frame … done: requestAnimationFrame loop. "every" lexes
|
|
549
549
|
// as TOKEN.EACH; guard on the following "frame" identifier ("for every
|
|
550
550
|
// item in list" is intercepted by TOKEN.FOR above).
|
|
551
551
|
if (token.type === TOKEN.EACH && peekAt(1).type === TOKEN.IDENTIFIER &&
|
|
@@ -797,14 +797,14 @@ function parse(tokens) {
|
|
|
797
797
|
return parseEvery();
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
-
// v1.0.
|
|
800
|
+
// v1.0.362 - every frame … done: requestAnimationFrame loop. Identifier
|
|
801
801
|
// mirror of the EACH dispatch above.
|
|
802
802
|
if (token.value === 'every' && peekAt(1).type === TOKEN.IDENTIFIER &&
|
|
803
803
|
peekAt(1).value === 'frame') {
|
|
804
804
|
return parseEveryFrame();
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
-
// v1.0.
|
|
807
|
+
// v1.0.362 - after <n> <unit>s … done: one-shot delayed execution.
|
|
808
808
|
// Contextual like "retry": "after becomes 5" and after(...) keep their
|
|
809
809
|
// ordinary meanings.
|
|
810
810
|
if (token.value === 'after' &&
|
|
@@ -2106,7 +2106,7 @@ function parseAsk() {
|
|
|
2106
2106
|
(nextToken.type === TOKEN.IDENTIFIER && (nextToken.value === 'nothing' || nextToken.value === 'socket'));
|
|
2107
2107
|
|
|
2108
2108
|
if (!isEventWhen) {
|
|
2109
|
-
// v1.0.
|
|
2109
|
+
// v1.0.362 - when <target> "<event>" happens [as <name>] … done binds a
|
|
2110
2110
|
// DOM event listener: when button "click" happens => addEventListener.
|
|
2111
2111
|
// Detection probes the target expression and commits only when a string
|
|
2112
2112
|
// followed by "happens" is next; otherwise the tokens are replayed and
|
|
@@ -3325,7 +3325,7 @@ function parseAsk() {
|
|
|
3325
3325
|
|
|
3326
3326
|
const item = tryParseItemExpression();
|
|
3327
3327
|
if (item) return item;
|
|
3328
|
-
// v1.0.
|
|
3328
|
+
// v1.0.362 - `new` works anywhere an expression is parsed (assignment
|
|
3329
3329
|
// targets, call arguments, member chains). "new" is not a keyword, so this
|
|
3330
3330
|
// identifier must be intercepted here; parseAtom would read it as a plain
|
|
3331
3331
|
// Identifier and turn "new THREE.Scene()" into "new.THREE.Scene()".
|
|
@@ -3816,7 +3816,7 @@ function parseAsk() {
|
|
|
3816
3816
|
return { type: 'EveryStatement', count, unit, body };
|
|
3817
3817
|
}
|
|
3818
3818
|
|
|
3819
|
-
// v1.0.
|
|
3819
|
+
// v1.0.362 - every frame … done: a requestAnimationFrame loop whose body runs
|
|
3820
3820
|
// once per animation frame. The next frame is scheduled after the body so it
|
|
3821
3821
|
// always runs (t is the frame timestamp, like the DOM's rAF callback).
|
|
3822
3822
|
function parseEveryFrame() {
|
|
@@ -3826,7 +3826,7 @@ function parseAsk() {
|
|
|
3826
3826
|
return { type: 'EveryFrameStatement', body };
|
|
3827
3827
|
}
|
|
3828
3828
|
|
|
3829
|
-
// v1.0.
|
|
3829
|
+
// v1.0.362 - after <n> <unit>s … done: run work once after a delay.
|
|
3830
3830
|
// after 5 seconds
|
|
3831
3831
|
// show "butter!" ... done
|
|
3832
3832
|
// The delay is a number expression ("after count seconds"); the unit is
|
package/compiler/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# PlainScript 1.0.
|
|
1
|
+
# PlainScript 1.0.362 Capability Audit
|
|
2
2
|
|
|
3
3
|
This audit is based on what the compiler actually supports right now.
|
|
4
4
|
If `plainscript check` validates it, it's listed here.
|
|
@@ -126,6 +126,6 @@ find examples -name '*.pln' -exec node compiler/cli.js check {} \;
|
|
|
126
126
|
|
|
127
127
|
## Version Info
|
|
128
128
|
|
|
129
|
-
The release label for this repo is `1.0.
|
|
129
|
+
The release label for this repo is `1.0.362`. It covers the compiler,
|
|
130
130
|
package metadata, website, editor tooling, and browser/game documentation.
|
|
131
131
|
Third-party dependency versions are not tied to this label.
|
package/docs/GAME-PROMPT.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# PlainScript Game Development Prompt Guide (v1.0.
|
|
1
|
+
# PlainScript Game Development Prompt Guide (v1.0.362)
|
|
2
2
|
|
|
3
3
|
The standing instruction sheet for AI agents asked to build games and
|
|
4
4
|
interactive browser apps in PlainScript.
|
|
@@ -29,7 +29,7 @@ Every PlainScript block you show a user must compile - check it first.
|
|
|
29
29
|
|
|
30
30
|
PlainScript is intent-oriented: you describe *what* the game should do and the
|
|
31
31
|
compiler generates JavaScript. One hard rule - **game logic lives in
|
|
32
|
-
PlainScript**. v1.0.
|
|
32
|
+
PlainScript**. v1.0.362 reaches into any JS API from `.pln`, which makes
|
|
33
33
|
dropping to JS tempting; do not. Every browser capability below stays
|
|
34
34
|
reachable without leaving PlainScript.
|
|
35
35
|
|
|
@@ -237,7 +237,7 @@ done
|
|
|
237
237
|
requestAnimationFrame(loop)
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
v1.0.
|
|
240
|
+
v1.0.362 adds hex literals (`0xRRGGBB`): numeric colors use `0xffffff` instead
|
|
241
241
|
of magic decimals, and a `"#ffffff"` string works too - THREE accepts all
|
|
242
242
|
three.
|
|
243
243
|
|
package/docs/PLAINSCRIPT-SPEC.md
CHANGED
package/docs/index.html
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<meta name="description" content="PlainScript 1.0.
|
|
6
|
+
<meta name="description" content="PlainScript 1.0.362 language reference and examples">
|
|
7
7
|
<meta name="theme-color" content="#070c16">
|
|
8
|
-
<title>PlainScript 1.0.
|
|
8
|
+
<title>PlainScript 1.0.362</title>
|
|
9
9
|
|
|
10
10
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
11
11
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<a class="nav-logo" href="#">
|
|
22
22
|
<img class="nav-logo-image" src="logo-pln.jpg" alt="">
|
|
23
23
|
<span>PlainScript</span>
|
|
24
|
-
<span class="logo-ver">1.0.
|
|
24
|
+
<span class="logo-ver">1.0.362</span>
|
|
25
25
|
</a>
|
|
26
26
|
<button class="nav-toggle" id="nav-toggle" aria-label="Toggle navigation" aria-expanded="false" aria-controls="nav-links">
|
|
27
27
|
<span class="nav-toggle-bar"></span>
|
|
@@ -117,7 +117,7 @@ npm start</code></pre>
|
|
|
117
117
|
<div class="container">
|
|
118
118
|
<p class="section-tag" data-reveal>Feature library</p>
|
|
119
119
|
<h2 class="section-title" data-reveal>Examples you can try today.</h2>
|
|
120
|
-
<p class="section-lead">These snippets use the PlainScript 1.0.
|
|
120
|
+
<p class="section-lead">These snippets use the PlainScript 1.0.362 grammar.</p>
|
|
121
121
|
<div class="library-toolbar" data-reveal>
|
|
122
122
|
<label class="sr-only" for="lib-search">Search examples</label>
|
|
123
123
|
<input id="lib-search" class="lib-search-input" type="search" placeholder="Search examples">
|
|
@@ -146,7 +146,7 @@ npm start</code></pre>
|
|
|
146
146
|
</main>
|
|
147
147
|
|
|
148
148
|
<footer class="site-footer">
|
|
149
|
-
<div class="container footer-bottom"><span>PlainScript</span><span>1.0.
|
|
149
|
+
<div class="container footer-bottom"><span>PlainScript</span><span>1.0.362</span></div>
|
|
150
150
|
</footer>
|
|
151
151
|
|
|
152
152
|
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
|
package/examples/arrays.pln
CHANGED
package/examples/auth-api.pln
CHANGED
package/examples/basics.pln
CHANGED
package/examples/bots.pln
CHANGED
|
@@ -5,7 +5,7 @@ no canvas, no library, no bundler. Click **+10 points** and the score span
|
|
|
5
5
|
updates; click **Log entry** to append a line to the run log; press **R** to
|
|
6
6
|
reset both.
|
|
7
7
|
|
|
8
|
-
It demonstrates the v1.0.
|
|
8
|
+
It demonstrates the v1.0.362 browser API:
|
|
9
9
|
|
|
10
10
|
- `document.querySelector` + `.innerHTML becomes` / `.textContent becomes`.
|
|
11
11
|
- `when clickButton "click" happens` DOM event handlers.
|
|
@@ -5,7 +5,7 @@ arrow keys while red blocks fall from the top. Score a point for every block
|
|
|
5
5
|
that drifts past you; lose a life when one collides with you. Run out of lives
|
|
6
6
|
and the game freezes until you press Restart.
|
|
7
7
|
|
|
8
|
-
It demonstrates the v1.0.
|
|
8
|
+
It demonstrates the v1.0.362 browser API:
|
|
9
9
|
|
|
10
10
|
- `when document "keydown"/"keyup" happens` handlers that set flags on a
|
|
11
11
|
`keys{}` map - the game loop reads the map, the event handlers never move the
|
package/examples/collections.pln
CHANGED
package/examples/concurrency.pln
CHANGED
package/examples/conditions.pln
CHANGED
package/examples/database.pln
CHANGED
package/examples/day2.pln
CHANGED
package/examples/day3.pln
CHANGED
package/examples/deployment.pln
CHANGED
package/examples/email-send.pln
CHANGED
package/examples/expressions.pln
CHANGED
package/examples/files.pln
CHANGED
package/examples/functions.pln
CHANGED
package/examples/hello.pln
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// PlainScript 1.0.
|
|
1
|
+
// PlainScript 1.0.362: hello world.
|
|
2
2
|
show "Hello, PlainScript!"
|
package/examples/http-client.pln
CHANGED
package/examples/http.pln
CHANGED
|
@@ -11,7 +11,7 @@ What the script exercises:
|
|
|
11
11
|
- `bring THREE from "three"` emits `require('three')` at the top of the build.
|
|
12
12
|
- `new THREE.Scene()`, `new THREE.WebGLRenderer()`, `new THREE.SphereGeometry(...)`
|
|
13
13
|
and `new THREE.Mesh(geo, mat)` fill a starfield of 150 primitives. Colors use
|
|
14
|
-
v1.0.
|
|
14
|
+
v1.0.362 hex literals (`0x40c463`), so the palette is legible at a glance.
|
|
15
15
|
- A resize callback `make fitWindow() ... done` passed straight to
|
|
16
16
|
`window.addEventListener("resize", fitWindow)`.
|
|
17
17
|
- `fetchJson("config.json")` (auto-awaiting) reads `{stars, color}` out of a
|
package/examples/json.pln
CHANGED
package/examples/loops.pln
CHANGED
package/examples/modules/app.pln
CHANGED
package/examples/mongo.pln
CHANGED
package/examples/objects.pln
CHANGED
package/examples/ocr.pln
CHANGED
package/examples/packages.pln
CHANGED
package/examples/records.pln
CHANGED
package/examples/rest-api.pln
CHANGED
package/examples/server.pln
CHANGED
package/examples/sqlite.pln
CHANGED
package/examples/start.pln
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// PlainScript 1.0.
|
|
1
|
+
// PlainScript 1.0.362: start command entry point.
|
|
2
2
|
show "PlainScript started"
|
package/examples/stdlib.pln
CHANGED
package/examples/testing.pln
CHANGED
|
@@ -11,7 +11,7 @@ What the script exercises:
|
|
|
11
11
|
- `remember scene as new THREE.Scene()`, `new THREE.PerspectiveCamera(...)`,
|
|
12
12
|
`new THREE.WebGLRenderer()` and `renderer.setSize(...)`.
|
|
13
13
|
- `new THREE.BoxGeometry(...)`, `new THREE.MeshStandardMaterial({ color: 0x40c463 })`
|
|
14
|
-
and `new THREE.Mesh(geo, mat)` - v1.0.
|
|
14
|
+
and `new THREE.Mesh(geo, mat)` - v1.0.362 hex literals (`0xRRGGBB`) keep the
|
|
15
15
|
palette legible; the lights use `0xffffff`.
|
|
16
16
|
- A light rig with `new THREE.AmbientLight(...)` + `new THREE.DirectionalLight(...)`.
|
|
17
17
|
- `document.body.append(renderer.domElement)` mounts the WebGL canvas.
|
package/examples/web-api.pln
CHANGED
package/examples/web-app.pln
CHANGED
package/examples/websocket.pln
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plainscript-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.362",
|
|
4
4
|
"description": "PlainScript - an Intent-Oriented Programming Language. When even a simple sentence can be code.",
|
|
5
5
|
"main": "compiler/cli.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"plainscript": "./compiler/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "node tests/compiler.test.js && node tests/build.test.js && node tests/telegram.test.js && node tests/ocr.test.js && node tests/nesting.test.js && node tests/backend.test.js && node tests/runtime.test.js && node tests/browser.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/sourcemap.test.js && node tests/modules.test.js && node tests/repeat.test.js && node tests/datastructures.test.js && node tests/kernel.test.js && node tests/docs.test.js && node tests/compat/browser-interop.test.js && node tests/compat/language.test.js && node tests/compat/node.test.js && node tests/compat/binary.test.js && node tests/compat/errors.test.js && node tests/compat/async.test.js && node tests/compat/modules.test.js && node tests/compat/npm.test.js && node tests/compat/web.test.js && node tests/compat/real-world.test.js"
|
|
10
|
+
"test": "node tests/compiler.test.js && node tests/build.test.js && node tests/telegram.test.js && node tests/ocr.test.js && node tests/nesting.test.js && node tests/backend.test.js && node tests/runtime.test.js && node tests/browser.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/sourcemap.test.js && node tests/modules.test.js && node tests/repeat.test.js && node tests/datastructures.test.js && node tests/kernel.test.js && node tests/docs.test.js && node tests/compat/browser-interop.test.js && node tests/compat/language.test.js && node tests/compat/node.test.js && node tests/compat/binary.test.js && node tests/compat/errors.test.js && node tests/compat/async.test.js && node tests/compat/modules.test.js && node tests/compat/npm.test.js && node tests/compat/web.test.js && node tests/compat/real-world.test.js && node tests/packaging.test.js"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"compiler",
|
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
"sql.js": "^1.13.0",
|
|
40
40
|
"ws": "^8.21.3"
|
|
41
41
|
},
|
|
42
|
-
"dependencies": {
|
|
42
|
+
"dependencies": {},
|
|
43
|
+
"optionalDependencies": {
|
|
44
|
+
"better-sqlite3": "^11.10.0",
|
|
43
45
|
"mongodb": "^6.20.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"three": "^0.185.1"
|
|
46
|
+
"sql.js": "^1.13.0",
|
|
47
|
+
"tesseract.js": "^7.0.0"
|
|
47
48
|
}
|
|
48
49
|
}
|