Changeset 0.37.19 (#232)
Co-authored-by: gobha <jasafpro@gmail.com> Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
@@ -81,7 +81,7 @@ mounts into the `#extension-mount` container:
|
||||
if (!mount) return;
|
||||
|
||||
var manifest = window.__MANIFEST__ || {};
|
||||
var user = window.__USER__ || {};
|
||||
var user = window.sw?.auth?.user || {};
|
||||
|
||||
mount.innerHTML = '<h1>Hello, ' + esc(user.display_name || user.username) + '!</h1>';
|
||||
|
||||
@@ -115,7 +115,7 @@ available when your script executes:
|
||||
| Global | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `window.__MANIFEST__` | Object | Your surface's manifest with route, layout, etc. Keys are **lowercase** (JSON serialization from Go). Access as `manifest.id`, `manifest.route`, `manifest.title`. |
|
||||
| `window.__USER__` | Object | Authenticated user: `{ username, display_name, role, id, email }`. |
|
||||
| `window.sw.auth.user` | Object | Authenticated user (via SDK): `{ username, display_name, role, id, email }`. Requires SDK boot. |
|
||||
| `window.__BASE__` | String | URL base path (e.g. `"/dev"` or `""`). Prepend to all internal links. |
|
||||
| `window.__VERSION__` | String | Platform version string. |
|
||||
| `window.__SURFACE__` | String | Your surface ID. |
|
||||
@@ -280,7 +280,7 @@ When your surface loads, the page DOM looks like this:
|
||||
</div>
|
||||
</div>
|
||||
<script>window.__MANIFEST__ = {...};</script>
|
||||
<script>window.__USER__ = {...};</script>
|
||||
<!-- User available via sw.auth.user after SDK boot -->
|
||||
<script src="/js/api.js"></script>
|
||||
<script src="/js/ui-core.js"></script>
|
||||
... platform scripts ...
|
||||
@@ -447,7 +447,7 @@ working example that demonstrates:
|
||||
|
||||
- Manifest structure
|
||||
- Mounting into `#extension-mount`
|
||||
- Reading `__MANIFEST__` and `__USER__`
|
||||
- Reading `__MANIFEST__` and `sw.auth.user`
|
||||
- Using `UI.toast()` for notifications
|
||||
- Using `API._get()` for authenticated requests
|
||||
- Using CSS custom properties for theming
|
||||
|
||||
Reference in New Issue
Block a user