-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
157 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "yarn workspace @affine/cli build", | ||
"dev": "yarn workspace @affine/cli dev", | ||
"static-server": "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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import './polyfill/dispose'; | ||
import './polyfill/intl-segmenter'; | ||
import './polyfill/request-idle-callback'; | ||
import '@affine/core/bootstrap/preload'; | ||
|
||
import { configureCommonModules, configureImpls } from '@affine/core/modules'; | ||
import { AuthService } from '@affine/core/modules/cloud'; | ||
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); | ||
configureImpls(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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'core-js/modules/esnext.symbol.async-dispose'; | ||
import 'core-js/modules/esnext.symbol.dispose'; |
11 changes: 11 additions & 0 deletions
11
packages/frontend/ios-bridge/src/polyfill/intl-segmenter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {}; |
19 changes: 19 additions & 0 deletions
19
packages/frontend/ios-bridge/src/polyfill/request-idle-callback.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"outDir": "lib", | ||
"moduleResolution": "Bundler", | ||
"types": ["affine__env"], | ||
"rootDir": "./src" | ||
}, | ||
"include": ["./src"], | ||
"references": [{ "path": "../core" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters