refactor: remove unused packages (#4532)

This commit is contained in:
Alex Yang
2023-09-27 20:33:42 -05:00
committed by GitHub
parent a860cf8e43
commit 56f75160f3
34 changed files with 16 additions and 1306 deletions

View File

@@ -1,35 +0,0 @@
{
"name": "@affine/docs",
"version": "0.9.0-canary.13",
"type": "module",
"private": true,
"scripts": {
"dev": "waku dev",
"build": "waku build",
"build:vercel": "waku build && cp -Lr ./dist/.vercel/output ./.vercel/"
},
"dependencies": {
"@affine/component": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/blocks": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/editor": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/global": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/lit": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/store": "0.0.0-20230921103931-38d8f07a-nightly",
"express": "^4.18.2",
"jotai": "^2.4.1",
"react": "18.3.0-canary-7118f5dd7-20230705",
"react-dom": "18.3.0-canary-7118f5dd7-20230705",
"react-server-dom-webpack": "18.3.0-canary-7118f5dd7-20230705",
"waku": "0.14.0"
},
"devDependencies": {
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@vanilla-extract/css": "^1.13.0",
"@vanilla-extract/vite-plugin": "^3.9.0",
"autoprefixer": "^10.4.15",
"tailwindcss": "^3.3.3",
"typescript": "^5.2.2"
}
}

View File

@@ -1,6 +0,0 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

View File

@@ -1,44 +0,0 @@
/// <reference types="vite/client" />
'use server';
import { existsSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { ReactElement } from 'react';
import { lazy } from 'react';
import { Sidebar } from './components/sidebar/index.js';
import { saveFile } from './server-fns.js';
const Editor = lazy(() =>
import('./components/editor.js').then(({ Editor }) => ({ default: Editor }))
);
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const AppCreator = (pathname: string) =>
function App(): ReactElement {
let path = resolve(__dirname, 'pages', 'binary');
if (!existsSync(path)) {
path = resolve(__dirname, '..', '..', 'src', 'pages', 'binary');
}
const buffer = [...readFileSync(path)];
return (
<div className="flex flex-col-reverse sm:flex-row h-screen">
<nav className="w-full sm:w-64">
<Sidebar />
</nav>
<main className="flex-1 p-6 w-full sm:w-[calc(100%-16rem)] overflow-scroll">
<Editor
workspaceId={pathname}
pageId="1"
onSave={saveFile}
binary={buffer}
/>
</main>
</div>
);
};
export default AppCreator;

View File

@@ -1,11 +0,0 @@
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import { atom } from 'jotai/vanilla';
export const workspaceAtom = atom(async () => {
const { Workspace } = await import('@blocksuite/store');
return new Workspace({
id: 'test-workspace',
})
.register(AffineSchemas)
.register(__unstableSchemas);
});

View File

@@ -1,53 +0,0 @@
'use client';
import '@blocksuite/editor/themes/affine.css';
import { BlockSuiteEditor } from '@affine/component/block-suite-editor';
import type { Page } from '@blocksuite/store';
import { useAtomValue } from 'jotai/react';
import type { ReactElement } from 'react';
import { use } from 'react';
import { applyUpdate } from 'yjs';
import { workspaceAtom } from '../atom.js';
export type EditorProps = {
workspaceId: string;
pageId: string;
binary?: number[];
onSave: (binary: any) => Promise<void>;
};
export const Editor = (props: EditorProps): ReactElement => {
const workspace = useAtomValue(workspaceAtom);
let page = workspace.getPage('page0') as Page;
if (!page) {
page = workspace.createPage({
id: 'page0',
});
}
if (props.binary && !page.root) {
use(
page.waitForLoaded().then(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
applyUpdate(page._ySpaceDoc, new Uint8Array(props.binary as number[]));
})
);
if (import.meta.env.MODE !== 'development') {
page.awarenessStore.setReadonly(page, true);
}
} else if (!page.root) {
use(
page.waitForLoaded().then(() => {
const pageBlockId = page.addBlock('affine:page', {
title: new page.Text(''),
});
page.addBlock('affine:surface', {}, pageBlockId);
const noteBlockId = page.addBlock('affine:note', {}, pageBlockId);
page.addBlock('affine:paragraph', {}, noteBlockId);
})
);
}
return <BlockSuiteEditor page={page} mode="page" onInit={() => {}} />;
};

View File

@@ -1,31 +0,0 @@
'use server';
import { lazy } from 'react';
import { saveFile } from '../../server-fns.js';
const SaveToLocal = lazy(() =>
import('./save-to-local.js').then(({ SaveToLocal }) => ({
default: SaveToLocal,
}))
);
export const Sidebar = () => {
return (
<div
className="h-screen text-black overflow-y-auto"
style={{
backgroundColor: '#f9f7f7',
}}
>
<a href="/">
<div className="flex items-center justify-center h-16 font-bold">
AFFiNE
</div>
</a>
{import.meta.env.MODE === 'development' && (
<SaveToLocal saveFile={saveFile} />
)}
</div>
);
};

View File

@@ -1,28 +0,0 @@
'use client';
import { assertExists } from '@blocksuite/global/utils';
import { useAtomValue } from 'jotai/react';
import { useCallback } from 'react';
import { encodeStateAsUpdate } from 'yjs';
import { workspaceAtom } from '../../atom.js';
type SaveToLocalProps = {
saveFile: (update: number[]) => void;
};
export const SaveToLocal = (props: SaveToLocalProps) => {
const workspace = useAtomValue(workspaceAtom);
const saveFile = props.saveFile;
const onSave = useCallback(() => {
const page = workspace.getPage('page0');
assertExists(page);
saveFile([...encodeStateAsUpdate(page.spaceDoc)]);
}, [saveFile, workspace]);
return (
<div>
<div className="flex items-center justify-center h-16 font-bold">
<button onClick={onSave}>Save to Local</button>
</div>
</div>
);
};

View File

@@ -1,17 +0,0 @@
import { defineRouter } from 'waku/router/server';
export default defineRouter(
async id => {
switch (id) {
case 'index': {
const { default: AppCreator } = await import('./app.js');
return AppCreator(id);
}
default:
return null;
}
},
async () => {
return ['index'];
}
);

View File

@@ -1,3 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@@ -1,36 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>AFFiNE Developer Documentation</title>
<style>
@keyframes spinner {
to {
transform: rotate(360deg);
}
}
.spinner {
width: 36px;
height: 36px;
margin: auto;
border: 2px solid #ddd;
border-top-color: #222;
border-radius: 50%;
animation: spinner 1s linear infinite;
}
#root > .spinner {
margin-top: calc(50% - 18px);
}
</style>
</head>
<body>
<!--placeholder1-->
<div id="root">
<div class="spinner"></div>
</div>
<!--/placeholder1-->
<script src="./index.tsx" defer type="module"></script>
<!--placeholder2-->
<!--/placeholder2-->
</body>
</html>

