chore: remove tarui (#7089)

* chore: remove tarui

* chore: remove tarui config
This commit is contained in:
Nathan.fooo 2024-12-30 15:41:23 +08:00 committed by GitHub
parent 09fa75f5ec
commit d9b3f3f6c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
694 changed files with 3 additions and 52664 deletions

View File

@ -7,7 +7,6 @@ on:
paths:
- ".github/workflows/mobile_ci.yaml"
- "frontend/**"
- "!frontend/appflowy_tauri/**"
pull_request:
branches:

View File

@ -7,7 +7,6 @@ on:
paths:
- ".github/workflows/mobile_ci.yaml"
- "frontend/**"
- "!frontend/appflowy_tauri/**"
- "!frontend/appflowy_web_app/**"
pull_request:
@ -16,7 +15,6 @@ on:
paths:
- ".github/workflows/mobile_ci.yaml"
- "frontend/**"
- "!frontend/appflowy_tauri/**"
- "!frontend/appflowy_web_app/**"
env:

View File

@ -121,20 +121,5 @@
// "request": "launch",
// "program": "[YOUR_APPLICATION_PATH]",
},
{
// https://tauri.app/v1/guides/debugging/vs-code
"type": "lldb",
"request": "launch",
"name": "AF-tauri: Debug backend",
"cargo": {
"args": [
"build",
"--manifest-path=./appflowy_tauri/src-tauri/Cargo.toml",
"--no-default-features"
]
},
"preLaunchTask": "AF: Tauri UI Dev",
"cwd": "${workspaceRoot}/appflowy_tauri/"
},
]
}

View File

@ -245,51 +245,6 @@
"problemMatcher": [],
"detail": "appflowy_flutter"
},
{
"label": "AF: Tauri UI Build",
"type": "shell",
"command": "pnpm run build",
"options": {
"cwd": "${workspaceFolder}/appflowy_tauri"
}
},
{
"label": "AF: Tauri UI Dev",
"type": "shell",
"isBackground": true,
"command": "pnpm sync:i18n && pnpm run dev",
"options": {
"cwd": "${workspaceFolder}/appflowy_tauri"
}
},
{
"label": "AF: Tauri Clean",
"type": "shell",
"command": "cargo make tauri_clean",
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "AF: Tauri Clean + Dev",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"AF: Tauri Clean",
"AF: Tauri UI Dev"
],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "AF: Tauri ESLint",
"type": "shell",
"command": "npx eslint --fix src",
"options": {
"cwd": "${workspaceFolder}/appflowy_tauri"
}
},
{
"label": "AF: Generate Env File",
"type": "shell",

View File

@ -1,7 +0,0 @@
src/services
src/styles
node_modules/
dist/
src-tauri/
.eslintrc.cjs
tsconfig.json

View File

@ -1,73 +0,0 @@
module.exports = {
// https://eslint.org/docs/latest/use/configure/configuration-files
env: {
browser: true,
es6: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
tsconfigRootDir: __dirname,
extraFileExtensions: ['.json'],
},
plugins: ['@typescript-eslint', "react-hooks"],
rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/unified-signatures': 'error',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'off',
'constructor-super': 'error',
eqeqeq: ['error', 'always'],
'no-cond-assign': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-empty': [
'error',
{
allowEmptyCatch: true,
},
],
'no-invalid-this': 'error',
'no-new-wrappers': 'error',
'no-param-reassign': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-unsafe-finally': 'error',
'no-unused-labels': 'error',
'no-var': 'error',
'no-void': 'off',
'prefer-const': 'error',
'prefer-spread': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
}
],
'padding-line-between-statements': [
"error",
{ blankLine: "always", prev: ["const", "let", "var"], next: "*"},
{ blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]},
{ blankLine: "always", prev: "import", next: "*" },
{ blankLine: "any", prev: "import", next: "import" },
{ blankLine: "always", prev: "block-like", next: "*" },
{ blankLine: "always", prev: "block", next: "*" },
]
},
ignorePatterns: ['src/**/*.test.ts', '**/__tests__/**/*.json', 'package.json']
};

View File

@ -1,33 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
**/src/services/backend/models/
**/src/services/backend/events/
**/src/appflowy_app/i18n/translations/
coverage
**/AppFlowy-Collab
.env

View File

@ -1,19 +0,0 @@
.DS_Store
node_modules
/build
/public
/.svelte-kit
/package
/.vscode
.env
.env.*
!.env.example
# rust and generated ts code
/src-tauri
/src/services
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@ -1,20 +0,0 @@
module.exports = {
arrowParens: 'always',
bracketSpacing: true,
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
jsxBracketSameLine: false,
jsxSingleQuote: true,
printWidth: 121,
plugins: [require('prettier-plugin-tailwindcss')],
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
vueIndentScriptAndStyle: false,
};

View File

@ -1,3 +0,0 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}

View File

@ -1,7 +0,0 @@
# Tauri + React + Typescript
This template should help get you started developing with Tauri, React and Typescript in Vite.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AppFlowy: The Open Source Alternative To Notion</title>
</head>
<body id="body">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@ -1,21 +0,0 @@
const { compilerOptions } = require('./tsconfig.json');
const { pathsToModuleNameMapper } = require("ts-jest");
const esModules = ["lodash-es", "nanoid"].join("|");
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths),
"^lodash-es(/(.*)|$)": "lodash$1",
"^nanoid(/(.*)|$)": "nanoid$1",
},
"transform": {
"(.*)/node_modules/nanoid/.+\\.(j|t)sx?$": "ts-jest"
},
"transformIgnorePatterns": [`/node_modules/(?!${esModules})`],
"testRegex": "(/__tests__/.*\.(test|spec))\\.(jsx?|tsx?)$",
};

View File

