solid-alive 0.1.7 → 0.1.9
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/LICENSE +127 -127
- package/{readme.md → README.md} +73 -48
- package/dist/index.js +1 -1
- package/dist/types/AliveProvider.d.ts +1 -4
- package/dist/types/context.d.ts +1 -1
- package/dist/types/default.d.ts +16 -29
- package/dist/types/index.d.ts +2 -2
- package/dist/types/useAlive.d.ts +6 -13
- package/dist/types/utils.d.ts +4 -0
- package/package.json +1 -1
- package/dist/styles/style.css +0 -30
package/LICENSE
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
木兰宽松许可证, 第2版
|
|
2
|
-
|
|
3
|
-
木兰宽松许可证, 第2版
|
|
4
|
-
2020年1月 http://license.coscl.org.cn/MulanPSL2
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
|
|
8
|
-
|
|
9
|
-
0. 定义
|
|
10
|
-
|
|
11
|
-
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
|
|
12
|
-
|
|
13
|
-
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
|
|
14
|
-
|
|
15
|
-
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
|
|
16
|
-
|
|
17
|
-
“法人实体”是指提交贡献的机构及其“关联实体”。
|
|
18
|
-
|
|
19
|
-
“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
|
|
20
|
-
|
|
21
|
-
1. 授予版权许可
|
|
22
|
-
|
|
23
|
-
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
|
|
24
|
-
|
|
25
|
-
2. 授予专利许可
|
|
26
|
-
|
|
27
|
-
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
|
|
28
|
-
|
|
29
|
-
3. 无商标许可
|
|
30
|
-
|
|
31
|
-
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
|
|
32
|
-
|
|
33
|
-
4. 分发限制
|
|
34
|
-
|
|
35
|
-
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
|
|
36
|
-
|
|
37
|
-
5. 免责声明与责任限制
|
|
38
|
-
|
|
39
|
-
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
|
|
40
|
-
|
|
41
|
-
6. 语言
|
|
42
|
-
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
|
|
43
|
-
|
|
44
|
-
条款结束
|
|
45
|
-
|
|
46
|
-
如何将木兰宽松许可证,第2版,应用到您的软件
|
|
47
|
-
|
|
48
|
-
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
|
|
49
|
-
|
|
50
|
-
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
|
|
51
|
-
|
|
52
|
-
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
|
|
53
|
-
|
|
54
|
-
3, 请将如下声明文本放入每个源文件的头部注释中。
|
|
55
|
-
|
|
56
|
-
Copyright (c) [Year] [name of copyright holder]
|
|
57
|
-
[Software Name] is licensed under Mulan PSL v2.
|
|
58
|
-
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
59
|
-
You may obtain a copy of Mulan PSL v2 at:
|
|
60
|
-
http://license.coscl.org.cn/MulanPSL2
|
|
61
|
-
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
62
|
-
See the Mulan PSL v2 for more details.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Mulan Permissive Software License,Version 2
|
|
66
|
-
|
|
67
|
-
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
|
|
68
|
-
January 2020 http://license.coscl.org.cn/MulanPSL2
|
|
69
|
-
|
|
70
|
-
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
|
|
71
|
-
|
|
72
|
-
0. Definition
|
|
73
|
-
|
|
74
|
-
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
|
|
75
|
-
|
|
76
|
-
Contribution means the copyrightable work licensed by a particular Contributor under this License.
|
|
77
|
-
|
|
78
|
-
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
|
|
79
|
-
|
|
80
|
-
Legal Entity means the entity making a Contribution and all its Affiliates.
|
|
81
|
-
|
|
82
|
-
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
|
|
83
|
-
|
|
84
|
-
1. Grant of Copyright License
|
|
85
|
-
|
|
86
|
-
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
|
|
87
|
-
|
|
88
|
-
2. Grant of Patent License
|
|
89
|
-
|
|
90
|
-
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
|
|
91
|
-
|
|
92
|
-
3. No Trademark License
|
|
93
|
-
|
|
94
|
-
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
|
|
95
|
-
|
|
96
|
-
4. Distribution Restriction
|
|
97
|
-
|
|
98
|
-
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
|
|
99
|
-
|
|
100
|
-
5. Disclaimer of Warranty and Limitation of Liability
|
|
101
|
-
|
|
102
|
-
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
103
|
-
|
|
104
|
-
6. Language
|
|
105
|
-
|
|
106
|
-
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
|
|
107
|
-
|
|
108
|
-
END OF THE TERMS AND CONDITIONS
|
|
109
|
-
|
|
110
|
-
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
|
|
111
|
-
|
|
112
|
-
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
|
|
113
|
-
|
|
114
|
-
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
|
|
115
|
-
|
|
116
|
-
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
|
|
117
|
-
|
|
118
|
-
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
Copyright (c) [Year] [name of copyright holder]
|
|
122
|
-
[Software Name] is licensed under Mulan PSL v2.
|
|
123
|
-
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
124
|
-
You may obtain a copy of Mulan PSL v2 at:
|
|
125
|
-
http://license.coscl.org.cn/MulanPSL2
|
|
126
|
-
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
127
|
-
See the Mulan PSL v2 for more details.
|
|
1
|
+
木兰宽松许可证, 第2版
|
|
2
|
+
|
|
3
|
+
木兰宽松许可证, 第2版
|
|
4
|
+
2020年1月 http://license.coscl.org.cn/MulanPSL2
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
|
|
8
|
+
|
|
9
|
+
0. 定义
|
|
10
|
+
|
|
11
|
+
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
|
|
12
|
+
|
|
13
|
+
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
|
|
14
|
+
|
|
15
|
+
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
|
|
16
|
+
|
|
17
|
+
“法人实体”是指提交贡献的机构及其“关联实体”。
|
|
18
|
+
|
|
19
|
+
“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
|
|
20
|
+
|
|
21
|
+
1. 授予版权许可
|
|
22
|
+
|
|
23
|
+
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
|
|
24
|
+
|
|
25
|
+
2. 授予专利许可
|
|
26
|
+
|
|
27
|
+
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
|
|
28
|
+
|
|
29
|
+
3. 无商标许可
|
|
30
|
+
|
|
31
|
+
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
|
|
32
|
+
|
|
33
|
+
4. 分发限制
|
|
34
|
+
|
|
35
|
+
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
|
|
36
|
+
|
|
37
|
+
5. 免责声明与责任限制
|
|
38
|
+
|
|
39
|
+
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
|
|
40
|
+
|
|
41
|
+
6. 语言
|
|
42
|
+
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
|
|
43
|
+
|
|
44
|
+
条款结束
|
|
45
|
+
|
|
46
|
+
如何将木兰宽松许可证,第2版,应用到您的软件
|
|
47
|
+
|
|
48
|
+
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
|
|
49
|
+
|
|
50
|
+
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
|
|
51
|
+
|
|
52
|
+
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
|
|
53
|
+
|
|
54
|
+
3, 请将如下声明文本放入每个源文件的头部注释中。
|
|
55
|
+
|
|
56
|
+
Copyright (c) [Year] [name of copyright holder]
|
|
57
|
+
[Software Name] is licensed under Mulan PSL v2.
|
|
58
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
59
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
60
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
61
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
62
|
+
See the Mulan PSL v2 for more details.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Mulan Permissive Software License,Version 2
|
|
66
|
+
|
|
67
|
+
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
|
|
68
|
+
January 2020 http://license.coscl.org.cn/MulanPSL2
|
|
69
|
+
|
|
70
|
+
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
|
|
71
|
+
|
|
72
|
+
0. Definition
|
|
73
|
+
|
|
74
|
+
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
|
|
75
|
+
|
|
76
|
+
Contribution means the copyrightable work licensed by a particular Contributor under this License.
|
|
77
|
+
|
|
78
|
+
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
|
|
79
|
+
|
|
80
|
+
Legal Entity means the entity making a Contribution and all its Affiliates.
|
|
81
|
+
|
|
82
|
+
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
|
|
83
|
+
|
|
84
|
+
1. Grant of Copyright License
|
|
85
|
+
|
|
86
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
|
|
87
|
+
|
|
88
|
+
2. Grant of Patent License
|
|
89
|
+
|
|
90
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
|
|
91
|
+
|
|
92
|
+
3. No Trademark License
|
|
93
|
+
|
|
94
|
+
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
|
|
95
|
+
|
|
96
|
+
4. Distribution Restriction
|
|
97
|
+
|
|
98
|
+
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
|
|
99
|
+
|
|
100
|
+
5. Disclaimer of Warranty and Limitation of Liability
|
|
101
|
+
|
|
102
|
+
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
103
|
+
|
|
104
|
+
6. Language
|
|
105
|
+
|
|
106
|
+
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
|
|
107
|
+
|
|
108
|
+
END OF THE TERMS AND CONDITIONS
|
|
109
|
+
|
|
110
|
+
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
|
|
111
|
+
|
|
112
|
+
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
|
|
113
|
+
|
|
114
|
+
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
|
|
115
|
+
|
|
116
|
+
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
|
|
117
|
+
|
|
118
|
+
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
Copyright (c) [Year] [name of copyright holder]
|
|
122
|
+
[Software Name] is licensed under Mulan PSL v2.
|
|
123
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
124
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
125
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
126
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
127
|
+
See the Mulan PSL v2 for more details.
|
package/{readme.md → README.md}
RENAMED
|
@@ -3,20 +3,12 @@
|
|
|
3
3
|
### 安装(install)
|
|
4
4
|
- pnpm add solid-alive / npm i solid-alive / yarn add solid-alive
|
|
5
5
|
### 描述(describe)
|
|
6
|
-
- 用于 solid 组件缓存,只测试过2
|
|
6
|
+
- 用于 solid 组件缓存,只测试过2级路由缓存
|
|
7
7
|
- AliveProvider
|
|
8
|
-
- scrollId : 想滚动的元素id, 我用的getElementById
|
|
9
|
-
- behavior : 想 scrollId 的滚动条是 alwaysTop / savaScroll
|
|
10
|
-
- transitionEnterName : 'appear'/ 'toLeft'/...., Customizable 路由切换 的过渡动画, 但要在 App中引入 样式, import 'solid-alive/dist/styles/style.css', 自定义的css要用 @keyframes 来定义动画
|
|
11
8
|
- 在 useAlive
|
|
12
9
|
- removeAliveElement: 函数, 可传一个参数, 不传就删除所有缓存 :
|
|
13
10
|
removeAliveElement('/home')
|
|
14
|
-
-
|
|
15
|
-
- onActivated(()=> console.log('actived'))
|
|
16
|
-
- <table><tr><td bgcolor=#ff0>现在多个onActivated/onDeactivated 会被保存,在一个组件 内不要有多个onActivated/onDeactivated函数</td></tr></table>
|
|
17
|
-
- directiveSaveScroll: 保存滚动条指令, 不过能不用就不用, 但组件不能使用,只能标签!!!ref会拿不到dom
|
|
18
|
-
- resetElScroll : 重置元素的滚动条
|
|
19
|
-
- removeScrollEl : 删除元素在alive中保存的dom
|
|
11
|
+
- aliveForzen: 暂时不响应 路由数据变化, aliveForzen()
|
|
20
12
|
- 子父 缓存/删除 问题
|
|
21
13
|
- 如果某组件下有子组件,在父的 AliveTransfer中,
|
|
22
14
|
第三个参数,为对象 写上子组件的唯一id: {children:['/childrenId','asf',...]}
|
|
@@ -25,18 +17,16 @@
|
|
|
25
17
|
|
|
26
18
|
|
|
27
19
|
### 使用(use)
|
|
28
|
-
1 /index.tsx,AliveProvider将app
|
|
20
|
+
1 /index.tsx,AliveProvider将app 包裹
|
|
29
21
|
```jsx
|
|
30
22
|
import { render } from 'solid-js/web'
|
|
31
23
|
import App from './App'
|
|
32
24
|
import { AliveProvider } from 'solid-alive'
|
|
33
|
-
import 'solid-alive/dist/styles/style.css' // transition css,
|
|
34
25
|
|
|
35
26
|
const root = document.getElementById('root')
|
|
36
27
|
|
|
37
28
|
render(() =>
|
|
38
|
-
|
|
39
|
-
<AliveProvider behavior="alwaysTop" scrollId='client' transitionEnterName='appear'>
|
|
29
|
+
<AliveProvider>
|
|
40
30
|
<App />
|
|
41
31
|
</AliveProvider>
|
|
42
32
|
, root!)
|
|
@@ -95,16 +85,10 @@ export default function Blog(props: any) {
|
|
|
95
85
|
|
|
96
86
|
- 子 /views/Blog/Single/index.tsx 中
|
|
97
87
|
```tsx
|
|
98
|
-
import {
|
|
88
|
+
import { onActivated,onDeactivated,useAlive } from "solid-alive"
|
|
99
89
|
|
|
100
90
|
export default function Single() {
|
|
101
|
-
const {
|
|
102
|
-
onActivated,onDeactivated,
|
|
103
|
-
removeAliveElement,
|
|
104
|
-
//@ts-ignore
|
|
105
|
-
directiveSaveScroll,
|
|
106
|
-
resetElScroll,
|
|
107
|
-
} = useAlive()
|
|
91
|
+
const { removeAliveElement,aliveFrozen } = useAlive()
|
|
108
92
|
|
|
109
93
|
let divRef: Element | undefined = undefined
|
|
110
94
|
const click = () => {
|
|
@@ -114,10 +98,10 @@ export default function Single() {
|
|
|
114
98
|
|
|
115
99
|
//todo call 这个会被调用
|
|
116
100
|
onActivated(()=>{
|
|
117
|
-
console.log('Single-activeated-1')
|
|
101
|
+
console.log('Single-activeated-1')
|
|
118
102
|
})
|
|
119
103
|
|
|
120
|
-
//todo call
|
|
104
|
+
//todo no call 这个不会被调用
|
|
121
105
|
onActivated(()=>{
|
|
122
106
|
console.log('Single-activeated-2')
|
|
123
107
|
})
|
|
@@ -129,31 +113,72 @@ export default function Single() {
|
|
|
129
113
|
<div>
|
|
130
114
|
<h2>Single</h2>
|
|
131
115
|
<input type="text" style={{ border: '2px solid red' }} />
|
|
132
|
-
<button
|
|
133
|
-
onClick={() => {
|
|
134
|
-
// divRef && resetElScroll(divRef)
|
|
135
|
-
divRef && removeScrollEl(divRef)
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
reset directiveSaveScroll
|
|
139
|
-
</button>
|
|
140
|
-
<div
|
|
141
|
-
style={{ height: '500px', width: '200px',border:'1px solid green',overflow:'auto'}}
|
|
142
|
-
{/* 可以不用参数 ,*/}
|
|
143
|
-
{/* use:directiveSaveScroll={dom => ((divRef as Element) = dom)} */}
|
|
144
|
-
use:directiveSaveScroll
|
|
145
|
-
>
|
|
146
|
-
<div style="height:900px;border:1px solid red">
|
|
147
|
-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam earum
|
|
148
|
-
aspernatur omnis, fugiat doloremque repellat facilis fugit nisi magni
|
|
149
|
-
provident hic aliquid nostrum reiciendis, dolores rem, quasi dolor
|
|
150
|
-
officia? Quidem? Sit alias tempore ab provident ea aliquid nostrum
|
|
151
|
-
quaerat? Natus aut dignissimos, illo nisi officiis adipisci ipsam
|
|
152
|
-
totam quasi ratione laboriosam eius recusandae asperiores nobis quis
|
|
153
|
-
assumenda odio consectetur animi. Debitis architecto mollitia sapiente
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
116
|
</div>
|
|
157
117
|
)
|
|
158
118
|
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
/** 动态路由 App.tsx */
|
|
124
|
+
import { createEffect, lazy, type Component } from 'solid-js'
|
|
125
|
+
import { Route, Router } from '@solidjs/router'
|
|
126
|
+
import { useAlive,AliveTransfer } from "solid-alive"
|
|
127
|
+
|
|
128
|
+
const modules = import.meta.glob<{ default: Component<any> }>([
|
|
129
|
+
'./views/**/**.tsx',
|
|
130
|
+
'./views/**.tsx'
|
|
131
|
+
])
|
|
132
|
+
|
|
133
|
+
const transferRouter = (data: MenuData[]) =>
|
|
134
|
+
data.flatMap(item => {
|
|
135
|
+
let m = modules[`./views${item.realPath}`]
|
|
136
|
+
if (!m) return []
|
|
137
|
+
const Transfer = (props: any) =>
|
|
138
|
+
AliveTransfer(
|
|
139
|
+
lazy(m).bind(null, props),
|
|
140
|
+
item.path,
|
|
141
|
+
item.children?.map(item => item.path)
|
|
142
|
+
)
|
|
143
|
+
return (
|
|
144
|
+
<Route component={Transfer} path={item.path.split('/').at(-1)}>
|
|
145
|
+
{item.children ? transferRouter(item.children) : null}
|
|
146
|
+
</Route>
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const App: Component = () => {
|
|
151
|
+
const { aliveFrozen } = useAlive()
|
|
152
|
+
|
|
153
|
+
const [data, setData] = createStore<MenuData[]>([])
|
|
154
|
+
const a: MenuData = {
|
|
155
|
+
id: 2,
|
|
156
|
+
text: 'ABOUT',
|
|
157
|
+
path: '/about',
|
|
158
|
+
realPath: '/About/index.tsx',
|
|
159
|
+
parentId: null,
|
|
160
|
+
hidden: 0,
|
|
161
|
+
sort: 2,
|
|
162
|
+
cache: 1
|
|
163
|
+
}
|
|
164
|
+
const addRoute =()=>{
|
|
165
|
+
aliveFrozen() // 暂时不响应下面数据变化
|
|
166
|
+
setData(d => {
|
|
167
|
+
return [...d, a]
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Router>
|
|
173
|
+
<Route component={Client}>
|
|
174
|
+
{/* treeData 将 data变成 树结构数据 */}
|
|
175
|
+
{transferRouter(treeData(data, 'id', 'parentId'))}
|
|
176
|
+
</Route>
|
|
177
|
+
</Router>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export default App
|
|
182
|
+
|
|
183
|
+
|
|
159
184
|
```
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createComponent as e}from"solid-js/web";import{createStore as
|
|
1
|
+
import{createComponent as e}from"solid-js/web";import{createStore as n,produce as t}from"solid-js/store";import{createContext as o,on as r,useContext as l,createRoot as i,createEffect as a,onCleanup as c}from"solid-js";var v=o({elements:{},info:{frozen:!1},setInfo:()=>{},insertElement:()=>{},onDeactivated:()=>{},onActivated:()=>{},removeAliveElement:()=>{},setCurrentComponentId:()=>{},insertCacheCb:()=>{}});function d(o){let[l,i]=n(),[a,c]=n({frozen:!0}),d="",s=new Map,f=new Map,u={cbType:"",caller:"",path:""};var m=e=>{var n;if(Reflect.has(l,e)){var t=null===(n=l[e])||void 0===n?void 0:n.children;null==t||t.forEach((n=>n!==e&&m(n))),i((n=>{var t,o;return n[e].onDeactivated=null,n[e].component=null,null===(o=(t=n[e]).dispose)||void 0===o||o.call(t),n[e].dispose=null,n[e].onActivated=null,n[e].onDeactivated=null,n[e].children=null,n[e]=null,delete n[e],n}))}},p=e=>{var{caller:n,path:t}=function(){var e=null,n=null;try{throw new Error}catch(i){var t=i.stack.split("\n"),o=t[0].includes("@")?5:6,r=t[o].trim(),l=r.includes("@")?r.split("@"):r.split(" ").slice(1);e=l[0],n=l[1]}return{caller:e,path:n}}();return u.caller&&u.cbType===e&&u.caller===n&&u.path!==t?(console.warn(`[solid-alive]:检测到多个${e}函数 ${t}`),!1):(u={caller:n,path:t,cbType:e},!0)},h=(e,n)=>{if(!a.frozen&&n&&p(e)){var t={onActivated:s,onDeactivated:f}[e],o=t.get(d)||new Set;o.add(r([],n))&&t.set(d,o)}};return e(v.Provider,{value:{info:a,elements:l,setInfo:(e,n)=>{c(e,n)},onActivated:e=>{h("onActivated",e)},onDeactivated:e=>{h("onDeactivated",e)},insertElement:e=>{let n=e.id;i([n],Object.assign(Object.assign({},l[n]),e))},removeAliveElement:e=>{if(null==e)for(const e of Object.values(l))m(e.id);else m(e)},setCurrentComponentId:e=>{d=e},insertCacheCb:e=>{let n=s.get(e),o=f.get(e);s.delete(e),f.delete(e),Reflect.has(l,e)&&i(t((t=>{t[e].onActivated=n,t[e].onDeactivated=o,t[e].loaded=!0})))}},get children(){return o.children}})}let s=new Set([]);function f(n,t,o){var{info:r,elements:d,setInfo:f,insertElement:u,setCurrentComponentId:m,insertCacheCb:p}=l(v);Reflect.has(d,t)||(f("frozen",!1),m(t),i((r=>{u({id:t,dispose:r,component:e(n,{}),children:Array.isArray(o)?new Set(o):null})})));var h=e=>{var n;if(d[e].isTop)return e;var t=null===(n=Object.values(d).find((n=>{var t;return null===(t=n.children)||void 0===t?void 0:t.has(e)})))||void 0===n?void 0:n.id;return t&&(t=h(t)),t||e};return s.has(h(t))||s.clear(),a((()=>{var e,n;if(f("frozen",!1),!s.has(t))if(d[t].loaded)s.add(t),f("frozen",!0),null===(e=d[t].onActivated)||void 0===e||e.forEach((e=>e())),f("frozen",!1);else{let e=null===(n=d[t])||void 0===n?void 0:n.component;for(;"function"==typeof e;)e=e();e instanceof HTMLElement&&p(t)}})),c((()=>{var e;r.frozen||(f("frozen",!0),null===(e=d[t].onDeactivated)||void 0===e||e.forEach((e=>e())),f("frozen",!1))})),d[t].component}function u(){var{onActivated:e,onDeactivated:n,removeAliveElement:t,setInfo:o}=l(v);return{onActivated:e,onDeactivated:n,removeAliveElement:t,setInfo:o}}function m(e){var{onActivated:n}=u();n(e)}function p(e){var{onDeactivated:n}=u();n(e)}function h(){var{removeAliveElement:e,setInfo:n}=u();return{removeAliveElement:e,aliveFrozen:()=>n("frozen",!0)}}export{d as AliveProvider,f as AliveTransfer,m as onActivated,p as onDeactivated,h as useAlive};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { ProveiderProps } from
|
|
1
|
+
import { ProveiderProps } from "./default";
|
|
2
2
|
/**
|
|
3
3
|
* @description Alive
|
|
4
4
|
* @param children jsx.element
|
|
5
|
-
* @param { string } [scrollId] id,如 'root' 会在切换组件时的动作,默认saveScrollTop
|
|
6
|
-
* @param { 'alwaysTop'|'saveScroll' } [behavior] 'alwaysTop'|'saveScroll' dom元素滚动条会如何保持
|
|
7
|
-
* @param { 'appear'|'toLeft' } [transitionEnterName] 'appear'|'toLeft' 路由切换动画, 可以自己加,看dist 中的样式格式
|
|
8
5
|
*/
|
|
9
6
|
export default function AliveProvider(props: ProveiderProps): import("solid-js").JSX.Element;
|
package/dist/types/context.d.ts
CHANGED
package/dist/types/default.d.ts
CHANGED
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
import { JSX } from 'solid-js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
namespace JSX {
|
|
5
|
-
interface Directives {
|
|
6
|
-
directiveSaveScroll: ((dom: Element) => void) | boolean
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface pub {
|
|
12
|
-
scrollId?: string // 保存
|
|
13
|
-
behavior?: 'alwaysTop' | 'saveScroll'
|
|
14
|
-
transitionEnterName?: 'appear' | 'toLeft'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ProveiderProps extends pub {
|
|
3
|
+
export interface ProveiderProps {
|
|
18
4
|
children: JSX.Element
|
|
19
5
|
}
|
|
20
6
|
|
|
21
7
|
export interface NodeInfo {
|
|
22
8
|
id: string
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
domList?: Map<Element, { top: number; left: number }> | null
|
|
9
|
+
loaded?: boolean
|
|
10
|
+
component?: JSX.Element | null
|
|
26
11
|
children?: Set<string> | null
|
|
27
12
|
dispose?: (() => void) | null
|
|
28
13
|
onActivated?: null | Set<() => void>
|
|
29
14
|
onDeactivated?: null | Set<() => void>
|
|
30
|
-
isTop?: boolean
|
|
15
|
+
isTop?: boolean | null
|
|
31
16
|
}
|
|
32
17
|
|
|
33
|
-
|
|
34
18
|
export interface SetElement {
|
|
35
|
-
|
|
19
|
+
(id: string, values: NodeInfo): void
|
|
36
20
|
}
|
|
37
21
|
|
|
38
22
|
export interface StoreProps {
|
|
39
|
-
[
|
|
23
|
+
[key: string]: NodeInfo
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IInfo {
|
|
27
|
+
frozen: boolean
|
|
40
28
|
}
|
|
41
29
|
|
|
42
|
-
export
|
|
43
|
-
|
|
30
|
+
export type TSetInfo = <T extends keyof IInfo>(key: T, value: IInfo[T]) => void
|
|
31
|
+
|
|
32
|
+
export interface ContextProps {
|
|
44
33
|
elements: StoreProps
|
|
45
|
-
|
|
34
|
+
info: IInfo
|
|
35
|
+
setInfo: TSetInfo
|
|
46
36
|
insertElement: (d: NodeInfo) => void
|
|
47
37
|
onActivated: (cb: () => void) => void
|
|
48
38
|
onDeactivated: (cb: () => void) => void
|
|
49
39
|
removeAliveElement: (id?: string) => void
|
|
50
|
-
setElement: SetElement
|
|
51
40
|
setCurrentComponentId: (id: string | symbol) => void
|
|
52
|
-
|
|
53
|
-
resetElScroll: (dom: Element) => boolean // 重置高度, 变成0
|
|
54
|
-
removeScrollEl: (dom: Element) => boolean // 删除 保存的 滚动条 元素
|
|
41
|
+
insertCacheCb: (id: string) => void
|
|
55
42
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import AliveProvider from './AliveProvider';
|
|
2
2
|
import AliveTransfer from './AliveTransfer';
|
|
3
|
-
import useAlive from './useAlive';
|
|
4
|
-
export { AliveProvider, AliveTransfer, useAlive };
|
|
3
|
+
import { onActivated, onDeactivated, useAlive } from './useAlive';
|
|
4
|
+
export { AliveProvider, AliveTransfer, onActivated, onDeactivated, useAlive };
|
package/dist/types/useAlive.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
export declare function onActivated(fn: () => void): void;
|
|
2
|
+
export declare function onDeactivated(fn: () => void): void;
|
|
1
3
|
/**
|
|
2
|
-
* @returns onActivated 激活缓存组件时触发,
|
|
3
|
-
* @returns onDeactivated 退出缓存组件时触发,
|
|
4
4
|
* @returns removeAliveElement 删除缓存组件,
|
|
5
|
-
* @returns
|
|
6
|
-
* @returns resetElScroll 将缓存组件中 某个滚动条的scrollTop scrollLeft 变成 0
|
|
7
|
-
* @returns removeScrollEl 将缓存组件中 某个滚动条dom元素删除了
|
|
5
|
+
* @returns aliveFrozen 让 alive 暂时失去响应, 一般在加新增路由数据时使用
|
|
8
6
|
*/
|
|
9
|
-
declare function useAlive(): {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
removeAliveElement: (id?: string | undefined) => void;
|
|
13
|
-
directiveSaveScroll: (dom: Element) => void;
|
|
14
|
-
resetElScroll: (dom: Element) => boolean;
|
|
15
|
-
removeScrollEl: (dom: Element) => boolean;
|
|
7
|
+
export declare function useAlive(): {
|
|
8
|
+
removeAliveElement: (id?: string) => void;
|
|
9
|
+
aliveFrozen: () => void;
|
|
16
10
|
};
|
|
17
|
-
export default useAlive;
|
package/package.json
CHANGED
package/dist/styles/style.css
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.index-module_appear__MaHzX {
|
|
2
|
-
animation: index-module__appear__7KeRW .5s ease;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
@keyframes index-module__appear__7KeRW {
|
|
6
|
-
0% {
|
|
7
|
-
opacity: 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
100% {
|
|
11
|
-
opacity: 1;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.index-module_toLeft__s1PDL {
|
|
17
|
-
animation: index-module__toLeft__SD-Zp .5s ease;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@keyframes index-module__toLeft__SD-Zp {
|
|
21
|
-
0% {
|
|
22
|
-
opacity: 0;
|
|
23
|
-
transform: translateX(30px);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
100% {
|
|
27
|
-
opacity: 1;
|
|
28
|
-
transform: translateX(0);
|
|
29
|
-
}
|
|
30
|
-
}
|