@spine-event-engine/client-web 2.0.0-snapshot.2 → 2.0.0-snapshot.6

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.
Files changed (2) hide show
  1. package/README.md +37 -10
  2. package/package.json +4 -5
package/README.md CHANGED
@@ -7,9 +7,31 @@ in `@spine-event-engine/client-react`.
7
7
  For protocol, browser-session, reconnect, and security limits, read the
8
8
  [reference](REFERENCE.md).
9
9
 
10
- The [browser client and gateway guide](../../docs/BROWSER_CLIENT_AUTH_EXTENSION_GUIDE.md)
10
+ The [browser client and gateway guide](https://github.com/SpineEventEngine/spine-ts/blob/master/docs/BROWSER_CLIENT_AUTH_EXTENSION_GUIDE.md)
11
11
  explains application sign-in and gateway composition.
12
12
 
13
+ ## Install and prepare an application
14
+
15
+ This is an experimental snapshot. In a browser application with its generated
16
+ Proto model already available, install every package imported by the browser
17
+ examples explicitly:
18
+
19
+ ```sh
20
+ pnpm add @bufbuild/protobuf@2.12.1 @spine-event-engine/core@snapshot @spine-event-engine/proto@snapshot @spine-event-engine/client-web@snapshot
21
+ ```
22
+
23
+ Generate your application's model from its authored Proto sources with the
24
+ [Proto tools guide](https://github.com/SpineEventEngine/spine-ts/tree/master/packages/proto-tools#readme), then import its published
25
+ schemas from your own model package. The Message Board schema used below is a
26
+ repository example of that application-owned output, not a package to install.
27
+
28
+ Before the first request, provide an application Gateway endpoint that permits
29
+ the browser origin, selects either gRPC-Web or binary Connect, and establishes
30
+ the application's cookie or bearer session. The Gateway resolves credentials
31
+ and authorizes requests; this package does not create it, sign users in, or
32
+ provide a model package. See the [reference](REFERENCE.md) for the complete
33
+ public contract.
34
+
13
35
  ## 💡 Why use it?
14
36
 
15
37
  - ✅ Uses browser-compatible gRPC-Web or Connect transports.
@@ -23,12 +45,13 @@ Choose the protocol deliberately. gRPC-Web is the portable browser choice.
23
45
  Connect is an optional binary optimization for a gateway already configured to
24
46
  accept it; the client does not probe or fall back between protocols.
25
47
 
48
+ <!-- docs-snippet-path: examples/message-board/web/src/docs/client-web-create-client.ts -->
49
+
26
50
  ```ts
27
- // docs-snippet-path: examples/message-board/web/src/index.tsx
28
51
  import { BrowserSession, Client } from "@spine-event-engine/client-web";
29
52
 
30
53
  const session = BrowserSession.cookie({ maxRequestMs: 10_000 });
31
- const client = Client.forGrpcWeb("https://api.example.test", {
54
+ const client = Client.forGrpcWeb("http://127.0.0.1:8080", {
32
55
  tenant: "tasks",
33
56
  credentials: session.credentials,
34
57
  onRequestMetadata: () => session.requestMetadata(),
@@ -38,16 +61,20 @@ await client.close();
38
61
  await session.close();
39
62
  ```
40
63
 
41
- The endpoint should be an application gateway. Applications provide sign-in,
42
- identity-provider redirects, session exchange, and authorization policy.
64
+ Use `forGrpcWeb()` for a gRPC-Web Gateway. Use `forConnect()` only when that
65
+ Gateway is separately configured for binary Connect (`application/proto`);
66
+ neither factory probes or falls back to the other protocol. The endpoint above
67
+ is illustrative: the local application must actually expose the chosen browser
68
+ protocol and allow its origin.
43
69
 
44
70
  ## 📬 Post commands and send queries
45
71
 
46
72
  Use an actor or guest request scope. Commands return an application outcome;
47
73
  queries return the raw Spine response.
48
74
 
75
+ <!-- docs-snippet-path: examples/message-board/web/src/docs/client-web-request-subscription.ts -->
76
+
49
77
  ```ts
50
- // docs-snippet-path: examples/message-board/web/src/index.tsx
51
78
  import { create } from "@bufbuild/protobuf";
52
79
  import { TypeUrls } from "@spine-event-engine/core";
53
80
  import { Client } from "@spine-event-engine/client-web";
@@ -61,7 +88,7 @@ import {
61
88
  } from "@spine-event-engine/proto/client";
62
89
  import { BoardMessageViewSchema } from "@spine-event-engine/example-message-board-model/generated/spine/examples/messageboard/message_board_pb.js";
63
90
 
64
- const client = Client.forGrpcWeb("https://api.example.test");
91
+ const client = Client.forGrpcWeb("http://127.0.0.1:8080");
65
92
  const request = client.onBehalfOf("alice");
66
93
  const target = create(TargetSchema, {
67
94
  type: TypeUrls.derive(BoardMessageViewSchema),
@@ -109,7 +136,7 @@ may be duplicated, reordered, or missed while disconnected.
109
136
 
110
137
  ## 🔗 Learn more
111
138
 
112
- - [React adapter](../client-react/README.md)
113
- - [Authentication package](../auth/README.md)
114
- - [Browser authentication and extension guide](../../docs/BROWSER_CLIENT_AUTH_EXTENSION_GUIDE.md)
139
+ - [React adapter](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/client-react/README.md)
140
+ - [Authentication package](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/auth/README.md)
141
+ - [Browser authentication and extension guide](https://github.com/SpineEventEngine/spine-ts/blob/master/docs/BROWSER_CLIENT_AUTH_EXTENSION_GUIDE.md)
115
142
  - [Detailed coding-agent reference](REFERENCE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spine-event-engine/client-web",
3
- "version": "2.0.0-snapshot.2",
3
+ "version": "2.0.0-snapshot.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -10,8 +10,7 @@
10
10
  },
11
11
  "publishConfig": {
12
12
  "registry": "https://registry.npmjs.org/",
13
- "access": "public",
14
- "tag": "snapshot"
13
+ "access": "public"
15
14
  },
16
15
  "description": "Browser-safe Spine client transport kernel.",
17
16
  "exports": {
@@ -29,8 +28,8 @@
29
28
  "@bufbuild/protobuf": "2.12.1",
30
29
  "@connectrpc/connect": "2.1.2",
31
30
  "@connectrpc/connect-web": "2.1.2",
32
- "@spine-event-engine/core": "2.0.0-snapshot.2",
33
- "@spine-event-engine/proto": "2.0.0-snapshot.2"
31
+ "@spine-event-engine/core": "2.0.0-snapshot.6",
32
+ "@spine-event-engine/proto": "2.0.0-snapshot.6"
34
33
  },
35
34
  "scripts": {
36
35
  "check:dependencies": "node ../../scripts/check-client-web-dependencies.mjs"