wevu 7.1.2 → 7.1.4

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.
Files changed (89) hide show
  1. package/dist/dev/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.mjs +1 -1
  2. package/dist/dev/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.mjs +1 -1
  3. package/dist/dev/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.mjs +1 -1
  4. package/dist/dev/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.mjs +1 -1
  5. package/dist/dev/macros/shared.d.mts +2 -0
  6. package/dist/dev/package.mjs +1 -1
  7. package/dist/dev/reactivity/core.mjs +1 -1
  8. package/dist/dev/reactivity/ref.mjs +1 -1
  9. package/dist/dev/runtime/define/setupResult.mjs +31 -3
  10. package/dist/dev/runtime/define/setupResult.mjs.map +1 -1
  11. package/dist/dev/runtime/define.mjs +4 -5
  12. package/dist/dev/runtime/define.mjs.map +1 -1
  13. package/dist/dev/runtime/hooks/base.mjs +11 -8
  14. package/dist/dev/runtime/hooks/base.mjs.map +1 -1
  15. package/dist/dev/runtime/platform.mjs +1 -1
  16. package/dist/dev/runtime/platform.mjs.map +1 -1
  17. package/dist/dev/runtime/register/component/registerDefinition.mjs +7 -0
  18. package/dist/dev/runtime/register/component/registerDefinition.mjs.map +1 -1
  19. package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs +16 -7
  20. package/dist/dev/runtime/register/runtimeInstance/setupPhase.mjs.map +1 -1
  21. package/dist/dev/runtime/types/options.d.mts +6 -4
  22. package/dist/dev/store/define.d.mts +1 -10
  23. package/dist/dev/store/define.mjs.map +1 -1
  24. package/dist/dev/store/types.d.mts +12 -2
  25. package/dist/macros/shared.d.mts +2 -0
  26. package/dist/package.mjs +1 -1
  27. package/dist/reactivity/core.mjs +1 -1
  28. package/dist/reactivity/reactive/mutation.mjs +1 -1
  29. package/dist/reactivity/reactive/patch.mjs +1 -1
  30. package/dist/reactivity/reactive/patchState.mjs +1 -1
  31. package/dist/reactivity/reactive/state.mjs +1 -1
  32. package/dist/reactivity/reactive.mjs +1 -1
  33. package/dist/reactivity/ref.mjs +1 -1
  34. package/dist/reactivity/traverse.mjs +1 -1
  35. package/dist/router/createRouter.mjs +1 -1
  36. package/dist/router/initialNavigation.mjs +1 -1
  37. package/dist/router/routeSync.mjs +1 -1
  38. package/dist/routerInternal/matching.mjs +1 -1
  39. package/dist/routerInternal/params.mjs +1 -1
  40. package/dist/routerInternal/records.mjs +1 -1
  41. package/dist/routerInternal/recordsWarnings.mjs +1 -1
  42. package/dist/runtime/app/computed.mjs +1 -1
  43. package/dist/runtime/app/context.mjs +1 -1
  44. package/dist/runtime/app/mount.mjs +1 -1
  45. package/dist/runtime/app/setData/commitTracker.mjs +1 -1
  46. package/dist/runtime/app/setData/patchScheduler.mjs +1 -1
  47. package/dist/runtime/app/setData/payload.mjs +1 -1
  48. package/dist/runtime/app/setData/scheduler.mjs +1 -1
  49. package/dist/runtime/app/setData/snapshot.mjs +1 -1
  50. package/dist/runtime/app.mjs +1 -1
  51. package/dist/runtime/bindingManifest.mjs +1 -1
  52. package/dist/runtime/define/initialComputed.mjs +1 -1
  53. package/dist/runtime/define/options.mjs +1 -1
  54. package/dist/runtime/define/props.mjs +1 -1
  55. package/dist/runtime/define/scopedSlotOptions.mjs +1 -1
  56. package/dist/runtime/define/setupResult.mjs +1 -1
  57. package/dist/runtime/define.mjs +1 -1
  58. package/dist/runtime/diff.mjs +1 -1
  59. package/dist/runtime/disposables.mjs +1 -1
  60. package/dist/runtime/features/patchStrategy.mjs +1 -1
  61. package/dist/runtime/hooks/base.mjs +1 -1
  62. package/dist/runtime/layoutBridge.mjs +1 -1
  63. package/dist/runtime/platform.mjs +1 -1
  64. package/dist/runtime/provideStore.mjs +1 -1
  65. package/dist/runtime/register/component/options.mjs +1 -1
  66. package/dist/runtime/register/component/props.mjs +1 -1
  67. package/dist/runtime/register/component/registerDefinition.mjs +1 -1
  68. package/dist/runtime/register/runtimeInstance/setupPhase.mjs +1 -1
  69. package/dist/runtime/register/runtimeInstance.mjs +1 -1
  70. package/dist/runtime/scopedSlots.mjs +1 -1
  71. package/dist/runtime/setupTracking.mjs +1 -1
  72. package/dist/runtime/templateRefs/helpers.mjs +1 -1
  73. package/dist/runtime/templateRefs.mjs +1 -1
  74. package/dist/runtime/types/options.d.mts +6 -4
  75. package/dist/runtime/uniAppHost.mjs +1 -1
  76. package/dist/runtime/vueCompat/model.mjs +1 -1
  77. package/dist/runtime/vueCompat/router.mjs +1 -1
  78. package/dist/runtime/vueCompat/templateRef.mjs +1 -1
  79. package/dist/scheduler.mjs +1 -1
  80. package/dist/store/base.mjs +1 -1
  81. package/dist/store/define/setupStyle.mjs +1 -1
  82. package/dist/store/define.d.mts +1 -10
  83. package/dist/store/manager.mjs +1 -1
  84. package/dist/store/types.d.mts +12 -2
  85. package/package.json +8 -8
  86. /package/dist/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.mjs +0 -0
  87. /package/dist/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.mjs +0 -0
  88. /package/dist/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.mjs +0 -0
  89. /package/dist/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"registerDefinition.mjs","names":[],"sources":["../../../../../src/runtime/register/component/registerDefinition.ts"],"sourcesContent":["import type { LayoutHostBinding, TemplateRefBinding } from '../../capabilities'\nimport type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeApp,\n} from '../../types'\nimport type { WatchMap } from '../watch'\nimport {\n WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY,\n WEVU_PUBLIC_RUNTIME_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport {\n ensureInitialNavigation,\n} from '../../../router/initialNavigation'\nimport { requireRuntimeCapability, runtimeCapabilityRegistry } from '../../capabilities'\nimport { callHookList } from '../../hooks'\nimport { getMiniProgramRuntimeGlobalObject } from '../../platform'\nimport { runTeardownSteps } from '../../teardown'\nimport { enableDeferredSetData, mountRuntimeInstance, refreshRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { registerNativeComponentDefinition } from './registerNativeDefinition'\n\nexport function registerComponentDefinition<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n restOptions: Record<string, any>\n pageLifecycleHooks: Record<string, any>\n finalObservers: Record<string, any>\n userLifetimes: Record<string, any>\n userPageLifetimes: Record<string, any>\n finalMethods: Record<string, (...args: any[]) => any>\n finalOptions: Record<string, any>\n applyExtraInstanceFields: (instance: InternalRuntimeState) => void\n templateRefs: TemplateRefBinding[] | undefined\n layoutHosts: LayoutHostBinding[] | undefined\n attachWevuPropKeys: (instance: InternalRuntimeState) => void\n setupLifecycle: 'created' | 'attached'\n syncWevuPropsFromInstance: (instance: InternalRuntimeState) => void\n syncWevuPropsFromValues: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n directPropsDerivedKeys: string[]\n isPage: boolean\n vueLifecycles: Record<string, unknown>\n getRuntimeOwnerLabel: (instance: InternalRuntimeState) => string\n registerNative?: boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n restOptions,\n pageLifecycleHooks,\n finalObservers,\n userLifetimes,\n userPageLifetimes,\n finalMethods,\n finalOptions,\n applyExtraInstanceFields,\n templateRefs,\n layoutHosts,\n attachWevuPropKeys,\n setupLifecycle,\n syncWevuPropsFromInstance,\n directPropsDerivedKeys,\n isPage,\n vueLifecycles,\n getRuntimeOwnerLabel,\n registerNative = true,\n } = options\n const activeTemplateRefs = Array.isArray(templateRefs) && templateRefs.length > 0\n ? templateRefs\n : undefined\n if (activeTemplateRefs) {\n requireRuntimeCapability('templateRefs', 'registerComponentDefinition(template refs)')\n }\n const activeLayoutHosts = Array.isArray(layoutHosts) && layoutHosts.length > 0\n ? layoutHosts\n : undefined\n const layoutHooks = activeLayoutHosts\n ? requireRuntimeCapability('layout', 'registerComponentDefinition(layout hosts)')\n : undefined\n\n const scheduleTemplateRefs = (instance: InternalRuntimeState, onResolved?: () => void) => {\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.schedule(instance, onResolved)\n return\n }\n onResolved?.()\n }\n\n const resolveRuntime = (instance: InternalRuntimeState) => {\n const directRuntime = (instance as any).__wevu ?? (instance as any)[WEVU_PUBLIC_RUNTIME_KEY]\n if (directRuntime) {\n return directRuntime\n }\n const runtimeState = (instance as any).$state\n if (runtimeState && typeof runtimeState === 'object') {\n return (runtimeState as any)[WEVU_RUNTIME_KEY]\n }\n return undefined\n }\n\n const resolveLifecycleContext = (instance: InternalRuntimeState) => {\n const runtimeProxy = resolveRuntime(instance)?.proxy\n if (runtimeProxy) {\n return runtimeProxy\n }\n return runtimeCapabilityRegistry.scopedSlots?.resolveLifecycleProxy(instance) ?? instance\n }\n\n const mountMissingRuntime = (instance: InternalRuntimeState) => {\n const existing = resolveRuntime(instance)\n if (existing) {\n return { runtime: existing, mounted: false }\n }\n applyExtraInstanceFields(instance)\n attachWevuPropKeys(instance)\n mountRuntimeInstance(instance, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n syncWevuPropsFromInstance(instance)\n enableDeferredSetData(instance)\n return { runtime: resolveRuntime(instance), mounted: true }\n }\n\n const callVueLifecycle = (instance: InternalRuntimeState, name: string, args: any[]) => {\n const hook = vueLifecycles[name]\n if (typeof hook === 'function') {\n return hook.apply(resolveLifecycleContext(instance), args)\n }\n return undefined\n }\n\n const deferPageUntilNavigation = (instance: InternalRuntimeState, task: () => void) => {\n if (!isPage) {\n task()\n return\n }\n const initialNavigationPromise = ensureInitialNavigation(instance as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n task()\n }\n },\n })\n if (!initialNavigationPromise) {\n task()\n }\n }\n\n const ensureReadyRuntime = (instance: InternalRuntimeState) => {\n if (resolveRuntime(instance) || typeof vueLifecycles.mounted !== 'function') {\n return\n }\n const result = mountMissingRuntime(instance)\n if (result.mounted) {\n callVueLifecycle(instance, 'created', [])\n callVueLifecycle(instance, 'beforeMount', [])\n }\n }\n\n const pageMethodBridges: Record<string, (...args: any[]) => any> = {}\n const attachRuntimeLayoutHosts = (instance: InternalRuntimeState) => {\n if (activeLayoutHosts) {\n layoutHooks?.attachHosts(activeLayoutHosts, instance)\n }\n }\n const attachPageLayoutSetter = (instance: InternalRuntimeState) => {\n if (isPage && layoutHooks) {\n layoutHooks?.attachPageSetter(instance)\n }\n }\n if (isPage) {\n const methodBridgeHookNames = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites']\n for (const hookName of methodBridgeHookNames) {\n const pageHook = (pageLifecycleHooks as any)[hookName]\n if (typeof pageHook !== 'function') {\n continue\n }\n if (typeof (finalMethods as any)[hookName] === 'function') {\n continue\n }\n pageMethodBridges[hookName] = function pageMethodBridge(this: InternalRuntimeState, ...args: any[]) {\n return pageHook.apply(this, args)\n }\n }\n }\n\n const componentDefinition = {\n ...restOptions,\n ...(isPage ? pageLifecycleHooks : {}),\n observers: finalObservers,\n lifetimes: {\n ...userLifetimes,\n created: function created(this: InternalRuntimeState, ...args: any[]) {\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n const runCreated = () => {\n callVueLifecycle(this, 'beforeCreate', args)\n if (setupLifecycle === 'created') {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in created (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n syncWevuPropsFromInstance(this)\n attachPageLayoutSetter(this)\n }\n if (typeof (userLifetimes as any).created === 'function') {\n ;(userLifetimes as any).created.apply(this, args)\n }\n }\n deferPageUntilNavigation(this, runCreated)\n },\n moved: function moved(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onMoved', args)\n if (typeof (userLifetimes as any).moved === 'function') {\n ;(userLifetimes as any).moved.apply(this, args)\n }\n },\n attached: function attached(this: InternalRuntimeState, ...args: any[]) {\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs && !runtimeCapabilityRegistry.templateRefs?.hasBindings(this)) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n deferPageUntilNavigation(this, () => {\n if (setupLifecycle !== 'created' || !(this as any).__wevu) {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in attached (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n syncWevuPropsFromInstance(this)\n callVueLifecycle(this, 'created', args)\n callVueLifecycle(this, 'beforeMount', args)\n attachPageLayoutSetter(this)\n attachRuntimeLayoutHosts(this)\n enableDeferredSetData(this)\n callHookList(this, 'onAttached', args)\n if (typeof (userLifetimes as any).attached === 'function') {\n ;(userLifetimes as any).attached.apply(this, args)\n }\n })\n },\n ready: function ready(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && !(this as any)[WEVU_READY_CALLED_KEY]) {\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: true,\n onComplete: (shouldMount) => {\n if (shouldMount && !(this as any).__wevuInitialNavigationReady) {\n ;(this as any).__wevuInitialNavigationReady = true\n componentDefinition.lifetimes.ready.call(this, ...args)\n }\n },\n })\n if (initialNavigationPromise && !(this as any).__wevuInitialNavigationReady) {\n return\n }\n }\n ensureReadyRuntime(this)\n if (isPage && typeof (pageLifecycleHooks as any).onReady === 'function') {\n const wasReadyCalled = Boolean((this as any)[WEVU_READY_CALLED_KEY])\n ;(pageLifecycleHooks as any).onReady.call(this, ...args)\n if (!wasReadyCalled) {\n const callMounted = () => callVueLifecycle(this, 'mounted', args)\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n callMounted()\n }\n },\n })\n if (!initialNavigationPromise) {\n callMounted()\n }\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n return\n }\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n syncWevuPropsFromInstance(this)\n runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this)\n scheduleTemplateRefs(this, () => {\n callHookList(this, 'onReady', args)\n callVueLifecycle(this, 'mounted', args)\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n })\n return\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n },\n detached: function detached(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onUnload === 'function') {\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => (pageLifecycleHooks as any).onUnload.call(this, ...args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n ])\n return\n }\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => {\n if (activeLayoutHosts) {\n layoutHooks?.detachHosts(activeLayoutHosts, this)\n }\n },\n () => teardownRuntimeInstance(this),\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n ])\n },\n error: function error(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onError', args)\n if (typeof (userLifetimes as any).error === 'function') {\n ;(userLifetimes as any).error.apply(this, args)\n }\n },\n },\n pageLifetimes: {\n ...userPageLifetimes,\n show: function show(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onShow === 'function') {\n ;(pageLifecycleHooks as any).onShow.call(this, ...args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, true)\n callHookList(this, 'onShow', args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n },\n hide: function hide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onHide === 'function') {\n ;(pageLifecycleHooks as any).onHide.call(this, ...args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n },\n resize: function resize(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onResize === 'function') {\n ;(pageLifecycleHooks as any).onResize.call(this, ...args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n return\n }\n callHookList(this, 'onResize', args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n },\n routeDone: function routeDone(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onRouteDone === 'function') {\n ;(pageLifecycleHooks as any).onRouteDone.call(this, ...args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n return\n }\n callHookList(this, 'onRouteDone', args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n },\n },\n methods: {\n ...pageMethodBridges,\n ...finalMethods,\n [WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD]: function resolvePublicInstance(this: InternalRuntimeState) {\n const result = mountMissingRuntime(this)\n if (result.mounted) {\n callVueLifecycle(this, 'created', [])\n callVueLifecycle(this, 'beforeMount', [])\n }\n return result.runtime?.proxy\n },\n },\n options: finalOptions,\n }\n if (!registerNative) {\n return componentDefinition\n }\n\n const statefulHmrBridge = getMiniProgramRuntimeGlobalObject()?.[WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY]\n if (typeof statefulHmrBridge?.trackWevuComponent === 'function') {\n const definition = statefulHmrBridge.trackWevuComponent(componentDefinition, (\n instance: InternalRuntimeState,\n stateSnapshot?: Record<string, any>,\n ) => {\n refreshRuntimeInstance(instance, runtimeApp, watch, setup, {\n snapshotOmitKeys: directPropsDerivedKeys,\n stateSnapshot,\n })\n syncWevuPropsFromInstance(instance)\n attachPageLayoutSetter(instance)\n attachRuntimeLayoutHosts(instance)\n enableDeferredSetData(instance, { rehydrateSetupState: true })\n })\n if (!statefulHmrBridge.isApplying()) {\n registerNativeComponentDefinition(definition, isPage)\n }\n return definition\n }\n registerNativeComponentDefinition(componentDefinition, isPage)\n return componentDefinition\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,4BAA0G,SAuBvH;;CACD,MAAM,EACJ,YACA,OACA,OACA,aACA,oBACA,gBACA,eACA,mBACA,cACA,cACA,0BACA,cACA,aACA,oBACA,gBACA,2BACA,wBACA,QACA,eACA,sBACA,iBAAiB,SACf;CACJ,MAAM,qBAAqB,MAAM,QAAQ,YAAY,KAAK,aAAa,SAAS,IAC5E,eACA;CACJ,IAAI,oBACF,yBAAyB,gBAAgB,4CAA4C;CAEvF,MAAM,oBAAoB,MAAM,QAAQ,WAAW,KAAK,YAAY,SAAS,IACzE,cACA;CACJ,MAAM,cAAc,oBAChB,yBAAyB,UAAU,2CAA2C,IAC9E;CAEJ,MAAM,wBAAwB,UAAgC,eAA4B;EACxF,IAAI,oBAAoB;;GACtB,mDAA0B,oFAAc,SAAS,UAAU,UAAU;GACrE;EACF;EACA,2DAAa;CACf;CAEA,MAAM,kBAAkB,aAAmC;;EACzD,MAAM,yBAAiB,SAAiB,+CAAW,SAAiB;EACpE,IAAI,eACF,OAAO;EAET,MAAM,eAAgB,SAAiB;EACvC,IAAI,gBAAgB,OAAO,iBAAiB,UAC1C,OAAQ,aAAqB;CAGjC;CAEA,MAAM,2BAA2B,aAAmC;;EAClE,MAAM,kCAAe,eAAe,QAAQ,qEAAG;EAC/C,IAAI,cACF,OAAO;EAET,2DAAO,0BAA0B,6FAAa,sBAAsB,QAAQ,4EAAK;CACnF;CAEA,MAAM,uBAAuB,aAAmC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A0B,WAAW,YAC9C,AAAC,kBAA0B,OAAO,MAAM,MAAM,IAAI;GAEvD;GACA,WAAW,SAAS,UAAsC,GAAG,MAAa;IACxE,IAAI,UAAU,OAAQ,mBAA2B,gBAAgB,YAAY;KAC1E,AAAC,mBAA2B,YAAY,KAAK,MAAM,GAAG,IAAI;KAC3D,IAAI,OAAQ,kBAA0B,cAAc,YACjD,AAAC,kBAA0B,UAAU,MAAM,MAAM,IAAI;KAExD;IACF;IACA,aAAa,MAAM,eAAe,IAAI;IACtC,IAAI,OAAQ,kBAA0B,cAAc,YACjD,AAAC,kBAA0B,UAAU,MAAM,MAAM,IAAI;GAE1D;EACF;EACA,SAAS;GACP,GAAG;GACH,GAAG;GACH,CAAC,sCAAsC,SAAS,wBAAkD;;IAChG,MAAM,SAAS,oBAAoB,IAAI;IACvC,IAAI,OAAO,SAAS;KAClB,iBAAiB,MAAM,WAAW,CAAC,CAAC;KACpC,iBAAiB,MAAM,eAAe,CAAC,CAAC;IAC1C;IACA,0BAAO,OAAO,2EAAS;GACzB;EACF;EACA,SAAS;CACX;CACA,IAAI,CAAC,gBACH,OAAO;CAGT,MAAM,6CAAoB,kCAAkC,iFAAI;CAChE,IAAI,8EAAO,kBAAmB,wBAAuB,YAAY;EAC/D,MAAM,aAAa,kBAAkB,mBAAmB,sBACtD,UACA,kBACG;GACH,uBAAuB,UAAU,YAAY,OAAO,OAAO;IACzD,kBAAkB;IAClB;GACF,CAAC;GACD,0BAA0B,QAAQ;GAClC,uBAAuB,QAAQ;GAC/B,yBAAyB,QAAQ;GACjC,sBAAsB,UAAU,EAAE,qBAAqB,KAAK,CAAC;EAC/D,CAAC;EACD,IAAI,CAAC,kBAAkB,WAAW,GAChC,kCAAkC,YAAY,MAAM;EAEtD,OAAO;CACT;CACA,kCAAkC,qBAAqB,MAAM;CAC7D,OAAO;AACT"}
