plainscript-lang 1.0.3 → 1.0.35
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 +29 -0
- package/compiler/cli.js +1 -1
- package/compiler/dependency-detector.js +6 -2
- package/compiler/generator.js +422 -51
- package/compiler/parser.js +40 -2
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +9 -3
- package/docs/PLAINSCRIPT-SPEC.md +135 -3
- package/docs/index.html +27 -26
- 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 +211 -47
- 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/cache-and-jobs.pln +1 -1
- package/examples/cache-schedule.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/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/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 +2 -1
- package/docs/logo.jpg +0 -0
package/README.md
CHANGED
|
@@ -204,6 +204,34 @@ remember identifier as uuid()
|
|
|
204
204
|
|
|
205
205
|
Other built-in helpers cover strings, collections, file paths, HTTP, caching, environment variables, and crypto.
|
|
206
206
|
|
|
207
|
+
## Images and visualizations
|
|
208
|
+
|
|
209
|
+
PlainScript includes a dependency-free SVG image library. Use `barChart` or
|
|
210
|
+
`lineChart` to turn labels and numbers into an image, then save it as an SVG or
|
|
211
|
+
embed it in a web response with `imageDataUri`:
|
|
212
|
+
|
|
213
|
+
```plainscript
|
|
214
|
+
remember months as ["Jan", "Feb", "Mar", "Apr"]
|
|
215
|
+
remember signups as [12, 18, 27, 35]
|
|
216
|
+
|
|
217
|
+
remember chart as barChart("Monthly signups", months, signups, {
|
|
218
|
+
width: 720,
|
|
219
|
+
height: 420,
|
|
220
|
+
accent: "#40c463"
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
saveImage("dist/monthly-signups.svg", chart)
|
|
224
|
+
show "Saved dist/monthly-signups.svg"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Use `lineChart(title, labels, values, options)` for trends, `svgImage(width,
|
|
228
|
+
height, markup, options)` for custom SVG content, and `imageDataUri(image)` when
|
|
229
|
+
an image needs to be returned from a route or embedded in HTML. The generated
|
|
230
|
+
image is a string, so it works with `saveImage`, `reply`, and normal string
|
|
231
|
+
helpers without a native graphics dependency.
|
|
232
|
+
|
|
233
|
+

|
|
234
|
+
|
|
207
235
|
## Web apps
|
|
208
236
|
|
|
209
237
|
```plainscript
|
|
@@ -300,6 +328,7 @@ The `examples/` folder has working code for every feature:
|
|
|
300
328
|
| WebSockets, cache | `examples/websocket.pln`, `examples/cache-schedule.pln` |
|
|
301
329
|
| Bots | `examples/bots.pln`, `examples/telegram-bot.pln`, `examples/whatsapp-bot/` |
|
|
302
330
|
| OCR, uploads | `examples/ocr.pln`, `examples/id-verification/` |
|
|
331
|
+
| Images, visualizations | `examples/visualization.pln` |
|
|
303
332
|
| Tests, modules | `examples/testing.pln`, `examples/modules/` |
|
|
304
333
|
| Starter projects | `templates/` |
|
|
305
334
|
|
package/compiler/cli.js
CHANGED
|
@@ -31,7 +31,9 @@ const PACKAGE_MAP = Object.freeze({
|
|
|
31
31
|
'wasm-sqlite': 'sql.js',
|
|
32
32
|
// v2.1.1 — WhatsApp bots run on Baileys; QR codes render in the terminal
|
|
33
33
|
// through qrcode-terminal. Neither package ever appears in PlainScript source.
|
|
34
|
-
|
|
34
|
+
// The default Baileys is the maintained @qwerty-xcv fork (reliable pairing);
|
|
35
|
+
// users can override it per-block with `use baileys "<pkg>"`.
|
|
36
|
+
whatsapp: '@qwerty-xcv/baileys',
|
|
35
37
|
'wa-qrcode': 'qrcode-terminal',
|
|
36
38
|
// v2.2.0 — MongoDB driver.
|
|
37
39
|
mongodb: 'mongodb',
|
|
@@ -116,7 +118,9 @@ function visit(node, onUse) {
|
|
|
116
118
|
} else if (node.type === 'WhatsAppBotStatement') {
|
|
117
119
|
// v2.1.1 — WhatsApp bots run on Baileys and render QR codes with
|
|
118
120
|
// qrcode-terminal; both are implementation packages, never source.
|
|
119
|
-
|
|
121
|
+
// The user may override the Baileys package per-block with
|
|
122
|
+
// `use baileys "<pkg>"`; otherwise the default is used.
|
|
123
|
+
onUse(node.baileysModule || 'whatsapp');
|
|
120
124
|
onUse('wa-qrcode');
|
|
121
125
|
}
|
|
122
126
|
|