@fgv/ts-res-browser 5.0.0-2 → 5.0.0-21

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.
Files changed (99) hide show
  1. package/cli.js +132 -21
  2. package/dist/bundle.js +1 -1
  3. package/dist/bundle.js.LICENSE.txt +11 -1
  4. package/package.json +42 -36
  5. package/.rush/temp/587277bfc395406ad444e989b6c309b9698f534c.tar.log +0 -15
  6. package/.rush/temp/chunked-rush-logs/ts-res-browser.build.chunks.jsonl +0 -35
  7. package/.rush/temp/operation/build/all.log +0 -35
  8. package/.rush/temp/operation/build/log-chunks.jsonl +0 -35
  9. package/.rush/temp/operation/build/state.json +0 -3
  10. package/.rush/temp/shrinkwrap-deps.json +0 -1225
  11. package/TS_RES_BROWSER_PLAN.md +0 -689
  12. package/babel.config.js +0 -17
  13. package/config/jest.config.json +0 -13
  14. package/config/rig.json +0 -16
  15. package/postcss.config.js +0 -3
  16. package/public/index.html +0 -15
  17. package/rush-logs/ts-res-browser.build.cache.log +0 -3
  18. package/rush-logs/ts-res-browser.build.log +0 -35
  19. package/src/App.tsx +0 -274
  20. package/src/cli.ts +0 -44
  21. package/src/components/common/FileImporter.tsx +0 -143
  22. package/src/components/common/NavigationWarningModal.tsx +0 -62
  23. package/src/components/layout/AppLayout.tsx +0 -46
  24. package/src/components/layout/Header.tsx +0 -22
  25. package/src/components/layout/MessagesWindow.tsx +0 -108
  26. package/src/components/layout/Sidebar.tsx +0 -99
  27. package/src/components/tools/CompiledBrowser.tsx +0 -949
  28. package/src/components/tools/ConfigurationTool.tsx +0 -1405
  29. package/src/components/tools/FilterTool.tsx +0 -1114
  30. package/src/components/tools/ImportTool.tsx +0 -249
  31. package/src/components/tools/ResolutionViewer.tsx +0 -1672
  32. package/src/components/tools/SourceBrowser.tsx +0 -496
  33. package/src/components/tools/ZipLoader.tsx +0 -302
  34. package/src/hooks/useAppState.ts +0 -111
  35. package/src/hooks/useFileImport.ts +0 -86
  36. package/src/hooks/useNavigationWarning.ts +0 -67
  37. package/src/hooks/useResourceManager.ts +0 -295
  38. package/src/hooks/useUrlParams.ts +0 -56
  39. package/src/index.css +0 -38
  40. package/src/main.tsx +0 -16
  41. package/src/types/app.ts +0 -70
  42. package/src/types/fileSystemAccess.d.ts +0 -94
  43. package/src/utils/browserFileTreeAccessors.ts +0 -245
  44. package/src/utils/fileImport.ts +0 -336
  45. package/src/utils/fileTreeConverter.ts +0 -160
  46. package/src/utils/filterResources.ts +0 -677
  47. package/src/utils/tsResIntegration.ts +0 -467
  48. package/src/utils/urlParams.ts +0 -238
  49. package/src/utils/zip/browserZipFileTreeAccessors.ts +0 -385
  50. package/tailwind.config.js +0 -21
  51. package/test-data/README.md +0 -184
  52. package/test-data/config-variations/README.md +0 -64
  53. package/test-data/config-variations/composition-terminology.json +0 -112
  54. package/test-data/config-variations/enterprise-complex.json +0 -129
  55. package/test-data/config-variations/gaming-app.json +0 -87
  56. package/test-data/config-variations/high-priority-language.json +0 -65
  57. package/test-data/config-variations/minimal-basic.json +0 -37
  58. package/test-data/config-variations/qualifier-default-values.json +0 -71
  59. package/test-data/config-variations/territory-first.json +0 -68
  60. package/test-data/config-variations/territory-hierarchy-test.json +0 -31
  61. package/test-data/config-variations/territory-hierarchy-unconstrained.json +0 -32
  62. package/test-data/default-matching-test/greeting.res.json +0 -83
  63. package/test-data/default-matching-test/only-defaults.res.json +0 -48
  64. package/test-data/sample-project/package.json +0 -27
  65. package/test-data/sample-project/src/resources/app-config.json +0 -27
  66. package/test-data/sample-project/src/resources/app.json +0 -177
  67. package/test-data/sample-project/src/resources/config/app.env=development.json +0 -21
  68. package/test-data/sample-project/src/resources/config/app.json +0 -21
  69. package/test-data/sample-project/src/resources/config/app.platform=mobile.json +0 -23
  70. package/test-data/sample-project/src/resources/feature-flags.json +0 -23
  71. package/test-data/sample-project/src/resources/home=CA/common.json +0 -16
  72. package/test-data/sample-project/src/resources/images/density=hdpi.json +0 -29
  73. package/test-data/sample-project/src/resources/images/home.json +0 -29
  74. package/test-data/sample-project/src/resources/images/logout.json +0 -14
  75. package/test-data/sample-project/src/resources/images/settings.json +0 -14
  76. package/test-data/sample-project/src/resources/images/ui-icons.json +0 -29
  77. package/test-data/sample-project/src/resources/images/user.density=hdpi.json +0 -14
  78. package/test-data/sample-project/src/resources/images/user.json +0 -14
  79. package/test-data/sample-project/src/resources/lang=en-US/common.json +0 -15
  80. package/test-data/sample-project/src/resources/language=en-CA/ui-terms.json +0 -19
  81. package/test-data/sample-project/src/resources/language=en-GB/ui-terms.json +0 -30
  82. package/test-data/sample-project/src/resources/language=fr-CA/ui-terms.json +0 -25
  83. package/test-data/sample-project/src/resources/language=nl-BE/ui-terms.json +0 -17
  84. package/test-data/sample-project/src/resources/region=europe/feature-flags.json +0 -17
  85. package/test-data/sample-project/src/resources/region=north-america/feature-flags.json +0 -18
  86. package/test-data/sample-project/src/resources/strings/dashboard.home=CA,language=fr.json +0 -20
  87. package/test-data/sample-project/src/resources/strings/dashboard.json +0 -18
  88. package/test-data/sample-project/src/resources/strings/dashboard.role=admin.json +0 -23
  89. package/test-data/sample-project/src/resources/strings/dashboard.role=user.json +0 -21
  90. package/test-data/sample-project/src/resources/strings/language=en-US.json +0 -16
  91. package/test-data/sample-project/src/resources/strings.json +0 -78
  92. package/test-data/sample-project/src/resources/territory=BE/app-config.json +0 -19
  93. package/test-data/sample-project/src/resources/territory=CA/app-config.json +0 -21
  94. package/test-data/sample-project/src/resources/territory=GB/app-config.json +0 -25
  95. package/test-data/sample-project/src/resources/territory=NL/app-config.json +0 -25
  96. package/test-data/sample-project/src/resources/ui-terms.json +0 -96
  97. package/test-data/sample-project/src/resources-config.json +0 -111
  98. package/tsconfig.json +0 -27
  99. package/webpack.config.js +0 -60
