Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser Edition #4222

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
95e63fc
start with browser version
Simon-Laux Sep 1, 2024
baaa64f
Added js login algorithm in login.html
meganoahj Sep 1, 2024
dd6515a
startup deltachat instance and serve blob dir
Simon-Laux Sep 1, 2024
3458699
Styled the login page
meganoahj Sep 1, 2024
40003aa
icon and start with runtime
Simon-Laux Sep 9, 2024
9ae921a
clarify comment
Simon-Laux Sep 9, 2024
f89ba21
add deltachat connection, fix setting desktop config
Simon-Laux Sep 10, 2024
854679b
fix fmt
Simon-Laux Sep 10, 2024
c02d03e
convert some not implemented errors into warning log messages
Simon-Laux Sep 10, 2024
45e1241
electron: fix string return
Simon-Laux Sep 10, 2024
b09e765
make blobs load
Simon-Laux Sep 10, 2024
d6f3de0
fix opening files in browser
Simon-Laux Sep 10, 2024
b341f1f
downloading files in browser
Simon-Laux Sep 10, 2024
7299a82
fix displaying thumbnails in chatlistitems
Simon-Laux Sep 10, 2024
fbd75a1
improve scrollbar styling that it looks similar in firefox
Simon-Laux Sep 11, 2024
634e968
Added Help functionality to browser version
meganoahj Sep 14, 2024
6012d49
Added automatic language detection of browser language
meganoahj Sep 14, 2024
6f1b2f0
fix build info
meganoahj Sep 14, 2024
023965c
Moved lib folder to global directory to remove redundancy, introduced…
meganoahj Sep 14, 2024
ff6d612
Added paste image from clipboard functionality (not in chat), fixed f…
meganoahj Sep 14, 2024
e40f580
removed console logging from readClipboardImage function
meganoahj Sep 14, 2024
5316d3c
beautifying function readClipboardImage
meganoahj Sep 14, 2024
3791a1d
added writeclipboard function
meganoahj Sep 15, 2024
31b15cd
better errors and make copy img to clipboard work with non png images
Simon-Laux Sep 15, 2024
369c828
fix readClipboardImage and use our logger
Simon-Laux Sep 15, 2024
af9c704
add browser user agent to about page
Simon-Laux Sep 16, 2024
5f694dd
make empty string errors in transformBlobURL less spammy
Simon-Laux Sep 16, 2024
67a25da
add notifications to browser runtime
Simon-Laux Sep 16, 2024
c1a8885
state that tray icon options are not available in browser
Simon-Laux Sep 16, 2024
de5f921
fix typecheck
Simon-Laux Sep 16, 2024
5160446
fix log convention checker
Simon-Laux Sep 16, 2024
275504d
relative path in log convention checker output instead of just filename
Simon-Laux Sep 16, 2024
80d613c
add logging, and fix eslint issues
Simon-Laux Sep 17, 2024
67fa275
electron: make sure log of stdio server is also logged to file
Simon-Laux Sep 17, 2024
32175f7
log frontend/renderer messages correctly
Simon-Laux Sep 17, 2024
ef591d5
log core log messages correctly
Simon-Laux Sep 17, 2024
5a950f8
keep names of runtime functions: fixes that runtime name is displayed…
Simon-Laux Sep 21, 2024
6a9ae8e
make scrollbar track transparent to fix cut-off dates in chatlistitems
Simon-Laux Sep 25, 2024
ebed056
Added paste image in chat functionality
meganoahj Sep 21, 2024
99e73be
implemented showOpenFileDialog fn and fixed base64 write temp file an…
meganoahj Oct 10, 2024
29ac0c2
add more info to browser readme
Simon-Laux Oct 17, 2024
d171257
fix fmt and lint
Simon-Laux Oct 17, 2024
a534090
remove debug console.log statements
Simon-Laux Oct 17, 2024
039d932
revert accidental change
Simon-Laux Oct 17, 2024
24d121a
Transform some missing urls
nicodh Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .log.convention.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.git
.vscode/
.tx
.github/
_locales/
_locales/**
bin/
images/
docs/
static/help/
static/fonts/
test/
.DS_Store
.*ignore
*.md
*.xdc
*.png
*.json
*.xml
*.html
*.yaml

packages/target-electron/tests/
packages/target-electron/static/
packages/target-electron/build/

packages/target-browser/static/

packages/frontend/static/
packages/frontend/themes/
packages/frontend/scss/
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules

packages/target-electron/bundle_out
packages/target-electron/tests/compiled
packages/shared/ts-compiled-for-tests
packages/shared/ts-compiled-for-tests

packages/target-browser/dist
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added
- Experimental Telegram-style Esc to cancel reply (quote) #4153
- new ViewProfile context menu for blocking/unblocking contact and checking encryption #4043
- added experimental browser version for developers (`packages/target-browser`)

### Changed
- Update electron from `30.3.1` to `32.1.0` #4138
Expand Down Expand Up @@ -53,6 +54,7 @@
- cancel old message highlight animations when a new message is highlighted #4203
- fix: packaging: include architecture in filename for all appimages #4202
- fix: make open external link scheme case insensive #4201
- target-electron: make sure log of stdio server is also logged to file

<a id="1_46_8"></a>

Expand Down
3 changes: 3 additions & 0 deletions _locales/_untranslated_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@
},
"join_group": {
"message": "Join Group"
},
"explain_desktop_browser_disabled_tray_pref": {
"message": "Tray icon does exist in the web version, install the full version from https://get.delta.chat"
}
}
File renamed without changes.
103 changes: 51 additions & 52 deletions bin/log-conventions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,67 @@ ${lines}

Consider using our logger (log.debug) or add this line ${green(
'/* ignore-console-log */'
)} above to add an exception
)} above to add an exception (or add your file to '.log.convention.ignore')
${blue('------------------------------------------------')}`
)
}

import { walk as _walk } from 'walk'
import { readFile } from 'fs'
import { join } from 'path'
const walker = _walk('./src')
import { readFile } from 'fs/promises'
import walk from 'ignore-walk'
import { basename, relative } from 'path'
//@ts-ignore
const files = await walk({
ignoreFiles: ['.log.convention.ignore', '.gitignore'],
})
let found = 0

walker.on('file', function(root, fileStats, next) {
if (!fileStats.name.includes('.js')) next()
const filename = join(root, fileStats.name)
readFile(filename, 'utf-8', function(err, data) {
if (err) throw err
const lines = data.split('\n')
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
const previousLine = i === 0 ? '' : lines[i - 1]
for (const file of files) {
if (!file.endsWith('.ts')) {
continue
}

const lineContainsConsoleLog =
line.indexOf('console.') !== -1 &&
/console.(debug|log|info|error)\(/.test(line) === true
//@ts-ignore
const data = await readFile(file, 'utf-8')

if (!lineContainsConsoleLog) continue
const lines = data.split('\n')
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
const previousLine = i === 0 ? '' : lines[i - 1]

const ignoreConsoleLog =
previousLine.includes('/* ignore-console-log */') ||
/^\s*\/\//.test(line)
const lineContainsConsoleLog =
line.indexOf('console.') !== -1 &&
/console.(debug|log|info|error)\(/.test(line) === true

if (ignoreConsoleLog) continue
if (!lineContainsConsoleLog) continue

formattedOutput(
`${filename}:${i + 1}`,
lines
.slice(i - 1, i + 2)
.join('\n')
.replace(line, string =>
string.replace(
/^([^]*)(console.(?:debug|log|info|error))([^]*)$/,
(_s, s1, s2, s3) => `${cyan(s1)}${red(s2)}${cyan(s3)}`
)
)
)
found++
}
next()
})
})
const ignoreConsoleLog =
previousLine.includes('/* ignore-console-log */') || /^\s*\/\//.test(line)

walker.on('errors', function(root, nodeStatsArray, next) {
next()
})
if (ignoreConsoleLog) continue

walker.on('end', function() {
console.log(
`found ${[
found > 0 ? bgRed(found.toString()) : bgGreen(found.toString()),
]} misplaced console.log statements ( ${grey(
'// comment'
)} lines were ignored)`
)
process.exit(found > 0 ? 1 : 0)
})
const filename = relative(process.cwd(), file)

formattedOutput(
`${filename}:${i + 1}`,
lines
.slice(i - 1, i + 2)
.join('\n')
.replace(line, string =>
string.replace(
/^([^]*)(console.(?:debug|log|info|error))([^]*)$/,
(_s, s1, s2, s3) => `${cyan(s1)}${red(s2)}${cyan(s3)}`
)
)
)
found++
}
}

console.log(
`found ${[
found > 0 ? bgRed(found.toString()) : bgGreen(found.toString()),
]} misplaced console.log statements ( ${grey(
'// comment'
)} lines were ignored)`
)
process.exit(found > 0 ? 1 : 0)
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"test-and-check": "pnpm test && pnpm check",
"reset:node_modules": "rm -rf node_modules && rm -rf packages/*/node_modules || true && pnpm i"
},
"dependencies": {},
"engineStrict": true,
"engines": {
"node": "^20",
Expand All @@ -48,17 +47,18 @@
}
},
"devDependencies": {
"yaml": "^2.4.5",
"@types/ignore-walk": "^4.0.3",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"chokidar": "^3.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-hooks": "^4.6.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"ignore-walk": "^7.0.0",
"prettier": "3.1.0",
"walk": "^2.3.15",
"xml-js": "^1.6.11",
"typescript": "catalog:",
"chokidar": "^3.6.0"
"xml-js": "^1.6.11",
"yaml": "^2.4.5"
}
}
5 changes: 5 additions & 0 deletions packages/frontend/scss/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ button:focus:not(:focus-visible) {
outline: none;
}

* {
scrollbar-width: thin;
scrollbar-color: var(--scrollbarThumb) transparent;
}

::-webkit-scrollbar {
width: 6px;
height: 0;
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/scss/chat/_chat-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// So that `.floating-action-button` is positioned relative to `.chat-list`.
position: relative;

// don't show extra scrollbar in browser edition
overflow: hidden;

.search-result-divider {
line-height: 43px;
height: 40px;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/scss/message/_message-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@
bottom: 0;
// There is also `will-change: scroll-position` dynamically set on this
// element.
overflow: scroll;
overflow-y: scroll;
max-height: 100%;
width: 100%;
padding: 0 0.5em;

scrollbar-color: var(--scrollbarThumb) transparent;
&::-webkit-scrollbar-track {
background: transparent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
onDCEvent,
EffectfulBackendActions,
} from '../../backend-com'
import { runtime } from '@deltachat-desktop/runtime-interface'
import { avatarInitial } from '../Avatar'
import { getLogger } from '../../../../shared/logger'
import useTranslationFunction from '../../hooks/useTranslationFunction'
Expand Down Expand Up @@ -204,7 +205,7 @@ export default function AccountItem({
{account.profileImage ? (
<img
className={styles.content}
src={'file://' + account.profileImage}
src={runtime.transformBlobURL(account.profileImage)}
/>
) : (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
flex-grow: 1;
overflow-y: scroll;
padding-top: 2px;
scrollbar-width: 0;

scrollbar-width: none;
&::-webkit-scrollbar {
width: 0;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import FullscreenAvatar from '../dialogs/FullscreenAvatar'
import type { Type } from '../../backend-com'
import type { PropsWithChildren } from 'react'
import { get_first_emoji } from '@deltachat/message_parser_wasm'
import { runtime } from '@deltachat-desktop/runtime-interface'

import styles from './styles.module.scss'

Expand Down Expand Up @@ -58,7 +59,7 @@ export function Avatar(props: {
} = props

const content = avatarPath ? (
<img className='content' src={'file://' + avatarPath} />
<img className='content' src={runtime.transformBlobURL(avatarPath)} />
) : (
<div className='content' style={{ backgroundColor: color }}>
{avatarInitial(displayName, addr)}
Expand Down
10 changes: 8 additions & 2 deletions packages/frontend/src/components/Settings/Appearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,23 @@ function SettingsTrayIcon({
}) {
const tx = useTranslationFunction()

const isBrowser = runtime.getRuntimeInfo().target === 'browser'
const disabled = settingsStore.rc.minimized || isBrowser

return (
<>
<DesktopSettingsSwitch
settingsKey='minimizeToTray'
label={tx('pref_show_tray_icon')}
disabled={settingsStore.rc.minimized}
disabledValue={settingsStore.rc.minimized}
disabled={disabled}
disabledValue={settingsStore.rc.minimized && !isBrowser}
/>
{settingsStore.rc.minimized && (
<Callout>{tx('explain_desktop_minimized_disabled_tray_pref')}</Callout>
)}
{isBrowser && (
<Callout>{tx('explain_desktop_browser_disabled_tray_pref')}</Callout>
)}
</>
)
}
4 changes: 3 additions & 1 deletion packages/frontend/src/components/chat/ChatListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ const Message = React.memo<
<div
className='summary_thumbnail'
style={{
backgroundImage: `url(${JSON.stringify(summaryPreviewImage)})`,
backgroundImage: `url("${JSON.stringify(
runtime.transformBlobURL(summaryPreviewImage)
)}")`,
}}
/>
)}
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/src/components/composer/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, {
useCallback,
} from 'react'
import { C, T } from '@deltachat/jsonrpc-client'
import { extension } from 'mime-types'

