[add] add LibraryCallsRecorder, integrate faker for argument generation

This commit is contained in:
2025-08-02 13:55:41 +01:00
parent 3f00b37291
commit f83b1fc00e
12 changed files with 196 additions and 366 deletions

18
package-lock.json generated
View File

@@ -27,12 +27,30 @@
"webpack": "^5.99.9" "webpack": "^5.99.9"
}, },
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^9.9.0",
"@types/eslint-scope": "^8.3.0", "@types/eslint-scope": "^8.3.0",
"@types/estree": "^1.0.8", "@types/estree": "^1.0.8",
"@types/node": "^24.0.0", "@types/node": "^24.0.0",
"classnames": "^2.5.1" "classnames": "^2.5.1"
} }
}, },
"node_modules/@faker-js/faker": {
"version": "9.9.0",
"resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-9.9.0.tgz",
"integrity": "sha512-OEl393iCOoo/z8bMezRlJu+GlRGlsKbUAN7jKB6LhnKoqKve5DXRpalbItIIcwnCjs1k/FOPjFzcA6Qn+H+YbA==",
"dev": true,
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/fakerjs"
}
],
"license": "MIT",
"engines": {
"node": ">=18.0.0",
"npm": ">=9.0.0"
}
},
"node_modules/@isaacs/balanced-match": { "node_modules/@isaacs/balanced-match": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",

View File

@@ -29,6 +29,7 @@
"webpack": "^5.99.9" "webpack": "^5.99.9"
}, },
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^9.9.0",
"@types/eslint-scope": "^8.3.0", "@types/eslint-scope": "^8.3.0",
"@types/estree": "^1.0.8", "@types/estree": "^1.0.8",
"@types/node": "^24.0.0", "@types/node": "^24.0.0",

View File

