@inquirer/core
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -59,8 +59,2 @@ "use strict"; | ||
} | ||
function cleanupHook(index) { | ||
const cleanFn = hooksCleanup[index]; | ||
if (typeof cleanFn === 'function') { | ||
cleanFn(); | ||
} | ||
} | ||
function mergeStateUpdates(fn) { | ||
@@ -82,2 +76,13 @@ const wrapped = (...args) => { | ||
} | ||
function cleanupHook(index) { | ||
const cleanFn = hooksCleanup[index]; | ||
if (typeof cleanFn === 'function') { | ||
cleanFn(); | ||
} | ||
} | ||
const runEffects = mergeStateUpdates(() => { | ||
for (const effect of hooksEffect) { | ||
effect(); | ||
} | ||
}); | ||
function useState(defaultValue) { | ||
@@ -120,3 +125,3 @@ const _idx = index; | ||
if (hasChanged) { | ||
hooksEffect.push(mergeStateUpdates(() => { | ||
hooksEffect.push(() => { | ||
cleanupHook(_idx); | ||
@@ -128,3 +133,3 @@ const cleanFn = cb(rl); | ||
hooksCleanup[_idx] = cleanFn; | ||
})); | ||
}); | ||
} | ||
@@ -254,7 +259,5 @@ hooks[_idx] = depArray; | ||
const nextView = view(resolvedConfig, done); | ||
for (const effect of hooksEffect) { | ||
effect(); | ||
} | ||
const [content, bottomContent] = typeof nextView === 'string' ? [nextView] : nextView; | ||
screen.render(content, bottomContent); | ||
runEffects(); | ||
} | ||
@@ -261,0 +264,0 @@ catch (err) { |
@@ -59,8 +59,2 @@ "use strict"; | ||
} | ||
function cleanupHook(index) { | ||
const cleanFn = hooksCleanup[index]; | ||
if (typeof cleanFn === 'function') { | ||
cleanFn(); | ||
} | ||
} | ||
function mergeStateUpdates(fn) { | ||
@@ -82,2 +76,13 @@ const wrapped = (...args) => { | ||
} | ||
function cleanupHook(index) { | ||
const cleanFn = hooksCleanup[index]; | ||
if (typeof cleanFn === 'function') { | ||
cleanFn(); | ||
} | ||
} | ||
const runEffects = mergeStateUpdates(() => { | ||
for (const effect of hooksEffect) { | ||
effect(); | ||
} | ||
}); | ||
function useState(defaultValue) { | ||
@@ -120,3 +125,3 @@ const _idx = index; | ||
if (hasChanged) { | ||
hooksEffect.push(mergeStateUpdates(() => { | ||
hooksEffect.push(() => { | ||
cleanupHook(_idx); | ||
@@ -128,3 +133,3 @@ const cleanFn = cb(rl); | ||
hooksCleanup[_idx] = cleanFn; | ||
})); | ||
}); | ||
} | ||
@@ -254,7 +259,5 @@ hooks[_idx] = depArray; | ||
const nextView = view(resolvedConfig, done); | ||
for (const effect of hooksEffect) { | ||
effect(); | ||
} | ||
const [content, bottomContent] = typeof nextView === 'string' ? [nextView] : nextView; | ||
screen.render(content, bottomContent); | ||
runEffects(); | ||
} | ||
@@ -261,0 +264,0 @@ catch (err) { |
{ | ||
"name": "@inquirer/core", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"engines": { | ||
@@ -60,3 +60,3 @@ "node": ">=14.18.0" | ||
"dependencies": { | ||
"@inquirer/type": "^1.1.1", | ||
"@inquirer/type": "^1.1.2", | ||
"@types/mute-stream": "^0.0.1", | ||
@@ -76,3 +76,3 @@ "@types/node": "^20.4.8", | ||
"devDependencies": { | ||
"@inquirer/testing": "^2.1.2" | ||
"@inquirer/testing": "^2.1.3" | ||
}, | ||
@@ -83,4 +83,3 @@ "scripts": { | ||
"tsc:esm": "tsc -p ./tsconfig.json", | ||
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && yarn run fix-ext", | ||
"fix-ext": "node --no-warnings=ExperimentalWarning --loader=ts-node/esm ../../tools/fix-ext.mts" | ||
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs" | ||
}, | ||
@@ -102,3 +101,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "dd31d57ed3b1d0771e24cc34bc72e5bedb63a1d7" | ||
"gitHead": "2b29f261c4c7d85a00c1a2305d97ee10e3c15b68" | ||
} |
Sorry, the diff of this file is not supported yet
1328
62687
2
Updated@inquirer/type@^1.1.2