@askrjs/askr 0.0.98 → 0.0.99
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/actions/index.js +5 -4
- package/dist/benchmark.js +2 -2
- package/package.json +1 -1
package/dist/actions/index.js
CHANGED
|
@@ -11,6 +11,7 @@ function readActionFramework() {
|
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/actions/index.tsx
|
|
14
|
+
const actionSubmissionGenerations = /* @__PURE__ */ new WeakMap();
|
|
14
15
|
function csrfToken() {
|
|
15
16
|
const value = getCurrentRenderData()?.framework.csrf ?? readActionFramework().csrf;
|
|
16
17
|
return typeof value === "string" ? value : void 0;
|
|
@@ -72,11 +73,11 @@ function action(descriptor) {
|
|
|
72
73
|
const runtime = resolveDataRuntimeState();
|
|
73
74
|
const value = state(initialStatus(descriptor.id));
|
|
74
75
|
const setValue = value.set;
|
|
75
|
-
let submissionGeneration = 0;
|
|
76
76
|
return {
|
|
77
77
|
state: value,
|
|
78
78
|
async submit(input) {
|
|
79
|
-
const generation =
|
|
79
|
+
const generation = (actionSubmissionGenerations.get(value) ?? 0) + 1;
|
|
80
|
+
actionSubmissionGenerations.set(value, generation);
|
|
80
81
|
setValue((previous) => ({
|
|
81
82
|
pending: true,
|
|
82
83
|
result: previous.result
|
|
@@ -96,7 +97,7 @@ function action(descriptor) {
|
|
|
96
97
|
if (!response.ok) throw envelope.error ?? validationError(envelope, descriptor.id) ?? /* @__PURE__ */ new Error(`Action failed (${response.status}).`);
|
|
97
98
|
const redirect = typeof envelope.redirect === "string" ? normalizeActionRedirect(envelope.redirect) : void 0;
|
|
98
99
|
const invalidates = Array.isArray(envelope.invalidates) ? envelope.invalidates.filter((prefix) => typeof prefix === "string") : descriptor.invalidates;
|
|
99
|
-
if (generation ===
|
|
100
|
+
if (generation === actionSubmissionGenerations.get(value)) {
|
|
100
101
|
for (const prefix of invalidates) invalidateQueriesForRuntime(runtime, prefix, true);
|
|
101
102
|
setValue({
|
|
102
103
|
pending: false,
|
|
@@ -106,7 +107,7 @@ function action(descriptor) {
|
|
|
106
107
|
}
|
|
107
108
|
return envelope.result;
|
|
108
109
|
} catch (error) {
|
|
109
|
-
if (generation ===
|
|
110
|
+
if (generation === actionSubmissionGenerations.get(value)) setValue({
|
|
110
111
|
pending: false,
|
|
111
112
|
error
|
|
112
113
|
});
|
package/dist/benchmark.js
CHANGED
|
@@ -63,8 +63,8 @@ function BenchmarkTable({ rows, isSelected, onSelect, onRemove }) {
|
|
|
63
63
|
installRendererBridge();
|
|
64
64
|
const benchmarkMetadata = {
|
|
65
65
|
packageName: "@askrjs/askr",
|
|
66
|
-
packageVersion: "0.0.
|
|
67
|
-
buildLabel: "0.0.
|
|
66
|
+
packageVersion: "0.0.99",
|
|
67
|
+
buildLabel: "0.0.99-local"
|
|
68
68
|
};
|
|
69
69
|
function getBenchmarkMetadata() {
|
|
70
70
|
return { ...benchmarkMetadata };
|