svelte-ag 1.1.17 → 1.2.1

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.
Files changed (28) hide show
  1. package/dist/api/form.svelte.d.ts +18 -4
  2. package/dist/api/form.svelte.d.ts.map +1 -1
  3. package/dist/api/form.svelte.js +11 -11
  4. package/dist/bin/build-tailwind-manifest.d.ts +15 -0
  5. package/dist/bin/build-tailwind-manifest.d.ts.map +1 -0
  6. package/dist/bin/build-tailwind-manifest.js +581 -0
  7. package/dist/bin/build-tailwind-manifest.unit.test.d.ts +2 -0
  8. package/dist/bin/build-tailwind-manifest.unit.test.d.ts.map +1 -0
  9. package/dist/bin/build-tailwind-manifest.unit.test.js +208 -0
  10. package/dist/index.d.ts +17 -4
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/tailwind-sources.manifest.jsonc +352 -0
  13. package/dist/vite/index.d.ts +5 -7
  14. package/dist/vite/index.d.ts.map +1 -1
  15. package/dist/vite/tailwind-sources-manifest.d.ts +27 -0
  16. package/dist/vite/tailwind-sources-manifest.d.ts.map +1 -0
  17. package/dist/vite/tailwind-sources-manifest.js +84 -0
  18. package/dist/vite/vite-plugin-component-source-collector.d.ts +5 -7
  19. package/dist/vite/vite-plugin-component-source-collector.d.ts.map +1 -1
  20. package/dist/vite/vite-plugin-component-source-collector.js +253 -21
  21. package/dist/vite/vite-plugin-component-source-collector.unit.test.js +114 -1
  22. package/package.json +10 -3
  23. package/src/lib/api/form.svelte.ts +46 -22
  24. package/src/lib/bin/build-tailwind-manifest.ts +755 -0
  25. package/src/lib/bin/build-tailwind-manifest.unit.test.ts +307 -0
  26. package/src/lib/vite/tailwind-sources-manifest.ts +125 -0
  27. package/src/lib/vite/vite-plugin-component-source-collector.ts +312 -31
  28. package/src/lib/vite/vite-plugin-component-source-collector.unit.test.ts +149 -2
@@ -1,7 +1,18 @@
1
1
  import { superForm } from 'sveltekit-superforms';
2
- import type { SuperForm, SuperValidated } from 'sveltekit-superforms';
2
+ import type { SuperForm } from 'sveltekit-superforms';
3
3
  import type { ApiRequestFunction, HTTPMethod, ApiEndpoints, ApiInput, ApiSuccessBody, ApiErrorBody, ApiSchema } from 'ts-ag';
4
4
  export type ValidInput<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = NonNullable<ApiInput<E, P, M>>;
5
+ type FormProps<T extends ApiEndpoints, P extends T['path'], M extends Extract<T, {
6
+ path: P;
7
+ }>['method']> = NonNullable<Parameters<typeof superForm<ValidInput<T, P, M>>>[1]>;
8
+ type FormOnUpdateArgs<T extends ApiEndpoints, P extends T['path'], M extends Extract<T, {
9
+ path: P;
10
+ }>['method']> = Parameters<NonNullable<FormProps<T, P, M>['onUpdate']>>[0];
11
+ type FormActionArgs<T extends ApiEndpoints, P extends T['path'], M extends Extract<T, {
12
+ path: P;
13
+ }>['method'], B = undefined> = FormOnUpdateArgs<T, P, M> & {
14
+ body: B;
15
+ };
5
16
  /**
6
17
  * Creates a strongly-typed form factory for an API schema.
7
18
  *
@@ -24,11 +35,13 @@ export type ApiRequestForm<API extends ApiEndpoints> = <Path extends API['path']
24
35
  * - `beforeRequest`: called before sending the api call
25
36
  * - `onSuccess`: called after a successful response body is parsed.
26
37
  * - `onFail`: called after an error response body is parsed and mapped to form errors/messages.
38
+ *
39
+ * Each hook receives the `onUpdate` event object plus a `body` field.
27
40
  */
28
41
  actions?: {
29
- beforeRequest?: (form: SuperValidated<ValidInput<API, Path, Method>>) => void | Promise<void>;
30
- onSuccess?: (form: SuperValidated<ValidInput<API, Path, Method>>, response: ApiSuccessBody<API, Path, Method>) => void | Promise<void>;
31
- onFail?: (form: SuperValidated<ValidInput<API, Path, Method>>, response: ApiErrorBody<API, Path, Method>) => void | Promise<void>;
42
+ beforeRequest?: (args: FormActionArgs<API, Path, Method>) => void | Promise<void>;
43
+ onSuccess?: (args: FormActionArgs<API, Path, Method, ApiSuccessBody<API, Path, Method>>) => void | Promise<void>;
44
+ onFail?: (args: FormActionArgs<API, Path, Method, ApiErrorBody<API, Path, Method>>) => void | Promise<void>;
32
45
  };
