@sentry/bundler-plugins 11.12.0 → 11.14.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 (184) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -702
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +41 -46
  53. package/build/cjs/core/upload-filter.js.map +1 -1
  54. package/build/cjs/core/utils.js +228 -221
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +183 -213
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +192 -246
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +151 -175
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -1
  69. package/build/cjs/vite/index.js +19 -21
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +112 -89
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -1
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +271 -340
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -683
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +39 -30
  129. package/build/esm/core/upload-filter.js.map +1 -1
  130. package/build/esm/core/utils.js +221 -211
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +179 -197
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +189 -226
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +149 -159
  145. package/build/esm/rollup/source-map-handling.js.map +1 -1
  146. package/build/esm/vite/index.js +19 -18
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +109 -72
  149. package/build/esm/vite/source-map-hooks.js.map +1 -1
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +268 -322
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +16 -5
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +3 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +25 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/utils.d.ts +4 -0
  170. package/build/types/core/utils.d.ts.map +1 -1
  171. package/build/types/core/version.d.ts +1 -1
  172. package/build/types/esbuild/index.d.ts +2 -2
  173. package/build/types/esbuild/index.d.ts.map +1 -1
  174. package/build/types/rollup/index.d.ts +2 -2
  175. package/build/types/rollup/index.d.ts.map +1 -1
  176. package/build/types/rollup/source-map-handling.d.ts.map +1 -1
  177. package/build/types/vite/index.d.ts +3 -3
  178. package/build/types/vite/index.d.ts.map +1 -1
  179. package/build/types/vite/source-map-hooks.d.ts.map +1 -1
  180. package/build/types/webpack/index.d.ts +7 -3
  181. package/build/types/webpack/index.d.ts.map +1 -1
  182. package/package.json +8 -15
  183. package/build/cjs/loader-utils/index.js.map +0 -1
  184. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1,266 +1,254 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const url = require('url');
6
- const util = require('util');
7
- const utils = require('./utils.js');
8
-
9
- function _interopDefault (e) { return e && e.__esModule ? e.default : e; }
10
-
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
14
- if (e) {
15
- for (const k in e) {
16
- n[k] = e[k];
17
- }
18
- }
19
- n.default = e;
20
- return n;
21
- }
22
-
23
- const fs__default = /*#__PURE__*/_interopDefault(fs);
24
- const path__default = /*#__PURE__*/_interopDefault(path);
25
- const url__namespace = /*#__PURE__*/_interopNamespace(url);
26
- const util__namespace = /*#__PURE__*/_interopNamespace(util);
27
-
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_utils = require("./utils.js");
3
+ let path = require("path");
4
+ path = require_runtime.__toESM(path);
5
+ let fs = require("fs");
6
+ fs = require_runtime.__toESM(fs);
7
+ let url = require("url");
8
+ url = require_runtime.__toESM(url);
9
+ let util = require("util");
10
+ util = require_runtime.__toESM(util);
11
+ // src/core/debug-id-upload.ts
28
12
  function createDebugIdUploadFunction({ sentryBuildPluginManager }) {
29
- return async (buildArtifactPaths, opts) => {
30
- const cleanedPaths = buildArtifactPaths.map(utils.stripQueryAndHashFromPath);
31
- return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);
32
- };
13
+ return async (buildArtifactPaths, opts) => {
14
+ const cleanedPaths = buildArtifactPaths.map(require_utils.stripQueryAndHashFromPath);
15
+ return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);
16
+ };
33
17
  }
18
+ /** Resolves to `undefined` when the bundle was skipped. */
34
19
  async function prepareBundleForDebugIdUpload(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook, resolveSourceMapHook) {
35
- let bundleContent;
36
- try {
37
- bundleContent = await fs__default.promises.readFile(bundleFilePath, "utf8");
38
- } catch (e) {
39
- logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);
40
- return;
41
- }
42
- if (determineDebugIdFromBundleSource(bundleContent) === void 0) {
43
- logger.debug(
44
- `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`
45
- );
46
- return;
47
- }
48
- const sourceMapPath = await determineSourceMapPathFromBundle(
49
- bundleFilePath,
50
- bundleContent,
51
- logger,
52
- resolveSourceMapHook
53
- );
54
- let sourceMapSource;
55
- if (sourceMapPath) {
56
- try {
57
- sourceMapSource = await fs__default.promises.readFile(sourceMapPath, "utf8");
58
- } catch (e) {
59
- logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);
60
- return;
61
- }
62
- }
63
- const result = prepareArtifactForUpload({
64
- code: bundleContent,
65
- mapSource: sourceMapSource,
66
- mapDir: path__default.dirname(sourceMapPath ?? bundleFilePath),
67
- rewriteSourcesHook
68
- });
69
- if (!result.ok) {
70
- if (result.reason === "invalid-source-map") {
71
- logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);
72
- } else {
73
- logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);
74
- }
75
- return;
76
- }
77
- await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);
20
+ let bundleContent;
21
+ try {
22
+ bundleContent = await fs.default.promises.readFile(bundleFilePath, "utf8");
23
+ } catch (e) {
24
+ logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);
25
+ return;
26
+ }
27
+ if (determineDebugIdFromBundleSource(bundleContent) === void 0) {
28
+ logger.debug(`Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`);
29
+ return;
30
+ }
31
+ const sourceMapPath = await determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger, resolveSourceMapHook);
32
+ let sourceMapSource;
33
+ if (sourceMapPath) try {
34
+ sourceMapSource = await fs.default.promises.readFile(sourceMapPath, "utf8");
35
+ } catch (e) {
36
+ logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);
37
+ return;
38
+ }
39
+ const result = prepareArtifactForUpload({
40
+ code: bundleContent,
41
+ mapSource: sourceMapSource,
42
+ mapDir: path.default.dirname(sourceMapPath ?? bundleFilePath),
43
+ rewriteSourcesHook
44
+ });
45
+ if (!result.ok) {
46
+ if (result.reason === "invalid-source-map") logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);
47
+ else logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);
48
+ return;
49
+ }
50
+ await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);
51
+ return { sourceMapPath };
78
52
  }
