@lokascript/language-server 2.6.0 → 2.7.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.
@@ -6054,20 +6054,6 @@ function withDefaultExtractors(tokenizer) {
6054
6054
  tokenizer.registerExtractors(getDefaultExtractors());
6055
6055
  return tokenizer;
6056
6056
  }
6057
- function createUnicodeRangeClassifier(ranges) {
6058
- return (char) => {
6059
- const code = char.charCodeAt(0);
6060
- return ranges.some(([start, end]) => code >= start && code <= end);
6061
- };
6062
- }
6063
- function combineClassifiers(...classifiers) {
6064
- return (char) => classifiers.some((fn) => fn(char));
6065
- }
6066
- function createLatinCharClassifiers(letterPattern) {
6067
- const isLetter = (char) => letterPattern.test(char);
6068
- const isIdentifierChar = (char) => isLetter(char) || /[0-9_-]/.test(char);
6069
- return { isLetter, isIdentifierChar };
6070
- }
6071
6057
  var SIMPLE_TOKENIZER_OPERATOR_SET = new Set(DEFAULT_OPERATORS);
6072
6058
  var MARKER_CONCEPT_NORMALIZEDS = /* @__PURE__ */ new Set([
6073
6059
  // Role-marker role names (profile.roleMarkers normalizeds)
@@ -6802,6 +6788,115 @@ function createSimpleTokenizer(config) {
6802
6788
  }
6803
6789
  return new SimpleTokenizer();
6804
6790
  }
6791
+ function mergeRoleMarkers(slice, vocab) {
6792
+ const merged = {};
6793
+ const add = (role, marker) => {
6794
+ if (!marker?.primary) {
6795
+ delete merged[role];
6796
+ return;
6797
+ }
6798
+ merged[role] = {
6799
+ primary: marker.primary,
6800
+ ...marker.alternatives?.length && { alternatives: [...marker.alternatives] },
6801
+ ...marker.position && { position: marker.position }
6802
+ };
6803
+ };
6804
+ for (const [role, marker] of Object.entries(slice.roleMarkers ?? {})) add(role, marker);
6805
+ for (const [role, marker] of Object.entries(vocab.roleMarkerOverrides ?? {})) add(role, marker);
6806
+ return merged;
6807
+ }
6808
+ function buildPatternProfile(slice, vocab) {
6809
+ const keywords = {};
6810
+ for (const [action, translation] of Object.entries(vocab.keywords)) {
6811
+ keywords[action] = {
6812
+ primary: translation.primary,
6813
+ ...translation.alternatives?.length && { alternatives: [...translation.alternatives] }
6814
+ };
6815
+ }
6816
+ const roleMarkers = mergeRoleMarkers(slice, vocab);
6817
+ return {
6818
+ code: slice.code,
6819
+ wordOrder: slice.wordOrder,
6820
+ keywords,
6821
+ ...Object.keys(roleMarkers).length > 0 && { roleMarkers }
6822
+ };
6823
+ }
6824
+ function defaultCaseInsensitive(script) {
6825
+ return script === void 0 || script === "latin" || script === "cyrillic";
6826
+ }
6827
+ function buildDomainTokenizer(slice, vocab, options = {}) {
6828
+ const roleMarkers = mergeRoleMarkers(slice, vocab);
6829
+ const keywords = /* @__PURE__ */ new Set();
6830
+ for (const translation of Object.values(vocab.keywords)) {
6831
+ keywords.add(translation.primary);
6832
+ for (const alt of translation.alternatives ?? []) keywords.add(alt);
6833
+ }
6834
+ for (const marker of Object.values(roleMarkers)) {
6835
+ keywords.add(marker.primary);
6836
+ for (const alt of marker.alternatives ?? []) keywords.add(alt);
6837
+ }
6838
+ for (const particle of slice.tokenization?.particles ?? []) keywords.add(particle);
6839
+ for (const extra of vocab.tokenizerKeywords ?? []) keywords.add(extra);
6840
+ const profileKeywords = {};
6841
+ for (const [action, translation] of Object.entries(vocab.keywords)) {
6842
+ profileKeywords[action] = {
6843
+ primary: translation.primary,
6844
+ ...translation.alternatives?.length && { alternatives: [...translation.alternatives] },
6845
+ normalized: translation.normalized ?? action
6846
+ };
6847
+ }
6848
+ const keywordProfile = {
6849
+ keywords: profileKeywords,
6850
+ ...Object.keys(roleMarkers).length > 0 && { roleMarkers }
6851
+ };
6852
+ const customExtractors = [
6853
+ ...options.customExtractors ?? [],
6854
+ ...slice.script === "latin" ? [new LatinExtendedIdentifierExtractor()] : []
6855
+ ];
6856
+ return createSimpleTokenizer({
6857
+ language: slice.code,
6858
+ direction: slice.direction ?? "ltr",
6859
+ keywords: [...keywords],
6860
+ ...vocab.keywordExtras?.length && { keywordExtras: vocab.keywordExtras.map((e) => ({ ...e })) },
6861
+ keywordProfile,
6862
+ includeOperators: options.includeOperators ?? false,
6863
+ caseInsensitive: options.caseInsensitive ?? defaultCaseInsensitive(slice.script),
6864
+ ...customExtractors.length > 0 && { customExtractors }
6865
+ });
6866
+ }
6867
+ function buildLanguageConfig(slice, vocab, meta = {}) {
6868
+ const name = meta.name ?? slice.name ?? slice.code;
6869
+ return {
6870
+ code: slice.code,
6871
+ name,
6872
+ nativeName: meta.nativeName ?? slice.nativeName ?? name,
6873
+ tokenizer: meta.tokenizer ?? buildDomainTokenizer(slice, vocab, meta.tokenizerOptions),
6874
+ patternProfile: buildPatternProfile(slice, vocab),
6875
+ ...meta.grammarProfile && { grammarProfile: meta.grammarProfile }
6876
+ };
6877
+ }
6878
+ function deriveRoleMarkers(slice, roleMapping) {
6879
+ const derived = {};
6880
+ for (const [domainRole, semanticRole] of Object.entries(roleMapping)) {
6881
+ const marker = slice.roleMarkers?.[semanticRole];
6882
+ if (marker?.primary) derived[domainRole] = marker.primary;
6883
+ }
6884
+ return derived;
6885
+ }
6886
+ function createUnicodeRangeClassifier(ranges) {
6887
+ return (char) => {
6888
+ const code = char.charCodeAt(0);
6889
+ return ranges.some(([start, end]) => code >= start && code <= end);
6890
+ };
6891
+ }
6892
+ function combineClassifiers(...classifiers) {
6893
+ return (char) => classifiers.some((fn) => fn(char));
6894
+ }
6895
+ function createLatinCharClassifiers(letterPattern) {
6896
+ const isLetter = (char) => letterPattern.test(char);
6897
+ const isIdentifierChar = (char) => isLetter(char) || /[0-9_-]/.test(char);
6898
+ return { isLetter, isIdentifierChar };
6899
+ }
6805
6900
  function noChange(word) {
6806
6901
  return { stem: word, confidence: 1 };
6807
6902
  }
@@ -7356,7 +7451,10 @@ export {
7356
7451
  WhitespaceExtractor,
7357
7452
  accumulateBlocks,
7358
7453
  buildDisambiguation,
7454
+ buildDomainTokenizer,
7359
7455
  buildFeedback,
7456
+ buildLanguageConfig,
7457
+ buildPatternProfile,
7360
7458
  buildPhrase,
7361
7459
  buildTablesFromProfiles,
7362
7460
  combineClassifiers,
@@ -7387,6 +7485,7 @@ export {
7387
7485
  createUnicodeRangeClassifier,
7388
7486
  defineCommand,
7389
7487
  defineRole,
7488
+ deriveRoleMarkers,
7390
7489
  detectWordOrders,
7391
7490
  extractCssSelector,
7392
7491
  extractNumber,
package/dist/server.js CHANGED
@@ -140,9 +140,6 @@ function detectLokascriptFeatures(code) {
140
140
  }
141
141
  return detected;
142
142
  }
143
- function getCommandsForMode(mode) {
144
- return mode === "hyperscript" ? HYPERSCRIPT_COMMANDS : ALL_COMMANDS;
145
- }
146
143
 
147
144
  // src/extraction.ts
148
145
  function isHtmlDocument(uri, content) {
@@ -1137,7 +1134,7 @@ try {
1137
1134
  }
1138
1135
  var frameworkIR = null;
1139
1136
  try {
1140
- const fw = await import("./dist-7HGHK5EJ.js");
1137
+ const fw = await import("./dist-MRVDB2YM.js");
1141
1138
  frameworkIR = { fromInterchangeNode: fw.fromInterchangeNode, renderExplicit: fw.renderExplicit };
1142
1139
  console.error(
1143
1140
  "[lokascript-ls] @lokascript/framework loaded \u2014 LSE bracket notation in hover enabled"
@@ -1441,7 +1438,7 @@ function getSemanticAnalyzer() {
1441
1438
  return cachedAnalyzer;
1442
1439
  }
1443
1440
  var globalSettings = envDefaultMode ? { ...defaultSettings, mode: envDefaultMode } : defaultSettings;
1444
- connection.onInitialize((params) => {
1441
+ connection.onInitialize((_params) => {
1445
1442
  resolvedMode = resolveMode(globalSettings);
1446
1443
  const brand = getBranding(resolvedMode);
1447
1444
  connection.console.log(`${brand} Language Server initializing (mode: ${resolvedMode})...`);
@@ -1813,15 +1810,12 @@ function getContextualCompletions(context, language) {
1813
1810
  }
1814
1811
  return eng;
1815
1812
  };
1816
- const commandMode = isHyperscriptCompatMode(resolvedMode) ? "hyperscript" : "lokascript";
1817
- const availableCommands = getCommandsForMode(commandMode);
1818
- const isCommandAvailable = (cmd) => availableCommands.includes(cmd);
1819
1813
  const getDetail = (command, fallback) => {
1820
1814
  const desc = getCommandDescription(command, effectiveLanguage);
1821
1815
  return desc?.detail ?? fallback;
1822
1816
  };
1823
1817
  switch (context) {
1824
- case "event":
1818
+ case "event": {
1825
1819
  const eventNames = lspMetadata?.EVENT_NAMES ?? FALLBACK_EVENT_NAMES;
1826
1820
  for (const eventName of eventNames) {
1827
1821
  completions.push({
@@ -1831,6 +1825,7 @@ function getContextualCompletions(context, language) {
1831
1825
  });
1832
1826
  }
1833
1827
  break;
1828
+ }
1834
1829
  case "command":
1835
1830
  completions.push(
1836
1831
  {
@@ -2174,7 +2169,7 @@ ${doc.example}
2174
2169
  var translationCache = null;
2175
2170
  function buildTranslationCache() {
2176
2171
  const cache2 = /* @__PURE__ */ new Map();
2177
- if (!semanticPackage) return cache2;
2172
+ if (!semanticPackage?.getKeywordTranslations) return cache2;
2178
2173
  const langMap = {
2179
2174
  es: "Spanish",
2180
2175
  ja: "Japanese",
@@ -2208,19 +2203,15 @@ function buildTranslationCache() {
2208
2203
  "result"
2209
2204
  ];
2210
2205
  for (const canonicalKey of canonicalKeywords) {
2206
+ const byLang = semanticPackage.getKeywordTranslations(
2207
+ canonicalKey,
2208
+ Object.keys(langMap)
2209
+ );
2211
2210
  const translations = [];
2212
2211
  for (const [lang, langName] of Object.entries(langMap)) {
2213
- try {
2214
- const profile = semanticPackage.tryGetProfile(lang);
2215
- const kw = profile?.keywords?.[canonicalKey];
2216
- if (kw) {
2217
- const trans = kw;
2218
- if (trans.primary && trans.primary !== canonicalKey) {
2219
- translations.push(`${langName}: \`${trans.primary}\``);
2220
- }
2221
- }
2222
- } catch (e) {
2223
- connection.console.log(`[lokascript-ls] Translation cache: profile '${lang}' not found`);
2212
+ const primary = byLang[lang]?.primary;
2213
+ if (primary && primary !== canonicalKey) {
2214
+ translations.push(`${langName}: \`${primary}\``);
2224
2215
  }
2225
2216
  }
2226
2217
  if (translations.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokascript/language-server",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Language Server Protocol implementation for LokaScript/hyperscript with 21 language support",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",
@@ -31,8 +31,8 @@
31
31
  "vscode-languageserver-textdocument": "^1.0.11"
32
32
  },
33
33
  "peerDependencies": {
34
- "@hyperfixi/core": "^2.6.0",
35
- "@lokascript/semantic": "^2.6.0"
34
+ "@hyperfixi/core": "^2.7.0",
35
+ "@lokascript/semantic": "^2.7.0"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@lokascript/semantic": {
@@ -43,8 +43,8 @@
43
43
  }
44
44
  },
45
45
  "devDependencies": {
46
- "@hyperfixi/core": "^2.6.0",
47
- "@lokascript/semantic": "^2.6.0",
46
+ "@hyperfixi/core": "^2.7.0",
47
+ "@lokascript/semantic": "^2.7.0",
48
48
  "@types/node": "^20.0.0",
49
49
  "@vitest/coverage-v8": "^4.0.0",
50
50
  "tsup": "^8.0.0",