@chatbotkit/fetch 0.1.0
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 +7 -0
- package/dist/cjs/index.cjs +22 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +17 -0
- package/package.json +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormData = exports.Blob = exports.fetch = void 0;
|
|
4
|
+
const node_fetch_native_1 = require("node-fetch-native");
|
|
5
|
+
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return node_fetch_native_1.fetch; } });
|
|
6
|
+
Object.defineProperty(exports, "Blob", { enumerable: true, get: function () { return node_fetch_native_1.Blob; } });
|
|
7
|
+
Object.defineProperty(exports, "FormData", { enumerable: true, get: function () { return node_fetch_native_1.FormData; } });
|
|
8
|
+
if (typeof globalThis.ReadableStream === 'function' &&
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
typeof globalThis.ReadableStream.prototype[Symbol.asyncIterator] !==
|
|
11
|
+
'function') {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
globalThis.ReadableStream.prototype[Symbol.asyncIterator] = function () {
|
|
14
|
+
const reader = this.getReader();
|
|
15
|
+
return {
|
|
16
|
+
next: () => reader.read(),
|
|
17
|
+
return: () => {
|
|
18
|
+
reader.releaseLock();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fetch, Blob, FormData } from 'node-fetch-native';
|
|
2
|
+
if (typeof globalThis.ReadableStream === 'function' &&
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
typeof globalThis.ReadableStream.prototype[Symbol.asyncIterator] !==
|
|
5
|
+
'function') {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
globalThis.ReadableStream.prototype[Symbol.asyncIterator] = function () {
|
|
8
|
+
const reader = this.getReader();
|
|
9
|
+
return {
|
|
10
|
+
next: () => reader.read(),
|
|
11
|
+
return: () => {
|
|
12
|
+
reader.releaseLock();
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export { fetch, Blob, FormData };
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chatbotkit/fetch",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Isomorphic implenetation for fetch specifically designed for @chatbotkit/sdk.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/chatbotkit/node-sdk.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/chatbotkit/node-sdk/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/chatbotkit/node-sdk#readme",
|
|
14
|
+
"author": "",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"fetch",
|
|
17
|
+
"Blob",
|
|
18
|
+
"FormData"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/esm/index.js",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/cjs/index.d.ts",
|
|
26
|
+
"default": "./dist/cjs/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/esm/index.d.ts",
|
|
30
|
+
"default": "./dist/esm/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./index.js": {
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/cjs/index.d.ts",
|
|
36
|
+
"default": "./dist/cjs/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/esm/index.d.ts",
|
|
40
|
+
"default": "./dist/esm/index.js"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "run-s build:*",
|
|
46
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
47
|
+
"build:cjs_rename": "find ./dist/cjs -name '*.js' -exec rename .js .cjs {} +",
|
|
48
|
+
"build:cjs_rewrite_cjs": "find ./dist/cjs -name '*.cjs' -exec sed -i 's/require(\"\\(.*\\)\\.js\")/require(\"\\1.cjs\")/g' {} +",
|
|
49
|
+
"build:cjs_rewrite_ts": "find ./dist/cjs -name '*.ts' -exec sed -i 's/from \"\\(.*\\)\\.js\"/from \"\\1.cjs\"/g' {} +",
|
|
50
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
51
|
+
"build:exports": "node scripts/build-exports.js",
|
|
52
|
+
"test": "true"
|
|
53
|
+
},
|
|
54
|
+
"types": "./dist/esm/index.d.ts",
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"isomorphic-fetch": "^3.0.0",
|
|
57
|
+
"node-fetch": "^3.3.1",
|
|
58
|
+
"node-fetch-native": "^1.2.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@tsconfig/recommended": "^1.0.2",
|
|
62
|
+
"npm-run-all": "^4.1.5",
|
|
63
|
+
"typescript": "^5.0.4"
|
|
64
|
+
}
|
|
65
|
+
}
|