fix(server-*): should export more types, and for module:announced should ignore self
This commit is contained in:
@@ -574,7 +574,7 @@ interface ModuleCompatibilityResultEvent {
|
||||
reason?: string
|
||||
}
|
||||
|
||||
interface RegistryModulesSyncEvent {
|
||||
export interface RegistryModulesSyncEvent {
|
||||
modules: Array<{
|
||||
name: string
|
||||
index?: number
|
||||
@@ -599,7 +599,7 @@ interface ModuleAnnounceEvent<C = undefined> {
|
||||
configSchema?: ModuleConfigSchema
|
||||
dependencies?: ModuleDependency[]
|
||||
}
|
||||
interface ModuleAnnouncedEvent {
|
||||
export interface ModuleAnnouncedEvent {
|
||||
name: string
|
||||
index?: number
|
||||
identity: ModuleIdentity
|
||||
|
||||
@@ -426,7 +426,10 @@ export function setupApp(options?: AppOptions): { app: H3, closeAllPeers: () =>
|
||||
|
||||
// broadcast module:announced to all authenticated peers
|
||||
for (const other of peers.values()) {
|
||||
if (other.authenticated) {
|
||||
// only send to
|
||||
// 1. authenticated peers
|
||||
// 2. other peers except the announcing peer itself
|
||||
if (other.authenticated && !(other.peer.id === peer.id)) {
|
||||
send(other.peer, {
|
||||
type: 'module:announced',
|
||||
data: { name, index, identity },
|
||||
|
||||
@@ -3,7 +3,9 @@ import type { RouteTargetExpression } from '@proj-airi/server-shared/types'
|
||||
import type { AuthenticatedPeer } from '../../types'
|
||||
|
||||
function globToRegExp(glob: string) {
|
||||
// eslint-disable-next-line e18e/prefer-static-regex
|
||||
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
||||
// eslint-disable-next-line e18e/prefer-static-regex
|
||||
const pattern = `^${escaped.replace(/\*/g, '.*')}$`
|
||||
return new RegExp(pattern)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user