@wix/validation-infra 0.0.0-stage → 0.5.1

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 (152) hide show
  1. package/README.md +192 -2
  2. package/dist/constants.d.ts +29 -0
  3. package/dist/constants.js +45 -0
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.js +13 -0
  6. package/dist/package-readers/constants.d.ts +6 -0
  7. package/dist/package-readers/constants.js +6 -0
  8. package/dist/package-readers/index.d.ts +1 -0
  9. package/dist/package-readers/index.js +1 -0
  10. package/dist/package-readers/read-from-files.d.ts +6 -0
  11. package/dist/package-readers/read-from-files.js +76 -0
  12. package/dist/package-readers/types.d.ts +7 -0
  13. package/dist/package-readers/types.js +1 -0
  14. package/dist/package-readers/utils.d.ts +4 -0
  15. package/dist/package-readers/utils.js +15 -0
  16. package/dist/page-model/build-page-model.d.ts +3 -0
  17. package/dist/page-model/build-page-model.js +12 -0
  18. package/dist/page-model/connect-css.d.ts +3 -0
  19. package/dist/page-model/connect-css.js +43 -0
  20. package/dist/page-model/constants.d.ts +17 -0
  21. package/dist/page-model/constants.js +17 -0
  22. package/dist/page-model/css-selectors.d.ts +2 -0
  23. package/dist/page-model/css-selectors.js +7 -0
  24. package/dist/page-model/index.d.ts +4 -0
  25. package/dist/page-model/index.js +4 -0
  26. package/dist/page-model/pages.d.ts +2 -0
  27. package/dist/page-model/pages.js +18 -0
  28. package/dist/page-model/read-css.d.ts +4 -0
  29. package/dist/page-model/read-css.js +98 -0
  30. package/dist/page-model/read-structure.d.ts +3 -0
  31. package/dist/page-model/read-structure.js +59 -0
  32. package/dist/page-model/read-theme.d.ts +6 -0
  33. package/dist/page-model/read-theme.js +14 -0
  34. package/dist/page-model/types.d.ts +92 -0
  35. package/dist/page-model/types.js +1 -0
  36. package/dist/page-model/utils.d.ts +16 -0
  37. package/dist/page-model/utils.js +29 -0
  38. package/dist/project-model/index.d.ts +5 -0
  39. package/dist/project-model/index.js +5 -0
  40. package/dist/project-model/menu-files.d.ts +4 -0
  41. package/dist/project-model/menu-files.js +14 -0
  42. package/dist/project-model/package-json.d.ts +5 -0
  43. package/dist/project-model/package-json.js +27 -0
  44. package/dist/project-model/popups.d.ts +4 -0
  45. package/dist/project-model/popups.js +12 -0
  46. package/dist/project-model/project-model.d.ts +4 -0
  47. package/dist/project-model/project-model.js +14 -0
  48. package/dist/project-model/types.d.ts +20 -0
  49. package/dist/project-model/types.js +2 -0
  50. package/dist/rules/index.d.ts +4 -0
  51. package/dist/rules/index.js +5 -0
  52. package/dist/rules/project/define-project-rule.d.ts +5 -0
  53. package/dist/rules/project/define-project-rule.js +4 -0
  54. package/dist/rules/project/index.d.ts +2 -0
  55. package/dist/rules/project/index.js +2 -0
  56. package/dist/rules/project/types.d.ts +16 -0
  57. package/dist/rules/project/types.js +1 -0
  58. package/dist/rules/site-app/define-rule.d.ts +5 -0
  59. package/dist/rules/site-app/define-rule.js +4 -0
  60. package/dist/rules/site-app/index.d.ts +2 -0
  61. package/dist/rules/site-app/index.js +1 -0
  62. package/dist/rules/site-app/types.d.ts +26 -0
  63. package/dist/rules/site-app/types.js +1 -0
  64. package/dist/rules/site-code/define-site-code-rule.d.ts +5 -0
  65. package/dist/rules/site-code/define-site-code-rule.js +4 -0
  66. package/dist/rules/site-code/index.d.ts +2 -0
  67. package/dist/rules/site-code/index.js +2 -0
  68. package/dist/rules/site-code/types.d.ts +11 -0
  69. package/dist/rules/site-code/types.js +1 -0
  70. package/dist/rules/types.d.ts +13 -0
  71. package/dist/rules/types.js +3 -0
  72. package/dist/rules-adapter/eslint/index.d.ts +1 -0
  73. package/dist/rules-adapter/eslint/index.js +1 -0
  74. package/dist/rules-adapter/eslint/types.d.ts +5 -0
  75. package/dist/rules-adapter/eslint/types.js +1 -0
  76. package/dist/rules-adapter/index.d.ts +2 -0
  77. package/dist/rules-adapter/index.js +2 -0
  78. package/dist/rules-adapter/types.d.ts +16 -0
  79. package/dist/rules-adapter/types.js +1 -0
  80. package/dist/rules-adapter/utils.d.ts +7 -0
  81. package/dist/rules-adapter/utils.js +20 -0
  82. package/dist/rules-api/component-catalog.d.ts +8 -0
  83. package/dist/rules-api/component-catalog.js +28 -0
  84. package/dist/rules-api/constants.d.ts +7 -0
  85. package/dist/rules-api/constants.js +7 -0
  86. package/dist/rules-api/index.d.ts +18 -0
  87. package/dist/rules-api/index.js +14 -0
  88. package/dist/rules-api/report.d.ts +8 -0
  89. package/dist/rules-api/report.js +13 -0
  90. package/dist/rules-api/rules-api.d.ts +13 -0
  91. package/dist/rules-api/rules-api.js +139 -0
  92. package/dist/rules-api/types.d.ts +141 -0
  93. package/dist/rules-api/types.js +1 -0
  94. package/dist/rules-api/utils.d.ts +14 -0
  95. package/dist/rules-api/utils.js +27 -0
  96. package/dist/shared/constants.d.ts +188 -0
  97. package/dist/shared/constants.js +242 -0
  98. package/dist/shared/css-variables.d.ts +9 -0
  99. package/dist/shared/css-variables.js +38 -0
  100. package/dist/shared/css.d.ts +78 -0
  101. package/dist/shared/css.js +426 -0
  102. package/dist/shared/element-match.d.ts +16 -0
  103. package/dist/shared/element-match.js +72 -0
  104. package/dist/shared/font-weights.d.ts +2 -0
  105. package/dist/shared/font-weights.js +551 -0
  106. package/dist/shared/index.d.ts +16 -0
  107. package/dist/shared/index.js +15 -0
  108. package/dist/shared/interactions-config.d.ts +15 -0
  109. package/dist/shared/interactions-config.js +120 -0
  110. package/dist/shared/links.d.ts +21 -0
  111. package/dist/shared/links.js +93 -0
  112. package/dist/shared/posix-path.d.ts +8 -0
  113. package/dist/shared/posix-path.js +27 -0
  114. package/dist/shared/site-files-tree-mapping.d.ts +40 -0
  115. package/dist/shared/site-files-tree-mapping.js +41 -0
  116. package/dist/shared/site-folders.d.ts +3 -0
  117. package/dist/shared/site-folders.js +17 -0
  118. package/dist/shared/site-media.d.ts +3 -0
  119. package/dist/shared/site-media.js +11 -0
  120. package/dist/shared/syntax-tree.d.ts +4 -0
  121. package/dist/shared/syntax-tree.js +30 -0
  122. package/dist/shared/transformation-values.d.ts +22 -0
  123. package/dist/shared/transformation-values.js +74 -0
  124. package/dist/shared/types.d.ts +477 -0
  125. package/dist/shared/types.js +1 -0
  126. package/dist/shared/utils.d.ts +155 -0
  127. package/dist/shared/utils.js +553 -0
  128. package/dist/shared/wrapper-contract.d.ts +31 -0
  129. package/dist/shared/wrapper-contract.js +157 -0
  130. package/dist/shared/wrapper-image-props.d.ts +3 -0
  131. package/dist/shared/wrapper-image-props.js +75 -0
  132. package/dist/site-code-model/constants.d.ts +107 -0
  133. package/dist/site-code-model/constants.js +102 -0
  134. package/dist/site-code-model/index.d.ts +3 -0
  135. package/dist/site-code-model/index.js +4 -0
  136. package/dist/site-code-model/manifest-values.d.ts +15 -0
  137. package/dist/site-code-model/manifest-values.js +88 -0
  138. package/dist/site-code-model/read-module.d.ts +4 -0
  139. package/dist/site-code-model/read-module.js +267 -0
  140. package/dist/site-code-model/read-site-code-model.d.ts +9 -0
  141. package/dist/site-code-model/read-site-code-model.js +42 -0
  142. package/dist/site-code-model/source-locations.d.ts +5 -0
  143. package/dist/site-code-model/source-locations.js +95 -0
  144. package/dist/site-code-model/types.d.ts +102 -0
  145. package/dist/site-code-model/types.js +1 -0
  146. package/dist/testing.d.ts +24 -0
  147. package/dist/testing.js +61 -0
  148. package/dist/types.d.ts +95 -0
  149. package/dist/types.js +1 -0
  150. package/dist/validate.d.ts +7 -0
  151. package/dist/validate.js +180 -0
  152. package/package.json +59 -3
