@vibes.diy/api-svc 14.3.20 → 14.3.22

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 (110) hide show
  1. package/create-handler.d.ts +2 -0
  2. package/create-handler.js +1 -0
  3. package/create-handler.js.map +1 -1
  4. package/index.d.ts +2 -0
  5. package/index.js +2 -0
  6. package/index.js.map +1 -1
  7. package/intern/agent-assembly.d.ts +2 -0
  8. package/intern/agent-assembly.js +2 -2
  9. package/intern/agent-assembly.js.map +1 -1
  10. package/intern/agent-build-tools.d.ts +7 -0
  11. package/intern/agent-build-tools.js +14 -3
  12. package/intern/agent-build-tools.js.map +1 -1
  13. package/intern/agent-dispatcher.js +66 -25
  14. package/intern/agent-dispatcher.js.map +1 -1
  15. package/intern/agent-request-frame.d.ts +9 -0
  16. package/intern/agent-request-frame.js +14 -0
  17. package/intern/agent-request-frame.js.map +1 -1
  18. package/intern/agent-router.js +1 -1
  19. package/intern/agent-router.js.map +1 -1
  20. package/intern/agent-session.d.ts +1 -1
  21. package/intern/agent-session.js +1 -1
  22. package/intern/agent-session.js.map +1 -1
  23. package/intern/attach-draft-handle.js +51 -8
  24. package/intern/attach-draft-handle.js.map +1 -1
  25. package/intern/draft-lane-autofix.d.ts +8 -0
  26. package/intern/draft-lane-autofix.js +8 -0
  27. package/intern/draft-lane-autofix.js.map +1 -0
  28. package/intern/draft-lane-classify.d.ts +55 -0
  29. package/intern/draft-lane-classify.js +168 -0
  30. package/intern/draft-lane-classify.js.map +1 -0
  31. package/intern/draft-lane-config.d.ts +16 -0
  32. package/intern/draft-lane-config.js +25 -0
  33. package/intern/draft-lane-config.js.map +1 -0
  34. package/intern/draft-lane-exports.d.ts +7 -0
  35. package/intern/draft-lane-exports.js +102 -0
  36. package/intern/draft-lane-exports.js.map +1 -0
  37. package/intern/draft-lane-imports.d.ts +6 -0
  38. package/intern/draft-lane-imports.js +180 -0
  39. package/intern/draft-lane-imports.js.map +1 -0
  40. package/intern/draft-lane-opens.d.ts +6 -0
  41. package/intern/draft-lane-opens.js +173 -0
  42. package/intern/draft-lane-opens.js.map +1 -0
  43. package/intern/draft-lane-parse.d.ts +16 -0
  44. package/intern/draft-lane-parse.js +104 -0
  45. package/intern/draft-lane-parse.js.map +1 -0
  46. package/intern/draft-lane-persist.d.ts +26 -0
  47. package/intern/draft-lane-persist.js +92 -0
  48. package/intern/draft-lane-persist.js.map +1 -0
  49. package/intern/draft-lane-prompt.d.ts +16 -0
  50. package/intern/draft-lane-prompt.js +59 -0
  51. package/intern/draft-lane-prompt.js.map +1 -0
  52. package/intern/draft-lane-store.d.ts +36 -0
  53. package/intern/draft-lane-store.js +5 -0
  54. package/intern/draft-lane-store.js.map +1 -0
  55. package/intern/draft-lane-transport.d.ts +3 -0
  56. package/intern/draft-lane-transport.js +58 -0
  57. package/intern/draft-lane-transport.js.map +1 -0
  58. package/intern/draft-lane-worker.d.ts +37 -0
  59. package/intern/draft-lane-worker.js +156 -0
  60. package/intern/draft-lane-worker.js.map +1 -0
  61. package/intern/draft-lane.d.ts +60 -0
  62. package/intern/draft-lane.js +148 -0
  63. package/intern/draft-lane.js.map +1 -0
  64. package/intern/eval-handles.d.ts +2 -1
  65. package/intern/eval-handles.js +2 -1
  66. package/intern/eval-handles.js.map +1 -1
  67. package/intern/first-build-request.js +5 -1
  68. package/intern/first-build-request.js.map +1 -1
  69. package/intern/import-synth.d.ts +25 -0
  70. package/intern/import-synth.js +456 -0
  71. package/intern/import-synth.js.map +1 -0
  72. package/intern/inline-build-pass.d.ts +23 -0
  73. package/intern/inline-build-pass.js +27 -0
  74. package/intern/inline-build-pass.js.map +1 -0
  75. package/intern/look-lint-engine.d.ts +9 -0
  76. package/intern/look-lint-engine.js +22 -0
  77. package/intern/look-lint-engine.js.map +1 -1
  78. package/intern/look-lint.d.ts +1 -0
  79. package/intern/look-lint.js +4 -1
  80. package/intern/look-lint.js.map +1 -1
  81. package/intern/mint-job-store.d.ts +50 -2
  82. package/intern/mint-job-store.js +149 -4
  83. package/intern/mint-job-store.js.map +1 -1
  84. package/intern/opens-check.d.ts +14 -0
  85. package/intern/opens-check.js +1044 -0
  86. package/intern/opens-check.js.map +1 -0
  87. package/intern/prompt-assembly.d.ts +19 -0
  88. package/intern/prompt-assembly.js +7 -4
  89. package/intern/prompt-assembly.js.map +1 -1
  90. package/intern/save-build-pass.d.ts +15 -0
  91. package/intern/save-build-pass.js +53 -0
  92. package/intern/save-build-pass.js.map +1 -0
  93. package/package.json +13 -12
  94. package/public/agent-turn-assembly.js +16 -0
  95. package/public/agent-turn-assembly.js.map +1 -1
  96. package/public/handle-prompt-context.d.ts +3 -1
  97. package/public/handle-prompt-context.js +39 -4
  98. package/public/handle-prompt-context.js.map +1 -1
  99. package/public/home-feed-common.js +2 -2
  100. package/public/home-feed-common.js.map +1 -1
  101. package/public/open-chat.d.ts +2 -0
  102. package/public/open-chat.js +80 -11
  103. package/public/open-chat.js.map +1 -1
  104. package/public/related-vibes.js +9 -3
  105. package/public/related-vibes.js.map +1 -1
  106. package/public/shared-mint.d.ts +5 -0
  107. package/public/shared-mint.js +15 -0
  108. package/public/shared-mint.js.map +1 -1
  109. package/types.d.ts +2 -0
  110. package/types.js.map +1 -1
