plainscript-lang 1.0.35 → 1.0.361

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 (92) hide show
  1. package/README.md +1052 -201
  2. package/compiler/bundler.js +4 -4
  3. package/compiler/cli.js +82 -18
  4. package/compiler/dependency-detector.js +34 -22
  5. package/compiler/generator.js +587 -172
  6. package/compiler/lexer.js +61 -39
  7. package/compiler/parser.js +685 -182
  8. package/compiler/sourcemap.js +1 -1
  9. package/compiler/version.js +1 -1
  10. package/docs/CAPABILITY_GAP_AUDIT.md +25 -4
  11. package/docs/FB-PROMPT.md +524 -0
  12. package/docs/GAME-PROMPT.md +916 -0
  13. package/docs/PLAINSCRIPT-SPEC.md +135 -5
  14. package/docs/index.html +28 -14
  15. package/docs/website/script.js +1 -1
  16. package/docs/website/style.css +162 -195
  17. package/examples/ai-providers.pln +1 -1
  18. package/examples/arrays.pln +1 -1
  19. package/examples/async-errors.pln +2 -1
  20. package/examples/auth-api.pln +1 -1
  21. package/examples/auth-sessions.pln +1 -1
  22. package/examples/basics.pln +1 -1
  23. package/examples/bots.pln +1 -1
  24. package/examples/browser-interactive/README.md +29 -0
  25. package/examples/browser-interactive/public/index.html +83 -0
  26. package/examples/browser-interactive/public/interactive.js +27 -0
  27. package/examples/browser-interactive/src/interactive.pln +34 -0
  28. package/examples/cache-and-jobs.pln +1 -1
  29. package/examples/cache-schedule.pln +1 -1
  30. package/examples/canvas-game/README.md +34 -0
  31. package/examples/canvas-game/public/game.js +131 -0
  32. package/examples/canvas-game/public/index.html +48 -0
  33. package/examples/canvas-game/src/game.pln +139 -0
  34. package/examples/collections.pln +1 -1
  35. package/examples/concurrency.pln +1 -1
  36. package/examples/conditions.pln +1 -1
  37. package/examples/database.pln +1 -1
  38. package/examples/day2.pln +1 -1
  39. package/examples/day3.pln +1 -1
  40. package/examples/deployment.pln +1 -1
  41. package/examples/email-send.pln +1 -1
  42. package/examples/error-handling.pln +3 -2
  43. package/examples/expressions.pln +1 -1
  44. package/examples/file-uploads.pln +1 -1
  45. package/examples/files-and-config.pln +1 -1
  46. package/examples/files.pln +1 -1
  47. package/examples/football-backend/app.pln +1 -1
  48. package/examples/functions.pln +1 -1
  49. package/examples/hello.pln +1 -1
  50. package/examples/http-client.pln +1 -1
  51. package/examples/http.pln +1 -1
  52. package/examples/id-verification/app.pln +1 -1
  53. package/examples/javascript-library/README.md +54 -0
  54. package/examples/javascript-library/package-lock.json +21 -0
  55. package/examples/javascript-library/package.json +8 -0
  56. package/examples/javascript-library/public/config.json +4 -0
  57. package/examples/javascript-library/public/index.html +40 -0
  58. package/examples/javascript-library/src/interop.pln +53 -0
  59. package/examples/json.pln +1 -1
  60. package/examples/loops.pln +1 -1
  61. package/examples/modules/app.pln +1 -1
  62. package/examples/modules/main.pln +1 -1
  63. package/examples/modules/math.pln +1 -1
  64. package/examples/mongo.pln +1 -1
  65. package/examples/objects.pln +1 -1
  66. package/examples/ocr.pln +1 -1
  67. package/examples/packages.pln +1 -1
  68. package/examples/record-kinds.pln +1 -1
  69. package/examples/records.pln +1 -1
  70. package/examples/rest-api-fetch.pln +1 -1
  71. package/examples/rest-api.pln +1 -1
  72. package/examples/scheduled-tasks.pln +1 -1
  73. package/examples/search-and-filter.pln +1 -1
  74. package/examples/server.pln +1 -1
  75. package/examples/sessions-and-cookies.pln +1 -1
  76. package/examples/sqlite.pln +1 -1
  77. package/examples/start.pln +1 -1
  78. package/examples/stdlib.pln +1 -1
  79. package/examples/string-verbs.pln +1 -1
  80. package/examples/telegram-ai-bot.pln +1 -1
  81. package/examples/telegram-bot.pln +1 -1
  82. package/examples/testing.pln +1 -1
  83. package/examples/three-dimensional/README.md +51 -0
  84. package/examples/three-dimensional/public/index.html +33 -0
  85. package/examples/three-dimensional/src/scene.pln +34 -0
  86. package/examples/web-api.pln +1 -1
  87. package/examples/web-app.pln +1 -1
  88. package/examples/websocket-server.pln +1 -1
  89. package/examples/websocket.pln +1 -1
  90. package/examples/whatsapp-bot/pairing.pln +2 -2
  91. package/examples/whatsapp-bot/qr.pln +2 -2
  92. package/package.json +9 -10
