ai-evaluate 2.1.8 → 2.2.0

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.
Files changed (61) hide show
  1. package/dist/evaluate.d.ts.map +1 -1
  2. package/dist/evaluate.js.map +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/miniflare-pool.d.ts.map +1 -1
  6. package/dist/miniflare-pool.js.map +1 -1
  7. package/dist/node.d.ts.map +1 -1
  8. package/dist/node.js.map +1 -1
  9. package/dist/static/index.d.ts +111 -0
  10. package/dist/static/index.d.ts.map +1 -0
  11. package/dist/static/index.js +347 -0
  12. package/dist/static/index.js.map +1 -0
  13. package/dist/type-guards.d.ts.map +1 -1
  14. package/dist/type-guards.js.map +1 -1
  15. package/dist/worker-template/core.d.ts.map +1 -1
  16. package/dist/worker-template/core.js +1 -1
  17. package/dist/worker-template/core.js.map +1 -1
  18. package/package.json +17 -4
  19. package/public/capnweb.mjs +220 -0
  20. package/public/index.mjs +426 -0
  21. package/public/scaffold.mjs +198 -0
  22. package/.turbo/turbo-build.log +0 -4
  23. package/.turbo/turbo-test.log +0 -54
  24. package/.turbo/turbo-typecheck.log +0 -4
  25. package/CHANGELOG.md +0 -48
  26. package/example/package.json +0 -20
  27. package/example/src/index.ts +0 -221
  28. package/example/wrangler.jsonc +0 -25
  29. package/src/capnweb-bundle.ts +0 -2596
  30. package/src/evaluate.ts +0 -329
  31. package/src/index.ts +0 -23
  32. package/src/miniflare-pool.ts +0 -395
  33. package/src/node.ts +0 -245
  34. package/src/repl.ts +0 -228
  35. package/src/shared.ts +0 -186
  36. package/src/type-guards.ts +0 -323
  37. package/src/types.ts +0 -196
  38. package/src/validation.ts +0 -120
  39. package/src/worker-template/code-transforms.ts +0 -32
  40. package/src/worker-template/core.ts +0 -557
  41. package/src/worker-template/helpers.ts +0 -90
  42. package/src/worker-template/index.ts +0 -23
  43. package/src/worker-template/sdk-generator.ts +0 -2515
  44. package/src/worker-template/test-generator.ts +0 -358
  45. package/test/evaluate-extended.test.js +0 -429
  46. package/test/evaluate-extended.test.ts +0 -469
  47. package/test/evaluate.test.js +0 -235
  48. package/test/evaluate.test.ts +0 -253
  49. package/test/index.test.js +0 -77
  50. package/test/index.test.ts +0 -95
  51. package/test/miniflare-pool.test.ts +0 -246
  52. package/test/node.test.ts +0 -467
  53. package/test/security.test.ts +0 -1009
  54. package/test/shared.test.ts +0 -105
  55. package/test/type-guards.test.ts +0 -303
  56. package/test/validation.test.ts +0 -240
  57. package/test/worker-template.test.js +0 -365
  58. package/test/worker-template.test.ts +0 -432
  59. package/tsconfig.json +0 -22
  60. package/vitest.config.js +0 -21
  61. package/vitest.config.ts +0 -28
