plainscript-lang 1.0.3-beta → 1.0.3

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 (73) hide show
  1. package/README.md +97 -120
  2. package/compiler/bundler.js +83 -12
  3. package/compiler/cli.js +62 -11
  4. package/compiler/dependency-detector.js +11 -0
  5. package/compiler/generator.js +280 -15
  6. package/compiler/lexer.js +2 -0
  7. package/compiler/parser.js +410 -28
  8. package/compiler/sourcemap.js +142 -0
  9. package/compiler/version.js +1 -1
  10. package/docs/CAPABILITY_GAP_AUDIT.md +17 -15
  11. package/docs/PLAINSCRIPT-SPEC.md +41 -39
  12. package/docs/index.html +60 -33
  13. package/docs/website/script.js +168 -19
  14. package/docs/website/style.css +187 -41
  15. package/examples/ai-providers.pln +1 -1
  16. package/examples/arrays.pln +1 -1
  17. package/examples/async-errors.pln +1 -1
  18. package/examples/auth-api.pln +1 -1
  19. package/examples/auth-sessions.pln +1 -1
  20. package/examples/basics.pln +1 -1
  21. package/examples/bots.pln +1 -1
  22. package/examples/cache-and-jobs.pln +1 -1
  23. package/examples/cache-schedule.pln +1 -1
  24. package/examples/collections.pln +1 -1
  25. package/examples/concurrency.pln +1 -1
  26. package/examples/conditions.pln +1 -1
  27. package/examples/database.pln +1 -1
  28. package/examples/day2.pln +1 -1
  29. package/examples/day3.pln +1 -1
  30. package/examples/deployment.pln +1 -1
  31. package/examples/email-send.pln +1 -1
  32. package/examples/error-handling.pln +1 -1
  33. package/examples/expressions.pln +1 -1
  34. package/examples/file-uploads.pln +1 -1
  35. package/examples/files-and-config.pln +1 -1
  36. package/examples/files.pln +1 -1
  37. package/examples/football-backend/app.pln +1 -1
  38. package/examples/functions.pln +1 -1
  39. package/examples/hello.pln +1 -1
  40. package/examples/http-client.pln +1 -1
  41. package/examples/http.pln +1 -1
  42. package/examples/id-verification/app.pln +1 -1
  43. package/examples/json.pln +1 -1
  44. package/examples/loops.pln +1 -1
  45. package/examples/modules/app.pln +1 -1
  46. package/examples/modules/main.pln +1 -1
  47. package/examples/modules/math.pln +1 -1
  48. package/examples/mongo.pln +33 -0
  49. package/examples/objects.pln +1 -1
  50. package/examples/ocr.pln +1 -1
  51. package/examples/packages.pln +1 -1
  52. package/examples/record-kinds.pln +1 -1
  53. package/examples/records.pln +1 -1
  54. package/examples/rest-api-fetch.pln +1 -1
  55. package/examples/rest-api.pln +1 -1
  56. package/examples/scheduled-tasks.pln +1 -1
  57. package/examples/search-and-filter.pln +1 -1
  58. package/examples/server.pln +1 -1
  59. package/examples/sessions-and-cookies.pln +1 -1
  60. package/examples/sqlite.pln +1 -1
  61. package/examples/start.pln +1 -1
  62. package/examples/stdlib.pln +1 -1
  63. package/examples/string-verbs.pln +16 -0
  64. package/examples/telegram-ai-bot.pln +1 -1
  65. package/examples/telegram-bot.pln +1 -1
  66. package/examples/testing.pln +1 -1
  67. package/examples/web-api.pln +1 -1
  68. package/examples/web-app.pln +1 -1
  69. package/examples/websocket-server.pln +1 -1
  70. package/examples/websocket.pln +1 -1
  71. package/examples/whatsapp-bot/pairing.pln +1 -1
  72. package/examples/whatsapp-bot/qr.pln +1 -1
  73. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: functions, defaults, and returns.
1
+ // PlainScript 1.0.3: functions, defaults, and returns.
2
2
 
3
3
  make greet(name)
4
4
  give `Hello, ${name}!`
@@ -1,2 +1,2 @@
1
- // PlainScript 1.0.3-beta: hello world.
1
+ // PlainScript 1.0.3: hello world.
2
2
  show "Hello, PlainScript!"
