Skip to content

Commit 70a285f

Browse files
hsy822ci-bot
andauthored
feat(editor): Implement dynamic type loading for TS/JS autocompletion (#6425)
* feat(editor): Implement dynamic type loading for TS/JS autocompletion * ethers autocompletion * wip: dynamic loading from cdn * bug fix * temp: enable dynamic import and autocompletion for ethers and viem libraries * temp: version 0.1 - viem/chains underline * temp: viem, ethers, lodash, axios * wip: add comments for reviewer * update explaination * fix(script-runner): robustly transform imports for runtime execution * feat(editor): Implement dynamic type loading and intelligent script transformation * fix(script-runner): Correctly transform imports for runtime execution * fix(script-runner): Separate static and dynamic imports in transformation * Add toast notifications for JS/TS type loading * feat: fix type loading bug * lint * fix hardhat import * lint * remove notification * rollback handleTypeScriptDependenciesOf * fixed bug and set e2e test * disabled test * rollback handleTypeScriptDependenciesOf * lint * added guard for onchange func --------- Co-authored-by: ci-bot <ci-bot@remix-project.org>
1 parent 5c93d75 commit 70a285f

File tree

7 files changed

+900
-85
lines changed

7 files changed

+900
-85
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ parameters:
1414
default: ""
1515
run_file_tests_keyword:
1616
type: enum
17-
enum: ["", "ai_panel", "ballot", "ballot_0_4_14", "blockchain", "bottom-bar", "circom", "code_format", "compile_run_widget", "compiler_api", "contract_flattener", "contract_verification", "debugger", "defaultLayout", "deploy_vefiry", "dgit_github", "dgit_local", "editor", "editorHoverContext", "editorReferences", "editor_error_marker", "editor_line_text", "eip1153", "eip7702", "environment-account", "erc721", "etherscan_api", "expandAllFolders", "fileExplorer", "fileManager_api", "file_decorator", "file_explorer_context_menu", "file_explorer_dragdrop", "file_explorer_multiselect", "generalSettings", "gist", "homeTab", "importFromGithub", "layout", "learneth", "libraryDeployment", "matomo-bot-detection", "matomo-consent", "mcp_all_resources", "mcp_all_tools", "mcp_server_complete", "mcp_server_connection", "mcp_server_lifecycle", "mcp_workflow_integration", "metamask", "migrateFileSystem", "noir", "pinned_contracts", "pluginManager", "plugin_api", "providers", "proxy_oz_v4", "proxy_oz_v5", "proxy_oz_v5_non_shanghai_runtime", "publishContract", "quickDapp_metamask", "recorder", "remixd", "runAndDeploy", "script-runner", "search", "signingMessage", "sol2uml", "solidityImport", "solidityUnittests", "specialFunctions", "staticAnalysis", "stressEditor", "template_exp_modal", "terminal", "toggle_panels", "transactionExecution", "txListener", "uniswap_v4_core", "url", "usingWebWorker", "verticalIconsPanel", "vm_state", "vyper_api", "walkthrough", "workspace", "workspace_git"]
17+
enum: ["", "ai_panel", "ballot", "ballot_0_4_14", "blockchain", "bottom-bar", "circom", "code_format", "compile_run_widget", "compiler_api", "contract_flattener", "contract_verification", "debugger", "defaultLayout", "deploy_vefiry", "dgit_github", "dgit_local", "editor", "editorHoverContext", "editorReferences", "editor_autocomplete", "editor_error_marker", "editor_line_text", "eip1153", "eip7702", "environment-account", "erc721", "etherscan_api", "expandAllFolders", "fileExplorer", "fileManager_api", "file_decorator", "file_explorer_context_menu", "file_explorer_dragdrop", "file_explorer_multiselect", "generalSettings", "gist", "homeTab", "importFromGithub", "layout", "learneth", "libraryDeployment", "matomo-bot-detection", "matomo-consent", "mcp_all_resources", "mcp_all_tools", "mcp_server_complete", "mcp_server_connection", "mcp_server_lifecycle", "mcp_workflow_integration", "metamask", "migrateFileSystem", "noir", "pinned_contracts", "pluginManager", "plugin_api", "providers", "proxy_oz_v4", "proxy_oz_v5", "proxy_oz_v5_non_shanghai_runtime", "publishContract", "quickDapp_metamask", "recorder", "remixd", "runAndDeploy", "script-runner", "search", "signingMessage", "sol2uml", "solidityImport", "solidityUnittests", "specialFunctions", "staticAnalysis", "stressEditor", "template_exp_modal", "terminal", "toggle_panels", "transactionExecution", "txListener", "uniswap_v4_core", "url", "usingWebWorker", "verticalIconsPanel", "vm_state", "vyper_api", "walkthrough", "workspace", "workspace_git"]
1818
default: ""
1919
run_flaky_tests:
2020
type: boolean
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
'use strict'
2+
3+
import { NightwatchBrowser } from 'nightwatch'
4+
import init from '../helpers/init'
5+
6+
module.exports = {
7+
'@disabled': true,
8+
before: function (browser: NightwatchBrowser, done: VoidFunction) {
9+
init(browser, done, 'http://127.0.0.1:8080', true)
10+
},
11+
12+
'Should load external types (axios) and show autocomplete #group1': function (browser: NightwatchBrowser) {
13+
browser
14+
.clickLaunchIcon('filePanel')
15+
.addFile('scripts/test_axios.ts', { content: testAxiosScript })
16+
.openFile('scripts/test_axios.ts')
17+
.waitForElementVisible('#editorView', 20000)
18+
.pause(15000)
19+
.execute(function () {
20+
const win = window as any
21+
if (!win.monaco || !win.monaco.editor) return false
22+
23+
const editors = win.monaco.editor.getEditors()
24+
const activeEditor = editors.find((e: any) => {
25+
const model = e.getModel()
26+
return model && model.uri.toString().includes('test_axios.ts')
27+
})
28+
29+
if (activeEditor) {
30+
activeEditor.focus()
31+
const model = activeEditor.getModel()
32+
const lastLine = model.getLineCount()
33+
const lastCol = model.getLineMaxColumn(lastLine)
34+
activeEditor.setPosition({ lineNumber: lastLine, column: lastCol })
35+
activeEditor.trigger('keyboard', 'type', { text: "\naxios" })
36+
activeEditor.trigger('keyboard', 'type', { text: "." })
37+
activeEditor.trigger('keyboard', 'editor.action.triggerSuggest', {})
38+
return true
39+
}
40+
return false
41+
})
42+
.pause(2000)
43+
.waitForElementVisible('.suggest-widget', 15000)
44+
.waitForElementVisible('.monaco-list-row', 5000)
45+
.waitForElementContainsText('.suggest-widget', 'get', 5000)
46+
.waitForElementContainsText('.suggest-widget', 'create', 5000)
47+
},
48+
49+
'Should provide autocomplete for local imports #group1': function (browser: NightwatchBrowser) {
50+
browser
51+
.addFile('scripts/localLib.ts', { content: localLibScript })
52+
.addFile('scripts/localConsumer.ts', { content: localConsumerScript })
53+
.openFile('scripts/localConsumer.ts')
54+
.waitForElementVisible('#editorView', 20000)
55+
.pause(2000)
56+
.execute(function () {
57+
const win = window as any
58+
if (!win.monaco) return false
59+
const editors = win.monaco.editor.getEditors()
60+
const activeEditor = editors.find((e: any) => {
61+
const model = e.getModel()
62+
return model && model.uri.toString().includes('localConsumer.ts')
63+
})
64+
65+
if (activeEditor) {
66+
activeEditor.focus()
67+
const model = activeEditor.getModel()
68+
const lastLine = model.getLineCount()
69+
const lastCol = model.getLineMaxColumn(lastLine)
70+
activeEditor.setPosition({ lineNumber: lastLine, column: lastCol })
71+
activeEditor.trigger('keyboard', 'type', { text: "\nHelper" })
72+
activeEditor.trigger('keyboard', 'type', { text: "." })
73+
activeEditor.trigger('keyboard', 'editor.action.triggerSuggest', {})
74+
return true
75+
}
76+
return false
77+
})
78+
.pause(2000)
79+
.waitForElementVisible('.suggest-widget', 15000)
80+
.waitForElementVisible('.monaco-list-row', 5000)
81+
.waitForElementContainsText('.suggest-widget', 'myLocalFunction', 5000)
82+
}
83+
}
84+
85+
const testAxiosScript = `
86+
import axios from 'axios';
87+
// Test Start`
88+
89+
const localLibScript = `
90+
export const myLocalFunction = () => { return "Local"; }`
91+
92+
const localConsumerScript = `
93+
import * as Helper from './localLib';
94+
// Test Start`

0 commit comments

Comments
 (0)