53
+ /**
54
+ * Prepares a bundle and its source map for the debug ID upload: stamps the debug ID into both
55
+ * and runs the `rewriteSources` hook over the map's `sources`.
56
+ *
57
+ * Pass `mapSource: undefined` when the bundle has no separate source map. A bundle with an
58
+ * inlined map is still prepared; a bundle without any map is skipped because it cannot be
59
+ * symbolicated.
60
+ */
79
61
  function prepareArtifactForUpload(input) {
80
- const debugId = determineDebugIdFromBundleSource(input.code);
81
- if (debugId === void 0) {
82
- return { ok: false, reason: "no-debug-id" };
83
- }
84
- const bundleSource = addDebugIdToBundleSource(input.code, debugId);
85
- if (input.mapSource === void 0) {
86
- if (!bundleHasInlineSourceMap(input.code)) {
87
- return { ok: false, reason: "no-source-map" };
88
- }
89
- return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: void 0 } };
90
- }
91
- const map = parseSourceMap(input.mapSource);
92
- if (!map) {
93
- return { ok: false, reason: "invalid-source-map" };
94
- }
95
- setDebugIdOnSourceMap(map, debugId);
96
- if (Array.isArray(map["sources"])) {
97
- map["sources"] = map["sources"].map(
98
- (source) => input.rewriteSourcesHook(source, map, { mapDir: input.mapDir })
99
- );
100
- }
101
- return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: JSON.stringify(map) } };
62
+ const debugId = determineDebugIdFromBundleSource(input.code);
63
+ if (debugId === void 0) return {
64
+ ok: false,
65
+ reason: "no-debug-id"
66
+ };
67
+ const bundleSource = addDebugIdToBundleSource(input.code, debugId);
68
+ if (input.mapSource === void 0) {
69
+ if (!bundleHasInlineSourceMap(input.code)) return {
70
+ ok: false,
71
+ reason: "no-source-map"
72
+ };
73
+ return {
74
+ ok: true,
75
+ artifact: {
76
+ debugId,
77
+ bundleSource,
78
+ sourceMapSource: void 0
79
+ }
80
+ };
81
+ }
82
+ const map = parseSourceMap(input.mapSource);
83
+ if (!map) return {
84
+ ok: false,
85
+ reason: "invalid-source-map"
86
+ };
87
+ setDebugIdOnSourceMap(map, debugId);
88
+ if (Array.isArray(map["sources"])) map["sources"] = map["sources"].map((source) => input.rewriteSourcesHook(source, map, { mapDir: input.mapDir }));
89
+ return {
90
+ ok: true,
91
+ artifact: {
92
+ debugId,
93
+ bundleSource,
94
+ sourceMapSource: JSON.stringify(map)
95
+ }
96
+ };
102
97
  }
98
+ /**
99
+ * Writes a prepared artifact as `<uniqueUploadName>.js` (and `.js.map`) into the upload folder.
100
+ */
103
101
  async function writePreparedArtifact(uploadFolder, uniqueUploadName, artifact) {
104
- const writes = [
105
- fs__default.promises.writeFile(path__default.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, "utf-8")
106
- ];
107
- if (artifact.sourceMapSource !== void 0) {
108
- writes.push(
109
- fs__default.promises.writeFile(path__default.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, "utf-8")
110
- );
111
- }
112
- await Promise.all(writes);
102
+ const writes = [fs.default.promises.writeFile(path.default.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, "utf-8")];
103
+ if (artifact.sourceMapSource !== void 0) writes.push(fs.default.promises.writeFile(path.default.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, "utf-8"));
104
+ await Promise.all(writes);
113
105
  }
106
+ /**
107
+ * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
108
+ * source and extracts the bundle's debug ID from it.
109
+ *
110
+ * The string pattern is injected via the debug ID injection snipped.
111
+ */
114
112
  function determineDebugIdFromBundleSource(code) {
115
- const match = code.match(
116
- /sentry-dbid-([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/
117
- );
118
- if (match) {
119
- return match[1];
120
- } else {
121
- return void 0;
122
- }
113
+ const match = code.match(/sentry-dbid-([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/);
114
+ if (match) return match[1];
115
+ else return;
123
116
  }
124
117
  const SPEC_LAST_DEBUG_ID_REGEX = /\/\/# debugId=([a-fA-F0-9-]+)(?![\s\S]*\/\/# debugId=)/m;
125
118
  function hasSpecCompliantDebugId(bundleSource) {
126
- return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);
119
+ return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);
127
120
  }
128
121
  function addDebugIdToBundleSource(bundleSource, debugId) {
129
- if (hasSpecCompliantDebugId(bundleSource)) {
130
- return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, `//# debugId=${debugId}`);
131
- } else {
132
- return `${bundleSource}
133
- //# debugId=${debugId}`;
134
- }
122
+ if (hasSpecCompliantDebugId(bundleSource)) return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, `//# debugId=${debugId}`);
123
+ else return `${bundleSource}\n//# debugId=${debugId}`;
135
124
  }
136
125
  function setDebugIdOnSourceMap(map, debugId) {
137
- map["debug_id"] = debugId;
138
- map["debugId"] = debugId;
126
+ map["debug_id"] = debugId;
127
+ map["debugId"] = debugId;
139
128
  }
140
129
  function parseSourceMap(sourceMapSource) {
141
- let map;
142
- try {
143
- map = JSON.parse(sourceMapSource);
144
- } catch {
145
- return void 0;
146
- }
147
- return map && typeof map === "object" ? map : void 0;
130
+ let map;
131
+ try {
132
+ map = JSON.parse(sourceMapSource);
133
+ } catch {
134
+ return;
135
+ }
136
+ return map && typeof map === "object" ? map : void 0;
148
137
  }
138
+ /**
139
+ * Stamps the debug ID injected into `bundleSource` into the bundle (as `//# debugId=` comment) and its
140
+ * source map (as `debug_id`/`debugId` fields).
141
+ *
142
+ * This exists for `sourcemaps.disable: "disable-upload"`: the regular upload path only stamps
143
+ * temporary copies of the artifacts (see `prepareBundleForDebugIdUpload`), so without this the
144
+ * emitted artifacts would carry no debug ID and a later manual upload could not match them.
145
+ * Callers must apply the result inside the bundler's asset pipeline (or, for bundlers without one,
146
+ * before the build resolves) so that integrity hashes computed by later build steps include it.
147
+ *
148
+ * Pass `sourceMapSource: undefined` when the bundle has no separate source map. A bundle with an
149
+ * inlined map still gets the comment, which is all the CLI and Symbolicator read the debug ID from.
150
+ *
151
+ * @returns the stamped artifacts, or `undefined` for bundles without a debug ID, without any source
152
+ * map, or with an unparseable map.
153
+ */
149
154
  function stampDebugId(bundleSource, sourceMapSource) {
150
- const debugId = determineDebugIdFromBundleSource(bundleSource);
151
- if (debugId === void 0) {
152
- return void 0;
153
- }
154
- if (sourceMapSource === void 0) {
155
- if (!bundleHasInlineSourceMap(bundleSource)) {
156
- return void 0;
157
- }
158
- return { bundleSource: addDebugIdToBundleSource(bundleSource, debugId), sourceMapSource: void 0 };
159
- }
160
- const map = parseSourceMap(sourceMapSource);
161
- if (!map) {
162
- return void 0;
163
- }
164
- setDebugIdOnSourceMap(map, debugId);
165
- return {
166
- bundleSource: addDebugIdToBundleSource(bundleSource, debugId),
167
- sourceMapSource: JSON.stringify(map)
168
- };
155
+ const debugId = determineDebugIdFromBundleSource(bundleSource);
156
+ if (debugId === void 0) return;
157
+ if (sourceMapSource === void 0) {
158
+ if (!bundleHasInlineSourceMap(bundleSource)) return;
159
+ return {
160
+ bundleSource: addDebugIdToBundleSource(bundleSource, debugId),
161
+ sourceMapSource: void 0
162
+ };
163
+ }
164
+ const map = parseSourceMap(sourceMapSource);
165
+ if (!map) return;
166
+ setDebugIdOnSourceMap(map, debugId);
167
+ return {
168
+ bundleSource: addDebugIdToBundleSource(bundleSource, debugId),
169
+ sourceMapSource: JSON.stringify(map)
170
+ };
169
171
  }
