chore: disable rules in oxlint (#9154)
This commit is contained in:
@@ -2,4 +2,6 @@ export type { DocCustomPropertyInfo, DocProperties } from './schema';
|
||||
export {
|
||||
AFFiNE_WORKSPACE_DB_SCHEMA,
|
||||
AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA,
|
||||
type AFFiNEWorkspaceDbSchema,
|
||||
type AFFiNEWorkspaceUserdataDbSchema,
|
||||
} from './schema';
|
||||
|
||||
@@ -30,14 +30,12 @@ export const AFFiNE_WORKSPACE_DB_SCHEMA = {
|
||||
// we will keep deleted properties in the database, for override legacy data
|
||||
},
|
||||
} as const satisfies DBSchemaBuilder;
|
||||
export type AFFiNE_WORKSPACE_DB_SCHEMA = typeof AFFiNE_WORKSPACE_DB_SCHEMA;
|
||||
export type AFFiNEWorkspaceDbSchema = typeof AFFiNE_WORKSPACE_DB_SCHEMA;
|
||||
|
||||
export type DocProperties = ORMEntity<
|
||||
AFFiNE_WORKSPACE_DB_SCHEMA['docProperties']
|
||||
>;
|
||||
export type DocProperties = ORMEntity<AFFiNEWorkspaceDbSchema['docProperties']>;
|
||||
|
||||
export type DocCustomPropertyInfo = ORMEntity<
|
||||
AFFiNE_WORKSPACE_DB_SCHEMA['docCustomPropertyInfo']
|
||||
AFFiNEWorkspaceDbSchema['docCustomPropertyInfo']
|
||||
>;
|
||||
|
||||
export const AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA = {
|
||||
@@ -46,5 +44,5 @@ export const AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA = {
|
||||
index: f.string(),
|
||||
},
|
||||
} as const satisfies DBSchemaBuilder;
|
||||
export type AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA =
|
||||
export type AFFiNEWorkspaceUserdataDbSchema =
|
||||
typeof AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA;
|
||||
|
||||
@@ -9,6 +9,8 @@ import { WorkspaceDB, type WorkspaceDBWithTables } from '../entities/db';
|
||||
import {
|
||||
AFFiNE_WORKSPACE_DB_SCHEMA,
|
||||
AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA,
|
||||
type AFFiNEWorkspaceDbSchema,
|
||||
type AFFiNEWorkspaceUserdataDbSchema,
|
||||
} from '../schema';
|
||||
|
||||
const WorkspaceDBClient = createORMClient(AFFiNE_WORKSPACE_DB_SCHEMA);
|
||||
@@ -17,10 +19,10 @@ const WorkspaceUserdataDBClient = createORMClient(
|
||||
);
|
||||
|
||||
export class WorkspaceDBService extends Service {
|
||||
db: WorkspaceDBWithTables<AFFiNE_WORKSPACE_DB_SCHEMA>;
|
||||
db: WorkspaceDBWithTables<AFFiNEWorkspaceDbSchema>;
|
||||
userdataDBPool = new ObjectPool<
|
||||
string,
|
||||
WorkspaceDB<AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA>
|
||||
WorkspaceDB<AFFiNEWorkspaceUserdataDbSchema>
|
||||
>({
|
||||
onDangling() {
|
||||
return false; // never release
|
||||
@@ -30,7 +32,7 @@ export class WorkspaceDBService extends Service {
|
||||
constructor(private readonly workspaceService: WorkspaceService) {
|
||||
super();
|
||||
this.db = this.framework.createEntity(
|
||||
WorkspaceDB<AFFiNE_WORKSPACE_DB_SCHEMA>,
|
||||
WorkspaceDB<AFFiNEWorkspaceDbSchema>,
|
||||
{
|
||||
db: new WorkspaceDBClient(
|
||||
new YjsDBAdapter(AFFiNE_WORKSPACE_DB_SCHEMA, {
|
||||
@@ -52,7 +54,7 @@ export class WorkspaceDBService extends Service {
|
||||
storageDocId: tableName =>
|
||||
`db$${this.workspaceService.workspace.id}$${tableName}`,
|
||||
}
|
||||
) as WorkspaceDBWithTables<AFFiNE_WORKSPACE_DB_SCHEMA>;
|
||||
) as WorkspaceDBWithTables<AFFiNEWorkspaceDbSchema>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
@@ -60,11 +62,11 @@ export class WorkspaceDBService extends Service {
|
||||
// __local__ for local workspace
|
||||
const userdataDb = this.userdataDBPool.get(userId);
|
||||
if (userdataDb) {
|
||||
return userdataDb.obj as WorkspaceDBWithTables<AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA>;
|
||||
return userdataDb.obj as WorkspaceDBWithTables<AFFiNEWorkspaceUserdataDbSchema>;
|
||||
}
|
||||
|
||||
const newDB = this.framework.createEntity(
|
||||
WorkspaceDB<AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA>,
|
||||
WorkspaceDB<AFFiNEWorkspaceUserdataDbSchema>,
|
||||
{
|
||||
db: new WorkspaceUserdataDBClient(
|
||||
new YjsDBAdapter(AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA, {
|
||||
@@ -89,7 +91,7 @@ export class WorkspaceDBService extends Service {
|
||||
);
|
||||
|
||||
this.userdataDBPool.put(userId, newDB);
|
||||
return newDB as WorkspaceDBWithTables<AFFiNE_WORKSPACE_USERDATA_DB_SCHEMA>;
|
||||
return newDB as WorkspaceDBWithTables<AFFiNEWorkspaceUserdataDbSchema>;
|
||||
}
|
||||
|
||||
static isDBDocId(docId: string) {
|
||||
|
||||
@@ -236,4 +236,5 @@ export const AFFINE_FLAGS = {
|
||||
},
|
||||
} satisfies { [key in string]: FlagInfo };
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export type AFFINE_FLAGS = typeof AFFINE_FLAGS;
|
||||
|
||||
@@ -25,7 +25,6 @@ test('fractional-indexing', () => {
|
||||
|
||||
if (set.has(s1) || set.has(s2) || s1 === s2) {
|
||||
throw new Error('Duplicate key, ' + set.size + ', ' + s1 + ', ' + s2);
|
||||
break;
|
||||
}
|
||||
set.add(s1);
|
||||
set.add(s2);
|
||||
|
||||
@@ -118,7 +118,7 @@ export function uint8ArrayToBase64(array: Uint8Array): Promise<string> {
|
||||
|
||||
export function base64ToUint8Array(base64: string) {
|
||||
const binaryString = atob(base64);
|
||||
const binaryArray = binaryString.split('').map(function (char) {
|
||||
const binaryArray = [...binaryString].map(function (char) {
|
||||
return char.charCodeAt(0);
|
||||
});
|
||||
return new Uint8Array(binaryArray);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
|
||||
import type { ConnectionStatus } from '../connection';
|
||||
import { type Storage, type StorageType } from '../storage';
|
||||
import { type Storage, type StorageType } from './storage';
|
||||
import type { BlobStorage } from './blob';
|
||||
import type { DocStorage } from './doc';
|
||||
import type { SyncStorage } from './sync';
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"version": "0.18.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/graphql": "workspace:*",
|
||||
"@radix-ui/react-accordion": "^1.2.2",
|
||||
|
||||
@@ -38,7 +38,11 @@ export function DataTableRowActions({ user }: DataTableRowActionsProps) {
|
||||
const { resetPasswordLink, onResetPassword } = useResetUserPassword();
|
||||
|
||||
const openResetPasswordDialog = useCallback(() => {
|
||||
onResetPassword(user.id, () => setResetPasswordDialogOpen(true));
|
||||
onResetPassword(user.id, () => setResetPasswordDialogOpen(true)).catch(
|
||||
e => {
|
||||
console.error(e);
|
||||
}
|
||||
);
|
||||
}, [onResetPassword, user.id]);
|
||||
|
||||
const handleCopy = useCallback(() => {
|
||||
|
||||
@@ -53,7 +53,7 @@ export const useCreateUser = () => {
|
||||
toast.error('Failed to update account: ' + (e as Error).message);
|
||||
}
|
||||
},
|
||||
[createAccount, revalidate]
|
||||
[createAccount, revalidate, updateAccountFeatures]
|
||||
);
|
||||
|
||||
return { creating: creating || !!error, create };
|
||||
@@ -99,7 +99,7 @@ export const useUpdateUser = () => {
|
||||
toast.error('Failed to update account: ' + (e as Error).message);
|
||||
}
|
||||
},
|
||||
[revalidate, updateAccount]
|
||||
[revalidate, updateAccount, updateAccountFeatures]
|
||||
);
|
||||
|
||||
return { updating: updating || !!error, update };
|
||||
|
||||
@@ -26,7 +26,7 @@ export function UserDropdown() {
|
||||
fetch('/api/auth/sign-out')
|
||||
.then(() => {
|
||||
toast.success('Logged out successfully');
|
||||
relative();
|
||||
return relative();
|
||||
})
|
||||
.catch(err => {
|
||||
toast.error(`Failed to logout: ${err.message}`);
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
CarouselItem,
|
||||
} from '@affine/admin/components/ui/carousel';
|
||||
import { validateEmailAndPassword } from '@affine/admin/utils';
|
||||
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { toast } from 'sonner';
|
||||
@@ -120,7 +121,7 @@ export const Form = () => {
|
||||
}
|
||||
}, [emailValue, passwordValue, refreshServerConfig]);
|
||||
|
||||
const onNext = useCallback(async () => {
|
||||
const onNext = useAsyncCallback(async () => {
|
||||
if (isCreateAdminStep) {
|
||||
if (
|
||||
!validateEmailAndPassword(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"@affine-test/kit": "workspace:*",
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/electron-api": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@affine/native": "workspace:*",
|
||||
"@affine/nbstore": "workspace:*",
|
||||
@@ -48,9 +49,12 @@
|
||||
"@toeverything/infra": "workspace:*",
|
||||
"@types/set-cookie-parser": "^2.4.10",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@vanilla-extract/css": "^1.16.1",
|
||||
"@vitejs/plugin-react-swc": "^3.7.2",
|
||||
"app-builder-lib": "^25.1.8",
|
||||
"builder-util-runtime": "^9.2.10",
|
||||
"cross-env": "^7.0.3",
|
||||
"debug": "^4.4.0",
|
||||
"electron": "^33.3.0",
|
||||
"electron-log": "^5.2.4",
|
||||
"electron-squirrel-startup": "1.0.1",
|
||||
@@ -59,6 +63,7 @@
|
||||
"fs-extra": "^11.2.0",
|
||||
"glob": "^11.0.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"msw": "^2.6.8",
|
||||
"nanoid": "^5.0.9",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
|
||||
@@ -80,7 +80,9 @@ async function watchLayers() {
|
||||
console.log(`[layers] has changed, [re]launching electron...`);
|
||||
spawnOrReloadElectron();
|
||||
} else {
|
||||
buildContextPromise.then(resolve);
|
||||
buildContextPromise.then(resolve).catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
initialBuild = true;
|
||||
}
|
||||
});
|
||||
@@ -88,9 +90,13 @@ async function watchLayers() {
|
||||
},
|
||||
],
|
||||
});
|
||||
buildContextPromise.then(async buildContext => {
|
||||
await buildContext.watch();
|
||||
});
|
||||
buildContextPromise
|
||||
.then(buildContext => {
|
||||
return buildContext.watch();
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -89,4 +89,6 @@ async function make() {
|
||||
await fs.remove(tmpPath);
|
||||
}
|
||||
|
||||
make();
|
||||
make().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
@@ -79,4 +79,6 @@ async function make() {
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
make();
|
||||
make().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
@@ -33,6 +33,7 @@ if (overrideSession) {
|
||||
app.setPath('sessionData', userDataPath);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
if (require('electron-squirrel-startup')) app.quit();
|
||||
|
||||
if (process.env.SKIP_ONBOARDING) {
|
||||
|
||||
@@ -50,6 +50,6 @@ export const SpellCheckStateSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const SpellCheckStateKey = 'spellCheckState';
|
||||
export type SpellCheckStateKey = typeof SpellCheckStateKey;
|
||||
export const SpellCheckStateKey = 'spellCheckState' as const;
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export type SpellCheckStateSchema = z.infer<typeof SpellCheckStateSchema>;
|
||||
|
||||
@@ -86,10 +86,14 @@ framework.impl(ValidatorProvider, {
|
||||
});
|
||||
framework.impl(VirtualKeyboardProvider, {
|
||||
addEventListener: (event, callback) => {
|
||||
Keyboard.addListener(event as any, callback as any);
|
||||
Keyboard.addListener(event as any, callback as any).catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
},
|
||||
removeAllListeners: () => {
|
||||
Keyboard.removeAllListeners();
|
||||
Keyboard.removeAllListeners().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
},
|
||||
});
|
||||
framework.impl(NavigationGestureProvider, {
|
||||
@@ -145,6 +149,8 @@ CapacitorApp.addListener('appUrlOpen', ({ url }) => {
|
||||
.catch(console.error);
|
||||
}
|
||||
}
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
export function App() {
|
||||
|
||||
@@ -115,7 +115,7 @@ const convertBody = async (body: unknown, contentType: string) => {
|
||||
};
|
||||
function base64ToUint8Array(base64: string) {
|
||||
const binaryString = atob(base64);
|
||||
const binaryArray = binaryString.split('').map(function (char) {
|
||||
const binaryArray = [...binaryString].map(function (char) {
|
||||
return char.charCodeAt(0);
|
||||
});
|
||||
return new Uint8Array(binaryArray);
|
||||
|
||||
@@ -13,7 +13,7 @@ class NavigatorVirtualKeyboard implements VirtualKeyboard {
|
||||
|
||||
private readonly _overlaysContent = false;
|
||||
|
||||
private _listeners = new Map<
|
||||
private readonly _listeners = new Map<
|
||||
string,
|
||||
Set<{
|
||||
cb: VirtualKeyboardCallback;
|
||||
@@ -53,11 +53,17 @@ class NavigatorVirtualKeyboard implements VirtualKeyboard {
|
||||
};
|
||||
|
||||
constructor() {
|
||||
this._bindListener();
|
||||
this._bindListener().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this._capacitorListenerHandles.forEach(handle => handle.remove());
|
||||
this._capacitorListenerHandles.forEach(handle => {
|
||||
handle.remove().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
get boundingRect(): DOMRect {
|
||||
@@ -75,11 +81,15 @@ class NavigatorVirtualKeyboard implements VirtualKeyboard {
|
||||
}
|
||||
|
||||
hide() {
|
||||
Keyboard.hide();
|
||||
Keyboard.hide().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
Keyboard.show();
|
||||
Keyboard.show().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
ongeometrychange: ((this: VirtualKeyboard, ev: Event) => any) | null = null;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { type PasswordLimitsFragment } from '@affine/graphql';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { type Options, passwordStrength } from 'check-password-strength';
|
||||
import { type FC, useEffect, useMemo } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { type FC, useEffect, useMemo, useCallback, useState } from 'react';
|
||||
import { z, type ZodCustomIssue, ZodIssueCode } from 'zod';
|
||||
|
||||
import type { InputProps } from '../../../ui/input';
|
||||
|
||||
@@ -97,7 +97,7 @@ export const DayPicker = memo(function DayPicker(
|
||||
const focused = document.activeElement;
|
||||
|
||||
// check if focused is a date cell
|
||||
if (!focused?.hasAttribute('data-is-date-cell')) return;
|
||||
if (!(focused as HTMLElement | null)?.dataset.isDateCell) return;
|
||||
if (e.shiftKey) return;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@@ -4,8 +4,9 @@ import { type EditorHost } from '@blocksuite/affine/block-std';
|
||||
import {
|
||||
type AIItemGroupConfig,
|
||||
EdgelessRootService,
|
||||
createLitPortal,
|
||||
HoverController,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { createLitPortal, HoverController } from '@blocksuite/affine/blocks';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import { flip, offset } from '@floating-ui/dom';
|
||||
import { css, html, LitElement, nothing } from 'lit';
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
type AffineSlashSubMenu,
|
||||
type AIItemConfig,
|
||||
DocModeProvider,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import {
|
||||
AFFINE_AI_PANEL_WIDGET,
|
||||
AffineSlashMenuWidget,
|
||||
AIStarIcon,
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
DocModeProvider,
|
||||
type EdgelessRootService,
|
||||
TelemetryProvider,
|
||||
NotificationProvider,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { NotificationProvider } from '@blocksuite/affine/blocks';
|
||||
import {
|
||||
type AIChatBlockModel,
|
||||
type ChatMessage,
|
||||
|
||||
@@ -4,8 +4,9 @@ import {
|
||||
type FrameBlockModel,
|
||||
ImageBlockModel,
|
||||
type SurfaceBlockComponent,
|
||||
BlocksUtils,
|
||||
EdgelessRootService,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { BlocksUtils, EdgelessRootService } from '@blocksuite/affine/blocks';
|
||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
type BlockModel,
|
||||
|
||||
@@ -236,6 +236,7 @@ export function revertUpdate(
|
||||
} else if (type === 'Array') {
|
||||
return snapshotDoc.getArray(key);
|
||||
}
|
||||
// eslint-disable-next-line array-callback-return
|
||||
throw new Error('Unknown type');
|
||||
})
|
||||
);
|
||||
|
||||
@@ -27,12 +27,12 @@ import { DebugLogger } from '@affine/debug';
|
||||
import { track } from '@affine/track';
|
||||
import {
|
||||
type BlockService,
|
||||
BlockServiceWatcher,
|
||||
BlockViewIdentifier,
|
||||
ConfigIdentifier,
|
||||
type ExtensionType,
|
||||
type WidgetComponent,
|
||||
} from '@blocksuite/affine/block-std';
|
||||
import { BlockServiceWatcher } from '@blocksuite/affine/block-std';
|
||||
import type {
|
||||
AffineReference,
|
||||
DocMode,
|
||||
|
||||
@@ -11,8 +11,6 @@ import { GlobalDialogService } from '@affine/core/modules/dialogs';
|
||||
import {
|
||||
type CreateCheckoutSessionInput,
|
||||
SubscriptionRecurring,
|
||||
} from '@affine/graphql';
|
||||
import {
|
||||
SubscriptionPlan,
|
||||
SubscriptionStatus,
|
||||
SubscriptionVariant,
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
ExplorerService,
|
||||
ExplorerTreeRoot,
|
||||
} from '@affine/core/modules/explorer';
|
||||
import type { FavoriteSupportType } from '@affine/core/modules/favorite';
|
||||
import type { FavoriteSupportTypeUnion } from '@affine/core/modules/favorite';
|
||||
import { FavoriteService } from '@affine/core/modules/favorite';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import {
|
||||
@@ -73,7 +73,7 @@ export const FavoriteNode = ({
|
||||
}: {
|
||||
favorite: {
|
||||
id: string;
|
||||
type: FavoriteSupportType;
|
||||
type: FavoriteSupportTypeUnion;
|
||||
};
|
||||
}) => {
|
||||
return favorite.type === 'doc' ? (
|
||||
|
||||
@@ -2,8 +2,8 @@ import {
|
||||
type SubscriptionQuery,
|
||||
SubscriptionRecurring,
|
||||
SubscriptionVariant,
|
||||
SubscriptionPlan,
|
||||
} from '@affine/graphql';
|
||||
import { SubscriptionPlan } from '@affine/graphql';
|
||||
import {
|
||||
backoffRetry,
|
||||
catchErrorInto,
|
||||
|
||||
@@ -32,4 +32,5 @@ export const EditorSettingSchema = BSEditorSettingSchema.merge(
|
||||
AffineEditorSettingSchema
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export type EditorSettingSchema = z.infer<typeof EditorSettingSchema>;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { LiveData, Service } from '@toeverything/infra';
|
||||
import type { DesktopApiService } from '../../desktop-api';
|
||||
import type { I18n } from '../../i18n';
|
||||
|
||||
const SPELL_CHECK_SETTING_KEY: SpellCheckStateKey = 'spellCheckState';
|
||||
const SPELL_CHECK_SETTING_KEY: typeof SpellCheckStateKey = 'spellCheckState';
|
||||
|
||||
export class SpellCheckSettingService extends Service {
|
||||
constructor(
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
DropEffect,
|
||||
ExplorerTreeRoot,
|
||||
} from '@affine/core/modules/explorer/views/tree';
|
||||
import type { FavoriteSupportType } from '@affine/core/modules/favorite';
|
||||
import type { FavoriteSupportTypeUnion } from '@affine/core/modules/favorite';
|
||||
import {
|
||||
FavoriteService,
|
||||
isFavoriteSupportType,
|
||||
@@ -97,7 +97,7 @@ export const ExplorerFavorites = () => {
|
||||
|
||||
const handleOnChildrenDrop = useCallback(
|
||||
(
|
||||
favorite: { id: string; type: FavoriteSupportType },
|
||||
favorite: { id: string; type: FavoriteSupportTypeUnion },
|
||||
data: DropTargetDropEvent<AffineDNDData>
|
||||
) => {
|
||||
if (
|
||||
@@ -220,12 +220,12 @@ const ExplorerFavoriteNode = ({
|
||||
}: {
|
||||
favorite: {
|
||||
id: string;
|
||||
type: FavoriteSupportType;
|
||||
type: FavoriteSupportTypeUnion;
|
||||
};
|
||||
onDrop: (
|
||||
favorite: {
|
||||
id: string;
|
||||
type: FavoriteSupportType;
|
||||
type: FavoriteSupportTypeUnion;
|
||||
},
|
||||
data: DropTargetDropEvent<AffineDNDData>
|
||||
) => void;
|
||||
|
||||
@@ -4,8 +4,8 @@ export const FavoriteSupportType = [
|
||||
'tag',
|
||||
'folder',
|
||||
] as const;
|
||||
export type FavoriteSupportType = 'collection' | 'doc' | 'tag' | 'folder';
|
||||
export type FavoriteSupportTypeUnion = 'collection' | 'doc' | 'tag' | 'folder';
|
||||
export const isFavoriteSupportType = (
|
||||
type: string
|
||||
): type is FavoriteSupportType =>
|
||||
FavoriteSupportType.includes(type as FavoriteSupportType);
|
||||
): type is FavoriteSupportTypeUnion =>
|
||||
FavoriteSupportType.includes(type as FavoriteSupportTypeUnion);
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
generateFractionalIndexingKeyBetween,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
import type { FavoriteSupportType } from '../constant';
|
||||
import type { FavoriteSupportTypeUnion } from '../constant';
|
||||
import type { FavoriteRecord, FavoriteStore } from '../stores/favorite';
|
||||
|
||||
export class FavoriteList extends Entity {
|
||||
@@ -20,16 +20,16 @@ export class FavoriteList extends Entity {
|
||||
/**
|
||||
* get favorite record by type and id
|
||||
*/
|
||||
favorite$(type: FavoriteSupportType, id: string) {
|
||||
favorite$(type: FavoriteSupportTypeUnion, id: string) {
|
||||
return this.store.watchFavorite(type, id);
|
||||
}
|
||||
|
||||
isFavorite$(type: FavoriteSupportType, id: string) {
|
||||
isFavorite$(type: FavoriteSupportTypeUnion, id: string) {
|
||||
return this.favorite$(type, id).map(v => !!v);
|
||||
}
|
||||
|
||||
add(
|
||||
type: FavoriteSupportType,
|
||||
type: FavoriteSupportTypeUnion,
|
||||
id: string,
|
||||
index: string = this.indexAt('before')
|
||||
) {
|
||||
@@ -37,7 +37,7 @@ export class FavoriteList extends Entity {
|
||||
}
|
||||
|
||||
toggle(
|
||||
type: FavoriteSupportType,
|
||||
type: FavoriteSupportTypeUnion,
|
||||
id: string,
|
||||
index: string = this.indexAt('before')
|
||||
) {
|
||||
@@ -48,18 +48,18 @@ export class FavoriteList extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
remove(type: FavoriteSupportType, id: string) {
|
||||
remove(type: FavoriteSupportTypeUnion, id: string) {
|
||||
return this.store.removeFavorite(type, id);
|
||||
}
|
||||
|
||||
reorder(type: FavoriteSupportType, id: string, index: string) {
|
||||
reorder(type: FavoriteSupportTypeUnion, id: string, index: string) {
|
||||
return this.store.reorderFavorite(type, id, index);
|
||||
}
|
||||
|
||||
indexAt(
|
||||
at: 'before' | 'after',
|
||||
targetRecord?: {
|
||||
type: FavoriteSupportType;
|
||||
type: FavoriteSupportTypeUnion;
|
||||
id: string;
|
||||
}
|
||||
) {
|
||||
|
||||
@@ -14,7 +14,11 @@ import {
|
||||
} from './services/old/adapter';
|
||||
import { FavoriteStore } from './stores/favorite';
|
||||
|
||||
export { FavoriteSupportType, isFavoriteSupportType } from './constant';
|
||||
export {
|
||||
FavoriteSupportType,
|
||||
type FavoriteSupportTypeUnion,
|
||||
isFavoriteSupportType,
|
||||
} from './constant';
|
||||
export type { FavoriteList } from './entities/favorite-list';
|
||||
export { FavoriteService } from './services/favorite';
|
||||
export {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { LiveData, Service } from '@toeverything/infra';
|
||||
import { defaultsDeep } from 'lodash-es';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import type { FavoriteSupportType } from '../../constant';
|
||||
import type { FavoriteSupportTypeUnion } from '../../constant';
|
||||
import type { FavoriteService } from '../favorite';
|
||||
import {
|
||||
PagePropertyType,
|
||||
@@ -192,7 +192,7 @@ export class MigrationFavoriteItemsAdapter extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
type CompatibleFavoriteSupportType = FavoriteSupportType;
|
||||
type CompatibleFavoriteSupportType = FavoriteSupportTypeUnion;
|
||||
|
||||
/**
|
||||
* A service written for compatibility,with the same API as old FavoriteItemsAdapter.
|
||||
|
||||
@@ -3,11 +3,11 @@ import { LiveData, Store } from '@toeverything/infra';
|
||||
import { map } from 'rxjs';
|
||||
|
||||
import { AuthService, type WorkspaceServerService } from '../../cloud';
|
||||
import type { FavoriteSupportType } from '../constant';
|
||||
import type { FavoriteSupportTypeUnion } from '../constant';
|
||||
import { isFavoriteSupportType } from '../constant';
|
||||
|
||||
export interface FavoriteRecord {
|
||||
type: FavoriteSupportType;
|
||||
type: FavoriteSupportTypeUnion;
|
||||
id: string;
|
||||
index: string;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ export class FavoriteStore extends Store {
|
||||
}
|
||||
|
||||
addFavorite(
|
||||
type: FavoriteSupportType,
|
||||
type: FavoriteSupportTypeUnion,
|
||||
id: string,
|
||||
index: string
|
||||
): FavoriteRecord {
|
||||
@@ -70,17 +70,17 @@ export class FavoriteStore extends Store {
|
||||
return this.toRecord(raw) as FavoriteRecord;
|
||||
}
|
||||
|
||||
reorderFavorite(type: FavoriteSupportType, id: string, index: string) {
|
||||
reorderFavorite(type: FavoriteSupportTypeUnion, id: string, index: string) {
|
||||
const db = this.userdataDB$.value;
|
||||
db.favorite.update(this.encodeKey(type, id), { index });
|
||||
}
|
||||
|
||||
removeFavorite(type: FavoriteSupportType, id: string) {
|
||||
removeFavorite(type: FavoriteSupportTypeUnion, id: string) {
|
||||
const db = this.userdataDB$.value;
|
||||
db.favorite.delete(this.encodeKey(type, id));
|
||||
}
|
||||
|
||||
watchFavorite(type: FavoriteSupportType, id: string) {
|
||||
watchFavorite(type: FavoriteSupportTypeUnion, id: string) {
|
||||
const db = this.userdataDB$.value;
|
||||
return LiveData.from<FavoriteRecord | undefined>(
|
||||
db.favorite
|
||||
@@ -112,7 +112,7 @@ export class FavoriteStore extends Store {
|
||||
* @returns null if key is invalid
|
||||
*/
|
||||
private parseKey(key: string): {
|
||||
type: FavoriteSupportType;
|
||||
type: FavoriteSupportTypeUnion;
|
||||
id: string;
|
||||
} | null {
|
||||
const [type, id] = key.split(':');
|
||||
@@ -122,10 +122,10 @@ export class FavoriteStore extends Store {
|
||||
if (!isFavoriteSupportType(type)) {
|
||||
return null;
|
||||
}
|
||||
return { type: type as FavoriteSupportType, id };
|
||||
return { type: type as FavoriteSupportTypeUnion, id };
|
||||
}
|
||||
|
||||
private encodeKey(type: FavoriteSupportType, id: string) {
|
||||
private encodeKey(type: FavoriteSupportTypeUnion, id: string) {
|
||||
return `${type}:${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ export const OrganizeSupportType = [
|
||||
'collection',
|
||||
'tag',
|
||||
] as const;
|
||||
export type OrganizeSupportType = 'folder' | 'doc' | 'collection' | 'tag';
|
||||
export type OrganizeSupportTypeUnion = 'folder' | 'doc' | 'collection' | 'tag';
|
||||
|
||||
export const isOrganizeSupportType = (
|
||||
type: string
|
||||
): type is OrganizeSupportType =>
|
||||
OrganizeSupportType.includes(type as OrganizeSupportType);
|
||||
): type is OrganizeSupportTypeUnion =>
|
||||
OrganizeSupportType.includes(type as OrganizeSupportTypeUnion);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createORMClient, Entity, YjsDBAdapter } from '@toeverything/infra';
|
||||
import { Doc as YDoc } from 'yjs';
|
||||
|
||||
import { USER_DB_SCHEMA } from '../schema';
|
||||
import { USER_DB_SCHEMA, type UserDbSchema } from '../schema';
|
||||
import { UserDBEngine } from './user-db-engine';
|
||||
import { UserDBTable } from './user-db-table';
|
||||
|
||||
@@ -42,5 +42,5 @@ export class UserDB extends Entity<{
|
||||
}
|
||||
|
||||
export type UserDBWithTables = UserDB & {
|
||||
[K in keyof USER_DB_SCHEMA]: UserDBTable<USER_DB_SCHEMA[K]>;
|
||||
[K in keyof UserDbSchema]: UserDBTable<UserDbSchema[K]>;
|
||||
};
|
||||
|
||||
@@ -6,4 +6,4 @@ export const USER_DB_SCHEMA = {
|
||||
value: f.string(),
|
||||
},
|
||||
} as const satisfies DBSchemaBuilder;
|
||||
export type USER_DB_SCHEMA = typeof USER_DB_SCHEMA;
|
||||
export type UserDbSchema = typeof USER_DB_SCHEMA;
|
||||
|
||||
@@ -24,8 +24,9 @@ import {
|
||||
type WorkspaceFlavoursProvider,
|
||||
type WorkspaceMetadata,
|
||||
type WorkspaceProfileInfo,
|
||||
effect,
|
||||
getAFFiNEWorkspaceSchema,
|
||||
} from '@toeverything/infra';
|
||||
import { effect, getAFFiNEWorkspaceSchema } from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { EMPTY, map, mergeMap, Observable, switchMap } from 'rxjs';
|
||||
|
||||
@@ -21,7 +21,7 @@ export function uint8ArrayToBase64(array: Uint8Array): Promise<string> {
|
||||
|
||||
export function base64ToUint8Array(base64: string) {
|
||||
const binaryString = atob(base64);
|
||||
const binaryArray = binaryString.split('').map(function (char) {
|
||||
const binaryArray = [...binaryString].map(function (char) {
|
||||
return char.charCodeAt(0);
|
||||
});
|
||||
return new Uint8Array(binaryArray);
|
||||
|
||||
@@ -16,16 +16,12 @@ export function fuzzyMatch(
|
||||
query: string,
|
||||
matchInitial?: boolean
|
||||
) {
|
||||
const pureName = name
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.split('')
|
||||
const pureName = [...name.trim().toLowerCase()]
|
||||
.filter(char => char !== ' ')
|
||||
.join('');
|
||||
|
||||
const regex = new RegExp(
|
||||
query
|
||||
.split('')
|
||||
[...query]
|
||||
.filter(char => char !== ' ')
|
||||
.map(item => `${escapeRegExp(item)}.*`)
|
||||
.join(''),
|
||||
|
||||
@@ -158,4 +158,4 @@ export function createI18nWrapper(getI18nFn: () => i18n) {
|
||||
* I18n['com.affine.xxx']({ arg1: 'hello' }) -> '中文 hello'
|
||||
*/
|
||||
export const I18n = createI18nWrapper(getOrCreateI18n);
|
||||
export type I18n = typeof I18n;
|
||||
export type I18nInstance = typeof I18n;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { I18n } from '../i18next';
|
||||
import { type I18nInstance, I18n } from '../i18next';
|
||||
|
||||
export type TimeUnit =
|
||||
| 'second'
|
||||
@@ -46,7 +46,7 @@ export function i18nTime(
|
||||
time: dayjs.ConfigType,
|
||||
options: {
|
||||
// override i18n instance, default is global I18n instance
|
||||
i18n?: I18n;
|
||||
i18n?: I18nInstance;
|
||||
// override now time, default is current time
|
||||
now?: dayjs.ConfigType;
|
||||
relative?:
|
||||
|
||||
Reference in New Issue
Block a user