diff --git a/scripthaus.md b/scripthaus.md index 7ff3fe49..10d5fdf1 100644 --- a/scripthaus.md +++ b/scripthaus.md @@ -49,6 +49,12 @@ node_modules/.bin/webpack-dev-server --config webpack.dev.js --host 0.0.0.0 node_modules/.bin/webpack-dev-server --config webpack.share.dev.js --host 127.0.0.1 ``` +```bash +# @scripthaus command webshare-build +# @scripthaus cd :playbook +node_modules/.bin/webpack --config webpack.share.dev.js +``` + ```bash # @scripthaus command typecheck # @scripthaus cd :playbook @@ -121,3 +127,11 @@ rm *.dmg $DMG_NAME \ "out/Prompt-darwin-arm64/Prompt.app" ``` + +```bash +# @scripthaus command sync-webshare-dev +# @scripthaus cd :playbook +aws --profile prompt-s3 s3 cp webshare/static/index.html s3://prompt-devshare-static/ --cache-control 'public, max-age=600, s-maxage=300, stale-if-error=60' +aws --profile prompt-s3 s3 sync webshare/static s3://prompt-devshare-static/static --cache-control 'public, max-age=600, s-maxage=300, stale-if-error=60' +aws --profile prompt-s3 s3 sync webshare/dist-dev s3://prompt-devshare-static/ --cache-control 'public, max-age=600, s-maxage=300, stale-if-error=60' +``` diff --git a/src/main.tsx b/src/main.tsx index 94bb685d..94675d8b 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1830,7 +1830,7 @@ class ScreenWindowView extends React.Component<{screen : Screen}, {}> { - +
@@ -1987,7 +1987,7 @@ class ScreenTabs extends React.Component<{session : Session}, {}> {
this.handleSwitchScreen(screen.screenId)} onContextMenu={(event) => this.openScreenSettings(event, screen)}> - + {screen.name.get()}
{renderCmdText(String(index+1))}
diff --git a/src/model.ts b/src/model.ts index 71020872..82aae3ef 100644 --- a/src/model.ts +++ b/src/model.ts @@ -259,7 +259,7 @@ class Screen { dispose() { } - isWebShare() : boolean { + isWebShared() : boolean { return (this.shareMode.get() == "web") && (this.webShareOpts.get() != null); } @@ -3202,6 +3202,12 @@ class CommandRunner { GlobalModel.submitCommand("screen", "archive", [screenId, (shouldArchive ? "1" : "0")], {"nohist": "1"}, false); } + screenWebShare(screenId : string, shouldShare : boolean) { + let kwargs : Record = {"nohist": "1"}; + kwargs["screen"] = screenId; + GlobalModel.submitCommand("screen", "webshare", [(shouldShare ? "1" : "0")], kwargs, true); + } + showRemote(remoteid : string) { GlobalModel.submitCommand("remote", "show", null, {"nohist": "1", "remote": remoteid}, true); } diff --git a/src/settings.tsx b/src/settings.tsx index 60e04efe..dcf1765d 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -25,6 +25,8 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId tempName : OV; tempTabColor : OV; tempArchived : OV; + tempWebShared : OV; + shareCopied : OV = mobx.observable.box(false, {name: "sw-shareCopied"}); constructor(props : any) { super(props); @@ -36,6 +38,7 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId this.tempName = mobx.observable.box(screen.name.get(), {name: "screenSettings-tempName"}); this.tempTabColor = mobx.observable.box(screen.getTabColor(), {name: "screenSettings-tempTabColor"}); this.tempArchived = mobx.observable.box(screen.archived.get(), {name: "screenSettings-tempArchived"}); + this.tempWebShared = mobx.observable.box(screen.isWebShared(), {name: "screenSettings-tempWebShare"}); } @boundMethod @@ -67,6 +70,9 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId if (this.tempArchived.get() != screen.archived.get()) { GlobalCommandRunner.screenArchive(screen.screenId, this.tempArchived.get()); } + if (this.tempWebShared.get() != screen.isWebShared()) { + GlobalCommandRunner.screenWebShare(screen.screenId, this.tempWebShared.get()); + } } @boundMethod @@ -90,6 +96,44 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId })(); } + @boundMethod + handleChangeWebShare(val : boolean) : void { + mobx.action(() => { + this.tempWebShared.set(val); + })(); + } + + @boundMethod + copyShareLink() : void { + let {sessionId, screenId} = this.props; + let screen = GlobalModel.getScreenById(sessionId, screenId); + if (screen == null) { + return null; + } + let shareLink = screen.getWebShareUrl(); + if (shareLink == null) { + return; + } + navigator.clipboard.writeText(shareLink); + mobx.action(() => { + this.shareCopied.set(true); + })(); + setTimeout(() => { + mobx.action(() => { + this.shareCopied.set(false); + })(); + }, 600) + } + + webSharedUpdated() : boolean { + let {sessionId, screenId} = this.props; + let screen = GlobalModel.getScreenById(sessionId, screenId); + if (screen == null) { + return null; + } + return screen.isWebShared() != this.tempWebShared.get(); + } + render() { let {sessionId, screenId} = this.props; let screen = GlobalModel.getScreenById(sessionId, screenId); @@ -101,6 +145,9 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
+ +
+
screen settings ({screen.name.get()})
@@ -159,6 +206,27 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
+
+
+ Web Shared +
+
+ +
+ will be web-shared + will stop being web-shared + +
+ copy share link + + + +
+
+
+ +
+