mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
browser: warn against top-level await in prompt
Updates the synthesis prompt to explicitly state that the output is executed as a classic script, making top-level `await` a syntax error.
This commit is contained in:
@@ -127,11 +127,15 @@ pub const save_synthesis_prompt =
|
||||
\\JavaScript wherever they fit; fall back to evaluate(...) only for logic the
|
||||
\\builtins can't express. End with an extract(...) for any data the user
|
||||
\\wanted out.
|
||||
\\The output MUST be valid JavaScript that runs as-is — it is executed as a
|
||||
\\classic script (not a module), so top-level `await` is a syntax error;
|
||||
\\`await` is only legal inside an `async` function.
|
||||
\\The builtins are synchronous and blocking: each returns its result
|
||||
\\directly. Do NOT use async/await, .then, or Promises around them — write a
|
||||
\\plain top-level script (e.g. `const data = extract(...)`, not
|
||||
\\`await extract(...)`). evaluate(...) may run async JS inside the page, but
|
||||
\\the evaluate(...) call itself still returns synchronously.
|
||||
\\directly, so you never need `await` at all. Do NOT use async/await, .then,
|
||||
\\or Promises around them — write a plain top-level script
|
||||
\\(e.g. `const data = extract(...)`, not `await extract(...)`). evaluate(...)
|
||||
\\may run async JS inside the page, but the evaluate(...) call itself still
|
||||
\\returns synchronously.
|
||||
\\Output ONLY JavaScript source — no markdown fences, no commentary, no prose
|
||||
\\before or after.
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user