Commit graph

931 commits

Author SHA1 Message Date
RMidhunSuresh 4474458f4b getActiveTheme should never return undefined
Instead it should throw an error.

This is useful for when we do setTheme(await getActiveTheme()) because
setTheme expects a string.
2022-06-05 20:52:47 +05:30
RMidhunSuresh 92c79c853d Convert index.js to typescript 2022-05-27 22:42:21 +05:30
Bruno Windels 13428bd03c allow updating cache of unhashed assets (like config) in service worker 2022-05-18 21:41:47 +02:00
Bruno Windels 1555b0f4bc put a message in container node when config file is not found 2022-05-18 21:41:31 +02:00
Bruno Windels 03ab1ee2c7 log theme being loaded 2022-05-18 17:48:03 +02:00
RMidhunSuresh a550788788 Remove some logging + use wrapOrRun 2022-05-18 18:56:28 +05:30
RMidhunSuresh 7952a34d64 Add logging 2022-05-18 16:09:09 +05:30
RMidhunSuresh 660a08db3e Give a better name 2022-05-18 14:41:52 +05:30
RMidhunSuresh 1b22a48b54 Treat theme-manifests the same way as config 2022-05-18 14:23:41 +05:30
RMidhunSuresh 9ba1534390 Remove unused import 2022-05-12 16:03:06 +05:30
RMidhunSuresh 4ddfd3b508 built-asset --> built-assets 2022-05-12 14:56:58 +05:30
RMidhunSuresh e63440527a Move condition to binding 2022-05-12 13:43:19 +05:30
RMidhunSuresh 0984aeb570 Move code to ThemeLoader 2022-05-12 13:39:57 +05:30
RMidhunSuresh 654e83a5f9 Remove method 2022-05-12 13:28:11 +05:30
RMidhunSuresh b306344739 Add explaining comment 2022-05-12 12:55:08 +05:30
R Midhun Suresh 4231037345
Update src/platform/web/Platform.js
Co-authored-by: Bruno Windels <274386+bwindels@users.noreply.github.com>
2022-05-12 12:48:41 +05:30
R Midhun Suresh d5bc9f5d7d
Update src/platform/web/Platform.js
Co-authored-by: Bruno Windels <274386+bwindels@users.noreply.github.com>
2022-05-12 12:48:34 +05:30
RMidhunSuresh cc88245933 Create themeLoader only if not dev 2022-05-11 15:46:12 +05:30
RMidhunSuresh 174adc0755 Move platform dependent code to Platform 2022-05-11 15:38:37 +05:30
RMidhunSuresh c26dc04b52 Fix type 2022-05-11 15:03:32 +05:30
RMidhunSuresh 2761789f45 Move theme code to separate file 2022-05-11 14:58:14 +05:30
RMidhunSuresh 213f87378b Use t.if instead of t.map 2022-05-11 12:46:12 +05:30
RMidhunSuresh 855298bdaf Read from manifest 2022-05-11 12:40:32 +05:30
RMidhunSuresh c39f0d2efb Don't show theme chooser on dev 2022-05-10 14:12:36 +05:30
RMidhunSuresh af9cbd727f Remove existing stylesheets when changing themes 2022-05-10 14:12:36 +05:30
RMidhunSuresh c611d3f85c Select current theme in dropdown 2022-05-10 14:12:36 +05:30
RMidhunSuresh ecb83bb277 Store and load theme from setting 2022-05-10 14:12:36 +05:30
RMidhunSuresh daae7442bb Create theme chooser 2022-05-10 14:12:36 +05:30
Bruno Windels fa34315210 undo refactoring typo from #723 2022-04-25 16:44:31 +02:00
Bruno Windels bec8cea583 fix for breaking in #725 2022-04-25 14:17:07 +02:00
Bruno Windels 3536d12680
Merge pull request #725 from vector-im/bwindels/templateview-ts
add typing for text bindings in template view
2022-04-25 12:42:37 +02:00
Bruno Windels ab893f63b5 remove unneeded assignment 2022-04-25 12:40:25 +02:00
Bruno Windels 6c57c96cb9 add typing for text bindings in template view 2022-04-25 12:07:28 +02:00
RMidhunSuresh d8da128780 remove await 2022-04-22 14:34:16 +05:30
RMidhunSuresh 7a33c2e00d await 2022-04-22 12:26:29 +05:30
RMidhunSuresh 5a94a2feba Move handleConfigRequest inside handleRequest 2022-04-22 12:22:30 +05:30
RMidhunSuresh c6691cf1cb Simplify code 2022-04-22 12:10:25 +05:30
RMidhunSuresh 826835e518 No need to rewrite to index.html 2022-04-22 12:07:53 +05:30
RMidhunSuresh b6e55ef59c Remove comment 2022-04-21 14:46:55 +05:30
RMidhunSuresh 4f23944581 Use named param in Legacy Platform 2022-04-21 14:17:47 +05:30
RMidhunSuresh 1cdc76f5a4 Use undefine instead of null 2022-04-21 14:14:38 +05:30
RMidhunSuresh 468b7e1595 Cache config.json 2022-04-21 12:52:42 +05:30
RMidhunSuresh 6cd3c8ee2b Read config from URL 2022-04-20 12:42:07 +05:30
RMidhunSuresh 2cfcd4653f Use named params 2022-04-20 12:00:33 +05:30
Bruno Windels 78f352b839 avoid white ring around avatars in dark theme 2022-04-14 10:38:08 +02:00
RMidhunSuresh 23aac5cb45 Make theme-name lowercase in manifest 2022-04-13 14:26:40 +05:30
RMidhunSuresh f7bfab6e08 Add develop only script tag to index.html 2022-04-13 14:26:40 +05:30
RMidhunSuresh 5e7432b5de Make badge font color always white 2022-04-13 14:26:40 +05:30
RMidhunSuresh 2de0450e97 Make colors better looking for dark variant 2022-04-13 14:26:40 +05:30
RMidhunSuresh f26b51e5da Change colors in more css files 2022-04-13 14:26:40 +05:30
RMidhunSuresh bf74c3c67b Add more colors to manifest 2022-04-13 14:26:40 +05:30
RMidhunSuresh 3d304be211 Convert theme.css
- Use color variables
- Use colorized icons
2022-04-13 14:26:40 +05:30
RMidhunSuresh 3e2a2b7942 Add theme manifest 2022-04-13 14:26:40 +05:30
RMidhunSuresh 061dc5f824 Replace icon colors with predefined color 2022-04-13 14:26:40 +05:30
Bruno Windels cf780ce259 also apply custom tiles in reply preview in composer 2022-04-08 15:16:22 +02:00
Bruno Windels d21d10e4f2 pass in viewClassForTile from SessionView
so you can also use custom tiles when using the grid view
2022-04-08 15:15:21 +02:00
Bruno Windels 1fea14dd10 ensure other parameters don't get passed to TemplateView parent ctors 2022-04-08 15:04:38 +02:00
Bruno Windels 1f0cb542c8 pass viewClassForTile to tile views, so they can create reply view with correct subtile 2022-04-08 15:02:07 +02:00
Bruno Windels cda96a35ee rename viewClassForEntry to viewClassForTile 2022-04-08 15:01:06 +02:00
Bruno Windels a913671f0c make tileClassForEntry optional, as otherwise it is a breaking change 2022-04-08 14:19:34 +02:00
Bruno Windels 5445db2a42 allow injecting the tilesCreator from the Root/Session/RoomViewModel
this changes the API slightly to be more future-proof,
as we'll expose it in the SDK now.

