From a8343c68686a5437e3b37e73d40450d60a7eb272 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Tue, 17 Sep 2024 12:06:26 -0500 Subject: [PATCH] chore!: update to `@comapeo/core@1` (#19) --- README.md | 16 ++-- package-lock.json | 223 +++++++++++++++++++++++----------------------- package.json | 2 +- src/client.js | 12 +-- src/server.js | 4 +- tests/helpers.js | 10 +-- 6 files changed, 134 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index 4e8711f..4c00671 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# @mapeo/ipc +# @comapeo/ipc -IPC wrappers for [Mapeo Core](https://github.com/digidem/mapeo-core-next). Meant to be used in contexts where there is a communication boundary between the contexts your code runs in e.g. Electron, React Native (with NodeJS Mobile), and NodeJS worker threads. The [channel messaging API](https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API) is an example where this usage applies. +IPC wrappers for [CoMapeo Core](https://github.com/digidem/comapeo-core). Meant to be used in contexts where there is a communication boundary between the contexts your code runs in e.g. Electron, React Native (with NodeJS Mobile), and NodeJS worker threads. The [channel messaging API](https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API) is an example where this usage applies. ## Table of Contents @@ -11,17 +11,17 @@ IPC wrappers for [Mapeo Core](https://github.com/digidem/mapeo-core-next). Meant ## Installation -Note that [`@mapeo/core`](https://github.com/digidem/mapeo-core-next) is a peer dependency, so you may have to install it manually depending on your package manager. +Note that [`@comapeo/core`](https://github.com/digidem/comapeo-core) is a peer dependency, so you may have to install it manually depending on your package manager. ```sh -npm install @mapeo/ipc @mapeo/core +npm install @comapeo/ipc @comapeo/core ``` ## API ### `createMapeoServer(manager: MapeoManager, messagePort: MessagePortLike): { close: () => void }` -Creates the IPC server instance. `manager` is a `@mapeo/core` `MapeoManager` instance and `messagePort` is an interface that resembles a [`MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort). +Creates the IPC server instance. `manager` is a `@comapeo/core` `MapeoManager` instance and `messagePort` is an interface that resembles a [`MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort). Returns an object with a `close()` method, which removes relevant event listeners from the `messagePort`. Does not close or destroy the `messagePort`. @@ -40,8 +40,8 @@ Closes the IPC client instance. Does not close or destroy the `messagePort` prov In the server: ```ts -import { MapeoManager } from '@mapeo/core' -import { createMapeoServer } from '@mapeo/ipc' +import { MapeoManager } from '@comapeo/core' +import { createMapeoServer } from '@comapeo/ipc' // Create Mapeo manager instance const manager = new MapeoManager({...}) @@ -59,7 +59,7 @@ server.close() In the client: ```ts -import { createMapeoClient, closeMapeoClient } from '@mapeo/ipc' +import { createMapeoClient, closeMapeoClient } from '@comapeo/ipc' // Create the client instance // `messagePort` can vary based on context (e.g. a port from a MessageChannel, a NodeJS Mobile bridge channel, etc.) diff --git a/package-lock.json b/package-lock.json index 05aabf6..9dfd356 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "node": ">=18.17.1" }, "peerDependencies": { - "@mapeo/core": "9.0.0-alpha.25" + "@comapeo/core": "1.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -237,6 +237,117 @@ "node": ">=6.9.0" } }, + "node_modules/@comapeo/core": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@comapeo/core/-/core-1.0.0.tgz", + "integrity": "sha512-4NKQzIIFpFBXv+DGyGDib7/WfXdP+sKblzP3pXJCzUer/Q/RgynaFGXe9MNRxoAT0oCF2J6HyyTAs0kgoZoMMA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@comapeo/schema": "1.0.0", + "@digidem/types": "^2.3.0", + "@electron/asar": "^3.2.8", + "@fastify/error": "^3.4.1", + "@fastify/static": "^7.0.3", + "@fastify/type-provider-typebox": "^4.0.0", + "@hyperswarm/secret-stream": "^6.1.2", + "@mapeo/crypto": "1.0.0-alpha.10", + "@mapeo/sqlite-indexer": "1.0.0-alpha.9", + "@sinclair/typebox": "^0.29.6", + "b4a": "^1.6.3", + "bcp-47": "^2.1.0", + "better-sqlite3": "^8.7.0", + "big-sparse-array": "^1.0.3", + "bogon": "^1.1.0", + "compact-encoding": "^2.12.0", + "corestore": "^6.8.4", + "debug": "^4.3.4", + "dot-prop": "^9.0.0", + "drizzle-orm": "^0.30.8", + "fastify": ">= 4", + "fastify-plugin": "^4.5.1", + "hyperblobs": "2.3.0", + "hypercore": "10.17.0", + "hypercore-crypto": "3.4.2", + "hyperdrive": "11.5.3", + "json-stable-stringify": "^1.1.1", + "magic-bytes.js": "^1.10.0", + "map-obj": "^5.0.2", + "mime": "^4.0.3", + "multi-core-indexer": "^1.0.0-alpha.10", + "p-defer": "^4.0.0", + "p-event": "^6.0.1", + "p-timeout": "^6.1.2", + "protobufjs": "^7.2.3", + "protomux": "^3.4.1", + "quickbit-universal": "^2.2.0", + "sodium-universal": "^4.0.0", + "start-stop-state-machine": "^1.2.0", + "streamx": "^2.19.0", + "sub-encoder": "^2.1.1", + "throttle-debounce": "^5.0.0", + "tiny-typed-emitter": "^2.1.0", + "type-fest": "^4.5.0", + "undici": "^6.13.0", + "varint": "^6.0.0", + "yauzl-promise": "^4.0.0" + } + }, + "node_modules/@comapeo/core/node_modules/dot-prop": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-9.0.0.tgz", + "integrity": "sha512-1gxPBJpI/pcjQhKgIU91II6Wkay+dLcN3M6rf2uwP8hRur3HtQXjVrdAK3sjC0piaEuxzMwjXChcETiJl47lAQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "type-fest": "^4.18.2" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@comapeo/core/node_modules/hypercore": { + "version": "10.17.0", + "resolved": "https://registry.npmjs.org/hypercore/-/hypercore-10.17.0.tgz", + "integrity": "sha512-Yp9lyfUjp81Gy1nPHemNFtYQtngliCGZ6prH+qxvjr2FPVG1QFtNqtOh+ZxFu4hXZ1dAOLYkQOA7Qq2vjFe64A==", + "license": "MIT", + "peer": true, + "dependencies": { + "@hyperswarm/secret-stream": "^6.0.0", + "b4a": "^1.1.0", + "big-sparse-array": "^1.0.3", + "compact-encoding": "^2.11.0", + "crc-universal": "^1.0.2", + "events": "^3.3.0", + "flat-tree": "^1.9.0", + "hypercore-crypto": "^3.2.1", + "is-options": "^1.0.1", + "protomux": "^3.4.0", + "quickbit-universal": "^2.1.1", + "random-access-file": "^4.0.0", + "random-array-iterator": "^1.0.0", + "safety-catch": "^1.0.1", + "sodium-universal": "^4.0.0", + "streamx": "^2.12.4", + "xache": "^1.1.0", + "z32": "^1.0.0" + } + }, + "node_modules/@comapeo/schema": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@comapeo/schema/-/schema-1.0.0.tgz", + "integrity": "sha512-dK227I+0yg9D2y5/O5NGywx50tgeNYyUkl1uYnSmNAPlbv+r2KX9aaC9m4dEjIja2aR2VFnYn6z537ERZiahqQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "compact-encoding": "^2.12.0", + "protobufjs": "^7.2.5", + "type-fest": "^4.26.0" + } + }, "node_modules/@digidem/types": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@digidem/types/-/types-2.3.0.tgz", @@ -618,103 +729,6 @@ "node": ">=8" } }, - "node_modules/@mapeo/core": { - "version": "9.0.0-alpha.25", - "resolved": "https://registry.npmjs.org/@mapeo/core/-/core-9.0.0-alpha.25.tgz", - "integrity": "sha512-XOTLE0LZ6QPRx+lV2uMhnnhcJRn/jpldfQ6lQITaSC+xyc7Fsq6dFcx6TItH6OaJwM8AOkOJDlSUidlQZAg3xw==", - "license": "MIT", - "peer": true, - "dependencies": { - "@digidem/types": "^2.3.0", - "@electron/asar": "^3.2.8", - "@fastify/error": "^3.4.1", - "@fastify/static": "^7.0.3", - "@fastify/type-provider-typebox": "^4.0.0", - "@hyperswarm/secret-stream": "^6.1.2", - "@mapeo/crypto": "1.0.0-alpha.10", - "@mapeo/schema": "3.0.0-next.28", - "@mapeo/sqlite-indexer": "1.0.0-alpha.9", - "@sinclair/typebox": "^0.29.6", - "b4a": "^1.6.3", - "bcp-47": "^2.1.0", - "better-sqlite3": "^8.7.0", - "big-sparse-array": "^1.0.3", - "bogon": "^1.1.0", - "compact-encoding": "^2.12.0", - "corestore": "^6.8.4", - "debug": "^4.3.4", - "dot-prop": "^9.0.0", - "drizzle-orm": "^0.30.8", - "fastify": ">= 4", - "fastify-plugin": "^4.5.1", - "hyperblobs": "2.3.0", - "hypercore": "10.17.0", - "hypercore-crypto": "3.4.2", - "hyperdrive": "11.5.3", - "json-stable-stringify": "^1.1.1", - "magic-bytes.js": "^1.10.0", - "map-obj": "^5.0.2", - "mime": "^4.0.3", - "multi-core-indexer": "^1.0.0-alpha.10", - "p-defer": "^4.0.0", - "p-event": "^6.0.1", - "p-timeout": "^6.1.2", - "protobufjs": "^7.2.3", - "protomux": "^3.4.1", - "quickbit-universal": "^2.2.0", - "sodium-universal": "^4.0.0", - "start-stop-state-machine": "^1.2.0", - "streamx": "^2.19.0", - "sub-encoder": "^2.1.1", - "throttle-debounce": "^5.0.0", - "tiny-typed-emitter": "^2.1.0", - "type-fest": "^4.5.0", - "undici": "^6.13.0", - "varint": "^6.0.0", - "yauzl-promise": "^4.0.0" - } - }, - "node_modules/@mapeo/core/node_modules/dot-prop": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-9.0.0.tgz", - "integrity": "sha512-1gxPBJpI/pcjQhKgIU91II6Wkay+dLcN3M6rf2uwP8hRur3HtQXjVrdAK3sjC0piaEuxzMwjXChcETiJl47lAQ==", - "peer": true, - "dependencies": { - "type-fest": "^4.18.2" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@mapeo/core/node_modules/hypercore": { - "version": "10.17.0", - "resolved": "https://registry.npmjs.org/hypercore/-/hypercore-10.17.0.tgz", - "integrity": "sha512-Yp9lyfUjp81Gy1nPHemNFtYQtngliCGZ6prH+qxvjr2FPVG1QFtNqtOh+ZxFu4hXZ1dAOLYkQOA7Qq2vjFe64A==", - "peer": true, - "dependencies": { - "@hyperswarm/secret-stream": "^6.0.0", - "b4a": "^1.1.0", - "big-sparse-array": "^1.0.3", - "compact-encoding": "^2.11.0", - "crc-universal": "^1.0.2", - "events": "^3.3.0", - "flat-tree": "^1.9.0", - "hypercore-crypto": "^3.2.1", - "is-options": "^1.0.1", - "protomux": "^3.4.0", - "quickbit-universal": "^2.1.1", - "random-access-file": "^4.0.0", - "random-array-iterator": "^1.0.0", - "safety-catch": "^1.0.1", - "sodium-universal": "^4.0.0", - "streamx": "^2.12.4", - "xache": "^1.1.0", - "z32": "^1.0.0" - } - }, "node_modules/@mapeo/crypto": { "version": "1.0.0-alpha.10", "resolved": "https://registry.npmjs.org/@mapeo/crypto/-/crypto-1.0.0-alpha.10.tgz", @@ -733,19 +747,6 @@ "z32": "^1.0.0" } }, - "node_modules/@mapeo/schema": { - "version": "3.0.0-next.28", - "resolved": "https://registry.npmjs.org/@mapeo/schema/-/schema-3.0.0-next.28.tgz", - "integrity": "sha512-yiAaSgJAg9yR3E5YKfkDpE3bChlUmwIdqI+/x8Ly7RYZJ75EHMHA7yBUqSNUYwyPZ0xym6bXZ60Z0T4V41v58g==", - "license": "MIT", - "peer": true, - "dependencies": { - "ajv": "^8.12.0", - "compact-encoding": "^2.12.0", - "protobufjs": "^7.2.5", - "type-fest": "^4.26.0" - } - }, "node_modules/@mapeo/sqlite-indexer": { "version": "1.0.0-alpha.9", "resolved": "https://registry.npmjs.org/@mapeo/sqlite-indexer/-/sqlite-indexer-1.0.0-alpha.9.tgz", diff --git a/package.json b/package.json index 84e8abc..ddad318 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "rpc-reflector": "^1.3.11" }, "peerDependencies": { - "@mapeo/core": "9.0.0-alpha.25" + "@comapeo/core": "1.0.0" }, "devDependencies": { "@digidem/types": "^2.1.0", diff --git a/src/client.js b/src/client.js index 6de7315..3bcf754 100644 --- a/src/client.js +++ b/src/client.js @@ -8,13 +8,13 @@ import { } from './lib/sub-channel.js' /** - * @typedef {import('rpc-reflector/client.js').ClientApi} MapeoProjectApi + * @typedef {import('rpc-reflector/client.js').ClientApi} MapeoProjectApi */ /** * @typedef {import('rpc-reflector/client.js').ClientApi< * Omit< - * import('@mapeo/core').MapeoManager, + * import('@comapeo/core').MapeoManager, * 'getProject' * > & { * getProject: (projectPublicId: string) => Promise @@ -31,13 +31,13 @@ const CLOSE = Symbol('close') * @returns {MapeoClientApi} */ export function createMapeoClient(messagePort, opts = {}) { - /** @type {Map>>} */ + /** @type {Map>>} */ const projectClientPromises = new Map() const managerChannel = new SubChannel(messagePort, MANAGER_CHANNEL_ID) const mapeoRpcChannel = new SubChannel(messagePort, MAPEO_RPC_ID) - /** @type {import('rpc-reflector').ClientApi} */ + /** @type {import('rpc-reflector').ClientApi} */ const managerClient = createClient(managerChannel, opts) /** @type {import('rpc-reflector').ClientApi} */ const mapeoRpcClient = createClient(mapeoRpcChannel, opts) @@ -84,7 +84,7 @@ export function createMapeoClient(messagePort, opts = {}) { if (existingClientPromise) return existingClientPromise - /** @type {import('p-defer').DeferredPromise>}*/ + /** @type {import('p-defer').DeferredPromise>}*/ const deferred = pDefer() projectClientPromises.set(projectPublicId, deferred.promise) @@ -98,7 +98,7 @@ export function createMapeoClient(messagePort, opts = {}) { const projectChannel = new SubChannel(messagePort, projectPublicId) - /** @type {import('rpc-reflector').ClientApi} */ + /** @type {import('rpc-reflector').ClientApi} */ const projectClient = createClient(projectChannel, opts) projectChannel.start() diff --git a/src/server.js b/src/server.js index 3bdf0c3..11974b4 100644 --- a/src/server.js +++ b/src/server.js @@ -7,7 +7,7 @@ import { import { extractMessageEventData } from './lib/utils.js' /** - * @param {import('@mapeo/core').MapeoManager} manager + * @param {import('@comapeo/core').MapeoManager} manager * @param {import('./lib/sub-channel.js').MessagePortLike} messagePort */ export function createMapeoServer(manager, messagePort) { @@ -96,7 +96,7 @@ export class MapeoRpcApi { #manager /** - * @param {import('@mapeo/core').MapeoManager} manager + * @param {import('@comapeo/core').MapeoManager} manager */ constructor(manager) { this.#manager = manager diff --git a/tests/helpers.js b/tests/helpers.js index 50792d4..3fd164b 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -6,7 +6,7 @@ import { MapeoMapsFastifyPlugin, MapeoOfflineFallbackMapFastifyPlugin, MapeoStaticMapsFastifyPlugin, -} from '@mapeo/core' +} from '@comapeo/core' import { createRequire } from 'node:module' import path from 'node:path' import Fastify from 'fastify' @@ -19,15 +19,15 @@ import { createMapeoServer } from '../src/server.js' const require = createRequire(import.meta.url) -const MAPEO_CORE_PKG_FOLDER = path.dirname( - require.resolve('@mapeo/core/package.json'), +const COMAPEO_CORE_PKG_FOLDER = path.dirname( + require.resolve('@comapeo/core/package.json'), ) const projectMigrationsFolder = path.join( - MAPEO_CORE_PKG_FOLDER, + COMAPEO_CORE_PKG_FOLDER, 'drizzle/project', ) const clientMigrationsFolder = path.join( - MAPEO_CORE_PKG_FOLDER, + COMAPEO_CORE_PKG_FOLDER, 'drizzle/client', )