@qilin-agent/client-ui-sidebar-browser 0.0.0-stage → 3.1.3

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/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ //#region lib/types/index.js
2
+ /** Host companion for the Sidebar Browser Client plugin. */
3
+ /** Mount the browser-only plugin through the Client loader. */
4
+ function apply() {}
5
+ //#endregion
6
+ export { apply };
@@ -0,0 +1,76 @@
1
+ /** Per-tab Browser controller. */
2
+ import type { BoundActions } from '@qilin-agent/client-store';
3
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
4
+ import type { HostObservable } from '@qilin-agent/client-ui-slots';
5
+ import type { BrowserFrame, BrowserFrameState } from './BrowserFrame.ts';
6
+ import type { BrowserTabState } from './BrowserNavigation.ts';
7
+ import type { BrowserStore } from './store.ts';
8
+ /** Construction dependencies for one tab-scoped Browser controller. */
9
+ export interface BrowserControllerOptions {
10
+ readonly tabId: TabId;
11
+ readonly signal: AbortSignal;
12
+ readonly applicationOrigin: string;
13
+ readonly initial?: BrowserTabState;
14
+ readonly actions: BoundActions<BrowserStore>;
15
+ }
16
+ /** Owns one Browser tab's URL state, loading lifecycle, and four navigation commands. */
17
+ export declare class BrowserController {
18
+ private readonly options;
19
+ /** Renderer-facing iframe and sandbox state. */
20
+ readonly frame: BrowserFrame;
21
+ private readonly navigation;
22
+ private disposed;
23
+ /**
24
+ * @param options - tab identity, persistence writer, URL origin, and lifetime.
25
+ */
26
+ constructor(options: BrowserControllerOptions);
27
+ /**
28
+ * Validate and load one address, replacing a same-address load with Reload.
29
+ * @param value - address-bar or typed-tab value.
30
+ */
31
+ loadUrl(value: string): void;
32
+ /** Move to the preceding application-known address when Web history remains usable. */
33
+ goBack(): void;
34
+ /** Move to the following application-known address when Web history remains usable. */
35
+ goForward(): void;
36
+ /** Reload the last application-known address without adding history. */
37
+ reload(): void;
38
+ private start;
39
+ private frameLoaded;
40
+ private publish;
41
+ private dispose;
42
+ }
43
+ /** Browser commands and keyed frame state injected into the tab body. */
44
+ export interface BrowserInjected {
45
+ readonly keyedHooks: {
46
+ readonly browserFrame: (key: string) => HostObservable<BrowserFrameState> | undefined;
47
+ };
48
+ /**
49
+ * @param tabId - tab occurrence.
50
+ * @param signal - occurrence lifetime.
51
+ * @param applicationOrigin - current application origin.
52
+ * @param initial - persisted tab state.
53
+ */
54
+ mount(tabId: TabId, signal: AbortSignal, applicationOrigin: string, initial?: BrowserTabState): void;
55
+ /** @param tabId - tab occurrence. @param value - address-bar or typed-open value. */
56
+ loadUrl(tabId: TabId, value: string): void;
57
+ /** @param tabId - tab occurrence. */
58
+ goBack(tabId: TabId): void;
59
+ /** @param tabId - tab occurrence. */
60
+ goForward(tabId: TabId): void;
61
+ /** @param tabId - tab occurrence. */
62
+ reload(tabId: TabId): void;
63
+ /** @param tabId - tab occurrence. */
64
+ toggleSandbox(tabId: TabId): void;
65
+ /** @param tabId - tab occurrence. @param revision - rendered document revision. */
66
+ reportLoaded(tabId: TabId, revision: number): void;
67
+ /** @param tabId - tab occurrence. @param revision - rendered document revision that emitted `error`. */
68
+ reportLoadFailed(tabId: TabId, revision: number): void;
69
+ }
70
+ /**
71
+ * Bind Browser controllers to one Session and its persistence writer.
72
+ * @param actions - Browser store mutation face.
73
+ * @returns a per-tab controller registry exposed as plain Slot callbacks.
74
+ */
75
+ export declare function createBrowserControllers(actions: BoundActions<BrowserStore>): BrowserInjected;
76
+ //# sourceMappingURL=BrowserController.d.ts.map
@@ -0,0 +1,60 @@
1
+ import type { HostObservable } from '@qilin-agent/client-ui-slots';
2
+ import type { BrowserTarget } from './url.ts';
3
+ /** One prepared document rendered by a BrowserFrame implementation. */
4
+ export interface BrowserDocument {
5
+ readonly target: BrowserTarget;
6
+ readonly src: string;
7
+ readonly revision: number;
8
+ }
9
+ /** Current renderer-facing state for one Browser tab. */
10
+ export interface BrowserFrameState {
11
+ readonly document: BrowserDocument | undefined;
12
+ readonly sandboxed: boolean;
13
+ readonly loadFailed: boolean;
14
+ }
15
+ /** Browser rendering operations shared by Web and future Electron implementations. */
16
+ export interface BrowserFrame extends HostObservable<BrowserFrameState> {
17
+ /** Toggle sandbox enforcement for this tab occurrence. */
18
+ toggleSandbox(): void;
19
+ /** @param document - current prepared document. */
20
+ setDocument(document: BrowserDocument): void;
21
+ /** Remove the current prepared document. */
22
+ clearDocument(): void;
23
+ /** @param revision - rendered document revision reported by the carrier. */
24
+ reportLoaded(revision: number): void;
25
+ /** @param revision - rendered document revision whose carrier reported an error. */
26
+ reportLoadFailed(revision: number): void;
27
+ }
28
+ /** Owns transient iframe and sandbox-toggle state independently from URL navigation. */
29
+ export declare class IframeImpl implements BrowserFrame {
30
+ private readonly sandboxChanged;
31
+ private readonly documentLoaded;
32
+ private readonly store;
33
+ /**
34
+ * @param sandboxChanged - applies the new policy to the current controlled target.
35
+ * @param documentLoaded - reports an iframe load to the navigation state machine.
36
+ */
37
+ constructor(sandboxChanged: (sandboxed: boolean) => void, documentLoaded: (revision: number) => void);
38
+ /** @returns the immutable renderer snapshot. */
39
+ getSnapshot: () => BrowserFrameState;
40
+ /**
41
+ * Subscribe to iframe or sandbox-mode changes.
42
+ * @param listener - invalidation callback.
43
+ * @returns the unsubscribe function.
44
+ */
45
+ subscribe: (listener: () => void) => (() => void);
46
+ /** Toggle sandbox enforcement for this tab occurrence. */
47
+ toggleSandbox(): void;
48
+ /**
49
+ * Publish a prepared frame from the owning controller.
50
+ * @param document - current prepared document.
51
+ */
52
+ setDocument(document: BrowserDocument): void;
53
+ /** Remove the current prepared frame and transient load failure. */
54
+ clearDocument(): void;
55
+ /** @param revision - rendered document revision reported by the iframe. */
56
+ reportLoaded(revision: number): void;
57
+ /** @param revision - rendered document revision whose iframe emitted `error`. */
58
+ reportLoadFailed(revision: number): void;
59
+ }
60
+ //# sourceMappingURL=BrowserFrame.d.ts.map
@@ -0,0 +1,109 @@
1
+ /** URL, history, and observability state for one Browser tab. */
2
+ import type { BrowserAddressFailure, BrowserTarget } from './url.ts';
3
+ /** Maximum retained application-known navigation entries per tab. */
4
+ export declare const MAX_BROWSER_HISTORY = 100;
5
+ /** One canonical address in the application-managed Web history. */
6
+ export type BrowserHistoryEntry = BrowserTarget;
7
+ /** Whether the current carrier document still corresponds to an application-known URL. */
8
+ export type BrowserNavigationStatus = {
9
+ readonly status: 'empty';
10
+ } | {
11
+ readonly status: 'loading';
12
+ readonly revision: number;
13
+ } | {
14
+ readonly status: 'known';
15
+ readonly revision: number;
16
+ } | {
17
+ readonly status: 'unknown';
18
+ readonly revision: number;
19
+ };
20
+ /** Address-policy or loading failure shown below the toolbar. */
21
+ export type BrowserFailure = {
22
+ readonly kind: 'address';
23
+ readonly reason: BrowserAddressFailure;
24
+ };
25
+ /** One Browser tab's serializable URL state. */
26
+ export interface BrowserTabState {
27
+ readonly entries: readonly BrowserHistoryEntry[];
28
+ readonly index: number;
29
+ /** Last application-directed load; carrier observations do not rewrite it. */
30
+ readonly request: {
31
+ readonly revision: number;
32
+ readonly target: BrowserTarget;
33
+ } | undefined;
34
+ readonly navigation: BrowserNavigationStatus;
35
+ readonly failure: BrowserFailure | undefined;
36
+ }
37
+ /**
38
+ * Owns the application-known URL history and the iframe observation state machine.
39
+ * The first load for a request keeps its URL authoritative; another load marks it unknown.
40
+ */
41
+ export declare class BrowserNavigation {
42
+ private value;
43
+ /**
44
+ * @param initial - persisted state restored for this tab, or a fresh empty state.
45
+ */
46
+ constructor(initial?: BrowserTabState);
47
+ /**
48
+ * Create state before a tab has a controlled navigation target.
49
+ * @returns empty serializable state.
50
+ */
51
+ static empty(): BrowserTabState;
52
+ /**
53
+ * Read the selected application-history entry.
54
+ * @param state - serializable tab state.
55
+ * @returns the current target, if any.
56
+ */
57
+ static current(state: BrowserTabState | undefined): BrowserHistoryEntry | undefined;
58
+ /**
59
+ * Test whether the Web carrier can use the preceding application-history entry.
60
+ * @param state - serializable tab state.
61
+ * @returns whether Back is available.
62
+ */
63
+ static canGoBack(state: BrowserTabState): boolean;
64
+ /**
65
+ * Test whether the Web carrier can use the following application-history entry.
66
+ * @param state - serializable tab state.
67
+ * @returns whether Forward is available.
68
+ */
69
+ static canGoForward(state: BrowserTabState): boolean;
70
+ /** Current immutable serializable state. */
71
+ get snapshot(): BrowserTabState;
72
+ /** Whether the Web iframe can safely use the application-owned Back entry. */
73
+ get canGoBack(): boolean;
74
+ /** Whether the Web iframe can safely use the application-owned Forward entry. */
75
+ get canGoForward(): boolean;
76
+ /**
77
+ * Add a controlled target and discard its stale forward branch.
78
+ * @param target - validated canonical target.
79
+ * @returns the new load request.
80
+ */
81
+ navigate(target: BrowserTarget): NonNullable<BrowserTabState['request']>;
82
+ /**
83
+ * Select the preceding application-known target.
84
+ * @returns a new load request, or undefined when unavailable.
85
+ */
86
+ back(): BrowserTabState['request'];
87
+ /**
88
+ * Select the following application-known target.
89
+ * @returns a new load request, or undefined when unavailable.
90
+ */
91
+ forward(): BrowserTabState['request'];
92
+ /**
93
+ * Start another load of the last application-known target.
94
+ * @returns a new load request, or undefined before the first target.
95
+ */
96
+ reload(): BrowserTabState['request'];
97
+ /**
98
+ * Record an invalid address without changing the active document state.
99
+ * @param reason - parser refusal.
100
+ */
101
+ addressFailed(reason: BrowserAddressFailure): void;
102
+ /**
103
+ * Record a frame load for its captured revision.
104
+ * @param revision - revision bound to the rendered frame.
105
+ */
106
+ frameLoaded(revision: number): void;
107
+ private request;
108
+ }
109
+ //# sourceMappingURL=BrowserNavigation.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Persisted Browser tab snapshots shared by the body and title slots. */
2
+ import { type EngineStoreHandle } from '@qilin-agent/client-store';
3
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
4
+ import type { BrowserTabState } from './BrowserNavigation.ts';
5
+ /** All Browser tabs in one Session-scoped store. */
6
+ export interface BrowserState {
7
+ byTab: Record<TabId, BrowserTabState>;
8
+ }
9
+ type BrowserActions = {
10
+ replace: (draft: BrowserState, tabId: TabId, state: BrowserTabState) => void;
11
+ forget: (draft: BrowserState, tabId: TabId) => void;
12
+ };
13
+ /**
14
+ * Declare the Session-scoped Browser persistence store.
15
+ * @returns a fresh store handle for Slot registration.
16
+ */
17
+ export declare function createBrowserStore(): EngineStoreHandle<BrowserState, BrowserActions>;
18
+ /** Browser store handle shared by body and title registrations. */
19
+ export type BrowserStore = ReturnType<typeof createBrowserStore>;
20
+ export {};
21
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,31 @@
1
+ /** Address parsing for the Sidebar browser's HTTP(S) allowlist. */
2
+ /** Maximum accepted address length; this bounds persisted navigation state. */
3
+ export declare const MAX_BROWSER_URL_LENGTH: number;
4
+ /** A normalized Browser navigation target. */
5
+ export type BrowserTarget = {
6
+ readonly kind: 'https';
7
+ readonly url: string;
8
+ readonly title: string;
9
+ } | {
10
+ readonly kind: 'http';
11
+ readonly url: string;
12
+ readonly title: string;
13
+ };
14
+ /** Why an address was refused before navigation. */
15
+ export type BrowserAddressFailure = 'empty' | 'invalid' | 'protocol' | 'credentials' | 'application-origin';
16
+ /** Result of parsing an address-bar value. */
17
+ export type BrowserAddressResult = {
18
+ readonly ok: true;
19
+ readonly target: BrowserTarget;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly reason: BrowserAddressFailure;
23
+ };
24
+ /**
25
+ * Parse one address-bar value into the fixed protocol allowlist.
26
+ * @param input - user or typed-open input.
27
+ * @param applicationOrigin - current QILIN document origin, blocked for HTTPS.
28
+ * @returns a canonical target or the refusal reason.
29
+ */
30
+ export declare function parseBrowserAddress(input: string, applicationOrigin?: string): BrowserAddressResult;
31
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1,14 @@
1
+ /** Static Browser tab type and guide declaration. */
2
+ import type { TranslateNS } from '@qilin-agent/client-locale/client';
3
+ import type { SidebarRightTabDefinition } from '@qilin-agent/client-ui-sidebar-right/client';
4
+ /** Browser tab kind. */
5
+ export declare const BROWSER_KIND = "browser";
6
+ /** Browser implementation identity and keyed Slot dispatch key. */
7
+ export declare const BROWSER_ID = "@qilin-agent/client-ui-sidebar-browser";
8
+ /**
9
+ * Build the Browser type with locale-live copy.
10
+ * @param t - namespace-bound translate, read fresh on every label call.
11
+ * @returns the definition to register.
12
+ */
13
+ export declare function browserDefinition(t: TranslateNS<'sidebarBrowser'>): SidebarRightTabDefinition;
14
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Register the HTTP(S) Browser tab type in the right Sidebar. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ export type { BrowserBodyProps } from './view/BrowserBody.tsx';
4
+ export type { BrowserInjected } from './browser/BrowserController.ts';
5
+ export type { BrowserDocument, BrowserFrame, BrowserFrameState } from './browser/BrowserFrame.ts';
6
+ export type { BrowserFailure, BrowserHistoryEntry, BrowserNavigationStatus, BrowserTabState } from './browser/BrowserNavigation.ts';
7
+ export type { SidebarBrowserKey } from './locales.ts';
8
+ export type { BrowserState } from './browser/store.ts';
9
+ export type { BrowserAddressFailure, BrowserAddressResult, BrowserTarget } from './browser/url.ts';
10
+ declare module '@qilin-agent/client-ui-sidebar-right/client' {
11
+ interface SidebarRightTabParamsMap {
12
+ /** Optional initial Browser URL. */
13
+ browser: {
14
+ readonly url?: string;
15
+ };
16
+ }
17
+ }
18
+ /** Required Browser services. */
19
+ export declare const inject: string[];
20
+ /** Register the Browser type, localized guide entry, body, and title. */
21
+ export declare function apply(ctx: Context): void;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,59 @@
1
+ /** Locale-owned Browser tab copy. */
2
+ export declare const zh: {
3
+ 'type.label': string;
4
+ 'guide.title': string;
5
+ 'guide.description': string;
6
+ 'address.placeholder': string;
7
+ 'address.changed': string;
8
+ back: string;
9
+ forward: string;
10
+ reload: string;
11
+ go: string;
12
+ external: string;
13
+ 'sandbox.disable': string;
14
+ 'sandbox.enable': string;
15
+ 'sandbox.warning': string;
16
+ start: string;
17
+ loading: string;
18
+ 'error.empty': string;
19
+ 'error.invalid': string;
20
+ 'error.protocol': string;
21
+ 'error.credentials': string;
22
+ 'error.application-origin': string;
23
+ 'web.loadFailed': string;
24
+ 'web.unknown': string;
25
+ };
26
+ /** Browser dictionary key union. */
27
+ export type SidebarBrowserKey = keyof typeof zh;
28
+ /** English dictionary with the same keys. */
29
+ export declare const en: {
30
+ 'type.label': string;
31
+ 'guide.title': string;
32
+ 'guide.description': string;
33
+ 'address.placeholder': string;
34
+ 'address.changed': string;
35
+ back: string;
36
+ forward: string;
37
+ reload: string;
38
+ go: string;
39
+ external: string;
40
+ 'sandbox.disable': string;
41
+ 'sandbox.enable': string;
42
+ 'sandbox.warning': string;
43
+ start: string;
44
+ loading: string;
45
+ 'error.empty': string;
46
+ 'error.invalid': string;
47
+ 'error.protocol': string;
48
+ 'error.credentials': string;
49
+ 'error.application-origin': string;
50
+ 'web.loadFailed': string;
51
+ 'web.unknown': string;
52
+ };
53
+ declare module '@qilin-agent/client-ui-slots' {
54
+ interface LocaleNamespaceMap {
55
+ /** Sidebar Browser labels, navigation controls, and failures. */
56
+ sidebarBrowser: SidebarBrowserKey;
57
+ }
58
+ }
59
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { InjectFace, PropsLocale, PropsRuntime, PropsStore } from '@qilin-agent/client-ui-slots';
3
+ import type { BrowserInjected } from '../browser/BrowserController.ts';
4
+ import type { BrowserStore } from '../browser/store.ts';
5
+ /** Fixed Web iframe sandbox; popups escape the sandbox while top navigation remains absent. */
6
+ export declare const WEB_BROWSER_SANDBOX = "allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox";
7
+ /** Browser body props assembled by the tab seat. */
8
+ export type BrowserBodyProps = PropsRuntime<'sidebar.right.pane.tab'> & PropsStore<BrowserStore> & PropsLocale<'sidebarBrowser'> & InjectFace<BrowserInjected>;
9
+ /**
10
+ * Browser tab renderer for a controller-owned URL state and Web iframe carrier.
11
+ * @param props - composed slot props for the Browser tab body.
12
+ * @returns the toolbar and the carrier frame.
13
+ */
14
+ export declare function BrowserBody(props: BrowserBodyProps): ReactNode;
15
+ //# sourceMappingURL=BrowserBody.d.ts.map
@@ -0,0 +1,13 @@
1
+ /** Live Browser tab title from the Browser store. */
2
+ import type { ReactNode } from 'react';
3
+ import type { PropsRuntime, PropsStore } from '@qilin-agent/client-ui-slots';
4
+ import type { BrowserStore } from '../browser/store.ts';
5
+ /** Browser title props assembled by the Sidebar title seat. */
6
+ export type BrowserTitleProps = PropsRuntime<'sidebar.right.pane.tab.title'> & PropsStore<BrowserStore>;
7
+ /**
8
+ * Browser icon and current host name.
9
+ * @param props - composed slot props for the Browser tab title.
10
+ * @returns the icon and the current host name.
11
+ */
12
+ export declare function BrowserTitle(props: BrowserTitleProps): ReactNode;
13
+ //# sourceMappingURL=BrowserTitle.d.ts.map
@@ -0,0 +1,4 @@
1
+ /** Host companion for the Sidebar Browser Client plugin. */
2
+ /** Mount the browser-only plugin through the Client loader. */
3
+ export declare function apply(): void;
4
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@qilin-agent/client-ui-sidebar-browser",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Sandboxed Web browser tabs for the right Sidebar",
4
+ "version": "3.1.3",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kkutysllb/QiLin.git",
11
+ "directory": "packages/client/ui-sidebar-browser"
12
+ },
13
+ "engines": {
14
+ "node": "^22.19.0 || >=24.0.0"
15
+ },
16
+ "type": "module",
17
+ "main": "lib/index.js",
18
+ "types": "lib/types/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./lib/types/index.d.ts",
22
+ "default": "./lib/index.js"
23
+ },
24
+ "./client": {
25
+ "types": "./lib/types/client/index.d.ts",
26
+ "default": "./lib/client.js"
27
+ },
28
+ "./src/*": "./src/*",
29
+ "./package.json": "./package.json"
30
+ },
31
+ "qilin": {
32
+ "client": {
33
+ "inject": [
34
+ "@qilin-agent/client-ui-sidebar-right",
35
+ "@qilin-agent/client-ui-session"
36
+ ],
37
+ "platform": "web"
38
+ }
39
+ },
40
+ "license": "MIT",
41
+ "peerDependencies": {
42
+ "@qilin-agent/kylin": "~4.0.3"
43
+ },
44
+ "devDependencies": {
45
+ "@testing-library/react": "^16.1.0",
46
+ "@types/react": "~18.3.1",
47
+ "@types/react-dom": "~18.3.0",
48
+ "react": "^18.2.0",
49
+ "react-dom": "^18.2.0",
50
+ "@qilin-agent/kylin": "~4.0.3",
51
+ "@qilin-agent/client-locale": "3.1.3",
52
+ "@qilin-agent/client-store": "3.1.3",
53
+ "@qilin-agent/client-ui-dockkit": "3.1.3",
54
+ "@qilin-agent/client-ui-primitives": "3.1.3",
55
+ "@qilin-agent/client-ui-renderer": "3.1.3",
56
+ "@qilin-agent/client-ui-session": "3.1.3",
57
+ "@qilin-agent/client-ui-slots": "3.1.3",
58
+ "@qilin-agent/client-ui-sidebar-right": "3.1.3"
59
+ },
60
+ "files": [
61
+ "lib/index.js",
62
+ "lib/client.js",
63
+ "lib/types/**/*.d.ts"
64
+ ],
65
+ "scripts": {
66
+ "bundle": "tsdown",
67
+ "watch": "tsdown --watch"
68
+ }
6
69
  }