import MenuAttachment from './menuAttachment'
import ComposerMessageInput from './ComposerMessageInput'
Expand Down Expand Up @@ -247,7 +248,9 @@ const Composer = forwardRef<

try {
// Write clipboard to file then attach it to the draft
const path = await runtime.writeClipboardToTempFile()
const path = await runtime.writeClipboardToTempFile(
file.name || `file.${extension(file.type)}`
)
await addFileToDraft(path, msgType)
// delete file again after it was sucessfuly added
await runtime.removeTempFile(path)
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/components/dialogs/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export default function About({ onClose }: DialogProps) {
<td style={{ userSelect: 'all' }}>{value}</td>
</tr>
))}
{runtime.getRuntimeInfo().target === 'browser' && (
<tr key={'browser-version'} style={{ color: 'grey' }}>
<td>Browser UA</td>
<td style={{ userSelect: 'all' }}>{navigator.userAgent}</td>
</tr>
)}
{runtime.getRuntimeInfo().runningUnderARM64Translation && (
<tr>
<td>runningUnderARM64Translation</td>
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/src/components/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,10 @@ export const Quote = ({
</div>
</div>
{hasMessage && quote.image && (
<img className='quoted-image' src={quote.image} />
<img
className='quoted-image'
src={runtime.transformBlobURL(quote.image)}
/>
)}
{hasMessage && quote.viewType == 'Webxdc' && (
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Screens } from '../../../ScreenController'
import { avatarInitial } from '../../Avatar'
import { getLogger } from '../../../../../shared/logger'
import ImageBackdrop from '../../ImageBackdrop'
import { runtime } from '@deltachat-desktop/runtime-interface'

const log = getLogger('AccountDeletionScreen')

Expand Down Expand Up @@ -69,7 +70,7 @@ export default function AccountDeletionScreen({
{accountInfo.profileImage ? (
<img
className={styles.content}
src={'file://' + accountInfo.profileImage}
src={runtime.transformBlobURL(accountInfo.profileImage)}
/>
) : (
<div
Expand Down
Loading
Loading