code-languages 1.38.0 → 1.39.0

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 CHANGED
@@ -199,6 +199,45 @@ Supported package manager aliases include: `npm`, `pnpm`, `yarn`, `pip`, `poetry
199
199
  `cargo`, `maven`, `gradle`, `nuget`, `composer`, `hex`, `spm`, `rubygems`, `go-mod`,
200
200
  `luarocks`, `opam`, `cpan`, and more. Searches `tooling.packageManagers` on each language.
201
201
 
202
+ Use `api.category(value)` to filter languages by their domain of use:
203
+
204
+ ```ts
205
+ import { api, getCategories } from "code-languages";
206
+
207
+ // frontend — targets the browser only (CSS, HTML, WGSL…)
208
+ api.category('frontend').langs().get();
209
+
210
+ // backend — runs on a server runtime (Python, Go, Ruby, PHP, Java, C#…)
211
+ api.category('backend').langs().locale('es').get();
212
+
213
+ // fullstack — targets both browser and server (JavaScript, TypeScript…)
214
+ api.category('fullstack').langs().get();
215
+
216
+ // systems — low-level / native / embedded (C, C++, Rust, Zig…)
217
+ api.category('systems').langs().get();
218
+
219
+ // data-science — data, ML, scientific computing (R, Julia, Python…)
220
+ api.category('data-science').langs().locale('pt').get();
221
+
222
+ // scripting — shell and scripting languages (Bash, Zsh, PowerShell…)
223
+ api.category('scripting').langs().get();
224
+
225
+ // other — everything that does not match any of the above
226
+ api.category('other').langs().get();
227
+
228
+ // async load and locale chaining work the same as other collection methods
229
+ await api.category('backend').langs().locale('pt').load();
230
+
231
+ // list all available categories
232
+ getCategories();
233
+ // → ['frontend', 'backend', 'fullstack', 'systems', 'data-science', 'scripting', 'other']
234
+ ```
235
+
236
+ Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems` —
237
+ no extra data is needed in individual language files.
238
+ `frontend`, `backend`, and `fullstack` are mutually exclusive; the remaining categories
239
+ can overlap (Python appears in both `backend` and `data-science`).
240
+
202
241
  Use `localizeLanguage` to read localized display content with English fallback:
203
242
 
204
243
  ```ts
@@ -1,6 +1,9 @@
1
1
  import { L as LanguageSlug } from './registry-p4uQJ2gP.cjs';
2
2
  import { d as Locale, e as LocalizedLanguage } from './types-B0_wjl_Q.cjs';
3
3
 
4
+ type LanguageCategory = 'frontend' | 'backend' | 'fullstack' | 'systems' | 'data-science' | 'scripting' | 'other';
5
+ declare function getCategories(): LanguageCategory[];
6
+
4
7
  interface PackageManagerInfo {
5
8
  slug: string;
6
9
  name: string;
@@ -57,6 +60,10 @@ interface PackageManagerRequest {
57
60
  /** Runtime platforms that include this package manager. */
58
61
  runtimes(): RuntimeInfo[];
59
62
  }
63
+ interface CategoryRequest {
64
+ /** Languages that belong to this category. */
65
+ langs(): LanguageCollectionRequest;
66
+ }
60
67
  interface LanguageCollectionRequest {
61
68
  /**
62
69
  * Sets the requested locale for every language returned by this collection lookup.
@@ -123,6 +130,25 @@ declare const api: {
123
130
  * api.packageManager('npm').runtimes();
124
131
  */
125
132
  packageManager(value: string): PackageManagerRequest;
133
+ /**
134
+ * Selects every language that belongs to the given category.
135
+ *
136
+ * Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems`:
137
+ * - `frontend` — targets the browser only (CSS, HTML, GLSL…)
138
+ * - `backend` — runs on a server runtime (Python, Go, Ruby, PHP…)
139
+ * - `fullstack` — targets both browser and server (JavaScript, TypeScript…)
140
+ * - `systems` — low-level / native / embedded (C, C++, Rust, Zig…)
141
+ * - `data-science`— data, ML, scientific computing (R, Julia, MATLAB…)
142
+ * - `scripting` — shell and scripting languages (Bash, Zsh, PowerShell…)
143
+ * - `other` — everything that does not match any of the above
144
+ *
145
+ * Categories are not mutually exclusive: Python appears in both `backend` and `data-science`.
146
+ *
147
+ * @example
148
+ * api.category('backend').langs().locale('es').get();
149
+ * await api.category('data-science').langs().load();
150
+ */
151
+ category(value: LanguageCategory): CategoryRequest;
126
152
  /**
127
153
  * Detects every matching language for a filename or path.
128
154
  *
@@ -131,4 +157,4 @@ declare const api: {
131
157
  detectAll(filename: string): LanguageCollectionRequest;
132
158
  };
133
159
 
134
- export { type LanguageCollectionRequest as L, type PackageManagerInfo as P, type RuntimeInfo as R, api as a, getRuntimes as b, type LanguageRequest as c, type PackageManagerRequest as d, type RuntimeRequest as e, getPackageManagers as g };
160
+ export { type CategoryRequest as C, type LanguageCategory as L, type PackageManagerInfo as P, type RuntimeInfo as R, api as a, getPackageManagers as b, getRuntimes as c, type LanguageCollectionRequest as d, type LanguageRequest as e, type PackageManagerRequest as f, getCategories as g, type RuntimeRequest as h };
@@ -1,6 +1,9 @@
1
1
  import { L as LanguageSlug } from './registry-p4uQJ2gP.js';
2
2
  import { d as Locale, e as LocalizedLanguage } from './types-B0_wjl_Q.js';
3
3
 
4
+ type LanguageCategory = 'frontend' | 'backend' | 'fullstack' | 'systems' | 'data-science' | 'scripting' | 'other';
5
+ declare function getCategories(): LanguageCategory[];
6
+
4
7
  interface PackageManagerInfo {
5
8
  slug: string;
6
9
  name: string;
@@ -57,6 +60,10 @@ interface PackageManagerRequest {
57
60
  /** Runtime platforms that include this package manager. */
