@fable-org/fable-library-ts 2.0.0-rc.1 → 2.0.0-rc.2

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 2.0.0-rc.2 - 2026-03-03
11
+
12
+ ### Fixed
13
+
14
+ * [JS/TS] Allows compiling `fable-library-ts` for Browser environment (by @goswinr)
15
+
10
16
  ## 2.0.0-rc.1 - 2026-02-26
11
17
 
12
18
  ## 2.0.0-beta.7 - 2026-02-03
package/Encoding.ts CHANGED
@@ -98,8 +98,11 @@ class UTF16LE {
98
98
  } else if (index != null) {
99
99
  str = str.substring(index);
100
100
  }
101
- if (typeof Buffer !== "undefined") {
102
- const bytes = Buffer.from(str, "utf16le");
101
+ // Allow to compile for Browser environment without @types/node being installed
102
+ // See https://github.com/fable-compiler/Fable/issues/4368
103
+ const g = globalThis as any;
104
+ if (typeof g.Buffer !== "undefined") {
105
+ const bytes = g.Buffer.from(str, "utf16le");
103
106
  return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
104
107
  } else {
105
108
  return utf16le_encode(str); // polyfill
@@ -114,10 +117,13 @@ class UTF16LE {
114
117
  } else if (index != null) {
115
118
  buffer = buffer.subarray(index);
116
119
  }
120
+ // Allow to compile for Browser environment without @types/node being installed
121
+ // See https://github.com/fable-compiler/Fable/issues/4368
122
+ const g = globalThis as any;
117
123
  if (typeof TextDecoder !== "undefined") {
118
124
  return new TextDecoder("utf-16le").decode(buffer);
119
- } else if (typeof Buffer !== "undefined") {
120
- return Buffer.from(buffer).toString("utf16le");
125
+ } else if (typeof g.Buffer !== "undefined") {
126
+ return g.Buffer.from(buffer).toString("utf16le");
121
127
  } else {
122
128
  return utf16le_decode(buffer); // polyfill
123
129
  }
@@ -134,10 +140,13 @@ class UTF8 {
134
140
  } else if (index != null) {
135
141
  str = str.substring(index);
136
142
  }
143
+ // Allow to compile for Browser environment without @types/node being installed
144
+ // See https://github.com/fable-compiler/Fable/issues/4368
145
+ const g = globalThis as any;
137
146
  if (typeof TextEncoder !== "undefined") {
138
147
  return new TextEncoder().encode(str);
139
- } else if (typeof Buffer !== "undefined") {
140
- const bytes = Buffer.from(str, "utf8");
148
+ } else if (typeof g.Buffer !== "undefined") {
149
+ const bytes = g.Buffer.from(str, "utf8");
141
150
  return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
142
151
  } else {
143
152
  return utf8_encode(str); // polyfill
@@ -152,10 +161,13 @@ class UTF8 {
152
161
  } else if (index != null) {
153
162
  buffer = buffer.subarray(index);
154
163
  }
164
+ // Allow to compile for Browser environment without @types/node being installed
165
+ // See https://github.com/fable-compiler/Fable/issues/4368
166
+ const g = globalThis as any;
155
167
  if (typeof TextDecoder !== "undefined") {
156
168
  return new TextDecoder().decode(buffer);
157
- } else if (typeof Buffer !== "undefined") {
158
- return Buffer.from(buffer).toString("utf8");
169
+ } else if (typeof g.Buffer !== "undefined") {
170
+ return g.Buffer.from(buffer).toString("utf8");
159
171
  } else {
160
172
  return utf8_decode(buffer); // polyfill
161
173
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "name": "@fable-org/fable-library-ts",
6
- "version": "2.0.0-rc.1",
6
+ "version": "2.0.0-rc.2",
7
7
  "description": "Core library used by F# projects compiled with fable.io",
8
8
  "author": "Fable Contributors",
9
9
  "license": "MIT",