@jigs.design/host 0.3.5 → 0.3.7
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/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/jigs.d.ts +21 -0
- package/dist/jigs.js +30 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DesignGuidance, GuidanceInput, SituationDefinition, situation } from "./guidance.js";
|
|
2
2
|
import { Catalog, CatalogProps, ComponentDefinition, ComponentDesign, ComponentNamed, PropDefinition, PropDefinitions, PropsOf, block, boolean, componentSchema, defineCatalog, defineComponent, handler, image, inline, link, list, none, number, oneOf, string } from "./catalog.js";
|
|
3
3
|
import { ActionDefinition, CallPolicy, DataDefinition, InputOf, InvalidationScope, InvalidationScopes, MutationDefinition, OutputOf, ProcedureDefinition, Procedures, Projection, QueryDefinition, action, data, dataSchema, isCallPolicy, mutation, query } from "./procedures.js";
|
|
4
|
-
import { DefineName, JigDefinition, PageName, jig } from "./jigs.js";
|
|
4
|
+
import { DefineName, DefineScan, JigDefinition, PageName, jig, scanDefine } from "./jigs.js";
|
|
5
5
|
import { ActionEvent, Host, PagePolicy, PolicyDirectives, contentSecurityPolicy, defineHost } from "./host.js";
|
|
6
|
-
export { type ActionDefinition, type ActionEvent, type CallPolicy, type Catalog, type CatalogProps, type ComponentDefinition, type ComponentDesign, type ComponentNamed, type DataDefinition, type DefineName, type DesignGuidance, type GuidanceInput, type Host, type InputOf, type InvalidationScope, type InvalidationScopes, type JigDefinition, type MutationDefinition, type OutputOf, type PageName, type PagePolicy, type PolicyDirectives, type ProcedureDefinition, type Procedures, type Projection, type PropDefinition, type PropDefinitions, type PropsOf, type QueryDefinition, type SituationDefinition, action, block, boolean, componentSchema, contentSecurityPolicy, data, dataSchema, defineCatalog, defineComponent, defineHost, handler, image, inline, isCallPolicy, jig, link, list, mutation, none, number, oneOf, query, situation, string };
|
|
6
|
+
export { type ActionDefinition, type ActionEvent, type CallPolicy, type Catalog, type CatalogProps, type ComponentDefinition, type ComponentDesign, type ComponentNamed, type DataDefinition, type DefineName, type DefineScan, type DesignGuidance, type GuidanceInput, type Host, type InputOf, type InvalidationScope, type InvalidationScopes, type JigDefinition, type MutationDefinition, type OutputOf, type PageName, type PagePolicy, type PolicyDirectives, type ProcedureDefinition, type Procedures, type Projection, type PropDefinition, type PropDefinitions, type PropsOf, type QueryDefinition, type SituationDefinition, action, block, boolean, componentSchema, contentSecurityPolicy, data, dataSchema, defineCatalog, defineComponent, defineHost, handler, image, inline, isCallPolicy, jig, link, list, mutation, none, number, oneOf, query, scanDefine, situation, string };
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,5 @@ import { situation } from "./guidance.js";
|
|
|
2
2
|
import { block, boolean, componentSchema, defineCatalog, defineComponent, handler, image, inline, link, list, none, number, oneOf, string } from "./catalog.js";
|
|
3
3
|
import { action, data, dataSchema, isCallPolicy, mutation, query } from "./procedures.js";
|
|
4
4
|
import { contentSecurityPolicy, defineHost } from "./host.js";
|
|
5
|
-
import { jig } from "./jigs.js";
|
|
6
|
-
export { action, block, boolean, componentSchema, contentSecurityPolicy, data, dataSchema, defineCatalog, defineComponent, defineHost, handler, image, inline, isCallPolicy, jig, link, list, mutation, none, number, oneOf, query, situation, string };
|
|
5
|
+
import { jig, scanDefine } from "./jigs.js";
|
|
6
|
+
export { action, block, boolean, componentSchema, contentSecurityPolicy, data, dataSchema, defineCatalog, defineComponent, defineHost, handler, image, inline, isCallPolicy, jig, link, list, mutation, none, number, oneOf, query, scanDefine, situation, string };
|
package/dist/jigs.d.ts
CHANGED
|
@@ -33,6 +33,27 @@ export type DefineName<TSource extends string> = TSource extends `${string}<defi
|
|
|
33
33
|
export type PageName<TJigs extends ReadonlyArray<JigDefinition>> = Extract<TJigs[number], {
|
|
34
34
|
page: true;
|
|
35
35
|
}>["name"];
|
|
36
|
+
/**
|
|
37
|
+
* What `scanDefine` read: the name of the one `<define>` a source is, or why
|
|
38
|
+
* it is not one: `"document"` when the source is not one `<define>` and
|
|
39
|
+
* nothing else, `"name"` when the define's name is not a literal tag name
|
|
40
|
+
* (with `name` when it is a literal of another shape).
|
|
41
|
+
*/
|
|
42
|
+
export type DefineScan = {
|
|
43
|
+
message: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
reason: "document" | "name";
|
|
46
|
+
} | {
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The name of the one top-level `<define>` that `source` is, with nothing
|
|
51
|
+
* else but whitespace and a leading pragma line, read the way `jig()` and
|
|
52
|
+
* the compiler read it, or why it is not one. Never throws: for a source a
|
|
53
|
+
* user wrote, such as a saved tag. A scan, not a parse: the compiler checks
|
|
54
|
+
* the source again.
|
|
55
|
+
*/
|
|
56
|
+
export declare function scanDefine(source: string): DefineScan;
|
|
36
57
|
/**
|
|
37
58
|
* A jig whose source is one `<define>`: named by it. A `description` makes
|
|
38
59
|
* it a tag the model may write; `page: true` makes it a page the product
|
package/dist/jigs.js
CHANGED
|
@@ -73,17 +73,38 @@ function defineStart(source) {
|
|
|
73
73
|
if (start === void 0 || starts.length > 1 || close === -1 || source.slice(pragma, start).trim() !== "" || source.slice(close + 9).trim() !== "") return null;
|
|
74
74
|
return start;
|
|
75
75
|
}
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* The name of the one top-level `<define>` that `source` is, with nothing
|
|
78
|
+
* else but whitespace and a leading pragma line, read the way `jig()` and
|
|
79
|
+
* the compiler read it, or why it is not one. Never throws: for a source a
|
|
80
|
+
* user wrote, such as a saved tag. A scan, not a parse: the compiler checks
|
|
81
|
+
* the source again.
|
|
82
|
+
*/
|
|
83
|
+
function scanDefine(source) {
|
|
84
|
+
const start = defineStart(source);
|
|
85
|
+
if (start === null) return {
|
|
86
|
+
message: "The source is not one <define> and nothing else",
|
|
87
|
+
reason: "document"
|
|
88
|
+
};
|
|
78
89
|
const name = nameAttribute(source, start);
|
|
79
|
-
if (name === null)
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
if (name === null) return {
|
|
91
|
+
message: "A jig's <define> needs a literal name, e.g. <define name=\"orderRow\">",
|
|
92
|
+
reason: "name"
|
|
93
|
+
};
|
|
94
|
+
if (!TAG_NAME.test(name)) return {
|
|
95
|
+
message: `Jig name "${name}" must start with a lowercase letter and use letters and digits only`,
|
|
96
|
+
name,
|
|
97
|
+
reason: "name"
|
|
98
|
+
};
|
|
99
|
+
return { name };
|
|
82
100
|
}
|
|
83
101
|
function jig(definition) {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
|
|
102
|
+
const scanned = scanDefine(definition.source);
|
|
103
|
+
if ("reason" in scanned) {
|
|
104
|
+
if (scanned.reason === "document") return documentJig(definition);
|
|
105
|
+
throw new Error(scanned.message);
|
|
106
|
+
}
|
|
107
|
+
const { name } = scanned;
|
|
87
108
|
if (definition.name !== void 0) throw new Error(`Jig "${name}" has a <define>, which names it: remove name: "${definition.name}"`);
|
|
88
109
|
const page = definition.page ?? false;
|
|
89
110
|
const tag = definition.description !== void 0;
|
|
@@ -114,4 +135,4 @@ function documentJig(definition) {
|
|
|
114
135
|
};
|
|
115
136
|
}
|
|
116
137
|
//#endregion
|
|
117
|
-
export { jig };
|
|
138
|
+
export { jig, scanDefine };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigs.design/host",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Define a host: the catalog a spec may draw, the procedures it may call, and the image hosts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@jigs.design/protocol": "0.3.
|
|
28
|
+
"@jigs.design/protocol": "0.3.7"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"zod": "^4.0.0"
|