html-standard 0.0.2 → 0.0.3

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 (133) hide show
  1. package/dist/index.cjs +2338 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +55 -0
  4. package/dist/index.d.ts +55 -0
  5. package/dist/index.js +2317 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +7 -4
  8. package/.prettierignore +0 -1
  9. package/.prettierrc +0 -1
  10. package/jest.config.js +0 -7
  11. package/src/elements/common/attributes.ts +0 -34
  12. package/src/elements/common/contents.ts +0 -191
  13. package/src/elements/document/html.ts +0 -18
  14. package/src/elements/document-metadata/base.ts +0 -9
  15. package/src/elements/document-metadata/head.ts +0 -21
  16. package/src/elements/document-metadata/link.ts +0 -27
  17. package/src/elements/document-metadata/meta.ts +0 -15
  18. package/src/elements/document-metadata/style.ts +0 -14
  19. package/src/elements/document-metadata/title.ts +0 -14
  20. package/src/elements/edits/del.ts +0 -15
  21. package/src/elements/edits/ins.ts +0 -15
  22. package/src/elements/embedded-content/area.ts +0 -19
  23. package/src/elements/embedded-content/audio.ts +0 -57
  24. package/src/elements/embedded-content/embed.ts +0 -9
  25. package/src/elements/embedded-content/iframe.ts +0 -20
  26. package/src/elements/embedded-content/img.ts +0 -23
  27. package/src/elements/embedded-content/map.ts +0 -15
  28. package/src/elements/embedded-content/object.ts +0 -22
  29. package/src/elements/embedded-content/picture.ts +0 -31
  30. package/src/elements/embedded-content/source.ts +0 -17
  31. package/src/elements/embedded-content/track.ts +0 -16
  32. package/src/elements/embedded-content/video.ts +0 -63
  33. package/src/elements/forms/button.ts +0 -39
  34. package/src/elements/forms/datalist.ts +0 -29
  35. package/src/elements/forms/fieldset.ts +0 -19
  36. package/src/elements/forms/form.ts +0 -36
  37. package/src/elements/forms/input.ts +0 -45
  38. package/src/elements/forms/label.ts +0 -18
  39. package/src/elements/forms/legend.ts +0 -16
  40. package/src/elements/forms/meter.ts +0 -32
  41. package/src/elements/forms/optgroup.ts +0 -16
  42. package/src/elements/forms/option.ts +0 -45
  43. package/src/elements/forms/output.ts +0 -15
  44. package/src/elements/forms/progress.ts +0 -18
  45. package/src/elements/forms/select.ts +0 -29
  46. package/src/elements/forms/textarea.ts +0 -29
  47. package/src/elements/grouping-content/blockquote.ts +0 -15
  48. package/src/elements/grouping-content/dd.ts +0 -15
  49. package/src/elements/grouping-content/div.ts +0 -43
  50. package/src/elements/grouping-content/dl.ts +0 -52
  51. package/src/elements/grouping-content/dt.ts +0 -26
  52. package/src/elements/grouping-content/figcaption.ts +0 -15
  53. package/src/elements/grouping-content/figure.ts +0 -42
  54. package/src/elements/grouping-content/hr.ts +0 -9
  55. package/src/elements/grouping-content/li.ts +0 -31
  56. package/src/elements/grouping-content/main.ts +0 -15
  57. package/src/elements/grouping-content/menu.ts +0 -16
  58. package/src/elements/grouping-content/ol.ts +0 -16
  59. package/src/elements/grouping-content/p.ts +0 -15
  60. package/src/elements/grouping-content/pre.ts +0 -15
  61. package/src/elements/grouping-content/search.ts +0 -15
  62. package/src/elements/grouping-content/ul.ts +0 -16
  63. package/src/elements/index.ts +0 -137
  64. package/src/elements/interactive-elements/details.ts +0 -19
  65. package/src/elements/interactive-elements/dialog.ts +0 -15
  66. package/src/elements/interactive-elements/summary.ts +0 -16
  67. package/src/elements/scripting/canvas.ts +0 -19
  68. package/src/elements/scripting/noscript.ts +0 -15
  69. package/src/elements/scripting/script.ts +0 -26
  70. package/src/elements/scripting/slot.ts +0 -15
  71. package/src/elements/scripting/template.ts +0 -14
  72. package/src/elements/sections/address.ts +0 -26
  73. package/src/elements/sections/article.ts +0 -15
  74. package/src/elements/sections/aside.ts +0 -15
  75. package/src/elements/sections/body.ts +0 -34
  76. package/src/elements/sections/footer.ts +0 -21
  77. package/src/elements/sections/h1.ts +0 -15
  78. package/src/elements/sections/h2.ts +0 -2
  79. package/src/elements/sections/h3.ts +0 -2
  80. package/src/elements/sections/h4.ts +0 -2
  81. package/src/elements/sections/h5.ts +0 -2
  82. package/src/elements/sections/h6.ts +0 -2
  83. package/src/elements/sections/header.ts +0 -21
  84. package/src/elements/sections/hrgroup.ts +0 -39
  85. package/src/elements/sections/nav.ts +0 -15
  86. package/src/elements/sections/section.ts +0 -15
  87. package/src/elements/tabular-data/caption.ts +0 -18
  88. package/src/elements/tabular-data/col.ts +0 -9
  89. package/src/elements/tabular-data/colgroup.ts +0 -26
  90. package/src/elements/tabular-data/table.ts +0 -68
  91. package/src/elements/tabular-data/tbody.ts +0 -16
  92. package/src/elements/tabular-data/td.ts +0 -15
  93. package/src/elements/tabular-data/tfoot.ts +0 -16
  94. package/src/elements/tabular-data/th.ts +0 -32
  95. package/src/elements/tabular-data/thead.ts +0 -16
  96. package/src/elements/tabular-data/tr.ts +0 -16
  97. package/src/elements/text-level-semantics/a.ts +0 -49
  98. package/src/elements/text-level-semantics/abbr.ts +0 -15
  99. package/src/elements/text-level-semantics/b.ts +0 -15
  100. package/src/elements/text-level-semantics/bdi.ts +0 -15
  101. package/src/elements/text-level-semantics/bdo.ts +0 -15
  102. package/src/elements/text-level-semantics/br.ts +0 -9
  103. package/src/elements/text-level-semantics/cite.ts +0 -15
  104. package/src/elements/text-level-semantics/code.ts +0 -15
  105. package/src/elements/text-level-semantics/data.ts +0 -15
  106. package/src/elements/text-level-semantics/dfn.ts +0 -18
  107. package/src/elements/text-level-semantics/em.ts +0 -15
  108. package/src/elements/text-level-semantics/i.ts +0 -15
  109. package/src/elements/text-level-semantics/kbd.ts +0 -15
  110. package/src/elements/text-level-semantics/mark.ts +0 -15
  111. package/src/elements/text-level-semantics/q.ts +0 -15
  112. package/src/elements/text-level-semantics/rp.ts +0 -15
  113. package/src/elements/text-level-semantics/rt.ts +0 -15
  114. package/src/elements/text-level-semantics/ruby.ts +0 -16
  115. package/src/elements/text-level-semantics/s.ts +0 -15
  116. package/src/elements/text-level-semantics/samp.ts +0 -15
  117. package/src/elements/text-level-semantics/small.ts +0 -15
  118. package/src/elements/text-level-semantics/span.ts +0 -15
  119. package/src/elements/text-level-semantics/strong.ts +0 -15
  120. package/src/elements/text-level-semantics/sub.ts +0 -15
  121. package/src/elements/text-level-semantics/sup.ts +0 -3
  122. package/src/elements/text-level-semantics/time.ts +0 -30
  123. package/src/elements/text-level-semantics/u.ts +0 -15
  124. package/src/elements/text-level-semantics/var.ts +0 -15
  125. package/src/elements/text-level-semantics/wbr.ts +0 -9
  126. package/src/elements/types.ts +0 -71
  127. package/src/elements/utils/contentAttributes.ts +0 -23
  128. package/src/elements/utils/contents.ts +0 -0
  129. package/src/getElementSpec.ts +0 -20
  130. package/src/index.ts +0 -1
  131. package/src/utils/set.ts +0 -20
  132. package/tsconfig.json +0 -10
  133. package/tsup.config.ts +0 -11
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const abbrSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const abbr: GetElementSpec = () => abbrSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const bSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const b: GetElementSpec = () => bSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const bdiSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const bdi: GetElementSpec = () => bdiSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const bdoSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const bdo: GetElementSpec = () => bdoSpec;
@@ -1,9 +0,0 @@
1
- import { ElementSpec, GetElementSpec } from "../types";
2
- import { contentAttributes } from "../utils/contentAttributes";
3
-
4
- const brSpec: ElementSpec = {
5
- contents: null,
6
- attributes: contentAttributes(true),
7
- };
8
-
9
- export const br: GetElementSpec = () => brSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const citeSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const cite: GetElementSpec = () => citeSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const codeSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const code: GetElementSpec = () => codeSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const dataSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true, ["value"]),
13
- };
14
-
15
- export const data: GetElementSpec = () => dataSpec;
@@ -1,18 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const dfnSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- constraints: {
11
- descendants: new Map([["dfn", { disallow: true }]]),
12
- },
13
- },
14
- ],
15
- attributes: contentAttributes(true),
16
- };
17
-
18
- export const dfn: GetElementSpec = () => dfnSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const emSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const em: GetElementSpec = () => emSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const iSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const i: GetElementSpec = () => iSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const kbdSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const kbd: GetElementSpec = () => kbdSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const markSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const mark: GetElementSpec = () => markSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const qSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true, ["cite"]),
13
- };
14
-
15
- export const q: GetElementSpec = () => qSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const rpSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.text,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const rp: GetElementSpec = () => rpSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const rtSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const rt: GetElementSpec = () => rtSpec;
@@ -1,16 +0,0 @@
1
- import { addToSet } from "../../utils/set";
2
- import { contents } from "../common/contents";
3
- import { ElementSpec, GetElementSpec } from "../types";
4
- import { contentAttributes } from "../utils/contentAttributes";
5
-
6
- const rubySpec: ElementSpec = {
7
- contents: [
8
- {
9
- type: "zeroOrMore",
10
- contents: addToSet(contents.phrasingContent, "rt", "rp"),
11
- },
12
- ],
13
- attributes: contentAttributes(true),
14
- };
15
-
16
- export const ruby: GetElementSpec = () => rubySpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const sSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const s: GetElementSpec = () => sSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const sampSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const samp: GetElementSpec = () => sampSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const smallSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const small: GetElementSpec = () => smallSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const spanSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const span: GetElementSpec = () => spanSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const strongSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const strong: GetElementSpec = () => strongSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const subSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const sub: GetElementSpec = () => subSpec;
@@ -1,3 +0,0 @@
1
- import { sub } from "./sub";
2
-
3
- export const sup = sub;
@@ -1,30 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const timeWihthoutDatetimeSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true, ["datetime"]),
13
- };
14
- const timeWithDatetimeSpec: ElementSpec = {
15
- contents: [
16
- {
17
- type: "oneOrMore",
18
- contents: contents.text,
19
- },
20
- ],
21
- attributes: contentAttributes(true, ["datetime"]),
22
- };
23
-
24
- export const time: GetElementSpec = (state) => {
25
- const attributes = state?.attributes || {};
26
- if (!!attributes["datetime"]) {
27
- return timeWihthoutDatetimeSpec;
28
- }
29
- return timeWithDatetimeSpec;
30
- };
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const uSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const u: GetElementSpec = () => uSpec;
@@ -1,15 +0,0 @@
1
- import { contents } from "../common/contents";
2
- import { ElementSpec, GetElementSpec } from "../types";
3
- import { contentAttributes } from "../utils/contentAttributes";
4
-
5
- const varSpec: ElementSpec = {
6
- contents: [
7
- {
8
- type: "oneOrMore",
9
- contents: contents.phrasingContent,
10
- },
11
- ],
12
- attributes: contentAttributes(true),
13
- };
14
-
15
- export const _var: GetElementSpec = () => varSpec;
@@ -1,9 +0,0 @@
1
- import { ElementSpec, GetElementSpec } from "../types";
2
- import { contentAttributes } from "../utils/contentAttributes";
3
-
4
- const wbrSpec: ElementSpec = {
5
- contents: null,
6
- attributes: contentAttributes(true),
7
- };
8
-
9
- export const wbr: GetElementSpec = () => wbrSpec;
@@ -1,71 +0,0 @@
1
- export type ContentConstraintValue = {
2
- ifAttributes?(attributes: Record<string, string>): boolean;
3
- required?: boolean;
4
- disallow?: boolean;
5
- max?: number;
6
- min?: number;
7
- };
8
-
9
- type ContentConstraint = Map<string, ContentConstraintValue>;
10
-
11
- type Constraints = {
12
- children?: ContentConstraint;
13
- descendants?: ContentConstraint;
14
- };
15
-
16
- type ContentModel =
17
- | {
18
- type: "required";
19
- contents: Set<string>;
20
- }
21
- | {
22
- type: "optional";
23
- contents: Set<string>;
24
- }
25
- | {
26
- type: "zeroOrMore";
27
- contents: Set<string>;
28
- constraints?: Constraints;
29
- }
30
- | {
31
- type: "oneOrMore";
32
- contents: Set<string>;
33
- constraints?: Constraints;
34
- }
35
- | {
36
- type: "either";
37
- options: ContentModel[][];
38
- }
39
- | {
40
- type: "conditional";
41
- conditions: {
42
- ifAttributes?: (
43
- attributes: Record<string, boolean | string>,
44
- ) => boolean;
45
- ifParent?: (parent: { name: string }) => void;
46
- model: ContentModel[] | null;
47
- }[];
48
- };
49
-
50
- type ElementState = {
51
- parent?: string;
52
- attributes?: Record<string, string | boolean>;
53
- };
54
-
55
- export type ElementSpec = {
56
- contents: ContentModel[] | null;
57
- attributes: {
58
- has(name: string): boolean;
59
- global: Set<string>;
60
- specific: Set<string>;
61
- };
62
- };
63
-
64
- export type GetElementSpec = (state?: ElementState) => {
65
- contents: ContentModel[] | null;
66
- attributes: {
67
- has(name: string): boolean;
68
- global: Set<string>;
69
- specific: Set<string>;
70
- };
71
- };
@@ -1,23 +0,0 @@
1
- import { globalAttributes } from "../common/attributes";
2
-
3
- const empty = new Set<string>();
4
-
5
- class AttributesSpec {
6
- public readonly global: Set<string> = globalAttributes;
7
- public readonly specific: Set<string> = empty;
8
- constructor(allowGloabal: boolean, specific?: string[]) {
9
- if (!allowGloabal) {
10
- this.global = empty;
11
- }
12
- if (specific?.length) {
13
- this.specific = new Set(specific);
14
- }
15
- }
16
- has(name: string) {
17
- return this.global.has(name) || this.specific.has(name);
18
- }
19
- }
20
-
21
- export const contentAttributes = (global: boolean, specific?: string[]) => {
22
- return new AttributesSpec(global, specific);
23
- };
File without changes
@@ -1,20 +0,0 @@
1
- import { ElementSpec, GetElementSpec } from "./elements/types";
2
- import * as elementsSpecs from "./elements";
3
-
4
- const specsRecord: Record<string, GetElementSpec> = elementsSpecs;
5
-
6
- type Options = {
7
- parent?: string;
8
- attributes?: Record<string, string | boolean>;
9
- };
10
-
11
- export function getElementSpec(
12
- name: string,
13
- options?: Options,
14
- ): ElementSpec | null {
15
- const getSpec = specsRecord[name.toLowerCase()] || null;
16
- if (!getSpec) {
17
- return null;
18
- }
19
- return getSpec(options);
20
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { getElementSpec } from "./getElementSpec";
package/src/utils/set.ts DELETED
@@ -1,20 +0,0 @@
1
- export const setsToMap = <T>(value: T, ...sets: Set<string>[]) =>
2
- new Map(
3
- sets
4
- .reduce<string[]>((acc, set) => [...acc, ...set], [])
5
- .map((key) => [key, value]),
6
- );
7
-
8
- export const addToSet = (set: Set<string>, ...keys: string[]): Set<string> => {
9
- const result = new Set(set);
10
- keys.forEach((key) => set.add(key));
11
- return result;
12
- };
13
-
14
- export const unionSets = (
15
- setA: Set<string>,
16
- setB: Set<string>,
17
- ): Set<string> => {
18
- const set = new Set(...setA, ...setB);
19
- return set;
20
- };
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
4
- "module": "commonjs" /* Specify what module code is generated. */,
5
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
6
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
7
- "strict": true,
8
- "skipLibCheck": true
9
- }
10
- }
package/tsup.config.ts DELETED
@@ -1,11 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: ["src/index.ts"],
5
- format: ["esm", "cjs"],
6
- splitting: false,
7
- sourcemap: true,
8
- clean: true,
9
- dts: true,
10
- outDir: "dist",
11
- });