@pushizo/vue 0.0.0-stage → 0.1.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) 2026 Pushizo contributors
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 CHANGED
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ <!-- pushizo:header -->
2
+ <p align="center">
3
+ <a href="https://pushizo.com"><img src="https://raw.githubusercontent.com/pushizo/.github/main/profile/assets/mark.svg" alt="Pushizo" width="56" height="56"></a>
4
+ </p>
5
+ <p align="center">
6
+ <a href="https://docs.pushizo.com/docs/integrations/vue"><img src="https://img.shields.io/badge/docs-docs.pushizo.com-5b4bdb" alt="Docs"></a>
7
+ <a href="https://docs.pushizo.com/docs/api"><img src="https://img.shields.io/badge/API-reference-b44fc4" alt="API reference"></a>
8
+ <a href="https://github.com/pushizo/pushizo-vue/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-16130f" alt="License: MIT"></a>
9
+ </p>
10
+ <p align="center"><a href="#english">English</a> · <a href="#türkçe">Türkçe</a></p>
2
11
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
12
+ ## English
13
+
14
+ **Pushizo for Vue** — Vue plugin for the Pushizo Web SDK. app.use(PushizoPlugin, options) initializes the shared SDK once in the browser (SSR safe); the usePushizo composable exposes reactive permission and push subscription state, and $pushizo is available in every component. Works with Vue 3 and Vue 2.7.
15
+
16
+ > **Status:** @pushizo/vue 0.1.0 is not on npm yet; until then you can install the release archive from this repository.<br>
17
+ > **Durum:** @pushizo/vue 0.1.0 henüz npm'de değil; o zamana kadar bu deponun sürüm arşivinden kurabilirsiniz.
18
+
19
+ **Install from GitHub until then · O zamana kadar GitHub'dan kurulum:**
20
+
21
+ ```bash
22
+ npm install @pushizo/web --allow-remote=root https://github.com/pushizo/pushizo-vue/releases/download/v0.1.0/pushizo-vue-0.1.0.tgz
23
+ ```
24
+
25
+ **After publication · Yayından sonra:**
26
+
27
+ ```bash
28
+ npm install @pushizo/vue @pushizo/web
29
+ ```
30
+
31
+ The detailed guide below is in Turkish; code samples are language-neutral. Full documentation:
32
+ [docs.pushizo.com/docs/integrations/vue](https://docs.pushizo.com/docs/integrations/vue) · API reference: [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
33
+
34
+ ## Türkçe
35
+ <!-- /pushizo:header -->
36
+
37
+ # @pushizo/vue
38
+
39
+ Pushizo Web SDK'sı (`@pushizo/web`) için Vue eklentisi: `app.use(PushizoPlugin, options)` paylaşılan SDK örneğini
40
+ tarayıcıda bir kez başlatır, `usePushizo()` composable'ı izin ve push abonelik durumunu reaktif olarak verir,
41
+ bileşenlerde `$pushizo` global özelliği kullanılabilir.
42
+
43
+ - Vue 3 ve Vue 2.7 aynı pakettir (yalnızca iki sürümde ortak Composition API kullanılır).
44
+ - SSR güvenli: sunucuda (Nuxt, `createSSRApp`) `init` çağrılmaz, gözlemci bağlanmaz.
45
+ - Eklenti birden çok kez kurulsa da SDK bir kez başlatılır. Vue 3'te uygulama sökülünce gözlemciler kaldırılır;
46
+ `onNotificationClick` dinleyicisi bileşen kapsamı bitince kaldırılır.
47
+
48
+ ## Kurulum
49
+
50
+ ```bash
51
+ npm install @pushizo/vue @pushizo/web
52
+ ```
53
+
54
+ Service worker site kökünde olmalıdır (`public/PushizoSDKWorker.js`):
55
+
56
+ ```js
57
+ // public/PushizoSDKWorker.js
58
+ const apiUrl = new URL(self.location.href).searchParams.get('apiUrl') || 'https://api.pushizo.com';
59
+ importScripts(`${apiUrl.replace(/\/$/, '')}/sdk-web/PushizoSDKWorker.js`);
60
+ ```
61
+
62
+ ## Kullanım
63
+
64
+ ```ts
65
+ // main.ts (Vue 3)
66
+ import { createApp } from 'vue';
67
+ import { PushizoPlugin } from '@pushizo/vue';
68
+ import App from './App.vue';
69
+
70
+ createApp(App).use(PushizoPlugin, { appId: 'app_…', serviceWorkerPath: '/PushizoSDKWorker.js' }).mount('#app');
71
+ ```
72
+
73
+ ```ts
74
+ // main.ts (Vue 2.7)
75
+ import Vue from 'vue';
76
+ import { PushizoPlugin } from '@pushizo/vue';
77
+
78
+ Vue.use(PushizoPlugin, { appId: 'app_…' });
79
+ ```
80
+
81
+ ```vue
82
+ <script setup lang="ts">
83
+ import { onNotificationClick, usePushizo } from '@pushizo/vue';
84
+
85
+ const { pushizo, ready, error, permission, pushSubscription } = usePushizo();
86
+ onNotificationClick(({ notification, result }) => {
87
+ window.location.assign(result.url ?? notification.url ?? '/');
88
+ });
89
+ </script>
90
+
91
+ <template>
92
+ <p v-if="error" role="alert">{{ error.message }}</p>
93
+ <p v-else-if="!ready">Yükleniyor…</p>
94
+ <p v-else-if="permission === 'unsupported'">Bu tarayıcı web push desteklemiyor.</p>
95
+ <p v-else-if="permission === 'denied'">Bildirimler tarayıcı ayarlarından engellenmiş.</p>
96
+ <button v-else-if="pushSubscription.optedIn" @click="pushizo.User.pushSubscription.optOut()">Bildirimleri kapat</button>
97
+ <button v-else @click="pushizo.Notifications.requestPermission()">Bildirimlere izin ver</button>
98
+ </template>
99
+ ```
100
+
101
+ Options API: `this.$pushizo.User.addTags({ plan: 'pro' })`.
102
+
103
+ ## API
104
+
105
+ | Ad | Açıklama |
106
+ |----|----------|
107
+ | `PushizoPlugin` | `app.use(PushizoPlugin, options)` / `Vue.use(PushizoPlugin, options)`; `Pushizo.init` tarayıcıda bir kez. |
108
+ | `usePushizo()` | `{ pushizo, state, ready, error, permission, pushSubscription }` (salt okunur ref/computed). |
109
+ | `onNotificationClick(handler)` | Bildirim tıklaması dinleyicisi; kapsam bitince kaldırılır, dönen işlevle elle de kaldırılır. |
110
+ | `$pushizo` | Paylaşılan SDK örneği (tüm bileşenlerde). |
111
+
112
+ `init` hatası fırlatılmaz, `error` ref'ine yazılır. Vue 2.7'de uygulama düzeyinde söküm kancası olmadığından
113
+ gözlemciler sayfa ömrü boyunca bağlı kalır. TypeScript'te `$pushizo` tipi Vue 3'ün `ComponentCustomProperties`
114
+ arayüzüne eklenir.
115
+
116
+ Ayrıntılı rehber (Nuxt, login/logout, tag ve olaylar, bildirim kutusu): [Vue rehberi](https://docs.pushizo.com/docs/integrations/vue).
117
+
118
+ <!-- pushizo:footer -->
119
+ ---
120
+
121
+ ## Support · Destek
122
+
123
+ - **Guide · Rehber:** [docs.pushizo.com/docs/integrations/vue](https://docs.pushizo.com/docs/integrations/vue)
124
+ - **API reference & OpenAPI · API referansı ve OpenAPI:** [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api) ·
125
+ [pushizo-openapi](https://github.com/pushizo/pushizo-openapi)
126
+ - **Bugs & ideas · Hata ve öneri:** [Issues](https://github.com/pushizo/pushizo-vue/issues)
127
+ - **Security · Güvenlik:** please do not open public issues; email [security@pushizo.com](mailto:security@pushizo.com) ·
128
+ herkese açık issue açmayın, bu adrese yazın.
129
+ - **Help · Destek:** [support@pushizo.com](mailto:support@pushizo.com)
130
+
131
+ This repository is mirrored automatically from the Pushizo main repository on every release. Please open an issue
132
+ instead of a pull request; fixes land in the main repository and ship with the next release.
133
+ Bu depo her sürümde Pushizo ana deposundan otomatik yansıtılır. Pull request yerine issue açın; düzeltmeler ana depoda
134
+ yapılır ve bir sonraki sürümle buraya gelir.
135
+
136
+ Released under the MIT License · MIT lisanslıdır — [LICENSE](https://github.com/pushizo/pushizo-vue/blob/main/LICENSE).
137
+ <!-- /pushizo:footer -->
@@ -0,0 +1,48 @@
1
+ import type { InitOptions, PermissionState, PushSubscriptionState, PushizoSdk } from '@pushizo/web';
2
+ export interface PushizoState {
3
+ /** `init` başarıyla tamamlandı. */
4
+ ready: boolean;
5
+ /** `init` hatası (ör. eksik `appId`); yoksa null. */
6
+ error: Error | null;
7
+ /** Tarayıcı bildirim izni (`Notifications.permission`). */
8
+ permission: PermissionState;
9
+ /** Push abonelik durumu (`User.pushSubscription.state`). */
10
+ pushSubscription: PushSubscriptionState;
11
+ }
12
+ type StateListener = (state: PushizoState) => void;
13
+ /** Tarayıcı dışı (SSR, Node, worker) ortamda SDK'ya dokunulmaz. */
14
+ export declare function isBrowser(): boolean;
15
+ /** Sunucuda ve hidrasyonun ilk çiziminde kullanılan sabit durum. */
16
+ export declare const SERVER_STATE: PushizoState;
17
+ export declare class PushizoBinding {
18
+ readonly sdk: PushizoSdk;
19
+ private state;
20
+ private readonly listeners;
21
+ private initPromise;
22
+ private connections;
23
+ private detach;
24
+ constructor(sdk: PushizoSdk);
25
+ getState: () => PushizoState;
26
+ /** Durum değişikliği aboneliği; dönen fonksiyon aboneliği kaldırır. */
27
+ subscribe: (listener: StateListener) => (() => void);
28
+ /**
29
+ * SDK'yı bir kez başlatır. Tekrarlanan çağrılar (React StrictMode, birden çok eklenti kurulumu) ilk çağrının
30
+ * sözünü döndürür; sonraki seçenekler yok sayılır. Söz reddedilmez: hata `state.error` alanına yazılır.
31
+ * Tarayıcı dışında hiçbir şey yapmaz.
32
+ */
33
+ init(options: InitOptions): Promise<void>;
34
+ /**
35
+ * Web SDK gözlemcilerini bağlar (referans sayımlı). Son bağlantı kapanınca gözlemciler kaldırılır.
36
+ * Tarayıcı dışında no-op döndürür.
37
+ */
38
+ connect(): () => void;
39
+ /** Etkin gözlemci bağlantısı sayısı (test ve tanılama amaçlı). */
40
+ get connectionCount(): number;
41
+ private read;
42
+ private update;
43
+ }
44
+ /** Paylaşılan `@pushizo/web` örneğine bağlı tekil bağlama. */
45
+ export declare function getBinding(): PushizoBinding;
46
+ /** Yalnızca birim testleri için: tekil bağlamayı sıfırlar (paketin dışa aktarımlarında yer almaz). */
47
+ export declare function resetBinding(): void;
48
+ export {};
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Çerçeveden bağımsız bağlama çekirdeği: paylaşılan `@pushizo/web` örneğini tek kez başlatır ve web SDK'nın
3
+ * gözlemcilerinden (izin, push aboneliği) tek bir durum nesnesi üretir.
4
+ *
5
+ * Bu dosya `sdk/react`, `sdk/vue` ve `sdk/angular` paketlerinde aynı içerikle tutulur: her paket ayrı yayın birimidir
6
+ * (ADR-0055 §1) ve ortak bir ara paket yayımlamamak için kopyalanır. Değişiklik üç dosyaya birlikte yapılır.
7
+ */
8
+ import Pushizo from '@pushizo/web';
9
+ /** Tarayıcı dışı (SSR, Node, worker) ortamda SDK'ya dokunulmaz. */
10
+ export function isBrowser() {
11
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
12
+ }
13
+ /** Sunucuda ve hidrasyonun ilk çiziminde kullanılan sabit durum. */
14
+ export const SERVER_STATE = Object.freeze({
15
+ ready: false,
16
+ error: null,
17
+ permission: 'default',
18
+ pushSubscription: Object.freeze({ id: null, token: null, optedIn: false, permission: 'default' }),
19
+ });
20
+ function sameSubscription(a, b) {
21
+ return (a.id === b.id && a.token === b.token && a.optedIn === b.optedIn && a.permission === b.permission);
22
+ }
23
+ function toError(err) {
24
+ return err instanceof Error ? err : new Error(String(err));
25
+ }
26
+ export class PushizoBinding {
27
+ sdk;
28
+ state;
29
+ listeners = new Set();
30
+ initPromise = null;
31
+ connections = 0;
32
+ detach = null;
33
+ constructor(sdk) {
34
+ this.sdk = sdk;
35
+ this.state = isBrowser() ? this.read(false, null) : SERVER_STATE;
36
+ }
37
+ getState = () => this.state;
38
+ /** Durum değişikliği aboneliği; dönen fonksiyon aboneliği kaldırır. */
39
+ subscribe = (listener) => {
40
+ this.listeners.add(listener);
41
+ return () => {
42
+ this.listeners.delete(listener);
43
+ };
44
+ };
45
+ /**
46
+ * SDK'yı bir kez başlatır. Tekrarlanan çağrılar (React StrictMode, birden çok eklenti kurulumu) ilk çağrının
47
+ * sözünü döndürür; sonraki seçenekler yok sayılır. Söz reddedilmez: hata `state.error` alanına yazılır.
48
+ * Tarayıcı dışında hiçbir şey yapmaz.
49
+ */
50
+ init(options) {
51
+ if (!isBrowser())
52
+ return Promise.resolve();
53
+ if (!this.initPromise) {
54
+ this.initPromise = this.sdk.init(options).then(() => this.update({ ready: true, error: null }), (err) => this.update({ ready: false, error: toError(err) }));
55
+ }
56
+ return this.initPromise;
57
+ }
58
+ /**
59
+ * Web SDK gözlemcilerini bağlar (referans sayımlı). Son bağlantı kapanınca gözlemciler kaldırılır.
60
+ * Tarayıcı dışında no-op döndürür.
61
+ */
62
+ connect() {
63
+ if (!isBrowser())
64
+ return () => undefined;
65
+ this.connections += 1;
66
+ if (this.connections === 1) {
67
+ const refresh = () => this.update({});
68
+ const offPermission = this.sdk.Notifications.addPermissionObserver(refresh);
69
+ const offSubscription = this.sdk.User.pushSubscription.addObserver(refresh);
70
+ this.detach = () => {
71
+ offPermission();
72
+ offSubscription();
73
+ };
74
+ // Bağlantı kapalıyken kaçırılmış değişiklikler okunur.
75
+ refresh();
76
+ }
77
+ let open = true;
78
+ return () => {
79
+ if (!open)
80
+ return;
81
+ open = false;
82
+ this.connections -= 1;
83
+ if (this.connections === 0) {
84
+ this.detach?.();
85
+ this.detach = null;
86
+ }
87
+ };
88
+ }
89
+ /** Etkin gözlemci bağlantısı sayısı (test ve tanılama amaçlı). */
90
+ get connectionCount() {
91
+ return this.connections;
92
+ }
93
+ read(ready, error) {
94
+ const subscription = this.sdk.User.pushSubscription.state;
95
+ return {
96
+ ready,
97
+ error,
98
+ permission: this.sdk.Notifications.permission,
99
+ pushSubscription: subscription,
100
+ };
101
+ }
102
+ update(patch) {
103
+ const prev = this.state;
104
+ const next = this.read(patch.ready ?? prev.ready, patch.error !== undefined ? patch.error : prev.error);
105
+ if (next.ready === prev.ready &&
106
+ next.error === prev.error &&
107
+ next.permission === prev.permission &&
108
+ sameSubscription(next.pushSubscription, prev.pushSubscription))
109
+ return;
110
+ // Değişmeyen abonelik nesnesi korunur: seçici tabanlı abonelikler gereksiz yeniden çizim yapmaz.
111
+ if (sameSubscription(next.pushSubscription, prev.pushSubscription))
112
+ next.pushSubscription = prev.pushSubscription;
113
+ this.state = next;
114
+ for (const listener of [...this.listeners])
115
+ listener(next);
116
+ }
117
+ }
118
+ let shared = null;
119
+ /** Paylaşılan `@pushizo/web` örneğine bağlı tekil bağlama. */
120
+ export function getBinding() {
121
+ shared ??= new PushizoBinding(Pushizo);
122
+ return shared;
123
+ }
124
+ /** Yalnızca birim testleri için: tekil bağlamayı sıfırlar (paketin dışa aktarımlarında yer almaz). */
125
+ export function resetBinding() {
126
+ shared = null;
127
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @pushizo/vue — Pushizo Web SDK'sı (`@pushizo/web`) için Vue eklentisi ve composable'lar.
3
+ *
4
+ * Vue 3 (`app.use(PushizoPlugin, options)`) ve Vue 2.7 (`Vue.use(PushizoPlugin, options)`) aynı paketle çalışır:
5
+ * yalnızca iki sürümde ortak olan Composition API (`shallowRef`, `computed`, `onScopeDispose`) kullanılır.
6
+ */
7
+ import { type ComputedRef } from 'vue';
8
+ import type { InitOptions, NotificationClickEvent, PermissionState, PushSubscriptionState, PushizoSdk } from '@pushizo/web';
9
+ import { type PushizoState } from './binding.js';
10
+ export type { PushizoState } from './binding.js';
11
+ export declare const PushizoPlugin: {
12
+ /**
13
+ * Tarayıcıda `Pushizo.init(options)` çağrısını bir kez yapar, `$pushizo` global özelliğini tanımlar ve durum
14
+ * gözlemcilerini bağlar. Sunucuda (SSR) yalnızca `$pushizo` tanımlanır; SDK başlatılmaz.
15
+ * Vue 3'te uygulama sökülünce gözlemciler kaldırılır; Vue 2.7'de uygulama düzeyinde söküm kancası yoktur.
16
+ */
17
+ install(app: unknown, options: InitOptions): void;
18
+ };
19
+ export interface UsePushizo {
20
+ /** Paylaşılan Pushizo SDK örneği. */
21
+ pushizo: PushizoSdk;
22
+ /** Tüm durum (salt okunur). */
23
+ state: ComputedRef<PushizoState>;
24
+ ready: ComputedRef<boolean>;
25
+ error: ComputedRef<Error | null>;
26
+ permission: ComputedRef<PermissionState>;
27
+ pushSubscription: ComputedRef<PushSubscriptionState>;
28
+ }
29
+ /** SDK örneği ve reaktif durum. `PushizoPlugin` kurulmadan çağrılırsa açıklayıcı hata verir. */
30
+ export declare function usePushizo(): UsePushizo;
31
+ /**
32
+ * Bildirim tıklaması dinleyicisi. Bileşen (veya `effectScope`) içinde çağrılırsa kapsam sonlanınca kendiliğinden
33
+ * kaldırılır; dönen işlev ile elle de kaldırılabilir. Tarayıcı dışında no-op.
34
+ */
35
+ export declare function onNotificationClick(handler: (event: NotificationClickEvent) => void): () => void;
36
+ declare module 'vue' {
37
+ interface ComponentCustomProperties {
38
+ /** Paylaşılan Pushizo SDK örneği (`PushizoPlugin`). */
39
+ $pushizo: PushizoSdk;
40
+ }
41
+ }
package/dist/index.js ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @pushizo/vue — Pushizo Web SDK'sı (`@pushizo/web`) için Vue eklentisi ve composable'lar.
3
+ *
4
+ * Vue 3 (`app.use(PushizoPlugin, options)`) ve Vue 2.7 (`Vue.use(PushizoPlugin, options)`) aynı paketle çalışır:
5
+ * yalnızca iki sürümde ortak olan Composition API (`shallowRef`, `computed`, `onScopeDispose`) kullanılır.
6
+ */
7
+ import { computed, getCurrentScope, onScopeDispose } from 'vue';
8
+ import { getBinding, isBrowser } from './binding.js';
9
+ import { acquire, installCount, release, state } from './state.js';
10
+ function isVue2(target) {
11
+ return typeof target === 'function' && typeof target.prototype === 'object';
12
+ }
13
+ /** Vue 3 uygulaması sökülünce (`app.unmount`) çalışacak işlevi kaydeder. */
14
+ function onAppUnmount(app, cb) {
15
+ if (typeof app.onUnmount === 'function') {
16
+ app.onUnmount(cb);
17
+ return;
18
+ }
19
+ // Vue < 3.5: `onUnmount` yok; özgün `unmount` sarılır.
20
+ const original = app.unmount.bind(app);
21
+ app.unmount = (...args) => {
22
+ cb();
23
+ return original(...args);
24
+ };
25
+ }
26
+ export const PushizoPlugin = {
27
+ /**
28
+ * Tarayıcıda `Pushizo.init(options)` çağrısını bir kez yapar, `$pushizo` global özelliğini tanımlar ve durum
29
+ * gözlemcilerini bağlar. Sunucuda (SSR) yalnızca `$pushizo` tanımlanır; SDK başlatılmaz.
30
+ * Vue 3'te uygulama sökülünce gözlemciler kaldırılır; Vue 2.7'de uygulama düzeyinde söküm kancası yoktur.
31
+ */
32
+ install(app, options) {
33
+ if (!options || typeof options !== 'object')
34
+ throw new Error('PushizoPlugin: init seçenekleri gerekli (appId).');
35
+ const binding = getBinding();
36
+ if (isVue2(app))
37
+ app.prototype.$pushizo = binding.sdk;
38
+ else
39
+ app.config.globalProperties.$pushizo = binding.sdk;
40
+ acquire();
41
+ void binding.init(options);
42
+ if (!isVue2(app)) {
43
+ let released = false;
44
+ onAppUnmount(app, () => {
45
+ if (released)
46
+ return;
47
+ released = true;
48
+ release();
49
+ });
50
+ }
51
+ },
52
+ };
53
+ /** SDK örneği ve reaktif durum. `PushizoPlugin` kurulmadan çağrılırsa açıklayıcı hata verir. */
54
+ export function usePushizo() {
55
+ if (installCount() === 0)
56
+ throw new Error('usePushizo: önce app.use(PushizoPlugin, { appId }) çağrılmalı.');
57
+ return {
58
+ pushizo: getBinding().sdk,
59
+ state: computed(() => state.value),
60
+ ready: computed(() => state.value.ready),
61
+ error: computed(() => state.value.error),
62
+ permission: computed(() => state.value.permission),
63
+ pushSubscription: computed(() => state.value.pushSubscription),
64
+ };
65
+ }
66
+ /**
67
+ * Bildirim tıklaması dinleyicisi. Bileşen (veya `effectScope`) içinde çağrılırsa kapsam sonlanınca kendiliğinden
68
+ * kaldırılır; dönen işlev ile elle de kaldırılabilir. Tarayıcı dışında no-op.
69
+ */
70
+ export function onNotificationClick(handler) {
71
+ if (!isBrowser())
72
+ return () => undefined;
73
+ const remove = getBinding().sdk.Notifications.addClickListener(handler);
74
+ const stop = () => {
75
+ remove();
76
+ };
77
+ if (getCurrentScope())
78
+ onScopeDispose(stop);
79
+ return stop;
80
+ }
@@ -0,0 +1,9 @@
1
+ import { type PushizoState } from './binding.js';
2
+ export declare const state: import("vue").ShallowRef<PushizoState, PushizoState>;
3
+ export declare function installCount(): number;
4
+ /** Kurulum sayısını artırır ve (tarayıcıda) bağlama ile durumu eşlemeye başlar. */
5
+ export declare function acquire(): void;
6
+ /** Kurulum sayısını azaltır; sıfıra inince gözlemciler kaldırılır. */
7
+ export declare function release(): void;
8
+ /** Yalnızca birim testleri için (paketin dışa aktarımlarında yer almaz). */
9
+ export declare function resetState(): void;
package/dist/state.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Eklentinin modül düzeyindeki reaktif durumu. Tek SDK örneği olduğundan durum uygulama başına değil paylaşılır;
3
+ * kurulum sayacı son uygulama sökülünce gözlemcileri kaldırmak için tutulur.
4
+ */
5
+ import { shallowRef } from 'vue';
6
+ import { getBinding, isBrowser, SERVER_STATE } from './binding.js';
7
+ export const state = shallowRef(SERVER_STATE);
8
+ let installs = 0;
9
+ let stopSync = null;
10
+ export function installCount() {
11
+ return installs;
12
+ }
13
+ /** Kurulum sayısını artırır ve (tarayıcıda) bağlama ile durumu eşlemeye başlar. */
14
+ export function acquire() {
15
+ installs += 1;
16
+ if (stopSync || !isBrowser())
17
+ return;
18
+ const binding = getBinding();
19
+ state.value = binding.getState();
20
+ const unsubscribe = binding.subscribe((next) => {
21
+ state.value = next;
22
+ });
23
+ const disconnect = binding.connect();
24
+ stopSync = () => {
25
+ unsubscribe();
26
+ disconnect();
27
+ };
28
+ }
29
+ /** Kurulum sayısını azaltır; sıfıra inince gözlemciler kaldırılır. */
30
+ export function release() {
31
+ installs = Math.max(0, installs - 1);
32
+ if (installs === 0) {
33
+ stopSync?.();
34
+ stopSync = null;
35
+ }
36
+ }
37
+ /** Yalnızca birim testleri için (paketin dışa aktarımlarında yer almaz). */
38
+ export function resetState() {
39
+ stopSync?.();
40
+ stopSync = null;
41
+ installs = 0;
42
+ state.value = SERVER_STATE;
43
+ }
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@pushizo/vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Pushizo Vue eklentisi: PushizoPlugin, usePushizo composable, $pushizo ve reaktif izin/abonelik durumu (Vue 3 ve 2.7; @pushizo/web üzerine)",
5
+ "license": "MIT",
6
+ "homepage": "https://docs.pushizo.com/docs/integrations/vue",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/pushizo/pushizo-vue.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/pushizo/pushizo-vue/issues",
13
+ "email": "support@pushizo.com"
14
+ },
15
+ "keywords": [
16
+ "pushizo",
17
+ "vue",
18
+ "vue3",
19
+ "nuxt",
20
+ "push",
21
+ "notifications",
22
+ "web-push"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "provenance": true
27
+ },
28
+ "type": "module",
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md"
42
+ ],
43
+ "scripts": {
44
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
45
+ "typecheck": "tsc -p tsconfig.json --noEmit",
46
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\""
47
+ },
48
+ "peerDependencies": {
49
+ "@pushizo/web": "^0.1.0",
50
+ "vue": "^2.7.0 || ^3.2.0"
51
+ },
52
+ "devDependencies": {
53
+ "@pushizo/web": "^0.1.0",
54
+ "happy-dom": "^21.0.4",
55
+ "vue": "^3.5.0"
56
+ },
57
+ "sideEffects": false
58
+ }