Skip to content

Commit

Permalink
fix(build): dev server compatibility (#188)
Browse files Browse the repository at this point in the history
* fix circular imports

* refactor: revert to isomorphic-ws package

* ci: add bundling test

* ci: share js client tarball between jobs

* ci: bundling test depends on packaging

* ci: wip

* ci: only cancel jobs for current wf

* ci: temporarily disable integration test

* ci: wip

* ci: wip

* ci: wip

* ci: wip

* ci: wip

* ci: wip

* break to verify

* ci: enable macos

* ci: enable node matrix

* ci: re-enable integration test

* ci: rename integration test job

* fix: shim crypto

* bulld: update nix flake

* build: revert to hopefully cachixed flake lock
  • Loading branch information
jost-s authored Apr 29, 2023
1 parent bb1e17d commit b10625f
Show file tree
Hide file tree
Showing 26 changed files with 168 additions and 102 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/bundling-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Bundling Test

on:
pull_request:
push:
branches:
- "main"

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: [16, 18]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install NPM packages
run: npm ci

- name: Build client library
run: npm run build

- name: Create package tarball
run: npm pack

- name: Upload package tarball
uses: actions/upload-artifact@v3
with:
name: client-${{ matrix.node }}.tgz
path: holochain-client-*.tgz

- name: Setup tmate session if a previous step failed
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 10

bundle-test:
needs: build
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: [16, 18]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: Download package tarball
uses: actions/download-artifact@v3
with:
name: client-${{ matrix.node }}.tgz

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Create a Vite project from template
run: npm create vite@latest test-app -- --template vanilla-ts

- name: Add JS client to project
run: |
cd test-app
npm i $(ls ../holochain-client-*.tgz)
- name: Write Vite config to set build target to ES2020
run: |
cd test-app
echo 'export default { build:{ target: "es2020" } }' > vite.config.js
- name: Write client import to main.js
run: |
cd test-app
echo 'import * as client from "@holochain/client";' > main.js
- name: Bundle app for production
run: |
cd test-app
npm run build
- name: Setup tmate session if a previous step failed
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Integration Test

on:
pull_request:
Expand All @@ -7,11 +7,11 @@ on:
- "main"

concurrency:
group: ${{ github.ref_name }}
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
test:
integration-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
Expand Down
6 changes: 3 additions & 3 deletions docs/client.dnastorageblob.dna.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [DnaStorageBlob](./client.dnastorageblob.md) &gt; [Dna](./client.dnastorageblob.dna.md)
[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [DnaStorageBlob](./client.dnastorageblob.md) &gt; [dna](./client.dnastorageblob.dna.md)

## DnaStorageBlob.Dna property
## DnaStorageBlob.dna property

**Signature:**

```typescript
Dna: DnaStorageInfo;
dna: DnaStorageInfo;
```
2 changes: 1 addition & 1 deletion docs/client.dnastorageblob.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export interface DnaStorageBlob

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [Dna](./client.dnastorageblob.dna.md) | | [DnaStorageInfo](./client.dnastorageinfo.md) | |
| [dna](./client.dnastorageblob.dna.md) | | [DnaStorageInfo](./client.dnastorageinfo.md) | |

13 changes: 0 additions & 13 deletions docs/client.isowebsocket.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@
| [InstalledAppInfoStatus](./client.installedappinfostatus.md) | |
| [InstalledCell](./client.installedcell.md) | |
| [IntegrityZome](./client.integrityzome.md) | |
| [IsoWebSocket](./client.isowebsocket.md) | Isomorphic wrapper around WebSocket for compatiblity with Nodejs and Web API. |
| [KitsuneAgent](./client.kitsuneagent.md) | |
| [KitsuneSpace](./client.kitsunespace.md) | |
| [ListActiveAppsRequest](./client.listactiveappsrequest.md) | |
Expand Down
2 changes: 1 addition & 1 deletion docs/client.networkinforequest.agent_pub_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The calling agent

<b>Signature:</b>
**Signature:**

```typescript
agent_pub_key: AgentPubKey;
Expand Down
2 changes: 1 addition & 1 deletion docs/client.networkinforequest.last_time_queried.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX\_EPOCH.

<b>Signature:</b>
**Signature:**

```typescript
last_time_queried?: number;
Expand Down
2 changes: 1 addition & 1 deletion docs/client.networkinforequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export interface NetworkInfoRequest
| --- | --- | --- | --- |
| [agent\_pub\_key](./client.networkinforequest.agent_pub_key.md) | | [AgentPubKey](./client.agentpubkey.md) | The calling agent |
| [dnas](./client.networkinforequest.dnas.md) | | [DnaHash](./client.dnahash.md)<!-- -->\[\] | Get network info for these DNAs |
| [last\_time\_queried?](./client.networkinforequest.last_time_queried.md) | | number | <i>(Optional)</i> Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX\_EPOCH. |
| [last\_time\_queried?](./client.networkinforequest.last_time_queried.md) | | number | _(Optional)_ Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX\_EPOCH. |

2 changes: 1 addition & 1 deletion docs/client.randombytearray.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
**Signature:**

```typescript
randomByteArray: (length: number) => Promise<Uint8Array>
randomByteArray: (length: number) => Uint8Array
```
2 changes: 1 addition & 1 deletion docs/client.randomcapsecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
**Signature:**

```typescript
randomCapSecret: () => Promise<CapSecret>
randomCapSecret: () => CapSecret
```
2 changes: 1 addition & 1 deletion docs/client.randomnonce.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
**Signature:**

```typescript
randomNonce: () => Promise<Nonce256Bit>
randomNonce: () => Nonce256Bit
```
2 changes: 1 addition & 1 deletion docs/client.wsclient._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ constructor(socket: IsoWebSocket);

| Parameter | Type | Description |
| --- | --- | --- |
| socket | [IsoWebSocket](./client.isowebsocket.md) | |
| socket | IsoWebSocket | |

2 changes: 1 addition & 1 deletion docs/client.wsclient.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export declare class WsClient extends Emittery
| --- | --- | --- | --- |
| [index](./client.wsclient.index.md) | | number | |
| [pendingRequests](./client.wsclient.pendingrequests.md) | | Record&lt;number, { resolve: (msg: unknown) =&gt; ReturnType&lt;typeof decode&gt;; reject: (error: Error) =&gt; void; }&gt; | |
| [socket](./client.wsclient.socket.md) | | [IsoWebSocket](./client.isowebsocket.md) | |
| [socket](./client.wsclient.socket.md) | | IsoWebSocket | |
## Methods
Expand Down
17 changes: 16 additions & 1 deletion package-lock.json

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

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"homepage": "https://github.com/holochain/holochain-client-js#readme",
"engines": {
"node": "^14.13.1 || >=16.0.0 || >=18.0.0"
"node": ">=16.0.0 || >=18.0.0"
},
"main": "lib/index.js",
"module": "lib/index.js",
Expand All @@ -30,22 +30,21 @@
"files": [
"lib"
],
"browser": {
"crypto": false
},
"scripts": {
"lint": "eslint --fix --ext .ts src test .eslintrc.cjs",
"test:app-agent": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/e2e/app-agent-websocket.ts",
"test": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/index.ts",
"build:lib": "rimraf ./lib && tsc -p tsconfig.build.json",
"build:docs": "api-extractor run --local && api-documenter markdown -i docs/temp -o docs",
"build": "rimraf ./lib && tsc -p tsconfig.build.json && npm run build:docs"
"build": "npm run build:lib && npm run build:docs"
},
"dependencies": {
"@holochain/serialization": "^0.1.0-beta-rc.3",
"@msgpack/msgpack": "^2.7.2",
"@noble/ed25519": "^2.0.0",
"@tauri-apps/api": "^1.2.0",
"emittery": "^1.0.1",
"isomorphic-ws": "^5.0.0",
"js-base64": "^3.7.3",
"lodash-es": "^4.17.21",
"ws": "^8.13.0"
Expand Down
2 changes: 1 addition & 1 deletion src/api/admin/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class AdminWebsocket implements AdminApi {
functions: GrantedFunctions,
signingKey: AgentPubKey
): Promise<CapSecret> => {
const capSecret = await randomCapSecret();
const capSecret = randomCapSecret();
await this.grantZomeCallCapability({
cell_id: cellId,
cap_grant: {
Expand Down
9 changes: 4 additions & 5 deletions src/api/app-agent/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ import { omit } from "lodash-es";
import { getLauncherEnvironment } from "../../environments/launcher.js";

import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
import { AppInfo, CellType } from "../admin/types.js";
import {
AppInfo,
AppSignal,
AppSignalCb,
AppWebsocket,
CallZomeRequest,
CallZomeResponse,
CellType,
CreateCloneCellResponse,
DisableCloneCellResponse,
EnableCloneCellResponse,
} from "../index.js";
} from "../app/types.js";
import { AppWebsocket } from "../app/websocket.js";
import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
import {
AppAgentCallZomeRequest,
AppAgentClient,
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
MembraneProof,
NetworkSeed,
ZomeName,
} from "../admin/index.js";
} from "../admin/types.js";
import { Requester } from "../common.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const signZomeCall = async (request: CallZomeRequest) => {
fn_name: request.fn_name,
provenance: signingCredentialsForCell.signingKey,
payload: encode(request.payload),
nonce: await randomNonce(),
nonce: randomNonce(),
expires_at: getNonceExpiration(),
};
const hashedZomeCall = await hashZomeCall(unsignedZomeCallPayload);
Expand Down
Loading

0 comments on commit b10625f

Please sign in to comment.