mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-13 18:34:51 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ce24e63b2 |
No files matched your search
@@ -70,6 +70,21 @@ describe('app browser embed shell', () => {
|
||||
expect(html).not.toContain('gui(');
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{}, '/dist/apps-embed.min.js'],
|
||||
[
|
||||
{ gui_bundle: 'https://gui-cdn.deployment.test/bundle.min.js' },
|
||||
'https://gui-cdn.deployment.test/apps-embed.min.js',
|
||||
],
|
||||
[
|
||||
{ gui_bundle: '/static/bundle.min.js?v=42' },
|
||||
'/static/apps-embed.min.js?v=42',
|
||||
],
|
||||
])('loads its script from beside the GUI bundle %j', (config, script) => {
|
||||
const html = makeService(config).renderAppBrowserEmbed();
|
||||
expect(html).toContain(`<script defer src="${script}"></script>`);
|
||||
});
|
||||
|
||||
it('escapes configured values without breaking its JSON bootstrap', () => {
|
||||
const sdkUrl = '/sdk.js?value=</script><script>unexpected()</script>';
|
||||
const html = makeService({
|
||||
|
||||
@@ -191,11 +191,28 @@ export class PuterHomepageService extends PuterService {
|
||||
<body>
|
||||
<main id="app-browser" class="dashboard"></main>
|
||||
<script type="application/json" id="app-browser-config">${configJson}</script>
|
||||
<script defer src="/dist/apps-embed.min.js"></script>
|
||||
<script defer src="${encode(this.#appBrowserEmbedScript())}"></script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The embed's script is built beside the GUI bundle, so it is served from
|
||||
* wherever `gui_bundle` is (a CDN in production), with the same query.
|
||||
*/
|
||||
#appBrowserEmbedScript(): string {
|
||||
const base = 'http://relative.invalid';
|
||||
const bundle = new URL(
|
||||
this.config.gui_bundle ?? '/dist/bundle.min.js',
|
||||
base,
|
||||
);
|
||||
const script = new URL('apps-embed.min.js', bundle);
|
||||
script.search = bundle.search;
|
||||
return script.origin === base
|
||||
? `${script.pathname}${script.search}`
|
||||
: script.href;
|
||||
}
|
||||
|
||||
/** `scriptPath` is a same-origin absolute path, like `/ext/push/worker.js`. */
|
||||
registerServiceWorkerScript(scriptPath: string): void {
|
||||
if (
|
||||
|
||||
@@ -256,12 +256,7 @@ export interface IPreludeConfig {
|
||||
* an RCS agent provisioned in the Prelude account to actually use RCS.
|
||||
*/
|
||||
preferredChannel?:
|
||||
| 'sms'
|
||||
| 'rcs'
|
||||
| 'whatsapp'
|
||||
| 'viber'
|
||||
| 'zalo'
|
||||
| 'telegram';
|
||||
'sms' | 'rcs' | 'whatsapp' | 'viber' | 'zalo' | 'telegram';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1106,7 +1101,10 @@ interface IConfigOptional {
|
||||
builtin_apps: Record<string, string>;
|
||||
/** Force the bundled GUI even in dev. Default: false. */
|
||||
use_bundled_gui: boolean;
|
||||
/** Override the GUI bundle JS path. Default: `/dist/bundle.min.js`. */
|
||||
/**
|
||||
* Override the GUI bundle JS path. Default: `/dist/bundle.min.js`. The app
|
||||
* browser embed loads `apps-embed.min.js` from the same directory.
|
||||
*/
|
||||
gui_bundle: string;
|
||||
/** Override the GUI CSS path when bundled. Default: `/dist/bundle.min.css`. */
|
||||
gui_css: string;
|
||||
@@ -1393,7 +1391,8 @@ export interface ServerDrainInfo {
|
||||
}
|
||||
|
||||
export interface WithCostsReporting extends WithLifecycle {
|
||||
getReportedCosts?: () => // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
getReportedCosts?: () =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| Promise<Record<string, any>[]>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| Record<string, any>[];
|
||||
|
||||
Reference in new issue
Block a user