@lytjs/renderer 6.0.0 → 6.5.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.
- package/README.md +14 -0
- package/dist/index.cjs +22 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -42
- package/dist/index.d.ts +3 -42
- package/dist/index.mjs +24 -12
- package/dist/index.mjs.map +1 -1
- package/dist/vapor/vapor-app.cjs +334 -0
- package/dist/vapor/vapor-app.cjs.map +1 -0
- package/dist/vapor/vapor-app.d.cts +88 -0
- package/dist/vapor/vapor-app.d.ts +88 -0
- package/dist/vapor/vapor-app.mjs +330 -0
- package/dist/vapor/vapor-app.mjs.map +1 -0
- package/package.json +22 -12
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Ref } from '@lytjs/reactivity';
|
|
2
2
|
export { getSkippedTrackingCount, resetSkippedTrackingCount, shouldSkipTracking, withFirstRenderOptimization } from '@lytjs/reactivity';
|
|
3
|
+
import { VaporComponentDefinition, VaporApp } from './vapor/vapor-app.cjs';
|
|
4
|
+
export { VaporAppOptions, VaporComponentOptions, VaporContext, PropOptions as VaporPropOptions } from './vapor/vapor-app.cjs';
|
|
3
5
|
import { VNode } from '@lytjs/vdom';
|
|
4
6
|
export { RendererOptions, VNode, createRenderer } from '@lytjs/vdom';
|
|
5
7
|
export { DOMRenderer, EventInvoker, HydrationRenderer, ParsedEvent, WebRendererHost, createDOMRenderer, createHydrationFunctions, createInvoker, createWebHost, getEventKey, normalizeEventName, parseEventModifier, patchAttr, patchClass, patchEvent, patchProp, patchStyle, removeAllEventListeners, wrapDOMEvent } from '@lytjs/adapter-web';
|
|
@@ -278,47 +280,6 @@ declare function defineServerComponent(options: Omit<ServerComponentDefinition,
|
|
|
278
280
|
serializeData?: () => string;
|
|
279
281
|
}): ServerComponentDefinition;
|
|
280
282
|
|
|
281
|
-
/** Vapor 组件的上下文对象 */
|
|
282
|
-
interface VaporContext {
|
|
283
|
-
attrs: Record<string, unknown>;
|
|
284
|
-
slots: Record<string, () => Node>;
|
|
285
|
-
emit: (event: string, ...args: unknown[]) => void;
|
|
286
|
-
}
|
|
287
|
-
/** Prop 定义选项 */
|
|
288
|
-
interface PropOptions {
|
|
289
|
-
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';
|
|
290
|
-
default?: unknown;
|
|
291
|
-
required?: boolean;
|
|
292
|
-
validator?: (value: unknown) => boolean;
|
|
293
|
-
}
|
|
294
|
-
/** Vapor 组件定义选项 */
|
|
295
|
-
interface VaporComponentOptions {
|
|
296
|
-
name?: string;
|
|
297
|
-
props?: Record<string, PropOptions>;
|
|
298
|
-
setup?: (props: Record<string, unknown>, context: VaporContext) => Record<string, unknown> | void;
|
|
299
|
-
template: string;
|
|
300
|
-
}
|
|
301
|
-
/** Vapor 组件定义(编译后的结果) */
|
|
302
|
-
interface VaporComponentDefinition {
|
|
303
|
-
name?: string;
|
|
304
|
-
props?: Record<string, PropOptions>;
|
|
305
|
-
setup?: (props: Record<string, unknown>, context: VaporContext) => Record<string, unknown> | void;
|
|
306
|
-
template: string;
|
|
307
|
-
compiledCode?: string;
|
|
308
|
-
}
|
|
309
|
-
/** Vapor 应用配置选项 */
|
|
310
|
-
interface VaporAppOptions {
|
|
311
|
-
/** 根容器属性(传递给根组件的 props) */
|
|
312
|
-
rootProps?: Record<string, unknown>;
|
|
313
|
-
}
|
|
314
|
-
/** Vapor 应用实例 */
|
|
315
|
-
interface VaporApp {
|
|
316
|
-
mount(container: Element | string): void;
|
|
317
|
-
unmount(): void;
|
|
318
|
-
provide(key: string | symbol, value: unknown): void;
|
|
319
|
-
component(name: string, component: VaporComponentDefinition): VaporApp;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
283
|
/** HMR 更新类型 */
|
|
323
284
|
type HMRUpdateType = 'template' | 'script' | 'style' | 'full';
|
|
324
285
|
/** HMR 更新信息 */
|
|
@@ -1001,4 +962,4 @@ declare function getDataFetchingFunctions(): Promise<{
|
|
|
1001
962
|
getPrefetchData: typeof getPrefetchData;
|
|
1002
963
|
}>;
|
|
1003
964
|
|
|
1004
|
-
export { DEFAULT_STATE_PRESERVATION, type DataFetchOptions, type DataFetchState, type HMRStatePreservation, type HMRUpdate, type HMRUpdateType, type HookHandler, type HydrationError, HydrationErrorHandler, type HydrationMismatch, type HydrationMode, type HydrationOptions, type HydrationStats, type ComponentOptions as IslandComponentOptions, type LifecycleEvent, OptimizedSSRStream, type OptimizedStreamOptions, type RendererPlugin as Plugin, type PluginContext, type PrefetchDataEntry, type PrefetchManager, type PreloadHint, type RecoveryStrategy, type RendererPlugin, type ResourceCleanupRenderer, type SSRStreamOptions, type ServerActionRequest, type ServerActionResponse, type ServerComponentDefinition, type SignalRenderer, type StreamStats,
|
|
965
|
+
export { DEFAULT_STATE_PRESERVATION, type DataFetchOptions, type DataFetchState, type HMRStatePreservation, type HMRUpdate, type HMRUpdateType, type HookHandler, type HydrationError, HydrationErrorHandler, type HydrationMismatch, type HydrationMode, type HydrationOptions, type HydrationStats, type ComponentOptions as IslandComponentOptions, type LifecycleEvent, OptimizedSSRStream, type OptimizedStreamOptions, type RendererPlugin as Plugin, type PluginContext, type PrefetchDataEntry, type PrefetchManager, type PreloadHint, type RecoveryStrategy, type RendererPlugin, type ResourceCleanupRenderer, type SSRStreamOptions, type ServerActionRequest, type ServerActionResponse, type ServerComponentDefinition, type SignalRenderer, type StreamStats, VaporApp, VaporComponentDefinition, type VaporHydrationOptions, type SignalRenderer as VaporRenderer, type VaporSSROptions, type VaporSSRResult, type VaporSSRStreamResult, cleanupComponentResources, createIslandSSRContent, createOptimizedStream, createSignalRenderer, createVaporApp, createVaporRenderer, definePrefetch, defineVaporComponent, executeHooks, getDataFetchingFunctions, getEnhancedHydrationFunctions, getInstalledPlugins, getServerComponentClientFunctions, getServerComponentFunctions, getVaporHMRFunctions, hydrateIsland, hydrateVaporComponent, isPluginInstalled, isVoidElement, registerComponentCleanup, registerComponentEffectSubscription, registerComponentEventListener, registerIslandComponent, removePlugin, renderDocumentToStream, renderToStream, renderToString, renderVaporToStream, renderVaporToString, use, usePrefetchData };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Ref } from '@lytjs/reactivity';
|
|
2
2
|
export { getSkippedTrackingCount, resetSkippedTrackingCount, shouldSkipTracking, withFirstRenderOptimization } from '@lytjs/reactivity';
|
|
3
|
+
import { VaporComponentDefinition, VaporApp } from './vapor/vapor-app.js';
|
|
4
|
+
export { VaporAppOptions, VaporComponentOptions, VaporContext, PropOptions as VaporPropOptions } from './vapor/vapor-app.js';
|
|
3
5
|
import { VNode } from '@lytjs/vdom';
|
|
4
6
|
export { RendererOptions, VNode, createRenderer } from '@lytjs/vdom';
|
|
5
7
|
export { DOMRenderer, EventInvoker, HydrationRenderer, ParsedEvent, WebRendererHost, createDOMRenderer, createHydrationFunctions, createInvoker, createWebHost, getEventKey, normalizeEventName, parseEventModifier, patchAttr, patchClass, patchEvent, patchProp, patchStyle, removeAllEventListeners, wrapDOMEvent } from '@lytjs/adapter-web';
|
|
@@ -278,47 +280,6 @@ declare function defineServerComponent(options: Omit<ServerComponentDefinition,
|
|
|
278
280
|
serializeData?: () => string;
|
|
279
281
|
}): ServerComponentDefinition;
|
|
280
282
|
|
|
281
|
-
/** Vapor 组件的上下文对象 */
|
|
282
|
-
interface VaporContext {
|
|
283
|
-
attrs: Record<string, unknown>;
|
|
284
|
-
slots: Record<string, () => Node>;
|
|
285
|
-
emit: (event: string, ...args: unknown[]) => void;
|
|
286
|
-
}
|
|
287
|
-
/** Prop 定义选项 */
|
|
288
|
-
interface PropOptions {
|
|
289
|
-
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';
|
|
290
|
-
default?: unknown;
|
|
291
|
-
required?: boolean;
|
|
292
|
-
validator?: (value: unknown) => boolean;
|
|
293
|
-
}
|
|
294
|
-
/** Vapor 组件定义选项 */
|
|
295
|
-
interface VaporComponentOptions {
|
|
296
|
-
name?: string;
|
|
297
|
-
props?: Record<string, PropOptions>;
|
|
298
|
-
setup?: (props: Record<string, unknown>, context: VaporContext) => Record<string, unknown> | void;
|
|
299
|
-
template: string;
|
|
300
|
-
}
|
|
301
|
-
/** Vapor 组件定义(编译后的结果) */
|
|
302
|
-
interface VaporComponentDefinition {
|
|
303
|
-
name?: string;
|
|
304
|
-
props?: Record<string, PropOptions>;
|
|
305
|
-
setup?: (props: Record<string, unknown>, context: VaporContext) => Record<string, unknown> | void;
|
|
306
|
-
template: string;
|
|
307
|
-
compiledCode?: string;
|
|
308
|
-
}
|
|
309
|
-
/** Vapor 应用配置选项 */
|
|
310
|
-
interface VaporAppOptions {
|
|
311
|
-
/** 根容器属性(传递给根组件的 props) */
|
|
312
|
-
rootProps?: Record<string, unknown>;
|
|
313
|
-
}
|
|
314
|
-
/** Vapor 应用实例 */
|
|
315
|
-
interface VaporApp {
|
|
316
|
-
mount(container: Element | string): void;
|
|
317
|
-
unmount(): void;
|
|
318
|
-
provide(key: string | symbol, value: unknown): void;
|
|
319
|
-
component(name: string, component: VaporComponentDefinition): VaporApp;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
283
|
/** HMR 更新类型 */
|
|
323
284
|
type HMRUpdateType = 'template' | 'script' | 'style' | 'full';
|
|
324
285
|
/** HMR 更新信息 */
|
|
@@ -1001,4 +962,4 @@ declare function getDataFetchingFunctions(): Promise<{
|
|
|
1001
962
|
getPrefetchData: typeof getPrefetchData;
|
|
1002
963
|
}>;
|
|
1003
964
|
|
|
1004
|
-
export { DEFAULT_STATE_PRESERVATION, type DataFetchOptions, type DataFetchState, type HMRStatePreservation, type HMRUpdate, type HMRUpdateType, type HookHandler, type HydrationError, HydrationErrorHandler, type HydrationMismatch, type HydrationMode, type HydrationOptions, type HydrationStats, type ComponentOptions as IslandComponentOptions, type LifecycleEvent, OptimizedSSRStream, type OptimizedStreamOptions, type RendererPlugin as Plugin, type PluginContext, type PrefetchDataEntry, type PrefetchManager, type PreloadHint, type RecoveryStrategy, type RendererPlugin, type ResourceCleanupRenderer, type SSRStreamOptions, type ServerActionRequest, type ServerActionResponse, type ServerComponentDefinition, type SignalRenderer, type StreamStats,
|
|
965
|
+
export { DEFAULT_STATE_PRESERVATION, type DataFetchOptions, type DataFetchState, type HMRStatePreservation, type HMRUpdate, type HMRUpdateType, type HookHandler, type HydrationError, HydrationErrorHandler, type HydrationMismatch, type HydrationMode, type HydrationOptions, type HydrationStats, type ComponentOptions as IslandComponentOptions, type LifecycleEvent, OptimizedSSRStream, type OptimizedStreamOptions, type RendererPlugin as Plugin, type PluginContext, type PrefetchDataEntry, type PrefetchManager, type PreloadHint, type RecoveryStrategy, type RendererPlugin, type ResourceCleanupRenderer, type SSRStreamOptions, type ServerActionRequest, type ServerActionResponse, type ServerComponentDefinition, type SignalRenderer, type StreamStats, VaporApp, VaporComponentDefinition, type VaporHydrationOptions, type SignalRenderer as VaporRenderer, type VaporSSROptions, type VaporSSRResult, type VaporSSRStreamResult, cleanupComponentResources, createIslandSSRContent, createOptimizedStream, createSignalRenderer, createVaporApp, createVaporRenderer, definePrefetch, defineVaporComponent, executeHooks, getDataFetchingFunctions, getEnhancedHydrationFunctions, getInstalledPlugins, getServerComponentClientFunctions, getServerComponentFunctions, getVaporHMRFunctions, hydrateIsland, hydrateVaporComponent, isPluginInstalled, isVoidElement, registerComponentCleanup, registerComponentEffectSubscription, registerComponentEventListener, registerIslandComponent, removePlugin, renderDocumentToStream, renderToStream, renderToString, renderVaporToStream, renderVaporToString, use, usePrefetchData };
|
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ export { escapeHtml, isBooleanAttr } from '@lytjs/common-string';
|
|
|
4
4
|
import { isFunction, isArray, isString, isNullish, isObject } from '@lytjs/common-is';
|
|
5
5
|
import { ShapeFlags, Fragment, Text, Comment } from '@lytjs/vdom';
|
|
6
6
|
export { createRenderer } from '@lytjs/vdom';
|
|
7
|
-
import { compile } from '@lytjs/compiler';
|
|
7
|
+
import { clearCompileCache, compile } from '@lytjs/compiler';
|
|
8
8
|
import { effect, ref, watch } from '@lytjs/reactivity';
|
|
9
9
|
export { getSkippedTrackingCount, resetSkippedTrackingCount, shouldSkipTracking, withFirstRenderOptimization } from '@lytjs/reactivity';
|
|
10
|
-
import { reconcileArray, createTemplate, setText, setAttribute, setProperty, setStyle, setClass, insert, remove, createEventHandler,
|
|
10
|
+
import { reconcileArray, createTemplate, setText, setHTML, setAttribute, setProperty, setStyle, setClass, insert, remove, createEventHandler, onCleanup, runCleanups } from '@lytjs/dom-runtime';
|
|
11
11
|
export { WebRendererHost, createDOMRenderer, createHydrationFunctions, createInvoker, createWebHost, getEventKey, normalizeEventName, parseEventModifier, patchAttr, patchClass, patchEvent, patchProp, patchStyle, removeAllEventListeners, wrapDOMEvent } from '@lytjs/adapter-web';
|
|
12
12
|
export { isOn } from '@lytjs/common-events';
|
|
13
13
|
|
|
@@ -1122,17 +1122,13 @@ var signal_renderer_exports = {};
|
|
|
1122
1122
|
__export(signal_renderer_exports, {
|
|
1123
1123
|
createSignalRenderer: () => createSignalRenderer
|
|
1124
1124
|
});
|
|
1125
|
-
function setSafeHTML(el, html) {
|
|
1126
|
-
const wrapper = el;
|
|
1127
|
-
const realNode = "content" in wrapper && "firstChild" in wrapper && wrapper.firstChild !== null ? wrapper.firstChild : el;
|
|
1128
|
-
realNode.textContent = html;
|
|
1129
|
-
}
|
|
1130
1125
|
function createSignalRenderer(template, context) {
|
|
1131
1126
|
let cleanup = null;
|
|
1132
1127
|
let code;
|
|
1133
1128
|
let renderBody;
|
|
1134
1129
|
try {
|
|
1135
|
-
|
|
1130
|
+
clearCompileCache();
|
|
1131
|
+
const compileResult = compile(template, { rendererMode: "signal", optimizeSignal: false });
|
|
1136
1132
|
code = compileResult.code;
|
|
1137
1133
|
renderBody = extractRenderBody(code);
|
|
1138
1134
|
if (!renderBody) {
|
|
@@ -1167,19 +1163,36 @@ function createSignalRenderer(template, context) {
|
|
|
1167
1163
|
"insert",
|
|
1168
1164
|
"remove",
|
|
1169
1165
|
"createEventHandler",
|
|
1170
|
-
"bindEffect",
|
|
1171
1166
|
"onCleanup",
|
|
1172
1167
|
"runCleanups",
|
|
1173
1168
|
"_ctx",
|
|
1174
1169
|
"_container",
|
|
1175
1170
|
renderBody
|
|
1176
1171
|
);
|
|
1172
|
+
const proxiedCtx = new Proxy(context, {
|
|
1173
|
+
get(target, prop) {
|
|
1174
|
+
const val = target[prop];
|
|
1175
|
+
if (val && typeof val === "object" && "value" in val) {
|
|
1176
|
+
return val.value;
|
|
1177
|
+
}
|
|
1178
|
+
return val;
|
|
1179
|
+
},
|
|
1180
|
+
set(target, prop, value) {
|
|
1181
|
+
const val = target[prop];
|
|
1182
|
+
if (val && typeof val === "object" && "value" in val) {
|
|
1183
|
+
val.value = value;
|
|
1184
|
+
return true;
|
|
1185
|
+
}
|
|
1186
|
+
target[prop] = value;
|
|
1187
|
+
return true;
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1177
1190
|
const cleanupFn = renderFn(
|
|
1178
1191
|
effect,
|
|
1179
1192
|
reconcileArray,
|
|
1180
1193
|
createTemplate,
|
|
1181
1194
|
setText,
|
|
1182
|
-
|
|
1195
|
+
setHTML,
|
|
1183
1196
|
setAttribute,
|
|
1184
1197
|
setProperty,
|
|
1185
1198
|
setStyle,
|
|
@@ -1187,10 +1200,9 @@ function createSignalRenderer(template, context) {
|
|
|
1187
1200
|
insert,
|
|
1188
1201
|
remove,
|
|
1189
1202
|
createEventHandler,
|
|
1190
|
-
bindEffect,
|
|
1191
1203
|
onCleanup,
|
|
1192
1204
|
runCleanups,
|
|
1193
|
-
|
|
1205
|
+
proxiedCtx,
|
|
1194
1206
|
el
|
|
1195
1207
|
);
|
|
1196
1208
|
if (typeof cleanupFn === "function") {
|