@ -1,126 +0,0 @@
{
"name": "appflowy_tauri",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "pnpm sync:i18n && tsc && vite build",
"preview": "vite preview",
"format": "prettier --write .",
"test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .",
"test:errors": "pnpm sync:i18n && tsc --noEmit && eslint --ext .js,.ts,.tsx .",
"test:prettier": "pnpm prettier --list-different src",
"tauri:clean": "cargo make --cwd .. tauri_clean",
"tauri:dev": "pnpm sync:i18n && tauri dev",
"sync:i18n": "node scripts/i18n/index.cjs",
"css:variables": "node style-dictionary/config.cjs",
"test": "jest"
},
"dependencies": {
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.12",
"@mui/system": "^5.14.4",
"@mui/x-date-pickers-pro": "^6.18.2",
"@reduxjs/toolkit": "2.0.0",
"@slate-yjs/core": "^1.0.2",
"@tauri-apps/api": "^1.2.0",
"@types/react-swipeable-views": "^0.13.4",
"dayjs": "^1.11.9",
"emoji-mart": "^5.5.2",
"emoji-regex": "^10.2.1",
"events": "^3.3.0",
"google-protobuf": "^3.15.12",
"i18next": "^22.4.10",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-resources-to-backend": "^1.1.4",
"is-hotkey": "^0.2.0",
"jest": "^29.5.0",
"js-base64": "^3.7.5",
"katex": "^0.16.7",
"lodash-es": "^4.17.21",
"nanoid": "^4.0.0",
"prismjs": "^1.29.0",
"protoc-gen-ts": "0.8.7",
"quill": "^1.3.7",
"quill-delta": "^5.1.0",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
"react-big-calendar": "^1.8.5",
"react-color": "^2.19.3",
"react-custom-scrollbars": "^4.2.1",
"react-datepicker": "^4.23.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^3.1.4",
"react-hot-toast": "^2.4.1",
"react-i18next": "^12.2.0",
"react-katex": "^3.0.1",
"react-redux": "^8.0.5",
"react-router-dom": "^6.8.0",
"react-swipeable-views": "^0.14.0",
"react-transition-group": "^4.4.5",
"react-virtualized-auto-sizer": "^1.0.20",
"react-vtree": "^2.0.4",
"react-window": "^1.8.10",
"react18-input-otp": "^1.1.2",
"redux": "^4.2.1",
"rxjs": "^7.8.0",
"sass": "^1.70.0",
"slate": "^0.101.4",
"slate-history": "^0.100.0",
"slate-react": "^0.101.3",
"ts-results": "^3.3.0",
"unsplash-js": "^7.0.19",
"utf8": "^3.0.0",
"valtio": "^1.12.1",
"yjs": "^13.5.51"
},
"devDependencies": {
"@svgr/plugin-svgo": "^8.0.1",
"@tauri-apps/cli": "^1.5.6",
"@types/google-protobuf": "^3.15.12",
"@types/is-hotkey": "^0.1.7",
"@types/jest": "^29.5.3",
"@types/katex": "^0.16.0",
"@types/lodash-es": "^4.17.11",
"@types/node": "^18.7.10",
"@types/prismjs": "^1.26.0",
"@types/quill": "^2.0.10",
"@types/react": "^18.0.15",
"@types/react-beautiful-dnd": "^13.1.3",
"@types/react-color": "^3.0.6",
"@types/react-custom-scrollbars": "^4.0.13",
"@types/react-datepicker": "^4.19.3",
"@types/react-dom": "^18.0.6",
"@types/react-katex": "^3.0.0",
"@types/react-transition-group": "^4.4.6",
"@types/react-window": "^1.8.8",
"@types/utf8": "^3.0.1",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@vitejs/plugin-react": "^3.0.0",
"autoprefixer": "^10.4.13",
"babel-jest": "^29.6.2",
"eslint": "^8.34.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"jest-environment-jsdom": "^29.6.2",
"postcss": "^8.4.21",
"prettier": "2.8.4",
"prettier-plugin-tailwindcss": "^0.2.2",
"style-dictionary": "^3.8.0",
"tailwindcss": "^3.2.7",
"ts-jest": "^29.1.1",
"ts-node-dev": "^2.0.0",
"tsconfig-paths-jest": "^0.0.1",
"typescript": "^4.6.4",
"uuid": "^9.0.0",
"vite": "^4.0.0",
"vite-plugin-svgr": "^3.2.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

View File

@ -1,93 +0,0 @@
Copyright 2020 The Poppins Project Authors (https://github.com/itfoundry/Poppins)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -1,6 +0,0 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,63 +0,0 @@
const languages = [
'ar-SA',
'ca-ES',
'de-DE',
'en',
'es-VE',
'eu-ES',
'fr-FR',
'hu-HU',
'id-ID',
'it-IT',
'ja-JP',
'ko-KR',
'pl-PL',
'pt-BR',
'pt-PT',
'ru-RU',
'sv-SE',
'th-TH',
'tr-TR',
'zh-CN',
'zh-TW',
];
const fs = require('fs');
languages.forEach(language => {
const json = require(`../../../resources/translations/${language}.json`);
const outputJSON = flattenJSON(json);
const output = JSON.stringify(outputJSON);
const isExistDir = fs.existsSync('./src/appflowy_app/i18n/translations');
if (!isExistDir) {
fs.mkdirSync('./src/appflowy_app/i18n/translations');
}
fs.writeFile(`./src/appflowy_app/i18n/translations/${language}.json`, new Uint8Array(Buffer.from(output)), (res) => {
if (res) {
console.error(res);
}
})
});
function flattenJSON(obj, prefix = '') {
let result = {};
const pluralsKey = ["one", "other", "few", "many", "two", "zero"];
for (let key in obj) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
const nestedKeys = flattenJSON(obj[key], `${prefix}${key}.`);
result = { ...result, ...nestedKeys };
} else {
let newKey = `${prefix}${key}`;
let replaceChar = '{'
if (pluralsKey.includes(key)) {
newKey = `${prefix.slice(0, -1)}_${key}`;
}
result[newKey] = obj[key].replaceAll('{', '{{').replaceAll('}', '}}');
}
}
return result;
}

View File

@ -1,31 +0,0 @@
const fs = require('fs');
const path = require('path');
if (process.argv.length < 3) {
console.error('Usage: node update-tauri-version.js <version>');
process.exit(1);
}
const newVersion = process.argv[2];
const tauriConfigPath = path.join(__dirname, '../src-tauri', 'tauri.conf.json');
fs.readFile(tauriConfigPath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading tauri.conf.json:', err);
return;
}
const config = JSON.parse(data);
config.package.version = newVersion;
fs.writeFile(tauriConfigPath, JSON.stringify(config, null, 2), 'utf8', (err) => {
if (err) {
console.error('Error writing tauri.conf.json:', err);
return;
}
console.log(`Tauri version updated to ${newVersion} successfully.`);
});
});

View File

@ -1,2 +0,0 @@
[build]
rustflags = ["--cfg", "tokio_unstable"]

View File

@ -1,4 +0,0 @@
# Generated by Cargo
# will have compiled files and executables
/target/
.env

File diff suppressed because it is too large Load Diff

View File

@ -1,137 +0,0 @@
[package]
name = "appflowy_tauri"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.57"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.5", features = [] }
[workspace.dependencies]
anyhow = "1.0"
tracing = "0.1.40"
bytes = "1.5.0"
serde = "1.0"
serde_json = "1.0.108"
protobuf.workspace = true
diesel = { version = "2.1.0", features = [
"sqlite",
"chrono",
"r2d2",
"serde_json",
] }
uuid = { version = "1.5.0", features = ["serde", "v4"] }
serde_repr = "0.1"
parking_lot = "0.12"
futures = "0.3.29"
tokio = "1.34.0"
tokio-stream = "0.1.14"
async-trait = "0.1.74"
chrono = { version = "0.4.31", default-features = false, features = ["clock"] }
zip = "2.2.0"
yrs = "0.19.1"
# Please use the following script to update collab.
# Working directory: frontend
#
# To update the commit ID, run:
# scripts/tool/update_collab_rev.sh new_rev_id
#
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { version = "0.2" }
collab-entity = { version = "0.2" }
collab-folder = { version = "0.2" }
collab-document = { version = "0.2" }
collab-database = { version = "0.2" }
collab-plugins = { version = "0.2" }
collab-user = { version = "0.2" }
collab-importer = { version = "0.1" }
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "ea131f0baab67defe7591067357eced490072372" }
[dependencies]
serde_json.workspace = true
serde.workspace = true
tauri = { version = "1.5", features = [
"dialog-all",
"clipboard-all",
"fs-all",
"shell-open",
] }
tauri-utils = "1.5.2"
bytes.workspace = true
tracing.workspace = true
lib-dispatch = { path = "../../rust-lib/lib-dispatch", features = [
"use_serde",
] }
flowy-core = { path = "../../rust-lib/flowy-core", features = ["ts"] }
flowy-user = { path = "../../rust-lib/flowy-user", features = ["tauri_ts"] }
flowy-date = { path = "../../rust-lib/flowy-date", features = ["tauri_ts"] }
flowy-ai = { path = "../../rust-lib/flowy-ai", features = ["tauri_ts"] }
flowy-error = { path = "../../rust-lib/flowy-error", features = [
"impl_from_sqlite",
"impl_from_dispatch_error",
"impl_from_appflowy_cloud",
"impl_from_reqwest",
"impl_from_serde",
"tauri_ts",
] }
flowy-search = { path = "../../rust-lib/flowy-search", features = ["tauri_ts"] }
flowy-document = { path = "../../rust-lib/flowy-document", features = [
"tauri_ts",
] }
flowy-notification = { path = "../../rust-lib/flowy-notification", features = [
"tauri_ts",
] }
uuid = "1.5.0"
tauri-plugin-deep-link = "0.1.2"
dotenv = "0.15.0"
semver = "1.0.23"
[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = ["custom-protocol"]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]
[patch.crates-io]
# Please use the following script to update collab.
# Working directory: frontend
#
# To update the commit ID, run:
# scripts/tool/update_collab_rev.sh new_rev_id
#
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "67b31e4bcc64d81332c37efecb0a8618681f1db9" }
# Working directory: frontend
# To update the commit ID, run:
# scripts/tool/update_local_ai_rev.sh new_rev_id
# ⚠️⚠️⚠️️
appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }
appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }

