wevu 6.16.2 → 6.16.3

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.
@@ -3,6 +3,7 @@ import { i as computed, n as defineStore, r as createStore, t as storeToRefs } f
3
3
  import { $ as pushHook, A as onLoad, B as onSaveExitState, C as setGlobalProvidedValue, D as onError, E as onDetached, F as onPullDownRefresh, G as onThemeChange, H as onShareTimeline, I as onReachBottom, J as assertInSetup, K as onUnhandledRejection, L as onReady, M as onMoved, N as onPageNotFound, O as onHide, P as onPageScroll, Q as getCurrentSetupContext, R as onResize, S as setRuntimeAppProvidedValue, T as onAttached, U as onShow, V as onShareAppMessage, W as onTabItemTap, X as callHookReturn, Y as callHookList, Z as getCurrentInstance, _ as provide, at as getMiniProgramGlobalObject, b as attachRuntimeProvideContext, ct as isProxy, dt as shallowReadonly, et as setCurrentInstance, g as injectGlobal, h as inject, it as getCurrentMiniProgramRuntimeCapabilities, j as onMemoryWarning, k as onLaunch, lt as isReadonly, m as hasInjectionContext, n as useNativeRouter, nt as getCurrentMiniProgramHostConfig, ot as getScopedSlotHostGlobalObject, q as onUnload, rt as getCurrentMiniProgramPages, st as supportsCurrentMiniProgramRuntimeCapability, t as useNativePageRouter, tt as setCurrentSetupContext, ut as readonly, v as provideGlobal, w as onAddToFavorites, x as ensureRuntimeAppProvides, y as attachRuntimeLayoutProvideContext, z as onRouteDone } from "./router-BZZnIx32.mjs";
4
4
  import { WEVU_ATTRS_KEY, WEVU_EFFECT_SCOPE_KEY, WEVU_EXPOSED_KEY, WEVU_HOOKS_KEY, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_APP_INSTANCE_KEY, WEVU_LAYOUT_BRIDGE_PAGE_KEYS, WEVU_LAYOUT_HOST_BRIDGE_KEY, WEVU_MODEL_HANDLER, WEVU_NATIVE_INSTANCE_KEY, WEVU_ON_BEFORE_UPDATE_HOOK, WEVU_ON_LOAD_CALLED_KEY, WEVU_ON_UPDATED_HOOK, WEVU_OWNER_HANDLER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_PAGE_SCROLL_HOOK_DEPTH_KEY, WEVU_PARENT_INSTANCE_KEY, WEVU_PENDING_PROP_VALUES_KEY, WEVU_PROPS_KEY, WEVU_PROP_KEYS_KEY, WEVU_PUBLIC_RUNTIME_KEY, WEVU_READY_CALLED_KEY, WEVU_RESERVED_METHOD_PREFIX, WEVU_ROUTE_DONE_CALLED_KEY, WEVU_ROUTE_DONE_IN_TICK_KEY, WEVU_RUNTIME_APP_KEY, WEVU_RUNTIME_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY, WEVU_SETUP_CONTEXT_INSTANCE_KEY, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_KEY, WEVU_SLOT_PROPS_DATA_KEY, WEVU_SLOT_PROPS_KEY, WEVU_SLOT_SCOPE_KEY, WEVU_TEMPLATE_REFS_CALLBACKS_KEY, WEVU_TEMPLATE_REFS_KEY, WEVU_TEMPLATE_REFS_PENDING_KEY, WEVU_TEMPLATE_REF_MAP_KEY, WEVU_WATCH_STOPS_KEY } from "@weapp-core/constants";
5
5
  import { resolveMiniProgramPageKeys } from "@weapp-core/shared";
6
+ import { wpi } from "@wevu/api";
6
7
 
7
8
  //#region \0rolldown/runtime.js
8
9
  var __defProp = Object.defineProperty;
