plainscript-lang 1.0.1 → 1.0.2-latest

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 (106) hide show
  1. package/README.md +194 -729
  2. package/compiler/bundler.js +2 -2
  3. package/compiler/cli.js +69 -73
  4. package/compiler/dependency-detector.js +5 -0
  5. package/compiler/formatter.js +1 -1
  6. package/compiler/generator.js +931 -89
  7. package/compiler/lexer.js +129 -53
  8. package/compiler/parser.js +995 -152
  9. package/compiler/version.js +1 -1
  10. package/docs/CAPABILITY_GAP_AUDIT.md +98 -435
  11. package/docs/PLAINSCRIPT-SPEC.md +335 -0
  12. package/docs/index.html +101 -608
  13. package/docs/website/script.js +59 -943
  14. package/docs/website/style.css +74 -656
  15. package/examples/ai-providers.pln +7 -0
  16. package/examples/arrays.pln +4 -0
  17. package/examples/async-errors.pln +18 -0
  18. package/examples/auth-api.pln +9 -0
  19. package/examples/auth-sessions.pln +32 -0
  20. package/examples/basics.pln +14 -0
  21. package/examples/bots.pln +13 -0
  22. package/examples/cache-and-jobs.pln +7 -0
  23. package/examples/cache-schedule.pln +22 -0
  24. package/examples/collections.pln +15 -0
  25. package/examples/concurrency.pln +18 -0
  26. package/examples/conditions.pln +22 -0
  27. package/examples/database.pln +8 -0
  28. package/examples/day2.pln +7 -0
  29. package/examples/day3.pln +5 -0
  30. package/examples/deployment.pln +6 -0
  31. package/examples/email-send.pln +3 -0
  32. package/examples/error-handling.pln +7 -0
  33. package/examples/expressions.pln +7 -0
  34. package/examples/file-uploads.pln +10 -0
  35. package/examples/files-and-config.pln +6 -0
  36. package/examples/files.pln +12 -0
  37. package/examples/football-backend/{app.ps → app.pln} +22 -21
  38. package/examples/functions.pln +17 -0
  39. package/examples/hello.pln +2 -0
  40. package/examples/http-client.pln +3 -0
  41. package/examples/http.pln +11 -0
  42. package/examples/id-verification/{app.ps → app.pln} +5 -4
  43. package/examples/id-verification/make-sample-id.js +29 -42
  44. package/examples/json.pln +11 -0
  45. package/examples/loops.pln +18 -0
  46. package/examples/modules/app.pln +3 -0
  47. package/examples/modules/main.pln +4 -0
  48. package/examples/modules/math.pln +9 -0
  49. package/examples/mongo.pln +33 -0
  50. package/examples/objects.pln +4 -0
  51. package/examples/ocr.pln +22 -0
  52. package/examples/packages.pln +6 -0
  53. package/examples/record-kinds.pln +7 -0
  54. package/examples/records.pln +15 -0
  55. package/examples/rest-api-fetch.pln +10 -0
  56. package/examples/rest-api.pln +8 -0
  57. package/examples/scheduled-tasks.pln +4 -0
  58. package/examples/search-and-filter.pln +4 -0
  59. package/examples/server.pln +6 -0
  60. package/examples/sessions-and-cookies.pln +8 -0
  61. package/examples/sqlite.pln +23 -0
  62. package/examples/start.pln +2 -0
  63. package/examples/stdlib.pln +4 -0
  64. package/examples/telegram-ai-bot.pln +19 -0
  65. package/examples/telegram-bot.pln +6 -0
  66. package/examples/testing.pln +13 -0
  67. package/examples/web-api.pln +27 -0
  68. package/examples/web-app.pln +8 -0
  69. package/examples/websocket-server.pln +6 -0
  70. package/examples/websocket.pln +13 -0
  71. package/examples/whatsapp-bot/{pairing.ps → pairing.pln} +4 -5
  72. package/examples/whatsapp-bot/qr.pln +12 -0
  73. package/package.json +3 -2
  74. package/docs/PLINJS_SPEC.md +0 -1151
  75. package/examples/arrays.ps +0 -13
  76. package/examples/auth-api.ps +0 -56
  77. package/examples/cache-and-jobs.ps +0 -29
  78. package/examples/concurrency.ps +0 -49
  79. package/examples/database.ps +0 -41
  80. package/examples/day2.ps +0 -7
  81. package/examples/day3.ps +0 -11
  82. package/examples/deployment.ps +0 -12
  83. package/examples/email-send.ps +0 -22
  84. package/examples/error-handling.ps +0 -54
  85. package/examples/expressions.ps +0 -40
  86. package/examples/file-uploads.ps +0 -39
  87. package/examples/files-and-config.ps +0 -47
  88. package/examples/hello.ps +0 -3
  89. package/examples/http-client.ps +0 -44
  90. package/examples/loops.ps +0 -17
  91. package/examples/modules/app.ps +0 -16
  92. package/examples/modules/math.ps +0 -20
  93. package/examples/objects.ps +0 -12
  94. package/examples/record-kinds.ps +0 -43
  95. package/examples/rest-api-fetch.ps +0 -94
  96. package/examples/rest-api.ps +0 -68
  97. package/examples/scheduled-tasks.ps +0 -23
  98. package/examples/search-and-filter.ps +0 -34
  99. package/examples/server.ps +0 -25
  100. package/examples/sessions-and-cookies.ps +0 -54
  101. package/examples/start.ps +0 -2
  102. package/examples/stdlib.ps +0 -41
  103. package/examples/telegram-bot.ps +0 -42
  104. package/examples/web-app.ps +0 -20
  105. package/examples/websocket-server.ps +0 -27
  106. package/examples/whatsapp-bot/qr.ps +0 -8
