Skip to content

Commit

Permalink
🚧 Support match arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Dec 14, 2023
1 parent 4166d60 commit ff33991
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 60 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-svelte": "^3.0.3",
"style-loader": "^3.3.3",
"svelte": "^4.2.1",
"svelte": "^4.2.8",
"svelte-loader": "^3.1.9",
"svelte-preprocess": "^5.0.4",
"svelte-preprocess": "^5.1.2",
"svelte-sequential-preprocessor": "^2.0.1",
"ts-loader": "^9.5.0",
"typescript": "^5.2.2",
Expand All @@ -78,7 +78,7 @@
},
"pnpm": {
"patchedDependencies": {
"[email protected].1": "patches/[email protected]",
"[email protected].8": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"@melt-ui/[email protected]": "patches/@[email protected]"
}
Expand Down
58 changes: 29 additions & 29 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
getSrcFile,
} from './lib/constants.js'
import { setupFiles } from './lib/files.js'
import { linkFolder, linkStaticFolder, linkTscFolder } from './lib/linker.js'
import { linkStaticFolder, linkTscFolder } from './lib/linker.js'
import { failure, info } from './lib/logging.js'
import { downloadReleaseAsset, getLatestRelease } from './lib/releases.js'

Expand Down
4 changes: 2 additions & 2 deletions src/content/browser/Browser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import CustomizableUi from './components/customizableUI/CustomizableUI.svelte'
import { BrowserContextMenu, HamburgerMenu } from './components/menus'
import Keybindings from './components/keybindings/Keybindings.svelte'
import { tabs, selectedTab } from './lib/window/tabs'
import { tabs, selectedTabId } from './lib/window/tabs'
let component = customizableUIDynamicPref('browser.uiCustomization.state')
$: currentTab = $tabs.find((tab) => tab.getId() == $selectedTab)
$: currentTab = $tabs.find((tab) => tab.getId() == $selectedTabId)
</script>

{#if currentTab}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
} from '@shared/customizableUI'
import UiItemBase from './UIItemBase.svelte'
import Browser from '../Browser.svelte'
import { selectedTab, tabs } from '@browser/lib/window/tabs'
import { selectedTabId, tabs } from '@browser/lib/window/tabs'
export let component: ComponentId & BrowserComponent
export let root: Component
Expand All @@ -24,6 +24,6 @@

<UiItemBase {component} {root}>
{#each sortedBrowers as tab (tab.getId())}
<Browser {tab} selectedTab={$selectedTab} />
<Browser {tab} selectedTab={$selectedTabId} />
{/each}
</UiItemBase>
4 changes: 2 additions & 2 deletions src/content/browser/components/customizableUI/Tabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import Tab from '@browser/components/tabs/Tab.svelte'
import UiItemBase from './UIItemBase.svelte'
import { selectedTab, tabs } from '@browser/lib/window/tabs'
import { selectedTabId, tabs } from '@browser/lib/window/tabs'
export let component: ComponentId & TabsComponent
export let root: Component
</script>

<UiItemBase {component} {root} class="tabs" on:drop={(e) => e.preventDefault()}>
{#each $tabs as tab (tab.getId())}
<Tab {tab} bind:selectedTab={$selectedTab} />
<Tab {tab} bind:selectedTab={$selectedTabId} />
{/each}
</UiItemBase>

Expand Down
4 changes: 3 additions & 1 deletion src/content/browser/components/omnibox/Omnibox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
/>

{#each $pageActions as [_extId, pageAction]}
<PageAction {pageAction} />
{#if pageAction.shouldShow($uri.asciiSpec)}
<PageAction {pageAction} />
{/if}
{/each}

<Bookmarks {tab} />
Expand Down
4 changes: 4 additions & 0 deletions src/content/browser/components/omnibox/PageAction.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<script lang="ts">
import type { PageAction } from 'resource://app/modules/EPageActions.sys.mjs'
import ToolbarButton from '@shared/components/ToolbarButton.svelte'
Expand Down
7 changes: 5 additions & 2 deletions src/content/browser/lib/modules/EPageActionsBindings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { readable } from 'svelte/store'

import { resource } from '../resources'
Expand All @@ -6,9 +9,9 @@ import { resource } from '../resources'
* @todo lazy loading store
*/
export const pageActions = readable(
resource.EPageActions.pageActions.entries(),
[...resource.EPageActions.pageActions.entries()],
(set) => {
const update = () => set(resource.EPageActions.pageActions.entries())
const update = () => set([...resource.EPageActions.pageActions.entries()])
resource.EPageActions.events.on('*', update)
return () => resource.EPageActions.events.off('*', update)
},
Expand Down
12 changes: 6 additions & 6 deletions src/content/browser/lib/window/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { resource } from '../resources'
import { Tab } from './tab'

let internalSelectedTab = -1
export const selectedTab = writable(-1)
selectedTab.subscribe((v) => (internalSelectedTab = v))
export const selectedTabId = writable(-1)
selectedTabId.subscribe((v) => (internalSelectedTab = v))

const uriPref = (pref: string) => (): nsIURIType =>
resource.NetUtil.newURI(Services.prefs.getStringPref(pref, 'about:blank'))
Expand All @@ -22,7 +22,7 @@ export const tabs = viewableWritable<Tab[]>([])
export function openTab(uri: nsIURIType = newTabUri()) {
const newTab = new Tab(uri)
tabs.update((tabs) => {
selectedTab.set(newTab.getId())
selectedTabId.set(newTab.getId())
return [...tabs, newTab]
})
return newTab
Expand All @@ -39,9 +39,9 @@ export function closeTab(tab: Tab) {
}

if (filtered[tabIndex]) {
selectedTab.set(filtered[tabIndex].getId())
selectedTabId.set(filtered[tabIndex].getId())
} else {
selectedTab.set(filtered[tabIndex - 1].getId())
selectedTabId.set(filtered[tabIndex - 1].getId())
}

tab.destroy()
Expand Down Expand Up @@ -78,7 +78,7 @@ export function setCurrentTabIndex(index: number) {
if (index < 0) index = allTabs.length - 1
if (index >= allTabs.length) index = 0

selectedTab.set(allTabs[index].getId())
selectedTabId.set(allTabs[index].getId())
}

export function moveTabBefore(toMoveId: number, targetId: number) {
Expand Down
Loading

0 comments on commit ff33991

Please sign in to comment.