@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,371 @@
|
|
|
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 check_exports = {};
|
|
25
|
+
__export(check_exports, {
|
|
26
|
+
MissingConfigArtifactError: () => MissingConfigArtifactError,
|
|
27
|
+
checkStyleFiles: () => checkStyleFiles,
|
|
28
|
+
createProjectExtractor: () => createProjectExtractor,
|
|
29
|
+
formatCheckResults: () => formatCheckResults
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(check_exports);
|
|
32
|
+
var import_fs = require("fs");
|
|
33
|
+
var import_path = require("path");
|
|
34
|
+
var import_parser = require("sucrase/dist/parser/index.js");
|
|
35
|
+
var import_types = require("sucrase/dist/parser/tokenizer/types.js");
|
|
36
|
+
var import_core = require("./core.native.js");
|
|
37
|
+
var import_document = require("./document.native.js");
|
|
38
|
+
var import_extract_sucrase = require("./extract-sucrase.native.js");
|
|
39
|
+
function _assert_this_initialized(self) {
|
|
40
|
+
if (self === void 0) {
|
|
41
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
42
|
+
}
|
|
43
|
+
return self;
|
|
44
|
+
}
|
|
45
|
+
function _call_super(_this, derived, args) {
|
|
46
|
+
derived = _get_prototype_of(derived);
|
|
47
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
48
|
+
}
|
|
49
|
+
function _class_call_check(instance, Constructor) {
|
|
50
|
+
if (!(instance instanceof Constructor)) {
|
|
51
|
+
throw new TypeError("Cannot call a class as a function");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function _construct(Parent, args, Class) {
|
|
55
|
+
if (_is_native_reflect_construct()) {
|
|
56
|
+
_construct = Reflect.construct;
|
|
57
|
+
} else {
|
|
58
|
+
_construct = function construct(Parent2, args2, Class2) {
|
|
59
|
+
var a = [null];
|
|
60
|
+
a.push.apply(a, args2);
|
|
61
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
62
|
+
var instance = new Constructor();
|
|
63
|
+
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
64
|
+
return instance;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return _construct.apply(null, arguments);
|
|
68
|
+
}
|
|
69
|
+
function _get_prototype_of(o) {
|
|
70
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
71
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
72
|
+
};
|
|
73
|
+
return _get_prototype_of(o);
|
|
74
|
+
}
|
|
75
|
+
function _inherits(subClass, superClass) {
|
|
76
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
77
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
78
|
+
}
|
|
79
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: {
|
|
80
|
+
value: subClass,
|
|
81
|
+
writable: true,
|
|
82
|
+
configurable: true
|
|
83
|
+
} });
|
|
84
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
85
|
+
}
|
|
86
|
+
function _is_native_function(fn) {
|
|
87
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
88
|
+
}
|
|
89
|
+
function _possible_constructor_return(self, call) {
|
|
90
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
91
|
+
return call;
|
|
92
|
+
}
|
|
93
|
+
return _assert_this_initialized(self);
|
|
94
|
+
}
|
|
95
|
+
function _set_prototype_of(o, p) {
|
|
96
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
97
|
+
o2.__proto__ = p2;
|
|
98
|
+
return o2;
|
|
99
|
+
};
|
|
100
|
+
return _set_prototype_of(o, p);
|
|
101
|
+
}
|
|
102
|
+
function _type_of(obj) {
|
|
103
|
+
"@swc/helpers - typeof";
|
|
104
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
105
|
+
}
|
|
106
|
+
function _wrap_native_super(Class) {
|
|
107
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
108
|
+
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
109
|
+
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
110
|
+
if (typeof Class2 !== "function") {
|
|
111
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
112
|
+
}
|
|
113
|
+
if (typeof _cache !== "undefined") {
|
|
114
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
115
|
+
_cache.set(Class2, Wrapper);
|
|
116
|
+
}
|
|
117
|
+
function Wrapper() {
|
|
118
|
+
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
119
|
+
}
|
|
120
|
+
Wrapper.prototype = Object.create(Class2.prototype, { constructor: {
|
|
121
|
+
value: Wrapper,
|
|
122
|
+
enumerable: false,
|
|
123
|
+
writable: true,
|
|
124
|
+
configurable: true
|
|
125
|
+
} });
|
|
126
|
+
return _set_prototype_of(Wrapper, Class2);
|
|
127
|
+
};
|
|
128
|
+
return _wrap_native_super(Class);
|
|
129
|
+
}
|
|
130
|
+
function _is_native_reflect_construct() {
|
|
131
|
+
try {
|
|
132
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
133
|
+
} catch (_) {}
|
|
134
|
+
return (_is_native_reflect_construct = function() {
|
|
135
|
+
return !!result;
|
|
136
|
+
})();
|
|
137
|
+
}
|
|
138
|
+
var sourceExtensions = /\.(tsx|jsx)$/;
|
|
139
|
+
var skippedDirectories = /* @__PURE__ */ new Set([
|
|
140
|
+
"node_modules",
|
|
141
|
+
"dist",
|
|
142
|
+
"build",
|
|
143
|
+
"out",
|
|
144
|
+
"coverage",
|
|
145
|
+
".git",
|
|
146
|
+
".next",
|
|
147
|
+
".expo",
|
|
148
|
+
".tamagui"
|
|
149
|
+
]);
|
|
150
|
+
var MissingConfigArtifactError = /* @__PURE__ */ (function(Error1) {
|
|
151
|
+
"use strict";
|
|
152
|
+
_inherits(MissingConfigArtifactError2, Error1);
|
|
153
|
+
function MissingConfigArtifactError2(configPath) {
|
|
154
|
+
_class_call_check(this, MissingConfigArtifactError2);
|
|
155
|
+
var _this;
|
|
156
|
+
_this = _call_super(this, MissingConfigArtifactError2, [`no Tamagui config artifact at ${configPath} \u2014 run your dev server or \`tamagui generate\` once so the compiler emits it`]);
|
|
157
|
+
_this.name = "MissingConfigArtifactError";
|
|
158
|
+
return _this;
|
|
159
|
+
}
|
|
160
|
+
return MissingConfigArtifactError2;
|
|
161
|
+
})(_wrap_native_super(Error));
|
|
162
|
+
function walkSourceFiles(directory, results) {
|
|
163
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
164
|
+
try {
|
|
165
|
+
for (var _iterator = (0, import_fs.readdirSync)(directory, { withFileTypes: true })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
166
|
+
var entry = _step.value;
|
|
167
|
+
if (entry.isDirectory()) {
|
|
168
|
+
if (!skippedDirectories.has(entry.name) && !entry.name.startsWith(".")) {
|
|
169
|
+
walkSourceFiles((0, import_path.join)(directory, entry.name), results);
|
|
170
|
+
}
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (sourceExtensions.test(entry.name)) results.push((0, import_path.join)(directory, entry.name));
|
|
174
|
+
}
|
|
175
|
+
} catch (err) {
|
|
176
|
+
_didIteratorError = true;
|
|
177
|
+
_iteratorError = err;
|
|
178
|
+
} finally {
|
|
179
|
+
try {
|
|
180
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
181
|
+
_iterator.return();
|
|
182
|
+
}
|
|
183
|
+
} finally {
|
|
184
|
+
if (_didIteratorError) {
|
|
185
|
+
throw _iteratorError;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function createProjectExtractor(isStyleProp) {
|
|
191
|
+
return (0, import_extract_sucrase.createSucraseStyleSiteExtractor)({
|
|
192
|
+
parse: import_parser.parse,
|
|
193
|
+
TokenType: import_types.TokenType
|
|
194
|
+
}, { isStyleProp });
|
|
195
|
+
}
|
|
196
|
+
function checkStyleFiles(options) {
|
|
197
|
+
var _options_configPath;
|
|
198
|
+
var configPath = (_options_configPath = options.configPath) !== null && _options_configPath !== void 0 ? _options_configPath : (0, import_path.join)(options.root, ".tamagui", "tamagui.config.json");
|
|
199
|
+
var contents;
|
|
200
|
+
try {
|
|
201
|
+
contents = (0, import_fs.readFileSync)(configPath, "utf8");
|
|
202
|
+
} catch (e) {
|
|
203
|
+
throw new MissingConfigArtifactError(configPath);
|
|
204
|
+
}
|
|
205
|
+
var tooling = (0, import_core.createStyleTooling)(JSON.parse(contents));
|
|
206
|
+
if (!tooling) throw new MissingConfigArtifactError(configPath);
|
|
207
|
+
var document = (0, import_document.createDocumentStyleTooling)(tooling, createProjectExtractor(function(name) {
|
|
208
|
+
return tooling.isStyleProp(name);
|
|
209
|
+
}));
|
|
210
|
+
var files;
|
|
211
|
+
if (options.files) {
|
|
212
|
+
files = [...options.files];
|
|
213
|
+
} else {
|
|
214
|
+
files = [];
|
|
215
|
+
walkSourceFiles(options.root, files);
|
|
216
|
+
files.sort();
|
|
217
|
+
}
|
|
218
|
+
var checked = [];
|
|
219
|
+
var diagnosticCount = 0;
|
|
220
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
221
|
+
try {
|
|
222
|
+
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
223
|
+
var file = _step.value;
|
|
224
|
+
var source = void 0;
|
|
225
|
+
try {
|
|
226
|
+
source = (0, import_fs.readFileSync)(file, "utf8");
|
|
227
|
+
} catch (e) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
var diagnostics = void 0;
|
|
231
|
+
try {
|
|
232
|
+
diagnostics = document.diagnostics(source);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (diagnostics.length === 0) continue;
|
|
237
|
+
diagnosticCount += diagnostics.length;
|
|
238
|
+
checked.push({
|
|
239
|
+
file: (0, import_path.relative)(options.root, file),
|
|
240
|
+
source,
|
|
241
|
+
diagnostics
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_didIteratorError = true;
|
|
246
|
+
_iteratorError = err;
|
|
247
|
+
} finally {
|
|
248
|
+
try {
|
|
249
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
250
|
+
_iterator.return();
|
|
251
|
+
}
|
|
252
|
+
} finally {
|
|
253
|
+
if (_didIteratorError) {
|
|
254
|
+
throw _iteratorError;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
files: checked,
|
|
260
|
+
checkedFileCount: files.length,
|
|
261
|
+
diagnosticCount
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
var ansi = {
|
|
265
|
+
red: function(text) {
|
|
266
|
+
return `\x1B[31m${text}\x1B[39m`;
|
|
267
|
+
},
|
|
268
|
+
dim: function(text) {
|
|
269
|
+
return `\x1B[2m${text}\x1B[22m`;
|
|
270
|
+
},
|
|
271
|
+
bold: function(text) {
|
|
272
|
+
return `\x1B[1m${text}\x1B[22m`;
|
|
273
|
+
},
|
|
274
|
+
cyan: function(text) {
|
|
275
|
+
return `\x1B[36m${text}\x1B[39m`;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
var plain = {
|
|
279
|
+
red: function(text) {
|
|
280
|
+
return text;
|
|
281
|
+
},
|
|
282
|
+
dim: function(text) {
|
|
283
|
+
return text;
|
|
284
|
+
},
|
|
285
|
+
bold: function(text) {
|
|
286
|
+
return text;
|
|
287
|
+
},
|
|
288
|
+
cyan: function(text) {
|
|
289
|
+
return text;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
function lineStarts(source) {
|
|
293
|
+
var starts = [0];
|
|
294
|
+
for (var index = 0; index < source.length; index++) {
|
|
295
|
+
if (source.charCodeAt(index) === 10) starts.push(index + 1);
|
|
296
|
+
}
|
|
297
|
+
return starts;
|
|
298
|
+
}
|
|
299
|
+
function positionOf(starts, offset) {
|
|
300
|
+
var low = 0;
|
|
301
|
+
var high = starts.length - 1;
|
|
302
|
+
while (low < high) {
|
|
303
|
+
var mid = low + high + 1 >> 1;
|
|
304
|
+
if (starts[mid] <= offset) low = mid;
|
|
305
|
+
else high = mid - 1;
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
line: low,
|
|
309
|
+
column: offset - starts[low]
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function formatCheckResults(result) {
|
|
313
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
314
|
+
var paint = options.color === false ? plain : ansi;
|
|
315
|
+
var output = [];
|
|
316
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
317
|
+
try {
|
|
318
|
+
for (var _iterator = result.files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
319
|
+
var checked = _step.value;
|
|
320
|
+
var starts = lineStarts(checked.source);
|
|
321
|
+
var lines = checked.source.split("\n");
|
|
322
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
323
|
+
try {
|
|
324
|
+
for (var _iterator1 = checked.diagnostics[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
325
|
+
var diagnostic = _step1.value;
|
|
326
|
+
var start = positionOf(starts, diagnostic.start);
|
|
327
|
+
var end = positionOf(starts, diagnostic.end);
|
|
328
|
+
output.push(`${paint.bold(checked.file)}${paint.dim(`:${start.line + 1}:${start.column + 1}`)} ${paint.red("error")} ${diagnostic.message}`);
|
|
329
|
+
var _lines_start_line;
|
|
330
|
+
var line = (_lines_start_line = lines[start.line]) !== null && _lines_start_line !== void 0 ? _lines_start_line : "";
|
|
331
|
+
var gutter = String(start.line + 1);
|
|
332
|
+
output.push(` ${paint.dim(`${gutter} \u2502`)} ${line}`);
|
|
333
|
+
var underlineLength = end.line === start.line ? Math.max(1, end.column - start.column) : Math.max(1, line.length - start.column);
|
|
334
|
+
output.push(` ${paint.dim(`${" ".repeat(gutter.length)} \u2502`)} ${" ".repeat(start.column)}${paint.red("^".repeat(underlineLength))}`);
|
|
335
|
+
output.push("");
|
|
336
|
+
}
|
|
337
|
+
} catch (err) {
|
|
338
|
+
_didIteratorError1 = true;
|
|
339
|
+
_iteratorError1 = err;
|
|
340
|
+
} finally {
|
|
341
|
+
try {
|
|
342
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
343
|
+
_iterator1.return();
|
|
344
|
+
}
|
|
345
|
+
} finally {
|
|
346
|
+
if (_didIteratorError1) {
|
|
347
|
+
throw _iteratorError1;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} catch (err) {
|
|
353
|
+
_didIteratorError = true;
|
|
354
|
+
_iteratorError = err;
|
|
355
|
+
} finally {
|
|
356
|
+
try {
|
|
357
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
358
|
+
_iterator.return();
|
|
359
|
+
}
|
|
360
|
+
} finally {
|
|
361
|
+
if (_didIteratorError) {
|
|
362
|
+
throw _iteratorError;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
var summary = result.diagnosticCount === 0 ? `${paint.bold("✓")} ${result.checkedFileCount} files, no flat value problems` : `${paint.red(paint.bold(`\u2717 ${result.diagnosticCount} problem${result.diagnosticCount === 1 ? "" : "s"}`))} in ${result.files.length} file${result.files.length === 1 ? "" : "s"} ${paint.dim(`(${result.checkedFileCount} checked)`)}`;
|
|
367
|
+
output.push(summary);
|
|
368
|
+
return output.join("\n");
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
//# sourceMappingURL=check.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.native.js","names":[],"sources":["cjs/check.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar check_exports = {};\n__export(check_exports, {\n MissingConfigArtifactError: () => MissingConfigArtifactError,\n checkStyleFiles: () => checkStyleFiles,\n createProjectExtractor: () => createProjectExtractor,\n formatCheckResults: () => formatCheckResults\n});\nmodule.exports = __toCommonJS(check_exports);\nvar import_fs = require(\"fs\");\nvar import_path = require(\"path\");\nvar import_parser = require(\"sucrase/dist/parser/index.js\");\nvar import_types = require(\"sucrase/dist/parser/tokenizer/types.js\");\nvar import_core = require(\"./core\");\nvar import_document = require(\"./document\");\nvar import_extract_sucrase = require(\"./extract-sucrase\");\nfunction _assert_this_initialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n}\nfunction _call_super(_this, derived, args) {\n derived = _get_prototype_of(derived);\n return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));\n}\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _construct(Parent, args, Class) {\n if (_is_native_reflect_construct()) {\n _construct = Reflect.construct;\n } else {\n _construct = function construct(Parent2, args2, Class2) {\n var a = [\n null\n ];\n a.push.apply(a, args2);\n var Constructor = Function.bind.apply(Parent2, a);\n var instance = new Constructor();\n if (Class2) _set_prototype_of(instance, Class2.prototype);\n return instance;\n };\n }\n return _construct.apply(null, arguments);\n}\nfunction _get_prototype_of(o) {\n _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {\n return o2.__proto__ || Object.getPrototypeOf(o2);\n };\n return _get_prototype_of(o);\n}\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _set_prototype_of(subClass, superClass);\n}\nfunction _is_native_function(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\nfunction _possible_constructor_return(self, call) {\n if (call && (_type_of(call) === \"object\" || typeof call === \"function\")) {\n return call;\n }\n return _assert_this_initialized(self);\n}\nfunction _set_prototype_of(o, p) {\n _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {\n o2.__proto__ = p2;\n return o2;\n };\n return _set_prototype_of(o, p);\n}\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nfunction _wrap_native_super(Class) {\n var _cache = typeof Map === \"function\" ? /* @__PURE__ */ new Map() : void 0;\n _wrap_native_super = function wrapNativeSuper(Class2) {\n if (Class2 === null || !_is_native_function(Class2)) return Class2;\n if (typeof Class2 !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class2)) return _cache.get(Class2);\n _cache.set(Class2, Wrapper);\n }\n function Wrapper() {\n return _construct(Class2, arguments, _get_prototype_of(this).constructor);\n }\n Wrapper.prototype = Object.create(Class2.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _set_prototype_of(Wrapper, Class2);\n };\n return _wrap_native_super(Class);\n}\nfunction _is_native_reflect_construct() {\n try {\n var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {\n }));\n } catch (_) {\n }\n return (_is_native_reflect_construct = function() {\n return !!result;\n })();\n}\nvar sourceExtensions = /\\.(tsx|jsx)$/;\nvar skippedDirectories = /* @__PURE__ */ new Set([\n \"node_modules\",\n \"dist\",\n \"build\",\n \"out\",\n \"coverage\",\n \".git\",\n \".next\",\n \".expo\",\n \".tamagui\"\n]);\nvar MissingConfigArtifactError = /* @__PURE__ */ (function(Error1) {\n \"use strict\";\n _inherits(MissingConfigArtifactError2, Error1);\n function MissingConfigArtifactError2(configPath) {\n _class_call_check(this, MissingConfigArtifactError2);\n var _this;\n _this = _call_super(this, MissingConfigArtifactError2, [\n `no Tamagui config artifact at ${configPath} \\u2014 run your dev server or \\`tamagui generate\\` once so the compiler emits it`\n ]);\n _this.name = \"MissingConfigArtifactError\";\n return _this;\n }\n return MissingConfigArtifactError2;\n})(_wrap_native_super(Error));\nfunction walkSourceFiles(directory, results) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = (0, import_fs.readdirSync)(directory, {\n withFileTypes: true\n })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n if (entry.isDirectory()) {\n if (!skippedDirectories.has(entry.name) && !entry.name.startsWith(\".\")) {\n walkSourceFiles((0, import_path.join)(directory, entry.name), results);\n }\n continue;\n }\n if (sourceExtensions.test(entry.name)) results.push((0, import_path.join)(directory, entry.name));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createProjectExtractor(isStyleProp) {\n return (0, import_extract_sucrase.createSucraseStyleSiteExtractor)({\n parse: import_parser.parse,\n TokenType: import_types.TokenType\n }, {\n isStyleProp\n });\n}\nfunction checkStyleFiles(options) {\n var _options_configPath;\n var configPath = (_options_configPath = options.configPath) !== null && _options_configPath !== void 0 ? _options_configPath : (0, import_path.join)(options.root, \".tamagui\", \"tamagui.config.json\");\n var contents;\n try {\n contents = (0, import_fs.readFileSync)(configPath, \"utf8\");\n } catch (e) {\n throw new MissingConfigArtifactError(configPath);\n }\n var tooling = (0, import_core.createStyleTooling)(JSON.parse(contents));\n if (!tooling) throw new MissingConfigArtifactError(configPath);\n var document = (0, import_document.createDocumentStyleTooling)(tooling, createProjectExtractor(function(name) {\n return tooling.isStyleProp(name);\n }));\n var files;\n if (options.files) {\n files = [\n ...options.files\n ];\n } else {\n files = [];\n walkSourceFiles(options.root, files);\n files.sort();\n }\n var checked = [];\n var diagnosticCount = 0;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var file = _step.value;\n var source = void 0;\n try {\n source = (0, import_fs.readFileSync)(file, \"utf8\");\n } catch (e) {\n continue;\n }\n var diagnostics = void 0;\n try {\n diagnostics = document.diagnostics(source);\n } catch (e) {\n continue;\n }\n if (diagnostics.length === 0) continue;\n diagnosticCount += diagnostics.length;\n checked.push({\n file: (0, import_path.relative)(options.root, file),\n source,\n diagnostics\n });\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return {\n files: checked,\n checkedFileCount: files.length,\n diagnosticCount\n };\n}\nvar ansi = {\n red: function(text) {\n return `\\x1B[31m${text}\\x1B[39m`;\n },\n dim: function(text) {\n return `\\x1B[2m${text}\\x1B[22m`;\n },\n bold: function(text) {\n return `\\x1B[1m${text}\\x1B[22m`;\n },\n cyan: function(text) {\n return `\\x1B[36m${text}\\x1B[39m`;\n }\n};\nvar plain = {\n red: function(text) {\n return text;\n },\n dim: function(text) {\n return text;\n },\n bold: function(text) {\n return text;\n },\n cyan: function(text) {\n return text;\n }\n};\nfunction lineStarts(source) {\n var starts = [\n 0\n ];\n for (var index = 0; index < source.length; index++) {\n if (source.charCodeAt(index) === 10) starts.push(index + 1);\n }\n return starts;\n}\nfunction positionOf(starts, offset) {\n var low = 0;\n var high = starts.length - 1;\n while (low < high) {\n var mid = low + high + 1 >> 1;\n if (starts[mid] <= offset) low = mid;\n else high = mid - 1;\n }\n return {\n line: low,\n column: offset - starts[low]\n };\n}\nfunction formatCheckResults(result) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var paint = options.color === false ? plain : ansi;\n var output = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = result.files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var checked = _step.value;\n var starts = lineStarts(checked.source);\n var lines = checked.source.split(\"\\n\");\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = checked.diagnostics[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var diagnostic = _step1.value;\n var start = positionOf(starts, diagnostic.start);\n var end = positionOf(starts, diagnostic.end);\n output.push(`${paint.bold(checked.file)}${paint.dim(`:${start.line + 1}:${start.column + 1}`)} ${paint.red(\"error\")} ${diagnostic.message}`);\n var _lines_start_line;\n var line = (_lines_start_line = lines[start.line]) !== null && _lines_start_line !== void 0 ? _lines_start_line : \"\";\n var gutter = String(start.line + 1);\n output.push(` ${paint.dim(`${gutter} \\u2502`)} ${line}`);\n var underlineLength = end.line === start.line ? Math.max(1, end.column - start.column) : Math.max(1, line.length - start.column);\n output.push(` ${paint.dim(`${\" \".repeat(gutter.length)} \\u2502`)} ${\" \".repeat(start.column)}${paint.red(\"^\".repeat(underlineLength))}`);\n output.push(\"\");\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n var summary = result.diagnosticCount === 0 ? `${paint.bold(\"\\u2713\")} ${result.checkedFileCount} files, no flat value problems` : `${paint.red(paint.bold(`\\u2717 ${result.diagnosticCount} problem${result.diagnosticCount === 1 ? \"\" : \"s\"}`))} in ${result.files.length} file${result.files.length === 1 ? \"\" : \"s\"} ${paint.dim(`(${result.checkedFileCount} checked)`)}`;\n output.push(summary);\n return output.join(\"\\n\");\n}\n//# sourceMappingURL=check.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACtB,kCAAkC;CAClC,uBAAuB;CACvB,8BAA8B;CAC9B,0BAA0B;AAC5B,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,YAAY,QAAQ,IAAI;AAC5B,IAAI,cAAc,QAAQ,MAAM;AAChC,IAAI,gBAAgB,QAAQ,8BAA8B;AAC1D,IAAI,eAAe,QAAQ,wCAAwC;AACnE,IAAI,cAAc,QAAQ,kBAAQ;AAClC,IAAI,kBAAkB,QAAQ,sBAAY;AAC1C,IAAI,yBAAyB,QAAQ,6BAAmB;AACxD,SAAS,yBAAyB,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|
|
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 core_exports = {};
|
|
23
|
+
__export(core_exports, {
|
|
24
|
+
completionSortText: () => completionSortText,
|
|
25
|
+
createStyleTooling: () => createStyleTooling
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(core_exports);
|
|
28
|
+
var import_normalize_css_color = require("@tamagui/normalize-css-color");
|
|
29
|
+
var import_tooling = require("@tamagui/style-grammar/tooling");
|
|
30
|
+
const modifierKindLabel = {
|
|
31
|
+
state: "state modifier",
|
|
32
|
+
media: "media modifier",
|
|
33
|
+
theme: "theme modifier",
|
|
34
|
+
platform: "platform modifier",
|
|
35
|
+
group: "group modifier",
|
|
36
|
+
container: "container modifier"
|
|
37
|
+
};
|
|
38
|
+
const modifierKindSort = {
|
|
39
|
+
state: "00",
|
|
40
|
+
group: "01",
|
|
41
|
+
media: "02",
|
|
42
|
+
container: "03",
|
|
43
|
+
theme: "04",
|
|
44
|
+
platform: "05"
|
|
45
|
+
};
|
|
46
|
+
const stateModifierSort = new Map(import_tooling.stateModifierNames.map((name, index) => [name, index]));
|
|
47
|
+
function completionSortText(completion, modifierKind) {
|
|
48
|
+
if (modifierKind) {
|
|
49
|
+
const stateOrder = modifierKind === "state" ? `${String(stateModifierSort.get(completion.value) ?? 999).padStart(3, "0")}:` : "";
|
|
50
|
+
return `${modifierKindSort[modifierKind]}:${stateOrder}${completion.value}`;
|
|
51
|
+
}
|
|
52
|
+
return `${completion.kind === "configured" ? "10" : "11"}:${completion.value}`;
|
|
53
|
+
}
|
|
54
|
+
function tokenValue(entry) {
|
|
55
|
+
if (entry && typeof entry === "object" && "val" in entry) {
|
|
56
|
+
return entry.val;
|
|
57
|
+
}
|
|
58
|
+
return entry;
|
|
59
|
+
}
|
|
60
|
+
function parseColor(value, opacity) {
|
|
61
|
+
if (typeof value !== "string") return null;
|
|
62
|
+
const normalized = (0, import_normalize_css_color.normalizeCSSColor)(value);
|
|
63
|
+
if (normalized === null) return null;
|
|
64
|
+
const color = (0, import_normalize_css_color.rgba)(normalized);
|
|
65
|
+
if (opacity !== void 0) color.a = color.a * (opacity / 100);
|
|
66
|
+
return color;
|
|
67
|
+
}
|
|
68
|
+
function createStyleTooling(file) {
|
|
69
|
+
const serialized = file.tamaguiConfig;
|
|
70
|
+
if (!serialized) return null;
|
|
71
|
+
const config = (0, import_tooling.createGrammarConfigViewFromSerializedConfig)(serialized, file.tamaguiConfigMetadata);
|
|
72
|
+
const registry = (0, import_tooling.createModifierRegistry)(config).registry;
|
|
73
|
+
const candidates = (0, import_tooling.createCandidatePropertyVocabulary)(config);
|
|
74
|
+
const engine = {
|
|
75
|
+
config,
|
|
76
|
+
registry,
|
|
77
|
+
candidates
|
|
78
|
+
};
|
|
79
|
+
const styleProps = (0, import_tooling.createStylePropSet)(config);
|
|
80
|
+
const themes = serialized.themes || {};
|
|
81
|
+
const rootThemes = Object.keys(themes).filter((name) => !name.includes("_"));
|
|
82
|
+
const previewThemes = [...["light", "dark"].filter((name) => rootThemes.includes(name)), ...rootThemes.filter((name) => name !== "light" && name !== "dark")];
|
|
83
|
+
const tokens = serialized.tokens || {};
|
|
84
|
+
const media = serialized.media || {};
|
|
85
|
+
const targetProperty = (name) => config.shorthands?.[name] || name;
|
|
86
|
+
const themeValue = (name) => {
|
|
87
|
+
for (const theme of previewThemes) {
|
|
88
|
+
const value = themes[theme]?.[name];
|
|
89
|
+
if (value !== void 0) return {
|
|
90
|
+
theme,
|
|
91
|
+
value
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
const annotationColor = (annotation) => {
|
|
97
|
+
if (annotation.kind === "token" || annotation.kind === "identifier") {
|
|
98
|
+
const name = annotation.opacity !== void 0 ? annotation.text.slice(0, annotation.text.lastIndexOf("/")) : annotation.text;
|
|
99
|
+
if (annotation.tokenCategory === "color") {
|
|
100
|
+
const themed = themeValue(name);
|
|
101
|
+
if (themed) {
|
|
102
|
+
const color2 = parseColor(themed.value, annotation.opacity);
|
|
103
|
+
return color2 ? {
|
|
104
|
+
color: color2,
|
|
105
|
+
theme: themed.theme
|
|
106
|
+
} : null;
|
|
107
|
+
}
|
|
108
|
+
const color = parseColor(tokenValue(tokens.color?.[name]), annotation.opacity);
|
|
109
|
+
return color ? { color } : null;
|
|
110
|
+
}
|
|
111
|
+
if (annotation.kind === "identifier") {
|
|
112
|
+
const color = parseColor(name);
|
|
113
|
+
return color ? { color } : null;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
if (annotation.kind === "keyword" && annotation.text === "transparent") {
|
|
118
|
+
return { color: {
|
|
119
|
+
r: 0,
|
|
120
|
+
g: 0,
|
|
121
|
+
b: 0,
|
|
122
|
+
a: 0
|
|
123
|
+
} };
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
};
|
|
127
|
+
const annotations = (property, value) => (0, import_tooling.annotateStyleValue)(property, value, engine);
|
|
128
|
+
const formatRgba = (color) => color.a === 1 ? `rgb(${color.r}, ${color.g}, ${color.b})` : `rgba(${color.r}, ${color.g}, ${color.b}, ${Number(color.a.toFixed(3))})`;
|
|
129
|
+
return {
|
|
130
|
+
styleProps,
|
|
131
|
+
engine,
|
|
132
|
+
previewThemes,
|
|
133
|
+
isStyleProp: (name) => styleProps.has(name),
|
|
134
|
+
targetProperty,
|
|
135
|
+
modifierKind: (name) => registry.get(name),
|
|
136
|
+
completions(property, value, cursor) {
|
|
137
|
+
const target = targetProperty(property);
|
|
138
|
+
if ((0, import_tooling.programEligibility)(target) === "legacy-part") return null;
|
|
139
|
+
if (!styleProps.has(property)) return null;
|
|
140
|
+
return (0, import_tooling.completeStyleValueAtCursor)(property, value, cursor, engine);
|
|
141
|
+
},
|
|
142
|
+
diagnostics(property, value) {
|
|
143
|
+
if (!styleProps.has(property)) return [];
|
|
144
|
+
return (0, import_tooling.diagnoseStyleValueProgram)(property, value, engine);
|
|
145
|
+
},
|
|
146
|
+
annotations,
|
|
147
|
+
colors(property, value) {
|
|
148
|
+
if (!styleProps.has(property)) return [];
|
|
149
|
+
const results = [];
|
|
150
|
+
for (const annotation of annotations(property, value)) {
|
|
151
|
+
const resolved = annotationColor(annotation);
|
|
152
|
+
if (!resolved) continue;
|
|
153
|
+
results.push({
|
|
154
|
+
start: annotation.start,
|
|
155
|
+
end: annotation.end,
|
|
156
|
+
text: annotation.text,
|
|
157
|
+
color: resolved.color,
|
|
158
|
+
...resolved.theme !== void 0 && { theme: resolved.theme }
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return results;
|
|
162
|
+
},
|
|
163
|
+
hover(property, value, offset) {
|
|
164
|
+
if (!styleProps.has(property)) return null;
|
|
165
|
+
const annotation = annotations(property, value).find((entry) => offset >= entry.start && offset <= entry.end);
|
|
166
|
+
if (!annotation) return null;
|
|
167
|
+
const lines = [];
|
|
168
|
+
let color;
|
|
169
|
+
if (annotation.kind === "modifier" && annotation.modifierKind) {
|
|
170
|
+
lines.push(`**${annotation.text}** \xB7 Tamagui ${modifierKindLabel[annotation.modifierKind]}`);
|
|
171
|
+
if (annotation.modifierKind === "media") {
|
|
172
|
+
const query = media[annotation.text];
|
|
173
|
+
if (query !== void 0) {
|
|
174
|
+
lines.push("```json\n" + JSON.stringify(query) + "\n```");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} else if (annotation.kind === "token") {
|
|
178
|
+
const name = annotation.opacity !== void 0 ? annotation.text.slice(0, annotation.text.lastIndexOf("/")) : annotation.text;
|
|
179
|
+
if (annotation.tokenCategory === "color") {
|
|
180
|
+
lines.push(`**${name}** \xB7 Tamagui color`);
|
|
181
|
+
let shown = 0;
|
|
182
|
+
for (const theme of previewThemes) {
|
|
183
|
+
const value2 = themes[theme]?.[name];
|
|
184
|
+
if (value2 === void 0 || shown >= 4) continue;
|
|
185
|
+
shown++;
|
|
186
|
+
lines.push(`- ${theme}: \`${String(value2)}\``);
|
|
187
|
+
}
|
|
188
|
+
if (shown === 0) {
|
|
189
|
+
const value2 = tokenValue(tokens.color?.[name]);
|
|
190
|
+
if (value2 !== void 0) lines.push(`- \`${String(value2)}\``);
|
|
191
|
+
}
|
|
192
|
+
if (annotation.opacity !== void 0) {
|
|
193
|
+
lines.push(`- opacity: ${annotation.opacity}%`);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
const value2 = tokenValue(tokens[annotation.tokenCategory || ""]?.[name]);
|
|
197
|
+
lines.push(`**${name}** \xB7 Tamagui ${annotation.tokenCategory} token` + (value2 !== void 0 ? ` = \`${String(value2)}\`` : ""));
|
|
198
|
+
}
|
|
199
|
+
const resolved = annotationColor(annotation);
|
|
200
|
+
if (resolved) {
|
|
201
|
+
color = resolved.color;
|
|
202
|
+
lines.push(`- resolves: \`${formatRgba(resolved.color)}\``);
|
|
203
|
+
}
|
|
204
|
+
} else if (annotation.kind === "keyword") {
|
|
205
|
+
lines.push(`**${annotation.text}** \xB7 CSS keyword` + (annotation.property ? ` for \`${annotation.property}\`` : ""));
|
|
206
|
+
} else {
|
|
207
|
+
const resolved = annotationColor(annotation);
|
|
208
|
+
if (!resolved) return null;
|
|
209
|
+
color = resolved.color;
|
|
210
|
+
lines.push(`**${annotation.text}** \xB7 CSS color = \`${formatRgba(resolved.color)}\``);
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
start: annotation.start,
|
|
214
|
+
end: annotation.end,
|
|
215
|
+
text: annotation.text,
|
|
216
|
+
markdown: lines.join("\n\n"),
|
|
217
|
+
...color !== void 0 && { color }
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|