Skip to content

Commit 87d8634

Browse files
committed
Fix failed to start app by User gesture required exception
1 parent 5aa3eb7 commit 87d8634

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkgs/web2/src/domains/engine.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { useNotifyStore } from './notifications'
2626
import { createUseStore, storePicker } from '@/utils/zustand'
2727
import { shallowEquals } from '@paplico/shared-lib'
2828
import debounce from 'just-debounce'
29+
import { rescue } from '@hanakla/arma'
2930

3031
interface EngineStore {
3132
_engine: Paplico | null
@@ -87,11 +88,12 @@ export function usePaplicoInit(
8788
// colorSpace: 'display-p3',
8889
})
8990

91+
console.log(pplc)
9092
;(window as any).pplc = pplc
9193
pplc.exposeLogChannelToGlobalThis()
9294

9395
await pplc.brushes.register(ExtraBrushes.ScatterBrush)
94-
await pplc.fonts.requestToRegisterLocalFonts()
96+
await rescue(() => pplc.fonts.requestToRegisterLocalFonts())
9597

9698
pplc.on('stateChanged', () => {
9799
engineStore._setEngineState(pplc.state)
@@ -136,11 +138,11 @@ export function usePaplicoInit(
136138

137139
// Canvas editor event
138140
useDangerouslyEffectAsync(() => {
139-
const handler = engineStore.canvasEditor
140-
if (!handler) return
141+
const canvasEditor = engineStore.canvasEditor
142+
if (!canvasEditor) return
141143

142144
const offs = [
143-
handler.on('toolModeChanged', ({ next }) => {
145+
canvasEditor.on('toolModeChanged', ({ next }) => {
144146
notifyStore.emit({ type: 'toolChanged', tool: next })
145147
}),
146148
]

0 commit comments

Comments
 (0)