@effect-app/vue-components 2.6.1 → 2.6.2
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.
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { useForm as z } from "@tanstack/vue-form";
|
|
2
|
-
import { Data as K, S as
|
|
3
|
-
import { runtimeFiberAsPromise as
|
|
4
|
-
import { isObject as
|
|
5
|
-
import { computed as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
2
|
+
import { Data as K, S as w, Effect as c, Fiber as U, Option as A, Array as j } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as Z } from "./vue-components.es16.js";
|
|
4
|
+
import { isObject as G } from "./vue-components.es17.js";
|
|
5
|
+
import { computed as D, onUnmounted as R, onMounted as Q, onBeforeUnmount as X, watch as T, ref as Y, h as q } from "vue";
|
|
6
|
+
import C from "./vue-components.es18.js";
|
|
7
|
+
import ee from "./vue-components.es19.js";
|
|
8
|
+
import te from "./vue-components.es20.js";
|
|
9
9
|
import { generateMetaFromSchema as re } from "./vue-components.es12.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import ne from "./vue-components.es6.js";
|
|
11
|
+
import se from "./vue-components.es8.js";
|
|
12
|
+
import oe from "./vue-components.es21.js";
|
|
13
13
|
import { trace as B } from "./vue-components.es22.js";
|
|
14
|
-
import { context as
|
|
15
|
-
class
|
|
14
|
+
import { context as V } from "./vue-components.es23.js";
|
|
15
|
+
class ie extends K.TaggedError("FormErrors") {
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const O = (a) => function(i) {
|
|
18
18
|
return {
|
|
19
19
|
render() {
|
|
20
20
|
return q(i, {
|
|
@@ -23,36 +23,36 @@ const F = (a) => function(i) {
|
|
|
23
23
|
}, this.$slots);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
},
|
|
26
|
+
}, ae = (a) => function(i) {
|
|
27
27
|
return {
|
|
28
28
|
setup() {
|
|
29
|
-
const { fieldMap:
|
|
30
|
-
const u =
|
|
31
|
-
Object.entries(
|
|
32
|
-
([
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
const
|
|
36
|
-
return
|
|
37
|
-
label:
|
|
38
|
-
inputId:
|
|
29
|
+
const { fieldMap: h, form: p } = a, f = p.useStore((u) => u.errors), d = p.useStore((u) => u.fieldMeta), k = p.useStore((u) => u.errorMap), x = D(() => {
|
|
30
|
+
const u = j.filterMap(
|
|
31
|
+
Object.entries(d.value),
|
|
32
|
+
([E, v]) => {
|
|
33
|
+
const b = v.errors ?? [];
|
|
34
|
+
if (!b.length) return A.none();
|
|
35
|
+
const o = h.value.get(E);
|
|
36
|
+
return o ? A.some({
|
|
37
|
+
label: o.label,
|
|
38
|
+
inputId: o.id,
|
|
39
39
|
// Only show the first error
|
|
40
|
-
errors: [
|
|
41
|
-
}) :
|
|
40
|
+
errors: [b[0]?.message].filter(Boolean)
|
|
41
|
+
}) : A.none();
|
|
42
42
|
}
|
|
43
43
|
), y = [];
|
|
44
|
-
if (
|
|
45
|
-
for (const [
|
|
46
|
-
if (
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
44
|
+
if (k.value.onSubmit) {
|
|
45
|
+
for (const [E, v] of Object.entries(k.value.onSubmit))
|
|
46
|
+
if (j.isArray(v) && v.length)
|
|
47
|
+
for (const b of v) {
|
|
48
|
+
const o = b;
|
|
49
|
+
if (o?.path && j.isArray(o.path) && o.path.length) {
|
|
50
|
+
const g = o.path.join(".");
|
|
51
|
+
if (!h.value.has(g)) {
|
|
52
52
|
y.push({
|
|
53
|
-
label:
|
|
54
|
-
inputId:
|
|
55
|
-
errors: [
|
|
53
|
+
label: g,
|
|
54
|
+
inputId: g,
|
|
55
|
+
errors: [o.message].filter(Boolean)
|
|
56
56
|
});
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
@@ -63,187 +63,209 @@ const F = (a) => function(i) {
|
|
|
63
63
|
});
|
|
64
64
|
return {
|
|
65
65
|
generalErrors: f,
|
|
66
|
-
errors:
|
|
66
|
+
errors: x
|
|
67
67
|
};
|
|
68
68
|
},
|
|
69
|
-
render({ errors:
|
|
69
|
+
render({ errors: h, generalErrors: p }) {
|
|
70
70
|
return q(i, {
|
|
71
|
-
errors:
|
|
72
|
-
generalErrors:
|
|
71
|
+
errors: h,
|
|
72
|
+
generalErrors: p,
|
|
73
73
|
...this.$attrs
|
|
74
74
|
}, this.$slots);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
},
|
|
77
|
+
}, ge = (a, m, i) => {
|
|
78
78
|
if (!a) throw new Error("Schema is required");
|
|
79
|
-
const
|
|
79
|
+
const h = w.standardSchemaV1(a), p = w.decode(a), { meta: f } = re(a), d = D(() => {
|
|
80
80
|
if (i?.persistency?.id)
|
|
81
81
|
return i.persistency.id;
|
|
82
|
-
const e = window.location.pathname,
|
|
83
|
-
return `${e}-${
|
|
84
|
-
}),
|
|
82
|
+
const e = window.location.pathname, t = Object.keys(f);
|
|
83
|
+
return `${e}-${t.join("-")}`;
|
|
84
|
+
}), k = () => {
|
|
85
85
|
const e = new URLSearchParams(window.location.search);
|
|
86
|
-
e.delete(
|
|
87
|
-
const
|
|
88
|
-
|
|
86
|
+
e.delete(d.value);
|
|
87
|
+
const t = new URL(window.location.href);
|
|
88
|
+
t.search = e.toString(), window.history.replaceState({}, "", t.toString());
|
|
89
89
|
};
|
|
90
|
-
function
|
|
91
|
-
for (const
|
|
92
|
-
r
|
|
90
|
+
function x(e, t) {
|
|
91
|
+
for (const r in t)
|
|
92
|
+
t[r] && G(t[r]) ? (e[r] || (e[r] = {}), x(e[r], t[r])) : e[r] = t[r];
|
|
93
93
|
return e;
|
|
94
94
|
}
|
|
95
95
|
const u = (e) => {
|
|
96
96
|
if (!e) return;
|
|
97
|
-
const
|
|
98
|
-
for (const
|
|
99
|
-
const s = f[
|
|
100
|
-
s && !s.required && s.nullableOrUndefined && s.type !== "boolean" && (
|
|
97
|
+
const t = { ...e };
|
|
98
|
+
for (const r in f) {
|
|
99
|
+
const s = f[r], n = t[r], F = (n == null || n === !1 || n === "" || Number.isNaN(n)) && n !== !1 && n !== 0;
|
|
100
|
+
s && !s.required && s.nullableOrUndefined && s.type !== "boolean" && (n === void 0 || F) && (t[r] = s.nullableOrUndefined === "undefined" ? void 0 : null);
|
|
101
101
|
}
|
|
102
|
-
return
|
|
103
|
-
}, y = (e
|
|
102
|
+
return t;
|
|
103
|
+
}, y = (e) => {
|
|
104
|
+
const t = {};
|
|
105
|
+
if (e?.fields && typeof e.fields == "object")
|
|
106
|
+
for (const [r, s] of Object.entries(e.fields)) {
|
|
107
|
+
if (s?.ast?.defaultValue)
|
|
108
|
+
try {
|
|
109
|
+
const l = s.ast.defaultValue();
|
|
110
|
+
l !== void 0 && (t[r] = l);
|
|
111
|
+
} catch {
|
|
112
|
+
}
|
|
113
|
+
const n = y(s);
|
|
114
|
+
Object.keys(n).length > 0 && (t[r] && typeof t[r] == "object" ? Object.assign(t[r], n) : t[r] || (t[r] = n));
|
|
115
|
+
}
|
|
116
|
+
return t;
|
|
117
|
+
}, E = (e = {}) => {
|
|
104
118
|
try {
|
|
105
|
-
if ("make" in a && typeof a.make == "function")
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
if ("make" in a && typeof a.make == "function") {
|
|
120
|
+
const t = a.make(e);
|
|
121
|
+
return w.encodeSync(a.pipe(w.partial))(t);
|
|
122
|
+
}
|
|
123
|
+
} catch (t) {
|
|
124
|
+
window.location.hostname === "localhost" && console.warn("schema.make() failed, extracting defaults from AST:", t);
|
|
125
|
+
try {
|
|
126
|
+
const r = y(a);
|
|
127
|
+
return w.encodeSync(a.pipe(w.partial))(r);
|
|
128
|
+
} catch (r) {
|
|
129
|
+
return window.location.hostname === "localhost" && console.warn("Could not extract defaults from AST:", r), {};
|
|
130
|
+
}
|
|
109
131
|
}
|
|
110
|
-
},
|
|
111
|
-
const e =
|
|
132
|
+
}, v = D(() => {
|
|
133
|
+
const e = E(u(m?.defaultValues));
|
|
112
134
|
if (e && !i?.persistency?.overrideDefaultValues)
|
|
113
135
|
return e;
|
|
114
|
-
let
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
if (
|
|
136
|
+
let t;
|
|
137
|
+
const r = i?.persistency;
|
|
138
|
+
if (!r?.policies || r.policies.length === 0) return {};
|
|
139
|
+
if (r.policies.includes("querystring"))
|
|
118
140
|
try {
|
|
119
|
-
const
|
|
120
|
-
|
|
141
|
+
const n = new URLSearchParams(window.location.search).get(d.value);
|
|
142
|
+
k(), n && (t = JSON.parse(n));
|
|
121
143
|
} catch (s) {
|
|
122
144
|
console.error(s);
|
|
123
145
|
}
|
|
124
146
|
if (
|
|
125
147
|
// query string has higher priority than local/session storage
|
|
126
|
-
!
|
|
148
|
+
!t && (r.policies.includes("local") || r.policies.includes("session"))
|
|
127
149
|
) {
|
|
128
|
-
const s =
|
|
150
|
+
const s = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
129
151
|
if (s)
|
|
130
152
|
try {
|
|
131
|
-
const
|
|
132
|
-
s.getItem(
|
|
153
|
+
const n = JSON.parse(
|
|
154
|
+
s.getItem(d.value) || "{}"
|
|
133
155
|
);
|
|
134
|
-
s.removeItem(
|
|
135
|
-
} catch (
|
|
136
|
-
console.error(
|
|
156
|
+
s.removeItem(d.value), t = n;
|
|
157
|
+
} catch (n) {
|
|
158
|
+
console.error(n);
|
|
137
159
|
}
|
|
138
160
|
}
|
|
139
|
-
return
|
|
140
|
-
}),
|
|
141
|
-
...
|
|
161
|
+
return t ??= E({}), e ? x(e, t) : t;
|
|
162
|
+
}), b = (e, t) => e ? V.with(B.setSpan(V.active(), e), t) : t(), o = z({
|
|
163
|
+
...m,
|
|
142
164
|
validators: {
|
|
143
|
-
onSubmit:
|
|
144
|
-
...
|
|
165
|
+
onSubmit: h,
|
|
166
|
+
...m?.validators || {}
|
|
145
167
|
},
|
|
146
|
-
onSubmit:
|
|
147
|
-
const s = await c.runPromise(
|
|
168
|
+
onSubmit: m?.onSubmit ? ({ formApi: e, meta: t, value: r }) => b(t?.currentSpan, async () => {
|
|
169
|
+
const s = await c.runPromise(p(r)), n = m.onSubmit({
|
|
148
170
|
formApi: e,
|
|
149
|
-
meta:
|
|
171
|
+
meta: t,
|
|
150
172
|
value: s
|
|
151
173
|
});
|
|
152
|
-
return
|
|
153
|
-
|
|
174
|
+
return U.isFiber(n) && U.isRuntimeFiber(n) ? await Z(n) : c.isEffect(n) ? await c.runPromise(
|
|
175
|
+
n.pipe(
|
|
154
176
|
// meta?.currentSpan
|
|
155
177
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
156
178
|
// : (_) => _,
|
|
157
|
-
c.flatMap((
|
|
179
|
+
c.flatMap((l) => U.join(l))
|
|
158
180
|
)
|
|
159
|
-
) :
|
|
181
|
+
) : n;
|
|
160
182
|
}) : void 0,
|
|
161
|
-
defaultValues:
|
|
162
|
-
}),
|
|
183
|
+
defaultValues: v.value
|
|
184
|
+
}), g = () => {
|
|
163
185
|
Object.keys(f).forEach((e) => {
|
|
164
186
|
o.setFieldValue(e, void 0);
|
|
165
187
|
});
|
|
166
|
-
},
|
|
167
|
-
const s =
|
|
168
|
-
return s.reduce((
|
|
188
|
+
}, N = (e) => e.reduce((t, r) => {
|
|
189
|
+
const s = r.split(".");
|
|
190
|
+
return s.reduce((n, l, F) => (F === s.length - 1 ? n[l] = o.getFieldValue(r) : n[l] = n[l] ?? {}, n[l]), t), t;
|
|
169
191
|
}, {}), _ = (e) => {
|
|
170
192
|
if (e) {
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
return
|
|
193
|
+
if (j.isArray(e.keys))
|
|
194
|
+
return N(e.keys);
|
|
195
|
+
if (j.isArray(e.banKeys)) {
|
|
196
|
+
const t = Object.keys(f).filter((r) => e.banKeys?.includes(r));
|
|
197
|
+
return N(t);
|
|
176
198
|
}
|
|
177
199
|
return o.store.state.values;
|
|
178
200
|
}
|
|
179
|
-
},
|
|
201
|
+
}, M = () => {
|
|
180
202
|
const e = i?.persistency;
|
|
181
203
|
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
184
|
-
const
|
|
185
|
-
return
|
|
204
|
+
const t = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
205
|
+
if (!t) return;
|
|
206
|
+
const r = _(e);
|
|
207
|
+
return t.setItem(d.value, JSON.stringify(r));
|
|
186
208
|
}
|
|
187
209
|
}, L = () => {
|
|
188
210
|
const e = i?.persistency;
|
|
189
211
|
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
190
|
-
const
|
|
191
|
-
|
|
212
|
+
const t = _(e), r = new URLSearchParams(window.location.search);
|
|
213
|
+
r.set(d.value, JSON.stringify(t));
|
|
192
214
|
const s = new URL(window.location.href);
|
|
193
|
-
s.search =
|
|
215
|
+
s.search = r.toString(), window.history.replaceState({}, "", s.toString());
|
|
194
216
|
}
|
|
195
|
-
},
|
|
217
|
+
}, I = (e) => {
|
|
196
218
|
o.store.state.isDirty && e.preventDefault();
|
|
197
219
|
};
|
|
198
|
-
if (
|
|
199
|
-
window.addEventListener("beforeunload",
|
|
200
|
-
}),
|
|
201
|
-
window.removeEventListener("beforeunload",
|
|
220
|
+
if (R(M), Q(() => {
|
|
221
|
+
window.addEventListener("beforeunload", M), window.addEventListener("blur", L), i?.preventWindowExit && i.preventWindowExit !== "nope" && window.addEventListener("beforeunload", I);
|
|
222
|
+
}), X(() => {
|
|
223
|
+
window.removeEventListener("beforeunload", M), window.removeEventListener("blur", L), i?.preventWindowExit && i.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", I);
|
|
202
224
|
}), i?.preventWindowExit === "prevent-and-reset") {
|
|
203
|
-
const e = o.useStore((
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
const e = o.useStore((n) => n.isSubmitting), t = o.useStore((n) => n.submissionAttempts), r = o.useStore((n) => n.canSubmit), s = o.useStore((n) => n.values);
|
|
226
|
+
T([e, t], ([n, l], [F]) => {
|
|
227
|
+
F && !n && l > 0 && r.value && o.reset(s.value);
|
|
206
228
|
});
|
|
207
229
|
}
|
|
208
|
-
const
|
|
230
|
+
const $ = (e) => c.currentSpan.pipe(
|
|
209
231
|
c.option,
|
|
210
232
|
c.flatMap(
|
|
211
|
-
(
|
|
233
|
+
(t) => c.promise(() => o.handleSubmit(A.isSome(t) ? { currentSpan: t.value, ...e } : e))
|
|
212
234
|
)
|
|
213
|
-
), H = (e) => e?.checkErrors ?
|
|
214
|
-
const
|
|
215
|
-
if (Object.keys(
|
|
216
|
-
return yield* new
|
|
217
|
-
}))) :
|
|
235
|
+
), H = (e) => e?.checkErrors ? $(e?.meta).pipe(c.flatMap(c.fnUntraced(function* () {
|
|
236
|
+
const t = o.getAllErrors();
|
|
237
|
+
if (Object.keys(t.fields).length || t.form.errors.length)
|
|
238
|
+
return yield* new ie({ form: t.form, fields: t.fields });
|
|
239
|
+
}))) : $(e?.meta), J = o.handleSubmit, P = Y(/* @__PURE__ */ new Map()), S = Object.assign(o, {
|
|
218
240
|
i18nNamespace: i?.i18nNamespace,
|
|
219
241
|
ignorePreventCloseEvents: i?.ignorePreventCloseEvents,
|
|
220
242
|
meta: f,
|
|
221
|
-
clear:
|
|
243
|
+
clear: g,
|
|
222
244
|
handleSubmit: (e) => {
|
|
223
|
-
const
|
|
224
|
-
return J({ currentSpan:
|
|
245
|
+
const t = B.getSpan(V.active());
|
|
246
|
+
return J({ currentSpan: t, ...e });
|
|
225
247
|
},
|
|
226
248
|
// /** @experimental */
|
|
227
249
|
handleSubmitEffect: H,
|
|
228
250
|
registerField: (e) => {
|
|
229
|
-
|
|
251
|
+
T(e, (t) => P.value.set(t.name, { label: t.label, id: t.id }), { immediate: !0 }), R(() => P.value.delete(e.value.name));
|
|
230
252
|
}
|
|
231
|
-
}),
|
|
253
|
+
}), W = { form: S, fieldMap: P };
|
|
232
254
|
return Object.assign(S, {
|
|
233
255
|
// Type-level properties for performance optimization (not used at runtime)
|
|
234
256
|
_paths: void 0,
|
|
235
257
|
_keys: void 0,
|
|
236
|
-
errorContext:
|
|
237
|
-
Form:
|
|
238
|
-
Input:
|
|
239
|
-
TaggedUnion:
|
|
258
|
+
errorContext: W,
|
|
259
|
+
Form: O(S)(oe),
|
|
260
|
+
Input: O(S)(i?.input ?? ne),
|
|
261
|
+
TaggedUnion: O(S)(se),
|
|
240
262
|
Field: o.Field,
|
|
241
|
-
Errors:
|
|
242
|
-
Array:
|
|
243
|
-
AutoGen:
|
|
263
|
+
Errors: ae(W)(te),
|
|
264
|
+
Array: O(S)(C),
|
|
265
|
+
AutoGen: O(S)(ee)
|
|
244
266
|
});
|
|
245
267
|
};
|
|
246
268
|
export {
|
|
247
|
-
|
|
248
|
-
|
|
269
|
+
ie as FormErrors,
|
|
270
|
+
ge as useOmegaForm
|
|
249
271
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^3.18.0",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"highlight.js": "^11.11.1",
|
|
54
54
|
"mitt": "^3.0.1",
|
|
55
55
|
"vue3-highlightjs": "^1.0.5",
|
|
56
|
-
"
|
|
57
|
-
"effect-app": "
|
|
56
|
+
"effect-app": "3.12.0",
|
|
57
|
+
"@effect-app/vue": "2.92.2"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "pnpm build:run",
|
|
@@ -706,16 +706,66 @@ export const useOmegaForm = <
|
|
|
706
706
|
return normalized
|
|
707
707
|
}
|
|
708
708
|
|
|
709
|
+
// Helper function to recursively extract default values from schema AST
|
|
710
|
+
const extractDefaultsFromAST = (schemaObj: any): any => {
|
|
711
|
+
const result: Record<string, any> = {}
|
|
712
|
+
|
|
713
|
+
// Check if this schema has fields (struct)
|
|
714
|
+
if (schemaObj?.fields && typeof schemaObj.fields === "object") {
|
|
715
|
+
for (const [key, fieldSchema] of Object.entries(schemaObj.fields)) {
|
|
716
|
+
// Check if this field has a default value in its AST
|
|
717
|
+
if ((fieldSchema as any)?.ast?.defaultValue) {
|
|
718
|
+
try {
|
|
719
|
+
const defaultValue = (fieldSchema as any).ast.defaultValue()
|
|
720
|
+
if (defaultValue !== undefined) {
|
|
721
|
+
result[key] = defaultValue
|
|
722
|
+
}
|
|
723
|
+
} catch {
|
|
724
|
+
// Silently ignore if defaultValue() throws
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// Recursively check nested fields for structs
|
|
729
|
+
const nestedDefaults = extractDefaultsFromAST(fieldSchema as any)
|
|
730
|
+
if (Object.keys(nestedDefaults).length > 0) {
|
|
731
|
+
// If we already have a default value for this key, merge with nested
|
|
732
|
+
if (result[key] && typeof result[key] === "object") {
|
|
733
|
+
Object.assign(result[key], nestedDefaults)
|
|
734
|
+
} else if (!result[key]) {
|
|
735
|
+
// Only set nested defaults if we don't have a default value
|
|
736
|
+
result[key] = nestedDefaults
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return result
|
|
743
|
+
}
|
|
744
|
+
|
|
709
745
|
// Extract default values from schema constructors (e.g., withDefaultConstructor)
|
|
710
746
|
const extractSchemaDefaults = (defaultValues: Partial<From> = {}) => {
|
|
711
747
|
try {
|
|
748
|
+
// First try to use schema.make() if available
|
|
712
749
|
// Note: Partial schemas don't have .make() method yet (https://github.com/Effect-TS/effect/issues/4222)
|
|
713
750
|
if ("make" in schema && typeof (schema as any).make === "function") {
|
|
714
|
-
|
|
751
|
+
const decoded = (schema as any).make(defaultValues)
|
|
752
|
+
return S.encodeSync(schema.pipe(S.partial))(decoded)
|
|
715
753
|
}
|
|
716
754
|
} catch (error) {
|
|
717
|
-
|
|
718
|
-
|
|
755
|
+
// If make() fails, try to extract defaults from AST
|
|
756
|
+
if (window.location.hostname === "localhost") {
|
|
757
|
+
console.warn("schema.make() failed, extracting defaults from AST:", error)
|
|
758
|
+
}
|
|
759
|
+
try {
|
|
760
|
+
const astDefaults = extractDefaultsFromAST(schema)
|
|
761
|
+
|
|
762
|
+
return S.encodeSync(schema.pipe(S.partial))(astDefaults)
|
|
763
|
+
} catch (astError) {
|
|
764
|
+
if (window.location.hostname === "localhost") {
|
|
765
|
+
console.warn("Could not extract defaults from AST:", astError)
|
|
766
|
+
}
|
|
767
|
+
return {}
|
|
768
|
+
}
|
|
719
769
|
}
|
|
720
770
|
}
|
|
721
771
|
|