ranger-compiler 3.2.0 → 3.5.0

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 (61) hide show
  1. package/CHANGELOG.md +2463 -0
  2. package/LICENSE +28 -0
  3. package/LICENSE-MIT +21 -0
  4. package/README.md +1651 -1895
  5. package/dist/Lang.rgr +10946 -5852
  6. package/dist/README.md +3 -2
  7. package/dist/api.d.ts +1548 -27
  8. package/dist/api.js +70572 -38295
  9. package/dist/git-http.mjs +126 -0
  10. package/dist/lib/ACEEditor.rgr +2 -0
  11. package/dist/lib/Ajax.rgr +2 -0
  12. package/dist/lib/CmdParams.rgr +2 -0
  13. package/dist/lib/Crypto.rgr +2 -0
  14. package/dist/lib/DOMLib.rgr +2 -0
  15. package/dist/lib/Engine3D.rgr +2 -0
  16. package/dist/lib/ImmutableVector.rgr +2 -0
  17. package/dist/lib/IndexedDB.rgr +2 -0
  18. package/dist/lib/IsoDate/DateMath.rgr +2 -0
  19. package/dist/lib/IsoDate/IsoCalendar.rgr +2 -0
  20. package/dist/lib/IsoDate/IsoDateParse.rgr +2 -0
  21. package/dist/lib/IsoDateLib.rgr +2 -0
  22. package/dist/lib/JSON.rgr +4906 -48
  23. package/dist/lib/JinxProcess.rgr +2 -0
  24. package/dist/lib/RangerProcess.rgr +2 -0
  25. package/dist/lib/Regex/RegexMatch.rgr +2 -0
  26. package/dist/lib/RegexLib.rgr +2 -0
  27. package/dist/lib/SQL.rgr +2 -0
  28. package/dist/lib/ServiceLib.rgr +2 -0
  29. package/dist/lib/Shell.rgr +326 -0
  30. package/dist/lib/Storage.rgr +2 -0
  31. package/dist/lib/Time.rgr +2 -0
  32. package/dist/lib/Timers.rgr +2 -0
  33. package/dist/lib/TypedArrays.rgr +2 -0
  34. package/dist/lib/ViewLib.rgr +2 -0
  35. package/dist/lib/WebLib.rgr +2 -0
  36. package/dist/lib/WebServerLib.rgr +2 -0
  37. package/dist/lib/apple/AppleAppBuilder.rgr +572 -0
  38. package/dist/lib/apple/AppleAppSpec.rgr +201 -0
  39. package/dist/lib/apple/AppleDevice.rgr +295 -0
  40. package/dist/lib/apple/AppleDeviceDoctor.rgr +453 -0
  41. package/dist/lib/apple/AppleSigning.rgr +379 -0
  42. package/dist/lib/apple/AppleSimulator.rgr +248 -0
  43. package/dist/lib/apple/AppleTarget.rgr +185 -0
  44. package/dist/lib/apple/AppleToolchain.rgr +458 -0
  45. package/dist/lib/apple/README.md +311 -0
  46. package/dist/lib/apple/apple_test.rgr +669 -0
  47. package/dist/lib/core/README.md +251 -0
  48. package/dist/lib/core/RgBase.rgr +313 -0
  49. package/dist/lib/core/RgNum.rgr +653 -0
  50. package/dist/lib/core/RgText.rgr +680 -0
  51. package/dist/lib/core/RgU32.rgr +309 -0
  52. package/dist/lib/ranger-dir.rgr +2 -0
  53. package/dist/lib/shell_test.rgr +193 -0
  54. package/dist/lib/stdlib.rgr +1176 -665
  55. package/dist/lib/stdops.rgr +2 -0
  56. package/dist/lib/zip/Inflate.rgr +675 -0
  57. package/dist/lib/zip/ZipBuffer.rgr +358 -0
  58. package/dist/package.json +1 -1
  59. package/dist/rgrc.js +76333 -40647
  60. package/dist/stdops.rgr +2 -0
  61. package/package.json +1121 -339
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: MIT
3
+ //
4
+ // Dumb HTTPS pipe for Git smart HTTP, shipped beside rgrc. All Git framing
5
+ // lives in Ranger -- the pack parser, pkt-line, SHA-1 and the tree walk are
6
+ // compiled into the compiler itself. This file only GETs and POSTs bytes,
7
+ // because Node has no synchronous HTTPS and the compiler is synchronous.
8
+ // Public repos, no credentials.
9
+
10
+ import { request as httpsRequest } from "node:https";
11
+ import { request as httpRequest } from "node:http";
12
+ import { readFileSync, writeFileSync } from "node:fs";
13
+
14
+ function toGitUrl(raw) {
15
+ let u = raw.trim();
16
+ if (u.startsWith("git@")) {
17
+ const rest = u.slice(4);
18
+ const colon = rest.indexOf(":");
19
+ if (colon > 0) {
20
+ u = "https://" + rest.slice(0, colon) + "/" + rest.slice(colon + 1);
21
+ }
22
+ }
23
+ if (!u.endsWith(".git")) {
24
+ u = u + ".git";
25
+ }
26
+ if (u.endsWith("/")) {
27
+ u = u.slice(0, -1);
28
+ }
29
+ return u;
30
+ }
31
+
32
+ function fetchBytes(url, { method = "GET", body, contentType } = {}) {
33
+ return new Promise((resolve, reject) => {
34
+ const go = (target, hops) => {
35
+ if (hops > 8) {
36
+ reject(new Error("too many redirects"));
37
+ return;
38
+ }
39
+ const u = new URL(target);
40
+ const lib = u.protocol === "http:" ? httpRequest : httpsRequest;
41
+ const req = lib(
42
+ {
43
+ protocol: u.protocol,
44
+ hostname: u.hostname,
45
+ port: u.port || (u.protocol === "http:" ? 80 : 443),
46
+ path: u.pathname + u.search,
47
+ method,
48
+ headers: {
49
+ "User-Agent": "git/2.43.0 ranger-pkg/0.1",
50
+ Accept: contentType
51
+ ? "application/x-git-upload-pack-result"
52
+ : "application/x-git-upload-pack-advertisement",
53
+ ...(process.env.GIT_PROTOCOL
54
+ ? { "Git-Protocol": process.env.GIT_PROTOCOL }
55
+ : {}),
56
+ ...(body
57
+ ? {
58
+ "Content-Type": contentType,
59
+ "Content-Length": String(body.length),
60
+ }
61
+ : {}),
62
+ },
63
+ },
64
+ (res) => {
65
+ const chunks = [];
66
+ res.on("data", (c) => chunks.push(c));
67
+ res.on("end", () => {
68
+ const buf = Buffer.concat(chunks);
69
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
70
+ go(new URL(res.headers.location, target).toString(), hops + 1);
71
+ return;
72
+ }
73
+ if (res.statusCode < 200 || res.statusCode >= 300) {
74
+ reject(new Error(`HTTP ${res.statusCode} ${target}\n${buf.slice(0, 400)}`));
75
+ return;
76
+ }
77
+ resolve(buf);
78
+ });
79
+ }
80
+ );
81
+ req.on("error", reject);
82
+ if (body) {
83
+ req.write(body);
84
+ }
85
+ req.end();
86
+ };
87
+ go(url, 0);
88
+ });
89
+ }
90
+
91
+ const cmd = process.argv[2];
92
+ const url = process.argv[3] ? toGitUrl(process.argv[3]) : "";
93
+
94
+ if (cmd === "advertise" && url) {
95
+ const buf = await fetchBytes(url + "/info/refs?service=git-upload-pack");
96
+ const out = process.argv[4];
97
+ if (out) {
98
+ writeFileSync(out, buf);
99
+ } else {
100
+ process.stdout.write(buf);
101
+ }
102
+ process.exit(0);
103
+ }
104
+
105
+ if (cmd === "post" && url) {
106
+ const reqFile = process.argv[4];
107
+ const out = process.argv[5];
108
+ const body = readFileSync(reqFile);
109
+ const buf = await fetchBytes(url + "/git-upload-pack", {
110
+ method: "POST",
111
+ body,
112
+ contentType: "application/x-git-upload-pack-request",
113
+ });
114
+ if (out) {
115
+ writeFileSync(out, buf);
116
+ } else {
117
+ process.stdout.write(buf);
118
+ }
119
+ process.exit(0);
120
+ }
121
+
122
+ console.error(`usage:
123
+ git-http.mjs advertise <git-url> [out.bin]
124
+ git-http.mjs post <git-url> <want.bin> [out.bin]
125
+ GIT_PROTOCOL=version=2 git-http.mjs …`);
126
+ process.exit(2);
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
  operator type:void es6 {
2
4
  fn disable_warnings (el:ACEEditor) ( (e 1) ".$blockScrolling = Infinity")
3
5
  fn set (el:ACEEditor str) ( (e 1) ".setValue(" (e 2) ")")
package/dist/lib/Ajax.rgr CHANGED
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
  Import "JSON.rgr"
2
4
 
3
5
 
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
 
3
5
  ; -i file2.pdf -o file3.pdf
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
  Import "TypedArrays.rgr"
3
5
 
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
  Import "ViewLib.rgr"
2
4
  Import "ACEEditor.rgr"
3
5
 
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
 
3
5
  systemclass Vector3 {
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
 
3
5
  ; immutable map type
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
  systemclass IndexedDBDatabase {
3
5
  es6 IDBDatabase
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
  ; Portable calendar math on ISO-8601 date strings (YYYY-MM-DD).
3
5
  ; No host Date, timezone, or locale — safe to compile to any Ranger target.
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
  Import "DateMath.rgr"
3
5
  Import "IsoDateParse.rgr"
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
  Import "DateMath.rgr"
3
5
 
@@ -1,3 +1,5 @@
1
+ ; SPDX-License-Identifier: MIT
2
+
1
3
 
2
4
  ; Portable ISO-8601 calendar library (date-only, no timezone).
3
5
  ; Convention: IsoDate = string "YYYY-MM-DD"