dsh-codex-subscription 3.2.9 → 3.2.10

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.js CHANGED
@@ -11654,7 +11654,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
11654
11654
  }
11655
11655
  //#endregion
11656
11656
  //#region src/version.js
11657
- const PACKAGE_VERSION = "3.2.9";
11657
+ const PACKAGE_VERSION = "3.2.10";
11658
11658
  //#endregion
11659
11659
  //#region src/client-recovery.js
11660
11660
  async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = endpoint === "usage" || endpoint.startsWith("usage/") ? 3e4 : 1e4) {
@@ -20936,11 +20936,182 @@ void main(){
20936
20936
  });
20937
20937
  }
20938
20938
  //#endregion
20939
+ //#region src/composer-prediction-layout.js
20940
+ const pixels = (value) => Number.parseFloat(value) || 0;
20941
+ /** Convert the mirror's border-box height to the editor's CSS min-height. */
20942
+ function predictionMinHeight(height, style) {
20943
+ if (!Number.isFinite(height)) return null;
20944
+ const inset = style.boxSizing === "border-box" ? 0 : pixels(style.paddingTop) + pixels(style.paddingBottom) + pixels(style.borderTopWidth) + pixels(style.borderBottomWidth);
20945
+ return Math.max(0, pixels(style.minHeight), height - inset);
20946
+ }
20947
+ function predictionAnchor(editor) {
20948
+ const scroll = editor.closest("[data-input-scroll]");
20949
+ if (!scroll) return null;
20950
+ let anchor = editor.parentElement;
20951
+ while (anchor && anchor !== scroll && getComputedStyle(anchor).display === "contents") anchor = anchor.parentElement;
20952
+ return anchor && scroll.contains(anchor) ? anchor : null;
20953
+ }
20954
+ function ownStyle(element, property) {
20955
+ const read = () => ({
20956
+ value: element.style.getPropertyValue(property),
20957
+ priority: element.style.getPropertyPriority(property)
20958
+ });
20959
+ let previous = read();
20960
+ let applied = null;
20961
+ const same = (a, b) => a?.value === b?.value && a?.priority === b?.priority;
20962
+ return {
20963
+ set(value) {
20964
+ const current = read();
20965
+ if (applied && !same(current, applied)) previous = current;
20966
+ element.style.setProperty(property, value);
20967
+ applied = read();
20968
+ },
20969
+ restore() {
20970
+ if (applied && same(read(), applied)) if (previous.value) element.style.setProperty(property, previous.value, previous.priority);
20971
+ else element.style.removeProperty(property);
20972
+ applied = null;
20973
+ previous = read();
20974
+ }
20975
+ };
20976
+ }
20977
+ const textProperties = [
20978
+ "font-family",
20979
+ "font-size",
20980
+ "font-weight",
20981
+ "font-style",
20982
+ "font-stretch",
20983
+ "font-variant",
20984
+ "font-feature-settings",
20985
+ "font-variation-settings",
20986
+ "font-kerning",
20987
+ "line-height",
20988
+ "letter-spacing",
20989
+ "word-spacing",
20990
+ "text-indent",
20991
+ "text-align",
20992
+ "text-transform",
20993
+ "text-rendering",
20994
+ "white-space",
20995
+ "word-break",
20996
+ "overflow-wrap",
20997
+ "tab-size",
20998
+ "direction",
20999
+ "writing-mode",
21000
+ "padding-top",
21001
+ "padding-right",
21002
+ "padding-bottom",
21003
+ "padding-left",
21004
+ "border-top-width",
21005
+ "border-right-width",
21006
+ "border-bottom-width",
21007
+ "border-left-width"
21008
+ ];
21009
+ /** Own only presentation and reversible height reservation; never edit the draft. */
21010
+ function attachPredictionLayout(editor, anchor, layer, onAnchorChange) {
21011
+ const height = ownStyle(editor, "min-height");
21012
+ const position = ownStyle(anchor, "position");
21013
+ let frame = 0;
21014
+ let disposed = false;
21015
+ let reanchoring = false;
21016
+ const scroll = editor.closest("[data-input-scroll]");
21017
+ const initialScroll = scroll.scrollTop;
21018
+ const card = editor.closest("[data-composer-card]");
21019
+ const placeholders = /* @__PURE__ */ new Map();
21020
+ const resize = new ResizeObserver(schedule);
21021
+ const mutations = new MutationObserver(schedule);
21022
+ function restorePlaceholders() {
21023
+ for (const lease of placeholders.values()) lease.restore();
21024
+ placeholders.clear();
21025
+ }
21026
+ function layout() {
21027
+ frame = 0;
21028
+ if (disposed) return;
21029
+ if (!editor.isConnected || !layer.isConnected) {
21030
+ dispose();
21031
+ return;
21032
+ }
21033
+ const nextAnchor = predictionAnchor(editor);
21034
+ if (nextAnchor !== anchor) {
21035
+ reanchoring = true;
21036
+ layer.style.visibility = "hidden";
21037
+ mutations.takeRecords();
21038
+ onAnchorChange(nextAnchor);
21039
+ return;
21040
+ }
21041
+ const currentScroll = scroll.scrollTop;
21042
+ height.restore();
21043
+ position.restore();
21044
+ if (getComputedStyle(anchor).position === "static") position.set("relative");
21045
+ const style = getComputedStyle(editor);
21046
+ if (!editor.offsetWidth || editor.offsetParent !== anchor) {
21047
+ layer.style.visibility = "hidden";
21048
+ restorePlaceholders();
21049
+ mutations.takeRecords();
21050
+ return;
21051
+ }
21052
+ for (const property of textProperties) layer.style.setProperty(property, style.getPropertyValue(property));
21053
+ layer.style.setProperty("--codex-prediction-ink", style.color);
21054
+ layer.style.left = `${editor.offsetLeft}px`;
21055
+ layer.style.top = `${editor.offsetTop}px`;
21056
+ layer.style.width = `${editor.offsetWidth}px`;
21057
+ const minimum = predictionMinHeight(layer.offsetHeight, style);
21058
+ if (minimum !== null) height.set(`${Math.ceil(minimum)}px`);
21059
+ layer.style.visibility = "visible";
21060
+ scroll.scrollTop = currentScroll;
21061
+ for (const placeholder of card?.querySelectorAll("[data-composer-placeholder]") ?? []) {
21062
+ if (!placeholders.has(placeholder)) placeholders.set(placeholder, ownStyle(placeholder, "visibility"));
21063
+ placeholders.get(placeholder).set("hidden");
21064
+ }
21065
+ mutations.takeRecords();
21066
+ }
21067
+ function schedule() {
21068
+ if (!disposed && !frame) frame = requestAnimationFrame(layout);
21069
+ }
21070
+ function dispose() {
21071
+ if (disposed) return;
21072
+ disposed = true;
21073
+ cancelAnimationFrame(frame);
21074
+ resize.disconnect();
21075
+ mutations.disconnect();
21076
+ window.removeEventListener("resize", schedule);
21077
+ document.fonts?.removeEventListener("loadingdone", schedule);
21078
+ editor.removeEventListener("input", dispose);
21079
+ editor.removeEventListener("compositionstart", dispose);
21080
+ layer.style.visibility = "hidden";
21081
+ height.restore();
21082
+ position.restore();
21083
+ restorePlaceholders();
21084
+ if (!reanchoring) scroll.scrollTop = initialScroll;
21085
+ }
21086
+ resize.observe(layer);
21087
+ for (let element = editor; element; element = element.parentElement) {
21088
+ resize.observe(element);
21089
+ if (element === scroll) break;
21090
+ }
21091
+ for (let element = editor; element; element = element.parentElement) mutations.observe(element, { attributes: true });
21092
+ if (card) mutations.observe(card, {
21093
+ attributes: true,
21094
+ childList: true,
21095
+ subtree: true,
21096
+ attributeFilter: [
21097
+ "class",
21098
+ "style",
21099
+ "contenteditable"
21100
+ ]
21101
+ });
21102
+ window.addEventListener("resize", schedule);
21103
+ document.fonts?.addEventListener("loadingdone", schedule);
21104
+ editor.addEventListener("input", dispose);
21105
+ editor.addEventListener("compositionstart", dispose);
21106
+ layout();
21107
+ return dispose;
21108
+ }
21109
+ //#endregion
20939
21110
  //#region src/client-predictions.jsx
