@sentry/svelte 10.53.1 → 10.55.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.
@@ -3,54 +3,29 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const preprocessors = require('./preprocessors.js');
4
4
 
5
5
  const defaultSentryOptions = {
6
- componentTracking: preprocessors.defaultComponentTrackingOptions,
6
+ componentTracking: preprocessors.defaultComponentTrackingOptions
7
7
  };
8
-
9
- /**
10
- * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.
11
- *
12
- * @param originalConfig The existing config to be exported prior to adding Sentry
13
- * @param sentryOptions The configuration of the Sentry-added options
14
- *
15
- * @return The wrapped and modified config to be exported
16
- */
17
- function withSentryConfig(
18
- originalConfig,
19
- sentryOptions,
20
- ) {
8
+ function withSentryConfig(originalConfig, sentryOptions) {
21
9
  const mergedOptions = {
22
10
  ...sentryOptions,
23
11
  componentTracking: {
24
12
  ...defaultSentryOptions.componentTracking,
25
- ...sentryOptions?.componentTracking,
26
- },
13
+ ...sentryOptions?.componentTracking
14
+ }
27
15
  };
28
-
29
16
  const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);
30
-
31
- // Bail if users already added the preprocessor
32
- if (originalPreprocessors.find((p) => !!(p ).sentryId)) {
17
+ if (originalPreprocessors.find((p) => !!p.sentryId)) {
33
18
  return originalConfig;
34
19
  }
35
-
36
20
  const mergedPreprocessors = [...originalPreprocessors];
37
21
  if (mergedOptions.componentTracking.trackComponents) {
38
22
  mergedPreprocessors.unshift(preprocessors.componentTrackingPreprocessor(mergedOptions.componentTracking));
39
23
  }
40
-
41
24
  return {
42
25
  ...originalConfig,
43
- preprocess: mergedPreprocessors,
26
+ preprocess: mergedPreprocessors
44
27
  };
45
28
  }
