@vaadin/hilla-generator-utils
Advanced tools
Comparing version 24.6.0-beta2 to 24.6.0-beta3
@@ -6,2 +6,3 @@ import { type ExportAssignment, type ExportDeclaration, type Identifier, type Statement } from 'typescript'; | ||
#private; | ||
get size(): number; | ||
constructor(collator: Intl.Collator); | ||
@@ -17,2 +18,3 @@ add(name: string, isType?: boolean, uniqueId?: Identifier): Identifier; | ||
#private; | ||
get size(): number; | ||
addCombined(path: string, name: string, uniqueId?: Identifier): Identifier; | ||
@@ -30,2 +32,3 @@ addSpread(path: string): void; | ||
#private; | ||
get isEmpty(): boolean; | ||
set(id: Identifier | string): Identifier; | ||
@@ -38,2 +41,3 @@ toCode(): ExportAssignment | undefined; | ||
readonly namespace: NamespaceExportManager; | ||
get size(): number; | ||
constructor(collator: Intl.Collator); | ||
@@ -40,0 +44,0 @@ toCode(): readonly Statement[]; |
@@ -8,2 +8,5 @@ import ts, {} from "typescript"; | ||
#map = /* @__PURE__ */ new Map(); | ||
get size() { | ||
return this.#map.size; | ||
} | ||
constructor(collator) { | ||
@@ -52,2 +55,5 @@ this.#collator = collator; | ||
#map = /* @__PURE__ */ new Map(); | ||
get size() { | ||
return this.#map.size; | ||
} | ||
addCombined(path, name, uniqueId) { | ||
@@ -95,2 +101,5 @@ const id = uniqueId ?? createFullyUniqueIdentifier(name); | ||
#id; | ||
get isEmpty() { | ||
return !this.#id; | ||
} | ||
set(id) { | ||
@@ -108,2 +117,5 @@ this.#id = typeof id === "string" ? ts.factory.createIdentifier(id) : id; | ||
namespace; | ||
get size() { | ||
return (this.default.isEmpty ? 0 : 1) + this.named.size + this.namespace.size; | ||
} | ||
constructor(collator) { | ||
@@ -110,0 +122,0 @@ this.named = new NamedExportManager(collator); |
@@ -7,2 +7,3 @@ import ts, { type Identifier, type ImportDeclaration, type Statement } from 'typescript'; | ||
constructor(collator: Intl.Collator); | ||
get size(): number; | ||
add(path: string, specifier: string, isType?: boolean, uniqueId?: Identifier): Identifier; | ||
@@ -21,2 +22,3 @@ remove(path: string, specifier: string): void; | ||
#private; | ||
get size(): number; | ||
add(path: string, name: string, uniqueId?: Identifier): Identifier; | ||
@@ -33,2 +35,3 @@ clear(): void; | ||
#private; | ||
get size(): number; | ||
add(path: string, name: string, isType?: boolean, uniqueId?: Identifier): Identifier; | ||
@@ -50,2 +53,3 @@ getIdentifier(path: string): Identifier | undefined; | ||
constructor(collator: Intl.Collator); | ||
get size(): number; | ||
toCode(): readonly Statement[]; | ||
@@ -52,0 +56,0 @@ fromCode(source: ts.SourceFile): void; |
@@ -12,2 +12,5 @@ import ts, {} from "typescript"; | ||
} | ||
get size() { | ||
return this.#map.size; | ||
} | ||
add(path, specifier, isType, uniqueId) { | ||
@@ -57,2 +60,3 @@ const record = createDependencyRecord(uniqueId ?? createFullyUniqueIdentifier(specifier), isType); | ||
names.sort(this.#collator.compare); | ||
const isTypeOnly = names.every((name) => specifiers.get(name).isType); | ||
yield [ | ||
@@ -63,3 +67,3 @@ path, | ||
ts.factory.createImportClause( | ||
false, | ||
isTypeOnly, | ||
void 0, | ||
@@ -69,3 +73,7 @@ ts.factory.createNamedImports( | ||
const { id, isType } = specifiers.get(name); | ||
return ts.factory.createImportSpecifier(isType, ts.factory.createIdentifier(name), id); | ||
return ts.factory.createImportSpecifier( | ||
isTypeOnly ? false : isType, | ||
ts.factory.createIdentifier(name), | ||
id | ||
); | ||
}) | ||
@@ -89,2 +97,5 @@ ) | ||
#map = /* @__PURE__ */ new Map(); | ||
get size() { | ||
return this.#map.size; | ||
} | ||
add(path, name, uniqueId) { | ||
@@ -130,2 +141,5 @@ const id = uniqueId ?? createFullyUniqueIdentifier(name); | ||
#map = /* @__PURE__ */ new Map(); | ||
get size() { | ||
return this.#map.size; | ||
} | ||
add(path, name, isType, uniqueId) { | ||
@@ -185,2 +199,5 @@ const id = uniqueId ?? createFullyUniqueIdentifier(name); | ||
} | ||
get size() { | ||
return this.default.size + this.named.size + this.namespace.size; | ||
} | ||
toCode() { | ||
@@ -187,0 +204,0 @@ const records = [ |
export type PathManagerOptions = Readonly<{ | ||
aliasRoot?: string; | ||
extension?: string; | ||
relativeTo?: string; | ||
relativeTo?: URL | string; | ||
}>; | ||
@@ -11,5 +11,5 @@ export default class PathManager { | ||
createBareModulePath(path: string, isFile?: boolean): string; | ||
createRelativePath(path: string, relativeTo?: string): string; | ||
createRelativePath(path: URL | string, fileExtension?: string, relativeTo?: string | URL): string; | ||
createTSAliasModulePath(path: string, root?: string | undefined): string; | ||
} | ||
//# sourceMappingURL=PathManager.d.ts.map |
@@ -1,2 +0,3 @@ | ||
import { posix } from "path"; | ||
import { basename, dirname, posix, relative, sep } from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
class PathManager { | ||
@@ -25,9 +26,13 @@ #options; | ||
} | ||
createRelativePath(path, relativeTo = this.#options.relativeTo) { | ||
createRelativePath(path, fileExtension, relativeTo = this.#options.relativeTo) { | ||
const { extension } = this.#options; | ||
let result = path; | ||
if (extension && !path.endsWith(extension)) { | ||
result = `${result}${extension}`; | ||
const _path = path instanceof URL ? fileURLToPath(path) : path; | ||
let result = _path; | ||
if (extension && !_path.endsWith(extension)) { | ||
result = `${dirname(result)}/${basename(result, fileExtension)}${extension}`; | ||
} | ||
result = posix.relative(relativeTo, result); | ||
result = relative(relativeTo instanceof URL ? fileURLToPath(relativeTo) : relativeTo, result).replaceAll( | ||
sep, | ||
posix.sep | ||
); | ||
return result.startsWith(".") ? result : `./${result}`; | ||
@@ -34,0 +39,0 @@ } |
{ | ||
"name": "@vaadin/hilla-generator-utils", | ||
"version": "24.6.0-beta2", | ||
"version": "24.6.0-beta3", | ||
"description": "A set of utils for developing Hilla generator plugins", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
86397
809