@@ -1,16 +1,16 @@
import { readFileSync ,realpathSync ,mkdirSync} from 'node:fs'; import { readFileSync ,mkdirSync} from 'node:fs';
import { writeFile } from 'node:fs/promises'; import { writeFile } from 'node:fs/promises';
import tsm, { Project, SyntaxKind ,ts} from 'ts-morph'; import { Project} from 'ts-morph';
import {getSliceAndInfoSync} from 'slice-js/src/slice-code/test/helpers/utils.js'; import {getSliceAndInfoSync} from 'slice-js/src/slice-code/test/helpers/utils.js';
import path, { dirname,join } from 'node:path'; import path from 'node:path';
import { getImportCallsAndArgumentTypes } from './tsCalls.mjs'; import { getImportCallsAndArgumentTypes } from './tsCalls.mjs';
import { LibraryCallsRecorder } from './libcalls.mjs'; import { wpCompress } from './bundle/index.mjs';
import { wpCompress } from '../src_bundle/index.mjs'; import { LibraryTypesRecorder } from './libcalls.mjs';
/** /**
* *
* @param {LibraryCallsRecorder['calls']} calls * @param {ReturnType<LibraryTypesRecorder['generateAllArgumentsForRecordedCalls']>} calls
* @param {string} FILE_PATH * @param {string} FILE_PATH
*/ */
export async function sliceAndWriteCalls(calls, FILE_PATH) { export async function sliceAndWriteCalls(calls, FILE_PATH) {

View File

@@ -0,0 +1,30 @@
/**
* Record library calls
*/
export class LibraryCallsRecorder {
/**
* @type {Map<string,Map<string,GenericLiteralType[][]>>}
*/
#calls = new Map();
/**
*
* @param {string} moduleName
* @param {string} libraryFunctionSegment
* @param {any[]} argumentsCalled
*/
pushToMap(moduleName, libraryFunctionSegment, argumentsCalled) {
const modulePortion = this.#calls.get(moduleName) ?? new Map();
const defArgs = modulePortion.get(libraryFunctionSegment) ?? [];
defArgs.push(argumentsCalled);
modulePortion.set(libraryFunctionSegment, defArgs);
this.#calls.set(moduleName, modulePortion);
}
get calls() {
return this.#calls;
}
}

View File

@@ -1,82 +1,64 @@
//@ts-check //@ts-check
/** /**
* @typedef {import('estree').Literal["value"]} GenericLiteralType * @typedef {import('estree').Literal["value"]} GenericLiteralType
*/ */
import tsm, { Type } from 'ts-morph'; import tsm, { Type } from 'ts-morph';
import { simpleFaker, faker } from '@faker-js/faker'
/** export class LibraryTypesRecorder {
* Record library calls
*/
export class LibraryCallsRecorder{
/**
* @type {Map<string,Map<string,GenericLiteralType[][]>>}
*/
#calls = new Map();
/**
*
* @param {string} moduleName
* @param {string} libraryFunctionSegment
* @param {any[]} argumentsCalled
*/
pushToMap(moduleName, libraryFunctionSegment, argumentsCalled){
const modulePortion = this.#calls.get(moduleName)?? new Map();
const defArgs = modulePortion.get(libraryFunctionSegment) ?? [];
defArgs.push(argumentsCalled);
modulePortion.set(libraryFunctionSegment,defArgs);
this.#calls.set(moduleName, modulePortion);
}
get calls(){
return this.#calls;
}
}
export class LibraryTypesRecorder{
/** /**
* @type {Map<string,Map<string,Type[][]>>} * @type {Map<string,Map<string,Type[][]>>}
*/ */
#calls = new Map(); #calls = new Map();
/** /**
* @param {tsm.TypeChecker} checker * @type {tsm.TypeChecker} checker
*/ */
checker; checker;
/**
*
* @param {tsm.TypeChecker} checker
*/
constructor(checker) {
this.checker = checker;
}
/** /**
* *
* @param {string} moduleName * @param {string} moduleName
* @param {string} libraryFunctionSegment * @param {string} libraryFunctionSegment
* @param {Type[]} argumentsCalled * @param {Type[]} argumentsCalled
*/ */
pushToMap(moduleName, libraryFunctionSegment, argumentsCalled){ pushToMap(moduleName, libraryFunctionSegment, argumentsCalled) {
const modulePortion = this.#calls.get(moduleName)?? new Map(); const modulePortion = this.#calls.get(moduleName) ?? new Map();
const defArgs = modulePortion.get(libraryFunctionSegment) ?? []; const defArgs = modulePortion.get(libraryFunctionSegment) ?? [];
defArgs.push(argumentsCalled); defArgs.push(argumentsCalled);
modulePortion.set(libraryFunctionSegment,defArgs); modulePortion.set(libraryFunctionSegment, defArgs);
this.#calls.set(moduleName, modulePortion); this.#calls.set(moduleName, modulePortion);
} }
get calls(){ get calls() {
return this.#calls; return this.#calls;
} }
generateAllArgumentsForRecordedCalls(){ generateAllArgumentsForRecordedCalls() {
/**
* @type {Map<string,Map<string,(GenericLiteralType|null|undefined|{})[][]>>}
*/
const callMap = new Map(); const callMap = new Map();
for(const [moduleName, modulePortion] of this.#calls){ for (const [moduleName, modulePortion] of this.#calls) {
/** /**
* @type {Map<string,(GenericLiteralType|null|undefined|{})[][]>} * @type {Map<string,(GenericLiteralType|null|undefined|{})[][]>}
*/ */
const moduleCallMap = new Map();// todo refactor const moduleCallMap = new Map();// todo refactor
for(const [libraryFunctionSegment, argsList] of modulePortion){ for (const [libraryFunctionSegment, argsList] of modulePortion) {
const argsForFunction = argsList.map(args=>args.map(arg=>this.instantiateType(arg))); const argsForFunctionSimple = argsList.map(args => args.map(arg => this.instantiateType(arg)));
moduleCallMap.set(libraryFunctionSegment,argsForFunction); const argsForFunction = argsList.flatMap(args => simpleFaker.helpers.multiple(()=> args.map(arg => this.instantiateFakerOnType(arg))));
moduleCallMap.set(libraryFunctionSegment, argsForFunction);
} }
callMap.set(moduleName,moduleCallMap); callMap.set(moduleName, moduleCallMap);
} }
return callMap; return callMap;
} }
@@ -87,50 +69,137 @@ export class LibraryTypesRecorder{
* @param {string} libraryFunctionSegment * @param {string} libraryFunctionSegment
* @returns {(GenericLiteralType|null|undefined|{})[][]|undefined} * @returns {(GenericLiteralType|null|undefined|{})[][]|undefined}
*/ */
generateArgumentsForCall(moduleName, libraryFunctionSegment){ generateArgumentsForCall(moduleName, libraryFunctionSegment) {
const modulePortion = this.#calls.get(moduleName); const modulePortion = this.#calls.get(moduleName);
if(modulePortion===undefined){ if (modulePortion === undefined) {
return undefined; return undefined;
} }
const argsTypesForFunctionCalls = modulePortion.get(libraryFunctionSegment); const argsTypesForFunctionCalls = modulePortion.get(libraryFunctionSegment);
if(argsTypesForFunctionCalls===undefined){ if (argsTypesForFunctionCalls === undefined) {
return undefined; return undefined;
} }
return argsTypesForFunctionCalls.map(argTypeForSingleCall=>{ return argsTypesForFunctionCalls.map(argTypeForSingleCall => {
return argTypeForSingleCall.map(type=>{ return argTypeForSingleCall.map(type => {
return LibraryTypesRecorder.instantiateType(type); return this.instantiateType(type);
}); });
}); });
}
/**
*
* @param {Type} type
*/
instantiateFakerOnType(type) {
const literalValue = type.getLiteralValue();
if (literalValue !== undefined) {
return literalValue;
} else if (type.isUndefined()) {
return undefined;
} else if (type.isString()) {
return simpleFaker.string.alphanumeric();
} else if (type.isNumber()) {
return simpleFaker.number.int();
} else if (type.isBoolean()) {
return simpleFaker.datatype.boolean();
} else if (type.isArray()) {
return []// TODO - handle arrays;
} else if (type.isObject()) {
const newObj = {};
for (const prop of type.getProperties()) {
const propName = prop.getName();
const declarations = prop.getDeclarations();
let propType = prop.getDeclaredType();
if (declarations.length !== 1) {
console.warn("Multiple declarations for property", propName, "in type", type.getText());
} else {
propType = this.checker.getTypeOfSymbolAtLocation(prop, declarations[0]);
}
newObj[propName] = this.instantiateFakerOnType(propType);
}
// TODO - handle functions
return newObj;
} else {
console.warn("Unknown type to instantiate", type.getText());
if (type.isAny()) {
return simpleFaker.helpers.arrayElement([
simpleFaker.string.sample(),
simpleFaker.number.int(),
simpleFaker.datatype.boolean(),
{},
[]
]);
}
return undefined;
}
} }
/** /**
* *
* @param {Type} type * @param {Type} type
* @returns * @returns
*/ */
instantiateType(type){ instantiateType(type) {
if(type.isStringLiteral()){ const literalValue = type.getLiteralValue();
return type.getLiteralValue(); if (literalValue !== undefined) {
}else if(type.isNumberLiteral()){ return literalValue;
return Number(type.getText()); } else if (type.isUndefined()) {
}else if(type.isBooleanLiteral()){ return undefined;
return type.getText() === 'true'; } else if (type.isString()) {
}else if(type.isString()){
return ""; return "";
}else if(type.isNumber()){ } else if (type.isNumber()) {
return 0; return 0;
}else if(type.isBoolean()){ } else if (type.isBoolean()) {
return false;// BAD IDEA return false;// BAD IDEA
}else if(type.isArray()){ } else if (type.isArray()) {
return []; return [];
}else if(type.isObject()){ } else if (type.isObject()) {
const newObj = {};
for (const prop of type.getProperties()) {
const propName = prop.getName();
const declarations = prop.getDeclarations();
let propType = prop.getDeclaredType();
if (declarations.length !== 1) {
console.warn("Multiple declarations for property", propName, "in type", type.getText());
} else {
propType = this.checker.getTypeOfSymbolAtLocation(prop, declarations[0]);
}
newObj[propName] = this.instantiateType(propType);
}
// TODO - handle functions // TODO - handle functions
return {}; return newObj;
}else{ } else {
console.warn("Unknown type to instantiate",type.getText()); console.warn("Unknown type to instantiate", type.getText());
return undefined; return undefined;
} }
} }
/**
*
* @param {Type} type
*/
instantiateMultipleFromType(type) {
if (type.isStringLiteral()) {
return [type.getLiteralValue()];
} else if (type.isNumberLiteral()) {
return [Number(type.getText())];
} else if (type.isBooleanLiteral()) {
return [type.getText() === 'true'];
} else if (type.is) {
} else if (type.isString()) {
return ["", "a", "b"];
} else if (type.isNumber()) {
return [0, 1, 2];
} else if (type.isBoolean()) {
return [false, true];
} else if (type.isArray()) {
return [[]];
} else if (type.isObject()) {
// TODO - handle functions
return [{}];
}
console.warn("Unknown type to instantiate", type.getText());
return [];
}
} }

View File

@@ -11,7 +11,7 @@ import { LibraryTypesRecorder } from './libcalls.mjs';
* @returns {LibraryTypesRecorder} instance of recorded library calls * @returns {LibraryTypesRecorder} instance of recorded library calls
*/ */
export function getImportCallsAndArgumentTypes(importDecls, checker, mainFilePath) { export function getImportCallsAndArgumentTypes(importDecls, checker, mainFilePath) {
const libraryCallsRecorder = new LibraryTypesRecorder(); const libraryCallsRecorder = new LibraryTypesRecorder(checker);
for (const importStringDecl of importDecls) { for (const importStringDecl of importDecls) {
// console.log(importStringDecl); // console.log(importStringDecl);
const importDecl = importStringDecl.getFirstAncestor(); const importDecl = importStringDecl.getFirstAncestor();

View File

@@ -1 +0,0 @@
Reads a bundle and bundles its dependencies into objects.

View File

@@ -1 +0,0 @@
npm i classnames semver ansi-styles debug supports-color chalk ms minimatch strip-ansi tslib has-flag ansi-regex color-convert color-name type-fest string-width

View File

@@ -1,257 +0,0 @@
{
"name": "src_bundle",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "src_bundle",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"ansi-regex": "^6.1.0",
"ansi-styles": "^6.2.1",
"chalk": "^5.4.1",
"classnames": "^2.5.1",
"color-convert": "^3.1.0",
"color-name": "^2.0.0",
"debug": "^4.4.1",
"has-flag": "^5.0.1",
"minimatch": "^10.0.3",
"ms": "^2.1.3",
"semver": "^7.7.2",
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"supports-color": "^10.0.0",
"tslib": "^2.8.1",
"type-fest": "^4.41.0"
}
},
"node_modules/@isaacs/balanced-match": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
"integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==",
"license": "MIT",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/@isaacs/brace-expansion": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz",
"integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==",
"license": "MIT",
"dependencies": {
"@isaacs/balanced-match": "^4.0.1"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/ansi-regex": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
"integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
}
},
"node_modules/ansi-styles": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/chalk": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz",
"integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==",
"license": "MIT",
"engines": {
"node": "^12.17.0 || ^14.13 || >=16.0.0"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/classnames": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz",
"integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==",
"license": "MIT"
},
"node_modules/color-convert": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-3.1.0.tgz",
"integrity": "sha512-TVoqAq8ZDIpK5lsQY874DDnu65CSsc9vzq0wLpNQ6UMBq81GSZocVazPiBbYGzngzBOIRahpkTzCLVe2at4MfA==",
"license": "MIT",
"dependencies": {
"color-name": "^2.0.0"
},
"engines": {
"node": ">=14.6"
}
},
"node_modules/color-name": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-2.0.0.tgz",
"integrity": "sha512-SbtvAMWvASO5TE2QP07jHBMXKafgdZz8Vrsrn96fiL+O92/FN/PLARzUW5sKt013fjAprK2d2iCn2hk2Xb5oow==",
"license": "MIT",
"engines": {
"node": ">=12.20"
}
},
"node_modules/debug": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/emoji-regex": {
"version": "10.4.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz",
"integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==",
"license": "MIT"
},
"node_modules/get-east-asian-width": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.0.tgz",
"integrity": "sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/has-flag": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-5.0.1.tgz",
"integrity": "sha512-CsNUt5x9LUdx6hnk/E2SZLsDyvfqANZSUq4+D3D8RzDJ2M+HDTIkF60ibS1vHaK55vzgiZw1bEPFG9yH7l33wA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/minimatch": {
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz",
"integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==",
"license": "ISC",
"dependencies": {
"@isaacs/brace-expansion": "^5.0.0"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/semver": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/string-width": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^10.3.0",
"get-east-asian-width": "^1.0.0",
"strip-ansi": "^7.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/strip-ansi": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^6.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
"node_modules/supports-color": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.0.0.tgz",
"integrity": "sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/type-fest": {
"version": "4.41.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz",
"integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==",
"license": "(MIT OR CC0-1.0)",
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
}
}
}

