effect-errors 1.4.12 → 1.5.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.
Files changed (95) hide show
  1. package/README.md +1 -1
  2. package/cjs/capture-errors.js +6 -54
  3. package/cjs/capture-errors.js.map +1 -1
  4. package/cjs/index.js +11 -0
  5. package/cjs/index.js.map +1 -1
  6. package/cjs/logic/effects/fs/fs-error.js +10 -0
  7. package/cjs/logic/effects/fs/fs-error.js.map +1 -0
  8. package/cjs/logic/effects/fs/fs-extra.effects.js +50 -0
  9. package/cjs/logic/effects/fs/fs-extra.effects.js.map +1 -0
  10. package/cjs/logic/stack/stack-regex.js +2 -3
  11. package/cjs/logic/stack/stack-regex.js.map +1 -1
  12. package/cjs/logic/util/big-int-replacer.js +17 -0
  13. package/cjs/logic/util/big-int-replacer.js.map +1 -0
  14. package/cjs/source-maps/get-error-location-from-file-path.js +23 -0
  15. package/cjs/source-maps/get-error-location-from-file-path.js.map +1 -0
  16. package/cjs/source-maps/get-error-related-sources.js +33 -0
  17. package/cjs/source-maps/get-error-related-sources.js.map +1 -0
  18. package/cjs/source-maps/get-source-code.js +28 -0
  19. package/cjs/source-maps/get-source-code.js.map +1 -0
  20. package/cjs/source-maps/get-sources-from-map-file.js +50 -0
  21. package/cjs/source-maps/get-sources-from-map-file.js.map +1 -0
  22. package/cjs/source-maps/maybe-map-sourcemaps.js +13 -10
  23. package/cjs/source-maps/maybe-map-sourcemaps.js.map +1 -1
  24. package/cjs/source-maps/transform-raw-error.js +60 -0
  25. package/cjs/source-maps/transform-raw-error.js.map +1 -0
  26. package/dts/capture-errors.d.ts +5 -3
  27. package/dts/capture-errors.d.ts.map +1 -1
  28. package/dts/index.d.ts +2 -1
  29. package/dts/index.d.ts.map +1 -1
  30. package/dts/logic/effects/fs/fs-error.d.ts +10 -0
  31. package/dts/logic/effects/fs/fs-error.d.ts.map +1 -0
  32. package/dts/logic/effects/fs/fs-extra.effects.d.ts +6 -0
  33. package/dts/logic/effects/fs/fs-extra.effects.d.ts.map +1 -0
  34. package/dts/logic/stack/stack-regex.d.ts +1 -2
  35. package/dts/logic/stack/stack-regex.d.ts.map +1 -1
  36. package/dts/logic/util/big-int-replacer.d.ts +2 -0
  37. package/dts/logic/util/big-int-replacer.d.ts.map +1 -0
  38. package/dts/source-maps/get-error-location-from-file-path.d.ts +7 -0
  39. package/dts/source-maps/get-error-location-from-file-path.d.ts.map +1 -0
  40. package/dts/source-maps/get-error-related-sources.d.ts +5 -0
  41. package/dts/source-maps/get-error-related-sources.d.ts.map +1 -0
  42. package/dts/source-maps/get-source-code.d.ts +10 -0
  43. package/dts/source-maps/get-source-code.d.ts.map +1 -0
  44. package/dts/source-maps/get-sources-from-map-file.d.ts +11 -0
  45. package/dts/source-maps/get-sources-from-map-file.d.ts.map +1 -0
  46. package/dts/source-maps/maybe-map-sourcemaps.d.ts +4 -2
  47. package/dts/source-maps/maybe-map-sourcemaps.d.ts.map +1 -1
  48. package/dts/source-maps/transform-raw-error.d.ts +17 -0
  49. package/dts/source-maps/transform-raw-error.d.ts.map +1 -0
  50. package/dts/types/pretty-error.type.d.ts +2 -2
  51. package/dts/types/pretty-error.type.d.ts.map +1 -1
  52. package/esm/capture-errors.js +7 -55
  53. package/esm/capture-errors.js.map +1 -1
  54. package/esm/index.js +1 -0
  55. package/esm/index.js.map +1 -1
  56. package/esm/logic/effects/fs/fs-error.js +3 -0
  57. package/esm/logic/effects/fs/fs-error.js.map +1 -0
  58. package/esm/logic/effects/fs/fs-extra.effects.js +36 -0
  59. package/esm/logic/effects/fs/fs-extra.effects.js.map +1 -0
  60. package/esm/logic/stack/stack-regex.js +1 -2
  61. package/esm/logic/stack/stack-regex.js.map +1 -1
  62. package/esm/logic/util/big-int-replacer.js +10 -0
  63. package/esm/logic/util/big-int-replacer.js.map +1 -0
  64. package/esm/source-maps/get-error-location-from-file-path.js +16 -0
  65. package/esm/source-maps/get-error-location-from-file-path.js.map +1 -0
  66. package/esm/source-maps/get-error-related-sources.js +26 -0
  67. package/esm/source-maps/get-error-related-sources.js.map +1 -0
  68. package/esm/source-maps/get-source-code.js +21 -0
  69. package/esm/source-maps/get-source-code.js.map +1 -0
  70. package/esm/source-maps/get-sources-from-map-file.js +38 -0
  71. package/esm/source-maps/get-sources-from-map-file.js.map +1 -0
  72. package/esm/source-maps/maybe-map-sourcemaps.js +14 -11
  73. package/esm/source-maps/maybe-map-sourcemaps.js.map +1 -1
  74. package/esm/source-maps/transform-raw-error.js +53 -0
  75. package/esm/source-maps/transform-raw-error.js.map +1 -0
  76. package/package.json +32 -28
  77. package/cjs/source-maps/get-source-excerpt.js +0 -46
  78. package/cjs/source-maps/get-source-excerpt.js.map +0 -1
  79. package/cjs/source-maps/get-ts-code-from-sourcemap.js +0 -58
  80. package/cjs/source-maps/get-ts-code-from-sourcemap.js.map +0 -1
  81. package/cjs/source-maps/insert-into.js +0 -9
  82. package/cjs/source-maps/insert-into.js.map +0 -1
  83. package/dts/source-maps/get-source-excerpt.d.ts +0 -2
  84. package/dts/source-maps/get-source-excerpt.d.ts.map +0 -1
  85. package/dts/source-maps/get-ts-code-from-sourcemap.d.ts +0 -6
  86. package/dts/source-maps/get-ts-code-from-sourcemap.d.ts.map +0 -1
  87. package/dts/source-maps/insert-into.d.ts +0 -2
  88. package/dts/source-maps/insert-into.d.ts.map +0 -1
  89. package/esm/source-maps/get-source-excerpt.js +0 -34
  90. package/esm/source-maps/get-source-excerpt.js.map +0 -1
  91. package/esm/source-maps/get-ts-code-from-sourcemap.js +0 -46
  92. package/esm/source-maps/get-ts-code-from-sourcemap.js.map +0 -1
  93. package/esm/source-maps/insert-into.js +0 -2
  94. package/esm/source-maps/insert-into.js.map +0 -1
  95. package/package.json.bak +0 -94
