mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
build: perform TypeCheck for all packages (#2573)
Co-authored-by: himself65 <himself65@outlook.com> Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
@@ -32,9 +32,9 @@ export const globalTypes = {
|
||||
},
|
||||
};
|
||||
|
||||
const createI18nDecorator = ({ options } = { options: {} }) => {
|
||||
const i18n = createI18n(options);
|
||||
const withI18n = (Story, context) => {
|
||||
const createI18nDecorator = () => {
|
||||
const i18n = createI18n();
|
||||
const withI18n = (Story: any, context: any) => {
|
||||
const locale = context.globals.locale;
|
||||
useEffect(() => {
|
||||
i18n.changeLanguage(locale);
|
||||
|
||||
@@ -6,7 +6,7 @@ import React from 'react';
|
||||
|
||||
import * as styles from './index.css';
|
||||
|
||||
interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
export interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
icon?: React.ReactElement;
|
||||
active?: boolean;
|
||||
disabled?: boolean;
|
||||
@@ -14,7 +14,9 @@ interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
onCollapsedChange?: (collapsed: boolean) => void;
|
||||
}
|
||||
|
||||
interface MenuLinkItemProps extends MenuItemProps, Pick<LinkProps, 'href'> {}
|
||||
export interface MenuLinkItemProps
|
||||
extends MenuItemProps,
|
||||
Pick<LinkProps, 'href'> {}
|
||||
|
||||
export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(
|
||||
(
|
||||
|
||||
@@ -30,7 +30,7 @@ const mockVariableMap = (vars: Partial<VariableMap>): VariableMap => {
|
||||
return {
|
||||
Created: 0,
|
||||
Updated: 0,
|
||||
Favorite: false,
|
||||
'Is Favourited': false,
|
||||
...vars,
|
||||
};
|
||||
};
|
||||
@@ -103,10 +103,10 @@ describe('eval filter', () => {
|
||||
test('is', async () => {
|
||||
const is = filterMatcher.findData(v => v.name === 'is');
|
||||
assertExists(is);
|
||||
const filter1 = filter(is, ref('Favorite'), [false]);
|
||||
const filter2 = filter(is, ref('Favorite'), [true]);
|
||||
const filter1 = filter(is, ref('Is Favourited'), [false]);
|
||||
const filter2 = filter(is, ref('Is Favourited'), [true]);
|
||||
const varMap = mockVariableMap({
|
||||
Favorite: true,
|
||||
'Is Favourited': true,
|
||||
});
|
||||
expect(filterByFilterList([filter1], varMap)).toBe(false);
|
||||
expect(filterByFilterList([filter2], varMap)).toBe(true);
|
||||
@@ -118,7 +118,9 @@ describe('render filter', () => {
|
||||
const is = filterMatcher.match(tBoolean.create());
|
||||
assertExists(is);
|
||||
const Wrapper = () => {
|
||||
const [value, onChange] = useState(filter(is, ref('Favorite'), [true]));
|
||||
const [value, onChange] = useState(
|
||||
filter(is, ref('Is Favourited'), [true])
|
||||
);
|
||||
return <Condition value={value} onChange={onChange} />;
|
||||
};
|
||||
const result = render(<Wrapper />);
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import type { BreadcrumbsProps } from '@mui/material/Breadcrumbs';
|
||||
import MuiBreadcrumbs from '@mui/material/Breadcrumbs';
|
||||
import type { ComponentType } from 'react';
|
||||
|
||||
import { styled } from '../../styles';
|
||||
|
||||
export const Breadcrumbs = styled(MuiBreadcrumbs)(() => {
|
||||
const StyledMuiBreadcrumbs = styled(MuiBreadcrumbs)(() => {
|
||||
return {
|
||||
color: 'var(--affine-text-primary-color)',
|
||||
};
|
||||
});
|
||||
|
||||
export const Breadcrumbs: ComponentType<BreadcrumbsProps> =
|
||||
StyledMuiBreadcrumbs;
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src", "./.storybook/*.ts"],
|
||||
"include": [
|
||||
"./src/**/*.ts",
|
||||
"./src/**/*.tsx",
|
||||
"./src/**/*.json",
|
||||
"../workspace/src",
|
||||
"../../apps/electron/layers/**/src"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"exclude": ["lib"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../debug"
|
||||
},
|
||||
{
|
||||
"path": "../i18n"
|
||||
},
|
||||
{
|
||||
"path": "../jotai"
|
||||
},
|
||||
{
|
||||
"path": "../hooks"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
},
|
||||
{ "path": "../../tests/fixtures" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"jsx": "react-jsx",
|
||||
"moduleResolution": "Node",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib/.storybook"
|
||||
},
|
||||
"include": [".storybook/**/*"]
|
||||
"include": [".storybook/**/*"],
|
||||
"exclude": ["lib"],
|
||||
"references": [{ "path": "../i18n" }]
|
||||
}
|
||||
|
||||
1
packages/debug/.gitignore
vendored
Normal file
1
packages/debug/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -3,8 +3,16 @@
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../env"
|
||||
}
|
||||
],
|
||||
"include": ["./src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
1
packages/env/.gitignore
vendored
Normal file
1
packages/env/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -1,5 +1,8 @@
|
||||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
||||
/// <reference path="../env.d.ts" />
|
||||
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import markdown from '@affine/templates/AFFiNE-beta-0.5.4.md';
|
||||
import markdownTemplate from '@affine/templates/AFFiNE-beta-0.5.4.md';
|
||||
import { ContentParser } from '@blocksuite/blocks/content-parser';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
|
||||
@@ -9,6 +12,8 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
const markdown = markdownTemplate as unknown as string;
|
||||
|
||||
const demoTitle = markdown
|
||||
.split('\n')
|
||||
.splice(0, 1)
|
||||
1
packages/env/env.d.ts
vendored
1
packages/env/env.d.ts
vendored
@@ -1,3 +1,2 @@
|
||||
import '../../apps/electron/layers/preload/preload.d.ts';
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
import '../hooks/src/use-block-suite-page-meta.ts';
|
||||
|
||||
4
packages/env/package.json
vendored
4
packages/env/package.json
vendored
@@ -14,14 +14,12 @@
|
||||
".": "./src/index.ts",
|
||||
"./config": "./src/config.ts",
|
||||
"./constant": "./src/constant.ts",
|
||||
"./blocksuite": "./src/blocksuite.ts"
|
||||
"./blocksuite": "./blocksuite/index.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@blocksuite/global": "0.0.0-20230409084303-221991d4-nightly"
|
||||
},
|
||||
"dependencies": {
|
||||
"@affine/copilot": "workspace:*",
|
||||
"@toeverything/plugin-infra": "workspace:*",
|
||||
"lit": "^2.7.4"
|
||||
},
|
||||
"version": "0.5.4-beta.2"
|
||||
|
||||
11
packages/env/src/bootstrap.ts
vendored
11
packages/env/src/bootstrap.ts
vendored
@@ -1,11 +0,0 @@
|
||||
import { config, setupGlobal } from './config';
|
||||
|
||||
setupGlobal();
|
||||
|
||||
if (config.enablePlugin && !environment.isServer) {
|
||||
import('@affine/copilot');
|
||||
}
|
||||
|
||||
if (!environment.isServer) {
|
||||
import('@affine/bookmark-block');
|
||||
}
|
||||
8
packages/env/src/config.ts
vendored
8
packages/env/src/config.ts
vendored
@@ -1,9 +1,11 @@
|
||||
/// <reference types="@blocksuite/global" />
|
||||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
||||
/// <reference path="./global.d.ts" />
|
||||
import { assertEquals } from '@blocksuite/global/utils';
|
||||
import getConfig from 'next/config';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { getUaHelper } from './ua-helper';
|
||||
import { UaHelper } from './ua-helper';
|
||||
|
||||
export const buildFlagsSchema = z.object({
|
||||
/**
|
||||
@@ -111,7 +113,7 @@ export function getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
const isDebug = process.env.NODE_ENV === 'development';
|
||||
if (typeof window === 'undefined') {
|
||||
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
||||
environment = {
|
||||
isDesktop: false,
|
||||
isBrowser: false,
|
||||
@@ -119,7 +121,7 @@ export function getEnvironment() {
|
||||
isDebug,
|
||||
} satisfies Server;
|
||||
} else {
|
||||
const uaHelper = getUaHelper();
|
||||
const uaHelper = new UaHelper(navigator);
|
||||
|
||||
environment = {
|
||||
origin: window.location.origin,
|
||||
|
||||
38
packages/env/src/constant.ts
vendored
38
packages/env/src/constant.ts
vendored
@@ -6,24 +6,24 @@ export const UNTITLED_WORKSPACE_NAME = 'Untitled';
|
||||
export const DEFAULT_HELLO_WORLD_PAGE_ID = 'hello-world';
|
||||
|
||||
export const DEFAULT_SORT_KEY = 'updatedDate';
|
||||
export const enum MessageCode {
|
||||
loginError,
|
||||
noPermission,
|
||||
loadListFailed,
|
||||
getDetailFailed,
|
||||
createWorkspaceFailed,
|
||||
getMembersFailed,
|
||||
updateWorkspaceFailed,
|
||||
deleteWorkspaceFailed,
|
||||
inviteMemberFailed,
|
||||
removeMemberFailed,
|
||||
acceptInvitingFailed,
|
||||
getBlobFailed,
|
||||
leaveWorkspaceFailed,
|
||||
downloadWorkspaceFailed,
|
||||
refreshTokenError,
|
||||
blobTooLarge,
|
||||
}
|
||||
export const MessageCode = {
|
||||
loginError: 0,
|
||||
noPermission: 1,
|
||||
loadListFailed: 2,
|
||||
getDetailFailed: 3,
|
||||
createWorkspaceFailed: 4,
|
||||
getMembersFailed: 5,
|
||||
updateWorkspaceFailed: 6,
|
||||
deleteWorkspaceFailed: 7,
|
||||
inviteMemberFailed: 8,
|
||||
removeMemberFailed: 9,
|
||||
acceptInvitingFailed: 10,
|
||||
getBlobFailed: 11,
|
||||
leaveWorkspaceFailed: 12,
|
||||
downloadWorkspaceFailed: 13,
|
||||
refreshTokenError: 14,
|
||||
blobTooLarge: 15,
|
||||
} as const;
|
||||
|
||||
export const Messages = {
|
||||
[MessageCode.loginError]: {
|
||||
@@ -75,7 +75,7 @@ export const Messages = {
|
||||
message: 'Blob too large',
|
||||
},
|
||||
} as const satisfies {
|
||||
[key in MessageCode]: {
|
||||
[key in (typeof MessageCode)[keyof typeof MessageCode]]: {
|
||||
message: string;
|
||||
};
|
||||
};
|
||||
|
||||
5
packages/env/src/global.d.ts
vendored
Normal file
5
packages/env/src/global.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
interface Window {
|
||||
appInfo: {
|
||||
electron: bool;
|
||||
};
|
||||
}
|
||||
10
packages/env/src/types.d.ts
vendored
10
packages/env/src/types.d.ts
vendored
@@ -1,10 +0,0 @@
|
||||
/// <reference types="@webpack/env"" />
|
||||
|
||||
// not using import because it will break the declare module line below
|
||||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
||||
/// <reference path='../../../electron/layers/preload/preload.d.ts' />
|
||||
|
||||
declare module '*.md' {
|
||||
const text: string;
|
||||
export default text;
|
||||
}
|
||||
156
packages/env/src/ua-helper.ts
vendored
156
packages/env/src/ua-helper.ts
vendored
@@ -1,92 +1,78 @@
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
|
||||
export function getUaHelper() {
|
||||
let uaHelper = null;
|
||||
(function (navigator) {
|
||||
const getUa = () => {
|
||||
const ua = navigator.userAgent;
|
||||
const uas = ua.toLowerCase();
|
||||
const mobile = /iPhone|iPad|iPod|Android/i.test(ua);
|
||||
const android =
|
||||
(mobile &&
|
||||
(uas.indexOf('android') > -1 || uas.indexOf('linux') > -1)) ||
|
||||
uas.indexOf('adr') > -1;
|
||||
const ios = mobile && !android && /Mac OS/i.test(ua);
|
||||
const mac = !mobile && /Mac OS/i.test(ua);
|
||||
const iphone = ios && uas.indexOf('iphone') > -1;
|
||||
const ipad = ios && !iphone;
|
||||
const wx = /MicroMessenger/i.test(ua);
|
||||
const chrome = /CriOS/i.test(ua) || /Chrome/i.test(ua);
|
||||
const tiktok = mobile && /aweme/i.test(ua);
|
||||
const weibo = mobile && /Weibo/i.test(ua);
|
||||
const safari =
|
||||
ios &&
|
||||
!chrome &&
|
||||
!wx &&
|
||||
!weibo &&
|
||||
!tiktok &&
|
||||
/Safari|Macintosh/i.test(ua);
|
||||
const firefox = /Firefox/.test(ua);
|
||||
const win = /windows|win32|win64|wow32|wow64/.test(uas);
|
||||
const linux = /linux/.test(uas);
|
||||
return {
|
||||
ua,
|
||||
mobile,
|
||||
android,
|
||||
ios,
|
||||
mac,
|
||||
wx,
|
||||
chrome,
|
||||
iphone,
|
||||
ipad,
|
||||
safari,
|
||||
tiktok,
|
||||
weibo,
|
||||
win,
|
||||
linux,
|
||||
firefox,
|
||||
};
|
||||
};
|
||||
export class UaHelper {
|
||||
private uaMap;
|
||||
public isLinux = false;
|
||||
public isMacOs = false;
|
||||
public isSafari = false;
|
||||
public isWindows = false;
|
||||
public isFireFox = false;
|
||||
public isMobile = false;
|
||||
public isChrome = false;
|
||||
public isIOS = false;
|
||||
|
||||
class UaHelper {
|
||||
private uaMap;
|
||||
public isLinux = false;
|
||||
public isMacOs = false;
|
||||
public isSafari = false;
|
||||
public isWindows = false;
|
||||
public isFireFox = false;
|
||||
public isMobile = false;
|
||||
public isChrome = false;
|
||||
public isIOS = false;
|
||||
getChromeVersion = (): number => {
|
||||
const raw = this.navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
|
||||
assertExists(raw);
|
||||
return parseInt(raw[2], 10);
|
||||
};
|
||||
|
||||
getChromeVersion = (): number => {
|
||||
const raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
|
||||
assertExists(raw);
|
||||
return parseInt(raw[2], 10);
|
||||
};
|
||||
constructor(private readonly navigator: Navigator) {
|
||||
this.uaMap = getUa(navigator);
|
||||
this.initUaFlags();
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.uaMap = getUa();
|
||||
this.initUaFlags();
|
||||
}
|
||||
public checkUseragent(isUseragent: keyof ReturnType<typeof getUa>) {
|
||||
return Boolean(this.uaMap[isUseragent]);
|
||||
}
|
||||
|
||||
public checkUseragent(isUseragent: keyof ReturnType<typeof getUa>) {
|
||||
return Boolean(this.uaMap[isUseragent]);
|
||||
}
|
||||
|
||||
private initUaFlags() {
|
||||
this.isLinux = this.checkUseragent('linux');
|
||||
this.isMacOs = this.checkUseragent('mac');
|
||||
this.isSafari = this.checkUseragent('safari');
|
||||
this.isWindows = this.checkUseragent('win');
|
||||
this.isFireFox = this.checkUseragent('firefox');
|
||||
this.isMobile = this.checkUseragent('mobile');
|
||||
this.isChrome = this.checkUseragent('chrome');
|
||||
this.isIOS = this.checkUseragent('ios');
|
||||
}
|
||||
}
|
||||
uaHelper = new UaHelper();
|
||||
})(navigator);
|
||||
|
||||
return uaHelper;
|
||||
private initUaFlags() {
|
||||
this.isLinux = this.checkUseragent('linux');
|
||||
this.isMacOs = this.checkUseragent('mac');
|
||||
this.isSafari = this.checkUseragent('safari');
|
||||
this.isWindows = this.checkUseragent('win');
|
||||
this.isFireFox = this.checkUseragent('firefox');
|
||||
this.isMobile = this.checkUseragent('mobile');
|
||||
this.isChrome = this.checkUseragent('chrome');
|
||||
this.isIOS = this.checkUseragent('ios');
|
||||
}
|
||||
}
|
||||
|
||||
const getUa = (navigator: Navigator) => {
|
||||
const ua = navigator.userAgent;
|
||||
const uas = ua.toLowerCase();
|
||||
const mobile = /iPhone|iPad|iPod|Android/i.test(ua);
|
||||
const android =
|
||||
(mobile && (uas.indexOf('android') > -1 || uas.indexOf('linux') > -1)) ||
|
||||
uas.indexOf('adr') > -1;
|
||||
const ios = mobile && !android && /Mac OS/i.test(ua);
|
||||
const mac = !mobile && /Mac OS/i.test(ua);
|
||||
const iphone = ios && uas.indexOf('iphone') > -1;
|
||||
const ipad = ios && !iphone;
|
||||
const wx = /MicroMessenger/i.test(ua);
|
||||
const chrome = /CriOS/i.test(ua) || /Chrome/i.test(ua);
|
||||
const tiktok = mobile && /aweme/i.test(ua);
|
||||
const weibo = mobile && /Weibo/i.test(ua);
|
||||
const safari =
|
||||
ios && !chrome && !wx && !weibo && !tiktok && /Safari|Macintosh/i.test(ua);
|
||||
const firefox = /Firefox/.test(ua);
|
||||
const win = /windows|win32|win64|wow32|wow64/.test(uas);
|
||||
const linux = /linux/.test(uas);
|
||||
return {
|
||||
ua,
|
||||
mobile,
|
||||
android,
|
||||
ios,
|
||||
mac,
|
||||
wx,
|
||||
chrome,
|
||||
iphone,
|
||||
ipad,
|
||||
safari,
|
||||
tiktok,
|
||||
weibo,
|
||||
win,
|
||||
linux,
|
||||
firefox,
|
||||
};
|
||||
};
|
||||
|
||||
11
packages/env/tsconfig.blocksuite.json
vendored
Normal file
11
packages/env/tsconfig.blocksuite.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib/blocksuite",
|
||||
"target": "ESNext"
|
||||
},
|
||||
"include": ["./blocksuite/*.ts", "src/types.d.ts", "env.d.ts"],
|
||||
"references": [{ "path": "../debug" }]
|
||||
}
|
||||
8
packages/env/tsconfig.json
vendored
8
packages/env/tsconfig.json
vendored
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src", "env.d.ts"]
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"composite": true,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["./src", "env.d.ts", "./src/global.d.ts"],
|
||||
"exclude": ["blocksuite", "lib"]
|
||||
}
|
||||
|
||||
@@ -4,5 +4,9 @@
|
||||
"./*": "./src/*"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@affine/env": "workspace:*",
|
||||
"@toeverything/y-indexeddb": "workspace:*"
|
||||
},
|
||||
"version": "0.5.4-beta.2"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src"]
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"composite": true,
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["./src"],
|
||||
"references": [{ "path": "../env" }, { "path": "../y-indexeddb" }]
|
||||
}
|
||||
|
||||
1
packages/i18n/.gitignore
vendored
Normal file
1
packages/i18n/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -1,4 +1,11 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src"]
|
||||
"include": ["./src"],
|
||||
"exclude": ["src/resources"],
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"composite": true,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"references": [{ "path": "./tsconfig.resources.json" }]
|
||||
}
|
||||
|
||||
13
packages/i18n/tsconfig.resources.json
Normal file
13
packages/i18n/tsconfig.resources.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "nodenext",
|
||||
"outDir": "lib/resources",
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["./src/resources/**/*.ts", "./src/resources/**/*.json"],
|
||||
"exclude": ["dist", "lib"]
|
||||
}
|
||||
1
packages/jotai/.gitignore
vendored
Normal file
1
packages/jotai/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -3,8 +3,12 @@
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib",
|
||||
"composite": true
|
||||
},
|
||||
"include": ["./src"],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["node_modules"],
|
||||
"references": [{ "path": "../env" }]
|
||||
}
|
||||
|
||||
@@ -7,21 +7,20 @@ import { fileURLToPath } from 'node:url';
|
||||
import { lastValueFrom, Subject } from 'rxjs';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import type { FSWatcher } from '../index';
|
||||
import { watch } from '../index.js';
|
||||
import { FsWatcher } from '../index';
|
||||
|
||||
test('fs watch', { concurrency: false }, async t => {
|
||||
let watcher: FSWatcher;
|
||||
let watcher: FsWatcher;
|
||||
let fixture: string;
|
||||
t.beforeEach(async () => {
|
||||
const fixtureName = `fs-${v4()}.fixture`;
|
||||
fixture = join(fileURLToPath(import.meta.url), '..', fixtureName);
|
||||
await fs.writeFile(fixture, '\n');
|
||||
watcher = watch(fixture);
|
||||
watcher = FsWatcher.watch(fixture);
|
||||
});
|
||||
|
||||
t.afterEach(async () => {
|
||||
watcher.close();
|
||||
FsWatcher.close();
|
||||
await fs.unlink(fixture).catch(() => false);
|
||||
});
|
||||
|
||||
|
||||
2
packages/native/index.d.ts
vendored
2
packages/native/index.d.ts
vendored
@@ -7,7 +7,7 @@ export interface WatchOptions {
|
||||
recursive?: boolean;
|
||||
}
|
||||
/** Watcher kind enumeration */
|
||||
export const enum WatcherKind {
|
||||
export enum WatcherKind {
|
||||
/** inotify backend (linux) */
|
||||
Inotify = 'Inotify',
|
||||
/** FS-Event backend (mac) */
|
||||
|
||||
@@ -3,7 +3,15 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
"path": "../component"
|
||||
},
|
||||
{
|
||||
"path": "../workspace"
|
||||
}
|
||||
]
|
||||
],
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"composite": true,
|
||||
"outDir": "lib"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
1
packages/workspace/.gitignore
vendored
Normal file
1
packages/workspace/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -10,7 +10,8 @@
|
||||
"./providers": "./src/providers/index.ts",
|
||||
"./affine/*": "./src/affine/*.ts",
|
||||
"./affine/api": "./src/affine/api/index.ts",
|
||||
"./affine/keck": "./src/affine/keck/index.ts"
|
||||
"./affine/keck": "./src/affine/keck/index.ts",
|
||||
"./affine/shared": "./src/affine/shared.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@blocksuite/blocks": "*",
|
||||
@@ -18,7 +19,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@affine-test/fixtures": "workspace:*",
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/debug": "workspace:*",
|
||||
"@affine/env": "workspace:*",
|
||||
"@toeverything/hooks": "workspace:*",
|
||||
|
||||
@@ -13,7 +13,6 @@ import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { Page, PageMeta } from '@blocksuite/store';
|
||||
import { Workspace } from '@blocksuite/store';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import type {} from '@toeverything/hooks/use-block-suite-page-meta';
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { WebSocket } from 'ws';
|
||||
import { applyUpdate } from 'yjs';
|
||||
@@ -36,6 +35,12 @@ import {
|
||||
setLoginStorage,
|
||||
} from '../login';
|
||||
|
||||
declare module '@blocksuite/store' {
|
||||
interface PageMeta {
|
||||
isPublic?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
globalThis.WebSocket = WebSocket;
|
||||
|
||||
@@ -110,7 +115,7 @@ beforeEach(async () => {
|
||||
declare global {
|
||||
interface DocumentEventMap {
|
||||
'affine-error': CustomEvent<{
|
||||
code: MessageCode;
|
||||
code: (typeof MessageCode)[keyof typeof MessageCode];
|
||||
}>;
|
||||
}
|
||||
}
|
||||
@@ -165,7 +170,7 @@ describe('api', () => {
|
||||
const listener = vi.fn(
|
||||
(
|
||||
e: CustomEvent<{
|
||||
code: MessageCode;
|
||||
code: (typeof MessageCode)[keyof typeof MessageCode];
|
||||
}>
|
||||
) => {
|
||||
expect(e.detail.code).toBe(MessageCode.loadListFailed);
|
||||
|
||||
@@ -4,9 +4,12 @@ import { z } from 'zod';
|
||||
import { checkLoginStorage } from '../login';
|
||||
|
||||
export class RequestError extends Error {
|
||||
public readonly code: MessageCode;
|
||||
public readonly code: (typeof MessageCode)[keyof typeof MessageCode];
|
||||
|
||||
constructor(code: MessageCode, cause: unknown | null = null) {
|
||||
constructor(
|
||||
code: (typeof MessageCode)[keyof typeof MessageCode],
|
||||
cause: unknown | null = null
|
||||
) {
|
||||
super(Messages[code].message);
|
||||
sendMessage(code);
|
||||
this.code = code;
|
||||
@@ -15,7 +18,7 @@ export class RequestError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
function sendMessage(code: MessageCode) {
|
||||
function sendMessage(code: (typeof MessageCode)[keyof typeof MessageCode]) {
|
||||
document.dispatchEvent(
|
||||
new CustomEvent('affine-error', {
|
||||
detail: {
|
||||
|
||||
@@ -119,7 +119,7 @@ export const checkLoginStorage = async (
|
||||
return getLoginStorage() as LoginResponse;
|
||||
};
|
||||
|
||||
export const enum SignMethod {
|
||||
export enum SignMethod {
|
||||
Google = 'Google',
|
||||
GitHub = 'GitHub',
|
||||
// Twitter = 'Twitter',
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { Workspace as RemoteWorkspace } from './affine/api';
|
||||
|
||||
export type JotaiStore = ReturnType<typeof createStore>;
|
||||
|
||||
export const enum WorkspaceSubPath {
|
||||
export enum WorkspaceSubPath {
|
||||
ALL = 'all',
|
||||
SETTING = 'setting',
|
||||
TRASH = 'trash',
|
||||
@@ -115,19 +115,19 @@ export interface AffinePublicWorkspace {
|
||||
providers: Provider[];
|
||||
}
|
||||
|
||||
export const enum ReleaseType {
|
||||
export enum ReleaseType {
|
||||
// if workspace is not released yet, we will not show it in the workspace list
|
||||
UNRELEASED = 'unreleased',
|
||||
STABLE = 'stable',
|
||||
}
|
||||
|
||||
export const enum LoadPriority {
|
||||
export enum LoadPriority {
|
||||
HIGH = 1,
|
||||
MEDIUM = 2,
|
||||
LOW = 3,
|
||||
}
|
||||
|
||||
export const enum WorkspaceFlavour {
|
||||
export enum WorkspaceFlavour {
|
||||
/**
|
||||
* AFFiNE Workspace is the workspace
|
||||
* that hosted on the Legacy AFFiNE Cloud Server.
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src"]
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["./src", "./src/affine/api", "../../apps/electron/layers"],
|
||||
"exclude": ["lib"],
|
||||
"references": [
|
||||
{ "path": "../../tests/fixtures" },
|
||||
{ "path": "../y-indexeddb" },
|
||||
{ "path": "../env" },
|
||||
{ "path": "../debug" },
|
||||
{ "path": "../hooks" },
|
||||
{ "path": "../component" }
|
||||
]
|
||||
}
|
||||
|
||||
1
packages/y-indexeddb/.gitignore
vendored
Normal file
1
packages/y-indexeddb/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -1,9 +1,17 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src"],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
},
|
||||
{
|
||||
"path": "../env"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user