wevu 6.20.5 → 6.21.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/dist/dev/internal-runtime.mjs +2 -2
- package/dist/dev/package.mjs +1 -1
- package/dist/dev/runtime/app.mjs +1 -1
- package/dist/dev/runtime/app.mjs.map +1 -1
- package/dist/dev/runtime/define/componentDefinition.mjs +25 -0
- package/dist/dev/runtime/define/componentDefinition.mjs.map +1 -0
- package/dist/dev/runtime/define.mjs +29 -25
- package/dist/dev/runtime/define.mjs.map +1 -1
- package/dist/dev/runtime/provideContext.mjs +2 -2
- package/dist/dev/runtime/provideContext.mjs.map +1 -1
- package/dist/internal-runtime.d.mts +2 -2
- package/dist/internal-runtime.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/define/componentDefinition.mjs +1 -0
- package/dist/runtime/define.d.mts +8 -1
- package/dist/runtime/define.mjs +1 -1
- package/dist/runtime/provideContext.mjs +1 -1
- package/package.json +4 -4
|
@@ -15,7 +15,7 @@ import { resolveLayoutBridge, resolveLayoutHost, useLayoutBridge, useLayoutHosts
|
|
|
15
15
|
import { registerComponent } from "./runtime/register/component.mjs";
|
|
16
16
|
import { createApp } from "./runtime/app.mjs";
|
|
17
17
|
import { hasInjectionContext, inject, injectGlobal, provide, provideGlobal } from "./runtime/provide.mjs";
|
|
18
|
-
import { createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition } from "./runtime/define.mjs";
|
|
18
|
+
import { createIsolatedWevuComponentDefinition, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition } from "./runtime/define.mjs";
|
|
19
19
|
import { useDisposables } from "./runtime/disposables.mjs";
|
|
20
20
|
import { useElementIntersectionObserver } from "./runtime/elementIntersectionObserver.mjs";
|
|
21
21
|
import { useIntersectionObserver } from "./runtime/intersectionObserver.mjs";
|
|
@@ -31,4 +31,4 @@ import { useNativePageRouter, useNativeRouter } from "./runtime/vueCompat/router
|
|
|
31
31
|
import { useTemplateRef } from "./runtime/vueCompat/templateRef.mjs";
|
|
32
32
|
import { createUniAppHost } from "./runtime/uniAppHost.mjs";
|
|
33
33
|
|
|
34
|
-
export { Fragment, INTERNAL_DEFAULTS_SCOPE_KEY, callHookList, callHookReturn, createApp, createTextVNode, createUniAppHost, createVNode, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineAppSetup, defineComponent, getCurrentInstance, getCurrentPageStackSnapshot, getCurrentSetupContext, getNavigationBarMetrics, getWevuComponentLifecycleDefinition, hasInjectionContext, inject, injectGlobal, isNoSetData, isVNode, markNoSetData, mergeModels, mergeProps, mountRuntimeInstance, normalizeJsxIsland, onActivated, onAddToFavorites, onAttached, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onDetached, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMemoryWarning, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, provide, provideGlobal, registerApp, registerComponent, resetWevuDefaults, resolveComponent, resolveDirective, resolveLayoutBridge, resolveLayoutHost, resolveRuntimePageLayoutName, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setGlobalProvidedValue, setPageLayout, setRuntimeSetDataVisibility, setWevuDefaults, syncRuntimePageLayoutState, syncRuntimePageLayoutStateFromRuntime, takePendingRuntimeAppRegistration, teardownRuntimeInstance, transformOn, use, useAsyncPullDownRefresh, useAttrs, useBindModel, useBoundingClientRect, useChangeModel, useDisposables, useElementIntersectionObserver, useIntersectionObserver, useLayoutBridge, useLayoutHosts, useModel, useNativeInstance, useNativePageRouter, useNativeRouter, useNavigationBarMetrics, usePageLayout, usePageScrollThrottle, usePageStack, useScrollOffset, useSelectorFields, useSelectorQuery, useSlots, useTemplateRef, useUpdatePerformanceListener, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, version, waitForLayoutHost, withDirectives };
|
|
34
|
+
export { Fragment, INTERNAL_DEFAULTS_SCOPE_KEY, callHookList, callHookReturn, createApp, createIsolatedWevuComponentDefinition, createTextVNode, createUniAppHost, createVNode, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineAppSetup, defineComponent, getCurrentInstance, getCurrentPageStackSnapshot, getCurrentSetupContext, getNavigationBarMetrics, getWevuComponentLifecycleDefinition, hasInjectionContext, inject, injectGlobal, isNoSetData, isVNode, markNoSetData, mergeModels, mergeProps, mountRuntimeInstance, normalizeJsxIsland, onActivated, onAddToFavorites, onAttached, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onDetached, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMemoryWarning, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, provide, provideGlobal, registerApp, registerComponent, resetWevuDefaults, resolveComponent, resolveDirective, resolveLayoutBridge, resolveLayoutHost, resolveRuntimePageLayoutName, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setGlobalProvidedValue, setPageLayout, setRuntimeSetDataVisibility, setWevuDefaults, syncRuntimePageLayoutState, syncRuntimePageLayoutStateFromRuntime, takePendingRuntimeAppRegistration, teardownRuntimeInstance, transformOn, use, useAsyncPullDownRefresh, useAttrs, useBindModel, useBoundingClientRect, useChangeModel, useDisposables, useElementIntersectionObserver, useIntersectionObserver, useLayoutBridge, useLayoutHosts, useModel, useNativeInstance, useNativePageRouter, useNativeRouter, useNavigationBarMetrics, usePageLayout, usePageScrollThrottle, usePageStack, useScrollOffset, useSelectorFields, useSelectorQuery, useSlots, useTemplateRef, useUpdatePerformanceListener, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, version, waitForLayoutHost, withDirectives };
|
package/dist/dev/package.mjs
CHANGED
package/dist/dev/runtime/app.mjs
CHANGED
|
@@ -33,7 +33,7 @@ function createApp(options) {
|
|
|
33
33
|
return runtimeApp;
|
|
34
34
|
},
|
|
35
35
|
provide(key, value) {
|
|
36
|
-
setRuntimeAppProvidedValue(runtimeApp, key, value);
|
|
36
|
+
setRuntimeAppProvidedValue(runtimeApp, key, value, { syncGlobal: defaultsScope !== "component" });
|
|
37
37
|
return runtimeApp;
|
|
38
38
|
},
|
|
39
39
|
onUnmount(cleanup) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.mjs","names":[],"sources":["../../../src/runtime/app.ts"],"sourcesContent":["import type {\n AppConfig,\n ComputedDefinitions,\n CreateAppOptions,\n MethodDefinitions,\n RuntimeApp,\n WevuPlugin,\n} from './types'\nimport { version } from '../version'\nimport { createRuntimeMount } from './app/mount'\nimport { setPendingRuntimeAppRegistration } from './app/pending'\nimport { applyWevuAppDefaults, INTERNAL_DEFAULTS_SCOPE_KEY } from './defaults'\nimport { getMiniProgramGlobalObject } from './platform'\nimport { ensureRuntimeAppProvides, setRuntimeAppProvidedValue } from './provideContext'\nimport { registerApp } from './register'\n\nexport function createApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(\n options: CreateAppOptions<D, C, M>,\n): RuntimeApp<D, C, M> {\n const defaultsScope = (options as any)[INTERNAL_DEFAULTS_SCOPE_KEY] as string | undefined\n const resolvedOptions = defaultsScope === 'component'\n ? options\n : applyWevuAppDefaults(options)\n const {\n [INTERNAL_DEFAULTS_SCOPE_KEY]: _ignoredDefaultsScope,\n data,\n computed: computedOptions,\n methods,\n setData: setDataOptions,\n watch: appWatch,\n setup: appSetup,\n ...mpOptions\n } = resolvedOptions\n const resolvedMethods = methods ?? ({} as M)\n const resolvedComputed = computedOptions ?? ({} as C)\n\n const installedPlugins = new Set<WevuPlugin>()\n const appUnmountCleanups = new Set<() => void>()\n let appUnmounted = false\n const appConfig: AppConfig = { globalProperties: {} }\n const mount = createRuntimeMount<D, C, M>({\n data,\n resolvedComputed,\n resolvedMethods,\n appConfig,\n setDataOptions,\n })\n\n const runtimeApp: RuntimeApp<D, C, M> = {\n mount,\n use(plugin: WevuPlugin, ...options: any[]) {\n if (!plugin || installedPlugins.has(plugin)) {\n return runtimeApp\n }\n installedPlugins.add(plugin)\n if (typeof plugin === 'function') {\n plugin(runtimeApp, ...options)\n }\n else if (typeof plugin.install === 'function') {\n plugin.install(runtimeApp, ...options)\n }\n else {\n throw new TypeError('插件必须是函数,或包含 install 方法的对象')\n }\n return runtimeApp\n },\n provide(key: any, value: any) {\n setRuntimeAppProvidedValue(runtimeApp, key, value)\n return runtimeApp\n },\n onUnmount(cleanup: () => void) {\n if (typeof cleanup !== 'function') {\n throw new TypeError('onUnmount 只接受函数')\n }\n if (appUnmounted) {\n cleanup()\n return runtimeApp\n }\n appUnmountCleanups.add(cleanup)\n return runtimeApp\n },\n unmount() {\n if (appUnmounted) {\n return\n }\n appUnmounted = true\n for (const cleanup of appUnmountCleanups) {\n cleanup()\n }\n appUnmountCleanups.clear()\n },\n config: appConfig,\n version,\n }\n\n try {\n ensureRuntimeAppProvides(runtimeApp)\n Object.defineProperty(runtimeApp as Record<string, any>, '__wevuSetDataOptions', {\n value: setDataOptions,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n Object.defineProperty(runtimeApp as Record<string, any>, '__wevuHasTemplateRuntimeBindings', {\n value: Object.keys(resolvedComputed as Record<string, unknown>).some(key => key.startsWith('__wv_bind_')),\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(runtimeApp as any).__wevuSetDataOptions = setDataOptions\n ;(runtimeApp as any).__wevuHasTemplateRuntimeBindings = Object.keys(resolvedComputed as Record<string, unknown>)\n .some(key => key.startsWith('__wv_bind_'))\n }\n\n const registerRuntimeApp = () => {\n const globalObject = getMiniProgramGlobalObject()\n const appRegisterKey = '__wevuAppRegistered'\n const hasRegistered = globalObject ? Boolean(globalObject[appRegisterKey]) : false\n // 开发者工具/HMR 可能重复执行入口,避免多次 App() 导致 AppService 事件监听累积。\n if (!hasRegistered) {\n if (globalObject) {\n globalObject[appRegisterKey] = true\n }\n // 若检测到全局 App 构造器则自动注册小程序 App\n registerApp<D, C, M>(runtimeApp, (methods ?? {}) as any, appWatch as any, appSetup as any, mpOptions as any)\n }\n }\n\n if (defaultsScope !== 'component' && typeof App === 'function') {\n registerRuntimeApp()\n }\n else if (defaultsScope !== 'component') {\n setPendingRuntimeAppRegistration({\n app: runtimeApp,\n register: registerRuntimeApp,\n })\n }\n\n return runtimeApp\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,UACd,SACqB;CACrB,MAAM,gBAAiB,QAAgB;CAIvC,MAAM,GACH,8BAA8B,uBAC/B,MACA,UAAU,iBACV,SACA,SAAS,gBACT,OAAO,UACP,OAAO,UACP,GAAG,cAXmB,kBAAkB,cACtC,UACA,qBAAqB,OAAO;CAWhC,MAAM,kBAAkB,mDAAY,CAAC;CACrC,MAAM,mBAAmB,2EAAoB,CAAC;CAE9C,MAAM,mCAAmB,IAAI,IAAgB;CAC7C,MAAM,qCAAqB,IAAI,IAAgB;CAC/C,IAAI,eAAe;CACnB,MAAM,YAAuB,EAAE,kBAAkB,CAAC,EAAE;CASpD,MAAM,aAAkC;EACtC,OATY,mBAA4B;GACxC;GACA;GACA;GACA;GACA;EACF,CAGM;EACJ,IAAI,QAAoB,GAAG,SAAgB;GACzC,IAAI,CAAC,UAAU,iBAAiB,IAAI,MAAM,GACxC,OAAO;GAET,iBAAiB,IAAI,MAAM;GAC3B,IAAI,OAAO,WAAW,YACpB,OAAO,YAAY,GAAG,OAAO;QAE1B,IAAI,OAAO,OAAO,YAAY,YACjC,OAAO,QAAQ,YAAY,GAAG,OAAO;QAGrC,MAAM,IAAI,UAAU,2BAA2B;GAEjD,OAAO;EACT;EACA,QAAQ,KAAU,OAAY;GAC5B,2BAA2B,YAAY,KAAK,
|
|
1
|
+
{"version":3,"file":"app.mjs","names":[],"sources":["../../../src/runtime/app.ts"],"sourcesContent":["import type {\n AppConfig,\n ComputedDefinitions,\n CreateAppOptions,\n MethodDefinitions,\n RuntimeApp,\n WevuPlugin,\n} from './types'\nimport { version } from '../version'\nimport { createRuntimeMount } from './app/mount'\nimport { setPendingRuntimeAppRegistration } from './app/pending'\nimport { applyWevuAppDefaults, INTERNAL_DEFAULTS_SCOPE_KEY } from './defaults'\nimport { getMiniProgramGlobalObject } from './platform'\nimport { ensureRuntimeAppProvides, setRuntimeAppProvidedValue } from './provideContext'\nimport { registerApp } from './register'\n\nexport function createApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(\n options: CreateAppOptions<D, C, M>,\n): RuntimeApp<D, C, M> {\n const defaultsScope = (options as any)[INTERNAL_DEFAULTS_SCOPE_KEY] as string | undefined\n const resolvedOptions = defaultsScope === 'component'\n ? options\n : applyWevuAppDefaults(options)\n const {\n [INTERNAL_DEFAULTS_SCOPE_KEY]: _ignoredDefaultsScope,\n data,\n computed: computedOptions,\n methods,\n setData: setDataOptions,\n watch: appWatch,\n setup: appSetup,\n ...mpOptions\n } = resolvedOptions\n const resolvedMethods = methods ?? ({} as M)\n const resolvedComputed = computedOptions ?? ({} as C)\n\n const installedPlugins = new Set<WevuPlugin>()\n const appUnmountCleanups = new Set<() => void>()\n let appUnmounted = false\n const appConfig: AppConfig = { globalProperties: {} }\n const mount = createRuntimeMount<D, C, M>({\n data,\n resolvedComputed,\n resolvedMethods,\n appConfig,\n setDataOptions,\n })\n\n const runtimeApp: RuntimeApp<D, C, M> = {\n mount,\n use(plugin: WevuPlugin, ...options: any[]) {\n if (!plugin || installedPlugins.has(plugin)) {\n return runtimeApp\n }\n installedPlugins.add(plugin)\n if (typeof plugin === 'function') {\n plugin(runtimeApp, ...options)\n }\n else if (typeof plugin.install === 'function') {\n plugin.install(runtimeApp, ...options)\n }\n else {\n throw new TypeError('插件必须是函数,或包含 install 方法的对象')\n }\n return runtimeApp\n },\n provide(key: any, value: any) {\n setRuntimeAppProvidedValue(runtimeApp, key, value, {\n syncGlobal: defaultsScope !== 'component',\n })\n return runtimeApp\n },\n onUnmount(cleanup: () => void) {\n if (typeof cleanup !== 'function') {\n throw new TypeError('onUnmount 只接受函数')\n }\n if (appUnmounted) {\n cleanup()\n return runtimeApp\n }\n appUnmountCleanups.add(cleanup)\n return runtimeApp\n },\n unmount() {\n if (appUnmounted) {\n return\n }\n appUnmounted = true\n for (const cleanup of appUnmountCleanups) {\n cleanup()\n }\n appUnmountCleanups.clear()\n },\n config: appConfig,\n version,\n }\n\n try {\n ensureRuntimeAppProvides(runtimeApp)\n Object.defineProperty(runtimeApp as Record<string, any>, '__wevuSetDataOptions', {\n value: setDataOptions,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n Object.defineProperty(runtimeApp as Record<string, any>, '__wevuHasTemplateRuntimeBindings', {\n value: Object.keys(resolvedComputed as Record<string, unknown>).some(key => key.startsWith('__wv_bind_')),\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(runtimeApp as any).__wevuSetDataOptions = setDataOptions\n ;(runtimeApp as any).__wevuHasTemplateRuntimeBindings = Object.keys(resolvedComputed as Record<string, unknown>)\n .some(key => key.startsWith('__wv_bind_'))\n }\n\n const registerRuntimeApp = () => {\n const globalObject = getMiniProgramGlobalObject()\n const appRegisterKey = '__wevuAppRegistered'\n const hasRegistered = globalObject ? Boolean(globalObject[appRegisterKey]) : false\n // 开发者工具/HMR 可能重复执行入口,避免多次 App() 导致 AppService 事件监听累积。\n if (!hasRegistered) {\n if (globalObject) {\n globalObject[appRegisterKey] = true\n }\n // 若检测到全局 App 构造器则自动注册小程序 App\n registerApp<D, C, M>(runtimeApp, (methods ?? {}) as any, appWatch as any, appSetup as any, mpOptions as any)\n }\n }\n\n if (defaultsScope !== 'component' && typeof App === 'function') {\n registerRuntimeApp()\n }\n else if (defaultsScope !== 'component') {\n setPendingRuntimeAppRegistration({\n app: runtimeApp,\n register: registerRuntimeApp,\n })\n }\n\n return runtimeApp\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,UACd,SACqB;CACrB,MAAM,gBAAiB,QAAgB;CAIvC,MAAM,GACH,8BAA8B,uBAC/B,MACA,UAAU,iBACV,SACA,SAAS,gBACT,OAAO,UACP,OAAO,UACP,GAAG,cAXmB,kBAAkB,cACtC,UACA,qBAAqB,OAAO;CAWhC,MAAM,kBAAkB,mDAAY,CAAC;CACrC,MAAM,mBAAmB,2EAAoB,CAAC;CAE9C,MAAM,mCAAmB,IAAI,IAAgB;CAC7C,MAAM,qCAAqB,IAAI,IAAgB;CAC/C,IAAI,eAAe;CACnB,MAAM,YAAuB,EAAE,kBAAkB,CAAC,EAAE;CASpD,MAAM,aAAkC;EACtC,OATY,mBAA4B;GACxC;GACA;GACA;GACA;GACA;EACF,CAGM;EACJ,IAAI,QAAoB,GAAG,SAAgB;GACzC,IAAI,CAAC,UAAU,iBAAiB,IAAI,MAAM,GACxC,OAAO;GAET,iBAAiB,IAAI,MAAM;GAC3B,IAAI,OAAO,WAAW,YACpB,OAAO,YAAY,GAAG,OAAO;QAE1B,IAAI,OAAO,OAAO,YAAY,YACjC,OAAO,QAAQ,YAAY,GAAG,OAAO;QAGrC,MAAM,IAAI,UAAU,2BAA2B;GAEjD,OAAO;EACT;EACA,QAAQ,KAAU,OAAY;GAC5B,2BAA2B,YAAY,KAAK,OAAO,EACjD,YAAY,kBAAkB,YAChC,CAAC;GACD,OAAO;EACT;EACA,UAAU,SAAqB;GAC7B,IAAI,OAAO,YAAY,YACrB,MAAM,IAAI,UAAU,iBAAiB;GAEvC,IAAI,cAAc;IAChB,QAAQ;IACR,OAAO;GACT;GACA,mBAAmB,IAAI,OAAO;GAC9B,OAAO;EACT;EACA,UAAU;GACR,IAAI,cACF;GAEF,eAAe;GACf,KAAK,MAAM,WAAW,oBACpB,QAAQ;GAEV,mBAAmB,MAAM;EAC3B;EACA,QAAQ;EACR;CACF;CAEA,IAAI;EACF,yBAAyB,UAAU;EACnC,OAAO,eAAe,YAAmC,wBAAwB;GAC/E,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;EACD,OAAO,eAAe,YAAmC,oCAAoC;GAC3F,OAAO,OAAO,KAAK,gBAA2C,CAAC,CAAC,MAAK,QAAO,IAAI,WAAW,YAAY,CAAC;GACxG,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,kBACM;EACH,AAAC,WAAmB,uBAAuB;EAC3C,AAAC,WAAmB,mCAAmC,OAAO,KAAK,gBAA2C,CAAC,CAC7G,MAAK,QAAO,IAAI,WAAW,YAAY,CAAC;CAC7C;CAEA,MAAM,2BAA2B;EAC/B,MAAM,eAAe,2BAA2B;EAChD,MAAM,iBAAiB;EAGvB,IAAI,EAFkB,eAAe,QAAQ,aAAa,eAAe,IAAI,QAEzD;GAClB,IAAI,cACF,aAAa,kBAAkB;GAGjC,YAAqB,YAAa,mDAAW,CAAC,GAAW,UAAiB,UAAiB,SAAgB;EAC7G;CACF;CAEA,IAAI,kBAAkB,eAAe,OAAO,QAAQ,YAClD,mBAAmB;MAEhB,IAAI,kBAAkB,aACzB,iCAAiC;EAC/B,KAAK;EACL,UAAU;CACZ,CAAC;CAGH,OAAO;AACT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { INTERNAL_DEFAULTS_SCOPE_KEY } from "../defaults.mjs";
|
|
2
|
+
import { registerComponent } from "../register/component.mjs";
|
|
3
|
+
import { createApp } from "../app.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/define/componentDefinition.ts
|
|
6
|
+
/**
|
|
7
|
+
* 从稳定的组件选项快照创建独立运行时和宿主生命周期定义。
|
|
8
|
+
*/
|
|
9
|
+
function createRuntimeComponentDefinition(options, registerNative = false) {
|
|
10
|
+
const runtimeApp = createApp({
|
|
11
|
+
data: options.data,
|
|
12
|
+
computed: options.computed,
|
|
13
|
+
methods: options.methods,
|
|
14
|
+
setData: options.setData,
|
|
15
|
+
[INTERNAL_DEFAULTS_SCOPE_KEY]: "component"
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
lifecycleDefinition: registerComponent(runtimeApp, options.methods, options.watch, options.setup, options.mpOptions, { registerNative }),
|
|
19
|
+
runtimeApp
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { createRuntimeComponentDefinition };
|
|
25
|
+
//# sourceMappingURL=componentDefinition.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentDefinition.mjs","names":[],"sources":["../../../../src/runtime/define/componentDefinition.ts"],"sourcesContent":["import type { WatchMap } from '../register/watch'\nimport type {\n ComputedDefinitions,\n MethodDefinitions,\n MiniProgramComponentRawOptions,\n SetDataSnapshotOptions,\n} from '../types'\nimport { createApp } from '../app'\nimport { INTERNAL_DEFAULTS_SCOPE_KEY } from '../defaults'\nimport { registerComponent } from '../register'\n\nexport interface RuntimeComponentDefinitionOptions {\n data: (() => Record<string, any>) | undefined\n computed: ComputedDefinitions\n methods: MethodDefinitions\n setData: SetDataSnapshotOptions | undefined\n watch: WatchMap | undefined\n setup: ((props: any, ctx: any) => any) | undefined\n mpOptions: MiniProgramComponentRawOptions\n}\n\n/**\n * 从稳定的组件选项快照创建独立运行时和宿主生命周期定义。\n */\nexport function createRuntimeComponentDefinition(\n options: RuntimeComponentDefinitionOptions,\n registerNative = false,\n) {\n const runtimeApp = createApp({\n data: options.data,\n computed: options.computed,\n methods: options.methods,\n setData: options.setData,\n [INTERNAL_DEFAULTS_SCOPE_KEY]: 'component',\n } as any)\n const lifecycleDefinition = registerComponent(\n runtimeApp as any,\n options.methods,\n options.watch,\n options.setup,\n options.mpOptions,\n { registerNative },\n )\n\n return {\n lifecycleDefinition,\n runtimeApp,\n }\n}\n"],"mappings":";;;;;;;;AAwBA,SAAgB,iCACd,SACA,iBAAiB,OACjB;CACA,MAAM,aAAa,UAAU;EAC3B,MAAM,QAAQ;EACd,UAAU,QAAQ;EAClB,SAAS,QAAQ;EACjB,SAAS,QAAQ;GAChB,8BAA8B;CACjC,CAAQ;CAUR,OAAO;EACL,qBAV0B,kBAC1B,YACA,QAAQ,SACR,QAAQ,OACR,QAAQ,OACR,QAAQ,WACR,EAAE,eAAe,CAIC;EAClB;CACF;AACF"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { getScopedSlotHostGlobalObject } from "./platform.mjs";
|
|
2
2
|
import { hasOwn } from "../utils.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { applyWevuComponentDefaults } from "./defaults.mjs";
|
|
4
4
|
import { allocateOwnerId } from "./scopedSlots.mjs";
|
|
5
5
|
import { runSetupFunction } from "./register/setup.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { createApp } from "./app.mjs";
|
|
6
|
+
import { createRuntimeComponentDefinition } from "./define/componentDefinition.mjs";
|
|
8
7
|
import { resolveNativeInitialData } from "./define/initialComputed.mjs";
|
|
9
8
|
import { resolveVueComponentOptions } from "./define/options.mjs";
|
|
10
9
|
import { applyOptionsApiProvide, resolveOptionsApiInjections } from "./define/optionsApi.mjs";
|
|
@@ -45,6 +44,15 @@ function resolveScopedSlotHostSetData(mpOptions, setData) {
|
|
|
45
44
|
strategy: "diff"
|
|
46
45
|
};
|
|
47
46
|
}
|
|
47
|
+
function materializeComponentDefinition(componentOptions, registerNative = false) {
|
|
48
|
+
const { lifecycleDefinition, runtimeApp } = createRuntimeComponentDefinition(componentOptions, registerNative);
|
|
49
|
+
const definition = {
|
|
50
|
+
__wevu_runtime: runtimeApp,
|
|
51
|
+
__wevu_options: componentOptions
|
|
52
|
+
};
|
|
53
|
+
componentLifecycleDefinitions.set(definition, lifecycleDefinition);
|
|
54
|
+
return definition;
|
|
55
|
+
}
|
|
48
56
|
function defineComponent(options) {
|
|
49
57
|
return createComponentDefinition(options, true);
|
|
50
58
|
}
|
|
@@ -66,13 +74,6 @@ function createComponentDefinition(options, registerNative) {
|
|
|
66
74
|
const normalizedMpOptions = normalizeProps(mpOptions, props);
|
|
67
75
|
const initialDataContext = resolveInitialDataContext(normalizedMpOptions.properties, methods);
|
|
68
76
|
const resolvedData = typeof data === "function" ? () => data.call(initialDataContext) : data;
|
|
69
|
-
const runtimeApp = createApp({
|
|
70
|
-
data: resolvedData,
|
|
71
|
-
computed,
|
|
72
|
-
methods,
|
|
73
|
-
setData: resolvedSetData,
|
|
74
|
-
[INTERNAL_DEFAULTS_SCOPE_KEY]: "component"
|
|
75
|
-
});
|
|
76
77
|
const setupWrapper = typeof setup === "function" || injectOptions != null || provideOptions != null ? ((props, ctx) => {
|
|
77
78
|
var _ref, _proxy;
|
|
78
79
|
const publicInstance = (_ref = (_proxy = ctx === null || ctx === void 0 ? void 0 : ctx.proxy) !== null && _proxy !== void 0 ? _proxy : ctx === null || ctx === void 0 ? void 0 : ctx.instance) !== null && _ref !== void 0 ? _ref : Object.create(null);
|
|
@@ -95,26 +96,18 @@ function createComponentDefinition(options, registerNative) {
|
|
|
95
96
|
[WEVU_SLOT_OWNER_ID_KEY]: shouldSeedNativeSlotOwnerId(mpOptions, resolvedSetData) ? (nativeData === null || nativeData === void 0 ? void 0 : nativeData[WEVU_SLOT_OWNER_ID_KEY]) || allocateOwnerId() : (nativeData === null || nativeData === void 0 ? void 0 : nativeData[WEVU_SLOT_OWNER_ID_KEY]) || ""
|
|
96
97
|
} : nativeData;
|
|
97
98
|
const nativeInitialData = resolveNativeInitialData(seededNativeData, computed, resolvedSetData, methods);
|
|
98
|
-
|
|
99
|
-
...normalizedMpOptions,
|
|
100
|
-
data: nativeInitialData
|
|
101
|
-
} : normalizedMpOptions;
|
|
102
|
-
const componentOptions = {
|
|
99
|
+
return materializeComponentDefinition({
|
|
103
100
|
data: resolvedData,
|
|
104
101
|
computed,
|
|
105
102
|
methods,
|
|
106
103
|
setData: resolvedSetData,
|
|
107
104
|
watch,
|
|
108
105
|
setup: setupWrapper,
|
|
109
|
-
mpOptions:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
__wevu_options: componentOptions
|
|
115
|
-
};
|
|
116
|
-
componentLifecycleDefinitions.set(definition, lifecycleDefinition);
|
|
117
|
-
return definition;
|
|
106
|
+
mpOptions: nativeInitialData !== void 0 ? {
|
|
107
|
+
...normalizedMpOptions,
|
|
108
|
+
data: nativeInitialData
|
|
109
|
+
} : normalizedMpOptions
|
|
110
|
+
}, registerNative);
|
|
118
111
|
}
|
|
119
112
|
/**
|
|
120
113
|
* 创建不触发宿主全局注册的 Wevu 组件定义。
|
|
@@ -126,6 +119,17 @@ function createWevuComponentDefinition(options) {
|
|
|
126
119
|
return createComponentDefinition(options, false);
|
|
127
120
|
}
|
|
128
121
|
/**
|
|
122
|
+
* 从现有组件定义派生拥有独立应用上下文的组件定义。
|
|
123
|
+
*
|
|
124
|
+
* @param definition 已解析的 Wevu 组件定义
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
function createIsolatedWevuComponentDefinition(definition) {
|
|
128
|
+
const componentOptions = definition.__wevu_options;
|
|
129
|
+
if (!componentOptions) throw new TypeError("无法从非 Wevu 组件定义创建独立运行时");
|
|
130
|
+
return materializeComponentDefinition(componentOptions);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
129
133
|
* 获取组件定义对应的宿主生命周期定义。
|
|
130
134
|
*
|
|
131
135
|
* @param definition Wevu 组件定义
|
|
@@ -162,5 +166,5 @@ scopedSlotCreator = createWevuScopedSlotComponent;
|
|
|
162
166
|
ensureScopedSlotComponentGlobal();
|
|
163
167
|
|
|
164
168
|
//#endregion
|
|
165
|
-
export { createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition };
|
|
169
|
+
export { createIsolatedWevuComponentDefinition, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition };
|
|
166
170
|
//# sourceMappingURL=define.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.mjs","names":[],"sources":["../../../src/runtime/define.ts"],"sourcesContent":["import type { InlineExpressionMap } from './register/inline'\nimport type { TemplateRefBinding } from './templateRefs'\nimport type {\n ComponentPropsOptions,\n ComponentPublicInstance,\n ComputedDefinitions,\n DefineComponent,\n DefineComponentOptions,\n InferProps,\n MethodDefinitions,\n MiniProgramComponentPropertyOption,\n MiniProgramComponentRawOptions,\n ShallowUnwrapRef,\n} from './types'\nimport {\n WEVU_FUNCTION_PROP_PATHS_KEY,\n WEVU_SCOPED_SLOT_CREATOR_KEY,\n WEVU_SLOT_OWNER_ID_KEY,\n WEVU_SLOT_OWNER_ID_PROP,\n WEVU_SLOT_SCOPE_KEY,\n} from '@weapp-core/constants'\nimport { hasOwn } from '../utils'\nimport { createApp } from './app'\nimport { applyWevuComponentDefaults, INTERNAL_DEFAULTS_SCOPE_KEY } from './defaults'\nimport { resolveNativeInitialData } from './define/initialComputed'\nimport { resolveVueComponentOptions } from './define/options'\nimport { applyOptionsApiProvide, resolveOptionsApiInjections } from './define/optionsApi'\nimport { normalizeProps } from './define/props'\nimport { createScopedSlotOptions } from './define/scopedSlotOptions'\nimport { applySetupResult } from './define/setupResult'\nimport { getScopedSlotHostGlobalObject } from './platform'\nimport { registerComponent, runSetupFunction } from './register'\nimport { allocateOwnerId } from './scopedSlots'\n\nlet scopedSlotCreator: (() => void) | undefined\nconst componentLifecycleDefinitions = new WeakMap<object, Record<string, any>>()\n\nfunction ensureScopedSlotComponentGlobal() {\n const globalObject = getScopedSlotHostGlobalObject()\n if (!globalObject) {\n return\n }\n const globalRecord = globalObject as Record<string, any>\n if (scopedSlotCreator && globalRecord[WEVU_SCOPED_SLOT_CREATOR_KEY] !== scopedSlotCreator) {\n globalRecord[WEVU_SCOPED_SLOT_CREATOR_KEY] = scopedSlotCreator\n }\n}\n\nfunction resolveInitialDataContext(properties: unknown, methods: MethodDefinitions | undefined) {\n const context: Record<string, unknown> = { ...(methods ?? {}) }\n if (!properties || typeof properties !== 'object') {\n return context\n }\n for (const [name, definition] of Object.entries(properties)) {\n if (definition && typeof definition === 'object' && hasOwn(definition, 'value')) {\n context[name] = (definition as Record<string, unknown>).value\n }\n }\n return context\n}\n\nfunction shouldSeedNativeSlotOwnerId(\n mpOptions: Record<string, any>,\n setData: DefineComponentOptions<any, any, any, any, any>['setData'],\n) {\n return Boolean((mpOptions as any).__wevu_isPage)\n && Array.isArray(setData?.pick)\n && setData.pick.includes(WEVU_SLOT_OWNER_ID_KEY)\n}\n\nfunction shouldDeclareNativeSlotOwnerId(\n setData: DefineComponentOptions<any, any, any, any, any>['setData'],\n) {\n return Array.isArray(setData?.pick)\n && setData.pick.includes(WEVU_SLOT_OWNER_ID_KEY)\n}\n\nfunction hasScopedSlotHostProperties(mpOptions: Record<string, any>) {\n const properties = mpOptions.properties\n return Boolean(\n properties\n && typeof properties === 'object'\n && (\n WEVU_SLOT_OWNER_ID_PROP in properties\n || WEVU_SLOT_SCOPE_KEY in properties\n ),\n )\n}\n\nfunction resolveScopedSlotHostSetData(\n mpOptions: Record<string, any>,\n setData: DefineComponentOptions<any, any, any, any, any>['setData'],\n) {\n if (setData?.strategy !== 'patch' || !hasScopedSlotHostProperties(mpOptions)) {\n return setData\n }\n return {\n ...setData,\n strategy: 'diff' as const,\n }\n}\n\n/**\n * defineComponent 返回的组件定义描述,用于手动注册或高级用法。\n */\nexport interface ComponentDefinition<\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> {\n /**\n * 内部 runtime app(高级能力使用),不对外暴露正式 API。\n * @internal\n */\n __wevu_runtime: import('./types').RuntimeApp<D, C, M>\n\n /**\n * 内部选项快照(高级能力使用),包含 data/computed/methods 等。\n * @internal\n */\n __wevu_options: {\n data: () => D\n computed: C\n methods: M\n setData: import('./types').SetDataSnapshotOptions | undefined\n watch: Record<string, any> | undefined\n setup: ((props: any, ctx: any) => any) | undefined\n mpOptions: MiniProgramComponentRawOptions\n }\n}\n\ntype SetupBindings<S> = Exclude<S, void> extends never ? Record<string, never> : Exclude<S, void>\ntype ResolveProps<P> = P extends ComponentPropsOptions ? InferProps<P> : P\n\nexport interface WevuComponentConstructor<\n Props,\n RawBindings,\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> {\n new (): ComponentPublicInstance<D, C, M, Props> & ShallowUnwrapRef<RawBindings>\n}\n\nexport type WevuDefinedComponent<\n PropsOrPropOptions,\n RawBindings,\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> = DefineComponent<PropsOrPropOptions, RawBindings, D, C, M> & ComponentDefinition<D, C, M>\nexport interface SetupContextWithTypeProps<TypeProps> {\n props: TypeProps\n [key: string]: any\n}\nexport type SetupFunctionWithTypeProps<\n TypeProps,\n> = (\n props: TypeProps,\n ctx: SetupContextWithTypeProps<TypeProps>,\n) => Record<string, any> | void\nexport interface DefineComponentTypePropsOptions<TypeProps> {\n __typeProps: TypeProps\n setup?: SetupFunctionWithTypeProps<TypeProps>\n [key: string]: any\n}\nexport interface DefineComponentWithTypeProps<TypeProps> {\n new (): { $props: TypeProps } & Record<string, any>\n}\n\n/**\n * 按 Vue 3 风格定义一个小程序组件/页面。\n *\n * - 统一注册为 `Component()`\n *\n * @param options 组件定义项\n * @returns 可手动注册的组件定义\n *\n * @example\n * ```ts\n * defineComponent({\n * data: () => ({ count: 0 }),\n * setup() {\n * onMounted(() => console.log('已挂载'))\n * }\n * })\n * ```\n *\n * @example\n * ```ts\n * defineComponent({\n * setup() {\n * onPageScroll(() => {})\n * }\n * })\n * ```\n */\n// @ts-expect-error -- TS2589:__typeProps 签名的重载实例化深度过高。\nexport function defineComponent<\n TypeProps = any,\n>(\n options: DefineComponentTypePropsOptions<TypeProps>,\n): DefineComponentWithTypeProps<TypeProps>\nexport function defineComponent<\n P extends ComponentPropsOptions = ComponentPropsOptions,\n D extends object = Record<string, any>,\n C extends ComputedDefinitions = ComputedDefinitions,\n M extends MethodDefinitions = MethodDefinitions,\n S extends Record<string, any> | void = Record<string, any> | void,\n>(\n options: DefineComponentOptions<P, D, C, M, S>,\n): WevuComponentConstructor<ResolveProps<P>, SetupBindings<S>, D, C, M> & ComponentDefinition<D, C, M>\nexport function defineComponent(\n options: DefineComponentOptions<any, any, any, any, any>,\n): WevuComponentConstructor<Record<string, any>, Record<string, any>, Record<string, any>, ComputedDefinitions, MethodDefinitions>\n & ComponentDefinition<any, any, any> {\n // eslint-disable-next-line ts/no-use-before-define -- 重载实现需保持在内部共享工厂之前。\n return createComponentDefinition(options, true) as any\n}\n\nfunction createComponentDefinition(\n options: DefineComponentOptions<any, any, any, any, any>,\n registerNative: boolean,\n) {\n if (registerNative) {\n ensureScopedSlotComponentGlobal()\n }\n const resolvedOptions = resolveVueComponentOptions(applyWevuComponentDefaults(options))\n const {\n __typeProps: _typeProps,\n data,\n computed,\n methods,\n setData,\n watch,\n setup,\n props,\n inject: injectOptions,\n provide: provideOptions,\n allowFunctionProps,\n ...mpOptions\n } = resolvedOptions\n\n const rawFunctionPropPaths = (mpOptions as any)[WEVU_FUNCTION_PROP_PATHS_KEY]\n const functionPropPaths: string[] = Array.isArray(rawFunctionPropPaths)\n ? [...new Set(rawFunctionPropPaths.filter((path: unknown): path is string => typeof path === 'string' && path.length > 0))]\n : []\n delete (mpOptions as any)[WEVU_FUNCTION_PROP_PATHS_KEY]\n\n const rawResolvedSetData = allowFunctionProps === true\n ? {\n ...(setData ?? {}),\n includeFunctions: true,\n functionPaths: functionPropPaths,\n }\n : allowFunctionProps === false\n ? setData\n : functionPropPaths.length\n ? {\n ...(setData ?? {}),\n functionPaths: functionPropPaths,\n }\n : setData\n const resolvedSetData = resolveScopedSlotHostSetData(mpOptions, rawResolvedSetData)\n const setupFunctionPropKeys = new Set(\n functionPropPaths\n .filter(path => !path.includes('.')),\n )\n\n const normalizedMpOptions = normalizeProps(mpOptions, props)\n const initialDataContext = resolveInitialDataContext(normalizedMpOptions.properties, methods)\n const resolvedData = typeof data === 'function'\n ? () => data.call(initialDataContext)\n : data\n\n const runtimeApp = createApp({\n data: resolvedData,\n computed,\n methods,\n setData: resolvedSetData,\n [INTERNAL_DEFAULTS_SCOPE_KEY]: 'component',\n } as any)\n\n const hasOptionsApiContext = injectOptions != null || provideOptions != null\n const setupWrapper = typeof setup === 'function' || hasOptionsApiContext\n ? ((props, ctx) => {\n const publicInstance = (ctx as any)?.proxy ?? (ctx as any)?.instance ?? Object.create(null)\n const injected = resolveOptionsApiInjections(injectOptions, publicInstance)\n if (provideOptions != null) {\n applyOptionsApiProvide(provideOptions, publicInstance)\n }\n const setupResult = typeof setup === 'function'\n ? runSetupFunction(setup as any, props as Record<string, any>, ctx as any) as Record<string, any> | void\n : undefined\n const result = {\n ...injected,\n ...(setupResult ?? {}),\n }\n if (ctx && Object.keys(result).length) {\n applySetupResult((ctx as any).runtime, (ctx as any).instance, result, {\n includeFunctionsInState: allowFunctionProps === true,\n functionPropPaths: allowFunctionProps === false ? undefined : setupFunctionPropKeys,\n })\n }\n return result\n }) satisfies DefineComponentOptions<ComponentPropsOptions, any, any, any, any>['setup']\n : undefined\n\n const nativeData = typeof resolvedData === 'function'\n ? resolvedData()\n : resolvedData\n const shouldDeclareOwnerId = shouldDeclareNativeSlotOwnerId(resolvedSetData)\n const seededNativeData = shouldDeclareOwnerId\n ? {\n ...(nativeData && typeof nativeData === 'object' ? nativeData : {}),\n [WEVU_SLOT_OWNER_ID_KEY]: shouldSeedNativeSlotOwnerId(mpOptions, resolvedSetData)\n ? (nativeData as any)?.[WEVU_SLOT_OWNER_ID_KEY] || allocateOwnerId()\n : (nativeData as any)?.[WEVU_SLOT_OWNER_ID_KEY] || '',\n }\n : nativeData\n const nativeInitialData = resolveNativeInitialData(seededNativeData, computed as ComputedDefinitions, resolvedSetData, methods as Record<string, any> | undefined)\n const mpOptionsWithProps = nativeInitialData !== undefined\n ? {\n ...normalizedMpOptions,\n data: nativeInitialData,\n }\n : normalizedMpOptions\n\n const componentOptions = {\n data: resolvedData as () => Record<string, any>,\n computed: computed as ComputedDefinitions,\n methods: methods as MethodDefinitions,\n setData: resolvedSetData,\n watch,\n setup: setupWrapper,\n mpOptions: mpOptionsWithProps,\n }\n\n const lifecycleDefinition = registerComponent(\n runtimeApp as any,\n methods ?? {},\n watch as any,\n setupWrapper as any,\n mpOptionsWithProps as any,\n { registerNative },\n )\n\n // 返回组件定义,便于外部自行注册\n const definition: ComponentDefinition<any, any, any> = {\n __wevu_runtime: runtimeApp as any,\n __wevu_options: componentOptions as ComponentDefinition<any, any, any>['__wevu_options'],\n }\n componentLifecycleDefinitions.set(definition, lifecycleDefinition)\n\n return definition as unknown as WevuComponentConstructor<\n ResolveProps<ComponentPropsOptions>,\n Record<string, any>,\n Record<string, any>,\n ComputedDefinitions,\n MethodDefinitions\n > & ComponentDefinition<any, any, any>\n}\n\n/**\n * 创建不触发宿主全局注册的 Wevu 组件定义。\n *\n * @param options 组件选项\n * @internal\n */\nexport function createWevuComponentDefinition(\n options: DefineComponentOptions<any, any, any, any, any>,\n) {\n return createComponentDefinition(options, false)\n}\n\n/**\n * 获取组件定义对应的宿主生命周期定义。\n *\n * @param definition Wevu 组件定义\n * @internal\n */\nexport function getWevuComponentLifecycleDefinition(definition: object) {\n return componentLifecycleDefinitions.get(definition)\n}\n\n/**\n * 从 Vue SFC 选项创建 wevu 组件,供 weapp-vite 编译产物直接调用的兼容入口。\n *\n * @param options 组件选项,可能包含小程序特有的 properties\n * @internal\n */\nexport function createWevuComponent<\n P extends ComponentPropsOptions = ComponentPropsOptions,\n D extends object = Record<string, any>,\n C extends ComputedDefinitions = ComputedDefinitions,\n M extends MethodDefinitions = MethodDefinitions,\n>(\n options: DefineComponentOptions<P, D, C, M> & { properties?: MiniProgramComponentPropertyOption },\n): void {\n ensureScopedSlotComponentGlobal()\n const {\n properties,\n props,\n ...restOptions\n } = options\n\n const baseOptions = {\n ...restOptions,\n allowNullPropInput: (restOptions as any).allowNullPropInput ?? true,\n __wevu_allowNullPropInput: true,\n }\n\n // 将 properties 合并到 mpOptions,保持小程序属性定义\n const finalOptions = normalizeProps(baseOptions, props, properties)\n\n defineComponent(finalOptions)\n}\n\n/**\n * scoped slot 兼容组件入口(编译产物内部使用)。\n * @internal\n */\nexport function createWevuScopedSlotComponent(\n overrides?: {\n computed?: ComputedDefinitions\n inlineMap?: InlineExpressionMap\n templateRefs?: TemplateRefBinding[]\n },\n): void {\n const baseOptions = createScopedSlotOptions(overrides)\n createWevuComponent(baseOptions as any)\n}\n\nscopedSlotCreator = createWevuScopedSlotComponent\nensureScopedSlotComponentGlobal()\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"define.mjs","names":[],"sources":["../../../src/runtime/define.ts"],"sourcesContent":["import type { RuntimeComponentDefinitionOptions } from './define/componentDefinition'\nimport type { InlineExpressionMap } from './register/inline'\nimport type { TemplateRefBinding } from './templateRefs'\nimport type {\n ComponentPropsOptions,\n ComponentPublicInstance,\n ComputedDefinitions,\n DefineComponent,\n DefineComponentOptions,\n InferProps,\n MethodDefinitions,\n MiniProgramComponentPropertyOption,\n MiniProgramComponentRawOptions,\n ShallowUnwrapRef,\n} from './types'\nimport {\n WEVU_FUNCTION_PROP_PATHS_KEY,\n WEVU_SCOPED_SLOT_CREATOR_KEY,\n WEVU_SLOT_OWNER_ID_KEY,\n WEVU_SLOT_OWNER_ID_PROP,\n WEVU_SLOT_SCOPE_KEY,\n} from '@weapp-core/constants'\nimport { hasOwn } from '../utils'\nimport { applyWevuComponentDefaults } from './defaults'\nimport {\n createRuntimeComponentDefinition,\n} from './define/componentDefinition'\nimport { resolveNativeInitialData } from './define/initialComputed'\nimport { resolveVueComponentOptions } from './define/options'\nimport { applyOptionsApiProvide, resolveOptionsApiInjections } from './define/optionsApi'\nimport { normalizeProps } from './define/props'\nimport { createScopedSlotOptions } from './define/scopedSlotOptions'\nimport { applySetupResult } from './define/setupResult'\nimport { getScopedSlotHostGlobalObject } from './platform'\nimport { runSetupFunction } from './register'\nimport { allocateOwnerId } from './scopedSlots'\n\nlet scopedSlotCreator: (() => void) | undefined\nconst componentLifecycleDefinitions = new WeakMap<object, Record<string, any>>()\n\nfunction ensureScopedSlotComponentGlobal() {\n const globalObject = getScopedSlotHostGlobalObject()\n if (!globalObject) {\n return\n }\n const globalRecord = globalObject as Record<string, any>\n if (scopedSlotCreator && globalRecord[WEVU_SCOPED_SLOT_CREATOR_KEY] !== scopedSlotCreator) {\n globalRecord[WEVU_SCOPED_SLOT_CREATOR_KEY] = scopedSlotCreator\n }\n}\n\nfunction resolveInitialDataContext(properties: unknown, methods: MethodDefinitions | undefined) {\n const context: Record<string, unknown> = { ...(methods ?? {}) }\n if (!properties || typeof properties !== 'object') {\n return context\n }\n for (const [name, definition] of Object.entries(properties)) {\n if (definition && typeof definition === 'object' && hasOwn(definition, 'value')) {\n context[name] = (definition as Record<string, unknown>).value\n }\n }\n return context\n}\n\nfunction shouldSeedNativeSlotOwnerId(\n mpOptions: Record<string, any>,\n setData: DefineComponentOptions<any, any, any, any, any>['setData'],\n) {\n return Boolean((mpOptions as any).__wevu_isPage)\n && Array.isArray(setData?.pick)\n && setData.pick.includes(WEVU_SLOT_OWNER_ID_KEY)\n}\n\nfunction shouldDeclareNativeSlotOwnerId(\n setData: DefineComponentOptions<any, any, any, any, any>['setData'],\n) {\n return Array.isArray(setData?.pick)\n && setData.pick.includes(WEVU_SLOT_OWNER_ID_KEY)\n}\n\nfunction hasScopedSlotHostProperties(mpOptions: Record<string, any>) {\n const properties = mpOptions.properties\n return Boolean(\n properties\n && typeof properties === 'object'\n && (\n WEVU_SLOT_OWNER_ID_PROP in properties\n || WEVU_SLOT_SCOPE_KEY in properties\n ),\n )\n}\n\nfunction resolveScopedSlotHostSetData(\n mpOptions: Record<string, any>,\n setData: DefineComponentOptions<any, any, any, any, any>['setData'],\n) {\n if (setData?.strategy !== 'patch' || !hasScopedSlotHostProperties(mpOptions)) {\n return setData\n }\n return {\n ...setData,\n strategy: 'diff' as const,\n }\n}\n\n/**\n * defineComponent 返回的组件定义描述,用于手动注册或高级用法。\n */\nexport interface ComponentDefinition<\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> {\n /**\n * 内部 runtime app(高级能力使用),不对外暴露正式 API。\n * @internal\n */\n __wevu_runtime: import('./types').RuntimeApp<D, C, M>\n\n /**\n * 内部选项快照(高级能力使用),包含 data/computed/methods 等。\n * @internal\n */\n __wevu_options: {\n data: () => D\n computed: C\n methods: M\n setData: import('./types').SetDataSnapshotOptions | undefined\n watch: Record<string, any> | undefined\n setup: ((props: any, ctx: any) => any) | undefined\n mpOptions: MiniProgramComponentRawOptions\n }\n}\n\nfunction materializeComponentDefinition(\n componentOptions: RuntimeComponentDefinitionOptions,\n registerNative = false,\n) {\n const { lifecycleDefinition, runtimeApp } = createRuntimeComponentDefinition(componentOptions, registerNative)\n const definition: ComponentDefinition<any, any, any> = {\n __wevu_runtime: runtimeApp as any,\n __wevu_options: componentOptions as ComponentDefinition<any, any, any>['__wevu_options'],\n }\n componentLifecycleDefinitions.set(definition, lifecycleDefinition)\n return definition\n}\n\ntype SetupBindings<S> = Exclude<S, void> extends never ? Record<string, never> : Exclude<S, void>\ntype ResolveProps<P> = P extends ComponentPropsOptions ? InferProps<P> : P\n\nexport interface WevuComponentConstructor<\n Props,\n RawBindings,\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> {\n new (): ComponentPublicInstance<D, C, M, Props> & ShallowUnwrapRef<RawBindings>\n}\n\nexport type WevuDefinedComponent<\n PropsOrPropOptions,\n RawBindings,\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> = DefineComponent<PropsOrPropOptions, RawBindings, D, C, M> & ComponentDefinition<D, C, M>\nexport interface SetupContextWithTypeProps<TypeProps> {\n props: TypeProps\n [key: string]: any\n}\nexport type SetupFunctionWithTypeProps<\n TypeProps,\n> = (\n props: TypeProps,\n ctx: SetupContextWithTypeProps<TypeProps>,\n) => Record<string, any> | void\nexport interface DefineComponentTypePropsOptions<TypeProps> {\n __typeProps: TypeProps\n setup?: SetupFunctionWithTypeProps<TypeProps>\n [key: string]: any\n}\nexport interface DefineComponentWithTypeProps<TypeProps> {\n new (): { $props: TypeProps } & Record<string, any>\n}\n\n/**\n * 按 Vue 3 风格定义一个小程序组件/页面。\n *\n * - 统一注册为 `Component()`\n *\n * @param options 组件定义项\n * @returns 可手动注册的组件定义\n *\n * @example\n * ```ts\n * defineComponent({\n * data: () => ({ count: 0 }),\n * setup() {\n * onMounted(() => console.log('已挂载'))\n * }\n * })\n * ```\n *\n * @example\n * ```ts\n * defineComponent({\n * setup() {\n * onPageScroll(() => {})\n * }\n * })\n * ```\n */\n// @ts-expect-error -- TS2589:__typeProps 签名的重载实例化深度过高。\nexport function defineComponent<\n TypeProps = any,\n>(\n options: DefineComponentTypePropsOptions<TypeProps>,\n): DefineComponentWithTypeProps<TypeProps>\nexport function defineComponent<\n P extends ComponentPropsOptions = ComponentPropsOptions,\n D extends object = Record<string, any>,\n C extends ComputedDefinitions = ComputedDefinitions,\n M extends MethodDefinitions = MethodDefinitions,\n S extends Record<string, any> | void = Record<string, any> | void,\n>(\n options: DefineComponentOptions<P, D, C, M, S>,\n): WevuComponentConstructor<ResolveProps<P>, SetupBindings<S>, D, C, M> & ComponentDefinition<D, C, M>\nexport function defineComponent(\n options: DefineComponentOptions<any, any, any, any, any>,\n): WevuComponentConstructor<Record<string, any>, Record<string, any>, Record<string, any>, ComputedDefinitions, MethodDefinitions>\n & ComponentDefinition<any, any, any> {\n // eslint-disable-next-line ts/no-use-before-define -- 重载实现需保持在内部共享工厂之前。\n return createComponentDefinition(options, true) as any\n}\n\nfunction createComponentDefinition(\n options: DefineComponentOptions<any, any, any, any, any>,\n registerNative: boolean,\n) {\n if (registerNative) {\n ensureScopedSlotComponentGlobal()\n }\n const resolvedOptions = resolveVueComponentOptions(applyWevuComponentDefaults(options))\n const {\n __typeProps: _typeProps,\n data,\n computed,\n methods,\n setData,\n watch,\n setup,\n props,\n inject: injectOptions,\n provide: provideOptions,\n allowFunctionProps,\n ...mpOptions\n } = resolvedOptions\n\n const rawFunctionPropPaths = (mpOptions as any)[WEVU_FUNCTION_PROP_PATHS_KEY]\n const functionPropPaths: string[] = Array.isArray(rawFunctionPropPaths)\n ? [...new Set(rawFunctionPropPaths.filter((path: unknown): path is string => typeof path === 'string' && path.length > 0))]\n : []\n delete (mpOptions as any)[WEVU_FUNCTION_PROP_PATHS_KEY]\n\n const rawResolvedSetData = allowFunctionProps === true\n ? {\n ...(setData ?? {}),\n includeFunctions: true,\n functionPaths: functionPropPaths,\n }\n : allowFunctionProps === false\n ? setData\n : functionPropPaths.length\n ? {\n ...(setData ?? {}),\n functionPaths: functionPropPaths,\n }\n : setData\n const resolvedSetData = resolveScopedSlotHostSetData(mpOptions, rawResolvedSetData)\n const setupFunctionPropKeys = new Set(\n functionPropPaths\n .filter(path => !path.includes('.')),\n )\n\n const normalizedMpOptions = normalizeProps(mpOptions, props)\n const initialDataContext = resolveInitialDataContext(normalizedMpOptions.properties, methods)\n const resolvedData = typeof data === 'function'\n ? () => data.call(initialDataContext)\n : data\n\n const hasOptionsApiContext = injectOptions != null || provideOptions != null\n const setupWrapper = typeof setup === 'function' || hasOptionsApiContext\n ? ((props, ctx) => {\n const publicInstance = (ctx as any)?.proxy ?? (ctx as any)?.instance ?? Object.create(null)\n const injected = resolveOptionsApiInjections(injectOptions, publicInstance)\n if (provideOptions != null) {\n applyOptionsApiProvide(provideOptions, publicInstance)\n }\n const setupResult = typeof setup === 'function'\n ? runSetupFunction(setup as any, props as Record<string, any>, ctx as any) as Record<string, any> | void\n : undefined\n const result = {\n ...injected,\n ...(setupResult ?? {}),\n }\n if (ctx && Object.keys(result).length) {\n applySetupResult((ctx as any).runtime, (ctx as any).instance, result, {\n includeFunctionsInState: allowFunctionProps === true,\n functionPropPaths: allowFunctionProps === false ? undefined : setupFunctionPropKeys,\n })\n }\n return result\n }) satisfies DefineComponentOptions<ComponentPropsOptions, any, any, any, any>['setup']\n : undefined\n\n const nativeData = typeof resolvedData === 'function'\n ? resolvedData()\n : resolvedData\n const shouldDeclareOwnerId = shouldDeclareNativeSlotOwnerId(resolvedSetData)\n const seededNativeData = shouldDeclareOwnerId\n ? {\n ...(nativeData && typeof nativeData === 'object' ? nativeData : {}),\n [WEVU_SLOT_OWNER_ID_KEY]: shouldSeedNativeSlotOwnerId(mpOptions, resolvedSetData)\n ? (nativeData as any)?.[WEVU_SLOT_OWNER_ID_KEY] || allocateOwnerId()\n : (nativeData as any)?.[WEVU_SLOT_OWNER_ID_KEY] || '',\n }\n : nativeData\n const nativeInitialData = resolveNativeInitialData(seededNativeData, computed as ComputedDefinitions, resolvedSetData, methods as Record<string, any> | undefined)\n const mpOptionsWithProps = nativeInitialData !== undefined\n ? {\n ...normalizedMpOptions,\n data: nativeInitialData,\n }\n : normalizedMpOptions\n\n const componentOptions: RuntimeComponentDefinitionOptions = {\n data: resolvedData as () => Record<string, any>,\n computed: computed as ComputedDefinitions,\n methods: methods as MethodDefinitions,\n setData: resolvedSetData,\n watch,\n setup: setupWrapper,\n mpOptions: mpOptionsWithProps as MiniProgramComponentRawOptions,\n }\n\n const definition = materializeComponentDefinition(componentOptions, registerNative)\n\n return definition as unknown as WevuComponentConstructor<\n ResolveProps<ComponentPropsOptions>,\n Record<string, any>,\n Record<string, any>,\n ComputedDefinitions,\n MethodDefinitions\n > & ComponentDefinition<any, any, any>\n}\n\n/**\n * 创建不触发宿主全局注册的 Wevu 组件定义。\n *\n * @param options 组件选项\n * @internal\n */\nexport function createWevuComponentDefinition(\n options: DefineComponentOptions<any, any, any, any, any>,\n) {\n return createComponentDefinition(options, false)\n}\n\n/**\n * 从现有组件定义派生拥有独立应用上下文的组件定义。\n *\n * @param definition 已解析的 Wevu 组件定义\n * @internal\n */\nexport function createIsolatedWevuComponentDefinition(definition: object) {\n const componentOptions = (definition as ComponentDefinition<any, any, any>).__wevu_options\n if (!componentOptions) {\n throw new TypeError('无法从非 Wevu 组件定义创建独立运行时')\n }\n return materializeComponentDefinition(componentOptions)\n}\n\n/**\n * 获取组件定义对应的宿主生命周期定义。\n *\n * @param definition Wevu 组件定义\n * @internal\n */\nexport function getWevuComponentLifecycleDefinition(definition: object) {\n return componentLifecycleDefinitions.get(definition)\n}\n\n/**\n * 从 Vue SFC 选项创建 wevu 组件,供 weapp-vite 编译产物直接调用的兼容入口。\n *\n * @param options 组件选项,可能包含小程序特有的 properties\n * @internal\n */\nexport function createWevuComponent<\n P extends ComponentPropsOptions = ComponentPropsOptions,\n D extends object = Record<string, any>,\n C extends ComputedDefinitions = ComputedDefinitions,\n M extends MethodDefinitions = MethodDefinitions,\n>(\n options: DefineComponentOptions<P, D, C, M> & { properties?: MiniProgramComponentPropertyOption },\n): void {\n ensureScopedSlotComponentGlobal()\n const {\n properties,\n props,\n ...restOptions\n } = options\n\n const baseOptions = {\n ...restOptions,\n allowNullPropInput: (restOptions as any).allowNullPropInput ?? true,\n __wevu_allowNullPropInput: true,\n }\n\n // 将 properties 合并到 mpOptions,保持小程序属性定义\n const finalOptions = normalizeProps(baseOptions, props, properties)\n\n defineComponent(finalOptions)\n}\n\n/**\n * scoped slot 兼容组件入口(编译产物内部使用)。\n * @internal\n */\nexport function createWevuScopedSlotComponent(\n overrides?: {\n computed?: ComputedDefinitions\n inlineMap?: InlineExpressionMap\n templateRefs?: TemplateRefBinding[]\n },\n): void {\n const baseOptions = createScopedSlotOptions(overrides)\n createWevuComponent(baseOptions as any)\n}\n\nscopedSlotCreator = createWevuScopedSlotComponent\nensureScopedSlotComponentGlobal()\n"],"mappings":"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"}
|
|
@@ -50,9 +50,9 @@ function getInstanceProvides(instance) {
|
|
|
50
50
|
function ensureRuntimeAppProvides(runtimeApp) {
|
|
51
51
|
return getRuntimeAppProvides(runtimeApp);
|
|
52
52
|
}
|
|
53
|
-
function setRuntimeAppProvidedValue(runtimeApp, key, value) {
|
|
53
|
+
function setRuntimeAppProvidedValue(runtimeApp, key, value, options = {}) {
|
|
54
54
|
getRuntimeAppProvides(runtimeApp)[key] = value;
|
|
55
|
-
setGlobalProvidedValue(key, value);
|
|
55
|
+
if (options.syncGlobal !== false) setGlobalProvidedValue(key, value);
|
|
56
56
|
}
|
|
57
57
|
function attachRuntimeProvideContext(instance, runtimeApp, parentInstance) {
|
|
58
58
|
var _parentInstance$WEVU_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provideContext.mjs","names":[],"sources":["../../../src/runtime/provideContext.ts"],"sourcesContent":["import type { InternalRuntimeState, RuntimeApp } from './types'\nimport {\n WEVU_APP_PROVIDES_KEY,\n WEVU_IS_APP_INSTANCE_KEY,\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_PROVIDES_KEY,\n WEVU_RUNTIME_APP_KEY,\n} from '@weapp-core/constants'\nimport { setGlobalProvidedValue } from './provideStore'\n\nexport function isRuntimeAppInstance(instance: unknown): boolean {\n return Boolean(\n instance\n && typeof instance === 'object'\n && (instance as { [WEVU_IS_APP_INSTANCE_KEY]?: boolean })[WEVU_IS_APP_INSTANCE_KEY] === true,\n )\n}\n\nfunction createProvides(parent?: Record<PropertyKey, any>) {\n return Object.create(parent ?? null) as Record<PropertyKey, any>\n}\n\nfunction getRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any> | undefined): Record<PropertyKey, any> {\n if (!runtimeApp) {\n return createProvides()\n }\n const existing = runtimeApp[WEVU_APP_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n const provides = createProvides()\n try {\n Object.defineProperty(runtimeApp, WEVU_APP_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(runtimeApp as any)[WEVU_APP_PROVIDES_KEY] = provides\n }\n return provides\n}\n\nexport function attachInstanceProvides(\n instance: InternalRuntimeState,\n provides: Record<PropertyKey, any>,\n): void {\n try {\n Object.defineProperty(instance, WEVU_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PROVIDES_KEY] = provides\n }\n}\n\nexport function getInstanceProvides(instance: InternalRuntimeState): Record<PropertyKey, any> {\n const existing = instance[WEVU_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n\n const runtimeApp = instance[WEVU_RUNTIME_APP_KEY]\n const parentProvides = instance[WEVU_PARENT_INSTANCE_KEY]?.[WEVU_PROVIDES_KEY]\n ?? getRuntimeAppProvides(runtimeApp)\n const provides = isRuntimeAppInstance(instance)\n ? getRuntimeAppProvides(runtimeApp)\n : createProvides(parentProvides)\n attachInstanceProvides(instance, provides)\n return provides\n}\n\nexport function ensureRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any>): Record<PropertyKey, any> {\n return getRuntimeAppProvides(runtimeApp)\n}\n\nexport function setRuntimeAppProvidedValue<T>(runtimeApp: RuntimeApp<any, any, any
|
|
1
|
+
{"version":3,"file":"provideContext.mjs","names":[],"sources":["../../../src/runtime/provideContext.ts"],"sourcesContent":["import type { InternalRuntimeState, RuntimeApp } from './types'\nimport {\n WEVU_APP_PROVIDES_KEY,\n WEVU_IS_APP_INSTANCE_KEY,\n WEVU_PARENT_INSTANCE_KEY,\n WEVU_PROVIDES_KEY,\n WEVU_RUNTIME_APP_KEY,\n} from '@weapp-core/constants'\nimport { setGlobalProvidedValue } from './provideStore'\n\nexport function isRuntimeAppInstance(instance: unknown): boolean {\n return Boolean(\n instance\n && typeof instance === 'object'\n && (instance as { [WEVU_IS_APP_INSTANCE_KEY]?: boolean })[WEVU_IS_APP_INSTANCE_KEY] === true,\n )\n}\n\nfunction createProvides(parent?: Record<PropertyKey, any>) {\n return Object.create(parent ?? null) as Record<PropertyKey, any>\n}\n\nfunction getRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any> | undefined): Record<PropertyKey, any> {\n if (!runtimeApp) {\n return createProvides()\n }\n const existing = runtimeApp[WEVU_APP_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n const provides = createProvides()\n try {\n Object.defineProperty(runtimeApp, WEVU_APP_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(runtimeApp as any)[WEVU_APP_PROVIDES_KEY] = provides\n }\n return provides\n}\n\nexport function attachInstanceProvides(\n instance: InternalRuntimeState,\n provides: Record<PropertyKey, any>,\n): void {\n try {\n Object.defineProperty(instance, WEVU_PROVIDES_KEY, {\n value: provides,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PROVIDES_KEY] = provides\n }\n}\n\nexport function getInstanceProvides(instance: InternalRuntimeState): Record<PropertyKey, any> {\n const existing = instance[WEVU_PROVIDES_KEY]\n if (existing && typeof existing === 'object') {\n return existing\n }\n\n const runtimeApp = instance[WEVU_RUNTIME_APP_KEY]\n const parentProvides = instance[WEVU_PARENT_INSTANCE_KEY]?.[WEVU_PROVIDES_KEY]\n ?? getRuntimeAppProvides(runtimeApp)\n const provides = isRuntimeAppInstance(instance)\n ? getRuntimeAppProvides(runtimeApp)\n : createProvides(parentProvides)\n attachInstanceProvides(instance, provides)\n return provides\n}\n\nexport function ensureRuntimeAppProvides(runtimeApp: RuntimeApp<any, any, any>): Record<PropertyKey, any> {\n return getRuntimeAppProvides(runtimeApp)\n}\n\nexport function setRuntimeAppProvidedValue<T>(\n runtimeApp: RuntimeApp<any, any, any>,\n key: any,\n value: T,\n options: { syncGlobal?: boolean } = {},\n): void {\n getRuntimeAppProvides(runtimeApp)[key as PropertyKey] = value\n if (options.syncGlobal !== false) {\n setGlobalProvidedValue(key, value)\n }\n}\n\nexport function attachRuntimeProvideContext(\n instance: InternalRuntimeState,\n runtimeApp: RuntimeApp<any, any, any>,\n parentInstance?: InternalRuntimeState,\n): void {\n const appProvides = getRuntimeAppProvides(runtimeApp)\n const parentProvides = parentInstance?.[WEVU_PROVIDES_KEY] ?? appProvides\n const provides = isRuntimeAppInstance(instance)\n ? appProvides\n : createProvides(parentProvides)\n\n if (parentInstance) {\n try {\n Object.defineProperty(instance, WEVU_PARENT_INSTANCE_KEY, {\n value: parentInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(instance as any)[WEVU_PARENT_INSTANCE_KEY] = parentInstance\n }\n }\n\n attachInstanceProvides(instance, provides)\n}\n\nfunction isPrototypeInChain(target: Record<PropertyKey, any>, candidate: Record<PropertyKey, any>) {\n let current = Object.getPrototypeOf(target)\n while (current) {\n if (current === candidate) {\n return true\n }\n current = Object.getPrototypeOf(current)\n }\n return false\n}\n\nexport function attachRuntimeLayoutProvideContext(\n layoutInstance: InternalRuntimeState,\n pageInstance: InternalRuntimeState,\n): void {\n const layoutProvides = getInstanceProvides(layoutInstance)\n const pageProvides = getInstanceProvides(pageInstance)\n if (\n layoutProvides === pageProvides\n || isPrototypeInChain(layoutProvides, pageProvides)\n || isPrototypeInChain(pageProvides, layoutProvides)\n ) {\n return\n }\n\n Object.setPrototypeOf(pageProvides, layoutProvides)\n\n try {\n Object.defineProperty(pageInstance, WEVU_PARENT_INSTANCE_KEY, {\n value: layoutInstance,\n configurable: true,\n enumerable: false,\n writable: true,\n })\n }\n catch {\n ;(pageInstance as any)[WEVU_PARENT_INSTANCE_KEY] = layoutInstance\n }\n}\n"],"mappings":";;;;AAUA,SAAgB,qBAAqB,UAA4B;CAC/D,OAAO,QACL,YACG,OAAO,aAAa,YACnB,SAAsD,8BAA8B,IAC1F;AACF;AAEA,SAAS,eAAe,QAAmC;CACzD,OAAO,OAAO,OAAO,gDAAU,IAAI;AACrC;AAEA,SAAS,sBAAsB,YAA6E;CAC1G,IAAI,CAAC,YACH,OAAO,eAAe;CAExB,MAAM,WAAW,WAAW;CAC5B,IAAI,YAAY,OAAO,aAAa,UAClC,OAAO;CAET,MAAM,WAAW,eAAe;CAChC,IAAI;EACF,OAAO,eAAe,YAAY,uBAAuB;GACvD,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,kBACM;EACH,AAAC,WAAmB,yBAAyB;CAChD;CACA,OAAO;AACT;AAEA,SAAgB,uBACd,UACA,UACM;CACN,IAAI;EACF,OAAO,eAAe,UAAU,mBAAmB;GACjD,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,mBACM;EACH,AAAC,SAAiB,qBAAqB;CAC1C;AACF;AAEA,SAAgB,oBAAoB,UAA0D;;CAC5F,MAAM,WAAW,SAAS;CAC1B,IAAI,YAAY,OAAO,aAAa,UAClC,OAAO;CAGT,MAAM,aAAa,SAAS;CAC5B,MAAM,oEAAiB,SAAS,2GAA4B,2FACvD,sBAAsB,UAAU;CACrC,MAAM,WAAW,qBAAqB,QAAQ,IAC1C,sBAAsB,UAAU,IAChC,eAAe,cAAc;CACjC,uBAAuB,UAAU,QAAQ;CACzC,OAAO;AACT;AAEA,SAAgB,yBAAyB,YAAiE;CACxG,OAAO,sBAAsB,UAAU;AACzC;AAEA,SAAgB,2BACd,YACA,KACA,OACA,UAAoC,CAAC,GAC/B;CACN,sBAAsB,UAAU,CAAC,CAAC,OAAsB;CACxD,IAAI,QAAQ,eAAe,OACzB,uBAAuB,KAAK,KAAK;AAErC;AAEA,SAAgB,4BACd,UACA,YACA,gBACM;;CACN,MAAM,cAAc,sBAAsB,UAAU;CACpD,MAAM,0GAAiB,eAAiB,2FAAsB;CAC9D,MAAM,WAAW,qBAAqB,QAAQ,IAC1C,cACA,eAAe,cAAc;CAEjC,IAAI,gBACF,IAAI;EACF,OAAO,eAAe,UAAU,0BAA0B;GACxD,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,mBACM;EACH,AAAC,SAAiB,4BAA4B;CACjD;CAGF,uBAAuB,UAAU,QAAQ;AAC3C;AAEA,SAAS,mBAAmB,QAAkC,WAAqC;CACjG,IAAI,UAAU,OAAO,eAAe,MAAM;CAC1C,OAAO,SAAS;EACd,IAAI,YAAY,WACd,OAAO;EAET,UAAU,OAAO,eAAe,OAAO;CACzC;CACA,OAAO;AACT;AAEA,SAAgB,kCACd,gBACA,cACM;CACN,MAAM,iBAAiB,oBAAoB,cAAc;CACzD,MAAM,eAAe,oBAAoB,YAAY;CACrD,IACE,mBAAmB,gBAChB,mBAAmB,gBAAgB,YAAY,KAC/C,mBAAmB,cAAc,cAAc,GAElD;CAGF,OAAO,eAAe,cAAc,cAAc;CAElD,IAAI;EACF,OAAO,eAAe,cAAc,0BAA0B;GAC5D,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,mBACM;EACH,AAAC,aAAqB,4BAA4B;CACrD;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createApp } from "./runtime/app.mjs";
|
|
2
2
|
import { INTERNAL_DEFAULTS_SCOPE_KEY, resetWevuDefaults, setWevuDefaults } from "./runtime/defaults.mjs";
|
|
3
|
-
import { createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition } from "./runtime/define.mjs";
|
|
3
|
+
import { createIsolatedWevuComponentDefinition, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition } from "./runtime/define.mjs";
|
|
4
4
|
import { useDisposables } from "./runtime/disposables.mjs";
|
|
5
5
|
import { useElementIntersectionObserver } from "./runtime/elementIntersectionObserver.mjs";
|
|
6
6
|
import { callHookList, callHookReturn, getCurrentInstance, getCurrentSetupContext, setCurrentInstance, setCurrentSetupContext } from "./runtime/hooks/base.mjs";
|
|
@@ -33,4 +33,4 @@ import { version } from "./version.mjs";
|
|
|
33
33
|
import { takePendingRuntimeAppRegistration } from "./runtime/app/pending.mjs";
|
|
34
34
|
import { Fragment, createTextVNode, createVNode, isVNode, mergeProps, normalizeJsxIsland, resolveComponent, resolveDirective, transformOn, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, withDirectives } from "./runtime/jsxIsland.mjs";
|
|
35
35
|
import { createUniAppHost } from "./runtime/uniAppHost.mjs";
|
|
36
|
-
export { Fragment, INTERNAL_DEFAULTS_SCOPE_KEY, callHookList, callHookReturn, createApp, createTextVNode, createUniAppHost, createVNode, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineAppSetup, defineComponent, getCurrentInstance, getCurrentPageStackSnapshot, getCurrentSetupContext, getNavigationBarMetrics, getWevuComponentLifecycleDefinition, hasInjectionContext, inject, injectGlobal, isNoSetData, isVNode, markNoSetData, mergeModels, mergeProps, mountRuntimeInstance, normalizeJsxIsland, onActivated, onAddToFavorites, onAttached, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onDetached, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMemoryWarning, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, provide, provideGlobal, registerApp, registerComponent, resetWevuDefaults, resolveComponent, resolveDirective, resolveLayoutBridge, resolveLayoutHost, resolveRuntimePageLayoutName, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setGlobalProvidedValue, setPageLayout, setRuntimeSetDataVisibility, setWevuDefaults, syncRuntimePageLayoutState, syncRuntimePageLayoutStateFromRuntime, takePendingRuntimeAppRegistration, teardownRuntimeInstance, transformOn, use, useAsyncPullDownRefresh, useAttrs, useBindModel, useBoundingClientRect, useChangeModel, useDisposables, useElementIntersectionObserver, useIntersectionObserver, useLayoutBridge, useLayoutHosts, useModel, useNativeInstance, useNativePageRouter, useNativeRouter, useNavigationBarMetrics, usePageLayout, usePageScrollThrottle, usePageStack, useScrollOffset, useSelectorFields, useSelectorQuery, useSlots, useTemplateRef, useUpdatePerformanceListener, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, version, waitForLayoutHost, withDirectives };
|
|
36
|
+
export { Fragment, INTERNAL_DEFAULTS_SCOPE_KEY, callHookList, callHookReturn, createApp, createIsolatedWevuComponentDefinition, createTextVNode, createUniAppHost, createVNode, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineAppSetup, defineComponent, getCurrentInstance, getCurrentPageStackSnapshot, getCurrentSetupContext, getNavigationBarMetrics, getWevuComponentLifecycleDefinition, hasInjectionContext, inject, injectGlobal, isNoSetData, isVNode, markNoSetData, mergeModels, mergeProps, mountRuntimeInstance, normalizeJsxIsland, onActivated, onAddToFavorites, onAttached, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onDetached, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMemoryWarning, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, provide, provideGlobal, registerApp, registerComponent, resetWevuDefaults, resolveComponent, resolveDirective, resolveLayoutBridge, resolveLayoutHost, resolveRuntimePageLayoutName, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setGlobalProvidedValue, setPageLayout, setRuntimeSetDataVisibility, setWevuDefaults, syncRuntimePageLayoutState, syncRuntimePageLayoutStateFromRuntime, takePendingRuntimeAppRegistration, teardownRuntimeInstance, transformOn, use, useAsyncPullDownRefresh, useAttrs, useBindModel, useBoundingClientRect, useChangeModel, useDisposables, useElementIntersectionObserver, useIntersectionObserver, useLayoutBridge, useLayoutHosts, useModel, useNativeInstance, useNativePageRouter, useNativeRouter, useNavigationBarMetrics, usePageLayout, usePageScrollThrottle, usePageStack, useScrollOffset, useSelectorFields, useSelectorQuery, useSlots, useTemplateRef, useUpdatePerformanceListener, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, version, waitForLayoutHost, withDirectives };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callHookList as e,callHookReturn as t,getCurrentInstance as n,getCurrentSetupContext as r,setCurrentInstance as i,setCurrentSetupContext as a}from"./runtime/hooks/base.mjs";import{onAddToFavorites as o,onAttached as s,onDetached as c,onError as l,onHide as u,onLaunch as d,onLoad as f,onMemoryWarning as p,onMoved as m,onPageNotFound as h,onPageScroll as g,onPullDownRefresh as _,onReachBottom as v,onReady as y,onResize as b,onRouteDone as x,onSaveExitState as S,onShareAppMessage as C,onShareTimeline as w,onShow as T,onTabItemTap as E,onThemeChange as D,onUnhandledRejection as O,onUnload as k}from"./runtime/hooks/register.mjs";import{onActivated as A,onBeforeMount as j,onBeforeUnmount as M,onBeforeUpdate as N,onDeactivated as P,onErrorCaptured as F,onMounted as I,onServerPrefetch as L,onUnmounted as R,onUpdated as z}from"./runtime/hooks/vue.mjs";import{version as B}from"./version.mjs";import{isNoSetData as V,markNoSetData as H}from"./runtime/noSetData.mjs";import{takePendingRuntimeAppRegistration as U}from"./runtime/app/pending.mjs";import{INTERNAL_DEFAULTS_SCOPE_KEY as W,resetWevuDefaults as G,setWevuDefaults as K}from"./runtime/defaults.mjs";import{setGlobalProvidedValue as q}from"./runtime/provideStore.mjs";import{resolveRuntimePageLayoutName as J,setPageLayout as Y,syncRuntimePageLayoutState as X,syncRuntimePageLayoutStateFromRuntime as Z,usePageLayout as Q}from"./runtime/pageLayout.mjs";import{runSetupFunction as $}from"./runtime/register/setup.mjs";import{mountRuntimeInstance as ee,setRuntimeSetDataVisibility as te,teardownRuntimeInstance as ne}from"./runtime/register/runtimeInstance.mjs";import{registerApp as re}from"./runtime/register/app.mjs";import{Fragment as ie,createTextVNode as ae,createVNode as oe,isVNode as se,mergeProps as ce,normalizeJsxIsland as le,resolveComponent as ue,resolveDirective as de,transformOn as fe,vModelCheckbox as pe,vModelRadio as me,vModelSelect as he,vModelText as ge,vShow as _e,withDirectives as ve}from"./runtime/jsxIsland.mjs";import{resolveLayoutBridge as ye,resolveLayoutHost as be,useLayoutBridge as xe,useLayoutHosts as Se,waitForLayoutHost as Ce}from"./runtime/layoutBridge.mjs";import{registerComponent as we}from"./runtime/register/component.mjs";import{createApp as Te}from"./runtime/app.mjs";import{hasInjectionContext as Ee,inject as De,injectGlobal as Oe,provide as ke,provideGlobal as Ae}from"./runtime/provide.mjs";import{
|
|
1
|
+
import{callHookList as e,callHookReturn as t,getCurrentInstance as n,getCurrentSetupContext as r,setCurrentInstance as i,setCurrentSetupContext as a}from"./runtime/hooks/base.mjs";import{onAddToFavorites as o,onAttached as s,onDetached as c,onError as l,onHide as u,onLaunch as d,onLoad as f,onMemoryWarning as p,onMoved as m,onPageNotFound as h,onPageScroll as g,onPullDownRefresh as _,onReachBottom as v,onReady as y,onResize as b,onRouteDone as x,onSaveExitState as S,onShareAppMessage as C,onShareTimeline as w,onShow as T,onTabItemTap as E,onThemeChange as D,onUnhandledRejection as O,onUnload as k}from"./runtime/hooks/register.mjs";import{onActivated as A,onBeforeMount as j,onBeforeUnmount as M,onBeforeUpdate as N,onDeactivated as P,onErrorCaptured as F,onMounted as I,onServerPrefetch as L,onUnmounted as R,onUpdated as z}from"./runtime/hooks/vue.mjs";import{version as B}from"./version.mjs";import{isNoSetData as V,markNoSetData as H}from"./runtime/noSetData.mjs";import{takePendingRuntimeAppRegistration as U}from"./runtime/app/pending.mjs";import{INTERNAL_DEFAULTS_SCOPE_KEY as W,resetWevuDefaults as G,setWevuDefaults as K}from"./runtime/defaults.mjs";import{setGlobalProvidedValue as q}from"./runtime/provideStore.mjs";import{resolveRuntimePageLayoutName as J,setPageLayout as Y,syncRuntimePageLayoutState as X,syncRuntimePageLayoutStateFromRuntime as Z,usePageLayout as Q}from"./runtime/pageLayout.mjs";import{runSetupFunction as $}from"./runtime/register/setup.mjs";import{mountRuntimeInstance as ee,setRuntimeSetDataVisibility as te,teardownRuntimeInstance as ne}from"./runtime/register/runtimeInstance.mjs";import{registerApp as re}from"./runtime/register/app.mjs";import{Fragment as ie,createTextVNode as ae,createVNode as oe,isVNode as se,mergeProps as ce,normalizeJsxIsland as le,resolveComponent as ue,resolveDirective as de,transformOn as fe,vModelCheckbox as pe,vModelRadio as me,vModelSelect as he,vModelText as ge,vShow as _e,withDirectives as ve}from"./runtime/jsxIsland.mjs";import{resolveLayoutBridge as ye,resolveLayoutHost as be,useLayoutBridge as xe,useLayoutHosts as Se,waitForLayoutHost as Ce}from"./runtime/layoutBridge.mjs";import{registerComponent as we}from"./runtime/register/component.mjs";import{createApp as Te}from"./runtime/app.mjs";import{hasInjectionContext as Ee,inject as De,injectGlobal as Oe,provide as ke,provideGlobal as Ae}from"./runtime/provide.mjs";import{createIsolatedWevuComponentDefinition as je,createWevuComponent as Me,createWevuComponentDefinition as Ne,createWevuScopedSlotComponent as Pe,defineComponent as Fe,getWevuComponentLifecycleDefinition as Ie}from"./runtime/define.mjs";import{useDisposables as Le}from"./runtime/disposables.mjs";import{useElementIntersectionObserver as Re}from"./runtime/elementIntersectionObserver.mjs";import{useIntersectionObserver as ze}from"./runtime/intersectionObserver.mjs";import{getCurrentPageStackSnapshot as Be,getNavigationBarMetrics as Ve,useNavigationBarMetrics as He,usePageStack as Ue}from"./runtime/pageEnvironment.mjs";import{usePageScrollThrottle as We}from"./runtime/pageScroll.mjs";import{useAsyncPullDownRefresh as Ge}from"./runtime/pullDownRefresh.mjs";import{useBoundingClientRect as Ke,useScrollOffset as qe,useSelectorFields as Je,useSelectorQuery as Ye}from"./runtime/selectorQuery.mjs";import{useUpdatePerformanceListener as Xe}from"./runtime/updatePerformance.mjs";import{defineAppSetup as Ze,use as Qe}from"./runtime/use.mjs";import{useAttrs as $e,useNativeInstance as et,useSlots as tt}from"./runtime/vueCompat/context.mjs";import{mergeModels as nt,useBindModel as rt,useChangeModel as it,useModel as at}from"./runtime/vueCompat/model.mjs";import{useNativePageRouter as ot,useNativeRouter as st}from"./runtime/vueCompat/router.mjs";import{useTemplateRef as ct}from"./runtime/vueCompat/templateRef.mjs";import{createUniAppHost as lt}from"./runtime/uniAppHost.mjs";export{ie as Fragment,W as INTERNAL_DEFAULTS_SCOPE_KEY,e as callHookList,t as callHookReturn,Te as createApp,je as createIsolatedWevuComponentDefinition,ae as createTextVNode,lt as createUniAppHost,oe as createVNode,Me as createWevuComponent,Ne as createWevuComponentDefinition,Pe as createWevuScopedSlotComponent,Ze as defineAppSetup,Fe as defineComponent,n as getCurrentInstance,Be as getCurrentPageStackSnapshot,r as getCurrentSetupContext,Ve as getNavigationBarMetrics,Ie as getWevuComponentLifecycleDefinition,Ee as hasInjectionContext,De as inject,Oe as injectGlobal,V as isNoSetData,se as isVNode,H as markNoSetData,nt as mergeModels,ce as mergeProps,ee as mountRuntimeInstance,le as normalizeJsxIsland,A as onActivated,o as onAddToFavorites,s as onAttached,j as onBeforeMount,M as onBeforeUnmount,N as onBeforeUpdate,P as onDeactivated,c as onDetached,l as onError,F as onErrorCaptured,u as onHide,d as onLaunch,f as onLoad,p as onMemoryWarning,I as onMounted,m as onMoved,h as onPageNotFound,g as onPageScroll,_ as onPullDownRefresh,v as onReachBottom,y as onReady,b as onResize,x as onRouteDone,S as onSaveExitState,L as onServerPrefetch,C as onShareAppMessage,w as onShareTimeline,T as onShow,E as onTabItemTap,D as onThemeChange,O as onUnhandledRejection,k as onUnload,R as onUnmounted,z as onUpdated,ke as provide,Ae as provideGlobal,re as registerApp,we as registerComponent,G as resetWevuDefaults,ue as resolveComponent,de as resolveDirective,ye as resolveLayoutBridge,be as resolveLayoutHost,J as resolveRuntimePageLayoutName,$ as runSetupFunction,i as setCurrentInstance,a as setCurrentSetupContext,q as setGlobalProvidedValue,Y as setPageLayout,te as setRuntimeSetDataVisibility,K as setWevuDefaults,X as syncRuntimePageLayoutState,Z as syncRuntimePageLayoutStateFromRuntime,U as takePendingRuntimeAppRegistration,ne as teardownRuntimeInstance,fe as transformOn,Qe as use,Ge as useAsyncPullDownRefresh,$e as useAttrs,rt as useBindModel,Ke as useBoundingClientRect,it as useChangeModel,Le as useDisposables,Re as useElementIntersectionObserver,ze as useIntersectionObserver,xe as useLayoutBridge,Se as useLayoutHosts,at as useModel,et as useNativeInstance,ot as useNativePageRouter,st as useNativeRouter,He as useNavigationBarMetrics,Q as usePageLayout,We as usePageScrollThrottle,Ue as usePageStack,qe as useScrollOffset,Je as useSelectorFields,Ye as useSelectorQuery,tt as useSlots,ct as useTemplateRef,Xe as useUpdatePerformanceListener,pe as vModelCheckbox,me as vModelRadio,he as vModelSelect,ge as vModelText,_e as vShow,B as version,Ce as waitForLayoutHost,ve as withDirectives};
|
package/dist/package.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`6.
|
|
1
|
+
var e=`6.21.0`;export{e as version};
|
package/dist/runtime/app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getMiniProgramGlobalObject as e}from"./platform.mjs";import{version as t}from"../version.mjs";import{createRuntimeMount as n}from"./app/mount.mjs";import{setPendingRuntimeAppRegistration as r}from"./app/pending.mjs";import{INTERNAL_DEFAULTS_SCOPE_KEY as i,applyWevuAppDefaults as a}from"./defaults.mjs";import{ensureRuntimeAppProvides as o,setRuntimeAppProvidedValue as s}from"./provideContext.mjs";import{registerApp as c}from"./register/app.mjs";function l(l){let u=l[i],{[i]:d,data:f,computed:p,methods:m,setData:h,watch:g,setup:_,...v}=u===`component`?l:a(l),y=m==null?{}:m,b=p==null?{}:p,x=new Set,S=new Set,C=!1,w={globalProperties:{}},T={mount:n({data:f,resolvedComputed:b,resolvedMethods:y,appConfig:w,setDataOptions:h}),use(e,...t){if(!e||x.has(e))return T;if(x.add(e),typeof e==`function`)e(T,...t);else if(typeof e.install==`function`)e.install(T,...t);else throw TypeError(`插件必须是函数,或包含 install 方法的对象`);return T},provide(e,t){return s(T,e,t),T},onUnmount(e){if(typeof e!=`function`)throw TypeError(`onUnmount 只接受函数`);return C?(e(),T):(S.add(e),T)},unmount(){if(!C){C=!0;for(let e of S)e();S.clear()}},config:w,version:t};try{o(T),Object.defineProperty(T,"__wevuSetDataOptions",{value:h,configurable:!0,enumerable:!1,writable:!1}),Object.defineProperty(T,"__wevuHasTemplateRuntimeBindings",{value:Object.keys(b).some(e=>e.startsWith(`__wv_bind_`)),configurable:!0,enumerable:!1,writable:!1})}catch(e){T.__wevuSetDataOptions=h,T.__wevuHasTemplateRuntimeBindings=Object.keys(b).some(e=>e.startsWith(`__wv_bind_`))}let E=()=>{let t=e(),n=`__wevuAppRegistered`;t&&t[n]||(t&&(t[n]=!0),c(T,m==null?{}:m,g,_,v))};return u!==`component`&&typeof App==`function`?E():u!==`component`&&r({app:T,register:E}),T}export{l as createApp};
|
|
1
|
+
import{getMiniProgramGlobalObject as e}from"./platform.mjs";import{version as t}from"../version.mjs";import{createRuntimeMount as n}from"./app/mount.mjs";import{setPendingRuntimeAppRegistration as r}from"./app/pending.mjs";import{INTERNAL_DEFAULTS_SCOPE_KEY as i,applyWevuAppDefaults as a}from"./defaults.mjs";import{ensureRuntimeAppProvides as o,setRuntimeAppProvidedValue as s}from"./provideContext.mjs";import{registerApp as c}from"./register/app.mjs";function l(l){let u=l[i],{[i]:d,data:f,computed:p,methods:m,setData:h,watch:g,setup:_,...v}=u===`component`?l:a(l),y=m==null?{}:m,b=p==null?{}:p,x=new Set,S=new Set,C=!1,w={globalProperties:{}},T={mount:n({data:f,resolvedComputed:b,resolvedMethods:y,appConfig:w,setDataOptions:h}),use(e,...t){if(!e||x.has(e))return T;if(x.add(e),typeof e==`function`)e(T,...t);else if(typeof e.install==`function`)e.install(T,...t);else throw TypeError(`插件必须是函数,或包含 install 方法的对象`);return T},provide(e,t){return s(T,e,t,{syncGlobal:u!==`component`}),T},onUnmount(e){if(typeof e!=`function`)throw TypeError(`onUnmount 只接受函数`);return C?(e(),T):(S.add(e),T)},unmount(){if(!C){C=!0;for(let e of S)e();S.clear()}},config:w,version:t};try{o(T),Object.defineProperty(T,"__wevuSetDataOptions",{value:h,configurable:!0,enumerable:!1,writable:!1}),Object.defineProperty(T,"__wevuHasTemplateRuntimeBindings",{value:Object.keys(b).some(e=>e.startsWith(`__wv_bind_`)),configurable:!0,enumerable:!1,writable:!1})}catch(e){T.__wevuSetDataOptions=h,T.__wevuHasTemplateRuntimeBindings=Object.keys(b).some(e=>e.startsWith(`__wv_bind_`))}let E=()=>{let t=e(),n=`__wevuAppRegistered`;t&&t[n]||(t&&(t[n]=!0),c(T,m==null?{}:m,g,_,v))};return u!==`component`&&typeof App==`function`?E():u!==`component`&&r({app:T,register:E}),T}export{l as createApp};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{INTERNAL_DEFAULTS_SCOPE_KEY as e}from"../defaults.mjs";import{registerComponent as t}from"../register/component.mjs";import{createApp as n}from"../app.mjs";function r(r,i=!1){let a=n({data:r.data,computed:r.computed,methods:r.methods,setData:r.setData,[e]:`component`});return{lifecycleDefinition:t(a,r.methods,r.watch,r.setup,r.mpOptions,{registerNative:i}),runtimeApp:a}}export{r as createRuntimeComponentDefinition};
|
|
@@ -90,6 +90,13 @@ declare function defineComponent<P extends ComponentPropsOptions = ComponentProp
|
|
|
90
90
|
* @internal
|
|
91
91
|
*/
|
|
92
92
|
declare function createWevuComponentDefinition(options: DefineComponentOptions<any, any, any, any, any>): WevuComponentConstructor<InferProps<ComponentPropsOptions>, Record<string, any>, Record<string, any>, ComputedDefinitions, MethodDefinitions> & ComponentDefinition<any, any, any>;
|
|
93
|
+
/**
|
|
94
|
+
* 从现有组件定义派生拥有独立应用上下文的组件定义。
|
|
95
|
+
*
|
|
96
|
+
* @param definition 已解析的 Wevu 组件定义
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
declare function createIsolatedWevuComponentDefinition(definition: object): ComponentDefinition<any, any, any>;
|
|
93
100
|
/**
|
|
94
101
|
* 获取组件定义对应的宿主生命周期定义。
|
|
95
102
|
*
|
|
@@ -116,4 +123,4 @@ declare function createWevuScopedSlotComponent(overrides?: {
|
|
|
116
123
|
templateRefs?: TemplateRefBinding[];
|
|
117
124
|
}): void;
|
|
118
125
|
//#endregion
|
|
119
|
-
export { ComponentDefinition, DefineComponentTypePropsOptions, DefineComponentWithTypeProps, SetupContextWithTypeProps, SetupFunctionWithTypeProps, WevuComponentConstructor, WevuDefinedComponent, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition };
|
|
126
|
+
export { ComponentDefinition, DefineComponentTypePropsOptions, DefineComponentWithTypeProps, SetupContextWithTypeProps, SetupFunctionWithTypeProps, WevuComponentConstructor, WevuDefinedComponent, createIsolatedWevuComponentDefinition, createWevuComponent, createWevuComponentDefinition, createWevuScopedSlotComponent, defineComponent, getWevuComponentLifecycleDefinition };
|
package/dist/runtime/define.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getScopedSlotHostGlobalObject as e}from"./platform.mjs";import{hasOwn as t}from"../utils.mjs";import{
|
|
1
|
+
import{getScopedSlotHostGlobalObject as e}from"./platform.mjs";import{hasOwn as t}from"../utils.mjs";import{applyWevuComponentDefaults as n}from"./defaults.mjs";import{allocateOwnerId as r}from"./scopedSlots.mjs";import{runSetupFunction as i}from"./register/setup.mjs";import{createRuntimeComponentDefinition as a}from"./define/componentDefinition.mjs";import{resolveNativeInitialData as o}from"./define/initialComputed.mjs";import{resolveVueComponentOptions as s}from"./define/options.mjs";import{applyOptionsApiProvide as c,resolveOptionsApiInjections as l}from"./define/optionsApi.mjs";import{normalizeProps as u}from"./define/props.mjs";import{createScopedSlotOptions as d}from"./define/scopedSlotOptions.mjs";import{applySetupResult as f}from"./define/setupResult.mjs";import{WEVU_FUNCTION_PROP_PATHS_KEY as p,WEVU_SCOPED_SLOT_CREATOR_KEY as m,WEVU_SLOT_OWNER_ID_KEY as h,WEVU_SLOT_OWNER_ID_PROP as g,WEVU_SLOT_SCOPE_KEY as _}from"@weapp-core/constants";let v;const y=new WeakMap;function b(){let t=e();if(!t)return;let n=t;v&&n[m]!==v&&(n[m]=v)}function x(e,n){let r={...n==null?{}:n};if(!e||typeof e!=`object`)return r;for(let[n,i]of Object.entries(e))i&&typeof i==`object`&&t(i,`value`)&&(r[n]=i.value);return r}function S(e,t){return!!e.__wevu_isPage&&Array.isArray(t==null?void 0:t.pick)&&t.pick.includes(h)}function C(e){return Array.isArray(e==null?void 0:e.pick)&&e.pick.includes(h)}function w(e){let t=e.properties;return!!(t&&typeof t==`object`&&(g in t||_ in t))}function T(e,t){return(t==null?void 0:t.strategy)!==`patch`||!w(e)?t:{...t,strategy:`diff`}}function E(e,t=!1){let{lifecycleDefinition:n,runtimeApp:r}=a(e,t),i={__wevu_runtime:r,__wevu_options:e};return y.set(i,n),i}function D(e){return O(e,!0)}function O(e,t){t&&b();let{__typeProps:a,data:d,computed:m,methods:g,setData:_,watch:v,setup:y,props:w,inject:D,provide:O,allowFunctionProps:k,...A}=s(n(e)),j=A[p],M=Array.isArray(j)?[...new Set(j.filter(e=>typeof e==`string`&&e.length>0))]:[];delete A[p];let N=T(A,k===!0?{..._==null?{}:_,includeFunctions:!0,functionPaths:M}:k===!1?_:M.length?{..._==null?{}:_,functionPaths:M}:_),P=new Set(M.filter(e=>!e.includes(`.`))),F=u(A,w),I=x(F.properties,g),L=typeof d==`function`?()=>d.call(I):d,R=typeof y==`function`||D!=null||O!=null?((e,t)=>{var n,r;let a=(n=(r=t==null?void 0:t.proxy)==null?t==null?void 0:t.instance:r)==null?Object.create(null):n,o=l(D,a);O!=null&&c(O,a);let s=typeof y==`function`?i(y,e,t):void 0,u={...o,...s==null?{}:s};return t&&Object.keys(u).length&&f(t.runtime,t.instance,u,{includeFunctionsInState:k===!0,functionPropPaths:k===!1?void 0:P}),u}):void 0,z=typeof L==`function`?L():L,B=C(N)?{...z&&typeof z==`object`?z:{},[h]:S(A,N)?(z==null?void 0:z[h])||r():(z==null?void 0:z[h])||``}:z,V=o(B,m,N,g);return E({data:L,computed:m,methods:g,setData:N,watch:v,setup:R,mpOptions:V===void 0?F:{...F,data:V}},t)}function k(e){return O(e,!1)}function A(e){let t=e.__wevu_options;if(!t)throw TypeError(`无法从非 Wevu 组件定义创建独立运行时`);return E(t)}function j(e){return y.get(e)}function M(e){var t;b();let{properties:n,props:r,...i}=e,a={...i,allowNullPropInput:(t=i.allowNullPropInput)==null||t,__wevu_allowNullPropInput:!0};D(u(a,r,n))}function N(e){M(d(e))}v=N,b();export{A as createIsolatedWevuComponentDefinition,M as createWevuComponent,k as createWevuComponentDefinition,N as createWevuScopedSlotComponent,D as defineComponent,j as getWevuComponentLifecycleDefinition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setGlobalProvidedValue as e}from"./provideStore.mjs";import{WEVU_APP_PROVIDES_KEY as t,WEVU_IS_APP_INSTANCE_KEY as n,WEVU_PARENT_INSTANCE_KEY as r,WEVU_PROVIDES_KEY as i,WEVU_RUNTIME_APP_KEY as a}from"@weapp-core/constants";function o(e){return!!(e&&typeof e==`object`&&e[n]===!0)}function s(e){return Object.create(e==null?null:e)}function c(e){if(!e)return s();let n=e[t];if(n&&typeof n==`object`)return n;let r=s();try{Object.defineProperty(e,t,{value:r,configurable:!0,enumerable:!1,writable:!1})}catch(n){e[t]=r}return r}function l(e,t){try{Object.defineProperty(e,i,{value:t,configurable:!0,enumerable:!1,writable:!0})}catch(n){e[i]=t}}function u(e){var t,n;let u=e[i];if(u&&typeof u==`object`)return u;let d=e[a],f=(t=(n=e[r])==null?void 0:n[i])==null?c(d):t,p=o(e)?c(d):s(f);return l(e,p),p}function d(e){return c(e)}function f(t,n,r){c(t)[n]=r,e(n,r)}function p(e,t,n){var a;let u=c(t),d=(a=n==null?void 0:n[i])==null?u:a,f=o(e)?u:s(d);if(n)try{Object.defineProperty(e,r,{value:n,configurable:!0,enumerable:!1,writable:!0})}catch(t){e[r]=n}l(e,f)}function m(e,t){let n=Object.getPrototypeOf(e);for(;n;){if(n===t)return!0;n=Object.getPrototypeOf(n)}return!1}function h(e,t){let n=u(e),i=u(t);if(!(n===i||m(n,i)||m(i,n))){Object.setPrototypeOf(i,n);try{Object.defineProperty(t,r,{value:e,configurable:!0,enumerable:!1,writable:!0})}catch(n){t[r]=e}}}export{l as attachInstanceProvides,h as attachRuntimeLayoutProvideContext,p as attachRuntimeProvideContext,d as ensureRuntimeAppProvides,u as getInstanceProvides,o as isRuntimeAppInstance,f as setRuntimeAppProvidedValue};
|
|
1
|
+
import{setGlobalProvidedValue as e}from"./provideStore.mjs";import{WEVU_APP_PROVIDES_KEY as t,WEVU_IS_APP_INSTANCE_KEY as n,WEVU_PARENT_INSTANCE_KEY as r,WEVU_PROVIDES_KEY as i,WEVU_RUNTIME_APP_KEY as a}from"@weapp-core/constants";function o(e){return!!(e&&typeof e==`object`&&e[n]===!0)}function s(e){return Object.create(e==null?null:e)}function c(e){if(!e)return s();let n=e[t];if(n&&typeof n==`object`)return n;let r=s();try{Object.defineProperty(e,t,{value:r,configurable:!0,enumerable:!1,writable:!1})}catch(n){e[t]=r}return r}function l(e,t){try{Object.defineProperty(e,i,{value:t,configurable:!0,enumerable:!1,writable:!0})}catch(n){e[i]=t}}function u(e){var t,n;let u=e[i];if(u&&typeof u==`object`)return u;let d=e[a],f=(t=(n=e[r])==null?void 0:n[i])==null?c(d):t,p=o(e)?c(d):s(f);return l(e,p),p}function d(e){return c(e)}function f(t,n,r,i={}){c(t)[n]=r,i.syncGlobal!==!1&&e(n,r)}function p(e,t,n){var a;let u=c(t),d=(a=n==null?void 0:n[i])==null?u:a,f=o(e)?u:s(d);if(n)try{Object.defineProperty(e,r,{value:n,configurable:!0,enumerable:!1,writable:!0})}catch(t){e[r]=n}l(e,f)}function m(e,t){let n=Object.getPrototypeOf(e);for(;n;){if(n===t)return!0;n=Object.getPrototypeOf(n)}return!1}function h(e,t){let n=u(e),i=u(t);if(!(n===i||m(n,i)||m(i,n))){Object.setPrototypeOf(i,n);try{Object.defineProperty(t,r,{value:e,configurable:!0,enumerable:!1,writable:!0})}catch(n){t[r]=e}}}export{l as attachInstanceProvides,h as attachRuntimeLayoutProvideContext,p as attachRuntimeProvideContext,d as ensureRuntimeAppProvides,u as getInstanceProvides,o as isRuntimeAppInstance,f as setRuntimeAppProvidedValue};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wevu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.21.0",
|
|
5
5
|
"description": "Vue 3 风格的小程序运行时,包含响应式、diff+setData 与轻量状态管理",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -228,9 +228,9 @@
|
|
|
228
228
|
"vue": "^3.5.41",
|
|
229
229
|
"@weapp-core/constants": "0.1.17",
|
|
230
230
|
"@weapp-core/shared": "3.1.1",
|
|
231
|
-
"@wevu/
|
|
232
|
-
"@wevu/
|
|
233
|
-
"@wevu/
|
|
231
|
+
"@wevu/compiler": "6.21.0",
|
|
232
|
+
"@wevu/web-apis": "1.2.34",
|
|
233
|
+
"@wevu/api": "0.2.16"
|
|
234
234
|
},
|
|
235
235
|
"scripts": {
|
|
236
236
|
"dev": "tsdown -w",
|