View File

@@ -1,14 +0,0 @@
import '@blocksuite/editor/themes/affine.css';
import './index.css';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { Router } from 'waku/router/client';
const root = createRoot(document.getElementById('root') as HTMLElement);
root.render(
<StrictMode>
<Router />
</StrictMode>
);

Binary file not shown.

View File

@@ -1,10 +0,0 @@
'use server';
import { writeFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
export async function saveFile(binary: any) {
const data = new Uint8Array(binary);
await writeFile(__dirname + 'pages' + '/binary', data);
}

View File

@@ -1,8 +0,0 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ['./index.html', './src/**/*.{ts,tsx}'],
theme: {
extend: {},
},
plugins: [],
};

View File

@@ -1,25 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"moduleResolution": "bundler",
"strict": true,
"target": "esnext",
"downlevelIteration": true,
"esModuleInterop": true,
"module": "NodeNext",
"skipLibCheck": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"jsx": "react-jsx",
"jsxImportSource": "react"
},
"include": ["src", "entries.ts"],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "../../packages/component"
}
]
}

View File

@@ -1,14 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"resolveJsonModule": true,
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"outDir": "dist/scripts",
"rootDir": "."
},
"include": ["vite.config.ts", "vite.prod.config.ts"]
}

View File

@@ -1,13 +0,0 @@
import path from 'node:path';
import url from 'node:url';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import { defineConfig } from 'waku/config';
export default defineConfig({
root: path.dirname(url.fileURLToPath(import.meta.url)),
plugins: [vanillaExtractPlugin()],
build: {
target: 'esnext',
},
});

View File

@@ -1,5 +0,0 @@
# AFFiNE Prototype
> This is a prototype of the AFFiNE system to test the feasibility of the approach.
>
> It is not intended for production use.

View File

@@ -1,15 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AFFiNE Prototype</title>
</head>
<body>
<ul>
<li>
<a href="suite/provider-status.html">Provider status test</a>
</li>
</ul>
</body>
</html>

View File

@@ -1,39 +0,0 @@
{
"name": "@affine/prototype",
"private": true,
"version": "0.9.0-canary.13",
"type": "module",
"scripts": {
"dev": "vite --host --port 3003",
"build": "tsc -b && vite build",
"preview": "vite preview --host --port 3003"
},
"dependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine/component": "workspace:*",
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@affine/graphql": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/blocks": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/editor": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/global": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/icons": "^2.1.33",
"@blocksuite/lit": "0.0.0-20230921103931-38d8f07a-nightly",
"@blocksuite/store": "0.0.0-20230921103931-38d8f07a-nightly",
"@toeverything/hooks": "workspace:*",
"@toeverything/y-indexeddb": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react-swc": "^3.3.2",
"typescript": "^5.2.2",
"vite": "^4.4.9"
}
}

