@symbiote-native/vue 3.1.0 → 3.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/composables/create-event-value-hook.d.ts +3 -0
- package/build/composables/create-event-value-hook.js +16 -0
- package/build/composables/create-permission-hook.d.ts +3 -0
- package/build/composables/create-permission-hook.js +22 -0
- package/build/composables/create-resource-hook.d.ts +7 -0
- package/build/composables/create-resource-hook.js +14 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/package.json +6 -6
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ShallowRef } from '@vue/runtime-core';
|
|
2
|
+
import type { IEventValueSource } from '@symbiote-native/engine';
|
|
3
|
+
export declare function createEventValueHook<TSource extends IEventValueSource<TValue, TEvent>, TValue, TEvent extends string = string>(event: TEvent, getValue: (source: TSource) => TValue): (getSource: () => TSource) => ShallowRef<TValue>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Every `useXStatus`-style composable (`useAudioPlayerStatus`, `useAudioPlaylistStatus`, ...)
|
|
2
|
+
// binds this to its own event name + initial-value getter instead of repeating the watch wiring
|
|
3
|
+
import { shallowRef, watch } from '@vue/runtime-core';
|
|
4
|
+
export function createEventValueHook(event, getValue) {
|
|
5
|
+
return function useEventValue(getSource) {
|
|
6
|
+
const value = shallowRef(getValue(getSource()));
|
|
7
|
+
watch(getSource, (source, _previous, onCleanup) => {
|
|
8
|
+
value.value = getValue(source);
|
|
9
|
+
const subscription = source.addListener(event, next => {
|
|
10
|
+
value.value = next;
|
|
11
|
+
});
|
|
12
|
+
onCleanup(() => subscription.remove());
|
|
13
|
+
}, { immediate: true });
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Ref } from '@vue/runtime-core';
|
|
2
|
+
import { type IPermissionHookBehavior, type IPermissionHookMethods } from '@symbiote-native/engine';
|
|
3
|
+
export declare function createPermissionHook<TPermission, TOptions extends object>(methods: IPermissionHookMethods<TPermission, TOptions>): (behavior?: IPermissionHookBehavior, methodOptions?: TOptions) => [Ref<TPermission | null>, () => Promise<TPermission>, () => Promise<TPermission>];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Every Expo-wrapper package's own permission composable (`useCameraPermissions`,
|
|
2
|
+
// `useCalendarPermissions`, `useRemindersPermissions`, ...) binds this factory to its `methods`
|
|
3
|
+
import { onMounted, shallowRef } from '@vue/runtime-core';
|
|
4
|
+
import { createPermissionApi, fetchInitialPermission, } from '@symbiote-native/engine';
|
|
5
|
+
export function createPermissionHook(methods) {
|
|
6
|
+
return function usePermission(behavior, methodOptions) {
|
|
7
|
+
const status = shallowRef(null);
|
|
8
|
+
const api = createPermissionApi(methods, value => {
|
|
9
|
+
status.value = value;
|
|
10
|
+
});
|
|
11
|
+
onMounted(() => {
|
|
12
|
+
fetchInitialPermission(methods, behavior, methodOptions, response => {
|
|
13
|
+
status.value = response;
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return [
|
|
17
|
+
status,
|
|
18
|
+
() => api.request(methodOptions),
|
|
19
|
+
() => api.get(methodOptions),
|
|
20
|
+
];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ComputedRef } from '@vue/runtime-core';
|
|
2
|
+
export type IResourceHookController<TArgs extends unknown[], TResource> = {
|
|
3
|
+
resolve: (...args: TArgs) => TResource;
|
|
4
|
+
flushDispose: () => void;
|
|
5
|
+
dispose: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function createResourceHook<TArgs extends unknown[], TResource>(createController: () => IResourceHookController<TArgs, TResource>): (getArgs: () => TArgs) => ComputedRef<TResource>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Every `useReleasingSharedObject`-style composable (`useAudioPlayer`, `useImageManipulator`, ...)
|
|
2
|
+
// binds this to its own `createXController()` instead of repeating the computed/watch wiring
|
|
3
|
+
import { computed, onUnmounted, watch, } from '@vue/runtime-core';
|
|
4
|
+
export function createResourceHook(createController) {
|
|
5
|
+
return function useResource(getArgs) {
|
|
6
|
+
const controller = createController();
|
|
7
|
+
const resource = computed(() => controller.resolve(...getArgs()));
|
|
8
|
+
watch(resource, () => {
|
|
9
|
+
controller.flushDispose();
|
|
10
|
+
});
|
|
11
|
+
onUnmounted(() => controller.dispose());
|
|
12
|
+
return resource;
|
|
13
|
+
};
|
|
14
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -54,6 +54,9 @@ export { AppRegistry, setHostRegistrar } from './modules/app-registry';
|
|
|
54
54
|
export type { IComponentProvider, IAppParameters, IRunnable, IHostRegistrar, IWrapperComponentProvider, IRegistry, IHeadlessTask, ITaskProvider, ITaskCanceller, ITaskCancelProvider, } from './modules/app-registry';
|
|
55
55
|
export { useColorScheme } from './composables/use-color-scheme';
|
|
56
56
|
export { useWindowDimensions } from './composables/use-window-dimensions';
|
|
57
|
+
export { createPermissionHook } from './composables/create-permission-hook';
|
|
58
|
+
export { createResourceHook } from './composables/create-resource-hook';
|
|
59
|
+
export { createEventValueHook } from './composables/create-event-value-hook';
|
|
57
60
|
export { Alert, Share, ActionSheetIOS, Linking, Vibration, ToastAndroid, Settings, I18nManager, Dimensions, Appearance, AppState, Keyboard, KEYBOARD_EVENT, BackHandler, PermissionsAndroid, PERMISSIONS, RESULTS, AccessibilityInfo, LayoutAnimation, } from '@symbiote-native/engine';
|
|
58
61
|
export type { IAlertType, IAlertButtonStyle, IAlertButton, IAlertButtons, IAlertOptions, IShareContent, IShareOptions, IShareAction, IActionSheetIOSOptions, IShareActionSheetIOSOptions, IShareActionSheetError, IUrlEvent, II18nManagerConstants, IDisplayMetrics, IDisplayMetricsAndroid, IDimensionsPayload, IDimensionsSet, IDimensionsKey, IDimensionsChangeListener, IDimensionsStatic, IColorSchemeName, IColorSchemePreference, IAppStateStatus, IAppStateEvent, IKeyboardEventName, IKeyboardEvent, IKeyboardMetrics, IBackPressEventName, IBackPressHandler, IPermission, IPermissionStatus, IRationale, IAccessibilityChangeEvent, IAccessibilityChangeEventName, IAccessibilityChangeEventHandler, IAccessibilityAnnouncementFinishedEvent, IAnnounceForAccessibilityOptions, IAccessibilityEventType, ILayoutAnimationType, ILayoutAnimationProperty, ILayoutAnimationConfig, ILayoutAnimationAnim, } from '@symbiote-native/engine';
|
|
59
62
|
export { Platform, StyleSheet, processColor, setColorProcessor, dlog, isDebug, } from '@symbiote-native/engine';
|
package/build/index.js
CHANGED
|
@@ -73,6 +73,9 @@ export { AppRegistry, setHostRegistrar } from './modules/app-registry/index.js';
|
|
|
73
73
|
// Vue composables over the core device-state modules.
|
|
74
74
|
export { useColorScheme } from './composables/use-color-scheme.js';
|
|
75
75
|
export { useWindowDimensions } from './composables/use-window-dimensions.js';
|
|
76
|
+
export { createPermissionHook } from './composables/create-permission-hook.js';
|
|
77
|
+
export { createResourceHook } from './composables/create-resource-hook.js';
|
|
78
|
+
export { createEventValueHook } from './composables/create-event-value-hook.js';
|
|
76
79
|
// Imperative runtime modules: the SAME module both adapters share, re-exported from @symbiote-native/engine.
|
|
77
80
|
export { Alert, Share, ActionSheetIOS, Linking, Vibration, ToastAndroid, Settings, I18nManager, Dimensions, Appearance, AppState, Keyboard, KEYBOARD_EVENT, BackHandler, PermissionsAndroid, PERMISSIONS, RESULTS, AccessibilityInfo, LayoutAnimation, } from '@symbiote-native/engine';
|
|
78
81
|
// Re-export the framework-agnostic engine surface (pure utilities + diagnostics).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/vue",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "SymbioteNative's Vue adapter — a @vue/runtime-core createRenderer driving real native iOS/Android views through the same engine as the React adapter.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -70,18 +70,18 @@
|
|
|
70
70
|
"@vue/compiler-sfc": "^3.5.13",
|
|
71
71
|
"@vue/runtime-core": "^3.5.13",
|
|
72
72
|
"typescript": "~6.0.0",
|
|
73
|
-
"@symbiote-native/components": "3.1.
|
|
74
|
-
"@symbiote-native/css-parser": "0.5.
|
|
73
|
+
"@symbiote-native/components": "3.1.4",
|
|
74
|
+
"@symbiote-native/css-parser": "0.5.3"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"vue": ">=3.5.0",
|
|
78
78
|
"react-native": ">=0.86",
|
|
79
|
-
"@symbiote-native/engine": "^1.
|
|
79
|
+
"@symbiote-native/engine": "^1.5.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@babel/core": "^7.25.2",
|
|
83
|
-
"@symbiote-native/engine": "1.
|
|
84
|
-
"@symbiote-native/test-utils": "0.4.
|
|
83
|
+
"@symbiote-native/engine": "1.5.0",
|
|
84
|
+
"@symbiote-native/test-utils": "0.4.6"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"typecheck": "tsc --build",
|