pull/17124/head
Elliott Johnson 2 weeks ago
parent cd7a71f92a
commit 0581bb9094

@ -1,13 +1,11 @@
/** @import { ComponentContext, DevStackEntry, Effect } from '#client' */ /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
/** @import { Transport } from '#shared' */
import { DEV } from 'esm-env'; import { DEV } from 'esm-env';
import * as e from './errors.js'; import * as e from './errors.js';
import { active_effect, active_reaction } from './runtime.js'; import { active_effect, active_reaction } from './runtime.js';
import { create_user_effect } from './reactivity/effects.js'; import { create_user_effect } from './reactivity/effects.js';
import { async_mode_flag, legacy_mode_flag } from '../flags/index.js'; import { async_mode_flag, legacy_mode_flag } from '../flags/index.js';
import { FILENAME } from '../../constants.js'; import { FILENAME } from '../../constants.js';
import { BRANCH_EFFECT, EFFECT_RAN } from './constants.js'; import { BRANCH_EFFECT } from './constants.js';
import { hydrating } from './dom/hydration.js';
/** @type {ComponentContext | null} */ /** @type {ComponentContext | null} */
export let component_context = null; export let component_context = null;

@ -5,10 +5,10 @@ import { hydrating } from './dom/hydration.js';
* @template T * @template T
* @param {string} key * @param {string} key
* @param {() => T} fn * @param {() => T} fn
* @param {{ transport?: Transport<T> }} [options] * @param {Transport<T>} [options]
* @returns {T} * @returns {T}
*/ */
export function hydratable(key, fn, options = {}) { export function hydratable(key, fn, options) {
if (!hydrating) { if (!hydrating) {
return fn(); return fn();
} }
@ -19,7 +19,7 @@ export function hydratable(key, fn, options = {}) {
// something to be synchronously hydratable and then have it not be // something to be synchronously hydratable and then have it not be
return fn(); return fn();
} }
return decode(val, options.transport?.decode); return decode(val, options?.decode);
} }
/** /**

@ -14,10 +14,10 @@ export function set_hydratable_key(key) {
* @template T * @template T
* @param {string} key * @param {string} key
* @param {() => T} fn * @param {() => T} fn
* @param {{ transport?: Transport<T> }} [options] * @param {Transport<T>} [options]
* @returns {T} * @returns {T}
*/ */
export function hydratable(key, fn, options = {}) { export function hydratable(key, fn, options) {
const store = get_render_context(); const store = get_render_context();
if (store.hydratables.has(key)) { if (store.hydratables.has(key)) {
@ -26,7 +26,7 @@ export function hydratable(key, fn, options = {}) {
} }
const result = fn(); const result = fn();
store.hydratables.set(key, { value: result, encode: options.transport?.encode }); store.hydratables.set(key, { value: result, encode: options?.encode });
return result; return result;
} }
/** /**

Loading…
Cancel
Save