@loomwork/blueprint-runtime 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +83 -2
- package/dist/Blueprint.d.ts +14 -0
- package/dist/Blueprint.d.ts.map +1 -0
- package/dist/Blueprint.js +18 -0
- package/dist/Blueprint.js.map +1 -0
- package/dist/RendererRegistry.d.ts +9 -0
- package/dist/RendererRegistry.d.ts.map +1 -0
- package/dist/RendererRegistry.js +39 -0
- package/dist/RendererRegistry.js.map +1 -0
- package/dist/catalog.d.ts +129 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +435 -0
- package/dist/catalog.js.map +1 -0
- package/dist/coverage.d.ts +18 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +22 -0
- package/dist/coverage.js.map +1 -0
- package/dist/customWidget.d.ts +10 -0
- package/dist/customWidget.d.ts.map +1 -0
- package/dist/customWidget.js +34 -0
- package/dist/customWidget.js.map +1 -0
- package/dist/esm/Blueprint.js +15 -0
- package/dist/esm/Blueprint.js.map +1 -0
- package/dist/esm/RendererRegistry.js +35 -0
- package/dist/esm/RendererRegistry.js.map +1 -0
- package/dist/esm/catalog.js +430 -0
- package/dist/esm/catalog.js.map +1 -0
- package/dist/esm/coverage.js +19 -0
- package/dist/esm/coverage.js.map +1 -0
- package/dist/esm/customWidget.js +31 -0
- package/dist/esm/customWidget.js.map +1 -0
- package/dist/esm/identity.js +116 -0
- package/dist/esm/identity.js.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/irVersion.js +150 -0
- package/dist/esm/irVersion.js.map +1 -0
- package/dist/esm/layout.js +63 -0
- package/dist/esm/layout.js.map +1 -0
- package/dist/esm/normalize.js +115 -0
- package/dist/esm/normalize.js.map +1 -0
- package/dist/esm/pins.js +82 -0
- package/dist/esm/pins.js.map +1 -0
- package/dist/esm/traverseBlueprint.js +38 -0
- package/dist/esm/traverseBlueprint.js.map +1 -0
- package/dist/esm/traverseBlueprintAsync.js +48 -0
- package/dist/esm/traverseBlueprintAsync.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/widgetStatus.js +137 -0
- package/dist/esm/widgetStatus.js.map +1 -0
- package/dist/esm/widgets.js +105 -0
- package/dist/esm/widgets.js.map +1 -0
- package/dist/identity.d.ts +58 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +122 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/irVersion.d.ts +23 -0
- package/dist/irVersion.d.ts.map +1 -0
- package/dist/irVersion.js +153 -0
- package/dist/irVersion.js.map +1 -0
- package/dist/layout.d.ts +57 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +71 -0
- package/dist/layout.js.map +1 -0
- package/dist/normalize.d.ts +29 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +126 -0
- package/dist/normalize.js.map +1 -0
- package/dist/pins.d.ts +27 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +86 -0
- package/dist/pins.js.map +1 -0
- package/dist/traverseBlueprint.d.ts +27 -0
- package/dist/traverseBlueprint.d.ts.map +1 -0
- package/dist/traverseBlueprint.js +40 -0
- package/dist/traverseBlueprint.js.map +1 -0
- package/dist/traverseBlueprintAsync.d.ts +18 -0
- package/dist/traverseBlueprintAsync.d.ts.map +1 -0
- package/dist/traverseBlueprintAsync.js +51 -0
- package/dist/traverseBlueprintAsync.js.map +1 -0
- package/dist/types.d.ts +176 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/widgetStatus.d.ts +66 -0
- package/dist/widgetStatus.d.ts.map +1 -0
- package/dist/widgetStatus.js +141 -0
- package/dist/widgetStatus.js.map +1 -0
- package/dist/widgets.d.ts +101 -0
- package/dist/widgets.d.ts.map +1 -0
- package/dist/widgets.js +115 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +60 -3
- package/src/Blueprint.ts +28 -0
- package/src/RendererRegistry.ts +38 -0
- package/src/catalog.ts +638 -0
- package/src/coverage.ts +52 -0
- package/src/customWidget.ts +42 -0
- package/src/identity.ts +178 -0
- package/src/index.ts +84 -0
- package/src/irVersion.ts +195 -0
- package/src/layout.ts +105 -0
- package/src/normalize.ts +130 -0
- package/src/pins.ts +84 -0
- package/src/traverseBlueprint.bench.ts +47 -0
- package/src/traverseBlueprint.ts +94 -0
- package/src/traverseBlueprintAsync.ts +92 -0
- package/src/types.ts +195 -0
- package/src/widgetStatus.ts +231 -0
- package/src/widgets.ts +213 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @loomwork/blueprint-runtime — the Blueprint rendering IR
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Blueprint is a declarative, JSON-serializable description of a screen: a layout (grid, flex, stack) of
|
|
4
|
+
widgets, each bound to a path in a projection. This package defines that IR and the framework-agnostic
|
|
5
|
+
tools around it: builders, a validator that checks a Blueprint against a catalogue of allowed widgets,
|
|
6
|
+
identity and version-pin checks, and a traversal that every renderer is built on. It draws nothing itself;
|
|
7
|
+
renderers (`@loomwork/plugin-renderer-terminal`, `@loomwork/plugin-renderer-dom`, `@loomwork/plugin-renderer-react`) read the same Blueprint. Use it to compose
|
|
8
|
+
a surface in code, or to check one that a model composed, before rendering or storing it.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import {
|
|
12
|
+
DataTable,
|
|
13
|
+
MetricCard,
|
|
14
|
+
blueprint$,
|
|
15
|
+
builtinCatalog,
|
|
16
|
+
cell,
|
|
17
|
+
grid,
|
|
18
|
+
validateBlueprint,
|
|
19
|
+
} from "@loomwork/blueprint-runtime";
|
|
20
|
+
|
|
21
|
+
const board = blueprint$({
|
|
22
|
+
id: "db-health",
|
|
23
|
+
title: "Database health",
|
|
24
|
+
projections: ["db"],
|
|
25
|
+
layout: grid({
|
|
26
|
+
columns: 3,
|
|
27
|
+
title: "Overview",
|
|
28
|
+
children: [
|
|
29
|
+
// Give a widget an explicit id if a composer will revise it: the default id hashes the props.
|
|
30
|
+
MetricCard({
|
|
31
|
+
id: "connections",
|
|
32
|
+
title: "Connections",
|
|
33
|
+
binding: { projectionId: "db", path: "connections" },
|
|
34
|
+
}),
|
|
35
|
+
cell(2, DataTable({ id: "slow", title: "Slow queries", binding: { projectionId: "db", path: "slow" } })),
|
|
36
|
+
],
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// A blueprint a model composes is data: check it against the catalogue. Never throws.
|
|
41
|
+
const report = validateBlueprint(board, builtinCatalog);
|
|
42
|
+
console.log(report.ok, report.widgets, report.findings); // true 2 []
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Surface
|
|
46
|
+
|
|
47
|
+
- **Build.** `blueprint$({ id, title, layout, projections, projectionVersions? })`; layouts `grid`, `flex`,
|
|
48
|
+
`stack` (with `cell(span, node, placement?)` for grid placement); widgets `MetricCard`, `Timeline`,
|
|
49
|
+
`ApprovalCard`, `StatusBadge`, `ProgressBar`, `DataTable`, `AlertCard`, `StreamingText`, and
|
|
50
|
+
`customWidget$` for your own kind.
|
|
51
|
+
- **Check.** `validateBlueprint(blueprint, catalog)` returns `{ ok, findings, widgets }`;
|
|
52
|
+
`defineWidgetCatalog`, `builtinCatalog`, `catalogCoverage`. `blueprintNodeIds`, `blueprintLayoutIds` and
|
|
53
|
+
`preservesNodes` report which ids a revision dropped. `blueprintPins` and `checkBlueprintPins` compare
|
|
54
|
+
the projection versions a view recorded with the live ones.
|
|
55
|
+
- **Render.** `traverseBlueprint` and `traverseBlueprintAsync`, `RendererRegistry`, `resolveWidgetValue`,
|
|
56
|
+
and `describeWidgetStatus` / `describeWidgetFrame`, the single decision about what a widget shows when its
|
|
57
|
+
binding is pending, stale, empty, errored or redacted.
|
|
58
|
+
- **Versioning.** `BLUEPRINT_IR_VERSION` (currently 2.5.0), `upgradeBlueprint`, `blueprintIrVersion`.
|
|
59
|
+
|
|
60
|
+
## Behaviour that surprises people
|
|
61
|
+
|
|
62
|
+
- **A default widget id is a hash of its props.** It changes when any prop changes, so a revised widget is
|
|
63
|
+
re-identified, remounted, and loses anything keyed on it. Pass `id` for any widget a composer will edit.
|
|
64
|
+
- **The checks report findings and never throw**, so a composer can degrade and record a gap. A report
|
|
65
|
+
with zero `widgets` is not a pass; `widgets` is the denominator.
|
|
66
|
+
- **Grid reading order is guaranteed only for fully placed or fully unplaced grids.** If some cells have
|
|
67
|
+
`row` and `column` and others do not, CSS auto-placement (React) and the terminal's absent-last sort can
|
|
68
|
+
disagree (ADR 0098).
|
|
69
|
+
- **`empty` is not `error`.** A binding that delivered but has nothing to show is its own state (IR 2.3.0,
|
|
70
|
+
ADR 0100), and a binding's `sensitivity` is read by compilers and delivery, never by renderers.
|
|
71
|
+
- **The IR is pinned.** A test pins the shape digest per version; any shape change needs a version bump.
|
|
72
|
+
A Blueprint without `irVersion` reads as 1.0.0, and `upgradeBlueprint` is the identity on 2.0.0 through
|
|
73
|
+
2.5.0.
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
Unpublished for now: inside this repo use `workspace:*`; from a sibling checkout use a `link:` override (see [AGENTS.md](../../AGENTS.md)).
|
|
78
|
+
|
|
79
|
+
## See also
|
|
80
|
+
|
|
81
|
+
- API reference: section "`@loomwork/blueprint-runtime` — declarative UI" in [docs/api-reference.org](../../docs/api-reference.org).
|
|
82
|
+
- Guides: [composed surfaces](../../docs/composed-surfaces.md), [user guide, section 6: projections and agent surfaces](../../docs/user-guide.md#6-projections--agent-surfaces).
|
|
83
|
+
- ADRs: [0088 blueprint conformance](../../docs/adr/0088-blueprint-conformance.md), [0094 node identity](../../docs/adr/0094-blueprint-node-identity.md), [0095 binding-semantics pin](../../docs/adr/0095-binding-semantics-pin.md), [0096 stable rendering IR](../../docs/adr/0096-blueprint-stable-rendering-ir.md), [0098 placement and titles](../../docs/adr/0098-blueprint-ir-placement-and-titles.md), [0100 empty state](../../docs/adr/0100-blueprint-ir-empty-binding-state.md).
|
|
84
|
+
- Source: `packages/blueprint-runtime/src`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Blueprint, Layout } from "./types";
|
|
2
|
+
export interface BlueprintConfig {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
layout: Layout;
|
|
6
|
+
projections: string[];
|
|
7
|
+
/**
|
|
8
|
+
* ADR 0095 — the declared versions of the projections this view binds to, at composition.
|
|
9
|
+
* `projectionRuntime.pins()` is where they come from. See {@link Blueprint.projectionVersions}.
|
|
10
|
+
*/
|
|
11
|
+
projectionVersions?: Readonly<Record<string, string>>;
|
|
12
|
+
}
|
|
13
|
+
export declare function blueprint$(config: BlueprintConfig): Blueprint;
|
|
14
|
+
//# sourceMappingURL=Blueprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Blueprint.d.ts","sourceRoot":"","sources":["../src/Blueprint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACvD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAY7D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blueprint$ = blueprint$;
|
|
4
|
+
const irVersion_1 = require("./irVersion");
|
|
5
|
+
function blueprint$(config) {
|
|
6
|
+
return {
|
|
7
|
+
_tag: "Blueprint",
|
|
8
|
+
irVersion: irVersion_1.BLUEPRINT_IR_VERSION,
|
|
9
|
+
id: config.id,
|
|
10
|
+
title: config.title,
|
|
11
|
+
layout: config.layout,
|
|
12
|
+
projections: config.projections,
|
|
13
|
+
...(config.projectionVersions !== undefined && {
|
|
14
|
+
projectionVersions: config.projectionVersions,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Blueprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Blueprint.js","sourceRoot":"","sources":["../src/Blueprint.ts"],"names":[],"mappings":";;AAeA,gCAYC;AA3BD,2CAAmD;AAenD,SAAgB,UAAU,CAAC,MAAuB;IAChD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,gCAAoB;QAC/B,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,CAAC,MAAM,CAAC,kBAAkB,KAAK,SAAS,IAAI;YAC7C,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;SAC9C,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class RendererRegistry<TRenderer> {
|
|
2
|
+
private readonly renderers;
|
|
3
|
+
register(kind: string, renderer: TRenderer): this;
|
|
4
|
+
get(kind: string): TRenderer | undefined;
|
|
5
|
+
has(kind: string): boolean;
|
|
6
|
+
kinds(): string[];
|
|
7
|
+
merge(other: RendererRegistry<TRenderer>): RendererRegistry<TRenderer>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=RendererRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RendererRegistry.d.ts","sourceRoot":"","sources":["../src/RendererRegistry.ts"],"names":[],"mappings":"AAMA,qBAAa,gBAAgB,CAAC,SAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAE1D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI;IAKjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIxC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,KAAK,IAAI,MAAM,EAAE;IAMjB,KAAK,CAAC,KAAK,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC;CASvE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Generic widget registry — framework-agnostic.
|
|
3
|
+
// TRenderer is narrowed by each framework adapter:
|
|
4
|
+
// React: RendererRegistry<React.FC<WidgetRendererProps>>
|
|
5
|
+
// Angular: RendererRegistry<Type<unknown>>
|
|
6
|
+
// DOM: RendererRegistry<(el: HTMLElement, props: WidgetRendererProps) => void>
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.RendererRegistry = void 0;
|
|
9
|
+
class RendererRegistry {
|
|
10
|
+
renderers = new Map();
|
|
11
|
+
register(kind, renderer) {
|
|
12
|
+
this.renderers.set(kind, renderer);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
get(kind) {
|
|
16
|
+
return this.renderers.get(kind);
|
|
17
|
+
}
|
|
18
|
+
has(kind) {
|
|
19
|
+
return this.renderers.has(kind);
|
|
20
|
+
}
|
|
21
|
+
kinds() {
|
|
22
|
+
return Array.from(this.renderers.keys());
|
|
23
|
+
}
|
|
24
|
+
// Returns a new registry that contains all renderers from both registries.
|
|
25
|
+
// Entries in `other` win on conflicts.
|
|
26
|
+
merge(other) {
|
|
27
|
+
const merged = new RendererRegistry();
|
|
28
|
+
for (const [kind, r] of this.renderers)
|
|
29
|
+
merged.register(kind, r);
|
|
30
|
+
for (const kind of other.kinds()) {
|
|
31
|
+
const r = other.get(kind);
|
|
32
|
+
if (r !== undefined)
|
|
33
|
+
merged.register(kind, r);
|
|
34
|
+
}
|
|
35
|
+
return merged;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.RendererRegistry = RendererRegistry;
|
|
39
|
+
//# sourceMappingURL=RendererRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RendererRegistry.js","sourceRoot":"","sources":["../src/RendererRegistry.ts"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,mDAAmD;AACnD,6DAA6D;AAC7D,6CAA6C;AAC7C,qFAAqF;;;AAErF,MAAa,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE1D,QAAQ,CAAC,IAAY,EAAE,QAAmB;QACxC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,2EAA2E;IAC3E,uCAAuC;IACvC,KAAK,CAAC,KAAkC;QACtC,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAa,CAAC;QACjD,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS;YAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACjE,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YACjC,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,SAAS;gBAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/BD,4CA+BC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { Blueprint } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* One component a composer may name.
|
|
4
|
+
*
|
|
5
|
+
* Both fields are required. An optional allow-list is the failure mode this
|
|
6
|
+
* module exists to prevent: an entry that declined to say which props it accepts
|
|
7
|
+
* would pass the payload check vacuously, and a check that cannot fail reads as
|
|
8
|
+
* coverage while verifying nothing. `props: []` is a perfectly good answer.
|
|
9
|
+
*/
|
|
10
|
+
export interface CatalogEntry {
|
|
11
|
+
readonly kind: string;
|
|
12
|
+
/**
|
|
13
|
+
* Prop keys this component accepts. `binding` is reserved and always allowed —
|
|
14
|
+
* the built-in builders duplicate the declared binding into `props` — so it
|
|
15
|
+
* need not be listed.
|
|
16
|
+
*/
|
|
17
|
+
readonly props: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether this component renders bound data.
|
|
20
|
+
* - `required` — a widget without a `DataBinding` renders nothing, so its
|
|
21
|
+
* absence is an error rather than an empty state;
|
|
22
|
+
* - `optional` — either is legitimate;
|
|
23
|
+
* - `none` — decorative or structural; a binding on it is a composer mistake.
|
|
24
|
+
*/
|
|
25
|
+
readonly binding: "required" | "optional" | "none";
|
|
26
|
+
}
|
|
27
|
+
export interface WidgetCatalog {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly entries: readonly CatalogEntry[];
|
|
30
|
+
}
|
|
31
|
+
/** Identity helper — declare a catalogue with inferred types. */
|
|
32
|
+
export declare function defineWidgetCatalog(catalog: WidgetCatalog): WidgetCatalog;
|
|
33
|
+
export declare const BUILTIN_CATALOG_ID = "loom.builtin.v1";
|
|
34
|
+
/**
|
|
35
|
+
* The eight widgets `@loomwork/blueprint-runtime` ships, as a catalogue.
|
|
36
|
+
*
|
|
37
|
+
* `props` mirrors each builder's props interface minus `title` (hoisted onto
|
|
38
|
+
* `Widget.title`) and minus `binding` (reserved). Every built-in requires a
|
|
39
|
+
* binding — none of them render anything without one.
|
|
40
|
+
*/
|
|
41
|
+
export declare const builtinCatalog: WidgetCatalog;
|
|
42
|
+
export type BlueprintFindingCode =
|
|
43
|
+
/** A `kind` the catalogue does not define. */
|
|
44
|
+
"unknown-kind"
|
|
45
|
+
/** A `binding: "required"` component with no `DataBinding`. */
|
|
46
|
+
| "missing-binding"
|
|
47
|
+
/** A `binding: "none"` component carrying one anyway. */
|
|
48
|
+
| "unexpected-binding"
|
|
49
|
+
/** A prop key outside the catalogue entry's allow-list — the exfiltration check. */
|
|
50
|
+
| "undeclared-prop"
|
|
51
|
+
/** A binding to a projection the blueprint never declares — renders blank, silently. */
|
|
52
|
+
| "undeclared-projection"
|
|
53
|
+
/**
|
|
54
|
+
* Two nodes sharing an id — node identity, and the renderer's key, collide. Widget ids and
|
|
55
|
+
* layout ids (IR 2.4.0) are ONE namespace: widget↔widget, widget↔layout and layout↔layout all
|
|
56
|
+
* collide. Reported on the second occurrence in pre-order.
|
|
57
|
+
*/
|
|
58
|
+
| "duplicate-node-id"
|
|
59
|
+
/** A grid cell's `span` is not an integer in `1..columns`. */
|
|
60
|
+
| "span-out-of-range"
|
|
61
|
+
/**
|
|
62
|
+
* A grid cell's placement (IR 2.1.0) cannot be laid out: `row`, `rowSpan` or `column` is not a
|
|
63
|
+
* positive integer, `column` exceeds `columns`, or `column + span - 1` overflows the grid.
|
|
64
|
+
*/
|
|
65
|
+
| "placement-out-of-range"
|
|
66
|
+
/**
|
|
67
|
+
* A layout's `role` (IR 2.2.0) is present but not a well-formed role (`isLayoutRole`): renderers
|
|
68
|
+
* draw the plain container, so nothing is lost but the custom rendering — a `warn`. An unknown
|
|
69
|
+
* but well-formed role is NOT a finding: whether a renderer has it registered is not loom's to say.
|
|
70
|
+
*/
|
|
71
|
+
| "role-invalid"
|
|
72
|
+
/**
|
|
73
|
+
* A layout's `id` (IR 2.4.0, ADR 0101) is present but not a non-empty string: renderers treat it
|
|
74
|
+
* as absent and key the container positionally, so nothing is lost but state preservation
|
|
75
|
+
* across a recompose — a `warn`.
|
|
76
|
+
*/
|
|
77
|
+
| "layout-id-invalid"
|
|
78
|
+
/** A grid's `columns` is not a positive integer — there is no column count to lay cells into. */
|
|
79
|
+
| "columns-invalid"
|
|
80
|
+
/** A node that is neither a `Widget` nor a `Layout` (a stray `null`, a string, a stranded `GridCell`). */
|
|
81
|
+
| "malformed-node"
|
|
82
|
+
/** `binding.status.path` is empty or not a dotted path. */
|
|
83
|
+
| "status-path-invalid"
|
|
84
|
+
/** `binding.sensitivity` is not a `@loomwork/classify` `DataClass`. */
|
|
85
|
+
| "sensitivity-unknown"
|
|
86
|
+
/** `widget.source` (or a `degradedFrom` entry) is missing `type` or `version`. */
|
|
87
|
+
| "source-invalid"
|
|
88
|
+
/**
|
|
89
|
+
* `source.redacted` (IR 2.5.0, ADR 0097 amendment) is present but not `true`, or is `true` on a
|
|
90
|
+
* widget that still carries a `binding` or a `degradedFrom` chain — both would leave the
|
|
91
|
+
* withheld content (a projection id, a path, the original type) on the artifact.
|
|
92
|
+
*/
|
|
93
|
+
| "redacted-invalid"
|
|
94
|
+
/** `blueprint.irVersion` is set but not a version this module recognizes. */
|
|
95
|
+
| "ir-version-unknown";
|
|
96
|
+
export interface BlueprintFinding {
|
|
97
|
+
readonly code: BlueprintFindingCode;
|
|
98
|
+
readonly severity: "error" | "warn";
|
|
99
|
+
readonly message: string;
|
|
100
|
+
/**
|
|
101
|
+
* The node the finding applies to. For a widget-level finding it is the widget's id. For a
|
|
102
|
+
* cell-level finding (`span-out-of-range`, `placement-out-of-range`) it is the id of the cell's
|
|
103
|
+
* OWN node — a widget's id, or a nested layout's well-formed id (IR 2.4.0) — else `"<layout>"`.
|
|
104
|
+
* For a layout-level finding (`columns-invalid`, `role-invalid`, `duplicate-node-id` on a
|
|
105
|
+
* layout) it is the layout's well-formed id when it has one, else `"<layout>"`. For
|
|
106
|
+
* `ir-version-unknown`, `malformed-node` and `layout-id-invalid` it is always `"<layout>"`.
|
|
107
|
+
*/
|
|
108
|
+
readonly nodeId: string;
|
|
109
|
+
/** The widget's kind, or `"<layout>"` for a layout-level finding. */
|
|
110
|
+
readonly kind: string;
|
|
111
|
+
}
|
|
112
|
+
export interface BlueprintValidation {
|
|
113
|
+
/** True iff there are no `error`-severity findings. */
|
|
114
|
+
readonly ok: boolean;
|
|
115
|
+
readonly findings: readonly BlueprintFinding[];
|
|
116
|
+
/**
|
|
117
|
+
* Widgets visited. The denominator for a first-attempt validation rate — a
|
|
118
|
+
* report with zero widgets is not a pass, and this is how a caller tells the
|
|
119
|
+
* difference.
|
|
120
|
+
*/
|
|
121
|
+
readonly widgets: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check a blueprint against a catalogue. Never throws; returns every finding it
|
|
125
|
+
* can see in one pass, so a caller degrades or records a gap on the whole report
|
|
126
|
+
* rather than on the first failure.
|
|
127
|
+
*/
|
|
128
|
+
export declare function validateBlueprint(blueprint: Blueprint, catalog: WidgetCatalog): BlueprintValidation;
|
|
129
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAA4B,MAAM,SAAS,CAAC;AAiCnE;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;CACpD;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAEzE;AAED,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,aAY5B,CAAC;AAIF,MAAM,MAAM,oBAAoB;AAC9B,8CAA8C;AAC5C,cAAc;AAChB,+DAA+D;GAC7D,iBAAiB;AACnB,yDAAyD;GACvD,oBAAoB;AACtB,oFAAoF;GAClF,iBAAiB;AACnB,wFAAwF;GACtF,uBAAuB;AACzB;;;;GAIG;GACD,mBAAmB;AACrB,8DAA8D;GAC5D,mBAAmB;AACrB;;;GAGG;GACD,wBAAwB;AAC1B;;;;GAIG;GACD,cAAc;AAChB;;;;GAIG;GACD,mBAAmB;AACrB,iGAAiG;GAC/F,iBAAiB;AACnB,0GAA0G;GACxG,gBAAgB;AAClB,2DAA2D;GACzD,qBAAqB;AACvB,uEAAuE;GACrE,qBAAqB;AACvB,kFAAkF;GAChF,gBAAgB;AAClB;;;;GAIG;GACD,kBAAkB;AACpB,6EAA6E;GAC3E,oBAAoB,CAAC;AAEzB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAoKD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,aAAa,GACrB,mBAAmB,CA+RrB"}
|