@swiftbrowser/web 0.18.3 → 0.21.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/app/index.html +11 -7
- package/package.json +1 -1
- package/src/appFiles.ts +12 -3
- package/src/audioEngine.ts +1467 -0
- package/src/chartDom.ts +1 -1
- package/src/deviceFrame.ts +188 -0
- package/src/dragDrop.ts +66 -10
- package/src/files.ts +68 -13
- package/src/hostRequests.ts +53 -3
- package/src/interaction.ts +6 -1
- package/src/languageModel.ts +309 -0
- package/src/layout/engine.ts +128 -48
- package/src/layoutDom.ts +43 -3
- package/src/main.ts +12 -1
- package/src/page.css +65 -0
- package/src/pinnedViews.ts +38 -1
- package/src/protocol.ts +70 -5
- package/src/renderer.ts +299 -53
- package/src/scrollTransition.ts +2 -1
- package/src/styles.css +374 -42
- package/src/styles.ts +13 -15
- package/src/symbols.ts +6 -0
- package/src/viewRegistry.ts +58 -0
package/app/index.html
CHANGED
|
@@ -40,9 +40,16 @@
|
|
|
40
40
|
var coarse = typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
41
41
|
var device = mode === 'device' || (mode !== 'frame' && (coarse || site.pageMode === 'device'));
|
|
42
42
|
document.documentElement.setAttribute('data-sb-mode', device ? 'device' : 'frame');
|
|
43
|
+
// The preview's device (src/deviceFrame.ts in @swiftbrowser/web): ?device=, else the last one picked.
|
|
44
|
+
var frame = new URLSearchParams(location.search).get('device');
|
|
45
|
+
var embedded = new URLSearchParams(location.search).get('embed') === '1';
|
|
46
|
+
try { frame = frame || (embedded ? null : localStorage.getItem('sb-device-frame')); } catch (e) {}
|
|
47
|
+
document.documentElement.setAttribute('data-sb-frame', frame === 'ipad' || frame === 'none' ? frame : 'iphone');
|
|
48
|
+
// ?toolbar=0: the toolbar's close button hid it (src/deviceFrame.ts).
|
|
49
|
+
if (new URLSearchParams(location.search).get('toolbar') === '0') document.documentElement.setAttribute('data-sb-toolbar', 'hidden');
|
|
43
50
|
// ?embed=1: the page is in another's frame (the playground's
|
|
44
51
|
// simulator), which has its own controls: the device alone.
|
|
45
|
-
if (
|
|
52
|
+
if (embedded) document.documentElement.setAttribute('data-sb-embed', '');
|
|
46
53
|
})();
|
|
47
54
|
// Point the manifest, the home-screen icon and the titles at the app
|
|
48
55
|
// this page runs (?app=, else the site's default), so Share -> Add to
|
|
@@ -73,9 +80,6 @@
|
|
|
73
80
|
</head>
|
|
74
81
|
<body>
|
|
75
82
|
<header class="toolbar" role="toolbar" aria-label="SwiftBrowser controls">
|
|
76
|
-
<span class="toolbar-brand">SwiftBrowser</span>
|
|
77
|
-
<span class="toolbar-sep" aria-hidden="true"></span>
|
|
78
|
-
<span class="toolbar-label">App</span>
|
|
79
83
|
<span id="app-name" class="toolbar-value">Loading…</span>
|
|
80
84
|
<span class="toolbar-spacer"></span>
|
|
81
85
|
<span id="build-status" class="toolbar-build" role="status" aria-live="polite" hidden>Rebuilding…</span>
|
|
@@ -114,9 +118,9 @@
|
|
|
114
118
|
</svg>
|
|
115
119
|
<!-- Wi-Fi -->
|
|
116
120
|
<svg class="glyph glyph-wifi" viewBox="0 0 16.3 12.33" width="16.3" height="12.33">
|
|
117
|
-
<path
|
|
118
|
-
<path
|
|
119
|
-
<path d="M8.15 12.
|
|
121
|
+
<path d="M0.02 3.3A12.15 12.15 0 0 1 16.28 3.3L14.41 5.38A9.35 9.35 0 0 0 1.89 5.38Z" />
|
|
122
|
+
<path d="M2.8 6.38A8 8 0 0 1 13.5 6.38L11.66 8.43A5.25 5.25 0 0 0 4.64 8.43Z" />
|
|
123
|
+
<path d="M8.15 12.33L5.54 9.43A3.9 3.9 0 0 1 10.76 9.43Z" />
|
|
120
124
|
</svg>
|
|
121
125
|
<!-- Battery -->
|
|
122
126
|
<svg class="glyph glyph-battery" viewBox="0 0 28 13" width="28" height="13">
|
package/package.json
CHANGED
package/src/appFiles.ts
CHANGED
|
@@ -125,10 +125,15 @@ export interface FilesPersistence {
|
|
|
125
125
|
clear(): Promise<void>;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* A row of the `entries` store: a file's bytes or a directory, with when it
|
|
130
|
+
* was last written where the writer said. A React app's `fileManager`
|
|
131
|
+
* (files.ts) may keep a file as the `Blob` the viewer handed over, which
|
|
132
|
+
* IndexedDB stores without reading; the module's loader reads one on load.
|
|
133
|
+
*/
|
|
129
134
|
export interface EntryRow {
|
|
130
135
|
path: string;
|
|
131
|
-
data?: Uint8Array;
|
|
136
|
+
data?: Uint8Array | Blob;
|
|
132
137
|
directory?: boolean;
|
|
133
138
|
/** Milliseconds since the epoch; rows the module wrote (and older rows) have none. */
|
|
134
139
|
modified?: number;
|
|
@@ -181,7 +186,11 @@ export function indexedDBFiles(app: string, factory: IDBFactory = indexedDB): Fi
|
|
|
181
186
|
const db = await database();
|
|
182
187
|
const rows = await request(db.transaction(ENTRIES, 'readonly').objectStore(ENTRIES).getAll() as IDBRequest<EntryRow[]>);
|
|
183
188
|
const entries: HomeEntries = new Map();
|
|
184
|
-
for (const row of rows)
|
|
189
|
+
for (const row of rows) {
|
|
190
|
+
if (row.directory) entries.set(row.path, null);
|
|
191
|
+
else if (row.data !== undefined && typeof Blob !== 'undefined' && row.data instanceof Blob) entries.set(row.path, new Uint8Array(await row.data.arrayBuffer()));
|
|
192
|
+
else entries.set(row.path, new Uint8Array((row.data as Uint8Array | undefined) ?? new Uint8Array()));
|
|
193
|
+
}
|
|
185
194
|
return entries;
|
|
186
195
|
},
|
|
187
196
|
apply(changes) {
|