1
+ {"version":3,"file":"registerDefinition.mjs","names":[],"sources":["../../../../../src/runtime/register/component/registerDefinition.ts"],"sourcesContent":["import type { LayoutHostBinding, TemplateRefBinding } from '../../capabilities'\nimport type {\n ComponentPropsOptions,\n ComputedDefinitions,\n DefineComponentOptions,\n InternalRuntimeState,\n MethodDefinitions,\n RuntimeApp,\n} from '../../types'\nimport type { WatchMap } from '../watch'\nimport {\n WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY,\n WEVU_PUBLIC_RUNTIME_KEY,\n WEVU_READY_CALLED_KEY,\n WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD,\n WEVU_RUNTIME_KEY,\n} from '@weapp-core/constants'\nimport {\n ensureInitialNavigation,\n} from '../../../router/initialNavigation'\nimport { requireRuntimeCapability, runtimeCapabilityRegistry } from '../../capabilities'\nimport { callHookList } from '../../hooks'\nimport { getMiniProgramRuntimeGlobalObject } from '../../platform'\nimport { runTeardownSteps } from '../../teardown'\nimport { enableDeferredSetData, mountRuntimeInstance, refreshRuntimeInstance, setRuntimeSetDataVisibility, teardownRuntimeInstance } from '../runtimeInstance'\nimport { registerNativeComponentDefinition } from './registerNativeDefinition'\n\nexport function registerComponentDefinition<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: {\n runtimeApp: RuntimeApp<D, C, M>\n watch: WatchMap | undefined\n setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']\n restOptions: Record<string, any>\n pageLifecycleHooks: Record<string, any>\n finalObservers: Record<string, any>\n userLifetimes: Record<string, any>\n userPageLifetimes: Record<string, any>\n finalMethods: Record<string, (...args: any[]) => any>\n finalOptions: Record<string, any>\n applyExtraInstanceFields: (instance: InternalRuntimeState) => void\n templateRefs: TemplateRefBinding[] | undefined\n layoutHosts: LayoutHostBinding[] | undefined\n attachWevuPropKeys: (instance: InternalRuntimeState) => void\n setupLifecycle: 'created' | 'attached'\n syncWevuPropsFromInstance: (instance: InternalRuntimeState) => void\n syncWevuPropsFromValues: (instance: InternalRuntimeState, values: Record<string, unknown> | undefined) => void\n directPropsDerivedKeys: string[]\n isPage: boolean\n vueLifecycles: Record<string, unknown>\n getRuntimeOwnerLabel: (instance: InternalRuntimeState) => string\n registerNative?: boolean\n}) {\n const {\n runtimeApp,\n watch,\n setup,\n restOptions,\n pageLifecycleHooks,\n finalObservers,\n userLifetimes,\n userPageLifetimes,\n finalMethods,\n finalOptions,\n applyExtraInstanceFields,\n templateRefs,\n layoutHosts,\n attachWevuPropKeys,\n setupLifecycle,\n syncWevuPropsFromInstance,\n directPropsDerivedKeys,\n isPage,\n vueLifecycles,\n getRuntimeOwnerLabel,\n registerNative = true,\n } = options\n const activeTemplateRefs = Array.isArray(templateRefs) && templateRefs.length > 0\n ? templateRefs\n : undefined\n const pendingAttachment = new WeakSet<InternalRuntimeState>()\n if (activeTemplateRefs) {\n requireRuntimeCapability('templateRefs', 'registerComponentDefinition(template refs)')\n }\n const activeLayoutHosts = Array.isArray(layoutHosts) && layoutHosts.length > 0\n ? layoutHosts\n : undefined\n const layoutHooks = activeLayoutHosts\n ? requireRuntimeCapability('layout', 'registerComponentDefinition(layout hosts)')\n : undefined\n\n const scheduleTemplateRefs = (instance: InternalRuntimeState, onResolved?: () => void) => {\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.schedule(instance, onResolved)\n return\n }\n onResolved?.()\n }\n\n const resolveRuntime = (instance: InternalRuntimeState) => {\n const directRuntime = (instance as any).__wevu ?? (instance as any)[WEVU_PUBLIC_RUNTIME_KEY]\n if (directRuntime) {\n return directRuntime\n }\n const runtimeState = (instance as any).$state\n if (runtimeState && typeof runtimeState === 'object') {\n return (runtimeState as any)[WEVU_RUNTIME_KEY]\n }\n return undefined\n }\n\n const resolveLifecycleContext = (instance: InternalRuntimeState) => {\n const runtimeProxy = resolveRuntime(instance)?.proxy\n if (runtimeProxy) {\n return runtimeProxy\n }\n return runtimeCapabilityRegistry.scopedSlots?.resolveLifecycleProxy(instance) ?? instance\n }\n\n const mountMissingRuntime = (instance: InternalRuntimeState) => {\n const existing = resolveRuntime(instance)\n if (existing) {\n return { runtime: existing, mounted: false }\n }\n applyExtraInstanceFields(instance)\n attachWevuPropKeys(instance)\n mountRuntimeInstance(instance, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n syncWevuPropsFromInstance(instance)\n enableDeferredSetData(instance)\n return { runtime: resolveRuntime(instance), mounted: true }\n }\n\n const callVueLifecycle = (instance: InternalRuntimeState, name: string, args: any[]) => {\n const hook = vueLifecycles[name]\n if (typeof hook === 'function') {\n return hook.apply(resolveLifecycleContext(instance), args)\n }\n return undefined\n }\n\n const deferPageUntilNavigation = (instance: InternalRuntimeState, task: () => void) => {\n if (!isPage) {\n task()\n return\n }\n const initialNavigationPromise = ensureInitialNavigation(instance as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n task()\n }\n },\n })\n if (!initialNavigationPromise) {\n task()\n }\n }\n\n const ensureReadyRuntime = (instance: InternalRuntimeState) => {\n if (resolveRuntime(instance) || typeof vueLifecycles.mounted !== 'function') {\n return\n }\n const result = mountMissingRuntime(instance)\n if (result.mounted) {\n callVueLifecycle(instance, 'created', [])\n callVueLifecycle(instance, 'beforeMount', [])\n }\n }\n\n const pageMethodBridges: Record<string, (...args: any[]) => any> = {}\n const attachRuntimeLayoutHosts = (instance: InternalRuntimeState) => {\n if (activeLayoutHosts) {\n layoutHooks?.attachHosts(activeLayoutHosts, instance)\n }\n }\n const attachPageLayoutSetter = (instance: InternalRuntimeState) => {\n if (isPage && layoutHooks) {\n layoutHooks?.attachPageSetter(instance)\n }\n }\n if (isPage) {\n const methodBridgeHookNames = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites']\n for (const hookName of methodBridgeHookNames) {\n const pageHook = (pageLifecycleHooks as any)[hookName]\n if (typeof pageHook !== 'function') {\n continue\n }\n if (typeof (finalMethods as any)[hookName] === 'function') {\n continue\n }\n pageMethodBridges[hookName] = function pageMethodBridge(this: InternalRuntimeState, ...args: any[]) {\n return pageHook.apply(this, args)\n }\n }\n }\n\n const componentDefinition = {\n ...restOptions,\n ...(isPage ? pageLifecycleHooks : {}),\n observers: finalObservers,\n lifetimes: {\n ...userLifetimes,\n created: function created(this: InternalRuntimeState, ...args: any[]) {\n pendingAttachment.add(this)\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n const runCreated = () => {\n callVueLifecycle(this, 'beforeCreate', args)\n if (setupLifecycle === 'created') {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in created (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n syncWevuPropsFromInstance(this)\n attachPageLayoutSetter(this)\n }\n if (typeof (userLifetimes as any).created === 'function') {\n ;(userLifetimes as any).created.apply(this, args)\n }\n }\n deferPageUntilNavigation(this, runCreated)\n },\n moved: function moved(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onMoved', args)\n if (typeof (userLifetimes as any).moved === 'function') {\n ;(userLifetimes as any).moved.apply(this, args)\n }\n },\n attached: function attached(this: InternalRuntimeState, ...args: any[]) {\n pendingAttachment.delete(this)\n applyExtraInstanceFields(this)\n attachWevuPropKeys(this)\n if (activeTemplateRefs && !runtimeCapabilityRegistry.templateRefs?.hasBindings(this)) {\n runtimeCapabilityRegistry.templateRefs?.attachBindings(this, activeTemplateRefs)\n }\n deferPageUntilNavigation(this, () => {\n if (setupLifecycle !== 'created' || !(this as any).__wevu) {\n try {\n mountRuntimeInstance(this, runtimeApp, watch, setup, {\n deferSetData: true,\n snapshotOmitKeys: directPropsDerivedKeys,\n })\n }\n catch (error) {\n const label = getRuntimeOwnerLabel(this)\n throw new Error(`[wevu] mount runtime failed in attached (${label}): ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n syncWevuPropsFromInstance(this)\n callVueLifecycle(this, 'created', args)\n callVueLifecycle(this, 'beforeMount', args)\n attachPageLayoutSetter(this)\n attachRuntimeLayoutHosts(this)\n enableDeferredSetData(this)\n callHookList(this, 'onAttached', args)\n if (typeof (userLifetimes as any).attached === 'function') {\n ;(userLifetimes as any).attached.apply(this, args)\n }\n })\n },\n ready: function ready(this: InternalRuntimeState, ...args: any[]) {\n // 微信可能向初始条件分支中已被替换、从未 attached 的实例发送 ready。\n // 此时保留原生回调,不得将它当作已挂载实例的 wrapper 丢失而补挂载。\n if (pendingAttachment.has(this)) {\n return userLifetimes.ready?.apply(this, args)\n }\n if (isPage && !(this as any)[WEVU_READY_CALLED_KEY]) {\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: true,\n onComplete: (shouldMount) => {\n if (shouldMount && !(this as any).__wevuInitialNavigationReady) {\n ;(this as any).__wevuInitialNavigationReady = true\n componentDefinition.lifetimes.ready.call(this, ...args)\n }\n },\n })\n if (initialNavigationPromise && !(this as any).__wevuInitialNavigationReady) {\n return\n }\n }\n ensureReadyRuntime(this)\n if (isPage && typeof (pageLifecycleHooks as any).onReady === 'function') {\n const wasReadyCalled = Boolean((this as any)[WEVU_READY_CALLED_KEY])\n ;(pageLifecycleHooks as any).onReady.call(this, ...args)\n if (!wasReadyCalled) {\n const callMounted = () => callVueLifecycle(this, 'mounted', args)\n const initialNavigationPromise = ensureInitialNavigation(this as any, undefined, {\n start: false,\n onComplete: (shouldMount) => {\n if (shouldMount) {\n callMounted()\n }\n },\n })\n if (!initialNavigationPromise) {\n callMounted()\n }\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n return\n }\n if (!(this as any)[WEVU_READY_CALLED_KEY]) {\n ;(this as any)[WEVU_READY_CALLED_KEY] = true\n syncWevuPropsFromInstance(this)\n runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this)\n scheduleTemplateRefs(this, () => {\n callHookList(this, 'onReady', args)\n callVueLifecycle(this, 'mounted', args)\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n })\n return\n }\n if (typeof (userLifetimes as any).ready === 'function') {\n ;(userLifetimes as any).ready.apply(this, args)\n }\n },\n detached: function detached(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onUnload === 'function') {\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => (pageLifecycleHooks as any).onUnload.call(this, ...args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n ])\n return\n }\n runTeardownSteps([\n () => callVueLifecycle(this, 'beforeUnmount', args),\n () => callVueLifecycle(this, 'beforeDestroy', args),\n () => runtimeCapabilityRegistry.templateRefs?.scheduleOwner(this),\n () => callHookList(this, 'onDetached', args),\n () => {\n if (activeLayoutHosts) {\n layoutHooks?.detachHosts(activeLayoutHosts, this)\n }\n },\n () => teardownRuntimeInstance(this),\n () => callVueLifecycle(this, 'unmounted', args),\n () => callVueLifecycle(this, 'destroyed', args),\n () => {\n if (typeof (userLifetimes as any).detached === 'function') {\n ;(userLifetimes as any).detached.apply(this, args)\n }\n },\n ])\n },\n error: function error(this: InternalRuntimeState, ...args: any[]) {\n callHookList(this, 'onError', args)\n if (typeof (userLifetimes as any).error === 'function') {\n ;(userLifetimes as any).error.apply(this, args)\n }\n },\n },\n pageLifetimes: {\n ...userPageLifetimes,\n show: function show(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onShow === 'function') {\n ;(pageLifecycleHooks as any).onShow.call(this, ...args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, true)\n callHookList(this, 'onShow', args)\n if (typeof (userPageLifetimes as any).show === 'function') {\n ;(userPageLifetimes as any).show.apply(this, args)\n }\n },\n hide: function hide(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onHide === 'function') {\n ;(pageLifecycleHooks as any).onHide.call(this, ...args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n return\n }\n setRuntimeSetDataVisibility(this, false)\n callHookList(this, 'onHide', args)\n if (typeof (userPageLifetimes as any).hide === 'function') {\n ;(userPageLifetimes as any).hide.apply(this, args)\n }\n },\n resize: function resize(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onResize === 'function') {\n ;(pageLifecycleHooks as any).onResize.call(this, ...args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n return\n }\n callHookList(this, 'onResize', args)\n if (typeof (userPageLifetimes as any).resize === 'function') {\n ;(userPageLifetimes as any).resize.apply(this, args)\n }\n },\n routeDone: function routeDone(this: InternalRuntimeState, ...args: any[]) {\n if (isPage && typeof (pageLifecycleHooks as any).onRouteDone === 'function') {\n ;(pageLifecycleHooks as any).onRouteDone.call(this, ...args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n return\n }\n callHookList(this, 'onRouteDone', args)\n if (typeof (userPageLifetimes as any).routeDone === 'function') {\n ;(userPageLifetimes as any).routeDone.apply(this, args)\n }\n },\n },\n methods: {\n ...pageMethodBridges,\n ...finalMethods,\n [WEVU_RESOLVE_PUBLIC_INSTANCE_METHOD]: function resolvePublicInstance(this: InternalRuntimeState) {\n const result = mountMissingRuntime(this)\n if (result.mounted) {\n callVueLifecycle(this, 'created', [])\n callVueLifecycle(this, 'beforeMount', [])\n }\n return result.runtime?.proxy\n },\n },\n options: finalOptions,\n }\n if (!registerNative) {\n return componentDefinition\n }\n\n const statefulHmrBridge = getMiniProgramRuntimeGlobalObject()?.[WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY]\n if (typeof statefulHmrBridge?.trackWevuComponent === 'function') {\n const definition = statefulHmrBridge.trackWevuComponent(componentDefinition, (\n instance: InternalRuntimeState,\n stateSnapshot?: Record<string, any>,\n ) => {\n refreshRuntimeInstance(instance, runtimeApp, watch, setup, {\n snapshotOmitKeys: directPropsDerivedKeys,\n stateSnapshot,\n })\n syncWevuPropsFromInstance(instance)\n attachPageLayoutSetter(instance)\n attachRuntimeLayoutHosts(instance)\n enableDeferredSetData(instance, { rehydrateSetupState: true })\n })\n if (!statefulHmrBridge.isApplying()) {\n registerNativeComponentDefinition(definition, isPage)\n }\n return definition\n }\n registerNativeComponentDefinition(componentDefinition, isPage)\n return componentDefinition\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,4BAA0G,SAuBvH;;CACD,MAAM,EACJ,YACA,OACA,OACA,aACA,oBACA,gBACA,eACA,mBACA,cACA,cACA,0BACA,cACA,aACA,oBACA,gBACA,2BACA,wBACA,QACA,eACA,sBACA,iBAAiB,SACf;CACJ,MAAM,qBAAqB,MAAM,QAAQ,YAAY,KAAK,aAAa,SAAS,IAC5E,eACA;CACJ,MAAM,oCAAoB,IAAI,QAA8B;CAC5D,IAAI,oBACF,yBAAyB,gBAAgB,4CAA4C;CAEvF,MAAM,oBAAoB,MAAM,QAAQ,WAAW,KAAK,YAAY,SAAS,IACzE,cACA;CACJ,MAAM,cAAc,oBAChB,yBAAyB,UAAU,2CAA2C,IAC9E;CAEJ,MAAM,wBAAwB,UAAgC,eAA4B;EACxF,IAAI,oBAAoB;;GACtB,mDAA0B,oFAAc,SAAS,UAAU,UAAU;GACrE;EACF;EACA,2DAAa;CACf;CAEA,MAAM,kBAAkB,aAAmC;;EACzD,MAAM,yBAAiB,S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EAC/D,MAAM,aAAa,kBAAkB,mBAAmB,sBACtD,UACA,kBACG;GACH,uBAAuB,UAAU,YAAY,OAAO,OAAO;IACzD,kBAAkB;IAClB;GACF,CAAC;GACD,0BAA0B,QAAQ;GAClC,uBAAuB,QAAQ;GAC/B,yBAAyB,QAAQ;GACjC,sBAAsB,UAAU,EAAE,qBAAqB,KAAK,CAAC;EAC/D,CAAC;EACD,IAAI,CAAC,kBAAkB,WAAW,GAChC,kCAAkC,YAAY,MAAM;EAEtD,OAAO;CACT;CACA,kCAAkC,qBAAqB,MAAM;CAC7D,OAAO;AACT"}
@@ -2,11 +2,12 @@ import { effectScope } from "../../../reactivity/core.mjs";
2
2
  import { toRaw } from "../../../reactivity/reactive/shared.mjs";
3
3
  import { shallowReactive } from "../../../reactivity/reactive/shallow.mjs";
4
4
  import { isReactive } from "../../../reactivity/reactive.mjs";
5
- import { setCurrentInstance, setCurrentSetupContext } from "../../hooks/base.mjs";
5
+ import { getCurrentInstance, getCurrentSetupContext, setCurrentInstance, setCurrentSetupContext } from "../../hooks/base.mjs";
6
6
  import { hasOwn } from "../../../utils.mjs";
7
7
  import { hasTrackableSetupBinding } from "../../setupTracking.mjs";
8
8
  import { normalizeEmitEventName, normalizeEmitPayload } from "../../emit.mjs";
9
9
  import { attachRuntimeSlots, ensureSetupContextInstance, safeMarkNoSetData } from "./setupContext.mjs";
10
+ import { preserveSetupAccessor } from "../../define/setupResult.mjs";
10
11
  import { runSetupFunction } from "../setup.mjs";
11
12
  import { attachRuntimeSetupState, ensureRuntimeProps } from "./utils.mjs";
12
13
  import { WEVU_ATTRS_KEY, WEVU_EFFECT_SCOPE_KEY, WEVU_EXPOSED_KEY, WEVU_PROP_KEYS_KEY } from "@weapp-core/constants";
@@ -123,6 +124,13 @@ function runRuntimeSetupPhase(options) {
123
124
  slots
124
125
  });
