@elementor/editor-variables 4.1.0-802 → 4.1.0-804
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/dist/index.js +24 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/mcp/variables-resource.ts +30 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-804",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,22 +39,22 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.1.0-
|
|
43
|
-
"@elementor/editor-canvas": "4.1.0-
|
|
44
|
-
"@elementor/editor-controls": "4.1.0-
|
|
45
|
-
"@elementor/editor-current-user": "4.1.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.1.0-
|
|
47
|
-
"@elementor/editor-panels": "4.1.0-
|
|
48
|
-
"@elementor/editor-props": "4.1.0-
|
|
49
|
-
"@elementor/editor-ui": "4.1.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
51
|
-
"@elementor/menus": "4.1.0-
|
|
52
|
-
"@elementor/http-client": "4.1.0-
|
|
42
|
+
"@elementor/editor": "4.1.0-804",
|
|
43
|
+
"@elementor/editor-canvas": "4.1.0-804",
|
|
44
|
+
"@elementor/editor-controls": "4.1.0-804",
|
|
45
|
+
"@elementor/editor-current-user": "4.1.0-804",
|
|
46
|
+
"@elementor/editor-mcp": "4.1.0-804",
|
|
47
|
+
"@elementor/editor-panels": "4.1.0-804",
|
|
48
|
+
"@elementor/editor-props": "4.1.0-804",
|
|
49
|
+
"@elementor/editor-ui": "4.1.0-804",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.1.0-804",
|
|
51
|
+
"@elementor/menus": "4.1.0-804",
|
|
52
|
+
"@elementor/http-client": "4.1.0-804",
|
|
53
53
|
"@elementor/icons": "^1.72.0",
|
|
54
|
-
"@elementor/events": "4.1.0-
|
|
55
|
-
"@elementor/schema": "4.1.0-
|
|
54
|
+
"@elementor/events": "4.1.0-804",
|
|
55
|
+
"@elementor/schema": "4.1.0-804",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.1.0-
|
|
57
|
+
"@elementor/utils": "4.1.0-804",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1,38 +1,54 @@
|
|
|
1
1
|
import { type MCPRegistryEntry } from '@elementor/editor-mcp';
|
|
2
|
+
import { __privateListenTo as listenTo, commandEndEvent } from '@elementor/editor-v1-adapters';
|
|
2
3
|
|
|
3
4
|
import { service } from '../service';
|
|
4
5
|
import { type TVariable } from '../storage';
|
|
5
6
|
|
|
6
7
|
export const GLOBAL_VARIABLES_URI = 'elementor://global-variables';
|
|
7
8
|
|
|
9
|
+
type GlobalVariablesResourceEntry =
|
|
10
|
+
| ( TVariable & { version: 'v4' } )
|
|
11
|
+
| ( Record< string, unknown > & { version: 'v3' } );
|
|
12
|
+
|
|
13
|
+
const buildGlobalVariablesPayload = async (): Promise< Record< string, GlobalVariablesResourceEntry > > => {
|
|
14
|
+
const merged: Record< string, GlobalVariablesResourceEntry > = {};
|
|
15
|
+
Object.entries( service.variables() ).forEach( ( [ id, variable ] ) => {
|
|
16
|
+
if ( ! variable.deleted ) {
|
|
17
|
+
merged[ id ] = { ...variable, version: 'v4' };
|
|
18
|
+
}
|
|
19
|
+
} );
|
|
20
|
+
return merged;
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
export const initVariablesResource = ( variablesMcpEntry: MCPRegistryEntry, canvasMcpEntry: MCPRegistryEntry ) => {
|
|
9
24
|
[ canvasMcpEntry, variablesMcpEntry ].forEach( ( entry ) => {
|
|
10
25
|
const { resource, sendResourceUpdated } = entry;
|
|
26
|
+
|
|
27
|
+
const notifyGlobalVariablesUpdated = () => {
|
|
28
|
+
sendResourceUpdated( {
|
|
29
|
+
uri: GLOBAL_VARIABLES_URI,
|
|
30
|
+
} );
|
|
31
|
+
};
|
|
32
|
+
|
|
11
33
|
resource(
|
|
12
34
|
'global-variables',
|
|
13
35
|
GLOBAL_VARIABLES_URI,
|
|
14
36
|
{
|
|
15
|
-
description:
|
|
16
|
-
'List of Global variables. Defined as a key-value store (ID as key, global-variable object as value)',
|
|
37
|
+
description: 'Global variables available (v4)',
|
|
17
38
|
},
|
|
18
39
|
async () => {
|
|
19
|
-
const variables
|
|
20
|
-
Object.entries( service.variables() ).forEach( ( [ id, variable ] ) => {
|
|
21
|
-
if ( ! variable.deleted ) {
|
|
22
|
-
variables[ id ] = variable;
|
|
23
|
-
}
|
|
24
|
-
} );
|
|
40
|
+
const variables = await buildGlobalVariablesPayload();
|
|
25
41
|
|
|
26
42
|
return {
|
|
27
|
-
contents: [
|
|
43
|
+
contents: [
|
|
44
|
+
{ uri: GLOBAL_VARIABLES_URI, mimeType: 'application/json', text: JSON.stringify( variables ) },
|
|
45
|
+
],
|
|
28
46
|
};
|
|
29
47
|
}
|
|
30
48
|
);
|
|
31
49
|
|
|
32
|
-
window.addEventListener( 'variables:updated',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} );
|
|
36
|
-
} );
|
|
50
|
+
window.addEventListener( 'variables:updated', notifyGlobalVariablesUpdated );
|
|
51
|
+
|
|
52
|
+
listenTo( commandEndEvent( 'document/save/update' ), notifyGlobalVariablesUpdated );
|
|
37
53
|
} );
|
|
38
54
|
};
|