View File

@@ -1,29 +0,0 @@
{
"name": "src_bundle",
"version": "1.0.0",
"description": "Reads a bundle and bundles its dependencies into objects.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"ansi-regex": "^6.1.0",
"ansi-styles": "^6.2.1",
"chalk": "^5.4.1",
"classnames": "^2.5.1",
"color-convert": "^3.1.0",
"color-name": "^2.0.0",
"debug": "^4.4.1",
"has-flag": "^5.0.1",
"minimatch": "^10.0.3",
"ms": "^2.1.3",
"semver": "^7.7.2",
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"supports-color": "^10.0.0",
"tslib": "^2.8.1",
"type-fest": "^4.41.0"
}
}

View File

@@ -1,10 +1,10 @@
import fs,{readFile} from 'node:fs' import fs,{readFile} from 'node:fs'
// import classnames from 'classnames' import classnames from 'classnames'
import * as s from 'esprima' // import * as s from 'esprima'
// import {sum, div} from './arithmetic.cjs'; // import {sum, div} from './arithmetic.cjs';
console.log(s.parseScript("const a = 5;")); // $ExpectType boolean console.log(s.parseScript("const a = 5;")); // $ExpectType boolean
// console.log(classnames({a:true,b:true})); // $ExpectType string console.log(classnames(Object.freeze({a:true,b:true}))); // $ExpectType string
// console.log(sum(2, 3)); // console.log(sum(2, 3));
// console.log(neq('1.0.0', '1.0.1')); // $ExpectType boolean // console.log(neq('1.0.0', '1.0.1')); // $ExpectType boolean