Skip to content

Commit

Permalink
v2.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
solvedDev authored Nov 5, 2022
2 parents 151fffc + 093d64d commit cd10f76
Show file tree
Hide file tree
Showing 20 changed files with 188 additions and 28 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bridge",
"version": "2.3.6",
"version": "2.3.7",
"private": true,
"scripts": {
"dev": "vite",
Expand All @@ -15,7 +15,7 @@
"@mdi/font": "^6.9.96",
"@types/lz-string": "^1.3.34",
"bridge-common-utils": "^0.3.3",
"bridge-iframe-api": "^0.4.7",
"bridge-iframe-api": "^0.4.11",
"bridge-js-runtime": "^0.3.6",
"bridge-model-viewer": "^0.7.7",
"buffer": "^6.0.3",
Expand Down
Binary file modified public/packages.zip
Binary file not shown.
21 changes: 18 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<template>
<v-app
ref="appContainer"
:style="{ fontFamily }"
@contextmenu.native="$event.preventDefault()"
>
<!-- We need access to native menus in order to hide the custom one on MacOS -->
<!-- <Toolbar v-if="!isMacOs" /> -->
<Toolbar />
<Toolbar v-if="!isInFullScreen" />

<Sidebar app />
<Sidebar v-if="!isInFullScreen" app />

<v-btn
v-if="!sidebarNavigationVisible"
Expand All @@ -23,7 +24,11 @@
<v-icon>mdi-table-column</v-icon>
</v-btn>

<v-main :style="{ 'padding-top': appToolbarHeight }">
<v-main
:style="{
'padding-top': isInFullScreen ? 0 : appToolbarHeight,
}"
>
<WindowRenderer />

