@react-native-harness/babel-preset 1.6.0 → 1.7.0
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/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible-plugin.d.ts","sourceRoot":"","sources":["../src/collapsible-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiC,MAAM,aAAa,CAAC;AAE5E,QAAA,MAAM,iBAAiB,GAAI,eAExB,cAAc,aAAa,CAAC,KAAG,SA8BjC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const collapsiblePlugin = ({ types: t, }) => {
|
|
4
|
-
return {
|
|
5
|
-
name: 'react-native-harness-collapsible-plugin',
|
|
6
|
-
visitor: {
|
|
7
|
-
JSXOpeningElement(path) {
|
|
8
|
-
const { node } = path;
|
|
9
|
-
// 1. Check if the tag is named "View"
|
|
10
|
-
if (t.isJSXIdentifier(node.name) && node.name.name === 'View') {
|
|
11
|
-
// 2. Check if 'collapsable' is already defined to avoid overriding explicit props
|
|
12
|
-
const hasCollapsable = node.attributes.some((attr) => t.isJSXAttribute(attr) &&
|
|
13
|
-
t.isJSXIdentifier(attr.name) &&
|
|
14
|
-
attr.name.name === 'collapsable');
|
|
15
|
-
if (!hasCollapsable) {
|
|
16
|
-
// 3. Inject collapsable={true}
|
|
17
|
-
node.attributes.push(t.jsxAttribute(t.jsxIdentifier('collapsable'), t.jsxExpressionContainer(t.booleanLiteral(true))));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.default = collapsiblePlugin;
|
package/dist/global-plugin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-plugin.d.ts","sourceRoot":"","sources":["../src/global-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiC,MAAM,aAAa,CAAC;AAE5E,QAAA,MAAM,qBAAqB,GAAI,eAE5B,cAAc,aAAa,CAAC,KAAG,SAyCjC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
package/dist/global-plugin.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const globalRnHarnessPlugin = ({ types: t, }) => {
|
|
4
|
-
return {
|
|
5
|
-
name: 'react-native-harness-global-plugin',
|
|
6
|
-
visitor: {
|
|
7
|
-
// Replace global.RN_HARNESS with the configured value (only reads, not assignments)
|
|
8
|
-
MemberExpression(path) {
|
|
9
|
-
const { node } = path;
|
|
10
|
-
// Check if this is global.RN_HARNESS
|
|
11
|
-
if (t.isIdentifier(node.object, { name: 'global' }) &&
|
|
12
|
-
t.isIdentifier(node.property, { name: 'RN_HARNESS' })) {
|
|
13
|
-
// Only transform reads, not assignments
|
|
14
|
-
// Check if this member expression is the left side of an assignment
|
|
15
|
-
const parent = path.parent;
|
|
16
|
-
if (t.isAssignmentExpression(parent) && parent.left === node) {
|
|
17
|
-
// This is an assignment like: global.RN_HARNESS = value
|
|
18
|
-
// Skip transformation
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const rnHarnessValue = !!process.env.RN_HARNESS;
|
|
22
|
-
path.replaceWith(t.booleanLiteral(rnHarnessValue));
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
// Optimize conditional expressions (ternary operators) - run after member expressions
|
|
26
|
-
ConditionalExpression: {
|
|
27
|
-
exit(path) {
|
|
28
|
-
const { node } = path;
|
|
29
|
-
// If the test is a boolean literal, we can eliminate the dead branch
|
|
30
|
-
if (t.isBooleanLiteral(node.test)) {
|
|
31
|
-
const result = node.test.value ? node.consequent : node.alternate;
|
|
32
|
-
path.replaceWith(result);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
exports.default = globalRnHarnessPlugin;
|