mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-03 13:52:06 +03:00
chore: release y-provider
package (#4642)
This commit is contained in:
parent
77efcad89d
commit
a0095496d7
@ -3,14 +3,11 @@ import type {
|
||||
LocalIndexedDBBackgroundProvider,
|
||||
SQLiteProvider,
|
||||
} from '@affine/env/workspace';
|
||||
import {
|
||||
syncDataSourceFromDoc,
|
||||
syncDocFromDataSource,
|
||||
} from '@affine/y-provider';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { Button } from '@toeverything/components/button';
|
||||
import { forceUpgradePages } from '@toeverything/infra/blocksuite';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { syncDataSourceFromDoc, syncDocFromDataSource } from 'y-provider';
|
||||
|
||||
import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
|
||||
|
||||
|
@ -4,11 +4,11 @@ import type {
|
||||
LocalIndexedDBBackgroundProvider,
|
||||
SQLiteProvider,
|
||||
} from '@affine/env/workspace';
|
||||
import { type Status, syncDataSource } from '@affine/y-provider';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { startTransition, useCallback, useMemo, useState } from 'react';
|
||||
import { type Status, syncDataSource } from 'y-provider';
|
||||
|
||||
export function useDatasourceSync(workspace: Workspace) {
|
||||
const [status, setStatus] = useState<Status>({
|
||||
|
2
packages/env/src/workspace.ts
vendored
2
packages/env/src/workspace.ts
vendored
@ -1,4 +1,3 @@
|
||||
import type { DataSourceAdapter } from '@affine/y-provider';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
import type {
|
||||
@ -7,6 +6,7 @@ import type {
|
||||
Workspace as BlockSuiteWorkspace,
|
||||
} from '@blocksuite/store';
|
||||
import type { PropsWithChildren, ReactNode } from 'react';
|
||||
import type { DataSourceAdapter } from 'y-provider';
|
||||
|
||||
import type { Collection } from './filter.js';
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine/env": "workspace:*",
|
||||
"@affine/y-provider": "workspace:*",
|
||||
"@blocksuite/block-std": "0.0.0-20230926212737-6d4b1569-nightly",
|
||||
"@blocksuite/blocks": "0.0.0-20230926212737-6d4b1569-nightly",
|
||||
"@blocksuite/editor": "0.0.0-20230926212737-6d4b1569-nightly",
|
||||
@ -24,24 +23,22 @@
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"@types/lodash.debounce": "^4.0.7",
|
||||
"fake-indexeddb": "^5.0.0",
|
||||
"vitest": "0.34.6"
|
||||
"vitest": "0.34.6",
|
||||
"y-provider": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@affine/y-provider": "workspace:*",
|
||||
"@blocksuite/block-std": "*",
|
||||
"@blocksuite/blocks": "*",
|
||||
"@blocksuite/editor": "*",
|
||||
"@blocksuite/global": "*",
|
||||
"@blocksuite/lit": "*",
|
||||
"@blocksuite/store": "*"
|
||||
"@blocksuite/store": "*",
|
||||
"y-provider": "workspace:*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@affine/env": {
|
||||
"optional": true
|
||||
},
|
||||
"@affine/y-provider": {
|
||||
"optional": true
|
||||
},
|
||||
"@blocksuite/block-std": {
|
||||
"optional": true
|
||||
},
|
||||
@ -59,6 +56,9 @@
|
||||
},
|
||||
"@blocksuite/store": {
|
||||
"optional": true
|
||||
},
|
||||
"y-provider": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"version": "0.10.0-canary.1"
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { DataSourceAdapter, Status } from '@affine/y-provider';
|
||||
import { useCallback, useSyncExternalStore } from 'react';
|
||||
import type { DataSourceAdapter, Status } from 'y-provider';
|
||||
|
||||
type UIStatus =
|
||||
| Status
|
||||
|
@ -20,7 +20,6 @@
|
||||
"@affine/debug": "workspace:*",
|
||||
"@affine/env": "workspace:*",
|
||||
"@affine/graphql": "workspace:*",
|
||||
"@affine/y-provider": "workspace:*",
|
||||
"@toeverything/hooks": "workspace:*",
|
||||
"@toeverything/y-indexeddb": "workspace:*",
|
||||
"async-call-rpc": "^6.3.1",
|
||||
@ -36,6 +35,7 @@
|
||||
"swr": "2.2.0",
|
||||
"valtio": "^1.11.2",
|
||||
"y-protocols": "^1.0.6",
|
||||
"y-provider": "workspace:*",
|
||||
"yjs": "^13.6.8",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
|
@ -10,7 +10,6 @@ import {
|
||||
getWorkspacesQuery,
|
||||
} from '@affine/graphql';
|
||||
import { createAffineDataSource } from '@affine/workspace/affine/index';
|
||||
import { syncDataSourceFromDoc } from '@affine/y-provider';
|
||||
import { createIndexeddbStorage, Workspace } from '@blocksuite/store';
|
||||
import { migrateLocalBlobStorage } from '@toeverything/infra/blocksuite';
|
||||
import {
|
||||
@ -19,6 +18,7 @@ import {
|
||||
} from '@toeverything/y-indexeddb';
|
||||
import { getSession } from 'next-auth/react';
|
||||
import { proxy } from 'valtio/vanilla';
|
||||
import { syncDataSourceFromDoc } from 'y-provider';
|
||||
|
||||
import { getOrCreateWorkspace } from '../manager';
|
||||
import { fetcher } from './gql';
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import type { DocDataSource } from '@affine/y-provider';
|
||||
import type { Socket } from 'socket.io-client';
|
||||
import { Manager } from 'socket.io-client';
|
||||
import {
|
||||
@ -7,6 +6,7 @@ import {
|
||||
type Awareness,
|
||||
encodeAwarenessUpdate,
|
||||
} from 'y-protocols/awareness';
|
||||
import type { DocDataSource } from 'y-provider';
|
||||
import type { Doc } from 'yjs';
|
||||
|
||||
import {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { syncDataSource } from '@affine/y-provider';
|
||||
import { createIndexeddbStorage } from '@blocksuite/store';
|
||||
import {
|
||||
createIndexedDBDatasource,
|
||||
DEFAULT_DB_NAME,
|
||||
downloadBinary,
|
||||
} from '@toeverything/y-indexeddb';
|
||||
import { syncDataSource } from 'y-provider';
|
||||
import type { Doc } from 'yjs';
|
||||
import { applyUpdate } from 'yjs';
|
||||
|
||||
|
@ -2,7 +2,6 @@ import type {
|
||||
SQLiteDBDownloadProvider,
|
||||
SQLiteProvider,
|
||||
} from '@affine/env/workspace';
|
||||
import { getDoc } from '@affine/y-provider';
|
||||
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
|
||||
import type { Y as YType } from '@blocksuite/store';
|
||||
import { Schema, Workspace } from '@blocksuite/store';
|
||||
@ -14,6 +13,7 @@ import type {
|
||||
import { nanoid } from 'nanoid';
|
||||
import { setTimeout } from 'timers/promises';
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { getDoc } from 'y-provider';
|
||||
|
||||
import {
|
||||
createSQLiteDBDownloadProvider,
|
||||
|
@ -4,7 +4,6 @@ import type {
|
||||
LocalIndexedDBBackgroundProvider,
|
||||
LocalIndexedDBDownloadProvider,
|
||||
} from '@affine/env/workspace';
|
||||
import { createLazyProvider } from '@affine/y-provider';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { DocProviderCreator } from '@blocksuite/store';
|
||||
import { Workspace } from '@blocksuite/store';
|
||||
@ -13,6 +12,7 @@ import {
|
||||
createIndexedDBDatasource,
|
||||
createIndexedDBProvider as create,
|
||||
} from '@toeverything/y-indexeddb';
|
||||
import { createLazyProvider } from 'y-provider';
|
||||
import { encodeStateVector } from 'yjs';
|
||||
|
||||
import { createAffineDataSource } from '../affine';
|
||||
|
@ -2,10 +2,10 @@ import type {
|
||||
SQLiteDBDownloadProvider,
|
||||
SQLiteProvider,
|
||||
} from '@affine/env/workspace';
|
||||
import { createLazyProvider, type DocDataSource } from '@affine/y-provider';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { DocProviderCreator } from '@blocksuite/store';
|
||||
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
||||
import { createLazyProvider, type DocDataSource } from 'y-provider';
|
||||
import type { Doc } from 'yjs';
|
||||
|
||||
import { localProviderLogger as logger } from './logger';
|
||||
|
@ -33,10 +33,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"idb": "^7.1.1",
|
||||
"nanoid": "^5.0.1"
|
||||
"nanoid": "^5.0.1",
|
||||
"y-provider": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine/y-provider": "workspace:*",
|
||||
"@blocksuite/blocks": "0.0.0-20230926212737-6d4b1569-nightly",
|
||||
"@blocksuite/store": "0.0.0-20230926212737-6d4b1569-nightly",
|
||||
"fake-indexeddb": "^5.0.0",
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { IDBPDatabase } from 'idb';
|
||||
import { openDB } from 'idb';
|
||||
import {
|
||||
createLazyProvider,
|
||||
type DocDataSource,
|
||||
writeOperation,
|
||||
} from '@affine/y-provider';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { IDBPDatabase } from 'idb';
|
||||
import { openDB } from 'idb';
|
||||
} from 'y-provider';
|
||||
import type { Doc } from 'yjs';
|
||||
import { diffUpdate, encodeStateVectorFromUpdate } from 'yjs';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { DataSourceAdapter } from '@affine/y-provider';
|
||||
import type { DBSchema, IDBPDatabase } from 'idb';
|
||||
import type { DataSourceAdapter } from 'y-provider';
|
||||
|
||||
export const dbVersion = 1;
|
||||
export const DEFAULT_DB_NAME = 'affine-local';
|
||||
|
@ -21,9 +21,10 @@ export default defineConfig({
|
||||
globals: {
|
||||
idb: 'idb',
|
||||
yjs: 'yjs',
|
||||
'y-provider': 'yProvider',
|
||||
},
|
||||
},
|
||||
external: ['idb', 'yjs'],
|
||||
external: ['idb', 'yjs', 'y-provider'],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
|
@ -1,17 +1,35 @@
|
||||
{
|
||||
"name": "@affine/y-provider",
|
||||
"name": "y-provider",
|
||||
"type": "module",
|
||||
"version": "0.10.0-canary.1",
|
||||
"description": "Yjs provider utilities for AFFiNE",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"version": "0.10.0-canary.0",
|
||||
"description": "Yjs provider protocol for multi document support",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs",
|
||||
"default": "./dist/index.umd.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blocksuite/store": "0.0.0-20230926212737-6d4b1569-nightly"
|
||||
"@blocksuite/store": "0.0.0-20230926212737-6d4b1569-nightly",
|
||||
"vite": "^4.4.11",
|
||||
"vite-plugin-dts": "3.6.0",
|
||||
"vitest": "0.34.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"yjs": "^13.5.51"
|
||||
"yjs": "^13"
|
||||
}
|
||||
}
|
||||
|
27
packages/y-provider/vite.config.ts
Normal file
27
packages/y-provider/vite.config.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { fileURLToPath } from 'url';
|
||||
import { defineConfig } from 'vite';
|
||||
import dts from 'vite-plugin-dts';
|
||||
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
minify: 'esbuild',
|
||||
sourcemap: true,
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/index.ts'),
|
||||
fileName: 'index',
|
||||
name: 'ToEverythingIndexedDBProvider',
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['idb', 'yjs'],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
dts({
|
||||
entryRoot: resolve(__dirname, 'src'),
|
||||
}),
|
||||
],
|
||||
});
|
@ -2,6 +2,7 @@
|
||||
|
||||
packages=(
|
||||
"y-indexeddb"
|
||||
"y-provider"
|
||||
"infra"
|
||||
"sdk"
|
||||
)
|
||||
|
35
yarn.lock
35
yarn.lock
@ -839,7 +839,6 @@ __metadata:
|
||||
"@affine/debug": "workspace:*"
|
||||
"@affine/env": "workspace:*"
|
||||
"@affine/graphql": "workspace:*"
|
||||
"@affine/y-provider": "workspace:*"
|
||||
"@testing-library/react": ^14.0.0
|
||||
"@toeverything/hooks": "workspace:*"
|
||||
"@toeverything/y-indexeddb": "workspace:*"
|
||||
@ -860,6 +859,7 @@ __metadata:
|
||||
vitest: 0.34.6
|
||||
ws: ^8.14.2
|
||||
y-protocols: ^1.0.6
|
||||
y-provider: "workspace:*"
|
||||
yjs: ^13.6.8
|
||||
zod: ^3.22.4
|
||||
peerDependencies:
|
||||
@ -868,16 +868,6 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@affine/y-provider@workspace:*, @affine/y-provider@workspace:packages/y-provider":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@affine/y-provider@workspace:packages/y-provider"
|
||||
dependencies:
|
||||
"@blocksuite/store": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
peerDependencies:
|
||||
yjs: ^13.5.51
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@agoric/babel-generator@npm:^7.17.6":
|
||||
version: 7.17.6
|
||||
resolution: "@agoric/babel-generator@npm:7.17.6"
|
||||
@ -12370,7 +12360,6 @@ __metadata:
|
||||
resolution: "@toeverything/hooks@workspace:packages/hooks"
|
||||
dependencies:
|
||||
"@affine/env": "workspace:*"
|
||||
"@affine/y-provider": "workspace:*"
|
||||
"@blocksuite/block-std": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
"@blocksuite/blocks": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
"@blocksuite/editor": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
@ -12386,19 +12375,18 @@ __metadata:
|
||||
react: 18.2.0
|
||||
swr: 2.2.0
|
||||
vitest: 0.34.6
|
||||
y-provider: "workspace:*"
|
||||
peerDependencies:
|
||||
"@affine/y-provider": "workspace:*"
|
||||
"@blocksuite/block-std": "*"
|
||||
"@blocksuite/blocks": "*"
|
||||
"@blocksuite/editor": "*"
|
||||
"@blocksuite/global": "*"
|
||||
"@blocksuite/lit": "*"
|
||||
"@blocksuite/store": "*"
|
||||
y-provider: "workspace:*"
|
||||
peerDependenciesMeta:
|
||||
"@affine/env":
|
||||
optional: true
|
||||
"@affine/y-provider":
|
||||
optional: true
|
||||
"@blocksuite/block-std":
|
||||
optional: true
|
||||
"@blocksuite/blocks":
|
||||
@ -12411,6 +12399,8 @@ __metadata:
|
||||
optional: true
|
||||
"@blocksuite/store":
|
||||
optional: true
|
||||
y-provider:
|
||||
optional: true
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@ -12475,7 +12465,6 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@toeverything/y-indexeddb@workspace:packages/y-indexeddb"
|
||||
dependencies:
|
||||
"@affine/y-provider": "workspace:*"
|
||||
"@blocksuite/blocks": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
"@blocksuite/store": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
fake-indexeddb: ^5.0.0
|
||||
@ -12485,6 +12474,7 @@ __metadata:
|
||||
vite-plugin-dts: 3.6.0
|
||||
vitest: 0.34.6
|
||||
y-indexeddb: ^9.0.11
|
||||
y-provider: "workspace:*"
|
||||
peerDependencies:
|
||||
yjs: ^13
|
||||
languageName: unknown
|
||||
@ -34487,6 +34477,19 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"y-provider@workspace:*, y-provider@workspace:packages/y-provider":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "y-provider@workspace:packages/y-provider"
|
||||
dependencies:
|
||||
"@blocksuite/store": 0.0.0-20230926212737-6d4b1569-nightly
|
||||
vite: ^4.4.11
|
||||
vite-plugin-dts: 3.6.0
|
||||
vitest: 0.34.6
|
||||
peerDependencies:
|
||||
yjs: ^13
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"y18n@npm:^4.0.0":
|
||||
version: 4.0.3
|
||||
resolution: "y18n@npm:4.0.3"
|
||||
|
Loading…
Reference in New Issue
Block a user