@threadbase-sh/streamer 1.37.0 → 1.38.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.
@@ -2020,7 +2020,7 @@ var require_thread_stream = __commonJS({
2020
2020
  var { version: version2 } = require_package();
2021
2021
  var { EventEmitter } = require("events");
2022
2022
  var { Worker } = require("worker_threads");
2023
- var { join: join2 } = require("path");
2023
+ var { join: join3 } = require("path");
2024
2024
  var { pathToFileURL } = require("url");
2025
2025
  var { wait } = require_wait();
2026
2026
  var {
@@ -2071,7 +2071,7 @@ var require_thread_stream = __commonJS({
2071
2071
  function createWorker(stream, opts) {
2072
2072
  const { filename, workerData } = opts;
2073
2073
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2074
- const toExecute = bundlerOverrides["thread-stream-worker"] || join2(__dirname, "lib", "worker.js");
2074
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join3(__dirname, "lib", "worker.js");
2075
2075
  const worker = new Worker(toExecute, {
2076
2076
  ...opts.workerOpts,
2077
2077
  name: opts.workerOpts?.name || "thread-stream",
@@ -2539,7 +2539,7 @@ var require_transport = __commonJS({
2539
2539
  var { createRequire } = require("module");
2540
2540
  var { existsSync: existsSync3 } = require("fs");
2541
2541
  var getCallers = require_caller();
2542
- var { join: join2, isAbsolute, sep } = require("path");
2542
+ var { join: join3, isAbsolute, sep } = require("path");
2543
2543
  var { fileURLToPath } = require("url");
2544
2544
  var sleep = require_atomic_sleep();
2545
2545
  var onExit = require_on_exit_leak_free();
@@ -2692,7 +2692,7 @@ var require_transport = __commonJS({
2692
2692
  throw new Error("only one of target or targets can be specified");
2693
2693
  }
2694
2694
  if (targets) {
2695
- target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
2695
+ target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
2696
2696
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2697
2697
  return {
2698
2698
  ...dest,
@@ -2710,7 +2710,7 @@ var require_transport = __commonJS({
2710
2710
  });
2711
2711
  });
2712
2712
  } else if (pipeline) {
2713
- target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
2713
+ target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
2714
2714
  options.pipelines = [pipeline.map((dest) => {
2715
2715
  return {
2716
2716
  ...dest,
@@ -2733,7 +2733,7 @@ var require_transport = __commonJS({
2733
2733
  return origin;
2734
2734
  }
2735
2735
  if (origin === "pino/file") {
2736
- return join2(__dirname, "..", "file.js");
2736
+ return join3(__dirname, "..", "file.js");
2737
2737
  }
2738
2738
  let fixTarget2;
2739
2739
  for (const filePath of callers) {
@@ -3714,7 +3714,7 @@ var require_safe_stable_stringify = __commonJS({
3714
3714
  return circularValue;
3715
3715
  }
3716
3716
  let res = "";
3717
- let join2 = ",";
3717
+ let join3 = ",";
3718
3718
  const originalIndentation = indentation;
3719
3719
  if (Array.isArray(value)) {
3720
3720
  if (value.length === 0) {
@@ -3728,7 +3728,7 @@ var require_safe_stable_stringify = __commonJS({
3728
3728
  indentation += spacer;
3729
3729
  res += `
3730
3730
  ${indentation}`;
3731
- join2 = `,
3731
+ join3 = `,
3732
3732
  ${indentation}`;
3733
3733
  }
3734
3734
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3736,13 +3736,13 @@ ${indentation}`;
3736
3736
  for (; i < maximumValuesToStringify - 1; i++) {
3737
3737
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3738
3738
  res += tmp2 !== void 0 ? tmp2 : "null";
3739
- res += join2;
3739
+ res += join3;
3740
3740
  }
3741
3741
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3742
3742
  res += tmp !== void 0 ? tmp : "null";
3743
3743
  if (value.length - 1 > maximumBreadth) {
3744
3744
  const removedKeys = value.length - maximumBreadth - 1;
3745
- res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
3745
+ res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
3746
3746
  }
3747
3747
  if (spacer !== "") {
3748
3748
  res += `
@@ -3763,7 +3763,7 @@ ${originalIndentation}`;
3763
3763
  let separator = "";
3764
3764
  if (spacer !== "") {
3765
3765
  indentation += spacer;
3766
- join2 = `,
3766
+ join3 = `,
3767
3767
  ${indentation}`;
3768
3768
  whitespace = " ";
3769
3769
  }
@@ -3777,13 +3777,13 @@ ${indentation}`;
3777
3777
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
3778
3778
  if (tmp !== void 0) {
3779
3779
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3780
- separator = join2;
3780
+ separator = join3;
3781
3781
  }
3782
3782
  }
3783
3783
  if (keyLength > maximumBreadth) {
3784
3784
  const removedKeys = keyLength - maximumBreadth;
3785
3785
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3786
- separator = join2;
3786
+ separator = join3;
3787
3787
  }
3788
3788
  if (spacer !== "" && separator.length > 1) {
3789
3789
  res = `
@@ -3824,7 +3824,7 @@ ${originalIndentation}`;
3824
3824
  }
3825
3825
  const originalIndentation = indentation;
3826
3826
  let res = "";
3827
- let join2 = ",";
3827
+ let join3 = ",";
3828
3828
  if (Array.isArray(value)) {
3829
3829
  if (value.length === 0) {
3830
3830
  return "[]";
@@ -3837,7 +3837,7 @@ ${originalIndentation}`;
3837
3837
  indentation += spacer;
3838
3838
  res += `
3839
3839
  ${indentation}`;
3840
- join2 = `,
3840
+ join3 = `,
3841
3841
  ${indentation}`;
3842
3842
  }
3843
3843
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3845,13 +3845,13 @@ ${indentation}`;
3845
3845
  for (; i < maximumValuesToStringify - 1; i++) {
3846
3846
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3847
3847
  res += tmp2 !== void 0 ? tmp2 : "null";
3848
- res += join2;
3848
+ res += join3;
3849
3849
  }
3850
3850
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3851
3851
  res += tmp !== void 0 ? tmp : "null";
3852
3852
  if (value.length - 1 > maximumBreadth) {
3853
3853
  const removedKeys = value.length - maximumBreadth - 1;
3854
- res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
3854
+ res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
3855
3855
  }
3856
3856
  if (spacer !== "") {
3857
3857
  res += `
@@ -3864,7 +3864,7 @@ ${originalIndentation}`;
3864
3864
  let whitespace = "";
3865
3865
  if (spacer !== "") {
3866
3866
  indentation += spacer;
3867
- join2 = `,
3867
+ join3 = `,
3868
3868
  ${indentation}`;
3869
3869
  whitespace = " ";
3870
3870
  }
@@ -3873,7 +3873,7 @@ ${indentation}`;
3873
3873
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
3874
3874
  if (tmp !== void 0) {
3875
3875
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3876
- separator = join2;
3876
+ separator = join3;
3877
3877
  }
3878
3878
  }
3879
3879
  if (spacer !== "" && separator.length > 1) {
@@ -3931,20 +3931,20 @@ ${originalIndentation}`;
3931
3931
  indentation += spacer;
3932
3932
  let res2 = `
3933
3933
  ${indentation}`;
3934
- const join3 = `,
3934
+ const join4 = `,
3935
3935
  ${indentation}`;
3936
3936
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3937
3937
  let i = 0;
3938
3938
  for (; i < maximumValuesToStringify - 1; i++) {
3939
3939
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3940
3940
  res2 += tmp2 !== void 0 ? tmp2 : "null";
3941
- res2 += join3;
3941
+ res2 += join4;
3942
3942
  }
3943
3943
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3944
3944
  res2 += tmp !== void 0 ? tmp : "null";
3945
3945
  if (value.length - 1 > maximumBreadth) {
3946
3946
  const removedKeys = value.length - maximumBreadth - 1;
3947
- res2 += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
3947
+ res2 += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
3948
3948
  }
3949
3949
  res2 += `
3950
3950
  ${originalIndentation}`;
@@ -3960,16 +3960,16 @@ ${originalIndentation}`;
3960
3960
  return '"[Object]"';
3961
3961
  }
3962
3962
  indentation += spacer;
3963
- const join2 = `,
3963
+ const join3 = `,
3964
3964
  ${indentation}`;
3965
3965
  let res = "";
3966
3966
  let separator = "";
3967
3967
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3968
3968
  if (isTypedArrayWithEntries(value)) {
3969
- res += stringifyTypedArray(value, join2, maximumBreadth);
3969
+ res += stringifyTypedArray(value, join3, maximumBreadth);
3970
3970
  keys = keys.slice(value.length);
3971
3971
  maximumPropertiesToStringify -= value.length;
3972
- separator = join2;
3972
+ separator = join3;
3973
3973
  }
3974
3974
  if (deterministic) {
3975
3975
  keys = sort(keys, comparator);
@@ -3980,13 +3980,13 @@ ${indentation}`;
3980
3980
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
3981
3981
  if (tmp !== void 0) {
3982
3982
  res += `${separator}${strEscape(key2)}: ${tmp}`;
3983
- separator = join2;
3983
+ separator = join3;
3984
3984
  }
3985
3985
  }
3986
3986
  if (keyLength > maximumBreadth) {
3987
3987
  const removedKeys = keyLength - maximumBreadth;
3988
3988
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
3989
- separator = join2;
3989
+ separator = join3;
3990
3990
  }
3991
3991
  if (separator !== "") {
3992
3992
  res = `
@@ -4515,11 +4515,15 @@ var require_pino = __commonJS({
4515
4515
  // cli/launchd-entry.ts
4516
4516
  var launchd_entry_exports = {};
4517
4517
  __export(launchd_entry_exports, {
4518
- decideShimAction: () => decideShimAction
4518
+ decideShimAction: () => decideShimAction,
4519
+ findApnsKeyFile: () => findApnsKeyFile,
4520
+ loadApnsKeyIntoEnv: () => loadApnsKeyIntoEnv,
4521
+ loadInstallDirEnv: () => loadInstallDirEnv
4519
4522
  });
4520
4523
  module.exports = __toCommonJS(launchd_entry_exports);
4521
4524
  var import_node_child_process = require("child_process");
4522
4525
  var import_node_fs2 = require("fs");
4526
+ var import_node_path3 = require("path");
4523
4527
 
4524
4528
  // src/lifecycle/constants.ts
4525
4529
  var import_node_os = require("os");
@@ -19147,6 +19151,79 @@ function decideShimAction() {
19147
19151
  }
19148
19152
  return { kind: "exit", reason: "dev-alive" };
19149
19153
  }
19154
+ function loadInstallDirEnv(env, dir = installDir()) {
19155
+ const envPath = (0, import_node_path3.join)(dir, ".env");
19156
+ if (!(0, import_node_fs2.existsSync)(envPath)) return;
19157
+ let raw;
19158
+ try {
19159
+ raw = (0, import_node_fs2.readFileSync)(envPath, "utf-8");
19160
+ } catch (err) {
19161
+ log2.warn(`could not read ${envPath}: ${err instanceof Error ? err.message : String(err)}`);
19162
+ return;
19163
+ }
19164
+ const loaded = [];
19165
+ for (const line of raw.split("\n")) {
19166
+ const trimmed = line.trim();
19167
+ if (trimmed.length === 0 || trimmed.startsWith("#")) continue;
19168
+ const eq = trimmed.indexOf("=");
19169
+ if (eq <= 0) continue;
19170
+ const key = trimmed.slice(0, eq).trim();
19171
+ let value = trimmed.slice(eq + 1).trim();
19172
+ if (value.length >= 2 && (value[0] === '"' || value[0] === "'") && value.at(-1) === value[0]) {
19173
+ value = value.slice(1, -1);
19174
+ }
19175
+ if (env[key] !== void 0) continue;
19176
+ env[key] = value;
19177
+ loaded.push(key);
19178
+ }
19179
+ if (loaded.length > 0) {
19180
+ log2.info(`loaded ${loaded.length} env var(s) from ${envPath}: ${loaded.join(", ")}`);
19181
+ }
19182
+ }
19183
+ var APNS_KEY_FILE_PATTERN = /^AuthKey_([A-Z0-9]{10})\.p8$/;
19184
+ function findApnsKeyFile(dir = installDir()) {
19185
+ let entries;
19186
+ try {
19187
+ entries = (0, import_node_fs2.readdirSync)(dir);
19188
+ } catch {
19189
+ return null;
19190
+ }
19191
+ const matches = entries.map((name) => ({ name, m: APNS_KEY_FILE_PATTERN.exec(name) })).filter((e) => e.m !== null).map((e) => {
19192
+ const path = (0, import_node_path3.join)(dir, e.name);
19193
+ let mtimeMs = 0;
19194
+ try {
19195
+ mtimeMs = (0, import_node_fs2.statSync)(path).mtimeMs;
19196
+ } catch {
19197
+ }
19198
+ return { path, keyId: e.m[1], mtimeMs };
19199
+ }).sort((a, b) => b.mtimeMs - a.mtimeMs);
19200
+ if (matches.length === 0) return null;
19201
+ if (matches.length > 1) {
19202
+ log2.warn(
19203
+ `found ${matches.length} APNs key files in ${dir}, using the newest (${matches[0].keyId}); remove the stale ones to make this unambiguous`
19204
+ );
19205
+ }
19206
+ return { path: matches[0].path, keyId: matches[0].keyId };
19207
+ }
19208
+ function loadApnsKeyIntoEnv(env, keyFileDir) {
19209
+ if (env.APNS_KEY) return;
19210
+ const found = findApnsKeyFile(keyFileDir);
19211
+ if (!found) return;
19212
+ try {
19213
+ const pem = (0, import_node_fs2.readFileSync)(found.path, "utf-8").trim();
19214
+ if (pem.length === 0) {
19215
+ log2.warn(`APNs key file is empty, Live Activity push stays disabled: ${found.path}`);
19216
+ return;
19217
+ }
19218
+ env.APNS_KEY = pem;
19219
+ if (!env.APNS_KEY_ID) env.APNS_KEY_ID = found.keyId;
19220
+ log2.info(`loaded APNs key ${found.keyId} for Live Activity push from ${found.path}`);
19221
+ } catch (err) {
19222
+ log2.warn(
19223
+ `could not read APNs key at ${found.path}, Live Activity push stays disabled: ${err instanceof Error ? err.message : String(err)}`
19224
+ );
19225
+ }
19226
+ }
19150
19227
  function main() {
19151
19228
  const action = decideShimAction();
19152
19229
  if (action.kind === "exit") {
@@ -19168,9 +19245,12 @@ function main() {
19168
19245
  process.exit(1);
19169
19246
  }
19170
19247
  const args = process.argv.slice(2);
19248
+ const env = { ...process.env };
19249
+ loadInstallDirEnv(env);
19250
+ loadApnsKeyIntoEnv(env);
19171
19251
  const result = (0, import_node_child_process.spawnSync)(process.execPath, [target, ...args], {
19172
19252
  stdio: "inherit",
19173
- env: process.env
19253
+ env
19174
19254
  });
19175
19255
  if (result.error) {
19176
19256
  log2.error(`failed to spawn ${target}: ${result.error.message}`);
@@ -19183,6 +19263,9 @@ if (typeof require !== "undefined" && require.main === module) {
19183
19263
  }
19184
19264
  // Annotate the CommonJS export names for ESM import in node:
19185
19265
  0 && (module.exports = {
19186
- decideShimAction
19266
+ decideShimAction,
19267
+ findApnsKeyFile,
19268
+ loadApnsKeyIntoEnv,
19269
+ loadInstallDirEnv
19187
19270
  });
19188
19271
  //# sourceMappingURL=launchd-entry.cjs.map