View File

@@ -1,58 +0,0 @@
{
"name": "prototype",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/prototype/src",
"targets": {
"build": {
"executor": "nx:run-script",
"dependsOn": [
{
"projects": ["tag:plugin"],
"target": "build",
"params": "ignore"
},
{
"projects": ["tag:infra"],
"target": "build",
"params": "ignore"
},
"^build"
],
"options": {
"script": "build"
},
"inputs": [
"{projectRoot}/.webpack/**/*",
"{projectRoot}/**/*",
"{workspaceRoot}/apps/core/public/**/*",
"{workspaceRoot}/packages/**/*",
{
"env": "BUILD_TYPE"
},
{
"env": "PERFSEE_TOKEN"
},
{
"env": "SENTRY_ORG"
},
{
"env": "SENTRY_PROJECT"
},
{
"env": "SENTRY_AUTH_TOKEN"
},
{
"env": "NEXT_PUBLIC_SENTRY_DSN"
},
{
"env": "DISTRIBUTION"
},
{
"env": "COVERAGE"
}
],
"outputs": ["{projectRoot}/dist"]
}
}
}

View File

@@ -1,57 +0,0 @@
import type { LocalIndexedDBBackgroundProvider } from '@affine/env/workspace';
import { createIndexedDBBackgroundProvider } from '@affine/workspace/providers';
import { assertExists } from '@blocksuite/global/utils';
import { useDataSourceStatus } from '@toeverything/hooks/use-data-source-status';
import React, { useCallback, useRef } from 'react';
import ReactDOM from 'react-dom/client';
import { Awareness } from 'y-protocols/awareness';
import { Doc } from 'yjs';
const doc = new Doc();
const map = doc.getMap();
const awareness = new Awareness(doc);
const indexeddbProvider = createIndexedDBBackgroundProvider('test', doc, {
awareness,
}) as LocalIndexedDBBackgroundProvider;
indexeddbProvider.connect();
const App = () => {
const counterRef = useRef(0);
const disposeRef = useRef<number>(0);
const status = useDataSourceStatus(indexeddbProvider);
return (
<div>
<button
data-testid="start-button"
onClick={useCallback(() => {
disposeRef.current = window.setInterval(() => {
const counter = counterRef.current;
map.set('counter', counter + 1);
counterRef.current = counter + 1;
}, 0);
}, [])}
>
start writing
</button>
<button
data-testid="stop-button"
onClick={useCallback(() => {
clearInterval(disposeRef.current);
}, [])}
>
stop writing
</button>
<div data-testid="status">{status.type}</div>
</div>
);
};
const root = document.getElementById('root');
assertExists(root);
ReactDOM.createRoot(root).render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@@ -1 +0,0 @@
/// <reference types="vite/client" />

View File

@@ -1,12 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Provider status test</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="../src/provider-status.tsx"></script>
</body>
</html>

View File

@@ -1,37 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"moduleResolution": "bundler",
"outDir": "./lib"
},
"include": ["./src"],
"references": [
{
"path": "../../packages/component"
},
{
"path": "../../packages/debug"
},
{
"path": "../../packages/env"
},
{
"path": "../../packages/graphql"
},
{
"path": "../../packages/hooks"
},
{
"path": "../../packages/i18n"
},
{
"path": "../../packages/y-indexeddb"
},
{
"path": "../../packages/workspace"
},
{
"path": "./tsconfig.node.json"
}
]
}

View File

@@ -1,16 +0,0 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "./lib",
"allowSyntheticDefaultImports": true
},
"references": [
{
"path": "../../apps/core"
}
],
"include": ["vite.config.ts"]
}

View File

@@ -1,38 +0,0 @@
import { resolve } from 'node:path';
import react from '@vitejs/plugin-react-swc';
import { defineConfig } from 'vite';
import { getRuntimeConfig } from '../core/.webpack/runtime-config';
// https://vitejs.dev/config/
export default defineConfig({
build: {
target: 'ES2022',
sourcemap: true,
rollupOptions: {
input: {
'suite/provider-status': resolve(
__dirname,
'suite',
'provider-status.html'
),
},
},
},
define: {
'process.env': {},
'process.env.COVERAGE': JSON.stringify(!!process.env.COVERAGE),
'process.env.SHOULD_REPORT_TRACE': `${Boolean(
process.env.SHOULD_REPORT_TRACE === 'true'
)}`,
'process.env.TRACE_REPORT_ENDPOINT': `"${process.env.TRACE_REPORT_ENDPOINT}"`,
runtimeConfig: getRuntimeConfig({
distribution: 'browser',
mode: 'development',
channel: 'canary',
coverage: false,
}),
},
plugins: [react()],
});