feat: add @affine/sdk (#3536)

This commit is contained in:
Alex Yang
2023-08-02 21:47:05 -07:00
committed by GitHub
parent d3c719d89a
commit ea34d66e14
39 changed files with 256 additions and 93 deletions
+15 -4
View File
@@ -1,5 +1,6 @@
import * as AFFiNEComponent from '@affine/component';
import { DebugLogger } from '@affine/debug';
import type { CallbackMap, PluginContext } from '@affine/sdk/entry';
import { FormatQuickBar } from '@blocksuite/blocks';
import * as BlockSuiteBlocksStd from '@blocksuite/blocks/std';
import * as BlockSuiteGlobalUtils from '@blocksuite/global/utils';
@@ -8,16 +9,15 @@ import { DisposableGroup } from '@blocksuite/global/utils';
import * as Icons from '@blocksuite/icons';
import * as Atom from '@toeverything/plugin-infra/atom';
import {
contentLayoutAtom,
currentPageAtom,
currentWorkspaceAtom,
editorItemsAtom,
headerItemsAtom,
rootStore,
settingItemsAtom,
windowItemsAtom,
} from '@toeverything/plugin-infra/atom';
import type {
CallbackMap,
PluginContext,
} from '@toeverything/plugin-infra/entry';
import * as Jotai from 'jotai/index';
import { Provider } from 'jotai/react';
import * as JotaiUtils from 'jotai/utils';
@@ -66,6 +66,17 @@ const setupRootImportsMap = () => {
'@toeverything/plugin-infra/atom',
new Map(Object.entries(Atom))
);
_rootImportsMap.set(
'@affine/sdk/entry',
new Map(
Object.entries({
rootStore: rootStore,
currentWorkspaceAtom: currentWorkspaceAtom,
currentPageAtom: currentPageAtom,
contentLayoutAtom: contentLayoutAtom,
})
)
);
_rootImportsMap.set('swr', new Map(Object.entries(SWR)));
};
@@ -1,6 +1,7 @@
import './page-detail-editor.css';
import { PageNotFoundError } from '@affine/env/constant';
import type { CallbackMap, LayoutNode } from '@affine/sdk//entry';
import { rootBlockHubAtom } from '@affine/workspace/atom';
import type { EditorContainer } from '@blocksuite/editor';
import { assertExists } from '@blocksuite/global/utils';
@@ -13,8 +14,6 @@ import {
rootStore,
windowItemsAtom,
} from '@toeverything/plugin-infra/atom';
import type { CallbackMap } from '@toeverything/plugin-infra/entry';
import type { LayoutNode } from '@toeverything/plugin-infra/type';
import clsx from 'clsx';
import { useAtomValue, useSetAtom } from 'jotai';
import type { CSSProperties, FC, ReactElement } from 'react';
+14
View File
@@ -137,6 +137,20 @@ module.exports = {
force: true,
}
);
await rm(resolve(__dirname, './node_modules/@affine/sdk'), {
recursive: true,
force: true,
});
await cp(
resolve(__dirname, '../../packages/sdk'),
resolve(__dirname, './node_modules/@affine/sdk'),
{
recursive: true,
force: true,
}
);
},
generateAssets: async (_, platform, arch) => {
if (process.env.SKIP_GENERATE_ASSETS) {
+1
View File
@@ -27,6 +27,7 @@
"@affine/env": "workspace:*",
"@affine/maker-dmg": "workspace:*",
"@affine/native": "workspace:*",
"@affine/sdk": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/editor": "0.0.0-20230802200139-381599c0-nightly",
"@blocksuite/lit": "0.0.0-20230802200139-381599c0-nightly",
+1 -1
View File
@@ -1,7 +1,7 @@
import { join, resolve } from 'node:path';
import { parentPort } from 'node:worker_threads';
import type { ServerContext } from '@toeverything/plugin-infra/server';
import type { ServerContext } from '@affine/sdk/server';
import { AsyncCall } from 'async-call-rpc';
import { MessageEventChannel } from '../shared/utils';
+3
View File
@@ -25,6 +25,9 @@
{
"path": "../../packages/infra"
},
{
"path": "../../packages/sdk"
},
{
"path": "../../packages/env"
},