diff --git a/bin/index.mjs b/bin/index.mjs index 259d0c240..0d7663f90 100755 --- a/bin/index.mjs +++ b/bin/index.mjs @@ -11,11 +11,8 @@ import chalk from 'chalk'; import add from './add.mjs'; import addLicense from './addLicense.mjs'; import run from './run.mjs'; -<<<<<<< HEAD import genTest from './genTest.mjs'; import { init } from './init.mjs'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb program .command('test') @@ -69,7 +66,6 @@ program .action(run); program -<<<<<<< HEAD .command('genTest') .description('generate all tests for the given library') .requiredOption('-l, --library ', 'the library to test') @@ -83,8 +79,6 @@ program .action(init); program -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb .name(pkg.name) .version(pkg.version) .description(pkg.description) diff --git a/bin/test.mjs b/bin/test.mjs index 1b387437a..f1f1b4042 100644 --- a/bin/test.mjs +++ b/bin/test.mjs @@ -1,5 +1,4 @@ import path from 'node:path'; -<<<<<<< HEAD import { exec, spawn } from 'node:child_process'; import chalk from 'chalk'; import { existsSync } from 'node:fs'; @@ -8,36 +7,19 @@ import { promisify } from 'node:util'; const execAsync = promisify(exec); -======= -import { spawn } from 'node:child_process'; -import { pathToFileURL } from 'node:url'; -import chalk from 'chalk'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb /** * Run all tests for the given library * @param {object} options - The options object * @param {string} options.library - The library to test -<<<<<<< HEAD * @param {string} [options.folder] - The folder to test * @returns {Promise} */ const test = async ({ library, folder }) => { -======= - * @returns {Promise} - */ -const test = async ({ library, folder, reporter }) => { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const start = performance.now(); console.log(`Running tests for ${library}`); // Resolve paths in a cross-platform way const mainFolder = path.join(process.cwd(), 'lib', library); -<<<<<<< HEAD -======= - const reporterPath = pathToFileURL( - path.join(process.cwd(), 'tools', 'testing', 'testReporter.mjs'), - ); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const flags = folder ? `--folder=${folder}` : ''; const runnerPath = path.join( process.cwd(), @@ -45,7 +27,6 @@ const test = async ({ library, folder, reporter }) => { 'testing', 'testRunner.mjs', ); -<<<<<<< HEAD if (!folder?.endsWith('.test.ts')) { if (existsSync(mainFolder + '/.tmp')) { @@ -72,22 +53,12 @@ const test = async ({ library, folder, reporter }) => { (folder?.endsWith('.test.ts')) ? `node --import tsx "${runnerPath.toString()}" -- ${flags}` : `node "${runnerPath.toString()}" -- ${flags}`, -======= - // "glob -c \"tsx --test\" \"./src/**/*.test.ts\"" - const spwn = spawn( - // `npx glob -c "tsx --test-reporter="${reporterPath.toString()}" --test" "./src/**/*.test.ts"`, - `node --import tsx "${runnerPath.toString()}" -- ${flags}`, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb [], { stdio: 'inherit', // Set cwd to the project root -<<<<<<< HEAD cwd: (!folder?.endsWith('.test.ts')) ? `${mainFolder}/.tmp/src` : `${mainFolder}/src`, -======= - cwd: `${mainFolder}`, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb shell: true, }, ); @@ -113,11 +84,8 @@ const test = async ({ library, folder, reporter }) => { `Duration: ${((performance.now() - start) / 1000).toFixed(2)}s`, ), ); -<<<<<<< HEAD if ((!folder?.endsWith('.test.ts'))) await rm(mainFolder + '/.tmp', { recursive: true }); -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); }; diff --git a/eslint.config.mjs b/eslint.config.mjs index 09fdb9f65..7489ee5b6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,11 +23,7 @@ export default [ { files: ['**/*.js'], languageOptions: { sourceType: 'commonjs' }, ignorePatterns: ['**/node_modules/**', '**/dist/**'] }, ...compat.extends('xo-typescript'), -<<<<<<< HEAD -======= - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // ...tseslint.configs.stylisticTypeChecked, { // enable object curly spacing @@ -69,10 +65,7 @@ export default [ allowBitwiseExpressions: true, }, ], -<<<<<<< HEAD '@typescript-eslint/prefer-ts-expect-error': 'off', -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }, }, { diff --git a/lib/aoi.js/.gitignore b/lib/aoi.js/.gitignore index c269d670f..4b1654531 100644 --- a/lib/aoi.js/.gitignore +++ b/lib/aoi.js/.gitignore @@ -2,11 +2,7 @@ node_modules dist coverage index.mjs -<<<<<<< HEAD bin/index.mjs index.js .tsbuildinfo pnpm-lock.yaml -======= -index.js ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/package.json b/lib/aoi.js/package.json index b133bc415..6d287e745 100755 --- a/lib/aoi.js/package.json +++ b/lib/aoi.js/package.json @@ -66,11 +66,7 @@ "devDependencies": { "@types/uglify-js": "^3.17.5", "@vladfrangu/async_event_emitter": "^2.4.6", -<<<<<<< HEAD "discord-api-types": "^0.37.100", "json5": "^2.2.3" -======= - "discord-api-types": "^0.37.100" ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } diff --git a/lib/aoi.js/src/classes/AoiClient.ts b/lib/aoi.js/src/classes/AoiClient.ts index 810278a69..5c7bbcb6d 100644 --- a/lib/aoi.js/src/classes/AoiClient.ts +++ b/lib/aoi.js/src/classes/AoiClient.ts @@ -5,19 +5,10 @@ import { type ICommandOptions, type IAoiClientOptions, } from '@aoi.js/typings/interface.js'; -<<<<<<< HEAD import { type Optional, type CommandTypes, type AsyncFunction } from '@aoi.js/typings/type.js'; import { Client, Partials, type ClientOptions } from 'discord.js'; import * as Events from '@aoi.js/events/index.js'; import { MacrosManager } from '@aoi.js/managers/Macro.js'; -======= -import { - type Optional, - type CommandTypes, -} from '@aoi.js/typings/type.js'; -import { Client, Partials, type ClientOptions } from 'discord.js'; -import * as Events from '@aoi.js/events/index.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb class AoiClient { client!: Client; @@ -27,10 +18,7 @@ class AoiClient { managers!: { commands: CommandManager; functions: FunctionManager; -<<<<<<< HEAD macros: MacrosManager; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; readonly #options: IAoiClientOptions; @@ -48,10 +36,7 @@ class AoiClient { this.managers = { commands: new CommandManager(this), functions: new FunctionManager(this), -<<<<<<< HEAD macros: new MacrosManager(this), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; if (options.testMode) return; @@ -78,11 +63,7 @@ class AoiClient { await this.client.login(this.#options.token); } -<<<<<<< HEAD command(data: Optional) { -======= - command(data: Optional ) { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (!data.type) data.type = 'basic' as CommandTypes; data.__path__ = data.__path__ ?? 'root'; @@ -90,7 +71,6 @@ class AoiClient { return this; } -<<<<<<< HEAD macro(name: string, code: string | AsyncFunction) { this.managers.macros.add({ name, code }); return this; @@ -110,8 +90,6 @@ class AoiClient { // `; // } -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb #validateOptions(options: IAoiClientOptions) { if (options.intents === undefined) { throw new SyntaxError( diff --git a/lib/aoi.js/src/classes/Command.ts b/lib/aoi.js/src/classes/Command.ts index 9f6d615d0..5255d3aee 100644 --- a/lib/aoi.js/src/classes/Command.ts +++ b/lib/aoi.js/src/classes/Command.ts @@ -17,11 +17,8 @@ export default class Command { executeAt?: 'guild' | 'dm' | 'both'; // eslint-disable-next-line @typescript-eslint/naming-convention __compiled__!: AsyncFunction; -<<<<<<< HEAD // eslint-disable-next-line @typescript-eslint/naming-convention __rawFnString__!: string; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb constructor(data: ICommandOptions, client: AoiClient) { this.name = data.name; @@ -49,7 +46,6 @@ export default class Command { this[key] = data[key]; } -<<<<<<< HEAD if (this.code instanceof Function) { this.__compiled__ = this.code; // get string representation of the function with the function name @@ -57,10 +53,6 @@ export default class Command { ${this.name}_func(__$DISCORD_DATA$__); `; } else { -======= - if (this.code instanceof Function) this.__compiled__ = this.code; - else { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb let channelId: Snowflake | undefined; if (this.channel) { if ( @@ -73,24 +65,17 @@ export default class Command { name: 'GLOBAL_CHANNEL', }, asFunction: false, -<<<<<<< HEAD command: this, -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }).result; } else channelId = this.channel; } -<<<<<<< HEAD -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const func = transpiler.transpile(this.code, { sendMessage: true, reverse: this.reverseRead, scopeData: { -<<<<<<< HEAD useChannel: channelId?.includes('__$DISCORD_DATA$__') ? escapeResult(channelId) : channelId, @@ -102,12 +87,6 @@ export default class Command { this.__compiled__ = func.func!; this.__rawFnString__ = func.result; -======= - useChannel: channelId?.includes('__$DISCORD_DATA$__') ? escapeResult(channelId) : channelId, - }, - }); - this.__compiled__ = func.func!; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } } diff --git a/lib/aoi.js/src/core/AoiReader.ts b/lib/aoi.js/src/core/AoiReader.ts index b1a5946be..5581dc812 100644 --- a/lib/aoi.js/src/core/AoiReader.ts +++ b/lib/aoi.js/src/core/AoiReader.ts @@ -1,17 +1,9 @@ -<<<<<<< HEAD import { BundlerCustoms, ErrorCode } from '@aoi.js/typings/enum.js'; import AoiError from './Error.js'; import { type ICommandOptions } from '@aoi.js/typings/interface.js'; import { type Optional } from '@aoi.js/typings/type.js'; import type AoiClient from '@aoi.js/classes/AoiClient.js'; import Command from '@aoi.js/classes/Command.js'; -======= -import { BundlerCustoms } from '@aoi.js/typings/enum.js'; -import { TranspilerError } from './Error.js'; -import { type ICommandOptions } from '@aoi.js/typings/interface.js'; -import { type Optional } from '@aoi.js/typings/type.js'; -import type AoiClient from '@aoi.js/classes/AoiClient.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export default class AoiReader { _parseEmbeddedJS(code: string) { @@ -58,15 +50,11 @@ export default class AoiReader { } if (cntr) { -<<<<<<< HEAD throw AoiError.ReaderError( ErrorCode.EmbedBracketsMismatch, 'Invalid embedded JS', code, ); -======= - throw TranspilerError.AoiReaderError('Invalid embedded JS', code); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } return embeds; @@ -152,24 +140,17 @@ export default class AoiReader { code = code.replace(`\${${ejs}}`, BundlerCustoms.EJS); } -<<<<<<< HEAD const cmd = new Command( { ...this._parseCmd(code), __path__: 'root' }, client, ); -======= - const cmd = this._parseCmd(code); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb cmd.code = client.transpiler.transpile(cmd.code as string, { scopeData: { embeddedJS: embeddedJS, }, sendMessage: true, reverse: cmd.reverseRead ?? false, -<<<<<<< HEAD command: cmd, -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }).func!; return cmd; diff --git a/lib/aoi.js/src/core/builders/Function.ts b/lib/aoi.js/src/core/builders/Function.ts index 64a776f63..fd06bb5a5 100644 --- a/lib/aoi.js/src/core/builders/Function.ts +++ b/lib/aoi.js/src/core/builders/Function.ts @@ -9,23 +9,16 @@ import { type ICodeFunctionData, type ITranspilerData, } from '@aoi.js/typings/interface.js'; -<<<<<<< HEAD import { type ProxyType, type FunctionCode, type CommandTypes, } from '@aoi.js/typings/type.js'; -======= -import { type ProxyType, type FunctionCode } from '@aoi.js/typings/type.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb import type Scope from './Scope.js'; import { inspect } from 'node:util'; import proxyBuilder from './typeProxy.js'; import { escapeVars } from '@aoi.js/utils/Helpers/core.js'; -<<<<<<< HEAD import type StringObject from './StringObject.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export default class FunctionBuilder implements IFunctionData { name!: string; @@ -109,14 +102,9 @@ export default class FunctionBuilder implements IFunctionData { } getParams(data: ICodeFunctionData): string[] { -<<<<<<< HEAD if (data.executed === '') return []; return data.fields.length === 1 && !this.#isReturnAnyOrArray(data.fields[0].type) -======= - return data.fields.length === 1 && - ![ReturnType.Any, ReturnType.Array].includes(data.fields[0].type) ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb ? [data.executed] : data.splits(); } @@ -182,16 +170,11 @@ export default class FunctionBuilder implements IFunctionData { let bodyWithoutArg = body.replace(matchWholeArgwithAsync, ''); -<<<<<<< HEAD // remove all //comments bodyWithoutArg = bodyWithoutArg.replace(/\/\/.*/g, ''); if (arg !== '') { bodyWithoutArg = this.#replaceArgInFunctionStringWithVar( -======= - if (arg !== '') { - bodyWithoutArg = this.#replaceArgInFunctionStringWithDiscord( ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb bodyWithoutArg, arg, ); @@ -206,11 +189,7 @@ export default class FunctionBuilder implements IFunctionData { const numbers = bodyWithoutBrackets.match(findNumbersRegex); if (!numbers) { -<<<<<<< HEAD return bodyWithoutBrackets.trim(); -======= - return bodyWithoutBrackets; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } let result = bodyWithoutBrackets; @@ -248,7 +227,6 @@ export default class FunctionBuilder implements IFunctionData { } } -<<<<<<< HEAD for( start: number, end: number, @@ -369,15 +347,5 @@ export default class FunctionBuilder implements IFunctionData { ((returnType & ReturnType.Any) as ReturnType) === ReturnType.Any || ((returnType & ReturnType.Array) as ReturnType) === ReturnType.Array ); -======= - #replaceArgInFunctionStringWithDiscord(func: string, arg: string) { - // it will replace all arg with __$DISCORD_DATA$__ and wont replace same word if it is a part of another word or a property - - const regex = new RegExp( - `(?>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } diff --git a/lib/aoi.js/src/core/builders/Scope.ts b/lib/aoi.js/src/core/builders/Scope.ts index abd46e177..3a3de1689 100644 --- a/lib/aoi.js/src/core/builders/Scope.ts +++ b/lib/aoi.js/src/core/builders/Scope.ts @@ -4,11 +4,7 @@ import { FunctionType, TranspilerCustoms, } from '@aoi.js/typings/enum.js'; -<<<<<<< HEAD import { type ICodeFunctionData, type IDateTimeOptions } from '@aoi.js/typings/interface.js'; -======= -import { type ICodeFunctionData } from '@aoi.js/typings/interface.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb import { escapeResult, escapeVars, @@ -29,10 +25,7 @@ export default class Scope { stickers: unknown[] = []; env: string[]; ephemeral = false; -<<<<<<< HEAD addExecutionTime = false; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb variables: string[]; setters: string; objects: Record; @@ -46,15 +39,12 @@ export default class Scope { useChannel?: bigint | string; embeddedJS: string[] = []; packages = ''; -<<<<<<< HEAD dateTimeOptions: IDateTimeOptions = { timezone: 'UTC', locale: 'en-US', hour12: false, }; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb client: AoiClient; constructor( name: string, @@ -201,10 +191,7 @@ export default class Scope { scope.useChannel = this.useChannel; scope.embeddedJS = this.embeddedJS; scope.packages = this.packages; -<<<<<<< HEAD scope.dateTimeOptions = this.dateTimeOptions; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb return scope; } @@ -223,20 +210,14 @@ export default class Scope { this.addReturn = this.addReturn || scope.addReturn; this.useChannel = scope.useChannel ?? this.useChannel; this.embeddedJS.push(...scope.embeddedJS); -<<<<<<< HEAD this.dateTimeOptions = { ...this.dateTimeOptions, ...scope.dateTimeOptions }; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb this.packages += scope.packages; } generate(code: string, sendMessage = true, asFunction = true) { if (sendMessage) for (const part of this._contentParts) { -<<<<<<< HEAD if (part.trim() === '') continue; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb code = code.replace(part, ''); } @@ -295,11 +276,7 @@ export default class Scope { this.hasSendData && sendMessage ? ` ${this.addReturn ? 'return ' : ''} await ${channelSendFunction}( ${payload} );` -<<<<<<< HEAD : `${this.addReturn ? 'return;' : ''}`; -======= - : ''; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const initialVars = sendMessage ? ` @@ -310,21 +287,15 @@ export default class Scope { ` : ''; -<<<<<<< HEAD const addExecution = this.addExecutionTime ? `let __$${this.name}_EXECUTION_TIME$__ = performance.now();` : ''; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb return parseResult( asFunction ? ` async function ${this.name === 'global' ? 'main' : this.name}(__$DISCORD_DATA$__) { -<<<<<<< HEAD ${addExecution} -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb ${initialVars} ${this.packages} ${this.functions} @@ -333,10 +304,7 @@ export default class Scope { } `.replaceAll(TranspilerCustoms.SL, '\\`') : ` -<<<<<<< HEAD ${addExecution} -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb ${initialVars} ${this.packages} ${this.functions} diff --git a/lib/aoi.js/src/core/builders/TextBlock.ts b/lib/aoi.js/src/core/builders/TextBlock.ts index e93c470c3..798858311 100644 --- a/lib/aoi.js/src/core/builders/TextBlock.ts +++ b/lib/aoi.js/src/core/builders/TextBlock.ts @@ -27,11 +27,7 @@ export default class TextBlock { this.text = this.text.replace(child.parsed, res); } -<<<<<<< HEAD return this.isMain ? `\`${this.text}\`` : this.parent?.isMain ? `\${${this.text}}` : this.text; -======= - return this.isMain ? `\`${this.text}\`` : `\${${this.text}}`; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } get parsed() { diff --git a/lib/aoi.js/src/core/builders/typeProxy.ts b/lib/aoi.js/src/core/builders/typeProxy.ts index 4fca78435..cef2d86d5 100644 --- a/lib/aoi.js/src/core/builders/typeProxy.ts +++ b/lib/aoi.js/src/core/builders/typeProxy.ts @@ -8,13 +8,8 @@ export default function proxyBuilder(variableName: string) { if (propKey === 'build') { return () => state; } -<<<<<<< HEAD // Dynamically handle method calls -======= - - // Dynamically handle method calls ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb return function (...args: any[]) { const argsStr = args .map((arg) => JSON.stringify(arg)) diff --git a/lib/aoi.js/src/core/parsers/condition.ts b/lib/aoi.js/src/core/parsers/condition.ts index 7dc948a8e..a738bb454 100644 --- a/lib/aoi.js/src/core/parsers/condition.ts +++ b/lib/aoi.js/src/core/parsers/condition.ts @@ -20,11 +20,7 @@ export function _areSmoothBracketsBalanced(condition: string) { export function parseCondition(condition: string) { if (condition.includes(TranspilerCustoms.FS)) { const matches = condition.match( -<<<<<<< HEAD /((#FUNCTION_START#([$a-z.0-9\s?(){}[\]._:'"`;=><,!\-`@/]|\n)+#FUNCTION_END#)|(__\$[a-z_?.()]+\$__))/gim, -======= - /((#FUNCTION_START#([$a-z.0-9\s?(){}[\]._:'"`;=><,!-]|\n)+#FUNCTION_END#)|(__\$[a-z_?.()]+\$__))/gim, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb ); if (matches) { diff --git a/lib/aoi.js/src/core/parsers/object.ts b/lib/aoi.js/src/core/parsers/object.ts index d41003a25..4d82c8caa 100644 --- a/lib/aoi.js/src/core/parsers/object.ts +++ b/lib/aoi.js/src/core/parsers/object.ts @@ -1,8 +1,4 @@ -<<<<<<< HEAD import { parseData, stringify } from '@aoi.js/utils/Helpers/core.js'; -======= -import { parseData } from '@aoi.js/utils/Helpers/core.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb import StringObject from '../builders/StringObject.js'; import { parseString } from './string.js'; import { TranspilerCustoms } from '@aoi.js/typings/enum.js'; @@ -28,7 +24,6 @@ export function _handleStringData(text: string, object: StringObject) { object.addValue(text); } -<<<<<<< HEAD export function _handleNonStringData(text: unknown, object: StringObject) { switch (typeof text) { case 'number': @@ -57,8 +52,6 @@ export function _handleNonStringData(text: unknown, object: StringObject) { } } -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export function _getObjectAst( objectString: string, currentObject: StringObject, @@ -75,20 +68,13 @@ export function _getObjectAst( currentObject = newObject; } else if (char === '}' || char === ']') { currentObject.addEnd(char); -<<<<<<< HEAD -======= - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (text.trim() !== '') { const t = parseData(text.trim()); if (typeof t === 'string') { _handleStringData(t, currentObject); text = ''; -<<<<<<< HEAD } else { _handleNonStringData(t, currentObject); -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } @@ -108,11 +94,8 @@ export function _getObjectAst( const t = parseData(text.trim()); if (typeof t === 'string') { _handleStringData(t, currentObject); -<<<<<<< HEAD } else { _handleNonStringData(t, currentObject); -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } text = ''; @@ -120,7 +103,6 @@ export function _getObjectAst( } else { text += char; } -<<<<<<< HEAD i++; } @@ -138,11 +120,6 @@ export function _getObjectAst( while (currentObject.parent) { currentObject.parent?.pushChild(currentObject); -======= - } - - while (currentObject.parent) { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb currentObject = currentObject.parent; } diff --git a/lib/aoi.js/src/core/parsers/string.ts b/lib/aoi.js/src/core/parsers/string.ts index b49f169ce..bc3364031 100644 --- a/lib/aoi.js/src/core/parsers/string.ts +++ b/lib/aoi.js/src/core/parsers/string.ts @@ -2,19 +2,11 @@ import { BundlerCustoms, TranspilerCustoms } from '@aoi.js/typings/enum.js'; import TextBlock from '../builders/TextBlock.js'; export function createStringAST(text: string) { -<<<<<<< HEAD - -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb let block = new TextBlock(0, true); let i = 0; let res = ''; -<<<<<<< HEAD while (i <= text.length) { -======= - while (i < text.length) { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (res.includes(TranspilerCustoms.FS)) { const child = new TextBlock(block.children.length, false, block); @@ -52,10 +44,7 @@ export function createStringAST(text: string) { res = text[i] ?? ''; } else { -<<<<<<< HEAD if (i === text.length) break; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb res += text[i] ?? ''; block.addText(text[i] ?? ''); } @@ -75,8 +64,4 @@ export function parseString(text: string) { return ast .parse() .replaceAll(BundlerCustoms.EJS, `\${${BundlerCustoms.EJS}`); -<<<<<<< HEAD -} -======= } ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/events/guildMessages/messageCreate.ts b/lib/aoi.js/src/events/guildMessages/messageCreate.ts index 46df73373..a31149583 100644 --- a/lib/aoi.js/src/events/guildMessages/messageCreate.ts +++ b/lib/aoi.js/src/events/guildMessages/messageCreate.ts @@ -6,16 +6,8 @@ import { safe } from '@aoi.js/utils/Helpers/core.js'; export async function _messageCreate(message: Message, bot: AoiClient) { let prefix: string | undefined; if (bot.options.prefix instanceof Array) { -<<<<<<< HEAD prefix = bot.options.prefix.find((p) => message.content.startsWith(p)); } else prefix = bot.options.prefix; -======= - prefix = bot.options.prefix.find((p) => - message.content.startsWith(p), - ); - } else prefix = bot.options.prefix; - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (!prefix) return; if (!message.content.startsWith(prefix)) return; @@ -40,21 +32,13 @@ export async function _messageCreate(message: Message, bot: AoiClient) { member: message.member ?? undefined, }, }) -<<<<<<< HEAD .catch((err: unknown) => { return new Error(err as string); -======= - - .catch((e) => { - if (e.component && !e.success) return; - else bot.client.emit(AoiClientEvents.Error, e); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); } export default function onMessageCreate(bot: AoiClient) { bot.client.on('messageCreate', async (message) => { -<<<<<<< HEAD const res = await safe(_messageCreate(message, bot)); if (!res.success) { @@ -62,12 +46,6 @@ export default function onMessageCreate(bot: AoiClient) { AoiClientEvents.Error, `An error occurred while executing the message event:${res.error as string}`, ); -======= - const [error] = await safe(_messageCreate(message, bot)); - - if (error) { - bot.client.emit(AoiClientEvents.Error, 'An error occurred while executing the message event'); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } }); } diff --git a/lib/aoi.js/src/events/nonIntents/onReady.ts b/lib/aoi.js/src/events/nonIntents/onReady.ts index d911b716c..07b959345 100644 --- a/lib/aoi.js/src/events/nonIntents/onReady.ts +++ b/lib/aoi.js/src/events/nonIntents/onReady.ts @@ -15,15 +15,9 @@ export async function _ready(bot: AoiClient) { export default function onReady(bot: AoiClient) { bot.client.on('ready', async () => { -<<<<<<< HEAD const res = await safe(_ready(bot)); if (!res.success) { -======= - const [error] = await safe(_ready(bot)); - - if (error) { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb bot.client.emit(AoiClientEvents.Error, 'An error occurred while executing the ready event'); } }); diff --git a/lib/aoi.js/src/functions/discord/channel/$channelid.ts b/lib/aoi.js/src/functions/discord/channel/$channelid.ts index c1ce62e30..0f80132bf 100644 --- a/lib/aoi.js/src/functions/discord/channel/$channelid.ts +++ b/lib/aoi.js/src/functions/discord/channel/$channelid.ts @@ -3,7 +3,6 @@ import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; import { ChannelType } from 'discord.js'; -<<<<<<< HEAD /** * Returns the id of the channel. * @example @@ -18,9 +17,6 @@ import { ChannelType } from 'discord.js'; * ``` */ const $channelid = new FunctionBuilder() -======= -const $channelId = new FunctionBuilder() ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb .setName('$channelid') .setType(FunctionType.Getter) .setReturns(ReturnType.String | ReturnType.Void) @@ -65,8 +61,4 @@ const $channelId = new FunctionBuilder() }) .build(); -<<<<<<< HEAD export { $channelid }; -======= -export { $channelId }; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/functions/discord/client/$ping.ts b/lib/aoi.js/src/functions/discord/client/$ping.ts index f015991fe..afa755a09 100644 --- a/lib/aoi.js/src/functions/discord/client/$ping.ts +++ b/lib/aoi.js/src/functions/discord/client/$ping.ts @@ -2,7 +2,6 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; -<<<<<<< HEAD /** * Returns the ping of the bot. * @example @@ -15,8 +14,6 @@ import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; * $ping // Returns the ping of the bot * ``` */ -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const $ping = new FunctionBuilder() .setName('$ping') .setBrackets(false) diff --git a/lib/aoi.js/src/functions/discord/index.ts b/lib/aoi.js/src/functions/discord/index.ts index 80204375c..364db21b4 100644 --- a/lib/aoi.js/src/functions/discord/index.ts +++ b/lib/aoi.js/src/functions/discord/index.ts @@ -1,9 +1,5 @@ export * from './client/index.js'; export * from './guild/index.js'; -<<<<<<< HEAD export * from './channel/index.js'; export * from './message/index.js'; export * from './user/index.js'; -======= -export * from './channel/index.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/functions/js/conditions/$and.test.ts b/lib/aoi.js/src/functions/js/conditions/$and.test.ts index c9f36cc68..a59386ee0 100644 --- a/lib/aoi.js/src/functions/js/conditions/$and.test.ts +++ b/lib/aoi.js/src/functions/js/conditions/$and.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $and } from './$and.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $and }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToFail = '$and'; @@ -40,10 +30,6 @@ const codeToFalse = '$and[1==1;2==3]'; void describe('$and', () => { void it('should not compile successfully without arg', () => { -<<<<<<< HEAD -======= - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // expect this to throw an error assert.throws(() => { client.transpiler.transpile(codeToFail, transpilerOptions); diff --git a/lib/aoi.js/src/functions/js/conditions/$and.ts b/lib/aoi.js/src/functions/js/conditions/$and.ts index 53cdf3e96..bc42fef98 100644 --- a/lib/aoi.js/src/functions/js/conditions/$and.ts +++ b/lib/aoi.js/src/functions/js/conditions/$and.ts @@ -3,7 +3,6 @@ import { parseCondition } from '@aoi.js/core/parsers/condition.js'; import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeResult, parseResult } from '@aoi.js/utils/Helpers/core.js'; -<<<<<<< HEAD /** * returns true if all conditions are true * @example @@ -17,8 +16,6 @@ import { escapeResult, parseResult } from '@aoi.js/utils/Helpers/core.js'; * $and[1==1;2==3] // returns false * ``` */ -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const $and = new FunctionBuilder() .setName('$and') .setBrackets(true) @@ -27,11 +24,7 @@ const $and = new FunctionBuilder() .setFields([ { name: 'conditions', -<<<<<<< HEAD type: ReturnType.Array | ReturnType.Boolean, -======= - type: ReturnType.Array, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb required: true, description: 'conditions to check', }, diff --git a/lib/aoi.js/src/functions/js/conditions/$or.test.ts b/lib/aoi.js/src/functions/js/conditions/$or.test.ts index 63d905168..173c26db9 100644 --- a/lib/aoi.js/src/functions/js/conditions/$or.test.ts +++ b/lib/aoi.js/src/functions/js/conditions/$or.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $or } from './$or.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $or }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToFail = '$or'; @@ -40,10 +30,6 @@ const codeToFalse = '$or[1==2;2==3]'; void describe('$or', () => { void it('should not compile successfully without arg', () => { -<<<<<<< HEAD -======= - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // expect this to throw an error assert.throws(() => { client.transpiler.transpile(codeToFail, transpilerOptions); diff --git a/lib/aoi.js/src/functions/js/conditions/$or.ts b/lib/aoi.js/src/functions/js/conditions/$or.ts index e51dad5b6..cc535b480 100644 --- a/lib/aoi.js/src/functions/js/conditions/$or.ts +++ b/lib/aoi.js/src/functions/js/conditions/$or.ts @@ -3,7 +3,6 @@ import { parseCondition } from '@aoi.js/core/parsers/condition.js'; import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeResult, parseResult } from '@aoi.js/utils/Helpers/core.js'; -<<<<<<< HEAD /** * Checks if any of the conditions are true * @example @@ -17,8 +16,6 @@ import { escapeResult, parseResult } from '@aoi.js/utils/Helpers/core.js'; * $or[1 == 2; 2 == 3] // Returns false * ``` */ -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const $or = new FunctionBuilder() .setName('$or') .setBrackets(true) diff --git a/lib/aoi.js/src/functions/js/index.ts b/lib/aoi.js/src/functions/js/index.ts index 770a56212..91daed7ce 100644 --- a/lib/aoi.js/src/functions/js/index.ts +++ b/lib/aoi.js/src/functions/js/index.ts @@ -1,11 +1,7 @@ export * from './misc/index.js'; export * from './process/index.js'; -<<<<<<< HEAD export * from './math/index.js'; export * from './conditions/index.js'; export * from './loops/index.js'; export * from './objects/index.js'; export * from './conversions/index.js'; -======= -export * from './math/index.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/functions/js/math/$abbreviate.test.ts b/lib/aoi.js/src/functions/js/math/$abbreviate.test.ts index 6acf24519..c3b825865 100644 --- a/lib/aoi.js/src/functions/js/math/$abbreviate.test.ts +++ b/lib/aoi.js/src/functions/js/math/$abbreviate.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $abbreviate } from './$abbreviate.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $abbreviate }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToFail = '$abbreviate'; @@ -56,18 +46,10 @@ void describe('$abbreviate', () => { void it('should return 2.00K', async () => { // logs true const orignalLog = console.log; -<<<<<<< HEAD let logged: unknown; console.log = (log: Record) => { logged = client.parseData(log.content, $abbreviate.returns); -======= - let logged: Record = { content: 'hi' }; - - console.log = (log: Record) => { - logged = log; - // orignalLog(log); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const { func } = client.transpiler.transpile(codeToValue, transpilerOptions); @@ -77,27 +59,16 @@ void describe('$abbreviate', () => { console.log = orignalLog; -<<<<<<< HEAD assert.strictEqual(logged, '2.00K'); -======= - assert.strictEqual(logged.content.toString(), '2.00K'); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); void it('should return 2K', async () => { // logs false const orignalLog = console.log; -<<<<<<< HEAD let logged: unknown; console.log = (log: Record) => { logged = client.parseData(log.content, $abbreviate.returns); -======= - let logged: Record = { content: 'hi' }; - - console.log = (log: Record) => { - logged = log; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // orignalLog(log); }; @@ -108,10 +79,6 @@ void describe('$abbreviate', () => { console.log = orignalLog; -<<<<<<< HEAD assert.strictEqual(logged, '2K'); -======= - assert.strictEqual(logged.content.toString(), '2K'); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); }); diff --git a/lib/aoi.js/src/functions/js/math/$abbreviate.ts b/lib/aoi.js/src/functions/js/math/$abbreviate.ts index 8aaed7fc3..46fbaa739 100644 --- a/lib/aoi.js/src/functions/js/math/$abbreviate.ts +++ b/lib/aoi.js/src/functions/js/math/$abbreviate.ts @@ -1,59 +1,9 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; -<<<<<<< HEAD import AoiError from '@aoi.js/core/Error.js'; import { ErrorCode, FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; import { abbreviate } from '@aoi.js/utils/Helpers/functions.js'; -======= -import { TranspilerError } from '@aoi.js/core/Error.js'; -import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; -import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; - -function _abbreviate(number: number, decimal: number) { - const SI_SYMBOLS = [ - '', - 'K', - 'M', - 'B', - 'T', - 'Qa', - 'Qi', - 'Sx', - 'Sp', - 'Oc', - 'No', - 'Dc', - 'Udc', - 'Ddc', - 'Tdc', - 'Qadc', - 'Qidc', - 'Sxdc', - 'Spdc', - 'Ocdc', - 'Nmdc', - 'Vg', - 'Uvg', - 'Dvg', - 'Tvg', - 'Qavg', - 'Qvg', - 'Sxvg', - 'Spvg', - 'Ovg', - 'Nvg', - 'Tg', - ] as const; - - const tier = Math.floor(Math.log10(Math.abs(number || 1)) / 3); - if (tier === 0) return number; - const suffix = SI_SYMBOLS[tier]; - const scale = Math.pow(10, tier * 3); - const scaled = number / scale; - return scaled.toFixed(decimal) + suffix; -} ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb /** * Returns the abbreviation of provided value to decimal place * @example @@ -89,11 +39,7 @@ const $abbreviate = new FunctionBuilder() .setType(FunctionType.FunctionGetter) .setCode((data, scopes, thisArg) => { const currentScope = thisArg.getCurrentScope(scopes); -<<<<<<< HEAD const [number, decimals = '2'] = thisArg.getParams(data); -======= - const [number, decimals] = thisArg.getParams(data); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const parsedDecimal = Number(decimals ?? 2); const parsedNumber = Number(number); @@ -102,14 +48,9 @@ const $abbreviate = new FunctionBuilder() isNaN(parsedNumber) && !thisArg.canSuppressAtComp(data, currentScope) ) { -<<<<<<< HEAD throw AoiError.FunctionError( ErrorCode.InvalidArgumentType, `Provided number argument is not a number, received ${number}`, -======= - throw TranspilerError.CompileError( - `Provided number is not a number, received ${number}`, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb data, ); } @@ -118,28 +59,17 @@ const $abbreviate = new FunctionBuilder() isNaN(parsedDecimal) && !thisArg.canSuppressAtComp(data, currentScope) ) { -<<<<<<< HEAD throw AoiError.FunctionError( ErrorCode.InvalidArgumentType, -======= - throw TranspilerError.CompileError( ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb `Provided number is not a valid decimal position, received ${decimals}`, data, ); } -<<<<<<< HEAD thisArg.addFunction(currentScope, abbreviate); const resultString = thisArg.getResultString( // @ts-expect-error - intended behaviour () => abbreviate('$0', '$1'), -======= - thisArg.addFunction(currentScope, _abbreviate); - const resultString = thisArg.getResultString( - // @ts-expect-error - intended behaviour - () => _abbreviate('$0', '$1'), ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb [parsedNumber.toString(), parsedDecimal.toString()], ); diff --git a/lib/aoi.js/src/functions/js/math/$abs.test.ts b/lib/aoi.js/src/functions/js/math/$abs.test.ts index c791ed20c..830f3c2ef 100644 --- a/lib/aoi.js/src/functions/js/math/$abs.test.ts +++ b/lib/aoi.js/src/functions/js/math/$abs.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $abs } from './$abs.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $abs }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToFail = '$abs'; @@ -56,18 +46,10 @@ void describe('$abs', () => { void it('should return 200 for 200', async () => { // logs true const orignalLog = console.log; -<<<<<<< HEAD let logged: unknown; console.log = (log: Record) => { logged = client.parseData(log.content, $abs.returns); -======= - let logged: Record = { content: 'hi' }; - - console.log = (log: Record) => { - logged = log; - // orignalLog(log); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const { func } = client.transpiler.transpile(codeWithPositive, transpilerOptions); @@ -77,28 +59,16 @@ void describe('$abs', () => { console.log = orignalLog; -<<<<<<< HEAD assert.strictEqual(logged, 200); -======= - assert.strictEqual(logged.content.toString(), '200'); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); void it('should return 200 for -200', async () => { // logs false const orignalLog = console.log; -<<<<<<< HEAD let logged: unknown; console.log = (log: Record) => { logged = client.parseData(log.content, $abs.returns); -======= - let logged: Record = { content: 'hi' }; - - console.log = (log: Record) => { - logged = log; - // orignalLog(log); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const { func } = client.transpiler.transpile(codeWithNegative, transpilerOptions); @@ -108,10 +78,6 @@ void describe('$abs', () => { console.log = orignalLog; -<<<<<<< HEAD assert.strictEqual(logged, 200); -======= - assert.strictEqual(logged.content.toString(), -200); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); }); diff --git a/lib/aoi.js/src/functions/js/math/$abs.ts b/lib/aoi.js/src/functions/js/math/$abs.ts index b594991f4..7911cc6b4 100644 --- a/lib/aoi.js/src/functions/js/math/$abs.ts +++ b/lib/aoi.js/src/functions/js/math/$abs.ts @@ -1,5 +1,4 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; -<<<<<<< HEAD import AoiError from '@aoi.js/core/Error.js'; import { ErrorCode, FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeMathResult, escapeResult } from '@aoi.js/utils/Helpers/core.js'; @@ -17,12 +16,6 @@ import { escapeMathResult, escapeResult } from '@aoi.js/utils/Helpers/core.js'; * $abs[5] // Returns 5 * ``` */ -======= -import { TranspilerError } from '@aoi.js/core/Error.js'; -import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; -import { escapeMathResult, escapeResult } from '@aoi.js/utils/Helpers/core.js'; - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const $abs = new FunctionBuilder() .setName('$abs') .setBrackets(true) @@ -47,14 +40,9 @@ const $abs = new FunctionBuilder() isNaN(parsedNumber) && !thisArg.canSuppressAtComp(data, currentScope) ) { -<<<<<<< HEAD throw AoiError.FunctionError( ErrorCode.InvalidArgumentType, `Provided argument is not a number, received ${number}`, -======= - throw TranspilerError.CompileError( - `Provided number is not a number, received ${number}`, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb data, ); } diff --git a/lib/aoi.js/src/functions/js/math/$math.test.ts b/lib/aoi.js/src/functions/js/math/$math.test.ts index 060b3e3aa..1c8275323 100644 --- a/lib/aoi.js/src/functions/js/math/$math.test.ts +++ b/lib/aoi.js/src/functions/js/math/$math.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $math } from './$math.js'; -<<<<<<< HEAD import TestCommand from '@aoi.js/testing/testCommand.js'; import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $math }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToFail = '$math'; @@ -65,17 +55,10 @@ void describe('$math', () => { void it('should return 998 for 2000/2+2-2*2', async () => { // logs true const orignalLog = console.log; -<<<<<<< HEAD let logged: unknown; console.log = (log: Record) => { logged = client.parseData(log.content, $math.returns); -======= - let logged: Record = { content: 'hi' }; - - console.log = (log: Record) => { - logged = log; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // orignalLog(log); }; @@ -86,27 +69,16 @@ void describe('$math', () => { console.log = orignalLog; -<<<<<<< HEAD assert.strictEqual(logged, 998); -======= - assert.strictEqual(logged.content.toString(), '998'); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); void it('should return 1 for pow(sin(90), 2) + pow(cos(90), 2)', async () => { // logs false const orignalLog = console.log; -<<<<<<< HEAD let logged: unknown; console.log = (log: Record) => { logged = client.parseData(log.content, $math.returns); -======= - let logged: Record = { content: 'hi' }; - - console.log = (log: Record) => { - logged = log; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // orignalLog(log); }; @@ -117,10 +89,6 @@ void describe('$math', () => { console.log = orignalLog; -<<<<<<< HEAD assert.strictEqual(logged, 1); -======= - assert.strictEqual(logged.content.toString(), '1'); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); }); diff --git a/lib/aoi.js/src/functions/js/math/$math.ts b/lib/aoi.js/src/functions/js/math/$math.ts index 300f39ddf..daafc259a 100644 --- a/lib/aoi.js/src/functions/js/math/$math.ts +++ b/lib/aoi.js/src/functions/js/math/$math.ts @@ -1,5 +1,4 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; -<<<<<<< HEAD import AoiError from '@aoi.js/core/Error.js'; import { ErrorCode, FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeMathResult, escapeResult, parseResult } from '@aoi.js/utils/Helpers/core.js'; @@ -18,13 +17,6 @@ import { isMathExpression } from '@aoi.js/utils/Helpers/functions.js'; * $math[ sin(90) ] // Returns 1 * ``` */ -======= -import { TranspilerError } from '@aoi.js/core/Error.js'; -import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; -import { escapeMathResult, escapeResult, parseResult } from '@aoi.js/utils/Helpers/core.js'; -import { isMathExpression } from '@aoi.js/utils/Helpers/functions.js'; - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const $math = new FunctionBuilder() .setName('$math') .setType(FunctionType.Getter) @@ -47,12 +39,8 @@ const $math = new FunctionBuilder() !mathExpression && !thisArg.canSuppressAtComp(data, thisArg.getCurrentScope(scopes)) ) { -<<<<<<< HEAD throw AoiError.FunctionError( ErrorCode.MissingParameter, -======= - throw TranspilerError.CompileError( ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb 'No math expression provided.', data, ); @@ -62,12 +50,8 @@ const $math = new FunctionBuilder() !isMathExpression(mathExpression) && !thisArg.canSuppressAtComp(data, thisArg.getCurrentScope(scopes)) ) { -<<<<<<< HEAD throw AoiError.FunctionError( ErrorCode.InvalidArgumentType, -======= - throw TranspilerError.CompileError( ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb 'Invalid math expression provided.', data, ); @@ -81,12 +65,8 @@ const $math = new FunctionBuilder() .replaceAll('EULERNUM', 'Math.E'); if (!math && !thisArg.canSuppressAtComp(data, thisArg.getCurrentScope(scopes))) { -<<<<<<< HEAD throw AoiError.FunctionError( ErrorCode.InvalidArgumentType, -======= - throw TranspilerError.CompileError( ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb 'Invalid math expression provided.', data, ); diff --git a/lib/aoi.js/src/functions/js/math/index.ts b/lib/aoi.js/src/functions/js/math/index.ts index 5e607eb83..8ce52b8cd 100644 --- a/lib/aoi.js/src/functions/js/math/index.ts +++ b/lib/aoi.js/src/functions/js/math/index.ts @@ -1,6 +1,5 @@ export * from './$abbreviate.js'; export * from './$abs.js'; -<<<<<<< HEAD export * from './$math.js'; export * from './$divide.js'; export * from './$modulo.js'; @@ -17,6 +16,3 @@ export * from './$random.js'; export * from './$min.js'; export * from './$max.js'; export * from './$avg.js'; -======= -export * from './$math.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/functions/js/misc/$let.test.ts b/lib/aoi.js/src/functions/js/misc/$let.test.ts index 36f850961..39b73610a 100644 --- a/lib/aoi.js/src/functions/js/misc/$let.test.ts +++ b/lib/aoi.js/src/functions/js/misc/$let.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $let } from './$let.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $let }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToFail = '$let'; diff --git a/lib/aoi.js/src/functions/js/misc/$let.ts b/lib/aoi.js/src/functions/js/misc/$let.ts index de8dfcdb9..52ee4b4ce 100644 --- a/lib/aoi.js/src/functions/js/misc/$let.ts +++ b/lib/aoi.js/src/functions/js/misc/$let.ts @@ -1,5 +1,4 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; -<<<<<<< HEAD import AoiError from '@aoi.js/core/Error.js'; import { parseString } from '@aoi.js/core/parsers/string.js'; import { @@ -13,33 +12,18 @@ import { parseData, stringify, } from '@aoi.js/utils/Helpers/core.js'; -======= -import { TranspilerError } from '@aoi.js/core/Error.js'; -import { parseString } from '@aoi.js/core/parsers/string.js'; -import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; -import { escapeResult, parseData, stringify } from '@aoi.js/utils/Helpers/core.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb /** * define a variable with a value * @example * ```aoi * --- -<<<<<<< HEAD * name: letget * type: basic * --- * * $let[v;value] * $get[v] // returns value -======= - * name: let - * type: basic - * --- - * - * $let[variable;value] - * $get[variable] // value ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb * ``` */ const $let = new FunctionBuilder() @@ -65,7 +49,6 @@ const $let = new FunctionBuilder() .setCode((data, scopes, thisArg) => { const currentScope = thisArg.getCurrentScope(scopes); const [variable, value] = data.splits(); -<<<<<<< HEAD if (!variable && !thisArg.canSuppressAtComp(data, currentScope)) { throw AoiError.FunctionError( @@ -108,27 +91,6 @@ const $let = new FunctionBuilder() currentScope.hasVariable(variable), ); -======= - - if (!variable && !thisArg.canSuppressAtComp(data, currentScope)) { - throw TranspilerError.CompileError('Variable name not provided.', data); - } - - if (!value && !thisArg.canSuppressAtComp(data, currentScope)) { - throw TranspilerError.CompileError('Value not provided.', data); - } - - let parsedValue = parseData(value); - - if (typeof parsedValue === 'string') { - parsedValue = parseString(parsedValue); - } else { - parsedValue = stringify(parsedValue); - } - - const result = thisArg.defineVar(variable, parsedValue, currentScope.hasVariable(variable)); - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (!currentScope.hasVariable(variable)) { currentScope.addVariables(variable); } @@ -143,7 +105,3 @@ const $let = new FunctionBuilder() .build(); export { $let }; -<<<<<<< HEAD -======= - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/functions/js/misc/index.ts b/lib/aoi.js/src/functions/js/misc/index.ts index 7633474a1..28c51e226 100644 --- a/lib/aoi.js/src/functions/js/misc/index.ts +++ b/lib/aoi.js/src/functions/js/misc/index.ts @@ -1,4 +1,3 @@ -<<<<<<< HEAD export * from './$let.js'; export * from './$log.js'; export * from './$env.js'; @@ -19,6 +18,3 @@ export * from './$executiontime.js'; export * from './$inc.js'; export * from './$passeddata.js'; export * from './$execute.js'; -======= -export * from './$let.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/functions/js/process/$cpu.test.ts b/lib/aoi.js/src/functions/js/process/$cpu.test.ts index 4cdd98a7b..ec015c4f8 100644 --- a/lib/aoi.js/src/functions/js/process/$cpu.test.ts +++ b/lib/aoi.js/src/functions/js/process/$cpu.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $cpu } from './$cpu.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $cpu }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToPassWithoutArg = '$cpu'; diff --git a/lib/aoi.js/src/functions/js/process/$cpu.ts b/lib/aoi.js/src/functions/js/process/$cpu.ts index e6fd343a6..a125fe062 100644 --- a/lib/aoi.js/src/functions/js/process/$cpu.ts +++ b/lib/aoi.js/src/functions/js/process/$cpu.ts @@ -1,11 +1,6 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; -<<<<<<< HEAD import AoiError from '@aoi.js/core/Error.js'; import { ErrorCode, FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; -======= -import { TranspilerError } from '@aoi.js/core/Error.js'; -import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; import type os from 'os'; @@ -48,35 +43,15 @@ const $cpu = new FunctionBuilder() !['process', 'os'].includes(type) && !thisArg.canSuppressAtComp(data, currentScope) ) { -<<<<<<< HEAD throw AoiError.FunctionError(ErrorCode.InvalidArgumentType, `Invalid CPU type: ${type}`, data); -======= - throw TranspilerError.CompileError(`Invalid CPU type: ${type}`, data); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } if (!currentScope.hasPkg('OS')) { currentScope.addPkg('OS', 'const OS = await import("os")'); } -<<<<<<< HEAD // placeholder for the actual module const OS = thisArg.as('OS'); -======= - - if (!currentScope.hasPkg('TRANSPILE_ERROR')) { - currentScope.addPkg( - 'TRANSPILE_ERROR', - 'const TRANSPILE_ERROR = await import("aoi.js/core/Error.js")', - ); - } - - // placeholder for the actual module - const OS = thisArg.as('OS'); - const TRANSPILE_ERROR = - thisArg.as('TRANSPILE_ERROR'); - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb function secNSec2ms(secNSec: number | number[]) { if (Array.isArray(secNSec)) { return secNSec[0] * 1000 + secNSec[1] / 1000000; @@ -106,14 +81,6 @@ const $cpu = new FunctionBuilder() return cpuPercent; } else if (type === 'os') { return ((OS.loadavg()[0] * 100) / OS.cpus().length).toFixed(2); -<<<<<<< HEAD -======= - } else { - throw TRANSPILE_ERROR.RunTimeError( - `Invalid CPU type: ${type}`, - data, - ) as TranspilerError; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } diff --git a/lib/aoi.js/src/functions/js/process/$cwd.test.ts b/lib/aoi.js/src/functions/js/process/$cwd.test.ts index 003adfa88..59fdcd120 100644 --- a/lib/aoi.js/src/functions/js/process/$cwd.test.ts +++ b/lib/aoi.js/src/functions/js/process/$cwd.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $cwd } from './$cwd.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $cwd }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,13 +19,8 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), }; -======= -}; - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const codeToPassWithoutArg = '$cwd'; diff --git a/lib/aoi.js/src/functions/js/process/$procenv.test.ts b/lib/aoi.js/src/functions/js/process/$procenv.test.ts index acc9c2449..b4d5cf2ee 100644 --- a/lib/aoi.js/src/functions/js/process/$procenv.test.ts +++ b/lib/aoi.js/src/functions/js/process/$procenv.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $procenv } from './$procenv.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $procenv }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToPassWithoutArg = '$procenv'; diff --git a/lib/aoi.js/src/functions/js/process/$procenv.ts b/lib/aoi.js/src/functions/js/process/$procenv.ts index 7ea38deef..52d0e95cb 100644 --- a/lib/aoi.js/src/functions/js/process/$procenv.ts +++ b/lib/aoi.js/src/functions/js/process/$procenv.ts @@ -43,11 +43,7 @@ const $procenv = new FunctionBuilder() }; } -<<<<<<< HEAD const result = thisArg.getResultString(() => process.env['"$0"'], [key]); -======= - const result = thisArg.getResultString(() => process.env.$0, [key]); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const escaped = escapeResult(result); diff --git a/lib/aoi.js/src/functions/js/process/$ram.test.ts b/lib/aoi.js/src/functions/js/process/$ram.test.ts index 4c64b4cbc..9cbdfb15e 100644 --- a/lib/aoi.js/src/functions/js/process/$ram.test.ts +++ b/lib/aoi.js/src/functions/js/process/$ram.test.ts @@ -3,20 +3,13 @@ import assert from 'node:assert'; import TestClient from '@aoi.js/testing/testClient.js'; import { $ram } from './$ram.js'; -<<<<<<< HEAD import type { ITranspileOptions } from '@aoi.js/typings/interface.js'; import TestCommand from '@aoi.js/testing/testCommand.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const client = new TestClient(); client.transpiler.addFunctions({ $ram }); -<<<<<<< HEAD const transpilerOptions: ITranspileOptions = { -======= -const transpilerOptions = { ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb scopeData: { name: 'global', vars: [], @@ -26,10 +19,7 @@ const transpilerOptions = { embeddedJS: [], sendFunction: 'console.log', }, -<<<<<<< HEAD command: new TestCommand(client), -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }; const codeToPassWithoutArg = '$ram'; diff --git a/lib/aoi.js/src/functions/js/process/$ram.ts b/lib/aoi.js/src/functions/js/process/$ram.ts index 5ba98b1a3..dcce18fad 100644 --- a/lib/aoi.js/src/functions/js/process/$ram.ts +++ b/lib/aoi.js/src/functions/js/process/$ram.ts @@ -1,5 +1,4 @@ import FunctionBuilder from '@aoi.js/core/builders/Function.js'; -<<<<<<< HEAD import AoiError from '@aoi.js/core/Error.js'; import { ErrorCode, FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; @@ -16,12 +15,6 @@ const units = { yb: 1024 ** 8, } as const; -======= -import { TranspilerError } from '@aoi.js/core/Error.js'; -import { FunctionType, ReturnType } from '@aoi.js/typings/enum.js'; -import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb /** * Returns the memory usage of the process for given type. * @example @@ -30,11 +23,7 @@ import { escapeResult } from '@aoi.js/utils/Helpers/core.js'; * name: ram * type: basic * --- -<<<<<<< HEAD * -======= - * ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb * $ram // returns heapUsed * $ram[heapTotal] // returns heapTotal * $ram[rss] // returns rss @@ -52,7 +41,6 @@ const $ram = new FunctionBuilder() name: 'type', type: ReturnType.String, required: false, -<<<<<<< HEAD description: 'The type of memory to get. Can be `heapUsed`, `heapTotal`, `rss`, `external`, `arrayBuffers`.', }, @@ -68,23 +56,11 @@ const $ram = new FunctionBuilder() const currentScope = thisArg.getCurrentScope(scopes); let [type, unit] = thisArg.getParams(data); -======= - description: 'The type of memory to get. Can be `heapUsed`, `heapTotal`, `rss`, `external`, `arrayBuffers`.', - - }, - ]) - .setReturns(ReturnType.String) - .setCode((data, scopes, thisArg) => { - const currentScope = thisArg.getCurrentScope(scopes); - let [type] = thisArg.getParams(data); - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (!type) { type = 'heapUsed'; } if ( -<<<<<<< HEAD ![ 'heapUsed', 'heapTotal', @@ -121,20 +97,6 @@ const $ram = new FunctionBuilder() // @ts-ignore () => process.memoryUsage()['"$0"'] / '$1', [type, units[unit as keyof typeof units ].toString()], -======= - !['heapUsed', 'heapTotal', 'rss', 'external', 'arrayBuffers'].includes(type) && - !thisArg.canSuppressAtComp(data, currentScope) - ) { - throw TranspilerError.CompileError(`Invalid memory type: ${type}`, data); - } - - const result = thisArg.getResultString( - // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error, @typescript-eslint/ban-ts-comment - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-return - () => process.memoryUsage()['"$0"'], - [type], ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb ); const escaped = escapeResult(result); @@ -146,8 +108,4 @@ const $ram = new FunctionBuilder() }) .build(); -<<<<<<< HEAD -export { $ram }; -======= export { $ram }; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/managers/Command.ts b/lib/aoi.js/src/managers/Command.ts index 44fc94ff0..e9d2c7eed 100644 --- a/lib/aoi.js/src/managers/Command.ts +++ b/lib/aoi.js/src/managers/Command.ts @@ -9,11 +9,8 @@ import fs, { readFile } from 'fs/promises'; import type AoiClient from '@aoi.js/classes/AoiClient.js'; import Path from 'path'; import AoiReader from '@aoi.js/core/AoiReader.js'; -<<<<<<< HEAD import AoijsErrorHandler from '@aoi.js/core/Error.js'; import { ErrorCode } from '@aoi.js/typings/enum.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export class CommandManager { static cmdTypes() { @@ -24,10 +21,6 @@ export class CommandManager { interaction: Group = new Group(Infinity); ready: Group = new Group(Infinity); debug: Group = new Group(Infinity); -<<<<<<< HEAD -======= - component: Group = new Group(Infinity); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb readonly #client: AoiClient; readonly #reader: AoiReader; @@ -49,7 +42,6 @@ export class CommandManager { if (!command.type) throw new Error('Command type is required'); if (!command.__path__) command.__path__ = 'root'; const cmd = new Command(command as ICommandOptions, this.#client); -<<<<<<< HEAD if (this.isValidType(command.type)) { this[command.type].set(this[command.type].size, cmd); } else { @@ -58,22 +50,6 @@ export class CommandManager { 'Invalid command type provided', cmd, ); -======= - if (this.isValidType(command.type) && command.type !== 'component') { - - this[command.type].set(this[command.type].size, cmd); - } else { - if (command.type === 'component') - - this.component.set(command.name, cmd); - else { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - //@ts-expect-error - throw new Error('Invalid command type provided', { - ...command, - }); - } ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } @@ -147,14 +123,10 @@ export class CommandManager { ) { const command = await readFile(filePath, 'utf-8'); try { -<<<<<<< HEAD const cmd = this.#reader.parse( command, this.#client, ); -======= - const cmd = this.#reader.parse(command, this.#client); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb cmd.__path__ = filePath; this.add(cmd as ICommandOptions); commands.push({ @@ -178,7 +150,6 @@ export class CommandManager { } const box = boxen( -<<<<<<< HEAD `${commands .map((cmd) => { return `∷ ${chalk.cyanBright( @@ -188,15 +159,6 @@ export class CommandManager { )}`; }) .join('\n')} -======= - `${commands.map((cmd) => { - return `∷ ${chalk.cyanBright( - cmd.loaded ? 'Loaded' : 'Failed', - )} ${chalk.greenBright(cmd.path)} ${chalk.redBright( - cmd.loaded ? '' : cmd.reason, - )}`; - }).join('\n')} ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb `, { title: `∴ Loading ${chalk.blueBright( @@ -237,15 +199,11 @@ export class CommandManager { } async loadFile(filePath: string) { -<<<<<<< HEAD let command: { default: | Optional | Array>; }; -======= - let command: { default: Optional | Array> }; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb try { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports command = require(filePath); diff --git a/lib/aoi.js/src/testing/testClient.ts b/lib/aoi.js/src/testing/testClient.ts index f42796de8..92a34965d 100644 --- a/lib/aoi.js/src/testing/testClient.ts +++ b/lib/aoi.js/src/testing/testClient.ts @@ -1,5 +1,4 @@ import AoiClient from '@aoi.js/classes/AoiClient.js'; -<<<<<<< HEAD import { ReturnType } from '@aoi.js/typings/enum.js'; import JSON5 from 'json5'; @@ -21,14 +20,6 @@ class TestClient extends AoiClient { default: return output; } } -======= - -class TestClient extends AoiClient { - constructor() { - super({ testMode: true, token: 'token.a.b', 'intents': 0, prefix: '!', events: [] }); - // code... - } ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } export default TestClient; \ No newline at end of file diff --git a/lib/aoi.js/src/typings/enum.ts b/lib/aoi.js/src/typings/enum.ts index 3a2e0172e..c369c5d4b 100644 --- a/lib/aoi.js/src/typings/enum.ts +++ b/lib/aoi.js/src/typings/enum.ts @@ -15,11 +15,8 @@ export enum ReturnType { Boolean = 1 << 4, Object = 1 << 5, Array = 1 << 6, -<<<<<<< HEAD Fn = 1 << 7, BigInt = 1 << 8, -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } export enum TranspilerCustoms { @@ -58,7 +55,6 @@ export enum BundlerCustoms { export enum AoiClientEvents { Error = 'AoiError', -<<<<<<< HEAD } export enum AoiErrorType { @@ -109,6 +105,3 @@ export enum ErrorCode { VariableNotFound, InvalidTimeZone, } -======= -} ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/src/typings/interface.ts b/lib/aoi.js/src/typings/interface.ts index a5faab648..cec2656df 100644 --- a/lib/aoi.js/src/typings/interface.ts +++ b/lib/aoi.js/src/typings/interface.ts @@ -1,6 +1,5 @@ import type AoiClient from '@aoi.js/classes/AoiClient.js'; import { type ReturnType, type FunctionType } from './enum.js'; -<<<<<<< HEAD import { type AoiEventNames, type AsyncFunction, @@ -18,12 +17,6 @@ import { type Message, type GuildMember, } from 'discord.js'; -======= -import { type AoiEventNames, type AsyncFunction, type CommandTypes, type FunctionCode } from './type.js'; -import type StringObject from '../core/builders/StringObject.js'; -import type Command from '@aoi.js/classes/Command.js'; -import { type User, type Channel, type Client, type ClientOptions, type Guild, type Message, type GuildMember } from 'discord.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export interface ITranspilerOptions { customFunctions: Record; @@ -33,11 +26,7 @@ export interface ITranspilerOptions { export interface ITranspileOptions { reverse?: boolean; parsedStringOnly?: boolean; -<<<<<<< HEAD command: Command; -======= - command?: Command; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb sendMessage?: boolean; scopeData?: IScopeData; asFunction?: boolean; @@ -53,10 +42,7 @@ export interface IScopeData { object?: Record; embeddedJS?: string[]; useChannel?: Snowflake | string; -<<<<<<< HEAD addReturn?: boolean; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } export interface IFunctionData { @@ -78,11 +64,7 @@ export interface ICodeFunctionData extends IFunctionData { funcs: ICodeFunctionData[]; parsed?: string; executed: string; -<<<<<<< HEAD cmd: Command; -======= - cmd?: Command; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } export interface IFunctionField { @@ -132,11 +114,7 @@ export interface IAoiClientOptions { time?: number; }; }; -<<<<<<< HEAD cache?: Record; -======= - cache?: Record; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb djsClientOptions?: ClientOptions; transpilerOptions?: ITranspilerOptions; testMode?: boolean; @@ -146,7 +124,6 @@ export interface IAoiLoggerOptions { logs?: boolean; warnings?: boolean; errors?: boolean; -<<<<<<< HEAD } export interface IFnBlock { @@ -174,6 +151,4 @@ export interface IDateTimeOptions { hour12: boolean; timezone: string; locale: string; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } \ No newline at end of file diff --git a/lib/aoi.js/src/typings/type.ts b/lib/aoi.js/src/typings/type.ts index 49939731e..03f4ee3bf 100644 --- a/lib/aoi.js/src/typings/type.ts +++ b/lib/aoi.js/src/typings/type.ts @@ -1,9 +1,5 @@ import type Scope from '@aoi.js/core/builders/Scope.js'; -<<<<<<< HEAD import { type ITranspilerData, type ICodeFunctionData, type IFunctionData, type IOk, type IErr } from './interface.js'; -======= -import { type ITranspilerData, type ICodeFunctionData, type IFunctionData } from './interface.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb import type * as Events from '@aoi.js/events/index.js'; export type FunctionCode = ( @@ -18,12 +14,7 @@ export type CommandTypes = | 'basic' | 'interaction' | 'ready' -<<<<<<< HEAD | 'debug'; -======= - | 'debug' - | 'component'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb // export type AsyncFunction = (arg: ITranspiledFuncData) => Promise; export type AutoFetchDataTypes = @@ -71,10 +62,6 @@ export type CustomFunctionProps = IFunctionData & { _code?: string; }; -<<<<<<< HEAD export type Safe = IOk | IErr; -======= -export type Safe = [Error, undefined] | [undefined, T]; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export type AoiEventNames = keyof typeof Events; \ No newline at end of file diff --git a/lib/aoi.js/src/utils/Helpers/core.ts b/lib/aoi.js/src/utils/Helpers/core.ts index 9db081f09..c081eb6d8 100644 --- a/lib/aoi.js/src/utils/Helpers/core.ts +++ b/lib/aoi.js/src/utils/Helpers/core.ts @@ -1,10 +1,6 @@ import StringObject from '@aoi.js/core/builders/StringObject.js'; import { parseStringObject } from '@aoi.js/core/parsers/object.js'; import { TranspilerCustoms } from '@aoi.js/typings/enum.js'; -<<<<<<< HEAD -import type { IOk } from '@aoi.js/typings/interface.js'; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb import { type Safe } from '@aoi.js/typings/type.js'; /** @@ -191,7 +187,6 @@ export function stringify(data: any): string { /** * Safely resolves a promise. * @param promise - The promise to resolve. -<<<<<<< HEAD * @returns - Returns a promise that resolves to an object with a success property. */ export async function safeAsync( @@ -216,31 +211,10 @@ export function safeSync(fn: () => T): Safe { return { success: true, data: fn() }; } catch (error: unknown) { return { success: false, error: error as E }; -======= - * @returns - Returns a tuple with the error and the data. - */ -export async function safeAsync(promise: Promise): Promise> { - return promise - .then((data) => [undefined, data]) - .catch((error) => [error, undefined]) as Promise>; -} - -/** - * Safely executes a function. - * @param fn - The function to execute. - * @returns - Returns a tuple with the error and the data. - */ -export function safeSync(fn: () => T): Safe { - try { - return [undefined, fn()]; - } catch (error) { - return [error as Error, undefined]; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } } /** -<<<<<<< HEAD * Safely executes a Promise or a function. * @param promiseOrFn - The promise or function to execute. * @returns - Returns an object with a success property. @@ -256,16 +230,4 @@ export function safe( } else { return safeAsync(promiseOrFn); } -======= - * Safely executes a function or a promise. - * @param promise - The promise to resolve. - * @returns - Returns a tuple with the error and the data. - */ -export function safe( promise: Promise): Promise>; -export function safe(fn: () => T): Safe; -// eslint-disable-next-line @typescript-eslint/promise-function-async -export function safe(funcOrPromise: Promise | (() => T)): Safe | Promise> { - if (funcOrPromise instanceof Promise) return safeAsync(funcOrPromise); - else return safeSync(funcOrPromise); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } \ No newline at end of file diff --git a/lib/aoi.js/src/utils/Helpers/functions.ts b/lib/aoi.js/src/utils/Helpers/functions.ts index 3b7e853e6..d69fbeb10 100644 --- a/lib/aoi.js/src/utils/Helpers/functions.ts +++ b/lib/aoi.js/src/utils/Helpers/functions.ts @@ -1,11 +1,7 @@ -<<<<<<< HEAD import type { AsyncFunction, Safe } from '@aoi.js/typings/type.js'; import { parseResult, safe } from './core.js'; import * as UTIL from 'node:util'; import type { IErr, IOk } from '@aoi.js/typings/interface.js'; -======= -import { parseResult } from './core.js'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb export function isMathExpression(expression: string): boolean { expression = parseResult(expression.trim()); @@ -98,7 +94,6 @@ export function isMathExpression(expression: string): boolean { return expression.trim() === ''; } -<<<<<<< HEAD export function abbreviate(number: number, decimal: number) { const SI_SYMBOLS = [ @@ -224,5 +219,3 @@ export async function wrap(promise: Promise): Promise> { } satisfies IErr; }); } -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/lib/aoi.js/tsconfig.json b/lib/aoi.js/tsconfig.json index cfcecb7c7..e1afdaf84 100644 --- a/lib/aoi.js/tsconfig.json +++ b/lib/aoi.js/tsconfig.json @@ -6,13 +6,8 @@ "composite": true, "tsBuildInfoFile": "./.tsbuildinfo", "target": "ESNext", -<<<<<<< HEAD "module": "NodeNext", "moduleResolution": "NodeNext", -======= - "module": "CommonJS", - "moduleResolution": "node10", ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb "baseUrl": ".", "paths": { "@aoi.js/*": ["./src/*"], diff --git a/package.json b/package.json index b73060858..80b20ab63 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,7 @@ "@types/eslint": "^8.56.10", "@types/eslint__eslintrc": "^2.1.1", "@types/eslint__js": "^8.42.3", -<<<<<<< HEAD "@types/node": "^22.8.2", -======= - "@types/node": "^20.12.7", ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb "@typescript-eslint/eslint-plugin": "^7.6.0", "@typescript-eslint/parser": ">=7.0.2", "acorn": "^8.11.3", diff --git a/tools/aoijs-tooling/getFunctionData.mjs b/tools/aoijs-tooling/getFunctionData.mjs index 37ec90882..8c9c80547 100644 --- a/tools/aoijs-tooling/getFunctionData.mjs +++ b/tools/aoijs-tooling/getFunctionData.mjs @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-call */ @@ -209,84 +208,3 @@ await fs.promises.writeFile( writePath, JSON.stringify(await getFunctionData(), null, 2), ); -======= -import fs from 'fs'; -import path from 'path'; - -/** - * Extract metadata from aoijs' function TypeScript file - * @param {string} filePath - The path to the TypeScript file - * @returns {object} - The extracted metadata - */ -function extractMetadata(filePath) { - // Read the TypeScript file - const tsFileContent = fs.readFileSync(filePath, 'utf-8'); - - // Extract metadata using regular expressions - const metadata = {}; - - // Extract function name - const nameMatch = /\.setName\(['"`](.*?)['"`]\)/.exec(tsFileContent); - if (nameMatch) metadata.name = nameMatch[1]; - - // Extract brackets - const bracketsMatch = /\.setBrackets\((.*?)\)/.exec(tsFileContent); - if (bracketsMatch) metadata.brackets = bracketsMatch[1] === 'true'; - - // Extract optional - const optionalMatch = /\.setOptional\((.*?)\)/.exec(tsFileContent); - if (optionalMatch) metadata.optional = optionalMatch[1] === 'true'; - - // Extract function type - const typeMatch = /\.setType\((.*?)\)/.exec(tsFileContent); - if (typeMatch) metadata.type = typeMatch[1].replace('FunctionType.', ''); - - // Extract fields - const fieldsMatch = /\.setFields\((.*?)\)/s.exec(tsFileContent); - if (fieldsMatch) { - const fields = fieldsMatch[1].split('],').map((field) => { - const fieldData = field.replace(/[\[\]']/g, '').split(','); - const name = fieldData - .find((data) => data.includes('name:')) - .split(':')[1] - .trim(); - const description = fieldData - .find((data) => data.includes('description:')) - .split(':')[1] - .trim(); - const type = fieldData - .find((data) => data.includes('type:')) - .split(':')[1] - .split('.')[1] - .trim(); - const required = - fieldData - .find((data) => data.includes('required:')) - .split(':')[1] - .trim() === 'true'; - - return { - name, - description, - type, - required, - }; - }); - metadata.fields = fields; - } - - // Extract return type - const returnTypeMatch = /\.setReturns\((.*?)\)/.exec(tsFileContent); - if (returnTypeMatch) - metadata.returns = returnTypeMatch[1].replace('ReturnType.', ''); - - return metadata; -} - -// Usage example -const filePath = path.join( - process.cwd() + '/lib/aoi.js/src/functions/js/conditions/$and.ts', -); -const metadata = extractMetadata(filePath); -console.log(metadata); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb diff --git a/tools/testing/testReporter.mjs b/tools/testing/testReporter.mjs index c3c101ab8..8eb494208 100644 --- a/tools/testing/testReporter.mjs +++ b/tools/testing/testReporter.mjs @@ -20,11 +20,6 @@ const customReporter = new Transform({ writableObjectMode: true, transform(event, _encoding, callback) { try { -<<<<<<< HEAD -======= - - ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (event.type === 'test:start') { if (event.data.nesting === 0) { groups[event.data.name] = { @@ -43,10 +38,7 @@ const customReporter = new Transform({ } } -<<<<<<< HEAD // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb switch (event.type) { case 'test:enqueue': // output = chalk.blue( @@ -64,55 +56,34 @@ const customReporter = new Transform({ case 'test:pass': if (event.data.nesting === 0) { groups[event.data.name].end = performance.now(); -<<<<<<< HEAD groups[event.data.name].status = event.data.todo ? 'todo' : event.data.skip ? 'skipped' : 'passed'; -======= - groups[event.data.name].status = 'passed'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } else { groups[parent].subtests[event.data.name].end = performance.now(); groups[parent].subtests[event.data.name].status = -<<<<<<< HEAD event.data.todo ? 'todo' : event.data.skip ? 'skipped' : 'passed'; -======= - 'passed'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } break; case 'test:fail': if (event.data.nesting === 0) { groups[event.data.name].end = performance.now(); -<<<<<<< HEAD groups[event.data.name].status = event.data.todo ? 'todo' : event.data.skip ? 'skipped' : 'failed'; -======= - groups[event.data.name].status = 'failed'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } else { groups[parent].subtests[event.data.name].end = performance.now(); groups[parent].subtests[event.data.name].status = -<<<<<<< HEAD event.data.todo ? 'todo' : event.data.skip ? 'skipped' : 'failed'; -======= - 'failed'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } break; case 'test:plan': // output = chalk.magenta('Test plan executed'); break; -<<<<<<< HEAD case 'test:watch:drained': { process.exit(0); } -======= - case 'test:watch:drained': - break; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb case 'test:coverage': { break; } @@ -122,14 +93,8 @@ const customReporter = new Transform({ case 'test:stdout': output += chalk.gray(event.data.message) + '\n'; break; -<<<<<<< HEAD case 'test:summary': break; -======= - default: { - throw new Error('default case'); - } ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb } if (output) { @@ -144,7 +109,6 @@ const customReporter = new Transform({ Object.keys(subtests).forEach((subtest) => { const { start, end, status } = subtests[subtest]; const duration = (end - start).toFixed(2); -<<<<<<< HEAD subtestoutput += `${ status === 'passed' ? chalk.green('✔') @@ -168,13 +132,6 @@ const customReporter = new Transform({ // skip emoji / fonticon : chalk.blue('>>') } ${group} (${duration}ms)`, -======= - subtestoutput += `${status === 'passed' ? chalk.green('✔') : chalk.red('✘')} ${subtest} (${duration}ms)\n`; - }); - boxoutput += boxen(`${subtestoutput}`, { - padding: { left: 2, right: 8 }, - title: `${status === 'passed' ? chalk.green('✔') : chalk.red('✘')} ${group} (${duration}ms)`, ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb }); boxoutput += '\n'; }); @@ -183,11 +140,8 @@ const customReporter = new Transform({ this.push('\n'); this.push(output + '\n'); -<<<<<<< HEAD output = ''; -======= ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb setTimeout(() => { spinner.stopAndPersist({ symbol: '★', diff --git a/tools/testing/testRunner.mjs b/tools/testing/testRunner.mjs index 10aba93bf..604453c70 100644 --- a/tools/testing/testRunner.mjs +++ b/tools/testing/testRunner.mjs @@ -1,4 +1,3 @@ -<<<<<<< HEAD /* eslint-disable @typescript-eslint/no-unsafe-call */ import { run } from 'node:test'; @@ -8,12 +7,6 @@ import * as glob from 'glob'; import { lcov, tap } from 'node:test/reporters'; import { createWriteStream, existsSync, writeFileSync } from 'node:fs'; import path from 'node:path'; -======= -import { run } from 'node:test'; -import process from 'node:process'; -import customReporter from './testReporter.mjs'; -import * as glob from 'glob'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const argvs = process.argv.slice(3); @@ -24,18 +17,13 @@ const flags = argvs.reduce((acc, arg) => { }, {}); // recursively go through src folder and find all test files -<<<<<<< HEAD let globBase = process.cwd() ; -======= -let globBase = './src'; ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb if (flags.folder) { globBase += `/${flags.folder}`; } let reporter = customReporter; -<<<<<<< HEAD let files = undefined; if (flags.folder) { @@ -46,15 +34,11 @@ if (flags.folder) { } } -======= -const files = glob.sync(`${globBase}/**/*.test.ts`); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb const testStream = run({ files, timeout: 60 * 1000, concurrency: true, -<<<<<<< HEAD forceExit: true, inspectPort: 3000, // 'coverage': true, @@ -77,10 +61,3 @@ const testStream = run({ // testStream.compose(lcov).pipe(lcovStream); testStream.compose(reporter).pipe(process.stdout); -======= - forceExit: true, -}); - -// eslint-disable-next-line @typescript-eslint/no-unsafe-call -testStream.compose(reporter).pipe(process.stdout); ->>>>>>> 9d1637b2e80d4bcbd055ccc60a53aa9f1c178bcb