@@ -67,7 +67,7 @@ function resolveDependencies(entryPath) {
67
67
  const order = []; // final compile order
68
68
 
69
69
  function visit(absPath, stack) {
70
- // Already fully processed — skip (handles duplicate imports)
70
+ // Already fully processed - skip (handles duplicate imports)
71
71
  if (visited.has(absPath)) return;
72
72
 
73
73
  // File is in the current DFS stack → circular dependency
@@ -90,7 +90,7 @@ function resolveDependencies(entryPath) {
90
90
 
91
91
  // Parse the file to discover its own imports.
92
92
  // Annotate any tokenise/parse error with the filename so callers see
93
- // "file.pln — Line N, Column N: …" rather than a bare positional message.
93
+ // "file.pln - Line N, Column N: …" rather than a bare positional message.
94
94
  const source = fs.readFileSync(absPath, 'utf8');
95
95
  let tokens, ast;
96
96
  try {
@@ -98,7 +98,7 @@ function resolveDependencies(entryPath) {
98
98
  ast = parse(tokens);
99
99
  } catch (err) {
100
100
  const relPath = path.relative(process.cwd(), absPath) || path.basename(absPath);
101
- throw new Error(`${relPath} — ${err.message}`);
101
+ throw new Error(`${relPath} - ${err.message}`);
102
102
  }
103
103
 
104
104
  // Recurse into each import before processing this file (DFS)
@@ -109,7 +109,7 @@ function resolveDependencies(entryPath) {
109
109
  visit(resolvedAbs, newStack);
110
110
  }
111
111
 
112
- // All dependencies are done — add this file to the order
112
+ // All dependencies are done - add this file to the order
113
113
  visited.add(absPath);
114
114
  order.push({ absPath, ast });
115
115
  }
package/compiler/cli.js CHANGED
@@ -4,6 +4,7 @@
4
4
  // Usage:
5
5
  // plainscript run <file.pln> install missing dependencies, compile and execute
6
6
  // plainscript build [file.pln] compile src/ (or one file) to dist/, names preserved
7
+ // plainscript build <file.pln> -o <out.js> compile one file to a chosen output path
7
8
  // plainscript check [target] fully validate source(s): imports + generate + JS syntax
8
9
  // (target: a .pln file, a directory, or none to scan the project)
9
10
  // plainscript fmt <file.pln> format a PlainScript file in-place
@@ -61,6 +62,8 @@ ${section('START')}
61
62
  ${section('BUILD & CHECK')}
62
63
  plainscript build Compile every .pln under src/ into dist/
63
64
  plainscript build <file.pln> Compile one file into dist/ (name preserved)
65
+ plainscript build <file.pln> -o <out.js> Compile one file to an explicit path
66
+
64
67
  plainscript check [target] Validate imports + generate + JS output (no writes)
65
68
  target: a .pln file, a directory, or none = project scan
66
69
  --json emits deterministic machine-readable output
@@ -284,7 +287,7 @@ function ensurePackageJson(cwd = process.cwd()) {
284
287
  }, null, 2) + '\n', 'utf8');
285
288
  }