View File

@ -1,19 +0,0 @@
<!-- Add this file next to your tauri.conf.json file -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<!-- Obviously needs to be replaced with your app's bundle identifier -->
<string>appflowy-flutter</string>
<key>CFBundleURLSchemes</key>
<array>
<string>appflowy-flutter</string>
</array>
</dict>
</array>
</dict>
</plist>

View File

@ -1,3 +0,0 @@
fn main() {
tauri_build::build()
}

View File

@ -1,4 +0,0 @@
APPFLOWY_CLOUD_ENV_APPFLOWY_CLOUD_BASE_URL=https://test.appflowy.cloud
APPFLOWY_CLOUD_ENV_APPFLOWY_CLOUD_WS_BASE_URL=wss://test.appflowy.cloud/ws/v1
APPFLOWY_CLOUD_ENV_APPFLOWY_CLOUD_GOTRUE_URL=https://test.appflowy.cloud/gotrue
APPFLOWY_CLOUD_ENV_CLOUD_TYPE=2

View File

@ -1,4 +0,0 @@
APPFLOWY_CLOUD_ENV_APPFLOWY_CLOUD_BASE_URL=https://beta.appflowy.cloud
APPFLOWY_CLOUD_ENV_APPFLOWY_CLOUD_WS_BASE_URL=wss://beta.appflowy.cloud/ws/v1
APPFLOWY_CLOUD_ENV_APPFLOWY_CLOUD_GOTRUE_URL=https://beta.appflowy.cloud/gotrue
APPFLOWY_CLOUD_ENV_CLOUD_TYPE=2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

View File

@ -1,2 +0,0 @@
[toolchain]
channel = "1.77.2"

View File

@ -1,12 +0,0 @@
# https://rust-lang.github.io/rustfmt/?version=master&search=
max_width = 100
tab_spaces = 2
newline_style = "Auto"
match_block_trailing_comma = true
use_field_init_shorthand = true
use_try_shorthand = true
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
merge_derives = true
edition = "2021"

View File

@ -1,78 +0,0 @@
use dotenv::dotenv;
use flowy_core::config::AppFlowyCoreConfig;
use flowy_core::{AppFlowyCore, DEFAULT_NAME};
use lib_dispatch::runtime::AFPluginRuntime;
use std::sync::Mutex;
pub fn read_env() {
dotenv().ok();
let env = if cfg!(debug_assertions) {
include_str!("../env.development")
} else {
include_str!("../env.production")
};
for line in env.lines() {
if let Some((key, value)) = line.split_once('=') {
// Check if the environment variable is not already set in the system
let current_value = std::env::var(key).unwrap_or_default();
if current_value.is_empty() {
std::env::set_var(key, value);
}
}
}
}
pub(crate) fn init_appflowy_core() -> MutexAppFlowyCore {
let config_json = include_str!("../tauri.conf.json");
let config: tauri_utils::config::Config = serde_json::from_str(config_json).unwrap();
let app_version = config
.package
.version
.clone()
.map(|v| v.to_string())
.unwrap_or_else(|| "0.5.8".to_string());
let app_version =
semver::Version::parse(&app_version).unwrap_or_else(|_| semver::Version::new(0, 5, 8));
let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap();
if cfg!(debug_assertions) {
data_path.push("data_dev");
} else {
data_path.push("data");
}
let custom_application_path = data_path.to_str().unwrap().to_string();
let application_path = data_path.to_str().unwrap().to_string();
let device_id = uuid::Uuid::new_v4().to_string();
read_env();
std::env::set_var("RUST_LOG", "trace");
let config = AppFlowyCoreConfig::new(
app_version,
custom_application_path,
application_path,
device_id,
"tauri".to_string(),
DEFAULT_NAME.to_string(),
)
.log_filter("trace", vec!["appflowy_tauri".to_string()]);
let runtime = Arc::new(AFPluginRuntime::new().unwrap());
let cloned_runtime = runtime.clone();
runtime.block_on(async move {
MutexAppFlowyCore::new(AppFlowyCore::new(config, cloned_runtime, None).await)
})
}
pub struct MutexAppFlowyCore(pub Arc<Mutex<AppFlowyCore>>);
impl MutexAppFlowyCore {
fn new(appflowy_core: AppFlowyCore) -> Self {
Self(Arc::new(Mutex::new(appflowy_core)))
}
}
unsafe impl Sync for MutexAppFlowyCore {}
unsafe impl Send for MutexAppFlowyCore {}

View File

