@markuplint/ml-spec 3.2.0 → 3.4.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.
@@ -6,189 +6,217 @@ import type { NamespaceURI } from '@markuplint/ml-ast';
6
6
  * markuplint Markup-language spec
7
7
  */
8
8
  export interface MLMLSpec {
9
- cites: Cites;
10
- def: SpecDefs;
11
- specs: ElementSpec[];
9
+ cites: Cites;
10
+ def: SpecDefs;
11
+ specs: ElementSpec[];
12
12
  }
13
13
  export type ExtendedElementSpec = Partial<Omit<ElementSpec, 'name' | 'attributes'>> & {
14
- name: ElementSpec['name'];
15
- attributes?: Record<string, Partial<Attribute>>;
14
+ name: ElementSpec['name'];
15
+ attributes?: Record<string, Partial<Attribute>>;
16
16
  };
17
17
  export type ExtendedSpec = {
18
- cites?: Cites;
19
- def?: Partial<SpecDefs>;
20
- specs?: ExtendedElementSpec[];
18
+ cites?: Cites;
19
+ def?: Partial<SpecDefs>;
20
+ specs?: ExtendedElementSpec[];
21
21
  };
22
22
  /**
23
23
  * Reference URLs
24
24
  */
25
25
  export type Cites = string[];
26
26
  export type SpecDefs = {
27
- '#globalAttrs': Partial<{
28
- '#extends': Record<string, Partial<Attribute>>;
29
- '#HTMLGlobalAttrs': Record<string, Partial<Attribute>>;
30
- [OtherGlobalAttrs: string]: Record<string, Partial<Attribute>>;
31
- }>;
32
- '#aria': {
33
- '1.2': ARIASpec;
34
- '1.1': ARIASpec;
35
- };
36
- '#contentModels': {
37
- [model in Category]?: string[];
38
- };
27
+ '#globalAttrs': Partial<{
28
+ '#extends': Record<string, Partial<Attribute>>;
29
+ '#HTMLGlobalAttrs': Record<string, Partial<Attribute>>;
30
+ [OtherGlobalAttrs: string]: Record<string, Partial<Attribute>>;
31
+ }>;
32
+ '#aria': {
33
+ '1.2': ARIASpec;
34
+ '1.1': ARIASpec;
35
+ };
36
+ '#contentModels': {
37
+ [model in Category]?: string[];
38
+ };
39
39
  };
40
40
  type ARIASpec = {
41
- roles: ARIARoleInSchema[];
42
- graphicsRoles: ARIARoleInSchema[];
43
- props: ARIAProperty[];
41
+ roles: ARIARoleInSchema[];
42
+ graphicsRoles: ARIARoleInSchema[];
43
+ props: ARIAProperty[];
44
44
  };
45
45
  /**
46
46
  * Element spec
47
47
  */
