type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
adBreak =>
adBreak.type === AdBreakType.POSTROLL && !adBreak.hasBeenWatched | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
InterfaceDeclaration |
interface IFWAdBreak extends IAdBreak {
maxAds: number;
freewheelSlot?: any;
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public onControllerPlay(next: NextHook) {
if (!this.adsRequested) {
this.emit(Events.ADBREAK_STATE_PLAY);
this.adContext.submitRequest();
return;
}
if (this.currentAdBreak) {
this.emit(Events.ADBREAK_STATE_PLAY);
this.mediaElement.play();
return;
}
next();
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public onControllerPause(next: NextHook) {
if (this.currentAdBreak) {
this.emit(Events.ADBREAK_STATE_PAUSE);
this.mediaElement.pause();
return;
}
next();
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public onControllerSetVolume(next: NextHook, volume: number) {
this.mediaElement.volume = volume;
this.mediaElement.muted = volume === 0;
next();
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public onControllerSeekTo(next: NextHook) {
if (this.currentAdBreak) {
return;
}
next();
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public createMediaElement() {
this.mediaElement = document.createElement('video');
this.mediaElement.style.width = '100%';
this.mediaElement.style.height = '100%';
this.mediaElement.addEventListener('playing', () => {
this.emit(Events.ADBREAK_STATE_PLAYING);
});
this.mediaElement.addEventListener('timeupdate', () => {
if (this.currentAdBreak) {
this.emit(Events.ADBREAK_STATE_TIMEUPDATE, {
currentTime: this.currentAdBreak.freewheelSlot.getPlayheadTime(),
} as IAdBreakTimeUpdateEventData);
}
});
this.mediaElement.addEventListener('waiting', () => {
this.emit(Events.ADBREAK_STATE_BUFFERING);
});
this.adContainer.appendChild(this.mediaElement);
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onInstanceInitialized() {
this.adContainer = document.createElement('div');
this.adContainer.style.position = 'absolute';
this.adContainer.style.left = '0px';
this.adContainer.style.right = '0px';
this.adContainer.style.top = '0px';
this.adContainer.style.bottom = '0px';
this.adContainer.style.display = 'none';
this.adContainer.id = 'fwAdsContainer';
this.instance.adsContainer.appendChild(this.adContainer);
// Create ads specific media element.
this.createMediaElement();
const { AdManager }: { AdManager: any } = this.sdk;
this.adManager = new AdManager();
this.adContext = this.adManager.newContext();
this.adContext.addEventListener(
this.sdk.EVENT_REQUEST_COMPLETE,
this.onAdRequestComplete.bind(this),
);
this.adContext.addEventListener(
this.sdk.EVENT_SLOT_STARTED,
this.onSlotStarted.bind(this),
);
this.adContext.addEventListener(
this.sdk.EVENT_SLOT_ENDED,
this.onSlotEnded.bind(this),
);
this.adContext.addEventListener(
this.sdk.EVENT_AD_IMPRESSION,
this.onAdImpression.bind(this),
);
this.adContext.addEventListener(
this.sdk.EVENT_AD_IMPRESSION_END,
this.onAdImpressionEnd.bind(this),
);
const freewheel = this.instance.config.freewheel;
this.adManager.setNetwork(freewheel.network);
this.adManager.setServer(freewheel.server);
this.adContext.setVideoAsset(
freewheel.videoAsset,
freewheel.duration,
freewheel.network,
);
this.adContext.setSiteSection(freewheel.siteSection);
this.adContext.setProfile(freewheel.profile);
freewheel.cuepoints.forEach(cuepoint => {
if (cuepoint === AdBreakType.PREROLL) {
this.adContext.addTemporalSlot('preroll', this.sdk.ADUNIT_PREROLL, 0);
} else if (cuepoint === AdBreakType.POSTROLL) {
this.adContext.addTemporalSlot(
'postroll',
this.sdk.ADUNIT_POSTROLL,
freewheel.duration,
);
} else {
const time = cuepoint as number;
this.adContext.addTemporalSlot(
`midroll-${time}`,
this.sdk.ADUNIT_MIDROLL,
time,
);
}
});
this.adContext.registerVideoDisplayBase(this.adContainer.id);
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public onAdRequestComplete(event) {
this.adsRequested = true;
if (event.success) {
const slots = this.adContext.getTemporalSlots();
this.adBreaks = slots.map(
(slot, index) =>
({
sequenceIndex: index,
id: slot.getCustomId(),
type: slot.getAdUnit(),
startsAt: slot.getTimePosition(),
duration: slot.getTotalDuration(),
hasBeenWatched: false,
maxAds: slot.getAdCount(),
freewheelSlot: slot,
} as IFWAdBreak),
);
}
this.emit(Events.ADBREAKS, {
adBreaks: this.adBreaks,
} as IAdBreaksEventData);
const preroll: IFWAdBreak = find(this.adBreaks, {
type: AdBreakType.PREROLL,
});
if (preroll && !this.shouldSkipPreroll()) {
this.playAdBreak(preroll);
} else {
this.instance.media.play();
}
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
public adClick() {
if (!this.currentAd) {
return;
}
this.currentAd.freewheelAdInstance
.getRendererController()
.processEvent({ name: this.sdk.EVENT_AD_CLICK });
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onSlotStarted(event) {
const slot: any = event.slot;
const adBreak = this.slotToAdBreak(slot);
this.currentAdBreak = adBreak;
this.emit(Events.ADBREAK_STARTED, {
adBreak,
} as IAdBreakEventData);
this.instance.media.pause();
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onSlotEnded(event) {
const slot: any = event.slot;
const adBreak = this.slotToAdBreak(slot);
adBreak.hasBeenWatched = true;
this.currentAdBreak = null;
this.emit(Events.ADBREAK_ENDED, {
adBreak,
} as IAdBreakEventData);
if (adBreak.type !== AdBreakType.POSTROLL) {
this.instance.media.play();
}
this.adContainer.style.display = 'none';
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onAdImpression(event) {
this.adSequenceIndex = 0;
this.currentAd = {
sequenceIndex: this.adSequenceIndex,
freewheelAdInstance: event.adInstance,
};
this.emit(Events.AD_STARTED, {
adBreak: this.currentAdBreak,
ad: this.currentAd,
} as IAdEventData);
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onAdImpressionEnd(event) {
const ad = this.currentAd;
this.currentAd = null;
this.emit(Events.AD_ENDED, {
adBreak: this.currentAdBreak,
ad,
} as IAdEventData);
this.adSequenceIndex += 1;
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onPlayerTimeUpdate({ currentTime }: ITimeUpdateEventData) {
const midroll: IFWAdBreak = find(
this.adBreaks,
adBreak =>
adBreak.type === AdBreakType.MIDROLL &&
adBreak.startsAt <= currentTime &&
adBreak.startsAt > this.prevCurrentTime &&
!adBreak.hasBeenWatched,
);
if (midroll) {
this.playAdBreak(midroll);
}
this.prevCurrentTime = currentTime;
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private onPlayerEnded() {
const postroll: IFWAdBreak = find(
this.adBreaks,
adBreak =>
adBreak.type === AdBreakType.POSTROLL && !adBreak.hasBeenWatched,
);
if (postroll) {
this.playAdBreak(postroll);
}
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private slotToAdBreak(slot: any): IFWAdBreak {
return find<IFWAdBreak>(this.adBreaks, {
id: slot.getCustomId(),
});
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private playAdBreak(adBreak: IFWAdBreak) {
try {
adBreak.freewheelSlot.play();
} catch (error) {
this.instance.media.play();
}
this.adContainer.style.display = 'block';
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
MethodDeclaration |
private shouldSkipPreroll() {
return this.instance.config.startPosition > 0;
} | JamoDevNich/indigo-player | src/extensions/FreeWheelExtension/FreeWheelExtension.ts | TypeScript |
ArrowFunction |
params => {
if (params['term']) {
this.help = params['term'];
//automat ponizsze zakomentowac
this.doSearch(this.help);
}
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
ArrowFunction |
term => this.onSearch(term) | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
ArrowFunction |
() => this.loading = true | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
ArrowFunction |
term => this.itunes.search2(term) | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
ArrowFunction |
() => this.loading = false | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
ClassDeclaration | // https://codecraft.tv/courses/angular/http/http-with-promises/
@Component({
selector: 'app-tune',
templateUrl: './app-tune.component.html',
styleUrls: ['./app-tune.component.scss'],
})
export class AppTuneComponent implements OnInit {
private loading = false;
// private results: SearchItem[];
private results: Observable<SearchItem[]>;
private searchField: FormControl;
private help = '';
constructor(private itunes: SearchService, private router: Router, private route: ActivatedRoute, private cd: ChangeDetectorRef) {
this.route.params.subscribe( params => {
if (params['term']) {
this.help = params['term'];
//automat ponizsze zakomentowac
this.doSearch(this.help);
}
});
}
ngOnInit() {
this.searchField = new FormControl();
this.searchField.setValue(this.help);
//automat
// this.search();
}
ngOnDestroy(){
this.itunes.clear();
}
search() {
this.cd.reattach();
this.results = this.searchField.valueChanges
.debounceTime(400)
.distinctUntilChanged()
.do(term => this.onSearch(term))
.do( () => this.loading = true)
.switchMap( term => this.itunes.search2(term))
.do( () => this.loading = false );
}
doSearch(term: string) {
this.loading = true;
this.itunes.search(term).then(() => this.loading = false);
}
doSearch2(term: string) {
this.itunes.search2(term);
}
goHome() {
this.router.navigate(['']);
}
goTune() {
this.router.navigate(['tune']);
}
onSearch(term: string) {
this.router.navigate(['tune', {term: term}]);
}
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
ngOnInit() {
this.searchField = new FormControl();
this.searchField.setValue(this.help);
//automat
// this.search();
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
ngOnDestroy(){
this.itunes.clear();
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
search() {
this.cd.reattach();
this.results = this.searchField.valueChanges
.debounceTime(400)
.distinctUntilChanged()
.do(term => this.onSearch(term))
.do( () => this.loading = true)
.switchMap( term => this.itunes.search2(term))
.do( () => this.loading = false );
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
doSearch(term: string) {
this.loading = true;
this.itunes.search(term).then(() => this.loading = false);
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
doSearch2(term: string) {
this.itunes.search2(term);
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
goHome() {
this.router.navigate(['']);
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
goTune() {
this.router.navigate(['tune']);
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
MethodDeclaration |
onSearch(term: string) {
this.router.navigate(['tune', {term: term}]);
} | psmuga/AngularContainer | src/app/components/app-tune/app-tune.component.ts | TypeScript |
ArrowFunction |
props => (
<svg
width="24" | Simspace/monorail | src/visualComponents/icon/custom/EssayDefault.tsx | TypeScript |
FunctionDeclaration |
function getURI(message: Message) {
var url = getURL(message);
var uri = url.split('https://open.spotify.com/track/')[1].split('?')[0];
return `spotify:track:${uri}`;
} | hemant-hari/BoToxic | src/listeners/spotify/enqueue.ts | TypeScript |
FunctionDeclaration |
function getURL(message: Message) {
var spotifyRegex = /https?:\/\/open\.spotify\.com\/track\/\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
return message.content.match(spotifyRegex)[0];
} | hemant-hari/BoToxic | src/listeners/spotify/enqueue.ts | TypeScript |
FunctionDeclaration |
async function enqueueTrack(reaction: MessageReaction, api: SpotifyWebApi) {
var accessToken = api.getAccessToken();
return (
WebApiRequest.builder(accessToken)
.withPath('/v1/me/player/queue')
.withHeaders({ 'Content-Type': 'application/json' })
.withQueryParameters({
uri: getURI(reaction.message)
})
.build()
.execute(HttpManager.post, null)
);
} | hemant-hari/BoToxic | src/listeners/spotify/enqueue.ts | TypeScript |
ArrowFunction |
async () => enqueueTrack(reaction, api) | hemant-hari/BoToxic | src/listeners/spotify/enqueue.ts | TypeScript |
ArrowFunction |
(appendToObject: JQuery) => {
var nSeries: number = (!this.xData ? 0 : this.xData.length);
var s: StyleChart = this.getStyle();
var margin: Margin = Style.getMargins(s);
// Set the ranges
var xScale: d3.scale.Linear<number,number> = d3.scale.linear().range([0, margin.widthExMargins]);
var yScale: d3.scale.Linear<number,number> = d3.scale.linear().range([margin.heightExMargins, 0]);
// Define the axes
var xAxis = d3.svg.axis().scale(xScale)
.orient("bottom").ticks(5);
if(this.gridVerticalStrokeWidth != null && this.gridVerticalStrokeWidth > 0){
xAxis.innerTickSize(-margin.heightExMargins); //used as grid line
}
var yAxis = d3.svg.axis().scale(yScale)
.orient("left").ticks(5);
if(this.gridHorizontalStrokeWidth != null && this.gridHorizontalStrokeWidth > 0){
yAxis.innerTickSize(-margin.widthExMargins); //used as grid line
}
if(this.suppressAxisHorizontal === true) xAxis.tickValues([]);
if(this.suppressAxisVertical === true) yAxis.tickValues([]);
var data: any[] = [];
for(var i=0; i<this.xData.length; i++ ){
var obj = {};
for( var j=0; j<this.labels.length; j++ ){
obj[this.labels[j]] = this.yData[j][i];
obj['xValue'] = this.xData[i];
}
data.push(obj);
}
var area = d3.svg.area()
.x(function(d: any) { return xScale(d.xValue); })
.y0(function(d: any) { return yScale(d.y0); })
.y1(function(d: any) { return yScale(d.y0 + d.y); });
var stack = d3.layout.stack()
.values(function(d: any) { return d.values; });
var svg = d3.select("#" + appendToObject.attr("id")).append("svg")
.attr("width", margin.widthExMargins + margin.left + margin.right)
.attr("height", margin.heightExMargins + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var color: any = d3.scale.category20();
color.domain(d3.keys(data[0]).filter(function (key) {
return key !== "xValue";
}));
var browsers = stack(color.domain().map(function (name) {
return {
name: name,
values: data.map(function (d) {
return {xValue: d.xValue, y: d[name] * 1};
})
};
}));
// Find the value of the day with highest total value
var maxX = d3.max(data, function (d) {
var vals = d3.keys(d).map(function (key) {
return key !== "xValue" ? d[key] : 0
});
return d3.sum(vals);
});
// Set domains for axes
xScale.domain(d3.extent(data, function (d) {
return d.xValue;
}));
yScale.domain([0, maxX]);
var browser = svg.selectAll(".browser")
.data(browsers)
.enter().append("g")
.attr("class", "browser");
var tempLabels = this.labels;
var defaultColor: Ordinal<string,string> = d3.scale.category20();
browser.append("path")
.attr("class", "area")
.attr("data-legend",function(d: any) { return d.name})
.attr("d", function (d: any) {
return area(d.values);
})
.style("fill", function(d: any){
if(s && s.getSeriesColor(tempLabels.indexOf(d.name))){
return s.getSeriesColor(tempLabels.indexOf(d.name));
} else{
return defaultColor(String(tempLabels.indexOf(d.name)))
}
})
.style({"stroke-width": "0px"});
//Add the x axis:
var xAxisNode = svg.append("g")
.attr("class", "x axis")
.style("stroke","#000")
.style("stroke-width", (s != null && s.getAxisStrokeWidth() != null ? s.getAxisStrokeWidth() : ChartConstants.DEFAULT_AXIS_STROKE_WIDTH))
.style("fill","none")
.attr("transform", "translate(0," + margin.heightExMargins + ")")
.call(xAxis);
xAxisNode.selectAll('text').style("stroke-width",0).style("fill","#000000");
//Add the y axis
var yAxisNode = svg.append("g")
.attr("class", "y axis")
.style("stroke","#000")
.style("stroke-width", (s != null && s.getAxisStrokeWidth() != null ? s.getAxisStrokeWidth() : ChartConstants.DEFAULT_AXIS_STROKE_WIDTH))
.style("fill","none")
.call(yAxis);
yAxisNode.selectAll('text').style("stroke-width",0).style("fill","#000000");
//Add title (if present)
if (this.title) {
var titleStyle: StyleText;
if(this.style) titleStyle = this.style.getTitleStyle();
Chart.appendTitle(svg, this.title, margin, titleStyle);
}
//Append the legend
var legend: any = svg.append("g")
.attr("class","legend")
.attr("transform","translate(40,40)")
.style("font-size","12px")
.call(Legend.legendFn);
} | A-Hilaly/deeplearning4j | deeplearning4j-ui-parent/deeplearning4j-ui-components/src/main/typescript/org/deeplearning4j/ui/components/chart/ChartStackedArea.ts | TypeScript |
ClassDeclaration | /*
*
* * Copyright 2016 Skymind,Inc.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
/// <reference path="../../api/Component.ts" />
/// <reference path="../../api/Renderable.ts" />
/// <reference path="../../typedefs/d3.d.ts" />
/// <reference path="../../util/TSUtils.ts" />
/// <reference path="Chart.ts" />
/// <reference path="Legend.ts" />
class ChartStackedArea extends Chart implements Renderable {
private xData: number[];
private yData: number[][];
private labels: string[];
constructor(jsonStr: string){
super(ComponentType.ChartStackedArea, jsonStr);
var json = JSON.parse(jsonStr);
if(!json["componentType"]) json = json[ComponentType[ComponentType.ChartStackedArea]];
this.xData = json['x'];
this.yData = json['y'];
this.labels = json['labels'];
}
render = (appendToObject: JQuery) => {
var nSeries: number = (!this.xData ? 0 : this.xData.length);
var s: StyleChart = this.getStyle();
var margin: Margin = Style.getMargins(s);
// Set the ranges
var xScale: d3.scale.Linear<number,number> = d3.scale.linear().range([0, margin.widthExMargins]);
var yScale: d3.scale.Linear<number,number> = d3.scale.linear().range([margin.heightExMargins, 0]);
// Define the axes
var xAxis = d3.svg.axis().scale(xScale)
.orient("bottom").ticks(5);
if(this.gridVerticalStrokeWidth != null && this.gridVerticalStrokeWidth > 0){
xAxis.innerTickSize(-margin.heightExMargins); //used as grid line
}
var yAxis = d3.svg.axis().scale(yScale)
.orient("left").ticks(5);
if(this.gridHorizontalStrokeWidth != null && this.gridHorizontalStrokeWidth > 0){
yAxis.innerTickSize(-margin.widthExMargins); //used as grid line
}
if(this.suppressAxisHorizontal === true) xAxis.tickValues([]);
if(this.suppressAxisVertical === true) yAxis.tickValues([]);
var data: any[] = [];
for(var i=0; i<this.xData.length; i++ ){
var obj = {};
for( var j=0; j<this.labels.length; j++ ){
obj[this.labels[j]] = this.yData[j][i];
obj['xValue'] = this.xData[i];
}
data.push(obj);
}
var area = d3.svg.area()
.x(function(d: any) { return xScale(d.xValue); })
.y0(function(d: any) { return yScale(d.y0); })
.y1(function(d: any) { return yScale(d.y0 + d.y); });
var stack = d3.layout.stack()
.values(function(d: any) { return d.values; });
var svg = d3.select("#" + appendToObject.attr("id")).append("svg")
.attr("width", margin.widthExMargins + margin.left + margin.right)
.attr("height", margin.heightExMargins + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var color: any = d3.scale.category20();
color.domain(d3.keys(data[0]).filter(function (key) {
return key !== "xValue";
}));
var browsers = stack(color.domain().map(function (name) {
return {
name: name,
values: data.map(function (d) {
return {xValue: d.xValue, y: d[name] * 1};
})
};
}));
// Find the value of the day with highest total value
var maxX = d3.max(data, function (d) {
var vals = d3.keys(d).map(function (key) {
return key !== "xValue" ? d[key] : 0
});
return d3.sum(vals);
});
// Set domains for axes
xScale.domain(d3.extent(data, function (d) {
return d.xValue;
}));
yScale.domain([0, maxX]);
var browser = svg.selectAll(".browser")
.data(browsers)
.enter().append("g")
.attr("class", "browser");
var tempLabels = this.labels;
var defaultColor: Ordinal<string,string> = d3.scale.category20();
browser.append("path")
.attr("class", "area")
.attr("data-legend",function(d: any) { return d.name})
.attr("d", function (d: any) {
return area(d.values);
})
.style("fill", function(d: any){
if(s && s.getSeriesColor(tempLabels.indexOf(d.name))){
return s.getSeriesColor(tempLabels.indexOf(d.name));
} else{
return defaultColor(String(tempLabels.indexOf(d.name)))
}
})
.style({"stroke-width": "0px"});
//Add the x axis:
var xAxisNode = svg.append("g")
.attr("class", "x axis")
.style("stroke","#000")
.style("stroke-width", (s != null && s.getAxisStrokeWidth() != null ? s.getAxisStrokeWidth() : ChartConstants.DEFAULT_AXIS_STROKE_WIDTH))
.style("fill","none")
.attr("transform", "translate(0," + margin.heightExMargins + ")")
.call(xAxis);
xAxisNode.selectAll('text').style("stroke-width",0).style("fill","#000000");
//Add the y axis
var yAxisNode = svg.append("g")
.attr("class", "y axis")
.style("stroke","#000")
.style("stroke-width", (s != null && s.getAxisStrokeWidth() != null ? s.getAxisStrokeWidth() : ChartConstants.DEFAULT_AXIS_STROKE_WIDTH))
.style("fill","none")
.call(yAxis);
yAxisNode.selectAll('text').style("stroke-width",0).style("fill","#000000");
//Add title (if present)
if (this.title) {
var titleStyle: StyleText;
if(this.style) titleStyle = this.style.getTitleStyle();
Chart.appendTitle(svg, this.title, margin, titleStyle);
}
//Append the legend
var legend: any = svg.append("g")
.attr("class","legend")
.attr("transform","translate(40,40)")
.style("font-size","12px")
.call(Legend.legendFn);
}
} | A-Hilaly/deeplearning4j | deeplearning4j-ui-parent/deeplearning4j-ui-components/src/main/typescript/org/deeplearning4j/ui/components/chart/ChartStackedArea.ts | TypeScript |
ArrowFunction |
async () => {
const { authority } = await this.remoteAuthorityResolverService.resolveAuthority(this._initDataProvider.remoteAuthority);
return { host: authority.host, port: authority.port, connectionToken: authority.connectionToken };
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
(resolverResult) => {
const startParams: IRemoteExtensionHostStartParams = {
language: platform.language,
debugId: this._environmentService.debugExtensionHost.debugId,
break: this._environmentService.debugExtensionHost.break,
port: this._environmentService.debugExtensionHost.port,
env: resolverResult.options && resolverResult.options.extensionHostEnv
};
const extDevLocs = this._environmentService.extensionDevelopmentLocationURI;
let debugOk = true;
if (extDevLocs && extDevLocs.length > 0) {
// TODO@AW: handles only first path in array
if (extDevLocs[0].scheme === Schemas.file) {
debugOk = false;
}
}
if (!debugOk) {
startParams.break = false;
}
return connectRemoteAgentExtensionHost(options, startParams).then(result => {
let { protocol, debugPort } = result;
const isExtensionDevelopmentDebug = typeof debugPort === 'number';
if (debugOk && this._environmentService.isExtensionDevelopment && this._environmentService.debugExtensionHost.debugId && debugPort) {
this._extensionHostDebugService.attachSession(this._environmentService.debugExtensionHost.debugId, debugPort, this._initDataProvider.remoteAuthority);
}
protocol.onDidDispose(() => {
this._onExtHostConnectionLost();
});
protocol.onSocketClose(() => {
if (this._isExtensionDevHost) {
this._onExtHostConnectionLost();
}
});
// 1) wait for the incoming `ready` event and send the initialization data.
// 2) wait for the incoming `initialized` event.
return new Promise<IMessagePassingProtocol>((resolve, reject) => {
let handle = setTimeout(() => {
reject('timeout');
}, 60 * 1000);
let logFile: URI;
const disposable = protocol.onMessage(msg => {
if (isMessageOfType(msg, MessageType.Ready)) {
// 1) Extension Host is ready to receive messages, initialize it
this._createExtHostInitData(isExtensionDevelopmentDebug).then(data => {
logFile = data.logFile;
protocol.send(VSBuffer.fromString(JSON.stringify(data)));
});
return;
}
if (isMessageOfType(msg, MessageType.Initialized)) {
// 2) Extension Host is initialized
clearTimeout(handle);
// stop listening for messages here
disposable.dispose();
// Register log channel for remote exthost log
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).registerChannel({ id: 'remoteExtHostLog', label: localize('remote extension host Log', "Remote Extension Host"), file: logFile, log: true });
// release this promise
this._protocol = protocol;
resolve(protocol);
return;
}
console.error(`received unexpected message during handshake phase from the extension host: `, msg);
});
});
});
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
result => {
let { protocol, debugPort } = result;
const isExtensionDevelopmentDebug = typeof debugPort === 'number';
if (debugOk && this._environmentService.isExtensionDevelopment && this._environmentService.debugExtensionHost.debugId && debugPort) {
this._extensionHostDebugService.attachSession(this._environmentService.debugExtensionHost.debugId, debugPort, this._initDataProvider.remoteAuthority);
}
protocol.onDidDispose(() => {
this._onExtHostConnectionLost();
});
protocol.onSocketClose(() => {
if (this._isExtensionDevHost) {
this._onExtHostConnectionLost();
}
});
// 1) wait for the incoming `ready` event and send the initialization data.
// 2) wait for the incoming `initialized` event.
return new Promise<IMessagePassingProtocol>((resolve, reject) => {
let handle = setTimeout(() => {
reject('timeout');
}, 60 * 1000);
let logFile: URI;
const disposable = protocol.onMessage(msg => {
if (isMessageOfType(msg, MessageType.Ready)) {
// 1) Extension Host is ready to receive messages, initialize it
this._createExtHostInitData(isExtensionDevelopmentDebug).then(data => {
logFile = data.logFile;
protocol.send(VSBuffer.fromString(JSON.stringify(data)));
});
return;
}
if (isMessageOfType(msg, MessageType.Initialized)) {
// 2) Extension Host is initialized
clearTimeout(handle);
// stop listening for messages here
disposable.dispose();
// Register log channel for remote exthost log
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).registerChannel({ id: 'remoteExtHostLog', label: localize('remote extension host Log', "Remote Extension Host"), file: logFile, log: true });
// release this promise
this._protocol = protocol;
resolve(protocol);
return;
}
console.error(`received unexpected message during handshake phase from the extension host: `, msg);
});
});
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
() => {
this._onExtHostConnectionLost();
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
() => {
if (this._isExtensionDevHost) {
this._onExtHostConnectionLost();
}
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
let handle = setTimeout(() => {
reject('timeout');
}, 60 * 1000);
let logFile: URI;
const disposable = protocol.onMessage(msg => {
if (isMessageOfType(msg, MessageType.Ready)) {
// 1) Extension Host is ready to receive messages, initialize it
this._createExtHostInitData(isExtensionDevelopmentDebug).then(data => {
logFile = data.logFile;
protocol.send(VSBuffer.fromString(JSON.stringify(data)));
});
return;
}
if (isMessageOfType(msg, MessageType.Initialized)) {
// 2) Extension Host is initialized
clearTimeout(handle);
// stop listening for messages here
disposable.dispose();
// Register log channel for remote exthost log
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).registerChannel({ id: 'remoteExtHostLog', label: localize('remote extension host Log', "Remote Extension Host"), file: logFile, log: true });
// release this promise
this._protocol = protocol;
resolve(protocol);
return;
}
console.error(`received unexpected message during handshake phase from the extension host: `, msg);
});
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
() => {
reject('timeout');
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
msg => {
if (isMessageOfType(msg, MessageType.Ready)) {
// 1) Extension Host is ready to receive messages, initialize it
this._createExtHostInitData(isExtensionDevelopmentDebug).then(data => {
logFile = data.logFile;
protocol.send(VSBuffer.fromString(JSON.stringify(data)));
});
return;
}
if (isMessageOfType(msg, MessageType.Initialized)) {
// 2) Extension Host is initialized
clearTimeout(handle);
// stop listening for messages here
disposable.dispose();
// Register log channel for remote exthost log
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).registerChannel({ id: 'remoteExtHostLog', label: localize('remote extension host Log', "Remote Extension Host"), file: logFile, log: true });
// release this promise
this._protocol = protocol;
resolve(protocol);
return;
}
console.error(`received unexpected message during handshake phase from the extension host: `, msg);
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
data => {
logFile = data.logFile;
protocol.send(VSBuffer.fromString(JSON.stringify(data)));
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
(extension) => remoteExtensions.add(ExtensionIdentifier.toKey(extension.identifier.value)) | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
extension => !extension.main && !extension.browser | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
extension => extension.identifier | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
extension => !remoteExtensions.has(ExtensionIdentifier.toKey(extension.identifier.value)) | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
extension => (extension.main || extension.browser) && extension.api === 'none' | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
InterfaceDeclaration |
export interface IRemoteExtensionHostInitData {
readonly connectionData: IRemoteConnectionData | null;
readonly pid: number;
readonly appRoot: URI;
readonly extensionHostLogsPath: URI;
readonly globalStorageHome: URI;
readonly workspaceStorageHome: URI;
readonly extensions: IExtensionDescription[];
readonly allExtensions: IExtensionDescription[];
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
InterfaceDeclaration |
export interface IRemoteExtensionHostDataProvider {
readonly remoteAuthority: string;
getInitData(): Promise<IRemoteExtensionHostInitData>;
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
MethodDeclaration |
public start(): Promise<IMessagePassingProtocol> {
const options: IConnectionOptions = {
commit: this._productService.commit,
socketFactory: this._socketFactory,
addressProvider: {
getAddress: async () => {
const { authority } = await this.remoteAuthorityResolverService.resolveAuthority(this._initDataProvider.remoteAuthority);
return { host: authority.host, port: authority.port, connectionToken: authority.connectionToken };
}
},
signService: this._signService,
logService: this._logService,
ipcLogger: null
};
return this.remoteAuthorityResolverService.resolveAuthority(this._initDataProvider.remoteAuthority).then((resolverResult) => {
const startParams: IRemoteExtensionHostStartParams = {
language: platform.language,
debugId: this._environmentService.debugExtensionHost.debugId,
break: this._environmentService.debugExtensionHost.break,
port: this._environmentService.debugExtensionHost.port,
env: resolverResult.options && resolverResult.options.extensionHostEnv
};
const extDevLocs = this._environmentService.extensionDevelopmentLocationURI;
let debugOk = true;
if (extDevLocs && extDevLocs.length > 0) {
// TODO@AW: handles only first path in array
if (extDevLocs[0].scheme === Schemas.file) {
debugOk = false;
}
}
if (!debugOk) {
startParams.break = false;
}
return connectRemoteAgentExtensionHost(options, startParams).then(result => {
let { protocol, debugPort } = result;
const isExtensionDevelopmentDebug = typeof debugPort === 'number';
if (debugOk && this._environmentService.isExtensionDevelopment && this._environmentService.debugExtensionHost.debugId && debugPort) {
this._extensionHostDebugService.attachSession(this._environmentService.debugExtensionHost.debugId, debugPort, this._initDataProvider.remoteAuthority);
}
protocol.onDidDispose(() => {
this._onExtHostConnectionLost();
});
protocol.onSocketClose(() => {
if (this._isExtensionDevHost) {
this._onExtHostConnectionLost();
}
});
// 1) wait for the incoming `ready` event and send the initialization data.
// 2) wait for the incoming `initialized` event.
return new Promise<IMessagePassingProtocol>((resolve, reject) => {
let handle = setTimeout(() => {
reject('timeout');
}, 60 * 1000);
let logFile: URI;
const disposable = protocol.onMessage(msg => {
if (isMessageOfType(msg, MessageType.Ready)) {
// 1) Extension Host is ready to receive messages, initialize it
this._createExtHostInitData(isExtensionDevelopmentDebug).then(data => {
logFile = data.logFile;
protocol.send(VSBuffer.fromString(JSON.stringify(data)));
});
return;
}
if (isMessageOfType(msg, MessageType.Initialized)) {
// 2) Extension Host is initialized
clearTimeout(handle);
// stop listening for messages here
disposable.dispose();
// Register log channel for remote exthost log
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).registerChannel({ id: 'remoteExtHostLog', label: localize('remote extension host Log', "Remote Extension Host"), file: logFile, log: true });
// release this promise
this._protocol = protocol;
resolve(protocol);
return;
}
console.error(`received unexpected message during handshake phase from the extension host: `, msg);
});
});
});
});
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
MethodDeclaration |
private _onExtHostConnectionLost(): void {
if (this._hasLostConnection) {
// avoid re-entering this method
return;
}
this._hasLostConnection = true;
if (this._isExtensionDevHost && this._environmentService.debugExtensionHost.debugId) {
this._extensionHostDebugService.close(this._environmentService.debugExtensionHost.debugId);
}
if (this._terminating) {
// Expected termination path (we asked the process to terminate)
return;
}
this._onExit.fire([0, null]);
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
MethodDeclaration |
private async _createExtHostInitData(isExtensionDevelopmentDebug: boolean): Promise<IInitData> {
const [telemetryInfo, remoteInitData] = await Promise.all([this._telemetryService.getTelemetryInfo(), this._initDataProvider.getInitData()]);
// Collect all identifiers for extension ids which can be considered "resolved"
const remoteExtensions = new Set<string>();
remoteInitData.extensions.forEach((extension) => remoteExtensions.add(ExtensionIdentifier.toKey(extension.identifier.value)));
const resolvedExtensions = remoteInitData.allExtensions.filter(extension => !extension.main && !extension.browser).map(extension => extension.identifier);
const hostExtensions = (
remoteInitData.allExtensions
.filter(extension => !remoteExtensions.has(ExtensionIdentifier.toKey(extension.identifier.value)))
.filter(extension => (extension.main || extension.browser) && extension.api === 'none').map(extension => extension.identifier)
);
const workspace = this._contextService.getWorkspace();
return {
commit: this._productService.commit,
version: this._productService.version,
parentPid: remoteInitData.pid,
environment: {
isExtensionDevelopmentDebug,
appRoot: remoteInitData.appRoot,
appName: this._productService.nameLong,
embedderIdentifier: this._productService.embedderIdentifier || 'desktop',
appUriScheme: this._productService.urlProtocol,
appLanguage: platform.language,
extensionDevelopmentLocationURI: this._environmentService.extensionDevelopmentLocationURI,
extensionTestsLocationURI: this._environmentService.extensionTestsLocationURI,
globalStorageHome: remoteInitData.globalStorageHome,
workspaceStorageHome: remoteInitData.workspaceStorageHome
},
workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : {
configuration: workspace.configuration,
id: workspace.id,
name: this._labelService.getWorkspaceLabel(workspace)
},
remote: {
isRemote: true,
authority: this._initDataProvider.remoteAuthority,
connectionData: remoteInitData.connectionData
},
resolvedExtensions: resolvedExtensions,
hostExtensions: hostExtensions,
extensions: remoteInitData.extensions,
telemetryInfo,
logLevel: this._logService.getLevel(),
logsLocation: remoteInitData.extensionHostLogsPath,
logFile: joinPath(remoteInitData.extensionHostLogsPath, `${ExtensionHostLogFileName}.log`),
autoStart: true,
uiKind: platform.isWeb ? UIKind.Web : UIKind.Desktop
};
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
MethodDeclaration |
getInspectPort(): number | undefined {
return undefined;
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
MethodDeclaration |
enableInspectPort(): Promise<boolean> {
return Promise.resolve(false);
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
MethodDeclaration |
override dispose(): void {
super.dispose();
this._terminating = true;
if (this._protocol) {
// Send the extension host a request to terminate itself
// (graceful termination)
const socket = this._protocol.getSocket();
this._protocol.send(createMessageOfType(MessageType.Terminate));
this._protocol.sendDisconnect();
this._protocol.dispose();
socket.end();
this._protocol = null;
}
} | 02818bea-9a08-4b24-a53f-8d4ad597fe20/vscode | src/vs/workbench/services/extensions/common/remoteExtensionHost.ts | TypeScript |
ArrowFunction |
() => {
it("should generate enums", () => {
const code = new main.Code({
lines: 31,
language: main.Code.Language.CPP,
});
const transferredCode = main.Code.deserialize(code.serialize());
expect(transferredCode.toObject()).toEqual({
lines: 31,
language: main.Code.Language.CPP,
});
});
} | EchoZhaoH/protoc-gen-ts | test/enum_within_message.spec.ts | TypeScript |
ArrowFunction |
() => {
const code = new main.Code({
lines: 31,
language: main.Code.Language.CPP,
});
const transferredCode = main.Code.deserialize(code.serialize());
expect(transferredCode.toObject()).toEqual({
lines: 31,
language: main.Code.Language.CPP,
});
} | EchoZhaoH/protoc-gen-ts | test/enum_within_message.spec.ts | TypeScript |
ArrowFunction |
(props: IEmojiProps) => (
<svg viewBox="0 0 72 72" | react-pakistan/react-emoji-collection | src/people-body/family/Family43.tsx | TypeScript |
FunctionDeclaration |
function parse(input: string): Package | never {
if (!input) {
throw Error('Name cannot be an empty value');
}
const {scope, name, version}: Package = grammar.parse(input);
if (!scope) {
if (blacklist.includes(name)) {
throw Error('Name cannot contain blacklisted names');
}
if (builtins.includes(name)) {
throw Error('Name cannot contain builtin names');
}
}
return {scope, name, version};
} | pobedit-instruments/package-name-parser | src/parser.ts | TypeScript |
TypeAliasDeclaration |
type Package = {
scope?: string;
name: string;
version?: {
basic: string;
comparator?: string;
preRelease?: string;
buildMetadata?: string;
original: string;
}
}; | pobedit-instruments/package-name-parser | src/parser.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss'],
})
export class HeaderComponent implements OnInit {
constructor(private router: Router) {}
ngOnInit() {}
onClick(link: string) {
this.router.navigateByUrl(link);
}
} | heavenshell/ts-angular | src/app/components/organisms/header/header.component.ts | TypeScript |
MethodDeclaration |
onClick(link: string) {
this.router.navigateByUrl(link);
} | heavenshell/ts-angular | src/app/components/organisms/header/header.component.ts | TypeScript |
InterfaceDeclaration |
export interface NewUser {
role: string;
email: string;
username: string;
firstName: string;
lastName: string;
avatarUrl: string;
uId: string;
providerName: Providers;
providerUrl: string;
accessToken: string;
} | BinaryStudioAcademy/bsa-2020-buildeR | frontend/src/app/shared/models/user/new-user.ts | TypeScript |
ArrowFunction |
() => {
console.log('Server started at: ' + server.info.uri);
} | 0-Captain/DefinitelyTyped | types/hapi/test/server/server-stop.ts | TypeScript |
ArrowFunction |
() => {
console.log('Server stoped.');
} | 0-Captain/DefinitelyTyped | types/hapi/test/server/server-stop.ts | TypeScript |
ArrowFunction |
() => {
server.stop({ timeout: 10 * 1000 });
} | 0-Captain/DefinitelyTyped | types/hapi/test/server/server-stop.ts | TypeScript |
FunctionDeclaration | /**
* Renders code tag with highlighting based on requested language.
*/
function CodeTag({ language, value }: CodeTagProps): ReactElement {
// language is explicitly null; don't highlight
if (language === null) {
return <code>{value}</code>
}
// no language provided; we'll default to python
if (language === undefined) {
logWarning(`No language provided, defaulting to Python`)
}
const languageKey = (language || "python").toLowerCase()
// language provided, but not supported; don't highlight
const lang: Grammar = Prism.languages[languageKey]
if (!lang) {
logWarning(`No syntax highlighting for ${language}.`)
return <code>{value}</code>
}
// language provided & supported; return highlighted code
return (
<code
className={`language-${languageKey}`} | 0phoff/streamlit | frontend/src/components/elements/CodeBlock/CodeBlock.tsx | TypeScript |
FunctionDeclaration | /**
* Renders a code block with syntax highlighting, via Prismjs
*/
export default function CodeBlock({
language,
value,
}: CodeBlockProps): ReactElement {
return (
<StyledCodeBlock className="stCodeBlock">
{value && (
<StyledCopyButtonContainer>
<CopyButton text={value} />
</StyledCopyButtonContainer>
)} | 0phoff/streamlit | frontend/src/components/elements/CodeBlock/CodeBlock.tsx | TypeScript |
InterfaceDeclaration |
interface CodeTagProps {
language?: string | null
value: string
} | 0phoff/streamlit | frontend/src/components/elements/CodeBlock/CodeBlock.tsx | TypeScript |
InterfaceDeclaration |
export interface CodeBlockProps extends CodeTagProps {} | 0phoff/streamlit | frontend/src/components/elements/CodeBlock/CodeBlock.tsx | TypeScript |
InterfaceDeclaration |
declare interface Window {
getCurrentWindow: Electron.Remote['getCurrentWindow'];
platform: NodeJS.Platform;
} | Losses/electron-with-cra-ts | common.d.ts | TypeScript |
ArrowFunction |
({
user,
workspace,
module,
isAuthor,
setInboxOpen,
inboxOpen,
expire,
signature,
setModule,
fetchDrafts,
}) => {
const [isEditing, setIsEditing] = useState(false)
const [addAuthors, setAddAuthors] = useState(false)
const [addParentMutation] = useMutation(addParent)
const [moduleEdit, { refetch, setQueryData }] = useQuery(
useCurrentModule,
{ suffix: module.suffix },
{ refetchOnWindowFocus: false }
)
const mainFile = moduleEdit!.main as Prisma.JsonObject
const supportingRaw = moduleEdit!.supporting as Prisma.JsonObject
const [approveAuthorshipMutation] = useMutation(approveAuthorship)
const [addReferenceMutation] = useMutation(addReference)
const [deleteReferenceMutation] = useMutation(deleteReference)
const [createReferenceMutation] = useMutation(createReferenceModule)
const [editModuleScreenMutation] = useMutation(editModuleScreen)
const prefersDarkMode = useMediaPredicate("(prefers-color-scheme: dark)")
const [previousOpen, setPreviousOpen] = useState(false)
const arrowColor = prefersDarkMode ? "white" : "#0f172a"
const formik = useFormik({
initialValues: {
type: moduleEdit!.type.id.toString(),
title: moduleEdit!.title,
description: moduleEdit!.description,
license: moduleEdit!.license?.id.toString(),
},
validate: validateZodSchema(
z.object({
type: z.string().min(1),
title: z.string().max(300),
description: z.string(),
license: z.string().min(1),
})
),
onSubmit: async (values) => {
const updatedModule = await editModuleScreenMutation({
id: moduleEdit?.id,
typeId: parseInt(values.type),
title: values.title,
description: values.description,
licenseId: parseInt(values.license),
})
setQueryData(updatedModule)
setIsEditing(false)
},
})
useEffect(() => {
formik.setFieldValue("type", moduleEdit!.type.id.toString())
formik.setFieldValue("title", moduleEdit!.title)
formik.setFieldValue("description", moduleEdit!.description)
formik.setFieldValue("license", moduleEdit!.license!.id.toString())
}, [moduleEdit])
const ownAuthorship = moduleEdit?.authors.find(
(author) => author.workspace?.handle === workspace.handle
)
return (
<div className="mx-auto max-w-4xl overflow-y-auto p-5 text-base">
{/* Publish module */}
{(moduleEdit!.authors.filter((author) => author.readyToPublish !== true).length === 0 &&
Object.keys(moduleEdit!.main!).length !== 0) ||
(moduleEdit!.authors.length === 1 && moduleEdit!.main!["name"]) ? (
<PublishModuleModal module={moduleEdit} user={user} workspace={workspace} /> | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
async (values) => {
const updatedModule = await editModuleScreenMutation({
id: moduleEdit?.id,
typeId: parseInt(values.type),
title: values.title,
description: values.description,
licenseId: parseInt(values.license),
})
setQueryData(updatedModule)
setIsEditing(false)
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
() => {
formik.setFieldValue("type", moduleEdit!.type.id.toString())
formik.setFieldValue("title", moduleEdit!.title)
formik.setFieldValue("description", moduleEdit!.description)
formik.setFieldValue("license", moduleEdit!.license!.id.toString())
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(author) => author.workspace?.handle === workspace.handle | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(author) => author.readyToPublish !== true | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
setQueryData(data)
return "Version approved for publication"
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
setQueryData(data)
return `Linked to: "${item.name}"`
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
toast.promise(
addParentMutation({
currentId: module?.id,
connectId: data.id,
}),
{
loading: "Adding link...",
success: (info) => {
setQueryData(info)
return `Linked to: "${data.title}"`
},
error: "Failed to add link...",
}
)
return "Record added to database"
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(info) => {
setQueryData(info)
return `Linked to: "${data.title}"`
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(file) => (
<>
<EditSupportingFileDisplay
name={file.original_filename} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
setQueryData(data)
return "Added reference!"
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
toast.promise(
addReferenceMutation({
currentId: moduleEdit?.id,
connectId: data.id,
}),
{
loading: "Adding reference...",
success: (data) => {
setQueryData(data)
return "Added reference!"
},
error: "Failed to add reference...",
}
)
return "Reference added to database"
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
setQueryData(data)
return "Added reference!"
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(reference) => (
<>
<li>
<button className="mx-2">
<TrashCan24
className | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(data) => {
setQueryData(data)
return `Removed reference: "${reference.title}"`
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(author, index) => (
<>
<Link href={Routes.HandlePage({ handle: author!.workspace!.handle })}>
<a target | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
ArrowFunction |
(author, index) => (
<>
{index === 3
? "[...]"
: index > 3
? ""
: author.given && author.family
? `${author.family}, ${author.given}`
: `${author.name}` | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
MethodDeclaration |
file< | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
MethodDeclaration |
inboxOpen ? (
<button
onClick={() => {
setInboxOpen | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
MethodDeclaration |
async onSelect(params) {
const { item, setQuery } = params
toast.promise(
addParentMutation({
currentId: module?.id,
connectId: item.objectID,
}),
{
loading: "Adding link...",
success: (data) => {
setQueryData(data)
return `Linked to: "${item.name}"`
},
error: "Failed to add link...",
}
)
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
MethodDeclaration |
getItems() {
return getAlgoliaResults({
searchClient,
queries: [
{
indexName: `${process.env.ALGOLIA_PREFIX}_modules`,
query,
},
],
})
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |
MethodDeclaration |
item({ item, components }) {
// TODO: Need to update search results per Algolia index
return <SearchResultModule item={item} />
} | egonw/ResearchEquals.com | app/modules/components/ModuleEdit.tsx | TypeScript |