@fable-org/fable-library-js 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 +6 -0
- package/Encoding.js +20 -8
- package/package.json +1 -1
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.js
CHANGED
|
@@ -99,8 +99,11 @@ class UTF16LE {
|
|
|
99
99
|
else if (index != null) {
|
|
100
100
|
str = str.substring(index);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
103
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
104
|
+
const g = globalThis;
|
|
105
|
+
if (typeof g.Buffer !== "undefined") {
|
|
106
|
+
const bytes = g.Buffer.from(str, "utf16le");
|
|
104
107
|
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
105
108
|
}
|
|
106
109
|
else {
|
|
@@ -116,11 +119,14 @@ class UTF16LE {
|
|
|
116
119
|
else if (index != null) {
|
|
117
120
|
buffer = buffer.subarray(index);
|
|
118
121
|
}
|
|
122
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
123
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
124
|
+
const g = globalThis;
|
|
119
125
|
if (typeof TextDecoder !== "undefined") {
|
|
120
126
|
return new TextDecoder("utf-16le").decode(buffer);
|
|
121
127
|
}
|
|
122
|
-
else if (typeof Buffer !== "undefined") {
|
|
123
|
-
return Buffer.from(buffer).toString("utf16le");
|
|
128
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
129
|
+
return g.Buffer.from(buffer).toString("utf16le");
|
|
124
130
|
}
|
|
125
131
|
else {
|
|
126
132
|
return utf16le_decode(buffer); // polyfill
|
|
@@ -136,11 +142,14 @@ class UTF8 {
|
|
|
136
142
|
else if (index != null) {
|
|
137
143
|
str = str.substring(index);
|
|
138
144
|
}
|
|
145
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
146
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
147
|
+
const g = globalThis;
|
|
139
148
|
if (typeof TextEncoder !== "undefined") {
|
|
140
149
|
return new TextEncoder().encode(str);
|
|
141
150
|
}
|
|
142
|
-
else if (typeof Buffer !== "undefined") {
|
|
143
|
-
const bytes = Buffer.from(str, "utf8");
|
|
151
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
152
|
+
const bytes = g.Buffer.from(str, "utf8");
|
|
144
153
|
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
145
154
|
}
|
|
146
155
|
else {
|
|
@@ -156,11 +165,14 @@ class UTF8 {
|
|
|
156
165
|
else if (index != null) {
|
|
157
166
|
buffer = buffer.subarray(index);
|
|
158
167
|
}
|
|
168
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
169
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
170
|
+
const g = globalThis;
|
|
159
171
|
if (typeof TextDecoder !== "undefined") {
|
|
160
172
|
return new TextDecoder().decode(buffer);
|
|
161
173
|
}
|
|
162
|
-
else if (typeof Buffer !== "undefined") {
|
|
163
|
-
return Buffer.from(buffer).toString("utf8");
|
|
174
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
175
|
+
return g.Buffer.from(buffer).toString("utf8");
|
|
164
176
|
}
|
|
165
177
|
else {
|
|
166
178
|
return utf8_decode(buffer); // polyfill
|
package/package.json
CHANGED