46
-
47
- /**
48
- * Standardizes the different ways the user-provided preprocessor option can be specified.
49
- * Users can specify an array of preprocessors, a single one or no preprocessor.
50
- *
51
- * @param originalConfig the user-provided svelte config oject
52
- * @return an array of preprocessors or an empty array if no preprocessors were specified
53
- */
54
29
  function getOriginalPreprocessorArray(originalConfig) {
55
30
  if (originalConfig.preprocess) {
56
31
  if (Array.isArray(originalConfig.preprocess)) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst defaultSentryOptions: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...defaultSentryOptions,\n ...sentryOptions,\n componentTracking: {\n ...defaultSentryOptions.componentTracking,\n ...sentryOptions?.componentTracking,\n },\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Bail if users already added the preprocessor\n if (originalPreprocessors.find((p: PreprocessorGroup) => !!(p as SentryPreprocessorGroup).sentryId)) {\n return originalConfig;\n }\n\n const mergedPreprocessors = [...originalPreprocessors];\n if (mergedOptions.componentTracking.trackComponents) {\n mergedPreprocessors.unshift(componentTrackingPreprocessor(mergedOptions.componentTracking));\n }\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":["defaultComponentTrackingOptions","componentTrackingPreprocessor"],"mappings":";;;;AAIA,MAAM,oBAAoB,GAA8B;AACxD,EAAE,iBAAiB,EAAEA,6CAA+B;AACpD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB;AAChC,EAAE,cAAc;AAChB,EAAE,aAAa;AACf,EAAgB;AAChB,EAAE,MAAM,gBAAgB;AACxB,IACI,GAAG,aAAa;AACpB,IAAI,iBAAiB,EAAE;AACvB,MAAM,GAAG,oBAAoB,CAAC,iBAAiB;AAC/C,MAAM,GAAG,aAAa,EAAE,iBAAiB;AACzC,KAAK;AACL,GAAG;;AAEH,EAAE,MAAM,qBAAA,GAAwB,4BAA4B,CAAC,cAAc,CAAC;;AAE5E;AACA,EAAE,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAwB,CAAC,CAAC,CAAC,CAAA,GAA8B,QAAQ,CAAC,EAAE;AACvG,IAAI,OAAO,cAAc;AACzB,EAAE;;AAEF,EAAE,MAAM,mBAAA,GAAsB,CAAC,GAAG,qBAAqB,CAAC;AACxD,EAAE,IAAI,aAAa,CAAC,iBAAiB,CAAC,eAAe,EAAE;AACvD,IAAI,mBAAmB,CAAC,OAAO,CAACC,2CAA6B,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAC/F,EAAE;;AAEF,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,UAAU,EAAE,mBAAmB;AACnC,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B,CAAC,cAAc,EAAqC;AACzF,EAAE,IAAI,cAAc,CAAC,UAAU,EAAE;AACjC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;AAClD,MAAM,OAAO,cAAc,CAAC,UAAU;AACtC,IAAI;AACJ,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC,EAAE;AACF,EAAE,OAAO,EAAE;AACX;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst defaultSentryOptions: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...defaultSentryOptions,\n ...sentryOptions,\n componentTracking: {\n ...defaultSentryOptions.componentTracking,\n ...sentryOptions?.componentTracking,\n },\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Bail if users already added the preprocessor\n if (originalPreprocessors.find((p: PreprocessorGroup) => !!(p as SentryPreprocessorGroup).sentryId)) {\n return originalConfig;\n }\n\n const mergedPreprocessors = [...originalPreprocessors];\n if (mergedOptions.componentTracking.trackComponents) {\n mergedPreprocessors.unshift(componentTrackingPreprocessor(mergedOptions.componentTracking));\n }\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":["defaultComponentTrackingOptions","componentTrackingPreprocessor"],"mappings":";;;;AAIA,MAAM,oBAAA,GAAkD;AAAA,EACtD,iBAAA,EAAmBA;AACrB,CAAA;AAUO,SAAS,gBAAA,CACd,gBACA,aAAA,EACc;AACd,EAAA,MAAM,aAAA,GAAgB;AAAA,IAEpB,GAAG,aAAA;AAAA,IACH,iBAAA,EAAmB;AAAA,MACjB,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,GAAG,aAAA,EAAe;AAAA;AACpB,GACF;AAEA,EAAA,MAAM,qBAAA,GAAwB,6BAA6B,cAAc,CAAA;AAGzE,EAAA,IAAI,qBAAA,CAAsB,KAAK,CAAC,CAAA,KAAyB,CAAC,CAAE,CAAA,CAA8B,QAAQ,CAAA,EAAG;AACnG,IAAA,OAAO,cAAA;AAAA,EACT;AAEA,EAAA,MAAM,mBAAA,GAAsB,CAAC,GAAG,qBAAqB,CAAA;AACrD,EAAA,IAAI,aAAA,CAAc,kBAAkB,eAAA,EAAiB;AACnD,IAAA,mBAAA,CAAoB,OAAA,CAAQC,2CAAA,CAA8B,aAAA,CAAc,iBAAiB,CAAC,CAAA;AAAA,EAC5F;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,cAAA;AAAA,IACH,UAAA,EAAY;AAAA,GACd;AACF;AASA,SAAS,6BAA6B,cAAA,EAAmD;AACvF,EAAA,IAAI,eAAe,UAAA,EAAY;AAC7B,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,cAAA,CAAe,UAAU,CAAA,EAAG;AAC5C,MAAA,OAAO,cAAA,CAAe,UAAA;AAAA,IACxB;AACA,IAAA,OAAO,CAAC,eAAe,UAAU,CAAA;AAAA,EACnC;AACA,EAAA,OAAO,EAAC;AACV;;;;"}
@@ -1,10 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- /**
4
- * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
5
- *
6
- * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
7
- */
8
3
  const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
9
4
 
10
5
  exports.DEBUG_BUILD = DEBUG_BUILD;
@@ -1 +1 @@
1
- {"version":3,"file":"debug_build.js","sources":["../../src/debug_build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
1
+ {"version":3,"file":"debug_build.js","sources":["../../src/debug_build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":";;AAOO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
@@ -5,75 +5,54 @@ const core = require('@sentry/core');
5
5
  const svelte = require('svelte');
6
6
  const debug_build = require('./debug_build.js');
7
7
 
8
- const defaultTrackComponentOptions
9
-
10
- = {
8
+ const defaultTrackComponentOptions = {
11
9
  trackInit: true,
12
- trackUpdates: false,
10
+ trackUpdates: false
13
11
  };
14
-
15
- /**
16
- * Tracks the Svelte component's initialization and mounting operation as well as
17
- * updates and records them as spans.
18
- *
19
- * This function is injected automatically into your Svelte components' code
20
- * if you are using the withSentryConfig wrapper.
21
- *
22
- * Alternatively, you can call it yourself if you don't want to use the preprocessor.
23
- */
24
12
  function trackComponent(options) {
25
13
  const mergedOptions = { ...defaultTrackComponentOptions, ...options };
26
-
27
14
  const customComponentName = mergedOptions.componentName;
28
-
29
- const componentName = `<${customComponentName || 'Svelte Component'}>`;
30
-
15
+ const componentName = `<${customComponentName || "Svelte Component"}>`;
31
16
  if (mergedOptions.trackInit) {
32
17
  recordInitSpan(componentName);
33
18
  }
34
-
35
19
  if (mergedOptions.trackUpdates) {
36
20
  try {
37
21
  recordUpdateSpans(componentName);
38
22
  } catch {
39
- debug_build.DEBUG_BUILD &&
40
- core.debug.warn(
41
- "Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.",
42
- );
23
+ debug_build.DEBUG_BUILD && core.debug.warn(
24
+ "Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning."
25
+ );
43
26
  }
44
27
  }
45
28
  }
46
-
47
29
  function recordInitSpan(componentName) {
48
30
  const initSpan = core.startInactiveSpan({
49
31
  onlyIfParent: true,
50
- op: 'ui.svelte.init',
32
+ op: "ui.svelte.init",
51
33
  name: componentName,
52
- attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
34
+ attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.svelte" }
53
35
  });
54
-
55
36
  svelte.onMount(() => {
56
37
  initSpan.end();
57
38
  });
58
39
  }
59
-
60
40
  function recordUpdateSpans(componentName) {
61
41
  let updateSpan;
62
42
  svelte.beforeUpdate(() => {
63
43
  updateSpan = core.startInactiveSpan({
64
44
  onlyIfParent: true,
65
- op: 'ui.svelte.update',
45
+ op: "ui.svelte.update",
66
46
  name: componentName,
67
- attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
47
+ attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.svelte" }
68
48
  });
69
49
  });
70
-
71
50
  svelte.afterUpdate(() => {
72
51
  if (!updateSpan) {
73
52
  return;
74
53
  }
75
54
  updateSpan.end();
76
- updateSpan = undefined;
55
+ updateSpan = void 0;
77
56
  });
78
57
  }
79
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';\nimport type { Span } from '@sentry/core';\nimport { debug, startInactiveSpan } from '@sentry/core';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { DEBUG_BUILD } from './debug_build';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: false,\n};\n\n/**\n * Tracks the Svelte component's initialization and mounting operation as well as\n * updates and records them as spans.\n *\n * This function is injected automatically into your Svelte components' code\n * if you are using the withSentryConfig wrapper.\n *\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const customComponentName = mergedOptions.componentName;\n\n const componentName = `<${customComponentName || 'Svelte Component'}>`;\n\n if (mergedOptions.trackInit) {\n recordInitSpan(componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n try {\n recordUpdateSpans(componentName);\n } catch {\n DEBUG_BUILD &&\n debug.warn(\n \"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.\",\n );\n }\n }\n}\n\nfunction recordInitSpan(componentName: string): void {\n const initSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.init',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n\n onMount(() => {\n initSpan.end();\n });\n}\n\nfunction recordUpdateSpans(componentName: string): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n updateSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.update',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n"],"names":["DEBUG_BUILD","debug","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","onMount","beforeUpdate","afterUpdate"],"mappings":";;;;;;;AAOA,MAAM;;AAIN,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,KAAK;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAgC;AACtE,EAAE,MAAM,gBAAgB,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAA,EAAS;;AAEvE,EAAE,MAAM,mBAAA,GAAsB,aAAa,CAAC,aAAa;;AAEzD,EAAE,MAAM,aAAA,GAAgB,CAAC,CAAC,EAAE,mBAAA,IAAuB,kBAAkB,CAAC,CAAC,CAAC;;AAExE,EAAE,IAAI,aAAa,CAAC,SAAS,EAAE;AAC/B,IAAI,cAAc,CAAC,aAAa,CAAC;AACjC,EAAE;;AAEF,EAAE,IAAI,aAAa,CAAC,YAAY,EAAE;AAClC,IAAI,IAAI;AACR,MAAM,iBAAiB,CAAC,aAAa,CAAC;AACtC,IAAI,EAAE,MAAM;AACZ,MAAMA,uBAAA;AACN,QAAQC,UAAK,CAAC,IAAI;AAClB,UAAU,0LAA0L;AACpM,SAAS;AACT,IAAI;AACJ,EAAE;AACF;;AAEA,SAAS,cAAc,CAAC,aAAa,EAAgB;AACrD,EAAE,MAAM,QAAA,GAAWC,sBAAiB,CAAC;AACrC,IAAI,YAAY,EAAE,IAAI;AACtB,IAAI,EAAE,EAAE,gBAAgB;AACxB,IAAI,IAAI,EAAE,aAAa;AACvB,IAAI,UAAU,EAAE,EAAE,CAACC,wCAAgC,GAAG,kBAAkB;AACxE,GAAG,CAAC;;AAEJ,EAAEC,cAAO,CAAC,MAAM;AAChB,IAAI,QAAQ,CAAC,GAAG,EAAE;AAClB,EAAE,CAAC,CAAC;AACJ;;AAEA,SAAS,iBAAiB,CAAC,aAAa,EAAgB;AACxD,EAAE,IAAI,UAAU;AAChB,EAAEC,mBAAY,CAAC,MAAM;AACrB,IAAI,UAAA,GAAaH,sBAAiB,CAAC;AACnC,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,EAAE,EAAE,kBAAkB;AAC5B,MAAM,IAAI,EAAE,aAAa;AACzB,MAAM,UAAU,EAAE,EAAE,CAACC,wCAAgC,GAAG,kBAAkB;AAC1E,KAAK,CAAC;AACN,EAAE,CAAC,CAAC;;AAEJ,EAAEG,kBAAW,CAAC,MAAM;AACpB,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM;AACN,IAAI;AACJ,IAAI,UAAU,CAAC,GAAG,EAAE;AACpB,IAAI,UAAA,GAAa,SAAS;AAC1B,EAAE,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';\nimport type { Span } from '@sentry/core';\nimport { debug, startInactiveSpan } from '@sentry/core';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { DEBUG_BUILD } from './debug_build';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: false,\n};\n\n/**\n * Tracks the Svelte component's initialization and mounting operation as well as\n * updates and records them as spans.\n *\n * This function is injected automatically into your Svelte components' code\n * if you are using the withSentryConfig wrapper.\n *\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const customComponentName = mergedOptions.componentName;\n\n const componentName = `<${customComponentName || 'Svelte Component'}>`;\n\n if (mergedOptions.trackInit) {\n recordInitSpan(componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n try {\n recordUpdateSpans(componentName);\n } catch {\n DEBUG_BUILD &&\n debug.warn(\n \"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.\",\n );\n }\n }\n}\n\nfunction recordInitSpan(componentName: string): void {\n const initSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.init',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n\n onMount(() => {\n initSpan.end();\n });\n}\n\nfunction recordUpdateSpans(componentName: string): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n updateSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.update',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n"],"names":["DEBUG_BUILD","debug","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","onMount","beforeUpdate","afterUpdate"],"mappings":";;;;;;;AAOA,MAAM,4BAAA,GAIF;AAAA,EACF,SAAA,EAAW,IAAA;AAAA,EACX,YAAA,EAAc;AAChB,CAAA;AAWO,SAAS,eAAe,OAAA,EAAuC;AACpE,EAA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f,MAAA;AAAA,IACF;AACA,IAAA,UAAA,CAAW,GAAA,EAAI;AACf,IAAA,UAAA,GAAa,MAAA;AAAA,EACf,CAAC,CAAA;AACH;;;;"}
@@ -5,132 +5,79 @@ const MagicString = require('magic-string');
5
5
  const defaultComponentTrackingOptions = {
6
6
  trackComponents: true,
7
7
  trackInit: true,
8
- trackUpdates: false,
8
+ trackUpdates: false
9
9
  };
10
-
11
- const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';
12
-
13
- /**
14
- * Svelte Preprocessor to inject Sentry performance monitoring related code
15
- * into Svelte components.
16
- */
10
+ const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = "FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR";
17
11
  function componentTrackingPreprocessor(options) {
18
12
  const mergedOptions = { ...defaultComponentTrackingOptions, ...options };
19
-
20
- const visitedFiles = new Set();
21
- const visitedFilesMarkup = new Set();
22
-
13
+ const visitedFiles = /* @__PURE__ */ new Set();
14
+ const visitedFilesMarkup = /* @__PURE__ */ new Set();
23
15
  const preprocessor = {
24
16
  // This markup hook is called once per .svelte component file, before the `script` hook is called
25
17
  // We use it to check if the passed component has a <script> tag. If it doesn't, we add one to inject our
26
18
  // code later on, when the `script` hook is executed.
27
19
  markup: ({ content, filename }) => {
28
- const finalFilename = filename || 'unknown';
20
+ const finalFilename = filename || "unknown";
29
21
  const shouldInject = shouldInjectFunction(mergedOptions.trackComponents, finalFilename, {}, visitedFilesMarkup);
30
-
31
22
  if (shouldInject && !hasScriptTag(content)) {
32
- // Insert a <script> tag into the component file where we can later on inject our code.
33
- // We have to add a placeholder to the script tag because for empty script tags,
34
- // the `script` preprocessor hook won't be called
35
- // Note: The space between <script> and </script> is important! Without any content,
36
- // the `script` hook wouldn't be executed for the added script tag.
37
23
  const s = new MagicString.default(content);
38
- s.prepend('<script>\n</script>\n');
24
+ s.prepend("<script>\n<\/script>\n");
39
25
  return { code: s.toString(), map: s.generateMap().toString() };
40
26
  }
41
-
42
27
  return { code: content };
43
28
  },
44
-
45
29
  // This script hook is called whenever a Svelte component's <script> content is preprocessed.
46
30
  // `content` contains the script code as a string
47
31
  script: ({ content, filename, attributes }) => {
48
- // TODO: Not sure when a filename could be undefined. Using this 'unknown' fallback for the time being
49
- const finalFilename = filename || 'unknown';
50
-
32
+ const finalFilename = filename || "unknown";
51
33
  if (!shouldInjectFunction(mergedOptions.trackComponents, finalFilename, attributes, visitedFiles)) {
52
34
  return { code: content };
53
35
  }
54
-
55
36
  const { trackInit, trackUpdates } = mergedOptions;
56
37
  const trackComponentOptions = {
57
38
  trackInit,
58
39
  trackUpdates,
59
- componentName: getBaseName(finalFilename),
40
+ componentName: getBaseName(finalFilename)
60
41
  };
61
-
62
42
  const importStmt = 'import { trackComponent } from "@sentry/svelte";\n';
63
- const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});\n`;
64
-
43
+ const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});
44
+ `;
65
45
  const s = new MagicString.default(content);
66
46
  s.prepend(functionCall).prepend(importStmt);
67
-
68
47
  const updatedCode = s.toString();
69
48
  const updatedSourceMap = s.generateMap().toString();
70
-
71
49
  return { code: updatedCode, map: updatedSourceMap };
72
- },
50
+ }
73
51
  };
74
-
75
52
  const sentryPreprocessor = {
76
53
  ...preprocessor,
77
- sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID,
54
+ sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID
78
55
  };
79
-
80
56
  return sentryPreprocessor;
81
57
  }
82
-
83
- function shouldInjectFunction(
84
- trackComponents,
85
- filename,
86
- attributes,
87
- visitedFiles,
88
- ) {
89
- // We do cannot inject our function multiple times into the same component
90
- // This can happen when a component has multiple <script> blocks
58
+ function shouldInjectFunction(trackComponents, filename, attributes, visitedFiles) {
91
59
  if (visitedFiles.has(filename)) {
92
60
  return false;
93
61
  }
94
62
  visitedFiles.add(filename);
95
-
96
- // We can't inject our function call into <script context="module"> blocks
97
- // because the code inside is not executed when the component is instantiated but
98
- // when the module is first imported.
99
- // see: https://svelte.dev/docs#component-format-script-context-module
100
- if (attributes.module || attributes.context === 'module') {
63
+ if (attributes.module || attributes.context === "module") {
101
64
  return false;
102
65
  }
103
-
104
66
  if (!trackComponents) {
105
67
  return false;
106
68
  }
107
-
108
69
  if (Array.isArray(trackComponents)) {
109
70
  const componentName = getBaseName(filename);
110
- return trackComponents.some(allowed => allowed === componentName);
71
+ return trackComponents.some((allowed) => allowed === componentName);
111
72
  }
112
-
113
73
  return true;
114
74
  }
115
-
116
75
  function getBaseName(filename) {
117
- const segments = filename.split('/');
118
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
119
- return segments[segments.length - 1].replace('.svelte', '');
76
+ const segments = filename.split("/");
77
+ return segments[segments.length - 1].replace(".svelte", "");
120
78
  }
121
-
122
79
  function hasScriptTag(content) {
123
- // This regex is taken from the Svelte compiler code.
124
- // They use this regex to find matching script tags that are passed to the `script` preprocessor hook:
125
- // https://github.com/sveltejs/svelte/blob/bb83eddfc623437528f24e9fe210885b446e72fa/src/compiler/preprocess/index.ts#L144
126
- // However, we remove the first part of the regex to not match HTML comments
127
80
  const scriptTagRegex = /<script(\s[^]*?)?(?:>([^]*?)<\/script\s*>|\/>)/gi;
128
-
129
- // Regex testing is not a super safe way of checking for the presence of a <script> tag in the Svelte
130
- // component file but I think we can use it as a start.
131
- // A case that is not covered by regex-testing HTML is e.g. nested <script> tags but I cannot
132
- // think of why one would do this in Svelte components. For instance, the Svelte compiler errors
133
- // when there's more than one top-level script tag.
134
81
  return scriptTagRegex.test(content);
135
82
  }
136
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"preprocessors.js","sources":["../../src/preprocessors.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';\n\nexport const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {\n trackComponents: true,\n trackInit: true,\n trackUpdates: false,\n};\n\nexport const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';\n\n/**\n * Svelte Preprocessor to inject Sentry performance monitoring related code\n * into Svelte components.\n */\nexport function componentTrackingPreprocessor(options?: ComponentTrackingInitOptions): PreprocessorGroup {\n const mergedOptions = { ...defaultComponentTrackingOptions, ...options };\n\n const visitedFiles = new Set<string>();\n const visitedFilesMarkup = new Set<string>();\n\n const preprocessor: PreprocessorGroup = {\n // This markup hook is called once per .svelte component file, before the `script` hook is called\n // We use it to check if the passed component has a <script> tag. If it doesn't, we add one to inject our\n // code later on, when the `script` hook is executed.\n markup: ({ content, filename }) => {\n const finalFilename = filename || 'unknown';\n const shouldInject = shouldInjectFunction(mergedOptions.trackComponents, finalFilename, {}, visitedFilesMarkup);\n\n if (shouldInject && !hasScriptTag(content)) {\n // Insert a <script> tag into the component file where we can later on inject our code.\n // We have to add a placeholder to the script tag because for empty script tags,\n // the `script` preprocessor hook won't be called\n // Note: The space between <script> and </script> is important! Without any content,\n // the `script` hook wouldn't be executed for the added script tag.\n const s = new MagicString(content);\n s.prepend('<script>\\n</script>\\n');\n return { code: s.toString(), map: s.generateMap().toString() };\n }\n\n return { code: content };\n },\n\n // This script hook is called whenever a Svelte component's <script> content is preprocessed.\n // `content` contains the script code as a string\n script: ({ content, filename, attributes }) => {\n // TODO: Not sure when a filename could be undefined. Using this 'unknown' fallback for the time being\n const finalFilename = filename || 'unknown';\n\n if (!shouldInjectFunction(mergedOptions.trackComponents, finalFilename, attributes, visitedFiles)) {\n return { code: content };\n }\n\n const { trackInit, trackUpdates } = mergedOptions;\n const trackComponentOptions: TrackComponentOptions = {\n trackInit,\n trackUpdates,\n componentName: getBaseName(finalFilename),\n };\n\n const importStmt = 'import { trackComponent } from \"@sentry/svelte\";\\n';\n const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});\\n`;\n\n const s = new MagicString(content);\n s.prepend(functionCall).prepend(importStmt);\n\n const updatedCode = s.toString();\n const updatedSourceMap = s.generateMap().toString();\n\n return { code: updatedCode, map: updatedSourceMap };\n },\n };\n\n const sentryPreprocessor: SentryPreprocessorGroup = {\n ...preprocessor,\n sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID,\n };\n\n return sentryPreprocessor;\n}\n\nfunction shouldInjectFunction(\n trackComponents: Required<ComponentTrackingInitOptions['trackComponents']>,\n filename: string,\n attributes: Record<string, string | boolean>,\n visitedFiles: Set<string>,\n): boolean {\n // We do cannot inject our function multiple times into the same component\n // This can happen when a component has multiple <script> blocks\n if (visitedFiles.has(filename)) {\n return false;\n }\n visitedFiles.add(filename);\n\n // We can't inject our function call into <script context=\"module\"> blocks\n // because the code inside is not executed when the component is instantiated but\n // when the module is first imported.\n // see: https://svelte.dev/docs#component-format-script-context-module\n if (attributes.module || attributes.context === 'module') {\n return false;\n }\n\n if (!trackComponents) {\n return false;\n }\n\n if (Array.isArray(trackComponents)) {\n const componentName = getBaseName(filename);\n return trackComponents.some(allowed => allowed === componentName);\n }\n\n return true;\n}\n\nfunction getBaseName(filename: string): string {\n const segments = filename.split('/');\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return segments[segments.length - 1]!.replace('.svelte', '');\n}\n\nfunction hasScriptTag(content: string): boolean {\n // This regex is taken from the Svelte compiler code.\n // They use this regex to find matching script tags that are passed to the `script` preprocessor hook:\n // https://github.com/sveltejs/svelte/blob/bb83eddfc623437528f24e9fe210885b446e72fa/src/compiler/preprocess/index.ts#L144\n // However, we remove the first part of the regex to not match HTML comments\n const scriptTagRegex = /<script(\\s[^]*?)?(?:>([^]*?)<\\/script\\s*>|\\/>)/gi;\n\n // Regex testing is not a super safe way of checking for the presence of a <script> tag in the Svelte\n // component file but I think we can use it as a start.\n // A case that is not covered by regex-testing HTML is e.g. nested <script> tags but I cannot\n // think of why one would do this in Svelte components. For instance, the Svelte compiler errors\n // when there's more than one top-level script tag.\n return scriptTagRegex.test(content);\n}\n"],"names":["MagicString"],"mappings":";;;;AAIO,MAAM,+BAA+B,GAA2C;AACvF,EAAE,eAAe,EAAE,IAAI;AACvB,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,KAAK;AACrB;;AAEO,MAAM,wCAAA,GAA2C;;AAExD;AACA;AACA;AACA;AACO,SAAS,6BAA6B,CAAC,OAAO,EAAoD;AACzG,EAAE,MAAM,gBAAgB,EAAE,GAAG,+BAA+B,EAAE,GAAG,OAAA,EAAS;;AAE1E,EAAE,MAAM,YAAA,GAAe,IAAI,GAAG,EAAU;AACxC,EAAE,MAAM,kBAAA,GAAqB,IAAI,GAAG,EAAU;;AAE9C,EAAE,MAAM,YAAY,GAAsB;AAC1C;AACA;AACA;AACA,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,QAAA,EAAU,KAAK;AACvC,MAAM,MAAM,aAAA,GAAgB,QAAA,IAAY,SAAS;AACjD,MAAM,MAAM,YAAA,GAAe,oBAAoB,CAAC,aAAa,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,EAAE,kBAAkB,CAAC;;AAErH,MAAM,IAAI,YAAA,IAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;AAClD;AACA;AACA;AACA;AACA;AACA,QAAQ,MAAM,CAAA,GAAI,IAAIA,mBAAW,CAAC,OAAO,CAAC;AAC1C,QAAQ,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC;AAC1C,QAAQ,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAC,EAAG;AACtE,MAAM;;AAEN,MAAM,OAAO,EAAE,IAAI,EAAE,SAAS;AAC9B,IAAI,CAAC;;AAEL;AACA;AACA,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO,EA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A,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;AAClC,IAAI,OAAO,KAAK;AAChB,EAAE;AACF,EAAE,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;;AAE5B;AACA;AACA;AACA;AACA,EAAE,IAAI,UAAU,CAAC,MAAA,IAAU,UAAU,CAAC,OAAA,KAAY,QAAQ,EAAE;AAC5D,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,CAAC,eAAe,EAAE;AACxB,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;AACtC,IAAI,MAAM,aAAA,GAAgB,WAAW,CAAC,QAAQ,CAAC;AAC/C,IAAI,OAAO,eAAe,CAAC,IAAI,CAAC,WAAW,OAAA,KAAY,aAAa,CAAC;AACrE,EAAE;;AAEF,EAAE,OAAO,IAAI;AACb;;AAEA,SAAS,WAAW,CAAC,QAAQ,EAAkB;AAC/C,EAAE,MAAM,WAAW,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC;AACtC;AACA,EAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAA,GAAS,CAAC,CAAC,CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AAC9D;;AAEA,SAAS,YAAY,CAAC,OAAO,EAAmB;AAChD;AACA;AACA;AACA;AACA,EAAE,MAAM,cAAA,GAAiB,kDAAkD;;AAE3E;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;AACrC;;;;;;"}
1
+ {"version":3,"file":"preprocessors.js","sources":["../../src/preprocessors.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';\n\nexport const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {\n trackComponents: true,\n trackInit: true,\n trackUpdates: false,\n};\n\nexport const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';\n\n/**\n * Svelte Preprocessor to inject Sentry performance monitoring related code\n * into Svelte components.\n */\nexport function componentTrackingPreprocessor(options?: ComponentTrackingInitOptions): PreprocessorGroup {\n const mergedOptions = { ...defaultComponentTrackingOptions, ...options };\n\n const visitedFiles = new Set<string>();\n const visitedFilesMarkup = new Set<string>();\n\n const preprocessor: PreprocessorGroup = {\n // This markup hook is called once per .svelte component file, before the `script` hook is called\n // We use it to check if the passed component has a <script> tag. If it doesn't, we add one to inject our\n // code later on, when the `script` hook is executed.\n markup: ({ content, filename }) => {\n const finalFilename = filename || 'unknown';\n const shouldInject = shouldInjectFunction(mergedOptions.trackComponents, finalFilename, {}, visitedFilesMarkup);\n\n if (shouldInject && !hasScriptTag(content)) {\n // Insert a <script> tag into the component file where we can later on inject our code.\n // We have to add a placeholder to the script tag because for empty script tags,\n // the `script` preprocessor hook won't be called\n // Note: The space between <script> and </script> is important! Without any content,\n // the `script` hook wouldn't be executed for the added script tag.\n const s = new MagicString(content);\n s.prepend('<script>\\n</script>\\n');\n return { code: s.toString(), map: s.generateMap().toString() };\n }\n\n return { code: content };\n },\n\n // This script hook is called whenever a Svelte component's <script> content is preprocessed.\n // `content` contains the script code as a string\n script: ({ content, filename, attributes }) => {\n // TODO: Not sure when a filename could be undefined. Using this 'unknown' fallback for the time being\n const finalFilename = filename || 'unknown';\n\n if (!shouldInjectFunction(mergedOptions.trackComponents, finalFilename, attributes, visitedFiles)) {\n return { code: content };\n }\n\n const { trackInit, trackUpdates } = mergedOptions;\n const trackComponentOptions: TrackComponentOptions = {\n trackInit,\n trackUpdates,\n componentName: getBaseName(finalFilename),\n };\n\n const importStmt = 'import { trackComponent } from \"@sentry/svelte\";\\n';\n const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});\\n`;\n\n const s = new MagicString(content);\n s.prepend(functionCall).prepend(importStmt);\n\n const updatedCode = s.toString();\n const updatedSourceMap = s.generateMap().toString();\n\n return { code: updatedCode, map: updatedSourceMap };\n },\n };\n\n const sentryPreprocessor: SentryPreprocessorGroup = {\n ...preprocessor,\n sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID,\n };\n\n return sentryPreprocessor;\n}\n\nfunction shouldInjectFunction(\n trackComponents: Required<ComponentTrackingInitOptions['trackComponents']>,\n filename: string,\n attributes: Record<string, string | boolean>,\n visitedFiles: Set<string>,\n): boolean {\n // We do cannot inject our function multiple times into the same component\n // This can happen when a component has multiple <script> blocks\n if (visitedFiles.has(filename)) {\n return false;\n }\n visitedFiles.add(filename);\n\n // We can't inject our function call into <script context=\"module\"> blocks\n // because the code inside is not executed when the component is instantiated but\n // when the module is first imported.\n // see: https://svelte.dev/docs#component-format-script-context-module\n if (attributes.module || attributes.context === 'module') {\n return false;\n }\n\n if (!trackComponents) {\n return false;\n }\n\n if (Array.isArray(trackComponents)) {\n const componentName = getBaseName(filename);\n return trackComponents.some(allowed => allowed === componentName);\n }\n\n return true;\n}\n\nfunction getBaseName(filename: string): string {\n const segments = filename.split('/');\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return segments[segments.length - 1]!.replace('.svelte', '');\n}\n\nfunction hasScriptTag(content: string): boolean {\n // This regex is taken from the Svelte compiler code.\n // They use this regex to find matching script tags that are passed to the `script` preprocessor hook:\n // https://github.com/sveltejs/svelte/blob/bb83eddfc623437528f24e9fe210885b446e72fa/src/compiler/preprocess/index.ts#L144\n // However, we remove the first part of the regex to not match HTML comments\n const scriptTagRegex = /<script(\\s[^]*?)?(?:>([^]*?)<\\/script\\s*>|\\/>)/gi;\n\n // Regex testing is not a super safe way of checking for the presence of a <script> tag in the Svelte\n // component file but I think we can use it as a start.\n // A case that is not covered by regex-testing HTML is e.g. nested <script> tags but I cannot\n // think of why one would do this in Svelte components. For instance, the Svelte compiler errors\n // when there's more than one top-level script tag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B;AACpB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,eAAe,CAAA,EAAG;AAClC,IAAA,MAAM,aAAA,GAAgB,YAAY,QAAQ,CAAA;AAC1C,IAAA,OAAO,eAAA,CAAgB,IAAA,CAAK,CAAA,OAAA,KAAW,OAAA,KAAY,aAAa,CAAA;AAAA,EAClE;AAEA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,YAAY,QAAA,EAA0B;AAC7C,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA;AAEnC,EAAA,OAAO,SAAS,QAAA,CAAS,MAAA,GAAS,CAAC,CAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,CAAA;AAC7D;AAEA,SAAS,aAAa,OAAA,EAA0B;AAK9C,EAAA,MAAM,cAAA,GAAiB,kDAAA;AAOvB,EAAA,OAAO,cAAA,CAAe,KAAK,OAAO,CAAA;AACpC;;;;;;"}
package/build/cjs/sdk.js CHANGED
@@ -3,16 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const browser = require('@sentry/browser');
4
4
  const core = require('@sentry/core');
5
5
 
6
- /**
7
- * Inits the Svelte SDK
8
- */
9
6
  function init(options) {
10
7
  const opts = {
11
- ...options,
8
+ ...options
12
9
  };
13
-
14
- core.applySdkMetadata(opts, 'svelte');
15
-
10
+ core.applySdkMetadata(opts, "svelte");
16
11
  return browser.init(opts);
17
12
  }
18
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit } from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n return browserInit(opts);\n}\n"],"names":["applySdkMetadata","browserInit"],"mappings":";;;;;AAIA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAElC,EAAE,OAAOC,YAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit } from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n return browserInit(opts);\n}\n"],"names":["applySdkMetadata","browserInit"],"mappings":";;;;;AAOO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAAA,qBAAA,CAAiB,MAAM,QAAQ,CAAA;AAE/B,EAAA,OAAOC,aAAY,IAAI,CAAA;AACzB;;;;"}
@@ -1,54 +1,29 @@
1
1
  import { defaultComponentTrackingOptions, componentTrackingPreprocessor } from './preprocessors.js';
