Adjust deno exports in x-* (#1578)
* Adjust deno exports in x-* * Adjust versionDetect
This commit is contained in:
@@ -24,7 +24,7 @@ interface PjsChecks extends This {
|
||||
__polkadotjs: Record<string, VersionPath[]>;
|
||||
}
|
||||
|
||||
type PjsGlobal = (Window & This) & PjsChecks;
|
||||
type PjsGlobal = This & PjsChecks & Record<string, unknown>;
|
||||
type FnString = () => string | undefined;
|
||||
|
||||
const DEDUPE = 'Either remove and explicitly install matching versions or dedupe using your package manager.\nThe following conflicting packages were found:';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/x-bigint authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const BigInt = xglobal.BigInt;
|
||||
const _BigInt = BigInt;
|
||||
|
||||
export { _BigInt as BigInt };
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './browser';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
const _fetch = fetch;
|
||||
|
||||
export { _fetch as fetch };
|
||||
|
||||
@@ -6,17 +6,18 @@ export { packageInfo } from './packageInfo';
|
||||
// Ensure that we are able to run this without any @types/node definitions
|
||||
// and without having lib: ['dom'] in our TypeScript configuration
|
||||
// (may not be available in all environments, e.g. Deno springs to mind)
|
||||
declare const global: typeof globalThis;
|
||||
declare const self: typeof globalThis;
|
||||
declare const global: unknown;
|
||||
declare const self: unknown;
|
||||
declare const window: unknown;
|
||||
|
||||
type GlobalThis = typeof globalThis;
|
||||
type GlobalThis = typeof globalThis & Record<string, unknown>;
|
||||
|
||||
type GlobalNames = keyof GlobalThis;
|
||||
type GlobalNames = keyof typeof globalThis;
|
||||
|
||||
type GlobalType<T extends GlobalNames> = typeof globalThis[T];
|
||||
type GlobalType<N extends GlobalNames> = typeof globalThis[N];
|
||||
|
||||
function evaluateThis (fn: (code: string) => unknown): GlobalThis {
|
||||
return fn('return this') as GlobalThis;
|
||||
function evaluateThis (fn: (code: string) => unknown): unknown {
|
||||
return fn('return this');
|
||||
}
|
||||
|
||||
export const xglobal = (
|
||||
@@ -29,7 +30,7 @@ export const xglobal = (
|
||||
: typeof window !== 'undefined'
|
||||
? window
|
||||
: evaluateThis(Function)
|
||||
);
|
||||
) as GlobalThis;
|
||||
|
||||
export function extractGlobal <N extends GlobalNames, T extends GlobalType<N>> (name: N, fallback: unknown): T {
|
||||
// Not quite sure why this is here - snuck in with TS 4.7.2 with no real idea
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/x-randomvalues authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './browser';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export function getRandomValues <T extends Uint8Array> (arr: T): T {
|
||||
return crypto.getRandomValues(arr);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const TextDecoder = xglobal.TextDecoder;
|
||||
const _TextDecoder = TextDecoder;
|
||||
|
||||
export { _TextDecoder as TextDecoder };
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const TextEncoder = xglobal.TextEncoder;
|
||||
const _TextEncoder = TextEncoder;
|
||||
|
||||
export { _TextEncoder as TextEncoder };
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/x-ws authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './browser';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
const _WebSocket = WebSocket;
|
||||
|
||||
export { _WebSocket as WebSocket };
|
||||
|
||||
Reference in New Issue
Block a user