@vibes.diy/api-svc 14.3.21 → 14.3.23

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