48
48
  export type ElementSpec = {
49
- /**
50
- * Tag name
51
- */
52
- name: string;
53
- /**
54
- * Namespaces in XML
55
- * @see https://www.w3.org/TR/xml-names/
56
- */
57
- namespace?: NamespaceURI;
58
- /**
59
- * Reference URL
60
- */
61
- cite: string;
62
- /**
63
- * Description
64
- */
65
- description?: string;
66
- /**
67
- * Experimental technology
68
- */
69
- experimental?: true;
70
- /**
71
- * Obsolete or alternative elements
72
- */
73
- obsolete?: true | {
74
- alt: string;
75
- };
76
- /**
77
- * Deprecated
78
- */
79
- deprecated?: true;
80
- /**
81
- * Non-standard
82
- */
83
- nonStandard?: true;
84
- /**
85
- * Element categories
86
- */
87
- categories: Category[];
88
- /**
89
- * Permitted contents and permitted parents
90
- */
91
- contentModel: ContentModel;
92
- /**
93
- * Tag omission
94
- */
95
- omission: ElementSpecOmission;
96
- /**
97
- * Global Attributes
98
- */
99
- globalAttrs: GlobalAttributes;
100
- /**
101
- * Attributes
102
- */
103
- attributes: Record<string, Attribute>;
104
- /**
105
- * WAI-ARIA role and properties
106
- */
107
- aria: ARIA;
108
- /**
109
- * If true, it is possible to add any properties as attributes,
110
- * for example, when using a template engine or a view language.
111
- *
112
- * @see https://v2.vuejs.org/v2/guide/components-slots.html#Scoped-Slots
113
- *
114
- * **It assumes to specify it on the parser plugin.**
115
- */
116
- possibleToAddProperties?: true;
49
+ /**
50
+ * Tag name
51
+ */
52
+ name: string;
53
+ /**
54
+ * Namespaces in XML
55
+ * @see https://www.w3.org/TR/xml-names/
56
+ */
57
+ namespace?: NamespaceURI;
58
+ /**
59
+ * Reference URL
60
+ */
61
+ cite: string;
62
+ /**
63
+ * Description
64
+ */
65
+ description?: string;
66
+ /**
67
+ * Experimental technology
68
+ */
69
+ experimental?: true;
70
+ /**
71
+ * Obsolete or alternative elements
72
+ */
73
+ obsolete?:
74
+ | true
75
+ | {
76
+ alt: string;
77
+ };
78
+ /**
79
+ * Deprecated
80
+ */
81
+ deprecated?: true;
82
+ /**
83
+ * Non-standard
84
+ */
85
+ nonStandard?: true;
86
+ /**
87
+ * Element categories
88
+ */
89
+ categories: Category[];
90
+ /**
91
+ * Permitted contents and permitted parents
92
+ */
93
+ contentModel: ContentModel;
94
+ /**
95
+ * Tag omission
96
+ */
97
+ omission: ElementSpecOmission;
98
+ /**
99
+ * Global Attributes
100
+ */
101
+ globalAttrs: GlobalAttributes;
102
+ /**
103
+ * Attributes
104
+ */
105
+ attributes: Record<string, Attribute>;
106
+ /**
107
+ * WAI-ARIA role and properties
108
+ */
109
+ aria: ARIA;
110
+ /**
111
+ * If true, it is possible to add any properties as attributes,
112
+ * for example, when using a template engine or a view language.
113
+ *
114
+ * @see https://v2.vuejs.org/v2/guide/components-slots.html#Scoped-Slots
115
+ *
116
+ * **It assumes to specify it on the parser plugin.**
117
+ */
118
+ possibleToAddProperties?: true;
117
119
  };
118
120
  type ElementSpecOmission = false | ElementSpecOmissionTags;
119
121
  type ElementSpecOmissionTags = {
120
- startTag: boolean | ElementCondition;
121
- endTag: boolean | ElementCondition;
122
+ startTag: boolean | ElementCondition;
123
+ endTag: boolean | ElementCondition;
122
124
  };
123
125
  type ElementCondition = {
124
- __WIP__: 'WORK_IN_PROGRESS';
126
+ __WIP__: 'WORK_IN_PROGRESS';
125
127
  };
126
128
  export type Attribute = {
127
- name: string;
128
- type: AttributeType | AttributeType[];
129
- description?: string;
130
- caseSensitive?: true;
131
- experimental?: boolean;
132
- obsolete?: true;
133
- deprecated?: boolean;
134
- nonStandard?: true;
129
+ name: string;
130
+ type: AttributeType | AttributeType[];
131
+ description?: string;
132
+ caseSensitive?: true;
133
+ experimental?: boolean;
134
+ obsolete?: true;
135
+ deprecated?: boolean;
136
+ nonStandard?: true;
135
137
  } & ExtendableAttributeSpec;
136
138
  type ExtendableAttributeSpec = Omit<AttributeJSON, 'type'>;
137
139
  export type ARIARole = {
138
- name: string;
139
- isAbstract: boolean;
140
- requiredContextRole: string[];
141
- requiredOwnedElements: string[];
142
- accessibleNameRequired: boolean;
143
- accessibleNameFromAuthor: boolean;
144
- accessibleNameFromContent: boolean;
145
- accessibleNameProhibited: boolean;
146
- childrenPresentational: boolean;
147
- ownedProperties: ARIARoleOwnedProperties[];
148
- prohibitedProperties: string[];
140
+ name: string;
141
+ isAbstract: boolean;
142
+ requiredContextRole: string[];
143
+ requiredOwnedElements: string[];
144
+ accessibleNameRequired: boolean;
145
+ accessibleNameFromAuthor: boolean;
146
+ accessibleNameFromContent: boolean;
147
+ accessibleNameProhibited: boolean;
148
+ childrenPresentational: boolean;
149
+ ownedProperties: ARIARoleOwnedProperties[];
150
+ prohibitedProperties: string[];
149
151
  };
