@bitbitpress/client 1.1.3 → 1.2.2
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 +8 -152
- package/dist/generated/openapi.d.ts +802 -314
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react/index.d.ts +76 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +122 -3
- package/dist/react/index.js.map +1 -1
- package/dist/react-native-expo/BitBitPiece.d.ts +64 -0
- package/dist/react-native-expo/BitBitPiece.d.ts.map +1 -0
- package/dist/react-native-expo/BitBitPiece.js +164 -0
- package/dist/react-native-expo/BitBitPiece.js.map +1 -0
- package/dist/react-native-expo/BitBitView.d.ts.map +1 -1
- package/dist/react-native-expo/BitBitView.js +21 -2
- package/dist/react-native-expo/BitBitView.js.map +1 -1
- package/dist/react-native-expo/bootstrapHtml.d.ts +13 -0
- package/dist/react-native-expo/bootstrapHtml.d.ts.map +1 -1
- package/dist/react-native-expo/bootstrapHtml.js +108 -12
- package/dist/react-native-expo/bootstrapHtml.js.map +1 -1
- package/dist/react-native-expo/index.d.ts +1 -0
- package/dist/react-native-expo/index.d.ts.map +1 -1
- package/dist/react-native-expo/index.js +1 -0
- package/dist/react-native-expo/index.js.map +1 -1
- package/dist/runtime/index.d.ts +32 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +68 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/studio/BitBitMobilePreview.d.ts +33 -0
- package/dist/studio/BitBitMobilePreview.d.ts.map +1 -0
- package/dist/studio/BitBitMobilePreview.js +120 -0
- package/dist/studio/BitBitMobilePreview.js.map +1 -0
- package/dist/studio/index.d.ts +7 -0
- package/dist/studio/index.d.ts.map +1 -0
- package/dist/studio/index.js +7 -0
- package/dist/studio/index.js.map +1 -0
- package/dist/synthesisUi/types.d.ts +3 -0
- package/dist/synthesisUi/types.d.ts.map +1 -1
- package/dist/user/index.d.ts +42 -19
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user/index.js +8 -3
- package/dist/user/index.js.map +1 -1
- package/dist/user/profile.d.ts +2 -2
- package/dist/user/profile.js +2 -2
- package/dist/user/submissions.d.ts +0 -21
- package/dist/user/submissions.d.ts.map +1 -1
- package/dist/user/submissions.js +0 -39
- package/dist/user/submissions.js.map +1 -1
- package/dist/user/synthesisOutputTts.d.ts +21 -0
- package/dist/user/synthesisOutputTts.d.ts.map +1 -0
- package/dist/user/synthesisOutputTts.js +32 -0
- package/dist/user/synthesisOutputTts.js.map +1 -0
- package/dist/user/synthesisPiece.d.ts +38 -0
- package/dist/user/synthesisPiece.d.ts.map +1 -0
- package/dist/user/synthesisPiece.js +58 -0
- package/dist/user/synthesisPiece.js.map +1 -0
- package/dist/user/track-batch-manager.d.ts +10 -4
- package/dist/user/track-batch-manager.d.ts.map +1 -1
- package/dist/user/track-batch-manager.js +6 -5
- package/dist/user/track-batch-manager.js.map +1 -1
- package/dist/user/track.d.ts +9 -0
- package/dist/user/track.d.ts.map +1 -1
- package/dist/user/track.js +17 -0
- package/dist/user/track.js.map +1 -1
- package/package.json +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitBitView.js","sourceRoot":"","sources":["../../src/react-native-expo/BitBitView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,OAAO,EAA4B,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAM7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"BitBitView.js","sourceRoot":"","sources":["../../src/react-native-expo/BitBitView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EA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B,OAAO,CAAC,IAAI,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAC3E,CAAC;gBACJ,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CACzD,CAAC;IAEF,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,aAAa,CAAC,OAAO,EAAE;QAC5B,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,oBAAoB,EAAE;QAC/C,eAAe,EAAE,CAAC,GAAG,CAAC;QACtB,SAAS;QACT,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,yBAAyB,EAAE,IAAI;QAC/B,+BAA+B,EAAE,KAAK;QACtC,yDAAyD;QACzD,4BAA4B,EAAE,CAAC,OAAwB,EAAE,EAAE,CACzD,OAAO,CAAC,GAAG,KAAK,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC1E,KAAK,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,aAAa,EAAE;KAC5D,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -16,5 +16,18 @@
|
|
|
16
16
|
export declare function buildBootstrapHtml(params: {
|
|
17
17
|
bundle: string;
|
|
18
18
|
theme: Record<string, string>;
|
|
19
|
+
/** Report content height to native (`{ kind: 'height', px }`) and lay the app
|
|
20
|
+
* out at its natural height instead of filling the viewport — for embedding a
|
|
21
|
+
* piece at its own size inside a scrolling host (a feed tile). Defaults to
|
|
22
|
+
* false: fill the WebView height (a full-screen `<BitBitView>`). */
|
|
23
|
+
autoHeight?: boolean;
|
|
24
|
+
/** Expose `ctx.tts(ref)` to the bundle: an audio player calls it on play to mint a streaming
|
|
25
|
+
* URL for the referenced piece content. Requests round-trip to native (`{ kind: 'tts', id,
|
|
26
|
+
* ref }`) and resolve when native injects `window.__bb.resolveTts(id, …)`. Defaults to false —
|
|
27
|
+
* without it `ctx.tts` is undefined and players stay idle. */
|
|
28
|
+
enableTts?: boolean;
|
|
29
|
+
/** The color scheme to render in (`ctx.colorScheme`). The WebView can't read the
|
|
30
|
+
* OS appearance reliably, so native passes it explicitly. Omit for none. */
|
|
31
|
+
colorScheme?: 'light' | 'dark';
|
|
19
32
|
}): string;
|
|
20
33
|
//# sourceMappingURL=bootstrapHtml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrapHtml.d.ts","sourceRoot":"","sources":["../../src/react-native-expo/bootstrapHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"bootstrapHtml.d.ts","sourceRoot":"","sources":["../../src/react-native-expo/bootstrapHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;yEAGqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;mEAG+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;iFAC6E;IAC7E,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC,GAAG,MAAM,CA8JT"}
|
|
@@ -16,14 +16,12 @@
|
|
|
16
16
|
export function buildBootstrapHtml(params) {
|
|
17
17
|
const bundle = JSON.stringify(params.bundle);
|
|
18
18
|
const theme = JSON.stringify(params.theme);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
html, body { margin: 0; padding: 0; }
|
|
26
|
-
/* Viewport units (not %) so the app fills the WebView height without a
|
|
19
|
+
const autoHeight = params.autoHeight ?? false;
|
|
20
|
+
const enableTts = params.enableTts ?? false;
|
|
21
|
+
const colorScheme = JSON.stringify(params.colorScheme ?? null);
|
|
22
|
+
const rootLayout = autoHeight
|
|
23
|
+
? `#bb-root { display: flex; flex-direction: column; }`
|
|
24
|
+
: `/* Viewport units (not %) so the app fills the WebView height without a
|
|
27
25
|
definite parent-height chain, which collapses in a WebView. */
|
|
28
26
|
body { min-height: 100vh; min-height: 100dvh; }
|
|
29
27
|
#bb-root {
|
|
@@ -33,7 +31,30 @@ export function buildBootstrapHtml(params) {
|
|
|
33
31
|
flex-direction: column;
|
|
34
32
|
}
|
|
35
33
|
/* Let the mounted app grow to fill the height (still scrolls when taller). */
|
|
36
|
-
#bb-root > * { flex: 1 0 auto; }
|
|
34
|
+
#bb-root > * { flex: 1 0 auto; }`;
|
|
35
|
+
// In auto-height mode, mirror the streamed content's size out to native so the
|
|
36
|
+
// host tile can size to it (the app's standard embed-sizing contract).
|
|
37
|
+
const heightReporter = autoHeight
|
|
38
|
+
? `
|
|
39
|
+
const root = document.getElementById('bb-root');
|
|
40
|
+
let lastHeight = 0;
|
|
41
|
+
const reportHeight = () => {
|
|
42
|
+
const px = Math.ceil(root.getBoundingClientRect().height);
|
|
43
|
+
if (px > 0 && Math.abs(px - lastHeight) >= 2) { lastHeight = px; post({ kind: 'height', px }); }
|
|
44
|
+
};
|
|
45
|
+
if (typeof ResizeObserver !== 'undefined') new ResizeObserver(reportHeight).observe(root);
|
|
46
|
+
if (typeof MutationObserver !== 'undefined')
|
|
47
|
+
new MutationObserver(reportHeight).observe(root, { childList: true, subtree: true, attributes: true });
|
|
48
|
+
[0, 150, 300, 750, 1500].forEach((d) => setTimeout(reportHeight, d));`
|
|
49
|
+
: '';
|
|
50
|
+
return `<!doctype html>
|
|
51
|
+
<html>
|
|
52
|
+
<head>
|
|
53
|
+
<meta charset="utf-8">
|
|
54
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover">
|
|
55
|
+
<style>
|
|
56
|
+
html, body { margin: 0; padding: 0; }
|
|
57
|
+
${rootLayout}
|
|
37
58
|
* { box-sizing: border-box; }
|
|
38
59
|
:root { -webkit-tap-highlight-color: transparent; }
|
|
39
60
|
</style>
|
|
@@ -41,18 +62,60 @@ export function buildBootstrapHtml(params) {
|
|
|
41
62
|
<body>
|
|
42
63
|
<div id="bb-root"></div>
|
|
43
64
|
<script type="module">
|
|
44
|
-
|
|
45
|
-
|
|
65
|
+
// Transport out: React Native WebView when hosted natively, else the parent window
|
|
66
|
+
// (a web <iframe> preview). Same message shapes both ways.
|
|
67
|
+
const post = (m) => {
|
|
68
|
+
try { if (window.ReactNativeWebView) { window.ReactNativeWebView.postMessage(JSON.stringify(m)); return; } } catch (e) {}
|
|
69
|
+
try { if (window.parent && window.parent !== window) window.parent.postMessage(m, '*'); } catch (e) {}
|
|
70
|
+
};
|
|
71
|
+
const bb = (window.__bb = { theme: ${theme}, colorScheme: ${colorScheme}, mod: null, handle: null, pending: null, data: undefined, history: undefined, viewed: false, tts: {}, ttsSeq: 0 });
|
|
46
72
|
const wrap = (h) => (typeof h === 'function' ? { update() {}, unmount: h } : h);
|
|
73
|
+
const applyColorScheme = () => { if (bb.colorScheme) document.documentElement.style.colorScheme = bb.colorScheme; };
|
|
74
|
+
applyColorScheme();
|
|
75
|
+
// An audio player calls ctx.tts(ref) on play; the request round-trips to the host, which mints
|
|
76
|
+
// a streaming URL for the referenced piece content and injects it back via resolveTts.
|
|
77
|
+
const requestTts = (ref) => new Promise((resolve, reject) => {
|
|
78
|
+
const id = ++bb.ttsSeq;
|
|
79
|
+
bb.tts[id] = { resolve, reject };
|
|
80
|
+
post({ kind: 'tts', id, ref });
|
|
81
|
+
});
|
|
82
|
+
bb.resolveTts = (id, url, error) => {
|
|
83
|
+
const p = bb.tts[id];
|
|
84
|
+
if (!p) return;
|
|
85
|
+
delete bb.tts[id];
|
|
86
|
+
if (error || !url) p.reject(new Error(error || 'Could not load audio'));
|
|
87
|
+
else p.resolve(url);
|
|
88
|
+
};
|
|
89
|
+
// Play an HLS URL on every platform: native HLS where the WebView supports it (iOS), else
|
|
90
|
+
// hls.js loaded on demand (Android). Handed to the bundle as ctx.playMedia — a plain <audio src>
|
|
91
|
+
// of an HLS playlist only works on iOS.
|
|
92
|
+
const playMedia = (el, url) => {
|
|
93
|
+
if (el.canPlayType('application/vnd.apple.mpegurl')) {
|
|
94
|
+
el.src = url;
|
|
95
|
+
return () => { el.removeAttribute('src'); el.load(); };
|
|
96
|
+
}
|
|
97
|
+
let destroyed = false; let hls = null;
|
|
98
|
+
import('https://esm.sh/hls.js@1').then((m) => {
|
|
99
|
+
if (destroyed) return;
|
|
100
|
+
const H = m.default || m;
|
|
101
|
+
if (!H || !H.isSupported()) { el.src = url; return; }
|
|
102
|
+
hls = new H(); hls.loadSource(url); hls.attachMedia(el);
|
|
103
|
+
}).catch(() => { if (!destroyed) el.src = url; });
|
|
104
|
+
return () => { destroyed = true; if (hls) { try { hls.destroy(); } catch (e) {} } };
|
|
105
|
+
};
|
|
47
106
|
const ctx = () => ({
|
|
48
107
|
theme: bb.theme,
|
|
108
|
+
...(bb.colorScheme ? { colorScheme: bb.colorScheme } : {}),
|
|
49
109
|
track: (event, payload) => post({ kind: 'track', event, payload }),
|
|
50
110
|
onEvent: (name, payload) => post({ kind: 'event', name, payload }),
|
|
51
111
|
navigate: (href) => post({ kind: 'navigate', href }),
|
|
112
|
+
playMedia,
|
|
113
|
+
${enableTts ? 'tts: requestTts,' : ''}
|
|
52
114
|
});
|
|
53
115
|
// Called by native (injectJavaScript) with each streamed data payload (+ the
|
|
54
116
|
// optional history array, forwarded into the view's props).
|
|
55
117
|
bb.update = (data, history) => {
|
|
118
|
+
bb.data = data; bb.history = history;
|
|
56
119
|
if (!bb.mod) { bb.pending = { data, history }; return; }
|
|
57
120
|
const el = document.getElementById('bb-root');
|
|
58
121
|
const props = { data, history, ctx: ctx() };
|
|
@@ -60,6 +123,22 @@ bb.update = (data, history) => {
|
|
|
60
123
|
bb.handle = wrap(bb.mod.mount(el, props));
|
|
61
124
|
if (!bb.viewed) { bb.viewed = true; post({ kind: 'view' }); }
|
|
62
125
|
};
|
|
126
|
+
// Native pushes OS appearance changes here; re-render the mounted view with the
|
|
127
|
+
// new scheme so a dual-mode piece recolors live.
|
|
128
|
+
bb.setColorScheme = (scheme) => {
|
|
129
|
+
bb.colorScheme = scheme || null;
|
|
130
|
+
applyColorScheme();
|
|
131
|
+
if (bb.handle && bb.data !== undefined) bb.handle.update({ data: bb.data, history: bb.history, ctx: ctx() });
|
|
132
|
+
};
|
|
133
|
+
// Transport in for a web <iframe> host (native drives these via injectJavaScript instead).
|
|
134
|
+
window.addEventListener('message', (e) => {
|
|
135
|
+
const m = e.data;
|
|
136
|
+
if (!m || typeof m !== 'object') return;
|
|
137
|
+
if (m.kind === 'update') bb.update(m.data, m.history);
|
|
138
|
+
else if (m.kind === 'setColorScheme') bb.setColorScheme(m.scheme);
|
|
139
|
+
else if (m.kind === 'resolveTts') bb.resolveTts(m.id, m.url, m.error);
|
|
140
|
+
});
|
|
141
|
+
${heightReporter}
|
|
63
142
|
(async () => {
|
|
64
143
|
try {
|
|
65
144
|
const src = ${bundle};
|
|
@@ -70,8 +149,25 @@ bb.update = (data, history) => {
|
|
|
70
149
|
if (typeof bb.mod.mount !== 'function') throw new Error('generated bundle has no mount()');
|
|
71
150
|
post({ kind: 'ready' });
|
|
72
151
|
if (bb.pending != null) bb.update(bb.pending.data, bb.pending.history);
|
|
73
|
-
} catch (e) {
|
|
152
|
+
} catch (e) {
|
|
153
|
+
post({ kind: 'error', message: (e && e.message) ? e.message : String(e) });
|
|
154
|
+
}
|
|
74
155
|
})();
|
|
156
|
+
// Surface uncaught errors so native can log them (otherwise the WebView fails
|
|
157
|
+
// silently). Capture phase (3rd arg true) so it also catches media element
|
|
158
|
+
// errors (<audio>/<video> load/decode failures), which don't bubble.
|
|
159
|
+
const MEDIA_ERR = ['', 'ABORTED', 'NETWORK', 'DECODE', 'SRC_NOT_SUPPORTED'];
|
|
160
|
+
window.addEventListener('error', (e) => {
|
|
161
|
+
const t = e.target;
|
|
162
|
+
if (t && (t.tagName === 'AUDIO' || t.tagName === 'VIDEO')) {
|
|
163
|
+
const code = t.error && t.error.code;
|
|
164
|
+
post({ kind: 'error', message: 'media ' + (MEDIA_ERR[code] || 'error') + ' loading ' + (t.currentSrc || t.src || '') });
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
post({ kind: 'error', message: e.message || 'script error' });
|
|
168
|
+
}, true);
|
|
169
|
+
window.addEventListener('unhandledrejection', (e) =>
|
|
170
|
+
post({ kind: 'error', message: (e.reason && e.reason.message) || String(e.reason) }));
|
|
75
171
|
</script>
|
|
76
172
|
</body>
|
|
77
173
|
</html>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrapHtml.js","sourceRoot":"","sources":["../../src/react-native-expo/bootstrapHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"bootstrapHtml.js","sourceRoot":"","sources":["../../src/react-native-expo/bootstrapHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAgBlC;IACC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,KAAK,CAAC;IAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC;IAC/D,MAAM,UAAU,GAAG,UAAU;QAC3B,CAAC,CAAC,qDAAqD;QACvD,CAAC,CAAC;;;;;;;;;;mCAU6B,CAAC;IAClC,+EAA+E;IAC/E,uEAAuE;IACvE,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC;;;;;;;;;;sEAUgE;QAClE,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;;;;;;;IAOL,UAAU;;;;;;;;;;;;;;qCAcuB,KAAK,kBAAkB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0CnE,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BrC,cAAc;;;kBAGE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6BhB,CAAC;AACT,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { type BitBitContextValue, BitBitProvider } from '../synthesisUi/context.js';
|
|
2
2
|
export type { SynthesisUiPlatform, SynthesisUiStreamEvent, SynthesizeUiFetcher, } from '../synthesisUi/types.js';
|
|
3
|
+
export { BitBitPiece, type BitBitPieceFetcher, type BitBitPieceProps, } from './BitBitPiece.js';
|
|
3
4
|
export { BitBitView, type BitBitViewProps } from './BitBitView.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACpF,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACpF,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMpF,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMpF,OAAO,EACL,WAAW,GAGZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAiB,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -35,9 +35,40 @@ export interface BitBitViewContext {
|
|
|
35
35
|
onEvent(name: string, payload?: unknown): void;
|
|
36
36
|
/** Brand design tokens (also mirrored as CSS custom properties on the host). */
|
|
37
37
|
theme: Record<string, string>;
|
|
38
|
+
/** The color scheme the host wants the view rendered in. Optional — when
|
|
39
|
+
* omitted, a dual-mode view should fall back to the environment's
|
|
40
|
+
* `prefers-color-scheme`. Native hosts set it from the OS appearance (the
|
|
41
|
+
* WebView can't read it reliably); web hosts usually leave it unset. */
|
|
42
|
+
colorScheme?: 'light' | 'dark';
|
|
38
43
|
/** Navigate a link (web: location; native: linking/navigation). */
|
|
39
44
|
navigate?(href: string): void;
|
|
45
|
+
/** Resolve a playable HLS URL for the piece's spoken content, synthesized on demand. Omit
|
|
46
|
+
* `ref` for the WHOLE piece's spoken content; pass `{ field }` to scope to a top-level field,
|
|
47
|
+
* and/or `{ index }` for a single turn. The text lives in the piece, so you don't build turns
|
|
48
|
+
* — you just reference what to voice. An audio player calls this on play, then hands the URL
|
|
49
|
+
* to `ctx.playMedia`. Absent when the host provides no TTS (players should hide playback). */
|
|
50
|
+
tts?(ref?: BitBitTtsRef): Promise<string>;
|
|
51
|
+
/** Attach an on-demand media URL (from `ctx.tts`) to an `<audio>`/`<video>` element and play
|
|
52
|
+
* it on every platform. The URL is HLS, so this uses native HLS where the browser supports it
|
|
53
|
+
* (Safari/iOS) and loads hls.js on demand elsewhere. ALWAYS use this instead of setting
|
|
54
|
+
* `el.src` directly — a plain `<audio src>` of an HLS playlist only plays on Safari/iOS.
|
|
55
|
+
* Returns a teardown to detach. Absent only in older hosts (feature-detect and fall back). */
|
|
56
|
+
playMedia?(el: HTMLMediaElement, url: string): () => void;
|
|
40
57
|
}
|
|
58
|
+
/** What `ctx.tts(ref)` points at — a REFERENCE into the piece's spoken content, not the text:
|
|
59
|
+
* omit for the whole piece, `field` scopes to a top-level field, `index` picks a single turn. */
|
|
60
|
+
export interface BitBitTtsRef {
|
|
61
|
+
field?: string;
|
|
62
|
+
index?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Attach an HLS URL (from `ctx.tts`) to a media element and make it play on every platform:
|
|
66
|
+
* native HLS where the browser supports it (Safari/iOS), else hls.js loaded on demand from the
|
|
67
|
+
* CDN (Chrome/Firefox/Android). Returns a teardown that detaches the source / destroys hls.js.
|
|
68
|
+
* This is the default `ctx.playMedia` for web (Shadow-DOM) hosts; the WebView/iframe hosts
|
|
69
|
+
* provide an equivalent inline in their bootstrap.
|
|
70
|
+
*/
|
|
71
|
+
export declare function attachHlsMedia(el: HTMLMediaElement, url: string): () => void;
|
|
41
72
|
/** Handle returned by a mounted view: push new props as `data` streams in,
|
|
42
73
|
* and tear down. */
|
|
43
74
|
export interface GeneratedUiViewHandle {
|
|
@@ -54,6 +85,7 @@ export interface GeneratedUiModule {
|
|
|
54
85
|
/**
|
|
55
86
|
* Load a generated bundle. `src` is either a URL to the ESM (served by the
|
|
56
87
|
* API/CDN) or the bundle source as a string (dynamic-imported via a Blob URL).
|
|
88
|
+
* Results are cached by `src`.
|
|
57
89
|
*/
|
|
58
90
|
export declare function loadGeneratedModule(src: string): Promise<GeneratedUiModule>;
|
|
59
91
|
export interface MountGeneratedViewOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;mCAEmC;AACnC,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,OAAO;IAClD;yEACqE;IACrE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;CACT;AAED;;gEAEgE;AAChE,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,IAAI,EAAE,CAAC,CAAC;IACR;;6EAEyE;IACzE,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;IACvC,GAAG,EAAE,iBAAiB,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9C,+DAA+D;IAC/D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,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AG,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3D;AAED;kGACkG;AAClG,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,IAAI,CAqC5E;AAED;qBACqB;AACrB,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACrC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;0CAG0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,qBAAqB,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CACvF;AAeD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQ3E;AA6BD,MAAM,WAAW,yBAAyB;IACxC;;mFAE+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AASD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,yBAA8B,GACtC,qBAAqB,CA0BvB"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -8,17 +8,77 @@
|
|
|
8
8
|
* never shares a React instance with the bundle, sidestepping duplicate-React
|
|
9
9
|
* hook errors. The contract here is types + DOM glue only (no React import).
|
|
10
10
|
*/
|
|
11
|
+
/** Load an ES module from a runtime URL. Kept behind a parameter (not a literal import) so a
|
|
12
|
+
* bundler leaves it as a real dynamic import instead of trying to resolve the CDN URL at build. */
|
|
13
|
+
function importFromUrl(url) {
|
|
14
|
+
return import(/* @vite-ignore */ /* webpackIgnore: true */ url);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Attach an HLS URL (from `ctx.tts`) to a media element and make it play on every platform:
|
|
18
|
+
* native HLS where the browser supports it (Safari/iOS), else hls.js loaded on demand from the
|
|
19
|
+
* CDN (Chrome/Firefox/Android). Returns a teardown that detaches the source / destroys hls.js.
|
|
20
|
+
* This is the default `ctx.playMedia` for web (Shadow-DOM) hosts; the WebView/iframe hosts
|
|
21
|
+
* provide an equivalent inline in their bootstrap.
|
|
22
|
+
*/
|
|
23
|
+
export function attachHlsMedia(el, url) {
|
|
24
|
+
if (el.canPlayType('application/vnd.apple.mpegurl')) {
|
|
25
|
+
el.src = url;
|
|
26
|
+
return () => {
|
|
27
|
+
el.removeAttribute('src');
|
|
28
|
+
el.load();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
let destroyed = false;
|
|
32
|
+
let hls = null;
|
|
33
|
+
void importFromUrl('https://esm.sh/hls.js@1')
|
|
34
|
+
.then((mod) => {
|
|
35
|
+
if (destroyed)
|
|
36
|
+
return;
|
|
37
|
+
const Hls = (mod.default ?? mod);
|
|
38
|
+
if (!Hls?.isSupported()) {
|
|
39
|
+
el.src = url; // last resort — better than silence
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const instance = new Hls();
|
|
43
|
+
hls = instance;
|
|
44
|
+
instance.loadSource(url);
|
|
45
|
+
instance.attachMedia(el);
|
|
46
|
+
})
|
|
47
|
+
.catch(() => {
|
|
48
|
+
if (!destroyed)
|
|
49
|
+
el.src = url;
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
destroyed = true;
|
|
53
|
+
hls?.destroy();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
11
56
|
function isGeneratedUiModule(value) {
|
|
12
57
|
return typeof value?.mount === 'function';
|
|
13
58
|
}
|
|
14
59
|
function toViewHandle(result) {
|
|
15
60
|
return typeof result === 'function' ? { update: () => { }, unmount: result } : result;
|
|
16
61
|
}
|
|
62
|
+
// Cache loaded modules by source so a remount (e.g. after an in-place edit) reuses the
|
|
63
|
+
// already-imported module instead of re-creating a Blob URL and re-importing — keeping
|
|
64
|
+
// the remount a near-instant re-render rather than an async reload flash.
|
|
65
|
+
const moduleCache = new Map();
|
|
17
66
|
/**
|
|
18
67
|
* Load a generated bundle. `src` is either a URL to the ESM (served by the
|
|
19
68
|
* API/CDN) or the bundle source as a string (dynamic-imported via a Blob URL).
|
|
69
|
+
* Results are cached by `src`.
|
|
20
70
|
*/
|
|
21
|
-
export
|
|
71
|
+
export function loadGeneratedModule(src) {
|
|
72
|
+
const cached = moduleCache.get(src);
|
|
73
|
+
if (cached)
|
|
74
|
+
return cached;
|
|
75
|
+
const promise = importGeneratedModule(src);
|
|
76
|
+
moduleCache.set(src, promise);
|
|
77
|
+
// Don't cache a failed load — let a later attempt retry.
|
|
78
|
+
promise.catch(() => moduleCache.delete(src));
|
|
79
|
+
return promise;
|
|
80
|
+
}
|
|
81
|
+
async function importGeneratedModule(src) {
|
|
22
82
|
const isUrl = /^(https?:|blob:|data:|\/)/.test(src);
|
|
23
83
|
let url = src;
|
|
24
84
|
let revoke;
|
|
@@ -75,7 +135,13 @@ export function mountGeneratedView(host, mod, props, options = {}) {
|
|
|
75
135
|
handle.update(next);
|
|
76
136
|
},
|
|
77
137
|
unmount: () => {
|
|
78
|
-
|
|
138
|
+
// The host app may edit the mounted DOM in place (e.g. contenteditable), which
|
|
139
|
+
// can break the bundle framework's own teardown reconciliation. Swallow that —
|
|
140
|
+
// removing the container below discards the whole subtree regardless.
|
|
141
|
+
try {
|
|
142
|
+
handle.unmount();
|
|
143
|
+
}
|
|
144
|
+
catch { }
|
|
79
145
|
if (root.contains(container))
|
|
80
146
|
root.removeChild(container);
|
|
81
147
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
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I,GAA6B,aAAa;QAClD,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC,IAAI,CAAC;IACT,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,2EAA2E;IAC3E,IAAI,CAAC,aAAa;QAAE,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IACpD,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IACzD,OAAO;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,+EAA+E;YAC/E,+EAA+E;YAC/E,sEAAsE;YACtE,IAAI,CAAC;gBACH,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BitBitTtsRef } from '../runtime/index.js';
|
|
2
|
+
export interface BitBitMobilePreviewProps {
|
|
3
|
+
/** The mobile bundle source (Preact ESM). */
|
|
4
|
+
code: string;
|
|
5
|
+
/** Field values passed to the bundle as `props.data`. */
|
|
6
|
+
data: unknown;
|
|
7
|
+
/** Render mode override (`ctx.colorScheme`). */
|
|
8
|
+
colorScheme?: 'light' | 'dark';
|
|
9
|
+
/** Brand tokens for `ctx.theme`. Bundles bake their own colors, so usually unused. */
|
|
10
|
+
theme?: Record<string, string>;
|
|
11
|
+
/** Resolve on-demand audio for an `<audio>` player (mint a streaming URL). */
|
|
12
|
+
onTts?: (ref?: BitBitTtsRef) => Promise<string>;
|
|
13
|
+
/** Emulated device logical size (CSS px). Defaults to iPhone 15 Pro Max (430×932). */
|
|
14
|
+
deviceWidth?: number;
|
|
15
|
+
deviceHeight?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Renders a MOBILE piece bundle inside an `<iframe>` so it runs against a real phone-sized
|
|
19
|
+
* viewport: `vw`/`vh`/`100dvh`, `position: fixed`, and safe-area insets all resolve to the
|
|
20
|
+
* frame, matching the native WebView. (A Shadow-DOM mount resolves them against the desktop
|
|
21
|
+
* window instead, rendering the UI ~2-3x oversized.) It reuses the native bootstrap HTML +
|
|
22
|
+
* message protocol; only the parent side of the bridge (data/scheme in, tts out) lives here.
|
|
23
|
+
*/
|
|
24
|
+
export declare function BitBitMobilePreview({ code, data, colorScheme, theme, onTts, deviceWidth, deviceHeight, }: BitBitMobilePreviewProps): import("react").DetailedReactHTMLElement<{
|
|
25
|
+
ref: import("react").RefObject<HTMLDivElement>;
|
|
26
|
+
style: {
|
|
27
|
+
position: "relative";
|
|
28
|
+
width: string;
|
|
29
|
+
height: string;
|
|
30
|
+
overflow: "hidden";
|
|
31
|
+
};
|
|
32
|
+
}, HTMLDivElement>;
|
|
33
|
+
//# sourceMappingURL=BitBitMobilePreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitBitMobilePreview.d.ts","sourceRoot":"","sources":["../../src/studio/BitBitMobilePreview.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,MAAM,WAAW,wBAAwB;IACvC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAC;IACd,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,sFAAsF;IACtF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,8EAA8E;IAC9E,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,KAAK,EACL,KAAK,EACL,WAA0B,EAC1B,YAA4B,GAC7B,EAAE,wBAAwB;;;;;;;;mBAiI1B"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createElement, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { buildBootstrapHtml } from '../react-native-expo/bootstrapHtml.js';
|
|
3
|
+
/** iPhone 15 Pro Max logical viewport (CSS px) — the emulated device. A `<meta viewport>`
|
|
4
|
+
* is ignored inside a desktop iframe, so the ONLY way the bundle sees a real phone-width
|
|
5
|
+
* viewport is to size the iframe to these exact dimensions and scale it down to fit. */
|
|
6
|
+
const DEVICE_WIDTH = 430;
|
|
7
|
+
const DEVICE_HEIGHT = 932;
|
|
8
|
+
/**
|
|
9
|
+
* Renders a MOBILE piece bundle inside an `<iframe>` so it runs against a real phone-sized
|
|
10
|
+
* viewport: `vw`/`vh`/`100dvh`, `position: fixed`, and safe-area insets all resolve to the
|
|
11
|
+
* frame, matching the native WebView. (A Shadow-DOM mount resolves them against the desktop
|
|
12
|
+
* window instead, rendering the UI ~2-3x oversized.) It reuses the native bootstrap HTML +
|
|
13
|
+
* message protocol; only the parent side of the bridge (data/scheme in, tts out) lives here.
|
|
14
|
+
*/
|
|
15
|
+
export function BitBitMobilePreview({ code, data, colorScheme, theme, onTts, deviceWidth = DEVICE_WIDTH, deviceHeight = DEVICE_HEIGHT, }) {
|
|
16
|
+
const iframeRef = useRef(null);
|
|
17
|
+
const wrapperRef = useRef(null);
|
|
18
|
+
const dataRef = useRef(data);
|
|
19
|
+
dataRef.current = data;
|
|
20
|
+
const onTtsRef = useRef(onTts);
|
|
21
|
+
onTtsRef.current = onTts;
|
|
22
|
+
const readyRef = useRef(false);
|
|
23
|
+
// Fit the fixed-resolution device into whatever space the frame gives us.
|
|
24
|
+
const [scale, setScale] = useState(1);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const el = wrapperRef.current;
|
|
27
|
+
if (!el)
|
|
28
|
+
return;
|
|
29
|
+
const measure = () => {
|
|
30
|
+
const { width, height } = el.getBoundingClientRect();
|
|
31
|
+
if (width > 0 && height > 0)
|
|
32
|
+
setScale(Math.min(width / deviceWidth, height / deviceHeight));
|
|
33
|
+
};
|
|
34
|
+
measure();
|
|
35
|
+
const observer = new ResizeObserver(measure);
|
|
36
|
+
observer.observe(el);
|
|
37
|
+
return () => observer.disconnect();
|
|
38
|
+
}, [deviceWidth, deviceHeight]);
|
|
39
|
+
// Rebuilt only when the bundle changes (which reloads the iframe). `colorScheme` is baked as
|
|
40
|
+
// the initial value and updated live via postMessage after, so a scheme toggle doesn't reload.
|
|
41
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: bake initial scheme/tts, update live
|
|
42
|
+
const srcDoc = useMemo(() => buildBootstrapHtml({
|
|
43
|
+
bundle: code,
|
|
44
|
+
theme: theme ?? {},
|
|
45
|
+
...(colorScheme ? { colorScheme } : {}),
|
|
46
|
+
enableTts: onTtsRef.current != null,
|
|
47
|
+
autoHeight: false,
|
|
48
|
+
}), [code]);
|
|
49
|
+
// A reload (new bundle) starts a fresh document — don't push to it until it re-signals ready.
|
|
50
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: code is a deliberate reset trigger — a new bundle reloads the iframe, so readyRef must clear until it re-signals ready.
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
readyRef.current = false;
|
|
53
|
+
}, [code]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const send = (m) => iframeRef.current?.contentWindow?.postMessage(m, '*');
|
|
56
|
+
const onMessage = (e) => {
|
|
57
|
+
if (e.source !== iframeRef.current?.contentWindow)
|
|
58
|
+
return;
|
|
59
|
+
const m = e.data;
|
|
60
|
+
if (!m || typeof m !== 'object')
|
|
61
|
+
return;
|
|
62
|
+
if (m.kind === 'ready') {
|
|
63
|
+
readyRef.current = true;
|
|
64
|
+
send({ kind: 'update', data: dataRef.current });
|
|
65
|
+
}
|
|
66
|
+
else if (m.kind === 'tts') {
|
|
67
|
+
const fn = onTtsRef.current;
|
|
68
|
+
const id = m.id;
|
|
69
|
+
if (!fn) {
|
|
70
|
+
send({ kind: 'resolveTts', id, error: 'Audio unavailable' });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
Promise.resolve(fn(m.ref)).then((url) => send({ kind: 'resolveTts', id, url }), (err) => send({
|
|
74
|
+
kind: 'resolveTts',
|
|
75
|
+
id,
|
|
76
|
+
error: err instanceof Error ? err.message : 'Could not load audio',
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
window.addEventListener('message', onMessage);
|
|
81
|
+
return () => window.removeEventListener('message', onMessage);
|
|
82
|
+
}, []);
|
|
83
|
+
// Push fresh field values once the iframe is ready, and on every change after.
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (readyRef.current)
|
|
86
|
+
iframeRef.current?.contentWindow?.postMessage({ kind: 'update', data }, '*');
|
|
87
|
+
}, [data]);
|
|
88
|
+
// Live light/dark without reloading.
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (readyRef.current)
|
|
91
|
+
iframeRef.current?.contentWindow?.postMessage({ kind: 'setColorScheme', scheme: colorScheme ?? null }, '*');
|
|
92
|
+
}, [colorScheme]);
|
|
93
|
+
// The iframe renders at the device's real resolution (so the bundle sees a 430px viewport);
|
|
94
|
+
// a centered scale() shrinks it to fit the frame without touching the internal layout.
|
|
95
|
+
return createElement('div', {
|
|
96
|
+
ref: wrapperRef,
|
|
97
|
+
style: {
|
|
98
|
+
position: 'relative',
|
|
99
|
+
width: '100%',
|
|
100
|
+
height: '100%',
|
|
101
|
+
overflow: 'hidden',
|
|
102
|
+
},
|
|
103
|
+
}, createElement('div', {
|
|
104
|
+
style: {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
top: '50%',
|
|
107
|
+
left: '50%',
|
|
108
|
+
width: deviceWidth,
|
|
109
|
+
height: deviceHeight,
|
|
110
|
+
transform: `translate(-50%, -50%) scale(${scale})`,
|
|
111
|
+
transformOrigin: 'center center',
|
|
112
|
+
},
|
|
113
|
+
}, createElement('iframe', {
|
|
114
|
+
ref: iframeRef,
|
|
115
|
+
srcDoc,
|
|
116
|
+
title: 'Mobile preview',
|
|
117
|
+
style: { width: '100%', height: '100%', border: '0', display: 'block' },
|
|
118
|
+
})));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=BitBitMobilePreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitBitMobilePreview.js","sourceRoot":"","sources":["../../src/studio/BitBitMobilePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E;;yFAEyF;AACzF,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,aAAa,GAAG,GAAG,CAAC;AAkB1B;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,KAAK,EACL,KAAK,EACL,WAAW,GAAG,YAAY,EAC1B,YAAY,GAAG,aAAa,GACH;I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CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,4FAA4F;IAC5F,uFAAuF;IACvF,OAAO,aAAa,CAClB,KAAK,EACL;QACE,GAAG,EAAE,UAAU;QACf,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,QAAQ;SACnB;KACF,EACD,aAAa,CACX,KAAK,EACL;QACE,KAAK,EAAE;YACL,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE,+BAA+B,KAAK,GAAG;YAClD,eAAe,EAAE,eAAe;SACjC;KACF,EACD,aAAa,CAAC,QAAQ,EAAE;QACtB,GAAG,EAAE,SAAS;QACd,MAAM;QACN,KAAK,EAAE,gBAAgB;QACvB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;KACxE,CAAC,CACH,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Studio-only entry (`@bitbitpress/client/studio`) — first-party authoring tools for the
|
|
3
|
+
* BitBit studio, NOT part of the customer-facing runtime. Kept in this package (not bitbit-web)
|
|
4
|
+
* so the mobile preview stays byte-faithful to the native WebView bootstrap it reuses.
|
|
5
|
+
*/
|
|
6
|
+
export { BitBitMobilePreview, type BitBitMobilePreviewProps, } from './BitBitMobilePreview.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/studio/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Studio-only entry (`@bitbitpress/client/studio`) — first-party authoring tools for the
|
|
3
|
+
* BitBit studio, NOT part of the customer-facing runtime. Kept in this package (not bitbit-web)
|
|
4
|
+
* so the mobile preview stays byte-faithful to the native WebView bootstrap it reuses.
|
|
5
|
+
*/
|
|
6
|
+
export { BitBitMobilePreview, } from './BitBitMobilePreview.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/studio/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,mBAAmB,GAEpB,MAAM,0BAA0B,CAAC"}
|
|
@@ -12,6 +12,9 @@ export type SynthesisUiStreamEvent = {
|
|
|
12
12
|
type: 'data';
|
|
13
13
|
data: unknown;
|
|
14
14
|
complete: boolean;
|
|
15
|
+
/** The stored output this data was synthesized into — the key `<BitBitView>`
|
|
16
|
+
* mints on-request audio against (`ctx.tts`). */
|
|
17
|
+
synthesisOutputId?: string;
|
|
15
18
|
/** Recent prior outputs (when `synthesisHistoryLimit > 0`), most-recent
|
|
16
19
|
* first. Forwarded into the view's `history` prop. */
|
|
17
20
|
synthesisHistoryEntries?: SynthesisUiHistoryEntry[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/synthesisUi/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEnD;6DAC6D;AAC7D,MAAM,MAAM,sBAAsB,GAC9B;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,G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