@@ -45,8 +45,8 @@ function resolveDependencies(entryPath) {
45
45
  }
46
46
 
47
47
  // Parse the file to discover its own imports.
48
- // Annotate any tokenise/parse error with the filename so callers see
49
- // "file.ps — Line N, Column N: …" rather than a bare positional message.
48
+ // Annotate any tokenise/parse error with the filename so callers see
49
+ // "file.pln — Line N, Column N: …" rather than a bare positional message.
50
50
  const source = fs.readFileSync(absPath, 'utf8');
51
51
  let tokens, ast;
52
52
  try {
package/compiler/cli.js CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env node
2
- // CLI: compile and run PlainScript (.ps) files.
2
+ // CLI: compile and run PlainScript (.pln) files.
3
3
  //
4
- // Usage:
5
- // plainscript run <file.ps> install missing dependencies, compile and execute
6
- // plainscript build [file.ps] compile src/ (or one file) to dist/, names preserved
7
- // plainscript check [target] fully validate source(s): imports + generate + JS syntax
8
- // (target: a .ps file, a directory, or none to scan the project)
9
- // plainscript fmt <file.ps> format a PlainScript file in-place
10
- // plainscript new [name] scaffold a new PlainScript project
11
- // plainscript install install dependencies detected in the project's sources
12
- // plainscript start build src/app.ps (or index.ps) and run its dist output
13
- // plainscript doctor check the PlainScript project environment
14
- // plainscript add <package> install a package into the project
15
- // plainscript remove <package> uninstall a package from the project
16
- // plainscript update update all installed packages
17
- // plainscript version print the compiler version
18
- // plainscript help print this help text
4
+ // Usage:
5
+ // plainscript run <file.pln> install missing dependencies, compile and execute
6
+ // plainscript build [file.pln] compile src/ (or one file) to dist/, names preserved
7
+ // plainscript check [target] fully validate source(s): imports + generate + JS syntax
8
+ // (target: a .pln file, a directory, or none to scan the project)
9
+ // plainscript fmt <file.pln> format a PlainScript file in-place
10
+ // plainscript new [name] scaffold a new PlainScript project
11
+ // plainscript install install dependencies detected in the project's sources
12
+ // plainscript start build src/app.pln (or index.pln) and run its dist output
13
+ // plainscript doctor check the PlainScript project environment
14
+ // plainscript add <package> install a package into the project
15
+ // plainscript remove <package> uninstall a package from the project
16
+ // plainscript update update all installed packages
17
+ // plainscript version print the compiler version
18
+ // plainscript help print this help text
19
19
 
20
20
  const fs = require('fs');
21
21
  const path = require('path');
@@ -51,20 +51,20 @@ function warn(message) {
51
51
  const section = (title) => `\n${clrCyan(clrBold(title))}`;
52
52
 
53
53
  const HELP = `
54
- ${clrBold(`PlainScript v${VERSION}`)} ${clrDim('· .ps compiles to readable Node.js')}
54
+ ${clrBold(`PlainScript v${VERSION}`)} ${clrDim('· .pln compiles to readable Node.js')}
55
55
 
56
56
  ${section('START')}
57
- plainscript new [name] Scaffold a new project with a working app.ps
58
- plainscript run <file.ps> Install missing deps, compile, execute
59
- plainscript start Build src/app.ps and run it from dist/
57
+ plainscript new [name] Scaffold a new project with a working app.pln
58
+ plainscript run <file.pln> Install missing deps, compile, execute
59
+ plainscript start Build src/app.pln and run it from dist/
60
60
 
61
61
  ${section('BUILD & CHECK')}
62
- plainscript build Compile every .ps under src/ into dist/
63
- plainscript build <file.ps> Compile one file into dist/ (name preserved)
62
+ plainscript build Compile every .pln under src/ into dist/
63
+ plainscript build <file.pln> Compile one file into dist/ (name preserved)
64
64
  plainscript check [target] Validate imports + generate + JS output (no writes)
65
- target: a .ps file, a directory, or none = project scan
65
+ target: a .pln file, a directory, or none = project scan
66
66
  --json emits deterministic machine-readable output
67
- plainscript fmt <file.ps> Format a file in place
67
+ plainscript fmt <file.pln> Format a file in place
68
68
 
69
69
  ${section('PACKAGES')}
70
70
  plainscript install Install everything your source needs
@@ -88,17 +88,17 @@ ${section('THE LANGUAGE IN EIGHT LINES')}
88
88
  try ... recover as err ... done retry 3 times every 5s errors
89
89
 
90
90
  ${section('ALSO SHIPPED')}
91
- Comparisons and stdlib (v1.0) · PlainScript Expressions (v1.1) ·
92
- JavaScript gateway with ask (v1.1.1) · OCR · Telegram bots ·
93
- WhatsApp bots (v2.1.1) ·
94
- email · schedules · WebSocket · cache (v2.1) ·
95
- sessions · uploads · cookies · rate limits · api keys · OAuth (v2.1.1)
91
+ Comparisons and stdlib · PlainScript Expressions ·
92
+ console input with ask · OCR · Telegram bots ·
93
+ WhatsApp bots ·
94
+ email · schedules · WebSocket · cache ·
95
+ sessions · uploads · cookies · rate limits · api keys · OAuth
96
96
  JSON body · redirect · AI chat/embeddings · vector similarity ·
97
- paginate · collection & string primitives (v2.2)
97
+ paginate · collection & string primitives
98
98
 
99
99
  ${section('FIRST RUN')}
100
100
  plainscript new hello scaffolds hello/ with a live web app
101
- plainscript run hello/app.ps serves it at http://localhost:3000
101
+ plainscript run hello/app.pln serves it at http://localhost:3000
102
102
  `.trim();
103
103
 
104
104
  // ── npm invocation ────────────────────────────────────────────────────────────
@@ -151,8 +151,8 @@ function isValidPackageName(name) {
151
151
  // "exclude": ["vendor"] } }
152
152
  //
153
153
  // Filenames and folder structure are always preserved:
154
- // src/messi.ps → dist/messi.js
155
- // src/helpers/math.ps → dist/helpers/math.js
154
+ // src/messi.pln → dist/messi.js
155
+ // src/helpers/math.pln → dist/helpers/math.js
156
156
  const SOURCE_DIR = 'src';
157
157
  const DEFAULT_OUT_DIR = 'dist';
158
158
 
@@ -185,7 +185,7 @@ function resolveOutDir(opts) {
185
185
  return DEFAULT_OUT_DIR;
186
186
  }
187
187
 
188
- // Every .ps file under srcDir, recursively, as paths relative to srcDir.
188
+ // Every .pln file under srcDir, recursively, as paths relative to srcDir.
189
189
  // Deterministic order (sorted); node_modules, hidden directories, the output
190
190
  // directory, and any user-specified exclude patterns are skipped.
191
191
  function discoverSources(srcDir, outDir, exclude) {
@@ -208,7 +208,7 @@ function discoverSources(srcDir, outDir, exclude) {
208
208
  try { stat = fs.statSync(full); } catch (_) { continue; }
209
209
  if (stat.isDirectory()) {
210
210
  walk(full);
211
- } else if (name.endsWith('.ps')) {
211
+ } else if (name.endsWith('.pln')) {
212
212
  found.push(path.relative(root, full));
213
213
  }
214
214
  }
@@ -405,7 +405,7 @@ function nodeModulesSearchPaths(entryDir) {
405
405
 
406
406
  async function cmdRun(filePath, extraArgs = []) {
407
407
  if (!filePath) {
408
- console.error('Usage: plainscript run <file.ps>');
408
+ console.error('Usage: plainscript run <file.pln>');
409
409
  process.exit(1);
410
410
  }
411
411
  const js = compile(filePath);
@@ -442,8 +442,8 @@ function buildOne(filePath, srcDir, outDir) {
442
442
  }
443
443
  const js = compile(absFile);
444
444
  const srcRoot = path.resolve(srcDir);
445
- let rel = path.relative(srcRoot, absFile).replace(/\.ps$/, '.js');
446
- if (rel.startsWith('..') || path.isAbsolute(rel)) rel = path.basename(absFile).replace(/\.ps$/, '.js');
445
+ let rel = path.relative(srcRoot, absFile).replace(/\.pln$/, '.js');
446
+ if (rel.startsWith('..') || path.isAbsolute(rel)) rel = path.basename(absFile).replace(/\.pln$/, '.js');
447
447
  const outPath = path.join(path.resolve(outDir), rel);
448
448
  fs.mkdirSync(path.dirname(outPath), { recursive: true });
449
449
  fs.writeFileSync(outPath, js, 'utf8');
@@ -453,16 +453,16 @@ function buildOne(filePath, srcDir, outDir) {
453
453
  // `plainscript build` — TypeScript-style production build:
454
454
  //
455
455
  // Zero config (default):
456
- // messi.ps → dist/messi.js (project-root sources)
457
- // src/index.ps → dist/index.js (src/ is the source root)
458
- // src/a/b.ps → dist/a/b.js (structure preserved)
456
+ // messi.pln → dist/messi.js (project-root sources)
457
+ // src/index.pln → dist/index.js (src/ is the source root)
458
+ // src/a/b.pln → dist/a/b.js (structure preserved)
459
459
  //
460
460
  // With plainscript.config.json:
461
461
  // { "compilerOptions": { "outDir": "./build", "rootDir": "./lib" } }
462
- // lib/app.ps → build/app.js
462
+ // lib/app.pln → build/app.js
463
463
  //
464
464
  // With an explicit file argument only that entry is compiled; without one,
465
- // every .ps under the discovered source root builds to the output directory.
465
+ // every .pln under the discovered source root builds to the output directory.
466
466
  async function cmdBuild(filePath) {
467
467
  const opts = readCompilerOptions();
468
468
  const srcDir = resolveSrcDir(opts);
@@ -475,7 +475,7 @@ async function cmdBuild(filePath) {
475
475
  }
476
476
  const sources = discoverSources(srcDir, outDir, exclude);
477
477
  if (sources.length === 0) {
478
- console.error(`No .ps files found under "${srcDir}".`);
478
+ console.error(`No .pln files found under "${srcDir}".`);
479
479
  process.exit(1);
480
480
  }
481
481
  QUIET_STAGES = true;
@@ -500,7 +500,7 @@ async function cmdStart(extraArgs = []) {
500
500
  const outDir = resolveOutDir(opts);
501
501
  const entryPath = findEntry(opts);
502
502
  if (!entryPath) {
503
- console.error('No entry file found. Expected "src/app.ps" or "src/index.ps".');
503
+ console.error('No entry file found. Expected "src/app.pln" or "src/index.pln".');
504
504
  process.exit(1);
505
505
  }
506
506
  const outFile = buildOne(entryPath, srcDir, outDir);
@@ -525,34 +525,30 @@ function cmdNew(projectName) {
525
525
  fs.mkdirSync(path.join(dir, 'public'));
526
526
  fs.mkdirSync(path.join(dir, 'src'));
527
527
 
528
- // src/app.ps — starter Express app
529
- fs.writeFileSync(path.join(dir, 'src', 'app.ps'), `use express
530
-
531
- remember app as express()
528
+ // src/app.pln — starter web app
529
+ fs.writeFileSync(path.join(dir, 'src', 'app.pln'), `web app
532
530
 
533
531
  serve folder "public"
534
532
 
535
- when someone visits "/"
533
+ route get "/"
536
534
  reply "Hello from PlainScript!"
537
535
  done
538
536
 
539
- when someone visits "/api/status"
537
+ route get "/api/status"
540
538
  reply json
541
539
  status is "ok"
542
- version is "1.0"
540
+ version is "1.0.2-latest"
543
541
  done
544
542
  done
545
543
 
546
- listen on 3000
547
- show "Server running at http://localhost:3000"
548
- done
544
+ start 3000
549
545
  `);
550
546
 
551
547
  // package.json — plain Node semantics; PlainScript itself is a devDependency and
552
548
  // deployment only needs the generated dist/ output.
553
549
  fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({
554
550
  name,
555
- version: '1.0.1',
551
+ version: VERSION,
556
552
  description: `A PlainScript v${VERSION} application`,
557
553
  main: 'dist/app.js',
558
554
  scripts: {
@@ -584,7 +580,7 @@ Then open http://localhost:3000 in your browser.
584
580
  `);
585
581
 
586
582
  console.log(`✓ Created project "${name}"`);
587
- console.log(`\nNext steps:\n cd ${name}\n npm install\n npx plainscript run src/app.ps`);
583
+ console.log(`\nNext steps:\n cd ${name}\n npm install\n npx plainscript run src/app.pln`);
588
584
  }
589
585
 
590
586
  // ── plainscript install ────────────────────────────────────────────────────────────
@@ -594,11 +590,11 @@ Then open http://localhost:3000 in your browser.
594
590
  function findEntry(opts) {
595
591
  const srcDir = resolveSrcDir(opts);
596
592
  const candidates = [
597
- path.join(srcDir, 'app.ps'),
598
- path.join(srcDir, 'index.ps'),
593
+ path.join(srcDir, 'app.pln'),
594
+ path.join(srcDir, 'index.pln'),
599
595
  ];
600
596
  if (srcDir !== '.') {
601
- candidates.push('app.ps', 'index.ps');
597
+ candidates.push('app.pln', 'index.pln');
602
598
  }
603
599
  return candidates.find((c) => fs.existsSync(path.resolve(c))) || null;
604
600
  }
@@ -613,7 +609,7 @@ function collectSourceAsts() {
613
609
  const exclude = opts && opts.exclude;
614
610
  const sources = discoverSources(srcDir, outDir, exclude);
615
611
  if (sources.length === 0) {
616
- console.error(`No .ps source files found under "${srcDir}".`);
612
+ console.error(`No .pln source files found under "${srcDir}".`);
617
613
  process.exit(1);
618
614
  }
619
615
  const root = path.resolve(srcDir);
@@ -669,14 +665,14 @@ function cmdDoctor() {
669
665
  check('Runtime', fs.existsSync(path.join(__dirname, 'generator.js')));
670
666
  console.log('');
671
667
 
672
- // Source discovery check: does the project have any .ps files?
668
+ // Source discovery check: does the project have any .pln files?
673
669
  const opts = readCompilerOptions();
674
670
  const srcDir = resolveSrcDir(opts);
675
671
  const outDir = resolveOutDir(opts);
676
672
  const exclude = opts && opts.exclude;
677
673
  const sources = discoverSources(srcDir, outDir, exclude);
678
674
  check('Source files', sources.length > 0,
679
- sources.length > 0 ? `"${srcDir}/" discovered (${sources.length} file(s))` : `no .ps files under "${srcDir}"`);
675
+ sources.length > 0 ? `"${srcDir}/" discovered (${sources.length} file(s))` : `no .pln files under "${srcDir}"`);
680
676
  if (sources.length === 0) return;
681
677
 
682
678
  // Dependency check: scan every source file for npm imports
@@ -751,7 +747,7 @@ function cmdUpdate() {
751
747
  }
752
748
 
753
749
  // Check syntax of a PlainScript file without generating JavaScript or executing.
754
- // Full validation of a single .ps entry: resolve imports, parse+generate every
750
+ // Full validation of a single .pln entry: resolve imports, parse+generate every
755
751
  // file in dependency order, and verify the emitted JavaScript is syntactically
756
752
  // valid — all without writing anything to disk. Returns a deterministic
757
753
  // result record; `deps` are the npm packages the sources require.
@@ -760,7 +756,7 @@ function validateSource(absPath) {
760
756
  const t0 = Date.now();
761
757
  try {
762
758
  // resolveDependencies parses each file too, so a parse error anywhere in
763
- // the import graph surfaces here with a "file.ps — Line:Col" prefix.
759
+ // the import graph surfaces here with a "file.pln — Line:Col" prefix.
764
760
  const files = resolveDependencies(absPath);
765
761
  const context = createGenerationContext();
766
762
  let js = files.map(({ ast }) => generate(ast, context)).filter(s => s.trim()).join('\n');
@@ -787,14 +783,14 @@ function validateSource(absPath) {
787
783
 
788
784
  // `plainscript check [target] [--json]`
789
785
  //
790
- // Fully validates one .ps file, every .ps under a directory, or (with no
786
+ // Fully validates one .pln file, every .pln under a directory, or (with no
791
787
  // target) the project sources, deterministically and non-interactively:
792
788
  // resolve imports, parse + generate, and confirm the JS output parses. Never
793
789
  // prompts, never writes files, never installs packages.
794
790
  //
795
- // plainscript check validate every .ps in the project source root
796
- // plainscript check app.ps validate one file (and its imports)
797
- // plainscript check src/ validate every .ps under a directory
791
+ // plainscript check validate every .pln in the project source root
792
+ // plainscript check app.pln validate one file (and its imports)
793
+ // plainscript check src/ validate every .pln under a directory
798
794
  // plainscript check --json machine-readable JSON on stdout
799
795
  function cmdCheck(target, json) {
800
796
  const opts = readCompilerOptions();
@@ -807,7 +803,7 @@ function cmdCheck(target, json) {
807
803
  const abs = path.resolve(target);
808
804
  if (fs.existsSync(abs) && fs.statSync(abs).isDirectory()) {
809
805
  sources = discoverSources(abs, outDir, exclude).map(r => path.join(abs, r));
810
- } else if (/\.ps$/.test(target) && !fs.existsSync(abs)) {
806
+ } else if (/\.pln$/.test(target) && !fs.existsSync(abs)) {
811
807
  if (json) {
812
808
  console.log(JSON.stringify({
813
809
  plainscript: VERSION, ok: false,
@@ -825,7 +821,7 @@ function cmdCheck(target, json) {
825
821
  const root = path.resolve(srcDir);
826
822
  sources = discoverSources(srcDir, outDir, exclude).map(r => path.join(root, r));
827
823
  if (sources.length === 0) {
828
- const msg = `No .ps files found under "${srcDir}".`;
824
+ const msg = `No .pln files found under "${srcDir}".`;
829
825
  if (json) console.log(JSON.stringify({ plainscript: VERSION, ok: false, sources: [], summary: { total: 0, passed: 0, failed: 1 }, errors: [{ file: srcDir, error: msg }] }));
830
826
  else console.error(msg);
831
827
  process.exit(1);
@@ -877,7 +873,7 @@ function cmdCheck(target, json) {
877
873
  // Format a PlainScript file in-place.
878
874
  function cmdFmt(filePath) {
879
875
  if (!filePath) {
880
- console.error('Usage: plainscript fmt <file.ps>');
876
+ console.error('Usage: plainscript fmt <file.pln>');
881
877
  process.exit(1);
882
878
  }
883
879
  const absPath = path.resolve(filePath);
@@ -937,7 +933,7 @@ async function main() {
937
933
  case 'help': cmdHelp(); break;
938
934
  default:
939
935
  // Backwards-compatible: treat the first arg as a file to run directly
940
- if (command && command.endsWith('.ps')) {
936
+ if (command && command.endsWith('.pln')) {
941
937
  await cmdRun(command);
942
938
  } else {
943
939
  console.error(`Unknown command: "${command}". Run "plainscript help" for usage.`);
@@ -33,6 +33,8 @@ const PACKAGE_MAP = Object.freeze({
33
33
  // through qrcode-terminal. Neither package ever appears in PlainScript source.
34
34
  whatsapp: '@whiskeysockets/baileys',
35
35
  'wa-qrcode': 'qrcode-terminal',
36
+ // v2.2.0 — MongoDB driver.
37
+ mongodb: 'mongodb',
36
38
  });
37
39
 
38
40
  const BUILTIN_MODULES = new Set(builtinModules);
@@ -87,6 +89,9 @@ function visit(node, onUse) {
87
89
  } else if (node.type === 'PostgresStatement') {
88
90
  // v2.1.0 — `postgres "<url>"` uses node-postgres under the hood.
89
91
  onUse('postgres');
92
+ } else if (node.type === 'MongoStatement') {
93
+ // v2.2.0 — `mongo "<uri>"` uses mongodb driver under the hood.
94
+ onUse('mongodb');
90
95
  } else if (node.type === 'OcrStatement') {
91
96
  // v2.0.1 — `ocr "<image>" as <variable>` uses tesseract.js under the hood.
92
97
  onUse('ocr');
@@ -17,7 +17,7 @@ const INDENT_STARTERS = [
17
17
  /^make\s+\S+\s*\(/, // make name(...)
18
18
  /^if\s+/, // if ...
19
19
  /^otherwise\b/, // otherwise
20
- /^for\s+(each|every)\s+/, // for each ... / for every ...
20
+ /^for\s+each\s+/, // for each ...
21
21
  /^while\s+/, // while ...
22
22
  /^when\s+someone\s+visits/, // when someone visits ...
23
23
  /^when\s+someone\s+(sends|clicks)\b/, // when someone sends / clicks (Telegram)