2
2
 
3
3
  const defaultSentryOptions = {
4
- componentTracking: defaultComponentTrackingOptions,
4
+ componentTracking: defaultComponentTrackingOptions
5
5
  };
6
-
7
- /**
8
- * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.
9
- *
10
- * @param originalConfig The existing config to be exported prior to adding Sentry
11
- * @param sentryOptions The configuration of the Sentry-added options
12
- *
13
- * @return The wrapped and modified config to be exported
14
- */
15
- function withSentryConfig(
16
- originalConfig,
17
- sentryOptions,
18
- ) {
6
+ function withSentryConfig(originalConfig, sentryOptions) {
19
7
  const mergedOptions = {
20
8
  ...sentryOptions,
21
9
  componentTracking: {
22
10
  ...defaultSentryOptions.componentTracking,
23
- ...sentryOptions?.componentTracking,
24
- },
11
+ ...sentryOptions?.componentTracking
12
+ }
25
13
  };
26
-
27
14
  const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);
28
-
29
- // Bail if users already added the preprocessor
30
- if (originalPreprocessors.find((p) => !!(p ).sentryId)) {
15
+ if (originalPreprocessors.find((p) => !!p.sentryId)) {
31
16
  return originalConfig;
32
17
  }
33
-
34
18
  const mergedPreprocessors = [...originalPreprocessors];
35
19
  if (mergedOptions.componentTracking.trackComponents) {
36
20
  mergedPreprocessors.unshift(componentTrackingPreprocessor(mergedOptions.componentTracking));
37
21
  }
38
-
39
22
  return {
40
23
  ...originalConfig,
41
- preprocess: mergedPreprocessors,
24
+ preprocess: mergedPreprocessors
42
25
  };
43
26
  }
