mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
refactor: environment setup (#2898)
Co-authored-by: Simon He <57086651+Simon-He95@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { MessageCode, Messages } from '@affine/env';
|
||||
import { MessageCode, Messages } from '@affine/env/constant';
|
||||
import type {
|
||||
AcceptInvitingParams,
|
||||
DeleteWorkspaceParams,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isBrowser } from '@affine/env/constant';
|
||||
import * as encoding from 'lib0/encoding';
|
||||
import * as math from 'lib0/math';
|
||||
import { Observable } from 'lib0/observable';
|
||||
@@ -217,7 +218,7 @@ export class KeckProvider extends Observable<string> {
|
||||
'window unload'
|
||||
);
|
||||
};
|
||||
if (typeof window !== 'undefined') {
|
||||
if (isBrowser) {
|
||||
window.addEventListener('unload', this._unloadHandler);
|
||||
} else if (typeof process !== 'undefined') {
|
||||
process.on('exit', this._unloadHandler);
|
||||
@@ -259,7 +260,7 @@ export class KeckProvider extends Observable<string> {
|
||||
}
|
||||
clearInterval(this._checkInterval);
|
||||
this.disconnect();
|
||||
if (typeof window !== 'undefined') {
|
||||
if (isBrowser) {
|
||||
window.removeEventListener('unload', this._unloadHandler);
|
||||
} else if (typeof process !== 'undefined') {
|
||||
process.off('exit', this._unloadHandler);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { env } from '@affine/env';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { Slot } from '@blocksuite/store';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
@@ -189,7 +188,7 @@ export function createAffineAuth(prefix = '/') {
|
||||
}
|
||||
try {
|
||||
let idToken: string | undefined;
|
||||
if (env.isDesktop) {
|
||||
if (environment.isDesktop) {
|
||||
idToken = await signInWithElectron(auth);
|
||||
} else {
|
||||
const response = await signInWithPopup(auth, provider);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { prefixUrl } from '@affine/env';
|
||||
import { setupGlobal } from '@affine/env/global';
|
||||
import { rootStore } from '@toeverything/plugin-infra/manager';
|
||||
|
||||
import { createUserApis, createWorkspaceApis } from './api/index';
|
||||
@@ -6,9 +6,12 @@ import { currentAffineUserAtom } from './atom';
|
||||
import type { LoginResponse } from './login';
|
||||
import { createAffineAuth, parseIdToken, setLoginStorage } from './login';
|
||||
|
||||
setupGlobal();
|
||||
|
||||
export const affineAuth = createAffineAuth(prefixUrl);
|
||||
const affineApis = {} as ReturnType<typeof createUserApis> &
|
||||
ReturnType<typeof createWorkspaceApis>;
|
||||
|
||||
Object.assign(affineApis, createUserApis(prefixUrl));
|
||||
Object.assign(affineApis, createWorkspaceApis(prefixUrl));
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { websocketPrefixUrl } from '@affine/env/api';
|
||||
import type { WorkspaceCRUD } from '@affine/env/workspace';
|
||||
import type { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import {
|
||||
|
||||
Reference in New Issue
Block a user