repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
nodejs-vertexai | github_2023 | googleapis | typescript | GenerativeModelPreview.generateContentStream | async generateContentStream(
request: GenerateContentRequest | string
): Promise<StreamGenerateContentResult> {
request = formulateRequestToGenerateContentRequest(request);
const formulatedRequest = {
...formulateSystemInstructionIntoGenerateContentRequest(
request,
this.systemInstru... | /**
* Makes an async stream request to generate content.
*
* The response is returned chunk by chunk as it's being generated in {@link
* StreamGenerateContentResult.stream}. After all chunks of the response are
* returned, the aggregated response is available in
* {@link StreamGenerateContentResult.re... | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/models/generative_models.ts#L410-L433 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | GenerativeModelPreview.startChat | startChat(request?: StartChatParams): ChatSessionPreview {
const startChatRequest: StartChatSessionRequest = {
project: this.project,
location: this.location,
googleAuth: this.googleAuth,
publisherModelEndpoint: this.publisherModelEndpoint,
resourcePath: this.resourcePath,
tools:... | /**
* Instantiates a {@link ChatSessionPreview}.
*
* The {@link ChatSessionPreview} class is a stateful class that holds the state of
* the conversation with the model and provides methods to interact with the
* model in chat mode. Calling this method doesn't make any calls to a remote
* endpoint. To ... | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/models/generative_models.ts#L488-L515 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | CachedContents.create | create(cachedContent: CachedContent): Promise<CachedContent> {
const curatedCachedContent = {
...cachedContent,
systemInstruction: cachedContent.systemInstruction
? formulateSystemInstructionIntoContent(cachedContent.systemInstruction)
: undefined,
model: inferModelName(
th... | /**
* Creates cached content, this call will initialize the cached content in the data storage, and users need to pay for the cache data storage.
* @param cachedContent
* @param parent - Required. The parent resource where the cached content will be created.
*/ | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/resources/cached_contents.ts#L154-L167 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | CachedContents.update | update(
cachedContent: CachedContent,
updateMask: string[]
): Promise<CachedContent> {
if (!cachedContent.name) {
throw new ClientError('Cached content name is required for update.');
}
if (!updateMask || updateMask.length === 0) {
throw new ClientError(
'Update mask is require... | /**
* Updates cached content configurations
*
* @param updateMask - Required. The list of fields to update. Format: google-fieldmask. See {@link https://cloud.google.com/docs/discovery/type-format}
* @param name - Immutable. Identifier. The server-generated resource name of the cached content Format: projec... | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/resources/cached_contents.ts#L175-L199 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | CachedContents.delete | delete(name: string): Promise<void> {
return this.client.delete(
inferFullResourceName(
this.client.apiClient.project,
this.client.apiClient.location,
name
)
);
} | /**
* Deletes cached content.
*
* @param name - Required. The resource name referring to the cached content.
*/ | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/resources/cached_contents.ts#L206-L214 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | CachedContents.list | list(
pageSize?: number,
pageToken?: string
): Promise<ListCachedContentsResponse> {
return this.client.list(pageSize, pageToken);
} | /**
* Lists cached contents in a project.
*
* @param pageSize - Optional. The maximum number of cached contents to return. The service may return fewer than this value. If unspecified, some default (under maximum) number of items will be returned. The maximum value is 1000; values above 1000 will be coerced to... | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/resources/cached_contents.ts#L222-L227 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | CachedContents.get | get(name: string): Promise<CachedContent> {
return this.client.get(
inferFullResourceName(
this.client.apiClient.project,
this.client.apiClient.location,
name
)
);
} | /**
* Gets cached content configurations.
*
* @param name - Required. The resource name referring to the cached content.
*/ | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/resources/cached_contents.ts#L234-L242 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | ApiClient.fetchToken | private fetchToken(): Promise<string | null | undefined> {
const tokenPromise = this.googleAuth.getAccessToken().catch(e => {
throw new GoogleAuthError(constants.CREDENTIAL_ERROR_MESSAGE, e);
});
return tokenPromise;
} | /**
* Gets access token from GoogleAuth. Throws {@link GoogleAuthError} when
* fails.
* @returns Promise of token string.
*/ | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/resources/shared/api_client.ts#L44-L49 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
nodejs-vertexai | github_2023 | googleapis | typescript | GenerateContentResponseHandler.getFunctionCallsFromCandidate | static getFunctionCallsFromCandidate(
candidate?: GenerateContentCandidate
): FunctionCall[] {
if (!candidate) return [] as FunctionCall[];
return candidate.content.parts
.filter((part: Part | undefined) => !!part && !!part.functionCall)
.map((part: Part) => part.functionCall!);
} | /**
* Extracts function calls from a {@link GenerateContentCandidate}.
*
* @param candidate - The candidate to extract function calls from.
* @returns the array of function calls in a {@link GenerateContentCandidate}.
*/ | https://github.com/googleapis/nodejs-vertexai/blob/99f3ee8a4589b97f32fa14e0f3adc01163cd9846/src/types/generate_content_response_handler.ts#L30-L37 | 99f3ee8a4589b97f32fa14e0f3adc01163cd9846 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Canvas.isDefaultMode | public isDefaultMode() {
return !this.grab.on && !this.insert.on;
} | /**
* 判断是否默认模式
* @description 根据状态判断拖拽、插入状态
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/index.ts#L120-L122 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | ElementNode.onMouseEnter | protected onMouseEnter = () => {
this.isHovering = true;
if (this.editor.selection.has(this.id)) {
return void 0;
}
this.editor.canvas.mask.drawingEffect(this.range);
} | /**
* 触发节点的 Hover 效果
* @description Root - MouseLeave
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/element.ts | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | FrameNode.onRootMouseDown | private onRootMouseDown = (e: MouseEvent) => {
this.savedRootMouseDown(e);
this.unbindOpEvents();
this.bindOpEvents();
this.landing = Point.from(e.x, e.y);
this.landingClient = Point.from(e.clientX, e.clientY);
} | /**
* 框选事件的起始
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/frame.ts | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Node.parent | public get parent() {
return this._parent;
} | // ====== Parent ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/node.ts#L40-L42 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Node.range | public get range() {
return this._range;
} | // ====== Range ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/node.ts#L49-L51 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Node.z | public get z() {
return this._z;
} | // ====== Z-Index ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/node.ts#L58-L60 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Node.ignoreEvent | public get ignoreEvent() {
return this._ignoreEvent;
} | // ====== Event ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/node.ts#L75-L77 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Node.append | public append<T extends Node>(node: T | Empty) {
if (!node) return void 0;
// 类似希尔排序 保证`children`有序 `zIndex`升序
// 如果使用`sort`也可以 `ES`规范添加了`sort`作为稳定排序
const index = this.children.findIndex(item => item.z > node.z);
if (index > -1) {
this.children.splice(index, 0, node);
} else {
this.... | // ====== DOM OP ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/node.ts#L84-L96 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Node.getFlatNode | public getFlatNode() {
if (this.flatNodes) {
return this.flatNodes;
}
// 右子树优先后序遍历 保证事件调用的顺序
const nodes: Node[] = [];
const reverse = [...this.children].reverse();
reverse.forEach(node => {
nodes.push(...node.getFlatNode());
nodes.push(node);
});
this.flatNodes = nodes... | /**
* 获取当前节点树的所有子节点
* @returns
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/node.ts#L127-L140 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | ReferNode.setRange | public setRange() {} | // COMPAT: 避免`Range`变换 | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/refer.ts#L27-L27 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | ReferNode.onMouseMoveController | public onMouseMoveController = (latest: Range) => {
this.clearNodes();
if (!latest || !this.editor.canvas.root.select.isDragging) return void 0;
if (this.sortedX.length === 0 && this.sortedY.length === 0) {
this.onMouseUpController(); // 取消所有状态
return void 0;
}
// 选中的节点候选`5`个点
// * ... | /**
* 拖拽选区的鼠标移动事件
* @param latest 拖拽选区的最新 Range
* @description 作为 SelectNode 的子元素 Node 事件
* 基于父元素的事件调用链执行当前的事件绑定
* 避免多次对父元素的 Range 修改来保证值唯一
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/refer.ts | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | createReferNode | const createReferNode = (range: Range) => {
nextPaintRange = nextPaintRange.compose(range);
const node = new Node(range);
node.setIgnoreEvent(true);
node.drawingMask = this.drawingMaskDispatch;
this.append(node);
this.matched = true;
}; | // 构建参考线节点 | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/refer.ts#L135-L142 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | SelectNode.unbindDragEvents | private bindDragEvents = () => {
this.editor.event.on(EDITOR_EVENT.MOUSE_UP_GLOBAL, this.onMouseUpController);
this.editor.event.on(EDITOR_EVENT.MOUSE_MOVE_GLOBAL, this.onMouseMoveController);
} | /**
* 绑定拖拽事件的触发器
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/dom/select.ts | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Mask.collectEffects | private collectEffects(range: Range) {
// 判定`range`范围内影响的节点
const effects = new Set<Node>();
const nodes: Node[] = this.engine.root.getFlatNode(false);
// 渲染顺序和事件调用顺序相反
for (let i = nodes.length - 1; i >= 0; i--) {
const node = nodes[i];
// 需要排除`root`否则必然导致全量重绘
if (node === this.en... | // ====== Drawing On Demand ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/paint/mask.ts#L37-L51 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Mask.setCursorState | public setCursorState(type: keyof typeof CURSOR_STATE | null) {
this.canvas.style.cursor = isEmptyValue(type) ? "" : CURSOR_STATE[type];
return this;
} | // ====== State ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/paint/mask.ts#L97-L100 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Mask.reset | public reset() {
this.clear();
const { width, height } = this.engine.getRect();
const ratio = this.engine.devicePixelRatio;
this.canvas.width = width * ratio;
this.canvas.height = height * ratio;
this.canvas.style.width = width + "px";
this.canvas.style.height = height + "px";
this.canva... | // ====== Canvas Actions ====== | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/paint/mask.ts#L111-L121 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Shape.rect | public static rect(ctx: CanvasRenderingContext2D, options: RectProps) {
ctx.beginPath();
ctx.rect(options.x, options.y, options.width, options.height);
if (options.fillColor) {
ctx.fillStyle = options.fillColor;
ctx.fill();
}
if (options.borderColor) {
ctx.strokeStyle = options.bor... | /**
* 绘制矩形
* @param ctx
* @param options
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/utils/shape.ts#L34-L47 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Shape.arc | public static arc(ctx: CanvasRenderingContext2D, options: ArcProps) {
ctx.beginPath();
ctx.arc(options.x, options.y, options.radius, 0, 2 * Math.PI);
if (options.fillColor) {
ctx.fillStyle = options.fillColor;
ctx.fill();
}
if (options.borderColor) {
ctx.strokeStyle = options.borde... | /**
* 绘制圆形
* @param ctx
* @param options
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/utils/shape.ts#L54-L67 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Shape.frame | public static frame(ctx: CanvasRenderingContext2D, options: FrameProps) {
// https://stackoverflow.com/questions/36615592/canvas-inner-stroke
ctx.save();
ctx.beginPath();
const frame = [options.x - 1, options.y - 1, options.width + 2, options.height + 2] as const;
const inside = [options.x, options.... | /**
* 绘制框选
* @param ctx
* @param options
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/canvas/utils/shape.ts#L74-L89 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Selection.clearActiveDeltas | public clearActiveDeltas() {
if (this.active.size === 0) {
return void 0;
}
this.active.clear();
this.set(null);
} | /**
* 清理选区内容
* @returns
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/selection/index.ts#L69-L75 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | Selection.compose | public compose() {
const active = this.active;
if (active.size === 0) {
this.set(null);
return void 0;
}
let range: Range | null = null;
active.forEach(key => {
const delta = this.editor.deltaSet.get(key);
if (!delta) return void 0;
const deltaRange = Range.from(delta);... | /**
* 组合当前选区节点的 Range
* @returns
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/selection/index.ts#L87-L101 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | dfs | const dfs = (delta: Delta) => {
const state = this.getDeltaState(delta.id);
if (!state) return void 0;
delta.children.forEach(id => {
const child = this.editor.deltaSet.get(id);
if (!child) return void 0;
// 按需创建`state`以及关联关系
const childState = new DeltaState(this.edito... | // 初始化构建整个`Delta`状态树 | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/core/src/state/index.ts#L37-L49 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | DeltaSet.get | public get(key: string) {
return this.deltas[key] || null;
} | /**
* 通过 key 获取 delta
* @param key
* @returns
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/delta/src/delta-set.ts#L33-L35 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | DeltaSet.has | public has(key: string) {
return !!this.deltas[key];
} | /**
* 判断是否存在目标 key
* @param key
* @returns
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/delta/src/delta-set.ts#L42-L44 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
CanvasEditor | github_2023 | WindRunnerMax | typescript | DeltaSet.add | public add(delta: Delta, to?: string) {
this.deltas[delta.id] = delta;
delta.getDeltaSet = () => this;
if (to) {
const delta = this.get(to);
delta && delta.insert(delta);
}
return this;
} | /**
* 添加目标 Delta 到 DeltaSet
* @param delta 目标 Delta
* @param to 目标 Delta 的父 Delta Id
* @returns
*/ | https://github.com/WindRunnerMax/CanvasEditor/blob/8039ee4fdccac675dd43a1f153c36d1c3be72e86/packages/delta/src/delta-set.ts#L52-L60 | 8039ee4fdccac675dd43a1f153c36d1c3be72e86 |
vnve | github_2023 | vnve | typescript | Director.action | public async action(screenplay: Screenplay) {
if (this.started) {
return;
}
const now = performance.now();
try {
const executors = this.parseScreenplay(screenplay);
return await this.run(executors);
} finally {
this.reset();
log.info("action cost:", performance.now() ... | // action! | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/director/Director.ts#L177-L194 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | Director.cut | public cut() {
return new Promise((resolve) => {
this.started = false;
this.cutResolver = resolve;
});
} | // cut! | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/director/Director.ts#L197-L202 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | Speak.fadeIn | private fadeIn(fromText: string, toText: string) {
gsap.fromTo(
this.target,
{
pixi: {
alpha: 0,
},
text: {
value: fromText,
},
},
{
pixi: {
alpha: 1,
},
text: {
value: toText,
},
... | // TODO: 优化效果 | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/director/directives/animation/Speak.ts#L118-L140 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.fromBuffer | static fromBuffer(
buffer: ArrayBuffer,
options?: Partial<AnimatedGIFOptions>,
) {
if (!buffer || buffer.byteLength === 0) {
throw new Error("Invalid buffer");
}
// fix https://github.com/matt-way/gifuct-js/issues/30
const validateAndFix = (gif: any): void => {
let currentGce = nu... | /**
* Create an animated GIF animation from a GIF image's ArrayBuffer. The easiest way to get
* the buffer is to use Assets.
* @example
* import { Assets } from 'pixi.js';
* import '@pixi/gif';
*
* const gif = await Assets.load('file.gif');
* @param buffer - GIF image arraybuffer from Assets.
... | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L189-L286 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | validateAndFix | const validateAndFix = (gif: any): void => {
let currentGce = null;
for (const frame of gif.frames) {
currentGce = frame.gce ?? currentGce;
// fix loosing graphic control extension for same frames
if ("image" in frame && !("gce" in frame)) {
frame.gce = currentGce;
... | // fix https://github.com/matt-way/gifuct-js/issues/30 | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L198-L209 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.constructor | constructor(options: Partial<AnimatedGIFOptions>) {
super(Texture.EMPTY);
// TODO: perf增加自定义选项
// Get the options, apply defaults
this.name = uuid();
this.label = "";
this.type = "AnimatedGIF";
this.source = options.source!;
this.assetID = 0;
this.assetType = "";
this._frames =... | /**
* @param options - Options for the AnimatedGIF
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L291-L306 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.stop | public stop(): void {
if (!this._playing) {
return;
}
this._playing = false;
if (this._autoUpdate && this._isConnectedToTicker) {
Ticker.shared.remove(this.update, this);
this._isConnectedToTicker = false;
}
} | /** Stops the animation. */ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L339-L349 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.play | public play(): void {
if (this._playing) {
return;
}
this._playing = true;
if (this._autoUpdate && !this._isConnectedToTicker) {
Ticker.shared.add(this.update, this, UPDATE_PRIORITY.HIGH);
this._isConnectedToTicker = true;
}
// If were on the last frame and stopped, play shou... | /** Plays the animation. */ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L352-L367 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.progress | public get progress(): number {
return this._currentTime / this.duration;
} | /**
* Get the current progress of the animation from 0 to 1.
* @readonly
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L373-L375 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.playing | public get playing(): boolean {
return this._playing;
} | /** `true` if the current animation is playing */ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L378-L380 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.update | update(deltaTime: number): void {
if (!this._playing) {
return;
}
// const elapsed =
// (this.animationSpeed * deltaTime) / (settings.TARGET_FPMS as number);
// const currentTime = this._currentTime + elapsed;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignor... | /**
* Updates the object transform for rendering. You only need to call this
* if the `autoUpdate` property is set to `false`.
*
* @param deltaTime - Time since last tick.
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L388-L420 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.updateFrame | private updateFrame(): void {
if (!this.dirty) {
return;
}
// Update the current frame
const { imageData } = this._frames[this._currentFrame] as FrameObject;
this._context.putImageData(imageData, 0, 0);
// Workaround hack for Safari & iOS
// which fails to upload canvas after putIma... | /**
* Redraw the current frame, is necessary for the animation to work when
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L425-L445 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF._render | _render(renderer: Renderer): void {
this.updateFrame();
super._render(renderer);
} | /**
* Renders the object using the WebGL renderer
*
* @param {PIXI.Renderer} renderer - The renderer
* @private
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L453-L457 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF._renderCanvas | _renderCanvas(renderer: any): void {
this.updateFrame();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
super._renderCanvas(renderer);
} | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L466-L472 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.autoUpdate | get autoUpdate(): boolean {
return this._autoUpdate;
} | /**
* Whether to use PIXI.Ticker.shared to auto update animation time.
* @default true
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L478-L480 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.currentFrame | get currentFrame(): number {
return this._currentFrame;
} | /** Set the current frame number */ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L501-L503 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.updateFrameIndex | private updateFrameIndex(value: number): void {
if (value < 0 || value >= this._frames.length) {
throw new Error(
`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${value}`,
);
}
if (this._currentFrame !== value) {
this._currentFrame = value;
this.dirty = tr... | /** Internally handle updating the frame index */ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L510-L521 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.totalFrames | get totalFrames(): number {
return this._frames.length;
} | /**
* Get the total number of frame in the GIF.
*/ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L526-L528 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | AnimatedGIF.destroy | destroy(): void {
this.stop();
super.destroy(true);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const forceClear = null as any;
this._context = forceClear;
this._frames = forceClear;
this.onComplete = forceClear;
this.onFrameChange = forceClear;
this.onLoop = for... | /** Destroy and don't use after this. */ | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/AnimatedGIF.ts#L531-L543 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | Graphics.load | public async load() {
// noop
} | // 用于存储颜色值,仅给选择器展示使用 | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/core/src/scene/child/Graphics.ts#L11-L13 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
vnve | github_2023 | vnve | typescript | onInsert | const onInsert = (value: TDirectiveValue) => {
tf.insert.directive({ value });
// move the selection after the element
moveSelection(editor, { unit: "offset" });
api.floatingDirective.hide();
// ??
setTimeout(() => {
focusEditor(editor, editor.selection!);
}, 0);
}; | // TODO: hotkeys | https://github.com/vnve/vnve/blob/f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0/packages/editor/src/components/plugin/directive/useFloatingDirective.ts#L99-L110 | f6f15c317886d8b422fca2b0efeb0fc90b2eb1a0 |
LawKnowledge | github_2023 | foxminchan | typescript | CaseInsensitiveFilterPlugin | function CaseInsensitiveFilterPlugin(): {
fn: {
opsFilter: (
taggedOps: {
filter: (
argument: (_tagObject: unknown, tag: string) => boolean,
) => unknown;
},
phrase: string,
) => {
filter: (
argument: (_tagObject: unknown, tag: string) => boolean,
... | /*
* Copyright (c) 2023-present Hutech University. All rights reserved
* Licensed under the MIT License
*/ | https://github.com/foxminchan/LawKnowledge/blob/f7f1dc8ab7b1dc71ecb356e3a2de0b1b2a035be9/libs/building-block/src/frameworks/swagger/swagger.plugin.ts#L6-L42 | f7f1dc8ab7b1dc71ecb356e3a2de0b1b2a035be9 |
goldrush-kit | github_2023 | covalenthq | typescript | Some.constructor | constructor(private value: A) {} | // eslint-disable-next-line no-empty-function | https://github.com/covalenthq/goldrush-kit/blob/e85ca98d815149f2ba32d7ae5b89f4b9eaa1e6e1/src/utils/option.ts#L56-L56 | e85ca98d815149f2ba32d7ae5b89f4b9eaa1e6e1 |
clash-verge-rev | github_2023 | clash-verge-rev | typescript | filterProxies | function filterProxies(
proxies: IProxyItem[],
groupName: string,
filterText: string
) {
if (!filterText) return proxies;
const res1 = regex1.exec(filterText);
if (res1) {
const symbol = res1[1];
const symbol2 = res1[2].toLowerCase();
const value =
symbol2 === "error" ? 1e5 : symbol2 === ... | /**
* filter the proxy
* according to the regular conditions
*/ | https://github.com/clash-verge-rev/clash-verge-rev/blob/3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224/src/components/proxy/use-filter-sort.ts#L60-L95 | 3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224 |
clash-verge-rev | github_2023 | clash-verge-rev | typescript | sortProxies | function sortProxies(
proxies: IProxyItem[],
groupName: string,
sortType: ProxySortType
) {
if (!proxies) return [];
if (sortType === 0) return proxies;
const list = proxies.slice();
if (sortType === 1) {
list.sort((a, b) => {
const ad = delayManager.getDelayFix(a, groupName);
const bd =... | /**
* sort the proxy
*/ | https://github.com/clash-verge-rev/clash-verge-rev/blob/3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224/src/components/proxy/use-filter-sort.ts#L100-L125 | 3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224 |
clash-verge-rev | github_2023 | clash-verge-rev | typescript | activateSelected | const activateSelected = async () => {
const proxiesData = await getProxies();
const profileData = await getProfiles();
if (!profileData || !proxiesData) return;
const current = profileData.items?.find(
(e) => e && e.uid === profileData.current
);
if (!current) return;
// init sele... | // 根据selected的节点选择 | https://github.com/clash-verge-rev/clash-verge-rev/blob/3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224/src/hooks/use-profiles.ts#L28-L64 | 3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224 |
clash-verge-rev | github_2023 | clash-verge-rev | typescript | generateItem | const generateItem = (name: string) => {
if (proxyRecord[name]) return proxyRecord[name];
if (providerMap[name]) return providerMap[name];
return {
name,
type: "unknown",
udp: false,
xudp: false,
tfo: false,
mptcp: false,
smux: false,
history: [],
};
}; | // compatible with proxy-providers | https://github.com/clash-verge-rev/clash-verge-rev/blob/3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224/src/services/api.ts#L116-L129 | 3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224 |
clash-verge-rev | github_2023 | clash-verge-rev | typescript | DelayManager.getDelayFix | getDelayFix(proxy: IProxyItem, group: string) {
if (!proxy.provider) {
const delay = this.getDelay(proxy.name, group);
if (delay >= 0 || delay === -2) return delay;
}
if (proxy.history.length > 0) {
// 0ms以error显示
return proxy.history[proxy.history.length - 1].delay || 1e6;
}
... | /// 暂时修复provider的节点延迟排序的问题 | https://github.com/clash-verge-rev/clash-verge-rev/blob/3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224/src/services/delay.ts#L59-L70 | 3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224 |
clash-verge-rev | github_2023 | clash-verge-rev | typescript | URI_VLESS | function URI_VLESS(line: string): IProxyVlessConfig {
line = line.split("vless://")[1];
let isShadowrocket;
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line)!;
if (!parsed) {
let [_, base64, other] = /^(.*?)(\?.*?$)/.exec(line)!;
line = `${atob(base64)}${other}`;
parsed = /^(.*?)... | /**
* VLess URL Decode.
*/ | https://github.com/clash-verge-rev/clash-verge-rev/blob/3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224/src/utils/uri-parser.ts#L498-L640 | 3ea0d20e2cf7cf08c7e8e8c098ff725c4ea92224 |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.setup | static async setup(headless_b:boolean):Promise<PuppeteerRun>{
const headless= headless_b ? "new":headless_b;
const browser=await puppeteer.launch({ headless: headless });
const page = await browser.newPage();
page.setViewport({ width: 800, height: 600 });
const cursor = createCursor(page);
await... | /* ==================== HELPER FUNCTIONS ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/mayo/src/index.ts#L60-L70 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.getSectionContent | async getSectionContent(section_url:string){
await this.page.goto(section_url);
this.page.waitForTimeout(TIMEOUT);
// Select content on page (try two different formats)
let base_sel = '';
if (await this.check_sel('div.content')){
base_sel = 'div.content';
}
else {
base_sel = 'di... | /* ==================== GUIDELINE EXTRACTOR ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/mayo/src/index.ts#L93-L151 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.scrape | async scrape(){
var all_good = true;
try {
// Iterate over each letter
for (let letter='A'; letter<='Z'; letter=String.fromCharCode(letter.charCodeAt(0)+1)){
const letter_URL = TOC_URL+'?letter='+letter;
await this.page.goto(letter_URL);
await this.page.waitForTimeout(TIMEOU... | /* ==================== SCRAPING FUNCTION ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/mayo/src/index.ts#L175-L216 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | run | async function run(){
const run = await PuppeteerRun.setup(HEADLESS);
let all_good = await run.scrape();
if (all_good){
try {
await run.browser.close();
}
catch(e) {
console.log("Error while closing",e);
}
}
} | /* ==================== MAIN ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/mayo/src/index.ts#L221-L232 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.setup | static async setup(headless_b:boolean):Promise<PuppeteerRun>{
const headless= headless_b ? "new":headless_b;
const browser=await puppeteer.launch({ headless: headless });
const page = await browser.newPage();
page.setViewport({ width: 800, height: 600 });
const cursor = createCursor(page);
await... | /* ==================== HELPER FUNCTIONS ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/nice/src/index.ts#L63-L73 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.getSectionContent | async getSectionContent(section_name:string, section_url:string){
await this.page.goto(section_url);
let section_content = '';
let content_selector = CONTENT_SELECTOR;
if (section_name == 'Context') {
content_selector = 'div.chapter p'
}
const elements = (await this.page.$$(content_selecto... | /* ==================== GUIDELINE EXTRACTOR ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/nice/src/index.ts#L100-L124 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.scrape | async scrape(){
var all_good = true;
try {
if (await this.check_sel(TOC_RESULT_ITEM_SELECTOR)){
let toc_links = await this.get_links(TOC_RESULT_ITEM_SELECTOR);
for (let [toc_index, el] of toc_links.entries()) {
const page_name = el[0]!;
const page_url = el[1]!;
... | /* ==================== SCRAPING FUNCTION ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/nice/src/index.ts#L151-L171 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | run | async function run(){
const run = await PuppeteerRun.setup(HEADLESS);
let all_good = await run.scrape();
if (all_good){
try {
await run.browser.close();
}
catch(e) {
console.log("Error while closing",e);
}
}
} | /* ==================== MAIN ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/nice/src/index.ts#L176-L187 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.setup | static async setup(headless_b:boolean,timeout:number):Promise<PuppeteerRun>{
const headless= headless_b ? "new":headless_b;
const browser=await puppeteer.launch({ headless: headless });
const page = await browser.newPage();
page.setViewport({ width: 800, height: 600 });
const cursor = createCursor(p... | /* ==================== HELPER FUNCTIONS ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/rch/src/index.ts#L59-L68 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.getGuideline | async getGuideline(name:string,url:string){
await this.page.goto(url);
await this.page.waitForTimeout(200);
let content = '';
let sections = await this.page.$$(CONTENT_SELECTOR);
// If there is a section with id 'key-points', start from there
const key_selector = 'div.widgetBody #key-points'
... | /* ==================== GUIDELINE EXTRACTOR ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/rch/src/index.ts#L96-L163 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.scrape | async scrape(){
await this.page.waitForTimeout(500);
let links = await this.get_links(TOC_SELECTOR);
let num_links = links.length;
for (let [idx, el] of links.entries()) {
const name = el[0]!.split(' (see')[0];
const url = el[1]!;
if (name in scraped){continue;}
console.log(`\n... | /* ==================== SCRAPING FUNCTION ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/rch/src/index.ts#L167-L189 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | run | async function run(){
const run = await PuppeteerRun.setup(HEADLESS, 200);
await run.page.click(`a[href="#tab-All"]`);
await run.scrape();
} | /* ==================== MAIN ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/rch/src/index.ts#L194-L199 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.setup | static async setup(headless_b:boolean):Promise<PuppeteerRun>{
const headless= headless_b ? "new":headless_b;
const browser=await puppeteer.launch({ headless: headless });
const page = await browser.newPage();
page.setViewport({ width: 800, height: 600 });
const cursor = createCursor(page);
await... | /* ==================== HELPER FUNCTIONS ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/wikidoc/src/index.ts#L63-L73 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.formatContent | async formatContent(){
let elements = (await this.page.$$(CONTENT_SELECTOR));
let content = '';
// If there is a TOC, skip all elements until first h2 after 'Contents'
for (let el of elements) {
let tag = (await this.page.evaluate(el => el.tagName, el));
let text = (await this.page.evaluate... | /* ==================== ARTICLE EXTRACTOR ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/wikidoc/src/index.ts#L103-L162 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | PuppeteerRun.scrape | async scrape(toc_url:string){
try {
await this.page.goto(toc_url);
await this.page.waitForTimeout(TIMEOUT);
let article_links = await this.get_links(TOC_SELECTOR);
for (let i = 0; i < article_links.length; i++) {
const article_link = article_links[i];
const article_name = ar... | /* ==================== SCRAPING FUNCTION ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/wikidoc/src/index.ts#L188-L208 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
meditron | github_2023 | epfLLM | typescript | run | async function run(){
const run = await PuppeteerRun.setup(HEADLESS);
// Get TOC pages
var toc_urls:string[] = [];
if (!fs.existsSync(TOC_PATH)) {
console.log('Scraping all TOC pages...')
toc_urls = await run.getAllPages([]);
console.log('\nSaving TOC URLs to file...')
for (let i = 0; i < toc_u... | /* ==================== MAIN ==================== */ | https://github.com/epfLLM/meditron/blob/a7c7cda3014e537f0df2ec58f836fbe920d6283b/gap-replay/guidelines/scrapers/wikidoc/src/index.ts#L213-L245 | a7c7cda3014e537f0df2ec58f836fbe920d6283b |
bangumi | github_2023 | xiaoyvyv | typescript | optContentJs | function optContentJs(content: HTMLElement | undefined | null) {
if (!content) return;
// 图片处理
const images = content.querySelectorAll("img");
const imageUrls: String[] = [];
for (let i = 0; i < images.length; i++) {
const imageEl = images[i];
const imageSrc = imageEl.src;
i... | /**
* 针对特定的节点进行交互优化
*
* @param content
*/ | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L16-L45 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | optReplyItemClick | const optReplyItemClick = (element: HTMLElement): boolean => {
// 点击 Mask 文案
if (toggleMask(element)) {
return true;
}
// a 标签点击
const tagName = element.tagName.toLowerCase();
if (tagName == "a") return true;
// 图片标签点击
if (tagName == "img" && window.android) {
const img... | /**
* 优化评论条目点击事件,是否拦截
*
* @param element
*/ | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L52-L74 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | optReplyContent | const optReplyContent = (userName: string, replyContent: string): string => {
let reply_to_content = replyContent
.replace(/<div class="quote">([^^]*?)<\/div>/, '')
.replace(/<span class="text_mask" style="([^^]*?)">([^^]*?)<\/span>/, '')
.replace(/<\/?[^>]+>/g, '')
.replace(/</g,... | /**
* 优化回复内容,剔除重复的引用,并重新添加引用
*
* @param userName
* @param replyContent
*/ | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L134-L147 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | optText | const optText = (text: string | null | undefined) => {
return (text || '').trim()
.replace(/ /g, " ").trim()
} | /**
* 优化文案
*
* @param text
*/ | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L154-L157 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | initComment | const initComment = (handEmojis: ((commentId: string, likeActionInfo: LikeActionEntity[]) => void) | null, comments: () => CommentTreeEntity[], onChangeSort: (sort: string) => void) => {
const refreshMainComment = (mainComment: CommentReplyMainContent) => {
for (const postId in mainComment) {
co... | /**
* 初始化评论发布填充逻辑
*
* @param handEmojis
* @param comments
* @param onChangeSort
*/ | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L170-L270 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | addComment | const addComment = (comment: CommentReplyEntity) => {
// 主评论
const main = comment.posts?.main;
if (main != undefined) {
refreshMainComment(main);
}
// 子评论
const sub = comment.posts?.sub;
if (sub != undefined) {
refreshSubComment(sub);
... | // 添加评论 | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L225-L237 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | refreshEmoji | const refreshEmoji = (likeData: any) => {
console.log("刷新贴贴:" + JSON.stringify(likeData, null, 2));
for (const commendId in likeData) {
const likeActionInfo = likeData[commendId] as LikeActionEntity[];
// 外部处理
handEmojis && handEmojis(commendId, likeActionInfo);
... | // 刷新贴贴 | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L241-L263 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | replyCommentToTreeComment | const replyCommentToTreeComment = (
reply: Post,
mainCommentId: string,
mainCommentUid: string,
isSub: boolean = false
): CommentTreeEntity => {
const target = {} as CommentTreeEntity;
const subType = isSub ? 1 : 0;
const subReplyId = isSub ? reply.pst_id : 0
const subReplyUid = reply.p... | /**
* 映射
*
* var subReply = function (
* type, // 评论的话题或日志等主题类型
* topic_id, // 主评论的评论ID
* post_id, // 评论的话题或日志等主题ID
* sub_reply_id, // 发布评论者的那条评论ID
* sub_reply_uid, // 发布评论者的用户ID
* post_uid, // 主评论的用户ID
* sub_post_type // 主评论 0、子评论 1
* )
*
* @param re... | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L290-L318 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
bangumi | github_2023 | xiaoyvyv | typescript | scrollToTargetComment | const scrollToTargetComment = (targetId: string) => {
if (targetId.length === 0) return;
const element = document.querySelector("#post_" + targetId);
if (element != null) {
element.scrollIntoView();
}
}; | /**
* 滑动到指定评论处
*
* @param targetId
*/ | https://github.com/xiaoyvyv/bangumi/blob/632a803548848201a33d1f0ed73e31dedf342bc8/lib-h5/src/util/common.ts#L325-L331 | 632a803548848201a33d1f0ed73e31dedf342bc8 |
content-collections | github_2023 | sdorra | typescript | tsconfigResolvePaths | function tsconfigResolvePaths(configPath: string) {
let tsconfig = loadTsConfig(dirname(configPath));
if (!tsconfig) {
tsconfig = loadTsConfig();
}
return tsconfig?.data?.compilerOptions?.paths || {};
} | // the code to handle externals is mostly the one which is used by the awesome tsup project | https://github.com/sdorra/content-collections/blob/98af25be09a9a8fd4017a087fe74d5939458c6bf/packages/core/src/esbuild.ts#L8-L14 | 98af25be09a9a8fd4017a087fe74d5939458c6bf |
content-collections | github_2023 | sdorra | typescript | createCacheKey | function createCacheKey(document: Document): Document {
const { content, _meta } = document;
return { content, _meta };
} | // Remove all unnecessary keys from the document | https://github.com/sdorra/content-collections/blob/98af25be09a9a8fd4017a087fe74d5939458c6bf/packages/markdown/src/index.ts#L52-L55 | 98af25be09a9a8fd4017a087fe74d5939458c6bf |
content-collections | github_2023 | sdorra | typescript | createCacheKey | function createCacheKey(document: Document): Document {
const { content, _meta } = document;
return { content, _meta };
} | // Remove all unnecessary keys from the document | https://github.com/sdorra/content-collections/blob/98af25be09a9a8fd4017a087fe74d5939458c6bf/packages/mdx/src/index.ts#L112-L115 | 98af25be09a9a8fd4017a087fe74d5939458c6bf |
learn.nuxt.com | github_2023 | nuxt | typescript | WorkerHost.fsStat | async fsStat(uriString: string) {
const uri = Uri.parse(uriString)
const dir = withoutLeadingSlash(dirname(uri.fsPath))
const base = basename(uri.fsPath)
try {
// TODO: should we cache it?
const files = await this.ctx.webcontainer!.fs.readdir(dir, { withFileTypes: true })
const file =... | // we have to use readdir to check if the file is a directory | https://github.com/nuxt/learn.nuxt.com/blob/6a9a8cb6c5e272f509a70c88b13810a7db6a794e/monaco/env.ts#L31-L62 | 6a9a8cb6c5e272f509a70c88b13810a7db6a794e |
learn.nuxt.com | github_2023 | nuxt | typescript | resolvePath | function resolvePath(path: string) {
if (path.startsWith('./'))
return `./.nuxt/${path.slice(2)}`
if (path.startsWith('..'))
return `.${path.slice(2)}`
return path
} | // Resolve .nuxt/tsconfig.json paths from `./.nuxt` to `./` | https://github.com/nuxt/learn.nuxt.com/blob/6a9a8cb6c5e272f509a70c88b13810a7db6a794e/monaco/env.ts#L98-L104 | 6a9a8cb6c5e272f509a70c88b13810a7db6a794e |
learn.nuxt.com | github_2023 | nuxt | typescript | mount | async function mount(map: Record<string, string>, templates = filesTemplate) {
const objects = {
...templates,
...map,
}
await Promise.all([
// update or create files
...Object.entries(objects)
.map(async ([filepath, content]) => {
await _updateOrCreateFile(filepat... | /**
* Mount files to WebContainer.
* This will do a diff with the current files and only update the ones that changed
*/ | https://github.com/nuxt/learn.nuxt.com/blob/6a9a8cb6c5e272f509a70c88b13810a7db6a794e/stores/playground.ts#L200-L221 | 6a9a8cb6c5e272f509a70c88b13810a7db6a794e |
zotero-scipdf | github_2023 | syt2 | typescript | onPrefsEvent | async function onPrefsEvent(type: string, data: { [key: string]: any }) {
switch (type) {
case "load":
registerPrefsScripts(data.window);
break;
default:
return;
}
} | /**
* This function is just an example of dispatcher for Preference UI events.
* Any operations should be placed in a function to keep this funcion clear.
* @param type event type
* @param data event data
*/ | https://github.com/syt2/zotero-scipdf/blob/f9360d2e0275989d04f3dcce1cac3de082711d7d/src/hooks.ts#L67-L75 | f9360d2e0275989d04f3dcce1cac3de082711d7d |
zotero-scipdf | github_2023 | syt2 | typescript | CustomResolverManager.appendCustomResolversInZotero | appendCustomResolversInZotero(resolvers: CustomResolver[] | Readonly<CustomResolver[]>) {
this.customResolversInZotero = this.customResolversInZotero.concat(resolvers.filter(value => this.customResolversInZotero.findIndex(e => isCustomResolverEqual(e, value)) < 0))
this.customResolvers = this.customResolvers.co... | // system custom resolvers | https://github.com/syt2/zotero-scipdf/blob/f9360d2e0275989d04f3dcce1cac3de082711d7d/src/modules/CustomResolverManager.ts#L25-L28 | f9360d2e0275989d04f3dcce1cac3de082711d7d |
zotero-scipdf | github_2023 | syt2 | typescript | initLocale | function initLocale() {
const l10n = new (
typeof Localization === "undefined"
? ztoolkit.getGlobal("Localization")
: Localization
)([`${config.addonRef}-addon.ftl`], true);
addon.data.locale = {
current: l10n,
};
} | /**
* Initialize locale data
*/ | https://github.com/syt2/zotero-scipdf/blob/f9360d2e0275989d04f3dcce1cac3de082711d7d/src/utils/locale.ts#L8-L17 | f9360d2e0275989d04f3dcce1cac3de082711d7d |
zotero-scipdf | github_2023 | syt2 | typescript | isWindowAlive | function isWindowAlive(win?: Window) {
return win && !Components.utils.isDeadWrapper(win) && !win.closed;
} | /**
* Check if the window is alive.
* Useful to prevent opening duplicate windows.
* @param win
*/ | https://github.com/syt2/zotero-scipdf/blob/f9360d2e0275989d04f3dcce1cac3de082711d7d/src/utils/window.ts#L8-L10 | f9360d2e0275989d04f3dcce1cac3de082711d7d |
braintrust-proxy | github_2023 | braintrustdata | typescript | OpenAiRealtimeLogger.close | public async close() {
// Pending client audio buffer is allowed in VAD mode.
if (this.turnDetectionEnabled) {
this.clientAudioBuffer = undefined;
}
// Check if there is a pending audio buffers.
if (this.serverAudioBuffer.size || this.clientAudioBuffer) {
console.warn(
`Closing ... | /**
* Close all pending spans.
*/ | https://github.com/braintrustdata/braintrust-proxy/blob/87c174af68cfc37e884ea36f551e99b8336e5949/apis/cloudflare/src/realtime-logger.ts#L419-L463 | 87c174af68cfc37e884ea36f551e99b8336e5949 |
braintrust-proxy | github_2023 | braintrustdata | typescript | cacheGet | const cacheGet = async (encryptionKey: string, key: string) => {
const redis = await getRedis();
if (!redis) {
return null;
}
return await redis.get(key);
}; | // Unlike the Cloudflare worker API, which supports public access, this API | https://github.com/braintrustdata/braintrust-proxy/blob/87c174af68cfc37e884ea36f551e99b8336e5949/apis/node/src/node-proxy.ts#L32-L38 | 87c174af68cfc37e884ea36f551e99b8336e5949 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.