2022-02-14 10:19:20 +01:00
|
|
|
/**
|
|
|
|
|
Exports the buildWebapp function that can be used for production builds.
|
|
|
|
|
*/
|
2022-12-27 15:37:40 +01:00
|
|
|
import { rollup } from "rollup"
|
2022-02-14 10:19:20 +01:00
|
|
|
import typescript from "@rollup/plugin-typescript"
|
2023-03-28 13:43:59 +02:00
|
|
|
import terser from "@rollup/plugin-terser"
|
2023-04-20 17:14:30 +02:00
|
|
|
import path from "node:path"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { nodeResolve } from "@rollup/plugin-node-resolve"
|
2022-02-14 10:19:20 +01:00
|
|
|
import commonjs from "@rollup/plugin-commonjs"
|
|
|
|
|
import fs from "fs-extra"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { bundleDependencyCheckPlugin, getChunkName, resolveLibs } from "./RollupConfig.js"
|
2023-04-20 17:14:30 +02:00
|
|
|
import os from "node:os"
|
2022-02-14 10:19:20 +01:00
|
|
|
import * as env from "./env.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { createHtml } from "./createHtml.js"
|
2023-09-26 18:03:30 +02:00
|
|
|
import { domainConfigs } from "./DomainConfigs.js"
|
Contact book provider (#6553)
* Added vCard import to attachments
Now, when user receives a vCard as attachment an import option is
displayed inside the attachment bubble, allowing the user to preview
and import the users contained inside that vCard.
The app handles both vCard mime types, text/vcard and text/x-vcard.
* [android] Added vCard Handling
* [android] Added readDataFile
* [ios] Fix iOS readFile function
The iOS readFile function was using the wrong Data constructor,
leading to an Error related to invalid URL when trying to read the file.
The readFile function now uses the Data(fileURLWithPath: ) instead of
Data(contentsOf: ), allowing us to pass file paths to be loaded.
* Add view file handling from native side to app's web part
Now the app is capable to handle native side calls asking for importing
files, mainly used when a user view a supported file and want that Tuta
app handles it.
Currently, the only supported format is .vcf and only on Android, since
iOS doesn't support setting our app as a handler for vcf files.
* Make array readonly
* Create ContactFacade
Implements a ContactFacade to communicate with the worker and handle
errors correctly.
* Show contact icon when attachment is a vCard file
* Add ContactFacadeTest
* Changes after review
* Moved vCard parsing logic to ContactImporter
* Create ContactImporter class
* [android] Fix readDataFile to read on I/O thread
* Implement device contacts import
Close #6467
Co-authored-by: mup <mup@tutao.de>
Co-authored-by: ivk <ivk@tutao.de>
* Fix importing contacts from Device book on Android
* Don't show incorrect mail address info on legacy plans
It is not true that legacy plans can have unlimited custom domains. Make
it not display anything here to prevent confusion.
Fixes #6540
* Changes after review
* Implement device contacts import
Close #6467
Co-authored-by: mup <mup@tutao.de>
Co-authored-by: ivk <ivk@tutao.de>
* Get Dirty info from contact on Android
This commit adds the isDirty property to a contact and return Dirty
contacts to the web part of the app, allowing the app to deal with
native updates.
* Handle native contact Updates
This commit adds a handler to deal with contacts that were added or
edited through the native. If created, inserts the new contact into the
server, otherwise, updates it.
* Apply contact deletion from native side
When user deletes a contact from the native side, the deletion is
applied to the server
* Adjust iOS types
* [android] Two-way contact sync on Android
* Reset Contact's dirty state during Contact update
* Two-way contact sync on iOS
* Fix nickname and deletedOnDevice
* Fix preview list scroll issue
* Don't show incorrect mail address info on legacy plans
It is not true that legacy plans can have unlimited custom domains. Make
it not display anything here to prevent confusion.
Fixes #6540
* Add new fields to Contact
This commit add new fields described in #6590 to the model and adapts
the ContactEditor and ContactViewer to handle the new fields.
* [android] Added new fields to Android Contact Import
* Fix Xcode warning for TaggedSqlValue
* [ios] Add new contact fields to iOS
* Add new fields to vCard
This commit adds the following fields:
- Middle Name
- Name Suffix
- Department (Inside ORG)
- URL
The field ROLE was changed to TITLE since that TITLE seems to be the
expected name for this field.
* Fix tests and add translations
This commit fixes the vCard import/export tests and adds the missing
translations for DE and DE_SIE.
* Code cleanup
* Code cleanup
* Fix bugs from review
* Reset selection in contact list view when deleting selected contents
Call selectNone on the list model to clear the selection after deleting
a selection of contacts.
Fixes #6623
* Fix wrong label on new event button tooltip
This should be newEvent_action; createEvent_label is used as a
placeholder for when the event name is empty in the edit event dialog.
Fixes #6626
* Lower the minimized mail editor overlay
The overlay was position a bit too high due to the recent
overlay changes.
* Events are removed immediately when deleting single or changing rules
Took out some code that was no longer useful. Long events are now always
taken out when updated, the new event will automatically be filled in.
close #6491
close #6444
Co-authored-by: ivk <ivk@tutao.de>
* Fix label in global settings clipping on mobile
* Makes version number copiable from about Dialog
This commit makes the Version Number, License and Company Name able
to be copied
fix #6605
* Fix SearchBar returning no results even with not enabled index
The users were able to trigger an empty search result even without
accepting to enable the search index. Now, even if the user tries
to bypass the dialog, the SearchBar will not return any result
fix #2689
* Fix Android unwanted auto login
This commit flags an intent that has already been handled by the
app as handled, avoiding that when the user opens the app an
intent re-deliver causes auto login.
fix #6322
* Fix client-side captcha verification; fix SignupFormTest
Fix Captcha matching hours 25-29 and allows it to match times that
will never be correct (but can be checked locally).
Add missing SignupFormTest to the test suite.
Fixes #6316
* Align all day events in the calendar on desktop
The ideal solution in my eyes is to rewrite the calendar header so that
the header and body for the day are in one column flex. Using flex
is better than constantly calculating the sizes of elements ourselves
both in code simplicity and performance.
Until then, this quick workaround seems to do the trick.
* Allow switching the calendar for accepted events
Co-authored-by: wec43 <wec@tutao.de>
* Change default email domain when adding email address on legacy plan
fix #6667
* Tell user they cannot add an alias before add alias dialog
* [ci, ios] Separate staging app for iOS
- Introduce new schemes in iOS app for debug, staging and prod
- Add new appId
- Add jobs to get provisioning profiles/certificates for staging app
- Introduce new Fastlane lanes
- Add Jenkins steps to build/upload staging app
Close #6591
* [android] Two-way contact sync on Android
* Fix an initial underscore being generated for Kotlin enum cases
Co-authored-by: paw-hub <104824185+paw-hub@users.noreply.github.com>
* Add an onboarding wizard prototype
This adds a guide that is displayed during the first run after
installing the app. This also includes it's first page,
the welcome page. This will be expanded upon in further commits.
The icon design still needs to be finalised, so
I have inserted a placeholder for now.
* Make the onboarding wizard show only on first run
This adds a property called `isSetupComplete` to `DeviceConfig` used to
determine whether the onboarding wizard has been displayed before.
The property is set to true after the wizard is completed or skipped
causing the wizard only to display once per install.
* Add notifications page to the Android version of the onboarding wizard
Includes the android implementation.
Co-authored-by: mup <mup@tutao.de>
* Fix `licc` generating incorrect code for enums
* Stop asking for notification permissions at launch
Co-authored-by: ivk <ivk@tutao.de>
* Add the theme page to the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Create a wrapper for onboarding wizard pages
Co-authored-by: ivk <ivk@tutao.de>
* Add the contacts page to the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Add the app lock page to the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Enable back buttons in the onboarding wizard
* Implement the notifications page for iOS
Co-authored-by: paw-hub <104824185+paw-hub@users.noreply.github.com>
* Fix the next button overlapping the content in landscape view
I am not happy about the magic '92%' value but to remove it we would
need to calculate the remaining space from the breadcrumbs & dialog
height. This may do for now.
* Change the congratulations page header to 'Welcome to Tuta!'
We decided to change it during a meeting. This way we welcome the user
to the Tuta ecosystem instead of just the app.
* Change `RadioSelector` styling
This styles the `RadioSelector` into a 'radio button button' for the
lack of a better term. This was decided in a meeting.
* Remove skip button from onboarding wizard
* Fix the app lock page of the onboarding wizard having too much padding
* Change wizard breadcrumbs styling
This changes the breadcrumbs in the wizard to make the style discussed
during the meeting.
* Remove the help text from the lock method options in the onboarding flow
This is so the unlock method pages matches our design.
* Improve the text in the onboarding wizard
This tries to make the wizard less wordy & includes a couple
small fixes.
* Align buttons in the onboarding wizard
* Clean up the notification permission check on visibility change code
Co-authored-by: ivk <ivk@tutao.de>
* Use a smaller dialog for the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Fix Android build breaking due to Kotlin JVM version
* Fix import errors
* Stop asking for notification permissions at launch on iOS
* Add the illustrations to the onboarding wizard
This needs some optimization as the illustrations cause the CSS
animations to lag. `Icons.ts` is not the best place to have the
illustrations so we should create a new file. We could also look at
sanitizing the SVGs once a way to keep the CSS classes in the SVG is
found.
* Disable the app lock page on the onboarding wizard if it is not needed
* Move the onboarding wizard illustrations into a separate file
The illustrations do not clutter up the icons file this way.
* Apply redesign of the onboarding wizard
This adds the next version of the illustrations and
changes some layouts.
* Optimise Onboarding Wizard Rendering
This tries to speed up the wait between pressing 'next' and the next
page of the onboarding wizard appearing.
* Bring back the visualizer plugin
We need it to diagnose chunk problems. It was removed because it was not
compatible with our version of `rollup` at the time.
Co-authored-by: ivk <ivk@tutao.de>
* Load the onboarding wizard's illustrations externally
As suggested by ivk, the illustrations are loaded in via an `img` tag
to avoid bloating the chunks. I have manually optimised and inserted the
illustrations again. This improves the performance of the wizard
drastically.
* Ignore the onboarding wizard's illustrations in screen readers
---------
Co-authored-by: mup <mrex@tuta.io>
Co-authored-by: paw <paw-hub@users.noreply.github.com>
Co-authored-by: mup <mup@tutao.de>
Co-authored-by: mac-github <mac-github@tutao.de>
Co-authored-by: mup <34790144+murilopereirame@users.noreply.github.com>
Co-authored-by: jat <jat@tutao.de>
Co-authored-by: wrd <wrd@tutao.de>
Co-authored-by: wec43 <wec@tutao.de>
Co-authored-by: tutao <hello@tutao.de>
Co-authored-by: paw-hub <104824185+paw-hub@users.noreply.github.com>
2024-03-13 10:53:51 +01:00
|
|
|
import { visualizer } from "rollup-plugin-visualizer"
|
2024-04-15 09:16:38 +02:00
|
|
|
import { rollupWasmLoader } from "@tutao/tuta-wasm-loader"
|
2022-02-14 10:19:20 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Builds the web app for production.
|
|
|
|
|
* @param version Version of the app. Will be used for html generation and service worker versioning.
|
|
|
|
|
* @param stage Deployment for which to build: 'prod' will build for the production system, 'test' for the test system, 'local' will use localhost.
|
|
|
|
|
* @param host If stage is left undefined, the value provided here will be used to construct the app URL for HTML creation.
|
|
|
|
|
* @param measure Function that returns the current elapsed build time.
|
|
|
|
|
* @param minify Boolean. Set to true to perform minification.
|
|
|
|
|
* @param projectDir Path to the tutanota root directory.
|
|
|
|
|
* @returns Nothing meaningful.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
export async function buildWebapp({ version, stage, host, measure, minify, projectDir }) {
|
2022-02-14 10:19:20 +01:00
|
|
|
console.log("started cleaning", measure())
|
|
|
|
|
await fs.emptyDir("build")
|
|
|
|
|
|
|
|
|
|
console.log("bundling polyfill", measure())
|
|
|
|
|
const polyfillBundle = await rollup({
|
|
|
|
|
input: ["src/polyfill.ts"],
|
|
|
|
|
plugins: [
|
|
|
|
|
typescript(),
|
|
|
|
|
minify && terser(),
|
|
|
|
|
{
|
|
|
|
|
name: "append-libs",
|
|
|
|
|
resolveId(id) {
|
|
|
|
|
if (id === "systemjs") {
|
|
|
|
|
return path.resolve("libs/s.js")
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-04-24 09:42:07 +02:00
|
|
|
// nodeResolve is for our own modules
|
|
|
|
|
nodeResolve({
|
|
|
|
|
preferBuiltins: true,
|
|
|
|
|
resolveOnly: [/^@tutao\/.*$/],
|
|
|
|
|
}),
|
2022-02-14 10:19:20 +01:00
|
|
|
commonjs(),
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
await polyfillBundle.write({
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
format: "iife",
|
2023-09-27 17:22:36 +02:00
|
|
|
file: "build/polyfill.js",
|
2022-02-14 10:19:20 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
console.log("started copying images", measure())
|
2023-09-27 17:22:36 +02:00
|
|
|
await fs.copy(path.join(projectDir, "/resources/images"), path.join(projectDir, "/build/images"))
|
|
|
|
|
await fs.copy(path.join(projectDir, "/resources/favicon"), path.join(projectDir, "build/images"))
|
2023-11-29 11:16:37 +01:00
|
|
|
await fs.copy(path.join(projectDir, "/resources/pdf"), path.join(projectDir, "build/pdf"))
|
2023-09-27 17:22:36 +02:00
|
|
|
await fs.copy(path.join(projectDir, "/resources/wordlibrary.json"), path.join(projectDir, "build/wordlibrary.json"))
|
|
|
|
|
await fs.copy(path.join(projectDir, "/src/braintree.html"), path.join(projectDir, "/build/braintree.html"))
|
2022-02-14 10:19:20 +01:00
|
|
|
|
|
|
|
|
console.log("started bundling", measure())
|
|
|
|
|
const bundle = await rollup({
|
|
|
|
|
input: ["src/app.ts", "src/api/worker/worker.ts"],
|
|
|
|
|
preserveEntrySignatures: false,
|
|
|
|
|
perf: true,
|
|
|
|
|
plugins: [
|
2023-12-15 11:19:31 +01:00
|
|
|
typescript(),
|
2022-02-14 10:19:20 +01:00
|
|
|
resolveLibs(),
|
|
|
|
|
commonjs({
|
|
|
|
|
exclude: "src/**",
|
|
|
|
|
}),
|
|
|
|
|
minify && terser(),
|
|
|
|
|
analyzer(projectDir),
|
Contact book provider (#6553)
* Added vCard import to attachments
Now, when user receives a vCard as attachment an import option is
displayed inside the attachment bubble, allowing the user to preview
and import the users contained inside that vCard.
The app handles both vCard mime types, text/vcard and text/x-vcard.
* [android] Added vCard Handling
* [android] Added readDataFile
* [ios] Fix iOS readFile function
The iOS readFile function was using the wrong Data constructor,
leading to an Error related to invalid URL when trying to read the file.
The readFile function now uses the Data(fileURLWithPath: ) instead of
Data(contentsOf: ), allowing us to pass file paths to be loaded.
* Add view file handling from native side to app's web part
Now the app is capable to handle native side calls asking for importing
files, mainly used when a user view a supported file and want that Tuta
app handles it.
Currently, the only supported format is .vcf and only on Android, since
iOS doesn't support setting our app as a handler for vcf files.
* Make array readonly
* Create ContactFacade
Implements a ContactFacade to communicate with the worker and handle
errors correctly.
* Show contact icon when attachment is a vCard file
* Add ContactFacadeTest
* Changes after review
* Moved vCard parsing logic to ContactImporter
* Create ContactImporter class
* [android] Fix readDataFile to read on I/O thread
* Implement device contacts import
Close #6467
Co-authored-by: mup <mup@tutao.de>
Co-authored-by: ivk <ivk@tutao.de>
* Fix importing contacts from Device book on Android
* Don't show incorrect mail address info on legacy plans
It is not true that legacy plans can have unlimited custom domains. Make
it not display anything here to prevent confusion.
Fixes #6540
* Changes after review
* Implement device contacts import
Close #6467
Co-authored-by: mup <mup@tutao.de>
Co-authored-by: ivk <ivk@tutao.de>
* Get Dirty info from contact on Android
This commit adds the isDirty property to a contact and return Dirty
contacts to the web part of the app, allowing the app to deal with
native updates.
* Handle native contact Updates
This commit adds a handler to deal with contacts that were added or
edited through the native. If created, inserts the new contact into the
server, otherwise, updates it.
* Apply contact deletion from native side
When user deletes a contact from the native side, the deletion is
applied to the server
* Adjust iOS types
* [android] Two-way contact sync on Android
* Reset Contact's dirty state during Contact update
* Two-way contact sync on iOS
* Fix nickname and deletedOnDevice
* Fix preview list scroll issue
* Don't show incorrect mail address info on legacy plans
It is not true that legacy plans can have unlimited custom domains. Make
it not display anything here to prevent confusion.
Fixes #6540
* Add new fields to Contact
This commit add new fields described in #6590 to the model and adapts
the ContactEditor and ContactViewer to handle the new fields.
* [android] Added new fields to Android Contact Import
* Fix Xcode warning for TaggedSqlValue
* [ios] Add new contact fields to iOS
* Add new fields to vCard
This commit adds the following fields:
- Middle Name
- Name Suffix
- Department (Inside ORG)
- URL
The field ROLE was changed to TITLE since that TITLE seems to be the
expected name for this field.
* Fix tests and add translations
This commit fixes the vCard import/export tests and adds the missing
translations for DE and DE_SIE.
* Code cleanup
* Code cleanup
* Fix bugs from review
* Reset selection in contact list view when deleting selected contents
Call selectNone on the list model to clear the selection after deleting
a selection of contacts.
Fixes #6623
* Fix wrong label on new event button tooltip
This should be newEvent_action; createEvent_label is used as a
placeholder for when the event name is empty in the edit event dialog.
Fixes #6626
* Lower the minimized mail editor overlay
The overlay was position a bit too high due to the recent
overlay changes.
* Events are removed immediately when deleting single or changing rules
Took out some code that was no longer useful. Long events are now always
taken out when updated, the new event will automatically be filled in.
close #6491
close #6444
Co-authored-by: ivk <ivk@tutao.de>
* Fix label in global settings clipping on mobile
* Makes version number copiable from about Dialog
This commit makes the Version Number, License and Company Name able
to be copied
fix #6605
* Fix SearchBar returning no results even with not enabled index
The users were able to trigger an empty search result even without
accepting to enable the search index. Now, even if the user tries
to bypass the dialog, the SearchBar will not return any result
fix #2689
* Fix Android unwanted auto login
This commit flags an intent that has already been handled by the
app as handled, avoiding that when the user opens the app an
intent re-deliver causes auto login.
fix #6322
* Fix client-side captcha verification; fix SignupFormTest
Fix Captcha matching hours 25-29 and allows it to match times that
will never be correct (but can be checked locally).
Add missing SignupFormTest to the test suite.
Fixes #6316
* Align all day events in the calendar on desktop
The ideal solution in my eyes is to rewrite the calendar header so that
the header and body for the day are in one column flex. Using flex
is better than constantly calculating the sizes of elements ourselves
both in code simplicity and performance.
Until then, this quick workaround seems to do the trick.
* Allow switching the calendar for accepted events
Co-authored-by: wec43 <wec@tutao.de>
* Change default email domain when adding email address on legacy plan
fix #6667
* Tell user they cannot add an alias before add alias dialog
* [ci, ios] Separate staging app for iOS
- Introduce new schemes in iOS app for debug, staging and prod
- Add new appId
- Add jobs to get provisioning profiles/certificates for staging app
- Introduce new Fastlane lanes
- Add Jenkins steps to build/upload staging app
Close #6591
* [android] Two-way contact sync on Android
* Fix an initial underscore being generated for Kotlin enum cases
Co-authored-by: paw-hub <104824185+paw-hub@users.noreply.github.com>
* Add an onboarding wizard prototype
This adds a guide that is displayed during the first run after
installing the app. This also includes it's first page,
the welcome page. This will be expanded upon in further commits.
The icon design still needs to be finalised, so
I have inserted a placeholder for now.
* Make the onboarding wizard show only on first run
This adds a property called `isSetupComplete` to `DeviceConfig` used to
determine whether the onboarding wizard has been displayed before.
The property is set to true after the wizard is completed or skipped
causing the wizard only to display once per install.
* Add notifications page to the Android version of the onboarding wizard
Includes the android implementation.
Co-authored-by: mup <mup@tutao.de>
* Fix `licc` generating incorrect code for enums
* Stop asking for notification permissions at launch
Co-authored-by: ivk <ivk@tutao.de>
* Add the theme page to the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Create a wrapper for onboarding wizard pages
Co-authored-by: ivk <ivk@tutao.de>
* Add the contacts page to the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Add the app lock page to the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Enable back buttons in the onboarding wizard
* Implement the notifications page for iOS
Co-authored-by: paw-hub <104824185+paw-hub@users.noreply.github.com>
* Fix the next button overlapping the content in landscape view
I am not happy about the magic '92%' value but to remove it we would
need to calculate the remaining space from the breadcrumbs & dialog
height. This may do for now.
* Change the congratulations page header to 'Welcome to Tuta!'
We decided to change it during a meeting. This way we welcome the user
to the Tuta ecosystem instead of just the app.
* Change `RadioSelector` styling
This styles the `RadioSelector` into a 'radio button button' for the
lack of a better term. This was decided in a meeting.
* Remove skip button from onboarding wizard
* Fix the app lock page of the onboarding wizard having too much padding
* Change wizard breadcrumbs styling
This changes the breadcrumbs in the wizard to make the style discussed
during the meeting.
* Remove the help text from the lock method options in the onboarding flow
This is so the unlock method pages matches our design.
* Improve the text in the onboarding wizard
This tries to make the wizard less wordy & includes a couple
small fixes.
* Align buttons in the onboarding wizard
* Clean up the notification permission check on visibility change code
Co-authored-by: ivk <ivk@tutao.de>
* Use a smaller dialog for the onboarding wizard
Co-authored-by: ivk <ivk@tutao.de>
* Fix Android build breaking due to Kotlin JVM version
* Fix import errors
* Stop asking for notification permissions at launch on iOS
* Add the illustrations to the onboarding wizard
This needs some optimization as the illustrations cause the CSS
animations to lag. `Icons.ts` is not the best place to have the
illustrations so we should create a new file. We could also look at
sanitizing the SVGs once a way to keep the CSS classes in the SVG is
found.
* Disable the app lock page on the onboarding wizard if it is not needed
* Move the onboarding wizard illustrations into a separate file
The illustrations do not clutter up the icons file this way.
* Apply redesign of the onboarding wizard
This adds the next version of the illustrations and
changes some layouts.
* Optimise Onboarding Wizard Rendering
This tries to speed up the wait between pressing 'next' and the next
page of the onboarding wizard appearing.
* Bring back the visualizer plugin
We need it to diagnose chunk problems. It was removed because it was not
compatible with our version of `rollup` at the time.
Co-authored-by: ivk <ivk@tutao.de>
* Load the onboarding wizard's illustrations externally
As suggested by ivk, the illustrations are loaded in via an `img` tag
to avoid bloating the chunks. I have manually optimised and inserted the
illustrations again. This improves the performance of the wizard
drastically.
* Ignore the onboarding wizard's illustrations in screen readers
---------
Co-authored-by: mup <mrex@tuta.io>
Co-authored-by: paw <paw-hub@users.noreply.github.com>
Co-authored-by: mup <mup@tutao.de>
Co-authored-by: mac-github <mac-github@tutao.de>
Co-authored-by: mup <34790144+murilopereirame@users.noreply.github.com>
Co-authored-by: jat <jat@tutao.de>
Co-authored-by: wrd <wrd@tutao.de>
Co-authored-by: wec43 <wec@tutao.de>
Co-authored-by: tutao <hello@tutao.de>
Co-authored-by: paw-hub <104824185+paw-hub@users.noreply.github.com>
2024-03-13 10:53:51 +01:00
|
|
|
visualizer({ filename: "build/stats.html", gzipSize: true }),
|
2022-02-14 10:19:20 +01:00
|
|
|
bundleDependencyCheckPlugin(),
|
2023-04-24 09:42:07 +02:00
|
|
|
nodeResolve({
|
|
|
|
|
preferBuiltins: true,
|
|
|
|
|
resolveOnly: [/^@tutao\/.*$/],
|
|
|
|
|
}),
|
2024-04-15 09:16:38 +02:00
|
|
|
rollupWasmLoader({
|
2024-04-23 11:06:40 +02:00
|
|
|
output: "build/wasm",
|
2024-04-15 09:16:38 +02:00
|
|
|
webassemblyLibraries: [
|
|
|
|
|
{
|
|
|
|
|
name: "liboqs.wasm",
|
2024-04-23 11:06:40 +02:00
|
|
|
command: "make -f Makefile_liboqs build",
|
|
|
|
|
options: {
|
|
|
|
|
workingDir: "libs/webassembly/",
|
|
|
|
|
env: {
|
|
|
|
|
WASM: "../../build/wasm/liboqs.wasm",
|
|
|
|
|
},
|
|
|
|
|
optimizationLevel: "O3",
|
|
|
|
|
},
|
2024-04-15 09:16:38 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "argon2.wasm",
|
2024-04-23 11:06:40 +02:00
|
|
|
command: "make -f Makefile_argon2 build",
|
|
|
|
|
options: {
|
|
|
|
|
workingDir: "libs/webassembly/",
|
|
|
|
|
env: {
|
|
|
|
|
WASM: "../../build/wasm/argon2.wasm",
|
|
|
|
|
},
|
|
|
|
|
optimizationLevel: "O3",
|
|
|
|
|
},
|
2024-04-15 09:16:38 +02:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}),
|
2022-02-14 10:19:20 +01:00
|
|
|
],
|
|
|
|
|
})
|
2022-06-10 09:43:22 +02:00
|
|
|
|
2022-02-14 10:19:20 +01:00
|
|
|
console.log("bundling timings: ")
|
|
|
|
|
for (let [k, v] of Object.entries(bundle.getTimings())) {
|
|
|
|
|
console.log(k, v[0])
|
|
|
|
|
}
|
|
|
|
|
console.log("started writing bundles", measure())
|
|
|
|
|
const output = await bundle.write({
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
format: "system",
|
2023-10-05 10:51:49 +02:00
|
|
|
dir: "build",
|
2022-12-27 15:37:40 +01:00
|
|
|
manualChunks(id, { getModuleInfo, getModuleIds }) {
|
|
|
|
|
return getChunkName(id, { getModuleInfo })
|
2022-02-14 10:19:20 +01:00
|
|
|
},
|
|
|
|
|
chunkFileNames: (chunkInfo) => {
|
|
|
|
|
return "[name]-[hash].js"
|
2022-12-27 15:37:40 +01:00
|
|
|
},
|
2022-02-14 10:19:20 +01:00
|
|
|
})
|
2022-12-27 15:37:40 +01:00
|
|
|
const chunks = output.output.map((c) => c.fileName)
|
2022-02-14 10:19:20 +01:00
|
|
|
|
|
|
|
|
// we have to use System.import here because bootstrap is not executed until we actually import()
|
|
|
|
|
// unlike nollup+es format where it just runs on being loaded like you expect
|
2022-12-27 15:37:40 +01:00
|
|
|
await fs.promises.writeFile(
|
2023-09-27 17:22:36 +02:00
|
|
|
"build/worker-bootstrap.js",
|
2022-12-27 15:37:40 +01:00
|
|
|
`importScripts("./polyfill.js")
|
2022-02-14 10:19:20 +01:00
|
|
|
const importPromise = System.import("./worker.js")
|
|
|
|
|
self.onmessage = function (msg) {
|
|
|
|
|
importPromise.then(function () {
|
|
|
|
|
self.onmessage(msg)
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-12-27 15:37:40 +01:00
|
|
|
`,
|
|
|
|
|
)
|
2022-02-14 10:19:20 +01:00
|
|
|
|
|
|
|
|
let restUrl
|
2022-12-27 15:37:40 +01:00
|
|
|
if (stage === "test") {
|
2023-10-19 09:45:30 +02:00
|
|
|
restUrl = "https://app.test.tuta.com"
|
2022-12-27 15:37:40 +01:00
|
|
|
} else if (stage === "prod") {
|
2023-09-25 13:28:09 +02:00
|
|
|
restUrl = "https://app.tuta.com"
|
2022-12-27 15:37:40 +01:00
|
|
|
} else if (stage === "local") {
|
2022-02-14 10:19:20 +01:00
|
|
|
restUrl = "http://" + os.hostname() + ":9000"
|
2022-12-27 15:37:40 +01:00
|
|
|
} else if (stage === "release") {
|
2022-02-14 10:19:20 +01:00
|
|
|
restUrl = undefined
|
2022-12-27 15:37:40 +01:00
|
|
|
} else {
|
|
|
|
|
// host
|
2022-02-14 10:19:20 +01:00
|
|
|
restUrl = host
|
|
|
|
|
}
|
|
|
|
|
await createHtml(
|
|
|
|
|
env.create({
|
2022-12-27 15:37:40 +01:00
|
|
|
staticUrl: stage === "release" || stage === "local" ? null : restUrl,
|
2022-02-14 10:19:20 +01:00
|
|
|
version,
|
|
|
|
|
mode: "Browser",
|
2022-12-27 15:37:40 +01:00
|
|
|
dist: true,
|
2023-09-26 18:03:30 +02:00
|
|
|
domainConfigs,
|
2022-02-14 10:19:20 +01:00
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
if (stage !== "release") {
|
2023-09-26 18:03:30 +02:00
|
|
|
await createHtml(env.create({ staticUrl: restUrl, version, mode: "App", dist: true, domainConfigs }))
|
2022-02-14 10:19:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await bundleServiceWorker(chunks, version, minify)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function bundleServiceWorker(bundles, version, minify) {
|
|
|
|
|
const customDomainFileExclusions = ["index.html", "index.js"]
|
|
|
|
|
const filesToCache = ["index.js", "index.html", "polyfill.js", "worker-bootstrap.js"]
|
|
|
|
|
// we always include English
|
|
|
|
|
// we still cache native-common even though we don't need it because worker has to statically depend on it
|
2022-12-27 15:37:40 +01:00
|
|
|
.concat(
|
|
|
|
|
bundles.filter(
|
|
|
|
|
(it) =>
|
|
|
|
|
it.startsWith("translation-en") ||
|
|
|
|
|
(!it.startsWith("translation") && !it.startsWith("native-main") && !it.startsWith("SearchInPageOverlay")),
|
|
|
|
|
),
|
|
|
|
|
)
|
2023-02-08 14:37:08 +01:00
|
|
|
.concat(["images/logo-favicon.png", "images/logo-favicon-152.png", "images/logo-favicon-196.png", "images/font.ttf"])
|
2022-02-14 10:19:20 +01:00
|
|
|
const swBundle = await rollup({
|
|
|
|
|
input: ["src/serviceworker/sw.ts"],
|
|
|
|
|
plugins: [
|
|
|
|
|
typescript(),
|
|
|
|
|
minify && terser(),
|
|
|
|
|
{
|
|
|
|
|
name: "sw-banner",
|
|
|
|
|
banner() {
|
|
|
|
|
return `function filesToCache() { return ${JSON.stringify(filesToCache)} }
|
|
|
|
|
function version() { return "${version}" }
|
2023-11-02 17:57:14 +01:00
|
|
|
function customDomainCacheExclusions() { return ${JSON.stringify(customDomainFileExclusions)} }
|
|
|
|
|
function shouldTakeOverImmediately() {
|
|
|
|
|
return self.location.hostname.endsWith(".tutanota.com") && Date.now() > new Date("2023-11-07T13:00:00.000Z").getTime()
|
|
|
|
|
}`
|
2022-12-27 15:37:40 +01:00
|
|
|
},
|
|
|
|
|
},
|
2022-02-14 10:19:20 +01:00
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
await swBundle.write({
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
format: "iife",
|
2023-09-27 17:22:36 +02:00
|
|
|
file: "build/sw.js",
|
2022-02-14 10:19:20 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A little plugin to:
|
|
|
|
|
* - Print out each chunk size and contents
|
|
|
|
|
* - Create a graph file with chunk dependencies.
|
|
|
|
|
*/
|
|
|
|
|
function analyzer(projectDir) {
|
|
|
|
|
return {
|
|
|
|
|
name: "analyze",
|
|
|
|
|
async generateBundle(outOpts, bundle) {
|
|
|
|
|
const prefix = projectDir
|
|
|
|
|
let buffer = "digraph G {\n"
|
|
|
|
|
buffer += "edge [dir=back]\n"
|
|
|
|
|
|
2023-03-28 13:43:59 +02:00
|
|
|
for (const [fileName, info] of Object.entries(bundle)) {
|
|
|
|
|
if (fileName.startsWith("translation")) continue
|
|
|
|
|
// https://www.rollupjs.org/plugin-development/#generatebundle
|
|
|
|
|
if (info.type === "asset") continue
|
|
|
|
|
for (const dep of info.imports) {
|
2022-02-14 10:19:20 +01:00
|
|
|
if (!dep.includes("translation")) {
|
2023-03-28 13:43:59 +02:00
|
|
|
buffer += `"${dep}" -> "${fileName}"\n`
|
2022-02-14 10:19:20 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-28 13:43:59 +02:00
|
|
|
console.log(fileName, "", info.code.length / 1024 + "K")
|
|
|
|
|
for (const module of Object.keys(info.modules)) {
|
2022-02-14 10:19:20 +01:00
|
|
|
if (module.includes("src/api/entities")) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
const moduleName = module.startsWith(prefix) ? module.substring(prefix.length) : module
|
2023-02-10 10:11:25 +01:00
|
|
|
console.log("\t" + moduleName)
|
2022-02-14 10:19:20 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer += "}\n"
|
|
|
|
|
await fs.writeFile("build/bundles.dot", buffer)
|
|
|
|
|
},
|
|
|
|
|
}
|
2022-12-27 15:37:40 +01:00
|
|
|
}
|