@symbiote-native/network 0.1.0 → 0.2.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/build/angular/index.d.ts +1 -1
- package/build/angular/index.js +1 -1
- package/build/react/index.d.ts +1 -1
- package/build/react/index.js +1 -1
- package/build/svelte/index.d.ts +2 -0
- package/build/svelte/index.js +5 -0
- package/build/svelte/runes/use-network-state.svelte.d.ts +4 -0
- package/build/svelte/runes/use-network-state.svelte.js +29 -0
- package/build/vue/index.d.ts +1 -1
- package/build/vue/index.js +1 -1
- package/build-ngc/angular/index.d.ts +1 -1
- package/build-ngc/angular/index.js +1 -1
- package/build-ngc/angular/index.js.map +1 -1
- package/build-ngc/angular/services/network-state.service/index.js +3 -3
- package/package.json +26 -12
- package/src/angular/index.ts +1 -10
- package/src/react/index.ts +1 -10
- package/src/svelte/index.ts +6 -0
- package/src/svelte/runes/use-network-state.svelte.ts +37 -0
- package/src/svelte/svelte-ambient.d.ts +6 -0
- package/src/vue/index.ts +1 -10
package/build/angular/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NetworkStateService } from './services/network-state.service';
|
|
2
|
-
export
|
|
2
|
+
export * from '../core';
|
package/build/angular/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// NetworkStateService is the Angular-only lifecycle half; the free functions and event
|
|
2
2
|
// subscription plumbing all live in core, shared with React/Vue.
|
|
3
3
|
export { NetworkStateService } from './services/network-state.service/index.js';
|
|
4
|
-
export
|
|
4
|
+
export * from '../core/index.js';
|
package/build/react/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useNetworkState } from './hooks/use-network-state';
|
|
2
|
-
export
|
|
2
|
+
export * from '../core';
|
package/build/react/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @symbiote-native/network/react: the React entry over the framework-agnostic core.
|
|
2
2
|
export { useNetworkState } from './hooks/use-network-state/index.js';
|
|
3
|
-
export
|
|
3
|
+
export * from '../core/index.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @symbiote-native/network/svelte: the Svelte entry over the framework-agnostic core — mirrors the
|
|
2
|
+
// lifecycle-bucket naming convention of adapters/svelte/src/runes (never `hooks`/`composables`,
|
|
3
|
+
// those are React's and Vue's terms).
|
|
4
|
+
export { useNetworkState } from './runes/use-network-state.svelte';
|
|
5
|
+
export * from '../core/index.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Svelte lifecycle wiring over the framework-agnostic core (core/network.ts). Seeds the initial
|
|
2
|
+
// value with a one-shot getNetworkStateAsync() call before the first native event fires, matching
|
|
3
|
+
// upstream's own useNetworkState and the Vue composable's onMounted half.
|
|
4
|
+
//
|
|
5
|
+
// `.svelte.ts` extension: runes ($state/$effect) only work there outside a `.svelte` component;
|
|
6
|
+
// `runes/` is Svelte's name for the lifecycle bucket (React's `hooks/`, Vue's `composables/`).
|
|
7
|
+
// Returns a boxed getter, not a bare `$state`: Svelte 5 reactivity is lexically scoped to the
|
|
8
|
+
// declaring module and doesn't survive being returned raw from a plain function, so the caller
|
|
9
|
+
// reads `.current` like unwrapping Vue's `Ref` via `.value`.
|
|
10
|
+
import { addNetworkStateListener, getNetworkStateAsync, } from '../../core/index.js';
|
|
11
|
+
export function useNetworkState() {
|
|
12
|
+
let networkState = $state({});
|
|
13
|
+
$effect(() => {
|
|
14
|
+
// Write-only touches of `networkState`, so the effect has no dependency on it and runs once
|
|
15
|
+
// per mount - the twin of Vue's onMounted/onUnmounted pair.
|
|
16
|
+
getNetworkStateAsync().then(state => {
|
|
17
|
+
networkState = state;
|
|
18
|
+
});
|
|
19
|
+
const subscription = addNetworkStateListener(event => {
|
|
20
|
+
networkState = event;
|
|
21
|
+
});
|
|
22
|
+
return () => subscription.remove();
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
get current() {
|
|
26
|
+
return networkState;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
package/build/vue/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useNetworkState } from './composables/use-network-state';
|
|
2
|
-
export
|
|
2
|
+
export * from '../core';
|
package/build/vue/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @symbiote-native/network/vue: the Vue entry over the framework-agnostic core.
|
|
2
2
|
export { useNetworkState } from './composables/use-network-state/index.js';
|
|
3
|
-
export
|
|
3
|
+
export * from '../core/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NetworkStateService } from './services/network-state.service';
|
|
2
|
-
export
|
|
2
|
+
export * from '../core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NetworkStateService is the Angular-only lifecycle half; the free functions and event
|
|
2
2
|
// subscription plumbing all live in core, shared with React/Vue.
|
|
3
3
|
export { NetworkStateService } from './services/network-state.service';
|
|
4
|
-
export
|
|
4
|
+
export * from '../core';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,iEAAiE;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,iEAAiE;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,cAAc,SAAS,CAAC"}
|
|
@@ -17,10 +17,10 @@ export class NetworkStateService {
|
|
|
17
17
|
}, { injector: this.injector });
|
|
18
18
|
return networkState.asReadonly();
|
|
19
19
|
}
|
|
20
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
21
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
20
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: NetworkStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
21
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: NetworkStateService, providedIn: 'root' });
|
|
22
22
|
}
|
|
23
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: NetworkStateService, decorators: [{
|
|
24
24
|
type: Injectable,
|
|
25
25
|
args: [{ providedIn: 'root' }]
|
|
26
26
|
}] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/network",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "expo-network wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, and Angular adapters. Network state (type/connected/internet-reachable) with a change listener, device IP address, and airplane-mode detection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./build/react/index.d.ts",
|
|
31
31
|
"default": "./build/react/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./svelte": {
|
|
34
|
+
"types": "./build/svelte/index.d.ts",
|
|
35
|
+
"default": "./build/svelte/index.js"
|
|
36
|
+
},
|
|
33
37
|
"./angular": {
|
|
34
38
|
"types": "./build-ngc/angular/index.d.ts",
|
|
35
39
|
"react-native": "./build-ngc/angular/index.js",
|
|
@@ -53,15 +57,17 @@
|
|
|
53
57
|
"expo-modules-core": "57.0.5"
|
|
54
58
|
},
|
|
55
59
|
"peerDependencies": {
|
|
60
|
+
"@symbiote-native/angular": ">=0.6.2",
|
|
56
61
|
"@symbiote-native/engine": ">=0.1.7",
|
|
62
|
+
"@symbiote-native/react": ">=0.2.8",
|
|
63
|
+
"@symbiote-native/svelte": ">=0.1.0",
|
|
64
|
+
"@symbiote-native/vue": ">=0.3.8",
|
|
57
65
|
"@angular/core": ">=20",
|
|
58
66
|
"@vue/runtime-core": "^3.5.13",
|
|
59
67
|
"react": ">=19.0.0",
|
|
60
68
|
"react-native": ">=0.86",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"@symbiote-native/react": "0.2.8",
|
|
64
|
-
"@symbiote-native/vue": "0.3.8"
|
|
69
|
+
"svelte": ">=5.56.0",
|
|
70
|
+
"vue": ">=3.5.0"
|
|
65
71
|
},
|
|
66
72
|
"peerDependenciesMeta": {
|
|
67
73
|
"@symbiote-native/angular": {
|
|
@@ -70,6 +76,9 @@
|
|
|
70
76
|
"@symbiote-native/react": {
|
|
71
77
|
"optional": true
|
|
72
78
|
},
|
|
79
|
+
"@symbiote-native/svelte": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
73
82
|
"@symbiote-native/vue": {
|
|
74
83
|
"optional": true
|
|
75
84
|
},
|
|
@@ -82,24 +91,29 @@
|
|
|
82
91
|
"react": {
|
|
83
92
|
"optional": true
|
|
84
93
|
},
|
|
94
|
+
"svelte": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
85
97
|
"vue": {
|
|
86
98
|
"optional": true
|
|
87
99
|
}
|
|
88
100
|
},
|
|
89
101
|
"devDependencies": {
|
|
90
|
-
"@angular/compiler": "
|
|
91
|
-
"@angular/compiler-cli": "
|
|
92
|
-
"@angular/core": "
|
|
102
|
+
"@angular/compiler": "~22.0.8",
|
|
103
|
+
"@angular/compiler-cli": "~22.0.8",
|
|
104
|
+
"@angular/core": "~22.0.8",
|
|
93
105
|
"@types/node": "^26.0.0",
|
|
94
106
|
"@types/react": "^19.2.0",
|
|
95
107
|
"@vue/runtime-core": "^3.5.13",
|
|
96
108
|
"react": "19.2.3",
|
|
109
|
+
"svelte": "^5.56.0",
|
|
97
110
|
"typescript": "~6.0.0",
|
|
98
|
-
"@symbiote-native/angular": "0.
|
|
99
|
-
"@symbiote-native/engine": "0.
|
|
100
|
-
"@symbiote-native/react": "0.
|
|
111
|
+
"@symbiote-native/angular": "0.7.0",
|
|
112
|
+
"@symbiote-native/engine": "0.2.0",
|
|
113
|
+
"@symbiote-native/react": "0.3.0",
|
|
114
|
+
"@symbiote-native/svelte": "0.2.0",
|
|
101
115
|
"@symbiote-native/test-utils": "0.1.6",
|
|
102
|
-
"@symbiote-native/vue": "0.
|
|
116
|
+
"@symbiote-native/vue": "0.4.0"
|
|
103
117
|
},
|
|
104
118
|
"scripts": {
|
|
105
119
|
"typecheck": "tsc --build",
|
package/src/angular/index.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
// NetworkStateService is the Angular-only lifecycle half; the free functions and event
|
|
2
2
|
// subscription plumbing all live in core, shared with React/Vue.
|
|
3
3
|
export { NetworkStateService } from './services/network-state.service';
|
|
4
|
-
export
|
|
5
|
-
getNetworkStateAsync,
|
|
6
|
-
getIpAddressAsync,
|
|
7
|
-
isAirplaneModeEnabledAsync,
|
|
8
|
-
addNetworkStateListener,
|
|
9
|
-
NetworkStateType,
|
|
10
|
-
type NetworkState,
|
|
11
|
-
type NetworkStateEvent,
|
|
12
|
-
type EventSubscription,
|
|
13
|
-
} from '../core';
|
|
4
|
+
export * from '../core';
|
package/src/react/index.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
// @symbiote-native/network/react: the React entry over the framework-agnostic core.
|
|
2
2
|
|
|
3
3
|
export { useNetworkState } from './hooks/use-network-state';
|
|
4
|
-
export
|
|
5
|
-
getNetworkStateAsync,
|
|
6
|
-
getIpAddressAsync,
|
|
7
|
-
isAirplaneModeEnabledAsync,
|
|
8
|
-
addNetworkStateListener,
|
|
9
|
-
NetworkStateType,
|
|
10
|
-
type NetworkState,
|
|
11
|
-
type NetworkStateEvent,
|
|
12
|
-
type EventSubscription,
|
|
13
|
-
} from '../core';
|
|
4
|
+
export * from '../core';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @symbiote-native/network/svelte: the Svelte entry over the framework-agnostic core — mirrors the
|
|
2
|
+
// lifecycle-bucket naming convention of adapters/svelte/src/runes (never `hooks`/`composables`,
|
|
3
|
+
// those are React's and Vue's terms).
|
|
4
|
+
|
|
5
|
+
export { useNetworkState } from './runes/use-network-state.svelte';
|
|
6
|
+
export * from '../core';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Svelte lifecycle wiring over the framework-agnostic core (core/network.ts). Seeds the initial
|
|
2
|
+
// value with a one-shot getNetworkStateAsync() call before the first native event fires, matching
|
|
3
|
+
// upstream's own useNetworkState and the Vue composable's onMounted half.
|
|
4
|
+
//
|
|
5
|
+
// `.svelte.ts` extension: runes ($state/$effect) only work there outside a `.svelte` component;
|
|
6
|
+
// `runes/` is Svelte's name for the lifecycle bucket (React's `hooks/`, Vue's `composables/`).
|
|
7
|
+
// Returns a boxed getter, not a bare `$state`: Svelte 5 reactivity is lexically scoped to the
|
|
8
|
+
// declaring module and doesn't survive being returned raw from a plain function, so the caller
|
|
9
|
+
// reads `.current` like unwrapping Vue's `Ref` via `.value`.
|
|
10
|
+
import {
|
|
11
|
+
addNetworkStateListener,
|
|
12
|
+
getNetworkStateAsync,
|
|
13
|
+
type EventSubscription,
|
|
14
|
+
type NetworkState,
|
|
15
|
+
} from '../../core';
|
|
16
|
+
|
|
17
|
+
export function useNetworkState(): { readonly current: NetworkState } {
|
|
18
|
+
let networkState = $state<NetworkState>({});
|
|
19
|
+
|
|
20
|
+
$effect(() => {
|
|
21
|
+
// Write-only touches of `networkState`, so the effect has no dependency on it and runs once
|
|
22
|
+
// per mount - the twin of Vue's onMounted/onUnmounted pair.
|
|
23
|
+
getNetworkStateAsync().then(state => {
|
|
24
|
+
networkState = state;
|
|
25
|
+
});
|
|
26
|
+
const subscription: EventSubscription = addNetworkStateListener(event => {
|
|
27
|
+
networkState = event;
|
|
28
|
+
});
|
|
29
|
+
return () => subscription.remove();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
get current(): NetworkState {
|
|
34
|
+
return networkState;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Pulls in svelte's ambient global declarations ($state/$effect/...) for this package's tsc
|
|
2
|
+
// program. adapters/svelte gets these for free because render.ts does a real value import from
|
|
3
|
+
// 'svelte' (any file in a program importing a module loads its ambient globals for the whole
|
|
4
|
+
// program); this package has no such import, so a triple-slash reference does the same job
|
|
5
|
+
// explicitly rather than relying on an incidental side-effect.
|
|
6
|
+
/// <reference types="svelte" />
|
package/src/vue/index.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
// @symbiote-native/network/vue: the Vue entry over the framework-agnostic core.
|
|
2
2
|
|
|
3
3
|
export { useNetworkState } from './composables/use-network-state';
|
|
4
|
-
export
|
|
5
|
-
getNetworkStateAsync,
|
|
6
|
-
getIpAddressAsync,
|
|
7
|
-
isAirplaneModeEnabledAsync,
|
|
8
|
-
addNetworkStateListener,
|
|
9
|
-
NetworkStateType,
|
|
10
|
-
type NetworkState,
|
|
11
|
-
type NetworkStateEvent,
|
|
12
|
-
type EventSubscription,
|
|
13
|
-
} from '../core';
|
|
4
|
+
export * from '../core';
|