@ -1,72 +0,0 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
#[allow(dead_code)]
pub const DEEP_LINK_SCHEME: &str = "appflowy-flutter";
pub const OPEN_DEEP_LINK: &str = "open_deep_link";
mod init;
mod notification;
mod request;
use crate::init::init_appflowy_core;
use crate::request::invoke_request;
use flowy_notification::{register_notification_sender, unregister_all_notification_sender};
use notification::*;
use tauri::Manager;
extern crate dotenv;
fn main() {
tauri_plugin_deep_link::prepare(DEEP_LINK_SCHEME);
let flowy_core = init_appflowy_core();
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![invoke_request])
.manage(flowy_core)
.on_window_event(|_window_event| {})
.on_menu_event(|_menu| {})
.on_page_load(|window, _payload| {
let app_handler = window.app_handle();
// Make sure hot reload won't register the notification sender twice
unregister_all_notification_sender();
register_notification_sender(TSNotificationSender::new(app_handler.clone()));
// tauri::async_runtime::spawn(async move {});
window.listen_global(AF_EVENT, move |event| {
on_event(app_handler.clone(), event);
});
})
.setup(|_app| {
let splashscreen_window = _app.get_window("splashscreen").unwrap();
let window = _app.get_window("main").unwrap();
let handle = _app.handle();
// we perform the initialization code on a new task so the app doesn't freeze
tauri::async_runtime::spawn(async move {
// initialize your app here instead of sleeping :)
std::thread::sleep(std::time::Duration::from_secs(2));
// After it's done, close the splashscreen and display the main window
splashscreen_window.close().unwrap();
window.show().unwrap();
// If you need macOS support this must be called in .setup() !
// Otherwise this could be called right after prepare() but then you don't have access to tauri APIs
// On macOS You still have to install a .app bundle you got from tauri build --debug for this to work!
tauri_plugin_deep_link::register(
DEEP_LINK_SCHEME,
move |request| {
dbg!(&request);
handle.emit_all(OPEN_DEEP_LINK, request).unwrap();
},
)
.unwrap(/* If listening to the scheme is optional for your app, you don't want to unwrap here. */);
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -1,35 +0,0 @@
use flowy_notification::entities::SubscribeObject;
use flowy_notification::NotificationSender;
use serde::Serialize;
use tauri::{AppHandle, Event, Manager, Wry};
#[allow(dead_code)]
pub const AF_EVENT: &str = "af-event";
pub const AF_NOTIFICATION: &str = "af-notification";
#[tracing::instrument(level = "trace")]
pub fn on_event(app_handler: AppHandle<Wry>, event: Event) {}
#[allow(dead_code)]
pub fn send_notification<P: Serialize + Clone>(app_handler: AppHandle<Wry>, payload: P) {
app_handler.emit_all(AF_NOTIFICATION, payload).unwrap();
}
pub struct TSNotificationSender {
handler: AppHandle<Wry>,
}
impl TSNotificationSender {
pub fn new(handler: AppHandle<Wry>) -> Self {
Self { handler }
}
}
impl NotificationSender for TSNotificationSender {
fn send_subject(&self, subject: SubscribeObject) -> Result<(), String> {
self
.handler
.emit_all(AF_NOTIFICATION, subject)
.map_err(|e| format!("{:?}", e))
}
}

View File

@ -1,45 +0,0 @@
use crate::init::MutexAppFlowyCore;
use lib_dispatch::prelude::{
AFPluginDispatcher, AFPluginEventResponse, AFPluginRequest, StatusCode,
};
use tauri::{AppHandle, Manager, State, Wry};
#[derive(Clone, Debug, serde::Deserialize)]
pub struct AFTauriRequest {
ty: String,
payload: Vec<u8>,
}
impl std::convert::From<AFTauriRequest> for AFPluginRequest {
fn from(event: AFTauriRequest) -> Self {
AFPluginRequest::new(event.ty).payload(event.payload)
}
}
#[derive(Clone, serde::Serialize)]
pub struct AFTauriResponse {
code: StatusCode,
payload: Vec<u8>,
}
impl std::convert::From<AFPluginEventResponse> for AFTauriResponse {
fn from(response: AFPluginEventResponse) -> Self {
Self {
code: response.status_code,
payload: response.payload.to_vec(),
}
}
}
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
pub async fn invoke_request(
request: AFTauriRequest,
app_handler: AppHandle<Wry>,
) -> AFTauriResponse {
let request: AFPluginRequest = request.into();
let state: State<MutexAppFlowyCore> = app_handler.state();
let dispatcher = state.0.lock().unwrap().dispatcher();
let response = AFPluginDispatcher::sync_send(dispatcher, request);
response.into()
}

View File

@ -1,113 +0,0 @@
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "pnpm run build",
"devPath": "http://localhost:1420",
"distDir": "../dist",
"withGlobalTauri": false
},
"package": {
"productName": "AppFlowy",
"version": "0.0.1"
},
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
},
"fs": {
"all": true,
"scope": [
"$APPLOCALDATA/**"
],
"readFile": true,
"writeFile": true,
"readDir": true,
"copyFile": true,
"createDir": true,
"removeDir": true,
"removeFile": true,
"renameFile": true,
"exists": true
},
"clipboard": {
"all": true,
"writeText": true,
"readText": true
},
"dialog": {
"all": true,
"ask": true,
"confirm": true,
"message": true,
"open": true,
"save": true
}
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"deb": {
"depends": []
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "com.appflowy.tauri",
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null,
"minimumSystemVersion": "10.15.0"
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"fileDropEnabled": false,
"fullscreen": false,
"height": 800,
"resizable": true,
"title": "AppFlowy",
"width": 1200,
"minWidth": 800,
"minHeight": 600,
"visible": false,
"label": "main"
},
{
"height": 300,
"width": 549,
"decorations": false,
"url": "launch_splash.jpg",
"label": "splashscreen",
"center": true,
"visible": true
}
]
}
}

View File

@ -1,8 +0,0 @@
import resources from './resources';
declare module 'i18next' {
interface CustomTypeOptions {
defaultNS: 'translation';
resources: typeof resources;
}
}

View File

@ -1,7 +0,0 @@
import translation from '$app/i18n/translations/en.json';
const resources = {
translation,
} as const;
export default resources;

View File

@ -1,25 +0,0 @@
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { store } from './stores/store';
import { ErrorHandlerPage } from './components/error/ErrorHandlerPage';
import '$app/i18n/config';
import { ErrorBoundary } from 'react-error-boundary';
import AppMain from '$app/AppMain';
const App = () => {
return (
<BrowserRouter>
<Provider store={store}>
<ErrorBoundary FallbackComponent={ErrorHandlerPage}>
<AppMain />
</ErrorBoundary>
</Provider>
</BrowserRouter>
);
};
export default App;

View File

@ -1,69 +0,0 @@
import { useAppDispatch, useAppSelector } from '$app/stores/store';
import { useEffect, useMemo } from 'react';
import { currentUserActions, LoginState } from '$app_reducers/current-user/slice';
import { Theme as ThemeType, ThemeMode } from '$app/stores/reducers/current-user/slice';
import { createTheme } from '@mui/material/styles';
import { getDesignTokens } from '$app/utils/mui';
import { useTranslation } from 'react-i18next';
import { UserService } from '$app/application/user/user.service';
export function useUserSetting() {
const dispatch = useAppDispatch();
const { i18n } = useTranslation();
const loginState = useAppSelector((state) => state.currentUser.loginState);
const { themeMode = ThemeMode.System, theme: themeType = ThemeType.Default } = useAppSelector((state) => {
return {
themeMode: state.currentUser.userSetting.themeMode,
theme: state.currentUser.userSetting.theme,
};
});
const isDark =
themeMode === ThemeMode.Dark ||
(themeMode === ThemeMode.System && window.matchMedia('(prefers-color-scheme: dark)').matches);
useEffect(() => {
if (loginState !== LoginState.Success && loginState !== undefined) return;
void (async () => {
const settings = await UserService.getAppearanceSetting();
if (!settings) return;
dispatch(currentUserActions.setUserSetting(settings));
await i18n.changeLanguage(settings.language);
})();
}, [dispatch, i18n, loginState]);
useEffect(() => {
const html = document.documentElement;
html?.setAttribute('data-dark-mode', String(isDark));
}, [isDark]);
useEffect(() => {
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
const handleSystemThemeChange = () => {
if (themeMode !== ThemeMode.System) return;
dispatch(
currentUserActions.setUserSetting({
isDark: mediaQuery.matches,
})
);
};
mediaQuery.addEventListener('change', handleSystemThemeChange);
return () => {
mediaQuery.removeEventListener('change', handleSystemThemeChange);
};
}, [dispatch, themeMode]);
const muiTheme = useMemo(() => createTheme(getDesignTokens(isDark)), [isDark]);
return {
muiTheme,
themeMode,
themeType,
};
}

View File

@ -1,31 +0,0 @@
import React from 'react';
import { Route, Routes } from 'react-router-dom';
import { ProtectedRoutes } from '$app/components/auth/ProtectedRoutes';
import { DatabasePage } from '$app/views/DatabasePage';
import { ThemeProvider } from '@mui/material';
import { useUserSetting } from '$app/AppMain.hooks';
import TrashPage from '$app/views/TrashPage';
import DocumentPage from '$app/views/DocumentPage';
import { Toaster } from 'react-hot-toast';
import AppFlowyDevTool from '$app/components/_shared/devtool/AppFlowyDevTool';
function AppMain() {
const { muiTheme } = useUserSetting();
return (
<ThemeProvider theme={muiTheme}>
<Routes>
<Route path={'/'} element={<ProtectedRoutes />}>
<Route path={'/page/document/:id'} element={<DocumentPage />} />
<Route path={'/page/grid/:id'} element={<DatabasePage />} />
<Route path={'/trash'} id={'trash'} element={<TrashPage />} />
</Route>
</Routes>
<Toaster />
{process.env.NODE_ENV === 'development' && <AppFlowyDevTool />}
</ThemeProvider>
);
}
export default AppMain;

View File