20940
21111
  const PREDICTION_CSS = `
20941
- .codex-composer-prediction{position:absolute;inset:16px 20px auto;z-index:1;display:flex;align-items:baseline;gap:10px;pointer-events:none;color:var(--dsw-alias-label-tertiary,#888);font:inherit;line-height:1.5;min-width:0}
20942
- .codex-composer-prediction>span{white-space:pre-wrap;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0}
20943
- .codex-composer-prediction button{pointer-events:auto;flex:none;border:0;border-radius:4px;background:var(--dsw-alias-bg-l2,transparent);color:inherit;font:inherit;font-size:11px;padding:1px 5px;cursor:pointer}
21112
+ .codex-composer-prediction{position:absolute;z-index:1;display:block;box-sizing:border-box;border-style:solid;border-color:transparent;pointer-events:none;user-select:none;color:color-mix(in srgb,var(--codex-prediction-ink,#888) 55%,transparent);visibility:hidden;min-width:0}
21113
+ .codex-composer-prediction>span{font:inherit;color:inherit}
21114
+ .codex-composer-prediction button{display:inline-block;pointer-events:auto;border:0;border-radius:4px;background:var(--dsw-alias-bg-l2,transparent);color:inherit;font:inherit;font-size:11px;line-height:1.4;padding:1px 5px;margin-inline-start:8px;vertical-align:baseline;white-space:nowrap;cursor:pointer}
20944
21115
  `;
