@mapples/app 1.6.0-beta.20260929132300 → 1.6.0-beta.20260929132641
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/CHANGELOG.md +3 -2
- package/README.md +11 -35
- package/dist/MapplesApp.d.ts +1 -1
- package/dist/MapplesApp.d.ts.map +1 -1
- package/dist/MapplesApp.js +12 -14
- package/dist/MapplesApp.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +50 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +43 -0
- package/dist/utils.js.map +1 -1
- package/expo/index.js +17 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# @mapples/render
|
|
2
2
|
|
|
3
|
-
## 1.6.0-beta.
|
|
3
|
+
## 1.6.0-beta.20260929132641
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- 0f0ccce: `MapplesApp` consumes what the `mapples` CLI writes: `mapplesResolver` maps `mapples::style` to `<app>/mapples/theme.ts` and `mapples::assets` to `mapples/assetMap.ts` (an empty module before the first sync), and no longer reads `.mapplesrc.json`. `theme.ts`'s `theme` / `typography` / `sizing` become the style configuration, and the asset map's metadata entries become the renderer's `ref(type:uuid:file)` lookups and expo-font registrations (`resolveAssets`). The `mapples::navigation` alias is gone — the CLI generates expo-router layouts; the `navigation` prop stays for hand-wired maps. The explicit `style` / `assets` props keep working, including `ref(...)`-keyed asset maps.
|
|
7
8
|
- a6c5872: All `@mapples/*` runtime packages now share one version and are versioned and published together from `mapplesorg/mapples-kit`; `mapples-open-kit` is a read-only mirror of the source.
|
|
8
9
|
|
|
9
10
|
### Patch Changes
|
|
10
11
|
|
|
11
12
|
- 6769311: The `expo-router` peer range now admits Expo SDK 57 (`>=56.0.0 <58`).
|
|
12
13
|
- Updated dependencies [a6c5872]
|
|
13
|
-
- @mapples/fonts@1.6.0-beta.
|
|
14
|
+
- @mapples/fonts@1.6.0-beta.20260929132641
|
|
14
15
|
|
|
15
16
|
## 1.3.0
|
|
16
17
|
|
package/README.md
CHANGED
|
@@ -305,49 +305,25 @@ interface MapplesAppProps {
|
|
|
305
305
|
|
|
306
306
|
## Metro Configuration
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
`MapplesApp` reads the files the [`mapples` CLI](https://www.npmjs.com/package/mapples) writes on `mapples sync`: `mapples/theme.ts` (design tokens) and `mapples/assetMap.ts` (bundled assets with their metadata). `mapplesResolver` maps the `mapples::style` and `mapples::assets` imports to those files — or to an empty module before the first sync, so the app renders with the defaults. Add it to your `metro.config.js`:
|
|
309
309
|
|
|
310
|
-
```
|
|
310
|
+
```js
|
|
311
311
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
312
312
|
const { mapplesResolver } = require('@mapples/app/expo');
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
const config = getDefaultConfig(__dirname);
|
|
316
|
-
|
|
317
|
-
const { transformer, resolver } = config;
|
|
318
|
-
|
|
319
|
-
config.transformer = {
|
|
320
|
-
...transformer,
|
|
321
|
-
babelTransformerPath: require.resolve('react-native-svg-transformer/expo'),
|
|
322
|
-
};
|
|
323
|
-
config.resolver = {
|
|
324
|
-
...resolver,
|
|
325
|
-
assetExts: resolver.assetExts.filter((ext) => ext !== 'svg'),
|
|
326
|
-
sourceExts: [...resolver.sourceExts, 'svg'],
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
config.resolver.resolveRequest = mapplesResolver(
|
|
330
|
-
(context, moduleName, platform) => {
|
|
331
|
-
// add your custom resolvers here
|
|
332
|
-
return context.resolveRequest(context, moduleName, platform);
|
|
333
|
-
},
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
return config;
|
|
337
|
-
})();
|
|
338
|
-
```
|
|
314
|
+
const config = getDefaultConfig(__dirname);
|
|
339
315
|
|
|
340
|
-
|
|
316
|
+
config.resolver.resolveRequest = mapplesResolver(
|
|
317
|
+
(context, moduleName, platform) => {
|
|
318
|
+
// add your custom resolvers here
|
|
319
|
+
return context.resolveRequest(context, moduleName, platform);
|
|
320
|
+
},
|
|
321
|
+
);
|
|
341
322
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
```bash
|
|
345
|
-
npm install react-native-svg react-native-svg-transformer
|
|
346
|
-
# or
|
|
347
|
-
yarn add react-native-svg react-native-svg-transformer
|
|
323
|
+
module.exports = config;
|
|
348
324
|
```
|
|
349
325
|
|
|
350
|
-
|
|
326
|
+
No `.mapplesrc.json` is needed. Navigation comes from the expo-router layouts the CLI generates; the `navigation` prop is only for a hand-wired action map.
|
|
351
327
|
|
|
352
328
|
## Development
|
|
353
329
|
|
package/dist/MapplesApp.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface MapplesAppProps {
|
|
|
12
12
|
style?: StyleContextType;
|
|
13
13
|
/** Optional custom assets configuration to override the default Mapples assets */
|
|
14
14
|
assets?: AnyObject;
|
|
15
|
-
/** Optional navigation map (Mapples action `routeName` → expo-router href)
|
|
15
|
+
/** Optional navigation map (Mapples action `routeName` → expo-router href); the CLI's generated expo-router layouts need none */
|
|
16
16
|
navigation?: NavigationMap;
|
|
17
17
|
/** Custom loading indicator component to display while fonts are loading */
|
|
18
18
|
FontLoadingIndicator?: JSX.Element;
|
package/dist/MapplesApp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapplesApp.d.ts","sourceRoot":"","sources":["../src/MapplesApp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"MapplesApp.d.ts","sourceRoot":"","sources":["../src/MapplesApp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,GAAG,EAAsB,MAAM,OAAO,CAAC;AAIvE,OAAO,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAczE,OAAO,EAAE,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AAKxE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,kFAAkF;IAClF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,iIAAiI;IACjI,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnC,4BAA4B;IAC5B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CA8CtD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/MapplesApp.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
2
|
import { Components } from '@mapples/components';
|
|
3
3
|
import { FONT_FILES } from '@mapples/fonts';
|
|
4
4
|
import { RenderProvider } from '@mapples/render';
|
|
5
5
|
import { StyleProvider, Styler } from '@mapples/style';
|
|
6
6
|
import { UIComponents } from '@mapples/ui';
|
|
7
7
|
import { useFonts } from 'expo-font';
|
|
8
|
+
// The files `mapples sync` writes — resolved by `mapplesResolver`
|
|
9
|
+
// (`@mapples/app/expo`) to <app>/mapples/theme.ts and mapples/assetMap.ts,
|
|
10
|
+
// or to an empty module before the first sync.
|
|
8
11
|
// @ts-ignore
|
|
9
12
|
// eslint-disable-next-line import/no-unresolved
|
|
10
|
-
import
|
|
13
|
+
import * as assetsModule from 'mapples::assets';
|
|
11
14
|
// @ts-ignore
|
|
12
15
|
// eslint-disable-next-line import/no-unresolved
|
|
13
|
-
import
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
// eslint-disable-next-line import/no-unresolved
|
|
16
|
-
import styleConfig from 'mapples::style';
|
|
16
|
+
import * as themeModule from 'mapples::style';
|
|
17
17
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
18
18
|
import { NavigationProvider } from './NavigationContext';
|
|
19
|
-
import {
|
|
19
|
+
import { resolveAssets, toStyleContext } from './utils';
|
|
20
20
|
const rootStyle = { flex: 1 };
|
|
21
21
|
/**
|
|
22
22
|
* The main MapplesApp component that provides the core Mapples ecosystem functionality.
|
|
@@ -60,10 +60,8 @@ const rootStyle = { flex: 1 };
|
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
const MapplesApp = ({ children, style, assets, navigation, FontLoadingIndicator, onFontLoaded, }) => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
...remapFonts(assets || assetsConfig),
|
|
66
|
-
});
|
|
63
|
+
const resolved = useMemo(() => resolveAssets(assets ?? assetsModule), [assets]);
|
|
64
|
+
const [loaded] = useFonts({ ...FONT_FILES, ...resolved.fonts });
|
|
67
65
|
useEffect(() => {
|
|
68
66
|
if (loaded && onFontLoaded) {
|
|
69
67
|
onFontLoaded();
|
|
@@ -82,9 +80,9 @@ const MapplesApp = ({ children, style, assets, navigation, FontLoadingIndicator,
|
|
|
82
80
|
// Gesture-driven library components (Slider, BottomSheet) need the
|
|
83
81
|
// gesture-handler root; the canvas provides its own through DnDRootView.
|
|
84
82
|
<GestureHandlerRootView style={rootStyle}>
|
|
85
|
-
<StyleProvider style={Styler.init(style
|
|
86
|
-
<RenderProvider components={{ ...Components, ...UIComponents }} assets={assets
|
|
87
|
-
<NavigationProvider navigation={navigation
|
|
83
|
+
<StyleProvider style={Styler.init(style ?? toStyleContext(themeModule))}>
|
|
84
|
+
<RenderProvider components={{ ...Components, ...UIComponents }} assets={resolved.assets}>
|
|
85
|
+
<NavigationProvider navigation={navigation}>
|
|
88
86
|
{children}
|
|
89
87
|
</NavigationProvider>
|
|
90
88
|
</RenderProvider>
|
package/dist/MapplesApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapplesApp.js","sourceRoot":"","sources":["../src/MapplesApp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MapplesApp.js","sourceRoot":"","sources":["../src/MapplesApp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAa,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAoB,aAAa,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,kEAAkE;AAClE,2EAA2E;AAC3E,+CAA+C;AAC/C,aAAa;AACb,gDAAgD;AAChD,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,aAAa;AACb,gDAAgD;AAChD,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,CAAC,EAAW,CAAC;AAoBvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,G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,sBAAsB,CAAC,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { default } from './MapplesApp';
|
|
10
10
|
export type { MapplesAppProps } from './MapplesApp';
|
|
11
|
-
export { normalizeKey, remapFonts } from './utils';
|
|
11
|
+
export { normalizeKey, remapFonts, resolveAssets, toStyleContext, } from './utils';
|
|
12
|
+
export type { CliAssetEntry, CliAssetModule, CliThemeModule } from './utils';
|
|
12
13
|
export { default as MapplesAppProvider } from './MapplesAppProvider';
|
|
13
14
|
export type { NavigationMap } from './NavigationContext';
|
|
14
15
|
export { NavigationContext, NavigationProvider, useNavigationMap, } from './NavigationContext';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,EACL,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
export { default } from './MapplesApp';
|
|
10
|
-
export { normalizeKey, remapFonts } from './utils';
|
|
10
|
+
export { normalizeKey, remapFonts, resolveAssets, toStyleContext, } from './utils';
|
|
11
11
|
export { default as MapplesAppProvider } from './MapplesAppProvider';
|
|
12
12
|
export { NavigationContext, NavigationProvider, useNavigationMap, } from './NavigationContext';
|
|
13
13
|
export { useNavigationActions } from './useNavigationActions';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,
|
|
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,EACL,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyObject } from '@mapples/render';
|
|
2
|
+
import type { DeepPartial, StyleContextType } from '@mapples/style';
|
|
2
3
|
/**
|
|
3
4
|
* Normalizes a reference key by extracting type, id, and name information.
|
|
4
5
|
*
|
|
@@ -46,4 +47,53 @@ export declare const normalizeKey: (key: `ref(${string}:${string}:${string})` |
|
|
|
46
47
|
* ```
|
|
47
48
|
*/
|
|
48
49
|
export declare const remapFonts: (assets: AnyObject) => {};
|
|
50
|
+
/**
|
|
51
|
+
* The module `mapples sync` writes as `mapples/theme.ts`: one exported
|
|
52
|
+
* document per token section. Each is the canvas singleton's `data`.
|
|
53
|
+
*/
|
|
54
|
+
export interface CliThemeModule {
|
|
55
|
+
theme?: DeepPartial<StyleContextType>['themeConfig'];
|
|
56
|
+
typography?: DeepPartial<StyleContextType>['typographyConfig'];
|
|
57
|
+
sizing?: DeepPartial<StyleContextType>['sizingConfig'];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Maps the CLI's `theme.ts` onto the style configuration `Styler.init`
|
|
61
|
+
* merges with the defaults (responsive breakpoints included).
|
|
62
|
+
*/
|
|
63
|
+
export declare const toStyleContext: (mod: CliThemeModule | undefined) => DeepPartial<StyleContextType>;
|
|
64
|
+
/**
|
|
65
|
+
* One entry of the CLI's `mapples/assetMap.ts`, keyed by the canvas `as_…`
|
|
66
|
+
* id. `source` is the bundled file; the rest is the asset record's
|
|
67
|
+
* metadata (`mapples` ≥ the assetMap-metadata release). Older maps hold the
|
|
68
|
+
* bare `require` as the value.
|
|
69
|
+
*/
|
|
70
|
+
export interface CliAssetEntry {
|
|
71
|
+
source: unknown;
|
|
72
|
+
type?: string;
|
|
73
|
+
/** File name without extension — the family name a font registers under. */
|
|
74
|
+
name?: string;
|
|
75
|
+
/** Local file name with extension — the third segment of a `ref(...)`. */
|
|
76
|
+
file?: string;
|
|
77
|
+
uuid?: string;
|
|
78
|
+
mime?: string;
|
|
79
|
+
}
|
|
80
|
+
/** The module `mapples sync` writes as `mapples/assetMap.ts`. */
|
|
81
|
+
export interface CliAssetModule {
|
|
82
|
+
assetMap?: Record<string, CliAssetEntry | unknown>;
|
|
83
|
+
default?: Record<string, CliAssetEntry | unknown>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolves what an app renders assets from: the renderer looks a node's
|
|
87
|
+
* `ref(type:uuid:file)` up in `assets`, expo-font registers `fonts`.
|
|
88
|
+
*
|
|
89
|
+
* Accepts either the CLI's `assetMap.ts` module (keys `as_…`, values with
|
|
90
|
+
* metadata) or a map already keyed by `ref(...)` — the `assets` prop of
|
|
91
|
+
* `MapplesApp`, or a map generated before the metadata release. A CLI entry
|
|
92
|
+
* without `uuid`/`file` still registers its font by `name`; it just cannot
|
|
93
|
+
* be addressed by a `ref(...)`.
|
|
94
|
+
*/
|
|
95
|
+
export declare const resolveAssets: (input: CliAssetModule | AnyObject | undefined) => {
|
|
96
|
+
assets: AnyObject;
|
|
97
|
+
fonts: AnyObject;
|
|
98
|
+
};
|
|
49
99
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,MAAM,GAAG,GAAG,MAAM;;;;aAmBnD,CAAC;AAEF;;;;;;;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+
/**
|
|
75
|
+
* Maps the CLI's `theme.ts` onto the style configuration `Styler.init`
|
|
76
|
+
* merges with the defaults (responsive breakpoints included).
|
|
77
|
+
*/
|
|
78
|
+
export const toStyleContext = (mod) => ({
|
|
79
|
+
themeConfig: mod?.theme,
|
|
80
|
+
typographyConfig: mod?.typography,
|
|
81
|
+
sizingConfig: mod?.sizing,
|
|
82
|
+
});
|
|
83
|
+
const isCliEntry = (value) => typeof value === 'object' && value !== null && 'source' in value;
|
|
84
|
+
/**
|
|
85
|
+
* Resolves what an app renders assets from: the renderer looks a node's
|
|
86
|
+
* `ref(type:uuid:file)` up in `assets`, expo-font registers `fonts`.
|
|
87
|
+
*
|
|
88
|
+
* Accepts either the CLI's `assetMap.ts` module (keys `as_…`, values with
|
|
89
|
+
* metadata) or a map already keyed by `ref(...)` — the `assets` prop of
|
|
90
|
+
* `MapplesApp`, or a map generated before the metadata release. A CLI entry
|
|
91
|
+
* without `uuid`/`file` still registers its font by `name`; it just cannot
|
|
92
|
+
* be addressed by a `ref(...)`.
|
|
93
|
+
*/
|
|
94
|
+
export const resolveAssets = (input) => {
|
|
95
|
+
const raw = input?.assetMap ??
|
|
96
|
+
input?.default ??
|
|
97
|
+
input ??
|
|
98
|
+
{};
|
|
99
|
+
const assets = {};
|
|
100
|
+
const fonts = {};
|
|
101
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
102
|
+
if (!isCliEntry(value)) {
|
|
103
|
+
// a ref(...)-keyed map: as given
|
|
104
|
+
assets[key] = value;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (value.uuid && value.file) {
|
|
108
|
+
assets[`ref(${value.type ?? 'file'}:${value.uuid}:${value.file})`] =
|
|
109
|
+
value.source;
|
|
110
|
+
}
|
|
111
|
+
if (value.type === 'font' && value.name) {
|
|
112
|
+
fonts[value.name] = value.source;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { assets, fonts: { ...remapFonts(assets), ...fonts } };
|
|
116
|
+
};
|
|
74
117
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,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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B,MAAM,CAAC,OAAO,KAAK,CAAC,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC;gBAChE,KAAK,CAAC,MAAM,CAAC;QACjB,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACxC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC;AAChE,CAAC,CAAC"}
|
package/expo/index.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return context.resolveRequest(context, stylePath, platform);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (moduleName === 'mapples::assets') {
|
|
17
|
-
const config = JSON.parse(
|
|
18
|
-
fs.readFileSync(path.resolve('./.mapplesrc.json'), 'utf-8'),
|
|
19
|
-
);
|
|
20
|
-
const assetsPath = path.resolve(
|
|
21
|
-
`./${config.sourceDir}/${config.dirs.assets}/assetMap`,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
return context.resolveRequest(context, assetsPath, platform);
|
|
25
|
-
}
|
|
4
|
+
// The files the `mapples` CLI writes (`mapples sync`): design tokens and the
|
|
5
|
+
// asset map, both under <app root>/mapples/. An app that has not synced yet
|
|
6
|
+
// resolves to the empty module, so `MapplesApp` falls back to the defaults
|
|
7
|
+
// instead of Metro failing on a missing file.
|
|
8
|
+
const CLI_FILES = {
|
|
9
|
+
'mapples::style': 'mapples/theme.ts',
|
|
10
|
+
'mapples::assets': 'mapples/assetMap.ts',
|
|
11
|
+
};
|
|
12
|
+
const EMPTY = require.resolve('./empty.js');
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
const mapplesResolver = (resolver) => (context, moduleName, platform) => {
|
|
15
|
+
const cliFile = CLI_FILES[moduleName];
|
|
16
|
+
if (cliFile) {
|
|
17
|
+
const target = path.resolve(cliFile);
|
|
18
|
+
return context.resolveRequest(
|
|
19
|
+
context,
|
|
20
|
+
fs.existsSync(target) ? target : EMPTY,
|
|
21
|
+
platform,
|
|
33
22
|
);
|
|
34
|
-
|
|
35
|
-
return context.resolveRequest(context, navigationMap, platform);
|
|
36
23
|
}
|
|
37
24
|
|
|
38
25
|
if (resolver) {
|