@webstir-io/module-contract 0.9.0 → 0.9.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.
@@ -20,3 +20,14 @@ export declare const CLIENT_NAV_HEADERS: {
20
20
  * client-nav when it falls back to a normal post.
21
21
  */
22
22
  export declare const CLIENT_NAV_SUBMISSION_FIELD = "_webstir_submission";
23
+ /**
24
+ * The form field carrying the address of the page a form was rendered on, so a failed submission
25
+ * goes back to that page even when the browser sends no Referer, or one that names the address of
26
+ * an earlier failed post.
27
+ */
28
+ export declare const FORM_PAGE_FIELD = "_webstir_page";
29
+ /**
30
+ * The form field an app writes into a form that is one of many on a page (one per item), naming
31
+ * the state its failures go to: `<input type="hidden" name="_webstir_form" value="reply:42">`.
32
+ */
33
+ export declare const FORM_ID_FIELD = "_webstir_form";
@@ -20,3 +20,14 @@ export const CLIENT_NAV_HEADERS = {
20
20
  * client-nav when it falls back to a normal post.
21
21
  */
22
22
  export const CLIENT_NAV_SUBMISSION_FIELD = '_webstir_submission';
23
+ /**
24
+ * The form field carrying the address of the page a form was rendered on, so a failed submission
25
+ * goes back to that page even when the browser sends no Referer, or one that names the address of
26
+ * an earlier failed post.
27
+ */
28
+ export const FORM_PAGE_FIELD = '_webstir_page';
29
+ /**
30
+ * The form field an app writes into a form that is one of many on a page (one per item), naming
31
+ * the state its failures go to: `<input type="hidden" name="_webstir_form" value="reply:42">`.
32
+ */
33
+ export const FORM_ID_FIELD = '_webstir_form';
package/dist/index.d.ts CHANGED
@@ -4683,4 +4683,4 @@ export { RENDER_PROGRAM_FILE, RENDER_PROGRAM_VERSION, renderFlashMessageSchema,
4683
4683
  export type { RenderFlashMessage, RenderNode, RenderPath, RenderProgram, RenderSourceLocation, } from './render-program.js';
4684
4684
  export { executeRenderProgram, programUsesCsrf, readRenderProgram, RENDER_CSRF_FIELD, RenderProgramError, prepareViewData, schemaDeclaresField, withShellData, } from './render-execute.js';
4685
4685
  export type { ExecuteRenderProgramOptions, PreparedViewData } from './render-execute.js';
4686
- export { CLIENT_NAV_HEADERS, CLIENT_NAV_SUBMISSION_FIELD } from './client-nav.js';
4686
+ export { CLIENT_NAV_HEADERS, CLIENT_NAV_SUBMISSION_FIELD, FORM_ID_FIELD, FORM_PAGE_FIELD, } from './client-nav.js';
package/dist/index.js CHANGED
@@ -279,4 +279,4 @@ export function createModule(definition) {
279
279
  export { fromTsRestRoute, fromTsRestRouter } from './adapters/ts-rest.js';
280
280
  export { RENDER_PROGRAM_FILE, RENDER_PROGRAM_VERSION, renderFlashMessageSchema, renderFlashSchema, renderNodeSchema, renderPathSchema, renderProgramSchema, renderSourceLocationSchema, } from './render-program.js';
281
281
  export { executeRenderProgram, programUsesCsrf, readRenderProgram, RENDER_CSRF_FIELD, RenderProgramError, prepareViewData, schemaDeclaresField, withShellData, } from './render-execute.js';
282
- export { CLIENT_NAV_HEADERS, CLIENT_NAV_SUBMISSION_FIELD } from './client-nav.js';
282
+ export { CLIENT_NAV_HEADERS, CLIENT_NAV_SUBMISSION_FIELD, FORM_ID_FIELD, FORM_PAGE_FIELD, } from './client-nav.js';
@@ -15,6 +15,8 @@ export interface ExecuteRenderProgramOptions {
15
15
  * double click) is answered once. Left out, forms render without one.
16
16
  */
17
17
  readonly submissionId?: () => string;
18
+ /** The page's own address, rendered into each POST form so a failure returns to it. */
19
+ readonly pagePath?: string;
18
20
  }
19
21
  export declare function readRenderProgram(value: unknown, source: string): RenderProgram;
20
22
  export declare function programUsesCsrf(program: RenderProgram): boolean;
@@ -1,4 +1,4 @@
1
- import { CLIENT_NAV_SUBMISSION_FIELD } from './client-nav.js';
1
+ import { CLIENT_NAV_SUBMISSION_FIELD, FORM_PAGE_FIELD } from './client-nav.js';
2
2
  import { RENDER_PROGRAM_VERSION } from './render-version.js';
3
3
  export const RENDER_CSRF_FIELD = '_csrf';
4
4
  const SAFE_URL_SCHEMES = new Set(['http', 'https', 'mailto', 'tel']);
@@ -67,6 +67,9 @@ function run(nodes, data, scopes, options, out) {
67
67
  if (options.submissionId) {
68
68
  out.push(`<input type="hidden" name="${CLIENT_NAV_SUBMISSION_FIELD}" value="${escapeAttribute(options.submissionId())}">`);
69
69
  }
70
+ if (options.pagePath) {
71
+ out.push(`<input type="hidden" name="${FORM_PAGE_FIELD}" value="${escapeAttribute(options.pagePath)}">`);
72
+ }
70
73
  break;
71
74
  case 'text': {
72
75
  const value = read(node.path, data, scopes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstir-io/module-contract",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Public contract definitions for Webstir frontend and backend module providers.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",