@ -1,48 +0,0 @@
import { Database } from '$app/application/database';
import { getCell } from './cell_service';
export function didDeleteCells({ database, rowId, fieldId }: { database: Database; rowId?: string; fieldId?: string }) {
const ids = Object.keys(database.cells);
ids.forEach((id) => {
const cell = database.cells[id];
if (rowId && cell.rowId !== rowId) return;
if (fieldId && cell.fieldId !== fieldId) return;
delete database.cells[id];
});
}
export async function didUpdateCells({
viewId,
database,
rowId,
fieldId,
}: {
viewId: string;
database: Database;
rowId?: string;
fieldId?: string;
}) {
const field = database.fields.find((field) => field.id === fieldId);
if (!field) {
delete database.cells[`${rowId}:${fieldId}`];
return;
}
const ids = Object.keys(database.cells);
ids.forEach((id) => {
const cell = database.cells[id];
if (rowId && cell.rowId !== rowId) return;
if (fieldId && cell.fieldId !== fieldId) return;
void getCell(viewId, cell.rowId, cell.fieldId, field.type).then((data) => {
// cache cell
database.cells[id] = data;
});
});
}

View File

@ -1,140 +0,0 @@
import {
CellIdPB,
CellChangesetPB,
SelectOptionCellChangesetPB,
ChecklistCellDataChangesetPB,
DateCellChangesetPB,
FieldType,
} from '../../../../services/backend';
import {
DatabaseEventGetCell,
DatabaseEventUpdateCell,
DatabaseEventUpdateSelectOptionCell,
DatabaseEventUpdateChecklistCell,
DatabaseEventUpdateDateCell,
} from '@/services/backend/events/flowy-database2';
import { SelectOption } from '../field';
import { Cell, pbToCell } from './cell_types';
export async function getCell(viewId: string, rowId: string, fieldId: string, fieldType?: FieldType): Promise<Cell> {
const payload = CellIdPB.fromObject({
view_id: viewId,
row_id: rowId,
field_id: fieldId,
});
const result = await DatabaseEventGetCell(payload);
if (result.ok === false) {
return Promise.reject(result.val);
}
const value = result.val;
return pbToCell(value, fieldType);
}
export async function updateCell(viewId: string, rowId: string, fieldId: string, changeset: string): Promise<void> {
const payload = CellChangesetPB.fromObject({
view_id: viewId,
row_id: rowId,
field_id: fieldId,
cell_changeset: changeset,
});
const result = await DatabaseEventUpdateCell(payload);
return result.unwrap();
}
export async function updateSelectCell(
viewId: string,
rowId: string,
fieldId: string,
data: {
insertOptionIds?: string[];
deleteOptionIds?: string[];
}
): Promise<void> {
const payload = SelectOptionCellChangesetPB.fromObject({
cell_identifier: {
view_id: viewId,
row_id: rowId,
field_id: fieldId,
},
insert_option_ids: data.insertOptionIds,
delete_option_ids: data.deleteOptionIds,
});
const result = await DatabaseEventUpdateSelectOptionCell(payload);
return result.unwrap();
}
export async function updateChecklistCell(
viewId: string,
rowId: string,
fieldId: string,
data: {
insertOptions?: string[];
selectedOptionIds?: string[];
deleteOptionIds?: string[];
updateOptions?: Partial<SelectOption>[];
}
): Promise<void> {
const payload = ChecklistCellDataChangesetPB.fromObject({
view_id: viewId,
row_id: rowId,
field_id: fieldId,
insert_options: data.insertOptions,
selected_option_ids: data.selectedOptionIds,
delete_option_ids: data.deleteOptionIds,
update_options: data.updateOptions,
});
const result = await DatabaseEventUpdateChecklistCell(payload);
return result.unwrap();
}
export async function updateDateCell(
viewId: string,
rowId: string,
fieldId: string,
data: {
// 10-digit timestamp
date?: number;
// time string in format HH:mm
time?: string;
// 10-digit timestamp
endDate?: number;
// time string in format HH:mm
endTime?: string;
includeTime?: boolean;
clearFlag?: boolean;
isRange?: boolean;
}
): Promise<void> {
const payload = DateCellChangesetPB.fromObject({
cell_id: {
view_id: viewId,
row_id: rowId,
field_id: fieldId,
},
date: data.date,
time: data.time,
include_time: data.includeTime,
clear_flag: data.clearFlag,
end_date: data.endDate,
end_time: data.endTime,
is_range: data.isRange,
});
const result = await DatabaseEventUpdateDateCell(payload);
if (!result.ok) {
return Promise.reject(typeof result.val.msg === 'string' ? result.val.msg : 'Unknown error');
}
return result.val;
}

View File

@ -1,163 +0,0 @@
import {
CellPB,
CheckboxCellDataPB,
ChecklistCellDataPB,
DateCellDataPB,
FieldType,
SelectOptionCellDataPB,
TimestampCellDataPB,
URLCellDataPB,
} from '../../../../services/backend';
import { SelectOption, pbToSelectOption } from '../field/select_option/select_option_types';
export interface Cell {
rowId: string;
fieldId: string;
fieldType: FieldType;
data: unknown;
}
export interface TextCell extends Cell {
fieldType: FieldType.RichText;
data: string;
}
export interface NumberCell extends Cell {
fieldType: FieldType.Number;
data: string;
}
export interface CheckboxCell extends Cell {
fieldType: FieldType.Checkbox;
data: boolean;
}
export interface UrlCell extends Cell {
fieldType: FieldType.URL;
data: string;
}
export interface SelectCell extends Cell {
fieldType: FieldType.SingleSelect | FieldType.MultiSelect;
data: SelectCellData;
}
export interface SelectCellData {
selectedOptionIds?: string[];
}
export interface DateTimeCell extends Cell {
fieldType: FieldType.DateTime;
data: DateTimeCellData;
}
export interface TimeStampCell extends Cell {
fieldType: FieldType.LastEditedTime | FieldType.CreatedTime;
data: TimestampCellData;
}
export interface DateTimeCellData {
date?: string;
time?: string;
timestamp?: number;
includeTime?: boolean;
endDate?: string;
endTime?: string;
endTimestamp?: number;
isRange?: boolean;
}
export interface TimestampCellData {
dataTime?: string;
timestamp?: number;
}
export interface ChecklistCell extends Cell {
fieldType: FieldType.Checklist;
data: ChecklistCellData;
}
export interface ChecklistCellData {
/**
* link to [SelectOption's id property]{@link SelectOption#id}.
*/
selectedOptions?: string[];
percentage?: number;
options?: SelectOption[];
}
export type UndeterminedCell =
| TextCell
| NumberCell
| DateTimeCell
| SelectCell
| CheckboxCell
| UrlCell
| ChecklistCell;
const pbToCheckboxCellData = (pb: CheckboxCellDataPB): boolean => (
pb.is_checked
);
const pbToDateTimeCellData = (pb: DateCellDataPB): DateTimeCellData => ({
date: pb.date,
time: pb.time,
timestamp: pb.timestamp,
includeTime: pb.include_time,
endDate: pb.end_date,
endTime: pb.end_time,
endTimestamp: pb.end_timestamp,
isRange: pb.is_range,
});
const pbToTimestampCellData = (pb: TimestampCellDataPB): TimestampCellData => ({
dataTime: pb.date_time,
timestamp: pb.timestamp,
});
export const pbToSelectCellData = (pb: SelectOptionCellDataPB): SelectCellData => {
return {
selectedOptionIds: pb.select_options.map((option) => option.id),
};
};
const pbToURLCellData = (pb: URLCellDataPB): string => (
pb.content
);
export const pbToChecklistCellData = (pb: ChecklistCellDataPB): ChecklistCellData => ({
selectedOptions: pb.selected_options.map(({ id }) => id),
percentage: pb.percentage,
options: pb.options.map(pbToSelectOption),
});
function bytesToCellData(bytes: Uint8Array, fieldType: FieldType) {
switch (fieldType) {
case FieldType.RichText:
case FieldType.Number:
return new TextDecoder().decode(bytes);
case FieldType.Checkbox:
return pbToCheckboxCellData(CheckboxCellDataPB.deserialize(bytes));
case FieldType.DateTime:
return pbToDateTimeCellData(DateCellDataPB.deserialize(bytes));
case FieldType.LastEditedTime:
case FieldType.CreatedTime:
return pbToTimestampCellData(TimestampCellDataPB.deserialize(bytes));
case FieldType.SingleSelect:
case FieldType.MultiSelect:
return pbToSelectCellData(SelectOptionCellDataPB.deserialize(bytes));
case FieldType.URL:
return pbToURLCellData(URLCellDataPB.deserialize(bytes));
case FieldType.Checklist:
return pbToChecklistCellData(ChecklistCellDataPB.deserialize(bytes));
}
}
export const pbToCell = (pb: CellPB, fieldType: FieldType = pb.field_type): Cell => {
return {
rowId: pb.row_id,
fieldId: pb.field_id,
fieldType: fieldType,
data: bytesToCellData(pb.data, fieldType),
};
};