@@ -1,3 +1,3 @@
1
- // PlainScript 1.0.3-beta: HTTP client request.
1
+ // PlainScript 1.0.3: HTTP client request.
2
2
  remember response as get "https://example.com" timeout 5000
3
3
  show response.status
package/examples/http.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: HTTP client requests.
1
+ // PlainScript 1.0.3: HTTP client requests.
2
2
 
3
3
  remember response as get "https://example.com/api/items" timeout 5000
4
4
  if response.ok is true
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: upload and OCR verification service.
1
+ // PlainScript 1.0.3: upload and OCR verification service.
2
2
 
3
3
  web app
4
4
  accept uploads limit "5 MB" allow list with "image/png", "image/jpeg" folder "uploads"
package/examples/json.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: JSON values and transformations.
1
+ // PlainScript 1.0.3: JSON values and transformations.
2
2
 
3
3
  remember person as record with name "Ada" and role "engineer" done
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: collection and numeric loops.
1
+ // PlainScript 1.0.3: collection and numeric loops.
2
2
 
3
3
  remember colors as list with "red", "green", "blue"
4
4
 
@@ -1,3 +1,3 @@
1
- // PlainScript 1.0.3-beta: module entry point.
1
+ // PlainScript 1.0.3: module entry point.
2
2
  import { circleArea } from "./math.pln"
3
3
  show circleArea(2)
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: named imports.
1
+ // PlainScript 1.0.3: named imports.
2
2
 
3
3
  import { circleArea } from "./math.pln"
4
4
  show circleArea(2)
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: an imported module.
1
+ // PlainScript 1.0.3: an imported module.
2
2
 
3
3
  remember PI as 3.14159
4
4
 
@@ -0,0 +1,33 @@
1
+ // PlainScript 1.0.3: MongoDB.
2
+ //
3
+ // The `mongo` statement binds a connection to a MongoDB instance using the
4
+ // official `mongodb` driver. Give it a connection string and an optional
5
+ // database name:
6
+ //
7
+ // mongo "<connection-string>" [db "<name>"]
8
+ //
9
+ // After connecting, the `remember ... as query` and `insert`/`update`/`delete`
10
+ // blocks run against the bound database. MongoDB understands a light SQL-like
11
+ // subset here:
12
+ //
13
+ // - SELECT <fields|*> FROM <collection> (query)
14
+ // - INSERT INTO <collection> (a, b) VALUES (?, ?) (insert)
15
+ //
16
+ // Swap the connection string below for your own server to run this file.
17
+
18
+ mongo "mongodb://localhost:27017" db "testdb"
19
+
20
+ // Fetch every user document. The result of the query block is stored in the
21
+ // `users` variable so it can be inspected or returned later.
22
+ remember users as query
23
+ SELECT * FROM users
24
+ done
25
+ show users
26
+
27
+ // Insert a new user document from a PlainScript variable. Field names and the
28
+ // order they appear in VALUES must match the column list.
29
+ remember name as "Ada"
30
+ remember email as "ada@example.com"
31
+ insert
32
+ INSERT INTO users (name, email) VALUES ({name}, {email})
33
+ done
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: object literals and member access.
1
+ // PlainScript 1.0.3: object literals and member access.
2
2
  remember user as {name: "Ada", active: true}
3
3
  show user.name
4
4
  user.active becomes false
package/examples/ocr.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: upload handling and OCR.
1
+ // PlainScript 1.0.3: upload handling and OCR.
2
2
 
3
3
  web app
4
4
  accept uploads limit "5 MB" allow list with "image/png", "image/jpeg" folder "uploads"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: importing npm packages.
1
+ // PlainScript 1.0.3: importing npm packages.
2
2
 
3
3
  use express
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: record kind construction.
1
+ // PlainScript 1.0.3: record kind construction.
2
2
  define a kind called "Player" with
3
3
  name is ""
4
4
  goals is 0
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: record kinds and record values.
1
+ // PlainScript 1.0.3: record kinds and record values.
2
2
 
3
3
  define a kind called "Player" with
4
4
  name is ""
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: fetch an upstream API from a route.
1
+ // PlainScript 1.0.3: fetch an upstream API from a route.
2
2
  web app
3
3
  route get "/proxy"