@@ -0,0 +1,188 @@
1
+ import type { ContractVars, ElementType, ImportKind, ReadMode } from './types.ts';
2
+ /** Any section: rules that don't care which one. */
3
+ export declare const SECTIONS: readonly ElementType[];
4
+ /** A page's reference to a global component (`<HeaderSection_x sharedCompId="…" />`). */
5
+ export declare const GLOBAL_SECTIONS: readonly ElementType[];
6
+ /** A tag that wraps one component and isn't one itself: `<Remove when={…}>`, `<Interaction interactKey="…">`, `<PinnedToScreen>` (the import drops it),
7
+ * and a context provider (`<CmsProvider_books>`: the import makes it a context of the component it wraps). */
8
+ export declare const WRAPPERS: readonly ElementType[];
9
+ /** The interactions packages, which the import reserves: structure.jsx imports nothing from them. Matched by source, not by name: `Interact` from @site/site-code is the site's own. */
10
+ export declare const INTERACTIONS_PACKAGES: readonly ImportKind[];
11
+ /** The name a structure file exports its tree under: `export const Structure = () => (…)`. */
12
+ export declare const STRUCTURE = "Structure";
13
+ /** The props a global component's Structure may take: its instance identity, `({ id, className })` (#300). */
14
+ export declare const INSTANCE_PROPS: readonly string[];
15
+ /** The system components package: `Page`, the sections, `InternalContainer`. */
16
+ export declare const SYSTEM_PACKAGE = "@wix/origami-system-components";
17
+ /** The runtime package: the builders (`ctx`, `fn`…) and the `<Remove>` wrapper. */
18
+ export declare const RUNTIME_PACKAGE = "@wix/origami-runtime";
19
+ /** The scope the export imports a component's wrapper from: `@origami-wrappers/<app>/<folder>`. */
20
+ export declare const WRAPPERS_SCOPE = "@origami-wrappers";
21
+ /** The typed builders (converter 0.76, PRIMITIVE_DATA_TYPES): `email('a@b.c')` is a fixed value of that type, like a literal. */
22
+ export declare const TYPED_BUILDERS: string[];
23
+ /** The builders whose second argument is a callback, `map(source, (item) => ({…}))` (astValue.ts TRANSFORM_CALLBACKS). */
24
+ export declare const TRANSFORM_BUILDERS: string[];
25
+ /** The runtime's builders: the converter's BINDINGS_BUILDER_ORDER without `Remove`, which is a tag (reservedAttributes.ts); `map`, `shape` and `callback` since converter 0.82–0.86. */
26
+ export declare const BUILDERS: string[];
27
+ /** The six builders no other package exports under these names; `email`, `regex`… may well come from a library for fn(). */
28
+ export declare const RUNTIME_ONLY_BUILDERS: string[];
29
+ /** The attributes the converter reads on any component as something other than its data (reservedAttributes.ts RESERVED_ATTRIBUTES, converter 0.98: `type` is data since 0.81, `slot` since 0.87, `props` since 0.97). */
30
+ export declare const RESERVED_ATTRIBUTES: readonly string[];
31
+ /** The attribute of a page's reference to a global component (SHARED_COMP_ID_ATTR); on any other tag it's data. */
32
+ export declare const SHARED_COMP_ID = "sharedCompId";
33
+ /** The keys of an elementProps entry the converter reads as something other than the part's data (RESERVED_INNER_ELEMENT_ENTRY_KEYS, converter 0.98: `slots` is data since 0.87). */
34
+ export declare const RESERVED_ENTRY_KEYS: readonly string[];
35
+ /** A data key is a JavaScript name (dataKeys.ts). */
36
+ export declare const DATA_KEY: RegExp;
37
+ /** An attribute the import reads as a React event, never as data: `on` in any case (dataKeys.ts REACT_EVENT_ATTR_PATTERN, converter 0.87). */
38
+ export declare const EVENT_ATTRIBUTE: RegExp;
39
+ /** A callback prop, which the runtime hands a function: `on` and a capital letter, `onClick` but not `onclick` (the runtime's withOrigami.tsx). */
40
+ export declare const CALLBACK_PROP: RegExp;
41
+ /** The attributes that hold an element's layers: drawn behind it, and pinned to it (a container's pinnedLayer, the Page's viewportLayer). */
42
+ export declare const LAYER_ATTRIBUTES: readonly string[];
43
+ /** The attribute that holds the elements of a component's inner parts: `elementProps={{ panel: { content: <X /> } }}`. */
44
+ export declare const ELEMENT_PROPS = "elementProps";
45
+ /** The media identifiers the export writes: an image's (`wix:image://v1/<uri>/<name>#originWidth=…`), a document's (`wix:document://v1/ugd/<file>/<name>`),
46
+ * an audio's (`wix:audio://v1/<uri>/<name>#duration=<seconds>`, converter 0.112). */
47
+ export declare const IMAGE_PREFIX = "wix:image://v1/";
48
+ export declare const DOCUMENT_PREFIX = "wix:document://v1/";
49
+ export declare const AUDIO_PREFIX = "wix:audio://v1/";
50
+ /** What a tag is, by its import source; the wrappers also by the imported name, since their packages export other things (`Show`, `Interact`). */
51
+ export declare const TYPE_BY_IMPORT_SOURCE: ReadonlyArray<[RegExp, ElementType, string?]>;
52
+ /** What an import's source is, by its source. */
53
+ export declare const KIND_BY_IMPORT_SOURCE: ReadonlyArray<[RegExp, ImportKind]>;
54
+ /** A page's reference to the global header or footer: its folder is `Header_<id>` / `Footer_<id>`. Not `HeaderSection_<id>`, which the import reads as any other global section. */
55
+ export declare const GLOBAL_SECTION_MODULE_SOURCE: RegExp;
56
+ /** The tags the import reads as the DM's own components ('document') or a global component's reference (identity.ts identityOfTag): no data attributes.
57
+ * An UnsupportedWidgetPlaceholder keeps its attributes as written, its data only in `data={…}` (converter 0.91, parseJsx.ts namespaceAttrs). */
58
+ export declare const NO_DATA_TYPES: readonly ElementType[];
59
+ /** The node types an element inside isn't read by the import (isReadByImport): a function other than Structure, a call, a condition. */
60
+ export declare const NOT_READ_IN_TYPES: readonly string[];
61
+ export declare const FULL_READ: ReadMode;
62
+ export declare const PLAIN_READ: ReadMode;
63
+ /** The `media` methods the export writes a media reference with. */
64
+ export declare const IMAGE_URL_METHOD = "getCroppedImageUrl";
65
+ export declare const DOCUMENT_URL_METHOD = "getDocumentUrl";
66
+ export declare const AUDIO_URL_METHOD = "getAudioUrl";
67
+ /** Not a value the code writes out: what getDataValue gives for an element, a variable, a call, a key that isn't a name or a string. */
68
+ export declare const NOT_A_VALUE: unique symbol;
69
+ /** The `@layer` the export writes at the top of every CSS file (the spx preamble); the import skips it. */
70
+ export declare const PREAMBLE_LAYER = "spx-preamble";
71
+ /** The at-rules the import reads as a breakpoint block: `@media`, and `@scope (.owner) { @media … }`. */
72
+ export declare const BREAKPOINT_AT_RULES: readonly string[];
73
+ /** The `@origami-target` blocks a layout rule can hold, an InternalContainer's inner wrappers (the converter's LAYOUT_TARGETS): its
74
+ * content wrapper (the container's layout) and its overflow wrapper (its scrolling). */
75
+ export declare const CONTENT_TARGET = "internal-container-content-wrapper";
76
+ export declare const OVERFLOW_TARGET = "internal-container-overflow-wrapper";
77
+ export declare const ORIGAMI_TARGETS: readonly string[];
78
+ /** The import's mixin id and `@apply` target: `--` and no space (astParser.ts `MIXIN_ID_PATTERN`). */
79
+ export declare const DASHED_ID: RegExp;
80
+ export declare const SCOPE_OWNER: RegExp;
81
+ /** The import's identifier (cssSelectors.ts `SAFE_CSS_IDENT`: `^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$`), written so it can't backtrack: the same strings. */
82
+ export declare const CSS_IDENT: RegExp;
83
+ /** Names the import refuses as an identifier: they'd be an object's own keys (cssSelectors.ts `RESERVED_OBJECT_KEYS`). */
84
+ export declare const RESERVED_IDENTIFIERS: ReadonlySet<string>;
85
+ /** A CSS name: letters, digits, `-`, `_`, any non-ASCII letter, and escapes (`\:`, `\31 `). */
86
+ export declare const CSS_NAME: RegExp;
87
+ export declare const BASE_CLASS: RegExp;
88
+ /** A type selector at a part's start, `a` (selectorSyntax.ts TYPE_PATTERN:35, read at a part's start only, :148, converter 0.103.0). */
89
+ export declare const TYPE_SELECTOR: RegExp;
90
+ export declare const FUNCTIONAL_PSEUDO: RegExp;
91
+ /** A class after the first: a state (`&.onSale`). */
92
+ export declare const STATE_CLASS: RegExp;
93
+ /** A class after a type selector, read as an identifier (selectorSyntax.ts identAt:43, IDENT_PATTERN:34, converter 0.103.0): `a.link#x` stops at `#x`. */
94
+ export declare const TYPE_CLASS: RegExp;
95
+ export declare const PSEUDO_CLASS: RegExp;
96
+ export declare const ATTRIBUTE_SELECTOR: RegExp;
97
+ /** An attribute an earlier converter wrote as a part of its own, which no contract's part is: a state (`[data-state~=…]`, before 0.74) or an
98
+ * inner part (`[data-ie-name=…]`, before 0.71). A part that starts with one isn't read. */
99
+ export declare const LEGACY_ATTRIBUTE: RegExp;
100
+ /** A theme font token: `--wst-heading-1-font`. */
101
+ export declare const THEME_FONT_TOKEN: RegExp;
102
+ export declare const FONT_SIZE: RegExp;
103
+ /** A number weight in a `font` shorthand: before the size, only the weight is a bare number. */
104
+ export declare const FONT_WEIGHT_NUMBER: RegExp;
105
+ /** A named breakpoint, `(--tablet)`: one dashed name in parentheses, spaces aside. */
106
+ export declare const NAMED_QUERY: RegExp;
107
+ /** `var(--name, <fallback>)`: a field connected to one of the site's layout variables, written with the field's own value as the fallback; the
108
+ * name is the import's identifier (CSS_IDENT_PATTERN, written as CSS_IDENT so it can't backtrack). */
109
+ export declare const LAYOUT_VARIABLE_TOKEN: RegExp;
110
+ /** The spx context: the reference an element's or the theme's `--spx()` sizes scale by (spxTransformer.ts SPX_PROPS), and the resolvers it takes. */
111
+ export declare const SPX_PROPS: readonly string[];
112
+ export declare const SPX_RESOLVER_TYPES: readonly string[];
113
+ /** A layout rule's selector, as the import reads one: one element's class. */
114
+ export declare const LAYOUT_CLASS_SELECTOR: RegExp;
115
+ /** The names a layout variable can't take, without their `--`: the layout's and the spx context's own custom properties (layoutVariables.ts RESERVED_NAMES). */
116
+ export declare const RESERVED_VARIABLE_NAMES: readonly string[];
117
+ /** The reserved attributes the import reads as data: the component's `data` and its inner parts' `elementProps`. */
118
+ export declare const RESERVED_DATA_ATTRIBUTES: readonly string[];
119
+ /** The names the import never reads as data (dataKeys.ts). The React name is joined as the converter does: Wix Standards fails the build on it in any file. */
120
+ export declare const EXCLUDED_DATA_KEYS: readonly string[];
121
+ /** The devices a <Page>'s `pageBackgrounds` holds a setting for (DM data schemas.json Page). */
122
+ export declare const PAGE_BACKGROUND_DEVICES: readonly string[];
123
+ /** A global header's or footer's top element, which takes the instance's `id={id} className={className}` (`<Header>`, `<Footer>`). */
124
+ export declare const LANDMARKS: readonly ElementType[];
125
+ /** A `className` term for a visibility: the viewer's utility class (reservedAttributes.ts CLASS_NAME_UTILITIES), which the runtime leaves as is
126
+ * (origami-runtime classNames.ts term:10): not a state. */
127
+ export declare const VISIBILITY_PREFIX = "wix-visibility-";
128
+ export declare const QUANTITY: RegExp;
129
+ export declare const CSS_FUNCTION_LIST: RegExp;
130
+ export declare const CSS_FUNCTION: RegExp;
131
+ /** The units of a length (lengthOfCss, :95: CSS_UNITS, :60); a plain 0 is a length too. */
132
+ export declare const LENGTH_UNITS: readonly string[];
133
+ /** The units of an angle (degreesOfCss, :103: DEGREES_PER_UNIT, :73); a plain 0 is no angle. */
134
+ export declare const ANGLE_UNITS: readonly string[];
135
+ /** The z-index of each zLayer (Z_INDEXES, :71). */
136
+ export declare const Z_INDEXES: readonly string[];
137
+ /** The filter's functions in the order the import reads them, and each one's unit (FILTER_UNITS, :262). */
138
+ export declare const FILTER_UNITS: Readonly<Record<string, string>>;
139
+ /** A segment's type and first class, or the attributes it starts with, all of them: 'a.link.open' → 'a.link'; '.label.open' → '.label';
140
+ * '[data-hook~="comment-box"]:hover' → '[data-hook~="comment-box"]'; '[data-hook~="comment-box"][data-x]' → both (PostComments' parts: converter
141
+ * 0.107 matches a part with its attributes, and refuses one beyond the part's own as a token no owner has); a `]` in a quoted value, or one escaped, ends none. */
142
+ export declare const ELEMENT_SELECTOR: RegExp;
143
+ /** @deprecated Use splitAtCombinators: this one has no capture group, so a `split` at it loses the combinators. Kept as 0.1.7 published it: a
144
+ * combinator between compounds, or an attribute, matched whole so its `~=` is no combinator (`[data-hook~="comment-box"]`). */
145
+ export declare const COMBINATOR: RegExp;
146
+ /** The comment that lists the overrides starts with this. */
147
+ export declare const ALLOWED_MARKER = "Allowed CSS overrides";
148
+ export declare const CONTRACT_BLOCK: RegExp;
149
+ /** A property at a line's start. Horizontal whitespace only before it, so a run of blank lines can't be rescanned from each line (quadratic);
150
+ * any whitespace before its colon, a line break too, as origami-lint master read it (`^\s*(…)\s*:` finds the same properties). */
151
+ export declare const CONTRACT_PROPERTY: RegExp;
152
+ /** A nested component's text line: '.button.hamburger-close-button: a wixEditorElements.Button; its overrides are in …'. */
153
+ export declare const NESTED_COMPONENT: RegExp;
154
+ /** The wrapper's JSON contract, next to its defaults.css: the app package exports it next to each wrapper. */
155
+ export declare const COMPONENT_CONTRACT_JSON = "component-contract.json";
156
+ /** A contract with no vars: a defaults.css, or a nested type without a contract. */
157
+ export declare const NO_CONTRACT_VARS: ContractVars;
158
+ /** The keys a typeless link may have (projectData.ts LINK_PROPERTIES). */
159
+ export declare const LINK_KEYS: readonly string[];
160
+ /** A rich text value, whose links are the <a> tags of its html (projectData.ts rebuildRichText). */
161
+ export declare const RICH_TEXT_TYPE = "Builder.RichText";
162
+ /** An <a> tag and its attributes, as rebuildRichText reads them. */
163
+ export declare const A_TAG: RegExp;
164
+ export declare const LINK_HTML_ATTRIBUTE: RegExp;
165
+ /** The entities lodash's unescape decodes, as rebuildRichText reads an attribute. */
166
+ export declare const LINK_HTML_ENTITIES: Record<string, string>;
167
+ /** Where defineComponent stores its props and ref-element props. */
168
+ export declare const DEFINITION_GROUPS: readonly [readonly ["props", readonly []], readonly ["elements", readonly ["elementProps"]]];
169
+ export declare const REMOTE_MEDIA: RegExp;
170
+ /** Names the runtime and the build write, which no theme declares: the spx context, the build's (origami-transforms: --origami-*,
171
+ * --sticky-offset, --divider-*), Wix's (--wix-*) and the editor components' container unit (--one-unit: 1cqw). The layout's own properties
172
+ * (format-spec § 6.1's reserved names) are RESERVED_VARIABLE_NAMES. */
173
+ export declare const RUNTIME_VARIABLE: RegExp;
174
+ /** A quoted string in a CSS value, `"…"` or `'…'`. The import parses a value with csstree (cssVariableReconciliation.ts
175
+ * parseCssVariableReferences), where a string is text, never a var(). */
176
+ export declare const QUOTED_STRING: RegExp;
177
+ /** A `style="…"` (or `style='…'`) attribute of an html tag. */
178
+ export declare const STYLE_ATTRIBUTE: RegExp;
179
+ /** A `var(--name)` that closes right after the name: with a `,` the browser has a fallback to use when the variable is missing. */
180
+ export declare const VAR_WITHOUT_FALLBACK: RegExp;
181
+ /** bindings/componentClass.ts COMPONENT_SELECTOR: a selector that names one component by its class. */
182
+ export declare const COMPONENT_SELECTOR: RegExp;
183
+ /** A descendant's state effect, `.<owner> .<descendant>` (converter 0.106 bindings/componentClass.ts:3 DESCENDANT_SELECTOR). */
184
+ export declare const DESCENDANT_SELECTOR: RegExp;
185
+ /** The style properties the import reads as the state's transformations (converter transformations.ts PROPERTY_FIELDS, and `rotate` beside
186
+ * a transform, assertViewerRotate), not as the component's CSS: interactions-state-values checks their values. */
187
+ export declare const TRANSFORMATIONS: readonly ["transform", "rotate", "transform-origin", "filter", "opacity", "visibility", "z-index"];
188
+ export declare const TRANSFORMATION_PROPERTIES: readonly string[];
@@ -0,0 +1,242 @@
1
+ // The constants more than one part reads: the groups of element types, the packages' names, and what the converter reserves on a tag (reservedAttributes.ts);
2
+ // how utils.ts tells a tag and an import apart, and what a data value reads; and what css.ts reads in one CSS file, as the import reads it.
3
+ // A rule imports them from rules-api/index.ts; a part from here.
4
+ import { GLOBAL_COMPONENTS, GLOBAL_MENUS } from "./site-files-tree-mapping.js";
5
+ /** Any section: rules that don't care which one. */
6
+ export const SECTIONS = ['section', 'header', 'footer'];
7
+ /** A page's reference to a global component (`<HeaderSection_x sharedCompId="…" />`). */
8
+ export const GLOBAL_SECTIONS = ['globalHeader', 'globalFooter', 'globalSection'];
9
+ /** A tag that wraps one component and isn't one itself: `<Remove when={…}>`, `<Interaction interactKey="…">`, `<PinnedToScreen>` (the import drops it),
10
+ * and a context provider (`<CmsProvider_books>`: the import makes it a context of the component it wraps). */
11
+ export const WRAPPERS = ['remove', 'interaction', 'pinnedToScreen', 'provider'];
12
+ /** The interactions packages, which the import reserves: structure.jsx imports nothing from them. Matched by source, not by name: `Interact` from @site/site-code is the site's own. */
13
+ export const INTERACTIONS_PACKAGES = ['interactReact', 'interact', 'motionPresets'];
14
+ /** The name a structure file exports its tree under: `export const Structure = () => (…)`. */
15
+ export const STRUCTURE = 'Structure';
16
+ /** The props a global component's Structure may take: its instance identity, `({ id, className })` (#300). */
17
+ export const INSTANCE_PROPS = ['id', 'className'];
18
+ /** The system components package: `Page`, the sections, `InternalContainer`. */
19
+ export const SYSTEM_PACKAGE = '@wix/origami-system-components';
20
+ /** The runtime package: the builders (`ctx`, `fn`…) and the `<Remove>` wrapper. */
21
+ export const RUNTIME_PACKAGE = '@wix/origami-runtime';
22
+ /** The interactions package's React entry: the `<Interaction>` wrapper. */
23
+ const INTERACT_REACT_PACKAGE = '@wix/interact/react';
24
+ /** The scope the export imports a component's wrapper from: `@origami-wrappers/<app>/<folder>`. */
25
+ export const WRAPPERS_SCOPE = '@origami-wrappers';
26
+ /** The typed builders (converter 0.76, PRIMITIVE_DATA_TYPES): `email('a@b.c')` is a fixed value of that type, like a literal. */
27
+ export const TYPED_BUILDERS = ['textEnum', 'phone', 'email', 'webUrl', 'hostname', 'regex', 'guid', 'direction', 'localDate', 'localTime', 'localDateTime', 'dateTime'];
28
+ /** The builders whose second argument is a callback, `map(source, (item) => ({…}))` (astValue.ts TRANSFORM_CALLBACKS). */
29
+ export const TRANSFORM_BUILDERS = ['map', 'shape'];
30
+ /** The runtime's builders: the converter's BINDINGS_BUILDER_ORDER without `Remove`, which is a tag (reservedAttributes.ts); `map`, `shape` and `callback` since converter 0.82–0.86. */
31
+ export const BUILDERS = [
32
+ 'all', 'ctx', 'fn', 'is', 'raw', 'state', 'map', 'shape', 'callback',
33
+ ...TYPED_BUILDERS,
34
+ ];
35
+ /** The six builders no other package exports under these names; `email`, `regex`… may well come from a library for fn(). */
36
+ export const RUNTIME_ONLY_BUILDERS = ['all', 'ctx', 'fn', 'is', 'raw', 'state'];
37
+ /** The attributes the converter reads on any component as something other than its data (reservedAttributes.ts RESERVED_ATTRIBUTES, converter 0.98: `type` is data since 0.81, `slot` since 0.87, `props` since 0.97). */
38
+ export const RESERVED_ATTRIBUTES = [
39
+ 'id', '_id', 'data', 'skin', 'styleId', 'className', 'documentType', 'style', 'bindings', 'elementProps',
40
+ ];
41
+ /** The attribute of a page's reference to a global component (SHARED_COMP_ID_ATTR); on any other tag it's data. */
42
+ export const SHARED_COMP_ID = 'sharedCompId';
43
+ /** The keys of an elementProps entry the converter reads as something other than the part's data (RESERVED_INNER_ELEMENT_ENTRY_KEYS, converter 0.98: `slots` is data since 0.87). */
44
+ export const RESERVED_ENTRY_KEYS = ['data', 'elementProps', 'bindings', 'className'];
45
+ /** A data key is a JavaScript name (dataKeys.ts). */
46
+ export const DATA_KEY = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
47
+ /** An attribute the import reads as a React event, never as data: `on` in any case (dataKeys.ts REACT_EVENT_ATTR_PATTERN, converter 0.87). */
48
+ export const EVENT_ATTRIBUTE = /^on/i;
49
+ /** A callback prop, which the runtime hands a function: `on` and a capital letter, `onClick` but not `onclick` (the runtime's withOrigami.tsx). */
50
+ export const CALLBACK_PROP = /^on[A-Z]/;
51
+ /** The attributes that hold an element's layers: drawn behind it, and pinned to it (a container's pinnedLayer, the Page's viewportLayer). */
52
+ export const LAYER_ATTRIBUTES = ['backgroundLayer', 'pinnedLayer', 'viewportLayer'];
53
+ /** The attribute that holds the elements of a component's inner parts: `elementProps={{ panel: { content: <X /> } }}`. */
54
+ export const ELEMENT_PROPS = 'elementProps';
55
+ /** The media identifiers the export writes: an image's (`wix:image://v1/<uri>/<name>#originWidth=…`), a document's (`wix:document://v1/ugd/<file>/<name>`),
56
+ * an audio's (`wix:audio://v1/<uri>/<name>#duration=<seconds>`, converter 0.112). */
57
+ export const IMAGE_PREFIX = 'wix:image://v1/';
58
+ export const DOCUMENT_PREFIX = 'wix:document://v1/';
59
+ export const AUDIO_PREFIX = 'wix:audio://v1/';
60
+ // ── a tag and an import, by source (utils.ts) ──
61
+ /** What a tag is, by its import source; the wrappers also by the imported name, since their packages export other things (`Show`, `Interact`). */
62
+ export const TYPE_BY_IMPORT_SOURCE = [
63
+ [new RegExp(`^${SYSTEM_PACKAGE}/Page$`), 'page'],
64
+ [new RegExp(`^${SYSTEM_PACKAGE}/Header$`), 'headerLandmark'],
65
+ [new RegExp(`^${SYSTEM_PACKAGE}/Footer$`), 'footerLandmark'],
66
+ [new RegExp(`^${SYSTEM_PACKAGE}/PinnedToScreen$`), 'pinnedToScreen'],
67
+ [new RegExp(`^${SYSTEM_PACKAGE}/UnsupportedWidgetPlaceholder$`), 'unsupportedWidget'],
68
+ [new RegExp(`^${SYSTEM_PACKAGE}/Section$`), 'section'],
69
+ [new RegExp(`^${SYSTEM_PACKAGE}/HeaderSection$`), 'header'],
70
+ [new RegExp(`^${SYSTEM_PACKAGE}/FooterSection$`), 'footer'],
71
+ [new RegExp(`^${SYSTEM_PACKAGE}/InternalContainer$`), 'innerElement'],
72
+ // The editor's containers and its background, as the export imports their wrappers.
73
+ [new RegExp(`^${WRAPPERS_SCOPE}/wixEditorElements/boxcontainer$`), 'box'],
74
+ [new RegExp(`^${WRAPPERS_SCOPE}/wixEditorElements/menu$`), 'menu'],
75
+ [new RegExp(`^${WRAPPERS_SCOPE}/wixSystemElements/background$`), 'background'],
76
+ // A global component's folder is `<Type>_<id>`: HeaderSection_mb7ogqqn.
77
+ [new RegExp(`/${GLOBAL_COMPONENTS}/(?:HeaderSection|Header)_[^/]+$`), 'globalHeader'],
78
+ [new RegExp(`/${GLOBAL_COMPONENTS}/(?:FooterSection|Footer)_[^/]+$`), 'globalFooter'],
79
+ [new RegExp(`/${GLOBAL_COMPONENTS}/[^/]+$`), 'globalSection'],
80
+ [new RegExp(`^${RUNTIME_PACKAGE}$`), 'remove', 'Remove'],
81
+ [new RegExp(`^${INTERACT_REACT_PACKAGE}$`), 'interaction', 'Interaction'],
82
+ ];
83
+ /** What an import's source is, by its source. */
84
+ export const KIND_BY_IMPORT_SOURCE = [
85
+ [new RegExp(`^${RUNTIME_PACKAGE}$`), 'runtime'],
86
+ [/^@wix\/sdk$/, 'sdk'],
87
+ [new RegExp(`^${INTERACT_REACT_PACKAGE}$`), 'interactReact'],
88
+ [/^@wix\/interact(\/|$)/, 'interact'],
89
+ [/^@wix\/motion-presets$/, 'motionPresets'],
90
+ [new RegExp(`^(\\.\\.?/)*${GLOBAL_MENUS}(/|$)`), 'menu'],
91
+ [/^document$/, 'core'],
92
+ [/^document\//, 'document'],
93
+ [new RegExp(`^${WRAPPERS_SCOPE}/`), 'wrapper'],
94
+ [/^@site\/site-code\/[^/]+$/, 'siteCode'],
95
+ ];
96
+ /** A page's reference to the global header or footer: its folder is `Header_<id>` / `Footer_<id>`. Not `HeaderSection_<id>`, which the import reads as any other global section. */
97
+ export const GLOBAL_SECTION_MODULE_SOURCE = new RegExp(`/${GLOBAL_COMPONENTS}/(Header|Footer)_[^/]+$`);
98
+ /** The tags the import reads as the DM's own components ('document') or a global component's reference (identity.ts identityOfTag): no data attributes.
99
+ * An UnsupportedWidgetPlaceholder keeps its attributes as written, its data only in `data={…}` (converter 0.91, parseJsx.ts namespaceAttrs). */
100
+ export const NO_DATA_TYPES = ['page', 'section', 'header', 'footer', 'headerLandmark', 'footerLandmark', 'pinnedToScreen', 'unsupportedWidget', ...GLOBAL_SECTIONS];
101
+ /** The node types an element inside isn't read by the import (isReadByImport): a function other than Structure, a call, a condition. */
102
+ export const NOT_READ_IN_TYPES = ['FunctionExpression', 'CallExpression', 'ConditionalExpression', 'LogicalExpression'];
103
+ // ── a data value, as the import reads it (utils.ts) ──
104
+ export const FULL_READ = { menus: true, media: true, jsx: true };
105
+ export const PLAIN_READ = {};
106
+ /** The `media` methods the export writes a media reference with. */
107
+ export const IMAGE_URL_METHOD = 'getCroppedImageUrl';
108
+ export const DOCUMENT_URL_METHOD = 'getDocumentUrl';
109
+ export const AUDIO_URL_METHOD = 'getAudioUrl';
110
+ /** Not a value the code writes out: what getDataValue gives for an element, a variable, a call, a key that isn't a name or a string. */
111
+ export const NOT_A_VALUE = Symbol('not a value');
112
+ // ── one CSS file, as the import reads it (css.ts) ──
113
+ /** The `@layer` the export writes at the top of every CSS file (the spx preamble); the import skips it. */
114
+ export const PREAMBLE_LAYER = 'spx-preamble';
115
+ /** The at-rules the import reads as a breakpoint block: `@media`, and `@scope (.owner) { @media … }`. */
116
+ export const BREAKPOINT_AT_RULES = ['media', 'scope'];
117
+ /** The `@origami-target` blocks a layout rule can hold, an InternalContainer's inner wrappers (the converter's LAYOUT_TARGETS): its
118
+ * content wrapper (the container's layout) and its overflow wrapper (its scrolling). */
119
+ export const CONTENT_TARGET = 'internal-container-content-wrapper';
120
+ export const OVERFLOW_TARGET = 'internal-container-overflow-wrapper';
121
+ export const ORIGAMI_TARGETS = [CONTENT_TARGET, OVERFLOW_TARGET];
122
+ /** The import's mixin id and `@apply` target: `--` and no space (astParser.ts `MIXIN_ID_PATTERN`). */
123
+ export const DASHED_ID = /^--(\S+)$/;
124
+ export const SCOPE_OWNER = /^\(\.([^:[\]"\s]+)\)$/;
125
+ /** The import's identifier (cssSelectors.ts `SAFE_CSS_IDENT`: `^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$`), written so it can't backtrack: the same strings. */
126
+ export const CSS_IDENT = /^-?[_a-zA-Z][_a-zA-Z0-9-]*$/;
127
+ /** Names the import refuses as an identifier: they'd be an object's own keys (cssSelectors.ts `RESERVED_OBJECT_KEYS`). */
128
+ export const RESERVED_IDENTIFIERS = new Set(['__proto__', 'constructor', 'prototype']);
129
+ /** A CSS name: letters, digits, `-`, `_`, any non-ASCII letter, and escapes (`\:`, `\31 `). */
130
+ export const CSS_NAME = /^(?:[\w-]|\P{ASCII}|\\[0-9a-fA-F]{1,6}\s?|\\[^\n0-9a-fA-F])+/u;
131
+ // cssSelectors.ts parseSegment's patterns
132
+ export const BASE_CLASS = /^\.[^:[\]"]+/;
133
+ /** A type selector at a part's start, `a` (selectorSyntax.ts TYPE_PATTERN:35, read at a part's start only, :148, converter 0.103.0). */
134
+ export const TYPE_SELECTOR = /^[a-zA-Z][a-zA-Z0-9-]*/;
135
+ export const FUNCTIONAL_PSEUDO = /^:[A-Za-z-]+\([^)]*\)/;
136
+ /** A class after the first: a state (`&.onSale`). */
137
+ export const STATE_CLASS = /^\.[^.:[\]"]+/;
138
+ /** A class after a type selector, read as an identifier (selectorSyntax.ts identAt:43, IDENT_PATTERN:34, converter 0.103.0): `a.link#x` stops at `#x`. */
139
+ export const TYPE_CLASS = /^\.-?[_a-zA-Z][_a-zA-Z0-9-]*/;
140
+ export const PSEUDO_CLASS = /^:[A-Za-z-]+/;
141
+ export const ATTRIBUTE_SELECTOR = /^\[[^\]]*\]/;
142
+ /** An attribute an earlier converter wrote as a part of its own, which no contract's part is: a state (`[data-state~=…]`, before 0.74) or an
143
+ * inner part (`[data-ie-name=…]`, before 0.71). A part that starts with one isn't read. */
144
+ export const LEGACY_ATTRIBUTE = /^\[\s*data-(?:state|ie-name)\s*[~|^$*]?=/;
145
+ /** A theme font token: `--wst-heading-1-font`. */
146
+ export const THEME_FONT_TOKEN = /^--wst-[\w-]+-font$/;
147
+ // The size in a `font` shorthand, with its optional line height: the family follows it. The number's quantifiers
148
+ // never overlap, so a long run of digits that is not a size fails in linear time.
149
+ export const FONT_SIZE = /^(?:--spx\(.*\)|calc\(.*\)|(?:\d+(?:\.\d*)?|\.\d+)(?:px|em|rem|%|vw|vh|pt)?)(?:\/\S+)?$/i;
150
+ /** A number weight in a `font` shorthand: before the size, only the weight is a bare number. */
151
+ export const FONT_WEIGHT_NUMBER = /^\d+(?:\.\d+)?$/;
152
+ /** A named breakpoint, `(--tablet)`: one dashed name in parentheses, spaces aside. */
153
+ export const NAMED_QUERY = /^\(\s*(--[\w-]+)\s*\)$/;
154
+ /** `var(--name, <fallback>)`: a field connected to one of the site's layout variables, written with the field's own value as the fallback; the
155
+ * name is the import's identifier (CSS_IDENT_PATTERN, written as CSS_IDENT so it can't backtrack). */
156
+ export const LAYOUT_VARIABLE_TOKEN = /^var\(--(-?[_a-zA-Z][_a-zA-Z0-9-]*),\s*(.+)\)$/;
157
+ /** The spx context: the reference an element's or the theme's `--spx()` sizes scale by (spxTransformer.ts SPX_PROPS), and the resolvers it takes. */
158
+ export const SPX_PROPS = ['--spx-ref-width', '--spx-resolver-type'];
159
+ export const SPX_RESOLVER_TYPES = ['scale', 'fixed'];
160
+ /** A layout rule's selector, as the import reads one: one element's class. */
161
+ export const LAYOUT_CLASS_SELECTOR = /^\.(\S+)$/;
162
+ /** The names a layout variable can't take, without their `--`: the layout's and the spx context's own custom properties (layoutVariables.ts RESERVED_NAMES). */
163
+ export const RESERVED_VARIABLE_NAMES = ['--spx-stopper-min', '--spx-stopper-max', '--content-max-width', '--content-max-width-align', '--scaling-factor', '--scrollbar-width', '--spx-width', ...SPX_PROPS].map((prop) => prop.slice('--'.length));
164
+ /** The reserved attributes the import reads as data: the component's `data` and its inner parts' `elementProps`. */
165
+ export const RESERVED_DATA_ATTRIBUTES = ['data', 'elementProps'];
166
+ /** The names the import never reads as data (dataKeys.ts). The React name is joined as the converter does: Wix Standards fails the build on it in any file. */
167
+ export const EXCLUDED_DATA_KEYS = [
168
+ '_slotsId', '_mapId', 'hidden', 'class', 'title', 'role', 'tabindex', 'draggable', 'lang', 'dir', 'accesskey', 'contenteditable', 'spellcheck',
169
+ 'translate', 'autofocus', 'inputmode', 'enterkeyhint', 'popover', 'inert', 'part', 'nonce', 'is', 'itemscope', 'itemtype', 'itemprop', 'itemid',
170
+ 'itemref', 'tabIndex', 'contentEditable', 'accessKey', 'autoFocus', 'inputMode', 'enterKeyHint', 'spellCheck', 'styleRef', 'key',
171
+ 'ref', ['dangerouslySet', 'InnerHTML'].join(''), '__proto__', 'constructor', 'prototype',
172
+ ];
173
+ /** The devices a <Page>'s `pageBackgrounds` holds a setting for (DM data schemas.json Page). */
174
+ export const PAGE_BACKGROUND_DEVICES = ['desktop', 'mobile'];
175
+ /** A global header's or footer's top element, which takes the instance's `id={id} className={className}` (`<Header>`, `<Footer>`). */
176
+ export const LANDMARKS = ['headerLandmark', 'footerLandmark'];
177
+ /** A `className` term for a visibility: the viewer's utility class (reservedAttributes.ts CLASS_NAME_UTILITIES), which the runtime leaves as is
178
+ * (origami-runtime classNames.ts term:10): not a state. */
179
+ export const VISIBILITY_PREFIX = 'wix-visibility-';
180
+ // ── a transformation's value, as the import reads it (transformation-values.ts) ──
181
+ export const QUANTITY = /^(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z%]*)$/i;
182
+ export const CSS_FUNCTION_LIST = /^\s*(?:[a-z-]+\([^()]*\)\s*)*$/i;
183
+ export const CSS_FUNCTION = /([a-z-]+)\(([^()]*)\)/gi;
184
+ /** The units of a length (lengthOfCss, :95: CSS_UNITS, :60); a plain 0 is a length too. */
185
+ export const LENGTH_UNITS = ['px', 'em', 'rem', 'vh', 'vw', '%', 'fr', 'spx'];
186
+ /** The units of an angle (degreesOfCss, :103: DEGREES_PER_UNIT, :73); a plain 0 is no angle. */
187
+ export const ANGLE_UNITS = ['deg', 'grad', 'rad', 'turn'];
188
+ /** The z-index of each zLayer (Z_INDEXES, :71). */
189
+ export const Z_INDEXES = ['1', '51', '100000'];
190
+ /** The filter's functions in the order the import reads them, and each one's unit (FILTER_UNITS, :262). */
191
+ export const FILTER_UNITS = { opacity: '%', grayscale: '%', blur: 'px' };
192
+ // ── a wrapper's allowed CSS overrides (wrapper-contract.ts) ──
193
+ /** A segment's type and first class, or the attributes it starts with, all of them: 'a.link.open' → 'a.link'; '.label.open' → '.label';
194
+ * '[data-hook~="comment-box"]:hover' → '[data-hook~="comment-box"]'; '[data-hook~="comment-box"][data-x]' → both (PostComments' parts: converter
195
+ * 0.107 matches a part with its attributes, and refuses one beyond the part's own as a token no owner has); a `]` in a quoted value, or one escaped, ends none. */
196
+ export const ELEMENT_SELECTOR = /^(?:[A-Za-z][A-Za-z0-9-]*(?:\.[\w-]+)?|\.[\w-]+|(?:\[(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\\.|[^\]"'\\])*\])+)/;
197
+ /** @deprecated Use splitAtCombinators: this one has no capture group, so a `split` at it loses the combinators. Kept as 0.1.7 published it: a
198
+ * combinator between compounds, or an attribute, matched whole so its `~=` is no combinator (`[data-hook~="comment-box"]`). */
199
+ export const COMBINATOR = /\[[^\]]*\]?|[>+~]/g;
200
+ /** The comment that lists the overrides starts with this. */
201
+ export const ALLOWED_MARKER = 'Allowed CSS overrides';
202
+ export const CONTRACT_BLOCK = /^([^{}\n]+)\{([^}]*)\}/gm;
203
+ /** A property at a line's start. Horizontal whitespace only before it, so a run of blank lines can't be rescanned from each line (quadratic);
204
+ * any whitespace before its colon, a line break too, as origami-lint master read it (`^\s*(…)\s*:` finds the same properties). */
205
+ export const CONTRACT_PROPERTY = /^[ \t]*(--[\w-]+|[a-z-]+)\s*:/gm;
206
+ /** A nested component's text line: '.button.hamburger-close-button: a wixEditorElements.Button; its overrides are in …'. */
207
+ export const NESTED_COMPONENT = /^(\.[\w.-]+): a /gm;
208
+ /** The wrapper's JSON contract, next to its defaults.css: the app package exports it next to each wrapper. */
209
+ export const COMPONENT_CONTRACT_JSON = 'component-contract.json';
210
+ /** A contract with no vars: a defaults.css, or a nested type without a contract. */
211
+ export const NO_CONTRACT_VARS = Object.freeze({ customEnums: [], customPropertyTypes: [] });
212
+ /** The keys a typeless link may have (projectData.ts LINK_PROPERTIES). */
213
+ export const LINK_KEYS = ['href', 'target', 'rel', 'pageRole'];
214
+ /** A rich text value, whose links are the <a> tags of its html (projectData.ts rebuildRichText). */
215
+ export const RICH_TEXT_TYPE = 'Builder.RichText';
216
+ /** An <a> tag and its attributes, as rebuildRichText reads them. */
217
+ export const A_TAG = /<a\b([^>]*)>/g;
218
+ export const LINK_HTML_ATTRIBUTE = /([\w-]+)=(?:"([^"]*)"|'([^']*)')/g;
219
+ /** The entities lodash's unescape decodes, as rebuildRichText reads an attribute. */
220
+ export const LINK_HTML_ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', '#39': "'" };
221
+ /** Where defineComponent stores its props and ref-element props. */
222
+ export const DEFINITION_GROUPS = [['props', []], ['elements', ['elementProps']]];
223
+ export const REMOTE_MEDIA = /^https?:\/\//i;
224
+ /** Names the runtime and the build write, which no theme declares: the spx context, the build's (origami-transforms: --origami-*,
225
+ * --sticky-offset, --divider-*), Wix's (--wix-*) and the editor components' container unit (--one-unit: 1cqw). The layout's own properties
226
+ * (format-spec § 6.1's reserved names) are RESERVED_VARIABLE_NAMES. */
227
+ export const RUNTIME_VARIABLE = /^--(?:spx-|origami-|divider-|wix-)|^--(?:sticky-offset|one-unit)$/;
228
+ /** A quoted string in a CSS value, `"…"` or `'…'`. The import parses a value with csstree (cssVariableReconciliation.ts
229
+ * parseCssVariableReferences), where a string is text, never a var(). */
230
+ export const QUOTED_STRING = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g;
231
+ /** A `style="…"` (or `style='…'`) attribute of an html tag. */
232
+ export const STYLE_ATTRIBUTE = /\sstyle=(?:"([^"]*)"|'([^']*)')/gi;
233
+ /** A `var(--name)` that closes right after the name: with a `,` the browser has a fallback to use when the variable is missing. */
234
+ export const VAR_WITHOUT_FALLBACK = /\bvar\(\s*(--[^\s,()]+)\s*\)/gi;
235
+ /** bindings/componentClass.ts COMPONENT_SELECTOR: a selector that names one component by its class. */
236
+ export const COMPONENT_SELECTOR = /^\.([^ .:>[\]]+)$/;
237
+ /** A descendant's state effect, `.<owner> .<descendant>` (converter 0.106 bindings/componentClass.ts:3 DESCENDANT_SELECTOR). */
238
+ export const DESCENDANT_SELECTOR = /^\.([^ .:>[\]]+) \.([^ .:>[\]]+)$/;
239
+ /** The style properties the import reads as the state's transformations (converter transformations.ts PROPERTY_FIELDS, and `rotate` beside
240
+ * a transform, assertViewerRotate), not as the component's CSS: interactions-state-values checks their values. */
241
+ export const TRANSFORMATIONS = ['transform', 'rotate', 'transform-origin', 'filter', 'opacity', 'visibility', 'z-index'];
242
+ export const TRANSFORMATION_PROPERTIES = [...TRANSFORMATIONS];
@@ -0,0 +1,9 @@
1
+ import type { Container, Root } from 'postcss';
2
+ /** Whether a name is one the runtime and the build write (RUNTIME_VARIABLE), or one of the layout's own (RESERVED_VARIABLE_NAMES): no theme declares it. */
3
+ export declare const isRuntimeVariable: (name: string) => boolean;
4
+ /** The site's variables: the `--name` lines of theme.css's `:root` rules, at the top level or in an at-rule like `@media`; none from a `@mixin`, a nested rule or the preamble. */
5
+ export declare function readRootVariables(theme: Root | undefined): string[];
6
+ /** Every `--name` a file, or a block of it, declares. */
7
+ export declare function readDeclaredVariables(node: Container | undefined): string[];
8
+ /** Whether a name is defined: a site variable, a runtime or layout name (isRuntimeVariable), or one in `declared` (the names the CSS around declares). With no theme.css every name is. */
9
+ export declare function createVariableCheck(theme: Root | undefined, declared: Iterable<string>): (name: string) => boolean;
@@ -0,0 +1,38 @@
1
+ import { PREAMBLE_LAYER, RESERVED_VARIABLE_NAMES, RUNTIME_VARIABLE } from "./constants.js";
2
+ import { isInsideRule } from "./css.js";
3
+ /** Whether a name is one the runtime and the build write (RUNTIME_VARIABLE), or one of the layout's own (RESERVED_VARIABLE_NAMES): no theme declares it. */
4
+ export const isRuntimeVariable = (name) => RUNTIME_VARIABLE.test(name) || (name.startsWith('--') && RESERVED_VARIABLE_NAMES.includes(name.slice('--'.length)));
5
+ /** Whether a node sits in a block of the given at-rule, through any blocks between. */
6
+ function isIn(node, test) {
7
+ for (let parent = node.parent; parent && parent.type !== 'root'; parent = parent.parent)
8
+ if (parent.type === 'atrule' && test(parent))
9
+ return true;
10
+ return false;
11
+ }
12
+ /** The site's variables: the `--name` lines of theme.css's `:root` rules, at the top level or in an at-rule like `@media`; none from a `@mixin`, a nested rule or the preamble. */
13
+ export function readRootVariables(theme) {
14
+ const names = [];
15
+ theme?.walkRules((rule) => {
16
+ if (rule.selector.trim() !== ':root' || isInsideRule(rule) || isIn(rule, ({ name, params }) => name === 'mixin' || (name === 'layer' && params.trim() === PREAMBLE_LAYER)))
17
+ return;
18
+ for (const node of rule.nodes ?? [])
19
+ if (node.type === 'decl' && node.prop.startsWith('--'))
20
+ names.push(node.prop);
21
+ });
22
+ return names;
23
+ }
24
+ /** Every `--name` a file, or a block of it, declares. */
25
+ export function readDeclaredVariables(node) {
26
+ const names = [];
27
+ node?.walkDecls(/^--/, ({ prop }) => {
28
+ names.push(prop);
29
+ });
30
+ return names;
31
+ }
32
+ /** Whether a name is defined: a site variable, a runtime or layout name (isRuntimeVariable), or one in `declared` (the names the CSS around declares). With no theme.css every name is. */
33
+ export function createVariableCheck(theme, declared) {
34
+ if (!theme)
35
+ return () => true;
36
+ const known = new Set([...readRootVariables(theme), ...declared]);
37
+ return (name) => known.has(name) || isRuntimeVariable(name);
38
+ }
@@ -0,0 +1,78 @@
1
+ import type { AtRule, ChildNode, Container, Root, Rule } from 'postcss';
2
+ import type { CssNode, CustomMedia, FontShorthand, LayoutRuleBlock, LayoutScope, RichTextStyleVariable, SelectorPlace, SelectorSegment, StyleRule, ThemeToken } from './types.ts';
3
+ /** Every `--name: value` in a file, wherever it's declared, in order. No file → none. */
4
+ export declare function readThemeTokens(file: Root | undefined): ThemeToken[];
5
+ /** The theme's font tokens (`--wst-heading-1-font: …`), as readThemeTokens reads them. */
6
+ export declare const readThemeFontTokens: (file: Root | undefined) => ThemeToken[];
7
+ /** Every `@custom-media --name (query)` at a file's top level, in order, as the import reads them; theme.css's are the site's breakpoints. No file → none. */
8
+ export declare function readCustomMedia(file: Root | undefined): CustomMedia[];
9
+ /** A `@media` query's params → the breakpoint name it uses: '(--tablet)' → '--tablet'; null for a range or anything that isn't one name. */
10
+ export declare const readBreakpointName: (query: string) => string | null;
11
+ /** A layout value as the import reads it (layoutVariables.ts literalOf): `var(--name, <fallback>)`, a field connected to one of the site's layout
12
+ * variables, by its fallback; any other value as is. */
13
+ export declare const getLayoutLiteral: (value: string) => string;
14
+ /** `var(--name, <fallback>)` → the variable's name (no `--`) and its fallback, as written; undefined for any other value (layoutVariables.ts parseLayoutVariableToken). */
15
+ export declare function readLayoutVariable(value: string): {
16
+ name: string;
17
+ fallback: string;
18
+ } | undefined;
19
+ /** A `font` shorthand's weight and family; undefined for a `var(…)` or a value with no family after its size. */
20
+ export declare function readFontShorthand(value: string): FontShorthand | undefined;
21
+ /** Whether a style rule sits inside another style rule, through any at-rules between them (`.a { .b { } }`, `.a { @media (…) { .b { } } }`). */
22
+ export declare function isInsideRule(rule: Rule): boolean;
23
+ /** style.css's rules by their selector's first class, each once, as the import reads them: a rule inside another rule or a `@mixin` is left
24
+ * out (astParser.ts parseStyleRuleAsRecords), and an empty or `@apply`-only rule, which has no line in `page.css`, is in. */
25
+ export declare function readStyleRules(file: Root | undefined): Map<string, StyleRule[]>;
26
+ /** A container's children, comments aside; none for a node with no block. */
27
+ export declare const getCssChildren: (node: Container) => CssNode[];
28
+ /** Whether a property picks a preset (css/utils.ts `isPresetProperty`): `--preset` (the rule's own element) or `--preset-<part path>`. */
29
+ export declare const isPresetProperty: (prop: string) => boolean;
30
+ /** The id a `@mixin` or `@apply` names: '--btn' → 'btn' (spaces around aside); undefined when its params aren't `--` and one word. */
31
+ export declare const getDashedId: (params: string) => string | undefined;
32
+ /** The id a `@mixin` declares (`--btn` → 'btn'), or null when it isn't one dashed identifier. */
33
+ export declare function getMixinId(mixin: AtRule): string | null;
34
+ /** Whether a `@scope` names its owner as the import reads it: `(.class)`, one element's class (css/ast/utils.ts parseScopeOwner at converter 0.97.0). */
35
+ export declare const hasScopeOwner: (scope: AtRule) => boolean;
36
+ /** Whether the import reads this as an identifier (cssSelectors.ts `isCssIdentifier`): letters, digits, - and _, not starting with a digit. */
37
+ export declare const isCssIdentifier: (id: string) => boolean;
38
+ /** Whether the import takes this as a name (a mixin id, a preset path's part; cssSelectors.ts `isSafeCssIdentifier`): an identifier, not a reserved name. */
39
+ export declare const isSafeCssIdentifier: (id: string) => boolean;
40
+ /** The selector's parts, split on spaces outside brackets and quotes, a combinator kept with its sides (cssSelectors.ts splitSegments); null for a list or an unbalanced bracket: the selectors rows'. */
41
+ export declare function getSelectorSegments(selector: string): string[] | null;
42
+ /** The selector at its combinators, each kept with the spaces around it, so the odd parts are the combinators: '.a > .b' → ['.a', ' > ', '.b'],
43
+ * as origami-lint master's split; a `>`, `+` or `~` inside an attribute, also in a quoted value, is none ('[data-hook~="x"]', '[data-label="x > [ y"]'), and so is an escaped one.
44
+ * One pass: a long selector costs no more than its length. */
45
+ export declare function splitAtCombinators(selector: string): string[];
46
+ /** A part with `&` anywhere outside brackets and quotes, as the import reads it: `&` first, the rest its states (`&&:hover` → `&:hover`,
47
+ * `.x&` → `&.x`; selectorSyntax.ts parseSelectorChain:123 at converter 0.101.0). Any other part as written. */
48
+ export declare function readAmpersands(segment: string): string;
49
+ /** A segment's base, states and what the import can't read. A functional pseudo-class (`:not(:hover)`) or an attribute (`[data-state~="open"]`)
50
+ * right after the class is part of the class; after a state, after `&` or after a type selector, it isn't read. A class right after a type
51
+ * selector is part of it (`a.link`), as a class glued to a class is; after a state it's a state (`a:hover.open`). */
52
+ export declare function readSegment(segment: string): SelectorSegment;
53
+ /** A segment's class, its states taken out: `&:hover` → `&`; `.label:hover` → `.label`; `.label.open` → `.label`; a type selector's part
54
+ * the same way (`a:hover` → `a`, `a.link:hover` → `a.link`). Null for a segment the import can't parse: a part with no class or type (`[data-ie-name="x"]`, `:hover`
55
+ * alone, `:root`), or `&` or a type followed by anything but a state (`&[x]`, `&:not(…)`, `&a`, `a[x]`). */
56
+ export declare function getSegmentClass(segment: string): string | null;
57
+ /**
58
+ * Whether a selector's first segment names a component as the import reads it (parseComponentChain, withStateClasses): its own class, the
59
+ * classes after it its state classes (`.comp-a.comp-a--open`, `.comp-a.constructor`), a safe identifier. `.comp-a[data-x]` isn't: an
60
+ * attribute is part of the class, read whole (the selectors rows').
61
+ */
62
+ export declare function hasComponentClass(segment: string): boolean;
63
+ /** layout.css's rule blocks in order, as the import reads them: at the top level, in each `@media`, and in each `@scope`'s `@media`. The preamble layer is skipped. */
64
+ export declare function readLayoutRuleBlocks(root: Root): LayoutRuleBlock[];
65
+ /** The blocks merged per element and breakpoint, the default scopes first (a breakpoint inherits the default's container type); a target's declarations join the rule's. */
66
+ export declare function mergeLayoutScopes(blocks: LayoutRuleBlock[]): LayoutScope[];
67
+ /** Whether a node sits in the `@layer spx-preamble { … }` block the export writes at the top of every file (PREAMBLE_LAYER), which the import skips. */
68
+ export declare function isInPreamble(node: ChildNode): boolean;
69
+ /** A selector's owner is its first `.x` or `#x` outside [attribute] brackets (only the first is read): '.comp-x' → '.comp-x', '&';
70
+ * '.comp-x:hover' → '.comp-x', '&:hover'; '.comp-x .label' → '.comp-x', '& .label'; '#comp-x' → '#comp-x', '&'; ':root' → null, ':root'. */
71
+ export declare function parseComponentSelector(selector: string): SelectorPlace;
72
+ /** `a\:b` → 'a:b', `\31 23` → '123': the class name an escaped selector names. */
73
+ export declare const unescapeName: (name: string) => string;
74
+ /** Each `var(--name)` without a fallback in the `style="…"` attributes of a rich text's html: unescaped, split at each `;` outside a quoted
75
+ * string and ( ) (splitDeclarations), in order. */
76
+ export declare function getRichTextStyleVariables(html: string): RichTextStyleVariable[];
77
+ /** An html attribute's value as the converter reads it (lodash unescape): the five entities it writes. */
78
+ export declare function unescapeHtml(value: string): string;