View File

@ -1,3 +0,0 @@
export * from './cell_types';
export * as cellService from './cell_service';
export * as cellListeners from './cell_listeners';

View File

@ -1,84 +0,0 @@
import { DatabaseViewIdPB } from '@/services/backend';
import {
DatabaseEventGetDatabase,
DatabaseEventGetDatabaseId,
DatabaseEventGetDatabaseSetting,
} from '@/services/backend/events/flowy-database2';
import { fieldService } from '../field';
import { pbToFilter } from '../filter';
import { groupService, pbToGroupSetting } from '../group';
import { pbToRowMeta } from '../row';
import { pbToSort } from '../sort';
import { Database } from './database_types';
export async function getDatabaseId(viewId: string): Promise<string> {
const payload = DatabaseViewIdPB.fromObject({ value: viewId });
const result = await DatabaseEventGetDatabaseId(payload);
return result.map((value) => value.value).unwrap();
}
export async function getDatabase(viewId: string) {
const payload = DatabaseViewIdPB.fromObject({
value: viewId,
});
const result = await DatabaseEventGetDatabase(payload);
if (!result.ok) return Promise.reject('Failed to get database');
return result
.map((value) => {
return {
id: value.id,
isLinked: value.is_linked,
layoutType: value.layout_type,
fieldIds: value.fields.map((field) => field.field_id),
rowMetas: value.rows.map(pbToRowMeta),
};
})
.unwrap();
}
export async function getDatabaseSetting(viewId: string) {
const payload = DatabaseViewIdPB.fromObject({
value: viewId,
});
const result = await DatabaseEventGetDatabaseSetting(payload);
return result
.map((value) => {
return {
filters: value.filters.items.map(pbToFilter),
sorts: value.sorts.items.map(pbToSort),
groupSettings: value.group_settings.items.map(pbToGroupSetting),
};
})
.unwrap();
}
export async function openDatabase(viewId: string): Promise<Database> {
const { id, isLinked, layoutType, fieldIds, rowMetas } = await getDatabase(viewId);
const { filters, sorts, groupSettings } = await getDatabaseSetting(viewId);
const { fields, typeOptions } = await fieldService.getFields(viewId, fieldIds);
const groups = await groupService.getGroups(viewId);
return {
id,
isLinked,
layoutType,
fields,
rowMetas,
filters,
sorts,
groups,
groupSettings,
typeOptions,
cells: {},
};
}

View File

@ -1,21 +0,0 @@
import { DatabaseLayoutPB } from '@/services/backend';
import { Field, UndeterminedTypeOptionData } from '../field';
import { Filter } from '../filter';
import { GroupSetting, Group } from '../group';
import { RowMeta } from '../row';
import { Sort } from '../sort';
import { Cell } from '../cell';
export interface Database {
id: string;
isLinked: boolean;
layoutType: DatabaseLayoutPB;
fields: Field[];
rowMetas: RowMeta[];
filters: Filter[];
sorts: Sort[];
groupSettings: GroupSetting[];
groups: Group[];
typeOptions: Record<string, UndeterminedTypeOptionData>;
cells: Record<string, Cell>;
}

View File

@ -1,2 +0,0 @@
export * from './database_types';
export * as databaseService from './database_service';

View File

@ -1,75 +0,0 @@
import { CreateViewPayloadPB, RepeatedViewIdPB, UpdateViewPayloadPB, ViewIdPB, ViewLayoutPB } from '@/services/backend';
import {
FolderEventCreateView,
FolderEventDeleteView,
FolderEventGetView,
FolderEventUpdateView,
} from '@/services/backend/events/flowy-folder';
import { databaseService } from '../database';
import { Page, parserViewPBToPage } from '$app_reducers/pages/slice';
export async function getDatabaseViews(viewId: string): Promise<Page[]> {
const payload = ViewIdPB.fromObject({ value: viewId });
const result = await FolderEventGetView(payload);
if (result.ok) {
return [parserViewPBToPage(result.val), ...result.val.child_views.map(parserViewPBToPage)];
}
return Promise.reject(result.val);
}
export async function createDatabaseView(
viewId: string,
layout: ViewLayoutPB,
name: string,
databaseId?: string
): Promise<Page> {
const payload = CreateViewPayloadPB.fromObject({
parent_view_id: viewId,
name,
layout,
meta: {
database_id: databaseId || (await databaseService.getDatabaseId(viewId)),
},
});
const result = await FolderEventCreateView(payload);
if (result.ok) {
return parserViewPBToPage(result.val);
}
return Promise.reject(result.err);
}
export async function updateView(viewId: string, view: { name?: string; layout?: ViewLayoutPB }): Promise<Page> {
const payload = UpdateViewPayloadPB.fromObject({
view_id: viewId,
name: view.name,
layout: view.layout,
});
const result = await FolderEventUpdateView(payload);
if (result.ok) {
return parserViewPBToPage(result.val);
}
return Promise.reject(result.err);
}
export async function deleteView(viewId: string): Promise<void> {
const payload = RepeatedViewIdPB.fromObject({
items: [viewId],
});
const result = await FolderEventDeleteView(payload);
if (result.ok) {
return;
}
return Promise.reject(result.err);
}

View File

@ -1 +0,0 @@
export * as databaseViewService from './database_view_service';

View File

@ -1,40 +0,0 @@
import { DatabaseFieldChangesetPB, FieldSettingsPB, FieldVisibility } from '@/services/backend';
import { Database, fieldService } from '$app/application/database';
import { didDeleteCells, didUpdateCells } from '$app/application/database/cell/cell_listeners';
export function didUpdateFieldSettings(database: Database, settings: FieldSettingsPB) {
const { field_id: fieldId, visibility, width } = settings;
const field = database.fields.find((field) => field.id === fieldId);
if (!field) return;
field.visibility = visibility;
field.width = width;
// delete cells if field is hidden
if (visibility === FieldVisibility.AlwaysHidden) {
didDeleteCells({ database, fieldId });
}
}
export async function didUpdateFields(viewId: string, database: Database, changeset: DatabaseFieldChangesetPB) {
const { fields, typeOptions } = await fieldService.getFields(viewId);
database.fields = fields;
const deletedFieldIds = Object.keys(changeset.deleted_fields);
const updatedFieldIds = changeset.updated_fields.map((field) => field.id);
Object.assign(database.typeOptions, typeOptions);
deletedFieldIds.forEach(
(fieldId) => {
// delete cache cells
didDeleteCells({ database, fieldId });
// delete cache type options
delete database.typeOptions[fieldId];
},
[database.typeOptions]
);
updatedFieldIds.forEach((fieldId) => {
// delete cache cells
void didUpdateCells({ viewId, database, fieldId });
});
}

View File