The function now returns a SimpleTile constructor, rather than an
instance. This allows us to test if an entry would render in the
timeline without creating a tile, which is something we might want in
the matrix layer later on.

The function is now called tileClassForEntry, analogue to what we
do in TimelineView.
2022-04-08 12:52:30 +02:00
Bruno Windels 220f35ae03 fix typescript error 2022-04-08 11:52:21 +02:00
Bruno Windels 6aa79cf6e2 allow to inject custom tile view creator fn into timeline view 2022-04-07 17:25:20 +02:00
Bruno Windels 8b8233ff00
Merge pull request #691 from vector-im/madlittlemods/only-crypto-in-secure-context
Only initialize `Crypto` when olm is provided
2022-03-03 17:33:50 +01:00
Eric Eastwood 2f4c639cef Only initialize Crypto when olm is provided
See https://github.com/vector-im/hydrogen-web/pull/691#discussion_r816988082
2022-03-02 03:17:59 -06:00
Eric Eastwood c09964dc30
Add data-event-id="$xxx" attributes to timeline items for easy selecting in end-to-end tests (#690)
Split out from https://github.com/vector-im/hydrogen-web/pull/653

Example test assertions: db6d3797d7/test/e2e-tests.js (L248-L252)

```js
// Make sure the $abc event on the page has "foobarbaz" text in it
assert.match(
  dom.document.querySelector(`[data-event-id="$abc"]`).outerHTML,
  new RegExp(`.*foobarbaz.*`)
);
```
2022-03-01 18:36:14 -06:00
Bruno Windels 62ce111938
Merge pull request #692 from ryushar/ryushar/typescriptify
Convert domain/avatar.js and domain/LogoutViewModel.js to Typescript
2022-03-01 18:50:19 +01:00
Tushar 7055f02f16 typescriptify domain/avatar.js 2022-02-25 15:52:54 +05:30
Eric Eastwood 0935f2d23a Only try to use window.crypto.subtle in secure contexts to avoid it throwing and stopping all JavaScript
Relevant error if you crypto is used in a non-secure context like a local LAN IP `http://192.168.1.151:3050/`
```
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'deriveBits')
	at new Crypto
	at new Platform
	at mountHydrogen
```

For my use-case with https://github.com/matrix-org/matrix-public-archive, I don't need crypto/encryption at all.

Docs:

 - https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
 - https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle
    - "Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers."

---

Related to https://github.com/vector-im/hydrogen-web/issues/579
2022-02-25 01:59:48 -06:00
Eric Eastwood b993331e06 Add more HTML form and SVG elements
Split off from https://github.com/vector-im/hydrogen-web/pull/653

Personally using `select`, `option`, and `path` currently in https://github.com/matrix-org/matrix-public-archive
but added a few extra SVG elements that seemed common to me.
2022-02-25 01:40:52 -06:00
Eric Eastwood dfed04166e Fix missing reply text when message body is parsed as HTML in [linkedom](https://github.com/WebReflection/linkedom) (SSR).
- [`linkedom`](https://github.com/WebReflection/linkedom) is being used https://github.com/matrix-org/matrix-public-archive to server-side render (SSR) Hydrogen (`hydrogen-view-sdk`)
 - This is being fixed by using a explicit HTML wrapper boilerplate with `DOMParser` to get a matching result in the browser and `linkedom`.

Currently `parseHTML` is only used for HTML content bodies in events. Events with replies have content bodies that look like `<mx-reply>Hello</mx-reply> What's up` so they're parsed as HTML to strip out the `<mx-reply>` part.

Before | After
---  |  ---
![](https://user-images.githubusercontent.com/558581/153692011-2f0e7114-fcb4-481f-b217-49f461b1740a.png) | ![](https://user-images.githubusercontent.com/558581/153692016-52582fdb-abd9-439d-9dce-3f04da6959db.png)

Before:
```js
// Browser (Chrome, Firefox)
new DOMParser().parseFromString(`<div>foo</div>`, "text/html").body.outerHTML;
// '<body><div>foo</div></body>'

// `linkedom` 
new DOMParser().parseFromString(`<div>foo</div>`, "text/html").body.outerHTML;
// '<body></body>'
```

After (consistent matching output):

```js
// Browser (Chrome, Firefox)
new DOMParser().parseFromString(`<!DOCTYPE html><html><body><div>foo</div></body></html>`, "text/html").body.outerHTML;
// '<body><div>foo</div></body>'

// `linkedom`
new DOMParser().parseFromString(`<!DOCTYPE html><html><body><div>foo</div></body></html>`, "text/html").body.outerHTML;
// '<body><div>foo</div></body>'
```

`linkedom` goal is to be close to the current DOM standard, but [not too close](https://github.com/WebReflection/linkedom#faq). Focused on the streamlined cases for server-side rendering (SSR).

Here is some context around getting `DOMParser` to interpret things better. The conclusion was to only support the explicit standard cases with a `<html><body></body></html>` specified instead of adding the magic HTML document creation and massaging that the browser does.

 - https://github.com/WebReflection/linkedom/issues/106
 - https://github.com/WebReflection/linkedom/pull/108

 ---

Part of https://github.com/vector-im/hydrogen-web/pull/653 to support server-side rendering Hydrogen for the [`matrix-public-archive`](https://github.com/matrix-org/matrix-public-archive) project.
2022-02-11 20:10:46 -06:00
Bruno Windels a442b4b009 Merge branch 'master' into bwindels/create-room 2022-02-10 20:05:40 +01:00
Bruno Windels d2008a336b fix lint errors 2022-02-10 19:54:47 +01:00
Bruno Windels 955a6bd6f9 styling for button in member details to open DM 2022-02-10 14:38:12 +01:00
Bruno Windels 147810864f add support to set alias and federation flag in create room 2022-02-10 14:09:18 +01:00
Bruno Windels b5536830d0 improve RoomBeingCreatedView, allow removing the roombeingcreated 2022-02-10 11:07:29 +01:00
Bruno Windels e8c20c28b2 allow passing label into LoadingView
also doesn't need to be a template view, as it doesn't have bindings
or event handlers
2022-02-10 11:06:44 +01:00
Bruno Windels bbb1683dbf fixup: login view styling 2022-02-10 09:40:42 +01:00
Bruno Windels fed42f13ad textarea styling 2022-02-10 09:40:30 +01:00
Bruno Windels 5f6308e7c4 fix homeserver field style in login view 2022-02-10 09:40:19 +01:00
Bruno Windels 5c085efc10 create room view and view model 2022-02-09 19:02:51 +01:00
Bruno Windels 4b1be30dc0 improve form-row classes so they can work with create room form 2022-02-09 19:01:35 +01:00
Bruno Windels 8523f6feaf setup navigation for create room form 2022-02-09 19:00:41 +01:00
Bruno Windels 83d2b58bad add avatar support to creating room 2022-02-09 19:00:00 +01:00
Bruno Windels 743f2270e5 have a single tile view that supports all 3 view models 2022-02-08 16:22:44 +01:00
Bruno Windels bc09ede09f WIP 2022-02-03 17:57:35 +01:00
RMidhunSuresh 8a3c0afba6 Fix incorrect types 2022-02-03 19:41:11 +05:30
RMidhunSuresh bb6a885116 Specify what errors are ignored in options 2022-02-03 19:40:25 +05:30
Bruno Windels 06a1421e97 add backupWriteStatus so binding can take multiple fields into account 2022-01-31 16:26:06 +01:00
Bruno Windels c340746a87 also remove text nodes when updating message body
fixes #649
2022-01-28 16:04:56 +01:00
Bruno Windels bd2c70b923 adapt key backup view(model) to changes in session, show backup progress 2022-01-28 15:14:23 +01:00
Bruno Windels 86caa5f9b1 rename session backup to key backup to be consistent with RoomKey 2022-01-26 09:51:48 +01:00
Bruno Windels e6fee75952 remove enterkeyhint attribute as it prevents entering newlines on android
on Android, by default (without the above attribute set to "send"), you
press enter twice to submit a field. The first time, enter, Android
seems to prevent sending logic by setting the key property on the event
to "Unidentified", but does insert a newline. The second consecutive enter,
it will be set to "Enter" and we'll send.

Having enterkeyhint to send will disable all of that. So we're going with
the default behaviour, which, IIRC, was a bit annoying on iOS as well.
2022-01-18 09:42:01 +01:00
Bruno Windels 4bc421527f also add extra classes to legacy spinner 2022-01-17 16:31:13 +01:00
Bruno Windels 05d23cc745 hook up logout view 2022-01-17 16:31:02 +01:00
Bruno Windels 164d72830f create subclass for inline template views (e.g. without sub classing) 2022-01-17 16:25:48 +01:00
Bruno Windels 412db33c36 click here labels are so nineties 2022-01-14 19:18:12 +01:00
Bruno Windels 65929194b0 fix lint warnings 2022-01-14 16:23:55 +01:00
Bruno Windels b578f4ac84 actually add LocationView 2022-01-14 15:50:19 +01:00
Bruno Windels 052ff02571 move TileView type too so we don't have to repeat imports 2022-01-14 15:47:22 +01:00
Bruno Windels 3c59004e72 Merge branch 'master' into threading-fallback-reply 2022-01-14 15:43:24 +01:00
Bruno Windels 18a76025c7 add location tile view so we don't throw when a location is shared 2022-01-14 15:27:46 +01:00
RMidhunSuresh d18f4d341c store replyFlags on this 2022-01-14 18:31:22 +05:30
Bruno Windels 1f9be978b7 load image in timeline from when it is partially visible 2022-01-14 13:57:11 +01:00
RMidhunSuresh 41fffdf155 Remove even more stray new lines 2022-01-14 18:17:49 +05:30
RMidhunSuresh ef5a377bc6 Hide reply option on pending tile 2022-01-14 18:17:49 +05:30
RMidhunSuresh 28a534ee49 Fix reply nesting 2022-01-14 18:17:49 +05:30
RMidhunSuresh 7f91653208 Rename replyTextTile -> replyTile 2022-01-14 18:17:49 +05:30
RMidhunSuresh 086e0c0320 Inline methods 2022-01-14 18:17:49 +05:30
RMidhunSuresh 273c44424f Throw if viewClass returns undefined 2022-01-14 18:17:49 +05:30
RMidhunSuresh b134fa7409 Format swtich case properly 2022-01-14 18:17:49 +05:30
RMidhunSuresh fee6447e22 Don't call render() 2022-01-14 18:17:49 +05:30
RMidhunSuresh e99cd41ed0 Change check 2022-01-14 18:17:49 +05:30
RMidhunSuresh af5a008d0f Move links to vm 2022-01-14 18:17:49 +05:30
RMidhunSuresh 27a9f5dd02 Use DOMPurify to remove mx-reply 2022-01-14 18:17:49 +05:30
RMidhunSuresh 88f9ad09a2 Move method as local function 2022-01-14 18:17:49 +05:30
RMidhunSuresh c34d574385 No need to export renderPart 2022-01-14 18:17:49 +05:30
RMidhunSuresh 2a124d4195 simplify css 2022-01-14 18:17:49 +05:30
RMidhunSuresh d69059de68 Use different flag 2022-01-14 18:17:49 +05:30
RMidhunSuresh dee22f7120 Implement render flags 2022-01-14 18:17:49 +05:30
RMidhunSuresh 46b69b3873 Render error 2022-01-14 18:17:49 +05:30
RMidhunSuresh 687aa5a7e3 Remove dead code 2022-01-14 18:17:49 +05:30
RMidhunSuresh 4df3654166 Prevent reply previews from being nested 2022-01-14 18:17:49 +05:30
RMidhunSuresh 4d63b41127 Make reply preview flush left 2022-01-14 18:17:49 +05:30
RMidhunSuresh 1b9f970d7f WIP: Render the whole view instead of messageBody 2022-01-14 18:17:49 +05:30
RMidhunSuresh 7f1b3e25e8 Use t instead of tag 2022-01-14 18:17:49 +05:30
RMidhunSuresh f01d5d95d9 Reuse code from timeline view 2022-01-14 18:17:49 +05:30
RMidhunSuresh 89d6968139 Show decryption error as well 2022-01-14 18:17:49 +05:30
RMidhunSuresh 2773642406 No need to handle redaction specially 2022-01-14 18:17:49 +05:30
RMidhunSuresh 13cba84445 Remove mapSideEffect 2022-01-14 18:17:49 +05:30
RMidhunSuresh bb45d0eae9 Render non-text messages as well 2022-01-14 18:17:49 +05:30
RMidhunSuresh e0dc853d74 Fill matrix.to links 2022-01-14 18:17:49 +05:30
RMidhunSuresh 91912bdb8d Create tile using tileCreator 2022-01-14 18:17:49 +05:30
RMidhunSuresh 54004eef4d Integrate into update mechanism 2022-01-14 18:17:49 +05:30
RMidhunSuresh 4a12acf157 Improve error code 2022-01-14 18:17:49 +05:30
RMidhunSuresh 67da746b48 Render error 2022-01-14 18:17:49 +05:30
RMidhunSuresh 545aae31d9 WIP 2022-01-14 18:17:49 +05:30
RMidhunSuresh 3aa29cfc65 Do not remove reply preview 2022-01-14 18:17:49 +05:30
RMidhunSuresh 99f4eb6843 Minimize manual dom manipulation where possible 2022-01-14 18:17:49 +05:30
RMidhunSuresh 61f4d0719f Refactor code 2022-01-14 18:17:49 +05:30
RMidhunSuresh d6233e7c77 Render static avatar 2022-01-14 18:17:49 +05:30
RMidhunSuresh 31573b3599 Render reply 2022-01-14 18:17:49 +05:30
Bruno Windels 13e77636a9 export paths from vite.js as required by Platform, reorder ctor params
make it easier for SDK users
2021-12-22 17:48:08 +01:00
Bruno Windels ba27d20b24 only pass platform into Client
simplifying the API for SDK
2021-12-22 17:20:37 +01:00
Bruno Windels 9238961992 cache olm and olm worker promise inside Platform
as prep to call them every time a Client is created
2021-12-22 17:19:10 +01:00
Bruno Windels fe26f48c47 rename SessionContainer to Client 2021-12-22 17:09:52 +01:00
Bruno Windels b48280905e include path/vite in sdk bundle 2021-12-22 16:31:19 +01:00
Bruno Windels 21a41e192b Merge branch 'master' into ts-conversion-matrix-net 2021-12-09 18:49:54 +01:00
Bruno Windels 0ec86b6dc1 Merge branch 'master' into bwindels/vite-mvp 2021-12-09 18:07:17 +01:00
Bruno Windels d9ff4a8484 sw.js is not part of the sdk yet, so just put the path in index.html 2021-12-09 17:12:08 +01:00