Compare commits

..

2 Commits

Author SHA1 Message Date
fe0814f0c7 Merge pull request 'Fix globalThis usage. Fixes #23' (#24) from snowball/registry-sdk:fix-globalthis into v0.2.51
Some checks failed
Publish npm package to gitea / npm_publish (18.x) (release) Failing after 1m34s
Reviewed-on: #24
2024-08-27 23:04:05 +00:00
Gilbert
82cf5f191f Fix globalThis usage. Fixes #23
Some checks failed
Lint & Build / lint_and_build (20.x) (pull_request) Successful in 1m49s
Tests / sdk_tests (pull_request) Has been cancelled
2024-08-27 14:52:53 -05:00
3 changed files with 21 additions and 21 deletions

View File

@ -1162,7 +1162,7 @@ export const RecordsList = {
declare var self: any | undefined; declare var self: any | undefined;
declare var window: any | undefined; declare var window: any | undefined;
declare var global: any | undefined; declare var global: any | undefined;
var globalThis: any = (() => { var _globalThis: any = (() => {
if (typeof globalThis !== "undefined") return globalThis; if (typeof globalThis !== "undefined") return globalThis;
if (typeof self !== "undefined") return self; if (typeof self !== "undefined") return self;
if (typeof window !== "undefined") return window; if (typeof window !== "undefined") return window;
@ -1171,10 +1171,10 @@ var globalThis: any = (() => {
})(); })();
function bytesFromBase64(b64: string): Uint8Array { function bytesFromBase64(b64: string): Uint8Array {
if (globalThis.Buffer) { if (_globalThis.Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); return Uint8Array.from(_globalThis.Buffer.from(b64, "base64"));
} else { } else {
const bin = globalThis.atob(b64); const bin = _globalThis.atob(b64);
const arr = new Uint8Array(bin.length); const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) { for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i); arr[i] = bin.charCodeAt(i);
@ -1184,14 +1184,14 @@ function bytesFromBase64(b64: string): Uint8Array {
} }
function base64FromBytes(arr: Uint8Array): string { function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) { if (_globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("base64"); return _globalThis.Buffer.from(arr).toString("base64");
} else { } else {
const bin: string[] = []; const bin: string[] = [];
arr.forEach((byte) => { arr.forEach((byte) => {
bin.push(String.fromCharCode(byte)); bin.push(String.fromCharCode(byte));
}); });
return globalThis.btoa(bin.join("")); return _globalThis.btoa(bin.join(""));
} }
} }

View File

@ -251,7 +251,7 @@ export const PageResponse = {
declare var self: any | undefined; declare var self: any | undefined;
declare var window: any | undefined; declare var window: any | undefined;
declare var global: any | undefined; declare var global: any | undefined;
var globalThis: any = (() => { var _globalThis: any = (() => {
if (typeof globalThis !== "undefined") return globalThis; if (typeof globalThis !== "undefined") return globalThis;
if (typeof self !== "undefined") return self; if (typeof self !== "undefined") return self;
if (typeof window !== "undefined") return window; if (typeof window !== "undefined") return window;
@ -260,10 +260,10 @@ var globalThis: any = (() => {
})(); })();
function bytesFromBase64(b64: string): Uint8Array { function bytesFromBase64(b64: string): Uint8Array {
if (globalThis.Buffer) { if (_globalThis.Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); return Uint8Array.from(_globalThis.Buffer.from(b64, "base64"));
} else { } else {
const bin = globalThis.atob(b64); const bin = _globalThis.atob(b64);
const arr = new Uint8Array(bin.length); const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) { for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i); arr[i] = bin.charCodeAt(i);
@ -273,14 +273,14 @@ function bytesFromBase64(b64: string): Uint8Array {
} }
function base64FromBytes(arr: Uint8Array): string { function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) { if (_globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("base64"); return _globalThis.Buffer.from(arr).toString("base64");
} else { } else {
const bin: string[] = []; const bin: string[] = [];
arr.forEach((byte) => { arr.forEach((byte) => {
bin.push(String.fromCharCode(byte)); bin.push(String.fromCharCode(byte));
}); });
return globalThis.btoa(bin.join("")); return _globalThis.btoa(bin.join(""));
} }
} }

View File

@ -4324,7 +4324,7 @@ export const GeneratedCodeInfo_Annotation = {
declare var self: any | undefined; declare var self: any | undefined;
declare var window: any | undefined; declare var window: any | undefined;
declare var global: any | undefined; declare var global: any | undefined;
var globalThis: any = (() => { var _globalThis: any = (() => {
if (typeof globalThis !== "undefined") return globalThis; if (typeof globalThis !== "undefined") return globalThis;
if (typeof self !== "undefined") return self; if (typeof self !== "undefined") return self;
if (typeof window !== "undefined") return window; if (typeof window !== "undefined") return window;
@ -4333,10 +4333,10 @@ var globalThis: any = (() => {
})(); })();
function bytesFromBase64(b64: string): Uint8Array { function bytesFromBase64(b64: string): Uint8Array {
if (globalThis.Buffer) { if (_globalThis.Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); return Uint8Array.from(_globalThis.Buffer.from(b64, "base64"));
} else { } else {
const bin = globalThis.atob(b64); const bin = _globalThis.atob(b64);
const arr = new Uint8Array(bin.length); const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) { for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i); arr[i] = bin.charCodeAt(i);
@ -4346,14 +4346,14 @@ function bytesFromBase64(b64: string): Uint8Array {
} }
function base64FromBytes(arr: Uint8Array): string { function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) { if (_globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("base64"); return _globalThis.Buffer.from(arr).toString("base64");
} else { } else {
const bin: string[] = []; const bin: string[] = [];
arr.forEach((byte) => { arr.forEach((byte) => {
bin.push(String.fromCharCode(byte)); bin.push(String.fromCharCode(byte));
}); });
return globalThis.btoa(bin.join("")); return _globalThis.btoa(bin.join(""));
} }
} }