@mapples/app 1.0.0
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 +349 -0
- package/app.plugin.js +0 -0
- package/dist/MapplesApp.d.ts +61 -0
- package/dist/MapplesApp.d.ts.map +1 -0
- package/dist/MapplesApp.js +64 -0
- package/dist/MapplesApp.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +49 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +74 -0
- package/dist/utils.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# @mapples/app
|
|
2
|
+
|
|
3
|
+
A React Native component library that provides the core Mapples ecosystem functionality. This package includes the main MapplesApp component and utility functions for asset management and font loading.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Core Mapples Integration**: Main entry point for the Mapples ecosystem
|
|
8
|
+
- 📱 **Font Loading**: Automatic font loading with expo-font integration
|
|
9
|
+
- 🎨 **Style Provider**: Built-in styling system integration
|
|
10
|
+
- 🧩 **Render Provider**: Dynamic component rendering capabilities
|
|
11
|
+
- 📦 **Asset Management**: Utility functions for processing Mapples asset references
|
|
12
|
+
- 🔧 **TypeScript Support**: Full TypeScript support with comprehensive type definitions
|
|
13
|
+
- ⚛️ **React Integration**: Seamless integration with React Native applications
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @mapples/app
|
|
19
|
+
# or
|
|
20
|
+
yarn add @mapples/app
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Basic Setup
|
|
26
|
+
|
|
27
|
+
Wrap your app with the `MapplesApp` component to enable the Mapples ecosystem:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import React from 'react';
|
|
31
|
+
import MapplesApp from '@mapples/app';
|
|
32
|
+
|
|
33
|
+
function App() {
|
|
34
|
+
return (
|
|
35
|
+
<MapplesApp>
|
|
36
|
+
{/* Your app components */}
|
|
37
|
+
</MapplesApp>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default App;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### With Custom Configuration
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import React from 'react';
|
|
48
|
+
import MapplesApp from '@mapples/app';
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
return (
|
|
52
|
+
<MapplesApp
|
|
53
|
+
showFontLoadingIndicator={true}
|
|
54
|
+
FontLoadingIndicator={<LoadingSpinner />}
|
|
55
|
+
>
|
|
56
|
+
{/* Your app components */}
|
|
57
|
+
</MapplesApp>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default App;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### With Custom Assets and Styles
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import React from 'react';
|
|
68
|
+
import MapplesApp from '@mapples/app';
|
|
69
|
+
|
|
70
|
+
const customAssets = {
|
|
71
|
+
'ref(font:123:CustomFont.ttf)': require('./fonts/CustomFont.ttf'),
|
|
72
|
+
'ref(image:456:logo.png)': require('./images/logo.png'),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const customStyle = {
|
|
76
|
+
// Your custom style configuration
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function App() {
|
|
80
|
+
return (
|
|
81
|
+
<MapplesApp
|
|
82
|
+
assets={customAssets}
|
|
83
|
+
style={customStyle}
|
|
84
|
+
>
|
|
85
|
+
{/* Your app components */}
|
|
86
|
+
</MapplesApp>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default App;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## API Reference
|
|
94
|
+
|
|
95
|
+
### MapplesApp
|
|
96
|
+
|
|
97
|
+
The main component that provides the core Mapples ecosystem functionality.
|
|
98
|
+
|
|
99
|
+
**Props:**
|
|
100
|
+
|
|
101
|
+
- `children` - Child components
|
|
102
|
+
- `style?` - Optional custom style configuration to override the default Mapples styling
|
|
103
|
+
- `assets?` - Optional custom assets configuration to override the default Mapples assets
|
|
104
|
+
- `showFontLoadingIndicator?` - Whether to show a loading indicator while fonts are loading
|
|
105
|
+
- `FontLoadingIndicator?` - Custom loading indicator component to display while fonts are loading
|
|
106
|
+
|
|
107
|
+
**Example:**
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<MapplesApp
|
|
111
|
+
showFontLoadingIndicator={true}
|
|
112
|
+
FontLoadingIndicator={<ActivityIndicator size="large" />}
|
|
113
|
+
>
|
|
114
|
+
<YourAppContent />
|
|
115
|
+
</MapplesApp>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Utility Functions
|
|
119
|
+
|
|
120
|
+
#### `normalizeKey(key)`
|
|
121
|
+
|
|
122
|
+
Normalizes a reference key by extracting type, id, and name information.
|
|
123
|
+
|
|
124
|
+
**Parameters:**
|
|
125
|
+
|
|
126
|
+
- `key` - The reference key to normalize, either in `ref(type:id:name)` format or a plain string
|
|
127
|
+
|
|
128
|
+
**Returns:**
|
|
129
|
+
|
|
130
|
+
- An object containing the parsed type, id, and normalized name, or undefined if the key format is invalid
|
|
131
|
+
|
|
132
|
+
**Example:**
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { normalizeKey } from '@mapples/app';
|
|
136
|
+
|
|
137
|
+
const result = normalizeKey('ref(font:123:MyFont.ttf)');
|
|
138
|
+
// Returns: { type: 'font', id: '123', name: 'MyFont' }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### `remapFonts(assets)`
|
|
142
|
+
|
|
143
|
+
Remaps font assets from the Mapples asset configuration format to a format compatible with expo-font.
|
|
144
|
+
|
|
145
|
+
**Parameters:**
|
|
146
|
+
|
|
147
|
+
- `assets` - The assets configuration object containing font references
|
|
148
|
+
|
|
149
|
+
**Returns:**
|
|
150
|
+
|
|
151
|
+
- A new object containing only the font assets in expo-font compatible format
|
|
152
|
+
|
|
153
|
+
**Example:**
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { remapFonts } from '@mapples/app';
|
|
157
|
+
|
|
158
|
+
const assets = {
|
|
159
|
+
'ref(font:123:MyFont.ttf)': require('./fonts/MyFont.ttf'),
|
|
160
|
+
'ref(image:456:logo.png)': require('./images/logo.png'),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const fonts = remapFonts(assets);
|
|
164
|
+
// Returns: { MyFont: require('./fonts/MyFont.ttf') }
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Advanced Usage
|
|
168
|
+
|
|
169
|
+
### Custom Font Loading
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import React from 'react';
|
|
173
|
+
import MapplesApp, { remapFonts } from '@mapples/app';
|
|
174
|
+
|
|
175
|
+
const customAssets = {
|
|
176
|
+
'ref(font:123:CustomFont.ttf)': require('./fonts/CustomFont.ttf'),
|
|
177
|
+
'ref(font:124:AnotherFont.ttf)': require('./fonts/AnotherFont.ttf'),
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
function App() {
|
|
181
|
+
return (
|
|
182
|
+
<MapplesApp assets={customAssets}>
|
|
183
|
+
<YourAppContent />
|
|
184
|
+
</MapplesApp>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Asset Processing
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { normalizeKey, remapFonts } from '@mapples/app';
|
|
193
|
+
|
|
194
|
+
// Process individual asset keys
|
|
195
|
+
const assetKey = 'ref(font:123:MyFont.ttf)';
|
|
196
|
+
const normalized = normalizeKey(assetKey);
|
|
197
|
+
console.log(normalized); // { type: 'font', id: '123', name: 'MyFont' }
|
|
198
|
+
|
|
199
|
+
// Process entire asset configuration
|
|
200
|
+
const assets = {
|
|
201
|
+
'ref(font:123:MyFont.ttf)': require('./fonts/MyFont.ttf'),
|
|
202
|
+
'ref(image:456:logo.png)': require('./images/logo.png'),
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const fonts = remapFonts(assets);
|
|
206
|
+
console.log(fonts); // { MyFont: require('./fonts/MyFont.ttf') }
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Integration with Other Mapples Packages
|
|
210
|
+
|
|
211
|
+
The MapplesApp component automatically integrates with other Mapples packages:
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
import React from 'react';
|
|
215
|
+
import MapplesApp from '@mapples/app';
|
|
216
|
+
import { useForm } from '@mapples/form';
|
|
217
|
+
import { useDnD } from '@mapples/dnd';
|
|
218
|
+
|
|
219
|
+
function App() {
|
|
220
|
+
return (
|
|
221
|
+
<MapplesApp>
|
|
222
|
+
<FormExample />
|
|
223
|
+
<DnDExample />
|
|
224
|
+
</MapplesApp>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function FormExample() {
|
|
229
|
+
const form = useForm();
|
|
230
|
+
// Form functionality is available
|
|
231
|
+
return <div>Form content</div>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function DnDExample() {
|
|
235
|
+
const { isDragging } = useDnD();
|
|
236
|
+
// Drag and drop functionality is available
|
|
237
|
+
return <div>DnD content</div>;
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## TypeScript Support
|
|
242
|
+
|
|
243
|
+
This package is written in TypeScript and provides full type safety. All APIs are documented with TSDoc comments for excellent IDE support and IntelliSense.
|
|
244
|
+
|
|
245
|
+
### Type Definitions
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
interface MapplesAppProps {
|
|
249
|
+
style?: StyleContextType;
|
|
250
|
+
assets?: AnyObject;
|
|
251
|
+
showFontLoadingIndicator?: boolean;
|
|
252
|
+
FontLoadingIndicator?: JSX.Element;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Best Practices
|
|
257
|
+
|
|
258
|
+
1. **Always wrap your app**: Use MapplesApp as the root component to ensure all Mapples functionality is available
|
|
259
|
+
|
|
260
|
+
2. **Font loading**: Consider using `showFontLoadingIndicator` for better user experience during font loading
|
|
261
|
+
|
|
262
|
+
3. **Asset organization**: Keep your asset references organized and use the utility functions for processing
|
|
263
|
+
|
|
264
|
+
4. **Performance**: The component handles font loading efficiently and only re-renders when necessary
|
|
265
|
+
|
|
266
|
+
5. **Testing**: Test your app with different asset configurations to ensure proper loading
|
|
267
|
+
|
|
268
|
+
## Metro Configuration
|
|
269
|
+
|
|
270
|
+
This package requires Metro configuration to work properly with Expo applications. Update your `metro.config.js`:
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
274
|
+
const { mapplesResolver } = require('@mapples/app/expo');
|
|
275
|
+
|
|
276
|
+
module.exports = (() => {
|
|
277
|
+
const config = getDefaultConfig(__dirname);
|
|
278
|
+
|
|
279
|
+
const { transformer, resolver } = config;
|
|
280
|
+
|
|
281
|
+
config.transformer = {
|
|
282
|
+
...transformer,
|
|
283
|
+
babelTransformerPath: require.resolve('react-native-svg-transformer/expo'),
|
|
284
|
+
};
|
|
285
|
+
config.resolver = {
|
|
286
|
+
...resolver,
|
|
287
|
+
assetExts: resolver.assetExts.filter((ext) => ext !== 'svg'),
|
|
288
|
+
sourceExts: [...resolver.sourceExts, 'svg'],
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
config.resolver.resolveRequest = mapplesResolver(
|
|
292
|
+
(context, moduleName, platform) => {
|
|
293
|
+
// add your custom resolvers here
|
|
294
|
+
return context.resolveRequest(context, moduleName, platform);
|
|
295
|
+
},
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
return config;
|
|
299
|
+
})();
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Dependencies
|
|
303
|
+
|
|
304
|
+
Make sure you have the required dependencies installed:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
npm install react-native-svg react-native-svg-transformer
|
|
308
|
+
# or
|
|
309
|
+
yarn add react-native-svg react-native-svg-transformer
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
For more information about SVG transformation, see the [react-native-svg-transformer documentation](https://github.com/kristerkari/react-native-svg-transformer).
|
|
313
|
+
|
|
314
|
+
## Development
|
|
315
|
+
|
|
316
|
+
### Building the Package
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
npm run build
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Type Checking
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
npm run type-check
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Linting
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
npm run lint
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Contributing
|
|
335
|
+
|
|
336
|
+
Contributions are welcome! Please ensure that:
|
|
337
|
+
|
|
338
|
+
1. All new APIs include comprehensive TSDoc documentation
|
|
339
|
+
2. TypeScript types are properly defined
|
|
340
|
+
3. Tests are added for new functionality
|
|
341
|
+
4. The README is updated for any new features
|
|
342
|
+
|
|
343
|
+
## License
|
|
344
|
+
|
|
345
|
+
MIT License - see LICENSE file for details.
|
|
346
|
+
|
|
347
|
+
## Author
|
|
348
|
+
|
|
349
|
+
Oleksandr Soloviov - [mapples.org](https://mapples.org/people/olek_soloviov)
|
package/app.plugin.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FC, PropsWithChildren, JSX } from 'react';
|
|
2
|
+
import { AnyObject } from '@mapples/render';
|
|
3
|
+
import { StyleContextType } from '@mapples/style';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the MapplesApp component.
|
|
6
|
+
*
|
|
7
|
+
* @interface MapplesAppProps
|
|
8
|
+
*/
|
|
9
|
+
export interface MapplesAppProps {
|
|
10
|
+
/** Optional custom style configuration to override the default Mapples styling */
|
|
11
|
+
style?: StyleContextType;
|
|
12
|
+
/** Optional custom assets configuration to override the default Mapples assets */
|
|
13
|
+
assets?: AnyObject;
|
|
14
|
+
/** Whether to show a loading indicator while fonts are loading */
|
|
15
|
+
showFontLoadingIndicator?: boolean;
|
|
16
|
+
/** Custom loading indicator component to display while fonts are loading */
|
|
17
|
+
FontLoadingIndicator?: JSX.Element;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The main MapplesApp component that provides the core Mapples ecosystem functionality.
|
|
21
|
+
*
|
|
22
|
+
* This component sets up the essential providers for styling, rendering, and asset management
|
|
23
|
+
* that are required for all Mapples applications. It handles font loading and provides
|
|
24
|
+
* a unified entry point for the Mapples ecosystem.
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
27
|
+
* @param props - The component props
|
|
28
|
+
* @returns The configured Mapples app with all necessary providers
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import MapplesApp from '@mapples/app';
|
|
33
|
+
*
|
|
34
|
+
* function App() {
|
|
35
|
+
* return (
|
|
36
|
+
* <MapplesApp>
|
|
37
|
+
* <YourAppContent />
|
|
38
|
+
* </MapplesApp>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* import MapplesApp from '@mapples/app';
|
|
46
|
+
*
|
|
47
|
+
* function App() {
|
|
48
|
+
* return (
|
|
49
|
+
* <MapplesApp
|
|
50
|
+
* showFontLoadingIndicator={true}
|
|
51
|
+
* FontLoadingIndicator={<LoadingSpinner />}
|
|
52
|
+
* >
|
|
53
|
+
* <YourAppContent />
|
|
54
|
+
* </MapplesApp>
|
|
55
|
+
* );
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare const MapplesApp: FC<PropsWithChildren<MapplesAppProps>>;
|
|
60
|
+
export default MapplesApp;
|
|
61
|
+
//# sourceMappingURL=MapplesApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapplesApp.d.ts","sourceRoot":"","sources":["../src/MapplesApp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAYzE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,kFAAkF;IAClF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,kEAAkE;IAClE,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAoBtD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { RenderProvider } from '@mapples/render';
|
|
2
|
+
import { StyleProvider, Styler } from '@mapples/style';
|
|
3
|
+
import { Components } from '@mapples/ui';
|
|
4
|
+
import { useFonts } from 'expo-font';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
// eslint-disable-next-line import/no-unresolved
|
|
7
|
+
import assetsConfig from 'mapples::assets';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
// eslint-disable-next-line import/no-unresolved
|
|
10
|
+
import styleConfig from 'mapples::style';
|
|
11
|
+
import { remapFonts } from './utils';
|
|
12
|
+
/**
|
|
13
|
+
* The main MapplesApp component that provides the core Mapples ecosystem functionality.
|
|
14
|
+
*
|
|
15
|
+
* This component sets up the essential providers for styling, rendering, and asset management
|
|
16
|
+
* that are required for all Mapples applications. It handles font loading and provides
|
|
17
|
+
* a unified entry point for the Mapples ecosystem.
|
|
18
|
+
*
|
|
19
|
+
* @component
|
|
20
|
+
* @param props - The component props
|
|
21
|
+
* @returns The configured Mapples app with all necessary providers
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import MapplesApp from '@mapples/app';
|
|
26
|
+
*
|
|
27
|
+
* function App() {
|
|
28
|
+
* return (
|
|
29
|
+
* <MapplesApp>
|
|
30
|
+
* <YourAppContent />
|
|
31
|
+
* </MapplesApp>
|
|
32
|
+
* );
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import MapplesApp from '@mapples/app';
|
|
39
|
+
*
|
|
40
|
+
* function App() {
|
|
41
|
+
* return (
|
|
42
|
+
* <MapplesApp
|
|
43
|
+
* showFontLoadingIndicator={true}
|
|
44
|
+
* FontLoadingIndicator={<LoadingSpinner />}
|
|
45
|
+
* >
|
|
46
|
+
* <YourAppContent />
|
|
47
|
+
* </MapplesApp>
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
const MapplesApp = ({ children, style, assets, showFontLoadingIndicator, FontLoadingIndicator, }) => {
|
|
53
|
+
const [loaded] = useFonts(remapFonts(assets || assetsConfig));
|
|
54
|
+
if (!loaded && showFontLoadingIndicator) {
|
|
55
|
+
return FontLoadingIndicator || null;
|
|
56
|
+
}
|
|
57
|
+
return (<StyleProvider style={Styler.init(style || styleConfig)}>
|
|
58
|
+
<RenderProvider components={Components} assets={assets || assetsConfig}>
|
|
59
|
+
{children}
|
|
60
|
+
</RenderProvider>
|
|
61
|
+
</StyleProvider>);
|
|
62
|
+
};
|
|
63
|
+
export default MapplesApp;
|
|
64
|
+
//# sourceMappingURL=MapplesApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapplesApp.js","sourceRoot":"","sources":["../src/MapplesApp.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAoB,aAAa,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,aAAa;AACb,gDAAgD;AAChD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,aAAa;AACb,gDAAgD;AAChD,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAkBrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,GAA2C,CAAC,EAC1D,QAAQ,EACR,KAAK,EACL,MAAM,EACN,wBAAwB,EACxB,oBAAoB,GACrB,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC;IAE9D,IAAI,CAAC,MAAM,IAAI,wBAAwB,EAAE,CAAC;QACxC,OAAO,oBAAoB,IAAI,IAAI,CAAC;IACtC,CAAC;IAED,OAAO,CACL,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CACtD;MAAA,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,IAAI,YAAY,CAAC,CACrE;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,cAAc,CAClB;IAAA,EAAE,aAAa,CAAC,CACjB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mapples/app
|
|
3
|
+
*
|
|
4
|
+
* A React Native component library that provides the core Mapples ecosystem functionality.
|
|
5
|
+
* This package includes the main MapplesApp component and utility functions for asset management.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export { default } from './MapplesApp';
|
|
10
|
+
export type { MapplesAppProps } from './MapplesApp';
|
|
11
|
+
export { normalizeKey, remapFonts } from './utils';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mapples/app
|
|
3
|
+
*
|
|
4
|
+
* A React Native component library that provides the core Mapples ecosystem functionality.
|
|
5
|
+
* This package includes the main MapplesApp component and utility functions for asset management.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export { default } from './MapplesApp';
|
|
10
|
+
export { normalizeKey, remapFonts } from './utils';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AnyObject } from '@mapples/render';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a reference key by extracting type, id, and name information.
|
|
4
|
+
*
|
|
5
|
+
* This function parses reference keys in the format `ref(type:id:name)` and extracts
|
|
6
|
+
* the individual components. It's used internally for processing asset references.
|
|
7
|
+
*
|
|
8
|
+
* @param key - The reference key to normalize, either in `ref(type:id:name)` format or a plain string
|
|
9
|
+
* @returns An object containing the parsed type, id, and normalized name, or undefined if the key format is invalid
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const result = normalizeKey('ref(font:123:MyFont.ttf)');
|
|
14
|
+
* // Returns: { type: 'font', id: '123', name: 'MyFont' }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = normalizeKey('plain-string');
|
|
20
|
+
* // Returns: undefined (invalid format)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const normalizeKey: (key: `ref(${string}:${string}:${string})` | string) => {
|
|
24
|
+
type: string;
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Remaps font assets from the Mapples asset configuration format to a format compatible with expo-font.
|
|
30
|
+
*
|
|
31
|
+
* This function processes the assets object and extracts only font-type assets, converting them
|
|
32
|
+
* from the Mapples reference format to a simple key-value mapping that expo-font can use.
|
|
33
|
+
*
|
|
34
|
+
* @param assets - The assets configuration object containing font references
|
|
35
|
+
* @returns A new object containing only the font assets in expo-font compatible format
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const assets = {
|
|
40
|
+
* 'ref(font:123:MyFont.ttf)': require('./fonts/MyFont.ttf'),
|
|
41
|
+
* 'ref(image:456:logo.png)': require('./images/logo.png'),
|
|
42
|
+
* };
|
|
43
|
+
*
|
|
44
|
+
* const fonts = remapFonts(assets);
|
|
45
|
+
* // Returns: { MyFont: require('./fonts/MyFont.ttf') }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const remapFonts: (assets: AnyObject) => {};
|
|
49
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,MAAM,GAAG,GAAG,MAAM;;;;aAmBnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,SAAS,OAsB3C,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { keys, reduce } from 'lodash';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a reference key by extracting type, id, and name information.
|
|
4
|
+
*
|
|
5
|
+
* This function parses reference keys in the format `ref(type:id:name)` and extracts
|
|
6
|
+
* the individual components. It's used internally for processing asset references.
|
|
7
|
+
*
|
|
8
|
+
* @param key - The reference key to normalize, either in `ref(type:id:name)` format or a plain string
|
|
9
|
+
* @returns An object containing the parsed type, id, and normalized name, or undefined if the key format is invalid
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const result = normalizeKey('ref(font:123:MyFont.ttf)');
|
|
14
|
+
* // Returns: { type: 'font', id: '123', name: 'MyFont' }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = normalizeKey('plain-string');
|
|
20
|
+
* // Returns: undefined (invalid format)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const normalizeKey = (key) => {
|
|
24
|
+
let normalizedKey = key;
|
|
25
|
+
if (!key.startsWith('ref(') || !key.endsWith(')')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const cleanValue = key.slice(4, -1);
|
|
29
|
+
const [type, id, name] = cleanValue.split(':');
|
|
30
|
+
const [fileName] = name.split('.');
|
|
31
|
+
normalizedKey = fileName;
|
|
32
|
+
return {
|
|
33
|
+
type,
|
|
34
|
+
id,
|
|
35
|
+
name: normalizedKey,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Remaps font assets from the Mapples asset configuration format to a format compatible with expo-font.
|
|
40
|
+
*
|
|
41
|
+
* This function processes the assets object and extracts only font-type assets, converting them
|
|
42
|
+
* from the Mapples reference format to a simple key-value mapping that expo-font can use.
|
|
43
|
+
*
|
|
44
|
+
* @param assets - The assets configuration object containing font references
|
|
45
|
+
* @returns A new object containing only the font assets in expo-font compatible format
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const assets = {
|
|
50
|
+
* 'ref(font:123:MyFont.ttf)': require('./fonts/MyFont.ttf'),
|
|
51
|
+
* 'ref(image:456:logo.png)': require('./images/logo.png'),
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
54
|
+
* const fonts = remapFonts(assets);
|
|
55
|
+
* // Returns: { MyFont: require('./fonts/MyFont.ttf') }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const remapFonts = (assets) => {
|
|
59
|
+
return reduce(keys(assets), (acc, key) => {
|
|
60
|
+
const normalizedKey = normalizeKey(key);
|
|
61
|
+
if (!normalizedKey) {
|
|
62
|
+
return acc;
|
|
63
|
+
}
|
|
64
|
+
const { type, name } = normalizedKey;
|
|
65
|
+
if (type !== 'font') {
|
|
66
|
+
return acc;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...acc,
|
|
70
|
+
[name]: assets[key],
|
|
71
|
+
};
|
|
72
|
+
}, {});
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAkD,EAClD,EAAE;IACF,IAAI,aAAa,GAAW,GAAG,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEpC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEnC,aAAa,GAAG,QAAQ,CAAC;IAEzB,OAAO;QACL,IAAI;QACJ,EAAE;QACF,IAAI,EAAE,aAAa;KACpB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAiB,EAAE,EAAE;IAC9C,OAAO,MAAM,CACX,IAAI,CAAC,MAAM,CAAC,EACZ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;QAErC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,OAAO;YACL,GAAG,GAAG;YACN,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC;SACpB,CAAC;IACJ,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mapples/app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc -b tsconfig.build.json",
|
|
8
|
+
"watch": "tsc -b --watch tsconfig.build.json",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"type-check": "tsc --noEmit",
|
|
11
|
+
"clean": "rm -rf dist"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Oleksandr Soloviov",
|
|
15
|
+
"url": "https://mapples.org/people/olek_soloviov"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/mapplesorg/mapples-open-kit.git",
|
|
21
|
+
"directory": "packages/@mapples/app"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18.0.0 <20.0.0",
|
|
25
|
+
"react-native": ">=0.71.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "~5.9.2"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"app.plugin.js",
|
|
33
|
+
"README.md",
|
|
34
|
+
"package.json"
|
|
35
|
+
]
|
|
36
|
+
}
|