@bestcheckout/dynamic-component-cli 0.1.1 → 0.1.2
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 +144 -20
- package/package.json +14 -10
- package/skills/checkout-theme-dynamic-development/SKILL.md +14 -0
- package/skills/checkout-theme-dynamic-development/agents/openai.yaml +3 -0
- package/skills/checkout-theme-dynamic-development/references/behaviors.json +1214 -0
- package/skills/checkout-theme-dynamic-development/references/cli-development.md +43 -0
- package/skills/checkout-theme-dynamic-development/references/component-catalog.json +5172 -0
- package/skills/checkout-theme-dynamic-development/references/workflow.md +114 -0
- package/src/core/build.mjs +62 -46
- package/src/core/doctor.mjs +14 -2
- package/src/core/project.mjs +10 -7
- package/src/core/server.mjs +16 -3
- package/src/core/source-bundle.mjs +135 -0
- package/src/protocol/validation.mjs +57 -1
- package/templates/starter/README.md +4 -0
- package/types/index.d.ts +182 -9
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Create and develop custom React components for BestCheckout's Checkout, Upsell,
|
|
|
5
5
|
This README is the public development guide for the CLI and dynamic components. The Editor links here from **Component source → Guide**.
|
|
6
6
|
|
|
7
7
|
- [Requirements](#requirements)
|
|
8
|
+
- [AI skill for local development](#ai-skill-for-local-development)
|
|
8
9
|
- [Quick start and Editor preview](#quick-start)
|
|
9
10
|
- [Global installation](#optional-global-installation)
|
|
10
11
|
- [Archive installation](#install-from-a-supplied-tgz)
|
|
@@ -27,9 +28,21 @@ This README is the public development guide for the CLI and dynamic components.
|
|
|
27
28
|
|
|
28
29
|
- Node.js >=20.10 and npm. The package has been tested on macOS with Node 22.22.1 and 24.14.1; the minimum Node version, Windows and Linux have not yet been verified.
|
|
29
30
|
- Internet access to install public npm dependencies.
|
|
30
|
-
-
|
|
31
|
+
- For integrated page preview, Save and Publish: access to a BestCheckout theme editor with custom components and the corresponding template permissions. Local source editing and builds do not require an active Editor session or MCP connection.
|
|
31
32
|
- Chromium for build validation, including builds requested by Editor Save. Install it as shown below. On macOS, an existing Google Chrome installation can also be detected automatically.
|
|
32
33
|
|
|
34
|
+
## AI skill for local development
|
|
35
|
+
|
|
36
|
+
The package includes `skills/checkout-theme-dynamic-development/`, an optional skill for AI assistants editing local dynamic-component projects. It guides requirement analysis, public Runtime usage, local validation/builds and Editor integration. Neither BestCheckout MCP nor the shop-visual source repository is required. Manual CLI development works without a Skill.
|
|
37
|
+
|
|
38
|
+
Copy the complete directory from the installed `node_modules/@bestcheckout/dynamic-component-cli/skills/checkout-theme-dynamic-development/` into your AI client's supported skill location, or extract a supplied versioned Skill ZIP there. Keep `SKILL.md`, `references/` and `agents/` together. Package installation alone does not register the Skill. The client also needs local file/terminal capabilities to perform development; browser/image capabilities determine which visual checks it can run.
|
|
39
|
+
|
|
40
|
+
The Skill reads the project's installed CLI README, public types and generated component/behavior catalogs. These catalogs ship with the Skill and record the CLI version and public-type hash; prefer the installed project's copies to a separately downloaded Skill's copies. Do not use newer reference material to assume an older project or deployed Host supports a capability. Generated catalogs describe platform behavior and supported settings, not the store's current page configuration.
|
|
41
|
+
|
|
42
|
+
MCP-only users receive the shared development principles and MCP operations from the service and do not need to install this Skill or CLI. If MCP is also connected during local development, it can supply relevant page context without changing the local source, Save or Publish path. Missing Editor/Host access leaves integration unverified; local source implementation and available checks can still proceed.
|
|
43
|
+
|
|
44
|
+
Local edits, builds, Editor previews, saved page changes and publication are separate states. Use the Editor's existing Save/Publish flow; the Skill does not add authentication, remote persistence or publication capabilities to the CLI.
|
|
45
|
+
|
|
33
46
|
## Quick start
|
|
34
47
|
|
|
35
48
|
The public package is available from npm. Run:
|
|
@@ -116,7 +129,7 @@ Restart `npm run dev` after adding a component or changing `dynamic.config.json`
|
|
|
116
129
|
- Page types are exactly `checkout`, `upsell`, `downsell`, `thankYou` (case-sensitive).
|
|
117
130
|
- Component IDs use 1–64 lowercase letters, numbers, underscores or hyphens and must be unique within the project.
|
|
118
131
|
- `dynamic.config.json` registers local entry files. Keep its component ID and page type consistent with each exported `manifest`; mismatches fail validation.
|
|
119
|
-
-
|
|
132
|
+
- All starters are ordinary components without recommendation-rule capabilities. Add `capabilities.offerRecommendation: true` only when the component is intended to own the Upsell/Downsell page's recommendation rules; then configure those rules in the Editor.
|
|
120
133
|
|
|
121
134
|
## Component development
|
|
122
135
|
|
|
@@ -136,7 +149,7 @@ A component exports a default definition containing `manifest`, `schema`, `defau
|
|
|
136
149
|
- `manifest.componentId` is 1–64 lowercase letters, numbers, `_` or `-`. It identifies shared code within a theme.
|
|
137
150
|
- `manifest.name` is the non-empty display name shown in the Editor, up to 128 Unicode characters.
|
|
138
151
|
- `manifest.supportedPageTypes` limits where the component can be selected. Omission means all four pages; an empty array means none. It does not grant runtime capabilities.
|
|
139
|
-
- `manifest.capabilities.offerRecommendation`
|
|
152
|
+
- `manifest.capabilities.offerRecommendation` is opt-in: set it to `true` only for an Upsell/Downsell component that owns the page's product recommendation rule. Ordinary content or interaction components omit it. Being placed on an offer page or reading `runtime.offer` recommendations does not require this declaration. The Editor uses the first rule provider in template order, including hidden sections.
|
|
140
153
|
- `schema` is an array of Editor fields. Use `[]` when there are no settings.
|
|
141
154
|
- `defaultSettings` supplies values for new instances. It does not overwrite values already configured by a merchant.
|
|
142
155
|
- `Component` receives `{ settings, runtime, context }`.
|
|
@@ -146,6 +159,16 @@ A component exports a default definition containing `manifest`, `schema`, `defau
|
|
|
146
159
|
|
|
147
160
|
### Editor schema and settings
|
|
148
161
|
|
|
162
|
+
Before writing code, inspect the current page and built-in settings. Prefer existing components, then configuration/layout changes, and use dynamic code for remaining requirements or an explicit custom-code choice. Clarify missing appearance, interaction or flow choices only when they affect the result; infer ordinary business behavior from the current contract instead of asking the merchant to enumerate it. “New” and “fully replace” describe outcomes, not a required replacement mechanism.
|
|
163
|
+
|
|
164
|
+
Every Section, including a built-in/core Section, supports deletion and hiding. Replacing an instance means removing the old instance once its replacement covers the requested behavior and configuration. Hiding retains the instance and is for an explicit hide/keep request, not the default substitute for replacement. Editing an existing instance in place needs no second instance. Keep page/global ownership and supported placement rules separate from deletion permission.
|
|
165
|
+
|
|
166
|
+
Check page tasks, business functions and component responsibilities together. A custom component can combine functions from several behavior profiles; dependencies may remain elsewhere on the page. For example, contact/address/shipping needs their applicable individual behaviors plus address-to-rates-to-totals/submission checks. Preserve the page's necessary flow, authoritative Host state, editable configuration and single transaction ownership. Component visibility or build success alone does not establish completeness.
|
|
167
|
+
|
|
168
|
+
The generated behavior catalog covers all registered Checkout-family components. Read every relevant profile when functions are combined, and use the existing Checkout example, page starters and Runtime examples as references. Custom controls need documented public Runtime capabilities and their own behavior checks. Reuse existing business APIs and configuration/resource save and publish operations. Build, structural validation, preview or publication success does not establish complete behavioral equivalence; report unverified behavior explicitly.
|
|
169
|
+
|
|
170
|
+
Before implementing, check the smallest proposed change against the user's intended difference, applicable behaviors and public capability limits below. Missing behavior guides in an older contract do not imply that there are no behaviors to preserve.
|
|
171
|
+
|
|
149
172
|
Schema fields use the same field types as the Editor configuration panel:
|
|
150
173
|
|
|
151
174
|
```ts
|
|
@@ -260,6 +283,8 @@ The types shipped with your installed CLI are the reference for full parameter a
|
|
|
260
283
|
|
|
261
284
|
Common actions return `{ ok: true }` or `{ ok: false, code, message? }`, with `code` of `unavailable / invalid_destination / blocked / failed`. Cart data is not order data; checkout add-ons use `checkout.upsell`. The platform may omit a capability because of page type or shop configuration. Do not create a private fallback client. There is no public `runtime.currency`; read currency from the page snapshot that owns the amount.
|
|
262
285
|
|
|
286
|
+
`runtime.account?.login` invokes the existing platform login flow when the actual page Host supplies it. It does not accept credentials or expose OTP verification, registration or session-management operations for a custom authentication form. An `ok` result only describes the action call; wait for the account snapshot to become `signed_in` before presenting an authenticated state. Handle cancellation, failure and missing capabilities without changing account state locally. Preview login is simulated and does not prove that a Live page has a working login integration.
|
|
287
|
+
|
|
263
288
|
#### Checkout runtime
|
|
264
289
|
|
|
265
290
|
`runtime.checkout.getSnapshot()` includes `contact`, read-only `lines`, optional `summary`, `currency`, `delivery`, `billing`, `shipping`, `coupon`, `payment` and `status`. `status.dataStatus` is `loading / ready / error / unknown`; `canSubmit` allows an attempt, while `blockedReasons` explains why it is blocked. The Host still revalidates on submission. Available actions:
|
|
@@ -314,40 +339,65 @@ Payment method IDs come from `snapshot.payment.methods`. Render only the methods
|
|
|
314
339
|
| PayPal | `payment.mountAction` for the native authorization button; do not use `checkout.submit()` |
|
|
315
340
|
| Express | `checkout.express.mount` for the native express controls |
|
|
316
341
|
|
|
317
|
-
Check the result of `payment.selectMethod(method)` before mounting. Secure-element handles also expose `validate()`.
|
|
342
|
+
Check the result of `payment.selectMethod(method)` before mounting. Secure-element handles also expose `validate()`. Mount only a supported method using the integration in the table above; do not guess secure/action support from a regular expression over the method label. Keep mount containers stable across input, address and quote updates. Components must not read or persist card numbers, CVV or payment tokens.
|
|
343
|
+
|
|
344
|
+
##### Payment mount lifecycle
|
|
345
|
+
|
|
346
|
+
Runtime capability objects and their methods may receive new references on ordinary Host updates. A new `checkout` reference is not a new checkout session. Do not make payment mount effects depend on `runtime`, `checkout`, `snapshot`, inline option objects or mount-function references: mounting/releasing can itself notify the Host, creating an update → cleanup → remount loop. Subscription effects may depend on the current API object; payment resource ownership must use a separate lifecycle.
|
|
347
|
+
|
|
348
|
+
The wrapper below updates a ref after commit and mounts by component instance, checkout presence, mount kind and payment method. The current Renderer remounts the enclosing dynamic component when its template/Section identity or Host session changes. Keep this wrapper inside that component; do not hoist it into a persistent global root. A custom Host must provide a session key that changes with the business session and remount the component on session replacement. `runtime.page` is not an order/session identifier; do not invent one from an email, amount or snapshot. Runtime refs are not a substitute for Host session isolation.
|
|
349
|
+
|
|
350
|
+
Use this wrapper as `src/NativePaymentControl.tsx`. `kind="secure"` mounts a secure form, `kind="action"` mounts a native authorization button, and `kind="express"` mounts native express controls (omit `method` for Express). Render one owner for each payment surface; do not mount a duplicate alongside an enabled built-in Payment/Express section.
|
|
318
351
|
|
|
319
352
|
```tsx
|
|
320
|
-
import { useEffect, useRef, useState } from "react";
|
|
353
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
321
354
|
import type { DynamicCheckoutRuntime } from "@bestcheckout/dynamic-component-cli/types";
|
|
322
355
|
|
|
323
|
-
export function
|
|
356
|
+
export function NativePaymentControl({ checkout, kind, method = "" }: {
|
|
324
357
|
checkout?: DynamicCheckoutRuntime;
|
|
325
|
-
|
|
358
|
+
kind: "secure" | "action" | "express";
|
|
359
|
+
method?: string;
|
|
326
360
|
}) {
|
|
327
361
|
const container = useRef<HTMLDivElement>(null);
|
|
362
|
+
const latestCheckout = useRef(checkout);
|
|
328
363
|
const [error, setError] = useState("");
|
|
364
|
+
const hasCheckout = Boolean(checkout);
|
|
365
|
+
|
|
366
|
+
// Keep the API current without making its reference a mount identity.
|
|
367
|
+
useLayoutEffect(() => {
|
|
368
|
+
latestCheckout.current = checkout;
|
|
369
|
+
}, [checkout]);
|
|
329
370
|
|
|
330
371
|
useEffect(() => {
|
|
372
|
+
const api = latestCheckout.current;
|
|
331
373
|
const element = container.current;
|
|
332
|
-
if (!
|
|
333
|
-
setError("Payment
|
|
374
|
+
if (!hasCheckout || !api || !element || (kind !== "express" && !method)) {
|
|
375
|
+
setError("Payment controls are unavailable. Please refresh the page.");
|
|
334
376
|
return;
|
|
335
377
|
}
|
|
336
378
|
let cancelled = false;
|
|
337
379
|
let unmount: (() => void) | undefined;
|
|
338
380
|
setError("");
|
|
339
|
-
|
|
340
|
-
|
|
381
|
+
const mount = async () => {
|
|
382
|
+
try {
|
|
383
|
+
const handle = await (kind === "express"
|
|
384
|
+
? api.express.mount({ element })
|
|
385
|
+
: kind === "action"
|
|
386
|
+
? api.payment.mountAction({ element, method })
|
|
387
|
+
: api.payment.mountSecureElement({ element, method }));
|
|
341
388
|
if (cancelled) handle.unmount();
|
|
342
389
|
else unmount = () => handle.unmount();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
390
|
+
} catch {
|
|
391
|
+
if (!cancelled) setError("Payment controls failed to load. Please refresh the page.");
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
// Run after React commits; cleanup of the previous owner is queued first.
|
|
395
|
+
queueMicrotask(() => { if (!cancelled) void mount(); });
|
|
346
396
|
return () => {
|
|
347
397
|
cancelled = true;
|
|
348
|
-
unmount?.();
|
|
398
|
+
queueMicrotask(() => unmount?.());
|
|
349
399
|
};
|
|
350
|
-
}, [
|
|
400
|
+
}, [hasCheckout, kind, method]);
|
|
351
401
|
|
|
352
402
|
return (
|
|
353
403
|
<div>
|
|
@@ -358,7 +408,45 @@ export function SecurePaymentForm({ checkout, method }: {
|
|
|
358
408
|
}
|
|
359
409
|
```
|
|
360
410
|
|
|
361
|
-
This
|
|
411
|
+
This manages control ownership only; mounting does not submit or prove successful payment. Host updates refresh an existing mounted control through the runtime adapter. If a mount resolves after cleanup, its handle is immediately released. Failure remains an unavailable state across ordinary snapshot updates; do not automatically retry on errors or new Runtime references.
|
|
412
|
+
|
|
413
|
+
The recovery policy in this example is a visible instruction to refresh the page manually, with no automatic retry or reload. After a mounted control becomes unavailable or throws during rendering, the Adapter removes the provider subtree, releases its Host reservation once and keeps a refresh message inside its owned container until disposal. Ordinary Host updates do not recover that failed mount; a page refresh creates a new instance. `hasCheckout` only detects that the checkout API exists, not that the payment SDK is ready. Errors handled internally by a payment SDK, including asynchronous network failures, remain the responsibility of that SDK/Host UI; a React error boundary does not catch every asynchronous error.
|
|
414
|
+
|
|
415
|
+
Mount calls and cleanup are queued after the React commit so nested payment roots are not synchronously unmounted while React is rendering; cancelled setups are skipped. React StrictMode may run setup/cleanup again in development; cleanup must tolerate it. Do not keep the first Runtime forever in a ref, remove all effect dependencies, or suppress dependency lint rules as a workaround.
|
|
416
|
+
|
|
417
|
+
##### Patterns to avoid in dynamic components
|
|
418
|
+
|
|
419
|
+
| Risky pattern | Failure mode | Supported approach |
|
|
420
|
+
| --- | --- | --- |
|
|
421
|
+
| Payment mount effect depends on an API/snapshot object; random, timestamp or serialized-snapshot React keys | Repeated SDK initialization, requests and lost input | Use the lifecycle wrapper above; stable component types, keys and container nodes within a session |
|
|
422
|
+
| `innerHTML`, `replaceChildren`, manual removal, or another `createRoot` inside a payment container | React/SDK DOM ownership conflicts and `removeChild` errors | Leave the empty ref container to the mount handle; release with `unmount()` |
|
|
423
|
+
| Calling setters, coupon actions, repricing or payment actions during render or in every subscription callback | Update/request feedback loops and duplicate writes | Render reads only; invoke writes from user intent or narrowly keyed, guarded effects |
|
|
424
|
+
| `getSnapshot: () => ({ ...checkout.getSnapshot() })`, allocating arrays with `map/filter`, or a new fallback object on every read | Unstable external-store snapshots and repeated renders | Return the existing snapshot; derive display values after reading it; always unsubscribe |
|
|
425
|
+
| Defining a component function inside another render, or keying the whole form by field values | React sees a new component identity; focus and payment state reset | Define components at module scope and use stable resource/instance keys |
|
|
426
|
+
| Applying an async result after its selection/session changed | Stale products, address options or quotes overwrite current state | Track request identity or cancellation; ignore stale completions and release late mount handles |
|
|
427
|
+
| Only using `setBusy(true)` to prevent same-tick duplicate actions; unbounded retry/polling | Duplicate submissions or request storms | Use an immediate ref lock plus visible busy state, unlock in `finally`; use bounded/manual recovery and existing payment status reads |
|
|
428
|
+
| Guessing payment capabilities by label, swallowing mount errors, or treating fulfilled Promises as payment success | Wrong control, silent failure or false success | Follow supported method integration and result contracts; show errors; keep unknown/processing explicit |
|
|
429
|
+
| Calling Hooks conditionally after an early return or inside a list/callback | Hook order changes when data or capabilities appear | Call Hooks unconditionally at component top level; put availability checks inside callbacks/effects or split a module-scope child component |
|
|
430
|
+
| Mutating settings/snapshots or computing authoritative totals, defaulting missing amount/currency to zero/USD | Corrupt shared data or show false prices/readiness | Keep snapshots/settings read-only; use local UI state and server amounts; render missing/unknown explicitly |
|
|
431
|
+
| Global DOM queries, duplicate hard-coded input IDs, global listeners/timers without cleanup | One instance changes another, leaked callbacks and duplicate actions | Use instance refs/IDs and scoped styles; remove listeners, clear timers, unsubscribe and release handles on cleanup |
|
|
432
|
+
| Automatically submitting/accepting/retrying a charge when data becomes ready or a request times out | Unintended or duplicate transactions | Require user intent; keep unknown/processing states; reconcile the existing attempt instead of creating another payment |
|
|
433
|
+
| Reading browser globals at module evaluation, storing business state in module globals/local storage, or private API/SDK fallbacks | Build failure, stale/cross-session data and bypassed Host controls | Browser work in cleaned-up effects; state per instance; use documented optional Runtime capabilities |
|
|
434
|
+
|
|
435
|
+
For asynchronous writes, acquire a ref lock before the first `await`; a disabled button/state update alone is not a synchronous lock. Release the lock in `finally` and discard stale UI results using the request/selection identity. A local lock does not replace the Host/server transaction guard or idempotency, and a timeout is not evidence that a payment failed. Avoid reporting a second global toast for errors the Host already displays; show a local unavailable/recovery state when needed.
|
|
436
|
+
|
|
437
|
+
For payment examples, validate ordinary Host reference changes, input/quote updates, method/kind switches, session remount, capability withdrawal, delayed resolution after cleanup, failed mounts and StrictMode. Assert both stable DOM/input and bounded mount/request counts. A successful build or Editor preview alone does not verify these properties or a real payment.
|
|
438
|
+
|
|
439
|
+
#### Current capability limits
|
|
440
|
+
|
|
441
|
+
Behavior profiles describe the built-in component's responsibilities, not a promise that each one can be reimplemented through the public Runtime. For every requested business function, check the current contract and actual Host for required authoritative data, operations/parameters, observable result/error/pending states, applicable page/configuration/access conditions, and ownership/persistence/dependencies. Check only affected functions; providers elsewhere on the page may fulfill dependencies.
|
|
442
|
+
|
|
443
|
+
Apply this to all domains, not just login or payment. Product selection is not catalog/inventory editing; applying a coupon is not creating promotion rules; selecting a shipping rate is not creating a shipping service; order/tracking reads are not refunds or cancellations. New points, subscription, notification, upload or other integration behavior needs its own supported capabilities. These are distinctions to verify, not a permanent denylist. Pure presentation and local UI state do not require a business API, but cannot substitute for a saved business result.
|
|
444
|
+
|
|
445
|
+
When an operation is confirmed unsupported, decline that part before creating dependent code: explain the unmet business result, the actual limitation, and a verified alternative if one exists. Preserve supported independent work and existing providers; do not claim full completion, silently deliver a mock, invent an enablement setting or bypass the boundary with private APIs. Distinguish missing support from unknown availability and temporary failure. A separate platform change requires its own scope; it is not implied by merchant customization.
|
|
446
|
+
|
|
447
|
+
- The public Checkout API has no input/mount entry for the platform's additional payment/order information. Some destinations require these fields during payment preparation. Keep the built-in Payment path when these fields apply or their applicability is unknown; a custom payment form cannot claim full coverage. An enabled built-in Payment also owns the native payment surface, so adding a second custom mount is not a supported workaround.
|
|
448
|
+
- Shipping insurance and VIP selections use their original Section identity and dedicated Host billing behavior. `checkout.upsell.setSelection` handles products under the dynamic instance's identity; it cannot substitute for those paid selections or adopt an existing section's selections. Retain the existing providers and configuration for those functions.
|
|
449
|
+
- Required data or actions that are absent from the public API remain unsupported, not inapplicable. Explain the specific unmet requirement and use a supported configuration/layout. Do not invent a private API, charge locally, or expand platform infrastructure as part of a merchant customization.
|
|
362
450
|
|
|
363
451
|
#### Upsell and Downsell runtime
|
|
364
452
|
|
|
@@ -385,7 +473,9 @@ Reprice returns `unitPrice / amount / currency` and the matching selection. Paym
|
|
|
385
473
|
|
|
386
474
|
Use the latest matching quote and server-returned amount. Do not call `accept` again while a transaction is processing or unknown; query the existing payment status instead. Disable repeated actions while repricing, accepting or reconciling.
|
|
387
475
|
|
|
388
|
-
Offer pages require a recommendation rule
|
|
476
|
+
Offer pages require a recommendation rule for the offer flow, but each component does not need to own one. All CLI starters omit `manifest.capabilities.offerRecommendation`. Ordinary components, including consumers of existing recommendations through `runtime.offer`, leave it omitted. Declare it as `true` only when intentionally providing the page's rules; the Editor then supplies the Product recommendation section. Do not duplicate the platform recommendation fields in your custom schema.
|
|
477
|
+
|
|
478
|
+
When replacing the current rule provider, copy its existing recommendation settings into the replacement instance's `props`, unless the user requested a rule change, and remove the old instance after the replacement is ready. The first provider in template order applies to the page, including hidden sections: hiding the old Offer can leave its rules active and is not a completed replacement. Read back the final page and verify which provider owns the rules. An ordinary component can replace other presentation content without becoming a rule provider. If removing the last provider leaves a required flow unconfigured, explain that specific missing configuration and arrange its intended replacement; do not prohibit deletion because the component is built-in.
|
|
389
479
|
|
|
390
480
|
#### Thank You runtime
|
|
391
481
|
|
|
@@ -395,7 +485,7 @@ Offer pages require a recommendation rule. The CLI's Upsell and Downsell starter
|
|
|
395
485
|
- `refresh?({ target?: "main" | "addOn" | "all" })` refreshes order data without modifying the order.
|
|
396
486
|
- `continueShopping?()` and `viewOrder?()` navigate through host-provided destinations.
|
|
397
487
|
|
|
398
|
-
The snapshot may include order number, status, customer, address, payment summary, lines, totals and
|
|
488
|
+
The snapshot may include order number, status, customer, address, payment summary, lines, totals, currency and `additionalInformation` (read-only `{ title, value }` entries). Display supplied additional information with non-empty titles and values alongside order details; do not invent missing values or expose checkout editing controls. Missing data should be omitted or shown as unavailable until loaded. `getSnapshot()` can be `undefined`. `reads.main` and `reads.addOn` independently describe read state:
|
|
399
489
|
|
|
400
490
|
| Field | Meaning |
|
|
401
491
|
| --- | --- |
|
|
@@ -449,12 +539,16 @@ For settings-only changes such as a title or color, use Save/Publish without upl
|
|
|
449
539
|
|
|
450
540
|
### Validation checklist
|
|
451
541
|
|
|
542
|
+
Scale checks to the change. Existing text/color/configuration edits need result and readback checks. For custom code, review the stable final source against the requested behavior and public Runtime, and inspect desktop/mobile rendering. Changed transaction or cross-function behavior warrants a focused independent adversarial review when available; otherwise explicitly self-review and report that limitation. Compare visual work to the reference or agreed theme, including usable controls and relevant error/loading states. Run code review alongside browser checks when practical and repeat only affected checks after fixes; do not add approval stages or fixed review rounds. Unavailable browser/business checks remain unverified.
|
|
543
|
+
|
|
452
544
|
Before publishing, verify:
|
|
453
545
|
|
|
454
546
|
- `npm run build` passes and the artifact is the current source.
|
|
455
547
|
- Manifest page support, schema and defaults match the target template.
|
|
456
548
|
- Preview works on desktop and mobile; HMR does not lose settings or create duplicate subscriptions.
|
|
457
549
|
- Loading, empty, unavailable, validation, network error and duplicate-action states are handled.
|
|
550
|
+
- Review the Runtime guide’s “Patterns to avoid in dynamic components”; test two instances, late/failed responses, session replacement and unmount cleanup.
|
|
551
|
+
- Payment mount/request counts settle after initialization and do not grow on ordinary API/snapshot updates; SDK containers and input values remain stable.
|
|
458
552
|
- Runtime actions check `ok`/status and never assume a Promise means payment success.
|
|
459
553
|
- Save and reopen preserve the component identity and settings.
|
|
460
554
|
- Publish succeeds, the local server can stop, and a refreshed storefront renders the published artifact.
|
|
@@ -511,7 +605,7 @@ npx dynamic-component doctor --project /absolute/path/to/my-components
|
|
|
511
605
|
| Runtime capability missing | Check page/shop configuration, handle `undefined` or `unavailable` and do not call absent methods |
|
|
512
606
|
| Component load or render failure | Check exports, schema, imports and browser console; fix and trigger HMR or rebuild/upload. Platform error UI does not handle your action errors |
|
|
513
607
|
|
|
514
|
-
Builds support up to 500 source files, 1000 source-tree entries, 16 MiB of source and a 1 MiB artifact. Editor-requested builds run one at a time and time out after 45 seconds. Components run in the browser during preview/validation; this is not a sandbox for untrusted code. No platform credentials are stored by the CLI.
|
|
608
|
+
Builds support up to 500 source files, 1000 source-tree entries, 16 MiB of source and a 1 MiB artifact. Local Save builds also return a deterministic draft-only source ZIP (up to 16 MiB) containing the selected component entry, local dependencies and declarations. The ZIP is created from the same source snapshot as the JavaScript artifact; ordinary `dist` output remains a single JavaScript file. Editor-requested builds run one at a time and time out after 45 seconds. Components run in the browser during preview/validation; this is not a sandbox for untrusted code. No platform credentials are stored by the CLI.
|
|
515
609
|
|
|
516
610
|
Windows/Linux, Safari/Firefox and production HTTPS Editor access remain outside the completed compatibility checks. `doctor` cannot change browser permissions. HTTPS Editor access to local HTTP services may also depend on browser local-network permissions.
|
|
517
611
|
|
|
@@ -535,3 +629,33 @@ Source lives in `shop-visual/packages/dynamic-component-cli`. Types and validati
|
|
|
535
629
|
## License
|
|
536
630
|
|
|
537
631
|
MIT. See [LICENSE](./LICENSE). This license applies to this CLI package; it does not change the licenses of other platform packages or third-party dependencies.
|
|
632
|
+
|
|
633
|
+
## Draft source archives
|
|
634
|
+
|
|
635
|
+
When saving from a Local URL, the Editor uploads the compiled JavaScript and the
|
|
636
|
+
source ZIP together. Source-only changes (including types and declarations) make
|
|
637
|
+
the component pending again. A missing source ZIP requires upgrading the local
|
|
638
|
+
CLI; Local Save does not silently fall back to JavaScript-only upload.
|
|
639
|
+
|
|
640
|
+
The archive contains `dynamic.config.json` with one registration and
|
|
641
|
+
`sourceBuild.cliVersion`, the entry and its local dependencies under `src/`.
|
|
642
|
+
Source bytes and relative paths are preserved. Ambient `src/**/*.d.ts` files are
|
|
643
|
+
included because the standard Starter includes them globally. The archive omits
|
|
644
|
+
package manifests, lockfiles, credentials and installed dependencies. Restore it
|
|
645
|
+
into a clean Starter using the recorded CLI version; validate archive paths,
|
|
646
|
+
entry count and expanded size before extracting, then run `npm run validate` and
|
|
647
|
+
`npm run build`. Normal Save does not download or rebuild the archive.
|
|
648
|
+
|
|
649
|
+
The exported `buildArtifact` / `buildSingleDynamicArtifact` helpers return an
|
|
650
|
+
additional `sourceBundle` (`fileName`, `format: "zip"`, `base64`, `sha256`, `size`).
|
|
651
|
+
MCP callers can reuse this contract; the CLI does not manage platform credentials
|
|
652
|
+
or make backend save requests. The archive is a draft development asset; Publish
|
|
653
|
+
continues to use JavaScript and manifest only. Direct JavaScript upload remains
|
|
654
|
+
supported without source.
|
|
655
|
+
|
|
656
|
+
MCP source persistence uses the same ZIP directory layout. MCP-built archives
|
|
657
|
+
record `sourceBuild.toolVersion`; CLI-built archives record `sourceBuild.cliVersion`.
|
|
658
|
+
The StationSign transport carries ZIP bytes as `source_file_base64` with
|
|
659
|
+
`source_sha256`, `source_file_size`, and `source_format: "zip"`; Admin uses multipart
|
|
660
|
+
`source_file`. Both store source metadata only on the draft. A saved source archive
|
|
661
|
+
must be verified against the authoritative resource response.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bestcheckout/dynamic-component-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "CLI and starter project generator for BestCheckout dynamic components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,17 +11,10 @@
|
|
|
11
11
|
"src",
|
|
12
12
|
"types",
|
|
13
13
|
"templates",
|
|
14
|
+
"skills",
|
|
14
15
|
"README.md",
|
|
15
16
|
"LICENSE"
|
|
16
17
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "node --test tests/*.test.mjs",
|
|
19
|
-
"pack:check": "npm pack --dry-run",
|
|
20
|
-
"test:integration": "node tests/standalone.integration.mjs",
|
|
21
|
-
"test:editor": "node scripts/test-editor.mjs",
|
|
22
|
-
"sync:protocol": "node scripts/sync-protocol.mjs",
|
|
23
|
-
"check:protocol": "node scripts/sync-protocol.mjs --check"
|
|
24
|
-
},
|
|
25
18
|
"engines": {
|
|
26
19
|
"node": ">=20.10.0"
|
|
27
20
|
},
|
|
@@ -37,6 +30,7 @@
|
|
|
37
30
|
"dependencies": {
|
|
38
31
|
"acorn": "8.15.0",
|
|
39
32
|
"esbuild": "0.21.5",
|
|
33
|
+
"fflate": "0.8.2",
|
|
40
34
|
"playwright": "1.56.1",
|
|
41
35
|
"react": "18.3.1",
|
|
42
36
|
"react-dom": "18.3.1",
|
|
@@ -49,5 +43,15 @@
|
|
|
49
43
|
},
|
|
50
44
|
"devDependencies": {
|
|
51
45
|
"dts-bundle-generator": "9.5.1"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "node --test tests/*.test.mjs",
|
|
49
|
+
"pack:check": "npm pack --dry-run",
|
|
50
|
+
"test:integration": "node tests/standalone.integration.mjs",
|
|
51
|
+
"test:editor": "node scripts/test-editor.mjs",
|
|
52
|
+
"test:payment-example": "node tests/payment-example.integration.mjs",
|
|
53
|
+
"test:payment-host": "node tests/payment-host.integration.mjs",
|
|
54
|
+
"sync:protocol": "node scripts/sync-protocol.mjs",
|
|
55
|
+
"check:protocol": "node scripts/sync-protocol.mjs --check"
|
|
52
56
|
}
|
|
53
|
-
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: checkout-theme-dynamic-development
|
|
3
|
+
description: "Develop or edit local BestCheckout dynamic React components with the dynamic-component CLI for Checkout, Upsell, Downsell and Thank You. Use for local source implementation, validation and Editor preview while preserving business-function completeness. Not needed for MCP-only page customization or platform repository maintenance."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Local Checkout component development
|
|
7
|
+
|
|
8
|
+
Help a developer work in a local dynamic-component project. BestCheckout MCP and the shop-visual source repository are not prerequisites. The CLI provides the development server, validation and builds; Editor integration provides page preview, Save and Publish.
|
|
9
|
+
|
|
10
|
+
Read the [shared development principles](references/workflow.md) and [local development steps](references/cli-development.md). Use the installed project's CLI version and public documentation for implementation. Read relevant profiles from the generated [behavior catalog](references/behaviors.json) and [component catalog](references/component-catalog.json) as directed by the local steps, checking version compatibility. Do not load every profile for a small change.
|
|
11
|
+
|
|
12
|
+
If MCP is also connected, it may supply relevant page context within the user's scope. Its presence does not change the local source or save path: do not submit the same work through MCP resource writes, accept changes or publish as a side effect of local development. A requested switch of development path requires reconciling the latest source, component identity and saved state before continuing. For MCP-only customization, use its own execution guide; this Skill need not be installed or invoked.
|
|
13
|
+
|
|
14
|
+
Missing page configuration, Editor access or a real Host leaves the corresponding checks unverified. Continue local implementation and checks that do not depend on those facts; ask only for decisions that materially change the result. Do not claim page-wide completeness or invent a business result from a sample preview.
|