@servlyadmin/runtime-core 0.1.34 → 0.1.36
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.cjs +61 -4
- package/dist/index.js +61 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2235,6 +2235,40 @@ var builtInPlugins = {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
return { success: true };
|
|
2237
2237
|
},
|
|
2238
|
+
/**
|
|
2239
|
+
* Execute arbitrary JavaScript code
|
|
2240
|
+
* Mirrors: executeCode from builder's FunctionPropExecutor
|
|
2241
|
+
* WARNING: This executes arbitrary code - use with caution in production
|
|
2242
|
+
*/
|
|
2243
|
+
"executeCode": (action, ctx) => {
|
|
2244
|
+
const code = action.code || action.config?.code;
|
|
2245
|
+
if (!code) return { success: false, error: "No code provided" };
|
|
2246
|
+
try {
|
|
2247
|
+
const fn = new Function(
|
|
2248
|
+
"event",
|
|
2249
|
+
"props",
|
|
2250
|
+
"state",
|
|
2251
|
+
"context",
|
|
2252
|
+
"stateManager",
|
|
2253
|
+
"currentItem",
|
|
2254
|
+
"currentIndex",
|
|
2255
|
+
code
|
|
2256
|
+
);
|
|
2257
|
+
const result = fn(
|
|
2258
|
+
ctx.event,
|
|
2259
|
+
ctx.context.props || {},
|
|
2260
|
+
ctx.context.state || {},
|
|
2261
|
+
ctx.context.context || {},
|
|
2262
|
+
ctx.stateManager,
|
|
2263
|
+
ctx.currentItem,
|
|
2264
|
+
ctx.currentIndex
|
|
2265
|
+
);
|
|
2266
|
+
return { success: true, result };
|
|
2267
|
+
} catch (error) {
|
|
2268
|
+
console.error("[EventSystem] executeCode error:", error);
|
|
2269
|
+
return { success: false, error };
|
|
2270
|
+
}
|
|
2271
|
+
},
|
|
2238
2272
|
/**
|
|
2239
2273
|
* Copy to clipboard
|
|
2240
2274
|
*/
|
|
@@ -2429,7 +2463,8 @@ var EventSystem = class {
|
|
|
2429
2463
|
const results = [];
|
|
2430
2464
|
for (const action of plugins) {
|
|
2431
2465
|
try {
|
|
2432
|
-
const
|
|
2466
|
+
const pluginKey = action.key || action.type;
|
|
2467
|
+
const executor = this.pluginExecutors[pluginKey];
|
|
2433
2468
|
if (executor) {
|
|
2434
2469
|
const result = await executor(action, eventContext);
|
|
2435
2470
|
results.push(result);
|
|
@@ -2437,11 +2472,12 @@ var EventSystem = class {
|
|
|
2437
2472
|
this.config.onPluginExecute(action, result);
|
|
2438
2473
|
}
|
|
2439
2474
|
} else {
|
|
2440
|
-
console.warn(`[EventSystem] Unknown plugin: ${
|
|
2441
|
-
results.push({ error: `Unknown plugin: ${
|
|
2475
|
+
console.warn(`[EventSystem] Unknown plugin: ${pluginKey}`);
|
|
2476
|
+
results.push({ error: `Unknown plugin: ${pluginKey}` });
|
|
2442
2477
|
}
|
|
2443
2478
|
} catch (error) {
|
|
2444
|
-
|
|
2479
|
+
const pluginKey = action.key || action.type;
|
|
2480
|
+
console.error(`[EventSystem] Plugin error (${pluginKey}):`, error);
|
|
2445
2481
|
results.push({ error });
|
|
2446
2482
|
}
|
|
2447
2483
|
}
|
|
@@ -3439,6 +3475,27 @@ function resolveComponentViewInputs(bindings, context, parentInputs) {
|
|
|
3439
3475
|
if (resolvedValue !== void 0 && typeof resolvedValue === "function") {
|
|
3440
3476
|
resolved[key] = resolvedValue;
|
|
3441
3477
|
}
|
|
3478
|
+
} else if (binding.binding?.type === "servly" && binding.binding?.plugins) {
|
|
3479
|
+
const plugins = binding.binding.plugins;
|
|
3480
|
+
resolved[key] = (event) => {
|
|
3481
|
+
for (const plugin of plugins) {
|
|
3482
|
+
const pluginType = plugin.type || plugin.key;
|
|
3483
|
+
if (pluginType === "executeCode" && plugin.code) {
|
|
3484
|
+
try {
|
|
3485
|
+
const fn = new Function(
|
|
3486
|
+
"event",
|
|
3487
|
+
"props",
|
|
3488
|
+
"state",
|
|
3489
|
+
"context",
|
|
3490
|
+
plugin.code
|
|
3491
|
+
);
|
|
3492
|
+
fn(event, context.props || {}, context.state || {}, context.context || {});
|
|
3493
|
+
} catch (error) {
|
|
3494
|
+
console.error("[Servly] executeCode error:", error);
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3442
3499
|
}
|
|
3443
3500
|
break;
|
|
3444
3501
|
default:
|
package/dist/index.js
CHANGED
|
@@ -1745,6 +1745,40 @@ var builtInPlugins = {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
return { success: true };
|
|
1747
1747
|
},
|
|
1748
|
+
/**
|
|
1749
|
+
* Execute arbitrary JavaScript code
|
|
1750
|
+
* Mirrors: executeCode from builder's FunctionPropExecutor
|
|
1751
|
+
* WARNING: This executes arbitrary code - use with caution in production
|
|
1752
|
+
*/
|
|
1753
|
+
"executeCode": (action, ctx) => {
|
|
1754
|
+
const code = action.code || action.config?.code;
|
|
1755
|
+
if (!code) return { success: false, error: "No code provided" };
|
|
1756
|
+
try {
|
|
1757
|
+
const fn = new Function(
|
|
1758
|
+
"event",
|
|
1759
|
+
"props",
|
|
1760
|
+
"state",
|
|
1761
|
+
"context",
|
|
1762
|
+
"stateManager",
|
|
1763
|
+
"currentItem",
|
|
1764
|
+
"currentIndex",
|
|
1765
|
+
code
|
|
1766
|
+
);
|
|
1767
|
+
const result = fn(
|
|
1768
|
+
ctx.event,
|
|
1769
|
+
ctx.context.props || {},
|
|
1770
|
+
ctx.context.state || {},
|
|
1771
|
+
ctx.context.context || {},
|
|
1772
|
+
ctx.stateManager,
|
|
1773
|
+
ctx.currentItem,
|
|
1774
|
+
ctx.currentIndex
|
|
1775
|
+
);
|
|
1776
|
+
return { success: true, result };
|
|
1777
|
+
} catch (error) {
|
|
1778
|
+
console.error("[EventSystem] executeCode error:", error);
|
|
1779
|
+
return { success: false, error };
|
|
1780
|
+
}
|
|
1781
|
+
},
|
|
1748
1782
|
/**
|
|
1749
1783
|
* Copy to clipboard
|
|
1750
1784
|
*/
|
|
@@ -1939,7 +1973,8 @@ var EventSystem = class {
|
|
|
1939
1973
|
const results = [];
|
|
1940
1974
|
for (const action of plugins) {
|
|
1941
1975
|
try {
|
|
1942
|
-
const
|
|
1976
|
+
const pluginKey = action.key || action.type;
|
|
1977
|
+
const executor = this.pluginExecutors[pluginKey];
|
|
1943
1978
|
if (executor) {
|
|
1944
1979
|
const result = await executor(action, eventContext);
|
|
1945
1980
|
results.push(result);
|
|
@@ -1947,11 +1982,12 @@ var EventSystem = class {
|
|
|
1947
1982
|
this.config.onPluginExecute(action, result);
|
|
1948
1983
|
}
|
|
1949
1984
|
} else {
|
|
1950
|
-
console.warn(`[EventSystem] Unknown plugin: ${
|
|
1951
|
-
results.push({ error: `Unknown plugin: ${
|
|
1985
|
+
console.warn(`[EventSystem] Unknown plugin: ${pluginKey}`);
|
|
1986
|
+
results.push({ error: `Unknown plugin: ${pluginKey}` });
|
|
1952
1987
|
}
|
|
1953
1988
|
} catch (error) {
|
|
1954
|
-
|
|
1989
|
+
const pluginKey = action.key || action.type;
|
|
1990
|
+
console.error(`[EventSystem] Plugin error (${pluginKey}):`, error);
|
|
1955
1991
|
results.push({ error });
|
|
1956
1992
|
}
|
|
1957
1993
|
}
|
|
@@ -2948,6 +2984,27 @@ function resolveComponentViewInputs(bindings, context, parentInputs) {
|
|
|
2948
2984
|
if (resolvedValue !== void 0 && typeof resolvedValue === "function") {
|
|
2949
2985
|
resolved[key] = resolvedValue;
|
|
2950
2986
|
}
|
|
2987
|
+
} else if (binding.binding?.type === "servly" && binding.binding?.plugins) {
|
|
2988
|
+
const plugins = binding.binding.plugins;
|
|
2989
|
+
resolved[key] = (event) => {
|
|
2990
|
+
for (const plugin of plugins) {
|
|
2991
|
+
const pluginType = plugin.type || plugin.key;
|
|
2992
|
+
if (pluginType === "executeCode" && plugin.code) {
|
|
2993
|
+
try {
|
|
2994
|
+
const fn = new Function(
|
|
2995
|
+
"event",
|
|
2996
|
+
"props",
|
|
2997
|
+
"state",
|
|
2998
|
+
"context",
|
|
2999
|
+
plugin.code
|
|
3000
|
+
);
|
|
3001
|
+
fn(event, context.props || {}, context.state || {}, context.context || {});
|
|
3002
|
+
} catch (error) {
|
|
3003
|
+
console.error("[Servly] executeCode error:", error);
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
};
|
|
2951
3008
|
}
|
|
2952
3009
|
break;
|
|
2953
3010
|
default:
|