svelte-effect-runtime 3.0.0 → 3.0.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/.dist/chunks/dispatcher-FCsx1Hlh.js +22 -0
- package/.dist/chunks/dispatcher-FCsx1Hlh.js.map +1 -0
- package/.dist/chunks/runtime-Sl685BVb.js +79 -0
- package/.dist/chunks/runtime-Sl685BVb.js.map +1 -0
- package/.dist/chunks/{transform-CMvL4SBp.js → transform-BTStPHku.js} +18 -11
- package/.dist/chunks/transform-BTStPHku.js.map +1 -0
- package/.dist/error.d.ts +1 -1
- package/.dist/generated/dispatcher.d.ts +13 -0
- package/.dist/generators.d.ts +4 -4
- package/.dist/internal/generators.d.ts +1 -1
- package/.dist/internal/generators.js +1 -1
- package/.dist/markup/promise.d.ts +18 -4
- package/.dist/markup/promise.js +16 -5
- package/.dist/markup/promise.js.map +1 -1
- package/.dist/markup/run.d.ts +1 -1
- package/.dist/markup/run.js +2 -2
- package/.dist/markup/run.js.map +1 -1
- package/.dist/markup/transform/types.d.ts +1 -1
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.d.ts +4 -4
- package/.dist/markup/value.js +9 -5
- package/.dist/markup/value.js.map +1 -1
- package/.dist/runtime/transform.d.ts +2 -2
- package/.dist/runtime/transform.js +654 -3
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/{preprocess → script-transform}/imports.d.ts +1 -1
- package/.dist/{preprocess → script-transform}/types.d.ts +2 -2
- package/.dist/server/runtime.d.ts +14 -0
- package/.dist/server.js +2 -56
- package/.dist/server.js.map +1 -1
- package/package.json +1 -1
- package/.dist/chunks/preprocess-BhoCga82.js +0 -656
- package/.dist/chunks/preprocess-BhoCga82.js.map +0 -1
- package/.dist/chunks/transform-CMvL4SBp.js.map +0 -1
- package/.dist/preprocess.d.ts +0 -2
- package/.dist/preprocess.js +0 -3
- /package/.dist/{preprocess → script-transform}/ast.d.ts +0 -0
- /package/.dist/{preprocess → script-transform}/index.d.ts +0 -0
- /package/.dist/{preprocess → script-transform}/lower.d.ts +0 -0
- /package/.dist/{preprocess → script-transform}/runes.d.ts +0 -0
- /package/.dist/{preprocess → script-transform}/runtime-block.d.ts +0 -0
- /package/.dist/{preprocess → script-transform}/source.d.ts +0 -0
package/.dist/markup/promise.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as get_dispatcher } from "../chunks/dispatcher-FCsx1Hlh.js";
|
|
2
2
|
//#region src/markup/promise.ts
|
|
3
3
|
/**
|
|
4
|
-
* Runtime helper emitted by the markup
|
|
4
|
+
* Runtime helper emitted by the markup transform for
|
|
5
5
|
* `{#await yield* expr}` blocks. Delegates to the dispatcher's
|
|
6
|
-
* promise mechanism
|
|
7
|
-
*
|
|
6
|
+
* promise mechanism. During SSR it can return a fallback promise without
|
|
7
|
+
* starting the dispatcher.
|
|
8
8
|
*
|
|
9
9
|
* @since 2.0.0
|
|
10
10
|
* @param id - Stable identifier generated from the expression's source
|
|
11
11
|
* position, used for cache lookups.
|
|
12
12
|
* @param deps - Array of reactive dependencies.
|
|
13
13
|
* @param factory - Generator function that yields the effect to run.
|
|
14
|
+
* @param ssr_fallback - Value to resolve during SSR when the helper is used
|
|
15
|
+
* from an awaited expression outside a Svelte await block.
|
|
16
|
+
* @param options - Optional SSR behavior for contexts such as await blocks
|
|
17
|
+
* that should render pending UI.
|
|
14
18
|
* @returns A Promise that resolves with the effect's result.
|
|
15
19
|
*/
|
|
16
|
-
function promise(id, deps, factory) {
|
|
20
|
+
function promise(id, deps, factory, ssr_fallback, options) {
|
|
21
|
+
if (is_server_render()) {
|
|
22
|
+
if (options?.ssr === "pending") return new Promise(() => {});
|
|
23
|
+
if (arguments.length >= 4) return Promise.resolve(ssr_fallback);
|
|
24
|
+
}
|
|
17
25
|
return get_dispatcher().promise({
|
|
18
26
|
id,
|
|
19
27
|
deps,
|
|
20
28
|
factory
|
|
21
29
|
});
|
|
22
30
|
}
|
|
31
|
+
function is_server_render() {
|
|
32
|
+
return typeof document === "undefined";
|
|
33
|
+
}
|
|
23
34
|
//#endregion
|
|
24
35
|
export { promise };
|
|
25
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup
|
|
1
|
+
{"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Options for markup promise behavior during server rendering.\n *\n * @since 2.4.0\n */\ninterface MarkupPromiseOptions {\n /** Keep the SSR promise pending so Svelte renders an await block fallback. */\n ssr?: \"pending\";\n}\n\n/**\n * Runtime helper emitted by the markup transform for\n * `{#await yield* expr}` blocks. Delegates to the dispatcher's\n * promise mechanism. During SSR it can return a fallback promise without\n * starting the dispatcher.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies.\n * @param factory - Generator function that yields the effect to run.\n * @param ssr_fallback - Value to resolve during SSR when the helper is used\n * from an awaited expression outside a Svelte await block.\n * @param options - Optional SSR behavior for contexts such as await blocks\n * that should render pending UI.\n * @returns A Promise that resolves with the effect's result.\n */\nexport function promise<A, E, R>(\n id: string,\n deps: readonly unknown[],\n factory: () => Effect.gen.Return<A, E, R>,\n ssr_fallback?: A,\n options?: MarkupPromiseOptions,\n): Promise<A> {\n if (is_server_render()) {\n if (options?.ssr === \"pending\") {\n return new Promise<A>(() => {});\n }\n\n if (arguments.length >= 4) {\n return Promise.resolve(ssr_fallback as A);\n }\n }\n\n return get_dispatcher().promise({ id, deps, factory });\n}\n\nfunction is_server_render(): boolean {\n return typeof document === \"undefined\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QACd,IACA,MACA,SACA,cACA,SACY;CACZ,IAAI,iBAAiB,GAAG;EACtB,IAAI,SAAS,QAAQ,WACnB,OAAO,IAAI,cAAiB,CAAC,CAAC;EAGhC,IAAI,UAAU,UAAU,GACtB,OAAO,QAAQ,QAAQ,YAAiB;CAE5C;CAEA,OAAO,eAAe,EAAE,QAAQ;EAAE;EAAI;EAAM;CAAQ,CAAC;AACvD;AAEA,SAAS,mBAA4B;CACnC,OAAO,OAAO,aAAa;AAC7B"}
|
package/.dist/markup/run.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
/**
|
|
3
|
-
* Runtime helper emitted by the markup
|
|
3
|
+
* Runtime helper emitted by the markup transform for inline event
|
|
4
4
|
* handlers containing `yield*`. Wraps the user's generator in an
|
|
5
5
|
* `Effect.gen` and delegates to the dispatcher's fire-and-forget
|
|
6
6
|
* mechanism.
|
package/.dist/markup/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as get_dispatcher } from "../chunks/dispatcher-FCsx1Hlh.js";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/markup/run.ts
|
|
4
4
|
/**
|
|
5
|
-
* Runtime helper emitted by the markup
|
|
5
|
+
* Runtime helper emitted by the markup transform for inline event
|
|
6
6
|
* handlers containing `yield*`. Wraps the user's generator in an
|
|
7
7
|
* `Effect.gen` and delegates to the dispatcher's fire-and-forget
|
|
8
8
|
* mechanism.
|
package/.dist/markup/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup
|
|
1
|
+
{"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for inline event\n * handlers containing `yield*`. Wraps the user's generator in an\n * `Effect.gen` and delegates to the dispatcher's fire-and-forget\n * mechanism.\n *\n * @since 2.0.0\n * @param factory - Generator function that yields the effect to run.\n * @returns A Promise that resolves or rejects when the effect completes.\n */\nexport function run<A, E, R>(\n factory: () => Effect.gen.Return<A, E, R>,\n): Promise<A> {\n const effect = Effect.gen(factory);\n\n return get_dispatcher().run(effect);\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,IACd,SACY;CACZ,MAAM,SAAS,OAAO,IAAI,OAAO;CAEjC,OAAO,eAAe,EAAE,IAAI,MAAM;AACpC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as transform_markup_effect } from "../chunks/transform-
|
|
1
|
+
import { t as transform_markup_effect } from "../chunks/transform-BTStPHku.js";
|
|
2
2
|
export { transform_markup_effect };
|
package/.dist/markup/value.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Effect } from "effect";
|
|
2
2
|
/**
|
|
3
|
-
* Runtime helper emitted by the markup
|
|
3
|
+
* Runtime helper emitted by the markup transform for `{yield* expr}`
|
|
4
4
|
* expressions in Svelte templates. Delegates to the dispatcher's
|
|
5
5
|
* cached reactive value mechanism — returns the fallback synchronously,
|
|
6
|
-
* then the resolved value once the effect completes
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* then the resolved value once the effect completes in the browser. During
|
|
7
|
+
* SSR the client dispatcher is not touched, so browser-only layers cannot
|
|
8
|
+
* turn server rendering into a 500.
|
|
9
9
|
*
|
|
10
10
|
* @since 2.0.0
|
|
11
11
|
* @param id - Stable identifier generated from the expression's source
|
package/.dist/markup/value.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as get_dispatcher } from "../chunks/dispatcher-FCsx1Hlh.js";
|
|
2
2
|
//#region src/markup/value.ts
|
|
3
3
|
/**
|
|
4
|
-
* Runtime helper emitted by the markup
|
|
4
|
+
* Runtime helper emitted by the markup transform for `{yield* expr}`
|
|
5
5
|
* expressions in Svelte templates. Delegates to the dispatcher's
|
|
6
6
|
* cached reactive value mechanism — returns the fallback synchronously,
|
|
7
|
-
* then the resolved value once the effect completes
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* then the resolved value once the effect completes in the browser. During
|
|
8
|
+
* SSR the client dispatcher is not touched, so browser-only layers cannot
|
|
9
|
+
* turn server rendering into a 500.
|
|
10
10
|
*
|
|
11
11
|
* @since 2.0.0
|
|
12
12
|
* @param id - Stable identifier generated from the expression's source
|
|
@@ -19,6 +19,7 @@ import { n as get_dispatcher } from "../chunks/dispatcher-CgCdn6bj.js";
|
|
|
19
19
|
* @returns The cached value if resolved, or the fallback.
|
|
20
20
|
*/
|
|
21
21
|
function value(id, deps, fallback, factory) {
|
|
22
|
+
if (is_server_render()) return fallback;
|
|
22
23
|
return get_dispatcher().value({
|
|
23
24
|
id,
|
|
24
25
|
deps,
|
|
@@ -26,6 +27,9 @@ function value(id, deps, fallback, factory) {
|
|
|
26
27
|
factory
|
|
27
28
|
});
|
|
28
29
|
}
|
|
30
|
+
function is_server_render() {
|
|
31
|
+
return typeof document === "undefined";
|
|
32
|
+
}
|
|
29
33
|
//#endregion
|
|
30
34
|
export { value };
|
|
31
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup
|
|
1
|
+
{"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for `{yield* expr}`\n * expressions in Svelte templates. Delegates to the dispatcher's\n * cached reactive value mechanism — returns the fallback synchronously,\n * then the resolved value once the effect completes in the browser. During\n * SSR the client dispatcher is not touched, so browser-only layers cannot\n * turn server rendering into a 500.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies (free identifiers in the\n * expression). When any dep changes, the previous fiber is cancelled\n * and a new one starts.\n * @param fallback - Value returned while the effect is running.\n * @param factory - Generator function that yields the effect to run.\n * @returns The cached value if resolved, or the fallback.\n */\nexport function value<A, F, E, R>(\n id: string,\n deps: readonly unknown[],\n fallback: F,\n factory: () => Effect.gen.Return<A, E, R>,\n): A | F {\n if (is_server_render()) {\n return fallback;\n }\n\n return get_dispatcher().value<A | F>({ id, deps, fallback, factory });\n}\n\nfunction is_server_render(): boolean {\n return typeof document === \"undefined\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,MACd,IACA,MACA,UACA,SACO;CACP,IAAI,iBAAiB,GACnB,OAAO;CAGT,OAAO,eAAe,EAAE,MAAa;EAAE;EAAI;EAAM;EAAU;CAAQ,CAAC;AACtE;AAEA,SAAS,mBAA4B;CACnC,OAAO,OAAO,aAAa;AAC7B"}
|
|
@@ -15,7 +15,7 @@ export interface SvelteTransformResult {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Lowers SER syntax in a complete Svelte component without using Svelte's
|
|
18
|
-
*
|
|
18
|
+
* adapter API.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
@@ -34,4 +34,4 @@ export interface SvelteTransformResult {
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function transform_svelte_effect(content: string, filename?: string): SvelteTransformResult;
|
|
36
36
|
export { type MarkupTransformResult, transform_markup_effect, } from "../markup/transform.js";
|
|
37
|
-
export { type BlockRef, type ScriptTransformResult, transform_script_effect, } from "../
|
|
37
|
+
export { type BlockRef, type ScriptTransformResult, transform_script_effect, } from "../script-transform/index.js";
|