@shd101wyy/yo 0.1.26 → 0.1.27

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 (167) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +4 -4
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
  3. package/.github/skills/yo-core-patterns/SKILL.md +1 -1
  4. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -26
  5. package/.github/skills/yo-project-workflow/SKILL.md +6 -3
  6. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
  7. package/.github/skills/yo-syntax/SKILL.md +7 -6
  8. package/.github/skills/yo-syntax/syntax-cheatsheet.md +73 -60
  9. package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
  10. package/README.md +10 -8
  11. package/out/cjs/index.cjs +456 -438
  12. package/out/cjs/yo-cli.cjs +576 -543
  13. package/out/cjs/yo-lsp.cjs +559 -532
  14. package/out/esm/index.mjs +281 -263
  15. package/out/types/src/formatter.d.ts +11 -0
  16. package/out/types/src/lsp/formatting.d.ts +2 -0
  17. package/out/types/src/tests/formatter.test.d.ts +1 -0
  18. package/out/types/tsconfig.tsbuildinfo +1 -1
  19. package/package.json +1 -1
  20. package/std/alg/hash.yo +13 -21
  21. package/std/allocator.yo +25 -40
  22. package/std/async.yo +3 -7
  23. package/std/build.yo +105 -151
  24. package/std/cli/arg_parser.yo +184 -169
  25. package/std/collections/array_list.yo +350 -314
  26. package/std/collections/btree_map.yo +142 -131
  27. package/std/collections/deque.yo +132 -128
  28. package/std/collections/hash_map.yo +542 -566
  29. package/std/collections/hash_set.yo +623 -687
  30. package/std/collections/linked_list.yo +275 -293
  31. package/std/collections/ordered_map.yo +113 -85
  32. package/std/collections/priority_queue.yo +73 -73
  33. package/std/crypto/md5.yo +191 -95
  34. package/std/crypto/random.yo +56 -64
  35. package/std/crypto/sha256.yo +151 -107
  36. package/std/encoding/base64.yo +87 -81
  37. package/std/encoding/hex.yo +43 -50
  38. package/std/encoding/html.yo +56 -81
  39. package/std/encoding/html_char_utils.yo +7 -13
  40. package/std/encoding/html_entities.yo +2248 -2253
  41. package/std/encoding/json.yo +316 -224
  42. package/std/encoding/punycode.yo +86 -116
  43. package/std/encoding/toml.yo +67 -66
  44. package/std/encoding/utf16.yo +37 -44
  45. package/std/env.yo +62 -91
  46. package/std/error.yo +7 -15
  47. package/std/fmt/display.yo +5 -9
  48. package/std/fmt/index.yo +8 -14
  49. package/std/fmt/to_string.yo +330 -315
  50. package/std/fmt/writer.yo +58 -87
  51. package/std/fs/dir.yo +83 -102
  52. package/std/fs/file.yo +147 -180
  53. package/std/fs/metadata.yo +45 -78
  54. package/std/fs/temp.yo +55 -65
  55. package/std/fs/types.yo +27 -40
  56. package/std/fs/walker.yo +53 -68
  57. package/std/gc.yo +5 -8
  58. package/std/glob.yo +30 -43
  59. package/std/http/client.yo +107 -120
  60. package/std/http/http.yo +106 -96
  61. package/std/http/index.yo +4 -6
  62. package/std/imm/list.yo +88 -93
  63. package/std/imm/map.yo +528 -464
  64. package/std/imm/set.yo +52 -57
  65. package/std/imm/sorted_map.yo +340 -286
  66. package/std/imm/sorted_set.yo +57 -63
  67. package/std/imm/string.yo +404 -345
  68. package/std/imm/vec.yo +173 -181
  69. package/std/io/reader.yo +3 -6
  70. package/std/io/writer.yo +4 -8
  71. package/std/libc/assert.yo +5 -9
  72. package/std/libc/ctype.yo +32 -22
  73. package/std/libc/dirent.yo +26 -25
  74. package/std/libc/errno.yo +164 -90
  75. package/std/libc/fcntl.yo +52 -45
  76. package/std/libc/float.yo +66 -44
  77. package/std/libc/limits.yo +42 -33
  78. package/std/libc/math.yo +53 -82
  79. package/std/libc/signal.yo +72 -47
  80. package/std/libc/stdatomic.yo +217 -188
  81. package/std/libc/stdint.yo +5 -29
  82. package/std/libc/stdio.yo +5 -29
  83. package/std/libc/stdlib.yo +32 -39
  84. package/std/libc/string.yo +5 -23
  85. package/std/libc/sys/stat.yo +58 -56
  86. package/std/libc/time.yo +5 -19
  87. package/std/libc/unistd.yo +5 -20
  88. package/std/libc/wctype.yo +6 -9
  89. package/std/libc/windows.yo +26 -30
  90. package/std/log.yo +41 -55
  91. package/std/net/addr.yo +102 -97
  92. package/std/net/dns.yo +27 -28
  93. package/std/net/errors.yo +50 -49
  94. package/std/net/tcp.yo +113 -124
  95. package/std/net/udp.yo +55 -66
  96. package/std/os/env.yo +35 -33
  97. package/std/os/signal.yo +15 -25
  98. package/std/path.yo +276 -311
  99. package/std/prelude.yo +6304 -4315
  100. package/std/process/command.yo +87 -103
  101. package/std/process/index.yo +12 -31
  102. package/std/regex/compiler.yo +196 -95
  103. package/std/regex/flags.yo +58 -39
  104. package/std/regex/index.yo +157 -173
  105. package/std/regex/match.yo +20 -31
  106. package/std/regex/node.yo +134 -152
  107. package/std/regex/parser.yo +283 -259
  108. package/std/regex/unicode.yo +172 -202
  109. package/std/regex/vm.yo +155 -171
  110. package/std/string/index.yo +5 -7
  111. package/std/string/rune.yo +45 -55
  112. package/std/string/string.yo +937 -964
  113. package/std/string/string_builder.yo +94 -104
  114. package/std/string/unicode.yo +46 -64
  115. package/std/sync/channel.yo +72 -73
  116. package/std/sync/cond.yo +31 -36
  117. package/std/sync/mutex.yo +30 -32
  118. package/std/sync/once.yo +13 -16
  119. package/std/sync/rwlock.yo +26 -31
  120. package/std/sync/waitgroup.yo +20 -25
  121. package/std/sys/advise.yo +16 -24
  122. package/std/sys/bufio/buf_reader.yo +77 -93
  123. package/std/sys/bufio/buf_writer.yo +52 -65
  124. package/std/sys/clock.yo +4 -9
  125. package/std/sys/constants.yo +77 -61
  126. package/std/sys/copy.yo +4 -10
  127. package/std/sys/dir.yo +26 -43
  128. package/std/sys/dns.yo +41 -61
  129. package/std/sys/errors.yo +95 -103
  130. package/std/sys/events.yo +45 -57
  131. package/std/sys/externs.yo +319 -267
  132. package/std/sys/fallocate.yo +7 -11
  133. package/std/sys/fcntl.yo +14 -22
  134. package/std/sys/file.yo +26 -40
  135. package/std/sys/future.yo +5 -8
  136. package/std/sys/iov.yo +12 -25
  137. package/std/sys/lock.yo +12 -13
  138. package/std/sys/mmap.yo +38 -43
  139. package/std/sys/path.yo +3 -8
  140. package/std/sys/perm.yo +7 -21
  141. package/std/sys/pipe.yo +5 -12
  142. package/std/sys/process.yo +23 -29
  143. package/std/sys/seek.yo +10 -12
  144. package/std/sys/signal.yo +7 -13
  145. package/std/sys/signals.yo +52 -35
  146. package/std/sys/socket.yo +63 -58
  147. package/std/sys/socketpair.yo +3 -6
  148. package/std/sys/sockinfo.yo +11 -20
  149. package/std/sys/statfs.yo +11 -34
  150. package/std/sys/statx.yo +25 -52
  151. package/std/sys/sysinfo.yo +15 -20
  152. package/std/sys/tcp.yo +62 -92
  153. package/std/sys/temp.yo +5 -9
  154. package/std/sys/time.yo +5 -15
  155. package/std/sys/timer.yo +6 -11
  156. package/std/sys/tty.yo +10 -18
  157. package/std/sys/udp.yo +22 -39
  158. package/std/sys/umask.yo +3 -6
  159. package/std/sys/unix.yo +33 -52
  160. package/std/testing/bench.yo +49 -52
  161. package/std/thread.yo +10 -15
  162. package/std/time/datetime.yo +105 -89
  163. package/std/time/duration.yo +43 -56
  164. package/std/time/instant.yo +13 -18
  165. package/std/time/sleep.yo +5 -9
  166. package/std/url/index.yo +184 -209
  167. package/std/worker.yo +6 -10
