@elementor/editor-v1-adapters
Advanced tools
Comparing version 0.8.5 to 0.9.0
# Change Log | ||
## 0.9.0 | ||
### Minor Changes | ||
- 65d3c4c: Support sync & internal commands | ||
## 0.8.5 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,6 @@ | ||
declare function runCommand(command: string, args?: object): Promise<any>; | ||
type RunCommandOptions = { | ||
internal?: boolean; | ||
}; | ||
declare function runCommand(command: string, args?: object, { internal }?: RunCommandOptions): Promise<any>; | ||
declare function runCommandSync(command: string, args?: object, { internal }?: RunCommandOptions): unknown; | ||
declare function openRoute(route: string): Promise<unknown>; | ||
@@ -101,2 +105,2 @@ declare function registerRoute(route: string): Promise<unknown>; | ||
export { type CommandEvent, type CommandEventDescriptor, type EventDescriptor, type ExtendedWindow, type ListenerCallback, type ListenerEvent, type RouteEvent, type RouteEventDescriptor, type WindowEvent, type WindowEventDescriptor, blockDataCommand as __privateBlockDataCommand, dispatchReadyEvent as __privateDispatchReadyEvent, flushListeners as __privateFlushListeners, getCurrentEditMode as __privateGetCurrentEditMode, isRouteActive as __privateIsRouteActive, listenTo as __privateListenTo, openRoute as __privateOpenRoute, registerRoute as __privateRegisterRoute, runCommand as __privateRunCommand, setReady as __privateSetReady, useIsPreviewMode as __privateUseIsPreviewMode, useIsRouteActive as __privateUseIsRouteActive, useListenTo as __privateUseListenTo, useRouteStatus as __privateUseRouteStatus, commandEndEvent, commandStartEvent, dispatchReadyEvent, editModeChangeEvent, flushListeners, isReady, listenTo, routeCloseEvent, routeOpenEvent, setReady, undoable, v1ReadyEvent, windowEvent }; | ||
export { type CommandEvent, type CommandEventDescriptor, type EventDescriptor, type ExtendedWindow, type ListenerCallback, type ListenerEvent, type RouteEvent, type RouteEventDescriptor, type WindowEvent, type WindowEventDescriptor, blockDataCommand as __privateBlockDataCommand, dispatchReadyEvent as __privateDispatchReadyEvent, flushListeners as __privateFlushListeners, getCurrentEditMode as __privateGetCurrentEditMode, isRouteActive as __privateIsRouteActive, listenTo as __privateListenTo, openRoute as __privateOpenRoute, registerRoute as __privateRegisterRoute, runCommand as __privateRunCommand, runCommandSync as __privateRunCommandSync, setReady as __privateSetReady, useIsPreviewMode as __privateUseIsPreviewMode, useIsRouteActive as __privateUseIsRouteActive, useListenTo as __privateUseListenTo, useRouteStatus as __privateUseRouteStatus, commandEndEvent, commandStartEvent, dispatchReadyEvent, editModeChangeEvent, flushListeners, isReady, listenTo, routeCloseEvent, routeOpenEvent, setReady, undoable, v1ReadyEvent, windowEvent }; |
@@ -21,4 +21,4 @@ "use strict"; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
var index_exports = {}; | ||
__export(index_exports, { | ||
__privateBlockDataCommand: () => blockDataCommand, | ||
@@ -33,2 +33,3 @@ __privateDispatchReadyEvent: () => dispatchReadyEvent, | ||
__privateRunCommand: () => runCommand, | ||
__privateRunCommandSync: () => runCommandSync, | ||
__privateSetReady: () => setReady, | ||
@@ -48,3 +49,3 @@ __privateUseIsPreviewMode: () => useIsPreviewMode, | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
module.exports = __toCommonJS(index_exports); | ||
@@ -62,8 +63,4 @@ // src/dispatchers/utils.ts | ||
// src/dispatchers/dispatchers.ts | ||
function runCommand(command, args) { | ||
const extendedWindow = window; | ||
if (!extendedWindow.$e?.run) { | ||
return Promise.reject("`$e.run()` is not available"); | ||
} | ||
const result = extendedWindow.$e.run(command, args); | ||
async function runCommand(command, args, { internal = false } = {}) { | ||
const result = runCommandSync(command, args, { internal }); | ||
if (result instanceof Promise) { | ||
@@ -77,2 +74,11 @@ return result; | ||
} | ||
function runCommandSync(command, args, { internal = false } = {}) { | ||
const extendedWindow = window; | ||
const run = internal ? extendedWindow.$e?.internal : extendedWindow.$e?.run; | ||
if (!run) { | ||
const runnerName = internal ? "$e.internal" : "$e.run"; | ||
throw new Error(`\`${runnerName}()\` is not available`); | ||
} | ||
return run(command, args); | ||
} | ||
function openRoute(route) { | ||
@@ -392,2 +398,3 @@ const extendedWindow = window; | ||
__privateRunCommand, | ||
__privateRunCommandSync, | ||
__privateSetReady, | ||
@@ -394,0 +401,0 @@ __privateUseIsPreviewMode, |
{ | ||
"name": "@elementor/editor-v1-adapters", | ||
"version": "0.8.5", | ||
"version": "0.9.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "author": "Elementor Team", |
import { type ExtendedWindow } from './types'; | ||
import { isJQueryDeferred, promisifyJQueryDeferred } from './utils'; | ||
export function runCommand( command: string, args?: object ) { | ||
const extendedWindow = window as unknown as ExtendedWindow; | ||
type RunCommandOptions = { | ||
internal?: boolean; | ||
}; | ||
if ( ! extendedWindow.$e?.run ) { | ||
return Promise.reject( '`$e.run()` is not available' ); | ||
} | ||
export async function runCommand( command: string, args?: object, { internal = false }: RunCommandOptions = {} ) { | ||
const result = runCommandSync( command, args, { internal } ); | ||
const result = extendedWindow.$e.run( command, args ); | ||
if ( result instanceof Promise ) { | ||
@@ -24,2 +22,16 @@ return result; | ||
export function runCommandSync( command: string, args?: object, { internal = false }: RunCommandOptions = {} ) { | ||
const extendedWindow = window as unknown as ExtendedWindow; | ||
const run = internal ? extendedWindow.$e?.internal : extendedWindow.$e?.run; | ||
if ( ! run ) { | ||
const runnerName = internal ? '$e.internal' : '$e.run'; | ||
throw new Error( `\`${ runnerName }()\` is not available` ); | ||
} | ||
return run( command, args ); | ||
} | ||
export function openRoute( route: string ) { | ||
@@ -26,0 +38,0 @@ const extendedWindow = window as unknown as ExtendedWindow; |
@@ -0,1 +1,3 @@ | ||
import { type V1Element } from '@elementor/editor-elements'; | ||
export type jQueryDeferred< T > = { | ||
@@ -7,4 +9,5 @@ then: < U >( onFulfill: ( value: T ) => U, onReject?: ( error: unknown ) => U ) => jQueryDeferred< U >; | ||
$e: { | ||
run: ( command: string, args?: object ) => unknown; | ||
route: ( route: string ) => unknown; | ||
run?: ( command: string, args?: object ) => unknown; | ||
internal?: ( command: string, args?: object ) => unknown; | ||
route?: ( route: string ) => unknown; | ||
routes?: { | ||
@@ -19,2 +22,5 @@ register?: ( component: string, route: string, callback: () => unknown ) => unknown; | ||
}; | ||
elementor?: { | ||
getContainer?: ( id: string ) => V1Element; | ||
}; | ||
}; | ||
@@ -21,0 +27,0 @@ |
export { | ||
runCommand as __privateRunCommand, | ||
runCommandSync as __privateRunCommandSync, | ||
openRoute as __privateOpenRoute, | ||
@@ -4,0 +5,0 @@ registerRoute as __privateRegisterRoute, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
103422
1380