@tomphttp/bare-client
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -55,4 +55,5 @@ export * from './Client'; | ||
repository?: string; | ||
version?: string; | ||
}; | ||
export declare type BareLanguage = 'NodeJS' | 'Deno' | 'Java' | 'PHP' | 'Rust' | 'C' | 'C++' | 'C#' | 'Ruby' | 'Go' | 'Crystal' | 'Bash' | string; | ||
export declare type BareLanguage = 'NodeJS' | 'ServiceWorker' | 'Deno' | 'Java' | 'PHP' | 'Rust' | 'C' | 'C++' | 'C#' | 'Ruby' | 'Go' | 'Crystal' | 'Shell' | string; | ||
export declare type BareManifest = { | ||
@@ -66,14 +67,26 @@ maintainer?: BareMaintainer; | ||
export default class BareClient { | ||
data: BareManifest | undefined; | ||
private client; | ||
/** | ||
* @depricated Use .manifest instead. | ||
*/ | ||
get data(): BareClient['manfiest']; | ||
manfiest?: BareManifest; | ||
private client?; | ||
private server; | ||
private ready; | ||
private working?; | ||
private onDemand; | ||
private onDemandSignal?; | ||
/** | ||
* | ||
* Lazily create a BareClient. Calls to fetch and connect will request the manifest once on-demand. | ||
* @param server A full URL to the bare server. | ||
* @param data The a copy of the Bare server data found in BareClient.data. If specified, this data will be loaded. Otherwise, a request will be made to the bare server (upon fetching or creating a WebSocket). | ||
* @param signal An abort signal for fetching the manifest on demand. | ||
*/ | ||
constructor(server: string | URL, data?: BareManifest); | ||
private loadData; | ||
private work; | ||
constructor(server: string | URL, signal?: AbortSignal); | ||
/** | ||
* Immediately create a BareClient. | ||
* @param server A full URL to the bare server. | ||
* @param manfiest A Bare server manifest. | ||
*/ | ||
constructor(server: string | URL, manfiest: BareManifest); | ||
private demand; | ||
private getClient; | ||
request(method: BareMethod, requestHeaders: BareHeaders, body: BareBodyInit, protocol: BareHTTPProtocol, host: string, port: string | number, path: string, cache: BareCache | undefined, signal: AbortSignal | undefined): Promise<BareResponse>; | ||
@@ -84,4 +97,4 @@ connect(requestHeaders: BareHeaders, protocol: BareWSProtocol, host: string, port: string | number, path: string): Promise<BareWebSocket>; | ||
* @param url | ||
* @param headers | ||
* @param protocols | ||
* @param origin Location of client that created the WebSocket | ||
* @returns | ||
@@ -92,1 +105,8 @@ */ | ||
} | ||
/** | ||
* | ||
* Facilitates fetching the Bare server and constructing a BareClient. | ||
* @param server Bare server | ||
* @param signal Abort signal when fetching the manifest | ||
*/ | ||
export declare function createBareClient(server: string | URL, signal?: AbortSignal): Promise<BareClient>; |
@@ -1,2 +0,2 @@ | ||
import { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient'; | ||
import type { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient'; | ||
export declare const statusEmpty: number[]; | ||
@@ -3,0 +3,0 @@ export declare const statusRedirect: number[]; |
@@ -1,2 +0,1 @@ | ||
import BareClient from './BareClient'; | ||
export default BareClient; | ||
export { createBareClient as default } from './BareClient'; |
@@ -1,2 +0,1 @@ | ||
export declare const global: typeof globalThis; | ||
export declare const fetch: typeof globalThis.fetch; | ||
@@ -3,0 +2,0 @@ export declare const WebSocket: { |
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
export declare function splitHeaders(headers: Readonly<Headers>): Headers; | ||
export declare function splitHeaders(headers: Headers): Headers; | ||
/** | ||
@@ -14,2 +14,2 @@ * Joins headers according to spec | ||
*/ | ||
export declare function joinHeaders(headers: Readonly<Headers>): Headers; | ||
export declare function joinHeaders(headers: Headers): Headers; |
@@ -1,3 +0,4 @@ | ||
import { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient.js'; | ||
import Client, { GenericClient } from './Client.js'; | ||
import type { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient.js'; | ||
import type { GenericClient } from './Client.js'; | ||
import Client from './Client.js'; | ||
export default class ClientV1 extends Client implements GenericClient { | ||
@@ -4,0 +5,0 @@ ws: URL; |
@@ -1,3 +0,4 @@ | ||
import { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient'; | ||
import Client, { GenericClient } from './Client'; | ||
import type { BareBodyInit, BareCache, BareHeaders, BareHTTPProtocol, BareMethod, BareResponse, BareWebSocket, BareWSProtocol } from './BareClient'; | ||
import type { GenericClient } from './Client'; | ||
import Client from './Client'; | ||
export default class ClientV2 extends Client implements GenericClient { | ||
@@ -4,0 +5,0 @@ ws: URL; |
{ | ||
"name": "@tomphttp/bare-client", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/tomphttp", | ||
@@ -20,4 +20,3 @@ "bugs": { | ||
"build": "rollup -c", | ||
"build:watch": "rollup -cw", | ||
"prepare": "node scripts/prepare.js" | ||
"build:watch": "rollup -cw" | ||
}, | ||
@@ -27,17 +26,14 @@ "type": "module", | ||
"exports": { | ||
"import": "./dist/BareClient.esm.js", | ||
"require": "./dist/BareClient.umd.cjs" | ||
"import": "./dist/BareClient.js", | ||
"require": "./dist/BareClient.cjs" | ||
}, | ||
"unpkg": "dist/BareClient.umd.min.cjs", | ||
"browser": "dist/BareClient.umd.min.cjs", | ||
"main": "dist/BareClient.umd.cjs", | ||
"module": "dist/BareClient.esm.js", | ||
"browser": "dist/BareClient.cjs", | ||
"main": "dist/BareClient.cjs", | ||
"module": "dist/BareClient.js", | ||
"types": "dist/BareClient.d.ts", | ||
"files": [ | ||
"dist", | ||
"scripts" | ||
"dist" | ||
], | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "^3.4.2", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-inject": "^4.0.4", | ||
@@ -47,12 +43,7 @@ "@typescript-eslint/eslint-plugin": "^5.31.0", | ||
"eslint": "^8.20.0", | ||
"husky": "^8.0.1", | ||
"prettier": "^2.7.1", | ||
"rollup": "^2.77.2", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.32.1" | ||
}, | ||
"lint-staged": { | ||
"*.{mjs, cjs, js, ts, json}": "prettier --write" | ||
} | ||
} |
@@ -5,2 +5,4 @@ # Bare Client | ||
See the [changelog](./CHANGELOG.md). | ||
## Quickstart | ||
@@ -11,23 +13,11 @@ | ||
```html | ||
<script src="https://unpkg.com/@tomphttp/bare-client@1.0.2-beta-rollup6/dist/BareClient.umd.min.cjs"></script> | ||
<script src="https://unpkg.com/@tomphttp/bare-client@1.1.0/dist/BareClient.cjs"></script> | ||
``` | ||
1. Install | ||
ESM/bundler: | ||
```sh | ||
npm install @tomphttp/bare-client | ||
$ npm i @tomphttp/bare-client | ||
``` | ||
2. Include in your code | ||
```js | ||
import BareClient from '@tomphttp/bare-client'; | ||
const client = new BareClient('https://uv.holyubofficial.net/'); | ||
// ... | ||
const response = await client.fetch('https://www.google.com/'); | ||
console.log(response.status, await response.text()); | ||
``` | ||
See [examples/](examples/). |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
9
2065
252286
16
22
19