Skip to content

Conversation

@shs96c
Copy link
Member

@shs96c shs96c commented Jan 2, 2026

This migrates the existing use of the Closure Library and Compiler to use TypeScript and esbuild. This should allow us to continue working on the atoms in a more modern way, with a toolchain that is supported.

@selenium-ci selenium-ci added B-atoms JavaScript chunks generated by Google closure B-build Includes scripting, bazel and CI integrations labels Jan 2, 2026
shs96c and others added 19 commits January 2, 2026 17:27
Migrated javascript/atoms/inject.js to TypeScript (inject.ts):

- Converted bot.inject.cache functions (addElement, getElement)
- Converted bot.inject functions (wrapValue, unwrapValue, executeScript,
  executeAsyncScript, wrapResponse, wrapError)
- Replaced Closure utilities with native equivalents:
  - goog.utils.typeOf → custom typeOf function
  - goog.array.map → Array.prototype.map
  - goog.object.containsKey → 'in' operator check (hasKey)
  - goog.object.map/filter → Object iteration
  - goog.utils.now → Date.now()
  - goog.utils.partial → inline closure
  - goog.dom.NodeType.ELEMENT/DOCUMENT → constants 1/9
- Imported BotError, ErrorCode from './error' and stringify from './json'
- Added proper TypeScript interfaces (JsonElement, JsonWindow, ResponseObject)
- Added special handling in generate-shim.js for the dual namespace structure
  (bot.inject and bot.inject.cache)
- All closure tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-019b7a6d-049e-7483-82da-e169bcb69aef
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-atoms JavaScript chunks generated by Google closure B-build Includes scripting, bazel and CI integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants