@xmoon76/dsh-pi-tui 0.5.7 → 0.5.8
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/README.en.md +13 -11
- package/README.md +13 -11
- package/dist/{bootstrap-C9nl6e13.mjs → bootstrap-CMIjGyuk.mjs} +532 -416
- package/dist/builtins.mjs +2 -2
- package/dist/{client-bootstrap-CGezi85O.mjs → client-bootstrap-BjGPc-DM.mjs} +826 -3
- package/dist/{daemon-launcher-H_1r5Cqs.mjs → daemon-launcher-Dult7Jxv.mjs} +121 -4
- package/dist/daemon-launcher.mjs +1 -1
- package/dist/{entry-control-jBfKn1qO.mjs → entry-control-DjNsE3I0.mjs} +1 -1
- package/dist/{extensions-6a5vvJUT.mjs → extensions-B4uLpSTv.mjs} +1 -4
- package/dist/extensions.mjs +1 -1
- package/dist/{host-foundation-probe-DK7n5jDu.mjs → host-foundation-probe-DMNTmNrH.mjs} +1 -1
- package/dist/index.mjs +532 -298
- package/dist/{local-acp-listener-CNkguN5-.mjs → local-acp-listener-B65J0Bx4.mjs} +561 -12
- package/dist/local-client.mjs +442 -45
- package/dist/{local-daemon-control-Cu_4FIdd.mjs → local-daemon-control-C14q9KnD.mjs} +5 -2
- package/dist/{local-daemon-control-Bg9s2aYi.mjs → local-daemon-control-TCnERL7n.mjs} +3 -3
- package/dist/{local-discovery-Bq3jLAn1.mjs → local-discovery-DOSsCh9q.mjs} +1 -1
- package/dist/{local-discovery-BMoNXZjJ.mjs → local-discovery-egN4_gsQ.mjs} +1 -1
- package/dist/{local-discovery-BPZw1wEd.mjs → local-discovery-uOBfFq5j.mjs} +1 -1
- package/dist/local-host.mjs +24 -6
- package/dist/local-profile-daemon-admin-BmQSdzT0.mjs +210 -0
- package/dist/{local-scope-DEuGAy8l.mjs → local-scope-DamiMqPd.mjs} +118 -1
- package/dist/{local-transport-X4ZCe2uE.mjs → local-transport-Iwo0mtu3.mjs} +2 -2
- package/dist/{local-web-control-DKWtXIkr.mjs → local-web-control-DMrjwCkl.mjs} +2 -2
- package/dist/{session-DC0XQr5O.mjs → session-C6tSs86s.mjs} +2 -2
- package/dist/{session-Cihe8PPS.mjs → session-CstInGIA.mjs} +1 -1
- package/dist/{startup-CARqn3kV.mjs → startup-EG5UqIcd.mjs} +3 -3
- package/dist/startup.mjs +1 -1
- package/dist/{terminal-progress-source-D4DHyXDo.mjs → terminal-progress-source-CpfpQO_h.mjs} +3 -6
- package/dist/{transcript-view-hvNVkPtv.mjs → transcript-view-C1YtJ49Y.mjs} +191 -192
- package/dist/{transcript-view-a7cROAaI.mjs → transcript-view-CuJYWkhp.mjs} +190 -191
- package/package.json +6 -6
- package/dist/local-profile-daemon-admin-AXgVH-6y.mjs +0 -91
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as detachedSessionStatus, At as projectMcpServerEntry, B as remoteFailureMessage, Bt as readWebApiBilling, C as projectShellExecutionSettings, Ct as baseDictKeysOf, F as REMOTE_IMPLEMENTED_CAPABILITIES, Ft as assertSearchProviderId, G as isRemoteBusinessRefusalCode, H as remoteRejected, Ht as webProviderSelectionFactsOf, I as classifyRemoteWriteFailure, It as assertSearchProviderReplaceable, J as extensions_exports, K as ScheduleOutcomeUnknownError, L as copyFailureDetails, Lt as assertWebApiBilling, M as classifySubagentPromptSettlement, Mt as assertFetchProviderId, Nt as assertFetchProviderReplaceable, O as QuestionAnswerError, Pt as assertSearchApiCount, R as isRemoteCancellation, S as projectSessionLogUpload, St as CuaAccessUnavailableError, T as projectSubagentModelSelection, U as settledWriteMessage, V as remoteNotDispatched, Vt as webApiAdvancedFactsOf, W as GATEWAY_PRE_INVOCATION_CODES, Y as PI_TUI_EXTENSIONS_SERVICE, _t as clientOwnerOf, a as detachMcpProbeResult, an as providerOptionsFor, b as snapshotExtensionConfigOps, c as detachChange, cn as contextPressureOccupancy, d as detachPhase, dn as TUI_STARTUP_SERVICE, f as detachPluginManagerSnapshot, fn as __exportAll, g as pluginInstallRequestId, gt as WorkspaceSelectionError, h as detachPluginVersionList, i as PluginManagerStaleResultError, in as getPath, j as detachedTurnOutline, l as detachInspection, ln as bundleVersion, lt as normalizeModelSelection, m as detachPluginUpdateResult, mt as deliveredFileReadErrorFrom, n as createRemoteTerminalProgressSource, o as detachMcpServerRoster, on as providerProfileProjectionOf, p as detachPluginUpdateProgress, pt as DeliveredFileReadError, q as ScheduleUnavailableError, r as createClientExtensionMountOwner, s as hostDirectoryBrowseFailureOutcome, sn as SupersededReadError, u as detachLog, un as dshVersion, v as extensionConfigUserDataPresent, w as projectSubagentLimits, wt as classifyMcpServerProvenance, x as projectAgentLoopSettings, y as projectExtensionConfigData, z as remoteFailureCode } from "./terminal-progress-source-
|
|
1
|
+
import { A as detachedSessionStatus, At as projectMcpServerEntry, B as remoteFailureMessage, Bt as readWebApiBilling, C as projectShellExecutionSettings, Ct as baseDictKeysOf, F as REMOTE_IMPLEMENTED_CAPABILITIES, Ft as assertSearchProviderId, G as isRemoteBusinessRefusalCode, H as remoteRejected, Ht as webProviderSelectionFactsOf, I as classifyRemoteWriteFailure, It as assertSearchProviderReplaceable, J as extensions_exports, K as ScheduleOutcomeUnknownError, L as copyFailureDetails, Lt as assertWebApiBilling, M as classifySubagentPromptSettlement, Mt as assertFetchProviderId, Nt as assertFetchProviderReplaceable, O as QuestionAnswerError, Pt as assertSearchApiCount, R as isRemoteCancellation, S as projectSessionLogUpload, St as CuaAccessUnavailableError, T as projectSubagentModelSelection, U as settledWriteMessage, V as remoteNotDispatched, Vt as webApiAdvancedFactsOf, W as GATEWAY_PRE_INVOCATION_CODES, Y as PI_TUI_EXTENSIONS_SERVICE, _t as clientOwnerOf, a as detachMcpProbeResult, an as providerOptionsFor, b as snapshotExtensionConfigOps, c as detachChange, cn as contextPressureOccupancy, d as detachPhase, dn as TUI_STARTUP_SERVICE, f as detachPluginManagerSnapshot, fn as __exportAll, g as pluginInstallRequestId, gt as WorkspaceSelectionError, h as detachPluginVersionList, i as PluginManagerStaleResultError, in as getPath, j as detachedTurnOutline, l as detachInspection, ln as bundleVersion, lt as normalizeModelSelection, m as detachPluginUpdateResult, mt as deliveredFileReadErrorFrom, n as createRemoteTerminalProgressSource, o as detachMcpServerRoster, on as providerProfileProjectionOf, p as detachPluginUpdateProgress, pt as DeliveredFileReadError, q as ScheduleUnavailableError, r as createClientExtensionMountOwner, s as hostDirectoryBrowseFailureOutcome, sn as SupersededReadError, u as detachLog, un as dshVersion, v as extensionConfigUserDataPresent, w as projectSubagentLimits, wt as classifyMcpServerProvenance, x as projectAgentLoopSettings, y as projectExtensionConfigData, z as remoteFailureCode } from "./terminal-progress-source-CpfpQO_h.mjs";
|
|
2
2
|
import { i as runDetached, o as safeErrorMessage, t as cancellationError } from "./tasks-D_z5Yjjr.mjs";
|
|
3
3
|
import { t as mergeCause } from "./dispose-cause-CNFuUnjR.mjs";
|
|
4
4
|
import { a as resolveUserLayerFooterMode, i as resolveUserCommandItemFallbackActivationIds, n as resolveTrustedFooterCommand, r as resolveUserCommandItemActivationIds } from "./command-trust-DChWUamk.mjs";
|
|
@@ -12,7 +12,6 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
12
12
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
13
13
|
import { pathToFileURL } from "node:url";
|
|
14
14
|
import "@deepseek-ai/cordis";
|
|
15
|
-
import * as clientStore from "@deepseek-ai/dsh-client-store";
|
|
16
15
|
import commandsRemote from "@deepseek-ai/dsh-commands/remote";
|
|
17
16
|
import subagentsRemote from "@deepseek-ai/dsh-subagent/remote";
|
|
18
17
|
import agentPresetsRemote from "@deepseek-ai/dsh-agent-preset-registry/remote";
|
|
@@ -9554,6 +9553,827 @@ async function createRemoteApplicationRuntimeFromClient(options) {
|
|
|
9554
9553
|
};
|
|
9555
9554
|
}
|
|
9556
9555
|
//#endregion
|
|
9556
|
+
//#region node_modules/.pnpm/zustand@4.5.7_immer@10.2.0_react@18.3.1/node_modules/zustand/esm/vanilla.mjs
|
|
9557
|
+
const createStoreImpl = (createState) => {
|
|
9558
|
+
let state;
|
|
9559
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
9560
|
+
const setState = (partial, replace) => {
|
|
9561
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
9562
|
+
if (!Object.is(nextState, state)) {
|
|
9563
|
+
const previousState = state;
|
|
9564
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
9565
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
9566
|
+
}
|
|
9567
|
+
};
|
|
9568
|
+
const getState = () => state;
|
|
9569
|
+
const getInitialState = () => initialState;
|
|
9570
|
+
const subscribe = (listener) => {
|
|
9571
|
+
listeners.add(listener);
|
|
9572
|
+
return () => listeners.delete(listener);
|
|
9573
|
+
};
|
|
9574
|
+
const destroy = () => {
|
|
9575
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected.");
|
|
9576
|
+
listeners.clear();
|
|
9577
|
+
};
|
|
9578
|
+
const api = {
|
|
9579
|
+
setState,
|
|
9580
|
+
getState,
|
|
9581
|
+
getInitialState,
|
|
9582
|
+
subscribe,
|
|
9583
|
+
destroy
|
|
9584
|
+
};
|
|
9585
|
+
const initialState = state = createState(setState, getState, api);
|
|
9586
|
+
return api;
|
|
9587
|
+
};
|
|
9588
|
+
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
9589
|
+
//#endregion
|
|
9590
|
+
//#region node_modules/.pnpm/zustand@4.5.7_immer@10.2.0_react@18.3.1/node_modules/zustand/esm/middleware.mjs
|
|
9591
|
+
const subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
9592
|
+
const origSubscribe = api.subscribe;
|
|
9593
|
+
api.subscribe = (selector, optListener, options) => {
|
|
9594
|
+
let listener = selector;
|
|
9595
|
+
if (optListener) {
|
|
9596
|
+
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
|
9597
|
+
let currentSlice = selector(api.getState());
|
|
9598
|
+
listener = (state) => {
|
|
9599
|
+
const nextSlice = selector(state);
|
|
9600
|
+
if (!equalityFn(currentSlice, nextSlice)) {
|
|
9601
|
+
const previousSlice = currentSlice;
|
|
9602
|
+
optListener(currentSlice = nextSlice, previousSlice);
|
|
9603
|
+
}
|
|
9604
|
+
};
|
|
9605
|
+
if (options == null ? void 0 : options.fireImmediately) optListener(currentSlice, currentSlice);
|
|
9606
|
+
}
|
|
9607
|
+
return origSubscribe(listener);
|
|
9608
|
+
};
|
|
9609
|
+
return fn(set, get, api);
|
|
9610
|
+
};
|
|
9611
|
+
const subscribeWithSelector = subscribeWithSelectorImpl;
|
|
9612
|
+
//#endregion
|
|
9613
|
+
//#region node_modules/.pnpm/zustand@4.5.7_immer@10.2.0_react@18.3.1/node_modules/zustand/esm/shallow.mjs
|
|
9614
|
+
function shallow$1(objA, objB) {
|
|
9615
|
+
if (Object.is(objA, objB)) return true;
|
|
9616
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) return false;
|
|
9617
|
+
if (objA instanceof Map && objB instanceof Map) {
|
|
9618
|
+
if (objA.size !== objB.size) return false;
|
|
9619
|
+
for (const [key, value] of objA) if (!Object.is(value, objB.get(key))) return false;
|
|
9620
|
+
return true;
|
|
9621
|
+
}
|
|
9622
|
+
if (objA instanceof Set && objB instanceof Set) {
|
|
9623
|
+
if (objA.size !== objB.size) return false;
|
|
9624
|
+
for (const value of objA) if (!objB.has(value)) return false;
|
|
9625
|
+
return true;
|
|
9626
|
+
}
|
|
9627
|
+
const keysA = Object.keys(objA);
|
|
9628
|
+
if (keysA.length !== Object.keys(objB).length) return false;
|
|
9629
|
+
for (const keyA of keysA) if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) return false;
|
|
9630
|
+
return true;
|
|
9631
|
+
}
|
|
9632
|
+
//#endregion
|
|
9633
|
+
//#region node_modules/.pnpm/immer@10.2.0/node_modules/immer/dist/immer.mjs
|
|
9634
|
+
var NOTHING = Symbol.for("immer-nothing");
|
|
9635
|
+
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
9636
|
+
var DRAFT_STATE = Symbol.for("immer-state");
|
|
9637
|
+
var errors = process.env.NODE_ENV !== "production" ? [
|
|
9638
|
+
function(plugin) {
|
|
9639
|
+
return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
|
|
9640
|
+
},
|
|
9641
|
+
function(thing) {
|
|
9642
|
+
return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
|
|
9643
|
+
},
|
|
9644
|
+
"This object has been frozen and should not be mutated",
|
|
9645
|
+
function(data) {
|
|
9646
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
|
|
9647
|
+
},
|
|
9648
|
+
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
9649
|
+
"Immer forbids circular references",
|
|
9650
|
+
"The first or second argument to `produce` must be a function",
|
|
9651
|
+
"The third argument to `produce` must be a function or undefined",
|
|
9652
|
+
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
9653
|
+
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
9654
|
+
function(thing) {
|
|
9655
|
+
return `'current' expects a draft, got: ${thing}`;
|
|
9656
|
+
},
|
|
9657
|
+
"Object.defineProperty() cannot be used on an Immer draft",
|
|
9658
|
+
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
9659
|
+
"Immer only supports deleting array indices",
|
|
9660
|
+
"Immer only supports setting array indices and the 'length' property",
|
|
9661
|
+
function(thing) {
|
|
9662
|
+
return `'original' expects a draft, got: ${thing}`;
|
|
9663
|
+
}
|
|
9664
|
+
] : [];
|
|
9665
|
+
function die(error, ...args) {
|
|
9666
|
+
if (process.env.NODE_ENV !== "production") {
|
|
9667
|
+
const e = errors[error];
|
|
9668
|
+
const msg = typeof e === "function" ? e.apply(null, args) : e;
|
|
9669
|
+
throw new Error(`[Immer] ${msg}`);
|
|
9670
|
+
}
|
|
9671
|
+
throw new Error(`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`);
|
|
9672
|
+
}
|
|
9673
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
9674
|
+
function isDraft(value) {
|
|
9675
|
+
return !!value && !!value[DRAFT_STATE];
|
|
9676
|
+
}
|
|
9677
|
+
function isDraftable(value) {
|
|
9678
|
+
if (!value) return false;
|
|
9679
|
+
return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
|
|
9680
|
+
}
|
|
9681
|
+
var objectCtorString = Object.prototype.constructor.toString();
|
|
9682
|
+
var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
9683
|
+
function isPlainObject(value) {
|
|
9684
|
+
if (!value || typeof value !== "object") return false;
|
|
9685
|
+
const proto = Object.getPrototypeOf(value);
|
|
9686
|
+
if (proto === null || proto === Object.prototype) return true;
|
|
9687
|
+
const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
9688
|
+
if (Ctor === Object) return true;
|
|
9689
|
+
if (typeof Ctor !== "function") return false;
|
|
9690
|
+
let ctorString = cachedCtorStrings.get(Ctor);
|
|
9691
|
+
if (ctorString === void 0) {
|
|
9692
|
+
ctorString = Function.toString.call(Ctor);
|
|
9693
|
+
cachedCtorStrings.set(Ctor, ctorString);
|
|
9694
|
+
}
|
|
9695
|
+
return ctorString === objectCtorString;
|
|
9696
|
+
}
|
|
9697
|
+
function each(obj, iter, strict = true) {
|
|
9698
|
+
if (getArchtype(obj) === 0) (strict ? Reflect.ownKeys(obj) : Object.keys(obj)).forEach((key) => {
|
|
9699
|
+
iter(key, obj[key], obj);
|
|
9700
|
+
});
|
|
9701
|
+
else obj.forEach((entry, index) => iter(index, entry, obj));
|
|
9702
|
+
}
|
|
9703
|
+
function getArchtype(thing) {
|
|
9704
|
+
const state = thing[DRAFT_STATE];
|
|
9705
|
+
return state ? state.type_ : Array.isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
|
|
9706
|
+
}
|
|
9707
|
+
function has(thing, prop) {
|
|
9708
|
+
return getArchtype(thing) === 2 ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
|
|
9709
|
+
}
|
|
9710
|
+
function set(thing, propOrOldValue, value) {
|
|
9711
|
+
const t = getArchtype(thing);
|
|
9712
|
+
if (t === 2) thing.set(propOrOldValue, value);
|
|
9713
|
+
else if (t === 3) thing.add(value);
|
|
9714
|
+
else thing[propOrOldValue] = value;
|
|
9715
|
+
}
|
|
9716
|
+
function is(x, y) {
|
|
9717
|
+
if (x === y) return x !== 0 || 1 / x === 1 / y;
|
|
9718
|
+
else return x !== x && y !== y;
|
|
9719
|
+
}
|
|
9720
|
+
function isMap(target) {
|
|
9721
|
+
return target instanceof Map;
|
|
9722
|
+
}
|
|
9723
|
+
function isSet(target) {
|
|
9724
|
+
return target instanceof Set;
|
|
9725
|
+
}
|
|
9726
|
+
function latest(state) {
|
|
9727
|
+
return state.copy_ || state.base_;
|
|
9728
|
+
}
|
|
9729
|
+
function shallowCopy(base, strict) {
|
|
9730
|
+
if (isMap(base)) return new Map(base);
|
|
9731
|
+
if (isSet(base)) return new Set(base);
|
|
9732
|
+
if (Array.isArray(base)) return Array.prototype.slice.call(base);
|
|
9733
|
+
const isPlain = isPlainObject(base);
|
|
9734
|
+
if (strict === true || strict === "class_only" && !isPlain) {
|
|
9735
|
+
const descriptors = Object.getOwnPropertyDescriptors(base);
|
|
9736
|
+
delete descriptors[DRAFT_STATE];
|
|
9737
|
+
let keys = Reflect.ownKeys(descriptors);
|
|
9738
|
+
for (let i = 0; i < keys.length; i++) {
|
|
9739
|
+
const key = keys[i];
|
|
9740
|
+
const desc = descriptors[key];
|
|
9741
|
+
if (desc.writable === false) {
|
|
9742
|
+
desc.writable = true;
|
|
9743
|
+
desc.configurable = true;
|
|
9744
|
+
}
|
|
9745
|
+
if (desc.get || desc.set) descriptors[key] = {
|
|
9746
|
+
configurable: true,
|
|
9747
|
+
writable: true,
|
|
9748
|
+
enumerable: desc.enumerable,
|
|
9749
|
+
value: base[key]
|
|
9750
|
+
};
|
|
9751
|
+
}
|
|
9752
|
+
return Object.create(getPrototypeOf(base), descriptors);
|
|
9753
|
+
} else {
|
|
9754
|
+
const proto = getPrototypeOf(base);
|
|
9755
|
+
if (proto !== null && isPlain) return { ...base };
|
|
9756
|
+
const obj = Object.create(proto);
|
|
9757
|
+
return Object.assign(obj, base);
|
|
9758
|
+
}
|
|
9759
|
+
}
|
|
9760
|
+
function freeze(obj, deep = false) {
|
|
9761
|
+
if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj;
|
|
9762
|
+
if (getArchtype(obj) > 1) Object.defineProperties(obj, {
|
|
9763
|
+
set: dontMutateMethodOverride,
|
|
9764
|
+
add: dontMutateMethodOverride,
|
|
9765
|
+
clear: dontMutateMethodOverride,
|
|
9766
|
+
delete: dontMutateMethodOverride
|
|
9767
|
+
});
|
|
9768
|
+
Object.freeze(obj);
|
|
9769
|
+
if (deep) Object.values(obj).forEach((value) => freeze(value, true));
|
|
9770
|
+
return obj;
|
|
9771
|
+
}
|
|
9772
|
+
function dontMutateFrozenCollections() {
|
|
9773
|
+
die(2);
|
|
9774
|
+
}
|
|
9775
|
+
var dontMutateMethodOverride = { value: dontMutateFrozenCollections };
|
|
9776
|
+
function isFrozen(obj) {
|
|
9777
|
+
if (obj === null || typeof obj !== "object") return true;
|
|
9778
|
+
return Object.isFrozen(obj);
|
|
9779
|
+
}
|
|
9780
|
+
var plugins = {};
|
|
9781
|
+
function getPlugin(pluginKey) {
|
|
9782
|
+
const plugin = plugins[pluginKey];
|
|
9783
|
+
if (!plugin) die(0, pluginKey);
|
|
9784
|
+
return plugin;
|
|
9785
|
+
}
|
|
9786
|
+
var currentScope;
|
|
9787
|
+
function getCurrentScope() {
|
|
9788
|
+
return currentScope;
|
|
9789
|
+
}
|
|
9790
|
+
function createScope(parent_, immer_) {
|
|
9791
|
+
return {
|
|
9792
|
+
drafts_: [],
|
|
9793
|
+
parent_,
|
|
9794
|
+
immer_,
|
|
9795
|
+
canAutoFreeze_: true,
|
|
9796
|
+
unfinalizedDrafts_: 0
|
|
9797
|
+
};
|
|
9798
|
+
}
|
|
9799
|
+
function usePatchesInScope(scope, patchListener) {
|
|
9800
|
+
if (patchListener) {
|
|
9801
|
+
getPlugin("Patches");
|
|
9802
|
+
scope.patches_ = [];
|
|
9803
|
+
scope.inversePatches_ = [];
|
|
9804
|
+
scope.patchListener_ = patchListener;
|
|
9805
|
+
}
|
|
9806
|
+
}
|
|
9807
|
+
function revokeScope(scope) {
|
|
9808
|
+
leaveScope(scope);
|
|
9809
|
+
scope.drafts_.forEach(revokeDraft);
|
|
9810
|
+
scope.drafts_ = null;
|
|
9811
|
+
}
|
|
9812
|
+
function leaveScope(scope) {
|
|
9813
|
+
if (scope === currentScope) currentScope = scope.parent_;
|
|
9814
|
+
}
|
|
9815
|
+
function enterScope(immer2) {
|
|
9816
|
+
return currentScope = createScope(currentScope, immer2);
|
|
9817
|
+
}
|
|
9818
|
+
function revokeDraft(draft) {
|
|
9819
|
+
const state = draft[DRAFT_STATE];
|
|
9820
|
+
if (state.type_ === 0 || state.type_ === 1) state.revoke_();
|
|
9821
|
+
else state.revoked_ = true;
|
|
9822
|
+
}
|
|
9823
|
+
function processResult(result, scope) {
|
|
9824
|
+
scope.unfinalizedDrafts_ = scope.drafts_.length;
|
|
9825
|
+
const baseDraft = scope.drafts_[0];
|
|
9826
|
+
if (result !== void 0 && result !== baseDraft) {
|
|
9827
|
+
if (baseDraft[DRAFT_STATE].modified_) {
|
|
9828
|
+
revokeScope(scope);
|
|
9829
|
+
die(4);
|
|
9830
|
+
}
|
|
9831
|
+
if (isDraftable(result)) {
|
|
9832
|
+
result = finalize(scope, result);
|
|
9833
|
+
if (!scope.parent_) maybeFreeze(scope, result);
|
|
9834
|
+
}
|
|
9835
|
+
if (scope.patches_) getPlugin("Patches").generateReplacementPatches_(baseDraft[DRAFT_STATE].base_, result, scope.patches_, scope.inversePatches_);
|
|
9836
|
+
} else result = finalize(scope, baseDraft, []);
|
|
9837
|
+
revokeScope(scope);
|
|
9838
|
+
if (scope.patches_) scope.patchListener_(scope.patches_, scope.inversePatches_);
|
|
9839
|
+
return result !== NOTHING ? result : void 0;
|
|
9840
|
+
}
|
|
9841
|
+
function finalize(rootScope, value, path) {
|
|
9842
|
+
if (isFrozen(value)) return value;
|
|
9843
|
+
const useStrictIteration = rootScope.immer_.shouldUseStrictIteration();
|
|
9844
|
+
const state = value[DRAFT_STATE];
|
|
9845
|
+
if (!state) {
|
|
9846
|
+
each(value, (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path), useStrictIteration);
|
|
9847
|
+
return value;
|
|
9848
|
+
}
|
|
9849
|
+
if (state.scope_ !== rootScope) return value;
|
|
9850
|
+
if (!state.modified_) {
|
|
9851
|
+
maybeFreeze(rootScope, state.base_, true);
|
|
9852
|
+
return state.base_;
|
|
9853
|
+
}
|
|
9854
|
+
if (!state.finalized_) {
|
|
9855
|
+
state.finalized_ = true;
|
|
9856
|
+
state.scope_.unfinalizedDrafts_--;
|
|
9857
|
+
const result = state.copy_;
|
|
9858
|
+
let resultEach = result;
|
|
9859
|
+
let isSet2 = false;
|
|
9860
|
+
if (state.type_ === 3) {
|
|
9861
|
+
resultEach = new Set(result);
|
|
9862
|
+
result.clear();
|
|
9863
|
+
isSet2 = true;
|
|
9864
|
+
}
|
|
9865
|
+
each(resultEach, (key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path, isSet2), useStrictIteration);
|
|
9866
|
+
maybeFreeze(rootScope, result, false);
|
|
9867
|
+
if (path && rootScope.patches_) getPlugin("Patches").generatePatches_(state, path, rootScope.patches_, rootScope.inversePatches_);
|
|
9868
|
+
}
|
|
9869
|
+
return state.copy_;
|
|
9870
|
+
}
|
|
9871
|
+
function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
|
|
9872
|
+
if (childValue == null) return;
|
|
9873
|
+
if (typeof childValue !== "object" && !targetIsSet) return;
|
|
9874
|
+
const childIsFrozen = isFrozen(childValue);
|
|
9875
|
+
if (childIsFrozen && !targetIsSet) return;
|
|
9876
|
+
if (process.env.NODE_ENV !== "production" && childValue === targetObject) die(5);
|
|
9877
|
+
if (isDraft(childValue)) {
|
|
9878
|
+
const res = finalize(rootScope, childValue, rootPath && parentState && parentState.type_ !== 3 && !has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0);
|
|
9879
|
+
set(targetObject, prop, res);
|
|
9880
|
+
if (isDraft(res)) rootScope.canAutoFreeze_ = false;
|
|
9881
|
+
else return;
|
|
9882
|
+
} else if (targetIsSet) targetObject.add(childValue);
|
|
9883
|
+
if (isDraftable(childValue) && !childIsFrozen) {
|
|
9884
|
+
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) return;
|
|
9885
|
+
if (parentState && parentState.base_ && parentState.base_[prop] === childValue && childIsFrozen) return;
|
|
9886
|
+
finalize(rootScope, childValue);
|
|
9887
|
+
if ((!parentState || !parentState.scope_.parent_) && typeof prop !== "symbol" && (isMap(targetObject) ? targetObject.has(prop) : Object.prototype.propertyIsEnumerable.call(targetObject, prop))) maybeFreeze(rootScope, childValue);
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9890
|
+
function maybeFreeze(scope, value, deep = false) {
|
|
9891
|
+
if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) freeze(value, deep);
|
|
9892
|
+
}
|
|
9893
|
+
function createProxyProxy(base, parent) {
|
|
9894
|
+
const isArray = Array.isArray(base);
|
|
9895
|
+
const state = {
|
|
9896
|
+
type_: isArray ? 1 : 0,
|
|
9897
|
+
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
9898
|
+
modified_: false,
|
|
9899
|
+
finalized_: false,
|
|
9900
|
+
assigned_: {},
|
|
9901
|
+
parent_: parent,
|
|
9902
|
+
base_: base,
|
|
9903
|
+
draft_: null,
|
|
9904
|
+
copy_: null,
|
|
9905
|
+
revoke_: null,
|
|
9906
|
+
isManual_: false
|
|
9907
|
+
};
|
|
9908
|
+
let target = state;
|
|
9909
|
+
let traps = objectTraps;
|
|
9910
|
+
if (isArray) {
|
|
9911
|
+
target = [state];
|
|
9912
|
+
traps = arrayTraps;
|
|
9913
|
+
}
|
|
9914
|
+
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
9915
|
+
state.draft_ = proxy;
|
|
9916
|
+
state.revoke_ = revoke;
|
|
9917
|
+
return proxy;
|
|
9918
|
+
}
|
|
9919
|
+
var objectTraps = {
|
|
9920
|
+
get(state, prop) {
|
|
9921
|
+
if (prop === DRAFT_STATE) return state;
|
|
9922
|
+
const source = latest(state);
|
|
9923
|
+
if (!has(source, prop)) return readPropFromProto(state, source, prop);
|
|
9924
|
+
const value = source[prop];
|
|
9925
|
+
if (state.finalized_ || !isDraftable(value)) return value;
|
|
9926
|
+
if (value === peek(state.base_, prop)) {
|
|
9927
|
+
prepareCopy(state);
|
|
9928
|
+
return state.copy_[prop] = createProxy(value, state);
|
|
9929
|
+
}
|
|
9930
|
+
return value;
|
|
9931
|
+
},
|
|
9932
|
+
has(state, prop) {
|
|
9933
|
+
return prop in latest(state);
|
|
9934
|
+
},
|
|
9935
|
+
ownKeys(state) {
|
|
9936
|
+
return Reflect.ownKeys(latest(state));
|
|
9937
|
+
},
|
|
9938
|
+
set(state, prop, value) {
|
|
9939
|
+
const desc = getDescriptorFromProto(latest(state), prop);
|
|
9940
|
+
if (desc?.set) {
|
|
9941
|
+
desc.set.call(state.draft_, value);
|
|
9942
|
+
return true;
|
|
9943
|
+
}
|
|
9944
|
+
if (!state.modified_) {
|
|
9945
|
+
const current2 = peek(latest(state), prop);
|
|
9946
|
+
const currentState = current2?.[DRAFT_STATE];
|
|
9947
|
+
if (currentState && currentState.base_ === value) {
|
|
9948
|
+
state.copy_[prop] = value;
|
|
9949
|
+
state.assigned_[prop] = false;
|
|
9950
|
+
return true;
|
|
9951
|
+
}
|
|
9952
|
+
if (is(value, current2) && (value !== void 0 || has(state.base_, prop))) return true;
|
|
9953
|
+
prepareCopy(state);
|
|
9954
|
+
markChanged(state);
|
|
9955
|
+
}
|
|
9956
|
+
if (state.copy_[prop] === value && (value !== void 0 || prop in state.copy_) || Number.isNaN(value) && Number.isNaN(state.copy_[prop])) return true;
|
|
9957
|
+
state.copy_[prop] = value;
|
|
9958
|
+
state.assigned_[prop] = true;
|
|
9959
|
+
return true;
|
|
9960
|
+
},
|
|
9961
|
+
deleteProperty(state, prop) {
|
|
9962
|
+
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
9963
|
+
state.assigned_[prop] = false;
|
|
9964
|
+
prepareCopy(state);
|
|
9965
|
+
markChanged(state);
|
|
9966
|
+
} else delete state.assigned_[prop];
|
|
9967
|
+
if (state.copy_) delete state.copy_[prop];
|
|
9968
|
+
return true;
|
|
9969
|
+
},
|
|
9970
|
+
getOwnPropertyDescriptor(state, prop) {
|
|
9971
|
+
const owner = latest(state);
|
|
9972
|
+
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
9973
|
+
if (!desc) return desc;
|
|
9974
|
+
return {
|
|
9975
|
+
writable: true,
|
|
9976
|
+
configurable: state.type_ !== 1 || prop !== "length",
|
|
9977
|
+
enumerable: desc.enumerable,
|
|
9978
|
+
value: owner[prop]
|
|
9979
|
+
};
|
|
9980
|
+
},
|
|
9981
|
+
defineProperty() {
|
|
9982
|
+
die(11);
|
|
9983
|
+
},
|
|
9984
|
+
getPrototypeOf(state) {
|
|
9985
|
+
return getPrototypeOf(state.base_);
|
|
9986
|
+
},
|
|
9987
|
+
setPrototypeOf() {
|
|
9988
|
+
die(12);
|
|
9989
|
+
}
|
|
9990
|
+
};
|
|
9991
|
+
var arrayTraps = {};
|
|
9992
|
+
each(objectTraps, (key, fn) => {
|
|
9993
|
+
arrayTraps[key] = function() {
|
|
9994
|
+
arguments[0] = arguments[0][0];
|
|
9995
|
+
return fn.apply(this, arguments);
|
|
9996
|
+
};
|
|
9997
|
+
});
|
|
9998
|
+
arrayTraps.deleteProperty = function(state, prop) {
|
|
9999
|
+
if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop))) die(13);
|
|
10000
|
+
return arrayTraps.set.call(this, state, prop, void 0);
|
|
10001
|
+
};
|
|
10002
|
+
arrayTraps.set = function(state, prop, value) {
|
|
10003
|
+
if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop))) die(14);
|
|
10004
|
+
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
10005
|
+
};
|
|
10006
|
+
function peek(draft, prop) {
|
|
10007
|
+
const state = draft[DRAFT_STATE];
|
|
10008
|
+
return (state ? latest(state) : draft)[prop];
|
|
10009
|
+
}
|
|
10010
|
+
function readPropFromProto(state, source, prop) {
|
|
10011
|
+
const desc = getDescriptorFromProto(source, prop);
|
|
10012
|
+
return desc ? `value` in desc ? desc.value : desc.get?.call(state.draft_) : void 0;
|
|
10013
|
+
}
|
|
10014
|
+
function getDescriptorFromProto(source, prop) {
|
|
10015
|
+
if (!(prop in source)) return void 0;
|
|
10016
|
+
let proto = getPrototypeOf(source);
|
|
10017
|
+
while (proto) {
|
|
10018
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
10019
|
+
if (desc) return desc;
|
|
10020
|
+
proto = getPrototypeOf(proto);
|
|
10021
|
+
}
|
|
10022
|
+
}
|
|
10023
|
+
function markChanged(state) {
|
|
10024
|
+
if (!state.modified_) {
|
|
10025
|
+
state.modified_ = true;
|
|
10026
|
+
if (state.parent_) markChanged(state.parent_);
|
|
10027
|
+
}
|
|
10028
|
+
}
|
|
10029
|
+
function prepareCopy(state) {
|
|
10030
|
+
if (!state.copy_) state.copy_ = shallowCopy(state.base_, state.scope_.immer_.useStrictShallowCopy_);
|
|
10031
|
+
}
|
|
10032
|
+
var Immer2 = class {
|
|
10033
|
+
constructor(config) {
|
|
10034
|
+
this.autoFreeze_ = true;
|
|
10035
|
+
this.useStrictShallowCopy_ = false;
|
|
10036
|
+
this.useStrictIteration_ = true;
|
|
10037
|
+
/**
|
|
10038
|
+
* The `produce` function takes a value and a "recipe function" (whose
|
|
10039
|
+
* return value often depends on the base state). The recipe function is
|
|
10040
|
+
* free to mutate its first argument however it wants. All mutations are
|
|
10041
|
+
* only ever applied to a __copy__ of the base state.
|
|
10042
|
+
*
|
|
10043
|
+
* Pass only a function to create a "curried producer" which relieves you
|
|
10044
|
+
* from passing the recipe function every time.
|
|
10045
|
+
*
|
|
10046
|
+
* Only plain objects and arrays are made mutable. All other objects are
|
|
10047
|
+
* considered uncopyable.
|
|
10048
|
+
*
|
|
10049
|
+
* Note: This function is __bound__ to its `Immer` instance.
|
|
10050
|
+
*
|
|
10051
|
+
* @param {any} base - the initial state
|
|
10052
|
+
* @param {Function} recipe - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
10053
|
+
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
10054
|
+
* @returns {any} a new state, or the initial state if nothing was modified
|
|
10055
|
+
*/
|
|
10056
|
+
this.produce = (base, recipe, patchListener) => {
|
|
10057
|
+
if (typeof base === "function" && typeof recipe !== "function") {
|
|
10058
|
+
const defaultBase = recipe;
|
|
10059
|
+
recipe = base;
|
|
10060
|
+
const self = this;
|
|
10061
|
+
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
10062
|
+
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
10063
|
+
};
|
|
10064
|
+
}
|
|
10065
|
+
if (typeof recipe !== "function") die(6);
|
|
10066
|
+
if (patchListener !== void 0 && typeof patchListener !== "function") die(7);
|
|
10067
|
+
let result;
|
|
10068
|
+
if (isDraftable(base)) {
|
|
10069
|
+
const scope = enterScope(this);
|
|
10070
|
+
const proxy = createProxy(base, void 0);
|
|
10071
|
+
let hasError = true;
|
|
10072
|
+
try {
|
|
10073
|
+
result = recipe(proxy);
|
|
10074
|
+
hasError = false;
|
|
10075
|
+
} finally {
|
|
10076
|
+
if (hasError) revokeScope(scope);
|
|
10077
|
+
else leaveScope(scope);
|
|
10078
|
+
}
|
|
10079
|
+
usePatchesInScope(scope, patchListener);
|
|
10080
|
+
return processResult(result, scope);
|
|
10081
|
+
} else if (!base || typeof base !== "object") {
|
|
10082
|
+
result = recipe(base);
|
|
10083
|
+
if (result === void 0) result = base;
|
|
10084
|
+
if (result === NOTHING) result = void 0;
|
|
10085
|
+
if (this.autoFreeze_) freeze(result, true);
|
|
10086
|
+
if (patchListener) {
|
|
10087
|
+
const p = [];
|
|
10088
|
+
const ip = [];
|
|
10089
|
+
getPlugin("Patches").generateReplacementPatches_(base, result, p, ip);
|
|
10090
|
+
patchListener(p, ip);
|
|
10091
|
+
}
|
|
10092
|
+
return result;
|
|
10093
|
+
} else die(1, base);
|
|
10094
|
+
};
|
|
10095
|
+
this.produceWithPatches = (base, recipe) => {
|
|
10096
|
+
if (typeof base === "function") return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
10097
|
+
let patches, inversePatches;
|
|
10098
|
+
return [
|
|
10099
|
+
this.produce(base, recipe, (p, ip) => {
|
|
10100
|
+
patches = p;
|
|
10101
|
+
inversePatches = ip;
|
|
10102
|
+
}),
|
|
10103
|
+
patches,
|
|
10104
|
+
inversePatches
|
|
10105
|
+
];
|
|
10106
|
+
};
|
|
10107
|
+
if (typeof config?.autoFreeze === "boolean") this.setAutoFreeze(config.autoFreeze);
|
|
10108
|
+
if (typeof config?.useStrictShallowCopy === "boolean") this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
10109
|
+
if (typeof config?.useStrictIteration === "boolean") this.setUseStrictIteration(config.useStrictIteration);
|
|
10110
|
+
}
|
|
10111
|
+
createDraft(base) {
|
|
10112
|
+
if (!isDraftable(base)) die(8);
|
|
10113
|
+
if (isDraft(base)) base = current(base);
|
|
10114
|
+
const scope = enterScope(this);
|
|
10115
|
+
const proxy = createProxy(base, void 0);
|
|
10116
|
+
proxy[DRAFT_STATE].isManual_ = true;
|
|
10117
|
+
leaveScope(scope);
|
|
10118
|
+
return proxy;
|
|
10119
|
+
}
|
|
10120
|
+
finishDraft(draft, patchListener) {
|
|
10121
|
+
const state = draft && draft[DRAFT_STATE];
|
|
10122
|
+
if (!state || !state.isManual_) die(9);
|
|
10123
|
+
const { scope_: scope } = state;
|
|
10124
|
+
usePatchesInScope(scope, patchListener);
|
|
10125
|
+
return processResult(void 0, scope);
|
|
10126
|
+
}
|
|
10127
|
+
/**
|
|
10128
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
10129
|
+
*
|
|
10130
|
+
* By default, auto-freezing is enabled.
|
|
10131
|
+
*/
|
|
10132
|
+
setAutoFreeze(value) {
|
|
10133
|
+
this.autoFreeze_ = value;
|
|
10134
|
+
}
|
|
10135
|
+
/**
|
|
10136
|
+
* Pass true to enable strict shallow copy.
|
|
10137
|
+
*
|
|
10138
|
+
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
10139
|
+
*/
|
|
10140
|
+
setUseStrictShallowCopy(value) {
|
|
10141
|
+
this.useStrictShallowCopy_ = value;
|
|
10142
|
+
}
|
|
10143
|
+
/**
|
|
10144
|
+
* Pass false to use faster iteration that skips non-enumerable properties
|
|
10145
|
+
* but still handles symbols for compatibility.
|
|
10146
|
+
*
|
|
10147
|
+
* By default, strict iteration is enabled (includes all own properties).
|
|
10148
|
+
*/
|
|
10149
|
+
setUseStrictIteration(value) {
|
|
10150
|
+
this.useStrictIteration_ = value;
|
|
10151
|
+
}
|
|
10152
|
+
shouldUseStrictIteration() {
|
|
10153
|
+
return this.useStrictIteration_;
|
|
10154
|
+
}
|
|
10155
|
+
applyPatches(base, patches) {
|
|
10156
|
+
let i;
|
|
10157
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
10158
|
+
const patch = patches[i];
|
|
10159
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
10160
|
+
base = patch.value;
|
|
10161
|
+
break;
|
|
10162
|
+
}
|
|
10163
|
+
}
|
|
10164
|
+
if (i > -1) patches = patches.slice(i + 1);
|
|
10165
|
+
const applyPatchesImpl = getPlugin("Patches").applyPatches_;
|
|
10166
|
+
if (isDraft(base)) return applyPatchesImpl(base, patches);
|
|
10167
|
+
return this.produce(base, (draft) => applyPatchesImpl(draft, patches));
|
|
10168
|
+
}
|
|
10169
|
+
};
|
|
10170
|
+
function createProxy(value, parent) {
|
|
10171
|
+
const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
|
|
10172
|
+
(parent ? parent.scope_ : getCurrentScope()).drafts_.push(draft);
|
|
10173
|
+
return draft;
|
|
10174
|
+
}
|
|
10175
|
+
function current(value) {
|
|
10176
|
+
if (!isDraft(value)) die(10, value);
|
|
10177
|
+
return currentImpl(value);
|
|
10178
|
+
}
|
|
10179
|
+
function currentImpl(value) {
|
|
10180
|
+
if (!isDraftable(value) || isFrozen(value)) return value;
|
|
10181
|
+
const state = value[DRAFT_STATE];
|
|
10182
|
+
let copy;
|
|
10183
|
+
let strict = true;
|
|
10184
|
+
if (state) {
|
|
10185
|
+
if (!state.modified_) return state.base_;
|
|
10186
|
+
state.finalized_ = true;
|
|
10187
|
+
copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
10188
|
+
strict = state.scope_.immer_.shouldUseStrictIteration();
|
|
10189
|
+
} else copy = shallowCopy(value, true);
|
|
10190
|
+
each(copy, (key, childValue) => {
|
|
10191
|
+
set(copy, key, currentImpl(childValue));
|
|
10192
|
+
}, strict);
|
|
10193
|
+
if (state) state.finalized_ = false;
|
|
10194
|
+
return copy;
|
|
10195
|
+
}
|
|
10196
|
+
var produce = new Immer2().produce;
|
|
10197
|
+
//#endregion
|
|
10198
|
+
//#region node_modules/.pnpm/@deepseek-ai+dsh-client-store@0.2.2-rc.5_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-client-store/lib/index.js
|
|
10199
|
+
var lib_exports = /* @__PURE__ */ __exportAll({
|
|
10200
|
+
createSnapshotStore: () => createSnapshotStore,
|
|
10201
|
+
defineStore: () => defineStore,
|
|
10202
|
+
notifySubscribers: () => notifySubscribers,
|
|
10203
|
+
shallowEqual: () => shallowEqual
|
|
10204
|
+
});
|
|
10205
|
+
/**
|
|
10206
|
+
* React-free snapshot store engine (zustand vanilla + immer + subscribeWithSelector +
|
|
10207
|
+
* rafFlush middleware + opt-in persist + dev freeze) plus the declarative
|
|
10208
|
+
* shell over it: {@link defineStore} bakes an init/persist/actions literal
|
|
10209
|
+
* into a {@link StoreHandle}, the registration-side store seat of slot
|
|
10210
|
+
* terminals. Engine products are bare observables — subscribe/getSnapshot/
|
|
10211
|
+
* update/set, NO selector hook. Hook synthesis is ui-renderer's (the one
|
|
10212
|
+
* uSES bridge, cached per source at the binding site).
|
|
10213
|
+
*/
|
|
10214
|
+
/**
|
|
10215
|
+
* Notify an observer set without allowing one callback to starve the rest.
|
|
10216
|
+
* @param listeners - current observer callbacks; copied before dispatch.
|
|
10217
|
+
* @param label - diagnostic owner prefix.
|
|
10218
|
+
* @param args - callback arguments.
|
|
10219
|
+
*/
|
|
10220
|
+
function notifySubscribers(listeners, label, ...args) {
|
|
10221
|
+
for (const listener of [...listeners]) try {
|
|
10222
|
+
listener(...args);
|
|
10223
|
+
} catch (error) {
|
|
10224
|
+
console.error(`${label} subscriber failed:`, error);
|
|
10225
|
+
}
|
|
10226
|
+
}
|
|
10227
|
+
/**
|
|
10228
|
+
* Shallow equality for selector slices (zustand/shallow semantics; travels
|
|
10229
|
+
* with the engine so hook consumers need no zustand dependency).
|
|
10230
|
+
* @param a - left value.
|
|
10231
|
+
* @param b - right value.
|
|
10232
|
+
* @returns whether the values are shallowly equal.
|
|
10233
|
+
*/
|
|
10234
|
+
function shallowEqual(a, b) {
|
|
10235
|
+
return shallow$1(a, b);
|
|
10236
|
+
}
|
|
10237
|
+
/** Batches subscriber notification into one flush per animation frame. */
|
|
10238
|
+
function rafBatch(notify) {
|
|
10239
|
+
const schedule = typeof requestAnimationFrame === "function" ? (fn) => {
|
|
10240
|
+
requestAnimationFrame(() => {
|
|
10241
|
+
fn();
|
|
10242
|
+
});
|
|
10243
|
+
} : (fn) => {
|
|
10244
|
+
queueMicrotask(fn);
|
|
10245
|
+
};
|
|
10246
|
+
let scheduled = false;
|
|
10247
|
+
return () => {
|
|
10248
|
+
if (scheduled) return;
|
|
10249
|
+
scheduled = true;
|
|
10250
|
+
schedule(() => {
|
|
10251
|
+
scheduled = false;
|
|
10252
|
+
notify();
|
|
10253
|
+
});
|
|
10254
|
+
};
|
|
10255
|
+
}
|
|
10256
|
+
/**
|
|
10257
|
+
* Create a snapshot store.
|
|
10258
|
+
*
|
|
10259
|
+
* Flush default is 'sync' (controlled inputs need same-tick echo); frame-driven
|
|
10260
|
+
* stores opt into 'raf', where a frame's worth of updates coalesces into one
|
|
10261
|
+
* notification. Known raf-mode tradeoff: a component mounting mid-frame reads
|
|
10262
|
+
* fresh state while existing subscribers hear it next flush — transient
|
|
10263
|
+
* frame-level skew, same nature as the object layer's microtask batching.
|
|
10264
|
+
*
|
|
10265
|
+
* @param init - initial state.
|
|
10266
|
+
* @param opts - flush mode and opt-in persistence (localStorage, keyed by name).
|
|
10267
|
+
* @returns the store.
|
|
10268
|
+
*/
|
|
10269
|
+
function createSnapshotStore(init, opts) {
|
|
10270
|
+
const withSelector = subscribeWithSelector(() => init);
|
|
10271
|
+
const api = createStore()(withSelector);
|
|
10272
|
+
if (opts?.persist) attachPersistence(api, opts.persist.name);
|
|
10273
|
+
let subscribe = (fn) => api.subscribe(() => {
|
|
10274
|
+
notifySubscribers([fn], "[client-store]");
|
|
10275
|
+
});
|
|
10276
|
+
if (opts?.flush === "raf") {
|
|
10277
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
10278
|
+
const flush = rafBatch(() => {
|
|
10279
|
+
notifySubscribers(listeners, "[client-store]");
|
|
10280
|
+
});
|
|
10281
|
+
api.subscribe(flush);
|
|
10282
|
+
subscribe = (fn) => {
|
|
10283
|
+
listeners.add(fn);
|
|
10284
|
+
return () => {
|
|
10285
|
+
listeners.delete(fn);
|
|
10286
|
+
};
|
|
10287
|
+
};
|
|
10288
|
+
}
|
|
10289
|
+
return {
|
|
10290
|
+
getSnapshot: () => api.getState(),
|
|
10291
|
+
subscribe: (fn) => subscribe(fn),
|
|
10292
|
+
update: (mutator) => {
|
|
10293
|
+
api.setState(produce(api.getState(), (draft) => {
|
|
10294
|
+
mutator(draft);
|
|
10295
|
+
}), true);
|
|
10296
|
+
},
|
|
10297
|
+
set: (next) => {
|
|
10298
|
+
api.setState(devFreeze(next), true);
|
|
10299
|
+
}
|
|
10300
|
+
};
|
|
10301
|
+
}
|
|
10302
|
+
/**
|
|
10303
|
+
* Whole-value JSON persistence to localStorage. Hand-rolled instead of the
|
|
10304
|
+
* zustand persist middleware: its write path spreads state into an object
|
|
10305
|
+
* (`partialize({ ...get() })`), exploding primitive state (a persisted string
|
|
10306
|
+
* draft becomes {0:'h',1:'e',...}) — not fixable via merge/deserialize options
|
|
10307
|
+
* because the corruption happens before serialization. Storage failures
|
|
10308
|
+
* (quota, private mode) only disable persistence, never break the store.
|
|
10309
|
+
*/
|
|
10310
|
+
function attachPersistence(api, name) {
|
|
10311
|
+
if (typeof localStorage === "undefined") return;
|
|
10312
|
+
try {
|
|
10313
|
+
const raw = localStorage.getItem(name);
|
|
10314
|
+
if (raw !== null) api.setState(devFreeze(JSON.parse(raw)), true);
|
|
10315
|
+
} catch (error) {
|
|
10316
|
+
console.error(`snapshot store '${name}' rehydration failed:`, error);
|
|
10317
|
+
}
|
|
10318
|
+
api.subscribe((state) => {
|
|
10319
|
+
try {
|
|
10320
|
+
localStorage.setItem(name, JSON.stringify(state));
|
|
10321
|
+
} catch (error) {
|
|
10322
|
+
console.error(`snapshot store '${name}' persistence failed:`, error);
|
|
10323
|
+
}
|
|
10324
|
+
});
|
|
10325
|
+
}
|
|
10326
|
+
/** Deep-freeze draftable wholesale-set state outside production: set() bypasses immer's freeze. */
|
|
10327
|
+
function devFreeze(value) {
|
|
10328
|
+
return value;
|
|
10329
|
+
}
|
|
10330
|
+
/**
|
|
10331
|
+
* Declare a store: initial state, optional persistence, and the full write
|
|
10332
|
+
* set as pure draft mutators. The returned handle is the registration
|
|
10333
|
+
* currency of the store seat — its identity keys instance sharing. Satisfies
|
|
10334
|
+
* ui-slots' DefineStore contract (the handle/instance are the engine-extended
|
|
10335
|
+
* subtypes).
|
|
10336
|
+
*
|
|
10337
|
+
* The `A & ActionsDecl<T>` actions position is load-bearing: T resolves from
|
|
10338
|
+
* `init` in the first inference round, and the intersection then contextually
|
|
10339
|
+
* types each mutator's draft parameter (context-sensitive functions defer),
|
|
10340
|
+
* so call sites write `(d, x: X) => { ... }` with no draft annotation. If a
|
|
10341
|
+
* future TS version breaks this single-literal inference, the design's
|
|
10342
|
+
* documented fallback is currying (`defineStore(init).actions({...})`).
|
|
10343
|
+
* @param decl - init lambda (fresh state per instance), optional persist key, actions table.
|
|
10344
|
+
* @returns the store handle.
|
|
10345
|
+
*/
|
|
10346
|
+
function defineStore(decl) {
|
|
10347
|
+
return {
|
|
10348
|
+
spec: decl,
|
|
10349
|
+
create(scopeKey) {
|
|
10350
|
+
const persistKey = decl.persist === void 0 ? void 0 : scopeKey === void 0 ? decl.persist : `${decl.persist}.${scopeKey}`;
|
|
10351
|
+
const store = createSnapshotStore(decl.init(), persistKey !== void 0 ? { persist: { name: persistKey } } : void 0);
|
|
10352
|
+
const actions = {};
|
|
10353
|
+
for (const key of Object.keys(decl.actions)) {
|
|
10354
|
+
const mutate = decl.actions[key];
|
|
10355
|
+
actions[key] = (...params) => {
|
|
10356
|
+
store.update((draft) => {
|
|
10357
|
+
mutate(draft, ...params);
|
|
10358
|
+
});
|
|
10359
|
+
};
|
|
10360
|
+
}
|
|
10361
|
+
return {
|
|
10362
|
+
actions,
|
|
10363
|
+
getSnapshot: () => store.getSnapshot(),
|
|
10364
|
+
subscribe: (fn) => store.subscribe(fn),
|
|
10365
|
+
store,
|
|
10366
|
+
clearPersisted: () => {
|
|
10367
|
+
if (persistKey === void 0 || typeof localStorage === "undefined") return;
|
|
10368
|
+
try {
|
|
10369
|
+
localStorage.removeItem(persistKey);
|
|
10370
|
+
} catch {}
|
|
10371
|
+
}
|
|
10372
|
+
};
|
|
10373
|
+
}
|
|
10374
|
+
};
|
|
10375
|
+
}
|
|
10376
|
+
//#endregion
|
|
9557
10377
|
//#region src/app/remote/client-runtime.ts
|
|
9558
10378
|
/**
|
|
9559
10379
|
* Experimental official Client runtime composition (M3-1).
|
|
@@ -9620,7 +10440,10 @@ const EXPECTED_REGISTRATION_IDS = OFFICIAL_CLIENT_BUNDLES.map((bundle) => bundle
|
|
|
9620
10440
|
* package graph. `@deepseek-ai/cordis` is imported directly by this module and
|
|
9621
10441
|
* therefore already resolves normally.
|
|
9622
10442
|
*/
|
|
9623
|
-
|
|
10443
|
+
/** The ONE platform static module table the official `/client` bundle loader
|
|
10444
|
+
* receives. Exported only as a module-internal seam (never a package export)
|
|
10445
|
+
* so the L5 contract test can prove every factory sees the same namespace. */
|
|
10446
|
+
const CLIENT_PLATFORM_MODULES = { "@deepseek-ai/dsh-client-store": lib_exports };
|
|
9624
10447
|
/** The loader's bare-dependency resolver: platform statics first, then the
|
|
9625
10448
|
* CALLER's installation resolver. The real Client passes the DSH anchor
|
|
9626
10449
|
* resolver so every non-platform dependency of a browser-form bundle also
|