125
126
  const instanceScope = effectScope(true);
127
+ const previousInstance = getCurrentInstance();
128
+ const previousSetupContext = getCurrentSetupContext();
129
+ const restoreSetupContext = () => {
130
+ if (getCurrentInstance() !== target || getCurrentSetupContext() !== context) return;
131
+ setCurrentSetupContext(previousSetupContext);
132
+ setCurrentInstance(previousInstance);
133
+ };
126
134
  target[WEVU_EFFECT_SCOPE_KEY] = instanceScope;
127
135
  setCurrentInstance(target);
128
136
  setCurrentSetupContext(context);
@@ -130,10 +138,12 @@ function runRuntimeSetupPhase(options) {
130
138
  const result = instanceScope.run(() => runSetupFunction(setup, props, context));
131
139
  let methodsChanged = false;
132
140
  if (result && typeof result === "object") {
141
+ const setupResult = result;
133
142
  const runtimeSetupState = runtime.setupState && typeof runtime.setupState === "object" ? isReactive(runtime.setupState) ? toRaw(runtime.setupState) : runtime.setupState : Object.create(null);
134
- Object.keys(result).forEach((key) => {
135
- const val = result[key];
136
- if (typeof val === "function") {
143
+ Object.keys(setupResult).forEach((key) => {
144
+ const val = setupResult[key];
145
+ const preservesAccessor = preserveSetupAccessor(runtimeSetupState, setupResult, key);
146
+ if (typeof val === "function" && !preservesAccessor) {
137
147
  const bound = (...args) => val.apply(runtime.proxy, args);
138
148
  runtime.methods[key] = bound;
139
149
  runtime.state[key] = bound;
@@ -145,7 +155,7 @@ function runRuntimeSetupPhase(options) {
145
155
  (_wevu_trackSetupReact = runtime.__wevu_trackSetupReactiveKey) === null || _wevu_trackSetupReact === void 0 || _wevu_trackSetupReact.call(runtime, key);
146
156
  }
147
157
  runtime.state[key] = val;
148
- runtimeSetupState[key] = val;
158
+ if (!preservesAccessor) runtimeSetupState[key] = val;
149
159
  }
150
160
  });
151
161
  }
@@ -154,8 +164,7 @@ function runRuntimeSetupPhase(options) {
154
164
  (_wevu_touchSetupMetho = runtime.__wevu_touchSetupMethodsVersion) === null || _wevu_touchSetupMetho === void 0 || _wevu_touchSetupMetho.call(runtime);
155
165
  }
156
166
  } finally {
157
- setCurrentSetupContext(void 0);
158
- setCurrentInstance(void 0);
167
+ restoreSetupContext();
159
168
  }
160
169
  }
161
170
 
@@ -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 { normalizeEmitEventName } from '../../emit'\nimport { 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 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 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(result).forEach((key) => {\n const val = (result as any)[key]\n if (typeof val === 'function') {\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 ;(runtimeSetupState as any)[key] = val\n }\n })\n }\n if (methodsChanged) {\n ;(runtime as any).__wevu_touchSetupMethodsVersion?.()\n }\n }\n finally {\n setCurrentSetupContext(undefined)\n setCurrentInstance(undefined)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,IAAI,uBAAuB;AAE3B,SAAS,4BAA4B,QAA8B,OAA4B;CAC7F,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,OAAO;EACpB;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,WAAW,GACxD,IAAI;EACF,OAAO,eAAe,UAAU,KAAK,UAAU;CACjD,kBACM;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,OAA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BAA0B,OAAO;KACnC,iBAAiB;IACnB,OACK;KACH,IAAI,yBAAyB,GAAG,GAAG;;MAChC,yBAAC,QAAgB,kHAA+B,GAAG;KACtD;KACC,AAAC,QAAQ,MAAc,OAAO;KAC9B,AAAC,kBAA0B,OAAO;IACrC;GACF,CAAC;EACH;EACA,IAAI,gBAAgB;;GACjB,yBAAC,QAAgB,mHAAkC;EACtD;CACF,UACQ;EACN,uBAAuB,MAAS;EAChC,mBAAmB,MAAS;CAC9B;AACF"}
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":";;;;;;;;;;;;;;;AAqCA,IAAI,uBAAuB;AAE3B,SAAS,4BAA4B,QAA8B,OAA4B;CAC7F,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,OAAO;EACpB;CACF;CACA,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,WAAW,GACxD,IAAI;EACF,OAAO,eAAe,UAAU,KAAK,UAAU;CACjD,kBACM;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,mBACM;EACJ,MAAM,OAAO,WAAW;CAC1B;AAEJ;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,CA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EvC;GACF,CAAC;EACH;EACA,IAAI,gBAAgB;;GACjB,yBAAC,QAAgB,mHAAkC;EACtD;CACF,UACQ;EAGN,oBAAoB;CACtB;AACF"}
@@ -1,11 +1,13 @@
1
1
  import { MiniProgramAppOptions, MiniProgramComponentOptions, MiniProgramPageLifetimes } from "./miniprogram.mjs";
2
- import { ComponentPropsOptions } from "./props/propTypes.mjs";
3
- import { ComputedDefinitions, MethodDefinitions } from "./core.mjs";
2
+ import { ComponentPropsOptions, InferProps } from "./props/propTypes.mjs";
3
+ import { ComponentPublicInstance, ComputedDefinitions, MethodDefinitions } from "./core.mjs";
4
4
  import { SetupContext, SetupFunction } from "./props/setup.mjs";
5
5
  import "./props.mjs";
6
+ import { ShallowUnwrapRef } from "../../vue-types.mjs";
6
7
  import { SetDataSnapshotOptions } from "./setData.mjs";
7
8
  //#region src/runtime/types/options.d.ts
8
9
  export type DataOption<D extends object> = D | (() => D);
10
+ type SetupThis<S> = [Exclude<S, void>] extends [never] ? Record<never, never> : ShallowUnwrapRef<Exclude<S, void>>;
9
11
  export interface DefineComponentOptions<P extends ComponentPropsOptions = ComponentPropsOptions, D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions, S extends Record<string, any> | void = Record<string, any> | void> extends MiniProgramComponentOptions, MiniProgramPageLifetimes {
10
12
  /**
11
13
  * 页面特性开关(用于按需注入 Page 事件处理函数)。
@@ -53,7 +55,7 @@ export interface DefineComponentOptions<P extends ComponentPropsOptions = Compon
53
55
  /**
54
56
  * 组件 computed(会参与快照 diff)。
55
57
  */
56
- computed?: C;
58
+ computed?: C & ThisType<ComponentPublicInstance<D, C, M, InferProps<P>> & SetupThis<S>>;
57
59
  /**
58
60
  * setData 快照控制选项(用于优化性能与 payload)。
59
61
  */
@@ -61,7 +63,7 @@ export interface DefineComponentOptions<P extends ComponentPropsOptions = Compon
61
63
  /**
62
64
  * 组件 methods(会绑定到 public instance 上)。
63
65
  */
64
- methods?: M;
66
+ methods?: M & ThisType<ComponentPublicInstance<D, C, M, InferProps<P>> & SetupThis<S>>;
65
67
  /**
66
68
  * 透传/扩展字段:允许携带其他小程序原生 Component 选项或自定义字段。
67
69
  * 说明:为保持兼容性保留索引签名,但仍会对已知字段提供智能提示。
@@ -1,15 +1,6 @@
1
- import { ActionSubscriber, DefineStoreOptions, StoreGetters, StoreSubscribeOptions, SubscriptionCallback } from "./types.mjs";
1
+ import { ActionSubscriber, DefineStoreOptions, OptionsStore, StoreSubscribeOptions, SubscriptionCallback } from "./types.mjs";
2
2
  //#region src/store/define.d.ts
3
3
  type SetupDefinition<T> = () => T;
4
- type ActionResult<A> = Awaited<ReturnType<Extract<A[keyof A], (...args: any[]) => any>>>;
5
- type OptionsStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>> = S & StoreGetters<G> & A & {
6
- $id: string;
7
- $state: S;
8
- $patch: (patch: Partial<S> | ((state: S) => void)) => void;
9
- $reset: () => void;
10
- $subscribe: (cb: SubscriptionCallback<S>, opts?: StoreSubscribeOptions) => () => void;
11
- $onAction: (cb: ActionSubscriber<OptionsStore<S, G, A>, ActionResult<A>>) => () => void;
12
- };
13
4
  /**
14
5
  * @description 定义一个 setup 风格的 store
15
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"define.mjs","names":[],"sources":["../../../src/store/define.ts"],"sourcesContent":["import type {\n ActionSubscriber,\n DefineStoreOptions,\n StoreGetters,\n StoreManager,\n StoreSubscribeOptions,\n SubscriptionCallback,\n} from './types'\nimport { effectScope } from '../reactivity'\nimport { createOptionsStyleStore } from './define/optionsStyle'\nimport { createSetupStyleStore } from './define/setupStyle'\nimport { createStore } from './manager'\n\ntype SetupDefinition<T> = () => T\n\ntype ActionResult<A> = Awaited<ReturnType<Extract<A[keyof A], (...args: any[]) => any>>>\ntype OptionsStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>> = S & StoreGetters<G> & A & {\n $id: string\n $state: S\n $patch: (patch: Partial<S> | ((state: S) => void)) => void\n $reset: () => void\n $subscribe: (cb: SubscriptionCallback<S>, opts?: StoreSubscribeOptions) => () => void\n $onAction: (cb: ActionSubscriber<OptionsStore<S, G, A>, ActionResult<A>>) => () => void\n}\n\n/**\n * @description 定义一个 setup 风格的 store\n */\nexport function defineStore<T extends Record<string, any>>(id: string, setup: SetupDefinition<T>): () => T & {\n $id: string\n $patch: (patch: Record<string, any> | ((state: any) => void)) => void\n $reset: () => void\n $subscribe: (cb: SubscriptionCallback<any>, opts?: StoreSubscribeOptions) => () => void\n $onAction: (cb: ActionSubscriber<any>) => () => void\n}\n/**\n * @description 定义一个 options 风格的 store\n */\nexport function defineStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>>(\n id: string,\n options: DefineStoreOptions<S, G, A>,\n): () => OptionsStore<S, G, A>\nexport function defineStore(id: string, setupOrOptions: any) {\n let instance: any\n let created = false\n const manager = (createStore as any)._instance as StoreManager | undefined\n\n return function useStore(): any {\n if (created && instance) {\n return instance\n }\n created = true\n\n const storeScope = effectScope(true)\n instance = storeScope.run(() => {\n return typeof setupOrOptions === 'function'\n ? createSetupStyleStore(id, setupOrOptions, manager)\n : createOptionsStyleStore(id, setupOrOptions as DefineStoreOptions<any, any, any>, manager)\n })\n\n return instance\n }\n}\n"],"mappings":";;;;;;AA0CA,SAAgB,YAAY,IAAY,gBAAqB;CAC3D,IAAI;CACJ,IAAI,UAAU;CACd,MAAM,UAAW,YAAoB;CAErC,OAAO,SAAS,WAAgB;EAC9B,IAAI,WAAW,UACb,OAAO;EAET,UAAU;EAGV,WADmB,YAAY,IACX,CAAC,CAAC,UAAU;GAC9B,OAAO,OAAO,mBAAmB,aAC7B,sBAAsB,IAAI,gBAAgB,OAAO,IACjD,wBAAwB,IAAI,gBAAqD,OAAO;EAC9F,CAAC;EAED,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"define.mjs","names":[],"sources":["../../../src/store/define.ts"],"sourcesContent":["import type {\n ActionSubscriber,\n DefineStoreOptions,\n OptionsStore,\n StoreManager,\n StoreSubscribeOptions,\n SubscriptionCallback,\n} from './types'\nimport { effectScope } from '../reactivity'\nimport { createOptionsStyleStore } from './define/optionsStyle'\nimport { createSetupStyleStore } from './define/setupStyle'\nimport { createStore } from './manager'\n\ntype SetupDefinition<T> = () => T\n\n/**\n * @description 定义一个 setup 风格的 store\n */\nexport function defineStore<T extends Record<string, any>>(id: string, setup: SetupDefinition<T>): () => T & {\n $id: string\n $patch: (patch: Record<string, any> | ((state: any) => void)) => void\n $reset: () => void\n $subscribe: (cb: SubscriptionCallback<any>, opts?: StoreSubscribeOptions) => () => void\n $onAction: (cb: ActionSubscriber<any>) => () => void\n}\n/**\n * @description 定义一个 options 风格的 store\n */\nexport function defineStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>>(\n id: string,\n options: DefineStoreOptions<S, G, A>,\n): () => OptionsStore<S, G, A>\nexport function defineStore(id: string, setupOrOptions: any) {\n let instance: any\n let created = false\n const manager = (createStore as any)._instance as StoreManager | undefined\n\n return function useStore(): any {\n if (created && instance) {\n return instance\n }\n created = true\n\n const storeScope = effectScope(true)\n instance = storeScope.run(() => {\n return typeof setupOrOptions === 'function'\n ? createSetupStyleStore(id, setupOrOptions, manager)\n : createOptionsStyleStore(id, setupOrOptions as DefineStoreOptions<any, any, any>, manager)\n })\n\n return instance\n }\n}\n"],"mappings":";;;;;;AAgCA,SAAgB,YAAY,IAAY,gBAAqB;CAC3D,IAAI;CACJ,IAAI,UAAU;CACd,MAAM,UAAW,YAAoB;CAErC,OAAO,SAAS,WAAgB;EAC9B,IAAI,WAAW,UACb,OAAO;EAET,UAAU;EAGV,WADmB,YAAY,IACX,CAAC,CAAC,UAAU;GAC9B,OAAO,OAAO,mBAAmB,aAC7B,sBAAsB,IAAI,gBAAgB,OAAO,IACjD,wBAAwB,IAAI,gBAAqD,OAAO;EAC9F,CAAC;EAED,OAAO;CACT;AACF"}
@@ -58,13 +58,23 @@ export type GetterTree<S extends Record<string, any>> = Record<string, (state: S
58
58
  * @description 从 Getter 定义中推导返回类型
59
59
  */
60
60
  export type StoreGetters<G extends GetterTree<any>> = { [K in keyof G]: G[K] extends ((...args: any[]) => infer R) ? R : never; };
61
+ type ActionResult<A> = Awaited<ReturnType<Extract<A[keyof A], (...args: any[]) => any>>>;
62
+ /** 选项式 Store 的完整实例,供外部调用及 action/getter 的 this 共享。 */
63
+ export type OptionsStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>> = S & StoreGetters<G> & A & {
64
+ $id: string;
65
+ $state: S;
66
+ $patch: (patch: Partial<S> | ((state: S) => void)) => void;
67
+ $reset: () => void;
68
+ $subscribe: (cb: SubscriptionCallback<S>, opts?: StoreSubscribeOptions) => () => void;
69
+ $onAction: (cb: ActionSubscriber<OptionsStore<S, G, A>, ActionResult<A>>) => () => void;
70
+ };
61
71
  /**
62
72
  * @description defineStore(options) 的配置类型
63
73
  */
64
74
  export interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree<S>, A extends Record<string, any>> {
65
75
  state: () => S;
66
- getters?: G & Record<string, (state: S) => any> & ThisType<S & StoreGetters<G> & A>;
67
- actions?: A & ThisType<S & StoreGetters<G> & A>;
76
+ getters?: G & Record<string, (state: S) => any> & ThisType<OptionsStore<S, G, A>>;
77
+ actions?: A & ThisType<OptionsStore<S, G, A>>;
68
78
  }
69
79
  //#endregion
70
80
  //# sourceMappingURL=types.d.mts.map
@@ -40,6 +40,8 @@ type ScriptSetupNativeProperties<D extends object, P extends ScriptSetupNativePr
40
40
  type ScriptSetupNativeMethods<D extends object, P extends ScriptSetupNativePropertyOption, M extends ScriptSetupNativeMethodOption> = M & ThisType<ScriptSetupNativeInstance<D, P, M>>;
41
41
  type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K]; };
42
42
  export type ScriptSetupDefineOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions, P extends ScriptSetupNativePropertyOption = ScriptSetupNativePropertyOption> = Omit<RemoveIndexSignature<DefineComponentOptions<ComponentPropsOptions, D, C, M>>, 'props' | 'options' | 'data' | 'methods'> & {
43
+ /** 组件静态名称,供编译器匹配组件配置。 */
44
+ name?: string;
43
45
  /**
44
46
  * props 必须通过 defineProps() 声明。
45
47
  */
package/dist/package.mjs CHANGED
@@ -1 +1 @@
1
- var e=`7.1.2`;export{e as version};
1
+ var e=`7.1.4`;export{e as version};
@@ -1 +1 @@
1
- import{queueJob as e}from"../scheduler.mjs";import t from"../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/defineProperty.mjs";const n=new WeakMap;let r=null;const i=[];let a=!0,o,s=0,c=!1;const l=new Set,u=new Set;function d(e){if(e.active){if(e.scheduler){let t=o;o=e._scope;try{e.scheduler()}finally{o=t}return}e()}}function f(e){if(s>0||c){u.add(e);return}u.delete(e),e()}function p(){s++}function m(e){let t=e.values().next();if(!t.done)return e.delete(t.value),t.value}function h(){let e,t=!1;c=!0;try{for(;l.size;){let n=m(l);if(n)try{d(n)}catch(n){t||(e=n,t=!0)}}}finally{c=!1}for(;u.size;){let n=u.values().next().value;u.delete(n);try{n()}catch(n){t||(e=n,t=!0)}}if(t)throw e}function g(){s!==0&&(s--,s===0&&!c&&h())}function _(e){p();try{return e()}finally{g()}}function v(e){let{deps:t}=e;for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}function y(e){var t;e.active&&(e.active=!1,v(e),(t=e.onStop)==null||t.call(e))}var b=class{constructor(e=!1){if(this.detached=e,t(this,`active`,!0),t(this,`effects`,[]),t(this,`cleanups`,[]),t(this,`parent`,void 0),t(this,`scopes`,void 0),!e&&o){var n;if(!o.active){this.active=!1;return}this.parent=o,((n=o).scopes||(n.scopes=[])).push(this)}}run(e){if(!this.active)return;let t=o;o=this;try{return e()}finally{o=t}}stop(){if(!this.active)return;this.active=!1;let e=o;o=this;let t,n=!1,r=e=>{n||(t=e,n=!0)};try{let e=this.effects.splice(0);for(let t of e)try{y(t)}catch(e){r(e)}let t=this.cleanups.splice(0);for(let e of t)try{e()}catch(e){r(e)}let n=this.scopes;if(this.scopes=void 0,n){for(let e of n)try{e.stop()}catch(e){r(e)}n.length=0}}finally{var i;if((i=this.parent)!=null&&i.scopes){let e=this.parent.scopes.indexOf(this);e>=0&&this.parent.scopes.splice(e,1)}this.parent=void 0,o=e}if(n)throw t}};function x(e=!1){return new b(e)}function S(){return o}function C(e){o!=null&&o.active&&o.cleanups.push(e)}function w(e){let t=a;a=!1;try{return e()}finally{a=t}}function T(e){if(o){if(o.active){o.effects.push(e);return}y(e)}}function E(e,t={}){let n=function(){if(!n.active||n._running)return e();v(n);let t=o;o=n._scope;let s=a;try{return a=!0,n._running=!0,i.push(n),r=n,e()}finally{var c;i.pop(),r=(c=i[i.length-1])==null?null:c,n._running=!1,o=t,a=s}};return n.deps=[],n.scheduler=t.scheduler,n.onStop=t.onStop,n.active=!0,n._running=!1,n._fn=e,n._scope=o,n}function D(e,t,n){let r=E(e,t);return r._computed=n,T(r),t.lazy||r(),r}function O(e,t={}){return D(e,t,!1)}function k(e,t={}){return D(e,t,!0)}function A(e,t){if(!a||!r)return;let i=n.get(e);i||(i=new Map,n.set(e,i));let o=i.get(t);o||(o=new Set,i.set(t,o)),o.has(r)||(o.add(r),r.deps.push(o))}function j(e){if(!e._running){if(e._computed){d(e);return}if(s>0||c){l.add(e);return}d(e)}}function M(e,t){let i=n.get(e);if(!i)return;let a=i.get(t);if(!a)return;let o=new Set;a.forEach(e=>{e!==r&&o.add(e)}),o.forEach(j)}function N(e){a&&r&&(e.has(r)||(e.add(r),r.deps.push(e)))}function P(e){new Set(e).forEach(j)}export{_ as batch,k as createComputedEffect,E as createReactiveEffect,O as effect,x as effectScope,g as endBatch,S as getCurrentScope,C as onScopeDispose,f as queueBatchCallback,e as queueJob,w as runWithoutTracking,p as startBatch,y as stop,A as track,N as trackEffects,M as trigger,P as triggerEffects};
1
+ import{queueJob as e}from"../scheduler.mjs";import t from"../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/defineProperty.mjs";const n=/* @__PURE__ */ new WeakMap;let r=null;const i=[];let a=!0,o,s=0,c=!1;const l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Set;function d(e){if(e.active){if(e.scheduler){let t=o;o=e._scope;try{e.scheduler()}finally{o=t}return}e()}}function f(e){if(s>0||c){u.add(e);return}u.delete(e),e()}function p(){s++}function m(e){let t=e.values().next();if(!t.done)return e.delete(t.value),t.value}function h(){let e,t=!1;c=!0;try{for(;l.size;){let n=m(l);if(n)try{d(n)}catch(n){t||(e=n,t=!0)}}}finally{c=!1}for(;u.size;){let n=u.values().next().value;u.delete(n);try{n()}catch(n){t||(e=n,t=!0)}}if(t)throw e}function g(){s!==0&&(s--,s===0&&!c&&h())}function _(e){p();try{return e()}finally{g()}}function v(e){let{deps:t}=e;for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}function y(e){var t;e.active&&(e.active=!1,v(e),(t=e.onStop)==null||t.call(e))}var b=class{constructor(e=!1){if(this.detached=e,t(this,`active`,!0),t(this,`effects`,[]),t(this,`cleanups`,[]),t(this,`parent`,void 0),t(this,`scopes`,void 0),!e&&o){var n;if(!o.active){this.active=!1;return}this.parent=o,((n=o).scopes||(n.scopes=[])).push(this)}}run(e){if(!this.active)return;let t=o;o=this;try{return e()}finally{o=t}}stop(){if(!this.active)return;this.active=!1;let e=o;o=this;let t,n=!1,r=e=>{n||(t=e,n=!0)};try{let e=this.effects.splice(0);for(let t of e)try{y(t)}catch(e){r(e)}let t=this.cleanups.splice(0);for(let e of t)try{e()}catch(e){r(e)}let n=this.scopes;if(this.scopes=void 0,n){for(let e of n)try{e.stop()}catch(e){r(e)}n.length=0}}finally{var i;if((i=this.parent)!=null&&i.scopes){let e=this.parent.scopes.indexOf(this);e>=0&&this.parent.scopes.splice(e,1)}this.parent=void 0,o=e}if(n)throw t}};function x(e=!1){return new b(e)}function S(){return o}function C(e){o!=null&&o.active&&o.cleanups.push(e)}function w(e){let t=a;a=!1;try{return e()}finally{a=t}}function T(e){if(o){if(o.active){o.effects.push(e);return}y(e)}}function E(e,t={}){let n=function(){if(!n.active||n._running)return e();v(n);let t=o;o=n._scope;let s=a;try{return a=!0,n._running=!0,i.push(n),r=n,e()}finally{var c;i.pop(),r=(c=i[i.length-1])==null?null:c,n._running=!1,o=t,a=s}};return n.deps=[],n.scheduler=t.scheduler,n.onStop=t.onStop,n.active=!0,n._running=!1,n._fn=e,n._scope=o,n}function D(e,t,n){let r=E(e,t);return r._computed=n,T(r),t.lazy||r(),r}function O(e,t={}){return D(e,t,!1)}function k(e,t={}){return D(e,t,!0)}function A(e,t){if(!a||!r)return;let i=n.get(e);i||(i=/* @__PURE__ */ new Map,n.set(e,i));let o=i.get(t);o||(o=/* @__PURE__ */ new Set,i.set(t,o)),o.has(r)||(o.add(r),r.deps.push(o))}function j(e){if(!e._running){if(e._computed){d(e);return}if(s>0||c){l.add(e);return}d(e)}}function M(e,t){let i=n.get(e);if(!i)return;let a=i.get(t);if(!a)return;let o=/* @__PURE__ */ new Set;a.forEach(e=>{e!==r&&o.add(e)}),o.forEach(j)}function N(e){a&&r&&(e.has(r)||(e.add(r),r.deps.push(e)))}function P(e){new Set(e).forEach(j)}export{_ as batch,k as createComputedEffect,E as createReactiveEffect,O as effect,x as effectScope,g as endBatch,S as getCurrentScope,C as onScopeDispose,f as queueBatchCallback,e as queueJob,w as runWithoutTracking,p as startBatch,y as stop,A as track,N as trackEffects,M as trigger,P as triggerEffects};
@@ -1 +1 @@
1
- const e=new Set;function t(t){e.add(t)}function n(t){e.delete(t)}export{t as addMutationRecorder,e as mutationRecorders,n as removeMutationRecorder};
1
+ const e=/* @__PURE__ */ new Set;function t(t){e.add(t)}function n(t){e.delete(t)}export{t as addMutationRecorder,e as mutationRecorders,n as removeMutationRecorder};
@@ -1 +1 @@
1
- import{track as e}from"../core.mjs";import{adoptReactiveRoot as t,indexPatchNode as n,rawMultiParentSet as r,rawParentMap as i,rawParentsMap as a,rawPathMap as o,rawRootMap as s,rawVersionMap as c,recordParentLink as l,rootPatchNodesMap as u}from"./patchState.mjs";import{VERSION_KEY as d,isObject as f,toRaw as p}from"./shared.mjs";function m(e,i){let a=p(e);o.set(a,``),n(a,a);let s=i==null?void 0:i.shouldIncludeTopKey,c=typeof(i==null?void 0:i.maxDepth)==`number`?Math.max(0,Math.floor(i.maxDepth)):1/0,u=typeof(i==null?void 0:i.maxKeys)==`number`?Math.max(0,Math.floor(i.maxKeys)):1/0,d=new WeakSet,m=[{current:a,path:``,depth:0}],h=0;for(;m.length;){let e=m.pop();if(d.has(e.current)||(d.add(e.current),o.set(e.current,e.path),n(a,e.current),h+=1,h>=u)||e.depth>=c||Array.isArray(e.current))continue;let i=Object.entries(e.current);for(let[c,u]of i){if(e.path===``&&s&&!s(c)||!f(u)||u.__r_skip)continue;let i=p(u);if(t(i,e.current),l(i,e.current,c),!r.has(i)){let t=e.path?`${e.path}.${c}`:c;o.set(i,t)}n(a,i),m.push({current:i,path:e.path?`${e.path}.${c}`:c,depth:e.depth+1})}}}function h(e){let t=p(e),n=u.get(t);if(!n){o.delete(t);return}for(let e of n)i.delete(e),a.delete(e),o.delete(e),r.delete(e),s.delete(e),c.delete(e);u.delete(t)}function g(t){let n=p(t);e(n,d)}export{h as clearPatchIndices,m as prelinkReactiveTree,g as touchReactive};
1
+ import{track as e}from"../core.mjs";import{adoptReactiveRoot as t,indexPatchNode as n,rawMultiParentSet as r,rawParentMap as i,rawParentsMap as a,rawPathMap as o,rawRootMap as s,rawVersionMap as c,recordParentLink as l,rootPatchNodesMap as u}from"./patchState.mjs";import{VERSION_KEY as d,isObject as f,toRaw as p}from"./shared.mjs";function m(e,i){let a=p(e);o.set(a,``),n(a,a);let s=i==null?void 0:i.shouldIncludeTopKey,c=typeof(i==null?void 0:i.maxDepth)==`number`?Math.max(0,Math.floor(i.maxDepth)):1/0,u=typeof(i==null?void 0:i.maxKeys)==`number`?Math.max(0,Math.floor(i.maxKeys)):1/0,d=/* @__PURE__ */ new WeakSet,m=[{current:a,path:``,depth:0}],h=0;for(;m.length;){let e=m.pop();if(d.has(e.current)||(d.add(e.current),o.set(e.current,e.path),n(a,e.current),h+=1,h>=u)||e.depth>=c||Array.isArray(e.current))continue;let i=Object.entries(e.current);for(let[c,u]of i){if(e.path===``&&s&&!s(c)||!f(u)||u.__r_skip)continue;let i=p(u);if(t(i,e.current),l(i,e.current,c),!r.has(i)){let t=e.path?`${e.path}.${c}`:c;o.set(i,t)}n(a,i),m.push({current:i,path:e.path?`${e.path}.${c}`:c,depth:e.depth+1})}}}function h(e){let t=p(e),n=u.get(t);if(!n){o.delete(t);return}for(let e of n)i.delete(e),a.delete(e),o.delete(e),r.delete(e),s.delete(e),c.delete(e);u.delete(t)}function g(t){let n=p(t);e(n,d)}export{h as clearPatchIndices,m as prelinkReactiveTree,g as touchReactive};
@@ -1 +1 @@
1
- import{mutationRecorders as e}from"./mutation.mjs";const t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakSet,o=new WeakMap,s=new WeakMap;function c(e){let t=s.get(e);return t||(t=new Set,s.set(e,t)),t}function l(e,t){c(e).add(t)}function u(e){var t;n.set(e,((t=n.get(e))==null?0:t)+1)}function d(e){var t;return(t=n.get(e))==null?0:t}function f(e,n){var r;let i=(r=t.get(n))==null?n:r,a=t.get(e);(!a||a===e||a===n)&&t.set(e,i)}function p(e){let t=new Set,n=[e];for(let e=0;e<2e3&&n.length;e++){let e=n.pop(),r=i.get(e);if(r)for(let e of r.keys())t.has(e)||(t.add(e),u(e),n.push(e))}}function m(e){let t=i.get(e);if(!t){a.delete(e),r.delete(e);return}let n,o,s=0;for(let[e,r]of t){for(let t of r){if(s+=1,s>1)break;n=e,o=t}if(s>1)break}if(s===1&&n&&o){a.delete(e),r.set(e,{parent:n,key:o});return}a.add(e),r.delete(e)}function h(n,o,s){if(typeof s!=`string`){a.add(n),r.delete(n);return}if(e.size){var c;let e=(c=t.get(o))==null?o:c;l(e,o),l(e,n)}let u=i.get(n);u||(u=new Map,i.set(n,u));let d=u.get(o);d||(d=new Set,u.set(o,d)),d.add(s),m(n)}function g(e,t,n){let r=i.get(e);if(!r)return;let a=r.get(t);a&&(a.delete(n),a.size||r.delete(t),r.size||i.delete(e),m(e))}function _(e,t){if(t===e)return[];if(a.has(t))return;let n=[],i=t;for(let t=0;t<2e3;t++){if(i===e)return n.reverse();if(a.has(i))return;let t=r.get(i);if(!t||typeof t.key!=`string`)return;n.push(t.key),i=t.parent}}export{f as adoptReactiveRoot,p as bumpAncestorVersions,u as bumpRawVersion,d as getRawVersion,l as indexPatchNode,a as rawMultiParentSet,r as rawParentMap,i as rawParentsMap,o as rawPathMap,t as rawRootMap,n as rawVersionMap,h as recordParentLink,g as removeParentLink,_ as resolvePathToTarget,s as rootPatchNodesMap};
1
+ import{mutationRecorders as e}from"./mutation.mjs";const t=/* @__PURE__ */ new WeakMap,n=/* @__PURE__ */ new WeakMap,r=/* @__PURE__ */ new WeakMap,i=/* @__PURE__ */ new WeakMap,a=/* @__PURE__ */ new WeakSet,o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new WeakMap;function c(e){let t=s.get(e);return t||(t=/* @__PURE__ */ new Set,s.set(e,t)),t}function l(e,t){c(e).add(t)}function u(e){var t;n.set(e,((t=n.get(e))==null?0:t)+1)}function d(e){var t;return(t=n.get(e))==null?0:t}function f(e,n){var r;let i=(r=t.get(n))==null?n:r,a=t.get(e);(!a||a===e||a===n)&&t.set(e,i)}function p(e){let t=/* @__PURE__ */ new Set,n=[e];for(let e=0;e<2e3&&n.length;e++){let e=n.pop(),r=i.get(e);if(r)for(let e of r.keys())t.has(e)||(t.add(e),u(e),n.push(e))}}function m(e){let t=i.get(e);if(!t){a.delete(e),r.delete(e);return}let n,o,s=0;for(let[e,r]of t){for(let t of r){if(s+=1,s>1)break;n=e,o=t}if(s>1)break}if(s===1&&n&&o){a.delete(e),r.set(e,{parent:n,key:o});return}a.add(e),r.delete(e)}function h(n,o,s){if(typeof s!=`string`){a.add(n),r.delete(n);return}if(e.size){var c;let e=(c=t.get(o))==null?o:c;l(e,o),l(e,n)}let u=i.get(n);u||(u=/* @__PURE__ */ new Map,i.set(n,u));let d=u.get(o);d||(d=/* @__PURE__ */ new Set,u.set(o,d)),d.add(s),m(n)}function g(e,t,n){let r=i.get(e);if(!r)return;let a=r.get(t);a&&(a.delete(n),a.size||r.delete(t),r.size||i.delete(e),m(e))}function _(e,t){if(t===e)return[];if(a.has(t))return;let n=[],i=t;for(let t=0;t<2e3;t++){if(i===e)return n.reverse();if(a.has(i))return;let t=r.get(i);if(!t||typeof t.key!=`string`)return;n.push(t.key),i=t.parent}}export{f as adoptReactiveRoot,p as bumpAncestorVersions,u as bumpRawVersion,d as getRawVersion,l as indexPatchNode,a as rawMultiParentSet,r as rawParentMap,i as rawParentsMap,o as rawPathMap,t as rawRootMap,n as rawVersionMap,h as recordParentLink,g as removeParentLink,_ as resolvePathToTarget,s as rootPatchNodesMap};
@@ -1 +1 @@
1
- const e=new WeakMap,t=new WeakMap,n=new WeakMap;export{t as rawMap,e as reactiveMap,n as shallowReactiveMap};
1
+ const e=/* @__PURE__ */ new WeakMap,t=/* @__PURE__ */ new WeakMap,n=/* @__PURE__ */ new WeakMap;export{t as rawMap,e as reactiveMap,n as shallowReactiveMap};
@@ -1 +1 @@
1
- import{track as e,trigger as t}from"./core.mjs";import{addMutationRecorder as n,mutationRecorders as r,removeMutationRecorder as i}from"./reactive/mutation.mjs";import{adoptReactiveRoot as a,bumpAncestorVersions as o,bumpRawVersion as s,getRawVersion as c,rawMultiParentSet as l,rawParentsMap as u,rawPathMap as d,rawRootMap as f,rawVersionMap as p,recordParentLink as m,removeParentLink as h,resolvePathToTarget as g}from"./reactive/patchState.mjs";import{VERSION_KEY as _,getTargetType as v,hasOwn as y,isArrayIndexKey as b,isObject as x,toRaw as S}from"./reactive/shared.mjs";import{rawMap as C,reactiveMap as w}from"./reactive/state.mjs";import{clearPatchIndices as T,prelinkReactiveTree as E,touchReactive as D}from"./reactive/patch.mjs";import{isShallowReactive as O,shallowReactive as k}from"./reactive/shallow.mjs";function A(e){let t=S(e);return c(t)}function j(e,t,n){var i;if(!r.size||typeof t!=`string`||t.startsWith(`__r_`))return;let a=(i=f.get(e))==null?e:i,o=Array.isArray(e)&&(t===`length`||b(t))?`array`:`property`,s=g(a,e);if(!s){let i=new Set,s=u.get(e);if(s)for(let[e,t]of s){var c;let n=d.get(e),r=n?n.split(`.`,1)[0]:void 0,o=r||(c=g(a,e))==null?void 0:c[0];for(let e of t){var l;typeof e==`string`&&i.add((l=r==null?o:r)==null?e:l)}}else i.add(t);for(let e of r)e({root:a,kind:o,op:n,path:void 0,fallbackTopKeys:i.size?[...i]:void 0});return}let p=s.findIndex(e=>b(e));if(p!==-1){let e=s.slice(0,p).join(`.`)||void 0;for(let t of r)t({root:a,kind:`array`,op:n,path:e});return}let m=s.length?s.join(`.`):``,h=o===`array`?m||void 0:m?`${m}.${t}`:t;for(let e of r)e({root:a,kind:o,op:n,path:h})}const M={get(t,n,i){if(n===`__r_isReactive`)return!0;if(n===`__r_raw`)return t;let o=Reflect.get(t,n,i);if(e(t,n),x(o)){var s;if(o.__r_skip)return o;let e=(s=o==null?void 0:o.__r_raw)==null?o:s;a(e,t),m(e,t,n);let i=d.get(t);if(r.size&&typeof n==`string`&&i!=null&&!l.has(e)){let t=i?`${i}.${n}`:n;d.set(e,t)}return N(o)}return o},set(e,n,i,c){let u=Array.isArray(e),p=u?e.length:0,g=Reflect.get(e,n,c),v=x(g)?S(g):g,y=x(i)?S(i):i;if(Object.is(v,y))return!0;let C=Reflect.set(e,n,i,c);if(C){let i=x(v)?v:void 0;if(i&&h(i,e,n),x(y)&&!y.__r_skip){let t=y;a(t,e),m(t,e,n);let i=d.get(e);if(r.size&&typeof n==`string`&&i!=null&&!l.has(t)){let e=i?`${i}.${n}`:n;d.set(t,e)}}t(e,n),u&&typeof n==`string`&&b(n)&&Number(n)>=p&&t(e,`length`),t(e,_),s(e),o(e);let c=f.get(e);c&&c!==e&&(t(c,_),s(c)),j(e,n,`set`)}return C},deleteProperty(e,n){let r=y(e,n),i=r?e[n]:void 0,a=Reflect.deleteProperty(e,n);if(r&&a){var c;let r=x(i)?(c=i==null?void 0:i.__r_raw)==null?i:c:void 0;r&&h(r,e,n),t(e,n),t(e,_),s(e),o(e);let a=f.get(e);a&&a!==e&&(t(a,_),s(a)),j(e,n,`delete`)}return a},ownKeys(t){return e(t,Symbol.iterator),e(t,_),Reflect.ownKeys(t)}};function N(e){if(!x(e)||e.__r_isReactive)return e;let t=w.get(e);if(t)return t;if(v(e)===0)return e;let n=new Proxy(e,M);return w.set(e,n),C.set(n,e),p.has(e)||p.set(e,0),f.has(e)||f.set(e,e),n}function P(e){return!!(e&&e.__r_isReactive)}function F(e){return x(e)?N(e):e}function I(e){return x(e)&&Object.defineProperty(e,"__r_skip",{value:!0,configurable:!0,enumerable:!1,writable:!0}),e}function L(e){return x(e)&&`__r_skip`in e}export{n as addMutationRecorder,T as clearPatchIndices,F as convertToReactive,A as getReactiveVersion,x as isObject,L as isRaw,P as isReactive,O as isShallowReactive,I as markRaw,E as prelinkReactiveTree,N as reactive,i as removeMutationRecorder,k as shallowReactive,S as toRaw,D as touchReactive};
1
+ import{track as e,trigger as t}from"./core.mjs";import{addMutationRecorder as n,mutationRecorders as r,removeMutationRecorder as i}from"./reactive/mutation.mjs";import{adoptReactiveRoot as a,bumpAncestorVersions as o,bumpRawVersion as s,getRawVersion as c,rawMultiParentSet as l,rawParentsMap as u,rawPathMap as d,rawRootMap as f,rawVersionMap as p,recordParentLink as m,removeParentLink as h,resolvePathToTarget as g}from"./reactive/patchState.mjs";import{VERSION_KEY as _,getTargetType as v,hasOwn as y,isArrayIndexKey as b,isObject as x,toRaw as S}from"./reactive/shared.mjs";import{rawMap as C,reactiveMap as w}from"./reactive/state.mjs";import{clearPatchIndices as T,prelinkReactiveTree as E,touchReactive as D}from"./reactive/patch.mjs";import{isShallowReactive as O,shallowReactive as k}from"./reactive/shallow.mjs";function A(e){let t=S(e);return c(t)}function j(e,t,n){var i;if(!r.size||typeof t!=`string`||t.startsWith(`__r_`))return;let a=(i=f.get(e))==null?e:i,o=Array.isArray(e)&&(t===`length`||b(t))?`array`:`property`,s=g(a,e);if(!s){let i=/* @__PURE__ */ new Set,s=u.get(e);if(s)for(let[e,t]of s){var c;let n=d.get(e),r=n?n.split(`.`,1)[0]:void 0,o=r||(c=g(a,e))==null?void 0:c[0];for(let e of t){var l;typeof e==`string`&&i.add((l=r==null?o:r)==null?e:l)}}else i.add(t);for(let e of r)e({root:a,kind:o,op:n,path:void 0,fallbackTopKeys:i.size?[...i]:void 0});return}let p=s.findIndex(e=>b(e));if(p!==-1){let e=s.slice(0,p).join(`.`)||void 0;for(let t of r)t({root:a,kind:`array`,op:n,path:e});return}let m=s.length?s.join(`.`):``,h=o===`array`?m||void 0:m?`${m}.${t}`:t;for(let e of r)e({root:a,kind:o,op:n,path:h})}const M={get(t,n,i){if(n===`__r_isReactive`)return!0;if(n===`__r_raw`)return t;let o=Reflect.get(t,n,i);if(e(t,n),x(o)){var s;if(o.__r_skip)return o;let e=(s=o==null?void 0:o.__r_raw)==null?o:s;a(e,t),m(e,t,n);let i=d.get(t);if(r.size&&typeof n==`string`&&i!=null&&!l.has(e)){let t=i?`${i}.${n}`:n;d.set(e,t)}return N(o)}return o},set(e,n,i,c){let u=Array.isArray(e),p=u?e.length:0,g=Reflect.get(e,n,c),v=x(g)?S(g):g,y=x(i)?S(i):i;if(Object.is(v,y))return!0;let C=Reflect.set(e,n,i,c);if(C){let i=x(v)?v:void 0;if(i&&h(i,e,n),x(y)&&!y.__r_skip){let t=y;a(t,e),m(t,e,n);let i=d.get(e);if(r.size&&typeof n==`string`&&i!=null&&!l.has(t)){let e=i?`${i}.${n}`:n;d.set(t,e)}}t(e,n),u&&typeof n==`string`&&b(n)&&Number(n)>=p&&t(e,`length`),t(e,_),s(e),o(e);let c=f.get(e);c&&c!==e&&(t(c,_),s(c)),j(e,n,`set`)}return C},deleteProperty(e,n){let r=y(e,n),i=r?e[n]:void 0,a=Reflect.deleteProperty(e,n);if(r&&a){var c;let r=x(i)?(c=i==null?void 0:i.__r_raw)==null?i:c:void 0;r&&h(r,e,n),t(e,n),t(e,_),s(e),o(e);let a=f.get(e);a&&a!==e&&(t(a,_),s(a)),j(e,n,`delete`)}return a},ownKeys(t){return e(t,Symbol.iterator),e(t,_),Reflect.ownKeys(t)}};function N(e){if(!x(e)||e.__r_isReactive)return e;let t=w.get(e);if(t)return t;if(v(e)===0)return e;let n=new Proxy(e,M);return w.set(e,n),C.set(n,e),p.has(e)||p.set(e,0),f.has(e)||f.set(e,e),n}function P(e){return!!(e&&e.__r_isReactive)}function F(e){return x(e)?N(e):e}function I(e){return x(e)&&Object.defineProperty(e,"__r_skip",{value:!0,configurable:!0,enumerable:!1,writable:!0}),e}function L(e){return x(e)&&`__r_skip`in e}export{n as addMutationRecorder,T as clearPatchIndices,F as convertToReactive,A as getReactiveVersion,x as isObject,L as isRaw,P as isReactive,O as isShallowReactive,I as markRaw,E as prelinkReactiveTree,N as reactive,i as removeMutationRecorder,k as shallowReactive,S as toRaw,D as touchReactive};
@@ -1 +1 @@
1
- import e from"../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/defineProperty.mjs";import{trackEffects as t,triggerEffects as n}from"./core.mjs";import{convertToReactive as r,markRaw as i}from"./reactive.mjs";const a=`__v_isRef`;function o(e){try{Object.defineProperty(e,a,{value:!0,configurable:!0})}catch(t){e[a]=!0}return e}function s(e){return!!(e&&typeof e==`object`&&e.__v_isRef===!0)}var c=class{constructor(t){e(this,`_value`,void 0),e(this,`_rawValue`,void 0),e(this,`dep`,void 0),o(this),this._rawValue=t,this._value=r(t)}get value(){return this.dep||(this.dep=new Set),t(this.dep),this._value}set value(e){Object.is(e,this._rawValue)||(this._rawValue=e,this._value=r(e),this.dep&&n(this.dep))}};function l(e){return s(e)?e:i(new c(e))}function u(e){return s(e)?e.value:e}function d(e){return typeof e==`function`?e():u(e)}var f=class{constructor(r,i){e(this,`_getValue`,void 0),e(this,`_setValue`,void 0),e(this,`dep`,void 0),o(this);let a=i,s=()=>{this.dep||(this.dep=new Set),t(this.dep)},c=()=>{this.dep&&n(this.dep)},l=e=>e===void 0&&a!==void 0?a:e;if(typeof r==`function`){let e=r(s,c);this._getValue=()=>l(e.get()),this._setValue=t=>e.set(t);return}let u=r;this._getValue=()=>(s(),l(u.get())),this._setValue=e=>{u.set(e),c()}}get value(){return this._getValue()}set value(e){this._setValue(e)}};function p(e,t){return i(new f(e,t))}export{a as RefFlag,p as customRef,s as isRef,o as markAsRef,l as ref,d as toValue,u as unref};
1
+ import e from"../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/defineProperty.mjs";import{trackEffects as t,triggerEffects as n}from"./core.mjs";import{convertToReactive as r,markRaw as i}from"./reactive.mjs";const a=`__v_isRef`;function o(e){try{Object.defineProperty(e,a,{value:!0,configurable:!0})}catch(t){e[a]=!0}return e}function s(e){return!!(e&&typeof e==`object`&&e.__v_isRef===!0)}var c=class{constructor(t){e(this,`_value`,void 0),e(this,`_rawValue`,void 0),e(this,`dep`,void 0),o(this),this._rawValue=t,this._value=r(t)}get value(){return this.dep||(this.dep=/* @__PURE__ */ new Set),t(this.dep),this._value}set value(e){Object.is(e,this._rawValue)||(this._rawValue=e,this._value=r(e),this.dep&&n(this.dep))}};function l(e){return s(e)?e:i(new c(e))}function u(e){return s(e)?e.value:e}function d(e){return typeof e==`function`?e():u(e)}var f=class{constructor(r,i){e(this,`_getValue`,void 0),e(this,`_setValue`,void 0),e(this,`dep`,void 0),o(this);let a=i,s=()=>{this.dep||(this.dep=/* @__PURE__ */ new Set),t(this.dep)},c=()=>{this.dep&&n(this.dep)},l=e=>e===void 0&&a!==void 0?a:e;if(typeof r==`function`){let e=r(s,c);this._getValue=()=>l(e.get()),this._setValue=t=>e.set(t);return}let u=r;this._getValue=()=>(s(),l(u.get())),this._setValue=e=>{u.set(e),c()}}get value(){return this._getValue()}set value(e){this._setValue(e)}};function p(e,t){return i(new f(e,t))}export{a as RefFlag,p as customRef,s as isRef,o as markAsRef,l as ref,d as toValue,u as unref};
@@ -1 +1 @@
1
- import{isObject as e,toRaw as t}from"./reactive/shared.mjs";import{isReactive as n}from"./reactive.mjs";import{isRef as r}from"./ref.mjs";function i(a,o=1/0,s=new Map){if(o<=0||!e(a))return a;if(r(a))return i(a.value,o-1,s),a;if(a.__r_skip)return a;let c=s.get(a);if(c!==void 0&&c>=o)return a;s.set(a,o);let l=o-1;if(Array.isArray(a)||a instanceof Map||a instanceof Set)return a.forEach(e=>i(e,l,s)),a;let u=n(a)&&o!==1/0?t(a):a;for(let e in u)i(a[e],l,s);return a}export{i as traverse};
1
+ import{isObject as e,toRaw as t}from"./reactive/shared.mjs";import{isReactive as n}from"./reactive.mjs";import{isRef as r}from"./ref.mjs";function i(a,o=1/0,s=/* @__PURE__ */ new Map){if(o<=0||!e(a))return a;if(r(a))return i(a.value,o-1,s),a;if(a.__r_skip)return a;let c=s.get(a);if(c!==void 0&&c>=o)return a;s.set(a,o);let l=o-1;if(Array.isArray(a)||a instanceof Map||a instanceof Set)return a.forEach(e=>i(e,l,s)),a;let u=n(a)&&o!==1/0?t(a):a;for(let e in u)i(a[e],l,s);return a}export{i as traverse};
@@ -1 +1 @@
1
- import{getCurrentMiniProgramTabBarPagePaths as e,getMiniProgramGlobalObject as t}from"../runtime/platform.mjs";import{setActiveRouter as n}from"./instance.mjs";import{DEFAULT_INITIAL_NAVIGATION_TIMEOUT as r,registerInitialNavigationRunner as i}from"./initialNavigation.mjs";import{installRouteStateSyncOnNativeRouter as a,notifyRouteStateSync as o}from"./routeSync.mjs";import{resolvePath as ee}from"../routerInternal/path.mjs";import{parseQuery as te,stringifyQuery as ne}from"../routerInternal/query.mjs";import{resolveCurrentRoute as re}from"../routerInternal/location.mjs";import{resolveNamedRouteLocation as s}from"../routerInternal/params.mjs";import{mergeMatchedRouteMeta as ie,resolveMatchedRouteRecord as ae}from"../routerInternal/matching.mjs";import{warnDuplicateRouteEntries as oe}from"../routerInternal/recordsWarnings.mjs";import{createNamedRouteLookup as se,resolveRouteOptionEntries as ce}from"../routerInternal/records.mjs";import{cloneRouteMeta as le,cloneRouteParams as ue,createNativeRouteUrl as de,createRouterOptionsSnapshot as fe,normalizeRouteRecordMatched as pe,snapshotRouteLocation as c}from"../routerInternal/snapshots.mjs";import{NavigationFailureType as me}from"./types.mjs";import{createNavigationFailure as l,executeNavigationMethod as u}from"./navigationCore.mjs";import{createNavigationResultController as d}from"./navigationResult.mjs";import{resolveBackNavigationTarget as f,runBackNavigationGuards as he}from"./backNavigation.mjs";import{navigateWithTarget as ge}from"./navigationTarget.mjs";import{createNavigationApi as _e}from"./navigationApi.mjs";import{resolveRouteLocation as ve}from"./resolve.mjs";import{createRouteRegistry as ye}from"./routeRegistry.mjs";import{createRouteStateController as p,useNativeRouter as m}from"./useRoute.mjs";function h(h={}){var g,_,v,y,b,x,S;let C=m();a(t());let w=new Set,T=new Set,E=new Set,D=new Set,O=(g=h.maxRedirects)==null?10:g,k=h.initialNavigationMode===`blocking`?`blocking`:`eager`,A=Number.isFinite(h.initialNavigationTimeout)&&((_=h.initialNavigationTimeout)==null?0:_)>0?Math.max(1,Math.trunc(h.initialNavigationTimeout)):r,j=(v=h.paramsMode)==null?`loose`:v,M=(y=h.rejectOnError)==null||y,N={parseQuery:(b=h.parseQuery)==null?te:b,stringifyQuery:(x=h.stringifyQuery)==null?ne:x},P=Promise.resolve(),F=ce(h);oe(F);let I=se(F),L=((S=h.tabBarEntries)==null?e():S).map(e=>ee(e,``)).filter(Boolean),R=new Set(L),z=ye(I),B=0,V,H,U,be=fe(L,z.getRoutes(),j,O,k,A,N,M);function W(e){let t={...e};t.href=t.fullPath;let n=ae(t,I);if(n){let e=n.record;t.name===void 0&&(t.name=e.name);let r=ie(n.matchedRecords);r!==void 0&&(t.meta=le(r)),n.params&&Object.keys(t.params).length===0&&(t.params=ue(n.params)),t.matched=n.matchedRecords.map((e,t,r)=>{let i=t===r.length-1?n.matchedPath:void 0;return pe(e,i)})}else t.matched=[];return t}function G(e,t){let n=typeof e==`string`?e:s(e,I,j);return W(ve(n,t,N))}let K,q;function xe(e){return e.source===`page`||e.source===`native`&&e.method===`navigateBack`}function J(e,t){if(B>0||!xe(t)||U!==void 0)return;if(H!==void 0){let t=H;if(H=void 0,e.fullPath===t)return}if(e.fullPath===K.fullPath)return;U=e.fullPath;let n=c(K);he({target:e,from:n,nativeRouter:C,beforeEachGuards:w,beforeResolveGuards:T,resolveWithCodec:G}).then(e=>q==null?void 0:q(e)).finally(()=>{U=void 0})}K=p({beforeRouteStateSync:J,resolveRoute:W}).route;function Se(e){return G(e,K.path)}let Y=d({afterEachHooks:E,errorHandlers:D,nativeRouter:C,rejectOnError:M});q=Y.emitNavigationAfterEach;let X=_e({nativeRouter:C,route:K,routeResolveCodec:N,namedRouteLookup:I,beforeEachGuards:w,beforeResolveGuards:T,maxRedirects:O,tabBarPathSet:R,resolveWithCodec:G,settleNavigationResult:Y.settleNavigationResult});async function Z(e,t){let n=K.fullPath;t&&(V=t),B+=1;try{let t=await e();return K.fullPath!==n&&(H=K.fullPath),t}finally{--B,B<=0&&(V=void 0)}}function Q(e){try{return G(e,K.path).fullPath}catch(e){return}}async function Ce(e,t,n=()=>!0){return Z(async()=>{let r=c(K),i=W(re(t,e));if(!i.path)return;if(V===i.fullPath){o({route:i,source:`router`});return}let a=await ge({mode:`push`,target:i,from:r,nativeRouter:C,routeResolveCodec:N,namedRouteLookup:I,beforeEachGuards:w,beforeResolveGuards:T,maxRedirects:O,tabBarPathSet:R,resolveWithCodec:G,executeNative:!1,allowSameLocation:!0});if(n()){if(k===`blocking`&&a.to&&a.to.fullPath!==i.fullPath){let e=a.to,t=R.has(e.path)?C.switchTab:C.redirectTo;return await u(t,{url:de(e,N.stringifyQuery)},e,r)||(o({route:e,source:`router`}),l(me.cancelled,e,r))}return Y.settleNavigationResult(a)}})}function we(e){return w.add(e),()=>{w.delete(e)}}function Te(e){return T.add(e),()=>{T.delete(e)}}function Ee(e){return E.add(e),()=>{E.delete(e)}}function De(e){return D.add(e),()=>{D.delete(e)}}let $={nativeRouter:C,options:be,currentRoute:K,install(e){var t;n($);let r=e==null||(t=e.config)==null?void 0:t.globalProperties;r&&(r.$router=$)},resolve:Se,isReady(){return P},push:e=>Z(()=>X.push(e),Q(e)),replace:e=>Z(()=>X.replace(e),Q(e)),back:e=>{var t;return Z(()=>X.back(e),(t=f(e==null?1:e,K,G))==null?void 0:t.fullPath)},go:e=>{var t;return Z(()=>X.go(e),e<0?(t=f(Math.abs(e),K,G))==null?void 0:t.fullPath:void 0)},forward:()=>Z(()=>X.forward()),hasRoute:z.hasRoute,getRoutes:z.getRoutes,addRoute:z.addRoute,removeRoute:z.removeRoute,clearRoutes:z.clearRoutes,beforeEach:we,beforeResolve:Te,afterEach:Ee,onError:De};return n($),i($,Ce,A,k),$}export{h as createRouter};
1
+ import{getCurrentMiniProgramTabBarPagePaths as e,getMiniProgramGlobalObject as t}from"../runtime/platform.mjs";import{setActiveRouter as n}from"./instance.mjs";import{DEFAULT_INITIAL_NAVIGATION_TIMEOUT as r,registerInitialNavigationRunner as i}from"./initialNavigation.mjs";import{installRouteStateSyncOnNativeRouter as a,notifyRouteStateSync as o}from"./routeSync.mjs";import{resolvePath as ee}from"../routerInternal/path.mjs";import{parseQuery as te,stringifyQuery as ne}from"../routerInternal/query.mjs";import{resolveCurrentRoute as re}from"../routerInternal/location.mjs";import{resolveNamedRouteLocation as s}from"../routerInternal/params.mjs";import{mergeMatchedRouteMeta as ie,resolveMatchedRouteRecord as ae}from"../routerInternal/matching.mjs";import{warnDuplicateRouteEntries as oe}from"../routerInternal/recordsWarnings.mjs";import{createNamedRouteLookup as se,resolveRouteOptionEntries as ce}from"../routerInternal/records.mjs";import{cloneRouteMeta as le,cloneRouteParams as ue,createNativeRouteUrl as de,createRouterOptionsSnapshot as fe,normalizeRouteRecordMatched as pe,snapshotRouteLocation as c}from"../routerInternal/snapshots.mjs";import{NavigationFailureType as me}from"./types.mjs";import{createNavigationFailure as l,executeNavigationMethod as u}from"./navigationCore.mjs";import{createNavigationResultController as d}from"./navigationResult.mjs";import{resolveBackNavigationTarget as f,runBackNavigationGuards as he}from"./backNavigation.mjs";import{navigateWithTarget as ge}from"./navigationTarget.mjs";import{createNavigationApi as _e}from"./navigationApi.mjs";import{resolveRouteLocation as ve}from"./resolve.mjs";import{createRouteRegistry as ye}from"./routeRegistry.mjs";import{createRouteStateController as p,useNativeRouter as m}from"./useRoute.mjs";function h(h={}){var g,_,v,y,b,x,S;let C=m();a(t());let w=/* @__PURE__ */ new Set,T=/* @__PURE__ */ new Set,E=/* @__PURE__ */ new Set,D=/* @__PURE__ */ new Set,O=(g=h.maxRedirects)==null?10:g,k=h.initialNavigationMode===`blocking`?`blocking`:`eager`,A=Number.isFinite(h.initialNavigationTimeout)&&((_=h.initialNavigationTimeout)==null?0:_)>0?Math.max(1,Math.trunc(h.initialNavigationTimeout)):r,j=(v=h.paramsMode)==null?`loose`:v,M=(y=h.rejectOnError)==null||y,N={parseQuery:(b=h.parseQuery)==null?te:b,stringifyQuery:(x=h.stringifyQuery)==null?ne:x},P=Promise.resolve(),F=ce(h);oe(F);let I=se(F),L=((S=h.tabBarEntries)==null?e():S).map(e=>ee(e,``)).filter(Boolean),R=new Set(L),z=ye(I),B=0,V,H,U,be=fe(L,z.getRoutes(),j,O,k,A,N,M);function W(e){let t={...e};t.href=t.fullPath;let n=ae(t,I);if(n){let e=n.record;t.name===void 0&&(t.name=e.name);let r=ie(n.matchedRecords);r!==void 0&&(t.meta=le(r)),n.params&&Object.keys(t.params).length===0&&(t.params=ue(n.params)),t.matched=n.matchedRecords.map((e,t,r)=>{let i=t===r.length-1?n.matchedPath:void 0;return pe(e,i)})}else t.matched=[];return t}function G(e,t){let n=typeof e==`string`?e:s(e,I,j);return W(ve(n,t,N))}let K,q;function xe(e){return e.source===`page`||e.source===`native`&&e.method===`navigateBack`}function J(e,t){if(B>0||!xe(t)||U!==void 0)return;if(H!==void 0){let t=H;if(H=void 0,e.fullPath===t)return}if(e.fullPath===K.fullPath)return;U=e.fullPath;let n=c(K);he({target:e,from:n,nativeRouter:C,beforeEachGuards:w,beforeResolveGuards:T,resolveWithCodec:G}).then(e=>q==null?void 0:q(e)).finally(()=>{U=void 0})}K=p({beforeRouteStateSync:J,resolveRoute:W}).route;function Se(e){return G(e,K.path)}let Y=d({afterEachHooks:E,errorHandlers:D,nativeRouter:C,rejectOnError:M});q=Y.emitNavigationAfterEach;let X=_e({nativeRouter:C,route:K,routeResolveCodec:N,namedRouteLookup:I,beforeEachGuards:w,beforeResolveGuards:T,maxRedirects:O,tabBarPathSet:R,resolveWithCodec:G,settleNavigationResult:Y.settleNavigationResult});async function Z(e,t){let n=K.fullPath;t&&(V=t),B+=1;try{let t=await e();return K.fullPath!==n&&(H=K.fullPath),t}finally{--B,B<=0&&(V=void 0)}}function Q(e){try{return G(e,K.path).fullPath}catch(e){return}}async function Ce(e,t,n=()=>!0){return Z(async()=>{let r=c(K),i=W(re(t,e));if(!i.path)return;if(V===i.fullPath){o({route:i,source:`router`});return}let a=await ge({mode:`push`,target:i,from:r,nativeRouter:C,routeResolveCodec:N,namedRouteLookup:I,beforeEachGuards:w,beforeResolveGuards:T,maxRedirects:O,tabBarPathSet:R,resolveWithCodec:G,executeNative:!1,allowSameLocation:!0});if(n()){if(k===`blocking`&&a.to&&a.to.fullPath!==i.fullPath){let e=a.to,t=R.has(e.path)?C.switchTab:C.redirectTo;return await u(t,{url:de(e,N.stringifyQuery)},e,r)||(o({route:e,source:`router`}),l(me.cancelled,e,r))}return Y.settleNavigationResult(a)}})}function we(e){return w.add(e),()=>{w.delete(e)}}function Te(e){return T.add(e),()=>{T.delete(e)}}function Ee(e){return E.add(e),()=>{E.delete(e)}}function De(e){return D.add(e),()=>{D.delete(e)}}let $={nativeRouter:C,options:be,currentRoute:K,install(e){var t;n($);let r=e==null||(t=e.config)==null?void 0:t.globalProperties;r&&(r.$router=$)},resolve:Se,isReady(){return P},push:e=>Z(()=>X.push(e),Q(e)),replace:e=>Z(()=>X.replace(e),Q(e)),back:e=>{var t;return Z(()=>X.back(e),(t=f(e==null?1:e,K,G))==null?void 0:t.fullPath)},go:e=>{var t;return Z(()=>X.go(e),e<0?(t=f(Math.abs(e),K,G))==null?void 0:t.fullPath:void 0)},forward:()=>Z(()=>X.forward()),hasRoute:z.hasRoute,getRoutes:z.getRoutes,addRoute:z.addRoute,removeRoute:z.removeRoute,clearRoutes:z.clearRoutes,beforeEach:we,beforeResolve:Te,afterEach:Ee,onError:De};return n($),i($,Ce,A,k),$}export{h as createRouter};
@@ -1 +1 @@
1
- import{getActiveRouter as e}from"./instance.mjs";import{WEVU_INITIAL_NAVIGATION_TIMEOUT_MARKER as t}from"@weapp-core/constants";import{queueMicrotaskPolyfill as n}from"@wevu/web-apis";const r=1e4,i=new WeakMap,a=new WeakMap;function o(e){return Number.isFinite(e)&&e>0?Math.max(1,Math.trunc(e)):r}function s(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 c(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 l(e,t,n=r,a=`blocking`){i.set(e,{runner:t,mode:a,timeoutMs:o(n)})}function u(){var t,n;let a=e();return a?(t=(n=i.get(a))==null?void 0:n.timeoutMs)==null?r:t:r}function d(e){return!!(e&&typeof e==`object`&&e.__wevuNavigationFailure)}function f(r,o,l={}){let f=a.get(r);if(f)return l.onComplete&&f.blocking&&f.subscribe(l.onComplete),l.start!==!1&&f.start(o),f.blocking?f.promise:void 0;let p=e(),m=p?i.get(p):void 0,h=m==null?void 0:m.runner;if(!h)return;let g=(m==null?void 0:m.mode)===`blocking`,_=s(r),v=c(o),y=`idle`,b,x=u(),S,C=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 r=[...C];C.clear(),h=void 0,_=void 0,v=void 0,S(t),n(()=>{if(y===`allowed`||y===`timed-out`)for(let e of r)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`?n(()=>{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(()=>{var e,n;y===`running`&&(console.warn(`${t} initial navigation exceeded ${x}ms; mounting page`,(e=(n=_==null?void 0:_.route)==null?_==null?void 0:_.__route__:n)==null?``:e),T(`timed-out`,!0))},x));let n=_,r=c(e==null?v:e),i=h;if(h=void 0,!i||!n){T(`aborted`,!1);return}i(n,r,()=>y===`running`).then(e=>{let t=d(e);T(t?`aborted`:`allowed`,!t)},()=>{T(`aborted`,!1)})},cancel(){T(`cancelled`,!1)}};return a.set(r,E),l.onComplete&&g&&E.subscribe(l.onComplete),l.start!==!1&&E.start(o),g?w:void 0}function p(e){var t;(t=a.get(e))==null||t.cancel()}export{r as DEFAULT_INITIAL_NAVIGATION_TIMEOUT,p as cancelInitialNavigation,f as ensureInitialNavigation,u as getInitialNavigationTimeout,l as registerInitialNavigationRunner};
1
+ import{getActiveRouter as e}from"./instance.mjs";import{WEVU_INITIAL_NAVIGATION_TIMEOUT_MARKER as t}from"@weapp-core/constants";import{queueMicrotaskPolyfill as n}from"@wevu/web-apis";const r=1e4,i=/* @__PURE__ */ new WeakMap,a=/* @__PURE__ */ new WeakMap;function o(e){return Number.isFinite(e)&&e>0?Math.max(1,Math.trunc(e)):r}function s(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 c(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 l(e,t,n=r,a=`blocking`){i.set(e,{runner:t,mode:a,timeoutMs:o(n)})}function u(){var t,n;let a=e();return a?(t=(n=i.get(a))==null?void 0:n.timeoutMs)==null?r:t:r}function d(e){return!!(e&&typeof e==`object`&&e.__wevuNavigationFailure)}function f(r,o,l={}){let f=a.get(r);if(f)return l.onComplete&&f.blocking&&f.subscribe(l.onComplete),l.start!==!1&&f.start(o),f.blocking?f.promise:void 0;let p=e(),m=p?i.get(p):void 0,h=m==null?void 0:m.runner;if(!h)return;let g=(m==null?void 0:m.mode)===`blocking`,_=s(r),v=c(o),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 r=[...C];C.clear(),h=void 0,_=void 0,v=void 0,S(t),n(()=>{if(y===`allowed`||y===`timed-out`)for(let e of r)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`?n(()=>{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(()=>{var e,n;y===`running`&&(console.warn(`${t} initial navigation exceeded ${x}ms; mounting page`,(e=(n=_==null?void 0:_.route)==null?_==null?void 0:_.__route__:n)==null?``:e),T(`timed-out`,!0))},x));let n=_,r=c(e==null?v:e),i=h;if(h=void 0,!i||!n){T(`aborted`,!1);return}i(n,r,()=>y===`running`).then(e=>{let t=d(e);T(t?`aborted`:`allowed`,!t)},()=>{T(`aborted`,!1)})},cancel(){T(`cancelled`,!1)}};return a.set(r,E),l.onComplete&&g&&E.subscribe(l.onComplete),l.start!==!1&&E.start(o),g?w:void 0}function p(e){var t;(t=a.get(e))==null||t.cancel()}export{r as DEFAULT_INITIAL_NAVIGATION_TIMEOUT,p as cancelInitialNavigation,f as ensureInitialNavigation,u as getInitialNavigationTimeout,l as registerInitialNavigationRunner};
@@ -1 +1 @@
1
- import{getCurrentMiniProgramPages as e}from"../runtime/platform.mjs";const t=[`switchTab`,`reLaunch`,`redirectTo`,`navigateTo`,`navigateBack`],n=new Set,r=new WeakSet;function i(e){return n.add(e),()=>{n.delete(e)}}function a(e){for(let t of n)try{t(e)}catch(e){}}function o(e,t,n){if(e===`navigateBack`)return{method:e,source:`native`};if(t&&typeof t==`object`){let r=t.url;if(typeof r==`string`)return{method:e,page:n,source:`native`,url:r}}return{method:e,page:n,source:`native`}}function s(n){if(!n||typeof n!=`object`)return;let i=n;if(!r.has(i)){r.add(i);for(let n of t){let t=i[n];typeof t==`function`&&(i[n]=function(r,...i){let s=e(),c=s[s.length-1],l=!1,u=()=>{l||(l=!0,a(o(n,r,c)))},d=r&&typeof r==`object`?{...r,success:(...e)=>{u();let t=r.success;return typeof t==`function`?t(...e):void 0}}:r,f=t.call(this,d,...i);return f&&typeof f.then==`function`&&f.then(u,()=>{}),f})}}}export{s as installRouteStateSyncOnNativeRouter,a as notifyRouteStateSync,i as registerRouteStateSyncHandler};
1
+ import{getCurrentMiniProgramPages as e}from"../runtime/platform.mjs";const t=[`switchTab`,`reLaunch`,`redirectTo`,`navigateTo`,`navigateBack`],n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new WeakSet;function i(e){return n.add(e),()=>{n.delete(e)}}function a(e){for(let t of n)try{t(e)}catch(e){}}function o(e,t,n){if(e===`navigateBack`)return{method:e,source:`native`};if(t&&typeof t==`object`){let r=t.url;if(typeof r==`string`)return{method:e,page:n,source:`native`,url:r}}return{method:e,page:n,source:`native`}}function s(n){if(!n||typeof n!=`object`)return;let i=n;if(!r.has(i)){r.add(i);for(let n of t){let t=i[n];typeof t==`function`&&(i[n]=function(r,...i){let s=e(),c=s[s.length-1],l=!1,u=()=>{l||(l=!0,a(o(n,r,c)))},d=r&&typeof r==`object`?{...r,success:(...e)=>{u();let t=r.success;return typeof t==`function`?t(...e):void 0}}:r,f=t.call(this,d,...i);return f&&typeof f.then==`function`&&f.then(u,()=>{}),f})}}}export{s as installRouteStateSyncOnNativeRouter,a as notifyRouteStateSync,i as registerRouteStateSyncHandler};
@@ -1 +1 @@
1
- import{isDynamicRoutePath as e}from"./path.mjs";import{decodeRouteParamSegment as t,parsePathParamToken as n}from"./params.mjs";function r(e){return e.split(`/`).filter(Boolean)}function i(e){return[e.path,...e.aliasPaths]}function a(e,t){let n=[],r=new Set,i=e;for(;i&&!(r.has(i.name)||(r.add(i.name),n.unshift(i),!i.parentName));)i=t.recordByName.get(i.parentName);return n}function o(e){let t;for(let n of e)n.meta&&(t||(t={}),Object.assign(t,n.meta));return t}function s(e,t){let n=new Set;if(!t.has(e))return n;n.add(e);let r=!0;for(;r;){r=!1;for(let[e,i]of t.entries())i.parentName&&!n.has(e)&&n.has(i.parentName)&&(n.add(e),r=!0)}return n}function c(e){let t={};for(let[n,r]of e.entries())r.length!==0&&(t[n]=r.length===1?r[0]:r);return t}function l(e,i){let a=r(e),o=r(i),s=new Map,l=(e,t)=>{let n=s.get(e);if(n){n.push(t);return}s.set(e,[t])},u=e=>{let t=s.get(e);t&&t.length!==0&&(t.pop(),t.length===0&&s.delete(e))},d=(e,n,r)=>{for(let i=0;i<r;i+=1)l(e,t(o[n+i]));return()=>{for(let t=0;t<r;t+=1)u(e)}},f=(e,r)=>{if(e>=a.length)return r>=o.length;let i=a[e],s=n(i);if(!s)return r>=o.length||i!==o[r]?!1:f(e+1,r+1);if(s.modifier===``){if(r>=o.length)return!1;l(s.key,t(o[r]));let n=f(e+1,r+1);return n||u(s.key),n}if(s.modifier===`?`){if(r<o.length){if(l(s.key,t(o[r])),f(e+1,r+1))return!0;u(s.key)}return f(e+1,r)}let c=+(s.modifier===`+`),p=o.length-r;for(let t=p;t>=c;--t){let n=d(s.key,r,t);if(f(e+1,r+t))return!0;n()}return!1};if(f(0,0))return c(s)}function u(t,n){if(t.name){let e=n.recordByName.get(t.name);if(e)return{record:e,matchedRecords:a(e,n)}}let r=n.nameByStaticPath.get(t.path);if(r){let e=n.recordByName.get(r);if(e)return{record:e,matchedRecords:a(e,n),matchedPath:t.path}}for(let r of n.recordByName.values())for(let o of i(r)){if(!e(o))continue;let i=l(o,t.path);if(i)return{record:r,matchedRecords:a(r,n),matchedPath:o,params:i}}}export{s as collectRouteNamesForRemoval,o as mergeMatchedRouteMeta,u as resolveMatchedRouteRecord};
1
+ import{isDynamicRoutePath as e}from"./path.mjs";import{decodeRouteParamSegment as t,parsePathParamToken as n}from"./params.mjs";function r(e){return e.split(`/`).filter(Boolean)}function i(e){return[e.path,...e.aliasPaths]}function a(e,t){let n=[],r=/* @__PURE__ */ new Set,i=e;for(;i&&!(r.has(i.name)||(r.add(i.name),n.unshift(i),!i.parentName));)i=t.recordByName.get(i.parentName);return n}function o(e){let t;for(let n of e)n.meta&&(t||(t={}),Object.assign(t,n.meta));return t}function s(e,t){let n=/* @__PURE__ */ new Set;if(!t.has(e))return n;n.add(e);let r=!0;for(;r;){r=!1;for(let[e,i]of t.entries())i.parentName&&!n.has(e)&&n.has(i.parentName)&&(n.add(e),r=!0)}return n}function c(e){let t={};for(let[n,r]of e.entries())r.length!==0&&(t[n]=r.length===1?r[0]:r);return t}function l(e,i){let a=r(e),o=r(i),s=/* @__PURE__ */ new Map,l=(e,t)=>{let n=s.get(e);if(n){n.push(t);return}s.set(e,[t])},u=e=>{let t=s.get(e);t&&t.length!==0&&(t.pop(),t.length===0&&s.delete(e))},d=(e,n,r)=>{for(let i=0;i<r;i+=1)l(e,t(o[n+i]));return()=>{for(let t=0;t<r;t+=1)u(e)}},f=(e,r)=>{if(e>=a.length)return r>=o.length;let i=a[e],s=n(i);if(!s)return r>=o.length||i!==o[r]?!1:f(e+1,r+1);if(s.modifier===``){if(r>=o.length)return!1;l(s.key,t(o[r]));let n=f(e+1,r+1);return n||u(s.key),n}if(s.modifier===`?`){if(r<o.length){if(l(s.key,t(o[r])),f(e+1,r+1))return!0;u(s.key)}return f(e+1,r)}let c=+(s.modifier===`+`),p=o.length-r;for(let t=p;t>=c;--t){let n=d(s.key,r,t);if(f(e+1,r+t))return!0;n()}return!1};if(f(0,0))return c(s)}function u(t,n){if(t.name){let e=n.recordByName.get(t.name);if(e)return{record:e,matchedRecords:a(e,n)}}let r=n.nameByStaticPath.get(t.path);if(r){let e=n.recordByName.get(r);if(e)return{record:e,matchedRecords:a(e,n),matchedPath:t.path}}for(let r of n.recordByName.values())for(let o of i(r)){if(!e(o))continue;let i=l(o,t.path);if(i)return{record:r,matchedRecords:a(r,n),matchedPath:o,params:i}}}export{s as collectRouteNamesForRemoval,o as mergeMatchedRouteMeta,u as resolveMatchedRouteRecord};
@@ -1 +1 @@
1
- import{normalizeRouteParams as e}from"./query.mjs";const t=/^:(\w+)(?:\([^)]*\))?([+*?])?$/;function n(e){var n;let r=t.exec(e);if(r)return{key:r[1],modifier:(n=r[2])==null?``:n}}function r(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function i(e){return encodeURIComponent(e)}function a(e){try{return decodeURIComponent(e)}catch(t){return e}}function o(e,t,a){let o=[],s=new Set;for(let c of e.split(`/`)){if(!c)continue;let e=n(c);if(!e){o.push(c);continue}let l=r(t[e.key]);if(e.modifier===``){if(l.length!==1)throw Error(`Missing required param "${e.key}" for named route "${a}"`);s.add(e.key),o.push(i(l[0]));continue}if(e.modifier===`?`){if(l.length===0)continue;if(l.length>1)throw Error(`Param "${e.key}" for named route "${a}" must be a single value`);s.add(e.key),o.push(i(l[0]));continue}if(e.modifier===`+`){if(l.length===0)throw Error(`Missing required repeatable param "${e.key}" for named route "${a}"`);s.add(e.key);for(let e of l)o.push(i(e));continue}l.length>0&&s.add(e.key);for(let e of l)o.push(i(e))}return{path:o.join(`/`),consumedKeys:s}}function s(e){return e===void 0?!1:!Array.isArray(e)||e.length>0}function c(e,t,n){let r=Object.keys(e).filter(e=>!t.has(e)).filter(t=>s(e[t]));if(r.length!==0)throw Error(`Unexpected params for named route "${n}": ${r.join(`, `)}`)}function l(t,n,r){let i=t.name;if(typeof i!=`string`||!i||t.path!==void 0||t.fullPath!==void 0)return t;let a=n.recordByName.get(i);if(!a)throw Error(`Named route "${i}" is not defined in createRouter({ routes | namedRoutes })`);let s=t.params?e(t.params):{},l=o(a.path,s,i);return r===`strict`&&c(s,l.consumedKeys,i),{...t,path:l.path?`/${l.path}`:`/`,params:s}}export{a as decodeRouteParamSegment,n as parsePathParamToken,l as resolveNamedRouteLocation};
1
+ import{normalizeRouteParams as e}from"./query.mjs";const t=/^:(\w+)(?:\([^)]*\))?([+*?])?$/;function n(e){var n;let r=t.exec(e);if(r)return{key:r[1],modifier:(n=r[2])==null?``:n}}function r(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function i(e){return encodeURIComponent(e)}function a(e){try{return decodeURIComponent(e)}catch(t){return e}}function o(e,t,a){let o=[],s=/* @__PURE__ */ new Set;for(let c of e.split(`/`)){if(!c)continue;let e=n(c);if(!e){o.push(c);continue}let l=r(t[e.key]);if(e.modifier===``){if(l.length!==1)throw Error(`Missing required param "${e.key}" for named route "${a}"`);s.add(e.key),o.push(i(l[0]));continue}if(e.modifier===`?`){if(l.length===0)continue;if(l.length>1)throw Error(`Param "${e.key}" for named route "${a}" must be a single value`);s.add(e.key),o.push(i(l[0]));continue}if(e.modifier===`+`){if(l.length===0)throw Error(`Missing required repeatable param "${e.key}" for named route "${a}"`);s.add(e.key);for(let e of l)o.push(i(e));continue}l.length>0&&s.add(e.key);for(let e of l)o.push(i(e))}return{path:o.join(`/`),consumedKeys:s}}function s(e){return e===void 0?!1:!Array.isArray(e)||e.length>0}function c(e,t,n){let r=Object.keys(e).filter(e=>!t.has(e)).filter(t=>s(e[t]));if(r.length!==0)throw Error(`Unexpected params for named route "${n}": ${r.join(`, `)}`)}function l(t,n,r){let i=t.name;if(typeof i!=`string`||!i||t.path!==void 0||t.fullPath!==void 0)return t;let a=n.recordByName.get(i);if(!a)throw Error(`Named route "${i}" is not defined in createRouter({ routes | namedRoutes })`);let s=t.params?e(t.params):{},l=o(a.path,s,i);return r===`strict`&&c(s,l.consumedKeys,i),{...t,path:l.path?`/${l.path}`:`/`,params:s}}export{a as decodeRouteParamSegment,n as parsePathParamToken,l as resolveNamedRouteLocation};
@@ -1 +1 @@
1
- import{createAbsoluteRoutePath as e,isDynamicRoutePath as t,resolvePath as n}from"./path.mjs";import{warnRouteConfig as r}from"./recordsWarnings.mjs";function i(e){return e?Array.isArray(e)?e:[e]:[]}function a(e,t,n=`namedRoutes`){return typeof e.name==`string`&&e.name.trim()?e.name.trim():n===`routes`?t||`/`:``}function o(e,t){if(!e)return[];let r=Array.isArray(e)?e:[e],i=[];for(let e of r){if(typeof e!=`string`)continue;let r=n(e,``);r&&r!==t&&(i.includes(r)||i.push(r))}return i}function s(e,t,r=`namedRoutes`){let s=n(e.path,``);if(!s&&e.path!==`/`)return;let c=a(e,s,r);if(c)return{name:c,path:s,aliasPaths:o(e.alias,s),parentName:t,meta:e.meta,beforeEnterGuards:i(e.beforeEnter),redirect:e.redirect}}function c(t,r){return!r||t.startsWith(`/`)?n(t,``):n(`${e(r)}/${t}`,``)}function l(e){return e?Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):typeof e==`string`&&e.length>0?[e]:[]:[]}function u(e){let t=[];for(let n of e)n&&!t.includes(n)&&t.push(n);return t}function d(t){if(t.length!==0)return t.length===1?e(t[0]):t.map(t=>e(t))}function f(t,n,i,o=[],s,p=`namedRoutes`,m=new Set){let h=[];for(let[g,_]of t.entries()){let t=`${p}[${g}]`;if(m.has(_)){r(`ignored route record at ${t}: detected circular children reference`);continue}if(typeof _.path!=`string`||!_.path){let e=typeof(_==null?void 0:_.name)==`string`?_.name.trim():``;r(`ignored route record "${e}" at ${t}: route path is required`);continue}let v=c(_.path,n),y=a(_,v,s);if(!y){r(`ignored route record at ${t}: route name is required`);continue}let b=[],x=new Map;for(let i of l(_.alias)){let a=c(i,n);if(!a)continue;if(a===v){r(`ignored alias "${e(a)}" for route "${y}" at ${t}: alias is same as route path`);continue}let o=x.get(a);if(o){r(`ignored duplicate alias "${e(a)}" for route "${y}" at ${t}: already declared by "${o}"`);continue}x.set(a,i),b.push(a)}let S=_.path.startsWith(`/`)?[]:o.map(e=>c(_.path,e)).filter(Boolean).filter(e=>e!==v),C=u([...b,...S]),w={name:y,path:v?e(v):`/`,alias:d(C),meta:_.meta,beforeEnter:_.beforeEnter,redirect:_.redirect};if(h.push({route:w,parentName:i,source:s}),Array.isArray(_.children)&&_.children.length>0){let e=new Set(m);e.add(_),h.push(...f(_.children,v,y,C,s,`${t}.children`,e))}}return h}function p(e,t=`namedRoutes`){if(!e)return[];if(Array.isArray(e))return f(e,void 0,void 0,[],t,t);let n=[];for(let[i,a]of Object.entries(e)){let e=typeof i==`string`?i.trim():``;if(!e){r(`ignored route record at ${t}: route name is required`);continue}if(typeof a!=`string`||!a){r(`ignored route record "${e}" at ${t}: route path is required`);continue}n.push({route:{name:e,path:a},source:t})}return n}function m(e){return[...p(e.routes,`routes`),...p(e.namedRoutes,`namedRoutes`)]}function h(e){let n=new Map;for(let[r,i]of e.entries()){!t(i.path)&&!n.has(i.path)&&n.set(i.path,r);for(let e of i.aliasPaths)!t(e)&&!n.has(e)&&n.set(e,r)}return n}function g(e){let t=new Map;for(let n of e){let e=s(n.route,n.parentName,n.source);e&&t.set(e.name,e)}return{recordByName:t,nameByStaticPath:h(t)}}export{g as createNamedRouteLookup,h as createNamedRouteNameByStaticPath,d as createRouteRecordAliasValue,f as flattenNamedRouteRecords,s as normalizeRouteRecordRaw,m as resolveRouteOptionEntries};
1
+ import{createAbsoluteRoutePath as e,isDynamicRoutePath as t,resolvePath as n}from"./path.mjs";import{warnRouteConfig as r}from"./recordsWarnings.mjs";function i(e){return e?Array.isArray(e)?e:[e]:[]}function a(e,t,n=`namedRoutes`){return typeof e.name==`string`&&e.name.trim()?e.name.trim():n===`routes`?t||`/`:``}function o(e,t){if(!e)return[];let r=Array.isArray(e)?e:[e],i=[];for(let e of r){if(typeof e!=`string`)continue;let r=n(e,``);r&&r!==t&&(i.includes(r)||i.push(r))}return i}function s(e,t,r=`namedRoutes`){let s=n(e.path,``);if(!s&&e.path!==`/`)return;let c=a(e,s,r);if(c)return{name:c,path:s,aliasPaths:o(e.alias,s),parentName:t,meta:e.meta,beforeEnterGuards:i(e.beforeEnter),redirect:e.redirect}}function c(t,r){return!r||t.startsWith(`/`)?n(t,``):n(`${e(r)}/${t}`,``)}function l(e){return e?Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):typeof e==`string`&&e.length>0?[e]:[]:[]}function u(e){let t=[];for(let n of e)n&&!t.includes(n)&&t.push(n);return t}function d(t){if(t.length!==0)return t.length===1?e(t[0]):t.map(t=>e(t))}function f(t,n,i,o=[],s,p=`namedRoutes`,m=/* @__PURE__ */ new Set){let h=[];for(let[g,_]of t.entries()){let t=`${p}[${g}]`;if(m.has(_)){r(`ignored route record at ${t}: detected circular children reference`);continue}if(typeof _.path!=`string`||!_.path){let e=typeof(_==null?void 0:_.name)==`string`?_.name.trim():``;r(`ignored route record "${e}" at ${t}: route path is required`);continue}let v=c(_.path,n),y=a(_,v,s);if(!y){r(`ignored route record at ${t}: route name is required`);continue}let b=[],x=/* @__PURE__ */ new Map;for(let i of l(_.alias)){let a=c(i,n);if(!a)continue;if(a===v){r(`ignored alias "${e(a)}" for route "${y}" at ${t}: alias is same as route path`);continue}let o=x.get(a);if(o){r(`ignored duplicate alias "${e(a)}" for route "${y}" at ${t}: already declared by "${o}"`);continue}x.set(a,i),b.push(a)}let S=_.path.startsWith(`/`)?[]:o.map(e=>c(_.path,e)).filter(Boolean).filter(e=>e!==v),C=u([...b,...S]),w={name:y,path:v?e(v):`/`,alias:d(C),meta:_.meta,beforeEnter:_.beforeEnter,redirect:_.redirect};if(h.push({route:w,parentName:i,source:s}),Array.isArray(_.children)&&_.children.length>0){let e=new Set(m);e.add(_),h.push(...f(_.children,v,y,C,s,`${t}.children`,e))}}return h}function p(e,t=`namedRoutes`){if(!e)return[];if(Array.isArray(e))return f(e,void 0,void 0,[],t,t);let n=[];for(let[i,a]of Object.entries(e)){let e=typeof i==`string`?i.trim():``;if(!e){r(`ignored route record at ${t}: route name is required`);continue}if(typeof a!=`string`||!a){r(`ignored route record "${e}" at ${t}: route path is required`);continue}n.push({route:{name:e,path:a},source:t})}return n}function m(e){return[...p(e.routes,`routes`),...p(e.namedRoutes,`namedRoutes`)]}function h(e){let n=/* @__PURE__ */ new Map;for(let[r,i]of e.entries()){!t(i.path)&&!n.has(i.path)&&n.set(i.path,r);for(let e of i.aliasPaths)!t(e)&&!n.has(e)&&n.set(e,r)}return n}function g(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=s(n.route,n.parentName,n.source);e&&t.set(e.name,e)}return{recordByName:t,nameByStaticPath:h(t)}}export{g as createNamedRouteLookup,h as createNamedRouteNameByStaticPath,d as createRouteRecordAliasValue,f as flattenNamedRouteRecords,s as normalizeRouteRecordRaw,m as resolveRouteOptionEntries};
@@ -1 +1 @@
1
- import{createAbsoluteRoutePath as e,resolvePath as t}from"./path.mjs";function n(e){typeof console>`u`||typeof console.warn!=`function`||console.warn(`[wevu/router] ${e}`)}function r(n){let r=t(n,``);return r?e(r):`/`}function i(e,t=new Set){if(t.has(e))return!0;if(!Array.isArray(e.children)||e.children.length===0)return!1;let n=new Set(t);n.add(e);for(let t of e.children)if(i(t,n))return!0;return!1}function a(e){let t=typeof e.name==`string`?e.name.trim():``;if(!t)throw Error(`Route name is required when adding a named route`);if(typeof e.path!=`string`||!e.path)throw Error(`Route path is required when adding named route "${t}"`);if(i(e))throw Error(`Circular children reference detected when adding named route "${t}"`)}function o(e){let t=new Map,i=[];for(let n of e){var a;let e=typeof n.route.name==`string`?n.route.name.trim():``;if(!e)continue;let o=(a=n.source)==null?`namedRoutes`:a,s=r(n.route.path),c=t.get(e);c&&i.push(`"${e}" (${c.source}:${c.path} -> ${o}:${s})`),t.set(e,{source:o,path:s})}i.length!==0&&n(`duplicate route names detected, later entries override earlier ones: ${i.join(`, `)}`)}export{a as assertValidAddRouteInput,o as warnDuplicateRouteEntries,n as warnRouteConfig};
1
+ import{createAbsoluteRoutePath as e,resolvePath as t}from"./path.mjs";function n(e){typeof console<`u`&&typeof console.warn==`function`&&console.warn(`[wevu/router] ${e}`)}function r(n){let r=t(n,``);return r?e(r):`/`}function i(e,t=/* @__PURE__ */ new Set){if(t.has(e))return!0;if(!Array.isArray(e.children)||e.children.length===0)return!1;let n=new Set(t);n.add(e);for(let t of e.children)if(i(t,n))return!0;return!1}function a(e){let t=typeof e.name==`string`?e.name.trim():``;if(!t)throw Error(`Route name is required when adding a named route`);if(typeof e.path!=`string`||!e.path)throw Error(`Route path is required when adding named route "${t}"`);if(i(e))throw Error(`Circular children reference detected when adding named route "${t}"`)}function o(e){let t=/* @__PURE__ */ new Map,i=[];for(let n of e){var a;let e=typeof n.route.name==`string`?n.route.name.trim():``;if(!e)continue;let o=(a=n.source)==null?`namedRoutes`:a,s=r(n.route.path),c=t.get(e);c&&i.push(`"${e}" (${c.source}:${c.path} -> ${o}:${s})`),t.set(e,{source:o,path:s})}i.length!==0&&n(`duplicate route names detected, later entries override earlier ones: ${i.join(`, `)}`)}export{a as assertValidAddRouteInput,o as warnDuplicateRouteEntries,n as warnRouteConfig};
@@ -1 +1 @@
1
- import{createComputedEffect as e,track as t,trigger as n}from"../../reactivity/core.mjs";import{markAsRef as r}from"../../reactivity/ref.mjs";function i(i){let a=Object.create(null),o=Object.create(null),s=new Set;return{computedRefs:a,computedSetters:o,dirtyComputedKeys:s,createTrackedComputed:(a,o,c)=>{let l,u=!0,d,f={get value(){return u&&(l=d(),u=!1),t(f,`value`),l},set value(e){if(!c)throw Error(`计算属性是只读的`);c(e)}};return r(f),d=e(o,{lazy:!0,scheduler:()=>{u||(u=!0,i.setDataStrategy===`patch`&&i.includeComputed&&s.add(a),n(f,`value`))}}),f},computedProxy:new Proxy({},{get(e,t){if(typeof t==`string`&&a[t])return a[t].value},has(e,t){return typeof t==`string`&&!!a[t]},ownKeys(){return Object.keys(a)},getOwnPropertyDescriptor(e,t){if(typeof t==`string`&&a[t])return{configurable:!0,enumerable:!0,value:a[t].value}}})}}export{i as createComputedAccessors};
1
+ import{createComputedEffect as e,track as t,trigger as n}from"../../reactivity/core.mjs";import{markAsRef as r}from"../../reactivity/ref.mjs";function i(i){let a=Object.create(null),o=Object.create(null),s=/* @__PURE__ */ new Set;return{computedRefs:a,computedSetters:o,dirtyComputedKeys:s,createTrackedComputed:(a,o,c)=>{let l,u=!0,d,f={get value(){return u&&(l=d(),u=!1),t(f,`value`),l},set value(e){if(!c)throw Error(`计算属性是只读的`);c(e)}};return r(f),d=e(o,{lazy:!0,scheduler:()=>{u||(u=!0,i.setDataStrategy===`patch`&&i.includeComputed&&s.add(a),n(f,`value`))}}),f},computedProxy:new Proxy({},{get(e,t){if(typeof t==`string`&&a[t])return a[t].value},has(e,t){return typeof t==`string`&&!!a[t]},ownKeys(){return Object.keys(a)},getOwnPropertyDescriptor(e,t){if(typeof t==`string`&&a[t])return{configurable:!0,enumerable:!0,value:a[t].value}}})}}export{i as createComputedAccessors};