@aioha/providers 1.8.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TechCoderX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Aioha Framework Providers
2
+
3
+ Provides Aioha reactive states for various JavaScript frameworks for the ease of integration.
4
+
5
+ ## Supported Frameworks
6
+
7
+ * [React](https://github.com/aioha-hive/providers/tree/main/react)
8
+ * [Vue](https://github.com/aioha-hive/providers/tree/main/vue)
9
+ * [Lit](https://github.com/aioha-hive/providers/tree/main/lit)
10
+ * [Svelte](https://github.com/aioha-hive/providers/tree/main/svelte)
11
+
12
+ ## Installation and Usage
13
+
14
+ Refer to the documentation [here](https://aioha.dev/docs/framework).
@@ -0,0 +1,24 @@
1
+ import { LitElement } from 'lit';
2
+ import type { Aioha, Providers, PersistentLoginProvs } from '@aioha/aioha';
3
+ export declare const AiohaCtx: {
4
+ __context__: Aioha;
5
+ };
6
+ export declare const UserCtx: {
7
+ __context__: string | undefined;
8
+ };
9
+ export declare const ProviderCtx: {
10
+ __context__: Providers | undefined;
11
+ };
12
+ export declare const OtherUsersCtx: {
13
+ __context__: PersistentLoginProvs;
14
+ };
15
+ export declare class AiohaProvider extends LitElement {
16
+ aioha: Aioha;
17
+ private _user?;
18
+ private _provider?;
19
+ private _otherUsers;
20
+ connectedCallback(): void;
21
+ disconnectedCallback(): void;
22
+ private _update;
23
+ render(): import("lit").TemplateResult<1>;
24
+ }
@@ -0,0 +1,70 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, html } from 'lit';
8
+ import { customElement, property, state } from 'lit/decorators.js';
9
+ import { createContext, provide } from '@lit/context';
10
+ // Create the context
11
+ export const AiohaCtx = createContext(Symbol('AiohaContext'));
12
+ export const UserCtx = createContext(Symbol('AiohaUser'));
13
+ export const ProviderCtx = createContext(Symbol('AiohaProvider'));
14
+ export const OtherUsersCtx = createContext(Symbol('AiohaOtherUsers'));
15
+ let AiohaProvider = class AiohaProvider extends LitElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this._otherUsers = {};
19
+ }
20
+ connectedCallback() {
21
+ super.connectedCallback();
22
+ // Initialize state
23
+ this._user = this.aioha.getCurrentUser();
24
+ this._provider = this.aioha.getCurrentProvider();
25
+ this._otherUsers = this.aioha.getOtherLogins();
26
+ // Set up event listeners
27
+ this.aioha.on('connect', this._update);
28
+ this.aioha.on('disconnect', this._update);
29
+ this.aioha.on('account_changed', this._update);
30
+ }
31
+ disconnectedCallback() {
32
+ super.disconnectedCallback();
33
+ // Clean up event listeners
34
+ this.aioha.off('connect', this._update);
35
+ this.aioha.off('disconnect', this._update);
36
+ this.aioha.off('account_changed', this._update);
37
+ }
38
+ _update() {
39
+ this._user = this.aioha.getCurrentUser();
40
+ this._provider = this.aioha.getCurrentProvider();
41
+ this._otherUsers = this.aioha.getOtherLogins();
42
+ }
43
+ render() {
44
+ return html `<slot></slot>`;
45
+ }
46
+ };
47
+ __decorate([
48
+ provide({ context: AiohaCtx }),
49
+ property({ attribute: false })
50
+ ], AiohaProvider.prototype, "aioha", void 0);
51
+ __decorate([
52
+ provide({ context: UserCtx }),
53
+ state()
54
+ //@ts-ignore
55
+ ], AiohaProvider.prototype, "_user", void 0);
56
+ __decorate([
57
+ provide({ context: ProviderCtx }),
58
+ state()
59
+ //@ts-ignore
60
+ ], AiohaProvider.prototype, "_provider", void 0);
61
+ __decorate([
62
+ provide({ context: OtherUsersCtx }),
63
+ state()
64
+ //@ts-ignore
65
+ ], AiohaProvider.prototype, "_otherUsers", void 0);
66
+ AiohaProvider = __decorate([
67
+ customElement('aioha-provider')
68
+ ], AiohaProvider);
69
+ export { AiohaProvider };
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lit/lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGrD,qBAAqB;AACrB,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAQ,MAA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CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACjD,CAAC;IAEO,OAAO;QACb,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAA;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAA;QAChD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAA;IAChD,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,eAAe,CAAA;IAC5B,CAAC;CACF,CAAA;AAjDC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAClB;AAKL;IAHP,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC7B,KAAK,EAAE;IACR,YAAY;4CACU;AAKd;IAHP,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IACjC,KAAK,EAAE;IACR,YAAY;gDACiB;AAKrB;IAHP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IACnC,KAAK,EAAE;IACR,YAAY;kDACkC;AAlBnC,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAoDzB"}
@@ -0,0 +1,18 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { Aioha, Providers, PersistentLoginProvs } from '@aioha/aioha';
3
+ export declare const AiohaContext: React.Context<{
4
+ aioha: Aioha;
5
+ user?: string;
6
+ provider?: Providers;
7
+ otherUsers: PersistentLoginProvs;
8
+ } | undefined>;
9
+ export declare const AiohaProvider: ({ aioha, children }: {
10
+ aioha: Aioha;
11
+ children: ReactNode;
12
+ }) => React.JSX.Element;
13
+ export declare const useAioha: () => {
14
+ aioha: Aioha;
15
+ user?: string;
16
+ provider?: Providers;
17
+ otherUsers: PersistentLoginProvs;
18
+ };
@@ -0,0 +1,35 @@
1
+ import React, { createContext, useContext, useEffect, useState } from 'react';
2
+ export const AiohaContext = createContext(undefined);
3
+ export const AiohaProvider = ({ aioha, children }) => {
4
+ const [user, setUser] = useState(aioha.getCurrentUser());
5
+ const [provider, setProvider] = useState(aioha.getCurrentProvider());
6
+ const [otherUsers, setOtherUsers] = useState(aioha.getOtherLogins());
7
+ const update = () => {
8
+ setUser(aioha.getCurrentUser());
9
+ setProvider(aioha.getCurrentProvider());
10
+ setOtherUsers(aioha.getOtherLogins());
11
+ };
12
+ useEffect(() => {
13
+ aioha.on('connect', update);
14
+ aioha.on('disconnect', update);
15
+ aioha.on('account_changed', update);
16
+ return () => {
17
+ aioha.off('connect', update);
18
+ aioha.off('disconnect', update);
19
+ aioha.off('account_changed', update);
20
+ };
21
+ }, []);
22
+ return (React.createElement(AiohaContext.Provider, { value: {
23
+ aioha,
24
+ user,
25
+ provider,
26
+ otherUsers
27
+ } }, children));
28
+ };
29
+ export const useAioha = () => {
30
+ const ctx = useContext(AiohaContext);
31
+ if (!ctx)
32
+ throw new Error('useAioha must be used within an AiohaProvider');
33
+ return ctx;
34
+ };
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../react/lib/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGxF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAQvC,SAAS,CAAC,CAAA;AAEZ,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAyC,EAAE,EAAE;IAC1F,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAqB,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAC5E,MAAM,CAAC,QAAQ,EAAE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Z,CAAC,CAAA"}
@@ -0,0 +1,36 @@
1
+ <script lang="ts">
2
+ import { onMount, setContext } from 'svelte'
3
+ import type { Aioha } from '@aioha/aioha'
4
+ import { AiohaCtxKey } from '../context.js'
5
+
6
+ const { aioha, children }: { aioha: Aioha; children: any } = $props()
7
+
8
+ let ctx = $state({
9
+ aioha: aioha,
10
+ user: aioha.getCurrentUser(),
11
+ provider: aioha.getCurrentProvider(),
12
+ otherUsers: aioha.getOtherLogins()
13
+ })
14
+
15
+ const update = () => {
16
+ ctx.user = aioha.getCurrentUser()
17
+ ctx.provider = aioha.getCurrentProvider()
18
+ ctx.otherUsers = aioha.getOtherLogins()
19
+ }
20
+
21
+ onMount(() => {
22
+ aioha.on('connect', update)
23
+ aioha.on('disconnect', update)
24
+ aioha.on('account_changed', update)
25
+
26
+ return () => {
27
+ aioha.off('connect', update)
28
+ aioha.off('disconnect', update)
29
+ aioha.off('account_changed', update)
30
+ }
31
+ })
32
+
33
+ setContext(AiohaCtxKey, ctx)
34
+ </script>
35
+
36
+ {@render children()}
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -0,0 +1,8 @@
1
+ import { Aioha, PersistentLoginProvs, Providers } from '@aioha/aioha';
2
+ export declare const AiohaCtxKey: unique symbol;
3
+ export interface AiohaContext {
4
+ aioha: Aioha;
5
+ user: string | undefined;
6
+ provider: Providers | undefined;
7
+ otherUsers: PersistentLoginProvs;
8
+ }
@@ -0,0 +1 @@
1
+ export const AiohaCtxKey = Symbol('AiohaContext');
@@ -0,0 +1,3 @@
1
+ import { default as AiohaProvider } from './components/AiohaProvider.svelte';
2
+ export { AiohaProvider };
3
+ export { AiohaCtxKey, type AiohaContext } from './context.js';
@@ -0,0 +1,3 @@
1
+ import AiohaProvider from './components/AiohaProvider.svelte';
2
+ export { AiohaProvider };
3
+ export { AiohaCtxKey } from './context.js';
@@ -0,0 +1,22 @@
1
+ import { Aioha } from '@aioha/aioha';
2
+ interface Props {
3
+ aioha: Aioha;
4
+ }
5
+ declare function __VLS_template(): {
6
+ attrs: Partial<{}>;
7
+ slots: {
8
+ default?(_: {}): any;
9
+ };
10
+ refs: {};
11
+ rootEl: any;
12
+ };
13
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
14
+ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
15
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
+ export default _default;
17
+ type __VLS_WithTemplateSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
22
+ //# sourceMappingURL=AiohaProvider.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiohaProvider.vue.d.ts","sourceRoot":"","sources":["../../../vue/lib/components/AiohaProvider.vue"],"names":[],"mappings":"AAkDA,OAAO,EAAE,KAAK,EAAmC,MAAM,cAAc,CAAA;AAIrE,UAAU,KAAK;IACb,KAAK,EAAE,KAAK,CAAA;CACb;AAsCD,iBAAS,cAAc;WAoBT,OAAO,IAA6B;;yBAVrB,GAAG;;;;EAe/B;AAQD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,sRAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ import { Aioha, Providers, PersistentLoginProvs } from '@aioha/aioha';
3
+ export declare const AiohaCtx: InjectionKey<Aioha>;
4
+ export declare const UserCtx: InjectionKey<Ref<string | undefined>>;
5
+ export declare const ProviderCtx: InjectionKey<Ref<Providers | undefined>>;
6
+ export declare const OtherUsersCtx: InjectionKey<Ref<PersistentLoginProvs>>;
7
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../vue/lib/composables/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAGrE,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,KAAK,CAA0B,CAAA;AACnE,eAAO,MAAM,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAuB,CAAA;AACjF,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAA2B,CAAA;AAC5F,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAA6B,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Ref } from 'vue';
2
+ import { Aioha, Providers, PersistentLoginProvs } from '@aioha/aioha';
3
+ export interface AiohaContext {
4
+ aioha: Aioha;
5
+ user?: Ref<string | undefined>;
6
+ provider?: Ref<Providers | undefined>;
7
+ otherUsers: Ref<PersistentLoginProvs>;
8
+ }
9
+ export declare const useAioha: () => AiohaContext;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../vue/lib/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,GAAG,EAAE,MAAM,KAAK,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAG1E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC9B,QAAQ,CAAC,EAAE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;IACrC,UAAU,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAA;CACtC;AAED,eAAO,MAAM,QAAQ,QAAO,YAS3B,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { default as AiohaProvider } from './components/AiohaProvider.vue';
2
+ import { useAioha } from './composables/index.js';
3
+ export { AiohaProvider, useAioha };
4
+ export { AiohaCtx, UserCtx, ProviderCtx, OtherUsersCtx } from './composables/context.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../vue/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,gCAAgC,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { defineComponent as p, ref as s, onMounted as m, onUnmounted as g, provide as a, renderSlot as l, inject as i } from "vue";
2
+ const c = Symbol("AiohaContext"), u = Symbol("AiohaUser"), d = Symbol("AiohaProvider"), v = Symbol("AiohaOtherUsers"), U = /* @__PURE__ */ p({
3
+ __name: "AiohaProvider",
4
+ props: {
5
+ aioha: {}
6
+ },
7
+ setup(n) {
8
+ const o = n, r = s(o.aioha.getCurrentUser()), t = s(o.aioha.getCurrentProvider()), h = s(o.aioha.getOtherLogins()), e = () => {
9
+ r.value = o.aioha.getCurrentUser(), t.value = o.aioha.getCurrentProvider(), h.value = o.aioha.getOtherLogins();
10
+ };
11
+ return m(() => {
12
+ o.aioha.on("connect", e), o.aioha.on("disconnect", e), o.aioha.on("account_changed", e);
13
+ }), g(() => {
14
+ o.aioha.off("connect", e), o.aioha.off("disconnect", e), o.aioha.off("account_changed", e);
15
+ }), a(c, o.aioha), a(u, r), a(d, t), a(v, h), (f, A) => l(f.$slots, "default");
16
+ }
17
+ }), P = () => {
18
+ const n = i(c), o = i(u), r = i(d), t = i(v);
19
+ if (!n || !o || !r || !t)
20
+ throw new Error("useAioha must be used within an AiohaProvider");
21
+ return { aioha: n, user: o, provider: r, otherUsers: t };
22
+ };
23
+ export {
24
+ c as AiohaCtx,
25
+ U as AiohaProvider,
26
+ v as OtherUsersCtx,
27
+ d as ProviderCtx,
28
+ u as UserCtx,
29
+ P as useAioha
30
+ };
@@ -0,0 +1 @@
1
+ (function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.AiohaVueProvider={},t.vue))})(this,(function(t,o){"use strict";const s=Symbol("AiohaContext"),h=Symbol("AiohaUser"),c=Symbol("AiohaProvider"),d=Symbol("AiohaOtherUsers"),u=o.defineComponent({__name:"AiohaProvider",props:{aioha:{}},setup(a){const e=a,i=o.ref(e.aioha.getCurrentUser()),r=o.ref(e.aioha.getCurrentProvider()),f=o.ref(e.aioha.getOtherLogins()),n=()=>{i.value=e.aioha.getCurrentUser(),r.value=e.aioha.getCurrentProvider(),f.value=e.aioha.getOtherLogins()};return o.onMounted(()=>{e.aioha.on("connect",n),e.aioha.on("disconnect",n),e.aioha.on("account_changed",n)}),o.onUnmounted(()=>{e.aioha.off("connect",n),e.aioha.off("disconnect",n),e.aioha.off("account_changed",n)}),o.provide(s,e.aioha),o.provide(h,i),o.provide(c,r),o.provide(d,f),(C,l)=>o.renderSlot(C.$slots,"default")}}),p=()=>{const a=o.inject(s),e=o.inject(h),i=o.inject(c),r=o.inject(d);if(!a||!e||!i||!r)throw new Error("useAioha must be used within an AiohaProvider");return{aioha:a,user:e,provider:i,otherUsers:r}};t.AiohaCtx=s,t.AiohaProvider=u,t.OtherUsersCtx=d,t.ProviderCtx=c,t.UserCtx=h,t.useAioha=p,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@aioha/providers",
3
+ "version": "1.8.0",
4
+ "description": "Framework-specific providers for Aioha",
5
+ "type": "module",
6
+ "exports": {
7
+ "./lit": {
8
+ "types": "./dist/lit/index.d.ts",
9
+ "import": "./dist/lit/index.js"
10
+ },
11
+ "./react": {
12
+ "types": "./dist/react/index.d.ts",
13
+ "import": "./dist/react/index.js"
14
+ },
15
+ "./vue": {
16
+ "types": "./dist/vue/index.d.ts",
17
+ "import": "./dist/vue/index.js",
18
+ "require": "./dist/vue/index.umd.cjs"
19
+ },
20
+ "./svelte": {
21
+ "types": "./dist/svelte/index.d.ts",
22
+ "svelte": "./dist/svelte/index.js"
23
+ }
24
+ },
25
+ "keywords": [
26
+ "aioha",
27
+ "react",
28
+ "vue",
29
+ "hive",
30
+ "blockchain",
31
+ "authentication",
32
+ "web3"
33
+ ],
34
+ "author": "techcoderx",
35
+ "license": "MIT",
36
+ "homepage": "https://aioha.dev",
37
+ "repository": {
38
+ "url": "https://github.com/aioha-hive/providers"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/aioha-hive/providers/issues"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "LICENSE",
46
+ "README.md"
47
+ ],
48
+ "devDependencies": {
49
+ "@aioha/aioha": "^1.8.0",
50
+ "@lit/context": "^1.1.6",
51
+ "@sveltejs/package": "^2.5.4",
52
+ "@sveltejs/vite-plugin-svelte": "^6.2.1",
53
+ "@tsconfig/svelte": "^5.0.5",
54
+ "@types/node": "^24.6.0",
55
+ "@types/react": "^19.1.8",
56
+ "@vitejs/plugin-vue": "^6.0.1",
57
+ "lit": "^3.3.1",
58
+ "react": "^19.1.0",
59
+ "svelte": "^5.0.0",
60
+ "typescript": "^5.9.2",
61
+ "vite": "^7.1.7",
62
+ "vite-plugin-dts": "^4.5.4",
63
+ "vue": "^3.5.22",
64
+ "vue-tsc": "^3.1.0"
65
+ },
66
+ "peerDependencies": {
67
+ "@aioha/aioha": "^1.8.0",
68
+ "@lit/context": "^1.1.0",
69
+ "lit": "^3.3.0",
70
+ "react": "^19.1.0",
71
+ "svelte": "^5.0.0",
72
+ "vue": "^3.0.0"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@lit/context": {
76
+ "optional": true
77
+ },
78
+ "lit": {
79
+ "optional": true
80
+ },
81
+ "react": {
82
+ "optional": true
83
+ },
84
+ "svelte": {
85
+ "optional": true
86
+ },
87
+ "vue": {
88
+ "optional": true
89
+ }
90
+ },
91
+ "scripts": {
92
+ "build:lit": "cd lit && tsc",
93
+ "build:react": "cd react && tsc",
94
+ "build:vue": "cd vue && vue-tsc && vite build",
95
+ "build:svelte": "cd svelte && vite build && cd ../ && svelte-package --tsconfig svelte/tsconfig.json -i svelte/lib -o dist/svelte -t -p && rm dist/svelte/index.es.js",
96
+ "build": "pnpm run build:lit && pnpm run build:react && pnpm run build:vue && pnpm run build:svelte",
97
+ "prepublish": "rm -rf dist/* && pnpm run build",
98
+ "test": "echo \"Error: no test specified\" && exit 1"
99
+ }
100
+ }