@elementor/frontend-handlers 0.1.1 → 3.32.0-20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +3 -3
- package/src/init.ts +3 -0
- package/.turbo/turbo-build.log +0 -22
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -93,6 +93,7 @@ function init() {
|
|
|
93
93
|
window.addEventListener("elementor/element/render", (_event) => {
|
|
94
94
|
const event = _event;
|
|
95
95
|
const { id, type, element } = event.detail;
|
|
96
|
+
onElementDestroy({ elementType: type, elementId: id });
|
|
96
97
|
onElementRender({ element, elementType: type, elementId: id });
|
|
97
98
|
});
|
|
98
99
|
window.addEventListener("elementor/element/destroy", (_event) => {
|
package/dist/index.mjs
CHANGED
|
@@ -65,6 +65,7 @@ function init() {
|
|
|
65
65
|
window.addEventListener("elementor/element/render", (_event) => {
|
|
66
66
|
const event = _event;
|
|
67
67
|
const { id, type, element } = event.detail;
|
|
68
|
+
onElementDestroy({ elementType: type, elementId: id });
|
|
68
69
|
onElementRender({ element, elementType: type, elementId: id });
|
|
69
70
|
});
|
|
70
71
|
window.addEventListener("elementor/element/destroy", (_event) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/frontend-handlers",
|
|
3
3
|
"description": "Elementor Frontend Handlers",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.32.0-20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/elementor/elementor
|
|
22
|
+
"url": "https://github.com/elementor/elementor.git",
|
|
23
23
|
"directory": "packages/core/frontend-handlers"
|
|
24
24
|
},
|
|
25
25
|
"bugs": {
|
|
26
|
-
"url": "https://github.com/elementor/elementor
|
|
26
|
+
"url": "https://github.com/elementor/elementor/issues"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
package/src/init.ts
CHANGED
|
@@ -5,6 +5,9 @@ export function init() {
|
|
|
5
5
|
const event = _event as CustomEvent< { id: string; type: string; element: Element } >;
|
|
6
6
|
const { id, type, element } = event.detail;
|
|
7
7
|
|
|
8
|
+
// Ensure the "destroy" event was not triggered before the render event.
|
|
9
|
+
onElementDestroy( { elementType: type, elementId: id } );
|
|
10
|
+
|
|
8
11
|
onElementRender( { element, elementType: type, elementId: id } );
|
|
9
12
|
} );
|
|
10
13
|
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @elementor/frontend-handlers@0.1.1 build
|
|
3
|
-
> tsup --config=../../tsup.build.ts
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: ../../../tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.0
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/elementor-packages/elementor-packages/tsup.build.ts
|
|
9
|
-
[34mCLI[39m Target: esnext
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[34mCJS[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m3.69 KB[39m
|
|
14
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m5.69 KB[39m
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in 256ms
|
|
16
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m2.64 KB[39m
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m5.52 KB[39m
|
|
18
|
-
[32mESM[39m ⚡️ Build success in 266ms
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 25566ms
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m415.00 B[39m
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m415.00 B[39m
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/handlers-registry.ts","../src/lifecycle-events.ts","../src/init.ts"],"sourcesContent":["export { register, unregister } from './handlers-registry';\n\nexport { init } from './init';\n","type Handler = ( params: { element: Element; signal: AbortSignal } ) => ( () => void ) | undefined;\n\nexport const handlers: Map< string, Map< string, Handler > > = new Map();\n\nexport const register = ( { elementType, id, callback }: { elementType: string; id: string; callback: Handler } ) => {\n\tif ( ! handlers.has( elementType ) ) {\n\t\thandlers.set( elementType, new Map() );\n\t}\n\n\tif ( ! handlers.get( elementType )?.has( id ) ) {\n\t\thandlers.get( elementType )?.set( id, callback );\n\t}\n};\n\nexport const unregister = ( { elementType, id }: { elementType: string; id?: string } ) => {\n\tif ( ! handlers.has( elementType ) ) {\n\t\treturn;\n\t}\n\n\tif ( id ) {\n\t\thandlers.get( elementType )?.delete( id );\n\n\t\tif ( handlers.get( elementType )?.size === 0 ) {\n\t\t\thandlers.delete( elementType );\n\t\t}\n\t} else {\n\t\thandlers.delete( elementType );\n\t}\n};\n","import { handlers } from './handlers-registry';\n\nconst unmountCallbacks: Map< string, Map< string, () => void > > = new Map();\n\nexport const onElementRender = ( {\n\telement,\n\telementType,\n\telementId,\n}: {\n\telement: Element;\n\telementType: string;\n\telementId: string;\n} ) => {\n\tconst controller = new AbortController();\n\tconst manualUnmount: ( () => void )[] = [];\n\n\tif ( ! handlers.has( elementType ) ) {\n\t\treturn;\n\t}\n\n\tArray.from( handlers.get( elementType )?.values() ?? [] ).forEach( ( handler ) => {\n\t\tconst unmount = handler( { element, signal: controller.signal } );\n\n\t\tif ( typeof unmount === 'function' ) {\n\t\t\tmanualUnmount.push( unmount );\n\t\t}\n\t} );\n\n\tif ( ! unmountCallbacks.has( elementType ) ) {\n\t\tunmountCallbacks.set( elementType, new Map() );\n\t}\n\n\tunmountCallbacks.get( elementType )?.set( elementId, () => {\n\t\tcontroller.abort();\n\n\t\tmanualUnmount.forEach( ( callback ) => callback() );\n\t} );\n};\n\nexport const onElementDestroy = ( { elementType, elementId }: { elementType: string; elementId: string } ) => {\n\tconst unmount = unmountCallbacks.get( elementType )?.get( elementId );\n\n\tif ( ! unmount ) {\n\t\treturn;\n\t}\n\n\tunmount();\n\n\tunmountCallbacks.get( elementType )?.delete( elementId );\n\n\tif ( unmountCallbacks.get( elementType )?.size === 0 ) {\n\t\tunmountCallbacks.delete( elementType );\n\t}\n};\n","import { onElementDestroy, onElementRender } from './lifecycle-events';\n\nexport function init() {\n\twindow.addEventListener( 'elementor/element/render', ( _event ) => {\n\t\tconst event = _event as CustomEvent< { id: string; type: string; element: Element } >;\n\t\tconst { id, type, element } = event.detail;\n\n\t\tonElementRender( { element, elementType: type, elementId: id } );\n\t} );\n\n\twindow.addEventListener( 'elementor/element/destroy', ( _event ) => {\n\t\tconst event = _event as CustomEvent< { id: string; type: string } >;\n\t\tconst { id, type } = event.detail;\n\n\t\tonElementDestroy( { elementType: type, elementId: id } );\n\t} );\n\n\tdocument.addEventListener( 'DOMContentLoaded', () => {\n\t\tdocument.querySelectorAll( '[data-e-type]' ).forEach( ( element ) => {\n\t\t\tconst el = element as HTMLElement;\n\n\t\t\tconst { eType, id } = el.dataset;\n\n\t\t\tif ( ! eType || ! id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.dispatchEvent(\n\t\t\t\tnew CustomEvent( 'elementor/element/render', {\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: eType,\n\t\t\t\t\t\telement,\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);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AA,IACD,CAAE;AAAA,EACH,CAAE;AACH;","names":[]}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/handlers-registry.ts","../src/lifecycle-events.ts","../src/init.ts"],"sourcesContent":["type Handler = ( params: { element: Element; signal: AbortSignal } ) => ( () => void ) | undefined;\n\nexport const handlers: Map< string, Map< string, Handler > > = new Map();\n\nexport const register = ( { elementType, id, callback }: { elementType: string; id: string; callback: Handler } ) => {\n\tif ( ! handlers.has( elementType ) ) {\n\t\thandlers.set( elementType, new Map() );\n\t}\n\n\tif ( ! handlers.get( elementType )?.has( id ) ) {\n\t\thandlers.get( elementType )?.set( id, callback );\n\t}\n};\n\nexport const unregister = ( { elementType, id }: { elementType: string; id?: string } ) => {\n\tif ( ! handlers.has( elementType ) ) {\n\t\treturn;\n\t}\n\n\tif ( id ) {\n\t\thandlers.get( elementType )?.delete( id );\n\n\t\tif ( handlers.get( elementType )?.size === 0 ) {\n\t\t\thandlers.delete( elementType );\n\t\t}\n\t} else {\n\t\thandlers.delete( elementType );\n\t}\n};\n","import { handlers } from './handlers-registry';\n\nconst unmountCallbacks: Map< string, Map< string, () => void > > = new Map();\n\nexport const onElementRender = ( {\n\telement,\n\telementType,\n\telementId,\n}: {\n\telement: Element;\n\telementType: string;\n\telementId: string;\n} ) => {\n\tconst controller = new AbortController();\n\tconst manualUnmount: ( () => void )[] = [];\n\n\tif ( ! handlers.has( elementType ) ) {\n\t\treturn;\n\t}\n\n\tArray.from( handlers.get( elementType )?.values() ?? [] ).forEach( ( handler ) => {\n\t\tconst unmount = handler( { element, signal: controller.signal } );\n\n\t\tif ( typeof unmount === 'function' ) {\n\t\t\tmanualUnmount.push( unmount );\n\t\t}\n\t} );\n\n\tif ( ! unmountCallbacks.has( elementType ) ) {\n\t\tunmountCallbacks.set( elementType, new Map() );\n\t}\n\n\tunmountCallbacks.get( elementType )?.set( elementId, () => {\n\t\tcontroller.abort();\n\n\t\tmanualUnmount.forEach( ( callback ) => callback() );\n\t} );\n};\n\nexport const onElementDestroy = ( { elementType, elementId }: { elementType: string; elementId: string } ) => {\n\tconst unmount = unmountCallbacks.get( elementType )?.get( elementId );\n\n\tif ( ! unmount ) {\n\t\treturn;\n\t}\n\n\tunmount();\n\n\tunmountCallbacks.get( elementType )?.delete( elementId );\n\n\tif ( unmountCallbacks.get( elementType )?.size === 0 ) {\n\t\tunmountCallbacks.delete( elementType );\n\t}\n};\n","import { onElementDestroy, onElementRender } from './lifecycle-events';\n\nexport function init() {\n\twindow.addEventListener( 'elementor/element/render', ( _event ) => {\n\t\tconst event = _event as CustomEvent< { id: string; type: string; element: Element } >;\n\t\tconst { id, type, element } = event.detail;\n\n\t\tonElementRender( { element, elementType: type, elementId: id } );\n\t} );\n\n\twindow.addEventListener( 'elementor/element/destroy', ( _event ) => {\n\t\tconst event = _event as CustomEvent< { id: string; type: string } >;\n\t\tconst { id, type } = event.detail;\n\n\t\tonElementDestroy( { elementType: type, elementId: id } );\n\t} );\n\n\tdocument.addEventListener( 'DOMContentLoaded', () => {\n\t\tdocument.querySelectorAll( '[data-e-type]' ).forEach( ( element ) => {\n\t\t\tconst el = element as HTMLElement;\n\n\t\t\tconst { eType, id } = el.dataset;\n\n\t\t\tif ( ! eType || ! id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.dispatchEvent(\n\t\t\t\tnew CustomEvent( 'elementor/element/render', {\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: eType,\n\t\t\t\t\t\telement,\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);\n\t\t} );\n\t} );\n}\n"],"mappings":";AAEO,IAAM,WAAkD,oBAAI,IAAI;AAEhE,IAAM,WAAW,CAAE,EAAE,aAAa,IAAI,SAAS,MAA+D;AACpH,MAAK,CAAE,SAAS,IAAK,WAAY,GAAI;AACpC,aAAS,IAAK,aAAa,oBAAI,IAAI,CAAE;AAAA,EACtC;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