@@ -477,7 +478,7 @@ function watchSyncEffect(effectFn, options = {}) {
477
478
 
478
479
  //#endregion
479
480
  //#region package.json
480
- var version$1 = "6.16.2";
481
+ var version$1 = "6.16.3";
481
482
 
482
483
  //#endregion
483
484
  //#region src/version.ts
@@ -5430,6 +5431,77 @@ function useDisposables() {
5430
5431
  };
5431
5432
  }
5432
5433
 
5434
+ //#endregion
5435
+ //#region src/runtime/elementIntersectionObserver.ts
5436
+ function createObserverFromContext(context, options) {
5437
+ const nativeContext = context;
5438
+ const creator = nativeContext.createIntersectionObserver;
5439
+ if (typeof creator === "function") return creator.call(nativeContext, options);
5440
+ if (!supportsCurrentMiniProgramRuntimeCapability("globalCreateIntersectionObserver")) return;
5441
+ const miniProgramGlobal = getMiniProgramGlobalObject();
5442
+ const globalCreator = miniProgramGlobal === null || miniProgramGlobal === void 0 ? void 0 : miniProgramGlobal.createIntersectionObserver;
5443
+ if (typeof globalCreator !== "function") return;
5444
+ return getCurrentMiniProgramRuntimeCapabilities().intersectionObserverScopeByParameter ? globalCreator.call(miniProgramGlobal, context, options) : globalCreator.call(miniProgramGlobal, options);
5445
+ }
5446
+ function applyRelativeToViewport(observer, relativeToViewport) {
5447
+ var _observer$relativeToV;
5448
+ if (relativeToViewport === false || typeof observer.relativeToViewport !== "function") return observer;
5449
+ const margins = relativeToViewport && typeof relativeToViewport === "object" ? relativeToViewport : void 0;
5450
+ return (_observer$relativeToV = observer.relativeToViewport(margins)) !== null && _observer$relativeToV !== void 0 ? _observer$relativeToV : observer;
5451
+ }
5452
+ /**
5453
+ * 观察当前组件或页面内的节点可见性,并在卸载时自动断开。
5454
+ */
5455
+ function useElementIntersectionObserver(options) {
5456
+ var _options$context;
5457
+ const context = (_options$context = options.context) !== null && _options$context !== void 0 ? _options$context : getCurrentInstance();
5458
+ if (!context || !getCurrentSetupContext()) throw new Error("useElementIntersectionObserver() 必须在 setup() 的同步阶段调用");
5459
+ let observer = null;
5460
+ const disconnect = () => {
5461
+ if (!observer) return;
5462
+ try {
5463
+ observer.disconnect();
5464
+ } catch (_unused) {}
5465
+ observer = null;
5466
+ };
5467
+ const observe = () => {
5468
+ var _options$observerOpti, _options$relativeToVi;
5469
+ disconnect();
5470
+ const selector = toValue(options.selector);
5471
+ if (!(options.enabled == null ? true : toValue(options.enabled)) || !selector) return null;
5472
+ const nextObserver = createObserverFromContext(context, toValue((_options$observerOpti = options.observerOptions) !== null && _options$observerOpti !== void 0 ? _options$observerOpti : {}));
5473
+ if (!nextObserver || typeof nextObserver.observe !== "function") return null;
5474
+ observer = applyRelativeToViewport(nextObserver, (_options$relativeToVi = options.relativeToViewport) !== null && _options$relativeToVi !== void 0 ? _options$relativeToVi : true);
5475
+ observer.observe(selector, (result) => {
5476
+ var _options$onObserve;
5477
+ return (_options$onObserve = options.onObserve) === null || _options$onObserve === void 0 ? void 0 : _options$onObserve.call(options, result);
5478
+ });
5479
+ return observer;
5480
+ };
5481
+ watch(() => {
5482
+ var _options$observerOpti2;
5483
+ return [
5484
+ toValue(options.selector),
5485
+ options.enabled == null ? true : toValue(options.enabled),
5486
+ toValue((_options$observerOpti2 = options.observerOptions) !== null && _options$observerOpti2 !== void 0 ? _options$observerOpti2 : {}),
5487
+ options.relativeToViewport
5488
+ ];
5489
+ }, () => {
5490
+ observe();
5491
+ }, { deep: true });
5492
+ onMounted(observe);
5493
+ onUnmounted(disconnect);
5494
+ onUnload(disconnect);
5495
+ onDetached(disconnect);
5496
+ return {
5497
+ disconnect,
5498
+ observe,
5499
+ get observer() {
5500
+ return observer;
5501
+ }
5502
+ };
5503
+ }
5504
+
5433
5505
  //#endregion
