goscript 0.2.1 → 0.2.3

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 (164) hide show
  1. package/compiler/gotest/runner.go +98 -0
  2. package/compiler/gotest/runner_test.go +45 -0
  3. package/compiler/gotest/testdata/browserapi/browserapi_test.go +36 -0
  4. package/compiler/lowering.go +227 -11
  5. package/compiler/override-registry_test.go +50 -0
  6. package/compiler/protobuf-ts-binding.go +155 -7
  7. package/compiler/protobuf-ts-binding_test.go +116 -2
  8. package/compiler/runtime-contract.go +2 -0
  9. package/compiler/runtime-contract_test.go +1 -0
  10. package/compiler/semantic-model.go +16 -0
  11. package/compiler/semantic-model_test.go +38 -0
  12. package/compiler/skeleton_test.go +477 -16
  13. package/compiler/typescript-emitter.go +4 -0
  14. package/dist/gs/builtin/builtin.js +7 -9
  15. package/dist/gs/builtin/builtin.js.map +1 -1
  16. package/dist/gs/builtin/defer.js +2 -2
  17. package/dist/gs/builtin/hostio.js +5 -5
  18. package/dist/gs/builtin/hostio.js.map +1 -1
  19. package/dist/gs/builtin/map.js +2 -1
  20. package/dist/gs/builtin/map.js.map +1 -1
  21. package/dist/gs/builtin/slice.d.ts +3 -0
  22. package/dist/gs/builtin/slice.js +39 -0
  23. package/dist/gs/builtin/slice.js.map +1 -1
  24. package/dist/gs/builtin/type.js +49 -0
  25. package/dist/gs/builtin/type.js.map +1 -1
  26. package/dist/gs/compress/zlib/index.js +5 -2
  27. package/dist/gs/compress/zlib/index.js.map +1 -1
  28. package/dist/gs/crypto/aes/index.d.ts +15 -0
  29. package/dist/gs/crypto/aes/index.js +57 -0
  30. package/dist/gs/crypto/aes/index.js.map +1 -0
  31. package/dist/gs/crypto/cipher/index.d.ts +41 -0
  32. package/dist/gs/crypto/cipher/index.js +255 -0
  33. package/dist/gs/crypto/cipher/index.js.map +1 -0
  34. package/dist/gs/crypto/ecdh/index.js +27 -8
  35. package/dist/gs/crypto/ecdh/index.js.map +1 -1
  36. package/dist/gs/crypto/ed25519/index.js +3 -3
  37. package/dist/gs/crypto/ed25519/index.js.map +1 -1
  38. package/dist/gs/crypto/rand/index.js +6 -3
  39. package/dist/gs/crypto/rand/index.js.map +1 -1
  40. package/dist/gs/embed/index.js +9 -3
  41. package/dist/gs/embed/index.js.map +1 -1
  42. package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.d.ts +1 -0
  43. package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.js +33 -0
  44. package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.js.map +1 -1
  45. package/dist/gs/github.com/mr-tron/base58/base58/index.js +4 -1
  46. package/dist/gs/github.com/mr-tron/base58/base58/index.js.map +1 -1
  47. package/dist/gs/golang.org/x/crypto/chacha20poly1305/index.d.ts +31 -0
  48. package/dist/gs/golang.org/x/crypto/chacha20poly1305/index.js +117 -0
  49. package/dist/gs/golang.org/x/crypto/chacha20poly1305/index.js.map +1 -0
  50. package/dist/gs/golang.org/x/crypto/scrypt/index.d.ts +2 -0
  51. package/dist/gs/golang.org/x/crypto/scrypt/index.js +39 -0
  52. package/dist/gs/golang.org/x/crypto/scrypt/index.js.map +1 -0
  53. package/dist/gs/hash/fnv/index.js +13 -5
  54. package/dist/gs/hash/fnv/index.js.map +1 -1
  55. package/dist/gs/io/fs/glob.d.ts +3 -3
  56. package/dist/gs/io/fs/glob.js +8 -8
  57. package/dist/gs/io/fs/glob.js.map +1 -1
  58. package/dist/gs/io/fs/readdir.d.ts +2 -2
  59. package/dist/gs/io/fs/readdir.js +13 -74
  60. package/dist/gs/io/fs/readdir.js.map +1 -1
  61. package/dist/gs/io/fs/sub.js +4 -4
  62. package/dist/gs/io/fs/sub.js.map +1 -1
  63. package/dist/gs/io/fs/walk.js +1 -1
  64. package/dist/gs/io/fs/walk.js.map +1 -1
  65. package/dist/gs/io/io.js +18 -2
  66. package/dist/gs/io/io.js.map +1 -1
  67. package/dist/gs/maps/iter.js.map +1 -1
  68. package/dist/gs/maps/maps.js.map +1 -1
  69. package/dist/gs/mime/index.js +5 -2
  70. package/dist/gs/mime/index.js.map +1 -1
  71. package/dist/gs/net/http/httptest/index.js +6 -3
  72. package/dist/gs/net/http/httptest/index.js.map +1 -1
  73. package/dist/gs/net/http/index.d.ts +16 -4
  74. package/dist/gs/net/http/index.js +236 -40
  75. package/dist/gs/net/http/index.js.map +1 -1
  76. package/dist/gs/net/http/pprof/index.js.map +1 -1
  77. package/dist/gs/reflect/iter.js +1 -1
  78. package/dist/gs/reflect/iter.js.map +1 -1
  79. package/dist/gs/reflect/type.d.ts +2 -0
  80. package/dist/gs/reflect/type.js +53 -21
  81. package/dist/gs/reflect/type.js.map +1 -1
  82. package/dist/gs/runtime/debug/index.js +2 -1
  83. package/dist/gs/runtime/debug/index.js.map +1 -1
  84. package/dist/gs/runtime/pprof/index.js.map +1 -1
  85. package/dist/gs/runtime/runtime.js +2 -2
  86. package/dist/gs/runtime/runtime.js.map +1 -1
  87. package/dist/gs/runtime/trace/index.js.map +1 -1
  88. package/dist/gs/slices/slices.d.ts +1 -1
  89. package/dist/gs/slices/slices.js +37 -4
  90. package/dist/gs/slices/slices.js.map +1 -1
  91. package/go.mod +2 -2
  92. package/go.sum +2 -0
  93. package/gs/builtin/builtin.ts +11 -14
  94. package/gs/builtin/defer.ts +2 -2
  95. package/gs/builtin/hostio.test.ts +8 -3
  96. package/gs/builtin/hostio.ts +5 -7
  97. package/gs/builtin/map.ts +4 -1
  98. package/gs/builtin/slice.test.ts +14 -0
  99. package/gs/builtin/slice.ts +64 -0
  100. package/gs/builtin/type.ts +72 -0
  101. package/gs/bytes/bytes.test.ts +14 -13
  102. package/gs/compress/zlib/index.test.ts +19 -5
  103. package/gs/compress/zlib/index.ts +16 -7
  104. package/gs/context/context.test.ts +3 -1
  105. package/gs/crypto/aes/index.test.ts +120 -0
  106. package/gs/crypto/aes/index.ts +76 -0
  107. package/gs/crypto/cipher/index.ts +345 -0
  108. package/gs/crypto/cipher/meta.json +6 -0
  109. package/gs/crypto/ecdh/index.test.ts +6 -2
  110. package/gs/crypto/ecdh/index.ts +49 -12
  111. package/gs/crypto/ed25519/index.ts +20 -7
  112. package/gs/crypto/rand/index.ts +6 -3
  113. package/gs/embed/index.test.ts +3 -3
  114. package/gs/embed/index.ts +9 -3
  115. package/gs/fmt/fmt.test.ts +29 -4
  116. package/gs/github.com/aperturerobotics/protobuf-go-lite/index.test.ts +126 -0
  117. package/gs/github.com/aperturerobotics/protobuf-go-lite/index.ts +46 -0
  118. package/gs/github.com/mr-tron/base58/base58/index.ts +9 -3
  119. package/gs/github.com/zeebo/blake3/internal/consts/index.test.ts +2 -8
  120. package/gs/golang.org/x/crypto/chacha20poly1305/index.test.ts +91 -0
  121. package/gs/golang.org/x/crypto/chacha20poly1305/index.ts +245 -0
  122. package/gs/golang.org/x/crypto/scrypt/index.test.ts +81 -0
  123. package/gs/golang.org/x/crypto/scrypt/index.ts +54 -0
  124. package/gs/golang.org/x/crypto/scrypt/meta.json +5 -0
  125. package/gs/hash/fnv/index.test.ts +1 -8
  126. package/gs/hash/fnv/index.ts +27 -10
  127. package/gs/io/fs/glob.ts +13 -10
  128. package/gs/io/fs/meta.json +2 -0
  129. package/gs/io/fs/readdir.test.ts +63 -2
  130. package/gs/io/fs/readdir.ts +33 -30
  131. package/gs/io/fs/sub.ts +4 -4
  132. package/gs/io/fs/walk.ts +1 -1
  133. package/gs/io/io.test.ts +56 -1
  134. package/gs/io/io.ts +19 -2
  135. package/gs/maps/iter.ts +9 -9
  136. package/gs/maps/maps.ts +4 -4
  137. package/gs/math/bits/index.test.ts +10 -1
  138. package/gs/mime/index.test.ts +33 -15
  139. package/gs/mime/index.ts +9 -2
  140. package/gs/net/http/httptest/index.test.ts +17 -3
  141. package/gs/net/http/httptest/index.ts +8 -3
  142. package/gs/net/http/index.test.ts +645 -123
  143. package/gs/net/http/index.ts +548 -113
  144. package/gs/net/http/pprof/index.ts +24 -6
  145. package/gs/os/file_unix_js.test.ts +22 -0
  146. package/gs/reflect/iter.ts +4 -2
  147. package/gs/reflect/map.test.ts +56 -1
  148. package/gs/reflect/type.ts +76 -37
  149. package/gs/runtime/debug/index.test.ts +32 -4
  150. package/gs/runtime/debug/index.ts +5 -2
  151. package/gs/runtime/pprof/index.test.ts +7 -1
  152. package/gs/runtime/pprof/index.ts +5 -1
  153. package/gs/runtime/runtime.test.ts +7 -0
  154. package/gs/runtime/runtime.ts +2 -4
  155. package/gs/runtime/trace/index.test.ts +9 -1
  156. package/gs/runtime/trace/index.ts +5 -1
  157. package/gs/slices/meta.json +3 -0
  158. package/gs/slices/slices.test.ts +59 -21
  159. package/gs/slices/slices.ts +61 -20
  160. package/gs/strconv/complex.test.ts +17 -3
  161. package/gs/sync/atomic/doc_64.test.ts +2 -9
  162. package/gs/sync/sync.test.ts +18 -8
  163. package/gs/syscall/js/index.test.ts +9 -4
  164. package/package.json +13 -5
