@ibnlanre/jumi 0.1.1 → 0.1.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 +7 -0
- package/dist/index.cjs +111 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +111 -26
- package/dist/index.js.map +1 -1
- package/dist/postcss.cjs +116 -31
- package/dist/postcss.cjs.map +1 -1
- package/dist/postcss.js +114 -29
- package/dist/postcss.js.map +1 -1
- package/dist/vite.cjs +114 -29
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +114 -29
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.cjs
CHANGED
|
@@ -7586,6 +7586,90 @@ function splitFrames(value) {
|
|
|
7586
7586
|
return frames;
|
|
7587
7587
|
}
|
|
7588
7588
|
|
|
7589
|
+
// src/helpers/unnest/index.ts
|
|
7590
|
+
var import_postcss = __toESM(require("postcss"), 1);
|
|
7591
|
+
var CONDITIONAL = /* @__PURE__ */ new Set([
|
|
7592
|
+
"container",
|
|
7593
|
+
"media",
|
|
7594
|
+
"starting-style",
|
|
7595
|
+
"supports"
|
|
7596
|
+
]);
|
|
7597
|
+
var isConditional = (node) => node.type === "atrule" && CONDITIONAL.has(node.name);
|
|
7598
|
+
var nests = (rule) => (rule.nodes ?? []).some((node) => node.type === "rule" || isConditional(node));
|
|
7599
|
+
var carriesJumi = (rule) => {
|
|
7600
|
+
let found = false;
|
|
7601
|
+
rule.walkDecls((declaration) => {
|
|
7602
|
+
if (!declaration.prop.startsWith("--jumi-")) return;
|
|
7603
|
+
found = true;
|
|
7604
|
+
return false;
|
|
7605
|
+
});
|
|
7606
|
+
return found;
|
|
7607
|
+
};
|
|
7608
|
+
var inKeyframes = (rule) => {
|
|
7609
|
+
for (let node = rule.parent; node && node.type !== "root"; node = node.parent) {
|
|
7610
|
+
if (node.type === "atrule" && /keyframes$/i.test(node.name))
|
|
7611
|
+
return true;
|
|
7612
|
+
}
|
|
7613
|
+
return false;
|
|
7614
|
+
};
|
|
7615
|
+
var resolveSelectors = (child, parent) => parent.flatMap(
|
|
7616
|
+
(outer) => child.map(
|
|
7617
|
+
(inner) => inner.includes("&") ? inner.replaceAll("&", outer) : `${outer} ${inner}`
|
|
7618
|
+
)
|
|
7619
|
+
);
|
|
7620
|
+
var wrap = (rule, conditions) => conditions.reduceRight((inner, condition) => {
|
|
7621
|
+
const shell = import_postcss.default.atRule({
|
|
7622
|
+
name: condition.name,
|
|
7623
|
+
params: condition.params
|
|
7624
|
+
});
|
|
7625
|
+
shell.append(inner);
|
|
7626
|
+
return shell;
|
|
7627
|
+
}, rule);
|
|
7628
|
+
var flatten = (container2, selectors, conditions, out) => {
|
|
7629
|
+
let pending = [];
|
|
7630
|
+
const flush = () => {
|
|
7631
|
+
if (!pending.length) return;
|
|
7632
|
+
const rule = import_postcss.default.rule({ raws: { semicolon: true }, selectors });
|
|
7633
|
+
for (const declaration of pending) rule.append(declaration.clone());
|
|
7634
|
+
out.push(wrap(rule, conditions));
|
|
7635
|
+
pending = [];
|
|
7636
|
+
};
|
|
7637
|
+
for (const node of container2.nodes ?? []) {
|
|
7638
|
+
if (node.type === "decl") {
|
|
7639
|
+
pending.push(node);
|
|
7640
|
+
continue;
|
|
7641
|
+
}
|
|
7642
|
+
if (node.type === "comment") continue;
|
|
7643
|
+
flush();
|
|
7644
|
+
if (node.type === "rule") {
|
|
7645
|
+
flatten(
|
|
7646
|
+
node,
|
|
7647
|
+
resolveSelectors(node.selectors, selectors),
|
|
7648
|
+
conditions,
|
|
7649
|
+
out
|
|
7650
|
+
);
|
|
7651
|
+
} else if (node.type === "atrule" && isConditional(node)) {
|
|
7652
|
+
flatten(node, selectors, [...conditions, node], out);
|
|
7653
|
+
} else {
|
|
7654
|
+
const rule = import_postcss.default.rule({ raws: { semicolon: true }, selectors });
|
|
7655
|
+
rule.append(node.clone());
|
|
7656
|
+
out.push(wrap(rule, conditions));
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
flush();
|
|
7660
|
+
};
|
|
7661
|
+
function unnest(root) {
|
|
7662
|
+
let rewritten = 0;
|
|
7663
|
+
root.walkRules((rule) => {
|
|
7664
|
+
if (inKeyframes(rule) || !nests(rule) || !carriesJumi(rule)) return;
|
|
7665
|
+
const out = [];
|
|
7666
|
+
flatten(rule, rule.selectors, [], out);
|
|
7667
|
+
rule.replaceWith(out);
|
|
7668
|
+
rewritten += 1;
|
|
7669
|
+
});
|
|
7670
|
+
return rewritten;
|
|
7671
|
+
}
|
|
7672
|
+
|
|
7589
7673
|
// src/helpers/carriers/animation-range.ts
|
|
7590
7674
|
var RANGE_NAMES = [
|
|
7591
7675
|
"contain",
|
|
@@ -7674,7 +7758,7 @@ var rangeReadings = (rule) => {
|
|
|
7674
7758
|
};
|
|
7675
7759
|
|
|
7676
7760
|
// src/helpers/carriers/view-transition.ts
|
|
7677
|
-
var
|
|
7761
|
+
var import_postcss2 = __toESM(require("postcss"), 1);
|
|
7678
7762
|
var markerPrefix = "jumi-vt-";
|
|
7679
7763
|
var invalidPrefix = "jumi-vt-invalid-";
|
|
7680
7764
|
var isStagingSelector = (selector) => STAGING_SHAPE.test(selector);
|
|
@@ -7816,10 +7900,10 @@ var viewTransitionProducts = (staging, isMotion) => {
|
|
|
7816
7900
|
}
|
|
7817
7901
|
return products;
|
|
7818
7902
|
};
|
|
7819
|
-
var
|
|
7903
|
+
var wrap2 = (node, conditions) => {
|
|
7820
7904
|
let wrapped = node;
|
|
7821
7905
|
for (const condition of [...conditions].reverse()) {
|
|
7822
|
-
wrapped =
|
|
7906
|
+
wrapped = import_postcss2.default.atRule({ name: condition.name, params: condition.params }).append(wrapped);
|
|
7823
7907
|
}
|
|
7824
7908
|
return wrapped;
|
|
7825
7909
|
};
|
|
@@ -7830,13 +7914,13 @@ function emitViewTransitions(root, staging, isMotion, data) {
|
|
|
7830
7914
|
warnings: products.warnings
|
|
7831
7915
|
};
|
|
7832
7916
|
for (const { conditions, identity, source } of products.identities) {
|
|
7833
|
-
const rule =
|
|
7834
|
-
rule.append(
|
|
7835
|
-
data.layer.append(
|
|
7917
|
+
const rule = import_postcss2.default.rule({ selector: source });
|
|
7918
|
+
rule.append(import_postcss2.default.decl({ prop: "view-transition-name", value: identity }));
|
|
7919
|
+
data.layer.append(wrap2(rule, conditions));
|
|
7836
7920
|
emission.emitted += 1;
|
|
7837
7921
|
}
|
|
7838
7922
|
if (!products.units.length) return emission;
|
|
7839
|
-
const preference =
|
|
7923
|
+
const preference = import_postcss2.default.atRule({
|
|
7840
7924
|
name: "media",
|
|
7841
7925
|
params: "(prefers-reduced-motion: no-preference)"
|
|
7842
7926
|
});
|
|
@@ -7844,7 +7928,7 @@ function emitViewTransitions(root, staging, isMotion, data) {
|
|
|
7844
7928
|
identity,
|
|
7845
7929
|
side
|
|
7846
7930
|
}) => `::view-transition-${side}(${identity})`;
|
|
7847
|
-
const supports =
|
|
7931
|
+
const supports = import_postcss2.default.atRule({
|
|
7848
7932
|
name: "supports",
|
|
7849
7933
|
// The capability is a fact about the browser, not about a name, so one guard covers the block — a
|
|
7850
7934
|
// browser that parses one of these pseudo-elements parses the rest. The side named is the first
|
|
@@ -7862,19 +7946,19 @@ function emitViewTransitions(root, staging, isMotion, data) {
|
|
|
7862
7946
|
}
|
|
7863
7947
|
for (const group of owning.values()) {
|
|
7864
7948
|
const [first] = group;
|
|
7865
|
-
const rule =
|
|
7949
|
+
const rule = import_postcss2.default.rule({ selector: group.map(pseudo).join(",\n") });
|
|
7866
7950
|
for (const { prop, value } of [...data.substrate, ...data.aggregate]) {
|
|
7867
|
-
rule.append(
|
|
7951
|
+
rule.append(import_postcss2.default.decl({ prop, value }));
|
|
7868
7952
|
}
|
|
7869
|
-
preference.append(
|
|
7953
|
+
preference.append(wrap2(rule, first.conditions));
|
|
7870
7954
|
emission.emitted += 1;
|
|
7871
7955
|
}
|
|
7872
7956
|
for (const unit of products.units) {
|
|
7873
|
-
const rule =
|
|
7957
|
+
const rule = import_postcss2.default.rule({ selector: pseudo(unit) });
|
|
7874
7958
|
for (const { prop, value } of unit.declarations)
|
|
7875
|
-
rule.append(
|
|
7876
|
-
rule.append(
|
|
7877
|
-
preference.append(
|
|
7959
|
+
rule.append(import_postcss2.default.decl({ prop, value }));
|
|
7960
|
+
rule.append(import_postcss2.default.decl({ prop: "mix-blend-mode", value: "plus-lighter" }));
|
|
7961
|
+
preference.append(wrap2(rule, unit.conditions));
|
|
7878
7962
|
emission.emitted += 1;
|
|
7879
7963
|
}
|
|
7880
7964
|
supports.append(preference);
|
|
@@ -7884,7 +7968,7 @@ function emitViewTransitions(root, staging, isMotion, data) {
|
|
|
7884
7968
|
|
|
7885
7969
|
// src/helpers/carriers/index.ts
|
|
7886
7970
|
var import_css84 = __toESM(require_css_escape(), 1);
|
|
7887
|
-
var
|
|
7971
|
+
var import_postcss3 = __toESM(require("postcss"), 1);
|
|
7888
7972
|
var import_shorthash22 = __toESM(require("shorthash2"), 1);
|
|
7889
7973
|
var REFUSED_NAME = /^--jumi-name-.+-refused$/;
|
|
7890
7974
|
var SHADOWED_NAME = /^--jumi-name-.+-shadowed$/;
|
|
@@ -8077,14 +8161,14 @@ var registerSelection = (root, variable) => {
|
|
|
8077
8161
|
root.walkAtRules("layer", (atRule) => {
|
|
8078
8162
|
if (atRule.params.trim() === "base") layers.push(atRule);
|
|
8079
8163
|
});
|
|
8080
|
-
const registration =
|
|
8164
|
+
const registration = import_postcss3.default.atRule({ name: "property", params: variable });
|
|
8081
8165
|
registration.append({ prop: "inherits", value: "false" });
|
|
8082
8166
|
registration.append({ prop: "syntax", value: '"*"' });
|
|
8083
8167
|
const base = layers[0] ?? null;
|
|
8084
8168
|
if (base) base.append(registration);
|
|
8085
8169
|
else
|
|
8086
8170
|
root.prepend(
|
|
8087
|
-
|
|
8171
|
+
import_postcss3.default.atRule({
|
|
8088
8172
|
name: "layer",
|
|
8089
8173
|
nodes: [registration],
|
|
8090
8174
|
params: "base"
|
|
@@ -8140,7 +8224,7 @@ var hoist = (staged, rules, selected, slots) => {
|
|
|
8140
8224
|
if (!value || published.has(prop)) continue;
|
|
8141
8225
|
published.add(prop);
|
|
8142
8226
|
rule.append(
|
|
8143
|
-
|
|
8227
|
+
import_postcss3.default.decl({ prop, value: namedHoist(own, value, key, selected) })
|
|
8144
8228
|
);
|
|
8145
8229
|
}
|
|
8146
8230
|
}
|
|
@@ -8157,7 +8241,7 @@ var hoist = (staged, rules, selected, slots) => {
|
|
|
8157
8241
|
if (published.has(prop)) continue;
|
|
8158
8242
|
published.add(prop);
|
|
8159
8243
|
rule.append(
|
|
8160
|
-
|
|
8244
|
+
import_postcss3.default.decl({
|
|
8161
8245
|
prop,
|
|
8162
8246
|
value: `var(${(0, import_css84.default)(`--jumi-label-${name}-${part}`)})`
|
|
8163
8247
|
})
|
|
@@ -8179,6 +8263,7 @@ function finalize(root, aggregate) {
|
|
|
8179
8263
|
viewTransitions: 0,
|
|
8180
8264
|
warnings: []
|
|
8181
8265
|
};
|
|
8266
|
+
unnest(root);
|
|
8182
8267
|
root.walkRules((rule) => {
|
|
8183
8268
|
const declarations = ownDeclarations(rule);
|
|
8184
8269
|
const staged = declarations.filter(
|
|
@@ -8218,7 +8303,7 @@ function finalize(root, aggregate) {
|
|
|
8218
8303
|
continue;
|
|
8219
8304
|
}
|
|
8220
8305
|
rule.append(
|
|
8221
|
-
|
|
8306
|
+
import_postcss3.default.decl({
|
|
8222
8307
|
prop: `--jumi-${reading.slot}-animation-range`,
|
|
8223
8308
|
value: reading.range
|
|
8224
8309
|
})
|
|
@@ -8343,12 +8428,12 @@ function finalize(root, aggregate) {
|
|
|
8343
8428
|
if (!rules?.length) continue;
|
|
8344
8429
|
const selectors = [...new Set(rules.map((rule) => rule.selector))];
|
|
8345
8430
|
const group = selectors.join(",\n");
|
|
8346
|
-
const composition =
|
|
8347
|
-
const defaults =
|
|
8431
|
+
const composition = import_postcss3.default.rule({ selector: group });
|
|
8432
|
+
const defaults = import_postcss3.default.rule({ selector: group });
|
|
8348
8433
|
for (const { prop, value } of aggregate2)
|
|
8349
|
-
composition.append(
|
|
8434
|
+
composition.append(import_postcss3.default.decl({ prop, value }));
|
|
8350
8435
|
for (const { prop, value } of substrate)
|
|
8351
|
-
defaults.append(
|
|
8436
|
+
defaults.append(import_postcss3.default.decl({ prop, value }));
|
|
8352
8437
|
if (!composition.nodes?.length) continue;
|
|
8353
8438
|
const layer = layerFor(root, rules[0]);
|
|
8354
8439
|
if (defaults.nodes?.length) defaultsLayerFor(root).prepend(defaults);
|
|
@@ -8368,12 +8453,12 @@ function finalize(root, aggregate) {
|
|
|
8368
8453
|
return finalized;
|
|
8369
8454
|
}
|
|
8370
8455
|
function finalizeCss(css2, aggregate) {
|
|
8371
|
-
const root =
|
|
8456
|
+
const root = import_postcss3.default.parse(css2);
|
|
8372
8457
|
return { ...finalize(root, aggregate), css: root.toString() };
|
|
8373
8458
|
}
|
|
8374
8459
|
|
|
8375
8460
|
// src/helpers/register/index.ts
|
|
8376
|
-
var
|
|
8461
|
+
var import_postcss4 = __toESM(require("postcss"), 1);
|
|
8377
8462
|
var pluginSpecifier = "@ibnlanre/jumi";
|
|
8378
8463
|
var isEntry = (atRule) => atRule.name === "tailwind" || atRule.name === "import" && /^["']?tailwindcss(\/[\w.-]+)*["']?(\s|$)/.test(atRule.params.trim());
|
|
8379
8464
|
var isJumi = (params, specifier) => {
|
|
@@ -8394,14 +8479,14 @@ function register(root, specifier = pluginSpecifier) {
|
|
|
8394
8479
|
registered = true;
|
|
8395
8480
|
}
|
|
8396
8481
|
if (!entry || registered) return { entry, injected: false };
|
|
8397
|
-
const directive =
|
|
8482
|
+
const directive = import_postcss4.default.atRule({ name: "plugin", params: `"${specifier}"` });
|
|
8398
8483
|
directive.raws.before = "\n";
|
|
8399
8484
|
if (lastImport) root.insertAfter(lastImport, directive);
|
|
8400
8485
|
else root.prepend(directive);
|
|
8401
8486
|
return { entry, injected: true };
|
|
8402
8487
|
}
|
|
8403
8488
|
function registerCss(css2, specifier = pluginSpecifier) {
|
|
8404
|
-
const root =
|
|
8489
|
+
const root = import_postcss4.default.parse(css2);
|
|
8405
8490
|
return { ...register(root, specifier), css: root.toString() };
|
|
8406
8491
|
}
|
|
8407
8492
|
|