5434
5506
  //#region src/runtime/intersectionObserver.ts
5435
5507
  function createObserverFromInstance(instance, options) {
@@ -5470,6 +5542,98 @@ function useIntersectionObserver(options = {}) {
5470
5542
  return observer;
5471
5543
  }
5472
5544
 
5545
+ //#endregion
5546
+ //#region src/runtime/pageEnvironment.ts
5547
+ function normalizeRoute(route) {
5548
+ var _route$split$0$replac, _route$split$;
5549
+ return route ? (_route$split$0$replac = (_route$split$ = route.split("?")[0]) === null || _route$split$ === void 0 ? void 0 : _route$split$.replace(/^\/+/, "")) !== null && _route$split$0$replac !== void 0 ? _route$split$0$replac : "" : "";
5550
+ }
5551
+ /**
5552
+ * 获取当前小程序页面栈的稳定快照。
5553
+ */
5554
+ function getCurrentPageStackSnapshot() {
5555
+ const pages = getCurrentMiniProgramPages();
5556
+ const currentPage = pages.at(-1);
5557
+ const stackLength = pages.length || 1;
5558
+ return {
5559
+ canGoBack: stackLength > 1,
5560
+ currentRoute: normalizeRoute(currentPage === null || currentPage === void 0 ? void 0 : currentPage.route),
5561
+ stackLength
5562
+ };
5563
+ }
5564
+ /**
5565
+ * 在 setup 中跟踪当前小程序页面栈状态。
5566
+ */
5567
+ function usePageStack(options = {}) {
5568
+ var _options$autoRefresh;
5569
+ if (!getCurrentSetupContext()) throw new Error("usePageStack() 必须在 setup() 的同步阶段调用");
5570
+ const snapshot = getCurrentPageStackSnapshot();
5571
+ const currentRoute = ref(snapshot.currentRoute);
5572
+ const stackLength = ref(snapshot.stackLength);
5573
+ const canGoBack = computed(() => stackLength.value > 1);
5574
+ const refresh = () => {
5575
+ const nextSnapshot = getCurrentPageStackSnapshot();
5576
+ currentRoute.value = nextSnapshot.currentRoute;
5577
+ stackLength.value = nextSnapshot.stackLength;
5578
+ };
5579
+ if ((_options$autoRefresh = options.autoRefresh) !== null && _options$autoRefresh !== void 0 ? _options$autoRefresh : true) {
5580
+ onAttached(refresh);
5581
+ onShow(refresh);
5582
+ }
5583
+ return {
5584
+ canGoBack,
5585
+ currentRoute,
5586
+ refresh,
5587
+ stackLength
5588
+ };
5589
+ }
5590
+ /**
5591
+ * 计算自定义导航栏所需的状态栏和胶囊占位高度。
5592
+ */
5593
+ function getNavigationBarMetrics(options = {}) {
5594
+ var _options$defaultStatu, _options$defaultNavig;
5595
+ const defaultStatusBarHeight = (_options$defaultStatu = options.defaultStatusBarHeight) !== null && _options$defaultStatu !== void 0 ? _options$defaultStatu : 20;
5596
+ const defaultNavigationBarHeight = (_options$defaultNavig = options.defaultNavigationBarHeight) !== null && _options$defaultNavig !== void 0 ? _options$defaultNavig : 44;
5597
+ const miniProgramGlobal = getMiniProgramGlobalObject();
5598
+ const systemInfo = typeof (miniProgramGlobal === null || miniProgramGlobal === void 0 ? void 0 : miniProgramGlobal.getSystemInfoSync) === "function" ? miniProgramGlobal.getSystemInfoSync() : {};
5599
+ const statusBarHeight = Number((systemInfo === null || systemInfo === void 0 ? void 0 : systemInfo.statusBarHeight) || defaultStatusBarHeight);
5600
+ let menuButtonRect;
5601
+ try {
5602
+ menuButtonRect = typeof (miniProgramGlobal === null || miniProgramGlobal === void 0 ? void 0 : miniProgramGlobal.getMenuButtonBoundingClientRect) === "function" ? miniProgramGlobal.getMenuButtonBoundingClientRect() : void 0;
5603
+ } catch (_unused) {}
5604
+ const menuTop = Number((menuButtonRect === null || menuButtonRect === void 0 ? void 0 : menuButtonRect.top) || 0);
5605
+ const menuHeight = Number((menuButtonRect === null || menuButtonRect === void 0 ? void 0 : menuButtonRect.height) || 0);
5606
+ const navigationBarHeight = menuTop > statusBarHeight && menuHeight > 0 ? (menuTop - statusBarHeight) * 2 + menuHeight : defaultNavigationBarHeight;
5607
+ return {
5608
+ navigationBarHeight,
5609
+ navigationHeight: statusBarHeight + navigationBarHeight,
5610
+ statusBarHeight
5611
+ };
5612
+ }
5613
+ /**
5614
+ * 在 setup 中跟踪自定义导航栏尺寸。
5615
+ */
5616
+ function useNavigationBarMetrics(options = {}) {
5617
+ var _options$autoRefresh2;
5618
+ if (!getCurrentSetupContext()) throw new Error("useNavigationBarMetrics() 必须在 setup() 的同步阶段调用");
5619
+ const initialMetrics = getNavigationBarMetrics(options);
5620
+ const statusBarHeight = ref(initialMetrics.statusBarHeight);
5621
+ const navigationBarHeight = ref(initialMetrics.navigationBarHeight);
5622
+ const navigationHeight = computed(() => statusBarHeight.value + navigationBarHeight.value);
5623
+ const refresh = () => {
5624
+ const nextMetrics = getNavigationBarMetrics(options);
5625
+ statusBarHeight.value = nextMetrics.statusBarHeight;
5626
+ navigationBarHeight.value = nextMetrics.navigationBarHeight;
5627
+ };
5628
+ if ((_options$autoRefresh2 = options.autoRefresh) !== null && _options$autoRefresh2 !== void 0 ? _options$autoRefresh2 : true) onAttached(refresh);
5629
+ return {
5630
+ navigationBarHeight,
5631
+ navigationHeight,
5632
+ refresh,
5633
+ statusBarHeight
5634
+ };
5635
+ }
5636
+
5473
5637
  //#endregion
5474
5638
  //#region src/runtime/pageScroll.ts
5475
5639
  function resolvePositiveInterval(interval) {
@@ -5575,6 +5739,69 @@ function usePageScrollThrottle(handler, options = {}) {
5575
5739
  return stop;
5576
5740
  }
5577
5741
 
5742
+ //#endregion
5743
+ //#region src/runtime/pullDownRefresh.ts
5744
+ /**
5745
+ * 注册下拉刷新回调,并在回调结束后自动停止宿主下拉刷新状态。
5746
+ */
5747
+ function useAsyncPullDownRefresh(refresh, options = {}) {
5748
+ onPullDownRefresh(async () => {
5749
+ try {
5750
+ await refresh();
5751
+ } catch (error) {
5752
+ var _options$onError;
5753
+ await ((_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, error));
5754
+ } finally {
5755
+ var _options$stopPullDown;
5756
+ await ((_options$stopPullDown = options.stopPullDownRefresh) !== null && _options$stopPullDown !== void 0 ? _options$stopPullDown : (() => wpi.stopPullDownRefresh()))();
5757
+ }
5758
+ });
5759
+ }
5760
+
5761
+ //#endregion
5762
+ //#region src/runtime/selectorQuery.ts
5763
+ function resolveSetupContext(apiName, context) {
5764
+ const resolved = context !== null && context !== void 0 ? context : getCurrentInstance();
5765
+ if (!resolved || !getCurrentSetupContext()) throw new Error(`${apiName}() 必须在 setup() 的同步阶段调用`);
5766
+ return resolved;
5767
+ }
5768
+ function runSelectorQuery(context, selector, all, apply) {
5769
+ const query = createSelectorQuery(context);
5770
+ if (!query || !selector) return Promise.resolve(null);
5771
+ apply(all ? query.selectAll(selector) : query.select(selector));
5772
+ return new Promise((resolve) => {
5773
+ query.exec((res) => {
5774
+ const result = Array.isArray(res) ? res[0] : null;
5775
+ resolve(result !== null && result !== void 0 ? result : null);
5776
+ });
5777
+ });
5778
+ }
5779
+ /**
5780
+ * 创建绑定当前小程序实例的选择器查询工厂。
5781
+ */
5782
+ function useSelectorQuery(options = {}) {
5783
+ const context = resolveSetupContext("useSelectorQuery", options.context);
5784
+ return () => createSelectorQuery(context);
5785
+ }
5786
+ function useBoundingClientRect(options = {}) {
5787
+ var _options$all;
5788
+ const context = resolveSetupContext("useBoundingClientRect", options.context);
5789
+ const all = (_options$all = options.all) !== null && _options$all !== void 0 ? _options$all : false;
5790
+ return (selector) => runSelectorQuery(context, selector, all, (nodesRef) => nodesRef.boundingClientRect());
5791
+ }
5792
+ function useSelectorFields(options) {
5793
+ var _options$all2;
5794
+ const context = resolveSetupContext("useSelectorFields", options.context);
5795
+ const all = (_options$all2 = options.all) !== null && _options$all2 !== void 0 ? _options$all2 : false;
5796
+ return (selector) => runSelectorQuery(context, selector, all, (nodesRef) => nodesRef.fields(options.fields));
5797
+ }
5798
+ function useScrollOffset(options = {}) {
5799
+ var _options$all3;
5800
+ const context = resolveSetupContext("useScrollOffset", options.context);
5801
+ const all = (_options$all3 = options.all) !== null && _options$all3 !== void 0 ? _options$all3 : false;
5802
+ return (selector) => runSelectorQuery(context, selector, all, (nodesRef) => nodesRef.scrollOffset());
5803
+ }
5804
+
5578
5805
  //#endregion
5579
5806
  //#region src/runtime/template.ts
5580
5807
  const hyphenateRE = /\B([A-Z])/g;
@@ -5808,6 +6035,15 @@ function useBindModel(defaultOptions) {
5808
6035
  };
5809
6036
  return bindModel;
5810
6037
  }
6038
+ /**
6039
+ * useChangeModel 返回以 change 事件为默认更新事件的 model 绑定助手。
6040
+ */
6041
+ function useChangeModel() {
6042
+ const bindModel = useBindModel({ event: "change" });
6043
+ return function changeModel(path, options) {
6044
+ return bindModel.model(path, options);
6045
+ };
6046
+ }
5811
6047
  function mergeModels(a, b) {
5812
6048
  if (a == null) return b;
5813
6049
  if (b == null) return a;
@@ -5851,5 +6087,5 @@ function useTemplateRef(name) {
5851
6087
  }
5852
6088
 
5853
6089
  //#endregion
5854
- export { onBeforeMount as $, registerApp as A, resetWevuDefaults as B, resolveLayoutBridge as C, useLayoutBridge as D, unregisterRuntimeLayoutHosts as E, resolveRuntimePageLayoutName as F, watch as G, isNoSetData as H, setPageLayout as I, watchSyncEffect as J, watchEffect as K, syncRuntimePageLayoutState as L, setRuntimeSetDataVisibility as M, teardownRuntimeInstance as N, useLayoutHosts as O, runSetupFunction as P, onActivated as Q, syncRuntimePageLayoutStateFromRuntime as R, registerRuntimeLayoutHosts as S, unregisterPageLayoutBridge as T, markNoSetData as U, setWevuDefaults as V, version as W, setDeepWatchStrategy as X, getDeepWatchStrategy as Y, callUpdateHooks as Z, createWevuScopedSlotComponent as _, useAttrs as a, onServerPrefetch as at, registerComponent as b, defineAppSetup as c, traverse as ct, normalizeClass as d, isShallowRef as dt, onBeforeUnmount as et, normalizeStyle as f, shallowRef as ft, createWevuComponent as g, useDisposables as h, __reExport as ht, useModel as i, onMounted as it, mountRuntimeInstance as j, waitForLayoutHost as k, use as l, toRef as lt, useIntersectionObserver as m, __exportAll as mt, mergeModels as n, onDeactivated as nt, useNativeInstance as o, onUnmounted as ot, usePageScrollThrottle as p, triggerRef as pt, watchPostEffect as q, useBindModel as r, onErrorCaptured as rt, useSlots as s, onUpdated as st, useTemplateRef as t, onBeforeUpdate as tt, useUpdatePerformanceListener as u, toRefs as ut, defineComponent as v, resolveLayoutHost as w, registerPageLayoutBridge as x, createApp as y, usePageLayout as z };
5855
- //# sourceMappingURL=src-DcTVnwpE.mjs.map
6090
+ export { isNoSetData as $, createApp as A, waitForLayoutHost as B, usePageStack as C, shallowRef as Ct, createWevuComponent as D, useDisposables as E, __reExport as Et, resolveLayoutHost as F, runSetupFunction as G, mountRuntimeInstance as H, unregisterPageLayoutBridge as I, syncRuntimePageLayoutState as J, resolveRuntimePageLayoutName as K, unregisterRuntimeLayoutHosts as L, registerPageLayoutBridge as M, registerRuntimeLayoutHosts as N, createWevuScopedSlotComponent as O, resolveLayoutBridge as P, setWevuDefaults as Q, useLayoutBridge as R, useNavigationBarMetrics as S, isShallowRef as St, useElementIntersectionObserver as T, __exportAll as Tt, setRuntimeSetDataVisibility as U, registerApp as V, teardownRuntimeInstance as W, usePageLayout as X, syncRuntimePageLayoutStateFromRuntime as Y, resetWevuDefaults as Z, useSelectorQuery as _, onUnmounted as _t, useModel as a, watchSyncEffect as at, getCurrentPageStackSnapshot as b, toRef as bt, useSlots as c, callUpdateHooks as ct, useUpdatePerformanceListener as d, onBeforeUnmount as dt, markNoSetData as et, normalizeClass as f, onBeforeUpdate as ft, useSelectorFields as g, onServerPrefetch as gt, useScrollOffset as h, onMounted as ht, useChangeModel as i, watchPostEffect as it, registerComponent as j, defineComponent as k, defineAppSetup as l, onActivated as lt, useBoundingClientRect as m, onErrorCaptured as mt, mergeModels as n, watch as nt, useAttrs as o, getDeepWatchStrategy as ot, normalizeStyle as p, onDeactivated as pt, setPageLayout as q, useBindModel as r, watchEffect as rt, useNativeInstance as s, setDeepWatchStrategy as st, useTemplateRef as t, version as tt, use as u, onBeforeMount as ut, useAsyncPullDownRefresh as v, onUpdated as vt, useIntersectionObserver as w, triggerRef as wt, getNavigationBarMetrics as x, toRefs as xt, usePageScrollThrottle as y, traverse as yt, useLayoutHosts as z };
6091
+ //# sourceMappingURL=src-DjDCQerj.mjs.map