goscript 0.0.25 → 0.0.28

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 (190) hide show
  1. package/README.md +4 -4
  2. package/cmd/goscript/cmd_compile.go +0 -3
  3. package/cmd/goscript/deps.go +11 -0
  4. package/compiler/analysis.go +259 -55
  5. package/compiler/assignment.go +2 -2
  6. package/compiler/builtin_test.go +1 -1
  7. package/compiler/compiler.go +201 -49
  8. package/compiler/compiler_test.go +53 -0
  9. package/compiler/composite-lit.go +32 -8
  10. package/compiler/decl.go +6 -6
  11. package/compiler/expr-call.go +83 -0
  12. package/compiler/expr.go +1 -1
  13. package/compiler/protobuf.go +557 -0
  14. package/compiler/spec-struct.go +4 -0
  15. package/compiler/spec-value.go +11 -3
  16. package/compiler/spec.go +18 -1
  17. package/compiler/stmt-assign.go +35 -0
  18. package/compiler/type-assert.go +87 -0
  19. package/compiler/type.go +5 -2
  20. package/dist/gs/builtin/builtin.d.ts +19 -1
  21. package/dist/gs/builtin/builtin.js +85 -5
  22. package/dist/gs/builtin/builtin.js.map +1 -1
  23. package/dist/gs/builtin/channel.js.map +1 -1
  24. package/dist/gs/builtin/slice.d.ts +1 -1
  25. package/dist/gs/builtin/slice.js +59 -26
  26. package/dist/gs/builtin/slice.js.map +1 -1
  27. package/dist/gs/cmp/index.js.map +1 -1
  28. package/dist/gs/context/context.d.ts +1 -1
  29. package/dist/gs/context/context.js +20 -11
  30. package/dist/gs/context/context.js.map +1 -1
  31. package/dist/gs/errors/errors.d.ts +7 -0
  32. package/dist/gs/errors/errors.js +190 -0
  33. package/dist/gs/errors/errors.js.map +1 -0
  34. package/dist/gs/errors/index.d.ts +1 -0
  35. package/dist/gs/errors/index.js +2 -0
  36. package/dist/gs/errors/index.js.map +1 -0
  37. package/dist/gs/internal/goarch/index.js +1 -1
  38. package/dist/gs/internal/goarch/index.js.map +1 -1
  39. package/dist/gs/io/index.d.ts +1 -0
  40. package/dist/gs/io/index.js +2 -0
  41. package/dist/gs/io/index.js.map +1 -0
  42. package/dist/gs/io/io.d.ts +107 -0
  43. package/dist/gs/io/io.js +385 -0
  44. package/dist/gs/io/io.js.map +1 -0
  45. package/dist/gs/iter/iter.js.map +1 -1
  46. package/dist/gs/math/bits/index.js +34 -32
  47. package/dist/gs/math/bits/index.js.map +1 -1
  48. package/dist/gs/runtime/runtime.d.ts +1 -0
  49. package/dist/gs/runtime/runtime.js +15 -18
  50. package/dist/gs/runtime/runtime.js.map +1 -1
  51. package/dist/gs/slices/slices.d.ts +1 -1
  52. package/dist/gs/slices/slices.js +1 -1
  53. package/dist/gs/slices/slices.js.map +1 -1
  54. package/dist/gs/strings/builder.d.ts +18 -0
  55. package/dist/gs/strings/builder.js +205 -0
  56. package/dist/gs/strings/builder.js.map +1 -0
  57. package/dist/gs/strings/clone.d.ts +1 -0
  58. package/dist/gs/strings/clone.js +16 -0
  59. package/dist/gs/strings/clone.js.map +1 -0
  60. package/dist/gs/strings/compare.d.ts +1 -0
  61. package/dist/gs/strings/compare.js +14 -0
  62. package/dist/gs/strings/compare.js.map +1 -0
  63. package/dist/gs/strings/index.d.ts +2 -0
  64. package/dist/gs/strings/index.js +3 -0
  65. package/dist/gs/strings/index.js.map +1 -0
  66. package/dist/gs/strings/iter.d.ts +8 -0
  67. package/dist/gs/strings/iter.js +160 -0
  68. package/dist/gs/strings/iter.js.map +1 -0
  69. package/dist/gs/strings/reader.d.ts +34 -0
  70. package/dist/gs/strings/reader.js +418 -0
  71. package/dist/gs/strings/reader.js.map +1 -0
  72. package/dist/gs/strings/replace.d.ts +106 -0
  73. package/dist/gs/strings/replace.js +1136 -0
  74. package/dist/gs/strings/replace.js.map +1 -0
  75. package/dist/gs/strings/search.d.ts +24 -0
  76. package/dist/gs/strings/search.js +169 -0
  77. package/dist/gs/strings/search.js.map +1 -0
  78. package/dist/gs/strings/strings.d.ts +47 -0
  79. package/dist/gs/strings/strings.js +418 -0
  80. package/dist/gs/strings/strings.js.map +1 -0
  81. package/dist/gs/stringslite/index.d.ts +1 -0
  82. package/dist/gs/stringslite/index.js +2 -0
  83. package/dist/gs/stringslite/index.js.map +1 -0
  84. package/dist/gs/stringslite/strings.d.ts +11 -0
  85. package/dist/gs/stringslite/strings.js +67 -0
  86. package/dist/gs/stringslite/strings.js.map +1 -0
  87. package/dist/gs/sync/index.d.ts +1 -0
  88. package/dist/gs/sync/index.js +2 -0
  89. package/dist/gs/sync/index.js.map +1 -0
  90. package/dist/gs/sync/sync.d.ts +79 -0
  91. package/dist/gs/sync/sync.js +392 -0
  92. package/dist/gs/sync/sync.js.map +1 -0
  93. package/dist/gs/time/time.js +7 -7
  94. package/dist/gs/time/time.js.map +1 -1
  95. package/dist/gs/unicode/index.d.ts +1 -0
  96. package/dist/gs/unicode/index.js +2 -0
  97. package/dist/gs/unicode/index.js.map +1 -0
  98. package/dist/gs/unicode/unicode.d.ts +105 -0
  99. package/dist/gs/unicode/unicode.js +332 -0
  100. package/dist/gs/unicode/unicode.js.map +1 -0
  101. package/dist/gs/unicode/utf8/index.d.ts +1 -0
  102. package/dist/gs/unicode/utf8/index.js +3 -0
  103. package/dist/gs/unicode/utf8/index.js.map +1 -0
  104. package/dist/gs/unicode/utf8/utf8.d.ts +20 -0
  105. package/dist/gs/unicode/utf8/utf8.js +196 -0
  106. package/dist/gs/unicode/utf8/utf8.js.map +1 -0
  107. package/dist/gs/unsafe/index.d.ts +1 -0
  108. package/dist/gs/unsafe/index.js +2 -0
  109. package/dist/gs/unsafe/index.js.map +1 -0
  110. package/dist/gs/unsafe/unsafe.d.ts +11 -0
  111. package/dist/gs/unsafe/unsafe.js +44 -0
  112. package/dist/gs/unsafe/unsafe.js.map +1 -0
  113. package/go.mod +2 -1
  114. package/go.sum +6 -2
  115. package/gs/README.md +6 -0
  116. package/gs/builtin/builtin.ts +158 -0
  117. package/gs/builtin/channel.ts +683 -0
  118. package/gs/builtin/defer.ts +58 -0
  119. package/gs/builtin/index.ts +1 -0
  120. package/gs/builtin/io.ts +22 -0
  121. package/gs/builtin/map.ts +50 -0
  122. package/gs/builtin/slice.ts +1030 -0
  123. package/gs/builtin/type.ts +1106 -0
  124. package/gs/builtin/varRef.ts +25 -0
  125. package/gs/cmp/godoc.txt +8 -0
  126. package/gs/cmp/index.ts +29 -0
  127. package/gs/context/context.ts +401 -0
  128. package/gs/context/godoc.txt +69 -0
  129. package/gs/context/index.ts +1 -0
  130. package/gs/errors/errors.ts +223 -0
  131. package/gs/errors/godoc.txt +63 -0
  132. package/gs/errors/index.ts +1 -0
  133. package/gs/internal/goarch/godoc.txt +39 -0
  134. package/gs/internal/goarch/index.ts +18 -0
  135. package/gs/io/godoc.txt +61 -0
  136. package/gs/io/index.ts +1 -0
  137. package/gs/io/io.go +75 -0
  138. package/gs/io/io.ts +546 -0
  139. package/gs/iter/godoc.txt +203 -0
  140. package/gs/iter/index.ts +1 -0
  141. package/gs/iter/iter.ts +117 -0
  142. package/gs/math/bits/index.ts +356 -0
  143. package/gs/math/godoc.txt +76 -0
  144. package/gs/runtime/godoc.txt +331 -0
  145. package/gs/runtime/index.ts +1 -0
  146. package/gs/runtime/runtime.ts +178 -0
  147. package/gs/slices/godoc.txt +44 -0
  148. package/gs/slices/index.ts +1 -0
  149. package/gs/slices/slices.ts +22 -0
  150. package/gs/strings/builder.test.ts +121 -0
  151. package/gs/strings/builder.ts +223 -0
  152. package/gs/strings/clone.test.ts +43 -0
  153. package/gs/strings/clone.ts +17 -0
  154. package/gs/strings/compare.test.ts +84 -0
  155. package/gs/strings/compare.ts +13 -0
  156. package/gs/strings/godoc.txt +66 -0
  157. package/gs/strings/index.ts +2 -0
  158. package/gs/strings/iter.test.ts +343 -0
  159. package/gs/strings/iter.ts +171 -0
  160. package/gs/strings/reader.test.ts +243 -0
  161. package/gs/strings/reader.ts +451 -0
  162. package/gs/strings/replace.test.ts +181 -0
  163. package/gs/strings/replace.ts +1310 -0
  164. package/gs/strings/search.test.ts +214 -0
  165. package/gs/strings/search.ts +213 -0
  166. package/gs/strings/strings.test.ts +477 -0
  167. package/gs/strings/strings.ts +510 -0
  168. package/gs/stringslite/godoc.txt +17 -0
  169. package/gs/stringslite/index.ts +1 -0
  170. package/gs/stringslite/strings.ts +82 -0
  171. package/gs/sync/godoc.txt +21 -0
  172. package/gs/sync/index.ts +1 -0
  173. package/gs/sync/sync.go +64 -0
  174. package/gs/sync/sync.ts +449 -0
  175. package/gs/time/godoc.md +116 -0
  176. package/gs/time/godoc.txt +116 -0
  177. package/gs/time/index.ts +1 -0
  178. package/gs/time/time.ts +272 -0
  179. package/gs/unicode/godoc.txt +52 -0
  180. package/gs/unicode/index.ts +1 -0
  181. package/gs/unicode/unicode.go +38 -0
  182. package/gs/unicode/unicode.ts +418 -0
  183. package/gs/unicode/utf8/godoc.txt +22 -0
  184. package/gs/unicode/utf8/index.ts +2 -0
  185. package/gs/unicode/utf8/utf8.ts +227 -0
  186. package/gs/unsafe/godoc.txt +19 -0
  187. package/gs/unsafe/index.ts +1 -0
  188. package/gs/unsafe/unsafe.test.ts +68 -0
  189. package/gs/unsafe/unsafe.ts +77 -0
  190. package/package.json +6 -4
