waypoint-expo-template 2.0.0 → 2.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.
- package/README.md +14 -0
- package/app.config.js +10 -0
- package/package.json +1 -1
- package/platform/base-url.js +53 -0
package/README.md
CHANGED
|
@@ -10,8 +10,22 @@ Waypoint device-preview tile.
|
|
|
10
10
|
src/app/_layout.tsx plain Stack, headers off
|
|
11
11
|
src/app/index.tsx the entry screen — `/` by expo-router convention
|
|
12
12
|
src/navigation.ts which control leads where (links only)
|
|
13
|
+
|
|
14
|
+
platform/ platform-owned — do not edit
|
|
15
|
+
app.config.js two lines; delegates to platform/
|
|
13
16
|
```
|
|
14
17
|
|
|
18
|
+
`platform/` holds the files the platform maintains, not you. Today that is the
|
|
19
|
+
base URL: the preview is embedded in the control plane under
|
|
20
|
+
`/api/v1/preview/<appId>/`, and expo-router matches routes against the
|
|
21
|
+
browser's pathname, so it has to be told that prefix or every screen renders
|
|
22
|
+
"Unmatched Route". It comes from `EXPO_BASE_URL`, set when the platform starts
|
|
23
|
+
Metro — unset (running the app yourself) the base is empty and it serves at the
|
|
24
|
+
root, as normal.
|
|
25
|
+
|
|
26
|
+
`app.config.js` has to sit at the root because Expo resolves its dynamic config
|
|
27
|
+
from `<projectRoot>/app.config` and nowhere else. It contains no logic.
|
|
28
|
+
|
|
15
29
|
## What is deliberately NOT here
|
|
16
30
|
|
|
17
31
|
No preview manifests, no compile step, no canvas protocol module, and no
|
package/app.config.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Expo resolves its dynamic config from `<projectRoot>/app.config` and nowhere
|
|
2
|
+
// else — @expo/config's getDynamicConfigFilePath does
|
|
3
|
+
// `resolveFrom(projectRoot, './app.config')`. So this file cannot live in
|
|
4
|
+
// platform/; it stays here as the entry point Expo requires, and holds no
|
|
5
|
+
// logic of its own.
|
|
6
|
+
//
|
|
7
|
+
// Everything the platform maintains is in platform/. Do not edit either.
|
|
8
|
+
const { withPlatformBaseUrl } = require('./platform/base-url');
|
|
9
|
+
|
|
10
|
+
module.exports = ({ config }) => withPlatformBaseUrl(config);
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subpath this app is served under, when the platform is serving it.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS
|
|
5
|
+
*
|
|
6
|
+
* The preview is embedded in the control plane as a SAME-ORIGIN iframe
|
|
7
|
+
* (ADR-033), served under `/api/v1/preview/<appId>/`. Same-origin is not
|
|
8
|
+
* incidental: the canvas reads this app's DOM directly to measure controls,
|
|
9
|
+
* observe presses and detect readiness (ADR-039), and all three throw across
|
|
10
|
+
* origins. So the app cannot be given its own origin to escape the prefix —
|
|
11
|
+
* it has to be told the prefix instead.
|
|
12
|
+
*
|
|
13
|
+
* expo-router resolves routes against `window.location.pathname`. Without a
|
|
14
|
+
* base it compares that whole prefixed path against the route files and
|
|
15
|
+
* matches nothing, so EVERY screen — the entry one included — renders
|
|
16
|
+
* "Unmatched Route". Verified live before this existed.
|
|
17
|
+
*
|
|
18
|
+
* ON `experiments`
|
|
19
|
+
*
|
|
20
|
+
* `experiments.baseUrl` is Expo's only mechanism for subpath hosting, and it
|
|
21
|
+
* is typed and documented in @expo/config-types ("Export a website relative
|
|
22
|
+
* to a subpath of a domain"). This project already depends on that namespace
|
|
23
|
+
* — `typedRoutes` in app.json — which in Expo is a grab-bag of build-pipeline
|
|
24
|
+
* flags rather than a staging area.
|
|
25
|
+
*
|
|
26
|
+
* The exposure is a rename on an SDK upgrade. The symptom is unmistakable
|
|
27
|
+
* (every route renders "Unmatched Route") and the fix is this one field;
|
|
28
|
+
* check @expo/config-types' ExpoConfig for where it moved.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Empty unless the platform set it. An app run directly (`npm run web`) has
|
|
33
|
+
* no prefix and serves at the origin root, which is what an empty base means.
|
|
34
|
+
* The variable is set by the harness when it starts Metro, from the pod's own
|
|
35
|
+
* app id — never written into the workspace, because the base URL is a
|
|
36
|
+
* deployment fact the platform owns and app.json belongs to you.
|
|
37
|
+
*/
|
|
38
|
+
function resolveBaseUrl() {
|
|
39
|
+
return process.env.EXPO_BASE_URL || '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Applies the base to an Expo config, leaving everything else untouched. */
|
|
43
|
+
function withPlatformBaseUrl(config) {
|
|
44
|
+
return {
|
|
45
|
+
...config,
|
|
46
|
+
experiments: {
|
|
47
|
+
...config.experiments,
|
|
48
|
+
baseUrl: resolveBaseUrl(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = { resolveBaseUrl, withPlatformBaseUrl };
|