<v-row
Expand Down Expand Up @@ -111,6 +116,10 @@ import WelcomeScreen from '/@/components/TabSystem/WelcomeScreen.vue'
import SidebarContent from './components/Sidebar/Content/Main.vue'
import { settingsState } from './components/Windows/Settings/SettingsState'
import { useTabSystem } from './components/Composables/UseTabSystem'
import {
setFullscreenElement,
useFullScreen,
} from './components/TabSystem/TabContextMenu/Fullscreen'
export default {
name: 'App',
Expand All @@ -119,11 +128,13 @@ export default {
setup() {
const { tabSystem, tabSystems, shouldRenderWelcomeScreen } =
useTabSystem()
const { isInFullScreen } = useFullScreen()
return {
tabSystem,
tabSystems,
shouldRenderWelcomeScreen,
isInFullScreen,
}
},
Expand All @@ -132,6 +143,8 @@ export default {
this.contextMenu = app.contextMenu
this.windowSize = app.windowResize.state
})
setFullscreenElement(this.$refs.appContainer.$el)
},
components: {
Expand All @@ -156,6 +169,8 @@ export default {
computed: {
isSidebarContentVisible() {
if (this.isInFullScreen) return false
return (
this.sidebarNavigationVisible &&
App.sidebar.isContentVisible.value
Expand Down
5 changes: 2 additions & 3 deletions src/components/CommandBar/CommandBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ export default {
color: packType?.color ?? 'primary',
onTrigger: async () => {
const fileHandle = await project.app.fileSystem.getFileHandle(
filePath
)
const fileHandle =
await project.app.fileSystem.getFileHandle(filePath)
project.openFile(fileHandle)
},
Expand Down
10 changes: 10 additions & 0 deletions src/components/Editors/IframeTab/API/IframeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { IframeTab } from '../IframeTab'
import { OpenFileEvent } from './Events/Tab/OpenFile'
import { openedFileReferenceName } from './Requests/FileSystem/ResolveFileReference'
import { GetItemPreviewRequest } from './Requests/Project/GetItemPreview'
import { ReadAsDataUrlRequest } from './Requests/FileSystem/ReadAsDataUrl'
import { FindRequest } from './Requests/PackIndexer/Find'
import { GetFileRequest } from './Requests/PackIndexer/GetFile'
import { wait } from '/@/utils/wait'

export class IframeApi {
didSetup = false
Expand All @@ -28,10 +32,15 @@ export class IframeApi {
// FileSystem
new ReadFileRequest(this),
new ReadTextFileRequest(this),
new ReadAsDataUrlRequest(this),
new WriteFileRequest(this),

// Project
new GetItemPreviewRequest(this),

// PackIndexer,
new FindRequest(this),
new GetFileRequest(this),
]

constructor(protected tab: IframeTab, protected iframe: HTMLIFrameElement) {
Expand All @@ -41,6 +50,7 @@ export class IframeApi {
this._channel = new Channel(this.iframe.contentWindow)
this.channelSetup.dispatch()

await wait(20)
await this.channel.open()

this.loaded.dispatch()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IframeApi } from '../../IframeApi'
import { GenericRequest } from '../GenericRequest'
import { resolveFileReference } from './ResolveFileReference'
import { loadHandleAsDataURL } from '/@/utils/loadAsDataUrl'

export class ReadAsDataUrlRequest extends GenericRequest<string, string> {
constructor(api: IframeApi) {
super('fs.readAsDataUrl', api)
}

async handle(filePath: string, origin: string): Promise<string> {
const fileHandle = await resolveFileReference(filePath, this.api)

return await loadHandleAsDataURL(fileHandle)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export const openedFileReferenceName = '~bridge://OPENED-FILE'

export async function resolveFileReference(
fileReference: string,
api: IframeApi
api: IframeApi,
createFile = false
) {
if (fileReference === openedFileReferenceName) {
const fileHandle = api.openedFileHandle
Expand All @@ -14,5 +15,5 @@ export async function resolveFileReference(
return fileHandle
}

return await api.app.fileSystem.getFileHandle(fileReference)
return await api.app.fileSystem.getFileHandle(fileReference, createFile)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class WriteFileRequest extends GenericRequest<IWriteFilePayload, void> {
): Promise<void> {
const app = await App.getApp()

const fileHandle = await resolveFileReference(filePath, this.api)
const fileHandle = await resolveFileReference(filePath, this.api, true)

await app.fileSystem.write(fileHandle, data)
}
Expand Down
30 changes: 30 additions & 0 deletions src/components/Editors/IframeTab/API/Requests/PackIndexer/Find.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { IframeApi } from '../../IframeApi'
import { GenericRequest } from '../GenericRequest'

interface IRequestData {
findFileType: string
whereCacheKey: string
matchesOneOf: string[]
fetchAll?: boolean
}

export class FindRequest extends GenericRequest<IRequestData, string[]> {
constructor(api: IframeApi) {
super('packIndexer.find', api)
}

async handle(
{ findFileType, whereCacheKey, matchesOneOf, fetchAll }: IRequestData,
origin: string
) {
const packIndexer = this.api.app.project.packIndexer
await packIndexer.fired

return await packIndexer.service.find(
findFileType,
whereCacheKey,
matchesOneOf,
fetchAll
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { IframeApi } from '../../IframeApi'
import { GenericRequest } from '../GenericRequest'
import { App } from '/@/App'

export class GetFileRequest extends GenericRequest<
string,
Record<string, unknown>
> {
constructor(api: IframeApi) {
super('packIndexer.getFile', api)
}

async handle(filePath: string, origin: string) {
const packIndexer = this.api.app.project.packIndexer
await packIndexer.fired

const fileType = App.fileType.getId(filePath)

return await packIndexer.service.getCacheDataFor(fileType, filePath)
}
}
5 changes: 3 additions & 2 deletions src/components/Editors/IframeTab/IframeTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Tab } from '../../TabSystem/CommonTab'
import { IframeApi } from './API/IframeApi'
import { markRaw } from 'vue'
import { AnyFileHandle } from '../../FileSystem/Types'
import { getFullScreenElement } from '../../TabSystem/TabContextMenu/Fullscreen'

interface IIframeTabOptions {
icon?: string
Expand Down Expand Up @@ -46,7 +47,7 @@ export class IframeTab extends Tab {
this.iframe.classList.add('outlined')
this.iframe.style.borderRadius = '12px'
this.iframe.style.margin = '8px'
document.body.appendChild(this.iframe)
getFullScreenElement()?.appendChild(this.iframe)
}

getOptions() {
Expand All @@ -71,7 +72,7 @@ export class IframeTab extends Tab {
this.iframe.style.display = 'none'
}
onDestroy() {
document.body.removeChild(this.iframe)
getFullScreenElement()?.removeChild(this.iframe)
this.api.dispose()
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/Mixins/AppToolbarHeight.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// @ts-nocheck

import { WindowControlsOverlayMixin } from './WindowControlsOverlay'
import { isInFullScreen } from '/@/components/TabSystem/TabContextMenu/Fullscreen'

export const AppToolbarHeightMixin = {
mixins: [WindowControlsOverlayMixin],
computed: {
appToolbarHeight() {
if (isInFullScreen.value) return `0px`

return `env(titlebar-area-height, ${
this.$vuetify.breakpoint.mobile ? 0 : 24
}px)`
},
appToolbarHeightNumber() {
if (isInFullScreen.value) return 0
if (this.windowControlsOverlay) return 33

return this.$vuetify.breakpoint.mobile ? 0 : 24
Expand Down
2 changes: 2 additions & 0 deletions src/components/TabSystem/CommonTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AnyFileHandle } from '../FileSystem/Types'
import { shareFile } from '../StartParams/Action/openRawFile'
import { getDefaultFileIcon } from '/@/utils/file/getIcon'
import { settingsState } from '../Windows/Settings/SettingsState'
import { fullScreenAction } from './TabContextMenu/Fullscreen'

export abstract class Tab<TRestoreData = any> extends Signal<Tab> {
abstract component: Vue.Component
Expand Down Expand Up @@ -210,6 +211,7 @@ export abstract class Tab<TRestoreData = any> extends Signal<Tab> {
additionalItems.push(<const>{ type: 'divider' })

await showContextMenu(event, [
fullScreenAction(false),
...additionalItems,
{
name: 'actions.closeTab.name',
Expand Down
14 changes: 10 additions & 4 deletions src/components/TabSystem/TabActions/ActionBar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<div
class="d-inline-flex mb-1"
style="height: 21px; width: 100%; overflow-x: auto; overflow-y: hidden"
>
<div class="d-inline-flex mb-1 tab-action-bar" style="">
<Action
v-for="action in actions"
:key="action.id"
Expand All @@ -22,3 +19,12 @@ export default {
},
}
</script>

<style scoped>
.tab-action-bar {
height: 21px;
width: 100%;
overflow-x: auto;
overflow-y: hidden;
}
</style>
5 changes: 4 additions & 1 deletion src/components/TabSystem/TabBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div class="tab-bar">
<Draggable
v-if="tabSystem && tabSystem.shouldRender"
v-model="tabSystem.tabs.value"
Expand Down Expand Up @@ -84,4 +84,7 @@ export default {
.inactive-action-bar {
opacity: 0.5;
}
.tab-bar {
background: var(--v-background-base);
}
</style>
Loading

0 comments on commit cd10f76

Please sign in to comment.