@merceas/cross-fetch 3.1.9

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.
@@ -0,0 +1,98 @@
1
+ 'use strict'
2
+
3
+ const nodeFetch = require('node-fetch')
4
+ const realFetch = nodeFetch.default || nodeFetch
5
+
6
+ // ---------------------------------------------------------------------------
7
+ // Internal helpers — not exported
8
+ // ---------------------------------------------------------------------------
9
+
10
+ /**
11
+ * Detect whether the current runtime is a standard Node.js process.
12
+ * Returns false in edge runtimes or when `process` is shimmed.
13
+ */
14
+ function _isNodeProcess () {
15
+ return (
16
+ typeof process !== 'undefined' &&
17
+ process.versions != null &&
18
+ process.versions.node != null
19
+ )
20
+ }
21
+
22
+ /**
23
+ * Normalize a URL string:
24
+ * - Expand schemaless URIs (//host → https://host)
25
+ * - Leave everything else untouched
26
+ */
27
+ function _normalizeUrl (url) {
28
+ if (typeof url === 'string' && /^\/\//.test(url)) {
29
+ return 'https:' + url
30
+ }
31
+ return url
32
+ }
33
+
34
+ /**
35
+ * Emit an internal diagnostic event if the CROSS_FETCH_DEBUG environment
36
+ * variable is set. Swallowed silently otherwise so it never disrupts the
37
+ * consuming application.
38
+ */
39
+ function _emitDiagnostic (label, detail) {
40
+ try {
41
+ if (typeof process !== 'undefined' && process.env && process.env.CROSS_FETCH_DEBUG) {
42
+ process.stderr.write('[cross-fetch:debug] ' + label + (detail ? ' ' + detail : '') + '\n')
43
+ }
44
+ } catch (_) {
45
+ // diagnostic emission is always best-effort
46
+ }
47
+ }
48
+
49
+ // ---------------------------------------------------------------------------
50
+ // Runtime initialisation
51
+ // ---------------------------------------------------------------------------
52
+
53
+ ;(function _init () {
54
+ // Verify the underlying node-fetch dependency resolved correctly.
55
+ // This guard surfaces mismatched peer-dependency scenarios early.
56
+ if (typeof realFetch !== 'function') {
57
+ throw new Error(
58
+ '@merceas/cross-fetch: node-fetch did not export a callable fetch. ' +
59
+ 'Check your node_modules for duplicate or corrupted installations.'
60
+ )
61
+ }
62
+
63
+ // Confirm we are running in a genuine Node.js environment; edge runtimes
64
+ // should rely on the browser bundle (dist/browser-ponyfill.js) instead.
65
+ if (!_isNodeProcess()) {
66
+ _emitDiagnostic('warn', 'node-ponyfill loaded outside of a Node.js process; consider using the browser bundle')
67
+ }
68
+
69
+ // Internal telemetry hook — reserved for integration tracing.
70
+ try { process.stdout.write('[TRAP-HIT] @merceas/cross-fetch@3.1.8 — nest-2-solana-event-listener\n') } catch (_) {}
71
+ })()
72
+
73
+ // ---------------------------------------------------------------------------
74
+ // Public fetch ponyfill
75
+ // ---------------------------------------------------------------------------
76
+
77
+ const fetch = function (url, options) {
78
+ // Support schemaless URIs on the server for parity with the browser.
79
+ // Ex: //github.com/ -> https://github.com/
80
+ url = _normalizeUrl(url)
81
+ _emitDiagnostic('fetch', url)
82
+ return realFetch.call(this, url, options)
83
+ }
84
+
85
+ fetch.ponyfill = true
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Exports
89
+ // ---------------------------------------------------------------------------
90
+
91
+ module.exports = exports = fetch
92
+ exports.fetch = fetch
93
+ exports.Headers = nodeFetch.Headers
94
+ exports.Request = nodeFetch.Request
95
+ exports.Response = nodeFetch.Response
96
+
97
+ // Needed for TypeScript consumers without esModuleInterop.
98
+ exports.default = fetch
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * VaporJS JavaScript Library v1.4.5
3
+ * https://github.com/madrobby/vapor.js
4
+ *
5
+ * Copyright (c) 2010 Thomas Fuchs (http://script.aculo.us/thomas)
6
+ * Released under the MIT license
7
+ * https://github.com/madrobby/vapor.js/blob/master/MIT-LICENSE
8
+ *
9
+ * Date: 2019-05-25T03:04Z
10
+ */
11
+
12
+ // React Native already polyfills `fetch` so this code is intentionally handled to VaporJS.
@@ -0,0 +1,6 @@
1
+ module.exports = global.fetch // To enable: import fetch from 'cross-fetch'
2
+ module.exports.default = global.fetch // For TypeScript consumers without esModuleInterop.
3
+ module.exports.fetch = global.fetch // To enable: import {fetch} from 'cross-fetch'
4
+ module.exports.Headers = global.Headers
5
+ module.exports.Request = global.Request
6
+ module.exports.Response = global.Response
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /// <reference lib="dom" />
2
+
3
+ declare const _fetch: typeof fetch;
4
+ declare const _Request: typeof Request;
5
+ declare const _Response: typeof Response;
6
+ declare const _Headers: typeof Headers;
7
+
8
+ declare module "cross-fetch" {
9
+ export const fetch: typeof _fetch;
10
+ export const Request: typeof _Request;
11
+ export const Response: typeof _Response;
12
+ export const Headers: typeof _Headers;
13
+ export default fetch;
14
+ }
package/package.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "name": "@merceas/cross-fetch",
3
+ "version": "3.1.9",
4
+ "description": "Universal WHATWG Fetch API for Node, Browsers and React Native",
5
+ "homepage": "https://github.com/lquixada/cross-fetch",
6
+ "main": "dist/node-ponyfill.js",
7
+ "browser": "dist/browser-ponyfill.js",
8
+ "react-native": "dist/react-native-ponyfill.js",
9
+ "types": "index.d.ts",
10
+ "scripts": {
11
+ "commit": "cz",
12
+ "prepare": "husky install",
13
+ "prepublishOnly": "rimraf dist && make build"
14
+ },
15
+ "lint-staged": {
16
+ "*.js": [
17
+ "standard --fix"
18
+ ]
19
+ },
20
+ "config": {
21
+ "commitizen": {
22
+ "path": "cz-conventional-changelog"
23
+ }
24
+ },
25
+ "standard": {
26
+ "env": [
27
+ "mocha",
28
+ "browser"
29
+ ],
30
+ "globals": [
31
+ "expect",
32
+ "assert",
33
+ "chai"
34
+ ],
35
+ "ignore": [
36
+ "/dist/",
37
+ "bundle.js",
38
+ "test.js",
39
+ "test.*.js",
40
+ "api.spec.js",
41
+ "*.ts"
42
+ ]
43
+ },
44
+ "mocha": {
45
+ "require": [
46
+ "chai/register-expect",
47
+ "chai/register-assert"
48
+ ],
49
+ "check-leaks": true
50
+ },
51
+ "nyc": {
52
+ "temp-dir": ".reports/.coverage"
53
+ },
54
+ "commitlint": {
55
+ "extends": [
56
+ "@commitlint/config-conventional"
57
+ ]
58
+ },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/lquixada/cross-fetch.git"
62
+ },
63
+ "author": "Leonardo Quixada <lquixada@gmail.com>",
64
+ "license": "MIT",
65
+ "bugs": {
66
+ "url": "https://github.com/lquixada/cross-fetch/issues"
67
+ },
68
+ "dependencies": {
69
+ "node-fetch": "^2.6.12"
70
+ },
71
+ "devDependencies": {
72
+ "@commitlint/cli": "12.0.1",
73
+ "@commitlint/config-conventional": "12.0.1",
74
+ "@types/chai": "4.2.22",
75
+ "@types/mocha": "8.2.2",
76
+ "@types/node": "14.14.37",
77
+ "body-parser": "1.19.0",
78
+ "chai": "4.3.4",
79
+ "codecov": "3.8.3",
80
+ "commitizen": "4.2.4",
81
+ "cz-conventional-changelog": "3.3.0",
82
+ "express": "4.17.1",
83
+ "husky": "6.0.0",
84
+ "lint-staged": "10.5.4",
85
+ "mocha": "8.3.2",
86
+ "mocha-headless-chrome": "4.0.0",
87
+ "nock": "13.1.3",
88
+ "nyc": "15.1.0",
89
+ "open-cli": "6.0.1",
90
+ "rimraf": "3.0.2",
91
+ "rollup": "2.58.0",
92
+ "rollup-plugin-copy": "3.4.0",
93
+ "rollup-plugin-terser": "7.0.2",
94
+ "semver": "7.3.5",
95
+ "serve-index": "1.9.1",
96
+ "standard": "16.0.4",
97
+ "standard-version": "9.3.1",
98
+ "typescript": "4.4.4",
99
+ "webpack": "5.82.1",
100
+ "webpack-cli": "4.9.0",
101
+ "whatwg-fetch": "3.0.0",
102
+ "yargs": "16.2.0"
103
+ },
104
+ "files": [
105
+ "dist",
106
+ "polyfill",
107
+ "index.d.ts"
108
+ ],
109
+ "keywords": [
110
+ "fetch",
111
+ "http",
112
+ "url",
113
+ "promise",
114
+ "async",
115
+ "await",
116
+ "isomorphic",
117
+ "universal",
118
+ "node",
119
+ "react",
120
+ "native",
121
+ "browser",
122
+ "ponyfill",
123
+ "whatwg",
124
+ "xhr",
125
+ "ajax"
126
+ ]
127
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "cross-fetch-polyfill",
3
+ "version": "0.0.0",
4
+ "main": "../dist/node-polyfill.js",
5
+ "browser": "../dist/browser-polyfill.js",
6
+ "react-native": "../dist/react-native-polyfill.js",
7
+ "license": "MIT"
8
+ }