rainbowindex 0.2.0 → 0.2.2
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/CHANGELOG.md +152 -0
- package/README.md +34 -0
- package/dist/browser.d.ts +2 -1
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-KCSNR2TV.mjs → chunk-CUUW2K35.mjs} +17 -7
- package/dist/chunk-FHATRQMN.mjs +1635 -0
- package/dist/chunk-KYDEHYIE.mjs +691 -0
- package/dist/{chunk-5N4GPK26.mjs → chunk-SOMDX7V6.mjs} +74 -16
- package/dist/{chunk-RPXZ3O6R.mjs → chunk-W6XIBM4M.mjs} +6118 -7201
- package/dist/cli.mjs +72 -40
- package/dist/editor.d.ts +464 -0
- package/dist/editor.mjs +402 -0
- package/dist/{safelist-DRk1XXxi.d.ts → index-CfDtWufj.d.ts} +29 -43
- package/dist/index-DK6APAGD.d.ts +260 -0
- package/dist/index.d.ts +5 -253
- package/dist/index.mjs +8 -6
- package/dist/safelist-CH3_PywB.d.ts +43 -0
- package/dist/vite.mjs +4 -3
- package/package.json +107 -101
|
@@ -282,6 +282,21 @@ function computeStop(def, suffix) {
|
|
|
282
282
|
h: roundedH
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
+
function computeDarkStop(def, suffix, darkConfig, darkOverride) {
|
|
286
|
+
const lightStop = generateStop(def, suffix);
|
|
287
|
+
const darkL = generateStop(def, 1e3 - suffix).l;
|
|
288
|
+
let extraChroma = 0;
|
|
289
|
+
let extraHue = 0;
|
|
290
|
+
if (darkOverride?.strategy === "shift") {
|
|
291
|
+
extraChroma = darkOverride.chromaDelta;
|
|
292
|
+
extraHue = darkOverride.hueDelta;
|
|
293
|
+
}
|
|
294
|
+
const darkH = lightStop.h + darkConfig.hueShift + extraHue;
|
|
295
|
+
const globalChromaBoost = def.chromaBoost !== false ? darkConfig.chromaBoost : 0;
|
|
296
|
+
const requestedChroma = lightStop.c + globalChromaBoost + extraChroma;
|
|
297
|
+
const darkC = Math.floor(gamutSafeChroma(darkL, requestedChroma, darkH) * 1e4) / 1e4;
|
|
298
|
+
return { stop: suffix, l: darkL, c: darkC, h: darkH };
|
|
299
|
+
}
|
|
285
300
|
function formatOklch(l, c, h) {
|
|
286
301
|
return `oklch(${l} ${c} ${h})`;
|
|
287
302
|
}
|
|
@@ -298,18 +313,8 @@ function generateColorVariables(name, def, suffixes, darkConfig = DEFAULT_DARK_C
|
|
|
298
313
|
vars.push(`--color-${name}-${suffix}: light-dark(${lightValue}, ${lightValue});`);
|
|
299
314
|
}
|
|
300
315
|
} else {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
let extraHue = 0;
|
|
304
|
-
if (darkOverride?.strategy === "shift") {
|
|
305
|
-
extraChroma = darkOverride.chromaDelta;
|
|
306
|
-
extraHue = darkOverride.hueDelta;
|
|
307
|
-
}
|
|
308
|
-
const darkH = lightStop.h + darkConfig.hueShift + extraHue;
|
|
309
|
-
const globalChromaBoost = def.chromaBoost !== false ? darkConfig.chromaBoost : 0;
|
|
310
|
-
const requestedChroma = lightStop.c + globalChromaBoost + extraChroma;
|
|
311
|
-
const darkC = Math.floor(gamutSafeChroma(darkL, requestedChroma, darkH) * 1e4) / 1e4;
|
|
312
|
-
const darkValue = formatOklch(darkL, darkC, darkH);
|
|
316
|
+
const darkStop = computeDarkStop(def, suffix, darkConfig, darkOverride);
|
|
317
|
+
const darkValue = formatOklch(darkStop.l, darkStop.c, darkStop.h);
|
|
313
318
|
vars.push(`--color-${name}-${suffix}: light-dark(${lightValue}, ${darkValue});`);
|
|
314
319
|
}
|
|
315
320
|
}
|
|
@@ -2330,7 +2335,7 @@ function canonicalVariantPrefix(variantPrefix) {
|
|
|
2330
2335
|
segments.sort();
|
|
2331
2336
|
return `${segments.join(":")}:`;
|
|
2332
2337
|
}
|
|
2333
|
-
function mergeUncached(classes, resolve) {
|
|
2338
|
+
function mergeUncached(classes, resolve, trace) {
|
|
2334
2339
|
const claimed = /* @__PURE__ */ new Set();
|
|
2335
2340
|
const result = [];
|
|
2336
2341
|
for (let i = classes.length - 1; i >= 0; i--) {
|
|
@@ -2353,13 +2358,27 @@ function mergeUncached(classes, resolve) {
|
|
|
2353
2358
|
break;
|
|
2354
2359
|
}
|
|
2355
2360
|
}
|
|
2356
|
-
if (dominated)
|
|
2361
|
+
if (dominated) {
|
|
2362
|
+
if (trace) {
|
|
2363
|
+
const by = /* @__PURE__ */ new Set();
|
|
2364
|
+
for (const prop of props) {
|
|
2365
|
+
const claimer = trace.claimers.get(ns + prop);
|
|
2366
|
+
if (claimer !== void 0) by.add(claimer);
|
|
2367
|
+
}
|
|
2368
|
+
trace.dropped.push({ index: i, overriddenBy: [...by].sort((a, b) => a - b) });
|
|
2369
|
+
}
|
|
2370
|
+
continue;
|
|
2371
|
+
}
|
|
2357
2372
|
for (const prop of props) {
|
|
2358
|
-
|
|
2373
|
+
const key = ns + prop;
|
|
2374
|
+
if (trace && !claimed.has(key)) trace.claimers.set(key, i);
|
|
2375
|
+
claimed.add(key);
|
|
2359
2376
|
const longhands = OVERRIDES[prop];
|
|
2360
2377
|
if (longhands !== void 0) {
|
|
2361
2378
|
for (const lh of longhands) {
|
|
2362
|
-
|
|
2379
|
+
const longhandKey = ns + lh;
|
|
2380
|
+
if (trace && !claimed.has(longhandKey)) trace.claimers.set(longhandKey, i);
|
|
2381
|
+
claimed.add(longhandKey);
|
|
2363
2382
|
}
|
|
2364
2383
|
}
|
|
2365
2384
|
}
|
|
@@ -2465,6 +2484,38 @@ function createRi(snapshot) {
|
|
|
2465
2484
|
return mergeFrom(inputs, resolve, cache);
|
|
2466
2485
|
};
|
|
2467
2486
|
}
|
|
2487
|
+
function analyzeMerge(classes, snapshot) {
|
|
2488
|
+
const snap = snapshot ?? _latestSnapshot ?? {
|
|
2489
|
+
customStaticProps: _customStaticProps,
|
|
2490
|
+
textSizes: _textSizes,
|
|
2491
|
+
fontFamilies: _fontFamilies,
|
|
2492
|
+
colorNames: _colorNames
|
|
2493
|
+
};
|
|
2494
|
+
const resolve = (utility) => resolvePropsWith(
|
|
2495
|
+
utility,
|
|
2496
|
+
snap.customStaticProps,
|
|
2497
|
+
snap.textSizes,
|
|
2498
|
+
snap.fontFamilies,
|
|
2499
|
+
snap.colorNames
|
|
2500
|
+
);
|
|
2501
|
+
const trace = { claimers: /* @__PURE__ */ new Map(), dropped: [] };
|
|
2502
|
+
const output = mergeUncached(classes, resolve, trace);
|
|
2503
|
+
trace.dropped.sort((a, b) => a.index - b.index);
|
|
2504
|
+
const droppedIndexes = new Set(trace.dropped.map((d) => d.index));
|
|
2505
|
+
const kept = [];
|
|
2506
|
+
for (let i = 0; i < classes.length; i++) {
|
|
2507
|
+
if (!droppedIndexes.has(i)) kept.push(i);
|
|
2508
|
+
}
|
|
2509
|
+
return {
|
|
2510
|
+
output,
|
|
2511
|
+
kept,
|
|
2512
|
+
dropped: trace.dropped.map((d) => ({
|
|
2513
|
+
index: d.index,
|
|
2514
|
+
className: classes[d.index],
|
|
2515
|
+
overriddenBy: d.overriddenBy
|
|
2516
|
+
}))
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2468
2519
|
var MAX_FLATTEN_DEPTH = 10;
|
|
2469
2520
|
var MAX_CLASS_NAME_LENGTH = 500;
|
|
2470
2521
|
var MAX_TOTAL_CLASSES = 1e4;
|
|
@@ -2622,6 +2673,12 @@ export {
|
|
|
2622
2673
|
isValidColorSuffix,
|
|
2623
2674
|
DEFAULT_COLORS,
|
|
2624
2675
|
DEFAULT_DARK_CONFIG,
|
|
2676
|
+
oklchToOklab,
|
|
2677
|
+
oklabToLinearSrgb,
|
|
2678
|
+
linearToSrgb,
|
|
2679
|
+
generateStop,
|
|
2680
|
+
computeDarkStop,
|
|
2681
|
+
formatOklch,
|
|
2625
2682
|
checkPaletteContrast,
|
|
2626
2683
|
generateAllColorVariables,
|
|
2627
2684
|
generateThemeOverrides,
|
|
@@ -2654,6 +2711,7 @@ export {
|
|
|
2654
2711
|
DEFAULT_TEXT_SIZES,
|
|
2655
2712
|
ri,
|
|
2656
2713
|
createRi,
|
|
2714
|
+
analyzeMerge,
|
|
2657
2715
|
createCompilationContext,
|
|
2658
2716
|
registerCustomUtility,
|
|
2659
2717
|
registerCustomTextSizes,
|