repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
eastworld | github_2023 | mluogh | typescript | GameDefinitionsService.updateGame | public static updateGame(
uuid: string,
requestBody: GameDef,
overwriteAgents: boolean = false,
): CancelablePromise<GameDef> {
return __request(OpenAPI, {
method: 'PUT',
url: '/game/{uuid}/update',
path: {
'uuid': uuid,
... | /**
* Update Game Def
* @param uuid
* @param requestBody
* @param overwriteAgents
* @returns GameDef Successful Response
* @throws ApiError
*/ | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameDefinitionsService.ts#L161-L181 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.createSession | public static createSession(
gameUuid: string,
): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/create',
query: {
'game_uuid': gameUuid,
},
errors: {
422: `Validation ... | /**
* Create Session
* Given a Game, creates a game session and populates the Agents
* with their lore and knowledge.
*
* <h3>Args:</h3>
*
* - **game_uuid** (uuid4 as str): The uuid of the GameDef that this session will
* populate from.
*
* <h3>Returns:</h3>
* - **... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L32-L45 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.listSessions | public static listSessions(
gameUuid: string,
): CancelablePromise<Array<string>> {
return __request(OpenAPI, {
method: 'GET',
url: '/session/list',
query: {
'game_uuid': gameUuid,
},
errors: {
422: `Validati... | /**
* Get Sessions List
* Lists all active sessions for a given Game.
*
* <h3>Args:</h3>
*
* - **game_uuid** (uuid4 as str): The uuid of the GameDef
*
* <h3>Returns:</h3>
* - **session_uuids** (List[uuid4] as List[str]): the uuids of the sessions
* @param gameUuid
... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L61-L74 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.startChat | public static startChat(
sessionUuid: string,
agent: string,
correspondent?: string,
requestBody?: Body_start_chat,
): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/{session_uuid}/start_chat',
path: {
... | /**
* Start Conversation
* Starts a chat with the given agent. Clears previous conversation
* history.
*
* <h3>Args:</h3>
*
* - **session_uuid** (str): the uuid of the session
* - **agent** (str): either the uuid or the name of the agent.
* - **correspondent** (str): the cha... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L99-L121 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.chat | public static chat(
sessionUuid: string,
agent: string,
message: string,
sendDebug: boolean = false,
): CancelablePromise<MessageWithDebug> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/{session_uuid}/chat',
path: {
... | /**
* Chat
* Sends `message` to the given agent. They will respond with text.
*
* <h3>Args:</h3>
*
* - **session_uuid** (str): the uuid of the session
* - **agent** (str): either the uuid or the name of the agent.
* - **message** (str): what you're saying to the agent
* - **... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L145-L166 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.interact | public static interact(
sessionUuid: string,
agent: string,
message: string,
sendDebug: boolean = false,
): CancelablePromise<InteractWithDebug> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/{session_uuid}/interact',
path: {
... | /**
* Interact
* Sends message to the given agent. They will respond with
* an Action or text.
*
* <h3>Args:</h3>
*
* - **session_uuid** (str): the uuid of the session
* - **agent** (str): either the uuid or the name of the agent.
* - **message** (str): what you're saying to... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L192-L213 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.action | public static action(
sessionUuid: string,
agent: string,
message: string,
sendDebug: boolean = false,
): CancelablePromise<ActionCompletionWithDebug> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/{session_uuid}/act',
path: {... | /**
* Act
* Asks the given agent to perform an action. Optionally
* after sending a message.
*
* <h3>Args:</h3>
*
* - **session_uuid** (str): the uuid of the session
* - **agent** (str): either the uuid or the name of the agent.
* - **message** (Optional[str]): what you're s... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L238-L259 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.guardrail | public static guardrail(
sessionUuid: string,
agent: string,
message: string,
): CancelablePromise<number> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/{session_uuid}/guardrail',
path: {
'session_uuid': sessionUuid,
... | /**
* Guardrail
* Asks whether or not what the player is saying is appropriate given
* the time period, tone, and intent of the game.
*
* <h3>Args:</h3>
*
* - **session_uuid** (str): the uuid of the session
* - **agent** (str): either the uuid or the name of the agent.
* - *... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L281-L300 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.query | public static query(
sessionUuid: string,
agent: string,
requestBody: Array<string>,
): CancelablePromise<Array<number>> {
return __request(OpenAPI, {
method: 'POST',
url: '/session/{session_uuid}/query',
path: {
'session_uuid': ses... | /**
* Query
* Responds to queries into how the Agent is feeling during conversation
* with the player. Write in second person. You can use {player} to refer
* to the player character (since there can be several).
*
* e.g.
* - How suspicious are you that {player} is onto him?
* - ... | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L331-L351 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | GameSessionsService.syncSessionsToGameDefs | public static syncSessionsToGameDefs(
gameUuid: string,
): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'PUT',
url: '/session/sync',
query: {
'game_uuid': gameUuid,
},
errors: {
422: `Validati... | /**
* Updatesessions
* @param gameUuid
* @returns any Successful Response
* @throws ApiError
*/ | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/GameSessionsService.ts#L359-L372 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | LlmService.embed | public static embed(
text: string,
): CancelablePromise<Array<number>> {
return __request(OpenAPI, {
method: 'GET',
url: '/llm/embed',
query: {
'text': text,
},
errors: {
422: `Validation Error`,
... | /**
* Embed
* @param text
* @returns number Successful Response
* @throws ApiError
*/ | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/LlmService.ts#L17-L30 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | LlmService.rate | public static rate(
question: string,
): CancelablePromise<number> {
return __request(OpenAPI, {
method: 'GET',
url: '/llm/rate',
query: {
'question': question,
},
errors: {
422: `Validation Error`,
... | /**
* Rate
* @param question
* @returns number Successful Response
* @throws ApiError
*/ | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/LlmService.ts#L38-L51 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
eastworld | github_2023 | mluogh | typescript | UtilService.getActionJsonSchema | public static getActionJsonSchema(): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'GET',
url: '/action.json',
});
} | /**
* Get Action Json Schema
* @returns string Successful Response
* @throws ApiError
*/ | https://github.com/mluogh/eastworld/blob/70afa3c1983954fa8bd46edd09e391e51cec4bc2/app/src/client/services/UtilService.ts#L16-L21 | 70afa3c1983954fa8bd46edd09e391e51cec4bc2 |
integrations | github_2023 | nolebase | typescript | renderSVGAndRewriteHTML | async function renderSVGAndRewriteHTML(
siteConfig: SiteConfig,
siteTitle: string,
siteDescription: string,
page: PageItem,
file: string,
ogImageTemplateSvg: string,
ogImageTemplateSvgPath: string,
domain: string,
imageUrlResolver: BuildEndGenerateOpenGraphImagesOptions['svgImageUrlResolver'],
addit... | /**
* Render SVG and rewrite HTML
*
* Will always save the rendered Open Graph image as PNG under the same directory as the HTML file with
* the name `og-${fileName of rendered HTML}.png`.
*
* @param {SiteConfig} siteConfig - Site configuration
* @param {string} siteTitle - Site title
* @param {string} siteDesc... | https://github.com/nolebase/integrations/blob/c316b50c5928a9b35d61c487662a2a9fe7196060/packages/vitepress-plugin-og-image/src/vitepress/index.ts#L46-L155 | c316b50c5928a9b35d61c487662a2a9fe7196060 |
integrations | github_2023 | nolebase | typescript | flattenThemeConfigSidebar | function flattenThemeConfigSidebar(sidebar?: DefaultTheme.Sidebar): DefaultTheme.SidebarItem[] {
if (!sidebar)
return []
if (Array.isArray(sidebar))
return sidebar
return Object.keys(sidebar).reduce((prev, curr) => {
const items = sidebar[curr]
return prev.concat(items)
}, [] as DefaultTheme.S... | /**
* Since sidebar is possible to be either items or multi-sidebars, we need to flatten it to a single array.
* @param {DefaultTheme.Sidebar} sidebar
* @returns {DefaultTheme.Sidebar} Flattened sidebar
*/ | https://github.com/nolebase/integrations/blob/c316b50c5928a9b35d61c487662a2a9fe7196060/packages/vitepress-plugin-og-image/src/vitepress/utils/vitepress/sidebar.ts#L58-L69 | c316b50c5928a9b35d61c487662a2a9fe7196060 |
integrations | github_2023 | nolebase | typescript | countWordsByLanguage | function countWordsByLanguage(content: string): Record<string, number> {
return Object.keys(languageHandlers).reduce((accumulator, language) => {
const match = content.match(languageHandlers[language].regex)
accumulator[language] = match ? match.length : 0
return accumulator
}, {})
} | // Function to count words in a text based on the provided language handlers | https://github.com/nolebase/integrations/blob/c316b50c5928a9b35d61c487662a2a9fe7196060/packages/vitepress-plugin-page-properties/src/vite/pageProperties/dynamic/readingTime.ts#L41-L48 | c316b50c5928a9b35d61c487662a2a9fe7196060 |
integrations | github_2023 | nolebase | typescript | calculateThumbHashForFile | async function calculateThumbHashForFile(imageData: Uint8Array): Promise<ThumbHashCalculated> {
const canvasKit = await CanvasKitInit()
const image = canvasKit.MakeImageFromEncoded(imageData)
if (!image)
throw new Error('Failed to make image from encoded data.')
const width = image.width()
const height =... | /**
* Calculate the thumbhash data for the image.
*
* Referenced the following implementations:
* thumbhash/examples/browser/index.html at main · evanw/thumbhash
* https://github.com/evanw/thumbhash/blob/main/examples/browser/index.html
*
* And the following implementations:
* vite-plugin-thumbhash/packages/cor... | https://github.com/nolebase/integrations/blob/c316b50c5928a9b35d61c487662a2a9fe7196060/packages/vitepress-plugin-thumbnail-hash/src/vite/index.ts#L35-L70 | c316b50c5928a9b35d61c487662a2a9fe7196060 |
integrations | github_2023 | nolebase | typescript | digestUint8ArrayDataSha256 | async function digestUint8ArrayDataSha256(data: Uint8Array) {
const hashBuffer = await subtle.digest('SHA-256', data) // hash the message
return Array.from(new Uint8Array(hashBuffer)) // convert buffer to byte array
} | /**
* Hashes the given data using SHA-256 algorithm.
*
* Official example by MDN: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
* @param {Uint8Array} data - The data to be hashed
* @returns {Promise<string>} - The SHA-256 hash of the message
*/ | https://github.com/nolebase/integrations/blob/c316b50c5928a9b35d61c487662a2a9fe7196060/packages/vitepress-plugin-thumbnail-hash/src/vite/utils.ts#L17-L20 | c316b50c5928a9b35d61c487662a2a9fe7196060 |
radiantkit | github_2023 | radiant-labs | typescript | RadiantKitController.activateTool | activateTool(toolId: number) {
this._controller.handleMessage({
SceneMessage: {
SelectTool: {
id: toolId,
},
},
});
} | /**
* Activates the provided tool.
*
* @param tool the tool to activate.
*/ | https://github.com/radiant-labs/radiantkit/blob/7c7eb1c3db742ba2216630694708e4c3049ad321/runtime/web/src/controller/index.ts#L29-L37 | 7c7eb1c3db742ba2216630694708e4c3049ad321 |
imgto.xyz | github_2023 | cloudinary-community | typescript | handleOnDownloadAll | async function handleOnDownloadAll() {
if ( archiveState !== 'ready' ) return;
setArchiveState('archiving');
const downloads = images?.filter(({ optimized }) => !!optimized).map(({ name, upload, optimized }) => {
return {
name,
format: upload?.format,
url: optimized?.url
... | /**
* handleOnDownloadAll
*/ | https://github.com/cloudinary-community/imgto.xyz/blob/1ae41b07bdab4989f7d2c13532d74cd2005a866e/src/components/WidgetUpload/WidgetUpload.tsx#L312-L332 | 1ae41b07bdab4989f7d2c13532d74cd2005a866e |
jsbenchmark | github_2023 | jsbenchmark | typescript | createWorkerBlobUrl | function createWorkerBlobUrl(
fn: Function,
deps: { url: string; name?: string }[],
esm: boolean = false
) {
const blobCode = `${depsParser(deps, esm)} \n onmessage=(${jobRunner})(${fn})`
const blob = new Blob([blobCode], { type: 'text/javascript' })
const url = URL.createObjectURL(blob)
return url
} | /**
* Converts the "fn" function into the syntax needed to be executed within a web worker
*
* @param {Function} fn the function to run with web worker
* @param {Array.<String>} deps array of strings, imported into the worker through "importScripts"
*
* @returns {String} a blob url, containing the code of "fn" as... | https://github.com/jsbenchmark/jsbenchmark/blob/0b120bf2ec689bc11ee2148aa79d70434db27a61/utils/worker/lib/createWorkerBlobUrl.ts#L18-L27 | 0b120bf2ec689bc11ee2148aa79d70434db27a61 |
jsbenchmark | github_2023 | jsbenchmark | typescript | depsParser | function depsParser(deps: Dependency[], esm: boolean = false) {
if (!deps?.length) return ''
if (esm) {
return deps
.map((dep, i) => {
if (!dep.esm) {
return `import '${dep.url}';`
}
const name = dep.name || `DEP_${i}`
return `import * as ${name} from '${dep.ur... | /**
*
* Concatenates the dependencies into a comma separated string.
* this string will then be passed as an argument to the "importScripts" function
*
* @param {Array.<String>} deps array of string
* @returns {String} a string composed by the concatenation of the array
* elements "deps" and "importScripts".
*
... | https://github.com/jsbenchmark/jsbenchmark/blob/0b120bf2ec689bc11ee2148aa79d70434db27a61/utils/worker/lib/depsParser.ts#L15-L37 | 0b120bf2ec689bc11ee2148aa79d70434db27a61 |
jsbenchmark | github_2023 | jsbenchmark | typescript | jobRunner | function jobRunner(userFunc: Function) {
return (e: MessageEvent) => {
const userFuncArgs = e.data[0]
// eslint-disable-next-line prefer-spread
return Promise.resolve(userFunc.apply(undefined, userFuncArgs))
.then((result) => {
postMessage(['SUCCESS', result])
})
.catch((error) ... | /**
* This function accepts as a parameter a function "userFunc"
* And as a result returns an anonymous function.
* This anonymous function, accepts as arguments,
* the parameters to pass to the function "useArgs" and returns a Promise
* This function can be used as a wrapper, only inside a Worker
* because it de... | https://github.com/jsbenchmark/jsbenchmark/blob/0b120bf2ec689bc11ee2148aa79d70434db27a61/utils/worker/lib/jobRunner.ts#L14-L27 | 0b120bf2ec689bc11ee2148aa79d70434db27a61 |
jacob | github_2023 | jacob-ai-bot | typescript | addVariablesForColors | function addVariablesForColors({ addBase, theme }: any) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const allColors = flattenColorPalette(theme("colors"));
const newVars = Object.fromEntries(
Object.entries(allColors).map(([key, val]) => [`--${key}`, val]),
);
addBase({
":root... | // This plugin adds each Tailwind color as a global CSS variable, e.g. var(--gray-200). | https://github.com/jacob-ai-bot/jacob/blob/5694d60c94b4fe050b78278ae33a20c6f650e9b3/tailwind.config.ts#L303-L313 | 5694d60c94b4fe050b78278ae33a20c6f650e9b3 |
jacob | github_2023 | jacob-ai-bot | typescript | createContext | const createContext = async (req: NextRequest) => {
return createTRPCContext({
headers: req.headers,
});
}; | /**
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
* handling a HTTP request (e.g. when you make requests from Client Components).
*/ | https://github.com/jacob-ai-bot/jacob/blob/5694d60c94b4fe050b78278ae33a20c6f650e9b3/src/app/api/trpc/[trpc]/route.ts#L12-L16 | 5694d60c94b4fe050b78278ae33a20c6f650e9b3 |
jacob | github_2023 | jacob-ai-bot | typescript | getImageFiles | async function getImageFiles(
dirPath: string,
imageExtensions: string[],
): Promise<string[]> {
const entries: Dirent[] = await fsPromises.readdir(dirPath, {
withFileTypes: true,
});
const filePaths = await Promise.all(
entries.map(async (entry) => {
const res = path.resolve(dirPath, entry.name... | // Recursive function to get all image files | https://github.com/jacob-ai-bot/jacob/blob/5694d60c94b4fe050b78278ae33a20c6f650e9b3/src/server/analyze/sourceMap.ts#L172-L189 | 5694d60c94b4fe050b78278ae33a20c6f650e9b3 |
jacob | github_2023 | jacob-ai-bot | typescript | fastFileSearch | const fastFileSearch = (
items: ContextItem[],
searchQuery: string,
): ContextItem[] => {
const normalizedQuery = searchQuery.toLowerCase();
return items
.filter((item) => {
const fileName = path.basename(item.file).toLowerCase();
return fileName?.startsWith(normalizedQuery) ?? f... | // Fast file search | https://github.com/jacob-ai-bot/jacob/blob/5694d60c94b4fe050b78278ae33a20c6f650e9b3/src/server/api/routers/codebaseContext.ts#L152-L167 | 5694d60c94b4fe050b78278ae33a20c6f650e9b3 |
jacob | github_2023 | jacob-ai-bot | typescript | isErrorWithStatus | function isErrorWithStatus(error: unknown): error is ErrorWithStatus {
return (
error !== null &&
typeof error === "object" &&
"status" in error &&
typeof (error as ErrorWithStatus).status === "number"
);
} | // Type guard to check if the error has a "status" property | https://github.com/jacob-ai-bot/jacob/blob/5694d60c94b4fe050b78278ae33a20c6f650e9b3/src/server/github/pr.ts#L23-L30 | 5694d60c94b4fe050b78278ae33a20c6f650e9b3 |
jacob | github_2023 | jacob-ai-bot | typescript | getStructuredPlan | const getStructuredPlan = async (o1Plan: string): Promise<Plan> => {
const systemPrompt = `You are part of an advanced AI coding assistant designed to convert detailed plans for resolving Github issues into a structured plan object.
You will be provided a plan, and your job is to convert this into a structured p... | // Function to extract issue information | https://github.com/jacob-ai-bot/jacob/blob/5694d60c94b4fe050b78278ae33a20c6f650e9b3/src/server/utils/plan.ts#L360-L417 | 5694d60c94b4fe050b78278ae33a20c6f650e9b3 |
obsidian-excel | github_2023 | ljcoder2015 | typescript | ExcelView.handleImportClick | handleImportClick(ev: MouseEvent) {
const importEle = document.getElementById("import");
importEle?.click();
} | // 处理顶部导入按钮点击事件 | https://github.com/ljcoder2015/obsidian-excel/blob/d9df140382517562181376d6ba53458e4f76f9c8/src/ExcelView.ts#L75-L78 | d9df140382517562181376d6ba53458e4f76f9c8 |
obsidian-excel | github_2023 | ljcoder2015 | typescript | tmpObsidianWYSIWYG | const tmpObsidianWYSIWYG = async (
el: HTMLElement,
ctx: MarkdownPostProcessorContext
) => {
const file = plugin.app.vault.getAbstractFileByPath(ctx.sourcePath);
// console.log("tmpObsidianWYSIWYG");
if (!(file instanceof TFile)) return;
if (!plugin.isExcelFile(file)) return;
//@ts-ignore
if (ctx.remainingNest... | // 编辑模式 | https://github.com/ljcoder2015/obsidian-excel/blob/d9df140382517562181376d6ba53458e4f76f9c8/src/MarkdownPostProcessor.ts#L28-L193 | d9df140382517562181376d6ba53458e4f76f9c8 |
obsidian-excel | github_2023 | ljcoder2015 | typescript | createEditSheetHtml | const createEditSheetHtml = (
excelData: string,
file: TFile,
sheet: string,
cells: string
): HTMLDivElement => {
const sheetDiv = createDiv();
if (plugin.settings.showSheetButton == "true") {
const fileEmbed = sheetDiv.createDiv({
cls: "internal-embed file-embed mod-generic is-loaded",
text: file.basen... | /**
* 编辑模式下转换成 HTML 显示
* @param data markdown 文件原始data
* @param sheet sheet 名称
* @param cells 选中的cells 格式为: sri-sci:eri-eci 例如 6-6:7-8
* @returns
*/ | https://github.com/ljcoder2015/obsidian-excel/blob/d9df140382517562181376d6ba53458e4f76f9c8/src/MarkdownPostProcessor.ts#L203-L242 | d9df140382517562181376d6ba53458e4f76f9c8 |
obsidian-excel | github_2023 | ljcoder2015 | typescript | createSheetHtml | const createSheetHtml = (
data: string,
file: TFile,
sheet: string,
cells: string
): HTMLDivElement => {
const sheetDiv = createDiv();
if (plugin.settings.showSheetButton == "true") {
const fileEmbed = sheetDiv.createDiv({
cls: "internal-embed file-embed mod-generic is-loaded",
text: file.basename,
at... | /**
* 预览模式下转换成 HTML 显示
* @param data markdown 文件原始data
* @param sheet sheet 名称
* @param cells 选中的cells 格式为: sri-sci:eri-eci 例如 6-6:7-8
* @returns
*/ | https://github.com/ljcoder2015/obsidian-excel/blob/d9df140382517562181376d6ba53458e4f76f9c8/src/MarkdownPostProcessor.ts#L251-L288 | d9df140382517562181376d6ba53458e4f76f9c8 |
obsidian-excel | github_2023 | ljcoder2015 | typescript | createSheetEl | const createSheetEl = (
data: string,
file: TFile,
width: number,
height: number = 300
): HTMLDivElement => {
const sheetDiv = createDiv();
if (plugin.settings.showSheetButton == "true") {
const fileEmbed = sheetDiv.createDiv({
cls: "internal-embed file-embed mod-generic is-loaded",
text: file.basename,
... | /**
* bembed link 显示
*/ | https://github.com/ljcoder2015/obsidian-excel/blob/d9df140382517562181376d6ba53458e4f76f9c8/src/MarkdownPostProcessor.ts#L293-L398 | d9df140382517562181376d6ba53458e4f76f9c8 |
CookiesClerk | github_2023 | 14790897 | typescript | getStorageData | async function getStorageData<T>(storageKey: string, defaultValue: T = {} as T): Promise<T> {
try {
const result = await chrome.storage.local.get(storageKey)
if (!result[storageKey]) {
console.log('Notice: the value is null in getStorageData. storageKey:', storageKey) //这里不应该抛出错误,因为这个函数是用来获取数据的,如果没有数据,就... | // 定义变量的类型 | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L34-L45 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | checkTabsAndCleanAccounts | async function checkTabsAndCleanAccounts() {
const accounts = await getStorageData<Record<string, Account>>('accounts') //8.27
// 创建一个新的对象来存储修改后的账户
const updatedAccounts: Record<string, Account> = {}
Object.keys(accounts).forEach((accountKey) => {
let modifiedKey = modifyTabIdFromKey(accountKey, true)
... | //每次重新打开浏览器插件时,需要检测一遍这个浏览器窗口的所有标签页,看是否和我现在账户列表里的域名加标签位置的域名是否匹配,如果不匹配,就把账户里对应的选项给删除 8.14 | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L63-L85 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | listener | const listener = async (tabId, changeInfo, tab) => {
if (changeInfo.status === 'complete') {
console.log('进入手动加载cookies的loadcookies部分')
loadCookies(rootDomain, accounts[request.account].cookies)
loadLocalStorage(tabId, accounts[request.account].localstorage)
... | // 添加监听器 | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L157-L167 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | extractTabIdFromKey | function extractTabIdFromKey(key: string, modify = false) {
const keyParts = key.split('-')
if (modify) {
return keyParts[0] + '-' + '0'
}
return keyParts[keyParts.length - 1] // tabID存储在键的最后一部分
} | //This function should be triggered manually | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L439-L445 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | handleTabChange | async function handleTabChange(tabId: number) {
let currentTabId: number | null = null
let clearCookiesEnabled = false
let accounts: Record<string, Account> = {}
try {
// If there is a currently active tab, save its cookies
currentTabId = await getStorageData<number | null>('currentTabId', null) //8.27
... | //这段代码的功能是激活新的tab时,先保存旧的页面的 cookies,然后清除旧的页面的cookies,然后加载新的页面的cookies | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L514-L603 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | saveCurrentCookies | async function saveCurrentCookies(rootDomain: string, key: string, manualSave: boolean | string = false): Promise<void> {
try {
const accounts = await getStorageData<Record<string, Account>>('accounts') //8.27
// Save the current cookies for this URL and tab index
let cookies = await chrome.cookies.getAl... | // Save the current cookies for the specified tab | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L606-L647 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | adjustCookieForSpecialNames | function adjustCookieForSpecialNames(cookie: any) {
// 如果 cookie 名称以 "__Host-" 开头
if (cookie.name.startsWith('__Host-')) {
delete cookie.domain // 移除 domain 属性
}
return cookie
} | // 辅助函数:根据 cookie 名称调整 cookie 属性 | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L654-L660 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | loadCookies | async function loadCookies(rootDomain: string, cookies: chrome.cookies.Cookie[]): Promise<void> {
try {
console.log('loadCookies已触发,clear的输出应该在此之前')
const existingCookies = await chrome.cookies.getAll({ domain: rootDomain })
const promises = Object.values(cookies).map(async (cookie) => {
// todo 执行这... | // Load the specified cookies for the specified URL | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L670-L713 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | clearCookiesForDomain | async function clearCookiesForDomain(domain: string) {
try {
const cookies = await chrome.cookies.getAll({ domain })
console.log('%c clear----------------------', 'background: #00ff00; color: #000')
console.log(`%c Found ${cookies.length} cookies for domain: ${domain}`, 'background: #00ff00; color: #000'... | // 清除特定域名的所有 cookies | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L717-L743 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | clearBrowsingDataForDomain | async function clearBrowsingDataForDomain(domain: string) {
try {
let url = domain
if (!domain.startsWith('http://') && !domain.startsWith('https://')) {
url = 'https://' + domain // 添加默认的 http 协议
}
await chrome.browsingData.remove(
{
origins: [url],
},
{
cacheS... | // if (!url.startsWith('http://') && !url.startsWith('https://')) { | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L748-L772 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
CookiesClerk | github_2023 | 14790897 | typescript | modifyLinksAndForms | function modifyLinksAndForms() {
document.querySelectorAll('a').forEach(function (link) {
link.target = '_self'
})
// document.querySelectorAll('form').forEach(function (form) {
// form.addEventListener('submit', function (event) {
// event.preventDefa... | // 函数:修改链接和表单 | https://github.com/14790897/CookiesClerk/blob/27df2d684c01a4478be93f7e7bb3f587240d78b5/src/background/index.ts#L949-L959 | 27df2d684c01a4478be93f7e7bb3f587240d78b5 |
moyu-chat | github_2023 | chenbb0128 | typescript | dispatchRoomTextMsg | async function dispatchRoomTextMsg(msg: Message, room: Room) {
const topic = await room.topic()
const content = msg.text().trim()
const contact = msg.talker()
const alias = await contact.alias()
const name = alias ? `${contact.name()}(${alias})` : contact.name()
log.info(`群【${topic}】【${name}】 发送了:${content... | /**
* 群文本消息
* @param msg
* @param room
*/ | https://github.com/chenbb0128/moyu-chat/blob/d094cbe4019820e8ff7b8570ccfac3f9a9cd0af9/src/listeners/onMessage.ts#L81-L89 | d094cbe4019820e8ff7b8570ccfac3f9a9cd0af9 |
moyu-chat | github_2023 | chenbb0128 | typescript | dispatchFriendTextMsg | async function dispatchFriendTextMsg(msg: Message) {
const content = msg.text().trim()
const contact = msg.talker()
const alias = await contact.alias()
const name = alias ? `${contact.name()}(${alias})` : contact.name()
log.info(`好友【${name}】 发送了:${content}`)
} | /**
* 好友文本消息
* @param msg
*/ | https://github.com/chenbb0128/moyu-chat/blob/d094cbe4019820e8ff7b8570ccfac3f9a9cd0af9/src/listeners/onMessage.ts#L95-L102 | d094cbe4019820e8ff7b8570ccfac3f9a9cd0af9 |
moyu-chat | github_2023 | chenbb0128 | typescript | getFileContentAsBase64 | function getFileContentAsBase64(path) {
try {
return fs.readFileSync(path, { encoding: 'base64' })
}
catch (err) {
throw new Error(err)
}
} | /**
* 获取文件base64编码
* @param string path 文件路径
* @return string base64编码信息,不带文件头
*/ | https://github.com/chenbb0128/moyu-chat/blob/d094cbe4019820e8ff7b8570ccfac3f9a9cd0af9/src/utils/asr.ts#L74-L81 | d094cbe4019820e8ff7b8570ccfac3f9a9cd0af9 |
bisheng | github_2023 | dataelement | typescript | callBack | const callBack = async (id) => {
await sensitiveSaveApi({ ..._form, id, type });
message({ title: t('prompt'), variant: 'success', description: t('build.saveSuccess') });
} | // 在线状态不允许修改 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/Pro/security/FlowSetting.tsx#L48-L51 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | callBack | const callBack = async (id) => {
sensitiveSaveApi({ ...form, isCheck: bln, id, type });
} | // 在线状态不允许修改 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/Pro/security/FlowSetting.tsx#L59-L61 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleSave | const handleSave = async (_item) => {
if (!_item.name) {
return setErrorData({
title: t('prompt'),
list: [t('flow.enterVarName')]
});
}
// 重名校验
const hasName = items.find(item => item.name === _item.name)
if (hasName && hasN... | // save | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/VariablesComponent/index.tsx#L43-L79 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDelClick | const handleDelClick = async (index) => {
let newItems = cloneDeep(items);
const item = newItems.splice(index, 1);
item[0].update && await captureAndAlertRequestErrorHoc(delVariableApi(item[0].id))
setItems(newItems)
// 触发必填校验
!newItems.length && onChange('')
} | // | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/VariablesComponent/index.tsx#L82-L89 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleClickGuideWord | const handleClickGuideWord = (message) => {
if (!showWhenLocked && inputLock.locked) return console.error('弹窗已锁定,消息无法发送')
inputRef.current.value = message
handleSendClick()
} | // 点击引导词 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx#L266-L270 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleTextAreaHeight | const handleTextAreaHeight = (e) => {
const textarea = e.target
textarea.style.height = 'auto'
textarea.style.height = textarea.scrollHeight + 'px'
// setInputEmpty(textarea.value.trim() === '')
} | // auto input height | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx#L273-L278 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDownloadFile | const handleDownloadFile = (file) => {
const url = file?.file_url
url && downloadFile(checkSassUrl(url), file?.file_name)
} | // download file | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/bs-comp/chatComponent/FileBs.tsx#L27-L30 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleChange | const handleChange = (newValue, id, index) => {
let newInputs = inputs.map(input =>
input.id === id ? { ...input, value: newValue } : input
);
// push
if (index === newInputs.length - 1) {
newInputs = ([...newInputs, { id: generateUUID(8), ... | // 依赖项中包含 value,确保外部 value 更新时同步更新 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/bs-ui/input/index.tsx#L176-L186 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleRemoveInput | const handleRemoveInput = (id) => {
const newInputs = inputs.filter(input => input.id !== id);
setInputs(newInputs);
props.onChange(newInputs.map(input => input.value));
}; | // delete input | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/bs-ui/input/index.tsx#L189-L193 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDelete | const handleDelete = (value: string) => {
const newValues = (values as any[]).filter((item) => {
const _value = onScrollLoad ? (item as Option).value : item;
return _value !== value
})
setValues(newValues)
onChange?.(newValues)
} | // delete | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/bs-ui/select/multi.tsx#L109-L116 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | fetchBuildStatus | const fetchBuildStatus = async () => {
const response = await getBuildStatus(flow.id, version.id);
setIsBuilt(response.built);
}; | // Define an async function within the useEffect hook | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/components/chatComponent/index.tsx#L41-L44 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | setErrorData | function setErrorData(newState: { title: string; list?: Array<string> }) {
setErrorDataState(newState);
setErrorOpen(true);
setNotificationCenter(true);
pushNotificationList({
type: "error",
title: newState.title || " ",
list: newState.list,
id: uniqueId(),
});
} | /**
* Sets the error data state, opens the error dialog and pushes the new error notification to the notification list
* @param newState An object containing the new error data, including title and optional list of error messages
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/alertContext.tsx#L80-L90 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | setNoticeData | function setNoticeData(newState: { title: string; link?: string }) {
if (newState.title && newState.title !== "") {
setNoticeDataState(newState);
setNoticeOpen(true);
// Add new notice to notification center
setNotificationCenter(true);
pushNotificationList({
type: "notice",
... | /**
* Sets the state of the notice data and opens the notice modal, also adds a new notice to the notification center if the title is defined.
* @param newState An object containing the title of the notice and optionally a link.
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/alertContext.tsx#L95-L108 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | setSuccessData | function setSuccessData(newState: { title: string }) {
// If the new state has a "title" property, add a new success notification to the list
if (newState.title && newState.title !== "") {
setSuccessDataState(newState); // update the success data state with the provided new state
setSuccessOpen(true... | /**
* Update the success data state and show a success alert notification.
* @param newState - A state object with a "title" property to set in the success data state.
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/alertContext.tsx#L113-L126 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | uploadFlow | function uploadFlow(file?: File) {
if (file) {
file.text().then((text) => {
// parse the text into a JSON object
let flow: FlowType = JSON.parse(text);
// 粘贴
paste(
{ nodes: flow.data.nodes, edges: flow.data.edges },
{ x: 10, y: 10 },
true
... | /**
* Creates a file input and listens to a change event to upload a JSON flow file.
* If the file type is application/json, the file is read and parsed into a JSON object.
* The resulting JSON object is passed to the addFlow function.
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/tabsContext.tsx#L73-L116 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | downloadFlow | function downloadFlow(
flow: FlowType,
flowName: string,
flowDescription?: string
) {
// create a data URI with the current flow data
const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
JSON.stringify({ ...flow, name: flowName, description: flowDescription })
)}`;
... | /**
* Downloads the current flow as a JSON file
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/tabsContext.tsx#L125-L145 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | paste | function paste(
selectionInstance,
position: { x: number; y: number; paneX?: number; paneY?: number },
keepId: boolean = false // keep id
) {
let minimumX = Infinity;
let minimumY = Infinity;
let idsMap = {};
let nodes = reactFlowInstance.getNodes();
let edges = reactFlowInstance.getEd... | /**
* Add a new flow to the list of flows.
* @param flow Optional flow to add.
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/tabsContext.tsx#L152-L245 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | updateNodeEdges | function updateNodeEdges(
flow: FlowType,
node: NodeType,
template: APIClassType
) {
flow.data.edges.forEach((edge) => {
if (edge.source === node.id) {
edge.sourceHandle = edge.sourceHandle
.split("|")
.slice(0, 2)
.concat(template["base_classes"])
... | // -- | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/tabsContext.tsx#L248-L262 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | checkComponentsName | const checkComponentsName = (name: string) => {
return savedComponents.some(item => item.name === name)
} | // 重名校验 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/userContext.tsx#L39-L41 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | delComponent | const delComponent = (name) => {
delComponentApi(name).then(res => {
setSavedComponents(comps => comps.filter(item => item.name !== name))
})
} | // del | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/contexts/userContext.tsx#L86-L90 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | updateLastMessage | function updateLastMessage({
str,
thought,
end = false,
files,
}: {
str?: string;
thought?: string;
// end param default is false
end?: boolean;
files?: Array<any>;
}) {
setChatHistory((old) => {
if (!old.length) return old // 拒绝 chatHistory无数据时接收数据
let newChat = ... | //add proper type signature for function | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/modals/formModal/index.tsx#L125-L175 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleCheckedChange | const handleCheckedChange = (checked, data) => {
if (data.flow_type === 1) {
return captureAndAlertRequestErrorHoc(updataOnlineState(data.id, data, checked).then(res => {
if (res) {
refreshData((item) => item.id === data.id, { status: checked ? 2 : 1 })
... | // 上下线 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/apps.tsx#L82-L105 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | getWsParamData | const getWsParamData = (action, msg, data) => {
const inputKey = 'input';
const msgData = {
chatHistory: messages,
flow_id: data?.id || assisId,
chat_id: '',
name: assistantState.name,
description: assistantState.desc,
inputs: {}
... | // send 前获取参数用来做 params to send ws | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/assistant/editAssistant/TestChat.tsx#L25-L39 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleChangeVersion | const handleChangeVersion = async (versionId) => {
setLoading(true)
// 切换版本UI
window.flow_version = Number(versionId)
// 加载选中版本data
const res = await getVersionDetails(versionId)
// console.log('res :>> ', res)
// 自动触发 page的 clone flow
setFlow(null)
... | // 切换版本 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Header.tsx#L173-L192 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleSaveNewVersion | const handleSaveNewVersion = async () => {
// 累加版本 vx ++
const maxNo = lastVersionIndexRef.current + 1
const { nodes, edges, viewport } = flow
const res = await captureAndAlertRequestErrorHoc(
createFlowVersion(flow.id, { name: `v${maxNo}`, description: '', data: { nodes, edg... | // new version | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Header.tsx#L198-L215 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleSaveAndClose | const handleSaveAndClose = async () => {
if (isOnlineVersion) {
handleSaveNewVersion()
blocker.reset?.()
} else {
const res = await handleSaveClick()
res ? blocker.proceed?.() : blocker.reset?.()
}
} | // 离开并保存 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Header.tsx#L222-L230 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | sendEvent | const sendEvent = (ids) => {
const event = new CustomEvent('nodeErrorBorderEvent', {
detail: {
nodeIds: ids
}
});
window.dispatchEvent(event);
}; | // event func | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Header.tsx#L462-L469 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleNodeUpdate | const handleNodeUpdate = (event) => {
const { nodeId, newData } = event.detail;
// 根据 nodeId 和 newData 更新节点状态
setNodes((nds) =>
nds.map((node) =>
node.id === nodeId ? { ...node, data: { ...node.data, ...newData } } : node
)
... | // 定义事件监听器 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Panne.tsx#L300-L308 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleNodeDelete | const handleNodeDelete = (event) => {
takeSnapshot()
const nodeId = event.detail;
setNodes((nodes) => nodes.filter((n) => n.id !== nodeId));
setEdges((edges) => edges.filter((ns) => ns.source !== nodeId && ns.target !== nodeId));
} | // del node | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Panne.tsx#L310-L315 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleCopy | const handleCopy = (event) => {
const nodeIds = event.detail;
let nodes = _reactFlowInstance.getNodes();
// let edges = _reactFlowInstance.getEdges();
const newNodes = nodeIds.map(nodeId => {
const node = nodes.find(n => n.id === nodeId);
c... | // copy | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Panne.tsx#L318-L350 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleAddNode | const handleAddNode = (event) => {
takeSnapshot()
const { id, targetNode, isLeft, position } = event.detail;
const newNode = cloneDeep(event.detail.newNode)
window.dispatchEvent(new CustomEvent("closeHandleMenu"));
const nodeId = `${newNode.type}_${generateUU... | // add node by handle | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Panne.tsx#L352-L399 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDelOutputEdge | const handleDelOutputEdge = (event) => {
const { nodeId } = event.detail;
setEdges((eds) => eds.filter((ns) => ns.source !== nodeId));
} | // 删除输出节点连线 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/Panne.tsx#L402-L405 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDownloadFile | const handleDownloadFile = (filePath) => {
filePath && downloadFile(checkSassUrl(filePath), fileName)
} | // download file | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatFileFile.tsx#L9-L11 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleWsMessage | const handleWsMessage = (data) => {
if (data.category === 'error') {
const { code, message } = data.message
return toast({
variant: 'error',
description: code == 500 ? message : t(`errors.${code}`, { type: message })
});
}
if (d... | // 接受 ws 消息 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatInput.tsx#L236-L300 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | sendNodeLogEvent | const sendNodeLogEvent = (data) => {
const { node_id } = data.message
const isError = !!data.message.reason
const event = new CustomEvent('nodeLogEvent', {
detail: {
nodeId: node_id,
action: isError ? '' : data.type === 'start' ? 'loading' : 'success',... | // 日志广播->nodes | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatInput.tsx#L303-L314 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleClickGuideWord | const handleClickGuideWord = (message) => {
if (inputLock.locked) return console.error('弹窗已锁定,消息无法发送')
inputRef.current.value = message
handleSendClick()
} | // 点击引导词 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatInput.tsx#L351-L355 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleTextAreaHeight | const handleTextAreaHeight = (e) => {
const textarea = e.target
textarea.style.height = 'auto'
textarea.style.height = textarea.scrollHeight + 'px'
// setInputEmpty(textarea.value.trim() === '')
} | // auto input height | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatInput.tsx#L358-L363 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleStopClick | const handleStopClick = () => {
if (stop.disable) return
setStop({ show: true, disable: true });
setInputLock({ locked: true, reason: '' })
sendWsMsg({ "action": "stop" });
} | // stop click | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatInput.tsx#L366-L371 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleRestartClick | const handleRestartClick = () => {
wsRef.current?.close()
wsRef.current = null
stop.show && insetSeparator('本轮会话已结束')
setTimeout(() => {
createWebSocket().then(() => {
sendWsMsg(onBeforSend('init_data', {}))
})
}, 300);
} | // restart | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowChat/ChatInput.tsx#L373-L382 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | loadMore | const loadMore = (name) => {
reload(pageRef.current + 1, name)
} | // 加载更多 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/KnowledgeQaSelectItem.tsx#L32-L34 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | loadFiles | const loadFiles = () => {
const files = []
flow.nodes.forEach(node => {
if (node.data.type !== 'input') return
node.data.group_params.forEach(group => {
group.params.forEach(param => {
if (param.key === 'form_input') {
p... | // input文件变量s | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/KnowledgeSelectItem.tsx#L61-L79 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | loadMore | const loadMore = (name) => {
reload(pageRef.current + 1, name)
} | // const handleChange = (res) => { | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/KnowledgeSelectItem.tsx#L92-L94 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | traverseNodes | const traverseNodes = (node) => {
let result = tempDiv !== node && node.nodeName === 'DIV' ? '\n' : '';
node.childNodes.forEach((child) => {
if (child.nodeName === 'BR') {
result += '\n'; // 换行符
} else if (child.nodeType === Node.TEXT_NODE) {
resul... | // 遍历子节点,将 <br> 转换为 \n,同时处理文本内容 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/VarInput.tsx#L36-L48 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDrag | const handleDrag = (e) => {
e.preventDefault();
const newHeight = e.clientY - textareaRef.current.getBoundingClientRect().top;
if (newHeight > minHeight) {
setHeight(newHeight); // 更新高度
}
}; | // 初始高度 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/VarInput.tsx#L239-L245 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleInputChange | const handleInputChange = (msg) => {
onChange({ msg, files })
} | // console.log('data.value :>> ', data.value); | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/VarTextareaUploadItem.tsx#L12-L14 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleFilesChange | const handleFilesChange = (updatedFiles) => {
onChange({ msg: data.value?.msg, files: updatedFiles })
}; | // Handle file upload | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/VarTextareaUploadItem.tsx#L16-L18 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleFileUpload | const handleFileUpload = () => {
const input = document.createElement("input");
input.type = "file";
input.accept = "image/*,application/pdf,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentatio... | // Handle file upload | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/VarTextareaUploadItem.tsx#L94-L121 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleFileRemove | const handleFileRemove = (filePath) => {
const newFiles = files.filter(file => file.path !== filePath);
setFiles(newFiles);
onFilesChange?.(newFiles);
}; | // Handle file removal | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/flow/FlowNode/component/VarTextareaUploadItem.tsx#L124-L128 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDragEnd | const handleDragEnd = ({ source, destination }: any) => {
if (!destination) {
return;
}
const updatedItems = Array.from(items);
const [removed] = updatedItems.splice(source.index, 1);
updatedItems.splice(destination.index, 0, removed);
handleSave(updatedItem... | // sort | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/FormSet.tsx#L36-L47 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleCheckedChange | const handleCheckedChange = (checked, data) => {
// data.versionId todo
return captureAndAlertRequestErrorHoc(updataOnlineState(data.id, data, checked).then(res => {
if (res) {
refreshData((item) => item.id === data.id, { status: checked ? 2 : 1 })
}
r... | // 上下线 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/index.tsx#L39-L47 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handldSelectTemp | const handldSelectTemp = async (tempId) => {
const [flow] = await readTempsDatabase('skill', tempId)
flow.name = `${flow.name}-${generateUUID(5)}`
// @ts-ignore
captureAndAlertRequestErrorHoc(saveFlowToDatabase({ ...flow, id: flow.flow_id }).then((res: any) => {
res.user_nam... | // 选模板(创建技能) | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/index.tsx#L67-L78 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleChangeVersion | const handleChangeVersion = async (versionId) => {
setLoading(true)
reactFlowInstance.setNodes([]) // 便于重新渲染节点
// 保存当前版本
// updateVersion(version.id, { name: version.name, description: '', data: flow.data })
// 切换版本UI
setCurrentVersion(Number(versionId))
// 加载选中版本... | // 切换版本 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/editSkill/Header.tsx#L78-L95 | be229e3e63eabfacbd35ae4971485980932f7227 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.