@li3/use 0.1.7 → 0.1.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/src/async-state.d.ts +4 -4
- package/dist/src/index.d.ts +3 -2
- package/index.js +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -2
- package/src/vue.ts +1 -1
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* update();
|
|
7
7
|
*/
|
|
8
8
|
export declare function useAsyncState<T>(effect?: (...args: any[]) => Promise<T>): {
|
|
9
|
-
data: any
|
|
10
|
-
error:
|
|
11
|
-
loading:
|
|
12
|
-
empty:
|
|
9
|
+
data: import("@li3/web").Signal<any>;
|
|
10
|
+
error: import("@li3/web").Signal<string>;
|
|
11
|
+
loading: import("@li3/web").Signal<boolean>;
|
|
12
|
+
empty: import("@li3/web").Signal<boolean>;
|
|
13
13
|
update: (...args: any[]) => Promise<void>;
|
|
14
14
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { useAsyncState } from
|
|
2
|
-
export { useQuery } from
|
|
1
|
+
export { useAsyncState } from './async-state.js';
|
|
2
|
+
export { useQuery } from './query.js';
|
|
3
|
+
export { useVue } from './vue';
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ref as e,getElement as r}from"@li3/web";function t
|
|
1
|
+
import{ref as e,getElement as t,use as r,SetProperty as n,TemplateFor as c,TemplateIf as a,AddEventListener as l}from"@li3/web";function u(t=fetch){const r=e(""),n=e(!1),c=e(!1),a=e(null);return{data:a,error:r,loading:n,empty:c,update:async(...e)=>{n.value=!0,c.value=!1;try{const r=await t(...e);a.value=r,c.value=Array.isArray(r)?!r.length:!r}catch(e){c.value=!1,r.value=e}finally{n.value=!1}}}}function o(e){const r=t();return{get one(){return r.querySelector(e)},get all(){return r.querySelectorAll(e)}}}function s(){const e="v-for",t="v-if";r(new class extends n{match(e,t){return":"===t.at(0)}exec(e,t,r,n){return super.exec(e,"bind-"+t.slice(1),r,n)}}),r(new class extends c{match(t,r){return r===e}exec(t,r,n,c){const a=document.createElement("template");t.replaceWith(a),t.removeAttribute(e),a.content.append(t),super.exec(a,"for",n,c)}}),r(new class extends a{match(e,r){return r===t}exec(e,r,n,c){const a=document.createElement("template");e.replaceWith(a),e.removeAttribute(t),a.content.append(e),super.exec(a,"if",n,c)}}),r(new class extends l{match(e,t){return"@"===t.at(0)}exec(e,t,r,n){return super.exec(e,"on-"+t.slice(1),r,n)}})}export{u as useAsyncState,o as useQuery,s as useVue};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@li3/use",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./dist/index.js",
|
|
6
6
|
"./*": {
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
"url": "https://github.com/apphorde/lithium"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@li3/web": "
|
|
15
|
+
"@li3/web": ">=0.2.0"
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { useAsyncState } from
|
|
2
|
-
export { useQuery } from
|
|
1
|
+
export { useAsyncState } from './async-state.js';
|
|
2
|
+
export { useQuery } from './query.js';
|
|
3
|
+
export { useVue } from './vue';
|
package/src/vue.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function useVue() {
|
|
|
27
27
|
exec(node, _name, value, context) {
|
|
28
28
|
const t = document.createElement('template');
|
|
29
29
|
node.replaceWith(t);
|
|
30
|
-
node.removeAttribute(
|
|
30
|
+
node.removeAttribute(vIf);
|
|
31
31
|
t.content.append(node);
|
|
32
32
|
|
|
33
33
|
super.exec(t, 'if', value, context);
|