172
+ /**
173
+ * Stamps the debug ID of an emitted bundle into the bundle and its source map on disk.
174
+ *
175
+ * Used by bundlers that offer no hook to modify assets before they are written (esbuild).
176
+ */
170
177
  async function addDebugIdToEmittedArtifacts(bundleFilePath, logger, resolveSourceMapHook) {
171
- let bundleSource;
172
- try {
173
- bundleSource = await fs__default.promises.readFile(bundleFilePath, "utf8");
174
- } catch (e) {
175
- logger.error(`Could not read bundle to stamp debug ID: ${bundleFilePath}`, e);
176
- return;
177
- }
178
- const sourceMapPath = await determineSourceMapPathFromBundle(
179
- bundleFilePath,
180
- bundleSource,
181
- logger,
182
- resolveSourceMapHook
183
- );
184
- let sourceMapSource;
185
- if (sourceMapPath) {
186
- try {
187
- sourceMapSource = await fs__default.promises.readFile(sourceMapPath, "utf8");
188
- } catch (e) {
189
- logger.error(`Could not read source map to stamp debug ID: ${sourceMapPath}`, e);
190
- return;
191
- }
192
- }
193
- const stamped = stampDebugId(bundleSource, sourceMapSource);
194
- if (!stamped) {
195
- logger.debug(
196
- `Could not stamp debug ID (no debug ID in bundle, no source map, or invalid source map): ${bundleFilePath}`
197
- );
198
- return;
199
- }
200
- const writes = [fs__default.promises.writeFile(bundleFilePath, stamped.bundleSource, "utf8")];
201
- if (sourceMapPath && stamped.sourceMapSource !== void 0) {
202
- writes.push(fs__default.promises.writeFile(sourceMapPath, stamped.sourceMapSource, "utf8"));
203
- }
204
- try {
205
- await Promise.all(writes);
206
- } catch (e) {
207
- logger.error(`Could not write debug ID into build artifacts: ${bundleFilePath}`, e);
208
- }
178
+ let bundleSource;
179
+ try {
180
+ bundleSource = await fs.default.promises.readFile(bundleFilePath, "utf8");
181
+ } catch (e) {
182
+ logger.error(`Could not read bundle to stamp debug ID: ${bundleFilePath}`, e);
183
+ return;
184
+ }
185
+ const sourceMapPath = await determineSourceMapPathFromBundle(bundleFilePath, bundleSource, logger, resolveSourceMapHook);
186
+ let sourceMapSource;
187
+ if (sourceMapPath) try {
188
+ sourceMapSource = await fs.default.promises.readFile(sourceMapPath, "utf8");
189
+ } catch (e) {
190
+ logger.error(`Could not read source map to stamp debug ID: ${sourceMapPath}`, e);
191
+ return;
192
+ }
193
+ const stamped = stampDebugId(bundleSource, sourceMapSource);
194
+ if (!stamped) {
195
+ logger.debug(`Could not stamp debug ID (no debug ID in bundle, no source map, or invalid source map): ${bundleFilePath}`);
196
+ return;
197
+ }
198
+ const writes = [fs.default.promises.writeFile(bundleFilePath, stamped.bundleSource, "utf8")];
199
+ if (sourceMapPath && stamped.sourceMapSource !== void 0) writes.push(fs.default.promises.writeFile(sourceMapPath, stamped.sourceMapSource, "utf8"));
200
+ try {
201
+ await Promise.all(writes);
202
+ } catch (e) {
203
+ logger.error(`Could not write debug ID into build artifacts: ${bundleFilePath}`, e);
204
+ }
209
205
  }
206
+ /**
207
+ * Whether the bundle carries its source map inlined as `sourceMappingURL=data:`
208
+ * URI, rather than referencing a separate `.map` file. Such bundles must still
209
+ * be uploaded even when no `.map` file is found, because the source file itself
210
+ * contains the map.
211
+ */
210
212
  function bundleHasInlineSourceMap(bundleSource) {
211
- return /^\s*\/\/# sourceMappingURL=data:/m.test(bundleSource);
213
+ return /^\s*\/\/# sourceMappingURL=data:/m.test(bundleSource);
212
214
  }
