@tomphttp/bare-client
Advanced tools
Comparing version 1.0.2-beta-rollup2 to 1.0.2-beta-rollup6
@@ -36,3 +36,3 @@ export * from './Client'; | ||
}; | ||
export declare type BareBodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | undefined; | ||
export declare type BareBodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | undefined | null; | ||
export declare type BareFetchInit = { | ||
@@ -57,3 +57,3 @@ method?: BareMethod; | ||
}; | ||
export declare type BareLanguage = 'JS' | 'TS' | 'Java' | 'PHP' | 'Rust' | 'C' | 'C++' | 'C#' | 'Ruby' | 'Go' | 'Crystal' | 'Bash' | string; | ||
export declare type BareLanguage = 'NodeJS' | 'Deno' | 'Java' | 'PHP' | 'Rust' | 'C' | 'C++' | 'C#' | 'Ruby' | 'Go' | 'Crystal' | 'Bash' | string; | ||
export declare type BareManifest = { | ||
@@ -89,3 +89,3 @@ maintainer?: BareMaintainer; | ||
createWebSocket(url: urlLike, headers?: BareHeaders, protocols?: string | string[]): Promise<BareWebSocket>; | ||
fetch(url: urlLike, init?: BareFetchInit): Promise<BareResponseFetch>; | ||
fetch(url: urlLike | Request, init?: BareFetchInit): Promise<BareResponseFetch>; | ||
} |
@@ -0,1 +1,10 @@ | ||
// The user likely has overwritten all networking functions after importing bare-client | ||
// It is our responsibility to make sure components of Bare-Client are using native networking functions | ||
// These exports are provided to plugins by @rollup/plugin-inject | ||
const global = globalThis; | ||
const fetch = global.fetch; | ||
const WebSocket = global.WebSocket; | ||
const Request = global.Request; | ||
const Response = global.Response; | ||
const statusEmpty = [101, 204, 205, 304]; | ||
@@ -612,3 +621,2 @@ const statusRedirect = [301, 302, 303, 307, 308]; | ||
// import Headers in NodeJS environments | ||
const MAX_HEADER_VALUE = 3072; | ||
@@ -825,3 +833,2 @@ /** | ||
// Implements the protocol for requesting bare data from a server | ||
const clientCtors = [['v2', ClientV2], ['v1', ClientV1]]; | ||
@@ -932,3 +939,14 @@ const maxRedirects = 20; | ||
async fetch(url, init = {}) { | ||
url = new URL(url); | ||
if (url instanceof Request) { | ||
// behave similar to the browser when fetch is called with (Request, Init) | ||
if (init) { | ||
url = new URL(url.url); | ||
} else { | ||
init = url; | ||
url = new URL(url.url); | ||
} | ||
} else { | ||
url = new URL(url); | ||
} | ||
let method; | ||
@@ -1017,1 +1035,2 @@ | ||
export { BareError, BareClient as default, maxRedirects, statusEmpty, statusRedirect }; | ||
//# sourceMappingURL=BareClient.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import { BareBodyInit, BareCache, BareHTTPProtocol, BareHeaders, BareMethod, BareResponse, BareWSProtocol, BareWebSocket } from './BareClient'; | ||
import { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient'; | ||
export declare const statusEmpty: number[]; | ||
@@ -3,0 +3,0 @@ export declare const statusRedirect: number[]; |
@@ -0,1 +1,2 @@ | ||
export declare const global: typeof globalThis; | ||
export declare const fetch: typeof globalThis.fetch; | ||
@@ -2,0 +3,0 @@ export declare const WebSocket: { |
@@ -1,2 +0,2 @@ | ||
import { BareBodyInit, BareCache, BareHTTPProtocol, BareHeaders, BareMethod, BareResponse, BareWSProtocol, BareWebSocket } from './BareClient.js'; | ||
import { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient.js'; | ||
import Client, { GenericClient } from './Client.js'; | ||
@@ -3,0 +3,0 @@ export default class ClientV1 extends Client implements GenericClient { |
@@ -1,2 +0,2 @@ | ||
import { BareHeaders, BareWSProtocol, BareWebSocket, BareResponse, BareCache, BareHTTPProtocol, BareBodyInit, BareMethod } from './BareClient'; | ||
import { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient'; | ||
import Client, { GenericClient } from './Client'; | ||
@@ -3,0 +3,0 @@ export default class ClientV2 extends Client implements GenericClient { |
{ | ||
"name": "@tomphttp/bare-client", | ||
"version": "1.0.2-beta-rollup2", | ||
"version": "1.0.2-beta-rollup6", | ||
"homepage": "https://github.com/tomphttp", | ||
@@ -21,4 +21,3 @@ "bugs": { | ||
"build:watch": "rollup -cw", | ||
"prepare": "node ./scripts/prepare.js", | ||
"lint": "eslint ./src/" | ||
"prepare": "node scripts/prepare.js" | ||
}, | ||
@@ -41,2 +40,3 @@ "type": "module", | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "^3.4.2", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
@@ -47,22 +47,12 @@ "@rollup/plugin-inject": "^4.0.4", | ||
"eslint": "^8.17.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"husky": "^8.0.1", | ||
"import-sort-style-module": "^6.0.0", | ||
"prettier": "^2.6.2", | ||
"prettier-plugin-import-sort": "^0.0.7", | ||
"resolve-typescript-plugin": "^1.2.0", | ||
"prettier": "^2.7.1", | ||
"rollup": "^2.75.6", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.32.1", | ||
"ts-loader": "^9.3.0", | ||
"typescript": "^4.7.3" | ||
"rollup-plugin-typescript2": "^0.32.1" | ||
}, | ||
"lint-staged": { | ||
"*.{mjs, js, ts, json}": "prettier --write" | ||
}, | ||
"importSort": { | ||
".mjs, .js, .jsx, .ts, .tsx": { | ||
"style": "module" | ||
} | ||
"*.{mjs, cjs, js, ts, json}": "prettier --write" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # Bare Client | ||
```html | ||
<script src="https://unpkg.com/@tomphttp/bare-client@1.0.2-beta-readme1/dist/BareClient.umd.min.js"></script> | ||
<script src="https://unpkg.com/@tomphttp/bare-client@1.0.2-beta-rollup6/dist/BareClient.umd.min.cjs"></script> | ||
``` | ||
@@ -31,3 +31,3 @@ | ||
console.log(response.status, await response.text()) | ||
console.log(response.status, await response.text()); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
281222
12
18
1991
18