@ankhorage/studio 0.0.20 → 0.1.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.
Files changed (211) hide show
  1. package/README.md +1 -2
  2. package/dist/cli/index.d.ts +4 -4
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +81 -56
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/core/constants.d.ts.map +1 -1
  7. package/dist/core/constants.js +17 -6
  8. package/dist/core/constants.js.map +1 -1
  9. package/dist/hooks/useProjects.js +1 -1
  10. package/dist/hooks/useProjects.js.map +1 -1
  11. package/dist/host/createStudioHost.d.ts +13 -0
  12. package/dist/host/createStudioHost.d.ts.map +1 -0
  13. package/dist/host/createStudioHost.js +16 -0
  14. package/dist/host/createStudioHost.js.map +1 -0
  15. package/dist/host/http/security.d.ts +2 -0
  16. package/dist/host/http/security.d.ts.map +1 -0
  17. package/dist/host/http/security.js +55 -0
  18. package/dist/host/http/security.js.map +1 -0
  19. package/dist/host/http/server.d.ts +16 -0
  20. package/dist/host/http/server.d.ts.map +1 -0
  21. package/dist/host/http/server.js +549 -0
  22. package/dist/host/http/server.js.map +1 -0
  23. package/dist/host/layout/auth/resolveAuthLayoutPlan.d.ts +38 -0
  24. package/dist/host/layout/auth/resolveAuthLayoutPlan.d.ts.map +1 -0
  25. package/dist/host/layout/auth/resolveAuthLayoutPlan.js +262 -0
  26. package/dist/host/layout/auth/resolveAuthLayoutPlan.js.map +1 -0
  27. package/dist/host/layout/layoutGenerator.d.ts +19 -0
  28. package/dist/host/layout/layoutGenerator.d.ts.map +1 -0
  29. package/dist/host/layout/layoutGenerator.js +418 -0
  30. package/dist/host/layout/layoutGenerator.js.map +1 -0
  31. package/dist/host/layout/templates/auth/adapter.d.ts +6 -0
  32. package/dist/host/layout/templates/auth/adapter.d.ts.map +1 -0
  33. package/dist/host/layout/templates/auth/adapter.js +94 -0
  34. package/dist/host/layout/templates/auth/adapter.js.map +1 -0
  35. package/dist/host/layout/templates/auth/screen.d.ts +12 -0
  36. package/dist/host/layout/templates/auth/screen.d.ts.map +1 -0
  37. package/dist/host/layout/templates/auth/screen.js +648 -0
  38. package/dist/host/layout/templates/auth/screen.js.map +1 -0
  39. package/dist/host/layout/templates/auth/session.d.ts +2 -0
  40. package/dist/host/layout/templates/auth/session.d.ts.map +1 -0
  41. package/dist/host/layout/templates/auth/session.js +326 -0
  42. package/dist/host/layout/templates/auth/session.js.map +1 -0
  43. package/dist/host/layout/templates/auth/signOut.d.ts +2 -0
  44. package/dist/host/layout/templates/auth/signOut.d.ts.map +1 -0
  45. package/dist/host/layout/templates/auth/signOut.js +43 -0
  46. package/dist/host/layout/templates/auth/signOut.js.map +1 -0
  47. package/dist/host/layout/templates/index.d.ts +11 -0
  48. package/dist/host/layout/templates/index.d.ts.map +1 -0
  49. package/dist/host/layout/templates/index.js +10 -0
  50. package/dist/host/layout/templates/index.js.map +1 -0
  51. package/dist/host/layout/templates/navigation.d.ts +16 -0
  52. package/dist/host/layout/templates/navigation.d.ts.map +1 -0
  53. package/dist/host/layout/templates/navigation.js +332 -0
  54. package/dist/host/layout/templates/navigation.js.map +1 -0
  55. package/dist/host/layout/templates/nestedLayout.d.ts +7 -0
  56. package/dist/host/layout/templates/nestedLayout.d.ts.map +1 -0
  57. package/dist/host/layout/templates/nestedLayout.js +56 -0
  58. package/dist/host/layout/templates/nestedLayout.js.map +1 -0
  59. package/dist/host/layout/templates/redirect.d.ts +2 -0
  60. package/dist/host/layout/templates/redirect.d.ts.map +1 -0
  61. package/dist/host/layout/templates/redirect.js +10 -0
  62. package/dist/host/layout/templates/redirect.js.map +1 -0
  63. package/dist/host/layout/templates/rootLayout.d.ts +28 -0
  64. package/dist/host/layout/templates/rootLayout.d.ts.map +1 -0
  65. package/dist/host/layout/templates/rootLayout.js +507 -0
  66. package/dist/host/layout/templates/rootLayout.js.map +1 -0
  67. package/dist/host/layout/templates/screen.d.ts +6 -0
  68. package/dist/host/layout/templates/screen.d.ts.map +1 -0
  69. package/dist/host/layout/templates/screen.js +94 -0
  70. package/dist/host/layout/templates/screen.js.map +1 -0
  71. package/dist/host/layout/templates/utils/routes.d.ts +3 -0
  72. package/dist/host/layout/templates/utils/routes.d.ts.map +1 -0
  73. package/dist/host/layout/templates/utils/routes.js +15 -0
  74. package/dist/host/layout/templates/utils/routes.js.map +1 -0
  75. package/dist/host/layout/templates/utils/strings.d.ts +3 -0
  76. package/dist/host/layout/templates/utils/strings.d.ts.map +1 -0
  77. package/dist/host/layout/templates/utils/strings.js +7 -0
  78. package/dist/host/layout/templates/utils/strings.js.map +1 -0
  79. package/dist/host/layout/utils/escapeStringLiteral.d.ts +2 -0
  80. package/dist/host/layout/utils/escapeStringLiteral.d.ts.map +1 -0
  81. package/dist/host/layout/utils/escapeStringLiteral.js +8 -0
  82. package/dist/host/layout/utils/escapeStringLiteral.js.map +1 -0
  83. package/dist/host/manifestSystem/auth/index.d.ts +2 -0
  84. package/dist/host/manifestSystem/auth/index.d.ts.map +1 -0
  85. package/dist/host/manifestSystem/auth/index.js +2 -0
  86. package/dist/host/manifestSystem/auth/index.js.map +1 -0
  87. package/dist/host/manifestSystem/auth/shared/global.auth.system.tpl.d.ts +4 -0
  88. package/dist/host/manifestSystem/auth/shared/global.auth.system.tpl.d.ts.map +1 -0
  89. package/dist/host/manifestSystem/auth/shared/global.auth.system.tpl.js +7 -0
  90. package/dist/host/manifestSystem/auth/shared/global.auth.system.tpl.js.map +1 -0
  91. package/dist/host/manifestSystem/auth/shared/index.d.ts +3 -0
  92. package/dist/host/manifestSystem/auth/shared/index.d.ts.map +1 -0
  93. package/dist/host/manifestSystem/auth/shared/index.js +8 -0
  94. package/dist/host/manifestSystem/auth/shared/index.js.map +1 -0
  95. package/dist/host/manifestSystem/index.d.ts +5 -0
  96. package/dist/host/manifestSystem/index.d.ts.map +1 -0
  97. package/dist/host/manifestSystem/index.js +23 -0
  98. package/dist/host/manifestSystem/index.js.map +1 -0
  99. package/dist/host/manifestSystem/types.d.ts +8 -0
  100. package/dist/host/manifestSystem/types.d.ts.map +1 -0
  101. package/dist/host/manifestSystem/types.js +2 -0
  102. package/dist/host/manifestSystem/types.js.map +1 -0
  103. package/dist/host/modules/catalog.d.ts +40 -0
  104. package/dist/host/modules/catalog.d.ts.map +1 -0
  105. package/dist/host/modules/catalog.js +112 -0
  106. package/dist/host/modules/catalog.js.map +1 -0
  107. package/dist/host/modules/layout.d.ts +7 -0
  108. package/dist/host/modules/layout.d.ts.map +1 -0
  109. package/dist/host/modules/layout.js +2 -0
  110. package/dist/host/modules/layout.js.map +1 -0
  111. package/dist/host/modules/runtime/LocalFsTargetAdapter.d.ts +34 -0
  112. package/dist/host/modules/runtime/LocalFsTargetAdapter.d.ts.map +1 -0
  113. package/dist/host/modules/runtime/LocalFsTargetAdapter.js +85 -0
  114. package/dist/host/modules/runtime/LocalFsTargetAdapter.js.map +1 -0
  115. package/dist/host/orchestrator/generatedAppFiles.d.ts +8 -0
  116. package/dist/host/orchestrator/generatedAppFiles.d.ts.map +1 -0
  117. package/dist/host/orchestrator/generatedAppFiles.js +125 -0
  118. package/dist/host/orchestrator/generatedAppFiles.js.map +1 -0
  119. package/dist/host/orchestrator/generatedRouteCleanup.d.ts +5 -0
  120. package/dist/host/orchestrator/generatedRouteCleanup.d.ts.map +1 -0
  121. package/dist/host/orchestrator/generatedRouteCleanup.js +117 -0
  122. package/dist/host/orchestrator/generatedRouteCleanup.js.map +1 -0
  123. package/dist/host/orchestrator/infraGenerator.d.ts +35 -0
  124. package/dist/host/orchestrator/infraGenerator.d.ts.map +1 -0
  125. package/dist/host/orchestrator/infraGenerator.js +135 -0
  126. package/dist/host/orchestrator/infraGenerator.js.map +1 -0
  127. package/dist/host/orchestrator/infraRuntime.d.ts +38 -0
  128. package/dist/host/orchestrator/infraRuntime.d.ts.map +1 -0
  129. package/dist/host/orchestrator/infraRuntime.js +227 -0
  130. package/dist/host/orchestrator/infraRuntime.js.map +1 -0
  131. package/dist/host/orchestrator/infraValidation.d.ts +3 -0
  132. package/dist/host/orchestrator/infraValidation.d.ts.map +1 -0
  133. package/dist/host/orchestrator/infraValidation.js +59 -0
  134. package/dist/host/orchestrator/infraValidation.js.map +1 -0
  135. package/dist/host/orchestrator/moduleManager.d.ts +86 -0
  136. package/dist/host/orchestrator/moduleManager.d.ts.map +1 -0
  137. package/dist/host/orchestrator/moduleManager.js +312 -0
  138. package/dist/host/orchestrator/moduleManager.js.map +1 -0
  139. package/dist/host/orchestrator/projectDeletion.d.ts +27 -0
  140. package/dist/host/orchestrator/projectDeletion.d.ts.map +1 -0
  141. package/dist/host/orchestrator/projectDeletion.js +242 -0
  142. package/dist/host/orchestrator/projectDeletion.js.map +1 -0
  143. package/dist/host/orchestrator/projectManager.d.ts +87 -0
  144. package/dist/host/orchestrator/projectManager.d.ts.map +1 -0
  145. package/dist/host/orchestrator/projectManager.js +371 -0
  146. package/dist/host/orchestrator/projectManager.js.map +1 -0
  147. package/dist/host/orchestrator/projectPaths.d.ts +4 -0
  148. package/dist/host/orchestrator/projectPaths.d.ts.map +1 -0
  149. package/dist/host/orchestrator/projectPaths.js +25 -0
  150. package/dist/host/orchestrator/projectPaths.js.map +1 -0
  151. package/dist/host/orchestrator/projectStore.d.ts +24 -0
  152. package/dist/host/orchestrator/projectStore.d.ts.map +1 -0
  153. package/dist/host/orchestrator/projectStore.js +155 -0
  154. package/dist/host/orchestrator/projectStore.js.map +1 -0
  155. package/dist/host/orchestrator/resolveMutations.d.ts +3 -0
  156. package/dist/host/orchestrator/resolveMutations.d.ts.map +1 -0
  157. package/dist/host/orchestrator/resolveMutations.js +12 -0
  158. package/dist/host/orchestrator/resolveMutations.js.map +1 -0
  159. package/dist/host/orchestrator/scaffolder.d.ts +33 -0
  160. package/dist/host/orchestrator/scaffolder.d.ts.map +1 -0
  161. package/dist/host/orchestrator/scaffolder.js +246 -0
  162. package/dist/host/orchestrator/scaffolder.js.map +1 -0
  163. package/dist/host/orchestrator/templates.d.ts +83 -0
  164. package/dist/host/orchestrator/templates.d.ts.map +1 -0
  165. package/dist/host/orchestrator/templates.js +355 -0
  166. package/dist/host/orchestrator/templates.js.map +1 -0
  167. package/dist/host/orchestrator/workspaceRuntime.d.ts +2 -0
  168. package/dist/host/orchestrator/workspaceRuntime.d.ts.map +1 -0
  169. package/dist/host/orchestrator/workspaceRuntime.js +82 -0
  170. package/dist/host/orchestrator/workspaceRuntime.js.map +1 -0
  171. package/dist/host/templateRegistry/index.d.ts +16 -0
  172. package/dist/host/templateRegistry/index.d.ts.map +1 -0
  173. package/dist/host/templateRegistry/index.js +74 -0
  174. package/dist/host/templateRegistry/index.js.map +1 -0
  175. package/dist/host/utils/requirementsInference.d.ts +4 -0
  176. package/dist/host/utils/requirementsInference.d.ts.map +1 -0
  177. package/dist/host/utils/requirementsInference.js +49 -0
  178. package/dist/host/utils/requirementsInference.js.map +1 -0
  179. package/dist/host/utils/trimOutput.d.ts +7 -0
  180. package/dist/host/utils/trimOutput.d.ts.map +1 -0
  181. package/dist/host/utils/trimOutput.js +32 -0
  182. package/dist/host/utils/trimOutput.js.map +1 -0
  183. package/dist/host/utils/workspaceRoot.d.ts +2 -0
  184. package/dist/host/utils/workspaceRoot.d.ts.map +1 -0
  185. package/dist/host/utils/workspaceRoot.js +33 -0
  186. package/dist/host/utils/workspaceRoot.js.map +1 -0
  187. package/dist/host/zoraExtensions/index.d.ts +11 -0
  188. package/dist/host/zoraExtensions/index.d.ts.map +1 -0
  189. package/dist/host/zoraExtensions/index.js +54 -0
  190. package/dist/host/zoraExtensions/index.js.map +1 -0
  191. package/dist/runtime/appExtensionRegistry.d.ts +3 -0
  192. package/dist/runtime/appExtensionRegistry.d.ts.map +1 -0
  193. package/dist/runtime/appExtensionRegistry.js +8 -0
  194. package/dist/runtime/appExtensionRegistry.js.map +1 -0
  195. package/dist/runtime/index.d.ts +8 -4
  196. package/dist/runtime/index.d.ts.map +1 -1
  197. package/dist/runtime/index.js +8 -4
  198. package/dist/runtime/index.js.map +1 -1
  199. package/dist/runtime/registry.d.ts +7 -0
  200. package/dist/runtime/registry.d.ts.map +1 -0
  201. package/dist/runtime/registry.js +7 -0
  202. package/dist/runtime/registry.js.map +1 -0
  203. package/dist/runtime/runtimeActions.d.ts +19 -0
  204. package/dist/runtime/runtimeActions.d.ts.map +1 -0
  205. package/dist/runtime/runtimeActions.js +5 -0
  206. package/dist/runtime/runtimeActions.js.map +1 -0
  207. package/dist/runtime/useRuntimeAction.d.ts +10 -0
  208. package/dist/runtime/useRuntimeAction.d.ts.map +1 -0
  209. package/dist/runtime/useRuntimeAction.js +30 -0
  210. package/dist/runtime/useRuntimeAction.js.map +1 -0
  211. package/package.json +35 -3
