@elementor/editor-variables 3.33.0-301 → 3.33.0-302
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 +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/mcp/index.ts +2 -0
- package/src/mcp/variables-resource.ts +28 -0
- package/src/storage.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -316,6 +316,9 @@ var OP_RW = "RW";
|
|
|
316
316
|
var OP_RO = "RO";
|
|
317
317
|
var Storage = class {
|
|
318
318
|
state;
|
|
319
|
+
notifyChange() {
|
|
320
|
+
window.dispatchEvent(new Event("variables:updated"));
|
|
321
|
+
}
|
|
319
322
|
constructor() {
|
|
320
323
|
this.state = {
|
|
321
324
|
watermark: -1,
|
|
@@ -335,16 +338,19 @@ var Storage = class {
|
|
|
335
338
|
this.state.watermark = watermark;
|
|
336
339
|
localStorage.setItem(STORAGE_WATERMARK_KEY, this.state.watermark.toString());
|
|
337
340
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
341
|
+
this.notifyChange();
|
|
338
342
|
}
|
|
339
343
|
add(id2, variable) {
|
|
340
344
|
this.load();
|
|
341
345
|
this.state.variables[id2] = variable;
|
|
342
346
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
347
|
+
this.notifyChange();
|
|
343
348
|
}
|
|
344
349
|
update(id2, variable) {
|
|
345
350
|
this.load();
|
|
346
351
|
this.state.variables[id2] = variable;
|
|
347
352
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
353
|
+
this.notifyChange();
|
|
348
354
|
}
|
|
349
355
|
watermark(watermark) {
|
|
350
356
|
this.state.watermark = watermark;
|
|
@@ -3249,7 +3255,7 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
3249
3255
|
};
|
|
3250
3256
|
|
|
3251
3257
|
// src/mcp/index.ts
|
|
3252
|
-
var
|
|
3258
|
+
var import_editor_mcp6 = require("@elementor/editor-mcp");
|
|
3253
3259
|
|
|
3254
3260
|
// src/mcp/create-variable-tool.ts
|
|
3255
3261
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
@@ -3490,14 +3496,40 @@ Failed update, which must be displayed to the end user. If the error message is
|
|
|
3490
3496
|
});
|
|
3491
3497
|
};
|
|
3492
3498
|
|
|
3499
|
+
// src/mcp/variables-resource.ts
|
|
3500
|
+
var import_editor_mcp5 = require("@elementor/editor-mcp");
|
|
3501
|
+
var GLOBAL_VARIABLES_URI = "elementor://variables";
|
|
3502
|
+
var initVariablesResource = () => {
|
|
3503
|
+
const { mcpServer } = (0, import_editor_mcp5.getMCPByDomain)("variables");
|
|
3504
|
+
mcpServer.resource(
|
|
3505
|
+
"global-variables",
|
|
3506
|
+
GLOBAL_VARIABLES_URI,
|
|
3507
|
+
{
|
|
3508
|
+
description: "Global variables list. Variables are being used in this way: If it is directly in the schema, you need to put the ID which is the key inside the object."
|
|
3509
|
+
},
|
|
3510
|
+
async () => {
|
|
3511
|
+
return {
|
|
3512
|
+
contents: [{ uri: GLOBAL_VARIABLES_URI, text: localStorage["elementor-global-variables"] }]
|
|
3513
|
+
};
|
|
3514
|
+
}
|
|
3515
|
+
);
|
|
3516
|
+
window.addEventListener("variables:updated", () => {
|
|
3517
|
+
mcpServer.server.sendResourceUpdated({
|
|
3518
|
+
uri: GLOBAL_VARIABLES_URI,
|
|
3519
|
+
contents: [{ uri: GLOBAL_VARIABLES_URI, text: localStorage["elementor-global-variables"] }]
|
|
3520
|
+
});
|
|
3521
|
+
});
|
|
3522
|
+
};
|
|
3523
|
+
|
|
3493
3524
|
// src/mcp/index.ts
|
|
3494
3525
|
function initMcp() {
|
|
3495
|
-
const { setMCPDescription } = (0,
|
|
3526
|
+
const { setMCPDescription } = (0, import_editor_mcp6.getMCPByDomain)("variables");
|
|
3496
3527
|
setMCPDescription(`Elementor Editor Variables MCP`);
|
|
3497
3528
|
initListVariablesTool();
|
|
3498
3529
|
initCreateVariableTool();
|
|
3499
3530
|
initUpdateVariableTool();
|
|
3500
3531
|
initDeleteVariableTool();
|
|
3532
|
+
initVariablesResource();
|
|
3501
3533
|
}
|
|
3502
3534
|
|
|
3503
3535
|
// src/register-variable-types.tsx
|