@developer_tribe/react-builder 1.2.20 → 1.2.22
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/dist/attribute-analyser/style/web/useExtractTextStyle.d.ts +1 -1
- package/dist/build-components/BIcon/BIconProps.generated.d.ts +2 -0
- package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +2 -0
- package/dist/build-components/Button/ButtonProps.generated.d.ts +2 -0
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +2 -0
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +2 -0
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +2 -0
- package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +2 -0
- package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +2 -0
- package/dist/build-components/CountDown/CountDownProps.generated.d.ts +2 -0
- package/dist/build-components/Counter/CounterProps.generated.d.ts +2 -0
- package/dist/build-components/Image/ImageProps.generated.d.ts +2 -0
- package/dist/build-components/Main/MainProps.generated.d.ts +2 -0
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallBackground/PaywallBackgroundProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallCounter/PaywallCounterProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallOptions/PaywallOptionsProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.d.ts +2 -0
- package/dist/build-components/RadioButton/RadioButtonProps.generated.d.ts +2 -0
- package/dist/build-components/Text/TextProps.generated.d.ts +2 -0
- package/dist/build-components/View/View.d.ts +1 -1
- package/dist/build-components/View/ViewProps.generated.d.ts +2 -0
- package/dist/build-components/patterns.generated.d.ts +287 -2
- package/dist/components/BuilderButton.d.ts +3 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +4 -4
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.esm.js +4 -4
- package/dist/index.web.esm.js.map +1 -1
- package/dist/store.d.ts +2 -0
- package/dist/styles.css +1 -1
- package/dist/utils/extractTextStyle/extractTextStyle.d.ts +1 -0
- package/package.json +1 -1
- package/scripts/migrate-patterns-to-v2.mjs +13 -8
- package/scripts/prebuild/icon-generator.js +34 -37
- package/src/assets/loading_animation.json +2587 -1
- package/src/assets/meta.json +1 -1
- package/src/assets/samples/carousel-sample.json +279 -197
- package/src/assets/samples/getSamples.ts +16 -1
- package/src/assets/samples/paywall-1.json +16 -0
- package/src/assets/samples/paywall-2.json +2 -2
- package/src/assets/samples/paywall-app-delete-offer.json +353 -0
- package/src/assets/samples/paywall-app-open-offer.json +353 -0
- package/src/assets/samples/paywall-back-offer.json +353 -0
- package/src/assets/samples/paywall-notification-offer.json +353 -0
- package/src/assets/samples/vpn-onboard-1.json +23 -12
- package/src/assets/samples/vpn-onboard-2.json +23 -12
- package/src/assets/samples/vpn-onboard-3.json +23 -12
- package/src/assets/samples/vpn-onboard-4.json +23 -12
- package/src/assets/samples/vpn-onboard-5.json +23 -12
- package/src/assets/samples/vpn-onboard-6.json +23 -12
- package/src/attribute-analyser/style/web/useExtractTextStyle.ts +9 -2
- package/src/build-components/BIcon/BIconProps.generated.ts +2 -0
- package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +2 -0
- package/src/build-components/Button/ButtonProps.generated.ts +2 -0
- package/src/build-components/Carousel/CarouselProps.generated.ts +2 -0
- package/src/build-components/Carousel/pattern.json +2 -8
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +2 -0
- package/src/build-components/CarouselButtons/pattern.json +2 -9
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +2 -0
- package/src/build-components/CarouselDots/pattern.json +1 -3
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +2 -0
- package/src/build-components/CarouselItem/pattern.json +1 -3
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +5 -44
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +2 -0
- package/src/build-components/CarouselProvider/pattern.json +6 -0
- package/src/build-components/CountDown/CountDownProps.generated.ts +2 -0
- package/src/build-components/CountDown/pattern.json +0 -1
- package/src/build-components/Counter/CounterProps.generated.ts +2 -0
- package/src/build-components/Counter/pattern.json +0 -1
- package/src/build-components/Image/Image.tsx +1 -1
- package/src/build-components/Image/ImageProps.generated.ts +2 -0
- package/src/build-components/Main/MainProps.generated.ts +2 -0
- package/src/build-components/Main/pattern.json +1 -3
- package/src/build-components/Onboard/OnboardProps.generated.ts +2 -0
- package/src/build-components/Onboard/pattern.json +2 -6
- package/src/build-components/OnboardButton/OnboardButton.tsx +0 -4
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +2 -0
- package/src/build-components/OnboardButton/pattern.json +9 -14
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +17 -20
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +2 -0
- package/src/build-components/OnboardButtons/pattern.json +15 -15
- package/src/build-components/OnboardDot/OnboardDot.tsx +0 -3
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +2 -0
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +63 -51
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +2 -0
- package/src/build-components/OnboardFooter/pattern.json +6 -3
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +2 -0
- package/src/build-components/OnboardImage/pattern.json +1 -5
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +2 -0
- package/src/build-components/OnboardItem/pattern.json +3 -11
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +2 -0
- package/src/build-components/OnboardProvider/pattern.json +2 -8
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +2 -0
- package/src/build-components/OnboardSubtitle/pattern.json +1 -4
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +2 -0
- package/src/build-components/OnboardTitle/pattern.json +1 -4
- package/src/build-components/PaywallBackground/PaywallBackgroundProps.generated.ts +2 -0
- package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +2 -0
- package/src/build-components/PaywallCloseButton/pattern.json +1 -3
- package/src/build-components/PaywallCounter/PaywallCounterProps.generated.ts +2 -0
- package/src/build-components/PaywallCounter/pattern.json +0 -1
- package/src/build-components/PaywallOptions/PaywallOptions.tsx +1 -1
- package/src/build-components/PaywallOptions/PaywallOptionsProps.generated.ts +2 -0
- package/src/build-components/PaywallOptions/pattern.json +1 -3
- package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +2 -0
- package/src/build-components/PaywallProvider/pattern.json +1 -3
- package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.ts +2 -0
- package/src/build-components/PaywallSubscribeButton/pattern.json +1 -3
- package/src/build-components/RadioButton/RadioButtonProps.generated.ts +2 -0
- package/src/build-components/RadioButton/pattern.json +1 -3
- package/src/build-components/RenderNode.generated.tsx +1 -1
- package/src/build-components/Text/TextProps.generated.ts +2 -0
- package/src/build-components/View/View.tsx +11 -7
- package/src/build-components/View/ViewProps.generated.ts +2 -0
- package/src/build-components/View/pattern.json +8 -0
- package/src/build-components/patterns.generated.ts +277 -2
- package/src/build-components/useNode.ts +2 -2
- package/src/components/Builder.tsx +98 -8
- package/src/components/BuilderButton.tsx +39 -7
- package/src/components/DeviceButton.tsx +5 -1
- package/src/pages/DebugJsonPage.tsx +30 -1
- package/src/pages/ProjectDebug.tsx +0 -1
- package/src/pages/ProjectPage.tsx +2 -2
- package/src/store.ts +8 -0
- package/src/styles/base/_global.scss +0 -5
- package/src/styles/components/_editor-shell.scss +18 -3
- package/src/styles/components/_onboard.scss +0 -17
- package/src/styles/foundation/_colors.scss +1 -4
- package/src/styles/foundation/_typography.scss +0 -1
- package/src/styles/layout/_builder.scss +20 -0
- package/src/styles/modals/_product-presets-modal.scss +0 -2
- package/src/utils/extractTextStyle/extractTextStyle.ts +47 -13
- package/src/utils/extractViewStyle/extractViewStyle.ts +118 -39
- package/src/utils/logRenderStore.ts +7 -9
- package/src/utils/logger.ts +1 -5
- package/src/utils/repairNodeKeys.ts +1 -4
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ViewPropsGenerated,
|
|
3
|
+
type ViewStyleGenerated,
|
|
4
|
+
} from '../../build-components/View/ViewProps.generated';
|
|
2
5
|
import type { NodeData } from '../../types/Node';
|
|
3
6
|
import type { ProjectColors } from '../../types/Project';
|
|
4
7
|
import { parseSize } from '../../size-matters';
|
|
@@ -14,16 +17,16 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
14
17
|
options: ExtractViewStyleOptions = {},
|
|
15
18
|
) {
|
|
16
19
|
const attributes = node.attributes;
|
|
17
|
-
const styleBag = (attributes as
|
|
18
|
-
|
|
|
20
|
+
const styleBag = (attributes as Record<string, unknown>)?.style as
|
|
21
|
+
| ViewStyleGenerated
|
|
19
22
|
| undefined;
|
|
20
23
|
const get = (key: string): unknown => {
|
|
21
|
-
const direct = (attributes as
|
|
24
|
+
const direct = (attributes as Record<string, unknown>)?.[key];
|
|
22
25
|
if (direct !== undefined && direct !== null) return direct;
|
|
23
|
-
return styleBag?.[key];
|
|
26
|
+
return styleBag?.[key as keyof ViewStyleGenerated];
|
|
24
27
|
};
|
|
25
28
|
|
|
26
|
-
const scrollable = (get('scrollable') as
|
|
29
|
+
const scrollable = (get('scrollable') as boolean | undefined) ?? false;
|
|
27
30
|
const style: React.CSSProperties = {
|
|
28
31
|
display: 'flex',
|
|
29
32
|
flexDirection: 'column',
|
|
@@ -50,7 +53,13 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
const flexDirection = get('flexDirection');
|
|
53
|
-
if (flexDirection)
|
|
56
|
+
if (flexDirection) {
|
|
57
|
+
style.flexDirection = flexDirection as React.CSSProperties['flexDirection'];
|
|
58
|
+
}
|
|
59
|
+
const flexWrap = get('flexWrap');
|
|
60
|
+
if (flexWrap) {
|
|
61
|
+
style.flexWrap = flexWrap as React.CSSProperties['flexWrap'];
|
|
62
|
+
}
|
|
54
63
|
const alignItems = get('alignItems');
|
|
55
64
|
if (alignItems)
|
|
56
65
|
style.alignItems = alignItems as React.CSSProperties['alignItems'];
|
|
@@ -67,17 +76,20 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
67
76
|
style[property] = parsed as React.CSSProperties[K];
|
|
68
77
|
};
|
|
69
78
|
|
|
70
|
-
setParsedSize('gap', get('gap') as
|
|
71
|
-
setParsedSize('padding', get('padding') as
|
|
72
|
-
setParsedSize('margin', get('margin') as
|
|
79
|
+
setParsedSize('gap', get('gap') as string | number | undefined);
|
|
80
|
+
setParsedSize('padding', get('padding') as string | number | undefined);
|
|
81
|
+
setParsedSize('margin', get('margin') as string | number | undefined);
|
|
73
82
|
|
|
74
|
-
const paddingHorizontal = get('paddingHorizontal') as
|
|
83
|
+
const paddingHorizontal = get('paddingHorizontal') as
|
|
84
|
+
| string
|
|
85
|
+
| number
|
|
86
|
+
| undefined;
|
|
75
87
|
if (!isEmptySizeValue(paddingHorizontal)) {
|
|
76
88
|
const parsed = parseSize(paddingHorizontal);
|
|
77
89
|
style.paddingLeft = parsed as React.CSSProperties['paddingLeft'];
|
|
78
90
|
style.paddingRight = parsed as React.CSSProperties['paddingRight'];
|
|
79
91
|
}
|
|
80
|
-
const paddingVertical = get('paddingVertical') as
|
|
92
|
+
const paddingVertical = get('paddingVertical') as string | number | undefined;
|
|
81
93
|
if (!isEmptySizeValue(paddingVertical)) {
|
|
82
94
|
const parsed = parseSize(paddingVertical);
|
|
83
95
|
style.paddingTop = parsed as React.CSSProperties['paddingTop'];
|
|
@@ -85,34 +97,50 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
// Explicit per-side paddings should override paddingHorizontal/paddingVertical.
|
|
88
|
-
setParsedSize('paddingTop', get('paddingTop') as
|
|
89
|
-
setParsedSize(
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
setParsedSize('paddingTop', get('paddingTop') as string | number | undefined);
|
|
101
|
+
setParsedSize(
|
|
102
|
+
'paddingBottom',
|
|
103
|
+
get('paddingBottom') as string | number | undefined,
|
|
104
|
+
);
|
|
105
|
+
setParsedSize(
|
|
106
|
+
'paddingLeft',
|
|
107
|
+
get('paddingLeft') as string | number | undefined,
|
|
108
|
+
);
|
|
109
|
+
setParsedSize(
|
|
110
|
+
'paddingRight',
|
|
111
|
+
get('paddingRight') as string | number | undefined,
|
|
112
|
+
);
|
|
92
113
|
|
|
93
114
|
const marginHorizontalRaw =
|
|
94
115
|
((attributes as Record<string, unknown>).marginHorizontal as
|
|
95
116
|
| string
|
|
96
117
|
| number
|
|
97
|
-
| undefined) ??
|
|
118
|
+
| undefined) ??
|
|
119
|
+
(styleBag?.marginHorizontal as string | number | undefined);
|
|
98
120
|
if (!isEmptySizeValue(marginHorizontalRaw)) {
|
|
99
121
|
const parsed = parseSize(marginHorizontalRaw);
|
|
100
122
|
style.marginLeft = parsed as React.CSSProperties['marginLeft'];
|
|
101
123
|
style.marginRight = parsed as React.CSSProperties['marginRight'];
|
|
102
124
|
}
|
|
103
125
|
|
|
104
|
-
const marginVertical = get('marginVertical') as
|
|
126
|
+
const marginVertical = get('marginVertical') as string | number | undefined;
|
|
105
127
|
if (!isEmptySizeValue(marginVertical)) {
|
|
106
128
|
const parsed = parseSize(marginVertical);
|
|
107
129
|
style.marginTop = parsed as React.CSSProperties['marginTop'];
|
|
108
130
|
style.marginBottom = parsed as React.CSSProperties['marginBottom'];
|
|
109
131
|
}
|
|
110
132
|
|
|
111
|
-
setParsedSize('marginTop', get('marginTop') as
|
|
112
|
-
setParsedSize(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
setParsedSize('marginTop', get('marginTop') as string | number | undefined);
|
|
134
|
+
setParsedSize(
|
|
135
|
+
'marginBottom',
|
|
136
|
+
get('marginBottom') as string | number | undefined,
|
|
137
|
+
);
|
|
138
|
+
setParsedSize('marginLeft', get('marginLeft') as string | number | undefined);
|
|
139
|
+
setParsedSize(
|
|
140
|
+
'marginRight',
|
|
141
|
+
get('marginRight') as string | number | undefined,
|
|
142
|
+
);
|
|
143
|
+
const backgroundColor = get('backgroundColor') as string | undefined;
|
|
116
144
|
if (backgroundColor) {
|
|
117
145
|
style.backgroundColor =
|
|
118
146
|
parseColor(backgroundColor, {
|
|
@@ -120,23 +148,74 @@ export function extractViewStyle<T extends ViewPropsGenerated['attributes']>(
|
|
|
120
148
|
theme: options.theme,
|
|
121
149
|
}) ?? backgroundColor;
|
|
122
150
|
}
|
|
123
|
-
setParsedSize(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
setParsedSize('
|
|
128
|
-
setParsedSize('
|
|
129
|
-
setParsedSize('
|
|
130
|
-
|
|
151
|
+
setParsedSize(
|
|
152
|
+
'borderRadius',
|
|
153
|
+
get('borderRadius') as string | number | undefined,
|
|
154
|
+
);
|
|
155
|
+
setParsedSize('width', get('width') as string | number | undefined);
|
|
156
|
+
setParsedSize('minWidth', get('minWidth') as string | number | undefined);
|
|
157
|
+
setParsedSize('maxWidth', get('maxWidth') as string | number | undefined);
|
|
158
|
+
setParsedSize('height', get('height') as string | number | undefined);
|
|
159
|
+
setParsedSize('minHeight', get('minHeight') as string | number | undefined);
|
|
160
|
+
setParsedSize('maxHeight', get('maxHeight') as string | number | undefined);
|
|
161
|
+
const flex = get('flex') as number | undefined;
|
|
131
162
|
if (flex !== undefined) style.flex = flex as React.CSSProperties['flex'];
|
|
132
|
-
const position = get('position') as
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
setParsedSize('
|
|
137
|
-
setParsedSize('
|
|
138
|
-
|
|
163
|
+
const position = get('position') as
|
|
164
|
+
| React.CSSProperties['position']
|
|
165
|
+
| undefined;
|
|
166
|
+
if (position) style.position = position;
|
|
167
|
+
setParsedSize('top', get('top') as string | number | undefined);
|
|
168
|
+
setParsedSize('bottom', get('bottom') as string | number | undefined);
|
|
169
|
+
setParsedSize('left', get('left') as string | number | undefined);
|
|
170
|
+
setParsedSize('right', get('right') as string | number | undefined);
|
|
171
|
+
const zIndex = get('zIndex') as number | undefined;
|
|
139
172
|
if (zIndex !== undefined)
|
|
140
173
|
style.zIndex = zIndex as React.CSSProperties['zIndex'];
|
|
141
|
-
|
|
174
|
+
|
|
175
|
+
// Filter out any text style properties that might have been included
|
|
176
|
+
const viewStyleProperties = new Set<keyof React.CSSProperties>([
|
|
177
|
+
'display',
|
|
178
|
+
'flexDirection',
|
|
179
|
+
'flexWrap',
|
|
180
|
+
'alignItems',
|
|
181
|
+
'justifyContent',
|
|
182
|
+
'gap',
|
|
183
|
+
'padding',
|
|
184
|
+
'paddingTop',
|
|
185
|
+
'paddingBottom',
|
|
186
|
+
'paddingLeft',
|
|
187
|
+
'paddingRight',
|
|
188
|
+
'margin',
|
|
189
|
+
'marginTop',
|
|
190
|
+
'marginBottom',
|
|
191
|
+
'marginLeft',
|
|
192
|
+
'marginRight',
|
|
193
|
+
'backgroundColor',
|
|
194
|
+
'borderRadius',
|
|
195
|
+
'width',
|
|
196
|
+
'minWidth',
|
|
197
|
+
'maxWidth',
|
|
198
|
+
'height',
|
|
199
|
+
'minHeight',
|
|
200
|
+
'maxHeight',
|
|
201
|
+
'flex',
|
|
202
|
+
'position',
|
|
203
|
+
'top',
|
|
204
|
+
'bottom',
|
|
205
|
+
'left',
|
|
206
|
+
'right',
|
|
207
|
+
'zIndex',
|
|
208
|
+
'overflowX',
|
|
209
|
+
'overflowY',
|
|
210
|
+
]);
|
|
211
|
+
|
|
212
|
+
const filteredStyle: React.CSSProperties = {};
|
|
213
|
+
for (const key in style) {
|
|
214
|
+
const typedKey = key as keyof React.CSSProperties;
|
|
215
|
+
if (viewStyleProperties.has(typedKey)) {
|
|
216
|
+
(filteredStyle as Record<string, unknown>)[key] = style[typedKey];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return filteredStyle;
|
|
142
221
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
// This file is a debug utility specifically designed to log to console for debugging purposes.
|
|
1
3
|
import { useRenderStore } from '../store';
|
|
2
4
|
|
|
3
5
|
export type LogRenderStoreOptions = {
|
|
@@ -17,7 +19,7 @@ function safeStringify(value: unknown): string {
|
|
|
17
19
|
value,
|
|
18
20
|
(_key, v) => {
|
|
19
21
|
if (typeof v === 'function') {
|
|
20
|
-
const name = (v as
|
|
22
|
+
const name = (v as (...args: unknown[]) => unknown).name;
|
|
21
23
|
return `[Function${name ? `: ${name}` : ''}]`;
|
|
22
24
|
}
|
|
23
25
|
if (typeof v === 'bigint') return v.toString();
|
|
@@ -82,7 +84,6 @@ export function logRenderStore(options: LogRenderStoreOptions = {}): void {
|
|
|
82
84
|
|
|
83
85
|
if (isFn(groupCollapsed)) groupCollapsed(title);
|
|
84
86
|
else {
|
|
85
|
-
// eslint-disable-next-line no-console
|
|
86
87
|
console.log(title);
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -103,24 +104,21 @@ export function logRenderStore(options: LogRenderStoreOptions = {}): void {
|
|
|
103
104
|
|
|
104
105
|
// NOTE: Logging objects in devtools can be confusing because they are "live" references.
|
|
105
106
|
// This JSON string is a stable snapshot of this click, and is copy/paste-friendly.
|
|
106
|
-
|
|
107
|
+
|
|
107
108
|
console.log('json', json);
|
|
108
109
|
|
|
109
|
-
// eslint-disable-next-line no-console
|
|
110
110
|
console.log('state', snapshot);
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
console.log('actions', actions);
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
console.log('rawState (includes functions)', state);
|
|
115
115
|
|
|
116
116
|
if (includeLocalStorage) {
|
|
117
|
-
// eslint-disable-next-line no-console
|
|
118
117
|
console.log('localStorage.render-store (raw)', persistedRaw);
|
|
119
|
-
|
|
118
|
+
|
|
120
119
|
console.log('localStorage.render-store (parsed)', persistedParsed);
|
|
121
120
|
}
|
|
122
121
|
if (extra) {
|
|
123
|
-
// eslint-disable-next-line no-console
|
|
124
122
|
console.log('extra', extra);
|
|
125
123
|
}
|
|
126
124
|
|
package/src/utils/logger.ts
CHANGED
|
@@ -24,19 +24,15 @@ function consoleLog(
|
|
|
24
24
|
const prefix = `[${source}] ${message}`;
|
|
25
25
|
switch (level) {
|
|
26
26
|
case 'ERROR':
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
27
|
console.error(prefix, payload);
|
|
29
28
|
break;
|
|
30
29
|
case 'WARN':
|
|
31
|
-
// eslint-disable-next-line no-console
|
|
32
30
|
console.warn(prefix, payload);
|
|
33
31
|
break;
|
|
34
32
|
case 'INFO':
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
33
|
console.info(prefix, payload);
|
|
37
34
|
break;
|
|
38
35
|
case 'VERBOSE':
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
36
|
console.debug(prefix, payload);
|
|
41
37
|
break;
|
|
42
38
|
default:
|
|
@@ -47,7 +43,7 @@ function consoleLog(
|
|
|
47
43
|
export const logger = {
|
|
48
44
|
setLevel(level: LogLevel) {
|
|
49
45
|
useRenderStore.getState().setLogLevel(level);
|
|
50
|
-
|
|
46
|
+
|
|
51
47
|
console.info(`[Logger] level set to ${level}`);
|
|
52
48
|
},
|
|
53
49
|
log(level: LogLevel, source: LogSource, message: string, payload?: unknown) {
|
|
@@ -53,10 +53,7 @@ function generateUniqueKey(type: string, usedKeys: Set<string>): string {
|
|
|
53
53
|
*
|
|
54
54
|
* `usedKeys` is mutated by design (to track uniqueness across recursion).
|
|
55
55
|
*/
|
|
56
|
-
export function repairNodeKeys(
|
|
57
|
-
root: Node,
|
|
58
|
-
usedKeys: Set<string> = new Set(),
|
|
59
|
-
): Node {
|
|
56
|
+
export function repairNodeKeys(root: Node, usedKeys = new Set<string>()): Node {
|
|
60
57
|
if (root === null || root === undefined) return root;
|
|
61
58
|
if (typeof root === 'string') return root;
|
|
62
59
|
|