html-standard 0.0.3 → 0.0.5

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.cts CHANGED
@@ -1,3 +1,8 @@
1
+ interface ReadonlyMap<T extends NonNullable<unknown>> {
2
+ get(name: string): T | undefined;
3
+ has(name: string): boolean;
4
+ }
5
+
1
6
  type ContentConstraintValue = {
2
7
  ifAttributes?(attributes: Record<string, string>): boolean;
3
8
  required?: boolean;
@@ -5,25 +10,30 @@ type ContentConstraintValue = {
5
10
  max?: number;
6
11
  min?: number;
7
12
  };
8
- type ContentConstraint = Map<string, ContentConstraintValue>;
9
- type Constraints = {
13
+ type ContentConstraints = {
10
14
  children?: ContentConstraint;
11
15
  descendants?: ContentConstraint;
12
16
  };
17
+ type ContentConstraint = ReadonlyMap<ContentConstraintValue>;
18
+
19
+ interface ReadonlySet<T extends NonNullable<unknown>> {
20
+ has(name: string): boolean;
21
+ }
22
+
13
23
  type ContentModel = {
14
24
  type: "required";
15
- contents: Set<string>;
25
+ contents: ReadonlySet<string>;
16
26
  } | {
17
27
  type: "optional";
18
- contents: Set<string>;
28
+ contents: ReadonlySet<string>;
19
29
  } | {
20
30
  type: "zeroOrMore";
21
- contents: Set<string>;
22
- constraints?: Constraints;
31
+ contents: ReadonlySet<string>;
32
+ constraints?: ContentConstraints;
23
33
  } | {
24
34
  type: "oneOrMore";
25
- contents: Set<string>;
26
- constraints?: Constraints;
35
+ contents: ReadonlySet<string>;
36
+ constraints?: ContentConstraints;
27
37
  } | {
28
38
  type: "either";
29
39
  options: ContentModel[][];
@@ -37,14 +47,21 @@ type ContentModel = {
37
47
  model: ContentModel[] | null;
38
48
  }[];
39
49
  };
40
- type ElementSpec = {
50
+
51
+ interface AttributesSpecMap {
52
+ has(name: string): boolean;
53
+ }
54
+
55
+ interface ElementSpec {
41
56
  contents: ContentModel[] | null;
42
- attributes: {
43
- has(name: string): boolean;
44
- global: Set<string>;
45
- specific: Set<string>;
46
- };
57
+ attributes: AttributesSpecMap;
58
+ }
59
+
60
+ type ElementState = {
61
+ parent?: string;
62
+ attributes?: Record<string, string | boolean>;
47
63
  };
64
+ type GetElementSpec = (state?: ElementState) => ElementSpec;
48
65
 
49
66
  type Options = {
50
67
  parent?: string;
@@ -52,4 +69,4 @@ type Options = {
52
69
  };
53
70
  declare function getElementSpec(name: string, options?: Options): ElementSpec | null;
54
71
 
55
- export { getElementSpec };
72
+ export { type AttributesSpecMap, type ContentConstraint, type ContentConstraintValue, type ContentConstraints, type ContentModel, type ElementSpec, type GetElementSpec, type ReadonlyMap, type ReadonlySet, getElementSpec };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ interface ReadonlyMap<T extends NonNullable<unknown>> {
2
+ get(name: string): T | undefined;
3
+ has(name: string): boolean;
4
+ }
5
+
1
6
  type ContentConstraintValue = {
2
7
  ifAttributes?(attributes: Record<string, string>): boolean;
3
8
  required?: boolean;
@@ -5,25 +10,30 @@ type ContentConstraintValue = {
5
10
  max?: number;
6
11
  min?: number;
7
12
  };
8
- type ContentConstraint = Map<string, ContentConstraintValue>;
9
- type Constraints = {
13
+ type ContentConstraints = {
10
14
  children?: ContentConstraint;
11
15
  descendants?: ContentConstraint;
12
16
  };
17
+ type ContentConstraint = ReadonlyMap<ContentConstraintValue>;
18
+
19
+ interface ReadonlySet<T extends NonNullable<unknown>> {
20
+ has(name: string): boolean;
21
+ }
22
+
13
23
  type ContentModel = {
14
24
  type: "required";
15
- contents: Set<string>;
25
+ contents: ReadonlySet<string>;
16
26
  } | {
17
27
  type: "optional";
18
- contents: Set<string>;
28
+ contents: ReadonlySet<string>;
19
29
  } | {
20
30
  type: "zeroOrMore";
21
- contents: Set<string>;
22
- constraints?: Constraints;
31
+ contents: ReadonlySet<string>;
32
+ constraints?: ContentConstraints;
23
33
  } | {
24
34
  type: "oneOrMore";
25
- contents: Set<string>;
26
- constraints?: Constraints;
35
+ contents: ReadonlySet<string>;
36
+ constraints?: ContentConstraints;
27
37
  } | {
28
38
  type: "either";
29
39
  options: ContentModel[][];
@@ -37,14 +47,21 @@ type ContentModel = {
37
47
  model: ContentModel[] | null;
38
48
  }[];
39
49
  };
40
- type ElementSpec = {
50
+
51
+ interface AttributesSpecMap {
52
+ has(name: string): boolean;
53
+ }
54
+
55
+ interface ElementSpec {
41
56
  contents: ContentModel[] | null;
42
- attributes: {
43
- has(name: string): boolean;
44
- global: Set<string>;
45
- specific: Set<string>;
46
- };
57
+ attributes: AttributesSpecMap;
58
+ }
59
+
60
+ type ElementState = {
61
+ parent?: string;
62
+ attributes?: Record<string, string | boolean>;
47
63
  };
64
+ type GetElementSpec = (state?: ElementState) => ElementSpec;
48
65
 
49
66
  type Options = {
50
67
  parent?: string;
@@ -52,4 +69,4 @@ type Options = {
52
69
  };
53
70
  declare function getElementSpec(name: string, options?: Options): ElementSpec | null;
54
71
 
55
- export { getElementSpec };
72
+ export { type AttributesSpecMap, type ContentConstraint, type ContentConstraintValue, type ContentConstraints, type ContentModel, type ElementSpec, type GetElementSpec, type ReadonlyMap, type ReadonlySet, getElementSpec };