@@ -0,0 +1,1044 @@
1
+ import { exception2Result } from "@adviser/cement";
2
+ import { Parser } from "acorn";
3
+ import acornJsx from "acorn-jsx";
4
+ import { transform } from "sucrase";
5
+ import { lockedGroupsVersions } from "./grouped-vibe-import-map.js";
6
+ export const OPENS_ADVISORY_CLASSES = new Set(["unknown-package"]);
7
+ const LOOK_EXPORTS = [
8
+ "Avatar",
9
+ "AvatarFallback",
10
+ "Badge",
11
+ "Button",
12
+ "Card",
13
+ "CardContent",
14
+ "CardDescription",
15
+ "CardFooter",
16
+ "CardHeader",
17
+ "CardTitle",
18
+ "Dialog",
19
+ "DialogContent",
20
+ "DialogDescription",
21
+ "DialogFooter",
22
+ "DialogHeader",
23
+ "DialogTitle",
24
+ "DialogTrigger",
25
+ "DropdownMenu",
26
+ "DropdownMenuContent",
27
+ "DropdownMenuItem",
28
+ "DropdownMenuTrigger",
29
+ "Input",
30
+ "LOOK_CLASS_CANDIDATES",
31
+ "Label",
32
+ "Popover",
33
+ "PopoverContent",
34
+ "PopoverTrigger",
35
+ "Progress",
36
+ "Select",
37
+ "SelectContent",
38
+ "SelectItem",
39
+ "SelectTrigger",
40
+ "SelectValue",
41
+ "Separator",
42
+ "Sheet",
43
+ "SheetContent",
44
+ "SheetDescription",
45
+ "SheetFooter",
46
+ "SheetHeader",
47
+ "SheetTitle",
48
+ "SheetTrigger",
49
+ "Skeleton",
50
+ "Table",
51
+ "TableBody",
52
+ "TableCell",
53
+ "TableHead",
54
+ "TableHeader",
55
+ "TableRow",
56
+ "Tabs",
57
+ "TabsContent",
58
+ "TabsList",
59
+ "TabsTrigger",
60
+ "Textarea",
61
+ "Tooltip",
62
+ "TooltipContent",
63
+ "TooltipProvider",
64
+ "TooltipTrigger",
65
+ "cn",
66
+ ];
67
+ const LOOK_OVERLAY_EXPORTS = [
68
+ "Dialog",
69
+ "DialogContent",
70
+ "DialogDescription",
71
+ "DialogFooter",
72
+ "DialogHeader",
73
+ "DialogTitle",
74
+ "DialogTrigger",
75
+ "DropdownMenu",
76
+ "DropdownMenuContent",
77
+ "DropdownMenuItem",
78
+ "DropdownMenuTrigger",
79
+ "Popover",
80
+ "PopoverContent",
81
+ "PopoverTrigger",
82
+ "Select",
83
+ "SelectContent",
84
+ "SelectItem",
85
+ "SelectTrigger",
86
+ "SelectValue",
87
+ "Sheet",
88
+ "SheetContent",
89
+ "SheetDescription",
90
+ "SheetFooter",
91
+ "SheetHeader",
92
+ "SheetTitle",
93
+ "SheetTrigger",
94
+ "Tooltip",
95
+ "TooltipContent",
96
+ "TooltipProvider",
97
+ "TooltipTrigger",
98
+ ];
99
+ const REACT_EXPORTS = [
100
+ "Activity",
101
+ "Children",
102
+ "Component",
103
+ "Fragment",
104
+ "Profiler",
105
+ "PureComponent",
106
+ "StrictMode",
107
+ "Suspense",
108
+ "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE",
109
+ "__COMPILER_RUNTIME",
110
+ "act",
111
+ "cache",
112
+ "cacheSignal",
113
+ "captureOwnerStack",
114
+ "cloneElement",
115
+ "createContext",
116
+ "createElement",
117
+ "createRef",
118
+ "default",
119
+ "forwardRef",
120
+ "isValidElement",
121
+ "lazy",
122
+ "memo",
123
+ "startTransition",
124
+ "unstable_useCacheRefresh",
125
+ "use",
126
+ "useActionState",
127
+ "useCallback",
128
+ "useContext",
129
+ "useDebugValue",
130
+ "useDeferredValue",
131
+ "useEffect",
132
+ "useEffectEvent",
133
+ "useId",
134
+ "useImperativeHandle",
135
+ "useInsertionEffect",
136
+ "useLayoutEffect",
137
+ "useMemo",
138
+ "useOptimistic",
139
+ "useReducer",
140
+ "useRef",
141
+ "useState",
142
+ "useSyncExternalStore",
143
+ "useTransition",
144
+ "version",
145
+ ];
146
+ const RUNTIME_EXPORTS = [
147
+ "ANON_CALLER",
148
+ "CALLAI_IMAGE_MAX_EDGE",
149
+ "CALLAI_IMAGE_QUALITY",
150
+ "COLOR_OVERRIDE_STYLE_ID",
151
+ "CREATE_VIBE_SAFE_URL_LENGTH",
152
+ "CallAIImageTooLargeError",
153
+ "CallAIRefusalError",
154
+ "Database",
155
+ "EMBED_DOCUMENT_PARAM",
156
+ "FONT_IMPORT_LINK_ID",
157
+ "FireflyDatabase",
158
+ "HOST_INJECTED_IFRAME_PARAMS",
159
+ "HOT_SWAP_ENTRY_PATH",
160
+ "HandleInput",
161
+ "IMG_GEN_SOURCE_UNUSABLE",
162
+ "INTERNAL_MEDIA_DB_ACCESS",
163
+ "ImgGen",
164
+ "RUNTIME_BUILD",
165
+ "RUNTIME_BUILD_GLOBAL",
166
+ "SHADCN_THEME_COLOR_NAMES",
167
+ "SHADCN_THEME_INLINE_CSS",
168
+ "TAILWIND_REMAP_STYLE_ID",
169
+ "VIBES_DIY_BUILDER_URL",
170
+ "VibeContextProvider",
171
+ "VibeSandboxApi",
172
+ "ViewerTag",
173
+ "__resetCalmErrorsForTests",
174
+ "__resetContentHeightForTests",
175
+ "__resetGraceForTest",
176
+ "__resetInterestRegistryForTests",
177
+ "__resetMirrorInterestBridgeForTests",
178
+ "__resetPaintSignalForTests",
179
+ "__resetPullToRefreshForTests",
180
+ "__resetRegisteredAccessFnSourcesForTests",
181
+ "__resetRegisteredSocialChangedForTests",
182
+ "__resetRegisteredViewerChangedForTests",
183
+ "__resetRuntimeBuildAnnounceForTests",
184
+ "__resetUrlStateForTests",
185
+ "__setBootErrorParentPostMessageForTests",
186
+ "__setCalmWindowMsForTests",
187
+ "__setContentProbeForTests",
188
+ "__setHotSwapParentPostMessageForTests",
189
+ "__setRegisteredVibeApiForTests",
190
+ "__setReportSinkForTests",
191
+ "__vibeLogBufferForTests",
192
+ "__vibeLogIdentityForTests",
193
+ "aclAllows",
194
+ "addInterest",
195
+ "adoptPersistedSocialGraph",
196
+ "adoptPersistedViewerIdentity",
197
+ "announceRuntimeBuild",
198
+ "apiFetch",
199
+ "applyColorOverrideMessage",
200
+ "applyFontImport",
201
+ "armGrace",
202
+ "beginHotSwap",
203
+ "beginHotSwapRollback",
204
+ "beginNetworkActivity",
205
+ "bootstrapAccessFnSources",
206
+ "bootstrapViewer",
207
+ "buildCreateVibeUrl",
208
+ "callAI",
209
+ "callAi",
210
+ "canRead",
211
+ "canSeeDoc",
212
+ "canWrite",
213
+ "classifyAuthoritativeAnonymous",
214
+ "clearSocialChangedBaseline",
215
+ "collectRelativeImports",
216
+ "confirmedMediaProbe",
217
+ "contentHeightChanged",
218
+ "createHotSwapState",
219
+ "createVibe",
220
+ "decorateFiles",
221
+ "deviceHashFor",
222
+ "downscaleImageDataUrl",
223
+ "encodeKey",
224
+ "endNetworkActivity",
225
+ "ensureMirrorInterestBridge",
226
+ "entryDirBase",
227
+ "evaluateWrite",
228
+ "finishHotSwapRollback",
229
+ "fireproof",
230
+ "flushVibeLog",
231
+ "formatRuntimeBuild",
232
+ "generateTailwindRemapCss",
233
+ "getActiveImportMap",
234
+ "getActiveProps",
235
+ "getHotSwapBaseUrl",
236
+ "getRegisteredAccessFnSources",
237
+ "getRegisteredSocialChanged",
238
+ "getRegisteredVibeApi",
239
+ "getRegisteredViewerChanged",
240
+ "hasAuthoritativeViewerResolved",
241
+ "heldInterests",
242
+ "imgGen",
243
+ "inGroup",
244
+ "installCalmErrorHandlers",
245
+ "installPullToRefresh",
246
+ "isBuildCalmActive",
247
+ "isCurrentHotSwapAttempt",
248
+ "isCurrentHotSwapRollback",
249
+ "isEmbeddedDocumentSearch",
250
+ "isFromHostShell",
251
+ "isGraceDegraded",
252
+ "isHotSwapAttemptCurrent",
253
+ "isHotSwapRollbackCurrent",
254
+ "isSupersededProvisionalViewerEvt",
255
+ "isTrustedViewerSource",
256
+ "isViewerEnvPending",
257
+ "listDbNames",
258
+ "loadHotSwapTranspiler",
259
+ "makeClientCtx",
260
+ "markHotSwapApplied",
261
+ "measureContentHeight",
262
+ "mergeKnownCache",
263
+ "mountVibe",
264
+ "noteBuildActivity",
265
+ "noteHotSwapApplied",
266
+ "noteHotSwapPainted",
267
+ "onUncaughtVibeError",
268
+ "orderCompanionGraph",
269
+ "parseRuntimeBuild",
270
+ "postBootErrorToParent",
271
+ "postHotSwapErrorToParent",
272
+ "postHotSwapOkToParent",
273
+ "prepareCallAIPrompt",
274
+ "promoteHotSwap",
275
+ "reconcileSoftSocialGraphWithViewer",
276
+ "recordEnvBaselinesFromMessage",
277
+ "recordSocialChangedBaseline",
278
+ "recordSocialGraphFromEvt",
279
+ "recordViewerChangedBaseline",
280
+ "recordViewerIdentityFromEvt",
281
+ "registerCallAI",
282
+ "registerContentHeightBridge",
283
+ "registerDependencies",
284
+ "registerFirefly",
285
+ "registerImgGen",
286
+ "registerInterestSink",
287
+ "registerPullToRefreshHandler",
288
+ "registerUrlStateBridge",
289
+ "registerVibeLog",
290
+ "removeInterest",
291
+ "renderColorOverrideCss",
292
+ "renderVibeLogArgs",
293
+ "reportHotSwapFailure",
294
+ "resizeImageToBase64",
295
+ "resolveBuilderOrigin",
296
+ "resolveBuilderOriginFrom",
297
+ "resolveCompanionPath",
298
+ "rewriteBareSpecifiers",
299
+ "rewriteRelativeSpecifiers",
300
+ "rewriteRelativeSpecifiersWithBlobs",
301
+ "seedHotSwapBootSource",
302
+ "setAppContainer",
303
+ "setGraceMsForTest",
304
+ "setHotSwapRestore",
305
+ "setHotSwapRuntimeId",
306
+ "socialEnv",
307
+ "splitVibeLogArgs",
308
+ "stripHostInjectedParams",
309
+ "subscribeGrace",
310
+ "unmountVibe",
311
+ "unregisterVibeLog",
312
+ "uploadViewerAvatar",
313
+ "urlStateChanged",
314
+ "useCaptureSeedRead",
315
+ "useConnection",
316
+ "useEnv",
317
+ "useFireproof",
318
+ "useGraceDegraded",
319
+ "useImgGen",
320
+ "useInterest",
321
+ "useSocial",
322
+ "useVibe",
323
+ "useVibeContext",
324
+ "useViewer",
325
+ "vibe",
326
+ "vibeApi",
327
+ "vibeEnv",
328
+ "vibeLog",
329
+ "vibeMountParams",
330
+ "viewerEnv",
331
+ ];
332
+ const RUNTIME_ALIAS = "alias:@vibes.diy/vibe-runtime";
333
+ function importMapEntries() {
334
+ return Object.values(lockedGroupsVersions).flatMap((group) => Object.entries(group));
335
+ }
336
+ export const OPENS_MODULE_EXPORTS = {
337
+ "@vibes.diy/look": LOOK_EXPORTS,
338
+ "@vibes.diy/look/overlay": LOOK_OVERLAY_EXPORTS,
339
+ react: REACT_EXPORTS,
340
+ "@vibes.diy/vibe-runtime": RUNTIME_EXPORTS,
341
+ ...Object.fromEntries(importMapEntries().flatMap(([spec, target]) => target === RUNTIME_ALIAS ? [[spec, RUNTIME_EXPORTS]] : [])),
342
+ };
343
+ function isMappedSpecifier(spec) {
344
+ return importMapEntries().some(([key]) => key === spec || (key.endsWith("/") && spec.startsWith(key)));
345
+ }
346
+ const BROWSER_GLOBALS = new Set([
347
+ "undefined",
348
+ "NaN",
349
+ "Infinity",
350
+ "globalThis",
351
+ "arguments",
352
+ "eval",
353
+ "Object",
354
+ "Function",
355
+ "Array",
356
+ "String",
357
+ "Number",
358
+ "Boolean",
359
+ "Symbol",
360
+ "BigInt",
361
+ "Math",
362
+ "JSON",
363
+ "Date",
364
+ "RegExp",
365
+ "Error",
366
+ "TypeError",
367
+ "RangeError",
368
+ "SyntaxError",
369
+ "ReferenceError",
370
+ "EvalError",
371
+ "URIError",
372
+ "AggregateError",
373
+ "Map",
374
+ "Set",
375
+ "WeakMap",
376
+ "WeakSet",
377
+ "WeakRef",
378
+ "FinalizationRegistry",
379
+ "Promise",
380
+ "Proxy",
381
+ "Reflect",
382
+ "Atomics",
383
+ "Iterator",
384
+ "ArrayBuffer",
385
+ "SharedArrayBuffer",
386
+ "DataView",
387
+ "Int8Array",
388
+ "Uint8Array",
389
+ "Uint8ClampedArray",
390
+ "Int16Array",
391
+ "Uint16Array",
392
+ "Int32Array",
393
+ "Uint32Array",
394
+ "Float32Array",
395
+ "Float64Array",
396
+ "BigInt64Array",
397
+ "BigUint64Array",
398
+ "Intl",
399
+ "parseInt",
400
+ "parseFloat",
401
+ "isNaN",
402
+ "isFinite",
403
+ "encodeURI",
404
+ "encodeURIComponent",
405
+ "decodeURI",
406
+ "decodeURIComponent",
407
+ "escape",
408
+ "unescape",
409
+ "window",
410
+ "self",
411
+ "document",
412
+ "navigator",
413
+ "location",
414
+ "history",
415
+ "screen",
416
+ "top",
417
+ "parent",
418
+ "frames",
419
+ "opener",
420
+ "console",
421
+ "alert",
422
+ "confirm",
423
+ "prompt",
424
+ "print",
425
+ "open",
426
+ "close",
427
+ "focus",
428
+ "blur",
429
+ "name",
430
+ "status",
431
+ "origin",
432
+ "localStorage",
433
+ "sessionStorage",
434
+ "indexedDB",
435
+ "caches",
436
+ "crypto",
437
+ "performance",
438
+ "visualViewport",
439
+ "devicePixelRatio",
440
+ "innerWidth",
441
+ "innerHeight",
442
+ "outerWidth",
443
+ "outerHeight",
444
+ "scrollX",
445
+ "scrollY",
446
+ "pageXOffset",
447
+ "pageYOffset",
448
+ "scrollTo",
449
+ "scrollBy",
450
+ "scroll",
451
+ "matchMedia",
452
+ "getComputedStyle",
453
+ "getSelection",
454
+ "isSecureContext",
455
+ "reportError",
456
+ "setTimeout",
457
+ "clearTimeout",
458
+ "setInterval",
459
+ "clearInterval",
460
+ "requestAnimationFrame",
461
+ "cancelAnimationFrame",
462
+ "requestIdleCallback",
463
+ "cancelIdleCallback",
464
+ "queueMicrotask",
465
+ "structuredClone",
466
+ "atob",
467
+ "btoa",
468
+ "postMessage",
469
+ "addEventListener",
470
+ "removeEventListener",
471
+ "dispatchEvent",
472
+ "customElements",
473
+ "speechSynthesis",
474
+ "fetch",
475
+ "Headers",
476
+ "Request",
477
+ "Response",
478
+ "URL",
479
+ "URLSearchParams",
480
+ "AbortController",
481
+ "AbortSignal",
482
+ "FormData",
483
+ "Blob",
484
+ "File",
485
+ "FileList",
486
+ "FileReader",
487
+ "TextEncoder",
488
+ "TextDecoder",
489
+ "WebSocket",
490
+ "EventSource",
491
+ "BroadcastChannel",
492
+ "MessageChannel",
493
+ "MessagePort",
494
+ "Worker",
495
+ "SharedWorker",
496
+ "DOMParser",
497
+ "XMLSerializer",
498
+ "XMLHttpRequest",
499
+ "ReadableStream",
500
+ "WritableStream",
501
+ "TransformStream",
502
+ "CompressionStream",
503
+ "DecompressionStream",
504
+ "Notification",
505
+ "DOMException",
506
+ "CSS",
507
+ "CSSStyleSheet",
508
+ "Node",
509
+ "Element",
510
+ "HTMLElement",
511
+ "HTMLDivElement",
512
+ "HTMLInputElement",
513
+ "HTMLTextAreaElement",
514
+ "HTMLCanvasElement",
515
+ "HTMLImageElement",
516
+ "HTMLVideoElement",
517
+ "HTMLAudioElement",
518
+ "HTMLAnchorElement",
519
+ "HTMLButtonElement",
520
+ "HTMLFormElement",
521
+ "HTMLSelectElement",
522
+ "SVGElement",
523
+ "Document",
524
+ "DocumentFragment",
525
+ "Text",
526
+ "Range",
527
+ "Selection",
528
+ "NodeFilter",
529
+ "Event",
530
+ "CustomEvent",
531
+ "KeyboardEvent",
532
+ "MouseEvent",
533
+ "PointerEvent",
534
+ "TouchEvent",
535
+ "WheelEvent",
536
+ "InputEvent",
537
+ "FocusEvent",
538
+ "DragEvent",
539
+ "ClipboardEvent",
540
+ "EventTarget",
541
+ "IntersectionObserver",
542
+ "ResizeObserver",
543
+ "MutationObserver",
544
+ "Image",
545
+ "Audio",
546
+ "Option",
547
+ "OffscreenCanvas",
548
+ "Path2D",
549
+ "ImageData",
550
+ "ImageBitmap",
551
+ "createImageBitmap",
552
+ "CanvasRenderingContext2D",
553
+ "WebGLRenderingContext",
554
+ "WebGL2RenderingContext",
555
+ "DOMRect",
556
+ "DOMMatrix",
557
+ "DOMPoint",
558
+ "AudioContext",
559
+ "webkitAudioContext",
560
+ "OfflineAudioContext",
561
+ "AudioBuffer",
562
+ "AudioNode",
563
+ "AudioParam",
564
+ "GainNode",
565
+ "OscillatorNode",
566
+ "AnalyserNode",
567
+ "BiquadFilterNode",
568
+ "AudioBufferSourceNode",
569
+ "MediaRecorder",
570
+ "MediaStream",
571
+ "MediaSource",
572
+ "SpeechSynthesisUtterance",
573
+ "SpeechRecognition",
574
+ "webkitSpeechRecognition",
575
+ "Geolocation",
576
+ ]);
577
+ function isGlobalName(name) {
578
+ return BROWSER_GLOBALS.has(name);
579
+ }
580
+ function asNode(value) {
581
+ if (typeof value !== "object" || value === null)
582
+ return undefined;
583
+ if ("type" in value && typeof value.type === "string" && "start" in value && typeof value.start === "number") {
584
+ return { ...value, type: value.type, start: value.start };
585
+ }
586
+ return undefined;
587
+ }
588
+ function field(node, key) {
589
+ return Reflect.get(node, key);
590
+ }
591
+ function nodeAt(node, key) {
592
+ return asNode(field(node, key));
593
+ }
594
+ function nodesAt(node, key) {
595
+ const value = field(node, key);
596
+ if (Array.isArray(value) === false)
597
+ return [];
598
+ return value.flatMap((item) => {
599
+ const n = asNode(item);
600
+ return n === undefined ? [] : [n];
601
+ });
602
+ }
603
+ function stringAt(node, key) {
604
+ const value = field(node, key);
605
+ return typeof value === "string" ? value : undefined;
606
+ }
607
+ function isComputed(node) {
608
+ return field(node, "computed") === true;
609
+ }
610
+ const SKIP_KEYS = new Set(["type", "start", "end", "loc", "range", "raw"]);
611
+ function childNodes(node) {
612
+ return Object.keys(node)
613
+ .filter((key) => SKIP_KEYS.has(key) === false)
614
+ .flatMap((key) => {
615
+ const value = field(node, key);
616
+ const items = Array.isArray(value) ? value : [value];
617
+ return items.flatMap((item) => {
618
+ const child = asNode(item);
619
+ return child === undefined ? [] : [{ key, child }];
620
+ });
621
+ });
622
+ }
623
+ const HOOK_NAME = /^use[A-Z0-9]/;
624
+ function declarePattern(pattern, visit, scan) {
625
+ switch (pattern.type) {
626
+ case "Identifier": {
627
+ const name = stringAt(pattern, "name");
628
+ if (name !== undefined)
629
+ scan.declared.add(name);
630
+ return;
631
+ }
632
+ case "ObjectPattern":
633
+ for (const prop of nodesAt(pattern, "properties")) {
634
+ if (prop.type === "RestElement") {
635
+ const arg = nodeAt(prop, "argument");
636
+ if (arg !== undefined)
637
+ declarePattern(arg, visit, scan);
638
+ continue;
639
+ }
640
+ const key = nodeAt(prop, "key");
641
+ if (key !== undefined && isComputed(prop))
642
+ walk({ node: key, parent: prop, key: "key", depth: visit.depth }, scan);
643
+ const value = nodeAt(prop, "value");
644
+ if (value !== undefined)
645
+ declarePattern(value, visit, scan);
646
+ }
647
+ return;
648
+ case "ArrayPattern":
649
+ for (const element of nodesAt(pattern, "elements"))
650
+ declarePattern(element, visit, scan);
651
+ return;
652
+ case "RestElement": {
653
+ const arg = nodeAt(pattern, "argument");
654
+ if (arg !== undefined)
655
+ declarePattern(arg, visit, scan);
656
+ return;
657
+ }
658
+ case "AssignmentPattern": {
659
+ const left = nodeAt(pattern, "left");
660
+ const right = nodeAt(pattern, "right");
661
+ if (left !== undefined)
662
+ declarePattern(left, visit, scan);
663
+ if (right !== undefined)
664
+ walk({ node: right, parent: pattern, key: "right", depth: visit.depth }, scan);
665
+ return;
666
+ }
667
+ default:
668
+ walk({ node: pattern, parent: undefined, key: "", depth: visit.depth }, scan);
669
+ }
670
+ }
671
+ function declareId(node, scan) {
672
+ const id = nodeAt(node, "id");
673
+ const name = id === undefined ? undefined : stringAt(id, "name");
674
+ if (name !== undefined)
675
+ scan.declared.add(name);
676
+ }
677
+ function walkFunction(v, scan) {
678
+ declareId(v.node, scan);
679
+ const inner = { depth: v.depth + 1 };
680
+ for (const param of nodesAt(v.node, "params"))
681
+ declarePattern(param, inner, scan);
682
+ const body = nodeAt(v.node, "body");
683
+ if (body !== undefined)
684
+ walk({ node: body, parent: v.node, key: "body", depth: inner.depth }, scan);
685
+ }
686
+ function jsxReference(name) {
687
+ switch (name.type) {
688
+ case "JSXIdentifier": {
689
+ const id = stringAt(name, "name");
690
+ if (id === undefined || /^[a-z]/.test(id) || id.includes("-"))
691
+ return undefined;
692
+ return { name: id, start: name.start };
693
+ }
694
+ case "JSXMemberExpression": {
695
+ let object = nodeAt(name, "object");
696
+ while (object !== undefined && object.type === "JSXMemberExpression")
697
+ object = nodeAt(object, "object");
698
+ const root = object === undefined ? undefined : stringAt(object, "name");
699
+ return object === undefined || root === undefined || root === "this" ? undefined : { name: root, start: object.start };
700
+ }
701
+ default:
702
+ return undefined;
703
+ }
704
+ }
705
+ function isNonReferenceIdentifier(v) {
706
+ const parent = v.parent;
707
+ if (parent === undefined)
708
+ return false;
709
+ switch (true) {
710
+ case parent.type === "MemberExpression" && v.key === "property" && isComputed(parent) === false:
711
+ case (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") &&
712
+ v.key === "key" &&
713
+ isComputed(parent) === false:
714
+ case parent.type === "LabeledStatement" || parent.type === "BreakStatement" || parent.type === "ContinueStatement":
715
+ case parent.type === "ExportSpecifier" && v.key === "exported":
716
+ case parent.type === "MetaProperty":
717
+ return true;
718
+ default:
719
+ return false;
720
+ }
721
+ }
722
+ function walk(v, scan) {
723
+ const node = v.node;
724
+ switch (node.type) {
725
+ case "Identifier": {
726
+ const name = stringAt(node, "name");
727
+ if (name !== undefined && isNonReferenceIdentifier(v) === false)
728
+ scan.refs.push({ name, start: node.start });
729
+ return;
730
+ }
731
+ case "ImportDeclaration":
732
+ case "ImportExpression":
733
+ case "ExportAllDeclaration":
734
+ return;
735
+ case "ExportNamedDeclaration":
736
+ if (nodeAt(node, "source") !== undefined)
737
+ return;
738
+ break;
739
+ case "VariableDeclarator": {
740
+ const id = nodeAt(node, "id");
741
+ if (id !== undefined)
742
+ declarePattern(id, v, scan);
743
+ const init = nodeAt(node, "init");
744
+ if (init !== undefined)
745
+ walk({ node: init, parent: node, key: "init", depth: v.depth }, scan);
746
+ return;
747
+ }
748
+ case "FunctionDeclaration":
749
+ case "FunctionExpression":
750
+ case "ArrowFunctionExpression":
751
+ walkFunction(v, scan);
752
+ return;
753
+ case "ClassDeclaration":
754
+ case "ClassExpression": {
755
+ declareId(node, scan);
756
+ const superClass = nodeAt(node, "superClass");
757
+ if (superClass !== undefined)
758
+ walk({ node: superClass, parent: node, key: "superClass", depth: v.depth }, scan);
759
+ const body = nodeAt(node, "body");
760
+ if (body !== undefined)
761
+ walk({ node: body, parent: node, key: "body", depth: v.depth + 1 }, scan);
762
+ return;
763
+ }
764
+ case "CatchClause": {
765
+ const param = nodeAt(node, "param");
766
+ if (param !== undefined)
767
+ declarePattern(param, v, scan);
768
+ const body = nodeAt(node, "body");
769
+ if (body !== undefined)
770
+ walk({ node: body, parent: node, key: "body", depth: v.depth }, scan);
771
+ return;
772
+ }
773
+ case "UnaryExpression": {
774
+ const arg = nodeAt(node, "argument");
775
+ if (stringAt(node, "operator") === "typeof" && arg !== undefined && arg.type === "Identifier")
776
+ return;
777
+ break;
778
+ }
779
+ case "CallExpression": {
780
+ const callee = nodeAt(node, "callee");
781
+ const hook = callee === undefined ? undefined : hookName(callee);
782
+ if (hook !== undefined && v.depth === 0)
783
+ scan.hookCalls.push({ name: hook, start: node.start });
784
+ break;
785
+ }
786
+ case "JSXElement": {
787
+ const opening = nodeAt(node, "openingElement");
788
+ if (opening !== undefined)
789
+ walk({ node: opening, parent: node, key: "openingElement", depth: v.depth }, scan);
790
+ for (const child of nodesAt(node, "children"))
791
+ walk({ node: child, parent: node, key: "children", depth: v.depth }, scan);
792
+ return;
793
+ }
794
+ case "JSXOpeningElement": {
795
+ const name = nodeAt(node, "name");
796
+ const ref = name === undefined ? undefined : jsxReference(name);
797
+ if (ref !== undefined)
798
+ scan.refs.push(ref);
799
+ for (const attr of nodesAt(node, "attributes"))
800
+ walk({ node: attr, parent: node, key: "attributes", depth: v.depth }, scan);
801
+ return;
802
+ }
803
+ case "JSXAttribute": {
804
+ const value = nodeAt(node, "value");
805
+ if (value !== undefined)
806
+ walk({ node: value, parent: node, key: "value", depth: v.depth }, scan);
807
+ return;
808
+ }
809
+ case "JSXText":
810
+ case "JSXIdentifier":
811
+ case "JSXNamespacedName":
812
+ case "JSXMemberExpression":
813
+ case "JSXClosingElement":
814
+ case "JSXClosingFragment":
815
+ case "JSXOpeningFragment":
816
+ case "Literal":
817
+ case "TemplateElement":
818
+ return;
819
+ default:
820
+ break;
821
+ }
822
+ for (const { key, child } of childNodes(node))
823
+ walk({ node: child, parent: node, key, depth: v.depth }, scan);
824
+ }
825
+ function hookName(callee) {
826
+ switch (callee.type) {
827
+ case "Identifier": {
828
+ const name = stringAt(callee, "name");
829
+ return name !== undefined && HOOK_NAME.test(name) ? name : undefined;
830
+ }
831
+ case "MemberExpression": {
832
+ const property = nodeAt(callee, "property");
833
+ const name = property === undefined || isComputed(callee) ? undefined : stringAt(property, "name");
834
+ return name !== undefined && HOOK_NAME.test(name) ? name : undefined;
835
+ }
836
+ default:
837
+ return undefined;
838
+ }
839
+ }
840
+ function collectImports(program, scan) {
841
+ for (const statement of nodesAt(program, "body")) {
842
+ const source = nodeAt(statement, "source");
843
+ const spec = source === undefined ? undefined : field(source, "value");
844
+ if (typeof spec !== "string")
845
+ continue;
846
+ switch (statement.type) {
847
+ case "ImportDeclaration": {
848
+ const names = [];
849
+ for (const specifier of nodesAt(statement, "specifiers")) {
850
+ const local = nodeAt(specifier, "local");
851
+ const localName = local === undefined ? undefined : stringAt(local, "name");
852
+ if (localName !== undefined)
853
+ scan.declared.add(localName);
854
+ const imported = nodeAt(specifier, "imported");
855
+ const importedName = imported === undefined ? undefined : (stringAt(imported, "name") ?? stringAt(imported, "value"));
856
+ if (specifier.type === "ImportSpecifier" && importedName !== undefined)
857
+ names.push(importedName);
858
+ if (specifier.type === "ImportDefaultSpecifier")
859
+ names.push("default");
860
+ }
861
+ scan.imports.push({ spec, start: statement.start, names });
862
+ break;
863
+ }
864
+ case "ExportNamedDeclaration": {
865
+ const names = nodesAt(statement, "specifiers").flatMap((specifier) => {
866
+ const local = nodeAt(specifier, "local");
867
+ const name = local === undefined ? undefined : (stringAt(local, "name") ?? stringAt(local, "value"));
868
+ return name === undefined ? [] : [name];
869
+ });
870
+ scan.imports.push({ spec, start: statement.start, names });
871
+ break;
872
+ }
873
+ case "ExportAllDeclaration":
874
+ scan.imports.push({ spec, start: statement.start, names: [] });
875
+ break;
876
+ default:
877
+ break;
878
+ }
879
+ }
880
+ }
881
+ function collectDynamicImports(node, scan) {
882
+ if (node.type === "ImportExpression") {
883
+ const source = nodeAt(node, "source");
884
+ const spec = source === undefined ? undefined : field(source, "value");
885
+ if (typeof spec === "string")
886
+ scan.imports.push({ spec, start: node.start, names: [] });
887
+ }
888
+ for (const { child } of childNodes(node))
889
+ collectDynamicImports(child, scan);
890
+ }
891
+ function lineAt(source, offset) {
892
+ return source.slice(0, offset).split("\n").length;
893
+ }
894
+ function resolveRelative(from, spec) {
895
+ const base = spec.startsWith("/") ? [] : from.split("/").slice(1, -1);
896
+ const parts = [...base];
897
+ for (const part of spec.split("/")) {
898
+ switch (part) {
899
+ case "":
900
+ case ".":
901
+ break;
902
+ case "..":
903
+ if (parts.length === 0)
904
+ return undefined;
905
+ parts.pop();
906
+ break;
907
+ default:
908
+ parts.push(part);
909
+ }
910
+ }
911
+ return `/${parts.join("/")}`;
912
+ }
913
+ function isRelativeSpecifier(spec) {
914
+ return spec.startsWith("./") || spec.startsWith("../") || (spec.startsWith("/") && spec.startsWith("//") === false);
915
+ }
916
+ function isBareSpecifier(spec) {
917
+ return isRelativeSpecifier(spec) === false && /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(spec) === false;
918
+ }
919
+ function parseableSource(path, contents) {
920
+ if (/\.tsx?$/.test(path) === false)
921
+ return contents;
922
+ const stripped = exception2Result(() => transform(contents, { transforms: path.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"], jsxRuntime: "preserve" })
923
+ .code);
924
+ return stripped.isErr() ? undefined : stripped.Ok();
925
+ }
926
+ const JsxParser = Parser.extend(acornJsx());
927
+ const NOTHING = { findings: [], deps: [] };
928
+ function checkFile(args) {
929
+ const { path } = args;
930
+ const source = parseableSource(path, args.contents);
931
+ if (source === undefined)
932
+ return NOTHING;
933
+ const parsed = exception2Result(() => JsxParser.parse(source, { ecmaVersion: "latest", sourceType: "module", allowHashBang: true, allowAwaitOutsideFunction: true }));
934
+ if (parsed.isErr()) {
935
+ const message = parsed.Err().message;
936
+ const at = /\((\d+):\d+\)\s*$/.exec(message);
937
+ if (message.includes("Expected corresponding JSX closing tag")) {
938
+ return {
939
+ findings: [
940
+ {
941
+ class: "jsx-tag-mismatch",
942
+ message: message.replace(/\s*\(\d+:\d+\)\s*$/, ""),
943
+ file: path,
944
+ line: at === null ? 1 : Number(at[1]),
945
+ },
946
+ ],
947
+ deps: [],
948
+ };
949
+ }
950
+ return NOTHING;
951
+ }
952
+ const program = asNode(parsed.Ok());
953
+ if (program === undefined)
954
+ return NOTHING;
955
+ const scan = { declared: new Set(), refs: [], hookCalls: [], imports: [] };
956
+ collectImports(program, scan);
957
+ collectDynamicImports(program, scan);
958
+ walk({ node: program, parent: undefined, key: "", depth: 0 }, scan);
959
+ const findings = [];
960
+ const deps = [];
961
+ for (const imp of scan.imports) {
962
+ const line = lineAt(source, imp.start);
963
+ if (isRelativeSpecifier(imp.spec)) {
964
+ const target = resolveRelative(path, imp.spec);
965
+ if (target === undefined || args.vfs.has(target) === false) {
966
+ findings.push({
967
+ class: "import-404",
968
+ message: `"${imp.spec}" has no file at ${target ?? "that path"}; the runtime serves exact paths, so write the extension (#6450)`,
969
+ file: path,
970
+ line,
971
+ });
972
+ }
973
+ else {
974
+ deps.push(target);
975
+ }
976
+ continue;
977
+ }
978
+ if (isBareSpecifier(imp.spec) === false)
979
+ continue;
980
+ const known = OPENS_MODULE_EXPORTS[imp.spec];
981
+ if (known !== undefined) {
982
+ for (const name of imp.names) {
983
+ if (known.includes(name))
984
+ continue;
985
+ findings.push({
986
+ class: "missing-export",
987
+ message: name === "default" ? `"${imp.spec}" has no default export` : `"${imp.spec}" has no export named ${name}`,
988
+ file: path,
989
+ line,
990
+ });
991
+ }
992
+ continue;
993
+ }
994
+ if (isMappedSpecifier(imp.spec) === false) {
995
+ findings.push({
996
+ class: "unknown-package",
997
+ message: `"${imp.spec}" is not in the sandbox import map (it would load from esm.sh, if at all)`,
998
+ file: path,
999
+ line,
1000
+ });
1001
+ }
1002
+ }
1003
+ const reported = new Set();
1004
+ for (const ref of scan.refs) {
1005
+ if (scan.declared.has(ref.name) || isGlobalName(ref.name) || reported.has(ref.name))
1006
+ continue;
1007
+ reported.add(ref.name);
1008
+ findings.push({
1009
+ class: "undefined-identifier",
1010
+ message: `${ref.name} is used but never imported or declared`,
1011
+ file: path,
1012
+ line: lineAt(source, ref.start),
1013
+ });
1014
+ }
1015
+ for (const hook of scan.hookCalls) {
1016
+ findings.push({
1017
+ class: "hook-at-module-scope",
1018
+ message: `${hook.name}(…) is called at module scope; hooks run inside a component or another hook`,
1019
+ file: path,
1020
+ line: lineAt(source, hook.start),
1021
+ });
1022
+ }
1023
+ return { findings: findings.sort((a, b) => a.line - b.line), deps };
1024
+ }
1025
+ function isBrowserModule(path) {
1026
+ return /\.(jsx?|tsx?)$/.test(path) && path.startsWith("/~~") === false && path !== "/access.js" && path !== "/backend.js";
1027
+ }
1028
+ export function checkOpens(vfs) {
1029
+ const entries = [...vfs.keys()].filter((path) => /^\/App\.(jsx|tsx|js|ts)$/.test(path));
1030
+ const queue = entries.length > 0 ? entries : [...vfs.keys()].filter(isBrowserModule);
1031
+ const seen = new Set();
1032
+ const findings = [];
1033
+ for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
1034
+ const contents = vfs.get(next);
1035
+ if (seen.has(next) || contents === undefined || isBrowserModule(next) === false)
1036
+ continue;
1037
+ seen.add(next);
1038
+ const checked = checkFile({ path: next, contents, vfs });
1039
+ findings.push(...checked.findings);
1040
+ queue.push(...checked.deps);
1041
+ }
1042
+ return { opens: findings.every((finding) => OPENS_ADVISORY_CLASSES.has(finding.class)), findings };
1043
+ }
1044
+ //# sourceMappingURL=opens-check.js.map