@mapples/app 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,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=MapplesAppProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapplesAppProvider.d.ts","sourceRoot":"","sources":["../src/MapplesAppProvider.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;AAMzE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,KAAK,EAAE,gBAAgB,CAAC;IACxB,kFAAkF;IAClF,MAAM,EAAE,SAAS,CAAC;IAClB,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,58 @@
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
+ import { remapFonts } from './utils';
6
+ /**
7
+ * The main MapplesApp component that provides the core Mapples ecosystem functionality.
8
+ *
9
+ * This component sets up the essential providers for styling, rendering, and asset management
10
+ * that are required for all Mapples applications. It handles font loading and provides
11
+ * a unified entry point for the Mapples ecosystem.
12
+ *
13
+ * @component
14
+ * @param props - The component props
15
+ * @returns The configured Mapples app with all necessary providers
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import MapplesApp from '@mapples/app';
20
+ *
21
+ * function App() {
22
+ * return (
23
+ * <MapplesApp>
24
+ * <YourAppContent />
25
+ * </MapplesApp>
26
+ * );
27
+ * }
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * import MapplesApp from '@mapples/app';
33
+ *
34
+ * function App() {
35
+ * return (
36
+ * <MapplesApp
37
+ * showFontLoadingIndicator={true}
38
+ * FontLoadingIndicator={<LoadingSpinner />}
39
+ * >
40
+ * <YourAppContent />
41
+ * </MapplesApp>
42
+ * );
43
+ * }
44
+ * ```
45
+ */
46
+ const MapplesApp = ({ children, style, assets, showFontLoadingIndicator, FontLoadingIndicator, }) => {
47
+ const [loaded] = useFonts(remapFonts(assets));
48
+ if (!loaded && showFontLoadingIndicator) {
49
+ return FontLoadingIndicator || null;
50
+ }
51
+ return (<StyleProvider style={Styler.init(style)}>
52
+ <RenderProvider components={Components} assets={assets}>
53
+ {children}
54
+ </RenderProvider>
55
+ </StyleProvider>);
56
+ };
57
+ export default MapplesApp;
58
+ //# sourceMappingURL=MapplesAppProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapplesAppProvider.js","sourceRoot":"","sources":["../src/MapplesAppProvider.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;AAErC,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,CAAC,CAAC,CAAC;IAE9C,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,CAAC,CAAC,CACvC;MAAA,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CACrD;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 CHANGED
@@ -9,4 +9,5 @@
9
9
  export { default } from './MapplesApp';
10
10
  export type { MapplesAppProps } from './MapplesApp';
11
11
  export { normalizeKey, remapFonts } from './utils';
12
+ export { default as MapplesAppProvider } from './MapplesAppProvider';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -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,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
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;AACnD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -8,4 +8,5 @@
8
8
  */
9
9
  export { default } from './MapplesApp';
10
10
  export { normalizeKey, remapFonts } from './utils';
11
+ export { default as MapplesAppProvider } from './MapplesAppProvider';
11
12
  //# sourceMappingURL=index.js.map
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,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
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;AACnD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/expo/index.js ADDED
@@ -0,0 +1,34 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const mapplesResolver = (resolver) => (context, moduleName, platform) => {
5
+ if (moduleName === 'mapples::style') {
6
+ const config = JSON.parse(
7
+ fs.readFileSync(path.resolve('./.mapplesrc.json'), 'utf-8'),
8
+ );
9
+ const stylePath = path.resolve(
10
+ `./${config.sourceDir}/${config.dirs.style}/style.json`,
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
+ }
26
+
27
+ if (resolver) {
28
+ return resolver(context, moduleName, platform);
29
+ }
30
+
31
+ return context.resolveRequest(context, moduleName, platform);
32
+ };
33
+
34
+ module.exports = { mapplesResolver };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapples/app",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -31,6 +31,7 @@
31
31
  "dist",
32
32
  "app.plugin.js",
33
33
  "README.md",
34
- "package.json"
34
+ "package.json",
35
+ "expo/index.js"
35
36
  ]
36
37
  }
package/app.plugin.js DELETED
File without changes