150
- export type ARIARoleInSchema = Partial<ARIARole & {
151
- description: string;
152
- generalization: string[];
153
- }> & {
154
- name: string;
152
+ export type ARIARoleInSchema = Partial<
153
+ ARIARole & {
154
+ description: string;
155
+ generalization: string[];
156
+ }
157
+ > & {
158
+ name: string;
155
159
  };
156
160
  export type ARIARoleOwnedProperties = {
157
- name: string;
158
- inherited?: true;
159
- required?: true;
160
- deprecated?: true;
161
+ name: string;
162
+ inherited?: true;
163
+ required?: true;
164
+ deprecated?: true;
161
165
  };
162
166
  export type ARIAProperty = {
163
- name: string;
164
- type: 'property' | 'state';
165
- deprecated?: true;
166
- isGlobal?: true;
167
- value: ARIAAttributeValue;
168
- conditionalValue?: {
169
- role: string[];
170
- value: ARIAAttributeValue;
171
- }[];
172
- enum: string[];
173
- defaultValue?: string;
174
- equivalentHtmlAttrs?: EquivalentHtmlAttr[];
175
- valueDescriptions?: Record<string, string>;
167
+ name: string;
168
+ type: 'property' | 'state';
169
+ deprecated?: true;
170
+ isGlobal?: true;
171
+ value: ARIAAttributeValue;
172
+ conditionalValue?: {
173
+ role: string[];
174
+ value: ARIAAttributeValue;
175
+ }[];
176
+ enum: string[];
177
+ defaultValue?: string;
178
+ equivalentHtmlAttrs?: EquivalentHtmlAttr[];
179
+ valueDescriptions?: Record<string, string>;
176
180
  };
177
- export type ARIAAttributeValue = 'true/false' | 'tristate' | 'true/false/undefined' | 'ID reference' | 'ID reference list' | 'integer' | 'number' | 'string' | 'token' | 'token list' | 'URI';
181
+ export type ARIAAttributeValue =
182
+ | 'true/false'
183
+ | 'tristate'
184
+ | 'true/false/undefined'
185
+ | 'ID reference'
186
+ | 'ID reference list'
187
+ | 'integer'
188
+ | 'number'
189
+ | 'string'
190
+ | 'token'
191
+ | 'token list'
192
+ | 'URI';
178
193
  export type ARIAVersion = '1.1' | '1.2';
179
194
  export type EquivalentHtmlAttr = {
180
- htmlAttrName: string;
181
- isNotStrictEquivalent?: true;
182
- value: string | null;
195
+ htmlAttrName: string;
196
+ isNotStrictEquivalent?: true;
197
+ value: string | null;
183
198
  };
184
199
  export type Matches = (selector: string) => boolean;
185
200
  export type ComputedRole = {
186
- el: Element;
187
- role: (ARIARole & {
188
- superClassRoles: ARIARoleInSchema[];
189
- isImplicit?: boolean;
190
- }) | null;
191
- errorType?: RoleComputationError;
201
+ el: Element;
202
+ role:
203
+ | (ARIARole & {
204
+ superClassRoles: ARIARoleInSchema[];
205
+ isImplicit?: boolean;
206
+ })
207
+ | null;
208
+ errorType?: RoleComputationError;
192
209
  };
193
- export type RoleComputationError = 'ABSTRACT' | 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL' | 'IMPLICIT_ROLE_NAMESPACE_ERROR' | 'INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL' | 'INVALID_LANDMARK' | 'INVALID_REQUIRED_CONTEXT_ROLE' | 'NO_EXPLICIT' | 'NO_OWNER' | 'NO_PERMITTED' | 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL' | 'ROLE_NO_EXISTS';
210
+ export type RoleComputationError =
211
+ | 'ABSTRACT'
212
+ | 'GLOBAL_PROP_MUST_NOT_BE_PRESENTATIONAL'
213
+ | 'IMPLICIT_ROLE_NAMESPACE_ERROR'
214
+ | 'INTERACTIVE_ELEMENT_MUST_NOT_BE_PRESENTATIONAL'
215
+ | 'INVALID_LANDMARK'
216
+ | 'INVALID_REQUIRED_CONTEXT_ROLE'
217
+ | 'NO_EXPLICIT'
218
+ | 'NO_OWNER'
219
+ | 'NO_PERMITTED'
220
+ | 'REQUIRED_OWNED_ELEMENT_MUST_NOT_BE_PRESENTATIONAL'
221
+ | 'ROLE_NO_EXISTS';
194
222
  export {};
@@ -3,56 +3,95 @@
3
3
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
4
  * and run json-schema-to-typescript to regenerate this file.
5
5
  */
6
- export type PermittedContentPattern = PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore | PermittedContentChoice | PermittedContentTransparent;
6
+ export type PermittedContentPattern =
7
+ | PermittedContentRequire
8
+ | PermittedContentOptional
9
+ | PermittedContentOneOrMore
10
+ | PermittedContentZeroOrMore
11
+ | PermittedContentChoice
12
+ | PermittedContentTransparent;
7
13
  export type Model = ContentType | ContentType[];
8
14
  export type ContentType = string | Category;
9
- export type Category = '#text' | '#phrasing' | '#flow' | '#interactive' | '#heading' | '#sectioning' | '#metadata' | '#embedded' | '#palpable' | '#script-supporting' | '#SVGAnimation' | '#SVGBasicShapes' | '#SVGContainer' | '#SVGDescriptive' | '#SVGFilterPrimitive' | '#SVGFont' | '#SVGGradient' | '#SVGGraphics' | '#SVGGraphicsReferencing' | '#SVGLightSource' | '#SVGNeverRendered' | '#SVGNone' | '#SVGPaintServer' | '#SVGRenderable' | '#SVGShape' | '#SVGStructural' | '#SVGStructurallyExternal' | '#SVGTextContent' | '#SVGTextContentChild';
15
+ export type Category =
16
+ | '#text'
17
+ | '#phrasing'
18
+ | '#flow'
19
+ | '#interactive'
20
+ | '#heading'
21
+ | '#sectioning'
22
+ | '#metadata'
23
+ | '#embedded'
24
+ | '#palpable'
25
+ | '#script-supporting'
26
+ | '#SVGAnimation'
27
+ | '#SVGBasicShapes'
28
+ | '#SVGContainer'
29
+ | '#SVGDescriptive'
30
+ | '#SVGFilterPrimitive'
31
+ | '#SVGFont'
32
+ | '#SVGGradient'
33
+ | '#SVGGraphics'
34
+ | '#SVGGraphicsReferencing'
35
+ | '#SVGLightSource'
36
+ | '#SVGNeverRendered'
37
+ | '#SVGNone'
38
+ | '#SVGPaintServer'
39
+ | '#SVGRenderable'
40
+ | '#SVGShape'
41
+ | '#SVGStructural'
42
+ | '#SVGStructurallyExternal'
43
+ | '#SVGTextContent'
44
+ | '#SVGTextContentChild';
10
45
  export interface ContentModelsSchema {
11
- __contentModel?: ContentModel;
46
+ __contentModel?: ContentModel;
12
47
  }
13
48
  export interface ContentModel {
14
- contents: PermittedContentPattern[] | boolean;
15
- descendantOf?: string;
16
- conditional?: {
17
- condition: string;
18
- contents: PermittedContentPattern[] | boolean;
19
- }[];
49
+ contents: PermittedContentPattern[] | boolean;
50
+ descendantOf?: string;
51
+ conditional?: {
52
+ condition: string;
53
+ contents: PermittedContentPattern[] | boolean;
54
+ }[];
20
55
  }
21
56
  export interface PermittedContentRequire {
22
- require: Model | PermittedContentPattern[];
23
- max?: number;
24
- min?: number;
25
- _TODO_?: string;
57
+ require: Model | PermittedContentPattern[];
58
+ max?: number;
59
+ min?: number;
60
+ _TODO_?: string;
26
61
  }
27
62
  export interface PermittedContentOptional {
28
- optional: Model | PermittedContentPattern[];
29
- max?: number;
30
- _TODO_?: string;
63
+ optional: Model | PermittedContentPattern[];
64
+ max?: number;
65
+ _TODO_?: string;
31
66
  }
32
67
  export interface PermittedContentOneOrMore {
33
- oneOrMore: Model | PermittedContentPattern[];
34
- max?: number;
35
- _TODO_?: string;
68
+ oneOrMore: Model | PermittedContentPattern[];
69
+ max?: number;
70
+ _TODO_?: string;
36
71
  }
37
72
  export interface PermittedContentZeroOrMore {
38
- zeroOrMore: Model | PermittedContentPattern[];
39
- max?: number;
40
- _TODO_?: string;
73
+ zeroOrMore: Model | PermittedContentPattern[];
74
+ max?: number;
75
+ _TODO_?: string;
41
76
  }
42
77
  export interface PermittedContentChoice {
43
- /**
44
- * @minItems 2
45
- * @maxItems 5
46
- */
47
- choice: [PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]] | [
48
- PermittedContentPattern[],
49
- PermittedContentPattern[],
50
- PermittedContentPattern[],
51
- PermittedContentPattern[],
52
- PermittedContentPattern[]
53
- ];
54
- _TODO_?: string;
78
+ /**
79
+ * @minItems 2
80
+ * @maxItems 5
81
+ */
82
+ choice:
83
+ | [PermittedContentPattern[], PermittedContentPattern[]]
84
+ | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
85
+ | [PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[], PermittedContentPattern[]]
86
+ | [
87
+ PermittedContentPattern[],
88
+ PermittedContentPattern[],
89
+ PermittedContentPattern[],
90
+ PermittedContentPattern[],
91
+ PermittedContentPattern[],
92
+ ];
93
+ _TODO_?: string;
55
94
  }
