svelte-effect-runtime 1.6.1 → 1.6.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.
@@ -1,5 +1,5 @@
1
- import { t as effect_preprocess } from "./preprocess-DIC5iR0_.js";
2
- import { n as sveltekit_effect_runtime } from "./vite-Bm2RdiT3.js";
1
+ import { t as effect_preprocess } from "./preprocess-BFePqOC6.js";
2
+ import { n as sveltekit_effect_runtime } from "./vite-BlUTKv2u.js";
3
3
  import { preprocess } from "svelte/compiler";
4
4
  //#region v3/effect.ts
5
5
  /**
@@ -48,4 +48,4 @@ function effect(options = {}) {
48
48
  //#endregion
49
49
  export { effect as t };
50
50
 
51
- //# sourceMappingURL=effect-zCli5qgO.js.map
51
+ //# sourceMappingURL=effect-Crj3S8Cg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect-zCli5qgO.js","names":[],"sources":["../../../modules/svelte-effect-runtime/v3/effect.ts"],"sourcesContent":["/**\n * High-level Vite integration for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n *\n * export default {\n * plugins: [effect()],\n * };\n * ```\n *\n * @module\n */\nimport { preprocess } from \"svelte/compiler\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport {\n effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\nimport { sveltekit_effect_runtime } from \"$/v3/vite.ts\";\n\n/** Options for the high-level {@link effect} Vite plugin. */\nexport interface EffectPluginOptions {\n effect?: EffectPreprocessOptions;\n remoteModuleId?: string;\n}\n\nfunction create_effect_svelte_transform(\n options: EffectPreprocessOptions = {},\n): Plugin {\n const preprocessor = effect_preprocess(options);\n\n return {\n name: \"svelte-effect-runtime-transform\",\n enforce: \"pre\",\n async transform(code, id, _options) {\n const filename = id.split(\"?\", 1)[0];\n if (!filename.endsWith(\".svelte\")) {\n return null;\n }\n\n const transformed = await preprocess(code, preprocessor, { filename });\n if (transformed.code === code) {\n return null;\n }\n\n return {\n code: transformed.code,\n ...(transformed.map ? { map: transformed.map as never } : {}),\n };\n },\n };\n}\n\n/**\n * Convenience Vite plugin that enables `<script effect>` transforms and wires\n * SvelteKit remote functions to the Effect-aware client adapters.\n *\n * Use this in `vite.config.ts` instead of composing lower-level runtime\n * plugins yourself.\n *\n * @see https://ser.barekey.dev/\n */\nexport function effect(\n options: EffectPluginOptions = {},\n): PluginOption[] {\n const transform_plugin = create_effect_svelte_transform(options.effect);\n\n return [\n transform_plugin,\n sveltekit_effect_runtime({\n remoteModuleId: options.remoteModuleId,\n }),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,SAAS,+BACP,UAAmC,EAAE,EAC7B;CACR,MAAM,eAAe,kBAAkB,QAAQ;AAE/C,QAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,UAAU,MAAM,IAAI,UAAU;GAClC,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE,CAAC;AAClC,OAAI,CAAC,SAAS,SAAS,UAAU,CAC/B,QAAO;GAGT,MAAM,cAAc,MAAM,WAAW,MAAM,cAAc,EAAE,UAAU,CAAC;AACtE,OAAI,YAAY,SAAS,KACvB,QAAO;AAGT,UAAO;IACL,MAAM,YAAY;IAClB,GAAI,YAAY,MAAM,EAAE,KAAK,YAAY,KAAc,GAAG,EAAE;IAC7D;;EAEJ;;;;;;;;;;;AAYH,SAAgB,OACd,UAA+B,EAAE,EACjB;AAGhB,QAAO,CAFkB,+BAA+B,QAAQ,OAAO,EAIrE,yBAAyB,EACvB,gBAAgB,QAAQ,gBACzB,CAAC,CACH"}
1
+ {"version":3,"file":"effect-Crj3S8Cg.js","names":[],"sources":["../../../modules/svelte-effect-runtime/v3/effect.ts"],"sourcesContent":["/**\n * High-level Vite integration for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n *\n * export default {\n * plugins: [effect()],\n * };\n * ```\n *\n * @module\n */\nimport { preprocess } from \"svelte/compiler\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport {\n effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\nimport { sveltekit_effect_runtime } from \"$/v3/vite.ts\";\n\n/** Options for the high-level {@link effect} Vite plugin. */\nexport interface EffectPluginOptions {\n effect?: EffectPreprocessOptions;\n remoteModuleId?: string;\n}\n\nfunction create_effect_svelte_transform(\n options: EffectPreprocessOptions = {},\n): Plugin {\n const preprocessor = effect_preprocess(options);\n\n return {\n name: \"svelte-effect-runtime-transform\",\n enforce: \"pre\",\n async transform(code, id, _options) {\n const filename = id.split(\"?\", 1)[0];\n if (!filename.endsWith(\".svelte\")) {\n return null;\n }\n\n const transformed = await preprocess(code, preprocessor, { filename });\n if (transformed.code === code) {\n return null;\n }\n\n return {\n code: transformed.code,\n ...(transformed.map ? { map: transformed.map as never } : {}),\n };\n },\n };\n}\n\n/**\n * Convenience Vite plugin that enables `<script effect>` transforms and wires\n * SvelteKit remote functions to the Effect-aware client adapters.\n *\n * Use this in `vite.config.ts` instead of composing lower-level runtime\n * plugins yourself.\n *\n * @see https://ser.barekey.dev/\n */\nexport function effect(\n options: EffectPluginOptions = {},\n): PluginOption[] {\n const transform_plugin = create_effect_svelte_transform(options.effect);\n\n return [\n transform_plugin,\n sveltekit_effect_runtime({\n remoteModuleId: options.remoteModuleId,\n }),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,SAAS,+BACP,UAAmC,EAAE,EAC7B;CACR,MAAM,eAAe,kBAAkB,QAAQ;AAE/C,QAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,UAAU,MAAM,IAAI,UAAU;GAClC,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE,CAAC;AAClC,OAAI,CAAC,SAAS,SAAS,UAAU,CAC/B,QAAO;GAGT,MAAM,cAAc,MAAM,WAAW,MAAM,cAAc,EAAE,UAAU,CAAC;AACtE,OAAI,YAAY,SAAS,KACvB,QAAO;AAGT,UAAO;IACL,MAAM,YAAY;IAClB,GAAI,YAAY,MAAM,EAAE,KAAK,YAAY,KAAc,GAAG,EAAE;IAC7D;;EAEJ;;;;;;;;;;;AAYH,SAAgB,OACd,UAA+B,EAAE,EACjB;AAGhB,QAAO,CAFkB,+BAA+B,QAAQ,OAAO,EAIrE,yBAAyB,EACvB,gBAAgB,QAAQ,gBACzB,CAAC,CACH"}
@@ -12555,15 +12555,9 @@ const DEFAULT_EFFECT_MODULE_ID = "effect";
12555
12555
  const DEFAULT_SVELTE_MODULE_ID = "svelte";
12556
12556
  const MARKUP_HELPER_PREFIX = "__svelteEffectRuntimeMarkup";
12557
12557
  function transformEffectMarkup(content, options) {
12558
+ if (!containsAnyYieldStarText(content)) return identityMarkupResult(content, options.filename);
12558
12559
  const sanitized = sanitizeEffectMarkup(content, options.filename);
12559
- if (sanitized.candidates.length === 0) return {
12560
- code: content,
12561
- map: new MagicString(content).generateMap({
12562
- hires: true,
12563
- includeContent: true,
12564
- source: options.filename
12565
- })
12566
- };
12560
+ if (sanitized.candidates.length === 0) return identityMarkupResult(content, options.filename);
12567
12561
  const replacements = collectMarkupReplacements(createParseSafeMarkupSource(sanitized.code), sanitized.candidates, options.filename);
12568
12562
  const magicString = new MagicString(content);
12569
12563
  for (const replacement of replacements) magicString.overwrite(replacement.start, replacement.end, replacement.text);
@@ -12577,6 +12571,19 @@ function transformEffectMarkup(content, options) {
12577
12571
  })
12578
12572
  };
12579
12573
  }
12574
+ function containsAnyYieldStarText(content) {
12575
+ return /\byield\s*\*/.test(content);
12576
+ }
12577
+ function identityMarkupResult(content, filename) {
12578
+ return {
12579
+ code: content,
12580
+ map: new MagicString(content).generateMap({
12581
+ hires: true,
12582
+ includeContent: true,
12583
+ source: filename
12584
+ })
12585
+ };
12586
+ }
12580
12587
  function createParseSafeMarkupSource(content) {
12581
12588
  const excludedRanges = findParseSafeMaskRanges(content);
12582
12589
  if (excludedRanges.length === 0) return content;
@@ -13380,4 +13387,4 @@ function indentBlock(text, indent) {
13380
13387
  //#endregion
13381
13388
  export { transformEffectMarkup as t };
13382
13389
 
13383
- //# sourceMappingURL=markup-D4zJP7U1.js.map
13390
+ //# sourceMappingURL=markup-CkPUZIJt.js.map