wevu 7.3.0 → 7.4.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/package.mjs +1 -1
- package/dist/dev/router/initialNavigation.mjs +4 -1
- package/dist/dev/router/initialNavigation.mjs.map +1 -1
- package/dist/dev/router/scrollRestoration/adapters.d.mts +8 -0
- package/dist/dev/router/scrollRestoration/adapters.mjs +86 -0
- package/dist/dev/router/scrollRestoration/adapters.mjs.map +1 -0
- package/dist/dev/router/scrollRestoration/controller.d.mts +8 -0
- package/dist/dev/router/scrollRestoration/controller.mjs +148 -0
- package/dist/dev/router/scrollRestoration/controller.mjs.map +1 -0
- package/dist/dev/router/scrollRestoration/host.d.mts +3 -0
- package/dist/dev/router/scrollRestoration/host.mjs +76 -0
- package/dist/dev/router/scrollRestoration/host.mjs.map +1 -0
- package/dist/dev/router/scrollRestoration/index.d.mts +9 -0
- package/dist/dev/router/scrollRestoration/index.mjs +156 -0
- package/dist/dev/router/scrollRestoration/index.mjs.map +1 -0
- package/dist/dev/router/scrollRestoration/types.d.mts +61 -0
- package/dist/dev/router.d.mts +5 -1
- package/dist/dev/router.mjs +4 -1
- package/dist/dev/runtime/hooks/base.mjs +1 -13
- package/dist/dev/runtime/hooks/base.mjs.map +1 -1
- package/dist/dev/runtime/hooks/pageScroll.mjs +41 -0
- package/dist/dev/runtime/hooks/pageScroll.mjs.map +1 -0
- package/dist/dev/runtime/hooks/register.mjs +2 -1
- package/dist/dev/runtime/hooks/register.mjs.map +1 -1
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs +2 -5
- package/dist/dev/runtime/register/component/lifecycle/optionalHooks.mjs.map +1 -1
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs +8 -20
- package/dist/dev/runtime/register/component/lifecycle/platform.mjs.map +1 -1
- package/dist/dev/runtime/register/component/registerDefinition.mjs +3 -0
- package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +7 -2
- package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
- package/dist/package.mjs +1 -1
- package/dist/router/initialNavigation.mjs +1 -1
- package/dist/router/scrollRestoration/adapters.d.mts +7 -0
- package/dist/router/scrollRestoration/adapters.mjs +1 -0
- package/dist/router/scrollRestoration/controller.d.mts +7 -0
- package/dist/router/scrollRestoration/controller.mjs +1 -0
- package/dist/router/scrollRestoration/host.d.mts +3 -0
- package/dist/router/scrollRestoration/host.mjs +1 -0
- package/dist/router/scrollRestoration/index.d.mts +8 -0
- package/dist/router/scrollRestoration/index.mjs +1 -0
- package/dist/router/scrollRestoration/types.d.mts +60 -0
- package/dist/router.d.mts +5 -1
- package/dist/router.mjs +1 -1
- package/dist/runtime/hooks/base.mjs +1 -1
- package/dist/runtime/hooks/pageScroll.mjs +1 -0
- package/dist/runtime/hooks/register.mjs +1 -1
- package/dist/runtime/register/component/lifecycle/optionalHooks.mjs +1 -1
- package/dist/runtime/register/component/lifecycle/platform.mjs +1 -1
- package/dist/runtime/register/component/registerDefinition.mjs +1 -1
- package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
- package/package.json +7 -7
|
@@ -15,6 +15,7 @@ import { WEVU_ATTRS_KEY, WEVU_EFFECT_SCOPE_KEY, WEVU_EXPOSED_KEY, WEVU_PROP_KEYS
|
|
|
15
15
|
//#region src/runtime/register/runtimeInstance/setupPhase.ts
|
|
16
16
|
let vueCompatInstanceUid = 0;
|
|
17
17
|
function attachVueCompatInstanceView(target, proxy) {
|
|
18
|
+
let exposedView;
|
|
18
19
|
const internal = target;
|
|
19
20
|
const descriptors = {
|
|
20
21
|
proxy: {
|
|
@@ -38,7 +39,7 @@ function attachVueCompatInstanceView(target, proxy) {
|
|
|
38
39
|
exposed: {
|
|
39
40
|
configurable: true,
|
|
40
41
|
enumerable: false,
|
|
41
|
-
get: () =>
|
|
42
|
+
get: () => exposedView
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
for (const [key, descriptor] of Object.entries(descriptors)) try {
|
|
@@ -65,6 +66,9 @@ function attachVueCompatInstanceView(target, proxy) {
|
|
|
65
66
|
} catch {
|
|
66
67
|
proxy[key] = descriptor.value;
|
|
67
68
|
}
|
|
69
|
+
return (exposed) => {
|
|
70
|
+
exposedView = exposed;
|
|
71
|
+
};
|
|
68
72
|
}
|
|
69
73
|
function isInternalAttrKey(key) {
|
|
70
74
|
return key.startsWith("__wv_");
|
|
@@ -99,7 +103,7 @@ function runRuntimeSetupPhase(options) {
|
|
|
99
103
|
target[WEVU_ATTRS_KEY] = attrs;
|
|
100
104
|
}
|
|
101
105
|
const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults);
|
|
102
|
-
attachVueCompatInstanceView(target, setupInstance);
|
|
106
|
+
const updateExposedView = attachVueCompatInstanceView(target, setupInstance);
|
|
103
107
|
const slots = attachRuntimeSlots(runtimeState, props);
|
|
104
108
|
const setupState = runtimeWithDefaults.setupState ?? Object.create(null);
|
|
105
109
|
attachRuntimeSetupState(runtimeState, setupState);
|
|
@@ -118,6 +122,7 @@ function runRuntimeSetupPhase(options) {
|
|
|
118
122
|
},
|
|
119
123
|
expose: (exposed) => {
|
|
120
124
|
target[WEVU_EXPOSED_KEY] = exposed;
|
|
125
|
+
updateExposedView(exposed);
|
|
121
126
|
},
|
|
122
127
|
attrs,
|
|
123
128
|
slots
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupPhase.mjs","names":[],"sources":["../../../../../src/runtime/register/runtimeInstance/setupPhase.ts"],"sourcesContent":["import type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineAppOptions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeInstance,\n} from '../../types'\nimport {\n WEVU_ATTRS_KEY,\n WEVU_EFFECT_SCOPE_KEY,\n WEVU_EXPOSED_KEY,\n WEVU_PROP_KEYS_KEY,\n} from '@weapp-core/constants'\nimport { effectScope, isReactive, shallowReactive, toRaw } from '../../../reactivity'\nimport { hasOwn } from '../../../utils'\nimport { preserveSetupAccessor } from '../../define/setupResult'\nimport { normalizeEmitEventName } from '../../emit'\nimport { getCurrentInstance, getCurrentSetupContext, setCurrentInstance, setCurrentSetupContext } from '../../hooks'\nimport { hasTrackableSetupBinding } from '../../setupTracking'\nimport { runSetupFunction } from '../setup'\nimport {\n attachRuntimeSlots,\n ensureSetupContextInstance,\n normalizeEmitPayload,\n safeMarkNoSetData,\n} from './setupContext'\nimport { attachRuntimeSetupState, ensureRuntimeProps } from './utils'\n\ntype RuntimeSetupFunction<\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> = DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n | DefineAppOptions<D, C, M>['setup']\n\nlet vueCompatInstanceUid = 0\n\nfunction attachVueCompatInstanceView(target: InternalRuntimeState, proxy: Record<string, any>) {\n const internal = target as Record<string, any>\n const descriptors: PropertyDescriptorMap = {\n proxy: {\n configurable: true,\n enumerable: false,\n value: proxy,\n writable: false,\n },\n $: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n uid: {\n configurable: true,\n enumerable: false,\n value: ++vueCompatInstanceUid,\n writable: false,\n },\n exposed: {\n configurable: true,\n enumerable: false,\n get: () => target[WEVU_EXPOSED_KEY],\n },\n }\n for (const [key, descriptor] of Object.entries(descriptors)) {\n try {\n Object.defineProperty(internal, key, descriptor)\n }\n catch {\n if ('value' in descriptor) {\n internal[key] = descriptor.value\n }\n }\n }\n const publicDescriptors: PropertyDescriptorMap = {\n $: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n $el: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n }\n for (const [key, descriptor] of Object.entries(publicDescriptors)) {\n try {\n Object.defineProperty(proxy, key, descriptor)\n }\n catch {\n proxy[key] = descriptor.value\n }\n }\n}\n\nfunction isInternalAttrKey(key: string) {\n return key.startsWith('__wv_')\n}\n\nexport function runRuntimeSetupPhase<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n target: InternalRuntimeState\n runtime: RuntimeInstance<D, C, M>\n runtimeWithDefaults: RuntimeInstance<any, any, any>\n runtimeState: Record<string, any>\n runtimeProxy: Record<string, any>\n setup: RuntimeSetupFunction<D, C, M>\n}) {\n const {\n target,\n runtime,\n runtimeWithDefaults,\n runtimeState,\n runtimeProxy,\n setup,\n } = options\n\n // 从小程序 properties 提取 props 供 setup 使用,并复用 runtime state 上的 props 容器,\n // 避免 computed 首次求值早于 setup 时丢失依赖。\n const mpProperties = ((target as any).properties || {}) as Record<string, any>\n const props = ensureRuntimeProps(target, runtimeState, mpProperties)\n\n // 与 Vue 3 对齐:attrs = 非 props 的 attributes。\n // 在小程序场景中,attrs 来源于 instance.properties 中“未声明在 props/properties 的字段”。\n const attrs = shallowReactive(Object.create(null)) as Record<string, any>\n const declaredPropKeys = new Set(\n Array.isArray((target as any)[WEVU_PROP_KEYS_KEY])\n ? ((target as any)[WEVU_PROP_KEYS_KEY] as string[])\n : [],\n )\n const hasRuntimeStateKey = (key: string) => {\n return runtimeState != null\n && typeof runtimeState === 'object'\n && hasOwn(runtimeState as Record<string, unknown>, key)\n }\n const syncAttrsFromProperties = () => {\n const next = ((target as any).properties && typeof (target as any).properties === 'object')\n ? ((target as any).properties as Record<string, unknown>)\n : undefined\n\n for (const existingKey of Object.keys(attrs)) {\n if (\n !next\n || !hasOwn(next, existingKey)\n || isInternalAttrKey(existingKey)\n || declaredPropKeys.has(existingKey)\n || hasRuntimeStateKey(existingKey)\n ) {\n delete attrs[existingKey]\n }\n }\n\n if (!next) {\n return\n }\n\n for (const [key, value] of Object.entries(next)) {\n if (isInternalAttrKey(key) || declaredPropKeys.has(key) || hasRuntimeStateKey(key)) {\n continue\n }\n attrs[key] = value\n }\n }\n syncAttrsFromProperties()\n\n try {\n Object.defineProperty(target, WEVU_ATTRS_KEY, {\n value: attrs,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(target as any)[WEVU_ATTRS_KEY] = attrs\n }\n\n const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults)\n attachVueCompatInstanceView(target, setupInstance as Record<string, any>)\n const slots = attachRuntimeSlots(runtimeState, props)\n const setupState = runtimeWithDefaults.setupState ?? Object.create(null)\n attachRuntimeSetupState(runtimeState, setupState)\n\n const context = safeMarkNoSetData({\n // 与 Vue 3 对齐的 ctx.props\n props,\n\n // 现有运行时能力\n runtime: runtimeWithDefaults,\n state: runtimeState,\n proxy: runtimeProxy,\n bindModel: runtime.bindModel.bind(runtimeWithDefaults),\n watch: runtime.watch.bind(runtimeWithDefaults),\n instance: setupInstance,\n\n // 通过小程序 triggerEvent 派发事件,并兼容 Vue 3 的 emit(event, ...args) 形式。\n emit: (event: string, ...args: any[]) => {\n const { detail, options } = normalizeEmitPayload(args)\n const eventName = normalizeEmitEventName(event)\n setupInstance.triggerEvent(eventName, detail, options)\n },\n\n // 与 Vue 3 对齐的 expose\n expose: (exposed: Record<string, any>) => {\n target[WEVU_EXPOSED_KEY] = exposed\n },\n\n // 与 Vue 3 对齐的 attrs(小程序中为非 props 属性集合)\n attrs,\n\n // 与 Vue 3 对齐的 slots(由编译期传入的 slot 名元数据驱动)\n slots,\n }) as any\n\n // 仅在同步 setup 执行期间暴露 current instance\n const instanceScope = effectScope(true)\n const previousInstance = getCurrentInstance()\n const previousSetupContext = getCurrentSetupContext()\n const restoreSetupContext = () => {\n // 仅当全局上下文仍属于本次 setup 时恢复父级;嵌套或重入 setup\n // 可能已经建立了新的上下文,不能被旧调用覆盖。\n if (getCurrentInstance() !== target || getCurrentSetupContext() !== context) {\n return\n }\n setCurrentSetupContext(previousSetupContext)\n setCurrentInstance(previousInstance)\n }\n target[WEVU_EFFECT_SCOPE_KEY] = instanceScope\n setCurrentInstance(target)\n setCurrentSetupContext(context)\n try {\n const result = instanceScope.run(() => runSetupFunction(setup, props, context))\n let methodsChanged = false\n if (result && typeof result === 'object') {\n const setupResult = result as Record<string, unknown>\n const runtimeSetupState = (runtime as any).setupState && typeof (runtime as any).setupState === 'object'\n ? (isReactive((runtime as any).setupState) ? toRaw((runtime as any).setupState) : (runtime as any).setupState)\n : Object.create(null)\n Object.keys(setupResult).forEach((key) => {\n const val = setupResult[key]\n const preservesAccessor = preserveSetupAccessor(runtimeSetupState, setupResult, key)\n if (typeof val === 'function' && !preservesAccessor) {\n const bound = (...args: any[]) => (val as any).apply((runtime as any).proxy, args)\n ;(runtime.methods as any)[key] = bound\n ;(runtime.state as any)[key] = bound\n ;(runtimeSetupState as any)[key] = bound\n methodsChanged = true\n }\n else {\n if (hasTrackableSetupBinding(val)) {\n ;(runtime as any).__wevu_trackSetupReactiveKey?.(key)\n }\n ;(runtime.state as any)[key] = val\n if (!preservesAccessor) {\n ;(runtimeSetupState as any)[key] = val\n }\n }\n })\n }\n if (methodsChanged) {\n ;(runtime as any).__wevu_touchSetupMethodsVersion?.()\n }\n }\n finally {\n // current instance/context 只属于本次同步 setup 调用;异步 continuation\n // 不能继续占用全局上下文,否则会污染随后挂载的组件。\n restoreSetupContext()\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"setupPhase.mjs","names":[],"sources":["../../../../../src/runtime/register/runtimeInstance/setupPhase.ts"],"sourcesContent":["import type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineAppOptions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeInstance,\n} from '../../types'\nimport {\n WEVU_ATTRS_KEY,\n WEVU_EFFECT_SCOPE_KEY,\n WEVU_EXPOSED_KEY,\n WEVU_PROP_KEYS_KEY,\n} from '@weapp-core/constants'\nimport { effectScope, isReactive, shallowReactive, toRaw } from '../../../reactivity'\nimport { hasOwn } from '../../../utils'\nimport { preserveSetupAccessor } from '../../define/setupResult'\nimport { normalizeEmitEventName } from '../../emit'\nimport { getCurrentInstance, getCurrentSetupContext, setCurrentInstance, setCurrentSetupContext } from '../../hooks'\nimport { hasTrackableSetupBinding } from '../../setupTracking'\nimport { runSetupFunction } from '../setup'\nimport {\n attachRuntimeSlots,\n ensureSetupContextInstance,\n normalizeEmitPayload,\n safeMarkNoSetData,\n} from './setupContext'\nimport { attachRuntimeSetupState, ensureRuntimeProps } from './utils'\n\ntype RuntimeSetupFunction<\n D extends object,\n C extends ComputedDefinitions,\n M extends MethodDefinitions,\n> = DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n | DefineAppOptions<D, C, M>['setup']\n\nlet vueCompatInstanceUid = 0\n\nfunction attachVueCompatInstanceView(target: InternalRuntimeState, proxy: Record<string, any>) {\n // 已排队的用户回调可以持有实例;兼容视图与宿主注册表的销毁周期分离。\n let exposedView: Record<string, any> | undefined\n const internal = target as Record<string, any>\n const descriptors: PropertyDescriptorMap = {\n proxy: {\n configurable: true,\n enumerable: false,\n value: proxy,\n writable: false,\n },\n $: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n uid: {\n configurable: true,\n enumerable: false,\n value: ++vueCompatInstanceUid,\n writable: false,\n },\n exposed: {\n configurable: true,\n enumerable: false,\n get: () => exposedView,\n },\n }\n for (const [key, descriptor] of Object.entries(descriptors)) {\n try {\n Object.defineProperty(internal, key, descriptor)\n }\n catch {\n if ('value' in descriptor) {\n internal[key] = descriptor.value\n }\n }\n }\n const publicDescriptors: PropertyDescriptorMap = {\n $: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n $el: {\n configurable: true,\n enumerable: false,\n value: target,\n writable: false,\n },\n }\n for (const [key, descriptor] of Object.entries(publicDescriptors)) {\n try {\n Object.defineProperty(proxy, key, descriptor)\n }\n catch {\n proxy[key] = descriptor.value\n }\n }\n return (exposed: Record<string, any>) => {\n exposedView = exposed\n }\n}\n\nfunction isInternalAttrKey(key: string) {\n return key.startsWith('__wv_')\n}\n\nexport function runRuntimeSetupPhase<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n target: InternalRuntimeState\n runtime: RuntimeInstance<D, C, M>\n runtimeWithDefaults: RuntimeInstance<any, any, any>\n runtimeState: Record<string, any>\n runtimeProxy: Record<string, any>\n setup: RuntimeSetupFunction<D, C, M>\n}) {\n const {\n target,\n runtime,\n runtimeWithDefaults,\n runtimeState,\n runtimeProxy,\n setup,\n } = options\n\n // 从小程序 properties 提取 props 供 setup 使用,并复用 runtime state 上的 props 容器,\n // 避免 computed 首次求值早于 setup 时丢失依赖。\n const mpProperties = ((target as any).properties || {}) as Record<string, any>\n const props = ensureRuntimeProps(target, runtimeState, mpProperties)\n\n // 与 Vue 3 对齐:attrs = 非 props 的 attributes。\n // 在小程序场景中,attrs 来源于 instance.properties 中“未声明在 props/properties 的字段”。\n const attrs = shallowReactive(Object.create(null)) as Record<string, any>\n const declaredPropKeys = new Set(\n Array.isArray((target as any)[WEVU_PROP_KEYS_KEY])\n ? ((target as any)[WEVU_PROP_KEYS_KEY] as string[])\n : [],\n )\n const hasRuntimeStateKey = (key: string) => {\n return runtimeState != null\n && typeof runtimeState === 'object'\n && hasOwn(runtimeState as Record<string, unknown>, key)\n }\n const syncAttrsFromProperties = () => {\n const next = ((target as any).properties && typeof (target as any).properties === 'object')\n ? ((target as any).properties as Record<string, unknown>)\n : undefined\n\n for (const existingKey of Object.keys(attrs)) {\n if (\n !next\n || !hasOwn(next, existingKey)\n || isInternalAttrKey(existingKey)\n || declaredPropKeys.has(existingKey)\n || hasRuntimeStateKey(existingKey)\n ) {\n delete attrs[existingKey]\n }\n }\n\n if (!next) {\n return\n }\n\n for (const [key, value] of Object.entries(next)) {\n if (isInternalAttrKey(key) || declaredPropKeys.has(key) || hasRuntimeStateKey(key)) {\n continue\n }\n attrs[key] = value\n }\n }\n syncAttrsFromProperties()\n\n try {\n Object.defineProperty(target, WEVU_ATTRS_KEY, {\n value: attrs,\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n catch {\n ;(target as any)[WEVU_ATTRS_KEY] = attrs\n }\n\n const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults)\n const updateExposedView = attachVueCompatInstanceView(target, setupInstance as Record<string, any>)\n const slots = attachRuntimeSlots(runtimeState, props)\n const setupState = runtimeWithDefaults.setupState ?? Object.create(null)\n attachRuntimeSetupState(runtimeState, setupState)\n\n const context = safeMarkNoSetData({\n // 与 Vue 3 对齐的 ctx.props\n props,\n\n // 现有运行时能力\n runtime: runtimeWithDefaults,\n state: runtimeState,\n proxy: runtimeProxy,\n bindModel: runtime.bindModel.bind(runtimeWithDefaults),\n watch: runtime.watch.bind(runtimeWithDefaults),\n instance: setupInstance,\n\n // 通过小程序 triggerEvent 派发事件,并兼容 Vue 3 的 emit(event, ...args) 形式。\n emit: (event: string, ...args: any[]) => {\n const { detail, options } = normalizeEmitPayload(args)\n const eventName = normalizeEmitEventName(event)\n setupInstance.triggerEvent(eventName, detail, options)\n },\n\n // 与 Vue 3 对齐的 expose\n expose: (exposed: Record<string, any>) => {\n target[WEVU_EXPOSED_KEY] = exposed\n updateExposedView(exposed)\n },\n\n // 与 Vue 3 对齐的 attrs(小程序中为非 props 属性集合)\n attrs,\n\n // 与 Vue 3 对齐的 slots(由编译期传入的 slot 名元数据驱动)\n slots,\n }) as any\n\n // 仅在同步 setup 执行期间暴露 current instance\n const instanceScope = effectScope(true)\n const previousInstance = getCurrentInstance()\n const previousSetupContext = getCurrentSetupContext()\n const restoreSetupContext = () => {\n // 仅当全局上下文仍属于本次 setup 时恢复父级;嵌套或重入 setup\n // 可能已经建立了新的上下文,不能被旧调用覆盖。\n if (getCurrentInstance() !== target || getCurrentSetupContext() !== context) {\n return\n }\n setCurrentSetupContext(previousSetupContext)\n setCurrentInstance(previousInstance)\n }\n target[WEVU_EFFECT_SCOPE_KEY] = instanceScope\n setCurrentInstance(target)\n setCurrentSetupContext(context)\n try {\n const result = instanceScope.run(() => runSetupFunction(setup, props, context))\n let methodsChanged = false\n if (result && typeof result === 'object') {\n const setupResult = result as Record<string, unknown>\n const runtimeSetupState = (runtime as any).setupState && typeof (runtime as any).setupState === 'object'\n ? (isReactive((runtime as any).setupState) ? toRaw((runtime as any).setupState) : (runtime as any).setupState)\n : Object.create(null)\n Object.keys(setupResult).forEach((key) => {\n const val = setupResult[key]\n const preservesAccessor = preserveSetupAccessor(runtimeSetupState, setupResult, key)\n if (typeof val === 'function' && !preservesAccessor) {\n const bound = (...args: any[]) => (val as any).apply((runtime as any).proxy, args)\n ;(runtime.methods as any)[key] = bound\n ;(runtime.state as any)[key] = bound\n ;(runtimeSetupState as any)[key] = bound\n methodsChanged = true\n }\n else {\n if (hasTrackableSetupBinding(val)) {\n ;(runtime as any).__wevu_trackSetupReactiveKey?.(key)\n }\n ;(runtime.state as any)[key] = val\n if (!preservesAccessor) {\n ;(runtimeSetupState as any)[key] = val\n }\n }\n })\n }\n if (methodsChanged) {\n ;(runtime as any).__wevu_touchSetupMethodsVersion?.()\n }\n }\n finally {\n // current instance/context 只属于本次同步 setup 调用;异步 continuation\n // 不能继续占用全局上下文,否则会污染随后挂载的组件。\n restoreSetupContext()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAI,uBAAuB;AAE3B,SAAS,4BAA4B,QAA8B,OAA4B;CAE7F,IAAI;CACJ,MAAM,WAAW;CACjB,MAAM,cAAqC;EACzC,OAAO;GACL,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;EACA,GAAG;GACD,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;EACA,KAAK;GACH,cAAc;GACd,YAAY;GACZ,OAAO,EAAE;GACT,UAAU;EACZ;EACA,SAAS;GACP,cAAc;GACd,YAAY;GACZ,WAAW;EACb;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,WAAW,GACxD,IAAI;EACF,OAAO,eAAe,UAAU,KAAK,UAAU;CACjD,QACM;EACJ,IAAI,WAAW,YACb,SAAS,OAAO,WAAW;CAE/B;CAEF,MAAM,oBAA2C;EAC/C,GAAG;GACD,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;EACA,KAAK;GACH,cAAc;GACd,YAAY;GACZ,OAAO;GACP,UAAU;EACZ;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,iBAAiB,GAC9D,IAAI;EACF,OAAO,eAAe,OAAO,KAAK,UAAU;CAC9C,QACM;EACJ,MAAM,OAAO,WAAW;CAC1B;CAEF,QAAQ,YAAiC;EACvC,cAAc;CAChB;AACF;AAEA,SAAS,kBAAkB,KAAa;CACtC,OAAO,IAAI,WAAW,OAAO;AAC/B;AAEA,SAAgB,qBAAmG,SAOhH;CACD,MAAM,EACJ,QACA,SACA,qBACA,cACA,cACA,UACE;CAIJ,MAAM,eAAiB,OAAe,cAAc,CAAC;CACrD,MAAM,QAAQ,mBAAmB,QAAQ,cAAc,YAAY;CAInE,MAAM,QAAQ,gBAAgB,OAAO,OAAO,IAAI,CAAC;CACjD,MAAM,mBAAmB,IAAI,IAC3B,MAAM,QAAS,OAAe,mBAAmB,IAC3C,OAAe,sBACjB,CAAC,CACP;CACA,MAAM,sBAAsB,QAAgB;EAC1C,OAAO,gBAAgB,QAClB,OAAO,iBAAiB,YACxB,OAAO,cAAyC,GAAG;CAC1D;CACA,MAAM,gCAAgC;EACpC,MAAM,OAAS,OAAe,cAAc,OAAQ,OAAe,eAAe,WAC5E,OAAe,aACjB;EAEJ,KAAK,MAAM,eAAe,OAAO,KAAK,KAAK,GACzC,IACE,CAAC,QACE,CAAC,OAAO,MAAM,WAAW,KACzB,kBAAkB,WAAW,KAC7B,iBAAiB,IAAI,WAAW,KAChC,mBAAmB,WAAW,GAEjC,OAAO,MAAM;EAIjB,IAAI,CAAC,MACH;EAGF,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;GAC/C,IAAI,kBAAkB,GAAG,KAAK,iBAAiB,IAAI,GAAG,KAAK,mBAAmB,GAAG,GAC/E;GAEF,MAAM,OAAO;EACf;CACF;CACA,wBAAwB;CAExB,IAAI;EACF,OAAO,eAAe,QAAQ,gBAAgB;GAC5C,OAAO;GACP,cAAc;GACd,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,QACM;EACH,AAAC,OAAe,kBAAkB;CACrC;CAEA,MAAM,gBAAgB,2BAA2B,QAAQ,mBAAmB;CAC5E,MAAM,oBAAoB,4BAA4B,QAAQ,aAAoC;CAClG,MAAM,QAAQ,mBAAmB,cAAc,KAAK;CACpD,MAAM,aAAa,oBAAoB,cAAc,OAAO,OAAO,IAAI;CACvE,wBAAwB,cAAc,UAAU;CAEhD,MAAM,UAAU,kBAAkB;EAEhC;EAGA,SAAS;EACT,OAAO;EACP,OAAO;EACP,WAAW,QAAQ,UAAU,KAAK,mBAAmB;EACrD,OAAO,QAAQ,MAAM,KAAK,mBAAmB;EAC7C,UAAU;EAGV,OAAO,OAAe,GAAG,SAAgB;GACvC,MAAM,EAAE,QAAQ,YAAY,qBAAqB,IAAI;GACrD,MAAM,YAAY,uBAAuB,KAAK;GAC9C,cAAc,aAAa,WAAW,QAAQ,OAAO;EACvD;EAGA,SAAS,YAAiC;GACxC,OAAO,oBAAoB;GAC3B,kBAAkB,OAAO;EAC3B;EAGA;EAGA;CACF,CAAC;CAGD,MAAM,gBAAgB,YAAY,IAAI;CACtC,MAAM,mBAAmB,mBAAmB;CAC5C,MAAM,uBAAuB,uBAAuB;CACpD,MAAM,4BAA4B;EAGhC,IAAI,mBAAmB,MAAM,UAAU,uBAAuB,MAAM,SAClE;EAEF,uBAAuB,oBAAoB;EAC3C,mBAAmB,gBAAgB;CACrC;CACA,OAAO,yBAAyB;CAChC,mBAAmB,MAAM;CACzB,uBAAuB,OAAO;CAC9B,IAAI;EACF,MAAM,SAAS,cAAc,UAAU,iBAAiB,OAAO,OAAO,OAAO,CAAC;EAC9E,IAAI,iBAAiB;EACrB,IAAI,UAAU,OAAO,WAAW,UAAU;GACxC,MAAM,cAAc;GACpB,MAAM,oBAAqB,QAAgB,cAAc,OAAQ,QAAgB,eAAe,WAC3F,WAAY,QAAgB,UAAU,IAAI,MAAO,QAAgB,UAAU,IAAK,QAAgB,aACjG,OAAO,OAAO,IAAI;GACtB,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,QAAQ;IACxC,MAAM,MAAM,YAAY;IACxB,MAAM,oBAAoB,sBAAsB,mBAAmB,aAAa,GAAG;IACnF,IAAI,OAAO,QAAQ,cAAc,CAAC,mBAAmB;KACnD,MAAM,SAAS,GAAG,SAAiB,IAAY,MAAO,QAAgB,OAAO,IAAI;KAChF,AAAC,QAAQ,QAAgB,OAAO;KAChC,AAAC,QAAQ,MAAc,OAAO;KAC9B,AAAC,kBAA0B,OAAO;KACnC,iBAAiB;IACnB,OACK;KACH,IAAI,yBAAyB,GAAG,GAC7B,AAAC,QAAgB,+BAA+B,GAAG;KAErD,AAAC,QAAQ,MAAc,OAAO;KAC/B,IAAI,CAAC,mBACF,AAAC,kBAA0B,OAAO;IAEvC;GACF,CAAC;EACH;EACA,IAAI,gBACD,AAAC,QAAgB,kCAAkC;CAExD,UACQ;EAGN,oBAAoB;CACtB;AACF"}
|
package/dist/package.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`7.
|
|
1
|
+
var e=`7.4.0`;export{e as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerInitialNavigationLifecycle as e}from"../runtime/navigationLifecycle.mjs";import{getActiveRouter as t}from"./instance.mjs";import{WEVU_INITIAL_NAVIGATION_TIMEOUT_MARKER as n}from"@weapp-core/constants";import{queueMicrotaskPolyfill as r}from"@wevu/web-apis";const i=1e4,a=/* @__PURE__ */ new WeakMap,o=/* @__PURE__ */ new WeakMap;function s(e){return Number.isFinite(e)&&e>0?Math.max(1,Math.trunc(e)):i}function c(e){return{route:typeof e.route==`string`?e.route:void 0,__route__:typeof e.__route__==`string`?e.__route__:void 0,options:e.options&&typeof e.options==`object`?{...e.options}:void 0}}function l(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))t[n]=Array.isArray(r)?[...r]:r;return t}function u(){let e=t();return e?a.get(e)?.timeoutMs??1e4:i}function d(e){return!!(e&&typeof e==`object`&&e.__wevuNavigationFailure)}function f(e,i,s={}){let f=o.get(e);if(f)return s.onComplete&&f.blocking&&f.subscribe(s.onComplete),s.start!==!1&&f.start(i),f.blocking?f.promise:void 0;let p=t(),m=p?a.get(p):void 0,h=m?.runner;if(!h)return;let g=m?.mode===`blocking`,_=c(e),v=l(i),y=`idle`,b,x=u(),S,C=/* @__PURE__ */ new Set,w=new Promise(e=>{S=e}),T=(e,t)=>{if(y!==`idle`&&y!==`running`)return;y=e,b!==void 0&&(clearTimeout(b),b=void 0);let n=[...C];C.clear(),h=void 0,_=void 0,v=void 0,S(t),r(()=>{if(y===`allowed`||y===`timed-out`)for(let e of n)e.active&&(e.callback(t),e.active=!1)})},E={promise:w,blocking:g,status:()=>y,subscribe(e){let t={callback:e,active:!0};return y!==`idle`&&y!==`running`?r(()=>{t.active&&(y===`allowed`||y===`timed-out`)&&(e(y===`allowed`||y===`timed-out`),t.active=!1)}):C.add(t),()=>{t.active=!1,C.delete(t)}},start(e){if(y!==`idle`)return;y=`running`,g&&(b=setTimeout(()=>{y===`running`&&(console.warn(`${n} initial navigation exceeded ${x}ms; mounting page`,_?.route??_?.__route__??``),T(`timed-out`,!0))},x));let t=_,r=l(e??v),i=h;if(h=void 0,!i||!t){T(`aborted`,!1);return}i(t,r,()=>y===`running`).then(e=>{let t=d(e);T(t?`aborted`:`allowed`,!t)},()=>{T(`aborted`,!1)})},cancel(){T(`cancelled`,!1)}};return o.set(e,E),s.onComplete&&g&&E.subscribe(s.onComplete),s.start!==!1&&E.start(i),g?w:void 0}function
|
|
1
|
+
import{registerInitialNavigationLifecycle as e}from"../runtime/navigationLifecycle.mjs";import{getActiveRouter as t}from"./instance.mjs";import{WEVU_INITIAL_NAVIGATION_TIMEOUT_MARKER as n}from"@weapp-core/constants";import{queueMicrotaskPolyfill as r}from"@wevu/web-apis";const i=1e4,a=/* @__PURE__ */ new WeakMap,o=/* @__PURE__ */ new WeakMap;function s(e){return Number.isFinite(e)&&e>0?Math.max(1,Math.trunc(e)):i}function c(e){return{route:typeof e.route==`string`?e.route:void 0,__route__:typeof e.__route__==`string`?e.__route__:void 0,options:e.options&&typeof e.options==`object`?{...e.options}:void 0}}function l(e){if(!e||typeof e!=`object`)return;let t={};for(let[n,r]of Object.entries(e))t[n]=Array.isArray(r)?[...r]:r;return t}function u(){let e=t();return e?a.get(e)?.timeoutMs??1e4:i}function d(e){return!!(e&&typeof e==`object`&&e.__wevuNavigationFailure)}function f(e){return o.get(e)?.promise}function p(e,i,s={}){let f=o.get(e);if(f)return s.onComplete&&f.blocking&&f.subscribe(s.onComplete),s.start!==!1&&f.start(i),f.blocking?f.promise:void 0;let p=t(),m=p?a.get(p):void 0,h=m?.runner;if(!h)return;let g=m?.mode===`blocking`,_=c(e),v=l(i),y=`idle`,b,x=u(),S,C=/* @__PURE__ */ new Set,w=new Promise(e=>{S=e}),T=(e,t)=>{if(y!==`idle`&&y!==`running`)return;y=e,b!==void 0&&(clearTimeout(b),b=void 0);let n=[...C];C.clear(),h=void 0,_=void 0,v=void 0,S(t),r(()=>{if(y===`allowed`||y===`timed-out`)for(let e of n)e.active&&(e.callback(t),e.active=!1)})},E={promise:w,blocking:g,status:()=>y,subscribe(e){let t={callback:e,active:!0};return y!==`idle`&&y!==`running`?r(()=>{t.active&&(y===`allowed`||y===`timed-out`)&&(e(y===`allowed`||y===`timed-out`),t.active=!1)}):C.add(t),()=>{t.active=!1,C.delete(t)}},start(e){if(y!==`idle`)return;y=`running`,g&&(b=setTimeout(()=>{y===`running`&&(console.warn(`${n} initial navigation exceeded ${x}ms; mounting page`,_?.route??_?.__route__??``),T(`timed-out`,!0))},x));let t=_,r=l(e??v),i=h;if(h=void 0,!i||!t){T(`aborted`,!1);return}i(t,r,()=>y===`running`).then(e=>{let t=d(e);T(t?`aborted`:`allowed`,!t)},()=>{T(`aborted`,!1)})},cancel(){T(`cancelled`,!1)}};return o.set(e,E),s.onComplete&&g&&E.subscribe(s.onComplete),s.start!==!1&&E.start(i),g?w:void 0}function m(e){o.get(e)?.cancel()}function h(t,n,r=i,o=`blocking`){e({ensure:p,cancel:m}),a.set(t,{runner:n,mode:o,timeoutMs:s(r)})}export{i as DEFAULT_INITIAL_NAVIGATION_TIMEOUT,m as cancelInitialNavigation,p as ensureInitialNavigation,f as getInitialNavigationPromise,u as getInitialNavigationTimeout,h as registerInitialNavigationRunner};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScrollRestorationHandle, ScrollRestorationRegistrationOptions, ScrollViewRestorationHandle } from "./types.mjs";
|
|
2
|
+
//#region src/router/scrollRestoration/adapters.d.ts
|
|
3
|
+
/** WebView 页面适配器;Skyline 没有隐式页面滚动容器。 */
|
|
4
|
+
export declare function usePageScrollRestoration(options?: ScrollRestorationRegistrationOptions): ScrollRestorationHandle;
|
|
5
|
+
/** 用属性控制 WebView/Skyline scroll-view,scroll 事件不产生 setData。 */
|
|
6
|
+
export declare function useScrollViewRestoration(options?: ScrollRestorationRegistrationOptions): ScrollViewRestorationHandle;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as e}from"../../reactivity/ref.mjs";import{getCurrentMiniProgramGlobalObject as t}from"../../runtime/platform/current.mjs";import{ensurePageHookOnInstance as n}from"../../runtime/hooks/pageScroll.mjs";import{addScrollHook as r}from"./host.mjs";import{resolveScrollController as i}from"./controller.mjs";import{getScrollSetupScope as a,registerScrollRestoration as o}from"./index.mjs";import{WEVU_PAGE_SCROLL_OBSERVERS_KEY as s,WEVU_PAGE_SCROLL_RESTORATION_OWNER_KEY as c}from"@weapp-core/constants";function l(e={}){let a=i(e.controller),l=t();if(typeof l?.pageScrollTo!=`function`)throw TypeError(`当前宿主不支持 pageScrollTo,请使用显式 scroll-view 适配器。`);let u=0,d,f=[];return o({...e,capture:()=>({top:u}),async restore(e,t){let n=a.transition;if(n&&n.page===d&&n.event.renderer===`skyline`)throw Error(`Skyline 不支持页面级滚动,请使用 useScrollViewRestoration()。`);t.isActive()&&await new Promise((t,n)=>{l.pageScrollTo({scrollTop:e?.top??0,duration:0,success:()=>t(),fail:n})})}},{onBindPage(e){d=e;let t=l[c]?.(d);typeof t==`function`&&f.push(t),f.push(r(d,s,e=>{e&&typeof e==`object`&&`scrollTop`in e&&typeof e.scrollTop==`number`&&(u=e.scrollTop)})),n(d,`onPageScroll`)},onStop(){for(let e of f)e();f.length=0}})}function u(t={}){let{commit:n}=a(),r=e(0),i=e(0),s=0,c=0;return{...o({...t,capture:()=>({top:s,left:c}),async restore(e,t){t.isActive()&&(r.value=s,i.value=c,await n(),t.isActive()&&(r.value=e?.top??0,i.value=e?.left??0,await n()))}}),scrollTop:r,scrollLeft:i,onScroll(e){s=e.detail.scrollTop,c=e.detail.scrollLeft}}}export{l as usePageScrollRestoration,u as useScrollViewRestoration};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../types.mjs";
|
|
2
|
+
import { ScrollRestorationController, ScrollRestorationOptions } from "./types.mjs";
|
|
3
|
+
import "./host.mjs";
|
|
4
|
+
//#region src/router/scrollRestoration/controller.d.ts
|
|
5
|
+
/** 创建显式启用的路由会话;不会安装全局默认滚动行为。 */
|
|
6
|
+
export declare function createScrollRestoration<TRouteMap extends object>(options: ScrollRestorationOptions<TRouteMap>): ScrollRestorationController;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCurrentMiniProgramPages as e}from"../../runtime/platform.mjs";import{resolvePageRoute as t}from"../../routerInternal/location.mjs";import{getActiveRouter as n}from"../instance.mjs";import{currentScrollPage as r,subscribeScrollRouteEvents as i,supportsScrollRouteEvents as a}from"./host.mjs";const o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new WeakMap;function c(n){if(s.has(n.router))throw Error(`该 router 已创建 scroll restoration 会话,请复用或先 dispose()。`);let c=n.router,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,d=new WeakSet(e()),f=n.onError??(e=>console.error(`[wevu/router] scroll restoration:`,e)),p=!1,m=0,h,g,_={automatic:a(),clear(e){e===void 0?l.clear():l.delete(e);for(let t of u.values())for(let n of t)(e===void 0||n.key===e)&&n.invalidate()},dispose(){if(!p){p=!0,m++,g?.();for(let e of u.values())for(let t of e)t.stop();u.clear(),l.clear(),h=void 0,s.delete(n.router),o.delete(_)}}},v={controller:_,get disposed(){return p},get transition(){return h},get generation(){return m},resolveRoute:e=>c.resolve(t(e)),register(e,t){if(p)throw Error(`scroll restoration 会话已 dispose()。`);let n=u.get(e);n||(n=/* @__PURE__ */ new Set,u.set(e,n));for(let e of n)if(e.key===t.key&&e.id===t.id)throw Error(`同一页面重复注册 scroll restoration key/id: ${t.key} / ${t.id}`);return n.add(t),()=>{n.delete(t),n.size===0&&u.delete(e)}},read:(e,t)=>l.get(e)?.get(t),save(e,t,n){if(p)return;if(n===null){v.clear(e,t);return}let r=l.get(e);r||(r=/* @__PURE__ */ new Map,l.set(e,r)),r.set(t,n)},clear(e,t){let n=l.get(e);n?.delete(t),n?.size===0&&l.delete(e);for(let n of u.values())for(let r of n)r.key===e&&r.id===t&&r.invalidate()},report:f};return _.automatic&&(g=i({BeforeAppRoute(e){if(p||h?.event.routeEventId===e.routeEventId)return;let t=r();if(t){d.add(t);for(let e of u.get(t)??[])e.capture()}m++;for(let e of u.values())for(let t of e)t.invalidate();h={event:e,fresh:!1,done:!1}},BeforePageUnload(e){let t=e.page;if(t){if(h?.event.routeEventId!==e.routeEventId&&t===r())for(let e of u.get(t)??[])e.capture();for(let e of u.get(t)??[])e.stop()}},AppRoute(e){if(p||h&&h.event.routeEventId!==e.routeEventId)return;let n=r();n&&t(n).path===e.path.replace(/^\/+/,``)&&(h??(h={event:e,fresh:!1,done:!1}),!h.page&&(h.page=n,h.fresh=!d.has(n),d.add(n)))},AppRouteDone(e){if(p||!h)return;let t=e.routeEventId===``&&h.fresh&&Number.isInteger(h.event.webviewId)&&e.webviewId===h.event.webviewId&&e.path===h.event.path&&typeof e.openType==`string`&&e.openType===h.event.openType;if((h.event.routeEventId===e.routeEventId||t)&&h.page&&h.page===r()&&!h.done){h.done=!0;for(let e of u.get(h.page)??[])e.restoreAutomatic()}}})),o.set(_,v),s.set(n.router,_),_}function l(e){let t=n(),r=e??(t&&s.get(t)),i=r&&o.get(r);if(!i||i.disposed)throw Error(`请先在应用启动时调用 createScrollRestoration({ router }),或传入有效的 controller。`);return i}export{c as createScrollRestoration,l as resolveScrollController};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCurrentMiniProgramGlobalObject as e}from"../../runtime/platform/current.mjs";import{getCurrentMiniProgramPages as t}from"../../runtime/platform.mjs";import{pushHook as n}from"../../runtime/hooks/base.mjs";import{WEVU_HOOKS_KEY as r,WEVU_NATIVE_INSTANCE_KEY as i,WEVU_ROUTE_EVENT_CONTRACT_KEY as a}from"@weapp-core/constants";const o=[`BeforeAppRoute`,`BeforePageUnload`,`AppRoute`,`AppRouteDone`];function s(t=e()){if(!t||!o.every(e=>typeof t[`on${e}`]==`function`&&typeof t[`off${e}`]==`function`))return!1;if(t[a]===1)return!0;let n=t.getAppBaseInfo?.().SDKVersion??t.getSystemInfoSync?.().SDKVersion;if(typeof n!=`string`)return!1;let r=/^(\d+)\.(\d+)\.(\d+)(?:\D|$)/.exec(n);if(!r)return!1;let i=Number(r[1]),s=Number(r[2]),c=Number(r[3]);return i>3||i===3&&(s>5||s===5&&c>=5)}function c(t){let n=e(),r=[];try{for(let e of o){let i=n=>{typeof n?.routeEventId==`string`&&typeof n.path==`string`&&t[e](n)};n[`on${e}`](i),r.push(()=>n[`off${e}`](i))}}catch(e){for(let e of r)e();throw e}return()=>{for(let e of r)e()}}function l(){let e=t();return e[e.length-1]}function u(e){let n=t(),r=/* @__PURE__ */ new Set,a=e;for(;a&&!r.has(a);){if(r.add(a),n.includes(a))return a;let e=a.__wxWebviewId__;if(e!==void 0){let t=n.find(t=>t.__wxWebviewId__===e);if(t)return t}let t=a[i]??a.$;a=t&&t!==a?t:a.selectOwnerComponent?.()}}function d(e,t,i){return n(e,t,i),()=>{let n=e[r],a=n?.[t];n&&Array.isArray(a)&&(n[t]=a.filter(e=>e!==i))}}export{d as addScrollHook,l as currentScrollPage,u as resolveScrollPage,c as subscribeScrollRouteEvents,s as supportsScrollRouteEvents};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ScrollRestorationContext, ScrollRestorationController, ScrollRestorationHandle, ScrollRestorationOptions, ScrollRestorationRegistrationOptions, ScrollViewRestorationHandle, UseScrollRestorationOptions } from "./types.mjs";
|
|
2
|
+
import "./host.mjs";
|
|
3
|
+
import { createScrollRestoration } from "./controller.mjs";
|
|
4
|
+
//#region src/router/scrollRestoration/index.d.ts
|
|
5
|
+
/** 在同步 setup 中注册快照;只恢复新实例,不覆盖原生保留页的位置。 */
|
|
6
|
+
export declare function useScrollRestoration<T extends object>(options: UseScrollRestorationOptions<T>): ScrollRestorationHandle;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type ScrollRestorationContext, type ScrollRestorationController, type ScrollRestorationHandle, type ScrollRestorationOptions, type ScrollRestorationRegistrationOptions, type ScrollViewRestorationHandle, type UseScrollRestorationOptions, createScrollRestoration };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{onScopeDispose as e}from"../../reactivity/core.mjs";import{assertInSetup as t,getCurrentSetupContext as n}from"../../runtime/hooks/base.mjs";import{getInitialNavigationPromise as r}from"../initialNavigation.mjs";import{addScrollHook as i,currentScrollPage as a,resolveScrollPage as o}from"./host.mjs";import{createScrollRestoration as s,resolveScrollController as c}from"./controller.mjs";import{WEVU_READY_CALLED_KEY as l}from"@weapp-core/constants";function u(){let e=t(`useScrollRestoration`),r=n()?.proxy;if(typeof r?.$nextTick!=`function`)throw TypeError(`scroll restoration 需要具有宿主提交屏障的 wevu setup 实例。`);return{instance:e,commit:()=>r.$nextTick()}}function d(t,n){let{instance:s,commit:d}=u(),f=c(t.controller),p=[],m,h,g=!1,_=!0,v=!1,y=!1,b=0,x=!!s[l],S=!1,C,w,T;function E(){(g||x&&S)&&w?.()}function D(){if(m||g)return;let e=o(s);if(!e)return;let r=f.resolveRoute(e);T.key=typeof t.key==`function`?t.key(r):t.key??r.fullPath;let a=f.register(e,T);m=e,h=r,p.push(a),S=!!e[l],p.push(i(e,`onReady`,()=>{S=!0,E(),T.restoreAutomatic()})),n?.onBindPage?.(e)}async function O(){if(g||f.disposed)return!1;if(D(),!m||!h)throw Error(`无法确定 scroll restoration 的原生归属页面,请在页面 attached 后恢复。`);if(!_||a()!==m)return!1;let e=++b,n=f.generation,i={route:h,routeEventId:f.transition?.page===m?f.transition.event.routeEventId:void 0,isActive:()=>!g&&!f.disposed&&_&&e===b&&n===f.generation&&a()===m};if((!x||!S)&&(C??(C=new Promise(e=>{w=e})),await C),!i.isActive()||await r(m)===!1||!i.isActive()||(await d(),!i.isActive()))return!1;let o=f.read(T.key,T.id);return await t.restore(o,i),i.isActive()}T={key:``,id:t.id??`default`,capture(){if(!(g||f.disposed||!m||!_||v)){v=!0;try{let e=t.capture();if(e!==null&&`then`in e&&typeof e.then==`function`)throw TypeError(`scroll restoration capture 必须同步返回快照,不能返回 Promise。`);f.save(T.key,T.id,e)}catch(e){f.clear(T.key,T.id),f.report(e)}}},invalidate(){b++,w?.(),C=void 0,w=void 0},restoreAutomatic(){let e=f.transition;!g&&!t.manual&&!y&&x&&S&&e?.fresh&&e.done&&e.page===m&&(y=!0,O().catch(f.report))},stop(){if(!g){g=!0,b++,E();for(let e of p)e();p.length=0,n?.onStop?.()}}};function k(){T.capture(),T.stop()}return p.push(i(s,`onAttached`,D),i(s,`onReady`,()=>{D(),x=!0,E(),T.restoreAutomatic()}),i(s,`onShow`,()=>{D(),_=!0,v=!1}),i(s,`onHide`,()=>{T.capture(),_=!1,T.invalidate()}),i(s,`onDetached`,k),i(s,`onUnload`,k)),e(k),D(),T.restoreAutomatic(),{automatic:f.controller.automatic&&!t.manual,scroll:O,clear:()=>{D(),m&&f.clear(T.key,T.id)},stop:T.stop}}function f(e){return d(e)}export{s as createScrollRestoration,u as getScrollSetupScope,d as registerScrollRestoration,f as useScrollRestoration};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Ref } from "../../reactivity/ref.mjs";
|
|
2
|
+
import "../../reactivity/index.mjs";
|
|
3
|
+
import { RouteLocationNormalizedLoaded, RouterNavigation } from "../types.mjs";
|
|
4
|
+
//#region src/router/scrollRestoration/types.d.ts
|
|
5
|
+
export interface ScrollRestorationController {
|
|
6
|
+
/** 当前宿主是否支持带 routeEventId 的自动路由关联。 */
|
|
7
|
+
readonly automatic: boolean;
|
|
8
|
+
/** 清除整个会话或指定路由 key 的快照,不注销组件。 */
|
|
9
|
+
clear: (key?: string) => void;
|
|
10
|
+
/** 注销宿主监听、组件注册和未完成的恢复,并清空会话。 */
|
|
11
|
+
dispose: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface ScrollRestorationOptions<TRouteMap extends object = object> {
|
|
14
|
+
router: RouterNavigation<TRouteMap>;
|
|
15
|
+
/** 自动捕获或恢复失败时调用;手动 scroll 的错误由调用者处理。 */
|
|
16
|
+
onError?: (error: unknown) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface ScrollRestorationContext {
|
|
19
|
+
readonly route: Readonly<RouteLocationNormalizedLoaded>;
|
|
20
|
+
readonly routeEventId?: string;
|
|
21
|
+
/** 异步自定义恢复在每次 await 后、写入宿主前必须重新检查。 */
|
|
22
|
+
isActive: () => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ScrollRestorationRegistrationOptions {
|
|
25
|
+
controller?: ScrollRestorationController;
|
|
26
|
+
/** 默认使用包含 query 的 route.fullPath。 */
|
|
27
|
+
key?: string | ((route: Readonly<RouteLocationNormalizedLoaded>) => string);
|
|
28
|
+
/** 同一页面和路由 key 内的独立容器名,默认为 default。 */
|
|
29
|
+
id?: string;
|
|
30
|
+
/** 只捕获,不在原生路由完成后自动恢复。 */
|
|
31
|
+
manual?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface UseScrollRestorationOptions<T extends object> extends ScrollRestorationRegistrationOptions {
|
|
34
|
+
/** 同步返回独立快照;不能返回响应式活动对象或 Promise,null 表示清除。 */
|
|
35
|
+
capture: () => (T & {
|
|
36
|
+
then?: never;
|
|
37
|
+
}) | null;
|
|
38
|
+
restore: (snapshot: T | undefined, context: ScrollRestorationContext) => void | Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export interface ScrollRestorationHandle {
|
|
41
|
+
readonly automatic: boolean;
|
|
42
|
+
/** 等待组件就绪及宿主提交后恢复;已离开或失效时返回 false。 */
|
|
43
|
+
scroll: () => Promise<boolean>;
|
|
44
|
+
/** 只清除当前 key/id 的快照。 */
|
|
45
|
+
clear: () => void;
|
|
46
|
+
/** 停止当前注册;保留已捕获快照。 */
|
|
47
|
+
stop: () => void;
|
|
48
|
+
}
|
|
49
|
+
export interface ScrollViewRestorationHandle extends ScrollRestorationHandle {
|
|
50
|
+
scrollTop: Ref<number>;
|
|
51
|
+
scrollLeft: Ref<number>;
|
|
52
|
+
/** 绑定 scroll-view 的 scroll 事件,只更新非响应式缓存。 */
|
|
53
|
+
onScroll: (event: {
|
|
54
|
+
detail: {
|
|
55
|
+
scrollTop: number;
|
|
56
|
+
scrollLeft: number;
|
|
57
|
+
};
|
|
58
|
+
}) => void;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
package/dist/router.d.mts
CHANGED
|
@@ -6,6 +6,10 @@ import { AddRoute, InitialNavigationMode, LocationQuery, LocationQueryRaw, Locat
|
|
|
6
6
|
import { createRouter } from "./router/createRouter.mjs";
|
|
7
7
|
import { createNavigationFailure, isNavigationFailure } from "./router/navigationCore.mjs";
|
|
8
8
|
import { resolveRouteLocation } from "./router/resolve.mjs";
|
|
9
|
+
import { ScrollRestorationContext, ScrollRestorationController, ScrollRestorationHandle, ScrollRestorationOptions, ScrollRestorationRegistrationOptions, ScrollViewRestorationHandle, UseScrollRestorationOptions } from "./router/scrollRestoration/types.mjs";
|
|
10
|
+
import { usePageScrollRestoration, useScrollViewRestoration } from "./router/scrollRestoration/adapters.mjs";
|
|
11
|
+
import { createScrollRestoration } from "./router/scrollRestoration/controller.mjs";
|
|
12
|
+
import { useScrollRestoration } from "./router/scrollRestoration/index.mjs";
|
|
9
13
|
import { UseRouteOptions, useNativePageRouter, useNativeRouter, useRoute } from "./router/useRoute.mjs";
|
|
10
14
|
import { useRouter } from "./router/useRouter.mjs";
|
|
11
15
|
import { StaticPageDeclaration, StaticPageDeclaration as StaticPageDeclaration$1, StaticRouteValue } from "@wevu/compiler/page-route";
|
|
@@ -22,4 +26,4 @@ export interface WevuNamedRouteMap {}
|
|
|
22
26
|
*/
|
|
23
27
|
export declare function definePage(route: StaticPageDeclaration$1): void;
|
|
24
28
|
//#endregion
|
|
25
|
-
export { type AddRoute, type InitialNavigationMode, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, type NamedRouteRecord, type NamedRoutes, type NavigationAfterEach, type NavigationAfterEachContext, type NavigationErrorContext, type NavigationErrorHandler, type NavigationFailure, NavigationFailureType, type NavigationFailureTypeValue, type NavigationGuard, type NavigationGuardContext, type NavigationGuardResult, type NavigationMode, type NavigationRedirect, type RouteLocationNamedRaw, type RouteLocationNormalizedByName, type RouteLocationNormalizedLoaded, type RouteLocationRaw, type RouteLocationRedirectedFrom, type RouteMeta, type RouteParamValue, type RouteParamValueRaw, type RouteParams, type RouteParamsMode, type RouteParamsRaw, type RouteQueryParser, type RouteQueryStringifier, type RouteRecordInput, type RouteRecordMatched, type RouteRecordRaw, type RouteRecordRedirect, type RouterNavigateToOption, type RouterNavigation, type RouterReLaunchOption, type RouterRedirectToOption, type RouterResolve, type RouterSwitchTabOption, type SetupContextRouter, type StaticPageDeclaration, type StaticRouteValue, type TypedRouterTabBarUrl, type TypedRouterUrl, type UseRouteOptions, type UseRouterOptions, type WevuAutoRoute, type WevuBroadRouteMap, type WevuNamedRouteDefinition, type WevuNamedRouteMeta, type WevuNamedRoutePath, type WevuRouteName, type WevuTypedRouterRouteMap, createNavigationFailure, createRouter, isNavigationFailure, parseQuery, resolveRouteLocation, stringifyQuery, useNativePageRouter, useNativeRouter, useRoute, useRouter };
|
|
29
|
+
export { type AddRoute, type InitialNavigationMode, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, type NamedRouteRecord, type NamedRoutes, type NavigationAfterEach, type NavigationAfterEachContext, type NavigationErrorContext, type NavigationErrorHandler, type NavigationFailure, NavigationFailureType, type NavigationFailureTypeValue, type NavigationGuard, type NavigationGuardContext, type NavigationGuardResult, type NavigationMode, type NavigationRedirect, type RouteLocationNamedRaw, type RouteLocationNormalizedByName, type RouteLocationNormalizedLoaded, type RouteLocationRaw, type RouteLocationRedirectedFrom, type RouteMeta, type RouteParamValue, type RouteParamValueRaw, type RouteParams, type RouteParamsMode, type RouteParamsRaw, type RouteQueryParser, type RouteQueryStringifier, type RouteRecordInput, type RouteRecordMatched, type RouteRecordRaw, type RouteRecordRedirect, type RouterNavigateToOption, type RouterNavigation, type RouterReLaunchOption, type RouterRedirectToOption, type RouterResolve, type RouterSwitchTabOption, type ScrollRestorationContext, type ScrollRestorationController, type ScrollRestorationHandle, type ScrollRestorationOptions, type ScrollRestorationRegistrationOptions, type ScrollViewRestorationHandle, type SetupContextRouter, type StaticPageDeclaration, type StaticRouteValue, type TypedRouterTabBarUrl, type TypedRouterUrl, type UseRouteOptions, type UseRouterOptions, type UseScrollRestorationOptions, type WevuAutoRoute, type WevuBroadRouteMap, type WevuNamedRouteDefinition, type WevuNamedRouteMeta, type WevuNamedRoutePath, type WevuRouteName, type WevuTypedRouterRouteMap, createNavigationFailure, createRouter, createScrollRestoration, isNavigationFailure, parseQuery, resolveRouteLocation, stringifyQuery, useNativePageRouter, useNativeRouter, usePageScrollRestoration, useRoute, useRouter, useScrollRestoration, useScrollViewRestoration };
|
package/dist/router.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseQuery as e,stringifyQuery as t}from"./routerInternal/query.mjs";import{NavigationFailureType as n}from"./router/types.mjs";import{createNavigationFailure as r,isNavigationFailure as i}from"./router/navigationCore.mjs";import{resolveRouteLocation as a}from"./router/resolve.mjs";import{useNativePageRouter as o,useNativeRouter as s,useRoute as c}from"./router/useRoute.mjs";import{createRouter as l}from"./router/createRouter.mjs";import{
|
|
1
|
+
import{parseQuery as e,stringifyQuery as t}from"./routerInternal/query.mjs";import{NavigationFailureType as n}from"./router/types.mjs";import{createNavigationFailure as r,isNavigationFailure as i}from"./router/navigationCore.mjs";import{resolveRouteLocation as a}from"./router/resolve.mjs";import{useNativePageRouter as o,useNativeRouter as s,useRoute as c}from"./router/useRoute.mjs";import{createRouter as l}from"./router/createRouter.mjs";import{createScrollRestoration as u}from"./router/scrollRestoration/controller.mjs";import{useScrollRestoration as d}from"./router/scrollRestoration/index.mjs";import{usePageScrollRestoration as f,useScrollViewRestoration as p}from"./router/scrollRestoration/adapters.mjs";import{useRouter as m}from"./router/useRouter.mjs";export{n as NavigationFailureType,r as createNavigationFailure,l as createRouter,u as createScrollRestoration,i as isNavigationFailure,e as parseQuery,a as resolveRouteLocation,t as stringifyQuery,o as useNativePageRouter,s as useNativeRouter,f as usePageScrollRestoration,c as useRoute,m as useRouter,d as useScrollRestoration,p as useScrollViewRestoration};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCurrentMiniProgramGlobalObject as e,getCurrentMiniProgramRuntimeCapabilities as t}from"../platform/current.mjs";import{getMiniProgramRuntimeGlobalObject as n,supportsCurrentMiniProgramRuntimeCapability as r}from"../platform.mjs";import{WEVU_CURRENT_SETUP_STATE_KEY as i,WEVU_HOOKS_KEY as a}from"@weapp-core/constants";const o=(()=>{let e=typeof globalThis<`u`?globalThis:n();return e?e[i]??(e[i]={}):{}})();function s(){return o.instance}function c(e){o.instance=e}function l(){return o.context}function u(e){o.context=e}function d(e){if(!o.instance)throw Error(`${e}() 必须在 setup() 的同步阶段调用`);return o.instance}function f(e){return e[a]||(e[a]=Object.create(null)),e[a]}function p(e,n){let r=t().shareTimelineRequiresShareAppMessage?e||n:e,i=[];return r&&i.push(`shareAppMessage`),n&&i.push(`shareTimeline`),i}function m(e,t){let n=[{withShareTicket:!0,menus:t},{menus:t},t.includes(`shareTimeline`)?{withShareTicket:!0}:void 0,t.includes(`shareTimeline`)?{}:void 0,void 0];for(let t of n)try{t===void 0?e():e(t);return}catch{}}function h(e,t,n,{single:r=!1}={}){let i=f(e);r?i[t]=n:(i[t]??(i[t]=[])).push(n)}function g(e,t){var n;let r=(n=e).__wevuShareHookBridges??(n.__wevuShareHookBridges=Object.create(null));if(typeof r[t]==`function`)return;let i=e[t],o=function(...e){let n=this[a]?.[t],r=this.__wevu?.proxy??this,o;if(typeof n==`function`)try{o=n.apply(r,e)}catch{o=void 0}else if(Array.isArray(n))for(let t of n)try{o=t.apply(r,e)}catch{}if(o!==void 0)return o;if(typeof i==`function`)return i.apply(this,e)};r[t]=o,e[t]=o}function _(t){if(!r(`pageShareMenu`))return;let n=e();if(!n||typeof n.showShareMenu!=`function`)return;let i=t[a]??{},o=typeof i.onShareAppMessage==`function`,s=typeof i.onShareTimeline==`function`;if(!o&&!s)return;let c=p(o,s);c.length&&m(n.showShareMenu.bind(n),c)}function v(e,t,n=[]){let r=e[a];if(!r)return;let i=r[t];if(!i)return;let o=e.__wevu?.proxy??e;if(Array.isArray(i))for(let e of i)try{e.apply(o,n)}catch{}else if(typeof i==`function`)try{i.apply(o,n)}catch{}}function y(e,t
|
|
1
|
+
import{getCurrentMiniProgramGlobalObject as e,getCurrentMiniProgramRuntimeCapabilities as t}from"../platform/current.mjs";import{getMiniProgramRuntimeGlobalObject as n,supportsCurrentMiniProgramRuntimeCapability as r}from"../platform.mjs";import{WEVU_CURRENT_SETUP_STATE_KEY as i,WEVU_HOOKS_KEY as a}from"@weapp-core/constants";const o=(()=>{let e=typeof globalThis<`u`?globalThis:n();return e?e[i]??(e[i]={}):{}})();function s(){return o.instance}function c(e){o.instance=e}function l(){return o.context}function u(e){o.context=e}function d(e){if(!o.instance)throw Error(`${e}() 必须在 setup() 的同步阶段调用`);return o.instance}function f(e){return e[a]||(e[a]=Object.create(null)),e[a]}function p(e,n){let r=t().shareTimelineRequiresShareAppMessage?e||n:e,i=[];return r&&i.push(`shareAppMessage`),n&&i.push(`shareTimeline`),i}function m(e,t){let n=[{withShareTicket:!0,menus:t},{menus:t},t.includes(`shareTimeline`)?{withShareTicket:!0}:void 0,t.includes(`shareTimeline`)?{}:void 0,void 0];for(let t of n)try{t===void 0?e():e(t);return}catch{}}function h(e,t,n,{single:r=!1}={}){let i=f(e);r?i[t]=n:(i[t]??(i[t]=[])).push(n)}function g(e,t){var n;let r=(n=e).__wevuShareHookBridges??(n.__wevuShareHookBridges=Object.create(null));if(typeof r[t]==`function`)return;let i=e[t],o=function(...e){let n=this[a]?.[t],r=this.__wevu?.proxy??this,o;if(typeof n==`function`)try{o=n.apply(r,e)}catch{o=void 0}else if(Array.isArray(n))for(let t of n)try{o=t.apply(r,e)}catch{}if(o!==void 0)return o;if(typeof i==`function`)return i.apply(this,e)};r[t]=o,e[t]=o}function _(t){if(!r(`pageShareMenu`))return;let n=e();if(!n||typeof n.showShareMenu!=`function`)return;let i=t[a]??{},o=typeof i.onShareAppMessage==`function`,s=typeof i.onShareTimeline==`function`;if(!o&&!s)return;let c=p(o,s);c.length&&m(n.showShareMenu.bind(n),c)}function v(e,t,n=[]){let r=e[a];if(!r)return;let i=r[t];if(!i)return;let o=e.__wevu?.proxy??e;if(Array.isArray(i))for(let e of i)try{e.apply(o,n)}catch{}else if(typeof i==`function`)try{i.apply(o,n)}catch{}}function y(e,t,n=[]){let r=e[a];if(!r)return;let i=r[t];if(!i)return;let o=e.__wevu?.proxy??e;if(typeof i==`function`)try{return i.apply(o,n)}catch{return}if(Array.isArray(i)){let e;for(let t of i)try{e=t.apply(o,n)}catch{}return e}}export{d as assertInSetup,v as callHookList,y as callHookReturn,_ as ensurePageShareMenusOnSetup,g as ensureSinglePageHookOnInstance,s as getCurrentInstance,l as getCurrentSetupContext,h as pushHook,c as setCurrentInstance,u as setCurrentSetupContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{callHookList as e}from"./base.mjs";import{WEVU_PAGE_HOOK_BRIDGES_KEY as t,WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY as n,WEVU_PAGE_SCROLL_OBSERVERS_KEY as r}from"@weapp-core/constants";function i(e,t){let r=e,i=Number(r[n]??0);r[n]=i+1;try{return t()}finally{i===0?delete r[n]:r[n]=i}}function a(t,a,o){let s=Number(t[n]??0)>0;return i(t,()=>(s||(e(t,r,a),e(t,`onPageScroll`,a)),o?.apply(t,a)))}function o(e,n){let r=e,i=r[t]??(r[t]={});if(typeof i[n]==`function`)return;let o=r[n],s=function(...e){return a(this,e,o)};i[n]=s,r[n]=s}export{a as callPageScrollHooks,o as ensurePageHookOnInstance,i as runInPageScrollHook};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertInSetup as e,
|
|
1
|
+
import{assertInSetup as e,ensurePageShareMenusOnSetup as t,ensureSinglePageHookOnInstance as n,pushHook as r}from"./base.mjs";import{ensurePageHookOnInstance as i}from"./pageScroll.mjs";function a(t,n,i){r(e(t),t,n,i)}function o(e){a(`onLaunch`,e)}function s(e){a(`onPageNotFound`,e)}function c(e){a(`onUnhandledRejection`,e)}function l(e){a(`onThemeChange`,e)}function u(e){a(`onMemoryWarning`,e)}function d(e){a(`onShow`,e)}function f(e){a(`onLoad`,e)}function p(e){a(`onHide`,e)}function m(e){a(`onUnload`,e)}function h(e){a(`onReady`,e)}function g(e){a(`onPullDownRefresh`,e)}function _(e){a(`onReachBottom`,e)}function v(t){let n=e(`onPageScroll`);r(n,`onPageScroll`,t),i(n,`onPageScroll`)}function y(e){a(`onRouteDone`,e)}function b(e){a(`onTabItemTap`,e)}function x(e){a(`onResize`,e)}function S(e){a(`onMoved`,e)}function C(e){a(`onAttached`,e)}function w(e){a(`onDetached`,e)}function T(e){a(`onError`,e)}function E(e){a(`onSaveExitState`,e,{single:!0})}function D(i){let a=e(`onShareAppMessage`);r(a,`onShareAppMessage`,i,{single:!0}),n(a,`onShareAppMessage`),t(a)}function O(i){let a=e(`onShareTimeline`);r(a,`onShareTimeline`,i,{single:!0}),n(a,`onShareTimeline`),t(a)}function k(t){let i=e(`onAddToFavorites`);r(i,`onAddToFavorites`,t,{single:!0}),n(i,`onAddToFavorites`)}export{k as onAddToFavorites,C as onAttached,w as onDetached,T as onError,p as onHide,o as onLaunch,f as onLoad,u as onMemoryWarning,S as onMoved,s as onPageNotFound,v as onPageScroll,g as onPullDownRefresh,_ as onReachBottom,h as onReady,x as onResize,y as onRouteDone,E as onSaveExitState,D as onShareAppMessage,O as onShareTimeline,d as onShow,b as onTabItemTap,l as onThemeChange,c as onUnhandledRejection,m as onUnload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callHookList as e,callHookReturn as t}from"../../../hooks/base.mjs";import{
|
|
1
|
+
import{callHookList as e,callHookReturn as t}from"../../../hooks/base.mjs";import{callPageScrollHooks as n}from"../../../hooks/pageScroll.mjs";import{WEVU_ROUTE_DONE_CALLED_KEY as r,WEVU_ROUTE_DONE_IN_TICK_KEY as i}from"@weapp-core/constants";function a(a,o){let{enableOnSaveExitState:s,enableOnPullDownRefresh:c,enableOnReachBottom:l,enableOnPageScroll:u,enableOnRouteDone:d,enableOnTabItemTap:f,enableOnResize:p,enableOnShareAppMessage:m,enableOnShareTimeline:h,enableOnAddToFavorites:g,effectiveOnSaveExitState:_,effectiveOnPullDownRefresh:v,effectiveOnReachBottom:y,effectiveOnPageScroll:b,effectiveOnRouteDone:x,effectiveOnTabItemTap:S,effectiveOnResize:C,effectiveOnShareAppMessage:w,effectiveOnShareTimeline:T,effectiveOnAddToFavorites:E,hasHook:D}=o;s&&(a.onSaveExitState=function(...e){let n=t(this,`onSaveExitState`,e);return n===void 0?_.apply(this,e):n}),c&&(a.onPullDownRefresh=function(...t){if(e(this,`onPullDownRefresh`,t),!D(this,`onPullDownRefresh`))return v.apply(this,t)}),l&&(a.onReachBottom=function(...t){if(e(this,`onReachBottom`,t),!D(this,`onReachBottom`))return y.apply(this,t)}),u&&(a.onPageScroll=function(...e){return n(this,e,D(this,`onPageScroll`)?void 0:b)}),d&&(a.onRouteDone=function(...t){if(!this[i]&&(this[i]=!0,Promise.resolve().then(()=>{this[i]=!1}),this[r]=!0,e(this,`onRouteDone`,t),!D(this,`onRouteDone`)))return x.apply(this,t)}),f&&(a.onTabItemTap=function(...t){if(e(this,`onTabItemTap`,t),!D(this,`onTabItemTap`))return S.apply(this,t)}),p&&(a.onResize=function(...t){if(e(this,`onResize`,t),!D(this,`onResize`))return C.apply(this,t)}),m&&(a.onShareAppMessage=function(...e){let n=t(this,`onShareAppMessage`,e);return n===void 0?w.apply(this,e):n}),h&&(a.onShareTimeline=function(...e){let n=t(this,`onShareTimeline`,e);return n===void 0?T.apply(this,e):n}),g&&(a.onAddToFavorites=function(...e){let n=t(this,`onAddToFavorites`,e);return n===void 0?E.apply(this,e):n})}export{a as attachOptionalPageLifecycleHooks};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCurrentMiniProgramGlobalObject as e,getCurrentMiniProgramRuntimeCapabilities as t}from"../../../platform/current.mjs";import{getCurrentMiniProgramPages as n,supportsCurrentMiniProgramRuntimeCapability as r}from"../../../platform.mjs";import{callHookList as i}from"../../../hooks/base.mjs";import{
|
|
1
|
+
import{getCurrentMiniProgramGlobalObject as e,getCurrentMiniProgramRuntimeCapabilities as t}from"../../../platform/current.mjs";import{getCurrentMiniProgramPages as n,supportsCurrentMiniProgramRuntimeCapability as r}from"../../../platform.mjs";import{callHookList as i}from"../../../hooks/base.mjs";import{runInPageScrollHook as a}from"../../../hooks/pageScroll.mjs";import{WEVU_PAGE_SCROLL_EVENT_CONTRACT_KEY as o}from"@weapp-core/constants";let s=!1,c;function l(){return c}function u(e){c=e}function d(e){c===e&&(c=void 0)}function f(e){let t=e.options;if(t&&typeof t==`object`)return t;let r=n(),i=r[r.length-1],a=i&&typeof i==`object`?i.options:void 0;return a&&typeof a==`object`?a:{}}function p(){if(s)return;s=!0;let t=e();if(t&&typeof t==`object`){if(r(`pullDownRefreshApi`)){let e=t.startPullDownRefresh;typeof e==`function`&&(t.startPullDownRefresh=function(...t){let n=e.apply(this,t);return c&&i(c,`onPullDownRefresh`,[]),n})}if(r(`pageScrollApi`)&&t[o]!==1){let e=t.pageScrollTo;typeof e==`function`&&(t.pageScrollTo=function(t,...n){let r=c,o=e.apply(this,[t,...n]);return r&&a(r,()=>{i(r,`onPageScroll`,[t??{}])}),o})}}}function m(n){let{enableOnShareAppMessage:i,enableOnShareTimeline:a}=n;if(!i&&!a||!r(`pageShareMenu`))return;let o=e();if(!o||typeof o.showShareMenu!=`function`)return;let s=t().shareTimelineRequiresShareAppMessage?i||a:i;if(!s&&!a)return;let c=[];s&&c.push(`shareAppMessage`),a&&c.push(`shareTimeline`);let l=[{withShareTicket:!0,menus:c},{menus:c},a?{withShareTicket:!0}:void 0,a?{}:void 0,void 0];for(let e of l)try{e===void 0?o.showShareMenu():o.showShareMenu(e);break}catch{}}export{u as bindCurrentPageInstance,p as ensureMiniProgramGlobalPatched,m as ensurePageShareMenus,l as getCurrentPageInstance,d as releaseCurrentPageInstance,f as resolvePageOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getMiniProgramRuntimeGlobalObject as e}from"../../platform.mjs";import{callHookList as t}from"../../hooks/base.mjs";import{requireRuntimeCapability as n,runtimeCapabilityRegistry as r}from"../../capabilities.mjs";import{runTeardownSteps as i}from"../../teardown.mjs";import{enableDeferredSetData as a,mountRuntimeInstance as o,refreshRuntimeInstance as s,setRuntimeSetDataVisibility as c,teardownRuntimeInstance as l}from"../runtimeInstance.mjs";import{ensureInitialNavigation as u}from"../../navigationLifecycle.mjs";import{registerNativeComponentDefinition as d}from"./registerNativeDefinition.mjs";import{WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY as f,WEVU_PUBLIC_RUNTIME_KEY as p,WEVU_READY_CALLED_KEY as m,WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD as h,WEVU_RUNTIME_KEY as g}from"@weapp-core/constants";function _(_){let{runtimeApp:v,watch:y,setup:b,restOptions:x,pageLifecycleHooks:S,finalObservers:
|
|
1
|
+
import{getMiniProgramRuntimeGlobalObject as e}from"../../platform.mjs";import{callHookList as t}from"../../hooks/base.mjs";import{requireRuntimeCapability as n,runtimeCapabilityRegistry as r}from"../../capabilities.mjs";import{runTeardownSteps as i}from"../../teardown.mjs";import{enableDeferredSetData as a,mountRuntimeInstance as o,refreshRuntimeInstance as s,setRuntimeSetDataVisibility as c,teardownRuntimeInstance as l}from"../runtimeInstance.mjs";import{ensureInitialNavigation as u}from"../../navigationLifecycle.mjs";import{registerNativeComponentDefinition as d}from"./registerNativeDefinition.mjs";import{WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY as f,WEVU_PUBLIC_RUNTIME_KEY as p,WEVU_READY_CALLED_KEY as m,WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD as h,WEVU_RUNTIME_KEY as g}from"@weapp-core/constants";function _(_){let{runtimeApp:v,watch:y,setup:b,restOptions:x,pageLifecycleHooks:S,finalObservers:C,userLifetimes:w,userPageLifetimes:T,finalMethods:E,finalOptions:D,applyExtraInstanceFields:O,templateRefs:k,layoutHosts:A,attachWevuPropKeys:j,setupLifecycle:M,syncWevuPropsFromInstance:N,directPropsDerivedKeys:P,isPage:F,vueLifecycles:I,getRuntimeOwnerLabel:L,registerNative:R=!0}=_,z=Array.isArray(k)&&k.length>0?k:void 0,B=/* @__PURE__ */ new WeakSet;z&&n(`templateRefs`,`registerComponentDefinition(template refs)`);let V=Array.isArray(A)&&A.length>0?A:void 0,H=V?n(`layout`,`registerComponentDefinition(layout hosts)`):void 0,ee=(e,t)=>{if(z){r.templateRefs?.schedule(e,t);return}t?.()},U=e=>{let t=e.__wevu??e[p];if(t)return t;let n=e.$state;if(n&&typeof n==`object`)return n[g]},W=e=>U(e)?.proxy||(r.scopedSlots?.resolveLifecycleProxy(e)??e),G=e=>{let t=U(e);return t?{runtime:t,mounted:!1}:(O(e),j(e),o(e,v,y,b,{deferSetData:!0,snapshotOmitKeys:P}),N(e),a(e),{runtime:U(e),mounted:!0})},K=(e,t,n)=>{let r=I[t];if(typeof r==`function`)return r.apply(W(e),n)},q=(e,t)=>{if(!F){t();return}u(e,void 0,{start:!1,onComplete:e=>{e&&t()}})||t()},J=e=>{U(e)||typeof I.mounted!=`function`||G(e).mounted&&(K(e,`created`,[]),K(e,`beforeMount`,[]))},Y={},X=e=>{V&&H?.attachHosts(V,e)},Z=e=>{F&&H&&H?.attachPageSetter(e)};if(F)for(let e of[`onPageScroll`,`onPullDownRefresh`,`onReachBottom`,`onShareAppMessage`,`onShareTimeline`,`onAddToFavorites`]){let t=S[e];typeof t==`function`&&typeof E[e]!=`function`&&(Y[e]=function(...e){return t.apply(this,e)})}let Q={...x,...F?S:{},observers:C,lifetimes:{...w,created:function(...e){B.add(this),O(this),j(this),z&&r.templateRefs?.attachBindings(this,z),q(this,()=>{if(K(this,`beforeCreate`,e),M===`created`){try{o(this,v,y,b,{deferSetData:!0,snapshotOmitKeys:P})}catch(e){let t=L(this);throw Error(`[wevu] mount runtime failed in created (${t}): ${e instanceof Error?e.message:String(e)}`)}N(this),Z(this)}typeof w.created==`function`&&w.created.apply(this,e)})},moved:function(...e){t(this,`onMoved`,e),typeof w.moved==`function`&&w.moved.apply(this,e)},attached:function(...e){B.delete(this),O(this),j(this),z&&!r.templateRefs?.hasBindings(this)&&r.templateRefs?.attachBindings(this,z),q(this,()=>{if(M!==`created`||!this.__wevu)try{o(this,v,y,b,{deferSetData:!0,snapshotOmitKeys:P})}catch(e){let t=L(this);throw Error(`[wevu] mount runtime failed in attached (${t}): ${e instanceof Error?e.message:String(e)}`)}N(this),K(this,`created`,e),K(this,`beforeMount`,e),Z(this),X(this),a(this),t(this,`onAttached`,e),typeof w.attached==`function`&&w.attached.apply(this,e)})},ready:function(...e){if(B.has(this))return w.ready?.apply(this,e);if(!F||this[m]||!u(this,void 0,{start:!0,onComplete:t=>{t&&!this.__wevuInitialNavigationReady&&(this.__wevuInitialNavigationReady=!0,Q.lifetimes.ready.call(this,...e))}})||this.__wevuInitialNavigationReady){if(J(this),F&&typeof S.onReady==`function`){let t=!!this[m];if(S.onReady.call(this,...e),!t){let t=()=>K(this,`mounted`,e);u(this,void 0,{start:!1,onComplete:e=>{e&&t()}})||t()}typeof w.ready==`function`&&w.ready.apply(this,e);return}if(!this[m]){this[m]=!0,N(this),r.templateRefs?.scheduleOwner(this),ee(this,()=>{t(this,`onReady`,e),K(this,`mounted`,e),typeof w.ready==`function`&&w.ready.apply(this,e)});return}typeof w.ready==`function`&&w.ready.apply(this,e)}},detached:function(...e){if(F&&typeof S.onUnload==`function`){i([()=>K(this,`beforeUnmount`,e),()=>K(this,`beforeDestroy`,e),()=>r.templateRefs?.scheduleOwner(this),()=>t(this,`onDetached`,e),()=>S.onUnload.call(this,...e),()=>{typeof w.detached==`function`&&w.detached.apply(this,e)},()=>K(this,`unmounted`,e),()=>K(this,`destroyed`,e)]);return}i([()=>K(this,`beforeUnmount`,e),()=>K(this,`beforeDestroy`,e),()=>r.templateRefs?.scheduleOwner(this),()=>t(this,`onDetached`,e),()=>{V&&H?.detachHosts(V,this)},()=>l(this),()=>K(this,`unmounted`,e),()=>K(this,`destroyed`,e),()=>{typeof w.detached==`function`&&w.detached.apply(this,e)}])},error:function(...e){t(this,`onError`,e),typeof w.error==`function`&&w.error.apply(this,e)}},pageLifetimes:{...T,show:function(...e){if(F&&typeof S.onShow==`function`){S.onShow.call(this,...e),typeof T.show==`function`&&T.show.apply(this,e);return}c(this,!0),t(this,`onShow`,e),typeof T.show==`function`&&T.show.apply(this,e)},hide:function(...e){if(F&&typeof S.onHide==`function`){S.onHide.call(this,...e),typeof T.hide==`function`&&T.hide.apply(this,e);return}c(this,!1),t(this,`onHide`,e),typeof T.hide==`function`&&T.hide.apply(this,e)},resize:function(...e){if(F&&typeof S.onResize==`function`){S.onResize.call(this,...e),typeof T.resize==`function`&&T.resize.apply(this,e);return}t(this,`onResize`,e),typeof T.resize==`function`&&T.resize.apply(this,e)},routeDone:function(...e){if(F&&typeof S.onRouteDone==`function`){S.onRouteDone.call(this,...e),typeof T.routeDone==`function`&&T.routeDone.apply(this,e);return}t(this,`onRouteDone`,e),typeof T.routeDone==`function`&&T.routeDone.apply(this,e)}},methods:{...Y,...E,[h]:function(){let e=G(this);return e.mounted&&(K(this,`created`,[]),K(this,`beforeMount`,[])),e.runtime?.proxy}},options:D};if(!R)return Q;let $=e()?.[f];if(typeof $?.trackWevuComponent==`function`){let e=$.trackWevuComponent(Q,(e,t)=>{s(e,v,y,b,{snapshotOmitKeys:P,stateSnapshot:t}),N(e),Z(e),X(e),a(e,{rehydrateSetupState:!0})},e=>{i([()=>V&&H?.detachHosts(V,e),()=>l(e,{skipHooks:!0})])});return $.isApplying()||d(e,F),e}return d(Q,F),Q}export{_ as registerComponentDefinition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{effectScope as e}from"../../../reactivity/core.mjs";import{toRaw as t}from"../../../reactivity/reactive/shared.mjs";import{shallowReactive as n}from"../../../reactivity/reactive/shallow.mjs";import{isReactive as r}from"../../../reactivity/reactive.mjs";import{getCurrentInstance as i,getCurrentSetupContext as a,setCurrentInstance as o,setCurrentSetupContext as s}from"../../hooks/base.mjs";import{hasOwn as c}from"../../../utils.mjs";import{hasTrackableSetupBinding as l}from"../../setupTracking.mjs";import{normalizeEmitEventName as u,normalizeEmitPayload as d}from"../../emit.mjs";import{attachRuntimeSlots as f,ensureSetupContextInstance as p,safeMarkNoSetData as m}from"./setupContext.mjs";import{preserveSetupAccessor as h}from"../../define/setupResult.mjs";import{runSetupFunction as g}from"../setup.mjs";import{attachRuntimeSetupState as _,ensureRuntimeProps as v}from"./utils.mjs";import{WEVU_ATTRS_KEY as y,WEVU_EFFECT_SCOPE_KEY as b,WEVU_EXPOSED_KEY as x,WEVU_PROP_KEYS_KEY as S}from"@weapp-core/constants";let C=0;function w(e,t){let n=e,
|
|
1
|
+
import{effectScope as e}from"../../../reactivity/core.mjs";import{toRaw as t}from"../../../reactivity/reactive/shared.mjs";import{shallowReactive as n}from"../../../reactivity/reactive/shallow.mjs";import{isReactive as r}from"../../../reactivity/reactive.mjs";import{getCurrentInstance as i,getCurrentSetupContext as a,setCurrentInstance as o,setCurrentSetupContext as s}from"../../hooks/base.mjs";import{hasOwn as c}from"../../../utils.mjs";import{hasTrackableSetupBinding as l}from"../../setupTracking.mjs";import{normalizeEmitEventName as u,normalizeEmitPayload as d}from"../../emit.mjs";import{attachRuntimeSlots as f,ensureSetupContextInstance as p,safeMarkNoSetData as m}from"./setupContext.mjs";import{preserveSetupAccessor as h}from"../../define/setupResult.mjs";import{runSetupFunction as g}from"../setup.mjs";import{attachRuntimeSetupState as _,ensureRuntimeProps as v}from"./utils.mjs";import{WEVU_ATTRS_KEY as y,WEVU_EFFECT_SCOPE_KEY as b,WEVU_EXPOSED_KEY as x,WEVU_PROP_KEYS_KEY as S}from"@weapp-core/constants";let C=0;function w(e,t){let n,r=e,i={proxy:{configurable:!0,enumerable:!1,value:t,writable:!1},$:{configurable:!0,enumerable:!1,value:e,writable:!1},uid:{configurable:!0,enumerable:!1,value:++C,writable:!1},exposed:{configurable:!0,enumerable:!1,get:()=>n}};for(let[e,t]of Object.entries(i))try{Object.defineProperty(r,e,t)}catch{`value`in t&&(r[e]=t.value)}let a={$:{configurable:!0,enumerable:!1,value:e,writable:!1},$el:{configurable:!0,enumerable:!1,value:e,writable:!1}};for(let[e,n]of Object.entries(a))try{Object.defineProperty(t,e,n)}catch{t[e]=n.value}return e=>{n=e}}function T(e){return e.startsWith(`__wv_`)}function E(C){let{target:E,runtime:D,runtimeWithDefaults:O,runtimeState:k,runtimeProxy:A,setup:j}=C,M=E.properties||{},N=v(E,k,M),P=n(Object.create(null)),F=new Set(Array.isArray(E[S])?E[S]:[]),I=e=>typeof k==`object`&&!!k&&c(k,e);(()=>{let e=E.properties&&typeof E.properties==`object`?E.properties:void 0;for(let t of Object.keys(P))(!e||!c(e,t)||T(t)||F.has(t)||I(t))&&delete P[t];if(e)for(let[t,n]of Object.entries(e))T(t)||F.has(t)||I(t)||(P[t]=n)})();try{Object.defineProperty(E,y,{value:P,configurable:!0,enumerable:!1,writable:!1})}catch{E[y]=P}let L=p(E,O),R=w(E,L),z=f(k,N),B=O.setupState??Object.create(null);_(k,B);let V=m({props:N,runtime:O,state:k,proxy:A,bindModel:D.bindModel.bind(O),watch:D.watch.bind(O),instance:L,emit:(e,...t)=>{let{detail:n,options:r}=d(t),i=u(e);L.triggerEvent(i,n,r)},expose:e=>{E[x]=e,R(e)},attrs:P,slots:z}),H=e(!0),U=i(),W=a(),G=()=>{i()===E&&a()===V&&(s(W),o(U))};E[b]=H,o(E),s(V);try{let e=H.run(()=>g(j,N,V)),n=!1;if(e&&typeof e==`object`){let i=e,a=D.setupState&&typeof D.setupState==`object`?r(D.setupState)?t(D.setupState):D.setupState:Object.create(null);Object.keys(i).forEach(e=>{let t=i[e],r=h(a,i,e);if(typeof t==`function`&&!r){let r=(...e)=>t.apply(D.proxy,e);D.methods[e]=r,D.state[e]=r,a[e]=r,n=!0}else l(t)&&D.__wevu_trackSetupReactiveKey?.(e),D.state[e]=t,r||(a[e]=t)})}n&&D.__wevu_touchSetupMethodsVersion?.()}finally{G()}}export{E as runRuntimeSetupPhase};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wevu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.4.0",
|
|
5
5
|
"description": "Vue 3 风格的小程序运行时,包含响应式、diff+setData 与轻量状态管理",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -291,12 +291,12 @@
|
|
|
291
291
|
}
|
|
292
292
|
},
|
|
293
293
|
"dependencies": {
|
|
294
|
-
"@weapp-core/constants": "0.
|
|
295
|
-
"@weapp-core/shared": "3.2.
|
|
296
|
-
"@weapp-core/types": "1.1.
|
|
297
|
-
"@wevu/api": "0.3.
|
|
298
|
-
"@wevu/compiler": "7.
|
|
299
|
-
"@wevu/web-apis": "1.3.
|
|
294
|
+
"@weapp-core/constants": "0.3.0",
|
|
295
|
+
"@weapp-core/shared": "3.2.7",
|
|
296
|
+
"@weapp-core/types": "1.1.5",
|
|
297
|
+
"@wevu/api": "0.3.7",
|
|
298
|
+
"@wevu/compiler": "7.4.0",
|
|
299
|
+
"@wevu/web-apis": "1.3.4",
|
|
300
300
|
"vue": "^3.5.43"
|
|
301
301
|
},
|
|
302
302
|
"devDependencies": {
|