pasika 0.10.126 → 0.10.128

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.
@@ -9646,11 +9646,6 @@ function preludeIdentifiers(node) {
9646
9646
  });
9647
9647
  return names;
9648
9648
  }
9649
- function rawValue(node) {
9650
- if (!node) return "";
9651
- if (node.type === "Raw") return node.value;
9652
- return "";
9653
- }
9654
9649
  function rules(node) {
9655
9650
  const result = [];
9656
9651
  walkNodes(node, (current) => {
@@ -11217,18 +11212,44 @@ var unusedUtilityRule = {
11217
11212
  import { spawnSync } from "child_process";
11218
11213
  import { existsSync as existsSync12 } from "fs";
11219
11214
  import path78 from "path";
11220
- function applyOperationCount(utility) {
11215
+ function applyOperationCount(utility, textOf) {
11221
11216
  let count = 0;
11222
11217
  for (const apply of atrulesNamed(utility, "apply")) {
11223
- const identifiers = preludeIdentifiers(apply);
11224
- if (identifiers.length > 0) {
11225
- count += identifiers.length;
11226
- continue;
11218
+ const value = textOf(apply).trim().replace(/^@apply\s+/u, "").replace(/;\s*$/u, "");
11219
+ let brackets = 0;
11220
+ let parentheses = 0;
11221
+ let quote;
11222
+ let escaped = false;
11223
+ let inToken = false;
11224
+ for (const character of value) {
11225
+ if (escaped) {
11226
+ escaped = false;
11227
+ inToken = true;
11228
+ continue;
11229
+ }
11230
+ if (character === "\\") {
11231
+ escaped = true;
11232
+ inToken = true;
11233
+ continue;
11234
+ }
11235
+ if (character === '"' || character === "'") {
11236
+ if (!quote) quote = character;
11237
+ else if (quote === character) quote = void 0;
11238
+ } else if (!quote) {
11239
+ if (character === "[") brackets++;
11240
+ if (character === "]") brackets--;
11241
+ if (character === "(") parentheses++;
11242
+ if (character === ")") parentheses--;
11243
+ }
11244
+ if (/\s/u.test(character) && brackets === 0 && parentheses === 0 && !quote) {
11245
+ if (inToken) count++;
11246
+ inToken = false;
11247
+ } else {
11248
+ inToken = true;
11249
+ }
11227
11250
  }
11228
- const prelude = "prelude" in apply ? apply.prelude : void 0;
11229
- const raw = prelude ? rawValue(prelude) : "";
11230
- const rawOperations = raw.trim().split(/\s+/).filter(Boolean);
11231
- count += rawOperations.length > 0 ? rawOperations.length : 1;
11251
+ if (inToken) count++;
11252
+ if (!value.trim()) count++;
11232
11253
  }
11233
11254
  return count;
11234
11255
  }
@@ -11262,39 +11283,58 @@ var themeOperations = [
11262
11283
  { property: "gap", prefix: "gap", namespace: "spacing" },
11263
11284
  { property: "width", prefix: "w", namespace: "spacing" },
11264
11285
  { property: "height", prefix: "h", namespace: "spacing" },
11286
+ { property: "max-height", prefix: "max-h", namespace: "spacing" },
11287
+ { property: "grid-template-columns", prefix: "grid-cols", namespace: "grid-template-columns" },
11288
+ { property: "transition-property", prefix: "transition", namespace: "transition-property" },
11265
11289
  { property: "aspect-ratio", prefix: "aspect", namespace: "aspect" },
11266
11290
  { property: "transition-timing-function", prefix: "ease", namespace: "ease" },
11267
11291
  { property: "zoom", prefix: "zoom", namespace: "zoom" },
11268
11292
  { property: "perspective", prefix: "perspective", namespace: "perspective" },
11269
11293
  { property: "animation", prefix: "animate", namespace: "animate" },
11270
- { property: "box-shadow", prefix: "shadow", namespace: "shadow" }
11294
+ { property: "box-shadow", prefix: "shadow", namespace: "shadow" },
11295
+ { property: "text-shadow", prefix: "text-shadow", namespace: "text-shadow" }
11271
11296
  ];
11272
- var SHADOW_THEME_WORKER = String.raw`
11297
+ var THEME_GENERATOR_WORKER = String.raw`
11273
11298
  import { readFileSync } from "node:fs";
11274
11299
  import { compile } from "tailwindcss";
11275
- const values = JSON.parse(readFileSync(0, "utf8"));
11300
+ const probes = JSON.parse(readFileSync(0, "utf8"));
11276
11301
  const results = [];
11277
- for (const value of values) {
11302
+ for (const probe of probes) {
11278
11303
  try {
11279
- const compiler = await compile(["@theme { --shadow-pasika-probe: ", value, "; } @tailwind utilities;"].join(""));
11280
- const css = compiler.build(["shadow-pasika-probe"]);
11281
- const block = css.match(/\.shadow-pasika-probe\s*\{(?<body>[^}]+)\}/u)?.groups?.body ?? "";
11282
- results.push(/--tw-shadow\s*:/u.test(block) && /box-shadow\s*:/u.test(block));
11304
+ const name = probe.prefix + "-pasika-probe";
11305
+ const css = ["@theme { --", probe.namespace, "-pasika-probe: ", probe.value, "; } @tailwind utilities;"].join("");
11306
+ const compiler = await compile(css);
11307
+ const output = compiler.build([name]);
11308
+ const block = output.match(new RegExp("\\." + name + "\\s*\\{(?<body>[^}]+)\\}", "u"))?.groups?.body ?? "";
11309
+ const property = new RegExp("(?:^|[;\\n])\\s*" + probe.property + "\\s*:", "u");
11310
+ const functionName = probe.property === "filter" ? probe.prefix
11311
+ : probe.property === "backdrop-filter" ? probe.prefix.slice("backdrop-".length) : "";
11312
+ const marker = ["box-shadow", "filter", "backdrop-filter"].includes(probe.property) ? "--tw-" + probe.prefix : "";
11313
+ const recognized = property.test(block)
11314
+ && (!marker || block.includes(marker + ":"))
11315
+ && (!functionName || block.includes(functionName + "("));
11316
+ results.push(recognized);
11283
11317
  } catch {
11284
11318
  results.push(false);
11285
11319
  }
11286
11320
  }
11287
11321
  process.stdout.write(JSON.stringify(results));
11288
11322
  `;
11289
- var shadowSupportCache = /* @__PURE__ */ new Map();
11290
- function themeSupportedShadows(values, cwd) {
11291
- const unique = [...new Set(values)];
11292
- const cacheKey = (value) => `${cwd}\0${value}`;
11293
- const missing = unique.filter((value) => !shadowSupportCache.has(cacheKey(value)));
11323
+ var generatorSupportCache = /* @__PURE__ */ new Map();
11324
+ function generatorProbeKey(candidate) {
11325
+ return JSON.stringify([candidate.prefix, candidate.namespace, candidate.property, candidate.value]);
11326
+ }
11327
+ function requiresGeneratorProbe(candidate) {
11328
+ return candidate.probe === true || ["box-shadow", "text-shadow", "filter", "backdrop-filter"].includes(candidate.property);
11329
+ }
11330
+ function themeSupportedGenerators(candidates, cwd) {
11331
+ const unique = new Map(candidates.map((candidate) => [generatorProbeKey(candidate), candidate]));
11332
+ const cacheKey = (key) => `${cwd}\0${key}`;
11333
+ const missing = [...unique].filter(([key]) => !generatorSupportCache.has(cacheKey(key)));
11294
11334
  if (missing.length > 0) {
11295
- const child = spawnSync(process.execPath, ["--input-type=module", "--eval", SHADOW_THEME_WORKER], {
11335
+ const child = spawnSync(process.execPath, ["--input-type=module", "--eval", THEME_GENERATOR_WORKER], {
11296
11336
  cwd,
11297
- input: JSON.stringify(missing),
11337
+ input: JSON.stringify(missing.map(([, candidate]) => candidate)),
11298
11338
  encoding: "utf8",
11299
11339
  timeout: 3e4,
11300
11340
  maxBuffer: 8 * 1024 * 1024,
@@ -11310,21 +11350,105 @@ function themeSupportedShadows(values, cwd) {
11310
11350
  } catch {
11311
11351
  }
11312
11352
  }
11313
- missing.forEach((value, index) => shadowSupportCache.set(cacheKey(value), supported[index] === true));
11353
+ missing.forEach(([key], index) => generatorSupportCache.set(cacheKey(key), supported[index] === true));
11354
+ }
11355
+ return new Set([...unique.keys()].filter((key) => generatorSupportCache.get(cacheKey(key))));
11356
+ }
11357
+ function singleCssFunction(value) {
11358
+ const match = /^(?<name>[a-z][a-z-]*)\(/u.exec(value);
11359
+ if (!match) return void 0;
11360
+ const name = match.groups?.name;
11361
+ if (!name) return void 0;
11362
+ let depth = 0;
11363
+ for (let index = match[0].length - 1; index < value.length; index++) {
11364
+ if (value[index] === "(") depth++;
11365
+ if (value[index] === ")") {
11366
+ depth--;
11367
+ if (depth === 0 && index !== value.length - 1) return void 0;
11368
+ if (depth < 0) return void 0;
11369
+ }
11370
+ }
11371
+ if (depth !== 0 || !value.endsWith(")")) return void 0;
11372
+ const args = value.slice(match[0].length, -1).trim();
11373
+ return args ? { name, args } : void 0;
11374
+ }
11375
+ function boxShadowNamespace(value) {
11376
+ const layers = [];
11377
+ let depth = 0;
11378
+ let start = 0;
11379
+ for (let index = 0; index < value.length; index++) {
11380
+ if (value[index] === "(") depth++;
11381
+ if (value[index] === ")") depth--;
11382
+ if (depth < 0) return void 0;
11383
+ if (value[index] === "," && depth === 0) {
11384
+ layers.push(value.slice(start, index).trim());
11385
+ start = index + 1;
11386
+ }
11387
+ }
11388
+ if (depth !== 0) return void 0;
11389
+ layers.push(value.slice(start).trim());
11390
+ if (layers.some((layer) => !layer)) return void 0;
11391
+ const inset = layers.map((layer) => /(?:^|\s)inset(?:\s|$)/u.test(layer));
11392
+ if (inset.every(Boolean)) return "inset-shadow";
11393
+ if (inset.some(Boolean)) return void 0;
11394
+ return "shadow";
11395
+ }
11396
+ function decodeArbitraryValue(value) {
11397
+ if (/\\|\burl\(/iu.test(value) || /var\(--[^)]*_/iu.test(value)) return void 0;
11398
+ let quote;
11399
+ let decoded = "";
11400
+ for (const character of value) {
11401
+ if (character === '"' || character === "'") {
11402
+ if (!quote) quote = character;
11403
+ else if (quote === character) quote = void 0;
11404
+ decoded += character;
11405
+ } else if (character === "_") {
11406
+ if (quote) return void 0;
11407
+ decoded += " ";
11408
+ } else {
11409
+ decoded += character;
11410
+ }
11411
+ }
11412
+ return quote ? void 0 : decoded.trim();
11413
+ }
11414
+ function arbitraryApplyOperation(prefix, value) {
11415
+ if (prefix === "bg") {
11416
+ return /^(?:repeating-)?(?:linear|radial|conic)-gradient\(/u.test(value) ? { property: "background-image", prefix: "bg", namespace: "background-image" } : void 0;
11314
11417
  }
11315
- return new Set(unique.filter((value) => shadowSupportCache.get(cacheKey(value))));
11418
+ const matched = themeOperations.filter((operation) => operation.prefix === prefix);
11419
+ return matched.length === 1 ? matched[0] : void 0;
11316
11420
  }
11317
11421
  function themeCandidate(name, utilityText) {
11318
11422
  const source = utilityText.trim();
11319
11423
  const arbitrary = /^@utility\s+[\w-]+\s*\{\s*@apply\s+\[(?<property>[a-z-]+):(?<value>[^\]\r\n;{}]+)\];?\s*\}$/u.exec(
11320
11424
  source
11321
11425
  );
11322
- const typed = /^@utility\s+[\w-]+\s*\{\s*@apply\s+(?<kind>[a-z]+)-\((?<hint>[a-z-]+:)?(?<variable>--[a-z][a-z0-9-]*)\);?\s*\}$/u.exec(
11426
+ const arbitraryApply = /^@utility\s+[\w-]+\s*\{\s*@apply\s+(?<prefix>[a-z][a-z0-9-]*)-\[(?<value>[^\]\r\n;{}]+)\];?\s*\}$/u.exec(source);
11427
+ const typed = /^@utility\s+[\w-]+\s*\{\s*@apply\s+(?<kind>[a-z-]+)-\((?<hint>[a-z-]+:)?(?<variable>--[a-z][a-z0-9-]*)\);?\s*\}$/u.exec(
11323
11428
  source
11324
11429
  );
11325
11430
  const direct = /^@utility\s+[\w-]+\s*\{\s*(?<property>[a-z-]+)\s*:\s*(?<value>[^;{}\r\n]+);?\s*\}$/u.exec(source);
11326
- const property = arbitrary?.groups?.property ?? direct?.groups?.property;
11327
- const matched = themeOperations.find((operation) => {
11431
+ const raw = arbitrary?.groups?.value?.trim() ?? direct?.groups?.value?.trim() ?? arbitraryApply?.groups?.value?.trim() ?? (typed?.groups?.variable ? `var(${typed.groups.variable})` : void 0);
11432
+ if (!raw) return void 0;
11433
+ const cssValue = arbitrary || arbitraryApply ? decodeArbitraryValue(raw) : raw;
11434
+ if (!cssValue) return void 0;
11435
+ const namedOperation = arbitraryApply?.groups?.prefix ? arbitraryApplyOperation(arbitraryApply.groups.prefix, cssValue) : void 0;
11436
+ if (arbitraryApply && !namedOperation) return void 0;
11437
+ const property = arbitrary?.groups?.property ?? direct?.groups?.property ?? namedOperation?.property;
11438
+ const functionValue = property === "filter" || property === "backdrop-filter" ? singleCssFunction(cssValue) : void 0;
11439
+ const shadowNamespace = property === "box-shadow" ? boxShadowNamespace(cssValue) : void 0;
11440
+ if (property === "box-shadow" && !shadowNamespace) return void 0;
11441
+ let inferred;
11442
+ if (functionValue && property) {
11443
+ inferred = {
11444
+ property,
11445
+ prefix: property === "filter" ? functionValue.name : `backdrop-${functionValue.name}`,
11446
+ namespace: property === "filter" ? functionValue.name : `backdrop-${functionValue.name}`
11447
+ };
11448
+ } else if (shadowNamespace === "inset-shadow") {
11449
+ inferred = { property: "box-shadow", prefix: "inset-shadow", namespace: "inset-shadow" };
11450
+ }
11451
+ const matched = inferred ?? namedOperation ?? themeOperations.find((operation) => {
11328
11452
  if (property) return property === operation.property;
11329
11453
  if (typed?.groups?.kind !== operation.prefix) return false;
11330
11454
  const hint = typed.groups.hint;
@@ -11332,25 +11456,21 @@ function themeCandidate(name, utilityText) {
11332
11456
  if (operation.prefix === "font") {
11333
11457
  return hint === (operation.property === "font-family" ? "family-name:" : "number:");
11334
11458
  }
11335
- if (operation.prefix === "bg") {
11336
- return hint === (operation.property === "background-image" ? "image:" : "color:");
11337
- }
11459
+ if (operation.prefix === "bg") return hint === (operation.property === "background-image" ? "image:" : "color:");
11338
11460
  if (["border", "outline", "decoration", "stroke"].includes(operation.prefix)) return hint === "color:";
11339
11461
  return hint === void 0;
11340
11462
  });
11341
11463
  if (!matched) return void 0;
11342
- const value = arbitrary?.groups?.value?.trim() ?? direct?.groups?.value?.trim() ?? (typed?.groups?.variable ? `var(${typed.groups.variable})` : void 0);
11343
- if (!value) return void 0;
11344
- if (arbitrary && (/\\|["']|\burl\(/iu.test(value) || /var\(--[^)]*_/iu.test(value))) return void 0;
11345
- const cssValue = arbitrary ? value.replaceAll("_", " ") : value;
11346
- if (matched.property === "font-size" && cssValue.startsWith("-")) return void 0;
11347
- const stem = name.startsWith(`${matched.prefix}-`) ? name.slice(matched.prefix.length + 1) : void 0;
11464
+ const value = functionValue?.args ?? cssValue;
11465
+ if (matched.property === "font-size" && value.startsWith("-")) return void 0;
11466
+ const stem = name.startsWith(`${matched.prefix}-`) && !/-hash-[0-9a-f]{8,}$/u.test(name) ? name.slice(matched.prefix.length + 1) : void 0;
11348
11467
  return {
11349
11468
  token: stem ? `--${matched.namespace}-${stem}` : "",
11350
11469
  property: matched.property,
11351
- value: cssValue,
11470
+ value,
11352
11471
  prefix: matched.prefix,
11353
- namespace: matched.namespace
11472
+ namespace: matched.namespace,
11473
+ probe: Boolean(arbitraryApply) || matched.property === "transition-property"
11354
11474
  };
11355
11475
  }
11356
11476
  var builtInTextSizes = /* @__PURE__ */ new Set([
@@ -11569,15 +11689,12 @@ var utilityMappingRule = {
11569
11689
  }
11570
11690
  return void 0;
11571
11691
  }
11572
- const shadowCandidates = utilities.map(
11692
+ const generatorCandidates = utilities.map(
11573
11693
  (utility) => themeCandidate(preludeIdentifiers(utility)[0] ?? "unknown", context.sourceCode.getText(utility))
11574
- ).filter((candidate) => candidate?.property === "box-shadow");
11694
+ ).filter((candidate) => Boolean(candidate && requiresGeneratorProbe(candidate)));
11575
11695
  const physicalDir = path78.dirname(context.physicalFilename);
11576
11696
  const tailwindCwd = path78.isAbsolute(physicalDir) && existsSync12(physicalDir) ? physicalDir : context.cwd;
11577
- const themeShadows = themeSupportedShadows(
11578
- shadowCandidates.map((candidate) => candidate.value),
11579
- tailwindCwd
11580
- );
11697
+ const themeGenerators = themeSupportedGenerators(generatorCandidates, tailwindCwd);
11581
11698
  for (const utility of utilities) {
11582
11699
  const name = preludeIdentifiers(utility)[0] ?? "unknown";
11583
11700
  const source = context.sourceCode.getText(utility);
@@ -11597,7 +11714,7 @@ var utilityMappingRule = {
11597
11714
  continue;
11598
11715
  }
11599
11716
  const possibleCandidate = themeCandidate(name, source);
11600
- const candidate = possibleCandidate?.property === "box-shadow" && !themeShadows.has(possibleCandidate.value) ? void 0 : possibleCandidate;
11717
+ const candidate = possibleCandidate && requiresGeneratorProbe(possibleCandidate) && !themeGenerators.has(generatorProbeKey(possibleCandidate)) ? void 0 : possibleCandidate;
11601
11718
  const equivalent = candidate ? matchingThemeToken(candidate) : void 0;
11602
11719
  if (candidate && equivalent && nameCounts.get(name) === 1) {
11603
11720
  context.report({
@@ -11606,7 +11723,7 @@ var utilityMappingRule = {
11606
11723
  });
11607
11724
  continue;
11608
11725
  }
11609
- const operationCount = applyOperationCount(utility);
11726
+ const operationCount = applyOperationCount(utility, (apply) => context.sourceCode.getText(apply));
11610
11727
  if (operationCount !== 1) {
11611
11728
  context.report({
11612
11729
  node: utility,
@@ -12055,6 +12172,9 @@ var PREFIX_NAMESPACES = {
12055
12172
  via: ["color"],
12056
12173
  to: ["color"],
12057
12174
  shadow: ["color", "shadow"],
12175
+ "inset-shadow": ["inset-shadow"],
12176
+ "grid-cols": ["grid-template-columns"],
12177
+ transition: ["transition-property"],
12058
12178
  rounded: ["radius"],
12059
12179
  font: ["font"],
12060
12180
  tracking: ["tracking"],
@@ -12205,7 +12325,9 @@ var PREFIX_BUILTINS = {
12205
12325
  accent: ["auto"],
12206
12326
  decoration: ["solid", "double", "dotted", "dashed", "wavy", "none"],
12207
12327
  outline: ["none", "hidden", "dashed", "dotted", "double", "solid"],
12208
- font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"]
12328
+ font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"],
12329
+ "grid-cols": ["none", "subgrid"],
12330
+ transition: ["none", "all", "colors", "opacity", "shadow", "transform", "discrete", "normal"]
12209
12331
  };
12210
12332
  var DEFAULT_TOKENS = {
12211
12333
  text: ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl", "9xl"],
@@ -12452,6 +12574,18 @@ function readInventory(files) {
12452
12574
  namespace = "background-image";
12453
12575
  token = token.slice("image-".length);
12454
12576
  }
12577
+ if (namespace === "inset" && token?.startsWith("shadow-")) {
12578
+ namespace = "inset-shadow";
12579
+ token = token.slice("shadow-".length);
12580
+ }
12581
+ if (namespace === "grid" && token?.startsWith("template-columns-")) {
12582
+ namespace = "grid-template-columns";
12583
+ token = token.slice("template-columns-".length);
12584
+ }
12585
+ if (namespace === "transition" && token?.startsWith("property-")) {
12586
+ namespace = "transition-property";
12587
+ token = token.slice("property-".length);
12588
+ }
12455
12589
  if (!namespace || !token) continue;
12456
12590
  let set = themeTokensByNamespace.get(namespace);
12457
12591
  if (!set) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.126",
3
+ "version": "0.10.128",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",