plainscript-lang 1.0.36 → 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 +252 -20
- package/compiler/bundler.js +4 -4
- package/compiler/cli.js +18 -18
- package/compiler/dependency-detector.js +34 -22
- package/compiler/generator.js +326 -196
- package/compiler/lexer.js +49 -39
- package/compiler/parser.js +552 -181
- package/compiler/sourcemap.js +1 -1
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +2 -2
- package/docs/FB-PROMPT.md +524 -0
- package/docs/GAME-PROMPT.md +56 -55
- package/docs/PLAINSCRIPT-SPEC.md +16 -15
- package/docs/index.html +13 -6
- package/docs/website/script.js +1 -1
- package/docs/website/style.css +3 -3
- package/examples/ai-providers.pln +1 -1
- package/examples/arrays.pln +1 -1
- package/examples/async-errors.pln +2 -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 +3 -3
- 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 +4 -4
- 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 +3 -2
- 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 +6 -6
- package/examples/javascript-library/public/index.html +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 +2 -2
- 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 +2 -2
- package/examples/whatsapp-bot/qr.pln +2 -2
- package/package.json +11 -12
package/examples/basics.pln
CHANGED
package/examples/bots.pln
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# DOM-first interactive clicker
|
|
2
2
|
|
|
3
|
-
A small dashboard built with PlainScript that talks to the DOM directly
|
|
3
|
+
A small dashboard built with PlainScript that talks to the DOM directly -
|
|
4
4
|
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.
|
|
@@ -18,7 +18,7 @@ It demonstrates the v1.0.36 browser API:
|
|
|
18
18
|
|
|
19
19
|
## Run
|
|
20
20
|
|
|
21
|
-
Build the compiled script and serve the folder (any static file server works
|
|
21
|
+
Build the compiled script and serve the folder (any static file server works -
|
|
22
22
|
`npx serve public` is one option):
|
|
23
23
|
|
|
24
24
|
```bash
|
|
@@ -5,10 +5,10 @@ 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
|
-
`keys{}` map
|
|
11
|
+
`keys{}` map - the game loop reads the map, the event handlers never move the
|
|
12
12
|
player directly.
|
|
13
13
|
- `every frame ... done`, a `requestAnimationFrame` loop with delta time from
|
|
14
14
|
`performance.now()` so movement speed is frame-rate independent.
|
|
@@ -20,7 +20,7 @@ It demonstrates the v1.0.36 browser API:
|
|
|
20
20
|
|
|
21
21
|
## Run
|
|
22
22
|
|
|
23
|
-
Build the compiled script, then open the page (any static file server works
|
|
23
|
+
Build the compiled script, then open the page (any static file server works -
|
|
24
24
|
`npx serve public` is one option):
|
|
25
25
|
|
|
26
26
|
```bash
|
|
@@ -30,5 +30,5 @@ npx serve public
|
|
|
30
30
|
|
|
31
31
|
Then open http://localhost:3000.
|
|
32
32
|
|
|
33
|
-
The page needs a server only for the HTML script tag, not for the game logic
|
|
33
|
+
The page needs a server only for the HTML script tag, not for the game logic -
|
|
34
34
|
opening `public/index.html` directly from disk works in most browsers too.
|
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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The full-interop showcase: import an npm package with `bring`, call members and
|
|
4
4
|
`new` constructors on it, pass PlainScript functions as native callbacks, and
|
|
5
5
|
optionally shape the scene with a JSON config fetched at runtime. This is the
|
|
6
|
-
**import path**
|
|
6
|
+
**import path** - unlike `examples/three-dimensional`, which maps `THREE` to a
|
|
7
7
|
browser global, this file demands the package be bundled for the browser.
|
|
8
8
|
|
|
9
9
|
What the script exercises:
|
|
@@ -11,12 +11,12 @@ 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
|
|
18
18
|
served file and re-sizes/re-colors the field. In `try ... recover as err ... done`
|
|
19
|
-
a failing fetch logs the error and falls back to the built-in defaults
|
|
19
|
+
a failing fetch logs the error and falls back to the built-in defaults -
|
|
20
20
|
serve the folder over HTTP so the fetch succeeds, and you'll see the fallback
|
|
21
21
|
path fire if you ever open the page from `file://`.
|
|
22
22
|
- `every frame ... done` rotates the whole scene and calls `renderer.render(...)`.
|
|
@@ -38,7 +38,7 @@ at `interop.bundle.js`.
|
|
|
38
38
|
`plainscript add <package>` installs a package into the current project and
|
|
39
39
|
saves it to `package.json` (`npm install <package> --save` under the hood). The
|
|
40
40
|
esbuild one-liner above is all the bundling the import path needs; vite or
|
|
41
|
-
rollup work equally well. Build twice
|
|
41
|
+
rollup work equally well. Build twice - once by PlainScript, once by a bundler -
|
|
42
42
|
is the whole trick: PlainScript emits ordinary CommonJS `require()`s and the
|
|
43
43
|
bundler turns them into browser-safe modules.
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ imports from the source alone.
|
|
|
48
48
|
## What to tweak
|
|
49
49
|
|
|
50
50
|
Point `fetchJson` at a remote URL or drop a different `config.json` next to the
|
|
51
|
-
page. Anything you can reach with `fetch`
|
|
52
|
-
`{ok, status, data, text, parseError}`
|
|
51
|
+
page. Anything you can reach with `fetch` - `fetchJson` returns
|
|
52
|
+
`{ok, status, data, text, parseError}` - is fair game, and the
|
|
53
53
|
`try ... recover` block shows the friendly-fallback pattern when the network
|
|
54
54
|
misbehaves.
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
</head>
|
|
32
32
|
<body>
|
|
33
33
|
<div class="note">
|
|
34
|
-
Fetching <code>config.json</code> from the server
|
|
34
|
+
Fetching <code>config.json</code> from the server - serve the folder over HTTP
|
|
35
35
|
and the star count / color come from the file; otherwise the scene falls back
|
|
36
36
|
to the built-in defaults (check the console for the log lines).
|
|
37
37
|
</div>
|
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The canonical PlainScript path to 3D: the page loads **three.js from a CDN**
|
|
4
4
|
before the compiled script, so `src/scene.pln` just references the global
|
|
5
|
-
`THREE` object directly. The build is 100% dependency-free
|
|
5
|
+
`THREE` object directly. The build is 100% dependency-free - the emitted file
|
|
6
6
|
contains no `require(...)` and needs no bundler, it only needs `THREE` to exist
|
|
7
7
|
in the page.
|
|
8
8
|
|
|
@@ -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)`
|
|
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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// PlainScript 1.0.
|
|
1
|
+
// PlainScript 1.0.362: WhatsApp pairing login.
|
|
2
2
|
// Showcases `use baileys`, message.type branching, media downloads,
|
|
3
3
|
// and button/list reply handling.
|
|
4
4
|
|
|
5
5
|
whatsapp bot
|
|
6
6
|
auth "plain-script-whatsapp"
|
|
7
|
-
use baileys "@
|
|
7
|
+
use baileys "@whiskeysockets/baileys"
|
|
8
8
|
login pairing "2348012345678"
|
|
9
9
|
on message
|
|
10
10
|
log message
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// PlainScript 1.0.
|
|
1
|
+
// PlainScript 1.0.362: WhatsApp QR login.
|
|
2
2
|
// Showcases `use baileys`, message.type branching, media downloads,
|
|
3
3
|
// and button handling.
|
|
4
4
|
|
|
5
5
|
whatsapp bot
|
|
6
6
|
auth "plain-script-whatsapp"
|
|
7
|
-
use baileys "@
|
|
7
|
+
use baileys "@whiskeysockets/baileys"
|
|
8
8
|
login qr
|
|
9
9
|
on message
|
|
10
10
|
log message
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plainscript-lang",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "PlainScript
|
|
3
|
+
"version": "1.0.362",
|
|
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/datastructures.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",
|
|
@@ -30,21 +30,20 @@
|
|
|
30
30
|
"node": ">=18.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"better-sqlite3": "^13.0.3",
|
|
33
|
+
"better-sqlite3": "^11.10.0",
|
|
35
34
|
"croner": "^10.0.1",
|
|
36
35
|
"express": "^5.2.1",
|
|
37
36
|
"multer": "^2.0.2",
|
|
38
37
|
"nodemailer": "^9.0.5",
|
|
39
|
-
"
|
|
40
|
-
"redis": "^6.2.1",
|
|
38
|
+
"redis": "^5.8.3",
|
|
41
39
|
"sql.js": "^1.13.0",
|
|
42
40
|
"ws": "^8.21.3"
|
|
43
41
|
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
42
|
+
"dependencies": {},
|
|
43
|
+
"optionalDependencies": {
|
|
44
|
+
"better-sqlite3": "^11.10.0",
|
|
45
|
+
"mongodb": "^6.20.0",
|
|
46
|
+
"sql.js": "^1.13.0",
|
|
47
|
+
"tesseract.js": "^7.0.0"
|
|
49
48
|
}
|
|
50
49
|
}
|