svelte-ag 1.0.18 → 1.0.19

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 +1 @@
1
- {"version":3,"file":"form.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/api/form.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkC,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,SAAS,EACV,MAAM,OAAO,CAAC;AAMf,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,WAAW,CACtG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAClB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,CAAC,GAAG,SAAS,YAAY,IAAI,CACrD,IAAI,SAAS,GAAG,CAAC,MAAM,CAAC,EACxB,MAAM,SAAS,OAAO,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,EACrD,CAAC,EAAE;IACH,qFAAqF;IACrF,IAAI,EAAE,IAAI,CAAC;IAEX,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,CACV,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EACnD,QAAQ,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,KACxC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAA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E,MAAM,CAAC,KACtC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IAEF;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAEpD;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,CAAC,EAAE;QACL;;;;;WAKG;QACH,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE9E;;;WAGG;QACH,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;KACtD,CAAC;IAEF;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5E,KAAK,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,SAAS,YAAY,EACzD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7E,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAC/B,cAAc,CAAC,GAAG,CAAC,CA2GrB"}
@@ -3,7 +3,7 @@ import { valibot } from 'sveltekit-superforms/adapters';
3
3
  import { watch } from 'runed';
4
4
  import { dequal } from 'dequal';
5
5
  import { get } from 'svelte/store';
6
- import { safeParseAsync } from 'valibot';
6
+ import { safeParse, safeParseAsync } from 'valibot';
7
7
  /**
8
8
  * Build an endpoint-specific Superforms factory.
9
9
  *
@@ -20,7 +20,11 @@ export function createFormFunction(schemas, request) {
20
20
  // if (typeof schema === 'function') {
21
21
  // schema = schema();
22
22
  // }
23
- const form = superForm(defaults(defaultValue, valibot(schema)), {
23
+ const defaultFormData = defaults(defaultValue, valibot(schema));
24
+ const boundFormData = bind && schema.async === false
25
+ ? safeParse(schema, bind.get(defaultFormData)).output
26
+ : defaultFormData;
27
+ const form = superForm(boundFormData, {
24
28
  SPA: true,
25
29
  resetForm: true,
26
30
  applyAction: false, // Prevents the form redirecting to the same page on submit
@@ -1,5 +1,5 @@
1
1
  import type { SearchProps } from '../types.js';
2
- declare const Search: import("svelte").Component<SearchProps, {}, "items" | "value" | "ref" | "searchWith">;
2
+ declare const Search: import("svelte").Component<SearchProps, {}, "value" | "items" | "ref" | "searchWith">;
3
3
  type Search = ReturnType<typeof Search>;
4
4
  export default Search;
5
5
  //# sourceMappingURL=search.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-component-source-collector.d.ts","sourceRoot":"","sources":["../../../src/lib/vite/vite-plugin-component-source-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAKnD,UAAU,OAAO;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAKD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,IAAI,GAAE,OAA8B,GAAG,MAAM,CAsH7F"}
1
+ {"version":3,"file":"vite-plugin-component-source-collector.d.ts","sourceRoot":"","sources":["../../../src/lib/vite/vite-plugin-component-source-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAKnD,UAAU,OAAO;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAKD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,IAAI,GAAE,OAA8B,GAAG,MAAM,CA0H7F"}
@@ -48,7 +48,7 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
48
48
  // ---- plugin ---- //
49
49
  return {
50
50
  name: 'vite-plugin-component-source-collector',
51
- enforce: 'post',
51
+ enforce: 'pre', // i want to see comments
52
52
  async configResolved(resolved) {
53
53
  config = resolved;
54
54
  const outPath = resolve(config.root, outFileName);
@@ -76,9 +76,14 @@ export default function componentSourceCollector(opts = { safePackages: [] }) {
76
76
  const matches = code.matchAll(importRegex);
77
77
  for (const match of matches) {
78
78
  // console.log('MATching', match);
79
- const resolved = await this.resolve(match[1], id);
80
- if (resolved) {
81
- addPath(resolved.id);
79
+ try {
80
+ const resolved = await this.resolve(match[1], id);
81
+ if (resolved) {
82
+ addPath(resolved.id);
83
+ }
84
+ }
85
+ catch {
86
+ // Cant resolve: dont add
82
87
  }
83
88
  }
84
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-ag",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Useful svelte components",
5
5
  "bugs": "https://github.com/ageorgeh/svelte-ag/issues",
6
6
  "repository": {
@@ -12,7 +12,7 @@ import type {
12
12
  import { watch } from 'runed';
13
13
  import { dequal } from 'dequal';
14
14
  import { get } from 'svelte/store';
15
- import { safeParseAsync } from 'valibot';
15
+ import { safeParse, safeParseAsync } from 'valibot';
16
16
 
17
17
  export type ValidInput<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = NonNullable<
18
18
  ApiInput<E, P, M>
@@ -121,7 +121,13 @@ export function createFormFunction<API extends ApiEndpoints>(
121
121
  // schema = schema();
122
122
  // }
123
123
 
124
- const form = superForm<ValidInput<API, typeof path, typeof method>>(defaults(defaultValue, valibot(schema)), {
124
+ const defaultFormData = defaults(defaultValue, valibot(schema));
125
+ const boundFormData =
126
+ bind && schema.async === false
127
+ ? (safeParse(schema, bind.get(defaultFormData)).output as ValidInput<API, typeof path, typeof method>)
128
+ : defaultFormData;
129
+
130
+ const form = superForm<ValidInput<API, typeof path, typeof method>>(boundFormData, {
125
131
  SPA: true,
126
132
  resetForm: true,
127
133
  applyAction: false, // Prevents the form redirecting to the same page on submit
@@ -78,7 +78,7 @@ export default function componentSourceCollector(opts: Options = { safePackages:
78
78
 
79
79
  return {
80
80
  name: 'vite-plugin-component-source-collector',
81
- enforce: 'post',
81
+ enforce: 'pre', // i want to see comments
82
82
 
83
83
  async configResolved(resolved) {
84
84
  config = resolved;
@@ -110,9 +110,13 @@ export default function componentSourceCollector(opts: Options = { safePackages:
110
110
 
111
111
  for (const match of matches) {
112
112
  // console.log('MATching', match);
113
- const resolved = await this.resolve(match[1], id);
114
- if (resolved) {
115
- addPath(resolved.id);
113
+ try {
114
+ const resolved = await this.resolve(match[1], id);
115
+ if (resolved) {
116
+ addPath(resolved.id);
117
+ }
118
+ } catch {
119
+ // Cant resolve: dont add
116
120
  }
117
121
  }
118
122
  }