@tamagui/language-service 0.0.0-bootstrap.0 → 3.0.0-beta.643.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 +140 -1
- package/dist/cjs/check.cjs +173 -0
- package/dist/cjs/check.native.cjs +369 -0
- package/dist/cjs/check.native.js +371 -0
- package/dist/cjs/check.native.js.map +1 -0
- package/dist/cjs/core.cjs +221 -0
- package/dist/cjs/core.native.cjs +305 -0
- package/dist/cjs/core.native.js +307 -0
- package/dist/cjs/core.native.js.map +1 -0
- package/dist/cjs/document.cjs +82 -0
- package/dist/cjs/document.native.cjs +158 -0
- package/dist/cjs/document.native.js +160 -0
- package/dist/cjs/document.native.js.map +1 -0
- package/dist/cjs/extract-estree.cjs +193 -0
- package/dist/cjs/extract-estree.native.cjs +296 -0
- package/dist/cjs/extract-estree.native.js +298 -0
- package/dist/cjs/extract-estree.native.js.map +1 -0
- package/dist/cjs/extract-sucrase.cjs +222 -0
- package/dist/cjs/extract-sucrase.native.cjs +256 -0
- package/dist/cjs/extract-sucrase.native.js +258 -0
- package/dist/cjs/extract-sucrase.native.js.map +1 -0
- package/dist/cjs/host.cjs +38 -0
- package/dist/cjs/host.native.cjs +61 -0
- package/dist/cjs/host.native.js +63 -0
- package/dist/cjs/host.native.js.map +1 -0
- package/dist/cjs/index.cjs +301 -0
- package/dist/cjs/index.native.cjs +414 -0
- package/dist/cjs/index.native.js +416 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/esm/check.mjs +148 -0
- package/dist/esm/check.mjs.map +1 -0
- package/dist/esm/check.native.js +342 -0
- package/dist/esm/check.native.js.map +1 -0
- package/dist/esm/core.mjs +198 -0
- package/dist/esm/core.mjs.map +1 -0
- package/dist/esm/core.native.js +280 -0
- package/dist/esm/core.native.js.map +1 -0
- package/dist/esm/document.mjs +61 -0
- package/dist/esm/document.mjs.map +1 -0
- package/dist/esm/document.native.js +135 -0
- package/dist/esm/document.native.js.map +1 -0
- package/dist/esm/extract-estree.mjs +172 -0
- package/dist/esm/extract-estree.mjs.map +1 -0
- package/dist/esm/extract-estree.native.js +273 -0
- package/dist/esm/extract-estree.native.js.map +1 -0
- package/dist/esm/extract-sucrase.mjs +201 -0
- package/dist/esm/extract-sucrase.mjs.map +1 -0
- package/dist/esm/extract-sucrase.native.js +233 -0
- package/dist/esm/extract-sucrase.native.js.map +1 -0
- package/dist/esm/host.mjs +17 -0
- package/dist/esm/host.mjs.map +1 -0
- package/dist/esm/host.native.js +38 -0
- package/dist/esm/host.native.js.map +1 -0
- package/dist/esm/index.mjs +281 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +392 -0
- package/dist/esm/index.native.js.map +1 -0
- package/index.cjs +1 -0
- package/package.json +79 -7
- package/src/check.ts +204 -0
- package/src/core.ts +355 -0
- package/src/document.ts +140 -0
- package/src/extract-estree.ts +251 -0
- package/src/extract-sucrase.ts +308 -0
- package/src/host.ts +32 -0
- package/src/index.ts +452 -0
- package/types/check.d.ts +31 -0
- package/types/check.d.ts.map +11 -0
- package/types/core.d.ts +68 -0
- package/types/core.d.ts.map +11 -0
- package/types/document.d.ts +42 -0
- package/types/document.d.ts.map +11 -0
- package/types/extract-estree.d.ts +19 -0
- package/types/extract-estree.d.ts.map +11 -0
- package/types/extract-sucrase.d.ts +26 -0
- package/types/extract-sucrase.d.ts.map +11 -0
- package/types/host.d.ts +10 -0
- package/types/host.d.ts.map +11 -0
- package/types/index.d.ts +9 -0
- package/types/index.d.ts.map +11 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var extract_sucrase_exports = {};
|
|
23
|
+
__export(extract_sucrase_exports, { createSucraseStyleSiteExtractor: () => createSucraseStyleSiteExtractor });
|
|
24
|
+
module.exports = __toCommonJS(extract_sucrase_exports);
|
|
25
|
+
function defaultIsTamaguiModule(source) {
|
|
26
|
+
return source === "tamagui" || source.startsWith("tamagui/") || source.startsWith("@tamagui/");
|
|
27
|
+
}
|
|
28
|
+
function createSucraseStyleSiteExtractor(parser, options = {}) {
|
|
29
|
+
const { TokenType } = parser;
|
|
30
|
+
const T = {
|
|
31
|
+
import: TokenType._import,
|
|
32
|
+
string: TokenType.string,
|
|
33
|
+
name: TokenType.name,
|
|
34
|
+
comma: TokenType.comma,
|
|
35
|
+
colon: TokenType.colon,
|
|
36
|
+
eq: TokenType.eq,
|
|
37
|
+
dot: TokenType.dot,
|
|
38
|
+
star: TokenType.star,
|
|
39
|
+
slash: TokenType.slash,
|
|
40
|
+
braceL: TokenType.braceL,
|
|
41
|
+
braceR: TokenType.braceR,
|
|
42
|
+
dollarBraceL: TokenType.dollarBraceL,
|
|
43
|
+
parenL: TokenType.parenL,
|
|
44
|
+
parenR: TokenType.parenR,
|
|
45
|
+
backQuote: TokenType.backQuote,
|
|
46
|
+
template: TokenType.template,
|
|
47
|
+
jsxTagStart: TokenType.jsxTagStart,
|
|
48
|
+
jsxTagEnd: TokenType.jsxTagEnd,
|
|
49
|
+
jsxName: TokenType.jsxName
|
|
50
|
+
};
|
|
51
|
+
const isStyleProp = options.isStyleProp ?? (() => true);
|
|
52
|
+
const isTamaguiModule = options.isTamaguiModule ?? defaultIsTamaguiModule;
|
|
53
|
+
return (source) => {
|
|
54
|
+
const tokens = parser.parse(source, true, true, false).tokens;
|
|
55
|
+
const sites = [];
|
|
56
|
+
const text = (token) => source.slice(token.start, token.end);
|
|
57
|
+
const stringContent = (index) => {
|
|
58
|
+
const token = tokens[index];
|
|
59
|
+
if (token.type === T.string) {
|
|
60
|
+
const content = source.slice(token.start + 1, token.end - 1);
|
|
61
|
+
if (content.includes("\\") || content.includes("&")) return null;
|
|
62
|
+
return {
|
|
63
|
+
start: token.start + 1,
|
|
64
|
+
end: token.end - 1,
|
|
65
|
+
next: index + 1
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (token.type === T.backQuote) {
|
|
69
|
+
const inner = tokens[index + 1];
|
|
70
|
+
if (inner?.type === T.backQuote) {
|
|
71
|
+
return {
|
|
72
|
+
start: token.end,
|
|
73
|
+
end: inner.start,
|
|
74
|
+
next: index + 2
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (inner?.type === T.template && tokens[index + 2]?.type === T.backQuote) {
|
|
78
|
+
if (text(inner).includes("\\")) return null;
|
|
79
|
+
return {
|
|
80
|
+
start: inner.start,
|
|
81
|
+
end: inner.end,
|
|
82
|
+
next: index + 3
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
const styledBindings = /* @__PURE__ */ new Set();
|
|
89
|
+
const componentNames = /* @__PURE__ */ new Set();
|
|
90
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
91
|
+
if (tokens[index].type !== T.import) continue;
|
|
92
|
+
let cursor = index + 1;
|
|
93
|
+
const specifiers = [];
|
|
94
|
+
let namespace = null;
|
|
95
|
+
let sawBrace = false;
|
|
96
|
+
while (cursor < tokens.length) {
|
|
97
|
+
const token = tokens[cursor];
|
|
98
|
+
if (token.type === T.string) break;
|
|
99
|
+
if (token.type === T.braceL) sawBrace = true;
|
|
100
|
+
if (token.type === T.star && tokens[cursor + 2]?.type === T.name) {
|
|
101
|
+
namespace = text(tokens[cursor + 2]);
|
|
102
|
+
cursor += 2;
|
|
103
|
+
}
|
|
104
|
+
if (token.type === T.name && sawBrace) {
|
|
105
|
+
const imported = text(token);
|
|
106
|
+
if (imported !== "as" && imported !== "type" && imported !== "from") {
|
|
107
|
+
let local = imported;
|
|
108
|
+
if (tokens[cursor + 1]?.type === T.name && text(tokens[cursor + 1]) === "as" && tokens[cursor + 2]?.type === T.name) {
|
|
109
|
+
local = text(tokens[cursor + 2]);
|
|
110
|
+
cursor += 2;
|
|
111
|
+
}
|
|
112
|
+
specifiers.push({
|
|
113
|
+
imported,
|
|
114
|
+
local
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
cursor++;
|
|
119
|
+
}
|
|
120
|
+
const moduleToken = tokens[cursor];
|
|
121
|
+
if (!moduleToken || moduleToken.type !== T.string) continue;
|
|
122
|
+
const moduleSource = source.slice(moduleToken.start + 1, moduleToken.end - 1);
|
|
123
|
+
if (!isTamaguiModule(moduleSource)) continue;
|
|
124
|
+
if (namespace) componentNames.add(namespace);
|
|
125
|
+
for (const specifier of specifiers) {
|
|
126
|
+
if (specifier.imported === "styled") {
|
|
127
|
+
styledBindings.add(specifier.local);
|
|
128
|
+
} else if (/^[A-Z]/.test(specifier.imported)) {
|
|
129
|
+
componentNames.add(specifier.local);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
index = cursor;
|
|
133
|
+
}
|
|
134
|
+
for (let index = 0; index + 3 < tokens.length; index++) {
|
|
135
|
+
if (tokens[index].type === T.name && tokens[index + 1].type === T.eq && tokens[index + 2].type === T.name && styledBindings.has(text(tokens[index + 2])) && tokens[index + 3].type === T.parenL) {
|
|
136
|
+
componentNames.add(text(tokens[index]));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const tagStack = [];
|
|
140
|
+
const styledStack = [];
|
|
141
|
+
let parenDepth = 0;
|
|
142
|
+
let braceDepth = 0;
|
|
143
|
+
const jsxRootAccepted = (name) => {
|
|
144
|
+
if (!name) return false;
|
|
145
|
+
if (options.allComponents) return /^[A-Z]/.test(name);
|
|
146
|
+
return componentNames.has(name);
|
|
147
|
+
};
|
|
148
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
149
|
+
const token = tokens[index];
|
|
150
|
+
if (token.type === T.parenL) parenDepth++;
|
|
151
|
+
else if (token.type === T.parenR) {
|
|
152
|
+
parenDepth--;
|
|
153
|
+
const styledContext2 = styledStack[styledStack.length - 1];
|
|
154
|
+
if (styledContext2 && parenDepth < styledContext2.parenDepth) styledStack.pop();
|
|
155
|
+
} else if (token.type === T.braceL || token.type === T.dollarBraceL) {
|
|
156
|
+
braceDepth++;
|
|
157
|
+
} else if (token.type === T.braceR) braceDepth--;
|
|
158
|
+
else if (token.type === T.jsxTagStart) {
|
|
159
|
+
const isClosing = tokens[index + 1]?.type === T.slash;
|
|
160
|
+
const root = !isClosing && tokens[index + 1]?.type === T.jsxName ? text(tokens[index + 1]) : null;
|
|
161
|
+
tagStack.push(root);
|
|
162
|
+
continue;
|
|
163
|
+
} else if (token.type === T.jsxTagEnd) {
|
|
164
|
+
tagStack.pop();
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (token.type === T.name && styledBindings.has(text(token)) && tokens[index + 1]?.type === T.parenL) {
|
|
168
|
+
styledStack.push({
|
|
169
|
+
parenDepth: parenDepth + 1,
|
|
170
|
+
braceDepth,
|
|
171
|
+
arg: 0
|
|
172
|
+
});
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const styledContext = styledStack[styledStack.length - 1];
|
|
176
|
+
if (styledContext && token.type === T.comma && parenDepth === styledContext.parenDepth && braceDepth === styledContext.braceDepth) {
|
|
177
|
+
styledContext.arg++;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (styledContext?.arg === 1 && (token.type === T.name || token.type === T.string) && (tokens[index - 1]?.type === T.braceL || tokens[index - 1]?.type === T.comma) && tokens[index + 1]?.type === T.colon && braceDepth > styledContext.braceDepth) {
|
|
181
|
+
const property = token.type === T.string ? source.slice(token.start + 1, token.end - 1) : text(token);
|
|
182
|
+
const content = stringContent(index + 2);
|
|
183
|
+
if (content && isStyleProp(property)) {
|
|
184
|
+
const after = tokens[content.next];
|
|
185
|
+
if (after?.type === T.comma || after?.type === T.braceR) {
|
|
186
|
+
sites.push({
|
|
187
|
+
property,
|
|
188
|
+
value: source.slice(content.start, content.end),
|
|
189
|
+
start: content.start,
|
|
190
|
+
end: content.end,
|
|
191
|
+
kind: "styled-property"
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (token.type === T.jsxName && tokens[index - 1]?.type !== T.jsxTagStart && tokens[index - 1]?.type !== T.dot && tokens[index - 1]?.type !== T.slash && jsxRootAccepted(tagStack[tagStack.length - 1] ?? null)) {
|
|
198
|
+
const property = text(token);
|
|
199
|
+
if (!isStyleProp(property)) continue;
|
|
200
|
+
if (tokens[index + 1]?.type !== T.eq) continue;
|
|
201
|
+
const valueIndex = index + 2;
|
|
202
|
+
let content = null;
|
|
203
|
+
if (tokens[valueIndex]?.type === T.braceL) {
|
|
204
|
+
const inner = stringContent(valueIndex + 1);
|
|
205
|
+
if (inner && tokens[inner.next]?.type === T.braceR) content = inner;
|
|
206
|
+
} else {
|
|
207
|
+
content = stringContent(valueIndex);
|
|
208
|
+
}
|
|
209
|
+
if (content) {
|
|
210
|
+
sites.push({
|
|
211
|
+
property,
|
|
212
|
+
value: source.slice(content.start, content.end),
|
|
213
|
+
start: content.start,
|
|
214
|
+
end: content.end,
|
|
215
|
+
kind: "jsx-attribute"
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return sites;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var extract_sucrase_exports = {};
|
|
25
|
+
__export(extract_sucrase_exports, { createSucraseStyleSiteExtractor: () => createSucraseStyleSiteExtractor });
|
|
26
|
+
module.exports = __toCommonJS(extract_sucrase_exports);
|
|
27
|
+
function defaultIsTamaguiModule(source) {
|
|
28
|
+
return source === "tamagui" || source.startsWith("tamagui/") || source.startsWith("@tamagui/");
|
|
29
|
+
}
|
|
30
|
+
function createSucraseStyleSiteExtractor(parser) {
|
|
31
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
32
|
+
var { TokenType } = parser;
|
|
33
|
+
var T = {
|
|
34
|
+
import: TokenType._import,
|
|
35
|
+
string: TokenType.string,
|
|
36
|
+
name: TokenType.name,
|
|
37
|
+
comma: TokenType.comma,
|
|
38
|
+
colon: TokenType.colon,
|
|
39
|
+
eq: TokenType.eq,
|
|
40
|
+
dot: TokenType.dot,
|
|
41
|
+
star: TokenType.star,
|
|
42
|
+
slash: TokenType.slash,
|
|
43
|
+
braceL: TokenType.braceL,
|
|
44
|
+
braceR: TokenType.braceR,
|
|
45
|
+
dollarBraceL: TokenType.dollarBraceL,
|
|
46
|
+
parenL: TokenType.parenL,
|
|
47
|
+
parenR: TokenType.parenR,
|
|
48
|
+
backQuote: TokenType.backQuote,
|
|
49
|
+
template: TokenType.template,
|
|
50
|
+
jsxTagStart: TokenType.jsxTagStart,
|
|
51
|
+
jsxTagEnd: TokenType.jsxTagEnd,
|
|
52
|
+
jsxName: TokenType.jsxName
|
|
53
|
+
};
|
|
54
|
+
var _options_isStyleProp;
|
|
55
|
+
var isStyleProp = (_options_isStyleProp = options.isStyleProp) !== null && _options_isStyleProp !== void 0 ? _options_isStyleProp : function() {
|
|
56
|
+
return true;
|
|
57
|
+
};
|
|
58
|
+
var _options_isTamaguiModule;
|
|
59
|
+
var isTamaguiModule = (_options_isTamaguiModule = options.isTamaguiModule) !== null && _options_isTamaguiModule !== void 0 ? _options_isTamaguiModule : defaultIsTamaguiModule;
|
|
60
|
+
return function(source) {
|
|
61
|
+
var tokens = parser.parse(source, true, true, false).tokens;
|
|
62
|
+
var sites = [];
|
|
63
|
+
var text = function(token2) {
|
|
64
|
+
return source.slice(token2.start, token2.end);
|
|
65
|
+
};
|
|
66
|
+
var stringContent = function(index3) {
|
|
67
|
+
var token2 = tokens[index3];
|
|
68
|
+
if (token2.type === T.string) {
|
|
69
|
+
var content2 = source.slice(token2.start + 1, token2.end - 1);
|
|
70
|
+
if (content2.includes("\\") || content2.includes("&")) return null;
|
|
71
|
+
return {
|
|
72
|
+
start: token2.start + 1,
|
|
73
|
+
end: token2.end - 1,
|
|
74
|
+
next: index3 + 1
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (token2.type === T.backQuote) {
|
|
78
|
+
var _tokens_13;
|
|
79
|
+
var inner2 = tokens[index3 + 1];
|
|
80
|
+
if ((inner2 === null || inner2 === void 0 ? void 0 : inner2.type) === T.backQuote) {
|
|
81
|
+
return {
|
|
82
|
+
start: token2.end,
|
|
83
|
+
end: inner2.start,
|
|
84
|
+
next: index3 + 2
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if ((inner2 === null || inner2 === void 0 ? void 0 : inner2.type) === T.template && ((_tokens_13 = tokens[index3 + 2]) === null || _tokens_13 === void 0 ? void 0 : _tokens_13.type) === T.backQuote) {
|
|
88
|
+
if (text(inner2).includes("\\")) return null;
|
|
89
|
+
return {
|
|
90
|
+
start: inner2.start,
|
|
91
|
+
end: inner2.end,
|
|
92
|
+
next: index3 + 3
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
var styledBindings = /* @__PURE__ */ new Set();
|
|
99
|
+
var componentNames = /* @__PURE__ */ new Set();
|
|
100
|
+
for (var index = 0; index < tokens.length; index++) {
|
|
101
|
+
if (tokens[index].type !== T.import) continue;
|
|
102
|
+
var cursor = index + 1;
|
|
103
|
+
var specifiers = [];
|
|
104
|
+
var namespace = null;
|
|
105
|
+
var sawBrace = false;
|
|
106
|
+
while (cursor < tokens.length) {
|
|
107
|
+
var _tokens_;
|
|
108
|
+
var token = tokens[cursor];
|
|
109
|
+
if (token.type === T.string) break;
|
|
110
|
+
if (token.type === T.braceL) sawBrace = true;
|
|
111
|
+
if (token.type === T.star && ((_tokens_ = tokens[cursor + 2]) === null || _tokens_ === void 0 ? void 0 : _tokens_.type) === T.name) {
|
|
112
|
+
namespace = text(tokens[cursor + 2]);
|
|
113
|
+
cursor += 2;
|
|
114
|
+
}
|
|
115
|
+
if (token.type === T.name && sawBrace) {
|
|
116
|
+
var imported = text(token);
|
|
117
|
+
if (imported !== "as" && imported !== "type" && imported !== "from") {
|
|
118
|
+
var _tokens_1, _tokens_2;
|
|
119
|
+
var local = imported;
|
|
120
|
+
if (((_tokens_1 = tokens[cursor + 1]) === null || _tokens_1 === void 0 ? void 0 : _tokens_1.type) === T.name && text(tokens[cursor + 1]) === "as" && ((_tokens_2 = tokens[cursor + 2]) === null || _tokens_2 === void 0 ? void 0 : _tokens_2.type) === T.name) {
|
|
121
|
+
local = text(tokens[cursor + 2]);
|
|
122
|
+
cursor += 2;
|
|
123
|
+
}
|
|
124
|
+
specifiers.push({
|
|
125
|
+
imported,
|
|
126
|
+
local
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
cursor++;
|
|
131
|
+
}
|
|
132
|
+
var moduleToken = tokens[cursor];
|
|
133
|
+
if (!moduleToken || moduleToken.type !== T.string) continue;
|
|
134
|
+
var moduleSource = source.slice(moduleToken.start + 1, moduleToken.end - 1);
|
|
135
|
+
if (!isTamaguiModule(moduleSource)) continue;
|
|
136
|
+
if (namespace) componentNames.add(namespace);
|
|
137
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
138
|
+
try {
|
|
139
|
+
for (var _iterator = specifiers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
140
|
+
var specifier = _step.value;
|
|
141
|
+
if (specifier.imported === "styled") {
|
|
142
|
+
styledBindings.add(specifier.local);
|
|
143
|
+
} else if (/^[A-Z]/.test(specifier.imported)) {
|
|
144
|
+
componentNames.add(specifier.local);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
_didIteratorError = true;
|
|
149
|
+
_iteratorError = err;
|
|
150
|
+
} finally {
|
|
151
|
+
try {
|
|
152
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
153
|
+
_iterator.return();
|
|
154
|
+
}
|
|
155
|
+
} finally {
|
|
156
|
+
if (_didIteratorError) {
|
|
157
|
+
throw _iteratorError;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
index = cursor;
|
|
162
|
+
}
|
|
163
|
+
for (var index1 = 0; index1 + 3 < tokens.length; index1++) {
|
|
164
|
+
if (tokens[index1].type === T.name && tokens[index1 + 1].type === T.eq && tokens[index1 + 2].type === T.name && styledBindings.has(text(tokens[index1 + 2])) && tokens[index1 + 3].type === T.parenL) {
|
|
165
|
+
componentNames.add(text(tokens[index1]));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
var tagStack = [];
|
|
169
|
+
var styledStack = [];
|
|
170
|
+
var parenDepth = 0;
|
|
171
|
+
var braceDepth = 0;
|
|
172
|
+
var jsxRootAccepted = function(name) {
|
|
173
|
+
if (!name) return false;
|
|
174
|
+
if (options.allComponents) return /^[A-Z]/.test(name);
|
|
175
|
+
return componentNames.has(name);
|
|
176
|
+
};
|
|
177
|
+
for (var index2 = 0; index2 < tokens.length; index2++) {
|
|
178
|
+
var _tokens_3, _tokens_4, _tokens_5, _tokens_6, _tokens_7, _tokens_8, _tokens_9;
|
|
179
|
+
var token1 = tokens[index2];
|
|
180
|
+
if (token1.type === T.parenL) parenDepth++;
|
|
181
|
+
else if (token1.type === T.parenR) {
|
|
182
|
+
parenDepth--;
|
|
183
|
+
var styledContext = styledStack[styledStack.length - 1];
|
|
184
|
+
if (styledContext && parenDepth < styledContext.parenDepth) styledStack.pop();
|
|
185
|
+
} else if (token1.type === T.braceL || token1.type === T.dollarBraceL) {
|
|
186
|
+
braceDepth++;
|
|
187
|
+
} else if (token1.type === T.braceR) braceDepth--;
|
|
188
|
+
else if (token1.type === T.jsxTagStart) {
|
|
189
|
+
var _tokens_10, _tokens_11;
|
|
190
|
+
var isClosing = ((_tokens_10 = tokens[index2 + 1]) === null || _tokens_10 === void 0 ? void 0 : _tokens_10.type) === T.slash;
|
|
191
|
+
var root = !isClosing && ((_tokens_11 = tokens[index2 + 1]) === null || _tokens_11 === void 0 ? void 0 : _tokens_11.type) === T.jsxName ? text(tokens[index2 + 1]) : null;
|
|
192
|
+
tagStack.push(root);
|
|
193
|
+
continue;
|
|
194
|
+
} else if (token1.type === T.jsxTagEnd) {
|
|
195
|
+
tagStack.pop();
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (token1.type === T.name && styledBindings.has(text(token1)) && ((_tokens_3 = tokens[index2 + 1]) === null || _tokens_3 === void 0 ? void 0 : _tokens_3.type) === T.parenL) {
|
|
199
|
+
styledStack.push({
|
|
200
|
+
parenDepth: parenDepth + 1,
|
|
201
|
+
braceDepth,
|
|
202
|
+
arg: 0
|
|
203
|
+
});
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
var styledContext1 = styledStack[styledStack.length - 1];
|
|
207
|
+
if (styledContext1 && token1.type === T.comma && parenDepth === styledContext1.parenDepth && braceDepth === styledContext1.braceDepth) {
|
|
208
|
+
styledContext1.arg++;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if ((styledContext1 === null || styledContext1 === void 0 ? void 0 : styledContext1.arg) === 1 && (token1.type === T.name || token1.type === T.string) && (((_tokens_4 = tokens[index2 - 1]) === null || _tokens_4 === void 0 ? void 0 : _tokens_4.type) === T.braceL || ((_tokens_5 = tokens[index2 - 1]) === null || _tokens_5 === void 0 ? void 0 : _tokens_5.type) === T.comma) && ((_tokens_6 = tokens[index2 + 1]) === null || _tokens_6 === void 0 ? void 0 : _tokens_6.type) === T.colon && braceDepth > styledContext1.braceDepth) {
|
|
212
|
+
var property = token1.type === T.string ? source.slice(token1.start + 1, token1.end - 1) : text(token1);
|
|
213
|
+
var content = stringContent(index2 + 2);
|
|
214
|
+
if (content && isStyleProp(property)) {
|
|
215
|
+
var after = tokens[content.next];
|
|
216
|
+
if ((after === null || after === void 0 ? void 0 : after.type) === T.comma || (after === null || after === void 0 ? void 0 : after.type) === T.braceR) {
|
|
217
|
+
sites.push({
|
|
218
|
+
property,
|
|
219
|
+
value: source.slice(content.start, content.end),
|
|
220
|
+
start: content.start,
|
|
221
|
+
end: content.end,
|
|
222
|
+
kind: "styled-property"
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
var _tagStack_;
|
|
229
|
+
if (token1.type === T.jsxName && ((_tokens_7 = tokens[index2 - 1]) === null || _tokens_7 === void 0 ? void 0 : _tokens_7.type) !== T.jsxTagStart && ((_tokens_8 = tokens[index2 - 1]) === null || _tokens_8 === void 0 ? void 0 : _tokens_8.type) !== T.dot && ((_tokens_9 = tokens[index2 - 1]) === null || _tokens_9 === void 0 ? void 0 : _tokens_9.type) !== T.slash && jsxRootAccepted((_tagStack_ = tagStack[tagStack.length - 1]) !== null && _tagStack_ !== void 0 ? _tagStack_ : null)) {
|
|
230
|
+
var _tokens_12, _tokens_valueIndex;
|
|
231
|
+
var property1 = text(token1);
|
|
232
|
+
if (!isStyleProp(property1)) continue;
|
|
233
|
+
if (((_tokens_12 = tokens[index2 + 1]) === null || _tokens_12 === void 0 ? void 0 : _tokens_12.type) !== T.eq) continue;
|
|
234
|
+
var valueIndex = index2 + 2;
|
|
235
|
+
var content1 = null;
|
|
236
|
+
if (((_tokens_valueIndex = tokens[valueIndex]) === null || _tokens_valueIndex === void 0 ? void 0 : _tokens_valueIndex.type) === T.braceL) {
|
|
237
|
+
var _tokens_inner_next;
|
|
238
|
+
var inner = stringContent(valueIndex + 1);
|
|
239
|
+
if (inner && ((_tokens_inner_next = tokens[inner.next]) === null || _tokens_inner_next === void 0 ? void 0 : _tokens_inner_next.type) === T.braceR) content1 = inner;
|
|
240
|
+
} else {
|
|
241
|
+
content1 = stringContent(valueIndex);
|
|
242
|
+
}
|
|
243
|
+
if (content1) {
|
|
244
|
+
sites.push({
|
|
245
|
+
property: property1,
|
|
246
|
+
value: source.slice(content1.start, content1.end),
|
|
247
|
+
start: content1.start,
|
|
248
|
+
end: content1.end,
|
|
249
|
+
kind: "jsx-attribute"
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return sites;
|
|
255
|
+
};
|
|
256
|
+
}
|