forked from toeverything/AFFiNE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
@affine/sdk
(toeverything#3536)
- Loading branch information
Showing
39 changed files
with
256 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,8 @@ | |
"storage", | ||
"infra", | ||
"plugin-infra", | ||
"plugin-cli" | ||
"plugin-cli", | ||
"sdk" | ||
] | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ lib | |
.eslintrc.js | ||
packages/i18n/src/i18n-generated.ts | ||
e2e-dist-* | ||
static | ||
web-static | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@affine/sdk", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite build --watch" | ||
}, | ||
"exports": { | ||
"./entry": { | ||
"types": "./dist/src/entry.d.ts", | ||
"import": "./dist/entry.js", | ||
"require": "./dist/entry.cjs" | ||
}, | ||
"./server": { | ||
"types": "./dist/src/server.d.ts", | ||
"import": "./dist/server.js", | ||
"require": "./dist/server.cjs" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": { | ||
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly", | ||
"@blocksuite/global": "0.0.0-20230802200139-381599c0-nightly", | ||
"@blocksuite/store": "0.0.0-20230802200139-381599c0-nightly", | ||
"jotai": "^2.2.2", | ||
"zod": "^3.21.4" | ||
}, | ||
"devDependencies": { | ||
"vite": "^4.4.7", | ||
"vite-plugin-dts": "3.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "sdk", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "library", | ||
"sourceRoot": "packages/sdk/src", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/vite:build", | ||
"options": { | ||
"outputPath": "packages/sdk/dist" | ||
} | ||
}, | ||
"serve": { | ||
"executor": "@nx/vite:build", | ||
"options": { | ||
"outputPath": "packages/sdk/dist", | ||
"watch": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type { getCurrentBlockRange } from '@blocksuite/blocks'; | ||
import type { EditorContainer } from '@blocksuite/editor'; | ||
import type { Page } from '@blocksuite/store'; | ||
import type { Workspace } from '@blocksuite/store'; | ||
import type { Atom, getDefaultStore, PrimitiveAtom } from 'jotai/vanilla'; | ||
import type { FC } from 'react'; | ||
|
||
export type Part = 'headerItem' | 'editor' | 'window' | 'setting' | 'formatBar'; | ||
|
||
export type CallbackMap = { | ||
headerItem: (root: HTMLElement) => () => void; | ||
window: (root: HTMLElement) => () => void; | ||
editor: (root: HTMLElement, editor: EditorContainer) => () => void; | ||
setting: (root: HTMLElement) => () => void; | ||
formatBar: ( | ||
root: HTMLElement, | ||
page: Page, | ||
getBlockRange: () => ReturnType<typeof getCurrentBlockRange> | ||
) => () => void; | ||
}; | ||
|
||
export interface PluginContext { | ||
register: <T extends Part>(part: T, callback: CallbackMap[T]) => void; | ||
utils: { | ||
PluginProvider: FC; | ||
}; | ||
} | ||
|
||
export type LayoutDirection = 'horizontal' | 'vertical'; | ||
export type LayoutNode = LayoutParentNode | string; | ||
export type LayoutParentNode = { | ||
direction: LayoutDirection; | ||
splitPercentage: number; // 0 - 100 | ||
first: LayoutNode; | ||
second: LayoutNode; | ||
}; | ||
|
||
export type ExpectedLayout = | ||
| { | ||
direction: LayoutDirection; | ||
// the first element is always the editor | ||
first: 'editor'; | ||
second: LayoutNode; | ||
// the percentage should be greater than 70 | ||
splitPercentage: number; | ||
} | ||
| 'editor'; | ||
|
||
export declare const contentLayoutAtom: PrimitiveAtom<ExpectedLayout>; | ||
export declare const currentPageAtom: Atom<Promise<Page>>; | ||
export declare const currentWorkspaceAtom: Atom<Promise<Workspace>>; | ||
export declare const rootStore: ReturnType<typeof getDefaultStore>; |
File renamed without changes.
Oops, something went wrong.