pasika 0.10.152 → 0.10.154

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.
@@ -10196,7 +10196,7 @@ var colorLiteralUsageRule = {
10196
10196
  schema: [],
10197
10197
  type: "problem",
10198
10198
  docs: {
10199
- description: "Require reusable fixed colors in --color-* tokens; allow one-off drop-shadow literals."
10199
+ description: "Require reusable colors in tokens and one-off fixed colors inline."
10200
10200
  }
10201
10201
  },
10202
10202
  create(context) {
@@ -10205,8 +10205,42 @@ var colorLiteralUsageRule = {
10205
10205
  const masked = maskNonColors(context.sourceCode.text);
10206
10206
  const declarations = [...masked.matchAll(DECLARATION)];
10207
10207
  const applyExpressions = [...masked.matchAll(APPLY)];
10208
- const literalKey = (text) => text.toLowerCase().replace(/\s+/gu, " ").trim();
10208
+ const literalKey = (text) => {
10209
+ const normalized = text.toLowerCase().replace(/\s+/gu, " ").trim();
10210
+ if (/^#[\da-f]{3,4}$/u.test(normalized)) {
10211
+ return `#${normalized.slice(1).replace(/[\da-f]/gu, (digit) => digit.repeat(2))}`;
10212
+ }
10213
+ return normalized;
10214
+ };
10209
10215
  const literalUses = /* @__PURE__ */ new Map();
10216
+ const literalColorTokens = /* @__PURE__ */ new Map();
10217
+ const colorTokenReferences = /* @__PURE__ */ new Map();
10218
+ const trackReferences = (value, start) => {
10219
+ for (const match of value.matchAll(/\bvar\s*\(\s*(?<token>--color-[\w-]+)\s*\)/giu)) {
10220
+ const token = match.groups?.token;
10221
+ if (!token) continue;
10222
+ const references = colorTokenReferences.get(token) ?? [];
10223
+ references.push({ offset: start + match.index, text: match[0] });
10224
+ colorTokenReferences.set(token, references);
10225
+ }
10226
+ };
10227
+ for (const match of declarations) {
10228
+ const property = match.groups?.property;
10229
+ const value = match.groups?.value;
10230
+ if (!property || value === void 0) continue;
10231
+ if (property.startsWith("--color-")) {
10232
+ const colors = colorLiterals(value);
10233
+ if (colors.length === 1 && colors[0]?.text === value.trim()) {
10234
+ literalColorTokens.set(property, { color: colors[0].text, key: literalKey(colors[0].text) });
10235
+ }
10236
+ }
10237
+ trackReferences(value, match.index + match[0].lastIndexOf(value));
10238
+ }
10239
+ for (const match of applyExpressions) {
10240
+ const value = match.groups?.value;
10241
+ if (value === void 0) continue;
10242
+ trackReferences(value, match.index + match[0].indexOf(value));
10243
+ }
10210
10244
  for (const match of [...declarations, ...applyExpressions]) {
10211
10245
  const value = match.groups?.value;
10212
10246
  if (value === void 0) continue;
@@ -10216,10 +10250,10 @@ var colorLiteralUsageRule = {
10216
10250
  }
10217
10251
  }
10218
10252
  const reported = /* @__PURE__ */ new Set();
10219
- const reportValue = (value, start, isDropShadowToken = false) => {
10253
+ const reportValue = (value, start) => {
10220
10254
  const colors = colorLiterals(value);
10221
10255
  for (const color of colors) {
10222
- if (isDropShadowToken && colors.length === 1 && literalUses.get(literalKey(color.text)) === 1) continue;
10256
+ if (literalUses.get(literalKey(color.text)) === 1) continue;
10223
10257
  const offset = start + color.offset;
10224
10258
  if (reported.has(offset)) continue;
10225
10259
  reported.add(offset);
@@ -10235,13 +10269,26 @@ var colorLiteralUsageRule = {
10235
10269
  const property = match.groups?.property;
10236
10270
  const value = match.groups?.value;
10237
10271
  if (!property || value === void 0 || property.startsWith("--color-")) continue;
10238
- reportValue(value, match.index + match[0].lastIndexOf(value), /^--drop-shadow-[\w-]+$/u.test(property));
10272
+ reportValue(value, match.index + match[0].lastIndexOf(value));
10239
10273
  }
10240
10274
  for (const match of applyExpressions) {
10241
10275
  const value = match.groups?.value;
10242
10276
  if (value === void 0) continue;
10243
10277
  reportValue(value, match.index + match[0].indexOf(value));
10244
10278
  }
10279
+ for (const [token, definition] of literalColorTokens) {
10280
+ const references = colorTokenReferences.get(token);
10281
+ if (references?.length !== 1 || literalUses.get(definition.key) !== 1) continue;
10282
+ const reference = references[0];
10283
+ if (!reference) continue;
10284
+ const start = context.sourceCode.getLocFromIndex(reference.offset);
10285
+ const end = context.sourceCode.getLocFromIndex(reference.offset + reference.text.length);
10286
+ context.report({
10287
+ node,
10288
+ loc: { start, end },
10289
+ message: `Inline one-off fixed color "${definition.color}" instead of referencing "${token}" through var().`
10290
+ });
10291
+ }
10245
10292
  }
10246
10293
  };
10247
10294
  }
@@ -11579,7 +11626,10 @@ function inferCssConsumerPaths(options) {
11579
11626
  if (!current || seen.has(current)) continue;
11580
11627
  seen.add(current);
11581
11628
  const consumer = componentPaths.get(current);
11582
- if (consumer) found.add(consumer);
11629
+ if (consumer) {
11630
+ found.add(consumer);
11631
+ continue;
11632
+ }
11583
11633
  for (const parent of importers.get(current) ?? []) pending.push(parent);
11584
11634
  }
11585
11635
  componentCache.set(key, found);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.152",
3
+ "version": "0.10.154",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",