forgeframe 0.0.2 → 0.0.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/README.md CHANGED
@@ -55,6 +55,7 @@ Imagine a payment company (like Stripe) wants to let merchants embed a checkout
55
55
  ## Table of Contents
56
56
 
57
57
  - [Installation](#installation)
58
+ - [Start Here (Most Users)](#start-here-most-users)
58
59
  - [Quick Start](#quick-start)
59
60
  - [Step-by-Step Guide](#step-by-step-guide)
60
61
  - [1. Define a Component](#1-define-a-component)
@@ -63,8 +64,8 @@ Imagine a payment company (like Stripe) wants to let merchants embed a checkout
63
64
  - [4. Handle Events](#4-handle-events)
64
65
  - [Props System](#props-system)
65
66
  - [Host Window API (hostProps)](#host-window-api-hostprops)
66
- - [Templates](#templates)
67
- - [React Integration](#react-integration)
67
+ - [Templates (Advanced)](#templates-advanced)
68
+ - [React Integration (Optional)](#react-integration-optional)
68
69
  - [Advanced Features](#advanced-features)
69
70
  - [API Reference](#api-reference)
70
71
  - [TypeScript](#typescript)
@@ -80,6 +81,17 @@ npm install forgeframe
80
81
 
81
82
  ---
82
83
 
84
+ ## Start Here (Most Users)
85
+
86
+ Use this path for typical integrations:
87
+
88
+ 1. Follow [Quick Start](#quick-start) to get a working component.
89
+ 2. Use [Step-by-Step Guide](#step-by-step-guide) to add typed props and callbacks.
90
+ 3. Use [Props System](#props-system) and [Host Window API (hostProps)](#host-window-api-hostprops) as your primary references.
91
+ 4. Treat sections marked **Advanced** as optional unless you specifically need them.
92
+
93
+ ---
94
+
83
95
  ## Quick Start
84
96
 
85
97
  > **`Consumer`**
@@ -281,6 +293,8 @@ await instance.render('#container');
281
293
  | `resize` | Component was resized |
282
294
  | `focus` | Component received focus |
283
295
 
296
+ If all you need is embed + typed props + callbacks, you can stop here and use the API reference as needed.
297
+
284
298
  ---
285
299
 
286
300
  ## Props System
@@ -386,6 +400,28 @@ const MyComponent = ForgeFrame.create({
386
400
  });
387
401
  ```
388
402
 
403
+ ### Passing Props via URL or POST Body (Advanced)
404
+
405
+ Use prop definition flags to include specific values in the host page's initial HTTP request:
406
+
407
+ ```typescript
408
+ const Checkout = ForgeFrame.create({
409
+ tag: 'checkout',
410
+ url: 'https://payments.example.com/checkout',
411
+ props: {
412
+ sessionToken: { schema: prop.string(), queryParam: true }, // ?sessionToken=...
413
+ csrf: { schema: prop.string(), bodyParam: true }, // POST body field "csrf"
414
+ userId: { schema: prop.string(), bodyParam: 'user_id' }, // custom body field name
415
+ },
416
+ });
417
+ ```
418
+
419
+ - `queryParam`: appends to the URL query string for initial load.
420
+ - `bodyParam`: sends values in a hidden form `POST` for initial load (iframe and popup).
421
+ - `bodyParam` only affects the initial navigation; later `updateProps()` uses postMessage.
422
+ - Object values are JSON-stringified. Function and `undefined` values are skipped.
423
+ - Most apps do not need this unless the host server requires initial URL/body parameters.
424
+
389
425
  ### Updating Props
390
426
 
391
427
  Props can be updated after rendering.
@@ -507,7 +543,9 @@ const data = await instance.exports.getFormData();
507
543
 
508
544
  ---
509
545
 
510
- ## Templates
546
+ ## Templates (Advanced)
547
+
548
+ Use this section only when you need custom containers/loading UI beyond the default behavior.
511
549
 
512
550
  ### Container Template
513
551
 
@@ -581,7 +619,7 @@ const MyComponent = ForgeFrame.create({
581
619
 
582
620
  ---
583
621
 
584
- ## React Integration
622
+ ## React Integration (Optional)
585
623
 
586
624
  ### Basic Usage
587
625
 
@@ -652,6 +690,8 @@ const ProfileReact = createComponent(ProfileComponent);
652
690
 
653
691
  ## Advanced Features
654
692
 
693
+ Most integrations can skip this section initially and return only when a specific requirement appears.
694
+
655
695
  ### Popup Windows
656
696
 
657
697
  Render as a popup instead of iframe.
@@ -154,8 +154,4 @@ export type MessageName = (typeof MESSAGE_NAME)[keyof typeof MESSAGE_NAME];
154
154
  * @internal
155
155
  */
156
156
  export declare const WINDOW_NAME_PREFIX = "__forgeframe__";
157
- /**
158
- * Current library version.
159
- * @public
160
- */
161
- export declare const VERSION = "0.0.1";
157
+ export declare const VERSION: string;
@@ -239,6 +239,16 @@ export declare class ConsumerComponent<P extends Record<string, unknown>, X = un
239
239
  * @internal
240
240
  */
241
241
  private buildUrl;
242
+ /**
243
+ * Builds POST body parameters from props marked with bodyParam.
244
+ * @internal
245
+ */
246
+ private buildBodyParams;
247
+ /**
248
+ * Submits a hidden form to navigate a target window via POST.
249
+ * @internal
250
+ */
251
+ private submitBodyForm;
242
252
  /**
243
253
  * Builds the window.name payload for the host window.
244
254
  * @internal