goscript 0.0.62 → 0.0.63

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.
@@ -164,7 +164,15 @@ export function ParseUint(s: string, base: number, bitSize: number): [number, $.
164
164
  }
165
165
 
166
166
  // Check range for the specified bit size
167
- const maxVal = (1 << bitSize) - 1;
167
+ // Note: JavaScript bitwise operators only work on 32-bit integers,
168
+ // so we use Math.pow() for larger bit sizes
169
+ let maxVal: number;
170
+ if (bitSize >= 53) {
171
+ // For 53+ bits, use MAX_SAFE_INTEGER as JavaScript can't represent larger integers accurately
172
+ maxVal = Number.MAX_SAFE_INTEGER;
173
+ } else {
174
+ maxVal = Math.pow(2, bitSize) - 1;
175
+ }
168
176
  if (result > maxVal) {
169
177
  return [0, rangeError("ParseUint", s0)];
170
178
  }
@@ -200,7 +208,15 @@ export function ParseInt(s: string, base: number, bitSize: number): [number, $.G
200
208
  bitSize = 64;
201
209
  }
202
210
 
203
- const cutoff = 1 << (bitSize - 1);
211
+ // Note: JavaScript bitwise operators only work on 32-bit integers,
212
+ // so we use Math.pow() for larger bit sizes
213
+ let cutoff: number;
214
+ if (bitSize >= 53) {
215
+ // For 53+ bits, use MAX_SAFE_INTEGER as JavaScript can't represent larger integers accurately
216
+ cutoff = Number.MAX_SAFE_INTEGER;
217
+ } else {
218
+ cutoff = Math.pow(2, bitSize - 1);
219
+ }
204
220
  if (!neg && un >= cutoff) {
205
221
  return [0, rangeError("ParseInt", s)];
206
222
  }
@@ -106,34 +106,30 @@ export class Pointer<T> {
106
106
  }
107
107
 
108
108
  // Store atomically stores val into x.
109
- // In Go, this takes *T which can be nil, so we accept T | null
110
- public Store(val: T | null): void {
109
+ // In Go, this takes *T which can be nil, so we accept VarRef<T> | null
110
+ public Store(val: $.VarRef<T> | null): void {
111
111
  const x = this
112
112
  if (val === null) {
113
113
  StorePointer(x._fields.v, null)
114
114
  } else {
115
- const varRef = $.varRef(val)
116
- StorePointer(x._fields.v, unsafe.Pointer(varRef))
115
+ StorePointer(x._fields.v, unsafe.Pointer(val))
117
116
  }
118
117
  }
119
118
 
120
119
  // Swap atomically stores new into x and returns the previous value.
121
- // In Go, this takes *T which can be nil, so we accept T | null
122
- public Swap(_new: T | null): $.VarRef<T> | null {
120
+ // In Go, this takes *T which can be nil, so we accept VarRef<T> | null
121
+ public Swap(_new: $.VarRef<T> | null): $.VarRef<T> | null {
123
122
  const x = this
124
123
  if (_new === null) {
125
124
  return SwapPointer(x._fields.v, null) as $.VarRef<T> | null
126
125
  }
127
- const varRef = $.varRef(_new)
128
- return SwapPointer(x._fields.v, unsafe.Pointer(varRef)) as $.VarRef<T> | null
126
+ return SwapPointer(x._fields.v, unsafe.Pointer(_new)) as $.VarRef<T> | null
129
127
  }
130
128
 
131
129
  // CompareAndSwap executes the compare-and-swap operation for x.
132
- public CompareAndSwap(old: T, _new: T): boolean {
130
+ public CompareAndSwap(old: $.VarRef<T> | null, _new: $.VarRef<T> | null): boolean {
133
131
  const x = this
134
- const oldVarRef = $.varRef(old)
135
- const newVarRef = $.varRef(_new)
136
- return CompareAndSwapPointer(x._fields.v, unsafe.Pointer(oldVarRef), unsafe.Pointer(newVarRef))
132
+ return CompareAndSwapPointer(x._fields.v, old ? unsafe.Pointer(old) : null, _new ? unsafe.Pointer(_new) : null)
137
133
  }
138
134
 
139
135
  // Register this type with the runtime type system
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "goscript",
3
3
  "description": "Go to TypeScript transpiler",
4
- "version": "0.0.62",
4
+ "version": "0.0.63",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",
@@ -49,6 +49,8 @@
49
49
  "test": "npm run test:go && npm run test:js",
50
50
  "test:go": "go test ./...",
51
51
  "test:js": "npm run typecheck && vitest run",
52
+ "test:browser": "bun run scripts/generate-browser-tests.ts && vitest run --config vitest.browser.config.ts",
53
+ "test:browser:ui": "bun run scripts/generate-browser-tests.ts && vitest --config vitest.browser.config.ts --ui",
52
54
  "typecheck": "tsgo --noEmit -p tsconfig.build.json",
53
55
  "format": "npm run format:go && npm run format:js && npm run format:config",
54
56
  "format:config": "prettier --write tsconfig.json package.json",
@@ -64,6 +66,11 @@
64
66
  "lint:go": "golangci-lint run .",
65
67
  "lint:js": "eslint -c eslint.config.mjs ./",
66
68
  "lint:js:fix": "eslint -c eslint.config.mjs ./ --fix",
69
+ "website:build": "bun run website:manifest && bun run website:examples && cd website && bun run build",
70
+ "website:manifest": "bun run scripts/generate-test-manifest.ts",
71
+ "website:examples": "bun run scripts/generate-examples.ts",
72
+ "website:dev": "cd website && bun run dev",
73
+ "website:serve": "cd website && bun run preview",
67
74
  "prepare": "husky",
68
75
  "precommit": "lint-staged"
69
76
  },
@@ -73,7 +80,7 @@
73
80
  "cmd",
74
81
  "compiler",
75
82
  "gs",
76
- "!compliance",
83
+ "!tests",
77
84
  "go.mod",
78
85
  "go.sum",
79
86
  "LICENSE",
@@ -90,12 +97,14 @@
90
97
  "@typescript-eslint/eslint-plugin": "^8.50.1",
91
98
  "@typescript-eslint/parser": "^8.50.1",
92
99
  "@typescript/native-preview": "^7.0.0-dev.20251226.1",
100
+ "@vitest/browser": "^4.0.16",
101
+ "@vitest/browser-playwright": "^4.0.16",
102
+ "@vitest/browser-preview": "^4.0.16",
93
103
  "eslint": "^9.39.2",
94
104
  "eslint-config-prettier": "^10.0.2",
95
105
  "husky": "^9.1.7",
96
106
  "lint-staged": "^16.2.7",
97
107
  "prettier": "^3.7.4",
98
- "tsx": "^4.21.0",
99
108
  "typescript": "^5.8.3",
100
109
  "typescript-eslint": "^8.50.1",
101
110
  "vitest": "^4.0.16"