@tsplc/compiler 0.2.10 → 0.2.11

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/index.js CHANGED
@@ -52,7 +52,7 @@ var runtimeSources = (program) => {
52
52
  // packages/compiler/src/frontend/typescript.ts
53
53
  import ts15 from "typescript";
54
54
  import { createRequire } from "node:module";
55
- import { mkdirSync, writeFileSync as writeFileSync2 } from "node:fs";
55
+ import { mkdirSync, realpathSync, writeFileSync as writeFileSync2 } from "node:fs";
56
56
  import { dirname as dirname8, join as join4, relative as relative6, resolve as resolve4 } from "node:path";
57
57
  import {
58
58
  instancedBlock as instancedBlock3,
@@ -1833,11 +1833,12 @@ protected execute(input:{}):void {}
1833
1833
  if (!interval || !ts6.isCallExpression(interval) || interval.arguments.length !== 1 || !ts6.isNumericLiteral(interval.arguments[0]) || !priority || !ts6.isNumericLiteral(priority) || !["ms", "seconds"].some((n) => official(interval.expression, n)))
1834
1834
  fail(init, "Background schedules require a literal ms/seconds interval and priority.");
1835
1835
  const milliseconds = Number(interval.arguments[0].text) * (official(interval.expression, "seconds") ? 1000 : 1);
1836
- if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0 || milliseconds > 4294967295 || Number(priority.text) < 1 || Number(priority.text) > 31)
1837
- fail(init, "Background interval must be positive and priority must be 1..31.");
1836
+ const taskPriority = Number(priority.text);
1837
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0 || milliseconds > 4294967295 || !Number.isInteger(taskPriority) || taskPriority < 1 || taskPriority > 31)
1838
+ fail(init, "Background interval must be positive and priority must be an integer in 1..31.");
1838
1839
  const schedule = {
1839
1840
  intervalNanoseconds: String(BigInt(milliseconds) * 1000000n),
1840
- priority: Number(priority.text),
1841
+ priority: taskPriority,
1841
1842
  mailbox: dec.name.text,
1842
1843
  worker
1843
1844
  };
@@ -5233,6 +5234,21 @@ var typeCheckOnly = {
5233
5234
  noEmit: true,
5234
5235
  tsBuildInfoFile: undefined
5235
5236
  };
5237
+ var sdkFor = (project, options) => {
5238
+ const name = "@tsplc/compiler/globals";
5239
+ const resolveSdk = (from) => createRequire(from).resolve(name).replaceAll("\\", "/");
5240
+ try {
5241
+ const installed = resolveSdk(project);
5242
+ const resolved = ts15.resolveModuleName(name, project, options, ts15.sys).resolvedModule;
5243
+ if (resolved && realpathSync(resolved.resolvedFileName) === realpathSync(installed))
5244
+ return resolved.resolvedFileName;
5245
+ return installed;
5246
+ } catch (cause) {
5247
+ if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "MODULE_NOT_FOUND")
5248
+ throw cause;
5249
+ return resolveSdk(import.meta.url);
5250
+ }
5251
+ };
5236
5252
  function analyze(options) {
5237
5253
  const filename = resolve4(options.tsconfig);
5238
5254
  const config = ts15.readConfigFile(filename, ts15.sys.readFile);
@@ -5241,12 +5257,10 @@ function analyze(options) {
5241
5257
  const parsed = ts15.parseJsonConfigFileContent(config.config, ts15.sys, dirname8(filename), undefined, filename);
5242
5258
  if (parsed.errors.length)
5243
5259
  return { diagnostics: parsed.errors.map(tsDiagnostic) };
5244
- const sdk = createRequire(import.meta.url).resolve("@tsplc/compiler/globals").replaceAll("\\", "/");
5245
5260
  const programFiles = Object.values(options.programs).map((entry) => resolve4(dirname8(filename), entry.module));
5246
5261
  const scope = options.sourceScope ?? (options.services ? "entry" : "project");
5247
5262
  const ambient = parsed.fileNames.filter((file) => /\.d\.[cm]?ts$/.test(file) && file.startsWith(`${dirname8(filename)}/`));
5248
5263
  const projectFiles = scope === "project" ? parsed.fileNames : ambient;
5249
- const rootNames = [...new Set([...projectFiles, ...programFiles, sdk])];
5250
5264
  const compilerOptions = {
5251
5265
  ...parsed.options,
5252
5266
  ...typeCheckOnly,
@@ -5266,6 +5280,8 @@ function analyze(options) {
5266
5280
  };
5267
5281
  delete compilerOptions.rootDir;
5268
5282
  delete compilerOptions.outDir;
5283
+ const sdk = sdkFor(filename, compilerOptions);
5284
+ const rootNames = [...new Set([...projectFiles, ...programFiles, sdk])];
5269
5285
  let program = ts15.createProgram(rootNames, compilerOptions);
5270
5286
  const plcFiles = (program) => {
5271
5287
  const files = new Set(runtimeSources(program));
@@ -6862,5 +6878,5 @@ export {
6862
6878
  typeCheckOnly
6863
6879
  };
6864
6880
 
6865
- //# debugId=43B8CCF724F116A364756E2164756E21
6881
+ //# debugId=1915DD200BDBBFDB64756E2164756E21
6866
6882
  //# sourceMappingURL=index.js.map