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

feat(wallet): enable webassembly loading #409

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions apps/wallet/build/main.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ export default defineConfig(_ => {
const folder = dirname(id);
const isNodeModule = folder.includes('node_modules');

if (isNodeModule && folder.includes('/@dfinity/didc')) {
// This ensures that the didc library is not included in the main ic libs chunk,
// this is because the didc library includes a wasm file that is loaded at runtime and
// makes the first load of the application slower.
return `ic-didc`;
}

if (
folder.includes('/src/locales') &&
SUPPORTED_LOCALES.some(locale => resolve(folder, `${locale}.locale.ts`) === id)
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet/build/plugins/with-ic-assets.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getContentSecurityPolicy = (
): string => {
const csp: Record<string, string[]> = {
'default-src': ["'none'"],
'script-src': ["'self'"],
'script-src': ["'self'", "'wasm-unsafe-eval'"],
'connect-src': ["'self'", 'https://icp-api.io', 'https://ic0.app', 'https://icp0.io'],
'img-src': ["'self'", 'data:'],
'font-src': ["'self'"],
Expand Down
15 changes: 11 additions & 4 deletions apps/wallet/src/components/PageLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@
</template>

<script lang="ts" setup>
import { computed, watch } from 'vue';
import { computed, defineAsyncComponent, watch } from 'vue';
import { useDisplay } from 'vuetify';
import { VBtn, VLayout, VMain, VSnackbar } from 'vuetify/components';
import AppSidebar from '~/components/layouts/AppSidebar.vue';
import AppToolbar from '~/components/layouts/AppToolbar.vue';
import OpenRequestOverlay from '~/components/requests/OpenRequestOverlay.vue';
import StationSelector from '~/components/StationSelector.vue';
import { appInitConfig } from '~/configs/init.config';
import { useAppStore } from '~/stores/app.store';
import { useSessionStore } from '~/stores/session.store';
import SessionExpiredOverlay from './SessionExpiredOverlay.vue';
import StationSelector from '~/components/StationSelector.vue';
import { appInitConfig } from '~/configs/init.config';
import ErrorDialog from './ui/ErrorDialog.vue';

const app = useAppStore();
const session = useSessionStore();
Expand Down Expand Up @@ -138,6 +138,13 @@ const showStationSelector = computed(
);

const showWarningBanner = ['playground', 'testing'].includes(appInitConfig.buildMode);

// Ensures that the OpenRequestOverlay is only loaded when there is a request in context to be displayed
const OpenRequestOverlay = defineAsyncComponent({
errorComponent: ErrorDialog,
loader: () => import('~/components/requests/OpenRequestOverlay.vue'),
delay: 200,
});
</script>

<style lang="scss">
Expand Down
40 changes: 40 additions & 0 deletions apps/wallet/src/components/ui/ErrorDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<VDialog v-model="open" width="600">
<ErrorCard :title="title" :error="error" :error-details="props.errorDetails" />
</VDialog>
</template>
<script setup lang="ts">
import { computed } from 'vue';
import { VDialog } from 'vuetify/components';
import ErrorCard from './ErrorCard.vue';
import { useI18n } from 'vue-i18n';

const props = withDefaults(
defineProps<{
modelValue?: boolean;
title?: string;
error: string;
errorDetails?: string;
}>(),
{
modelValue: true,
title: undefined,
error: '',
errorDetails: undefined,
},
);

const emit = defineEmits<{
(event: 'update:modelValue', payload: boolean): void;
}>();

const open = computed({
get: () => props.modelValue,
set: value => emit('update:modelValue', value),
});

const i18n = useI18n();

const title = computed(() => props.title || i18n.t('app.error_dialog_title'));
const error = computed(() => props.error || i18n.t('app.error_dialog_message'));
</script>
2 changes: 2 additions & 0 deletions apps/wallet/src/locales/en.locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export default {
no_matching_results: 'No matching results found for `{search}`.',
add_new_label: 'Add new label: {label}',
user_cancel_pending_requests: 'Cancel all pending requests from this user.',
error_dialog_title: 'Failed to load.',
error_dialog_message: 'Failed to load, please try again.',
},
alpha_warning: {
version: 'This is an alpha version.',
Expand Down
2 changes: 2 additions & 0 deletions apps/wallet/src/locales/fr.locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export default {
no_matching_results: 'Pas de résultats correspondants trouvés pour `{search}`.',
add_new_label: 'Ajouter une nouvelle étiquette: {label}',
user_cancel_pending_requests: 'Annuler toutes les demandes en attente de cet usager.',
error_dialog_title: 'Échec de chargement.',
error_dialog_message: 'Échec de chargement, veuillez réessayer.',
},
alpha_warning: {
version: 'Ceci est une version alpha.',
Expand Down
2 changes: 2 additions & 0 deletions apps/wallet/src/locales/pt.locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export default {
no_matching_results: 'Nenhum resultado encontrado para `{search}`.',
add_new_label: 'Adicionar novo rótulo: {label}',
user_cancel_pending_requests: 'Cancelar todos os pedidos pendentes deste usuário.',
error_dialog_title: 'Falha ao carregar.',
error_dialog_message: 'Falha ao carregar, por favor, tente novamente.',
},
alpha_warning: {
version: 'Esta é uma versão alfa.',
Expand Down
Loading