repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
LeagueAkari
github_2023
Hanxven
typescript
SgpMain.getMatchHistory
async getMatchHistory( playerPuuid: string, start: number, count: number, tag?: string | null, sgpServerId?: string ) { if (!sgpServerId) { sgpServerId = this.state.availability.sgpServerId } if (tag) { const { data } = await this._sgp.getMatchHistory(sgpServerId, playerPu...
/** * 获取玩家的战绩记录 * @param playerPuuid 玩家的 PUUID * @param start 起始索引 * @param count 获取数量 * @param sgpServerId 目标 SGP 服务器 ID,如果不提供则使用当前登录 LCU 的服务器 ID * @returns */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/shards/sgp/index.ts#L236-L254
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
SgpMain.parseSgpMatchHistoryToLcu0Format
parseSgpMatchHistoryToLcu0Format(sgpMh: SgpMatchHistoryLol, start = 0, count = 20): MatchHistory { const jsonArr = sgpMh.games.map((game) => this.parseSgpGameSummaryToLcu0Format(game)) const gamePage = { gameBeginDate: '', // 默认值 gameCount: count, gameEndDate: '', // 默认值 gameIndexBegin:...
/** * 始终是 detailed 的,但只有部分属性 * 不是很优雅 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/shards/sgp/index.ts#L490-L507
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
StorageMain._performUpgrades
private async _performUpgrades(r: QueryRunner, currentVersion: number) { const pendingUpgrades = Object.entries(this._upgrades) .filter(([v]) => Number(v) > currentVersion) .toSorted(([v1], [v2]) => Number(v1) - Number(v2)) this._log.info(`即将进行的数据库升级数量: ${pendingUpgrades.length}`) for (const [...
/** * 处理 League Akari 的数据库的升级 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/shards/storage/index.ts#L105-L118
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
WindowManagerMain._settingToNativeBackgroundMaterial
_settingToNativeBackgroundMaterial(material: string) { if (material === 'mica' && process.env['NODE_ENV'] !== 'development') { this._log.warn( 'Mica is disabled in production mode. (https://github.com/electron/electron/issues/41824)' ) return 'none' } if (!this.state.supportsMica)...
/** * 设置项的背景材质转换为原生系统级别背景材质 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/shards/window-manager/index.ts#L123-L140
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.constructor
constructor(callback?: () => void, delay = 0) { this._callback = callback this._delay = delay }
/** * @param callback 回调函数 * @param delay 默认延迟时间(毫秒) */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L11-L14
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.isStarted
get isStarted(): boolean { return this._isStarted }
/** * 是否已经启动 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L19-L21
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.cancel
cancel(): boolean { if (!this._isStarted || !this._timerId) { return false } clearTimeout(this._timerId) this._timerId = null this._isStarted = false return true }
/** * 取消定时任务 * @returns 是否成功取消(如果当前未启动则返回 false) */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L27-L35
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.start
start(delay?: number): void { // 如果需要更新新的延迟时间 if (delay !== undefined) { this._delay = delay } if (!this._callback) { return } // 先取消已存在的定时器,避免重复 this.cancel() this._isStarted = true this._timerId = setTimeout(() => { this._callback?.() this._isStarted = fal...
/** * 启动定时器 * @param delay 可选新延迟时间,不传则使用当前 _delay */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L41-L59
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.setTask
setTask(callback: () => void, autoStart = false, delay?: number): void { this._callback = callback // 如果当前已在执行,则先取消 this.cancel() if (autoStart) { this.start(delay) } }
/** * 设置新的回调函数,并根据 autoStart 决定是否立即启动 * @param callback 回调函数 * @param autoStart 是否自动启动 * @param delay 可选新的延迟时间 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L67-L75
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.updateTime
updateTime(newDelay: number): void { this._delay = newDelay // 如果已经启动,需要让新的延迟生效 if (this._isStarted) { this.start(this._delay) } }
/** * 更新延迟时间,如果定时器正在执行,则重启定时器使其应用新的延迟 * @param newDelay 新的延迟时间 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L81-L87
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.triggerCompletion
triggerCompletion(): void { if (this._isStarted && this._callback) { this._callback() this.cancel() } }
/** * 触发回调并立即取消定时器 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L92-L97
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
TimeoutTask.refreshTimeImmediately
refreshTimeImmediately(): void { if (this._isStarted) { this.start(this._delay) } }
/** * 立即刷新时间(如果正在执行,则重启定时器,延迟从当前时间开始重新计时) */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/main/utils/timer.ts#L102-L106
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariIpcRenderer.call
async call<T = any>(namespace: string, fnName: string, ...args: any[]) { const result: IpcMainDataType<T> = await window.electron.ipcRenderer.invoke( 'akariCall', namespace, fnName, ...args ) if (result.success) { return result.data as T } else { // axios 错误将不会触发特殊日志 ...
/** * 调用一个函数, 若不存在会抛出异常 * @param namespace * @param fnName * @param args * @returns */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer-shared/shards/ipc/index.ts#L77-L97
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariIpcRenderer.onEvent
onEvent(namespace: string, eventName: string, fn: (...args: any[]) => void) { const key = `${namespace}:${eventName}` if (!this._eventMap.has(key)) { this._eventMap.set(key, new Set()) } this._eventMap.get(key)!.add(fn) return () => { this._eventMap.get(key)!.delete(fn) } }
/** * 期待一个事件 * @param namespace * @param eventName * @param fn * @returns 取消订阅函数 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer-shared/shards/ipc/index.ts#L106-L118
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariIpcRenderer.onEventVue
onEventVue(namespace: string, eventName: string, fn: (...args: any[]) => void) { const disposeFn = this.onEvent(namespace, eventName, fn) getCurrentScope() && onScopeDispose(() => disposeFn()) return disposeFn }
/** * Vue 可自行解除订阅的事件 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer-shared/shards/ipc/index.ts#L123-L127
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariIpcRenderer.offEvent
offEvent(namespace: string, eventName: string, fn: (...args: any[]) => void) { const key = `${namespace}:${eventName}` const functions = this._eventMap.get(key) if (functions) { functions.delete(fn) } }
/** * 取消订阅一个事件 * @param namespace * @param eventName * @param fn */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer-shared/shards/ipc/index.ts#L135-L142
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
LoggerRenderer._objectsToString
private _objectsToString(...args: any[]) { return args .map((arg) => { if (arg instanceof Error) { return formatError(arg) } if (typeof arg === 'undefined') { return 'undefined' } if (typeof arg === 'function') { return arg.toString() ...
// same as main shard
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer-shared/shards/logger/index.ts#L19-L45
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
SettingUtilsRenderer.autoSavePropVue
async autoSavePropVue( namespace: string, key: string, getter: () => any, initValueSetter: (value: any) => void ) { initValueSetter(await this.get(namespace, key, getter())) const stopHandle = watch(getter, (value) => { this.set(namespace, key, toRaw(value)) }) this._stopHandles....
/** * 远古工具方法 2.0, 仅用于渲染进程的某些数据存储和初始化 * 用于持久化某些仅用于渲染进程的数据 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer-shared/shards/setting-utils/index.ts#L32-L43
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
MatchHistoryTabsRenderer.getSearchHistory
async getSearchHistory(): Promise<SearchHistoryItem[]> { return this._setting.get( MatchHistoryTabsRenderer.id, MatchHistoryTabsRenderer.SEARCH_HISTORY_KEY, [] ) }
/** * 获取搜索历史, 有数量限制 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer/src-main-window/shards/match-history-tabs/index.ts#L132-L138
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
MatchHistoryTabsRenderer.saveSearchHistory
async saveSearchHistory(item: SearchHistoryItem) { const items = await this.getSearchHistory() // 先查重, 若存在, 则将其放到第一位 const index = items.findIndex((i) => i.puuid === item.puuid) if (index !== -1) { items.splice(index, 1) } items.unshift(item) if (items.length > MatchHistoryTabsRende...
/** * 使用全量替换的方式更新搜索历史 * @param item */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer/src-main-window/shards/match-history-tabs/index.ts#L144-L164
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
MatchHistoryTabsRenderer.useNavigateToTab
useNavigateToTab() { const router = useRouter() const sgps = useSgpStore() const navigateToTab = async (unionId: string) => { const { sgpServerId, puuid } = this.parseUnionId(unionId) if (!puuid || puuid === EMPTY_PUUID) { return } return router.replace({ name: 'ma...
// 如果直接引用 router, 在热更新的时候会失效
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer/src-main-window/shards/match-history-tabs/index.ts#L182-L225
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
navigateToTabByPuuid
const navigateToTabByPuuid = async (puuid: string) => { if (!puuid || puuid === EMPTY_PUUID) { return } return router.replace({ name: 'match-history', params: { puuid, sgpServerId: sgps.availability.sgpServerId } }) }
/** * 以当前大区为准跳转到指定 puuid 的战绩页面 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer/src-main-window/shards/match-history-tabs/index.ts#L213-L222
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
MatchHistoryTabsRenderer.createTab
createTab(puuid: string, sgpServerId: string, setCurrent = true, pin = false) { const mhs = useMatchHistoryTabsStore() if (mhs.getTab(this.toUnionId(sgpServerId, puuid))) { return } mhs.createTab( { id: this.toUnionId(sgpServerId, puuid), puuid, sgpServerId, ...
/** 创建一个新的 Tab, 并设置一些初始值 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/renderer/src-main-window/shards/match-history-tabs/index.ts#L238-L268
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariManager.setup
async setup() { if (this._isSetup) { throw new Error('Already setup') } // 在 setup 阶段先注册全局 SharedGlobalShard(如果尚未注册) if (!this._registry.has(SHARED_GLOBAL_ID)) { const global = this.global const manager = this this._registry.set(SHARED_GLOBAL_ID, { cls: class __$SharedGl...
/** * 启用所有注册的模块,进行依赖解析、实例化和生命周期钩子调用 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/akari-shard/manager.ts#L68-L117
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariManager.getInstance
getInstance<T = any>(id: string) { return this._instances.get(id) as T | undefined }
/** * 获取某个模块的实例 * @param id 模块 ID * @returns 模块实例(可能为 undefined) */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/akari-shard/manager.ts#L141-L143
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
AkariManager._getInitializationStack
_getInitializationStack() { return this._initializationStack }
/** * 仅用于调试:返回模块初始化顺序 * 仅在 setup 后有效 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/akari-shard/manager.ts#L149-L151
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
SgpApi._getSubId
private _getSubId(sgpServerId: string) { if (sgpServerId.startsWith('TENCENT')) { const [_, rsoPlatformId] = sgpServerId.split('_') return rsoPlatformId } return sgpServerId }
/** * 对于腾讯系, 仅保留其 rsoPlatformId * @param sgpServerId */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/data-sources/sgp/index.ts#L141-L148
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
RadixEventEmitter.emit
emit<T = any>(uri: string, data: T): void { const routes = this.matcher.findAll(uri) for (const r of routes) { for (const cb of r.data.callbacks) { cb(data, r.params) } } }
/** * dispatcher! * @param uri 资源标识符 * @param data 除了 null 和 undefined 之外的东西 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/event-emitter/index.ts#L14-L22
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
RadixEventEmitter.on
on<T = any, P = Record<string, any>>( uri: string, listener: (data: T, params: P) => void ): () => void { const data = this.matcher.getRouteData(uri) if (data) { data.data.callbacks.add(listener) } else { this.matcher.insert(uri, { callbacks: new Set([listener]) }) } return (...
/** * @param uri 资源标识符 * @param listener 回调 * @returns 一个取消监听的回调 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/event-emitter/index.ts#L29-L50
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
ChatHttpApi.chatSend
chatSend( targetId: number | string, message: string, type: string = 'chat', isHistorical: boolean = false, summonerId?: number ) { return this._http.post<ChatMessage>(`/lol-chat/v1/conversations/${targetId}/messages`, { body: message, fromId: summonerId, fromPid: '', f...
// 暂时不了解summonerId有什么用处,经过测试是加不加都行,尽量保持原样
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/chat.ts#L39-L56
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
LobbyHttpApi.promote
promote(summonerId: string | number) { return this._http.post<number>(`/lol-lobby/v2/lobby/members/${summonerId}/promote`) }
/** * 提升为房主 * @param summonerId 目标召唤师 ID */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/lobby.ts#L53-L55
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
LobbyHttpApi.getAvailableBots
getAvailableBots() { return this._http.get<AvailableBot[]>('/lol-lobby/v2/lobby/custom/available-bots') }
/** * 可以选择的人机种类 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/lobby.ts#L76-L78
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
LobbyHttpApi.isBotEnabled
isBotEnabled() { return this._http.get<boolean>('/lol-lobby/v2/lobby/custom/bots-enabled') }
/** * 是否可以添加人机 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/lobby.ts#L83-L85
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
MissionsHttpApi.putRewardGroups
putRewardGroups(id: string, rewardGroups: string[]) { return this._http.put<void>(`/lol-missions/v1/player/${id}/reward-groups`, { rewardGroups }) }
// ?
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/missions.ts#L12-L14
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
PerksHttpApi.getRuneRecommenderAutoSelect
getRuneRecommenderAutoSelect() { return this._http.get<boolean>(`/lol-perks/v1/rune-recommender-auto-select`) }
/** * 是否系统级别自动选择 * @returns */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/perks.ts#L81-L83
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
PerksHttpApi.postRuneRecommenderAutoSelect
postRuneRecommenderAutoSelect(data: object) { return this._http.post(`/lol-perks/v1/rune-recommender-auto-select`, data) }
/** * 开启系统级别自动选择 * @returns */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/perks.ts#L89-L91
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
PlayerNotificationsHttpApi.createTitleDetailsNotification
createTitleDetailsNotification(title: string, details: string) { return this.postNotification({ critical: true, data: { details, title }, detailKey: 'pre_translated_details', dismissible: true, state: 'toast', titleKey: 'pre_translated_title', type: 'd...
/** * 一个预设通知 */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/http-api-axios-helper/league-client/player-notifications.ts#L14-L27
f75d7cd05ff40722c81517152cc11097052c9433
LeagueAkari
github_2023
Hanxven
typescript
isInside
function isInside(polygon: readonly [x: number, y: number][], x: number, y: number) { let count = 0 for (let i = 0; i < polygon.length; i++) { const [x1, y1] = polygon[i] const [x2, y2] = polygon[(i + 1) % polygon.length] if (y1 === y2) { continue } if (y < Math.min(y1, y2)) { contin...
/** * 射线法判断点是否在多边形内部 * @param polygon * @param x * @param y */
https://github.com/Hanxven/LeagueAkari/blob/f75d7cd05ff40722c81517152cc11097052c9433/src/shared/utils/map-where.ts#L56-L76
f75d7cd05ff40722c81517152cc11097052c9433
bitspace
github_2023
emilwidlund
typescript
CanvasStore.connections
public get connections() { return this.circuit.nodes .flatMap(node => node.connections) .filter((value, index, self) => self.indexOf(value) === index); }
/** All associated connections */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L45-L49
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.canvasMidpoint
public get canvasMidpoint(): Position { return { x: this.canvasPosition.x + this.canvasSize.width / 2, y: this.canvasPosition.y + this.canvasSize.height / 2 }; }
/** Canvas midpoint */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L52-L57
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.removeNode
public removeNode(node: Node) { this.circuit.removeNode(node); this.nodeElements.delete(node.id); }
/** Removes a node from the store */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L60-L63
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setNodeElement
public setNodeElement( nodeId: Node['id'], portElement: HTMLDivElement ): void { this.nodeElements.set(nodeId, portElement); }
/** Associates a given Node instance with an HTML Element */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L66-L71
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.removeNodeElement
public removeNodeElement(nodeId: Node['id']): void { this.nodeElements.delete(nodeId); }
/** Clears a given Node's associated HTML Element from store */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L74-L76
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setPortElement
public setPortElement( portId: Input['id'] | Output['id'], portElement: HTMLDivElement ): void { this.portElements.set(portId, portElement); }
/** Associates a given Input or Output instance with an HTML Element */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L79-L84
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.removePortElement
public removePortElement(portId: Input['id'] | Output['id']): void { this.portElements.delete(portId); }
/** Clears a given Input's or Output's associated HTML Element from store */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L87-L89
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setDraftConnectionSource
public setDraftConnectionSource(source: Output | null): void { this.draftConnectionSource = source; }
/** Sets an Output as the current draft connection source */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L92-L94
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.commitDraftConnection
public commitDraftConnection<T>(target: Input<T>): Connection<T> | void { if (this.draftConnectionSource) { const connection = this.draftConnectionSource.connect(target); this.setDraftConnectionSource(null); return connection; } }
/** Sets an Output as the current draft connection source */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L97-L105
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.selectNodes
public selectNodes(nodes: Node[]): void { this.selectedNodes = nodes; }
/** Selects the given nodes */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L108-L110
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setSelectionBounds
public setSelectionBounds(bounds: Bounds | null): void { this.selectionBounds = bounds; }
/** Sets the selection bounds */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L113-L115
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setMousePosition
public setMousePosition(mousePosition: Position): void { this.mousePosition = mousePosition; }
/** Sets the mouse position */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L118-L120
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setCanvasSize
public setCanvasSize(size: Size): void { this.canvasSize = size; }
/** Sets the canvas size */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L123-L125
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.setCanvasPosition
public setCanvasPosition(position: Position): void { this.canvasPosition = position; }
/** Sets the canvas position */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L128-L130
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.getNodeByPortId
public getNodeByPortId(portId: Input['id'] | Output['id']) { return this.circuit.nodes.find(node => { return [ ...Object.values(node.inputs), ...Object.values(node.outputs) ].some(port => port.id === portId); }); }
/** Returns the node with the associated port */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L133-L140
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.dispose
public dispose(): void { this.circuit.dispose(); this.nodeElements.clear(); this.portElements.clear(); this.selectedNodes = []; this.selectionBounds = null; this.draftConnectionSource = null; this.mousePosition = { x: 0, y: 0 }; this.selectionBoundsDispos...
/** Disposes the store by cleaning up effects */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L143-L153
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
CanvasStore.onSelectionBoundsChange
private onSelectionBoundsChange(): IReactionDisposer { return autorun(() => { if (this.selectionBounds) { const bounds = normalizeBounds(this.selectionBounds); const selectionCandidates = []; for (const node of this.circuit.nodes) { ...
/** Automatically selects the nodes which are within the selection bounds */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/apps/web/src/circuit/stores/CanvasStore/CanvasStore.ts#L156-L200
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Circuit.addNode
public addNode(node: Node): this { this.nodes.push(node); return this; }
/** Add Node to Circuit */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Circuit/Circuit.ts#L40-L44
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Circuit.removeNode
public removeNode(node: Node): this { this.nodes = this.nodes.filter(n => n.id !== node.id); return this; }
/** Remove Node from Circuit */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Circuit/Circuit.ts#L47-L51
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Circuit.createInput
public createInput<T>(inputProps: IInputProps<T>): this { if (!inputProps.name) { throw new Error('An input name must be provided'); } this.inputs[inputProps.name] = new Input(inputProps); return this; }
/** Creates an Input on the Circuit */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Circuit/Circuit.ts#L54-L62
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Circuit.dispose
public dispose(): void { for (const node of this.nodes) { node.dispose(); } super.dispose(); }
/** Dispose all Circuit resources */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Circuit/Circuit.ts#L65-L71
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Connection.dispose
public dispose() { this.complete(); this.unsubscribe(); this.subscription?.unsubscribe(); this.from.connections = this.from.connections.filter( connection => connection !== this ); this.to.connection = null; this.to.next(this.to.defaultValue); }
/** Disposes the Connection */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Connection/Connection.ts#L55-L66
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Connection.next
public next(value: T) { super.next(this.to.type.parse(value)); }
/** Parses the value and sends it */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Connection/Connection.ts#L69-L71
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Input.connected
public get connected(): boolean { return !!this.connection; }
/** Determines if input is connected */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Input/Input.ts#L41-L43
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Input.dispose
public dispose(): void { this.complete(); this.connection?.dispose(); this.connection = null; this.unsubscribe(); }
/** Disposes the Input */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Input/Input.ts#L46-L52
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Input.next
public next(value: TValue) { super.next(this.type.parse(value)); }
/** Parses the value and sends it */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Input/Input.ts#L55-L57
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Output.connected
public get connected(): boolean { return this.connections.length > 0; }
/** Determines if output is connected */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Output/Output.ts#L53-L55
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Output.connect
public connect( input: Input<TValue>, onValidationFail?: (fromId: string, toId: string) => void ): Connection<TValue> { return new Connection(this, input, onValidationFail); }
/** Connects the output with a compatible input port */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Output/Output.ts#L58-L63
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Output.setLoading
public setLoading() { this.loading = true; }
/** Sets the loading state */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Output/Output.ts#L66-L68
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Output.resetLoading
public resetLoading() { this.loading = false; }
/** Flushes the loading state */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Output/Output.ts#L71-L73
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Output.dispose
public dispose() { for (const connection of this.connections) { connection.dispose(); } this.connections = []; this.unsubscribe(); }
/** Disposes the Output */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Output/Output.ts#L76-L84
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Output.next
public next(value: TValue) { super.next(this.type.parse(value)); }
/** Parses the value and sends it */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/circuit/src/Output/Output.ts#L87-L89
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Gamepad.extractAxis
public extractAxis(analog: 'left' | 'right') { return (gamepad: globalThis.Gamepad) => { const [x, y] = gamepad.axes.slice.call( gamepad.axes, ...(analog === 'left' ? [0, 2] : [2, 4]) ); return { x: x ?? 0, y: y ?? 0 }; }; }
/** Extracts axis from gamepad */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/interface/Gamepad/Gamepad.ts#L43-L51
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Gamepad.initializeGamepad
public initializeGamepad(): Observable<globalThis.Gamepad> { return interval(0, animationFrameScheduler).pipe( switchMap(() => from( navigator .getGamepads() .filter((gamepad): gamepad is globalThis.Gamepad => ...
/** Initializes gamepad resources */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/interface/Gamepad/Gamepad.ts#L54-L66
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Webcam.initializeWebcam
public initializeWebcam(audio: boolean): Observable<MediaStream> { return from( navigator.mediaDevices.getUserMedia({ video: { width: { min: 480, ideal: 720, max: 1080 }, height: { min: 480, ideal: 720, max: 1080 } }, ...
/** Initializes webcam resources */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/interface/Webcam/Webcam.ts#L34-L44
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Webcam.saveMediaStream
public saveMediaStream(mediaStream: MediaStream): void { this.mediaStream = mediaStream; }
/** Saves the media stream internally */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/interface/Webcam/Webcam.ts#L47-L49
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Webcam.disposeMediaStream
public disposeMediaStream(): void { if (this.mediaStream) { this.mediaStream.getTracks().forEach(track => { track.stop(); this.mediaStream?.removeTrack(track); }); } this.mediaStream = null; }
/** Disposes webcam resources */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/interface/Webcam/Webcam.ts#L52-L61
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Webcam.dispose
public dispose(): void { this.disposeMediaStream(); super.dispose(); }
/** Disposes webcam node */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/interface/Webcam/Webcam.ts#L64-L68
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Lerp.lerp
public lerp(a: number, b: number, t: number) { return a * (1 - t) + b * t; }
/** Linear Interpolation */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/nodes/src/utilities/Lerp/Lerp.ts#L52-L54
4b5ce53961a9aba9c8207cc66aa141a944660613
bitspace
github_2023
emilwidlund
typescript
Fragment.resolve
public resolve< TUniforms extends Record<string, Sym<any>>, TIns extends Record<string, Sym<any>>, TOuts extends Record<string, Sym<any>> >(gl: GLSLTarget, uniforms: TUniforms, ins: TIns, outs: TOuts) { this.uniforms = uniforms; this.ins = ins; this.outs = outs; ...
/** Resolves the shader graph */
https://github.com/emilwidlund/bitspace/blob/4b5ce53961a9aba9c8207cc66aa141a944660613/packages/webgl/src/nodes/core/Fragment/Fragment.ts#L26-L39
4b5ce53961a9aba9c8207cc66aa141a944660613
openapi-ui
github_2023
rookie-luochao
typescript
patchOperation
const patchOperation = (path: string, method: IMethodType, operation: IOperation) => (operations: IOperationEnhanceMap, tag: string): IOperationEnhanceMap => { // without openapiId, use path + method as the unique name, this combination can determine the uniqueness const operationId = operation.operationId ...
// use operationId combine Operations
https://github.com/rookie-luochao/openapi-ui/blob/57b8d911d24a3b6d8f80b495fd378c3563433856/src/pages/openapi/hook/utils.ts#L6-L23
57b8d911d24a3b6d8f80b495fd378c3563433856
sail
github_2023
lakehq
typescript
loadPages
async function loadPages( srcDir: string, pattern: string | string[], exclude?: string[], ): Promise<PageLink[]> { if (typeof pattern === "string") { pattern = [pattern]; } pattern = pattern.map((p) => path.join(srcDir, p)); const files = await glob(pattern, { ignore: exclude }); return await Promis...
/** * Load the Markdown pages matching the pattern. * This is similar to `createContentLoader` in VitePress, * but we cannot use it since it relies on the VitePress configuration, * which may not exist when this function is called. * @param srcDir The source directory of the documentation. * @param pattern The gl...
https://github.com/lakehq/sail/blob/a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead/docs/.vitepress/theme/utils/page.ts#L20-L48
a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead
sail
github_2023
lakehq
typescript
loadSphinxPages
async function loadSphinxPages(): Promise<SphinxPage[]> { const files = await glob( path.join(SPHINX_BUILD_OUTPUT, "**/!(search|genindex).fjson"), ); return await Promise.all( files.map(async (file): Promise<SphinxPage> => { const content = await fs.readFile(file, "utf-8"); const data = JSON.p...
/** * Load the Sphinx pages generated by the Sphinx JSON builder. * @returns The list of Sphinx pages. */
https://github.com/lakehq/sail/blob/a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead/docs/.vitepress/theme/utils/sphinx.ts#L87-L111
a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead
sail
github_2023
lakehq
typescript
TreeNode.fromNodes
static fromNodes<T extends NodeLike>(items: T[]): TreeNode<T>[] { function error(message: string): never { const input = items.map((item) => ({ name: item.name(), parent: item.parent(), prev: item.prev(), next: item.next(), })); throw new Error(`${message}: ${JSON.s...
/** * Construct trees from a list of nodes, where each node has pointers to its * parent, previous node, and next node. The previous and next pointers are * determined by pre-order traversal of the tree. * @param items The list of nodes. * @returns The list of root tree nodes. */
https://github.com/lakehq/sail/blob/a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead/docs/.vitepress/theme/utils/tree.ts#L35-L110
a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead
sail
github_2023
lakehq
typescript
TreeNode.fromPaths
static fromPaths<T extends PathLike>( items: T[], prefix?: string[], ): TreeNode<T | null>[] { if (prefix === undefined) { prefix = []; } const roots: TreeNode<T | null>[] = []; for (const item of items) { const parts = item.path(); // Skip the item if it does not match the...
/** * Construct trees from a list of items, where each item has a path. * The path is split into components that defines the hierarchy of the tree. * When the prefix is specified, only items that match the prefix are included, * and the prefix is removed from the path of each matching item. * @param item...
https://github.com/lakehq/sail/blob/a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead/docs/.vitepress/theme/utils/tree.ts#L121-L186
a159393f4ecb99ce1bef2b6ac99ed2cbb8d06ead
visual-sorting
github_2023
mszula
typescript
minRunLength
function minRunLength(n: number): number { let r = 0; while (n >= MIN_MERGE) { r |= n & 1; n >>= 1; } return n + r; }
/** * Computes the minimum run length for Timsort given an array length. * This follows Timsort's logic: * - Repeatedly shift right until n < MIN_MERGE. * - Track if any bits were shifted off (r), and add that to final result. */
https://github.com/mszula/visual-sorting/blob/cb26fc8b109992f38e65bab4963a1507b731602a/src/lib/sort-algorithms/tim-sort.ts#L16-L23
cb26fc8b109992f38e65bab4963a1507b731602a
Gemini-Next-Web
github_2023
blacksev
typescript
animateResponseText
function animateResponseText() { if (finished || controller.signal.aborted) { responseText += remainText; console.log("[Response Animation] finished"); return; } if (remainText.length > 0) { const fetchCount = Math.max(1, Math.round(remainTe...
// animate response to make it looks smooth
https://github.com/blacksev/Gemini-Next-Web/blob/12828ee3319e0a9e13cca0c91b3a6eb559d6bb3a/app/client/platforms/openai.ts#L145-L161
12828ee3319e0a9e13cca0c91b3a6eb559d6bb3a
Gemini-Next-Web
github_2023
blacksev
typescript
changeIndex
const changeIndex = (delta: number) => { e.stopPropagation(); e.preventDefault(); const nextIndex = Math.max( 0, Math.min(props.prompts.length - 1, selectIndex + delta), ); setSelectIndex(nextIndex); selectedRef.current?.scrollIntoView({ bloc...
// arrow up / down to select prompt
https://github.com/blacksev/Gemini-Next-Web/blob/12828ee3319e0a9e13cca0c91b3a6eb559d6bb3a/app/components/chat.tsx#L260-L271
12828ee3319e0a9e13cca0c91b3a6eb559d6bb3a
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.stopCurrentVM
async stopCurrentVM(): Promise<void> { return stopCurrentVM(); }
// Stop VM by pid file on the system
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L98-L100
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.selectBuildConfigFile
async selectBuildConfigFile(): Promise<string> { const path = await podmanDesktopApi.window.showOpenDialog({ title: 'Select build config file', selectors: ['openFile'], filters: [ { name: '*', extensions: ['toml', 'json'], }, ], }); if (path && pat...
// Build config file will only ever be config.yaml or config.json as per bootc-iamge-builder requirements / constraints
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L154-L169
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.inspectManifest
async inspectManifest(image: ImageInfo): Promise<podmanDesktopApi.ManifestInspectInfo> { let manifestInspect: podmanDesktopApi.ManifestInspectInfo; try { manifestInspect = await podmanDesktopApi.containerEngine.inspectManifest(image.engineId, image.Id); } catch (err) { throw new Error(`Error ins...
// name and engineId required.
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L231-L242
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.pullImage
async pullImage(imageName: string, arch?: string): Promise<void> { let success: boolean = false; let error: string = ''; try { await containerUtils.pullImage(await getContainerEngine(), imageName, arch); success = true; } catch (err) { await podmanDesktopApi.window.showErrorMessage(`Er...
// Pull an image from the registry
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L270-L284
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.telemetryLogUsage
async telemetryLogUsage(eventName: string, data?: Record<string, unknown>): Promise<void> { telemetryLogger.logUsage(eventName, data); }
// Log an event to telemetry
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L287-L289
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.telemetryLogError
async telemetryLogError(eventName: string, data?: Record<string, unknown>): Promise<void> { telemetryLogger.logError(eventName, data); }
// Log an error to telemetry
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L292-L294
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.getConfigurationValue
async getConfigurationValue(config: string, section: string): Promise<unknown> { try { return podmanDesktopApi.configuration.getConfiguration(config).get(section); } catch (err) { console.error('Error getting configuration, will return undefined: ', err); } return undefined; }
// returns "any" because the configuration values are not typed
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L328-L335
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.readFromClipboard
async readFromClipboard(): Promise<string> { return podmanDesktopApi.env.clipboard.readText(); }
// Read from the podman desktop clipboard
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L338-L340
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
BootcApiImpl.notify
protected async notify(id: string, body: unknown = {}): Promise<void> { // Must pass in an empty body, if it is undefined this fails await this.webview.postMessage({ id, body, }); }
// this method is internal and meant to be used by the API implementation
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/api-impl.ts#L345-L351
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
getVolumesMatchingContainer
async function getVolumesMatchingContainer(engineId: string, container: string): Promise<string[]> { try { // Volumes returns a list of volumes across all engines. Only get the volume that matches our engineId const engineVolumes = await extensionApi.containerEngine.listVolumes(); if (!engineVolumes) { ...
// Get all volume names that match the name of the container
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/container-utils.ts#L252-L287
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
History.ensureNoUndefinedNames
public async ensureNoUndefinedNames(): Promise<void> { let changed = false; for (const info of this.infos) { if (!info.id && info.image) { // Update the 'name' field with the name of the image const segments = info.image.split('/'); const imageName = segments?.pop() ?? info.image; ...
// field was not required. Rather than deleting the file, we'll just update it with the new field.
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/history.ts#L92-L107
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
History.getUnusedHistoryName
public async getUnusedHistoryName(name: string): Promise<string> { // Extract the last segment after the last '/' as the imageName. const segments = name.split('/'); const imageName = segments.pop() ?? name; // Fallback to name if split is an empty last segment let builds: string[] = []; try { ...
// same as getUnusedName from build-disk-image.ts but instead checks from the history information.
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/history.ts#L110-L137
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
getMachineInfo
async function getMachineInfo(connection: extensionApi.ContainerProviderConnection): Promise<any> { const { stdout: machineInfoJson } = await extensionApi.process.exec( getPodmanCli(), ['machine', 'info', '--format', 'json'], { env: { CONTAINERS_MACHINE_PROVIDER: getMachineProviderEnv(connec...
// Async function to get machine information in JSON format
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/machine-utils.ts#L60-L71
d5bbd58a824131ca533ababcc2e7b35ff86c264b
extension-bootc
github_2023
podman-desktop
typescript
readMachineConfig
async function readMachineConfig(machineConfigDir: string, currentMachine: string): Promise<any> { const filepath = path.join(machineConfigDir, `${currentMachine}.json`); // Check if the file exists before reading it if (!fs.existsSync(filepath)) { throw new Error(`Machine config file ${filepath} does not ex...
// Read the machine configuration and error out if we are uanble to read it.
https://github.com/podman-desktop/extension-bootc/blob/d5bbd58a824131ca533ababcc2e7b35ff86c264b/packages/backend/src/machine-utils.ts#L75-L85
d5bbd58a824131ca533ababcc2e7b35ff86c264b