@travetto/runtime 8.0.0-alpha.14 → 8.0.0-alpha.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/runtime",
3
- "version": "8.0.0-alpha.14",
3
+ "version": "8.0.0-alpha.17",
4
4
  "type": "module",
5
5
  "description": "Runtime for travetto applications.",
6
6
  "keywords": [
@@ -26,17 +26,20 @@
26
26
  "directory": "module/runtime"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/manifest": "^8.0.0-alpha.7",
29
+ "@travetto/manifest": "^8.0.0-alpha.8",
30
30
  "@types/debug": "^4.1.13",
31
- "debug": "^4.4.3",
32
- "temporal-polyfill-lite": "^0.3.4"
31
+ "debug": "^4.4.3"
33
32
  },
34
33
  "peerDependencies": {
35
- "@travetto/transformer": "^8.0.0-alpha.10"
34
+ "@travetto/transformer": "^8.0.0-alpha.11",
35
+ "temporal-polyfill-lite": "^0.4.0"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@travetto/transformer": {
39
39
  "optional": true
40
+ },
41
+ "temporal-polyfill-lite": {
42
+ "optional": true
40
43
  }
41
44
  },
42
45
  "travetto": {
package/src/codec.ts CHANGED
@@ -85,7 +85,10 @@ export class CodecUtil {
85
85
  /** Consume lines */
86
86
  static async readLines(stream: BinaryType, handler: (input: string) => unknown | Promise<unknown>): Promise<void> {
87
87
  for await (const item of createInterface(BinaryUtil.toReadable(stream))) {
88
- await handler(item);
88
+ const result = await handler(item);
89
+ if (result === false) {
90
+ break;
91
+ }
89
92
  }
90
93
  }
91
94
 
@@ -102,4 +105,19 @@ export class CodecUtil {
102
105
  return BinaryUtil.isBinaryArray(chunk) ? chunk :
103
106
  Buffer.from(typeof chunk === 'string' ? chunk : `${chunk}`, castTo(encoding ?? 'utf8'));
104
107
  }
108
+
109
+ static readFirstLine(data: string): string;
110
+ static readFirstLine(data: string | undefined, defaultValue: string): string;
111
+ static readFirstLine(data: string | undefined, defaultValue: string = ''): string {
112
+ if (typeof data === 'undefined') {
113
+ return defaultValue;
114
+ } else {
115
+ const end = data.indexOf('\n');
116
+ if (end === -1) {
117
+ return data.trim();
118
+ } else {
119
+ return data.substring(0, end).trim();
120
+ }
121
+ }
122
+ }
105
123
  }
package/src/exec.ts CHANGED
@@ -40,6 +40,18 @@ type ExecutionBaseResult = Omit<ExecutionResult, 'stdout' | 'stderr'>;
40
40
  */
41
41
  export class ExecUtil {
42
42
 
43
+ /** Read stream as string from a result */
44
+ static toString(result: ExecutionResult<BinaryArray | string>, stream: 'stdout' | 'stderr' | 'any'): string {
45
+ if (stream === 'any') {
46
+ return this.toString(result, 'stderr') || this.toString(result, 'stdout');
47
+ }
48
+ const value = result[stream];
49
+ if (typeof value === 'string') {
50
+ return value.trim();
51
+ }
52
+ return CodecUtil.toUTF8String(value).trim();
53
+ }
54
+
43
55
  /**
44
56
  * Take a child process, and some additional options, and produce a promise that
45
57
  * represents the entire execution. On successful completion the promise will resolve, and
package/src/global.d.ts CHANGED
@@ -2,10 +2,6 @@ import './types';
2
2
 
3
3
  declare const write: unique symbol;
4
4
 
5
- declare global {
6
- var devProcessWarningExclusions: ((message: string, category: string) => boolean)[] | undefined;
7
- }
8
-
9
5
  declare global {
10
6
  // https://github.com/microsoft/TypeScript/issues/59012
11
7
  interface WritableStreamDefaultWriter<W = any> {
package/src/types.ts CHANGED
@@ -12,7 +12,6 @@ export type TypedFunction<R = Any, V = unknown> = (this: V, ...args: Any[]) => R
12
12
  export type MethodDescriptor<V = Any, R = Any> = TypedPropertyDescriptor<TypedFunction<R, V>>;
13
13
  export type AsyncMethodDescriptor<V = Any, R = Any> = TypedPropertyDescriptor<TypedFunction<Promise<R>, V>>;
14
14
  export type AsyncIterableMethodDescriptor<V = Any, R = Any> = TypedPropertyDescriptor<TypedFunction<AsyncIterable<R>, V>>;
15
- export type ClassTDecorator<T extends Class = Class> = (target: T) => T | void;
16
15
 
17
16
  export type NumericPrimitive = number | bigint;
18
17
  export type Primitive = NumericPrimitive | boolean | string;
@@ -34,10 +33,17 @@ export type ValidFields<T, I> = {
34
33
 
35
34
  export type RetainIntrinsicFields<T> = Pick<T, ValidFields<T, IntrinsicType>>;
36
35
 
37
- export type ValidTypedFields<T, F> = {
38
- [K in Extract<keyof T, string>]:
39
- (T[K] extends F ? K : never)
40
- }[Extract<keyof T, string>];
36
+ export type KeyPaths<T, PrimitiveType = IntrinsicType | IntrinsicType[], PREFIX extends string = '', SEP extends string = '.'> =
37
+ { [K in keyof T]:
38
+ (K extends string ? (
39
+ (T[K] extends (IntrinsicType[] | IntrinsicType | undefined) ?
40
+ (T[K] extends PrimitiveType ? `${PREFIX}${K}` : never) : (
41
+ (T[K] extends Any[] ?
42
+ KeyPaths<T[K][number], PrimitiveType, `${K}${SEP}`, SEP> :
43
+ (T[K] extends object ? KeyPaths<T[K], PrimitiveType, `${K}${SEP}`, SEP> : never))
44
+ )
45
+ )) : never)
46
+ }[keyof T];
41
47
 
42
48
  export const TypedObject: {
43
49
  keys<T = unknown, K extends keyof T = keyof T & string>(value: T): K[];
package/support/patch.js CHANGED
@@ -1,28 +1,15 @@
1
- import 'temporal-polyfill-lite/global';
2
1
  import fs from 'node:fs/promises';
3
2
 
4
3
  if (process.env.NODE_ENV !== 'production') {
5
4
  process.setSourceMapsEnabled(true); // Ensure source map during compilation/development
6
5
  process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS ?? ''} --enable-source-maps`; // Ensure it passes to children
7
6
  Error.stackTraceLimit = 50;
8
-
9
- const ogEmitWarning = process.emitWarning;
10
- const exclusions = global.devProcessWarningExclusions = [];
11
- process.emitWarning = (message, category, ...other) => {
12
- if (exclusions.length === 0 || !exclusions.some(filter => filter(message, category))) {
13
- return ogEmitWarning(message, category, ...other);
14
- }
15
- };
16
7
  }
17
8
 
18
- const isError = Error.isError.bind(Error);
19
- Object.defineProperty(Error, 'isError', {
20
- value: (input) => isError(input) || (input instanceof Error)
21
- });
22
-
23
9
  // polyfills
24
-
25
- const [majorVersion, minorVersion] = process.version.replace(/^v/, '').split('.').map(text => parseInt(text, 10));
10
+ if (!globalThis.Temporal) { // For anyone that doesn't have it
11
+ void import('temporal-polyfill-lite/global');
12
+ }
26
13
 
27
14
  Map.prototype.getOrInsert ??= function (key, value) {
28
15
  return (this.has(key) || this.set(key, value), this.get(key));
@@ -33,6 +20,7 @@ Map.prototype.getOrInsertComputed ??= function (key, compute) {
33
20
  };
34
21
 
35
22
  // Allow for the throwIfNoEntry if on a version of node that is less than 25.7
23
+ const [majorVersion, minorVersion] = process.version.match(/\d+/g).map(text => parseInt(text, 10));
36
24
  if (majorVersion < 25 || (majorVersion === 25 && minorVersion < 7)) {
37
25
  const og = fs.stat;
38
26
  Object.defineProperty(fs, 'stat', {
@@ -44,4 +32,4 @@ if (majorVersion < 25 || (majorVersion === 25 && minorVersion < 7)) {
44
32
  return out;
45
33
  }
46
34
  });
47
- }
35
+ }