From f7a7fd7df8a09b6d7d2c2b785af32517598aa003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Magalh=C3=A3es?= Date: Wed, 8 May 2024 10:35:10 -0400 Subject: [PATCH 1/2] fix: fix integration with vtex / spa --- src/lib/sandbox/read-main-platform.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/sandbox/read-main-platform.ts b/src/lib/sandbox/read-main-platform.ts index bc4c85f1..3e6d3a36 100644 --- a/src/lib/sandbox/read-main-platform.ts +++ b/src/lib/sandbox/read-main-platform.ts @@ -93,11 +93,11 @@ const readImplementations = (impls: any[], interfaces: InterfaceInfo[]) => { const impl = implData[0]; const interfaceType: InterfaceType = implData[1] as any; const cstrName = getConstructorName(impl); - const CstrPrototype = (mainWindow as any)[cstrName].prototype; + const CstrPrototype = cstrName === 'History' ? History.prototype : (mainWindow as any)[cstrName].prototype; return [cstrName, CstrPrototype, impl, interfaceType]; - }); - - cstrImpls.map(([cstrName, CstrPrototype, impl, intefaceType]) => + }); + + cstrImpls.filter(([cstrName, CstrPrototype, impl, intefaceType])=> !!CstrPrototype).map(([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType) ); @@ -121,7 +121,7 @@ const readOwnImplementation = ( impl: any, interfaceType: InterfaceType ) => { - if (!cstrs.has(cstrName)) { + if (!cstrs.has(cstrName) && CstrPrototype) { cstrs.add(cstrName); const SuperCstr = Object.getPrototypeOf(CstrPrototype); const superCstrName = getConstructorName(SuperCstr); From e4545d0d1a4a50460f536db4422f0c26c927110d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Magalh=C3=A3es?= Date: Wed, 15 May 2024 14:48:44 -0300 Subject: [PATCH 2/2] fix: fixed --- src/lib/web-worker/worker-forwarded-trigger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/web-worker/worker-forwarded-trigger.ts b/src/lib/web-worker/worker-forwarded-trigger.ts index 86d89e3f..58330d9e 100644 --- a/src/lib/web-worker/worker-forwarded-trigger.ts +++ b/src/lib/web-worker/worker-forwarded-trigger.ts @@ -18,7 +18,7 @@ export const workerForwardedTriggerHandle = ({ if (i + 1 < l) { target = target[$forward$[i]]; } else { - target[$forward$[i]].apply(target, deserializeFromMain(null, $winId$, [], $args$)); + target[$forward$[i]]?.apply(target, deserializeFromMain(null, $winId$, [], $args$)); } } } catch (e) {