@peripheries/renderer 0.29.0 → 0.30.0

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
@@ -56,6 +56,15 @@ const runtime = await loadPageData(page, source, { params, baseProps, viewer, co
56
56
  small "hidden (empty)" placeholder instead of nothing.
57
57
  - `showProblemCodes`: a cell's problem notice adds its diagnostic code, for
58
58
  staff and editors; without it a viewer reads only the plain wording.
59
+ - `mockCell(cellId)`: a design preview's stand-in for a cell. It returns
60
+ `{ props?, data? }`: the props are merged over the cell's resolved ones, and
61
+ `data` becomes its whole data bundle, settled (`isLoading: false`, no error).
62
+ `context` and `style` are never the mock's to set. A cell it returns nothing
63
+ for is drawn as the page has it; the page's own reads still run. It is read
64
+ only in a Vite build made with `VITE_PREVIEW=true` (the host's preview
65
+ build): a production build replaces the flag with `false` and drops the
66
+ code, so it adds no bytes to what a phone loads (a build without
67
+ `import.meta.env` ignores it too).
59
68
 
60
69
  A consumer with resolved values instead of a graph (the component repos'
61
70
  harness) builds its runtime with `pageRuntimeFromValues(page, { values,
@@ -12,6 +12,10 @@ export declare function failedLabels(cell: PageCell, data: DataContext): string[
12
12
  export declare function isEmptyPropValue(value: unknown): boolean;
13
13
  export declare function hideWhenEmptyProblem(cell: Pick<PageCell, 'hide_when_empty' | 'props'>, data: DataContext): 'QUERY_UNRESOLVED' | null;
14
14
  export declare function hiddenWhenEmpty(cell: Pick<PageCell, 'hide_when_empty' | 'props'>, props: Record<string, unknown>, data: DataContext): boolean;
15
+ export type CellMock = {
16
+ props?: Record<string, unknown>;
17
+ data?: unknown;
18
+ };
15
19
  export type AssembledInputs = {
16
20
  resolvedProps: Record<string, unknown>;
17
21
  children: unknown;
@@ -34,5 +38,6 @@ export type AssembledInputs = {
34
38
  navigate: (to: string) => void;
35
39
  context: Record<string, unknown>;
36
40
  renderComponent?: (key: string, props?: Record<string, unknown>) => unknown;
41
+ mock?: CellMock;
37
42
  };
38
43
  export declare function assembleCellProps(i: AssembledInputs): Record<string, unknown>;
@@ -16,7 +16,7 @@ export { pageRuntimeFromValues } from './values.js';
16
16
  export { actionBindingKey, actionProblems, actionReferences, declaredActions, normalizeActionDeclaration, projectCellActions, resolveAction, type RunAction } from './actions.js';
17
17
  export type { ActionDeclaration } from '@peripheries/runtime';
18
18
  export type * from './types.js';
19
- export { assembleCellProps, hiddenWhenEmpty, hideWhenEmptyProblem, isEmptyPropValue, projectCellData, type CellStatus } from './cell-props.js';
19
+ export { assembleCellProps, hiddenWhenEmpty, hideWhenEmptyProblem, isEmptyPropValue, projectCellData, type CellMock, type CellStatus } from './cell-props.js';
20
20
  export { cellAttributes, cellPlacementStyle, pageContainerStyle } from './layout.js';
21
21
  export { deriveElementReferences, deriveSectionNumbering, deriveSectionReferences, mergeSectionReferences, nodePrintStyle, normalizeStructure, numberingFor, PAGE_DOCUMENT, referencesFor, SECTION_KINDS, sectionAnchor, structureIssues, tableOfContents, usesStructureLayout, type ContentsEntry, type LayoutNode, type SectionNumbering, type SectionReference, type SectionReferences, } from './structure.js';
22
22
  export { _clearBundleCache, isComponentExport, loadBundle, loadBundles, loadBundlesSettled, projectModule, runtimeReady, type BundleFiles, type BundleRow, type LoadedBundle, type LoadedBundles, } from './bundles/load.js';
@@ -4,6 +4,7 @@ import type { LoadedBundle } from '../core/bundles/load.js';
4
4
  import type { Diagnostic } from '../core/graph.js';
5
5
  import { type CoreRegistry } from '../core/bundles/resolve.js';
6
6
  import { type RunAction } from '../core/actions.js';
7
+ import { type CellMock } from '../core/cell-props.js';
7
8
  import { type HostReads } from '../core/host-reads.js';
8
9
  import type { CellData } from '../core/load-page.js';
9
10
  import { type ResolutionContext } from '../core/references.js';
@@ -44,6 +45,7 @@ export type CellEnvironment = {
44
45
  cellProps?: (cell: PageCell) => Record<string, unknown> | undefined;
45
46
  showHiddenCells?: boolean;
46
47
  showProblemCodes?: boolean;
48
+ mockCell?: (cellId: string) => CellMock | undefined;
47
49
  };
48
50
  export type FrameProps = {
49
51
  attributes?: Record<string, string>;
@@ -1,6 +1,7 @@
1
1
  import type { CellAction, ComponentContract } from '@peripheries/runtime';
2
2
  import type { RunAction } from '../core/actions.js';
3
3
  import type { PageBundles } from '../core/bundles/page-bundles.js';
4
+ import type { CellMock } from '../core/cell-props.js';
4
5
  import type { CoreRegistry } from '../core/bundles/resolve.js';
5
6
  import type { HostReads } from '../core/host-reads.js';
6
7
  import type { Diagnostic } from '../core/graph.js';
@@ -27,6 +28,7 @@ export type RendererEnvironment = {
27
28
  cellProps?: (cell: PageCell) => Record<string, unknown> | undefined;
28
29
  showHiddenCells?: boolean;
29
30
  showProblemCodes?: boolean;
31
+ mockCell?: (cellId: string) => CellMock | undefined;
30
32
  };
31
33
  export type PageRendererProps = {
32
34
  runtime: PageRuntime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peripheries/renderer",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "The one renderer for pages of federated component bundles: a framework-free core, a React renderer, the runtime a page boots with, and golden pages for testing.",
5
5
  "type": "module",
6
6
  "sideEffects": [