rapydscript-ns 0.9.2 → 0.9.4

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 (88) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/PYTHON_GAPS.md +352 -0
  3. package/README.md +176 -32
  4. package/TODO.md +1 -128
  5. package/bin/rapydscript +70 -70
  6. package/language-service/index.js +242 -11
  7. package/memory/project_string_impl.md +43 -0
  8. package/package.json +1 -1
  9. package/release/baselib-plain-pretty.js +248 -38
  10. package/release/baselib-plain-ugly.js +8 -8
  11. package/release/compiler.js +778 -277
  12. package/release/signatures.json +30 -30
  13. package/src/ast.pyj +10 -1
  14. package/src/baselib-builtins.pyj +56 -2
  15. package/src/baselib-containers.pyj +25 -1
  16. package/src/baselib-errors.pyj +7 -3
  17. package/src/baselib-internal.pyj +51 -6
  18. package/src/baselib-str.pyj +18 -5
  19. package/src/lib/asyncio.pyj +534 -0
  20. package/src/lib/base64.pyj +399 -0
  21. package/src/lib/bisect.pyj +73 -0
  22. package/src/lib/collections.pyj +228 -4
  23. package/src/lib/csv.pyj +494 -0
  24. package/src/lib/heapq.pyj +98 -0
  25. package/src/lib/html.pyj +382 -0
  26. package/src/lib/http/__init__.pyj +98 -0
  27. package/src/lib/http/client.pyj +304 -0
  28. package/src/lib/http/cookies.pyj +236 -0
  29. package/src/lib/logging.pyj +672 -0
  30. package/src/lib/pprint.pyj +455 -0
  31. package/src/lib/pythonize.pyj +20 -20
  32. package/src/lib/statistics.pyj +0 -0
  33. package/src/lib/string.pyj +357 -0
  34. package/src/lib/textwrap.pyj +329 -0
  35. package/src/lib/urllib/__init__.pyj +14 -0
  36. package/src/lib/urllib/error.pyj +66 -0
  37. package/src/lib/urllib/parse.pyj +475 -0
  38. package/src/lib/urllib/request.pyj +86 -0
  39. package/src/monaco-language-service/analyzer.js +5 -2
  40. package/src/monaco-language-service/completions.js +26 -0
  41. package/src/monaco-language-service/diagnostics.js +203 -4
  42. package/src/monaco-language-service/scope.js +1 -0
  43. package/src/output/codegen.pyj +4 -1
  44. package/src/output/functions.pyj +152 -6
  45. package/src/output/loops.pyj +17 -2
  46. package/src/output/modules.pyj +1 -1
  47. package/src/output/operators.pyj +15 -0
  48. package/src/output/stream.pyj +0 -1
  49. package/src/parse.pyj +108 -24
  50. package/src/tokenizer.pyj +19 -3
  51. package/test/async_generators.pyj +144 -0
  52. package/test/asyncio.pyj +307 -0
  53. package/test/base64.pyj +202 -0
  54. package/test/baselib.pyj +23 -0
  55. package/test/bisect.pyj +178 -0
  56. package/test/chainmap.pyj +185 -0
  57. package/test/csv.pyj +405 -0
  58. package/test/float_special.pyj +64 -0
  59. package/test/heapq.pyj +174 -0
  60. package/test/html.pyj +212 -0
  61. package/test/http.pyj +259 -0
  62. package/test/imports.pyj +79 -72
  63. package/test/logging.pyj +356 -0
  64. package/test/long.pyj +130 -0
  65. package/test/parenthesized_with.pyj +141 -0
  66. package/test/pprint.pyj +232 -0
  67. package/test/python_compat.pyj +3 -5
  68. package/test/python_modulo.pyj +76 -0
  69. package/test/python_modulo_off.pyj +21 -0
  70. package/test/statistics.pyj +224 -0
  71. package/test/str.pyj +14 -0
  72. package/test/string.pyj +245 -0
  73. package/test/textwrap.pyj +172 -0
  74. package/test/type_display.pyj +48 -0
  75. package/test/type_enforcement.pyj +164 -0
  76. package/test/unit/index.js +94 -6
  77. package/test/unit/language-service-completions.js +121 -0
  78. package/test/unit/language-service-scope.js +32 -0
  79. package/test/unit/language-service.js +190 -5
  80. package/test/unit/run-language-service.js +17 -3
  81. package/test/unit/web-repl.js +2401 -13
  82. package/test/urllib.pyj +193 -0
  83. package/tools/compile.js +1 -1
  84. package/tools/embedded_compiler.js +7 -7
  85. package/tools/export.js +4 -2
  86. package/web-repl/main.js +1 -1
  87. package/web-repl/rapydscript.js +7 -5
  88. package/test/omit_function_metadata.pyj +0 -20
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: string.pyj Implementation
3
+ description: string module (character constants, Template, Formatter) — pitfalls and design decisions
4
+ type: project
5
+ ---
6
+
7
+ ## string.pyj Implementation (added 2026-05-02)
8
+ - `src/lib/string.pyj` — character constants, `Template`, `Formatter`
9
+ - `test/string.pyj` — unit tests; `test/unit/web-repl.js` — 3 bundle tests (bundle_string_*)
10
+ - Language service: `'string'` added to `STDLIB_MODULES` in `src/monaco-language-service/diagnostics.js`
11
+
12
+ ## Character Constants
13
+ - Built via simple Python assignments; `chr(39)` = `'`, `chr(92)` = `\`, `chr(96)` = `` ` `` avoid escaping issues in string literals
14
+ - `whitespace = ' \t\n\r' + chr(11) + chr(12)` — chr(11)=VT, chr(12)=FF
15
+
16
+ ## Template
17
+ - `substitute(mapping=None)` / `safe_substitute(mapping=None)` — accepts plain dict or ρσ_dict
18
+ - `_tmpl_to_plain(mapping)` converts ρσ_dict (via `.jsmap`) to a plain JS object
19
+ - `_tmpl_re` regex: `/\$(?:(\$)|\{([_a-zA-Z][_a-zA-Z0-9]*)\}|([_a-zA-Z][_a-zA-Z0-9]*)|([^]?))/g`
20
+ - Uses `[^]?` (zero-or-one of any char) to match trailing lone `$` so substitute raises ValueError
21
+ - `ρσ_str(val)` used for substituted values (gives 'None' for null, matching Python behavior)
22
+
23
+ ## Formatter
24
+ - `format(format_string, *args)` — positional args ONLY (no **kwargs in RapydScript)
25
+ - Named fields: use `vformat(fmt, [], {'key': val})` directly
26
+ - `vformat` delegates to `_fmt_vformat(fmt_str, args, kwargs, self)` JS helper
27
+ - `_fmt_get_kwarg(kwargs, key)` handles both plain objects and ρσ_dict (.jsmap)
28
+ - `format_field` calls `format(value, format_spec)` (= `ρσ_format`) for specs; `str(value)` when empty
29
+ - Subclassing works: override `format_field`, `convert_field`, `get_value`, `get_field`
30
+
31
+ ## Critical v-block Pitfall Discovered
32
+ **v-blocks are TRULY VERBATIM — Python does NOT process escape sequences.**
33
+ - `\n` in v-block → `\n` in JS output (which in a JS string = newline char)
34
+ - `\\n` in v-block → `\\n` in JS output (which in a JS string = backslash+n)
35
+ - For regex literals in v-blocks: write exactly the JS you want — `\$` → `\$` in JS regex (literal $)
36
+ - NEVER double backslashes in v-block regex literals (unlike what an older MEMORY note implies)
37
+ - The MEMORY note about doubling (`\\n`/`\\t`) applies when you WANT literal `\n` text in JS, not actual newlines
38
+
39
+ ## String.prototype .upper() in Tests
40
+ - `String.prototype.upper` (and other Python str methods) is NOT added in the test runner context unless `from pythonize import strings` is used
41
+ - Subclass tests that operate on string return values must use `.toUpperCase()` (native JS) not `.upper()` (Python) unless pythonize is imported
42
+
43
+ **Why:** How to apply: When testing Formatter/string subclasses in .pyj test files that don't import pythonize, use `v'result.toUpperCase()'` not `result.upper()`.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "rapydscript-ns",
3
3
  "description": "Pythonic JavaScript that doesn't suck",
4
4
  "homepage": "https://github.com/ficocelliguy/rapydscript-ns",
5
- "version": "0.9.2",
5
+ "version": "0.9.4",
6
6
  "license": "BSD-2-Clause",
7
7
  "engines": {
8
8
  "node": ">=0.12.0"