repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
Wasmnizer-ts | github_2023 | web-devkits | typescript | createFunctionScope | function createFunctionScope(
specializedFunctionType: TSFunction,
parentScope: Scope,
isMethod: boolean,
context: ParserContext,
) {
const typeArguments = isMethod
? (parentScope as ClassScope).classType.specializedArguments
? (parentScope as ClassScope).classType.specializedArg... | /**
* @describe create a new specialize FunctionScope
* @param specializedFunctionType the new specialized function type
* @param parentScope the parent scope
* @param isMethod method or not
* @param context the parser context
* @returns a new specialized FunctionScope
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/utils.ts#L1339-L1448 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | WASMGen.parseFuncs | private parseFuncs() {
const funcArray = this._semanticModule!.functions;
for (const func of funcArray) {
this.parseFunc(func);
}
} | /* parse functions */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/index.ts#L497-L502 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | WASMGen.parseBody | private parseBody(body: BlockNode) {
/* assign value for block's context variable */
if (
body.varList &&
body.varList[0].type instanceof ClosureContextType &&
body.varList[0].initCtx
) {
const freeVars: VarDeclareNode[] = [];
for (cons... | /* parse function body */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/index.ts#L1011-L1030 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | WASMExpressionGen.fixVtableIndex | private fixVtableIndex(
meta: ObjectDescription,
member: MemberDescription,
isSetter = false,
) {
const members = meta.members;
const bound = members.findIndex((m) => m.name === member.name);
let index = bound;
if (index < 0) {
throw new Error(
... | /* Currently we don't believe the index provided by semantic tree, semantic
tree treat all method/accessors as instance field, but in binaryen
backend we put all these into vtable, so every getter/setter pair will
occupies two vtable slots */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/wasm_expr_gen.ts#L1970-L1998 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | WASMExpressionGen.getClosureOfFunc | private getClosureOfFunc(
func: binaryen.ExpressionRef,
type: FunctionType,
_this: binaryen.ExpressionRef,
) {
const closureType = this.wasmTypeGen.getWASMValueHeapType(type);
const res = binaryenCAPI._BinaryenStructNew(
this.module.ptr,
arrayToPtr([th... | /** return method in the form of closure */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/wasm_expr_gen.ts#L2580-L2593 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | WASMExpressionGen.dyntypeInvoke | private dyntypeInvoke(
name: string,
args: Array<SemanticsValue>,
isNew = false,
): binaryen.ExpressionRef {
const namePointer = this.wasmCompiler.generateRawString(name);
const thisArg = !isNew
? this.wasmExprGen(args.splice(0, 1)[0])
: undefined;
... | /** the dynamic object will fallback to libdyntype */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/wasm_expr_gen.ts#L4253-L4282 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | WASMTypeGen.heapType | get heapType() {
return this.heapTypeMap;
} | /** return heapTypeMap */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/wasm_type_gen.ts#L952-L954 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genarateI8ArrayTypeInfo | function genarateI8ArrayTypeInfo(): typeInfo {
const charArrayTypeInfo = initArrayType(
binaryen.i32,
Packed.I8,
true,
true,
-1,
binaryenCAPI._TypeBuilderCreate(1),
);
return charArrayTypeInfo;
} | // generate array type to store character context | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L314-L324 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | generateStringTypeInfo | function generateStringTypeInfo(): typeInfo {
const charArrayTypeInfo = i8ArrayType;
const stringTypeInfo = initStructType(
[
binaryen.i32,
binaryenCAPI._BinaryenTypeFromHeapType(
charArrayTypeInfo.heapTypeRef,
true,
),
],
... | // generate struct type to store string information | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L327-L345 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genarateNumberArrayTypeInfo | function genarateNumberArrayTypeInfo(): typeInfo {
const numberArrayTypeInfo = initArrayType(
binaryen.f64,
Packed.Not,
true,
true,
-1,
binaryenCAPI._TypeBuilderCreate(1),
);
return numberArrayTypeInfo;
} | // generate number array type | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L348-L358 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genarateI32ArrayTypeInfo | function genarateI32ArrayTypeInfo(): typeInfo {
const i32ArrayTypeInfo = initArrayType(
binaryen.i32,
Packed.Not,
true,
true,
-1,
binaryenCAPI._TypeBuilderCreate(1),
);
return i32ArrayTypeInfo;
} | // generate i32 array type | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L361-L371 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genarateStringArrayTypeInfo | function genarateStringArrayTypeInfo(struct_wrap: boolean): typeInfo {
const stringTypeInfo = stringType;
const stringArrayTypeInfo = initArrayType(
stringTypeInfo.typeRef,
Packed.Not,
true,
true,
-1,
binaryenCAPI._TypeBuilderCreate(1),
);
if (struct_wrap... | // generate string array type | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L374-L390 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genarateBoolArrayTypeInfo | function genarateBoolArrayTypeInfo(): typeInfo {
const boolArrayTypeInfo = initArrayType(
binaryen.i32,
Packed.Not,
true,
true,
-1,
binaryenCAPI._TypeBuilderCreate(1),
);
return boolArrayTypeInfo;
} | // generate bool array type | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L414-L424 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genarateAnyArrayTypeInfo | function genarateAnyArrayTypeInfo(): typeInfo {
const anyArrayTypeInfo = initArrayType(
binaryenCAPI._BinaryenTypeAnyref(),
Packed.Not,
true,
true,
-1,
binaryenCAPI._TypeBuilderCreate(1),
);
return anyArrayTypeInfo;
} | // generate any array type | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/glue/transform.ts#L427-L437 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | loop | const loop = (loopLabel: string, ifTrueBlock: binaryen.ExpressionRef) => {
const loopInit = module.local.set(loopIndex, module.i32.const(0));
const loopCond = module.i32.lt_u(loopIdx, mataFieldsCount);
const loopIncrementor = module.local.set(
loopIndex,
module.i32.add(lo... | // 4. get number of iterable properties, and fill string array by iterable names | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/lib/init_builtin_api.ts#L160-L211 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | setAnyToI32 | const setAnyToI32 = (
module: binaryen.Module,
localIdx: number,
anyRef: binaryen.ExpressionRef,
defaultValue: binaryen.ExpressionRef,
) => {
const isUndefined = FunctionalFuncs.isBaseType(
module,
anyRef,
dyntype.dyntype_is_undefined,
... | /** 1. set start and end to i32 */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/lib/init_builtin_api.ts#L733-L781 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | createNewCharArray | const createNewCharArray = (module: binaryen.Module) => {
return binaryenCAPI._BinaryenArrayNew(
module.ptr,
i8ArrayTypeInfo.heapTypeRef,
module.local.get(curStrLenIdx, binaryen.i32),
module.i32.const(0),
);
}; | /**3.2 find a matched string and copy it to resStrArr. Currently, only a single
* matched string will be copied.
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/lib/init_builtin_api.ts#L1319-L1326 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | string_match_stringref | function string_match_stringref(module: binaryen.Module) {
const ref_index = 1;
const str_index = 2;
const match_pos_index = 3;
const arr_index = 4;
const ref = module.local.get(
ref_index,
binaryenCAPI._BinaryenTypeStringref(),
);
const str = module.local.get(
str_in... | // TODO: Now only return the first appreared pattern string | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/lib/init_builtin_api.ts#L2177-L2274 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | string_search_stringref | function string_search_stringref(module: binaryen.Module) {
const ref_index = 1;
const str_index = 2;
const statementArray: binaryen.ExpressionRef[] = [];
const index = module.call(
UtilFuncs.getFuncName(
BuiltinNames.builtinModuleName,
BuiltinNames.stringIndexOfInternalF... | // TODO: Now it works as string.indexOf | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/lib/init_builtin_api.ts#L2315-L2336 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | newExtRef | function newExtRef(module: binaryen.Module) {
const _context_unused = 0;
const objTagIdx = 1;
const objIdx = 2;
/* alloc table slot */
const tableIdx = module.call(
getBuiltInFuncName(BuiltinNames.allocExtRefTableSlot),
[module.local.get(objIdx, binaryen.anyref)],
dyntype.in... | /** to extref with runtime getting table index */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/backend/binaryen/lib/init_builtin_api.ts#L3392-L3420 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | buildTemplateExpression | function buildTemplateExpression(
expr: TemplateExpression,
context: BuildContext,
): SemanticsValue {
const head = buildExpression(expr.head, context);
const follows: SemanticsValue[] = [];
for (const span of expr.spans) {
let expr = buildExpression(span.expr, context);
expr = newCa... | // convert `Hello ${name} World` to the format | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/semantics/expression_builder.ts#L896-L910 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | removeRecWhichHasInfc | function removeRecWhichHasInfc(recGroupTypes: TSClass[][]) {
const recGroupTypesNew: TSClass[][] = [];
if (recGroupTypes.length == 0) {
return recGroupTypesNew;
}
for (let i = 0; i < recGroupTypes.length; ++i) {
let hasInfc = false;
for (let j = 0; j < recGroupTypes[i].length; +... | /** to avoid interface in rec circles */ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/semantics/index.ts#L863-L882 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | getClassMetaName | function getClassMetaName(name: string): string {
return `@${name}`;
} | /*
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/semantics/internal.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | DynamicGetValue.constructor | constructor(
public owner: SemanticsValue,
public name: string,
public isMethodCall: boolean,
type?: ValueType,
) {
super(SemanticsValueKind.DYNAMIC_GET, type ? type : Primitive.Any);
} | /* 'isMethodCall' determines the specific semantics of member function property access,
whether it is just to obtain the member function property value,
or needs to call the member function.
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/src/semantics/value.ts#L824-L831 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | fibonacci | function fibonacci(num: number): number {
if (num < 2) {
return num;
} else {
return fibonacci(num - 1) + fibonacci(num - 2);
}
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/benchmark/fibonacci.ts#L6-L12 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | colour | function colour(iteration: number, offset: number, scale: number): number {
iteration = (iteration * scale + offset) & 1023;
if (iteration < 256) {
return iteration;
} else if (iteration < 512) {
return 255 - (iteration - 255);
}
return 0;
} | /* This file is modified base on:
* https://github.com/ColinEberhardt/wasm-mandelbrot/blob/master/assemblyscript/mandelbrot.ts
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/benchmark/mandelbrot.ts#L8-L16 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | approximate | function approximate(n: number): number {
const u: number[] = new Array(n),
v: number[] = new Array(n);
for (let i = 0; i < n; ++i) {
u[i] = 1.0;
}
for (let i = 0; i < 10; ++i) {
multiplyAtAv(n, u, v);
multiplyAtAv(n, v, u);
}
let vBv = 0.0,
vv = 0.0;
... | /* The Computer Language Benchmarks Game
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
contributed by Isaac Gouy
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/benchmark/spectral_norm.ts#L10-L27 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | getAnyObj | function getAnyObj(): any {
return { a: 1 };
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/any_box_obj_as_return_value.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | output_number_arr | function output_number_arr(arr: number[]) {
for (let i = 0; i < arr.length; ++i) {
console.log(arr[i]);
}
} | /*
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/array_splice.ts#L6-L10 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | callReturnTest | function callReturnTest(a = 10, b = 1, c = 99) {
return a + b + c;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/call_expression_get_value.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | closure | function closure(x: number) {
let z = 1;
function inner1() {
return z + 1;
}
function inner2() {
return z + 2;
}
if (x > 10) {
return inner1;
}
return inner2;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/closure_first_class_func.ts#L6-L18 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | throwNewError | function throwNewError() {
throw new Error('A new error');
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/exception_catch_error.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | anyFunc | function anyFunc(num: any) {
console.log(num);
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/generic_param.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | global_func | function global_func<T>(value: T) {
console.log("call global function");
return value;
} | /*
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/global_generics_function.ts#L6-L9 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | logMapElements | function logMapElements(value: any, key: any, map: any) {
console.log(key, value, map);
} | /*
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/map_callback.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | optionalParam | function optionalParam(a?: number) {
return 10;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/optional_param.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | test | function test(a?: string) {
if (a) {
console.log(a);
a = undefined;
} else {
console.log('undefined');
}
} | // 47 | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/rest_param_number.ts#L19-L26 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | pet_point | function pet_point(p: pet, point: IntPoint) {
console.log(p, point.x, point.y);
} | // function | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/typealias.ts#L22-L24 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | outer | function outer() {
let i = 10;
function inner1() {
i++;
return i;
}
function inner2() {
i--;
return i;
}
return [inner1, inner2];
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/array_contain_closure.ts#L6-L17 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | A1.test | test() {
return 123;
} | // empty constructor | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/class_basic.ts#L8-L10 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | closure1 | function closure1(x: number, y: boolean) {
let z = 1;
function inner(z: number) {
function inner1(a: number) {
const m = 1;
return m + z + a + x; // 4
}
return inner1;
}
return inner;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/closure_basic.ts#L6-L16 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | test | function test(a?: string) {
if (a) {
let b: string = a as string;
console.log(b)
}
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/any_as_string.ts#L6-L11 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | reBindingBlockClosure | function reBindingBlockClosure() {
let arr: Array<() => number> = [];
for (let i = 0; i < 10; i++) {
arr.push(() => i);
}
return arr;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/block_closure.ts#L6-L13 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | callReturnTest1 | function callReturnTest1(a = 10, b = 1, c = 99) {
return a + b + c;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/call_expression_param.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | genericFunc | function genericFunc<T>(param: T): T {
return param;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/generic_func.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | inner1 | function inner1() {
return 10;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/array_contain_func.ts#L8-L10 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | oriExportFunc | function oriExportFunc() {
return 10;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/export_alias_identifier.ts#L6-L8 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | A15.constructor | constructor() {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/class_static_prop.ts#L11-L11 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | cpxCase2Func1 | function cpxCase2Func1(a: number) {
return 1;
} | // class cpxCase2Class1 {} | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/complexType_case2.ts#L12-L14 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | func5 | function func5<X, Y>(a: X, b: Y) {
const foo = new Foo1(a);
const bar = new Bar1(b);
console.log(foo.x);
console.log(bar._y);
} | // case 3 | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/nest_generic.ts#L106-L111 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | helper | function helper(str: string, num: number) {
return `${str} is not ${num}`;
} | // string template | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/string_type.ts#L44-L46 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
Wasmnizer-ts | github_2023 | web-devkits | typescript | testFunc | function testFunc(a: boolean) {
if (a) {
return 10;
}
return 11;
} | /*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ | https://github.com/web-devkits/Wasmnizer-ts/blob/228cb803eb71bc7003b0e1d4faafecbc153e03fd/tests/samples/union_func_call.ts#L6-L11 | 228cb803eb71bc7003b0e1d4faafecbc153e03fd |
ai-dial-chat | github_2023 | epam | typescript | FolderAssertion.assertSearchResultRepresentation | public async assertSearchResultRepresentation(searchFolderPath: string) {
//extract folder path elements to an array
const searchFolderHierarchyArray = searchFolderPath.split('/');
const foundFolders = await this.folder.getFolderNames();
let index = 0;
//check if each path element is sequentially in... | //the function argument is a full path to the searched folder, e.g., 'test' - if the folder is not nested, or 'test1/test1.1/test1.1.1' in the case of a nested structure | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat-e2e/src/assertions/folderAssertion.ts#L423-L438 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | BaseApiHelper.getHost | public getHost(endpoint: string) {
const baseUrl = config.use!.baseURL;
if (baseUrl === overlayHost) {
endpoint = process.env.NEXT_PUBLIC_OVERLAY_HOST + endpoint;
}
return endpoint;
} | //function to override the API host if overlay sandbox is running | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat-e2e/src/testData/api/baseApiHelper.ts#L14-L20 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | TalkToAgentDialog.selectRecentAgent | public async selectRecentAgent(agent: DialAIEntityModel) {
const resp = this.page.waitForResponse((r) =>
r.url().includes(API.moveHost),
);
await this.getAgents().getAgent(agent).click();
await resp;
} | //select agent available on 'Talk to' modal | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat-e2e/src/ui/webElements/talkToAgentDialog.ts#L149-L155 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | Folders.renameEmptyFolder | public async renameEmptyFolder(
newName: string,
method: () => Promise<void>,
{ isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {},
) {
await this.editFolderName(newName);
if (isHttpMethodTriggered && isApiStorageType) {
const respPromise = this.page.waitForResponse((re... | //no API is triggered if to rename folder in 'Manage Attachments' or 'Change path' modals | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts#L258-L272 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | Folders.renameFolderWithContent | public async renameFolderWithContent(
newName: string,
method: () => Promise<void>,
{ isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {},
) {
await this.editFolderName(newName);
if (isApiStorageType && isHttpMethodTriggered) {
const hostsMap = new Map([
[API.lis... | //if shared folder is renamed, confirmation popup is prompted | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat-e2e/src/ui/webElements/entityTree/folders.ts#L276-L305 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | compareVersions | function compareVersions(v1: string, v2: string): number {
const v1Parts = v1.split('.').map(String);
const v2Parts = v2.split('.').map(String);
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
const part1 = parseInt(v1Parts[i] || '0');
const part2 = parseInt(v2Parts[i] || '0');
if... | //algorithm for semver versions sorting | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat-e2e/src/utils/sortingUtil.ts#L61-L75 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | handleSetProperVHPoints | const handleSetProperVHPoints = () => {
document.documentElement.style.setProperty(
'--vh',
window.innerHeight * 0.01 + 'px',
);
dispatch(UIActions.resize());
}; | // Hack for ios 100vh issue | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/components/Layout.tsx#L99-L105 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | safeStringify | const safeStringify = (
featureData: DialAIEntityFeatures | Record<string, string> | undefined,
) => {
if (
!featureData ||
(isObject(featureData) && !Object.keys(featureData).length)
) {
return '';
}
return JSON.stringify(featureData, null, 2);
}; | // DATA TRANSFORMERS | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/components/Common/ApplicationWizard/form.ts#L291-L302 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | handler | const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getServerSession(req, res, authOptions);
const isSessionValid = validateServerSession(session, req, res);
if (!isSessionValid) {
return;
}
const token = await getToken({ req });
try {
const entities: DialA... | // export const config = { | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/pages/api/addons.ts#L18-L54 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | defaultCookies | function defaultCookies(
useSecureCookies: boolean,
sameSite = 'lax',
): CookiesOptions {
const cookiePrefix = useSecureCookies ? '__Secure-' : '';
return {
// default cookie options
sessionToken: {
name: `${cookiePrefix}next-auth.session-token`,
options: {
httpOnly: true,
sa... | // https://github.com/nextauthjs/next-auth/blob/a8dfc8ebb11ccb96fd694db888e52f0d20395e64/packages/core/src/lib/cookie.ts#L53 | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/pages/api/auth/[...nextauth].ts#L11-L77 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | notifyHostAboutReadyEpic | const notifyHostAboutReadyEpic: AppEpic = (_action$, state$) =>
state$.pipe(
filter(() => SettingsSelectors.selectIsOverlay(state$.value)),
map((state) => {
return {
isShouldLogin: AuthSelectors.selectIsShouldLogin(state),
isModelLoaded: ModelsSelectors.selectIsModelsLoaded(state),
... | // models are loading after conversations, if models loaded that means that we can work with application. Maybe there is better condition. | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/store/overlay/overlay.epics.ts#L604-L624 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | getSharedListingSuccessEpic | const getSharedListingSuccessEpic: AppEpic = (action$, state$) =>
action$.pipe(
filter(ShareActions.getSharedListingSuccess.match),
switchMap(({ payload }) => {
const actions = [];
const { acceptedId, isFolderAccepted, isConversation, isPrompt } =
ShareSelectors.selectAcceptedEntityInfo(st... | // TODO: refactor it to something better | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/store/share/share.epics.ts#L667-L1014 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ConversationService.getConversation | public static getConversation(
info: ConversationInfo,
): Observable<Conversation | null> {
return DataService.getDataStorage().getConversation(info);
} | // TODO: allow to pass only path, because it's hard to create full object every time | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/utils/app/data/conversation-service.ts#L70-L74 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | DataService.getRecentModelsIds | public static getRecentModelsIds(): Observable<string[] | undefined> {
return BrowserStorage.getData(UIStorageKeys.RecentModelsIds, undefined);
} | // TODO: extract all this methods to separate services to prevent using Data service there | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/utils/app/data/data-service.ts#L43-L45 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | refreshAccessToken | async function refreshAccessToken(token: Token) {
const displayedTokenSub =
process.env.SHOW_TOKEN_SUB === 'true' ? token.sub : '******';
try {
if (!token.providerId) {
throw new Error(`No provider information exists in token`);
}
const client = NextClient.getClient(token.providerId);
if (... | /**
* Takes a token, and returns a new token with updated
* `accessToken` and `accessTokenExpires`. If an error occurs,
* returns the old token and an error property
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/apps/chat/src/utils/auth/auth-callbacks.ts#L75-L167 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.constructor | constructor(
dialHost: string,
appName: string,
dataCallback: (visualizerData: AttachmentData) => void,
) {
this.dialHost = dialHost;
this.appName = appName;
this.dataCallback = dataCallback;
this.postMessageListener = this.postMessageListener.bind(this);
window.addEventListener('mess... | /**
* Creates a ChatVisualizerConnector
* @param dialHost {string} DIAL CHAT host
* @param appName {string} name of the Visualizer same as in config
* @param dataCallback {(visualizerData: AttachmentData) => void} callback to get data that will be used in the Visualizer
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L30-L41 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.send | public send({
type,
payload,
dialHost = this.dialHost,
}: {
type: VisualizerConnectorEvents;
payload?: unknown;
dialHost?: string;
}) {
if (!window?.parent) {
throw new Error(
`[${this.appName}] There is no parent window to send requests`,
);
}
window.parent.... | /**
* Sends the post message to the DIAL Chat
* @param type Visualizer Event name
* @param payload Event payload
* @param dialHost host of the DIAL Chat
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L49-L71 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.sendPMResponse | sendPMResponse(requestParams: PostMessageRequestParams): void {
const { type, requestId, dialHost, payload } = requestParams;
window?.parent.postMessage(
{
type: `${type}/RESPONSE`,
requestId,
payload,
},
dialHost,
);
} | /**
* Sends response via postMessage to the DIAL CHAT to notify it data received
* @param requestParams {PostMessageRequestParams}
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L77-L88 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.sendReady | public sendReady() {
this.send({ type: VisualizerConnectorEvents.ready });
} | /**
* Sends 'READY' event via postMessage to the DIAL CHAT to notify that Visualizer loaded
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L122-L124 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.sendReadyToInteract | public sendReadyToInteract() {
this.send({ type: VisualizerConnectorEvents.readyToInteract });
} | /**
* Sends 'READY_TO_INTERACT' event via postMessage to the DIAL CHAT to notify that Visualizer ready to get data
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L129-L131 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.sendMessage | public async sendMessage(content: string) {
this.send({
type: VisualizerConnectorEvents.sendMessage,
payload: { message: content },
});
} | /**
* Send message into the selected conversations
* @param content {string} text of message that should be sent to the chat
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L137-L142 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatVisualizerConnector.destroy | destroy() {
window.removeEventListener('message', this.postMessageListener);
} | /**
* Destroys ChatVisualizerConnector
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/chat-visualizer-connector/src/lib/ChatVisualizerConnector.ts#L147-L149 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.constructor | constructor(root: HTMLElement | string, options: ChatOverlayOptions) {
this.options = options;
this.root = this.getRoot(root);
this.requests = [];
this.subscriptions = [];
this.iframeInteraction = new Task();
this.iframe = this.initIframe();
this.loader = this.initLoader(
options?.... | /**
* Creates a ChatOverlay
* @param root {HTMLElement | string} reference or selector to parent container where the iframe should be placed
* @param options {ChatOverlayOptions} overlay options (incl. domain, hostDomain, theme, modelId, etc.)
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L62-L87 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.initIframe | protected initIframe(): HTMLIFrameElement {
const iframe = document.createElement('iframe');
iframe.src = this.options.domain;
iframe.allow = 'clipboard-write';
iframe.name = 'overlay';
iframe.ariaLabel = 'Chat overlay';
iframe.sandbox.add('allow-same-origin');
iframe.sandbox.add('allow-sc... | /**
* Creates iframe add set initial options to it
* @returns {HTMLIFrameElement} reference to iframe element
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L93-L114 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.initLoader | protected initLoader(
styles: Styles,
className?: string,
loaderInnerHTML?: string,
): HTMLElement {
const loader = document.createElement('div');
loader.innerHTML = loaderInnerHTML ?? defaultLoaderSVG;
if (className) {
loader.className = className;
}
if (styles?.display) {
... | /**
* Creates loader and add styles
* @returns {HTMLElement} reference to loader element
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L120-L152 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.showLoader | private showLoader() {
setStyles(this.loader, {
display: this.loaderDisplayCss,
});
} | /**
* Shows loader
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L156-L160 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.hideLoader | private hideLoader() {
setStyles(this.loader, {
display: 'none',
});
} | /**
* Hides loader
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L164-L168 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.ready | public async ready(): Promise<boolean> {
return this.iframeInteraction.ready();
} | /**
* Displays if iframe ready to interact
* @returns {Promise<boolean>} if the promise resolved -> iframe ready to interact
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L174-L176 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.getRoot | protected getRoot(root: HTMLElement | string): HTMLElement {
if (typeof root === 'string') {
const element = document.querySelector(root);
if (!element) {
throw new Error(
`[${overlayLibName}] There is no element with selector ${root} to append iframe`,
);
}
retur... | /**
* If user provides reference to container ? returns the container : query the selector and return reference to container
* @param {HTMLElement | string} root reference to parent container or selector where iframe should be placed
* @returns {HTMLElement} reference to container where iframe would be placed
... | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L183-L197 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.allowFullscreen | public allowFullscreen(): void {
this.iframe.allowFullscreen = true;
} | /**
* Allows iframe to be in fullscreen mode
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L202-L204 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.openFullscreen | public openFullscreen(): void {
if (!this.iframe.requestFullscreen) {
throw new Error(
`[${overlayLibName}] Fullscreen is not allowed. Allow it first`,
);
}
this.iframe.requestFullscreen();
} | /**
* Opens iframe in fullscreen mode
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L209-L217 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.process | protected process = (event: MessageEvent<OverlayRequest>): void => {
if (event.data.type === `${overlayAppName}/${OverlayEvents.initReady}`) {
this.showLoader();
return;
}
if (event.data.type === `${overlayAppName}/${OverlayEvents.ready}`) {
this.setOverlayOptions(this.options);
this... | /**
* Callback to post message event, contains mapping event to this.requests, mapping event to this.subscriptions
* @param event {MessageEvent} post message event
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.processEvent | protected processEvent(eventType: string, payload?: unknown): void {
for (const subscription of this.subscriptions) {
if (subscription.eventType === eventType) {
subscription.callback(payload);
}
}
} | /**
* Going through all event callbacks and call it if eventType is the same as in subscription
* @param eventType {string} Name of event that DIAL send
* @param payload {unknown} Payload of event
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L265-L271 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.send | public async send(
type: OverlayRequests,
payload?: unknown,
waitForReady = true,
): Promise<unknown> {
if (waitForReady) {
await this.iframeInteraction.ready();
}
if (!this.iframe.contentWindow) {
throw new Error(
`[${overlayLibName}] There is no content window to send re... | /**
* Creates DeferredRequests, put into the this.requests
* We don't put something into the this.requests until `this.ready()`
* @param type Request name
* @param payload Request payload
* @param waitForReady Is this request should wait for overlay ready (default: true)
* @returns {Promise<unknown>} ... | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L281-L309 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.subscribe | public subscribe(
eventType: string,
callback: (payload: unknown) => void,
): () => void {
this.subscriptions.push({ eventType, callback });
return () => {
this.subscriptions = this.subscriptions.filter(
(sub) => sub.callback !== callback,
);
};
} | /**
* Add callback with eventType to this.subscriptions
* @param eventType Event type
* @param callback Callback which should associated to the event type
* @returns {() => void} Callback which removes event callback from the this.requests
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L317-L328 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.getMessages | public async getMessages(): Promise<GetMessagesResponse> {
return this.send(
OverlayRequests.getMessages,
) as Promise<GetMessagesResponse>;
} | /**
* Get messages from first selected conversation
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L333-L337 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.getConversations | public async getConversations(): Promise<GetConversationsResponse> {
return this.send(
OverlayRequests.getConversations,
) as Promise<GetConversationsResponse>;
} | /**
* Get all listing conversations
* @returns {OverlayConversation[]} all conversations visible in chat
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L343-L347 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.selectConversation | public async selectConversation(
id: string,
): Promise<SelectConversationResponse> {
const request: SelectConversationRequest = {
id,
};
return this.send(
OverlayRequests.selectConversation,
request,
) as Promise<SelectConversationResponse>;
} | /**
* Select conversation
* @param {string} id - id of conversation to select
* @returns Returns selected conversation info
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L354-L365 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.createConversation | public async createConversation(
parentPath?: string | null,
): Promise<CreateConversationResponse> {
const request: CreateConversationRequest = {
parentPath,
};
return this.send(
OverlayRequests.createConversation,
request,
) as Promise<CreateConversationResponse>;
} | /**
* Create conversation
* @param {string} parentPath - path to create conversation in. If not defined or null conversation will be created in user Root
* @returns Returns created conversation info
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L372-L383 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.sendMessage | public async sendMessage(content: string): Promise<SendMessageResponse> {
const request: SendMessageRequest = {
content,
};
return this.send(
OverlayRequests.sendMessage,
request,
) as Promise<SendMessageResponse>;
} | /**
* Send message into the first selected conversation
* @param content {string} text of message that should be sent to the chat
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L389-L398 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.setSystemPrompt | public async setSystemPrompt(
systemPrompt: string,
): Promise<SetSystemPromptResponse> {
const request: SetSystemPromptRequest = {
systemPrompt,
};
return this.send(
OverlayRequests.setSystemPrompt,
request,
) as Promise<SetSystemPromptResponse>;
} | /**
* Set systemPrompt into the first selected conversation
* @param systemPrompt {string} text content of system prompt
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L404-L415 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.setOverlayOptions | public async setOverlayOptions(options: ChatOverlayOptions) {
await this.send(OverlayRequests.setOverlayOptions, options, false);
} | /**
* Send to DIAL overlay options (modelId, hostDomain, etc.)
* @param options {ChatOverlayOptions} Options that should be set into the DIAL
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L421-L423 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlay.destroy | destroy() {
window.removeEventListener('message', this.process);
this.iframeInteraction.fail('Chat Overlay destroyed');
this.root.removeChild(this.iframe);
this.root.removeChild(this.loader);
} | /**
* Destroys ChatOverlay
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlay.ts#L428-L434 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | getPosition | const getPosition = (): Record<OverlayPosition, Position> => {
return {
'left-bottom': {
top: 'initial',
bottom: '20px',
left: '20px',
right: 'initial',
transform: `translate(-${window.innerWidth * 2}px, ${
window.innerHeight * 2
}px)`,
},
'left-top': {
to... | /**
* Returns the styles for overlay placement
* @returns {Record<OverlayPosition, Position>} styles for overlay placement
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlayManager.ts#L23-L62 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | getDefaultSVG | const getDefaultSVG = (height: number, width: number): string => {
return `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-message-circle-2-filled" width="${width}" height="${height}" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin... | /**
* Returns default icon for button which shows overlay
* @param height height of svg
* @param width width of svg
* @returns {string}
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlayManager.ts#L70-L75 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlayManager.constructor | constructor() {
this.overlays = [];
window.addEventListener(
'orientationchange',
() => {
for (const overlay of this.overlays) {
this.updateOverlay(overlay.options.id);
}
},
{ signal: this.listenerAbortController.signal },
);
window.addEventListener(
... | /**
* Creates a ChatOverlayManager
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlayManager.ts#L134-L156 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlayManager.createOverlay | public createOverlay(options: ChatOverlayManagerOptions) {
const container = document.createElement('div');
container.id = 'frame-container';
const overlayContainer = document.createElement('div');
const controlsContainer = document.createElement('div');
const position = getPosition()[options?.pos... | /**
* Creates HTML Container and put ChatOverlay to it, saves to this.overlays
* Received same options as ChatOverlay, but contains 'id' and settings how to place this overlay
* @param options {ChatOverlayManagerOptions} ChatOverlayOptions with `id` and settings how to place this overlay
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlayManager.ts#L163-L220 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
ai-dial-chat | github_2023 | epam | typescript | ChatOverlayManager.createOverlayToggle | public createOverlayToggle(
position: Position,
options: ChatOverlayManagerOptions,
): HTMLButtonElement {
const button = document.createElement('button');
setStyles(button, {
backgroundColor:
options?.iconBgColor || overlayToggleIconOptions.iconBgColor,
borderRadius: '100%',
... | /**
* Creates toggle button to show overlay
* @param position overlay placement, needed to show button in the same place where would be the overlay
* @param options overlay options, needed to show cu
* @returns {HTMLButtonElement} Reference to created toggle button
*/ | https://github.com/epam/ai-dial-chat/blob/bbc3ab44ffc97c358295c08abcc577bc3c3c0636/libs/overlay/src/lib/ChatOverlayManager.ts#L228-L254 | bbc3ab44ffc97c358295c08abcc577bc3c3c0636 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.