286
289
 
287
- // v2.1.1 — verify that a freshly installed package actually LOADS on this
290
+ // v2.1.1 - verify that a freshly installed package actually LOADS on this
288
291
  // machine. "better-sqlite3 present in node_modules" does not imply usable:
289
292
  // its native binding may be missing for this platform or Node ABI (the
290
293
  // Termux failure mode). The check runs in a child process so a hard crash
@@ -318,7 +321,7 @@ function installPackages(packages, cwd = process.cwd()) {
318
321
  stdio: 'ignore',
319
322
  });
320
323
  dependencyCache.set(`${cwd}\0${bareName}`, true);
321
- // v2.1.1 — "downloaded" and "usable" are different facts. Report both.
324
+ // v2.1.1 - "downloaded" and "usable" are different facts. Report both.
322
325
  if (verifyPackageUsable(bareName, cwd)) {
323
326
  console.log(`${clrGreen('✓')} ${pkg} installed`);
324
327
  } else {
@@ -329,7 +332,7 @@ function installPackages(packages, cwd = process.cwd()) {
329
332
  );
330
333
  }
331
334
  } catch (_) {
332
- // v2.1.1 — better-sqlite3 is optional at install time: programs opened
335
+ // v2.1.1 - better-sqlite3 is optional at install time: programs opened
333
336
  // through the portable engine chain fall back to sql.js, so a native
334
337
  // build failure must not abort setup.
335
338
  if (bareName === 'better-sqlite3') {
@@ -363,7 +366,7 @@ function ensureDependencies(files, install = true) {
363
366
  //
364
367
  // Deterministic only: the lexer/parser/generator pipeline is the single
365
368
  // authoritative compiler. Unsupported syntax produces a precise compiler
366
- // error — there is no second compilation path (v2.1.1).
369
+ // error - there is no second compilation path (v2.1.1).
367
370
  function compile(filePath, options = {}) {
368
371
  const absPath = path.resolve(filePath);
369
372
  if (!fs.existsSync(absPath)) {
@@ -418,7 +421,7 @@ function compile(filePath, options = {}) {
418
421
  // file in the OS temp dir could never see the project's node_modules. Passing
419
422
  // every node_modules directory between the entry file and the filesystem root
420
423
  // through NODE_PATH gives the child the exact same resolution the old
421
- // project-local temp file had — without ever writing into the project.
424
+ // project-local temp file had - without ever writing into the project.
422
425
  function nodeModulesSearchPaths(entryDir) {
423
426
  const paths = [];
424
427
  let dir = path.resolve(entryDir);
@@ -501,7 +504,39 @@ function buildOne(filePath, srcDir, outDir, options = {}) {
501
504
  return path.relative(process.cwd(), outPath) || outPath;
502
505
  }
503
506
 
504
- // `plainscript build` — TypeScript-style production build:
507
+ // `plainscript build <file.pln> -o <out.js>` - compile one entry to an explicit
508
+ // output path (same compilation pipeline as buildOne, including source maps
509
+ // when requested). Valuable for browser payloads such as the v1.0.361
510
+ // requestAnimationFrame / addEventListener helpers, which are meant to run as
511
+ // a single script tag.
512
+ function writeOneFile(filePath, outputFile) {
513
+ const absFile = path.resolve(filePath);
514
+ if (!fs.existsSync(absFile)) {
515
+ console.error(`File not found: ${filePath}`);
516
+ process.exit(1);
517
+ }
518
+ const outPath = path.resolve(outputFile);
519
+
520
+ const isSourcemap = process.argv.includes('--sourcemap') || process.argv.includes('-m') || process.env.PLAINSCRIPT_SOURCEMAP === 'true';
521
+
522
+ let code, mapObject;
523
+ if (isSourcemap) {
524
+ const res = compile(absFile, { sourceMap: true, outputFile: path.basename(outPath) });
525
+ code = res.code + `\n//# sourceMappingURL=${path.basename(outPath)}.map\n`;
526
+ mapObject = res.mapObject;
527
+ } else {
528
+ code = compile(absFile);
529
+ }
530
+
531
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
532
+ fs.writeFileSync(outPath, code, 'utf8');
533
+ if (mapObject) {
534
+ fs.writeFileSync(outPath + '.map', JSON.stringify(mapObject, null, 2), 'utf8');
535
+ }
536
+ return path.relative(process.cwd(), outPath) || outPath;
537
+ }
538
+
539
+ // `plainscript build` - TypeScript-style production build:
505
540
  //
506
541
  // Zero config (default):
507
542
  // messi.pln → dist/messi.js (project-root sources)
@@ -514,16 +549,24 @@ function buildOne(filePath, srcDir, outDir, options = {}) {
514
549
  //
515
550
  // With an explicit file argument only that entry is compiled; without one,
516
551
  // every .pln under the discovered source root builds to the output directory.
517
- async function cmdBuild(filePath) {
552
+ // The optional -o/--output <path> flag (single-file builds only) redirects the
553
+ // output to an explicit file instead of the dist layout.
554
+ async function cmdBuild(filePath, outputPath) {
518
555
  const opts = readCompilerOptions();
519
556
  const srcDir = resolveSrcDir(opts);
520
557
  const outDir = resolveOutDir(opts);
521
558
  const exclude = opts && opts.exclude;
522
559
  if (filePath) {
523
- const outPath = buildOne(filePath, srcDir, outDir);
560
+ const outPath = outputPath
561
+ ? writeOneFile(filePath, outputPath)
562
+ : buildOne(filePath, srcDir, outDir);
524
563
  console.log(`\nOutput written to ${outPath}`);
525
564
  return;
526
565
  }
566
+ if (outputPath) {
567
+ console.error('Usage: plainscript build <file.pln> -o <output.js>\n\n-o/--output needs a single .pln file to compile.');
568
+ process.exit(1);
569
+ }
527
570
  const sources = discoverSources(srcDir, outDir, exclude);
528
571
  if (sources.length === 0) {
529
572
  console.error(`No .pln files found under "${srcDir}".`);
@@ -576,7 +619,7 @@ function cmdNew(projectName) {
576
619
  fs.mkdirSync(path.join(dir, 'public'));
577
620
  fs.mkdirSync(path.join(dir, 'src'));
578
621
 
579
- // src/app.pln — starter web app
622
+ // src/app.pln - starter web app
580
623
  fs.writeFileSync(path.join(dir, 'src', 'app.pln'), `web app
581
624
 
582
625
  serve folder "public"
@@ -588,14 +631,14 @@ done
588
631
  route get "/api/status"
589
632
  reply json
590
633
  status is "ok"
591
- version is "1.0.35"
634
+ version is "1.0.361"
592
635
  done
593
636
  done
594
637
 
595
638
  start 3000
596
639
  `);
597
640
 
598
- // package.json — plain Node semantics; PlainScript itself is a devDependency and
641
+ // package.json - plain Node semantics; PlainScript itself is a devDependency and
599
642
  // deployment only needs the generated dist/ output.
600
643
  fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({
601
644
  name,
@@ -703,7 +746,7 @@ function cmdInstall() {
703
746
  function cmdDoctor() {
704
747
  console.log('PlainScript doctor\n');
705
748
  const check = (label, ok, detail = '') => {
706
- const suffix = detail ? ` — ${detail}` : '';
749
+ const suffix = detail ? ` - ${detail}` : '';
707
750
  console.log(`${ok ? clrGreen('✓') : clrRed('✗')} ${label}${suffix}`);
708
751
  };
709
752
  check('Node.js', Boolean(process.version));
@@ -800,14 +843,14 @@ function cmdUpdate() {
800
843
  // Check syntax of a PlainScript file without generating JavaScript or executing.
801
844
  // Full validation of a single .pln entry: resolve imports, parse+generate every
802
845
  // file in dependency order, and verify the emitted JavaScript is syntactically
803
- // valid — all without writing anything to disk. Returns a deterministic
846
+ // valid - all without writing anything to disk. Returns a deterministic
804
847
  // result record; `deps` are the npm packages the sources require.
805
848
  function validateSource(absPath) {
806
849
  const rel = path.relative(process.cwd(), absPath) || absPath;
807
850
  const t0 = Date.now();
808
851
  try {
809
852
  // resolveDependencies parses each file too, so a parse error anywhere in
810
- // the import graph surfaces here with a "file.pln — Line:Col" prefix.
853
+ // the import graph surfaces here with a "file.pln - Line:Col" prefix.
811
854
  const files = resolveDependencies(absPath);
812
855
  const context = createGenerationContext();
813
856
  let js = files.map(({ ast }) => generate(ast, context)).filter(s => s.trim()).join('\n');
@@ -905,7 +948,7 @@ function cmdCheck(target, json) {
905
948
 
906
949
  for (const r of results) {
907
950
  if (r.ok) {
908
- console.log(`${clrGreen('✓')} ${r.file} — ok${clrDim(` (${r.ms}ms)`)}`);
951
+ console.log(`${clrGreen('✓')} ${r.file} - ok${clrDim(` (${r.ms}ms)`)}`);
909
952
  } else {
910
953
  console.log(`${clrRed('✗')} ${r.file}`);
911
954
  console.error(r.error);
@@ -935,7 +978,7 @@ function cmdFmt(filePath) {
935
978
  const source = fs.readFileSync(absPath, 'utf8');
936
979
  const formatted = format(source);
937
980
  if (source === formatted) {
938
- console.log(`${clrDim('–')} ${filePath} — already formatted.`);
981
+ console.log(`${clrDim('–')} ${filePath} - already formatted.`);
939
982
  } else {
940
983
  fs.writeFileSync(absPath, formatted, 'utf8');
941
984
  console.log(`${clrGreen('✓')} Formatted ${filePath}`);
@@ -955,7 +998,7 @@ function cmdHelp() {
955
998
  async function main() {
956
999
  const args = process.argv.slice(2);
957
1000
 
958
- // Global flags — recognized anywhere in the argument list.
1001
+ // Global flags - recognized anywhere in the argument list.
959
1002
  const quiet = args.includes('--quiet');
960
1003
  const verbose = args.includes('--verbose');
961
1004
  const json = args.includes('--json');
@@ -970,7 +1013,28 @@ async function main() {
970
1013
 
971
1014
  switch (command) {
972
1015
  case 'run': await cmdRun(fileArg, positional.slice(2)); break;
973
- case 'build': await cmdBuild(fileArg); break;
1016
+ case 'build': {
1017
+ // v1.0.361 - optional -o/--output <path>. "-o" is a single-dash flag, so
1018
+ // it survives the "--filtered" positional list; pull it out here before
1019
+ // building the positional file argument for cmdBuild.
1020
+ let outputPath = null;
1021
+ const positionalOnly = [];
1022
+ for (let i = 0; i < args.length; i++) {
1023
+ const a = args[i];
1024
+ if (a === '-o' || a === '--output') {
1025
+ if (i + 1 < args.length && !args[i + 1].startsWith('-')) {
1026
+ outputPath = args[++i];
1027
+ } else {
1028
+ console.error('Usage: plainscript build <file.pln> -o <output.js>');
1029
+ process.exit(1);
1030
+ }
1031
+ } else if (!a.startsWith('-')) {
1032
+ positionalOnly.push(a);
1033
+ }
1034
+ }
1035
+ await cmdBuild(positionalOnly[1] || '', outputPath);
1036
+ break;
1037
+ }
974
1038
  case 'check': cmdCheck(fileArg, json); break;
975
1039
  case 'fmt': cmdFmt(fileArg); break;
976
1040
  case 'new': cmdNew(fileArg); break;
@@ -14,28 +14,29 @@ const PACKAGE_MAP = Object.freeze({
14
14
  sqlite: 'better-sqlite3',
15
15
  fs: 'fs',
16
16
  path: 'path',
17
- // v2.0.1 — OCR statements are backed by tesseract.js. The mapping keeps the
17
+ // v2.0.1 - OCR statements are backed by tesseract.js. The mapping keeps the
18
18
  // implementation dependency out of PlainScript's language surface: source says
19
19
  // `ocr ... as text`, tooling installs tesseract.js.
20
20
  ocr: 'tesseract.js',
21
- // v2.1.0 — PostgreSQL behind the friendly "postgres" name.
21
+ // v2.1.0 - PostgreSQL behind the friendly "postgres" name.
22
22
  postgres: 'pg',
23
- // v2.1.0 — backend integrations keep implementation packages out of source.
23
+ // v2.1.0 - backend integrations keep implementation packages out of source.
24
24
  mailer: 'nodemailer',
25
25
  scheduler: 'croner',
26
26
  websocket: 'ws',
27
27
  cache: 'redis',
28
- // v2.1.1 — "accept uploads" is backed by multer; the WebAssembly SQLite
28
+ // v2.1.1 - "accept uploads" is backed by multer; the WebAssembly SQLite
29
29
  // engine used by the `database` statement's fallback chain is sql.js.
30
30
  uploads: 'multer',
31
31
  'wasm-sqlite': 'sql.js',
32
- // v2.1.1 — WhatsApp bots run on Baileys; QR codes render in the terminal
33
- // through qrcode-terminal. Neither package ever appears in PlainScript source.
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',
32
+ // v2.1.1 - WhatsApp bots run on Baileys; QR codes render in the terminal
33
+ // through qrcode-terminal. These are optional application dependencies, not
34
+ // compiler dependencies. Pin the default adapter so `plainscript install`
35
+ // remains reproducible; users can override it per-block with
36
+ // `use baileys "<pkg>"`.
37
+ whatsapp: '@whiskeysockets/baileys@6.7.24',
37
38
  'wa-qrcode': 'qrcode-terminal',
38
- // v2.2.0 — MongoDB driver.
39
+ // v2.2.0 - MongoDB driver.
39
40
  mongodb: 'mongodb',
40
41
  });
41
42
 
@@ -45,7 +46,7 @@ function isBuiltinModule(name) {
45
46
  return BUILTIN_MODULES.has(name) || BUILTIN_MODULES.has(`node:${name}`);
46
47
  }
47
48
 
48
- // v2.0.1 — split an npm specifier into its package name and version range.
49
+ // v2.0.1 - split an npm specifier into its package name and version range.
49
50
  //
50
51
  // "express" → { name: "express", spec: null }
51
52
  // "left-pad@^1.3" → { name: "left-pad", spec: "^1.3" }
@@ -60,6 +61,13 @@ function splitPackageSpec(specifier) {
60
61
  return { name: specifier.slice(0, at), spec: specifier.slice(at + 1) };
61
62
  }
62
63
 
64
+ function isLocalPackageSpecifier(specifier) {
65
+ return specifier.startsWith('.') ||
66
+ specifier.startsWith('/') ||
67
+ specifier.startsWith('\\') ||
68
+ specifier.startsWith('file:');
69
+ }
70
+
63
71
  function visit(node, onUse) {
64
72
  if (!node || typeof node !== 'object') return;
65
73
 
@@ -80,7 +88,7 @@ function visit(node, onUse) {
80
88
  // The `web app` shorthand creates an Express application.
81
89
  onUse('express');
82
90
  } else if (node.type === 'DatabaseStatement') {
83
- // v2.1.1 — `database` runs SQLite through a portable engine chain:
91
+ // v2.1.1 - `database` runs SQLite through a portable engine chain:
84
92
  // better-sqlite3 (native) first, sql.js (WebAssembly) as the fallback.
85
93
  // "using" picks one engine explicitly.
86
94
  if (node.driver === 'wasm') {
@@ -92,31 +100,31 @@ function visit(node, onUse) {
92
100
  onUse('wasm-sqlite');
93
101
  }
94
102
  } else if (node.type === 'AcceptUploadsStatement') {
95
- // v2.1.1 — `accept uploads` is backed by multer under the hood.
103
+ // v2.1.1 - `accept uploads` is backed by multer under the hood.
96
104
  onUse('uploads');
97
105
  } else if (node.type === 'PostgresStatement') {
98
- // v2.1.0 — `postgres "<url>"` uses node-postgres under the hood.
106
+ // v2.1.0 - `postgres "<url>"` uses node-postgres under the hood.
99
107
  onUse('postgres');
100
108
  } else if (node.type === 'MongoStatement') {
101
- // v2.2.0 — `mongo "<uri>"` uses mongodb driver under the hood.
109
+ // v2.2.0 - `mongo "<uri>"` uses mongodb driver under the hood.
102
110
  onUse('mongodb');
103
111
  } else if (node.type === 'OcrStatement') {
104
- // v2.0.1 — `ocr "<image>" as <variable>` uses tesseract.js under the hood.
112
+ // v2.0.1 - `ocr "<image>" as <variable>` uses tesseract.js under the hood.
105
113
  onUse('ocr');
106
114
  } else if (node.type === 'MailTransportStatement' || node.type === 'SendMailStatement') {
107
- // v2.1.0 — email statements use nodemailer under the hood.
115
+ // v2.1.0 - email statements use nodemailer under the hood.
108
116
  onUse('mailer');
109
117
  } else if (node.type === 'ScheduleStatement') {
110
- // v2.1.0 — cron schedules use croner under the hood.
118
+ // v2.1.0 - cron schedules use croner under the hood.
111
119
  onUse('scheduler');
112
120
  } else if (node.type === 'WebSocketServerStatement') {
113
- // v2.1.0 — websocket servers use ws under the hood.
121
+ // v2.1.0 - websocket servers use ws under the hood.
114
122
  onUse('websocket');
115
123
  } else if (node.type === 'CacheStatement') {
116
- // v2.1.0 — cache statements use the redis client under the hood.
124
+ // v2.1.0 - cache statements use the redis client under the hood.
117
125
  onUse('cache');
118
126
  } else if (node.type === 'WhatsAppBotStatement') {
119
- // v2.1.1 — WhatsApp bots run on Baileys and render QR codes with
127
+ // v2.1.1 - WhatsApp bots run on Baileys and render QR codes with
120
128
  // qrcode-terminal; both are implementation packages, never source.
121
129
  // The user may override the Baileys package per-block with
122
130
  // `use baileys "<pkg>"`; otherwise the default is used.
@@ -151,7 +159,10 @@ function detectDependencies(source) {
151
159
  // so `use sqlite@7` still maps to better-sqlite3@7.
152
160
  const { name, spec } = splitPackageSpec(moduleName);
153
161
  const packageName = PACKAGE_MAP[name] || name;
154
- if (!isBuiltinModule(packageName)) {
162
+ // A local adapter is installed by the application author, not npm's
163
+ // dependency detector. This also permits a project-local Baileys fork when
164
+ // the default package is unavailable behind a package firewall.
165
+ if (!isLocalPackageSpecifier(packageName) && !isBuiltinModule(packageName)) {
155
166
  dependencies.add(spec ? `${packageName}@${spec}` : packageName);
156
167
  }
157
168
  };
@@ -184,5 +195,6 @@ module.exports = {
184
195
  detectDependencies,
185
196
  isBuiltinModule,
186
197
  splitPackageSpec,
198
+ isLocalPackageSpecifier,
187
199
  PACKAGE_MAP,
188
200
  };