package/package.json CHANGED
@@ -1,19 +1,23 @@
1
1
  {
2
2
  "repository": "https://github.com/jpb06/effect-errors.git",
3
+ "type": "module",
3
4
  "main": "./cjs/index.js",
4
5
  "module": "./esm/index.js",
5
6
  "types": "./dts/index.d.ts",
6
7
  "exports": {
7
8
  ".": {
8
- "import": {
9
- "types": "./dts/index.d.ts",
10
- "default": "./esm/index.js"
9
+ "require": {
10
+ "default": "./cjs/index.js",
11
+ "types": "./dts/index.d.ts"
11
12
  },
12
- "require": "./cjs/index.js"
13
+ "import": {
14
+ "default": "./esm/index.js",
15
+ "types": "./dts/index.d.ts"
16
+ }
13
17
  }
14
18
  },
15
19
  "name": "effect-errors",
16
- "version": "1.4.12",
20
+ "version": "1.5.0",
17
21
  "author": "jpb06 <jp.bois.06@outlook.fr>",
18
22
  "description": "A POC for errors reporting in Effect",
19
23
  "keywords": [
@@ -26,13 +30,12 @@
26
30
  "scripts": {
27
31
  "update-deps": "bunx npm-check-updates --root --format group -i",
28
32
  "copy-package": "copyfiles package.json ./dist/",
29
- "remove-type-module-from-package": "sed -i.bak '/\"type\": \"module\"/d' ./dist/package.json",
30
33
  "copy-readme": "copyfiles README.md ./dist/",
31
34
  "build": "del-cli ./dist && bun build-esm && bun build-cjs && bun build-annotate",
32
35
  "build-esm": "tsc -b tsconfig-prod.json",
33
36
  "build-cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
34
37
  "build-annotate": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
35
- "postbuild": "bun run copy-package && bun run copy-readme && bun run remove-type-module-from-package",
38
+ "postbuild": "bun run copy-package && bun run copy-readme",
36
39
  "lint": "eslint ./src",
37
40
  "type-check": "tsc --noEmit",
38
41
  "test": "vitest",
@@ -42,42 +45,43 @@
42
45
  "sync-icons": "bun generateReadmeIcons -h 50",
43
46
  "run-example-tsx": "tsx ./src/examples/util/run",
44
47
  "run-example": "bun run ./src/examples/util/run",
45
- "run-examples": "bun run ./src/examples/util/run-all"
48
+ "run-examples": "bun run ./src/examples/util/run-all",
49
+ "bundle-example": "bun esbuild --bundle --platform=node --format=esm --sourcemap=external --minify --inject:./src/examples/bundling/cjs-shims.ts --outfile=./src/tests/bundle/from-promise.js ./src/examples/bundling/from-promise.bundle.ts"
46
50
  },
47
51
  "dependencies": {
48
- "@effect/schema": "^0.68.23",
52
+ "@effect/schema": "^0.69.2",
49
53
  "chalk": "<5",
50
- "convert-source-map": "^2.0.0",
51
- "effect": "^3.5.3",
52
- "source-map": "^0.7.4"
54
+ "effect": "^3.5.8",
55
+ "source-map-js": "^1.2.0"
53
56
  },
54
57
  "devDependencies": {
55
58
  "@babel/cli": "^7.24.8",
56
- "@babel/core": "^7.24.8",
59
+ "@babel/core": "^7.24.9",
57
60
  "@babel/plugin-transform-export-namespace-from": "^7.24.7",
58
61
  "@babel/plugin-transform-modules-commonjs": "^7.24.8",
59
62
  "@eslint/eslintrc": "^3.1.0",
60
- "@eslint/js": "^9.7.0",
61
- "@stylistic/eslint-plugin": "^2.3.0",
62
- "@stylistic/eslint-plugin-ts": "^2.3.0",
63
+ "@eslint/js": "^9.8.0",
64
+ "@stylistic/eslint-plugin": "^2.4.0",
65
+ "@stylistic/eslint-plugin-ts": "^2.4.0",
63
66
  "@types/eslint": "^8.56.10",
64
67
  "@types/fs-extra": "^11.0.4",
65
- "@types/node": "^20.14.10",
66
- "@typescript-eslint/eslint-plugin": "^7.16.0",
67
- "@typescript-eslint/parser": "^7.16.0",
68
- "@vitest/coverage-v8": "^1.6.0",
68
+ "@types/node": "^20.14.12",
69
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
70
+ "@typescript-eslint/parser": "^7.17.0",
71
+ "@vitest/coverage-v8": "^2.0.4",
69
72
  "babel-plugin-annotate-pure-calls": "^0.4.0",
70
73
  "copyfiles": "^2.4.1",
71
74
  "del-cli": "^5.1.0",
72
- "eslint": "^9.7.0",
75
+ "eslint": "^9.8.0",
76
+ "esbuild": "^0.23.0",
73
77
  "eslint-config-prettier": "^9.1.0",
74
78
  "eslint-config-standard-with-typescript": "^43.0.1",
75
79
  "eslint-import-resolver-typescript": "^3.6.1",
76
80
  "eslint-plugin-import": "^2.29.1",
77
81
  "eslint-plugin-markdown": "^5.1.0",
78
- "eslint-plugin-n": "^17.9.0",
79
- "eslint-plugin-prettier": "^5.1.3",
80
- "eslint-plugin-promise": "^6.4.0",
82
+ "eslint-plugin-n": "^17.10.1",
83
+ "eslint-plugin-prettier": "^5.2.1",
84
+ "eslint-plugin-promise": "^7.0.0",
81
85
  "eslint-plugin-vitest": "^0.5.4",
82
86
  "fs-extra": "^11.2.0",
83
87
  "globals": "^15.8.0",
@@ -85,9 +89,9 @@
85
89
  "readme-package-icons": "^1.1.14",
86
90
  "ts-node": "^10.9.2",
87
91
  "tsx": "^4.16.2",
88
- "typescript": "^5.5.3",
89
- "typescript-eslint": "^7.16.0",
90
- "vitest": "^1.6.0",
91
- "vitest-mock-extended": "^1.3.1"
92
+ "typescript": "^5.5.4",
93
+ "typescript-eslint": "^7.17.0",
94
+ "vitest": "^2.0.4",
95
+ "vitest-mock-extended": "^2.0.0"
92
96
  }
93
97
  }
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSourceExcerpt = void 0;
7
- var _fsExtra = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("fs-extra"));
8
- var _insertInto = /*#__PURE__*/require("./insert-into.js");
9
- function _interopRequireDefault(e) {
10
- return e && e.__esModule ? e : {
11
- default: e
12
- };
13
- }
14
- // const whitePipe = chalk.whiteBright('|');
15
- const getSourceExcerpt = async (tsFileAbsolutePath, tsLine, tsColumn) => {
16
- const sourceCode = await _fsExtra.default.readFile(tsFileAbsolutePath, {
17
- encoding: 'utf-8'
18
- });
19
- const sourceCodeByLine = sourceCode.split('\n');
20
- const start = tsLine >= 4 ? tsLine - 4 : 0;
21
- const end = tsLine + 4 > sourceCodeByLine.length ? sourceCodeByLine.length : tsLine + 4;
22
- return sourceCodeByLine.splice(start, 7).map((line, index) => {
23
- const currentLine = index + start + 1;
24
- const lineNumber = `${currentLine}`.padStart(`${end}`.length, '0');
25
- const code = currentLine === tsLine ? (0, _insertInto.insertInto)(line, '|', tsColumn === 0 ? 0 : tsColumn - 1, 0) : line;
26
- return `${lineNumber} ${code}`;
27
- }).join('\n');
28
- // return sourceCodeByLine
29
- // .splice(start, 7)
30
- // .map((line, index) => {
31
- // const currentLine = index + start + 1;
32
- // const lineNumber = chalk.white(
33
- // `${currentLine}`.padStart(`${end}`.length, '0'),
34
- // );
35
- // const code =
36
- // currentLine === tsLine
37
- // ? chalk.redBright(
38
- // insertInto(line, whitePipe, tsColumn === 0 ? 0 : tsColumn - 1, 0),
39
- // )
40
- // : chalk.gray(line);
41
- // return `${lineNumber} ${code}`;
42
- // })
43
- // .join('\n');
44
- };
45
- exports.getSourceExcerpt = getSourceExcerpt;
46
- //# sourceMappingURL=get-source-excerpt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-source-excerpt.js","names":["_fsExtra","_interopRequireDefault","require","_insertInto","e","__esModule","default","getSourceExcerpt","tsFileAbsolutePath","tsLine","tsColumn","sourceCode","readFile","encoding","sourceCodeByLine","split","start","end","length","splice","map","line","index","currentLine","lineNumber","padStart","code","insertInto","join","exports"],"sources":["../../../src/source-maps/get-source-excerpt.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,QAAA,gBAAAC,sBAAA,eAAAC,OAAA;AAEA,IAAAC,WAAA,gBAAAD,OAAA;AAA8C,SAAAD,uBAAAG,CAAA;EAAA,OAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA;IAAAE,OAAA,EAAAF;EAAA;AAAA;AAE9C;AAEO,MAAMG,gBAAgB,GAAG,MAAAA,CAC9BC,kBAA0B,EAC1BC,MAAc,EACdC,QAAgB,KACd;EACF,MAAMC,UAAU,GAAG,MAAMX,QAAA,CAAAM,OAAE,CAACM,QAAQ,CAACJ,kBAAkB,EAAE;IACvDK,QAAQ,EAAE;GACX,CAAC;EACF,MAAMC,gBAAgB,GAAGH,UAAU,CAACI,KAAK,CAAC,IAAI,CAAC;EAE/C,MAAMC,KAAK,GAAGP,MAAM,IAAI,CAAC,GAAGA,MAAM,GAAG,CAAC,GAAG,CAAC;EAC1C,MAAMQ,GAAG,GACPR,MAAM,GAAG,CAAC,GAAGK,gBAAgB,CAACI,MAAM,GAAGJ,gBAAgB,CAACI,MAAM,GAAGT,MAAM,GAAG,CAAC;EAE7E,OAAOK,gBAAgB,CACpBK,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC,CAChBI,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAI;IACnB,MAAMC,WAAW,GAAGD,KAAK,GAAGN,KAAK,GAAG,CAAC;IACrC,MAAMQ,UAAU,GAAG,GAAGD,WAAW,EAAE,CAACE,QAAQ,CAAC,GAAGR,GAAG,EAAE,CAACC,MAAM,EAAE,GAAG,CAAC;IAClE,MAAMQ,IAAI,GACRH,WAAW,KAAKd,MAAM,GAClB,IAAAN,WAAA,CAAAwB,UAAU,EAACN,IAAI,EAAE,GAAG,EAAEX,QAAQ,KAAK,CAAC,GAAG,CAAC,GAAGA,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,GAC3DW,IAAI;IAEV,OAAO,GAAGG,UAAU,IAAIE,IAAI,EAAE;EAChC,CAAC,CAAC,CACDE,IAAI,CAAC,IAAI,CAAC;EAEb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;AACF,CAAC;AAACC,OAAA,CAAAtB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getTsCodeFromSourcemap = void 0;
7
- var _path = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("path"));
8
- var _chalk = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("chalk"));
9
- var _fsExtra = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("fs-extra"));
10
- var _sourceMap = /*#__PURE__*/require("source-map");
11
- var _getSourceExcerpt = /*#__PURE__*/require("./get-source-excerpt.js");
12
- function _interopRequireDefault(e) {
13
- return e && e.__esModule ? e : {
14
- default: e
15
- };
16
- }
17
- const sourceFileRegex = /^(file:\/\/)?(.*.(j|t)s)(\?.*)?:(\d*):(\d*)$/;
18
- const getTsCodeFromSourcemap = async sourceFile => {
19
- const regex = sourceFileRegex.exec(sourceFile);
20
- if (regex === null || regex.length !== 7) {
21
- return;
22
- }
23
- const filePath = regex[2];
24
- const line = +regex[5];
25
- const column = +regex[6];
26
- if (filePath.endsWith('.ts')) {
27
- const codeExcerpt = await (0, _getSourceExcerpt.getSourceExcerpt)(filePath, line, column);
28
- return {
29
- file: `${filePath}:${line}:${column}`,
30
- codeExcerpt
31
- };
32
- }
33
- const fileExists = await _fsExtra.default.exists(`${filePath}.map`);
34
- if (!fileExists) {
35
- console.warn(`${_chalk.default.blueBright.underline('effect-errors')}: ${_chalk.default.yellow(`${filePath}.map does not exist: unable to retrieve spans sourcemaps.`)} `);
36
- return;
37
- }
38
- const data = await _fsExtra.default.readFile(`${filePath}.map`, {
39
- encoding: 'utf-8'
40
- });
41
- return await _sourceMap.SourceMapConsumer.with(data, null, async consumer => {
42
- const tsCode = consumer.originalPositionFor({
43
- line,
44
- column
45
- });
46
- if (tsCode.source === null || tsCode.line === null || tsCode.column === null) {
47
- return;
48
- }
49
- const tsFileAbsolutePath = _path.default.resolve(filePath.substring(0, filePath.lastIndexOf('/')), tsCode.source);
50
- const codeExcerpt = await (0, _getSourceExcerpt.getSourceExcerpt)(tsFileAbsolutePath, tsCode.line, tsCode.column);
51
- return {
52
- file: `${tsFileAbsolutePath}:${tsCode.line}:${tsCode.column}`,
53
- codeExcerpt
54
- };
55
- });
56
- };
57
- exports.getTsCodeFromSourcemap = getTsCodeFromSourcemap;
58
- //# sourceMappingURL=get-ts-code-from-sourcemap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-ts-code-from-sourcemap.js","names":["_path","_interopRequireDefault","require","_chalk","_fsExtra","_sourceMap","_getSourceExcerpt","e","__esModule","default","sourceFileRegex","getTsCodeFromSourcemap","sourceFile","regex","exec","length","filePath","line","column","endsWith","codeExcerpt","getSourceExcerpt","file","fileExists","exists","console","warn","blueBright","underline","yellow","data","readFile","encoding","SourceMapConsumer","with","consumer","tsCode","originalPositionFor","source","tsFileAbsolutePath","resolve","substring","lastIndexOf","exports"],"sources":["../../../src/source-maps/get-ts-code-from-sourcemap.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,KAAA,gBAAAC,sBAAA,eAAAC,OAAA;AAEA,IAAAC,MAAA,gBAAAF,sBAAA,eAAAC,OAAA;AACA,IAAAE,QAAA,gBAAAH,sBAAA,eAAAC,OAAA;AACA,IAAAG,UAAA,gBAAAH,OAAA;AAEA,IAAAI,iBAAA,gBAAAJ,OAAA;AAA2D,SAAAD,uBAAAM,CAAA;EAAA,OAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA;IAAAE,OAAA,EAAAF;EAAA;AAAA;AAE3D,MAAMG,eAAe,GAAG,8CAA8C;AAO/D,MAAMC,sBAAsB,GAAG,MACpCC,UAAkB,IACyB;EAC3C,MAAMC,KAAK,GAAGH,eAAe,CAACI,IAAI,CAACF,UAAU,CAAC;EAC9C,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACxC;EACF;EAEA,MAAMC,QAAQ,GAAGH,KAAK,CAAC,CAAC,CAAC;EACzB,MAAMI,IAAI,GAAG,CAACJ,KAAK,CAAC,CAAC,CAAC;EACtB,MAAMK,MAAM,GAAG,CAACL,KAAK,CAAC,CAAC,CAAC;EAExB,IAAIG,QAAQ,CAACG,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC5B,MAAMC,WAAW,GAAG,MAAM,IAAAd,iBAAA,CAAAe,gBAAgB,EAACL,QAAQ,EAAEC,IAAI,EAAEC,MAA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AAO;MACLI,IAAI,EAAE,GAAGiB,kBAAkB,IAAIH,MAAM,CAACnB,IAAI,IAAImB,MAAM,CAAClB,MAAM,EAAE;MAC7DE;KACD;EACH,CAAC,CAAC;AACJ,CAAC;AAACuB,OAAA,CAAAhC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.insertInto = void 0;
7
- const insertInto = (input, data, start, delCount) => input.slice(0, start) + data + input.slice(start + Math.abs(delCount));
8
- exports.insertInto = insertInto;
9
- //# sourceMappingURL=insert-into.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert-into.js","names":["insertInto","input","data","start","delCount","slice","Math","abs","exports"],"sources":["../../../src/source-maps/insert-into.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAO,MAAMA,UAAU,GAAGA,CACxBC,KAAa,EACbC,IAAY,EACZC,KAAa,EACbC,QAAgB,KACbH,KAAK,CAACI,KAAK,CAAC,CAAC,EAAEF,KAAK,CAAC,GAAGD,IAAI,GAAGD,KAAK,CAACI,KAAK,CAACF,KAAK,GAAGG,IAAI,CAACC,GAAG,CAACH,QAAQ,CAAC,CAAC;AAACI,OAAA,CAAAR,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export declare const getSourceExcerpt: (tsFileAbsolutePath: string, tsLine: number, tsColumn: number) => Promise<string>;
2
- //# sourceMappingURL=get-source-excerpt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-source-excerpt.d.ts","sourceRoot":"","sources":["../../../src/source-maps/get-source-excerpt.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,uBACP,MAAM,UAClB,MAAM,YACJ,MAAM,oBA0CjB,CAAC"}
@@ -1,6 +0,0 @@
1
- export interface TsCodeErrorDetails {
2
- codeExcerpt: string | undefined;
3
- file: string;
4
- }
5
- export declare const getTsCodeFromSourcemap: (sourceFile: string) => Promise<TsCodeErrorDetails | undefined>;
6
- //# sourceMappingURL=get-ts-code-from-sourcemap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-ts-code-from-sourcemap.d.ts","sourceRoot":"","sources":["../../../src/source-maps/get-ts-code-from-sourcemap.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,sBAAsB,eACrB,MAAM,KACjB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAyDxC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const insertInto: (input: string, data: string, start: number, delCount: number) => string;
2
- //# sourceMappingURL=insert-into.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert-into.d.ts","sourceRoot":"","sources":["../../../src/source-maps/insert-into.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,UACd,MAAM,QACP,MAAM,SACL,MAAM,YACH,MAAM,WACyD,CAAC"}
@@ -1,34 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { insertInto } from './insert-into.js';
3
- // const whitePipe = chalk.whiteBright('|');
4
- export const getSourceExcerpt = async (tsFileAbsolutePath, tsLine, tsColumn) => {
5
- const sourceCode = await fs.readFile(tsFileAbsolutePath, {
6
- encoding: 'utf-8'
7
- });
8
- const sourceCodeByLine = sourceCode.split('\n');
9
- const start = tsLine >= 4 ? tsLine - 4 : 0;
10
- const end = tsLine + 4 > sourceCodeByLine.length ? sourceCodeByLine.length : tsLine + 4;
11
- return sourceCodeByLine.splice(start, 7).map((line, index) => {
12
- const currentLine = index + start + 1;
13
- const lineNumber = `${currentLine}`.padStart(`${end}`.length, '0');
14
- const code = currentLine === tsLine ? insertInto(line, '|', tsColumn === 0 ? 0 : tsColumn - 1, 0) : line;
15
- return `${lineNumber} ${code}`;
16
- }).join('\n');
17
- // return sourceCodeByLine
18
- // .splice(start, 7)
19
- // .map((line, index) => {
20
- // const currentLine = index + start + 1;
21
- // const lineNumber = chalk.white(
22
- // `${currentLine}`.padStart(`${end}`.length, '0'),
23
- // );
24
- // const code =
25
- // currentLine === tsLine
26
- // ? chalk.redBright(
27
- // insertInto(line, whitePipe, tsColumn === 0 ? 0 : tsColumn - 1, 0),
28
- // )
29
- // : chalk.gray(line);
30
- // return `${lineNumber} ${code}`;
31
- // })
32
- // .join('\n');
33
- };
34
- //# sourceMappingURL=get-source-excerpt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-source-excerpt.js","names":["fs","insertInto","getSourceExcerpt","tsFileAbsolutePath","tsLine","tsColumn","sourceCode","readFile","encoding","sourceCodeByLine","split","start","end","length","splice","map","line","index","currentLine","lineNumber","padStart","code","join"],"sources":["../../../src/source-maps/get-source-excerpt.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,EAAE,MAAM,UAAU;AAEzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C;AAEA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,kBAA0B,EAC1BC,MAAc,EACdC,QAAgB,KACd;EACF,MAAMC,UAAU,GAAG,MAAMN,EAAE,CAACO,QAAQ,CAACJ,kBAAkB,EAAE;IACvDK,QAAQ,EAAE;GACX,CAAC;EACF,MAAMC,gBAAgB,GAAGH,UAAU,CAACI,KAAK,CAAC,IAAI,CAAC;EAE/C,MAAMC,KAAK,GAAGP,MAAM,IAAI,CAAC,GAAGA,MAAM,GAAG,CAAC,GAAG,CAAC;EAC1C,MAAMQ,GAAG,GACPR,MAAM,GAAG,CAAC,GAAGK,gBAAgB,CAACI,MAAM,GAAGJ,gBAAgB,CAACI,MAAM,GAAGT,MAAM,GAAG,CAAC;EAE7E,OAAOK,gBAAgB,CACpBK,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC,CAChBI,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAI;IACnB,MAAMC,WAAW,GAAGD,KAAK,GAAGN,KAAK,GAAG,CAAC;IACrC,MAAMQ,UAAU,GAAG,GAAGD,WAAW,EAAE,CAACE,QAAQ,CAAC,GAAGR,GAAG,EAAE,CAACC,MAAM,EAAE,GAAG,CAAC;IAClE,MAAMQ,IAAI,GACRH,WAAW,KAAKd,MAAM,GAClBH,UAAU,CAACe,IAAI,EAAE,GAAG,EAAEX,QAAQ,KAAK,CAAC,GAAG,CAAC,GAAGA,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,GAC3DW,IAAI;IAEV,OAAO,GAAGG,UAAU,IAAIE,IAAI,EAAE;EAChC,CAAC,CAAC,CACDC,IAAI,CAAC,IAAI,CAAC;EAEb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;AACF,CAAC","ignoreList":[]}
@@ -1,46 +0,0 @@
1
- import path from 'path';
2
- import chalk from 'chalk';
3
- import fs from 'fs-extra';
4
- import { SourceMapConsumer } from 'source-map';
5
- import { getSourceExcerpt } from './get-source-excerpt.js';
6
- const sourceFileRegex = /^(file:\/\/)?(.*.(j|t)s)(\?.*)?:(\d*):(\d*)$/;
7
- export const getTsCodeFromSourcemap = async sourceFile => {
8
- const regex = sourceFileRegex.exec(sourceFile);
9
- if (regex === null || regex.length !== 7) {
10
- return;
11
- }
12
- const filePath = regex[2];
13
- const line = +regex[5];
14
- const column = +regex[6];
15
- if (filePath.endsWith('.ts')) {
16
- const codeExcerpt = await getSourceExcerpt(filePath, line, column);
17
- return {
18
- file: `${filePath}:${line}:${column}`,
19
- codeExcerpt
20
- };
21
- }
22
- const fileExists = await fs.exists(`${filePath}.map`);
23
- if (!fileExists) {
24
- console.warn(`${chalk.blueBright.underline('effect-errors')}: ${chalk.yellow(`${filePath}.map does not exist: unable to retrieve spans sourcemaps.`)} `);
25
- return;
26
- }
27
- const data = await fs.readFile(`${filePath}.map`, {
28
- encoding: 'utf-8'
29
- });
30
- return await SourceMapConsumer.with(data, null, async consumer => {
31
- const tsCode = consumer.originalPositionFor({
32
- line,
33
- column
34
- });
35
- if (tsCode.source === null || tsCode.line === null || tsCode.column === null) {
36
- return;
37
- }
38
- const tsFileAbsolutePath = path.resolve(filePath.substring(0, filePath.lastIndexOf('/')), tsCode.source);
39
- const codeExcerpt = await getSourceExcerpt(tsFileAbsolutePath, tsCode.line, tsCode.column);
40
- return {
41
- file: `${tsFileAbsolutePath}:${tsCode.line}:${tsCode.column}`,
42
- codeExcerpt
43
- };
44
- });
45
- };
46
- //# sourceMappingURL=get-ts-code-from-sourcemap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-ts-code-from-sourcemap.js","names":["path","chalk","fs","SourceMapConsumer","getSourceExcerpt","sourceFileRegex","getTsCodeFromSourcemap","sourceFile","regex","exec","length","filePath","line","column","endsWith","codeExcerpt","file","fileExists","exists","console","warn","blueBright","underline","yellow","data","readFile","encoding","with","consumer","tsCode","originalPositionFor","source","tsFileAbsolutePath","resolve","substring","lastIndexOf"],"sources":["../../../src/source-maps/get-ts-code-from-sourcemap.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,EAAE,MAAM,UAAU;AACzB,SAASC,iBAAiB,QAAQ,YAAY;AAE9C,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,MAAMC,eAAe,GAAG,8CAA8C;AAOtE,OAAO,MAAMC,sBAAsB,GAAG,MACpCC,UAAkB,IACyB;EAC3C,MAAMC,KAAK,GAAGH,eAAe,CAACI,IAAI,CAACF,UAAU,CAAC;EAC9C,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACxC;EACF;EAEA,MAAMC,QAAQ,GAAGH,KAAK,CAAC,CAAC,CAAC;EACzB,MAAMI,IAAI,GAAG,CAACJ,KAAK,CAAC,CAAC,CAAC;EACtB,MAAMK,MAAM,GAAG,CAACL,KAA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,CAACjB,IAAI,EACXiB,MAAM,CAAChB,MAAM,CACd;IAED,OAAO;MACLG,IAAI,EAAE,GAAGgB,kBAAkB,IAAIH,MAAM,CAACjB,IAAI,IAAIiB,MAAM,CAAChB,MAAM,EAAE;MAC7DE;KACD;EACH,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export const insertInto = (input, data, start, delCount) => input.slice(0, start) + data + input.slice(start + Math.abs(delCount));
2
- //# sourceMappingURL=insert-into.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert-into.js","names":["insertInto","input","data","start","delCount","slice","Math","abs"],"sources":["../../../src/source-maps/insert-into.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAGA,CACxBC,KAAa,EACbC,IAAY,EACZC,KAAa,EACbC,QAAgB,KACbH,KAAK,CAACI,KAAK,CAAC,CAAC,EAAEF,KAAK,CAAC,GAAGD,IAAI,GAAGD,KAAK,CAACI,KAAK,CAACF,KAAK,GAAGG,IAAI,CAACC,GAAG,CAACH,QAAQ,CAAC,CAAC","ignoreList":[]}
package/package.json.bak DELETED
@@ -1,94 +0,0 @@
1
- {
2
- "repository": "https://github.com/jpb06/effect-errors.git",
3
- "type": "module",
4
- "main": "./cjs/index.js",
5
- "module": "./esm/index.js",
6
- "types": "./dts/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": {
10
- "types": "./dts/index.d.ts",
11
- "default": "./esm/index.js"
12
- },
13
- "require": "./cjs/index.js"
14
- }
15
- },
16
- "name": "effect-errors",
17
- "version": "1.4.12",
18
- "author": "jpb06 <jp.bois.06@outlook.fr>",
19
- "description": "A POC for errors reporting in Effect",
20
- "keywords": [
21
- "effect"
22
- ],
23
- "license": "MIT",
24
- "engines": {
25
- "node": "20.x"
26
- },
27
- "scripts": {
28
- "update-deps": "bunx npm-check-updates --root --format group -i",
29
- "copy-package": "copyfiles package.json ./dist/",
30
- "remove-type-module-from-package": "sed -i.bak '/\"type\": \"module\"/d' ./dist/package.json",
31
- "copy-readme": "copyfiles README.md ./dist/",
32
- "build": "del-cli ./dist && bun build-esm && bun build-cjs && bun build-annotate",
33
- "build-esm": "tsc -b tsconfig-prod.json",
34
- "build-cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
35
- "build-annotate": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
36
- "postbuild": "bun run copy-package && bun run copy-readme && bun run remove-type-module-from-package",
37
- "lint": "eslint ./src",
38
- "type-check": "tsc --noEmit",
39
- "test": "vitest",
40
- "test-ci": "vitest --coverage --run",
41
- "test-dev": "vitest --coverage",
42
- "test-coverage": "vitest run --coverage",
43
- "sync-icons": "bun generateReadmeIcons -h 50",
44
- "run-example-tsx": "tsx ./src/examples/util/run",
45
- "run-example": "bun run ./src/examples/util/run",
46
- "run-examples": "bun run ./src/examples/util/run-all"
47
- },
48
- "dependencies": {
49
- "@effect/schema": "^0.68.23",
50
- "chalk": "<5",
51
- "convert-source-map": "^2.0.0",
52
- "effect": "^3.5.3",
53
- "source-map": "^0.7.4"
54
- },
55
- "devDependencies": {
56
- "@babel/cli": "^7.24.8",
57
- "@babel/core": "^7.24.8",
58
- "@babel/plugin-transform-export-namespace-from": "^7.24.7",
59
- "@babel/plugin-transform-modules-commonjs": "^7.24.8",
60
- "@eslint/eslintrc": "^3.1.0",
61
- "@eslint/js": "^9.7.0",
62
- "@stylistic/eslint-plugin": "^2.3.0",
63
- "@stylistic/eslint-plugin-ts": "^2.3.0",
64
- "@types/eslint": "^8.56.10",
65
- "@types/fs-extra": "^11.0.4",
66
- "@types/node": "^20.14.10",
67
- "@typescript-eslint/eslint-plugin": "^7.16.0",
68
- "@typescript-eslint/parser": "^7.16.0",
69
- "@vitest/coverage-v8": "^1.6.0",
70
- "babel-plugin-annotate-pure-calls": "^0.4.0",
71
- "copyfiles": "^2.4.1",
72
- "del-cli": "^5.1.0",
73
- "eslint": "^9.7.0",
74
- "eslint-config-prettier": "^9.1.0",
75
- "eslint-config-standard-with-typescript": "^43.0.1",
76
- "eslint-import-resolver-typescript": "^3.6.1",
77
- "eslint-plugin-import": "^2.29.1",
78
- "eslint-plugin-markdown": "^5.1.0",
79
- "eslint-plugin-n": "^17.9.0",
80
- "eslint-plugin-prettier": "^5.1.3",
81
- "eslint-plugin-promise": "^6.4.0",
82
- "eslint-plugin-vitest": "^0.5.4",
83
- "fs-extra": "^11.2.0",
84
- "globals": "^15.8.0",
85
- "prettier": "^3.3.3",
86
- "readme-package-icons": "^1.1.14",
87
- "ts-node": "^10.9.2",
88
- "tsx": "^4.16.2",
89
- "typescript": "^5.5.3",
90
- "typescript-eslint": "^7.16.0",
91
- "vitest": "^1.6.0",
92
- "vitest-mock-extended": "^1.3.1"
93
- }
94
- }