type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
InterfaceDeclaration
/** * Wraps sampling parameters for a WebGL texture */ export interface SamplingParameters { /** * Magnification mode when upsampling from a WebGL texture */ magFilter?: TextureMagFilter; /** * Minification mode when upsampling from a WebGL texture */ minFilter?: TextureMinFilter; /** * X axis wrapping mode when sampling out of a WebGL texture bounds */ wrapS?: TextureWrapMode; /** * Y axis wrapping mode when sampling out of a WebGL texture bounds */ wrapT?: TextureWrapMode; /** * Anisotropic filtering samples */ maxAnisotropy?: number; }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
EnumDeclaration
/** * WebGL Pixel Formats */ export const enum PixelFormat { DEPTH_COMPONENT = 0x1902, ALPHA = 0x1906, RGB = 0x1907, RGBA = 0x1908, LUMINANCE = 0x1909, LUMINANCE_ALPHA = 0x190a, }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
EnumDeclaration
/** * WebGL Pixel Types */ export const enum PixelType { UNSIGNED_BYTE = 0x1401, UNSIGNED_SHORT_4_4_4_4 = 0x8033, UNSIGNED_SHORT_5_5_5_1 = 0x8034, UNSIGNED_SHORT_5_6_5 = 0x8363, }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
EnumDeclaration
/** * WebGL Texture Magnification Filter */ export const enum TextureMagFilter { NEAREST = 0x2600, LINEAR = 0x2601, }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
EnumDeclaration
/** * WebGL Texture Minification Filter */ export const enum TextureMinFilter { NEAREST = 0x2600, LINEAR = 0x2601, NEAREST_MIPMAP_NEAREST = 0x2700, LINEAR_MIPMAP_NEAREST = 0x2701, NEAREST_MIPMAP_LINEAR = 0x2702, LINEAR_MIPMAP_LINEAR = 0x2703, }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
EnumDeclaration
/** * WebGL Texture Wrap Modes */ export const enum TextureWrapMode { REPEAT = 0x2901, CLAMP_TO_EDGE = 0x812f, MIRRORED_REPEAT = 0x8370, }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
TypeAliasDeclaration
/** * Represents a valid WebGL texture source for use in texImage2D */ export type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
TypeAliasDeclaration
/** * A generic set of texture mipmaps (where index 0 has the largest dimension) */ export type Mipmaps<T> = Array<T>;
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
TypeAliasDeclaration
/** * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z] */ export type Faces<T> = Array<T>;
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
TypeAliasDeclaration
/** * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension) */ export type Mipmaps2D = Mipmaps<TextureSource>;
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
TypeAliasDeclaration
/** * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension) */ export type MipmapsCube = Mipmaps<Faces<TextureSource>>;
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
MethodDeclaration
/** * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters. * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created. * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired. * @param scene A Babylon Scene instance * @param textureCube A Spectre TextureCube object * @param parameters WebGL texture sampling parameters * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images) * @param environment Specifies that the texture will be used as an environment * @param singleLod Specifies that the texture will be a singleLod (for environment) * @return Babylon cube texture */ public static GetBabylonCubeTexture(scene: Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment = false, singleLod = false): CubeTexture { if (!textureCube) { throw new Error("no texture cube provided"); } var parameters: SamplingParameters; if (environment) { parameters = singleLod ? TextureUtils._EnvironmentSingleMipSampling : TextureUtils._EnvironmentSampling; } else { parameters = { magFilter: TextureMagFilter.NEAREST, minFilter: TextureMinFilter.NEAREST, wrapS: TextureWrapMode.CLAMP_TO_EDGE, wrapT: TextureWrapMode.CLAMP_TO_EDGE }; } let key = TextureUtils.BabylonTextureKeyPrefix + parameters.magFilter + '' + parameters.minFilter + '' + parameters.wrapS + '' + parameters.wrapT; let babylonTexture: CubeTexture = (<any>textureCube)[key]; if (!babylonTexture) { //initialize babylon texture babylonTexture = new CubeTexture('', scene); if (environment) { babylonTexture.lodGenerationOffset = TextureUtils.EnvironmentLODOffset; babylonTexture.lodGenerationScale = TextureUtils.EnvironmentLODScale; } babylonTexture.gammaSpace = false; let internalTexture = new InternalTexture(scene.getEngine(), InternalTexture.DATASOURCE_CUBERAW); let glTexture = internalTexture._webGLTexture; //babylon properties internalTexture.isCube = true; internalTexture.generateMipMaps = false; babylonTexture._texture = internalTexture; TextureUtils.ApplySamplingParameters(babylonTexture, parameters); let maxMipLevel = automaticMipmaps ? 0 : textureCube.source.length - 1; let texturesUploaded = 0; var textureComplete = function() { return texturesUploaded === ((maxMipLevel + 1) * 6); }; var uploadFace = function(i: number, level: number, face: TextureSource) { if (!glTexture) { return; } if (i === 0 && level === 0) { internalTexture.width = face.width; internalTexture.height = face.height; } let gl = (<any>(scene.getEngine()))._gl; gl.bindTexture(gl.TEXTURE_CUBE_MAP, glTexture); scene.getEngine()._unpackFlipY(false); if (face instanceof HTMLElement || face instanceof ImageData) { gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, textureCube.internalFormat, textureCube.internalFormat, textureCube.type, <any>face); } else { let textureData = <TextureData>face; gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, textureCube.internalFormat, textureData.width, textureData.height, 0, textureData.format, textureCube.type, textureData.data); } texturesUploaded++; if (textureComplete()) { //generate mipmaps if (automaticMipmaps) { let w = face.width; let h = face.height; let isPot = (((w !== 0) && (w & (w - 1))) === 0) && (((h !== 0) && (h & (h - 1))) === 0); if (isPot) { gl.generateMipmap(gl.TEXTURE_CUBE_MAP); } } // Upload Separate lods in case there is no support for texture lod. if (environment && !scene.getEngine().getCaps().textureLOD && !singleLod) { const mipSlices = 3; for (let i = 0; i < mipSlices; i++) { let lodKey = TextureUtils.BabylonTextureKeyPrefix + 'lod' + i; let lod: CubeTexture = (<any>textureCube)[lodKey]; //initialize lod texture if it doesn't already exist if (lod == null && textureCube.Width) { //compute LOD from even spacing in smoothness (matching shader calculation) let smoothness = i / (mipSlices - 1); let roughness = 1 - smoothness; const kMinimumVariance = 0.0005; let alphaG = roughness * roughness + kMinimumVariance; let microsurfaceAverageSlopeTexels = alphaG * textureCube.Width; let environmentSpecularLOD = TextureUtils.EnvironmentLODScale * (Scalar.Log2(microsurfaceAverageSlopeTexels)) + TextureUtils.EnvironmentLODOffset; let maxLODIndex = textureCube.source.length - 1; let mipmapIndex = Math.min(Math.max(Math.round(environmentSpecularLOD), 0), maxLODIndex); lod = TextureUtils.GetBabylonCubeTexture(scene, new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, [textureCube.source[mipmapIndex]]), false, true, true); if (i === 0) { internalTexture._lodTextureLow = lod; } else if (i === 1) { internalTexture._lodTextureMid = lod; } else { internalTexture._lodTextureHigh = lod; } (<any>textureCube)[lodKey] = lod; } } } internalTexture.isReady = true; } gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); scene.getEngine().resetTextureCache(); }; for (let i = 0; i <= maxMipLevel; i++) { let faces = textureCube.source[i]; for (let j = 0; j < faces.length; j++) { let face = faces[j]; if (face instanceof HTMLImageElement && !face.complete) { face.addEventListener('load', () => { uploadFace(j, i, face); }, false); } else { uploadFace(j, i, face); } } } scene.getEngine().resetTextureCache(); babylonTexture.isReady = () => { return textureComplete(); }; (<any>textureCube)[key] = babylonTexture; } return babylonTexture; }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
MethodDeclaration
/** * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field) * @param parameters Spectre SamplingParameters to apply */ public static ApplySamplingParameters(babylonTexture: BaseTexture, parameters: SamplingParameters) { let scene = babylonTexture.getScene(); if (!scene) { return; } let gl = (<any>(scene.getEngine()))._gl; let target = babylonTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D; let internalTexture = babylonTexture._texture; if (!internalTexture) { return; } let glTexture = internalTexture._webGLTexture; gl.bindTexture(target, glTexture); if (parameters.magFilter != null) { gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, parameters.magFilter); } if (parameters.minFilter != null) { gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, parameters.minFilter); } if (parameters.wrapS != null) { gl.texParameteri(target, gl.TEXTURE_WRAP_S, parameters.wrapS); } if (parameters.wrapT != null) { gl.texParameteri(target, gl.TEXTURE_WRAP_T, parameters.wrapT); } //set babylon wrap modes from sampling parameter switch (parameters.wrapS) { case TextureWrapMode.REPEAT: babylonTexture.wrapU = Texture.WRAP_ADDRESSMODE; break; case TextureWrapMode.CLAMP_TO_EDGE: babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE; break; case TextureWrapMode.MIRRORED_REPEAT: babylonTexture.wrapU = Texture.MIRROR_ADDRESSMODE; break; default: babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE; } switch (parameters.wrapT) { case TextureWrapMode.REPEAT: babylonTexture.wrapV = Texture.WRAP_ADDRESSMODE; break; case TextureWrapMode.CLAMP_TO_EDGE: babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE; break; case TextureWrapMode.MIRRORED_REPEAT: babylonTexture.wrapV = Texture.MIRROR_ADDRESSMODE; break; default: babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE; } if (parameters.maxAnisotropy != null && parameters.maxAnisotropy > 1) { let anisotropicExt = gl.getExtension('EXT_texture_filter_anisotropic'); if (anisotropicExt) { let maxAnisotropicSamples = gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT); let maxAnisotropy = Math.min(parameters.maxAnisotropy, maxAnisotropicSamples); gl.texParameterf(target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy); babylonTexture.anisotropicFilteringLevel = maxAnisotropy; } } gl.bindTexture(target, null); scene.getEngine().resetTextureCache(); }
CGHWorker/Babylon.js
Viewer/src/labs/texture.ts
TypeScript
ClassDeclaration
@NgModule({ imports: [CommonModule, A11yModule, McCommonModule], exports: [McToggleComponent], declarations: [McToggleComponent] }) export class McToggleModule { }
Di-did-done/mosaic
packages/mosaic/toggle/toggle.module.ts
TypeScript
ClassDeclaration
@Injectable() export class CreateProfileMapper { public request(request: CreateProfileRequest): Partial<Profile> { return { gender: request.gender, emailId: request.emailId, city: request.city, }; } }
Madhan-vj/typeorm-relations
src/modules/profile/create-profile/create-profile-mapper.ts
TypeScript
MethodDeclaration
public request(request: CreateProfileRequest): Partial<Profile> { return { gender: request.gender, emailId: request.emailId, city: request.city, }; }
Madhan-vj/typeorm-relations
src/modules/profile/create-profile/create-profile-mapper.ts
TypeScript
ArrowFunction
() => { const intl = useIntl() const { register, formState: { errors: { chassisNumber: chassisNumberError }, }, } = useFormContext<CreateVehicleRequest>() return ( <Input label={intl.formatMessage({ defaultMessage: 'Chassis number', description: 'Chassis number field', })} helperText={chassisNumberError?.message} helperColor={'error'} status={chassisNumberError ? 'error' : 'default'} width="100%" {...register('chassisNumber', { required: { value: true, message: intl.formatMessage({ defaultMessage: 'Please enter a chassis number', description: 'Error message for chassis number field', }), }, })} />
cantte/rusell-web
packages/vehicles/src/components/form/chassis-number.field.tsx
TypeScript
ArrowFunction
(evt) => { if (!(evt instanceof NavigationEnd)) { return; } window.scrollTo(0, 0); }
lndlwangwei/coreui-free-angular-admin-template
src/app/app.component.ts
TypeScript
ClassDeclaration
@Component({ // tslint:disable-next-line selector: 'body', template: '<router-outlet></router-outlet><app-alert></app-alert>' }) export class AppComponent implements OnInit { constructor(private router: Router) { } ngOnInit() { this.router.events.subscribe((evt) => { if (!(evt instanceof NavigationEnd)) { return; } window.scrollTo(0, 0); }); } }
lndlwangwei/coreui-free-angular-admin-template
src/app/app.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.router.events.subscribe((evt) => { if (!(evt instanceof NavigationEnd)) { return; } window.scrollTo(0, 0); }); }
lndlwangwei/coreui-free-angular-admin-template
src/app/app.component.ts
TypeScript
FunctionDeclaration
/** * Tap configuration in a Network Interface. * API Version: 2020-08-01. */ export function getNetworkInterfaceTapConfiguration(args: GetNetworkInterfaceTapConfigurationArgs, opts?: pulumi.InvokeOptions): Promise<GetNetworkInterfaceTapConfigurationResult> { if (!opts) { opts = {} } if (!opts.version) { opts.version = utilities.getVersion(); } return pulumi.runtime.invoke("azure-native:network:getNetworkInterfaceTapConfiguration", { "networkInterfaceName": args.networkInterfaceName, "resourceGroupName": args.resourceGroupName, "tapConfigurationName": args.tapConfigurationName, }, opts); }
pulumi-bot/pulumi-azure-native
sdk/nodejs/network/getNetworkInterfaceTapConfiguration.ts
TypeScript
InterfaceDeclaration
export interface GetNetworkInterfaceTapConfigurationArgs { /** * The name of the network interface. */ readonly networkInterfaceName: string; /** * The name of the resource group. */ readonly resourceGroupName: string; /** * The name of the tap configuration. */ readonly tapConfigurationName: string; }
pulumi-bot/pulumi-azure-native
sdk/nodejs/network/getNetworkInterfaceTapConfiguration.ts
TypeScript
InterfaceDeclaration
/** * Tap configuration in a Network Interface. */ export interface GetNetworkInterfaceTapConfigurationResult { /** * A unique read-only string that changes whenever the resource is updated. */ readonly etag: string; /** * Resource ID. */ readonly id?: string; /** * The name of the resource that is unique within a resource group. This name can be used to access the resource. */ readonly name?: string; /** * The provisioning state of the network interface tap configuration resource. */ readonly provisioningState: string; /** * Sub Resource type. */ readonly type: string; /** * The reference to the Virtual Network Tap resource. */ readonly virtualNetworkTap?: outputs.network.VirtualNetworkTapResponse; }
pulumi-bot/pulumi-azure-native
sdk/nodejs/network/getNetworkInterfaceTapConfiguration.ts
TypeScript
ArrowFunction
async (): Promise<string[]> => { const disciplines = await AsyncStorage.getItem('customDisciplines') return disciplines ? JSON.parse(disciplines) : null }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (customDisciplines: string[]): Promise<void> => { await AsyncStorage.setItem('customDisciplines', JSON.stringify(customDisciplines)) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (session: sessionData): Promise<void> => { await AsyncStorage.setItem(SESSION_KEY, JSON.stringify(session)) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (): Promise<sessionData | null> => { const sessionJson = await AsyncStorage.getItem(SESSION_KEY) return sessionJson === null ? null : JSON.parse(sessionJson) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (): Promise<void> => { await AsyncStorage.removeItem(SESSION_KEY) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (exerciseKey: ExerciseKeyType, exercise: ExerciseType): Promise<void> => { await AsyncStorage.setItem(exerciseKey.toString(), JSON.stringify(exercise)) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (exerciseKey: ExerciseKeyType): Promise<ExerciseType | null> => { const exerciseJson = await AsyncStorage.getItem(exerciseKey.toString()) return exerciseJson === null ? null : JSON.parse(exerciseJson) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
async (exerciseKey: ExerciseKeyType): Promise<void> => { await AsyncStorage.removeItem(exerciseKey.toString()) }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
InterfaceDeclaration
export interface ExerciseType { [disciplineId: number]: { [word: string]: DocumentResultType } }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
InterfaceDeclaration
interface sessionData { id: number title: string numberOfWords: number exercise: number retryData?: { data: DocumentsType } results: [] }
digitalfabrik/lunes-app
src/services/AsyncStorage.ts
TypeScript
ArrowFunction
(value: unknown): string => { const coercedValue = coerceType(value); return coercedValue.toLowerCase(); }
stekycz/graphql-extra-scalars
src/scalars/uuid.ts
TypeScript
ArrowFunction
() => <hr css
lucymonie/repo-migration-testv2
apps-rendering/src/components/horizontalRule.tsx
TypeScript
ClassDeclaration
export class CreateScheduleRequest { readonly disciplineId: number; readonly grade: string; }
viniosilva/kairos-manager
src/schedule/dto/create-schedule.dto.ts
TypeScript
ClassDeclaration
export class CreateScheduleResponse extends CreateScheduleRequest { readonly id: number; }
viniosilva/kairos-manager
src/schedule/dto/create-schedule.dto.ts
TypeScript
FunctionDeclaration
export function createSnapToN(n: number): Type;
Abogical/DefinitelyTyped
types/ol/rotationconstraint.d.ts
TypeScript
FunctionDeclaration
export function createSnapToZero(opt_tolerance?: number): Type;
Abogical/DefinitelyTyped
types/ol/rotationconstraint.d.ts
TypeScript
FunctionDeclaration
export function disable(rotation: number, delta: number): number;
Abogical/DefinitelyTyped
types/ol/rotationconstraint.d.ts
TypeScript
FunctionDeclaration
export function none(rotation: number, delta: number): number;
Abogical/DefinitelyTyped
types/ol/rotationconstraint.d.ts
TypeScript
TypeAliasDeclaration
export type Type = ((param0: number, param1: number) => number);
Abogical/DefinitelyTyped
types/ol/rotationconstraint.d.ts
TypeScript
ArrowFunction
webview => { webview.showFind(); this._findWidgetVisible.set(true); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
webview => webview.hideFind()
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
webview => { webview.runFindAction(previous); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
webview => webview.reload()
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
focused => { if (focused && this._editorService.activeControl === this) { this.focus(); } }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
webview => webview.focus()
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
() => this._onDidFocusWebview.fire()
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ClassDeclaration
export class WebviewEditor extends BaseEditor { public static readonly ID = 'WebviewEditor'; private readonly _scopedContextKeyService = this._register(new MutableDisposable<IContextKeyService>()); private _findWidgetVisible: IContextKey<boolean>; private _editorFrame?: HTMLElement; private _content?: HTMLElement; private readonly _webviewFocusTrackerDisposables = this._register(new DisposableStore()); private readonly _onFocusWindowHandler = this._register(new MutableDisposable()); private readonly _onDidFocusWebview = this._register(new Emitter<void>()); public get onDidFocus(): Event<any> { return this._onDidFocusWebview.event; } constructor( @ITelemetryService telemetryService: ITelemetryService, @IThemeService themeService: IThemeService, @IContextKeyService private readonly _contextKeyService: IContextKeyService, @IEditorService private readonly _editorService: IEditorService, @IWindowService private readonly _windowService: IWindowService, @IStorageService storageService: IStorageService ) { super(WebviewEditor.ID, telemetryService, themeService, storageService); this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(_contextKeyService); } public get isWebviewEditor() { return true; } protected createEditor(parent: HTMLElement): void { this._editorFrame = parent; this._content = document.createElement('div'); parent.appendChild(this._content); } public dispose(): void { if (this._content) { this._content.remove(); this._content = undefined; } super.dispose(); } public showFind() { this.withWebview(webview => { webview.showFind(); this._findWidgetVisible.set(true); }); } public hideFind() { this._findWidgetVisible.reset(); this.withWebview(webview => webview.hideFind()); } public find(previous: boolean) { this.withWebview(webview => { webview.runFindAction(previous); }); } public reload() { this.withWebview(webview => webview.reload()); } public layout(dimension: DOM.Dimension): void { if (this.input && this.input instanceof WebviewEditorInput) { this.synchronizeWebviewContainerDimensions(this.input.webview, dimension); this.input.webview.layout(); } } public focus(): void { super.focus(); if (!this._onFocusWindowHandler.value) { // Make sure we restore focus when switching back to a VS Code window this._onFocusWindowHandler.value = this._windowService.onDidChangeFocus(focused => { if (focused && this._editorService.activeControl === this) { this.focus(); } }); } this.withWebview(webview => webview.focus()); } public withWebview(f: (element: Webview) => void): void { if (this.input && this.input instanceof WebviewEditorInput) { f(this.input.webview); } } protected setEditorVisible(visible: boolean, group: IEditorGroup | undefined): void { const webview = this.input && (this.input as WebviewEditorInput).webview; if (webview) { if (visible) { webview.claim(this); } else { webview.release(this); } this.claimWebview(this.input as WebviewEditorInput); } super.setEditorVisible(visible, group); } public clearInput() { if (this.input && this.input instanceof WebviewEditorInput) { this.input.webview.release(this); } super.clearInput(); } public async setInput(input: WebviewEditorInput, options: EditorOptions | undefined, token: CancellationToken): Promise<void> { if (this.input && this.input instanceof WebviewEditorInput) { this.input.webview.release(this); } await super.setInput(input, options, token); await input.resolve(); if (token.isCancellationRequested) { return; } if (this.group) { input.updateGroup(this.group.id); } this.claimWebview(input); } private claimWebview(input: WebviewEditorInput): void { input.webview.claim(this); if (input.webview.options.enableFindWidget) { this._scopedContextKeyService.value = this._contextKeyService.createScoped(input.webview.container); this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(this._scopedContextKeyService.value); } if (this._content) { this._content.setAttribute('aria-flowto', input.webview.container.id); } this.synchronizeWebviewContainerDimensions(input.webview); this.trackFocus(input.webview); } private synchronizeWebviewContainerDimensions(webview: WebviewEditorOverlay, dimension?: DOM.Dimension) { const webviewContainer = webview.container; if (webviewContainer && webviewContainer.parentElement && this._editorFrame) { const frameRect = this._editorFrame.getBoundingClientRect(); const containerRect = webviewContainer.parentElement.getBoundingClientRect(); webviewContainer.style.position = 'absolute'; webviewContainer.style.top = `${frameRect.top - containerRect.top}px`; webviewContainer.style.left = `${frameRect.left - containerRect.left}px`; webviewContainer.style.width = `${dimension ? dimension.width : frameRect.width}px`; webviewContainer.style.height = `${dimension ? dimension.height : frameRect.height}px`; } } private trackFocus(webview: WebviewEditorOverlay): void { this._webviewFocusTrackerDisposables.clear(); // Track focus in webview content const webviewContentFocusTracker = DOM.trackFocus(webview.container); this._webviewFocusTrackerDisposables.add(webviewContentFocusTracker); this._webviewFocusTrackerDisposables.add(webviewContentFocusTracker.onDidFocus(() => this._onDidFocusWebview.fire())); // Track focus in webview element this._webviewFocusTrackerDisposables.add(webview.onDidFocus(() => this._onDidFocusWebview.fire())); } }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
protected createEditor(parent: HTMLElement): void { this._editorFrame = parent; this._content = document.createElement('div'); parent.appendChild(this._content); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public dispose(): void { if (this._content) { this._content.remove(); this._content = undefined; } super.dispose(); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public showFind() { this.withWebview(webview => { webview.showFind(); this._findWidgetVisible.set(true); }); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public hideFind() { this._findWidgetVisible.reset(); this.withWebview(webview => webview.hideFind()); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public find(previous: boolean) { this.withWebview(webview => { webview.runFindAction(previous); }); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public reload() { this.withWebview(webview => webview.reload()); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public layout(dimension: DOM.Dimension): void { if (this.input && this.input instanceof WebviewEditorInput) { this.synchronizeWebviewContainerDimensions(this.input.webview, dimension); this.input.webview.layout(); } }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public focus(): void { super.focus(); if (!this._onFocusWindowHandler.value) { // Make sure we restore focus when switching back to a VS Code window this._onFocusWindowHandler.value = this._windowService.onDidChangeFocus(focused => { if (focused && this._editorService.activeControl === this) { this.focus(); } }); } this.withWebview(webview => webview.focus()); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public withWebview(f: (element: Webview) => void): void { if (this.input && this.input instanceof WebviewEditorInput) { f(this.input.webview); } }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
protected setEditorVisible(visible: boolean, group: IEditorGroup | undefined): void { const webview = this.input && (this.input as WebviewEditorInput).webview; if (webview) { if (visible) { webview.claim(this); } else { webview.release(this); } this.claimWebview(this.input as WebviewEditorInput); } super.setEditorVisible(visible, group); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public clearInput() { if (this.input && this.input instanceof WebviewEditorInput) { this.input.webview.release(this); } super.clearInput(); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
public async setInput(input: WebviewEditorInput, options: EditorOptions | undefined, token: CancellationToken): Promise<void> { if (this.input && this.input instanceof WebviewEditorInput) { this.input.webview.release(this); } await super.setInput(input, options, token); await input.resolve(); if (token.isCancellationRequested) { return; } if (this.group) { input.updateGroup(this.group.id); } this.claimWebview(input); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
private claimWebview(input: WebviewEditorInput): void { input.webview.claim(this); if (input.webview.options.enableFindWidget) { this._scopedContextKeyService.value = this._contextKeyService.createScoped(input.webview.container); this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(this._scopedContextKeyService.value); } if (this._content) { this._content.setAttribute('aria-flowto', input.webview.container.id); } this.synchronizeWebviewContainerDimensions(input.webview); this.trackFocus(input.webview); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
private synchronizeWebviewContainerDimensions(webview: WebviewEditorOverlay, dimension?: DOM.Dimension) { const webviewContainer = webview.container; if (webviewContainer && webviewContainer.parentElement && this._editorFrame) { const frameRect = this._editorFrame.getBoundingClientRect(); const containerRect = webviewContainer.parentElement.getBoundingClientRect(); webviewContainer.style.position = 'absolute'; webviewContainer.style.top = `${frameRect.top - containerRect.top}px`; webviewContainer.style.left = `${frameRect.left - containerRect.left}px`; webviewContainer.style.width = `${dimension ? dimension.width : frameRect.width}px`; webviewContainer.style.height = `${dimension ? dimension.height : frameRect.height}px`; } }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
MethodDeclaration
private trackFocus(webview: WebviewEditorOverlay): void { this._webviewFocusTrackerDisposables.clear(); // Track focus in webview content const webviewContentFocusTracker = DOM.trackFocus(webview.container); this._webviewFocusTrackerDisposables.add(webviewContentFocusTracker); this._webviewFocusTrackerDisposables.add(webviewContentFocusTracker.onDidFocus(() => this._onDidFocusWebview.fire())); // Track focus in webview element this._webviewFocusTrackerDisposables.add(webview.onDidFocus(() => this._onDidFocusWebview.fire())); }
DJGHOSTMACHINE/vscode
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
TypeScript
ArrowFunction
() => { it('with missing remediation is not supported', async () => { const entity = generateEntityToFix( 'pip', 'requirements.txt', JSON.stringify({}), ); // @ts-ignore: for test purpose only delete entity.testResult.remediation; const res = await isSupported(entity); expect(res.supported).toBeFalsy(); }); it('with empty Pins is not supported', async () => { const entity = generateEntityToFix( 'poetry', 'pyproject.toml', JSON.stringify({}), ); // @ts-ignore: for test purpose only delete entity.testResult.remediation; // @ts-ignore: for test purpose only entity.testResult.remediation = { unresolved: [], upgrade: { 'django@1.6.1': { upgradeTo: 'django@2.0.1', vulns: ['vuln-id'], isTransitive: false, }, }, patch: {}, ignore: {}, pin: {}, }; const res = await isSupported(entity); expect(res.supported).toBeFalsy(); }); it('with -r directive in the manifest is supported', async () => { const entity = generateEntityToFix( 'pip', 'requirements.txt', '-r prod.txt\nDjango==1.6.1', ); const res = await isSupported(entity); expect(res.supported).toBeTruthy(); }); it('with -c directive in the manifest is supported', async () => { const entity = generateEntityToFix( 'pip', 'requirements.txt', '-c constraints.txt', ); const res = await isSupported(entity); expect(res.supported).toBeTruthy(); }); it('with -e directive in the manifest is supported', async () => { const entity = generateEntityToFix('pip', 'requirements.txt', '-e .'); entity.testResult.remediation!.pin = { 'django@1.6.1': { upgradeTo: 'django@2.0.1', vulns: [], isTransitive: false, }, }; const res = await isSupported(entity); expect(res.supported).toBeTruthy(); }); }
MaxMood96/snyk
packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts
TypeScript
ArrowFunction
async () => { const entity = generateEntityToFix( 'pip', 'requirements.txt', JSON.stringify({}), ); // @ts-ignore: for test purpose only delete entity.testResult.remediation; const res = await isSupported(entity); expect(res.supported).toBeFalsy(); }
MaxMood96/snyk
packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts
TypeScript
ArrowFunction
async () => { const entity = generateEntityToFix( 'poetry', 'pyproject.toml', JSON.stringify({}), ); // @ts-ignore: for test purpose only delete entity.testResult.remediation; // @ts-ignore: for test purpose only entity.testResult.remediation = { unresolved: [], upgrade: { 'django@1.6.1': { upgradeTo: 'django@2.0.1', vulns: ['vuln-id'], isTransitive: false, }, }, patch: {}, ignore: {}, pin: {}, }; const res = await isSupported(entity); expect(res.supported).toBeFalsy(); }
MaxMood96/snyk
packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts
TypeScript
ArrowFunction
async () => { const entity = generateEntityToFix( 'pip', 'requirements.txt', '-r prod.txt\nDjango==1.6.1', ); const res = await isSupported(entity); expect(res.supported).toBeTruthy(); }
MaxMood96/snyk
packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts
TypeScript
ArrowFunction
async () => { const entity = generateEntityToFix( 'pip', 'requirements.txt', '-c constraints.txt', ); const res = await isSupported(entity); expect(res.supported).toBeTruthy(); }
MaxMood96/snyk
packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts
TypeScript
ArrowFunction
async () => { const entity = generateEntityToFix('pip', 'requirements.txt', '-e .'); entity.testResult.remediation!.pin = { 'django@1.6.1': { upgradeTo: 'django@2.0.1', vulns: [], isTransitive: false, }, }; const res = await isSupported(entity); expect(res.supported).toBeTruthy(); }
MaxMood96/snyk
packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts
TypeScript
ArrowFunction
({ onDismiss }: Props) => ( <Modal onDismiss={onDismiss}> <div className
craigwongva/craigbfui
src/components/SessionExpired.tsx
TypeScript
InterfaceDeclaration
interface Props { onDismiss() }
craigwongva/craigbfui
src/components/SessionExpired.tsx
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function getProfile(identityId: string, profileId: string) { const sql = { text: ` SELECT id, name, email, is_default, created_at, updated_at FROM profile WHERE id = $2 AND identity_id = $1`, args: [ identityId, profileId, ], }; return await fetch(sql) as profileRows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function getDefaultProfile(identityId: string) { const sql = { text: ` SELECT id, name, email, is_default, created_at, updated_at FROM profile WHERE identity_id = $1 AND is_default = true LIMIT 1`, args: [ identityId, ], }; return await fetch(sql) as profileRows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function listProfile( identityId: string, limit: number, offset: number, ) { const sql = { text: ` SELECT id, name, email, is_default, created_at, updated_at FROM profile WHERE identity_id = $1 ORDER BY name LIMIT $2 OFFSET $3`, args: [ identityId, limit, offset, ], }; return await fetch(sql) as profileRows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function addProfile( identityId: string, name: string, email: string, isDefault = false, ) { const sql = { text: ` INSERT INTO profile (identity_id, name, email, is_default) VALUES ($1, $2, $3, $4) RETURNING id, created_at as at`, args: [ identityId, name, email, isDefault, ], }; return await fetch(sql) as idRows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function delProfile(identityId: string, profileId: string) { const sql = { text: ` DELETE FROM profile WHERE id = $2 AND identity_id = $1 AND is_default = false RETURNING id, now() as at`, args: [ identityId, profileId, ], }; return await fetch(sql) as idRows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function updateProfile( identityId: string, profileId: string, name: string, email: string, ) { const sql = { text: ` UPDATE profile SET name = $3, email = $4, updated_at = now() WHERE id = $2 AND identity_id = $1 RETURNING id, updated_at as at`, args: [ identityId, profileId, name, email, ], }; return await fetch(sql) as idRows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
FunctionDeclaration
// ----------------------------------------------------------------------------- export async function setDefaultProfile(identityId: string, profileId: string) { // note: don't add an is_default checking into WHERE. user should set a // profile as default although it's already default to solve the duplicated // defaults issue. Also UI should support this. const sql = { text: ` UPDATE profile SET is_default = true, updated_at = now() WHERE id = $2 AND identity_id = $1 RETURNING id, updated_at as at`, args: [ identityId, profileId, ], }; const rows = await fetch(sql) as idRows; // reset the old default if the set action is successful const sql1 = { text: ` UPDATE profile SET is_default = false, updated_at = now() WHERE identity_id = $1 AND id != $2 AND is_default = true`, args: [ identityId, profileId, ], }; if (rows[0] !== undefined) await query(sql1); return rows; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
InterfaceDeclaration
// ----------------------------------------------------------------------------- interface profileRows { [index: number]: { id: string; name: string; email: string; is_default: boolean; created_at: string; updated_at: string; }; }
emrahcom/galaxy
machines/eb-app-api/home/api/galaxy/lib/database/profile.ts
TypeScript
ClassDeclaration
@Pipe({ name: 'duration', }) export class DurationPipe implements PipeTransform { transform(value: any): string { if (value) { return dayjs.duration(value).humanize(); } return ''; } }
Aligon42/tp-dev-ops
src/main/webapp/app/shared/date/duration.pipe.ts
TypeScript
MethodDeclaration
transform(value: any): string { if (value) { return dayjs.duration(value).humanize(); } return ''; }
Aligon42/tp-dev-ops
src/main/webapp/app/shared/date/duration.pipe.ts
TypeScript
FunctionDeclaration
export function WaitTracker(): WaitTrackerClass { if (waitTrackerInstance === undefined) { waitTrackerInstance = new WaitTrackerClass(); } return waitTrackerInstance; }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
ArrowFunction
() => { this.getwaitingExecutions(); }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
ArrowFunction
(execution) => execution.id.toString()
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
ArrowFunction
() => { this.startExecution(executionId); }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
ArrowFunction
async () => { // Get the data to execute const fullExecutionDataFlatted = await Db.collections.Execution!.findOne(executionId); if (fullExecutionDataFlatted === undefined) { throw new Error(`The execution with the id "${executionId}" does not exist.`); } const fullExecutionData = ResponseHelper.unflattenExecutionData(fullExecutionDataFlatted); if (fullExecutionData.finished) { throw new Error('The execution did succeed and can so not be started again.'); } const data: IWorkflowExecutionDataProcess = { executionMode: fullExecutionData.mode, executionData: fullExecutionData.data, workflowData: fullExecutionData.workflowData, }; // Start the execution again const workflowRunner = new WorkflowRunner(); await workflowRunner.run(data, false, false, executionId); }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
ArrowFunction
(error) => { Logger.error( `There was a problem starting the waiting execution with id "${executionId}": "${error.message}"`, { executionId }, ); }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
ClassDeclaration
export class WaitTrackerClass { activeExecutionsInstance: ActiveExecutions.ActiveExecutions; private waitingExecutions: { [key: string]: { executionId: string; timer: NodeJS.Timeout; }; } = {}; mainTimer: NodeJS.Timeout; constructor() { this.activeExecutionsInstance = ActiveExecutions.getInstance(); // Poll every 60 seconds a list of upcoming executions this.mainTimer = setInterval(() => { this.getwaitingExecutions(); }, 60000); this.getwaitingExecutions(); } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types async getwaitingExecutions() { Logger.debug('Wait tracker querying database for waiting executions'); // Find all the executions which should be triggered in the next 70 seconds const findQuery: FindManyOptions<IExecutionFlattedDb> = { select: ['id', 'waitTill'], where: { waitTill: LessThanOrEqual(new Date(Date.now() + 70000)), }, order: { waitTill: 'ASC', }, }; const dbType = (await GenericHelpers.getConfigValue('database.type')) as DatabaseType; if (dbType === 'sqlite') { // This is needed because of issue in TypeORM <> SQLite: // https://github.com/typeorm/typeorm/issues/2286 (findQuery.where! as ObjectLiteral).waitTill = LessThanOrEqual( DateUtils.mixedDateToUtcDatetimeString(new Date(Date.now() + 70000)), ); } const executions = await Db.collections.Execution!.find(findQuery); if (executions.length === 0) { return; } const executionIds = executions.map((execution) => execution.id.toString()).join(', '); Logger.debug( `Wait tracker found ${executions.length} executions. Setting timer for IDs: ${executionIds}`, ); // Add timers for each waiting execution that they get started at the correct time // eslint-disable-next-line no-restricted-syntax for (const execution of executions) { const executionId = execution.id.toString(); if (this.waitingExecutions[executionId] === undefined) { const triggerTime = execution.waitTill!.getTime() - new Date().getTime(); this.waitingExecutions[executionId] = { executionId, timer: setTimeout(() => { this.startExecution(executionId); }, triggerTime), }; } } } async stopExecution(executionId: string): Promise<IExecutionsStopData> { if (this.waitingExecutions[executionId] !== undefined) { // The waiting execution was already sheduled to execute. // So stop timer and remove. clearTimeout(this.waitingExecutions[executionId].timer); delete this.waitingExecutions[executionId]; } // Also check in database const execution = await Db.collections.Execution!.findOne(executionId); if (execution === undefined || !execution.waitTill) { throw new Error(`The execution ID "${executionId}" could not be found.`); } const fullExecutionData = ResponseHelper.unflattenExecutionData(execution); // Set in execution in DB as failed and remove waitTill time const error = new WorkflowOperationError('Workflow-Execution has been canceled!'); fullExecutionData.data.resultData.error = { ...error, message: error.message, stack: error.stack, }; fullExecutionData.stoppedAt = new Date(); fullExecutionData.waitTill = undefined; await Db.collections.Execution!.update( executionId, ResponseHelper.flattenExecutionData(fullExecutionData), ); return { mode: fullExecutionData.mode, startedAt: new Date(fullExecutionData.startedAt), stoppedAt: fullExecutionData.stoppedAt ? new Date(fullExecutionData.stoppedAt) : undefined, finished: fullExecutionData.finished, }; } startExecution(executionId: string) { Logger.debug(`Wait tracker resuming execution ${executionId}`, { executionId }); delete this.waitingExecutions[executionId]; (async () => { // Get the data to execute const fullExecutionDataFlatted = await Db.collections.Execution!.findOne(executionId); if (fullExecutionDataFlatted === undefined) { throw new Error(`The execution with the id "${executionId}" does not exist.`); } const fullExecutionData = ResponseHelper.unflattenExecutionData(fullExecutionDataFlatted); if (fullExecutionData.finished) { throw new Error('The execution did succeed and can so not be started again.'); } const data: IWorkflowExecutionDataProcess = { executionMode: fullExecutionData.mode, executionData: fullExecutionData.data, workflowData: fullExecutionData.workflowData, }; // Start the execution again const workflowRunner = new WorkflowRunner(); await workflowRunner.run(data, false, false, executionId); })().catch((error) => { Logger.error( `There was a problem starting the waiting execution with id "${executionId}": "${error.message}"`, { executionId }, ); }); } }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
MethodDeclaration
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types async getwaitingExecutions() { Logger.debug('Wait tracker querying database for waiting executions'); // Find all the executions which should be triggered in the next 70 seconds const findQuery: FindManyOptions<IExecutionFlattedDb> = { select: ['id', 'waitTill'], where: { waitTill: LessThanOrEqual(new Date(Date.now() + 70000)), }, order: { waitTill: 'ASC', }, }; const dbType = (await GenericHelpers.getConfigValue('database.type')) as DatabaseType; if (dbType === 'sqlite') { // This is needed because of issue in TypeORM <> SQLite: // https://github.com/typeorm/typeorm/issues/2286 (findQuery.where! as ObjectLiteral).waitTill = LessThanOrEqual( DateUtils.mixedDateToUtcDatetimeString(new Date(Date.now() + 70000)), ); } const executions = await Db.collections.Execution!.find(findQuery); if (executions.length === 0) { return; } const executionIds = executions.map((execution) => execution.id.toString()).join(', '); Logger.debug( `Wait tracker found ${executions.length} executions. Setting timer for IDs: ${executionIds}`, ); // Add timers for each waiting execution that they get started at the correct time // eslint-disable-next-line no-restricted-syntax for (const execution of executions) { const executionId = execution.id.toString(); if (this.waitingExecutions[executionId] === undefined) { const triggerTime = execution.waitTill!.getTime() - new Date().getTime(); this.waitingExecutions[executionId] = { executionId, timer: setTimeout(() => { this.startExecution(executionId); }, triggerTime), }; } } }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
MethodDeclaration
async stopExecution(executionId: string): Promise<IExecutionsStopData> { if (this.waitingExecutions[executionId] !== undefined) { // The waiting execution was already sheduled to execute. // So stop timer and remove. clearTimeout(this.waitingExecutions[executionId].timer); delete this.waitingExecutions[executionId]; } // Also check in database const execution = await Db.collections.Execution!.findOne(executionId); if (execution === undefined || !execution.waitTill) { throw new Error(`The execution ID "${executionId}" could not be found.`); } const fullExecutionData = ResponseHelper.unflattenExecutionData(execution); // Set in execution in DB as failed and remove waitTill time const error = new WorkflowOperationError('Workflow-Execution has been canceled!'); fullExecutionData.data.resultData.error = { ...error, message: error.message, stack: error.stack, }; fullExecutionData.stoppedAt = new Date(); fullExecutionData.waitTill = undefined; await Db.collections.Execution!.update( executionId, ResponseHelper.flattenExecutionData(fullExecutionData), ); return { mode: fullExecutionData.mode, startedAt: new Date(fullExecutionData.startedAt), stoppedAt: fullExecutionData.stoppedAt ? new Date(fullExecutionData.stoppedAt) : undefined, finished: fullExecutionData.finished, }; }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
MethodDeclaration
startExecution(executionId: string) { Logger.debug(`Wait tracker resuming execution ${executionId}`, { executionId }); delete this.waitingExecutions[executionId]; (async () => { // Get the data to execute const fullExecutionDataFlatted = await Db.collections.Execution!.findOne(executionId); if (fullExecutionDataFlatted === undefined) { throw new Error(`The execution with the id "${executionId}" does not exist.`); } const fullExecutionData = ResponseHelper.unflattenExecutionData(fullExecutionDataFlatted); if (fullExecutionData.finished) { throw new Error('The execution did succeed and can so not be started again.'); } const data: IWorkflowExecutionDataProcess = { executionMode: fullExecutionData.mode, executionData: fullExecutionData.data, workflowData: fullExecutionData.workflowData, }; // Start the execution again const workflowRunner = new WorkflowRunner(); await workflowRunner.run(data, false, false, executionId); })().catch((error) => { Logger.error( `There was a problem starting the waiting execution with id "${executionId}": "${error.message}"`, { executionId }, ); }); }
5-stones/n8n
packages/cli/src/WaitTracker.ts
TypeScript
FunctionDeclaration
export default function UseBoolean(initial = false) { const [isOn, setIsOn] = useState(initial) const turnOn = () => setIsOn(true) const turnOff = () => setIsOn(false) return [isOn, turnOn, turnOff] as const }
navikt/testnorge
apps/dolly-frontend/src/main/js/src/utils/hooks/useBoolean.tsx
TypeScript
ArrowFunction
() => setIsOn(true)
navikt/testnorge
apps/dolly-frontend/src/main/js/src/utils/hooks/useBoolean.tsx
TypeScript
ArrowFunction
() => setIsOn(false)
navikt/testnorge
apps/dolly-frontend/src/main/js/src/utils/hooks/useBoolean.tsx
TypeScript
FunctionDeclaration
export default function MyProductVideo() { const {data} = useShopQuery({query: QUERY}); const firstMediaElement = data.products.edges[0].node.media.edges[0].node; if (firstMediaElement.mediaContentType === 'EXTERNAL_VIDEO') { return <ExternalVideo data={firstMediaElement} />; } }
M-Krilano/hydrogen
packages/hydrogen/src/components/ExternalVideo/examples/external-video.example.tsx
TypeScript
ArrowFunction
props => { const tablehead = props.columns.map(c => { return th(c, `${props.modelName}.${c}`); }); return ( <div className='row'> <div className='col-xs-12'> <Card> <div className='card-content'> <DynamicGuiComponent authorized={ props.authorizeAdd }> <Link to={ props.addNewRoute } className='btn btn-default pull-right'> <span className='glyphicon glyphicon-plus' aria-hidden='true'></span> { T.translate(props.modelName + '.addNew') } </Link> </DynamicGuiComponent> <InfoTable head={ tablehead } data={ props.response.data } onClick={ props.onSelect } /> <Pagination onClick={ props.fetchModels } response={ props.response }/> </div> </Card> </div> </div>
domien96/SolvasFleet
frontend/src/javascripts/components/app/Listing.tsx
TypeScript
ArrowFunction
c => { return th(c, `${props.modelName}.${c}`); }
domien96/SolvasFleet
frontend/src/javascripts/components/app/Listing.tsx
TypeScript
InterfaceDeclaration
interface Props { onSelect: any; addNewRoute: string; fetchModels: any; modelName: string; columns: string[]; response: ListResponse; authorizeAdd: boolean; }
domien96/SolvasFleet
frontend/src/javascripts/components/app/Listing.tsx
TypeScript