package/std/fs/walker.yo CHANGED
@@ -21,134 +21,119 @@
21
21
  //! };
22
22
  //! });
23
23
  //! ```
24
-
25
- { ArrayList } :: import "../collections/array_list";
26
- open import "../string";
27
- { Path } :: import "../path";
28
- { IOError } :: import "../sys/errors";
29
- { Error, AnyError, Exception } :: import "../error";
30
- { FileType } :: import "./dir";
31
- { DirEntry } :: import "./dir";
32
- _dir :: import "./dir";
33
-
24
+ { ArrayList } :: import("../collections/array_list");
25
+ open(import("../string"));
26
+ { Path } :: import("../path");
27
+ { IOError } :: import("../sys/errors");
28
+ { Error, AnyError, Exception } :: import("../error");
29
+ { FileType } :: import("./dir");
30
+ { DirEntry } :: import("./dir");
31
+ _dir :: import("./dir");
34
32
  /// Entry returned by the directory walker.
35
33
  WalkEntry :: struct(
36
- path : Path,
37
- name : String,
38
- depth : u32,
34
+ path : Path,
35
+ name : String,
36
+ depth : u32,
39
37
  file_type : FileType
40
38
  );
41
-
42
- export WalkEntry;
43
-
39
+ export(WalkEntry);
44
40
  /// Options controlling directory walk behavior.
