1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// debug-sandbox.js - Debug the sandbox structure
import { createDefaultJSBridge } from './src/core/js-bridge.js';
const bridge = createDefaultJSBridge({
allowedFunctions: new Set([
'JSON.parse', 'JSON.stringify',
'Math.abs', 'Math.floor', 'Math.ceil', 'Math.round',
'Math.min', 'Math.max', 'Math.random',
'console.log', 'console.warn', 'console.error',
'Date.now', 'performance.now'
])
});
console.log('Sandbox keys:', Object.keys(bridge.config.sandbox));
console.log('Math object:', bridge.config.sandbox.Math);
console.log('Math.abs:', bridge.config.sandbox.Math.abs);
console.log('typeof Math.abs:', typeof bridge.config.sandbox.Math.abs);
// Test function resolution
const fn = bridge.resolveFunction('Math.abs');
console.log('Resolved function:', fn);
console.log('Function type:', typeof fn);
// Test function call
const result = bridge.callFunction('Math.abs', [-5]);
console.log('Call result:', result);
|