repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
velite | github_2023 | zce | typescript | VeliteFile.get | static get(path: string): VeliteFile | undefined {
return loaded.get(path)
} | /**
* Get meta object from cache
* @param path file path
* @returns resolved meta object if exists
*/ | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/file.ts#L75-L77 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | VeliteFile.create | static async create({ path, config }: { path: string; config: Config }): Promise<VeliteFile> {
const meta = new VeliteFile({ path, config })
const loader = config.loaders.find(loader => loader.test.test(path))
if (loader == null) return meta.fail(`no loader found for '${path}'`)
meta.value = await readF... | /**
* Create meta object from file path
* @param options meta options
* @returns resolved meta object
*/ | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/file.ts#L84-L93 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | flatten | const flatten = (msg: unknown): unknown => {
if (typeof msg !== 'string') return msg
return msg.replaceAll(process.cwd() + sep, '').replace(/\\/g, '/')
} | /**
* replace cwd with '.' and replace backslash with slash to make output more readable
* @param msg message
* @returns flattened message
*/ | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/logger.ts#L24-L27 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodString.nonempty | nonempty(message?: errorUtil.ErrMessage) {
return this.min(1, errorUtil.errToObj(message))
} | /**
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
*/ | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L1065-L1067 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | floatSafeRemainder | function floatSafeRemainder(val: number, step: number) {
const valDecCount = (val.toString().split('.')[1] || '').length
const stepDecCount = (step.toString().split('.')[1] || '').length
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount
const valInt = parseInt(val.toFixed(decCount).replac... | // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034 | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L1185-L1192 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodObject.extend | extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall> {
return new ZodObject({
...this._def,
shape: () => ({
...this._def.shape(),
...augmentation
})
}) as any
} | // }; | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2446-L2454 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodObject.merge | merge<Incoming extends AnyZodObject, Augmentation extends Incoming['shape']>(
merging: Incoming
): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming['_def']['unknownKeys'], Incoming['_def']['catchall']> {
const merged: any = new ZodObject({
unknownKeys: merging._def.unknownKeys,
catchall... | /**
* Prior to zod@1.0.12 there was a bug in the
* inferred type of merged objects. Please
* upgrade if you are experiencing issues.
*/ | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2498-L2511 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodObject.setKey | setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & { [k in Key]: Schema }, UnknownKeys, Catchall> {
return this.augment({ [key]: schema }) as any
} | // } | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2548-L2550 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodObject.catchall | catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index> {
return new ZodObject({
...this._def,
catchall: index
}) as any
} | // } | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2573-L2578 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodObject.deepPartial | deepPartial(): partialUtil.DeepPartial<this> {
return deepPartialify(this) as any
} | /**
* @deprecated
*/ | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2613-L2615 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | getDiscriminator | const getDiscriminator = <T extends ZodTypeAny>(type: T): Primitive[] => {
if (type instanceof ZodLazy) {
return getDiscriminator(type.schema)
} else if (type instanceof ZodEffects) {
return getDiscriminator(type.innerType())
} else if (type instanceof ZodLiteral) {
return [type.value]
} else if (ty... | ///////////////////////////////////////////////////// | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2853-L2884 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
velite | github_2023 | zce | typescript | ZodDiscriminatedUnion.create | static create<Discriminator extends string, Types extends [ZodDiscriminatedUnionOption<Discriminator>, ...ZodDiscriminatedUnionOption<Discriminator>[]]>(
discriminator: Discriminator,
options: Types,
params?: RawCreateParams
): ZodDiscriminatedUnion<Discriminator, Types> {
// Get all the valid discrim... | /**
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
* have a different value for each object in the union.
* @... | https://github.com/zce/velite/blob/cfb639a8fa0452168c1be3962a1022cdb947d8d3/src/schemas/zod/types.ts#L2971-L3005 | cfb639a8fa0452168c1be3962a1022cdb947d8d3 |
shadcnui-boilerplate | github_2023 | TinsFox | typescript | createWrapper | const createWrapper = () => {
return function Wrapper({ children }: { children: ReactNode }) {
return (
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
)
}
} | // 测试包装器 | https://github.com/TinsFox/shadcnui-boilerplate/blob/880aba5f59a9ef6de3d42597cf332ae7754b4a50/apps/admin/src/hooks/query/use-user.test.tsx#L31-L39 | 880aba5f59a9ef6de3d42597cf332ae7754b4a50 |
shadcnui-boilerplate | github_2023 | TinsFox | typescript | openInEditor | const openInEditor = (file: string) => {
fetch(`/__open-in-editor?file=${encodeURIComponent(`${file}`)}`)
} | // http://localhost:5173/src/App.tsx?t=1720527056591:41:9 | https://github.com/TinsFox/shadcnui-boilerplate/blob/880aba5f59a9ef6de3d42597cf332ae7754b4a50/apps/admin/src/lib/dev.tsx#L59-L61 | 880aba5f59a9ef6de3d42597cf332ae7754b4a50 |
shadcnui-boilerplate | github_2023 | TinsFox | typescript | getAbsolutePath | function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")))
} | /**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/ | https://github.com/TinsFox/shadcnui-boilerplate/blob/880aba5f59a9ef6de3d42597cf332ae7754b4a50/packages/pro-table/.storybook/main.ts#L9-L11 | 880aba5f59a9ef6de3d42597cf332ae7754b4a50 |
shadcnui-boilerplate | github_2023 | TinsFox | typescript | PaginationWrapper | function PaginationWrapper(props: Omit<React.ComponentProps<typeof DataTablePagination>, "table">) {
// 模拟数据和列
const data = React.useMemo(() => Array.from({ length: 100 }).fill(0).map((_, index) => ({ id: index })), [])
const columns = React.useMemo(() => [{ accessorKey: "id" }], [])
const table = useReactTabl... | // 创建一个包装组件来使用 Hook | https://github.com/TinsFox/shadcnui-boilerplate/blob/880aba5f59a9ef6de3d42597cf332ae7754b4a50/packages/pro-table/src/components/data-table/data-table-pagination.stories.tsx#L8-L28 | 880aba5f59a9ef6de3d42597cf332ae7754b4a50 |
shadcnui-boilerplate | github_2023 | TinsFox | typescript | ToolbarWrapper | function ToolbarWrapper(props: Omit<React.ComponentProps<typeof DataTableToolbar>, "table">) {
const table = useReactTable({
data: [],
columns: [],
getCoreRowModel: getCoreRowModel(),
})
return <DataTableToolbar table={table} {...props} />
} | // 创建一个包装组件来使用 Hook | https://github.com/TinsFox/shadcnui-boilerplate/blob/880aba5f59a9ef6de3d42597cf332ae7754b4a50/packages/pro-table/src/components/data-table/data-table-toolbar.stories.tsx#L8-L16 | 880aba5f59a9ef6de3d42597cf332ae7754b4a50 |
fuji-web | github_2023 | normal-computing | typescript | visionActionAdapter | function visionActionAdapter(action: ParsedResponseSuccess): Action {
const args = { ...action.parsedAction.args, uid: "" };
if ("elementId" in args) {
args.uid = args.elementId;
}
return {
thought: action.thought,
operation: {
name: action.parsedAction.name,
args,
} as Action["opera... | // make action compatible with vision agent | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/helpers/dom-agent/determineNextAction.ts#L145-L157 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | DomActions.sendCommand | private async sendCommand(method: string, params?: any): Promise<any> {
return chrome.debugger.sendCommand({ tabId: this.tabId }, method, params);
} | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/helpers/rpc/domActions.ts#L21-L23 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | DomActions.waitTillElementRendered | public async waitTillElementRendered(
selectorExpression: string,
interval = DEFAULT_INTERVAL,
timeout = DEFAULT_TIMEOUT,
): Promise<void> {
return waitTillStable(
async () => {
const { result } = await this.sendCommand("Runtime.evaluate", {
expression: `${selectorExpression}?.... | // so always check if it exists first (e.g. with waitForElement) | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/helpers/rpc/domActions.ts#L186-L201 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | sendMessage | function sendMessage<K extends keyof RPCMethods>(
tabId: number,
method: K,
payload: Parameters<RPCMethods[K]>,
): Promise<ReturnType<RPCMethods[K]>> {
// Send a message to the other world
// Ensure that the method and arguments are correct according to RpcMethods
return new Promise((resolve, reject) => {
... | // Call these functions to execute code in the content script | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/helpers/rpc/pageRPC.ts#L6-L22 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | scrollIntoViewFunction | function scrollIntoViewFunction() {
// @ts-expect-error this is run in the browser context
this.scrollIntoView({
block: "center",
inline: "center",
// behavior: 'smooth',
});
} | // TypeScript function | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/helpers/rpc/runtimeFunctionStrings.ts#L2-L9 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | isTouchedElement | function isTouchedElement(elem: Element) {
return (
elem.hasAttribute(VISIBLE_TEXT_ATTRIBUTE_NAME) ||
elem.hasAttribute(ARIA_LABEL_ATTRIBUTE_NAME)
);
} | // check if the node has the attributes we added | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/pages/content/drawLabels.ts#L119-L124 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | traverseDom | function traverseDom(node: Node, selector: string): DomAttrs {
if (node.nodeType === Node.TEXT_NODE) {
return { visibleText: node.nodeValue ?? "", ariaLabel: "" };
} else if (isElementNode(node)) {
if (!isVisible(node)) return emptyDomAttrs; // skip if the element is not visible
if (isTouchedElement(nod... | // find the visible text and best-match aria-label of the element | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/pages/content/drawLabels.ts#L128-L164 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | removeEmojis | function removeEmojis(label: string) {
return label.replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, "").trim();
} | // It removes all symbols except: | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/pages/content/drawLabels.ts#L171-L173 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | getWebPDataURL | function getWebPDataURL(
canvas: HTMLCanvasElement,
maxFileSizeMB: number = 5,
maxQuality = 1,
qualityStep = 0.05,
) {
const maxFileSizeBytes = maxFileSizeMB * 1024 * 1024;
let quality = maxQuality;
let dataURL = canvas.toDataURL("image/webp", quality);
// Check the size of the data URL
while (dataUR... | // Function to get WebP data URL and ensure it's less than 5 MB | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/src/shared/images/mergeScreenshots.ts#L50-L67 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | ManifestParser.constructor | private constructor() {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/utils/manifest-parser/index.ts#L5-L5 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | reload | function reload(): void {
pendingReload = false;
window.location.reload();
} | // reload | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/utils/reload/injections/view.ts#L19-L22 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | reloadWhenTabIsVisible | function reloadWhenTabIsVisible(): void {
!document.hidden && pendingReload && reload();
} | // reload when tab is visible | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/utils/reload/injections/view.ts#L25-L27 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
fuji-web | github_2023 | normal-computing | typescript | MessageInterpreter.constructor | private constructor() {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/normal-computing/fuji-web/blob/1aec509e4c437ca7764a5b4a56deaeba18691729/utils/reload/interpreter/index.ts#L5-L5 | 1aec509e4c437ca7764a5b4a56deaeba18691729 |
DistiLlama | github_2023 | shreyaskarnik | typescript | Header | const Header = ({ onBack, onRefresh, onOpenSettings }) => {
return (
<div className="header">
<FaBackspace size="2rem" className="button" onClick={onBack} title="Go Back" />
<FaCog size="2rem" className="button center-button" onClick={onOpenSettings} title="Settings" />
<IoIosRefresh size="2rem"... | // eslint-disable-next-line react/prop-types | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/src/pages/common/Header.tsx#L7-L15 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | bytesToGB | const bytesToGB = bytes => (bytes / 1e9).toFixed(2); | // Helper function to convert bytes to GB | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/src/pages/sidePanel/Settings.tsx#L10-L10 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | updateStorage | const updateStorage = (newModel, newTemperature) => {
chrome.storage.local.set({ model: newModel, temperature: newTemperature });
}; | // Function to update Chrome storage | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/src/pages/sidePanel/Settings.tsx#L22-L24 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | fetchAndSetModels | const fetchAndSetModels = async () => {
try {
setIsLoading(true);
const fetchedModels = await getModels();
if (isMounted) {
setModels(fetchedModels);
chrome.storage.local.get(['model', 'temperature', 'isDefaultSet'], result => {
if (result.isDefaultSet) {
... | // To handle component unmount | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/src/pages/sidePanel/Settings.tsx#L41-L78 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | ManifestParser.constructor | private constructor() {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/utils/manifest-parser/index.ts#L5-L5 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | reload | function reload(): void {
pendingReload = false;
window.location.reload();
} | // reload | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/utils/reload/injections/view.ts#L19-L22 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | reloadWhenTabIsVisible | function reloadWhenTabIsVisible(): void {
!document.hidden && pendingReload && reload();
} | // reload when tab is visible | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/utils/reload/injections/view.ts#L25-L27 | d0bff7ae6a310d910488a87016e0f14be286c31d |
DistiLlama | github_2023 | shreyaskarnik | typescript | MessageInterpreter.constructor | private constructor() {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/shreyaskarnik/DistiLlama/blob/d0bff7ae6a310d910488a87016e0f14be286c31d/utils/reload/interpreter/index.ts#L5-L5 | d0bff7ae6a310d910488a87016e0f14be286c31d |
InterpAny-Clearer | github_2023 | zzh-tech | typescript | App | const App = () => {
const [masks, setMasks] = useState<Array<modelMaskProps>>([]);
const [defaultRawMask, setDefaultRawMask] = useState<modelRawMaskProps | null>(null);
const [blocking, setBlocking] = useState<boolean>(false);
const addMask = (mask: modelMaskProps) => {
setMasks([...masks, mask]);
}
co... | // 000 | https://github.com/zzh-tech/InterpAny-Clearer/blob/50ece06a1fca91bfeed2bd3f2e724d696833ff63/webapp/webapp/src/App.tsx#L32-L82 | 50ece06a1fca91bfeed2bd3f2e724d696833ff63 |
InterpAny-Clearer | github_2023 | zzh-tech | typescript | initModel | const initModel = async () => {
try {
if (MODEL_DIR === undefined) return;
const URL: string = MODEL_DIR;
const model = await InferenceSession.create(URL);
setModel(model);
} catch (e) {
console.log(e);
}
}; | // Initialize the ONNX model | https://github.com/zzh-tech/InterpAny-Clearer/blob/50ece06a1fca91bfeed2bd3f2e724d696833ff63/webapp/webapp/src/StageApp.tsx#L50-L59 | 50ece06a1fca91bfeed2bd3f2e724d696833ff63 |
InterpAny-Clearer | github_2023 | zzh-tech | typescript | arrayToImageData | function arrayToImageData(input: any, width: number, height: number) {
const [r, g, b, a] = [0, 114, 189, 255]; // the masks's blue color
const arr = new Uint8ClampedArray(4 * width * height).fill(0);
for (let i = 0; i < input.length; i++) {
// Threshold the onnx model mask prediction at 0.0
// This is e... | // Convert the onnx model mask prediction to ImageData | https://github.com/zzh-tech/InterpAny-Clearer/blob/50ece06a1fca91bfeed2bd3f2e724d696833ff63/webapp/webapp/src/components/helpers/maskUtils.tsx#L28-L44 | 50ece06a1fca91bfeed2bd3f2e724d696833ff63 |
InterpAny-Clearer | github_2023 | zzh-tech | typescript | imageDataToImage | function imageDataToImage(imageData: ImageData) {
const canvas = imageDataToCanvas(imageData);
const image = new Image();
image.src = canvas.toDataURL();
return image;
} | // Use a Canvas element to produce an image from ImageData | https://github.com/zzh-tech/InterpAny-Clearer/blob/50ece06a1fca91bfeed2bd3f2e724d696833ff63/webapp/webapp/src/components/helpers/maskUtils.tsx#L47-L52 | 50ece06a1fca91bfeed2bd3f2e724d696833ff63 |
InterpAny-Clearer | github_2023 | zzh-tech | typescript | imageDataToCanvas | function imageDataToCanvas(imageData: ImageData) {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
canvas.width = imageData.width;
canvas.height = imageData.height;
ctx?.putImageData(imageData, 0, 0);
return canvas;
} | // Canvas elements can be created from ImageData | https://github.com/zzh-tech/InterpAny-Clearer/blob/50ece06a1fca91bfeed2bd3f2e724d696833ff63/webapp/webapp/src/components/helpers/maskUtils.tsx#L55-L62 | 50ece06a1fca91bfeed2bd3f2e724d696833ff63 |
InterpAny-Clearer | github_2023 | zzh-tech | typescript | handleImageScale | const handleImageScale = (image: HTMLImageElement) => {
// Input images to SAM must be resized so the longest side is 1024
const LONG_SIDE_LENGTH = 1024;
let w = image.naturalWidth;
let h = image.naturalHeight;
const samScale = LONG_SIDE_LENGTH / Math.max(h, w);
return { height: h, width: w, samScale };
}; | // Copyright (c) Meta Platforms, Inc. and affiliates. | https://github.com/zzh-tech/InterpAny-Clearer/blob/50ece06a1fca91bfeed2bd3f2e724d696833ff63/webapp/webapp/src/components/helpers/scaleHelper.tsx#L9-L16 | 50ece06a1fca91bfeed2bd3f2e724d696833ff63 |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | updateGame | const updateGame = () => {
const currentTime = performance.now();
gc.lastFrameDelta = (currentTime - lastUpdateTime) / 1000;
// const key = gc.input.getLastKeyDown("a", "w", "s", "d");
// if (key === "a") transform.translation.x -= 3;
// else if (key === "d") transform.translation.x += 3;
/... | /************************************
***** Updates the game state *******
************************************/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/components/Game.tsx#L231-L256 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | drawGame | const drawGame = () => {
const ents: EntsWith<[CTransform, CBackgroundTile]> = ecs.getEntsWith(CTransform, CBackgroundTile);
backgroundRenderSystem.run(gc, ents);
spriteRenderSystem.run(gc, ecs);
const fgEnts: EntsWith<[CTransform, CForegroundTile]> = ecs.getEntsWith(CTransform, CForegroundTile);
f... | /**
* Renders all content in the game
*/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/components/Game.tsx#L261-L271 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | CTransform.mat3 | public mat3(): Mat3 {
const c = Math.cos(this.rotation);
const s = Math.sin(this.rotation);
return new Mat3(
this.scale.x * c, -this.scale.y * s, -this.translation.x,
this.scale.x * s, this.scale.y * c, -this.translation.y,
0, 0, 1
);
} | /**
*
* @returns Matrix corresponding to Translate * R * scale,
*/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/engine/comps/CTransform.ts#L13-L22 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | AgentMovementSystem.isPositionOpen | private isPositionOpen(entId: number, pos: Vec2, colliders: EntsWith<[CGridCollider]>): boolean {
if (this.staticBoundaries.has(pos.toString())) {
return false;
}
for (const [eid, [collider]] of colliders) {
if (entId === eid) continue;
if (collider.gridPos?.equals(pos)) return false;
... | /**
*
* @param eid The ent id that is trying to move. Necessary so that they dont pick up self collisions
* @param pos The grid position they want to check if its available
* @param colliders The other colliders in the scene to check
* @returns
*/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/engine/systems/AgentMovementSystem.ts#L144-L154 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | GridMovementSystem.isPositionOpen | private isPositionOpen(entId: number, pos: Vec2, colliders: EntsWith<[CGridCollider]>): boolean {
if (this.staticBoundaries.has(pos.toString())) {
return false;
}
// todo, optimize collision detection with a hashset
for (const [eid, [collider]] of colliders) {
if (entId === eid) continue;
... | /**
*
* @param eid The ent id that is trying to move. Necessary so that they dont pick up self collisions
* @param pos The grid position they want to check if its available
* @param colliders The other colliders in the scene to check
* @returns
*/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/engine/systems/GridMovementSystem.ts#L100-L112 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | Index.addEnt | private addEnt(eid: EntIdType, manager: EcsManager) {
const comps = this.componentTypes.map(compType => manager.getComponent(eid, compType)) as T;
this.indexedComponents.set(eid, comps);
} | // } | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L34-L37 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | EcsManager.addComponent | public addComponent<T extends IComponent>(eid: EntIdType, component: T): T {
const store = this.getComponentStore(component.constructor.name);
store.set(eid, component);
this.updateIndexes(eid);
return component;
} | // Returns the component passed in | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L104-L109 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | EcsManager.removeComponent | public removeComponent<T extends IComponent>(eid: EntIdType, componentType: ComponentConstructor<T>): void {
const store = this.getComponentStore(componentType.name);
store.delete(eid);
this.updateIndexes(eid);
} | // Remove a component from an entity | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L112-L116 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | EcsManager.getComponent | public getComponent<T extends IComponent>(eid: EntIdType, componentType: ComponentConstructor<T>): T {
const store = this.getComponentStore(componentType.name);
return store.get(eid) as T;
} | // Get a component from an entity | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L119-L122 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | EcsManager.hasComponent | public hasComponent<T extends IComponent>(eid: EntIdType, componentType: ComponentConstructor<T>): boolean {
const store = this.getComponentStore(componentType.name);
return store.has(eid);
} | // Check if an entity has a component | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L125-L128 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | EcsManager.getEntsWith | public getEntsWith<T extends IComponent[]>(...componentTypes: ComponentConstructor<T[number]>[])
: EntsWith<T> {
// if just on component type passed in, use the component store itself
if (componentTypes.length === 1) {
const store = this.getComponentStore(componentTypes[0].name);
const iter = st... | // what if i make this extend the component constructors instead | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L163-L218 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | EcsManager.updateIndex | private updateIndex(index: Index<any>, entId?: EntIdType): void {
if (entId) {
index.addEntIfMatch(entId, this);
return;
}
for (const eid of this.entities) {
index.addEntIfMatch(eid, this);
}
} | // overloaded to support 1 or all | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Ecs.ts#L274-L282 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | InputMapper.getActionPressTime | getActionPressTime(action: Action): number | null {
const keys = this.keyMap[action];
let minPressTime = this.keyListener.getKeyPressTime(keys[0]);
for (let i = 1; i < keys.length; i++) {
const keyPressTime = this.keyListener.getKeyPressTime(keys[i]);
if (!keyPressTime) continue;
if (!minP... | /**
*
* @param action The action to check
* @returns The time the action was first pressed
*/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/Inputmapper.ts#L28-L41 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
ChatGPT_Agent | github_2023 | liyucheng09 | typescript | KeyListener.getLastKeyDown | getLastKeyDown(...keys: string[]): string | null {
let lastKeyDown: string | null = null;
let lastKeyPressTime = Number.NEGATIVE_INFINITY;
if ((keys?.length ?? 0) > 0) {
keys.forEach(key => {
const keyPressTime = this.getKeyPressTime(key);
if (keyPressTime !== null && keyPressTime > l... | /**
*
* @param keys Optional. If not provided, all keys are checked
* @returns The last key that was pressed
*/ | https://github.com/liyucheng09/ChatGPT_Agent/blob/d7cd74e79af467a6c6c56b96090f6d9860a5574e/src/frontend/infra/KeyListener.ts#L38-L61 | d7cd74e79af467a6c6c56b96090f6d9860a5574e |
wordflow | github_2023 | poloclub | typescript | Wordflow.constructor | constructor() {
super();
} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/.fttemplates/default-template/[FTName].ts#L20-L22 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | Wordflow.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/.fttemplates/default-template/[FTName].ts#L28-L28 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | Wordflow.initData | async initData() {} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/.fttemplates/default-template/[FTName].ts | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarConfirmDialog.constructor | constructor() {
super();
this.confirmAction = () => {};
this.cancelAction = () => {};
} | // ===== Lifecycle Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/confirm-dialog/confirm-dialog.ts#L42-L46 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarConfirmDialog.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/confirm-dialog/confirm-dialog.ts#L56-L56 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarConfirmDialog.initData | initData = async () => {} | // ===== Custom Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/confirm-dialog/confirm-dialog.ts | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarConfirmDialog.dialogClicked | dialogClicked(e: MouseEvent) {
if (e.target === this.dialogElement) {
this.dialogElement.close();
}
} | // ===== Event Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/confirm-dialog/confirm-dialog.ts#L91-L95 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarConfirmDialog.render | render() {
return html`
<dialog
class="confirm-dialog"
@click=${(e: MouseEvent) => this.dialogClicked(e)}
>
<div class="header">
<div class="header-name">${this.header}</div>
</div>
<div class="content">
<div class="message">${this.message}</d... | // ===== Templates and Styles ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/confirm-dialog/confirm-dialog.ts#L124-L164 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.constructor | constructor() {
super();
} | // ===== Lifecycle Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/floating-menu/floating-menu.ts#L35-L37 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.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/floating-menu/floating-menu.ts#L43-L43 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.initData | async initData() {} | // ===== Custom Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/floating-menu/floating-menu.ts#L46-L46 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.toolButtonGroupMouseEnterHandler | toolButtonGroupMouseEnterHandler(e: MouseEvent) {
e.preventDefault();
// Tell the editor component to highlight the effective region
const event = new Event('mouse-enter-tools', {
bubbles: true,
composed: true
});
this.dispatchEvent(event);
} | /**
* Highlight the currently effective region when the user hovers over the buttons
* @param e Mouse event
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/floating-menu/floating-menu.ts#L54-L63 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.toolButtonGroupMouseLeaveHandler | toolButtonGroupMouseLeaveHandler(e: MouseEvent) {
e.preventDefault();
const event = new Event('mouse-leave-tools', {
bubbles: true,
composed: true
});
this.dispatchEvent(event);
} | /**
* De-highlight the currently effective region when mouse leaves the buttons
* @param e Mouse event
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/floating-menu/floating-menu.ts#L69-L76 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.toolButtonClickHandler | toolButtonClickHandler(e: MouseEvent, index: number) {
e.preventDefault();
const curPrompt = this.favPrompts[index];
// Special case for empty button: clicking opens the setting window
if (curPrompt === null) {
this.settingButtonClicked();
return;
}
// Do not respond to interactio... | /**
* Notify the parent to take wordflow action
* @param e Mouse event
* @param index Index of the active tool button
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/floating-menu/floating-menu.ts#L83-L113 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowFloatingMenu.render | render() {
// Create the active tool buttons
let toolButtons = html``;
for (const [i, prompt] of this.favPrompts.entries()) {
// Take the first unicode character as the icon
const icon = prompt?.icon || '+';
toolButtons = html`${toolButtons}
<button
class="tool-button"
... | // ===== Templates and Styles ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/floating-menu/floating-menu.ts#L172-L226 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowModalAuth.constructor | constructor() {
super();
this.modelSetMap = {
palm: false,
gpt: false
};
this.modelMessageMap = {
palm: 'Verifying...',
gpt: 'Verifying...'
};
} | // ===== Lifecycle Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/modal-auth/modal-auth.ts#L41-L53 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowModalAuth.submitButtonClicked | initData = async () => {} | // ===== Custom Methods ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/modal-auth/modal-auth.ts | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowModalAuth.render | render() {
const getInputButtonLabel = (model: Model) => {
if (this.modelSetMap[model]) {
return 'Edit';
} else {
return 'Add';
}
};
return html`
<div class="modal-auth">
<div class="dialog-window">
<div class="header">Enter At Least an LLM API Key<... | // ===== Templates and Styles ====== | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/modal-auth/modal-auth.ts#L250-L323 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarPagination.constructor | constructor() {
super();
} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/pagination/pagination.ts#L34-L36 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarPagination.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/pagination/pagination.ts#L42-L42 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarPagination.initData | async initData() {} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/pagination/pagination.ts#L47-L47 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarPagination.pageButtonClicked | pageButtonClicked(name: string) {
let newPage = this.curPage;
if (name === 'Prev') {
if (this.curPage > 1) {
newPage -= 1;
}
} else if (name === 'Next') {
if (this.curPage < this.totalPageNum) {
newPage += 1;
}
} else {
const pageNum = parseInt(name);
... | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/pagination/pagination.ts#L52-L75 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarPagination.getPageButtonTemplate | getPageButtonTemplate = (name: string) => {
return html` <button
class="page-button"
?is-cur-page=${this.curPage === parseInt(name)}
@click=${() => this.pageButtonClicked(name)}
>
${name}
</button>`;
} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/pagination/pagination.ts | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | NightjarPagination.render | render() {
// Compose the pagination
let pagination = html``;
if (this.totalPageNum <= this.pageWindowSize) {
for (let i = 0; i < Math.max(this.totalPageNum, 1); i++) {
pagination = html`${pagination}
${this.getPageButtonTemplate(`${i + 1}`)}`;
}
} else {
const paginat... | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/pagination/pagination.ts#L93-L146 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelCommunity.constructor | constructor() {
super();
} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-community/panel-community.ts#L95-L97 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelCommunity.willUpdate | willUpdate(changedProperties: PropertyValues<this>) {
if (changedProperties.has('is-shown') && this['is-shown']) {
if (this.popularTags.length > 0) {
this.updateMaxTagsOneLine();
}
}
} | /**
* 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/panel-community/panel-community.ts#L103-L109 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelCommunity.initData | async initData() {} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-community/panel-community.ts#L116-L116 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelCommunity.updateMaxTagsOneLine | async updateMaxTagsOneLine() {
const popularTagsElement = await this.popularTagsElementPromise;
if (!this.panelElement) {
throw Error('A queried element is not initialized.');
}
const tagsBBox = popularTagsElement.getBoundingClientRect();
const tempTags = document.createElement('div');
t... | /**
* Determine how many popular tags to show so that the tags element has only one line
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-community/panel-community.ts#L121-L167 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelCommunity.popularTagListToggled | popularTagListToggled() {
this.isPopularTagListExpanded = !this.isPopularTagListExpanded;
} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-community/panel-community.ts#L172-L174 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelCommunity.render | render() {
// Create the tag list
let popularTagList = html``;
const curMaxTag = this.isPopularTagListExpanded
? Math.min(MAX_POPULAR_TAGS, this.popularTags.length)
: this.maxTagsOneLine;
for (const tag of this.popularTags.slice(0, curMaxTag)) {
popularTagList = html`${popularTagList}... | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-community/panel-community.ts#L290-L423 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.constructor | constructor() {
super();
} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L114-L116 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.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/panel-local/panel-local.ts#L133-L133 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.initData | async initData() {} | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L138-L138 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.promptCardClicked | promptCardClicked(promptData: PromptDataLocal) {
if (
this.promptModalElement === undefined ||
this.promptContentElement === undefined
) {
throw Error('promptModalElement is undefined.');
}
this.shouldCreateNewPrompt = false;
this.selectedPrompt = promptData;
this.promptModalEl... | //==========================================================================|| | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L144-L158 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.promptContainerScrolled | async promptContainerScrolled() {
if (
this.promptContainerElement === undefined ||
this.promptLoaderElement === undefined
) {
throw Error('promptContainerElement is undefined');
}
const isAtBottom =
this.promptContainerElement.scrollHeight -
this.promptContainerElement.... | /**
* Event handler for scroll event. Load more items when the user scrolls to
* the bottom.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L164-L202 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.promptCardDragStarted | promptCardDragStarted(e: DragEvent) {
this.isDraggingPromptCard = true;
const target = e.target as WordflowPromptCard;
target.classList.add('dragging');
document.body.style.setProperty('cursor', 'grabbing');
this.hoveringPromptCardIndex = null;
// Set the current prompt to data transfer
if... | /**
* Event handler for drag starting from the prompt card
* @param e Drag event
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L208-L261 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.promptCardDragEnded | promptCardDragEnded(e: DragEvent) {
this.isDraggingPromptCard = false;
const target = e.target as WordflowPromptCard;
target.classList.remove('dragging');
document.body.style.removeProperty('cursor');
// Remove the temporary slot element
this.draggingImageElement?.remove();
this.draggingIma... | /**
* Event handler for drag ending from the prompt card
* @param e Drag event
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L267-L276 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.favPromptSlotDropped | favPromptSlotDropped(e: DragEvent, index: number) {
if (e.dataTransfer) {
const newPromptDataString = e.dataTransfer.getData('newPromptData');
const newPromptData = JSON.parse(newPromptDataString) as PromptDataLocal;
this.favPrompts[index] = newPromptData;
const newFavPrompts = structuredClo... | /**
* Copy prompt data to the favorite prompt slot
* @param e Drag event
* @param index Index of the current fav prompt slot
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L293-L307 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.menuIconMouseEntered | menuIconMouseEntered(e: MouseEvent, button: 'edit' | 'delete' | 'remove') {
const target = e.currentTarget as HTMLElement;
let content = '';
switch (button) {
case 'edit': {
content = 'Edit';
break;
}
case 'delete': {
content = 'Delete';
break;
}
... | /**
* Event handler for mouse entering the menu bar button
* @param e Mouse event
* @param button Button name
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L352-L375 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.menuIconMouseLeft | menuIconMouseLeft() {
tooltipMouseLeave(this.tooltipConfig, 0);
} | /**
* Event handler for mouse leaving the info icon in each filed
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L380-L382 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.menuDeleteClicked | menuDeleteClicked(promptData: PromptDataLocal) {
if (this.confirmDialogComponent === undefined) {
throw Error('confirmDialogComponent is undefined');
}
const dialogInfo: DialogInfo = {
header: 'Delete Prompt',
message:
'Are you sure you want to delete this prompt? This action cann... | /**
* Delete the current prompt.
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L387-L403 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
wordflow | github_2023 | poloclub | typescript | WordflowPanelLocal.searchBarEntered | searchBarEntered(e: InputEvent) {
const inputElement = e.currentTarget as HTMLInputElement;
const query = inputElement.value;
if (query.length > 0) {
if (!this.showSearchBarCancelButton) {
// Record the total number of local prompts
this.totalLocalPrompts = this.localPrompts.length;
... | /**
* Handler for the search bar input event
* @param e Input event
*/ | https://github.com/poloclub/wordflow/blob/09840c4b7b4434152c83b55c5d47ab85d367e772/src/components/panel-local/panel-local.ts#L409-L432 | 09840c4b7b4434152c83b55c5d47ab85d367e772 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.