@ -1,215 +0,0 @@
import {
CreateFieldPayloadPB,
DeleteFieldPayloadPB,
DuplicateFieldPayloadPB,
FieldChangesetPB,
FieldType,
GetFieldPayloadPB,
MoveFieldPayloadPB,
RepeatedFieldIdPB,
UpdateFieldTypePayloadPB,
FieldSettingsChangesetPB,
FieldVisibility,
DatabaseViewIdPB,
OrderObjectPositionTypePB,
} from '@/services/backend';
import {
DatabaseEventDuplicateField,
DatabaseEventUpdateField,
DatabaseEventUpdateFieldType,
DatabaseEventMoveField,
DatabaseEventGetFields,
DatabaseEventDeleteField,
DatabaseEventCreateField,
DatabaseEventUpdateFieldSettings,
DatabaseEventGetAllFieldSettings,
} from '@/services/backend/events/flowy-database2';
import { Field, pbToField } from './field_types';
import { bytesToTypeOption } from './type_option';
import { Database } from '$app/application/database';
export async function getFields(
viewId: string,
fieldIds?: string[]
): Promise<{
fields: Field[];
typeOptions: Database['typeOptions'];
}> {
const payload = GetFieldPayloadPB.fromObject({
view_id: viewId,
field_ids: fieldIds
? RepeatedFieldIdPB.fromObject({
items: fieldIds.map((fieldId) => ({ field_id: fieldId })),
})
: undefined,
});
const result = await DatabaseEventGetFields(payload);
const getSettingsPayload = DatabaseViewIdPB.fromObject({
value: viewId,
});
const settings = await DatabaseEventGetAllFieldSettings(getSettingsPayload);
if (settings.ok === false || result.ok === false) {
return Promise.reject('Failed to get fields');
}
const typeOptions: Database['typeOptions'] = {};
const fields = await Promise.all(
result.val.items.map(async (item) => {
const setting = settings.val.items.find((setting) => setting.field_id === item.id);
const field = pbToField(item);
const typeOption = bytesToTypeOption(item.type_option_data, item.field_type);
if (typeOption) {
typeOptions[item.id] = typeOption;
}
return {
...field,
visibility: setting?.visibility,
width: setting?.width,
};
})
);
return { fields, typeOptions };
}
export async function createField({
viewId,
targetFieldId,
fieldPosition,
fieldType,
data,
}: {
viewId: string;
targetFieldId?: string;
fieldPosition?: OrderObjectPositionTypePB;
fieldType?: FieldType;
data?: Uint8Array;
}): Promise<Field> {
const payload = CreateFieldPayloadPB.fromObject({
view_id: viewId,
field_type: fieldType,
type_option_data: data,
field_position: {
position: fieldPosition,
object_id: targetFieldId,
},
});
const result = await DatabaseEventCreateField(payload);
if (result.ok === false) {
return Promise.reject('Failed to create field');
}
return pbToField(result.val);
}
export async function duplicateField(viewId: string, fieldId: string): Promise<void> {
const payload = DuplicateFieldPayloadPB.fromObject({
view_id: viewId,
field_id: fieldId,
});
const result = await DatabaseEventDuplicateField(payload);
if (result.ok === false) {
return Promise.reject('Failed to duplicate field');
}
return result.val;
}
export async function updateField(
viewId: string,
fieldId: string,
data: {
name?: string;
desc?: string;
}
): Promise<void> {
const payload = FieldChangesetPB.fromObject({
view_id: viewId,
field_id: fieldId,
...data,
});
const result = await DatabaseEventUpdateField(payload);
return result.unwrap();
}
export async function updateFieldType(viewId: string, fieldId: string, fieldType: FieldType): Promise<void> {
const payload = UpdateFieldTypePayloadPB.fromObject({
view_id: viewId,
field_id: fieldId,
field_type: fieldType,
});
const result = await DatabaseEventUpdateFieldType(payload);
return result.unwrap();
}
export async function moveField(viewId: string, fromFieldId: string, toFieldId: string): Promise<void> {
const payload = MoveFieldPayloadPB.fromObject({
view_id: viewId,
from_field_id: fromFieldId,
to_field_id: toFieldId,
});
const result = await DatabaseEventMoveField(payload);
return result.unwrap();
}
export async function deleteField(viewId: string, fieldId: string): Promise<void> {
const payload = DeleteFieldPayloadPB.fromObject({
view_id: viewId,
field_id: fieldId,
});
const result = await DatabaseEventDeleteField(payload);
return result.unwrap();
}
export async function updateFieldSetting(
viewId: string,
fieldId: string,
settings: {
visibility?: FieldVisibility;
width?: number;
}
): Promise<void> {
const payload = FieldSettingsChangesetPB.fromObject({
view_id: viewId,
field_id: fieldId,
...settings,
});
const result = await DatabaseEventUpdateFieldSettings(payload);
if (result.ok === false) {
return Promise.reject('Failed to update field settings');
}
return result.val;
}
export const reorderFields = (list: Field[], startIndex: number, endIndex: number) => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed);
return result;
};

View File

@ -1,51 +0,0 @@
import { FieldPB, FieldType, FieldVisibility } from '@/services/backend';
export interface Field {
id: string;
name: string;
type: FieldType;
visibility?: FieldVisibility;
width?: number;
isPrimary: boolean;
}
export interface NumberField extends Field {
type: FieldType.Number;
}
export interface DateTimeField extends Field {
type: FieldType.DateTime;
}
export interface LastEditedTimeField extends Field {
type: FieldType.LastEditedTime;
}
export interface CreatedTimeField extends Field {
type: FieldType.CreatedTime;
}
export type UndeterminedDateField = DateTimeField | CreatedTimeField | LastEditedTimeField;
export interface SelectField extends Field {
type: FieldType.SingleSelect | FieldType.MultiSelect;
}
export interface ChecklistField extends Field {
type: FieldType.Checklist;
}
export interface DateTimeField extends Field {
type: FieldType.DateTime;
}
export type UndeterminedField = NumberField | DateTimeField | SelectField | Field;
export const pbToField = (pb: FieldPB): Field => {
return {
id: pb.id,
name: pb.name,
type: pb.field_type,
isPrimary: pb.is_primary,
};
};

View File

@ -1,5 +0,0 @@
export * from './select_option';
export * from './type_option';
export * from './field_types';
export * as fieldService from './field_service';
export * as fieldListeners from './field_listeners';

View File

@ -1,2 +0,0 @@
export * from './select_option_types';
export * as selectOptionService from './select_option_service';

View File

@ -1,58 +0,0 @@
import { CreateSelectOptionPayloadPB, RepeatedSelectOptionPayload } from '@/services/backend';
import {
DatabaseEventCreateSelectOption,
DatabaseEventInsertOrUpdateSelectOption,
DatabaseEventDeleteSelectOption,
} from '@/services/backend/events/flowy-database2';
import { pbToSelectOption, SelectOption } from './select_option_types';
export async function createSelectOption(viewId: string, fieldId: string, optionName: string): Promise<SelectOption> {
const payload = CreateSelectOptionPayloadPB.fromObject({
view_id: viewId,
field_id: fieldId,
option_name: optionName,
});
const result = await DatabaseEventCreateSelectOption(payload);
return result.map(pbToSelectOption).unwrap();
}
/**
* @param [rowId] If pass the rowId, the cell will select this option after insert or update.
*/
export async function insertOrUpdateSelectOption(
viewId: string,
fieldId: string,
items: Partial<SelectOption>[],
rowId?: string
): Promise<void> {
const payload = RepeatedSelectOptionPayload.fromObject({
view_id: viewId,
field_id: fieldId,
row_id: rowId,
items: items,
});
const result = await DatabaseEventInsertOrUpdateSelectOption(payload);
return result.unwrap();
}
export async function deleteSelectOption(
viewId: string,
fieldId: string,
items: Partial<SelectOption>[],
rowId?: string
): Promise<void> {
const payload = RepeatedSelectOptionPayload.fromObject({
view_id: viewId,
field_id: fieldId,
row_id: rowId,
items,
});
const result = await DatabaseEventDeleteSelectOption(payload);
return result.unwrap();
}