56
95
  export interface PermittedContentTransparent {
57
- transparent: string;
96
+ transparent: string;
58
97
  }
@@ -1,5 +1,7 @@
1
- type NamedDefinition = string | {
2
- name: string;
3
- };
1
+ type NamedDefinition =
2
+ | string
3
+ | {
4
+ name: string;
5
+ };
4
6
  export declare function mergeArray<T extends NamedDefinition>(a: T[], b: T[] | null | undefined): T[];
5
7
  export {};
@@ -1,9 +1,9 @@
1
1
  import type { NamespaceURI, Namespace } from '@markuplint/ml-ast';
2
2
  type NamespacedElementName = {
3
- localNameWithNS: string;
4
- localName: string;
5
- namespace: Namespace;
6
- namespaceURI: NamespaceURI;
3
+ localNameWithNS: string;
4
+ localName: string;
5
+ namespace: Namespace;
6
+ namespaceURI: NamespaceURI;
7
7
  };
8
8
  export declare function resolveNamespace(name: string, namespaceURI?: string | null): NamespacedElementName;
9
9
  export {};
@@ -10,13 +10,14 @@ const namespaceURIMap = {
10
10
  xlink: 'http://www.w3.org/1999/xlink',
11
11
  };
12
12
  function resolveNamespace(name, namespaceURI = 'http://www.w3.org/1999/xhtml') {
13
+ var _a;
13
14
  const cached = cache.get(name + namespaceURI);
14
15
  if (cached) {
15
16
  return cached;
16
17
  }
17
18
  const [_explicitNS, _localName] = name.split(':');
18
19
  const explicitNS = _localName ? _explicitNS : null;
19
- const localName = _localName !== null && _localName !== void 0 ? _localName : _explicitNS;
20
+ const localName = (_a = _localName !== null && _localName !== void 0 ? _localName : _explicitNS) !== null && _a !== void 0 ? _a : '';
20
21
  const namespace = ['html', 'svg', 'mml', 'xlink'].find(_ns => _ns === (explicitNS || (0, get_ns_1.getNS)(namespaceURI || null))) ||
21
22
  'html';
22
23
  const result = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-spec",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Types and schema that specs of the Markup languages for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -11,6 +11,9 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
+ "typedoc": {
15
+ "entryPoint": "./src/index.ts"
16
+ },
14
17
  "scripts": {
15
18
  "build": "tsc",
16
19
  "dev": "tsc --build --watch",
@@ -22,14 +25,14 @@
22
25
  "schema": "run-s schema:*"
23
26
  },
24
27
  "dependencies": {
25
- "@markuplint/ml-ast": "3.0.0-rc.5",
28
+ "@markuplint/ml-ast": "3.0.0",
26
29
  "dom-accessibility-api": "^0.5.14",
27
30
  "tslib": "^2.4.1"
28
31
  },
29
32
  "devDependencies": {
30
- "@markuplint/test-tools": "3.0.0-rc.5",
31
- "@markuplint/types": "3.1.0",
32
- "json-schema-to-typescript": "^11.0.2"
33
+ "@markuplint/test-tools": "3.0.0",
34
+ "@markuplint/types": "3.3.0",
35
+ "json-schema-to-typescript": "11.0.2"
33
36
  },
34
- "gitHead": "26b04e045d91e29befca34c10dda2147b1bca9c7"
37
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
35
38
  }