plainscript-lang 1.0.3 → 1.0.36
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 +836 -188
- package/compiler/cli.js +68 -4
- package/compiler/dependency-detector.js +6 -2
- package/compiler/generator.js +737 -51
- package/compiler/lexer.js +12 -0
- package/compiler/parser.js +184 -14
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +32 -5
- package/docs/GAME-PROMPT.md +915 -0
- package/docs/PLAINSCRIPT-SPEC.md +264 -3
- package/docs/index.html +41 -33
- package/docs/logo-pln.jpg +0 -0
- package/docs/visualization-example.svg +32 -0
- package/docs/website/script.js +130 -1
- package/docs/website/style.css +253 -122
- 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 +29 -0
- package/examples/browser-interactive/public/index.html +83 -0
- package/examples/browser-interactive/public/interactive.js +27 -0
- package/examples/browser-interactive/src/interactive.pln +34 -0
- package/examples/cache-and-jobs.pln +1 -1
- package/examples/cache-schedule.pln +1 -1
- package/examples/canvas-game/README.md +34 -0
- package/examples/canvas-game/public/game.js +131 -0
- package/examples/canvas-game/public/index.html +48 -0
- package/examples/canvas-game/src/game.pln +139 -0
- 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 +54 -0
- package/examples/javascript-library/package-lock.json +21 -0
- package/examples/javascript-library/package.json +8 -0
- package/examples/javascript-library/public/config.json +4 -0
- package/examples/javascript-library/public/index.html +40 -0
- package/examples/javascript-library/src/interop.pln +53 -0
- 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 +51 -0
- package/examples/three-dimensional/public/index.html +33 -0
- package/examples/three-dimensional/src/scene.pln +34 -0
- package/examples/visualization.pln +12 -0
- 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 +24 -2
- package/examples/whatsapp-bot/qr.pln +18 -2
- package/package.json +5 -3
- package/docs/logo.jpg +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// PlainScript 1.0.36: drop into an npm library via import, callbacks, and fetch.
|
|
2
|
+
|
|
3
|
+
bring THREE from "three"
|
|
4
|
+
|
|
5
|
+
remember scene as new THREE.Scene()
|
|
6
|
+
remember camera as new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000)
|
|
7
|
+
remember renderer as new THREE.WebGLRenderer()
|
|
8
|
+
renderer.setSize(window.innerWidth, window.innerHeight)
|
|
9
|
+
camera.position.z becomes 9
|
|
10
|
+
document.body.append(renderer.domElement)
|
|
11
|
+
|
|
12
|
+
make fitWindow()
|
|
13
|
+
camera.aspect becomes window.innerWidth / window.innerHeight
|
|
14
|
+
camera.updateProjectionMatrix()
|
|
15
|
+
renderer.setSize(window.innerWidth, window.innerHeight)
|
|
16
|
+
done
|
|
17
|
+
|
|
18
|
+
window.addEventListener("resize", fitWindow)
|
|
19
|
+
|
|
20
|
+
remember starCount as 150
|
|
21
|
+
remember starColor as 0x40c463
|
|
22
|
+
|
|
23
|
+
try
|
|
24
|
+
remember cfg as fetchJson("config.json")
|
|
25
|
+
if cfg.ok is true
|
|
26
|
+
starCount becomes cfg.data.stars
|
|
27
|
+
starColor becomes cfg.data.color
|
|
28
|
+
otherwise
|
|
29
|
+
show "Config request returned status " + cfg.status
|
|
30
|
+
done
|
|
31
|
+
recover as err
|
|
32
|
+
show message of err
|
|
33
|
+
show "Falling back to the built-in starfield."
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
remember stars as []
|
|
37
|
+
for index n from 0 to starCount
|
|
38
|
+
remember shape as new THREE.SphereGeometry(0.05, 6, 6)
|
|
39
|
+
remember starMaterial as new THREE.MeshBasicMaterial({ color: starColor })
|
|
40
|
+
remember star as new THREE.Mesh(shape, starMaterial)
|
|
41
|
+
star.position.x becomes (Math.random() - 0.5) * 18
|
|
42
|
+
star.position.y becomes (Math.random() - 0.5) * 10
|
|
43
|
+
star.position.z becomes (Math.random() - 0.5) * 10
|
|
44
|
+
scene.add(star)
|
|
45
|
+
stars.push(star)
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
show "Starfield ready with " + starCount + " stars"
|
|
49
|
+
|
|
50
|
+
every frame
|
|
51
|
+
scene.rotation.y becomes scene.rotation.y + 0.002
|
|
52
|
+
renderer.render(scene, camera)
|
|
53
|
+
done
|
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.36: start command entry point.
|
|
2
2
|
show "PlainScript started"
|
package/examples/stdlib.pln
CHANGED
package/examples/testing.pln
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# WebGL 3D scene via the global THREE object
|
|
2
|
+
|
|
3
|
+
The canonical PlainScript path to 3D: the page loads **three.js from a CDN**
|
|
4
|
+
before the compiled script, so `src/scene.pln` just references the global
|
|
5
|
+
`THREE` object directly. The build is 100% dependency-free — the emitted file
|
|
6
|
+
contains no `require(...)` and needs no bundler, it only needs `THREE` to exist
|
|
7
|
+
in the page.
|
|
8
|
+
|
|
9
|
+
What the script exercises:
|
|
10
|
+
|
|
11
|
+
- `remember scene as new THREE.Scene()`, `new THREE.PerspectiveCamera(...)`,
|
|
12
|
+
`new THREE.WebGLRenderer()` and `renderer.setSize(...)`.
|
|
13
|
+
- `new THREE.BoxGeometry(...)`, `new THREE.MeshStandardMaterial({ color: 0x40c463 })`
|
|
14
|
+
and `new THREE.Mesh(geo, mat)` — v1.0.36 hex literals (`0xRRGGBB`) keep the
|
|
15
|
+
palette legible; the lights use `0xffffff`.
|
|
16
|
+
- A light rig with `new THREE.AmbientLight(...)` + `new THREE.DirectionalLight(...)`.
|
|
17
|
+
- `document.body.append(renderer.domElement)` mounts the WebGL canvas.
|
|
18
|
+
- A `when window "resize" happens` handler that updates the camera aspect ratio
|
|
19
|
+
and the renderer size.
|
|
20
|
+
- An `every frame ... done` `requestAnimationFrame` loop that rotates the cube
|
|
21
|
+
and calls `renderer.render(scene, camera)`.
|
|
22
|
+
|
|
23
|
+
## Run
|
|
24
|
+
|
|
25
|
+
No install, no bundler. Build, then open the page over a static server:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx plainscript build src/scene.pln -o public/scene.js
|
|
29
|
+
npx serve public
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then open http://localhost:3000.
|
|
33
|
+
|
|
34
|
+
## The alternative: importing three as a package
|
|
35
|
+
|
|
36
|
+
If you prefer the npm module instead of a CDN global, swap the `.pln` header for
|
|
37
|
+
|
|
38
|
+
```plainscript
|
|
39
|
+
bring THREE from "three"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`plainscript build` then emits `const THREE = require('three');` at the top, and
|
|
43
|
+
the browser needs that bundled:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
plainscript add three
|
|
47
|
+
npx esbuild public/scene.js --bundle --outfile=public/scene.bundle.js
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
and point `index.html` at the bundled file. The CDN-global route above exists
|
|
51
|
+
precisely so you can ship 3D without a bundler.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>PlainScript 3D</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
background: #0d1117;
|
|
12
|
+
color: #e6edf3;
|
|
13
|
+
font-family: system-ui, "Segoe UI", sans-serif;
|
|
14
|
+
}
|
|
15
|
+
.note {
|
|
16
|
+
position: fixed;
|
|
17
|
+
bottom: 12px;
|
|
18
|
+
left: 50%;
|
|
19
|
+
transform: translateX(-50%);
|
|
20
|
+
padding: 6px 14px;
|
|
21
|
+
border-radius: 999px;
|
|
22
|
+
background: rgba(13, 17, 23, 0.75);
|
|
23
|
+
font-size: 13px;
|
|
24
|
+
color: #8b949e;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
|
|
31
|
+
<script src="scene.js"></script>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// PlainScript 1.0.36: a WebGL 3D scene using the global THREE object.
|
|
2
|
+
|
|
3
|
+
remember scene as new THREE.Scene()
|
|
4
|
+
remember camera as new THREE.PerspectiveCamera(75, 640 / 480, 0.1, 1000)
|
|
5
|
+
remember renderer as new THREE.WebGLRenderer()
|
|
6
|
+
renderer.setSize(640, 480)
|
|
7
|
+
camera.position.z becomes 5
|
|
8
|
+
|
|
9
|
+
remember geometry as new THREE.BoxGeometry(1, 1, 1)
|
|
10
|
+
remember material as new THREE.MeshStandardMaterial({ color: 0x40c463 })
|
|
11
|
+
remember cube as new THREE.Mesh(geometry, material)
|
|
12
|
+
scene.add(cube)
|
|
13
|
+
|
|
14
|
+
remember ambient as new THREE.AmbientLight(0xffffff)
|
|
15
|
+
remember sun as new THREE.DirectionalLight(0xffffff, 1)
|
|
16
|
+
sun.position.set(3, 5, 4)
|
|
17
|
+
scene.add(ambient)
|
|
18
|
+
scene.add(sun)
|
|
19
|
+
|
|
20
|
+
document.body.append(renderer.domElement)
|
|
21
|
+
|
|
22
|
+
make fitWindow()
|
|
23
|
+
camera.aspect becomes window.innerWidth / window.innerHeight
|
|
24
|
+
camera.updateProjectionMatrix()
|
|
25
|
+
renderer.setSize(window.innerWidth, window.innerHeight)
|
|
26
|
+
done
|
|
27
|
+
|
|
28
|
+
window.addEventListener("resize", fitWindow)
|
|
29
|
+
|
|
30
|
+
every frame
|
|
31
|
+
cube.rotation.y becomes cube.rotation.y + 0.01
|
|
32
|
+
cube.rotation.x becomes cube.rotation.x + 0.005
|
|
33
|
+
renderer.render(scene, camera)
|
|
34
|
+
done
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Create a dependency-free SVG visualization.
|
|
2
|
+
remember months as ["Jan", "Feb", "Mar", "Apr"]
|
|
3
|
+
remember signups as [12, 18, 27, 35]
|
|
4
|
+
|
|
5
|
+
remember chart as barChart("Monthly signups", months, signups, {
|
|
6
|
+
width: 720,
|
|
7
|
+
height: 420,
|
|
8
|
+
accent: "#40c463"
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
saveImage("dist/monthly-signups.svg", chart)
|
|
12
|
+
show "Saved dist/monthly-signups.svg"
|
package/examples/web-api.pln
CHANGED
package/examples/web-app.pln
CHANGED
package/examples/websocket.pln
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
// PlainScript 1.0.
|
|
1
|
+
// PlainScript 1.0.36: WhatsApp pairing login.
|
|
2
|
+
// Showcases `use baileys`, message.type branching, media downloads,
|
|
3
|
+
// and button/list reply handling.
|
|
2
4
|
|
|
3
5
|
whatsapp bot
|
|
4
6
|
auth "plain-script-whatsapp"
|
|
7
|
+
use baileys "@qwerty-xcv/baileys"
|
|
5
8
|
login pairing "2348012345678"
|
|
6
9
|
on message
|
|
7
10
|
log message
|
|
11
|
+
// Text commands.
|
|
8
12
|
if message.text is "/start"
|
|
9
13
|
reply "Welcome!"
|
|
10
14
|
done
|
|
@@ -12,5 +16,23 @@ whatsapp bot
|
|
|
12
16
|
reply `Available commands:
|
|
13
17
|
/start /help`
|
|
14
18
|
done
|
|
19
|
+
// Save any incoming image to disk.
|
|
20
|
+
if message.type is "image"
|
|
21
|
+
download "media/photo.jpg"
|
|
22
|
+
reply "Got your image, saved it to media/photo.jpg"
|
|
23
|
+
done
|
|
24
|
+
// Same for documents.
|
|
25
|
+
if message.type is "document"
|
|
26
|
+
download "media/file.bin"
|
|
27
|
+
reply "Got your document, saved it to media/file.bin"
|
|
28
|
+
done
|
|
29
|
+
// Button taps carry a buttonId we can reply with.
|
|
30
|
+
if message.type is "button"
|
|
31
|
+
reply "You chose: " + message.buttonId
|
|
32
|
+
done
|
|
33
|
+
// List replies carry the selected list item.
|
|
34
|
+
if message.type is "list"
|
|
35
|
+
reply "You picked: " + message.buttonId
|
|
36
|
+
done
|
|
15
37
|
done
|
|
16
|
-
done
|
|
38
|
+
done
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
// PlainScript 1.0.
|
|
1
|
+
// PlainScript 1.0.36: WhatsApp QR login.
|
|
2
|
+
// Showcases `use baileys`, message.type branching, media downloads,
|
|
3
|
+
// and button handling.
|
|
2
4
|
|
|
3
5
|
whatsapp bot
|
|
4
6
|
auth "plain-script-whatsapp"
|
|
7
|
+
use baileys "@qwerty-xcv/baileys"
|
|
5
8
|
login qr
|
|
6
9
|
on message
|
|
7
10
|
log message
|
|
8
11
|
if message.text is "/start"
|
|
9
12
|
reply "Welcome"
|
|
10
13
|
done
|
|
14
|
+
// Save incoming images automatically.
|
|
15
|
+
if message.type is "image"
|
|
16
|
+
download "media/photo.jpg"
|
|
17
|
+
reply "Saved your photo!"
|
|
18
|
+
done
|
|
19
|
+
if message.type is "document"
|
|
20
|
+
download "media/file.bin"
|
|
21
|
+
reply "Saved your document!"
|
|
22
|
+
done
|
|
23
|
+
// Button replies include the tapped button's id.
|
|
24
|
+
if message.type is "button"
|
|
25
|
+
reply "You chose: " + message.buttonId
|
|
26
|
+
done
|
|
11
27
|
done
|
|
12
|
-
done
|
|
28
|
+
done
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plainscript-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
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/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/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/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"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"compiler",
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"ws": "^8.21.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@qwerty-xcv/baileys": "^0.0.1",
|
|
45
46
|
"mongodb": "^7.6.0",
|
|
46
|
-
"tesseract.js": "^7.0.0"
|
|
47
|
+
"tesseract.js": "^7.0.0",
|
|
48
|
+
"three": "^0.185.1"
|
|
47
49
|
}
|
|
48
50
|
}
|
package/docs/logo.jpg
DELETED
|
Binary file
|