@sentry/svelte 9.0.0-alpha.1 → 9.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/config.js +13 -20
- package/build/cjs/config.js.map +1 -1
- package/build/cjs/performance.js +11 -6
- package/build/cjs/performance.js.map +1 -1
- package/build/cjs/preprocessors.js +1 -1
- package/build/cjs/preprocessors.js.map +1 -1
- package/build/cjs/sdk.js +1 -46
- package/build/cjs/sdk.js.map +1 -1
- package/build/esm/config.js +13 -20
- package/build/esm/config.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/performance.js +12 -7
- package/build/esm/performance.js.map +1 -1
- package/build/esm/preprocessors.js +1 -1
- package/build/esm/preprocessors.js.map +1 -1
- package/build/esm/sdk.js +3 -46
- package/build/esm/sdk.js.map +1 -1
- package/build/types/config.d.ts.map +1 -1
- package/build/types/performance.d.ts.map +1 -1
- package/build/types/sdk.d.ts +0 -17
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/types.d.ts +5 -2
- package/build/types/types.d.ts.map +1 -1
- package/build/types-ts3.8/sdk.d.ts +0 -17
- package/build/types-ts3.8/types.d.ts +5 -2
- package/package.json +3 -3
- package/build/cjs/constants.js +0 -12
- package/build/cjs/constants.js.map +0 -1
- package/build/esm/constants.js +0 -8
- package/build/esm/constants.js.map +0 -1
- package/build/types/constants.d.ts +0 -4
- package/build/types/constants.d.ts.map +0 -1
- package/build/types-ts3.8/constants.d.ts +0 -4
package/build/cjs/config.js
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const preprocessors = require('./preprocessors.js');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const defaultSentryOptions = {
|
|
6
6
|
componentTracking: preprocessors.defaultComponentTrackingOptions,
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -19,32 +19,25 @@ function withSentryConfig(
|
|
|
19
19
|
sentryOptions,
|
|
20
20
|
) {
|
|
21
21
|
const mergedOptions = {
|
|
22
|
-
...
|
|
22
|
+
...defaultSentryOptions,
|
|
23
23
|
...sentryOptions,
|
|
24
|
+
componentTracking: {
|
|
25
|
+
...defaultSentryOptions.componentTracking,
|
|
26
|
+
...sentryOptions?.componentTracking,
|
|
27
|
+
},
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);
|
|
27
31
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const sentryPreprocessors = new Map();
|
|
32
|
-
|
|
33
|
-
const shouldTrackComponents = mergedOptions.componentTracking?.trackComponents;
|
|
34
|
-
if (shouldTrackComponents) {
|
|
35
|
-
const firstPassPreproc = preprocessors.componentTrackingPreprocessor(mergedOptions.componentTracking);
|
|
36
|
-
sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);
|
|
32
|
+
// Bail if users already added the preprocessor
|
|
33
|
+
if (originalPreprocessors.find((p) => !!(p ).sentryId)) {
|
|
34
|
+
return originalConfig;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
sentryPreprocessors.delete(p.sentryId);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const mergedPreprocessors = [...sentryPreprocessors.values(), ...originalPreprocessors];
|
|
37
|
+
const mergedPreprocessors = [...originalPreprocessors];
|
|
38
|
+
if (mergedOptions.componentTracking.trackComponents) {
|
|
39
|
+
mergedPreprocessors.unshift(preprocessors.componentTrackingPreprocessor(mergedOptions.componentTracking));
|
|
40
|
+
}
|
|
48
41
|
|
|
49
42
|
return {
|
|
50
43
|
...originalConfig,
|
package/build/cjs/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\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":";;;;AAKA,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,IAAI,GAAG,oBAAoB;AAC3B,IAAI,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,qBAAsB,GAAE,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;;AAEA,EAAE,MAAM,mBAAoB,GAAE,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;;AAEA,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;AACA,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC;AACA,EAAE,OAAO,EAAE;AACX;;;;"}
|
package/build/cjs/performance.js
CHANGED
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const browser = require('@sentry/browser');
|
|
4
4
|
const svelte = require('svelte');
|
|
5
5
|
const core = require('@sentry/core');
|
|
6
|
-
const constants = require('./constants.js');
|
|
7
6
|
|
|
8
7
|
const defaultTrackComponentOptions
|
|
9
8
|
|
|
10
9
|
= {
|
|
11
10
|
trackInit: true,
|
|
12
|
-
trackUpdates:
|
|
11
|
+
trackUpdates: false,
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -26,21 +25,27 @@ function trackComponent(options) {
|
|
|
26
25
|
|
|
27
26
|
const customComponentName = mergedOptions.componentName;
|
|
28
27
|
|
|
29
|
-
const componentName = `<${customComponentName ||
|
|
28
|
+
const componentName = `<${customComponentName || 'Svelte Component'}>`;
|
|
30
29
|
|
|
31
30
|
if (mergedOptions.trackInit) {
|
|
32
31
|
recordInitSpan(componentName);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
if (mergedOptions.trackUpdates) {
|
|
36
|
-
|
|
35
|
+
try {
|
|
36
|
+
recordUpdateSpans(componentName);
|
|
37
|
+
} catch {
|
|
38
|
+
core.logger.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
|
+
);
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
function recordInitSpan(componentName) {
|
|
41
46
|
const initSpan = core.startInactiveSpan({
|
|
42
47
|
onlyIfParent: true,
|
|
43
|
-
op:
|
|
48
|
+
op: 'ui.svelte.init',
|
|
44
49
|
name: componentName,
|
|
45
50
|
attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
|
|
46
51
|
});
|
|
@@ -55,7 +60,7 @@ function recordUpdateSpans(componentName) {
|
|
|
55
60
|
svelte.beforeUpdate(() => {
|
|
56
61
|
updateSpan = core.startInactiveSpan({
|
|
57
62
|
onlyIfParent: true,
|
|
58
|
-
op:
|
|
63
|
+
op: 'ui.svelte.update',
|
|
59
64
|
name: componentName,
|
|
60
65
|
attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
|
|
61
66
|
});
|
|
@@ -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 { afterUpdate, beforeUpdate, onMount } from 'svelte';\n\nimport { startInactiveSpan } from '@sentry/core';\nimport
|
|
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 { afterUpdate, beforeUpdate, onMount } from 'svelte';\n\nimport { logger, startInactiveSpan } from '@sentry/core';\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 logger.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":["logger","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,aAAc,GAAE,CAAC,CAAC,EAAE,mBAAA,IAAuB,kBAAkB,CAAC,CAAC,CAAC;;AAExE,EAAE,IAAI,aAAa,CAAC,SAAS,EAAE;AAC/B,IAAI,cAAc,CAAC,aAAa,CAAC;AACjC;;AAEA,EAAE,IAAI,aAAa,CAAC,YAAY,EAAE;AAClC,IAAI,IAAI;AACR,MAAM,iBAAiB,CAAC,aAAa,CAAC;AACtC,MAAM,MAAM;AACZ,MAAMA,WAAM,CAAC,IAAI;AACjB,QAAQ,0LAA0L;AAClM,OAAO;AACP;AACA;AACA;;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,GAAG,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,GAAG,CAAC;;AAEJ,EAAEG,kBAAW,CAAC,MAAM;AACpB,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM;AACN;AACA,IAAI,UAAU,CAAC,GAAG,EAAE;AACpB,IAAI,UAAA,GAAa,SAAS;AAC1B,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -5,7 +5,7 @@ const MagicString = require('magic-string');
|
|
|
5
5
|
const defaultComponentTrackingOptions = {
|
|
6
6
|
trackComponents: true,
|
|
7
7
|
trackInit: true,
|
|
8
|
-
trackUpdates:
|
|
8
|
+
trackUpdates: false,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';
|
|
@@ -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';\n\nimport type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';\n\nexport const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {\n trackComponents: true,\n trackInit: true,\n trackUpdates:
|
|
1
|
+
{"version":3,"file":"preprocessors.js","sources":["../../src/preprocessors.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\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.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":";;;;AAKO,MAAM,+BAA+B,GAA2C;AACvF,EAAE,eAAe,EAAE,IAAI;AACvB,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,KAAK;AACrB;;AAEO,MAAM,wCAAyC,GAAE;;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,kBAAmB,GAAE,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,GAA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AAO,QAAQ,CAAC,QAAQ,CAAC,MAAO,GAAE,CAAC,CAAC,CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AAC9D;;AAEA,SAAS,YAAY,CAAC,OAAO,EAAmB;AAChD;AACA;AACA;AACA;AACA,EAAE,MAAM,cAAe,GAAE,kDAAkD;;AAE3E;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;AACrC;;;;;;"}
|
package/build/cjs/sdk.js
CHANGED
|
@@ -13,53 +13,8 @@ function init(options) {
|
|
|
13
13
|
|
|
14
14
|
core.applySdkMetadata(opts, 'svelte');
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
detectAndReportSvelteKit();
|
|
19
|
-
|
|
20
|
-
return client;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,
|
|
25
|
-
* in which case we add SvelteKit an event.modules entry to outgoing events.
|
|
26
|
-
* SvelteKit detection is performed only once, when the event processor is called for the
|
|
27
|
-
* first time. We cannot perform this check upfront (directly when init is called) because
|
|
28
|
-
* at this time, the HTML element might not yet be accessible.
|
|
29
|
-
*/
|
|
30
|
-
function detectAndReportSvelteKit() {
|
|
31
|
-
let detectedSvelteKit = undefined;
|
|
32
|
-
|
|
33
|
-
const svelteKitProcessor = event => {
|
|
34
|
-
if (detectedSvelteKit === undefined) {
|
|
35
|
-
detectedSvelteKit = isSvelteKitApp();
|
|
36
|
-
}
|
|
37
|
-
if (detectedSvelteKit) {
|
|
38
|
-
event.modules = {
|
|
39
|
-
svelteKit: 'latest',
|
|
40
|
-
...event.modules,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return event;
|
|
44
|
-
};
|
|
45
|
-
svelteKitProcessor.id = 'svelteKitProcessor';
|
|
46
|
-
|
|
47
|
-
browser.addEventProcessor(svelteKitProcessor);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* To actually detect a SvelteKit frontend, we search the DOM for a special
|
|
52
|
-
* div that's inserted by SvelteKit when the page is rendered. It's identified
|
|
53
|
-
* by its id, 'svelte-announcer', and it's used to improve page accessibility.
|
|
54
|
-
* This div is not present when only using Svelte without SvelteKit.
|
|
55
|
-
*
|
|
56
|
-
* @see https://github.com/sveltejs/kit/issues/307 for more information
|
|
57
|
-
*/
|
|
58
|
-
function isSvelteKitApp() {
|
|
59
|
-
return !!browser.WINDOW.document.querySelector('div#svelte-announcer');
|
|
16
|
+
return browser.init(opts);
|
|
60
17
|
}
|
|
61
18
|
|
|
62
|
-
exports.detectAndReportSvelteKit = detectAndReportSvelteKit;
|
|
63
19
|
exports.init = init;
|
|
64
|
-
exports.isSvelteKitApp = isSvelteKitApp;
|
|
65
20
|
//# sourceMappingURL=sdk.js.map
|
package/build/cjs/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport {
|
|
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;;;;"}
|
package/build/esm/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors.js';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const defaultSentryOptions = {
|
|
4
4
|
componentTracking: defaultComponentTrackingOptions,
|
|
5
5
|
};
|
|
6
6
|
|
|
@@ -17,32 +17,25 @@ function withSentryConfig(
|
|
|
17
17
|
sentryOptions,
|
|
18
18
|
) {
|
|
19
19
|
const mergedOptions = {
|
|
20
|
-
...
|
|
20
|
+
...defaultSentryOptions,
|
|
21
21
|
...sentryOptions,
|
|
22
|
+
componentTracking: {
|
|
23
|
+
...defaultSentryOptions.componentTracking,
|
|
24
|
+
...sentryOptions?.componentTracking,
|
|
25
|
+
},
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);
|
|
25
29
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const sentryPreprocessors = new Map();
|
|
30
|
-
|
|
31
|
-
const shouldTrackComponents = mergedOptions.componentTracking?.trackComponents;
|
|
32
|
-
if (shouldTrackComponents) {
|
|
33
|
-
const firstPassPreproc = componentTrackingPreprocessor(mergedOptions.componentTracking);
|
|
34
|
-
sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);
|
|
30
|
+
// Bail if users already added the preprocessor
|
|
31
|
+
if (originalPreprocessors.find((p) => !!(p ).sentryId)) {
|
|
32
|
+
return originalConfig;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
sentryPreprocessors.delete(p.sentryId);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const mergedPreprocessors = [...sentryPreprocessors.values(), ...originalPreprocessors];
|
|
35
|
+
const mergedPreprocessors = [...originalPreprocessors];
|
|
36
|
+
if (mergedOptions.componentTracking.trackComponents) {
|
|
37
|
+
mergedPreprocessors.unshift(componentTrackingPreprocessor(mergedOptions.componentTracking));
|
|
38
|
+
}
|
|
46
39
|
|
|
47
40
|
return {
|
|
48
41
|
...originalConfig,
|
package/build/esm/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\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":";;AAKA,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,IAAI,GAAG,oBAAoB;AAC3B,IAAI,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,qBAAsB,GAAE,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;;AAEA,EAAE,MAAM,mBAAoB,GAAE,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;;AAEA,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;AACA,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC;AACA,EAAE,OAAO,EAAE;AACX;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"9.0.0-alpha.
|
|
1
|
+
{"type":"module","version":"9.0.0-alpha.2","sideEffects":false}
|
package/build/esm/performance.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';
|
|
2
2
|
import { onMount, beforeUpdate, afterUpdate } from 'svelte';
|
|
3
|
-
import { startInactiveSpan } from '@sentry/core';
|
|
4
|
-
import { UI_SVELTE_INIT, UI_SVELTE_UPDATE, DEFAULT_COMPONENT_NAME } from './constants.js';
|
|
3
|
+
import { logger, startInactiveSpan } from '@sentry/core';
|
|
5
4
|
|
|
6
5
|
const defaultTrackComponentOptions
|
|
7
6
|
|
|
8
7
|
= {
|
|
9
8
|
trackInit: true,
|
|
10
|
-
trackUpdates:
|
|
9
|
+
trackUpdates: false,
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -24,21 +23,27 @@ function trackComponent(options) {
|
|
|
24
23
|
|
|
25
24
|
const customComponentName = mergedOptions.componentName;
|
|
26
25
|
|
|
27
|
-
const componentName = `<${customComponentName ||
|
|
26
|
+
const componentName = `<${customComponentName || 'Svelte Component'}>`;
|
|
28
27
|
|
|
29
28
|
if (mergedOptions.trackInit) {
|
|
30
29
|
recordInitSpan(componentName);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
if (mergedOptions.trackUpdates) {
|
|
34
|
-
|
|
33
|
+
try {
|
|
34
|
+
recordUpdateSpans(componentName);
|
|
35
|
+
} catch {
|
|
36
|
+
logger.warn(
|
|
37
|
+
"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.",
|
|
38
|
+
);
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
function recordInitSpan(componentName) {
|
|
39
44
|
const initSpan = startInactiveSpan({
|
|
40
45
|
onlyIfParent: true,
|
|
41
|
-
op:
|
|
46
|
+
op: 'ui.svelte.init',
|
|
42
47
|
name: componentName,
|
|
43
48
|
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
|
|
44
49
|
});
|
|
@@ -53,7 +58,7 @@ function recordUpdateSpans(componentName) {
|
|
|
53
58
|
beforeUpdate(() => {
|
|
54
59
|
updateSpan = startInactiveSpan({
|
|
55
60
|
onlyIfParent: true,
|
|
56
|
-
op:
|
|
61
|
+
op: 'ui.svelte.update',
|
|
57
62
|
name: componentName,
|
|
58
63
|
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
|
|
59
64
|
});
|
|
@@ -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 { afterUpdate, beforeUpdate, onMount } from 'svelte';\n\nimport { startInactiveSpan } from '@sentry/core';\nimport
|
|
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 { afterUpdate, beforeUpdate, onMount } from 'svelte';\n\nimport { logger, startInactiveSpan } from '@sentry/core';\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 logger.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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ACN,GAAG,CAAC;;AAEJ,EAAE,WAAW,CAAC,MAAM;AACpB,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM;AACN;AACA,IAAI,UAAU,CAAC,GAAG,EAAE;AACpB,IAAI,UAAA,GAAa,SAAS;AAC1B,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -3,7 +3,7 @@ import MagicString from 'magic-string';
|
|
|
3
3
|
const defaultComponentTrackingOptions = {
|
|
4
4
|
trackComponents: true,
|
|
5
5
|
trackInit: true,
|
|
6
|
-
trackUpdates:
|
|
6
|
+
trackUpdates: false,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
const FIRST_PASS_COMPONENT_TRACKING_PREPROC_ID = 'FIRST_PASS_COMPONENT_TRACKING_PREPROCESSOR';
|
|
@@ -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';\n\nimport type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';\n\nexport const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {\n trackComponents: true,\n trackInit: true,\n trackUpdates:
|
|
1
|
+
{"version":3,"file":"preprocessors.js","sources":["../../src/preprocessors.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\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.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":";;AAKO,MAAM,+BAA+B,GAA2C;AACvF,EAAE,eAAe,EAAE,IAAI;AACvB,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,KAAK;AACrB;;AAEO,MAAM,wCAAyC,GAAE;;AAExD;AACA;AACA;AACA;AACO,SAAS,6BAA6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AAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;AACtC,IAAI,MAAM,aAAc,GAAE,WAAW,CAAC,QAAQ,CAAC;AAC/C,IAAI,OAAO,eAAe,CAAC,IAAI,CAAC,WAAW,OAAA,KAAY,aAAa,CAAC;AACrE;;AAEA,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,MAAO,GAAE,CAAC,CAAC,CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AAC9D;;AAEA,SAAS,YAAY,CAAC,OAAO,EAAmB;AAChD;AACA;AACA;AACA;AACA,EAAE,MAAM,cAAe,GAAE,kDAAkD;;AAE3E;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;AACrC;;;;"}
|
package/build/esm/sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { init as init$1
|
|
1
|
+
import { init as init$1 } from '@sentry/browser';
|
|
2
2
|
import { applySdkMetadata } from '@sentry/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -11,51 +11,8 @@ function init(options) {
|
|
|
11
11
|
|
|
12
12
|
applySdkMetadata(opts, 'svelte');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
detectAndReportSvelteKit();
|
|
17
|
-
|
|
18
|
-
return client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,
|
|
23
|
-
* in which case we add SvelteKit an event.modules entry to outgoing events.
|
|
24
|
-
* SvelteKit detection is performed only once, when the event processor is called for the
|
|
25
|
-
* first time. We cannot perform this check upfront (directly when init is called) because
|
|
26
|
-
* at this time, the HTML element might not yet be accessible.
|
|
27
|
-
*/
|
|
28
|
-
function detectAndReportSvelteKit() {
|
|
29
|
-
let detectedSvelteKit = undefined;
|
|
30
|
-
|
|
31
|
-
const svelteKitProcessor = event => {
|
|
32
|
-
if (detectedSvelteKit === undefined) {
|
|
33
|
-
detectedSvelteKit = isSvelteKitApp();
|
|
34
|
-
}
|
|
35
|
-
if (detectedSvelteKit) {
|
|
36
|
-
event.modules = {
|
|
37
|
-
svelteKit: 'latest',
|
|
38
|
-
...event.modules,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return event;
|
|
42
|
-
};
|
|
43
|
-
svelteKitProcessor.id = 'svelteKitProcessor';
|
|
44
|
-
|
|
45
|
-
addEventProcessor(svelteKitProcessor);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* To actually detect a SvelteKit frontend, we search the DOM for a special
|
|
50
|
-
* div that's inserted by SvelteKit when the page is rendered. It's identified
|
|
51
|
-
* by its id, 'svelte-announcer', and it's used to improve page accessibility.
|
|
52
|
-
* This div is not present when only using Svelte without SvelteKit.
|
|
53
|
-
*
|
|
54
|
-
* @see https://github.com/sveltejs/kit/issues/307 for more information
|
|
55
|
-
*/
|
|
56
|
-
function isSvelteKitApp() {
|
|
57
|
-
return !!WINDOW.document.querySelector('div#svelte-announcer');
|
|
14
|
+
return init$1(opts);
|
|
58
15
|
}
|
|
59
16
|
|
|
60
|
-
export {
|
|
17
|
+
export { init };
|
|
61
18
|
//# sourceMappingURL=sdk.js.map
|
package/build/esm/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport {
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA2B,yBAAyB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMhG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,YAAY,EAC5B,aAAa,CAAC,EAAE,yBAAyB,GACxC,YAAY,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA2B,yBAAyB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMhG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,YAAY,EAC5B,aAAa,CAAC,EAAE,yBAAyB,GACxC,YAAY,CA0Bd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/performance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/performance.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAoBpE"}
|
package/build/types/sdk.d.ts
CHANGED
|
@@ -4,21 +4,4 @@ import type { Client } from '@sentry/core';
|
|
|
4
4
|
* Inits the Svelte SDK
|
|
5
5
|
*/
|
|
6
6
|
export declare function init(options: BrowserOptions): Client | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,
|
|
9
|
-
* in which case we add SvelteKit an event.modules entry to outgoing events.
|
|
10
|
-
* SvelteKit detection is performed only once, when the event processor is called for the
|
|
11
|
-
* first time. We cannot perform this check upfront (directly when init is called) because
|
|
12
|
-
* at this time, the HTML element might not yet be accessible.
|
|
13
|
-
*/
|
|
14
|
-
export declare function detectAndReportSvelteKit(): void;
|
|
15
|
-
/**
|
|
16
|
-
* To actually detect a SvelteKit frontend, we search the DOM for a special
|
|
17
|
-
* div that's inserted by SvelteKit when the page is rendered. It's identified
|
|
18
|
-
* by its id, 'svelte-announcer', and it's used to improve page accessibility.
|
|
19
|
-
* This div is not present when only using Svelte without SvelteKit.
|
|
20
|
-
*
|
|
21
|
-
* @see https://github.com/sveltejs/kit/issues/307 for more information
|
|
22
|
-
*/
|
|
23
|
-
export declare function isSvelteKitApp(): boolean;
|
|
24
7
|
//# sourceMappingURL=sdk.d.ts.map
|
package/build/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAQhE"}
|
package/build/types/types.d.ts
CHANGED
|
@@ -23,14 +23,17 @@ export type SpanOptions = {
|
|
|
23
23
|
* onMount lifecycle hook. This span tells how long it takes a component
|
|
24
24
|
* to be created and inserted into the DOM.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* @default `true` if component tracking is enabled
|
|
27
27
|
*/
|
|
28
28
|
trackInit?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* If true, a span is recorded between a component's beforeUpdate and afterUpdate
|
|
31
31
|
* lifecycle hooks.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* Caution: Component updates can only be tracked in Svelte versions prior to version 5
|
|
34
|
+
* or in Svelte 5 in legacy mode (i.e. without Runes).
|
|
35
|
+
*
|
|
36
|
+
* @default `false` if component tracking is enabled
|
|
34
37
|
*/
|
|
35
38
|
trackUpdates?: boolean;
|
|
36
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAI1E,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,iBAAiB,EAAE,GAAG,iBAAiB,CAAC;IACrD,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,iBAAiB,CAAC,EAAE,4BAA4B,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAI1E,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,iBAAiB,EAAE,GAAG,iBAAiB,CAAC;IACrD,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,iBAAiB,CAAC,EAAE,4BAA4B,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;CACtC,GAAG,WAAW,CAAC;AAEhB,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,WAAW,CAAC"}
|
|
@@ -4,21 +4,4 @@ import { Client } from '@sentry/core';
|
|
|
4
4
|
* Inits the Svelte SDK
|
|
5
5
|
*/
|
|
6
6
|
export declare function init(options: BrowserOptions): Client | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,
|
|
9
|
-
* in which case we add SvelteKit an event.modules entry to outgoing events.
|
|
10
|
-
* SvelteKit detection is performed only once, when the event processor is called for the
|
|
11
|
-
* first time. We cannot perform this check upfront (directly when init is called) because
|
|
12
|
-
* at this time, the HTML element might not yet be accessible.
|
|
13
|
-
*/
|
|
14
|
-
export declare function detectAndReportSvelteKit(): void;
|
|
15
|
-
/**
|
|
16
|
-
* To actually detect a SvelteKit frontend, we search the DOM for a special
|
|
17
|
-
* div that's inserted by SvelteKit when the page is rendered. It's identified
|
|
18
|
-
* by its id, 'svelte-announcer', and it's used to improve page accessibility.
|
|
19
|
-
* This div is not present when only using Svelte without SvelteKit.
|
|
20
|
-
*
|
|
21
|
-
* @see https://github.com/sveltejs/kit/issues/307 for more information
|
|
22
|
-
*/
|
|
23
|
-
export declare function isSvelteKitApp(): boolean;
|
|
24
7
|
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -23,14 +23,17 @@ export type SpanOptions = {
|
|
|
23
23
|
* onMount lifecycle hook. This span tells how long it takes a component
|
|
24
24
|
* to be created and inserted into the DOM.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* @default `true` if component tracking is enabled
|
|
27
27
|
*/
|
|
28
28
|
trackInit?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* If true, a span is recorded between a component's beforeUpdate and afterUpdate
|
|
31
31
|
* lifecycle hooks.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* Caution: Component updates can only be tracked in Svelte versions prior to version 5
|
|
34
|
+
* or in Svelte 5 in legacy mode (i.e. without Runes).
|
|
35
|
+
*
|
|
36
|
+
* @default `false` if component tracking is enabled
|
|
34
37
|
*/
|
|
35
38
|
trackUpdates?: boolean;
|
|
36
39
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/svelte",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.2",
|
|
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": "9.0.0-alpha.
|
|
43
|
-
"@sentry/core": "9.0.0-alpha.
|
|
42
|
+
"@sentry/browser": "9.0.0-alpha.2",
|
|
43
|
+
"@sentry/core": "9.0.0-alpha.2",
|
|
44
44
|
"magic-string": "^0.30.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
package/build/cjs/constants.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const UI_SVELTE_INIT = 'ui.svelte.init';
|
|
4
|
-
|
|
5
|
-
const UI_SVELTE_UPDATE = 'ui.svelte.update';
|
|
6
|
-
|
|
7
|
-
const DEFAULT_COMPONENT_NAME = 'Svelte Component';
|
|
8
|
-
|
|
9
|
-
exports.DEFAULT_COMPONENT_NAME = DEFAULT_COMPONENT_NAME;
|
|
10
|
-
exports.UI_SVELTE_INIT = UI_SVELTE_INIT;
|
|
11
|
-
exports.UI_SVELTE_UPDATE = UI_SVELTE_UPDATE;
|
|
12
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/constants.ts"],"sourcesContent":["export const UI_SVELTE_INIT = 'ui.svelte.init';\n\nexport const UI_SVELTE_UPDATE = 'ui.svelte.update';\n\nexport const DEFAULT_COMPONENT_NAME = 'Svelte Component';\n"],"names":[],"mappings":";;AAAO,MAAM,cAAe,GAAE;;AAEvB,MAAM,gBAAiB,GAAE;;AAEzB,MAAM,sBAAuB,GAAE;;;;;;"}
|
package/build/esm/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../src/constants.ts"],"sourcesContent":["export const UI_SVELTE_INIT = 'ui.svelte.init';\n\nexport const UI_SVELTE_UPDATE = 'ui.svelte.update';\n\nexport const DEFAULT_COMPONENT_NAME = 'Svelte Component';\n"],"names":[],"mappings":"AAAO,MAAM,cAAe,GAAE;;AAEvB,MAAM,gBAAiB,GAAE;;AAEzB,MAAM,sBAAuB,GAAE;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC"}
|