58
61
  runtimes(): RuntimeInfo[];
59
62
  }
63
+ interface CategoryRequest {
64
+ /** Languages that belong to this category. */
65
+ langs(): LanguageCollectionRequest;
66
+ }
60
67
  interface LanguageCollectionRequest {
61
68
  /**
62
69
  * Sets the requested locale for every language returned by this collection lookup.
@@ -123,6 +130,25 @@ declare const api: {
123
130
  * api.packageManager('npm').runtimes();
124
131
  */
125
132
  packageManager(value: string): PackageManagerRequest;
133
+ /**
134
+ * Selects every language that belongs to the given category.
135
+ *
136
+ * Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems`:
137
+ * - `frontend` — targets the browser only (CSS, HTML, GLSL…)
138
+ * - `backend` — runs on a server runtime (Python, Go, Ruby, PHP…)
139
+ * - `fullstack` — targets both browser and server (JavaScript, TypeScript…)
140
+ * - `systems` — low-level / native / embedded (C, C++, Rust, Zig…)
141
+ * - `data-science`— data, ML, scientific computing (R, Julia, MATLAB…)
142
+ * - `scripting` — shell and scripting languages (Bash, Zsh, PowerShell…)
143
+ * - `other` — everything that does not match any of the above
144
+ *
145
+ * Categories are not mutually exclusive: Python appears in both `backend` and `data-science`.
146
+ *
147
+ * @example
148
+ * api.category('backend').langs().locale('es').get();
149
+ * await api.category('data-science').langs().load();
150
+ */
151
+ category(value: LanguageCategory): CategoryRequest;
126
152
  /**
127
153
  * Detects every matching language for a filename or path.
128
154
  *
@@ -131,4 +157,4 @@ declare const api: {
131
157
  detectAll(filename: string): LanguageCollectionRequest;
132
158
  };
133
159
 
134
- export { type LanguageCollectionRequest as L, type PackageManagerInfo as P, type RuntimeInfo as R, api as a, getRuntimes as b, type LanguageRequest as c, type PackageManagerRequest as d, type RuntimeRequest as e, getPackageManagers as g };
160
+ export { type CategoryRequest as C, type LanguageCategory as L, type PackageManagerInfo as P, type RuntimeInfo as R, api as a, getPackageManagers as b, getRuntimes as c, type LanguageCollectionRequest as d, type LanguageRequest as e, type PackageManagerRequest as f, getCategories as g, type RuntimeRequest as h };
package/dist/api.cjs CHANGED
@@ -16722,6 +16722,77 @@ var init_zsh = __esm({
16722
16722
  }
16723
16723
  });
16724
16724
 
16725
+ // src/domain/category/registry.ts
16726
+ var BROWSER_TARGETS = ["Browser"];
16727
+ var SERVER_TARGETS = [
16728
+ "Node.js",
16729
+ "Deno",
16730
+ "Bun",
16731
+ "CPython",
16732
+ "PyPy",
16733
+ "JVM",
16734
+ "BEAM",
16735
+ "Erlang/OTP",
16736
+ "Ruby MRI",
16737
+ "JRuby",
16738
+ "TruffleRuby",
16739
+ "Go runtime",
16740
+ "PHP",
16741
+ ".NET",
16742
+ "Mono"
16743
+ ];
16744
+ var SYSTEMS_TARGETS = [
16745
+ "Systems",
16746
+ "Systems Programming",
16747
+ "Embedded",
16748
+ "Native",
16749
+ "LLVM",
16750
+ "Firmware",
16751
+ "Linux Kernel",
16752
+ "Microcontroller"
16753
+ ];
16754
+ var DATA_TARGETS = [
16755
+ "Data Science",
16756
+ "Machine Learning",
16757
+ "Scientific Computing",
16758
+ "Statistics",
16759
+ "Bioinformatics",
16760
+ "HPC",
16761
+ "Numerical Computing"
16762
+ ];
16763
+ var SCRIPT_TARGETS = ["shell", "PowerShell", "Scripting"];
16764
+ function poolMatches(pool, targets) {
16765
+ return targets.some((t) => pool.some((s) => s.toLowerCase().includes(t.toLowerCase())));
16766
+ }
16767
+ function hasBrowser(lang) {
16768
+ return poolMatches(lang.tooling?.runtimes ?? [], BROWSER_TARGETS);
16769
+ }
16770
+ function hasServer(lang) {
16771
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16772
+ return poolMatches(pool, SERVER_TARGETS);
16773
+ }
16774
+ function matchesCategory(lang, category) {
16775
+ const browser = hasBrowser(lang);
16776
+ const server = hasServer(lang);
16777
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16778
+ switch (category) {
16779
+ case "frontend":
16780
+ return browser && !server;
16781
+ case "backend":
16782
+ return server && !browser;
16783
+ case "fullstack":
16784
+ return browser && server;
16785
+ case "systems":
16786
+ return poolMatches(pool, SYSTEMS_TARGETS);
16787
+ case "data-science":
16788
+ return poolMatches(pool, DATA_TARGETS);
16789
+ case "scripting":
16790
+ return poolMatches(pool, SCRIPT_TARGETS);
16791
+ case "other":
16792
+ return !browser && !server && !poolMatches(pool, SYSTEMS_TARGETS) && !poolMatches(pool, DATA_TARGETS) && !poolMatches(pool, SCRIPT_TARGETS);
16793
+ }
16794
+ }
16795
+
16725
16796
  // src/domain/language/registry.ts
16726
16797
  var languageIndex = [
16727
16798
  { slug: "abap", extensions: [".abap"] },
@@ -17321,7 +17392,10 @@ var loadLanguage = (slug) => languageLoaders[slug]?.();
17321
17392
 
17322
17393
  // src/domain/detection/match.ts
17323
17394
  var pathSegmentPattern = /[/\\]/;
17324
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
17395
+ var getBasename = (filename) => {
17396
+ const parts = filename.trim().split(pathSegmentPattern);
17397
+ return parts.at(-1).toLowerCase();
17398
+ };
17325
17399
  var matchesExtension = (basename, extension) => {
17326
17400
  const normalizedExtension = extension.toLowerCase();
17327
17401
  if (normalizedExtension.startsWith(".")) {
@@ -18829,6 +18903,35 @@ var api = {
18829
18903
  }
18830
18904
  };
18831
18905
  },
18906
+ /**
18907
+ * Selects every language that belongs to the given category.
18908
+ *
18909
+ * Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems`:
18910
+ * - `frontend` — targets the browser only (CSS, HTML, GLSL…)
18911
+ * - `backend` — runs on a server runtime (Python, Go, Ruby, PHP…)
18912
+ * - `fullstack` — targets both browser and server (JavaScript, TypeScript…)
18913
+ * - `systems` — low-level / native / embedded (C, C++, Rust, Zig…)
18914
+ * - `data-science`— data, ML, scientific computing (R, Julia, MATLAB…)
18915
+ * - `scripting` — shell and scripting languages (Bash, Zsh, PowerShell…)
18916
+ * - `other` — everything that does not match any of the above
18917
+ *
18918
+ * Categories are not mutually exclusive: Python appears in both `backend` and `data-science`.
18919
+ *
18920
+ * @example
18921
+ * api.category('backend').langs().locale('es').get();
18922
+ * await api.category('data-science').langs().load();
18923
+ */
18924
+ category(value) {
18925
+ return {
18926
+ langs() {
18927
+ const filtered = () => languages.filter((lang) => matchesCategory(lang, value));
18928
+ return createLanguageCollectionRequest(filtered, async () => {
18929
+ const loaded = await Promise.all(filtered().map((lang) => loadLanguage(lang.slug)));
18930
+ return loaded.filter((lang) => Boolean(lang));
18931
+ });
18932
+ }
18933
+ };
18934
+ },
18832
18935
  /**
18833
18936
  * Detects every matching language for a filename or path.
18834
18937
  *
package/dist/api.d.cts CHANGED
@@ -1,3 +1,3 @@
1
+ export { C as CategoryRequest, L as LanguageCategory, d as LanguageCollectionRequest, e as LanguageRequest, f as PackageManagerRequest, h as RuntimeRequest, a as api } from './api-C-SCQpIV.cjs';
1
2
  export { L as LanguageSlug } from './registry-p4uQJ2gP.cjs';
2
- export { L as LanguageCollectionRequest, c as LanguageRequest, d as PackageManagerRequest, e as RuntimeRequest, a as api } from './api-CjNcbLKv.cjs';
3
3
  import './types-B0_wjl_Q.cjs';
package/dist/api.d.ts CHANGED
@@ -1,3 +1,3 @@
1
+ export { C as CategoryRequest, L as LanguageCategory, d as LanguageCollectionRequest, e as LanguageRequest, f as PackageManagerRequest, h as RuntimeRequest, a as api } from './api-EZK9DmOV.js';
1
2
  export { L as LanguageSlug } from './registry-p4uQJ2gP.js';
2
- export { L as LanguageCollectionRequest, c as LanguageRequest, d as PackageManagerRequest, e as RuntimeRequest, a as api } from './api-u3GKPoGq.js';
3
3
  import './types-B0_wjl_Q.js';
package/dist/api.js CHANGED
@@ -16720,6 +16720,77 @@ var init_zsh = __esm({
16720
16720
  }
16721
16721
  });
16722
16722
 
16723
+ // src/domain/category/registry.ts
16724
+ var BROWSER_TARGETS = ["Browser"];
16725
+ var SERVER_TARGETS = [
16726
+ "Node.js",
16727
+ "Deno",
16728
+ "Bun",
16729
+ "CPython",
16730
+ "PyPy",
16731
+ "JVM",
16732
+ "BEAM",
16733
+ "Erlang/OTP",
16734
+ "Ruby MRI",
16735
+ "JRuby",
16736
+ "TruffleRuby",
16737
+ "Go runtime",
16738
+ "PHP",
16739
+ ".NET",
16740
+ "Mono"
16741
+ ];
16742
+ var SYSTEMS_TARGETS = [
16743
+ "Systems",
16744
+ "Systems Programming",
16745
+ "Embedded",
16746
+ "Native",
16747
+ "LLVM",
16748
+ "Firmware",
16749
+ "Linux Kernel",
16750
+ "Microcontroller"
16751
+ ];
16752
+ var DATA_TARGETS = [
16753
+ "Data Science",
16754
+ "Machine Learning",
16755
+ "Scientific Computing",
16756
+ "Statistics",
16757
+ "Bioinformatics",
16758
+ "HPC",
16759
+ "Numerical Computing"
16760
+ ];
16761
+ var SCRIPT_TARGETS = ["shell", "PowerShell", "Scripting"];
16762
+ function poolMatches(pool, targets) {
16763
+ return targets.some((t) => pool.some((s) => s.toLowerCase().includes(t.toLowerCase())));
16764
+ }
16765
+ function hasBrowser(lang) {
16766
+ return poolMatches(lang.tooling?.runtimes ?? [], BROWSER_TARGETS);
16767
+ }
16768
+ function hasServer(lang) {
16769
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16770
+ return poolMatches(pool, SERVER_TARGETS);
16771
+ }
16772
+ function matchesCategory(lang, category) {
16773
+ const browser = hasBrowser(lang);
16774
+ const server = hasServer(lang);
16775
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16776
+ switch (category) {
16777
+ case "frontend":
16778
+ return browser && !server;
16779
+ case "backend":
16780
+ return server && !browser;
16781
+ case "fullstack":
16782
+ return browser && server;
16783
+ case "systems":
16784
+ return poolMatches(pool, SYSTEMS_TARGETS);
16785
+ case "data-science":
16786
+ return poolMatches(pool, DATA_TARGETS);
16787
+ case "scripting":
16788
+ return poolMatches(pool, SCRIPT_TARGETS);
16789
+ case "other":
16790
+ return !browser && !server && !poolMatches(pool, SYSTEMS_TARGETS) && !poolMatches(pool, DATA_TARGETS) && !poolMatches(pool, SCRIPT_TARGETS);
16791
+ }
16792
+ }
16793
+
16723
16794
  // src/domain/language/registry.ts
16724
16795
  var languageIndex = [
16725
16796
  { slug: "abap", extensions: [".abap"] },
@@ -17319,7 +17390,10 @@ var loadLanguage = (slug) => languageLoaders[slug]?.();
17319
17390
 
17320
17391
  // src/domain/detection/match.ts
17321
17392
  var pathSegmentPattern = /[/\\]/;
17322
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
17393
+ var getBasename = (filename) => {
17394
+ const parts = filename.trim().split(pathSegmentPattern);
17395
+ return parts.at(-1).toLowerCase();
17396
+ };
17323
17397
  var matchesExtension = (basename, extension) => {
17324
17398
  const normalizedExtension = extension.toLowerCase();
17325
17399
  if (normalizedExtension.startsWith(".")) {
@@ -18827,6 +18901,35 @@ var api = {
18827
18901
  }
18828
18902
  };
18829
18903
  },
18904
+ /**
18905
+ * Selects every language that belongs to the given category.
18906
+ *
18907
+ * Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems`:
18908
+ * - `frontend` — targets the browser only (CSS, HTML, GLSL…)
18909
+ * - `backend` — runs on a server runtime (Python, Go, Ruby, PHP…)
18910
+ * - `fullstack` — targets both browser and server (JavaScript, TypeScript…)
18911
+ * - `systems` — low-level / native / embedded (C, C++, Rust, Zig…)
18912
+ * - `data-science`— data, ML, scientific computing (R, Julia, MATLAB…)
18913
+ * - `scripting` — shell and scripting languages (Bash, Zsh, PowerShell…)
18914
+ * - `other` — everything that does not match any of the above
18915
+ *
18916
+ * Categories are not mutually exclusive: Python appears in both `backend` and `data-science`.
18917
+ *
18918
+ * @example
18919
+ * api.category('backend').langs().locale('es').get();
18920
+ * await api.category('data-science').langs().load();
18921
+ */
18922
+ category(value) {
18923
+ return {
18924
+ langs() {
18925
+ const filtered = () => languages.filter((lang) => matchesCategory(lang, value));
18926
+ return createLanguageCollectionRequest(filtered, async () => {
18927
+ const loaded = await Promise.all(filtered().map((lang) => loadLanguage(lang.slug)));
18928
+ return loaded.filter((lang) => Boolean(lang));
18929
+ });
18930
+ }
18931
+ };
18932
+ },
18830
18933
  /**
18831
18934
  * Detects every matching language for a filename or path.
18832
18935
  *
@@ -310,7 +310,10 @@ var languageIndex = [
310
310
 
311
311
  // src/domain/detection/match.ts
312
312
  var pathSegmentPattern = /[/\\]/;
313
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
313
+ var getBasename = (filename) => {
314
+ const parts = filename.trim().split(pathSegmentPattern);
315
+ return parts.at(-1).toLowerCase();
316
+ };
314
317
  var matchesExtension = (basename, extension) => {
315
318
  const normalizedExtension = extension.toLowerCase();
316
319
  if (normalizedExtension.startsWith(".")) {
@@ -308,7 +308,10 @@ var languageIndex = [
308
308
 
309
309
  // src/domain/detection/match.ts
310
310
  var pathSegmentPattern = /[/\\]/;
311
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
311
+ var getBasename = (filename) => {
312
+ const parts = filename.trim().split(pathSegmentPattern);
313
+ return parts.at(-1).toLowerCase();
314
+ };
312
315
  var matchesExtension = (basename, extension) => {
313
316
  const normalizedExtension = extension.toLowerCase();
314
317
  if (normalizedExtension.startsWith(".")) {
package/dist/detect.cjs CHANGED
@@ -14430,7 +14430,10 @@ var languages = [
14430
14430
 
14431
14431
  // src/domain/detection/match.ts
14432
14432
  var pathSegmentPattern = /[/\\]/;
14433
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
14433
+ var getBasename = (filename) => {
14434
+ const parts = filename.trim().split(pathSegmentPattern);
14435
+ return parts.at(-1).toLowerCase();
14436
+ };
14434
14437
  var matchesExtension = (basename, extension) => {
14435
14438
  const normalizedExtension = extension.toLowerCase();
14436
14439
  if (normalizedExtension.startsWith(".")) {
package/dist/detect.js CHANGED
@@ -14428,7 +14428,10 @@ var languages = [
14428
14428
 
14429
14429
  // src/domain/detection/match.ts
14430
14430
  var pathSegmentPattern = /[/\\]/;
14431
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
14431
+ var getBasename = (filename) => {
14432
+ const parts = filename.trim().split(pathSegmentPattern);
14433
+ return parts.at(-1).toLowerCase();
14434
+ };
14432
14435
  var matchesExtension = (basename, extension) => {
14433
14436
  const normalizedExtension = extension.toLowerCase();
14434
14437
  if (normalizedExtension.startsWith(".")) {
package/dist/index.cjs CHANGED
@@ -16722,6 +16722,80 @@ var init_zsh = __esm({
16722
16722
  }
16723
16723
  });
16724
16724
 
16725
+ // src/domain/category/registry.ts
16726
+ var BROWSER_TARGETS = ["Browser"];
16727
+ var SERVER_TARGETS = [
16728
+ "Node.js",
16729
+ "Deno",
16730
+ "Bun",
16731
+ "CPython",
16732
+ "PyPy",
16733
+ "JVM",
16734
+ "BEAM",
16735
+ "Erlang/OTP",
16736
+ "Ruby MRI",
16737
+ "JRuby",
16738
+ "TruffleRuby",
16739
+ "Go runtime",
16740
+ "PHP",
16741
+ ".NET",
16742
+ "Mono"
16743
+ ];
16744
+ var SYSTEMS_TARGETS = [
16745
+ "Systems",
16746
+ "Systems Programming",
16747
+ "Embedded",
16748
+ "Native",
16749
+ "LLVM",
16750
+ "Firmware",
16751
+ "Linux Kernel",
16752
+ "Microcontroller"
16753
+ ];
16754
+ var DATA_TARGETS = [
16755
+ "Data Science",
16756
+ "Machine Learning",
16757
+ "Scientific Computing",
16758
+ "Statistics",
16759
+ "Bioinformatics",
16760
+ "HPC",
16761
+ "Numerical Computing"
16762
+ ];
16763
+ var SCRIPT_TARGETS = ["shell", "PowerShell", "Scripting"];
16764
+ function poolMatches(pool, targets) {
16765
+ return targets.some((t) => pool.some((s) => s.toLowerCase().includes(t.toLowerCase())));
16766
+ }
16767
+ function hasBrowser(lang) {
16768
+ return poolMatches(lang.tooling?.runtimes ?? [], BROWSER_TARGETS);
16769
+ }
16770
+ function hasServer(lang) {
16771
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16772
+ return poolMatches(pool, SERVER_TARGETS);
16773
+ }
16774
+ function matchesCategory(lang, category) {
16775
+ const browser = hasBrowser(lang);
16776
+ const server = hasServer(lang);
16777
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16778
+ switch (category) {
16779
+ case "frontend":
16780
+ return browser && !server;
16781
+ case "backend":
16782
+ return server && !browser;
16783
+ case "fullstack":
16784
+ return browser && server;
16785
+ case "systems":
16786
+ return poolMatches(pool, SYSTEMS_TARGETS);
16787
+ case "data-science":
16788
+ return poolMatches(pool, DATA_TARGETS);
16789
+ case "scripting":
16790
+ return poolMatches(pool, SCRIPT_TARGETS);
16791
+ case "other":
16792
+ return !browser && !server && !poolMatches(pool, SYSTEMS_TARGETS) && !poolMatches(pool, DATA_TARGETS) && !poolMatches(pool, SCRIPT_TARGETS);
16793
+ }
16794
+ }
16795
+ function getCategories() {
16796
+ return ["frontend", "backend", "fullstack", "systems", "data-science", "scripting", "other"];
16797
+ }
16798
+
16725
16799
  // src/domain/language/registry.ts
16726
16800
  var languageIndex = [
16727
16801
  { slug: "abap", extensions: [".abap"] },
@@ -17321,7 +17395,10 @@ var loadLanguage = (slug) => languageLoaders[slug]?.();
17321
17395
 
17322
17396
  // src/domain/detection/match.ts
17323
17397
  var pathSegmentPattern = /[/\\]/;
17324
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
17398
+ var getBasename = (filename) => {
17399
+ const parts = filename.trim().split(pathSegmentPattern);
17400
+ return parts.at(-1).toLowerCase();
17401
+ };
17325
17402
  var matchesExtension = (basename, extension) => {
17326
17403
  const normalizedExtension = extension.toLowerCase();
17327
17404
  if (normalizedExtension.startsWith(".")) {
@@ -18846,6 +18923,35 @@ var api = {
18846
18923
  }
18847
18924
  };
18848
18925
  },
18926
+ /**
18927
+ * Selects every language that belongs to the given category.
18928
+ *
18929
+ * Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems`:
18930
+ * - `frontend` — targets the browser only (CSS, HTML, GLSL…)
18931
+ * - `backend` — runs on a server runtime (Python, Go, Ruby, PHP…)
18932
+ * - `fullstack` — targets both browser and server (JavaScript, TypeScript…)
18933
+ * - `systems` — low-level / native / embedded (C, C++, Rust, Zig…)
18934
+ * - `data-science`— data, ML, scientific computing (R, Julia, MATLAB…)
18935
+ * - `scripting` — shell and scripting languages (Bash, Zsh, PowerShell…)
18936
+ * - `other` — everything that does not match any of the above
18937
+ *
18938
+ * Categories are not mutually exclusive: Python appears in both `backend` and `data-science`.
18939
+ *
18940
+ * @example
18941
+ * api.category('backend').langs().locale('es').get();
18942
+ * await api.category('data-science').langs().load();
18943
+ */
18944
+ category(value) {
18945
+ return {
18946
+ langs() {
18947
+ const filtered = () => languages.filter((lang) => matchesCategory(lang, value));
18948
+ return createLanguageCollectionRequest(filtered, async () => {
18949
+ const loaded = await Promise.all(filtered().map((lang) => loadLanguage(lang.slug)));
18950
+ return loaded.filter((lang) => Boolean(lang));
18951
+ });
18952
+ }
18953
+ };
18954
+ },
18849
18955
  /**
18850
18956
  * Detects every matching language for a filename or path.
18851
18957
  *
@@ -19148,6 +19254,7 @@ exports.detectLanguageSlug = detectLanguageSlug;
19148
19254
  exports.detectLanguageSlugs = detectLanguageSlugs;
19149
19255
  exports.detectLanguages = detectLanguages;
19150
19256
  exports.detectProjectLanguages = detectProjectLanguages;
19257
+ exports.getCategories = getCategories;
19151
19258
  exports.getPackageManagers = getPackageManagers;
19152
19259
  exports.getRuntimes = getRuntimes;
19153
19260
  exports.languages = languages;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { P as PackageManagerInfo, R as RuntimeInfo, a as api, g as getPackageManagers, b as getRuntimes } from './api-CjNcbLKv.cjs';
1
+ export { C as CategoryRequest, L as LanguageCategory, P as PackageManagerInfo, R as RuntimeInfo, a as api, g as getCategories, b as getPackageManagers, c as getRuntimes } from './api-C-SCQpIV.cjs';
2
2
  export { detectLanguage, detectLanguages } from './detect.cjs';
3
3
  export { ProjectLanguageDetection, detectLanguageSlug, detectLanguageSlugs, detectProjectLanguages } from './detect-slugs.cjs';
4
4
  export { localizeLanguage } from './i18n.cjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { P as PackageManagerInfo, R as RuntimeInfo, a as api, g as getPackageManagers, b as getRuntimes } from './api-u3GKPoGq.js';
1
+ export { C as CategoryRequest, L as LanguageCategory, P as PackageManagerInfo, R as RuntimeInfo, a as api, g as getCategories, b as getPackageManagers, c as getRuntimes } from './api-EZK9DmOV.js';
2
2
  export { detectLanguage, detectLanguages } from './detect.js';
3
3
  export { ProjectLanguageDetection, detectLanguageSlug, detectLanguageSlugs, detectProjectLanguages } from './detect-slugs.js';
4
4
  export { localizeLanguage } from './i18n.js';
package/dist/index.js CHANGED
@@ -16720,6 +16720,80 @@ var init_zsh = __esm({
16720
16720
  }
16721
16721
  });
16722
16722
 
16723
+ // src/domain/category/registry.ts
16724
+ var BROWSER_TARGETS = ["Browser"];
16725
+ var SERVER_TARGETS = [
16726
+ "Node.js",
16727
+ "Deno",
16728
+ "Bun",
16729
+ "CPython",
16730
+ "PyPy",
16731
+ "JVM",
16732
+ "BEAM",
16733
+ "Erlang/OTP",
16734
+ "Ruby MRI",
16735
+ "JRuby",
16736
+ "TruffleRuby",
16737
+ "Go runtime",
16738
+ "PHP",
16739
+ ".NET",
16740
+ "Mono"
16741
+ ];
16742
+ var SYSTEMS_TARGETS = [
16743
+ "Systems",
16744
+ "Systems Programming",
16745
+ "Embedded",
16746
+ "Native",
16747
+ "LLVM",
16748
+ "Firmware",
16749
+ "Linux Kernel",
16750
+ "Microcontroller"
16751
+ ];
16752
+ var DATA_TARGETS = [
16753
+ "Data Science",
16754
+ "Machine Learning",
16755
+ "Scientific Computing",
16756
+ "Statistics",
16757
+ "Bioinformatics",
16758
+ "HPC",
16759
+ "Numerical Computing"
16760
+ ];
16761
+ var SCRIPT_TARGETS = ["shell", "PowerShell", "Scripting"];
16762
+ function poolMatches(pool, targets) {
16763
+ return targets.some((t) => pool.some((s) => s.toLowerCase().includes(t.toLowerCase())));
16764
+ }
16765
+ function hasBrowser(lang) {
16766
+ return poolMatches(lang.tooling?.runtimes ?? [], BROWSER_TARGETS);
16767
+ }
16768
+ function hasServer(lang) {
16769
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16770
+ return poolMatches(pool, SERVER_TARGETS);
16771
+ }
16772
+ function matchesCategory(lang, category) {
16773
+ const browser = hasBrowser(lang);
16774
+ const server = hasServer(lang);
16775
+ const pool = [...lang.tooling?.runtimes ?? [], ...lang.tooling?.ecosystems ?? []];
16776
+ switch (category) {
16777
+ case "frontend":
16778
+ return browser && !server;
16779
+ case "backend":
16780
+ return server && !browser;
16781
+ case "fullstack":
16782
+ return browser && server;
16783
+ case "systems":
16784
+ return poolMatches(pool, SYSTEMS_TARGETS);
16785
+ case "data-science":
16786
+ return poolMatches(pool, DATA_TARGETS);
16787
+ case "scripting":
16788
+ return poolMatches(pool, SCRIPT_TARGETS);
16789
+ case "other":
16790
+ return !browser && !server && !poolMatches(pool, SYSTEMS_TARGETS) && !poolMatches(pool, DATA_TARGETS) && !poolMatches(pool, SCRIPT_TARGETS);
16791
+ }
16792
+ }
16793
+ function getCategories() {
16794
+ return ["frontend", "backend", "fullstack", "systems", "data-science", "scripting", "other"];
16795
+ }
16796
+
16723
16797
  // src/domain/language/registry.ts
16724
16798
  var languageIndex = [
16725
16799
  { slug: "abap", extensions: [".abap"] },
@@ -17319,7 +17393,10 @@ var loadLanguage = (slug) => languageLoaders[slug]?.();
17319
17393
 
17320
17394
  // src/domain/detection/match.ts
17321
17395
  var pathSegmentPattern = /[/\\]/;
17322
- var getBasename = (filename) => filename.trim().split(pathSegmentPattern).at(-1)?.toLowerCase() ?? "";
17396
+ var getBasename = (filename) => {
17397
+ const parts = filename.trim().split(pathSegmentPattern);
17398
+ return parts.at(-1).toLowerCase();
17399
+ };
17323
17400
  var matchesExtension = (basename, extension) => {
17324
17401
  const normalizedExtension = extension.toLowerCase();
17325
17402
  if (normalizedExtension.startsWith(".")) {
@@ -18844,6 +18921,35 @@ var api = {
18844
18921
  }
18845
18922
  };
18846
18923
  },
18924
+ /**
18925
+ * Selects every language that belongs to the given category.
18926
+ *
18927
+ * Categories are inferred from each language's `tooling.runtimes` and `tooling.ecosystems`:
18928
+ * - `frontend` — targets the browser only (CSS, HTML, GLSL…)
18929
+ * - `backend` — runs on a server runtime (Python, Go, Ruby, PHP…)
18930
+ * - `fullstack` — targets both browser and server (JavaScript, TypeScript…)
18931
+ * - `systems` — low-level / native / embedded (C, C++, Rust, Zig…)
18932
+ * - `data-science`— data, ML, scientific computing (R, Julia, MATLAB…)
18933
+ * - `scripting` — shell and scripting languages (Bash, Zsh, PowerShell…)
18934
+ * - `other` — everything that does not match any of the above
18935
+ *
18936
+ * Categories are not mutually exclusive: Python appears in both `backend` and `data-science`.
18937
+ *
18938
+ * @example
18939
+ * api.category('backend').langs().locale('es').get();
18940
+ * await api.category('data-science').langs().load();
18941
+ */
18942
+ category(value) {
18943
+ return {
18944
+ langs() {
18945
+ const filtered = () => languages.filter((lang) => matchesCategory(lang, value));
18946
+ return createLanguageCollectionRequest(filtered, async () => {
18947
+ const loaded = await Promise.all(filtered().map((lang) => loadLanguage(lang.slug)));
18948
+ return loaded.filter((lang) => Boolean(lang));
18949
+ });
18950
+ }
18951
+ };
18952
+ },
18847
18953
  /**
18848
18954
  * Detects every matching language for a filename or path.
18849
18955
  *
@@ -19140,4 +19246,4 @@ init_zig();
19140
19246
  init_ziggy();
19141
19247
  init_zsh();
19142
19248
 
19143
- export { abap, actionscript, ada, agda, algol, ampl, ante, antlr, apex, api, apl, applescript, aql, arduino, asciidoc, asp, assembly, assemblyscript, astro, austral, autohotkey, avroIdl, awk, ballerina, bash, basic, batch, bazel, bcpl, bibtex, bicep, blade, bosque, bqn, brainfuck, c, cairo, capnproto, carbon, cel, chapel, circom, clojure, cmake, cobol, coffeescript, coldfusion, coq, cpp, cql, crystal, csharp, css, cuda, cue, curry, cypher, cython, d, dafny, dart, dax, detectLanguage, detectLanguageSlug, detectLanguageSlugs, detectLanguages, detectProjectLanguages, dhall, dita, dockerfile, dot, earthly, editorconfig, eiffel, ejs, elixir, elm, erb, erlang, factor, fe, fennel, fish, flatbuffers, flux, forth, fortran, fql, freemarker, fsharp, fstar, gcode, gdscript, getPackageManagers, getRuntimes, gettext, git, gleam, glsl, go, gradle, grain, graphql, gremlin, groovy, hack, haml, handlebars, hare, haskell, haxe, hcl, hlsl, hocon, html, hy, idris, ini, ink, io, isabelle, janet, java, javascript, jinja, jmespath, json, json5, jsonata, jsonc, jsonnet, julia, jupyterNotebook, just, kcl, kdl, koka, kotlin, kql, languages, lean, less, ligo, linkerscript, liquid, lisp, llvmIr, lobster, localizeLanguage, logo, lua, luau, makefile, mako, markdown, marlowe, mathematica, matlab, maxima, mdx, mercury, mermaid, meson, metal, modula2, mojo, moonbit, move, mumps, mustache, n1ql, nginx, nickel, nim, nix, nunjucks, nushell, oberon, objectiveC, ocaml, odin, openapi, opencl, openscad, org, pascal, perl, php, pineScript, pkl, plI, plantuml, plpgsql, plsql, pod, pony, postscript, powerquery, powershell, processing, prolog, promql, protobuf, pug, puppet, purescript, python, qmake, qml, qsharp, r, racket, raku, razor, reasonml, rebol, red, rego, rescript, restructuredtext, roc, rpg, ruby, rust, sas, scala, scheme, scss, self, simula, smalltalk, smarty, snobol, solidity, soql, spark, sparql, spl, sql, standardMl, starlark, stata, stylus, svelte, svg, svn, swift, tcl, tcsh, tex, textile, thrift, tlaPlus, toml, troff, tsql, twig, typescript, typst, unison, v, vala, vale, vba, velocity, verilog, verse, vhdl, visualBasic, vue, vyper, webassembly, wgsl, wren, xaml, xml, xpath, xquery, xslt, yaml, yara, zeek, zig, ziggy, zsh };
19249
+ export { abap, actionscript, ada, agda, algol, ampl, ante, antlr, apex, api, apl, applescript, aql, arduino, asciidoc, asp, assembly, assemblyscript, astro, austral, autohotkey, avroIdl, awk, ballerina, bash, basic, batch, bazel, bcpl, bibtex, bicep, blade, bosque, bqn, brainfuck, c, cairo, capnproto, carbon, cel, chapel, circom, clojure, cmake, cobol, coffeescript, coldfusion, coq, cpp, cql, crystal, csharp, css, cuda, cue, curry, cypher, cython, d, dafny, dart, dax, detectLanguage, detectLanguageSlug, detectLanguageSlugs, detectLanguages, detectProjectLanguages, dhall, dita, dockerfile, dot, earthly, editorconfig, eiffel, ejs, elixir, elm, erb, erlang, factor, fe, fennel, fish, flatbuffers, flux, forth, fortran, fql, freemarker, fsharp, fstar, gcode, gdscript, getCategories, getPackageManagers, getRuntimes, gettext, git, gleam, glsl, go, gradle, grain, graphql, gremlin, groovy, hack, haml, handlebars, hare, haskell, haxe, hcl, hlsl, hocon, html, hy, idris, ini, ink, io, isabelle, janet, java, javascript, jinja, jmespath, json, json5, jsonata, jsonc, jsonnet, julia, jupyterNotebook, just, kcl, kdl, koka, kotlin, kql, languages, lean, less, ligo, linkerscript, liquid, lisp, llvmIr, lobster, localizeLanguage, logo, lua, luau, makefile, mako, markdown, marlowe, mathematica, matlab, maxima, mdx, mercury, mermaid, meson, metal, modula2, mojo, moonbit, move, mumps, mustache, n1ql, nginx, nickel, nim, nix, nunjucks, nushell, oberon, objectiveC, ocaml, odin, openapi, opencl, openscad, org, pascal, perl, php, pineScript, pkl, plI, plantuml, plpgsql, plsql, pod, pony, postscript, powerquery, powershell, processing, prolog, promql, protobuf, pug, puppet, purescript, python, qmake, qml, qsharp, r, racket, raku, razor, reasonml, rebol, red, rego, rescript, restructuredtext, roc, rpg, ruby, rust, sas, scala, scheme, scss, self, simula, smalltalk, smarty, snobol, solidity, soql, spark, sparql, spl, sql, standardMl, starlark, stata, stylus, svelte, svg, svn, swift, tcl, tcsh, tex, textile, thrift, tlaPlus, toml, troff, tsql, twig, typescript, typst, unison, v, vala, vale, vba, velocity, verilog, verse, vhdl, visualBasic, vue, vyper, webassembly, wgsl, wren, xaml, xml, xpath, xquery, xslt, yaml, yara, zeek, zig, ziggy, zsh };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-languages",
3
- "version": "1.38.0",
3
+ "version": "1.39.0",
4
4
  "description": "Structured metadata for programming languages.",
5
5
  "homepage": "https://github.com/ElJijuna/code-languages#readme",
6
6
  "bugs": {
@@ -1504,6 +1504,7 @@
1504
1504
  "prepare": "husky",
1505
1505
  "release": "semantic-release",
1506
1506
  "test": "vitest run",
1507
+ "test:coverage": "vitest run --coverage",
1507
1508
  "translate:i18n": "node scripts/translate-language-i18n.mjs",
1508
1509
  "typecheck": "tsc --noEmit",
1509
1510
  "website:bench": "node scripts/run-website-benchmarks.mjs",
@@ -1522,6 +1523,7 @@
1522
1523
  "@semantic-release/github": "^12.0.8",
1523
1524
  "@semantic-release/npm": "^13.1.5",
1524
1525
  "@semantic-release/release-notes-generator": "^14.1.1",
1526
+ "@vitest/coverage-v8": "^4.1.9",
1525
1527
  "eslint": "^9.39.4",
1526
1528
  "husky": "^9.1.7",
1527
1529
  "semantic-release": "^25.0.3",