215
+ /**
216
+ * Applies a set of heuristics to find the source map for a particular bundle.
217
+ *
218
+ * @returns the path to the bundle's source map or `undefined` if none could be found.
219
+ */
213
220
  async function determineSourceMapPathFromBundle(bundlePath, bundleSource, logger, resolveSourceMapHook) {
214
- const sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
215
- const sourceMappingUrl = sourceMappingUrlMatch ? sourceMappingUrlMatch[1] : void 0;
216
- const searchLocations = [];
217
- if (resolveSourceMapHook) {
218
- logger.debug(
219
- `Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`
220
- );
221
- const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);
222
- logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);
223
- if (customPath) {
224
- searchLocations.push(customPath);
225
- }
226
- }
227
- if (sourceMappingUrl) {
228
- let parsedUrl;
229
- try {
230
- parsedUrl = new URL(sourceMappingUrl);
231
- } catch {
232
- }
233
- if (parsedUrl?.protocol === "file:") {
234
- searchLocations.push(url__namespace.fileURLToPath(sourceMappingUrl));
235
- } else if (parsedUrl) ; else if (path__default.isAbsolute(sourceMappingUrl)) {
236
- searchLocations.push(path__default.normalize(sourceMappingUrl));
237
- } else {
238
- searchLocations.push(path__default.normalize(path__default.join(path__default.dirname(bundlePath), sourceMappingUrl)));
239
- }
240
- }
241
- searchLocations.push(`${bundlePath}.map`);
242
- for (const searchLocation of searchLocations) {
243
- try {
244
- await util__namespace.promisify(fs__default.access)(searchLocation);
245
- logger.debug(`Source map found for bundle \`${bundlePath}\`: \`${searchLocation}\``);
246
- return searchLocation;
247
- } catch {
248
- }
249
- }
250
- logger.debug(
251
- `Could not determine source map path for bundle \`${bundlePath}\` with sourceMappingURL=${sourceMappingUrl === void 0 ? "undefined" : `\`${sourceMappingUrl}\``} - Did you turn on source map generation in your bundler? (Attempted paths: ${searchLocations.map((e) => `\`${e}\``).join(", ")})`
252
- );
253
- return void 0;
221
+ const sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
222
+ const sourceMappingUrl = sourceMappingUrlMatch ? sourceMappingUrlMatch[1] : void 0;
223
+ const searchLocations = [];
224
+ if (resolveSourceMapHook) {
225
+ logger.debug(`Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`);
226
+ const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);
227
+ logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);
228
+ if (customPath) searchLocations.push(customPath);
229
+ }
230
+ if (sourceMappingUrl) {
231
+ let parsedUrl;
232
+ try {
233
+ parsedUrl = new URL(sourceMappingUrl);
234
+ } catch {}
235
+ if (parsedUrl?.protocol === "file:") searchLocations.push(url.fileURLToPath(sourceMappingUrl));
236
+ else if (parsedUrl) {} else if (path.default.isAbsolute(sourceMappingUrl)) searchLocations.push(path.default.normalize(sourceMappingUrl));
237
+ else searchLocations.push(path.default.normalize(path.default.join(path.default.dirname(bundlePath), sourceMappingUrl)));
238
+ }
239
+ searchLocations.push(`${bundlePath}.map`);
240
+ for (const searchLocation of searchLocations) try {
241
+ await util.promisify(fs.default.access)(searchLocation);
242
+ logger.debug(`Source map found for bundle \`${bundlePath}\`: \`${searchLocation}\``);
243
+ return searchLocation;
244
+ } catch {}
245
+ logger.debug(`Could not determine source map path for bundle \`${bundlePath}\` with sourceMappingURL=${sourceMappingUrl === void 0 ? "undefined" : `\`${sourceMappingUrl}\``} - Did you turn on source map generation in your bundler? (Attempted paths: ${searchLocations.map((e) => `\`${e}\``).join(", ")})`);
254
246
  }
255
247
  const PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//;
256
248
  function defaultRewriteSourcesHook(source) {
257
- if (source.match(PROTOCOL_REGEX)) {
258
- return source.replace(PROTOCOL_REGEX, "");
259
- } else {
260
- return path__default.relative(process.cwd(), path__default.normalize(source));
261
- }
249
+ if (source.match(PROTOCOL_REGEX)) return source.replace(PROTOCOL_REGEX, "");
250
+ else return path.default.relative(process.cwd(), path.default.normalize(source));
262
251
  }
263
-
264
252
  exports.addDebugIdToEmittedArtifacts = addDebugIdToEmittedArtifacts;
265
253
  exports.createDebugIdUploadFunction = createDebugIdUploadFunction;
266
254
  exports.defaultRewriteSourcesHook = defaultRewriteSourcesHook;
@@ -269,4 +257,5 @@ exports.prepareArtifactForUpload = prepareArtifactForUpload;
269
257
  exports.prepareBundleForDebugIdUpload = prepareBundleForDebugIdUpload;
270
258
  exports.stampDebugId = stampDebugId;
271
259
  exports.writePreparedArtifact = writePreparedArtifact;
272
- //# sourceMappingURL=debug-id-upload.js.map
260
+
261
+ //# sourceMappingURL=debug-id-upload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-id-upload.js","sources":["../../../src/core/debug-id-upload.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport * as url from 'url';\nimport * as util from 'util';\nimport type { SentryBuildPluginManager, UploadStaging } from './build-plugin-manager';\nimport type { Logger } from './logger';\nimport type { ResolveSourceMapHook, RewriteSourcesHook } from './types';\nimport { stripQueryAndHashFromPath } from './utils';\n\ninterface DebugIdUploadPluginOptions {\n sentryBuildPluginManager: SentryBuildPluginManager;\n}\n\nexport function createDebugIdUploadFunction({ sentryBuildPluginManager }: DebugIdUploadPluginOptions) {\n return async (buildArtifactPaths: string[], opts?: { staging?: UploadStaging }) => {\n // Webpack and perhaps other bundlers allow you to append query strings to\n // filenames for cache busting purposes. We should strip these before upload.\n const cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);\n return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);\n };\n}\n\nexport async function prepareBundleForDebugIdUpload(\n bundleFilePath: string,\n uploadFolder: string,\n chunkIndex: number,\n logger: Logger,\n rewriteSourcesHook: RewriteSourcesHook,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleContent: string;\n try {\n bundleContent = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);\n return;\n }\n\n if (determineDebugIdFromBundleSource(bundleContent) === undefined) {\n logger.debug(\n `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`,\n );\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleContent,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const result = prepareArtifactForUpload({\n code: bundleContent,\n mapSource: sourceMapSource,\n mapDir: path.dirname(sourceMapPath ?? bundleFilePath),\n rewriteSourcesHook,\n });\n\n if (!result.ok) {\n if (result.reason === 'invalid-source-map') {\n logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);\n } else {\n // A chunk with a debug ID but no resolvable source map\n // (e.g. framework-generated stub chunks that never emit one) can't be\n // symbolicated, so uploading its minified source alone accomplishes\n // nothing and only makes the uploader warn about a missing source map ref.\n logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);\n }\n return;\n }\n\n await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);\n}\n\nexport type PreparedUploadArtifact = {\n debugId: string;\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nexport type PrepareArtifactResult =\n | { ok: true; artifact: PreparedUploadArtifact }\n | { ok: false; reason: 'no-debug-id' | 'no-source-map' | 'invalid-source-map' };\n\n/**\n * Prepares a bundle and its source map for the debug ID upload: stamps the debug ID into both\n * and runs the `rewriteSources` hook over the map's `sources`.\n *\n * Pass `mapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map is still prepared; a bundle without any map is skipped because it cannot be\n * symbolicated.\n */\nexport function prepareArtifactForUpload(input: {\n code: string;\n mapSource: string | undefined;\n /** Directory the source map lives in, passed to the `rewriteSources` hook. */\n mapDir: string;\n rewriteSourcesHook: RewriteSourcesHook;\n}): PrepareArtifactResult {\n const debugId = determineDebugIdFromBundleSource(input.code);\n if (debugId === undefined) {\n return { ok: false, reason: 'no-debug-id' };\n }\n\n const bundleSource = addDebugIdToBundleSource(input.code, debugId);\n\n if (input.mapSource === undefined) {\n if (!bundleHasInlineSourceMap(input.code)) {\n return { ok: false, reason: 'no-source-map' };\n }\n return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: undefined } };\n }\n\n const map = parseSourceMap(input.mapSource);\n if (!map) {\n return { ok: false, reason: 'invalid-source-map' };\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n if (Array.isArray(map['sources'])) {\n map['sources'] = map['sources'].map((source: string) =>\n input.rewriteSourcesHook(source, map, { mapDir: input.mapDir }),\n );\n }\n\n return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: JSON.stringify(map) } };\n}\n\n/**\n * Writes a prepared artifact as `<uniqueUploadName>.js` (and `.js.map`) into the upload folder.\n */\nexport async function writePreparedArtifact(\n uploadFolder: string,\n uniqueUploadName: string,\n artifact: PreparedUploadArtifact,\n): Promise<void> {\n const writes = [\n fs.promises.writeFile(path.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, 'utf-8'),\n ];\n\n if (artifact.sourceMapSource !== undefined) {\n writes.push(\n fs.promises.writeFile(path.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, 'utf-8'),\n );\n }\n\n await Promise.all(writes);\n}\n\n/**\n * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle\n * source and extracts the bundle's debug ID from it.\n *\n * The string pattern is injected via the debug ID injection snipped.\n */\nfunction determineDebugIdFromBundleSource(code: string): string | undefined {\n const match = code.match(\n /sentry-dbid-([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})/,\n );\n\n if (match) {\n return match[1];\n } else {\n return undefined;\n }\n}\n\nconst SPEC_LAST_DEBUG_ID_REGEX = /\\/\\/# debugId=([a-fA-F0-9-]+)(?![\\s\\S]*\\/\\/# debugId=)/m;\n\nfunction hasSpecCompliantDebugId(bundleSource: string): boolean {\n return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);\n}\n\nfunction addDebugIdToBundleSource(bundleSource: string, debugId: string): string {\n if (hasSpecCompliantDebugId(bundleSource)) {\n return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, `//# debugId=${debugId}`);\n } else {\n return `${bundleSource}\\n//# debugId=${debugId}`;\n }\n}\n\nfunction setDebugIdOnSourceMap(map: Record<string, unknown>, debugId: string): void {\n // For now we write both fields until we know what will become the standard - if ever.\n map['debug_id'] = debugId;\n map['debugId'] = debugId;\n}\n\nexport type StampedArtifacts = {\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nfunction parseSourceMap(sourceMapSource: string): Record<string, unknown> | undefined {\n let map: unknown;\n try {\n map = JSON.parse(sourceMapSource);\n } catch {\n return undefined;\n }\n\n return map && typeof map === 'object' ? (map as Record<string, unknown>) : undefined;\n}\n\n/**\n * Stamps the debug ID injected into `bundleSource` into the bundle (as `//# debugId=` comment) and its\n * source map (as `debug_id`/`debugId` fields).\n *\n * This exists for `sourcemaps.disable: \"disable-upload\"`: the regular upload path only stamps\n * temporary copies of the artifacts (see `prepareBundleForDebugIdUpload`), so without this the\n * emitted artifacts would carry no debug ID and a later manual upload could not match them.\n * Callers must apply the result inside the bundler's asset pipeline (or, for bundlers without one,\n * before the build resolves) so that integrity hashes computed by later build steps include it.\n *\n * Pass `sourceMapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map still gets the comment, which is all the CLI and Symbolicator read the debug ID from.\n *\n * @returns the stamped artifacts, or `undefined` for bundles without a debug ID, without any source\n * map, or with an unparseable map.\n */\nexport function stampDebugId(bundleSource: string, sourceMapSource: string | undefined): StampedArtifacts | undefined {\n const debugId = determineDebugIdFromBundleSource(bundleSource);\n if (debugId === undefined) {\n return undefined;\n }\n\n if (sourceMapSource === undefined) {\n if (!bundleHasInlineSourceMap(bundleSource)) {\n return undefined;\n }\n\n return { bundleSource: addDebugIdToBundleSource(bundleSource, debugId), sourceMapSource: undefined };\n }\n\n const map = parseSourceMap(sourceMapSource);\n if (!map) {\n return undefined;\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n return {\n bundleSource: addDebugIdToBundleSource(bundleSource, debugId),\n sourceMapSource: JSON.stringify(map),\n };\n}\n\n/**\n * Stamps the debug ID of an emitted bundle into the bundle and its source map on disk.\n *\n * Used by bundlers that offer no hook to modify assets before they are written (esbuild).\n */\nexport async function addDebugIdToEmittedArtifacts(\n bundleFilePath: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleSource: string;\n try {\n bundleSource = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to stamp debug ID: ${bundleFilePath}`, e);\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleSource,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Could not read source map to stamp debug ID: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const stamped = stampDebugId(bundleSource, sourceMapSource);\n if (!stamped) {\n logger.debug(\n `Could not stamp debug ID (no debug ID in bundle, no source map, or invalid source map): ${bundleFilePath}`,\n );\n return;\n }\n\n const writes = [fs.promises.writeFile(bundleFilePath, stamped.bundleSource, 'utf8')];\n if (sourceMapPath && stamped.sourceMapSource !== undefined) {\n writes.push(fs.promises.writeFile(sourceMapPath, stamped.sourceMapSource, 'utf8'));\n }\n\n try {\n await Promise.all(writes);\n } catch (e) {\n logger.error(`Could not write debug ID into build artifacts: ${bundleFilePath}`, e);\n }\n}\n\n/**\n * Whether the bundle carries its source map inlined as `sourceMappingURL=data:`\n * URI, rather than referencing a separate `.map` file. Such bundles must still\n * be uploaded even when no `.map` file is found, because the source file itself\n * contains the map.\n */\nfunction bundleHasInlineSourceMap(bundleSource: string): boolean {\n return /^\\s*\\/\\/# sourceMappingURL=data:/m.test(bundleSource);\n}\n\n/**\n * Applies a set of heuristics to find the source map for a particular bundle.\n *\n * @returns the path to the bundle's source map or `undefined` if none could be found.\n */\nexport async function determineSourceMapPathFromBundle(\n bundlePath: string,\n bundleSource: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<string | undefined> {\n const sourceMappingUrlMatch = bundleSource.match(/^\\s*\\/\\/# sourceMappingURL=(.*)$/m);\n const sourceMappingUrl = sourceMappingUrlMatch ? (sourceMappingUrlMatch[1] as string) : undefined;\n\n const searchLocations: string[] = [];\n\n if (resolveSourceMapHook) {\n logger.debug(\n `Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`,\n );\n const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);\n logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);\n\n if (customPath) {\n searchLocations.push(customPath);\n }\n }\n\n // 1. try to find source map at `sourceMappingURL` location\n if (sourceMappingUrl) {\n let parsedUrl: URL | undefined;\n try {\n parsedUrl = new URL(sourceMappingUrl);\n } catch {\n // noop\n }\n\n if (parsedUrl?.protocol === 'file:') {\n searchLocations.push(url.fileURLToPath(sourceMappingUrl));\n } else if (parsedUrl) {\n // noop, non-file urls don't translate to a local sourcemap file\n } else if (path.isAbsolute(sourceMappingUrl)) {\n searchLocations.push(path.normalize(sourceMappingUrl));\n } else {\n searchLocations.push(path.normalize(path.join(path.dirname(bundlePath), sourceMappingUrl)));\n }\n }\n\n // 2. try to find source map at path adjacent to chunk source, but with `.map` appended\n searchLocations.push(`${bundlePath}.map`);\n\n for (const searchLocation of searchLocations) {\n try {\n await util.promisify(fs.access)(searchLocation);\n logger.debug(`Source map found for bundle \\`${bundlePath}\\`: \\`${searchLocation}\\``);\n return searchLocation;\n } catch {\n // noop\n }\n }\n\n // This is just a debug message because it can be quite spammy for some frameworks\n logger.debug(\n `Could not determine source map path for bundle \\`${bundlePath}\\`` +\n ` with sourceMappingURL=${sourceMappingUrl === undefined ? 'undefined' : `\\`${sourceMappingUrl}\\``}` +\n ` - Did you turn on source map generation in your bundler?` +\n ` (Attempted paths: ${searchLocations.map(e => `\\`${e}\\``).join(', ')})`,\n );\n return undefined;\n}\n\nconst PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\//;\nexport function defaultRewriteSourcesHook(source: string): string {\n if (source.match(PROTOCOL_REGEX)) {\n return source.replace(PROTOCOL_REGEX, '');\n } else {\n return path.relative(process.cwd(), path.normalize(source));\n }\n}\n"],"names":["stripQueryAndHashFromPath","fs","path","url","util"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,2BAAA,CAA4B,EAAE,wBAAA,EAAyB,EAA+B;AACpG,EAAA,OAAO,OAAO,oBAA8B,IAA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;AAExC,EAAA,KAAA,MAAW,kBAAkB,eAAA,EAAiB;AAC5C,IAAA,IAAI;AACF,MAAA,MAAME,eAAA,CAAK,SAAA,CAAUH,WAAA,CAAG,MAAM,EAAE,cAAc,CAAA;AAC9C,MAAA,MAAA,CAAO,KAAA,CAAM,CAAA,8BAAA,EAAiC,UAAU,CAAA,MAAA,EAAS,cAAc,CAAA,EAAA,CAAI,CAAA;AACnF,MAAA,OAAO,cAAA;AAAA,IACT,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAGA,EAAA,MAAA,CAAO,KAAA;AAAA,IACL,oDAAoD,UAAU,CAAA,yBAAA,EAClC,qBAAqB,MAAA,GAAY,WAAA,GAAc,KAAK,gBAAgB,CAAA,EAAA,CAAI,+EAE5E,eAAA,CAAgB,GAAA,CAAI,OAAK,CAAA,EAAA,EAAK,CAAC,IAAI,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,GACzE;AACA,EAAA,OAAO,MAAA;AACT;AAEA,MAAM,cAAA,GAAiB,gCAAA;AAChB,SAAS,0BAA0B,MAAA,EAAwB;AAChE,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,cAAc,CAAA,EAAG;AAChC,IAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,cAAA,EAAgB,EAAE,CAAA;AAAA,EAC1C,CAAA,MAAO;AACL,IAAA,OAAOC,aAAA,CAAK,SAAS,OAAA,CAAQ,GAAA,IAAOA,aAAA,CAAK,SAAA,CAAU,MAAM,CAAC,CAAA;AAAA,EAC5D;AACF;;;;;;;;;;;"}
1
+ {"version":3,"file":"debug-id-upload.js","names":["stripQueryAndHashFromPath","fs","path"],"sources":["../../../src/core/debug-id-upload.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport * as url from 'url';\nimport * as util from 'util';\nimport type { SentryBuildPluginManager, UploadStaging } from './build-plugin-manager';\nimport type { Logger } from './logger';\nimport type { ResolveSourceMapHook, RewriteSourcesHook } from './types';\nimport { stripQueryAndHashFromPath } from './utils';\n\ninterface DebugIdUploadPluginOptions {\n sentryBuildPluginManager: SentryBuildPluginManager;\n}\n\nexport function createDebugIdUploadFunction({ sentryBuildPluginManager }: DebugIdUploadPluginOptions) {\n return async (buildArtifactPaths: string[], opts?: { staging?: UploadStaging }) => {\n // Webpack and perhaps other bundlers allow you to append query strings to\n // filenames for cache busting purposes. We should strip these before upload.\n const cleanedPaths = buildArtifactPaths.map(stripQueryAndHashFromPath);\n return sentryBuildPluginManager.uploadSourcemaps(cleanedPaths, opts);\n };\n}\n\n/** The source map of a prepared bundle. `sourceMapPath` is `undefined` for an inline map. */\nexport type PreparedBundle = { sourceMapPath: string | undefined };\n\n/** Resolves to `undefined` when the bundle was skipped. */\nexport async function prepareBundleForDebugIdUpload(\n bundleFilePath: string,\n uploadFolder: string,\n chunkIndex: number,\n logger: Logger,\n rewriteSourcesHook: RewriteSourcesHook,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<PreparedBundle | undefined> {\n let bundleContent: string;\n try {\n bundleContent = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to determine debug ID and source map: ${bundleFilePath}`, e);\n return;\n }\n\n if (determineDebugIdFromBundleSource(bundleContent) === undefined) {\n logger.debug(\n `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}`,\n );\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleContent,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Failed to read source map for debug ID upload: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const result = prepareArtifactForUpload({\n code: bundleContent,\n mapSource: sourceMapSource,\n mapDir: path.dirname(sourceMapPath ?? bundleFilePath),\n rewriteSourcesHook,\n });\n\n if (!result.ok) {\n if (result.reason === 'invalid-source-map') {\n logger.error(`Failed to parse source map for debug ID upload: ${sourceMapPath}`);\n } else {\n // A chunk with a debug ID but no resolvable source map\n // (e.g. framework-generated stub chunks that never emit one) can't be\n // symbolicated, so uploading its minified source alone accomplishes\n // nothing and only makes the uploader warn about a missing source map ref.\n logger.debug(`Not uploading bundle without a source map: ${bundleFilePath}`);\n }\n return;\n }\n\n await writePreparedArtifact(uploadFolder, `${result.artifact.debugId}-${chunkIndex}`, result.artifact);\n return { sourceMapPath };\n}\n\nexport type PreparedUploadArtifact = {\n debugId: string;\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nexport type PrepareArtifactResult =\n | { ok: true; artifact: PreparedUploadArtifact }\n | { ok: false; reason: 'no-debug-id' | 'no-source-map' | 'invalid-source-map' };\n\n/**\n * Prepares a bundle and its source map for the debug ID upload: stamps the debug ID into both\n * and runs the `rewriteSources` hook over the map's `sources`.\n *\n * Pass `mapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map is still prepared; a bundle without any map is skipped because it cannot be\n * symbolicated.\n */\nexport function prepareArtifactForUpload(input: {\n code: string;\n mapSource: string | undefined;\n /** Directory the source map lives in, passed to the `rewriteSources` hook. */\n mapDir: string;\n rewriteSourcesHook: RewriteSourcesHook;\n}): PrepareArtifactResult {\n const debugId = determineDebugIdFromBundleSource(input.code);\n if (debugId === undefined) {\n return { ok: false, reason: 'no-debug-id' };\n }\n\n const bundleSource = addDebugIdToBundleSource(input.code, debugId);\n\n if (input.mapSource === undefined) {\n if (!bundleHasInlineSourceMap(input.code)) {\n return { ok: false, reason: 'no-source-map' };\n }\n return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: undefined } };\n }\n\n const map = parseSourceMap(input.mapSource);\n if (!map) {\n return { ok: false, reason: 'invalid-source-map' };\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n if (Array.isArray(map['sources'])) {\n map['sources'] = map['sources'].map((source: string) =>\n input.rewriteSourcesHook(source, map, { mapDir: input.mapDir }),\n );\n }\n\n return { ok: true, artifact: { debugId, bundleSource, sourceMapSource: JSON.stringify(map) } };\n}\n\n/**\n * Writes a prepared artifact as `<uniqueUploadName>.js` (and `.js.map`) into the upload folder.\n */\nexport async function writePreparedArtifact(\n uploadFolder: string,\n uniqueUploadName: string,\n artifact: PreparedUploadArtifact,\n): Promise<void> {\n const writes = [\n fs.promises.writeFile(path.join(uploadFolder, `${uniqueUploadName}.js`), artifact.bundleSource, 'utf-8'),\n ];\n\n if (artifact.sourceMapSource !== undefined) {\n writes.push(\n fs.promises.writeFile(path.join(uploadFolder, `${uniqueUploadName}.js.map`), artifact.sourceMapSource, 'utf-8'),\n );\n }\n\n await Promise.all(writes);\n}\n\n/**\n * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle\n * source and extracts the bundle's debug ID from it.\n *\n * The string pattern is injected via the debug ID injection snipped.\n */\nfunction determineDebugIdFromBundleSource(code: string): string | undefined {\n const match = code.match(\n /sentry-dbid-([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})/,\n );\n\n if (match) {\n return match[1];\n } else {\n return undefined;\n }\n}\n\nconst SPEC_LAST_DEBUG_ID_REGEX = /\\/\\/# debugId=([a-fA-F0-9-]+)(?![\\s\\S]*\\/\\/# debugId=)/m;\n\nfunction hasSpecCompliantDebugId(bundleSource: string): boolean {\n return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);\n}\n\nfunction addDebugIdToBundleSource(bundleSource: string, debugId: string): string {\n if (hasSpecCompliantDebugId(bundleSource)) {\n return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, `//# debugId=${debugId}`);\n } else {\n return `${bundleSource}\\n//# debugId=${debugId}`;\n }\n}\n\nfunction setDebugIdOnSourceMap(map: Record<string, unknown>, debugId: string): void {\n // For now we write both fields until we know what will become the standard - if ever.\n map['debug_id'] = debugId;\n map['debugId'] = debugId;\n}\n\nexport type StampedArtifacts = {\n bundleSource: string;\n /** `undefined` when the bundle has no separate source map (i.e. the map is inlined). */\n sourceMapSource: string | undefined;\n};\n\nfunction parseSourceMap(sourceMapSource: string): Record<string, unknown> | undefined {\n let map: unknown;\n try {\n map = JSON.parse(sourceMapSource);\n } catch {\n return undefined;\n }\n\n return map && typeof map === 'object' ? (map as Record<string, unknown>) : undefined;\n}\n\n/**\n * Stamps the debug ID injected into `bundleSource` into the bundle (as `//# debugId=` comment) and its\n * source map (as `debug_id`/`debugId` fields).\n *\n * This exists for `sourcemaps.disable: \"disable-upload\"`: the regular upload path only stamps\n * temporary copies of the artifacts (see `prepareBundleForDebugIdUpload`), so without this the\n * emitted artifacts would carry no debug ID and a later manual upload could not match them.\n * Callers must apply the result inside the bundler's asset pipeline (or, for bundlers without one,\n * before the build resolves) so that integrity hashes computed by later build steps include it.\n *\n * Pass `sourceMapSource: undefined` when the bundle has no separate source map. A bundle with an\n * inlined map still gets the comment, which is all the CLI and Symbolicator read the debug ID from.\n *\n * @returns the stamped artifacts, or `undefined` for bundles without a debug ID, without any source\n * map, or with an unparseable map.\n */\nexport function stampDebugId(bundleSource: string, sourceMapSource: string | undefined): StampedArtifacts | undefined {\n const debugId = determineDebugIdFromBundleSource(bundleSource);\n if (debugId === undefined) {\n return undefined;\n }\n\n if (sourceMapSource === undefined) {\n if (!bundleHasInlineSourceMap(bundleSource)) {\n return undefined;\n }\n\n return { bundleSource: addDebugIdToBundleSource(bundleSource, debugId), sourceMapSource: undefined };\n }\n\n const map = parseSourceMap(sourceMapSource);\n if (!map) {\n return undefined;\n }\n\n setDebugIdOnSourceMap(map, debugId);\n\n return {\n bundleSource: addDebugIdToBundleSource(bundleSource, debugId),\n sourceMapSource: JSON.stringify(map),\n };\n}\n\n/**\n * Stamps the debug ID of an emitted bundle into the bundle and its source map on disk.\n *\n * Used by bundlers that offer no hook to modify assets before they are written (esbuild).\n */\nexport async function addDebugIdToEmittedArtifacts(\n bundleFilePath: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<void> {\n let bundleSource: string;\n try {\n bundleSource = await fs.promises.readFile(bundleFilePath, 'utf8');\n } catch (e) {\n logger.error(`Could not read bundle to stamp debug ID: ${bundleFilePath}`, e);\n return;\n }\n\n const sourceMapPath = await determineSourceMapPathFromBundle(\n bundleFilePath,\n bundleSource,\n logger,\n resolveSourceMapHook,\n );\n\n let sourceMapSource: string | undefined;\n if (sourceMapPath) {\n try {\n sourceMapSource = await fs.promises.readFile(sourceMapPath, 'utf8');\n } catch (e) {\n logger.error(`Could not read source map to stamp debug ID: ${sourceMapPath}`, e);\n return;\n }\n }\n\n const stamped = stampDebugId(bundleSource, sourceMapSource);\n if (!stamped) {\n logger.debug(\n `Could not stamp debug ID (no debug ID in bundle, no source map, or invalid source map): ${bundleFilePath}`,\n );\n return;\n }\n\n const writes = [fs.promises.writeFile(bundleFilePath, stamped.bundleSource, 'utf8')];\n if (sourceMapPath && stamped.sourceMapSource !== undefined) {\n writes.push(fs.promises.writeFile(sourceMapPath, stamped.sourceMapSource, 'utf8'));\n }\n\n try {\n await Promise.all(writes);\n } catch (e) {\n logger.error(`Could not write debug ID into build artifacts: ${bundleFilePath}`, e);\n }\n}\n\n/**\n * Whether the bundle carries its source map inlined as `sourceMappingURL=data:`\n * URI, rather than referencing a separate `.map` file. Such bundles must still\n * be uploaded even when no `.map` file is found, because the source file itself\n * contains the map.\n */\nfunction bundleHasInlineSourceMap(bundleSource: string): boolean {\n return /^\\s*\\/\\/# sourceMappingURL=data:/m.test(bundleSource);\n}\n\n/**\n * Applies a set of heuristics to find the source map for a particular bundle.\n *\n * @returns the path to the bundle's source map or `undefined` if none could be found.\n */\nexport async function determineSourceMapPathFromBundle(\n bundlePath: string,\n bundleSource: string,\n logger: Logger,\n resolveSourceMapHook: ResolveSourceMapHook | undefined,\n): Promise<string | undefined> {\n const sourceMappingUrlMatch = bundleSource.match(/^\\s*\\/\\/# sourceMappingURL=(.*)$/m);\n const sourceMappingUrl = sourceMappingUrlMatch ? (sourceMappingUrlMatch[1] as string) : undefined;\n\n const searchLocations: string[] = [];\n\n if (resolveSourceMapHook) {\n logger.debug(\n `Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`,\n );\n const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);\n logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);\n\n if (customPath) {\n searchLocations.push(customPath);\n }\n }\n\n // 1. try to find source map at `sourceMappingURL` location\n if (sourceMappingUrl) {\n let parsedUrl: URL | undefined;\n try {\n parsedUrl = new URL(sourceMappingUrl);\n } catch {\n // noop\n }\n\n if (parsedUrl?.protocol === 'file:') {\n searchLocations.push(url.fileURLToPath(sourceMappingUrl));\n } else if (parsedUrl) {\n // noop, non-file urls don't translate to a local sourcemap file\n } else if (path.isAbsolute(sourceMappingUrl)) {\n searchLocations.push(path.normalize(sourceMappingUrl));\n } else {\n searchLocations.push(path.normalize(path.join(path.dirname(bundlePath), sourceMappingUrl)));\n }\n }\n\n // 2. try to find source map at path adjacent to chunk source, but with `.map` appended\n searchLocations.push(`${bundlePath}.map`);\n\n for (const searchLocation of searchLocations) {\n try {\n await util.promisify(fs.access)(searchLocation);\n logger.debug(`Source map found for bundle \\`${bundlePath}\\`: \\`${searchLocation}\\``);\n return searchLocation;\n } catch {\n // noop\n }\n }\n\n // This is just a debug message because it can be quite spammy for some frameworks\n logger.debug(\n `Could not determine source map path for bundle \\`${bundlePath}\\`` +\n ` with sourceMappingURL=${sourceMappingUrl === undefined ? 'undefined' : `\\`${sourceMappingUrl}\\``}` +\n ` - Did you turn on source map generation in your bundler?` +\n ` (Attempted paths: ${searchLocations.map(e => `\\`${e}\\``).join(', ')})`,\n );\n return undefined;\n}\n\nconst PROTOCOL_REGEX = /^[a-zA-Z][a-zA-Z0-9+\\-.]*:\\/\\//;\nexport function defaultRewriteSourcesHook(source: string): string {\n if (source.match(PROTOCOL_REGEX)) {\n return source.replace(PROTOCOL_REGEX, '');\n } else {\n return path.relative(process.cwd(), path.normalize(source));\n }\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,4BAA4B,EAAE,4BAAwD;CACpG,OAAO,OAAO,oBAA8B,SAAuC;EAGjF,MAAM,eAAe,mBAAmB,IAAIA,cAAAA,yBAAyB;EACrE,OAAO,yBAAyB,iBAAiB,cAAc,IAAI;CACrE;AACF;;AAMA,eAAsB,8BACpB,gBACA,cACA,YACA,QACA,oBACA,sBACqC;CACrC,IAAI;CACJ,IAAI;EACF,gBAAgB,MAAMC,GAAAA,QAAG,SAAS,SAAS,gBAAgB,MAAM;CACnE,SAAS,GAAG;EACV,OAAO,MAAM,+DAA+D,kBAAkB,CAAC;EAC/F;CACF;CAEA,IAAI,iCAAiC,aAAa,MAAM,KAAA,GAAW;EACjE,OAAO,MACL,0KAA0K,gBAC5K;EACA;CACF;CAEA,MAAM,gBAAgB,MAAM,iCAC1B,gBACA,eACA,QACA,oBACF;CAEA,IAAI;CACJ,IAAI,eACF,IAAI;EACF,kBAAkB,MAAMA,GAAAA,QAAG,SAAS,SAAS,eAAe,MAAM;CACpE,SAAS,GAAG;EACV,OAAO,MAAM,kDAAkD,iBAAiB,CAAC;EACjF;CACF;CAGF,MAAM,SAAS,yBAAyB;EACtC,MAAM;EACN,WAAW;EACX,QAAQC,KAAAA,QAAK,QAAQ,iBAAiB,cAAc;EACpD;CACF,CAAC;CAED,IAAI,CAAC,OAAO,IAAI;EACd,IAAI,OAAO,WAAW,sBACpB,OAAO,MAAM,mDAAmD,eAAe;OAM/E,OAAO,MAAM,8CAA8C,gBAAgB;EAE7E;CACF;CAEA,MAAM,sBAAsB,cAAc,GAAG,OAAO,SAAS,QAAQ,GAAG,cAAc,OAAO,QAAQ;CACrG,OAAO,EAAE,cAAc;AACzB;;;;;;;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