@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.
- package/README.md +192 -2
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +45 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -0
- package/dist/package-readers/constants.d.ts +6 -0
- package/dist/package-readers/constants.js +6 -0
- package/dist/package-readers/index.d.ts +1 -0
- package/dist/package-readers/index.js +1 -0
- package/dist/package-readers/read-from-files.d.ts +6 -0
- package/dist/package-readers/read-from-files.js +76 -0
- package/dist/package-readers/types.d.ts +7 -0
- package/dist/package-readers/types.js +1 -0
- package/dist/package-readers/utils.d.ts +4 -0
- package/dist/package-readers/utils.js +15 -0
- package/dist/page-model/build-page-model.d.ts +3 -0
- package/dist/page-model/build-page-model.js +12 -0
- package/dist/page-model/connect-css.d.ts +3 -0
- package/dist/page-model/connect-css.js +43 -0
- package/dist/page-model/constants.d.ts +17 -0
- package/dist/page-model/constants.js +17 -0
- package/dist/page-model/css-selectors.d.ts +2 -0
- package/dist/page-model/css-selectors.js +7 -0
- package/dist/page-model/index.d.ts +4 -0
- package/dist/page-model/index.js +4 -0
- package/dist/page-model/pages.d.ts +2 -0
- package/dist/page-model/pages.js +18 -0
- package/dist/page-model/read-css.d.ts +4 -0
- package/dist/page-model/read-css.js +98 -0
- package/dist/page-model/read-structure.d.ts +3 -0
- package/dist/page-model/read-structure.js +59 -0
- package/dist/page-model/read-theme.d.ts +6 -0
- package/dist/page-model/read-theme.js +14 -0
- package/dist/page-model/types.d.ts +92 -0
- package/dist/page-model/types.js +1 -0
- package/dist/page-model/utils.d.ts +16 -0
- package/dist/page-model/utils.js +29 -0
- package/dist/project-model/index.d.ts +5 -0
- package/dist/project-model/index.js +5 -0
- package/dist/project-model/menu-files.d.ts +4 -0
- package/dist/project-model/menu-files.js +14 -0
- package/dist/project-model/package-json.d.ts +5 -0
- package/dist/project-model/package-json.js +27 -0
- package/dist/project-model/popups.d.ts +4 -0
- package/dist/project-model/popups.js +12 -0
- package/dist/project-model/project-model.d.ts +4 -0
- package/dist/project-model/project-model.js +14 -0
- package/dist/project-model/types.d.ts +20 -0
- package/dist/project-model/types.js +2 -0
- package/dist/rules/index.d.ts +4 -0
- package/dist/rules/index.js +5 -0
- package/dist/rules/project/define-project-rule.d.ts +5 -0
- package/dist/rules/project/define-project-rule.js +4 -0
- package/dist/rules/project/index.d.ts +2 -0
- package/dist/rules/project/index.js +2 -0
- package/dist/rules/project/types.d.ts +16 -0
- package/dist/rules/project/types.js +1 -0
- package/dist/rules/site-app/define-rule.d.ts +5 -0
- package/dist/rules/site-app/define-rule.js +4 -0
- package/dist/rules/site-app/index.d.ts +2 -0
- package/dist/rules/site-app/index.js +1 -0
- package/dist/rules/site-app/types.d.ts +26 -0
- package/dist/rules/site-app/types.js +1 -0
- package/dist/rules/site-code/define-site-code-rule.d.ts +5 -0
- package/dist/rules/site-code/define-site-code-rule.js +4 -0
- package/dist/rules/site-code/index.d.ts +2 -0
- package/dist/rules/site-code/index.js +2 -0
- package/dist/rules/site-code/types.d.ts +11 -0
- package/dist/rules/site-code/types.js +1 -0
- package/dist/rules/types.d.ts +13 -0
- package/dist/rules/types.js +3 -0
- package/dist/rules-adapter/eslint/index.d.ts +1 -0
- package/dist/rules-adapter/eslint/index.js +1 -0
- package/dist/rules-adapter/eslint/types.d.ts +5 -0
- package/dist/rules-adapter/eslint/types.js +1 -0
- package/dist/rules-adapter/index.d.ts +2 -0
- package/dist/rules-adapter/index.js +2 -0
- package/dist/rules-adapter/types.d.ts +16 -0
- package/dist/rules-adapter/types.js +1 -0
- package/dist/rules-adapter/utils.d.ts +7 -0
- package/dist/rules-adapter/utils.js +20 -0
- package/dist/rules-api/component-catalog.d.ts +8 -0
- package/dist/rules-api/component-catalog.js +28 -0
- package/dist/rules-api/constants.d.ts +7 -0
- package/dist/rules-api/constants.js +7 -0
- package/dist/rules-api/index.d.ts +18 -0
- package/dist/rules-api/index.js +14 -0
- package/dist/rules-api/report.d.ts +8 -0
- package/dist/rules-api/report.js +13 -0
- package/dist/rules-api/rules-api.d.ts +13 -0
- package/dist/rules-api/rules-api.js +139 -0
- package/dist/rules-api/types.d.ts +141 -0
- package/dist/rules-api/types.js +1 -0
- package/dist/rules-api/utils.d.ts +14 -0
- package/dist/rules-api/utils.js +27 -0
- package/dist/shared/constants.d.ts +188 -0
- package/dist/shared/constants.js +242 -0
- package/dist/shared/css-variables.d.ts +9 -0
- package/dist/shared/css-variables.js +38 -0
- package/dist/shared/css.d.ts +78 -0
- package/dist/shared/css.js +426 -0
- package/dist/shared/element-match.d.ts +16 -0
- package/dist/shared/element-match.js +72 -0
- package/dist/shared/font-weights.d.ts +2 -0
- package/dist/shared/font-weights.js +551 -0
- package/dist/shared/index.d.ts +16 -0
- package/dist/shared/index.js +15 -0
- package/dist/shared/interactions-config.d.ts +15 -0
- package/dist/shared/interactions-config.js +120 -0
- package/dist/shared/links.d.ts +21 -0
- package/dist/shared/links.js +93 -0
- package/dist/shared/posix-path.d.ts +8 -0
- package/dist/shared/posix-path.js +27 -0
- package/dist/shared/site-files-tree-mapping.d.ts +40 -0
- package/dist/shared/site-files-tree-mapping.js +41 -0
- package/dist/shared/site-folders.d.ts +3 -0
- package/dist/shared/site-folders.js +17 -0
- package/dist/shared/site-media.d.ts +3 -0
- package/dist/shared/site-media.js +11 -0
- package/dist/shared/syntax-tree.d.ts +4 -0
- package/dist/shared/syntax-tree.js +30 -0
- package/dist/shared/transformation-values.d.ts +22 -0
- package/dist/shared/transformation-values.js +74 -0
- package/dist/shared/types.d.ts +477 -0
- package/dist/shared/types.js +1 -0
- package/dist/shared/utils.d.ts +155 -0
- package/dist/shared/utils.js +553 -0
- package/dist/shared/wrapper-contract.d.ts +31 -0
- package/dist/shared/wrapper-contract.js +157 -0
- package/dist/shared/wrapper-image-props.d.ts +3 -0
- package/dist/shared/wrapper-image-props.js +75 -0
- package/dist/site-code-model/constants.d.ts +107 -0
- package/dist/site-code-model/constants.js +102 -0
- package/dist/site-code-model/index.d.ts +3 -0
- package/dist/site-code-model/index.js +4 -0
- package/dist/site-code-model/manifest-values.d.ts +15 -0
- package/dist/site-code-model/manifest-values.js +88 -0
- package/dist/site-code-model/read-module.d.ts +4 -0
- package/dist/site-code-model/read-module.js +267 -0
- package/dist/site-code-model/read-site-code-model.d.ts +9 -0
- package/dist/site-code-model/read-site-code-model.js +42 -0
- package/dist/site-code-model/source-locations.d.ts +5 -0
- package/dist/site-code-model/source-locations.js +95 -0
- package/dist/site-code-model/types.d.ts +102 -0
- package/dist/site-code-model/types.js +1 -0
- package/dist/testing.d.ts +24 -0
- package/dist/testing.js +61 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.js +1 -0
- package/dist/validate.d.ts +7 -0
- package/dist/validate.js +180 -0
- package/package.json +59 -3
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { Comment, ChildNode, Declaration, Rule } from 'postcss';
|
|
3
|
+
import type { CallbackNode } from '../rules-adapter/index.ts';
|
|
4
|
+
import type { TRANSFORMATIONS } from './constants.ts';
|
|
5
|
+
/** Files by their path from the site root, each one's text: validate()'s `files` and `packageFiles`. */
|
|
6
|
+
export type Files = Readonly<Record<string, string>>;
|
|
7
|
+
/** A site file's text by its path from the site root; undefined when it doesn't exist. */
|
|
8
|
+
export type ReadFile = (file: string) => string | undefined;
|
|
9
|
+
/** A wrapper's image location: JSX attribute, object keys, and `[]` for each array item. */
|
|
10
|
+
export type ImagePath = readonly string[];
|
|
11
|
+
/** A font catalog: each Wix font id and its weights. */
|
|
12
|
+
export type FontCatalog = Readonly<Record<string, readonly number[]>>;
|
|
13
|
+
/** A line and a column in a file. */
|
|
14
|
+
export interface Position {
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Loc {
|
|
19
|
+
start: Position;
|
|
20
|
+
end: Position;
|
|
21
|
+
}
|
|
22
|
+
/** Where a node is in the text: its start and end offsets. */
|
|
23
|
+
type Span = Pick<TSESTree.Node, 'range'>;
|
|
24
|
+
export type AstNode = Span & {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
export interface Source {
|
|
28
|
+
/** The node's code, whitespace collapsed (so reformatting isn't a change). */
|
|
29
|
+
code(node: Span): string;
|
|
30
|
+
/** line 1-based, column 0-based. */
|
|
31
|
+
loc(node: Span): Loc;
|
|
32
|
+
}
|
|
33
|
+
/** What a tag is, by its import. 'box' is a BoxContainer, 'menu' a Menu and 'background' a Background (the editor's elements the layout rules tell apart).
|
|
34
|
+
* 'provider' is a context provider, by the site's component catalog. null: anything else (a plain tag, a wrapper component, a tag that isn't imported). */
|
|
35
|
+
export type ElementType = 'page' | 'section' | 'header' | 'footer' | 'innerElement' | 'globalHeader' | 'globalFooter' | 'globalSection' | 'remove' | 'interaction' | 'headerLandmark' | 'footerLandmark' | 'pinnedToScreen' | 'unsupportedWidget' | 'box' | 'menu' | 'background' | 'provider';
|
|
36
|
+
/** What an import's source is, for rules that care. null: anything else (a component package, a global component).
|
|
37
|
+
* 'core' is the DM's own `document`, 'document' anything under it (`document/components`). 'wrapper' is a component wrapper
|
|
38
|
+
* (`@origami-wrappers/…`) and 'siteCode' a companion component or provider (`@site/site-code/<Name>`): the two the site's runtime
|
|
39
|
+
* wraps with withOrigami. */
|
|
40
|
+
export type ImportKind = 'runtime' | 'sdk' | 'interactReact' | 'interact' | 'motionPresets' | 'menu' | 'core' | 'document' | 'wrapper' | 'siteCode';
|
|
41
|
+
/** A name's import: `import { Remove as R } from '@wix/origami-runtime'` → R is { imported: 'Remove', source: '@wix/origami-runtime', kind: 'runtime' }. */
|
|
42
|
+
export interface Import {
|
|
43
|
+
/** The name it's exported under; 'default' for a default import, '*' for `import * as ns`. */
|
|
44
|
+
imported: string;
|
|
45
|
+
source: string;
|
|
46
|
+
kind: ImportKind | null;
|
|
47
|
+
}
|
|
48
|
+
/** The global component a page's reference to the global header or footer names: its folder is `Header_<id>` / `Footer_<id>`. */
|
|
49
|
+
export type GlobalSectionModule = 'Header' | 'Footer';
|
|
50
|
+
/** The callbacks whose parameters the import reads as bindings: a renderItem template, a map() / shape() callback. */
|
|
51
|
+
export type CallbackKind = 'template' | 'transform';
|
|
52
|
+
/** The tool's nodes the rules read, by the syntax tree's names. Each keeps the tool's type (its loc, its parent). */
|
|
53
|
+
export type JSXElement = CallbackNode<'JSXElement'>;
|
|
54
|
+
export type JSXAttribute = CallbackNode<'JSXAttribute'>;
|
|
55
|
+
export type CallExpression = CallbackNode<'CallExpression'>;
|
|
56
|
+
export type LogicalExpression = CallbackNode<'LogicalExpression'>;
|
|
57
|
+
export type ArrayExpression = CallbackNode<'ArrayExpression'>;
|
|
58
|
+
export type ObjectExpression = CallbackNode<'ObjectExpression'>;
|
|
59
|
+
/** A `key: value` of an object literal: not a spread. */
|
|
60
|
+
export type Property = Extract<ObjectExpression['properties'][number], {
|
|
61
|
+
type: 'Property';
|
|
62
|
+
}>;
|
|
63
|
+
/** A value in the code: what a property holds, what an attribute's `{…}` holds. */
|
|
64
|
+
export type Expression = Property['value'];
|
|
65
|
+
/** A call's argument: a value, or a spread. */
|
|
66
|
+
export type Argument = CallExpression['arguments'][number];
|
|
67
|
+
/** A node a message quotes or points at: a value, a spread, or an object's `key: value` or spread. */
|
|
68
|
+
export type Node = Argument | Expression | ObjectExpression['properties'][number];
|
|
69
|
+
/** The node's code as written (`context.sourceCode.getText`). */
|
|
70
|
+
export type GetText = (node: Node) => string;
|
|
71
|
+
interface JSXIdentifier {
|
|
72
|
+
type: 'JSXIdentifier';
|
|
73
|
+
name: string;
|
|
74
|
+
}
|
|
75
|
+
/** `svg:rect`, `xlink:href`. */
|
|
76
|
+
interface JSXNamespacedName {
|
|
77
|
+
type: 'JSXNamespacedName';
|
|
78
|
+
namespace: {
|
|
79
|
+
name: string;
|
|
80
|
+
};
|
|
81
|
+
name: {
|
|
82
|
+
name: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** `Band`, `Band.Item`, `svg:rect`. */
|
|
86
|
+
export type JSXElementName = JSXIdentifier | JSXNamespacedName | {
|
|
87
|
+
type: 'JSXMemberExpression';
|
|
88
|
+
object: JSXElementName;
|
|
89
|
+
property: {
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** An attribute's value: a string, an {expression}, an element. Read deeper through `Nested`. */
|
|
94
|
+
export interface ValueNode {
|
|
95
|
+
type: string;
|
|
96
|
+
value?: unknown;
|
|
97
|
+
}
|
|
98
|
+
/** An object's key: `a` (an Identifier), or `'a'` (a Literal). */
|
|
99
|
+
interface NestedKey {
|
|
100
|
+
type: string;
|
|
101
|
+
name?: string;
|
|
102
|
+
value?: unknown;
|
|
103
|
+
}
|
|
104
|
+
/** An object's property (or a spread, which has no key or value). */
|
|
105
|
+
export interface NestedProperty {
|
|
106
|
+
type: string;
|
|
107
|
+
value?: Nested;
|
|
108
|
+
key?: NestedKey;
|
|
109
|
+
computed?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/** What `getLiteralString` and `getAttributeElements` read inside a value: an {expression}, an object's properties, an array's elements. */
|
|
112
|
+
export interface Nested extends ValueNode {
|
|
113
|
+
expression?: Nested;
|
|
114
|
+
argument?: Nested;
|
|
115
|
+
operator?: string;
|
|
116
|
+
properties?: ReadonlyArray<NestedProperty>;
|
|
117
|
+
elements?: ReadonlyArray<Nested | null>;
|
|
118
|
+
}
|
|
119
|
+
export interface JSXAttributeShape {
|
|
120
|
+
type: 'JSXAttribute';
|
|
121
|
+
name: JSXIdentifier | JSXNamespacedName;
|
|
122
|
+
value: ValueNode | null;
|
|
123
|
+
}
|
|
124
|
+
export interface JSXElementShape {
|
|
125
|
+
openingElement: {
|
|
126
|
+
name: JSXElementName;
|
|
127
|
+
attributes: ReadonlyArray<JSXAttributeShape | {
|
|
128
|
+
type: 'JSXSpreadAttribute';
|
|
129
|
+
}>;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** The owner's own attribute type, so a tool's node keeps its type (position, parent). */
|
|
133
|
+
export type AttributeOf<Element extends JSXElementShape> = Extract<Element['openingElement']['attributes'][number], {
|
|
134
|
+
type: 'JSXAttribute';
|
|
135
|
+
}>;
|
|
136
|
+
/** One step toward an element inside an attribute's value: an object key, and, when the key holds an array, the position of the item the way goes through (converter 0.100 addresses an array item by position, `items[0].content`, not by its `_id`). */
|
|
137
|
+
export interface PathStep {
|
|
138
|
+
key: string;
|
|
139
|
+
index?: number;
|
|
140
|
+
}
|
|
141
|
+
/** An element held in an attribute (`content={<X />}`): the element, the attribute it is in, the attribute's name, and its path (the name, then a
|
|
142
|
+
* step per object key; null when the way has no such spelling). */
|
|
143
|
+
export interface AttributeElement<Element extends JSXElementShape> {
|
|
144
|
+
element: Element;
|
|
145
|
+
attribute: AttributeOf<Element>;
|
|
146
|
+
name: string;
|
|
147
|
+
path: PathStep[] | null;
|
|
148
|
+
}
|
|
149
|
+
/** `import X`, `import * as X`, `import { X }` or `import { Y as X }`. */
|
|
150
|
+
export interface ImportSpecifier {
|
|
151
|
+
type: string;
|
|
152
|
+
local: {
|
|
153
|
+
name: string;
|
|
154
|
+
};
|
|
155
|
+
/** The exported name, for `import { Remove as Hide }`; absent on a default or namespace import. */
|
|
156
|
+
imported?: {
|
|
157
|
+
name?: string;
|
|
158
|
+
value?: unknown;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface ImportDeclaration {
|
|
162
|
+
type: 'ImportDeclaration';
|
|
163
|
+
source: {
|
|
164
|
+
value: string;
|
|
165
|
+
};
|
|
166
|
+
specifiers: ReadonlyArray<ImportSpecifier>;
|
|
167
|
+
}
|
|
168
|
+
export interface Program {
|
|
169
|
+
body: ReadonlyArray<{
|
|
170
|
+
type: string;
|
|
171
|
+
}>;
|
|
172
|
+
}
|
|
173
|
+
/** A JSX element's child, as far as this reads it: text, an {expression}, an element. */
|
|
174
|
+
export interface JSXChild {
|
|
175
|
+
type: string;
|
|
176
|
+
value?: unknown;
|
|
177
|
+
expression?: {
|
|
178
|
+
type: string;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** The fields of a node that the scope of a callback's parameters reads: what is around it, and what an arrow, a call and a member read hold. */
|
|
182
|
+
export interface ScopeNode {
|
|
183
|
+
type: string;
|
|
184
|
+
parent?: ScopeNode;
|
|
185
|
+
params?: ReadonlyArray<{
|
|
186
|
+
type: string;
|
|
187
|
+
name?: unknown;
|
|
188
|
+
}>;
|
|
189
|
+
body?: ScopeNode;
|
|
190
|
+
expression?: ScopeNode;
|
|
191
|
+
callee?: {
|
|
192
|
+
type: string;
|
|
193
|
+
name?: unknown;
|
|
194
|
+
};
|
|
195
|
+
arguments?: readonly unknown[];
|
|
196
|
+
object?: ScopeNode;
|
|
197
|
+
name?: unknown;
|
|
198
|
+
}
|
|
199
|
+
/** A node of any kind, as far as `isTypeScript` reads it. */
|
|
200
|
+
export interface TypedNode {
|
|
201
|
+
type: string;
|
|
202
|
+
importKind?: string;
|
|
203
|
+
exportKind?: string;
|
|
204
|
+
declare?: boolean;
|
|
205
|
+
abstract?: boolean;
|
|
206
|
+
}
|
|
207
|
+
/** A function's parameters, as far as `getPropNames` reads them: `({ id, className })` is one ObjectPattern. */
|
|
208
|
+
export interface ParamsOwner {
|
|
209
|
+
params: ReadonlyArray<{
|
|
210
|
+
type: string;
|
|
211
|
+
properties?: ReadonlyArray<{
|
|
212
|
+
type: string;
|
|
213
|
+
computed?: boolean;
|
|
214
|
+
key?: {
|
|
215
|
+
type: string;
|
|
216
|
+
name?: unknown;
|
|
217
|
+
} | null;
|
|
218
|
+
value?: {
|
|
219
|
+
type: string;
|
|
220
|
+
name?: unknown;
|
|
221
|
+
} | null;
|
|
222
|
+
}>;
|
|
223
|
+
}>;
|
|
224
|
+
}
|
|
225
|
+
/** What a value in the code reads as data needs from the file: where a name is imported from (rulesApi has it). */
|
|
226
|
+
export interface ImportReader {
|
|
227
|
+
getImport(node: Extract<Expression, {
|
|
228
|
+
type: 'Identifier';
|
|
229
|
+
}>): Import | null;
|
|
230
|
+
}
|
|
231
|
+
/** What the reader finds the import can't read as data: the node, and how a message names it. */
|
|
232
|
+
export type NonLiteral = {
|
|
233
|
+
node: Node;
|
|
234
|
+
what: string;
|
|
235
|
+
};
|
|
236
|
+
/** Reads one `key: value` entry of an object, at its path: a non-literal in it, or null. */
|
|
237
|
+
export type ReadValue = (property: Property, path: string) => NonLiteral | null;
|
|
238
|
+
/** How much the reader takes as data: a menu reference (`MAIN_MENU`, `MAIN_MENU.items`), a media call, an element. An attribute's value takes all three (FULL_READ); a media call's arguments are plain literals (PLAIN_READ). */
|
|
239
|
+
export type ReadMode = {
|
|
240
|
+
menus?: boolean;
|
|
241
|
+
media?: boolean;
|
|
242
|
+
jsx?: boolean;
|
|
243
|
+
};
|
|
244
|
+
/** A node of a CSS file, comments aside (the import drops them). */
|
|
245
|
+
export type CssNode = Exclude<ChildNode, Comment>;
|
|
246
|
+
/** One `--name: value` in a file. */
|
|
247
|
+
export interface ThemeToken {
|
|
248
|
+
name: string;
|
|
249
|
+
value: string;
|
|
250
|
+
/** Its line in its file. */
|
|
251
|
+
line: number;
|
|
252
|
+
}
|
|
253
|
+
/** A `font` shorthand as the theme writes it: `normal normal 700 --spx(88)/1em benzin` (style, variant, weight, size/line height, family). */
|
|
254
|
+
export interface FontShorthand {
|
|
255
|
+
/** The weight: its number, 700 for `bold`, 400 for `normal` or none; undefined for `bolder` and `lighter`, which depend on the parent. */
|
|
256
|
+
weight: number | undefined;
|
|
257
|
+
/** The family as written, after the size. */
|
|
258
|
+
family: string;
|
|
259
|
+
}
|
|
260
|
+
/** One top-level `@custom-media` in a file, split as the import reads it; a malformed one keeps what it has (no `--`, or an empty query). */
|
|
261
|
+
export interface CustomMedia {
|
|
262
|
+
/** '--tablet' */
|
|
263
|
+
name: string;
|
|
264
|
+
/** '(max-width: 1023px)', as written. */
|
|
265
|
+
query: string;
|
|
266
|
+
/** Its line in its file. */
|
|
267
|
+
line: number;
|
|
268
|
+
}
|
|
269
|
+
/** A style.css rule of one class: its selector with the class written as `&` ('&.comp-x--open .label'), and its line. */
|
|
270
|
+
export interface StyleRule {
|
|
271
|
+
selector: string;
|
|
272
|
+
line: number;
|
|
273
|
+
}
|
|
274
|
+
export interface SelectorPlace {
|
|
275
|
+
/** The selector's first `.x` or `#x` as written ('.comp-x', '#comp-x'); null when it has neither, so it's global CSS. */
|
|
276
|
+
owner: string | null;
|
|
277
|
+
/** The selector with that owner written as `&`; the whole selector when there's no owner. */
|
|
278
|
+
selector: string;
|
|
279
|
+
}
|
|
280
|
+
/** One space-separated part of a selector, read as cssSelectors.ts parseSegment reads it (0.83.0). */
|
|
281
|
+
export interface SelectorSegment {
|
|
282
|
+
/** `&` (the mixin's own element), or its class with what is glued to it: '.label', '.label[data-state~="open"]', '.label:not(:hover)',
|
|
283
|
+
* '.button.close' (the import splits the state classes off later), or its type selector with the classes glued to it ('a', 'a.link':
|
|
284
|
+
* which of them the contract writes and which are states is the contract's); undefined for a part with neither (`[x]`, `:hover`, `:root`). */
|
|
285
|
+
base: string | undefined;
|
|
286
|
+
/** Its states as written, in order: ':hover', '.onSale'. */
|
|
287
|
+
states: string[];
|
|
288
|
+
/** What the import can't read, from where it stops; '' when it reads all of it: `&[x]` → '[x]', `.label:hover[x]` → '[x]'. */
|
|
289
|
+
unread: string;
|
|
290
|
+
/** The type selector the part starts with, `a` in `a:hover`; only for such a part. Where a part may start with one is the selector's
|
|
291
|
+
* position: the import refuses it on the selector's first part, the ancestor element and an inner part's first part (cssSelectors.ts
|
|
292
|
+
* leadingTokensOf:122, parseAncestorChain:203, `:root` :350 at converter 0.103.0); a rule decides. */
|
|
293
|
+
type?: string;
|
|
294
|
+
/** The attribute the part starts with, `[data-hook~="comment-box"]` in `[data-hook~="comment-box"]:hover`; only for such a part. The import
|
|
295
|
+
* matches a part, attributes and all, against the component's inner-part selectors (cssSelectors.ts namesInnerElement:171, selectorSyntax.ts
|
|
296
|
+
* compoundContains:196 at converter 0.107.0), and a contract may write a part as an attribute alone (PostComments' `[data-hook~="comment-box"]`).
|
|
297
|
+
* On the selector's first part and the ancestor element it's refused (leadingTokensOf:122, parseAncestorChain:203); a rule decides. Not
|
|
298
|
+
* for the attributes earlier converters wrote alone (`[data-state~=…]`, `[data-ie-name=…]`): that part is unread, as before. */
|
|
299
|
+
attribute?: string;
|
|
300
|
+
}
|
|
301
|
+
/** One rule block of layout.css: its element, the breakpoint it's in (null by default), and its declarations at the top and in each target. */
|
|
302
|
+
export interface LayoutRuleBlock {
|
|
303
|
+
element: string;
|
|
304
|
+
media: string | null;
|
|
305
|
+
rule: Rule;
|
|
306
|
+
declarations: Declaration[];
|
|
307
|
+
targets: Map<string, Declaration[]>;
|
|
308
|
+
}
|
|
309
|
+
/** An element's declarations at one breakpoint, merged over its rules (the last value of a property wins), with the rules that hold `@origami-target` blocks. */
|
|
310
|
+
export interface LayoutScope {
|
|
311
|
+
element: string;
|
|
312
|
+
media: string | null;
|
|
313
|
+
values: Map<string, Declaration>;
|
|
314
|
+
rulesWithTargets: Rule[];
|
|
315
|
+
}
|
|
316
|
+
/** A number and its unit, in lowercase, as the import reads one value (quantityOf, :207). */
|
|
317
|
+
export interface Quantity {
|
|
318
|
+
value: number;
|
|
319
|
+
unit: string;
|
|
320
|
+
}
|
|
321
|
+
/** A CSS function, its name in lowercase, and its values. */
|
|
322
|
+
export interface CssFunction {
|
|
323
|
+
name: string;
|
|
324
|
+
args: Quantity[];
|
|
325
|
+
}
|
|
326
|
+
/** A transform function (or skewX and skewY, one pair) as the import reads it: its names, and what its values are. */
|
|
327
|
+
export interface TransformFunction {
|
|
328
|
+
names: readonly string[];
|
|
329
|
+
reads: (args: Quantity[]) => boolean;
|
|
330
|
+
}
|
|
331
|
+
/** One style property a state transition sets, written as a string: its name, its value and the value's line. */
|
|
332
|
+
export interface StateStyleProperty {
|
|
333
|
+
name: string;
|
|
334
|
+
value: string;
|
|
335
|
+
line: number;
|
|
336
|
+
}
|
|
337
|
+
/** One state transition: the state it styles (its `effects` key, or the effect's `effectId`), its line, its style properties, and the
|
|
338
|
+
* components it styles, by their `key` (a component id of the unit's structure.jsx): an inline effect's own `key`; an `effects` entry's
|
|
339
|
+
* own `key` and the owner each inline effect that plays it by its `effectId` gives it (getStateOwner: its selector's component first). */
|
|
340
|
+
export interface StateTransition {
|
|
341
|
+
stateId: string;
|
|
342
|
+
line: number;
|
|
343
|
+
properties: StateStyleProperty[];
|
|
344
|
+
targets: string[];
|
|
345
|
+
}
|
|
346
|
+
/** A transition as readStateTransitions' walk finds it: the `effectId` whose entry it overlays, the effect's own `key`, and whether it is
|
|
347
|
+
* an `effects` entry (named by its key, not by an `effectId`), which plays on the components of the inline effects that name it. */
|
|
348
|
+
export interface FoundTransition {
|
|
349
|
+
transition: Omit<StateTransition, 'targets'>;
|
|
350
|
+
overlays?: string;
|
|
351
|
+
key: string | null;
|
|
352
|
+
isEntry: boolean;
|
|
353
|
+
}
|
|
354
|
+
/** What an interaction or an effect names its component by. */
|
|
355
|
+
export interface ComponentFields {
|
|
356
|
+
key: string | undefined;
|
|
357
|
+
selector: string | undefined;
|
|
358
|
+
}
|
|
359
|
+
/** A style property the import reads as a state's transformation (TRANSFORMATION_PROPERTIES). */
|
|
360
|
+
export type TransformationProperty = (typeof TRANSFORMATIONS)[number];
|
|
361
|
+
/** A wrapper's allowed overrides, as its component-contract.json or defaults.css lists them. */
|
|
362
|
+
export interface WrapperContract {
|
|
363
|
+
/** The defaults.css as a package path, for messages (it lists the overrides with their defaults): '@origami-wrappers/wixEditorElements/button/defaults.css'. */
|
|
364
|
+
file: string;
|
|
365
|
+
/** The component's own block: '.button'. */
|
|
366
|
+
root: string;
|
|
367
|
+
/** Each block's properties, by its key (blockKey): '.button', '.label', '.button .label'. */
|
|
368
|
+
blocks: Map<string, Set<string>>;
|
|
369
|
+
/** The nested components' selectors, from the comment's text lines: '.animated-icon.item-icon'. */
|
|
370
|
+
nested: string[];
|
|
371
|
+
/** Each element's state classes, from its state blocks (`.label.button__label--hover`), by the element: '.label' → 'button__label--hover'. */
|
|
372
|
+
stateClasses: Map<string, Set<string>>;
|
|
373
|
+
/** Each element's native states, from its pseudo-class state blocks (`.label:hover`), by the element: '.label' → 'hover'. A defaults.css
|
|
374
|
+
* written before the wrapper server split them lists native states as classes, and has none. */
|
|
375
|
+
statePseudoClasses: Map<string, Set<string>>;
|
|
376
|
+
/** Whether statePseudoClasses is the component's whole list of native states, so the import takes no other pseudo-class: always for a
|
|
377
|
+
* component-contract.json (its `states` are the manifest's, an empty list too), and for a defaults.css that lists any pseudo-class. A
|
|
378
|
+
* defaults.css that lists none (written before the wrapper server wrote native states as pseudo-classes) says nothing. */
|
|
379
|
+
declaresNativeStates: boolean;
|
|
380
|
+
/** The custom enums component-contract.json lists, its own elements' and its nested components' roots'; none for a defaults.css, or a
|
|
381
|
+
* component-contract.json written before wrapper revision 23. */
|
|
382
|
+
customEnums: CustomEnum[];
|
|
383
|
+
/** The typed vars component-contract.json lists, the same way; none for a defaults.css, or a component-contract.json written before
|
|
384
|
+
* wrapper revision 25. */
|
|
385
|
+
customPropertyTypes: CustomPropertyType[];
|
|
386
|
+
}
|
|
387
|
+
/** A var component-contract.json lists for one element. */
|
|
388
|
+
export interface ContractVar {
|
|
389
|
+
/** The custom property: '--items-width'. */
|
|
390
|
+
key: string;
|
|
391
|
+
/** Its element's selector: '.navbar'; a nested component's, '.gallery.gallery-1'; undefined for the root. */
|
|
392
|
+
inline: string | undefined;
|
|
393
|
+
/** Whether it's a nested component's root var, from that component's own contract (`refElements` names its type). */
|
|
394
|
+
nested: boolean;
|
|
395
|
+
/** The component-contract.json it's in, as a package path, for messages: '@origami-wrappers/wixEditorElements/menu/component-contract.json'. */
|
|
396
|
+
file: string;
|
|
397
|
+
}
|
|
398
|
+
/** A custom enum var of component-contract.json's `customEnums`, the only values the import takes for it. */
|
|
399
|
+
export interface CustomEnum extends ContractVar {
|
|
400
|
+
/** Its options, as written: ['fitToText', 'fillMenu'], ['0 0 auto', '1 1 0']. */
|
|
401
|
+
options: string[];
|
|
402
|
+
}
|
|
403
|
+
/** A var of component-contract.json's `customPropertyTypes`: the type its value must be. */
|
|
404
|
+
export interface CustomPropertyType extends ContractVar {
|
|
405
|
+
/** As the manifest names it (`cssPropertyType`): 'length', 'lengthPercentage', 'textShadow'. */
|
|
406
|
+
type: string;
|
|
407
|
+
}
|
|
408
|
+
/** A contract's vars: its custom enums and typed vars. */
|
|
409
|
+
export type ContractVars = Pick<WrapperContract, 'customEnums' | 'customPropertyTypes'>;
|
|
410
|
+
/** A file of a package, as the site's node resolves it from a page: its path (what a contract is read once by) and its text. */
|
|
411
|
+
export interface PackageFile {
|
|
412
|
+
file: string;
|
|
413
|
+
text: string;
|
|
414
|
+
}
|
|
415
|
+
/** How the site's node resolves a package request from a site file (`@origami-wrappers/<app>/<name>/css`, from the page's structure file):
|
|
416
|
+
* the file and its text; null when it doesn't resolve. The caller's: validate() reads no disk. */
|
|
417
|
+
export type ReadPackageFile = (request: string, fromFile: string) => PackageFile | null;
|
|
418
|
+
/** component-contract.json: each element by its manifest selector, and each ref element's selector → its type. */
|
|
419
|
+
/** An element of component-contract.json: its properties and custom properties, its custom enums' options (revision 23) and its typed vars'
|
|
420
|
+
* types (revision 25), and its states. */
|
|
421
|
+
export interface ComponentContractElement {
|
|
422
|
+
properties: string[];
|
|
423
|
+
customProperties: string[];
|
|
424
|
+
customEnums?: Record<string, string[]>;
|
|
425
|
+
customPropertyTypes?: Record<string, string>;
|
|
426
|
+
states: ({
|
|
427
|
+
name: string;
|
|
428
|
+
} & ({
|
|
429
|
+
pseudoClass: string;
|
|
430
|
+
} | {
|
|
431
|
+
class: string;
|
|
432
|
+
}))[];
|
|
433
|
+
}
|
|
434
|
+
export interface ComponentContractJson {
|
|
435
|
+
root: string;
|
|
436
|
+
elements: Record<string, ComponentContractElement>;
|
|
437
|
+
refElements: Record<string, string>;
|
|
438
|
+
}
|
|
439
|
+
/** A block as defaults.css writes it: its selector and the properties it lists. */
|
|
440
|
+
export interface ContractBlock {
|
|
441
|
+
selector: string;
|
|
442
|
+
properties: string[];
|
|
443
|
+
}
|
|
444
|
+
/** An `elementProps` entry: its key, its object, and the keys from the element down to it (`nav.label` for `{ nav: { elementProps: { label: … } } }`). */
|
|
445
|
+
export interface ElementPropsEntry {
|
|
446
|
+
key: string;
|
|
447
|
+
entry: ObjectExpression;
|
|
448
|
+
path: string[];
|
|
449
|
+
}
|
|
450
|
+
export interface DataValuesReader extends ImportReader {
|
|
451
|
+
hasDataAttributes(node: JSXElement): boolean;
|
|
452
|
+
getBuilder(node: TypedNode): string | null;
|
|
453
|
+
}
|
|
454
|
+
/** What rebuildRichText does with one <a> (getAnchorLink): the href it rebuilds a link from, 'kept' as it is (a typed data-link, a
|
|
455
|
+
* dataquery), or 'no_href' (refused). */
|
|
456
|
+
export type AnchorLink = {
|
|
457
|
+
href: string;
|
|
458
|
+
} | 'kept' | 'no_href';
|
|
459
|
+
/** A link of a data value: the label above it, its href, and for a rich text's <a> its attributes in quotes, unescaped, and the href the
|
|
460
|
+
* converter rebuilds a link from (getAnchorLink), or none. */
|
|
461
|
+
export interface DataLink {
|
|
462
|
+
label?: string;
|
|
463
|
+
href?: string;
|
|
464
|
+
anchor?: Readonly<Record<string, string | undefined>>;
|
|
465
|
+
}
|
|
466
|
+
export interface RebuiltLink {
|
|
467
|
+
attribute: string | null;
|
|
468
|
+
/** A link object, `{ href, … }`, or a rich text (isRichTextObject). */
|
|
469
|
+
link: ObjectExpression;
|
|
470
|
+
}
|
|
471
|
+
/** A `var(--name)` with no fallback in a rich text's inline style: the declaration it is in, and the variable. */
|
|
472
|
+
export interface RichTextStyleVariable {
|
|
473
|
+
property: string;
|
|
474
|
+
value: string;
|
|
475
|
+
name: string;
|
|
476
|
+
}
|
|
477
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { Argument, DataValuesReader, AttributeElement, AttributeOf, CallbackKind, CallExpression, ElementPropsEntry, ElementType, Expression, GetText, GlobalSectionModule, Import, ImportKind, ImportReader, ImportSpecifier, JSXAttribute, JSXAttributeShape, JSXChild, JSXElement, JSXElementShape, LogicalExpression, NonLiteral, ObjectExpression, ParamsOwner, Program, Property, ReadValue, TypedNode, ValueNode } from './types.ts';
|
|
3
|
+
/** <Band> with `import { Section as Band } from '@wix/origami-system-components/Section'` → 'section'. `<Band.Item>` is Band's. A wrapper is the named export: `<Show>` from the runtime is null.
|
|
4
|
+
* A context provider ('provider') is known from the site's component catalog: rulesApi.getType adds it. */
|
|
5
|
+
export declare function getType(element: JSXElementShape, program: Program): ElementType | null;
|
|
6
|
+
/** 'Header' for `<Header_mb7ogqqn>` imported from global/components/Header_mb7ogqqn, 'Footer' for a Footer_…, null for anything else
|
|
7
|
+
* (converter 0.97 identity.ts globalSectionModuleOf): the reference a <Page> takes in its header / footer attribute. */
|
|
8
|
+
export declare function getGlobalSectionModule(element: JSXElementShape, program: Program): GlobalSectionModule | null;
|
|
9
|
+
/** Converter 0.81: are the tag's attributes saved as its component's data? Yes on a builder component (its import gives a componentType):
|
|
10
|
+
* imported, not from `document` and not from a local file. No on the DM's own tags (`Page`, the sections) and a global component's reference. */
|
|
11
|
+
export declare function hasDataAttributes(element: JSXElementShape, program: Program): boolean;
|
|
12
|
+
/** What an import's source is: 'runtime' for @wix/origami-runtime, 'interact' for @wix/interact/…; null for anything else. */
|
|
13
|
+
export declare const getImportKind: (source: string) => ImportKind | null;
|
|
14
|
+
/** Where a name of the file comes from; null when no import brings it in. */
|
|
15
|
+
export declare function getImport(name: string, program: Program): Import | null;
|
|
16
|
+
/** The import of a tag: of `Band` for <Band.Item>; null when nothing imports it. */
|
|
17
|
+
export declare const getTagImport: (element: JSXElementShape, program: Program) => Import | null;
|
|
18
|
+
/** The name a specifier is exported under: `import X` → 'default', `import * as X` → '*', `import { Remove as Hide }` → 'Remove', `import { 'a-b' as ab }` → 'a-b'. */
|
|
19
|
+
export declare function getImportedName({ type, imported }: ImportSpecifier): string;
|
|
20
|
+
/** 'Section', 'Band.Item', 'svg:rect'. */
|
|
21
|
+
export declare function getTagName(element: JSXElementShape): string;
|
|
22
|
+
/** An attribute's value as a string: x="a" and x={'a'} → 'a'; no value, or any other expression → null. */
|
|
23
|
+
export declare function getLiteralString(value: ValueNode | null | undefined): string | null;
|
|
24
|
+
/** id="sec" and id={'sec'} → 'sec'; no id, or id={variable} → null. */
|
|
25
|
+
export declare function getId(element: JSXElementShape): string | null;
|
|
26
|
+
/** The elements this one holds in its attributes (`content={<X />}`, or inside the attribute's object or array, `elementProps` too), each with the attribute it is in, its name, and its path: the name, then a step per object key down to the element; an array item's position goes on the step of the key that holds the array. Not its children, and not the elements inside those elements.
|
|
27
|
+
* path is null when the way has no such spelling: a computed key, an array item that isn't an object (an element directly in an array, an array in an array). */
|
|
28
|
+
export declare function getAttributeElements<Element extends JSXElementShape>(owner: Element): Array<AttributeElement<Element>>;
|
|
29
|
+
/** An attribute's value as plain data: literals (including a negative number such as `-1`), objects and arrays. undefined for what has no known value (no such attribute, an element, a variable, a call); inside an object or array such a value stays as undefined in its place. A computed key and a spread are left out. */
|
|
30
|
+
export declare function getAttributeValue(owner: JSXElementShape, name: string): unknown;
|
|
31
|
+
/** The interaction key, as componentClassOf reads it: a string's first space-delimited word or an array's first string item; null for a non-literal, never the id. */
|
|
32
|
+
export declare function getComponentClass(element: JSXElementShape): string | null;
|
|
33
|
+
/** Elements, text and {expressions}, in order. Whitespace and JSX comments are skipped. */
|
|
34
|
+
export declare function getChildren<Child extends JSXChild>(element: {
|
|
35
|
+
children: readonly Child[];
|
|
36
|
+
}): Child[];
|
|
37
|
+
/** The element's attribute with this name (`a:b` for a namespaced one); undefined without one. A tool's element gives the tool's attribute. */
|
|
38
|
+
export declare function getAttribute<Element extends JSXElementShape>(element: Element, name: string): AttributeOf<Element> | undefined;
|
|
39
|
+
/** The attribute's name: `type`, or `a:b` for a namespaced one. */
|
|
40
|
+
export declare const getName: (attribute: JSXAttributeShape) => string;
|
|
41
|
+
/** What the attribute's {…} holds, without parentheses; null for a string value, no value, or `{}`. */
|
|
42
|
+
export declare function getExpression(attribute: JSXAttribute | undefined): Expression | null;
|
|
43
|
+
/** The object written out in a value, in parentheses or in an attribute's `{…}`: `x={{ a: 1 }}` → `{ a: 1 }`; null for any other value. */
|
|
44
|
+
export declare function getObject(node: JSXAttribute | Argument | Expression | null | undefined): ObjectExpression | null;
|
|
45
|
+
/** Not the component's data: the converter's reserved attributes, and `sharedCompId` (reservedAttributes.ts). */
|
|
46
|
+
export declare const isReservedAttribute: (name: string) => boolean;
|
|
47
|
+
/** The node inside its parentheses: `((x))` → `x`. */
|
|
48
|
+
export declare function bare<T extends {
|
|
49
|
+
type: string;
|
|
50
|
+
expression?: unknown;
|
|
51
|
+
}>(node: T): T;
|
|
52
|
+
/** An object's `key: value` entries: no spread, no computed key. */
|
|
53
|
+
export declare const getProperties: (object: ObjectExpression) => Property[];
|
|
54
|
+
/** The object's entry with this key; undefined without one. */
|
|
55
|
+
export declare const getProperty: (object: ObjectExpression, key: string) => Property | undefined;
|
|
56
|
+
/** null for a number key: the import reads only name and string keys, and fails on any other. */
|
|
57
|
+
export declare function getKey(property: Property): string | null;
|
|
58
|
+
/** The names a `className` array declares after its class, as the import reads its terms (parseJsx.ts splitClassName): its strings, split on
|
|
59
|
+
* spaces, and its objects' keys: `['comp-x', 'open', { hover: … }]` → 'open', 'hover'. None for a className that isn't an array. */
|
|
60
|
+
export declare function getClassNameTerms(element: JSXElement): string[];
|
|
61
|
+
/** The inner elements' own states, the classes the runtime writes for an `elementProps` entry's className keys, at any depth: `<class>-<key>--<name>`
|
|
62
|
+
* (css-codec/states.ts applicativeClassPrefixOf:250, parse/fromBundle.ts applicativeClassesOfJsx:760): `elementProps={{ label: { className: { busy: … } } }}` →
|
|
63
|
+
* 'comp-btn-label--busy'. */
|
|
64
|
+
export declare function getInnerElementStates(node: JSXElement, className: string): Set<string>;
|
|
65
|
+
/** An element's `elementProps` entries, at any depth: each entry, then the entries of its own `elementProps`. An entry with no string key or no object
|
|
66
|
+
* value is left out, and so are the entries under it. */
|
|
67
|
+
export declare function getElementPropsEntries(element: JSXElement): ElementPropsEntry[];
|
|
68
|
+
/** A top-level function or variable declaration, including a named export; nested helpers do not count. */
|
|
69
|
+
export declare function findDeclaration(program: TSESTree.Program, name: string): TSESTree.FunctionDeclaration | TSESTree.VariableDeclarator | null;
|
|
70
|
+
/** The function `export const Structure = () => …` at the top of the file. Any `Structure` declarator counts, as the page model reads it; no-free-code reports a wrong form. */
|
|
71
|
+
export declare function isStructure(node: {
|
|
72
|
+
parent?: unknown;
|
|
73
|
+
}): boolean;
|
|
74
|
+
/** The import reads the element: it is not inside a function other than Structure or a renderItem template, a call, a condition, or an {expression} child. */
|
|
75
|
+
export declare function isReadByImport(element: JSXElement): boolean;
|
|
76
|
+
/** The callbacks whose parameters the import reads as bindings: 'template' for a slot's template, `renderItem={(item, index, length) => <X />}`, an attribute's
|
|
77
|
+
* arrow that returns one element (parseJsx.ts templateCallbackOf); 'transform' for `map(source, (item, index) => ({…}))` and `shape(source, (obj) => ({…}))`
|
|
78
|
+
* (astValue.ts transformCallbackOf). null for any other node. */
|
|
79
|
+
export declare function getCallbackKind(syntax: {
|
|
80
|
+
type: string;
|
|
81
|
+
parent?: unknown;
|
|
82
|
+
}): CallbackKind | null;
|
|
83
|
+
/** A read of a callback's parameter, `item`, `item.name`, `item['link-1']`, which the import reads as a binding (astValue.ts templateReadOf):
|
|
84
|
+
* 'template' off a renderItem's parameter, 'transform' off a map() or shape() callback's. null for any other value, or inside any other function. */
|
|
85
|
+
export declare function getParamReadKind(syntax: {
|
|
86
|
+
type: string;
|
|
87
|
+
parent?: unknown;
|
|
88
|
+
}): CallbackKind | null;
|
|
89
|
+
/** A call, or a read of a renderItem / map() parameter (`item.name`): the import reads it as a binding, not as data (parseJsx.ts takeBoundProp).
|
|
90
|
+
* Any call: the bindings rule reports one that isn't a builder. Not `a ?? b` (isFallback): a rule that takes it reads its sides itself, as
|
|
91
|
+
* data-values does with a row read and its stored data. */
|
|
92
|
+
export declare const isBound: (value: Expression | null | undefined) => value is Expression;
|
|
93
|
+
/** `a ?? b`: since converter 0.104 the import reads it only as a renderItem row read with its stored data on the right (parseJsx.ts takeBoundProp). */
|
|
94
|
+
export declare const isFallback: (value: Expression) => value is LogicalExpression;
|
|
95
|
+
/** The stored data of `attr={item.x ?? data}`, a renderItem read with its data (converter 0.103, DM-16073): the import reads the right side as the
|
|
96
|
+
* attribute's data. The left side is read through names or string keys only (astValue.ts templateReadOf), and the right side isn't a read
|
|
97
|
+
* (parseJsx.ts takeBoundProp). Any other value, as it is. */
|
|
98
|
+
export declare function getStoredData<Value extends Expression | null | undefined>(value: Value): Value | Expression;
|
|
99
|
+
/** `{ placeholder: … }` alone: a call's options, not a data item (decode.ts isPlaceholderOptions). */
|
|
100
|
+
export declare const isPlaceholderOptions: (object: ObjectExpression) => boolean;
|
|
101
|
+
/** A component in a message: `<Image>` img, or `<Image>` when it has no id. */
|
|
102
|
+
export declare function ownerOf(element: JSXElementShape): string;
|
|
103
|
+
/** One letter added, removed or changed, as the converter counts it (dataKeys.ts, reservedAttrNearMiss). */
|
|
104
|
+
export declare function isOneEditAway(name: string, target: string): boolean;
|
|
105
|
+
/** A TypeScript node (`TSTypeAnnotation`, `TSAsExpression`…), an `import type` / `export type` / `{ type Y }`, or a `declare` / `abstract` declaration. JavaScript, null and undefined: false. */
|
|
106
|
+
export declare function isTypeScript(node: TypedNode | null | undefined): boolean;
|
|
107
|
+
/** The names a function destructures from its one parameter: `({ id, className })` → ['id', 'className']. A property with a default, a new name, a computed key or `...rest` is null. `()` and `({})` → []; any other parameters → null. */
|
|
108
|
+
export declare function getPropNames(fn: ParamsOwner): Array<string | null> | null;
|
|
109
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
110
|
+
/** `media.<method>(…)`, with `media` imported from '@wix/sdk'. */
|
|
111
|
+
export declare function isMediaCall(node: Argument | Expression, method: string, rulesApi: ImportReader): node is CallExpression;
|
|
112
|
+
/** `media.getCroppedImageUrl('wix:image://v1/…', …)` with the export's eight arguments. */
|
|
113
|
+
export declare function isImageCall(node: Argument | Expression, rulesApi: ImportReader): node is CallExpression;
|
|
114
|
+
/** The identifier in `media.getDocumentUrl('wix:document://v1/…').url`; null for any other value. */
|
|
115
|
+
export declare function getDocumentIdentifier(node: Argument | Expression, rulesApi: ImportReader): string | null;
|
|
116
|
+
/** The identifier in `media.getAudioUrl('wix:audio://v1/…').url`, or `.duration` when property is 'duration'; null for any other value (converter 0.112,
|
|
117
|
+
* audioExpression.ts:88 resolveAudioExpression). */
|
|
118
|
+
export declare function getAudioIdentifier(node: Argument | Expression, rulesApi: ImportReader, property?: 'url' | 'duration'): string | null;
|
|
119
|
+
/** The first part of a value the import can't read as data (astValue.ts), or null when it reads all of it: a string, a number, true / false,
|
|
120
|
+
* null, a negative number, a call by name (a builder: the bindings rule's), an element, a menu or media reference, and an array or object of
|
|
121
|
+
* these. */
|
|
122
|
+
export declare const getNonLiteral: (node: Argument | Expression | null, rulesApi: ImportReader, getText: GetText, path?: string) => NonLiteral | null;
|
|
123
|
+
/** An object's first part the import can't read as data: each level is checked whole (its entries, then its keys once) before the values inside it, as the import does. readValue reads each value (getNonLiteral by default). */
|
|
124
|
+
export declare const getNonLiteralInObject: (object: ObjectExpression, rulesApi: ImportReader, getText: GetText, path: string, readValue?: ReadValue) => NonLiteral | null;
|
|
125
|
+
/** A value written out, as plain data: a string, a number, true / false, null, a negative number, and an array or object of these. NOT_A_VALUE for anything else, or when anything inside is. */
|
|
126
|
+
export declare function getDataValue(node: Argument | Expression | null): unknown;
|
|
127
|
+
/** Never data, as an attribute or a key (dataKeys.ts): an excluded name, `data-*`, `aria-*`, an `on…` event, or a name that isn't a data key. */
|
|
128
|
+
export declare const isExcludedDataKey: (name: string) => boolean;
|
|
129
|
+
/** The reserved attribute this name is one edit away from (a typo the converter refuses); undefined for none. */
|
|
130
|
+
export declare const getReservedNearMiss: (name: string) => string | undefined;
|
|
131
|
+
/** A builder component's attribute the import saves as its data: not reserved, not excluded, and not a reserved name's near miss. */
|
|
132
|
+
export declare const isDataName: (name: string) => boolean;
|
|
133
|
+
/** An elementProps value's first part the import can't read as data, as it reads an inner part's entry (parseJsx.ts innerElementNodeOfValue):
|
|
134
|
+
* an entry's `bindings` and `className`, and a bound value of its own (a call, a template's or a transform's param), are bindings, not data.
|
|
135
|
+
* A data key's `item.x ?? data` is read by its stored data (getStoredData). */
|
|
136
|
+
export declare function getNonLiteralInElementProps(node: Argument | Expression, rulesApi: ImportReader, getText: GetText, path?: string): NonLiteral | null;
|
|
137
|
+
/** An object literal's values; none for anything else. */
|
|
138
|
+
export declare const getPropertyValues: (value: Expression | undefined) => Expression[];
|
|
139
|
+
/** The value at `keys` through nested object literals, or undefined. */
|
|
140
|
+
export declare const getObjectValue: (node: Expression | undefined, ...keys: string[]) => Expression | undefined;
|
|
141
|
+
/** An array literal's items, holes and spreads left out; none for anything else. */
|
|
142
|
+
export declare const getArrayItems: (value: Expression | undefined) => Expression[];
|
|
143
|
+
export declare const getJSXAttributes: (element: JSXElement) => JSXAttribute[];
|
|
144
|
+
/** The attributes the import saves as the component's data: none on a tag without data attributes; not a reserved, excluded or bound one, nor a renderItem. */
|
|
145
|
+
export declare const getDataAttributes: (element: JSXElement, reader: DataValuesReader) => JSXAttribute[];
|
|
146
|
+
/** An elementProps entry's keys the import saves as data: not a reserved entry key, nor a bound one. */
|
|
147
|
+
export declare const getEntryDataKeys: (entry: ObjectExpression) => Property[];
|
|
148
|
+
/**
|
|
149
|
+
* The objects the import reads as an argument's data item, in any attribute (decode.ts callOptionsOf, decodeDataRef): each object argument of an
|
|
150
|
+
* `fn()` or a `callback()` after its function, or of a called ctx() or row member, but a `{ placeholder }`. The bindings rule checks the rest.
|
|
151
|
+
*/
|
|
152
|
+
export declare function getDataItemArguments(element: JSXElement, reader: DataValuesReader): {
|
|
153
|
+
node: ObjectExpression;
|
|
154
|
+
label: string;
|
|
155
|
+
}[];
|