@univa/core 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/use.cjs ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/use.ts
21
+ var use_exports = {};
22
+ __export(use_exports, {
23
+ usePageContext: () => usePageContext
24
+ });
25
+ module.exports = __toCommonJS(use_exports);
26
+
27
+ // src/hooks/usePageContext.ts
28
+ var import_vue = require("vue");
29
+ function usePageContext() {
30
+ const rootRef = (0, import_vue.shallowRef)(null);
31
+ (0, import_vue.onMounted)(() => {
32
+ const pagesStack = getCurrentPages();
33
+ const pageStack = pagesStack[pagesStack.length - 1];
34
+ if (!pageStack?.$vm?.$refs?.uniKuRoot) {
35
+ throw new Error("[usePageContext] Root not found.");
36
+ }
37
+ rootRef.value = pageStack.$vm.$refs.uniKuRoot;
38
+ });
39
+ return {
40
+ rootRef
41
+ };
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ usePageContext
46
+ });
package/dist/use.d.cts ADDED
@@ -0,0 +1,9 @@
1
+ import { ShallowRef } from 'vue';
2
+
3
+ interface PageContext {
4
+ rootRef: ShallowRef;
5
+ }
6
+
7
+ declare function usePageContext(): PageContext;
8
+
9
+ export { usePageContext };
package/dist/use.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ShallowRef } from 'vue';
2
+
3
+ interface PageContext {
4
+ rootRef: ShallowRef;
5
+ }
6
+
7
+ declare function usePageContext(): PageContext;
8
+
9
+ export { usePageContext };
package/dist/use.js ADDED
@@ -0,0 +1,19 @@
1
+ // src/hooks/usePageContext.ts
2
+ import { onMounted, shallowRef } from "vue";
3
+ function usePageContext() {
4
+ const rootRef = shallowRef(null);
5
+ onMounted(() => {
6
+ const pagesStack = getCurrentPages();
7
+ const pageStack = pagesStack[pagesStack.length - 1];
8
+ if (!pageStack?.$vm?.$refs?.uniKuRoot) {
9
+ throw new Error("[usePageContext] Root not found.");
10
+ }
11
+ rootRef.value = pageStack.$vm.$refs.uniKuRoot;
12
+ });
13
+ return {
14
+ rootRef
15
+ };
16
+ }
17
+ export {
18
+ usePageContext
19
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@univa/core",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "description": "🚀 开箱即用的 uni-app Vite 插件集,提供完整的开发体验",
6
6
  "author": "lianghang <libre1103@163.com>",
7
7
  "license": "MIT",
@@ -29,18 +29,18 @@
29
29
  "default": "./dist/index.cjs"
30
30
  }
31
31
  },
32
- "./hooks": {
32
+ "./use": {
33
33
  "import": {
34
- "types": "./dist/hooks.d.ts",
35
- "default": "./dist/hooks.js"
34
+ "types": "./dist/use.d.ts",
35
+ "default": "./dist/use.js"
36
36
  },
37
37
  "require": {
38
- "types": "./dist/hooks.d.cts",
39
- "default": "./dist/hooks.cjs"
38
+ "types": "./dist/use.d.cts",
39
+ "default": "./dist/use.cjs"
40
40
  }
41
41
  },
42
- "./client": {
43
- "types": "./src/client.d.ts"
42
+ "./global": {
43
+ "types": "./dist/global.d.ts"
44
44
  }
45
45
  },
46
46
  "main": "./dist/index.cjs",
@@ -49,9 +49,7 @@
49
49
  "files": [
50
50
  "LICENSE",
51
51
  "README.md",
52
- "dist",
53
- "src/client.d.ts",
54
- "src/global.d.ts"
52
+ "dist"
55
53
  ],
56
54
  "engines": {
57
55
  "node": ">=20.0.0"
@@ -61,40 +59,42 @@
61
59
  "registry": "https://registry.npmjs.org/"
62
60
  },
63
61
  "scripts": {
64
- "build": "tsup",
62
+ "build": "node scripts/build.mjs",
65
63
  "dev": "tsup --watch"
66
64
  },
67
65
  "peerDependencies": {
68
- "@dcloudio/uni-app": "^3.0.0-3090920231225001",
69
- "vite": "^5.2.8",
70
- "vue": "^3.4.21"
66
+ "vite": "^5.2.8"
71
67
  },
72
68
  "dependencies": {
73
- "@uni-helper/eslint-config": "0.7.3",
69
+ "@antfu/utils": "catalog:",
70
+ "@dcloudio/types": "3.4.28",
71
+ "@uni-helper/eslint-config": "0.7.4",
74
72
  "@uni-helper/plugin-uni": "0.1.0",
75
- "@uni-helper/uni-types": "1.0.0-alpha.8",
73
+ "@uni-helper/uni-pages-types": "0.4.6",
74
+ "@uni-helper/uni-types": "1.1.0",
76
75
  "@uni-helper/unocss-preset-uni": "0.2.11",
77
- "@uni-helper/vite-plugin-uni-components": "0.2.10",
76
+ "@uni-helper/vite-plugin-uni-components": "0.3.2",
78
77
  "@uni-helper/vite-plugin-uni-layouts": "0.1.11",
79
- "@uni-helper/vite-plugin-uni-pages": "0.3.24",
80
- "@uni-ku/bundle-optimizer": "2.1.2",
81
- "@univa/manifest": "^0.0.1",
82
- "@univa/root": "^0.0.1",
83
- "@univa/tsconfig": "^0.0.2",
78
+ "@uni-helper/vite-plugin-uni-manifest": "0.4.1",
79
+ "@uni-helper/vite-plugin-uni-pages": "0.4.6",
80
+ "@uni-ku/root": "1.4.1",
84
81
  "@unocss/eslint-plugin": "66.6.7",
85
82
  "@unocss/preset-legacy-compat": "66.0.0",
86
- "eslint": "10.3.0",
83
+ "c12": "3.3.4",
84
+ "defu": "6.1.7",
85
+ "eslint": "catalog:",
86
+ "jiti": "2.7.0",
87
87
  "sass": "1.99.0",
88
88
  "unocss": "66.0.0",
89
89
  "unplugin-auto-import": "20.0.0",
90
90
  "vite-plugin-uni-polyfill": "0.1.0"
91
91
  },
92
92
  "devDependencies": {
93
- "@dcloudio/uni-app": "^3.0.0-3090920231225001",
94
- "c12": "3.3.4",
95
- "tsup": "8.5.1",
96
- "typescript": "^5.4.0",
97
- "vite": "5.2.8",
98
- "vue": "^3.4.21"
93
+ "@dcloudio/uni-app": "catalog:",
94
+ "@types/node": "catalog:",
95
+ "tsup": "catalog:",
96
+ "typescript": "catalog:",
97
+ "vite": "catalog:",
98
+ "vue": "catalog:"
99
99
  }
100
100
  }
