react-native-css 0.0.0-nightly.04af4c6 → 0.0.0-nightly.08286a2

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.
@@ -47,11 +47,11 @@ export function maybeMutateReactNativeOptions(
47
47
  }
48
48
 
49
49
  /***********************************************
50
- * @nativeMapping *
50
+ * @prop *
51
51
  ***********************************************/
52
52
 
53
- function isNativeMappingAtRule(rule: Rule | PropAtRule): rule is PropAtRule {
54
- return rule.type === "unknown" && rule.value.name === "nativeMapping";
53
+ function isPropAtRule(rule: Rule | PropAtRule): rule is PropAtRule {
54
+ return rule.type === "unknown" && rule.value.name === "prop";
55
55
  }
56
56
 
57
57
  export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
@@ -71,14 +71,14 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
71
71
  if (!rules) return mapping;
72
72
 
73
73
  for (const rule of rules) {
74
- if (!isNativeMappingAtRule(rule)) continue;
74
+ if (!isPropAtRule(rule)) continue;
75
75
 
76
76
  if (rule.value.prelude.length > 0) {
77
77
  const prelude = rule.value.prelude.filter((item) => {
78
78
  return item.value.type !== "white-space";
79
79
  });
80
80
 
81
- nativeMappingAtRuleBlock(prelude, mapping);
81
+ propAtRuleBlock(prelude, mapping);
82
82
  } else if (rule.value.block) {
83
83
  // Remove all whitespace tokens
84
84
  const blocks = rule.value.block.filter((item) => {
@@ -91,7 +91,7 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
91
91
  });
92
92
 
93
93
  for (const block of blockRules) {
94
- nativeMappingAtRuleBlock(block, mapping);
94
+ propAtRuleBlock(block, mapping);
95
95
  }
96
96
  }
97
97
  }
@@ -99,7 +99,7 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
99
99
  return mapping;
100
100
  }
101
101
 
