refactor: migrate renderer utilities to TypeScript modules - #68
Open
nihmadev wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
assets/js/lib.jscombined unrelated concerns in a 1,000-line browser module: text and encoding helpers, DOM behavior, Electron adapters, bug/history state, runtime diagnostics, sandbox execution, UI classes, registry initialization, and legacy globals. Because the renderer loads native ESM directly from disk, this could not be replaced with a TypeScript file without also preserving the emitted.jsURLs consumed by the application.Source and build layout
assets/ts/lib.tsas the compatibility entry point andassets/ts/lib/*as the typed source modules.tsconfig.renderer.jsonfor strict browser ESM compilation with DOM libraries.assets/js, preserving the paths already used by renderer imports.npm run buildwith the renderer TypeScript project and addsnpm run build:rendererfor focused work..jsand.d.tsfiles in the repository because packaged and development builds load renderer modules directly fromassets/jswithout a bundler or runtime TypeScript loader.Module boundaries
text: escaping, capitalization, initials, truncation, linkification, camel-case splitting, and dedent.encoding: UTF-8 base64 conversion and DOM identifier encoding.format: editor mode lookup, Unix date formatting, path normalization, time conversion, and color alpha conversion.values: runtime value classification and the existing object/array predicates.dom: tab labels, status transitions, popup behavior, scrolling, generated avatars, CSS variable discovery, code-window visibility, tag replacement, and editor sizing.platform: notifications, theme access, clipboard, Twemoji, application title, and GitHub token access.history: adapters for the existing global history and bug stores.runtimeErrors: runtime error state and bottom-window rendering.sandbox: captured console execution and parser/runtime checks.ui: reload notification behavior.validation: the value validation contract used by notifications without importing the modal engine.Compatibility retained
The generated
assets/js/lib.jsremains the public compatibility facade. Existing consumers do not need import changes.capitilizespelling remains available.false,null, andundefinedsentinel behavior is preserved where consumers rely on it.window.Notificator,window.addToBug,window.addToHistory,window.showIndicator, andwindow.animateare still assigned._ClassNameimplementations.Dependency graph changes
Three classes previously imported the compatibility facade that imported those same classes, creating circular module graphs:
EditorAdapternow imports the language registry directly.Optionsnow importstransparentColorfromlib/format.js.TopBarElementnow importsidifyfromlib/encoding.js.createNotifynow uses the leaf validation module instead of importingmodalsHandler/engine.js. Importing notification utilities therefore no longer initializes the modal backdrop and the complete modal component graph.The debugger window also receives an explicit module-scoped
debuggerWindowreference instead of assigning an undeclared global.Types and documentation
The renderer project is compiled with
strict: true. Browser globals that are provided by preload scripts or external scripts are declared inassets/ts/globals.d.ts. Public utility behavior is documented with focused TSDoc comments rather than repeating function names or implementation details.Verification
npm run buildnpm test(6/6tests pass)nullbehaviorlibClassesno longer importlib.js