4
4
  remember upstream as get "https://example.com/data" timeout 5000
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: JSON REST route.
1
+ // PlainScript 1.0.3: JSON REST route.
2
2
  web app
3
3
  route get "/api/status"
4
4
  reply json
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: recurring task.
1
+ // PlainScript 1.0.3: recurring task.
2
2
  schedule "0 * * * *"
3
3
  show "hourly task"
4
4
  done
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: collection filtering.
1
+ // PlainScript 1.0.3: collection filtering.
2
2
  remember values as list with 1, 2, 3
3
3
  remember found as first item from values
4
4
  show found
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: minimal server.
1
+ // PlainScript 1.0.3: minimal server.
2
2
  web app
3
3
  route get "/"
4
4
  reply "Hello from PlainScript"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: sessions and cookies.
1
+ // PlainScript 1.0.3: sessions and cookies.
2
2
  web app
3
3
  enable sessions "session-secret"
4
4
  route get "/"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: SQLite, SQL blocks, parameters, and transactions.
1
+ // PlainScript 1.0.3: SQLite, SQL blocks, parameters, and transactions.
2
2
 
3
3
  database "plain-script-demo.db" using "wasm"
4
4
  remember personName as "Ada"
@@ -1,2 +1,2 @@
1
- // PlainScript 1.0.3-beta: start command entry point.
1
+ // PlainScript 1.0.3: start command entry point.
2
2
  show "PlainScript started"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: standard library helpers.
1
+ // PlainScript 1.0.3: standard library helpers.
2
2
  remember text as trim(" PlainScript ")
3
3
  remember digest as sha256(text)
4
4
  show digest
@@ -0,0 +1,16 @@
1
+ // PlainScript 1.0.3: natural string verbs — transform a variable in place.
2
+
3
+ make capitalize(title)
4
+ lowercase title
5
+ split title by " "
6
+ uppercase first letter of each word in title
7
+ join title by " "
8
+ give title
9
+ done
10
+
11
+ remember headline as "hello world from plainscript"
12
+ show capitalize(headline)
13
+
14
+ remember label as " just a label "
15
+ trim label
16
+ show label
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: fixed and provider-backed Telegram replies.
1
+ // PlainScript 1.0.3: fixed and provider-backed Telegram replies.
2
2
 
3
3
  bot env("TELEGRAM_BOT_TOKEN")
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: Telegram bot.
1
+ // PlainScript 1.0.3: Telegram bot.
2
2
  bot env("TELEGRAM_BOT_TOKEN")
3
3
  when someone sends "/start"
4
4
  reply "Welcome"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: the native test DSL.
1
+ // PlainScript 1.0.3: the native test DSL.
2
2
 
3
3
  make add(a, b)
4
4
  give a + b
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: web apps, routes, JSON, and status codes.
1
+ // PlainScript 1.0.3: web apps, routes, JSON, and status codes.
2
2
 
3
3
  web app
4
4
  allow cors
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: web application.
1
+ // PlainScript 1.0.3: web application.
2
2
  web app
3
3
  route get "/health"
4
4
  reply json
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: WebSocket server.
1
+ // PlainScript 1.0.3: WebSocket server.
2
2
  websocket server on 8080
3
3
  when socket connects
4
4
  send socket "connected"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: WebSocket server handlers.
1
+ // PlainScript 1.0.3: WebSocket server handlers.
2
2
 
3
3
  websocket server on 8080
4
4
  when socket connects
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: WhatsApp pairing login.
1
+ // PlainScript 1.0.3: WhatsApp pairing login.
2
2
 
3
3
  whatsapp bot
4
4
  auth "plain-script-whatsapp"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.3-beta: WhatsApp QR login.
1
+ // PlainScript 1.0.3: WhatsApp QR login.
2
2
 
3
3
  whatsapp bot
4
4
  auth "plain-script-whatsapp"
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "plainscript-lang",
3
- "version": "1.0.3-beta",
3
+ "version": "1.0.3",
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/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/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"
11
11
  },
12
12
  "files": [
13
13
  "compiler",
@@ -42,6 +42,7 @@
42
42
  "ws": "^8.21.3"
43
43
  },
44
44
  "dependencies": {
45
+ "mongodb": "^7.6.0",
45
46
  "tesseract.js": "^7.0.0"
46
47
  }
47
48
  }