@reintent/react/views
Generated React entries for intent roots (0045 §7): for each `.intent.tsx` whose default export is its root, a `.intent.view.ts` beside it that is the explicit form, written out: `export default reintentView(Root, 'Card')`.
React code imports the view; intent modules and Node import the root as it is. Being a real TypeScript file, the view's props are the root's to tsc, esbuild, Vite, Sucrase and an editor alike; no build step rewrites an import.
A root is the default export, and only it: named exports (other intent components, tools) are never made views. An anonymous default takes the file's name. A re-export of a default (export { default } from './card.intent.js') is a root too. export = is refused, and so is a file name with a backslash, which a view could not import.
reintent-views [dir…] write the views of every root under each dir (src by default)
reintent-views --check [dir…] fail when one is missing, stale, or left without its rootNew.
Type Aliases
ViewOf
type ViewOf =
| {
name: string;
root: true;
source: string;
}
| {
reason: "no-default";
root: false;
}
| {
message: string;
reason: "error";
root: false;
};Defined in: packages/react/src/views.ts
What a file holds as its root: the view to write, or why there is none.
Functions
viewOf()
function viewOf(file, text): ViewOf;Defined in: packages/react/src/views.ts
The view of one .intent.tsx, from its text.
Parameters
| Parameter | Type |
|---|---|
file | string |
text | string |
Returns
writeViews()
function writeViews(dirs, opts?): string[];Defined in: packages/react/src/views.ts
Write (or, with check, compare) the views of every root under dirs, and remove a view whose
file is no root any more. What is wrong, by file: empty when every view is as its root gives it.
Parameters
| Parameter | Type |
|---|---|
dirs | readonly string[] |
opts | { check?: boolean; } |
opts.check? | boolean |
Returns
string[]
Last updated on
Edit on GitHub