diff --git a/package.json b/package.json index 2431cbb..9e50a2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@finsweet/ts-utils", - "version": "0.13.3", + "version": "0.13.4", "description": "Typescript utils for custom Webflow projects.", "main": "index.ts", "module": "index.ts", diff --git a/webflow/restartWebflow.ts b/webflow/restartWebflow.ts index a49f174..f13a9c3 100644 --- a/webflow/restartWebflow.ts +++ b/webflow/restartWebflow.ts @@ -1,11 +1,14 @@ /** - * Restart Webflow JS library + * Restarts the Webflow JS library. + * @returns An awaitable promise that is fulfilled when the library has been correctly reinitialized. */ -export const restartWebflow = (): void => { +export const restartWebflow = async (): Promise => { const { Webflow } = window; if (!Webflow || !('destroy' in Webflow) || !('ready' in Webflow) || !('require' in Webflow)) return; Webflow.destroy(); Webflow.ready(); Webflow.require('ix2')?.init(); + + return new Promise((resolve) => Webflow.push(() => resolve(undefined))); };