repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
GPTPortal | github_2023 | Zaki-1052 | typescript | Steps.retrieve | retrieve(
threadId: string,
runId: string,
stepId: string,
options?: Core.RequestOptions,
): Core.APIPromise<RunStep> {
return this._client.get(`/threads/${threadId}/runs/${runId}/steps/${stepId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
... | /**
* Retrieves a run step.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/threads/runs/steps.ts#L13-L23 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | FileBatches.create | create(
vectorStoreId: string,
body: FileBatchCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStoreFileBatch> {
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.he... | /**
* Create a vector store file batch.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L18-L28 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | FileBatches.retrieve | retrieve(
vectorStoreId: string,
batchId: string,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStoreFileBatch> {
return this._client.get(`/vector_stores/${vectorStoreId}/file_batches/${batchId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
... | /**
* Retrieves a vector store file batch.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L33-L42 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | FileBatches.cancel | cancel(
vectorStoreId: string,
batchId: string,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStoreFileBatch> {
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/cancel`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers ... | /**
* Cancel a vector store file batch. This attempts to cancel the processing of
* files in this batch as soon as possible.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L48-L57 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | FileBatches.createAndPoll | async createAndPoll(
vectorStoreId: string,
body: FileBatchCreateParams,
options?: Core.RequestOptions & { pollIntervalMs?: number },
): Promise<VectorStoreFileBatch> {
const batch = await this.create(vectorStoreId, body);
return await this.poll(vectorStoreId, batch.id, options);
} | /**
* Create a vector store batch and poll until all files have been processed.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L62-L69 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | FileBatches.poll | async poll(
vectorStoreId: string,
batchId: string,
options?: Core.RequestOptions & { pollIntervalMs?: number },
): Promise<VectorStoreFileBatch> {
const headers: { [key: string]: string } = { ...options?.headers, 'X-Stainless-Poll-Helper': 'true' };
if (options?.pollIntervalMs) {
headers['X... | /**
* Wait for the given file batch to be processed.
*
* Note: this will return even if one of the files failed to process, you need to
* check batch.file_counts.failed_count to handle this case.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L107-L146 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | FileBatches.uploadAndPoll | async uploadAndPoll(
vectorStoreId: string,
{ files, fileIds = [] }: { files: Uploadable[]; fileIds?: string[] },
options?: Core.RequestOptions & { pollIntervalMs?: number; maxConcurrency?: number },
): Promise<VectorStoreFileBatch> {
if (files == null || files.length == 0) {
throw new Error(
... | /**
* Uploads the given files concurrently and then creates a vector store file batch.
*
* The concurrency limit is configurable using the `maxConcurrency` parameter.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L153-L191 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | processFiles | async function processFiles(iterator: IterableIterator<Uploadable>) {
for (let item of iterator) {
const fileObj = await client.files.create({ file: item, purpose: 'assistants' }, options);
allFileIds.push(fileObj.id);
}
} | // This code is based on this design. The libraries don't accommodate our environment limits. | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/file-batches.ts#L175-L180 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.create | create(
vectorStoreId: string,
body: FileCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStoreFile> {
return this._client.post(`/vector_stores/${vectorStoreId}/files`, {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
... | /**
* Create a vector store file by attaching a
* [File](https://platform.openai.com/docs/api-reference/files) to a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L15-L25 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.retrieve | retrieve(
vectorStoreId: string,
fileId: string,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStoreFile> {
return this._client.get(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
} | /**
* Retrieves a vector store file.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L30-L39 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.del | del(
vectorStoreId: string,
fileId: string,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStoreFileDeleted> {
return this._client.delete(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
} | /**
* Delete a vector store file. This will remove the file from the vector store but
* the file itself will not be deleted. To delete the file, use the
* [delete file](https://platform.openai.com/docs/api-reference/files/delete)
* endpoint.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L74-L83 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.createAndPoll | async createAndPoll(
vectorStoreId: string,
body: FileCreateParams,
options?: Core.RequestOptions & { pollIntervalMs?: number },
): Promise<VectorStoreFile> {
const file = await this.create(vectorStoreId, body, options);
return await this.poll(vectorStoreId, file.id, options);
} | /**
* Attach a file to the given vector store and wait for it to be processed.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L88-L95 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.poll | async poll(
vectorStoreId: string,
fileId: string,
options?: Core.RequestOptions & { pollIntervalMs?: number },
): Promise<VectorStoreFile> {
const headers: { [key: string]: string } = { ...options?.headers, 'X-Stainless-Poll-Helper': 'true' };
if (options?.pollIntervalMs) {
headers['X-Stain... | /**
* Wait for the vector store file to finish processing.
*
* Note: this will return even if the file failed to process, you need to check
* file.last_error and file.status to handle these cases
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L103-L142 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.upload | async upload(
vectorStoreId: string,
file: Uploadable,
options?: Core.RequestOptions,
): Promise<VectorStoreFile> {
const fileInfo = await this._client.files.create({ file: file, purpose: 'assistants' }, options);
return this.create(vectorStoreId, { file_id: fileInfo.id }, options);
} | /**
* Upload a file to the `files` API and then attach it to the given vector store.
*
* Note the file will be asynchronously processed (you can use the alternative
* polling helper method to wait for processing to complete).
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L150-L157 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Files.uploadAndPoll | async uploadAndPoll(
vectorStoreId: string,
file: Uploadable,
options?: Core.RequestOptions & { pollIntervalMs?: number },
): Promise<VectorStoreFile> {
const fileInfo = await this.upload(vectorStoreId, file, options);
return await this.poll(vectorStoreId, fileInfo.id, options);
} | /**
* Add a file to a vector store and poll until processing is complete.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/files.ts#L162-L169 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | VectorStores.create | create(body: VectorStoreCreateParams, options?: Core.RequestOptions): Core.APIPromise<VectorStore> {
return this._client.post('/vector_stores', {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
} | /**
* Create a vector store.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/vector-stores.ts#L18-L24 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | VectorStores.retrieve | retrieve(vectorStoreId: string, options?: Core.RequestOptions): Core.APIPromise<VectorStore> {
return this._client.get(`/vector_stores/${vectorStoreId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
} | /**
* Retrieves a vector store.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/vector-stores.ts#L29-L34 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | VectorStores.update | update(
vectorStoreId: string,
body: VectorStoreUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<VectorStore> {
return this._client.post(`/vector_stores/${vectorStoreId}`, {
body,
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
} | /**
* Modifies a vector store.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/vector-stores.ts#L39-L49 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | VectorStores.del | del(vectorStoreId: string, options?: Core.RequestOptions): Core.APIPromise<VectorStoreDeleted> {
return this._client.delete(`/vector_stores/${vectorStoreId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v2', ...options?.headers },
});
} | /**
* Delete a vector store.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/beta/vector-stores/vector-stores.ts#L76-L81 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Jobs.create | create(body: JobCreateParams, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
return this._client.post('/fine_tuning/jobs', { body, ...options });
} | /**
* Creates a fine-tuning job which begins the process of creating a new model from
* a given dataset.
*
* Response includes details of the enqueued job including job status and the name
* of the fine-tuned models once complete.
*
* [Learn more about fine-tuning](https://platform.openai.com/docs/... | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/fine-tuning/jobs/jobs.ts#L22-L24 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Jobs.retrieve | retrieve(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
return this._client.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
} | /**
* Get info about a fine-tuning job.
*
* [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/fine-tuning/jobs/jobs.ts#L31-L33 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Jobs.cancel | cancel(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
} | /**
* Immediately cancel a fine-tune job.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/fine-tuning/jobs/jobs.ts#L56-L58 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Parts.create | create(
uploadId: string,
body: PartCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<UploadPart> {
return this._client.post(
`/uploads/${uploadId}/parts`,
Core.multipartFormRequestOptions({ body, ...options }),
);
} | /**
* Adds a
* [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object.
* A Part represents a chunk of bytes from the file you are trying to upload.
*
* Each Part can be at most 64 MB, and you can... | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/uploads/parts.ts#L21-L30 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Uploads.create | create(body: UploadCreateParams, options?: Core.RequestOptions): Core.APIPromise<Upload> {
return this._client.post('/uploads', { body, ...options });
} | /**
* Creates an intermediate
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object
* that you can add
* [Parts](https://platform.openai.com/docs/api-reference/uploads/part-object) to.
* Currently, an Upload can accept at most 8 GB in total and expires after an hour
* after ... | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/uploads/uploads.ts#L34-L36 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Uploads.cancel | cancel(uploadId: string, options?: Core.RequestOptions): Core.APIPromise<Upload> {
return this._client.post(`/uploads/${uploadId}/cancel`, options);
} | /**
* Cancels the Upload. No Parts may be added after an Upload is cancelled.
*/ | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/uploads/uploads.ts#L41-L43 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
GPTPortal | github_2023 | Zaki-1052 | typescript | Uploads.complete | complete(
uploadId: string,
body: UploadCompleteParams,
options?: Core.RequestOptions,
): Core.APIPromise<Upload> {
return this._client.post(`/uploads/${uploadId}/complete`, { body, ...options });
} | /**
* Completes the
* [Upload](https://platform.openai.com/docs/api-reference/uploads/object).
*
* Within the returned Upload object, there is a nested
* [File](https://platform.openai.com/docs/api-reference/files/object) object that
* is ready to use in the rest of the platform.
*
* You can spe... | https://github.com/Zaki-1052/GPTPortal/blob/16ffa0c14672c637cf27249d8f0bf146e56c29b7/node_modules/openai/src/resources/uploads/uploads.ts#L60-L66 | 16ffa0c14672c637cf27249d8f0bf146e56c29b7 |
bilibili-cleaner | github_2023 | festoney8 | typescript | KeywordFilter.buildRegExp | private buildRegExp(): void {
this.mergedRegExp = []
const validNormalParts = [] // 普通字串、普通正则
const validBackrefParts = [] // 包含反向引用的正则
for (let word of this.keywordSet) {
word = word.trim()
if (word === '' || word === '//') {
continue
... | /** 将关键词或正则列表合并为正则 */ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/core/subFilters/keywordFilter.ts#L18-L52 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | CommentFilterCommon.checkRoot | async checkRoot(mode?: 'full' | 'incr') {
const timer = performance.now()
let revertAll = false
if (
!(
this.commentUsernameFilter.isEnable ||
this.commentContentFilter.isEnable ||
this.commentLevelFilter.isEnable ||
thi... | /**
* 检测一级评论
* @param mode full全量,incr增量
* @returns
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/comment/pages/common.ts#L294-L379 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | CommentFilterCommon.checkSub | async checkSub(mode?: 'full' | 'incr') {
const timer = performance.now()
let revertAll = false
if (
!(
this.commentUsernameFilter.isEnable ||
this.commentContentFilter.isEnable ||
this.commentLevelFilter.isEnable ||
this... | /**
* 检测二级评论
* @param mode full全量,incr增量
* @returns
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/comment/pages/common.ts#L386-L467 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | CommentFilterCommon.observe | observe() {
ShadowInstance.addShadowObserver(
'BILI-COMMENTS',
new MutationObserver(() => {
this.checkRoot('incr').then().catch()
}),
{
subtree: true,
childList: true,
},
)
ShadowInstance... | /**
* 监听一级/二级评论container
* 使用同一Observer监视所有二级评论上级节点,所有变化只触发一次回调
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/comment/pages/common.ts#L486-L508 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | getVideoData | const getVideoData = (video: HTMLElement): any => {
let videoData
if (!video.classList.contains('rank-item')) {
// 热门视频、每周必看
return (video as any).__vue__?.videoData
}
// 排行榜页
const rank = video.getAttribute('data-rank')
if (rank && parseInt(rank) > 0) {
videoData = (vide... | // 视频列表信息提取 | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/video/pages/popular.ts#L64-L76 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | VideoFilterPopular.observe | observe() {
waitForEle(document, '#app', (node: HTMLElement): boolean => {
return node.id === 'app'
}).then((ele) => {
if (!ele) {
return
}
debug('VideoFilterPopular target appear')
this.target = ele
this.checkFull(... | // } | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/video/pages/popular.ts#L219-L235 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | VideoFilterSearch.observe | observe() {
waitForEle(document, '.search-layout', (node: HTMLElement): boolean => {
return node.className.includes('search-layout')
}).then((ele) => {
if (!ele) {
return
}
debug('VideoFilterSearch target appear')
this.target =... | // } | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/video/pages/search.ts#L182-L198 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | VideoFilterSpace.observe | observe() {
waitForEle(document, '#app', (node: HTMLElement): boolean => {
return node.id === 'app'
}).then((ele) => {
if (!ele) {
return
}
debug('VideoFilterSpace target appear')
this.target = ele
this.checkFull()
... | // } | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/video/pages/space.ts#L161-L177 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | VideoFilterVideo.observe | observe() {
waitForEle(
document,
'#reco_list, .recommend-list-v1, .recommend-list-container',
(node: HTMLElement): boolean => {
return (
node.id === 'reco_list' ||
['recommend-list-v1', 'recommend-list-container'].inclu... | // } | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/filters/variety/video/pages/video.ts#L204-L227 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | unfold | const unfold = () => {
const dynFoldNodes = document.querySelectorAll('main .bili-dyn-list__item .bili-dyn-item-fold')
if (dynFoldNodes.length) {
dynFoldNodes.forEach((e) => {
e instanceof HTMLDivElement && e.click()
})
... | // 大量动态下,单次耗时10ms内 | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/rules/dynamic/groups/centerDyn.ts#L87-L94 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | bv2av | const bv2av = (url: string): string => {
const XOR_CODE = 23442827791579n
const MASK_CODE = 2251799813685247n
const BASE = 58n
const data = 'FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf'
const dec = (bvid: string): number => {... | /**
* algo by bilibili-API-collect
* @see https://www.zhihu.com/question/381784377/answer/1099438784
* @see https://github.com/SocialSisterYi/bilibili-API-collect/issues/740
* @see https://socialsisteryi.github.io/bilibili-API-collect/docs/misc/bvid_desc.html
... | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/modules/rules/video/groups/basic.ts#L21-L57 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | wrapper | const wrapper = (loggingFunc: (..._args: any[]) => void | undefined, isEnable: boolean) => {
if (isEnable) {
return (...innerArgs: any[]) => {
currTime = performance.now()
const during: string = (currTime - lastTime).toFixed(1)
loggingFunc(`[bili-cleaner] ${during} / ${cu... | /**
* 计时日志wrapper
* 输出格式: [bili-cleaner] 0.1 / 2.4 ms | XXXXXXXXXXXXXX
* 第一个时间为上一条日志到本条日志间隔, 第二个时间为页面开启总时长
* 使用 performance.now() 做精确计时
*
* @param loggingFunc console.log等带级别打印日志的函数
* @param isEnable 是否打印日志
* @returns 返回wrap后的日志函数
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/utils/logger.ts#L17-L27 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | Shadow.hook | private hook() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this
const origAttachShadow = Element.prototype.attachShadow
Element.prototype.attachShadow = function (init) {
const shadowRoot = origAttachShadow.call(this, init)
const t... | /**
* hook attachShadow,创建shadowRoot时注入自定义样式,启用自定义监听
* 重载ShadowRoot.innerHTML,被调用时注入自定义样式
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/utils/shadow.ts#L58-L109 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | Shadow.addShadowStyle | addShadowStyle(tag: TagName, className: string, css: string) {
tag = tag.toUpperCase()
const curr = this.cssStore.get(tag)
if (curr) {
curr.add({ className: className, css: css })
} else {
this.cssStore.set(tag, new Set([{ className: className, css: css }]))
... | /**
* 新增需要在shadowDOM内注入的样式
* @param tag tagName
* @param className css类名
* @param css 样式
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/utils/shadow.ts#L117-L135 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | Shadow.removeShadowStyle | removeShadowStyle(tag: TagName, className: string) {
tag = tag.toUpperCase()
const curr = this.cssStore.get(tag)
if (curr) {
for (const value of curr) {
if (value.className === className) {
curr.delete(value)
break
... | /**
* 移除需要在shadowDOM内注入的样式
* @param tag tagName
* @param className css类名
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/utils/shadow.ts#L142-L160 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
bilibili-cleaner | github_2023 | festoney8 | typescript | Shadow.addShadowObserver | addShadowObserver(tag: TagName, observer: MutationObserver, config: MutationObserverInit) {
tag = tag.toUpperCase()
const curr = this.observerStore.get(tag)
if (curr) {
curr.add([observer, config])
} else {
this.observerStore.set(tag, new Set([[observer, config]])... | /**
* 新增shadowRoot内MutationObserver
* @param tag tagName
* @param observer MutationObserver
* @param config Observer配置
*/ | https://github.com/festoney8/bilibili-cleaner/blob/0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a/src/utils/shadow.ts#L168-L183 | 0b3b937154ce9d3d5e44be7fc422a5ede6a0b72a |
next-devtools | github_2023 | xinyao27 | typescript | doSearchSync | const doSearchSync = () => {
const res = onSearchSync?.(debouncedSearchTerm)
setOptions(transToGroupOption(res || [], groupBy))
} | /** sync search */ | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/client/src/components/ui/multiselect.tsx#L290-L293 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | doSearch | const doSearch = async () => {
setIsLoading(true)
const res = await onSearch?.(debouncedSearchTerm)
setOptions(transToGroupOption(res || [], groupBy))
setIsLoading(false)
} | /** async search */ | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/client/src/components/ui/multiselect.tsx#L313-L318 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | displayNameHandler | const displayNameHandler = (documentation: Documentation, componentDefinition: NodePath<ComponentNode>) => {
builtinHandlers.displayNameHandler(documentation, componentDefinition)
if (!documentation.get('displayName')) {
const variableDeclarator = componentDefinition.parentPath
if (variableDeclarato... | // handle the case where displayName is empty | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/components.ts#L42-L53 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | isNextRouteFile | function isNextRouteFile(fileName: string): boolean {
return nextJsFilePattern.test(fileName) && NEXT_ROUTE_FILE_PATTERN.test(fileName)
} | // Helper function to check if a file is a Next.js route file | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/routes.ts#L37-L39 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | hasRouteFiles | async function hasRouteFiles(directory: string): Promise<boolean> {
const items = await fs.readdir(directory, { withFileTypes: true })
// Check if current directory has any route files
if (items.some((item) => !item.isDirectory() && isNextRouteFile(item.name))) {
return true
}
// Recursively... | // Helper function to check if directory or its children contain route files | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/routes.ts#L42-L62 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | createRouteNode | function createRouteNode(path: string, name: string, parentId: number, parentNode?: Route): Route {
return {
id: idCounter++,
route: `${parentNode?.id === 0 ? '' : parentNode?.route}/${name}`,
name,
parentNode: parentId,
path,
contents: [],
render: 'server',
}
} | // Create a new route node for the tree | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/routes.ts#L65-L75 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | handleDirectory | async function handleDirectory(
entity: fs.Dirent,
fullPath: string,
parentId: number,
parentNode?: Route,
): Promise<void> {
const isValidRoute = parentId === 0 || (await hasRouteFiles(fullPath))
if (isValidRoute) {
const newNode = createRouteNode(fullPath, entity.name, parentId, paren... | // Handle directory processing | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/routes.ts#L95-L108 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | handleRouteFile | async function handleRouteFile(fileName: string, fullPath: string, parentId: number): Promise<void> {
treeNodes[parentId].contents.push(fileName)
if (await detectClientDirective(fullPath)) {
treeNodes[parentId].render = 'client'
}
} | // Handle route file processing | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/routes.ts#L111-L116 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getBasicMetadata | function getBasicMetadata() {
// title
const title = document.title
if (title) result.title = title
else result.missing.push('title')
// description
const description = document.querySelector('meta[name="description"]')?.getAttribute('content')
if (description) result.descript... | // Basic metadata | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L19-L45 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getOpenGraphData | function getOpenGraphData() {
const og: Record<string, any> = {}
// images is a array of objects -
const images: Record<string, string>[] = []
const ogTags = document.querySelectorAll('[property^="og:"]')
ogTags.forEach((tag) => {
const property = tag.getAttribute('property')?.rep... | // Open Graph - https://ogp.me/ | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L48-L129 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getTwitterData | function getTwitterData() {
const twitter: Record<string, any> = {}
const twitterTags = document.querySelectorAll('[name^="twitter:"]')
const images: Record<string, string>[] = []
twitterTags.forEach((tag) => {
const name = tag.getAttribute('name')?.replace('twitter:', '')
const... | // Twitter Card | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L132-L162 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getIconsData | function getIconsData() {
const icons: Record<string, any> = {}
const iconLinks = document.querySelectorAll('link[rel*="icon"]')
iconLinks.forEach((link) => {
const rel = link.getAttribute('rel')
const href = link.getAttribute('href')
if (rel && href) {
if (rel === '... | // Icon data | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L165-L184 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getRobotsData | function getRobotsData() {
const robots = document.querySelector('meta[name="robots"]')?.getAttribute('content')
if (robots) {
const robotsObj: Record<string, boolean> = {}
robots.split(',').forEach((directive) => {
const trimmed = directive.trim()
if (trimmed.startsWith(... | // Robots | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L187-L201 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getVerificationData | function getVerificationData() {
const verification: Record<string, string | string[]> = {}
const verificationTags = document.querySelectorAll('meta[name$="-verification"]')
verificationTags.forEach((tag) => {
const name = tag.getAttribute('name')?.replace('-verification', '')
const c... | // Verification | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L204-L219 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getFacebookData | function getFacebookData() {
const fbAppId = document.querySelector('meta[property="fb:app_id"]')?.getAttribute('content')
const fbAdmins = document.querySelector('meta[property="fb:admins"]')?.getAttribute('content')
if (fbAppId || fbAdmins) {
result.facebook = {} as Facebook
if (fbA... | // Facebook | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L222-L231 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getJSONLDData | function getJSONLDData() {
const scripts = document.querySelectorAll('script[type="application/ld+json"]')
scripts.forEach((script) => {
const jsonRaw = (script.textContent as string) ?? '{}'
const json = JSON.parse(jsonRaw) as WithContext<any>
if (!result.jsonLd) result.jsonLd = []... | // JSON-LD | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L234-L243 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
next-devtools | github_2023 | xinyao27 | typescript | getName | function getName() {
const jsonLd = result.jsonLd?.find((json) => json.name)
if (jsonLd?.name) {
result.name = jsonLd.name
return
}
const titleTag = document.querySelector('title')?.textContent
if (titleTag) {
result.name = titleTag
return
}
cons... | /**
* name
* Determine the name from multiple sources, including:
* - WebSite structured data - https://json-ld.org/
* - <title>
* - <h1>
* - og:size_name
*/ | https://github.com/xinyao27/next-devtools/blob/ec985015f48febab2e4e061ba8fd6d4238563f52/packages/core/src/features/seo.ts#L253-L273 | ec985015f48febab2e4e061ba8fd6d4238563f52 |
searchemoji | github_2023 | rotick | typescript | go | async function go () {
for (const l of locale) {
if (l.code !== 'en' && l.code !== 'zh-hans') {
await main(l.code)
}
}
} | // const badResult = ['da', 'fi', 'he', 'hu', 'id', 'it', 'th', 'tr'].map(lang => ({ code: lang })) | https://github.com/rotick/searchemoji/blob/be31747fb2868a9bdd61a7b0a1e4d5b7c8bc9d3f/scripts/generateLocale.ts#L45-L51 | be31747fb2868a9bdd61a7b0a1e4d5b7c8bc9d3f |
searchemoji | github_2023 | rotick | typescript | batch | function batch (arr: any[], size: number) {
const batches = []
/* eslint-disable @typescript-eslint/restrict-plus-operands */
for (let i = 0; i < arr.length; i += size) {
batches.push(arr.slice(i, i + size))
}
return batches
} | // async function main () { | https://github.com/rotick/searchemoji/blob/be31747fb2868a9bdd61a7b0a1e4d5b7c8bc9d3f/scripts/handle.ts#L41-L48 | be31747fb2868a9bdd61a7b0a1e4d5b7c8bc9d3f |
gratelets | github_2023 | lilnasy | typescript | idle | async function idle(page: Page) {
await page.goto("http://localhost:4321/idle")
await expect(page.locator("#counter-message")).toHaveText("server rendered")
await page.click("body")
await expect(page.locator("#counter-message")).toHaveText("hydrated")
} | // the nuances of how idle directive makes the component load cant be tested | https://github.com/lilnasy/gratelets/blob/e9de129a55e69c0a50bfa27ac218947f1d3e8611/tests-e2e/client-interaction.spec.ts#L23-L28 | e9de129a55e69c0a50bfa27ac218947f1d3e8611 |
three-pinata | github_2023 | dgreenheck | typescript | findIsolatedGeometry | function findIsolatedGeometry(fragment: Fragment): Fragment[] {
// Initialize the union-find data structure
const uf = new UnionFind(fragment.vertexCount);
// Triangles for each submesh are stored separately
const rootTriangles: Record<number, number[][]> = {};
const N = fragment.vertices.length;
const M =... | /**
* Uses the union-find algorithm to find isolated groups of geometry
* within a fragment that are not connected together. These groups
* are identified and split into separate fragments.
* @returns An array of fragments
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/Fracture.ts#L91-L191 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | fillCutFaces | function fillCutFaces(
topSlice: Fragment,
bottomSlice: Fragment,
sliceNormal: Vector3,
textureScale: Vector2,
textureOffset: Vector2,
convex: boolean,
): void {
// Since the topSlice and bottomSlice both share the same cut face, we only need to calculate it
// once. Then the same vertex/triangle data f... | /**
* Fills the cut faces for each sliced mesh. The `sliceNormal` is the normal for the plane and points
* in the direction of `topfragment`
* @param topSlice Fragment mesh data for slice above the slice plane
* @param bottomSlice Fragment mesh data for slice above the slice plane
* @param sliceNormal Normal of th... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/Slice.ts#L148-L227 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | splitTriangles | function splitTriangles(
fragment: Fragment,
topSlice: Fragment,
bottomSlice: Fragment,
sliceNormal: Vector3,
sliceOrigin: Vector3,
side: boolean[],
subMesh: SlicedMeshSubmesh,
): void {
const triangles: number[] = fragment.triangles[subMesh];
// Keep track of vertices that lie on the intersection pl... | /**
* Identifies triangles that are intersected by the slice plane and splits them in two
* @param fragment
* @param topSlice Fragment mesh data for slice above the slice plane
* @param bottomSlice Fragment mesh data for slice above the slice plane
* @param sliceNormal The normal of the slice plane (points towards... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/Slice.ts#L239-L354 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | splitTriangle | function splitTriangle(
v1_idx: number,
v2_idx: number,
v3_idx: number,
sliceNormal: Vector3,
sliceOrigin: Vector3,
fragment: Fragment,
topSlice: Fragment,
bottomSlice: Fragment,
subMesh: SlicedMeshSubmesh,
v3BelowCutPlane: boolean,
): void {
// - `v1`, `v2`, `v3` are the indexes of the triangle r... | /**
* Splits triangle defined by the points (v1,v2,v3)
* @param v1_idx Index of first vertex in triangle
* @param v2_idx Index of second vertex in triangle
* @param v3_idx Index of third vertex in triangle
* @param sliceNormal The normal of the slice plane (points towards the top slice)
* @param sliceOrigin The o... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/Slice.ts#L369-L548 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | EdgeConstraint.constructor | constructor(
v1: number,
v2: number,
triangle1?: number,
triangle2?: number,
edge1?: number,
) {
this.v1 = v1;
this.v2 = v2;
this.t1 = triangle1 ?? -1;
this.t2 = triangle2 ?? -1;
this.t1Edge = edge1 ?? 0;
} | /**
* Creates a new edge constraint with the given end points
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/EdgeConstraint.ts#L33-L45 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | EdgeConstraint.equals | equals(other: EdgeConstraint): boolean {
return (
(this.v1 === other.v1 && this.v2 === other.v2) ||
(this.v1 === other.v2 && this.v2 === other.v1)
);
} | /**
* Determines whether the specified object is equal to the current object
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/EdgeConstraint.ts#L50-L55 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | EdgeConstraint.toString | toString(): string {
return `Edge: T${this.t1}->T${this.t2} (V${this.v1}->V${this.v2})`;
} | /**
* Returns a string that represents the current object
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/EdgeConstraint.ts#L60-L62 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.constructor | constructor(args: FragmentArgs | undefined = undefined) {
this.vertices = [];
this.cutVertices = [];
this.triangles = [[], []];
this.constraints = [];
this.indexMap = [];
this.bounds = new Box3();
this.vertexAdjacency = [];
if (!args) {
return;
}
const { positions, normal... | /**
* Constructor for a Fragment object
* @param args The arguments for the Fragment object
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L62-L97 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.triangleCount | get triangleCount(): number {
return (this.triangles[0].length + this.triangles[1].length) / 3;
} | /**
* Gets the total number of triangles across all sub meshes
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L102-L104 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.vertexCount | get vertexCount(): number {
return this.vertices.length + this.cutVertices.length;
} | /**
* Gets the total number of vertices in the geometry
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L109-L111 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.addCutFaceVertex | addCutFaceVertex(position: Vector3, normal: Vector3, uv: Vector2): void {
const vertex = new MeshVertex(position, normal, uv);
this.vertices.push(vertex);
this.cutVertices.push(vertex);
// Track which non-cut-face vertex this cut-face vertex is mapped to
this.vertexAdjacency.push(this.vertices.leng... | /**
* Adds a new cut face vertex
* @param position The vertex position
* @param normal The vertex normal
* @param uv The vertex UV coordinates
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L119-L126 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.addMappedVertex | addMappedVertex(vertex: MeshVertex, sourceIndex: number): void {
this.vertices.push(vertex);
this.indexMap[sourceIndex] = this.vertices.length - 1;
} | /**
* Adds a new vertex to this mesh that is mapped to the source mesh
* @param vertex Vertex data
* @param sourceIndex Index of the vertex in the source mesh
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L133-L136 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.addTriangle | addTriangle(
v1: number,
v2: number,
v3: number,
subMesh: SlicedMeshSubmesh,
): void {
this.triangles[subMesh].push(v1, v2, v3);
} | /**
* Adds a new triangle to this mesh. The arguments v1, v2, v3 are the indexes of the
* vertices relative to this mesh's list of vertices; no mapping is performed.
* @param v1 Index of the first vertex
* @param v2 Index of the second vertex
* @param v3 Index of the third vertex
* @param subMesh The ... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L146-L153 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.addMappedTriangle | addMappedTriangle(
v1: number,
v2: number,
v3: number,
subMesh: SlicedMeshSubmesh,
): void {
this.triangles[subMesh].push(
this.indexMap[v1],
this.indexMap[v2],
this.indexMap[v3],
);
} | /**
* Adds a new triangle to this mesh. The arguments v1, v2, v3 are the indices of the
* vertices in the original mesh. These vertices are mapped to the indices in the sliced mesh.
* @param v1 Index of the first vertex
* @param v2 Index of the second vertex
* @param v3 Index of the third vertex
* @pa... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L163-L174 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.weldCutFaceVertices | weldCutFaceVertices(): void {
// Temporary array containing the unique (welded) vertices
// Initialize capacity to current number of cut vertices to prevent
// unnecessary reallocations
const weldedVerts: MeshVertex[] = [];
// Need to update adjacency as well
const weldedVertsAdjacency: number[]... | /**
* Finds coincident vertices on the cut face and welds them together.
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L179-L219 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Fragment.calculateBounds | calculateBounds() {
// Initialize min and max vectors with the first vertex in the array
let min = this.vertices[0].position.clone();
let max = min.clone();
// Iterate over the vertices to find the min and max x, y, and z
this.vertices.forEach((vertex) => {
min.x = Math.min(min.x, vertex.posi... | /**
* Calculates the bounds of the mesh data
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/Fragment.ts#L224-L241 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | MeshVertex.hash | hash(): number {
// Use inverse so we can multiply instead of divide to save a few ops
const x = Math.floor(this.position.x * this.invTolerance);
const y = Math.floor(this.position.y * this.invTolerance);
const z = Math.floor(this.position.z * this.invTolerance);
const xy = 0.5 * ((x + y) * (x + y +... | /**
* Uses Cantor pairing to hash vertex position into a unique integer
* @param inverseTolerance The inverse of the tolerance used for spatial hashing
* @returns
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/MeshVertex.ts#L29-L36 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | MeshVertex.equals | equals(other: MeshVertex): boolean {
return this.hash() === other.hash();
} | /**
* Returns true if this vertex and another vertex share the same position
* @param other
* @returns
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/MeshVertex.ts#L43-L45 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | TriangulationPoint.constructor | constructor(index: number, coords: Vector2) {
this.index = index;
this.coords = coords;
this.bin = 0;
} | /**
* Instantiates a new triangulation point
* @param index The index of the point in the original point list
* @param coords The 2D coordinates of the point in the triangulation plane
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/entities/TriangulationPoint.ts#L28-L32 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | getAdjacentVertex | function getAdjacentVertex(i: number, n: number): number {
if (i + 1 < n) {
return i + 1;
} else {
// If i == n, adjacent vertex is i == 1
return ((i + 1) % n) + 1;
}
} | // Helper function for getting an adjacent vertex, translated to TypeScript | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.test.ts#L7-L14 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.constructor | constructor(
inputPoints: MeshVertex[],
constraints: EdgeConstraint[],
normal: Vector3,
) {
super(inputPoints, normal);
this.constraints = constraints;
this.vertexTriangles = [];
} | /**
* Initializes the triangulator with the vertex data to be triangulated given a set of edge constraints
* @param inputPoints The of points to triangulate
* @param constraints The list of edge constraints which defines how the vertices in `inputPoints` are connected.
* @param normal The normal of the plan... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L69-L77 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.triangulate | triangulate(): number[] {
// Need at least 3 vertices to triangulate
if (this.N < 3) {
return [];
}
this.addSuperTriangle();
this.normalizeCoordinates();
this.computeTriangulation();
if (this.constraints.length > 0) {
this.applyConstraints();
this.discardTrianglesViolatin... | /**
* Calculates the triangulation
* @returns Returns an array containing the indices of the triangles, mapped to the list of points passed in during initialization.
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L83-L111 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.applyConstraints | applyConstraints(): void {
// Map each vertex to a triangle that contains it
this.vertexTriangles = new Array<number>(this.N + 3).fill(0);
for (let i = 0; i < this.triangulation.length; i++) {
this.vertexTriangles[this.triangulation[i][V1]] = i;
this.vertexTriangles[this.triangulation[i][V2]] = ... | /**
* Applys the edge constraints to the triangulation
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L116-L139 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.findIntersectingEdges | findIntersectingEdges(
constraint: EdgeConstraint,
vertexTriangles: number[],
): EdgeConstraint[] {
const intersectingEdges: EdgeConstraint[] = [];
// Need to find the first edge that the constraint crosses.
const startEdge = this.findStartingEdge(vertexTriangles, constraint);
if (startEdge)... | /**
* Searches through the triangulation to find intersecting edges
* @param constraint
* @param vertexTriangles
* @returns Array of edges that are intersecting
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L147-L230 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.findStartingEdge | findStartingEdge(
vertexTriangles: number[],
constraint: EdgeConstraint,
): EdgeConstraint | null {
// Initialize out parameter to default value
let startingEdge = new EdgeConstraint(-1, -1);
let v_i = constraint.v1;
// Start the search with an initial triangle that contains v1
let tSear... | /**
* Finds the starting edge for the search to find all edges that intersect the constraint
* @param vertexTriangles
* @param constraint The constraint being used to check for intersections
* @param startingEdge
* @returns
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L239-L324 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.removeIntersectingEdges | removeIntersectingEdges(
constraint: EdgeConstraint,
intersectingEdges: EdgeConstraint[],
): void {
// Remove intersecting edges. Keep track of the new edges that we create
let newEdges: EdgeConstraint[] = [];
let edge: EdgeConstraint | undefined;
// Mark the number of times we have been thro... | /// <param name="intersectingEdges">A queue containing the previously found edges that intersect the constraint</param> | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L332-L413 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.restoreConstrainedDelauneyTriangulation | restoreConstrainedDelauneyTriangulation(
constraint: EdgeConstraint,
newEdges: EdgeConstraint[],
): void {
// Iterate over the list of newly created edges and swap
// non-constraint diagonals until no more swaps take place
let swapOccurred = true;
let counter = 0;
while (swapOccurred) {
... | /// <param name="newEdges">The list of new edges that were added</param> | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L420-L462 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.discardTrianglesViolatingConstraints | discardTrianglesViolatingConstraints(): void {
// Initialize to all triangles being skipped
this.skipTriangle.fill(true);
function hash(x: number, y: number) {
return ((x + y) * (x + y + 1)) / 2 + y;
}
// Identify the boundary edges
let boundaries = new Set<number>();
for (let i = 0;... | /**
* Discards triangles that violate the any of the edge constraints
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L467-L542 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.triangleContainsConstraint | triangleContainsConstraint(t: number, constraint: EdgeConstraint): boolean {
if (t >= this.triangulation.length) return false;
return (
(this.triangulation[t][V1] === constraint.v1 ||
this.triangulation[t][V2] === constraint.v1 ||
this.triangulation[t][V3] === constraint.v1) &&
(thi... | /// <returns>True if the triangle contains one or both of the endpoints of the constraint</returns> | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L550-L561 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.edgeConstraintIntersectsTriangle | edgeConstraintIntersectsTriangle(
t: number,
constraint: EdgeConstraint,
): number | null {
const v_i = this.points[constraint.v1].coords;
const v_j = this.points[constraint.v2].coords;
const v1 = this.points[this.triangulation[t][V1]].coords;
const v2 = this.points[this.triangulation[t][V2]].... | /**
* Returns true if the edge constraint intersects an edge of triangle `t`
* @param t The triangle to test
* @param constraint The edge constraint
* @param intersectingEdgeIndex The index of the intersecting edge (E12, E23, E31)
* @returns Returns true if an intersection is found, otherwise false.
*... | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L570-L589 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.findQuadFromSharedEdge | findQuadFromSharedEdge(t1: number, t1SharedEdge: number): Quad | null {
// q3
// *---------*---------*
// \ / \ /
// \ t2L / \ t2R /
// \ / \ /
// \ / t2 \ /
// q1 *---------* q2
// / \ t1 / \
... | /**
*
* @param t1 Base triangle
* @param t1SharedEdge Edge index that is being intersected<
* @returns Returns the quad formed by triangle `t1` and the other triangle that shares the intersecting edge
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L597-L648 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.swapQuadDiagonal | swapQuadDiagonal(
quad: Quad,
edges1: EdgeConstraint[],
edges2: EdgeConstraint[],
edges3: EdgeConstraint[] | null,
): void {
// BEFORE
// q3
// *---------*---------*
// \ / \ /
// \ t2L / \ t2R /
// \ / \ /
// ... | /**
* Swaps the diagonal of the quadrilateral q0->q1->q2->q3 formed by t1 and t2
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L653-L726 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | ConstrainedTriangulator.updateEdgesAfterSwap | updateEdgesAfterSwap(
edges: EdgeConstraint[] | null,
t1: number,
t2: number,
t1L: number,
t1R: number,
t2L: number,
t2R: number,
) {
if (!edges) {
return;
}
// Update edges to reflect changes in triangles
for (let edge of edges) {
if (edge.t1 === t1 && edge.t2... | /**
* Update the edges
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/ConstrainedTriangulator.ts#L731-L770 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Triangulator.constructor | constructor(inputPoints: MeshVertex[], normal: Vector3) {
this.N = inputPoints.length;
if (this.N >= 3) {
this.triangleCount = 2 * this.N + 1;
this.triangulation = Array.from({ length: this.triangleCount }, () =>
new Array(6).fill(0),
);
this.skipTriangle = new Array<boolean>(th... | /**
* Initializes the triangulator with the vertex data to be triangulated
*
* @param inputPoints The points to triangulate
* @param normal The normal of the triangulation plane
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/Triangulator.ts#L73-L109 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Triangulator.triangulate | triangulate(): number[] {
// Need at least 3 vertices to triangulate
if (this.N < 3) {
return [];
}
this.addSuperTriangle();
this.normalizeCoordinates();
this.computeTriangulation();
this.discardTrianglesWithSuperTriangleVertices();
const triangles: number[] = [];
for (let i ... | /**
* Performs the triangulation
*
* @returns Returns an array containing the indices of the triangles, mapped to the list of points passed in during initialization
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/Triangulator.ts#L116-L140 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Triangulator.normalizeCoordinates | normalizeCoordinates() {
// 1) Normalize coordinates. Coordinates are scaled so they lie between 0 and 1
// The scaling should be uniform so relative positions of points are unchanged
let xMin = Number.MAX_VALUE;
let xMax = Number.MIN_VALUE;
let yMin = Number.MAX_VALUE;
let yMax = Number.MIN_VAL... | /**
* Uniformly scales the 2D coordinates of all the points between [0, 1]
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/Triangulator.ts#L145-L175 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Triangulator.sortPointsIntoBins | sortPointsIntoBins(): TriangulationPoint[] {
// Compute the number of bins along each axis
const n = Math.round(Math.pow(this.N, 0.25));
// Total bin count
const binCount = n * n;
// Assign bin numbers to each point by taking the normalized coordinates
// and dividing them into a n x n grid.
... | /**
* Sorts the points into bins using an ordered grid
*
* @returns Returns the array of sorted points
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/Triangulator.ts#L182-L199 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
three-pinata | github_2023 | dgreenheck | typescript | Triangulator.computeTriangulation | computeTriangulation() {
let tSearch = 0; // Index of the current triangle being searched
let tLast = 0; // Index of the last triangle formed
let sortedPoints = this.sortPointsIntoBins();
// Loop through each point and insert it into the triangulation
for (let i = 0; i < this.N; i++) {
let p... | /**
* Computes the triangulation of the point set.
* @returns Returns true if the triangulation was successful.
*/ | https://github.com/dgreenheck/three-pinata/blob/3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0/src/fracture/triangulators/Triangulator.ts#L205-L246 | 3d2f3acbfb4d237a2cee93f4118711aa7c5fa0b0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.