@idealyst/tooling 1.2.3

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.
@@ -0,0 +1,217 @@
1
+ import { PrimitiveRule, PrimitiveRuleSet } from '../types';
2
+
3
+ /**
4
+ * Module sources that indicate React DOM platform
5
+ */
6
+ export const REACT_DOM_SOURCES = [
7
+ 'react-dom',
8
+ 'react-dom/client',
9
+ 'react-dom/server',
10
+ ] as const;
11
+
12
+ /**
13
+ * React DOM API primitives
14
+ * These are functions/components that are React DOM specific
15
+ */
16
+ const DOM_API_PRIMITIVES: PrimitiveRule[] = [
17
+ {
18
+ name: 'createPortal',
19
+ source: 'react-dom',
20
+ platform: 'react-dom',
21
+ description: 'Render children into a different DOM node',
22
+ },
23
+ {
24
+ name: 'flushSync',
25
+ source: 'react-dom',
26
+ platform: 'react-dom',
27
+ description: 'Force synchronous DOM updates',
28
+ },
29
+ {
30
+ name: 'createRoot',
31
+ source: 'react-dom/client',
32
+ platform: 'react-dom',
33
+ description: 'Create a React root for rendering',
34
+ },
35
+ {
36
+ name: 'hydrateRoot',
37
+ source: 'react-dom/client',
38
+ platform: 'react-dom',
39
+ description: 'Hydrate server-rendered content',
40
+ },
41
+ {
42
+ name: 'render',
43
+ source: 'react-dom',
44
+ platform: 'react-dom',
45
+ description: 'Legacy render function (deprecated)',
46
+ },
47
+ {
48
+ name: 'hydrate',
49
+ source: 'react-dom',
50
+ platform: 'react-dom',
51
+ description: 'Legacy hydrate function (deprecated)',
52
+ },
53
+ {
54
+ name: 'unmountComponentAtNode',
55
+ source: 'react-dom',
56
+ platform: 'react-dom',
57
+ description: 'Legacy unmount function (deprecated)',
58
+ },
59
+ {
60
+ name: 'findDOMNode',
61
+ source: 'react-dom',
62
+ platform: 'react-dom',
63
+ description: 'Find DOM node (deprecated)',
64
+ },
65
+ ];
66
+
67
+ /**
68
+ * Intrinsic HTML elements that indicate web-only code
69
+ * These are JSX intrinsic elements that only exist in DOM
70
+ *
71
+ * Note: These are detected via JSX usage, not imports
72
+ * This list is for reference and specialized detection
73
+ */
74
+ export const HTML_INTRINSIC_ELEMENTS = [
75
+ // Document structure
76
+ 'html',
77
+ 'head',
78
+ 'body',
79
+ 'main',
80
+ 'header',
81
+ 'footer',
82
+ 'nav',
83
+ 'aside',
84
+ 'article',
85
+ 'section',
86
+
87
+ // Content sectioning
88
+ 'div',
89
+ 'span',
90
+ 'p',
91
+ 'h1',
92
+ 'h2',
93
+ 'h3',
94
+ 'h4',
95
+ 'h5',
96
+ 'h6',
97
+
98
+ // Text content
99
+ 'a',
100
+ 'strong',
101
+ 'em',
102
+ 'code',
103
+ 'pre',
104
+ 'blockquote',
105
+ 'br',
106
+ 'hr',
107
+
108
+ // Lists
109
+ 'ul',
110
+ 'ol',
111
+ 'li',
112
+ 'dl',
113
+ 'dt',
114
+ 'dd',
115
+
116
+ // Tables
117
+ 'table',
118
+ 'thead',
119
+ 'tbody',
120
+ 'tfoot',
121
+ 'tr',
122
+ 'th',
123
+ 'td',
124
+ 'caption',
125
+ 'colgroup',
126
+ 'col',
127
+
128
+ // Forms
129
+ 'form',
130
+ 'input',
131
+ 'textarea',
132
+ 'select',
133
+ 'option',
134
+ 'optgroup',
135
+ 'button',
136
+ 'label',
137
+ 'fieldset',
138
+ 'legend',
139
+ 'datalist',
140
+ 'output',
141
+ 'progress',
142
+ 'meter',
143
+
144
+ // Media
145
+ 'img',
146
+ 'video',
147
+ 'audio',
148
+ 'source',
149
+ 'track',
150
+ 'picture',
151
+ 'figure',
152
+ 'figcaption',
153
+ 'canvas',
154
+ 'svg',
155
+ 'iframe',
156
+ 'embed',
157
+ 'object',
158
+
159
+ // Interactive
160
+ 'details',
161
+ 'summary',
162
+ 'dialog',
163
+ 'menu',
164
+
165
+ // Scripting
166
+ 'script',
167
+ 'noscript',
168
+ 'template',
169
+ 'slot',
170
+ ] as const;
171
+
172
+ /**
173
+ * All React DOM primitives (API functions)
174
+ */
175
+ export const REACT_DOM_PRIMITIVES: PrimitiveRule[] = [...DOM_API_PRIMITIVES];
176
+
177
+ /**
178
+ * Set of primitive names for quick lookup
179
+ */
180
+ export const REACT_DOM_PRIMITIVE_NAMES = new Set(
181
+ REACT_DOM_PRIMITIVES.map((p) => p.name)
182
+ );
183
+
184
+ /**
185
+ * Set of HTML intrinsic element names for quick lookup
186
+ */
187
+ export const HTML_ELEMENT_NAMES: Set<string> = new Set(HTML_INTRINSIC_ELEMENTS);
188
+
189
+ /**
190
+ * Complete rule set for React DOM
191
+ */
192
+ export const REACT_DOM_RULE_SET: PrimitiveRuleSet = {
193
+ platform: 'react-dom',
194
+ primitives: REACT_DOM_PRIMITIVES,
195
+ sources: [...REACT_DOM_SOURCES],
196
+ };
197
+
198
+ /**
199
+ * Check if a name is a React DOM primitive (API function)
200
+ */
201
+ export function isReactDomPrimitive(name: string): boolean {
202
+ return REACT_DOM_PRIMITIVE_NAMES.has(name);
203
+ }
204
+
205
+ /**
206
+ * Check if a name is an HTML intrinsic element
207
+ */
208
+ export function isHtmlElement(name: string): boolean {
209
+ return HTML_ELEMENT_NAMES.has(name);
210
+ }
211
+
212
+ /**
213
+ * Get primitive info by name
214
+ */
215
+ export function getReactDomPrimitive(name: string): PrimitiveRule | undefined {
216
+ return REACT_DOM_PRIMITIVES.find((p) => p.name === name);
217
+ }
@@ -0,0 +1,363 @@
1
+ import { PrimitiveRule, PrimitiveRuleSet } from '../types';
2
+
3
+ /**
4
+ * Module sources that indicate React Native platform
5
+ */
6
+ export const REACT_NATIVE_SOURCES = [
7
+ 'react-native',
8
+ 'react-native-web',
9
+ 'react-native-gesture-handler',
10
+ 'react-native-reanimated',
11
+ 'react-native-safe-area-context',
12
+ 'react-native-screens',
13
+ 'react-native-svg',
14
+ 'react-native-vector-icons',
15
+ 'react-native-vector-icons/MaterialCommunityIcons',
16
+ '@react-native-community/async-storage',
17
+ '@react-native-picker/picker',
18
+ '@react-native-vector-icons/common',
19
+ 'expo',
20
+ 'expo-constants',
21
+ 'expo-linking',
22
+ 'expo-status-bar',
23
+ ] as const;
24
+
25
+ /**
26
+ * Core React Native view primitives
27
+ */
28
+ const CORE_PRIMITIVES: PrimitiveRule[] = [
29
+ {
30
+ name: 'View',
31
+ source: 'react-native',
32
+ platform: 'react-native',
33
+ description: 'Basic container component',
34
+ },
35
+ {
36
+ name: 'Text',
37
+ source: 'react-native',
38
+ platform: 'react-native',
39
+ description: 'Text display component',
40
+ },
41
+ {
42
+ name: 'Image',
43
+ source: 'react-native',
44
+ platform: 'react-native',
45
+ description: 'Image display component',
46
+ },
47
+ {
48
+ name: 'ImageBackground',
49
+ source: 'react-native',
50
+ platform: 'react-native',
51
+ description: 'Background image container',
52
+ },
53
+ {
54
+ name: 'ScrollView',
55
+ source: 'react-native',
56
+ platform: 'react-native',
57
+ description: 'Scrollable container',
58
+ },
59
+ {
60
+ name: 'FlatList',
61
+ source: 'react-native',
62
+ platform: 'react-native',
63
+ description: 'Performant list component',
64
+ },
65
+ {
66
+ name: 'SectionList',
67
+ source: 'react-native',
68
+ platform: 'react-native',
69
+ description: 'Sectioned list component',
70
+ },
71
+ {
72
+ name: 'VirtualizedList',
73
+ source: 'react-native',
74
+ platform: 'react-native',
75
+ description: 'Base virtualized list',
76
+ },
77
+ ];
78
+
79
+ /**
80
+ * Interactive/touchable primitives
81
+ */
82
+ const INTERACTIVE_PRIMITIVES: PrimitiveRule[] = [
83
+ {
84
+ name: 'TouchableOpacity',
85
+ source: 'react-native',
86
+ platform: 'react-native',
87
+ description: 'Touch with opacity feedback',
88
+ },
89
+ {
90
+ name: 'TouchableHighlight',
91
+ source: 'react-native',
92
+ platform: 'react-native',
93
+ description: 'Touch with highlight feedback',
94
+ },
95
+ {
96
+ name: 'TouchableWithoutFeedback',
97
+ source: 'react-native',
98
+ platform: 'react-native',
99
+ description: 'Touch without visual feedback',
100
+ },
101
+ {
102
+ name: 'TouchableNativeFeedback',
103
+ source: 'react-native',
104
+ platform: 'react-native',
105
+ description: 'Android ripple feedback',
106
+ },
107
+ {
108
+ name: 'Pressable',
109
+ source: 'react-native',
110
+ platform: 'react-native',
111
+ description: 'Modern press handler component',
112
+ },
113
+ {
114
+ name: 'Button',
115
+ source: 'react-native',
116
+ platform: 'react-native',
117
+ description: 'Basic button component',
118
+ },
119
+ ];
120
+
121
+ /**
122
+ * Input primitives
123
+ */
124
+ const INPUT_PRIMITIVES: PrimitiveRule[] = [
125
+ {
126
+ name: 'TextInput',
127
+ source: 'react-native',
128
+ platform: 'react-native',
129
+ description: 'Text input field',
130
+ },
131
+ {
132
+ name: 'Switch',
133
+ source: 'react-native',
134
+ platform: 'react-native',
135
+ description: 'Toggle switch component',
136
+ },
137
+ {
138
+ name: 'Slider',
139
+ source: 'react-native',
140
+ platform: 'react-native',
141
+ description: 'Slider input (deprecated)',
142
+ },
143
+ ];
144
+
145
+ /**
146
+ * Modal and overlay primitives
147
+ */
148
+ const MODAL_PRIMITIVES: PrimitiveRule[] = [
149
+ {
150
+ name: 'Modal',
151
+ source: 'react-native',
152
+ platform: 'react-native',
153
+ description: 'Modal overlay component',
154
+ },
155
+ {
156
+ name: 'Alert',
157
+ source: 'react-native',
158
+ platform: 'react-native',
159
+ description: 'Native alert dialog',
160
+ },
161
+ {
162
+ name: 'ActionSheetIOS',
163
+ source: 'react-native',
164
+ platform: 'react-native',
165
+ description: 'iOS action sheet',
166
+ },
167
+ {
168
+ name: 'StatusBar',
169
+ source: 'react-native',
170
+ platform: 'react-native',
171
+ description: 'Status bar controller',
172
+ },
173
+ ];
174
+
175
+ /**
176
+ * Animation primitives
177
+ */
178
+ const ANIMATION_PRIMITIVES: PrimitiveRule[] = [
179
+ {
180
+ name: 'Animated',
181
+ source: 'react-native',
182
+ platform: 'react-native',
183
+ description: 'Animation library namespace',
184
+ },
185
+ {
186
+ name: 'Easing',
187
+ source: 'react-native',
188
+ platform: 'react-native',
189
+ description: 'Easing functions',
190
+ },
191
+ {
192
+ name: 'LayoutAnimation',
193
+ source: 'react-native',
194
+ platform: 'react-native',
195
+ description: 'Layout animation controller',
196
+ },
197
+ ];
198
+
199
+ /**
200
+ * Platform and device primitives
201
+ */
202
+ const PLATFORM_PRIMITIVES: PrimitiveRule[] = [
203
+ {
204
+ name: 'Platform',
205
+ source: 'react-native',
206
+ platform: 'react-native',
207
+ description: 'Platform detection utility',
208
+ },
209
+ {
210
+ name: 'Dimensions',
211
+ source: 'react-native',
212
+ platform: 'react-native',
213
+ description: 'Screen dimensions utility',
214
+ },
215
+ {
216
+ name: 'PixelRatio',
217
+ source: 'react-native',
218
+ platform: 'react-native',
219
+ description: 'Pixel ratio utility',
220
+ },
221
+ {
222
+ name: 'Appearance',
223
+ source: 'react-native',
224
+ platform: 'react-native',
225
+ description: 'Color scheme detection',
226
+ },
227
+ {
228
+ name: 'useColorScheme',
229
+ source: 'react-native',
230
+ platform: 'react-native',
231
+ description: 'Color scheme hook',
232
+ },
233
+ {
234
+ name: 'useWindowDimensions',
235
+ source: 'react-native',
236
+ platform: 'react-native',
237
+ description: 'Window dimensions hook',
238
+ },
239
+ ];
240
+
241
+ /**
242
+ * Event handling primitives
243
+ */
244
+ const EVENT_PRIMITIVES: PrimitiveRule[] = [
245
+ {
246
+ name: 'BackHandler',
247
+ source: 'react-native',
248
+ platform: 'react-native',
249
+ description: 'Android back button handler',
250
+ },
251
+ {
252
+ name: 'Keyboard',
253
+ source: 'react-native',
254
+ platform: 'react-native',
255
+ description: 'Keyboard event handler',
256
+ },
257
+ {
258
+ name: 'PanResponder',
259
+ source: 'react-native',
260
+ platform: 'react-native',
261
+ description: 'Gesture responder system',
262
+ },
263
+ {
264
+ name: 'Linking',
265
+ source: 'react-native',
266
+ platform: 'react-native',
267
+ description: 'Deep linking utility',
268
+ },
269
+ {
270
+ name: 'AppState',
271
+ source: 'react-native',
272
+ platform: 'react-native',
273
+ description: 'App lifecycle state',
274
+ },
275
+ ];
276
+
277
+ /**
278
+ * Safety primitives
279
+ */
280
+ const SAFETY_PRIMITIVES: PrimitiveRule[] = [
281
+ {
282
+ name: 'SafeAreaView',
283
+ source: 'react-native',
284
+ platform: 'react-native',
285
+ description: 'Safe area inset container',
286
+ },
287
+ {
288
+ name: 'KeyboardAvoidingView',
289
+ source: 'react-native',
290
+ platform: 'react-native',
291
+ description: 'Keyboard avoidance container',
292
+ },
293
+ ];
294
+
295
+ /**
296
+ * Accessibility primitives
297
+ */
298
+ const ACCESSIBILITY_PRIMITIVES: PrimitiveRule[] = [
299
+ {
300
+ name: 'AccessibilityInfo',
301
+ source: 'react-native',
302
+ platform: 'react-native',
303
+ description: 'Accessibility information API',
304
+ },
305
+ ];
306
+
307
+ /**
308
+ * Style primitives
309
+ */
310
+ const STYLE_PRIMITIVES: PrimitiveRule[] = [
311
+ {
312
+ name: 'StyleSheet',
313
+ source: 'react-native',
314
+ platform: 'react-native',
315
+ description: 'Style sheet creator',
316
+ },
317
+ ];
318
+
319
+ /**
320
+ * All React Native primitives combined
321
+ */
322
+ export const REACT_NATIVE_PRIMITIVES: PrimitiveRule[] = [
323
+ ...CORE_PRIMITIVES,
324
+ ...INTERACTIVE_PRIMITIVES,
325
+ ...INPUT_PRIMITIVES,
326
+ ...MODAL_PRIMITIVES,
327
+ ...ANIMATION_PRIMITIVES,
328
+ ...PLATFORM_PRIMITIVES,
329
+ ...EVENT_PRIMITIVES,
330
+ ...SAFETY_PRIMITIVES,
331
+ ...ACCESSIBILITY_PRIMITIVES,
332
+ ...STYLE_PRIMITIVES,
333
+ ];
334
+
335
+ /**
336
+ * Set of primitive names for quick lookup
337
+ */
338
+ export const REACT_NATIVE_PRIMITIVE_NAMES = new Set(
339
+ REACT_NATIVE_PRIMITIVES.map((p) => p.name)
340
+ );
341
+
342
+ /**
343
+ * Complete rule set for React Native
344
+ */
345
+ export const REACT_NATIVE_RULE_SET: PrimitiveRuleSet = {
346
+ platform: 'react-native',
347
+ primitives: REACT_NATIVE_PRIMITIVES,
348
+ sources: [...REACT_NATIVE_SOURCES],
349
+ };
350
+
351
+ /**
352
+ * Check if a name is a React Native primitive
353
+ */
354
+ export function isReactNativePrimitive(name: string): boolean {
355
+ return REACT_NATIVE_PRIMITIVE_NAMES.has(name);
356
+ }
357
+
358
+ /**
359
+ * Get primitive info by name
360
+ */
361
+ export function getReactNativePrimitive(name: string): PrimitiveRule | undefined {
362
+ return REACT_NATIVE_PRIMITIVES.find((p) => p.name === name);
363
+ }