repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
wordflow | github_2023 | poloclub | typescript | NightjarToast.initData | async initData() {} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/toast/toast.ts#L122-L122 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarToast.show | show() {
if (this.isHidden) {
this.isHidden = false;
}
// Hide the element after delay
if (this.duration > 0) {
if (this.timer !== null) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
this.hide();
}, this.duration);
}
} | /**
* Show the toast message
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/toast/toast.ts#L127-L142 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarToast.hide | hide() {
if (this.isHidden) return;
if (this.shadowRoot === null) {
throw Error('Shadow root is null');
}
const toastElement = this.shadowRoot.querySelector('.toast') as HTMLElement;
// Fade the element first
const fadeOutAnimation = toastElement.animate(
{ opacity: [1, 0] },
... | /**
* Hide the toast message
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/toast/toast.ts#L147-L165 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarToast.render | render() {
let curIcon = SUCCESS_SVG;
if (this.type === 'warning') {
curIcon = WARN_SVG;
} else if (this.type === 'error') {
curIcon = ERROR_SVG;
}
return html`
<div class="toast" toast-type=${this.type} ?is-hidden=${this.isHidden}>
<div class="svg-icon">${curIcon}</div>
... | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/toast/toast.ts#L178-L200 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.restoreFromStorage | async restoreFromStorage() {
// Restore the local prompts
const promptKeys = (await get(`${PREFIX}-keys`)) as string[] | undefined;
if (promptKeys !== undefined) {
this.promptKeys = [];
this.localPrompts = [];
this.promptKeys = promptKeys;
for (const key of this.promptKeys) {
... | /**
* Reconstruct the prompts from the local storage.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L67-L107 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.addPrompt | addPrompt(newPrompt: PromptDataLocal) {
this.promptKeys.unshift(newPrompt.key);
this.localPrompts.unshift(newPrompt);
// Save the prompt and new keys in indexed db
set(`${PREFIX}-${newPrompt.key}`, newPrompt);
set(`${PREFIX}-keys`, this.promptKeys);
// If the user is in the search mode, add th... | /**
* Add a new prompt
* @param newPrompt New prompt
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L113-L129 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.setPrompt | setPrompt(newPrompt: PromptDataLocal) {
// Find the index of this prompt based on its key
let index = -1;
for (const [i, p] of this.localPrompts.entries()) {
if (p.key === newPrompt.key) {
index = i;
break;
}
}
if (index === -1) {
throw Error(`Can't find they key $... | /**
* Update the prompt in the localPrompts. This method doesn't change
* the prompt key.
* @param newPrompt New prompt
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L136-L190 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.deletePrompt | deletePrompt(prompt: PromptDataLocal) {
// Find the index of this prompt based on its key
let index = -1;
for (const [i, p] of this.localPrompts.entries()) {
if (p.key === prompt.key) {
index = i;
}
}
if (index === -1) {
throw Error(`Can't find they key ${prompt.key}.`);
... | /**
* Delete a prompt in the localPrompts
* @param prompt The prompt to delete
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L196-L255 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.setFavPrompt | setFavPrompt(index: number, newPrompt: PromptDataLocal | null) {
this.favPrompts[index] = newPrompt;
this.favPromptKeys[index] = newPrompt?.key || null;
// Update indexed db
set(`${PREFIX}-fav-keys`, this.favPromptKeys);
this._broadcastFavPrompts();
} | /**
* Update the prompt at the index of favPrompts
* @param index Index of the prompt in favPrompts to update (fav slot index)
* @param newPrompt New prompt
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L262-L270 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.sortPrompts | sortPrompts(order: 'name' | 'created' | 'runCount') {
switch (order) {
case 'name': {
this.localPrompts.sort((a, b) => a.title.localeCompare(b.title));
this.localPromptsProjection?.sort((a, b) =>
a.title.localeCompare(b.title)
);
break;
}
case 'created': ... | /**
* Sort the local prompts by an order
* @param order Order of the new local prompts
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L276-L317 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager.searchPrompt | searchPrompt(query: string) {
if (query === '') {
// Cancel the search
this.localPromptsProjection = null;
this._broadcastLocalPrompts();
} else {
// Create a projection of the local prompts that only include search results
this.localPromptsProjection = [];
const queryLower =... | /**
* Search all prompts and only show prompts including the query
* @param query Search query
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L323-L342 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager._cleanStorage | _cleanStorage() {
clear();
} | /**
* Remove all local storage set by PromptManager.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L347-L349 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager._syncStorage | _syncStorage() {
this.promptKeys = [];
for (const [_, prompt] of this.localPrompts.entries()) {
this.promptKeys.push(prompt.key);
set(`${PREFIX}-${prompt.key}`, prompt);
}
this.favPromptKeys = [null, null, null];
for (const prompt of this.favPrompts) {
this.favPromptKeys.push(prom... | /**
* Sync localPrompts and keys to storage
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L354-L368 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager._broadcastLocalPrompts | _broadcastLocalPrompts() {
this.localPromptCount = this.localPrompts.length;
this.localPromptBroadcastCount = this.localPrompts.length;
// const getRandomISODateString = () => {
// const start = new Date('2023-11-01');
// const end = new Date('2023-12-31T23:59:59');
// const randomDate = ... | /**
* Pass the localPrompts to consumers as their localPrompts
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L373-L419 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager._broadcastLocalPromptsProjection | _broadcastLocalPromptsProjection() {
if (this.localPromptsProjection === null) {
throw Error('localPromptsProjection is null');
}
this.localPromptCount = this.localPrompts.length;
this.localPromptBroadcastCount = this.localPromptsProjection.length;
this.localPromptsUpdateCallback(
struct... | /**
* Pass the localPromptsProjection to consumers as their localPrompts
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L424-L433 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager._broadcastFavPrompts | _broadcastFavPrompts() {
this.favPromptsUpdateCallback(structuredClone(this.favPrompts));
} | /**
* Pass the favPrompts to consumers as their favPrompts
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L438-L440 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | PromptManager._getPromptString | _getPromptString(prompt: PromptDataLocal) {
const content =
`${prompt.title} ${prompt.prompt} ${prompt.icon} ${prompt.description}
${prompt.recommendedModels} ${prompt.tags}`.toLowerCase();
return content;
} | /**
* Convert a prompt object to string that can be used for search
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/prompt-manager.ts#L445-L450 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager.getPopularTags | async getPopularTags() {
const url = new URL(ENDPOINT);
url.searchParams.append('popularTags', 'true');
const requestOptions: RequestInit = {
method: 'GET',
credentials: 'include'
};
const response = await fetch(url.toString(), requestOptions);
this.popularTags = (await response.jso... | /**
* Get a list of the most popular tags.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L73-L87 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager.getPromptsByTag | async getPromptsByTag(tag: string, orderMode: 'new' | 'popular') {
const url = new URL(ENDPOINT);
url.searchParams.append('tag', tag);
if (orderMode === 'new') {
url.searchParams.append('mostRecent', 'true');
} else {
url.searchParams.append('mostPopular', 'true');
}
const request... | /**
* Query prompts based on tags.
* @param tag A tag string. If tag is '', query all prompts.
* @param orderMode Prompt query order
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L94-L176 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager.sharePrompt | async sharePrompt(prompt: PromptDataLocal) {
const url = new URL(ENDPOINT);
url.searchParams.append('type', 'prompt');
const promptBody = { ...prompt } as PromptPOSTBody;
delete promptBody.created;
delete promptBody.promptRunCount;
delete promptBody.key;
const requestOptions: RequestInit =... | /**
* Share a local prompt to the server
* @param prompt Local prompt
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L182-L206 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager.getPrompt | async getPrompt(promptID: string) {
const url = new URL(ENDPOINT);
url.searchParams.append('getPrompt', promptID);
const requestOptions: RequestInit = {
method: 'GET',
credentials: 'include'
};
const response = await fetch(url.toString(), requestOptions);
if (response.status === 20... | /**
* Get a particular prompt
* @param promptID Remote prompt ID
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L212-L228 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager._broadcastRemotePrompts | _broadcastRemotePrompts() {
this.remotePromptsUpdateCallback(structuredClone(this.remotePrompts));
} | /**
* Pass the remotePrompts to consumers as their remotePrompts
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L233-L235 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager._broadcastPopularTags | _broadcastPopularTags() {
this.popularTagsUpdateCallback(structuredClone(this.popularTags));
} | /**
* Pass the popularTags to consumers as their popularTags
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L240-L242 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | RemotePromptManager._populateRemotePrompts | async _populateRemotePrompts(size: number) {
for (const p of fakePrompts.slice(0, size)) {
await this.sharePrompt(p);
}
} | /**
* Initialize remote servers with fake prompts
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L247-L251 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | getRandomISODateString | const getRandomISODateString = () => {
const start = new Date('2023-01-01'); // January 1, 2023
const end = new Date('2023-12-31T23:59:59'); // December 31, 2023
const randomDate = new Date(
start.getTime() + Math.random() * (end.getTime() - start.getTime())
);
return randomDate.toISOString();
}; | /**
* Generates a random ISO date string in 2023
*
* @returns {string} The generated random ISO date string.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/remote-prompt-manager.ts#L259-L266 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | UserConfigManager._restoreFromStorage | async _restoreFromStorage() {
// Restore the local prompts
const config = (await get(PREFIX)) as UserConfig | undefined;
if (config) {
this.#llmAPIKeys = config.llmAPIKeys;
this.#preferredLLM = config.preferredLLM;
}
this._broadcastUserConfig();
} | /**
* Reconstruct the prompts from the local storage.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/user-config.ts#L99-L107 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | UserConfigManager._syncStorage | async _syncStorage() {
const config = this._constructConfig();
await set(PREFIX, config);
} | /**
* Store the current config to local storage
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/user-config.ts#L112-L115 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | UserConfigManager._constructConfig | _constructConfig(): UserConfig {
const config: UserConfig = {
llmAPIKeys: this.#llmAPIKeys,
preferredLLM: this.#preferredLLM
};
return config;
} | /**
* Create a copy of the user config
* @returns User config
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/user-config.ts#L121-L127 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | UserConfigManager._cleanStorage | async _cleanStorage() {
await del(PREFIX);
} | /**
* Clean the local storage
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/user-config.ts#L132-L134 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | UserConfigManager._broadcastUserConfig | _broadcastUserConfig() {
const newConfig = this._constructConfig();
this.updateUserConfig(newConfig);
} | /**
* Update the public user config
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/user-config.ts#L139-L142 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowWordflow.constructor | constructor() {
super();
// Set up user info
this.initUserID();
// Set up the local prompt manager
const updateLocalPrompts = (newLocalPrompts: PromptDataLocal[]) => {
this.localPrompts = newLocalPrompts;
};
const updateFavPrompts = (
newFavPrompts: [
PromptDataLocal |... | // ===== Lifecycle Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L158-L228 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | updateLocalPrompts | const updateLocalPrompts = (newLocalPrompts: PromptDataLocal[]) => {
this.localPrompts = newLocalPrompts;
}; | // Set up the local prompt manager | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L165-L167 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | updateRemotePrompts | const updateRemotePrompts = (newRemotePrompts: PromptDataRemote[]) => {
this.remotePrompts = newRemotePrompts;
}; | // Set up the remote prompt manager | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L185-L187 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | updateUserConfig | const updateUserConfig = (userConfig: UserConfig) => {
this.userConfig = userConfig;
}; | // Set up the user config store | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L201-L203 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowWordflow.willUpdate | willUpdate(changedProperties: PropertyValues<this>) {} | /**
* This method is called before new DOM is updated and rendered
* @param changedProperties Property that has been changed
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L240-L240 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowWordflow.updateSidebarMenu | initData = async () => {} | /**
* Update the sidebar menu position and content
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowWordflow.initDefaultPrompts | initDefaultPrompts() {
let userID = localStorage.getItem('user-id');
if (userID === null) {
console.warn('userID is null');
userID = this.initUserID();
}
// Add some default prompts for the first-time users
const hasAddedDefaultPrompts = localStorage.getItem(
'has-added-default-pr... | /**
* Add a few default prompts to the new user's local library.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L259-L291 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowWordflow.sidebarMenuFooterButtonClickedHandler | sidebarMenuFooterButtonClickedHandler(e: CustomEvent<string>) {
// Delegate the event to the text editor component
if (!this.textEditorElement) return;
this.textEditorElement.sidebarMenuFooterButtonClickedHandler(e);
} | // ===== Event Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L409-L413 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowWordflow.render | render() {
return html`
<div class="wordflow">
<div class="toast-container">
<nightjar-toast
id="toast-wordflow"
message=${this.toastMessage}
type=${this.toastType}
></nightjar-toast>
</div>
<div class="left-panel">
<di... | // ===== Templates and Styles ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/wordflow/wordflow.ts#L488-L635 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | startLoadModel | const startLoadModel = async (
model: SupportedLocalModel,
temperature: number
) => {
const curModel = modelMap[model];
// Only use custom conv template for Llama to override the pre-included system
// prompt from WebLLM
let chatOption: webllm.ChatOptions | undefined = undefined;
if (model === Supported... | /**
* Reload a WebLLM model
* @param model Local LLM model
* @param temperature LLM temperature for all subsequent generation
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/llms/web-llm.ts#L151-L197 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | startTextGen | const startTextGen = async (prompt: string, temperature: number) => {
try {
const curEngine = await engine!;
const response = await curEngine.chat.completions.create({
messages: [{ role: 'user', content: prompt }],
n: 1,
max_gen_len: 2048,
// Override temperature to 0 because local mod... | /**
* Use Web LLM to generate text based on a given prompt
* @param prompt Prompt to give to the PaLM model
* @param temperature Model temperature
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/llms/web-llm.ts#L204-L243 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
vscode-helix | github_2023 | jasonwilliams | typescript | CommandLine.addChar | addChar(helixState: HelixState, char: string): void{
if (char==='\n'){
// when the `enter` key is pressed
this.enter(helixState)
return;
}
this.commandLineText += char;
// display what the user has written in command mode
this.setText(this.commandLineText, helixState);
} | // concatenate each keystroke to a buffer | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/commandLine.ts#L13-L22 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | SearchState.getFlags | getFlags(): string {
if (this.searchString.startsWith('(?i)')) {
return 'gi';
} else if (this.searchString.startsWith('(?-i)')) {
return 'g';
}
return this.searchString === this.searchString.toLowerCase() ? 'gi' : 'g';
} | // https://github.com/helix-editor/helix/issues/4978 | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/search.ts#L20-L28 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | SearchState.addChar | addChar(helixState: HelixState, char: string): void {
if (char === '\n') {
this.enter(helixState);
return;
}
// If we've just started a search, set a marker where we were so we can go back on escape
if (this.searchString === '') {
this.lastActivePosition = helixState.editorState.activ... | /** Add character to search string */ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/search.ts#L46-L64 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | SearchState.backspace | backspace(helixState: HelixState): void {
this.searchString = this.searchString.slice(0, -1);
helixState.commandLine.setText(this.searchString, helixState);
if (this.searchString && helixState.mode === Mode.Select) {
this.findInstancesInRange(helixState);
} else if (this.searchString) {
this... | /** The "type" event handler doesn't pick up backspace so it needs to be dealt with separately */ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/search.ts#L82-L90 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | SearchState.enter | enter(helixState: HelixState): void {
this.searchHistory.push(this.searchString);
this.searchString = '';
helixState.commandLine.setText(this.searchString, helixState);
// Upstream Bug
// Annoyingly, addSelectionToNextFindMatch actually does 2 things.
// For normal search it will put the select... | /** Clear search string and return to Normal mode */ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/search.ts#L93-L118 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | SearchState.previousSearchResult | previousSearchResult(helixState: HelixState): void {
if (this.searchHistory.length > 0) {
this.searchString = this.searchHistory[this.searchHistoryIndex] || '';
this.searchHistoryIndex = Math.max(this.searchHistoryIndex - 1, 0); // Add this line
helixState.commandLine.setText(this.searchString, he... | /** Go to the previous search result in our search history */ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/search.ts#L166-L173 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | StatusBarImpl.setText | public setText(helixState: HelixState, text: string) {
// Text
text = text.replace(/\n/g, '^M');
if (this.statusBarItem.text !== text) {
this.statusBarItem.text = `${this.statusBarPrefix(helixState)} ${text}`;
}
this.previousMode = helixState.mode;
this.showingDefaultMessage = false;
... | /**
* Updates the status bar text
* @param isError If true, text rendered in red
*/ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/statusBar.ts#L34-L44 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | StatusBarImpl.clear | public clear(helixState: HelixState, force = true) {
if (!this.showingDefaultMessage && !force) {
return;
}
StatusBar.setText(helixState, '');
this.showingDefaultMessage = true;
} | /**
* Clears any messages from the status bar, leaving the default info, such as
* the current mode and macro being recorded.
* @param force If true, will clear even high priority messages like errors.
*/ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/statusBar.ts#L59-L66 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | createInnerMatchHandler | function createInnerMatchHandler(): (
helixState: HelixState,
document: vscode.TextDocument,
position: vscode.Position,
) => vscode.Range | undefined {
return (helixState, document, position) => {
const count = helixState.resolveCount();
// Get all ranges from our position then reduce down to the shorte... | /*
* Implements going to nearest matching brackets from the cursor.
* This will need to call the other `createInnerBracketHandler` functions and get the smallest range from them.
* This should ensure that we're fetching the nearest bracket pair.
**/ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/actions/operator_ranges.ts#L518-L545 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | createOuterMatchHandler | function createOuterMatchHandler(): (
vimState: HelixState,
document: vscode.TextDocument,
position: vscode.Position,
) => vscode.Range | undefined {
return (_, document, position) => {
// Get all ranges from our position then reduce down to the shortest one
const bracketRange = [
getBracketRange(... | /*
* Implements going to nearest matching brackets from the cursor.
* This will need to call the other `createInnerBracketHandler` functions and get the smallest range from them.
* This should ensure that we're fetching the nearest bracket pair.
**/ | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/actions/operator_ranges.ts#L552-L578 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
vscode-helix | github_2023 | jasonwilliams | typescript | isEmptyRange | function isEmptyRange(range: vscode.Range) {
return range.start.line === range.end.line && range.start.character === range.end.character;
} | // detect if a range is covering just a single character | https://github.com/jasonwilliams/vscode-helix/blob/a79c1f022cf82433a6dfa929e31b2295d2be149d/src/actions/operators.ts#L143-L145 | a79c1f022cf82433a6dfa929e31b2295d2be149d |
local-action | github_2023 | github | typescript | checkActionPath | function checkActionPath(value: string): string {
const actionPath: string = path.resolve(value)
try {
// Confirm the value is a directory
if (!fs.statSync(actionPath).isDirectory())
throw new InvalidArgumentError('Action path must be a directory')
// eslint-disable-next-line @typescr... | /**
* Checks if the provided action path is valid
*
* @param value The action path
* @returns The resolved action path
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/command.ts#L23-L53 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | checkEntrypoint | function checkEntrypoint(value: string): string {
const entrypoint: string = path.resolve(EnvMeta.actionPath, value)
// Confirm the entrypoint exists
if (!fs.existsSync(entrypoint))
throw new InvalidArgumentError('Entrypoint does not exist')
// Save the action entrypoint to environment metadata
... | /**
* Checks if the provided entrypoint is valid
*
* @param value The entrypoint
* @returns The resolved entrypoint path
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/command.ts#L61-L72 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | checkDotenvFile | function checkDotenvFile(value: string): string {
const dotenvFile: string = path.resolve(value)
// Confirm the dotenv file exists
if (!fs.existsSync(dotenvFile))
throw new InvalidArgumentError('Environment file does not exist')
// Save the .env file path to environment metadata
EnvMeta.dote... | /**
* Checks if the provided dotenv file is valid
*
* @param value The dotenv file path
* @returns The resolved dotenv file path
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/command.ts#L80-L91 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | scrubQueryParameters | const scrubQueryParameters = (url: string): string => {
const parsed = new URL(url)
parsed.search = ''
return parsed.toString()
} | /**
* @github/local-action Unmodified
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/download/download-artifact.ts#L22-L26 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | exists | async function exists(path: string): Promise<boolean> {
try {
fs.accessSync(path)
return true
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (error.code === 'ENOENT') return false
else throw error
}
} | /**
* @github/local-action Unmodified
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/download/download-artifact.ts#L32-L41 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | streamExtract | async function streamExtract(url: string, directory: string): Promise<void> {
let retryCount = 0
while (retryCount < 5) {
try {
await streamExtractExternal(url, directory)
return
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
retryCount++
... | /**
* @github/local-action Unmodified
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/download/download-artifact.ts#L47-L65 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | resolveOrCreateDirectory | async function resolveOrCreateDirectory(
downloadPath = getGitHubWorkspaceDir()
): Promise<string> {
if (!(await exists(downloadPath))) {
core.debug(
`Artifact destination folder does not exist, creating: ${downloadPath}`
)
fs.mkdirSync(downloadPath, { recursive: true })
} else
core.debug(`A... | /**
* @github/local-action Unmodified
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/download/download-artifact.ts#L215-L227 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | filterLatest | function filterLatest(artifacts: Artifact[]): Artifact[] {
artifacts.sort((a, b) => b.id - a.id)
const latestArtifacts: Artifact[] = []
const seenArtifactNames = new Set<string>()
for (const artifact of artifacts) {
if (!seenArtifactNames.has(artifact.name)) {
latestArtifacts.push(artifact)
seen... | /**
* @github/local-action Unmodified
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/find/list-artifacts.ts#L137-L148 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | ZipUploadStream._transform | _transform(chunk: any, enc: any, cb: any): void {
cb(null, chunk)
} | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/upload/zip.ts#L25-L27 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | zipErrorCallback | const zipErrorCallback = (error: any): void => {
core.error('An error has occurred while creating the zip file for upload')
core.info(error)
throw new Error('An error has occurred during zip creation for the artifact')
} | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/upload/zip.ts#L84-L89 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | zipWarningCallback | const zipWarningCallback = (error: any): void => {
if (error.code === 'ENOENT') {
core.warning(
'ENOENT warning during artifact zip creation. No such file or directory'
)
core.info(error)
} else {
core.warning(
`A non-blocking warning has occurred during artifact zip creation: ${error.co... | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/artifact/internal/upload/zip.ts#L92-L104 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.constructor | constructor() {
this._buffer = ''
} | /**
* @github/local-action Unmodified
*
* Initialize with an empty buffer.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L80-L82 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.filePath | async filePath(): Promise<string> {
// Return the current value, if available.
if (this._filePath) return this._filePath
// Throw if the path is not set/empty.
if (!CoreMeta.stepSummaryPath)
throw new Error(
'Unable to find environment variable for $GITHUB_STEP_SUMMARY. Check if your runt... | /**
* @github/local-action Modified
*
* Finds the summary file path from the environment. Rejects if the
* environment variable is not set/empty or the file does not exist.
*
* @returns Step summary file path.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L92-L128 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.wrap | wrap(
tag: string,
content: string | null,
attrs: { [attribute: string]: string } = {}
): string {
const htmlAttrs: string = Object.entries(attrs)
.map(([key, value]) => ` ${key}="${value}"`)
.join('')
return !content
? `<${tag}${htmlAttrs}>`
: `<${tag}${htmlAttrs}>${conte... | /**
* @github/local-action Unmodified
*
* Wraps content in the provided HTML tag and adds any specified attributes.
*
* @param tag HTML tag to wrap. Example: 'html', 'body', 'div', etc.
* @param content The content to wrap within the tag.
* @param attrs A key-value list of HTML attributes to add.
... | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L140-L152 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.write | async write(
options: SummaryWriteOptions = { overwrite: false }
): Promise<Summary> {
// Set the function to call based on the overwrite setting.
const writeFunc = options.overwrite ? fs.writeFileSync : fs.appendFileSync
// If the file does not exist, create it. GitHub Actions runners normally
/... | /**
* @github/local-action Modified
*
* Writes the buffer to the summary file and empties the buffer. This can
* append (default) or overwrite the file.
*
* @param options Options for the write operation.
* @returns A promise that resolves to the Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L163-L179 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.clear | async clear(): Promise<Summary> {
return this.emptyBuffer().write({ overwrite: true })
} | /**
* @github/local-action Unmodified
*
* Clears the buffer and summary file.
*
* @returns A promise that resolve to the Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L188-L190 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.stringify | stringify(): string {
return this._buffer
} | /**
* @github/local-action Unmodified
*
* Returns the current buffer as a string.
*
* @returns Current buffer contents.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L199-L201 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.isEmptyBuffer | isEmptyBuffer(): boolean {
return this._buffer.length === 0
} | /**
* @github/local-action Unmodified
*
* Returns `true` the buffer is empty, `false` otherwise.
*
* @returns Whether the buffer is empty.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L210-L212 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.emptyBuffer | emptyBuffer(): Summary {
this._buffer = ''
return this
} | /**
* @github/local-action Unmodified
*
* Resets the buffer without writing to the summary file.
*
* @returns The Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L221-L224 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addRaw | addRaw(text: string, addEOL: boolean = false): Summary {
this._buffer += text
return addEOL ? this.addEOL() : this
} | /**
* @github/local-action Unmodified
*
* Adds raw text to the buffer.
*
* @param text The content to add.
* @param addEOL Whether to append `EOL` to the raw text (default: `false`).
*
* @returns The Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L236-L239 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addEOL | addEOL(): Summary {
return this.addRaw(EOL)
} | /**
* @github/local-action Unmodified
*
* Adds the operating system-specific `EOL` marker to the buffer.
*
* @returns The Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L248-L250 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addCodeBlock | addCodeBlock(code: string, lang?: string): Summary {
return this.addRaw(
this.wrap('pre', this.wrap('code', code), lang ? { lang } : {})
).addEOL()
} | /**
* @github/local-action Modified
*
* Adds a code block (\<code\>) to the buffer.
*
* @param code Content to render within the code block.
* @param lang Language to use for syntax highlighting.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L261-L265 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addList | addList(items: string[], ordered: boolean = false): Summary {
return this.addRaw(
this.wrap(
ordered ? 'ol' : 'ul',
items.map(item => this.wrap('li', item)).join('')
)
).addEOL()
} | /**
* @github/local-action Modified
*
* Adds a list (\<li\>) element to the buffer.
*
* @param items List of items to render.
* @param ordered Whether the list should be ordered.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L276-L283 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addTable | addTable(rows: SummaryTableRow[]): Summary {
return this.addRaw(
this.wrap(
'table',
// The table body consists of a list of rows, each with a list of cells.
rows
.map(row => {
const cells: string = row
.map(cell => {
// Cell is a str... | /**
* @github/local-action Modified
*
* Adds a table (\<table\>) element to the buffer.
*
* @param rows Table rows to render.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L293-L318 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addDetails | addDetails(label: string, content: string): Summary {
return this.addRaw(
this.wrap('details', this.wrap('summary', label) + content)
).addEOL()
} | /**
* @github/local-action Modified
*
* Adds a details (\<details\>) element to the buffer.
*
* @param label Text for the \<summary\> element.
* @param content Text for the \<details\> container.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L329-L333 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addImage | addImage(
src: string,
alt: string,
options: SummaryImageOptions = {}
): Summary {
return this.addRaw(
this.wrap('img', null, {
src,
alt,
...(options.width ? { width: options.width } : {}),
...(options.height ? { height: options.height } : {})
})
).addEO... | /**
* @github/local-action Modified
*
* Adds an image (\<img\>) element to the buffer.
*
* @param src Path to the image to embed.
* @param alt Text description of the image.
* @param options Additional image attributes.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L345-L358 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addHeading | addHeading(text: string, level: number | string = 1): Summary {
// If level is a string, attempt to parse it as a number.
const levelAsNum = typeof level === 'string' ? parseInt(level) : level
// If level is less than 1 or greater than 6, default to `h1`.
const tag =
Number.isNaN(levelAsNum) || l... | /**
* @github/local-action Modified
*
* Adds a heading (\<hX\>) element to the buffer.
*
* @param text Heading text to render.
* @param level Heading level. Defaults to `1`.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L369-L381 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addSeparator | addSeparator(): Summary {
return this.addRaw(this.wrap('hr', null)).addEOL()
} | /**
* @github/local-action Modified
*
* Adds a horizontal rule (\<hr\>) element to the buffer.
*
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L390-L392 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addBreak | addBreak(): Summary {
return this.addRaw(this.wrap('br', null)).addEOL()
} | /**
* @github/local-action Modified
*
* Adds a line break (\<br\>) to the buffer.
*
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L401-L403 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addQuote | addQuote(text: string, cite?: string): Summary {
return this.addRaw(
this.wrap('blockquote', text, cite ? { cite } : {})
).addEOL()
} | /**
* @github/local-action Modified
*
* Adds a block quote \<blockquote\> element to the buffer.
*
* @param text Quote text to render.
* @param cite (Optional) Citation URL.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L414-L418 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Summary.addLink | addLink(text: string, href: string): Summary {
return this.addRaw(this.wrap('a', text, { href })).addEOL()
} | /**
* @github/local-action Modified
*
* Adds an anchor (\<a\>) element to the buffer.
*
* @param text Text content to render.
* @param href Hyperlink to the target.
* @returns Summary instance for chaining.
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/core/summary.ts#L429-L431 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
local-action | github_2023 | github | typescript | Context.constructor | constructor() {
this.payload = {}
if (process.env.GITHUB_EVENT_PATH) {
console.log(process.env.GITHUB_EVENT_PATH)
if (existsSync(process.env.GITHUB_EVENT_PATH)) {
this.payload = JSON.parse(
readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })
)
} else {
... | /**
* Hydrate the context from the environment
*/ | https://github.com/github/local-action/blob/9d6078726e3f3abcd0c64f5134629bcf88dcb2c5/src/stubs/github/context.ts#L28-L60 | 9d6078726e3f3abcd0c64f5134629bcf88dcb2c5 |
PI-Assistant | github_2023 | Lucky-183 | typescript | emitTreeLayer | function emitTreeLayer(layer: ReadonlyRangeTree[], colMap: Map<number, number>): string {
const line: string[] = [];
let curIdx: number = 0;
for (const {start, end, count} of layer) {
const startIdx: number = colMap.get(start)!;
const endIdx: number = colMap.get(end)!;
if (startIdx > curIdx) {
l... | /**
*
* @param layer Sorted list of disjoint trees.
* @param colMap
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/dist/lib/_src/ascii.ts#L80-L93 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | stringifyFunctionRootRange | function stringifyFunctionRootRange(funcCov: Readonly<FunctionCov>): string {
const rootRange: RangeCov = funcCov.ranges[0];
return `${rootRange.startOffset.toString(10)};${rootRange.endOffset.toString(10)}`;
} | /**
* Returns a string representation of the root range of the function.
*
* This string can be used to match function with same root range.
* The string is derived from the start and end offsets of the root range of
* the function.
* This assumes that `ranges` is non-empty (true for valid function coverages).
*... | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/dist/lib/_src/merge.ts#L118-L121 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | mergeRangeTrees | function mergeRangeTrees(trees: ReadonlyArray<RangeTree>): RangeTree | undefined {
if (trees.length <= 1) {
return trees[0];
}
const first: RangeTree = trees[0];
let delta: number = 0;
for (const tree of trees) {
delta += tree.delta;
}
const children: RangeTree[] = mergeRangeTreeChildren(trees);
... | /**
* @precondition Same `start` and `end` for all the trees
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/dist/lib/_src/merge.ts#L167-L178 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | RangeTree.fromSortedRanges | static fromSortedRanges(ranges: ReadonlyArray<RangeCov>): RangeTree | undefined {
let root: RangeTree | undefined;
// Stack of parent trees and parent counts.
const stack: [RangeTree, number][] = [];
for (const range of ranges) {
const node: RangeTree = new RangeTree(range.startOffset, range.endOf... | /**
* @precodition `ranges` are well-formed and pre-order sorted
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/dist/lib/_src/range-tree.ts#L24-L51 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | RangeTree.split | split(value: number): RangeTree {
let leftChildLen: number = this.children.length;
let mid: RangeTree | undefined;
// TODO(perf): Binary search (check overhead)
for (let i: number = 0; i < this.children.length; i++) {
const child: RangeTree = this.children[i];
if (child.start < value && val... | /**
* @precondition `tree.start < value && value < tree.end`
* @return RangeTree Right part
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/dist/lib/_src/range-tree.ts#L105-L135 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | RangeTree.toRanges | toRanges(): RangeCov[] {
const ranges: RangeCov[] = [];
// Stack of parent trees and counts.
const stack: [RangeTree, number][] = [[this, 0]];
while (stack.length > 0) {
const [cur, parentCount]: [RangeTree, number] = stack.pop()!;
const count: number = parentCount + cur.delta;
ranges.... | /**
* Get the range coverages corresponding to the tree.
*
* The ranges are pre-order sorted.
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/dist/lib/_src/range-tree.ts#L142-L155 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | emitTreeLayer | function emitTreeLayer(layer: ReadonlyRangeTree[], colMap: Map<number, number>): string {
const line: string[] = [];
let curIdx: number = 0;
for (const {start, end, count} of layer) {
const startIdx: number = colMap.get(start)!;
const endIdx: number = colMap.get(end)!;
if (startIdx > curIdx) {
l... | /**
*
* @param layer Sorted list of disjoint trees.
* @param colMap
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/src/lib/ascii.ts#L80-L93 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | stringifyFunctionRootRange | function stringifyFunctionRootRange(funcCov: Readonly<FunctionCov>): string {
const rootRange: RangeCov = funcCov.ranges[0];
return `${rootRange.startOffset.toString(10)};${rootRange.endOffset.toString(10)}`;
} | /**
* Returns a string representation of the root range of the function.
*
* This string can be used to match function with same root range.
* The string is derived from the start and end offsets of the root range of
* the function.
* This assumes that `ranges` is non-empty (true for valid function coverages).
*... | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/src/lib/merge.ts#L118-L121 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | mergeRangeTrees | function mergeRangeTrees(trees: ReadonlyArray<RangeTree>): RangeTree | undefined {
if (trees.length <= 1) {
return trees[0];
}
const first: RangeTree = trees[0];
let delta: number = 0;
for (const tree of trees) {
delta += tree.delta;
}
const children: RangeTree[] = mergeRangeTreeChildren(trees);
... | /**
* @precondition Same `start` and `end` for all the trees
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/src/lib/merge.ts#L167-L178 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | RangeTree.fromSortedRanges | static fromSortedRanges(ranges: ReadonlyArray<RangeCov>): RangeTree | undefined {
let root: RangeTree | undefined;
// Stack of parent trees and parent counts.
const stack: [RangeTree, number][] = [];
for (const range of ranges) {
const node: RangeTree = new RangeTree(range.startOffset, range.endOf... | /**
* @precodition `ranges` are well-formed and pre-order sorted
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/src/lib/range-tree.ts#L24-L51 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | RangeTree.split | split(value: number): RangeTree {
let leftChildLen: number = this.children.length;
let mid: RangeTree | undefined;
// TODO(perf): Binary search (check overhead)
for (let i: number = 0; i < this.children.length; i++) {
const child: RangeTree = this.children[i];
if (child.start < value && val... | /**
* @precondition `tree.start < value && value < tree.end`
* @return RangeTree Right part
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/src/lib/range-tree.ts#L105-L135 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | RangeTree.toRanges | toRanges(): RangeCov[] {
const ranges: RangeCov[] = [];
// Stack of parent trees and counts.
const stack: [RangeTree, number][] = [[this, 0]];
while (stack.length > 0) {
const [cur, parentCount]: [RangeTree, number] = stack.pop()!;
const count: number = parentCount + cur.delta;
ranges.... | /**
* Get the range coverages corresponding to the tree.
*
* The ranges are pre-order sorted.
*/ | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@bcoe/v8-coverage/src/lib/range-tree.ts#L142-L155 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
PI-Assistant | github_2023 | Lucky-183 | typescript | buildNullArray | function buildNullArray<T extends { __proto__: null }>(): T {
return { __proto__: null } as T;
} | // Null arrays allow us to use ordered index keys without actually allocating contiguous memory like | https://github.com/Lucky-183/PI-Assistant/blob/2672d66e01ac6d8dedc840a9f23394ca26d6265f/QQMusicApi/node_modules/@jridgewell/trace-mapping/src/by-source.ts#L62-L64 | 2672d66e01ac6d8dedc840a9f23394ca26d6265f |
Microsoft-365-Copilot-Samples | github_2023 | OfficeDev | typescript | TokenValidator.constructor | constructor(options: TokenValidatorOptions) {
if (!options) {
throw new Error("options is required");
}
const cache = options.cache ?? true;
this.client = jwksClient({
cache,
cacheMaxAge: options.cacheMaxAge ?? 24 * 60 * 60 * 1000, // 24 hours in milliseconds
jwksUri: options.j... | /**
* Constructs a new instance of TokenValidator.
* @param {Object} options Configuration options for the TokenValidator.
* @param {boolean} [options.cache=true] Whether to cache the JWKS keys.
* @param {number} [options.cacheMaxAge=86400000] The maximum age of the cache in milliseconds (default is 24 hour... | https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/functions/middleware/tokenValidator.ts#L44-L60 | 159c86a02b84a4ebba05ec606411afc76bf9d9ab |
Microsoft-365-Copilot-Samples | github_2023 | OfficeDev | typescript | TokenValidator.validateToken | public async validateToken(token: string, options?: ValidateTokenOptions) {
const decoded = jwt.decode(token, { complete: true });
if (!decoded) {
throw new Error("jwt malformed");
}
// necessary to support multitenant apps
this.updateIssuer(decoded, options);
const key = await this.getS... | /**
* Validates a JWT token.
* @param {string} token The JWT token to validate.
* @param {import('jsonwebtoken').VerifyOptions & { complete?: false } & { idtyp?: string, ver?: string, scp?: string[], roles?: string[] }} [options] Validation options.
* @property {string[]} [options.allowedTenants] The allowe... | https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/functions/middleware/tokenValidator.ts#L74-L99 | 159c86a02b84a4ebba05ec606411afc76bf9d9ab |
Microsoft-365-Copilot-Samples | github_2023 | OfficeDev | typescript | TokenValidator.clearCache | public clearCache() {
this.cacheWrapper?.cache.reset();
} | /**
* Clears the cache used by the TokenValidator.
*/ | https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/functions/middleware/tokenValidator.ts#L155-L157 | 159c86a02b84a4ebba05ec606411afc76bf9d9ab |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.