@markuplint/ml-spec 3.0.0-alpha.0 → 3.0.0-alpha.2

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.
Files changed (58) hide show
  1. package/lib/dom-traverse/get-content-model.d.ts +3 -0
  2. package/lib/dom-traverse/get-content-model.js +28 -0
  3. package/lib/dom-traverse/get-spec.d.ts +2 -2
  4. package/lib/dom-traverse/get-spec.js +2 -2
  5. package/lib/index.d.ts +2 -1
  6. package/lib/index.js +2 -1
  7. package/lib/specs/content-model-category-to-tag-names.d.ts +2 -2
  8. package/lib/specs/content-model-category-to-tag-names.js +2 -2
  9. package/lib/specs/get-aria.js +3 -3
  10. package/lib/specs/get-attr-specs.d.ts +1 -1
  11. package/lib/specs/get-selectors-by-content-model-category.d.ts +1 -1
  12. package/lib/specs/get-spec-by-tag-name.d.ts +2 -2
  13. package/lib/specs/get-spec-by-tag-name.js +1 -1
  14. package/lib/specs/schema-to-spec.d.ts +1 -1
  15. package/lib/specs/schema-to-spec.js +1 -1
  16. package/lib/types/aria.d.ts +7 -1
  17. package/lib/types/attributes.d.ts +93 -38
  18. package/lib/types/index.d.ts +8 -8
  19. package/lib/types/permitted-structres.d.ts +21 -27
  20. package/lib/types/permitted-structures.d.ts +54 -0
  21. package/lib/types/permitted-structures.js +8 -0
  22. package/package.json +7 -7
  23. package/schema.json +6 -6
  24. package/schemas/aria.schema.json +1 -1
  25. package/schemas/content-models.schema.json +32 -47
  26. package/src/dom-traverse/accname-computation.spec.ts +3 -3
  27. package/src/dom-traverse/get-computed-role.spec.ts +1 -1
  28. package/src/dom-traverse/get-content-model.ts +32 -0
  29. package/src/dom-traverse/get-spec.ts +3 -3
  30. package/src/index.ts +2 -1
  31. package/src/specs/content-model-category-to-tag-names.ts +3 -3
  32. package/src/specs/get-aria.ts +3 -3
  33. package/src/specs/get-selectors-by-content-model-category.ts +1 -1
  34. package/src/specs/get-spec-by-tag-name.spec.ts +10 -10
  35. package/src/specs/get-spec-by-tag-name.ts +9 -5
  36. package/src/specs/schema-to-spec.ts +1 -1
  37. package/src/types/aria.ts +7 -1
  38. package/src/types/attributes.ts +160 -105
  39. package/src/types/index.ts +8 -8
  40. package/src/types/permitted-structres.ts +23 -30
  41. package/src/types/permitted-structures.ts +97 -0
  42. package/tsconfig.tsbuildinfo +1 -1
  43. package/lib/dom-traverse/focusability-computation.d.ts +0 -1
  44. package/lib/dom-traverse/focusability-computation.js +0 -8
  45. package/lib/dom-traverse/get-aria.d.ts +0 -9
  46. package/lib/dom-traverse/get-aria.js +0 -54
  47. package/lib/specs/aria-spec.d.ts +0 -5
  48. package/lib/specs/aria-spec.js +0 -12
  49. package/lib/specs/get-spec.d.ts +0 -13
  50. package/lib/specs/get-spec.js +0 -85
  51. package/lib/specs/html-spec.d.ts +0 -6
  52. package/lib/specs/html-spec.js +0 -16
  53. package/lib/specs/resolve-namespace.d.ts +0 -9
  54. package/lib/specs/resolve-namespace.js +0 -26
  55. package/lib/utils/cache.d.ts +0 -10
  56. package/lib/utils/cache.js +0 -42
  57. package/lib/utils.d.ts +0 -8
  58. package/lib/utils.js +0 -50
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveNamespace = void 0;
4
- const utils_1 = require("../utils");
5
- const cache = new Map();
6
- function resolveNamespace(localName, namespaceURI = 'http://www.w3.org/1999/xhtml') {
7
- const cached = cache.get(localName + namespaceURI);
8
- if (cached) {
9
- return cached;
10
- }
11
- const name = localName.split(':')[1] || localName;
12
- const ns = (0, utils_1.getNS)(namespaceURI || null);
13
- const result = {
14
- localNameWithNS: `${ns === 'html' ? '' : `${ns}:`}${name}`,
15
- localName: name,
16
- namespace: ns,
17
- namespaceURI: [
18
- 'http://www.w3.org/1999/xhtml',
19
- 'http://www.w3.org/2000/svg',
20
- 'http://www.w3.org/1998/Math/MathML',
21
- ].find(ns => namespaceURI) || 'http://www.w3.org/1999/xhtml',
22
- };
23
- cache.set(localName + namespaceURI, result);
24
- return result;
25
- }
26
- exports.resolveNamespace = resolveNamespace;
@@ -1,10 +0,0 @@
1
- declare type CacheKeys<K1, K2 = undefined, K3 = undefined, K4 = undefined, K5 = undefined, K6 = undefined> = K2 extends undefined ? [K1] : K3 extends undefined ? [K1, K2] : K4 extends undefined ? [K1, K2, K3] : K5 extends undefined ? [K1, K2, K3, K4] : K6 extends undefined ? [K1, K2, K3, K4, K5] : [K1, K2, K3, K4, K5, K6];
2
- export declare class Cache<V, K1, K2 = undefined, K3 = undefined, K4 = undefined, K5 = undefined, K6 = undefined, K = CacheKeys<K1, K2, K3, K4, K5, K6>> {
3
- #private;
4
- constructor();
5
- set(keys: K, value: V): this;
6
- get(keys: K): V | undefined;
7
- createKey(keys: K): string;
8
- clear(): void;
9
- }
10
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var _Cache_i, _Cache_m, _Cache_o;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Cache = void 0;
5
- const tslib_1 = require("tslib");
6
- class Cache {
7
- constructor() {
8
- _Cache_i.set(this, 0);
9
- _Cache_m.set(this, new Map());
10
- _Cache_o.set(this, new Map());
11
- }
12
- set(keys, value) {
13
- const _keys = this.createKey(keys);
14
- tslib_1.__classPrivateFieldGet(this, _Cache_m, "f").set(_keys, value);
15
- return this;
16
- }
17
- get(keys) {
18
- const _keys = this.createKey(keys);
19
- return tslib_1.__classPrivateFieldGet(this, _Cache_m, "f").get(_keys);
20
- }
21
- createKey(keys) {
22
- const _keys = keys
23
- // @ts-ignore
24
- .map(o => {
25
- if (tslib_1.__classPrivateFieldGet(this, _Cache_o, "f").has(o)) {
26
- return tslib_1.__classPrivateFieldGet(this, _Cache_o, "f").get(o);
27
- }
28
- const i = tslib_1.__classPrivateFieldGet(this, _Cache_i, "f") + 1;
29
- tslib_1.__classPrivateFieldSet(this, _Cache_i, i, "f");
30
- tslib_1.__classPrivateFieldGet(this, _Cache_o, "f").set(o, i);
31
- return i;
32
- })
33
- .join('_');
34
- return _keys;
35
- }
36
- clear() {
37
- tslib_1.__classPrivateFieldGet(this, _Cache_m, "f").clear();
38
- tslib_1.__classPrivateFieldGet(this, _Cache_o, "f").clear();
39
- }
40
- }
41
- exports.Cache = Cache;
42
- _Cache_i = new WeakMap(), _Cache_m = new WeakMap(), _Cache_o = new WeakMap();
package/lib/utils.d.ts DELETED
@@ -1,8 +0,0 @@
1
- declare type NamedDefinition =
2
- | string
3
- | {
4
- name: string;
5
- };
6
- export declare function getNS(namespaceURI: string | null): 'svg' | 'mml' | 'html';
7
- export declare function mergeArray<T extends NamedDefinition>(a: T[], b: T[] | null | undefined): T[];
8
- export {};
package/lib/utils.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeArray = exports.getNS = void 0;
4
- function getNS(namespaceURI) {
5
- switch (namespaceURI) {
6
- case 'http://www.w3.org/2000/svg': {
7
- return 'svg';
8
- }
9
- case 'http://www.w3.org/1998/Math/MathML': {
10
- return 'mml';
11
- }
12
- default: {
13
- return 'html';
14
- }
15
- }
16
- }
17
- exports.getNS = getNS;
18
- function mergeArray(a, b) {
19
- if (!b) {
20
- return a;
21
- }
22
- const result = a.slice();
23
- for (const bItem of b) {
24
- const bName = getName(bItem);
25
- const aIndex = result.findIndex(item => getName(item) === bName);
26
- if (aIndex === -1) {
27
- result.push(bItem);
28
- continue;
29
- }
30
- const aItem = result.splice(aIndex, 1)[0];
31
- if (typeof bItem === 'string') {
32
- continue;
33
- }
34
- if (typeof aItem === 'string') {
35
- result.push(bItem);
36
- continue;
37
- }
38
- const exItem = {
39
- ...aItem,
40
- ...bItem,
41
- };
42
- result.push(exItem);
43
- }
44
- return result;
45
- }
46
- exports.mergeArray = mergeArray;
47
- function getName(def) {
48
- const result = typeof def === 'string' ? def : def.name;
49
- return result.toLowerCase().trim();
50
- }