@typeberry/lib 0.1.1-127cc86 → 0.1.1-4a6ffa9

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/index.cjs CHANGED
@@ -18,10 +18,10 @@ var TestSuite;
18
18
  })(TestSuite || (TestSuite = {}));
19
19
  const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
20
20
  const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
21
- const env = typeof process === "undefined" ? {} : process.env;
21
+ const env$1 = typeof process === "undefined" ? {} : process.env;
22
22
  const DEFAULT_VERSION = GpVersion.V0_7_0;
23
- let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
24
- let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
23
+ let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
24
+ let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
25
25
  function parseCurrentVersion(env) {
26
26
  if (env === undefined) {
27
27
  return undefined;
@@ -200,6 +200,33 @@ class WithDebug {
200
200
  }
201
201
  }
202
202
 
203
+ const env = typeof process === "undefined" ? {} : process.env;
204
+ /**
205
+ * The function will produce relative path resolver that is adjusted
206
+ * for package location within the workspace.
207
+ *
208
+ * Example:
209
+ * $ npm start -w @typeberry/jam
210
+ *
211
+ * The above command will run `./bin/jam/index.js`, however we would
212
+ * still want relative paths to be resolved according to top-level workspace
213
+ * directory.
214
+ *
215
+ * So the caller, passes the absolute workspace path as argument and get's
216
+ * a function that can properly resolve relative paths.
217
+ *
218
+ * NOTE: the translation happens only for development build! When
219
+ * we build a single library from our project, we no longer mangle the paths.
220
+ */
221
+ const workspacePathFix = env.NODE_ENV === "development"
222
+ ? (workspacePath) => (p) => {
223
+ if (p.startsWith("/")) {
224
+ return p;
225
+ }
226
+ return `${workspacePath}/${p}`;
227
+ }
228
+ : () => (p) => p;
229
+
203
230
  /**
204
231
  * @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
205
232
  * specified unique token Token. It means that base type cannot be assigned to unique type by accident.
@@ -552,7 +579,8 @@ var index$s = /*#__PURE__*/Object.freeze({
552
579
  isBrowser: isBrowser,
553
580
  measure: measure,
554
581
  resultToString: resultToString,
555
- seeThrough: seeThrough
582
+ seeThrough: seeThrough,
583
+ workspacePathFix: workspacePathFix
556
584
  });
557
585
 
558
586
  /**
package/index.d.ts CHANGED
@@ -12,8 +12,6 @@ declare enum TestSuite {
12
12
  declare const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
13
13
 
14
14
  declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
15
-
16
- declare const env = typeof process === "undefined" ? {} : process.env;
17
15
  declare const DEFAULT_VERSION = GpVersion.V0_7_0;
18
16
  declare let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
19
17
  declare let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
@@ -235,6 +233,33 @@ declare abstract class WithDebug {
235
233
  }
236
234
  }
237
235
 
236
+ /**
237
+ * The function will produce relative path resolver that is adjusted
238
+ * for package location within the workspace.
239
+ *
240
+ * Example:
241
+ * $ npm start -w @typeberry/jam
242
+ *
243
+ * The above command will run `./bin/jam/index.js`, however we would
244
+ * still want relative paths to be resolved according to top-level workspace
245
+ * directory.
246
+ *
247
+ * So the caller, passes the absolute workspace path as argument and get's
248
+ * a function that can properly resolve relative paths.
249
+ *
250
+ * NOTE: the translation happens only for development build! When
251
+ * we build a single library from our project, we no longer mangle the paths.
252
+ */
253
+ declare const workspacePathFix =
254
+ env.NODE_ENV === "development"
255
+ ? (workspacePath: string) => (p: string) => {
256
+ if (p.startsWith("/")) {
257
+ return p;
258
+ }
259
+ return `${workspacePath}/${p}`;
260
+ }
261
+ : () => (p: string) => p;
262
+
238
263
  /**
239
264
  * @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
240
265
  * specified unique token Token. It means that base type cannot be assigned to unique type by accident.
@@ -712,7 +737,6 @@ declare const index$s_assertNever: typeof assertNever;
712
737
  declare const index$s_callCompareFunction: typeof callCompareFunction;
713
738
  declare const index$s_check: typeof check;
714
739
  declare const index$s_deepEqual: typeof deepEqual;
715
- declare const index$s_env: typeof env;
716
740
  declare const index$s_getAllKeysSorted: typeof getAllKeysSorted;
717
741
  declare const index$s_inspect: typeof inspect;
718
742
  declare const index$s_isBrowser: typeof isBrowser;
@@ -726,8 +750,9 @@ declare const index$s_parseCurrentVersion: typeof parseCurrentVersion;
726
750
  declare const index$s_resultToString: typeof resultToString;
727
751
  declare const index$s_seeThrough: typeof seeThrough;
728
752
  declare const index$s_trimStack: typeof trimStack;
753
+ declare const index$s_workspacePathFix: typeof workspacePathFix;
729
754
  declare namespace index$s {
730
- export { index$s_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$s_CURRENT_SUITE as CURRENT_SUITE, index$s_CURRENT_VERSION as CURRENT_VERSION, index$s_Compatibility as Compatibility, index$s_DEFAULT_SUITE as DEFAULT_SUITE, index$s_DEFAULT_VERSION as DEFAULT_VERSION, index$s_ErrorsCollector as ErrorsCollector, index$s_GpVersion as GpVersion, Result$2 as Result, index$s_RichTaggedError as RichTaggedError, index$s_TEST_COMPARE_USING as TEST_COMPARE_USING, index$s_TestSuite as TestSuite, index$s_WithDebug as WithDebug, index$s___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$s_asOpaqueType as asOpaqueType, index$s_assertEmpty as assertEmpty, index$s_assertNever as assertNever, index$s_callCompareFunction as callCompareFunction, index$s_check as check, index$s_deepEqual as deepEqual, index$s_env as env, index$s_getAllKeysSorted as getAllKeysSorted, index$s_inspect as inspect, index$s_isBrowser as isBrowser, index$s_isResult as isResult, index$s_isTaggedError as isTaggedError, index$s_maybeTaggedErrorToString as maybeTaggedErrorToString, index$s_measure as measure, index$s_oomWarningPrinted as oomWarningPrinted, index$s_parseCurrentSuite as parseCurrentSuite, index$s_parseCurrentVersion as parseCurrentVersion, index$s_resultToString as resultToString, index$s_seeThrough as seeThrough, index$s_trimStack as trimStack };
755
+ export { index$s_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$s_CURRENT_SUITE as CURRENT_SUITE, index$s_CURRENT_VERSION as CURRENT_VERSION, index$s_Compatibility as Compatibility, index$s_DEFAULT_SUITE as DEFAULT_SUITE, index$s_DEFAULT_VERSION as DEFAULT_VERSION, index$s_ErrorsCollector as ErrorsCollector, index$s_GpVersion as GpVersion, Result$2 as Result, index$s_RichTaggedError as RichTaggedError, index$s_TEST_COMPARE_USING as TEST_COMPARE_USING, index$s_TestSuite as TestSuite, index$s_WithDebug as WithDebug, index$s___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$s_asOpaqueType as asOpaqueType, index$s_assertEmpty as assertEmpty, index$s_assertNever as assertNever, index$s_callCompareFunction as callCompareFunction, index$s_check as check, index$s_deepEqual as deepEqual, index$s_getAllKeysSorted as getAllKeysSorted, index$s_inspect as inspect, index$s_isBrowser as isBrowser, index$s_isResult as isResult, index$s_isTaggedError as isTaggedError, index$s_maybeTaggedErrorToString as maybeTaggedErrorToString, index$s_measure as measure, index$s_oomWarningPrinted as oomWarningPrinted, index$s_parseCurrentSuite as parseCurrentSuite, index$s_parseCurrentVersion as parseCurrentVersion, index$s_resultToString as resultToString, index$s_seeThrough as seeThrough, index$s_trimStack as trimStack, index$s_workspacePathFix as workspacePathFix };
731
756
  export type { index$s_DeepEqualOptions as DeepEqualOptions, index$s_EnumMapping as EnumMapping, index$s_ErrorResult as ErrorResult, index$s_OK as OK, index$s_OkResult as OkResult, index$s_Opaque as Opaque, index$s_StringLiteral as StringLiteral, index$s_TaggedError as TaggedError, index$s_TokenOf as TokenOf, index$s_Uninstantiable as Uninstantiable, index$s_WithOpaque as WithOpaque };
732
757
  }
733
758
 
package/index.js CHANGED
@@ -15,10 +15,10 @@ var TestSuite;
15
15
  })(TestSuite || (TestSuite = {}));
16
16
  const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
17
17
  const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
18
- const env = typeof process === "undefined" ? {} : process.env;
18
+ const env$1 = typeof process === "undefined" ? {} : process.env;
19
19
  const DEFAULT_VERSION = GpVersion.V0_7_0;
20
- let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
21
- let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
20
+ let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
21
+ let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
22
22
  function parseCurrentVersion(env) {
23
23
  if (env === undefined) {
24
24
  return undefined;
@@ -197,6 +197,33 @@ class WithDebug {
197
197
  }
198
198
  }
199
199
 
200
+ const env = typeof process === "undefined" ? {} : process.env;
201
+ /**
202
+ * The function will produce relative path resolver that is adjusted
203
+ * for package location within the workspace.
204
+ *
205
+ * Example:
206
+ * $ npm start -w @typeberry/jam
207
+ *
208
+ * The above command will run `./bin/jam/index.js`, however we would
209
+ * still want relative paths to be resolved according to top-level workspace
210
+ * directory.
211
+ *
212
+ * So the caller, passes the absolute workspace path as argument and get's
213
+ * a function that can properly resolve relative paths.
214
+ *
215
+ * NOTE: the translation happens only for development build! When
216
+ * we build a single library from our project, we no longer mangle the paths.
217
+ */
218
+ const workspacePathFix = env.NODE_ENV === "development"
219
+ ? (workspacePath) => (p) => {
220
+ if (p.startsWith("/")) {
221
+ return p;
222
+ }
223
+ return `${workspacePath}/${p}`;
224
+ }
225
+ : () => (p) => p;
226
+
200
227
  /**
201
228
  * @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
202
229
  * specified unique token Token. It means that base type cannot be assigned to unique type by accident.
@@ -549,7 +576,8 @@ var index$s = /*#__PURE__*/Object.freeze({
549
576
  isBrowser: isBrowser,
550
577
  measure: measure,
551
578
  resultToString: resultToString,
552
- seeThrough: seeThrough
579
+ seeThrough: seeThrough,
580
+ workspacePathFix: workspacePathFix
553
581
  });
554
582
 
555
583
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeberry/lib",
3
- "version": "0.1.1-127cc86",
3
+ "version": "0.1.1-4a6ffa9",
4
4
  "main": "index.js",
5
5
  "author": "Fluffy Labs",
6
6
  "license": "MPL-2.0",