Skip to content

Conversation

nikgraf
Copy link
Collaborator

@nikgraf nikgraf commented May 9, 2025

  • upgrade to latest automerge beta (needed to change the find logic)
  • fixes imports in Inbox (the package was referencing itself, vite is ok with that, but next doesn't like it)
  • manually load wasm as base64 encoded string instead
    • not vite wasm plugin needed and Turbopack for example has no WASM support yet
    • Downsides are:
      • larger bundle size
      • the Provider currently is rendering null until the automerge is loaded. (Need to think about a more elegant solution!)

The nextjs example could be improved. Added an issue here: #181

@nikgraf nikgraf self-assigned this May 9, 2025
@nikgraf nikgraf force-pushed the ng/nextjs-support branch 3 times, most recently from f130705 to d26d034 Compare May 9, 2025 12:24
@nikgraf nikgraf requested review from cmwhited, Copilot and pcarranzav May 9, 2025 12:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates various import statements and dependency versions to support the hypergraph functionality in Next.js, while switching to the automerge slim build and manually loading the WASM bundle. Key changes include:

  • Fixing import paths for Messages, Identity, and related modules across inbox and event files.
  • Upgrading "@automerge/automerge-repo" (and its react hooks) from beta 2 to beta 5.
  • Adding Next.js specific configuration files and usage instructions in the next-example app.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/hypergraph/src/inboxes/*.ts Updated import paths to use local module references.
packages/hypergraph/package.json Upgraded automerge-repo dependency version to beta 5.
packages/hypergraph-react/src/HypergraphSpaceContext.tsx Updated repo lookup to use findWithProgress for better progress reporting.
packages/hypergraph-react/src/HypergraphAppContext.tsx Switched to automerge slim; initialized WASM and fixed import paths.
apps/next-example/** Added/updated config, tsconfig, and provider components for Next.js support.
README.md Improved documentation on running the Next.js example app.
Comments suppressed due to low confidence (2)

packages/hypergraph-react/src/HypergraphAppContext.tsx:1370

  • [nitpick] Consider extracting the hard-coded maxAttempts constant into a configurable parameter or named constant to enhance the maintainability and flexibility of the retry logic.
const maxAttempts = 10;

packages/hypergraph-react/src/HypergraphAppContext.tsx:6

  • Consider adding a reference to an external issue or a TODO comment with context regarding the missing type definitions in the Automerge package to improve maintainability.
// @ts-expect-error not properly typed and exported in the automerge package

@nikgraf nikgraf force-pushed the ng/nextjs-support branch 2 times, most recently from 9dfd86c to af2a151 Compare May 9, 2025 12:47
import { Effect } from 'effect';
import { bytesToHex, hexToBytes, stringToUint8Array } from '../utils/index.js';
import { canonicalize } from '../utils/index.js';
import type * as Inboxes from '../inboxes/types.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be './types.js'

},
setSpaceFromList: (context, event: { spaceId: string }) => {
if (!context.repo) {
return context;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will silently fail to set the space... should we fail more loudly if this happens?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I like it, but couldn't think of something useful. What do you have in mind?

(btw setSpaceFromList never runs afaik if repo is not set)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's something that should never happen, maybe throwing an error would be best?

@nikgraf nikgraf force-pushed the ng/nextjs-support branch from af2a151 to c2d3a0b Compare May 9, 2025 13:32
@nikgraf nikgraf merged commit 53b4183 into main May 9, 2025
4 checks passed
@nikgraf nikgraf deleted the ng/nextjs-support branch May 9, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants