@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 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 (new URLSearchParams(location.search).get('embed') === '1') document.documentElement.setAttribute('data-sb-embed', '');
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 class="wifi-band" d="M1.08 3.87A11.0 11.0 0 0 1 15.22 3.87" stroke-width="2.6" />
118
- <path class="wifi-band" d="M3.91 7.24A6.6 6.6 0 0 1 12.39 7.24" stroke-width="2.9" />
119
- <path d="M8.15 12.3L5.64 9.31A3.9 3.9 0 0 1 10.66 9.31Z" />
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftbrowser/web",
3
- "version": "0.18.3",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "description": "SwiftBrowser web renderer and dev server: applies render ops from a Swift/Wasm app to the DOM inside an iPhone frame.",
6
6
  "repository": {
package/src/appFiles.ts CHANGED
@@ -125,10 +125,15 @@ export interface FilesPersistence {
125
125
  clear(): Promise<void>;
126
126
  }
127
127
 
128
- /** A row of the `entries` store: a file's bytes or a directory, with when it was last written where the writer said. */
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) entries.set(row.path, row.directory ? null : new Uint8Array(row.data ?? new Uint8Array()));
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) {