Skip to content

Commit

Permalink
feat: rename SlidevSync to BuiltinSync
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 27, 2024
1 parent 599738c commit 3a3cf6a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
28 changes: 20 additions & 8 deletions packages/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
export { useDarkMode } from './composables/useDarkMode'
export { useDrawings } from './composables/useDrawings'
export { useNav } from './composables/useNav'
/**
* This file is the public APIs that you might use in your app.
*
* The other files despite they are accessable, are not meant to be used directly, breaking changes might happen.
*/

export { useDarkMode } from './composables/useDarkMode'
export { useDrawings } from './composables/useDrawings'
export { useNav } from './composables/useNav'

export { useSlideContext } from './context'

export * from './env'
export * from './layoutHelper'

export {
onSlideEnter,
onSlideLeave,
useIsSlideActive,
} from './logic/slides'

export { createSyncState, disableSlidevSync, addSyncMethod } from './state/syncState'
export { onDrawingUpdate, drawingState } from './state/drawings'
export { onSharedUpdate, sharedState } from './state/shared'
export type { DrawingsState } from './state/drawings'
export { drawingState, onDrawingUpdate } from './state/drawings'
export type { SharedState } from './state/shared'
export { onSharedUpdate, sharedState } from './state/shared'

export * from './layoutHelper'
export { onSlideEnter, onSlideLeave, useIsSlideActive } from './logic/slides'
export {
addSyncMethod,
createSyncState,
disableBuiltinSync,
} from './state/syncState'
10 changes: 5 additions & 5 deletions packages/client/state/syncState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export interface Sync {
init: <State extends object>(channelKey: string, onUpdate: (data: Partial<State>) => void, state: State, persist?: boolean) => SyncWrite<State> | undefined
}

interface SlidevSync extends Sync {
interface BuiltinSync extends Sync {
channels: BroadcastChannel[]
disable: () => void
listener?: (event: StorageEvent) => void
}

const slidevSync: SlidevSync = {
const builtinSync: BuiltinSync = {
channels: [],
enabled: true,
init<State extends object>(channelKey: string, onUpdate: (data: Partial<State>) => void, state: State, persist = false) {
Expand Down Expand Up @@ -50,12 +50,12 @@ const slidevSync: SlidevSync = {
}
},
}
const syncInterfaces: Sync[] = reactive([slidevSync])
const syncInterfaces: Sync[] = reactive([builtinSync])
const channels: Map<string, { onUpdate: (data: Partial<object>) => void, persist?: boolean, state: object }> = new Map()
const syncWrites = ref<Record<string, SyncWrite<object>[]>>({})

export function disableSlidevSync() {
slidevSync.disable()
export function disableBuiltinSync() {
builtinSync.disable()
}

export function addSyncMethod(sync: Sync) {
Expand Down

0 comments on commit 3a3cf6a

Please sign in to comment.