@@ -0,0 +1,507 @@
1
+ import { escapeStringLiteral } from '../utils/escapeStringLiteral';
2
+ import { routeNameToGroupedHref, routeNameToHref } from './utils/routes';
3
+ function serializeStringArrayLiteral(values) {
4
+ return `[${values.map((value) => `'${escapeStringLiteral(value)}'`).join(', ')}]`;
5
+ }
6
+ function indentGeneratedBlock(content, indent = ' ') {
7
+ return content
8
+ .split('\n')
9
+ .map((line) => (line.length > 0 ? `${indent}${line}` : line))
10
+ .join('\n');
11
+ }
12
+ export function getRootLayoutTsx(args) {
13
+ const { manifest, mutations, allImports, allHooks, innerNavigation, includeStudio, authRuntime, initialRouteNameOverride, runtimeModuleDeclarations, runtimeProviderEnd = [], runtimeProviderStart = [], useStoredAuthSessionCredentialResolver = false, } = args;
14
+ const pluginProvidersStart = mutations.flatMap((m) => m.providerStart);
15
+ const pluginProvidersEnd = mutations.flatMap((m) => m.providerEnd).reverse();
16
+ const innerThemeHook = innerNavigation.usesTheme ? ' const { theme } = useZoraTheme();\n' : '';
17
+ const providersStart = [...runtimeProviderStart, ...pluginProvidersStart].join('\n ');
18
+ const providersEnd = [...pluginProvidersEnd, ...runtimeProviderEnd].join('\n ');
19
+ const finalJsx = providersStart ? `{${providersStart}{output}${providersEnd}}` : '{output}';
20
+ const authRuntimeConstants = authRuntime
21
+ ? `
22
+ const AUTH_SIGN_IN_ROUTE_SEGMENT = '${escapeStringLiteral(authRuntime.signInRouteName)}';
23
+ const AUTH_SIGN_UP_ROUTE_SEGMENT = '${escapeStringLiteral(authRuntime.signUpRouteName)}';
24
+ const AUTH_SIGN_IN_ROUTE_PATH = '${escapeStringLiteral(routeNameToHref(authRuntime.signInRoute))}';
25
+ const AUTH_SIGN_IN_ROUTE_TARGET = '${escapeStringLiteral(routeNameToGroupedHref(authRuntime.signInRoute, 'auth'))}';
26
+ const AUTH_POST_SIGN_IN_ROUTE_PATH = '${escapeStringLiteral(routeNameToHref(authRuntime.postSignInRoute))}';
27
+ const AUTH_POST_SIGN_IN_ROUTE_TARGET = '${escapeStringLiteral(routeNameToGroupedHref(authRuntime.postSignInRoute, 'app'))}';
28
+ const AUTH_PUBLIC_ROUTES = ${serializeStringArrayLiteral(authRuntime.publicRoutes)};
29
+ const AUTH_DISABLE_IN_DEV = process.env.EXPO_PUBLIC_ANKH_AUTH_DISABLE_IN_DEV === 'true';
30
+
31
+ function normalizeRoutePath(pathname: string): string {
32
+ const normalized = pathname.replace(/\\/+$/, '');
33
+ return normalized === '' ? '/' : normalized;
34
+ }
35
+
36
+ function getTopLevelRoute(pathname: string): string {
37
+ const normalized = normalizeRoutePath(pathname);
38
+ if (normalized === '/') return 'index';
39
+ const [, topLevelRoute = 'index'] = normalized.split('/');
40
+ return topLevelRoute;
41
+ }
42
+
43
+ function getRootNavigationKey(state: { key?: string } | null | undefined): string {
44
+ return state?.key ?? '';
45
+ }
46
+ ${includeStudio
47
+ ? `
48
+ function isAuthRoute(pathname: string): boolean {
49
+ const activeTopLevelRoute = getTopLevelRoute(pathname);
50
+ return (
51
+ activeTopLevelRoute === AUTH_SIGN_IN_ROUTE_SEGMENT ||
52
+ activeTopLevelRoute === AUTH_SIGN_UP_ROUTE_SEGMENT
53
+ );
54
+ }
55
+
56
+ function shouldMountAuthenticatedAppHeader(pathname: string, isAuthRuntimeReady: boolean): boolean {
57
+ const authEnforced = !__DEV__ || !AUTH_DISABLE_IN_DEV;
58
+ if (!authEnforced) return true;
59
+ if (!isAuthRuntimeReady) return false;
60
+ if (!isAuthenticated()) return false;
61
+ return !isAuthRoute(pathname);
62
+ }
63
+ `
64
+ : ''}
65
+ `
66
+ : '';
67
+ const appHeaderHelpers = `
68
+ function normalizeAppHeaderPath(pathname: string): string {
69
+ const normalized = pathname.replace(/\\/+$/, '');
70
+ return normalized === '' ? '/' : normalized;
71
+ }
72
+
73
+ function getAppHeaderSegments(pathname: string): string[] {
74
+ const normalized = normalizeAppHeaderPath(pathname);
75
+ if (normalized === '/') return ['index'];
76
+ return normalized.replace(/^\\/+/, '').split('/').filter(Boolean);
77
+ }
78
+
79
+ function findRouteBySegments(navigator: NavigatorSpec, segments: string[]): RouteDefinition | null {
80
+ let current: NavigatorSpec | undefined = navigator;
81
+ let match: RouteDefinition | undefined;
82
+
83
+ for (const segment of segments) {
84
+ if (!current) break;
85
+ match = current.routes.find((route) => route.name === segment);
86
+ if (!match) break;
87
+ current = match.navigator ?? undefined;
88
+ }
89
+
90
+ return match ?? null;
91
+ }
92
+
93
+ function findRouteByScreenId(navigator: NavigatorSpec, screenId: string): RouteDefinition | null {
94
+ for (const route of navigator.routes) {
95
+ if (route.screenId === screenId) {
96
+ return route;
97
+ }
98
+
99
+ if (route.navigator) {
100
+ const nestedRoute = findRouteByScreenId(route.navigator, screenId);
101
+ if (nestedRoute) {
102
+ return nestedRoute;
103
+ }
104
+ }
105
+ }
106
+
107
+ return null;
108
+ }
109
+
110
+ function resolveAppHeaderTitle(manifest: AppManifest, pathname: string): string {
111
+ const segments = getAppHeaderSegments(pathname);
112
+ const route = findRouteBySegments(manifest.navigator, segments);
113
+ const screen = route?.screenId ? manifest.screens[route.screenId] : undefined;
114
+ return route?.label ?? screen?.title ?? screen?.name ?? route?.name ?? 'App';
115
+ }
116
+
117
+ function resolveAppHeaderTitleForScreenId(
118
+ manifest: AppManifest,
119
+ screenId: string | null | undefined,
120
+ ): string | null {
121
+ if (!screenId) return null;
122
+
123
+ const screen = manifest.screens[screenId];
124
+ if (!screen) return null;
125
+
126
+ const route = findRouteByScreenId(manifest.navigator, screenId);
127
+ return route?.label ?? screen.title ?? screen.name;
128
+ }
129
+
130
+ function resolveStudioAppHeaderTitle(args: {
131
+ runtimeManifest: AppManifest;
132
+ studioManifest: AppManifest | null;
133
+ previewMode: boolean;
134
+ activeScreenId: string | null;
135
+ pathname: string;
136
+ }): string {
137
+ const { runtimeManifest, studioManifest, previewMode, activeScreenId, pathname } = args;
138
+
139
+ if (previewMode) {
140
+ const previewTitle = resolveAppHeaderTitleForScreenId(
141
+ studioManifest ?? runtimeManifest,
142
+ activeScreenId,
143
+ );
144
+ if (previewTitle) {
145
+ return previewTitle;
146
+ }
147
+ }
148
+
149
+ return resolveAppHeaderTitle(runtimeManifest, pathname);
150
+ }
151
+ `;
152
+ const authRuntimeHook = authRuntime
153
+ ? `
154
+ const router = useRouter();
155
+ const rootNavigationState = useRootNavigationState();
156
+ const pathname = usePathname();
157
+ const rootNavigationKey = getRootNavigationKey(rootNavigationState);
158
+ const [authSessionVersion, setAuthSessionVersion] = useState(0);
159
+ const [isAuthRuntimeReady, setIsAuthRuntimeReady] = useState(false);
160
+ const [isInnerContentReady, setIsInnerContentReady] = useState(false);
161
+
162
+ useEffect(() => {
163
+ const mountController = new AbortController();
164
+
165
+ void (async () => {
166
+ bootstrapAuthSession();
167
+ await refreshAuthSessionIfNeeded(authAdapter);
168
+ if (mountController.signal.aborted) return;
169
+ setIsAuthRuntimeReady(true);
170
+ setAuthSessionVersion((value) => value + 1);
171
+ })();
172
+
173
+ return () => {
174
+ mountController.abort();
175
+ };
176
+ }, []);
177
+
178
+ useEffect(() => {
179
+ return subscribeToAuthSessionChanges(() => {
180
+ setAuthSessionVersion((value) => value + 1);
181
+ });
182
+ }, []);
183
+
184
+ useEffect(() => {
185
+ if (!isInnerContentReady || rootNavigationKey.length === 0 || !isAuthRuntimeReady) return;
186
+
187
+ const authEnforced = !__DEV__ || !AUTH_DISABLE_IN_DEV;
188
+ if (!authEnforced) return;
189
+
190
+ const authenticated = isAuthenticated();
191
+ const activeTopLevelRoute = getTopLevelRoute(pathname);
192
+ const isPublicRoute = AUTH_PUBLIC_ROUTES.includes(activeTopLevelRoute);
193
+ const currentPath = normalizeRoutePath(pathname);
194
+ const signInPath = normalizeRoutePath(AUTH_SIGN_IN_ROUTE_PATH);
195
+ const postSignInPath = normalizeRoutePath(AUTH_POST_SIGN_IN_ROUTE_PATH);
196
+
197
+ if (!authenticated && !isPublicRoute) {
198
+ if (currentPath !== signInPath) {
199
+ router.replace(AUTH_SIGN_IN_ROUTE_TARGET);
200
+ }
201
+ return;
202
+ }
203
+
204
+ if (authenticated && currentPath === '/' && postSignInPath !== '/') {
205
+ router.replace(AUTH_POST_SIGN_IN_ROUTE_TARGET);
206
+ return;
207
+ }
208
+
209
+ if (
210
+ authenticated &&
211
+ (activeTopLevelRoute === AUTH_SIGN_IN_ROUTE_SEGMENT ||
212
+ activeTopLevelRoute === AUTH_SIGN_UP_ROUTE_SEGMENT)
213
+ ) {
214
+ if (currentPath !== postSignInPath) {
215
+ router.replace(AUTH_POST_SIGN_IN_ROUTE_TARGET);
216
+ }
217
+ }
218
+ }, [
219
+ router,
220
+ isInnerContentReady,
221
+ rootNavigationKey,
222
+ pathname,
223
+ authSessionVersion,
224
+ isAuthRuntimeReady,
225
+ ]);
226
+ `
227
+ : '';
228
+ const rootHookBlock = [allHooks, authRuntimeHook.trim()].filter(Boolean).join('\n\n');
229
+ const indentedRootHookBlock = rootHookBlock.length > 0 ? indentGeneratedBlock(rootHookBlock) : '';
230
+ const innerContentNode = authRuntime
231
+ ? '<InnerContent onReady={handleInnerContentReady} />'
232
+ : '<InnerContent />';
233
+ const innerContentSignature = authRuntime ? '{ onReady }: { onReady?: () => void }' : '';
234
+ const innerContentReadyHook = authRuntime
235
+ ? `
236
+ useEffect(() => {
237
+ onReady?.();
238
+ }, [onReady]);`
239
+ : '';
240
+ const rootLayoutTypeImports = includeStudio ? "import type { ReactNode } from 'react';" : '';
241
+ const runtimeOperationHelpers = `
242
+ async function runtimeDataSourceFetch(
243
+ url: string,
244
+ init: {
245
+ readonly method: string;
246
+ readonly headers: Readonly<Record<string, string>>;
247
+ readonly body?: string;
248
+ },
249
+ ) {
250
+ const response = await fetch(url, {
251
+ method: init.method,
252
+ headers: init.headers,
253
+ body: init.body,
254
+ });
255
+
256
+ return {
257
+ status: response.status,
258
+ headers: Object.fromEntries(response.headers.entries()),
259
+ text: () => response.text(),
260
+ };
261
+ }
262
+ ${useStoredAuthSessionCredentialResolver
263
+ ? `
264
+ function resolveRuntimeOperationCredential(credential: { readonly kind?: string } | undefined) {
265
+ if (credential?.kind !== 'bearer' && credential?.kind !== 'oauth2') {
266
+ return undefined;
267
+ }
268
+
269
+ const session = getStoredAuthSession();
270
+ if (!session?.accessToken) {
271
+ return undefined;
272
+ }
273
+
274
+ return {
275
+ headers: {
276
+ Authorization: \`Bearer \${session.accessToken}\`,
277
+ },
278
+ };
279
+ }
280
+ `
281
+ : ''}
282
+ `;
283
+ const runtimeContentDeclaration = `const { executeAction } = useRuntimeAction();
284
+
285
+ const generatedRuntimeConfig = useMemo(
286
+ () => ({
287
+ executeAction,
288
+ registry: runtimeComponentRegistry,
289
+ executeOperation,
290
+ }),
291
+ [executeAction, executeOperation],
292
+ );
293
+
294
+ const runtimeContent = (
295
+ <RuntimeRendererConfigProvider value={generatedRuntimeConfig}>
296
+ {appContent}
297
+ </RuntimeRendererConfigProvider>
298
+ );`;
299
+ const outputDeclaration = includeStudio
300
+ ? `${runtimeContentDeclaration}
301
+ const output = __DEV__ ? (
302
+ <AnkhStudio
303
+ runtimeRegistry={runtimeComponentRegistry}
304
+ runtimeConfig={generatedRuntimeConfig}
305
+ >
306
+ {runtimeContent}
307
+ </AnkhStudio>
308
+ ) : (
309
+ runtimeContent
310
+ );`
311
+ : `${runtimeContentDeclaration}
312
+ const output = runtimeContent;`;
313
+ const moduleLevelDeclarations = [
314
+ runtimeModuleDeclarations?.trim(),
315
+ runtimeOperationHelpers.trim(),
316
+ authRuntimeConstants.trim(),
317
+ includeStudio ? appHeaderHelpers.trim() : '',
318
+ innerNavigation.declarations.trim(),
319
+ ]
320
+ .filter(Boolean)
321
+ .join('\n\n');
322
+ const studioRuntimeLines = includeStudio
323
+ ? `const appPathname = ${authRuntime ? 'pathname' : 'usePathname()'};
324
+ const shouldMountAppHeader = ${authRuntime ? 'shouldMountAuthenticatedAppHeader(appPathname, isAuthRuntimeReady)' : 'true'};`
325
+ : '';
326
+ const indentedStudioRuntimeLines = studioRuntimeLines.length > 0 ? `\n${indentGeneratedBlock(studioRuntimeLines)}\n` : '\n';
327
+ const handleInnerContentReadyDeclaration = authRuntime
328
+ ? `const handleInnerContentReady = useCallback(() => {
329
+ setIsInnerContentReady(true);
330
+ }, []);`
331
+ : '';
332
+ const indentedHandleInnerContentReadyDeclaration = handleInnerContentReadyDeclaration.length > 0
333
+ ? `${indentGeneratedBlock(handleInnerContentReadyDeclaration)}
334
+
335
+ `
336
+ : '';
337
+ const studioShellBlock = includeStudio
338
+ ? `if (__DEV__) {
339
+ return (
340
+ <GestureHandlerRootView style={{ flex: 1 }}>
341
+ <StudioProvider projectId={ankhConfig.metadata.slug}>
342
+ <StudioShell
343
+ output={output}
344
+ activeTheme={activeTheme}
345
+ activeThemeMode={activeThemeMode}
346
+ runtimeManifest={runtimeManifest}
347
+ appPathname={appPathname}
348
+ shouldMountAppHeader={shouldMountAppHeader}
349
+ />
350
+ </StudioProvider>
351
+ </GestureHandlerRootView>
352
+ );
353
+ }`
354
+ : '';
355
+ const indentedStudioShellBlock = studioShellBlock.length > 0 ? `\n${indentGeneratedBlock(studioShellBlock)}\n` : '\n';
356
+ const indentedInnerNavigationJsx = indentGeneratedBlock(innerNavigation.jsx, ' ');
357
+ return `
358
+ ${rootLayoutTypeImports ? `${rootLayoutTypeImports}\n` : ''}${allImports}
359
+
360
+ const fallbackManifest = ankhConfig as unknown as AppManifest;
361
+ const runtimeComponentRegistry = {
362
+ ...ZORA_COMPONENT_REGISTRY,
363
+ ...APP_EXTENSION_COMPONENT_REGISTRY,
364
+ };
365
+
366
+ ${moduleLevelDeclarations}
367
+
368
+ function resolveZoraProviderTheme(theme: AppManifest['themes'][number]) {
369
+ return {
370
+ id: theme.id,
371
+ name: theme.name,
372
+ appCategory: 'developer_tools' as const,
373
+ primaryColor: theme.light.primaryColor,
374
+ harmony: theme.light.harmony,
375
+ };
376
+ }
377
+
378
+ function resolveThemeMode(
379
+ mode: AppManifest['activeThemeMode'],
380
+ fallback: NonNullable<AppManifest['activeThemeMode']>,
381
+ ): NonNullable<AppManifest['activeThemeMode']> {
382
+ if (mode === 'dark' || mode === 'light') {
383
+ return mode;
384
+ }
385
+
386
+ return fallback;
387
+ }
388
+
389
+ export const unstable_settings = {
390
+ initialRouteName: '${initialRouteNameOverride ?? manifest.navigator.initialRouteName ?? 'index'}',
391
+ };
392
+
393
+ export default function RootLayout() {
394
+ ${indentedRootHookBlock}
395
+
396
+ const manifestContext = useOptionalManifestContext();
397
+ const runtimeManifest = manifestContext?.manifest ?? fallbackManifest;${indentedStudioRuntimeLines}
398
+ const activeTheme =
399
+ runtimeManifest.themes.find((theme) => theme.id === runtimeManifest.activeThemeId) ??
400
+ runtimeManifest.themes[0];
401
+ if (!activeTheme) {
402
+ return null;
403
+ }
404
+
405
+ const activeThemeMode = resolveThemeMode(runtimeManifest.activeThemeMode, 'light');
406
+ const zoraTheme = resolveZoraProviderTheme(activeTheme);
407
+ const executeOperation = useMemo(
408
+ () =>
409
+ createRuntimeDataSourceOperationExecutor({
410
+ fetch: runtimeDataSourceFetch,
411
+ ${useStoredAuthSessionCredentialResolver
412
+ ? 'credentialResolver: resolveRuntimeOperationCredential,'
413
+ : ''}
414
+ }),
415
+ [],
416
+ );
417
+ ${indentedHandleInnerContentReadyDeclaration} const appContent = ${innerContentNode};
418
+
419
+ ${outputDeclaration}
420
+
421
+ const shell = (
422
+ <ZoraProvider theme={zoraTheme} initialMode={activeThemeMode}>
423
+ <SafeAreaProvider>
424
+ <AppShell>
425
+ ${finalJsx}
426
+ </AppShell>
427
+ <StatusBar style={activeThemeMode === 'dark' ? 'light' : 'dark'} />
428
+ </SafeAreaProvider>
429
+ </ZoraProvider>
430
+ );
431
+ ${indentedStudioShellBlock} return <GestureHandlerRootView style={{ flex: 1 }}>{shell}</GestureHandlerRootView>;
432
+ }${includeStudio
433
+ ? `
434
+ function StudioShell({
435
+ output,
436
+ activeTheme,
437
+ activeThemeMode,
438
+ runtimeManifest,
439
+ appPathname,
440
+ shouldMountAppHeader,
441
+ }: {
442
+ output: ReactNode;
443
+ activeTheme: AppManifest['themes'][number];
444
+ activeThemeMode: NonNullable<AppManifest['activeThemeMode']>;
445
+ runtimeManifest: AppManifest;
446
+ appPathname: string;
447
+ shouldMountAppHeader: boolean;
448
+ }) {
449
+ const { activeScreenId, manifest: studioManifest, previewMode } = useStudio();
450
+ const appHeaderTitle = resolveStudioAppHeaderTitle({
451
+ runtimeManifest,
452
+ studioManifest,
453
+ previewMode,
454
+ activeScreenId,
455
+ pathname: appPathname,
456
+ });
457
+ const header = shouldMountAppHeader ? (
458
+ <StudioAppHeader appHeaderTitle={appHeaderTitle} />
459
+ ) : undefined;
460
+ const studioRuntimeManifest = studioManifest ?? runtimeManifest;
461
+ const activeStudioTheme =
462
+ studioRuntimeManifest.themes.find(
463
+ (theme) => theme.id === studioRuntimeManifest.activeThemeId,
464
+ ) ?? activeTheme;
465
+ const activeStudioThemeMode = resolveThemeMode(
466
+ studioRuntimeManifest.activeThemeMode,
467
+ activeThemeMode,
468
+ );
469
+ const studioZoraTheme = resolveZoraProviderTheme(activeStudioTheme);
470
+
471
+ return (
472
+ <ZoraProvider theme={studioZoraTheme} initialMode={activeStudioThemeMode}>
473
+ <SafeAreaProvider>
474
+ <AppShell header={header}>
475
+ ${finalJsx}
476
+ </AppShell>
477
+ <StatusBar style={activeStudioThemeMode === 'dark' ? 'light' : 'dark'} />
478
+ </SafeAreaProvider>
479
+ </ZoraProvider>
480
+ );
481
+ }
482
+
483
+ function StudioAppHeader({ appHeaderTitle }: { appHeaderTitle: string }) {
484
+ const studioAppBar = useStudioAppBarAugmentation();
485
+
486
+ return (
487
+ <>
488
+ <AppBar
489
+ title={appHeaderTitle}
490
+ appMode={studioAppBar.appMode}
491
+ actions={studioAppBar.actions}
492
+ overflow={studioAppBar.overflow}
493
+ />
494
+ {studioAppBar.overlay}
495
+ </>
496
+ );
497
+ }`
498
+ : ''}
499
+
500
+ function InnerContent(${innerContentSignature}) {${innerContentReadyHook}
501
+ ${innerThemeHook} return (
502
+ ${indentedInnerNavigationJsx}
503
+ );
504
+ }
505
+ `.trimStart();
506
+ }
507
+ //# sourceMappingURL=rootLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootLayout.js","sourceRoot":"","sources":["../../../../src/host/layout/templates/rootLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA0BzE,SAAS,2BAA2B,CAAC,MAAyB;IAC5D,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACpF,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAe,EAAE,MAAM,GAAG,IAAI;IAC1D,OAAO,OAAO;SACX,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC5D,IAAI,CAA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AoB,CAAC,kCAAkC,CAAC;;CAElE;QACK,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,gBAAgB,GAAG,aAAa;QACpC,CAAC,CAAC;;;;;;;;;;;;;;;EAeJ;QACE,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,wBAAwB,GAC5B,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,oBAAoB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACvF,MAAM,0BAA0B,GAAG,oBAAoB,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAErF,OAAO;EACP,qBAAqB,CAAC,CAAC,CAAC,GAAG,qBAAqB,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU;;;;;;;;EAQtE,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;uBAwBF,wBAAwB,IAAI,QAAQ,CAAC,SAAS,CAAC,gBAAgB,IAAI,OAAO;;;;EAI/F,qBAAqB;;;0EAGmD,0BAA0B;;;;;;;;;;;;;;UAe1F,sCAAsC;QACpC,CAAC,CAAC,wDAAwD;QAC1D,CAAC,CAAC,EACN;;;;EAIN,0CAA0C,wBAAwB,gBAAgB;;IAEhF,iBAAiB;;;;;;YAMT,QAAQ;;;;;;EAMlB,wBAAwB;GAEtB,aAAa;QACX,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA0CI,QAAQ;;;;;;;;;;;;;;;;;;;;;;EAsBlB;QACI,CAAC,CAAC,EACN;;wBAEsB,qBAAqB,MAAM,qBAAqB;EACtE,cAAc;EACd,0BAA0B;;;CAG3B,CAAC,SAAS,EAAE,CAAC;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ScreenSpec } from '@ankhorage/contracts';
2
+ export declare function getScreenTsx(args: {
3
+ screenId: string;
4
+ screenDef: ScreenSpec;
5
+ }): string;
6
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../../../src/host/layout/templates/screen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKvD,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,UA2F7E"}
@@ -0,0 +1,94 @@
1
+ import { escapeStringLiteral } from '../utils/escapeStringLiteral';
2
+ import { toSafeComponentName } from './utils/strings';
3
+ export function getScreenTsx(args) {
4
+ const { screenId, screenDef } = args;
5
+ const safeName = toSafeComponentName(screenDef.name);
6
+ return `import type { AppManifest } from '@ankhorage/contracts';
7
+ import {
8
+ ManifestProvider,
9
+ RuntimeRendererConfigProvider,
10
+ RuntimeScreen,
11
+ useOptionalManifestContext,
12
+ useRuntimeRendererConfig,
13
+ } from '@ankhorage/runtime';
14
+ import { Text, useZoraTheme } from '@ankhorage/zora';
15
+ import ankhConfig from '@root/ankh.config.json';
16
+ import { useGlobalSearchParams, useLocalSearchParams } from 'expo-router';
17
+ import { useMemo } from 'react';
18
+ import { ScrollView, View } from 'react-native';
19
+
20
+ const fallbackManifest = ankhConfig as unknown as AppManifest;
21
+ type SearchParams = Record<string, string | string[] | undefined> & {
22
+ screenId?: string | string[];
23
+ };
24
+
25
+ function resolveScreenIdParam(value: string | string[] | undefined): string | undefined {
26
+ if (typeof value === 'string') {
27
+ return value;
28
+ }
29
+
30
+ if (Array.isArray(value)) {
31
+ return value[0];
32
+ }
33
+
34
+ return undefined;
35
+ }
36
+
37
+ export default function ${safeName}Screen() {
38
+ const { theme } = useZoraTheme();
39
+ const manifestContext = useOptionalManifestContext();
40
+ const runtimeManifest = manifestContext?.manifest ?? fallbackManifest;
41
+ const runtimeConfig = useRuntimeRendererConfig();
42
+ const local = useLocalSearchParams<SearchParams>();
43
+ const global = useGlobalSearchParams<SearchParams>();
44
+ const routeParams = useMemo(() => ({ ...global, ...local }), [global, local]);
45
+
46
+ const currentScreenId =
47
+ resolveScreenIdParam(local.screenId) ??
48
+ resolveScreenIdParam(global.screenId) ??
49
+ '${escapeStringLiteral(screenId)}';
50
+ const screenConfig = runtimeManifest.screens[currentScreenId];
51
+ const runtimeRendererConfig = useMemo(
52
+ () => ({
53
+ ...runtimeConfig,
54
+ bindingContext: {
55
+ ...(runtimeConfig.bindingContext ?? {}),
56
+ route: {
57
+ params: routeParams,
58
+ },
59
+ },
60
+ }),
61
+ [routeParams, runtimeConfig],
62
+ );
63
+
64
+ if (!screenConfig) {
65
+ return (
66
+ <View style={{ flex: 1, backgroundColor: theme.colors.background }}>
67
+ <View style={{ marginTop: 20, paddingHorizontal: 20 }}>
68
+ <Text align="center" color="danger" variant="bodySmall">
69
+ Screen configuration not found for ID: {currentScreenId}
70
+ </Text>
71
+ </View>
72
+ </View>
73
+ );
74
+ }
75
+
76
+ return (
77
+ <View style={{ flex: 1, backgroundColor: theme.colors.background }}>
78
+ <ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }}>
79
+ <ManifestProvider manifest={runtimeManifest}>
80
+ <RuntimeRendererConfigProvider value={runtimeRendererConfig}>
81
+ <RuntimeScreen
82
+ manifest={runtimeManifest}
83
+ screen={screenConfig}
84
+ stateAdapter={runtimeConfig.stateAdapter}
85
+ />
86
+ </RuntimeRendererConfigProvider>
87
+ </ManifestProvider>
88
+ </ScrollView>
89
+ </View>
90
+ );
91
+ }
92
+ `;
93
+ }
94
+ //# sourceMappingURL=screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.js","sourceRoot":"","sources":["../../../../src/host/layout/templates/screen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,UAAU,YAAY,CAAC,IAAiD;IAC5E,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA+BiB,QAAQ;;;;;;;;;;;;OAY3B,mBAAmB,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CnC,CAAC;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function routeNameToHref(routeName: string): string;
2
+ export declare function routeNameToGroupedHref(routeName: string, groupName: string): string;
3
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../../src/host/layout/templates/utils/routes.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOzD;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAOnF"}
@@ -0,0 +1,15 @@
1
+ export function routeNameToHref(routeName) {
2
+ const normalized = routeName.trim().replace(/^\/+/, '').replace(/\/+$/, '');
3
+ if (!normalized || normalized === 'index') {
4
+ return '/';
5
+ }
6
+ return `/${normalized}`;
7
+ }
8
+ export function routeNameToGroupedHref(routeName, groupName) {
9
+ const normalized = routeName.trim().replace(/^\/+/, '').replace(/\/+$/, '');
10
+ if (!normalized || normalized === 'index') {
11
+ return groupName === 'app' ? '/' : `/(${groupName})`;
12
+ }
13
+ return `/${normalized}`;
14
+ }
15
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../../src/host/layout/templates/utils/routes.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC1C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,IAAI,UAAU,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,SAAiB,EAAE,SAAiB;IACzE,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC1C,OAAO,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,GAAG,CAAC;IACvD,CAAC;IAED,OAAO,IAAI,UAAU,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function joinNonEmptyLines(lines: string[]): string;
2
+ export declare function toSafeComponentName(value: string): string;
3
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../../../../src/host/layout/templates/utils/strings.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEzD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,7 @@
1
+ export function joinNonEmptyLines(lines) {
2
+ return lines.filter((line) => line.length > 0).join('\n');
3
+ }
4
+ export function toSafeComponentName(value) {
5
+ return value.replace(/[^a-zA-Z0-9]/g, '');
6
+ }
7
+ //# sourceMappingURL=strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../../../src/host/layout/templates/utils/strings.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function escapeStringLiteral(value: string): string;
2
+ //# sourceMappingURL=escapeStringLiteral.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escapeStringLiteral.d.ts","sourceRoot":"","sources":["../../../../src/host/layout/utils/escapeStringLiteral.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMzD"}