@tivility/dsh-session-share 0.3.2 → 0.3.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/client/index.js
CHANGED
|
@@ -89,7 +89,9 @@ function openRequestedSession(ctx) {
|
|
|
89
89
|
export function apply(ctx) {
|
|
90
90
|
openRequestedSession(ctx);
|
|
91
91
|
ctx.effect(() => ctx.locale.register(SHARE_NS, { zh, en }));
|
|
92
|
-
|
|
92
|
+
// Declaration-gated since dsh 0.1.3: registering into a slot before its
|
|
93
|
+
// parent declares it throws, so the registration waits behind slots.inject.
|
|
94
|
+
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
|
93
95
|
// The header's utility band, not the title row: this is a control, and the
|
|
94
96
|
// band beside the breadcrumb is where static session context belongs.
|
|
95
97
|
name: 'conversation.session.header.utilities',
|
package/lib/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,cAAc,CA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AAC,CAAA;AAChB,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -188,7 +188,7 @@ function apply(ctx) {
|
|
|
188
188
|
zh,
|
|
189
189
|
en
|
|
190
190
|
}));
|
|
191
|
-
ctx.
|
|
191
|
+
ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
|
|
192
192
|
name: "conversation.session.header.utilities",
|
|
193
193
|
id: "session-share",
|
|
194
194
|
locale: SHARE_NS
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["Button","IconCheckOutline16","IconLinkOutline16"],"sources":["param.js","client/locales.js","client/namespace.js","client/ShareLink.js","client/index.js"],"sourcesContent":["/**\n * The one fact both halves of this plugin have to agree on.\n *\n * The query parameter is a constant rather than configuration because the two\n * halves cannot share a configuration value: the browser bundle is fetched\n * outside the loader's config tree and receives only what its own `apply`\n * is handed, while the link the host writes into the system prompt is built\n * on the other side of the wire. A constant is the honest form of a value\n * that must match in two places.\n * @module @tivility/dsh-session-share/param\n */\n/** Query parameter naming the session to open on load. */\nexport const SESSION_PARAM = 'session';\n/**\n * Build the query a share link carries.\n * @param sessionId - the session to open.\n * @returns the query string, question mark included.\n */\nexport function shareQuery(sessionId) {\n return `?${SESSION_PARAM}=${encodeURIComponent(sessionId)}`;\n}\n//# sourceMappingURL=param.js.map","/** Copy for the session-header share control. */\n/** English copy. */\nexport const en = {\n copy: 'Copy link',\n copied: 'Copied',\n hint: 'Copy a link that opens this session',\n};\n/** Chinese copy. */\nexport const zh = {\n copy: '复制链接',\n copied: '已复制',\n hint: '复制一个直接打开这条会话的链接',\n};\n//# sourceMappingURL=locales.js.map","/**\n * The locale namespace this bundle registers, and the key union its copy\n * satisfies.\n *\n * Kept in its own module because the declaration merge below has to be visible\n * to both the registration site and the component, and importing the component\n * from the registration site (or the reverse) would make that a cycle.\n * @module @tivility/dsh-session-share/client/namespace\n */\n/** Locale namespace for the session-header share control. */\nexport const SHARE_NS = 'session.share';\n//# sourceMappingURL=namespace.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * The session header's \"copy link\" control.\n *\n * Without it the feature is unreachable by a person: the link format lives in\n * the system prompt, which teaches the *model* to hand out links, and leaves\n * whoever is looking at the GUI to construct one from a session id they cannot\n * see. This is the one affordance that makes it a feature rather than a\n * convention.\n *\n * The origin comes from `window.location`, so the link is always the address\n * this browser reached the harness at — the loopback URL when that is how you\n * opened it, the LAN address when it is not. Nothing to configure, and nothing\n * that can drift from where the server actually answers.\n * @module @tivility/dsh-session-share/client/ShareLink\n */\nimport { useCallback, useState } from 'react';\nimport { Button, IconCheckOutline16, IconLinkOutline16, writeClipboard, } from '@deepseek-ai/dsh-client-ui-primitives';\nimport { shareQuery } from '../param.js';\nimport { SHARE_NS } from './namespace.js';\n/** How long the copied state shows, in ms — matched to the harness's own copy controls. */\nconst COPIED_MS = 1000;\n/**\n * Render the copy-link control for the current session.\n * @param props - composed slot props.\n * @returns the control.\n */\nexport function ShareLink({ sessionId, t }) {\n const [copied, setCopied] = useState(false);\n const url = `${window.location.origin}/${shareQuery(String(sessionId))}`;\n const onCopy = useCallback(() => {\n if (copied)\n return;\n void writeClipboard(url).then((accepted) => {\n // A refused write (denied permission, insecure context) leaves the flag\n // alone: the control must never claim a copy the host declined.\n if (!accepted)\n return;\n setCopied(true);\n window.setTimeout(() => { setCopied(false); }, COPIED_MS);\n });\n }, [copied, url]);\n return (_jsx(Button, { variant: \"ghost\", size: \"sm\", onClick: onCopy, \n // The URL itself is the most useful hover text: it is what gets copied,\n // and seeing it is how someone learns the format exists.\n title: copied ? t('copied') : `${t('hint')}\\n${url}`, icon: copied ? _jsx(IconCheckOutline16, { size: 14 }) : _jsx(IconLinkOutline16, { size: 14 }), children: copied ? t('copied') : t('copy') }));\n}\n//# sourceMappingURL=ShareLink.js.map","/**\n * The browser half: open the session a link names, and offer a way to get one.\n *\n * The harness's GUI has no routing — the whole client is searched in vain for\n * `pushState`, `location.hash`, or `searchParams`. The selected session lives\n * in the sessions manager and is restored from persisted state on load, so a\n * URL naming one has nowhere to be read. This adds that step, and the control\n * that makes it reachable by a person rather than only by the model.\n *\n * It deliberately hides nothing. The sidebar, the other sessions, and the\n * composer are all exactly as they would be — the link decides where you land,\n * not what you can see.\n *\n * ## Why the context is typed here\n *\n * The two halves of this package compile in one TypeScript program, and the\n * node half pulls in the harness's HOST augmentations of `Context` — where\n * `sessions` is a different service with the same name. Importing\n * `ClientContext` would therefore resolve `ctx.sessions` to the host's shape.\n * The harness avoids this with separate client and host programs; this package\n * states the members it uses instead.\n * @module @tivility/dsh-session-share/client\n */\nimport { SESSION_PARAM } from '../param.js';\nimport { en, zh } from './locales.js';\nimport { SHARE_NS } from './namespace.js';\nimport { ShareLink } from './ShareLink.js';\nexport { ShareLink } from './ShareLink.js';\nexport { SHARE_NS } from './namespace.js';\n/** Client-side services this plugin drives. */\nexport const inject = ['sessions', 'slots', 'locale'];\n/**\n * Remove the parameter from the address bar once it has been acted on.\n *\n * The selection is persisted by the runtime, so leaving the parameter in place\n * would make every later reload jump back to the linked session — fighting the\n * user each time they navigate away and refresh. Consuming it once makes the\n * link mean \"start here\", which is what a link means.\n */\nfunction stripParam() {\n const url = new URL(window.location.href);\n if (!url.searchParams.has(SESSION_PARAM))\n return;\n url.searchParams.delete(SESSION_PARAM);\n window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);\n}\n/**\n * Open the session a `?session=` parameter names, once the list can carry it.\n * @param ctx - the client root context.\n */\nfunction openRequestedSession(ctx) {\n const requested = new URL(window.location.href).searchParams.get(SESSION_PARAM);\n // No parameter is the overwhelmingly common case — every ordinary visit — so\n // this costs nothing at all when it has nothing to do.\n if (requested === null || requested === '')\n return;\n ctx.effect(() => {\n let done = false;\n const attempt = () => {\n if (done)\n return;\n const state = ctx.sessions.list.getSnapshot();\n if (state.byId[requested] !== undefined) {\n done = true;\n ctx.sessions.open(requested);\n stripParam();\n return;\n }\n // The list arrives asynchronously, so an id that is absent right now may\n // simply not have loaded. The phase is what separates \"not yet\" from \"no\n // such session\" — a timeout would guess at it.\n if (state.phase === 'ready') {\n done = true;\n stripParam();\n ctx.logger?.warn?.(`session-share: no session ${requested} in this harness`);\n }\n };\n const unsubscribe = ctx.sessions.list.subscribe(attempt);\n // The list may already be ready before this plugin activates, in which case\n // no change is ever published and the subscription alone would wait forever.\n attempt();\n return unsubscribe;\n });\n}\n/**\n * Read the link, and offer one.\n * @param ctx - the client root context.\n */\nexport function apply(ctx) {\n openRequestedSession(ctx);\n ctx.effect(() => ctx.locale.register(SHARE_NS, { zh, en }));\n ctx.effect(() => ctx.slots.register({\n // The header's utility band, not the title row: this is a control, and the\n // band beside the breadcrumb is where static session context belongs.\n name: 'conversation.session.header.utilities',\n id: 'session-share',\n locale: SHARE_NS,\n }, ShareLink));\n}\n//# sourceMappingURL=index.js.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYA,MAAa,gBAAgB;;;;;;AAM7B,SAAgB,WAAW,WAAW;AAClC,QAAO,IAAI,cAAc,GAAG,mBAAmB,UAAU;;;;;;;ACjB7D,MAAa,KAAK;CACd,MAAM;CACN,QAAQ;CACR,MAAM;CACT;;AAED,MAAa,KAAK;CACd,MAAM;CACN,QAAQ;CACR,MAAM;CACT;;;;;;;;;;;;;;ACFD,MAAa,WAAW;;;;;;;;;;;;;;;;;;;;ACWxB,MAAM,YAAY;;;;;;AAMlB,SAAgB,UAAU,EAAE,WAAW,KAAK;CACxC,MAAM,CAAC,QAAQ,iCAAsB,MAAM;CAC3C,MAAM,MAAM,GAAG,OAAO,SAAS,OAAO,GAAG,WAAW,OAAO,UAAU,CAAC;AAatE,mCAAaA,8CAAQ;EAAE,SAAS;EAAS,MAAM;EAAM,sCAZpB;AAC7B,OAAI,OACA;AACJ,6DAAoB,IAAI,CAAC,MAAM,aAAa;AAGxC,QAAI,CAAC,SACD;AACJ,cAAU,KAAK;AACf,WAAO,iBAAiB;AAAE,eAAU,MAAM;OAAK,U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AAI;EAAI,CAAC,CAAC;AAC3D,KAAI,aAAa,IAAI,MAAM,SAAS;EAGhC,MAAM;EACN,IAAI;EACJ,QAAQ;EACX,EAAE,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["Button","IconCheckOutline16","IconLinkOutline16"],"sources":["param.js","client/locales.js","client/namespace.js","client/ShareLink.js","client/index.js"],"sourcesContent":["/**\n * The one fact both halves of this plugin have to agree on.\n *\n * The query parameter is a constant rather than configuration because the two\n * halves cannot share a configuration value: the browser bundle is fetched\n * outside the loader's config tree and receives only what its own `apply`\n * is handed, while the link the host writes into the system prompt is built\n * on the other side of the wire. A constant is the honest form of a value\n * that must match in two places.\n * @module @tivility/dsh-session-share/param\n */\n/** Query parameter naming the session to open on load. */\nexport const SESSION_PARAM = 'session';\n/**\n * Build the query a share link carries.\n * @param sessionId - the session to open.\n * @returns the query string, question mark included.\n */\nexport function shareQuery(sessionId) {\n return `?${SESSION_PARAM}=${encodeURIComponent(sessionId)}`;\n}\n//# sourceMappingURL=param.js.map","/** Copy for the session-header share control. */\n/** English copy. */\nexport const en = {\n copy: 'Copy link',\n copied: 'Copied',\n hint: 'Copy a link that opens this session',\n};\n/** Chinese copy. */\nexport const zh = {\n copy: '复制链接',\n copied: '已复制',\n hint: '复制一个直接打开这条会话的链接',\n};\n//# sourceMappingURL=locales.js.map","/**\n * The locale namespace this bundle registers, and the key union its copy\n * satisfies.\n *\n * Kept in its own module because the declaration merge below has to be visible\n * to both the registration site and the component, and importing the component\n * from the registration site (or the reverse) would make that a cycle.\n * @module @tivility/dsh-session-share/client/namespace\n */\n/** Locale namespace for the session-header share control. */\nexport const SHARE_NS = 'session.share';\n//# sourceMappingURL=namespace.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * The session header's \"copy link\" control.\n *\n * Without it the feature is unreachable by a person: the link format lives in\n * the system prompt, which teaches the *model* to hand out links, and leaves\n * whoever is looking at the GUI to construct one from a session id they cannot\n * see. This is the one affordance that makes it a feature rather than a\n * convention.\n *\n * The origin comes from `window.location`, so the link is always the address\n * this browser reached the harness at — the loopback URL when that is how you\n * opened it, the LAN address when it is not. Nothing to configure, and nothing\n * that can drift from where the server actually answers.\n * @module @tivility/dsh-session-share/client/ShareLink\n */\nimport { useCallback, useState } from 'react';\nimport { Button, IconCheckOutline16, IconLinkOutline16, writeClipboard, } from '@deepseek-ai/dsh-client-ui-primitives';\nimport { shareQuery } from '../param.js';\nimport { SHARE_NS } from './namespace.js';\n/** How long the copied state shows, in ms — matched to the harness's own copy controls. */\nconst COPIED_MS = 1000;\n/**\n * Render the copy-link control for the current session.\n * @param props - composed slot props.\n * @returns the control.\n */\nexport function ShareLink({ sessionId, t }) {\n const [copied, setCopied] = useState(false);\n const url = `${window.location.origin}/${shareQuery(String(sessionId))}`;\n const onCopy = useCallback(() => {\n if (copied)\n return;\n void writeClipboard(url).then((accepted) => {\n // A refused write (denied permission, insecure context) leaves the flag\n // alone: the control must never claim a copy the host declined.\n if (!accepted)\n return;\n setCopied(true);\n window.setTimeout(() => { setCopied(false); }, COPIED_MS);\n });\n }, [copied, url]);\n return (_jsx(Button, { variant: \"ghost\", size: \"sm\", onClick: onCopy, \n // The URL itself is the most useful hover text: it is what gets copied,\n // and seeing it is how someone learns the format exists.\n title: copied ? t('copied') : `${t('hint')}\\n${url}`, icon: copied ? _jsx(IconCheckOutline16, { size: 14 }) : _jsx(IconLinkOutline16, { size: 14 }), children: copied ? t('copied') : t('copy') }));\n}\n//# sourceMappingURL=ShareLink.js.map","/**\n * The browser half: open the session a link names, and offer a way to get one.\n *\n * The harness's GUI has no routing — the whole client is searched in vain for\n * `pushState`, `location.hash`, or `searchParams`. The selected session lives\n * in the sessions manager and is restored from persisted state on load, so a\n * URL naming one has nowhere to be read. This adds that step, and the control\n * that makes it reachable by a person rather than only by the model.\n *\n * It deliberately hides nothing. The sidebar, the other sessions, and the\n * composer are all exactly as they would be — the link decides where you land,\n * not what you can see.\n *\n * ## Why the context is typed here\n *\n * The two halves of this package compile in one TypeScript program, and the\n * node half pulls in the harness's HOST augmentations of `Context` — where\n * `sessions` is a different service with the same name. Importing\n * `ClientContext` would therefore resolve `ctx.sessions` to the host's shape.\n * The harness avoids this with separate client and host programs; this package\n * states the members it uses instead.\n * @module @tivility/dsh-session-share/client\n */\nimport { SESSION_PARAM } from '../param.js';\nimport { en, zh } from './locales.js';\nimport { SHARE_NS } from './namespace.js';\nimport { ShareLink } from './ShareLink.js';\nexport { ShareLink } from './ShareLink.js';\nexport { SHARE_NS } from './namespace.js';\n/** Client-side services this plugin drives. */\nexport const inject = ['sessions', 'slots', 'locale'];\n/**\n * Remove the parameter from the address bar once it has been acted on.\n *\n * The selection is persisted by the runtime, so leaving the parameter in place\n * would make every later reload jump back to the linked session — fighting the\n * user each time they navigate away and refresh. Consuming it once makes the\n * link mean \"start here\", which is what a link means.\n */\nfunction stripParam() {\n const url = new URL(window.location.href);\n if (!url.searchParams.has(SESSION_PARAM))\n return;\n url.searchParams.delete(SESSION_PARAM);\n window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);\n}\n/**\n * Open the session a `?session=` parameter names, once the list can carry it.\n * @param ctx - the client root context.\n */\nfunction openRequestedSession(ctx) {\n const requested = new URL(window.location.href).searchParams.get(SESSION_PARAM);\n // No parameter is the overwhelmingly common case — every ordinary visit — so\n // this costs nothing at all when it has nothing to do.\n if (requested === null || requested === '')\n return;\n ctx.effect(() => {\n let done = false;\n const attempt = () => {\n if (done)\n return;\n const state = ctx.sessions.list.getSnapshot();\n if (state.byId[requested] !== undefined) {\n done = true;\n ctx.sessions.open(requested);\n stripParam();\n return;\n }\n // The list arrives asynchronously, so an id that is absent right now may\n // simply not have loaded. The phase is what separates \"not yet\" from \"no\n // such session\" — a timeout would guess at it.\n if (state.phase === 'ready') {\n done = true;\n stripParam();\n ctx.logger?.warn?.(`session-share: no session ${requested} in this harness`);\n }\n };\n const unsubscribe = ctx.sessions.list.subscribe(attempt);\n // The list may already be ready before this plugin activates, in which case\n // no change is ever published and the subscription alone would wait forever.\n attempt();\n return unsubscribe;\n });\n}\n/**\n * Read the link, and offer one.\n * @param ctx - the client root context.\n */\nexport function apply(ctx) {\n openRequestedSession(ctx);\n ctx.effect(() => ctx.locale.register(SHARE_NS, { zh, en }));\n // Declaration-gated since dsh 0.1.3: registering into a slot before its\n // parent declares it throws, so the registration waits behind slots.inject.\n ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({\n // The header's utility band, not the title row: this is a control, and the\n // band beside the breadcrumb is where static session context belongs.\n name: 'conversation.session.header.utilities',\n id: 'session-share',\n locale: SHARE_NS,\n }, ShareLink));\n}\n//# sourceMappingURL=index.js.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYA,MAAa,gBAAgB;;;;;;AAM7B,SAAgB,WAAW,WAAW;AAClC,QAAO,IAAI,cAAc,GAAG,mBAAmB,UAAU;;;;;;;ACjB7D,MAAa,KAAK;CACd,MAAM;CACN,QAAQ;CACR,MAAM;CACT;;AAED,MAAa,KAAK;CACd,MAAM;CACN,QAAQ;CACR,MAAM;CACT;;;;;;;;;;;;;;ACFD,MAAa,WAAW;;;;;;;;;;;;;;;;;;;;ACWxB,MAAM,YAAY;;;;;;AAMlB,SAAgB,UAAU,EAAE,WAAW,KAAK;CACxC,MAAM,CAAC,QAAQ,iCAAsB,MAAM;CAC3C,MAAM,MAAM,GAAG,OAAO,SAAS,OAAO,GAAG,WAAW,OAAO,UAAU,CAAC;AAatE,mCAAaA,8CAAQ;EAAE,SAAS;EAAS,MAAM;EAAM,sCAZpB;AAC7B,OAAI,OACA;AACJ,6DAAoB,IAAI,CAAC,MAAM,aAAa;AAGxC,QAAI,CAAC,SACD;AACJ,cAAU,KAAK;AACf,WAAO,iBAAiB;AAAE,eAAU,MAAM;OAAK,UAAU;KAC3D;KACH,CAAC,QAAQ,IAAI,CAAC;EAIb,OAAO,SAAS,EAAE,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,IAAI;EAAO,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X,EAAE,UAAU,CAAC"}
|
|
@@ -50,6 +50,8 @@ interface SlotsFace {
|
|
|
50
50
|
order?: number;
|
|
51
51
|
locale?: string;
|
|
52
52
|
}, component: unknown): () => void;
|
|
53
|
+
/** Declaration-gated wait (dsh ≥0.1.3): runs the callback once the slot's parent declares it. */
|
|
54
|
+
inject(name: string, callback: () => () => void): () => void;
|
|
53
55
|
}
|
|
54
56
|
/** The locale registry, narrowed to the one bundle this plugin adds. */
|
|
55
57
|
interface LocaleFace {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,mDAAmD;AACnD,UAAU,mBAAmB;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAChD,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAA;CACpC;AAED,kEAAkE;AAClE,UAAU,YAAY;IACpB,QAAQ,CAAC,IAAI,EAAE;QACb,WAAW,IAAI,mBAAmB,CAAA;QAClC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;KAC5C,CAAA;IACD;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,6EAA6E;AAC7E,UAAU,SAAS;IACjB,QAAQ,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,EAA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GAAG,MAAM,IAAI,CAAA;CAC/E;AAED,mDAAmD;AACnD,UAAU,YAAY;IACpB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,MAAM,CAAC,GAAG,EAAE,MAAM,MAAM,IAAI,GAAG,OAAO,CAAA;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CACnD;AAED,+CAA+C;AAC/C,eAAO,MAAM,MAAM,UAAkC,CAAA;AAuDrD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAa7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tivility/dsh-session-share",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Link straight to one DeepSeek Harness session: the GUI opens on it instead of wherever it was left.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,8 +43,11 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"bundle": "tsdown"
|
|
48
|
+
},
|
|
46
49
|
"dependencies": {
|
|
47
|
-
"@tivility/dsh-web-kit": "
|
|
50
|
+
"@tivility/dsh-web-kit": "workspace:^"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"@deepseek-ai/cordis": "*",
|
|
@@ -80,8 +83,5 @@
|
|
|
80
83
|
},
|
|
81
84
|
"publishConfig": {
|
|
82
85
|
"access": "public"
|
|
83
|
-
},
|
|
84
|
-
"scripts": {
|
|
85
|
-
"bundle": "tsdown"
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -54,6 +54,8 @@ interface SessionsFace {
|
|
|
54
54
|
/** The slot registry, narrowed to the one registration this plugin makes. */
|
|
55
55
|
interface SlotsFace {
|
|
56
56
|
register(spec: { name: string, id?: string, order?: number, locale?: string }, component: unknown): () => void
|
|
57
|
+
/** Declaration-gated wait (dsh ≥0.1.3): runs the callback once the slot's parent declares it. */
|
|
58
|
+
inject(name: string, callback: () => () => void): () => void
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/** The locale registry, narrowed to the one bundle this plugin adds. */
|
|
@@ -134,7 +136,9 @@ export function apply(ctx: ShareContext): void {
|
|
|
134
136
|
openRequestedSession(ctx)
|
|
135
137
|
|
|
136
138
|
ctx.effect(() => ctx.locale.register(SHARE_NS, { zh, en }))
|
|
137
|
-
|
|
139
|
+
// Declaration-gated since dsh 0.1.3: registering into a slot before its
|
|
140
|
+
// parent declares it throws, so the registration waits behind slots.inject.
|
|
141
|
+
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
|
138
142
|
// The header's utility band, not the title row: this is a control, and the
|
|
139
143
|
// band beside the breadcrumb is where static session context belongs.
|
|
140
144
|
name: 'conversation.session.header.utilities',
|