Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope and rename grpc-web-client package #290

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ This library is tested against:

## Node.js Support

`grpc-web-client` also [supports Node.js through a transport](./client/grpc-web-client/docs/transport.md#node-http-only-available-in-a-nodejs-environment) that uses the `http` and `https` packages. Usage does not vary from browser usage as transport is determined at runtime.
`grpc-web-client` also [supports Node.js through a transport](./client/grpc-web/docs/transport.md#node-http-only-available-in-a-nodejs-environment) that uses the `http` and `https` packages. Usage does not vary from browser usage as transport is determined at runtime.

If you want to use `grpc-web-client` in a node.js environment with Typescript, you must include `dom` in the `"lib"` Array in your `tsconfig.json` otherwise `tsc` will be unable to find some type declarations to compile. Note that `dom` will be included automatically if you do not declare `lib` in your configration and your target is one of `es5` or `es6`. (See [Typescript compiler options](https://www.typescriptlang.org/docs/handbook/compiler-options.html)).

Expand All @@ -171,7 +171,7 @@ This, however, is useful for a lot of frontend functionality.
The code here is `alpha` quality. It is being used for a subset of Improbable's frontend single-page apps in production.

## Known Limitations
See the grpc-web-client's Transport Documentation for [a list of Web Browser caveats](./client/grpc-web-client/docs/transport.md#http/2-based-transports).
See the grpc-web-client's Transport Documentation for [a list of Web Browser caveats](./client/grpc-web/docs/transport.md#http/2-based-transports).

### Contributing
See [CONTRIBUTING](./CONTRIBUTING.md)
13 changes: 13 additions & 0 deletions client/grpc-web-node-http-transport/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 30 additions & 6 deletions client/grpc-web-react-example/go/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/grpc-web-react-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "none",
"dependencies": {
"google-protobuf": "^3.6.1",
"grpc-web-client": "0.6.2"
"grpc-web-client": "^0.6.2"
},
"devDependencies": {
"@types/google-protobuf": "^3.2.5",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# grpc-web-client
# @improbable-eng/grpc-web
> Library for making gRPC-Web requests from a browser

This library is intended for both JavaScript and TypeScript usage from a web browser or NodeJS (see [Usage with NodeJS](#usage-with-nodejs)).
Expand All @@ -11,9 +11,9 @@ Please see the full [gRPC-Web README](https://github.com/improbable-eng/grpc-web

## Installation

`grpc-web-client` has peer dependencies of `google-protobuf` and `@types/google-protobuf`.
`@improbable-eng/grpc-web` has peer dependencies of `google-protobuf` and `@types/google-protobuf`.

`npm install google-protobuf @types/google-protobuf grpc-web-client --save`
`npm install google-protobuf @types/google-protobuf @improbable-eng/grpc-web --save`

## Example Project

Expand All @@ -25,7 +25,7 @@ There is an [example project available here](https://github.com/improbable-eng/g
* Make a request using [`unary()`](docs/unary.md), [`invoke()`](docs/invoke.md) or [`client()`](docs/client.md)

```javascript
import {grpc} from "grpc-web-client";
import {grpc} from "@improbable-eng/grpc-web";

// Import code-generated data structures.
import {BookService} from "./generated/proto/examplecom/library/book_service_pb_service";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ A gRPC request goes through the following stages:

### Transport Limitations

Sending multiple messages and indicating that the client has finished sending are complicated by the nature of some of the transports used by `grpc-web-client`:
Sending multiple messages and indicating that the client has finished sending are complicated by the nature of some of the transports used by `@improbable-eng/grpc-web`.

Most browser networking methods do not allow control over the sending of the body of the request, meaning that sending a single request message forces the finishing of sending, limiting these transports to unary or server-streaming methods only.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ service BookService {

Will generate `book_service_pb.js`, `book_service_pb.d.ts`, `book_service_pb_service.js` and `book_service_pb_service.d.ts`

The first two files contain the message classes while the lst two contain a `BookService.GetBook` class that acts as [method definition](concepts.md#method-definition) that can be used with `grpc-web-client`.
The first two files contain the message classes while the lst two contain a `BookService.GetBook` class that acts as [method definition](concepts.md#method-definition) that can be used with `@improbable-eng/grpc-web`.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This page describes various concepts referred to within the gRPC-Web documentati
### Method Definition
A method definition includes the service and method names, request and response types and whether the method is client-streaming and/or server-streaming.

Definitions of the format used by `grpc-web-client` can be generated using the [`ts-protoc-gen`](https://github.com/improbable-eng/ts-protoc-gen) plugin for [protoc](https://github.com/google/protobuf). See [code generation](code-generation) for instructions.
Definitions of the format used by `@improbable-eng/grpc-web` can be generated using the [`ts-protoc-gen`](https://github.com/improbable-eng/ts-protoc-gen) plugin for [protoc](https://github.com/google/protobuf). See [code generation](code-generation) for instructions.

#### Example method definition:
```javascript
Expand All @@ -26,7 +26,7 @@ export namespace BookService {
### Metadata
Metadata is a collection of key-value pairs sent by the client to the server and then from the server to the client both before the response (headers) and after the response (trailers). One use case for metadata is for sending authentication tokens from a client.

`grpc-web-client` uses the [`js-browser-headers`](https://github.com/improbable-eng/js-browser-headers) library to provide a consistent implementation of the Headers class across browsers. The `BrowserHeaders` class from this library is aliased to `grpc.Metadata`.
`@improbable-eng/grpc-web` uses the [`js-browser-headers`](https://github.com/improbable-eng/js-browser-headers) library to provide a consistent implementation of the Headers class across browsers. The `BrowserHeaders` class from this library is aliased to `grpc.Metadata`.

### Status Codes
Upon completion a gRPC request will expose a status code indicating how the request ended. This status code can be provided by the server in the [Metadata](#metadata), but if the request failed or the server did not include a status code then the status code is determined by the client.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Transports

`grpc-web-client` is a library for JavaScript-based clients to communicate with servers which can talk the `grpc-web` protocol.
`@improbable-eng/grpc-web` is a library for JavaScript-based clients to communicate with servers which can talk the `grpc-web` protocol.

To enable this communication, `grpc-web-client` uses Transports provides built-in transports which abstract the underlying browser primitives.
To enable this communication, `@improbable-eng/grpc-web` uses Transports provides built-in transports which abstract the underlying browser primitives.

## Specifying Transports
You can tell `grpc-web-client` which Transport to use either on a per-request basis, or by configuring the Default Transport in your application.
You can tell `@improbable-eng/grpc-web` which Transport to use either on a per-request basis, or by configuring the Default Transport in your application.

### Specifying the Default Transport
The Default Transport is used for every call unless a specific transport has been provided when the call is made. `gprc-web-client` will default to using the `CrossBrowserHttpTransport`, however you can re-configure this:
The Default Transport is used for every call unless a specific transport has been provided when the call is made. `@improbable-eng/grpc-web` will default to using the `CrossBrowserHttpTransport`, however you can re-configure this:

```typescript
import {grpc} from "grpc-web-client";
import {grpc} from "@improbable-eng/grpc-web";

// 'myTransport' is configured to send Browser cookies along with cross-origin requests.
const myTransport = grpc.CrossBrowserHttpTransport({ withCredentials: true });
Expand All @@ -21,10 +21,10 @@ grpc.setDefaultTransport(myTransport);
```

### Specifying the Transport on a per-request basis
As mentioned above, `grpc-web-client` will use the Default Transport if none is specified with the call; you can override this behavior by setting the optional `transport` property when calling `unary()`, `invoke()` or `client()`:
As mentioned above, `@improbable-eng/grpc-web` will use the Default Transport if none is specified with the call; you can override this behavior by setting the optional `transport` property when calling `unary()`, `invoke()` or `client()`:

```typescript
import {grpc} from "grpc-web-client";
import {grpc} from "@improbable-eng/grpc-web";

// 'myTransport' is configured to send Browser cookies along with cross-origin requests.
const myTransport = grpc.CrossBrowserHttpTransport({ withCredentials: true });
Expand All @@ -36,13 +36,12 @@ const client = grpc.client(BookService.QueryBooks, {


## Built-in Transports
`grpc-web-client` ships with two categories of Transports: [HTTP/2-based](#http/2-based-transports) and [socket-based](#socket-based-transports):
`@improbable-eng/grpc-web` ships with two categories of Transports: [HTTP/2-based](#http/2-based-transports) and [socket-based](#socket-based-transports):

### HTTP/2-based Transports
It's great that we have more than one choice when it comes to Web Browsers, however the inconsistencies and limited feature-sets can be frustrating. Whilst `grpc-web-client` looks to abstract as much of this as possible with the `CrossBrowserHttpTransport` there are some caveats all application developers who make use of `grpc-web-client`'s HTTP/2 based transports should be aware of:
It's great that we have more than one choice when it comes to Web Browsers, however the inconsistencies and limited feature-sets can be frustrating. Whilst `@improbable-eng/grpc-web` looks to abstract as much of this as possible with the `CrossBrowserHttpTransport` there are some caveats all application developers who make use of `@improbable-eng/grpc-web`'s HTTP/2 based transports should be aware of:

* gRPC offers four categories of request: unary, server-streaming, client-streaming and bi-directional. Due to limitations of the Browser HTTP primitives (`fetch` and `XMLHttpRequest`), the HTTP/2-based transports provided by `grpc-web-client
can only support unary and server-streaming requests. Attempts to invoke either client-streaming or bi-directional endpoints will result in failure.
* gRPC offers four categories of request: unary, server-streaming, client-streaming and bi-directional. Due to limitations of the Browser HTTP primitives (`fetch` and `XMLHttpRequest`), the HTTP/2-based transports provided by `@improbable-eng/grpc-web` can only support unary and server-streaming requests. Attempts to invoke either client-streaming or bi-directional endpoints will result in failure.
* Older versions of Safari (<7) and all versions of Internet Explorer do not provide an efficient way to stream data from a server; this will result in the entire response of a gRPC client-stream being buffered into memory which can cause performance and stability issues for end-users.
* Microsoft Edge does not propagate the cancellation of requests to the server; which can result in memory/process leaks on your server. Track this issue for status.

Expand Down
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grpc-web-client",
"version": "0.7.0",
"name": "@improbable-eng/grpc-web",
"version": "0.8.0",
"description": "gRPC-Web client for browsers (JS/TS)",
"main": "dist/grpc-web-client.js",
"browser": "dist/grpc-web-client.umd.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ then
npm run lib:build

echo "Staring npm publish"
npm publish --tag $TAG
npm publish --access public --tag $TAG

echo "Creating Github release branch release/v${VERSION}"
git checkout -b release/v${VERSION}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const packageJson = require("./package.json");

const LIB_BASE_CONFIG = {
entry: "./src/index.ts",
Expand All @@ -20,7 +19,7 @@ module.exports = [{
name: 'lib-commonjs',
...LIB_BASE_CONFIG,
output: {
filename: `${packageJson.name}.js`,
filename: `grpc-web-client.js`,
path: DIST_DIR,
libraryTarget: 'commonjs',
}
Expand All @@ -29,7 +28,7 @@ module.exports = [{
name: 'lib-umd',
...LIB_BASE_CONFIG,
output: {
filename: `${packageJson.name}.umd.js`,
filename: `grpc-web-client.umd.js`,
path: DIST_DIR,
libraryTarget: 'umd',
}
Expand Down
8 changes: 0 additions & 8 deletions integration_test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration_test/ts/src/ChunkParser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import { decodeASCII, encodeASCII } from "../../../client/grpc-web-client/src/ChunkParser";
import { decodeASCII, encodeASCII } from "../../../client/grpc-web/src/ChunkParser";
import { conditionallyRunTestSuite, SuiteEnum } from "../suiteUtils";

conditionallyRunTestSuite(SuiteEnum.ChunkParser, () => {
Expand Down
2 changes: 1 addition & 1 deletion integration_test/ts/src/cancellation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
grpc,
} from "grpc-web-client";

import {debug} from "../../../client/grpc-web-client/src/debug";
import {debug} from "../../../client/grpc-web/src/debug";
import {assert} from "chai";

// Generated Test Classes
Expand Down
2 changes: 1 addition & 1 deletion integration_test/ts/src/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// gRPC-Web library
import {grpc} from "grpc-web-client";

import {debug} from "../../../client/grpc-web-client/src/debug";
import {debug} from "../../../client/grpc-web/src/debug";
import {assert} from "chai";
// Generated Test Classes
import {Empty, } from "google-protobuf/google/protobuf/empty_pb";
Expand Down
2 changes: 1 addition & 1 deletion integration_test/ts/src/client.websocket.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// gRPC-Web library
import { grpc } from "grpc-web-client";

import { debug } from "../../../client/grpc-web-client/src/debug";
import { debug } from "../../../client/grpc-web/src/debug";
import { assert } from "chai";
// Generated Test Classes
import { PingRequest, PingResponse } from "../_proto/improbable/grpcweb/test/test_pb";
Expand Down
2 changes: 1 addition & 1 deletion integration_test/ts/src/detach.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from "chai";
import detach from "../../../client/grpc-web-client/src/detach";
import detach from "../../../client/grpc-web/src/detach";
import {UncaughtExceptionListener} from "./util";
import { conditionallyRunTestSuite, SuiteEnum } from "../suiteUtils";

Expand Down
2 changes: 1 addition & 1 deletion integration_test/ts/src/invoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
grpc,
} from "grpc-web-client";

import {debug} from "../../../client/grpc-web-client/src/debug";
import {debug} from "../../../client/grpc-web/src/debug";
import {assert} from "chai";

// Generated Test Classes
Expand Down
Loading