20945
21116
  /** The disabled path owns neither DOM nor composer event listeners. */
20946
21117
  function ComposerPrediction(props) {
@@ -20956,6 +21127,10 @@ void main(){
20956
21127
  const controller = (0, react.useMemo)(() => createComposerPredictionController(rpc), [rpc]);
20957
21128
  const snapshot = (0, react.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
20958
21129
  const marker = (0, react.useRef)(null);
21130
+ const layer = (0, react.useRef)(null);
21131
+ const [target, setTarget] = (0, react.useState)(null);
21132
+ const card = target?.card;
21133
+ const editor = target?.editor;
20959
21134
  const current = (0, react.useRef)(null);
20960
21135
  const [focused, setFocused] = (0, react.useState)(false);
20961
21136
  const composing = (0, react.useRef)(false);
@@ -20979,11 +21154,51 @@ void main(){
20979
21154
  span: inputActions.captureInsertion()
20980
21155
  });
20981
21156
  const refresh = () => controller.update(environment());
20982
- const accept = () => controller.accept(inputActions, environment());
20983
- (0, react.useEffect)(() => {
21157
+ const accept = () => {
21158
+ const prediction = layer.current;
21159
+ const activeEditor = dom.current?.editor;
21160
+ if (!prediction?.isConnected || !activeEditor || activeEditor.offsetParent !== prediction.parentElement || !prediction.getClientRects().length || getComputedStyle(prediction).visibility !== "visible") return false;
21161
+ return controller.accept(inputActions, environment());
21162
+ };
21163
+ (0, react.useLayoutEffect)(() => {
20984
21164
  const card = marker.current?.closest("[data-composer-card]");
20985
- const editor = card?.querySelector("[data-composer-input][contenteditable=\"true\"]");
20986
- if (!editor) return;
21165
+ if (!card) return;
21166
+ const resolve = () => {
21167
+ const editor = card.querySelector("[data-composer-input][contenteditable=\"true\"]");
21168
+ const anchor = editor && predictionAnchor(editor);
21169
+ setTarget((previous) => previous?.editor === editor && previous?.anchor === anchor ? previous : anchor ? {
21170
+ card,
21171
+ editor,
21172
+ anchor
21173
+ } : null);
21174
+ };
21175
+ const observer = new MutationObserver(resolve);
21176
+ observer.observe(card, {
21177
+ childList: true,
21178
+ subtree: true,
21179
+ attributes: true,
21180
+ attributeFilter: ["contenteditable"]
21181
+ });
21182
+ resolve();
21183
+ return () => observer.disconnect();
21184
+ }, [sessionId]);
21185
+ (0, react.useLayoutEffect)(() => {
21186
+ if (!snapshot.prediction || !focused || !accountKey || !target?.anchor || !layer.current) return;
21187
+ const { editor, anchor } = target;
21188
+ return attachPredictionLayout(editor, anchor, layer.current, (nextAnchor) => {
21189
+ setTarget((previous) => previous?.editor === editor && previous.anchor === anchor ? {
21190
+ ...previous,
21191
+ anchor: nextAnchor
21192
+ } : previous);
21193
+ });
21194
+ }, [
21195
+ snapshot.prediction,
21196
+ focused,
21197
+ accountKey,
21198
+ target
21199
+ ]);
21200
+ (0, react.useEffect)(() => {
21201
+ if (!card || !editor) return;
20987
21202
  dom.current = {
20988
21203
  card,
20989
21204
  editor
@@ -21029,12 +21244,16 @@ void main(){
21029
21244
  document.removeEventListener("selectionchange", focus);
21030
21245
  document.removeEventListener("visibilitychange", focus);
21031
21246
  dom.current = null;
21247
+ composing.current = false;
21248
+ compositionUntil.current = 0;
21032
21249
  controller.cancel();
21033
21250
  };
21034
21251
  }, [
21035
21252
  controller,
21036
21253
  sessionId,
21037
- inputActions
21254
+ inputActions,
21255
+ card,
21256
+ editor
21038
21257
  ]);
21039
21258
  (0, react.useLayoutEffect)(() => {
21040
21259
  refresh();
@@ -21048,29 +21267,11 @@ void main(){
21048
21267
  focused
21049
21268
  ]);
21050
21269
  (0, react.useEffect)(() => () => controller.cancel(), [controller]);
21051
- (0, react.useLayoutEffect)(() => {
21052
- if (!snapshot.prediction || !focused) return;
21053
- const placeholder = marker.current?.closest("[data-composer-card]")?.querySelector("[data-composer-placeholder]");
21054
- if (!placeholder) return;
21055
- const visibility = placeholder.style.getPropertyValue("visibility");
21056
- const priority = placeholder.style.getPropertyPriority("visibility");
21057
- placeholder.style.setProperty("visibility", "hidden");
21058
- return () => {
21059
- if (placeholder.style.getPropertyValue("visibility") !== "hidden") return;
21060
- if (visibility) placeholder.style.setProperty("visibility", visibility, priority);
21061
- else placeholder.style.removeProperty("visibility");
21062
- };
21063
- }, [
21064
- snapshot.prediction,
21065
- focused,
21066
- sessionId
21067
- ]);
21068
- if (!snapshot.prediction || !focused || !accountKey) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
21270
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
21069
21271
  ref: marker,
21070
21272
  hidden: true
21071
- });
21072
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21073
- ref: marker,
21273
+ }), snapshot.prediction && focused && accountKey && target?.anchor && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21274
+ ref: layer,
21074
21275
  className: "codex-composer-prediction",
21075
21276
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
21076
21277
  "aria-hidden": "true",
@@ -21083,7 +21284,7 @@ void main(){
21083
21284
  onClick: accept,
21084
21285
  children: "Tab"
21085
21286
  })]
