@hyperspan/framework 0.5.2 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperspan/framework",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Hyperspan Web Framework",
5
5
  "main": "dist/server.ts",
6
6
  "types": "src/server.ts",
package/src/actions.ts CHANGED
@@ -30,22 +30,25 @@ export interface HSAction<T extends z.ZodTypeAny> {
30
30
  form(
31
31
  renderForm: (
32
32
  c: THSContext,
33
- { data, error }: { data?: z.infer<T>; error?: z.ZodError | Error }
33
+ { data, error }: { data?: Partial<z.infer<T>>; error?: z.ZodError | Error }
34
34
  ) => HSHtml | void | null | Promise<HSHtml | void | null>
35
35
  ): HSAction<T>;
36
36
  post(
37
37
  handler: (
38
38
  c: THSContext,
39
- { data }: { data?: z.infer<T> }
39
+ { data }: { data?: Partial<z.infer<T>> }
40
40
  ) => TActionResponse | Promise<TActionResponse>
41
41
  ): HSAction<T>;
42
42
  error(
43
43
  handler: (
44
44
  c: THSContext,
45
- { data, error }: { data?: z.infer<T>; error?: z.ZodError | Error }
45
+ { data, error }: { data?: Partial<z.infer<T>>; error?: z.ZodError | Error }
46
46
  ) => TActionResponse
47
47
  ): HSAction<T>;
48
- render(c: THSContext, props?: { data?: z.infer<T>; error?: z.ZodError | Error }): TActionResponse;
48
+ render(
49
+ c: THSContext,
50
+ props?: { data?: Partial<z.infer<T>>; error?: z.ZodError | Error }
51
+ ): TActionResponse;
49
52
  run(c: THSContext): TActionResponse | Promise<TActionResponse>;
50
53
  middleware: (
51
54
  middleware: Array<
@@ -108,7 +111,7 @@ export function unstable__createAction<T extends z.ZodTypeAny>(
108
111
  /**
109
112
  * Get form renderer method
110
113
  */
111
- render(c: THSContext, formState?: { data?: z.infer<T>; error?: z.ZodError | Error }) {
114
+ render(c: THSContext, formState?: { data?: Partial<z.infer<T>>; error?: z.ZodError | Error }) {
112
115
  const form = _form ? _form(c, formState || {}) : null;
113
116
  return form ? html`<hs-action url="${this._route}">${form}</hs-action>` : null;
114
117
  },
@@ -149,9 +152,9 @@ export function unstable__createAction<T extends z.ZodTypeAny>(
149
152
  }
150
153
 
151
154
  const formData = await c.req.formData();
152
- const jsonData = unstable__formDataToJSON(formData);
155
+ const jsonData = unstable__formDataToJSON(formData) as Partial<z.infer<T>>;
153
156
  const schemaData = schema ? schema.safeParse(jsonData) : null;
154
- const data = schemaData?.success ? (schemaData.data as z.infer<T>) : jsonData;
157
+ const data = schemaData?.success ? (schemaData.data as Partial<z.infer<T>>) : jsonData;
155
158
  let error: z.ZodError | Error | null = null;
156
159
 
157
160
  try {
package/src/plugins.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { assetHash, CLIENTJS_PUBLIC_PATH, clientImportMap, clientJSFiles } from './assets';
1
+ import { assetHash, CLIENTJS_PUBLIC_PATH, clientImportMap } from './assets';
2
2
  import { IS_PROD, type THSServerConfig } from './server';
3
3
 
4
4
  const CLIENT_JS_CACHE = new Map<string, string>();