@@ -1,557 +0,0 @@
1
- /**
2
- * Worker scaffold and main template generation
3
- *
4
- * This module contains the main generateWorkerCode and generateDevWorkerCode functions
5
- * that produce the complete worker code for sandbox execution.
6
- */
7
-
8
- import type { SDKConfig, FetchConfig } from '../types.js'
9
- import { getExportNames, wrapScriptForReturn } from './helpers.js'
10
- import { transformModuleCode } from './code-transforms.js'
11
- import { generateSDKCode, generateShouldCode } from './sdk-generator.js'
12
- import { generateTestFrameworkCode, generateTestRunnerCode } from './test-generator.js'
13
- import { generateDomainCheckCode } from '../shared.js'
14
-
15
- /**
16
- * Generate worker code for production (uses RPC to ai-tests)
17
- */
18
- export function generateWorkerCode(options: {
19
- module?: string | undefined
20
- tests?: string | undefined
21
- script?: string | undefined
22
- sdk?: SDKConfig | boolean | undefined
23
- imports?: string[] | undefined
24
- fetch?: FetchConfig
25
- }): string {
26
- const {
27
- module: rawModule = '',
28
- tests = '',
29
- script: rawScript = '',
30
- sdk,
31
- imports = [],
32
- fetch: fetchOption,
33
- } = options
34
- const sdkConfig = sdk === true ? {} : sdk || null
35
- const module = rawModule ? transformModuleCode(rawModule) : ''
36
- const script = rawScript ? wrapScriptForReturn(rawScript) : ''
37
- const exportNames = getExportNames(rawModule)
38
-
39
- // Hoisted imports (from MDX test files) - placed at true module top level
40
- const hoistedImports = imports.length > 0 ? imports.join('\n') + '\n' : ''
41
-
42
- // Generate fetch control code for allowlist (block is handled by globalOutbound)
43
- const allowlistDomains = Array.isArray(fetchOption) ? fetchOption : null
44
- const fetchControlCode = allowlistDomains ? generateDomainCheckCode(allowlistDomains) : ''
45
-
46
- return `
47
- // Sandbox Worker Entry Point
48
- import { RpcTarget, newWorkersRpcResponse } from 'capnweb.js';
49
- ${hoistedImports}
50
- const logs = [];
51
-
52
- ${fetchControlCode}
53
-
54
- ${sdkConfig ? generateShouldCode() : ''}
55
-
56
- ${sdkConfig ? generateSDKCode(sdkConfig) : '// SDK not enabled'}
57
-
58
- // Capture console output
59
- const originalConsole = { ...console };
60
- const captureConsole = (level) => (...args) => {
61
- logs.push({
62
- level,
63
- message: args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '),
64
- timestamp: Date.now()
65
- });
66
- originalConsole[level](...args);
67
- };
68
- console.log = captureConsole('log');
69
- console.warn = captureConsole('warn');
70
- console.error = captureConsole('error');
71
- console.info = captureConsole('info');
72
- console.debug = captureConsole('debug');
73
-
74
- // ============================================================
75
- // USER MODULE CODE (embedded at generation time)
76
- // ============================================================
77
- // Module exports object - exports become top-level variables
78
- const exports = {};
79
-
80
- ${
81
- module
82
- ? `
83
- // Execute module code
84
- try {
85
- ${module}
86
- } catch (e) {
87
- console.error('Module error:', e.message);
88
- }
89
- `
90
- : '// No module code provided'
91
- }
92
-
93
- // Expose all exports as top-level variables for tests and scripts
94
- // This allows: export const add = (a, b) => a + b; then later: add(1, 2)
95
- ${
96
- rawModule
97
- ? `
98
- const { ${exportNames} } = exports;
99
- `.trim()
100
- : ''
101
- }
102
-
103
- // ============================================================
104
- // RPC SERVER - Expose exports via capnweb
105
- // ============================================================
106
- class ExportsRpcTarget extends RpcTarget {
107
- // Dynamically expose all exports as RPC methods
108
- constructor() {
109
- super();
110
- for (const [key, value] of Object.entries(exports)) {
111
- if (typeof value === 'function') {
112
- this[key] = value;
113
- }
114
- }
115
- }
116
-
117
- // List available exports
118
- list() {
119
- return Object.keys(exports);
120
- }
121
-
122
- // Get an export by name
123
- get(name) {
124
- return exports[name];
125
- }
126
- }
127
-
128
- // ============================================================
129
- // WORKER ENTRY POINT
130
- // ============================================================
131
- export default {
132
- async fetch(request, env) {
133
- const url = new URL(request.url);
134
-
135
- // Route: GET / - Return info about exports
136
- if (request.method === 'GET' && url.pathname === '/') {
137
- return Response.json({
138
- exports: Object.keys(exports),
139
- rpc: '/rpc',
140
- execute: '/execute'
141
- });
142
- }
143
-
144
- // Route: /rpc - capnweb RPC to module exports
145
- if (url.pathname === '/rpc') {
146
- return newWorkersRpcResponse(request, new ExportsRpcTarget());
147
- }
148
-
149
- // Route: GET /:name - Simple JSON endpoint to access exports
150
- if (request.method === 'GET' && url.pathname !== '/execute') {
151
- const name = url.pathname.slice(1); // Remove leading /
152
- const value = exports[name];
153
-
154
- // Check if export exists
155
- if (!(name in exports)) {
156
- return Response.json({ error: \`Export "\${name}" not found\` }, { status: 404 });
157
- }
158
-
159
- // If it's not a function, just return the value
160
- if (typeof value !== 'function') {
161
- return Response.json({ result: value });
162
- }
163
-
164
- // It's a function - parse args and call it
165
- try {
166
- const args = [];
167
- const argsParam = url.searchParams.get('args');
168
- if (argsParam) {
169
- // Support JSON array: ?args=[1,2,3]
170
- try {
171
- const parsed = JSON.parse(argsParam);
172
- if (Array.isArray(parsed)) {
173
- args.push(...parsed);
174
- } else {
175
- args.push(parsed);
176
- }
177
- } catch {
178
- // Not JSON, use as single string arg
179
- args.push(argsParam);
180
- }
181
- } else {
182
- // Support named params: ?a=1&b=2 -> passed as object
183
- const params = Object.fromEntries(url.searchParams.entries());
184
- if (Object.keys(params).length > 0) {
185
- // Try to parse numeric values
186
- for (const [key, val] of Object.entries(params)) {
187
- const num = Number(val);
188
- params[key] = !isNaN(num) && val !== '' ? num : val;
189
- }
190
- args.push(params);
191
- }
192
- }
193
-
194
- const result = await value(...args);
195
- return Response.json({ result });
196
- } catch (e) {
197
- return Response.json({ error: e.message }, { status: 500 });
198
- }
199
- }
200
-
201
- // Route: /execute - Run tests and scripts
202
- // Check for TEST service binding
203
- if (!env.TEST) {
204
- return Response.json({
205
- success: false,
206
- error: 'TEST service binding not available. Ensure ai-tests worker is bound.',
207
- logs,
208
- duration: 0
209
- });
210
- }
211
-
212
- // Connect to get the TestServiceCore via RPC
213
- const testService = await env.TEST.connect();
214
-
215
- // Create global test functions that proxy to the RPC service
216
- const describe = (name, fn) => testService.describe(name, fn);
217
- const it = (name, fn) => testService.it(name, fn);
218
- const test = (name, fn) => testService.test(name, fn);
219
- const expect = (value, message) => testService.expect(value, message);
220
- const should = (value) => testService.should(value);
221
- const assert = testService.assert;
222
- const beforeEach = (fn) => testService.beforeEach(fn);
223
- const afterEach = (fn) => testService.afterEach(fn);
224
- const beforeAll = (fn) => testService.beforeAll(fn);
225
- const afterAll = (fn) => testService.afterAll(fn);
226
-
227
- // Add skip/only modifiers
228
- it.skip = (name, fn) => testService.skip(name, fn);
229
- it.only = (name, fn) => testService.only(name, fn);
230
- test.skip = it.skip;
231
- test.only = it.only;
232
-
233
- let scriptResult = undefined;
234
- let scriptError = null;
235
- let testResults = undefined;
236
-
237
- // ============================================================
238
- // USER TEST CODE (embedded at generation time)
239
- // ============================================================
240
-
241
- ${
242
- tests
243
- ? `
244
- // Register tests
245
- try {
246
- ${tests}
247
- } catch (e) {
248
- console.error('Test registration error:', e.message);
249
- }
250
- `
251
- : '// No test code provided'
252
- }
253
-
254
- // Execute user script
255
- ${
256
- script
257
- ? `
258
- try {
259
- scriptResult = await (async () => {
260
- ${script}
261
- })();
262
- } catch (e) {
263
- console.error('Script error:', e.message);
264
- scriptError = e.message;
265
- }
266
- `
267
- : '// No script code provided'
268
- }
269
-
270
- // Run tests if any were registered
271
- ${
272
- tests
273
- ? `
274
- try {
275
- testResults = await testService.run();
276
- } catch (e) {
277
- console.error('Test run error:', e.message);
278
- testResults = { total: 0, passed: 0, failed: 1, skipped: 0, tests: [], duration: 0, error: e.message };
279
- }
280
- `
281
- : ''
282
- }
283
-
284
- const hasTests = ${tests ? 'true' : 'false'};
285
- const success = scriptError === null && (!hasTests || (testResults && testResults.failed === 0));
286
-
287
- return Response.json({
288
- success,
289
- value: scriptResult,
290
- logs,
291
- testResults: hasTests ? testResults : undefined,
292
- error: scriptError || undefined,
293
- duration: 0
294
- });
295
- }
296
- };
297
- `
298
- }
299
-
300
- /**
301
- * Generate worker code for development (embedded test framework)
302
- *
303
- * This version bundles the test framework directly into the worker,
304
- * avoiding the need for RPC service bindings in local development.
305
- */
306
- export function generateDevWorkerCode(options: {
307
- module?: string | undefined
308
- tests?: string | undefined
309
- script?: string | undefined
310
- sdk?: SDKConfig | boolean | undefined
311
- imports?: string[] | undefined
312
- fetch?: null | FetchConfig | undefined
313
- }): string {
314
- const {
315
- module: rawModule = '',
316
- tests = '',
317
- script: rawScript = '',
318
- sdk,
319
- imports = [],
320
- fetch: fetchOption,
321
- } = options
322
- const sdkConfig = sdk === true ? {} : sdk || null
323
- const module = rawModule ? transformModuleCode(rawModule) : ''
324
- const script = rawScript ? wrapScriptForReturn(rawScript) : ''
325
- const exportNames = getExportNames(rawModule)
326
-
327
- // Determine fetch handling mode
328
- // - false or null -> block all network
329
- // - string[] -> domain allowlist
330
- // - true or undefined -> allow all (no wrapper needed)
331
- const blockFetch = fetchOption === false || fetchOption === null
332
- const allowlistDomains = Array.isArray(fetchOption) ? fetchOption : null
333
-
334
- // Hoisted imports (from MDX test files) - placed at true module top level
335
- const hoistedImports = imports.length > 0 ? imports.join('\n') + '\n' : ''
336
-
337
- // Generate fetch control code based on mode
338
- let fetchControlCode = ''
339
- if (blockFetch) {
340
- fetchControlCode = `
341
- // Block fetch when fetch: false or null is specified
342
- const __originalFetch__ = globalThis.fetch;
343
- globalThis.fetch = async (...args) => {
344
- throw new Error('Network access blocked: fetch is disabled in this sandbox');
345
- };
346
- `
347
- } else if (allowlistDomains) {
348
- fetchControlCode = generateDomainCheckCode(allowlistDomains)
349
- }
350
-
351
- return `
352
- // Sandbox Worker Entry Point (Dev Mode - embedded test framework)
353
- ${hoistedImports}
354
- const logs = [];
355
- const testResults = { total: 0, passed: 0, failed: 0, skipped: 0, tests: [], duration: 0 };
356
- const pendingTests = [];
357
-
358
- ${fetchControlCode}
359
-
360
- ${sdkConfig ? generateShouldCode() : ''}
361
-
362
- ${sdkConfig ? generateSDKCode(sdkConfig) : '// SDK not enabled'}
363
-
364
- // Capture console output
365
- const originalConsole = { ...console };
366
- const captureConsole = (level) => (...args) => {
367
- logs.push({
368
- level,
369
- message: args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '),
370
- timestamp: Date.now()
371
- });
372
- originalConsole[level](...args);
373
- };
374
- console.log = captureConsole('log');
375
- console.warn = captureConsole('warn');
376
- console.error = captureConsole('error');
377
- console.info = captureConsole('info');
378
- console.debug = captureConsole('debug');
379
-
380
- ${generateTestFrameworkCode()}
381
-
382
- // ============================================================
383
- // USER MODULE CODE (embedded at generation time)
384
- // ============================================================
385
- // Module exports object - exports become top-level variables
386
- const exports = {};
387
-
388
- ${
389
- module
390
- ? `
391
- // Execute module code
392
- try {
393
- ${module}
394
- } catch (e) {
395
- console.error('Module error:', e.message);
396
- }
397
- `
398
- : '// No module code provided'
399
- }
400
-
401
- // Expose all exports as top-level variables for tests and scripts
402
- // This allows: export const add = (a, b) => a + b; then later: add(1, 2)
403
- ${
404
- rawModule
405
- ? `
406
- const { ${exportNames} } = exports;
407
- `.trim()
408
- : ''
409
- }
410
-
411
- // ============================================================
412
- // USER TEST CODE (embedded at generation time)
413
- // ============================================================
414
- ${
415
- tests
416
- ? `
417
- // Register tests
418
- try {
419
- ${tests}
420
- } catch (e) {
421
- console.error('Test registration error:', e.message);
422
- }
423
- `
424
- : '// No test code provided'
425
- }
426
-
427
- // ============================================================
428
- // SIMPLE RPC HANDLER (dev mode - no capnweb dependency)
429
- // ============================================================
430
- async function handleRpc(request) {
431
- try {
432
- const { method, args = [] } = await request.json();
433
- if (method === 'list') {
434
- return Response.json({ result: Object.keys(exports) });
435
- }
436
- if (method === 'get') {
437
- const [name] = args;
438
- const value = exports[name];
439
- if (typeof value === 'function') {
440
- return Response.json({ result: { type: 'function', name } });
441
- }
442
- return Response.json({ result: value });
443
- }
444
- // Call an exported function
445
- const fn = exports[method];
446
- if (typeof fn !== 'function') {
447
- return Response.json({ error: \`Export "\${method}" is not a function\` }, { status: 400 });
448
- }
449
- const result = await fn(...args);
450
- return Response.json({ result });
451
- } catch (e) {
452
- return Response.json({ error: e.message }, { status: 500 });
453
- }
454
- }
455
-
456
- // ============================================================
457
- // WORKER ENTRY POINT
458
- // ============================================================
459
- export default {
460
- async fetch(request, env) {
461
- const url = new URL(request.url);
462
-
463
- // Route: GET / - Return info about exports
464
- if (request.method === 'GET' && url.pathname === '/') {
465
- return Response.json({
466
- exports: Object.keys(exports),
467
- rpc: '/rpc',
468
- execute: '/execute'
469
- });
470
- }
471
-
472
- // Route: POST /rpc - Simple RPC to module exports
473
- if (url.pathname === '/rpc' && request.method === 'POST') {
474
- return handleRpc(request);
475
- }
476
-
477
- // Route: GET /:name - Simple JSON endpoint to access exports
478
- if (request.method === 'GET' && url.pathname !== '/execute') {
479
- const name = url.pathname.slice(1);
480
- const value = exports[name];
481
-
482
- // Check if export exists
483
- if (!(name in exports)) {
484
- return Response.json({ error: \`Export "\${name}" not found\` }, { status: 404 });
485
- }
486
-
487
- // If it's not a function, just return the value
488
- if (typeof value !== 'function') {
489
- return Response.json({ result: value });
490
- }
491
-
492
- // It's a function - parse args and call it
493
- try {
494
- const args = [];
495
- const argsParam = url.searchParams.get('args');
496
- if (argsParam) {
497
- try {
498
- const parsed = JSON.parse(argsParam);
499
- if (Array.isArray(parsed)) args.push(...parsed);
500
- else args.push(parsed);
501
- } catch {
502
- args.push(argsParam);
503
- }
504
- } else {
505
- const params = Object.fromEntries(url.searchParams.entries());
506
- if (Object.keys(params).length > 0) {
507
- for (const [key, val] of Object.entries(params)) {
508
- const num = Number(val);
509
- params[key] = !isNaN(num) && val !== '' ? num : val;
510
- }
511
- args.push(params);
512
- }
513
- }
514
- const result = await value(...args);
515
- return Response.json({ result });
516
- } catch (e) {
517
- return Response.json({ error: e.message }, { status: 500 });
518
- }
519
- }
520
-
521
- // Route: /execute - Run tests and scripts
522
- let scriptResult = undefined;
523
- let scriptError = null;
524
-
525
- // Execute user script
526
- ${
527
- script
528
- ? `
529
- try {
530
- scriptResult = await (async () => {
531
- ${script}
532
- })();
533
- } catch (e) {
534
- console.error('Script error:', e.message);
535
- scriptError = e.message;
536
- }
537
- `
538
- : '// No script code provided'
539
- }
540
-
541
- ${generateTestRunnerCode()}
542
-
543
- const hasTests = ${tests ? 'true' : 'false'};
544
- const success = scriptError === null && (!hasTests || testResults.failed === 0);
545
-
546
- return Response.json({
547
- success,
548
- value: scriptResult,
549
- logs,
550
- testResults: hasTests ? testResults : undefined,
551
- error: scriptError || undefined,
552
- duration: 0
553
- });
554
- }
555
- };
556
- `
557
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * Shared utility functions for worker template generation
3
- */
4
-
5
- /**
6
- * Extract export names from module code
7
- * Supports both CommonJS (exports.foo) and ES module (export const foo) syntax
8
- */
9
- export function getExportNames(moduleCode: string): string {
10
- const names = new Set<string>()
11
-
12
- // Match exports.name = ...
13
- const dotPattern = /exports\.(\w+)\s*=/g
14
- let match
15
- while ((match = dotPattern.exec(moduleCode)) !== null) {
16
- if (match[1]) names.add(match[1])
17
- }
18
-
19
- // Match exports['name'] = ... or exports["name"] = ...
20
- const bracketPattern = /exports\[['"](\w+)['"]\]\s*=/g
21
- while ((match = bracketPattern.exec(moduleCode)) !== null) {
22
- if (match[1]) names.add(match[1])
23
- }
24
-
25
- // Match export const name = ... or export let name = ... or export var name = ...
26
- const esConstPattern = /export\s+(?:const|let|var)\s+(\w+)\s*=/g
27
- while ((match = esConstPattern.exec(moduleCode)) !== null) {
28
- if (match[1]) names.add(match[1])
29
- }
30
-
31
- // Match export function name(...) or export async function name(...) or export async function* name(...)
32
- const esFunctionPattern = /export\s+(?:async\s+)?function\*?\s+(\w+)\s*\(/g
33
- while ((match = esFunctionPattern.exec(moduleCode)) !== null) {
34
- if (match[1]) names.add(match[1])
35
- }
36
-
37
- // Match export class name
38
- const esClassPattern = /export\s+class\s+(\w+)/g
39
- while ((match = esClassPattern.exec(moduleCode)) !== null) {
40
- if (match[1]) names.add(match[1])
41
- }
42
-
43
- return Array.from(names).join(', ') || '_unused'
44
- }
45
-
46
- /**
47
- * Wrap script to auto-return the last expression
48
- * Converts: `add(1, 2)` -> `return add(1, 2)`
49
- */
50
- export function wrapScriptForReturn(script: string): string {
51
- const trimmed = script.trim()
52
- if (!trimmed) return script
53
-
54
- // If script already contains a return statement anywhere, don't modify
55
- if (/\breturn\b/.test(trimmed)) return script
56
-
57
- // If script starts with throw, don't modify
58
- if (/^\s*throw\b/.test(trimmed)) return script
59
-
60
- // If it's a single expression (no newlines, no semicolons except at end), wrap it
61
- const withoutTrailingSemi = trimmed.replace(/;?\s*$/, '')
62
- const isSingleLine = !withoutTrailingSemi.includes('\n')
63
-
64
- // Check if it looks like a single expression (no control flow, no declarations)
65
- const startsWithKeyword =
66
- /^\s*(const|let|var|if|for|while|switch|try|class|function|async\s+function)\b/.test(
67
- withoutTrailingSemi
68
- )
69
-
70
- if (isSingleLine && !startsWithKeyword) {
71
- return `return ${withoutTrailingSemi}`
72
- }
73
-
74
- // For multi-statement scripts, try to return the last expression
75
- const lines = trimmed.split('\n')
76
- const lastLineRaw = lines[lines.length - 1]
77
- if (!lastLineRaw) return script
78
- const lastLine = lastLineRaw.trim()
79
-
80
- // If last line is an expression (not a declaration, control flow, or throw)
81
- if (
82
- lastLine &&
83
- !/^\s*(const|let|var|if|for|while|switch|try|class|function|return|throw)\b/.test(lastLine)
84
- ) {
85
- lines[lines.length - 1] = `return ${lastLine.replace(/;?\s*$/, '')}`
86
- return lines.join('\n')
87
- }
88
-
89
- return script
90
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Worker template module for sandbox execution
3
- *
4
- * This module provides functions to generate worker code for sandboxed execution.
5
- * The generated code is stringified and sent to the worker loader.
6
- *
7
- * @module worker-template
8
- */
9
-
10
- // Main public API - worker code generators
11
- export { generateWorkerCode, generateDevWorkerCode } from './core.js'
12
-
13
- // SDK code generation (local and remote modes)
14
- export { generateSDKCode, generateShouldCode } from './sdk-generator.js'
15
-
16
- // Test framework embedding
17
- export { generateTestFrameworkCode, generateTestRunnerCode } from './test-generator.js'
18
-
19
- // Module transformation and export detection
20
- export { transformModuleCode } from './code-transforms.js'
21
-
22
- // Shared utility functions
23
- export { getExportNames, wrapScriptForReturn } from './helpers.js'