zard-cli 1.0.0-beta.13 → 1.0.0-beta.130
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 +39 -167
- package/commands/add/component-installer.d.ts +5 -1
- package/commands/add/component-installer.d.ts.map +1 -1
- package/commands/add/component-installer.js +34 -5
- package/commands/add/component-installer.js.map +1 -1
- package/commands/add/component-selector.d.ts +6 -0
- package/commands/add/component-selector.d.ts.map +1 -1
- package/commands/add/component-selector.js +9 -27
- package/commands/add/component-selector.js.map +1 -1
- package/commands/add/dark-mode-setup.d.ts +2 -0
- package/commands/add/dark-mode-setup.d.ts.map +1 -1
- package/commands/add/dark-mode-setup.js +5 -11
- package/commands/add/dark-mode-setup.js.map +1 -1
- package/commands/add/dependency-resolver.d.ts +9 -2
- package/commands/add/dependency-resolver.d.ts.map +1 -1
- package/commands/add/dependency-resolver.js +91 -21
- package/commands/add/dependency-resolver.js.map +1 -1
- package/commands/add/index.d.ts.map +1 -1
- package/commands/add/index.js +140 -86
- package/commands/add/index.js.map +1 -1
- package/commands/add/stylesheet-setup.d.ts +3 -0
- package/commands/add/stylesheet-setup.d.ts.map +1 -0
- package/commands/add/stylesheet-setup.js +92 -0
- package/commands/add/stylesheet-setup.js.map +1 -0
- package/commands/add/wizard.d.ts +35 -0
- package/commands/add/wizard.d.ts.map +1 -0
- package/commands/add/wizard.js +299 -0
- package/commands/add/wizard.js.map +1 -0
- package/commands/init/config-prompter.d.ts +67 -56
- package/commands/init/config-prompter.d.ts.map +1 -1
- package/commands/init/config-prompter.js +92 -74
- package/commands/init/config-prompter.js.map +1 -1
- package/commands/init/dependencies.d.ts +1 -8
- package/commands/init/dependencies.d.ts.map +1 -1
- package/commands/init/dependencies.js +51 -23
- package/commands/init/dependencies.js.map +1 -1
- package/commands/init/index.d.ts.map +1 -1
- package/commands/init/index.js +150 -86
- package/commands/init/index.js.map +1 -1
- package/commands/init/project-kind.d.ts +82 -0
- package/commands/init/project-kind.d.ts.map +1 -0
- package/commands/init/project-kind.js +166 -0
- package/commands/init/project-kind.js.map +1 -0
- package/commands/init/steps.d.ts +15 -0
- package/commands/init/steps.d.ts.map +1 -0
- package/commands/init/steps.js +154 -0
- package/commands/init/steps.js.map +1 -0
- package/commands/init/tailwind-setup.d.ts +9 -2
- package/commands/init/tailwind-setup.d.ts.map +1 -1
- package/commands/init/tailwind-setup.js +33 -9
- package/commands/init/tailwind-setup.js.map +1 -1
- package/commands/init/theme-loader.d.ts.map +1 -1
- package/commands/init/theme-loader.js +1 -3
- package/commands/init/theme-loader.js.map +1 -1
- package/commands/init/tsconfig-updater.d.ts +8 -1
- package/commands/init/tsconfig-updater.d.ts.map +1 -1
- package/commands/init/tsconfig-updater.js +30 -11
- package/commands/init/tsconfig-updater.js.map +1 -1
- package/commands/init/update-angular-config.d.ts.map +1 -1
- package/commands/init/update-angular-config.js +28 -47
- package/commands/init/update-angular-config.js.map +1 -1
- package/commands/init/vite-setup.d.ts +11 -0
- package/commands/init/vite-setup.d.ts.map +1 -0
- package/commands/init/vite-setup.js +61 -0
- package/commands/init/vite-setup.js.map +1 -0
- package/commands/init/wizard.d.ts +30 -0
- package/commands/init/wizard.d.ts.map +1 -0
- package/commands/init/wizard.js +560 -0
- package/commands/init/wizard.js.map +1 -0
- package/constants/app.constants.d.ts +17 -0
- package/constants/app.constants.d.ts.map +1 -1
- package/constants/app.constants.js +39 -16
- package/constants/app.constants.js.map +1 -1
- package/core/icons/families.d.ts +38 -0
- package/core/icons/families.d.ts.map +1 -0
- package/core/icons/families.js +26 -0
- package/core/icons/families.js.map +1 -0
- package/core/icons/icon-map.d.ts +24 -0
- package/core/icons/icon-map.d.ts.map +1 -0
- package/core/icons/icon-map.js +141 -0
- package/core/icons/icon-map.js.map +1 -0
- package/core/icons/index.d.ts +107 -0
- package/core/icons/index.d.ts.map +1 -0
- package/core/icons/index.js +183 -0
- package/core/icons/index.js.map +1 -0
- package/core/registry/registry-data.d.ts.map +1 -1
- package/core/registry/registry-data.js +861 -108
- package/core/registry/registry-data.js.map +1 -1
- package/core/themes/theme-definitions.d.ts +5 -5
- package/core/themes/theme-definitions.d.ts.map +1 -1
- package/core/themes/theme-definitions.js +75 -82
- package/core/themes/theme-definitions.js.map +1 -1
- package/index.js +41 -4
- package/index.js.map +1 -1
- package/package.json +9 -14
- package/ui/blocks.d.ts +71 -0
- package/ui/blocks.d.ts.map +1 -0
- package/ui/blocks.js +116 -0
- package/ui/blocks.js.map +1 -0
- package/ui/brand.d.ts +14 -0
- package/ui/brand.d.ts.map +1 -0
- package/ui/brand.js +35 -0
- package/ui/brand.js.map +1 -0
- package/ui/engine/animation/index.d.ts +38 -0
- package/ui/engine/animation/index.d.ts.map +1 -0
- package/ui/engine/animation/index.js +102 -0
- package/ui/engine/animation/index.js.map +1 -0
- package/ui/engine/ansi/index.d.ts +51 -0
- package/ui/engine/ansi/index.d.ts.map +1 -0
- package/ui/engine/ansi/index.js +116 -0
- package/ui/engine/ansi/index.js.map +1 -0
- package/ui/engine/components/index.d.ts +211 -0
- package/ui/engine/components/index.d.ts.map +1 -0
- package/ui/engine/components/index.js +109 -0
- package/ui/engine/components/index.js.map +1 -0
- package/ui/engine/cursor/index.d.ts +16 -0
- package/ui/engine/cursor/index.d.ts.map +1 -0
- package/ui/engine/cursor/index.js +40 -0
- package/ui/engine/cursor/index.js.map +1 -0
- package/ui/engine/diff/index.d.ts +26 -0
- package/ui/engine/diff/index.d.ts.map +1 -0
- package/ui/engine/diff/index.js +56 -0
- package/ui/engine/diff/index.js.map +1 -0
- package/ui/engine/events/index.d.ts +24 -0
- package/ui/engine/events/index.d.ts.map +1 -0
- package/ui/engine/events/index.js +60 -0
- package/ui/engine/events/index.js.map +1 -0
- package/ui/engine/focus/index.d.ts +25 -0
- package/ui/engine/focus/index.d.ts.map +1 -0
- package/ui/engine/focus/index.js +77 -0
- package/ui/engine/focus/index.js.map +1 -0
- package/ui/engine/frame/index.d.ts +48 -0
- package/ui/engine/frame/index.d.ts.map +1 -0
- package/ui/engine/frame/index.js +0 -0
- package/ui/engine/frame/index.js.map +1 -0
- package/ui/engine/index.d.ts +28 -0
- package/ui/engine/index.d.ts.map +1 -0
- package/ui/engine/index.js +28 -0
- package/ui/engine/index.js.map +1 -0
- package/ui/engine/input/index.d.ts +36 -0
- package/ui/engine/input/index.d.ts.map +1 -0
- package/ui/engine/input/index.js +224 -0
- package/ui/engine/input/index.js.map +1 -0
- package/ui/engine/layout/index.d.ts +42 -0
- package/ui/engine/layout/index.d.ts.map +1 -0
- package/ui/engine/layout/index.js +241 -0
- package/ui/engine/layout/index.js.map +1 -0
- package/ui/engine/renderer/index.d.ts +43 -0
- package/ui/engine/renderer/index.d.ts.map +1 -0
- package/ui/engine/renderer/index.js +619 -0
- package/ui/engine/renderer/index.js.map +1 -0
- package/ui/engine/scheduler/index.d.ts +22 -0
- package/ui/engine/scheduler/index.d.ts.map +1 -0
- package/ui/engine/scheduler/index.js +77 -0
- package/ui/engine/scheduler/index.js.map +1 -0
- package/ui/engine/screen/index.d.ts +39 -0
- package/ui/engine/screen/index.d.ts.map +1 -0
- package/ui/engine/screen/index.js +255 -0
- package/ui/engine/screen/index.js.map +1 -0
- package/ui/engine/terminal/index.d.ts +84 -0
- package/ui/engine/terminal/index.d.ts.map +1 -0
- package/ui/engine/terminal/index.js +235 -0
- package/ui/engine/terminal/index.js.map +1 -0
- package/ui/engine/testing/index.d.ts +27 -0
- package/ui/engine/testing/index.d.ts.map +1 -0
- package/ui/engine/testing/index.js +63 -0
- package/ui/engine/testing/index.js.map +1 -0
- package/ui/engine/theme/index.d.ts +26 -0
- package/ui/engine/theme/index.d.ts.map +1 -0
- package/ui/engine/theme/index.js +128 -0
- package/ui/engine/theme/index.js.map +1 -0
- package/ui/engine/utils/index.d.ts +12 -0
- package/ui/engine/utils/index.d.ts.map +1 -0
- package/ui/engine/utils/index.js +143 -0
- package/ui/engine/utils/index.js.map +1 -0
- package/ui/gate.d.ts +19 -0
- package/ui/gate.d.ts.map +1 -0
- package/ui/gate.js +36 -0
- package/ui/gate.js.map +1 -0
- package/ui/index.d.ts +18 -0
- package/ui/index.d.ts.map +1 -0
- package/ui/index.js +18 -0
- package/ui/index.js.map +1 -0
- package/ui/log-sink.d.ts +24 -0
- package/ui/log-sink.d.ts.map +1 -0
- package/ui/log-sink.js +35 -0
- package/ui/log-sink.js.map +1 -0
- package/ui/output.d.ts +14 -0
- package/ui/output.d.ts.map +1 -0
- package/ui/output.js +28 -0
- package/ui/output.js.map +1 -0
- package/ui/report.d.ts +30 -0
- package/ui/report.d.ts.map +1 -0
- package/ui/report.js +45 -0
- package/ui/report.js.map +1 -0
- package/ui/runner.d.ts +66 -0
- package/ui/runner.d.ts.map +1 -0
- package/ui/runner.js +135 -0
- package/ui/runner.js.map +1 -0
- package/ui/style.d.ts +24 -0
- package/ui/style.d.ts.map +1 -0
- package/ui/style.js +44 -0
- package/ui/style.js.map +1 -0
- package/ui/testing/fake-tty.d.ts +26 -0
- package/ui/testing/fake-tty.d.ts.map +1 -0
- package/ui/testing/fake-tty.js +61 -0
- package/ui/testing/fake-tty.js.map +1 -0
- package/ui/text-input.d.ts +31 -0
- package/ui/text-input.d.ts.map +1 -0
- package/ui/text-input.js +89 -0
- package/ui/text-input.js.map +1 -0
- package/ui/theme.d.ts +10 -0
- package/ui/theme.d.ts.map +1 -0
- package/ui/theme.js +20 -0
- package/ui/theme.js.map +1 -0
- package/utils/angular-compat.d.ts +21 -0
- package/utils/angular-compat.d.ts.map +1 -0
- package/utils/angular-compat.js +52 -0
- package/utils/angular-compat.js.map +1 -0
- package/utils/config.d.ts +55 -69
- package/utils/config.d.ts.map +1 -1
- package/utils/config.js +66 -9
- package/utils/config.js.map +1 -1
- package/utils/errors.d.ts +27 -0
- package/utils/errors.d.ts.map +1 -0
- package/utils/errors.js +45 -0
- package/utils/errors.js.map +1 -0
- package/utils/get-package-info.js +4 -4
- package/utils/get-package-info.js.map +1 -1
- package/utils/get-project-info.d.ts +30 -0
- package/utils/get-project-info.d.ts.map +1 -1
- package/utils/get-project-info.js +195 -6
- package/utils/get-project-info.js.map +1 -1
- package/utils/http-client.d.ts +8 -0
- package/utils/http-client.d.ts.map +1 -0
- package/utils/http-client.js +83 -0
- package/utils/http-client.js.map +1 -0
- package/utils/icon-catalog.d.ts +34 -0
- package/utils/icon-catalog.d.ts.map +1 -0
- package/utils/icon-catalog.js +63 -0
- package/utils/icon-catalog.js.map +1 -0
- package/utils/logger.d.ts +16 -1
- package/utils/logger.d.ts.map +1 -1
- package/utils/logger.js +104 -12
- package/utils/logger.js.map +1 -1
- package/utils/package-manager.d.ts +44 -1
- package/utils/package-manager.d.ts.map +1 -1
- package/utils/package-manager.js +210 -14
- package/utils/package-manager.js.map +1 -1
- package/utils/registry.d.ts +86 -2
- package/utils/registry.d.ts.map +1 -1
- package/utils/registry.js +147 -31
- package/utils/registry.js.map +1 -1
- package/utils/schema-version.d.ts +21 -0
- package/utils/schema-version.d.ts.map +1 -0
- package/utils/schema-version.js +28 -0
- package/utils/schema-version.js.map +1 -0
- package/utils/source-file.d.ts +40 -0
- package/utils/source-file.d.ts.map +1 -0
- package/utils/source-file.js +104 -0
- package/utils/source-file.js.map +1 -0
- package/utils/theme-selector.d.ts +1 -1
- package/utils/theme-selector.d.ts.map +1 -1
- package/utils/theme-selector.js +6 -6
- package/utils/theme-selector.js.map +1 -1
- package/utils/fetch-component.d.ts +0 -3
- package/utils/fetch-component.d.ts.map +0 -1
- package/utils/fetch-component.js +0 -75
- package/utils/fetch-component.js.map +0 -1
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import { readFileSync } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// Not `__dirname`: transpiled to CJS (as Jest does) that name is already bound
|
|
5
|
+
// by the module wrapper, and redeclaring it is a syntax error.
|
|
6
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const VERSION_FALLBACK = '0.0.0';
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* Reads the CLI version from the package.json that ships with the binary.
|
|
10
|
+
*
|
|
11
|
+
* The build copies package.json next to the compiled entrypoint, so from
|
|
12
|
+
* `constants/` it is always one level up — both in `dist/` and in the published
|
|
13
|
+
* package, whose root *is* `dist/`. Going up two levels instead used to land on
|
|
14
|
+
* `packages/cli/package.json` inside the monorepo, which hid the bug during
|
|
15
|
+
* development, and on `node_modules/package.json` once installed, which is why
|
|
16
|
+
* `zard-cli --version` printed `0.0.0` for users.
|
|
17
|
+
*
|
|
18
|
+
* The second candidate covers running straight from `src/`, and the name check
|
|
19
|
+
* keeps an unrelated package.json further up the tree from being picked up.
|
|
20
|
+
*
|
|
21
|
+
* Exported for testing: the directory is a parameter so both layouts can be
|
|
22
|
+
* exercised without depending on where the test file itself lives.
|
|
9
23
|
*/
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
export function resolveAppVersion(fromDir) {
|
|
25
|
+
const candidates = [join(fromDir, '../package.json'), join(fromDir, '../../package.json')];
|
|
26
|
+
for (const candidate of candidates) {
|
|
27
|
+
try {
|
|
28
|
+
const packageJson = JSON.parse(readFileSync(candidate, 'utf8'));
|
|
29
|
+
if (typeof packageJson === 'object' &&
|
|
30
|
+
packageJson !== null &&
|
|
31
|
+
'version' in packageJson &&
|
|
32
|
+
'name' in packageJson &&
|
|
33
|
+
typeof packageJson.version === 'string' &&
|
|
34
|
+
typeof packageJson.name === 'string' &&
|
|
35
|
+
packageJson.name.startsWith('zard-cli')) {
|
|
36
|
+
return packageJson.version;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Not there, or not readable — try the next candidate.
|
|
41
|
+
}
|
|
21
42
|
}
|
|
43
|
+
console.warn('Failed to read version from package.json');
|
|
44
|
+
return VERSION_FALLBACK;
|
|
22
45
|
}
|
|
23
|
-
export const APP_VERSION =
|
|
46
|
+
export const APP_VERSION = resolveAppVersion(moduleDir);
|
|
24
47
|
//# sourceMappingURL=app.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.constants.js","sourceRoot":"","sources":["../../src/constants/app.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,
|
|
1
|
+
{"version":3,"file":"app.constants.js","sourceRoot":"","sources":["../../src/constants/app.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,+EAA+E;AAC/E,+DAA+D;AAC/D,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAE3F,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,WAAW,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;YACzE,IACE,OAAO,WAAW,KAAK,QAAQ;gBAC/B,WAAW,KAAK,IAAI;gBACpB,SAAS,IAAI,WAAW;gBACxB,MAAM,IAAI,WAAW;gBACrB,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ;gBACvC,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ;gBACpC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EACvC,CAAC;gBACD,OAAO,WAAW,CAAC,OAAO,CAAC;YAC7B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,uDAAuD;QACzD,CAAC;IACH,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IACzD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icon families `components.json` accepts under `icons`.
|
|
3
|
+
*
|
|
4
|
+
* Every component in the library draws through ng-icons' `<ng-icon>`, which is
|
|
5
|
+
* family-agnostic: what ties the drawing to one family is the package the
|
|
6
|
+
* symbols are imported from (`@ng-icons/lucide`) and the prefix they carry
|
|
7
|
+
* (`lucideCheck`). Both are declared here, and that is all that separates one
|
|
8
|
+
* family from another on the install path.
|
|
9
|
+
*
|
|
10
|
+
* This table is the local copy — the one used when the registry does not
|
|
11
|
+
* answer. The authoritative list comes from `<registry>/icons.json`, which is
|
|
12
|
+
* what lets a new family arrive without anyone updating the CLI.
|
|
13
|
+
*/
|
|
14
|
+
export interface IconFamilyInfo {
|
|
15
|
+
/** How it appears in `components.json`. */
|
|
16
|
+
readonly value: string;
|
|
17
|
+
/** Display name, for prompts and reports. */
|
|
18
|
+
readonly label: string;
|
|
19
|
+
/** The npm package the project needs installed. */
|
|
20
|
+
readonly package: string;
|
|
21
|
+
/** The prefix of the symbols that package exports (`lucide` → `lucideCheck`). */
|
|
22
|
+
readonly prefix: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A string, not the union of the known families.
|
|
26
|
+
*
|
|
27
|
+
* The literal type would be more precise and more wrong: families now come from
|
|
28
|
+
* the registry, so the valid set is whatever is published at run time, not
|
|
29
|
+
* whatever existed when the CLI was compiled. `assertIconFamily` validates the
|
|
30
|
+
* value against the catalog in hand.
|
|
31
|
+
*/
|
|
32
|
+
export type IconFamily = string;
|
|
33
|
+
export declare const ICON_FAMILIES: Record<string, IconFamilyInfo>;
|
|
34
|
+
/** The family `libs/zard` uses — the one the registry files are written in. */
|
|
35
|
+
export declare const SOURCE_ICON_FAMILY: IconFamily;
|
|
36
|
+
/** The package that registers `<ng-icon>`, shared by every family. */
|
|
37
|
+
export declare const ICON_CORE_PACKAGE = "@ng-icons/core";
|
|
38
|
+
//# sourceMappingURL=families.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"families.d.ts","sourceRoot":"","sources":["../../../src/core/icons/families.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAOxD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,EAAE,UAAqB,CAAC;AAEvD,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icon families `components.json` accepts under `icons`.
|
|
3
|
+
*
|
|
4
|
+
* Every component in the library draws through ng-icons' `<ng-icon>`, which is
|
|
5
|
+
* family-agnostic: what ties the drawing to one family is the package the
|
|
6
|
+
* symbols are imported from (`@ng-icons/lucide`) and the prefix they carry
|
|
7
|
+
* (`lucideCheck`). Both are declared here, and that is all that separates one
|
|
8
|
+
* family from another on the install path.
|
|
9
|
+
*
|
|
10
|
+
* This table is the local copy — the one used when the registry does not
|
|
11
|
+
* answer. The authoritative list comes from `<registry>/icons.json`, which is
|
|
12
|
+
* what lets a new family arrive without anyone updating the CLI.
|
|
13
|
+
*/
|
|
14
|
+
export const ICON_FAMILIES = {
|
|
15
|
+
lucide: {
|
|
16
|
+
value: 'lucide',
|
|
17
|
+
label: 'Lucide',
|
|
18
|
+
package: '@ng-icons/lucide',
|
|
19
|
+
prefix: 'lucide',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
/** The family `libs/zard` uses — the one the registry files are written in. */
|
|
23
|
+
export const SOURCE_ICON_FAMILY = 'lucide';
|
|
24
|
+
/** The package that registers `<ng-icon>`, shared by every family. */
|
|
25
|
+
export const ICON_CORE_PACKAGE = '@ng-icons/core';
|
|
26
|
+
//# sourceMappingURL=families.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"families.js","sourceRoot":"","sources":["../../../src/core/icons/families.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAuBH,MAAM,CAAC,MAAM,aAAa,GAAmC;IAC3D,MAAM,EAAE;QACN,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,QAAQ;KACjB;CACF,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAe,QAAQ,CAAC;AAEvD,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The translation table between icon sets.
|
|
3
|
+
*
|
|
4
|
+
* Each row is an icon by what it MEANS — `check`, `chevron-down` — and the
|
|
5
|
+
* value is the symbol each set exports for it. Only the `lucide` column exists
|
|
6
|
+
* today, the one set the library supports; supporting another one means filling
|
|
7
|
+
* in its column, and nothing else along the install path changes.
|
|
8
|
+
*
|
|
9
|
+
* This is the copy bundled with the CLI. It is published at
|
|
10
|
+
* `<registry>/icons.json`, and that is where the CLI reads it from at run time
|
|
11
|
+
* — the file here is what holds when the registry does not answer, and the
|
|
12
|
+
* floor the published table is generated from.
|
|
13
|
+
*
|
|
14
|
+
* The list covers every icon the components and demos use today. A new icon in
|
|
15
|
+
* the code with no row here is an error: `icons.spec.ts` compares this table
|
|
16
|
+
* against what `libs/zard` actually imports.
|
|
17
|
+
*
|
|
18
|
+
* The tokens come from the lucide name in kebab-case because that already is
|
|
19
|
+
* the icon's semantic name (`lucideChevronDown` → `chevron-down`) — the key
|
|
20
|
+
* belongs to the table, not to the set, and stays valid once lucide is no
|
|
21
|
+
* longer the only column.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ICON_MAP: Record<string, Record<string, string>>;
|
|
24
|
+
//# sourceMappingURL=icon-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-map.d.ts","sourceRoot":"","sources":["../../../src/core/icons/icon-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqH3D,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The translation table between icon sets.
|
|
3
|
+
*
|
|
4
|
+
* Each row is an icon by what it MEANS — `check`, `chevron-down` — and the
|
|
5
|
+
* value is the symbol each set exports for it. Only the `lucide` column exists
|
|
6
|
+
* today, the one set the library supports; supporting another one means filling
|
|
7
|
+
* in its column, and nothing else along the install path changes.
|
|
8
|
+
*
|
|
9
|
+
* This is the copy bundled with the CLI. It is published at
|
|
10
|
+
* `<registry>/icons.json`, and that is where the CLI reads it from at run time
|
|
11
|
+
* — the file here is what holds when the registry does not answer, and the
|
|
12
|
+
* floor the published table is generated from.
|
|
13
|
+
*
|
|
14
|
+
* The list covers every icon the components and demos use today. A new icon in
|
|
15
|
+
* the code with no row here is an error: `icons.spec.ts` compares this table
|
|
16
|
+
* against what `libs/zard` actually imports.
|
|
17
|
+
*
|
|
18
|
+
* The tokens come from the lucide name in kebab-case because that already is
|
|
19
|
+
* the icon's semantic name (`lucideChevronDown` → `chevron-down`) — the key
|
|
20
|
+
* belongs to the table, not to the set, and stays valid once lucide is no
|
|
21
|
+
* longer the only column.
|
|
22
|
+
*/
|
|
23
|
+
export const ICON_MAP = {
|
|
24
|
+
'alert-triangle': { lucide: 'lucideAlertTriangle' },
|
|
25
|
+
'app-window': { lucide: 'lucideAppWindow' },
|
|
26
|
+
archive: { lucide: 'lucideArchive' },
|
|
27
|
+
'arrow-left': { lucide: 'lucideArrowLeft' },
|
|
28
|
+
'arrow-right': { lucide: 'lucideArrowRight' },
|
|
29
|
+
'arrow-up': { lucide: 'lucideArrowUp' },
|
|
30
|
+
'arrow-up-right': { lucide: 'lucideArrowUpRight' },
|
|
31
|
+
'audio-lines': { lucide: 'lucideAudioLines' },
|
|
32
|
+
'badge-check': { lucide: 'lucideBadgeCheck' },
|
|
33
|
+
bell: { lucide: 'lucideBell' },
|
|
34
|
+
bluetooth: { lucide: 'lucideBluetooth' },
|
|
35
|
+
bold: { lucide: 'lucideBold' },
|
|
36
|
+
'book-open-check': { lucide: 'lucideBookOpenCheck' },
|
|
37
|
+
bookmark: { lucide: 'lucideBookmark' },
|
|
38
|
+
bot: { lucide: 'lucideBot' },
|
|
39
|
+
'building-2': { lucide: 'lucideBuilding2' },
|
|
40
|
+
calculator: { lucide: 'lucideCalculator' },
|
|
41
|
+
calendar: { lucide: 'lucideCalendar' },
|
|
42
|
+
'calendar-plus': { lucide: 'lucideCalendarPlus' },
|
|
43
|
+
check: { lucide: 'lucideCheck' },
|
|
44
|
+
'chevron-down': { lucide: 'lucideChevronDown' },
|
|
45
|
+
'chevron-left': { lucide: 'lucideChevronLeft' },
|
|
46
|
+
'chevron-right': { lucide: 'lucideChevronRight' },
|
|
47
|
+
'chevron-up': { lucide: 'lucideChevronUp' },
|
|
48
|
+
'chevrons-left': { lucide: 'lucideChevronsLeft' },
|
|
49
|
+
'chevrons-right': { lucide: 'lucideChevronsRight' },
|
|
50
|
+
'chevrons-up-down': { lucide: 'lucideChevronsUpDown' },
|
|
51
|
+
'circle-alert': { lucide: 'lucideCircleAlert' },
|
|
52
|
+
'circle-check': { lucide: 'lucideCircleCheck' },
|
|
53
|
+
'circle-dashed': { lucide: 'lucideCircleDashed' },
|
|
54
|
+
'circle-fading-arrow-up': { lucide: 'lucideCircleFadingArrowUp' },
|
|
55
|
+
'circle-fading-plus': { lucide: 'lucideCircleFadingPlus' },
|
|
56
|
+
'circle-help': { lucide: 'lucideCircleHelp' },
|
|
57
|
+
'circle-small': { lucide: 'lucideCircleSmall' },
|
|
58
|
+
'clipboard-paste': { lucide: 'lucideClipboardPaste' },
|
|
59
|
+
clock: { lucide: 'lucideClock' },
|
|
60
|
+
'clock-2': { lucide: 'lucideClock2' },
|
|
61
|
+
cloud: { lucide: 'lucideCloud' },
|
|
62
|
+
code: { lucide: 'lucideCode' },
|
|
63
|
+
copy: { lucide: 'lucideCopy' },
|
|
64
|
+
'corner-down-left': { lucide: 'lucideCornerDownLeft' },
|
|
65
|
+
'credit-card': { lucide: 'lucideCreditCard' },
|
|
66
|
+
dot: { lucide: 'lucideDot' },
|
|
67
|
+
download: { lucide: 'lucideDownload' },
|
|
68
|
+
ellipsis: { lucide: 'lucideEllipsis' },
|
|
69
|
+
'external-link': { lucide: 'lucideExternalLink' },
|
|
70
|
+
'eye-off': { lucide: 'lucideEyeOff' },
|
|
71
|
+
file: { lucide: 'lucideFile' },
|
|
72
|
+
'file-code': { lucide: 'lucideFileCode' },
|
|
73
|
+
'file-code-2': { lucide: 'lucideFileCode2' },
|
|
74
|
+
'file-text': { lucide: 'lucideFileText' },
|
|
75
|
+
folder: { lucide: 'lucideFolder' },
|
|
76
|
+
'folder-code': { lucide: 'lucideFolderCode' },
|
|
77
|
+
'folder-plus': { lucide: 'lucideFolderPlus' },
|
|
78
|
+
footprints: { lucide: 'lucideFootprints' },
|
|
79
|
+
'gallery-vertical-end': { lucide: 'lucideGalleryVerticalEnd' },
|
|
80
|
+
'git-branch': { lucide: 'lucideGitBranch' },
|
|
81
|
+
globe: { lucide: 'lucideGlobe' },
|
|
82
|
+
house: { lucide: 'lucideHouse' },
|
|
83
|
+
image: { lucide: 'lucideImage' },
|
|
84
|
+
inbox: { lucide: 'lucideInbox' },
|
|
85
|
+
info: { lucide: 'lucideInfo' },
|
|
86
|
+
italic: { lucide: 'lucideItalic' },
|
|
87
|
+
keyboard: { lucide: 'lucideKeyboard' },
|
|
88
|
+
'layout-grid': { lucide: 'lucideLayoutGrid' },
|
|
89
|
+
lightbulb: { lucide: 'lucideLightbulb' },
|
|
90
|
+
'lightbulb-off': { lucide: 'lucideLightbulbOff' },
|
|
91
|
+
list: { lucide: 'lucideList' },
|
|
92
|
+
'list-filter': { lucide: 'lucideListFilter' },
|
|
93
|
+
'list-filter-plus': { lucide: 'lucideListFilterPlus' },
|
|
94
|
+
loader: { lucide: 'lucideLoader' },
|
|
95
|
+
'loader-2': { lucide: 'lucideLoader2' },
|
|
96
|
+
'loader-circle': { lucide: 'lucideLoaderCircle' },
|
|
97
|
+
'log-out': { lucide: 'lucideLogOut' },
|
|
98
|
+
mail: { lucide: 'lucideMail' },
|
|
99
|
+
'mail-check': { lucide: 'lucideMailCheck' },
|
|
100
|
+
maximize: { lucide: 'lucideMaximize' },
|
|
101
|
+
'message-square': { lucide: 'lucideMessageSquare' },
|
|
102
|
+
minimize: { lucide: 'lucideMinimize' },
|
|
103
|
+
minus: { lucide: 'lucideMinus' },
|
|
104
|
+
monitor: { lucide: 'lucideMonitor' },
|
|
105
|
+
'more-horizontal': { lucide: 'lucideMoreHorizontal' },
|
|
106
|
+
'octagon-x': { lucide: 'lucideOctagonX' },
|
|
107
|
+
'panel-left': { lucide: 'lucidePanelLeft' },
|
|
108
|
+
pencil: { lucide: 'lucidePencil' },
|
|
109
|
+
plus: { lucide: 'lucidePlus' },
|
|
110
|
+
'refresh-ccw': { lucide: 'lucideRefreshCcw' },
|
|
111
|
+
'refresh-cw': { lucide: 'lucideRefreshCw' },
|
|
112
|
+
'rotate-ccw': { lucide: 'lucideRotateCcw' },
|
|
113
|
+
save: { lucide: 'lucideSave' },
|
|
114
|
+
scissors: { lucide: 'lucideScissors' },
|
|
115
|
+
search: { lucide: 'lucideSearch' },
|
|
116
|
+
settings: { lucide: 'lucideSettings' },
|
|
117
|
+
share: { lucide: 'lucideShare' },
|
|
118
|
+
'shield-alert': { lucide: 'lucideShieldAlert' },
|
|
119
|
+
smartphone: { lucide: 'lucideSmartphone' },
|
|
120
|
+
smile: { lucide: 'lucideSmile' },
|
|
121
|
+
star: { lucide: 'lucideStar' },
|
|
122
|
+
sun: { lucide: 'lucideSun' },
|
|
123
|
+
tag: { lucide: 'lucideTag' },
|
|
124
|
+
terminal: { lucide: 'lucideTerminal' },
|
|
125
|
+
'thumbs-down': { lucide: 'lucideThumbsDown' },
|
|
126
|
+
'thumbs-up': { lucide: 'lucideThumbsUp' },
|
|
127
|
+
trash: { lucide: 'lucideTrash' },
|
|
128
|
+
'trash-2': { lucide: 'lucideTrash2' },
|
|
129
|
+
'trending-up': { lucide: 'lucideTrendingUp' },
|
|
130
|
+
'triangle-alert': { lucide: 'lucideTriangleAlert' },
|
|
131
|
+
underline: { lucide: 'lucideUnderline' },
|
|
132
|
+
user: { lucide: 'lucideUser' },
|
|
133
|
+
'user-round-x': { lucide: 'lucideUserRoundX' },
|
|
134
|
+
'volume-off': { lucide: 'lucideVolumeOff' },
|
|
135
|
+
wallet: { lucide: 'lucideWallet' },
|
|
136
|
+
waves: { lucide: 'lucideWaves' },
|
|
137
|
+
x: { lucide: 'lucideX' },
|
|
138
|
+
'zoom-in': { lucide: 'lucideZoomIn' },
|
|
139
|
+
'zoom-out': { lucide: 'lucideZoomOut' },
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=icon-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-map.js","sourceRoot":"","sources":["../../../src/core/icons/icon-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAA2C;IAC9D,gBAAgB,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE;IACnD,YAAY,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;IAC3C,OAAO,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE;IACpC,YAAY,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;IAC3C,aAAa,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;IAC7C,UAAU,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE;IACvC,gBAAgB,EAAE,EAAE,MAAM,EAAE,oBAAoB,EAAE;IAClD,aAAa,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;IAC7C,aAAa,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;IAC7C,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;IAC9B,SAAS,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;IACxC,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;IAC9B,iBAAiB,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE;IACpD,QAAQ,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE;IACtC,GAAG,EAAE,EAAE,MAAM,EAAE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K,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE;IAChC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;IACxB,SAAS,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;IACrC,UAAU,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE;CACxC,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icons — what the components draw, and how that changes with the family.
|
|
3
|
+
*
|
|
4
|
+
* Everything here works off a catalog: the pair (declared families, translation
|
|
5
|
+
* table). The local catalog is the bundled copy; the one that counts at runtime
|
|
6
|
+
* comes from `<registry>/icons.json`. That indirection is what makes "support
|
|
7
|
+
* material" a matter of publishing one more column in the registry, with no CLI
|
|
8
|
+
* release and no hunting for `lucide` through the code.
|
|
9
|
+
*
|
|
10
|
+
* `extractIcons` reads which icons a source uses (the registry publishes this)
|
|
11
|
+
* `retargetIcons` rewrites a source from one family to another (install uses it)
|
|
12
|
+
* `iconPackagesFor` says which packages the project needs (init uses it)
|
|
13
|
+
*/
|
|
14
|
+
import { type IconFamily, type IconFamilyInfo } from './families.js';
|
|
15
|
+
export { ICON_CORE_PACKAGE, ICON_FAMILIES, SOURCE_ICON_FAMILY, type IconFamily, type IconFamilyInfo, } from './families.js';
|
|
16
|
+
export { ICON_MAP } from './icon-map.js';
|
|
17
|
+
/** An icon by what it means: `check`, `chevron-down`. */
|
|
18
|
+
export type IconToken = string;
|
|
19
|
+
/**
|
|
20
|
+
* The declared families and the table that translates between them.
|
|
21
|
+
*
|
|
22
|
+
* `icons` is keyed by token and then by family — the same shape as
|
|
23
|
+
* `icon-map.ts`, which is the local copy of this same data.
|
|
24
|
+
*/
|
|
25
|
+
export interface IconCatalog {
|
|
26
|
+
readonly families: Readonly<Record<string, IconFamilyInfo>>;
|
|
27
|
+
readonly icons: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
28
|
+
}
|
|
29
|
+
/** The catalog bundled with the CLI — used when the registry does not answer. */
|
|
30
|
+
export declare const LOCAL_ICON_CATALOG: IconCatalog;
|
|
31
|
+
/** A list of icons in both forms: as the code writes them, and as the table names them. */
|
|
32
|
+
export interface IconList {
|
|
33
|
+
/** The symbols as they appear in the code (`lucideCheck`). */
|
|
34
|
+
readonly symbols: string[];
|
|
35
|
+
/** The same icons under the table's neutral key (`check`). */
|
|
36
|
+
readonly tokens: IconToken[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A component's icons, in the shape the registry publishes them.
|
|
40
|
+
*
|
|
41
|
+
* The two lists are separate because they serve different things: `symbols` and
|
|
42
|
+
* `tokens` are what `add` writes into the project — the ng-icons dependency
|
|
43
|
+
* comes from them — while `demos` are the icons that only appear in the
|
|
44
|
+
* documentation examples. A component can draw no icon at all and still have
|
|
45
|
+
* demos full of them, and switching family has to reach both.
|
|
46
|
+
*/
|
|
47
|
+
export interface ComponentIcons extends IconList {
|
|
48
|
+
/** The family the published files are written in. */
|
|
49
|
+
readonly family: IconFamily;
|
|
50
|
+
readonly demos: IconList;
|
|
51
|
+
}
|
|
52
|
+
export declare function iconFamilies(catalog?: IconCatalog): string[];
|
|
53
|
+
export declare function isIconFamily(value: string, catalog?: IconCatalog): boolean;
|
|
54
|
+
export declare function iconFamily(family: IconFamily, catalog?: IconCatalog): IconFamilyInfo | undefined;
|
|
55
|
+
/** The npm packages a project configured with this family needs. */
|
|
56
|
+
export declare function iconPackagesFor(family: IconFamily, catalog?: IconCatalog): string[];
|
|
57
|
+
export declare function tokenFor(symbol: string, family?: IconFamily, catalog?: IconCatalog): IconToken | undefined;
|
|
58
|
+
export declare function symbolFor(token: IconToken, family: IconFamily, catalog?: IconCatalog): string | undefined;
|
|
59
|
+
/** Tokens that have no symbol declared in this family yet. */
|
|
60
|
+
export declare function missingTokensFor(family: IconFamily, catalog?: IconCatalog): IconToken[];
|
|
61
|
+
/**
|
|
62
|
+
* The icon symbols a source imports.
|
|
63
|
+
*
|
|
64
|
+
* Only the import counts. A stray `name="lucideCheck"` in a template draws
|
|
65
|
+
* nothing without the matching `provideIcons`, so the import is at once the
|
|
66
|
+
* complete list and the list without false positives — `@ng-icons/core`
|
|
67
|
+
* (NgIcon, provideIcons, IconName) is left out because it is not a family.
|
|
68
|
+
*/
|
|
69
|
+
export declare function extractIcons(source: string, family?: IconFamily, catalog?: IconCatalog): string[];
|
|
70
|
+
/** The icons of a set of files, in both forms. */
|
|
71
|
+
export declare function listIcons(sources: readonly string[], family?: IconFamily, catalog?: IconCatalog): IconList;
|
|
72
|
+
/**
|
|
73
|
+
* A component's icon mapping, ready for the registry.
|
|
74
|
+
*
|
|
75
|
+
* It comes back filled in even when there is no icon at all: the field always
|
|
76
|
+
* being present is what tells "this component draws no icons" apart from "this
|
|
77
|
+
* registry was published before the mapping existed", so a reader never has to
|
|
78
|
+
* guess which of the two it is.
|
|
79
|
+
*/
|
|
80
|
+
export declare function collectIcons(files: readonly string[], demos?: readonly string[], family?: IconFamily, catalog?: IconCatalog): ComponentIcons;
|
|
81
|
+
export interface RetargetResult {
|
|
82
|
+
readonly content: string;
|
|
83
|
+
/** Symbols the target family does not declare — left untouched. */
|
|
84
|
+
readonly missing: string[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Rewrites a source from one icon family to another.
|
|
88
|
+
*
|
|
89
|
+
* Two swaps: the package the symbols come from, and each symbol itself. A symbol
|
|
90
|
+
* is replaced wherever it appears — the import, the `provideIcons({ lucideCheck })`
|
|
91
|
+
* and the template's `name="lucideCheck"` are the same word, and the object
|
|
92
|
+
* shorthand stays valid after the swap.
|
|
93
|
+
*
|
|
94
|
+
* A symbol with no equivalent in the target family is not invented: it stays as
|
|
95
|
+
* it is and comes back in `missing`, so the caller can warn instead of writing
|
|
96
|
+
* an import that does not resolve.
|
|
97
|
+
*/
|
|
98
|
+
export declare function retargetIcons(source: string, from: IconFamily, to: IconFamily, catalog?: IconCatalog): RetargetResult;
|
|
99
|
+
/**
|
|
100
|
+
* The mechanical half of the swap, separated from whatever decides what to swap.
|
|
101
|
+
*
|
|
102
|
+
* It is exported because this is where rewriting bugs live — whole-word
|
|
103
|
+
* replacement and the order of the alternation — and because testing it does
|
|
104
|
+
* not require more than one declared family.
|
|
105
|
+
*/
|
|
106
|
+
export declare function rewriteIcons(source: string, fromPackage: string, toPackage: string, replacements: ReadonlyMap<string, string>): string;
|
|
107
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/icons/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5E;AAED,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,EAAE,WAA0D,CAAC;AAE5F,2FAA2F;AAC3F,MAAM,WAAW,QAAQ;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,MAAM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K,GAAE,SAAS,MAAM,EAAO,EAC7B,MAAM,GAAE,UAA+B,EACvC,OAAO,GAAE,WAAgC,GACxC,cAAc,CAMhB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,UAAU,EACd,OAAO,GAAE,WAAgC,GACxC,cAAc,CAoBhB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACxC,MAAM,CAcR"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icons — what the components draw, and how that changes with the family.
|
|
3
|
+
*
|
|
4
|
+
* Everything here works off a catalog: the pair (declared families, translation
|
|
5
|
+
* table). The local catalog is the bundled copy; the one that counts at runtime
|
|
6
|
+
* comes from `<registry>/icons.json`. That indirection is what makes "support
|
|
7
|
+
* material" a matter of publishing one more column in the registry, with no CLI
|
|
8
|
+
* release and no hunting for `lucide` through the code.
|
|
9
|
+
*
|
|
10
|
+
* `extractIcons` reads which icons a source uses (the registry publishes this)
|
|
11
|
+
* `retargetIcons` rewrites a source from one family to another (install uses it)
|
|
12
|
+
* `iconPackagesFor` says which packages the project needs (init uses it)
|
|
13
|
+
*/
|
|
14
|
+
import { ICON_CORE_PACKAGE, ICON_FAMILIES, SOURCE_ICON_FAMILY, } from './families.js';
|
|
15
|
+
import { ICON_MAP } from './icon-map.js';
|
|
16
|
+
export { ICON_CORE_PACKAGE, ICON_FAMILIES, SOURCE_ICON_FAMILY, } from './families.js';
|
|
17
|
+
export { ICON_MAP } from './icon-map.js';
|
|
18
|
+
/** The catalog bundled with the CLI — used when the registry does not answer. */
|
|
19
|
+
export const LOCAL_ICON_CATALOG = { families: ICON_FAMILIES, icons: ICON_MAP };
|
|
20
|
+
/**
|
|
21
|
+
* Reverse symbol → token index, built per catalog and memoized.
|
|
22
|
+
*
|
|
23
|
+
* The remote catalog is a single object, fetched once per run, so a weak key is
|
|
24
|
+
* enough and the index is not rebuilt for every installed file.
|
|
25
|
+
*/
|
|
26
|
+
const reverseIndexes = new WeakMap();
|
|
27
|
+
function reverseIndex(catalog, family) {
|
|
28
|
+
let byFamily = reverseIndexes.get(catalog);
|
|
29
|
+
if (!byFamily) {
|
|
30
|
+
byFamily = new Map();
|
|
31
|
+
for (const [token, symbols] of Object.entries(catalog.icons)) {
|
|
32
|
+
for (const [name, symbol] of Object.entries(symbols)) {
|
|
33
|
+
const index = byFamily.get(name) ?? new Map();
|
|
34
|
+
index.set(symbol, token);
|
|
35
|
+
byFamily.set(name, index);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
reverseIndexes.set(catalog, byFamily);
|
|
39
|
+
}
|
|
40
|
+
return byFamily.get(family) ?? new Map();
|
|
41
|
+
}
|
|
42
|
+
export function iconFamilies(catalog = LOCAL_ICON_CATALOG) {
|
|
43
|
+
return Object.keys(catalog.families).sort();
|
|
44
|
+
}
|
|
45
|
+
export function isIconFamily(value, catalog = LOCAL_ICON_CATALOG) {
|
|
46
|
+
return Object.prototype.hasOwnProperty.call(catalog.families, value);
|
|
47
|
+
}
|
|
48
|
+
export function iconFamily(family, catalog = LOCAL_ICON_CATALOG) {
|
|
49
|
+
return catalog.families[family];
|
|
50
|
+
}
|
|
51
|
+
/** The npm packages a project configured with this family needs. */
|
|
52
|
+
export function iconPackagesFor(family, catalog = LOCAL_ICON_CATALOG) {
|
|
53
|
+
const info = iconFamily(family, catalog);
|
|
54
|
+
return info ? [ICON_CORE_PACKAGE, info.package] : [ICON_CORE_PACKAGE];
|
|
55
|
+
}
|
|
56
|
+
export function tokenFor(symbol, family = SOURCE_ICON_FAMILY, catalog = LOCAL_ICON_CATALOG) {
|
|
57
|
+
return reverseIndex(catalog, family).get(symbol);
|
|
58
|
+
}
|
|
59
|
+
export function symbolFor(token, family, catalog = LOCAL_ICON_CATALOG) {
|
|
60
|
+
return catalog.icons[token]?.[family];
|
|
61
|
+
}
|
|
62
|
+
/** Tokens that have no symbol declared in this family yet. */
|
|
63
|
+
export function missingTokensFor(family, catalog = LOCAL_ICON_CATALOG) {
|
|
64
|
+
return Object.keys(catalog.icons).filter(token => symbolFor(token, family, catalog) === undefined);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `import { lucideCheck, lucideX } from '@ng-icons/lucide'` — on one line or
|
|
68
|
+
* several, with a leading `type` or aliased. What matters is the package (which
|
|
69
|
+
* gives the family) and the names imported from it.
|
|
70
|
+
*/
|
|
71
|
+
const ICON_IMPORT = /import\s*(?:type\s+)?\{([^}]*)\}\s*from\s*['"]@ng-icons\/([a-z0-9-]+)['"]/g;
|
|
72
|
+
function familyByPackageSuffix(suffix, catalog) {
|
|
73
|
+
return Object.keys(catalog.families).find(name => catalog.families[name]?.package === `@ng-icons/${suffix}`);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The icon symbols a source imports.
|
|
77
|
+
*
|
|
78
|
+
* Only the import counts. A stray `name="lucideCheck"` in a template draws
|
|
79
|
+
* nothing without the matching `provideIcons`, so the import is at once the
|
|
80
|
+
* complete list and the list without false positives — `@ng-icons/core`
|
|
81
|
+
* (NgIcon, provideIcons, IconName) is left out because it is not a family.
|
|
82
|
+
*/
|
|
83
|
+
export function extractIcons(source, family = SOURCE_ICON_FAMILY, catalog = LOCAL_ICON_CATALOG) {
|
|
84
|
+
const found = new Set();
|
|
85
|
+
for (const match of source.matchAll(ICON_IMPORT)) {
|
|
86
|
+
if (familyByPackageSuffix(match[2] ?? '', catalog) !== family)
|
|
87
|
+
continue;
|
|
88
|
+
for (const specifier of (match[1] ?? '').split(',')) {
|
|
89
|
+
// `type Foo`, `Foo as Bar` — the package's symbol is always the first name.
|
|
90
|
+
const name = specifier
|
|
91
|
+
.trim()
|
|
92
|
+
.replace(/^type\s+/, '')
|
|
93
|
+
.split(/\s+as\s+/)[0]
|
|
94
|
+
?.trim();
|
|
95
|
+
if (name)
|
|
96
|
+
found.add(name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return [...found].sort();
|
|
100
|
+
}
|
|
101
|
+
/** The icons of a set of files, in both forms. */
|
|
102
|
+
export function listIcons(sources, family = SOURCE_ICON_FAMILY, catalog = LOCAL_ICON_CATALOG) {
|
|
103
|
+
const symbols = new Set();
|
|
104
|
+
for (const source of sources) {
|
|
105
|
+
for (const symbol of extractIcons(source, family, catalog))
|
|
106
|
+
symbols.add(symbol);
|
|
107
|
+
}
|
|
108
|
+
const sorted = [...symbols].sort();
|
|
109
|
+
return {
|
|
110
|
+
symbols: sorted,
|
|
111
|
+
tokens: sorted
|
|
112
|
+
.map(symbol => tokenFor(symbol, family, catalog))
|
|
113
|
+
.filter((token) => token !== undefined),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A component's icon mapping, ready for the registry.
|
|
118
|
+
*
|
|
119
|
+
* It comes back filled in even when there is no icon at all: the field always
|
|
120
|
+
* being present is what tells "this component draws no icons" apart from "this
|
|
121
|
+
* registry was published before the mapping existed", so a reader never has to
|
|
122
|
+
* guess which of the two it is.
|
|
123
|
+
*/
|
|
124
|
+
export function collectIcons(files, demos = [], family = SOURCE_ICON_FAMILY, catalog = LOCAL_ICON_CATALOG) {
|
|
125
|
+
return {
|
|
126
|
+
family,
|
|
127
|
+
...listIcons(files, family, catalog),
|
|
128
|
+
demos: listIcons(demos, family, catalog),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Rewrites a source from one icon family to another.
|
|
133
|
+
*
|
|
134
|
+
* Two swaps: the package the symbols come from, and each symbol itself. A symbol
|
|
135
|
+
* is replaced wherever it appears — the import, the `provideIcons({ lucideCheck })`
|
|
136
|
+
* and the template's `name="lucideCheck"` are the same word, and the object
|
|
137
|
+
* shorthand stays valid after the swap.
|
|
138
|
+
*
|
|
139
|
+
* A symbol with no equivalent in the target family is not invented: it stays as
|
|
140
|
+
* it is and comes back in `missing`, so the caller can warn instead of writing
|
|
141
|
+
* an import that does not resolve.
|
|
142
|
+
*/
|
|
143
|
+
export function retargetIcons(source, from, to, catalog = LOCAL_ICON_CATALOG) {
|
|
144
|
+
const origin = iconFamily(from, catalog);
|
|
145
|
+
const target = iconFamily(to, catalog);
|
|
146
|
+
if (from === to || !origin || !target)
|
|
147
|
+
return { content: source, missing: [] };
|
|
148
|
+
const missing = [];
|
|
149
|
+
const replacements = new Map();
|
|
150
|
+
for (const symbol of extractIcons(source, from, catalog)) {
|
|
151
|
+
const token = tokenFor(symbol, from, catalog);
|
|
152
|
+
const replacement = token !== undefined ? symbolFor(token, to, catalog) : undefined;
|
|
153
|
+
if (replacement === undefined)
|
|
154
|
+
missing.push(symbol);
|
|
155
|
+
else
|
|
156
|
+
replacements.set(symbol, replacement);
|
|
157
|
+
}
|
|
158
|
+
if (replacements.size === 0)
|
|
159
|
+
return { content: source, missing };
|
|
160
|
+
return { content: rewriteIcons(source, origin.package, target.package, replacements), missing };
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The mechanical half of the swap, separated from whatever decides what to swap.
|
|
164
|
+
*
|
|
165
|
+
* It is exported because this is where rewriting bugs live — whole-word
|
|
166
|
+
* replacement and the order of the alternation — and because testing it does
|
|
167
|
+
* not require more than one declared family.
|
|
168
|
+
*/
|
|
169
|
+
export function rewriteIcons(source, fromPackage, toPackage, replacements) {
|
|
170
|
+
if (replacements.size === 0)
|
|
171
|
+
return source;
|
|
172
|
+
// The alternation is tried in written order, so the long names come first:
|
|
173
|
+
// with `lucideClock` in front, `lucideClock2` would be matched from its prefix
|
|
174
|
+
// and only the trailing `\b` would save it — cheaper not to rely on that.
|
|
175
|
+
const pattern = new RegExp(`\\b(${[...replacements.keys()].sort((a, b) => b.length - a.length).join('|')})\\b`, 'g');
|
|
176
|
+
return source
|
|
177
|
+
.replace(new RegExp(`(['"])${escapeRegExp(fromPackage)}\\1`, 'g'), (_match, quote) => `${quote}${toPackage}${quote}`)
|
|
178
|
+
.replace(pattern, symbol => replacements.get(symbol) ?? symbol);
|
|
179
|
+
}
|
|
180
|
+
function escapeRegExp(value) {
|
|
181
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/icons/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgBzC,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAyB5F;;;;;GAKG;AACH,MAAM,cAAc,GAAG,IAAI,OAAO,EAAoD,CAAC;AAEvF,SAAS,YAAY,CAAC,OAAoB,EAAE,MAAkB;IAC5D,IAAI,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAE3C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAErB,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IA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