33
46
  /**
34
47
  * Partial initial values merged into schema defaults via `defaults(..., valibot(schema))`.
@@ -82,4 +95,5 @@ export type ApiRequestForm<API extends ApiEndpoints> = <Path extends API['path']
82
95
  * @returns A function that creates a `SuperForm` for a particular `{path, method}` pair.
83
96
  */
84
97
  export declare function createFormFunction<API extends ApiEndpoints>(schemas: Partial<Record<API['path'], Partial<Record<HTTPMethod, ApiSchema>>>>, request: ApiRequestFunction<API>): ApiRequestForm<API>;
98
+ export {};
85
99
  //# sourceMappingURL=form.svelte.d.ts.map
@@ -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,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtE,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,CACxB,GAAG,SAAS,YAAY,IAEtB,CAAC,IAAI,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,SAAS,OAAO,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;IACvF,qFAAqF;IACrF,IAAI,EAAE,IAAI,CAAC;IAEX,oFAAo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M,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7E,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAC/B,cAAc,CAAC,GAAG,CAAC,CA0GrB"}
@@ -43,32 +43,32 @@ export function createFormFunction(schemas, request) {
43
43
  });
44
44
  }
45
45
  },
46
- async onUpdate({ form }) {
46
+ async onUpdate(props) {
47
47
  if (actions && actions.beforeRequest)
48
- await actions.beforeRequest(form);
49
- if (!form.valid)
48
+ await actions.beforeRequest({ ...props, body: undefined });
49
+ if (!props.form.valid)
50
50
  return;
51
51
  // console.log('onUpdate: sending data', form.data);
52
- const res = await request(path, method, form.data);
52
+ const res = await request(path, method, props.form.data);
53
53
  if (res.ok === false) {
54
- const body = await res.json();
54
+ const body = (await res.json());
55
55
  // TODO set some kind of overall form error if there is no field
56
56
  if (!body.field) {
57
- setMessage(form, body.message);
57
+ setMessage(props.form, body.message);
58
58
  // setError(form, '', body.message);
59
59
  }
60
60
  else {
61
- setError(form, body.field.name, body.field.value, { status: res.status });
61
+ setError(props.form, body.field.name, body.field.value, { status: res.status });
62
62
  }
63
63
  if (actions && actions.onFail) {
64
- await actions.onFail(form, body);
64
+ await actions.onFail({ ...props, body });
65
65
  }
66
66
  }
67
67
  else {
68
- setMessage(form, 'Success');
68
+ setMessage(props.form, 'Success');
69
69
  if (actions && actions.onSuccess) {
70
- const body = await res.json();
71
- await actions.onSuccess(form, body);
70
+ const body = (await res.json());
71
+ await actions.onSuccess({ ...props, body });
72
72
  }
73
73
  }
74
74
  },
@@ -0,0 +1,15 @@
1
+ //#region dist/bin/build-tailwind-manifest.d.ts
2
+ type GeneratorOptions = {
3
+ exportFilters: string[];
4
+ };
5
+ /** Build a Tailwind source manifest for one package export map. */
6
+ declare function generateTailwindManifestForPackage(packageDir: string, options: GeneratorOptions): Promise<{
7
+ didWrite: boolean;
8
+ outputFile: string;
9
+ exportCount: number;
10
+ }>;
11
+ /** Run the manifest builder once or in watch mode from the current working directory. */
12
+ declare function main(argv?: string[]): Promise<void>;
13
+ //#endregion
14
+ export { generateTailwindManifestForPackage, main };
15
+ //# sourceMappingURL=build-tailwind-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-tailwind-manifest.d.ts","names":["GeneratorOptions","exportFilters","generateTailwindManifestForPackage","Promise","packageDir","options","didWrite","outputFile","exportCount","main","argv"],"sources":["../../home/runner/work/svelte-ag/svelte-ag/dist/bin/build-tailwind-manifest.d.ts"],"mappings":";KAAKA,gBAAAA;EACDC,aAAAA;AAAAA;;iBAGoBC,kCAAAA,CAAmCE,UAAAA,UAAoBC,OAAAA,EAASL,gBAAAA,GAAmBG,OAAAA;EACvGG,QAAAA;EACAC,UAAAA;EACAC,WAAAA;AAAAA;;iBAGoBC,IAAAA,CAAKC,IAAAA,cAAkBP,OAAAA"}