mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 03:33:06 +08:00
feat: init ios-bridge
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@affine/ios-bridge",
|
||||
"version": "0.0.0",
|
||||
"description": "AFFiNE API For iOS app",
|
||||
"private": true,
|
||||
"browser": "src/index.ts",
|
||||
"scripts": {
|
||||
"build": "DISTRIBUTION=ios-bridge yarn workspace @affine/cli build",
|
||||
"dev": "DISTRIBUTION=ios-bridge yarn workspace @affine/cli dev",
|
||||
"static-server": "DISTRIBUTION=ios-bridge yarn workspace @affine/cli dev --static"
|
||||
},
|
||||
"dependencies": {
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/env": "workspace:*",
|
||||
"@sentry/react": "^7.109.0",
|
||||
"core-js": "^3.36.1",
|
||||
"intl-segmenter-polyfill-rs": "^0.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine/cli": "workspace:*",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import './polyfill/dispose';
|
||||
import './polyfill/intl-segmenter';
|
||||
import './polyfill/request-idle-callback';
|
||||
import '@affine/core/bootstrap/preload';
|
||||
|
||||
import { configureCommonModules } from '@affine/core/modules';
|
||||
import { AuthService } from '@affine/core/modules/cloud';
|
||||
import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage';
|
||||
import {
|
||||
configureBrowserWorkspaceFlavours,
|
||||
configureIndexedDBWorkspaceEngineStorageProvider,
|
||||
} from '@affine/core/modules/workspace-engine';
|
||||
import {
|
||||
DocsService,
|
||||
Framework,
|
||||
LifecycleService,
|
||||
type WorkspaceMetadata,
|
||||
WorkspacesService,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
const framework = new Framework();
|
||||
configureCommonModules(framework);
|
||||
configureLocalStorageStateStorageImpls(framework);
|
||||
configureBrowserWorkspaceFlavours(framework);
|
||||
configureIndexedDBWorkspaceEngineStorageProvider(framework);
|
||||
const frameworkProvider = framework.provider();
|
||||
|
||||
// start the application
|
||||
frameworkProvider.get(LifecycleService).applicationStart();
|
||||
|
||||
const jsb = {
|
||||
signInPassword(email: string, password: string) {
|
||||
return frameworkProvider
|
||||
.get(AuthService)
|
||||
.signInPassword({ email, password });
|
||||
},
|
||||
|
||||
getWorkspacesList() {
|
||||
return frameworkProvider.get(WorkspacesService).list.workspaces$;
|
||||
},
|
||||
|
||||
getWorkspacesDocs(workspaceMeta: WorkspaceMetadata) {
|
||||
return frameworkProvider
|
||||
.get(WorkspacesService)
|
||||
.open({ metadata: workspaceMeta })
|
||||
.workspace.scope.get(DocsService)
|
||||
.list.docs$.map(docs => docs.map(d => d.meta$.value));
|
||||
},
|
||||
// ... add more methods here
|
||||
};
|
||||
|
||||
(window as any).jsb = jsb;
|
||||
(window as any).workspacesService = frameworkProvider.get(WorkspacesService);
|
||||
@@ -0,0 +1,2 @@
|
||||
import 'core-js/modules/esnext.symbol.async-dispose';
|
||||
import 'core-js/modules/esnext.symbol.dispose';
|
||||
@@ -0,0 +1,11 @@
|
||||
if (Intl.Segmenter === undefined) {
|
||||
await import('intl-segmenter-polyfill-rs').then(({ Segmenter }) => {
|
||||
Object.defineProperty(Intl, 'Segmenter', {
|
||||
value: Segmenter,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,19 @@
|
||||
window.requestIdleCallback =
|
||||
window.requestIdleCallback ||
|
||||
function (cb) {
|
||||
const start = Date.now();
|
||||
return setTimeout(function () {
|
||||
cb({
|
||||
didTimeout: false,
|
||||
timeRemaining: function () {
|
||||
return Math.max(0, 50 - (Date.now() - start));
|
||||
},
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
window.cancelIdleCallback =
|
||||
window.cancelIdleCallback ||
|
||||
function (id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "lib",
|
||||
"moduleResolution": "Bundler",
|
||||
"types": ["affine__env"],
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["./src"],
|
||||
"references": [{ "path": "../core" }]
|
||||
}
|
||||
Reference in New Issue
Block a user