@swiftbrowser/web 0.5.6 → 0.6.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 +39 -7
- package/app/index.html +25 -13
- package/node/dist/node/config.d.ts +24 -3
- package/node/dist/node/config.d.ts.map +1 -1
- package/node/dist/node/config.js +41 -10
- package/node/dist/node/config.js.map +1 -1
- package/node/dist/node/index.d.ts +9 -4
- package/node/dist/node/index.d.ts.map +1 -1
- package/node/dist/node/index.js +14 -5
- package/node/dist/node/index.js.map +1 -1
- package/node/dist/plugins/app-manifests.d.ts +12 -4
- package/node/dist/plugins/app-manifests.d.ts.map +1 -1
- package/node/dist/plugins/app-manifests.js +14 -9
- package/node/dist/plugins/app-manifests.js.map +1 -1
- package/node/dist/plugins/site-layout.d.ts +41 -0
- package/node/dist/plugins/site-layout.d.ts.map +1 -0
- package/node/dist/plugins/site-layout.js +77 -0
- package/node/dist/plugins/site-layout.js.map +1 -0
- package/package.json +1 -1
- package/plugins/app-manifests.ts +28 -9
- package/plugins/site-layout.ts +96 -0
- package/src/animation.ts +86 -3
- package/src/deviceMode.ts +9 -2
- package/src/gaugeRing.ts +2 -2
- package/src/layout/engine.ts +228 -51
- package/src/layout/index.ts +1 -1
- package/src/layoutDom.ts +96 -12
- package/src/main.ts +6 -4
- package/src/press.ts +130 -0
- package/src/protocol.ts +26 -0
- package/src/renderer.ts +57 -14
- package/src/styles.css +184 -29
- package/src/styles.ts +3 -0
- package/src/symbols.ts +3 -1
- package/src/vite-env.d.ts +18 -0
package/README.md
CHANGED
|
@@ -9,13 +9,14 @@ size back to the Swift/Wasm app, and drives the app's cooperative executor
|
|
|
9
9
|
(Phase 4) so `Task`, `.task` and sleeps reach the screen.
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
index.html Landing page (served at /): one card per registered app with an Open link and a QR code
|
|
13
|
-
app/index.html The app page (served at /app/): toolbar, iPhone frame, #screen
|
|
12
|
+
index.html Landing page (served at / of a multi-app site): one card per registered app with an Open link and a QR code
|
|
13
|
+
app/index.html The app page (served at /app/, and at / of a single-app site): toolbar, iPhone frame, #screen
|
|
14
14
|
src/landing.ts Landing page script: app cards (qrcode SVGs), build info from the `define`s
|
|
15
15
|
src/landing.css Landing page styles
|
|
16
|
+
plugins/site-layout.ts The site's layout (one app at /, or a landing page over several) and window.__SB_SITE__ for the app page
|
|
16
17
|
src/deviceMode.ts Frame vs device mode decision, env(safe-area-inset-*) reader, viewport watcher
|
|
17
18
|
src/chromeColor.ts Device mode: the browser's status bar strip and safe areas take the app's top-edge color
|
|
18
|
-
src/vite-env.d.ts Types of the build-time defines (__SB_APPS__, __SB_COMMIT__, …)
|
|
19
|
+
src/vite-env.d.ts Types of the build-time defines (__SB_APPS__, __SB_DEFAULT_APP__, __SB_PAGE_MODE__, __SB_COMMIT__, …)
|
|
19
20
|
src/protocol.ts TypeScript mirror of the ops protocol (Op, element kinds, Style, Color, Animation, events)
|
|
20
21
|
src/renderer.ts Renderer: Map<id, HTMLElement> + LayoutNode tree, ops, navigation, sheets, layout on commit
|
|
21
22
|
src/layout/ The layout engine (propose/report/place, text wrapping, Dynamic Type table); unit-tested with vitest
|
|
@@ -34,6 +35,7 @@ src/bitmapWorker.ts The store in a worker, answering drawings with ImageBitmaps
|
|
|
34
35
|
src/imageOps.ts Core Image's steps (sepia, crystallize, edges, blur, pixellate, unsharp mask, vignette, crop) on rasters; no DOM
|
|
35
36
|
src/hostContent.ts `host` elements: the registry of the page's own DOM elements the renderer adopts (docs/ops-protocol.md, "Host elements")
|
|
36
37
|
src/pointerEffects.ts Hover events, tooltips, cursors and symbol effects for page-side producers; frame reports' safe-area overlap (docs/ops-protocol.md, "Pointer, effects, matched geometry and frames on screen")
|
|
38
|
+
src/press.ts iOS 26 press feedback: the Liquid Glass under a pressed bar button or glass button swells and springs back
|
|
37
39
|
src/styles.css iOS tokens, device frame, device mode, element styles, host boxes and islands
|
|
38
40
|
src/page.css The app page around the frame: its toolbar, stage, error banner, device-mode chrome
|
|
39
41
|
node/ Node side: apps.ts (the AppSpec registry type), config.ts (Vite config from specs),
|
|
@@ -58,6 +60,7 @@ npm run dev # http://localhost:5173/ landing page (list
|
|
|
58
60
|
# http://localhost:5173/app/?app=Todos loads /Todos.wasm
|
|
59
61
|
# http://localhost:5173/app/?mock=1 hardcoded Counter fixture, no wasm needed
|
|
60
62
|
npm run build # typechecks src/, writes dist/ (dist/index.html + dist/app/index.html) and node/dist/
|
|
63
|
+
# (the examples are a multi-app site; a site with one app is built as the app at /, see "Site layouts")
|
|
61
64
|
npm run build:node # only node/dist/ (the programmatic API other packages import)
|
|
62
65
|
npm run preview # serves dist/
|
|
63
66
|
npm run typecheck # src/, e2e/, node/, plugins/ and the config files
|
|
@@ -119,7 +122,9 @@ Both resolve the Vite root (`Web/`) relative to the module and ignore
|
|
|
119
122
|
## Pages and URLs
|
|
120
123
|
|
|
121
124
|
The site is a Vite multi-page app (`build.rollupOptions.input` in
|
|
122
|
-
`
|
|
125
|
+
`node/config.ts`, `appType: 'mpa'`). The examples are a multi-app site, the
|
|
126
|
+
`landing` layout; a site with one app (what `swiftbrowser dev` and `build`
|
|
127
|
+
make) is the `app` layout, see "Site layouts" below.
|
|
123
128
|
|
|
124
129
|
- `/` (`index.html` + `src/landing.ts`): "SwiftBrowser examples". The list of
|
|
125
130
|
apps comes from the app registry (`node/config.ts`, see "App registry"
|
|
@@ -138,7 +143,30 @@ The site is a Vite multi-page app (`build.rollupOptions.input` in
|
|
|
138
143
|
- `/app/` (`app/index.html` + `src/main.ts`): the renderer. `import.meta.env.BASE_URL`
|
|
139
144
|
stays `/`, so the modules are still fetched from `/<Name>.wasm` and the
|
|
140
145
|
dev-server plugin's rebuild registry (which watches those requests) works
|
|
141
|
-
unchanged.
|
|
146
|
+
unchanged. Without `?app=` it runs the site's default app
|
|
147
|
+
(`__SB_DEFAULT_APP__`; `Counter` for the examples, `vite.config.ts`).
|
|
148
|
+
|
|
149
|
+
### Site layouts
|
|
150
|
+
|
|
151
|
+
`node/config.ts` picks a layout from the registry (`siteLayout`,
|
|
152
|
+
`SiteOptions.layout` overrides it), and `plugins/site-layout.ts` applies it:
|
|
153
|
+
|
|
154
|
+
- `app`: one app and no included sites. The site is that app: the dev server
|
|
155
|
+
serves the app page at `/`, a build writes it as `index.html` and nothing at
|
|
156
|
+
`/app/` (the directory holds only the OAuth callback page), there is no
|
|
157
|
+
landing page, every manifest starts the app at `/` and the site's
|
|
158
|
+
`/manifest.webmanifest` is the app's own. `buildSite` builds such a site
|
|
159
|
+
with `pageMode: 'device'`: the app fills the window on every screen, so a
|
|
160
|
+
desktop browser shows the app's regular-width (iPad) layout, not a phone in
|
|
161
|
+
a bezel; `?mode=frame` still shows the frame. The dev server keeps
|
|
162
|
+
`pageMode: 'auto'`: the frame and its dark mode and text size controls on a
|
|
163
|
+
desktop, device mode on a phone.
|
|
164
|
+
- `landing`: several apps, or included sites. The landing page at `/` lists
|
|
165
|
+
them and each runs at `/app/?app=<Name>`, as the examples do.
|
|
166
|
+
|
|
167
|
+
Both layouts give the app page `window.__SB_SITE__` (`{ layout, defaultApp,
|
|
168
|
+
displayName, pageMode }`), which its inline scripts read before the first
|
|
169
|
+
paint, and `src/main.ts` the same values as `define`s.
|
|
142
170
|
|
|
143
171
|
The app page's query parameters:
|
|
144
172
|
|
|
@@ -259,7 +287,10 @@ serves `/manifests/<Name>.webmanifest` (`start_url: /app/?app=<Name>`,
|
|
|
259
287
|
in `vite build`, and an inline script in `app/index.html` points
|
|
260
288
|
`<link rel="manifest">` and `apple-mobile-web-app-title` at the app named by
|
|
261
289
|
`?app=`. `public/manifest.webmanifest` (`start_url: /app/`, the default app)
|
|
262
|
-
remains for the landing page and for `/app/` without a parameter.
|
|
290
|
+
remains for the landing page and for `/app/` without a parameter. In the
|
|
291
|
+
`app` layout the manifests start the app at `/`, the site's
|
|
292
|
+
`/manifest.webmanifest` is the app's, and the page is titled by the app's
|
|
293
|
+
display name alone.
|
|
263
294
|
|
|
264
295
|
## Deploying (Cloudflare Pages)
|
|
265
296
|
|
|
@@ -270,7 +301,8 @@ and deploys `Web/dist` with `wrangler pages deploy`. `public/_headers` tells
|
|
|
270
301
|
Pages to serve `/*.wasm` with `Content-Type: application/wasm` and
|
|
271
302
|
`Cache-Control: no-cache` (the modules are not content-hashed) and the hashed
|
|
272
303
|
`/assets/*` as immutable. Apps are opened as
|
|
273
|
-
`https://<site>/app/?app=<Name>`; the landing page lists and QR-codes them.
|
|
304
|
+
`https://<site>/app/?app=<Name>`; the landing page lists and QR-codes them. A
|
|
305
|
+
site built by the CLI from one app is that app at `https://<site>`.
|
|
274
306
|
|
|
275
307
|
## Getting `Counter.wasm` into `public/`
|
|
276
308
|
|
package/app/index.html
CHANGED
|
@@ -26,33 +26,45 @@
|
|
|
26
26
|
<link rel="stylesheet" href="/src/styles.css" />
|
|
27
27
|
<link rel="stylesheet" href="/src/page.css" />
|
|
28
28
|
<script>
|
|
29
|
+
// The site this page is in (plugins/site-layout.ts injects window.__SB_SITE__
|
|
30
|
+
// ahead of this script): its layout, the app the page runs without ?app=,
|
|
31
|
+
// and what a wide screen shows.
|
|
32
|
+
var site = window.__SB_SITE__ || {};
|
|
29
33
|
// Decide frame vs device mode before the first paint so a phone never
|
|
30
34
|
// flashes the fake bezel. src/deviceMode.ts holds the same rule and is
|
|
31
35
|
// what main.ts trusts; this only pre-sets the attribute the CSS keys on.
|
|
32
|
-
// A coarse pointer means device mode at any width (Phase 7)
|
|
36
|
+
// A coarse pointer means device mode at any width (Phase 7); a site built
|
|
37
|
+
// for a deployment (pageMode "device") fills every screen.
|
|
33
38
|
(function () {
|
|
34
39
|
var mode = new URLSearchParams(location.search).get('mode');
|
|
35
40
|
var coarse = typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
36
|
-
var device = mode === 'device' || (mode !== 'frame' && coarse);
|
|
41
|
+
var device = mode === 'device' || (mode !== 'frame' && (coarse || site.pageMode === 'device'));
|
|
37
42
|
document.documentElement.setAttribute('data-sb-mode', device ? 'device' : 'frame');
|
|
38
43
|
})();
|
|
39
|
-
// Point the manifest
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
// bring their own icon are listed in window.__SB_APP_ICONS__
|
|
43
|
-
// by plugins/app-manifests.ts); Safari reads the
|
|
44
|
-
// not the manifest, for the home-screen image.
|
|
44
|
+
// Point the manifest, the home-screen icon and the titles at the app
|
|
45
|
+
// this page runs (?app=, else the site's default), so Share -> Add to
|
|
46
|
+
// Home Screen makes an icon that launches it. Same name rule as main.ts.
|
|
47
|
+
// Apps that bring their own icon are listed in window.__SB_APP_ICONS__
|
|
48
|
+
// (injected by plugins/app-manifests.ts); Safari reads the
|
|
49
|
+
// apple-touch-icon link, not the manifest, for the home-screen image. A
|
|
50
|
+
// site that is its one app already links that app's manifest and is
|
|
51
|
+
// titled by the app's display name alone; on a multi-app site the page
|
|
52
|
+
// without ?app= keeps the site's generic manifest and title.
|
|
45
53
|
(function () {
|
|
46
|
-
var
|
|
54
|
+
var requested = (new URLSearchParams(location.search).get('app') || '').replace(/[^A-Za-z0-9_-]/g, '');
|
|
55
|
+
var app = requested || (site.layout === 'app' ? site.defaultApp : '') || '';
|
|
47
56
|
if (!app) return;
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
if (requested) {
|
|
58
|
+
var manifest = document.querySelector('link[rel="manifest"]');
|
|
59
|
+
if (manifest) manifest.setAttribute('href', '/manifests/' + app + '.webmanifest');
|
|
60
|
+
}
|
|
50
61
|
var icons = window.__SB_APP_ICONS__ || {};
|
|
51
62
|
var touchIcon = document.querySelector('link[rel="apple-touch-icon"]');
|
|
52
63
|
if (touchIcon && icons[app]) touchIcon.setAttribute('href', icons[app]);
|
|
64
|
+
var name = site.layout === 'app' && app === site.defaultApp ? site.displayName || app : app;
|
|
53
65
|
var title = document.querySelector('meta[name="apple-mobile-web-app-title"]');
|
|
54
|
-
if (title) title.setAttribute('content',
|
|
55
|
-
document.title = app + ' \u00b7 SwiftBrowser';
|
|
66
|
+
if (title) title.setAttribute('content', name);
|
|
67
|
+
document.title = site.layout === 'app' ? name : app + ' \u00b7 SwiftBrowser';
|
|
56
68
|
})();
|
|
57
69
|
</script>
|
|
58
70
|
</head>
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the Vite config for a set of apps: the registry plugins
|
|
3
|
-
* (plugins/swift-wasm.ts, asset-catalogs.ts, app-manifests.ts), the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* (plugins/swift-wasm.ts, asset-catalogs.ts, app-manifests.ts), the pages,
|
|
4
|
+
* the `define`s the pages read, and the apps of other built sites joining
|
|
5
|
+
* this one (plugins/included-sites.ts).
|
|
6
|
+
*
|
|
7
|
+
* A site with one app is that app (`layout: 'app'`, plugins/site-layout.ts):
|
|
8
|
+
* the app page is `/` and there is no landing page. With several apps, or
|
|
9
|
+
* included sites, the landing page at `/` lists them and each runs at
|
|
10
|
+
* `/app/?app=<name>` (`layout: 'landing'`).
|
|
6
11
|
*
|
|
7
12
|
* `vite.config.ts` calls this with the example apps; the programmatic API
|
|
8
13
|
* (./index.ts) with whatever the caller registered.
|
|
9
14
|
*/
|
|
10
15
|
import type { UserConfig } from 'vite';
|
|
16
|
+
import { type SiteLayout, type SitePageMode } from '../plugins/site-layout.js';
|
|
11
17
|
import { type AppSpec } from './apps.js';
|
|
12
18
|
export interface SiteOptions {
|
|
13
19
|
apps: AppSpec[];
|
|
@@ -21,7 +27,22 @@ export interface SiteOptions {
|
|
|
21
27
|
* copied into the build (plugins/included-sites.ts). Build only.
|
|
22
28
|
*/
|
|
23
29
|
sites?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* `app` (the site is its one app, at `/`) or `landing` (a landing page lists
|
|
32
|
+
* the apps). Default: `app` for one app and no included sites, else `landing`.
|
|
33
|
+
*/
|
|
34
|
+
layout?: SiteLayout;
|
|
35
|
+
/** The app the app page runs when the URL names none (`?app=`); default: the first registered app. */
|
|
36
|
+
defaultApp?: string;
|
|
37
|
+
/**
|
|
38
|
+
* What the app page shows on a wide screen: `auto` (the iPhone frame and the
|
|
39
|
+
* dev controls; device mode on a touch screen) or `device` everywhere.
|
|
40
|
+
* Default `auto`; `buildSite` builds an `app` layout site with `device`.
|
|
41
|
+
*/
|
|
42
|
+
pageMode?: SitePageMode;
|
|
24
43
|
}
|
|
44
|
+
/** The layout `options` resolve to (see `SiteOptions.layout`). */
|
|
45
|
+
export declare function siteLayout(options: Pick<SiteOptions, 'apps' | 'sites' | 'layout'>): SiteLayout;
|
|
25
46
|
/** One entry of `__SB_APPS__`, what the landing page renders a card from (see src/vite-env.d.ts). */
|
|
26
47
|
export interface LandingApp {
|
|
27
48
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,OAAO,EAAmD,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEhI,OAAO,EAAmC,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,sGAAsG;IACtG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG,UAAU,CAG9F;AAED,qGAAqG;AACrG,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oHAAoH;IACpH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yGAAyG;IACzG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAOD;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAoBhC;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,UAAU,EAAE,CAWnE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAuDjE"}
|
package/node/dist/node/config.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Builds the Vite config for a set of apps: the registry plugins
|
|
3
|
-
* (plugins/swift-wasm.ts, asset-catalogs.ts, app-manifests.ts), the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* (plugins/swift-wasm.ts, asset-catalogs.ts, app-manifests.ts), the pages,
|
|
4
|
+
* the `define`s the pages read, and the apps of other built sites joining
|
|
5
|
+
* this one (plugins/included-sites.ts).
|
|
6
|
+
*
|
|
7
|
+
* A site with one app is that app (`layout: 'app'`, plugins/site-layout.ts):
|
|
8
|
+
* the app page is `/` and there is no landing page. With several apps, or
|
|
9
|
+
* included sites, the landing page at `/` lists them and each runs at
|
|
10
|
+
* `/app/?app=<name>` (`layout: 'landing'`).
|
|
6
11
|
*
|
|
7
12
|
* `vite.config.ts` calls this with the example apps; the programmatic API
|
|
8
13
|
* (./index.ts) with whatever the caller registered.
|
|
@@ -14,8 +19,15 @@ import { appManifests } from '../plugins/app-manifests.js';
|
|
|
14
19
|
import { assetCatalogs } from '../plugins/asset-catalogs.js';
|
|
15
20
|
import { bundleResources } from '../plugins/bundle-resources.js';
|
|
16
21
|
import { includedSites, readSiteApps } from '../plugins/included-sites.js';
|
|
22
|
+
import { ROOT_START_URL, siteLayoutPlugin } from '../plugins/site-layout.js';
|
|
17
23
|
import { swiftWasm } from '../plugins/swift-wasm.js';
|
|
18
24
|
import { displayNameOf, validateAppSpecs } from './apps.js';
|
|
25
|
+
/** The layout `options` resolve to (see `SiteOptions.layout`). */
|
|
26
|
+
export function siteLayout(options) {
|
|
27
|
+
if (options.layout)
|
|
28
|
+
return options.layout;
|
|
29
|
+
return options.apps.length === 1 && !options.sites?.length ? 'app' : 'landing';
|
|
30
|
+
}
|
|
19
31
|
/** The package name that marks the Vite root. */
|
|
20
32
|
const PACKAGE_NAME = '@swiftbrowser/web';
|
|
21
33
|
let cachedRoot;
|
|
@@ -85,14 +97,36 @@ export function createViteConfig(options) {
|
|
|
85
97
|
throw new Error(`Duplicate app name ${JSON.stringify(app.name)} in the included sites`);
|
|
86
98
|
names.add(app.name);
|
|
87
99
|
}
|
|
100
|
+
const layout = siteLayout(options);
|
|
101
|
+
const defaultApp = options.defaultApp ?? apps[0]?.name;
|
|
102
|
+
if (defaultApp === undefined)
|
|
103
|
+
throw new Error('A site needs at least one app');
|
|
104
|
+
if (!apps.some((app) => app.name === defaultApp))
|
|
105
|
+
throw new Error(`Default app ${JSON.stringify(defaultApp)} is not a registered app`);
|
|
106
|
+
const main = apps.find((app) => app.name === defaultApp);
|
|
107
|
+
const site = { layout, defaultApp, displayName: displayNameOf(main), pageMode: options.pageMode ?? 'auto' };
|
|
108
|
+
// In the `app` layout every manifest starts the app at `/`.
|
|
109
|
+
const manifestOptions = layout === 'app' ? { startUrl: ROOT_START_URL } : {};
|
|
110
|
+
const pages = { app: path.resolve(root, 'app/index.html') };
|
|
111
|
+
if (layout === 'landing')
|
|
112
|
+
pages['landing'] = path.resolve(root, 'index.html');
|
|
88
113
|
return {
|
|
89
114
|
root,
|
|
90
|
-
plugins: [
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
plugins: [
|
|
116
|
+
swiftWasm(apps),
|
|
117
|
+
appManifests(apps, included, manifestOptions),
|
|
118
|
+
assetCatalogs(apps),
|
|
119
|
+
bundleResources(apps),
|
|
120
|
+
includedSites(landing, sites),
|
|
121
|
+
siteLayoutPlugin(site, main),
|
|
122
|
+
],
|
|
123
|
+
// The landing page at `/` and the app at `/app/` (or the app alone). `mpa`
|
|
124
|
+
// keeps the dev server from answering unknown URLs with a page.
|
|
93
125
|
appType: 'mpa',
|
|
94
126
|
define: {
|
|
95
127
|
__SB_APPS__: JSON.stringify(landing),
|
|
128
|
+
__SB_DEFAULT_APP__: JSON.stringify(site.defaultApp),
|
|
129
|
+
__SB_PAGE_MODE__: JSON.stringify(site.pageMode),
|
|
96
130
|
__SB_COMMIT__: JSON.stringify(options.commit ?? 'dev'),
|
|
97
131
|
__SB_BRANCH__: JSON.stringify(options.branch ?? ''),
|
|
98
132
|
__SB_BUILT_AT__: JSON.stringify(new Date().toISOString()),
|
|
@@ -105,10 +139,7 @@ export function createViteConfig(options) {
|
|
|
105
139
|
target: 'es2022',
|
|
106
140
|
sourcemap: true,
|
|
107
141
|
rollupOptions: {
|
|
108
|
-
input:
|
|
109
|
-
landing: path.resolve(root, 'index.html'),
|
|
110
|
-
app: path.resolve(root, 'app/index.html'),
|
|
111
|
-
},
|
|
142
|
+
input: pages,
|
|
112
143
|
},
|
|
113
144
|
},
|
|
114
145
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings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AC,OAAO,EAAE,KAAK,CAAC;YAC7B,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC;SAC7B;QACD,2EAA2E;QAC3E,gEAAgE;QAChE,OAAO,EAAE,KAAK;QACd,MAAM,EAAE;YACN,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACpC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC;YACnD,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC/C,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC;YACtD,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;YACnD,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SAC1D;QACD,MAAM,EAAE;YACN,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;SACjB;QACD,KAAK,EAAE;YACL,MAAM,EAAE,QAAQ;YAChB,SAAS,EAAE,IAAI;YACf,aAAa,EAAE;gBACb,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -13,7 +13,8 @@ import { type SiteOptions } from './config.js';
|
|
|
13
13
|
export type { AppSpec } from './apps.js';
|
|
14
14
|
export { APP_NAME, validateAppSpecs } from './apps.js';
|
|
15
15
|
export type { LandingApp, SiteOptions } from './config.js';
|
|
16
|
-
export { createViteConfig, landingApps, webRoot } from './config.js';
|
|
16
|
+
export { createViteConfig, landingApps, siteLayout, webRoot } from './config.js';
|
|
17
|
+
export type { SiteInfo, SiteLayout, SitePageMode } from '../plugins/site-layout.js';
|
|
17
18
|
export interface DevServerOptions extends SiteOptions {
|
|
18
19
|
/** Defaults to 5173. */
|
|
19
20
|
port?: number;
|
|
@@ -39,9 +40,13 @@ export interface BuildSiteOptions extends SiteOptions {
|
|
|
39
40
|
*/
|
|
40
41
|
export declare function createDevServer(options: DevServerOptions): Promise<ViteDevServer>;
|
|
41
42
|
/**
|
|
42
|
-
* `vite build` of the
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* `vite build` of the site's pages into `outDir`, with every app's wasm
|
|
44
|
+
* module, catalog JSON + images and web manifest (+ icon) written into it, so
|
|
45
|
+
* the directory is a complete static site. A site that is its one app
|
|
46
|
+
* (`layout: 'app'`) is built for a deployment: the app fills the window on
|
|
47
|
+
* every screen (`pageMode: 'device'`) unless the options say otherwise.
|
|
45
48
|
*/
|
|
46
49
|
export declare function buildSite(options: BuildSiteOptions): Promise<void>;
|
|
50
|
+
/** `url` as a QR code drawn with block characters, for a terminal (the phone's way into a dev server). */
|
|
51
|
+
export declare function qrCodeText(url: string): Promise<string>;
|
|
47
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAA2C,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AACnF,OAAO,EAAgC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7E,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEpF,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAWvF;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUxE;AAED,0GAA0G;AAC1G,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D"}
|
package/node/dist/node/index.js
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
* from the options; `vite.config.ts` is not read.
|
|
10
10
|
*/
|
|
11
11
|
import path from 'node:path';
|
|
12
|
+
import { toString as qrToString } from 'qrcode';
|
|
12
13
|
import { build, createServer } from 'vite';
|
|
13
|
-
import { createViteConfig } from './config.js';
|
|
14
|
+
import { createViteConfig, siteLayout } from './config.js';
|
|
14
15
|
export { APP_NAME, validateAppSpecs } from './apps.js';
|
|
15
|
-
export { createViteConfig, landingApps, webRoot } from './config.js';
|
|
16
|
+
export { createViteConfig, landingApps, siteLayout, webRoot } from './config.js';
|
|
16
17
|
/**
|
|
17
18
|
* A configured, started Vite dev server (`listen` has been called) with the
|
|
18
19
|
* registry plugins for `options.apps`. Call `server.printUrls()` to show the
|
|
@@ -35,12 +36,16 @@ export async function createDevServer(options) {
|
|
|
35
36
|
return devServer;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
|
-
* `vite build` of the
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* `vite build` of the site's pages into `outDir`, with every app's wasm
|
|
40
|
+
* module, catalog JSON + images and web manifest (+ icon) written into it, so
|
|
41
|
+
* the directory is a complete static site. A site that is its one app
|
|
42
|
+
* (`layout: 'app'`) is built for a deployment: the app fills the window on
|
|
43
|
+
* every screen (`pageMode: 'device'`) unless the options say otherwise.
|
|
41
44
|
*/
|
|
42
45
|
export async function buildSite(options) {
|
|
43
46
|
const { outDir, emptyOutDir, logLevel, ...site } = options;
|
|
47
|
+
if (site.pageMode === undefined && siteLayout(site) === 'app')
|
|
48
|
+
site.pageMode = 'device';
|
|
44
49
|
const config = createViteConfig(site);
|
|
45
50
|
await build({
|
|
46
51
|
...config,
|
|
@@ -49,4 +54,8 @@ export async function buildSite(options) {
|
|
|
49
54
|
build: { ...config.build, outDir: path.resolve(outDir), emptyOutDir: emptyOutDir ?? true },
|
|
50
55
|
});
|
|
51
56
|
}
|
|
57
|
+
/** `url` as a QR code drawn with block characters, for a terminal (the phone's way into a dev server). */
|
|
58
|
+
export async function qrCodeText(url) {
|
|
59
|
+
return qrToString(url, { type: 'terminal', small: true });
|
|
60
|
+
}
|
|
52
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,YAAY,EAA0C,MAAM,MAAM,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAoB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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C,KAAK,UAAU,SAAS,CAAC,OAAyB;IACvD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK;QAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACxF,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,KAAK,CAAC;QACV,GAAG,MAAM;QACT,UAAU,EAAE,KAAK;QACjB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,WAAW,IAAI,IAAI,EAAE;KAC3F,CAAC,CAAC;AACL,CAAC;AAED,0GAA0G;AAC1G,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,OAAO,UAAU,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -40,8 +40,16 @@ export interface AppManifest {
|
|
|
40
40
|
export declare function manifestPath(app: string): string;
|
|
41
41
|
/** URL path of an app's own icon (only served for specs with `icon`). */
|
|
42
42
|
export declare function manifestIconPath(app: string): string;
|
|
43
|
-
/** The app page URL that runs `app` (matches `appPath` in src/landing.ts). */
|
|
43
|
+
/** The app page URL that runs `app` in the `landing` layout (matches `appPath` in src/landing.ts). */
|
|
44
44
|
export declare function appStartUrl(app: string): string;
|
|
45
|
+
export interface ManifestOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Where the app starts, and the manifest's scope (its directory): the app
|
|
48
|
+
* page with `?app=` by default; `/` in a site that is the one app
|
|
49
|
+
* (plugins/site-layout.ts).
|
|
50
|
+
*/
|
|
51
|
+
startUrl?: string;
|
|
52
|
+
}
|
|
45
53
|
/** Default description, for a spec without one. */
|
|
46
54
|
export declare function defaultDescription(spec: ManifestSpec): string;
|
|
47
55
|
/**
|
|
@@ -49,8 +57,8 @@ export declare function defaultDescription(spec: ManifestSpec): string;
|
|
|
49
57
|
* and the page draws its own background under it, and the light/dark
|
|
50
58
|
* `theme-color` metas in app/index.html cover the browser UI.
|
|
51
59
|
*/
|
|
52
|
-
export declare function appManifest(spec: ManifestSpec | string): AppManifest;
|
|
53
|
-
export declare function appManifestJson(spec: ManifestSpec | string): string;
|
|
60
|
+
export declare function appManifest(spec: ManifestSpec | string, options?: ManifestOptions): AppManifest;
|
|
61
|
+
export declare function appManifestJson(spec: ManifestSpec | string, options?: ManifestOptions): string;
|
|
54
62
|
/** The app named by a manifest request URL, or null for any other URL. */
|
|
55
63
|
export declare function manifestRequestApp(url: string): string | null;
|
|
56
64
|
/** The app named by an icon request URL (`/manifests/<name>-icon.png`), or null. */
|
|
@@ -60,5 +68,5 @@ export declare function appIconUrls(specs: readonly ManifestSpec[]): Record<stri
|
|
|
60
68
|
export declare function appManifests(specs: readonly ManifestSpec[], included?: readonly {
|
|
61
69
|
name: string;
|
|
62
70
|
icon?: string;
|
|
63
|
-
}[]): Plugin;
|
|
71
|
+
}[], options?: ManifestOptions): Plugin;
|
|
64
72
|
//# sourceMappingURL=app-manifests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifests.d.ts","sourceRoot":"","sources":["../../../plugins/app-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGxE,eAAO,MAAM,YAAY,cAAc,CAAC;AAExC,gEAAgE;AA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AAE,SAAS,YAAY,EAAE,EAC9B,QAAQ,GAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAO,EACzD,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAqER"}
|
|
@@ -27,10 +27,15 @@ export function manifestPath(app) {
|
|
|
27
27
|
export function manifestIconPath(app) {
|
|
28
28
|
return `/${MANIFEST_DIR}/${app}-icon.png`;
|
|
29
29
|
}
|
|
30
|
-
/** The app page URL that runs `app` (matches `appPath` in src/landing.ts). */
|
|
30
|
+
/** The app page URL that runs `app` in the `landing` layout (matches `appPath` in src/landing.ts). */
|
|
31
31
|
export function appStartUrl(app) {
|
|
32
32
|
return `/app/?app=${encodeURIComponent(app)}`;
|
|
33
33
|
}
|
|
34
|
+
/** The scope of a manifest starting at `start`: the directory of the URL's path. */
|
|
35
|
+
function scopeOf(start) {
|
|
36
|
+
const pathname = start.split('?')[0] ?? '/';
|
|
37
|
+
return pathname.endsWith('/') ? pathname : pathname.slice(0, pathname.lastIndexOf('/') + 1) || '/';
|
|
38
|
+
}
|
|
34
39
|
/** Default description, for a spec without one. */
|
|
35
40
|
export function defaultDescription(spec) {
|
|
36
41
|
return `The ${displayNameOf(spec)} app, compiled to WebAssembly and rendered in the browser.`;
|
|
@@ -50,11 +55,11 @@ function iconSizes(file) {
|
|
|
50
55
|
* and the page draws its own background under it, and the light/dark
|
|
51
56
|
* `theme-color` metas in app/index.html cover the browser UI.
|
|
52
57
|
*/
|
|
53
|
-
export function appManifest(spec) {
|
|
58
|
+
export function appManifest(spec, options = {}) {
|
|
54
59
|
const app = typeof spec === 'string' ? { name: spec } : spec;
|
|
55
60
|
if (!APP_NAME.test(app.name))
|
|
56
61
|
throw new Error(`Invalid app name: ${JSON.stringify(app.name)}`);
|
|
57
|
-
const start = appStartUrl(app.name);
|
|
62
|
+
const start = options.startUrl ?? appStartUrl(app.name);
|
|
58
63
|
const displayName = displayNameOf(app);
|
|
59
64
|
return {
|
|
60
65
|
id: start,
|
|
@@ -62,7 +67,7 @@ export function appManifest(spec) {
|
|
|
62
67
|
short_name: displayName,
|
|
63
68
|
description: app.description ?? defaultDescription(app),
|
|
64
69
|
start_url: start,
|
|
65
|
-
scope:
|
|
70
|
+
scope: scopeOf(start),
|
|
66
71
|
display: 'standalone',
|
|
67
72
|
orientation: 'portrait',
|
|
68
73
|
background_color: '#000000',
|
|
@@ -74,8 +79,8 @@ export function appManifest(spec) {
|
|
|
74
79
|
],
|
|
75
80
|
};
|
|
76
81
|
}
|
|
77
|
-
export function appManifestJson(spec) {
|
|
78
|
-
return JSON.stringify(appManifest(spec), null, 2) + '\n';
|
|
82
|
+
export function appManifestJson(spec, options = {}) {
|
|
83
|
+
return JSON.stringify(appManifest(spec, options), null, 2) + '\n';
|
|
79
84
|
}
|
|
80
85
|
/** The app named by a manifest request URL, or null for any other URL. */
|
|
81
86
|
export function manifestRequestApp(url) {
|
|
@@ -95,7 +100,7 @@ export function appIconUrls(specs) {
|
|
|
95
100
|
icons[spec.name] = manifestIconPath(spec.name);
|
|
96
101
|
return icons;
|
|
97
102
|
}
|
|
98
|
-
export function appManifests(specs, included = []) {
|
|
103
|
+
export function appManifests(specs, included = [], options = {}) {
|
|
99
104
|
const byName = new Map(specs.map((spec) => [spec.name, spec]));
|
|
100
105
|
// The apps of included sites (plugins/included-sites.ts) bring their icons.
|
|
101
106
|
const icons = { ...appIconUrls(specs), ...Object.fromEntries(included.flatMap((app) => (app.icon ? [[app.name, app.icon]] : []))) };
|
|
@@ -115,7 +120,7 @@ export function appManifests(specs, included = []) {
|
|
|
115
120
|
}
|
|
116
121
|
res.setHeader('Content-Type', 'application/manifest+json');
|
|
117
122
|
res.setHeader('Cache-Control', 'no-cache');
|
|
118
|
-
res.end(appManifestJson(spec));
|
|
123
|
+
res.end(appManifestJson(spec, options));
|
|
119
124
|
return;
|
|
120
125
|
}
|
|
121
126
|
const iconApp = iconRequestApp(url);
|
|
@@ -149,7 +154,7 @@ export function appManifests(specs, included = []) {
|
|
|
149
154
|
this.emitFile({
|
|
150
155
|
type: 'asset',
|
|
151
156
|
fileName: `${MANIFEST_DIR}/${spec.name}.webmanifest`,
|
|
152
|
-
source: appManifestJson(spec),
|
|
157
|
+
source: appManifestJson(spec, options),
|
|
153
158
|
});
|
|
154
159
|
if (spec.icon) {
|
|
155
160
|
if (!existsSync(spec.icon)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifests.js","sourceRoot":"","sources":["../../../plugins/app-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AAkBxC,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,YAAY,IAAI,GAAG,cAAc,CAAC;AAC/C,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,OAAO,IAAI,YAAY,IAAI,GAAG,WAAW,CAAC;AAC5C,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"app-manifests.js","sourceRoot":"","sources":["../../../plugins/app-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AAkBxC,+DAA+D;AAC/D,MAAM,UAAU,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I,UAAU,IAAI,CAAC,IAAI,0BAA0B,CAAC,CAAC;wBACrE,SAAS;oBACX,CAAC;oBACD,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,GAAG,YAAY,IAAI,IAAI,CAAC,IAAI,WAAW;wBACjD,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;qBAChC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site's layout, and what the app page knows about the site it is in.
|
|
3
|
+
*
|
|
4
|
+
* A site holds one app or several (node/config.ts, `siteLayout`):
|
|
5
|
+
*
|
|
6
|
+
* - `app`: one app, the site is that app. The app page is `/` (the dev server
|
|
7
|
+
* serves it there; a build writes it as `index.html` and nothing at `/app/`),
|
|
8
|
+
* there is no landing page, and the site's `/manifest.webmanifest` is the
|
|
9
|
+
* app's own, starting at `/`.
|
|
10
|
+
* - `landing`: the landing page at `/` lists the apps, each at `/app/?app=<name>`.
|
|
11
|
+
*
|
|
12
|
+
* Both layouts give the app page `window.__SB_SITE__` (the layout, the app
|
|
13
|
+
* the page runs without `?app=`, its display name, and the page mode a wide
|
|
14
|
+
* screen gets), which the inline scripts of app/index.html read before the
|
|
15
|
+
* first paint; src/main.ts gets the same through `define`s.
|
|
16
|
+
*/
|
|
17
|
+
import type { Plugin } from 'vite';
|
|
18
|
+
import { type ManifestSpec } from './app-manifests.js';
|
|
19
|
+
export type SiteLayout = 'app' | 'landing';
|
|
20
|
+
/**
|
|
21
|
+
* What the app page shows on a wide screen (a desktop browser): `auto` is the
|
|
22
|
+
* iPhone frame with the dev controls, device mode on a touch screen; `device`
|
|
23
|
+
* fills the window everywhere, as a deployed app should (src/deviceMode.ts).
|
|
24
|
+
* `?mode=` on the URL overrides either.
|
|
25
|
+
*/
|
|
26
|
+
export type SitePageMode = 'auto' | 'device';
|
|
27
|
+
/** `window.__SB_SITE__` on the app page. */
|
|
28
|
+
export interface SiteInfo {
|
|
29
|
+
layout: SiteLayout;
|
|
30
|
+
/** The app the page runs when the URL names none. */
|
|
31
|
+
defaultApp: string;
|
|
32
|
+
/** Its display name (the document title in the `app` layout). */
|
|
33
|
+
displayName: string;
|
|
34
|
+
pageMode: SitePageMode;
|
|
35
|
+
}
|
|
36
|
+
/** The manifest an `app` layout site serves at its root, and the start URL its pages use. */
|
|
37
|
+
export declare const ROOT_START_URL = "/";
|
|
38
|
+
/** The `pathname?query` of a request to the app page that serves `url` in the `app` layout, or null. */
|
|
39
|
+
export declare function rewriteRootRequest(url: string): string | null;
|
|
40
|
+
export declare function siteLayoutPlugin(info: SiteInfo, app: ManifestSpec | undefined): Plugin;
|
|
41
|
+
//# sourceMappingURL=site-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-layout.d.ts","sourceRoot":"","sources":["../../../plugins/site-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AACnD,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7C,4CAA4C;AAC5C,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,6FAA6F;AAC7F,eAAO,MAAM,cAAc,MAAM,CAAC;AAIlC,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI7D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAyCtF"}
|