44
-
45
- /**
46
- * Standardizes the different ways the user-provided preprocessor option can be specified.
47
- * Users can specify an array of preprocessors, a single one or no preprocessor.
48
- *
49
- * @param originalConfig the user-provided svelte config oject
50
- * @return an array of preprocessors or an empty array if no preprocessors were specified
51
- */
52
27
  function getOriginalPreprocessorArray(originalConfig) {
53
28
  if (originalConfig.preprocess) {
54
29
  if (Array.isArray(originalConfig.preprocess)) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst defaultSentryOptions: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...defaultSentryOptions,\n ...sentryOptions,\n componentTracking: {\n ...defaultSentryOptions.componentTracking,\n ...sentryOptions?.componentTracking,\n },\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Bail if users already added the preprocessor\n if (originalPreprocessors.find((p: PreprocessorGroup) => !!(p as SentryPreprocessorGroup).sentryId)) {\n return originalConfig;\n }\n\n const mergedPreprocessors = [...originalPreprocessors];\n if (mergedOptions.componentTracking.trackComponents) {\n mergedPreprocessors.unshift(componentTrackingPreprocessor(mergedOptions.componentTracking));\n }\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":[],"mappings":";;AAIA,MAAM,oBAAoB,GAA8B;AACxD,EAAE,iBAAiB,EAAE,+BAA+B;AACpD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB;AAChC,EAAE,cAAc;AAChB,EAAE,aAAa;AACf,EAAgB;AAChB,EAAE,MAAM,gBAAgB;AACxB,IACI,GAAG,aAAa;AACpB,IAAI,iBAAiB,EAAE;AACvB,MAAM,GAAG,oBAAoB,CAAC,iBAAiB;AAC/C,MAAM,GAAG,aAAa,EAAE,iBAAiB;AACzC,KAAK;AACL,GAAG;;AAEH,EAAE,MAAM,qBAAA,GAAwB,4BAA4B,CAAC,cAAc,CAAC;;AAE5E;AACA,EAAE,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAwB,CAAC,CAAC,CAAC,CAAA,GAA8B,QAAQ,CAAC,EAAE;AACvG,IAAI,OAAO,cAAc;AACzB,EAAE;;AAEF,EAAE,MAAM,mBAAA,GAAsB,CAAC,GAAG,qBAAqB,CAAC;AACxD,EAAE,IAAI,aAAa,CAAC,iBAAiB,CAAC,eAAe,EAAE;AACvD,IAAI,mBAAmB,CAAC,OAAO,CAAC,6BAA6B,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAC/F,EAAE;;AAEF,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,UAAU,EAAE,mBAAmB;AACnC,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B,CAAC,cAAc,EAAqC;AACzF,EAAE,IAAI,cAAc,CAAC,UAAU,EAAE;AACjC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;AAClD,MAAM,OAAO,cAAc,CAAC,UAAU;AACtC,IAAI;AACJ,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC,EAAE;AACF,EAAE,OAAO,EAAE;AACX;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst defaultSentryOptions: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...defaultSentryOptions,\n ...sentryOptions,\n componentTracking: {\n ...defaultSentryOptions.componentTracking,\n ...sentryOptions?.componentTracking,\n },\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Bail if users already added the preprocessor\n if (originalPreprocessors.find((p: PreprocessorGroup) => !!(p as SentryPreprocessorGroup).sentryId)) {\n return originalConfig;\n }\n\n const mergedPreprocessors = [...originalPreprocessors];\n if (mergedOptions.componentTracking.trackComponents) {\n mergedPreprocessors.unshift(componentTrackingPreprocessor(mergedOptions.componentTracking));\n }\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":[],"mappings":";;AAIA,MAAM,oBAAA,GAAkD;AAAA,EACtD,iBAAA,EAAmB;AACrB,CAAA;AAUO,SAAS,gBAAA,CACd,gBACA,aAAA,EACc;AACd,EAAA,MAAM,aAAA,GAAgB;AAAA,IAEpB,GAAG,aAAA;AAAA,IACH,iBAAA,EAAmB;AAAA,MACjB,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,GAAG,aAAA,EAAe;AAAA;AACpB,GACF;AAEA,EAAA,MAAM,qBAAA,GAAwB,6BAA6B,cAAc,CAAA;AAGzE,EAAA,IAAI,qBAAA,CAAsB,KAAK,CAAC,CAAA,KAAyB,CAAC,CAAE,CAAA,CAA8B,QAAQ,CAAA,EAAG;AACnG,IAAA,OAAO,cAAA;AAAA,EACT;AAEA,EAAA,MAAM,mBAAA,GAAsB,CAAC,GAAG,qBAAqB,CAAA;AACrD,EAAA,IAAI,aAAA,CAAc,kBAAkB,eAAA,EAAiB;AACnD,IAAA,mBAAA,CAAoB,OAAA,CAAQ,6BAAA,CAA8B,aAAA,CAAc,iBAAiB,CAAC,CAAA;AAAA,EAC5F;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,cAAA;AAAA,IACH,UAAA,EAAY;AAAA,GACd;AACF;AASA,SAAS,6BAA6B,cAAA,EAAmD;AACvF,EAAA,IAAI,eAAe,UAAA,EAAY;AAC7B,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,cAAA,CAAe,UAAU,CAAA,EAAG;AAC5C,MAAA,OAAO,cAAA,CAAe,UAAA;AAAA,IACxB;AACA,IAAA,OAAO,CAAC,eAAe,UAAU,CAAA;AAAA,EACnC;AACA,EAAA,OAAO,EAAC;AACV;;;;"}
@@ -1,8 +1,3 @@
1
- /**
2
- * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
3
- *
4
- * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
5
- */
6
1
  const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
7
2
 
8
3
  export { DEBUG_BUILD };
@@ -1 +1 @@
1
- {"version":3,"file":"debug_build.js","sources":["../../src/debug_build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
1
+ {"version":3,"file":"debug_build.js","sources":["../../src/debug_build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":"AAOO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.53.1","sideEffects":false}
1
+ {"type":"module","version":"10.55.0","sideEffects":false}
@@ -3,75 +3,54 @@ import { debug, startInactiveSpan } from '@sentry/core';
3
3
  import { onMount, beforeUpdate, afterUpdate } from 'svelte';
4
4
  import { DEBUG_BUILD } from './debug_build.js';
5
5
 
6
- const defaultTrackComponentOptions
7
-
8
- = {
6
+ const defaultTrackComponentOptions = {
9
7
  trackInit: true,
10
- trackUpdates: false,
8
+ trackUpdates: false
11
9
  };
12
-
13
- /**
14
- * Tracks the Svelte component's initialization and mounting operation as well as
15
- * updates and records them as spans.
16
- *
17
- * This function is injected automatically into your Svelte components' code
18
- * if you are using the withSentryConfig wrapper.
19
- *
20
- * Alternatively, you can call it yourself if you don't want to use the preprocessor.
21
- */
22
10
  function trackComponent(options) {
23
11
  const mergedOptions = { ...defaultTrackComponentOptions, ...options };
24
-
25
12
  const customComponentName = mergedOptions.componentName;
26
-
27
- const componentName = `<${customComponentName || 'Svelte Component'}>`;
28
-
13
+ const componentName = `<${customComponentName || "Svelte Component"}>`;
29
14
  if (mergedOptions.trackInit) {
30
15
  recordInitSpan(componentName);
31
16
  }
32
-
33
17
  if (mergedOptions.trackUpdates) {
34
18
  try {
35
19
  recordUpdateSpans(componentName);
36
20
  } catch {
37
- DEBUG_BUILD &&
38
- debug.warn(
39
- "Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.",
40
- );
21
+ DEBUG_BUILD && debug.warn(
22
+ "Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning."
23
+ );
41
24
  }
42
25
  }
43
26
  }
44
-
45
27
  function recordInitSpan(componentName) {
46
28
  const initSpan = startInactiveSpan({
47
29
  onlyIfParent: true,
48
- op: 'ui.svelte.init',
30
+ op: "ui.svelte.init",
49
31
  name: componentName,
50
- attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
32
+ attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.svelte" }
51
33
  });
52
-
53
34
  onMount(() => {
54
35
  initSpan.end();
55
36
  });
56
37
  }
57
-
58
38
  function recordUpdateSpans(componentName) {
59
39
  let updateSpan;
60
40
  beforeUpdate(() => {
61
41
  updateSpan = startInactiveSpan({
62
42
  onlyIfParent: true,
63
- op: 'ui.svelte.update',
43
+ op: "ui.svelte.update",
64
44
  name: componentName,
65
- attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
45
+ attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.svelte" }
66
46
  });
67
47
  });
68
-
69
48
  afterUpdate(() => {
70
49
  if (!updateSpan) {
71
50
  return;
72
51
  }
73
52
  updateSpan.end();
74
- updateSpan = undefined;
53
+ updateSpan = void 0;
75
54
  });
76
55
  }
77
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';\nimport type { Span } from '@sentry/core';\nimport { debug, startInactiveSpan } from '@sentry/core';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { DEBUG_BUILD } from './debug_build';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: false,\n};\n\n/**\n * Tracks the Svelte component's initialization and mounting operation as well as\n * updates and records them as spans.\n *\n * This function is injected automatically into your Svelte components' code\n * if you are using the withSentryConfig wrapper.\n *\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const customComponentName = mergedOptions.componentName;\n\n const componentName = `<${customComponentName || 'Svelte Component'}>`;\n\n if (mergedOptions.trackInit) {\n recordInitSpan(componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n try {\n recordUpdateSpans(componentName);\n } catch {\n DEBUG_BUILD &&\n debug.warn(\n \"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.\",\n );\n }\n }\n}\n\nfunction recordInitSpan(componentName: string): void {\n const initSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.init',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n\n onMount(() => {\n initSpan.end();\n });\n}\n\nfunction recordUpdateSpans(componentName: string): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n updateSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.update',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n"],"names":[],"mappings":";;;;;AAOA,MAAM;;AAIN,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,KAAK;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAgC;AACtE,EAAE,MAAM,gBAAgB,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAA,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AAM;AACN,IAAI;AACJ,IAAI,UAAU,CAAC,GAAG,EAAE;AACpB,IAAI,UAAA,GAAa,SAAS;AAC1B,EAAE,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';\nimport type { Span } from '@sentry/core';\nimport { debug, startInactiveSpan } from '@sentry/core';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { DEBUG_BUILD } from './debug_build';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: false,\n};\n\n/**\n * Tracks the Svelte component's initialization and mounting operation as well as\n * updates and records them as spans.\n *\n * This function is injected automatically into your Svelte components' code\n * if you are using the withSentryConfig wrapper.\n *\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const customComponentName = mergedOptions.componentName;\n\n const componentName = `<${customComponentName || 'Svelte Component'}>`;\n\n if (mergedOptions.trackInit) {\n recordInitSpan(componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n try {\n recordUpdateSpans(componentName);\n } catch {\n DEBUG_BUILD &&\n debug.warn(\n \"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.\",\n );\n }\n }\n}\n\nfunction recordInitSpan(componentName: string): void {\n const initSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.init',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n\n onMount(() => {\n initSpan.end();\n });\n}\n\nfunction recordUpdateSpans(componentName: string): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n updateSpan = startInactiveSpan({\n onlyIfParent: true,\n op: 'ui.svelte.update',\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n"],"names":[],"mappings":";;;;;AAOA,MAAM,4BAAA,GAIF;AAAA,EACF,SAAA,EAAW,IAAA;AAAA,EACX,YAAA,EAAc;AAChB,CAAA;AAWO,SAAS,eAAe,OAAA,EAAuC;AACpE,EAAA,MAAM,aAAA,GAAgB,EAAE,GAAG,4BAAA,EAA8B,GAAG,OAAA,EAAQ;AAEpE,EAAA,MAAM,sBAAsB,aAAA,CAAc,aAAA;AAE1C,EAAA,MAAM,aAAA,GAAgB,CAAA,CAAA,EAAI,mBAAA,IAAuB,kBAAkB,CAAA,CAAA,CAAA;AAEnE,EAAA,IAAI,cAAc,SAAA,EAAW;AAC3B,IAAA,cAAA,CAAe,aAAa,CAAA;AAAA,EAC9B;AAEA,EAAA,IAAI,cAAc,YAAA,EAAc;AAC9B,IAAA,IAAI;AACF,MAAA,iBAAA,CAAkB,aAAa,CAAA;AAAA,IACjC,CAAA,CAAA,MAAQ;AACN,MAAA,WAAA,IACE,KAAA,CAAM,IAAA;AAAA,QACJ;AAAA,OACF;AAAA,IACJ;AAAA,EACF;AACF;AAEA,SAAS,eAAe,aAAA,EAA6B;AACnD,EAAA,MAAM,WAAW,iBAAA,CAAkB;AAAA,IACjC,YAAA,EAAc,IAAA;AAAA,IACd,EAAA,EAAI,gBAAA;AAAA,IACJ,IAAA,EAAM,aAAA;AAAA,IACN,UAAA,EAAY,EAAE,CAAC,gCAAgC,GAAG,gBAAA;AAAiB,GACpE,CAAA;AAED,EAAA,OAAA,CAAQ,MAAM;AACZ,IAAA,QAAA,CAAS,GAAA,EAAI;AAAA,EACf,CAAC,CAAA;AACH;AAEA,SAAS,kBAAkB,aAAA,EAA6B;AACtD,EAAA,IAAI,UAAA;AACJ,EAAA,YAAA,CAAa,MAAM;AACjB,IAAA,UAAA,GAAa,iBAAA,CAAkB;AAAA,MAC7B,YAAA,EAAc,IAAA;AAAA,MACd,EAAA,EAAI,kBAAA;AAAA,MACJ,IAAA,EAAM,aAAA;AAAA,MACN,UAAA,EAAY,EAAE,CAAC,gCAAgC,GAAG,gBAAA;AAAiB,KACpE,CAAA;AAAA,EACH,CAAC,CAAA;AAED,EAAA,WAAA,CAAY,MAAM;AAChB,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA;AAAA,IACF;AACA,IAAA,UAAA,CAAW,GAAA,EAAI;AACf,IAAA,UAAA,GAAa,MAAA;AAAA,EACf,CAAC,CAAA;AACH;;;;"}
@@ -3,132 +3,79 @@ import MagicString from 'magic-string';
3
3
  const defaultComponentTrackingOptions = {
4
4
  trackComponents: true,
5
5
  trackInit: true,
6
- trackUpdates: false,
6
+ trackUpdates: false
7
7
  };
8
-
9
- const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';
10
-
11
- /**
12
- * Svelte Preprocessor to inject Sentry performance monitoring related code
13
- * into Svelte components.
14
- */
8
+ const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = "FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR";
15
9
  function componentTrackingPreprocessor(options) {
16
10
  const mergedOptions = { ...defaultComponentTrackingOptions, ...options };
17
-
18
- const visitedFiles = new Set();
19
- const visitedFilesMarkup = new Set();
20
-
11
+ const visitedFiles = /* @__PURE__ */ new Set();
12
+ const visitedFilesMarkup = /* @__PURE__ */ new Set();
21
13
  const preprocessor = {
22
14
  // This markup hook is called once per .svelte component file, before the `script` hook is called
23
15
  // We use it to check if the passed component has a <script> tag. If it doesn't, we add one to inject our
24
16
  // code later on, when the `script` hook is executed.
25
17
  markup: ({ content, filename }) => {
26
- const finalFilename = filename || 'unknown';
18
+ const finalFilename = filename || "unknown";
27
19
  const shouldInject = shouldInjectFunction(mergedOptions.trackComponents, finalFilename, {}, visitedFilesMarkup);
28
-
29
20
  if (shouldInject && !hasScriptTag(content)) {
30
- // Insert a <script> tag into the component file where we can later on inject our code.
31
- // We have to add a placeholder to the script tag because for empty script tags,
32
- // the `script` preprocessor hook won't be called
33
- // Note: The space between <script> and </script> is important! Without any content,
34
- // the `script` hook wouldn't be executed for the added script tag.
35
21
  const s = new MagicString(content);
36
- s.prepend('<script>\n</script>\n');
22
+ s.prepend("<script>\n<\/script>\n");
37
23
  return { code: s.toString(), map: s.generateMap().toString() };
38
24
  }
39
-
40
25
  return { code: content };
41
26
  },
42
-
43
27
  // This script hook is called whenever a Svelte component's <script> content is preprocessed.
44
28
  // `content` contains the script code as a string
45
29
  script: ({ content, filename, attributes }) => {
46
- // TODO: Not sure when a filename could be undefined. Using this 'unknown' fallback for the time being
47
- const finalFilename = filename || 'unknown';
48
-
30
+ const finalFilename = filename || "unknown";
49
31
  if (!shouldInjectFunction(mergedOptions.trackComponents, finalFilename, attributes, visitedFiles)) {
50
32
  return { code: content };
51
33
  }
52
-
53
34
  const { trackInit, trackUpdates } = mergedOptions;
54
35
  const trackComponentOptions = {
55
36
  trackInit,
56
37
  trackUpdates,
57
- componentName: getBaseName(finalFilename),
38
+ componentName: getBaseName(finalFilename)
58
39
  };
59
-
60
40
  const importStmt = 'import { trackComponent } from "@sentry/svelte";\n';
61
- const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});\n`;
62
-
41
+ const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});
42
+ `;
63
43
  const s = new MagicString(content);
64
44
  s.prepend(functionCall).prepend(importStmt);
65
-
66
45
  const updatedCode = s.toString();
67
46
  const updatedSourceMap = s.generateMap().toString();
68
-
69
47
  return { code: updatedCode, map: updatedSourceMap };
70
- },
48
+ }
71
49
  };
72
-
73
50
  const sentryPreprocessor = {
74
51
  ...preprocessor,
75
- sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID,
52
+ sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID
76
53
  };
77
-
78
54
  return sentryPreprocessor;
79
55
  }
80
-
81
- function shouldInjectFunction(
82
- trackComponents,
83
- filename,
84
- attributes,
85
- visitedFiles,
86
- ) {
87
- // We do cannot inject our function multiple times into the same component
88
- // This can happen when a component has multiple <script> blocks
56
+ function shouldInjectFunction(trackComponents, filename, attributes, visitedFiles) {
89
57
  if (visitedFiles.has(filename)) {
90
58
  return false;
91
59
  }
92
60
  visitedFiles.add(filename);
93
-
94
- // We can't inject our function call into <script context="module"> blocks
95
- // because the code inside is not executed when the component is instantiated but
96
- // when the module is first imported.
97
- // see: https://svelte.dev/docs#component-format-script-context-module
98
- if (attributes.module || attributes.context === 'module') {
61
+ if (attributes.module || attributes.context === "module") {
99
62
  return false;
100
63
  }
101
-
102
64
  if (!trackComponents) {
103
65
  return false;
104
66
  }
105
-
106
67
  if (Array.isArray(trackComponents)) {
107
68
  const componentName = getBaseName(filename);
108
- return trackComponents.some(allowed => allowed === componentName);
69
+ return trackComponents.some((allowed) => allowed === componentName);
109
70
  }
110
-
111
71
  return true;
112
72
  }
113
-
114
73
  function getBaseName(filename) {
115
- const segments = filename.split('/');
116
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
117
- return segments[segments.length - 1].replace('.svelte', '');
74
+ const segments = filename.split("/");
75
+ return segments[segments.length - 1].replace(".svelte", "");
118
76
  }
119
-
120
77
  function hasScriptTag(content) {
121
- // This regex is taken from the Svelte compiler code.
122
- // They use this regex to find matching script tags that are passed to the `script` preprocessor hook:
123
- // https://github.com/sveltejs/svelte/blob/bb83eddfc623437528f24e9fe210885b446e72fa/src/compiler/preprocess/index.ts#L144
124
- // However, we remove the first part of the regex to not match HTML comments
125
78
  const scriptTagRegex = /<script(\s[^]*?)?(?:>([^]*?)<\/script\s*>|\/>)/gi;
126
-
127
- // Regex testing is not a super safe way of checking for the presence of a <script> tag in the Svelte
128
- // component file but I think we can use it as a start.
129
- // A case that is not covered by regex-testing HTML is e.g. nested <script> tags but I cannot
130
- // think of why one would do this in Svelte components. For instance, the Svelte compiler errors
131
- // when there's more than one top-level script tag.
132
79
  return scriptTagRegex.test(content);
133
80
  }
134
81
 
@@ -1 +1 @@
1
- {"version":3,"file":"preprocessors.js","sources":["../../src/preprocessors.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';\n\nexport const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {\n trackComponents: true,\n trackInit: true,\n trackUpdates: false,\n};\n\nexport const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';\n\n/**\n * Svelte Preprocessor to inject Sentry performance monitoring related code\n * into Svelte components.\n */\nexport function componentTrackingPreprocessor(options?: ComponentTrackingInitOptions): PreprocessorGroup {\n const mergedOptions = { ...defaultComponentTrackingOptions, ...options };\n\n const visitedFiles = new Set<string>();\n const visitedFilesMarkup = new Set<string>();\n\n const preprocessor: PreprocessorGroup = {\n // This markup hook is called once per .svelte component file, before the `script` hook is called\n // We use it to check if the passed component has a <script> tag. If it doesn't, we add one to inject our\n // code later on, when the `script` hook is executed.\n markup: ({ content, filename }) => {\n const finalFilename = filename || 'unknown';\n const shouldInject = shouldInjectFunction(mergedOptions.trackComponents, finalFilename, {}, visitedFilesMarkup);\n\n if (shouldInject && !hasScriptTag(content)) {\n // Insert a <script> tag into the component file where we can later on inject our code.\n // We have to add a placeholder to the script tag because for empty script tags,\n // the `script` preprocessor hook won't be called\n // Note: The space between <script> and </script> is important! Without any content,\n // the `script` hook wouldn't be executed for the added script tag.\n const s = new MagicString(content);\n s.prepend('<script>\\n</script>\\n');\n return { code: s.toString(), map: s.generateMap().toString() };\n }\n\n return { code: content };\n },\n\n // This script hook is called whenever a Svelte component's <script> content is preprocessed.\n // `content` contains the script code as a string\n script: ({ content, filename, attributes }) => {\n // TODO: Not sure when a filename could be undefined. Using this 'unknown' fallback for the time being\n const finalFilename = filename || 'unknown';\n\n if (!shouldInjectFunction(mergedOptions.trackComponents, finalFilename, attributes, visitedFiles)) {\n return { code: content };\n }\n\n const { trackInit, trackUpdates } = mergedOptions;\n const trackComponentOptions: TrackComponentOptions = {\n trackInit,\n trackUpdates,\n componentName: getBaseName(finalFilename),\n };\n\n const importStmt = 'import { trackComponent } from \"@sentry/svelte\";\\n';\n const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});\\n`;\n\n const s = new MagicString(content);\n s.prepend(functionCall).prepend(importStmt);\n\n const updatedCode = s.toString();\n const updatedSourceMap = s.generateMap().toString();\n\n return { code: updatedCode, map: updatedSourceMap };\n },\n };\n\n const sentryPreprocessor: SentryPreprocessorGroup = {\n ...preprocessor,\n sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID,\n };\n\n return sentryPreprocessor;\n}\n\nfunction shouldInjectFunction(\n trackComponents: Required<ComponentTrackingInitOptions['trackComponents']>,\n filename: string,\n attributes: Record<string, string | boolean>,\n visitedFiles: Set<string>,\n): boolean {\n // We do cannot inject our function multiple times into the same component\n // This can happen when a component has multiple <script> blocks\n if (visitedFiles.has(filename)) {\n return false;\n }\n visitedFiles.add(filename);\n\n // We can't inject our function call into <script context=\"module\"> blocks\n // because the code inside is not executed when the component is instantiated but\n // when the module is first imported.\n // see: https://svelte.dev/docs#component-format-script-context-module\n if (attributes.module || attributes.context === 'module') {\n return false;\n }\n\n if (!trackComponents) {\n return false;\n }\n\n if (Array.isArray(trackComponents)) {\n const componentName = getBaseName(filename);\n return trackComponents.some(allowed => allowed === componentName);\n }\n\n return true;\n}\n\nfunction getBaseName(filename: string): string {\n const segments = filename.split('/');\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return segments[segments.length - 1]!.replace('.svelte', '');\n}\n\nfunction hasScriptTag(content: string): boolean {\n // This regex is taken from the Svelte compiler code.\n // They use this regex to find matching script tags that are passed to the `script` preprocessor hook:\n // https://github.com/sveltejs/svelte/blob/bb83eddfc623437528f24e9fe210885b446e72fa/src/compiler/preprocess/index.ts#L144\n // However, we remove the first part of the regex to not match HTML comments\n const scriptTagRegex = /<script(\\s[^]*?)?(?:>([^]*?)<\\/script\\s*>|\\/>)/gi;\n\n // Regex testing is not a super safe way of checking for the presence of a <script> tag in the Svelte\n // component file but I think we can use it as a start.\n // A case that is not covered by regex-testing HTML is e.g. nested <script> tags but I cannot\n // think of why one would do this in Svelte components. For instance, the Svelte compiler errors\n // when there's more than one top-level script tag.\n return scriptTagRegex.test(content);\n}\n"],"names":[],"mappings":";;AAIO,MAAM,+BAA+B,GAA2C;AACvF,EAAE,eAAe,EAAE,IAAI;AACvB,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,KAAK;AACrB;;AAEO,MAAM,wCAAA,GAA2C;;AAExD;AACA;AACA;AACA;AACO,SAAS,6BAA6B,CAAC,OAAO,EAAoD;AACzG,EAAE,MAAM,gBAAgB,EAAE,GAAG,+BAA+B,EAAE,GAAG,OAAA,EAAS;;AAE1E,EAAE,MAAM,YAAA,GAAe,IAAI,GAAG,EAAU;AACxC,EAAE,MAAM,kBAAA,GAAqB,IAAI,GAAG,EAAU;;AAE9C,EAAE,MAAM,YAAY,GAAsB;AAC1C;AACA;AACA;AACA,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,QAAA,EAAU,KAAK;AACvC,MAAM,MAAM,aAAA,GAAgB,QAAA,IAAY,SAAS;AACjD,MAAM,MAAM,YAAA,GAAe,oBAAoB,CAAC,aAAa,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,EAAE,kBAAkB,CAAC;;AAErH,MAAM,IAAI,YAAA,IAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;AAClD;AACA;AACA;AACA;AACA;AACA,QAAQ,MAAM,CAAA,GAAI,IAAI,WAAW,CAAC,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;;AAE3E;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;AACrC;;;;"}
1
+ {"version":3,"file":"preprocessors.js","sources":["../../src/preprocessors.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\nimport type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';\n\nexport const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {\n trackComponents: true,\n trackInit: true,\n trackUpdates: false,\n};\n\nexport const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';\n\n/**\n * Svelte Preprocessor to inject Sentry performance monitoring related code\n * into Svelte components.\n */\nexport function componentTrackingPreprocessor(options?: ComponentTrackingInitOptions): PreprocessorGroup {\n const mergedOptions = { ...defaultComponentTrackingOptions, ...options };\n\n const visitedFiles = new Set<string>();\n const visitedFilesMarkup = new Set<string>();\n\n const preprocessor: PreprocessorGroup = {\n // This markup hook is called once per .svelte component file, before the `script` hook is called\n // We use it to check if the passed component has a <script> tag. If it doesn't, we add one to inject our\n // code later on, when the `script` hook is executed.\n markup: ({ content, filename }) => {\n const finalFilename = filename || 'unknown';\n const shouldInject = shouldInjectFunction(mergedOptions.trackComponents, finalFilename, {}, visitedFilesMarkup);\n\n if (shouldInject && !hasScriptTag(content)) {\n // Insert a <script> tag into the component file where we can later on inject our code.\n // We have to add a placeholder to the script tag because for empty script tags,\n // the `script` preprocessor hook won't be called\n // Note: The space between <script> and </script> is important! Without any content,\n // the `script` hook wouldn't be executed for the added script tag.\n const s = new MagicString(content);\n s.prepend('<script>\\n</script>\\n');\n return { code: s.toString(), map: s.generateMap().toString() };\n }\n\n return { code: content };\n },\n\n // This script hook is called whenever a Svelte component's <script> content is preprocessed.\n // `content` contains the script code as a string\n script: ({ content, filename, attributes }) => {\n // TODO: Not sure when a filename could be undefined. Using this 'unknown' fallback for the time being\n const finalFilename = filename || 'unknown';\n\n if (!shouldInjectFunction(mergedOptions.trackComponents, finalFilename, attributes, visitedFiles)) {\n return { code: content };\n }\n\n const { trackInit, trackUpdates } = mergedOptions;\n const trackComponentOptions: TrackComponentOptions = {\n trackInit,\n trackUpdates,\n componentName: getBaseName(finalFilename),\n };\n\n const importStmt = 'import { trackComponent } from \"@sentry/svelte\";\\n';\n const functionCall = `trackComponent(${JSON.stringify(trackComponentOptions)});\\n`;\n\n const s = new MagicString(content);\n s.prepend(functionCall).prepend(importStmt);\n\n const updatedCode = s.toString();\n const updatedSourceMap = s.generateMap().toString();\n\n return { code: updatedCode, map: updatedSourceMap };\n },\n };\n\n const sentryPreprocessor: SentryPreprocessorGroup = {\n ...preprocessor,\n sentryId: FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID,\n };\n\n return sentryPreprocessor;\n}\n\nfunction shouldInjectFunction(\n trackComponents: Required<ComponentTrackingInitOptions['trackComponents']>,\n filename: string,\n attributes: Record<string, string | boolean>,\n visitedFiles: Set<string>,\n): boolean {\n // We do cannot inject our function multiple times into the same component\n // This can happen when a component has multiple <script> blocks\n if (visitedFiles.has(filename)) {\n return false;\n }\n visitedFiles.add(filename);\n\n // We can't inject our function call into <script context=\"module\"> blocks\n // because the code inside is not executed when the component is instantiated but\n // when the module is first imported.\n // see: https://svelte.dev/docs#component-format-script-context-module\n if (attributes.module || attributes.context === 'module') {\n return false;\n }\n\n if (!trackComponents) {\n return false;\n }\n\n if (Array.isArray(trackComponents)) {\n const componentName = getBaseName(filename);\n return trackComponents.some(allowed => allowed === componentName);\n }\n\n return true;\n}\n\nfunction getBaseName(filename: string): string {\n const segments = filename.split('/');\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return segments[segments.length - 1]!.replace('.svelte', '');\n}\n\nfunction hasScriptTag(content: string): boolean {\n // This regex is taken from the Svelte compiler code.\n // They use this regex to find matching script tags that are passed to the `script` preprocessor hook:\n // https://github.com/sveltejs/svelte/blob/bb83eddfc623437528f24e9fe210885b446e72fa/src/compiler/preprocess/index.ts#L144\n // However, we remove the first part of the regex to not match HTML comments\n const scriptTagRegex = /<script(\\s[^]*?)?(?:>([^]*?)<\\/script\\s*>|\\/>)/gi;\n\n // Regex testing is not a super safe way of checking for the presence of a <script> tag in the Svelte\n // component file but I think we can use it as a start.\n // A case that is not covered by regex-testing HTML is e.g. nested <script> tags but I cannot\n // think of why one would do this in Svelte components. For instance, the Svelte compiler errors\n // when there's more than one top-level script tag.\n return scriptTagRegex.test(content);\n}\n"],"names":[],"mappings":";;AAIO,MAAM,+BAAA,GAA0E;AAAA,EACrF,eAAA,EAAiB,IAAA;AAAA,EACjB,SAAA,EAAW,IAAA;AAAA,EACX,YAAA,EAAc;AAChB;AAEO,MAAM,wCAAA,GAA2C;AAMjD,SAAS,8BAA8B,OAAA,EAA2D;AACvG,EAAA,MAAM,aAAA,GAAgB,EAAE,GAAG,+BAAA,EAAiC,GAAG,OAAA,EAAQ;AAEvE,EAAA,MAAM,YAAA,uBAAmB,GAAA,EAAY;AACrC,EAAA,MAAM,kBAAA,uBAAyB,GAAA,EAAY;AAE3C,EAAA,MAAM,YAAA,GAAkC;AAAA;AAAA;AAAA;AAAA,IAItC,MAAA,EAAQ,CAAC,EAAE,OAAA,EAAS,UAAS,KAAM;AACjC,MAAA,MAAM,gBAAgB,QAAA,IAAY,SAAA;AAClC,MAAA,MAAM,eAAe,oBAAA,CAAqB,aAAA,CAAc,iBAAiB,aAAA,EAAe,IAAI,kBAAkB,CAAA;AAE9G,MAAA,IAAI,YAAA,IAAgB,CAAC,YAAA,CAAa,OAAO,CAAA,EAAG;AAM1C,QAAA,MAAM,CAAA,GAAI,IAAI,WAAA,CAAY,OAAO,CAAA;AACjC,QAAA,CAAA,CAAE,QAAQ,wBAAuB,CAAA;AACjC,QAAA,OAAO,EAAE,IAAA,EAAM,CAAA,CAAE,QAAA,EAAS,EAAG,KAAK,CAAA,CAAE,WAAA,EAAY,C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AA,EACA,YAAA,EACS;AAGT,EAAA,IAAI,YAAA,CAAa,GAAA,CAAI,QAAQ,CAAA,EAAG;AAC9B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,YAAA,CAAa,IAAI,QAAQ,CAAA;AAMzB,EAAA,IAAI,UAAA,CAAW,MAAA,IAAU,UAAA,CAAW,OAAA,KAAY,QAAA,EAAU;AACxD,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,CAAC,eAAA,EAAiB;AACpB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,eAAe,CAAA,EAAG;AAClC,IAAA,MAAM,aAAA,GAAgB,YAAY,QAAQ,CAAA;AAC1C,IAAA,OAAO,eAAA,CAAgB,IAAA,CAAK,CAAA,OAAA,KAAW,OAAA,KAAY,aAAa,CAAA;AAAA,EAClE;AAEA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,YAAY,QAAA,EAA0B;AAC7C,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA;AAEnC,EAAA,OAAO,SAAS,QAAA,CAAS,MAAA,GAAS,CAAC,CAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,CAAA;AAC7D;AAEA,SAAS,aAAa,OAAA,EAA0B;AAK9C,EAAA,MAAM,cAAA,GAAiB,kDAAA;AAOvB,EAAA,OAAO,cAAA,CAAe,KAAK,OAAO,CAAA;AACpC;;;;"}
package/build/esm/sdk.js CHANGED
@@ -1,16 +1,11 @@
1
1
  import { init as init$1 } from '@sentry/browser';
2
2
  import { applySdkMetadata } from '@sentry/core';
3
3
 
4
- /**
5
- * Inits the Svelte SDK
6
- */
7
4
  function init(options) {
8
5
  const opts = {
9
- ...options,
6
+ ...options
10
7
  };
11
-
12
- applySdkMetadata(opts, 'svelte');
13
-
8
+ applySdkMetadata(opts, "svelte");
14
9
  return init$1(opts);
15
10
  }
16
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit } from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n return browserInit(opts);\n}\n"],"names":["browserInit"],"mappings":";;;AAIA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAElC,EAAE,OAAOA,MAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as browserInit } from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n return browserInit(opts);\n}\n"],"names":["browserInit"],"mappings":";;;AAOO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAA,gBAAA,CAAiB,MAAM,QAAQ,CAAA;AAE/B,EAAA,OAAOA,OAAY,IAAI,CAAA;AACzB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/svelte",
3
- "version": "10.53.1",
3
+ "version": "10.55.0",
4
4
  "description": "Official Sentry SDK for Svelte",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/svelte",
@@ -39,8 +39,8 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@sentry/browser": "10.53.1",
43
- "@sentry/core": "10.53.1",
42
+ "@sentry/browser": "10.55.0",
43
+ "@sentry/core": "10.55.0",
44
44
  "magic-string": "~0.30.0"
45
45
  },
46
46
  "peerDependencies": {