@shenora/react 0.15.0 → 0.16.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.js +9 -0
- package/dist/windowOrientation.d.ts +48 -0
- package/dist/windowOrientation.js +27 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { createShenoraStore, type ShenoraStore, type ShenoraStoreOptions, type S
|
|
|
7
7
|
export { BaseModuleService } from './moduleService.js';
|
|
8
8
|
export { IpcRequestStates, IpcRequestEventTypes, IpcRequestRoutes, IpcRequestsModuleName, createRequestsStore, useShenoraRequests, type IpcRequestState, type IpcLabel, type IpcProgress, type IpcRequestStatus, type RequestsState, type RequestsActions, type RequestsStoreOptions, } from './requests.js';
|
|
9
9
|
export { WindowCommands, useWindowMaximized, type WindowResizeEdge, type CaptionButtonKind, type CaptionButtonRect, } from './windowCommands.js';
|
|
10
|
+
export { WindowOrientation, type WindowOrientationKind, } from './windowOrientation.js';
|
|
10
11
|
export { useDropZone, DROP_ZONE_MODULE, type DropZoneFileDrop, type UseDropZoneOptions, } from './useDropZone.js';
|
|
11
12
|
export { useShenora, useShenoraEvent, useShenoraQuery, useShellInfo, type ShenoraQueryResult, } from './hooks.js';
|
|
12
13
|
export { FileDialogs, useFileDialogs, type FileDialogFilter, type FileDialogOptions, type OpenFileOptions, type OpenFolderOptions, type SaveFileOptions, type FileDialogResult, type FileDialogsHandle, } from './fileDialogs.js';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { IpcRequestStates,
|
|
|
14
14
|
// request without `useShenoraRequests` never types the wire literals by hand.
|
|
15
15
|
IpcRequestEventTypes, IpcRequestRoutes, IpcRequestsModuleName, createRequestsStore, useShenoraRequests, } from './requests.js';
|
|
16
16
|
export { WindowCommands, useWindowMaximized, } from './windowCommands.js';
|
|
17
|
+
export { WindowOrientation, } from './windowOrientation.js';
|
|
17
18
|
export { useDropZone, DROP_ZONE_MODULE, } from './useDropZone.js';
|
|
18
19
|
export { useShenora, useShenoraEvent, useShenoraQuery, useShellInfo, } from './hooks.js';
|
|
19
20
|
// Native dialogs, capability-gated. The client half of the host's SHENORA.DIALOGS module.
|
package/dist/types.d.ts
CHANGED
|
@@ -131,6 +131,15 @@ export declare const ShellCapabilities: {
|
|
|
131
131
|
* and allowed roots are the app's, and it says nothing about the URL SCHEME.
|
|
132
132
|
*/
|
|
133
133
|
readonly localFiles: "localFiles";
|
|
134
|
+
/**
|
|
135
|
+
* The shell can HOLD the window at an orientation — see `WindowOrientation`. Android only today; the
|
|
136
|
+
* desktop has nothing to hold, and iOS refuses rather than half-doing it.
|
|
137
|
+
*
|
|
138
|
+
* ⚠ Branch on it, because the page's own fallback is real but weaker: `screen.orientation.lock()` is
|
|
139
|
+
* honoured only while the document is FULLSCREEN, and not at all in WKWebView. Absent here means take
|
|
140
|
+
* fullscreen first or leave rotation alone.
|
|
141
|
+
*/
|
|
142
|
+
readonly windowOrientation: "windowOrientation";
|
|
134
143
|
};
|
|
135
144
|
/** The response envelope the host returns for an {@link IpcRequest}. */
|
|
136
145
|
export interface IpcResponse<TData = unknown> {
|
package/dist/types.js
CHANGED
|
@@ -101,4 +101,13 @@ export const ShellCapabilities = {
|
|
|
101
101
|
* and allowed roots are the app's, and it says nothing about the URL SCHEME.
|
|
102
102
|
*/
|
|
103
103
|
localFiles: 'localFiles',
|
|
104
|
+
/**
|
|
105
|
+
* The shell can HOLD the window at an orientation — see `WindowOrientation`. Android only today; the
|
|
106
|
+
* desktop has nothing to hold, and iOS refuses rather than half-doing it.
|
|
107
|
+
*
|
|
108
|
+
* ⚠ Branch on it, because the page's own fallback is real but weaker: `screen.orientation.lock()` is
|
|
109
|
+
* honoured only while the document is FULLSCREEN, and not at all in WKWebView. Absent here means take
|
|
110
|
+
* fullscreen first or leave rotation alone.
|
|
111
|
+
*/
|
|
112
|
+
windowOrientation: 'windowOrientation',
|
|
104
113
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hold the window at an orientation. Mirrors `Shenora.Modules.Platform.WindowOrientationModule`, pinned
|
|
3
|
+
* by `WireMirrorTests`.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 **Try `screen.orientation.lock()` first — and know why it usually will not do.** The web API is
|
|
6
|
+
* honoured only while the document is FULLSCREEN, so a page can hold an orientation only by taking over
|
|
7
|
+
* the display; and WKWebView does not implement it at all. This route has neither limitation, because the
|
|
8
|
+
* host asks the platform directly. The common shape — portrait everywhere EXCEPT a media viewer — is
|
|
9
|
+
* exactly the one the web API cannot express.
|
|
10
|
+
*
|
|
11
|
+
* ⚠ **Branch on the `windowOrientation` capability**, which only a shell that can really hold an
|
|
12
|
+
* orientation advertises. Calling where it is absent is refused with `CAPABILITY_NOT_SUPPORTED` rather
|
|
13
|
+
* than silently ignored — but a page that checks first never shows a control that cannot work.
|
|
14
|
+
*
|
|
15
|
+
* ⚠ **There is no "what is it now".** The page already knows: `screen.orientation.type`, or a CSS media
|
|
16
|
+
* query that re-renders for it. An IPC answer would be the same fact, later.
|
|
17
|
+
*/
|
|
18
|
+
import type { ShenoraBridge } from './bridge.js';
|
|
19
|
+
import { BaseModuleService } from './moduleService.js';
|
|
20
|
+
/** The orientations a window can be held at — the host's `WindowOrientation` enum, serialized. */
|
|
21
|
+
export type WindowOrientationKind = 'portrait' | 'landscape';
|
|
22
|
+
interface WindowOrientationRequests {
|
|
23
|
+
LOCK: {
|
|
24
|
+
orientation: WindowOrientationKind;
|
|
25
|
+
};
|
|
26
|
+
UNLOCK: void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Typed client for the host's `SHENORA.ORIENTATION` module. Two calls and no state: the app decides
|
|
30
|
+
* WHEN, the kit never rotates anything by itself.
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const orientation = new WindowOrientation();
|
|
34
|
+
* useEffect(() => {
|
|
35
|
+
* if (!capabilities.has('windowOrientation')) return;
|
|
36
|
+
* orientation.lock('landscape'); // entering the viewer
|
|
37
|
+
* return () => { void orientation.unlock(); }; // leaving it
|
|
38
|
+
* }, []);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare class WindowOrientation extends BaseModuleService<WindowOrientationRequests> {
|
|
42
|
+
constructor(bridge?: ShenoraBridge);
|
|
43
|
+
/** Hold the window at `orientation` until {@link unlock}. Idempotent; a second lock replaces the first. */
|
|
44
|
+
lock(orientation: WindowOrientationKind): Promise<void>;
|
|
45
|
+
/** Let the platform choose again — whatever the device's own rotation setting says. Idempotent. */
|
|
46
|
+
unlock(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseModuleService } from './moduleService.js';
|
|
2
|
+
/**
|
|
3
|
+
* Typed client for the host's `SHENORA.ORIENTATION` module. Two calls and no state: the app decides
|
|
4
|
+
* WHEN, the kit never rotates anything by itself.
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const orientation = new WindowOrientation();
|
|
8
|
+
* useEffect(() => {
|
|
9
|
+
* if (!capabilities.has('windowOrientation')) return;
|
|
10
|
+
* orientation.lock('landscape'); // entering the viewer
|
|
11
|
+
* return () => { void orientation.unlock(); }; // leaving it
|
|
12
|
+
* }, []);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class WindowOrientation extends BaseModuleService {
|
|
16
|
+
constructor(bridge) {
|
|
17
|
+
super('SHENORA.ORIENTATION', bridge);
|
|
18
|
+
}
|
|
19
|
+
/** Hold the window at `orientation` until {@link unlock}. Idempotent; a second lock replaces the first. */
|
|
20
|
+
lock(orientation) {
|
|
21
|
+
return this.send('LOCK', { payload: { orientation } });
|
|
22
|
+
}
|
|
23
|
+
/** Let the platform choose again — whatever the device's own rotation setting says. Idempotent. */
|
|
24
|
+
unlock() {
|
|
25
|
+
return this.send('UNLOCK');
|
|
26
|
+
}
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shenora/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "React client for Shenora hosts on Windows, Android and iOS: correlated invoke/send/subscribe over the desktop postMessage bridge or the MAUI HybridWebView transport, typed module services, host-backed stores, and hooks for request tracking and media playback. Drop zones and window commands are desktop-only, because the capabilities are. Ships a browser fallback for pure-UI development.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jiarong Gu",
|