@rohal12/spindle-lsp 0.2.0 → 0.3.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.
package/dist/bin.js CHANGED
@@ -244,6 +244,7 @@ var init_passage_index = __esm({
244
244
 
245
245
  // src/core/workspace/macro-registry.ts
246
246
  import { existsSync, readFileSync as readFileSync2 } from "node:fs";
247
+ import { createRequire } from "node:module";
247
248
  import { dirname, join, parse as parsePath } from "node:path";
248
249
  import { fileURLToPath } from "node:url";
249
250
  var MacroRegistry;
@@ -262,7 +263,7 @@ var init_macro_registry = __esm({
262
263
  let builtinMacros = [];
263
264
  try {
264
265
  const thisDir = dirname(fileURLToPath(import.meta.url));
265
- const registryPath = this.resolveRegistryPath(thisDir);
266
+ const registryPath = this.resolveRegistryPathViaRequire(thisDir) ?? this.resolveRegistryPath(thisDir);
266
267
  if (registryPath) {
267
268
  const raw = readFileSync2(registryPath, "utf-8");
268
269
  const parsed = JSON.parse(raw);
@@ -352,6 +353,20 @@ var init_macro_registry = __esm({
352
353
  * Walk up directory tree from `startDir` to find the
353
354
  * @rohal12/spindle/dist/pkg/macro-registry.json file.
354
355
  */
356
+ /**
357
+ * Resolve macro-registry.json using Node's require resolution.
358
+ * Works in bundled contexts where import.meta.url may not be near node_modules.
359
+ */
360
+ resolveRegistryPathViaRequire(startDir) {
361
+ try {
362
+ const require2 = createRequire(join(startDir, "_"));
363
+ const toolingPath = require2.resolve("@rohal12/spindle/tooling");
364
+ const candidate = join(dirname(toolingPath), "macro-registry.json");
365
+ if (existsSync(candidate)) return candidate;
366
+ } catch {
367
+ }
368
+ return null;
369
+ }
355
370
  resolveRegistryPath(startDir) {
356
371
  const target = join("node_modules", "@rohal12", "spindle", "dist", "pkg", "macro-registry.json");
357
372
  let dir = startDir;
@@ -2397,8 +2412,11 @@ function parseConfig(content, format) {
2397
2412
  return { macros: {} };
2398
2413
  }
2399
2414
  const obj = raw;
2415
+ const spindle0 = obj["spindle-0"];
2416
+ const source = spindle0 && typeof spindle0 === "object" ? spindle0 : obj;
2400
2417
  return {
2401
- macros: typeof obj.macros === "object" && obj.macros !== null ? obj.macros : {}
2418
+ macros: typeof source.macros === "object" && source.macros !== null ? source.macros : {},
2419
+ enums: typeof source.enums === "object" && source.enums !== null ? source.enums : void 0
2402
2420
  };
2403
2421
  }
2404
2422
  function findConfigFile(workspaceRoot) {
@@ -2426,7 +2444,10 @@ var init_config_loader = __esm({
2426
2444
  CONFIG_FILENAMES = [
2427
2445
  "spindle.config.yaml",
2428
2446
  "spindle.config.yml",
2429
- "spindle.config.json"
2447
+ "spindle.config.json",
2448
+ "t3lt.twee-config.yaml",
2449
+ "t3lt.twee-config.yml",
2450
+ "t3lt.twee-config.json"
2430
2451
  ];
2431
2452
  EMPTY_CONFIG = { macros: {} };
2432
2453
  }
@@ -2685,7 +2706,26 @@ async function runCheck(args2) {
2685
2706
  }
2686
2707
  return 0;
2687
2708
  }
2688
- const configRoot = options.configPath ? resolve(cwd, options.configPath, "..") : cwd;
2709
+ let configRoot;
2710
+ if (options.configPath) {
2711
+ configRoot = resolve(cwd, options.configPath, "..");
2712
+ } else {
2713
+ const dirs = uniqueFiles.map((f) => resolve(f, ".."));
2714
+ configRoot = dirs.reduce((a, b) => {
2715
+ while (!b.startsWith(a)) a = resolve(a, "..");
2716
+ return a;
2717
+ });
2718
+ let search = configRoot;
2719
+ for (let i = 0; i < 10; i++) {
2720
+ if (findConfigFile(search)) {
2721
+ configRoot = search;
2722
+ break;
2723
+ }
2724
+ const parent = resolve(search, "..");
2725
+ if (parent === search) break;
2726
+ search = parent;
2727
+ }
2728
+ }
2689
2729
  const projectConfig = loadConfigFromDisk(configRoot);
2690
2730
  const workspace = new WorkspaceModel();
2691
2731
  const fileContents = /* @__PURE__ */ new Map();
@@ -4847,7 +4887,8 @@ function startServer(_args) {
4847
4887
  { globPattern: "**/*.twee" },
4848
4888
  { globPattern: "**/*.js" },
4849
4889
  { globPattern: "**/*.ts" },
4850
- { globPattern: "**/spindle.config.*" }
4890
+ { globPattern: "**/spindle.config.*" },
4891
+ { globPattern: "**/*twee-config.*" }
4851
4892
  ]
4852
4893
  });
4853
4894
  if (workspace) {