react-native-skelo 0.0.1 → 0.0.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/LICENSE +21 -0
- package/README.md +147 -20
- package/lib/commonjs/Skelo.js +104 -0
- package/lib/commonjs/Skelo.js.map +1 -0
- package/lib/commonjs/animations/AnimationWrapper.js +76 -0
- package/lib/commonjs/animations/AnimationWrapper.js.map +1 -0
- package/lib/commonjs/animations/PulseAnimation.js +76 -0
- package/lib/commonjs/animations/PulseAnimation.js.map +1 -0
- package/lib/commonjs/animations/ShimmerAnimation.js +103 -0
- package/lib/commonjs/animations/ShimmerAnimation.js.map +1 -0
- package/lib/commonjs/animations/index.js +27 -0
- package/lib/commonjs/animations/index.js.map +1 -0
- package/lib/commonjs/components/MeasuredBlock.js +64 -0
- package/lib/commonjs/components/MeasuredBlock.js.map +1 -0
- package/lib/commonjs/components/Skeleton.js +144 -0
- package/lib/commonjs/components/Skeleton.js.map +1 -0
- package/lib/commonjs/components/SkeletonIgnore.js +30 -0
- package/lib/commonjs/components/SkeletonIgnore.js.map +1 -0
- package/lib/commonjs/components/SkeletonRenderer.js +270 -0
- package/lib/commonjs/components/SkeletonRenderer.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonBox.js +47 -0
- package/lib/commonjs/components/primitives/SkeletonBox.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonCircle.js +44 -0
- package/lib/commonjs/components/primitives/SkeletonCircle.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonImage.js +46 -0
- package/lib/commonjs/components/primitives/SkeletonImage.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonText.js +60 -0
- package/lib/commonjs/components/primitives/SkeletonText.js.map +1 -0
- package/lib/commonjs/components/primitives/index.js +34 -0
- package/lib/commonjs/components/primitives/index.js.map +1 -0
- package/lib/commonjs/components/withSkeleton.js +45 -0
- package/lib/commonjs/components/withSkeleton.js.map +1 -0
- package/lib/commonjs/constants/defaults.js +43 -0
- package/lib/commonjs/constants/defaults.js.map +1 -0
- package/lib/commonjs/core/deepRegistry.js +18 -0
- package/lib/commonjs/core/deepRegistry.js.map +1 -0
- package/lib/commonjs/core/generator/StyleSkeleton.js +101 -0
- package/lib/commonjs/core/generator/StyleSkeleton.js.map +1 -0
- package/lib/commonjs/core/parser/Parser.js +84 -0
- package/lib/commonjs/core/parser/Parser.js.map +1 -0
- package/lib/commonjs/core/parser/expandOffline.js +83 -0
- package/lib/commonjs/core/parser/expandOffline.js.map +1 -0
- package/lib/commonjs/core/parser/hostTreeReconciler.js +228 -0
- package/lib/commonjs/core/parser/hostTreeReconciler.js.map +1 -0
- package/lib/commonjs/core/parser/index.js +13 -0
- package/lib/commonjs/core/parser/index.js.map +1 -0
- package/lib/commonjs/core/registry/SkeletonRegistry.js +113 -0
- package/lib/commonjs/core/registry/SkeletonRegistry.js.map +1 -0
- package/lib/commonjs/core/registry/index.js +19 -0
- package/lib/commonjs/core/registry/index.js.map +1 -0
- package/lib/commonjs/core/resolver/StyleResolver.js +83 -0
- package/lib/commonjs/core/resolver/StyleResolver.js.map +1 -0
- package/lib/commonjs/core/resolver/index.js +13 -0
- package/lib/commonjs/core/resolver/index.js.map +1 -0
- package/lib/commonjs/deep.js +18 -0
- package/lib/commonjs/deep.js.map +1 -0
- package/lib/commonjs/index.js +66 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/plugins/ImagePlugin.js +60 -0
- package/lib/commonjs/plugins/ImagePlugin.js.map +1 -0
- package/lib/commonjs/plugins/TextPlugin.js +70 -0
- package/lib/commonjs/plugins/TextPlugin.js.map +1 -0
- package/lib/commonjs/plugins/ViewPlugin.js +71 -0
- package/lib/commonjs/plugins/ViewPlugin.js.map +1 -0
- package/lib/commonjs/plugins/index.js +27 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/plugin.js +6 -0
- package/lib/commonjs/types/plugin.js.map +1 -0
- package/lib/commonjs/types/skeleton.js +6 -0
- package/lib/commonjs/types/skeleton.js.map +1 -0
- package/lib/commonjs/utils/componentUtils.js +138 -0
- package/lib/commonjs/utils/componentUtils.js.map +1 -0
- package/lib/commonjs/utils/index.js +62 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/styleUtils.js +76 -0
- package/lib/commonjs/utils/styleUtils.js.map +1 -0
- package/lib/module/Skelo.js +98 -0
- package/lib/module/Skelo.js.map +1 -0
- package/lib/module/animations/AnimationWrapper.js +69 -0
- package/lib/module/animations/AnimationWrapper.js.map +1 -0
- package/lib/module/animations/PulseAnimation.js +69 -0
- package/lib/module/animations/PulseAnimation.js.map +1 -0
- package/lib/module/animations/ShimmerAnimation.js +96 -0
- package/lib/module/animations/ShimmerAnimation.js.map +1 -0
- package/lib/module/animations/index.js +4 -0
- package/lib/module/animations/index.js.map +1 -0
- package/lib/module/components/MeasuredBlock.js +57 -0
- package/lib/module/components/MeasuredBlock.js.map +1 -0
- package/lib/module/components/Skeleton.js +138 -0
- package/lib/module/components/Skeleton.js.map +1 -0
- package/lib/module/components/SkeletonIgnore.js +23 -0
- package/lib/module/components/SkeletonIgnore.js.map +1 -0
- package/lib/module/components/SkeletonRenderer.js +264 -0
- package/lib/module/components/SkeletonRenderer.js.map +1 -0
- package/lib/module/components/primitives/SkeletonBox.js +40 -0
- package/lib/module/components/primitives/SkeletonBox.js.map +1 -0
- package/lib/module/components/primitives/SkeletonCircle.js +37 -0
- package/lib/module/components/primitives/SkeletonCircle.js.map +1 -0
- package/lib/module/components/primitives/SkeletonImage.js +39 -0
- package/lib/module/components/primitives/SkeletonImage.js.map +1 -0
- package/lib/module/components/primitives/SkeletonText.js +53 -0
- package/lib/module/components/primitives/SkeletonText.js.map +1 -0
- package/lib/module/components/primitives/index.js +5 -0
- package/lib/module/components/primitives/index.js.map +1 -0
- package/lib/module/components/withSkeleton.js +38 -0
- package/lib/module/components/withSkeleton.js.map +1 -0
- package/lib/module/constants/defaults.js +37 -0
- package/lib/module/constants/defaults.js.map +1 -0
- package/lib/module/core/deepRegistry.js +11 -0
- package/lib/module/core/deepRegistry.js.map +1 -0
- package/lib/module/core/generator/StyleSkeleton.js +95 -0
- package/lib/module/core/generator/StyleSkeleton.js.map +1 -0
- package/lib/module/core/parser/Parser.js +77 -0
- package/lib/module/core/parser/Parser.js.map +1 -0
- package/lib/module/core/parser/expandOffline.js +77 -0
- package/lib/module/core/parser/expandOffline.js.map +1 -0
- package/lib/module/core/parser/hostTreeReconciler.js +222 -0
- package/lib/module/core/parser/hostTreeReconciler.js.map +1 -0
- package/lib/module/core/parser/index.js +2 -0
- package/lib/module/core/parser/index.js.map +1 -0
- package/lib/module/core/registry/SkeletonRegistry.js +106 -0
- package/lib/module/core/registry/SkeletonRegistry.js.map +1 -0
- package/lib/module/core/registry/index.js +2 -0
- package/lib/module/core/registry/index.js.map +1 -0
- package/lib/module/core/resolver/StyleResolver.js +77 -0
- package/lib/module/core/resolver/StyleResolver.js.map +1 -0
- package/lib/module/core/resolver/index.js +2 -0
- package/lib/module/core/resolver/index.js.map +1 -0
- package/lib/module/deep.js +11 -0
- package/lib/module/deep.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/plugins/ImagePlugin.js +53 -0
- package/lib/module/plugins/ImagePlugin.js.map +1 -0
- package/lib/module/plugins/TextPlugin.js +63 -0
- package/lib/module/plugins/TextPlugin.js.map +1 -0
- package/lib/module/plugins/ViewPlugin.js +64 -0
- package/lib/module/plugins/ViewPlugin.js.map +1 -0
- package/lib/module/plugins/index.js +4 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/plugin.js.map +1 -0
- package/lib/module/types/skeleton.js +2 -0
- package/lib/module/types/skeleton.js.map +1 -0
- package/lib/module/utils/componentUtils.js +123 -0
- package/lib/module/utils/componentUtils.js.map +1 -0
- package/lib/module/utils/index.js +3 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/styleUtils.js +66 -0
- package/lib/module/utils/styleUtils.js.map +1 -0
- package/lib/typescript/Skelo.d.ts +76 -0
- package/lib/typescript/Skelo.d.ts.map +1 -0
- package/lib/typescript/animations/AnimationWrapper.d.ts +66 -0
- package/lib/typescript/animations/AnimationWrapper.d.ts.map +1 -0
- package/lib/typescript/animations/PulseAnimation.d.ts +59 -0
- package/lib/typescript/animations/PulseAnimation.d.ts.map +1 -0
- package/lib/typescript/animations/ShimmerAnimation.d.ts +59 -0
- package/lib/typescript/animations/ShimmerAnimation.d.ts.map +1 -0
- package/lib/typescript/animations/index.d.ts +5 -0
- package/lib/typescript/animations/index.d.ts.map +1 -0
- package/lib/typescript/components/MeasuredBlock.d.ts +32 -0
- package/lib/typescript/components/MeasuredBlock.d.ts.map +1 -0
- package/lib/typescript/components/Skeleton.d.ts +37 -0
- package/lib/typescript/components/Skeleton.d.ts.map +1 -0
- package/lib/typescript/components/SkeletonIgnore.d.ts +26 -0
- package/lib/typescript/components/SkeletonIgnore.d.ts.map +1 -0
- package/lib/typescript/components/SkeletonRenderer.d.ts +39 -0
- package/lib/typescript/components/SkeletonRenderer.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonBox.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonBox.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonCircle.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonCircle.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonImage.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonImage.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonText.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonText.d.ts.map +1 -0
- package/lib/typescript/components/primitives/index.d.ts +5 -0
- package/lib/typescript/components/primitives/index.d.ts.map +1 -0
- package/lib/typescript/components/withSkeleton.d.ts +37 -0
- package/lib/typescript/components/withSkeleton.d.ts.map +1 -0
- package/lib/typescript/constants/defaults.d.ts +29 -0
- package/lib/typescript/constants/defaults.d.ts.map +1 -0
- package/lib/typescript/core/deepRegistry.d.ts +7 -0
- package/lib/typescript/core/deepRegistry.d.ts.map +1 -0
- package/lib/typescript/core/generator/StyleSkeleton.d.ts +36 -0
- package/lib/typescript/core/generator/StyleSkeleton.d.ts.map +1 -0
- package/lib/typescript/core/parser/Parser.d.ts +30 -0
- package/lib/typescript/core/parser/Parser.d.ts.map +1 -0
- package/lib/typescript/core/parser/expandOffline.d.ts +10 -0
- package/lib/typescript/core/parser/expandOffline.d.ts.map +1 -0
- package/lib/typescript/core/parser/hostTreeReconciler.d.ts +28 -0
- package/lib/typescript/core/parser/hostTreeReconciler.d.ts.map +1 -0
- package/lib/typescript/core/parser/index.d.ts +2 -0
- package/lib/typescript/core/parser/index.d.ts.map +1 -0
- package/lib/typescript/core/registry/SkeletonRegistry.d.ts +57 -0
- package/lib/typescript/core/registry/SkeletonRegistry.d.ts.map +1 -0
- package/lib/typescript/core/registry/index.d.ts +2 -0
- package/lib/typescript/core/registry/index.d.ts.map +1 -0
- package/lib/typescript/core/resolver/StyleResolver.d.ts +54 -0
- package/lib/typescript/core/resolver/StyleResolver.d.ts.map +1 -0
- package/lib/typescript/core/resolver/index.d.ts +2 -0
- package/lib/typescript/core/resolver/index.d.ts.map +1 -0
- package/lib/typescript/deep.d.ts +2 -0
- package/lib/typescript/deep.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +17 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/plugins/ImagePlugin.d.ts +11 -0
- package/lib/typescript/plugins/ImagePlugin.d.ts.map +1 -0
- package/lib/typescript/plugins/TextPlugin.d.ts +12 -0
- package/lib/typescript/plugins/TextPlugin.d.ts.map +1 -0
- package/lib/typescript/plugins/ViewPlugin.d.ts +11 -0
- package/lib/typescript/plugins/ViewPlugin.d.ts.map +1 -0
- package/lib/typescript/plugins/index.d.ts +4 -0
- package/lib/typescript/plugins/index.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +3 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/plugin.d.ts +144 -0
- package/lib/typescript/types/plugin.d.ts.map +1 -0
- package/lib/typescript/types/skeleton.d.ts +176 -0
- package/lib/typescript/types/skeleton.d.ts.map +1 -0
- package/lib/typescript/utils/componentUtils.d.ts +40 -0
- package/lib/typescript/utils/componentUtils.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +3 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/styleUtils.d.ts +41 -0
- package/lib/typescript/utils/styleUtils.d.ts.map +1 -0
- package/package.json +171 -11
- package/src/Skelo.ts +103 -0
- package/src/animations/AnimationWrapper.tsx +139 -0
- package/src/animations/PulseAnimation.tsx +138 -0
- package/src/animations/ShimmerAnimation.tsx +169 -0
- package/src/animations/index.ts +4 -0
- package/src/components/MeasuredBlock.tsx +85 -0
- package/src/components/Skeleton.tsx +149 -0
- package/src/components/SkeletonIgnore.tsx +27 -0
- package/src/components/SkeletonRenderer.tsx +341 -0
- package/src/components/primitives/SkeletonBox.tsx +53 -0
- package/src/components/primitives/SkeletonCircle.tsx +48 -0
- package/src/components/primitives/SkeletonImage.tsx +50 -0
- package/src/components/primitives/SkeletonText.tsx +69 -0
- package/src/components/primitives/index.ts +4 -0
- package/src/components/withSkeleton.tsx +62 -0
- package/src/constants/defaults.ts +38 -0
- package/src/core/deepRegistry.ts +16 -0
- package/src/core/generator/StyleSkeleton.tsx +138 -0
- package/src/core/parser/Parser.ts +86 -0
- package/src/core/parser/expandOffline.tsx +83 -0
- package/src/core/parser/hostTreeReconciler.tsx +271 -0
- package/src/core/parser/index.ts +1 -0
- package/src/core/registry/SkeletonRegistry.ts +111 -0
- package/src/core/registry/index.ts +1 -0
- package/src/core/resolver/StyleResolver.ts +80 -0
- package/src/core/resolver/index.ts +1 -0
- package/src/deep.ts +12 -0
- package/src/index.ts +30 -0
- package/src/plugins/ImagePlugin.tsx +65 -0
- package/src/plugins/TextPlugin.tsx +71 -0
- package/src/plugins/ViewPlugin.tsx +67 -0
- package/src/plugins/index.ts +3 -0
- package/src/types/index.ts +14 -0
- package/src/types/plugin.ts +164 -0
- package/src/types/skeleton.ts +197 -0
- package/src/utils/componentUtils.ts +166 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/styleUtils.ts +72 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyleSheet, View } from 'react-native';
|
|
4
|
+
import { SkeletonBox, SkeletonText, SkeletonCircle } from '../../components/primitives';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A single named style, or an ordered list of styles, or a whole StyleSheet
|
|
8
|
+
* object as returned by `StyleSheet.create`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Turn one flattened style into the most appropriate skeleton primitive.
|
|
13
|
+
*
|
|
14
|
+
* Heuristics:
|
|
15
|
+
* - a `fontSize` with no explicit height → text bar
|
|
16
|
+
* - square with radius ≥ half its size → circle (avatar)
|
|
17
|
+
* - anything with width and/or height → box
|
|
18
|
+
* - a pure layout container (no visual dimensions) → skipped (returns null)
|
|
19
|
+
*/
|
|
20
|
+
function styleToSkeleton(rawStyle, key, config) {
|
|
21
|
+
const flat = StyleSheet.flatten(rawStyle) || {};
|
|
22
|
+
const {
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
borderRadius,
|
|
26
|
+
fontSize
|
|
27
|
+
} = flat;
|
|
28
|
+
const anim = {
|
|
29
|
+
animation: config.animation,
|
|
30
|
+
baseColor: config.baseColor,
|
|
31
|
+
highlightColor: config.highlightColor,
|
|
32
|
+
duration: config.duration
|
|
33
|
+
};
|
|
34
|
+
const spacing = {
|
|
35
|
+
marginTop: flat.marginTop ?? 0,
|
|
36
|
+
marginBottom: flat.marginBottom ?? 12
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Text-like: has a font size but isn't a fixed-height box.
|
|
40
|
+
if (fontSize != null && height == null) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(SkeletonText, _extends({
|
|
42
|
+
key: key,
|
|
43
|
+
lines: 1,
|
|
44
|
+
fontSize: fontSize,
|
|
45
|
+
lineHeight: flat.lineHeight,
|
|
46
|
+
width: width ?? '60%',
|
|
47
|
+
style: spacing
|
|
48
|
+
}, anim));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Circle / avatar: square with a radius that rounds it fully.
|
|
52
|
+
if (typeof width === 'number' && width === height && typeof borderRadius === 'number' && borderRadius >= width / 2) {
|
|
53
|
+
return /*#__PURE__*/React.createElement(SkeletonCircle, _extends({
|
|
54
|
+
key: key,
|
|
55
|
+
size: width,
|
|
56
|
+
style: spacing
|
|
57
|
+
}, anim));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Box: anything with an explicit dimension.
|
|
61
|
+
if (width != null || height != null) {
|
|
62
|
+
return /*#__PURE__*/React.createElement(SkeletonBox, _extends({
|
|
63
|
+
key: key,
|
|
64
|
+
width: width ?? '100%',
|
|
65
|
+
height: height ?? 20,
|
|
66
|
+
borderRadius: borderRadius ?? config.borderRadius ?? 4,
|
|
67
|
+
style: spacing
|
|
68
|
+
}, anim));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Pure layout container (no visual footprint) — nothing to draw.
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generates a skeleton directly from a set of styles.
|
|
77
|
+
*
|
|
78
|
+
* Because a StyleSheet is flat (no element hierarchy), the output is a vertical
|
|
79
|
+
* stack of skeleton shapes — one per style that has visual dimensions — sized
|
|
80
|
+
* from each style's own props. Layout-only styles are skipped.
|
|
81
|
+
*/
|
|
82
|
+
export function StyleSkeleton({
|
|
83
|
+
styles,
|
|
84
|
+
config,
|
|
85
|
+
exclude
|
|
86
|
+
}) {
|
|
87
|
+
const entries = Array.isArray(styles) ? styles.map((s, i) => [i, s]) : Object.entries(styles || {}).filter(([name]) => !exclude || !exclude.includes(name));
|
|
88
|
+
const nodes = entries.map(([key, style]) => styleToSkeleton(style, key, config)).filter(n => n !== null);
|
|
89
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
90
|
+
accessibilityRole: "progressbar",
|
|
91
|
+
accessible: true
|
|
92
|
+
}, nodes);
|
|
93
|
+
}
|
|
94
|
+
StyleSkeleton.displayName = 'Skeleton.FromStyles';
|
|
95
|
+
//# sourceMappingURL=StyleSkeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","View","SkeletonBox","SkeletonText","SkeletonCircle","styleToSkeleton","rawStyle","key","config","flat","flatten","width","height","borderRadius","fontSize","anim","animation","baseColor","highlightColor","duration","spacing","marginTop","marginBottom","createElement","_extends","lines","lineHeight","style","size","StyleSkeleton","styles","exclude","entries","Array","isArray","map","s","i","Object","filter","name","includes","nodes","n","accessibilityRole","accessible","displayName"],"sourceRoot":"../../../../src","sources":["core/generator/StyleSkeleton.tsx"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAG/C,SAASC,WAAW,EAAEC,YAAY,EAAEC,cAAc,QAAQ,6BAA6B;;AAEvF;AACA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CACtBC,QAAiB,EACjBC,GAAoB,EACpBC,MAAsB,EACK;EAC3B,MAAMC,IAAI,GAAIT,UAAU,CAAC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AACrB,WAAW,EAAAsB,QAAA;MACVjB,GAAG,EAAEA,GAAI;MACTI,KAAK,EAAGA,KAAK,IAAuB,MAAO;MAC3CC,MAAM,EAAGA,MAAM,IAAuB,EAAG;MACzCC,YAAY,EAAEA,YAAY,IAAIL,MAAM,CAACK,YAAY,IAAI,CAAE;MACvDc,KAAK,EAAEP;IAAQ,GACXL,IAAI,CACT,CAAC;EAEN;;EAEA;EACA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASc,aAAaA,CAAC;EAAEC,MAAM;EAAEtB,MAAM;EAAEuB;AAA4B,CAAC,EAAE;EAC7E,MAAMC,OAA0C,GAAGC,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,GACpEA,MAAM,CAACK,GAAG,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK,CAACA,CAAC,EAAED,CAAC,CAAC,CAAC,GAC5BE,MAAM,CAACN,OAAO,CAACF,MAAM,IAAI,CAAC,CAAC,CAAC,CAACS,MAAM,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,CAACT,OAAO,IAAI,CAACA,OAAO,CAACU,QAAQ,CAACD,IAAI,CAAC,CAAC;EAExF,MAAME,KAAK,GAAGV,OAAO,CAClBG,GAAG,CAAC,CAAC,CAAC5B,GAAG,EAAEoB,KAAK,CAAC,KAAKtB,eAAe,CAACsB,KAAK,EAAEpB,GAAG,EAAEC,MAAM,CAAC,CAAC,CAC1D+B,MAAM,CAAEI,CAAC,IAA8BA,CAAC,KAAK,IAAI,CAAC;EAErD,oBACE5C,KAAA,CAAAwB,aAAA,CAACtB,IAAI;IAAC2C,iBAAiB,EAAC,aAAa;IAACC,UAAU;EAAA,GAC7CH,KACG,CAAC;AAEX;AAEAb,aAAa,CAACiB,WAAW,GAAG,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { isValidElement } from 'react';
|
|
2
|
+
import { StyleResolver } from '../resolver';
|
|
3
|
+
import { getComponentName, flattenChildren } from '../../utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parser class for traversing and analyzing React component trees
|
|
7
|
+
*/
|
|
8
|
+
export class Parser {
|
|
9
|
+
/**
|
|
10
|
+
* Parse a React element tree into a component node tree
|
|
11
|
+
*
|
|
12
|
+
* @param children - React children to parse
|
|
13
|
+
* @returns Array of component nodes
|
|
14
|
+
*/
|
|
15
|
+
static parse(children) {
|
|
16
|
+
const flattened = flattenChildren(children);
|
|
17
|
+
const nodes = [];
|
|
18
|
+
flattened.forEach(child => {
|
|
19
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
20
|
+
// Skip non-element children (strings, numbers, null, etc.)
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const node = this.parseElement(child);
|
|
24
|
+
if (node) {
|
|
25
|
+
nodes.push(node);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return nodes;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Parse a single React element
|
|
33
|
+
*
|
|
34
|
+
* @param element - React element
|
|
35
|
+
* @returns Component node or null
|
|
36
|
+
*/
|
|
37
|
+
static parseElement(element) {
|
|
38
|
+
const type = getComponentName(element);
|
|
39
|
+
const props = element.props || {};
|
|
40
|
+
const style = StyleResolver.resolve(element);
|
|
41
|
+
|
|
42
|
+
// Parse children recursively
|
|
43
|
+
const children = props.children ? this.parse(props.children) : [];
|
|
44
|
+
return {
|
|
45
|
+
type,
|
|
46
|
+
props,
|
|
47
|
+
style,
|
|
48
|
+
children,
|
|
49
|
+
element
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Estimate number of text lines from content and style
|
|
55
|
+
*
|
|
56
|
+
* @param children - Text content
|
|
57
|
+
* @param style - Resolved style
|
|
58
|
+
* @returns Estimated number of lines
|
|
59
|
+
*/
|
|
60
|
+
static estimateTextLines(children, _style) {
|
|
61
|
+
if (!children) {
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Convert children to string
|
|
66
|
+
const text = React.Children.toArray(children).filter(child => typeof child === 'string' || typeof child === 'number').join('');
|
|
67
|
+
if (!text) {
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Simple heuristic: ~40 characters per line
|
|
72
|
+
const avgCharsPerLine = 40;
|
|
73
|
+
const estimatedLines = Math.ceil(text.length / avgCharsPerLine);
|
|
74
|
+
return Math.max(1, Math.min(estimatedLines, 5)); // Cap at 5 lines
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","isValidElement","StyleResolver","getComponentName","flattenChildren","Parser","parse","children","flattened","nodes","forEach","child","node","parseElement","push","element","type","props","style","resolve","estimateTextLines","_style","text","Children","toArray","filter","join","avgCharsPerLine","estimatedLines","Math","ceil","length","max","min"],"sourceRoot":"../../../../src","sources":["core/parser/Parser.ts"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,cAAc,QAAQ,OAAO;AAG7C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,aAAa;;AAE/D;AACA;AACA;AACA,OAAO,MAAMC,MAAM,CAAC;EAClB;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,KAAKA,CAACC,QAAmB,EAAmB;IACjD,MAAMC,SAAS,GAAGJ,eAAe,CAACG,QAAQ,CAAC;IAC3C,MAAME,KAAsB,GAAG,EAAE;IAEjCD,SAAS,CAACE,OAAO,CAACC,KAAK,IAAI;MACzB,IAAI,eAACV,cAAc,CAACU,KAAK,CAAC,EAAE;QAC1B;QACA;MACF;MAEA,MAAMC,IAAI,GAAG,IAAI,CAACC,YAAY,CAACF,KAAK,CAAC;MACrC,IAAIC,IAAI,EAAE;QACRH,KAAK,CAACK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 @@
|
|
|
1
|
+
import { resolveStyle } from '../../utils/styleUtils';
|
|
2
|
+
import { renderToHostTree } from './hostTreeReconciler';
|
|
3
|
+
/**
|
|
4
|
+
* Offline structural expansion.
|
|
5
|
+
*
|
|
6
|
+
* Renders an element (including opaque function/class components) through a
|
|
7
|
+
* JS-only `react-reconciler` renderer to recover its underlying host-element
|
|
8
|
+
* tree (View / Text / Image + resolved styles), then converts it to Skelo's
|
|
9
|
+
* `ComponentNode` tree.
|
|
10
|
+
*
|
|
11
|
+
* This is what lets `<Skeleton><AnyComponent/></Skeleton>` produce a *structured*
|
|
12
|
+
* skeleton without the developer inlining host elements — the core DX. No
|
|
13
|
+
* deprecated APIs, no `act()`.
|
|
14
|
+
*
|
|
15
|
+
* Caveats (inherent to rendering the real component):
|
|
16
|
+
* - The component's mount effects run during expansion. Effectful screens
|
|
17
|
+
* should be guarded or given an explicit skeleton via `Skelo.register`.
|
|
18
|
+
* - It renders outside the app's providers, so context-dependent components may
|
|
19
|
+
* throw — caught, returning null so the caller falls back to static parsing.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a host instance type to a canonical name the renderer understands.
|
|
24
|
+
* On device, RN host components may surface as native names (e.g. RCTView,
|
|
25
|
+
* RCTSinglelineTextInputView); map them to View/Text/Image/etc.
|
|
26
|
+
*/
|
|
27
|
+
function normalizeType(type) {
|
|
28
|
+
if (/image/i.test(type)) return 'Image';
|
|
29
|
+
if (/textinput/i.test(type)) return 'TextInput';
|
|
30
|
+
if (/text/i.test(type)) return 'Text';
|
|
31
|
+
if (/scroll/i.test(type)) return 'ScrollView';
|
|
32
|
+
if (/(flat|section|virtualized)list/i.test(type)) return 'FlatList';
|
|
33
|
+
// Everything else is treated as a plain container view.
|
|
34
|
+
return 'View';
|
|
35
|
+
}
|
|
36
|
+
function toComponentNode(node) {
|
|
37
|
+
if (node.type === '#text') {
|
|
38
|
+
return null; // text is folded into its parent's props.children
|
|
39
|
+
}
|
|
40
|
+
const textParts = [];
|
|
41
|
+
const elementChildren = [];
|
|
42
|
+
for (const child of node.children) {
|
|
43
|
+
if (child.type === '#text') {
|
|
44
|
+
if (child.text) textParts.push(child.text);
|
|
45
|
+
} else {
|
|
46
|
+
elementChildren.push(child);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const props = {
|
|
50
|
+
...node.props
|
|
51
|
+
};
|
|
52
|
+
if (textParts.length > 0 && props.children == null) {
|
|
53
|
+
props.children = textParts.join('');
|
|
54
|
+
}
|
|
55
|
+
const style = resolveStyle(node.props.style);
|
|
56
|
+
return {
|
|
57
|
+
type: normalizeType(node.type),
|
|
58
|
+
props,
|
|
59
|
+
style,
|
|
60
|
+
children: elementChildren.map(toComponentNode).filter(n => n !== null)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Expand an element to a `ComponentNode[]` via offline rendering.
|
|
66
|
+
*
|
|
67
|
+
* @returns the host-tree nodes, or `null` if offline rendering is unavailable
|
|
68
|
+
* (react-reconciler not installed) or the render failed.
|
|
69
|
+
*/
|
|
70
|
+
export function expandToComponentNodes(element) {
|
|
71
|
+
const tree = renderToHostTree(element);
|
|
72
|
+
if (!tree) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return tree.map(toComponentNode).filter(n => n !== null);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=expandOffline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["resolveStyle","renderToHostTree","normalizeType","type","test","toComponentNode","node","textParts","elementChildren","child","children","text","push","props","length","join","style","map","filter","n","expandToComponentNodes","element","tree"],"sourceRoot":"../../../../src","sources":["core/parser/expandOffline.tsx"],"mappings":"AAEA,SAASA,YAAY,QAAQ,wBAAwB;AACrD,SAASC,gBAAgB,QAAQ,sBAAsB;AAGvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,IAAI,EAAED,aAAa,CAACI,IAAI,CAACH,IAAI,CAAC;IAC9BU,KAAK;IACLG,KAAK;IACLN,QAAQ,EAAEF,eAAe,CAACS,GAAG,CAACZ,eAAe,CAAC,CAACa,MAAM,CAAEC,CAAC,IAAyBA,CAAC,KAAK,IAAI;EAC7F,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAACC,OAAqB,EAA0B;EACpF,MAAMC,IAAI,GAAGrB,gBAAgB,CAACoB,OAAO,CAAC;EACtC,IAAI,CAACC,IAAI,EAAE;IACT,OAAO,IAAI;EACb;EACA,OAAOA,IAAI,CAACL,GAAG,CAACZ,eAAe,CAAC,CAACa,MAAM,CAAEC,CAAC,IAAyBA,CAAC,KAAK,IAAI,CAAC;AAChF","ignoreList":[]}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A JS-only React renderer built on `react-reconciler`.
|
|
5
|
+
*
|
|
6
|
+
* It renders any element (including opaque function/class components) into a
|
|
7
|
+
* plain host-node tree — no native views, no `act()`, no deprecated APIs. Used
|
|
8
|
+
* to introspect a component's real View/Text/Image structure + styles so Skelo
|
|
9
|
+
* can generate a matching skeleton.
|
|
10
|
+
*
|
|
11
|
+
* Rendered as a synchronous LegacyRoot, so `updateContainer` flushes inline and
|
|
12
|
+
* we can read the tree immediately.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const NO_CONTEXT = {};
|
|
16
|
+
const DefaultEventPriority = 32; // DefaultLane
|
|
17
|
+
|
|
18
|
+
function makeHostConfig() {
|
|
19
|
+
// Reconciler 0.31 (React 19) tracks update priority via host methods.
|
|
20
|
+
let currentUpdatePriority = 0; // NoLane
|
|
21
|
+
return {
|
|
22
|
+
supportsMutation: true,
|
|
23
|
+
supportsPersistence: false,
|
|
24
|
+
supportsHydration: false,
|
|
25
|
+
isPrimaryRenderer: false,
|
|
26
|
+
noTimeout: -1,
|
|
27
|
+
now: () => Date.now(),
|
|
28
|
+
scheduleTimeout: setTimeout,
|
|
29
|
+
cancelTimeout: clearTimeout,
|
|
30
|
+
// Must be false: microtask scheduling defers the render, leaving the tree
|
|
31
|
+
// empty when we read it synchronously. Disabling it makes the LegacyRoot
|
|
32
|
+
// render commit inline inside updateContainer.
|
|
33
|
+
supportsMicrotasks: false,
|
|
34
|
+
getRootHostContext: () => NO_CONTEXT,
|
|
35
|
+
getChildHostContext: parent => parent,
|
|
36
|
+
getPublicInstance: instance => instance,
|
|
37
|
+
prepareForCommit: () => null,
|
|
38
|
+
resetAfterCommit: () => {},
|
|
39
|
+
preparePortalMount: () => {},
|
|
40
|
+
createInstance(type, props) {
|
|
41
|
+
return {
|
|
42
|
+
type,
|
|
43
|
+
props,
|
|
44
|
+
children: []
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
createTextInstance(text) {
|
|
48
|
+
return {
|
|
49
|
+
type: '#text',
|
|
50
|
+
props: {},
|
|
51
|
+
children: [],
|
|
52
|
+
text
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
appendInitialChild(parent, child) {
|
|
56
|
+
parent.children.push(child);
|
|
57
|
+
},
|
|
58
|
+
appendChild(parent, child) {
|
|
59
|
+
parent.children.push(child);
|
|
60
|
+
},
|
|
61
|
+
appendChildToContainer(container, child) {
|
|
62
|
+
container.children.push(child);
|
|
63
|
+
},
|
|
64
|
+
insertBefore(parent, child, before) {
|
|
65
|
+
const i = parent.children.indexOf(before);
|
|
66
|
+
if (i === -1) parent.children.push(child);else parent.children.splice(i, 0, child);
|
|
67
|
+
},
|
|
68
|
+
insertInContainerBefore(container, child, before) {
|
|
69
|
+
const i = container.children.indexOf(before);
|
|
70
|
+
if (i === -1) container.children.push(child);else container.children.splice(i, 0, child);
|
|
71
|
+
},
|
|
72
|
+
removeChild(parent, child) {
|
|
73
|
+
const i = parent.children.indexOf(child);
|
|
74
|
+
if (i !== -1) parent.children.splice(i, 1);
|
|
75
|
+
},
|
|
76
|
+
removeChildFromContainer(container, child) {
|
|
77
|
+
const i = container.children.indexOf(child);
|
|
78
|
+
if (i !== -1) container.children.splice(i, 1);
|
|
79
|
+
},
|
|
80
|
+
finalizeInitialChildren: () => false,
|
|
81
|
+
shouldSetTextContent: () => false,
|
|
82
|
+
prepareUpdate: () => ({}),
|
|
83
|
+
commitUpdate(instance, _payload, _type, _old, newProps) {
|
|
84
|
+
instance.props = newProps;
|
|
85
|
+
},
|
|
86
|
+
commitTextUpdate(textInstance, _old, next) {
|
|
87
|
+
textInstance.text = next;
|
|
88
|
+
},
|
|
89
|
+
clearContainer(container) {
|
|
90
|
+
container.children = [];
|
|
91
|
+
},
|
|
92
|
+
detachDeletedInstance: () => {},
|
|
93
|
+
// Required by React 18/19 reconcilers:
|
|
94
|
+
getCurrentEventPriority: () => DefaultEventPriority,
|
|
95
|
+
// Reconciler 0.31 (React 19) replaced the above with update-priority hooks;
|
|
96
|
+
// requestUpdateLane() calls these, so they must exist or it throws
|
|
97
|
+
// "undefined is not a function".
|
|
98
|
+
setCurrentUpdatePriority: priority => {
|
|
99
|
+
currentUpdatePriority = priority;
|
|
100
|
+
},
|
|
101
|
+
getCurrentUpdatePriority: () => currentUpdatePriority,
|
|
102
|
+
resolveUpdatePriority: () => currentUpdatePriority || DefaultEventPriority,
|
|
103
|
+
beforeActiveInstanceBlur: () => {},
|
|
104
|
+
afterActiveInstanceBlur: () => {},
|
|
105
|
+
prepareScopeUpdate: () => {},
|
|
106
|
+
getInstanceFromScope: () => null,
|
|
107
|
+
getInstanceFromNode: () => null,
|
|
108
|
+
// Newer reconciler (0.31 / React 19) additions — harmless on older versions:
|
|
109
|
+
maySuspendCommit: () => false,
|
|
110
|
+
startSuspendingCommit: () => {},
|
|
111
|
+
suspendInstance: () => {},
|
|
112
|
+
waitForCommitToBeReady: () => null,
|
|
113
|
+
NotPendingTransition: null,
|
|
114
|
+
// React 19 reads this context during render; it must be a real context.
|
|
115
|
+
HostTransitionContext: /*#__PURE__*/React.createContext(null),
|
|
116
|
+
resetFormInstance: () => {},
|
|
117
|
+
requestPostPaintCallback: () => {},
|
|
118
|
+
shouldAttemptEagerTransition: () => false,
|
|
119
|
+
trackSchedulerEvent: () => {},
|
|
120
|
+
resolveEventType: () => null,
|
|
121
|
+
resolveEventTimeStamp: () => -1.1
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
class RenderBoundary extends React.Component {
|
|
125
|
+
static getDerivedStateFromError() {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
render() {
|
|
129
|
+
return this.props.children;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
let cachedReconciler = null;
|
|
133
|
+
function getReconciler() {
|
|
134
|
+
if (cachedReconciler) return cachedReconciler;
|
|
135
|
+
const Reconciler = require('react-reconciler');
|
|
136
|
+
cachedReconciler = Reconciler.default || Reconciler;
|
|
137
|
+
return cachedReconciler;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Render an element to a plain host-node tree, or return null if the reconciler
|
|
142
|
+
* is unavailable or rendering failed.
|
|
143
|
+
*/
|
|
144
|
+
export function renderToHostTree(element) {
|
|
145
|
+
let Reconciler;
|
|
146
|
+
try {
|
|
147
|
+
Reconciler = getReconciler();
|
|
148
|
+
} catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
if (!Reconciler) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
// Wrap the host config so any method a newer reconciler calls that we
|
|
156
|
+
// didn't explicitly define resolves to a safe no-op instead of `undefined`
|
|
157
|
+
// (which throws "undefined is not a function"). All value-returning methods
|
|
158
|
+
// are defined above, so only side-effect methods hit this fallback.
|
|
159
|
+
const baseConfig = makeHostConfig();
|
|
160
|
+
const noopFn = () => {};
|
|
161
|
+
const safeConfig = new Proxy(baseConfig, {
|
|
162
|
+
get(target, prop) {
|
|
163
|
+
if (prop in target) return target[prop];
|
|
164
|
+
return noopFn;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const reconciler = Reconciler(safeConfig);
|
|
168
|
+
const container = {
|
|
169
|
+
children: []
|
|
170
|
+
};
|
|
171
|
+
const noop = () => {};
|
|
172
|
+
// createContainer's signature differs across reconciler versions:
|
|
173
|
+
// React 19 (reconciler 0.31) added onUncaughtError/onCaughtError before
|
|
174
|
+
// onRecoverableError; React 18 (0.29) has a single onRecoverableError.
|
|
175
|
+
const isReact19 = parseInt(React.version, 10) >= 19;
|
|
176
|
+
const root = isReact19 ? reconciler.createContainer(container, 0,
|
|
177
|
+
// LegacyRoot -> synchronous
|
|
178
|
+
null, false, null, '', noop,
|
|
179
|
+
// onUncaughtError
|
|
180
|
+
noop,
|
|
181
|
+
// onCaughtError
|
|
182
|
+
noop,
|
|
183
|
+
// onRecoverableError
|
|
184
|
+
null) : reconciler.createContainer(container, 0, null, false, null, '', noop,
|
|
185
|
+
// onRecoverableError
|
|
186
|
+
null);
|
|
187
|
+
const rc = reconciler;
|
|
188
|
+
const element0 = /*#__PURE__*/React.createElement(RenderBoundary, null, element);
|
|
189
|
+
|
|
190
|
+
// Render synchronously so the tree is populated before we read it.
|
|
191
|
+
// react-reconciler 0.31 (React 19) defers `updateContainer`; it exposes
|
|
192
|
+
// `updateContainerSync` + `flushSyncWork` for a guaranteed inline commit.
|
|
193
|
+
// Older 0.29 flushes inline via `flushSync(updateContainer)`.
|
|
194
|
+
if (typeof rc.updateContainerSync === 'function') {
|
|
195
|
+
rc.updateContainerSync(element0, root, null, noop);
|
|
196
|
+
rc.flushSyncWork?.();
|
|
197
|
+
} else if (typeof rc.flushSync === 'function') {
|
|
198
|
+
rc.flushSync(() => rc.updateContainer(element0, root, null, noop));
|
|
199
|
+
} else {
|
|
200
|
+
rc.updateContainer(element0, root, null, noop);
|
|
201
|
+
}
|
|
202
|
+
const tree = container.children.slice();
|
|
203
|
+
|
|
204
|
+
// Unmount to run cleanup.
|
|
205
|
+
if (typeof rc.updateContainerSync === 'function') {
|
|
206
|
+
rc.updateContainerSync(null, root, null, noop);
|
|
207
|
+
rc.flushSyncWork?.();
|
|
208
|
+
} else {
|
|
209
|
+
rc.updateContainer(null, root, null, noop);
|
|
210
|
+
}
|
|
211
|
+
if (__DEV__ && tree.length === 0) {
|
|
212
|
+
console.warn('[Skelo] Offline render produced an empty tree; falling back to static parsing.');
|
|
213
|
+
}
|
|
214
|
+
return tree;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if (__DEV__) {
|
|
217
|
+
console.warn('[Skelo] Offline render failed:', error);
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=hostTreeReconciler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","NO_CONTEXT","DefaultEventPriority","makeHostConfig","currentUpdatePriority","supportsMutation","supportsPersistence","supportsHydration","isPrimaryRenderer","noTimeout","now","Date","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","supportsMicrotasks","getRootHostContext","getChildHostContext","parent","getPublicInstance","instance","prepareForCommit","resetAfterCommit","preparePortalMount","createInstance","type","props","children","createTextInstance","text","appendInitialChild","child","push","appendChild","appendChildToContainer","container","insertBefore","before","i","indexOf","splice","insertInContainerBefore","removeChild","removeChildFromContainer","finalizeInitialChildren","shouldSetTextContent","prepareUpdate","commitUpdate","_payload","_type","_old","newProps","commitTextUpdate","textInstance","next","clearContainer","detachDeletedInstance","getCurrentEventPriority","setCurrentUpdatePriority","priority","getCurrentUpdatePriority","resolveUpdatePriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","prepareScopeUpdate","getInstanceFromScope","getInstanceFromNode","maySuspendCommit","startSuspendingCommit","suspendInstance","waitForCommitToBeReady","NotPendingTransition","HostTransitionContext","createContext","resetFormInstance","requestPostPaintCallback","shouldAttemptEagerTransition","trackSchedulerEvent","resolveEventType","resolveEventTimeStamp","RenderBoundary","Component","getDerivedStateFromError","render","cachedReconciler","getReconciler","Reconciler","require","default","renderToHostTree","element","baseConfig","noopFn","safeConfig","Proxy","get","target","prop","reconciler","noop","isReact19","parseInt","version","root","createContainer","rc","element0","createElement","updateContainerSync","flushSyncWork","flushSync","updateContainer","tree","slice","__DEV__","length","console","warn","error"],"sourceRoot":"../../../../src","sources":["core/parser/hostTreeReconciler.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;;AAGzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,MAAMC,UAAU,GAAG,CAAC,CAAC;AAErB,MAAMC,oBAAoB,GAAG,EAAE,CAAC,CAAC;;AAEjC,SAASC,cAAcA,CAAA,EAAG;EACxB;EACA,IAAIC,qBAAqB,GAAG,CAAC,CAAC,CAAC;EAC/B,OAAO;IACLC,gBAAgB,EAAE,IAAI;IACtBC,mBAAmB,EAAE,KAAK;IAC1BC,iBAAiB,EAAE,KAAK;IACxBC,iBAAiB,EAAE,KAAK;IACxBC,SAAS,EAAE,CAAC,CAAC;IACbC,GAAG,EAAEA,CAAA,KAAMC,IAAI,CAACD,GAAG,CAAC,CAAC;IACrBE,eAAe,EAAEC,UAAU;IAC3BC,aAAa,EAAEC,YAAY;IAC3B;IACA;IACA;IACAC,kBAAkB,EAAE,KAAK;IAEzBC,kBAAkB,EAAEA,CAAA,KAAMhB,UAAU;IACpCiB,mBAAmB,EAAGC,MAAe,IAAKA,MAAM;IAChDC,iBAAiB,EAAGC,QAAiB,IAAKA,QAAQ;IAClDC,gBAAgB,EAAEA,CAAA,KAAM,IAAI;IAC5BC,gBAAgB,EAAEA,CAAA,KAAM,CAAC,CAAC;IAC1BC,kBAAkB,EAAEA,CAAA,KAAM,CAAC,CAAC;IAE5BC,cAAcA,CAACC,IAAY,EAAEC,KAA4B,EAAgB;MACvE,OAAO;QAAED,IAAI;QAAEC,KAAK;QAAEC,QAAQ,EAAE;MAAG,CAAC;IACtC,CA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ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Parser"],"sourceRoot":"../../../../src","sources":["core/parser/index.ts"],"mappings":"AAAA,SAASA,MAAM,QAAQ,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for skeleton plugins
|
|
3
|
+
*
|
|
4
|
+
* Manages mapping between React components and their skeleton generation strategies
|
|
5
|
+
*/
|
|
6
|
+
export class SkeletonRegistry {
|
|
7
|
+
plugins = new Map();
|
|
8
|
+
nameIndex = new Map();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Register a plugin for a component
|
|
12
|
+
*
|
|
13
|
+
* @param plugin - Plugin configuration
|
|
14
|
+
* @throws Error if plugin is invalid
|
|
15
|
+
*/
|
|
16
|
+
register(plugin) {
|
|
17
|
+
// Validation
|
|
18
|
+
if (!plugin.name) {
|
|
19
|
+
throw new Error('[Skelo] Plugin must have a name');
|
|
20
|
+
}
|
|
21
|
+
if (!plugin.component) {
|
|
22
|
+
throw new Error('[Skelo] Plugin must specify a component');
|
|
23
|
+
}
|
|
24
|
+
if (!plugin.strategy) {
|
|
25
|
+
throw new Error('[Skelo] Plugin must have a strategy function');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Check for conflicts
|
|
29
|
+
if (this.plugins.has(plugin.component)) {
|
|
30
|
+
if (__DEV__) {
|
|
31
|
+
console.warn(`[Skelo] Plugin "${plugin.name}" is overriding existing plugin for component`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Register
|
|
36
|
+
this.plugins.set(plugin.component, plugin);
|
|
37
|
+
this.nameIndex.set(plugin.name, plugin);
|
|
38
|
+
if (__DEV__) {
|
|
39
|
+
console.log(`[Skelo] Registered plugin: ${plugin.name}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Unregister a plugin
|
|
45
|
+
*
|
|
46
|
+
* @param component - Component to unregister
|
|
47
|
+
*/
|
|
48
|
+
unregister(component) {
|
|
49
|
+
const plugin = this.plugins.get(component);
|
|
50
|
+
if (plugin) {
|
|
51
|
+
this.plugins.delete(component);
|
|
52
|
+
this.nameIndex.delete(plugin.name);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get plugin for a component
|
|
58
|
+
*
|
|
59
|
+
* @param component - Component type
|
|
60
|
+
* @returns Plugin or undefined
|
|
61
|
+
*/
|
|
62
|
+
getPlugin(component) {
|
|
63
|
+
return this.plugins.get(component);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get plugin by name
|
|
68
|
+
*
|
|
69
|
+
* @param name - Plugin name
|
|
70
|
+
* @returns Plugin or undefined
|
|
71
|
+
*/
|
|
72
|
+
getPluginByName(name) {
|
|
73
|
+
return this.nameIndex.get(name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check if component has a plugin
|
|
78
|
+
*
|
|
79
|
+
* @param component - Component type
|
|
80
|
+
* @returns True if plugin exists
|
|
81
|
+
*/
|
|
82
|
+
hasPlugin(component) {
|
|
83
|
+
return this.plugins.has(component);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get all registered plugins
|
|
88
|
+
*
|
|
89
|
+
* @returns Array of all plugins
|
|
90
|
+
*/
|
|
91
|
+
getAllPlugins() {
|
|
92
|
+
return Array.from(this.plugins.values());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Clear all plugins
|
|
97
|
+
*/
|
|
98
|
+
clear() {
|
|
99
|
+
this.plugins.clear();
|
|
100
|
+
this.nameIndex.clear();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Singleton instance
|
|
105
|
+
export const registry = new SkeletonRegistry();
|
|
106
|
+
//# sourceMappingURL=SkeletonRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SkeletonRegistry","plugins","Map","nameIndex","register","plugin","name","Error","component","strategy","has","__DEV__","console","warn","set","log","unregister","get","delete","getPlugin","getPluginByName","hasPlugin","getAllPlugins","Array","from","values","clear","registry"],"sourceRoot":"../../../../src","sources":["core/registry/SkeletonRegistry.ts"],"mappings":"AAGA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,CAAC;EACpBC,OAAO,GAA4C,IAAIC,GAAG,CAAC,CAAC;EAC5DC,SAAS,GAAgC,IAAID,GAAG,CAAC,CAAC;;EAE1D;AACF;AACA;AACA;AACA;AACA;EACEE,QAAQA,CAAIC,MAAyB,EAAQ;IAC3C;IACA,IAAI,CAACA,MAAM,CAACC,IAAI,EAAE;MAChB,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;IACpD;IAEA,IAAI,CAACF,MAAM,CAACG,SAAS,EAAE;MACrB,MAAM,IAAID,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IAEA,IAAI,CAACF,MAAM,CAACI,QAAQ,EAAE;MACpB,MAAM,IAAIF,KAAK,CAAC,8CAA8C,CAAC;IACjE;;IAEA;IACA,IAAI,IAAI,CAACN,OAAO,CAACS,GAAG,CAACL,MAAM,CAACG,SAAS,CAAC,EAAE;MACtC,IAAIG,OAAO,EAAE;QACXC,OAAO,CAACC,IAAI,CAAC,mBAAmBR,MAAM,CAACC,IAAI,+CAA+C,CAAC;MAC7F;IACF;;IAEA;IACA,IAAI,CAACL,OAAO,CAACa,GAAG,CAACT,MAAM,CAACG,SAAS,EAAEH,MAAM,CAAC;IAC1C,IAAI,CAACF,SAAS,CAACW,GAAG,CAACT,MAAM,CAACC,IAAI,EAAED,MAAM,CAAC;IAEvC,IAAIM,OAAO,EAAE;MACXC,OAAO,CAACG,GAAG,CAAC,8BAA8BV,MAAM,CAACC,IAAI,EAAE,CAAC;IAC1D;EACF;;EAEA;AACF;AACA;AACA;AACA;EACEU,UAAUA,CAACR,SAAwB,EAAQ;IACzC,MAAMH,MAAM,GAAG,IAAI,CAACJ,OAAO,CAACgB,GAAG,CAACT,SAAS,CAAC;IAC1C,IAAIH,MAAM,EAAE;MACV,IAAI,CAACJ,OAAO,CAACiB,MAAM,CAACV,SAAS,CAAC;MAC9B,IAAI,CAACL,SAAS,CAACe,MAAM,CAACb,MAAM,CAACC,IAAI,CAAC;IACpC;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEa,SAASA,CAACX,SAAwB,EAA8B;IAC9D,OAAO,IAAI,CAACP,OAAO,CAACgB,GAAG,CAACT,SAAS,CAAC;EACpC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEY,eAAeA,CAACd,IAAY,EAA8B;IACxD,OAAO,IAAI,CAACH,SAAS,CAACc,GAAG,CAACX,IAAI,CAAC;EACjC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEe,SAASA,CAACb,SAAwB,EAAW;IAC3C,OAAO,IAAI,CAACP,OAAO,CAACS,GAAG,CAACF,SAAS,CAAC;EACpC;;EAEA;AACF;AACA;AACA;AACA;EACEc,aAAaA,CAAA,EAAqB;IAChC,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACvB,OAAO,CAACwB,MAAM,CAAC,CAAC,CAAC;EAC1C;;EAEA;AACF;AACA;EACEC,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACzB,OAAO,CAACyB,KAAK,CAAC,CAAC;IACpB,IAAI,CAACvB,SAAS,CAACuB,KAAK,CAAC,CAAC;EACxB;AACF;;AAEA;AACA,OAAO,MAAMC,QAAQ,GAAG,IAAI3B,gBAAgB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SkeletonRegistry","registry"],"sourceRoot":"../../../../src","sources":["core/registry/index.ts"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,oBAAoB","ignoreList":[]}
|