@litlab/audx 0.0.1 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -53
- package/dist/bin.js +1212 -0
- package/dist/cc-DgCkkqq8.js +13 -0
- package/dist/cc-he3fHS3P.js +12 -0
- package/dist/index.d.ts +723 -3
- package/dist/index.js +1534 -126
- package/dist/react.d.ts +583 -0
- package/dist/react.js +1556 -0
- package/package.json +64 -39
- package/schemas/pack.schema.json +4 -0
- package/schemas/patch.schema.json +857 -0
- package/dist/codegen/theme-codegen.d.ts +0 -12
- package/dist/codegen/theme-codegen.d.ts.map +0 -1
- package/dist/codegen/theme-codegen.js +0 -153
- package/dist/codegen/theme-codegen.js.map +0 -1
- package/dist/commands/add.d.ts +0 -2
- package/dist/commands/add.d.ts.map +0 -1
- package/dist/commands/add.js +0 -120
- package/dist/commands/add.js.map +0 -1
- package/dist/commands/diff.d.ts +0 -2
- package/dist/commands/diff.d.ts.map +0 -1
- package/dist/commands/diff.js +0 -103
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/generate.d.ts +0 -12
- package/dist/commands/generate.d.ts.map +0 -1
- package/dist/commands/generate.js +0 -96
- package/dist/commands/generate.js.map +0 -1
- package/dist/commands/init.d.ts +0 -2
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -79
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list.d.ts +0 -14
- package/dist/commands/list.d.ts.map +0 -1
- package/dist/commands/list.js +0 -93
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/remove.d.ts +0 -2
- package/dist/commands/remove.d.ts.map +0 -1
- package/dist/commands/remove.js +0 -71
- package/dist/commands/remove.js.map +0 -1
- package/dist/commands/theme.d.ts +0 -31
- package/dist/commands/theme.d.ts.map +0 -1
- package/dist/commands/theme.js +0 -142
- package/dist/commands/theme.js.map +0 -1
- package/dist/commands/update.d.ts +0 -2
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -123
- package/dist/commands/update.js.map +0 -1
- package/dist/core/alias-resolver.d.ts +0 -24
- package/dist/core/alias-resolver.d.ts.map +0 -1
- package/dist/core/alias-resolver.js +0 -87
- package/dist/core/alias-resolver.js.map +0 -1
- package/dist/core/config.d.ts +0 -21
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -43
- package/dist/core/config.js.map +0 -1
- package/dist/core/file-writer.d.ts +0 -14
- package/dist/core/file-writer.d.ts.map +0 -1
- package/dist/core/file-writer.js +0 -90
- package/dist/core/file-writer.js.map +0 -1
- package/dist/core/package-manager.d.ts +0 -3
- package/dist/core/package-manager.d.ts.map +0 -1
- package/dist/core/package-manager.js +0 -17
- package/dist/core/package-manager.js.map +0 -1
- package/dist/core/registry.d.ts +0 -18
- package/dist/core/registry.d.ts.map +0 -1
- package/dist/core/registry.js +0 -69
- package/dist/core/registry.js.map +0 -1
- package/dist/core/theme-manager.d.ts +0 -35
- package/dist/core/theme-manager.d.ts.map +0 -1
- package/dist/core/theme-manager.js +0 -94
- package/dist/core/theme-manager.js.map +0 -1
- package/dist/core/utils.d.ts +0 -22
- package/dist/core/utils.d.ts.map +0 -1
- package/dist/core/utils.js +0 -44
- package/dist/core/utils.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -116
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -43
- package/dist/types.js.map +0 -1
package/dist/commands/list.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RegistryItem } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Filter catalog items by tag — include only items whose meta.tags contains the tag.
|
|
4
|
-
*/
|
|
5
|
-
export declare function filterByTag(items: RegistryItem[], tag: string): RegistryItem[];
|
|
6
|
-
/**
|
|
7
|
-
* Filter catalog items by search query — case-insensitive match on name, description, or tags.
|
|
8
|
-
*/
|
|
9
|
-
export declare function filterBySearch(items: RegistryItem[], query: string): RegistryItem[];
|
|
10
|
-
export declare function listCommand(projectRoot: string, options: {
|
|
11
|
-
tag?: string;
|
|
12
|
-
search?: string;
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,YAAY,EAAE,EACrB,GAAG,EAAE,MAAM,GACT,YAAY,EAAE,CAIhB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,EAAE,MAAM,GACX,YAAY,EAAE,CAQhB;AAkDD,wBAAsB,WAAW,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
package/dist/commands/list.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as ConfigManager from "../core/config.js";
|
|
2
|
-
import { fetchCatalog } from "../core/registry.js";
|
|
3
|
-
/**
|
|
4
|
-
* Filter catalog items by tag — include only items whose meta.tags contains the tag.
|
|
5
|
-
*/
|
|
6
|
-
export function filterByTag(items, tag) {
|
|
7
|
-
return items.filter((item) => item.meta?.tags?.some((t) => t.toLowerCase() === tag.toLowerCase()));
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Filter catalog items by search query — case-insensitive match on name, description, or tags.
|
|
11
|
-
*/
|
|
12
|
-
export function filterBySearch(items, query) {
|
|
13
|
-
const q = query.toLowerCase();
|
|
14
|
-
return items.filter((item) => {
|
|
15
|
-
if (item.name.toLowerCase().includes(q))
|
|
16
|
-
return true;
|
|
17
|
-
if (item.description.toLowerCase().includes(q))
|
|
18
|
-
return true;
|
|
19
|
-
if (item.meta?.tags?.some((t) => t.toLowerCase().includes(q)))
|
|
20
|
-
return true;
|
|
21
|
-
return false;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Format and print a table of registry items to stdout.
|
|
26
|
-
*/
|
|
27
|
-
function printTable(items) {
|
|
28
|
-
if (items.length === 0) {
|
|
29
|
-
console.log("No sounds found.");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Column headers
|
|
33
|
-
const headers = [
|
|
34
|
-
"Name",
|
|
35
|
-
"Description",
|
|
36
|
-
"Duration",
|
|
37
|
-
"Format",
|
|
38
|
-
"Size (KB)",
|
|
39
|
-
"License",
|
|
40
|
-
"Tags",
|
|
41
|
-
];
|
|
42
|
-
// Build rows
|
|
43
|
-
const rows = items.map((item) => [
|
|
44
|
-
item.name,
|
|
45
|
-
item.description,
|
|
46
|
-
item.meta?.duration != null ? `${item.meta.duration}s` : "-",
|
|
47
|
-
item.meta?.format ?? "-",
|
|
48
|
-
item.meta?.sizeKb != null ? String(item.meta.sizeKb) : "-",
|
|
49
|
-
item.meta?.license ?? "-",
|
|
50
|
-
item.meta?.tags?.join(", ") ?? "-",
|
|
51
|
-
]);
|
|
52
|
-
// Compute column widths
|
|
53
|
-
const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length)));
|
|
54
|
-
// Print header
|
|
55
|
-
const headerLine = headers.map((h, i) => h.padEnd(colWidths[i])).join(" ");
|
|
56
|
-
const separator = colWidths.map((w) => "-".repeat(w)).join(" ");
|
|
57
|
-
console.log(headerLine);
|
|
58
|
-
console.log(separator);
|
|
59
|
-
// Print rows
|
|
60
|
-
for (const row of rows) {
|
|
61
|
-
console.log(row.map((cell, i) => cell.padEnd(colWidths[i])).join(" "));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export async function listCommand(projectRoot, options) {
|
|
65
|
-
// Read config to get registryUrl
|
|
66
|
-
if (!ConfigManager.exists(projectRoot)) {
|
|
67
|
-
console.error("Configuration not found. Run 'audx init' first.");
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
const config = ConfigManager.read(projectRoot);
|
|
71
|
-
let catalog;
|
|
72
|
-
try {
|
|
73
|
-
catalog = await fetchCatalog(config.registryUrl);
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
// Requirement 4.5 — handle fetch failures
|
|
77
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
78
|
-
console.error(`✘ ${message}`);
|
|
79
|
-
process.exit(2);
|
|
80
|
-
}
|
|
81
|
-
let items = catalog.items;
|
|
82
|
-
// Requirement 4.3 — tag filter
|
|
83
|
-
if (options.tag) {
|
|
84
|
-
items = filterByTag(items, options.tag);
|
|
85
|
-
}
|
|
86
|
-
// Requirement 4.4 — search filter
|
|
87
|
-
if (options.search) {
|
|
88
|
-
items = filterBySearch(items, options.search);
|
|
89
|
-
}
|
|
90
|
-
// Requirement 4.2 — display formatted table
|
|
91
|
-
printTable(items);
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD;;GAEG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAqB,EACrB,GAAW;IAEX,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAC5B,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC,CACnE,CAAC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
1
|
-
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/commands/remove.ts"],"names":[],"mappings":"AAkCA,wBAAsB,aAAa,CAClC,MAAM,EAAE,MAAM,EAAE,EAChB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CA8Df"}
|
package/dist/commands/remove.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { existsSync, unlinkSync } from "node:fs";
|
|
2
|
-
import * as ConfigManager from "../core/config.js";
|
|
3
|
-
import * as ThemeManager from "../core/theme-manager.js";
|
|
4
|
-
/**
|
|
5
|
-
* Collect every file path referenced by installed sounds *other* than the
|
|
6
|
-
* ones being removed. These are the files that must be preserved.
|
|
7
|
-
*/
|
|
8
|
-
function getFilesReferencedByOtherSounds(config, soundsToRemove) {
|
|
9
|
-
const referenced = new Set();
|
|
10
|
-
for (const [name, entry] of Object.entries(config.installedSounds)) {
|
|
11
|
-
if (soundsToRemove.has(name))
|
|
12
|
-
continue;
|
|
13
|
-
for (const file of entry.files) {
|
|
14
|
-
referenced.add(file);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return referenced;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Determine which files from a sound's entry are safe to delete.
|
|
21
|
-
* Shared dependency files still referenced by other sounds are preserved.
|
|
22
|
-
*/
|
|
23
|
-
function getFilesToDelete(files, preservedFiles) {
|
|
24
|
-
return files.filter((f) => !preservedFiles.has(f));
|
|
25
|
-
}
|
|
26
|
-
export async function removeCommand(sounds, projectRoot) {
|
|
27
|
-
// Requirement 9 — config must exist
|
|
28
|
-
if (!ConfigManager.exists(projectRoot)) {
|
|
29
|
-
console.error("Configuration not found. Run 'audx init' first.");
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
const config = ConfigManager.read(projectRoot);
|
|
33
|
-
const updatedConfig = {
|
|
34
|
-
...config,
|
|
35
|
-
installedSounds: { ...config.installedSounds },
|
|
36
|
-
};
|
|
37
|
-
const soundsToRemove = new Set(sounds);
|
|
38
|
-
// Requirement 9.4 — error if sound is not installed
|
|
39
|
-
for (const soundName of sounds) {
|
|
40
|
-
if (!updatedConfig.installedSounds[soundName]) {
|
|
41
|
-
const installed = Object.keys(updatedConfig.installedSounds);
|
|
42
|
-
const list = installed.length > 0 ? installed.join(", ") : "(none)";
|
|
43
|
-
console.error(`Sound '${soundName}' is not installed. Installed sounds: ${list}`);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Requirement 9.6 — preserve shared dependency files
|
|
48
|
-
const preservedFiles = getFilesReferencedByOtherSounds(updatedConfig, soundsToRemove);
|
|
49
|
-
for (const soundName of sounds) {
|
|
50
|
-
const entry = updatedConfig.installedSounds[soundName];
|
|
51
|
-
const filesToDelete = getFilesToDelete(entry.files, preservedFiles);
|
|
52
|
-
// Requirement 9.1 — delete sound module files
|
|
53
|
-
for (const filePath of filesToDelete) {
|
|
54
|
-
if (existsSync(filePath)) {
|
|
55
|
-
unlinkSync(filePath);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Requirement 9.2 — remove from installedSounds
|
|
59
|
-
delete updatedConfig.installedSounds[soundName];
|
|
60
|
-
// Requirement 9.3 — update theme mappings
|
|
61
|
-
if (ThemeManager.exists(projectRoot)) {
|
|
62
|
-
const themeConfig = ThemeManager.read(projectRoot);
|
|
63
|
-
const updatedThemeConfig = ThemeManager.removeSoundMappings(themeConfig, soundName);
|
|
64
|
-
ThemeManager.write(projectRoot, updatedThemeConfig);
|
|
65
|
-
}
|
|
66
|
-
console.log(`✔ Removed ${soundName}`);
|
|
67
|
-
}
|
|
68
|
-
// Write updated config once after all sounds are processed
|
|
69
|
-
ConfigManager.write(projectRoot, updatedConfig);
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=remove.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../src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ACnD,MAAM,kBAAkB,GAAG,YAAY,CAAC,mBAAmB,CAC1D,WAAW,EACX,SAAS,CACT,CAAC;YACF,YAAY,CAAC,KAAK,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,aAAa,SAAS,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,2DAA2D;IAC3D,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/commands/theme.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `audx theme init` — create `audx.themes.json` with a default theme.
|
|
3
|
-
* Requirement 5.1, 5.2, 5.3, 5.4
|
|
4
|
-
*/
|
|
5
|
-
export declare function themeInitCommand(projectRoot: string): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* `audx theme set <theme-name>` — set the active theme.
|
|
8
|
-
* Requirement 6.1, 6.2
|
|
9
|
-
*/
|
|
10
|
-
export declare function themeSetCommand(themeName: string, projectRoot: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* `audx theme map <semantic-name> <sound-name>` — map a semantic name to an installed sound.
|
|
13
|
-
* Requirement 6.3, 6.4, 6.5
|
|
14
|
-
*/
|
|
15
|
-
export declare function themeMapCommand(semanticName: string, soundName: string, projectRoot: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* `audx theme create <theme-name>` — add a new theme with all names mapped to null.
|
|
18
|
-
* Requirement 6.6
|
|
19
|
-
*/
|
|
20
|
-
export declare function themeCreateCommand(themeName: string, projectRoot: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* `audx theme list` — display all themes, indicate active theme.
|
|
23
|
-
* Requirement 6.7
|
|
24
|
-
*/
|
|
25
|
-
export declare function themeListCommand(projectRoot: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* `audx theme generate` — generate `sound-theme.ts` via ThemeCodegen.
|
|
28
|
-
* Requirement 7.1
|
|
29
|
-
*/
|
|
30
|
-
export declare function themeGenerateCommand(projectRoot: string): void;
|
|
31
|
-
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/commands/theme.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAc5E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GACjB,IAAI,CAyCN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GACjB,IAAI,CAWN;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAa1D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAwB9D"}
|
package/dist/commands/theme.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { createInterface } from "node:readline";
|
|
4
|
-
import { generate as generateThemeCode } from "../codegen/theme-codegen.js";
|
|
5
|
-
import { loadFromTsConfig } from "../core/alias-resolver.js";
|
|
6
|
-
import * as ConfigManager from "../core/config.js";
|
|
7
|
-
import * as ThemeManager from "../core/theme-manager.js";
|
|
8
|
-
import { SEMANTIC_SOUND_NAMES } from "../types.js";
|
|
9
|
-
/**
|
|
10
|
-
* Prompt the user with a yes/no question via stdin/stdout.
|
|
11
|
-
* Returns `true` when the user answers y/yes (case-insensitive).
|
|
12
|
-
*/
|
|
13
|
-
function confirm(question) {
|
|
14
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
rl.question(question, (answer) => {
|
|
17
|
-
rl.close();
|
|
18
|
-
resolve(/^y(es)?$/i.test(answer.trim()));
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* `audx theme init` — create `audx.themes.json` with a default theme.
|
|
24
|
-
* Requirement 5.1, 5.2, 5.3, 5.4
|
|
25
|
-
*/
|
|
26
|
-
export async function themeInitCommand(projectRoot) {
|
|
27
|
-
// Prompt if theme config already exists
|
|
28
|
-
if (ThemeManager.exists(projectRoot)) {
|
|
29
|
-
const overwrite = await confirm("audx.themes.json already exists. Overwrite? (y/N) ");
|
|
30
|
-
if (!overwrite) {
|
|
31
|
-
console.log("Theme init cancelled.");
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// Build default theme with all 16 semantic names mapped to null
|
|
36
|
-
const defaultMappings = Object.fromEntries(SEMANTIC_SOUND_NAMES.map((name) => [name, null]));
|
|
37
|
-
const themeConfig = {
|
|
38
|
-
activeTheme: "default",
|
|
39
|
-
themes: {
|
|
40
|
-
default: defaultMappings,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
ThemeManager.write(projectRoot, themeConfig);
|
|
44
|
-
console.log("✔ Created audx.themes.json with default theme");
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* `audx theme set <theme-name>` — set the active theme.
|
|
48
|
-
* Requirement 6.1, 6.2
|
|
49
|
-
*/
|
|
50
|
-
export function themeSetCommand(themeName, projectRoot) {
|
|
51
|
-
const themeConfig = ThemeManager.read(projectRoot);
|
|
52
|
-
if (!(themeName in themeConfig.themes)) {
|
|
53
|
-
const available = Object.keys(themeConfig.themes).join(", ");
|
|
54
|
-
console.error(`Theme "${themeName}" does not exist. Available themes: ${available}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
const updated = ThemeManager.setActiveTheme(themeConfig, themeName);
|
|
58
|
-
ThemeManager.write(projectRoot, updated);
|
|
59
|
-
console.log(`✔ Active theme set to "${themeName}"`);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* `audx theme map <semantic-name> <sound-name>` — map a semantic name to an installed sound.
|
|
63
|
-
* Requirement 6.3, 6.4, 6.5
|
|
64
|
-
*/
|
|
65
|
-
export function themeMapCommand(semanticName, soundName, projectRoot) {
|
|
66
|
-
// Validate semantic name
|
|
67
|
-
if (!SEMANTIC_SOUND_NAMES.includes(semanticName)) {
|
|
68
|
-
const valid = SEMANTIC_SOUND_NAMES.join(", ");
|
|
69
|
-
console.error(`"${semanticName}" is not a valid semantic sound name. Valid names: ${valid}`);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
// Validate config exists and sound is installed
|
|
73
|
-
if (!ConfigManager.exists(projectRoot)) {
|
|
74
|
-
console.error("Configuration not found. Run 'audx init' first.");
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
const config = ConfigManager.read(projectRoot);
|
|
78
|
-
const installed = config.installedSounds[soundName];
|
|
79
|
-
if (!installed) {
|
|
80
|
-
console.error(`Sound "${soundName}" is not installed. Run 'audx add ${soundName}' first.`);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
// Find the sound module file path (the first file in soundDir, or the first file overall)
|
|
84
|
-
const soundFilePath = installed.files.find((f) => f.includes(config.soundDir)) ??
|
|
85
|
-
installed.files[0];
|
|
86
|
-
const themeConfig = ThemeManager.read(projectRoot);
|
|
87
|
-
const updated = ThemeManager.mapSound(themeConfig, semanticName, soundFilePath);
|
|
88
|
-
ThemeManager.write(projectRoot, updated);
|
|
89
|
-
console.log(`✔ Mapped "${semanticName}" → "${soundName}" (${soundFilePath}) in theme "${updated.activeTheme}"`);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* `audx theme create <theme-name>` — add a new theme with all names mapped to null.
|
|
93
|
-
* Requirement 6.6
|
|
94
|
-
*/
|
|
95
|
-
export function themeCreateCommand(themeName, projectRoot) {
|
|
96
|
-
const themeConfig = ThemeManager.read(projectRoot);
|
|
97
|
-
if (themeName in themeConfig.themes) {
|
|
98
|
-
console.error(`Theme "${themeName}" already exists.`);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
const updated = ThemeManager.createTheme(themeConfig, themeName);
|
|
102
|
-
ThemeManager.write(projectRoot, updated);
|
|
103
|
-
console.log(`✔ Created theme "${themeName}"`);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* `audx theme list` — display all themes, indicate active theme.
|
|
107
|
-
* Requirement 6.7
|
|
108
|
-
*/
|
|
109
|
-
export function themeListCommand(projectRoot) {
|
|
110
|
-
const themeConfig = ThemeManager.read(projectRoot);
|
|
111
|
-
console.log("Themes:");
|
|
112
|
-
for (const themeName of Object.keys(themeConfig.themes)) {
|
|
113
|
-
const indicator = themeName === themeConfig.activeTheme ? " (active)" : "";
|
|
114
|
-
const mappings = themeConfig.themes[themeName];
|
|
115
|
-
const mapped = Object.values(mappings).filter((v) => v !== null).length;
|
|
116
|
-
const total = Object.keys(mappings).length;
|
|
117
|
-
console.log(` ${themeName}${indicator} — ${mapped}/${total} sounds mapped`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* `audx theme generate` — generate `sound-theme.ts` via ThemeCodegen.
|
|
122
|
-
* Requirement 7.1
|
|
123
|
-
*/
|
|
124
|
-
export function themeGenerateCommand(projectRoot) {
|
|
125
|
-
if (!ConfigManager.exists(projectRoot)) {
|
|
126
|
-
console.error("Configuration not found. Run 'audx init' first.");
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
if (!ThemeManager.exists(projectRoot)) {
|
|
130
|
-
console.error("Theme configuration not found. Run 'audx theme init' first.");
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
const config = ConfigManager.read(projectRoot);
|
|
134
|
-
const themeConfig = ThemeManager.read(projectRoot);
|
|
135
|
-
const aliasMap = loadFromTsConfig(projectRoot);
|
|
136
|
-
const source = generateThemeCode(themeConfig, aliasMap, config);
|
|
137
|
-
const outputPath = join(projectRoot, config.libDir, "sound-theme.ts");
|
|
138
|
-
mkdirSync(join(projectRoot, config.libDir), { recursive: true });
|
|
139
|
-
writeFileSync(outputPath, source, "utf-8");
|
|
140
|
-
console.log(`✔ Generated ${config.libDir}/sound-theme.ts`);
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/commands/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,aAAa,CAAC;AAE3E;;;GAGG;AACH,SAAS,OAAO,CAAC,QAAgB;IAChC,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,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AW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAEtE,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,MAAM,iBAAiB,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAqEA,wBAAsB,aAAa,CAClC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAqFf"}
|
package/dist/commands/update.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { basename, dirname, join } from "node:path";
|
|
3
|
-
import { loadFromTsConfig } from "../core/alias-resolver.js";
|
|
4
|
-
import * as ConfigManager from "../core/config.js";
|
|
5
|
-
import { writeRegistryFile } from "../core/file-writer.js";
|
|
6
|
-
import { fetchItem } from "../core/registry.js";
|
|
7
|
-
/**
|
|
8
|
-
* Resolve the expected local file path for a registry file based on its type
|
|
9
|
-
* and the project config.
|
|
10
|
-
*/
|
|
11
|
-
function resolveLocalPath(file, config, projectRoot) {
|
|
12
|
-
const fileName = basename(file.path);
|
|
13
|
-
if (file.type === "registry:hook") {
|
|
14
|
-
const hooksDir = join(dirname(config.libDir), "hooks");
|
|
15
|
-
return join(projectRoot, hooksDir, fileName);
|
|
16
|
-
}
|
|
17
|
-
if (file.type === "registry:lib") {
|
|
18
|
-
const normalised = file.path.replace(/\\/g, "/");
|
|
19
|
-
if (normalised.includes("/sounds/")) {
|
|
20
|
-
return join(projectRoot, config.soundDir, fileName);
|
|
21
|
-
}
|
|
22
|
-
return join(projectRoot, config.libDir, fileName);
|
|
23
|
-
}
|
|
24
|
-
return join(projectRoot, config.soundDir, fileName);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Read local file content, returning null if the file cannot be read.
|
|
28
|
-
*/
|
|
29
|
-
function readLocalFile(filePath) {
|
|
30
|
-
try {
|
|
31
|
-
return readFileSync(filePath, "utf-8");
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Check whether a registry item has changes compared to local files.
|
|
39
|
-
*/
|
|
40
|
-
function hasChanges(registryFiles, config, projectRoot) {
|
|
41
|
-
for (const file of registryFiles) {
|
|
42
|
-
const localPath = resolveLocalPath(file, config, projectRoot);
|
|
43
|
-
const localContent = readLocalFile(localPath);
|
|
44
|
-
if (localContent === null) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
if (file.content !== localContent) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
export async function updateCommand(soundName, projectRoot) {
|
|
54
|
-
// Config must exist
|
|
55
|
-
if (!ConfigManager.exists(projectRoot)) {
|
|
56
|
-
console.error("Configuration not found. Run 'audx init' first.");
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
const config = ConfigManager.read(projectRoot);
|
|
60
|
-
const aliasMap = loadFromTsConfig(projectRoot);
|
|
61
|
-
const updatedConfig = {
|
|
62
|
-
...config,
|
|
63
|
-
installedSounds: { ...config.installedSounds },
|
|
64
|
-
};
|
|
65
|
-
// Requirement 10.5 — if sound name provided, update only that sound
|
|
66
|
-
const soundsToUpdate = soundName
|
|
67
|
-
? [soundName]
|
|
68
|
-
: Object.keys(config.installedSounds);
|
|
69
|
-
if (soundsToUpdate.length === 0) {
|
|
70
|
-
console.log("No sounds installed.");
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Validate the specified sound is installed
|
|
74
|
-
if (soundName && !config.installedSounds[soundName]) {
|
|
75
|
-
console.error(`Sound '${soundName}' is not installed. Installed sounds: ${Object.keys(config.installedSounds).join(", ") || "(none)"}`);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
let updatedCount = 0;
|
|
79
|
-
for (const name of soundsToUpdate) {
|
|
80
|
-
try {
|
|
81
|
-
// Fetch current registry item
|
|
82
|
-
const item = await fetchItem(config.registryUrl, name);
|
|
83
|
-
// Requirement 10.4 — only update sounds that have differences
|
|
84
|
-
if (!soundName && !hasChanges(item.files, config, projectRoot)) {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const targetDir = join(projectRoot, config.soundDir);
|
|
88
|
-
const writtenFiles = [];
|
|
89
|
-
// Overwrite local files with registry content
|
|
90
|
-
for (const file of item.files) {
|
|
91
|
-
const writtenPath = writeRegistryFile(file, targetDir, aliasMap, config);
|
|
92
|
-
if (writtenPath) {
|
|
93
|
-
writtenFiles.push(writtenPath);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// File was skipped (existing dependency) — keep it in the list
|
|
97
|
-
const localPath = resolveLocalPath(file, config, projectRoot);
|
|
98
|
-
writtenFiles.push(localPath);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Requirement 10.6 — update timestamp in config
|
|
102
|
-
updatedConfig.installedSounds[name] = {
|
|
103
|
-
files: writtenFiles,
|
|
104
|
-
installedAt: new Date().toISOString(),
|
|
105
|
-
};
|
|
106
|
-
updatedCount++;
|
|
107
|
-
console.log(`✔ Updated ${name}`);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
// Requirement 10.7 — continue on individual fetch failures with warning
|
|
111
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
112
|
-
console.warn(`⚠ Could not update '${name}': ${message}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// Write updated config if any sounds were updated
|
|
116
|
-
if (updatedCount > 0) {
|
|
117
|
-
ConfigManager.write(projectRoot, updatedConfig);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
console.log("All sounds are up to date.");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=update.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD;;;GAGG;AACH,SAAS,gBAAgB,CACxB,IAAkB,EAClB,MAAkB,EAClB,WAAmB;IAEnB,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAErC,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QAClC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CA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;IAC3C,CAAC;AACF,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AliasMap } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Read `tsconfig.json` from the given project root and extract
|
|
4
|
-
* `compilerOptions.paths` into an AliasMap.
|
|
5
|
-
*/
|
|
6
|
-
export declare function loadFromTsConfig(projectRoot: string): AliasMap;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve a target module path to an aliased import path if a matching alias
|
|
9
|
-
* exists, otherwise fall back to a relative import path.
|
|
10
|
-
*
|
|
11
|
-
* @param aliasMap - The alias map loaded from tsconfig
|
|
12
|
-
* @param sourceFilePath - Absolute or project-relative path of the importing file
|
|
13
|
-
* @param targetModulePath - Absolute or project-relative path of the target module
|
|
14
|
-
* @returns The import specifier to use (aliased or relative, without extension)
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveImport(aliasMap: AliasMap, sourceFilePath: string, targetModulePath: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Compute a relative import path from `sourceFilePath` to `targetModulePath`,
|
|
19
|
-
* stripping the file extension from the result.
|
|
20
|
-
*
|
|
21
|
-
* Both paths should be project-relative (e.g. `src/sounds/click.ts`).
|
|
22
|
-
*/
|
|
23
|
-
export declare function computeRelativePath(sourceFilePath: string, targetModulePath: string): string;
|
|
24
|
-
//# sourceMappingURL=alias-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alias-resolver.d.ts","sourceRoot":"","sources":["../../src/core/alias-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CA+B9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAwBR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAaR"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { dirname, join, relative } from "node:path";
|
|
3
|
-
/**
|
|
4
|
-
* Read `tsconfig.json` from the given project root and extract
|
|
5
|
-
* `compilerOptions.paths` into an AliasMap.
|
|
6
|
-
*/
|
|
7
|
-
export function loadFromTsConfig(projectRoot) {
|
|
8
|
-
let raw;
|
|
9
|
-
try {
|
|
10
|
-
raw = readFileSync(join(projectRoot, "tsconfig.json"), "utf-8");
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return { hasAliases: false, patterns: [] };
|
|
14
|
-
}
|
|
15
|
-
let parsed;
|
|
16
|
-
try {
|
|
17
|
-
parsed = JSON.parse(raw);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return { hasAliases: false, patterns: [] };
|
|
21
|
-
}
|
|
22
|
-
const paths = parsed?.compilerOptions != null
|
|
23
|
-
? parsed.compilerOptions
|
|
24
|
-
.paths
|
|
25
|
-
: undefined;
|
|
26
|
-
if (!paths || Object.keys(paths).length === 0) {
|
|
27
|
-
return { hasAliases: false, patterns: [] };
|
|
28
|
-
}
|
|
29
|
-
const patterns = Object.entries(paths).map(([alias, targets]) => ({
|
|
30
|
-
alias,
|
|
31
|
-
paths: targets,
|
|
32
|
-
}));
|
|
33
|
-
return { hasAliases: true, patterns };
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Resolve a target module path to an aliased import path if a matching alias
|
|
37
|
-
* exists, otherwise fall back to a relative import path.
|
|
38
|
-
*
|
|
39
|
-
* @param aliasMap - The alias map loaded from tsconfig
|
|
40
|
-
* @param sourceFilePath - Absolute or project-relative path of the importing file
|
|
41
|
-
* @param targetModulePath - Absolute or project-relative path of the target module
|
|
42
|
-
* @returns The import specifier to use (aliased or relative, without extension)
|
|
43
|
-
*/
|
|
44
|
-
export function resolveImport(aliasMap, sourceFilePath, targetModulePath) {
|
|
45
|
-
if (aliasMap.hasAliases) {
|
|
46
|
-
for (const pattern of aliasMap.patterns) {
|
|
47
|
-
const { alias, paths: aliasPaths } = pattern;
|
|
48
|
-
// Only handle wildcard aliases like `@/*` → [`./*`]
|
|
49
|
-
if (!alias.endsWith("/*") || aliasPaths.length === 0) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const aliasPrefix = alias.slice(0, -1); // "@/*" → "@/"
|
|
53
|
-
const pathPrefix = aliasPaths[0].slice(0, -1); // "./*" → "./"
|
|
54
|
-
// Normalise separators to forward slashes for comparison
|
|
55
|
-
const normTarget = targetModulePath.replace(/\\/g, "/");
|
|
56
|
-
if (normTarget.startsWith(pathPrefix)) {
|
|
57
|
-
const remainder = normTarget.slice(pathPrefix.length);
|
|
58
|
-
return stripExtension(aliasPrefix + remainder);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return computeRelativePath(sourceFilePath, targetModulePath);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Compute a relative import path from `sourceFilePath` to `targetModulePath`,
|
|
66
|
-
* stripping the file extension from the result.
|
|
67
|
-
*
|
|
68
|
-
* Both paths should be project-relative (e.g. `src/sounds/click.ts`).
|
|
69
|
-
*/
|
|
70
|
-
export function computeRelativePath(sourceFilePath, targetModulePath) {
|
|
71
|
-
const sourceDir = dirname(sourceFilePath);
|
|
72
|
-
let rel = relative(sourceDir, targetModulePath);
|
|
73
|
-
// Normalise Windows backslashes to forward slashes
|
|
74
|
-
rel = rel.replace(/\\/g, "/");
|
|
75
|
-
// Ensure the path starts with "./" when it doesn't already start with "."
|
|
76
|
-
if (!rel.startsWith(".")) {
|
|
77
|
-
rel = "./" + rel;
|
|
78
|
-
}
|
|
79
|
-
return stripExtension(rel);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Strip known TypeScript / JavaScript extensions from an import path.
|
|
83
|
-
*/
|
|
84
|
-
function stripExtension(importPath) {
|
|
85
|
-
return importPath.replace(/\.(tsx?|jsx?|mjs|cjs)$/, "");
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=alias-resolver.js.map
|