102
- function nativeMappingAtRuleBlock(
102
+ function propAtRuleBlock(
103
103
  token: Extract<TokenOrValue, { type: "token" }>[],
104
104
  mapping: StyleRuleMapping = {},
105
105
  ): StyleRuleMapping {
@@ -107,7 +107,7 @@ function nativeMappingAtRuleBlock(
107
107
  return item.value.type === "colon";
108
108
  });
109
109
 
110
- // @nativeMapping <to>; (has no from value)
110
+ // @props <to>; (has no from value)
111
111
  if (!to) {
112
112
  to = from;
113
113
  from = [
@@ -128,10 +128,10 @@ function nativeMappingAtRuleBlock(
128
128
  return mapping;
129
129
  }
130
130
 
131
- let value: string | string[] = to.flatMap((item, index) => {
131
+ mapping[toRNProperty(fromToken.value.value)] = to.flatMap((item, index) => {
132
132
  switch (item.value.type) {
133
133
  case "delim":
134
- return index === 0 && item.value.value === "&" ? ["&"] : [];
134
+ return index === 0 && item.value.value === "*" ? ["*"] : [];
135
135
  case "ident":
136
136
  return item.value.value.split(".").map((part) => toRNProperty(part));
137
137
  default:
@@ -139,11 +139,5 @@ function nativeMappingAtRuleBlock(
139
139
  }
140
140
  });
141
141
 
142
- if (value.length === 2 && value[0] === "&" && value[1]) {
143
- value = value[1];
144
- }
145
-
146
- mapping[toRNProperty(fromToken.value.value)] = value;
147
-
148
142
  return mapping;
149
143
  }
@@ -1984,11 +1984,11 @@ export function parseTextShadow(
1984
1984
  parseColor(textShadow.color, builder),
1985
1985
  );
1986
1986
  builder.addDescriptor(
1987
- "&.textShadowOffset.width",
1987
+ "*.textShadowOffset.width",
1988
1988
  parseLength(textShadow.xOffset, builder),
1989
1989
  );
1990
1990
  builder.addDescriptor(
1991
- "&.textShadowOffset.height",
1991
+ "*.textShadowOffset.height",
1992
1992
  parseLength(textShadow.yOffset, builder),
1993
1993
  );
1994
1994
  builder.addDescriptor(
@@ -2374,27 +2374,27 @@ export function parseBoxShadow(
2374
2374
  ) {
2375
2375
  for (const [index, shadow] of value.entries()) {
2376
2376
  builder.addDescriptor(
2377
- `&.boxShadow.[${index}].color`,
2377
+ `*.boxShadow.[${index}].color`,
2378
2378
  parseColor(shadow.color, builder),
2379
2379
  );
2380
2380
  builder.addDescriptor(
2381
- `&.boxShadow.[${index}].offsetX`,
2381
+ `*.boxShadow.[${index}].offsetX`,
2382
2382
  parseLength(shadow.xOffset, builder),
2383
2383
  );
2384
2384
  builder.addDescriptor(
2385
- `&.boxShadow.[${index}].offsetY`,
2385
+ `*.boxShadow.[${index}].offsetY`,
2386
2386
  parseLength(shadow.yOffset, builder),
2387
2387
  );
2388
2388
  builder.addDescriptor(
2389
- `&.boxShadow.[${index}].blurRadius`,
2389
+ `*.boxShadow.[${index}].blurRadius`,
2390
2390
  parseLength(shadow.blur, builder),
2391
2391
  );
2392
2392
  builder.addDescriptor(
2393
- `&.boxShadow.[${index}].spreadDistance`,
2393
+ `*.boxShadow.[${index}].spreadDistance`,
2394
2394
  parseLength(shadow.spread, builder),
2395
2395
  );
2396
2396
  builder.addDescriptor(
2397
- `&.boxShadow.[${index}].inset`,
2397
+ `*.boxShadow.[${index}].inset`,
2398
2398
  shadow.inset ? true : undefined,
2399
2399
  );
2400
2400
  }
@@ -3088,7 +3088,7 @@ function parseObjectFit(
3088
3088
  builder: StylesheetBuilder,
3089
3089
  ) {
3090
3090
  builder.addMapping({
3091
- "object-fit": ["contentFit"],
3091
+ "object-fit": "contentFit",
3092
3092
  });
3093
3093
  builder.addDescriptor(
3094
3094
  "object-fit",
@@ -3101,7 +3101,7 @@ function parseObjectPosition(
3101
3101
  builder: StylesheetBuilder,
3102
3102
  ) {
3103
3103
  builder.addMapping({
3104
- "object-position": ["contentPosition"],
3104
+ "object-position": "contentPosition",
3105
3105
  });
3106
3106
  builder.addDescriptor("object-position", [
3107
3107
  {},
@@ -56,7 +56,7 @@ export class StylesheetBuilder {
56
56
  private ruleTemplate: StyleRule = {
57
57
  s: [],
58
58
  },
59
- // Any default mapping should be included in the @nativeMapping parsing
59
+ // Any default mapping should be included in the @prop parsing
60
60
  private mapping: StyleRuleMapping = {},
61
61
  public descriptorProperty?: string,
62
62
  private shared: {
@@ -403,10 +403,12 @@ export class StylesheetBuilder {
403
403
  } else {
404
404
  forceTuple = true;
405
405
  }
406
+ } else if (propPath) {
407
+ forceTuple = true;
408
+ } else {
409
+ propPath = property;
406
410
  }
407
411
 
408
- propPath ??= property;
409
-
410
412
  if (forceTuple && !Array.isArray(propPath)) {
411
413
  propPath = [propPath];
412
414
  }
@@ -129,7 +129,7 @@ export function applyDeclarations(
129
129
  const final = rest.pop();
130
130
 
131
131
  if (final) {
132
- if (first !== "&") {
132
+ if (first !== "*") {
133
133
  topLevelTarget[first] ??= {};
134
134
  target = topLevelTarget[first];
135
135
  }