@unieai/rabi-client-ui-directory-picker-native 0.0.0-stage → 0.2.2-rc.5
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 +21 -0
- package/README.md +7 -2
- package/lib/client.js +2 -0
- package/lib/index.js +12 -0
- package/lib/types/client/flow.d.ts +17 -0
- package/lib/types/client/index.d.ts +13 -0
- package/lib/types/index.d.ts +10 -0
- package/locale/de.json +6 -0
- package/locale/en.json +5 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +45 -4
- package/src/client/flow.ts +65 -0
- package/src/client/index.ts +46 -0
- package/src/index.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
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,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @unieai/rabi-client-ui-directory-picker-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native directory-picker surface: the renderless workspace directory-flow occupant driving the local Desktop or Host OS chooser
|
|
4
|
+
|
|
5
|
+
Part of Rabi, the agent harness UnieAI Code runs on. Installed as a dependency of `@unieai/rabi`;
|
|
6
|
+
not meant to be used on its own.
|
|
7
|
+
|
|
8
|
+
See LICENSE for the license and copyright of this package.
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
|
|
2
|
+
window.__ModuleLoader__.load({id:`@unieai/rabi-client-ui-directory-picker-native`,factory:require=>{var module={exports:{}};var exports=module.exports;Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let react=require("react");function NativeDirectoryFlow(props){const{open,pick}=props;const armed=(0,react.useRef)(false);const outcome=(0,react.useRef)(props);outcome.current=props;const alive=(0,react.useRef)(true);(0,react.useEffect)(()=>{alive.current=true;return()=>{alive.current=false}},[]);(0,react.useEffect)(()=>{if(!open){armed.current=false;return}if(armed.current)return;armed.current=true;pick().then(path=>{if(!alive.current)return;if(path===null)outcome.current.onCancel();else outcome.current.onPicked(path)},reason=>{if(!alive.current)return;outcome.current.onError(reason instanceof Error?reason.message:String(reason))})},[open,pick]);return null}const inject=[`slots`,`uiWorkspace`,`remoteAccess`];function apply(ctx){const desktop=globalThis.__RABI_DIRECTORY_PICKER__;const pick=desktop===void 0?()=>ctx.uiWorkspace.pickDirectory():()=>desktop.pick();const injected=()=>({pick});ctx.remoteAccess.whenAccess(`directoryPicker/pick`,()=>ctx.slots.inject(`conversation.hero.workspace.directoryFlow`,()=>ctx.slots.inject(`sidebar.workspaces.directoryFlow`,()=>ctx.slots.inject(`workspace.picker.directoryFlow`,function*(){yield ctx.slots.register({name:`conversation.hero.workspace.directoryFlow`,inject:injected},NativeDirectoryFlow);yield ctx.slots.register({name:`sidebar.workspaces.directoryFlow`,inject:injected},NativeDirectoryFlow);yield ctx.slots.register({name:`workspace.picker.directoryFlow`,inject:injected},NativeDirectoryFlow)}))))}exports.apply=apply;exports.inject=inject;return module.exports}});
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region lib/types/index.js
|
|
2
|
+
/**
|
|
3
|
+
* Native directory-picker surface, node half. Pure UI plugin: the empty apply
|
|
4
|
+
* exists so the plugin appears in the host cordis.yml / Loader; the browser
|
|
5
|
+
* half ships via exports["./client"], discovered through the package.json
|
|
6
|
+
* rabi.client declaration. The OS chooser it drives lives in
|
|
7
|
+
* `@unieai/rabi-host-directory-picker-native`.
|
|
8
|
+
*/
|
|
9
|
+
/** Host plugin body — no host-side behavior for this surface plugin. */
|
|
10
|
+
function apply() {}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { apply };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { DirectoryFlowOwnerProps } from '@unieai/rabi-client-ui-workspace/client';
|
|
3
|
+
/** Injected face: the native chooser call the flow drives (bound in apply's closure). */
|
|
4
|
+
export interface NativeFlowInjected {
|
|
5
|
+
/** Open the local desktop or Host single-directory chooser. */
|
|
6
|
+
pick: () => Promise<string | null>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renderless flow occupant: each rising `open` edge runs exactly one pick and
|
|
10
|
+
* reports exactly one outcome; the ref arms once per open so re-renders (and
|
|
11
|
+
* an adoption keeping `open` true while `busy`) never launch a second
|
|
12
|
+
* chooser. The owner withdrawing `open` re-arms the next request.
|
|
13
|
+
* @param props - owner conversation plus the injected pick call.
|
|
14
|
+
* @returns nothing — the native chooser renders on the host display.
|
|
15
|
+
*/
|
|
16
|
+
export declare function NativeDirectoryFlow(props: DirectoryFlowOwnerProps & NativeFlowInjected): ReactElement | null;
|
|
17
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Native directory flow using the local desktop bridge or the Host's OS chooser. */
|
|
2
|
+
import type { Context as ClientContext } from '@unieai/cordis';
|
|
3
|
+
/** Required services (cordis fiber inject): the slot registry, workspace UI service, and access. */
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
/**
|
|
6
|
+
* Client plugin body: while the current Peer may open the Host's directory
|
|
7
|
+
* chooser, register the renderless native flow into all three directory-flow
|
|
8
|
+
* holes through `slots.inject()` because the ui-workspace declarations may
|
|
9
|
+
* activate later or be replaced.
|
|
10
|
+
* @param ctx - client root context.
|
|
11
|
+
*/
|
|
12
|
+
export declare function apply(ctx: ClientContext): void;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native directory-picker surface, node half. Pure UI plugin: the empty apply
|
|
3
|
+
* exists so the plugin appears in the host cordis.yml / Loader; the browser
|
|
4
|
+
* half ships via exports["./client"], discovered through the package.json
|
|
5
|
+
* rabi.client declaration. The OS chooser it drives lives in
|
|
6
|
+
* `@unieai/rabi-host-directory-picker-native`.
|
|
7
|
+
*/
|
|
8
|
+
/** Host plugin body — no host-side behavior for this surface plugin. */
|
|
9
|
+
export declare function apply(): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/locale/de.json
ADDED
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unieai/rabi-client-ui-directory-picker-native",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Native directory-picker surface: the renderless workspace directory-flow occupant driving the local Desktop or Host OS chooser",
|
|
4
|
+
"version": "0.2.2-rc.5",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"types": "lib/types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./client": {
|
|
17
|
+
"types": "./lib/types/client/index.d.ts",
|
|
18
|
+
"default": "./lib/client.js"
|
|
19
|
+
},
|
|
20
|
+
"./src/*": "./src/*",
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./locale/*.json": "./locale/*.json"
|
|
23
|
+
},
|
|
24
|
+
"rabi": {
|
|
25
|
+
"client": {
|
|
26
|
+
"inject": [
|
|
27
|
+
"@unieai/rabi-client-ui-renderer",
|
|
28
|
+
"@unieai/rabi-client-ui-workspace"
|
|
29
|
+
],
|
|
30
|
+
"platform": "web"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@unieai/cordis": "4.1.0"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"locale/*.json",
|
|
39
|
+
"lib/index.js",
|
|
40
|
+
"lib/client.js",
|
|
41
|
+
"lib/types/**/*.d.ts",
|
|
42
|
+
"lib/types/**/*.d.ts.map",
|
|
43
|
+
"lib/**/*.js.map",
|
|
44
|
+
"src",
|
|
45
|
+
"README.md"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native picking occupant (package-internal; the `./client` surface
|
|
3
|
+
* exposes only the Loader exports). Same-package tests exercise it directly
|
|
4
|
+
* through this module.
|
|
5
|
+
*/
|
|
6
|
+
import { useEffect, useRef } from 'react'
|
|
7
|
+
import type { ReactElement } from 'react'
|
|
8
|
+
// Type-only: the owner contract of the directory-flow holes.
|
|
9
|
+
import type { DirectoryFlowOwnerProps } from '@unieai/rabi-client-ui-workspace/client'
|
|
10
|
+
|
|
11
|
+
/** Injected face: the native chooser call the flow drives (bound in apply's closure). */
|
|
12
|
+
export interface NativeFlowInjected {
|
|
13
|
+
/** Open the local desktop or Host single-directory chooser. */
|
|
14
|
+
pick: () => Promise<string | null>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renderless flow occupant: each rising `open` edge runs exactly one pick and
|
|
19
|
+
* reports exactly one outcome; the ref arms once per open so re-renders (and
|
|
20
|
+
* an adoption keeping `open` true while `busy`) never launch a second
|
|
21
|
+
* chooser. The owner withdrawing `open` re-arms the next request.
|
|
22
|
+
* @param props - owner conversation plus the injected pick call.
|
|
23
|
+
* @returns nothing — the native chooser renders on the host display.
|
|
24
|
+
*/
|
|
25
|
+
export function NativeDirectoryFlow(props: DirectoryFlowOwnerProps & NativeFlowInjected): ReactElement | null {
|
|
26
|
+
const { open, pick } = props
|
|
27
|
+
const armed = useRef(false)
|
|
28
|
+
// Callbacks ride a ref so the settled pick reports through the owner's
|
|
29
|
+
// latest handlers, not the ones captured when the chooser opened.
|
|
30
|
+
const outcome = useRef(props)
|
|
31
|
+
outcome.current = props
|
|
32
|
+
// Unmount (HMR replacing the occupant) discards settlements wholesale: the
|
|
33
|
+
// dead instance must neither adopt a path nor drive the owner's error
|
|
34
|
+
// surface. The wire carries no per-request abort, so the native chooser
|
|
35
|
+
// survives until answered — its answer just lands nowhere; the replacement
|
|
36
|
+
// instance re-arms under the owner's still-open request. An injected-face
|
|
37
|
+
// identity change alone (re-registration) keeps the pending settlement:
|
|
38
|
+
// the native chooser is still the same dialog.
|
|
39
|
+
const alive = useRef(true)
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
// StrictMode's development replay runs the cleanup once before the real
|
|
42
|
+
// lifetime: re-arm on setup or every outcome would be discarded.
|
|
43
|
+
alive.current = true
|
|
44
|
+
return () => { alive.current = false }
|
|
45
|
+
}, [])
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!open) {
|
|
48
|
+
armed.current = false
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
if (armed.current) return
|
|
52
|
+
armed.current = true
|
|
53
|
+
pick().then(
|
|
54
|
+
(path) => {
|
|
55
|
+
if (!alive.current) return
|
|
56
|
+
if (path === null) outcome.current.onCancel(); else outcome.current.onPicked(path)
|
|
57
|
+
},
|
|
58
|
+
(reason: unknown) => {
|
|
59
|
+
if (!alive.current) return
|
|
60
|
+
outcome.current.onError(reason instanceof Error ? reason.message : String(reason))
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
}, [open, pick])
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Native directory flow using the local desktop bridge or the Host's OS chooser. */
|
|
2
|
+
import type { Context as ClientContext } from '@unieai/cordis'
|
|
3
|
+
// Type-only: pulls the remoteAccess service merge (ctx.remoteAccess).
|
|
4
|
+
import type {} from '@unieai/rabi-api-remote-access/client'
|
|
5
|
+
// Type-only: pulls the SlotMap merge declaring the directory-flow holes.
|
|
6
|
+
import type {} from '@unieai/rabi-client-ui-workspace/client'
|
|
7
|
+
// Type-only: pulls the SlotRegistry service merge (ctx.slots).
|
|
8
|
+
import type {} from '@unieai/rabi-client-ui-renderer/client'
|
|
9
|
+
import type { NativeFlowInjected } from './flow.ts'
|
|
10
|
+
import { NativeDirectoryFlow } from './flow.ts'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** Required services (cordis fiber inject): the slot registry, workspace UI service, and access. */
|
|
14
|
+
export const inject = ['slots', 'uiWorkspace', 'remoteAccess']
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Client plugin body: while the current Peer may open the Host's directory
|
|
18
|
+
* chooser, register the renderless native flow into all three directory-flow
|
|
19
|
+
* holes through `slots.inject()` because the ui-workspace declarations may
|
|
20
|
+
* activate later or be replaced.
|
|
21
|
+
* @param ctx - client root context.
|
|
22
|
+
*/
|
|
23
|
+
export function apply(ctx: ClientContext): void {
|
|
24
|
+
const desktop = (globalThis as typeof globalThis & {
|
|
25
|
+
__RABI_DIRECTORY_PICKER__?: NativeFlowInjected
|
|
26
|
+
}).__RABI_DIRECTORY_PICKER__
|
|
27
|
+
const pick = desktop === undefined ? () => ctx.uiWorkspace.pickDirectory() : () => desktop.pick()
|
|
28
|
+
const injected = (): NativeFlowInjected => ({ pick })
|
|
29
|
+
// Every declaration lifetime must be live before the set installs; the
|
|
30
|
+
// generator makes the three registrations one transactional effect. The
|
|
31
|
+
// nesting order is arbitrary; no hole has precedence.
|
|
32
|
+
ctx.remoteAccess.whenAccess('directoryPicker/pick', () =>
|
|
33
|
+
ctx.slots.inject('conversation.hero.workspace.directoryFlow', () =>
|
|
34
|
+
ctx.slots.inject('sidebar.workspaces.directoryFlow', () =>
|
|
35
|
+
ctx.slots.inject('workspace.picker.directoryFlow', function* () {
|
|
36
|
+
yield ctx.slots.register({
|
|
37
|
+
name: 'conversation.hero.workspace.directoryFlow', inject: injected,
|
|
38
|
+
}, NativeDirectoryFlow)
|
|
39
|
+
yield ctx.slots.register({
|
|
40
|
+
name: 'sidebar.workspaces.directoryFlow', inject: injected,
|
|
41
|
+
}, NativeDirectoryFlow)
|
|
42
|
+
yield ctx.slots.register({
|
|
43
|
+
name: 'workspace.picker.directoryFlow', inject: injected,
|
|
44
|
+
}, NativeDirectoryFlow)
|
|
45
|
+
}))))
|
|
46
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native directory-picker surface, node half. Pure UI plugin: the empty apply
|
|
3
|
+
* exists so the plugin appears in the host cordis.yml / Loader; the browser
|
|
4
|
+
* half ships via exports["./client"], discovered through the package.json
|
|
5
|
+
* rabi.client declaration. The OS chooser it drives lives in
|
|
6
|
+
* `@unieai/rabi-host-directory-picker-native`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Host plugin body — no host-side behavior for this surface plugin. */
|
|
10
|
+
export function apply(): void {}
|