solid-alive 0.3.2 → 0.3.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.
- package/dist/index.js +1 -1
- package/dist/types/AliveProvider.d.ts +6 -0
- package/dist/types/active.d.ts +1 -0
- package/dist/types/aliveTransfer.d.ts +7 -1
- package/dist/types/context.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/nextTick.d.ts +2 -1
- package/dist/types/types.d.ts +18 -5
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createComponent as e}from"solid-js/web";import{createContext as
|
|
1
|
+
import{createComponent as e}from"solid-js/web";import{createContext as n,useContext as t,createRoot as r,createEffect as i,onCleanup as o,untrack as l}from"solid-js";import{produce as s,createStore as a}from"solid-js/store";const d=Symbol("currentId"),v=Symbol("setActiveCb"),u=Symbol("parentId");var c=n({elements:{},setElements:()=>{},setActiveCb:()=>{},aliveIds:()=>{},info:{frozen:!1},transitionEnterName:()=>{}});const f=n({[d]:void 0,[v]:()=>{}});var m=(n,t,r,i)=>e(f.Provider,{value:{[d]:i,[v]:r,[u]:t},get children(){return n()}}),p=e=>{for(;"function"==typeof e;)e=e();return e},h=!1;function y(e,n,l){return function(a){var v,u,y,A,b=t(c),E=t(f)[d],I=b.transitionEnterName();if(!(null===(v=b.aliveIds())||void 0===v?void 0:v.includes(n)))return m((()=>e(a)));if(E&&(null===(u=b.elements[n])||void 0===u?void 0:u.parentId)&&b.elements[n].parentId!==E)return null;b.elements[n]?b.info.frozen?(null===(y=b.elements[n].subsets)||void 0===y?void 0:y.some((e=>b.elements[e])))||(b.info.frozen=!1):null===(A=b.elements[n].onActivated)||void 0===A||A.forEach((e=>e())):(b.setElements({[n]:{id:n,subsets:Array.isArray(l)?l:null}}),r((t=>{b.setElements(s((r=>{var i;r[n].dispose=t,r[n].parentId=null===(i=Object.values(b.elements).find((e=>{var t;return null===(t=e.subsets)||void 0===t?void 0:t.includes(n)})))||void 0===i?void 0:i.id,r[n].element=m((()=>e(a)),r[n].parentId,b.setActiveCb,n)})))})));var g=e=>{if(e instanceof HTMLElement&&!h){h=!0,e.classList.add(I);var n=()=>{e.removeEventListener("animationend",n),e.classList.remove(I),h=!1};e.addEventListener("animationend",n)}};return I&&!b.info.frozen&&i((()=>{if(!h){var e=n;do{b.elements[e].parentId||g(p(b.elements[e].element)),e=b.elements[e].parentId}while(e)}})),o((()=>{var e,t;b.info.frozen||null===(t=null===(e=b.elements[n])||void 0===e?void 0:e.onDeactivated)||void 0===t||t.forEach((e=>e()))})),b.elements[n].element}}function A(n){const[t,r]=a();return i((e=>{var i=Array.isArray(n.include)?n.include:[];if(e.length>i.length){var o=new Set(i);(e=>{var n,i;if(Array.isArray(e))for(var o of e)null===(i=null===(n=t[o])||void 0===n?void 0:n.dispose)||void 0===i||i.call(n),r({[o]:void 0})})(e.filter((e=>!o.has(e))))}return i}),Array.isArray(n.include)?n.include:[]),e(c.Provider,{value:{info:{frozen:!1},elements:t,setElements:r,setActiveCb:(e,n,t,i)=>{r(s((r=>{r[e][n]?r[e][n][i](t):"add"===i&&(r[e][n]=new Set([t]))})))},aliveIds:()=>n.include,transitionEnterName:()=>n.transitionEnterName},get children(){return n.children}})}const b=(()=>{let e=[],n=!1,t=()=>{},r=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,i=()=>{n=!1;var t=e.slice(0);e.length=0;for(let e=0;e<t.length;e++)t[e]()};if("undefined"!=typeof Promise&&"function"==typeof Promise.prototype.then){const e=Promise.resolve();t=()=>{e.then(i),r&&setTimeout((()=>{}))}}else if("undefined"!=typeof MutationObserver){let e=1;const n=new MutationObserver(i),r=document.createTextNode(String(e));n.observe(r,{characterData:!0}),t=()=>{e=(e+1)%2,r.data=String(e)}}else t=()=>{setTimeout(i,0)};return r=>{e.push(r),n||(n=!0,t())}})();function E(e,n){l((()=>{var r,i=t(f),l=i[d];l&&(null===(r=i[v])||void 0===r||r.call(i,l,e,n,"add"),"onActivated"===e&&b(n),o((()=>{var t;null===(t=i[v])||void 0===t||t.call(i,l,e,n,"delete"),n=null})))}))}function I(e){E("onActivated",e)}function g(e){E("onDeactivated",e)}function S(){var e=t(c).info;return()=>e.frozen=!0}export{A as AliveProvider,y as aliveTransfer,b as nextTick,I as onActivated,g as onDeactivated,S as useAliveFrozen};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { ProveiderProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* @description Alive
|
|
4
|
+
* @param children jsx.element
|
|
5
|
+
* @param {Arrya<string> | null} [include] 哪些路由要缓存, 默认不缓存, ['/','/about',...]
|
|
6
|
+
* @param {string} [transitionEnterName] 动画名称 transitionEnterName="appear"
|
|
7
|
+
*/
|
|
2
8
|
export default function AliveProvider(props: ProveiderProps): import("solid-js").JSX.Element;
|
package/dist/types/active.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { JSX } from "solid-js";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @description Alive 组件用的 转换函数; aliveTransfer(Comp, ‘/home’)
|
|
4
|
+
* @param { ()=> JSX.Element } Component () => JSX.Element
|
|
5
|
+
* @param { string } id string,自己的id 值,一定要唯一
|
|
6
|
+
* @param { Array<string> } [subsets] [string,...], 子组件的 id值 可不传
|
|
7
|
+
*/
|
|
8
|
+
export default function aliveTransfer(Component: <T>(props: T) => JSX.Element, id: string, subsets?: Array<string> | null): <T>(props: T) => JSX.Element;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Context } from "./types";
|
|
2
2
|
export declare const CURRENTID: unique symbol;
|
|
3
3
|
export declare const SETACTIVECB: unique symbol;
|
|
4
|
+
export declare const PARENTID: unique symbol;
|
|
4
5
|
declare const _default: import("solid-js").Context<Context>;
|
|
5
6
|
export default _default;
|
|
6
7
|
export declare const ChildContext: import("solid-js").Context<{
|
|
7
8
|
[CURRENTID]: string | undefined;
|
|
8
9
|
[SETACTIVECB]?: Context["setActiveCb"];
|
|
10
|
+
[PARENTID]?: string;
|
|
9
11
|
}>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import aliveTransfer from "./aliveTransfer";
|
|
2
2
|
import AliveProvider from "./AliveProvider";
|
|
3
|
-
import { onActivated, onDeactivated } from "./active";
|
|
4
|
-
|
|
3
|
+
import { onActivated, onDeactivated, useAliveFrozen } from "./active";
|
|
4
|
+
import nextTick from "./nextTick";
|
|
5
|
+
export { aliveTransfer, AliveProvider, onActivated, onDeactivated, useAliveFrozen, nextTick };
|
package/dist/types/nextTick.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const nextTick: (cb: () => void) => void;
|
|
2
|
+
export default nextTick;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Owner, JSX } from "solid-js"
|
|
1
|
+
import { Owner, JSX, Accessor } from "solid-js"
|
|
2
2
|
import { SetStoreFunction } from "solid-js/store"
|
|
3
3
|
|
|
4
4
|
export type EmitType = keyof Emit
|
|
@@ -14,21 +14,34 @@ export interface Emit {
|
|
|
14
14
|
|
|
15
15
|
export interface ProveiderProps {
|
|
16
16
|
children: JSX.Element
|
|
17
|
-
include?:
|
|
17
|
+
include?: Array<string>
|
|
18
|
+
transitionEnterName?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Info {
|
|
22
|
+
frozen: boolean
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export interface Element {
|
|
21
26
|
id: string
|
|
22
27
|
element: JSX.Element
|
|
28
|
+
subsets?:Array<string> | null
|
|
23
29
|
dispose?: () => void
|
|
24
30
|
onActivated?: Set<() => void>
|
|
25
31
|
onDeactivated?: Set<() => void>
|
|
26
|
-
|
|
32
|
+
parentId?: string
|
|
27
33
|
owner?: Owner | null
|
|
28
34
|
}
|
|
29
35
|
export interface Context {
|
|
30
36
|
elements: Record<string, Element>
|
|
31
37
|
setElements: SetStoreFunction<{}>
|
|
32
|
-
aliveIds: ()=> Array<string> | undefined
|
|
33
|
-
setActiveCb: (
|
|
38
|
+
aliveIds: () => Array<string> | undefined
|
|
39
|
+
setActiveCb: (
|
|
40
|
+
id: string,
|
|
41
|
+
t: Activate,
|
|
42
|
+
cb: () => void,
|
|
43
|
+
t1: "add" | "delete"
|
|
44
|
+
) => void
|
|
45
|
+
info: { frozen: boolean }
|
|
46
|
+
transitionEnterName: () => string | void
|
|
34
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-alive",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"author": "1iuxs",
|
|
5
5
|
"description": "solid-alive",
|
|
6
6
|
"type": "module",
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
|
-
"keep-alive",
|
|
16
15
|
"solid-js",
|
|
17
|
-
"keepalive",
|
|
18
16
|
"cache",
|
|
19
17
|
"solid-alive",
|
|
20
18
|
"solid-keep-alive",
|
|
@@ -32,7 +30,7 @@
|
|
|
32
30
|
},
|
|
33
31
|
"license": "ISC",
|
|
34
32
|
"dependencies": {
|
|
35
|
-
"solid-js": "^1.9.
|
|
33
|
+
"solid-js": "^1.9.4"
|
|
36
34
|
},
|
|
37
35
|
"devDependencies": {
|
|
38
36
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -40,13 +38,13 @@
|
|
|
40
38
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
41
39
|
"@types/css-modules": "^1.0.5",
|
|
42
40
|
"autoprefixer": "^10.4.20",
|
|
43
|
-
"rollup": "^4.
|
|
41
|
+
"rollup": "^4.30.1",
|
|
44
42
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
45
43
|
"rollup-plugin-postcss": "^4.0.2",
|
|
46
44
|
"rollup-plugin-serve": "^1.1.1",
|
|
47
45
|
"rollup-plugin-terser": "^7.0.2",
|
|
48
46
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
49
47
|
"rollup-preset-solid": "^2.0.1",
|
|
50
|
-
"typescript": "^5.7.
|
|
48
|
+
"typescript": "^5.7.3"
|
|
51
49
|
}
|
|
52
50
|
}
|