45
41
  WalkOptions :: struct(
46
- max_depth : ?(u32),
42
+ max_depth : ?(u32),
47
43
  follow_symlinks : bool,
48
- include_dirs : bool
44
+ include_dirs : bool
49
45
  );
50
-
51
- impl(WalkOptions,
46
+ impl(
47
+ WalkOptions,
52
48
  defaults : (fn() -> Self)(
53
49
  Self(
54
- max_depth: .None,
55
- follow_symlinks: false,
56
- include_dirs: true
50
+ max_depth :.None,
51
+ follow_symlinks : false,
52
+ include_dirs : true
57
53
  )
58
54
  )
59
55
  );
60
-
61
- export WalkOptions;
62
-
56
+ export(WalkOptions);
63
57
  // ============================================================================
64
58
  // Internal path join helper
65
59
  // ============================================================================
66
-
67
- _join_path :: (fn(base: String, name: String) -> String)(
60
+ _join_path :: (fn(base : String, name : String) -> String)(
68
61
  cond(
69
62
  base.ends_with(String.from("/")) => `${base}${name}`,
70
63
  true => `${base}/${name}`
71
64
  )
72
65
  );
73
-
74
66
  // ============================================================================
75
67
  // Walk functions
76
68
  // ============================================================================
77
-
78
69
  // Walk a directory tree with custom options.
79
- walk_with :: (fn(root: Path, options: WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))({
70
+ walk_with :: (fn(root : Path, options : WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))({
80
71
  root_s := root.to_string();
81
72
  io.async((using(io, exn)) => {
82
73
  results := ArrayList(WalkEntry).new();
83
74
  // Stack of (path, depth) pairs to process
84
- stack := ArrayList(struct(path: String, depth: u32)).new();
85
- stack.push({ path: root_s, depth: u32(0) });
86
-
87
- while runtime((stack.len() > usize(0))), {
75
+ stack := ArrayList(struct(path : String, depth : u32)).new();
76
+ stack.push({ path : root_s, depth : u32(0) });
77
+ while(runtime(stack.len() > usize(0)), {
88
78
  item := stack.pop().unwrap();
89
79
  cur_path := item.path;
90
80
  cur_depth := item.depth;
91
-
92
81
  // Check max depth
93
- should_continue := match(options.max_depth,
82
+ should_continue := match(
83
+ options.max_depth,
94
84
  .Some(max) => (cur_depth <= max),
95
85
  .None => true
96
86
  );
97
-
98
87
  cond(
99
88
  should_continue => {
100
89
  entries := io.await(_dir.read_dir(Path.new(cur_path)));
101
90
  i := usize(0);
102
- while runtime((i < entries.len())), {
91
+ while(runtime(i < entries.len()), {
103
92
  entry := entries.get(i).unwrap();
104
93
  entry_path := _join_path(cur_path, entry.name);
105
- match(entry.file_type,
94
+ match(
95
+ entry.file_type,
106
96
  .Directory => {
107
97
  cond(
108
98
  options.include_dirs => {
109
- results.push(WalkEntry(
110
- path: Path.new(entry_path),
111
- name: entry.name,
112
- depth: cur_depth,
113
- file_type: .Directory
114
- ));
99
+ results.push(
100
+ WalkEntry(
101
+ path : Path.new(entry_path),
102
+ name : entry.name,
103
+ depth : cur_depth,
104
+ file_type :.Directory
105
+ )
106
+ );
115
107
  },
116
108
  true => ()
117
109
  );
118
110
  // Push subdirectory for processing
119
- stack.push({ path: entry_path, depth: (cur_depth + u32(1)) });
111
+ stack.push({ path : entry_path, depth : (cur_depth + u32(1)) });
120
112
  },
121
113
  _ => {
122
- results.push(WalkEntry(
123
- path: Path.new(entry_path),
124
- name: entry.name,
125
- depth: cur_depth,
126
- file_type: entry.file_type
127
- ));
114
+ results.push(
115
+ WalkEntry(
116
+ path : Path.new(entry_path),
117
+ name : entry.name,
118
+ depth : cur_depth,
119
+ file_type : entry.file_type
120
+ )
121
+ );
128
122
  }
129
123
  );
130
124
  i = (i + usize(1));
131
- };
125
+ });
132
126
  },
133
127
  true => ()
134
128
  );
135
- };
136
-
129
+ });
137
130
  results
138
131
  })
139
132
  });
140
-
141
- walk_with_cstr :: (fn(root: *(u8), options: WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(
133
+ walk_with_cstr :: (fn(root : *(u8), options : WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(
142
134
  walk_with(Path.from_cstr(root), options)
143
135
  );
144
-
145
136
  /// Walk a directory tree with default options.
146
- walk :: (fn(root: Path, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))
147
- walk_with(root, WalkOptions.defaults())
148
- ;
149
-
150
- walk_cstr :: (fn(root: *(u8), using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))
151
- walk(Path.from_cstr(root))
152
- ;
153
-
154
- export walk, walk_cstr, walk_with, walk_with_cstr;
137
+ walk :: (fn(root : Path, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(walk_with(root, WalkOptions.defaults()));
138
+ walk_cstr :: (fn(root : *(u8), using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(walk(Path.from_cstr(root)));
139
+ export(walk, walk_cstr, walk_with, walk_with_cstr);
package/std/gc.yo CHANGED
@@ -1,15 +1,12 @@
1
1
  //! Garbage collection interface for cycle collection.
2
-
3
- extern "Yo",
2
+ extern(
3
+ "Yo",
4
4
  __yo_gc_collect : (fn() -> unit),
5
5
  __yo_gc_tracked_count : (fn() -> u64)
6
- ;
7
-
6
+ );
8
7
  /// Trigger the cycle collector to reclaim reference cycles.
9
8
  collect :: __yo_gc_collect;
10
-
11
9
  /// Get the number of objects currently tracked by the cycle collector.
12
10
  tracked_count :: __yo_gc_tracked_count;
13
-
14
- export collect;
15
- export tracked_count;
11
+ export(collect);
12
+ export(tracked_count);
package/std/glob.yo CHANGED
@@ -1,33 +1,28 @@
1
1
  //! Glob pattern matching for file paths.
2
-
3
- open import "./string";
4
- { ArrayList } :: import "./collections/array_list";
5
-
2
+ open(import("./string"));
3
+ { ArrayList } :: import("./collections/array_list");
6
4
  // Recursive byte-level glob pattern matching
7
- _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usize) -> bool)({
5
+ _glob_match_impl :: (fn(pb : ArrayList(u8), pi : usize, tb : ArrayList(u8), ti : usize) -> bool)({
8
6
  // Base: both pattern and text consumed
9
7
  cond(
10
8
  ((pi == pb.len()) && (ti == tb.len())) => {
11
- return true;
9
+ return(true);
12
10
  },
13
11
  true => ()
14
12
  );
15
-
16
13
  // Pattern consumed but text remains
17
14
  cond(
18
15
  (pi == pb.len()) => {
19
- return false;
16
+ return(false);
20
17
  },
21
18
  true => ()
22
19
  );
23
-
24
20
  p := pb.get(pi).unwrap();
25
-
26
21
  // Handle * and **
27
22
  cond(
28
23
  (p == u8(42)) => {
29
24
  is_dbl := cond(
30
- ((pi + usize(1)) < pb.len()) => (pb.get((pi + usize(1))).unwrap() == u8(42)),
25
+ ((pi + usize(1)) < pb.len()) => (pb.get(pi + usize(1)).unwrap() == u8(42)),
31
26
  true => false
32
27
  );
33
28
  cond(
@@ -49,17 +44,17 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
49
44
  // Try ** matching nothing
50
45
  cond(
51
46
  recur(pb, npi, tb, ti) => {
52
- return true;
47
+ return(true);
53
48
  },
54
49
  true => ()
55
50
  );
56
51
  // Try ** consuming one char
57
52
  cond(
58
53
  (ti < tb.len()) => {
59
- return recur(pb, pi, tb, (ti + usize(1)));
54
+ return(recur(pb, pi, tb, ti + usize(1)));
60
55
  },
61
56
  true => {
62
- return false;
57
+ return(false);
63
58
  }
64
59
  );
65
60
  },
@@ -67,8 +62,8 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
67
62
  // Single * matches any except /
68
63
  // Try * matching nothing
69
64
  cond(
70
- recur(pb, (pi + usize(1)), tb, ti) => {
71
- return true;
65
+ recur(pb, pi + usize(1), tb, ti) => {
66
+ return(true);
72
67
  },
73
68
  true => ()
74
69
  );
@@ -78,15 +73,15 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
78
73
  tc := tb.get(ti).unwrap();
79
74
  cond(
80
75
  (tc != u8(47)) => {
81
- return recur(pb, pi, tb, (ti + usize(1)));
76
+ return(recur(pb, pi, tb, ti + usize(1)));
82
77
  },
83
78
  true => {
84
- return false;
79
+ return(false);
85
80
  }
86
81
  );
87
82
  },
88
83
  true => {
89
- return false;
84
+ return(false);
90
85
  }
91
86
  );
92
87
  }
@@ -94,32 +89,28 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
94
89
  },
95
90
  true => ()
96
91
  );
97
-
98
92
  // Text consumed but non-star pattern remains
99
93
  cond(
100
94
  (ti == tb.len()) => {
101
- return false;
95
+ return(false);
102
96
  },
103
97
  true => ()
104
98
  );
105
-
106
99
  t := tb.get(ti).unwrap();
107
-
108
100
  // Handle ?
109
101
  cond(
110
102
  (p == u8(63)) => {
111
103
  cond(
112
104
  (t != u8(47)) => {
113
- return recur(pb, (pi + usize(1)), tb, (ti + usize(1)));
105
+ return(recur(pb, pi + usize(1), tb, ti + usize(1)));
114
106
  },
115
107
  true => {
116
- return false;
108
+ return(false);
117
109
  }
118
110
  );
119
111
  },
120
112
  true => ()
121
113
  );
122
-
123
114
  // Handle [...]
124
115
  cond(
125
116
  (p == u8(91)) => {
@@ -142,7 +133,7 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
142
133
  // Scan characters in class until ]
143
134
  found := false;
144
135
  cdone := false;
145
- while (((ci < pb.len()) && (!(cdone)))), (ci = (ci + usize(1))), {
136
+ while((ci < pb.len()) && (!(cdone)), ci = (ci + usize(1)), {
146
137
  ch := pb.get(ci).unwrap();
147
138
  cond(
148
139
  (ch == u8(93)) => {
@@ -157,11 +148,11 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
157
148
  );
158
149
  }
159
150
  );
160
- };
151
+ });
161
152
  // Malformed pattern (no closing ])
162
153
  cond(
163
154
  (!(cdone)) => {
164
- return false;
155
+ return(false);
165
156
  },
166
157
  true => ()
167
158
  );
@@ -171,39 +162,35 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
171
162
  );
172
163
  cond(
173
164
  matched => {
174
- return recur(pb, ci, tb, (ti + usize(1)));
165
+ return(recur(pb, ci, tb, ti + usize(1)));
175
166
  },
176
167
  true => {
177
- return false;
168
+ return(false);
178
169
  }
179
170
  );
180
171
  },
181
172
  true => ()
182
173
  );
183
-
184
174
  // Literal byte match
185
175
  cond(
186
- (p == t) => recur(pb, (pi + usize(1)), tb, (ti + usize(1))),
176
+ (p == t) => recur(pb, pi + usize(1), tb, ti + usize(1)),
187
177
  true => false
188
178
  )
189
179
  });
190
-
191
- glob_match :: (fn(pattern: String, text: String) -> bool)(
180
+ glob_match :: (fn(pattern : String, text : String) -> bool)(
192
181
  _glob_match_impl(pattern.as_bytes(), usize(0), text.as_bytes(), usize(0))
193
182
  );
194
-
195
183
  /// Compiled glob pattern that can be matched against strings.
196
184
  GlobPattern :: object(
197
185
  _pattern : String
198
186
  );
199
-
200
- impl(GlobPattern,
201
- new : (fn(pattern: String) -> Self)(
202
- Self(_pattern: pattern)
187
+ impl(
188
+ GlobPattern,
189
+ new : (fn(pattern : String) -> Self)(
190
+ Self(_pattern : pattern)
203
191
  ),
204
- matches : (fn(self: Self, text: String) -> bool)(
192
+ matches : (fn(self : Self, text : String) -> bool)(
205
193
  _glob_match_impl(self._pattern.as_bytes(), usize(0), text.as_bytes(), usize(0))
206
194
  )
207
195
  );
208
-
209
- export glob_match, GlobPattern;
196
+ export(glob_match, GlobPattern);