package/dist/hooks.cjs DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/hooks.ts
21
- var hooks_exports = {};
22
- __export(hooks_exports, {
23
- usePageContext: () => usePageContext
24
- });
25
- module.exports = __toCommonJS(hooks_exports);
26
-
27
- // src/hooks/usePageContext/index.ts
28
- var import_uni_app = require("@dcloudio/uni-app");
29
- var import_vue = require("vue");
30
- function usePageContext(options = {}) {
31
- const isMounted = (0, import_vue.ref)(false);
32
- const univaRootRef = (0, import_vue.ref)();
33
- const scrollTop = (0, import_vue.ref)(0);
34
- const mountedCallbacks = [];
35
- const unmountedCallbacks = [];
36
- const showAfterMountedCallbacks = [];
37
- const onPageShowAfterMounted = (callback) => {
38
- showAfterMountedCallbacks.push(callback);
39
- };
40
- const onPageMounted = (callback) => {
41
- mountedCallbacks.push(callback);
42
- };
43
- const onPageUnmounted = (callback) => {
44
- unmountedCallbacks.push(callback);
45
- };
46
- (0, import_uni_app.onShow)(() => {
47
- if (isMounted.value) {
48
- showAfterMountedCallbacks.forEach((cb) => cb());
49
- }
50
- });
51
- (0, import_uni_app.onPageScroll)((e) => {
52
- scrollTop.value = e.scrollTop;
53
- });
54
- (0, import_vue.onMounted)(() => {
55
- const pagesStack = getCurrentPages();
56
- const pageStack = pagesStack[pagesStack.length - 1];
57
- if (!pageStack?.$vm?.$refs?.univaRootRef) {
58
- throw new Error('[usePageContext] univaRootRef not found. Make sure the page has <univa-root ref="univaRootRef" /> component.');
59
- }
60
- univaRootRef.value = pageStack.$vm.$refs.univaRootRef;
61
- isMounted.value = true;
62
- mountedCallbacks.forEach((cb) => cb());
63
- });
64
- (0, import_vue.onUnmounted)(() => {
65
- isMounted.value = false;
66
- unmountedCallbacks.forEach((cb) => cb());
67
- mountedCallbacks.length = 0;
68
- unmountedCallbacks.length = 0;
69
- showAfterMountedCallbacks.length = 0;
70
- });
71
- return {
72
- isMounted,
73
- univaRootRef,
74
- scrollTop: (0, import_vue.computed)(() => scrollTop.value),
75
- onPageMounted,
76
- onPageUnmounted,
77
- onPageShowAfterMounted
78
- };
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- usePageContext
83
- });
package/dist/hooks.d.cts DELETED
@@ -1,36 +0,0 @@
1
- import { Ref, ComputedRef } from 'vue';
2
-
3
- interface PageContextOptions {
4
- /**
5
- * uniapp 必须在页面内检测到 onPageScroll 关键词才会注册事件。
6
- * @see https://github.com/dcloudio/uni-app/issues/3099 让页面被正则捕获从而开启监听
7
- */
8
- onPageScroll?: any;
9
- }
10
- interface PageContext {
11
- isMounted: Ref<boolean>;
12
- univaRootRef: Ref<any>;
13
- scrollTop: ComputedRef<number>;
14
- /**
15
- * 页面挂载成功时执行
16
- * @param callback
17
- * @returns
18
- */
19
- onPageMounted: (callback: () => void) => void;
20
- /**
21
- * 页面卸载时执行
22
- * @param callback
23
- * @returns
24
- */
25
- onPageUnmounted: (callback: () => void) => void;
26
- /**
27
- * 页面挂载成功后的每次显示时执行
28
- * @param callback
29
- * @returns
30
- */
31
- onPageShowAfterMounted: (callback: () => void) => void;
32
- }
33
-
34
- declare function usePageContext(options?: PageContextOptions): PageContext;
35
-
36
- export { usePageContext };
package/dist/hooks.d.ts DELETED
@@ -1,36 +0,0 @@
1
- import { Ref, ComputedRef } from 'vue';
2
-
3
- interface PageContextOptions {
4
- /**
5
- * uniapp 必须在页面内检测到 onPageScroll 关键词才会注册事件。
6
- * @see https://github.com/dcloudio/uni-app/issues/3099 让页面被正则捕获从而开启监听
7
- */
8
- onPageScroll?: any;
9
- }
10
- interface PageContext {
11
- isMounted: Ref<boolean>;
12
- univaRootRef: Ref<any>;
13
- scrollTop: ComputedRef<number>;
14
- /**
15
- * 页面挂载成功时执行
16
- * @param callback
17
- * @returns
18
- */
19
- onPageMounted: (callback: () => void) => void;
20
- /**
21
- * 页面卸载时执行
22
- * @param callback
23
- * @returns
24
- */
25
- onPageUnmounted: (callback: () => void) => void;
26
- /**
27
- * 页面挂载成功后的每次显示时执行
28
- * @param callback
29
- * @returns
30
- */
31
- onPageShowAfterMounted: (callback: () => void) => void;
32
- }
33
-
34
- declare function usePageContext(options?: PageContextOptions): PageContext;
35
-
36
- export { usePageContext };
package/dist/hooks.js DELETED
@@ -1,56 +0,0 @@
1
- // src/hooks/usePageContext/index.ts
2
- import { onPageScroll, onShow } from "@dcloudio/uni-app";
3
- import { computed, onMounted, onUnmounted, ref } from "vue";
4
- function usePageContext(options = {}) {
5
- const isMounted = ref(false);
6
- const univaRootRef = ref();
7
- const scrollTop = ref(0);
8
- const mountedCallbacks = [];
9
- const unmountedCallbacks = [];
10
- const showAfterMountedCallbacks = [];
11
- const onPageShowAfterMounted = (callback) => {
12
- showAfterMountedCallbacks.push(callback);
13
- };
14
- const onPageMounted = (callback) => {
15
- mountedCallbacks.push(callback);
16
- };
17
- const onPageUnmounted = (callback) => {
18
- unmountedCallbacks.push(callback);
19
- };
20
- onShow(() => {
21
- if (isMounted.value) {
22
- showAfterMountedCallbacks.forEach((cb) => cb());
23
- }
24
- });
25
- onPageScroll((e) => {
26
- scrollTop.value = e.scrollTop;
27
- });
28
- onMounted(() => {
29
- const pagesStack = getCurrentPages();
30
- const pageStack = pagesStack[pagesStack.length - 1];
31
- if (!pageStack?.$vm?.$refs?.univaRootRef) {
32
- throw new Error('[usePageContext] univaRootRef not found. Make sure the page has <univa-root ref="univaRootRef" /> component.');
33
- }
34
- univaRootRef.value = pageStack.$vm.$refs.univaRootRef;
35
- isMounted.value = true;
36
- mountedCallbacks.forEach((cb) => cb());
37
- });
38
- onUnmounted(() => {
39
- isMounted.value = false;
40
- unmountedCallbacks.forEach((cb) => cb());
41
- mountedCallbacks.length = 0;
42
- unmountedCallbacks.length = 0;
43
- showAfterMountedCallbacks.length = 0;
44
- });
45
- return {
46
- isMounted,
47
- univaRootRef,
48
- scrollTop: computed(() => scrollTop.value),
49
- onPageMounted,
50
- onPageUnmounted,
51
- onPageShowAfterMounted
52
- };
53
- }
54
- export {
55
- usePageContext
56
- };
package/src/client.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /// <reference path="./global.d.ts" />
2
- /// <reference types="@uni-helper/vite-plugin-uni-pages/client" />
3
- /// <reference types="vite/client" />
4
- /// <reference types="@uni-ku/bundle-optimizer/client" />
5
- /// <reference types="@uni-helper/uni-types" />
6
-
7
- declare module 'virtual:univa-pages' {
8
- import type { PageMetaDatum, SubPackage, TabBar } from '@uni-helper/vite-plugin-uni-pages'
9
-
10
- export const tabBar: TabBar
11
- export const pages: PageMetaDatum[]
12
- export const subPackages: SubPackage[]
13
- }
package/src/global.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}