@@ -27,35 +27,47 @@ async function main() {
2727 console . log ( '2. Registering user modules...' ) ;
2828
2929 // A constants module — other modules can import from it
30- sandbox . addModule ( 'constants' , `
30+ sandbox . addModule (
31+ 'constants' ,
32+ `
3133 export const PI = 3.14159;
3234 export const E = 2.71828;
33- ` ) ;
35+ `
36+ ) ;
3437
3538 // A geometry module that depends on the constants module
36- sandbox . addModule ( 'geometry' , `
39+ sandbox . addModule (
40+ 'geometry' ,
41+ `
3742 import { PI } from 'user:constants';
3843 export function circleArea(radius) { return PI * radius * radius; }
3944 export function circleCircumference(radius) { return 2 * PI * radius; }
40- ` ) ;
45+ `
46+ ) ;
4147
4248 // A string utils module with a custom namespace
43- sandbox . addModule ( 'strings' , `
49+ sandbox . addModule (
50+ 'strings' ,
51+ `
4452 export function capitalize(s) {
4553 return s.charAt(0).toUpperCase() + s.slice(1);
4654 }
4755 export function reverse(s) {
4856 return s.split('').reverse().join('');
4957 }
50- ` , 'mylib' ) ; // custom namespace → import from 'mylib:strings'
58+ ` ,
59+ 'mylib'
60+ ) ; // custom namespace → import from 'mylib:strings'
5161
5262 console . log ( ' ✓ 3 modules registered (2 default namespace, 1 custom)\n' ) ;
5363
5464 // ── Add handlers that import the modules ─────────────────────────
5565 console . log ( '3. Adding handlers...' ) ;
5666
5767 // Handler 1: uses geometry module (which transitively imports constants)
58- sandbox . addHandler ( 'circle' , `
68+ sandbox . addHandler (
69+ 'circle' ,
70+ `
5971 import { circleArea, circleCircumference } from 'user:geometry';
6072
6173 function handler(event) {
@@ -65,10 +77,13 @@ async function main() {
6577 circumference: circleCircumference(event.radius),
6678 };
6779 }
68- ` ) ;
80+ `
81+ ) ;
6982
7083 // Handler 2: uses the custom-namespace strings module
71- sandbox . addHandler ( 'strings' , `
84+ sandbox . addHandler (
85+ 'strings' ,
86+ `
7287 import { capitalize, reverse } from 'mylib:strings';
7388
7489 function handler(event) {
@@ -78,7 +93,8 @@ async function main() {
7893 reversed: reverse(event.text),
7994 };
8095 }
81- ` ) ;
96+ `
97+ ) ;
8298
8399 const loaded = await sandbox . getLoadedSandbox ( ) ;
84100 console . log ( ' ✓ Handlers loaded\n' ) ;
0 commit comments