@absolutejs/absolute 0.19.0-beta.1071 → 0.19.0-beta.1072

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/cli/index.js CHANGED
@@ -178649,6 +178649,7 @@ var resolveDevPort = async (requestedPort, options = {}) => {
178649
178649
  init_utils();
178650
178650
  var cliTag = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
178651
178651
  var DEFAULT_PORT_RANGE = 10;
178652
+ var RESTART_PARK_POLL_MS = 20;
178652
178653
  var NODE_API_IMPORT_ERROR = "To load Node-API modules, use require() or process.dlopen instead of import.";
178653
178654
  var formatServerBootDiagnostic = (output, serverEntry) => {
178654
178655
  if (!output.includes(NODE_API_IMPORT_ERROR))
@@ -179000,17 +179001,30 @@ var dev = async (serverEntry, configPath2) => {
179000
179001
  let serverProcess = await spawnServer();
179001
179002
  const sessionStart = Date.now();
179002
179003
  let serverRestartPending = false;
179004
+ let serverRestartQueued = false;
179005
+ const runServerRestart = async () => {
179006
+ serverRestartQueued = false;
179007
+ try {
179008
+ await restartServer();
179009
+ } catch (err) {
179010
+ console.error(cliTag("\x1B[31m", `Restart failed: ${err}`));
179011
+ }
179012
+ if (serverRestartQueued) {
179013
+ await runServerRestart();
179014
+ return;
179015
+ }
179016
+ serverRestartPending = false;
179017
+ };
179003
179018
  const scheduleServerRestart = (filePath) => {
179004
- if (serverRestartPending)
179019
+ if (serverRestartPending) {
179020
+ serverRestartQueued = true;
179005
179021
  return;
179022
+ }
179006
179023
  serverRestartPending = true;
179007
179024
  const relPath = filePath.startsWith(process.cwd()) ? filePath.slice(process.cwd().length + 1) : filePath;
179008
179025
  console.log(cliTag("\x1B[36m", `Server file changed: ${relPath} \u2014 restarting...`));
179009
179026
  setTimeout(() => {
179010
- serverRestartPending = false;
179011
- restartServer().catch((err) => {
179012
- console.error(cliTag("\x1B[31m", `Restart failed: ${err}`));
179013
- });
179027
+ runServerRestart();
179014
179028
  }, 80);
179015
179029
  };
179016
179030
  try {
@@ -179112,8 +179126,8 @@ var dev = async (serverEntry, configPath2) => {
179112
179126
  } catch {}
179113
179127
  updateInstance(instancePid, { frameworks });
179114
179128
  sendTelemetryEvent("dev:start", { entry: serverEntry, frameworks });
179115
- const killChildTree = (signal) => {
179116
- const childPid = serverProcess.pid;
179129
+ const signalChildTree = (proc, signal) => {
179130
+ const childPid = proc.pid;
179117
179131
  if (typeof childPid !== "number")
179118
179132
  return;
179119
179133
  try {
@@ -179124,6 +179138,28 @@ var dev = async (serverEntry, configPath2) => {
179124
179138
  process.kill(childPid, signal);
179125
179139
  } catch {}
179126
179140
  };
179141
+ const killChildTree = (signal) => signalChildTree(serverProcess, signal);
179142
+ const FORCE_KILL_GRACE_MS = 2 * MILLISECONDS_IN_A_SECOND;
179143
+ const terminateChild = (proc) => new Promise((res) => {
179144
+ if (proc.exitCode !== null || typeof proc.pid !== "number") {
179145
+ res();
179146
+ return;
179147
+ }
179148
+ let settled = false;
179149
+ const finish = () => {
179150
+ if (settled)
179151
+ return;
179152
+ settled = true;
179153
+ clearTimeout(killTimer);
179154
+ res();
179155
+ };
179156
+ proc.once("exit", finish);
179157
+ signalChildTree(proc, "SIGTERM");
179158
+ const killTimer = setTimeout(() => {
179159
+ signalChildTree(proc, "SIGKILL");
179160
+ }, FORCE_KILL_GRACE_MS);
179161
+ killTimer.unref();
179162
+ });
179127
179163
  const cleanup = async (exitCode = 0) => {
179128
179164
  if (cleaning)
179129
179165
  return;
@@ -179157,6 +179193,7 @@ var dev = async (serverEntry, configPath2) => {
179157
179193
  removeHeapPreload();
179158
179194
  process.exit(exitCode);
179159
179195
  };
179196
+ let intentionalRestart = false;
179160
179197
  const restartServer = async () => {
179161
179198
  serverReady = false;
179162
179199
  console.log(cliTag("\x1B[36m", "Restarting server..."));
@@ -179166,17 +179203,10 @@ var dev = async (serverEntry, configPath2) => {
179166
179203
  sendSignal("SIGCONT");
179167
179204
  paused = false;
179168
179205
  }
179169
- try {
179170
- old.kill("SIGTERM");
179171
- } catch {}
179206
+ intentionalRestart = true;
179207
+ await terminateChild(old);
179172
179208
  serverProcess = await spawnServer();
179173
- await new Promise((res) => {
179174
- if (old.exitCode !== null) {
179175
- res();
179176
- return;
179177
- }
179178
- old.once("exit", () => res());
179179
- });
179209
+ intentionalRestart = false;
179180
179210
  console.log(cliTag("\x1B[32m", "Server restarted."));
179181
179211
  };
179182
179212
  const sendSignalToGroup = (signal) => {
@@ -179325,6 +179355,12 @@ var dev = async (serverEntry, configPath2) => {
179325
179355
  serverProcess = await spawnServer();
179326
179356
  return true;
179327
179357
  };
179358
+ const waitForIntentionalRestart = async () => {
179359
+ if (!intentionalRestart)
179360
+ return;
179361
+ await Bun.sleep(RESTART_PARK_POLL_MS);
179362
+ await waitForIntentionalRestart();
179363
+ };
179328
179364
  const monitorServer = async () => {
179329
179365
  if (cleaning) {
179330
179366
  return;
@@ -179337,6 +179373,11 @@ var dev = async (serverEntry, configPath2) => {
179337
179373
  }
179338
179374
  current.once("exit", (code) => res(code));
179339
179375
  });
179376
+ if (intentionalRestart) {
179377
+ await waitForIntentionalRestart();
179378
+ await monitorServer();
179379
+ return;
179380
+ }
179340
179381
  if (cleaning || serverProcess !== current) {
179341
179382
  await monitorServer();
179342
179383
  return;
package/dist/index.js CHANGED
@@ -25255,6 +25255,59 @@ ${fields}
25255
25255
  deferSlots: inlinedTemplate.deferSlots,
25256
25256
  source: result
25257
25257
  };
25258
+ }, CLASS_KEYWORD = "class", isIdentifierChar = (char) => char !== undefined && /[A-Za-z0-9_$]/.test(char), skipStringLiteral = (source, start) => {
25259
+ const quote = source[start];
25260
+ let index = start + 1;
25261
+ while (index < source.length) {
25262
+ if (source[index] === "\\") {
25263
+ index += 2;
25264
+ continue;
25265
+ }
25266
+ if (source[index] === quote)
25267
+ return index + 1;
25268
+ index += 1;
25269
+ }
25270
+ return index;
25271
+ }, findDecoratedClassKeyword = (source, start) => {
25272
+ let index = start;
25273
+ let depth = 0;
25274
+ while (index < source.length) {
25275
+ const char = source[index];
25276
+ if (char === '"' || char === "'" || char === "`") {
25277
+ index = skipStringLiteral(source, index);
25278
+ continue;
25279
+ }
25280
+ const isOpen = char === "(" || char === "[" || char === "{";
25281
+ const isClose = char === ")" || char === "]" || char === "}";
25282
+ const atClass = depth === 0 && source.startsWith(CLASS_KEYWORD, index) && !isIdentifierChar(source[index - 1]) && !isIdentifierChar(source[index + CLASS_KEYWORD.length]);
25283
+ if (atClass)
25284
+ return index;
25285
+ if (isOpen)
25286
+ depth += 1;
25287
+ else if (isClose)
25288
+ depth -= 1;
25289
+ index += 1;
25290
+ }
25291
+ return -1;
25292
+ }, hoistExportPastDecorators = (source) => {
25293
+ const exportBeforeDecorator = /\bexport\s+(?=@)/g;
25294
+ let result = "";
25295
+ let lastIndex = 0;
25296
+ let match = exportBeforeDecorator.exec(source);
25297
+ while (match !== null) {
25298
+ const decoratorStart = match.index + match[0].length;
25299
+ const classIndex = findDecoratedClassKeyword(source, decoratorStart);
25300
+ if (classIndex !== -1) {
25301
+ result += source.slice(lastIndex, match.index);
25302
+ result += source.slice(decoratorStart, classIndex);
25303
+ result += `export ${CLASS_KEYWORD}`;
25304
+ lastIndex = classIndex + CLASS_KEYWORD.length;
25305
+ exportBeforeDecorator.lastIndex = lastIndex;
25306
+ }
25307
+ match = exportBeforeDecorator.exec(source);
25308
+ }
25309
+ result += source.slice(lastIndex);
25310
+ return result;
25258
25311
  }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
25259
25312
  const entryPath = resolve24(inputPath);
25260
25313
  const allOutputs = [];
@@ -25319,7 +25372,7 @@ ${fields}
25319
25372
  return specifier.includes("?") ? `${specifier}&t=${cacheBuster}` : `${specifier}?t=${cacheBuster}`;
25320
25373
  };
25321
25374
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
25322
- let processedContent = angularTranspiler.transformSync(sourceCode);
25375
+ let processedContent = angularTranspiler.transformSync(hoistExportPastDecorators(sourceCode));
25323
25376
  const outputPath = toOutputPath(actualPath);
25324
25377
  const rewriteBareImport = (prefix, specifier, suffix) => {
25325
25378
  const rewritten = importRewrites.get(specifier);
@@ -46608,5 +46661,5 @@ export {
46608
46661
  ANGULAR_INIT_TIMEOUT_MS
46609
46662
  };
46610
46663
 
46611
- //# debugId=119C10E5B5088D9764756E2164756E21
46664
+ //# debugId=8A2CABA7603DDD1464756E2164756E21
46612
46665
  //# sourceMappingURL=index.js.map