View File

@ -1,15 +0,0 @@
import { SelectOptionColorPB, SelectOptionPB } from '@/services/backend';
export interface SelectOption {
id: string;
name: string;
color: SelectOptionColorPB;
}
export function pbToSelectOption(pb: SelectOptionPB): SelectOption {
return {
id: pb.id,
name: pb.name,
color: pb.color,
};
}

View File

@ -1,2 +0,0 @@
export * from './type_option_types';
export * from './type_option_service';

View File

@ -1,26 +0,0 @@
import { FieldType, TypeOptionChangesetPB } from '@/services/backend';
import {
DatabaseEventUpdateFieldTypeOption,
} from '@/services/backend/events/flowy-database2';
import { UndeterminedTypeOptionData, typeOptionDataToPB } from './type_option_types';
export async function updateTypeOption(
viewId: string,
fieldId: string,
fieldType: FieldType,
data: UndeterminedTypeOptionData
) {
const payload = TypeOptionChangesetPB.fromObject({
view_id: viewId,
field_id: fieldId,
type_option_data: typeOptionDataToPB(data, fieldType)?.serialize(),
});
const result = await DatabaseEventUpdateFieldTypeOption(payload);
if (!result.ok) {
return Promise.reject(result.val);
}
return;
}

View File

@ -1,148 +0,0 @@
import {
CheckboxTypeOptionPB,
DateFormatPB,
FieldType,
MultiSelectTypeOptionPB,
NumberFormatPB,
NumberTypeOptionPB,
RichTextTypeOptionPB,
SingleSelectTypeOptionPB,
TimeFormatPB,
ChecklistTypeOptionPB,
DateTypeOptionPB,
TimestampTypeOptionPB,
} from '@/services/backend';
import { pbToSelectOption, SelectOption } from '../select_option';
export interface TextTypeOption {
data?: string;
}
export interface NumberTypeOption {
format?: NumberFormatPB;
scale?: number;
symbol?: string;
name?: string;
}
export interface DateTimeTypeOption {
dateFormat?: DateFormatPB;
timeFormat?: TimeFormatPB;
timezoneId?: string;
}
export interface TimeStampTypeOption extends DateTimeTypeOption {
includeTime?: boolean;
fieldType?: FieldType;
}
export interface SelectTypeOption {
options?: SelectOption[];
disableColor?: boolean;
}
export interface CheckboxTypeOption {
isSelected?: boolean;
}
export interface ChecklistTypeOption {
config?: string;
}
export type UndeterminedTypeOptionData =
| TextTypeOption
| NumberTypeOption
| SelectTypeOption
| CheckboxTypeOption
| ChecklistTypeOption
| DateTimeTypeOption
| TimeStampTypeOption;
export function typeOptionDataToPB(data: UndeterminedTypeOptionData, fieldType: FieldType) {
switch (fieldType) {
case FieldType.Number:
return NumberTypeOptionPB.fromObject(data as NumberTypeOption);
case FieldType.DateTime:
return dateTimeTypeOptionToPB(data as DateTimeTypeOption);
case FieldType.CreatedTime:
case FieldType.LastEditedTime:
return timestampTypeOptionToPB(data as TimeStampTypeOption);
default:
return null;
}
}
function dateTimeTypeOptionToPB(data: DateTimeTypeOption): DateTypeOptionPB {
return DateTypeOptionPB.fromObject({
time_format: data.timeFormat,
date_format: data.dateFormat,
timezone_id: data.timezoneId,
});
}
function timestampTypeOptionToPB(data: TimeStampTypeOption): TimestampTypeOptionPB {
return TimestampTypeOptionPB.fromObject({
include_time: data.includeTime,
date_format: data.dateFormat,
time_format: data.timeFormat,
field_type: data.fieldType,
});
}
function pbToSelectTypeOption(pb: SingleSelectTypeOptionPB | MultiSelectTypeOptionPB): SelectTypeOption {
return {
options: pb.options?.map(pbToSelectOption),
disableColor: pb.disable_color,
};
}
function pbToCheckboxTypeOption(pb: CheckboxTypeOptionPB): CheckboxTypeOption {
return {
isSelected: pb.dummy_field,
};
}
function pbToChecklistTypeOption(pb: ChecklistTypeOptionPB): ChecklistTypeOption {
return {
config: pb.config,
};
}
function pbToDateTypeOption(pb: DateTypeOptionPB): DateTimeTypeOption {
return {
dateFormat: pb.date_format,
timezoneId: pb.timezone_id,
timeFormat: pb.time_format,
};
}
function pbToTimeStampTypeOption(pb: TimestampTypeOptionPB): TimeStampTypeOption {
return {
includeTime: pb.include_time,
dateFormat: pb.date_format,
timeFormat: pb.time_format,
fieldType: pb.field_type,
};
}
export function bytesToTypeOption(data: Uint8Array, fieldType: FieldType) {
switch (fieldType) {
case FieldType.RichText:
return RichTextTypeOptionPB.deserialize(data).toObject() as TextTypeOption;
case FieldType.Number:
return NumberTypeOptionPB.deserialize(data).toObject() as NumberTypeOption;
case FieldType.SingleSelect:
return pbToSelectTypeOption(SingleSelectTypeOptionPB.deserialize(data));
case FieldType.MultiSelect:
return pbToSelectTypeOption(MultiSelectTypeOptionPB.deserialize(data));
case FieldType.Checkbox:
return pbToCheckboxTypeOption(CheckboxTypeOptionPB.deserialize(data));
case FieldType.Checklist:
return pbToChecklistTypeOption(ChecklistTypeOptionPB.deserialize(data));
case FieldType.DateTime:
return pbToDateTypeOption(DateTypeOptionPB.deserialize(data));
case FieldType.CreatedTime:
case FieldType.LastEditedTime:
return pbToTimeStampTypeOption(TimestampTypeOptionPB.deserialize(data));
}
}

View File

@ -1,42 +0,0 @@
import {
CheckboxFilterConditionPB,
ChecklistFilterConditionPB,
FieldType,
NumberFilterConditionPB,
SelectOptionFilterConditionPB,
TextFilterConditionPB,
} from '@/services/backend';
import { UndeterminedFilter } from '$app/application/database';
export function getDefaultFilter(fieldType: FieldType): UndeterminedFilter['data'] | undefined {
switch (fieldType) {
case FieldType.RichText:
case FieldType.URL:
return {
condition: TextFilterConditionPB.TextContains,
content: '',
};
case FieldType.Number:
return {
condition: NumberFilterConditionPB.NumberIsNotEmpty,
};
case FieldType.Checkbox:
return {
condition: CheckboxFilterConditionPB.IsUnChecked,
};
case FieldType.Checklist:
return {
condition: ChecklistFilterConditionPB.IsIncomplete,
};
case FieldType.SingleSelect:
return {
condition: SelectOptionFilterConditionPB.OptionIs,
};
case FieldType.MultiSelect:
return {
condition: SelectOptionFilterConditionPB.OptionContains,
};
default:
return;
}
}

View File

@ -1,8 +0,0 @@
import { Database, pbToFilter } from '$app/application/database';
import { FilterChangesetNotificationPB } from '@/services/backend';
export const didUpdateFilter = (database: Database, changeset: FilterChangesetNotificationPB) => {
const filters = changeset.filters.items.map((pb) => pbToFilter(pb));
database.filters = filters;
};

Some files were not shown because too many files have changed in this diff Show More