@@ -22,9 +22,20 @@ import {
22
22
  MinFunc,
23
23
  Replace,
24
24
  Sorted,
25
+ SortFunc,
25
26
  SortStableFunc,
26
27
  } from './slices.js'
27
28
 
29
+ describe('slices.SortFunc', () => {
30
+ it('awaits async comparison callbacks', async () => {
31
+ const values = $.arrayToSlice([3, 1, 2])
32
+
33
+ await SortFunc(values, async (a, b) => a - b)
34
+
35
+ expect(Array.from(values ?? [])).toEqual([1, 2, 3])
36
+ })
37
+ })
38
+
28
39
  describe('slices.SortStableFunc', () => {
29
40
  it('preserves original order for equal elements', () => {
30
41
  const values = $.arrayToSlice([
@@ -43,14 +54,22 @@ describe('slices.SortStableFunc', () => {
43
54
  describe('slices compatibility helpers', () => {
44
55
  it('implements comparison, min/max, compact, replace, clip, and search helpers', () => {
45
56
  expect(
46
- CompareFunc($.arrayToSlice(['a', 'c']), $.arrayToSlice(['a', 'b']), (a, b) =>
47
- a.localeCompare(b),
57
+ CompareFunc(
58
+ $.arrayToSlice(['a', 'c']),
59
+ $.arrayToSlice(['a', 'b']),
60
+ (a, b) => a.localeCompare(b),
48
61
  ),
49
62
  ).toBeGreaterThan(0)
50
63
  expect(Min($.arrayToSlice([3, 1, 2]))).toBe(1)
51
- expect(MaxFunc($.arrayToSlice([{ v: 1 }, { v: 4 }]), (a, b) => a.v - b.v).v).toBe(4)
52
- expect(MinFunc($.arrayToSlice([{ v: 3 }, { v: 2 }]), (a, b) => a.v - b.v).v).toBe(2)
53
- expect(Array.from(Compact($.arrayToSlice([1, 1, 2, 2, 3])) ?? [])).toEqual([1, 2, 3])
64
+ expect(
65
+ MaxFunc($.arrayToSlice([{ v: 1 }, { v: 4 }]), (a, b) => a.v - b.v).v,
66
+ ).toBe(4)
67
+ expect(
68
+ MinFunc($.arrayToSlice([{ v: 3 }, { v: 2 }]), (a, b) => a.v - b.v).v,
69
+ ).toBe(2)
70
+ expect(Array.from(Compact($.arrayToSlice([1, 1, 2, 2, 3])) ?? [])).toEqual([
71
+ 1, 2, 3,
72
+ ])
54
73
  expect(
55
74
  Array.from(
56
75
  CompactFunc(
@@ -59,9 +78,9 @@ describe('slices compatibility helpers', () => {
59
78
  ) ?? [],
60
79
  ),
61
80
  ).toEqual(['a', 'b'])
62
- expect(Array.from(Replace($.arrayToSlice([1, 2, 3, 4]), 1, 3, 9, 8)) ?? []).toEqual([
63
- 1, 9, 8, 4,
64
- ])
81
+ expect(
82
+ Array.from(Replace($.arrayToSlice([1, 2, 3, 4]), 1, 3, 9, 8)) ?? [],
83
+ ).toEqual([1, 9, 8, 4])
65
84
  expect(Array.from(Clip($.arrayToSlice([1, 2])) ?? [])).toEqual([1, 2])
66
85
  expect(BinarySearch($.arrayToSlice([1, 3, 5]), 3)).toEqual([1, true])
67
86
  })
@@ -69,22 +88,37 @@ describe('slices compatibility helpers', () => {
69
88
  it('concatenates slices and preserves empty concat nilness', () => {
70
89
  expect(Concat()).toBeNull()
71
90
  expect(Concat($.arrayToSlice<number>([]))).toBeNull()
72
- expect(Array.from(Concat($.arrayToSlice([1]), null, $.arrayToSlice([2, 3])) ?? [])).toEqual([
73
- 1, 2, 3,
74
- ])
75
- expect(Array.from(Concat(new Uint8Array([1, 2]), new Uint8Array([3])) ?? [])).toEqual([
76
- 1, 2, 3,
77
- ])
91
+ expect(
92
+ Array.from(
93
+ Concat($.arrayToSlice([1]), null, $.arrayToSlice([2, 3])) ?? [],
94
+ ),
95
+ ).toEqual([1, 2, 3])
96
+ expect(
97
+ Array.from(Concat(new Uint8Array([1, 2]), new Uint8Array([3])) ?? []),
98
+ ).toEqual([1, 2, 3])
78
99
  })
79
100
 
80
101
  it('accepts generated possibly-async callback types for sync helpers', () => {
81
- const compare: (a: number, b: number) => number | Promise<number> = (a, b) => a - b
82
- const keepOdd: (v: number) => boolean | Promise<boolean> = (v) => v % 2 === 0
83
- const equal: (a: string, b: string) => boolean | Promise<boolean> = (a, b) => a === b
102
+ const compare: (a: number, b: number) => number | Promise<number> = (
103
+ a,
104
+ b,
105
+ ) => a - b
106
+ const keepOdd: (v: number) => boolean | Promise<boolean> = (v) =>
107
+ v % 2 === 0
108
+ const equal: (a: string, b: string) => boolean | Promise<boolean> = (
109
+ a,
110
+ b,
111
+ ) => a === b
84
112
 
85
- expect(CompareFunc($.arrayToSlice([1]), $.arrayToSlice([2]), compare)).toBeLessThan(0)
86
- expect(Array.from(DeleteFunc($.arrayToSlice([1, 2, 3]), keepOdd) ?? [])).toEqual([1, 3])
87
- expect(EqualFunc($.arrayToSlice(['a']), $.arrayToSlice(['a']), equal)).toBe(true)
113
+ expect(
114
+ CompareFunc($.arrayToSlice([1]), $.arrayToSlice([2]), compare),
115
+ ).toBeLessThan(0)
116
+ expect(
117
+ Array.from(DeleteFunc($.arrayToSlice([1, 2, 3]), keepOdd) ?? []),
118
+ ).toEqual([1, 3])
119
+ expect(EqualFunc($.arrayToSlice(['a']), $.arrayToSlice(['a']), equal)).toBe(
120
+ true,
121
+ )
88
122
  expect(IndexFunc($.arrayToSlice([1, 2, 3]), keepOdd)).toBe(1)
89
123
  expect(IsSortedFunc($.arrayToSlice([1, 2, 3]), compare)).toBe(true)
90
124
  expect(BinarySearch($.arrayToSlice([1, 2, 3]), 2)).toEqual([1, true])
@@ -92,7 +126,11 @@ describe('slices compatibility helpers', () => {
92
126
 
93
127
  it('rejects actual async callback results in sync helpers', () => {
94
128
  expect(() =>
95
- CompareFunc($.arrayToSlice([1]), $.arrayToSlice([2]), async (a, b) => a - b),
129
+ CompareFunc(
130
+ $.arrayToSlice([1]),
131
+ $.arrayToSlice([2]),
132
+ async (a, b) => a - b,
133
+ ),
96
134
  ).toThrow('slices: asynchronous callback result is not supported')
97
135
  })
98
136
  })
@@ -4,9 +4,13 @@ import * as cmp from '../cmp/index.js'
4
4
  import * as iter from '../iter/index.js'
5
5
 
6
6
  type SyncCallbackResult<T> = T | globalThis.Promise<T>
7
- type CompareCallback<T, U = T> = ((v1: T, v2: U) => SyncCallbackResult<number>) | null
7
+ type CompareCallback<T, U = T> =
8
+ | ((v1: T, v2: U) => SyncCallbackResult<number>)
9
+ | null
8
10
  type PredicateCallback<T> = ((value: T) => SyncCallbackResult<boolean>) | null
9
- type EqualCallback<T, U = T> = ((v1: T, v2: U) => SyncCallbackResult<boolean>) | null
11
+ type EqualCallback<T, U = T> =
12
+ | ((v1: T, v2: U) => SyncCallbackResult<boolean>)
13
+ | null
10
14
 
11
15
  /**
12
16
  * Compare compares the elements of s1 and s2 using cmp.Compare.
@@ -59,9 +63,7 @@ export function CompareFunc<T, U>(
59
63
  const len2 = $.len(s2)
60
64
  const minLen = len1 < len2 ? len1 : len2
61
65
  for (let i = 0; i < minLen; i++) {
62
- const result = syncNumber(
63
- compare((s1 as any)[i] as T, (s2 as any)[i] as U),
64
- )
66
+ const result = syncNumber(compare((s1 as any)[i] as T, (s2 as any)[i] as U))
65
67
  if (result !== 0) {
66
68
  return result
67
69
  }
@@ -131,7 +133,9 @@ export function Concat<T>(...slices: $.Slice<T>[]): $.Slice<T> {
131
133
  */
132
134
  export function All<T>(
133
135
  s: $.Slice<T>,
134
- ): (yieldFunc: (index: number, value: T) => iter.YieldResult) => void | globalThis.Promise<void> {
136
+ ): (
137
+ yieldFunc: (index: number, value: T) => iter.YieldResult,
138
+ ) => void | globalThis.Promise<void> {
135
139
  return function (
136
140
  _yield: (index: number, value: T) => iter.YieldResult,
137
141
  ): void | globalThis.Promise<void> {
@@ -228,10 +232,7 @@ export function Min<T extends cmp.Ordered>(x: $.Slice<T>): T {
228
232
  return min
229
233
  }
230
234
 
231
- export function MaxFunc<T>(
232
- x: $.Slice<T>,
233
- compare: CompareCallback<T>,
234
- ): T {
235
+ export function MaxFunc<T>(x: $.Slice<T>, compare: CompareCallback<T>): T {
235
236
  if (compare == null) {
236
237
  throw new Error('slices.MaxFunc: nil comparison function')
237
238
  }
@@ -248,10 +249,7 @@ export function MaxFunc<T>(
248
249
  return max
249
250
  }
250
251
 
251
- export function MinFunc<T>(
252
- x: $.Slice<T>,
253
- compare: CompareCallback<T>,
254
- ): T {
252
+ export function MinFunc<T>(x: $.Slice<T>, compare: CompareCallback<T>): T {
255
253
  if (compare == null) {
256
254
  throw new Error('slices.MinFunc: nil comparison function')
257
255
  }
@@ -476,7 +474,10 @@ export function Contains<T>(s: $.Slice<T>, v: T): boolean {
476
474
  return Index(s, v) >= 0
477
475
  }
478
476
 
479
- export function ContainsFunc<T>(s: $.Slice<T>, f: PredicateCallback<T>): boolean {
477
+ export function ContainsFunc<T>(
478
+ s: $.Slice<T>,
479
+ f: PredicateCallback<T>,
480
+ ): boolean {
480
481
  return IndexFunc(s, f) >= 0
481
482
  }
482
483
 
@@ -555,18 +556,58 @@ export function Grow<T>(s: $.Slice<T>, n: number): $.Slice<T> {
555
556
  * @param s The slice to sort in place
556
557
  * @param cmp Comparison function
557
558
  */
558
- export function SortFunc<T>(
559
+ export async function SortFunc<T>(
559
560
  s: $.Slice<T>,
560
561
  cmp: CompareCallback<T>,
561
- ): void {
562
+ ): globalThis.Promise<void> {
562
563
  if (cmp == null) {
563
564
  throw new Error('slices.SortFunc: nil comparison function')
564
565
  }
565
- if (s === null || s === undefined) {
566
+ if (s === null || s === undefined || $.len(s) < 2) {
566
567
  return
567
568
  }
568
- const arr = s as any as T[]
569
- arr.sort((a, b) => syncNumber(cmp(a, b)))
569
+ const sorted = await asyncMergeSort(Array.from(s as any as T[]), cmp)
570
+ for (let i = 0; i < sorted.length; i++) {
571
+ ;(s as any)[i] = sorted[i]
572
+ }
573
+ }
574
+
575
+ async function asyncMergeSort<T>(
576
+ values: T[],
577
+ cmp: CompareCallback<T>,
578
+ ): globalThis.Promise<T[]> {
579
+ if (values.length < 2) {
580
+ return values
581
+ }
582
+ const mid = Math.floor(values.length / 2)
583
+ const left = await asyncMergeSort(values.slice(0, mid), cmp)
584
+ const right = await asyncMergeSort(values.slice(mid), cmp)
585
+ return asyncMerge(left, right, cmp)
586
+ }
587
+
588
+ async function asyncMerge<T>(
589
+ left: T[],
590
+ right: T[],
591
+ cmp: CompareCallback<T>,
592
+ ): globalThis.Promise<T[]> {
593
+ const out: T[] = []
594
+ let li = 0
595
+ let ri = 0
596
+ while (li < left.length && ri < right.length) {
597
+ const order = await cmp!(left[li], right[ri])
598
+ if (order <= 0) {
599
+ out.push(left[li++])
600
+ } else {
601
+ out.push(right[ri++])
602
+ }
603
+ }
604
+ while (li < left.length) {
605
+ out.push(left[li++])
606
+ }
607
+ while (ri < right.length) {
608
+ out.push(right[ri++])
609
+ }
610
+ return out
570
611
  }
571
612
 
572
613
  export function IsSortedFunc<T>(
@@ -48,10 +48,22 @@ describe('strconv complex helpers', () => {
48
48
  })
49
49
 
50
50
  it('rejects whitespace and malformed imaginary forms', () => {
51
- for (const input of [' 1+2i', '1+2i ', '1 +2i', 'i', '+i', '-i', '1++2i', '1-+2i', '0xp1']) {
51
+ for (const input of [
52
+ ' 1+2i',
53
+ '1+2i ',
54
+ '1 +2i',
55
+ 'i',
56
+ '+i',
57
+ '-i',
58
+ '1++2i',
59
+ '1-+2i',
60
+ '0xp1',
61
+ ]) {
52
62
  const [, err] = ParseComplex(input, 128)
53
63
 
54
- expect(err?.Error(), input).toBe(`strconv.ParseComplex: parsing "${input}": invalid syntax`)
64
+ expect(err?.Error(), input).toBe(
65
+ `strconv.ParseComplex: parsing "${input}": invalid syntax`,
66
+ )
55
67
  }
56
68
  })
57
69
 
@@ -60,6 +72,8 @@ describe('strconv complex helpers', () => {
60
72
 
61
73
  expect($.real(value)).toBe(Infinity)
62
74
  expect($.imag(value)).toBe(0)
63
- expect(err?.Error()).toBe('strconv.ParseComplex: parsing "0x1p1025": value out of range')
75
+ expect(err?.Error()).toBe(
76
+ 'strconv.ParseComplex: parsing "0x1p1025": value out of range',
77
+ )
64
78
  })
65
79
  })
@@ -1,12 +1,7 @@
1
1
  import { describe, expect, test } from 'vitest'
2
2
 
3
3
  import * as $ from '../../builtin/index.js'
4
- import {
5
- AddInt64,
6
- AddUint64,
7
- AndUint64,
8
- OrUint64,
9
- } from './doc_64.gs.js'
4
+ import { AddInt64, AddUint64, AndUint64, OrUint64 } from './doc_64.gs.js'
10
5
 
11
6
  function asBigInt(value: number): bigint {
12
7
  return typeof value === 'bigint' ? value : BigInt(value)
@@ -23,9 +18,7 @@ describe('sync/atomic 64-bit operations', () => {
23
18
  test('preserves high uint64 bits for bitwise operations', () => {
24
19
  const value = $.varRef($.uint('9223372036854775808', 64))
25
20
 
26
- expect(asBigInt(OrUint64(value, $.uint(1, 64)))).toBe(
27
- 9223372036854775808n,
28
- )
21
+ expect(asBigInt(OrUint64(value, $.uint(1, 64)))).toBe(9223372036854775808n)
29
22
  expect(asBigInt(value.value)).toBe(9223372036854775809n)
30
23
 
31
24
  expect(asBigInt(AndUint64(value, $.uint('18446744073709551614', 64)))).toBe(
@@ -94,14 +94,24 @@ describe('sync.Map', () => {
94
94
 
95
95
  it('matches boxed comparable interface keys', async () => {
96
96
  const m = new Map()
97
- const first = $.namedValueInterfaceValue(8, 'uint16', {}, {
98
- kind: $.TypeKind.Basic,
99
- name: 'uint16',
100
- })
101
- const second = $.namedValueInterfaceValue(8, 'uint16', {}, {
102
- kind: $.TypeKind.Basic,
103
- name: 'uint16',
104
- })
97
+ const first = $.namedValueInterfaceValue(
98
+ 8,
99
+ 'uint16',
100
+ {},
101
+ {
102
+ kind: $.TypeKind.Basic,
103
+ name: 'uint16',
104
+ },
105
+ )
106
+ const second = $.namedValueInterfaceValue(
107
+ 8,
108
+ 'uint16',
109
+ {},
110
+ {
111
+ kind: $.TypeKind.Basic,
112
+ name: 'uint16',
113
+ },
114
+ )
105
115
 
106
116
  await m.Store(first, 'compressor')
107
117
  expect(await m.Load(second)).toEqual(['compressor', true])
@@ -7,10 +7,15 @@ import { ValueOf } from './index.js'
7
7
  describe('syscall/js override', () => {
8
8
  test('ValueOf unwraps generated interface numeric boxes', () => {
9
9
  const value = ValueOf(
10
- $.namedValueInterfaceValue(41, 'int', {}, {
11
- kind: $.TypeKind.Basic,
12
- name: 'int',
13
- }),
10
+ $.namedValueInterfaceValue(
11
+ 41,
12
+ 'int',
13
+ {},
14
+ {
15
+ kind: $.TypeKind.Basic,
16
+ name: 'int',
17
+ },
18
+ ),
14
19
  )
15
20
 
16
21
  expect(value.Int()).toBe(41)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "goscript",
3
3
  "description": "Go to TypeScript transpiler",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",
@@ -48,8 +48,8 @@
48
48
  "example": "cd ./example/simple && bash run.bash",
49
49
  "test": "bun run test:go && bun run test:js",
50
50
  "test:go": "go test ./...",
51
- "test:go:browser": "go run ./cmd/goscript test --browser --timeout 1m --dir compiler/gotest/testdata/browserapi --run TestBrowserAPI .",
52
- "test:go:browser:shim": "mkdir -p .tmp/bin && go build -o .tmp/bin/go_js_wasm_exec ./cmd/go_js_wasm_exec && sh -c 'exec_path=\"$PWD/.tmp/bin/go_js_wasm_exec\"; cd compiler/gotest/testdata/browserapi && GOOS=js GOARCH=wasm go test -exec \"$exec_path\" -run TestBrowserAPI -count=1'",
51
+ "test:go:browser": "go run ./cmd/goscript test --browser --timeout 1m --dir compiler/gotest/testdata/browserapi --run TestBrowser .",
52
+ "test:go:browser:shim": "mkdir -p .tmp/bin && go build -o .tmp/bin/go_js_wasm_exec ./cmd/go_js_wasm_exec && sh -c 'exec_path=\"$PWD/.tmp/bin/go_js_wasm_exec\"; cd compiler/gotest/testdata/browserapi && GOOS=js GOARCH=wasm go test -exec \"$exec_path\" -run TestBrowser -count=1'",
53
53
  "test:js": "bun run typecheck && vitest run",
54
54
  "test:browser": "bun run scripts/generate-browser-tests.ts && vitest run --config vitest.browser.config.ts",
55
55
  "test:browser:ui": "bun run scripts/generate-browser-tests.ts && vitest --config vitest.browser.config.ts --ui",
@@ -94,7 +94,7 @@
94
94
  "./{src,builtin,example}/**/(*.ts|*.tsx|*.html|*.css|*.scss)": "prettier --config .prettierrc.yaml --write"
95
95
  },
96
96
  "devDependencies": {
97
- "@aptre/protobuf-es-lite": "^1.0.2",
97
+ "@aptre/protobuf-es-lite": "1.1.0",
98
98
  "@eslint/js": "^10.0.0",
99
99
  "@types/node": "^25.5.2",
100
100
  "@typescript-eslint/eslint-plugin": "^8.58.0",
@@ -108,12 +108,20 @@
108
108
  "husky": "^9.1.7",
109
109
  "lint-staged": "^17.0.0",
110
110
  "prettier": "^3.8.1",
111
- "starpc": "0.49.16",
111
+ "starpc": "0.49.18",
112
112
  "typescript": "^6.0.0",
113
113
  "typescript-eslint": "^8.58.0",
114
114
  "vitest": "^4.1.2"
115
115
  },
116
116
  "dependencies": {
117
+ "@noble/ciphers": "2.2.0",
118
+ "@noble/hashes": "2.2.0",
117
119
  "globals": "^17.4.0"
120
+ },
121
+ "resolutions": {
122
+ "@aptre/protobuf-es-lite": "1.1.0"
123
+ },
124
+ "overrides": {
125
+ "@aptre/protobuf-es-lite": "1.1.0"
118
126
  }
119
127
  }