mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-06-18 23:31:04 +00:00
Initial rebrand: @polkadot -> @pezkuwi (14 packages)
- Package namespace: @polkadot/* -> @pezkuwi/* - Repository: polkadot-js/common -> pezkuwichain/pezkuwi-common - Author: Pezkuwi Team <team@pezkuwichain.io> Core packages: - @pezkuwi/util (utilities) - @pezkuwi/util-crypto (crypto primitives) - @pezkuwi/keyring (account management) - @pezkuwi/networks (chain metadata) - @pezkuwi/hw-ledger (Ledger hardware wallet) - @pezkuwi/x-* (10 polyfill packages) Total: 14 packages Upstream: polkadot-js/common v14.0.1
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# @pezkuwi/x-fetch
|
||||
|
||||
A cross-environment fetch.
|
||||
|
||||
Install it via `yarn add @pezkuwi/x-fetch`
|
||||
|
||||
```js
|
||||
import { fetch } from '@pezkuwi/x-fetch';
|
||||
|
||||
...
|
||||
const response = await fetch('https://example.com/something.json');
|
||||
const json = await response.json();
|
||||
```
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/pezkuwichain/pezkuwi-common/issues",
|
||||
"description": "A cross-environment fetch replacement",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/pezkuwichain/pezkuwi-common/tree/master/packages/x-fetch#readme",
|
||||
"license": "Apache-2.0",
|
||||
"name": "@pezkuwi/x-fetch",
|
||||
"repository": {
|
||||
"directory": "packages/x-fetch",
|
||||
"type": "git",
|
||||
"url": "https://github.com/pezkuwichain/pezkuwi-common.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "14.0.1",
|
||||
"browser": "browser.js",
|
||||
"main": "node.js",
|
||||
"react-native": "react-native.js",
|
||||
"dependencies": {
|
||||
"@pezkuwi/x-global": "14.0.1",
|
||||
"node-fetch": "^3.3.2",
|
||||
"tslib": "^2.8.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2025 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@pezkuwi/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
|
||||
export const fetch = xglobal.fetch;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './browser.js';
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2017-2025 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { extractGlobal } from '@pezkuwi/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
|
||||
// This is an ESM module, use the async import(...) syntax to pull it
|
||||
// in. Logically we would like it in nodeFetch(...) itself, however
|
||||
// while it is all-ok on Node itself, it does create issues in Jest,
|
||||
// possibly due to the Jest 28 need for --experimental-vm-modules
|
||||
const importFetch = import('node-fetch').catch(() => null);
|
||||
|
||||
// keep track of the resolved import value
|
||||
let modFn: typeof fetch | null = null;
|
||||
|
||||
async function nodeFetch (...args: Parameters<typeof fetch>): Promise<Response> {
|
||||
if (!modFn) {
|
||||
const mod = await importFetch;
|
||||
|
||||
if (!mod?.default) {
|
||||
throw new Error('Unable to import node-fetch in this environment');
|
||||
}
|
||||
|
||||
modFn = mod.default as unknown as typeof fetch;
|
||||
}
|
||||
|
||||
return modFn(...args);
|
||||
}
|
||||
|
||||
export const fetch = /*#__PURE__*/ extractGlobal('fetch', nodeFetch);
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './browser.js';
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2025 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { fetch } from '@pezkuwi/x-fetch';
|
||||
import { exposeGlobal } from '@pezkuwi/x-global';
|
||||
|
||||
exposeGlobal('fetch', fetch);
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../x-global/tsconfig.build.json" }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user