@jsenv/navi 0.18.24 → 0.18.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsenv_navi.js +46 -33
- package/dist/jsenv_navi.js.map +5 -5
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -174,9 +174,6 @@ const ActionRenderer = ({
|
|
|
174
174
|
if (errorBoundary) {
|
|
175
175
|
return renderError(errorBoundary, "ui_error", action);
|
|
176
176
|
}
|
|
177
|
-
if (error) {
|
|
178
|
-
return renderError(error, "action_error", action);
|
|
179
|
-
}
|
|
180
177
|
if (aborted) {
|
|
181
178
|
return renderAborted(action);
|
|
182
179
|
}
|
|
@@ -199,6 +196,9 @@ const ActionRenderer = ({
|
|
|
199
196
|
}
|
|
200
197
|
return renderLoading(action);
|
|
201
198
|
}
|
|
199
|
+
if (error) {
|
|
200
|
+
return renderError(error, "action_error", action);
|
|
201
|
+
}
|
|
202
202
|
return renderCompletedSafe(data, action);
|
|
203
203
|
};
|
|
204
204
|
const defaultPromise = Promise.resolve();
|
|
@@ -1248,7 +1248,11 @@ ${lines.join("\n")}`);
|
|
|
1248
1248
|
for (const actionToReset of willResetSet) {
|
|
1249
1249
|
const actionToResetPrivateProperties =
|
|
1250
1250
|
getActionPrivateProperties(actionToReset);
|
|
1251
|
-
actionToResetPrivateProperties.performReset({
|
|
1251
|
+
actionToResetPrivateProperties.performReset({
|
|
1252
|
+
reason,
|
|
1253
|
+
willRunOrPrerun:
|
|
1254
|
+
willRunSet.has(actionToReset) || willPrerunSet.has(actionToReset),
|
|
1255
|
+
});
|
|
1252
1256
|
activationWeakSet.delete(actionToReset);
|
|
1253
1257
|
}
|
|
1254
1258
|
}
|
|
@@ -1372,7 +1376,6 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1372
1376
|
completed = false,
|
|
1373
1377
|
renderLoadedAsync,
|
|
1374
1378
|
sideEffect = () => {},
|
|
1375
|
-
keepOldData = false,
|
|
1376
1379
|
meta = {},
|
|
1377
1380
|
|
|
1378
1381
|
outputSignal,
|
|
@@ -1414,10 +1417,10 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1414
1417
|
};
|
|
1415
1418
|
/**
|
|
1416
1419
|
* Stop the action completely - this will:
|
|
1417
|
-
* 1. Abort
|
|
1418
|
-
* 2. Reset
|
|
1420
|
+
* 1. Abort if it's currently running
|
|
1421
|
+
* 2. Reset action running signal to IDLE state
|
|
1419
1422
|
* 3. Clean up any resources and side effects
|
|
1420
|
-
* 4. Reset data to initial value
|
|
1423
|
+
* 4. Reset data/error to initial value
|
|
1421
1424
|
*/
|
|
1422
1425
|
const reset = (options) => {
|
|
1423
1426
|
return dispatchSingleAction(action, "reset", options);
|
|
@@ -1747,7 +1750,6 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1747
1750
|
actionAbortMap.set(action, abort);
|
|
1748
1751
|
|
|
1749
1752
|
batch(() => {
|
|
1750
|
-
errorSignal.value = null;
|
|
1751
1753
|
runningStateSignal.value = RUNNING;
|
|
1752
1754
|
if (!isPrerun) {
|
|
1753
1755
|
isPrerunSignal.value = false;
|
|
@@ -1794,6 +1796,7 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1794
1796
|
const value = resultToValue
|
|
1795
1797
|
? resultToValue(runResult, action)
|
|
1796
1798
|
: runResult;
|
|
1799
|
+
errorSignal.value = undefined;
|
|
1797
1800
|
valueSignal.value = value;
|
|
1798
1801
|
runningStateSignal.value = COMPLETED;
|
|
1799
1802
|
const data = dataSignal.value;
|
|
@@ -1897,7 +1900,7 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1897
1900
|
}
|
|
1898
1901
|
};
|
|
1899
1902
|
|
|
1900
|
-
const performReset = ({ reason }) => {
|
|
1903
|
+
const performReset = ({ reason, willRunOrPrerun }) => {
|
|
1901
1904
|
abort(reason);
|
|
1902
1905
|
if (DEBUG$3) {
|
|
1903
1906
|
console.log(`"${action}": resetting (reason: ${reason})`);
|
|
@@ -1912,12 +1915,12 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1912
1915
|
|
|
1913
1916
|
actionPromiseMap.delete(action);
|
|
1914
1917
|
batch(() => {
|
|
1915
|
-
|
|
1916
|
-
|
|
1918
|
+
if (!willRunOrPrerun) {
|
|
1919
|
+
errorSignal.value = undefined;
|
|
1917
1920
|
valueSignal.value = valueInitial;
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
+
if (outputSignal) {
|
|
1922
|
+
outputSignal.value = undefined;
|
|
1923
|
+
}
|
|
1921
1924
|
}
|
|
1922
1925
|
isPrerunSignal.value = true;
|
|
1923
1926
|
runningStateSignal.value = IDLE;
|
|
@@ -1954,10 +1957,14 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
1954
1957
|
* @param {boolean} options.rerunOnChange - Ensures the action is rerun every time a signal value is modified.
|
|
1955
1958
|
* This enables live updates - for example, performing an HTTP GET request every time
|
|
1956
1959
|
* a list of filters changes, providing real-time results without user interaction.
|
|
1957
|
-
* @param {boolean} options.
|
|
1958
|
-
*
|
|
1959
|
-
*
|
|
1960
|
-
*
|
|
1960
|
+
* @param {boolean} options.inheritData - When true, each new target action starts fresh with no inherited state.
|
|
1961
|
+
* By default (false), the proxy carries over the previous target's value and error into the new action.
|
|
1962
|
+
* This keeps the facade in sync with the latest known data: `action.dataSignal.value` only changes when a
|
|
1963
|
+
* new action completes, not when it starts loading. Code that needs to distinguish loading state can still
|
|
1964
|
+
* check `action.runningState`, while code that just reads `action.data` always sees the most recent
|
|
1965
|
+
* available data — even while a newer action is in flight.
|
|
1966
|
+
* This default also enables "Apply Filters" workflows where parameters change but the action only reruns
|
|
1967
|
+
* on an explicit user trigger: the previous results remain visible until the new action completes.
|
|
1961
1968
|
* @param {function} options.onChange - Optional callback triggered when the target action changes
|
|
1962
1969
|
*/
|
|
1963
1970
|
const createActionProxyFromSignal = (
|
|
@@ -1966,7 +1973,7 @@ const createActionProxyFromSignal = (
|
|
|
1966
1973
|
{
|
|
1967
1974
|
runOnce = false,
|
|
1968
1975
|
rerunOnChange = false,
|
|
1969
|
-
|
|
1976
|
+
inheritData = true,
|
|
1970
1977
|
onChange,
|
|
1971
1978
|
syncParams,
|
|
1972
1979
|
} = {},
|
|
@@ -1997,6 +2004,18 @@ const createActionProxyFromSignal = (
|
|
|
1997
2004
|
let currentActionPrivateProperties = getActionPrivateProperties(action);
|
|
1998
2005
|
let actionTargetPreviousWeakRef = null;
|
|
1999
2006
|
|
|
2007
|
+
const createTarget = (params) => {
|
|
2008
|
+
if (inheritData) {
|
|
2009
|
+
const previousActionTarget = actionTargetPreviousWeakRef?.deref();
|
|
2010
|
+
const previousTarget = previousActionTarget || action;
|
|
2011
|
+
return action.bindParams(params, {
|
|
2012
|
+
error: previousTarget.errorSignal.peek(),
|
|
2013
|
+
value: previousTarget.valueSignal.peek(),
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
return action.bindParams(params);
|
|
2017
|
+
};
|
|
2018
|
+
|
|
2000
2019
|
let isUpdatingTarget = false;
|
|
2001
2020
|
const _updateTarget = (context) => {
|
|
2002
2021
|
if (isUpdatingTarget) {
|
|
@@ -2026,7 +2045,7 @@ const createActionProxyFromSignal = (
|
|
|
2026
2045
|
currentAction = action;
|
|
2027
2046
|
currentActionPrivateProperties = getActionPrivateProperties(action);
|
|
2028
2047
|
} else {
|
|
2029
|
-
actionTarget =
|
|
2048
|
+
actionTarget = createTarget(params);
|
|
2030
2049
|
if (previousActionTarget === actionTarget) {
|
|
2031
2050
|
return;
|
|
2032
2051
|
}
|
|
@@ -2069,6 +2088,7 @@ const createActionProxyFromSignal = (
|
|
|
2069
2088
|
return nameSignal.value;
|
|
2070
2089
|
},
|
|
2071
2090
|
});
|
|
2091
|
+
actionWeakMap.set(actionProxy, actionProxy);
|
|
2072
2092
|
}
|
|
2073
2093
|
|
|
2074
2094
|
// Create our own signal for params that we control completely
|
|
@@ -2211,15 +2231,6 @@ const createActionProxyFromSignal = (
|
|
|
2211
2231
|
return true;
|
|
2212
2232
|
};
|
|
2213
2233
|
|
|
2214
|
-
if (transferData) {
|
|
2215
|
-
onActionTargetChange((actionTarget, actionTargetPrevious) => {
|
|
2216
|
-
if (actionTarget && actionTargetPrevious) {
|
|
2217
|
-
const targetValueSignal = actionTarget.valueSignal;
|
|
2218
|
-
const previousValueSignal = actionTargetPrevious.valueSignal;
|
|
2219
|
-
targetValueSignal.value = previousValueSignal.value;
|
|
2220
|
-
}
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
2234
|
if (runOnce) {
|
|
2224
2235
|
onActionTargetChange((actionTarget, actionTargetPrevious) => {
|
|
2225
2236
|
if (!actionTargetPrevious && actionTarget) {
|
|
@@ -2319,9 +2330,11 @@ getActionPrivateProperties(COMPLETED_ACTION).performRun({});
|
|
|
2319
2330
|
const actionRunEffect = (
|
|
2320
2331
|
action,
|
|
2321
2332
|
deriveActionParamsFromSignals,
|
|
2322
|
-
{ debounce,
|
|
2333
|
+
{ debounce, ...options } = {},
|
|
2323
2334
|
) => {
|
|
2324
|
-
if (typeof action === "function")
|
|
2335
|
+
if (typeof action === "function") {
|
|
2336
|
+
action = createAction(action);
|
|
2337
|
+
}
|
|
2325
2338
|
let lastTruthyParams;
|
|
2326
2339
|
let actionParamsSignal = computed(() => {
|
|
2327
2340
|
const params = deriveActionParamsFromSignals();
|
|
@@ -2389,7 +2402,7 @@ const actionRunEffect = (
|
|
|
2389
2402
|
}
|
|
2390
2403
|
}
|
|
2391
2404
|
},
|
|
2392
|
-
|
|
2405
|
+
...options,
|
|
2393
2406
|
});
|
|
2394
2407
|
if (actionParamsSignal.peek()) {
|
|
2395
2408
|
actionRunnedByThisEffect.run({ reason: "initial truthy params" });
|