cbs-block 1.0.5 → 1.0.6
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/bin/cbs-block.js +6 -4
- package/package.json +1 -1
package/bin/cbs-block.js
CHANGED
|
@@ -106,7 +106,9 @@ async function main() {
|
|
|
106
106
|
// Simple bundle logic: find imports and Warn for now (Premium feature for Phase 15.1)
|
|
107
107
|
// For now, we wrap it into a compatible run function for the engine
|
|
108
108
|
if (logic.includes('export function run')) {
|
|
109
|
-
logic = logic.replace(
|
|
109
|
+
logic = logic.replace(/export\s+function\s+run/g, 'function run');
|
|
110
|
+
} else if (logic.includes('export const run')) {
|
|
111
|
+
logic = logic.replace(/export\s+const\s+run\s*=\s*/g, 'function run');
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
metadata.logic = logic;
|
|
@@ -206,7 +208,7 @@ async function main() {
|
|
|
206
208
|
const block = JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
207
209
|
console.log(chalk.yellow(`Testing logic for: ${block.name}...`));
|
|
208
210
|
try {
|
|
209
|
-
const run = new Function('inputs',
|
|
211
|
+
const run = new Function('inputs', block.logic + '\nreturn run(inputs);');
|
|
210
212
|
const testResult = run({ input1: "Test Input" });
|
|
211
213
|
console.log(chalk.green(`\n✔ Test Passed! Output: ${testResult}`));
|
|
212
214
|
} catch (e) {
|
|
@@ -232,7 +234,7 @@ async function main() {
|
|
|
232
234
|
console.log(chalk.cyan(`\n[CHANGE] Re-testing ${target}...`));
|
|
233
235
|
try {
|
|
234
236
|
const block = JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
235
|
-
const run = new Function('inputs',
|
|
237
|
+
const run = new Function('inputs', block.logic + '\nreturn run(inputs);');
|
|
236
238
|
const result = run({ input1: "Watch Input" });
|
|
237
239
|
console.log(chalk.green(`✔ Test Passed: ${result}`));
|
|
238
240
|
} catch (e) {
|
|
@@ -260,7 +262,7 @@ async function main() {
|
|
|
260
262
|
const block = JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
261
263
|
console.log(chalk.yellow(`Benchmarking: ${block.name} (100,000 iterations)...`));
|
|
262
264
|
try {
|
|
263
|
-
const run = new Function('inputs',
|
|
265
|
+
const run = new Function('inputs', block.logic + '\nreturn run(inputs);');
|
|
264
266
|
const start = performance.now();
|
|
265
267
|
for(let i=0; i<100000; i++) run({ input1: "bench" });
|
|
266
268
|
const end = performance.now();
|