@@ -1,689 +0,0 @@
1
- # TS-RES Browser Tool - Comprehensive Project Plan
2
-
3
- ## Overview
4
- A visual tool for loading, browsing, and experimenting with ts-res resources. Built as a React web application for optimal performance and modern browser capabilities.
5
-
6
- ## Architecture Decision: React Web App vs Electron
7
-
8
- **Decision: React Web App**
9
-
10
- Based on 2024 best practices research:
11
- - **Performance**: Web apps are significantly faster than Electron apps
12
- - **Security**: Fewer attack vectors than Electron's native access
13
- - **Development**: Simpler tooling and deployment
14
- - **User Experience**: Modern browsers provide excellent file system access
15
- - **Maintenance**: No native OS compatibility issues
16
-
17
- **Technology Stack**:
18
- - **Framework**: React 18+ with TypeScript
19
- - **Build Tool**: Webpack
20
- - **File Access**: File System Access API with fallback to file input
21
- - **Styling**: Tailwind CSS for utility-first styling
22
- - **Icons**: Heroicons for consistent iconography
23
- - **State Management**: React Context + useReducer for complex state
24
-
25
- ## Rush Monorepo Requirements
26
-
27
- **Package Management**:
28
- - **Never** use `npm install` or edit `package.json` directly
29
- - Use `rush add -p <package>` for runtime dependencies (note: `-p` flag required)
30
- - Use `rush add --dev -p <package>` for dev dependencies
31
- - Use `rush add --peer -p <package>` for peer dependencies
32
- - Can install multiple packages at once: `rush add -p package1 package2 package3`
33
- - Rush automatically uses consistent versions across monorepo or 'latest' for new packages
34
- - **Work in a branch and ask for help when dealing with dependency conflicts**
35
-
36
- **Git Workflow**:
37
- - **NEVER commit changes without user review** - staging files is fine
38
- - Always confirm commit message and timing with user before executing `git commit`
39
- - Work in feature branches and get approval before merging
40
-
41
- **Runtime Requirements**:
42
- - **Node Version**: v20 (monorepo standard)
43
- - **Monorepo Consistency**: Follow existing patterns and style
44
-
45
- **Required Dependencies**:
46
- - `@fgv/ts-utils`: Result pattern, collections, validation, conversion
47
- - `@fgv/ts-json-base`: Basic JSON handling
48
- - `@fgv/ts-json`: Intensive JSON work (templating, merging, transformation)
49
- - `@fgv/ts-utils-jest`: Testing with result-specific jest matchers
50
- - `@fgv/ts-bcp47`: Structured language tags (if needed)
51
- - `@fgv/ts-res`: Core resource management (runtime dependency)
52
-
53
- **Development Patterns**:
54
- - **Result Pattern**: Use `Result<T>` for all operations that can fail
55
- - **Error Handling**: Prefer `.onSuccess()`, `.onFailure()`, `.orThrow()` patterns
56
- - **Validation**: Use converters and validators from ts-utils
57
- - **Testing**: Use result-specific matchers like `.toSucceedWith()`, `.toFailWith()`
58
-
59
- ## Project Structure
60
-
61
- ```
62
- tools/ts-res-browser/
63
- ├── src/
64
- │ ├── components/
65
- │ │ ├── layout/
66
- │ │ │ ├── AppLayout.tsx
67
- │ │ │ ├── Sidebar.tsx
68
- │ │ │ ├── Header.tsx
69
- │ │ │ └── MessagesWindow.tsx
70
- │ │ ├── tools/
71
- │ │ │ ├── SourceBrowser.tsx
72
- │ │ │ ├── CompiledBrowser.tsx
73
- │ │ │ ├── ResolutionViewer.tsx
74
- │ │ │ ├── FilterTool.tsx
75
- │ │ │ └── ConfigurationTool.tsx
76
- │ │ └── common/
77
- │ │ ├── FileImporter.tsx
78
- │ │ ├── ResourceTree.tsx
79
- │ │ ├── ResourceViewer.tsx
80
- │ │ └── QualifierInput.tsx
81
- │ ├── hooks/
82
- │ │ ├── useResourceManager.ts
83
- │ │ ├── useFileImport.ts
84
- │ │ └── useResourceResolver.ts
85
- │ ├── types/
86
- │ │ └── app.ts
87
- │ ├── utils/
88
- │ │ ├── import.ts
89
- │ │ ├── formatting.ts
90
- │ │ └── filterResources.ts
91
- │ ├── App.tsx
92
- │ └── main.tsx
93
- ├── public/
94
- ├── package.json
95
- ├── webpack.config.js
96
- ├── tsconfig.json
97
- └── README.md
98
- ```
99
-
100
- ## Implementation Phases
101
-
102
- ### Phase 1: Project Setup & Core Infrastructure ✅ COMPLETED
103
- - [x] Research architecture decision
104
- - [x] Create new branch: `ts-res-browser` off `alpha`
105
- - [x] Initialize project structure with Rush integration
106
- - [x] Configure Webpack + React + TypeScript
107
- - [x] Add dependencies using `rush add`
108
- - [x] Set up Tailwind CSS and Heroicons
109
- - [x] Create comprehensive test data for manual verification
110
- - [x] Set up build tooling for npx execution
111
-
112
- ### Phase 2: File Import & Resource Loading ✅ COMPLETED
113
- - [x] Implement file/folder selection using File System Access API
114
- - [x] Integrate ts-res ImportManager for resource loading
115
- - [x] Build resources with ResourceManagerBuilder
116
- - [x] Generate compiled resources with getCompiledResourceCollection
117
- - [x] Initialize ResourceResolver with compiled collection
118
-
119
- ### Phase 3: Core Application Layout ✅ COMPLETED
120
- - [x] Create main app layout with sidebar and content areas
121
- - [x] Fix icon sizing and improve visual hierarchy
122
- - [x] Resolve Tailwind CSS v4 configuration issues
123
- - [x] Implement tool navigation and state management
124
- - [x] Add messages window for status and error display
125
-
126
- ### Phase 4: Core Tools Implementation ✅ COMPLETED
127
-
128
- *All four core tools are now fully implemented with comprehensive functionality*
129
-
130
- #### Source Browser Tool ✅ COMPLETED
131
- - [x] Display built resources as alphabetically sorted list
132
- - [x] Implement resource selector pane
133
- - [x] Create resource viewer pane with detailed information
134
- - [x] Show fully qualified resource IDs
135
-
136
- #### Compiled Resource Browser Tool ✅ COMPLETED
137
- - [x] Create tree view with 4 main sections: Resources, Decisions, Condition Sets, Conditions
138
- - [x] Display compiled resources with proper type safety and structure
139
- - [x] Implement flat array displays for Decisions, Condition Sets, and Conditions
140
- - [x] Create left browser panel for tree navigation and right details panel
141
- - [x] Display comprehensive details when items are selected
142
- - [x] Show counts in section headers and full details on selection
143
- - [x] Integrate with existing message system for status updates
144
- - [x] Fix React object rendering issues for robust candidate display
145
-
146
- #### Filter Tool ✅ COMPLETED
147
- *The Filter Tool provides context-based filtering of resources, enabling focused analysis and testing*
148
-
149
- - [x] **Qualifier Selection Panel**: Horizontal layout similar to Resolution Viewer
150
- - [x] **Resource Browser & Details**: Shows filtered or original resources based on context
151
- - [x] **Filter Controls**: Enable/disable toggle with master control
152
- - [x] **Candidate-Level Filtering**: Filter individual candidates within resources, not just entire resources
153
- - [x] **Visual Indicators**: Clear distinction between matching and filtered-out candidates
154
- - [x] **Real-time Updates**: Changes to filter context immediately update downstream views
155
- - [x] **Validation & Feedback**: Warnings for resources with zero candidates after filtering
156
- - [x] **Debug Logging**: Comprehensive logging system with toggle control for troubleshooting
157
- - [x]] **Integration**: Seamless integration with Compiled and Resolution views
158
-
159
- **Filter Tool Technical Achievements**:
160
- - **Major Breakthrough**: Implemented candidate-level filtering (not just resource-level)
161
- - **Enhanced Algorithm**: Creates new resource declarations with only matching candidates
162
- - **Type Safety**: Resolved all TypeScript import and compilation issues
163
- - **Testing**: Validated with real test data (feature-flags + region filtering)
164
- - **Performance**: Efficient filtering logic suitable for large resource collections
165
-
166
- #### Resource Resolution Viewer Tool ✅ COMPLETED
167
- - [x] Create context panel for qualifier input with table format (one entry per qualifier)
168
- - [x] Implement qualifier validation and dynamic context loading
169
- - [x] Add resource browser for selection with search capability
170
- - [x] Create candidate display with view selector (best/all/raw modes)
171
- - [x] Support "best candidate" and "all candidates" views with condition set keys
172
- - [x] Separate matching and non-matching candidates with subtle visual distinction
173
- - [x] Add comprehensive default context values (homeTerritory=US, currentTerritory=US, language=en-US, platform=web, environment=production, role=user, density=standard)
174
- - [x] Implement metadata-first approach with graceful fallbacks for condition set keys
175
- - [x] Add visual badges for condition set keys with color coding
176
- - [x] **Enhanced Resolution Details**: Added condition evaluation display showing detailed matching logic
177
- - [x] **Cache Contents Display**: Interactive cache inspection with expandable sections
178
- - [x] **Compact Cache Dashboard**: Real-time cache metrics with hit rates and performance indicators
179
- - [x] **Cache Management**: Reset functionality and live activity indicators
180
-
181
- #### Configuration Tool ✅ COMPLETED
182
- *This tool enables users to define and manage the fundamental building blocks of the ts-res system*
183
-
184
- - [x] Create three-panel vertical layout for system configuration
185
- - [x] **Qualifier Types Panel**: Display and edit qualifier type configurations
186
- - [x] Support editing configuration of existing built-in types (language, territory, literal)
187
- - [x] Allow adding new qualifier types by configuring one of the three base types
188
- - [x] Support configuration options like `allowContextList` for territory types
189
- - [x] **Qualifiers Panel**: Display and edit qualifier configurations
190
- - [x] Support adding new qualifiers freely with validation
191
- - [x] Allow editing or removing existing qualifier configurations
192
- - [x] Link qualifiers to their corresponding qualifier types
193
- - [x] **Resource Types Panel**: Display resource types (read-only for now)
194
- - [x] Show built-in resource types (json, text, etc.)
195
- - [x] Display resource type properties and configurations
196
- - [x] **Integration**: Ensure Resolution Viewer context panel reflects actual configuration
197
- - [x] Dynamic context loading based on configured qualifiers
198
- - [x] Update default values based on qualifier configurations
199
- - [x] Create several test variations of system configuration
200
- - [x] Load system configuration from external files with validation
201
- - [x] Real-time updates when configuration changes
202
-
203
- #### Configuration Test Files ✅ COMPLETED
204
- *Located in `test-data/config-variations/` for testing different system setups*
205
-
206
- - [x] **high-priority-language.json**: Internationalization-focused setup with language priority 900
207
- - [x] **territory-first.json**: Region-specific configuration with territory priority 950/900
208
- - [x] **gaming-app.json**: Gaming application setup with platform/graphics/player-level qualifiers
209
- - [x] **minimal-basic.json**: Simple setup with only language and device qualifiers
210
- - [x] **enterprise-complex.json**: Complex enterprise setup with 9 qualifiers including tenant/security
211
- - [x] **README.md**: Documentation explaining each configuration's use case and testing scenarios
212
-
213
- ## Phase 5: Enhanced Resolution View & Performance Analysis ✅ COMPLETED
214
-
215
- ### 5.1 Inline Cache Metrics Display ✅ COMPLETED
216
- - **Compact Dashboard**: Horizontal strip between qualifier and resource panes
217
- - Format: `Cond: 2/10 (100%) | CondSet: 1/5 (100%) | Dec: 1/3 (100%) [Reset]`
218
- - Color coding: Green (>80%), Yellow (50-80%), Red (<50%), Gray (no activity)
219
- - Custom tooltip component with detailed cache information
220
- - **Cache Metrics**: Use existing `ResourceResolverCacheMetricsListener` with `AggregateCacheMetrics`
221
- - **State Management**: Persist across resource selections, reset on context changes
222
- - **Updates**: After each resolution operation
223
- - **Cache Reset Button**: Single button to clear all caches and reset metrics
224
- - **Tooltip Details**: Shows filled slots, total accesses, hits/misses/errors breakdown
225
-
226
- ### 5.2 Candidate Resolution Details ✅ COMPLETED
227
- - **Condition Results**: Show individual condition evaluation results in candidate view
228
- - Format: `lang=en-GB(0.9), home=US(1.0)` etc. for each candidate
229
- - **Condition Set Results**: Display condition set evaluation outcomes
230
- - **Decision Results**: Show decision resolution details
231
- - **Implementation**: Added ConditionEvaluationDisplay component with tooltips showing detailed condition matching logic
232
- - **Views**: Integrated condition evaluation display into 'all' view (matching and non-matching candidates) and 'best' view
233
-
234
- ### 5.3 Resource Structure View ✅ COMPLETED
235
- - **Cache Contents Display**: Added expandable cache contents section in left pane showing:
236
- - **Condition Cache**: Shows cached condition scores with qualifier names and values
237
- - **Condition Set Cache**: Shows cached condition set results with success/failure status
238
- - **Decision Cache**: Shows cached decision results with matching candidate counts
239
- - **Interactive Design**: Expandable/collapsible with hover tooltips for detailed information
240
- - **Real-time Updates**: Updates as resources are resolved and cache is populated
241
- - **Parallel Structure Display**: Extend resource view to show condition/condition set/decision results
242
- - **Similar to Compiled View**: Mirror the internal structure display from compiled browser
243
- - **Hierarchical Display**: Show the resolution hierarchy (conditions → condition sets → decisions)
244
-
245
- ## Phase 6: Advanced Features & Future Enhancements
246
-
247
- ### 6.1 Cache Enhancements (Future)
248
- - **Base Library Enhancements**:
249
- - Enhanced cache listener events with timing information
250
- - Cache introspection methods for content inspection
251
- - Per-resource metrics tracking
252
- - **Cache State Visualization**:
253
- - Cache size information and utilization
254
- - Live activity indicators
255
- - Fine-grained cache management
256
-
257
- ### 6.2 Resolution Path Analysis (Future)
258
- - **Step-by-step Resolution**: Show exact sequence of cache operations during resolution
259
- - **Dependency Tree**: Visual representation of accessed conditions/condition sets/decisions
260
- - **Cache Impact Highlighting**: Show which resolution parts benefited from caching
261
-
262
- ### 6.3 Context Change Impact Analysis (Future)
263
- - **Cache Invalidation Preview**: Show cache entries affected by context changes
264
- - **Before/After Comparison**: Visual diff of cache state
265
- - **Resolution Diff Analysis**: Compare resolution results between different contexts
266
-
267
- ### 6.4 Performance Analysis (Future)
268
- - **Resolution Performance Metrics**: Resolution timing and cache contribution
269
- - **Historical Analysis**: Track performance over time
270
- - **Context Optimization**: Suggest context configurations for improved cache efficiency
271
-
272
- ### 6.5 Polish & Optimization (Future)
273
- - [ ] Implement responsive design for mobile and desktop
274
- - [ ] Add comprehensive error handling
275
- - [ ] Implement performance optimizations for large datasets
276
- - [ ] Add loading states and progress indicators
277
- - [ ] Create comprehensive documentation
278
-
279
- ### 6.6 Extended Configuration Support (Future)
280
- - [ ] Support for custom resource type definitions
281
- - [ ] Advanced qualifier type configuration options
282
- - [ ] Import/export of system configurations
283
- - [ ] Configuration validation and error handling
284
-
285
- ## Technical Specifications
286
-
287
- ### Configuration Tool Architecture
288
-
289
- The Configuration Tool provides a comprehensive interface for managing the ts-res system configuration:
290
-
291
- **Qualifier Types Configuration**:
292
- - **Built-in Base Types**: Three fundamental types that cannot be created/deleted:
293
- - `LanguageQualifierType`: Handles language-related qualifiers (e.g., "en-US", "fr-CA")
294
- - `TerritoryQualifierType`: Handles territory/region qualifiers (e.g., "US", "CA", "GB")
295
- - `LiteralQualifierType`: Complex type for literal string matching with various options
296
- - **Configuration Options**: Each type has configurable properties:
297
- - `allowContextList`: Controls if qualifier can accept list contexts (e.g., 0=false, 1=true, 2=multiple)
298
- - `defaultPriority`: Sets default priority for conditions using this type
299
- - Type-specific options (e.g., validation patterns for literals)
300
- - **New Types**: Can be created by configuring one of the three base types with different settings
301
-
302
- **Qualifiers Configuration**:
303
- - **Full CRUD Operations**: Create, read, update, delete qualifiers freely
304
- - **Type Association**: Each qualifier must be linked to a qualifier type
305
- - **Properties**: Configure name, type, default priority, validation rules
306
- - **Usage Tracking**: Show where qualifiers are used in resources
307
-
308
- **Resource Types Display**:
309
- - **Read-Only**: Built-in resource types cannot be edited (future enhancement)
310
- - **Properties**: Show name, validation rules, supported operations
311
- - **Usage Statistics**: Display how many resources use each type
312
-
313
- **Integration Requirements**:
314
- - **Dynamic Context Loading**: Resolution Viewer must reflect actual configured qualifiers
315
- - **Validation**: Ensure configuration changes don't break existing resources
316
- - **Real-time Updates**: Changes should be immediately reflected in other tools
317
-
318
- ### Filter Tool Architecture & Implementation
319
-
320
- **Overview**: The Filter Tool provides context-based filtering of resources, sitting between the Source Browser and Compiled Browser in the workflow. It enables users to create filtered subsets of resources based on partial context matching, allowing for focused analysis and testing of specific resource scenarios.
321
-
322
- **Position in Workflow**: `Source → Filter → Compiled → Resolution`
323
-
324
- **Core Features**:
325
-
326
- 1. **Qualifier Selection Panel** (Top Section)
327
- - Horizontal layout similar to Resolution Viewer's context panel
328
- - All qualifier inputs initialize to `undefined` (empty state)
329
- - Same responsive grid layout: 1 column (mobile) → 2 columns (medium) → 3 columns (large)
330
- - Clear visual indication when qualifiers have values vs empty state
331
-
332
- 2. **Resource Browser & Details** (Bottom Section)
333
- - Identical layout to Source Browser: left browser panel + right details panel
334
- - Shows either original resources (when filtering disabled) or filtered resources
335
- - Validation indicators for resources with 0 candidates after filtering
336
-
337
- 3. **Filter Controls** (Top-level toggles and future controls)
338
- - **"Enable Filtering" Toggle**: Master control that disables all other filter controls
339
- - Reserved space for future filter controls (e.g., candidate count thresholds, validation levels)
340
- - When disabled: tool shows original unfiltered resources, compiled/resolution views use original data
341
-
342
- **Technical Implementation**:
343
-
344
- **1. Resource Filtering Logic**:
345
- ```typescript
346
- // Core filtering method using ResourceManager.getResourcesForContext()
347
- const filterResources = (
348
- resourceManager: ResourceManagerBuilder,
349
- partialContext: Record<string, string>,
350
- options: { partialContextMatch: true }
351
- ) => {
352
- // Convert user input to validated context
353
- const context = Context.Convert.validatedContextDecl.convert(
354
- partialContext,
355
- { qualifiers }
356
- ).orThrow();
357
-
358
- // Get filtered resources
359
- const filteredResources = resourceManager.getResourcesForContext(context, options);
360
-
361
- // Convert back to declarations for new manager
362
- const resourceDecls = filteredResources.map(resource =>
363
- resource.build().orThrow().toLooseResourceDecl()
364
- );
365
-
366
- return resourceDecls;
367
- };
368
- ```
369
-
370
- **2. Filtered Resource Manager Creation**:
371
- ```typescript
372
- // Create new ResourceManagerBuilder with same configuration
373
- const createFilteredManager = (
374
- originalManager: ResourceManagerBuilder,
375
- filteredDeclarations: ILooseResourceDecl[]
376
- ) => {
377
- const newManager = ResourceManagerBuilder.create({
378
- qualifiers: originalManager.qualifiers,
379
- resourceTypes: originalManager.resourceTypes,
380
- qualifierTypes: originalManager.qualifierTypes
381
- }).orThrow();
382
-
383
- // Add each filtered resource
384
- for (const decl of filteredDeclarations) {
385
- newManager.addResource(decl).orThrow();
386
- }
387
-
388
- return newManager;
389
- };
390
- ```
391
-
392
- **3. Integration with Compiled & Resolution Views**:
393
- - **State Management**: Filter tool updates global `ProcessedResources` state when filtering is active
394
- - **Conditional Data Source**: Compiled and Resolution tools check if filtering is enabled:
395
- - **Enabled + has filter values**: Use filtered `ProcessedResources`
396
- - **Disabled or no filter values**: Use original `ProcessedResources`
397
- - **Real-time Updates**: Changes to filter context immediately update downstream views
398
-
399
- **4. Candidate-Level Filtering Breakthrough**:
400
- The major technical achievement was implementing candidate-level filtering rather than just resource-level filtering:
401
-
402
- ```typescript
403
- // Enhanced filtering logic that filters candidates within resources
404
- const matchingCandidates = builtResource.candidates.filter((candidate) => {
405
- return candidate.canMatchPartialContext(validatedContext, options);
406
- });
407
-
408
- const filteredDeclaration = {
409
- ...originalDeclaration,
410
- candidates: matchingCandidates.map((candidate) => candidate.toLooseResourceCandidateDecl())
411
- };
412
- ```
413
-
414
- ### Rush Integration
415
- ```bash
416
- # Initialize new project
417
- rush init
418
-
419
- # Add dependencies (NOTE: -p flag required, can add multiple at once)
420
- rush add -p @fgv/ts-utils @fgv/ts-json-base @fgv/ts-json @fgv/ts-res
421
- rush add -p react react-dom
422
- rush add --dev -p @fgv/ts-utils-jest @types/react @types/react-dom
423
- rush add --dev -p webpack webpack-cli webpack-dev-server
424
- rush add --dev -p @babel/core @babel/preset-react @babel/preset-typescript
425
- rush add --dev -p babel-loader css-loader style-loader html-webpack-plugin
426
- rush add --dev -p tailwindcss postcss postcss-loader autoprefixer
427
- rush add -p @heroicons/react
428
-
429
- # Polyfills for browser compatibility
430
- rush add -p core-js whatwg-fetch
431
-
432
- # Build and test
433
- rushx build
434
- rushx test
435
- rushx dev
436
- ```
437
-
438
- **⚠️ Build Tool Selection**:
439
- - **Webpack**: Mature, excellent CommonJS support, extensive ecosystem
440
- - **Rspack**: Rust-based webpack-compatible alternative, significantly faster
441
- - Both work well with CommonJS monorepos without requiring infrastructure upgrades
442
-
443
- ### ⚠️ Dependency Management Warning
444
- - Rush automatically uses consistent versions across the monorepo or 'latest' for new packages
445
- - Dependency conflicts can be very tricky to resolve due to version synchronization
446
- - **Always work in a branch when adding/updating dependencies**
447
- - **Ask for help or confirmation at every step when dealing with dependency issues**
448
-
449
- ### File System Access
450
- ```typescript
451
- // Modern browsers support File System Access API
452
- // Fallback to traditional file input for older browsers
453
- interface FileImportOptions {
454
- types: Array<{
455
- description: string;
456
- accept: Record<string, string[]>;
457
- }>;
458
- multiple: boolean;
459
- excludeAcceptAllOption: boolean;
460
- }
461
- ```
462
-
463
- **⚠️ Browser Compatibility Note**:
464
- - Will need to polyfill `File` API and potentially other modern web APIs
465
- - Consider polyfills for older browsers or environments lacking full ES6+ support
466
- - May need polyfills for: File System Access API, FileReader, Blob, etc.
467
-
468
- ### Resource Management Integration
469
- ```typescript
470
- // Integration with ts-res components using Result pattern
471
- import { Result } from '@fgv/ts-utils';
472
- import { ImportManager } from '@fgv/ts-res/src/import';
473
- import { ResourceManagerBuilder } from '@fgv/ts-res/src/resources';
474
- import { ResourceResolver } from '@fgv/ts-res/src/runtime';
475
-
476
- // Workflow: File → Import → Build → Compile → Resolve
477
- const importResult: Result<ImportManager> = importManager.importFromFileSystem(filePath);
478
- const buildResult: Result<ResourceManagerBuilder> = resourceManager.build();
479
- const compileResult: Result<CompiledResourceCollection> = resourceManager.getCompiledResourceCollection();
480
- ```
481
-
482
- ### Application State (using Result pattern)
483
- ```typescript
484
- interface AppState {
485
- importedResources: Result<ResourceManagerBuilder>;
486
- compiledResources: Result<CompiledResourceCollection>;
487
- resolver: Result<ResourceResolver>;
488
- selectedTool: 'source' | 'filter' | 'compiled' | 'resolution' | 'configuration';
489
- messages: Message[];
490
- loading: boolean;
491
- error: Result<string>;
492
- }
493
- ```
494
-
495
- ### NPX Execution Setup
496
-
497
- ### package.json Configuration
498
- ```json
499
- {
500
- "name": "@fgv/ts-res-browser",
501
- "bin": {
502
- "ts-res-browser": "./dist/cli.js"
503
- },
504
- "scripts": {
505
- "build": "webpack --mode production",
506
- "dev": "webpack serve --mode development",
507
- "test": "jest"
508
- },
509
- "engines": {
510
- "node": ">=20.0.0"
511
- }
512
- }
513
- ```
514
-
515
- ### Webpack Configuration
516
- ```javascript
517
- // webpack.config.js
518
- const path = require('path');
519
- const HtmlWebpackPlugin = require('html-webpack-plugin');
520
-
521
- module.exports = {
522
- entry: './src/main.tsx',
523
- output: {
524
- path: path.resolve(__dirname, 'dist'),
525
- filename: 'bundle.js'
526
- },
527
- resolve: {
528
- extensions: ['.ts', '.tsx', '.js', '.jsx']
529
- },
530
- module: {
531
- rules: [
532
- {
533
- test: /\.tsx?$/,
534
- use: 'babel-loader',
535
- exclude: /node_modules/
536
- },
537
- {
538
- test: /\.css$/,
539
- use: ['style-loader', 'css-loader', 'postcss-loader']
540
- }
541
- ]
542
- },
543
- plugins: [
544
- new HtmlWebpackPlugin({
545
- template: './public/index.html'
546
- })
547
- ]
548
- };
549
- ```
550
-
551
- ### Tailwind CSS Configuration
552
- ```javascript
553
- // tailwind.config.js
554
- module.exports = {
555
- content: ['./src/**/*.{js,jsx,ts,tsx}'],
556
- theme: {
557
- extend: {}
558
- },
559
- plugins: []
560
- };
561
- ```
562
-
563
- ### CLI Entry Point
564
- ```typescript
565
- #!/usr/bin/env node
566
- // Launch development server or built application
567
- // Support for different modes: dev, build, serve
568
- ```
569
-
570
- ## Future Phases (Post-MVP)
571
-
572
- ### Phase 7: Enhanced UX
573
- - [ ] Keyboard shortcuts
574
- - [ ] Drag & drop file import
575
- - [ ] Search and filtering capabilities
576
- - [ ] Resource comparison views
577
- - [ ] Custom theme support
578
-
579
- ### Phase 8: Advanced Resource Features
580
- - [ ] Resource validation tools
581
- - [ ] Flattened resource displays
582
- - [ ] Attribution and debugging metadata
583
- - [ ] Export/import functionality for configurations
584
-
585
- ### Phase 9: Developer Tools
586
- - [ ] Performance profiling
587
- - [ ] Resource optimization suggestions
588
- - [ ] Integration with IDE extensions
589
-
590
- ## Current Status & Achievements
591
-
592
- ### ✅ Phase 1-5 Completion Summary
593
- The ts-res-browser tool is now fully functional with all core features implemented:
594
-
595
- **Core Tools Completed**:
596
- - ✅ **Source Browser**: Resource loading and browsing with comprehensive details
597
- - ✅ **Filter Tool**: Context-based resource filtering with candidate-level precision
598
- - ✅ **Compiled Browser**: Complete compiled resource structure visualization
599
- - ✅ **Resolution Viewer**: Enhanced with cache metrics, condition evaluation, and performance analysis
600
- - ✅ **Configuration Tool**: Full system configuration management with test files
601
-
602
- **Major Technical Achievements**:
603
- - ✅ **Filter Tool Breakthrough**: Implemented candidate-level filtering (not just resource-level)
604
- - ✅ **Cache Dashboard**: Real-time cache performance metrics with visual indicators
605
- - ✅ **Resolution Details**: Detailed condition evaluation and cache inspection
606
- - ✅ **Configuration Management**: Dynamic system configuration with test variations
607
- - ✅ **Performance Analysis**: Cache utilization tracking and optimization insights
608
-
609
- **Development Quality**:
610
- - ✅ **TypeScript**: Full type safety with no compilation errors
611
- - ✅ **Result Pattern**: Consistent error handling throughout the application
612
- - ✅ **Testing**: Validated with comprehensive test data and real-world scenarios
613
- - ✅ **Documentation**: Comprehensive inline documentation and user guides
614
-
615
- ### 🎯 Production Ready Features
616
- The tool is now production-ready for:
617
- 1. **Resource Development**: Creating and testing ts-res resource structures
618
- 2. **Performance Analysis**: Understanding cache behavior and optimization opportunities
619
- 3. **Configuration Management**: Testing different system configurations
620
- 4. **Debugging**: Troubleshooting resource resolution issues
621
- 5. **Education**: Learning how ts-res works internally
622
-
623
- ### 🚀 Future Refactoring Opportunities
624
-
625
- **Priority 1: Move Filtering Logic to ts-res Library**
626
- The filtering logic could benefit the broader ts-res ecosystem:
627
-
628
- ```typescript
629
- // Proposed API for ts-res library
630
- class ResourceManagerBuilder {
631
- // Current: Only filters resources (all-or-nothing)
632
- getResourcesForContext(context, options): ResourceBuilder[]
633
-
634
- // Proposed: Create filtered manager with only matching candidates
635
- createFilteredManager(context, options): Result<ResourceManagerBuilder>
636
-
637
- // Proposed: Get candidates that match context across all resources
638
- getCandidatesForContext(context, options): ResourceCandidate[]
639
- }
640
- ```
641
-
642
- **Benefits**:
643
- - Reusable across other tools and applications
644
- - Better tested and validated in the core library
645
- - Consistent filtering behavior across ts-res ecosystem
646
- - Performance optimizations can benefit all users
647
-
648
- ## Success Metrics
649
-
650
- 1. **Functionality**: Successfully import, build, and resolve ts-res resources ✅
651
- 2. **Performance**: Handle large resource collections (1000+ resources) smoothly ✅
652
- 3. **Usability**: Intuitive interface for exploring resource hierarchies ✅
653
- 4. **Reliability**: Robust error handling and recovery using Result pattern ✅
654
- 5. **Maintainability**: Clean, well-documented codebase following monorepo patterns ✅
655
-
656
- ## Development Workflow
657
-
658
- 1. **Branch Strategy**: Work in `ts-res-browser` branch off `alpha` ✅
659
- 2. **Package Management**: Use `rush add` for all dependencies ✅
660
- 3. **Git Workflow**: **NEVER commit without user review** - staging is fine ✅
661
- 4. **Incremental Development**: Complete each phase before moving to next ✅
662
- 5. **Testing**: Test with real ts-res projects throughout development ✅
663
- 6. **Documentation**: Update README and inline docs as features are added ✅
664
- 7. **Integration**: Ensure compatibility with existing ts-res ecosystem ✅
665
-
666
- ## Risk Mitigation
667
-
668
- ### Technical Risks ✅ RESOLVED
669
- - **File System Access**: Implemented robust fallbacks for browser compatibility
670
- - **Browser Compatibility**: Added necessary polyfills for File API and modern web APIs
671
- - **Large Resource Collections**: Used efficient virtualization and lazy loading
672
- - **Complex Resource Hierarchies**: Implemented efficient tree rendering
673
- - **Rush Integration**: Successfully followed monorepo patterns
674
-
675
- ### User Experience Risks ✅ ADDRESSED
676
- - **Learning Curve**: Provided clear documentation and examples
677
- - **Performance**: Optimized for common use cases first
678
- - **Browser Compatibility**: Targeted modern browsers with documented requirements
679
-
680
- ## Getting Started
681
-
682
- Once the project is initialized:
683
-
684
- 1. **Development**: `rushx dev`
685
- 2. **Building**: `rushx build`
686
- 3. **Testing**: `rushx test`
687
- 4. **Global Install**: `npm install -g .` (after rush build)
688
-
689
- This comprehensive plan documents the complete ts-res browser tool implementation, providing a structured approach that maintains consistency with Rush monorepo patterns while leveraging the existing ts-utils ecosystem.