Loading static/js/exercises.api.mjs +22 −3 Original line number Diff line number Diff line Loading @@ -162,6 +162,18 @@ class ExerciseExecutionContext { * @param {boolean} keepVisible */ prepareWith(command, keepVisible) { return this.#prepareWith(command, keepVisible) } /** * Private method actually doing all the work of prepareWith. * * Needed because the prepareWith public API is disabled in retry contexts, but we still need * it internally. * @param {string} command * @param {boolean} keepVisible */ #prepareWith(command, keepVisible) { return new Promise((resolve, _) => { async function prepareAndResolve() { Loading Loading @@ -194,7 +206,15 @@ class ExerciseExecutionContext { * Clear the terminal. Shorthand for prepareWith(null, false) */ async clear() { await this.prepareWith(null, false) await this.#clear() } /** * Private method actually clearing the terminal. Again, this is needed because the clear() public API * method is disabled in retry contexts, but we still need it internally. */ async #clear() { await this.#prepareWith(null, false) } /** Loading Loading @@ -246,8 +266,7 @@ class ExerciseExecutionContext { // if no command is provided, directly start with a resolved promise. const commandPromise = command ? runCommand(command) : Promise.resolve() const verifyHandler = this._verifyHandler // TODO This won't work if the user is already retrying the exercise, because then the public clear API is disabled const clear = this.clear.bind(this) const clear = this.#clear.bind(this) return { /** Loading Loading
static/js/exercises.api.mjs +22 −3 Original line number Diff line number Diff line Loading @@ -162,6 +162,18 @@ class ExerciseExecutionContext { * @param {boolean} keepVisible */ prepareWith(command, keepVisible) { return this.#prepareWith(command, keepVisible) } /** * Private method actually doing all the work of prepareWith. * * Needed because the prepareWith public API is disabled in retry contexts, but we still need * it internally. * @param {string} command * @param {boolean} keepVisible */ #prepareWith(command, keepVisible) { return new Promise((resolve, _) => { async function prepareAndResolve() { Loading Loading @@ -194,7 +206,15 @@ class ExerciseExecutionContext { * Clear the terminal. Shorthand for prepareWith(null, false) */ async clear() { await this.prepareWith(null, false) await this.#clear() } /** * Private method actually clearing the terminal. Again, this is needed because the clear() public API * method is disabled in retry contexts, but we still need it internally. */ async #clear() { await this.#prepareWith(null, false) } /** Loading Loading @@ -246,8 +266,7 @@ class ExerciseExecutionContext { // if no command is provided, directly start with a resolved promise. const commandPromise = command ? runCommand(command) : Promise.resolve() const verifyHandler = this._verifyHandler // TODO This won't work if the user is already retrying the exercise, because then the public clear API is disabled const clear = this.clear.bind(this) const clear = this.#clear.bind(this) return { /** Loading