@@ -0,0 +1,332 @@
1
+ // Package unicode provides data and functions to test some properties of Unicode code points.
2
+ // Constants
3
+ export const MaxRune = 0x10ffff;
4
+ export const ReplacementChar = 0xfffd;
5
+ export const MaxASCII = 0x7f;
6
+ export const MaxLatin1 = 0xff;
7
+ export const Version = '15.0.0';
8
+ // Case constants
9
+ export const UpperCase = 0;
10
+ export const LowerCase = 1;
11
+ export const TitleCase = 2;
12
+ export const MaxCase = 3;
13
+ export const UpperLower = MaxRune + 1;
14
+ // Range16 represents a range of 16-bit Unicode code points
15
+ export class Range16 {
16
+ Lo;
17
+ Hi;
18
+ Stride;
19
+ constructor(lo, hi, stride) {
20
+ this.Lo = lo;
21
+ this.Hi = hi;
22
+ this.Stride = stride;
23
+ }
24
+ clone() {
25
+ return new Range16(this.Lo, this.Hi, this.Stride);
26
+ }
27
+ }
28
+ // Range32 represents a range of 32-bit Unicode code points
29
+ export class Range32 {
30
+ Lo;
31
+ Hi;
32
+ Stride;
33
+ constructor(lo, hi, stride) {
34
+ this.Lo = lo;
35
+ this.Hi = hi;
36
+ this.Stride = stride;
37
+ }
38
+ clone() {
39
+ return new Range32(this.Lo, this.Hi, this.Stride);
40
+ }
41
+ }
42
+ // RangeTable defines a set of Unicode code points by listing the ranges of code points within the set
43
+ export class RangeTable {
44
+ R16;
45
+ R32;
46
+ LatinOffset;
47
+ constructor(r16 = [], r32 = [], latinOffset = 0) {
48
+ this.R16 = r16;
49
+ this.R32 = r32;
50
+ this.LatinOffset = latinOffset;
51
+ }
52
+ clone() {
53
+ return new RangeTable(this.R16.map((r) => r.clone()), this.R32.map((r) => r.clone()), this.LatinOffset);
54
+ }
55
+ }
56
+ // CaseRange represents a range of Unicode code points for case mapping
57
+ export class CaseRange {
58
+ Lo;
59
+ Hi;
60
+ Delta;
61
+ constructor(lo, hi, delta) {
62
+ this.Lo = lo;
63
+ this.Hi = hi;
64
+ this.Delta = delta;
65
+ }
66
+ clone() {
67
+ return new CaseRange(this.Lo, this.Hi, [...this.Delta]);
68
+ }
69
+ }
70
+ // Basic character classification functions using JavaScript's built-in Unicode support
71
+ // IsControl reports whether the rune is a control character
72
+ export function IsControl(r) {
73
+ // Control characters are in categories Cc, Cf, Co, Cs
74
+ if (r < 0 || r > MaxRune)
75
+ return false;
76
+ const char = String.fromCodePoint(r);
77
+ // Use regex to match control characters
78
+ return /[\p{Cc}\p{Cf}\p{Co}\p{Cs}]/u.test(char);
79
+ }
80
+ // IsDigit reports whether the rune is a decimal digit
81
+ export function IsDigit(r) {
82
+ if (r < 0 || r > MaxRune)
83
+ return false;
84
+ const char = String.fromCodePoint(r);
85
+ return /\p{Nd}/u.test(char);
86
+ }
87
+ // IsGraphic reports whether the rune is defined as a Graphic by Unicode
88
+ export function IsGraphic(r) {
89
+ if (r < 0 || r > MaxRune)
90
+ return false;
91
+ return IsLetter(r) || IsMark(r) || IsNumber(r) || IsPunct(r) || IsSymbol(r);
92
+ }
93
+ // IsLetter reports whether the rune is a letter (category L)
94
+ export function IsLetter(r) {
95
+ if (r < 0 || r > MaxRune)
96
+ return false;
97
+ const char = String.fromCodePoint(r);
98
+ return /\p{L}/u.test(char);
99
+ }
100
+ // IsLower reports whether the rune is a lower case letter
101
+ export function IsLower(r) {
102
+ if (r < 0 || r > MaxRune)
103
+ return false;
104
+ const char = String.fromCodePoint(r);
105
+ return /\p{Ll}/u.test(char);
106
+ }
107
+ // IsMark reports whether the rune is a mark character (category M)
108
+ export function IsMark(r) {
109
+ if (r < 0 || r > MaxRune)
110
+ return false;
111
+ const char = String.fromCodePoint(r);
112
+ return /\p{M}/u.test(char);
113
+ }
114
+ // IsNumber reports whether the rune is a number (category N)
115
+ export function IsNumber(r) {
116
+ if (r < 0 || r > MaxRune)
117
+ return false;
118
+ const char = String.fromCodePoint(r);
119
+ return /\p{N}/u.test(char);
120
+ }
121
+ // IsPrint reports whether the rune is defined as printable by Go
122
+ export function IsPrint(r) {
123
+ if (r < 0 || r > MaxRune)
124
+ return false;
125
+ if (IsGraphic(r))
126
+ return true;
127
+ return r === 0x20; // space character
128
+ }
129
+ // IsPunct reports whether the rune is a punctuation character (category P)
130
+ export function IsPunct(r) {
131
+ if (r < 0 || r > MaxRune)
132
+ return false;
133
+ const char = String.fromCodePoint(r);
134
+ return /\p{P}/u.test(char);
135
+ }
136
+ // IsSpace reports whether the rune is a space character
137
+ export function IsSpace(r) {
138
+ if (r < 0 || r > MaxRune)
139
+ return false;
140
+ const char = String.fromCodePoint(r);
141
+ return /\s/u.test(char) || /\p{Z}/u.test(char);
142
+ }
143
+ // IsSymbol reports whether the rune is a symbol character (category S)
144
+ export function IsSymbol(r) {
145
+ if (r < 0 || r > MaxRune)
146
+ return false;
147
+ const char = String.fromCodePoint(r);
148
+ return /\p{S}/u.test(char);
149
+ }
150
+ // IsTitle reports whether the rune is a title case letter
151
+ export function IsTitle(r) {
152
+ if (r < 0 || r > MaxRune)
153
+ return false;
154
+ const char = String.fromCodePoint(r);
155
+ return /\p{Lt}/u.test(char);
156
+ }
157
+ // IsUpper reports whether the rune is an upper case letter
158
+ export function IsUpper(r) {
159
+ if (r < 0 || r > MaxRune)
160
+ return false;
161
+ const char = String.fromCodePoint(r);
162
+ return /\p{Lu}/u.test(char);
163
+ }
164
+ // Case conversion functions
165
+ // ToLower returns the lowercase mapping of the rune
166
+ export function ToLower(r) {
167
+ if (r < 0 || r > MaxRune)
168
+ return r;
169
+ const char = String.fromCodePoint(r);
170
+ const lower = char.toLowerCase();
171
+ return lower.codePointAt(0) || r;
172
+ }
173
+ // ToUpper returns the uppercase mapping of the rune
174
+ export function ToUpper(r) {
175
+ if (r < 0 || r > MaxRune)
176
+ return r;
177
+ const char = String.fromCodePoint(r);
178
+ const upper = char.toUpperCase();
179
+ return upper.codePointAt(0) || r;
180
+ }
181
+ // ToTitle returns the title case mapping of the rune
182
+ export function ToTitle(r) {
183
+ // For most characters, title case is the same as uppercase
184
+ return ToUpper(r);
185
+ }
186
+ // To returns the case mapping of the rune
187
+ export function To(_case, r) {
188
+ switch (_case) {
189
+ case UpperCase:
190
+ return ToUpper(r);
191
+ case LowerCase:
192
+ return ToLower(r);
193
+ case TitleCase:
194
+ return ToTitle(r);
195
+ default:
196
+ return r;
197
+ }
198
+ }
199
+ // SimpleFold returns the next rune in the simple case folding sequence
200
+ export function SimpleFold(r) {
201
+ if (r < 0 || r > MaxRune)
202
+ return r;
203
+ // Simple implementation - just toggle between upper and lower case
204
+ if (IsUpper(r)) {
205
+ return ToLower(r);
206
+ }
207
+ else if (IsLower(r)) {
208
+ return ToUpper(r);
209
+ }
210
+ return r;
211
+ }
212
+ // Is reports whether the rune is in the specified table of ranges
213
+ export function Is(rangeTab, r) {
214
+ if (r < 0 || r > MaxRune)
215
+ return false;
216
+ // Check 16-bit ranges
217
+ for (const range of rangeTab.R16) {
218
+ if (r < range.Lo)
219
+ break;
220
+ if (r <= range.Hi) {
221
+ return range.Stride === 1 || (r - range.Lo) % range.Stride === 0;
222
+ }
223
+ }
224
+ // Check 32-bit ranges
225
+ for (const range of rangeTab.R32) {
226
+ if (r < range.Lo)
227
+ break;
228
+ if (r <= range.Hi) {
229
+ return range.Stride === 1 || (r - range.Lo) % range.Stride === 0;
230
+ }
231
+ }
232
+ return false;
233
+ }
234
+ // In reports whether the rune is a member of one of the ranges
235
+ export function In(r, ...ranges) {
236
+ for (const rangeTab of ranges) {
237
+ if (Is(rangeTab, r)) {
238
+ return true;
239
+ }
240
+ }
241
+ return false;
242
+ }
243
+ // IsOneOf reports whether the rune is a member of one of the ranges
244
+ export function IsOneOf(ranges, r) {
245
+ return In(r, ...ranges);
246
+ }
247
+ // Predefined range tables for common character categories
248
+ // These are simplified versions - in a full implementation, these would contain
249
+ // the complete Unicode range data
250
+ export const Letter = new RangeTable([new Range16(0x0041, 0x005a, 1), new Range16(0x0061, 0x007a, 1)], // Basic Latin letters
251
+ []);
252
+ export const Digit = new RangeTable([new Range16(0x0030, 0x0039, 1)], // ASCII digits
253
+ []);
254
+ export const Space = new RangeTable([new Range16(0x0009, 0x000d, 1), new Range16(0x0020, 0x0020, 1)], // Basic whitespace
255
+ []);
256
+ export const Upper = new RangeTable([new Range16(0x0041, 0x005a, 1)], // ASCII uppercase
257
+ []);
258
+ export const Lower = new RangeTable([new Range16(0x0061, 0x007a, 1)], // ASCII lowercase
259
+ []);
260
+ export const Title = new RangeTable([], []);
261
+ export const Punct = new RangeTable([
262
+ new Range16(0x0021, 0x002f, 1), // !"#$%&'()*+,-./
263
+ new Range16(0x003a, 0x0040, 1), // :;<=>?@
264
+ new Range16(0x005b, 0x0060, 1), // [\]^_`
265
+ new Range16(0x007b, 0x007e, 1), // {|}~
266
+ ], []);
267
+ export const Symbol = new RangeTable([], []);
268
+ export const Mark = new RangeTable([], []);
269
+ export const Number = new RangeTable([new Range16(0x0030, 0x0039, 1)], // ASCII digits
270
+ []);
271
+ // Categories map
272
+ export const Categories = new Map([
273
+ ['L', Letter],
274
+ ['Ll', Lower],
275
+ ['Lu', Upper],
276
+ ['Lt', Title],
277
+ ['M', Mark],
278
+ ['N', Number],
279
+ ['Nd', Digit],
280
+ ['P', Punct],
281
+ ['S', Symbol],
282
+ ['Z', Space],
283
+ ]);
284
+ // Scripts and Properties maps (simplified)
285
+ export const Scripts = new Map();
286
+ export const Properties = new Map();
287
+ export const FoldCategory = new Map();
288
+ export const FoldScript = new Map();
289
+ // Graphic ranges
290
+ export const GraphicRanges = [Letter, Mark, Number, Punct, Symbol];
291
+ // Print ranges
292
+ export const PrintRanges = [Letter, Mark, Number, Punct, Symbol, Space];
293
+ // Case ranges (simplified)
294
+ export const CaseRanges = [];
295
+ // Special cases
296
+ export const TurkishCase = [];
297
+ export const AzeriCase = TurkishCase;
298
+ // Predefined character categories (simplified implementations)
299
+ export const Cc = new RangeTable([new Range16(0x0000, 0x001f, 1), new Range16(0x007f, 0x009f, 1)], []);
300
+ export const Cf = new RangeTable([], []);
301
+ export const Co = new RangeTable([], []);
302
+ export const Cs = new RangeTable([new Range16(0xd800, 0xdfff, 1)], []);
303
+ export const Lm = new RangeTable([], []);
304
+ export const Lo = new RangeTable([], []);
305
+ export const Mc = new RangeTable([], []);
306
+ export const Me = new RangeTable([], []);
307
+ export const Mn = new RangeTable([], []);
308
+ export const Nl = new RangeTable([], []);
309
+ export const No = new RangeTable([], []);
310
+ export const Pc = new RangeTable([new Range16(0x005f, 0x005f, 1)], []); // underscore
311
+ export const Pd = new RangeTable([new Range16(0x002d, 0x002d, 1)], []); // hyphen
312
+ export const Pe = new RangeTable([
313
+ new Range16(0x0029, 0x0029, 1),
314
+ new Range16(0x005d, 0x005d, 1),
315
+ new Range16(0x007d, 0x007d, 1),
316
+ ], []);
317
+ export const Pf = new RangeTable([], []);
318
+ export const Pi = new RangeTable([], []);
319
+ export const Po = new RangeTable([new Range16(0x0021, 0x0023, 1), new Range16(0x0025, 0x0027, 1)], []);
320
+ export const Ps = new RangeTable([
321
+ new Range16(0x0028, 0x0028, 1),
322
+ new Range16(0x005b, 0x005b, 1),
323
+ new Range16(0x007b, 0x007b, 1),
324
+ ], []);
325
+ export const Sc = new RangeTable([new Range16(0x0024, 0x0024, 1)], []); // dollar sign
326
+ export const Sk = new RangeTable([new Range16(0x005e, 0x005e, 1), new Range16(0x0060, 0x0060, 1)], []);
327
+ export const Sm = new RangeTable([new Range16(0x002b, 0x002b, 1), new Range16(0x003c, 0x003e, 1)], []);
328
+ export const So = new RangeTable([], []);
329
+ export const Zl = new RangeTable([], []);
330
+ export const Zp = new RangeTable([], []);
331
+ export const Zs = new RangeTable([new Range16(0x0020, 0x0020, 1)], []); // space
332
+ //# sourceMappingURL=unicode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unicode.js","sourceRoot":"","sources":["../../../gs/unicode/unicode.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,YAAY;AACZ,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAA;AAC/B,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AACrC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAA;AAC5B,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAA;AAC7B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAA;AAE/B,iBAAiB;AACjB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAA;AAC1B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAA;AAC1B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAA;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAA;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,GAAG,CAAC,CAAA;AAErC,2DAA2D;AAC3D,MAAM,OAAO,OAAO;IACX,EAAE,CAAQ;IACV,EAAE,CAAQ;IACV,MAAM,CAAQ;IAErB,YAAY,EAAU,EAAE,EAAU,EAAE,MAAc;QAChD,I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C,MAAM,EAAE,GAAG,IAAI,UAAU,CAC9B,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAChE,EAAE,CACH,CAAA;AACD,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AACxC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AACxC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AACxC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,QAAQ"}
@@ -0,0 +1 @@
1
+ export * from './utf8.js';
@@ -0,0 +1,3 @@
1
+ // Package utf8 implements functions and constants to support text encoded in UTF-8.
2
+ export * from './utf8.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/unicode/utf8/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,cAAc,WAAW,CAAA"}
@@ -0,0 +1,20 @@
1
+ import * as $ from '@goscript/builtin/builtin.js';
2
+ export declare const RuneError = 65533;
3
+ export declare const RuneSelf = 128;
4
+ export declare const MaxRune = 1114111;
5
+ export declare const UTFMax = 4;
6
+ export declare function AppendRune(p: Uint8Array, r: number): Uint8Array;
7
+ export declare function DecodeLastRune(p: Uint8Array): [number, number];
8
+ export declare function DecodeLastRuneInString(s: string): [number, number];
9
+ export declare function DecodeRune(p: Uint8Array): [number, number];
10
+ export declare function DecodeRuneInString(s: string): [number, number];
11
+ export declare function EncodeRune(p: Uint8Array | $.Slice<number>, r: number): number;
12
+ export declare function FullRune(p: Uint8Array): boolean;
13
+ export declare function FullRuneInString(s: string): boolean;
14
+ export declare function RuneCount(p: Uint8Array): number;
15
+ export declare function RuneCountInString(s: string): number;
16
+ export declare function RuneLen(r: number): number;
17
+ export declare function RuneStart(b: number): boolean;
18
+ export declare function Valid(p: Uint8Array): boolean;
19
+ export declare function ValidRune(r: number): boolean;
20
+ export declare function ValidString(s: string): boolean;
@@ -0,0 +1,196 @@
1
+ // Package utf8 implements functions and constants to support text encoded in UTF-8.
2
+ import * as $ from '@goscript/builtin/builtin.js';
3
+ // RuneError is the "error" Rune or "Unicode replacement character"
4
+ export const RuneError = 0xfffd;
5
+ // RuneSelf is the maximum rune value that can be represented as a single byte.
6
+ export const RuneSelf = 0x80;
7
+ // MaxRune is the maximum valid Unicode code point.
8
+ export const MaxRune = 0x10ffff;
9
+ // UTFMax is the maximum number of bytes of a UTF-8 encoded Unicode character.
10
+ export const UTFMax = 4;
11
+ // AppendRune appends the UTF-8 encoding of r to the end of p and returns the extended buffer.
12
+ export function AppendRune(p, r) {
13
+ const temp = new Uint8Array(UTFMax);
14
+ const n = EncodeRune(temp, r);
15
+ const result = new Uint8Array(p.length + n);
16
+ result.set(p);
17
+ result.set(temp.slice(0, n), p.length);
18
+ return result;
19
+ }
20
+ // DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and its width in bytes.
21
+ export function DecodeLastRune(p) {
22
+ if (p.length === 0) {
23
+ return [RuneError, 0];
24
+ }
25
+ // Simple implementation - find the start of the last rune
26
+ let start = p.length - 1;
27
+ while (start > 0 && !RuneStart(p[start])) {
28
+ start--;
29
+ }
30
+ const [r, size] = DecodeRune(p.slice(start));
31
+ if (start + size !== p.length) {
32
+ return [RuneError, 1];
33
+ }
34
+ return [r, size];
35
+ }
36
+ // DecodeLastRuneInString is like DecodeLastRune but its input is a string.
37
+ export function DecodeLastRuneInString(s) {
38
+ if (s.length === 0) {
39
+ return [RuneError, 0];
40
+ }
41
+ // Use JavaScript's built-in Unicode handling
42
+ const chars = [...s];
43
+ if (chars.length === 0) {
44
+ return [RuneError, 0];
45
+ }
46
+ const lastChar = chars[chars.length - 1];
47
+ const codePoint = lastChar.codePointAt(0) || RuneError;
48
+ const encoder = new TextEncoder();
49
+ const encoded = encoder.encode(lastChar);
50
+ return [codePoint, encoded.length];
51
+ }
52
+ // DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and its width in bytes.
53
+ export function DecodeRune(p) {
54
+ if (p.length === 0) {
55
+ return [RuneError, 0];
56
+ }
57
+ if (p[0] < RuneSelf) {
58
+ return [p[0], 1];
59
+ }
60
+ // Convert bytes to string and decode
61
+ const decoder = new TextDecoder('utf-8', { fatal: false });
62
+ const str = decoder.decode(p.slice(0, Math.min(4, p.length)));
63
+ if (str.length === 0 || str === '\uFFFD') {
64
+ return [RuneError, 1];
65
+ }
66
+ const codePoint = str.codePointAt(0) || RuneError;
67
+ const char = String.fromCodePoint(codePoint);
68
+ const encoder = new TextEncoder();
69
+ const encoded = encoder.encode(char);
70
+ return [codePoint, encoded.length];
71
+ }
72
+ // DecodeRuneInString is like DecodeRune but its input is a string.
73
+ export function DecodeRuneInString(s) {
74
+ if (s.length === 0) {
75
+ return [RuneError, 0];
76
+ }
77
+ const c = s.charCodeAt(0);
78
+ if (c < RuneSelf) {
79
+ return [c, 1];
80
+ }
81
+ // Use JavaScript's built-in Unicode handling
82
+ const codePoint = s.codePointAt(0) || RuneError;
83
+ const char = String.fromCodePoint(codePoint);
84
+ const encoder = new TextEncoder();
85
+ const encoded = encoder.encode(char);
86
+ return [codePoint, encoded.length];
87
+ }
88
+ // EncodeRune writes into p (which must be large enough) the UTF-8 encoding of the rune.
89
+ export function EncodeRune(p, r) {
90
+ if (p === null)
91
+ return 0;
92
+ if (!ValidRune(r)) {
93
+ r = RuneError;
94
+ }
95
+ const str = String.fromCodePoint(r);
96
+ const encoder = new TextEncoder();
97
+ const encoded = encoder.encode(str);
98
+ // Handle both Uint8Array and Slice types
99
+ if (p instanceof Uint8Array) {
100
+ for (let i = 0; i < Math.min(encoded.length, p.length); i++) {
101
+ p[i] = encoded[i];
102
+ }
103
+ return Math.min(encoded.length, p.length);
104
+ }
105
+ else {
106
+ // Handle Slice<number>
107
+ const len = $.len(p);
108
+ for (let i = 0; i < Math.min(encoded.length, len); i++) {
109
+ ;
110
+ p[i] = encoded[i];
111
+ }
112
+ return Math.min(encoded.length, len);
113
+ }
114
+ }
115
+ // FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune.
116
+ export function FullRune(p) {
117
+ if (p.length === 0) {
118
+ return false;
119
+ }
120
+ if (p[0] < RuneSelf) {
121
+ return true;
122
+ }
123
+ const [, size] = DecodeRune(p);
124
+ return size <= p.length && size > 0;
125
+ }
126
+ // FullRuneInString is like FullRune but its input is a string.
127
+ export function FullRuneInString(s) {
128
+ if (s.length === 0) {
129
+ return false;
130
+ }
131
+ const c = s.charCodeAt(0);
132
+ if (c < RuneSelf) {
133
+ return true;
134
+ }
135
+ const [, size] = DecodeRuneInString(s);
136
+ return size <= s.length && size > 0;
137
+ }
138
+ // RuneCount returns the number of runes in p.
139
+ export function RuneCount(p) {
140
+ const decoder = new TextDecoder('utf-8', { fatal: false });
141
+ const str = decoder.decode(p);
142
+ return [...str].length;
143
+ }
144
+ // RuneCountInString is like RuneCount but its input is a string.
145
+ export function RuneCountInString(s) {
146
+ return [...s].length;
147
+ }
148
+ // RuneLen returns the number of bytes required to encode the rune.
149
+ export function RuneLen(r) {
150
+ if (!ValidRune(r)) {
151
+ return -1;
152
+ }
153
+ if (r < RuneSelf) {
154
+ return 1;
155
+ }
156
+ const str = String.fromCodePoint(r);
157
+ const encoder = new TextEncoder();
158
+ return encoder.encode(str).length;
159
+ }
160
+ // RuneStart reports whether the byte could be the first byte of an encoded, possibly invalid rune.
161
+ export function RuneStart(b) {
162
+ return (b & 0xc0) !== 0x80;
163
+ }
164
+ // Valid reports whether p consists entirely of valid UTF-8-encoded runes.
165
+ export function Valid(p) {
166
+ try {
167
+ const decoder = new TextDecoder('utf-8', { fatal: true });
168
+ decoder.decode(p);
169
+ return true;
170
+ }
171
+ catch {
172
+ return false;
173
+ }
174
+ }
175
+ // ValidRune reports whether r can be legally encoded as UTF-8.
176
+ export function ValidRune(r) {
177
+ return r >= 0 && r <= MaxRune && !(r >= 0xd800 && r <= 0xdfff);
178
+ }
179
+ // ValidString reports whether s consists entirely of valid UTF-8-encoded runes.
180
+ export function ValidString(s) {
181
+ // JavaScript strings are always valid UTF-16, but we check for surrogates
182
+ for (let i = 0; i < s.length; i++) {
183
+ const code = s.charCodeAt(i);
184
+ if (code >= 0xd800 && code <= 0xdfff) {
185
+ // Surrogate pair
186
+ if (i + 1 >= s.length)
187
+ return false;
188
+ const next = s.charCodeAt(i + 1);
189
+ if (code >= 0xdc00 || next < 0xdc00 || next > 0xdfff)
190
+ return false;
191
+ i++; // Skip the next character as it's part of the surrogate pair
192
+ }
193
+ }
194
+ return true;
195
+ }
196
+ //# sourceMappingURL=utf8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.js","sourceRoot":"","sources":["../../../../gs/unicode/utf8/utf8.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAA;AAEjD,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAA;AAE/B,+EAA+E;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAA;AAE5B,mDAAmD;AACnD,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAA;AAE/B,8EAA8E;AAC9E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AAEvB,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,CAAa,EAAE,CAAS;IACjD,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;IACnC,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,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AAM,IAAI,IAAI,GAAG,MAAM;gBAAE,OAAO,KAAK,CAAA;YAClE,CAAC,EAAE,CAAA,CAAC,6DAA6D;QACnE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './unsafe.js';
@@ -0,0 +1,2 @@
1
+ export * from './unsafe.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../gs/unsafe/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -0,0 +1,11 @@
1
+ export type ArbitraryType = any;
2
+ export type Pointer = any;
3
+ export type IntegerType = number;
4
+ export declare function Alignof(variable: ArbitraryType): number;
5
+ export declare function Offsetof(selector: ArbitraryType): number;
6
+ export declare function Sizeof(variable: ArbitraryType): number;
7
+ export declare function Add(ptr: Pointer, len: IntegerType): Pointer;
8
+ export declare function Slice(ptr: Pointer, len: IntegerType): any[];
9
+ export declare function SliceData(slice: any[]): Pointer;
10
+ export declare function String(ptr: Pointer, len: IntegerType): string;
11
+ export declare function StringData(str: string): Pointer;
@@ -0,0 +1,44 @@
1
+ // Package unsafe provides facilities for low-level programming including operations
2
+ // that violate the type system. Most operations are not supported in JavaScript/TypeScript
3
+ // and will throw errors when used.
4
+ // Alignof returns the alignment of the (type of the) variable in bytes
5
+ // This operation is not meaningful in JavaScript/TypeScript
6
+ export function Alignof(variable) {
7
+ throw new Error('unsafe.Alignof is not supported in JavaScript/TypeScript: memory alignment is not a meaningful concept in JavaScript');
8
+ }
9
+ // Offsetof returns the field offset in bytes relative to the struct's address
10
+ // This operation is not meaningful in JavaScript/TypeScript
11
+ export function Offsetof(selector) {
12
+ throw new Error('unsafe.Offsetof is not supported in JavaScript/TypeScript: memory layout and field offsets are not meaningful concepts in JavaScript');
13
+ }
14
+ // Sizeof returns the size of the (type of the) variable in bytes
15
+ // This operation is not meaningful in JavaScript/TypeScript
16
+ export function Sizeof(variable) {
17
+ throw new Error('unsafe.Sizeof is not supported in JavaScript/TypeScript: memory size is not a meaningful concept in JavaScript');
18
+ }
19
+ // Add adds len to ptr and returns the updated pointer
20
+ // Pointer arithmetic is not supported in JavaScript/TypeScript
21
+ export function Add(ptr, len) {
22
+ throw new Error('unsafe.Add is not supported in JavaScript/TypeScript: pointer arithmetic is not available in JavaScript');
23
+ }
24
+ // Slice returns a slice whose underlying array starts at ptr
25
+ // This operation is not meaningful in JavaScript/TypeScript
26
+ export function Slice(ptr, len) {
27
+ throw new Error('unsafe.Slice is not supported in JavaScript/TypeScript: direct memory access is not available in JavaScript');
28
+ }
29
+ // SliceData returns a pointer to the underlying array of the slice
30
+ // This operation is not meaningful in JavaScript/TypeScript
31
+ export function SliceData(slice) {
32
+ throw new Error('unsafe.SliceData is not supported in JavaScript/TypeScript: direct memory access is not available in JavaScript');
33
+ }
34
+ // String returns a string value whose underlying bytes start at ptr
35
+ // This operation is not meaningful in JavaScript/TypeScript
36
+ export function String(ptr, len) {
37
+ throw new Error('unsafe.String is not supported in JavaScript/TypeScript: direct memory access is not available in JavaScript');
38
+ }
39
+ // StringData returns a pointer to the underlying bytes of the str
40
+ // This operation is not meaningful in JavaScript/TypeScript
41
+ export function StringData(str) {
42
+ throw new Error('unsafe.StringData is not supported in JavaScript/TypeScript: direct memory access is not available in JavaScript');
43
+ }
44
+ //# sourceMappingURL=unsafe.js.map