21086
- });
21287
+ }), target.anchor)] });
21087
21288
  }
21088
21289
  //#endregion
21089
21290
  //#region src/client.jsx
package/lib/index.js CHANGED
@@ -3136,7 +3136,8 @@ Object.freeze([
3136
3136
  "1.3.0",
3137
3137
  "1.4.0",
3138
3138
  "1.5.0",
3139
- "1.5.1"
3139
+ "1.5.1",
3140
+ "1.5.2"
3140
3141
  ]);
3141
3142
  //#endregion
3142
3143
  //#region src/reasoning-json.js
@@ -4751,7 +4752,7 @@ function inheritedOriginalImageRef(session, assetId) {
4751
4752
  }
4752
4753
  //#endregion
4753
4754
  //#region src/version.js
4754
- const PACKAGE_VERSION = "3.2.9";
4755
+ const PACKAGE_VERSION = "3.2.10";
4755
4756
  const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
4756
4757
  //#endregion
4757
4758
  //#region src/codex-images.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-subscription",
3
- "version": "3.2.9",
3
+ "version": "3.2.10",
4
4
  "description": "Use ChatGPT and Codex subscriptions in DeepSeek Harness with OAuth, quota, safe resets, web search, images and Fast mode, and control DSH from the ChatGPT mobile app (Beta)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -94,7 +94,7 @@
94
94
  "@deepseek-ai/dsh-tools": "0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-alpha.1 || 0.2.1-alpha.2 || 0.2.1-alpha.3 || 0.2.1-alpha.4 || 0.2.1-alpha.5 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-alpha.2 || 0.2.2-alpha.3 || 0.2.2-rc.1",
95
95
  "@deepseek-ai/dsh-web": "0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-alpha.1 || 0.2.1-alpha.2 || 0.2.1-alpha.3 || 0.2.1-alpha.4 || 0.2.1-alpha.5 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-alpha.2 || 0.2.2-alpha.3 || 0.2.2-rc.1",
96
96
  "@deepseek-ai/schemastery": "3.18.1 || ^3.18.2 || 3.18.6-alpha.1",
97
- "@earendil-works/pi-ai": "0.85.1 || 0.87.1 || 1.1.0 || 1.2.0 || 1.3.0 || 1.4.0 || 1.5.0 || 1.5.1",
97
+ "@earendil-works/pi-ai": "0.85.1 || 0.87.1 || 1.1.0 || 1.2.0 || 1.3.0 || 1.4.0 || 1.5.0 || 1.5.1 || 1.5.2",
98
98
  "react": "^18.2.0",
99
99
  "react-dom": "^18.2.0"
100
100
  },