@fgv/ts-res-browser 1.0.0 → 5.0.0-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.
- package/README.md +85 -15
- package/cli.js +121 -0
- package/dist/bundle.js +1 -1
- package/package.json +20 -7
- package/.rush/temp/5fc90bc7c2ccf812114ea099111568e5429be2a2.tar.log +0 -15
- package/.rush/temp/chunked-rush-logs/ts-res-browser.build.chunks.jsonl +0 -35
- package/.rush/temp/operation/build/all.log +0 -35
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -35
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -1217
- package/TS_RES_BROWSER_PLAN.md +0 -689
- package/babel.config.js +0 -17
- package/config/jest.config.json +0 -13
- package/config/rig.json +0 -16
- package/postcss.config.js +0 -3
- package/public/index.html +0 -15
- package/rush-logs/ts-res-browser.build.cache.log +0 -3
- package/rush-logs/ts-res-browser.build.log +0 -35
- package/src/App.tsx +0 -153
- package/src/cli.ts +0 -44
- package/src/components/common/FileImporter.tsx +0 -138
- package/src/components/common/NavigationWarningModal.tsx +0 -62
- package/src/components/layout/AppLayout.tsx +0 -46
- package/src/components/layout/Header.tsx +0 -22
- package/src/components/layout/MessagesWindow.tsx +0 -108
- package/src/components/layout/Sidebar.tsx +0 -92
- package/src/components/tools/CompiledBrowser.tsx +0 -949
- package/src/components/tools/ConfigurationTool.tsx +0 -1402
- package/src/components/tools/FilterTool.tsx +0 -1027
- package/src/components/tools/ImportTool.tsx +0 -246
- package/src/components/tools/ResolutionViewer.tsx +0 -1672
- package/src/components/tools/SourceBrowser.tsx +0 -496
- package/src/hooks/useAppState.ts +0 -107
- package/src/hooks/useFileImport.ts +0 -86
- package/src/hooks/useNavigationWarning.ts +0 -67
- package/src/hooks/useResourceManager.ts +0 -244
- package/src/index.css +0 -38
- package/src/main.tsx +0 -16
- package/src/types/app.ts +0 -62
- package/src/types/fileSystemAccess.d.ts +0 -94
- package/src/utils/browserFileTreeAccessors.ts +0 -245
- package/src/utils/fileImport.ts +0 -334
- package/src/utils/filterResources.ts +0 -677
- package/src/utils/tsResIntegration.ts +0 -467
- package/tailwind.config.js +0 -21
- package/test-data/README.md +0 -184
- package/test-data/config-variations/README.md +0 -64
- package/test-data/config-variations/composition-terminology.json +0 -112
- package/test-data/config-variations/enterprise-complex.json +0 -129
- package/test-data/config-variations/gaming-app.json +0 -87
- package/test-data/config-variations/high-priority-language.json +0 -65
- package/test-data/config-variations/minimal-basic.json +0 -37
- package/test-data/config-variations/qualifier-default-values.json +0 -71
- package/test-data/config-variations/territory-first.json +0 -68
- package/test-data/config-variations/territory-hierarchy-test.json +0 -31
- package/test-data/config-variations/territory-hierarchy-unconstrained.json +0 -32
- package/test-data/default-matching-test/greeting.res.json +0 -83
- package/test-data/default-matching-test/only-defaults.res.json +0 -48
- package/test-data/sample-project/package.json +0 -27
- package/test-data/sample-project/src/resources/app-config.json +0 -27
- package/test-data/sample-project/src/resources/app.json +0 -177
- package/test-data/sample-project/src/resources/config/app.env=development.json +0 -21
- package/test-data/sample-project/src/resources/config/app.json +0 -21
- package/test-data/sample-project/src/resources/config/app.platform=mobile.json +0 -23
- package/test-data/sample-project/src/resources/feature-flags.json +0 -23
- package/test-data/sample-project/src/resources/home=CA/common.json +0 -16
- package/test-data/sample-project/src/resources/images/density=hdpi.json +0 -29
- package/test-data/sample-project/src/resources/images/home.json +0 -29
- package/test-data/sample-project/src/resources/images/logout.json +0 -14
- package/test-data/sample-project/src/resources/images/settings.json +0 -14
- package/test-data/sample-project/src/resources/images/ui-icons.json +0 -29
- package/test-data/sample-project/src/resources/images/user.density=hdpi.json +0 -14
- package/test-data/sample-project/src/resources/images/user.json +0 -14
- package/test-data/sample-project/src/resources/lang=en-US/common.json +0 -15
- package/test-data/sample-project/src/resources/language=en-CA/ui-terms.json +0 -19
- package/test-data/sample-project/src/resources/language=en-GB/ui-terms.json +0 -30
- package/test-data/sample-project/src/resources/language=fr-CA/ui-terms.json +0 -25
- package/test-data/sample-project/src/resources/language=nl-BE/ui-terms.json +0 -17
- package/test-data/sample-project/src/resources/region=europe/feature-flags.json +0 -17
- package/test-data/sample-project/src/resources/region=north-america/feature-flags.json +0 -18
- package/test-data/sample-project/src/resources/strings/dashboard.home=CA,language=fr.json +0 -20
- package/test-data/sample-project/src/resources/strings/dashboard.json +0 -18
- package/test-data/sample-project/src/resources/strings/dashboard.role=admin.json +0 -23
- package/test-data/sample-project/src/resources/strings/dashboard.role=user.json +0 -21
- package/test-data/sample-project/src/resources/strings/language=en-US.json +0 -16
- package/test-data/sample-project/src/resources/strings.json +0 -78
- package/test-data/sample-project/src/resources/territory=BE/app-config.json +0 -19
- package/test-data/sample-project/src/resources/territory=CA/app-config.json +0 -21
- package/test-data/sample-project/src/resources/territory=GB/app-config.json +0 -25
- package/test-data/sample-project/src/resources/territory=NL/app-config.json +0 -25
- package/test-data/sample-project/src/resources/ui-terms.json +0 -96
- package/test-data/sample-project/src/resources-config.json +0 -111
- package/tsconfig.json +0 -27
- package/webpack.config.js +0 -54
package/README.md
CHANGED
|
@@ -4,9 +4,20 @@ A visual tool for loading, browsing, and experimenting with ts-res resources. Bu
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
7
|
+
### Core Tools
|
|
8
|
+
- **Import Tool**: Load resources from files or directories using File System Access API
|
|
9
|
+
- **ZIP Loader**: Load pre-bundled ZIP archives created by ts-res-browser-cli
|
|
10
|
+
- **Source Browser**: Browse and explore built resources in alphabetical order
|
|
11
|
+
- **Compiled Browser**: Navigate compiled resource collections in tree view
|
|
12
|
+
- **Filter Tool**: Filter resources by context for focused analysis
|
|
13
|
+
- **Resolution Viewer**: Test resource resolution with different qualifiers and contexts
|
|
14
|
+
- **Configuration Tool**: Manage qualifier types, qualifiers, and resource types
|
|
15
|
+
|
|
16
|
+
### Advanced Features
|
|
17
|
+
- **ZIP Archive Support**: Direct loading of ZIP bundles with automatic configuration application
|
|
18
|
+
- **URL Parameter Integration**: Launch with pre-configured settings via command line
|
|
19
|
+
- **Context Filtering**: Advanced filtering by language, territory, and custom qualifiers
|
|
20
|
+
- **Interactive Mode**: Explore with sample data and predefined configurations
|
|
10
21
|
- **Modern UI**: Built with React, TypeScript, and Tailwind CSS
|
|
11
22
|
|
|
12
23
|
## Getting Started
|
|
@@ -37,10 +48,40 @@ The application will open in your browser at `http://localhost:3000`.
|
|
|
37
48
|
|
|
38
49
|
### Usage
|
|
39
50
|
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
#### Option 1: Direct File Loading
|
|
52
|
+
1. **Import Files**: Use the Import Tool to select your ts-res project files/directories
|
|
53
|
+
2. **Browse Resources**: Navigate between different tools using the sidebar
|
|
42
54
|
3. **Explore**: View resource details, test resolution, and experiment with qualifiers
|
|
43
55
|
|
|
56
|
+
#### Option 2: ZIP Archive Workflow (Recommended)
|
|
57
|
+
1. **Create Archive**: Use ts-res-browser-cli to create ZIP archives:
|
|
58
|
+
```bash
|
|
59
|
+
ts-res-browser-cli browse --input ./resources --config extended-example
|
|
60
|
+
```
|
|
61
|
+
2. **Load Archive**: Use the ZIP Loader tool to load the created archive
|
|
62
|
+
3. **Automatic Setup**: Configuration and resources are applied automatically
|
|
63
|
+
|
|
64
|
+
#### Option 3: Command Line Integration
|
|
65
|
+
Launch directly with pre-configured settings:
|
|
66
|
+
```bash
|
|
67
|
+
# Launch with automatic development server
|
|
68
|
+
ts-res-browser-cli browse --input ./resources --dev
|
|
69
|
+
|
|
70
|
+
# Launch with ZIP creation but no browser opening
|
|
71
|
+
ts-res-browser-cli browse --input ./resources --no-open
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### URL Parameters
|
|
75
|
+
|
|
76
|
+
The browser supports URL parameters for automated setup:
|
|
77
|
+
- `config=<name>`: Load predefined configuration
|
|
78
|
+
- `contextFilter=<filter>`: Apply context filtering
|
|
79
|
+
- `loadZip=true`: Navigate directly to ZIP Loader
|
|
80
|
+
- `interactive=true`: Launch in interactive mode
|
|
81
|
+
- `reduceQualifiers=true`: Enable qualifier reduction
|
|
82
|
+
|
|
83
|
+
Example: `http://localhost:3000?config=extended-example&loadZip=true`
|
|
84
|
+
|
|
44
85
|
## Development
|
|
45
86
|
|
|
46
87
|
### Scripts
|
|
@@ -55,32 +96,61 @@ The application will open in your browser at `http://localhost:3000`.
|
|
|
55
96
|
```
|
|
56
97
|
src/
|
|
57
98
|
├── components/
|
|
58
|
-
│ ├── layout/ # Layout components
|
|
99
|
+
│ ├── layout/ # Layout components (Header, Sidebar, etc.)
|
|
59
100
|
│ ├── tools/ # Tool-specific components
|
|
101
|
+
│ │ ├── ImportTool.tsx # File/directory import
|
|
102
|
+
│ │ ├── ZipLoader.tsx # ZIP archive loader
|
|
103
|
+
│ │ ├── SourceBrowser.tsx # Resource browsing
|
|
104
|
+
│ │ ├── CompiledBrowser.tsx # Tree view navigation
|
|
105
|
+
│ │ ├── FilterTool.tsx # Context filtering
|
|
106
|
+
│ │ ├── ResolutionViewer.tsx # Resolution testing
|
|
107
|
+
│ │ └── ConfigurationTool.tsx # Configuration management
|
|
60
108
|
│ └── common/ # Shared components
|
|
61
109
|
├── hooks/ # Custom React hooks
|
|
62
|
-
├──
|
|
110
|
+
│ ├── useAppState.ts # Main application state
|
|
111
|
+
│ ├── useResourceManager.ts # Resource processing
|
|
112
|
+
│ ├── useFileImport.ts # File system operations
|
|
113
|
+
│ └── useUrlParams.ts # URL parameter parsing
|
|
63
114
|
├── utils/ # Utility functions
|
|
64
|
-
├──
|
|
115
|
+
│ ├── zip/ # Browser-specific ZIP utilities
|
|
116
|
+
│ ├── fileImport.ts # File system integration
|
|
117
|
+
│ ├── fileTreeConverter.ts # FileTree integration
|
|
118
|
+
│ └── urlParams.ts # URL parameter utilities
|
|
119
|
+
├── types/ # TypeScript type definitions
|
|
120
|
+
├── App.tsx # Main application component
|
|
65
121
|
└── main.tsx # Application entry point
|
|
66
122
|
```
|
|
67
123
|
|
|
68
124
|
### Technology Stack
|
|
69
125
|
|
|
70
|
-
- **React
|
|
71
|
-
- **Webpack** for bundling
|
|
126
|
+
- **React 19** with TypeScript
|
|
127
|
+
- **Webpack 5** for bundling with browser polyfills
|
|
72
128
|
- **Tailwind CSS** for styling
|
|
73
|
-
- **Heroicons** for iconography
|
|
129
|
+
- **Heroicons** for iconography
|
|
130
|
+
- **JSZip** for browser-based ZIP processing
|
|
74
131
|
- **@fgv/ts-res** for resource management
|
|
132
|
+
- **@fgv/ts-utils** for Result pattern and FileTree abstraction
|
|
75
133
|
|
|
76
134
|
## Architecture
|
|
77
135
|
|
|
78
136
|
The application follows a component-based architecture with:
|
|
79
137
|
|
|
80
|
-
|
|
81
|
-
- **
|
|
82
|
-
- **
|
|
83
|
-
- **
|
|
138
|
+
### Core Systems
|
|
139
|
+
- **State Management**: React hooks with centralized state management
|
|
140
|
+
- **File Access**: File System Access API with fallback to input elements
|
|
141
|
+
- **ZIP Processing**: Browser-compatible ZIP implementation using JSZip
|
|
142
|
+
- **Resource Processing**: FileTree abstraction for unified file access
|
|
143
|
+
- **Error Handling**: Result pattern from @fgv/ts-utils throughout
|
|
144
|
+
|
|
145
|
+
### Integration Points
|
|
146
|
+
- **CLI Integration**: Seamless workflow with ts-res-browser-cli via ZIP archives
|
|
147
|
+
- **URL Parameters**: Support for automated setup and configuration
|
|
148
|
+
- **Development Server**: Integration with webpack-dev-server for hot reloading
|
|
149
|
+
|
|
150
|
+
### Browser Compatibility
|
|
151
|
+
- **File System Access API**: Modern file access with graceful fallback
|
|
152
|
+
- **Node.js Polyfills**: Webpack configuration for browser compatibility
|
|
153
|
+
- **ZIP Archives**: Client-side processing without server dependencies
|
|
84
154
|
|
|
85
155
|
## Contributing
|
|
86
156
|
|
package/cli.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { exec, spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
const command = process.argv[2];
|
|
8
|
+
const projectRoot = __dirname;
|
|
9
|
+
|
|
10
|
+
// Check if we have a built dist directory
|
|
11
|
+
const distPath = path.join(projectRoot, 'dist');
|
|
12
|
+
const hasBuiltFiles = fs.existsSync(distPath) && fs.existsSync(path.join(distPath, 'index.html'));
|
|
13
|
+
|
|
14
|
+
function startDevServer(port = 3000) {
|
|
15
|
+
const packageManager = fs.existsSync(path.join(projectRoot, 'package-lock.json'))
|
|
16
|
+
? 'npm'
|
|
17
|
+
: fs.existsSync(path.join(projectRoot, 'yarn.lock'))
|
|
18
|
+
? 'yarn'
|
|
19
|
+
: 'npm';
|
|
20
|
+
|
|
21
|
+
console.log('Starting TS-RES Browser development server...');
|
|
22
|
+
console.log(`Using ${packageManager} to start server...`);
|
|
23
|
+
|
|
24
|
+
const child = spawn(packageManager, ['run', 'dev'], {
|
|
25
|
+
cwd: projectRoot,
|
|
26
|
+
stdio: 'inherit',
|
|
27
|
+
env: { ...process.env, PORT: port.toString() }
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
child.on('error', (error) => {
|
|
31
|
+
console.error(`Error starting dev server: ${error.message}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function serveBuildFiles(port = 8080) {
|
|
37
|
+
if (!hasBuiltFiles) {
|
|
38
|
+
console.error('No built files found. Please run "ts-res-browser build" first.');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Try to use a simple static server
|
|
43
|
+
try {
|
|
44
|
+
const handler = require('serve-handler');
|
|
45
|
+
const http = require('http');
|
|
46
|
+
|
|
47
|
+
const server = http.createServer((request, response) => {
|
|
48
|
+
return handler(request, response, {
|
|
49
|
+
public: distPath,
|
|
50
|
+
rewrites: [{ source: '**', destination: '/index.html' }]
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
server.listen(port, () => {
|
|
55
|
+
console.log(`TS-RES Browser running at http://localhost:${port}`);
|
|
56
|
+
console.log('Press Ctrl+C to stop');
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
// Fallback: just open the HTML file
|
|
60
|
+
console.log(`Built files available at: ${path.join(distPath, 'index.html')}`);
|
|
61
|
+
console.log('To serve the files, install a static server like: npm install -g serve');
|
|
62
|
+
console.log(`Then run: serve -s ${distPath} -p ${port}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
switch (command) {
|
|
67
|
+
case 'dev':
|
|
68
|
+
const devPort = process.argv[3] || process.env.PORT || 3000;
|
|
69
|
+
startDevServer(devPort);
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case 'serve':
|
|
73
|
+
case 'start':
|
|
74
|
+
const servePort = process.argv[3] || 8080;
|
|
75
|
+
serveBuildFiles(servePort);
|
|
76
|
+
break;
|
|
77
|
+
|
|
78
|
+
case 'build':
|
|
79
|
+
console.log('Building TS-RES Browser...');
|
|
80
|
+
const packageManager = fs.existsSync(path.join(projectRoot, 'package-lock.json')) ? 'npm' : 'npm';
|
|
81
|
+
|
|
82
|
+
const buildChild = spawn(packageManager, ['run', 'build'], {
|
|
83
|
+
cwd: projectRoot,
|
|
84
|
+
stdio: 'inherit'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
buildChild.on('error', (error) => {
|
|
88
|
+
console.error(`Error building: ${error.message}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
buildChild.on('close', (code) => {
|
|
93
|
+
if (code === 0) {
|
|
94
|
+
console.log('Build completed successfully!');
|
|
95
|
+
console.log('To serve the built files, run: ts-res-browser serve');
|
|
96
|
+
} else {
|
|
97
|
+
console.error(`Build failed with code ${code}`);
|
|
98
|
+
process.exit(code);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
console.log('TS-RES Browser CLI');
|
|
105
|
+
console.log('');
|
|
106
|
+
console.log('Usage:');
|
|
107
|
+
console.log(' ts-res-browser dev - Start development server');
|
|
108
|
+
console.log(' ts-res-browser build - Build for production');
|
|
109
|
+
console.log(' ts-res-browser serve - Serve built files');
|
|
110
|
+
console.log('');
|
|
111
|
+
console.log('Options:');
|
|
112
|
+
console.log(' ts-res-browser dev [port] - Start dev server on specific port');
|
|
113
|
+
console.log(' ts-res-browser serve [port] - Serve on specific port');
|
|
114
|
+
console.log('');
|
|
115
|
+
if (hasBuiltFiles) {
|
|
116
|
+
console.log('✅ Built files found - you can run "ts-res-browser serve"');
|
|
117
|
+
} else {
|
|
118
|
+
console.log('⚠️ No built files - run "ts-res-browser build" first');
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|