@lokascript/semantic 2.6.0 → 2.7.1

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.
Files changed (40) hide show
  1. package/dist/browser-ar.ar.global.js +5 -5
  2. package/dist/browser-bn.bn.global.js +4 -4
  3. package/dist/browser-de.de.global.js +4 -4
  4. package/dist/browser-east-asian.east-asian.global.js +3 -3
  5. package/dist/browser-en-tr.en-tr.global.js +4 -4
  6. package/dist/browser-es.es.global.js +4 -4
  7. package/dist/browser-fr.fr.global.js +3 -3
  8. package/dist/browser-hi.hi.global.js +3 -3
  9. package/dist/browser-id.id.global.js +4 -4
  10. package/dist/browser-it.it.global.js +3 -3
  11. package/dist/browser-ja.ja.global.js +4 -4
  12. package/dist/browser-ko.ko.global.js +5 -5
  13. package/dist/browser-lazy.lazy.global.js +1 -1
  14. package/dist/browser-ms.ms.global.js +4 -4
  15. package/dist/browser-pl.pl.global.js +4 -4
  16. package/dist/browser-priority.priority.global.js +1 -1
  17. package/dist/browser-qu.qu.global.js +5 -5
  18. package/dist/browser-ru.ru.global.js +5 -5
  19. package/dist/browser-sw.sw.global.js +4 -4
  20. package/dist/browser-th.th.global.js +3 -3
  21. package/dist/browser-tl.tl.global.js +4 -4
  22. package/dist/browser-tr.tr.global.js +4 -4
  23. package/dist/browser-uk.uk.global.js +5 -5
  24. package/dist/browser-vi.vi.global.js +3 -3
  25. package/dist/browser.global.js +22 -22
  26. package/dist/browser.global.js.map +1 -1
  27. package/dist/generators/index.d.ts +1 -0
  28. package/dist/generators/index.d.ts.map +1 -1
  29. package/dist/generators/profile-queries.d.ts +32 -0
  30. package/dist/generators/profile-queries.d.ts.map +1 -0
  31. package/dist/index.cjs +19 -0
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +17 -0
  36. package/dist/index.js.map +1 -1
  37. package/package.json +3 -3
  38. package/src/generators/index.ts +3 -0
  39. package/src/generators/profile-queries.ts +53 -0
  40. package/src/index.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokascript/semantic",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "Semantic multilingual parser for hyperscript (24 languages)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -246,7 +246,7 @@
246
246
  "author": "LokaScript Contributors",
247
247
  "license": "MIT",
248
248
  "dependencies": {
249
- "@lokascript/framework": "^2.6.0",
249
+ "@lokascript/framework": "^2.7.1",
250
250
  "nearley": "^2.20.1"
251
251
  },
252
252
  "devDependencies": {
@@ -272,7 +272,7 @@
272
272
  },
273
273
  "homepage": "https://github.com/codetalcott/hyperfixi/tree/main/packages/semantic#readme",
274
274
  "engines": {
275
- "node": ">=18.0.0"
275
+ "node": ">=24"
276
276
  },
277
277
  "publishConfig": {
278
278
  "access": "public"
@@ -44,6 +44,9 @@ export {
44
44
  // Static all-known-profiles manifest (non-deprecated successor to languageProfiles)
45
45
  export { KNOWN_PROFILES } from './known-profiles';
46
46
 
47
+ // Query helpers over the manifest (public API for mcp-server/LSP/domain bridges)
48
+ export { getKeywordTranslations, getRoleMarkers } from './profile-queries';
49
+
47
50
  // Command schemas
48
51
  export {
49
52
  type CommandSchema,
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Small query helpers over the language-profile manifest.
3
+ *
4
+ * Public API for consumers that need per-language profile facts without
5
+ * hand-rolling profile iteration (mcp-server's profile tools,
6
+ * language-server hovers, framework-bridge domains). Backed by
7
+ * `KNOWN_PROFILES` (every defined profile, independent of runtime
8
+ * registration) — pass an explicit `languages` list to narrow.
9
+ */
10
+
11
+ import type { SemanticRole } from '../types';
12
+ import type { KeywordTranslation, RoleMarker } from './profiles/types';
13
+ import { KNOWN_PROFILES } from './known-profiles';
14
+
15
+ /**
16
+ * Look up one keyword's translations across languages.
17
+ *
18
+ * @param keyword - Profile keyword / action name (e.g. `toggle`, `set`)
19
+ * @param languages - Language codes to include (default: every known profile)
20
+ * @returns Map of language code → translation, with entries only for
21
+ * languages whose profile defines the keyword
22
+ */
23
+ export function getKeywordTranslations(
24
+ keyword: string,
25
+ languages?: readonly string[]
26
+ ): Record<string, KeywordTranslation> {
27
+ const codes = languages ?? Object.keys(KNOWN_PROFILES);
28
+ const translations: Record<string, KeywordTranslation> = {};
29
+ for (const code of codes) {
30
+ const translation = KNOWN_PROFILES[code]?.keywords[keyword];
31
+ if (translation) translations[code] = translation;
32
+ }
33
+ return translations;
34
+ }
35
+
36
+ /**
37
+ * Look up a language's grammatical role markers.
38
+ *
39
+ * @param language - Language code (e.g. `ja`)
40
+ * @param role - Optional semantic role; when given, returns that role's
41
+ * marker only
42
+ * @returns The marker(s), or `undefined` when the language is unknown or
43
+ * has no marker for the requested role
44
+ */
45
+ export function getRoleMarkers(language: string): Partial<Record<SemanticRole, RoleMarker>>;
46
+ export function getRoleMarkers(language: string, role: SemanticRole): RoleMarker | undefined;
47
+ export function getRoleMarkers(
48
+ language: string,
49
+ role?: SemanticRole
50
+ ): Partial<Record<SemanticRole, RoleMarker>> | RoleMarker | undefined {
51
+ const markers = KNOWN_PROFILES[language]?.roleMarkers ?? {};
52
+ return role ? markers[role] : markers;
53
+ }
package/src/index.ts CHANGED
@@ -302,6 +302,10 @@ export {
302
302
  // Static all-known-profiles manifest
303
303
  KNOWN_PROFILES,
304
304
 
305
+ // Query helpers over the manifest (for mcp-server/LSP/domain bridges)
306
+ getKeywordTranslations,
307
+ getRoleMarkers,
308
+
305
309
  // Command schemas
306
310
  type CommandSchema,
307
311
  type RoleSpec,